]> git.ipfire.org Git - thirdparty/grsecurity-scrape.git/blob - test/grsecurity-2.9.1-3.8.4-201303221826.patch
Auto commit, 1 new patch{es}.
[thirdparty/grsecurity-scrape.git] / test / grsecurity-2.9.1-3.8.4-201303221826.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 e20f162..11365cc 100644
263 --- a/Makefile
264 +++ b/Makefile
265 @@ -241,8 +241,9 @@ CONFIG_SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \
266
267 HOSTCC = gcc
268 HOSTCXX = g++
269 -HOSTCFLAGS = -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 -fomit-frame-pointer
270 -HOSTCXXFLAGS = -O2
271 +HOSTCFLAGS = -Wall -W -Wmissing-prototypes -Wstrict-prototypes -Wno-unused-parameter -Wno-missing-field-initializers -O2 -fomit-frame-pointer -fno-delete-null-pointer-checks
272 +HOSTCLFAGS += $(call cc-option, -Wno-empty-body)
273 +HOSTCXXFLAGS = -O2 -Wall -W -fno-delete-null-pointer-checks
274
275 # Decide whether to build built-in, modular, or both.
276 # Normally, just do built-in.
277 @@ -414,8 +415,8 @@ export RCS_TAR_IGNORE := --exclude SCCS --exclude BitKeeper --exclude .svn \
278 # Rules shared between *config targets and build targets
279
280 # Basic helpers built in scripts/
281 -PHONY += scripts_basic
282 -scripts_basic:
283 +PHONY += scripts_basic gcc-plugins
284 +scripts_basic: gcc-plugins
285 $(Q)$(MAKE) $(build)=scripts/basic
286 $(Q)rm -f .tmp_quiet_recordmcount
287
288 @@ -575,6 +576,62 @@ 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 +ifndef CONFIG_UML
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 +GCC_PLUGINS_CFLAGS := $(CONSTIFY_PLUGIN_CFLAGS) $(STACKLEAK_PLUGIN_CFLAGS) $(KALLOCSTAT_PLUGIN_CFLAGS)
327 +GCC_PLUGINS_CFLAGS += $(KERNEXEC_PLUGIN_CFLAGS) $(CHECKER_PLUGIN_CFLAGS) $(COLORIZE_PLUGIN_CFLAGS)
328 +GCC_PLUGINS_CFLAGS += $(SIZE_OVERFLOW_PLUGIN_CFLAGS) $(LATENT_ENTROPY_PLUGIN_CFLAGS)
329 +GCC_PLUGINS_AFLAGS := $(KERNEXEC_PLUGIN_AFLAGS)
330 +export PLUGINCC GCC_PLUGINS_CFLAGS GCC_PLUGINS_AFLAGS CONSTIFY_PLUGIN
331 +ifeq ($(KBUILD_EXTMOD),)
332 +gcc-plugins:
333 + $(Q)$(MAKE) $(build)=tools/gcc
334 +else
335 +gcc-plugins: ;
336 +endif
337 +else
338 +gcc-plugins:
339 +ifeq ($(call cc-ifversion, -ge, 0405, y), y)
340 + $(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.))
341 +else
342 + $(Q)echo "warning, your gcc version does not support plugins, you should upgrade it to gcc 4.5 at least"
343 +endif
344 + $(Q)echo "PAX_MEMORY_STACKLEAK, constification, PAX_LATENT_ENTROPY and other features will be less secure. PAX_SIZE_OVERFLOW will not be active."
345 +endif
346 +endif
347 +
348 include $(srctree)/arch/$(SRCARCH)/Makefile
349
350 ifdef CONFIG_READABLE_ASM
351 @@ -731,7 +788,7 @@ export mod_sign_cmd
352
353
354 ifeq ($(KBUILD_EXTMOD),)
355 -core-y += kernel/ mm/ fs/ ipc/ security/ crypto/ block/
356 +core-y += kernel/ mm/ fs/ ipc/ security/ crypto/ block/ grsecurity/
357
358 vmlinux-dirs := $(patsubst %/,%,$(filter %/, $(init-y) $(init-m) \
359 $(core-y) $(core-m) $(drivers-y) $(drivers-m) \
360 @@ -778,6 +835,8 @@ endif
361
362 # The actual objects are generated when descending,
363 # make sure no implicit rule kicks in
364 +$(filter-out $(init-y),$(vmlinux-deps)): KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
365 +$(filter-out $(init-y),$(vmlinux-deps)): KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
366 $(sort $(vmlinux-deps)): $(vmlinux-dirs) ;
367
368 # Handle descending into subdirectories listed in $(vmlinux-dirs)
369 @@ -787,7 +846,7 @@ $(sort $(vmlinux-deps)): $(vmlinux-dirs) ;
370 # Error messages still appears in the original language
371
372 PHONY += $(vmlinux-dirs)
373 -$(vmlinux-dirs): prepare scripts
374 +$(vmlinux-dirs): gcc-plugins prepare scripts
375 $(Q)$(MAKE) $(build)=$@
376
377 # Store (new) KERNELRELASE string in include/config/kernel.release
378 @@ -831,6 +890,7 @@ prepare0: archprepare FORCE
379 $(Q)$(MAKE) $(build)=.
380
381 # All the preparing..
382 +prepare: KBUILD_CFLAGS := $(filter-out $(GCC_PLUGINS_CFLAGS),$(KBUILD_CFLAGS))
383 prepare: prepare0
384
385 # Generate some files
386 @@ -938,6 +998,8 @@ all: modules
387 # using awk while concatenating to the final file.
388
389 PHONY += modules
390 +modules: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
391 +modules: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
392 modules: $(vmlinux-dirs) $(if $(KBUILD_BUILTIN),vmlinux) modules.builtin
393 $(Q)$(AWK) '!x[$$0]++' $(vmlinux-dirs:%=$(objtree)/%/modules.order) > $(objtree)/modules.order
394 @$(kecho) ' Building modules, stage 2.';
395 @@ -953,7 +1015,7 @@ modules.builtin: $(vmlinux-dirs:%=%/modules.builtin)
396
397 # Target to prepare building external modules
398 PHONY += modules_prepare
399 -modules_prepare: prepare scripts
400 +modules_prepare: gcc-plugins prepare scripts
401
402 # Target to install modules
403 PHONY += modules_install
404 @@ -1019,7 +1081,7 @@ MRPROPER_FILES += .config .config.old .version .old_version $(version_h) \
405 Module.symvers tags TAGS cscope* GPATH GTAGS GRTAGS GSYMS \
406 signing_key.priv signing_key.x509 x509.genkey \
407 extra_certificates signing_key.x509.keyid \
408 - signing_key.x509.signer
409 + signing_key.x509.signer tools/gcc/size_overflow_hash.h
410
411 # clean - Delete most, but leave enough to build external modules
412 #
413 @@ -1059,6 +1121,7 @@ distclean: mrproper
414 \( -name '*.orig' -o -name '*.rej' -o -name '*~' \
415 -o -name '*.bak' -o -name '#*#' -o -name '.*.orig' \
416 -o -name '.*.rej' \
417 + -o -name '.*.rej' -o -name '*.so' \
418 -o -name '*%' -o -name '.*.cmd' -o -name 'core' \) \
419 -type f -print | xargs rm -f
420
421 @@ -1219,6 +1282,8 @@ PHONY += $(module-dirs) modules
422 $(module-dirs): crmodverdir $(objtree)/Module.symvers
423 $(Q)$(MAKE) $(build)=$(patsubst _module_%,%,$@)
424
425 +modules: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
426 +modules: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
427 modules: $(module-dirs)
428 @$(kecho) ' Building modules, stage 2.';
429 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost
430 @@ -1355,17 +1420,21 @@ else
431 target-dir = $(if $(KBUILD_EXTMOD),$(dir $<),$(dir $@))
432 endif
433
434 -%.s: %.c prepare scripts FORCE
435 +%.s: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
436 +%.s: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
437 +%.s: %.c gcc-plugins prepare scripts FORCE
438 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
439 %.i: %.c prepare scripts FORCE
440 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
441 -%.o: %.c prepare scripts FORCE
442 +%.o: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
443 +%.o: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
444 +%.o: %.c gcc-plugins prepare scripts FORCE
445 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
446 %.lst: %.c prepare scripts FORCE
447 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
448 -%.s: %.S prepare scripts FORCE
449 +%.s: %.S gcc-plugins prepare scripts FORCE
450 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
451 -%.o: %.S prepare scripts FORCE
452 +%.o: %.S gcc-plugins prepare scripts FORCE
453 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
454 %.symtypes: %.c prepare scripts FORCE
455 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
456 @@ -1375,11 +1444,15 @@ endif
457 $(cmd_crmodverdir)
458 $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \
459 $(build)=$(build-dir)
460 -%/: prepare scripts FORCE
461 +%/: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
462 +%/: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
463 +%/: gcc-plugins prepare scripts FORCE
464 $(cmd_crmodverdir)
465 $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \
466 $(build)=$(build-dir)
467 -%.ko: prepare scripts FORCE
468 +%.ko: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
469 +%.ko: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
470 +%.ko: gcc-plugins prepare scripts FORCE
471 $(cmd_crmodverdir)
472 $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \
473 $(build)=$(build-dir) $(@:.ko=.o)
474 diff --git a/arch/alpha/include/asm/atomic.h b/arch/alpha/include/asm/atomic.h
475 index c2cbe4f..f7264b4 100644
476 --- a/arch/alpha/include/asm/atomic.h
477 +++ b/arch/alpha/include/asm/atomic.h
478 @@ -250,6 +250,16 @@ static __inline__ int atomic64_add_unless(atomic64_t *v, long a, long u)
479 #define atomic_dec(v) atomic_sub(1,(v))
480 #define atomic64_dec(v) atomic64_sub(1,(v))
481
482 +#define atomic64_read_unchecked(v) atomic64_read(v)
483 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
484 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
485 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
486 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
487 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
488 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
489 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
490 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
491 +
492 #define smp_mb__before_atomic_dec() smp_mb()
493 #define smp_mb__after_atomic_dec() smp_mb()
494 #define smp_mb__before_atomic_inc() smp_mb()
495 diff --git a/arch/alpha/include/asm/cache.h b/arch/alpha/include/asm/cache.h
496 index ad368a9..fbe0f25 100644
497 --- a/arch/alpha/include/asm/cache.h
498 +++ b/arch/alpha/include/asm/cache.h
499 @@ -4,19 +4,19 @@
500 #ifndef __ARCH_ALPHA_CACHE_H
501 #define __ARCH_ALPHA_CACHE_H
502
503 +#include <linux/const.h>
504
505 /* Bytes per L1 (data) cache line. */
506 #if defined(CONFIG_ALPHA_GENERIC) || defined(CONFIG_ALPHA_EV6)
507 -# define L1_CACHE_BYTES 64
508 # define L1_CACHE_SHIFT 6
509 #else
510 /* Both EV4 and EV5 are write-through, read-allocate,
511 direct-mapped, physical.
512 */
513 -# define L1_CACHE_BYTES 32
514 # define L1_CACHE_SHIFT 5
515 #endif
516
517 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
518 #define SMP_CACHE_BYTES L1_CACHE_BYTES
519
520 #endif
521 diff --git a/arch/alpha/include/asm/elf.h b/arch/alpha/include/asm/elf.h
522 index 968d999..d36b2df 100644
523 --- a/arch/alpha/include/asm/elf.h
524 +++ b/arch/alpha/include/asm/elf.h
525 @@ -91,6 +91,13 @@ typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
526
527 #define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE + 0x1000000)
528
529 +#ifdef CONFIG_PAX_ASLR
530 +#define PAX_ELF_ET_DYN_BASE (current->personality & ADDR_LIMIT_32BIT ? 0x10000 : 0x120000000UL)
531 +
532 +#define PAX_DELTA_MMAP_LEN (current->personality & ADDR_LIMIT_32BIT ? 14 : 28)
533 +#define PAX_DELTA_STACK_LEN (current->personality & ADDR_LIMIT_32BIT ? 14 : 19)
534 +#endif
535 +
536 /* $0 is set by ld.so to a pointer to a function which might be
537 registered using atexit. This provides a mean for the dynamic
538 linker to call DT_FINI functions for shared libraries that have
539 diff --git a/arch/alpha/include/asm/pgalloc.h b/arch/alpha/include/asm/pgalloc.h
540 index bc2a0da..8ad11ee 100644
541 --- a/arch/alpha/include/asm/pgalloc.h
542 +++ b/arch/alpha/include/asm/pgalloc.h
543 @@ -29,6 +29,12 @@ pgd_populate(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmd)
544 pgd_set(pgd, pmd);
545 }
546
547 +static inline void
548 +pgd_populate_kernel(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmd)
549 +{
550 + pgd_populate(mm, pgd, pmd);
551 +}
552 +
553 extern pgd_t *pgd_alloc(struct mm_struct *mm);
554
555 static inline void
556 diff --git a/arch/alpha/include/asm/pgtable.h b/arch/alpha/include/asm/pgtable.h
557 index 81a4342..348b927 100644
558 --- a/arch/alpha/include/asm/pgtable.h
559 +++ b/arch/alpha/include/asm/pgtable.h
560 @@ -102,6 +102,17 @@ struct vm_area_struct;
561 #define PAGE_SHARED __pgprot(_PAGE_VALID | __ACCESS_BITS)
562 #define PAGE_COPY __pgprot(_PAGE_VALID | __ACCESS_BITS | _PAGE_FOW)
563 #define PAGE_READONLY __pgprot(_PAGE_VALID | __ACCESS_BITS | _PAGE_FOW)
564 +
565 +#ifdef CONFIG_PAX_PAGEEXEC
566 +# define PAGE_SHARED_NOEXEC __pgprot(_PAGE_VALID | __ACCESS_BITS | _PAGE_FOE)
567 +# define PAGE_COPY_NOEXEC __pgprot(_PAGE_VALID | __ACCESS_BITS | _PAGE_FOW | _PAGE_FOE)
568 +# define PAGE_READONLY_NOEXEC __pgprot(_PAGE_VALID | __ACCESS_BITS | _PAGE_FOW | _PAGE_FOE)
569 +#else
570 +# define PAGE_SHARED_NOEXEC PAGE_SHARED
571 +# define PAGE_COPY_NOEXEC PAGE_COPY
572 +# define PAGE_READONLY_NOEXEC PAGE_READONLY
573 +#endif
574 +
575 #define PAGE_KERNEL __pgprot(_PAGE_VALID | _PAGE_ASM | _PAGE_KRE | _PAGE_KWE)
576
577 #define _PAGE_NORMAL(x) __pgprot(_PAGE_VALID | __ACCESS_BITS | (x))
578 diff --git a/arch/alpha/kernel/module.c b/arch/alpha/kernel/module.c
579 index 2fd00b7..cfd5069 100644
580 --- a/arch/alpha/kernel/module.c
581 +++ b/arch/alpha/kernel/module.c
582 @@ -160,7 +160,7 @@ apply_relocate_add(Elf64_Shdr *sechdrs, const char *strtab,
583
584 /* The small sections were sorted to the end of the segment.
585 The following should definitely cover them. */
586 - gp = (u64)me->module_core + me->core_size - 0x8000;
587 + gp = (u64)me->module_core_rw + me->core_size_rw - 0x8000;
588 got = sechdrs[me->arch.gotsecindex].sh_addr;
589
590 for (i = 0; i < n; i++) {
591 diff --git a/arch/alpha/kernel/osf_sys.c b/arch/alpha/kernel/osf_sys.c
592 index 14db93e..47bed62 100644
593 --- a/arch/alpha/kernel/osf_sys.c
594 +++ b/arch/alpha/kernel/osf_sys.c
595 @@ -1295,16 +1295,16 @@ SYSCALL_DEFINE1(old_adjtimex, struct timex32 __user *, txc_p)
596 generic version except that we know how to honor ADDR_LIMIT_32BIT. */
597
598 static unsigned long
599 -arch_get_unmapped_area_1(unsigned long addr, unsigned long len,
600 - unsigned long limit)
601 +arch_get_unmapped_area_1(struct file *filp, unsigned long addr, unsigned long len,
602 + unsigned long limit, unsigned long flags)
603 {
604 struct vm_area_struct *vma = find_vma(current->mm, addr);
605 -
606 + unsigned long offset = gr_rand_threadstack_offset(current->mm, filp, flags);
607 while (1) {
608 /* At this point: (!vma || addr < vma->vm_end). */
609 if (limit - len < addr)
610 return -ENOMEM;
611 - if (!vma || addr + len <= vma->vm_start)
612 + if (check_heap_stack_gap(vma, addr, len, offset))
613 return addr;
614 addr = vma->vm_end;
615 vma = vma->vm_next;
616 @@ -1340,20 +1340,24 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
617 merely specific addresses, but regions of memory -- perhaps
618 this feature should be incorporated into all ports? */
619
620 +#ifdef CONFIG_PAX_RANDMMAP
621 + if (!(current->mm->pax_flags & MF_PAX_RANDMMAP))
622 +#endif
623 +
624 if (addr) {
625 - addr = arch_get_unmapped_area_1 (PAGE_ALIGN(addr), len, limit);
626 + addr = arch_get_unmapped_area_1 (filp, PAGE_ALIGN(addr), len, limit, flags);
627 if (addr != (unsigned long) -ENOMEM)
628 return addr;
629 }
630
631 /* Next, try allocating at TASK_UNMAPPED_BASE. */
632 - addr = arch_get_unmapped_area_1 (PAGE_ALIGN(TASK_UNMAPPED_BASE),
633 - len, limit);
634 + addr = arch_get_unmapped_area_1 (filp, PAGE_ALIGN(current->mm->mmap_base), len, limit, flags);
635 +
636 if (addr != (unsigned long) -ENOMEM)
637 return addr;
638
639 /* Finally, try allocating in low memory. */
640 - addr = arch_get_unmapped_area_1 (PAGE_SIZE, len, limit);
641 + addr = arch_get_unmapped_area_1 (filp, PAGE_SIZE, len, limit, flags);
642
643 return addr;
644 }
645 diff --git a/arch/alpha/mm/fault.c b/arch/alpha/mm/fault.c
646 index 0c4132d..88f0d53 100644
647 --- a/arch/alpha/mm/fault.c
648 +++ b/arch/alpha/mm/fault.c
649 @@ -53,6 +53,124 @@ __load_new_mm_context(struct mm_struct *next_mm)
650 __reload_thread(pcb);
651 }
652
653 +#ifdef CONFIG_PAX_PAGEEXEC
654 +/*
655 + * PaX: decide what to do with offenders (regs->pc = fault address)
656 + *
657 + * returns 1 when task should be killed
658 + * 2 when patched PLT trampoline was detected
659 + * 3 when unpatched PLT trampoline was detected
660 + */
661 +static int pax_handle_fetch_fault(struct pt_regs *regs)
662 +{
663 +
664 +#ifdef CONFIG_PAX_EMUPLT
665 + int err;
666 +
667 + do { /* PaX: patched PLT emulation #1 */
668 + unsigned int ldah, ldq, jmp;
669 +
670 + err = get_user(ldah, (unsigned int *)regs->pc);
671 + err |= get_user(ldq, (unsigned int *)(regs->pc+4));
672 + err |= get_user(jmp, (unsigned int *)(regs->pc+8));
673 +
674 + if (err)
675 + break;
676 +
677 + if ((ldah & 0xFFFF0000U) == 0x277B0000U &&
678 + (ldq & 0xFFFF0000U) == 0xA77B0000U &&
679 + jmp == 0x6BFB0000U)
680 + {
681 + unsigned long r27, addr;
682 + unsigned long addrh = (ldah | 0xFFFFFFFFFFFF0000UL) << 16;
683 + unsigned long addrl = ldq | 0xFFFFFFFFFFFF0000UL;
684 +
685 + addr = regs->r27 + ((addrh ^ 0x80000000UL) + 0x80000000UL) + ((addrl ^ 0x8000UL) + 0x8000UL);
686 + err = get_user(r27, (unsigned long *)addr);
687 + if (err)
688 + break;
689 +
690 + regs->r27 = r27;
691 + regs->pc = r27;
692 + return 2;
693 + }
694 + } while (0);
695 +
696 + do { /* PaX: patched PLT emulation #2 */
697 + unsigned int ldah, lda, br;
698 +
699 + err = get_user(ldah, (unsigned int *)regs->pc);
700 + err |= get_user(lda, (unsigned int *)(regs->pc+4));
701 + err |= get_user(br, (unsigned int *)(regs->pc+8));
702 +
703 + if (err)
704 + break;
705 +
706 + if ((ldah & 0xFFFF0000U) == 0x277B0000U &&
707 + (lda & 0xFFFF0000U) == 0xA77B0000U &&
708 + (br & 0xFFE00000U) == 0xC3E00000U)
709 + {
710 + unsigned long addr = br | 0xFFFFFFFFFFE00000UL;
711 + unsigned long addrh = (ldah | 0xFFFFFFFFFFFF0000UL) << 16;
712 + unsigned long addrl = lda | 0xFFFFFFFFFFFF0000UL;
713 +
714 + regs->r27 += ((addrh ^ 0x80000000UL) + 0x80000000UL) + ((addrl ^ 0x8000UL) + 0x8000UL);
715 + regs->pc += 12 + (((addr ^ 0x00100000UL) + 0x00100000UL) << 2);
716 + return 2;
717 + }
718 + } while (0);
719 +
720 + do { /* PaX: unpatched PLT emulation */
721 + unsigned int br;
722 +
723 + err = get_user(br, (unsigned int *)regs->pc);
724 +
725 + if (!err && (br & 0xFFE00000U) == 0xC3800000U) {
726 + unsigned int br2, ldq, nop, jmp;
727 + unsigned long addr = br | 0xFFFFFFFFFFE00000UL, resolver;
728 +
729 + addr = regs->pc + 4 + (((addr ^ 0x00100000UL) + 0x00100000UL) << 2);
730 + err = get_user(br2, (unsigned int *)addr);
731 + err |= get_user(ldq, (unsigned int *)(addr+4));
732 + err |= get_user(nop, (unsigned int *)(addr+8));
733 + err |= get_user(jmp, (unsigned int *)(addr+12));
734 + err |= get_user(resolver, (unsigned long *)(addr+16));
735 +
736 + if (err)
737 + break;
738 +
739 + if (br2 == 0xC3600000U &&
740 + ldq == 0xA77B000CU &&
741 + nop == 0x47FF041FU &&
742 + jmp == 0x6B7B0000U)
743 + {
744 + regs->r28 = regs->pc+4;
745 + regs->r27 = addr+16;
746 + regs->pc = resolver;
747 + return 3;
748 + }
749 + }
750 + } while (0);
751 +#endif
752 +
753 + return 1;
754 +}
755 +
756 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
757 +{
758 + unsigned long i;
759 +
760 + printk(KERN_ERR "PAX: bytes at PC: ");
761 + for (i = 0; i < 5; i++) {
762 + unsigned int c;
763 + if (get_user(c, (unsigned int *)pc+i))
764 + printk(KERN_CONT "???????? ");
765 + else
766 + printk(KERN_CONT "%08x ", c);
767 + }
768 + printk("\n");
769 +}
770 +#endif
771
772 /*
773 * This routine handles page faults. It determines the address,
774 @@ -133,8 +251,29 @@ retry:
775 good_area:
776 si_code = SEGV_ACCERR;
777 if (cause < 0) {
778 - if (!(vma->vm_flags & VM_EXEC))
779 + if (!(vma->vm_flags & VM_EXEC)) {
780 +
781 +#ifdef CONFIG_PAX_PAGEEXEC
782 + if (!(mm->pax_flags & MF_PAX_PAGEEXEC) || address != regs->pc)
783 + goto bad_area;
784 +
785 + up_read(&mm->mmap_sem);
786 + switch (pax_handle_fetch_fault(regs)) {
787 +
788 +#ifdef CONFIG_PAX_EMUPLT
789 + case 2:
790 + case 3:
791 + return;
792 +#endif
793 +
794 + }
795 + pax_report_fault(regs, (void *)regs->pc, (void *)rdusp());
796 + do_group_exit(SIGKILL);
797 +#else
798 goto bad_area;
799 +#endif
800 +
801 + }
802 } else if (!cause) {
803 /* Allow reads even for write-only mappings */
804 if (!(vma->vm_flags & (VM_READ | VM_WRITE)))
805 diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
806 index 67874b8..0e40765 100644
807 --- a/arch/arm/Kconfig
808 +++ b/arch/arm/Kconfig
809 @@ -1813,7 +1813,7 @@ config ALIGNMENT_TRAP
810
811 config UACCESS_WITH_MEMCPY
812 bool "Use kernel mem{cpy,set}() for {copy_to,clear}_user()"
813 - depends on MMU
814 + depends on MMU && !PAX_MEMORY_UDEREF
815 default y if CPU_FEROCEON
816 help
817 Implement faster copy_to_user and clear_user methods for CPU
818 diff --git a/arch/arm/common/gic.c b/arch/arm/common/gic.c
819 index 87dfa902..3a523fc 100644
820 --- a/arch/arm/common/gic.c
821 +++ b/arch/arm/common/gic.c
822 @@ -81,7 +81,7 @@ static u8 gic_cpu_map[NR_GIC_CPU_IF] __read_mostly;
823 * Supported arch specific GIC irq extension.
824 * Default make them NULL.
825 */
826 -struct irq_chip gic_arch_extn = {
827 +irq_chip_no_const gic_arch_extn __read_only = {
828 .irq_eoi = NULL,
829 .irq_mask = NULL,
830 .irq_unmask = NULL,
831 @@ -329,7 +329,7 @@ static void gic_handle_cascade_irq(unsigned int irq, struct irq_desc *desc)
832 chained_irq_exit(chip, desc);
833 }
834
835 -static struct irq_chip gic_chip = {
836 +static irq_chip_no_const gic_chip __read_only = {
837 .name = "GIC",
838 .irq_mask = gic_mask_irq,
839 .irq_unmask = gic_unmask_irq,
840 diff --git a/arch/arm/include/asm/atomic.h b/arch/arm/include/asm/atomic.h
841 index c79f61f..9ac0642 100644
842 --- a/arch/arm/include/asm/atomic.h
843 +++ b/arch/arm/include/asm/atomic.h
844 @@ -17,17 +17,35 @@
845 #include <asm/barrier.h>
846 #include <asm/cmpxchg.h>
847
848 +#ifdef CONFIG_GENERIC_ATOMIC64
849 +#include <asm-generic/atomic64.h>
850 +#endif
851 +
852 #define ATOMIC_INIT(i) { (i) }
853
854 #ifdef __KERNEL__
855
856 +#define _ASM_EXTABLE(from, to) \
857 +" .pushsection __ex_table,\"a\"\n"\
858 +" .align 3\n" \
859 +" .long " #from ", " #to"\n" \
860 +" .popsection"
861 +
862 /*
863 * On ARM, ordinary assignment (str instruction) doesn't clear the local
864 * strex/ldrex monitor on some implementations. The reason we can use it for
865 * atomic_set() is the clrex or dummy strex done on every exception return.
866 */
867 #define atomic_read(v) (*(volatile int *)&(v)->counter)
868 +static inline int atomic_read_unchecked(const atomic_unchecked_t *v)
869 +{
870 + return v->counter;
871 +}
872 #define atomic_set(v,i) (((v)->counter) = (i))
873 +static inline void atomic_set_unchecked(atomic_unchecked_t *v, int i)
874 +{
875 + v->counter = i;
876 +}
877
878 #if __LINUX_ARM_ARCH__ >= 6
879
880 @@ -42,6 +60,35 @@ static inline void atomic_add(int i, atomic_t *v)
881 int result;
882
883 __asm__ __volatile__("@ atomic_add\n"
884 +"1: ldrex %1, [%3]\n"
885 +" adds %0, %1, %4\n"
886 +
887 +#ifdef CONFIG_PAX_REFCOUNT
888 +" bvc 3f\n"
889 +"2: bkpt 0xf103\n"
890 +"3:\n"
891 +#endif
892 +
893 +" strex %1, %0, [%3]\n"
894 +" teq %1, #0\n"
895 +" bne 1b"
896 +
897 +#ifdef CONFIG_PAX_REFCOUNT
898 +"\n4:\n"
899 + _ASM_EXTABLE(2b, 4b)
900 +#endif
901 +
902 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
903 + : "r" (&v->counter), "Ir" (i)
904 + : "cc");
905 +}
906 +
907 +static inline void atomic_add_unchecked(int i, atomic_unchecked_t *v)
908 +{
909 + unsigned long tmp;
910 + int result;
911 +
912 + __asm__ __volatile__("@ atomic_add_unchecked\n"
913 "1: ldrex %0, [%3]\n"
914 " add %0, %0, %4\n"
915 " strex %1, %0, [%3]\n"
916 @@ -60,6 +107,42 @@ static inline int atomic_add_return(int i, atomic_t *v)
917 smp_mb();
918
919 __asm__ __volatile__("@ atomic_add_return\n"
920 +"1: ldrex %1, [%3]\n"
921 +" adds %0, %1, %4\n"
922 +
923 +#ifdef CONFIG_PAX_REFCOUNT
924 +" bvc 3f\n"
925 +" mov %0, %1\n"
926 +"2: bkpt 0xf103\n"
927 +"3:\n"
928 +#endif
929 +
930 +" strex %1, %0, [%3]\n"
931 +" teq %1, #0\n"
932 +" bne 1b"
933 +
934 +#ifdef CONFIG_PAX_REFCOUNT
935 +"\n4:\n"
936 + _ASM_EXTABLE(2b, 4b)
937 +#endif
938 +
939 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
940 + : "r" (&v->counter), "Ir" (i)
941 + : "cc");
942 +
943 + smp_mb();
944 +
945 + return result;
946 +}
947 +
948 +static inline int atomic_add_return_unchecked(int i, atomic_unchecked_t *v)
949 +{
950 + unsigned long tmp;
951 + int result;
952 +
953 + smp_mb();
954 +
955 + __asm__ __volatile__("@ atomic_add_return_unchecked\n"
956 "1: ldrex %0, [%3]\n"
957 " add %0, %0, %4\n"
958 " strex %1, %0, [%3]\n"
959 @@ -80,6 +163,35 @@ static inline void atomic_sub(int i, atomic_t *v)
960 int result;
961
962 __asm__ __volatile__("@ atomic_sub\n"
963 +"1: ldrex %1, [%3]\n"
964 +" subs %0, %1, %4\n"
965 +
966 +#ifdef CONFIG_PAX_REFCOUNT
967 +" bvc 3f\n"
968 +"2: bkpt 0xf103\n"
969 +"3:\n"
970 +#endif
971 +
972 +" strex %1, %0, [%3]\n"
973 +" teq %1, #0\n"
974 +" bne 1b"
975 +
976 +#ifdef CONFIG_PAX_REFCOUNT
977 +"\n4:\n"
978 + _ASM_EXTABLE(2b, 4b)
979 +#endif
980 +
981 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
982 + : "r" (&v->counter), "Ir" (i)
983 + : "cc");
984 +}
985 +
986 +static inline void atomic_sub_unchecked(int i, atomic_unchecked_t *v)
987 +{
988 + unsigned long tmp;
989 + int result;
990 +
991 + __asm__ __volatile__("@ atomic_sub_unchecked\n"
992 "1: ldrex %0, [%3]\n"
993 " sub %0, %0, %4\n"
994 " strex %1, %0, [%3]\n"
995 @@ -98,11 +210,25 @@ static inline int atomic_sub_return(int i, atomic_t *v)
996 smp_mb();
997
998 __asm__ __volatile__("@ atomic_sub_return\n"
999 -"1: ldrex %0, [%3]\n"
1000 -" sub %0, %0, %4\n"
1001 +"1: ldrex %1, [%3]\n"
1002 +" subs %0, %1, %4\n"
1003 +
1004 +#ifdef CONFIG_PAX_REFCOUNT
1005 +" bvc 3f\n"
1006 +" mov %0, %1\n"
1007 +"2: bkpt 0xf103\n"
1008 +"3:\n"
1009 +#endif
1010 +
1011 " strex %1, %0, [%3]\n"
1012 " teq %1, #0\n"
1013 " bne 1b"
1014 +
1015 +#ifdef CONFIG_PAX_REFCOUNT
1016 +"\n4:\n"
1017 + _ASM_EXTABLE(2b, 4b)
1018 +#endif
1019 +
1020 : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1021 : "r" (&v->counter), "Ir" (i)
1022 : "cc");
1023 @@ -134,6 +260,28 @@ static inline int atomic_cmpxchg(atomic_t *ptr, int old, int new)
1024 return oldval;
1025 }
1026
1027 +static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *ptr, int old, int new)
1028 +{
1029 + unsigned long oldval, res;
1030 +
1031 + smp_mb();
1032 +
1033 + do {
1034 + __asm__ __volatile__("@ atomic_cmpxchg_unchecked\n"
1035 + "ldrex %1, [%3]\n"
1036 + "mov %0, #0\n"
1037 + "teq %1, %4\n"
1038 + "strexeq %0, %5, [%3]\n"
1039 + : "=&r" (res), "=&r" (oldval), "+Qo" (ptr->counter)
1040 + : "r" (&ptr->counter), "Ir" (old), "r" (new)
1041 + : "cc");
1042 + } while (res);
1043 +
1044 + smp_mb();
1045 +
1046 + return oldval;
1047 +}
1048 +
1049 static inline void atomic_clear_mask(unsigned long mask, unsigned long *addr)
1050 {
1051 unsigned long tmp, tmp2;
1052 @@ -167,7 +315,17 @@ static inline int atomic_add_return(int i, atomic_t *v)
1053
1054 return val;
1055 }
1056 +
1057 +static inline int atomic_add_return_unchecked(int i, atomic_unchecked_t *v)
1058 +{
1059 + return atomic_add_return(i, v);
1060 +}
1061 +
1062 #define atomic_add(i, v) (void) atomic_add_return(i, v)
1063 +static inline void atomic_add_unchecked(int i, atomic_unchecked_t *v)
1064 +{
1065 + (void) atomic_add_return(i, v);
1066 +}
1067
1068 static inline int atomic_sub_return(int i, atomic_t *v)
1069 {
1070 @@ -182,6 +340,10 @@ static inline int atomic_sub_return(int i, atomic_t *v)
1071 return val;
1072 }
1073 #define atomic_sub(i, v) (void) atomic_sub_return(i, v)
1074 +static inline void atomic_sub_unchecked(int i, atomic_unchecked_t *v)
1075 +{
1076 + (void) atomic_sub_return(i, v);
1077 +}
1078
1079 static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
1080 {
1081 @@ -197,6 +359,11 @@ static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
1082 return ret;
1083 }
1084
1085 +static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *v, int old, int new)
1086 +{
1087 + return atomic_cmpxchg(v, old, new);
1088 +}
1089 +
1090 static inline void atomic_clear_mask(unsigned long mask, unsigned long *addr)
1091 {
1092 unsigned long flags;
1093 @@ -209,6 +376,10 @@ static inline void atomic_clear_mask(unsigned long mask, unsigned long *addr)
1094 #endif /* __LINUX_ARM_ARCH__ */
1095
1096 #define atomic_xchg(v, new) (xchg(&((v)->counter), new))
1097 +static inline int atomic_xchg_unchecked(atomic_unchecked_t *v, int new)
1098 +{
1099 + return xchg(&v->counter, new);
1100 +}
1101
1102 static inline int __atomic_add_unless(atomic_t *v, int a, int u)
1103 {
1104 @@ -221,11 +392,27 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
1105 }
1106
1107 #define atomic_inc(v) atomic_add(1, v)
1108 +static inline void atomic_inc_unchecked(atomic_unchecked_t *v)
1109 +{
1110 + atomic_add_unchecked(1, v);
1111 +}
1112 #define atomic_dec(v) atomic_sub(1, v)
1113 +static inline void atomic_dec_unchecked(atomic_unchecked_t *v)
1114 +{
1115 + atomic_sub_unchecked(1, v);
1116 +}
1117
1118 #define atomic_inc_and_test(v) (atomic_add_return(1, v) == 0)
1119 +static inline int atomic_inc_and_test_unchecked(atomic_unchecked_t *v)
1120 +{
1121 + return atomic_add_return_unchecked(1, v) == 0;
1122 +}
1123 #define atomic_dec_and_test(v) (atomic_sub_return(1, v) == 0)
1124 #define atomic_inc_return(v) (atomic_add_return(1, v))
1125 +static inline int atomic_inc_return_unchecked(atomic_unchecked_t *v)
1126 +{
1127 + return atomic_add_return_unchecked(1, v);
1128 +}
1129 #define atomic_dec_return(v) (atomic_sub_return(1, v))
1130 #define atomic_sub_and_test(i, v) (atomic_sub_return(i, v) == 0)
1131
1132 @@ -241,6 +428,14 @@ typedef struct {
1133 u64 __aligned(8) counter;
1134 } atomic64_t;
1135
1136 +#ifdef CONFIG_PAX_REFCOUNT
1137 +typedef struct {
1138 + u64 __aligned(8) counter;
1139 +} atomic64_unchecked_t;
1140 +#else
1141 +typedef atomic64_t atomic64_unchecked_t;
1142 +#endif
1143 +
1144 #define ATOMIC64_INIT(i) { (i) }
1145
1146 static inline u64 atomic64_read(const atomic64_t *v)
1147 @@ -256,6 +451,19 @@ static inline u64 atomic64_read(const atomic64_t *v)
1148 return result;
1149 }
1150
1151 +static inline u64 atomic64_read_unchecked(atomic64_unchecked_t *v)
1152 +{
1153 + u64 result;
1154 +
1155 + __asm__ __volatile__("@ atomic64_read_unchecked\n"
1156 +" ldrexd %0, %H0, [%1]"
1157 + : "=&r" (result)
1158 + : "r" (&v->counter), "Qo" (v->counter)
1159 + );
1160 +
1161 + return result;
1162 +}
1163 +
1164 static inline void atomic64_set(atomic64_t *v, u64 i)
1165 {
1166 u64 tmp;
1167 @@ -270,6 +478,20 @@ static inline void atomic64_set(atomic64_t *v, u64 i)
1168 : "cc");
1169 }
1170
1171 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, u64 i)
1172 +{
1173 + u64 tmp;
1174 +
1175 + __asm__ __volatile__("@ atomic64_set_unchecked\n"
1176 +"1: ldrexd %0, %H0, [%2]\n"
1177 +" strexd %0, %3, %H3, [%2]\n"
1178 +" teq %0, #0\n"
1179 +" bne 1b"
1180 + : "=&r" (tmp), "=Qo" (v->counter)
1181 + : "r" (&v->counter), "r" (i)
1182 + : "cc");
1183 +}
1184 +
1185 static inline void atomic64_add(u64 i, atomic64_t *v)
1186 {
1187 u64 result;
1188 @@ -278,6 +500,36 @@ static inline void atomic64_add(u64 i, atomic64_t *v)
1189 __asm__ __volatile__("@ atomic64_add\n"
1190 "1: ldrexd %0, %H0, [%3]\n"
1191 " adds %0, %0, %4\n"
1192 +" adcs %H0, %H0, %H4\n"
1193 +
1194 +#ifdef CONFIG_PAX_REFCOUNT
1195 +" bvc 3f\n"
1196 +"2: bkpt 0xf103\n"
1197 +"3:\n"
1198 +#endif
1199 +
1200 +" strexd %1, %0, %H0, [%3]\n"
1201 +" teq %1, #0\n"
1202 +" bne 1b"
1203 +
1204 +#ifdef CONFIG_PAX_REFCOUNT
1205 +"\n4:\n"
1206 + _ASM_EXTABLE(2b, 4b)
1207 +#endif
1208 +
1209 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1210 + : "r" (&v->counter), "r" (i)
1211 + : "cc");
1212 +}
1213 +
1214 +static inline void atomic64_add_unchecked(u64 i, atomic64_unchecked_t *v)
1215 +{
1216 + u64 result;
1217 + unsigned long tmp;
1218 +
1219 + __asm__ __volatile__("@ atomic64_add_unchecked\n"
1220 +"1: ldrexd %0, %H0, [%3]\n"
1221 +" adds %0, %0, %4\n"
1222 " adc %H0, %H0, %H4\n"
1223 " strexd %1, %0, %H0, [%3]\n"
1224 " teq %1, #0\n"
1225 @@ -289,12 +541,49 @@ static inline void atomic64_add(u64 i, atomic64_t *v)
1226
1227 static inline u64 atomic64_add_return(u64 i, atomic64_t *v)
1228 {
1229 - u64 result;
1230 - unsigned long tmp;
1231 + u64 result, tmp;
1232
1233 smp_mb();
1234
1235 __asm__ __volatile__("@ atomic64_add_return\n"
1236 +"1: ldrexd %1, %H1, [%3]\n"
1237 +" adds %0, %1, %4\n"
1238 +" adcs %H0, %H1, %H4\n"
1239 +
1240 +#ifdef CONFIG_PAX_REFCOUNT
1241 +" bvc 3f\n"
1242 +" mov %0, %1\n"
1243 +" mov %H0, %H1\n"
1244 +"2: bkpt 0xf103\n"
1245 +"3:\n"
1246 +#endif
1247 +
1248 +" strexd %1, %0, %H0, [%3]\n"
1249 +" teq %1, #0\n"
1250 +" bne 1b"
1251 +
1252 +#ifdef CONFIG_PAX_REFCOUNT
1253 +"\n4:\n"
1254 + _ASM_EXTABLE(2b, 4b)
1255 +#endif
1256 +
1257 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1258 + : "r" (&v->counter), "r" (i)
1259 + : "cc");
1260 +
1261 + smp_mb();
1262 +
1263 + return result;
1264 +}
1265 +
1266 +static inline u64 atomic64_add_return_unchecked(u64 i, atomic64_unchecked_t *v)
1267 +{
1268 + u64 result;
1269 + unsigned long tmp;
1270 +
1271 + smp_mb();
1272 +
1273 + __asm__ __volatile__("@ atomic64_add_return_unchecked\n"
1274 "1: ldrexd %0, %H0, [%3]\n"
1275 " adds %0, %0, %4\n"
1276 " adc %H0, %H0, %H4\n"
1277 @@ -318,6 +607,36 @@ static inline void atomic64_sub(u64 i, atomic64_t *v)
1278 __asm__ __volatile__("@ atomic64_sub\n"
1279 "1: ldrexd %0, %H0, [%3]\n"
1280 " subs %0, %0, %4\n"
1281 +" sbcs %H0, %H0, %H4\n"
1282 +
1283 +#ifdef CONFIG_PAX_REFCOUNT
1284 +" bvc 3f\n"
1285 +"2: bkpt 0xf103\n"
1286 +"3:\n"
1287 +#endif
1288 +
1289 +" strexd %1, %0, %H0, [%3]\n"
1290 +" teq %1, #0\n"
1291 +" bne 1b"
1292 +
1293 +#ifdef CONFIG_PAX_REFCOUNT
1294 +"\n4:\n"
1295 + _ASM_EXTABLE(2b, 4b)
1296 +#endif
1297 +
1298 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1299 + : "r" (&v->counter), "r" (i)
1300 + : "cc");
1301 +}
1302 +
1303 +static inline void atomic64_sub_unchecked(u64 i, atomic64_unchecked_t *v)
1304 +{
1305 + u64 result;
1306 + unsigned long tmp;
1307 +
1308 + __asm__ __volatile__("@ atomic64_sub_unchecked\n"
1309 +"1: ldrexd %0, %H0, [%3]\n"
1310 +" subs %0, %0, %4\n"
1311 " sbc %H0, %H0, %H4\n"
1312 " strexd %1, %0, %H0, [%3]\n"
1313 " teq %1, #0\n"
1314 @@ -329,18 +648,32 @@ static inline void atomic64_sub(u64 i, atomic64_t *v)
1315
1316 static inline u64 atomic64_sub_return(u64 i, atomic64_t *v)
1317 {
1318 - u64 result;
1319 - unsigned long tmp;
1320 + u64 result, tmp;
1321
1322 smp_mb();
1323
1324 __asm__ __volatile__("@ atomic64_sub_return\n"
1325 -"1: ldrexd %0, %H0, [%3]\n"
1326 -" subs %0, %0, %4\n"
1327 -" sbc %H0, %H0, %H4\n"
1328 +"1: ldrexd %1, %H1, [%3]\n"
1329 +" subs %0, %1, %4\n"
1330 +" sbcs %H0, %H1, %H4\n"
1331 +
1332 +#ifdef CONFIG_PAX_REFCOUNT
1333 +" bvc 3f\n"
1334 +" mov %0, %1\n"
1335 +" mov %H0, %H1\n"
1336 +"2: bkpt 0xf103\n"
1337 +"3:\n"
1338 +#endif
1339 +
1340 " strexd %1, %0, %H0, [%3]\n"
1341 " teq %1, #0\n"
1342 " bne 1b"
1343 +
1344 +#ifdef CONFIG_PAX_REFCOUNT
1345 +"\n4:\n"
1346 + _ASM_EXTABLE(2b, 4b)
1347 +#endif
1348 +
1349 : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1350 : "r" (&v->counter), "r" (i)
1351 : "cc");
1352 @@ -374,6 +707,30 @@ static inline u64 atomic64_cmpxchg(atomic64_t *ptr, u64 old, u64 new)
1353 return oldval;
1354 }
1355
1356 +static inline u64 atomic64_cmpxchg_unchecked(atomic64_unchecked_t *ptr, u64 old, u64 new)
1357 +{
1358 + u64 oldval;
1359 + unsigned long res;
1360 +
1361 + smp_mb();
1362 +
1363 + do {
1364 + __asm__ __volatile__("@ atomic64_cmpxchg_unchecked\n"
1365 + "ldrexd %1, %H1, [%3]\n"
1366 + "mov %0, #0\n"
1367 + "teq %1, %4\n"
1368 + "teqeq %H1, %H4\n"
1369 + "strexdeq %0, %5, %H5, [%3]"
1370 + : "=&r" (res), "=&r" (oldval), "+Qo" (ptr->counter)
1371 + : "r" (&ptr->counter), "r" (old), "r" (new)
1372 + : "cc");
1373 + } while (res);
1374 +
1375 + smp_mb();
1376 +
1377 + return oldval;
1378 +}
1379 +
1380 static inline u64 atomic64_xchg(atomic64_t *ptr, u64 new)
1381 {
1382 u64 result;
1383 @@ -397,21 +754,34 @@ static inline u64 atomic64_xchg(atomic64_t *ptr, u64 new)
1384
1385 static inline u64 atomic64_dec_if_positive(atomic64_t *v)
1386 {
1387 - u64 result;
1388 - unsigned long tmp;
1389 + u64 result, tmp;
1390
1391 smp_mb();
1392
1393 __asm__ __volatile__("@ atomic64_dec_if_positive\n"
1394 -"1: ldrexd %0, %H0, [%3]\n"
1395 -" subs %0, %0, #1\n"
1396 -" sbc %H0, %H0, #0\n"
1397 +"1: ldrexd %1, %H1, [%3]\n"
1398 +" subs %0, %1, #1\n"
1399 +" sbcs %H0, %H1, #0\n"
1400 +
1401 +#ifdef CONFIG_PAX_REFCOUNT
1402 +" bvc 3f\n"
1403 +" mov %0, %1\n"
1404 +" mov %H0, %H1\n"
1405 +"2: bkpt 0xf103\n"
1406 +"3:\n"
1407 +#endif
1408 +
1409 " teq %H0, #0\n"
1410 -" bmi 2f\n"
1411 +" bmi 4f\n"
1412 " strexd %1, %0, %H0, [%3]\n"
1413 " teq %1, #0\n"
1414 " bne 1b\n"
1415 -"2:"
1416 +"4:\n"
1417 +
1418 +#ifdef CONFIG_PAX_REFCOUNT
1419 + _ASM_EXTABLE(2b, 4b)
1420 +#endif
1421 +
1422 : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1423 : "r" (&v->counter)
1424 : "cc");
1425 @@ -434,13 +804,25 @@ static inline int atomic64_add_unless(atomic64_t *v, u64 a, u64 u)
1426 " teq %0, %5\n"
1427 " teqeq %H0, %H5\n"
1428 " moveq %1, #0\n"
1429 -" beq 2f\n"
1430 +" beq 4f\n"
1431 " adds %0, %0, %6\n"
1432 -" adc %H0, %H0, %H6\n"
1433 +" adcs %H0, %H0, %H6\n"
1434 +
1435 +#ifdef CONFIG_PAX_REFCOUNT
1436 +" bvc 3f\n"
1437 +"2: bkpt 0xf103\n"
1438 +"3:\n"
1439 +#endif
1440 +
1441 " strexd %2, %0, %H0, [%4]\n"
1442 " teq %2, #0\n"
1443 " bne 1b\n"
1444 -"2:"
1445 +"4:\n"
1446 +
1447 +#ifdef CONFIG_PAX_REFCOUNT
1448 + _ASM_EXTABLE(2b, 4b)
1449 +#endif
1450 +
1451 : "=&r" (val), "+r" (ret), "=&r" (tmp), "+Qo" (v->counter)
1452 : "r" (&v->counter), "r" (u), "r" (a)
1453 : "cc");
1454 @@ -453,10 +835,13 @@ static inline int atomic64_add_unless(atomic64_t *v, u64 a, u64 u)
1455
1456 #define atomic64_add_negative(a, v) (atomic64_add_return((a), (v)) < 0)
1457 #define atomic64_inc(v) atomic64_add(1LL, (v))
1458 +#define atomic64_inc_unchecked(v) atomic64_add_unchecked(1LL, (v))
1459 #define atomic64_inc_return(v) atomic64_add_return(1LL, (v))
1460 +#define atomic64_inc_return_unchecked(v) atomic64_add_return_unchecked(1LL, (v))
1461 #define atomic64_inc_and_test(v) (atomic64_inc_return(v) == 0)
1462 #define atomic64_sub_and_test(a, v) (atomic64_sub_return((a), (v)) == 0)
1463 #define atomic64_dec(v) atomic64_sub(1LL, (v))
1464 +#define atomic64_dec_unchecked(v) atomic64_sub_unchecked(1LL, (v))
1465 #define atomic64_dec_return(v) atomic64_sub_return(1LL, (v))
1466 #define atomic64_dec_and_test(v) (atomic64_dec_return((v)) == 0)
1467 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1LL, 0LL)
1468 diff --git a/arch/arm/include/asm/cache.h b/arch/arm/include/asm/cache.h
1469 index 75fe66b..ba3dee4 100644
1470 --- a/arch/arm/include/asm/cache.h
1471 +++ b/arch/arm/include/asm/cache.h
1472 @@ -4,8 +4,10 @@
1473 #ifndef __ASMARM_CACHE_H
1474 #define __ASMARM_CACHE_H
1475
1476 +#include <linux/const.h>
1477 +
1478 #define L1_CACHE_SHIFT CONFIG_ARM_L1_CACHE_SHIFT
1479 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
1480 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
1481
1482 /*
1483 * Memory returned by kmalloc() may be used for DMA, so we must make
1484 @@ -24,5 +26,6 @@
1485 #endif
1486
1487 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
1488 +#define __read_only __attribute__ ((__section__(".data..read_only")))
1489
1490 #endif
1491 diff --git a/arch/arm/include/asm/cacheflush.h b/arch/arm/include/asm/cacheflush.h
1492 index e1489c5..d418304 100644
1493 --- a/arch/arm/include/asm/cacheflush.h
1494 +++ b/arch/arm/include/asm/cacheflush.h
1495 @@ -116,7 +116,7 @@ struct cpu_cache_fns {
1496 void (*dma_unmap_area)(const void *, size_t, int);
1497
1498 void (*dma_flush_range)(const void *, const void *);
1499 -};
1500 +} __no_const;
1501
1502 /*
1503 * Select the calling method
1504 diff --git a/arch/arm/include/asm/checksum.h b/arch/arm/include/asm/checksum.h
1505 index 6dcc164..b14d917 100644
1506 --- a/arch/arm/include/asm/checksum.h
1507 +++ b/arch/arm/include/asm/checksum.h
1508 @@ -37,7 +37,19 @@ __wsum
1509 csum_partial_copy_nocheck(const void *src, void *dst, int len, __wsum sum);
1510
1511 __wsum
1512 -csum_partial_copy_from_user(const void __user *src, void *dst, int len, __wsum sum, int *err_ptr);
1513 +__csum_partial_copy_from_user(const void __user *src, void *dst, int len, __wsum sum, int *err_ptr);
1514 +
1515 +static inline __wsum
1516 +csum_partial_copy_from_user(const void __user *src, void *dst, int len, __wsum sum, int *err_ptr)
1517 +{
1518 + __wsum ret;
1519 + pax_open_userland();
1520 + ret = __csum_partial_copy_from_user(src, dst, len, sum, err_ptr);
1521 + pax_close_userland();
1522 + return ret;
1523 +}
1524 +
1525 +
1526
1527 /*
1528 * Fold a partial checksum without adding pseudo headers
1529 diff --git a/arch/arm/include/asm/cmpxchg.h b/arch/arm/include/asm/cmpxchg.h
1530 index 7eb18c1..e38b6d2 100644
1531 --- a/arch/arm/include/asm/cmpxchg.h
1532 +++ b/arch/arm/include/asm/cmpxchg.h
1533 @@ -102,6 +102,8 @@ static inline unsigned long __xchg(unsigned long x, volatile void *ptr, int size
1534
1535 #define xchg(ptr,x) \
1536 ((__typeof__(*(ptr)))__xchg((unsigned long)(x),(ptr),sizeof(*(ptr))))
1537 +#define xchg_unchecked(ptr,x) \
1538 + ((__typeof__(*(ptr)))__xchg((unsigned long)(x),(ptr),sizeof(*(ptr))))
1539
1540 #include <asm-generic/cmpxchg-local.h>
1541
1542 diff --git a/arch/arm/include/asm/delay.h b/arch/arm/include/asm/delay.h
1543 index 720799f..2f67631 100644
1544 --- a/arch/arm/include/asm/delay.h
1545 +++ b/arch/arm/include/asm/delay.h
1546 @@ -25,9 +25,9 @@ extern struct arm_delay_ops {
1547 void (*const_udelay)(unsigned long);
1548 void (*udelay)(unsigned long);
1549 bool const_clock;
1550 -} arm_delay_ops;
1551 +} *arm_delay_ops;
1552
1553 -#define __delay(n) arm_delay_ops.delay(n)
1554 +#define __delay(n) arm_delay_ops->delay(n)
1555
1556 /*
1557 * This function intentionally does not exist; if you see references to
1558 @@ -48,8 +48,8 @@ extern void __bad_udelay(void);
1559 * first constant multiplications gets optimized away if the delay is
1560 * a constant)
1561 */
1562 -#define __udelay(n) arm_delay_ops.udelay(n)
1563 -#define __const_udelay(n) arm_delay_ops.const_udelay(n)
1564 +#define __udelay(n) arm_delay_ops->udelay(n)
1565 +#define __const_udelay(n) arm_delay_ops->const_udelay(n)
1566
1567 #define udelay(n) \
1568 (__builtin_constant_p(n) ? \
1569 diff --git a/arch/arm/include/asm/domain.h b/arch/arm/include/asm/domain.h
1570 index 6ddbe44..b5e38b1 100644
1571 --- a/arch/arm/include/asm/domain.h
1572 +++ b/arch/arm/include/asm/domain.h
1573 @@ -48,18 +48,37 @@
1574 * Domain types
1575 */
1576 #define DOMAIN_NOACCESS 0
1577 -#define DOMAIN_CLIENT 1
1578 #ifdef CONFIG_CPU_USE_DOMAINS
1579 +#define DOMAIN_USERCLIENT 1
1580 +#define DOMAIN_KERNELCLIENT 1
1581 #define DOMAIN_MANAGER 3
1582 +#define DOMAIN_VECTORS DOMAIN_USER
1583 #else
1584 +
1585 +#ifdef CONFIG_PAX_KERNEXEC
1586 #define DOMAIN_MANAGER 1
1587 +#define DOMAIN_KERNEXEC 3
1588 +#else
1589 +#define DOMAIN_MANAGER 1
1590 +#endif
1591 +
1592 +#ifdef CONFIG_PAX_MEMORY_UDEREF
1593 +#define DOMAIN_USERCLIENT 0
1594 +#define DOMAIN_UDEREF 1
1595 +#define DOMAIN_VECTORS DOMAIN_KERNEL
1596 +#else
1597 +#define DOMAIN_USERCLIENT 1
1598 +#define DOMAIN_VECTORS DOMAIN_USER
1599 +#endif
1600 +#define DOMAIN_KERNELCLIENT 1
1601 +
1602 #endif
1603
1604 #define domain_val(dom,type) ((type) << (2*(dom)))
1605
1606 #ifndef __ASSEMBLY__
1607
1608 -#ifdef CONFIG_CPU_USE_DOMAINS
1609 +#if defined(CONFIG_CPU_USE_DOMAINS) || defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
1610 static inline void set_domain(unsigned val)
1611 {
1612 asm volatile(
1613 @@ -68,15 +87,7 @@ static inline void set_domain(unsigned val)
1614 isb();
1615 }
1616
1617 -#define modify_domain(dom,type) \
1618 - do { \
1619 - struct thread_info *thread = current_thread_info(); \
1620 - unsigned int domain = thread->cpu_domain; \
1621 - domain &= ~domain_val(dom, DOMAIN_MANAGER); \
1622 - thread->cpu_domain = domain | domain_val(dom, type); \
1623 - set_domain(thread->cpu_domain); \
1624 - } while (0)
1625 -
1626 +extern void modify_domain(unsigned int dom, unsigned int type);
1627 #else
1628 static inline void set_domain(unsigned val) { }
1629 static inline void modify_domain(unsigned dom, unsigned type) { }
1630 diff --git a/arch/arm/include/asm/elf.h b/arch/arm/include/asm/elf.h
1631 index 38050b1..9d90e8b 100644
1632 --- a/arch/arm/include/asm/elf.h
1633 +++ b/arch/arm/include/asm/elf.h
1634 @@ -116,7 +116,14 @@ int dump_task_regs(struct task_struct *t, elf_gregset_t *elfregs);
1635 the loader. We need to make sure that it is out of the way of the program
1636 that it will "exec", and that there is sufficient room for the brk. */
1637
1638 -#define ELF_ET_DYN_BASE (2 * TASK_SIZE / 3)
1639 +#define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
1640 +
1641 +#ifdef CONFIG_PAX_ASLR
1642 +#define PAX_ELF_ET_DYN_BASE 0x00008000UL
1643 +
1644 +#define PAX_DELTA_MMAP_LEN ((current->personality == PER_LINUX_32BIT) ? 16 : 10)
1645 +#define PAX_DELTA_STACK_LEN ((current->personality == PER_LINUX_32BIT) ? 16 : 10)
1646 +#endif
1647
1648 /* When the program starts, a1 contains a pointer to a function to be
1649 registered with atexit, as per the SVR4 ABI. A value of 0 means we
1650 @@ -126,8 +133,4 @@ int dump_task_regs(struct task_struct *t, elf_gregset_t *elfregs);
1651 extern void elf_set_personality(const struct elf32_hdr *);
1652 #define SET_PERSONALITY(ex) elf_set_personality(&(ex))
1653
1654 -struct mm_struct;
1655 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
1656 -#define arch_randomize_brk arch_randomize_brk
1657 -
1658 #endif
1659 diff --git a/arch/arm/include/asm/fncpy.h b/arch/arm/include/asm/fncpy.h
1660 index de53547..52b9a28 100644
1661 --- a/arch/arm/include/asm/fncpy.h
1662 +++ b/arch/arm/include/asm/fncpy.h
1663 @@ -81,7 +81,9 @@
1664 BUG_ON((uintptr_t)(dest_buf) & (FNCPY_ALIGN - 1) || \
1665 (__funcp_address & ~(uintptr_t)1 & (FNCPY_ALIGN - 1))); \
1666 \
1667 + pax_open_kernel(); \
1668 memcpy(dest_buf, (void const *)(__funcp_address & ~1), size); \
1669 + pax_close_kernel(); \
1670 flush_icache_range((unsigned long)(dest_buf), \
1671 (unsigned long)(dest_buf) + (size)); \
1672 \
1673 diff --git a/arch/arm/include/asm/futex.h b/arch/arm/include/asm/futex.h
1674 index e42cf59..7b94b8f 100644
1675 --- a/arch/arm/include/asm/futex.h
1676 +++ b/arch/arm/include/asm/futex.h
1677 @@ -50,6 +50,8 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
1678 if (!access_ok(VERIFY_WRITE, uaddr, sizeof(u32)))
1679 return -EFAULT;
1680
1681 + pax_open_userland();
1682 +
1683 smp_mb();
1684 __asm__ __volatile__("@futex_atomic_cmpxchg_inatomic\n"
1685 "1: ldrex %1, [%4]\n"
1686 @@ -65,6 +67,8 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
1687 : "cc", "memory");
1688 smp_mb();
1689
1690 + pax_close_userland();
1691 +
1692 *uval = val;
1693 return ret;
1694 }
1695 @@ -95,6 +99,8 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
1696 if (!access_ok(VERIFY_WRITE, uaddr, sizeof(u32)))
1697 return -EFAULT;
1698
1699 + pax_open_userland();
1700 +
1701 __asm__ __volatile__("@futex_atomic_cmpxchg_inatomic\n"
1702 "1: " TUSER(ldr) " %1, [%4]\n"
1703 " teq %1, %2\n"
1704 @@ -105,6 +111,8 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
1705 : "r" (oldval), "r" (newval), "r" (uaddr), "Ir" (-EFAULT)
1706 : "cc", "memory");
1707
1708 + pax_close_userland();
1709 +
1710 *uval = val;
1711 return ret;
1712 }
1713 @@ -127,6 +135,7 @@ futex_atomic_op_inuser (int encoded_op, u32 __user *uaddr)
1714 return -EFAULT;
1715
1716 pagefault_disable(); /* implies preempt_disable() */
1717 + pax_open_userland();
1718
1719 switch (op) {
1720 case FUTEX_OP_SET:
1721 @@ -148,6 +157,7 @@ futex_atomic_op_inuser (int encoded_op, u32 __user *uaddr)
1722 ret = -ENOSYS;
1723 }
1724
1725 + pax_close_userland();
1726 pagefault_enable(); /* subsumes preempt_enable() */
1727
1728 if (!ret) {
1729 diff --git a/arch/arm/include/asm/hardware/gic.h b/arch/arm/include/asm/hardware/gic.h
1730 index 4b1ce6c..bea3f73 100644
1731 --- a/arch/arm/include/asm/hardware/gic.h
1732 +++ b/arch/arm/include/asm/hardware/gic.h
1733 @@ -34,9 +34,10 @@
1734
1735 #ifndef __ASSEMBLY__
1736 #include <linux/irqdomain.h>
1737 +#include <linux/irq.h>
1738 struct device_node;
1739
1740 -extern struct irq_chip gic_arch_extn;
1741 +extern irq_chip_no_const gic_arch_extn;
1742
1743 void gic_init_bases(unsigned int, int, void __iomem *, void __iomem *,
1744 u32 offset, struct device_node *);
1745 diff --git a/arch/arm/include/asm/kmap_types.h b/arch/arm/include/asm/kmap_types.h
1746 index 83eb2f7..ed77159 100644
1747 --- a/arch/arm/include/asm/kmap_types.h
1748 +++ b/arch/arm/include/asm/kmap_types.h
1749 @@ -4,6 +4,6 @@
1750 /*
1751 * This is the "bare minimum". AIO seems to require this.
1752 */
1753 -#define KM_TYPE_NR 16
1754 +#define KM_TYPE_NR 17
1755
1756 #endif
1757 diff --git a/arch/arm/include/asm/mach/dma.h b/arch/arm/include/asm/mach/dma.h
1758 index 9e614a1..3302cca 100644
1759 --- a/arch/arm/include/asm/mach/dma.h
1760 +++ b/arch/arm/include/asm/mach/dma.h
1761 @@ -22,7 +22,7 @@ struct dma_ops {
1762 int (*residue)(unsigned int, dma_t *); /* optional */
1763 int (*setspeed)(unsigned int, dma_t *, int); /* optional */
1764 const char *type;
1765 -};
1766 +} __do_const;
1767
1768 struct dma_struct {
1769 void *addr; /* single DMA address */
1770 diff --git a/arch/arm/include/asm/mach/map.h b/arch/arm/include/asm/mach/map.h
1771 index 2fe141f..192dc01 100644
1772 --- a/arch/arm/include/asm/mach/map.h
1773 +++ b/arch/arm/include/asm/mach/map.h
1774 @@ -27,13 +27,16 @@ struct map_desc {
1775 #define MT_MINICLEAN 6
1776 #define MT_LOW_VECTORS 7
1777 #define MT_HIGH_VECTORS 8
1778 -#define MT_MEMORY 9
1779 +#define MT_MEMORY_RWX 9
1780 #define MT_ROM 10
1781 -#define MT_MEMORY_NONCACHED 11
1782 +#define MT_MEMORY_NONCACHED_RX 11
1783 #define MT_MEMORY_DTCM 12
1784 #define MT_MEMORY_ITCM 13
1785 #define MT_MEMORY_SO 14
1786 #define MT_MEMORY_DMA_READY 15
1787 +#define MT_MEMORY_RW 16
1788 +#define MT_MEMORY_RX 17
1789 +#define MT_MEMORY_NONCACHED_RW 18
1790
1791 #ifdef CONFIG_MMU
1792 extern void iotable_init(struct map_desc *, int);
1793 diff --git a/arch/arm/include/asm/outercache.h b/arch/arm/include/asm/outercache.h
1794 index 53426c6..c7baff3 100644
1795 --- a/arch/arm/include/asm/outercache.h
1796 +++ b/arch/arm/include/asm/outercache.h
1797 @@ -35,7 +35,7 @@ struct outer_cache_fns {
1798 #endif
1799 void (*set_debug)(unsigned long);
1800 void (*resume)(void);
1801 -};
1802 +} __no_const;
1803
1804 #ifdef CONFIG_OUTER_CACHE
1805
1806 diff --git a/arch/arm/include/asm/page.h b/arch/arm/include/asm/page.h
1807 index 812a494..71fc0b6 100644
1808 --- a/arch/arm/include/asm/page.h
1809 +++ b/arch/arm/include/asm/page.h
1810 @@ -114,7 +114,7 @@ struct cpu_user_fns {
1811 void (*cpu_clear_user_highpage)(struct page *page, unsigned long vaddr);
1812 void (*cpu_copy_user_highpage)(struct page *to, struct page *from,
1813 unsigned long vaddr, struct vm_area_struct *vma);
1814 -};
1815 +} __no_const;
1816
1817 #ifdef MULTI_USER
1818 extern struct cpu_user_fns cpu_user;
1819 diff --git a/arch/arm/include/asm/pgalloc.h b/arch/arm/include/asm/pgalloc.h
1820 index 943504f..c37a730 100644
1821 --- a/arch/arm/include/asm/pgalloc.h
1822 +++ b/arch/arm/include/asm/pgalloc.h
1823 @@ -17,6 +17,7 @@
1824 #include <asm/processor.h>
1825 #include <asm/cacheflush.h>
1826 #include <asm/tlbflush.h>
1827 +#include <asm/system_info.h>
1828
1829 #define check_pgt_cache() do { } while (0)
1830
1831 @@ -43,6 +44,11 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
1832 set_pud(pud, __pud(__pa(pmd) | PMD_TYPE_TABLE));
1833 }
1834
1835 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
1836 +{
1837 + pud_populate(mm, pud, pmd);
1838 +}
1839 +
1840 #else /* !CONFIG_ARM_LPAE */
1841
1842 /*
1843 @@ -51,6 +57,7 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
1844 #define pmd_alloc_one(mm,addr) ({ BUG(); ((pmd_t *)2); })
1845 #define pmd_free(mm, pmd) do { } while (0)
1846 #define pud_populate(mm,pmd,pte) BUG()
1847 +#define pud_populate_kernel(mm,pmd,pte) BUG()
1848
1849 #endif /* CONFIG_ARM_LPAE */
1850
1851 @@ -126,6 +133,19 @@ static inline void pte_free(struct mm_struct *mm, pgtable_t pte)
1852 __free_page(pte);
1853 }
1854
1855 +static inline void __section_update(pmd_t *pmdp, unsigned long addr, pmdval_t prot)
1856 +{
1857 +#ifdef CONFIG_ARM_LPAE
1858 + pmdp[0] = __pmd(pmd_val(pmdp[0]) | prot);
1859 +#else
1860 + if (addr & SECTION_SIZE)
1861 + pmdp[1] = __pmd(pmd_val(pmdp[1]) | prot);
1862 + else
1863 + pmdp[0] = __pmd(pmd_val(pmdp[0]) | prot);
1864 +#endif
1865 + flush_pmd_entry(pmdp);
1866 +}
1867 +
1868 static inline void __pmd_populate(pmd_t *pmdp, phys_addr_t pte,
1869 pmdval_t prot)
1870 {
1871 @@ -155,7 +175,7 @@ pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmdp, pte_t *ptep)
1872 static inline void
1873 pmd_populate(struct mm_struct *mm, pmd_t *pmdp, pgtable_t ptep)
1874 {
1875 - __pmd_populate(pmdp, page_to_phys(ptep), _PAGE_USER_TABLE);
1876 + __pmd_populate(pmdp, page_to_phys(ptep), _PAGE_USER_TABLE | __supported_pmd_mask);
1877 }
1878 #define pmd_pgtable(pmd) pmd_page(pmd)
1879
1880 diff --git a/arch/arm/include/asm/pgtable-2level-hwdef.h b/arch/arm/include/asm/pgtable-2level-hwdef.h
1881 index 5cfba15..f415e1a 100644
1882 --- a/arch/arm/include/asm/pgtable-2level-hwdef.h
1883 +++ b/arch/arm/include/asm/pgtable-2level-hwdef.h
1884 @@ -20,12 +20,15 @@
1885 #define PMD_TYPE_FAULT (_AT(pmdval_t, 0) << 0)
1886 #define PMD_TYPE_TABLE (_AT(pmdval_t, 1) << 0)
1887 #define PMD_TYPE_SECT (_AT(pmdval_t, 2) << 0)
1888 +#define PMD_PXNTABLE (_AT(pmdval_t, 1) << 2) /* v7 */
1889 #define PMD_BIT4 (_AT(pmdval_t, 1) << 4)
1890 #define PMD_DOMAIN(x) (_AT(pmdval_t, (x)) << 5)
1891 #define PMD_PROTECTION (_AT(pmdval_t, 1) << 9) /* v5 */
1892 +
1893 /*
1894 * - section
1895 */
1896 +#define PMD_SECT_PXN (_AT(pmdval_t, 1) << 0) /* v7 */
1897 #define PMD_SECT_BUFFERABLE (_AT(pmdval_t, 1) << 2)
1898 #define PMD_SECT_CACHEABLE (_AT(pmdval_t, 1) << 3)
1899 #define PMD_SECT_XN (_AT(pmdval_t, 1) << 4) /* v6 */
1900 @@ -37,6 +40,7 @@
1901 #define PMD_SECT_nG (_AT(pmdval_t, 1) << 17) /* v6 */
1902 #define PMD_SECT_SUPER (_AT(pmdval_t, 1) << 18) /* v6 */
1903 #define PMD_SECT_AF (_AT(pmdval_t, 0))
1904 +#define PMD_SECT_RDONLY (_AT(pmdval_t, 0))
1905
1906 #define PMD_SECT_UNCACHED (_AT(pmdval_t, 0))
1907 #define PMD_SECT_BUFFERED (PMD_SECT_BUFFERABLE)
1908 @@ -66,6 +70,7 @@
1909 * - extended small page/tiny page
1910 */
1911 #define PTE_EXT_XN (_AT(pteval_t, 1) << 0) /* v6 */
1912 +#define PTE_EXT_PXN (_AT(pteval_t, 1) << 2) /* v7 */
1913 #define PTE_EXT_AP_MASK (_AT(pteval_t, 3) << 4)
1914 #define PTE_EXT_AP0 (_AT(pteval_t, 1) << 4)
1915 #define PTE_EXT_AP1 (_AT(pteval_t, 2) << 4)
1916 diff --git a/arch/arm/include/asm/pgtable-2level.h b/arch/arm/include/asm/pgtable-2level.h
1917 index f97ee02..07f1be5 100644
1918 --- a/arch/arm/include/asm/pgtable-2level.h
1919 +++ b/arch/arm/include/asm/pgtable-2level.h
1920 @@ -125,6 +125,7 @@
1921 #define L_PTE_XN (_AT(pteval_t, 1) << 9)
1922 #define L_PTE_SHARED (_AT(pteval_t, 1) << 10) /* shared(v6), coherent(xsc3) */
1923 #define L_PTE_NONE (_AT(pteval_t, 1) << 11)
1924 +#define L_PTE_PXN (_AT(pteval_t, 1) << 12) /* v7*/
1925
1926 /*
1927 * These are the memory types, defined to be compatible with
1928 diff --git a/arch/arm/include/asm/pgtable-3level-hwdef.h b/arch/arm/include/asm/pgtable-3level-hwdef.h
1929 index d795282..a43ea90 100644
1930 --- a/arch/arm/include/asm/pgtable-3level-hwdef.h
1931 +++ b/arch/arm/include/asm/pgtable-3level-hwdef.h
1932 @@ -32,15 +32,18 @@
1933 #define PMD_TYPE_SECT (_AT(pmdval_t, 1) << 0)
1934 #define PMD_BIT4 (_AT(pmdval_t, 0))
1935 #define PMD_DOMAIN(x) (_AT(pmdval_t, 0))
1936 +#define PMD_PXNTABLE (_AT(pmdval_t, 1) << 59) /* PXNTable */
1937
1938 /*
1939 * - section
1940 */
1941 #define PMD_SECT_BUFFERABLE (_AT(pmdval_t, 1) << 2)
1942 #define PMD_SECT_CACHEABLE (_AT(pmdval_t, 1) << 3)
1943 +#define PMD_SECT_RDONLY (_AT(pmdval_t, 1) << 7)
1944 #define PMD_SECT_S (_AT(pmdval_t, 3) << 8)
1945 #define PMD_SECT_AF (_AT(pmdval_t, 1) << 10)
1946 #define PMD_SECT_nG (_AT(pmdval_t, 1) << 11)
1947 +#define PMD_SECT_PXN (_AT(pmdval_t, 1) << 53)
1948 #define PMD_SECT_XN (_AT(pmdval_t, 1) << 54)
1949 #define PMD_SECT_AP_WRITE (_AT(pmdval_t, 0))
1950 #define PMD_SECT_AP_READ (_AT(pmdval_t, 0))
1951 @@ -66,6 +69,7 @@
1952 #define PTE_EXT_SHARED (_AT(pteval_t, 3) << 8) /* SH[1:0], inner shareable */
1953 #define PTE_EXT_AF (_AT(pteval_t, 1) << 10) /* Access Flag */
1954 #define PTE_EXT_NG (_AT(pteval_t, 1) << 11) /* nG */
1955 +#define PTE_EXT_PXN (_AT(pteval_t, 1) << 53) /* PXN */
1956 #define PTE_EXT_XN (_AT(pteval_t, 1) << 54) /* XN */
1957
1958 /*
1959 diff --git a/arch/arm/include/asm/pgtable-3level.h b/arch/arm/include/asm/pgtable-3level.h
1960 index a3f3792..7b932a6 100644
1961 --- a/arch/arm/include/asm/pgtable-3level.h
1962 +++ b/arch/arm/include/asm/pgtable-3level.h
1963 @@ -74,6 +74,7 @@
1964 #define L_PTE_RDONLY (_AT(pteval_t, 1) << 7) /* AP[2] */
1965 #define L_PTE_SHARED (_AT(pteval_t, 3) << 8) /* SH[1:0], inner shareable */
1966 #define L_PTE_YOUNG (_AT(pteval_t, 1) << 10) /* AF */
1967 +#define L_PTE_PXN (_AT(pteval_t, 1) << 53) /* PXN */
1968 #define L_PTE_XN (_AT(pteval_t, 1) << 54) /* XN */
1969 #define L_PTE_DIRTY (_AT(pteval_t, 1) << 55) /* unused */
1970 #define L_PTE_SPECIAL (_AT(pteval_t, 1) << 56) /* unused */
1971 @@ -82,6 +83,7 @@
1972 /*
1973 * To be used in assembly code with the upper page attributes.
1974 */
1975 +#define L_PTE_PXN_HIGH (1 << (53 - 32))
1976 #define L_PTE_XN_HIGH (1 << (54 - 32))
1977 #define L_PTE_DIRTY_HIGH (1 << (55 - 32))
1978
1979 diff --git a/arch/arm/include/asm/pgtable.h b/arch/arm/include/asm/pgtable.h
1980 index c094749..fd8272e 100644
1981 --- a/arch/arm/include/asm/pgtable.h
1982 +++ b/arch/arm/include/asm/pgtable.h
1983 @@ -30,6 +30,9 @@
1984 #include <asm/pgtable-2level.h>
1985 #endif
1986
1987 +#define ktla_ktva(addr) (addr)
1988 +#define ktva_ktla(addr) (addr)
1989 +
1990 /*
1991 * Just any arbitrary offset to the start of the vmalloc VM area: the
1992 * current 8MB value just means that there will be a 8MB "hole" after the
1993 @@ -45,6 +48,9 @@
1994 #define LIBRARY_TEXT_START 0x0c000000
1995
1996 #ifndef __ASSEMBLY__
1997 +extern pteval_t __supported_pte_mask;
1998 +extern pmdval_t __supported_pmd_mask;
1999 +
2000 extern void __pte_error(const char *file, int line, pte_t);
2001 extern void __pmd_error(const char *file, int line, pmd_t);
2002 extern void __pgd_error(const char *file, int line, pgd_t);
2003 @@ -53,6 +59,50 @@ extern void __pgd_error(const char *file, int line, pgd_t);
2004 #define pmd_ERROR(pmd) __pmd_error(__FILE__, __LINE__, pmd)
2005 #define pgd_ERROR(pgd) __pgd_error(__FILE__, __LINE__, pgd)
2006
2007 +#define __HAVE_ARCH_PAX_OPEN_KERNEL
2008 +#define __HAVE_ARCH_PAX_CLOSE_KERNEL
2009 +
2010 +#ifdef CONFIG_PAX_KERNEXEC
2011 +#include <asm/domain.h>
2012 +#include <linux/thread_info.h>
2013 +#include <linux/preempt.h>
2014 +#endif
2015 +
2016 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2017 +static inline int test_domain(int domain, int domaintype)
2018 +{
2019 + return ((current_thread_info()->cpu_domain) & domain_val(domain, 3)) == domain_val(domain, domaintype);
2020 +}
2021 +#endif
2022 +
2023 +#ifdef CONFIG_PAX_KERNEXEC
2024 +static inline unsigned long pax_open_kernel(void) {
2025 +#ifdef CONFIG_ARM_LPAE
2026 + /* TODO */
2027 +#else
2028 + preempt_disable();
2029 + BUG_ON(test_domain(DOMAIN_KERNEL, DOMAIN_KERNEXEC));
2030 + modify_domain(DOMAIN_KERNEL, DOMAIN_KERNEXEC);
2031 +#endif
2032 + return 0;
2033 +}
2034 +
2035 +static inline unsigned long pax_close_kernel(void) {
2036 +#ifdef CONFIG_ARM_LPAE
2037 + /* TODO */
2038 +#else
2039 + BUG_ON(test_domain(DOMAIN_KERNEL, DOMAIN_MANAGER));
2040 + /* DOMAIN_MANAGER = "client" under KERNEXEC */
2041 + modify_domain(DOMAIN_KERNEL, DOMAIN_MANAGER);
2042 + preempt_enable_no_resched();
2043 +#endif
2044 + return 0;
2045 +}
2046 +#else
2047 +static inline unsigned long pax_open_kernel(void) { return 0; }
2048 +static inline unsigned long pax_close_kernel(void) { return 0; }
2049 +#endif
2050 +
2051 /*
2052 * This is the lowest virtual address we can permit any user space
2053 * mapping to be mapped at. This is particularly important for
2054 @@ -63,8 +113,8 @@ extern void __pgd_error(const char *file, int line, pgd_t);
2055 /*
2056 * The pgprot_* and protection_map entries will be fixed up in runtime
2057 * to include the cachable and bufferable bits based on memory policy,
2058 - * as well as any architecture dependent bits like global/ASID and SMP
2059 - * shared mapping bits.
2060 + * as well as any architecture dependent bits like global/ASID, PXN,
2061 + * and SMP shared mapping bits.
2062 */
2063 #define _L_PTE_DEFAULT L_PTE_PRESENT | L_PTE_YOUNG
2064
2065 @@ -240,8 +290,7 @@ static inline pte_t pte_mkspecial(pte_t pte) { return pte; }
2066
2067 static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
2068 {
2069 - const pteval_t mask = L_PTE_XN | L_PTE_RDONLY | L_PTE_USER |
2070 - L_PTE_NONE | L_PTE_VALID;
2071 + const pteval_t mask = L_PTE_XN | L_PTE_RDONLY | L_PTE_USER | L_PTE_NONE | L_PTE_VALID | __supported_pte_mask;
2072 pte_val(pte) = (pte_val(pte) & ~mask) | (pgprot_val(newprot) & mask);
2073 return pte;
2074 }
2075 diff --git a/arch/arm/include/asm/proc-fns.h b/arch/arm/include/asm/proc-fns.h
2076 index f3628fb..a0672dd 100644
2077 --- a/arch/arm/include/asm/proc-fns.h
2078 +++ b/arch/arm/include/asm/proc-fns.h
2079 @@ -75,7 +75,7 @@ extern struct processor {
2080 unsigned int suspend_size;
2081 void (*do_suspend)(void *);
2082 void (*do_resume)(void *);
2083 -} processor;
2084 +} __do_const processor;
2085
2086 #ifndef MULTI_CPU
2087 extern void cpu_proc_init(void);
2088 diff --git a/arch/arm/include/asm/processor.h b/arch/arm/include/asm/processor.h
2089 index 06e7d50..8a8e251 100644
2090 --- a/arch/arm/include/asm/processor.h
2091 +++ b/arch/arm/include/asm/processor.h
2092 @@ -65,9 +65,8 @@ struct thread_struct {
2093 regs->ARM_cpsr |= PSR_ENDSTATE; \
2094 regs->ARM_pc = pc & ~1; /* pc */ \
2095 regs->ARM_sp = sp; /* sp */ \
2096 - regs->ARM_r2 = stack[2]; /* r2 (envp) */ \
2097 - regs->ARM_r1 = stack[1]; /* r1 (argv) */ \
2098 - regs->ARM_r0 = stack[0]; /* r0 (argc) */ \
2099 + /* r2 (envp), r1 (argv), r0 (argc) */ \
2100 + (void)copy_from_user(&regs->ARM_r0, (const char __user *)stack, 3 * sizeof(unsigned long)); \
2101 nommu_start_thread(regs); \
2102 })
2103
2104 diff --git a/arch/arm/include/asm/smp.h b/arch/arm/include/asm/smp.h
2105 index d3a22be..3a69ad5 100644
2106 --- a/arch/arm/include/asm/smp.h
2107 +++ b/arch/arm/include/asm/smp.h
2108 @@ -107,7 +107,7 @@ struct smp_operations {
2109 int (*cpu_disable)(unsigned int cpu);
2110 #endif
2111 #endif
2112 -};
2113 +} __no_const;
2114
2115 /*
2116 * set platform specific SMP operations
2117 diff --git a/arch/arm/include/asm/thread_info.h b/arch/arm/include/asm/thread_info.h
2118 index cddda1f..ff357f7 100644
2119 --- a/arch/arm/include/asm/thread_info.h
2120 +++ b/arch/arm/include/asm/thread_info.h
2121 @@ -77,9 +77,9 @@ struct thread_info {
2122 .flags = 0, \
2123 .preempt_count = INIT_PREEMPT_COUNT, \
2124 .addr_limit = KERNEL_DS, \
2125 - .cpu_domain = domain_val(DOMAIN_USER, DOMAIN_MANAGER) | \
2126 - domain_val(DOMAIN_KERNEL, DOMAIN_MANAGER) | \
2127 - domain_val(DOMAIN_IO, DOMAIN_CLIENT), \
2128 + .cpu_domain = domain_val(DOMAIN_USER, DOMAIN_USERCLIENT) | \
2129 + domain_val(DOMAIN_KERNEL, DOMAIN_KERNELCLIENT) | \
2130 + domain_val(DOMAIN_IO, DOMAIN_KERNELCLIENT), \
2131 .restart_block = { \
2132 .fn = do_no_restart_syscall, \
2133 }, \
2134 @@ -152,6 +152,12 @@ extern int vfp_restore_user_hwstate(struct user_vfp __user *,
2135 #define TIF_SYSCALL_AUDIT 9
2136 #define TIF_SYSCALL_TRACEPOINT 10
2137 #define TIF_SECCOMP 11 /* seccomp syscall filtering active */
2138 +
2139 +/* within 8 bits of TIF_SYSCALL_TRACE
2140 + * to meet flexible second operand requirements
2141 + */
2142 +#define TIF_GRSEC_SETXID 12
2143 +
2144 #define TIF_USING_IWMMXT 17
2145 #define TIF_MEMDIE 18 /* is terminating due to OOM killer */
2146 #define TIF_RESTORE_SIGMASK 20
2147 @@ -165,10 +171,11 @@ extern int vfp_restore_user_hwstate(struct user_vfp __user *,
2148 #define _TIF_SYSCALL_TRACEPOINT (1 << TIF_SYSCALL_TRACEPOINT)
2149 #define _TIF_SECCOMP (1 << TIF_SECCOMP)
2150 #define _TIF_USING_IWMMXT (1 << TIF_USING_IWMMXT)
2151 +#define _TIF_GRSEC_SETXID (1 << TIF_GRSEC_SETXID)
2152
2153 /* Checks for any syscall work in entry-common.S */
2154 #define _TIF_SYSCALL_WORK (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | \
2155 - _TIF_SYSCALL_TRACEPOINT | _TIF_SECCOMP)
2156 + _TIF_SYSCALL_TRACEPOINT | _TIF_SECCOMP | _TIF_GRSEC_SETXID)
2157
2158 /*
2159 * Change these and you break ASM code in entry-common.S
2160 diff --git a/arch/arm/include/asm/uaccess.h b/arch/arm/include/asm/uaccess.h
2161 index 7e1f760..752fcb7 100644
2162 --- a/arch/arm/include/asm/uaccess.h
2163 +++ b/arch/arm/include/asm/uaccess.h
2164 @@ -18,6 +18,7 @@
2165 #include <asm/domain.h>
2166 #include <asm/unified.h>
2167 #include <asm/compiler.h>
2168 +#include <asm/pgtable.h>
2169
2170 #define VERIFY_READ 0
2171 #define VERIFY_WRITE 1
2172 @@ -60,10 +61,34 @@ extern int __put_user_bad(void);
2173 #define USER_DS TASK_SIZE
2174 #define get_fs() (current_thread_info()->addr_limit)
2175
2176 +static inline void pax_open_userland(void)
2177 +{
2178 +
2179 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2180 + if (get_fs() == USER_DS) {
2181 + BUG_ON(test_domain(DOMAIN_USER, DOMAIN_UDEREF));
2182 + modify_domain(DOMAIN_USER, DOMAIN_UDEREF);
2183 + }
2184 +#endif
2185 +
2186 +}
2187 +
2188 +static inline void pax_close_userland(void)
2189 +{
2190 +
2191 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2192 + if (get_fs() == USER_DS) {
2193 + BUG_ON(test_domain(DOMAIN_USER, DOMAIN_NOACCESS));
2194 + modify_domain(DOMAIN_USER, DOMAIN_NOACCESS);
2195 + }
2196 +#endif
2197 +
2198 +}
2199 +
2200 static inline void set_fs(mm_segment_t fs)
2201 {
2202 current_thread_info()->addr_limit = fs;
2203 - modify_domain(DOMAIN_KERNEL, fs ? DOMAIN_CLIENT : DOMAIN_MANAGER);
2204 + modify_domain(DOMAIN_KERNEL, fs ? DOMAIN_KERNELCLIENT : DOMAIN_MANAGER);
2205 }
2206
2207 #define segment_eq(a,b) ((a) == (b))
2208 @@ -143,8 +168,12 @@ extern int __get_user_4(void *);
2209
2210 #define get_user(x,p) \
2211 ({ \
2212 + int __e; \
2213 might_fault(); \
2214 - __get_user_check(x,p); \
2215 + pax_open_userland(); \
2216 + __e = __get_user_check(x,p); \
2217 + pax_close_userland(); \
2218 + __e; \
2219 })
2220
2221 extern int __put_user_1(void *, unsigned int);
2222 @@ -188,8 +217,12 @@ extern int __put_user_8(void *, unsigned long long);
2223
2224 #define put_user(x,p) \
2225 ({ \
2226 + int __e; \
2227 might_fault(); \
2228 - __put_user_check(x,p); \
2229 + pax_open_userland(); \
2230 + __e = __put_user_check(x,p); \
2231 + pax_close_userland(); \
2232 + __e; \
2233 })
2234
2235 #else /* CONFIG_MMU */
2236 @@ -230,13 +263,17 @@ static inline void set_fs(mm_segment_t fs)
2237 #define __get_user(x,ptr) \
2238 ({ \
2239 long __gu_err = 0; \
2240 + pax_open_userland(); \
2241 __get_user_err((x),(ptr),__gu_err); \
2242 + pax_close_userland(); \
2243 __gu_err; \
2244 })
2245
2246 #define __get_user_error(x,ptr,err) \
2247 ({ \
2248 + pax_open_userland(); \
2249 __get_user_err((x),(ptr),err); \
2250 + pax_close_userland(); \
2251 (void) 0; \
2252 })
2253
2254 @@ -312,13 +349,17 @@ do { \
2255 #define __put_user(x,ptr) \
2256 ({ \
2257 long __pu_err = 0; \
2258 + pax_open_userland(); \
2259 __put_user_err((x),(ptr),__pu_err); \
2260 + pax_close_userland(); \
2261 __pu_err; \
2262 })
2263
2264 #define __put_user_error(x,ptr,err) \
2265 ({ \
2266 + pax_open_userland(); \
2267 __put_user_err((x),(ptr),err); \
2268 + pax_close_userland(); \
2269 (void) 0; \
2270 })
2271
2272 @@ -418,11 +459,44 @@ do { \
2273
2274
2275 #ifdef CONFIG_MMU
2276 -extern unsigned long __must_check __copy_from_user(void *to, const void __user *from, unsigned long n);
2277 -extern unsigned long __must_check __copy_to_user(void __user *to, const void *from, unsigned long n);
2278 +extern unsigned long __must_check ___copy_from_user(void *to, const void __user *from, unsigned long n);
2279 +extern unsigned long __must_check ___copy_to_user(void __user *to, const void *from, unsigned long n);
2280 +
2281 +static inline unsigned long __must_check __copy_from_user(void *to, const void __user *from, unsigned long n)
2282 +{
2283 + unsigned long ret;
2284 +
2285 + check_object_size(to, n, false);
2286 + pax_open_userland();
2287 + ret = ___copy_from_user(to, from, n);
2288 + pax_close_userland();
2289 + return ret;
2290 +}
2291 +
2292 +static inline unsigned long __must_check __copy_to_user(void __user *to, const void *from, unsigned long n)
2293 +{
2294 + unsigned long ret;
2295 +
2296 + check_object_size(from, n, true);
2297 + pax_open_userland();
2298 + ret = ___copy_to_user(to, from, n);
2299 + pax_close_userland();
2300 + return ret;
2301 +}
2302 +
2303 extern unsigned long __must_check __copy_to_user_std(void __user *to, const void *from, unsigned long n);
2304 -extern unsigned long __must_check __clear_user(void __user *addr, unsigned long n);
2305 +extern unsigned long __must_check ___clear_user(void __user *addr, unsigned long n);
2306 extern unsigned long __must_check __clear_user_std(void __user *addr, unsigned long n);
2307 +
2308 +static inline unsigned long __must_check __clear_user(void __user *addr, unsigned long n)
2309 +{
2310 + unsigned long ret;
2311 + pax_open_userland();
2312 + ret = ___clear_user(addr, n);
2313 + pax_close_userland();
2314 + return ret;
2315 +}
2316 +
2317 #else
2318 #define __copy_from_user(to,from,n) (memcpy(to, (void __force *)from, n), 0)
2319 #define __copy_to_user(to,from,n) (memcpy((void __force *)to, from, n), 0)
2320 @@ -431,6 +505,9 @@ extern unsigned long __must_check __clear_user_std(void __user *addr, unsigned l
2321
2322 static inline unsigned long __must_check copy_from_user(void *to, const void __user *from, unsigned long n)
2323 {
2324 + if ((long)n < 0)
2325 + return n;
2326 +
2327 if (access_ok(VERIFY_READ, from, n))
2328 n = __copy_from_user(to, from, n);
2329 else /* security hole - plug it */
2330 @@ -440,6 +517,9 @@ static inline unsigned long __must_check copy_from_user(void *to, const void __u
2331
2332 static inline unsigned long __must_check copy_to_user(void __user *to, const void *from, unsigned long n)
2333 {
2334 + if ((long)n < 0)
2335 + return n;
2336 +
2337 if (access_ok(VERIFY_WRITE, to, n))
2338 n = __copy_to_user(to, from, n);
2339 return n;
2340 diff --git a/arch/arm/include/uapi/asm/ptrace.h b/arch/arm/include/uapi/asm/ptrace.h
2341 index 96ee092..37f1844 100644
2342 --- a/arch/arm/include/uapi/asm/ptrace.h
2343 +++ b/arch/arm/include/uapi/asm/ptrace.h
2344 @@ -73,7 +73,7 @@
2345 * ARMv7 groups of PSR bits
2346 */
2347 #define APSR_MASK 0xf80f0000 /* N, Z, C, V, Q and GE flags */
2348 -#define PSR_ISET_MASK 0x01000010 /* ISA state (J, T) mask */
2349 +#define PSR_ISET_MASK 0x01000020 /* ISA state (J, T) mask */
2350 #define PSR_IT_MASK 0x0600fc00 /* If-Then execution state mask */
2351 #define PSR_ENDIAN_MASK 0x00000200 /* Endianness state mask */
2352
2353 diff --git a/arch/arm/kernel/armksyms.c b/arch/arm/kernel/armksyms.c
2354 index 60d3b73..d27ee09 100644
2355 --- a/arch/arm/kernel/armksyms.c
2356 +++ b/arch/arm/kernel/armksyms.c
2357 @@ -89,9 +89,9 @@ EXPORT_SYMBOL(__memzero);
2358 #ifdef CONFIG_MMU
2359 EXPORT_SYMBOL(copy_page);
2360
2361 -EXPORT_SYMBOL(__copy_from_user);
2362 -EXPORT_SYMBOL(__copy_to_user);
2363 -EXPORT_SYMBOL(__clear_user);
2364 +EXPORT_SYMBOL(___copy_from_user);
2365 +EXPORT_SYMBOL(___copy_to_user);
2366 +EXPORT_SYMBOL(___clear_user);
2367
2368 EXPORT_SYMBOL(__get_user_1);
2369 EXPORT_SYMBOL(__get_user_2);
2370 diff --git a/arch/arm/kernel/entry-armv.S b/arch/arm/kernel/entry-armv.S
2371 index 0f82098..3dbd3ee 100644
2372 --- a/arch/arm/kernel/entry-armv.S
2373 +++ b/arch/arm/kernel/entry-armv.S
2374 @@ -47,6 +47,87 @@
2375 9997:
2376 .endm
2377
2378 + .macro pax_enter_kernel
2379 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2380 + @ make aligned space for saved DACR
2381 + sub sp, sp, #8
2382 + @ save regs
2383 + stmdb sp!, {r1, r2}
2384 + @ read DACR from cpu_domain into r1
2385 + mov r2, sp
2386 + @ assume 8K pages, since we have to split the immediate in two
2387 + bic r2, r2, #(0x1fc0)
2388 + bic r2, r2, #(0x3f)
2389 + ldr r1, [r2, #TI_CPU_DOMAIN]
2390 + @ store old DACR on stack
2391 + str r1, [sp, #8]
2392 +#ifdef CONFIG_PAX_KERNEXEC
2393 + @ set type of DOMAIN_KERNEL to DOMAIN_KERNELCLIENT
2394 + bic r1, r1, #(domain_val(DOMAIN_KERNEL, 3))
2395 + orr r1, r1, #(domain_val(DOMAIN_KERNEL, DOMAIN_KERNELCLIENT))
2396 +#endif
2397 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2398 + @ set current DOMAIN_USER to DOMAIN_NOACCESS
2399 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2400 +#endif
2401 + @ write r1 to current_thread_info()->cpu_domain
2402 + str r1, [r2, #TI_CPU_DOMAIN]
2403 + @ write r1 to DACR
2404 + mcr p15, 0, r1, c3, c0, 0
2405 + @ instruction sync
2406 + instr_sync
2407 + @ restore regs
2408 + ldmia sp!, {r1, r2}
2409 +#endif
2410 + .endm
2411 +
2412 + .macro pax_open_userland
2413 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2414 + @ save regs
2415 + stmdb sp!, {r0, r1}
2416 + @ read DACR from cpu_domain into r1
2417 + mov r0, sp
2418 + @ assume 8K pages, since we have to split the immediate in two
2419 + bic r0, r0, #(0x1fc0)
2420 + bic r0, r0, #(0x3f)
2421 + ldr r1, [r0, #TI_CPU_DOMAIN]
2422 + @ set current DOMAIN_USER to DOMAIN_CLIENT
2423 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2424 + orr r1, r1, #(domain_val(DOMAIN_USER, DOMAIN_UDEREF))
2425 + @ write r1 to current_thread_info()->cpu_domain
2426 + str r1, [r0, #TI_CPU_DOMAIN]
2427 + @ write r1 to DACR
2428 + mcr p15, 0, r1, c3, c0, 0
2429 + @ instruction sync
2430 + instr_sync
2431 + @ restore regs
2432 + ldmia sp!, {r0, r1}
2433 +#endif
2434 + .endm
2435 +
2436 + .macro pax_close_userland
2437 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2438 + @ save regs
2439 + stmdb sp!, {r0, r1}
2440 + @ read DACR from cpu_domain into r1
2441 + mov r0, sp
2442 + @ assume 8K pages, since we have to split the immediate in two
2443 + bic r0, r0, #(0x1fc0)
2444 + bic r0, r0, #(0x3f)
2445 + ldr r1, [r0, #TI_CPU_DOMAIN]
2446 + @ set current DOMAIN_USER to DOMAIN_NOACCESS
2447 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2448 + @ write r1 to current_thread_info()->cpu_domain
2449 + str r1, [r0, #TI_CPU_DOMAIN]
2450 + @ write r1 to DACR
2451 + mcr p15, 0, r1, c3, c0, 0
2452 + @ instruction sync
2453 + instr_sync
2454 + @ restore regs
2455 + ldmia sp!, {r0, r1}
2456 +#endif
2457 + .endm
2458 +
2459 .macro pabt_helper
2460 @ PABORT handler takes pt_regs in r2, fault address in r4 and psr in r5
2461 #ifdef MULTI_PABORT
2462 @@ -89,11 +170,15 @@
2463 * Invalid mode handlers
2464 */
2465 .macro inv_entry, reason
2466 +
2467 + pax_enter_kernel
2468 +
2469 sub sp, sp, #S_FRAME_SIZE
2470 ARM( stmib sp, {r1 - lr} )
2471 THUMB( stmia sp, {r0 - r12} )
2472 THUMB( str sp, [sp, #S_SP] )
2473 THUMB( str lr, [sp, #S_LR] )
2474 +
2475 mov r1, #\reason
2476 .endm
2477
2478 @@ -149,7 +234,11 @@ ENDPROC(__und_invalid)
2479 .macro svc_entry, stack_hole=0
2480 UNWIND(.fnstart )
2481 UNWIND(.save {r0 - pc} )
2482 +
2483 + pax_enter_kernel
2484 +
2485 sub sp, sp, #(S_FRAME_SIZE + \stack_hole - 4)
2486 +
2487 #ifdef CONFIG_THUMB2_KERNEL
2488 SPFIX( str r0, [sp] ) @ temporarily saved
2489 SPFIX( mov r0, sp )
2490 @@ -164,7 +253,12 @@ ENDPROC(__und_invalid)
2491 ldmia r0, {r3 - r5}
2492 add r7, sp, #S_SP - 4 @ here for interlock avoidance
2493 mov r6, #-1 @ "" "" "" ""
2494 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2495 + @ offset sp by 8 as done in pax_enter_kernel
2496 + add r2, sp, #(S_FRAME_SIZE + \stack_hole + 4)
2497 +#else
2498 add r2, sp, #(S_FRAME_SIZE + \stack_hole - 4)
2499 +#endif
2500 SPFIX( addeq r2, r2, #4 )
2501 str r3, [sp, #-4]! @ save the "real" r0 copied
2502 @ from the exception stack
2503 @@ -359,6 +453,9 @@ ENDPROC(__pabt_svc)
2504 .macro usr_entry
2505 UNWIND(.fnstart )
2506 UNWIND(.cantunwind ) @ don't unwind the user space
2507 +
2508 + pax_enter_kernel_user
2509 +
2510 sub sp, sp, #S_FRAME_SIZE
2511 ARM( stmib sp, {r1 - r12} )
2512 THUMB( stmia sp, {r0 - r12} )
2513 @@ -456,7 +553,9 @@ __und_usr:
2514 tst r3, #PSR_T_BIT @ Thumb mode?
2515 bne __und_usr_thumb
2516 sub r4, r2, #4 @ ARM instr at LR - 4
2517 + pax_open_userland
2518 1: ldrt r0, [r4]
2519 + pax_close_userland
2520 #ifdef CONFIG_CPU_ENDIAN_BE8
2521 rev r0, r0 @ little endian instruction
2522 #endif
2523 @@ -491,10 +590,14 @@ __und_usr_thumb:
2524 */
2525 .arch armv6t2
2526 #endif
2527 + pax_open_userland
2528 2: ldrht r5, [r4]
2529 + pax_close_userland
2530 cmp r5, #0xe800 @ 32bit instruction if xx != 0
2531 blo __und_usr_fault_16 @ 16bit undefined instruction
2532 + pax_open_userland
2533 3: ldrht r0, [r2]
2534 + pax_close_userland
2535 add r2, r2, #2 @ r2 is PC + 2, make it PC + 4
2536 str r2, [sp, #S_PC] @ it's a 2x16bit instr, update
2537 orr r0, r0, r5, lsl #16
2538 @@ -733,7 +836,7 @@ ENTRY(__switch_to)
2539 THUMB( stmia ip!, {r4 - sl, fp} ) @ Store most regs on stack
2540 THUMB( str sp, [ip], #4 )
2541 THUMB( str lr, [ip], #4 )
2542 -#ifdef CONFIG_CPU_USE_DOMAINS
2543 +#if defined(CONFIG_CPU_USE_DOMAINS) || defined(CONFIG_PAX_KERNEXEC)
2544 ldr r6, [r2, #TI_CPU_DOMAIN]
2545 #endif
2546 set_tls r3, r4, r5
2547 @@ -742,7 +845,7 @@ ENTRY(__switch_to)
2548 ldr r8, =__stack_chk_guard
2549 ldr r7, [r7, #TSK_STACK_CANARY]
2550 #endif
2551 -#ifdef CONFIG_CPU_USE_DOMAINS
2552 +#if defined(CONFIG_CPU_USE_DOMAINS) || defined(CONFIG_PAX_KERNEXEC)
2553 mcr p15, 0, r6, c3, c0, 0 @ Set domain register
2554 #endif
2555 mov r5, r0
2556 diff --git a/arch/arm/kernel/entry-common.S b/arch/arm/kernel/entry-common.S
2557 index a6c301e..908821b 100644
2558 --- a/arch/arm/kernel/entry-common.S
2559 +++ b/arch/arm/kernel/entry-common.S
2560 @@ -10,18 +10,46 @@
2561
2562 #include <asm/unistd.h>
2563 #include <asm/ftrace.h>
2564 +#include <asm/domain.h>
2565 #include <asm/unwind.h>
2566
2567 +#include "entry-header.S"
2568 +
2569 #ifdef CONFIG_NEED_RET_TO_USER
2570 #include <mach/entry-macro.S>
2571 #else
2572 .macro arch_ret_to_user, tmp1, tmp2
2573 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2574 + @ save regs
2575 + stmdb sp!, {r1, r2}
2576 + @ read DACR from cpu_domain into r1
2577 + mov r2, sp
2578 + @ assume 8K pages, since we have to split the immediate in two
2579 + bic r2, r2, #(0x1fc0)
2580 + bic r2, r2, #(0x3f)
2581 + ldr r1, [r2, #TI_CPU_DOMAIN]
2582 +#ifdef CONFIG_PAX_KERNEXEC
2583 + @ set type of DOMAIN_KERNEL to DOMAIN_KERNELCLIENT
2584 + bic r1, r1, #(domain_val(DOMAIN_KERNEL, 3))
2585 + orr r1, r1, #(domain_val(DOMAIN_KERNEL, DOMAIN_KERNELCLIENT))
2586 +#endif
2587 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2588 + @ set current DOMAIN_USER to DOMAIN_UDEREF
2589 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2590 + orr r1, r1, #(domain_val(DOMAIN_USER, DOMAIN_UDEREF))
2591 +#endif
2592 + @ write r1 to current_thread_info()->cpu_domain
2593 + str r1, [r2, #TI_CPU_DOMAIN]
2594 + @ write r1 to DACR
2595 + mcr p15, 0, r1, c3, c0, 0
2596 + @ instruction sync
2597 + instr_sync
2598 + @ restore regs
2599 + ldmia sp!, {r1, r2}
2600 +#endif
2601 .endm
2602 #endif
2603
2604 -#include "entry-header.S"
2605 -
2606 -
2607 .align 5
2608 /*
2609 * This is the fast syscall return path. We do as little as
2610 @@ -339,6 +367,7 @@ ENDPROC(ftrace_stub)
2611
2612 .align 5
2613 ENTRY(vector_swi)
2614 +
2615 sub sp, sp, #S_FRAME_SIZE
2616 stmia sp, {r0 - r12} @ Calling r0 - r12
2617 ARM( add r8, sp, #S_PC )
2618 @@ -388,6 +417,12 @@ ENTRY(vector_swi)
2619 ldr scno, [lr, #-4] @ get SWI instruction
2620 #endif
2621
2622 + /*
2623 + * do this here to avoid a performance hit of wrapping the code above
2624 + * that directly dereferences userland to parse the SWI instruction
2625 + */
2626 + pax_enter_kernel_user
2627 +
2628 #ifdef CONFIG_ALIGNMENT_TRAP
2629 ldr ip, __cr_alignment
2630 ldr ip, [ip]
2631 diff --git a/arch/arm/kernel/entry-header.S b/arch/arm/kernel/entry-header.S
2632 index 9a8531e..812e287 100644
2633 --- a/arch/arm/kernel/entry-header.S
2634 +++ b/arch/arm/kernel/entry-header.S
2635 @@ -73,9 +73,66 @@
2636 msr cpsr_c, \rtemp @ switch back to the SVC mode
2637 .endm
2638
2639 + .macro pax_enter_kernel_user
2640 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2641 + @ save regs
2642 + stmdb sp!, {r0, r1}
2643 + @ read DACR from cpu_domain into r1
2644 + mov r0, sp
2645 + @ assume 8K pages, since we have to split the immediate in two
2646 + bic r0, r0, #(0x1fc0)
2647 + bic r0, r0, #(0x3f)
2648 + ldr r1, [r0, #TI_CPU_DOMAIN]
2649 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2650 + @ set current DOMAIN_USER to DOMAIN_NOACCESS
2651 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2652 +#endif
2653 +#ifdef CONFIG_PAX_KERNEXEC
2654 + @ set current DOMAIN_KERNEL to DOMAIN_KERNELCLIENT
2655 + bic r1, r1, #(domain_val(DOMAIN_KERNEL, 3))
2656 + orr r1, r1, #(domain_val(DOMAIN_KERNEL, DOMAIN_KERNELCLIENT))
2657 +#endif
2658 + @ write r1 to current_thread_info()->cpu_domain
2659 + str r1, [r0, #TI_CPU_DOMAIN]
2660 + @ write r1 to DACR
2661 + mcr p15, 0, r1, c3, c0, 0
2662 + @ instruction sync
2663 + instr_sync
2664 + @ restore regs
2665 + ldmia sp!, {r0, r1}
2666 +#endif
2667 + .endm
2668 +
2669 + .macro pax_exit_kernel
2670 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2671 + @ save regs
2672 + stmdb sp!, {r0, r1}
2673 + @ read old DACR from stack into r1
2674 + ldr r1, [sp, #(8 + S_SP)]
2675 + sub r1, r1, #8
2676 + ldr r1, [r1]
2677 +
2678 + @ write r1 to current_thread_info()->cpu_domain
2679 + mov r0, sp
2680 + @ assume 8K pages, since we have to split the immediate in two
2681 + bic r0, r0, #(0x1fc0)
2682 + bic r0, r0, #(0x3f)
2683 + str r1, [r0, #TI_CPU_DOMAIN]
2684 + @ write r1 to DACR
2685 + mcr p15, 0, r1, c3, c0, 0
2686 + @ instruction sync
2687 + instr_sync
2688 + @ restore regs
2689 + ldmia sp!, {r0, r1}
2690 +#endif
2691 + .endm
2692 +
2693 #ifndef CONFIG_THUMB2_KERNEL
2694 .macro svc_exit, rpsr
2695 msr spsr_cxsf, \rpsr
2696 +
2697 + pax_exit_kernel
2698 +
2699 #if defined(CONFIG_CPU_V6)
2700 ldr r0, [sp]
2701 strex r1, r2, [sp] @ clear the exclusive monitor
2702 @@ -121,6 +178,9 @@
2703 .endm
2704 #else /* CONFIG_THUMB2_KERNEL */
2705 .macro svc_exit, rpsr
2706 +
2707 + pax_exit_kernel
2708 +
2709 ldr lr, [sp, #S_SP] @ top of the stack
2710 ldrd r0, r1, [sp, #S_LR] @ calling lr and pc
2711 clrex @ clear the exclusive monitor
2712 diff --git a/arch/arm/kernel/fiq.c b/arch/arm/kernel/fiq.c
2713 index 2adda11..7fbe958 100644
2714 --- a/arch/arm/kernel/fiq.c
2715 +++ b/arch/arm/kernel/fiq.c
2716 @@ -82,7 +82,9 @@ void set_fiq_handler(void *start, unsigned int length)
2717 #if defined(CONFIG_CPU_USE_DOMAINS)
2718 memcpy((void *)0xffff001c, start, length);
2719 #else
2720 + pax_open_kernel();
2721 memcpy(vectors_page + 0x1c, start, length);
2722 + pax_close_kernel();
2723 #endif
2724 flush_icache_range(0xffff001c, 0xffff001c + length);
2725 if (!vectors_high())
2726 diff --git a/arch/arm/kernel/head.S b/arch/arm/kernel/head.S
2727 index e0eb9a1..c7d74a3 100644
2728 --- a/arch/arm/kernel/head.S
2729 +++ b/arch/arm/kernel/head.S
2730 @@ -52,7 +52,9 @@
2731 .equ swapper_pg_dir, KERNEL_RAM_VADDR - PG_DIR_SIZE
2732
2733 .macro pgtbl, rd, phys
2734 - add \rd, \phys, #TEXT_OFFSET - PG_DIR_SIZE
2735 + mov \rd, #TEXT_OFFSET
2736 + sub \rd, #PG_DIR_SIZE
2737 + add \rd, \rd, \phys
2738 .endm
2739
2740 /*
2741 @@ -434,7 +436,7 @@ __enable_mmu:
2742 mov r5, #(domain_val(DOMAIN_USER, DOMAIN_MANAGER) | \
2743 domain_val(DOMAIN_KERNEL, DOMAIN_MANAGER) | \
2744 domain_val(DOMAIN_TABLE, DOMAIN_MANAGER) | \
2745 - domain_val(DOMAIN_IO, DOMAIN_CLIENT))
2746 + domain_val(DOMAIN_IO, DOMAIN_KERNELCLIENT))
2747 mcr p15, 0, r5, c3, c0, 0 @ load domain access register
2748 mcr p15, 0, r4, c2, c0, 0 @ load page table pointer
2749 #endif
2750 diff --git a/arch/arm/kernel/hw_breakpoint.c b/arch/arm/kernel/hw_breakpoint.c
2751 index 5ff2e77..556d030 100644
2752 --- a/arch/arm/kernel/hw_breakpoint.c
2753 +++ b/arch/arm/kernel/hw_breakpoint.c
2754 @@ -1011,7 +1011,7 @@ static int __cpuinit dbg_reset_notify(struct notifier_block *self,
2755 return NOTIFY_OK;
2756 }
2757
2758 -static struct notifier_block __cpuinitdata dbg_reset_nb = {
2759 +static struct notifier_block dbg_reset_nb = {
2760 .notifier_call = dbg_reset_notify,
2761 };
2762
2763 diff --git a/arch/arm/kernel/module.c b/arch/arm/kernel/module.c
2764 index 1e9be5d..03edbc2 100644
2765 --- a/arch/arm/kernel/module.c
2766 +++ b/arch/arm/kernel/module.c
2767 @@ -37,12 +37,37 @@
2768 #endif
2769
2770 #ifdef CONFIG_MMU
2771 -void *module_alloc(unsigned long size)
2772 +static inline void *__module_alloc(unsigned long size, pgprot_t prot)
2773 {
2774 + if (!size || PAGE_ALIGN(size) > MODULES_END - MODULES_VADDR)
2775 + return NULL;
2776 return __vmalloc_node_range(size, 1, MODULES_VADDR, MODULES_END,
2777 - GFP_KERNEL, PAGE_KERNEL_EXEC, -1,
2778 + GFP_KERNEL, prot, -1,
2779 __builtin_return_address(0));
2780 }
2781 +
2782 +void *module_alloc(unsigned long size)
2783 +{
2784 +
2785 +#ifdef CONFIG_PAX_KERNEXEC
2786 + return __module_alloc(size, PAGE_KERNEL);
2787 +#else
2788 + return __module_alloc(size, PAGE_KERNEL_EXEC);
2789 +#endif
2790 +
2791 +}
2792 +
2793 +#ifdef CONFIG_PAX_KERNEXEC
2794 +void module_free_exec(struct module *mod, void *module_region)
2795 +{
2796 + module_free(mod, module_region);
2797 +}
2798 +
2799 +void *module_alloc_exec(unsigned long size)
2800 +{
2801 + return __module_alloc(size, PAGE_KERNEL_EXEC);
2802 +}
2803 +#endif
2804 #endif
2805
2806 int
2807 diff --git a/arch/arm/kernel/patch.c b/arch/arm/kernel/patch.c
2808 index 07314af..c46655c 100644
2809 --- a/arch/arm/kernel/patch.c
2810 +++ b/arch/arm/kernel/patch.c
2811 @@ -18,6 +18,7 @@ void __kprobes __patch_text(void *addr, unsigned int insn)
2812 bool thumb2 = IS_ENABLED(CONFIG_THUMB2_KERNEL);
2813 int size;
2814
2815 + pax_open_kernel();
2816 if (thumb2 && __opcode_is_thumb16(insn)) {
2817 *(u16 *)addr = __opcode_to_mem_thumb16(insn);
2818 size = sizeof(u16);
2819 @@ -39,6 +40,7 @@ void __kprobes __patch_text(void *addr, unsigned int insn)
2820 *(u32 *)addr = insn;
2821 size = sizeof(u32);
2822 }
2823 + pax_close_kernel();
2824
2825 flush_icache_range((uintptr_t)(addr),
2826 (uintptr_t)(addr) + size);
2827 diff --git a/arch/arm/kernel/perf_event_cpu.c b/arch/arm/kernel/perf_event_cpu.c
2828 index 5f66206..dce492f 100644
2829 --- a/arch/arm/kernel/perf_event_cpu.c
2830 +++ b/arch/arm/kernel/perf_event_cpu.c
2831 @@ -171,7 +171,7 @@ static int __cpuinit cpu_pmu_notify(struct notifier_block *b,
2832 return NOTIFY_OK;
2833 }
2834
2835 -static struct notifier_block __cpuinitdata cpu_pmu_hotplug_notifier = {
2836 +static struct notifier_block cpu_pmu_hotplug_notifier = {
2837 .notifier_call = cpu_pmu_notify,
2838 };
2839
2840 diff --git a/arch/arm/kernel/process.c b/arch/arm/kernel/process.c
2841 index c6dec5f..e0fddd1 100644
2842 --- a/arch/arm/kernel/process.c
2843 +++ b/arch/arm/kernel/process.c
2844 @@ -28,7 +28,6 @@
2845 #include <linux/tick.h>
2846 #include <linux/utsname.h>
2847 #include <linux/uaccess.h>
2848 -#include <linux/random.h>
2849 #include <linux/hw_breakpoint.h>
2850 #include <linux/cpuidle.h>
2851 #include <linux/leds.h>
2852 @@ -256,9 +255,10 @@ void machine_power_off(void)
2853 machine_shutdown();
2854 if (pm_power_off)
2855 pm_power_off();
2856 + BUG();
2857 }
2858
2859 -void machine_restart(char *cmd)
2860 +__noreturn void machine_restart(char *cmd)
2861 {
2862 machine_shutdown();
2863
2864 @@ -283,8 +283,8 @@ void __show_regs(struct pt_regs *regs)
2865 init_utsname()->release,
2866 (int)strcspn(init_utsname()->version, " "),
2867 init_utsname()->version);
2868 - print_symbol("PC is at %s\n", instruction_pointer(regs));
2869 - print_symbol("LR is at %s\n", regs->ARM_lr);
2870 + printk("PC is at %pA\n", instruction_pointer(regs));
2871 + printk("LR is at %pA\n", regs->ARM_lr);
2872 printk("pc : [<%08lx>] lr : [<%08lx>] psr: %08lx\n"
2873 "sp : %08lx ip : %08lx fp : %08lx\n",
2874 regs->ARM_pc, regs->ARM_lr, regs->ARM_cpsr,
2875 @@ -452,12 +452,6 @@ unsigned long get_wchan(struct task_struct *p)
2876 return 0;
2877 }
2878
2879 -unsigned long arch_randomize_brk(struct mm_struct *mm)
2880 -{
2881 - unsigned long range_end = mm->brk + 0x02000000;
2882 - return randomize_range(mm->brk, range_end, 0) ? : mm->brk;
2883 -}
2884 -
2885 #ifdef CONFIG_MMU
2886 /*
2887 * The vectors page is always readable from user space for the
2888 @@ -470,9 +464,8 @@ static int __init gate_vma_init(void)
2889 {
2890 gate_vma.vm_start = 0xffff0000;
2891 gate_vma.vm_end = 0xffff0000 + PAGE_SIZE;
2892 - gate_vma.vm_page_prot = PAGE_READONLY_EXEC;
2893 - gate_vma.vm_flags = VM_READ | VM_EXEC |
2894 - VM_MAYREAD | VM_MAYEXEC;
2895 + gate_vma.vm_flags = VM_NONE;
2896 + gate_vma.vm_page_prot = vm_get_page_prot(gate_vma.vm_flags);
2897 return 0;
2898 }
2899 arch_initcall(gate_vma_init);
2900 diff --git a/arch/arm/kernel/ptrace.c b/arch/arm/kernel/ptrace.c
2901 index 03deeff..741ce88 100644
2902 --- a/arch/arm/kernel/ptrace.c
2903 +++ b/arch/arm/kernel/ptrace.c
2904 @@ -937,10 +937,19 @@ static int tracehook_report_syscall(struct pt_regs *regs,
2905 return current_thread_info()->syscall;
2906 }
2907
2908 +#ifdef CONFIG_GRKERNSEC_SETXID
2909 +extern void gr_delayed_cred_worker(void);
2910 +#endif
2911 +
2912 asmlinkage int syscall_trace_enter(struct pt_regs *regs, int scno)
2913 {
2914 current_thread_info()->syscall = scno;
2915
2916 +#ifdef CONFIG_GRKERNSEC_SETXID
2917 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
2918 + gr_delayed_cred_worker();
2919 +#endif
2920 +
2921 /* Do the secure computing check first; failures should be fast. */
2922 if (secure_computing(scno) == -1)
2923 return -1;
2924 diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c
2925 index 3f6cbb2..6d856f5 100644
2926 --- a/arch/arm/kernel/setup.c
2927 +++ b/arch/arm/kernel/setup.c
2928 @@ -97,21 +97,23 @@ EXPORT_SYMBOL(system_serial_high);
2929 unsigned int elf_hwcap __read_mostly;
2930 EXPORT_SYMBOL(elf_hwcap);
2931
2932 +pteval_t __supported_pte_mask __read_only;
2933 +pmdval_t __supported_pmd_mask __read_only;
2934
2935 #ifdef MULTI_CPU
2936 -struct processor processor __read_mostly;
2937 +struct processor processor;
2938 #endif
2939 #ifdef MULTI_TLB
2940 -struct cpu_tlb_fns cpu_tlb __read_mostly;
2941 +struct cpu_tlb_fns cpu_tlb __read_only;
2942 #endif
2943 #ifdef MULTI_USER
2944 -struct cpu_user_fns cpu_user __read_mostly;
2945 +struct cpu_user_fns cpu_user __read_only;
2946 #endif
2947 #ifdef MULTI_CACHE
2948 -struct cpu_cache_fns cpu_cache __read_mostly;
2949 +struct cpu_cache_fns cpu_cache __read_only;
2950 #endif
2951 #ifdef CONFIG_OUTER_CACHE
2952 -struct outer_cache_fns outer_cache __read_mostly;
2953 +struct outer_cache_fns outer_cache __read_only;
2954 EXPORT_SYMBOL(outer_cache);
2955 #endif
2956
2957 @@ -236,9 +238,13 @@ static int __get_cpu_architecture(void)
2958 asm("mrc p15, 0, %0, c0, c1, 4"
2959 : "=r" (mmfr0));
2960 if ((mmfr0 & 0x0000000f) >= 0x00000003 ||
2961 - (mmfr0 & 0x000000f0) >= 0x00000030)
2962 + (mmfr0 & 0x000000f0) >= 0x00000030) {
2963 cpu_arch = CPU_ARCH_ARMv7;
2964 - else if ((mmfr0 & 0x0000000f) == 0x00000002 ||
2965 + if ((mmfr0 & 0x0000000f) == 0x00000005 || (mmfr0 & 0x0000000f) == 0x00000004) {
2966 + __supported_pte_mask |= L_PTE_PXN;
2967 + __supported_pmd_mask |= PMD_PXNTABLE;
2968 + }
2969 + } else if ((mmfr0 & 0x0000000f) == 0x00000002 ||
2970 (mmfr0 & 0x000000f0) == 0x00000020)
2971 cpu_arch = CPU_ARCH_ARMv6;
2972 else
2973 @@ -462,7 +468,7 @@ static void __init setup_processor(void)
2974 __cpu_architecture = __get_cpu_architecture();
2975
2976 #ifdef MULTI_CPU
2977 - processor = *list->proc;
2978 + memcpy((void *)&processor, list->proc, sizeof processor);
2979 #endif
2980 #ifdef MULTI_TLB
2981 cpu_tlb = *list->tlb;
2982 diff --git a/arch/arm/kernel/signal.c b/arch/arm/kernel/signal.c
2983 index 56f72d2..6924200 100644
2984 --- a/arch/arm/kernel/signal.c
2985 +++ b/arch/arm/kernel/signal.c
2986 @@ -433,22 +433,14 @@ setup_return(struct pt_regs *regs, struct k_sigaction *ka,
2987 __put_user(sigreturn_codes[idx+1], rc+1))
2988 return 1;
2989
2990 - if (cpsr & MODE32_BIT) {
2991 - /*
2992 - * 32-bit code can use the new high-page
2993 - * signal return code support.
2994 - */
2995 - retcode = KERN_SIGRETURN_CODE + (idx << 2) + thumb;
2996 - } else {
2997 - /*
2998 - * Ensure that the instruction cache sees
2999 - * the return code written onto the stack.
3000 - */
3001 - flush_icache_range((unsigned long)rc,
3002 - (unsigned long)(rc + 2));
3003 + /*
3004 + * Ensure that the instruction cache sees
3005 + * the return code written onto the stack.
3006 + */
3007 + flush_icache_range((unsigned long)rc,
3008 + (unsigned long)(rc + 2));
3009
3010 - retcode = ((unsigned long)rc) + thumb;
3011 - }
3012 + retcode = ((unsigned long)rc) + thumb;
3013 }
3014
3015 regs->ARM_r0 = usig;
3016 diff --git a/arch/arm/kernel/smp.c b/arch/arm/kernel/smp.c
3017 index 58af91c..343ce99 100644
3018 --- a/arch/arm/kernel/smp.c
3019 +++ b/arch/arm/kernel/smp.c
3020 @@ -70,7 +70,7 @@ enum ipi_msg_type {
3021
3022 static DECLARE_COMPLETION(cpu_running);
3023
3024 -static struct smp_operations smp_ops;
3025 +static struct smp_operations smp_ops __read_only;
3026
3027 void __init smp_set_ops(struct smp_operations *ops)
3028 {
3029 diff --git a/arch/arm/kernel/traps.c b/arch/arm/kernel/traps.c
3030 index b0179b8..829510e 100644
3031 --- a/arch/arm/kernel/traps.c
3032 +++ b/arch/arm/kernel/traps.c
3033 @@ -57,7 +57,7 @@ static void dump_mem(const char *, const char *, unsigned long, unsigned long);
3034 void dump_backtrace_entry(unsigned long where, unsigned long from, unsigned long frame)
3035 {
3036 #ifdef CONFIG_KALLSYMS
3037 - printk("[<%08lx>] (%pS) from [<%08lx>] (%pS)\n", where, (void *)where, from, (void *)from);
3038 + printk("[<%08lx>] (%pA) from [<%08lx>] (%pA)\n", where, (void *)where, from, (void *)from);
3039 #else
3040 printk("Function entered at [<%08lx>] from [<%08lx>]\n", where, from);
3041 #endif
3042 @@ -266,6 +266,8 @@ static arch_spinlock_t die_lock = __ARCH_SPIN_LOCK_UNLOCKED;
3043 static int die_owner = -1;
3044 static unsigned int die_nest_count;
3045
3046 +extern void gr_handle_kernel_exploit(void);
3047 +
3048 static unsigned long oops_begin(void)
3049 {
3050 int cpu;
3051 @@ -308,6 +310,9 @@ static void oops_end(unsigned long flags, struct pt_regs *regs, int signr)
3052 panic("Fatal exception in interrupt");
3053 if (panic_on_oops)
3054 panic("Fatal exception");
3055 +
3056 + gr_handle_kernel_exploit();
3057 +
3058 if (signr)
3059 do_exit(signr);
3060 }
3061 @@ -601,7 +606,9 @@ asmlinkage int arm_syscall(int no, struct pt_regs *regs)
3062 * The user helper at 0xffff0fe0 must be used instead.
3063 * (see entry-armv.S for details)
3064 */
3065 + pax_open_kernel();
3066 *((unsigned int *)0xffff0ff0) = regs->ARM_r0;
3067 + pax_close_kernel();
3068 }
3069 return 0;
3070
3071 @@ -841,13 +848,10 @@ void __init early_trap_init(void *vectors_base)
3072 */
3073 kuser_get_tls_init(vectors);
3074
3075 - /*
3076 - * Copy signal return handlers into the vector page, and
3077 - * set sigreturn to be a pointer to these.
3078 - */
3079 - memcpy((void *)(vectors + KERN_SIGRETURN_CODE - CONFIG_VECTORS_BASE),
3080 - sigreturn_codes, sizeof(sigreturn_codes));
3081 -
3082 flush_icache_range(vectors, vectors + PAGE_SIZE);
3083 - modify_domain(DOMAIN_USER, DOMAIN_CLIENT);
3084 +
3085 +#ifndef CONFIG_PAX_MEMORY_UDEREF
3086 + modify_domain(DOMAIN_USER, DOMAIN_USERCLIENT);
3087 +#endif
3088 +
3089 }
3090 diff --git a/arch/arm/kernel/vmlinux.lds.S b/arch/arm/kernel/vmlinux.lds.S
3091 index 11c1785..c67d54c 100644
3092 --- a/arch/arm/kernel/vmlinux.lds.S
3093 +++ b/arch/arm/kernel/vmlinux.lds.S
3094 @@ -8,7 +8,11 @@
3095 #include <asm/thread_info.h>
3096 #include <asm/memory.h>
3097 #include <asm/page.h>
3098 -
3099 +
3100 +#ifdef CONFIG_PAX_KERNEXEC
3101 +#include <asm/pgtable.h>
3102 +#endif
3103 +
3104 #define PROC_INFO \
3105 . = ALIGN(4); \
3106 VMLINUX_SYMBOL(__proc_info_begin) = .; \
3107 @@ -90,6 +94,11 @@ SECTIONS
3108 _text = .;
3109 HEAD_TEXT
3110 }
3111 +
3112 +#ifdef CONFIG_PAX_KERNEXEC
3113 + . = ALIGN(1<<SECTION_SHIFT);
3114 +#endif
3115 +
3116 .text : { /* Real text segment */
3117 _stext = .; /* Text and read-only data */
3118 __exception_text_start = .;
3119 @@ -144,6 +153,10 @@ SECTIONS
3120
3121 _etext = .; /* End of text and rodata section */
3122
3123 +#ifdef CONFIG_PAX_KERNEXEC
3124 + . = ALIGN(1<<SECTION_SHIFT);
3125 +#endif
3126 +
3127 #ifndef CONFIG_XIP_KERNEL
3128 . = ALIGN(PAGE_SIZE);
3129 __init_begin = .;
3130 @@ -203,6 +216,11 @@ SECTIONS
3131 . = PAGE_OFFSET + TEXT_OFFSET;
3132 #else
3133 __init_end = .;
3134 +
3135 +#ifdef CONFIG_PAX_KERNEXEC
3136 + . = ALIGN(1<<SECTION_SHIFT);
3137 +#endif
3138 +
3139 . = ALIGN(THREAD_SIZE);
3140 __data_loc = .;
3141 #endif
3142 diff --git a/arch/arm/lib/clear_user.S b/arch/arm/lib/clear_user.S
3143 index 14a0d98..7771a7d 100644
3144 --- a/arch/arm/lib/clear_user.S
3145 +++ b/arch/arm/lib/clear_user.S
3146 @@ -12,14 +12,14 @@
3147
3148 .text
3149
3150 -/* Prototype: int __clear_user(void *addr, size_t sz)
3151 +/* Prototype: int ___clear_user(void *addr, size_t sz)
3152 * Purpose : clear some user memory
3153 * Params : addr - user memory address to clear
3154 * : sz - number of bytes to clear
3155 * Returns : number of bytes NOT cleared
3156 */
3157 ENTRY(__clear_user_std)
3158 -WEAK(__clear_user)
3159 +WEAK(___clear_user)
3160 stmfd sp!, {r1, lr}
3161 mov r2, #0
3162 cmp r1, #4
3163 @@ -44,7 +44,7 @@ WEAK(__clear_user)
3164 USER( strnebt r2, [r0])
3165 mov r0, #0
3166 ldmfd sp!, {r1, pc}
3167 -ENDPROC(__clear_user)
3168 +ENDPROC(___clear_user)
3169 ENDPROC(__clear_user_std)
3170
3171 .pushsection .fixup,"ax"
3172 diff --git a/arch/arm/lib/copy_from_user.S b/arch/arm/lib/copy_from_user.S
3173 index 66a477a..bee61d3 100644
3174 --- a/arch/arm/lib/copy_from_user.S
3175 +++ b/arch/arm/lib/copy_from_user.S
3176 @@ -16,7 +16,7 @@
3177 /*
3178 * Prototype:
3179 *
3180 - * size_t __copy_from_user(void *to, const void *from, size_t n)
3181 + * size_t ___copy_from_user(void *to, const void *from, size_t n)
3182 *
3183 * Purpose:
3184 *
3185 @@ -84,11 +84,11 @@
3186
3187 .text
3188
3189 -ENTRY(__copy_from_user)
3190 +ENTRY(___copy_from_user)
3191
3192 #include "copy_template.S"
3193
3194 -ENDPROC(__copy_from_user)
3195 +ENDPROC(___copy_from_user)
3196
3197 .pushsection .fixup,"ax"
3198 .align 0
3199 diff --git a/arch/arm/lib/copy_page.S b/arch/arm/lib/copy_page.S
3200 index 6ee2f67..d1cce76 100644
3201 --- a/arch/arm/lib/copy_page.S
3202 +++ b/arch/arm/lib/copy_page.S
3203 @@ -10,6 +10,7 @@
3204 * ASM optimised string functions
3205 */
3206 #include <linux/linkage.h>
3207 +#include <linux/const.h>
3208 #include <asm/assembler.h>
3209 #include <asm/asm-offsets.h>
3210 #include <asm/cache.h>
3211 diff --git a/arch/arm/lib/copy_to_user.S b/arch/arm/lib/copy_to_user.S
3212 index d066df6..df28194 100644
3213 --- a/arch/arm/lib/copy_to_user.S
3214 +++ b/arch/arm/lib/copy_to_user.S
3215 @@ -16,7 +16,7 @@
3216 /*
3217 * Prototype:
3218 *
3219 - * size_t __copy_to_user(void *to, const void *from, size_t n)
3220 + * size_t ___copy_to_user(void *to, const void *from, size_t n)
3221 *
3222 * Purpose:
3223 *
3224 @@ -88,11 +88,11 @@
3225 .text
3226
3227 ENTRY(__copy_to_user_std)
3228 -WEAK(__copy_to_user)
3229 +WEAK(___copy_to_user)
3230
3231 #include "copy_template.S"
3232
3233 -ENDPROC(__copy_to_user)
3234 +ENDPROC(___copy_to_user)
3235 ENDPROC(__copy_to_user_std)
3236
3237 .pushsection .fixup,"ax"
3238 diff --git a/arch/arm/lib/csumpartialcopyuser.S b/arch/arm/lib/csumpartialcopyuser.S
3239 index 7d08b43..f7ca7ea 100644
3240 --- a/arch/arm/lib/csumpartialcopyuser.S
3241 +++ b/arch/arm/lib/csumpartialcopyuser.S
3242 @@ -57,8 +57,8 @@
3243 * Returns : r0 = checksum, [[sp, #0], #0] = 0 or -EFAULT
3244 */
3245
3246 -#define FN_ENTRY ENTRY(csum_partial_copy_from_user)
3247 -#define FN_EXIT ENDPROC(csum_partial_copy_from_user)
3248 +#define FN_ENTRY ENTRY(__csum_partial_copy_from_user)
3249 +#define FN_EXIT ENDPROC(__csum_partial_copy_from_user)
3250
3251 #include "csumpartialcopygeneric.S"
3252
3253 diff --git a/arch/arm/lib/delay.c b/arch/arm/lib/delay.c
3254 index 6b93f6a..88d9b64 100644
3255 --- a/arch/arm/lib/delay.c
3256 +++ b/arch/arm/lib/delay.c
3257 @@ -28,12 +28,14 @@
3258 /*
3259 * Default to the loop-based delay implementation.
3260 */
3261 -struct arm_delay_ops arm_delay_ops = {
3262 +static struct arm_delay_ops arm_loop_delay_ops = {
3263 .delay = __loop_delay,
3264 .const_udelay = __loop_const_udelay,
3265 .udelay = __loop_udelay,
3266 };
3267
3268 +struct arm_delay_ops *arm_delay_ops __read_only = &arm_loop_delay_ops;
3269 +
3270 static const struct delay_timer *delay_timer;
3271 static bool delay_calibrated;
3272
3273 @@ -67,6 +69,13 @@ static void __timer_udelay(unsigned long usecs)
3274 __timer_const_udelay(usecs * UDELAY_MULT);
3275 }
3276
3277 +static struct arm_delay_ops arm_timer_delay_ops = {
3278 + .delay = __timer_delay,
3279 + .const_udelay = __timer_const_udelay,
3280 + .udelay = __timer_udelay,
3281 + .const_clock = true,
3282 +};
3283 +
3284 void __init register_current_timer_delay(const struct delay_timer *timer)
3285 {
3286 if (!delay_calibrated) {
3287 @@ -74,10 +83,7 @@ void __init register_current_timer_delay(const struct delay_timer *timer)
3288 delay_timer = timer;
3289 lpj_fine = timer->freq / HZ;
3290 loops_per_jiffy = lpj_fine;
3291 - arm_delay_ops.delay = __timer_delay;
3292 - arm_delay_ops.const_udelay = __timer_const_udelay;
3293 - arm_delay_ops.udelay = __timer_udelay;
3294 - arm_delay_ops.const_clock = true;
3295 + arm_delay_ops = &arm_timer_delay_ops;
3296 delay_calibrated = true;
3297 } else {
3298 pr_info("Ignoring duplicate/late registration of read_current_timer delay\n");
3299 diff --git a/arch/arm/lib/uaccess_with_memcpy.c b/arch/arm/lib/uaccess_with_memcpy.c
3300 index 025f742..8432b08 100644
3301 --- a/arch/arm/lib/uaccess_with_memcpy.c
3302 +++ b/arch/arm/lib/uaccess_with_memcpy.c
3303 @@ -104,7 +104,7 @@ out:
3304 }
3305
3306 unsigned long
3307 -__copy_to_user(void __user *to, const void *from, unsigned long n)
3308 +___copy_to_user(void __user *to, const void *from, unsigned long n)
3309 {
3310 /*
3311 * This test is stubbed out of the main function above to keep
3312 diff --git a/arch/arm/mach-kirkwood/common.c b/arch/arm/mach-kirkwood/common.c
3313 index bac21a5..b67ef8e 100644
3314 --- a/arch/arm/mach-kirkwood/common.c
3315 +++ b/arch/arm/mach-kirkwood/common.c
3316 @@ -150,7 +150,16 @@ static void clk_gate_fn_disable(struct clk_hw *hw)
3317 clk_gate_ops.disable(hw);
3318 }
3319
3320 -static struct clk_ops clk_gate_fn_ops;
3321 +static int clk_gate_fn_is_enabled(struct clk_hw *hw)
3322 +{
3323 + return clk_gate_ops.is_enabled(hw);
3324 +}
3325 +
3326 +static struct clk_ops clk_gate_fn_ops = {
3327 + .enable = clk_gate_fn_enable,
3328 + .disable = clk_gate_fn_disable,
3329 + .is_enabled = clk_gate_fn_is_enabled,
3330 +};
3331
3332 static struct clk __init *clk_register_gate_fn(struct device *dev,
3333 const char *name,
3334 @@ -184,14 +193,6 @@ static struct clk __init *clk_register_gate_fn(struct device *dev,
3335 gate_fn->fn_en = fn_en;
3336 gate_fn->fn_dis = fn_dis;
3337
3338 - /* ops is the gate ops, but with our enable/disable functions */
3339 - if (clk_gate_fn_ops.enable != clk_gate_fn_enable ||
3340 - clk_gate_fn_ops.disable != clk_gate_fn_disable) {
3341 - clk_gate_fn_ops = clk_gate_ops;
3342 - clk_gate_fn_ops.enable = clk_gate_fn_enable;
3343 - clk_gate_fn_ops.disable = clk_gate_fn_disable;
3344 - }
3345 -
3346 clk = clk_register(dev, &gate_fn->gate.hw);
3347
3348 if (IS_ERR(clk))
3349 diff --git a/arch/arm/mach-omap2/board-n8x0.c b/arch/arm/mach-omap2/board-n8x0.c
3350 index 0abb30f..54064da 100644
3351 --- a/arch/arm/mach-omap2/board-n8x0.c
3352 +++ b/arch/arm/mach-omap2/board-n8x0.c
3353 @@ -631,7 +631,7 @@ static int n8x0_menelaus_late_init(struct device *dev)
3354 }
3355 #endif
3356
3357 -static struct menelaus_platform_data n8x0_menelaus_platform_data __initdata = {
3358 +static struct menelaus_platform_data n8x0_menelaus_platform_data __initconst = {
3359 .late_init = n8x0_menelaus_late_init,
3360 };
3361
3362 diff --git a/arch/arm/mach-omap2/gpmc.c b/arch/arm/mach-omap2/gpmc.c
3363 index 8033cb7..2f7cb62 100644
3364 --- a/arch/arm/mach-omap2/gpmc.c
3365 +++ b/arch/arm/mach-omap2/gpmc.c
3366 @@ -139,7 +139,6 @@ struct omap3_gpmc_regs {
3367 };
3368
3369 static struct gpmc_client_irq gpmc_client_irq[GPMC_NR_IRQ];
3370 -static struct irq_chip gpmc_irq_chip;
3371 static unsigned gpmc_irq_start;
3372
3373 static struct resource gpmc_mem_root;
3374 @@ -700,6 +699,18 @@ static void gpmc_irq_noop(struct irq_data *data) { }
3375
3376 static unsigned int gpmc_irq_noop_ret(struct irq_data *data) { return 0; }
3377
3378 +static struct irq_chip gpmc_irq_chip = {
3379 + .name = "gpmc",
3380 + .irq_startup = gpmc_irq_noop_ret,
3381 + .irq_enable = gpmc_irq_enable,
3382 + .irq_disable = gpmc_irq_disable,
3383 + .irq_shutdown = gpmc_irq_noop,
3384 + .irq_ack = gpmc_irq_noop,
3385 + .irq_mask = gpmc_irq_noop,
3386 + .irq_unmask = gpmc_irq_noop,
3387 +
3388 +};
3389 +
3390 static int gpmc_setup_irq(void)
3391 {
3392 int i;
3393 @@ -714,15 +725,6 @@ static int gpmc_setup_irq(void)
3394 return gpmc_irq_start;
3395 }
3396
3397 - gpmc_irq_chip.name = "gpmc";
3398 - gpmc_irq_chip.irq_startup = gpmc_irq_noop_ret;
3399 - gpmc_irq_chip.irq_enable = gpmc_irq_enable;
3400 - gpmc_irq_chip.irq_disable = gpmc_irq_disable;
3401 - gpmc_irq_chip.irq_shutdown = gpmc_irq_noop;
3402 - gpmc_irq_chip.irq_ack = gpmc_irq_noop;
3403 - gpmc_irq_chip.irq_mask = gpmc_irq_noop;
3404 - gpmc_irq_chip.irq_unmask = gpmc_irq_noop;
3405 -
3406 gpmc_client_irq[0].bitmask = GPMC_IRQ_FIFOEVENTENABLE;
3407 gpmc_client_irq[1].bitmask = GPMC_IRQ_COUNT_EVENT;
3408
3409 diff --git a/arch/arm/mach-omap2/omap-wakeupgen.c b/arch/arm/mach-omap2/omap-wakeupgen.c
3410 index 5d3b4f4..ddba3c0 100644
3411 --- a/arch/arm/mach-omap2/omap-wakeupgen.c
3412 +++ b/arch/arm/mach-omap2/omap-wakeupgen.c
3413 @@ -340,7 +340,7 @@ static int __cpuinit irq_cpu_hotplug_notify(struct notifier_block *self,
3414 return NOTIFY_OK;
3415 }
3416
3417 -static struct notifier_block __refdata irq_hotplug_notifier = {
3418 +static struct notifier_block irq_hotplug_notifier = {
3419 .notifier_call = irq_cpu_hotplug_notify,
3420 };
3421
3422 diff --git a/arch/arm/mach-omap2/omap_device.c b/arch/arm/mach-omap2/omap_device.c
3423 index e065daa..7b1ad9b 100644
3424 --- a/arch/arm/mach-omap2/omap_device.c
3425 +++ b/arch/arm/mach-omap2/omap_device.c
3426 @@ -686,7 +686,7 @@ void omap_device_delete(struct omap_device *od)
3427 * passes along the return value of omap_device_build_ss().
3428 */
3429 struct platform_device __init *omap_device_build(const char *pdev_name, int pdev_id,
3430 - struct omap_hwmod *oh, void *pdata,
3431 + struct omap_hwmod *oh, const void *pdata,
3432 int pdata_len,
3433 struct omap_device_pm_latency *pm_lats,
3434 int pm_lats_cnt, int is_early_device)
3435 @@ -720,7 +720,7 @@ struct platform_device __init *omap_device_build(const char *pdev_name, int pdev
3436 */
3437 struct platform_device __init *omap_device_build_ss(const char *pdev_name, int pdev_id,
3438 struct omap_hwmod **ohs, int oh_cnt,
3439 - void *pdata, int pdata_len,
3440 + const void *pdata, int pdata_len,
3441 struct omap_device_pm_latency *pm_lats,
3442 int pm_lats_cnt, int is_early_device)
3443 {
3444 diff --git a/arch/arm/mach-omap2/omap_device.h b/arch/arm/mach-omap2/omap_device.h
3445 index 0933c59..42b8e2d 100644
3446 --- a/arch/arm/mach-omap2/omap_device.h
3447 +++ b/arch/arm/mach-omap2/omap_device.h
3448 @@ -91,14 +91,14 @@ int omap_device_shutdown(struct platform_device *pdev);
3449 /* Core code interface */
3450
3451 struct platform_device *omap_device_build(const char *pdev_name, int pdev_id,
3452 - struct omap_hwmod *oh, void *pdata,
3453 + struct omap_hwmod *oh, const void *pdata,
3454 int pdata_len,
3455 struct omap_device_pm_latency *pm_lats,
3456 int pm_lats_cnt, int is_early_device);
3457
3458 struct platform_device *omap_device_build_ss(const char *pdev_name, int pdev_id,
3459 struct omap_hwmod **oh, int oh_cnt,
3460 - void *pdata, int pdata_len,
3461 + const void *pdata, int pdata_len,
3462 struct omap_device_pm_latency *pm_lats,
3463 int pm_lats_cnt, int is_early_device);
3464
3465 diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c
3466 index 4653efb..8c60bf7 100644
3467 --- a/arch/arm/mach-omap2/omap_hwmod.c
3468 +++ b/arch/arm/mach-omap2/omap_hwmod.c
3469 @@ -189,10 +189,10 @@ struct omap_hwmod_soc_ops {
3470 int (*init_clkdm)(struct omap_hwmod *oh);
3471 void (*update_context_lost)(struct omap_hwmod *oh);
3472 int (*get_context_lost)(struct omap_hwmod *oh);
3473 -};
3474 +} __no_const;
3475
3476 /* soc_ops: adapts the omap_hwmod code to the currently-booted SoC */
3477 -static struct omap_hwmod_soc_ops soc_ops;
3478 +static struct omap_hwmod_soc_ops soc_ops __read_only;
3479
3480 /* omap_hwmod_list contains all registered struct omap_hwmods */
3481 static LIST_HEAD(omap_hwmod_list);
3482 diff --git a/arch/arm/mach-omap2/wd_timer.c b/arch/arm/mach-omap2/wd_timer.c
3483 index 7c2b4ed..b2ea51f 100644
3484 --- a/arch/arm/mach-omap2/wd_timer.c
3485 +++ b/arch/arm/mach-omap2/wd_timer.c
3486 @@ -110,7 +110,9 @@ static int __init omap_init_wdt(void)
3487 struct omap_hwmod *oh;
3488 char *oh_name = "wd_timer2";
3489 char *dev_name = "omap_wdt";
3490 - struct omap_wd_timer_platform_data pdata;
3491 + static struct omap_wd_timer_platform_data pdata = {
3492 + .read_reset_sources = prm_read_reset_sources
3493 + };
3494
3495 if (!cpu_class_is_omap2() || of_have_populated_dt())
3496 return 0;
3497 @@ -121,8 +123,6 @@ static int __init omap_init_wdt(void)
3498 return -EINVAL;
3499 }
3500
3501 - pdata.read_reset_sources = prm_read_reset_sources;
3502 -
3503 pdev = omap_device_build(dev_name, id, oh, &pdata,
3504 sizeof(struct omap_wd_timer_platform_data),
3505 NULL, 0, 0);
3506 diff --git a/arch/arm/mach-ux500/include/mach/setup.h b/arch/arm/mach-ux500/include/mach/setup.h
3507 index 6be4c4d..32ac32a 100644
3508 --- a/arch/arm/mach-ux500/include/mach/setup.h
3509 +++ b/arch/arm/mach-ux500/include/mach/setup.h
3510 @@ -38,13 +38,6 @@ extern struct sys_timer ux500_timer;
3511 .type = MT_DEVICE, \
3512 }
3513
3514 -#define __MEM_DEV_DESC(x, sz) { \
3515 - .virtual = IO_ADDRESS(x), \
3516 - .pfn = __phys_to_pfn(x), \
3517 - .length = sz, \
3518 - .type = MT_MEMORY, \
3519 -}
3520 -
3521 extern struct smp_operations ux500_smp_ops;
3522 extern void ux500_cpu_die(unsigned int cpu);
3523
3524 diff --git a/arch/arm/mm/Kconfig b/arch/arm/mm/Kconfig
3525 index 3fd629d..8b1aca9 100644
3526 --- a/arch/arm/mm/Kconfig
3527 +++ b/arch/arm/mm/Kconfig
3528 @@ -425,7 +425,7 @@ config CPU_32v5
3529
3530 config CPU_32v6
3531 bool
3532 - select CPU_USE_DOMAINS if CPU_V6 && MMU
3533 + select CPU_USE_DOMAINS if CPU_V6 && MMU && !PAX_KERNEXEC
3534 select TLS_REG_EMUL if !CPU_32v6K && !MMU
3535
3536 config CPU_32v6K
3537 @@ -577,6 +577,7 @@ config CPU_CP15_MPU
3538
3539 config CPU_USE_DOMAINS
3540 bool
3541 + depends on !ARM_LPAE && !PAX_KERNEXEC
3542 help
3543 This option enables or disables the use of domain switching
3544 via the set_fs() function.
3545 diff --git a/arch/arm/mm/alignment.c b/arch/arm/mm/alignment.c
3546 index db26e2e..ee44569 100644
3547 --- a/arch/arm/mm/alignment.c
3548 +++ b/arch/arm/mm/alignment.c
3549 @@ -211,10 +211,12 @@ union offset_union {
3550 #define __get16_unaligned_check(ins,val,addr) \
3551 do { \
3552 unsigned int err = 0, v, a = addr; \
3553 + pax_open_userland(); \
3554 __get8_unaligned_check(ins,v,a,err); \
3555 val = v << ((BE) ? 8 : 0); \
3556 __get8_unaligned_check(ins,v,a,err); \
3557 val |= v << ((BE) ? 0 : 8); \
3558 + pax_close_userland(); \
3559 if (err) \
3560 goto fault; \
3561 } while (0)
3562 @@ -228,6 +230,7 @@ union offset_union {
3563 #define __get32_unaligned_check(ins,val,addr) \
3564 do { \
3565 unsigned int err = 0, v, a = addr; \
3566 + pax_open_userland(); \
3567 __get8_unaligned_check(ins,v,a,err); \
3568 val = v << ((BE) ? 24 : 0); \
3569 __get8_unaligned_check(ins,v,a,err); \
3570 @@ -236,6 +239,7 @@ union offset_union {
3571 val |= v << ((BE) ? 8 : 16); \
3572 __get8_unaligned_check(ins,v,a,err); \
3573 val |= v << ((BE) ? 0 : 24); \
3574 + pax_close_userland(); \
3575 if (err) \
3576 goto fault; \
3577 } while (0)
3578 @@ -249,6 +253,7 @@ union offset_union {
3579 #define __put16_unaligned_check(ins,val,addr) \
3580 do { \
3581 unsigned int err = 0, v = val, a = addr; \
3582 + pax_open_userland(); \
3583 __asm__( FIRST_BYTE_16 \
3584 ARM( "1: "ins" %1, [%2], #1\n" ) \
3585 THUMB( "1: "ins" %1, [%2]\n" ) \
3586 @@ -268,6 +273,7 @@ union offset_union {
3587 " .popsection\n" \
3588 : "=r" (err), "=&r" (v), "=&r" (a) \
3589 : "0" (err), "1" (v), "2" (a)); \
3590 + pax_close_userland(); \
3591 if (err) \
3592 goto fault; \
3593 } while (0)
3594 @@ -281,6 +287,7 @@ union offset_union {
3595 #define __put32_unaligned_check(ins,val,addr) \
3596 do { \
3597 unsigned int err = 0, v = val, a = addr; \
3598 + pax_open_userland(); \
3599 __asm__( FIRST_BYTE_32 \
3600 ARM( "1: "ins" %1, [%2], #1\n" ) \
3601 THUMB( "1: "ins" %1, [%2]\n" ) \
3602 @@ -310,6 +317,7 @@ union offset_union {
3603 " .popsection\n" \
3604 : "=r" (err), "=&r" (v), "=&r" (a) \
3605 : "0" (err), "1" (v), "2" (a)); \
3606 + pax_close_userland(); \
3607 if (err) \
3608 goto fault; \
3609 } while (0)
3610 diff --git a/arch/arm/mm/fault.c b/arch/arm/mm/fault.c
3611 index 5dbf13f..1a60561 100644
3612 --- a/arch/arm/mm/fault.c
3613 +++ b/arch/arm/mm/fault.c
3614 @@ -25,6 +25,7 @@
3615 #include <asm/system_misc.h>
3616 #include <asm/system_info.h>
3617 #include <asm/tlbflush.h>
3618 +#include <asm/sections.h>
3619
3620 #include "fault.h"
3621
3622 @@ -138,6 +139,20 @@ __do_kernel_fault(struct mm_struct *mm, unsigned long addr, unsigned int fsr,
3623 if (fixup_exception(regs))
3624 return;
3625
3626 +#ifdef CONFIG_PAX_KERNEXEC
3627 + if ((fsr & FSR_WRITE) &&
3628 + (((unsigned long)_stext <= addr && addr < init_mm.end_code) ||
3629 + (MODULES_VADDR <= addr && addr < MODULES_END)))
3630 + {
3631 + if (current->signal->curr_ip)
3632 + 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),
3633 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
3634 + else
3635 + printk(KERN_ERR "PAX: %s:%d, uid/euid: %u/%u, attempted to modify kernel code\n", current->comm, task_pid_nr(current),
3636 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
3637 + }
3638 +#endif
3639 +
3640 /*
3641 * No handler, we'll have to terminate things with extreme prejudice.
3642 */
3643 @@ -174,6 +189,13 @@ __do_user_fault(struct task_struct *tsk, unsigned long addr,
3644 }
3645 #endif
3646
3647 +#ifdef CONFIG_PAX_PAGEEXEC
3648 + if (fsr & FSR_LNX_PF) {
3649 + pax_report_fault(regs, (void *)regs->ARM_pc, (void *)regs->ARM_sp);
3650 + do_group_exit(SIGKILL);
3651 + }
3652 +#endif
3653 +
3654 tsk->thread.address = addr;
3655 tsk->thread.error_code = fsr;
3656 tsk->thread.trap_no = 14;
3657 @@ -398,6 +420,33 @@ do_page_fault(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
3658 }
3659 #endif /* CONFIG_MMU */
3660
3661 +#ifdef CONFIG_PAX_PAGEEXEC
3662 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
3663 +{
3664 + long i;
3665 +
3666 + printk(KERN_ERR "PAX: bytes at PC: ");
3667 + for (i = 0; i < 20; i++) {
3668 + unsigned char c;
3669 + if (get_user(c, (__force unsigned char __user *)pc+i))
3670 + printk(KERN_CONT "?? ");
3671 + else
3672 + printk(KERN_CONT "%02x ", c);
3673 + }
3674 + printk("\n");
3675 +
3676 + printk(KERN_ERR "PAX: bytes at SP-4: ");
3677 + for (i = -1; i < 20; i++) {
3678 + unsigned long c;
3679 + if (get_user(c, (__force unsigned long __user *)sp+i))
3680 + printk(KERN_CONT "???????? ");
3681 + else
3682 + printk(KERN_CONT "%08lx ", c);
3683 + }
3684 + printk("\n");
3685 +}
3686 +#endif
3687 +
3688 /*
3689 * First Level Translation Fault Handler
3690 *
3691 @@ -543,9 +592,22 @@ do_DataAbort(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
3692 const struct fsr_info *inf = fsr_info + fsr_fs(fsr);
3693 struct siginfo info;
3694
3695 +#ifdef CONFIG_PAX_MEMORY_UDEREF
3696 + if (addr < TASK_SIZE && is_domain_fault(fsr)) {
3697 + if (current->signal->curr_ip)
3698 + 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),
3699 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()), addr);
3700 + else
3701 + printk(KERN_ERR "PAX: %s:%d, uid/euid: %u/%u, attempted to access userland memory at %08lx\n", current->comm, task_pid_nr(current),
3702 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()), addr);
3703 + goto die;
3704 + }
3705 +#endif
3706 +
3707 if (!inf->fn(addr, fsr & ~FSR_LNX_PF, regs))
3708 return;
3709
3710 +die:
3711 printk(KERN_ALERT "Unhandled fault: %s (0x%03x) at 0x%08lx\n",
3712 inf->name, fsr, addr);
3713
3714 @@ -575,9 +637,49 @@ do_PrefetchAbort(unsigned long addr, unsigned int ifsr, struct pt_regs *regs)
3715 const struct fsr_info *inf = ifsr_info + fsr_fs(ifsr);
3716 struct siginfo info;
3717
3718 + if (user_mode(regs)) {
3719 + if (addr == 0xffff0fe0UL) {
3720 + /*
3721 + * PaX: __kuser_get_tls emulation
3722 + */
3723 + regs->ARM_r0 = current_thread_info()->tp_value;
3724 + regs->ARM_pc = regs->ARM_lr;
3725 + return;
3726 + }
3727 + }
3728 +
3729 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
3730 + else if (is_domain_fault(ifsr) || is_xn_fault(ifsr)) {
3731 + if (current->signal->curr_ip)
3732 + 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),
3733 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()),
3734 + addr >= TASK_SIZE ? "non-executable kernel" : "userland", addr);
3735 + else
3736 + printk(KERN_ERR "PAX: %s:%d, uid/euid: %u/%u, attempted to execute %s memory at %08lx\n", current->comm, task_pid_nr(current),
3737 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()),
3738 + addr >= TASK_SIZE ? "non-executable kernel" : "userland", addr);
3739 + goto die;
3740 + }
3741 +#endif
3742 +
3743 +#ifdef CONFIG_PAX_REFCOUNT
3744 + if (fsr_fs(ifsr) == FAULT_CODE_DEBUG) {
3745 + unsigned int bkpt;
3746 +
3747 + if (!probe_kernel_address((unsigned int *)addr, bkpt) && bkpt == 0xe12f1073) {
3748 + current->thread.error_code = ifsr;
3749 + current->thread.trap_no = 0;
3750 + pax_report_refcount_overflow(regs);
3751 + fixup_exception(regs);
3752 + return;
3753 + }
3754 + }
3755 +#endif
3756 +
3757 if (!inf->fn(addr, ifsr | FSR_LNX_PF, regs))
3758 return;
3759
3760 +die:
3761 printk(KERN_ALERT "Unhandled prefetch abort: %s (0x%03x) at 0x%08lx\n",
3762 inf->name, ifsr, addr);
3763
3764 diff --git a/arch/arm/mm/fault.h b/arch/arm/mm/fault.h
3765 index cf08bdf..772656c 100644
3766 --- a/arch/arm/mm/fault.h
3767 +++ b/arch/arm/mm/fault.h
3768 @@ -3,6 +3,7 @@
3769
3770 /*
3771 * Fault status register encodings. We steal bit 31 for our own purposes.
3772 + * Set when the FSR value is from an instruction fault.
3773 */
3774 #define FSR_LNX_PF (1 << 31)
3775 #define FSR_WRITE (1 << 11)
3776 @@ -22,6 +23,17 @@ static inline int fsr_fs(unsigned int fsr)
3777 }
3778 #endif
3779
3780 +/* valid for LPAE and !LPAE */
3781 +static inline int is_xn_fault(unsigned int fsr)
3782 +{
3783 + return ((fsr_fs(fsr) & 0x3c) == 0xc);
3784 +}
3785 +
3786 +static inline int is_domain_fault(unsigned int fsr)
3787 +{
3788 + return ((fsr_fs(fsr) & 0xD) == 0x9);
3789 +}
3790 +
3791 void do_bad_area(unsigned long addr, unsigned int fsr, struct pt_regs *regs);
3792 unsigned long search_exception_table(unsigned long addr);
3793
3794 diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c
3795 index ad722f1..763fdd3 100644
3796 --- a/arch/arm/mm/init.c
3797 +++ b/arch/arm/mm/init.c
3798 @@ -30,6 +30,8 @@
3799 #include <asm/setup.h>
3800 #include <asm/tlb.h>
3801 #include <asm/fixmap.h>
3802 +#include <asm/system_info.h>
3803 +#include <asm/cp15.h>
3804
3805 #include <asm/mach/arch.h>
3806 #include <asm/mach/map.h>
3807 @@ -736,7 +738,46 @@ void free_initmem(void)
3808 {
3809 #ifdef CONFIG_HAVE_TCM
3810 extern char __tcm_start, __tcm_end;
3811 +#endif
3812
3813 +#ifdef CONFIG_PAX_KERNEXEC
3814 + unsigned long addr;
3815 + pgd_t *pgd;
3816 + pud_t *pud;
3817 + pmd_t *pmd;
3818 + int cpu_arch = cpu_architecture();
3819 + unsigned int cr = get_cr();
3820 +
3821 + if (cpu_arch >= CPU_ARCH_ARMv6 && (cr & CR_XP)) {
3822 + /* make pages tables, etc before .text NX */
3823 + for (addr = PAGE_OFFSET; addr < (unsigned long)_stext; addr += SECTION_SIZE) {
3824 + pgd = pgd_offset_k(addr);
3825 + pud = pud_offset(pgd, addr);
3826 + pmd = pmd_offset(pud, addr);
3827 + __section_update(pmd, addr, PMD_SECT_XN);
3828 + }
3829 + /* make init NX */
3830 + for (addr = (unsigned long)__init_begin; addr < (unsigned long)_sdata; addr += SECTION_SIZE) {
3831 + pgd = pgd_offset_k(addr);
3832 + pud = pud_offset(pgd, addr);
3833 + pmd = pmd_offset(pud, addr);
3834 + __section_update(pmd, addr, PMD_SECT_XN);
3835 + }
3836 + /* make kernel code/rodata RX */
3837 + for (addr = (unsigned long)_stext; addr < (unsigned long)__init_begin; addr += SECTION_SIZE) {
3838 + pgd = pgd_offset_k(addr);
3839 + pud = pud_offset(pgd, addr);
3840 + pmd = pmd_offset(pud, addr);
3841 +#ifdef CONFIG_ARM_LPAE
3842 + __section_update(pmd, addr, PMD_SECT_RDONLY);
3843 +#else
3844 + __section_update(pmd, addr, PMD_SECT_APX|PMD_SECT_AP_WRITE);
3845 +#endif
3846 + }
3847 + }
3848 +#endif
3849 +
3850 +#ifdef CONFIG_HAVE_TCM
3851 poison_init_mem(&__tcm_start, &__tcm_end - &__tcm_start);
3852 totalram_pages += free_area(__phys_to_pfn(__pa(&__tcm_start)),
3853 __phys_to_pfn(__pa(&__tcm_end)),
3854 diff --git a/arch/arm/mm/ioremap.c b/arch/arm/mm/ioremap.c
3855 index 88fd86c..7a224ce 100644
3856 --- a/arch/arm/mm/ioremap.c
3857 +++ b/arch/arm/mm/ioremap.c
3858 @@ -335,9 +335,9 @@ __arm_ioremap_exec(unsigned long phys_addr, size_t size, bool cached)
3859 unsigned int mtype;
3860
3861 if (cached)
3862 - mtype = MT_MEMORY;
3863 + mtype = MT_MEMORY_RX;
3864 else
3865 - mtype = MT_MEMORY_NONCACHED;
3866 + mtype = MT_MEMORY_NONCACHED_RX;
3867
3868 return __arm_ioremap_caller(phys_addr, size, mtype,
3869 __builtin_return_address(0));
3870 diff --git a/arch/arm/mm/mmap.c b/arch/arm/mm/mmap.c
3871 index 10062ce..aa96dd7 100644
3872 --- a/arch/arm/mm/mmap.c
3873 +++ b/arch/arm/mm/mmap.c
3874 @@ -59,6 +59,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
3875 struct vm_area_struct *vma;
3876 int do_align = 0;
3877 int aliasing = cache_is_vipt_aliasing();
3878 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
3879 struct vm_unmapped_area_info info;
3880
3881 /*
3882 @@ -81,6 +82,10 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
3883 if (len > TASK_SIZE)
3884 return -ENOMEM;
3885
3886 +#ifdef CONFIG_PAX_RANDMMAP
3887 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
3888 +#endif
3889 +
3890 if (addr) {
3891 if (do_align)
3892 addr = COLOUR_ALIGN(addr, pgoff);
3893 @@ -88,8 +93,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
3894 addr = PAGE_ALIGN(addr);
3895
3896 vma = find_vma(mm, addr);
3897 - if (TASK_SIZE - len >= addr &&
3898 - (!vma || addr + len <= vma->vm_start))
3899 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
3900 return addr;
3901 }
3902
3903 @@ -112,6 +116,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
3904 unsigned long addr = addr0;
3905 int do_align = 0;
3906 int aliasing = cache_is_vipt_aliasing();
3907 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
3908 struct vm_unmapped_area_info info;
3909
3910 /*
3911 @@ -132,6 +137,10 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
3912 return addr;
3913 }
3914
3915 +#ifdef CONFIG_PAX_RANDMMAP
3916 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
3917 +#endif
3918 +
3919 /* requesting a specific address */
3920 if (addr) {
3921 if (do_align)
3922 @@ -139,8 +148,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
3923 else
3924 addr = PAGE_ALIGN(addr);
3925 vma = find_vma(mm, addr);
3926 - if (TASK_SIZE - len >= addr &&
3927 - (!vma || addr + len <= vma->vm_start))
3928 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
3929 return addr;
3930 }
3931
3932 @@ -162,6 +170,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
3933 VM_BUG_ON(addr != -ENOMEM);
3934 info.flags = 0;
3935 info.low_limit = mm->mmap_base;
3936 +
3937 +#ifdef CONFIG_PAX_RANDMMAP
3938 + if (mm->pax_flags & MF_PAX_RANDMMAP)
3939 + info.low_limit += mm->delta_mmap;
3940 +#endif
3941 +
3942 info.high_limit = TASK_SIZE;
3943 addr = vm_unmapped_area(&info);
3944 }
3945 @@ -173,6 +187,10 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
3946 {
3947 unsigned long random_factor = 0UL;
3948
3949 +#ifdef CONFIG_PAX_RANDMMAP
3950 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
3951 +#endif
3952 +
3953 /* 8 bits of randomness in 20 address space bits */
3954 if ((current->flags & PF_RANDOMIZE) &&
3955 !(current->personality & ADDR_NO_RANDOMIZE))
3956 @@ -180,10 +198,22 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
3957
3958 if (mmap_is_legacy()) {
3959 mm->mmap_base = TASK_UNMAPPED_BASE + random_factor;
3960 +
3961 +#ifdef CONFIG_PAX_RANDMMAP
3962 + if (mm->pax_flags & MF_PAX_RANDMMAP)
3963 + mm->mmap_base += mm->delta_mmap;
3964 +#endif
3965 +
3966 mm->get_unmapped_area = arch_get_unmapped_area;
3967 mm->unmap_area = arch_unmap_area;
3968 } else {
3969 mm->mmap_base = mmap_base(random_factor);
3970 +
3971 +#ifdef CONFIG_PAX_RANDMMAP
3972 + if (mm->pax_flags & MF_PAX_RANDMMAP)
3973 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
3974 +#endif
3975 +
3976 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
3977 mm->unmap_area = arch_unmap_area_topdown;
3978 }
3979 diff --git a/arch/arm/mm/mmu.c b/arch/arm/mm/mmu.c
3980 index ce328c7..35b88dc 100644
3981 --- a/arch/arm/mm/mmu.c
3982 +++ b/arch/arm/mm/mmu.c
3983 @@ -35,6 +35,23 @@
3984
3985 #include "mm.h"
3986
3987 +
3988 +#if defined(CONFIG_CPU_USE_DOMAINS) || defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
3989 +void modify_domain(unsigned int dom, unsigned int type)
3990 +{
3991 + struct thread_info *thread = current_thread_info();
3992 + unsigned int domain = thread->cpu_domain;
3993 + /*
3994 + * DOMAIN_MANAGER might be defined to some other value,
3995 + * use the arch-defined constant
3996 + */
3997 + domain &= ~domain_val(dom, 3);
3998 + thread->cpu_domain = domain | domain_val(dom, type);
3999 + set_domain(thread->cpu_domain);
4000 +}
4001 +EXPORT_SYMBOL(modify_domain);
4002 +#endif
4003 +
4004 /*
4005 * empty_zero_page is a special page that is used for
4006 * zero-initialized data and COW.
4007 @@ -195,10 +212,18 @@ void adjust_cr(unsigned long mask, unsigned long set)
4008 }
4009 #endif
4010
4011 -#define PROT_PTE_DEVICE L_PTE_PRESENT|L_PTE_YOUNG|L_PTE_DIRTY|L_PTE_XN
4012 +#define PROT_PTE_DEVICE L_PTE_PRESENT|L_PTE_YOUNG|L_PTE_DIRTY
4013 #define PROT_SECT_DEVICE PMD_TYPE_SECT|PMD_SECT_AP_WRITE
4014
4015 -static struct mem_type mem_types[] = {
4016 +#ifdef CONFIG_PAX_KERNEXEC
4017 +#define L_PTE_KERNEXEC L_PTE_RDONLY
4018 +#define PMD_SECT_KERNEXEC PMD_SECT_RDONLY
4019 +#else
4020 +#define L_PTE_KERNEXEC L_PTE_DIRTY
4021 +#define PMD_SECT_KERNEXEC PMD_SECT_AP_WRITE
4022 +#endif
4023 +
4024 +static struct mem_type mem_types[] __read_only = {
4025 [MT_DEVICE] = { /* Strongly ordered / ARMv6 shared device */
4026 .prot_pte = PROT_PTE_DEVICE | L_PTE_MT_DEV_SHARED |
4027 L_PTE_SHARED,
4028 @@ -227,16 +252,16 @@ static struct mem_type mem_types[] = {
4029 [MT_UNCACHED] = {
4030 .prot_pte = PROT_PTE_DEVICE,
4031 .prot_l1 = PMD_TYPE_TABLE,
4032 - .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN,
4033 + .prot_sect = PROT_SECT_DEVICE,
4034 .domain = DOMAIN_IO,
4035 },
4036 [MT_CACHECLEAN] = {
4037 - .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN,
4038 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_RDONLY,
4039 .domain = DOMAIN_KERNEL,
4040 },
4041 #ifndef CONFIG_ARM_LPAE
4042 [MT_MINICLEAN] = {
4043 - .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN | PMD_SECT_MINICACHE,
4044 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_MINICACHE | PMD_SECT_RDONLY,
4045 .domain = DOMAIN_KERNEL,
4046 },
4047 #endif
4048 @@ -244,36 +269,54 @@ static struct mem_type mem_types[] = {
4049 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4050 L_PTE_RDONLY,
4051 .prot_l1 = PMD_TYPE_TABLE,
4052 - .domain = DOMAIN_USER,
4053 + .domain = DOMAIN_VECTORS,
4054 },
4055 [MT_HIGH_VECTORS] = {
4056 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4057 - L_PTE_USER | L_PTE_RDONLY,
4058 + L_PTE_RDONLY,
4059 .prot_l1 = PMD_TYPE_TABLE,
4060 - .domain = DOMAIN_USER,
4061 + .domain = DOMAIN_VECTORS,
4062 },
4063 - [MT_MEMORY] = {
4064 + [MT_MEMORY_RWX] = {
4065 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY,
4066 .prot_l1 = PMD_TYPE_TABLE,
4067 .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE,
4068 .domain = DOMAIN_KERNEL,
4069 },
4070 + [MT_MEMORY_RW] = {
4071 + .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY,
4072 + .prot_l1 = PMD_TYPE_TABLE,
4073 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE,
4074 + .domain = DOMAIN_KERNEL,
4075 + },
4076 + [MT_MEMORY_RX] = {
4077 + .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_KERNEXEC,
4078 + .prot_l1 = PMD_TYPE_TABLE,
4079 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_KERNEXEC,
4080 + .domain = DOMAIN_KERNEL,
4081 + },
4082 [MT_ROM] = {
4083 - .prot_sect = PMD_TYPE_SECT,
4084 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_RDONLY,
4085 .domain = DOMAIN_KERNEL,
4086 },
4087 - [MT_MEMORY_NONCACHED] = {
4088 + [MT_MEMORY_NONCACHED_RW] = {
4089 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4090 L_PTE_MT_BUFFERABLE,
4091 .prot_l1 = PMD_TYPE_TABLE,
4092 .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE,
4093 .domain = DOMAIN_KERNEL,
4094 },
4095 + [MT_MEMORY_NONCACHED_RX] = {
4096 + .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_KERNEXEC |
4097 + L_PTE_MT_BUFFERABLE,
4098 + .prot_l1 = PMD_TYPE_TABLE,
4099 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_KERNEXEC,
4100 + .domain = DOMAIN_KERNEL,
4101 + },
4102 [MT_MEMORY_DTCM] = {
4103 - .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4104 - L_PTE_XN,
4105 + .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY,
4106 .prot_l1 = PMD_TYPE_TABLE,
4107 - .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN,
4108 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_RDONLY,
4109 .domain = DOMAIN_KERNEL,
4110 },
4111 [MT_MEMORY_ITCM] = {
4112 @@ -283,10 +326,10 @@ static struct mem_type mem_types[] = {
4113 },
4114 [MT_MEMORY_SO] = {
4115 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4116 - L_PTE_MT_UNCACHED | L_PTE_XN,
4117 + L_PTE_MT_UNCACHED,
4118 .prot_l1 = PMD_TYPE_TABLE,
4119 .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE | PMD_SECT_S |
4120 - PMD_SECT_UNCACHED | PMD_SECT_XN,
4121 + PMD_SECT_UNCACHED,
4122 .domain = DOMAIN_KERNEL,
4123 },
4124 [MT_MEMORY_DMA_READY] = {
4125 @@ -371,9 +414,35 @@ static void __init build_mem_type_table(void)
4126 * to prevent speculative instruction fetches.
4127 */
4128 mem_types[MT_DEVICE].prot_sect |= PMD_SECT_XN;
4129 + mem_types[MT_DEVICE].prot_pte |= L_PTE_XN;
4130 mem_types[MT_DEVICE_NONSHARED].prot_sect |= PMD_SECT_XN;
4131 + mem_types[MT_DEVICE_NONSHARED].prot_pte |= L_PTE_XN;
4132 mem_types[MT_DEVICE_CACHED].prot_sect |= PMD_SECT_XN;
4133 + mem_types[MT_DEVICE_CACHED].prot_pte |= L_PTE_XN;
4134 mem_types[MT_DEVICE_WC].prot_sect |= PMD_SECT_XN;
4135 + mem_types[MT_DEVICE_WC].prot_pte |= L_PTE_XN;
4136 +
4137 + /* Mark other regions on ARMv6+ as execute-never */
4138 +
4139 +#ifdef CONFIG_PAX_KERNEXEC
4140 + mem_types[MT_UNCACHED].prot_sect |= PMD_SECT_XN;
4141 + mem_types[MT_UNCACHED].prot_pte |= L_PTE_XN;
4142 + mem_types[MT_CACHECLEAN].prot_sect |= PMD_SECT_XN;
4143 + mem_types[MT_CACHECLEAN].prot_pte |= L_PTE_XN;
4144 +#ifndef CONFIG_ARM_LPAE
4145 + mem_types[MT_MINICLEAN].prot_sect |= PMD_SECT_XN;
4146 + mem_types[MT_MINICLEAN].prot_pte |= L_PTE_XN;
4147 +#endif
4148 + mem_types[MT_MEMORY_RW].prot_sect |= PMD_SECT_XN;
4149 + mem_types[MT_MEMORY_RW].prot_pte |= L_PTE_XN;
4150 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |= PMD_SECT_XN;
4151 + mem_types[MT_MEMORY_NONCACHED_RW].prot_pte |= PMD_SECT_XN;
4152 + mem_types[MT_MEMORY_DTCM].prot_sect |= PMD_SECT_XN;
4153 + mem_types[MT_MEMORY_DTCM].prot_pte |= L_PTE_XN;
4154 +#endif
4155 +
4156 + mem_types[MT_MEMORY_SO].prot_sect |= PMD_SECT_XN;
4157 + mem_types[MT_MEMORY_SO].prot_pte |= L_PTE_XN;
4158 }
4159 if (cpu_arch >= CPU_ARCH_ARMv7 && (cr & CR_TRE)) {
4160 /*
4161 @@ -432,6 +501,9 @@ static void __init build_mem_type_table(void)
4162 * from SVC mode and no access from userspace.
4163 */
4164 mem_types[MT_ROM].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4165 +#ifdef CONFIG_PAX_KERNEXEC
4166 + mem_types[MT_MEMORY_RX].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4167 +#endif
4168 mem_types[MT_MINICLEAN].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4169 mem_types[MT_CACHECLEAN].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4170 #endif
4171 @@ -448,11 +520,17 @@ static void __init build_mem_type_table(void)
4172 mem_types[MT_DEVICE_WC].prot_pte |= L_PTE_SHARED;
4173 mem_types[MT_DEVICE_CACHED].prot_sect |= PMD_SECT_S;
4174 mem_types[MT_DEVICE_CACHED].prot_pte |= L_PTE_SHARED;
4175 - mem_types[MT_MEMORY].prot_sect |= PMD_SECT_S;
4176 - mem_types[MT_MEMORY].prot_pte |= L_PTE_SHARED;
4177 + mem_types[MT_MEMORY_RWX].prot_sect |= PMD_SECT_S;
4178 + mem_types[MT_MEMORY_RWX].prot_pte |= L_PTE_SHARED;
4179 + mem_types[MT_MEMORY_RW].prot_sect |= PMD_SECT_S;
4180 + mem_types[MT_MEMORY_RW].prot_pte |= L_PTE_SHARED;
4181 + mem_types[MT_MEMORY_RX].prot_sect |= PMD_SECT_S;
4182 + mem_types[MT_MEMORY_RX].prot_pte |= L_PTE_SHARED;
4183 mem_types[MT_MEMORY_DMA_READY].prot_pte |= L_PTE_SHARED;
4184 - mem_types[MT_MEMORY_NONCACHED].prot_sect |= PMD_SECT_S;
4185 - mem_types[MT_MEMORY_NONCACHED].prot_pte |= L_PTE_SHARED;
4186 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |= PMD_SECT_S;
4187 + mem_types[MT_MEMORY_NONCACHED_RW].prot_pte |= L_PTE_SHARED;
4188 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |= PMD_SECT_S;
4189 + mem_types[MT_MEMORY_NONCACHED_RX].prot_pte |= L_PTE_SHARED;
4190 }
4191 }
4192
4193 @@ -463,15 +541,20 @@ static void __init build_mem_type_table(void)
4194 if (cpu_arch >= CPU_ARCH_ARMv6) {
4195 if (cpu_arch >= CPU_ARCH_ARMv7 && (cr & CR_TRE)) {
4196 /* Non-cacheable Normal is XCB = 001 */
4197 - mem_types[MT_MEMORY_NONCACHED].prot_sect |=
4198 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |=
4199 + PMD_SECT_BUFFERED;
4200 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |=
4201 PMD_SECT_BUFFERED;
4202 } else {
4203 /* For both ARMv6 and non-TEX-remapping ARMv7 */
4204 - mem_types[MT_MEMORY_NONCACHED].prot_sect |=
4205 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |=
4206 + PMD_SECT_TEX(1);
4207 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |=
4208 PMD_SECT_TEX(1);
4209 }
4210 } else {
4211 - mem_types[MT_MEMORY_NONCACHED].prot_sect |= PMD_SECT_BUFFERABLE;
4212 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |= PMD_SECT_BUFFERABLE;
4213 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |= PMD_SECT_BUFFERABLE;
4214 }
4215
4216 #ifdef CONFIG_ARM_LPAE
4217 @@ -487,6 +570,8 @@ static void __init build_mem_type_table(void)
4218 vecs_pgprot |= PTE_EXT_AF;
4219 #endif
4220
4221 + user_pgprot |= __supported_pte_mask;
4222 +
4223 for (i = 0; i < 16; i++) {
4224 pteval_t v = pgprot_val(protection_map[i]);
4225 protection_map[i] = __pgprot(v | user_pgprot);
4226 @@ -501,10 +586,15 @@ static void __init build_mem_type_table(void)
4227
4228 mem_types[MT_LOW_VECTORS].prot_l1 |= ecc_mask;
4229 mem_types[MT_HIGH_VECTORS].prot_l1 |= ecc_mask;
4230 - mem_types[MT_MEMORY].prot_sect |= ecc_mask | cp->pmd;
4231 - mem_types[MT_MEMORY].prot_pte |= kern_pgprot;
4232 + mem_types[MT_MEMORY_RWX].prot_sect |= ecc_mask | cp->pmd;
4233 + mem_types[MT_MEMORY_RWX].prot_pte |= kern_pgprot;
4234 + mem_types[MT_MEMORY_RW].prot_sect |= ecc_mask | cp->pmd;
4235 + mem_types[MT_MEMORY_RW].prot_pte |= kern_pgprot;
4236 + mem_types[MT_MEMORY_RX].prot_sect |= ecc_mask | cp->pmd;
4237 + mem_types[MT_MEMORY_RX].prot_pte |= kern_pgprot;
4238 mem_types[MT_MEMORY_DMA_READY].prot_pte |= kern_pgprot;
4239 - mem_types[MT_MEMORY_NONCACHED].prot_sect |= ecc_mask;
4240 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |= ecc_mask;
4241 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |= ecc_mask;
4242 mem_types[MT_ROM].prot_sect |= cp->pmd;
4243
4244 switch (cp->pmd) {
4245 @@ -1105,18 +1195,15 @@ void __init arm_mm_memblock_reserve(void)
4246 * called function. This means you can't use any function or debugging
4247 * method which may touch any device, otherwise the kernel _will_ crash.
4248 */
4249 +
4250 +static char vectors[PAGE_SIZE] __read_only __aligned(PAGE_SIZE);
4251 +
4252 static void __init devicemaps_init(struct machine_desc *mdesc)
4253 {
4254 struct map_desc map;
4255 unsigned long addr;
4256 - void *vectors;
4257
4258 - /*
4259 - * Allocate the vector page early.
4260 - */
4261 - vectors = early_alloc(PAGE_SIZE);
4262 -
4263 - early_trap_init(vectors);
4264 + early_trap_init(&vectors);
4265
4266 for (addr = VMALLOC_START; addr; addr += PMD_SIZE)
4267 pmd_clear(pmd_off_k(addr));
4268 @@ -1156,7 +1243,7 @@ static void __init devicemaps_init(struct machine_desc *mdesc)
4269 * location (0xffff0000). If we aren't using high-vectors, also
4270 * create a mapping at the low-vectors virtual address.
4271 */
4272 - map.pfn = __phys_to_pfn(virt_to_phys(vectors));
4273 + map.pfn = __phys_to_pfn(virt_to_phys(&vectors));
4274 map.virtual = 0xffff0000;
4275 map.length = PAGE_SIZE;
4276 map.type = MT_HIGH_VECTORS;
4277 @@ -1214,8 +1301,39 @@ static void __init map_lowmem(void)
4278 map.pfn = __phys_to_pfn(start);
4279 map.virtual = __phys_to_virt(start);
4280 map.length = end - start;
4281 - map.type = MT_MEMORY;
4282
4283 +#ifdef CONFIG_PAX_KERNEXEC
4284 + if (map.virtual <= (unsigned long)_stext && ((unsigned long)_end < (map.virtual + map.length))) {
4285 + struct map_desc kernel;
4286 + struct map_desc initmap;
4287 +
4288 + /* when freeing initmem we will make this RW */
4289 + initmap.pfn = __phys_to_pfn(__pa(__init_begin));
4290 + initmap.virtual = (unsigned long)__init_begin;
4291 + initmap.length = _sdata - __init_begin;
4292 + initmap.type = MT_MEMORY_RWX;
4293 + create_mapping(&initmap);
4294 +
4295 + /* when freeing initmem we will make this RX */
4296 + kernel.pfn = __phys_to_pfn(__pa(_stext));
4297 + kernel.virtual = (unsigned long)_stext;
4298 + kernel.length = __init_begin - _stext;
4299 + kernel.type = MT_MEMORY_RWX;
4300 + create_mapping(&kernel);
4301 +
4302 + if (map.virtual < (unsigned long)_stext) {
4303 + map.length = (unsigned long)_stext - map.virtual;
4304 + map.type = MT_MEMORY_RWX;
4305 + create_mapping(&map);
4306 + }
4307 +
4308 + map.pfn = __phys_to_pfn(__pa(_sdata));
4309 + map.virtual = (unsigned long)_sdata;
4310 + map.length = end - __pa(_sdata);
4311 + }
4312 +#endif
4313 +
4314 + map.type = MT_MEMORY_RW;
4315 create_mapping(&map);
4316 }
4317 }
4318 diff --git a/arch/arm/mm/proc-v7-2level.S b/arch/arm/mm/proc-v7-2level.S
4319 index 6d98c13..3cfb174 100644
4320 --- a/arch/arm/mm/proc-v7-2level.S
4321 +++ b/arch/arm/mm/proc-v7-2level.S
4322 @@ -99,6 +99,9 @@ ENTRY(cpu_v7_set_pte_ext)
4323 tst r1, #L_PTE_XN
4324 orrne r3, r3, #PTE_EXT_XN
4325
4326 + tst r1, #L_PTE_PXN
4327 + orrne r3, r3, #PTE_EXT_PXN
4328 +
4329 tst r1, #L_PTE_YOUNG
4330 tstne r1, #L_PTE_VALID
4331 #ifndef CONFIG_CPU_USE_DOMAINS
4332 diff --git a/arch/arm/plat-omap/sram.c b/arch/arm/plat-omap/sram.c
4333 index a5bc92d..0bb4730 100644
4334 --- a/arch/arm/plat-omap/sram.c
4335 +++ b/arch/arm/plat-omap/sram.c
4336 @@ -93,6 +93,8 @@ void __init omap_map_sram(unsigned long start, unsigned long size,
4337 * Looks like we need to preserve some bootloader code at the
4338 * beginning of SRAM for jumping to flash for reboot to work...
4339 */
4340 + pax_open_kernel();
4341 memset_io(omap_sram_base + omap_sram_skip, 0,
4342 omap_sram_size - omap_sram_skip);
4343 + pax_close_kernel();
4344 }
4345 diff --git a/arch/arm/plat-samsung/include/plat/dma-ops.h b/arch/arm/plat-samsung/include/plat/dma-ops.h
4346 index f5144cd..71f6d1f 100644
4347 --- a/arch/arm/plat-samsung/include/plat/dma-ops.h
4348 +++ b/arch/arm/plat-samsung/include/plat/dma-ops.h
4349 @@ -47,7 +47,7 @@ struct samsung_dma_ops {
4350 int (*started)(unsigned ch);
4351 int (*flush)(unsigned ch);
4352 int (*stop)(unsigned ch);
4353 -};
4354 +} __no_const;
4355
4356 extern void *samsung_dmadev_get_ops(void);
4357 extern void *s3c_dma_get_ops(void);
4358 diff --git a/arch/arm64/kernel/debug-monitors.c b/arch/arm64/kernel/debug-monitors.c
4359 index 0c3ba9f..95722b3 100644
4360 --- a/arch/arm64/kernel/debug-monitors.c
4361 +++ b/arch/arm64/kernel/debug-monitors.c
4362 @@ -151,7 +151,7 @@ static int __cpuinit os_lock_notify(struct notifier_block *self,
4363 return NOTIFY_OK;
4364 }
4365
4366 -static struct notifier_block __cpuinitdata os_lock_nb = {
4367 +static struct notifier_block os_lock_nb = {
4368 .notifier_call = os_lock_notify,
4369 };
4370
4371 diff --git a/arch/arm64/kernel/hw_breakpoint.c b/arch/arm64/kernel/hw_breakpoint.c
4372 index 5ab825c..96aaec8 100644
4373 --- a/arch/arm64/kernel/hw_breakpoint.c
4374 +++ b/arch/arm64/kernel/hw_breakpoint.c
4375 @@ -831,7 +831,7 @@ static int __cpuinit hw_breakpoint_reset_notify(struct notifier_block *self,
4376 return NOTIFY_OK;
4377 }
4378
4379 -static struct notifier_block __cpuinitdata hw_breakpoint_reset_nb = {
4380 +static struct notifier_block hw_breakpoint_reset_nb = {
4381 .notifier_call = hw_breakpoint_reset_notify,
4382 };
4383
4384 diff --git a/arch/avr32/include/asm/cache.h b/arch/avr32/include/asm/cache.h
4385 index c3a58a1..78fbf54 100644
4386 --- a/arch/avr32/include/asm/cache.h
4387 +++ b/arch/avr32/include/asm/cache.h
4388 @@ -1,8 +1,10 @@
4389 #ifndef __ASM_AVR32_CACHE_H
4390 #define __ASM_AVR32_CACHE_H
4391
4392 +#include <linux/const.h>
4393 +
4394 #define L1_CACHE_SHIFT 5
4395 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4396 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4397
4398 /*
4399 * Memory returned by kmalloc() may be used for DMA, so we must make
4400 diff --git a/arch/avr32/include/asm/elf.h b/arch/avr32/include/asm/elf.h
4401 index e2c3287..6c4f98c 100644
4402 --- a/arch/avr32/include/asm/elf.h
4403 +++ b/arch/avr32/include/asm/elf.h
4404 @@ -84,8 +84,14 @@ typedef struct user_fpu_struct elf_fpregset_t;
4405 the loader. We need to make sure that it is out of the way of the program
4406 that it will "exec", and that there is sufficient room for the brk. */
4407
4408 -#define ELF_ET_DYN_BASE (2 * TASK_SIZE / 3)
4409 +#define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
4410
4411 +#ifdef CONFIG_PAX_ASLR
4412 +#define PAX_ELF_ET_DYN_BASE 0x00001000UL
4413 +
4414 +#define PAX_DELTA_MMAP_LEN 15
4415 +#define PAX_DELTA_STACK_LEN 15
4416 +#endif
4417
4418 /* This yields a mask that user programs can use to figure out what
4419 instruction set this CPU supports. This could be done in user space,
4420 diff --git a/arch/avr32/include/asm/kmap_types.h b/arch/avr32/include/asm/kmap_types.h
4421 index 479330b..53717a8 100644
4422 --- a/arch/avr32/include/asm/kmap_types.h
4423 +++ b/arch/avr32/include/asm/kmap_types.h
4424 @@ -2,9 +2,9 @@
4425 #define __ASM_AVR32_KMAP_TYPES_H
4426
4427 #ifdef CONFIG_DEBUG_HIGHMEM
4428 -# define KM_TYPE_NR 29
4429 +# define KM_TYPE_NR 30
4430 #else
4431 -# define KM_TYPE_NR 14
4432 +# define KM_TYPE_NR 15
4433 #endif
4434
4435 #endif /* __ASM_AVR32_KMAP_TYPES_H */
4436 diff --git a/arch/avr32/mm/fault.c b/arch/avr32/mm/fault.c
4437 index b2f2d2d..d1c85cb 100644
4438 --- a/arch/avr32/mm/fault.c
4439 +++ b/arch/avr32/mm/fault.c
4440 @@ -41,6 +41,23 @@ static inline int notify_page_fault(struct pt_regs *regs, int trap)
4441
4442 int exception_trace = 1;
4443
4444 +#ifdef CONFIG_PAX_PAGEEXEC
4445 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
4446 +{
4447 + unsigned long i;
4448 +
4449 + printk(KERN_ERR "PAX: bytes at PC: ");
4450 + for (i = 0; i < 20; i++) {
4451 + unsigned char c;
4452 + if (get_user(c, (unsigned char *)pc+i))
4453 + printk(KERN_CONT "???????? ");
4454 + else
4455 + printk(KERN_CONT "%02x ", c);
4456 + }
4457 + printk("\n");
4458 +}
4459 +#endif
4460 +
4461 /*
4462 * This routine handles page faults. It determines the address and the
4463 * problem, and then passes it off to one of the appropriate routines.
4464 @@ -174,6 +191,16 @@ bad_area:
4465 up_read(&mm->mmap_sem);
4466
4467 if (user_mode(regs)) {
4468 +
4469 +#ifdef CONFIG_PAX_PAGEEXEC
4470 + if (mm->pax_flags & MF_PAX_PAGEEXEC) {
4471 + if (ecr == ECR_PROTECTION_X || ecr == ECR_TLB_MISS_X) {
4472 + pax_report_fault(regs, (void *)regs->pc, (void *)regs->sp);
4473 + do_group_exit(SIGKILL);
4474 + }
4475 + }
4476 +#endif
4477 +
4478 if (exception_trace && printk_ratelimit())
4479 printk("%s%s[%d]: segfault at %08lx pc %08lx "
4480 "sp %08lx ecr %lu\n",
4481 diff --git a/arch/blackfin/include/asm/cache.h b/arch/blackfin/include/asm/cache.h
4482 index 568885a..f8008df 100644
4483 --- a/arch/blackfin/include/asm/cache.h
4484 +++ b/arch/blackfin/include/asm/cache.h
4485 @@ -7,6 +7,7 @@
4486 #ifndef __ARCH_BLACKFIN_CACHE_H
4487 #define __ARCH_BLACKFIN_CACHE_H
4488
4489 +#include <linux/const.h>
4490 #include <linux/linkage.h> /* for asmlinkage */
4491
4492 /*
4493 @@ -14,7 +15,7 @@
4494 * Blackfin loads 32 bytes for cache
4495 */
4496 #define L1_CACHE_SHIFT 5
4497 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4498 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4499 #define SMP_CACHE_BYTES L1_CACHE_BYTES
4500
4501 #define ARCH_DMA_MINALIGN L1_CACHE_BYTES
4502 diff --git a/arch/cris/include/arch-v10/arch/cache.h b/arch/cris/include/arch-v10/arch/cache.h
4503 index aea2718..3639a60 100644
4504 --- a/arch/cris/include/arch-v10/arch/cache.h
4505 +++ b/arch/cris/include/arch-v10/arch/cache.h
4506 @@ -1,8 +1,9 @@
4507 #ifndef _ASM_ARCH_CACHE_H
4508 #define _ASM_ARCH_CACHE_H
4509
4510 +#include <linux/const.h>
4511 /* Etrax 100LX have 32-byte cache-lines. */
4512 -#define L1_CACHE_BYTES 32
4513 #define L1_CACHE_SHIFT 5
4514 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4515
4516 #endif /* _ASM_ARCH_CACHE_H */
4517 diff --git a/arch/cris/include/arch-v32/arch/cache.h b/arch/cris/include/arch-v32/arch/cache.h
4518 index 7caf25d..ee65ac5 100644
4519 --- a/arch/cris/include/arch-v32/arch/cache.h
4520 +++ b/arch/cris/include/arch-v32/arch/cache.h
4521 @@ -1,11 +1,12 @@
4522 #ifndef _ASM_CRIS_ARCH_CACHE_H
4523 #define _ASM_CRIS_ARCH_CACHE_H
4524
4525 +#include <linux/const.h>
4526 #include <arch/hwregs/dma.h>
4527
4528 /* A cache-line is 32 bytes. */
4529 -#define L1_CACHE_BYTES 32
4530 #define L1_CACHE_SHIFT 5
4531 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4532
4533 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
4534
4535 diff --git a/arch/frv/include/asm/atomic.h b/arch/frv/include/asm/atomic.h
4536 index b86329d..6709906 100644
4537 --- a/arch/frv/include/asm/atomic.h
4538 +++ b/arch/frv/include/asm/atomic.h
4539 @@ -186,6 +186,16 @@ static inline void atomic64_dec(atomic64_t *v)
4540 #define atomic64_cmpxchg(v, old, new) (__cmpxchg_64(old, new, &(v)->counter))
4541 #define atomic64_xchg(v, new) (__xchg_64(new, &(v)->counter))
4542
4543 +#define atomic64_read_unchecked(v) atomic64_read(v)
4544 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
4545 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
4546 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
4547 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
4548 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
4549 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
4550 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
4551 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
4552 +
4553 static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
4554 {
4555 int c, old;
4556 diff --git a/arch/frv/include/asm/cache.h b/arch/frv/include/asm/cache.h
4557 index 2797163..c2a401d 100644
4558 --- a/arch/frv/include/asm/cache.h
4559 +++ b/arch/frv/include/asm/cache.h
4560 @@ -12,10 +12,11 @@
4561 #ifndef __ASM_CACHE_H
4562 #define __ASM_CACHE_H
4563
4564 +#include <linux/const.h>
4565
4566 /* bytes per L1 cache line */
4567 #define L1_CACHE_SHIFT (CONFIG_FRV_L1_CACHE_SHIFT)
4568 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4569 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4570
4571 #define __cacheline_aligned __attribute__((aligned(L1_CACHE_BYTES)))
4572 #define ____cacheline_aligned __attribute__((aligned(L1_CACHE_BYTES)))
4573 diff --git a/arch/frv/include/asm/kmap_types.h b/arch/frv/include/asm/kmap_types.h
4574 index 43901f2..0d8b865 100644
4575 --- a/arch/frv/include/asm/kmap_types.h
4576 +++ b/arch/frv/include/asm/kmap_types.h
4577 @@ -2,6 +2,6 @@
4578 #ifndef _ASM_KMAP_TYPES_H
4579 #define _ASM_KMAP_TYPES_H
4580
4581 -#define KM_TYPE_NR 17
4582 +#define KM_TYPE_NR 18
4583
4584 #endif
4585 diff --git a/arch/frv/mm/elf-fdpic.c b/arch/frv/mm/elf-fdpic.c
4586 index 385fd30..3aaf4fe 100644
4587 --- a/arch/frv/mm/elf-fdpic.c
4588 +++ b/arch/frv/mm/elf-fdpic.c
4589 @@ -61,6 +61,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
4590 {
4591 struct vm_area_struct *vma;
4592 unsigned long limit;
4593 + unsigned long offset = gr_rand_threadstack_offset(current->mm, filp, flags);
4594
4595 if (len > TASK_SIZE)
4596 return -ENOMEM;
4597 @@ -73,8 +74,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
4598 if (addr) {
4599 addr = PAGE_ALIGN(addr);
4600 vma = find_vma(current->mm, addr);
4601 - if (TASK_SIZE - len >= addr &&
4602 - (!vma || addr + len <= vma->vm_start))
4603 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
4604 goto success;
4605 }
4606
4607 @@ -89,7 +89,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
4608 for (; vma; vma = vma->vm_next) {
4609 if (addr > limit)
4610 break;
4611 - if (addr + len <= vma->vm_start)
4612 + if (check_heap_stack_gap(vma, addr, len, offset))
4613 goto success;
4614 addr = vma->vm_end;
4615 }
4616 @@ -104,7 +104,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
4617 for (; vma; vma = vma->vm_next) {
4618 if (addr > limit)
4619 break;
4620 - if (addr + len <= vma->vm_start)
4621 + if (check_heap_stack_gap(vma, addr, len, offset))
4622 goto success;
4623 addr = vma->vm_end;
4624 }
4625 diff --git a/arch/hexagon/include/asm/cache.h b/arch/hexagon/include/asm/cache.h
4626 index f4ca594..adc72fd6 100644
4627 --- a/arch/hexagon/include/asm/cache.h
4628 +++ b/arch/hexagon/include/asm/cache.h
4629 @@ -21,9 +21,11 @@
4630 #ifndef __ASM_CACHE_H
4631 #define __ASM_CACHE_H
4632
4633 +#include <linux/const.h>
4634 +
4635 /* Bytes per L1 cache line */
4636 -#define L1_CACHE_SHIFT (5)
4637 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4638 +#define L1_CACHE_SHIFT 5
4639 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4640
4641 #define __cacheline_aligned __aligned(L1_CACHE_BYTES)
4642 #define ____cacheline_aligned __aligned(L1_CACHE_BYTES)
4643 diff --git a/arch/ia64/include/asm/atomic.h b/arch/ia64/include/asm/atomic.h
4644 index 6e6fe18..a6ae668 100644
4645 --- a/arch/ia64/include/asm/atomic.h
4646 +++ b/arch/ia64/include/asm/atomic.h
4647 @@ -208,6 +208,16 @@ atomic64_add_negative (__s64 i, atomic64_t *v)
4648 #define atomic64_inc(v) atomic64_add(1, (v))
4649 #define atomic64_dec(v) atomic64_sub(1, (v))
4650
4651 +#define atomic64_read_unchecked(v) atomic64_read(v)
4652 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
4653 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
4654 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
4655 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
4656 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
4657 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
4658 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
4659 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
4660 +
4661 /* Atomic operations are already serializing */
4662 #define smp_mb__before_atomic_dec() barrier()
4663 #define smp_mb__after_atomic_dec() barrier()
4664 diff --git a/arch/ia64/include/asm/cache.h b/arch/ia64/include/asm/cache.h
4665 index 988254a..e1ee885 100644
4666 --- a/arch/ia64/include/asm/cache.h
4667 +++ b/arch/ia64/include/asm/cache.h
4668 @@ -1,6 +1,7 @@
4669 #ifndef _ASM_IA64_CACHE_H
4670 #define _ASM_IA64_CACHE_H
4671
4672 +#include <linux/const.h>
4673
4674 /*
4675 * Copyright (C) 1998-2000 Hewlett-Packard Co
4676 @@ -9,7 +10,7 @@
4677
4678 /* Bytes per L1 (data) cache line. */
4679 #define L1_CACHE_SHIFT CONFIG_IA64_L1_CACHE_SHIFT
4680 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4681 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4682
4683 #ifdef CONFIG_SMP
4684 # define SMP_CACHE_SHIFT L1_CACHE_SHIFT
4685 diff --git a/arch/ia64/include/asm/elf.h b/arch/ia64/include/asm/elf.h
4686 index b5298eb..67c6e62 100644
4687 --- a/arch/ia64/include/asm/elf.h
4688 +++ b/arch/ia64/include/asm/elf.h
4689 @@ -42,6 +42,13 @@
4690 */
4691 #define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE + 0x800000000UL)
4692
4693 +#ifdef CONFIG_PAX_ASLR
4694 +#define PAX_ELF_ET_DYN_BASE (current->personality == PER_LINUX32 ? 0x08048000UL : 0x4000000000000000UL)
4695 +
4696 +#define PAX_DELTA_MMAP_LEN (current->personality == PER_LINUX32 ? 16 : 3*PAGE_SHIFT - 13)
4697 +#define PAX_DELTA_STACK_LEN (current->personality == PER_LINUX32 ? 16 : 3*PAGE_SHIFT - 13)
4698 +#endif
4699 +
4700 #define PT_IA_64_UNWIND 0x70000001
4701
4702 /* IA-64 relocations: */
4703 diff --git a/arch/ia64/include/asm/pgalloc.h b/arch/ia64/include/asm/pgalloc.h
4704 index 96a8d92..617a1cf 100644
4705 --- a/arch/ia64/include/asm/pgalloc.h
4706 +++ b/arch/ia64/include/asm/pgalloc.h
4707 @@ -39,6 +39,12 @@ pgd_populate(struct mm_struct *mm, pgd_t * pgd_entry, pud_t * pud)
4708 pgd_val(*pgd_entry) = __pa(pud);
4709 }
4710
4711 +static inline void
4712 +pgd_populate_kernel(struct mm_struct *mm, pgd_t * pgd_entry, pud_t * pud)
4713 +{
4714 + pgd_populate(mm, pgd_entry, pud);
4715 +}
4716 +
4717 static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr)
4718 {
4719 return quicklist_alloc(0, GFP_KERNEL, NULL);
4720 @@ -57,6 +63,12 @@ pud_populate(struct mm_struct *mm, pud_t * pud_entry, pmd_t * pmd)
4721 pud_val(*pud_entry) = __pa(pmd);
4722 }
4723
4724 +static inline void
4725 +pud_populate_kernel(struct mm_struct *mm, pud_t * pud_entry, pmd_t * pmd)
4726 +{
4727 + pud_populate(mm, pud_entry, pmd);
4728 +}
4729 +
4730 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long addr)
4731 {
4732 return quicklist_alloc(0, GFP_KERNEL, NULL);
4733 diff --git a/arch/ia64/include/asm/pgtable.h b/arch/ia64/include/asm/pgtable.h
4734 index 815810c..d60bd4c 100644
4735 --- a/arch/ia64/include/asm/pgtable.h
4736 +++ b/arch/ia64/include/asm/pgtable.h
4737 @@ -12,7 +12,7 @@
4738 * David Mosberger-Tang <davidm@hpl.hp.com>
4739 */
4740
4741 -
4742 +#include <linux/const.h>
4743 #include <asm/mman.h>
4744 #include <asm/page.h>
4745 #include <asm/processor.h>
4746 @@ -142,6 +142,17 @@
4747 #define PAGE_READONLY __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
4748 #define PAGE_COPY __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
4749 #define PAGE_COPY_EXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_RX)
4750 +
4751 +#ifdef CONFIG_PAX_PAGEEXEC
4752 +# define PAGE_SHARED_NOEXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_RW)
4753 +# define PAGE_READONLY_NOEXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
4754 +# define PAGE_COPY_NOEXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
4755 +#else
4756 +# define PAGE_SHARED_NOEXEC PAGE_SHARED
4757 +# define PAGE_READONLY_NOEXEC PAGE_READONLY
4758 +# define PAGE_COPY_NOEXEC PAGE_COPY
4759 +#endif
4760 +
4761 #define PAGE_GATE __pgprot(__ACCESS_BITS | _PAGE_PL_0 | _PAGE_AR_X_RX)
4762 #define PAGE_KERNEL __pgprot(__DIRTY_BITS | _PAGE_PL_0 | _PAGE_AR_RWX)
4763 #define PAGE_KERNELRX __pgprot(__ACCESS_BITS | _PAGE_PL_0 | _PAGE_AR_RX)
4764 diff --git a/arch/ia64/include/asm/spinlock.h b/arch/ia64/include/asm/spinlock.h
4765 index 54ff557..70c88b7 100644
4766 --- a/arch/ia64/include/asm/spinlock.h
4767 +++ b/arch/ia64/include/asm/spinlock.h
4768 @@ -71,7 +71,7 @@ static __always_inline void __ticket_spin_unlock(arch_spinlock_t *lock)
4769 unsigned short *p = (unsigned short *)&lock->lock + 1, tmp;
4770
4771 asm volatile ("ld2.bias %0=[%1]" : "=r"(tmp) : "r"(p));
4772 - ACCESS_ONCE(*p) = (tmp + 2) & ~1;
4773 + ACCESS_ONCE_RW(*p) = (tmp + 2) & ~1;
4774 }
4775
4776 static __always_inline void __ticket_spin_unlock_wait(arch_spinlock_t *lock)
4777 diff --git a/arch/ia64/include/asm/uaccess.h b/arch/ia64/include/asm/uaccess.h
4778 index 449c8c0..50cdf87 100644
4779 --- a/arch/ia64/include/asm/uaccess.h
4780 +++ b/arch/ia64/include/asm/uaccess.h
4781 @@ -42,6 +42,8 @@
4782 #include <asm/pgtable.h>
4783 #include <asm/io.h>
4784
4785 +extern void check_object_size(const void *ptr, unsigned long n, bool to);
4786 +
4787 /*
4788 * For historical reasons, the following macros are grossly misnamed:
4789 */
4790 @@ -240,12 +242,24 @@ extern unsigned long __must_check __copy_user (void __user *to, const void __use
4791 static inline unsigned long
4792 __copy_to_user (void __user *to, const void *from, unsigned long count)
4793 {
4794 + if (count > INT_MAX)
4795 + return count;
4796 +
4797 + if (!__builtin_constant_p(count))
4798 + check_object_size(from, count, true);
4799 +
4800 return __copy_user(to, (__force void __user *) from, count);
4801 }
4802
4803 static inline unsigned long
4804 __copy_from_user (void *to, const void __user *from, unsigned long count)
4805 {
4806 + if (count > INT_MAX)
4807 + return count;
4808 +
4809 + if (!__builtin_constant_p(count))
4810 + check_object_size(to, count, false);
4811 +
4812 return __copy_user((__force void __user *) to, from, count);
4813 }
4814
4815 @@ -255,10 +269,13 @@ __copy_from_user (void *to, const void __user *from, unsigned long count)
4816 ({ \
4817 void __user *__cu_to = (to); \
4818 const void *__cu_from = (from); \
4819 - long __cu_len = (n); \
4820 + unsigned long __cu_len = (n); \
4821 \
4822 - if (__access_ok(__cu_to, __cu_len, get_fs())) \
4823 + if (__cu_len <= INT_MAX && __access_ok(__cu_to, __cu_len, get_fs())) { \
4824 + if (!__builtin_constant_p(n)) \
4825 + check_object_size(__cu_from, __cu_len, true); \
4826 __cu_len = __copy_user(__cu_to, (__force void __user *) __cu_from, __cu_len); \
4827 + } \
4828 __cu_len; \
4829 })
4830
4831 @@ -266,11 +283,14 @@ __copy_from_user (void *to, const void __user *from, unsigned long count)
4832 ({ \
4833 void *__cu_to = (to); \
4834 const void __user *__cu_from = (from); \
4835 - long __cu_len = (n); \
4836 + unsigned long __cu_len = (n); \
4837 \
4838 __chk_user_ptr(__cu_from); \
4839 - if (__access_ok(__cu_from, __cu_len, get_fs())) \
4840 + if (__cu_len <= INT_MAX && __access_ok(__cu_from, __cu_len, get_fs())) { \
4841 + if (!__builtin_constant_p(n)) \
4842 + check_object_size(__cu_to, __cu_len, false); \
4843 __cu_len = __copy_user((__force void __user *) __cu_to, __cu_from, __cu_len); \
4844 + } \
4845 __cu_len; \
4846 })
4847
4848 diff --git a/arch/ia64/kernel/err_inject.c b/arch/ia64/kernel/err_inject.c
4849 index 2d67317..07d8bfa 100644
4850 --- a/arch/ia64/kernel/err_inject.c
4851 +++ b/arch/ia64/kernel/err_inject.c
4852 @@ -256,7 +256,7 @@ static int __cpuinit err_inject_cpu_callback(struct notifier_block *nfb,
4853 return NOTIFY_OK;
4854 }
4855
4856 -static struct notifier_block __cpuinitdata err_inject_cpu_notifier =
4857 +static struct notifier_block err_inject_cpu_notifier =
4858 {
4859 .notifier_call = err_inject_cpu_callback,
4860 };
4861 diff --git a/arch/ia64/kernel/mca.c b/arch/ia64/kernel/mca.c
4862 index 65bf9cd..794f06b 100644
4863 --- a/arch/ia64/kernel/mca.c
4864 +++ b/arch/ia64/kernel/mca.c
4865 @@ -1922,7 +1922,7 @@ static int __cpuinit mca_cpu_callback(struct notifier_block *nfb,
4866 return NOTIFY_OK;
4867 }
4868
4869 -static struct notifier_block mca_cpu_notifier __cpuinitdata = {
4870 +static struct notifier_block mca_cpu_notifier = {
4871 .notifier_call = mca_cpu_callback
4872 };
4873
4874 diff --git a/arch/ia64/kernel/module.c b/arch/ia64/kernel/module.c
4875 index 24603be..948052d 100644
4876 --- a/arch/ia64/kernel/module.c
4877 +++ b/arch/ia64/kernel/module.c
4878 @@ -307,8 +307,7 @@ plt_target (struct plt_entry *plt)
4879 void
4880 module_free (struct module *mod, void *module_region)
4881 {
4882 - if (mod && mod->arch.init_unw_table &&
4883 - module_region == mod->module_init) {
4884 + if (mod && mod->arch.init_unw_table && module_region == mod->module_init_rx) {
4885 unw_remove_unwind_table(mod->arch.init_unw_table);
4886 mod->arch.init_unw_table = NULL;
4887 }
4888 @@ -494,15 +493,39 @@ module_frob_arch_sections (Elf_Ehdr *ehdr, Elf_Shdr *sechdrs, char *secstrings,
4889 }
4890
4891 static inline int
4892 +in_init_rx (const struct module *mod, uint64_t addr)
4893 +{
4894 + return addr - (uint64_t) mod->module_init_rx < mod->init_size_rx;
4895 +}
4896 +
4897 +static inline int
4898 +in_init_rw (const struct module *mod, uint64_t addr)
4899 +{
4900 + return addr - (uint64_t) mod->module_init_rw < mod->init_size_rw;
4901 +}
4902 +
4903 +static inline int
4904 in_init (const struct module *mod, uint64_t addr)
4905 {
4906 - return addr - (uint64_t) mod->module_init < mod->init_size;
4907 + return in_init_rx(mod, addr) || in_init_rw(mod, addr);
4908 +}
4909 +
4910 +static inline int
4911 +in_core_rx (const struct module *mod, uint64_t addr)
4912 +{
4913 + return addr - (uint64_t) mod->module_core_rx < mod->core_size_rx;
4914 +}
4915 +
4916 +static inline int
4917 +in_core_rw (const struct module *mod, uint64_t addr)
4918 +{
4919 + return addr - (uint64_t) mod->module_core_rw < mod->core_size_rw;
4920 }
4921
4922 static inline int
4923 in_core (const struct module *mod, uint64_t addr)
4924 {
4925 - return addr - (uint64_t) mod->module_core < mod->core_size;
4926 + return in_core_rx(mod, addr) || in_core_rw(mod, addr);
4927 }
4928
4929 static inline int
4930 @@ -685,7 +708,14 @@ do_reloc (struct module *mod, uint8_t r_type, Elf64_Sym *sym, uint64_t addend,
4931 break;
4932
4933 case RV_BDREL:
4934 - val -= (uint64_t) (in_init(mod, val) ? mod->module_init : mod->module_core);
4935 + if (in_init_rx(mod, val))
4936 + val -= (uint64_t) mod->module_init_rx;
4937 + else if (in_init_rw(mod, val))
4938 + val -= (uint64_t) mod->module_init_rw;
4939 + else if (in_core_rx(mod, val))
4940 + val -= (uint64_t) mod->module_core_rx;
4941 + else if (in_core_rw(mod, val))
4942 + val -= (uint64_t) mod->module_core_rw;
4943 break;
4944
4945 case RV_LTV:
4946 @@ -820,15 +850,15 @@ apply_relocate_add (Elf64_Shdr *sechdrs, const char *strtab, unsigned int symind
4947 * addresses have been selected...
4948 */
4949 uint64_t gp;
4950 - if (mod->core_size > MAX_LTOFF)
4951 + if (mod->core_size_rx + mod->core_size_rw > MAX_LTOFF)
4952 /*
4953 * This takes advantage of fact that SHF_ARCH_SMALL gets allocated
4954 * at the end of the module.
4955 */
4956 - gp = mod->core_size - MAX_LTOFF / 2;
4957 + gp = mod->core_size_rx + mod->core_size_rw - MAX_LTOFF / 2;
4958 else
4959 - gp = mod->core_size / 2;
4960 - gp = (uint64_t) mod->module_core + ((gp + 7) & -8);
4961 + gp = (mod->core_size_rx + mod->core_size_rw) / 2;
4962 + gp = (uint64_t) mod->module_core_rx + ((gp + 7) & -8);
4963 mod->arch.gp = gp;
4964 DEBUGP("%s: placing gp at 0x%lx\n", __func__, gp);
4965 }
4966 diff --git a/arch/ia64/kernel/palinfo.c b/arch/ia64/kernel/palinfo.c
4967 index 77597e5..6f28f3f 100644
4968 --- a/arch/ia64/kernel/palinfo.c
4969 +++ b/arch/ia64/kernel/palinfo.c
4970 @@ -1045,7 +1045,7 @@ static int __cpuinit palinfo_cpu_callback(struct notifier_block *nfb,
4971 return NOTIFY_OK;
4972 }
4973
4974 -static struct notifier_block __refdata palinfo_cpu_notifier =
4975 +static struct notifier_block palinfo_cpu_notifier =
4976 {
4977 .notifier_call = palinfo_cpu_callback,
4978 .priority = 0,
4979 diff --git a/arch/ia64/kernel/salinfo.c b/arch/ia64/kernel/salinfo.c
4980 index 79802e5..1a89ec5 100644
4981 --- a/arch/ia64/kernel/salinfo.c
4982 +++ b/arch/ia64/kernel/salinfo.c
4983 @@ -616,7 +616,7 @@ salinfo_cpu_callback(struct notifier_block *nb, unsigned long action, void *hcpu
4984 return NOTIFY_OK;
4985 }
4986
4987 -static struct notifier_block salinfo_cpu_notifier __cpuinitdata =
4988 +static struct notifier_block salinfo_cpu_notifier =
4989 {
4990 .notifier_call = salinfo_cpu_callback,
4991 .priority = 0,
4992 diff --git a/arch/ia64/kernel/sys_ia64.c b/arch/ia64/kernel/sys_ia64.c
4993 index d9439ef..d0cac6b 100644
4994 --- a/arch/ia64/kernel/sys_ia64.c
4995 +++ b/arch/ia64/kernel/sys_ia64.c
4996 @@ -28,6 +28,7 @@ arch_get_unmapped_area (struct file *filp, unsigned long addr, unsigned long len
4997 unsigned long start_addr, align_mask = PAGE_SIZE - 1;
4998 struct mm_struct *mm = current->mm;
4999 struct vm_area_struct *vma;
5000 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
5001
5002 if (len > RGN_MAP_LIMIT)
5003 return -ENOMEM;
5004 @@ -43,6 +44,13 @@ arch_get_unmapped_area (struct file *filp, unsigned long addr, unsigned long len
5005 if (REGION_NUMBER(addr) == RGN_HPAGE)
5006 addr = 0;
5007 #endif
5008 +
5009 +#ifdef CONFIG_PAX_RANDMMAP
5010 + if (mm->pax_flags & MF_PAX_RANDMMAP)
5011 + addr = mm->free_area_cache;
5012 + else
5013 +#endif
5014 +
5015 if (!addr)
5016 addr = mm->free_area_cache;
5017
5018 @@ -61,14 +69,14 @@ arch_get_unmapped_area (struct file *filp, unsigned long addr, unsigned long len
5019 for (vma = find_vma(mm, addr); ; vma = vma->vm_next) {
5020 /* At this point: (!vma || addr < vma->vm_end). */
5021 if (TASK_SIZE - len < addr || RGN_MAP_LIMIT - len < REGION_OFFSET(addr)) {
5022 - if (start_addr != TASK_UNMAPPED_BASE) {
5023 + if (start_addr != mm->mmap_base) {
5024 /* Start a new search --- just in case we missed some holes. */
5025 - addr = TASK_UNMAPPED_BASE;
5026 + addr = mm->mmap_base;
5027 goto full_search;
5028 }
5029 return -ENOMEM;
5030 }
5031 - if (!vma || addr + len <= vma->vm_start) {
5032 + if (check_heap_stack_gap(vma, addr, len, offset)) {
5033 /* Remember the address where we stopped this search: */
5034 mm->free_area_cache = addr + len;
5035 return addr;
5036 diff --git a/arch/ia64/kernel/topology.c b/arch/ia64/kernel/topology.c
5037 index dc00b2c..cce53c2 100644
5038 --- a/arch/ia64/kernel/topology.c
5039 +++ b/arch/ia64/kernel/topology.c
5040 @@ -445,7 +445,7 @@ static int __cpuinit cache_cpu_callback(struct notifier_block *nfb,
5041 return NOTIFY_OK;
5042 }
5043
5044 -static struct notifier_block __cpuinitdata cache_cpu_notifier =
5045 +static struct notifier_block cache_cpu_notifier =
5046 {
5047 .notifier_call = cache_cpu_callback
5048 };
5049 diff --git a/arch/ia64/kernel/vmlinux.lds.S b/arch/ia64/kernel/vmlinux.lds.S
5050 index 0ccb28f..8992469 100644
5051 --- a/arch/ia64/kernel/vmlinux.lds.S
5052 +++ b/arch/ia64/kernel/vmlinux.lds.S
5053 @@ -198,7 +198,7 @@ SECTIONS {
5054 /* Per-cpu data: */
5055 . = ALIGN(PERCPU_PAGE_SIZE);
5056 PERCPU_VADDR(SMP_CACHE_BYTES, PERCPU_ADDR, :percpu)
5057 - __phys_per_cpu_start = __per_cpu_load;
5058 + __phys_per_cpu_start = per_cpu_load;
5059 /*
5060 * ensure percpu data fits
5061 * into percpu page size
5062 diff --git a/arch/ia64/mm/fault.c b/arch/ia64/mm/fault.c
5063 index 6cf0341..d352594 100644
5064 --- a/arch/ia64/mm/fault.c
5065 +++ b/arch/ia64/mm/fault.c
5066 @@ -72,6 +72,23 @@ mapped_kernel_page_is_present (unsigned long address)
5067 return pte_present(pte);
5068 }
5069
5070 +#ifdef CONFIG_PAX_PAGEEXEC
5071 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
5072 +{
5073 + unsigned long i;
5074 +
5075 + printk(KERN_ERR "PAX: bytes at PC: ");
5076 + for (i = 0; i < 8; i++) {
5077 + unsigned int c;
5078 + if (get_user(c, (unsigned int *)pc+i))
5079 + printk(KERN_CONT "???????? ");
5080 + else
5081 + printk(KERN_CONT "%08x ", c);
5082 + }
5083 + printk("\n");
5084 +}
5085 +#endif
5086 +
5087 # define VM_READ_BIT 0
5088 # define VM_WRITE_BIT 1
5089 # define VM_EXEC_BIT 2
5090 @@ -149,8 +166,21 @@ retry:
5091 if (((isr >> IA64_ISR_R_BIT) & 1UL) && (!(vma->vm_flags & (VM_READ | VM_WRITE))))
5092 goto bad_area;
5093
5094 - if ((vma->vm_flags & mask) != mask)
5095 + if ((vma->vm_flags & mask) != mask) {
5096 +
5097 +#ifdef CONFIG_PAX_PAGEEXEC
5098 + if (!(vma->vm_flags & VM_EXEC) && (mask & VM_EXEC)) {
5099 + if (!(mm->pax_flags & MF_PAX_PAGEEXEC) || address != regs->cr_iip)
5100 + goto bad_area;
5101 +
5102 + up_read(&mm->mmap_sem);
5103 + pax_report_fault(regs, (void *)regs->cr_iip, (void *)regs->r12);
5104 + do_group_exit(SIGKILL);
5105 + }
5106 +#endif
5107 +
5108 goto bad_area;
5109 + }
5110
5111 /*
5112 * If for any reason at all we couldn't handle the fault, make
5113 diff --git a/arch/ia64/mm/hugetlbpage.c b/arch/ia64/mm/hugetlbpage.c
5114 index 5ca674b..127c3cb 100644
5115 --- a/arch/ia64/mm/hugetlbpage.c
5116 +++ b/arch/ia64/mm/hugetlbpage.c
5117 @@ -149,6 +149,7 @@ unsigned long hugetlb_get_unmapped_area(struct file *file, unsigned long addr, u
5118 unsigned long pgoff, unsigned long flags)
5119 {
5120 struct vm_area_struct *vmm;
5121 + unsigned long offset = gr_rand_threadstack_offset(current->mm, file, flags);
5122
5123 if (len > RGN_MAP_LIMIT)
5124 return -ENOMEM;
5125 @@ -171,7 +172,7 @@ unsigned long hugetlb_get_unmapped_area(struct file *file, unsigned long addr, u
5126 /* At this point: (!vmm || addr < vmm->vm_end). */
5127 if (REGION_OFFSET(addr) + len > RGN_MAP_LIMIT)
5128 return -ENOMEM;
5129 - if (!vmm || (addr + len) <= vmm->vm_start)
5130 + if (check_heap_stack_gap(vmm, addr, len, offset))
5131 return addr;
5132 addr = ALIGN(vmm->vm_end, HPAGE_SIZE);
5133 }
5134 diff --git a/arch/ia64/mm/init.c b/arch/ia64/mm/init.c
5135 index b755ea9..b9a969e 100644
5136 --- a/arch/ia64/mm/init.c
5137 +++ b/arch/ia64/mm/init.c
5138 @@ -120,6 +120,19 @@ ia64_init_addr_space (void)
5139 vma->vm_start = current->thread.rbs_bot & PAGE_MASK;
5140 vma->vm_end = vma->vm_start + PAGE_SIZE;
5141 vma->vm_flags = VM_DATA_DEFAULT_FLAGS|VM_GROWSUP|VM_ACCOUNT;
5142 +
5143 +#ifdef CONFIG_PAX_PAGEEXEC
5144 + if (current->mm->pax_flags & MF_PAX_PAGEEXEC) {
5145 + vma->vm_flags &= ~VM_EXEC;
5146 +
5147 +#ifdef CONFIG_PAX_MPROTECT
5148 + if (current->mm->pax_flags & MF_PAX_MPROTECT)
5149 + vma->vm_flags &= ~VM_MAYEXEC;
5150 +#endif
5151 +
5152 + }
5153 +#endif
5154 +
5155 vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
5156 down_write(&current->mm->mmap_sem);
5157 if (insert_vm_struct(current->mm, vma)) {
5158 diff --git a/arch/m32r/include/asm/cache.h b/arch/m32r/include/asm/cache.h
5159 index 40b3ee9..8c2c112 100644
5160 --- a/arch/m32r/include/asm/cache.h
5161 +++ b/arch/m32r/include/asm/cache.h
5162 @@ -1,8 +1,10 @@
5163 #ifndef _ASM_M32R_CACHE_H
5164 #define _ASM_M32R_CACHE_H
5165
5166 +#include <linux/const.h>
5167 +
5168 /* L1 cache line size */
5169 #define L1_CACHE_SHIFT 4
5170 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
5171 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5172
5173 #endif /* _ASM_M32R_CACHE_H */
5174 diff --git a/arch/m32r/lib/usercopy.c b/arch/m32r/lib/usercopy.c
5175 index 82abd15..d95ae5d 100644
5176 --- a/arch/m32r/lib/usercopy.c
5177 +++ b/arch/m32r/lib/usercopy.c
5178 @@ -14,6 +14,9 @@
5179 unsigned long
5180 __generic_copy_to_user(void __user *to, const void *from, unsigned long n)
5181 {
5182 + if ((long)n < 0)
5183 + return n;
5184 +
5185 prefetch(from);
5186 if (access_ok(VERIFY_WRITE, to, n))
5187 __copy_user(to,from,n);
5188 @@ -23,6 +26,9 @@ __generic_copy_to_user(void __user *to, const void *from, unsigned long n)
5189 unsigned long
5190 __generic_copy_from_user(void *to, const void __user *from, unsigned long n)
5191 {
5192 + if ((long)n < 0)
5193 + return n;
5194 +
5195 prefetchw(to);
5196 if (access_ok(VERIFY_READ, from, n))
5197 __copy_user_zeroing(to,from,n);
5198 diff --git a/arch/m68k/include/asm/cache.h b/arch/m68k/include/asm/cache.h
5199 index 0395c51..5f26031 100644
5200 --- a/arch/m68k/include/asm/cache.h
5201 +++ b/arch/m68k/include/asm/cache.h
5202 @@ -4,9 +4,11 @@
5203 #ifndef __ARCH_M68K_CACHE_H
5204 #define __ARCH_M68K_CACHE_H
5205
5206 +#include <linux/const.h>
5207 +
5208 /* bytes per L1 cache line */
5209 #define L1_CACHE_SHIFT 4
5210 -#define L1_CACHE_BYTES (1<< L1_CACHE_SHIFT)
5211 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5212
5213 #define ARCH_DMA_MINALIGN L1_CACHE_BYTES
5214
5215 diff --git a/arch/microblaze/include/asm/cache.h b/arch/microblaze/include/asm/cache.h
5216 index 4efe96a..60e8699 100644
5217 --- a/arch/microblaze/include/asm/cache.h
5218 +++ b/arch/microblaze/include/asm/cache.h
5219 @@ -13,11 +13,12 @@
5220 #ifndef _ASM_MICROBLAZE_CACHE_H
5221 #define _ASM_MICROBLAZE_CACHE_H
5222
5223 +#include <linux/const.h>
5224 #include <asm/registers.h>
5225
5226 #define L1_CACHE_SHIFT 5
5227 /* word-granular cache in microblaze */
5228 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
5229 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5230
5231 #define SMP_CACHE_BYTES L1_CACHE_BYTES
5232
5233 diff --git a/arch/mips/include/asm/atomic.h b/arch/mips/include/asm/atomic.h
5234 index 01cc6ba..bcb7a5d 100644
5235 --- a/arch/mips/include/asm/atomic.h
5236 +++ b/arch/mips/include/asm/atomic.h
5237 @@ -21,6 +21,10 @@
5238 #include <asm/cmpxchg.h>
5239 #include <asm/war.h>
5240
5241 +#ifdef CONFIG_GENERIC_ATOMIC64
5242 +#include <asm-generic/atomic64.h>
5243 +#endif
5244 +
5245 #define ATOMIC_INIT(i) { (i) }
5246
5247 /*
5248 @@ -759,6 +763,16 @@ static __inline__ int atomic64_add_unless(atomic64_t *v, long a, long u)
5249 */
5250 #define atomic64_add_negative(i, v) (atomic64_add_return(i, (v)) < 0)
5251
5252 +#define atomic64_read_unchecked(v) atomic64_read(v)
5253 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
5254 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
5255 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
5256 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
5257 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
5258 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
5259 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
5260 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
5261 +
5262 #endif /* CONFIG_64BIT */
5263
5264 /*
5265 diff --git a/arch/mips/include/asm/cache.h b/arch/mips/include/asm/cache.h
5266 index b4db69f..8f3b093 100644
5267 --- a/arch/mips/include/asm/cache.h
5268 +++ b/arch/mips/include/asm/cache.h
5269 @@ -9,10 +9,11 @@
5270 #ifndef _ASM_CACHE_H
5271 #define _ASM_CACHE_H
5272
5273 +#include <linux/const.h>
5274 #include <kmalloc.h>
5275
5276 #define L1_CACHE_SHIFT CONFIG_MIPS_L1_CACHE_SHIFT
5277 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
5278 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5279
5280 #define SMP_CACHE_SHIFT L1_CACHE_SHIFT
5281 #define SMP_CACHE_BYTES L1_CACHE_BYTES
5282 diff --git a/arch/mips/include/asm/elf.h b/arch/mips/include/asm/elf.h
5283 index 455c0ac..ad65fbe 100644
5284 --- a/arch/mips/include/asm/elf.h
5285 +++ b/arch/mips/include/asm/elf.h
5286 @@ -372,13 +372,16 @@ extern const char *__elf_platform;
5287 #define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
5288 #endif
5289
5290 +#ifdef CONFIG_PAX_ASLR
5291 +#define PAX_ELF_ET_DYN_BASE (TASK_IS_32BIT_ADDR ? 0x00400000UL : 0x00400000UL)
5292 +
5293 +#define PAX_DELTA_MMAP_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
5294 +#define PAX_DELTA_STACK_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
5295 +#endif
5296 +
5297 #define ARCH_HAS_SETUP_ADDITIONAL_PAGES 1
5298 struct linux_binprm;
5299 extern int arch_setup_additional_pages(struct linux_binprm *bprm,
5300 int uses_interp);
5301
5302 -struct mm_struct;
5303 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
5304 -#define arch_randomize_brk arch_randomize_brk
5305 -
5306 #endif /* _ASM_ELF_H */
5307 diff --git a/arch/mips/include/asm/exec.h b/arch/mips/include/asm/exec.h
5308 index c1f6afa..38cc6e9 100644
5309 --- a/arch/mips/include/asm/exec.h
5310 +++ b/arch/mips/include/asm/exec.h
5311 @@ -12,6 +12,6 @@
5312 #ifndef _ASM_EXEC_H
5313 #define _ASM_EXEC_H
5314
5315 -extern unsigned long arch_align_stack(unsigned long sp);
5316 +#define arch_align_stack(x) ((x) & ~0xfUL)
5317
5318 #endif /* _ASM_EXEC_H */
5319 diff --git a/arch/mips/include/asm/page.h b/arch/mips/include/asm/page.h
5320 index dbaec94..6a14935 100644
5321 --- a/arch/mips/include/asm/page.h
5322 +++ b/arch/mips/include/asm/page.h
5323 @@ -96,7 +96,7 @@ extern void copy_user_highpage(struct page *to, struct page *from,
5324 #ifdef CONFIG_CPU_MIPS32
5325 typedef struct { unsigned long pte_low, pte_high; } pte_t;
5326 #define pte_val(x) ((x).pte_low | ((unsigned long long)(x).pte_high << 32))
5327 - #define __pte(x) ({ pte_t __pte = {(x), ((unsigned long long)(x)) >> 32}; __pte; })
5328 + #define __pte(x) ({ pte_t __pte = {(x), (x) >> 32}; __pte; })
5329 #else
5330 typedef struct { unsigned long long pte; } pte_t;
5331 #define pte_val(x) ((x).pte)
5332 diff --git a/arch/mips/include/asm/pgalloc.h b/arch/mips/include/asm/pgalloc.h
5333 index 881d18b..cea38bc 100644
5334 --- a/arch/mips/include/asm/pgalloc.h
5335 +++ b/arch/mips/include/asm/pgalloc.h
5336 @@ -37,6 +37,11 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
5337 {
5338 set_pud(pud, __pud((unsigned long)pmd));
5339 }
5340 +
5341 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
5342 +{
5343 + pud_populate(mm, pud, pmd);
5344 +}
5345 #endif
5346
5347 /*
5348 diff --git a/arch/mips/include/asm/thread_info.h b/arch/mips/include/asm/thread_info.h
5349 index b2050b9..d71bb1b 100644
5350 --- a/arch/mips/include/asm/thread_info.h
5351 +++ b/arch/mips/include/asm/thread_info.h
5352 @@ -111,6 +111,8 @@ register struct thread_info *__current_thread_info __asm__("$28");
5353 #define TIF_32BIT_ADDR 23 /* 32-bit address space (o32/n32) */
5354 #define TIF_FPUBOUND 24 /* thread bound to FPU-full CPU set */
5355 #define TIF_LOAD_WATCH 25 /* If set, load watch registers */
5356 +/* li takes a 32bit immediate */
5357 +#define TIF_GRSEC_SETXID 29 /* update credentials on syscall entry/exit */
5358 #define TIF_SYSCALL_TRACE 31 /* syscall trace active */
5359
5360 #define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
5361 @@ -126,15 +128,18 @@ register struct thread_info *__current_thread_info __asm__("$28");
5362 #define _TIF_32BIT_ADDR (1<<TIF_32BIT_ADDR)
5363 #define _TIF_FPUBOUND (1<<TIF_FPUBOUND)
5364 #define _TIF_LOAD_WATCH (1<<TIF_LOAD_WATCH)
5365 +#define _TIF_GRSEC_SETXID (1<<TIF_GRSEC_SETXID)
5366 +
5367 +#define _TIF_SYSCALL_WORK (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | _TIF_GRSEC_SETXID)
5368
5369 /* work to do in syscall_trace_leave() */
5370 -#define _TIF_WORK_SYSCALL_EXIT (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT)
5371 +#define _TIF_WORK_SYSCALL_EXIT (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | _TIF_GRSEC_SETXID)
5372
5373 /* work to do on interrupt/exception return */
5374 #define _TIF_WORK_MASK \
5375 (_TIF_SIGPENDING | _TIF_NEED_RESCHED | _TIF_NOTIFY_RESUME)
5376 /* work to do on any return to u-space */
5377 -#define _TIF_ALLWORK_MASK (_TIF_WORK_MASK | _TIF_WORK_SYSCALL_EXIT)
5378 +#define _TIF_ALLWORK_MASK (_TIF_WORK_MASK | _TIF_WORK_SYSCALL_EXIT | _TIF_GRSEC_SETXID)
5379
5380 #endif /* __KERNEL__ */
5381
5382 diff --git a/arch/mips/kernel/binfmt_elfn32.c b/arch/mips/kernel/binfmt_elfn32.c
5383 index 9fdd8bc..4bd7f1a 100644
5384 --- a/arch/mips/kernel/binfmt_elfn32.c
5385 +++ b/arch/mips/kernel/binfmt_elfn32.c
5386 @@ -50,6 +50,13 @@ typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
5387 #undef ELF_ET_DYN_BASE
5388 #define ELF_ET_DYN_BASE (TASK32_SIZE / 3 * 2)
5389
5390 +#ifdef CONFIG_PAX_ASLR
5391 +#define PAX_ELF_ET_DYN_BASE (TASK_IS_32BIT_ADDR ? 0x00400000UL : 0x00400000UL)
5392 +
5393 +#define PAX_DELTA_MMAP_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
5394 +#define PAX_DELTA_STACK_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
5395 +#endif
5396 +
5397 #include <asm/processor.h>
5398 #include <linux/module.h>
5399 #include <linux/elfcore.h>
5400 diff --git a/arch/mips/kernel/binfmt_elfo32.c b/arch/mips/kernel/binfmt_elfo32.c
5401 index ff44823..97f8906 100644
5402 --- a/arch/mips/kernel/binfmt_elfo32.c
5403 +++ b/arch/mips/kernel/binfmt_elfo32.c
5404 @@ -52,6 +52,13 @@ typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
5405 #undef ELF_ET_DYN_BASE
5406 #define ELF_ET_DYN_BASE (TASK32_SIZE / 3 * 2)
5407
5408 +#ifdef CONFIG_PAX_ASLR
5409 +#define PAX_ELF_ET_DYN_BASE (TASK_IS_32BIT_ADDR ? 0x00400000UL : 0x00400000UL)
5410 +
5411 +#define PAX_DELTA_MMAP_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
5412 +#define PAX_DELTA_STACK_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
5413 +#endif
5414 +
5415 #include <asm/processor.h>
5416
5417 /*
5418 diff --git a/arch/mips/kernel/process.c b/arch/mips/kernel/process.c
5419 index a11c6f9..be5e164 100644
5420 --- a/arch/mips/kernel/process.c
5421 +++ b/arch/mips/kernel/process.c
5422 @@ -460,15 +460,3 @@ unsigned long get_wchan(struct task_struct *task)
5423 out:
5424 return pc;
5425 }
5426 -
5427 -/*
5428 - * Don't forget that the stack pointer must be aligned on a 8 bytes
5429 - * boundary for 32-bits ABI and 16 bytes for 64-bits ABI.
5430 - */
5431 -unsigned long arch_align_stack(unsigned long sp)
5432 -{
5433 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
5434 - sp -= get_random_int() & ~PAGE_MASK;
5435 -
5436 - return sp & ALMASK;
5437 -}
5438 diff --git a/arch/mips/kernel/ptrace.c b/arch/mips/kernel/ptrace.c
5439 index 4812c6d..2069554 100644
5440 --- a/arch/mips/kernel/ptrace.c
5441 +++ b/arch/mips/kernel/ptrace.c
5442 @@ -528,6 +528,10 @@ static inline int audit_arch(void)
5443 return arch;
5444 }
5445
5446 +#ifdef CONFIG_GRKERNSEC_SETXID
5447 +extern void gr_delayed_cred_worker(void);
5448 +#endif
5449 +
5450 /*
5451 * Notification of system call entry/exit
5452 * - triggered by current->work.syscall_trace
5453 @@ -537,6 +541,11 @@ asmlinkage void syscall_trace_enter(struct pt_regs *regs)
5454 /* do the secure computing check first */
5455 secure_computing_strict(regs->regs[2]);
5456
5457 +#ifdef CONFIG_GRKERNSEC_SETXID
5458 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
5459 + gr_delayed_cred_worker();
5460 +#endif
5461 +
5462 if (!(current->ptrace & PT_PTRACED))
5463 goto out;
5464
5465 diff --git a/arch/mips/kernel/scall32-o32.S b/arch/mips/kernel/scall32-o32.S
5466 index d20a4bc..7096ae5 100644
5467 --- a/arch/mips/kernel/scall32-o32.S
5468 +++ b/arch/mips/kernel/scall32-o32.S
5469 @@ -52,7 +52,7 @@ NESTED(handle_sys, PT_SIZE, sp)
5470
5471 stack_done:
5472 lw t0, TI_FLAGS($28) # syscall tracing enabled?
5473 - li t1, _TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT
5474 + li t1, _TIF_SYSCALL_WORK
5475 and t0, t1
5476 bnez t0, syscall_trace_entry # -> yes
5477
5478 diff --git a/arch/mips/kernel/scall64-64.S b/arch/mips/kernel/scall64-64.S
5479 index b64f642..0fe6eab 100644
5480 --- a/arch/mips/kernel/scall64-64.S
5481 +++ b/arch/mips/kernel/scall64-64.S
5482 @@ -54,7 +54,7 @@ NESTED(handle_sys64, PT_SIZE, sp)
5483
5484 sd a3, PT_R26(sp) # save a3 for syscall restarting
5485
5486 - li t1, _TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT
5487 + li t1, _TIF_SYSCALL_WORK
5488 LONG_L t0, TI_FLAGS($28) # syscall tracing enabled?
5489 and t0, t1, t0
5490 bnez t0, syscall_trace_entry
5491 diff --git a/arch/mips/kernel/scall64-n32.S b/arch/mips/kernel/scall64-n32.S
5492 index c29ac19..c592d05 100644
5493 --- a/arch/mips/kernel/scall64-n32.S
5494 +++ b/arch/mips/kernel/scall64-n32.S
5495 @@ -47,7 +47,7 @@ NESTED(handle_sysn32, PT_SIZE, sp)
5496
5497 sd a3, PT_R26(sp) # save a3 for syscall restarting
5498
5499 - li t1, _TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT
5500 + li t1, _TIF_SYSCALL_WORK
5501 LONG_L t0, TI_FLAGS($28) # syscall tracing enabled?
5502 and t0, t1, t0
5503 bnez t0, n32_syscall_trace_entry
5504 diff --git a/arch/mips/kernel/scall64-o32.S b/arch/mips/kernel/scall64-o32.S
5505 index cf3e75e..72e93fe 100644
5506 --- a/arch/mips/kernel/scall64-o32.S
5507 +++ b/arch/mips/kernel/scall64-o32.S
5508 @@ -81,7 +81,7 @@ NESTED(handle_sys, PT_SIZE, sp)
5509 PTR 4b, bad_stack
5510 .previous
5511
5512 - li t1, _TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT
5513 + li t1, _TIF_SYSCALL_WORK
5514 LONG_L t0, TI_FLAGS($28) # syscall tracing enabled?
5515 and t0, t1, t0
5516 bnez t0, trace_a_syscall
5517 diff --git a/arch/mips/mm/fault.c b/arch/mips/mm/fault.c
5518 index ddcec1e..c7f983e 100644
5519 --- a/arch/mips/mm/fault.c
5520 +++ b/arch/mips/mm/fault.c
5521 @@ -27,6 +27,23 @@
5522 #include <asm/highmem.h> /* For VMALLOC_END */
5523 #include <linux/kdebug.h>
5524
5525 +#ifdef CONFIG_PAX_PAGEEXEC
5526 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
5527 +{
5528 + unsigned long i;
5529 +
5530 + printk(KERN_ERR "PAX: bytes at PC: ");
5531 + for (i = 0; i < 5; i++) {
5532 + unsigned int c;
5533 + if (get_user(c, (unsigned int *)pc+i))
5534 + printk(KERN_CONT "???????? ");
5535 + else
5536 + printk(KERN_CONT "%08x ", c);
5537 + }
5538 + printk("\n");
5539 +}
5540 +#endif
5541 +
5542 /*
5543 * This routine handles page faults. It determines the address,
5544 * and the problem, and then passes it off to one of the appropriate
5545 diff --git a/arch/mips/mm/mmap.c b/arch/mips/mm/mmap.c
5546 index 7e5fe27..479a219 100644
5547 --- a/arch/mips/mm/mmap.c
5548 +++ b/arch/mips/mm/mmap.c
5549 @@ -59,6 +59,7 @@ static unsigned long arch_get_unmapped_area_common(struct file *filp,
5550 struct vm_area_struct *vma;
5551 unsigned long addr = addr0;
5552 int do_color_align;
5553 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
5554 struct vm_unmapped_area_info info;
5555
5556 if (unlikely(len > TASK_SIZE))
5557 @@ -84,6 +85,11 @@ static unsigned long arch_get_unmapped_area_common(struct file *filp,
5558 do_color_align = 1;
5559
5560 /* requesting a specific address */
5561 +
5562 +#ifdef CONFIG_PAX_RANDMMAP
5563 + if (!(current->mm->pax_flags & MF_PAX_RANDMMAP))
5564 +#endif
5565 +
5566 if (addr) {
5567 if (do_color_align)
5568 addr = COLOUR_ALIGN(addr, pgoff);
5569 @@ -91,8 +97,7 @@ static unsigned long arch_get_unmapped_area_common(struct file *filp,
5570 addr = PAGE_ALIGN(addr);
5571
5572 vma = find_vma(mm, addr);
5573 - if (TASK_SIZE - len >= addr &&
5574 - (!vma || addr + len <= vma->vm_start))
5575 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vmm, addr, len, offset))
5576 return addr;
5577 }
5578
5579 @@ -146,6 +151,10 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
5580 {
5581 unsigned long random_factor = 0UL;
5582
5583 +#ifdef CONFIG_PAX_RANDMMAP
5584 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
5585 +#endif
5586 +
5587 if (current->flags & PF_RANDOMIZE) {
5588 random_factor = get_random_int();
5589 random_factor = random_factor << PAGE_SHIFT;
5590 @@ -157,42 +166,27 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
5591
5592 if (mmap_is_legacy()) {
5593 mm->mmap_base = TASK_UNMAPPED_BASE + random_factor;
5594 +
5595 +#ifdef CONFIG_PAX_RANDMMAP
5596 + if (mm->pax_flags & MF_PAX_RANDMMAP)
5597 + mm->mmap_base += mm->delta_mmap;
5598 +#endif
5599 +
5600 mm->get_unmapped_area = arch_get_unmapped_area;
5601 mm->unmap_area = arch_unmap_area;
5602 } else {
5603 mm->mmap_base = mmap_base(random_factor);
5604 +
5605 +#ifdef CONFIG_PAX_RANDMMAP
5606 + if (mm->pax_flags & MF_PAX_RANDMMAP)
5607 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
5608 +#endif
5609 +
5610 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
5611 mm->unmap_area = arch_unmap_area_topdown;
5612 }
5613 }
5614
5615 -static inline unsigned long brk_rnd(void)
5616 -{
5617 - unsigned long rnd = get_random_int();
5618 -
5619 - rnd = rnd << PAGE_SHIFT;
5620 - /* 8MB for 32bit, 256MB for 64bit */
5621 - if (TASK_IS_32BIT_ADDR)
5622 - rnd = rnd & 0x7ffffful;
5623 - else
5624 - rnd = rnd & 0xffffffful;
5625 -
5626 - return rnd;
5627 -}
5628 -
5629 -unsigned long arch_randomize_brk(struct mm_struct *mm)
5630 -{
5631 - unsigned long base = mm->brk;
5632 - unsigned long ret;
5633 -
5634 - ret = PAGE_ALIGN(base + brk_rnd());
5635 -
5636 - if (ret < mm->brk)
5637 - return mm->brk;
5638 -
5639 - return ret;
5640 -}
5641 -
5642 int __virt_addr_valid(const volatile void *kaddr)
5643 {
5644 return pfn_valid(PFN_DOWN(virt_to_phys(kaddr)));
5645 diff --git a/arch/mn10300/proc-mn103e010/include/proc/cache.h b/arch/mn10300/proc-mn103e010/include/proc/cache.h
5646 index 967d144..db12197 100644
5647 --- a/arch/mn10300/proc-mn103e010/include/proc/cache.h
5648 +++ b/arch/mn10300/proc-mn103e010/include/proc/cache.h
5649 @@ -11,12 +11,14 @@
5650 #ifndef _ASM_PROC_CACHE_H
5651 #define _ASM_PROC_CACHE_H
5652
5653 +#include <linux/const.h>
5654 +
5655 /* L1 cache */
5656
5657 #define L1_CACHE_NWAYS 4 /* number of ways in caches */
5658 #define L1_CACHE_NENTRIES 256 /* number of entries in each way */
5659 -#define L1_CACHE_BYTES 16 /* bytes per entry */
5660 #define L1_CACHE_SHIFT 4 /* shift for bytes per entry */
5661 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT) /* bytes per entry */
5662 #define L1_CACHE_WAYDISP 0x1000 /* displacement of one way from the next */
5663
5664 #define L1_CACHE_TAG_VALID 0x00000001 /* cache tag valid bit */
5665 diff --git a/arch/mn10300/proc-mn2ws0050/include/proc/cache.h b/arch/mn10300/proc-mn2ws0050/include/proc/cache.h
5666 index bcb5df2..84fabd2 100644
5667 --- a/arch/mn10300/proc-mn2ws0050/include/proc/cache.h
5668 +++ b/arch/mn10300/proc-mn2ws0050/include/proc/cache.h
5669 @@ -16,13 +16,15 @@
5670 #ifndef _ASM_PROC_CACHE_H
5671 #define _ASM_PROC_CACHE_H
5672
5673 +#include <linux/const.h>
5674 +
5675 /*
5676 * L1 cache
5677 */
5678 #define L1_CACHE_NWAYS 4 /* number of ways in caches */
5679 #define L1_CACHE_NENTRIES 128 /* number of entries in each way */
5680 -#define L1_CACHE_BYTES 32 /* bytes per entry */
5681 #define L1_CACHE_SHIFT 5 /* shift for bytes per entry */
5682 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT) /* bytes per entry */
5683 #define L1_CACHE_WAYDISP 0x1000 /* distance from one way to the next */
5684
5685 #define L1_CACHE_TAG_VALID 0x00000001 /* cache tag valid bit */
5686 diff --git a/arch/openrisc/include/asm/cache.h b/arch/openrisc/include/asm/cache.h
5687 index 4ce7a01..449202a 100644
5688 --- a/arch/openrisc/include/asm/cache.h
5689 +++ b/arch/openrisc/include/asm/cache.h
5690 @@ -19,11 +19,13 @@
5691 #ifndef __ASM_OPENRISC_CACHE_H
5692 #define __ASM_OPENRISC_CACHE_H
5693
5694 +#include <linux/const.h>
5695 +
5696 /* FIXME: How can we replace these with values from the CPU...
5697 * they shouldn't be hard-coded!
5698 */
5699
5700 -#define L1_CACHE_BYTES 16
5701 #define L1_CACHE_SHIFT 4
5702 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5703
5704 #endif /* __ASM_OPENRISC_CACHE_H */
5705 diff --git a/arch/parisc/include/asm/atomic.h b/arch/parisc/include/asm/atomic.h
5706 index af9cf30..2aae9b2 100644
5707 --- a/arch/parisc/include/asm/atomic.h
5708 +++ b/arch/parisc/include/asm/atomic.h
5709 @@ -229,6 +229,16 @@ static __inline__ int atomic64_add_unless(atomic64_t *v, long a, long u)
5710
5711 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
5712
5713 +#define atomic64_read_unchecked(v) atomic64_read(v)
5714 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
5715 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
5716 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
5717 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
5718 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
5719 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
5720 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
5721 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
5722 +
5723 #endif /* !CONFIG_64BIT */
5724
5725
5726 diff --git a/arch/parisc/include/asm/cache.h b/arch/parisc/include/asm/cache.h
5727 index 47f11c7..3420df2 100644
5728 --- a/arch/parisc/include/asm/cache.h
5729 +++ b/arch/parisc/include/asm/cache.h
5730 @@ -5,6 +5,7 @@
5731 #ifndef __ARCH_PARISC_CACHE_H
5732 #define __ARCH_PARISC_CACHE_H
5733
5734 +#include <linux/const.h>
5735
5736 /*
5737 * PA 2.0 processors have 64-byte cachelines; PA 1.1 processors have
5738 @@ -15,13 +16,13 @@
5739 * just ruin performance.
5740 */
5741 #ifdef CONFIG_PA20
5742 -#define L1_CACHE_BYTES 64
5743 #define L1_CACHE_SHIFT 6
5744 #else
5745 -#define L1_CACHE_BYTES 32
5746 #define L1_CACHE_SHIFT 5
5747 #endif
5748
5749 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5750 +
5751 #ifndef __ASSEMBLY__
5752
5753 #define SMP_CACHE_BYTES L1_CACHE_BYTES
5754 diff --git a/arch/parisc/include/asm/elf.h b/arch/parisc/include/asm/elf.h
5755 index 19f6cb1..6c78cf2 100644
5756 --- a/arch/parisc/include/asm/elf.h
5757 +++ b/arch/parisc/include/asm/elf.h
5758 @@ -342,6 +342,13 @@ struct pt_regs; /* forward declaration... */
5759
5760 #define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE + 0x01000000)
5761
5762 +#ifdef CONFIG_PAX_ASLR
5763 +#define PAX_ELF_ET_DYN_BASE 0x10000UL
5764 +
5765 +#define PAX_DELTA_MMAP_LEN 16
5766 +#define PAX_DELTA_STACK_LEN 16
5767 +#endif
5768 +
5769 /* This yields a mask that user programs can use to figure out what
5770 instruction set this CPU supports. This could be done in user space,
5771 but it's not easy, and we've already done it here. */
5772 diff --git a/arch/parisc/include/asm/pgalloc.h b/arch/parisc/include/asm/pgalloc.h
5773 index fc987a1..6e068ef 100644
5774 --- a/arch/parisc/include/asm/pgalloc.h
5775 +++ b/arch/parisc/include/asm/pgalloc.h
5776 @@ -61,6 +61,11 @@ static inline void pgd_populate(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmd)
5777 (__u32)(__pa((unsigned long)pmd) >> PxD_VALUE_SHIFT));
5778 }
5779
5780 +static inline void pgd_populate_kernel(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmd)
5781 +{
5782 + pgd_populate(mm, pgd, pmd);
5783 +}
5784 +
5785 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long address)
5786 {
5787 pmd_t *pmd = (pmd_t *)__get_free_pages(GFP_KERNEL|__GFP_REPEAT,
5788 @@ -93,6 +98,7 @@ static inline void pmd_free(struct mm_struct *mm, pmd_t *pmd)
5789 #define pmd_alloc_one(mm, addr) ({ BUG(); ((pmd_t *)2); })
5790 #define pmd_free(mm, x) do { } while (0)
5791 #define pgd_populate(mm, pmd, pte) BUG()
5792 +#define pgd_populate_kernel(mm, pmd, pte) BUG()
5793
5794 #endif
5795
5796 diff --git a/arch/parisc/include/asm/pgtable.h b/arch/parisc/include/asm/pgtable.h
5797 index 7df49fa..38b62bf 100644
5798 --- a/arch/parisc/include/asm/pgtable.h
5799 +++ b/arch/parisc/include/asm/pgtable.h
5800 @@ -218,6 +218,17 @@ extern void purge_tlb_entries(struct mm_struct *, unsigned long);
5801 #define PAGE_EXECREAD __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_EXEC |_PAGE_ACCESSED)
5802 #define PAGE_COPY PAGE_EXECREAD
5803 #define PAGE_RWX __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_WRITE | _PAGE_EXEC |_PAGE_ACCESSED)
5804 +
5805 +#ifdef CONFIG_PAX_PAGEEXEC
5806 +# define PAGE_SHARED_NOEXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_WRITE | _PAGE_ACCESSED)
5807 +# define PAGE_COPY_NOEXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_ACCESSED)
5808 +# define PAGE_READONLY_NOEXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_ACCESSED)
5809 +#else
5810 +# define PAGE_SHARED_NOEXEC PAGE_SHARED
5811 +# define PAGE_COPY_NOEXEC PAGE_COPY
5812 +# define PAGE_READONLY_NOEXEC PAGE_READONLY
5813 +#endif
5814 +
5815 #define PAGE_KERNEL __pgprot(_PAGE_KERNEL)
5816 #define PAGE_KERNEL_EXEC __pgprot(_PAGE_KERNEL_EXEC)
5817 #define PAGE_KERNEL_RWX __pgprot(_PAGE_KERNEL_RWX)
5818 diff --git a/arch/parisc/include/asm/uaccess.h b/arch/parisc/include/asm/uaccess.h
5819 index 4ba2c93..f5e3974 100644
5820 --- a/arch/parisc/include/asm/uaccess.h
5821 +++ b/arch/parisc/include/asm/uaccess.h
5822 @@ -251,10 +251,10 @@ static inline unsigned long __must_check copy_from_user(void *to,
5823 const void __user *from,
5824 unsigned long n)
5825 {
5826 - int sz = __compiletime_object_size(to);
5827 + size_t sz = __compiletime_object_size(to);
5828 int ret = -EFAULT;
5829
5830 - if (likely(sz == -1 || !__builtin_constant_p(n) || sz >= n))
5831 + if (likely(sz == (size_t)-1 || !__builtin_constant_p(n) || sz >= n))
5832 ret = __copy_from_user(to, from, n);
5833 else
5834 copy_from_user_overflow();
5835 diff --git a/arch/parisc/kernel/module.c b/arch/parisc/kernel/module.c
5836 index 2a625fb..9908930 100644
5837 --- a/arch/parisc/kernel/module.c
5838 +++ b/arch/parisc/kernel/module.c
5839 @@ -98,16 +98,38 @@
5840
5841 /* three functions to determine where in the module core
5842 * or init pieces the location is */
5843 +static inline int in_init_rx(struct module *me, void *loc)
5844 +{
5845 + return (loc >= me->module_init_rx &&
5846 + loc < (me->module_init_rx + me->init_size_rx));
5847 +}
5848 +
5849 +static inline int in_init_rw(struct module *me, void *loc)
5850 +{
5851 + return (loc >= me->module_init_rw &&
5852 + loc < (me->module_init_rw + me->init_size_rw));
5853 +}
5854 +
5855 static inline int in_init(struct module *me, void *loc)
5856 {
5857 - return (loc >= me->module_init &&
5858 - loc <= (me->module_init + me->init_size));
5859 + return in_init_rx(me, loc) || in_init_rw(me, loc);
5860 +}
5861 +
5862 +static inline int in_core_rx(struct module *me, void *loc)
5863 +{
5864 + return (loc >= me->module_core_rx &&
5865 + loc < (me->module_core_rx + me->core_size_rx));
5866 +}
5867 +
5868 +static inline int in_core_rw(struct module *me, void *loc)
5869 +{
5870 + return (loc >= me->module_core_rw &&
5871 + loc < (me->module_core_rw + me->core_size_rw));
5872 }
5873
5874 static inline int in_core(struct module *me, void *loc)
5875 {
5876 - return (loc >= me->module_core &&
5877 - loc <= (me->module_core + me->core_size));
5878 + return in_core_rx(me, loc) || in_core_rw(me, loc);
5879 }
5880
5881 static inline int in_local(struct module *me, void *loc)
5882 @@ -371,13 +393,13 @@ int module_frob_arch_sections(CONST Elf_Ehdr *hdr,
5883 }
5884
5885 /* align things a bit */
5886 - me->core_size = ALIGN(me->core_size, 16);
5887 - me->arch.got_offset = me->core_size;
5888 - me->core_size += gots * sizeof(struct got_entry);
5889 + me->core_size_rw = ALIGN(me->core_size_rw, 16);
5890 + me->arch.got_offset = me->core_size_rw;
5891 + me->core_size_rw += gots * sizeof(struct got_entry);
5892
5893 - me->core_size = ALIGN(me->core_size, 16);
5894 - me->arch.fdesc_offset = me->core_size;
5895 - me->core_size += fdescs * sizeof(Elf_Fdesc);
5896 + me->core_size_rw = ALIGN(me->core_size_rw, 16);
5897 + me->arch.fdesc_offset = me->core_size_rw;
5898 + me->core_size_rw += fdescs * sizeof(Elf_Fdesc);
5899
5900 me->arch.got_max = gots;
5901 me->arch.fdesc_max = fdescs;
5902 @@ -395,7 +417,7 @@ static Elf64_Word get_got(struct module *me, unsigned long value, long addend)
5903
5904 BUG_ON(value == 0);
5905
5906 - got = me->module_core + me->arch.got_offset;
5907 + got = me->module_core_rw + me->arch.got_offset;
5908 for (i = 0; got[i].addr; i++)
5909 if (got[i].addr == value)
5910 goto out;
5911 @@ -413,7 +435,7 @@ static Elf64_Word get_got(struct module *me, unsigned long value, long addend)
5912 #ifdef CONFIG_64BIT
5913 static Elf_Addr get_fdesc(struct module *me, unsigned long value)
5914 {
5915 - Elf_Fdesc *fdesc = me->module_core + me->arch.fdesc_offset;
5916 + Elf_Fdesc *fdesc = me->module_core_rw + me->arch.fdesc_offset;
5917
5918 if (!value) {
5919 printk(KERN_ERR "%s: zero OPD requested!\n", me->name);
5920 @@ -431,7 +453,7 @@ static Elf_Addr get_fdesc(struct module *me, unsigned long value)
5921
5922 /* Create new one */
5923 fdesc->addr = value;
5924 - fdesc->gp = (Elf_Addr)me->module_core + me->arch.got_offset;
5925 + fdesc->gp = (Elf_Addr)me->module_core_rw + me->arch.got_offset;
5926 return (Elf_Addr)fdesc;
5927 }
5928 #endif /* CONFIG_64BIT */
5929 @@ -843,7 +865,7 @@ register_unwind_table(struct module *me,
5930
5931 table = (unsigned char *)sechdrs[me->arch.unwind_section].sh_addr;
5932 end = table + sechdrs[me->arch.unwind_section].sh_size;
5933 - gp = (Elf_Addr)me->module_core + me->arch.got_offset;
5934 + gp = (Elf_Addr)me->module_core_rw + me->arch.got_offset;
5935
5936 DEBUGP("register_unwind_table(), sect = %d at 0x%p - 0x%p (gp=0x%lx)\n",
5937 me->arch.unwind_section, table, end, gp);
5938 diff --git a/arch/parisc/kernel/sys_parisc.c b/arch/parisc/kernel/sys_parisc.c
5939 index f76c108..92bad82 100644
5940 --- a/arch/parisc/kernel/sys_parisc.c
5941 +++ b/arch/parisc/kernel/sys_parisc.c
5942 @@ -33,9 +33,11 @@
5943 #include <linux/utsname.h>
5944 #include <linux/personality.h>
5945
5946 -static unsigned long get_unshared_area(unsigned long addr, unsigned long len)
5947 +static unsigned long get_unshared_area(struct file *filp, unsigned long addr, unsigned long len,
5948 + unsigned long flags)
5949 {
5950 struct vm_area_struct *vma;
5951 + unsigned long offset = gr_rand_threadstack_offset(current->mm, filp, flags);
5952
5953 addr = PAGE_ALIGN(addr);
5954
5955 @@ -43,7 +45,7 @@ static unsigned long get_unshared_area(unsigned long addr, unsigned long len)
5956 /* At this point: (!vma || addr < vma->vm_end). */
5957 if (TASK_SIZE - len < addr)
5958 return -ENOMEM;
5959 - if (!vma || addr + len <= vma->vm_start)
5960 + if (check_heap_stack_gap(vma, addr, len, offset))
5961 return addr;
5962 addr = vma->vm_end;
5963 }
5964 @@ -67,11 +69,12 @@ static int get_offset(struct address_space *mapping)
5965 return offset & 0x3FF000;
5966 }
5967
5968 -static unsigned long get_shared_area(struct address_space *mapping,
5969 - unsigned long addr, unsigned long len, unsigned long pgoff)
5970 +static unsigned long get_shared_area(struct file *filp, struct address_space *mapping,
5971 + unsigned long addr, unsigned long len, unsigned long pgoff, unsigned long flags)
5972 {
5973 struct vm_area_struct *vma;
5974 int offset = mapping ? get_offset(mapping) : 0;
5975 + unsigned long rand_offset = gr_rand_threadstack_offset(current->mm, filp, flags);
5976
5977 offset = (offset + (pgoff << PAGE_SHIFT)) & 0x3FF000;
5978
5979 @@ -81,7 +84,7 @@ static unsigned long get_shared_area(struct address_space *mapping,
5980 /* At this point: (!vma || addr < vma->vm_end). */
5981 if (TASK_SIZE - len < addr)
5982 return -ENOMEM;
5983 - if (!vma || addr + len <= vma->vm_start)
5984 + if (check_heap_stack_gap(vma, addr, len, rand_offset))
5985 return addr;
5986 addr = DCACHE_ALIGN(vma->vm_end - offset) + offset;
5987 if (addr < vma->vm_end) /* handle wraparound */
5988 @@ -100,14 +103,14 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
5989 if (flags & MAP_FIXED)
5990 return addr;
5991 if (!addr)
5992 - addr = TASK_UNMAPPED_BASE;
5993 + addr = current->mm->mmap_base;
5994
5995 if (filp) {
5996 - addr = get_shared_area(filp->f_mapping, addr, len, pgoff);
5997 + addr = get_shared_area(filp, filp->f_mapping, addr, len, pgoff, flags);
5998 } else if(flags & MAP_SHARED) {
5999 - addr = get_shared_area(NULL, addr, len, pgoff);
6000 + addr = get_shared_area(filp, NULL, addr, len, pgoff, flags);
6001 } else {
6002 - addr = get_unshared_area(addr, len);
6003 + addr = get_unshared_area(filp, addr, len, flags);
6004 }
6005 return addr;
6006 }
6007 diff --git a/arch/parisc/kernel/traps.c b/arch/parisc/kernel/traps.c
6008 index 45ba99f..8e22c33 100644
6009 --- a/arch/parisc/kernel/traps.c
6010 +++ b/arch/parisc/kernel/traps.c
6011 @@ -732,9 +732,7 @@ void notrace handle_interruption(int code, struct pt_regs *regs)
6012
6013 down_read(&current->mm->mmap_sem);
6014 vma = find_vma(current->mm,regs->iaoq[0]);
6015 - if (vma && (regs->iaoq[0] >= vma->vm_start)
6016 - && (vma->vm_flags & VM_EXEC)) {
6017 -
6018 + if (vma && (regs->iaoq[0] >= vma->vm_start)) {
6019 fault_address = regs->iaoq[0];
6020 fault_space = regs->iasq[0];
6021
6022 diff --git a/arch/parisc/mm/fault.c b/arch/parisc/mm/fault.c
6023 index 18162ce..94de376 100644
6024 --- a/arch/parisc/mm/fault.c
6025 +++ b/arch/parisc/mm/fault.c
6026 @@ -15,6 +15,7 @@
6027 #include <linux/sched.h>
6028 #include <linux/interrupt.h>
6029 #include <linux/module.h>
6030 +#include <linux/unistd.h>
6031
6032 #include <asm/uaccess.h>
6033 #include <asm/traps.h>
6034 @@ -52,7 +53,7 @@ DEFINE_PER_CPU(struct exception_data, exception_data);
6035 static unsigned long
6036 parisc_acctyp(unsigned long code, unsigned int inst)
6037 {
6038 - if (code == 6 || code == 16)
6039 + if (code == 6 || code == 7 || code == 16)
6040 return VM_EXEC;
6041
6042 switch (inst & 0xf0000000) {
6043 @@ -138,6 +139,116 @@ parisc_acctyp(unsigned long code, unsigned int inst)
6044 }
6045 #endif
6046
6047 +#ifdef CONFIG_PAX_PAGEEXEC
6048 +/*
6049 + * PaX: decide what to do with offenders (instruction_pointer(regs) = fault address)
6050 + *
6051 + * returns 1 when task should be killed
6052 + * 2 when rt_sigreturn trampoline was detected
6053 + * 3 when unpatched PLT trampoline was detected
6054 + */
6055 +static int pax_handle_fetch_fault(struct pt_regs *regs)
6056 +{
6057 +
6058 +#ifdef CONFIG_PAX_EMUPLT
6059 + int err;
6060 +
6061 + do { /* PaX: unpatched PLT emulation */
6062 + unsigned int bl, depwi;
6063 +
6064 + err = get_user(bl, (unsigned int *)instruction_pointer(regs));
6065 + err |= get_user(depwi, (unsigned int *)(instruction_pointer(regs)+4));
6066 +
6067 + if (err)
6068 + break;
6069 +
6070 + if (bl == 0xEA9F1FDDU && depwi == 0xD6801C1EU) {
6071 + unsigned int ldw, bv, ldw2, addr = instruction_pointer(regs)-12;
6072 +
6073 + err = get_user(ldw, (unsigned int *)addr);
6074 + err |= get_user(bv, (unsigned int *)(addr+4));
6075 + err |= get_user(ldw2, (unsigned int *)(addr+8));
6076 +
6077 + if (err)
6078 + break;
6079 +
6080 + if (ldw == 0x0E801096U &&
6081 + bv == 0xEAC0C000U &&
6082 + ldw2 == 0x0E881095U)
6083 + {
6084 + unsigned int resolver, map;
6085 +
6086 + err = get_user(resolver, (unsigned int *)(instruction_pointer(regs)+8));
6087 + err |= get_user(map, (unsigned int *)(instruction_pointer(regs)+12));
6088 + if (err)
6089 + break;
6090 +
6091 + regs->gr[20] = instruction_pointer(regs)+8;
6092 + regs->gr[21] = map;
6093 + regs->gr[22] = resolver;
6094 + regs->iaoq[0] = resolver | 3UL;
6095 + regs->iaoq[1] = regs->iaoq[0] + 4;
6096 + return 3;
6097 + }
6098 + }
6099 + } while (0);
6100 +#endif
6101 +
6102 +#ifdef CONFIG_PAX_EMUTRAMP
6103 +
6104 +#ifndef CONFIG_PAX_EMUSIGRT
6105 + if (!(current->mm->pax_flags & MF_PAX_EMUTRAMP))
6106 + return 1;
6107 +#endif
6108 +
6109 + do { /* PaX: rt_sigreturn emulation */
6110 + unsigned int ldi1, ldi2, bel, nop;
6111 +
6112 + err = get_user(ldi1, (unsigned int *)instruction_pointer(regs));
6113 + err |= get_user(ldi2, (unsigned int *)(instruction_pointer(regs)+4));
6114 + err |= get_user(bel, (unsigned int *)(instruction_pointer(regs)+8));
6115 + err |= get_user(nop, (unsigned int *)(instruction_pointer(regs)+12));
6116 +
6117 + if (err)
6118 + break;
6119 +
6120 + if ((ldi1 == 0x34190000U || ldi1 == 0x34190002U) &&
6121 + ldi2 == 0x3414015AU &&
6122 + bel == 0xE4008200U &&
6123 + nop == 0x08000240U)
6124 + {
6125 + regs->gr[25] = (ldi1 & 2) >> 1;
6126 + regs->gr[20] = __NR_rt_sigreturn;
6127 + regs->gr[31] = regs->iaoq[1] + 16;
6128 + regs->sr[0] = regs->iasq[1];
6129 + regs->iaoq[0] = 0x100UL;
6130 + regs->iaoq[1] = regs->iaoq[0] + 4;
6131 + regs->iasq[0] = regs->sr[2];
6132 + regs->iasq[1] = regs->sr[2];
6133 + return 2;
6134 + }
6135 + } while (0);
6136 +#endif
6137 +
6138 + return 1;
6139 +}
6140 +
6141 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
6142 +{
6143 + unsigned long i;
6144 +
6145 + printk(KERN_ERR "PAX: bytes at PC: ");
6146 + for (i = 0; i < 5; i++) {
6147 + unsigned int c;
6148 + if (get_user(c, (unsigned int *)pc+i))
6149 + printk(KERN_CONT "???????? ");
6150 + else
6151 + printk(KERN_CONT "%08x ", c);
6152 + }
6153 + printk("\n");
6154 +}
6155 +#endif
6156 +
6157 int fixup_exception(struct pt_regs *regs)
6158 {
6159 const struct exception_table_entry *fix;
6160 @@ -192,8 +303,33 @@ good_area:
6161
6162 acc_type = parisc_acctyp(code,regs->iir);
6163
6164 - if ((vma->vm_flags & acc_type) != acc_type)
6165 + if ((vma->vm_flags & acc_type) != acc_type) {
6166 +
6167 +#ifdef CONFIG_PAX_PAGEEXEC
6168 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && (acc_type & VM_EXEC) &&
6169 + (address & ~3UL) == instruction_pointer(regs))
6170 + {
6171 + up_read(&mm->mmap_sem);
6172 + switch (pax_handle_fetch_fault(regs)) {
6173 +
6174 +#ifdef CONFIG_PAX_EMUPLT
6175 + case 3:
6176 + return;
6177 +#endif
6178 +
6179 +#ifdef CONFIG_PAX_EMUTRAMP
6180 + case 2:
6181 + return;
6182 +#endif
6183 +
6184 + }
6185 + pax_report_fault(regs, (void *)instruction_pointer(regs), (void *)regs->gr[30]);
6186 + do_group_exit(SIGKILL);
6187 + }
6188 +#endif
6189 +
6190 goto bad_area;
6191 + }
6192
6193 /*
6194 * If for any reason at all we couldn't handle the fault, make
6195 diff --git a/arch/powerpc/include/asm/atomic.h b/arch/powerpc/include/asm/atomic.h
6196 index e3b1d41..8e81edf 100644
6197 --- a/arch/powerpc/include/asm/atomic.h
6198 +++ b/arch/powerpc/include/asm/atomic.h
6199 @@ -523,6 +523,16 @@ static __inline__ long atomic64_inc_not_zero(atomic64_t *v)
6200 return t1;
6201 }
6202
6203 +#define atomic64_read_unchecked(v) atomic64_read(v)
6204 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
6205 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
6206 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
6207 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
6208 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
6209 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
6210 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
6211 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
6212 +
6213 #endif /* __powerpc64__ */
6214
6215 #endif /* __KERNEL__ */
6216 diff --git a/arch/powerpc/include/asm/cache.h b/arch/powerpc/include/asm/cache.h
6217 index 9e495c9..b6878e5 100644
6218 --- a/arch/powerpc/include/asm/cache.h
6219 +++ b/arch/powerpc/include/asm/cache.h
6220 @@ -3,6 +3,7 @@
6221
6222 #ifdef __KERNEL__
6223
6224 +#include <linux/const.h>
6225
6226 /* bytes per L1 cache line */
6227 #if defined(CONFIG_8xx) || defined(CONFIG_403GCX)
6228 @@ -22,7 +23,7 @@
6229 #define L1_CACHE_SHIFT 7
6230 #endif
6231
6232 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
6233 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
6234
6235 #define SMP_CACHE_BYTES L1_CACHE_BYTES
6236
6237 diff --git a/arch/powerpc/include/asm/elf.h b/arch/powerpc/include/asm/elf.h
6238 index 6abf0a1..459d0f1 100644
6239 --- a/arch/powerpc/include/asm/elf.h
6240 +++ b/arch/powerpc/include/asm/elf.h
6241 @@ -28,8 +28,19 @@
6242 the loader. We need to make sure that it is out of the way of the program
6243 that it will "exec", and that there is sufficient room for the brk. */
6244
6245 -extern unsigned long randomize_et_dyn(unsigned long base);
6246 -#define ELF_ET_DYN_BASE (randomize_et_dyn(0x20000000))
6247 +#define ELF_ET_DYN_BASE (0x20000000)
6248 +
6249 +#ifdef CONFIG_PAX_ASLR
6250 +#define PAX_ELF_ET_DYN_BASE (0x10000000UL)
6251 +
6252 +#ifdef __powerpc64__
6253 +#define PAX_DELTA_MMAP_LEN (is_32bit_task() ? 16 : 28)
6254 +#define PAX_DELTA_STACK_LEN (is_32bit_task() ? 16 : 28)
6255 +#else
6256 +#define PAX_DELTA_MMAP_LEN 15
6257 +#define PAX_DELTA_STACK_LEN 15
6258 +#endif
6259 +#endif
6260
6261 /*
6262 * Our registers are always unsigned longs, whether we're a 32 bit
6263 @@ -124,10 +135,6 @@ extern int arch_setup_additional_pages(struct linux_binprm *bprm,
6264 (0x7ff >> (PAGE_SHIFT - 12)) : \
6265 (0x3ffff >> (PAGE_SHIFT - 12)))
6266
6267 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
6268 -#define arch_randomize_brk arch_randomize_brk
6269 -
6270 -
6271 #ifdef CONFIG_SPU_BASE
6272 /* Notes used in ET_CORE. Note name is "SPU/<fd>/<filename>". */
6273 #define NT_SPU 1
6274 diff --git a/arch/powerpc/include/asm/exec.h b/arch/powerpc/include/asm/exec.h
6275 index 8196e9c..d83a9f3 100644
6276 --- a/arch/powerpc/include/asm/exec.h
6277 +++ b/arch/powerpc/include/asm/exec.h
6278 @@ -4,6 +4,6 @@
6279 #ifndef _ASM_POWERPC_EXEC_H
6280 #define _ASM_POWERPC_EXEC_H
6281
6282 -extern unsigned long arch_align_stack(unsigned long sp);
6283 +#define arch_align_stack(x) ((x) & ~0xfUL)
6284
6285 #endif /* _ASM_POWERPC_EXEC_H */
6286 diff --git a/arch/powerpc/include/asm/kmap_types.h b/arch/powerpc/include/asm/kmap_types.h
6287 index 5acabbd..7ea14fa 100644
6288 --- a/arch/powerpc/include/asm/kmap_types.h
6289 +++ b/arch/powerpc/include/asm/kmap_types.h
6290 @@ -10,7 +10,7 @@
6291 * 2 of the License, or (at your option) any later version.
6292 */
6293
6294 -#define KM_TYPE_NR 16
6295 +#define KM_TYPE_NR 17
6296
6297 #endif /* __KERNEL__ */
6298 #endif /* _ASM_POWERPC_KMAP_TYPES_H */
6299 diff --git a/arch/powerpc/include/asm/mman.h b/arch/powerpc/include/asm/mman.h
6300 index 8565c25..2865190 100644
6301 --- a/arch/powerpc/include/asm/mman.h
6302 +++ b/arch/powerpc/include/asm/mman.h
6303 @@ -24,7 +24,7 @@ static inline unsigned long arch_calc_vm_prot_bits(unsigned long prot)
6304 }
6305 #define arch_calc_vm_prot_bits(prot) arch_calc_vm_prot_bits(prot)
6306
6307 -static inline pgprot_t arch_vm_get_page_prot(unsigned long vm_flags)
6308 +static inline pgprot_t arch_vm_get_page_prot(vm_flags_t vm_flags)
6309 {
6310 return (vm_flags & VM_SAO) ? __pgprot(_PAGE_SAO) : __pgprot(0);
6311 }
6312 diff --git a/arch/powerpc/include/asm/page.h b/arch/powerpc/include/asm/page.h
6313 index f072e97..b436dee 100644
6314 --- a/arch/powerpc/include/asm/page.h
6315 +++ b/arch/powerpc/include/asm/page.h
6316 @@ -220,8 +220,9 @@ extern long long virt_phys_offset;
6317 * and needs to be executable. This means the whole heap ends
6318 * up being executable.
6319 */
6320 -#define VM_DATA_DEFAULT_FLAGS32 (VM_READ | VM_WRITE | VM_EXEC | \
6321 - VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
6322 +#define VM_DATA_DEFAULT_FLAGS32 \
6323 + (((current->personality & READ_IMPLIES_EXEC) ? VM_EXEC : 0) | \
6324 + VM_READ | VM_WRITE | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
6325
6326 #define VM_DATA_DEFAULT_FLAGS64 (VM_READ | VM_WRITE | \
6327 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
6328 @@ -249,6 +250,9 @@ extern long long virt_phys_offset;
6329 #define is_kernel_addr(x) ((x) >= PAGE_OFFSET)
6330 #endif
6331
6332 +#define ktla_ktva(addr) (addr)
6333 +#define ktva_ktla(addr) (addr)
6334 +
6335 /*
6336 * Use the top bit of the higher-level page table entries to indicate whether
6337 * the entries we point to contain hugepages. This works because we know that
6338 diff --git a/arch/powerpc/include/asm/page_64.h b/arch/powerpc/include/asm/page_64.h
6339 index cd915d6..c10cee8 100644
6340 --- a/arch/powerpc/include/asm/page_64.h
6341 +++ b/arch/powerpc/include/asm/page_64.h
6342 @@ -154,15 +154,18 @@ do { \
6343 * stack by default, so in the absence of a PT_GNU_STACK program header
6344 * we turn execute permission off.
6345 */
6346 -#define VM_STACK_DEFAULT_FLAGS32 (VM_READ | VM_WRITE | VM_EXEC | \
6347 - VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
6348 +#define VM_STACK_DEFAULT_FLAGS32 \
6349 + (((current->personality & READ_IMPLIES_EXEC) ? VM_EXEC : 0) | \
6350 + VM_READ | VM_WRITE | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
6351
6352 #define VM_STACK_DEFAULT_FLAGS64 (VM_READ | VM_WRITE | \
6353 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
6354
6355 +#ifndef CONFIG_PAX_PAGEEXEC
6356 #define VM_STACK_DEFAULT_FLAGS \
6357 (is_32bit_task() ? \
6358 VM_STACK_DEFAULT_FLAGS32 : VM_STACK_DEFAULT_FLAGS64)
6359 +#endif
6360
6361 #include <asm-generic/getorder.h>
6362
6363 diff --git a/arch/powerpc/include/asm/pgalloc-64.h b/arch/powerpc/include/asm/pgalloc-64.h
6364 index 292725c..f87ae14 100644
6365 --- a/arch/powerpc/include/asm/pgalloc-64.h
6366 +++ b/arch/powerpc/include/asm/pgalloc-64.h
6367 @@ -50,6 +50,7 @@ static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd)
6368 #ifndef CONFIG_PPC_64K_PAGES
6369
6370 #define pgd_populate(MM, PGD, PUD) pgd_set(PGD, PUD)
6371 +#define pgd_populate_kernel(MM, PGD, PUD) pgd_populate((MM), (PGD), (PUD))
6372
6373 static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr)
6374 {
6375 @@ -67,6 +68,11 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
6376 pud_set(pud, (unsigned long)pmd);
6377 }
6378
6379 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
6380 +{
6381 + pud_populate(mm, pud, pmd);
6382 +}
6383 +
6384 #define pmd_populate(mm, pmd, pte_page) \
6385 pmd_populate_kernel(mm, pmd, page_address(pte_page))
6386 #define pmd_populate_kernel(mm, pmd, pte) pmd_set(pmd, (unsigned long)(pte))
6387 @@ -76,6 +82,7 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
6388 #else /* CONFIG_PPC_64K_PAGES */
6389
6390 #define pud_populate(mm, pud, pmd) pud_set(pud, (unsigned long)pmd)
6391 +#define pud_populate_kernel(mm, pud, pmd) pud_populate((mm), (pud), (pmd))
6392
6393 static inline void pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmd,
6394 pte_t *pte)
6395 diff --git a/arch/powerpc/include/asm/pgtable.h b/arch/powerpc/include/asm/pgtable.h
6396 index a9cbd3b..3b67efa 100644
6397 --- a/arch/powerpc/include/asm/pgtable.h
6398 +++ b/arch/powerpc/include/asm/pgtable.h
6399 @@ -2,6 +2,7 @@
6400 #define _ASM_POWERPC_PGTABLE_H
6401 #ifdef __KERNEL__
6402
6403 +#include <linux/const.h>
6404 #ifndef __ASSEMBLY__
6405 #include <asm/processor.h> /* For TASK_SIZE */
6406 #include <asm/mmu.h>
6407 diff --git a/arch/powerpc/include/asm/pte-hash32.h b/arch/powerpc/include/asm/pte-hash32.h
6408 index 4aad413..85d86bf 100644
6409 --- a/arch/powerpc/include/asm/pte-hash32.h
6410 +++ b/arch/powerpc/include/asm/pte-hash32.h
6411 @@ -21,6 +21,7 @@
6412 #define _PAGE_FILE 0x004 /* when !present: nonlinear file mapping */
6413 #define _PAGE_USER 0x004 /* usermode access allowed */
6414 #define _PAGE_GUARDED 0x008 /* G: prohibit speculative access */
6415 +#define _PAGE_EXEC _PAGE_GUARDED
6416 #define _PAGE_COHERENT 0x010 /* M: enforce memory coherence (SMP systems) */
6417 #define _PAGE_NO_CACHE 0x020 /* I: cache inhibit */
6418 #define _PAGE_WRITETHRU 0x040 /* W: cache write-through */
6419 diff --git a/arch/powerpc/include/asm/reg.h b/arch/powerpc/include/asm/reg.h
6420 index 3d5c9dc..62f8414 100644
6421 --- a/arch/powerpc/include/asm/reg.h
6422 +++ b/arch/powerpc/include/asm/reg.h
6423 @@ -215,6 +215,7 @@
6424 #define SPRN_DBCR 0x136 /* e300 Data Breakpoint Control Reg */
6425 #define SPRN_DSISR 0x012 /* Data Storage Interrupt Status Register */
6426 #define DSISR_NOHPTE 0x40000000 /* no translation found */
6427 +#define DSISR_GUARDED 0x10000000 /* fetch from guarded storage */
6428 #define DSISR_PROTFAULT 0x08000000 /* protection fault */
6429 #define DSISR_ISSTORE 0x02000000 /* access was a store */
6430 #define DSISR_DABRMATCH 0x00400000 /* hit data breakpoint */
6431 diff --git a/arch/powerpc/include/asm/thread_info.h b/arch/powerpc/include/asm/thread_info.h
6432 index 406b7b9..af63426 100644
6433 --- a/arch/powerpc/include/asm/thread_info.h
6434 +++ b/arch/powerpc/include/asm/thread_info.h
6435 @@ -97,7 +97,6 @@ static inline struct thread_info *current_thread_info(void)
6436 #define TIF_PERFMON_CTXSW 6 /* perfmon needs ctxsw calls */
6437 #define TIF_SYSCALL_AUDIT 7 /* syscall auditing active */
6438 #define TIF_SINGLESTEP 8 /* singlestepping active */
6439 -#define TIF_MEMDIE 9 /* is terminating due to OOM killer */
6440 #define TIF_SECCOMP 10 /* secure computing */
6441 #define TIF_RESTOREALL 11 /* Restore all regs (implies NOERROR) */
6442 #define TIF_NOERROR 12 /* Force successful syscall return */
6443 @@ -106,6 +105,9 @@ static inline struct thread_info *current_thread_info(void)
6444 #define TIF_SYSCALL_TRACEPOINT 15 /* syscall tracepoint instrumentation */
6445 #define TIF_EMULATE_STACK_STORE 16 /* Is an instruction emulation
6446 for stack store? */
6447 +#define TIF_MEMDIE 17 /* is terminating due to OOM killer */
6448 +/* mask must be expressable within 16 bits to satisfy 'andi' instruction reqs */
6449 +#define TIF_GRSEC_SETXID 9 /* update credentials on syscall entry/exit */
6450
6451 /* as above, but as bit values */
6452 #define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
6453 @@ -124,8 +126,10 @@ static inline struct thread_info *current_thread_info(void)
6454 #define _TIF_UPROBE (1<<TIF_UPROBE)
6455 #define _TIF_SYSCALL_TRACEPOINT (1<<TIF_SYSCALL_TRACEPOINT)
6456 #define _TIF_EMULATE_STACK_STORE (1<<TIF_EMULATE_STACK_STORE)
6457 +#define _TIF_GRSEC_SETXID (1<<TIF_GRSEC_SETXID)
6458 #define _TIF_SYSCALL_T_OR_A (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | \
6459 - _TIF_SECCOMP | _TIF_SYSCALL_TRACEPOINT)
6460 + _TIF_SECCOMP | _TIF_SYSCALL_TRACEPOINT | \
6461 + _TIF_GRSEC_SETXID)
6462
6463 #define _TIF_USER_WORK_MASK (_TIF_SIGPENDING | _TIF_NEED_RESCHED | \
6464 _TIF_NOTIFY_RESUME | _TIF_UPROBE)
6465 diff --git a/arch/powerpc/include/asm/uaccess.h b/arch/powerpc/include/asm/uaccess.h
6466 index 4db4959..335e00c 100644
6467 --- a/arch/powerpc/include/asm/uaccess.h
6468 +++ b/arch/powerpc/include/asm/uaccess.h
6469 @@ -13,6 +13,8 @@
6470 #define VERIFY_READ 0
6471 #define VERIFY_WRITE 1
6472
6473 +extern void check_object_size(const void *ptr, unsigned long n, bool to);
6474 +
6475 /*
6476 * The fs value determines whether argument validity checking should be
6477 * performed or not. If get_fs() == USER_DS, checking is performed, with
6478 @@ -318,52 +320,6 @@ do { \
6479 extern unsigned long __copy_tofrom_user(void __user *to,
6480 const void __user *from, unsigned long size);
6481
6482 -#ifndef __powerpc64__
6483 -
6484 -static inline unsigned long copy_from_user(void *to,
6485 - const void __user *from, unsigned long n)
6486 -{
6487 - unsigned long over;
6488 -
6489 - if (access_ok(VERIFY_READ, from, n))
6490 - return __copy_tofrom_user((__force void __user *)to, from, n);
6491 - if ((unsigned long)from < TASK_SIZE) {
6492 - over = (unsigned long)from + n - TASK_SIZE;
6493 - return __copy_tofrom_user((__force void __user *)to, from,
6494 - n - over) + over;
6495 - }
6496 - return n;
6497 -}
6498 -
6499 -static inline unsigned long copy_to_user(void __user *to,
6500 - const void *from, unsigned long n)
6501 -{
6502 - unsigned long over;
6503 -
6504 - if (access_ok(VERIFY_WRITE, to, n))
6505 - return __copy_tofrom_user(to, (__force void __user *)from, n);
6506 - if ((unsigned long)to < TASK_SIZE) {
6507 - over = (unsigned long)to + n - TASK_SIZE;
6508 - return __copy_tofrom_user(to, (__force void __user *)from,
6509 - n - over) + over;
6510 - }
6511 - return n;
6512 -}
6513 -
6514 -#else /* __powerpc64__ */
6515 -
6516 -#define __copy_in_user(to, from, size) \
6517 - __copy_tofrom_user((to), (from), (size))
6518 -
6519 -extern unsigned long copy_from_user(void *to, const void __user *from,
6520 - unsigned long n);
6521 -extern unsigned long copy_to_user(void __user *to, const void *from,
6522 - unsigned long n);
6523 -extern unsigned long copy_in_user(void __user *to, const void __user *from,
6524 - unsigned long n);
6525 -
6526 -#endif /* __powerpc64__ */
6527 -
6528 static inline unsigned long __copy_from_user_inatomic(void *to,
6529 const void __user *from, unsigned long n)
6530 {
6531 @@ -387,6 +343,10 @@ static inline unsigned long __copy_from_user_inatomic(void *to,
6532 if (ret == 0)
6533 return 0;
6534 }
6535 +
6536 + if (!__builtin_constant_p(n))
6537 + check_object_size(to, n, false);
6538 +
6539 return __copy_tofrom_user((__force void __user *)to, from, n);
6540 }
6541
6542 @@ -413,6 +373,10 @@ static inline unsigned long __copy_to_user_inatomic(void __user *to,
6543 if (ret == 0)
6544 return 0;
6545 }
6546 +
6547 + if (!__builtin_constant_p(n))
6548 + check_object_size(from, n, true);
6549 +
6550 return __copy_tofrom_user(to, (__force const void __user *)from, n);
6551 }
6552
6553 @@ -430,6 +394,92 @@ static inline unsigned long __copy_to_user(void __user *to,
6554 return __copy_to_user_inatomic(to, from, size);
6555 }
6556
6557 +#ifndef __powerpc64__
6558 +
6559 +static inline unsigned long __must_check copy_from_user(void *to,
6560 + const void __user *from, unsigned long n)
6561 +{
6562 + unsigned long over;
6563 +
6564 + if ((long)n < 0)
6565 + return n;
6566 +
6567 + if (access_ok(VERIFY_READ, from, n)) {
6568 + if (!__builtin_constant_p(n))
6569 + check_object_size(to, n, false);
6570 + return __copy_tofrom_user((__force void __user *)to, from, n);
6571 + }
6572 + if ((unsigned long)from < TASK_SIZE) {
6573 + over = (unsigned long)from + n - TASK_SIZE;
6574 + if (!__builtin_constant_p(n - over))
6575 + check_object_size(to, n - over, false);
6576 + return __copy_tofrom_user((__force void __user *)to, from,
6577 + n - over) + over;
6578 + }
6579 + return n;
6580 +}
6581 +
6582 +static inline unsigned long __must_check copy_to_user(void __user *to,
6583 + const void *from, unsigned long n)
6584 +{
6585 + unsigned long over;
6586 +
6587 + if ((long)n < 0)
6588 + return n;
6589 +
6590 + if (access_ok(VERIFY_WRITE, to, n)) {
6591 + if (!__builtin_constant_p(n))
6592 + check_object_size(from, n, true);
6593 + return __copy_tofrom_user(to, (__force void __user *)from, n);
6594 + }
6595 + if ((unsigned long)to < TASK_SIZE) {
6596 + over = (unsigned long)to + n - TASK_SIZE;
6597 + if (!__builtin_constant_p(n))
6598 + check_object_size(from, n - over, true);
6599 + return __copy_tofrom_user(to, (__force void __user *)from,
6600 + n - over) + over;
6601 + }
6602 + return n;
6603 +}
6604 +
6605 +#else /* __powerpc64__ */
6606 +
6607 +#define __copy_in_user(to, from, size) \
6608 + __copy_tofrom_user((to), (from), (size))
6609 +
6610 +static inline unsigned long __must_check copy_from_user(void *to, const void __user *from, unsigned long n)
6611 +{
6612 + if ((long)n < 0 || n > INT_MAX)
6613 + return n;
6614 +
6615 + if (!__builtin_constant_p(n))
6616 + check_object_size(to, n, false);
6617 +
6618 + if (likely(access_ok(VERIFY_READ, from, n)))
6619 + n = __copy_from_user(to, from, n);
6620 + else
6621 + memset(to, 0, n);
6622 + return n;
6623 +}
6624 +
6625 +static inline unsigned long __must_check copy_to_user(void __user *to, const void *from, unsigned long n)
6626 +{
6627 + if ((long)n < 0 || n > INT_MAX)
6628 + return n;
6629 +
6630 + if (likely(access_ok(VERIFY_WRITE, to, n))) {
6631 + if (!__builtin_constant_p(n))
6632 + check_object_size(from, n, true);
6633 + n = __copy_to_user(to, from, n);
6634 + }
6635 + return n;
6636 +}
6637 +
6638 +extern unsigned long copy_in_user(void __user *to, const void __user *from,
6639 + unsigned long n);
6640 +
6641 +#endif /* __powerpc64__ */
6642 +
6643 extern unsigned long __clear_user(void __user *addr, unsigned long size);
6644
6645 static inline unsigned long clear_user(void __user *addr, unsigned long size)
6646 diff --git a/arch/powerpc/kernel/exceptions-64e.S b/arch/powerpc/kernel/exceptions-64e.S
6647 index 4684e33..acc4d19e 100644
6648 --- a/arch/powerpc/kernel/exceptions-64e.S
6649 +++ b/arch/powerpc/kernel/exceptions-64e.S
6650 @@ -715,6 +715,7 @@ storage_fault_common:
6651 std r14,_DAR(r1)
6652 std r15,_DSISR(r1)
6653 addi r3,r1,STACK_FRAME_OVERHEAD
6654 + bl .save_nvgprs
6655 mr r4,r14
6656 mr r5,r15
6657 ld r14,PACA_EXGEN+EX_R14(r13)
6658 @@ -723,8 +724,7 @@ storage_fault_common:
6659 cmpdi r3,0
6660 bne- 1f
6661 b .ret_from_except_lite
6662 -1: bl .save_nvgprs
6663 - mr r5,r3
6664 +1: mr r5,r3
6665 addi r3,r1,STACK_FRAME_OVERHEAD
6666 ld r4,_DAR(r1)
6667 bl .bad_page_fault
6668 diff --git a/arch/powerpc/kernel/exceptions-64s.S b/arch/powerpc/kernel/exceptions-64s.S
6669 index 3684cbd..bc89eab 100644
6670 --- a/arch/powerpc/kernel/exceptions-64s.S
6671 +++ b/arch/powerpc/kernel/exceptions-64s.S
6672 @@ -1206,10 +1206,10 @@ handle_page_fault:
6673 11: ld r4,_DAR(r1)
6674 ld r5,_DSISR(r1)
6675 addi r3,r1,STACK_FRAME_OVERHEAD
6676 + bl .save_nvgprs
6677 bl .do_page_fault
6678 cmpdi r3,0
6679 beq+ 12f
6680 - bl .save_nvgprs
6681 mr r5,r3
6682 addi r3,r1,STACK_FRAME_OVERHEAD
6683 lwz r4,_DAR(r1)
6684 diff --git a/arch/powerpc/kernel/module_32.c b/arch/powerpc/kernel/module_32.c
6685 index 2e3200c..72095ce 100644
6686 --- a/arch/powerpc/kernel/module_32.c
6687 +++ b/arch/powerpc/kernel/module_32.c
6688 @@ -162,7 +162,7 @@ int module_frob_arch_sections(Elf32_Ehdr *hdr,
6689 me->arch.core_plt_section = i;
6690 }
6691 if (!me->arch.core_plt_section || !me->arch.init_plt_section) {
6692 - printk("Module doesn't contain .plt or .init.plt sections.\n");
6693 + printk("Module %s doesn't contain .plt or .init.plt sections.\n", me->name);
6694 return -ENOEXEC;
6695 }
6696
6697 @@ -192,11 +192,16 @@ static uint32_t do_plt_call(void *location,
6698
6699 DEBUGP("Doing plt for call to 0x%x at 0x%x\n", val, (unsigned int)location);
6700 /* Init, or core PLT? */
6701 - if (location >= mod->module_core
6702 - && location < mod->module_core + mod->core_size)
6703 + if ((location >= mod->module_core_rx && location < mod->module_core_rx + mod->core_size_rx) ||
6704 + (location >= mod->module_core_rw && location < mod->module_core_rw + mod->core_size_rw))
6705 entry = (void *)sechdrs[mod->arch.core_plt_section].sh_addr;
6706 - else
6707 + else if ((location >= mod->module_init_rx && location < mod->module_init_rx + mod->init_size_rx) ||
6708 + (location >= mod->module_init_rw && location < mod->module_init_rw + mod->init_size_rw))
6709 entry = (void *)sechdrs[mod->arch.init_plt_section].sh_addr;
6710 + else {
6711 + printk(KERN_ERR "%s: invalid R_PPC_REL24 entry found\n", mod->name);
6712 + return ~0UL;
6713 + }
6714
6715 /* Find this entry, or if that fails, the next avail. entry */
6716 while (entry->jump[0]) {
6717 diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c
6718 index 8143067..21ae55b 100644
6719 --- a/arch/powerpc/kernel/process.c
6720 +++ b/arch/powerpc/kernel/process.c
6721 @@ -680,8 +680,8 @@ void show_regs(struct pt_regs * regs)
6722 * Lookup NIP late so we have the best change of getting the
6723 * above info out without failing
6724 */
6725 - printk("NIP ["REG"] %pS\n", regs->nip, (void *)regs->nip);
6726 - printk("LR ["REG"] %pS\n", regs->link, (void *)regs->link);
6727 + printk("NIP ["REG"] %pA\n", regs->nip, (void *)regs->nip);
6728 + printk("LR ["REG"] %pA\n", regs->link, (void *)regs->link);
6729 #endif
6730 show_stack(current, (unsigned long *) regs->gpr[1]);
6731 if (!user_mode(regs))
6732 @@ -1129,10 +1129,10 @@ void show_stack(struct task_struct *tsk, unsigned long *stack)
6733 newsp = stack[0];
6734 ip = stack[STACK_FRAME_LR_SAVE];
6735 if (!firstframe || ip != lr) {
6736 - printk("["REG"] ["REG"] %pS", sp, ip, (void *)ip);
6737 + printk("["REG"] ["REG"] %pA", sp, ip, (void *)ip);
6738 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
6739 if ((ip == rth || ip == mrth) && curr_frame >= 0) {
6740 - printk(" (%pS)",
6741 + printk(" (%pA)",
6742 (void *)current->ret_stack[curr_frame].ret);
6743 curr_frame--;
6744 }
6745 @@ -1152,7 +1152,7 @@ void show_stack(struct task_struct *tsk, unsigned long *stack)
6746 struct pt_regs *regs = (struct pt_regs *)
6747 (sp + STACK_FRAME_OVERHEAD);
6748 lr = regs->link;
6749 - printk("--- Exception: %lx at %pS\n LR = %pS\n",
6750 + printk("--- Exception: %lx at %pA\n LR = %pA\n",
6751 regs->trap, (void *)regs->nip, (void *)lr);
6752 firstframe = 1;
6753 }
6754 @@ -1194,58 +1194,3 @@ void __ppc64_runlatch_off(void)
6755 mtspr(SPRN_CTRLT, ctrl);
6756 }
6757 #endif /* CONFIG_PPC64 */
6758 -
6759 -unsigned long arch_align_stack(unsigned long sp)
6760 -{
6761 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
6762 - sp -= get_random_int() & ~PAGE_MASK;
6763 - return sp & ~0xf;
6764 -}
6765 -
6766 -static inline unsigned long brk_rnd(void)
6767 -{
6768 - unsigned long rnd = 0;
6769 -
6770 - /* 8MB for 32bit, 1GB for 64bit */
6771 - if (is_32bit_task())
6772 - rnd = (long)(get_random_int() % (1<<(23-PAGE_SHIFT)));
6773 - else
6774 - rnd = (long)(get_random_int() % (1<<(30-PAGE_SHIFT)));
6775 -
6776 - return rnd << PAGE_SHIFT;
6777 -}
6778 -
6779 -unsigned long arch_randomize_brk(struct mm_struct *mm)
6780 -{
6781 - unsigned long base = mm->brk;
6782 - unsigned long ret;
6783 -
6784 -#ifdef CONFIG_PPC_STD_MMU_64
6785 - /*
6786 - * If we are using 1TB segments and we are allowed to randomise
6787 - * the heap, we can put it above 1TB so it is backed by a 1TB
6788 - * segment. Otherwise the heap will be in the bottom 1TB
6789 - * which always uses 256MB segments and this may result in a
6790 - * performance penalty.
6791 - */
6792 - if (!is_32bit_task() && (mmu_highuser_ssize == MMU_SEGSIZE_1T))
6793 - base = max_t(unsigned long, mm->brk, 1UL << SID_SHIFT_1T);
6794 -#endif
6795 -
6796 - ret = PAGE_ALIGN(base + brk_rnd());
6797 -
6798 - if (ret < mm->brk)
6799 - return mm->brk;
6800 -
6801 - return ret;
6802 -}
6803 -
6804 -unsigned long randomize_et_dyn(unsigned long base)
6805 -{
6806 - unsigned long ret = PAGE_ALIGN(base + brk_rnd());
6807 -
6808 - if (ret < base)
6809 - return base;
6810 -
6811 - return ret;
6812 -}
6813 diff --git a/arch/powerpc/kernel/ptrace.c b/arch/powerpc/kernel/ptrace.c
6814 index c497000..8fde506 100644
6815 --- a/arch/powerpc/kernel/ptrace.c
6816 +++ b/arch/powerpc/kernel/ptrace.c
6817 @@ -1737,6 +1737,10 @@ long arch_ptrace(struct task_struct *child, long request,
6818 return ret;
6819 }
6820
6821 +#ifdef CONFIG_GRKERNSEC_SETXID
6822 +extern void gr_delayed_cred_worker(void);
6823 +#endif
6824 +
6825 /*
6826 * We must return the syscall number to actually look up in the table.
6827 * This can be -1L to skip running any syscall at all.
6828 @@ -1747,6 +1751,11 @@ long do_syscall_trace_enter(struct pt_regs *regs)
6829
6830 secure_computing_strict(regs->gpr[0]);
6831
6832 +#ifdef CONFIG_GRKERNSEC_SETXID
6833 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
6834 + gr_delayed_cred_worker();
6835 +#endif
6836 +
6837 if (test_thread_flag(TIF_SYSCALL_TRACE) &&
6838 tracehook_report_syscall_entry(regs))
6839 /*
6840 @@ -1781,6 +1790,11 @@ void do_syscall_trace_leave(struct pt_regs *regs)
6841 {
6842 int step;
6843
6844 +#ifdef CONFIG_GRKERNSEC_SETXID
6845 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
6846 + gr_delayed_cred_worker();
6847 +#endif
6848 +
6849 audit_syscall_exit(regs);
6850
6851 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
6852 diff --git a/arch/powerpc/kernel/signal_32.c b/arch/powerpc/kernel/signal_32.c
6853 index 804e323..79181c1 100644
6854 --- a/arch/powerpc/kernel/signal_32.c
6855 +++ b/arch/powerpc/kernel/signal_32.c
6856 @@ -851,7 +851,7 @@ int handle_rt_signal32(unsigned long sig, struct k_sigaction *ka,
6857 /* Save user registers on the stack */
6858 frame = &rt_sf->uc.uc_mcontext;
6859 addr = frame;
6860 - if (vdso32_rt_sigtramp && current->mm->context.vdso_base) {
6861 + if (vdso32_rt_sigtramp && current->mm->context.vdso_base != ~0UL) {
6862 if (save_user_regs(regs, frame, 0, 1))
6863 goto badframe;
6864 regs->link = current->mm->context.vdso_base + vdso32_rt_sigtramp;
6865 diff --git a/arch/powerpc/kernel/signal_64.c b/arch/powerpc/kernel/signal_64.c
6866 index 1ca045d..139c3f7 100644
6867 --- a/arch/powerpc/kernel/signal_64.c
6868 +++ b/arch/powerpc/kernel/signal_64.c
6869 @@ -430,7 +430,7 @@ int handle_rt_signal64(int signr, struct k_sigaction *ka, siginfo_t *info,
6870 current->thread.fpscr.val = 0;
6871
6872 /* Set up to return from userspace. */
6873 - if (vdso64_rt_sigtramp && current->mm->context.vdso_base) {
6874 + if (vdso64_rt_sigtramp && current->mm->context.vdso_base != ~0UL) {
6875 regs->link = current->mm->context.vdso_base + vdso64_rt_sigtramp;
6876 } else {
6877 err |= setup_trampoline(__NR_rt_sigreturn, &frame->tramp[0]);
6878 diff --git a/arch/powerpc/kernel/sysfs.c b/arch/powerpc/kernel/sysfs.c
6879 index 3ce1f86..c30e629 100644
6880 --- a/arch/powerpc/kernel/sysfs.c
6881 +++ b/arch/powerpc/kernel/sysfs.c
6882 @@ -522,7 +522,7 @@ static int __cpuinit sysfs_cpu_notify(struct notifier_block *self,
6883 return NOTIFY_OK;
6884 }
6885
6886 -static struct notifier_block __cpuinitdata sysfs_cpu_nb = {
6887 +static struct notifier_block sysfs_cpu_nb = {
6888 .notifier_call = sysfs_cpu_notify,
6889 };
6890
6891 diff --git a/arch/powerpc/kernel/traps.c b/arch/powerpc/kernel/traps.c
6892 index 3251840..3f7c77a 100644
6893 --- a/arch/powerpc/kernel/traps.c
6894 +++ b/arch/powerpc/kernel/traps.c
6895 @@ -133,6 +133,8 @@ static unsigned __kprobes long oops_begin(struct pt_regs *regs)
6896 return flags;
6897 }
6898
6899 +extern void gr_handle_kernel_exploit(void);
6900 +
6901 static void __kprobes oops_end(unsigned long flags, struct pt_regs *regs,
6902 int signr)
6903 {
6904 @@ -182,6 +184,9 @@ static void __kprobes oops_end(unsigned long flags, struct pt_regs *regs,
6905 panic("Fatal exception in interrupt");
6906 if (panic_on_oops)
6907 panic("Fatal exception");
6908 +
6909 + gr_handle_kernel_exploit();
6910 +
6911 do_exit(signr);
6912 }
6913
6914 diff --git a/arch/powerpc/kernel/vdso.c b/arch/powerpc/kernel/vdso.c
6915 index 1b2076f..835e4be 100644
6916 --- a/arch/powerpc/kernel/vdso.c
6917 +++ b/arch/powerpc/kernel/vdso.c
6918 @@ -34,6 +34,7 @@
6919 #include <asm/firmware.h>
6920 #include <asm/vdso.h>
6921 #include <asm/vdso_datapage.h>
6922 +#include <asm/mman.h>
6923
6924 #include "setup.h"
6925
6926 @@ -218,7 +219,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
6927 vdso_base = VDSO32_MBASE;
6928 #endif
6929
6930 - current->mm->context.vdso_base = 0;
6931 + current->mm->context.vdso_base = ~0UL;
6932
6933 /* vDSO has a problem and was disabled, just don't "enable" it for the
6934 * process
6935 @@ -238,7 +239,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
6936 vdso_base = get_unmapped_area(NULL, vdso_base,
6937 (vdso_pages << PAGE_SHIFT) +
6938 ((VDSO_ALIGNMENT - 1) & PAGE_MASK),
6939 - 0, 0);
6940 + 0, MAP_PRIVATE | MAP_EXECUTABLE);
6941 if (IS_ERR_VALUE(vdso_base)) {
6942 rc = vdso_base;
6943 goto fail_mmapsem;
6944 diff --git a/arch/powerpc/lib/usercopy_64.c b/arch/powerpc/lib/usercopy_64.c
6945 index 5eea6f3..5d10396 100644
6946 --- a/arch/powerpc/lib/usercopy_64.c
6947 +++ b/arch/powerpc/lib/usercopy_64.c
6948 @@ -9,22 +9,6 @@
6949 #include <linux/module.h>
6950 #include <asm/uaccess.h>
6951
6952 -unsigned long copy_from_user(void *to, const void __user *from, unsigned long n)
6953 -{
6954 - if (likely(access_ok(VERIFY_READ, from, n)))
6955 - n = __copy_from_user(to, from, n);
6956 - else
6957 - memset(to, 0, n);
6958 - return n;
6959 -}
6960 -
6961 -unsigned long copy_to_user(void __user *to, const void *from, unsigned long n)
6962 -{
6963 - if (likely(access_ok(VERIFY_WRITE, to, n)))
6964 - n = __copy_to_user(to, from, n);
6965 - return n;
6966 -}
6967 -
6968 unsigned long copy_in_user(void __user *to, const void __user *from,
6969 unsigned long n)
6970 {
6971 @@ -35,7 +19,5 @@ unsigned long copy_in_user(void __user *to, const void __user *from,
6972 return n;
6973 }
6974
6975 -EXPORT_SYMBOL(copy_from_user);
6976 -EXPORT_SYMBOL(copy_to_user);
6977 EXPORT_SYMBOL(copy_in_user);
6978
6979 diff --git a/arch/powerpc/mm/fault.c b/arch/powerpc/mm/fault.c
6980 index 3a8489a..6a63b3b 100644
6981 --- a/arch/powerpc/mm/fault.c
6982 +++ b/arch/powerpc/mm/fault.c
6983 @@ -32,6 +32,10 @@
6984 #include <linux/perf_event.h>
6985 #include <linux/magic.h>
6986 #include <linux/ratelimit.h>
6987 +#include <linux/slab.h>
6988 +#include <linux/pagemap.h>
6989 +#include <linux/compiler.h>
6990 +#include <linux/unistd.h>
6991
6992 #include <asm/firmware.h>
6993 #include <asm/page.h>
6994 @@ -68,6 +72,33 @@ static inline int notify_page_fault(struct pt_regs *regs)
6995 }
6996 #endif
6997
6998 +#ifdef CONFIG_PAX_PAGEEXEC
6999 +/*
7000 + * PaX: decide what to do with offenders (regs->nip = fault address)
7001 + *
7002 + * returns 1 when task should be killed
7003 + */
7004 +static int pax_handle_fetch_fault(struct pt_regs *regs)
7005 +{
7006 + return 1;
7007 +}
7008 +
7009 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
7010 +{
7011 + unsigned long i;
7012 +
7013 + printk(KERN_ERR "PAX: bytes at PC: ");
7014 + for (i = 0; i < 5; i++) {
7015 + unsigned int c;
7016 + if (get_user(c, (unsigned int __user *)pc+i))
7017 + printk(KERN_CONT "???????? ");
7018 + else
7019 + printk(KERN_CONT "%08x ", c);
7020 + }
7021 + printk("\n");
7022 +}
7023 +#endif
7024 +
7025 /*
7026 * Check whether the instruction at regs->nip is a store using
7027 * an update addressing form which will update r1.
7028 @@ -213,7 +244,7 @@ int __kprobes do_page_fault(struct pt_regs *regs, unsigned long address,
7029 * indicate errors in DSISR but can validly be set in SRR1.
7030 */
7031 if (trap == 0x400)
7032 - error_code &= 0x48200000;
7033 + error_code &= 0x58200000;
7034 else
7035 is_write = error_code & DSISR_ISSTORE;
7036 #else
7037 @@ -364,7 +395,7 @@ good_area:
7038 * "undefined". Of those that can be set, this is the only
7039 * one which seems bad.
7040 */
7041 - if (error_code & 0x10000000)
7042 + if (error_code & DSISR_GUARDED)
7043 /* Guarded storage error. */
7044 goto bad_area;
7045 #endif /* CONFIG_8xx */
7046 @@ -379,7 +410,7 @@ good_area:
7047 * processors use the same I/D cache coherency mechanism
7048 * as embedded.
7049 */
7050 - if (error_code & DSISR_PROTFAULT)
7051 + if (error_code & (DSISR_PROTFAULT | DSISR_GUARDED))
7052 goto bad_area;
7053 #endif /* CONFIG_PPC_STD_MMU */
7054
7055 @@ -462,6 +493,23 @@ bad_area:
7056 bad_area_nosemaphore:
7057 /* User mode accesses cause a SIGSEGV */
7058 if (user_mode(regs)) {
7059 +
7060 +#ifdef CONFIG_PAX_PAGEEXEC
7061 + if (mm->pax_flags & MF_PAX_PAGEEXEC) {
7062 +#ifdef CONFIG_PPC_STD_MMU
7063 + if (is_exec && (error_code & (DSISR_PROTFAULT | DSISR_GUARDED))) {
7064 +#else
7065 + if (is_exec && regs->nip == address) {
7066 +#endif
7067 + switch (pax_handle_fetch_fault(regs)) {
7068 + }
7069 +
7070 + pax_report_fault(regs, (void *)regs->nip, (void *)regs->gpr[PT_R1]);
7071 + do_group_exit(SIGKILL);
7072 + }
7073 + }
7074 +#endif
7075 +
7076 _exception(SIGSEGV, regs, code, address);
7077 return 0;
7078 }
7079 diff --git a/arch/powerpc/mm/mmap_64.c b/arch/powerpc/mm/mmap_64.c
7080 index 67a42ed..cd463e0 100644
7081 --- a/arch/powerpc/mm/mmap_64.c
7082 +++ b/arch/powerpc/mm/mmap_64.c
7083 @@ -57,6 +57,10 @@ static unsigned long mmap_rnd(void)
7084 {
7085 unsigned long rnd = 0;
7086
7087 +#ifdef CONFIG_PAX_RANDMMAP
7088 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
7089 +#endif
7090 +
7091 if (current->flags & PF_RANDOMIZE) {
7092 /* 8MB for 32bit, 1GB for 64bit */
7093 if (is_32bit_task())
7094 @@ -91,10 +95,22 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
7095 */
7096 if (mmap_is_legacy()) {
7097 mm->mmap_base = TASK_UNMAPPED_BASE;
7098 +
7099 +#ifdef CONFIG_PAX_RANDMMAP
7100 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7101 + mm->mmap_base += mm->delta_mmap;
7102 +#endif
7103 +
7104 mm->get_unmapped_area = arch_get_unmapped_area;
7105 mm->unmap_area = arch_unmap_area;
7106 } else {
7107 mm->mmap_base = mmap_base();
7108 +
7109 +#ifdef CONFIG_PAX_RANDMMAP
7110 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7111 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
7112 +#endif
7113 +
7114 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
7115 mm->unmap_area = arch_unmap_area_topdown;
7116 }
7117 diff --git a/arch/powerpc/mm/mmu_context_nohash.c b/arch/powerpc/mm/mmu_context_nohash.c
7118 index e779642..e5bb889 100644
7119 --- a/arch/powerpc/mm/mmu_context_nohash.c
7120 +++ b/arch/powerpc/mm/mmu_context_nohash.c
7121 @@ -363,7 +363,7 @@ static int __cpuinit mmu_context_cpu_notify(struct notifier_block *self,
7122 return NOTIFY_OK;
7123 }
7124
7125 -static struct notifier_block __cpuinitdata mmu_context_cpu_nb = {
7126 +static struct notifier_block mmu_context_cpu_nb = {
7127 .notifier_call = mmu_context_cpu_notify,
7128 };
7129
7130 diff --git a/arch/powerpc/mm/numa.c b/arch/powerpc/mm/numa.c
7131 index bba87ca..c346a33 100644
7132 --- a/arch/powerpc/mm/numa.c
7133 +++ b/arch/powerpc/mm/numa.c
7134 @@ -932,7 +932,7 @@ static void __init *careful_zallocation(int nid, unsigned long size,
7135 return ret;
7136 }
7137
7138 -static struct notifier_block __cpuinitdata ppc64_numa_nb = {
7139 +static struct notifier_block ppc64_numa_nb = {
7140 .notifier_call = cpu_numa_callback,
7141 .priority = 1 /* Must run before sched domains notifier. */
7142 };
7143 diff --git a/arch/powerpc/mm/slice.c b/arch/powerpc/mm/slice.c
7144 index cf9dada..241529f 100644
7145 --- a/arch/powerpc/mm/slice.c
7146 +++ b/arch/powerpc/mm/slice.c
7147 @@ -103,7 +103,7 @@ static int slice_area_is_free(struct mm_struct *mm, unsigned long addr,
7148 if ((mm->task_size - len) < addr)
7149 return 0;
7150 vma = find_vma(mm, addr);
7151 - return (!vma || (addr + len) <= vma->vm_start);
7152 + return check_heap_stack_gap(vma, addr, len, 0);
7153 }
7154
7155 static int slice_low_has_vma(struct mm_struct *mm, unsigned long slice)
7156 @@ -272,7 +272,7 @@ full_search:
7157 addr = _ALIGN_UP(addr + 1, 1ul << SLICE_HIGH_SHIFT);
7158 continue;
7159 }
7160 - if (!vma || addr + len <= vma->vm_start) {
7161 + if (check_heap_stack_gap(vma, addr, len, 0)) {
7162 /*
7163 * Remember the place where we stopped the search:
7164 */
7165 @@ -329,10 +329,14 @@ static unsigned long slice_find_area_topdown(struct mm_struct *mm,
7166 }
7167 }
7168
7169 - addr = mm->mmap_base;
7170 - while (addr > len) {
7171 + if (mm->mmap_base < len)
7172 + addr = -ENOMEM;
7173 + else
7174 + addr = mm->mmap_base - len;
7175 +
7176 + while (!IS_ERR_VALUE(addr)) {
7177 /* Go down by chunk size */
7178 - addr = _ALIGN_DOWN(addr - len, 1ul << pshift);
7179 + addr = _ALIGN_DOWN(addr, 1ul << pshift);
7180
7181 /* Check for hit with different page size */
7182 mask = slice_range_to_mask(addr, len);
7183 @@ -352,7 +356,7 @@ static unsigned long slice_find_area_topdown(struct mm_struct *mm,
7184 * return with success:
7185 */
7186 vma = find_vma(mm, addr);
7187 - if (!vma || (addr + len) <= vma->vm_start) {
7188 + if (check_heap_stack_gap(vma, addr, len, 0)) {
7189 /* remember the address as a hint for next time */
7190 if (use_cache)
7191 mm->free_area_cache = addr;
7192 @@ -364,7 +368,7 @@ static unsigned long slice_find_area_topdown(struct mm_struct *mm,
7193 mm->cached_hole_size = vma->vm_start - addr;
7194
7195 /* try just below the current vma->vm_start */
7196 - addr = vma->vm_start;
7197 + addr = skip_heap_stack_gap(vma, len, 0);
7198 }
7199
7200 /*
7201 @@ -442,6 +446,11 @@ unsigned long slice_get_unmapped_area(unsigned long addr, unsigned long len,
7202 if (fixed && addr > (mm->task_size - len))
7203 return -EINVAL;
7204
7205 +#ifdef CONFIG_PAX_RANDMMAP
7206 + if (!fixed && (mm->pax_flags & MF_PAX_RANDMMAP))
7207 + addr = 0;
7208 +#endif
7209 +
7210 /* If hint, make sure it matches our alignment restrictions */
7211 if (!fixed && addr) {
7212 addr = _ALIGN_UP(addr, 1ul << pshift);
7213 diff --git a/arch/powerpc/platforms/powermac/smp.c b/arch/powerpc/platforms/powermac/smp.c
7214 index bdb738a..49c9f95 100644
7215 --- a/arch/powerpc/platforms/powermac/smp.c
7216 +++ b/arch/powerpc/platforms/powermac/smp.c
7217 @@ -885,7 +885,7 @@ static int smp_core99_cpu_notify(struct notifier_block *self,
7218 return NOTIFY_OK;
7219 }
7220
7221 -static struct notifier_block __cpuinitdata smp_core99_cpu_nb = {
7222 +static struct notifier_block smp_core99_cpu_nb = {
7223 .notifier_call = smp_core99_cpu_notify,
7224 };
7225 #endif /* CONFIG_HOTPLUG_CPU */
7226 diff --git a/arch/s390/include/asm/atomic.h b/arch/s390/include/asm/atomic.h
7227 index c797832..ce575c8 100644
7228 --- a/arch/s390/include/asm/atomic.h
7229 +++ b/arch/s390/include/asm/atomic.h
7230 @@ -326,6 +326,16 @@ static inline long long atomic64_dec_if_positive(atomic64_t *v)
7231 #define atomic64_dec_and_test(_v) (atomic64_sub_return(1, _v) == 0)
7232 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
7233
7234 +#define atomic64_read_unchecked(v) atomic64_read(v)
7235 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
7236 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
7237 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
7238 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
7239 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
7240 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
7241 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
7242 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
7243 +
7244 #define smp_mb__before_atomic_dec() smp_mb()
7245 #define smp_mb__after_atomic_dec() smp_mb()
7246 #define smp_mb__before_atomic_inc() smp_mb()
7247 diff --git a/arch/s390/include/asm/cache.h b/arch/s390/include/asm/cache.h
7248 index 4d7ccac..d03d0ad 100644
7249 --- a/arch/s390/include/asm/cache.h
7250 +++ b/arch/s390/include/asm/cache.h
7251 @@ -9,8 +9,10 @@
7252 #ifndef __ARCH_S390_CACHE_H
7253 #define __ARCH_S390_CACHE_H
7254
7255 -#define L1_CACHE_BYTES 256
7256 +#include <linux/const.h>
7257 +
7258 #define L1_CACHE_SHIFT 8
7259 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
7260 #define NET_SKB_PAD 32
7261
7262 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
7263 diff --git a/arch/s390/include/asm/elf.h b/arch/s390/include/asm/elf.h
7264 index 178ff96..8c93bd1 100644
7265 --- a/arch/s390/include/asm/elf.h
7266 +++ b/arch/s390/include/asm/elf.h
7267 @@ -160,8 +160,14 @@ extern unsigned int vdso_enabled;
7268 the loader. We need to make sure that it is out of the way of the program
7269 that it will "exec", and that there is sufficient room for the brk. */
7270
7271 -extern unsigned long randomize_et_dyn(unsigned long base);
7272 -#define ELF_ET_DYN_BASE (randomize_et_dyn(STACK_TOP / 3 * 2))
7273 +#define ELF_ET_DYN_BASE (STACK_TOP / 3 * 2)
7274 +
7275 +#ifdef CONFIG_PAX_ASLR
7276 +#define PAX_ELF_ET_DYN_BASE (test_thread_flag(TIF_31BIT) ? 0x10000UL : 0x80000000UL)
7277 +
7278 +#define PAX_DELTA_MMAP_LEN (test_thread_flag(TIF_31BIT) ? 15 : 26)
7279 +#define PAX_DELTA_STACK_LEN (test_thread_flag(TIF_31BIT) ? 15 : 26)
7280 +#endif
7281
7282 /* This yields a mask that user programs can use to figure out what
7283 instruction set this CPU supports. */
7284 @@ -210,9 +216,6 @@ struct linux_binprm;
7285 #define ARCH_HAS_SETUP_ADDITIONAL_PAGES 1
7286 int arch_setup_additional_pages(struct linux_binprm *, int);
7287
7288 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
7289 -#define arch_randomize_brk arch_randomize_brk
7290 -
7291 void *fill_cpu_elf_notes(void *ptr, struct save_area *sa);
7292
7293 #endif
7294 diff --git a/arch/s390/include/asm/exec.h b/arch/s390/include/asm/exec.h
7295 index c4a93d6..4d2a9b4 100644
7296 --- a/arch/s390/include/asm/exec.h
7297 +++ b/arch/s390/include/asm/exec.h
7298 @@ -7,6 +7,6 @@
7299 #ifndef __ASM_EXEC_H
7300 #define __ASM_EXEC_H
7301
7302 -extern unsigned long arch_align_stack(unsigned long sp);
7303 +#define arch_align_stack(x) ((x) & ~0xfUL)
7304
7305 #endif /* __ASM_EXEC_H */
7306 diff --git a/arch/s390/include/asm/uaccess.h b/arch/s390/include/asm/uaccess.h
7307 index 34268df..ea97318 100644
7308 --- a/arch/s390/include/asm/uaccess.h
7309 +++ b/arch/s390/include/asm/uaccess.h
7310 @@ -252,6 +252,10 @@ static inline unsigned long __must_check
7311 copy_to_user(void __user *to, const void *from, unsigned long n)
7312 {
7313 might_fault();
7314 +
7315 + if ((long)n < 0)
7316 + return n;
7317 +
7318 if (access_ok(VERIFY_WRITE, to, n))
7319 n = __copy_to_user(to, from, n);
7320 return n;
7321 @@ -277,6 +281,9 @@ copy_to_user(void __user *to, const void *from, unsigned long n)
7322 static inline unsigned long __must_check
7323 __copy_from_user(void *to, const void __user *from, unsigned long n)
7324 {
7325 + if ((long)n < 0)
7326 + return n;
7327 +
7328 if (__builtin_constant_p(n) && (n <= 256))
7329 return uaccess.copy_from_user_small(n, from, to);
7330 else
7331 @@ -308,10 +315,14 @@ __compiletime_warning("copy_from_user() buffer size is not provably correct")
7332 static inline unsigned long __must_check
7333 copy_from_user(void *to, const void __user *from, unsigned long n)
7334 {
7335 - unsigned int sz = __compiletime_object_size(to);
7336 + size_t sz = __compiletime_object_size(to);
7337
7338 might_fault();
7339 - if (unlikely(sz != -1 && sz < n)) {
7340 +
7341 + if ((long)n < 0)
7342 + return n;
7343 +
7344 + if (unlikely(sz != (size_t)-1 && sz < n)) {
7345 copy_from_user_overflow();
7346 return n;
7347 }
7348 diff --git a/arch/s390/kernel/module.c b/arch/s390/kernel/module.c
7349 index 4610dea..cf0af21 100644
7350 --- a/arch/s390/kernel/module.c
7351 +++ b/arch/s390/kernel/module.c
7352 @@ -171,11 +171,11 @@ module_frob_arch_sections(Elf_Ehdr *hdr, Elf_Shdr *sechdrs,
7353
7354 /* Increase core size by size of got & plt and set start
7355 offsets for got and plt. */
7356 - me->core_size = ALIGN(me->core_size, 4);
7357 - me->arch.got_offset = me->core_size;
7358 - me->core_size += me->arch.got_size;
7359 - me->arch.plt_offset = me->core_size;
7360 - me->core_size += me->arch.plt_size;
7361 + me->core_size_rw = ALIGN(me->core_size_rw, 4);
7362 + me->arch.got_offset = me->core_size_rw;
7363 + me->core_size_rw += me->arch.got_size;
7364 + me->arch.plt_offset = me->core_size_rx;
7365 + me->core_size_rx += me->arch.plt_size;
7366 return 0;
7367 }
7368
7369 @@ -252,7 +252,7 @@ apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
7370 if (info->got_initialized == 0) {
7371 Elf_Addr *gotent;
7372
7373 - gotent = me->module_core + me->arch.got_offset +
7374 + gotent = me->module_core_rw + me->arch.got_offset +
7375 info->got_offset;
7376 *gotent = val;
7377 info->got_initialized = 1;
7378 @@ -276,7 +276,7 @@ apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
7379 else if (r_type == R_390_GOTENT ||
7380 r_type == R_390_GOTPLTENT)
7381 *(unsigned int *) loc =
7382 - (val + (Elf_Addr) me->module_core - loc) >> 1;
7383 + (val + (Elf_Addr) me->module_core_rw - loc) >> 1;
7384 else if (r_type == R_390_GOT64 ||
7385 r_type == R_390_GOTPLT64)
7386 *(unsigned long *) loc = val;
7387 @@ -290,7 +290,7 @@ apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
7388 case R_390_PLTOFF64: /* 16 bit offset from GOT to PLT. */
7389 if (info->plt_initialized == 0) {
7390 unsigned int *ip;
7391 - ip = me->module_core + me->arch.plt_offset +
7392 + ip = me->module_core_rx + me->arch.plt_offset +
7393 info->plt_offset;
7394 #ifndef CONFIG_64BIT
7395 ip[0] = 0x0d105810; /* basr 1,0; l 1,6(1); br 1 */
7396 @@ -315,7 +315,7 @@ apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
7397 val - loc + 0xffffUL < 0x1ffffeUL) ||
7398 (r_type == R_390_PLT32DBL &&
7399 val - loc + 0xffffffffULL < 0x1fffffffeULL)))
7400 - val = (Elf_Addr) me->module_core +
7401 + val = (Elf_Addr) me->module_core_rx +
7402 me->arch.plt_offset +
7403 info->plt_offset;
7404 val += rela->r_addend - loc;
7405 @@ -337,7 +337,7 @@ apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
7406 case R_390_GOTOFF32: /* 32 bit offset to GOT. */
7407 case R_390_GOTOFF64: /* 64 bit offset to GOT. */
7408 val = val + rela->r_addend -
7409 - ((Elf_Addr) me->module_core + me->arch.got_offset);
7410 + ((Elf_Addr) me->module_core_rw + me->arch.got_offset);
7411 if (r_type == R_390_GOTOFF16)
7412 *(unsigned short *) loc = val;
7413 else if (r_type == R_390_GOTOFF32)
7414 @@ -347,7 +347,7 @@ apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
7415 break;
7416 case R_390_GOTPC: /* 32 bit PC relative offset to GOT. */
7417 case R_390_GOTPCDBL: /* 32 bit PC rel. off. to GOT shifted by 1. */
7418 - val = (Elf_Addr) me->module_core + me->arch.got_offset +
7419 + val = (Elf_Addr) me->module_core_rw + me->arch.got_offset +
7420 rela->r_addend - loc;
7421 if (r_type == R_390_GOTPC)
7422 *(unsigned int *) loc = val;
7423 diff --git a/arch/s390/kernel/process.c b/arch/s390/kernel/process.c
7424 index 536d645..4a5bd9e 100644
7425 --- a/arch/s390/kernel/process.c
7426 +++ b/arch/s390/kernel/process.c
7427 @@ -250,39 +250,3 @@ unsigned long get_wchan(struct task_struct *p)
7428 }
7429 return 0;
7430 }
7431 -
7432 -unsigned long arch_align_stack(unsigned long sp)
7433 -{
7434 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
7435 - sp -= get_random_int() & ~PAGE_MASK;
7436 - return sp & ~0xf;
7437 -}
7438 -
7439 -static inline unsigned long brk_rnd(void)
7440 -{
7441 - /* 8MB for 32bit, 1GB for 64bit */
7442 - if (is_32bit_task())
7443 - return (get_random_int() & 0x7ffUL) << PAGE_SHIFT;
7444 - else
7445 - return (get_random_int() & 0x3ffffUL) << PAGE_SHIFT;
7446 -}
7447 -
7448 -unsigned long arch_randomize_brk(struct mm_struct *mm)
7449 -{
7450 - unsigned long ret = PAGE_ALIGN(mm->brk + brk_rnd());
7451 -
7452 - if (ret < mm->brk)
7453 - return mm->brk;
7454 - return ret;
7455 -}
7456 -
7457 -unsigned long randomize_et_dyn(unsigned long base)
7458 -{
7459 - unsigned long ret = PAGE_ALIGN(base + brk_rnd());
7460 -
7461 - if (!(current->flags & PF_RANDOMIZE))
7462 - return base;
7463 - if (ret < base)
7464 - return base;
7465 - return ret;
7466 -}
7467 diff --git a/arch/s390/mm/mmap.c b/arch/s390/mm/mmap.c
7468 index c59a5ef..3fae59c 100644
7469 --- a/arch/s390/mm/mmap.c
7470 +++ b/arch/s390/mm/mmap.c
7471 @@ -90,10 +90,22 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
7472 */
7473 if (mmap_is_legacy()) {
7474 mm->mmap_base = TASK_UNMAPPED_BASE;
7475 +
7476 +#ifdef CONFIG_PAX_RANDMMAP
7477 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7478 + mm->mmap_base += mm->delta_mmap;
7479 +#endif
7480 +
7481 mm->get_unmapped_area = arch_get_unmapped_area;
7482 mm->unmap_area = arch_unmap_area;
7483 } else {
7484 mm->mmap_base = mmap_base();
7485 +
7486 +#ifdef CONFIG_PAX_RANDMMAP
7487 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7488 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
7489 +#endif
7490 +
7491 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
7492 mm->unmap_area = arch_unmap_area_topdown;
7493 }
7494 @@ -172,10 +184,22 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
7495 */
7496 if (mmap_is_legacy()) {
7497 mm->mmap_base = TASK_UNMAPPED_BASE;
7498 +
7499 +#ifdef CONFIG_PAX_RANDMMAP
7500 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7501 + mm->mmap_base += mm->delta_mmap;
7502 +#endif
7503 +
7504 mm->get_unmapped_area = s390_get_unmapped_area;
7505 mm->unmap_area = arch_unmap_area;
7506 } else {
7507 mm->mmap_base = mmap_base();
7508 +
7509 +#ifdef CONFIG_PAX_RANDMMAP
7510 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7511 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
7512 +#endif
7513 +
7514 mm->get_unmapped_area = s390_get_unmapped_area_topdown;
7515 mm->unmap_area = arch_unmap_area_topdown;
7516 }
7517 diff --git a/arch/score/include/asm/cache.h b/arch/score/include/asm/cache.h
7518 index ae3d59f..f65f075 100644
7519 --- a/arch/score/include/asm/cache.h
7520 +++ b/arch/score/include/asm/cache.h
7521 @@ -1,7 +1,9 @@
7522 #ifndef _ASM_SCORE_CACHE_H
7523 #define _ASM_SCORE_CACHE_H
7524
7525 +#include <linux/const.h>
7526 +
7527 #define L1_CACHE_SHIFT 4
7528 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
7529 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
7530
7531 #endif /* _ASM_SCORE_CACHE_H */
7532 diff --git a/arch/score/include/asm/exec.h b/arch/score/include/asm/exec.h
7533 index f9f3cd5..58ff438 100644
7534 --- a/arch/score/include/asm/exec.h
7535 +++ b/arch/score/include/asm/exec.h
7536 @@ -1,6 +1,6 @@
7537 #ifndef _ASM_SCORE_EXEC_H
7538 #define _ASM_SCORE_EXEC_H
7539
7540 -extern unsigned long arch_align_stack(unsigned long sp);
7541 +#define arch_align_stack(x) (x)
7542
7543 #endif /* _ASM_SCORE_EXEC_H */
7544 diff --git a/arch/score/kernel/process.c b/arch/score/kernel/process.c
7545 index 7956846..5f37677 100644
7546 --- a/arch/score/kernel/process.c
7547 +++ b/arch/score/kernel/process.c
7548 @@ -134,8 +134,3 @@ unsigned long get_wchan(struct task_struct *task)
7549
7550 return task_pt_regs(task)->cp0_epc;
7551 }
7552 -
7553 -unsigned long arch_align_stack(unsigned long sp)
7554 -{
7555 - return sp;
7556 -}
7557 diff --git a/arch/sh/include/asm/cache.h b/arch/sh/include/asm/cache.h
7558 index ef9e555..331bd29 100644
7559 --- a/arch/sh/include/asm/cache.h
7560 +++ b/arch/sh/include/asm/cache.h
7561 @@ -9,10 +9,11 @@
7562 #define __ASM_SH_CACHE_H
7563 #ifdef __KERNEL__
7564
7565 +#include <linux/const.h>
7566 #include <linux/init.h>
7567 #include <cpu/cache.h>
7568
7569 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
7570 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
7571
7572 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
7573
7574 diff --git a/arch/sh/kernel/cpu/sh4a/smp-shx3.c b/arch/sh/kernel/cpu/sh4a/smp-shx3.c
7575 index 03f2b55..b027032 100644
7576 --- a/arch/sh/kernel/cpu/sh4a/smp-shx3.c
7577 +++ b/arch/sh/kernel/cpu/sh4a/smp-shx3.c
7578 @@ -143,7 +143,7 @@ shx3_cpu_callback(struct notifier_block *nfb, unsigned long action, void *hcpu)
7579 return NOTIFY_OK;
7580 }
7581
7582 -static struct notifier_block __cpuinitdata shx3_cpu_notifier = {
7583 +static struct notifier_block shx3_cpu_notifier = {
7584 .notifier_call = shx3_cpu_callback,
7585 };
7586
7587 diff --git a/arch/sh/mm/mmap.c b/arch/sh/mm/mmap.c
7588 index 6777177..cb5e44f 100644
7589 --- a/arch/sh/mm/mmap.c
7590 +++ b/arch/sh/mm/mmap.c
7591 @@ -36,6 +36,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
7592 struct mm_struct *mm = current->mm;
7593 struct vm_area_struct *vma;
7594 int do_colour_align;
7595 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
7596 struct vm_unmapped_area_info info;
7597
7598 if (flags & MAP_FIXED) {
7599 @@ -55,6 +56,10 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
7600 if (filp || (flags & MAP_SHARED))
7601 do_colour_align = 1;
7602
7603 +#ifdef CONFIG_PAX_RANDMMAP
7604 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
7605 +#endif
7606 +
7607 if (addr) {
7608 if (do_colour_align)
7609 addr = COLOUR_ALIGN(addr, pgoff);
7610 @@ -62,14 +67,13 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
7611 addr = PAGE_ALIGN(addr);
7612
7613 vma = find_vma(mm, addr);
7614 - if (TASK_SIZE - len >= addr &&
7615 - (!vma || addr + len <= vma->vm_start))
7616 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
7617 return addr;
7618 }
7619
7620 info.flags = 0;
7621 info.length = len;
7622 - info.low_limit = TASK_UNMAPPED_BASE;
7623 + info.low_limit = mm->mmap_base;
7624 info.high_limit = TASK_SIZE;
7625 info.align_mask = do_colour_align ? (PAGE_MASK & shm_align_mask) : 0;
7626 info.align_offset = pgoff << PAGE_SHIFT;
7627 @@ -85,6 +89,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
7628 struct mm_struct *mm = current->mm;
7629 unsigned long addr = addr0;
7630 int do_colour_align;
7631 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
7632 struct vm_unmapped_area_info info;
7633
7634 if (flags & MAP_FIXED) {
7635 @@ -104,6 +109,10 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
7636 if (filp || (flags & MAP_SHARED))
7637 do_colour_align = 1;
7638
7639 +#ifdef CONFIG_PAX_RANDMMAP
7640 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
7641 +#endif
7642 +
7643 /* requesting a specific address */
7644 if (addr) {
7645 if (do_colour_align)
7646 @@ -112,8 +121,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
7647 addr = PAGE_ALIGN(addr);
7648
7649 vma = find_vma(mm, addr);
7650 - if (TASK_SIZE - len >= addr &&
7651 - (!vma || addr + len <= vma->vm_start))
7652 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
7653 return addr;
7654 }
7655
7656 @@ -135,6 +143,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
7657 VM_BUG_ON(addr != -ENOMEM);
7658 info.flags = 0;
7659 info.low_limit = TASK_UNMAPPED_BASE;
7660 +
7661 +#ifdef CONFIG_PAX_RANDMMAP
7662 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7663 + info.low_limit += mm->delta_mmap;
7664 +#endif
7665 +
7666 info.high_limit = TASK_SIZE;
7667 addr = vm_unmapped_area(&info);
7668 }
7669 diff --git a/arch/sparc/include/asm/atomic_64.h b/arch/sparc/include/asm/atomic_64.h
7670 index be56a24..443328f 100644
7671 --- a/arch/sparc/include/asm/atomic_64.h
7672 +++ b/arch/sparc/include/asm/atomic_64.h
7673 @@ -14,18 +14,40 @@
7674 #define ATOMIC64_INIT(i) { (i) }
7675
7676 #define atomic_read(v) (*(volatile int *)&(v)->counter)
7677 +static inline int atomic_read_unchecked(const atomic_unchecked_t *v)
7678 +{
7679 + return v->counter;
7680 +}
7681 #define atomic64_read(v) (*(volatile long *)&(v)->counter)
7682 +static inline long atomic64_read_unchecked(const atomic64_unchecked_t *v)
7683 +{
7684 + return v->counter;
7685 +}
7686
7687 #define atomic_set(v, i) (((v)->counter) = i)
7688 +static inline void atomic_set_unchecked(atomic_unchecked_t *v, int i)
7689 +{
7690 + v->counter = i;
7691 +}
7692 #define atomic64_set(v, i) (((v)->counter) = i)
7693 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, long i)
7694 +{
7695 + v->counter = i;
7696 +}
7697
7698 extern void atomic_add(int, atomic_t *);
7699 +extern void atomic_add_unchecked(int, atomic_unchecked_t *);
7700 extern void atomic64_add(long, atomic64_t *);
7701 +extern void atomic64_add_unchecked(long, atomic64_unchecked_t *);
7702 extern void atomic_sub(int, atomic_t *);
7703 +extern void atomic_sub_unchecked(int, atomic_unchecked_t *);
7704 extern void atomic64_sub(long, atomic64_t *);
7705 +extern void atomic64_sub_unchecked(long, atomic64_unchecked_t *);
7706
7707 extern int atomic_add_ret(int, atomic_t *);
7708 +extern int atomic_add_ret_unchecked(int, atomic_unchecked_t *);
7709 extern long atomic64_add_ret(long, atomic64_t *);
7710 +extern long atomic64_add_ret_unchecked(long, atomic64_unchecked_t *);
7711 extern int atomic_sub_ret(int, atomic_t *);
7712 extern long atomic64_sub_ret(long, atomic64_t *);
7713
7714 @@ -33,13 +55,29 @@ extern long atomic64_sub_ret(long, atomic64_t *);
7715 #define atomic64_dec_return(v) atomic64_sub_ret(1, v)
7716
7717 #define atomic_inc_return(v) atomic_add_ret(1, v)
7718 +static inline int atomic_inc_return_unchecked(atomic_unchecked_t *v)
7719 +{
7720 + return atomic_add_ret_unchecked(1, v);
7721 +}
7722 #define atomic64_inc_return(v) atomic64_add_ret(1, v)
7723 +static inline long atomic64_inc_return_unchecked(atomic64_unchecked_t *v)
7724 +{
7725 + return atomic64_add_ret_unchecked(1, v);
7726 +}
7727
7728 #define atomic_sub_return(i, v) atomic_sub_ret(i, v)
7729 #define atomic64_sub_return(i, v) atomic64_sub_ret(i, v)
7730
7731 #define atomic_add_return(i, v) atomic_add_ret(i, v)
7732 +static inline int atomic_add_return_unchecked(int i, atomic_unchecked_t *v)
7733 +{
7734 + return atomic_add_ret_unchecked(i, v);
7735 +}
7736 #define atomic64_add_return(i, v) atomic64_add_ret(i, v)
7737 +static inline long atomic64_add_return_unchecked(long i, atomic64_unchecked_t *v)
7738 +{
7739 + return atomic64_add_ret_unchecked(i, v);
7740 +}
7741
7742 /*
7743 * atomic_inc_and_test - increment and test
7744 @@ -50,6 +88,10 @@ extern long atomic64_sub_ret(long, atomic64_t *);
7745 * other cases.
7746 */
7747 #define atomic_inc_and_test(v) (atomic_inc_return(v) == 0)
7748 +static inline int atomic_inc_and_test_unchecked(atomic_unchecked_t *v)
7749 +{
7750 + return atomic_inc_return_unchecked(v) == 0;
7751 +}
7752 #define atomic64_inc_and_test(v) (atomic64_inc_return(v) == 0)
7753
7754 #define atomic_sub_and_test(i, v) (atomic_sub_ret(i, v) == 0)
7755 @@ -59,25 +101,60 @@ extern long atomic64_sub_ret(long, atomic64_t *);
7756 #define atomic64_dec_and_test(v) (atomic64_sub_ret(1, v) == 0)
7757
7758 #define atomic_inc(v) atomic_add(1, v)
7759 +static inline void atomic_inc_unchecked(atomic_unchecked_t *v)
7760 +{
7761 + atomic_add_unchecked(1, v);
7762 +}
7763 #define atomic64_inc(v) atomic64_add(1, v)
7764 +static inline void atomic64_inc_unchecked(atomic64_unchecked_t *v)
7765 +{
7766 + atomic64_add_unchecked(1, v);
7767 +}
7768
7769 #define atomic_dec(v) atomic_sub(1, v)
7770 +static inline void atomic_dec_unchecked(atomic_unchecked_t *v)
7771 +{
7772 + atomic_sub_unchecked(1, v);
7773 +}
7774 #define atomic64_dec(v) atomic64_sub(1, v)
7775 +static inline void atomic64_dec_unchecked(atomic64_unchecked_t *v)
7776 +{
7777 + atomic64_sub_unchecked(1, v);
7778 +}
7779
7780 #define atomic_add_negative(i, v) (atomic_add_ret(i, v) < 0)
7781 #define atomic64_add_negative(i, v) (atomic64_add_ret(i, v) < 0)
7782
7783 #define atomic_cmpxchg(v, o, n) (cmpxchg(&((v)->counter), (o), (n)))
7784 +static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *v, int old, int new)
7785 +{
7786 + return cmpxchg(&v->counter, old, new);
7787 +}
7788 #define atomic_xchg(v, new) (xchg(&((v)->counter), new))
7789 +static inline int atomic_xchg_unchecked(atomic_unchecked_t *v, int new)
7790 +{
7791 + return xchg(&v->counter, new);
7792 +}
7793
7794 static inline int __atomic_add_unless(atomic_t *v, int a, int u)
7795 {
7796 - int c, old;
7797 + int c, old, new;
7798 c = atomic_read(v);
7799 for (;;) {
7800 - if (unlikely(c == (u)))
7801 + if (unlikely(c == u))
7802 break;
7803 - old = atomic_cmpxchg((v), c, c + (a));
7804 +
7805 + asm volatile("addcc %2, %0, %0\n"
7806 +
7807 +#ifdef CONFIG_PAX_REFCOUNT
7808 + "tvs %%icc, 6\n"
7809 +#endif
7810 +
7811 + : "=r" (new)
7812 + : "0" (c), "ir" (a)
7813 + : "cc");
7814 +
7815 + old = atomic_cmpxchg(v, c, new);
7816 if (likely(old == c))
7817 break;
7818 c = old;
7819 @@ -88,20 +165,35 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
7820 #define atomic64_cmpxchg(v, o, n) \
7821 ((__typeof__((v)->counter))cmpxchg(&((v)->counter), (o), (n)))
7822 #define atomic64_xchg(v, new) (xchg(&((v)->counter), new))
7823 +static inline long atomic64_xchg_unchecked(atomic64_unchecked_t *v, long new)
7824 +{
7825 + return xchg(&v->counter, new);
7826 +}
7827
7828 static inline long atomic64_add_unless(atomic64_t *v, long a, long u)
7829 {
7830 - long c, old;
7831 + long c, old, new;
7832 c = atomic64_read(v);
7833 for (;;) {
7834 - if (unlikely(c == (u)))
7835 + if (unlikely(c == u))
7836 break;
7837 - old = atomic64_cmpxchg((v), c, c + (a));
7838 +
7839 + asm volatile("addcc %2, %0, %0\n"
7840 +
7841 +#ifdef CONFIG_PAX_REFCOUNT
7842 + "tvs %%xcc, 6\n"
7843 +#endif
7844 +
7845 + : "=r" (new)
7846 + : "0" (c), "ir" (a)
7847 + : "cc");
7848 +
7849 + old = atomic64_cmpxchg(v, c, new);
7850 if (likely(old == c))
7851 break;
7852 c = old;
7853 }
7854 - return c != (u);
7855 + return c != u;
7856 }
7857
7858 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
7859 diff --git a/arch/sparc/include/asm/cache.h b/arch/sparc/include/asm/cache.h
7860 index 5bb6991..5c2132e 100644
7861 --- a/arch/sparc/include/asm/cache.h
7862 +++ b/arch/sparc/include/asm/cache.h
7863 @@ -7,10 +7,12 @@
7864 #ifndef _SPARC_CACHE_H
7865 #define _SPARC_CACHE_H
7866
7867 +#include <linux/const.h>
7868 +
7869 #define ARCH_SLAB_MINALIGN __alignof__(unsigned long long)
7870
7871 #define L1_CACHE_SHIFT 5
7872 -#define L1_CACHE_BYTES 32
7873 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
7874
7875 #ifdef CONFIG_SPARC32
7876 #define SMP_CACHE_BYTES_SHIFT 5
7877 diff --git a/arch/sparc/include/asm/elf_32.h b/arch/sparc/include/asm/elf_32.h
7878 index ac74a2c..a9e58af 100644
7879 --- a/arch/sparc/include/asm/elf_32.h
7880 +++ b/arch/sparc/include/asm/elf_32.h
7881 @@ -114,6 +114,13 @@ typedef struct {
7882
7883 #define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE)
7884
7885 +#ifdef CONFIG_PAX_ASLR
7886 +#define PAX_ELF_ET_DYN_BASE 0x10000UL
7887 +
7888 +#define PAX_DELTA_MMAP_LEN 16
7889 +#define PAX_DELTA_STACK_LEN 16
7890 +#endif
7891 +
7892 /* This yields a mask that user programs can use to figure out what
7893 instruction set this cpu supports. This can NOT be done in userspace
7894 on Sparc. */
7895 diff --git a/arch/sparc/include/asm/elf_64.h b/arch/sparc/include/asm/elf_64.h
7896 index 370ca1e..d4f4a98 100644
7897 --- a/arch/sparc/include/asm/elf_64.h
7898 +++ b/arch/sparc/include/asm/elf_64.h
7899 @@ -189,6 +189,13 @@ typedef struct {
7900 #define ELF_ET_DYN_BASE 0x0000010000000000UL
7901 #define COMPAT_ELF_ET_DYN_BASE 0x0000000070000000UL
7902
7903 +#ifdef CONFIG_PAX_ASLR
7904 +#define PAX_ELF_ET_DYN_BASE (test_thread_flag(TIF_32BIT) ? 0x10000UL : 0x100000UL)
7905 +
7906 +#define PAX_DELTA_MMAP_LEN (test_thread_flag(TIF_32BIT) ? 14 : 28)
7907 +#define PAX_DELTA_STACK_LEN (test_thread_flag(TIF_32BIT) ? 15 : 29)
7908 +#endif
7909 +
7910 extern unsigned long sparc64_elf_hwcap;
7911 #define ELF_HWCAP sparc64_elf_hwcap
7912
7913 diff --git a/arch/sparc/include/asm/pgalloc_32.h b/arch/sparc/include/asm/pgalloc_32.h
7914 index 9b1c36d..209298b 100644
7915 --- a/arch/sparc/include/asm/pgalloc_32.h
7916 +++ b/arch/sparc/include/asm/pgalloc_32.h
7917 @@ -33,6 +33,7 @@ static inline void pgd_set(pgd_t * pgdp, pmd_t * pmdp)
7918 }
7919
7920 #define pgd_populate(MM, PGD, PMD) pgd_set(PGD, PMD)
7921 +#define pgd_populate_kernel(MM, PGD, PMD) pgd_populate((MM), (PGD), (PMD))
7922
7923 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm,
7924 unsigned long address)
7925 diff --git a/arch/sparc/include/asm/pgalloc_64.h b/arch/sparc/include/asm/pgalloc_64.h
7926 index bcfe063..b333142 100644
7927 --- a/arch/sparc/include/asm/pgalloc_64.h
7928 +++ b/arch/sparc/include/asm/pgalloc_64.h
7929 @@ -26,6 +26,7 @@ static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd)
7930 }
7931
7932 #define pud_populate(MM, PUD, PMD) pud_set(PUD, PMD)
7933 +#define pud_populate_kernel(MM, PUD, PMD) pud_populate((MM), (PUD), (PMD))
7934
7935 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long addr)
7936 {
7937 diff --git a/arch/sparc/include/asm/pgtable_32.h b/arch/sparc/include/asm/pgtable_32.h
7938 index 6fc1348..390c50a 100644
7939 --- a/arch/sparc/include/asm/pgtable_32.h
7940 +++ b/arch/sparc/include/asm/pgtable_32.h
7941 @@ -50,6 +50,9 @@ extern unsigned long calc_highpages(void);
7942 #define PAGE_SHARED SRMMU_PAGE_SHARED
7943 #define PAGE_COPY SRMMU_PAGE_COPY
7944 #define PAGE_READONLY SRMMU_PAGE_RDONLY
7945 +#define PAGE_SHARED_NOEXEC SRMMU_PAGE_SHARED_NOEXEC
7946 +#define PAGE_COPY_NOEXEC SRMMU_PAGE_COPY_NOEXEC
7947 +#define PAGE_READONLY_NOEXEC SRMMU_PAGE_RDONLY_NOEXEC
7948 #define PAGE_KERNEL SRMMU_PAGE_KERNEL
7949
7950 /* Top-level page directory - dummy used by init-mm.
7951 @@ -62,18 +65,18 @@ extern unsigned long ptr_in_current_pgd;
7952
7953 /* xwr */
7954 #define __P000 PAGE_NONE
7955 -#define __P001 PAGE_READONLY
7956 -#define __P010 PAGE_COPY
7957 -#define __P011 PAGE_COPY
7958 +#define __P001 PAGE_READONLY_NOEXEC
7959 +#define __P010 PAGE_COPY_NOEXEC
7960 +#define __P011 PAGE_COPY_NOEXEC
7961 #define __P100 PAGE_READONLY
7962 #define __P101 PAGE_READONLY
7963 #define __P110 PAGE_COPY
7964 #define __P111 PAGE_COPY
7965
7966 #define __S000 PAGE_NONE
7967 -#define __S001 PAGE_READONLY
7968 -#define __S010 PAGE_SHARED
7969 -#define __S011 PAGE_SHARED
7970 +#define __S001 PAGE_READONLY_NOEXEC
7971 +#define __S010 PAGE_SHARED_NOEXEC
7972 +#define __S011 PAGE_SHARED_NOEXEC
7973 #define __S100 PAGE_READONLY
7974 #define __S101 PAGE_READONLY
7975 #define __S110 PAGE_SHARED
7976 diff --git a/arch/sparc/include/asm/pgtsrmmu.h b/arch/sparc/include/asm/pgtsrmmu.h
7977 index 79da178..c2eede8 100644
7978 --- a/arch/sparc/include/asm/pgtsrmmu.h
7979 +++ b/arch/sparc/include/asm/pgtsrmmu.h
7980 @@ -115,6 +115,11 @@
7981 SRMMU_EXEC | SRMMU_REF)
7982 #define SRMMU_PAGE_RDONLY __pgprot(SRMMU_VALID | SRMMU_CACHE | \
7983 SRMMU_EXEC | SRMMU_REF)
7984 +
7985 +#define SRMMU_PAGE_SHARED_NOEXEC __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_WRITE | SRMMU_REF)
7986 +#define SRMMU_PAGE_COPY_NOEXEC __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_REF)
7987 +#define SRMMU_PAGE_RDONLY_NOEXEC __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_REF)
7988 +
7989 #define SRMMU_PAGE_KERNEL __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_PRIV | \
7990 SRMMU_DIRTY | SRMMU_REF)
7991
7992 diff --git a/arch/sparc/include/asm/spinlock_64.h b/arch/sparc/include/asm/spinlock_64.h
7993 index 9689176..63c18ea 100644
7994 --- a/arch/sparc/include/asm/spinlock_64.h
7995 +++ b/arch/sparc/include/asm/spinlock_64.h
7996 @@ -92,14 +92,19 @@ static inline void arch_spin_lock_flags(arch_spinlock_t *lock, unsigned long fla
7997
7998 /* Multi-reader locks, these are much saner than the 32-bit Sparc ones... */
7999
8000 -static void inline arch_read_lock(arch_rwlock_t *lock)
8001 +static inline void arch_read_lock(arch_rwlock_t *lock)
8002 {
8003 unsigned long tmp1, tmp2;
8004
8005 __asm__ __volatile__ (
8006 "1: ldsw [%2], %0\n"
8007 " brlz,pn %0, 2f\n"
8008 -"4: add %0, 1, %1\n"
8009 +"4: addcc %0, 1, %1\n"
8010 +
8011 +#ifdef CONFIG_PAX_REFCOUNT
8012 +" tvs %%icc, 6\n"
8013 +#endif
8014 +
8015 " cas [%2], %0, %1\n"
8016 " cmp %0, %1\n"
8017 " bne,pn %%icc, 1b\n"
8018 @@ -112,10 +117,10 @@ static void inline arch_read_lock(arch_rwlock_t *lock)
8019 " .previous"
8020 : "=&r" (tmp1), "=&r" (tmp2)
8021 : "r" (lock)
8022 - : "memory");
8023 + : "memory", "cc");
8024 }
8025
8026 -static int inline arch_read_trylock(arch_rwlock_t *lock)
8027 +static inline int arch_read_trylock(arch_rwlock_t *lock)
8028 {
8029 int tmp1, tmp2;
8030
8031 @@ -123,7 +128,12 @@ static int inline arch_read_trylock(arch_rwlock_t *lock)
8032 "1: ldsw [%2], %0\n"
8033 " brlz,a,pn %0, 2f\n"
8034 " mov 0, %0\n"
8035 -" add %0, 1, %1\n"
8036 +" addcc %0, 1, %1\n"
8037 +
8038 +#ifdef CONFIG_PAX_REFCOUNT
8039 +" tvs %%icc, 6\n"
8040 +#endif
8041 +
8042 " cas [%2], %0, %1\n"
8043 " cmp %0, %1\n"
8044 " bne,pn %%icc, 1b\n"
8045 @@ -136,13 +146,18 @@ static int inline arch_read_trylock(arch_rwlock_t *lock)
8046 return tmp1;
8047 }
8048
8049 -static void inline arch_read_unlock(arch_rwlock_t *lock)
8050 +static inline void arch_read_unlock(arch_rwlock_t *lock)
8051 {
8052 unsigned long tmp1, tmp2;
8053
8054 __asm__ __volatile__(
8055 "1: lduw [%2], %0\n"
8056 -" sub %0, 1, %1\n"
8057 +" subcc %0, 1, %1\n"
8058 +
8059 +#ifdef CONFIG_PAX_REFCOUNT
8060 +" tvs %%icc, 6\n"
8061 +#endif
8062 +
8063 " cas [%2], %0, %1\n"
8064 " cmp %0, %1\n"
8065 " bne,pn %%xcc, 1b\n"
8066 @@ -152,7 +167,7 @@ static void inline arch_read_unlock(arch_rwlock_t *lock)
8067 : "memory");
8068 }
8069
8070 -static void inline arch_write_lock(arch_rwlock_t *lock)
8071 +static inline void arch_write_lock(arch_rwlock_t *lock)
8072 {
8073 unsigned long mask, tmp1, tmp2;
8074
8075 @@ -177,7 +192,7 @@ static void inline arch_write_lock(arch_rwlock_t *lock)
8076 : "memory");
8077 }
8078
8079 -static void inline arch_write_unlock(arch_rwlock_t *lock)
8080 +static inline void arch_write_unlock(arch_rwlock_t *lock)
8081 {
8082 __asm__ __volatile__(
8083 " stw %%g0, [%0]"
8084 @@ -186,7 +201,7 @@ static void inline arch_write_unlock(arch_rwlock_t *lock)
8085 : "memory");
8086 }
8087
8088 -static int inline arch_write_trylock(arch_rwlock_t *lock)
8089 +static inline int arch_write_trylock(arch_rwlock_t *lock)
8090 {
8091 unsigned long mask, tmp1, tmp2, result;
8092
8093 diff --git a/arch/sparc/include/asm/thread_info_32.h b/arch/sparc/include/asm/thread_info_32.h
8094 index 25849ae..924c54b 100644
8095 --- a/arch/sparc/include/asm/thread_info_32.h
8096 +++ b/arch/sparc/include/asm/thread_info_32.h
8097 @@ -49,6 +49,8 @@ struct thread_info {
8098 unsigned long w_saved;
8099
8100 struct restart_block restart_block;
8101 +
8102 + unsigned long lowest_stack;
8103 };
8104
8105 /*
8106 diff --git a/arch/sparc/include/asm/thread_info_64.h b/arch/sparc/include/asm/thread_info_64.h
8107 index 269bd92..e46a9b8 100644
8108 --- a/arch/sparc/include/asm/thread_info_64.h
8109 +++ b/arch/sparc/include/asm/thread_info_64.h
8110 @@ -63,6 +63,8 @@ struct thread_info {
8111 struct pt_regs *kern_una_regs;
8112 unsigned int kern_una_insn;
8113
8114 + unsigned long lowest_stack;
8115 +
8116 unsigned long fpregs[0] __attribute__ ((aligned(64)));
8117 };
8118
8119 @@ -192,10 +194,11 @@ register struct thread_info *current_thread_info_reg asm("g6");
8120 #define TIF_UNALIGNED 5 /* allowed to do unaligned accesses */
8121 /* flag bit 6 is available */
8122 #define TIF_32BIT 7 /* 32-bit binary */
8123 -/* flag bit 8 is available */
8124 +#define TIF_GRSEC_SETXID 8 /* update credentials on syscall entry/exit */
8125 #define TIF_SECCOMP 9 /* secure computing */
8126 #define TIF_SYSCALL_AUDIT 10 /* syscall auditing active */
8127 #define TIF_SYSCALL_TRACEPOINT 11 /* syscall tracepoint instrumentation */
8128 +
8129 /* NOTE: Thread flags >= 12 should be ones we have no interest
8130 * in using in assembly, else we can't use the mask as
8131 * an immediate value in instructions such as andcc.
8132 @@ -214,12 +217,18 @@ register struct thread_info *current_thread_info_reg asm("g6");
8133 #define _TIF_SYSCALL_AUDIT (1<<TIF_SYSCALL_AUDIT)
8134 #define _TIF_SYSCALL_TRACEPOINT (1<<TIF_SYSCALL_TRACEPOINT)
8135 #define _TIF_POLLING_NRFLAG (1<<TIF_POLLING_NRFLAG)
8136 +#define _TIF_GRSEC_SETXID (1<<TIF_GRSEC_SETXID)
8137
8138 #define _TIF_USER_WORK_MASK ((0xff << TI_FLAG_WSAVED_SHIFT) | \
8139 _TIF_DO_NOTIFY_RESUME_MASK | \
8140 _TIF_NEED_RESCHED)
8141 #define _TIF_DO_NOTIFY_RESUME_MASK (_TIF_NOTIFY_RESUME | _TIF_SIGPENDING)
8142
8143 +#define _TIF_WORK_SYSCALL \
8144 + (_TIF_SYSCALL_TRACE | _TIF_SECCOMP | _TIF_SYSCALL_AUDIT | \
8145 + _TIF_SYSCALL_TRACEPOINT | _TIF_GRSEC_SETXID)
8146 +
8147 +
8148 /*
8149 * Thread-synchronous status.
8150 *
8151 diff --git a/arch/sparc/include/asm/uaccess.h b/arch/sparc/include/asm/uaccess.h
8152 index 0167d26..9acd8ed 100644
8153 --- a/arch/sparc/include/asm/uaccess.h
8154 +++ b/arch/sparc/include/asm/uaccess.h
8155 @@ -1,5 +1,13 @@
8156 #ifndef ___ASM_SPARC_UACCESS_H
8157 #define ___ASM_SPARC_UACCESS_H
8158 +
8159 +#ifdef __KERNEL__
8160 +#ifndef __ASSEMBLY__
8161 +#include <linux/types.h>
8162 +extern void check_object_size(const void *ptr, unsigned long n, bool to);
8163 +#endif
8164 +#endif
8165 +
8166 #if defined(__sparc__) && defined(__arch64__)
8167 #include <asm/uaccess_64.h>
8168 #else
8169 diff --git a/arch/sparc/include/asm/uaccess_32.h b/arch/sparc/include/asm/uaccess_32.h
8170 index 53a28dd..50c38c3 100644
8171 --- a/arch/sparc/include/asm/uaccess_32.h
8172 +++ b/arch/sparc/include/asm/uaccess_32.h
8173 @@ -250,27 +250,46 @@ extern unsigned long __copy_user(void __user *to, const void __user *from, unsig
8174
8175 static inline unsigned long copy_to_user(void __user *to, const void *from, unsigned long n)
8176 {
8177 - if (n && __access_ok((unsigned long) to, n))
8178 + if ((long)n < 0)
8179 + return n;
8180 +
8181 + if (n && __access_ok((unsigned long) to, n)) {
8182 + if (!__builtin_constant_p(n))
8183 + check_object_size(from, n, true);
8184 return __copy_user(to, (__force void __user *) from, n);
8185 - else
8186 + } else
8187 return n;
8188 }
8189
8190 static inline unsigned long __copy_to_user(void __user *to, const void *from, unsigned long n)
8191 {
8192 + if ((long)n < 0)
8193 + return n;
8194 +
8195 + if (!__builtin_constant_p(n))
8196 + check_object_size(from, n, true);
8197 +
8198 return __copy_user(to, (__force void __user *) from, n);
8199 }
8200
8201 static inline unsigned long copy_from_user(void *to, const void __user *from, unsigned long n)
8202 {
8203 - if (n && __access_ok((unsigned long) from, n))
8204 + if ((long)n < 0)
8205 + return n;
8206 +
8207 + if (n && __access_ok((unsigned long) from, n)) {
8208 + if (!__builtin_constant_p(n))
8209 + check_object_size(to, n, false);
8210 return __copy_user((__force void __user *) to, from, n);
8211 - else
8212 + } else
8213 return n;
8214 }
8215
8216 static inline unsigned long __copy_from_user(void *to, const void __user *from, unsigned long n)
8217 {
8218 + if ((long)n < 0)
8219 + return n;
8220 +
8221 return __copy_user((__force void __user *) to, from, n);
8222 }
8223
8224 diff --git a/arch/sparc/include/asm/uaccess_64.h b/arch/sparc/include/asm/uaccess_64.h
8225 index e562d3c..191f176 100644
8226 --- a/arch/sparc/include/asm/uaccess_64.h
8227 +++ b/arch/sparc/include/asm/uaccess_64.h
8228 @@ -10,6 +10,7 @@
8229 #include <linux/compiler.h>
8230 #include <linux/string.h>
8231 #include <linux/thread_info.h>
8232 +#include <linux/kernel.h>
8233 #include <asm/asi.h>
8234 #include <asm/spitfire.h>
8235 #include <asm-generic/uaccess-unaligned.h>
8236 @@ -214,8 +215,15 @@ extern unsigned long copy_from_user_fixup(void *to, const void __user *from,
8237 static inline unsigned long __must_check
8238 copy_from_user(void *to, const void __user *from, unsigned long size)
8239 {
8240 - unsigned long ret = ___copy_from_user(to, from, size);
8241 + unsigned long ret;
8242
8243 + if ((long)size < 0 || size > INT_MAX)
8244 + return size;
8245 +
8246 + if (!__builtin_constant_p(size))
8247 + check_object_size(to, size, false);
8248 +
8249 + ret = ___copy_from_user(to, from, size);
8250 if (unlikely(ret))
8251 ret = copy_from_user_fixup(to, from, size);
8252
8253 @@ -231,8 +239,15 @@ extern unsigned long copy_to_user_fixup(void __user *to, const void *from,
8254 static inline unsigned long __must_check
8255 copy_to_user(void __user *to, const void *from, unsigned long size)
8256 {
8257 - unsigned long ret = ___copy_to_user(to, from, size);
8258 + unsigned long ret;
8259
8260 + if ((long)size < 0 || size > INT_MAX)
8261 + return size;
8262 +
8263 + if (!__builtin_constant_p(size))
8264 + check_object_size(from, size, true);
8265 +
8266 + ret = ___copy_to_user(to, from, size);
8267 if (unlikely(ret))
8268 ret = copy_to_user_fixup(to, from, size);
8269 return ret;
8270 diff --git a/arch/sparc/kernel/Makefile b/arch/sparc/kernel/Makefile
8271 index 6cf591b..b49e65a 100644
8272 --- a/arch/sparc/kernel/Makefile
8273 +++ b/arch/sparc/kernel/Makefile
8274 @@ -3,7 +3,7 @@
8275 #
8276
8277 asflags-y := -ansi
8278 -ccflags-y := -Werror
8279 +#ccflags-y := -Werror
8280
8281 extra-y := head_$(BITS).o
8282
8283 diff --git a/arch/sparc/kernel/process_32.c b/arch/sparc/kernel/process_32.c
8284 index be8e862..5b50b12 100644
8285 --- a/arch/sparc/kernel/process_32.c
8286 +++ b/arch/sparc/kernel/process_32.c
8287 @@ -126,14 +126,14 @@ void show_regs(struct pt_regs *r)
8288
8289 printk("PSR: %08lx PC: %08lx NPC: %08lx Y: %08lx %s\n",
8290 r->psr, r->pc, r->npc, r->y, print_tainted());
8291 - printk("PC: <%pS>\n", (void *) r->pc);
8292 + printk("PC: <%pA>\n", (void *) r->pc);
8293 printk("%%G: %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
8294 r->u_regs[0], r->u_regs[1], r->u_regs[2], r->u_regs[3],
8295 r->u_regs[4], r->u_regs[5], r->u_regs[6], r->u_regs[7]);
8296 printk("%%O: %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
8297 r->u_regs[8], r->u_regs[9], r->u_regs[10], r->u_regs[11],
8298 r->u_regs[12], r->u_regs[13], r->u_regs[14], r->u_regs[15]);
8299 - printk("RPC: <%pS>\n", (void *) r->u_regs[15]);
8300 + printk("RPC: <%pA>\n", (void *) r->u_regs[15]);
8301
8302 printk("%%L: %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
8303 rw->locals[0], rw->locals[1], rw->locals[2], rw->locals[3],
8304 @@ -168,7 +168,7 @@ void show_stack(struct task_struct *tsk, unsigned long *_ksp)
8305 rw = (struct reg_window32 *) fp;
8306 pc = rw->ins[7];
8307 printk("[%08lx : ", pc);
8308 - printk("%pS ] ", (void *) pc);
8309 + printk("%pA ] ", (void *) pc);
8310 fp = rw->ins[6];
8311 } while (++count < 16);
8312 printk("\n");
8313 diff --git a/arch/sparc/kernel/process_64.c b/arch/sparc/kernel/process_64.c
8314 index cdb80b2..5ca141d 100644
8315 --- a/arch/sparc/kernel/process_64.c
8316 +++ b/arch/sparc/kernel/process_64.c
8317 @@ -181,14 +181,14 @@ static void show_regwindow(struct pt_regs *regs)
8318 printk("i4: %016lx i5: %016lx i6: %016lx i7: %016lx\n",
8319 rwk->ins[4], rwk->ins[5], rwk->ins[6], rwk->ins[7]);
8320 if (regs->tstate & TSTATE_PRIV)
8321 - printk("I7: <%pS>\n", (void *) rwk->ins[7]);
8322 + printk("I7: <%pA>\n", (void *) rwk->ins[7]);
8323 }
8324
8325 void show_regs(struct pt_regs *regs)
8326 {
8327 printk("TSTATE: %016lx TPC: %016lx TNPC: %016lx Y: %08x %s\n", regs->tstate,
8328 regs->tpc, regs->tnpc, regs->y, print_tainted());
8329 - printk("TPC: <%pS>\n", (void *) regs->tpc);
8330 + printk("TPC: <%pA>\n", (void *) regs->tpc);
8331 printk("g0: %016lx g1: %016lx g2: %016lx g3: %016lx\n",
8332 regs->u_regs[0], regs->u_regs[1], regs->u_regs[2],
8333 regs->u_regs[3]);
8334 @@ -201,7 +201,7 @@ void show_regs(struct pt_regs *regs)
8335 printk("o4: %016lx o5: %016lx sp: %016lx ret_pc: %016lx\n",
8336 regs->u_regs[12], regs->u_regs[13], regs->u_regs[14],
8337 regs->u_regs[15]);
8338 - printk("RPC: <%pS>\n", (void *) regs->u_regs[15]);
8339 + printk("RPC: <%pA>\n", (void *) regs->u_regs[15]);
8340 show_regwindow(regs);
8341 show_stack(current, (unsigned long *) regs->u_regs[UREG_FP]);
8342 }
8343 @@ -290,7 +290,7 @@ void arch_trigger_all_cpu_backtrace(void)
8344 ((tp && tp->task) ? tp->task->pid : -1));
8345
8346 if (gp->tstate & TSTATE_PRIV) {
8347 - printk(" TPC[%pS] O7[%pS] I7[%pS] RPC[%pS]\n",
8348 + printk(" TPC[%pA] O7[%pA] I7[%pA] RPC[%pA]\n",
8349 (void *) gp->tpc,
8350 (void *) gp->o7,
8351 (void *) gp->i7,
8352 diff --git a/arch/sparc/kernel/ptrace_64.c b/arch/sparc/kernel/ptrace_64.c
8353 index 7ff45e4..a58f271 100644
8354 --- a/arch/sparc/kernel/ptrace_64.c
8355 +++ b/arch/sparc/kernel/ptrace_64.c
8356 @@ -1057,6 +1057,10 @@ long arch_ptrace(struct task_struct *child, long request,
8357 return ret;
8358 }
8359
8360 +#ifdef CONFIG_GRKERNSEC_SETXID
8361 +extern void gr_delayed_cred_worker(void);
8362 +#endif
8363 +
8364 asmlinkage int syscall_trace_enter(struct pt_regs *regs)
8365 {
8366 int ret = 0;
8367 @@ -1064,6 +1068,11 @@ asmlinkage int syscall_trace_enter(struct pt_regs *regs)
8368 /* do the secure computing check first */
8369 secure_computing_strict(regs->u_regs[UREG_G1]);
8370
8371 +#ifdef CONFIG_GRKERNSEC_SETXID
8372 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
8373 + gr_delayed_cred_worker();
8374 +#endif
8375 +
8376 if (test_thread_flag(TIF_SYSCALL_TRACE))
8377 ret = tracehook_report_syscall_entry(regs);
8378
8379 @@ -1084,6 +1093,11 @@ asmlinkage int syscall_trace_enter(struct pt_regs *regs)
8380
8381 asmlinkage void syscall_trace_leave(struct pt_regs *regs)
8382 {
8383 +#ifdef CONFIG_GRKERNSEC_SETXID
8384 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
8385 + gr_delayed_cred_worker();
8386 +#endif
8387 +
8388 audit_syscall_exit(regs);
8389
8390 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
8391 diff --git a/arch/sparc/kernel/sys_sparc_32.c b/arch/sparc/kernel/sys_sparc_32.c
8392 index 2da0bdc..79128d2 100644
8393 --- a/arch/sparc/kernel/sys_sparc_32.c
8394 +++ b/arch/sparc/kernel/sys_sparc_32.c
8395 @@ -52,7 +52,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
8396 if (len > TASK_SIZE - PAGE_SIZE)
8397 return -ENOMEM;
8398 if (!addr)
8399 - addr = TASK_UNMAPPED_BASE;
8400 + addr = current->mm->mmap_base;
8401
8402 info.flags = 0;
8403 info.length = len;
8404 diff --git a/arch/sparc/kernel/sys_sparc_64.c b/arch/sparc/kernel/sys_sparc_64.c
8405 index 708bc29..f0129cb 100644
8406 --- a/arch/sparc/kernel/sys_sparc_64.c
8407 +++ b/arch/sparc/kernel/sys_sparc_64.c
8408 @@ -90,13 +90,14 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
8409 struct vm_area_struct * vma;
8410 unsigned long task_size = TASK_SIZE;
8411 int do_color_align;
8412 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
8413 struct vm_unmapped_area_info info;
8414
8415 if (flags & MAP_FIXED) {
8416 /* We do not accept a shared mapping if it would violate
8417 * cache aliasing constraints.
8418 */
8419 - if ((flags & MAP_SHARED) &&
8420 + if ((filp || (flags & MAP_SHARED)) &&
8421 ((addr - (pgoff << PAGE_SHIFT)) & (SHMLBA - 1)))
8422 return -EINVAL;
8423 return addr;
8424 @@ -111,6 +112,10 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
8425 if (filp || (flags & MAP_SHARED))
8426 do_color_align = 1;
8427
8428 +#ifdef CONFIG_PAX_RANDMMAP
8429 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
8430 +#endif
8431 +
8432 if (addr) {
8433 if (do_color_align)
8434 addr = COLOR_ALIGN(addr, pgoff);
8435 @@ -118,14 +123,13 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
8436 addr = PAGE_ALIGN(addr);
8437
8438 vma = find_vma(mm, addr);
8439 - if (task_size - len >= addr &&
8440 - (!vma || addr + len <= vma->vm_start))
8441 + if (task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
8442 return addr;
8443 }
8444
8445 info.flags = 0;
8446 info.length = len;
8447 - info.low_limit = TASK_UNMAPPED_BASE;
8448 + info.low_limit = mm->mmap_base;
8449 info.high_limit = min(task_size, VA_EXCLUDE_START);
8450 info.align_mask = do_color_align ? (PAGE_MASK & (SHMLBA - 1)) : 0;
8451 info.align_offset = pgoff << PAGE_SHIFT;
8452 @@ -134,6 +138,12 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
8453 if ((addr & ~PAGE_MASK) && task_size > VA_EXCLUDE_END) {
8454 VM_BUG_ON(addr != -ENOMEM);
8455 info.low_limit = VA_EXCLUDE_END;
8456 +
8457 +#ifdef CONFIG_PAX_RANDMMAP
8458 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8459 + info.low_limit += mm->delta_mmap;
8460 +#endif
8461 +
8462 info.high_limit = task_size;
8463 addr = vm_unmapped_area(&info);
8464 }
8465 @@ -151,6 +161,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8466 unsigned long task_size = STACK_TOP32;
8467 unsigned long addr = addr0;
8468 int do_color_align;
8469 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
8470 struct vm_unmapped_area_info info;
8471
8472 /* This should only ever run for 32-bit processes. */
8473 @@ -160,7 +171,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8474 /* We do not accept a shared mapping if it would violate
8475 * cache aliasing constraints.
8476 */
8477 - if ((flags & MAP_SHARED) &&
8478 + if ((filp || (flags & MAP_SHARED)) &&
8479 ((addr - (pgoff << PAGE_SHIFT)) & (SHMLBA - 1)))
8480 return -EINVAL;
8481 return addr;
8482 @@ -173,6 +184,10 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8483 if (filp || (flags & MAP_SHARED))
8484 do_color_align = 1;
8485
8486 +#ifdef CONFIG_PAX_RANDMMAP
8487 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
8488 +#endif
8489 +
8490 /* requesting a specific address */
8491 if (addr) {
8492 if (do_color_align)
8493 @@ -181,8 +196,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8494 addr = PAGE_ALIGN(addr);
8495
8496 vma = find_vma(mm, addr);
8497 - if (task_size - len >= addr &&
8498 - (!vma || addr + len <= vma->vm_start))
8499 + if (task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
8500 return addr;
8501 }
8502
8503 @@ -204,6 +218,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8504 VM_BUG_ON(addr != -ENOMEM);
8505 info.flags = 0;
8506 info.low_limit = TASK_UNMAPPED_BASE;
8507 +
8508 +#ifdef CONFIG_PAX_RANDMMAP
8509 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8510 + info.low_limit += mm->delta_mmap;
8511 +#endif
8512 +
8513 info.high_limit = STACK_TOP32;
8514 addr = vm_unmapped_area(&info);
8515 }
8516 @@ -264,6 +284,10 @@ static unsigned long mmap_rnd(void)
8517 {
8518 unsigned long rnd = 0UL;
8519
8520 +#ifdef CONFIG_PAX_RANDMMAP
8521 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
8522 +#endif
8523 +
8524 if (current->flags & PF_RANDOMIZE) {
8525 unsigned long val = get_random_int();
8526 if (test_thread_flag(TIF_32BIT))
8527 @@ -289,6 +313,12 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
8528 gap == RLIM_INFINITY ||
8529 sysctl_legacy_va_layout) {
8530 mm->mmap_base = TASK_UNMAPPED_BASE + random_factor;
8531 +
8532 +#ifdef CONFIG_PAX_RANDMMAP
8533 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8534 + mm->mmap_base += mm->delta_mmap;
8535 +#endif
8536 +
8537 mm->get_unmapped_area = arch_get_unmapped_area;
8538 mm->unmap_area = arch_unmap_area;
8539 } else {
8540 @@ -301,6 +331,12 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
8541 gap = (task_size / 6 * 5);
8542
8543 mm->mmap_base = PAGE_ALIGN(task_size - gap - random_factor);
8544 +
8545 +#ifdef CONFIG_PAX_RANDMMAP
8546 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8547 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
8548 +#endif
8549 +
8550 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
8551 mm->unmap_area = arch_unmap_area_topdown;
8552 }
8553 diff --git a/arch/sparc/kernel/syscalls.S b/arch/sparc/kernel/syscalls.S
8554 index e0fed77..604a7e5 100644
8555 --- a/arch/sparc/kernel/syscalls.S
8556 +++ b/arch/sparc/kernel/syscalls.S
8557 @@ -58,7 +58,7 @@ sys32_rt_sigreturn:
8558 #endif
8559 .align 32
8560 1: ldx [%g6 + TI_FLAGS], %l5
8561 - andcc %l5, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
8562 + andcc %l5, _TIF_WORK_SYSCALL, %g0
8563 be,pt %icc, rtrap
8564 nop
8565 call syscall_trace_leave
8566 @@ -190,7 +190,7 @@ linux_sparc_syscall32:
8567
8568 srl %i5, 0, %o5 ! IEU1
8569 srl %i2, 0, %o2 ! IEU0 Group
8570 - andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
8571 + andcc %l0, _TIF_WORK_SYSCALL, %g0
8572 bne,pn %icc, linux_syscall_trace32 ! CTI
8573 mov %i0, %l5 ! IEU1
8574 call %l7 ! CTI Group brk forced
8575 @@ -213,7 +213,7 @@ linux_sparc_syscall:
8576
8577 mov %i3, %o3 ! IEU1
8578 mov %i4, %o4 ! IEU0 Group
8579 - andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
8580 + andcc %l0, _TIF_WORK_SYSCALL, %g0
8581 bne,pn %icc, linux_syscall_trace ! CTI Group
8582 mov %i0, %l5 ! IEU0
8583 2: call %l7 ! CTI Group brk forced
8584 @@ -229,7 +229,7 @@ ret_sys_call:
8585
8586 cmp %o0, -ERESTART_RESTARTBLOCK
8587 bgeu,pn %xcc, 1f
8588 - andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
8589 + andcc %l0, _TIF_WORK_SYSCALL, %g0
8590 ldx [%sp + PTREGS_OFF + PT_V9_TNPC], %l1 ! pc = npc
8591
8592 2:
8593 diff --git a/arch/sparc/kernel/sysfs.c b/arch/sparc/kernel/sysfs.c
8594 index 654e8aa..45f431b 100644
8595 --- a/arch/sparc/kernel/sysfs.c
8596 +++ b/arch/sparc/kernel/sysfs.c
8597 @@ -266,7 +266,7 @@ static int __cpuinit sysfs_cpu_notify(struct notifier_block *self,
8598 return NOTIFY_OK;
8599 }
8600
8601 -static struct notifier_block __cpuinitdata sysfs_cpu_nb = {
8602 +static struct notifier_block sysfs_cpu_nb = {
8603 .notifier_call = sysfs_cpu_notify,
8604 };
8605
8606 diff --git a/arch/sparc/kernel/traps_32.c b/arch/sparc/kernel/traps_32.c
8607 index a5785ea..405c5f7 100644
8608 --- a/arch/sparc/kernel/traps_32.c
8609 +++ b/arch/sparc/kernel/traps_32.c
8610 @@ -44,6 +44,8 @@ static void instruction_dump(unsigned long *pc)
8611 #define __SAVE __asm__ __volatile__("save %sp, -0x40, %sp\n\t")
8612 #define __RESTORE __asm__ __volatile__("restore %g0, %g0, %g0\n\t")
8613
8614 +extern void gr_handle_kernel_exploit(void);
8615 +
8616 void die_if_kernel(char *str, struct pt_regs *regs)
8617 {
8618 static int die_counter;
8619 @@ -76,15 +78,17 @@ void die_if_kernel(char *str, struct pt_regs *regs)
8620 count++ < 30 &&
8621 (((unsigned long) rw) >= PAGE_OFFSET) &&
8622 !(((unsigned long) rw) & 0x7)) {
8623 - printk("Caller[%08lx]: %pS\n", rw->ins[7],
8624 + printk("Caller[%08lx]: %pA\n", rw->ins[7],
8625 (void *) rw->ins[7]);
8626 rw = (struct reg_window32 *)rw->ins[6];
8627 }
8628 }
8629 printk("Instruction DUMP:");
8630 instruction_dump ((unsigned long *) regs->pc);
8631 - if(regs->psr & PSR_PS)
8632 + if(regs->psr & PSR_PS) {
8633 + gr_handle_kernel_exploit();
8634 do_exit(SIGKILL);
8635 + }
8636 do_exit(SIGSEGV);
8637 }
8638
8639 diff --git a/arch/sparc/kernel/traps_64.c b/arch/sparc/kernel/traps_64.c
8640 index e7ecf15..6520e65 100644
8641 --- a/arch/sparc/kernel/traps_64.c
8642 +++ b/arch/sparc/kernel/traps_64.c
8643 @@ -76,7 +76,7 @@ static void dump_tl1_traplog(struct tl1_traplog *p)
8644 i + 1,
8645 p->trapstack[i].tstate, p->trapstack[i].tpc,
8646 p->trapstack[i].tnpc, p->trapstack[i].tt);
8647 - printk("TRAPLOG: TPC<%pS>\n", (void *) p->trapstack[i].tpc);
8648 + printk("TRAPLOG: TPC<%pA>\n", (void *) p->trapstack[i].tpc);
8649 }
8650 }
8651
8652 @@ -96,6 +96,12 @@ void bad_trap(struct pt_regs *regs, long lvl)
8653
8654 lvl -= 0x100;
8655 if (regs->tstate & TSTATE_PRIV) {
8656 +
8657 +#ifdef CONFIG_PAX_REFCOUNT
8658 + if (lvl == 6)
8659 + pax_report_refcount_overflow(regs);
8660 +#endif
8661 +
8662 sprintf(buffer, "Kernel bad sw trap %lx", lvl);
8663 die_if_kernel(buffer, regs);
8664 }
8665 @@ -114,11 +120,16 @@ void bad_trap(struct pt_regs *regs, long lvl)
8666 void bad_trap_tl1(struct pt_regs *regs, long lvl)
8667 {
8668 char buffer[32];
8669 -
8670 +
8671 if (notify_die(DIE_TRAP_TL1, "bad trap tl1", regs,
8672 0, lvl, SIGTRAP) == NOTIFY_STOP)
8673 return;
8674
8675 +#ifdef CONFIG_PAX_REFCOUNT
8676 + if (lvl == 6)
8677 + pax_report_refcount_overflow(regs);
8678 +#endif
8679 +
8680 dump_tl1_traplog((struct tl1_traplog *)(regs + 1));
8681
8682 sprintf (buffer, "Bad trap %lx at tl>0", lvl);
8683 @@ -1142,7 +1153,7 @@ static void cheetah_log_errors(struct pt_regs *regs, struct cheetah_err_info *in
8684 regs->tpc, regs->tnpc, regs->u_regs[UREG_I7], regs->tstate);
8685 printk("%s" "ERROR(%d): ",
8686 (recoverable ? KERN_WARNING : KERN_CRIT), smp_processor_id());
8687 - printk("TPC<%pS>\n", (void *) regs->tpc);
8688 + printk("TPC<%pA>\n", (void *) regs->tpc);
8689 printk("%s" "ERROR(%d): M_SYND(%lx), E_SYND(%lx)%s%s\n",
8690 (recoverable ? KERN_WARNING : KERN_CRIT), smp_processor_id(),
8691 (afsr & CHAFSR_M_SYNDROME) >> CHAFSR_M_SYNDROME_SHIFT,
8692 @@ -1749,7 +1760,7 @@ void cheetah_plus_parity_error(int type, struct pt_regs *regs)
8693 smp_processor_id(),
8694 (type & 0x1) ? 'I' : 'D',
8695 regs->tpc);
8696 - printk(KERN_EMERG "TPC<%pS>\n", (void *) regs->tpc);
8697 + printk(KERN_EMERG "TPC<%pA>\n", (void *) regs->tpc);
8698 panic("Irrecoverable Cheetah+ parity error.");
8699 }
8700
8701 @@ -1757,7 +1768,7 @@ void cheetah_plus_parity_error(int type, struct pt_regs *regs)
8702 smp_processor_id(),
8703 (type & 0x1) ? 'I' : 'D',
8704 regs->tpc);
8705 - printk(KERN_WARNING "TPC<%pS>\n", (void *) regs->tpc);
8706 + printk(KERN_WARNING "TPC<%pA>\n", (void *) regs->tpc);
8707 }
8708
8709 struct sun4v_error_entry {
8710 @@ -2104,9 +2115,9 @@ void sun4v_itlb_error_report(struct pt_regs *regs, int tl)
8711
8712 printk(KERN_EMERG "SUN4V-ITLB: Error at TPC[%lx], tl %d\n",
8713 regs->tpc, tl);
8714 - printk(KERN_EMERG "SUN4V-ITLB: TPC<%pS>\n", (void *) regs->tpc);
8715 + printk(KERN_EMERG "SUN4V-ITLB: TPC<%pA>\n", (void *) regs->tpc);
8716 printk(KERN_EMERG "SUN4V-ITLB: O7[%lx]\n", regs->u_regs[UREG_I7]);
8717 - printk(KERN_EMERG "SUN4V-ITLB: O7<%pS>\n",
8718 + printk(KERN_EMERG "SUN4V-ITLB: O7<%pA>\n",
8719 (void *) regs->u_regs[UREG_I7]);
8720 printk(KERN_EMERG "SUN4V-ITLB: vaddr[%lx] ctx[%lx] "
8721 "pte[%lx] error[%lx]\n",
8722 @@ -2128,9 +2139,9 @@ void sun4v_dtlb_error_report(struct pt_regs *regs, int tl)
8723
8724 printk(KERN_EMERG "SUN4V-DTLB: Error at TPC[%lx], tl %d\n",
8725 regs->tpc, tl);
8726 - printk(KERN_EMERG "SUN4V-DTLB: TPC<%pS>\n", (void *) regs->tpc);
8727 + printk(KERN_EMERG "SUN4V-DTLB: TPC<%pA>\n", (void *) regs->tpc);
8728 printk(KERN_EMERG "SUN4V-DTLB: O7[%lx]\n", regs->u_regs[UREG_I7]);
8729 - printk(KERN_EMERG "SUN4V-DTLB: O7<%pS>\n",
8730 + printk(KERN_EMERG "SUN4V-DTLB: O7<%pA>\n",
8731 (void *) regs->u_regs[UREG_I7]);
8732 printk(KERN_EMERG "SUN4V-DTLB: vaddr[%lx] ctx[%lx] "
8733 "pte[%lx] error[%lx]\n",
8734 @@ -2336,13 +2347,13 @@ void show_stack(struct task_struct *tsk, unsigned long *_ksp)
8735 fp = (unsigned long)sf->fp + STACK_BIAS;
8736 }
8737
8738 - printk(" [%016lx] %pS\n", pc, (void *) pc);
8739 + printk(" [%016lx] %pA\n", pc, (void *) pc);
8740 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
8741 if ((pc + 8UL) == (unsigned long) &return_to_handler) {
8742 int index = tsk->curr_ret_stack;
8743 if (tsk->ret_stack && index >= graph) {
8744 pc = tsk->ret_stack[index - graph].ret;
8745 - printk(" [%016lx] %pS\n", pc, (void *) pc);
8746 + printk(" [%016lx] %pA\n", pc, (void *) pc);
8747 graph++;
8748 }
8749 }
8750 @@ -2367,6 +2378,8 @@ static inline struct reg_window *kernel_stack_up(struct reg_window *rw)
8751 return (struct reg_window *) (fp + STACK_BIAS);
8752 }
8753
8754 +extern void gr_handle_kernel_exploit(void);
8755 +
8756 void die_if_kernel(char *str, struct pt_regs *regs)
8757 {
8758 static int die_counter;
8759 @@ -2395,7 +2408,7 @@ void die_if_kernel(char *str, struct pt_regs *regs)
8760 while (rw &&
8761 count++ < 30 &&
8762 kstack_valid(tp, (unsigned long) rw)) {
8763 - printk("Caller[%016lx]: %pS\n", rw->ins[7],
8764 + printk("Caller[%016lx]: %pA\n", rw->ins[7],
8765 (void *) rw->ins[7]);
8766
8767 rw = kernel_stack_up(rw);
8768 @@ -2408,8 +2421,10 @@ void die_if_kernel(char *str, struct pt_regs *regs)
8769 }
8770 user_instruction_dump ((unsigned int __user *) regs->tpc);
8771 }
8772 - if (regs->tstate & TSTATE_PRIV)
8773 + if (regs->tstate & TSTATE_PRIV) {
8774 + gr_handle_kernel_exploit();
8775 do_exit(SIGKILL);
8776 + }
8777 do_exit(SIGSEGV);
8778 }
8779 EXPORT_SYMBOL(die_if_kernel);
8780 diff --git a/arch/sparc/kernel/unaligned_64.c b/arch/sparc/kernel/unaligned_64.c
8781 index 8201c25e..072a2a7 100644
8782 --- a/arch/sparc/kernel/unaligned_64.c
8783 +++ b/arch/sparc/kernel/unaligned_64.c
8784 @@ -286,7 +286,7 @@ static void log_unaligned(struct pt_regs *regs)
8785 static DEFINE_RATELIMIT_STATE(ratelimit, 5 * HZ, 5);
8786
8787 if (__ratelimit(&ratelimit)) {
8788 - printk("Kernel unaligned access at TPC[%lx] %pS\n",
8789 + printk("Kernel unaligned access at TPC[%lx] %pA\n",
8790 regs->tpc, (void *) regs->tpc);
8791 }
8792 }
8793 diff --git a/arch/sparc/lib/Makefile b/arch/sparc/lib/Makefile
8794 index 8410065f2..4fd4ca22 100644
8795 --- a/arch/sparc/lib/Makefile
8796 +++ b/arch/sparc/lib/Makefile
8797 @@ -2,7 +2,7 @@
8798 #
8799
8800 asflags-y := -ansi -DST_DIV0=0x02
8801 -ccflags-y := -Werror
8802 +#ccflags-y := -Werror
8803
8804 lib-$(CONFIG_SPARC32) += ashrdi3.o
8805 lib-$(CONFIG_SPARC32) += memcpy.o memset.o
8806 diff --git a/arch/sparc/lib/atomic_64.S b/arch/sparc/lib/atomic_64.S
8807 index 85c233d..68500e0 100644
8808 --- a/arch/sparc/lib/atomic_64.S
8809 +++ b/arch/sparc/lib/atomic_64.S
8810 @@ -17,7 +17,12 @@
8811 ENTRY(atomic_add) /* %o0 = increment, %o1 = atomic_ptr */
8812 BACKOFF_SETUP(%o2)
8813 1: lduw [%o1], %g1
8814 - add %g1, %o0, %g7
8815 + addcc %g1, %o0, %g7
8816 +
8817 +#ifdef CONFIG_PAX_REFCOUNT
8818 + tvs %icc, 6
8819 +#endif
8820 +
8821 cas [%o1], %g1, %g7
8822 cmp %g1, %g7
8823 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
8824 @@ -27,10 +32,28 @@ ENTRY(atomic_add) /* %o0 = increment, %o1 = atomic_ptr */
8825 2: BACKOFF_SPIN(%o2, %o3, 1b)
8826 ENDPROC(atomic_add)
8827
8828 +ENTRY(atomic_add_unchecked) /* %o0 = increment, %o1 = atomic_ptr */
8829 + BACKOFF_SETUP(%o2)
8830 +1: lduw [%o1], %g1
8831 + add %g1, %o0, %g7
8832 + cas [%o1], %g1, %g7
8833 + cmp %g1, %g7
8834 + bne,pn %icc, 2f
8835 + nop
8836 + retl
8837 + nop
8838 +2: BACKOFF_SPIN(%o2, %o3, 1b)
8839 +ENDPROC(atomic_add_unchecked)
8840 +
8841 ENTRY(atomic_sub) /* %o0 = decrement, %o1 = atomic_ptr */
8842 BACKOFF_SETUP(%o2)
8843 1: lduw [%o1], %g1
8844 - sub %g1, %o0, %g7
8845 + subcc %g1, %o0, %g7
8846 +
8847 +#ifdef CONFIG_PAX_REFCOUNT
8848 + tvs %icc, 6
8849 +#endif
8850 +
8851 cas [%o1], %g1, %g7
8852 cmp %g1, %g7
8853 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
8854 @@ -40,10 +63,28 @@ ENTRY(atomic_sub) /* %o0 = decrement, %o1 = atomic_ptr */
8855 2: BACKOFF_SPIN(%o2, %o3, 1b)
8856 ENDPROC(atomic_sub)
8857
8858 +ENTRY(atomic_sub_unchecked) /* %o0 = decrement, %o1 = atomic_ptr */
8859 + BACKOFF_SETUP(%o2)
8860 +1: lduw [%o1], %g1
8861 + sub %g1, %o0, %g7
8862 + cas [%o1], %g1, %g7
8863 + cmp %g1, %g7
8864 + bne,pn %icc, 2f
8865 + nop
8866 + retl
8867 + nop
8868 +2: BACKOFF_SPIN(%o2, %o3, 1b)
8869 +ENDPROC(atomic_sub_unchecked)
8870 +
8871 ENTRY(atomic_add_ret) /* %o0 = increment, %o1 = atomic_ptr */
8872 BACKOFF_SETUP(%o2)
8873 1: lduw [%o1], %g1
8874 - add %g1, %o0, %g7
8875 + addcc %g1, %o0, %g7
8876 +
8877 +#ifdef CONFIG_PAX_REFCOUNT
8878 + tvs %icc, 6
8879 +#endif
8880 +
8881 cas [%o1], %g1, %g7
8882 cmp %g1, %g7
8883 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
8884 @@ -53,10 +94,29 @@ ENTRY(atomic_add_ret) /* %o0 = increment, %o1 = atomic_ptr */
8885 2: BACKOFF_SPIN(%o2, %o3, 1b)
8886 ENDPROC(atomic_add_ret)
8887
8888 +ENTRY(atomic_add_ret_unchecked) /* %o0 = increment, %o1 = atomic_ptr */
8889 + BACKOFF_SETUP(%o2)
8890 +1: lduw [%o1], %g1
8891 + addcc %g1, %o0, %g7
8892 + cas [%o1], %g1, %g7
8893 + cmp %g1, %g7
8894 + bne,pn %icc, 2f
8895 + add %g7, %o0, %g7
8896 + sra %g7, 0, %o0
8897 + retl
8898 + nop
8899 +2: BACKOFF_SPIN(%o2, %o3, 1b)
8900 +ENDPROC(atomic_add_ret_unchecked)
8901 +
8902 ENTRY(atomic_sub_ret) /* %o0 = decrement, %o1 = atomic_ptr */
8903 BACKOFF_SETUP(%o2)
8904 1: lduw [%o1], %g1
8905 - sub %g1, %o0, %g7
8906 + subcc %g1, %o0, %g7
8907 +
8908 +#ifdef CONFIG_PAX_REFCOUNT
8909 + tvs %icc, 6
8910 +#endif
8911 +
8912 cas [%o1], %g1, %g7
8913 cmp %g1, %g7
8914 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
8915 @@ -69,7 +129,12 @@ ENDPROC(atomic_sub_ret)
8916 ENTRY(atomic64_add) /* %o0 = increment, %o1 = atomic_ptr */
8917 BACKOFF_SETUP(%o2)
8918 1: ldx [%o1], %g1
8919 - add %g1, %o0, %g7
8920 + addcc %g1, %o0, %g7
8921 +
8922 +#ifdef CONFIG_PAX_REFCOUNT
8923 + tvs %xcc, 6
8924 +#endif
8925 +
8926 casx [%o1], %g1, %g7
8927 cmp %g1, %g7
8928 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
8929 @@ -79,10 +144,28 @@ ENTRY(atomic64_add) /* %o0 = increment, %o1 = atomic_ptr */
8930 2: BACKOFF_SPIN(%o2, %o3, 1b)
8931 ENDPROC(atomic64_add)
8932
8933 +ENTRY(atomic64_add_unchecked) /* %o0 = increment, %o1 = atomic_ptr */
8934 + BACKOFF_SETUP(%o2)
8935 +1: ldx [%o1], %g1
8936 + addcc %g1, %o0, %g7
8937 + casx [%o1], %g1, %g7
8938 + cmp %g1, %g7
8939 + bne,pn %xcc, 2f
8940 + nop
8941 + retl
8942 + nop
8943 +2: BACKOFF_SPIN(%o2, %o3, 1b)
8944 +ENDPROC(atomic64_add_unchecked)
8945 +
8946 ENTRY(atomic64_sub) /* %o0 = decrement, %o1 = atomic_ptr */
8947 BACKOFF_SETUP(%o2)
8948 1: ldx [%o1], %g1
8949 - sub %g1, %o0, %g7
8950 + subcc %g1, %o0, %g7
8951 +
8952 +#ifdef CONFIG_PAX_REFCOUNT
8953 + tvs %xcc, 6
8954 +#endif
8955 +
8956 casx [%o1], %g1, %g7
8957 cmp %g1, %g7
8958 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
8959 @@ -92,10 +175,28 @@ ENTRY(atomic64_sub) /* %o0 = decrement, %o1 = atomic_ptr */
8960 2: BACKOFF_SPIN(%o2, %o3, 1b)
8961 ENDPROC(atomic64_sub)
8962
8963 +ENTRY(atomic64_sub_unchecked) /* %o0 = decrement, %o1 = atomic_ptr */
8964 + BACKOFF_SETUP(%o2)
8965 +1: ldx [%o1], %g1
8966 + subcc %g1, %o0, %g7
8967 + casx [%o1], %g1, %g7
8968 + cmp %g1, %g7
8969 + bne,pn %xcc, 2f
8970 + nop
8971 + retl
8972 + nop
8973 +2: BACKOFF_SPIN(%o2, %o3, 1b)
8974 +ENDPROC(atomic64_sub_unchecked)
8975 +
8976 ENTRY(atomic64_add_ret) /* %o0 = increment, %o1 = atomic_ptr */
8977 BACKOFF_SETUP(%o2)
8978 1: ldx [%o1], %g1
8979 - add %g1, %o0, %g7
8980 + addcc %g1, %o0, %g7
8981 +
8982 +#ifdef CONFIG_PAX_REFCOUNT
8983 + tvs %xcc, 6
8984 +#endif
8985 +
8986 casx [%o1], %g1, %g7
8987 cmp %g1, %g7
8988 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
8989 @@ -105,10 +206,29 @@ ENTRY(atomic64_add_ret) /* %o0 = increment, %o1 = atomic_ptr */
8990 2: BACKOFF_SPIN(%o2, %o3, 1b)
8991 ENDPROC(atomic64_add_ret)
8992
8993 +ENTRY(atomic64_add_ret_unchecked) /* %o0 = increment, %o1 = atomic_ptr */
8994 + BACKOFF_SETUP(%o2)
8995 +1: ldx [%o1], %g1
8996 + addcc %g1, %o0, %g7
8997 + casx [%o1], %g1, %g7
8998 + cmp %g1, %g7
8999 + bne,pn %xcc, 2f
9000 + add %g7, %o0, %g7
9001 + mov %g7, %o0
9002 + retl
9003 + nop
9004 +2: BACKOFF_SPIN(%o2, %o3, 1b)
9005 +ENDPROC(atomic64_add_ret_unchecked)
9006 +
9007 ENTRY(atomic64_sub_ret) /* %o0 = decrement, %o1 = atomic_ptr */
9008 BACKOFF_SETUP(%o2)
9009 1: ldx [%o1], %g1
9010 - sub %g1, %o0, %g7
9011 + subcc %g1, %o0, %g7
9012 +
9013 +#ifdef CONFIG_PAX_REFCOUNT
9014 + tvs %xcc, 6
9015 +#endif
9016 +
9017 casx [%o1], %g1, %g7
9018 cmp %g1, %g7
9019 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
9020 diff --git a/arch/sparc/lib/ksyms.c b/arch/sparc/lib/ksyms.c
9021 index 0c4e35e..745d3e4 100644
9022 --- a/arch/sparc/lib/ksyms.c
9023 +++ b/arch/sparc/lib/ksyms.c
9024 @@ -109,12 +109,18 @@ EXPORT_SYMBOL(__downgrade_write);
9025
9026 /* Atomic counter implementation. */
9027 EXPORT_SYMBOL(atomic_add);
9028 +EXPORT_SYMBOL(atomic_add_unchecked);
9029 EXPORT_SYMBOL(atomic_add_ret);
9030 +EXPORT_SYMBOL(atomic_add_ret_unchecked);
9031 EXPORT_SYMBOL(atomic_sub);
9032 +EXPORT_SYMBOL(atomic_sub_unchecked);
9033 EXPORT_SYMBOL(atomic_sub_ret);
9034 EXPORT_SYMBOL(atomic64_add);
9035 +EXPORT_SYMBOL(atomic64_add_unchecked);
9036 EXPORT_SYMBOL(atomic64_add_ret);
9037 +EXPORT_SYMBOL(atomic64_add_ret_unchecked);
9038 EXPORT_SYMBOL(atomic64_sub);
9039 +EXPORT_SYMBOL(atomic64_sub_unchecked);
9040 EXPORT_SYMBOL(atomic64_sub_ret);
9041 EXPORT_SYMBOL(atomic64_dec_if_positive);
9042
9043 diff --git a/arch/sparc/mm/Makefile b/arch/sparc/mm/Makefile
9044 index 30c3ecc..736f015 100644
9045 --- a/arch/sparc/mm/Makefile
9046 +++ b/arch/sparc/mm/Makefile
9047 @@ -2,7 +2,7 @@
9048 #
9049
9050 asflags-y := -ansi
9051 -ccflags-y := -Werror
9052 +#ccflags-y := -Werror
9053
9054 obj-$(CONFIG_SPARC64) += ultra.o tlb.o tsb.o gup.o
9055 obj-y += fault_$(BITS).o
9056 diff --git a/arch/sparc/mm/fault_32.c b/arch/sparc/mm/fault_32.c
9057 index e98bfda..ea8d221 100644
9058 --- a/arch/sparc/mm/fault_32.c
9059 +++ b/arch/sparc/mm/fault_32.c
9060 @@ -21,6 +21,9 @@
9061 #include <linux/perf_event.h>
9062 #include <linux/interrupt.h>
9063 #include <linux/kdebug.h>
9064 +#include <linux/slab.h>
9065 +#include <linux/pagemap.h>
9066 +#include <linux/compiler.h>
9067
9068 #include <asm/page.h>
9069 #include <asm/pgtable.h>
9070 @@ -159,6 +162,277 @@ static unsigned long compute_si_addr(struct pt_regs *regs, int text_fault)
9071 return safe_compute_effective_address(regs, insn);
9072 }
9073
9074 +#ifdef CONFIG_PAX_PAGEEXEC
9075 +#ifdef CONFIG_PAX_DLRESOLVE
9076 +static void pax_emuplt_close(struct vm_area_struct *vma)
9077 +{
9078 + vma->vm_mm->call_dl_resolve = 0UL;
9079 +}
9080 +
9081 +static int pax_emuplt_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
9082 +{
9083 + unsigned int *kaddr;
9084 +
9085 + vmf->page = alloc_page(GFP_HIGHUSER);
9086 + if (!vmf->page)
9087 + return VM_FAULT_OOM;
9088 +
9089 + kaddr = kmap(vmf->page);
9090 + memset(kaddr, 0, PAGE_SIZE);
9091 + kaddr[0] = 0x9DE3BFA8U; /* save */
9092 + flush_dcache_page(vmf->page);
9093 + kunmap(vmf->page);
9094 + return VM_FAULT_MAJOR;
9095 +}
9096 +
9097 +static const struct vm_operations_struct pax_vm_ops = {
9098 + .close = pax_emuplt_close,
9099 + .fault = pax_emuplt_fault
9100 +};
9101 +
9102 +static int pax_insert_vma(struct vm_area_struct *vma, unsigned long addr)
9103 +{
9104 + int ret;
9105 +
9106 + INIT_LIST_HEAD(&vma->anon_vma_chain);
9107 + vma->vm_mm = current->mm;
9108 + vma->vm_start = addr;
9109 + vma->vm_end = addr + PAGE_SIZE;
9110 + vma->vm_flags = VM_READ | VM_EXEC | VM_MAYREAD | VM_MAYEXEC;
9111 + vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
9112 + vma->vm_ops = &pax_vm_ops;
9113 +
9114 + ret = insert_vm_struct(current->mm, vma);
9115 + if (ret)
9116 + return ret;
9117 +
9118 + ++current->mm->total_vm;
9119 + return 0;
9120 +}
9121 +#endif
9122 +
9123 +/*
9124 + * PaX: decide what to do with offenders (regs->pc = fault address)
9125 + *
9126 + * returns 1 when task should be killed
9127 + * 2 when patched PLT trampoline was detected
9128 + * 3 when unpatched PLT trampoline was detected
9129 + */
9130 +static int pax_handle_fetch_fault(struct pt_regs *regs)
9131 +{
9132 +
9133 +#ifdef CONFIG_PAX_EMUPLT
9134 + int err;
9135 +
9136 + do { /* PaX: patched PLT emulation #1 */
9137 + unsigned int sethi1, sethi2, jmpl;
9138 +
9139 + err = get_user(sethi1, (unsigned int *)regs->pc);
9140 + err |= get_user(sethi2, (unsigned int *)(regs->pc+4));
9141 + err |= get_user(jmpl, (unsigned int *)(regs->pc+8));
9142 +
9143 + if (err)
9144 + break;
9145 +
9146 + if ((sethi1 & 0xFFC00000U) == 0x03000000U &&
9147 + (sethi2 & 0xFFC00000U) == 0x03000000U &&
9148 + (jmpl & 0xFFFFE000U) == 0x81C06000U)
9149 + {
9150 + unsigned int addr;
9151 +
9152 + regs->u_regs[UREG_G1] = (sethi2 & 0x003FFFFFU) << 10;
9153 + addr = regs->u_regs[UREG_G1];
9154 + addr += (((jmpl | 0xFFFFE000U) ^ 0x00001000U) + 0x00001000U);
9155 + regs->pc = addr;
9156 + regs->npc = addr+4;
9157 + return 2;
9158 + }
9159 + } while (0);
9160 +
9161 + do { /* PaX: patched PLT emulation #2 */
9162 + unsigned int ba;
9163 +
9164 + err = get_user(ba, (unsigned int *)regs->pc);
9165 +
9166 + if (err)
9167 + break;
9168 +
9169 + if ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30480000U) {
9170 + unsigned int addr;
9171 +
9172 + if ((ba & 0xFFC00000U) == 0x30800000U)
9173 + addr = regs->pc + ((((ba | 0xFFC00000U) ^ 0x00200000U) + 0x00200000U) << 2);
9174 + else
9175 + addr = regs->pc + ((((ba | 0xFFF80000U) ^ 0x00040000U) + 0x00040000U) << 2);
9176 + regs->pc = addr;
9177 + regs->npc = addr+4;
9178 + return 2;
9179 + }
9180 + } while (0);
9181 +
9182 + do { /* PaX: patched PLT emulation #3 */
9183 + unsigned int sethi, bajmpl, nop;
9184 +
9185 + err = get_user(sethi, (unsigned int *)regs->pc);
9186 + err |= get_user(bajmpl, (unsigned int *)(regs->pc+4));
9187 + err |= get_user(nop, (unsigned int *)(regs->pc+8));
9188 +
9189 + if (err)
9190 + break;
9191 +
9192 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
9193 + ((bajmpl & 0xFFFFE000U) == 0x81C06000U || (bajmpl & 0xFFF80000U) == 0x30480000U) &&
9194 + nop == 0x01000000U)
9195 + {
9196 + unsigned int addr;
9197 +
9198 + addr = (sethi & 0x003FFFFFU) << 10;
9199 + regs->u_regs[UREG_G1] = addr;
9200 + if ((bajmpl & 0xFFFFE000U) == 0x81C06000U)
9201 + addr += (((bajmpl | 0xFFFFE000U) ^ 0x00001000U) + 0x00001000U);
9202 + else
9203 + addr = regs->pc + ((((bajmpl | 0xFFF80000U) ^ 0x00040000U) + 0x00040000U) << 2);
9204 + regs->pc = addr;
9205 + regs->npc = addr+4;
9206 + return 2;
9207 + }
9208 + } while (0);
9209 +
9210 + do { /* PaX: unpatched PLT emulation step 1 */
9211 + unsigned int sethi, ba, nop;
9212 +
9213 + err = get_user(sethi, (unsigned int *)regs->pc);
9214 + err |= get_user(ba, (unsigned int *)(regs->pc+4));
9215 + err |= get_user(nop, (unsigned int *)(regs->pc+8));
9216 +
9217 + if (err)
9218 + break;
9219 +
9220 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
9221 + ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30680000U) &&
9222 + nop == 0x01000000U)
9223 + {
9224 + unsigned int addr, save, call;
9225 +
9226 + if ((ba & 0xFFC00000U) == 0x30800000U)
9227 + addr = regs->pc + 4 + ((((ba | 0xFFC00000U) ^ 0x00200000U) + 0x00200000U) << 2);
9228 + else
9229 + addr = regs->pc + 4 + ((((ba | 0xFFF80000U) ^ 0x00040000U) + 0x00040000U) << 2);
9230 +
9231 + err = get_user(save, (unsigned int *)addr);
9232 + err |= get_user(call, (unsigned int *)(addr+4));
9233 + err |= get_user(nop, (unsigned int *)(addr+8));
9234 + if (err)
9235 + break;
9236 +
9237 +#ifdef CONFIG_PAX_DLRESOLVE
9238 + if (save == 0x9DE3BFA8U &&
9239 + (call & 0xC0000000U) == 0x40000000U &&
9240 + nop == 0x01000000U)
9241 + {
9242 + struct vm_area_struct *vma;
9243 + unsigned long call_dl_resolve;
9244 +
9245 + down_read(&current->mm->mmap_sem);
9246 + call_dl_resolve = current->mm->call_dl_resolve;
9247 + up_read(&current->mm->mmap_sem);
9248 + if (likely(call_dl_resolve))
9249 + goto emulate;
9250 +
9251 + vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
9252 +
9253 + down_write(&current->mm->mmap_sem);
9254 + if (current->mm->call_dl_resolve) {
9255 + call_dl_resolve = current->mm->call_dl_resolve;
9256 + up_write(&current->mm->mmap_sem);
9257 + if (vma)
9258 + kmem_cache_free(vm_area_cachep, vma);
9259 + goto emulate;
9260 + }
9261 +
9262 + call_dl_resolve = get_unmapped_area(NULL, 0UL, PAGE_SIZE, 0UL, MAP_PRIVATE);
9263 + if (!vma || (call_dl_resolve & ~PAGE_MASK)) {
9264 + up_write(&current->mm->mmap_sem);
9265 + if (vma)
9266 + kmem_cache_free(vm_area_cachep, vma);
9267 + return 1;
9268 + }
9269 +
9270 + if (pax_insert_vma(vma, call_dl_resolve)) {
9271 + up_write(&current->mm->mmap_sem);
9272 + kmem_cache_free(vm_area_cachep, vma);
9273 + return 1;
9274 + }
9275 +
9276 + current->mm->call_dl_resolve = call_dl_resolve;
9277 + up_write(&current->mm->mmap_sem);
9278 +
9279 +emulate:
9280 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
9281 + regs->pc = call_dl_resolve;
9282 + regs->npc = addr+4;
9283 + return 3;
9284 + }
9285 +#endif
9286 +
9287 + /* PaX: glibc 2.4+ generates sethi/jmpl instead of save/call */
9288 + if ((save & 0xFFC00000U) == 0x05000000U &&
9289 + (call & 0xFFFFE000U) == 0x85C0A000U &&
9290 + nop == 0x01000000U)
9291 + {
9292 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
9293 + regs->u_regs[UREG_G2] = addr + 4;
9294 + addr = (save & 0x003FFFFFU) << 10;
9295 + addr += (((call | 0xFFFFE000U) ^ 0x00001000U) + 0x00001000U);
9296 + regs->pc = addr;
9297 + regs->npc = addr+4;
9298 + return 3;
9299 + }
9300 + }
9301 + } while (0);
9302 +
9303 + do { /* PaX: unpatched PLT emulation step 2 */
9304 + unsigned int save, call, nop;
9305 +
9306 + err = get_user(save, (unsigned int *)(regs->pc-4));
9307 + err |= get_user(call, (unsigned int *)regs->pc);
9308 + err |= get_user(nop, (unsigned int *)(regs->pc+4));
9309 + if (err)
9310 + break;
9311 +
9312 + if (save == 0x9DE3BFA8U &&
9313 + (call & 0xC0000000U) == 0x40000000U &&
9314 + nop == 0x01000000U)
9315 + {
9316 + unsigned int dl_resolve = regs->pc + ((((call | 0xC0000000U) ^ 0x20000000U) + 0x20000000U) << 2);
9317 +
9318 + regs->u_regs[UREG_RETPC] = regs->pc;
9319 + regs->pc = dl_resolve;
9320 + regs->npc = dl_resolve+4;
9321 + return 3;
9322 + }
9323 + } while (0);
9324 +#endif
9325 +
9326 + return 1;
9327 +}
9328 +
9329 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
9330 +{
9331 + unsigned long i;
9332 +
9333 + printk(KERN_ERR "PAX: bytes at PC: ");
9334 + for (i = 0; i < 8; i++) {
9335 + unsigned int c;
9336 + if (get_user(c, (unsigned int *)pc+i))
9337 + printk(KERN_CONT "???????? ");
9338 + else
9339 + printk(KERN_CONT "%08x ", c);
9340 + }
9341 + printk("\n");
9342 +}
9343 +#endif
9344 +
9345 static noinline void do_fault_siginfo(int code, int sig, struct pt_regs *regs,
9346 int text_fault)
9347 {
9348 @@ -230,6 +504,24 @@ good_area:
9349 if (!(vma->vm_flags & VM_WRITE))
9350 goto bad_area;
9351 } else {
9352 +
9353 +#ifdef CONFIG_PAX_PAGEEXEC
9354 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && text_fault && !(vma->vm_flags & VM_EXEC)) {
9355 + up_read(&mm->mmap_sem);
9356 + switch (pax_handle_fetch_fault(regs)) {
9357 +
9358 +#ifdef CONFIG_PAX_EMUPLT
9359 + case 2:
9360 + case 3:
9361 + return;
9362 +#endif
9363 +
9364 + }
9365 + pax_report_fault(regs, (void *)regs->pc, (void *)regs->u_regs[UREG_FP]);
9366 + do_group_exit(SIGKILL);
9367 + }
9368 +#endif
9369 +
9370 /* Allow reads even for write-only mappings */
9371 if (!(vma->vm_flags & (VM_READ | VM_EXEC)))
9372 goto bad_area;
9373 diff --git a/arch/sparc/mm/fault_64.c b/arch/sparc/mm/fault_64.c
9374 index 5062ff3..e0b75f3 100644
9375 --- a/arch/sparc/mm/fault_64.c
9376 +++ b/arch/sparc/mm/fault_64.c
9377 @@ -21,6 +21,9 @@
9378 #include <linux/kprobes.h>
9379 #include <linux/kdebug.h>
9380 #include <linux/percpu.h>
9381 +#include <linux/slab.h>
9382 +#include <linux/pagemap.h>
9383 +#include <linux/compiler.h>
9384
9385 #include <asm/page.h>
9386 #include <asm/pgtable.h>
9387 @@ -74,7 +77,7 @@ static void __kprobes bad_kernel_pc(struct pt_regs *regs, unsigned long vaddr)
9388 printk(KERN_CRIT "OOPS: Bogus kernel PC [%016lx] in fault handler\n",
9389 regs->tpc);
9390 printk(KERN_CRIT "OOPS: RPC [%016lx]\n", regs->u_regs[15]);
9391 - printk("OOPS: RPC <%pS>\n", (void *) regs->u_regs[15]);
9392 + printk("OOPS: RPC <%pA>\n", (void *) regs->u_regs[15]);
9393 printk(KERN_CRIT "OOPS: Fault was to vaddr[%lx]\n", vaddr);
9394 dump_stack();
9395 unhandled_fault(regs->tpc, current, regs);
9396 @@ -270,6 +273,466 @@ static void noinline __kprobes bogus_32bit_fault_address(struct pt_regs *regs,
9397 show_regs(regs);
9398 }
9399
9400 +#ifdef CONFIG_PAX_PAGEEXEC
9401 +#ifdef CONFIG_PAX_DLRESOLVE
9402 +static void pax_emuplt_close(struct vm_area_struct *vma)
9403 +{
9404 + vma->vm_mm->call_dl_resolve = 0UL;
9405 +}
9406 +
9407 +static int pax_emuplt_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
9408 +{
9409 + unsigned int *kaddr;
9410 +
9411 + vmf->page = alloc_page(GFP_HIGHUSER);
9412 + if (!vmf->page)
9413 + return VM_FAULT_OOM;
9414 +
9415 + kaddr = kmap(vmf->page);
9416 + memset(kaddr, 0, PAGE_SIZE);
9417 + kaddr[0] = 0x9DE3BFA8U; /* save */
9418 + flush_dcache_page(vmf->page);
9419 + kunmap(vmf->page);
9420 + return VM_FAULT_MAJOR;
9421 +}
9422 +
9423 +static const struct vm_operations_struct pax_vm_ops = {
9424 + .close = pax_emuplt_close,
9425 + .fault = pax_emuplt_fault
9426 +};
9427 +
9428 +static int pax_insert_vma(struct vm_area_struct *vma, unsigned long addr)
9429 +{
9430 + int ret;
9431 +
9432 + INIT_LIST_HEAD(&vma->anon_vma_chain);
9433 + vma->vm_mm = current->mm;
9434 + vma->vm_start = addr;
9435 + vma->vm_end = addr + PAGE_SIZE;
9436 + vma->vm_flags = VM_READ | VM_EXEC | VM_MAYREAD | VM_MAYEXEC;
9437 + vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
9438 + vma->vm_ops = &pax_vm_ops;
9439 +
9440 + ret = insert_vm_struct(current->mm, vma);
9441 + if (ret)
9442 + return ret;
9443 +
9444 + ++current->mm->total_vm;
9445 + return 0;
9446 +}
9447 +#endif
9448 +
9449 +/*
9450 + * PaX: decide what to do with offenders (regs->tpc = fault address)
9451 + *
9452 + * returns 1 when task should be killed
9453 + * 2 when patched PLT trampoline was detected
9454 + * 3 when unpatched PLT trampoline was detected
9455 + */
9456 +static int pax_handle_fetch_fault(struct pt_regs *regs)
9457 +{
9458 +
9459 +#ifdef CONFIG_PAX_EMUPLT
9460 + int err;
9461 +
9462 + do { /* PaX: patched PLT emulation #1 */
9463 + unsigned int sethi1, sethi2, jmpl;
9464 +
9465 + err = get_user(sethi1, (unsigned int *)regs->tpc);
9466 + err |= get_user(sethi2, (unsigned int *)(regs->tpc+4));
9467 + err |= get_user(jmpl, (unsigned int *)(regs->tpc+8));
9468 +
9469 + if (err)
9470 + break;
9471 +
9472 + if ((sethi1 & 0xFFC00000U) == 0x03000000U &&
9473 + (sethi2 & 0xFFC00000U) == 0x03000000U &&
9474 + (jmpl & 0xFFFFE000U) == 0x81C06000U)
9475 + {
9476 + unsigned long addr;
9477 +
9478 + regs->u_regs[UREG_G1] = (sethi2 & 0x003FFFFFU) << 10;
9479 + addr = regs->u_regs[UREG_G1];
9480 + addr += (((jmpl | 0xFFFFFFFFFFFFE000UL) ^ 0x00001000UL) + 0x00001000UL);
9481 +
9482 + if (test_thread_flag(TIF_32BIT))
9483 + addr &= 0xFFFFFFFFUL;
9484 +
9485 + regs->tpc = addr;
9486 + regs->tnpc = addr+4;
9487 + return 2;
9488 + }
9489 + } while (0);
9490 +
9491 + do { /* PaX: patched PLT emulation #2 */
9492 + unsigned int ba;
9493 +
9494 + err = get_user(ba, (unsigned int *)regs->tpc);
9495 +
9496 + if (err)
9497 + break;
9498 +
9499 + if ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30480000U) {
9500 + unsigned long addr;
9501 +
9502 + if ((ba & 0xFFC00000U) == 0x30800000U)
9503 + addr = regs->tpc + ((((ba | 0xFFFFFFFFFFC00000UL) ^ 0x00200000UL) + 0x00200000UL) << 2);
9504 + else
9505 + addr = regs->tpc + ((((ba | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
9506 +
9507 + if (test_thread_flag(TIF_32BIT))
9508 + addr &= 0xFFFFFFFFUL;
9509 +
9510 + regs->tpc = addr;
9511 + regs->tnpc = addr+4;
9512 + return 2;
9513 + }
9514 + } while (0);
9515 +
9516 + do { /* PaX: patched PLT emulation #3 */
9517 + unsigned int sethi, bajmpl, nop;
9518 +
9519 + err = get_user(sethi, (unsigned int *)regs->tpc);
9520 + err |= get_user(bajmpl, (unsigned int *)(regs->tpc+4));
9521 + err |= get_user(nop, (unsigned int *)(regs->tpc+8));
9522 +
9523 + if (err)
9524 + break;
9525 +
9526 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
9527 + ((bajmpl & 0xFFFFE000U) == 0x81C06000U || (bajmpl & 0xFFF80000U) == 0x30480000U) &&
9528 + nop == 0x01000000U)
9529 + {
9530 + unsigned long addr;
9531 +
9532 + addr = (sethi & 0x003FFFFFU) << 10;
9533 + regs->u_regs[UREG_G1] = addr;
9534 + if ((bajmpl & 0xFFFFE000U) == 0x81C06000U)
9535 + addr += (((bajmpl | 0xFFFFFFFFFFFFE000UL) ^ 0x00001000UL) + 0x00001000UL);
9536 + else
9537 + addr = regs->tpc + ((((bajmpl | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
9538 +
9539 + if (test_thread_flag(TIF_32BIT))
9540 + addr &= 0xFFFFFFFFUL;
9541 +
9542 + regs->tpc = addr;
9543 + regs->tnpc = addr+4;
9544 + return 2;
9545 + }
9546 + } while (0);
9547 +
9548 + do { /* PaX: patched PLT emulation #4 */
9549 + unsigned int sethi, mov1, call, mov2;
9550 +
9551 + err = get_user(sethi, (unsigned int *)regs->tpc);
9552 + err |= get_user(mov1, (unsigned int *)(regs->tpc+4));
9553 + err |= get_user(call, (unsigned int *)(regs->tpc+8));
9554 + err |= get_user(mov2, (unsigned int *)(regs->tpc+12));
9555 +
9556 + if (err)
9557 + break;
9558 +
9559 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
9560 + mov1 == 0x8210000FU &&
9561 + (call & 0xC0000000U) == 0x40000000U &&
9562 + mov2 == 0x9E100001U)
9563 + {
9564 + unsigned long addr;
9565 +
9566 + regs->u_regs[UREG_G1] = regs->u_regs[UREG_RETPC];
9567 + addr = regs->tpc + 4 + ((((call | 0xFFFFFFFFC0000000UL) ^ 0x20000000UL) + 0x20000000UL) << 2);
9568 +
9569 + if (test_thread_flag(TIF_32BIT))
9570 + addr &= 0xFFFFFFFFUL;
9571 +
9572 + regs->tpc = addr;
9573 + regs->tnpc = addr+4;
9574 + return 2;
9575 + }
9576 + } while (0);
9577 +
9578 + do { /* PaX: patched PLT emulation #5 */
9579 + unsigned int sethi, sethi1, sethi2, or1, or2, sllx, jmpl, nop;
9580 +
9581 + err = get_user(sethi, (unsigned int *)regs->tpc);
9582 + err |= get_user(sethi1, (unsigned int *)(regs->tpc+4));
9583 + err |= get_user(sethi2, (unsigned int *)(regs->tpc+8));
9584 + err |= get_user(or1, (unsigned int *)(regs->tpc+12));
9585 + err |= get_user(or2, (unsigned int *)(regs->tpc+16));
9586 + err |= get_user(sllx, (unsigned int *)(regs->tpc+20));
9587 + err |= get_user(jmpl, (unsigned int *)(regs->tpc+24));
9588 + err |= get_user(nop, (unsigned int *)(regs->tpc+28));
9589 +
9590 + if (err)
9591 + break;
9592 +
9593 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
9594 + (sethi1 & 0xFFC00000U) == 0x03000000U &&
9595 + (sethi2 & 0xFFC00000U) == 0x0B000000U &&
9596 + (or1 & 0xFFFFE000U) == 0x82106000U &&
9597 + (or2 & 0xFFFFE000U) == 0x8A116000U &&
9598 + sllx == 0x83287020U &&
9599 + jmpl == 0x81C04005U &&
9600 + nop == 0x01000000U)
9601 + {
9602 + unsigned long addr;
9603 +
9604 + regs->u_regs[UREG_G1] = ((sethi1 & 0x003FFFFFU) << 10) | (or1 & 0x000003FFU);
9605 + regs->u_regs[UREG_G1] <<= 32;
9606 + regs->u_regs[UREG_G5] = ((sethi2 & 0x003FFFFFU) << 10) | (or2 & 0x000003FFU);
9607 + addr = regs->u_regs[UREG_G1] + regs->u_regs[UREG_G5];
9608 + regs->tpc = addr;
9609 + regs->tnpc = addr+4;
9610 + return 2;
9611 + }
9612 + } while (0);
9613 +
9614 + do { /* PaX: patched PLT emulation #6 */
9615 + unsigned int sethi, sethi1, sethi2, sllx, or, jmpl, nop;
9616 +
9617 + err = get_user(sethi, (unsigned int *)regs->tpc);
9618 + err |= get_user(sethi1, (unsigned int *)(regs->tpc+4));
9619 + err |= get_user(sethi2, (unsigned int *)(regs->tpc+8));
9620 + err |= get_user(sllx, (unsigned int *)(regs->tpc+12));
9621 + err |= get_user(or, (unsigned int *)(regs->tpc+16));
9622 + err |= get_user(jmpl, (unsigned int *)(regs->tpc+20));
9623 + err |= get_user(nop, (unsigned int *)(regs->tpc+24));
9624 +
9625 + if (err)
9626 + break;
9627 +
9628 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
9629 + (sethi1 & 0xFFC00000U) == 0x03000000U &&
9630 + (sethi2 & 0xFFC00000U) == 0x0B000000U &&
9631 + sllx == 0x83287020U &&
9632 + (or & 0xFFFFE000U) == 0x8A116000U &&
9633 + jmpl == 0x81C04005U &&
9634 + nop == 0x01000000U)
9635 + {
9636 + unsigned long addr;
9637 +
9638 + regs->u_regs[UREG_G1] = (sethi1 & 0x003FFFFFU) << 10;
9639 + regs->u_regs[UREG_G1] <<= 32;
9640 + regs->u_regs[UREG_G5] = ((sethi2 & 0x003FFFFFU) << 10) | (or & 0x3FFU);
9641 + addr = regs->u_regs[UREG_G1] + regs->u_regs[UREG_G5];
9642 + regs->tpc = addr;
9643 + regs->tnpc = addr+4;
9644 + return 2;
9645 + }
9646 + } while (0);
9647 +
9648 + do { /* PaX: unpatched PLT emulation step 1 */
9649 + unsigned int sethi, ba, nop;
9650 +
9651 + err = get_user(sethi, (unsigned int *)regs->tpc);
9652 + err |= get_user(ba, (unsigned int *)(regs->tpc+4));
9653 + err |= get_user(nop, (unsigned int *)(regs->tpc+8));
9654 +
9655 + if (err)
9656 + break;
9657 +
9658 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
9659 + ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30680000U) &&
9660 + nop == 0x01000000U)
9661 + {
9662 + unsigned long addr;
9663 + unsigned int save, call;
9664 + unsigned int sethi1, sethi2, or1, or2, sllx, add, jmpl;
9665 +
9666 + if ((ba & 0xFFC00000U) == 0x30800000U)
9667 + addr = regs->tpc + 4 + ((((ba | 0xFFFFFFFFFFC00000UL) ^ 0x00200000UL) + 0x00200000UL) << 2);
9668 + else
9669 + addr = regs->tpc + 4 + ((((ba | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
9670 +
9671 + if (test_thread_flag(TIF_32BIT))
9672 + addr &= 0xFFFFFFFFUL;
9673 +
9674 + err = get_user(save, (unsigned int *)addr);
9675 + err |= get_user(call, (unsigned int *)(addr+4));
9676 + err |= get_user(nop, (unsigned int *)(addr+8));
9677 + if (err)
9678 + break;
9679 +
9680 +#ifdef CONFIG_PAX_DLRESOLVE
9681 + if (save == 0x9DE3BFA8U &&
9682 + (call & 0xC0000000U) == 0x40000000U &&
9683 + nop == 0x01000000U)
9684 + {
9685 + struct vm_area_struct *vma;
9686 + unsigned long call_dl_resolve;
9687 +
9688 + down_read(&current->mm->mmap_sem);
9689 + call_dl_resolve = current->mm->call_dl_resolve;
9690 + up_read(&current->mm->mmap_sem);
9691 + if (likely(call_dl_resolve))
9692 + goto emulate;
9693 +
9694 + vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
9695 +
9696 + down_write(&current->mm->mmap_sem);
9697 + if (current->mm->call_dl_resolve) {
9698 + call_dl_resolve = current->mm->call_dl_resolve;
9699 + up_write(&current->mm->mmap_sem);
9700 + if (vma)
9701 + kmem_cache_free(vm_area_cachep, vma);
9702 + goto emulate;
9703 + }
9704 +
9705 + call_dl_resolve = get_unmapped_area(NULL, 0UL, PAGE_SIZE, 0UL, MAP_PRIVATE);
9706 + if (!vma || (call_dl_resolve & ~PAGE_MASK)) {
9707 + up_write(&current->mm->mmap_sem);
9708 + if (vma)
9709 + kmem_cache_free(vm_area_cachep, vma);
9710 + return 1;
9711 + }
9712 +
9713 + if (pax_insert_vma(vma, call_dl_resolve)) {
9714 + up_write(&current->mm->mmap_sem);
9715 + kmem_cache_free(vm_area_cachep, vma);
9716 + return 1;
9717 + }
9718 +
9719 + current->mm->call_dl_resolve = call_dl_resolve;
9720 + up_write(&current->mm->mmap_sem);
9721 +
9722 +emulate:
9723 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
9724 + regs->tpc = call_dl_resolve;
9725 + regs->tnpc = addr+4;
9726 + return 3;
9727 + }
9728 +#endif
9729 +
9730 + /* PaX: glibc 2.4+ generates sethi/jmpl instead of save/call */
9731 + if ((save & 0xFFC00000U) == 0x05000000U &&
9732 + (call & 0xFFFFE000U) == 0x85C0A000U &&
9733 + nop == 0x01000000U)
9734 + {
9735 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
9736 + regs->u_regs[UREG_G2] = addr + 4;
9737 + addr = (save & 0x003FFFFFU) << 10;
9738 + addr += (((call | 0xFFFFFFFFFFFFE000UL) ^ 0x00001000UL) + 0x00001000UL);
9739 +
9740 + if (test_thread_flag(TIF_32BIT))
9741 + addr &= 0xFFFFFFFFUL;
9742 +
9743 + regs->tpc = addr;
9744 + regs->tnpc = addr+4;
9745 + return 3;
9746 + }
9747 +
9748 + /* PaX: 64-bit PLT stub */
9749 + err = get_user(sethi1, (unsigned int *)addr);
9750 + err |= get_user(sethi2, (unsigned int *)(addr+4));
9751 + err |= get_user(or1, (unsigned int *)(addr+8));
9752 + err |= get_user(or2, (unsigned int *)(addr+12));
9753 + err |= get_user(sllx, (unsigned int *)(addr+16));
9754 + err |= get_user(add, (unsigned int *)(addr+20));
9755 + err |= get_user(jmpl, (unsigned int *)(addr+24));
9756 + err |= get_user(nop, (unsigned int *)(addr+28));
9757 + if (err)
9758 + break;
9759 +
9760 + if ((sethi1 & 0xFFC00000U) == 0x09000000U &&
9761 + (sethi2 & 0xFFC00000U) == 0x0B000000U &&
9762 + (or1 & 0xFFFFE000U) == 0x88112000U &&
9763 + (or2 & 0xFFFFE000U) == 0x8A116000U &&
9764 + sllx == 0x89293020U &&
9765 + add == 0x8A010005U &&
9766 + jmpl == 0x89C14000U &&
9767 + nop == 0x01000000U)
9768 + {
9769 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
9770 + regs->u_regs[UREG_G4] = ((sethi1 & 0x003FFFFFU) << 10) | (or1 & 0x000003FFU);
9771 + regs->u_regs[UREG_G4] <<= 32;
9772 + regs->u_regs[UREG_G5] = ((sethi2 & 0x003FFFFFU) << 10) | (or2 & 0x000003FFU);
9773 + regs->u_regs[UREG_G5] += regs->u_regs[UREG_G4];
9774 + regs->u_regs[UREG_G4] = addr + 24;
9775 + addr = regs->u_regs[UREG_G5];
9776 + regs->tpc = addr;
9777 + regs->tnpc = addr+4;
9778 + return 3;
9779 + }
9780 + }
9781 + } while (0);
9782 +
9783 +#ifdef CONFIG_PAX_DLRESOLVE
9784 + do { /* PaX: unpatched PLT emulation step 2 */
9785 + unsigned int save, call, nop;
9786 +
9787 + err = get_user(save, (unsigned int *)(regs->tpc-4));
9788 + err |= get_user(call, (unsigned int *)regs->tpc);
9789 + err |= get_user(nop, (unsigned int *)(regs->tpc+4));
9790 + if (err)
9791 + break;
9792 +
9793 + if (save == 0x9DE3BFA8U &&
9794 + (call & 0xC0000000U) == 0x40000000U &&
9795 + nop == 0x01000000U)
9796 + {
9797 + unsigned long dl_resolve = regs->tpc + ((((call | 0xFFFFFFFFC0000000UL) ^ 0x20000000UL) + 0x20000000UL) << 2);
9798 +
9799 + if (test_thread_flag(TIF_32BIT))
9800 + dl_resolve &= 0xFFFFFFFFUL;
9801 +
9802 + regs->u_regs[UREG_RETPC] = regs->tpc;
9803 + regs->tpc = dl_resolve;
9804 + regs->tnpc = dl_resolve+4;
9805 + return 3;
9806 + }
9807 + } while (0);
9808 +#endif
9809 +
9810 + do { /* PaX: patched PLT emulation #7, must be AFTER the unpatched PLT emulation */
9811 + unsigned int sethi, ba, nop;
9812 +
9813 + err = get_user(sethi, (unsigned int *)regs->tpc);
9814 + err |= get_user(ba, (unsigned int *)(regs->tpc+4));
9815 + err |= get_user(nop, (unsigned int *)(regs->tpc+8));
9816 +
9817 + if (err)
9818 + break;
9819 +
9820 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
9821 + (ba & 0xFFF00000U) == 0x30600000U &&
9822 + nop == 0x01000000U)
9823 + {
9824 + unsigned long addr;
9825 +
9826 + addr = (sethi & 0x003FFFFFU) << 10;
9827 + regs->u_regs[UREG_G1] = addr;
9828 + addr = regs->tpc + ((((ba | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
9829 +
9830 + if (test_thread_flag(TIF_32BIT))
9831 + addr &= 0xFFFFFFFFUL;
9832 +
9833 + regs->tpc = addr;
9834 + regs->tnpc = addr+4;
9835 + return 2;
9836 + }
9837 + } while (0);
9838 +
9839 +#endif
9840 +
9841 + return 1;
9842 +}
9843 +
9844 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
9845 +{
9846 + unsigned long i;
9847 +
9848 + printk(KERN_ERR "PAX: bytes at PC: ");
9849 + for (i = 0; i < 8; i++) {
9850 + unsigned int c;
9851 + if (get_user(c, (unsigned int *)pc+i))
9852 + printk(KERN_CONT "???????? ");
9853 + else
9854 + printk(KERN_CONT "%08x ", c);
9855 + }
9856 + printk("\n");
9857 +}
9858 +#endif
9859 +
9860 asmlinkage void __kprobes do_sparc64_fault(struct pt_regs *regs)
9861 {
9862 struct mm_struct *mm = current->mm;
9863 @@ -341,6 +804,29 @@ retry:
9864 if (!vma)
9865 goto bad_area;
9866
9867 +#ifdef CONFIG_PAX_PAGEEXEC
9868 + /* PaX: detect ITLB misses on non-exec pages */
9869 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && vma->vm_start <= address &&
9870 + !(vma->vm_flags & VM_EXEC) && (fault_code & FAULT_CODE_ITLB))
9871 + {
9872 + if (address != regs->tpc)
9873 + goto good_area;
9874 +
9875 + up_read(&mm->mmap_sem);
9876 + switch (pax_handle_fetch_fault(regs)) {
9877 +
9878 +#ifdef CONFIG_PAX_EMUPLT
9879 + case 2:
9880 + case 3:
9881 + return;
9882 +#endif
9883 +
9884 + }
9885 + pax_report_fault(regs, (void *)regs->tpc, (void *)(regs->u_regs[UREG_FP] + STACK_BIAS));
9886 + do_group_exit(SIGKILL);
9887 + }
9888 +#endif
9889 +
9890 /* Pure DTLB misses do not tell us whether the fault causing
9891 * load/store/atomic was a write or not, it only says that there
9892 * was no match. So in such a case we (carefully) read the
9893 diff --git a/arch/sparc/mm/hugetlbpage.c b/arch/sparc/mm/hugetlbpage.c
9894 index d2b5944..bd813f2 100644
9895 --- a/arch/sparc/mm/hugetlbpage.c
9896 +++ b/arch/sparc/mm/hugetlbpage.c
9897 @@ -38,7 +38,7 @@ static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *filp,
9898
9899 info.flags = 0;
9900 info.length = len;
9901 - info.low_limit = TASK_UNMAPPED_BASE;
9902 + info.low_limit = mm->mmap_base;
9903 info.high_limit = min(task_size, VA_EXCLUDE_START);
9904 info.align_mask = PAGE_MASK & ~HPAGE_MASK;
9905 info.align_offset = 0;
9906 @@ -47,6 +47,12 @@ static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *filp,
9907 if ((addr & ~PAGE_MASK) && task_size > VA_EXCLUDE_END) {
9908 VM_BUG_ON(addr != -ENOMEM);
9909 info.low_limit = VA_EXCLUDE_END;
9910 +
9911 +#ifdef CONFIG_PAX_RANDMMAP
9912 + if (mm->pax_flags & MF_PAX_RANDMMAP)
9913 + info.low_limit += mm->delta_mmap;
9914 +#endif
9915 +
9916 info.high_limit = task_size;
9917 addr = vm_unmapped_area(&info);
9918 }
9919 @@ -85,6 +91,12 @@ hugetlb_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
9920 VM_BUG_ON(addr != -ENOMEM);
9921 info.flags = 0;
9922 info.low_limit = TASK_UNMAPPED_BASE;
9923 +
9924 +#ifdef CONFIG_PAX_RANDMMAP
9925 + if (mm->pax_flags & MF_PAX_RANDMMAP)
9926 + info.low_limit += mm->delta_mmap;
9927 +#endif
9928 +
9929 info.high_limit = STACK_TOP32;
9930 addr = vm_unmapped_area(&info);
9931 }
9932 @@ -99,6 +111,7 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
9933 struct mm_struct *mm = current->mm;
9934 struct vm_area_struct *vma;
9935 unsigned long task_size = TASK_SIZE;
9936 + unsigned long offset = gr_rand_threadstack_offset(mm, file, flags);
9937
9938 if (test_thread_flag(TIF_32BIT))
9939 task_size = STACK_TOP32;
9940 @@ -114,11 +127,14 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
9941 return addr;
9942 }
9943
9944 +#ifdef CONFIG_PAX_RANDMMAP
9945 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
9946 +#endif
9947 +
9948 if (addr) {
9949 addr = ALIGN(addr, HPAGE_SIZE);
9950 vma = find_vma(mm, addr);
9951 - if (task_size - len >= addr &&
9952 - (!vma || addr + len <= vma->vm_start))
9953 + if (task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
9954 return addr;
9955 }
9956 if (mm->get_unmapped_area == arch_get_unmapped_area)
9957 diff --git a/arch/tile/include/asm/atomic_64.h b/arch/tile/include/asm/atomic_64.h
9958 index f4500c6..889656c 100644
9959 --- a/arch/tile/include/asm/atomic_64.h
9960 +++ b/arch/tile/include/asm/atomic_64.h
9961 @@ -143,6 +143,16 @@ static inline long atomic64_add_unless(atomic64_t *v, long a, long u)
9962
9963 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
9964
9965 +#define atomic64_read_unchecked(v) atomic64_read(v)
9966 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
9967 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
9968 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
9969 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
9970 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
9971 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
9972 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
9973 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
9974 +
9975 /* Atomic dec and inc don't implement barrier, so provide them if needed. */
9976 #define smp_mb__before_atomic_dec() smp_mb()
9977 #define smp_mb__after_atomic_dec() smp_mb()
9978 diff --git a/arch/tile/include/asm/cache.h b/arch/tile/include/asm/cache.h
9979 index a9a5299..0fce79e 100644
9980 --- a/arch/tile/include/asm/cache.h
9981 +++ b/arch/tile/include/asm/cache.h
9982 @@ -15,11 +15,12 @@
9983 #ifndef _ASM_TILE_CACHE_H
9984 #define _ASM_TILE_CACHE_H
9985
9986 +#include <linux/const.h>
9987 #include <arch/chip.h>
9988
9989 /* bytes per L1 data cache line */
9990 #define L1_CACHE_SHIFT CHIP_L1D_LOG_LINE_SIZE()
9991 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
9992 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
9993
9994 /* bytes per L2 cache line */
9995 #define L2_CACHE_SHIFT CHIP_L2_LOG_LINE_SIZE()
9996 diff --git a/arch/tile/include/asm/uaccess.h b/arch/tile/include/asm/uaccess.h
9997 index 9ab078a..d6635c2 100644
9998 --- a/arch/tile/include/asm/uaccess.h
9999 +++ b/arch/tile/include/asm/uaccess.h
10000 @@ -403,9 +403,9 @@ static inline unsigned long __must_check copy_from_user(void *to,
10001 const void __user *from,
10002 unsigned long n)
10003 {
10004 - int sz = __compiletime_object_size(to);
10005 + size_t sz = __compiletime_object_size(to);
10006
10007 - if (likely(sz == -1 || sz >= n))
10008 + if (likely(sz == (size_t)-1 || sz >= n))
10009 n = _copy_from_user(to, from, n);
10010 else
10011 copy_from_user_overflow();
10012 diff --git a/arch/um/Makefile b/arch/um/Makefile
10013 index 133f7de..1d6f2f1 100644
10014 --- a/arch/um/Makefile
10015 +++ b/arch/um/Makefile
10016 @@ -62,6 +62,10 @@ USER_CFLAGS = $(patsubst $(KERNEL_DEFINES),,$(patsubst -D__KERNEL__,,\
10017 $(patsubst -I%,,$(KBUILD_CFLAGS)))) $(ARCH_INCLUDE) $(MODE_INCLUDE) \
10018 $(filter -I%,$(CFLAGS)) -D_FILE_OFFSET_BITS=64 -idirafter include
10019
10020 +ifdef CONSTIFY_PLUGIN
10021 +USER_CFLAGS += -fplugin-arg-constify_plugin-no-constify
10022 +endif
10023 +
10024 #This will adjust *FLAGS accordingly to the platform.
10025 include $(srctree)/$(ARCH_DIR)/Makefile-os-$(OS)
10026
10027 diff --git a/arch/um/include/asm/cache.h b/arch/um/include/asm/cache.h
10028 index 19e1bdd..3665b77 100644
10029 --- a/arch/um/include/asm/cache.h
10030 +++ b/arch/um/include/asm/cache.h
10031 @@ -1,6 +1,7 @@
10032 #ifndef __UM_CACHE_H
10033 #define __UM_CACHE_H
10034
10035 +#include <linux/const.h>
10036
10037 #if defined(CONFIG_UML_X86) && !defined(CONFIG_64BIT)
10038 # define L1_CACHE_SHIFT (CONFIG_X86_L1_CACHE_SHIFT)
10039 @@ -12,6 +13,6 @@
10040 # define L1_CACHE_SHIFT 5
10041 #endif
10042
10043 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
10044 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
10045
10046 #endif
10047 diff --git a/arch/um/include/asm/kmap_types.h b/arch/um/include/asm/kmap_types.h
10048 index 2e0a6b1..a64d0f5 100644
10049 --- a/arch/um/include/asm/kmap_types.h
10050 +++ b/arch/um/include/asm/kmap_types.h
10051 @@ -8,6 +8,6 @@
10052
10053 /* No more #include "asm/arch/kmap_types.h" ! */
10054
10055 -#define KM_TYPE_NR 14
10056 +#define KM_TYPE_NR 15
10057
10058 #endif
10059 diff --git a/arch/um/include/asm/page.h b/arch/um/include/asm/page.h
10060 index 5ff53d9..5850cdf 100644
10061 --- a/arch/um/include/asm/page.h
10062 +++ b/arch/um/include/asm/page.h
10063 @@ -14,6 +14,9 @@
10064 #define PAGE_SIZE (_AC(1, UL) << PAGE_SHIFT)
10065 #define PAGE_MASK (~(PAGE_SIZE-1))
10066
10067 +#define ktla_ktva(addr) (addr)
10068 +#define ktva_ktla(addr) (addr)
10069 +
10070 #ifndef __ASSEMBLY__
10071
10072 struct page;
10073 diff --git a/arch/um/include/asm/pgtable-3level.h b/arch/um/include/asm/pgtable-3level.h
10074 index 0032f92..cd151e0 100644
10075 --- a/arch/um/include/asm/pgtable-3level.h
10076 +++ b/arch/um/include/asm/pgtable-3level.h
10077 @@ -58,6 +58,7 @@
10078 #define pud_present(x) (pud_val(x) & _PAGE_PRESENT)
10079 #define pud_populate(mm, pud, pmd) \
10080 set_pud(pud, __pud(_PAGE_TABLE + __pa(pmd)))
10081 +#define pud_populate_kernel(mm, pud, pmd) pud_populate((mm), (pud), (pmd))
10082
10083 #ifdef CONFIG_64BIT
10084 #define set_pud(pudptr, pudval) set_64bit((u64 *) (pudptr), pud_val(pudval))
10085 diff --git a/arch/um/kernel/process.c b/arch/um/kernel/process.c
10086 index b462b13..e7a19aa 100644
10087 --- a/arch/um/kernel/process.c
10088 +++ b/arch/um/kernel/process.c
10089 @@ -386,22 +386,6 @@ int singlestepping(void * t)
10090 return 2;
10091 }
10092
10093 -/*
10094 - * Only x86 and x86_64 have an arch_align_stack().
10095 - * All other arches have "#define arch_align_stack(x) (x)"
10096 - * in their asm/system.h
10097 - * As this is included in UML from asm-um/system-generic.h,
10098 - * we can use it to behave as the subarch does.
10099 - */
10100 -#ifndef arch_align_stack
10101 -unsigned long arch_align_stack(unsigned long sp)
10102 -{
10103 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
10104 - sp -= get_random_int() % 8192;
10105 - return sp & ~0xf;
10106 -}
10107 -#endif
10108 -
10109 unsigned long get_wchan(struct task_struct *p)
10110 {
10111 unsigned long stack_page, sp, ip;
10112 diff --git a/arch/unicore32/include/asm/cache.h b/arch/unicore32/include/asm/cache.h
10113 index ad8f795..2c7eec6 100644
10114 --- a/arch/unicore32/include/asm/cache.h
10115 +++ b/arch/unicore32/include/asm/cache.h
10116 @@ -12,8 +12,10 @@
10117 #ifndef __UNICORE_CACHE_H__
10118 #define __UNICORE_CACHE_H__
10119
10120 -#define L1_CACHE_SHIFT (5)
10121 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
10122 +#include <linux/const.h>
10123 +
10124 +#define L1_CACHE_SHIFT 5
10125 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
10126
10127 /*
10128 * Memory returned by kmalloc() may be used for DMA, so we must make
10129 diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
10130 index 0694d09..b58b3aa 100644
10131 --- a/arch/x86/Kconfig
10132 +++ b/arch/x86/Kconfig
10133 @@ -238,7 +238,7 @@ config X86_HT
10134
10135 config X86_32_LAZY_GS
10136 def_bool y
10137 - depends on X86_32 && !CC_STACKPROTECTOR
10138 + depends on X86_32 && !CC_STACKPROTECTOR && !PAX_MEMORY_UDEREF
10139
10140 config ARCH_HWEIGHT_CFLAGS
10141 string
10142 @@ -1031,6 +1031,7 @@ config MICROCODE_OLD_INTERFACE
10143
10144 config X86_MSR
10145 tristate "/dev/cpu/*/msr - Model-specific register support"
10146 + depends on !GRKERNSEC_KMEM
10147 ---help---
10148 This device gives privileged processes access to the x86
10149 Model-Specific Registers (MSRs). It is a character device with
10150 @@ -1054,7 +1055,7 @@ choice
10151
10152 config NOHIGHMEM
10153 bool "off"
10154 - depends on !X86_NUMAQ
10155 + depends on !X86_NUMAQ && !(PAX_PAGEEXEC && PAX_ENABLE_PAE)
10156 ---help---
10157 Linux can use up to 64 Gigabytes of physical memory on x86 systems.
10158 However, the address space of 32-bit x86 processors is only 4
10159 @@ -1091,7 +1092,7 @@ config NOHIGHMEM
10160
10161 config HIGHMEM4G
10162 bool "4GB"
10163 - depends on !X86_NUMAQ
10164 + depends on !X86_NUMAQ && !(PAX_PAGEEXEC && PAX_ENABLE_PAE)
10165 ---help---
10166 Select this if you have a 32-bit processor and between 1 and 4
10167 gigabytes of physical RAM.
10168 @@ -1145,7 +1146,7 @@ config PAGE_OFFSET
10169 hex
10170 default 0xB0000000 if VMSPLIT_3G_OPT
10171 default 0x80000000 if VMSPLIT_2G
10172 - default 0x78000000 if VMSPLIT_2G_OPT
10173 + default 0x70000000 if VMSPLIT_2G_OPT
10174 default 0x40000000 if VMSPLIT_1G
10175 default 0xC0000000
10176 depends on X86_32
10177 @@ -1542,6 +1543,7 @@ config SECCOMP
10178
10179 config CC_STACKPROTECTOR
10180 bool "Enable -fstack-protector buffer overflow detection"
10181 + depends on X86_64 || !PAX_MEMORY_UDEREF
10182 ---help---
10183 This option turns on the -fstack-protector GCC feature. This
10184 feature puts, at the beginning of functions, a canary value on
10185 @@ -1599,6 +1601,7 @@ config KEXEC_JUMP
10186 config PHYSICAL_START
10187 hex "Physical address where the kernel is loaded" if (EXPERT || CRASH_DUMP)
10188 default "0x1000000"
10189 + range 0x400000 0x40000000
10190 ---help---
10191 This gives the physical address where the kernel is loaded.
10192
10193 @@ -1662,6 +1665,7 @@ config X86_NEED_RELOCS
10194 config PHYSICAL_ALIGN
10195 hex "Alignment value to which kernel should be aligned" if X86_32
10196 default "0x1000000"
10197 + range 0x400000 0x1000000 if PAX_KERNEXEC
10198 range 0x2000 0x1000000
10199 ---help---
10200 This value puts the alignment restrictions on physical address
10201 @@ -1737,9 +1741,10 @@ config DEBUG_HOTPLUG_CPU0
10202 If unsure, say N.
10203
10204 config COMPAT_VDSO
10205 - def_bool y
10206 + def_bool n
10207 prompt "Compat VDSO support"
10208 depends on X86_32 || IA32_EMULATION
10209 + depends on !PAX_PAGEEXEC && !PAX_SEGMEXEC && !PAX_KERNEXEC && !PAX_MEMORY_UDEREF
10210 ---help---
10211 Map the 32-bit VDSO to the predictable old-style address too.
10212
10213 diff --git a/arch/x86/Kconfig.cpu b/arch/x86/Kconfig.cpu
10214 index c026cca..14657ae 100644
10215 --- a/arch/x86/Kconfig.cpu
10216 +++ b/arch/x86/Kconfig.cpu
10217 @@ -319,7 +319,7 @@ config X86_PPRO_FENCE
10218
10219 config X86_F00F_BUG
10220 def_bool y
10221 - depends on M586MMX || M586TSC || M586 || M486
10222 + depends on (M586MMX || M586TSC || M586 || M486) && !PAX_KERNEXEC
10223
10224 config X86_INVD_BUG
10225 def_bool y
10226 @@ -327,7 +327,7 @@ config X86_INVD_BUG
10227
10228 config X86_ALIGNMENT_16
10229 def_bool y
10230 - depends on MWINCHIP3D || MWINCHIPC6 || MCYRIXIII || MELAN || MK6 || M586MMX || M586TSC || M586 || M486 || MVIAC3_2 || MGEODEGX1
10231 + depends on MWINCHIP3D || MWINCHIPC6 || MCYRIXIII || X86_ELAN || MK8 || MK7 || MK6 || MCORE2 || MPENTIUM4 || MPENTIUMIII || MPENTIUMII || M686 || M586MMX || M586TSC || M586 || M486 || MVIAC3_2 || MGEODEGX1
10232
10233 config X86_INTEL_USERCOPY
10234 def_bool y
10235 @@ -373,7 +373,7 @@ config X86_CMPXCHG64
10236 # generates cmov.
10237 config X86_CMOV
10238 def_bool y
10239 - depends on (MK8 || MK7 || MCORE2 || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || MVIAC3_2 || MVIAC7 || MCRUSOE || MEFFICEON || X86_64 || MATOM || MGEODE_LX)
10240 + depends on (MK8 || MK7 || MCORE2 || MPSC || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || MVIAC3_2 || MVIAC7 || MCRUSOE || MEFFICEON || X86_64 || MATOM || MGEODE_LX)
10241
10242 config X86_MINIMUM_CPU_FAMILY
10243 int
10244 diff --git a/arch/x86/Kconfig.debug b/arch/x86/Kconfig.debug
10245 index b322f12..652d0d9 100644
10246 --- a/arch/x86/Kconfig.debug
10247 +++ b/arch/x86/Kconfig.debug
10248 @@ -84,7 +84,7 @@ config X86_PTDUMP
10249 config DEBUG_RODATA
10250 bool "Write protect kernel read-only data structures"
10251 default y
10252 - depends on DEBUG_KERNEL
10253 + depends on DEBUG_KERNEL && BROKEN
10254 ---help---
10255 Mark the kernel read-only data as write-protected in the pagetables,
10256 in order to catch accidental (and incorrect) writes to such const
10257 @@ -102,7 +102,7 @@ config DEBUG_RODATA_TEST
10258
10259 config DEBUG_SET_MODULE_RONX
10260 bool "Set loadable kernel module data as NX and text as RO"
10261 - depends on MODULES
10262 + depends on MODULES && BROKEN
10263 ---help---
10264 This option helps catch unintended modifications to loadable
10265 kernel module's text and read-only data. It also prevents execution
10266 @@ -294,7 +294,7 @@ config OPTIMIZE_INLINING
10267
10268 config DEBUG_STRICT_USER_COPY_CHECKS
10269 bool "Strict copy size checks"
10270 - depends on DEBUG_KERNEL && !TRACE_BRANCH_PROFILING
10271 + depends on DEBUG_KERNEL && !TRACE_BRANCH_PROFILING && !PAX_SIZE_OVERFLOW
10272 ---help---
10273 Enabling this option turns a certain set of sanity checks for user
10274 copy operations into compile time failures.
10275 diff --git a/arch/x86/Makefile b/arch/x86/Makefile
10276 index e71fc42..7829607 100644
10277 --- a/arch/x86/Makefile
10278 +++ b/arch/x86/Makefile
10279 @@ -50,6 +50,7 @@ else
10280 UTS_MACHINE := x86_64
10281 CHECKFLAGS += -D__x86_64__ -m64
10282
10283 + biarch := $(call cc-option,-m64)
10284 KBUILD_AFLAGS += -m64
10285 KBUILD_CFLAGS += -m64
10286
10287 @@ -230,3 +231,12 @@ define archhelp
10288 echo ' FDARGS="..." arguments for the booted kernel'
10289 echo ' FDINITRD=file initrd for the booted kernel'
10290 endef
10291 +
10292 +define OLD_LD
10293 +
10294 +*** ${VERSION}.${PATCHLEVEL} PaX kernels no longer build correctly with old versions of binutils.
10295 +*** Please upgrade your binutils to 2.18 or newer
10296 +endef
10297 +
10298 +archprepare:
10299 + $(if $(LDFLAGS_BUILD_ID),,$(error $(OLD_LD)))
10300 diff --git a/arch/x86/boot/Makefile b/arch/x86/boot/Makefile
10301 index 379814b..add62ce 100644
10302 --- a/arch/x86/boot/Makefile
10303 +++ b/arch/x86/boot/Makefile
10304 @@ -65,6 +65,9 @@ KBUILD_CFLAGS := $(USERINCLUDE) -g -Os -D_SETUP -D__KERNEL__ \
10305 $(call cc-option, -fno-stack-protector) \
10306 $(call cc-option, -mpreferred-stack-boundary=2)
10307 KBUILD_CFLAGS += $(call cc-option, -m32)
10308 +ifdef CONSTIFY_PLUGIN
10309 +KBUILD_CFLAGS += -fplugin-arg-constify_plugin-no-constify
10310 +endif
10311 KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
10312 GCOV_PROFILE := n
10313
10314 diff --git a/arch/x86/boot/bitops.h b/arch/x86/boot/bitops.h
10315 index 878e4b9..20537ab 100644
10316 --- a/arch/x86/boot/bitops.h
10317 +++ b/arch/x86/boot/bitops.h
10318 @@ -26,7 +26,7 @@ static inline int variable_test_bit(int nr, const void *addr)
10319 u8 v;
10320 const u32 *p = (const u32 *)addr;
10321
10322 - asm("btl %2,%1; setc %0" : "=qm" (v) : "m" (*p), "Ir" (nr));
10323 + asm volatile("btl %2,%1; setc %0" : "=qm" (v) : "m" (*p), "Ir" (nr));
10324 return v;
10325 }
10326
10327 @@ -37,7 +37,7 @@ static inline int variable_test_bit(int nr, const void *addr)
10328
10329 static inline void set_bit(int nr, void *addr)
10330 {
10331 - asm("btsl %1,%0" : "+m" (*(u32 *)addr) : "Ir" (nr));
10332 + asm volatile("btsl %1,%0" : "+m" (*(u32 *)addr) : "Ir" (nr));
10333 }
10334
10335 #endif /* BOOT_BITOPS_H */
10336 diff --git a/arch/x86/boot/boot.h b/arch/x86/boot/boot.h
10337 index 18997e5..83d9c67 100644
10338 --- a/arch/x86/boot/boot.h
10339 +++ b/arch/x86/boot/boot.h
10340 @@ -85,7 +85,7 @@ static inline void io_delay(void)
10341 static inline u16 ds(void)
10342 {
10343 u16 seg;
10344 - asm("movw %%ds,%0" : "=rm" (seg));
10345 + asm volatile("movw %%ds,%0" : "=rm" (seg));
10346 return seg;
10347 }
10348
10349 @@ -181,7 +181,7 @@ static inline void wrgs32(u32 v, addr_t addr)
10350 static inline int memcmp(const void *s1, const void *s2, size_t len)
10351 {
10352 u8 diff;
10353 - asm("repe; cmpsb; setnz %0"
10354 + asm volatile("repe; cmpsb; setnz %0"
10355 : "=qm" (diff), "+D" (s1), "+S" (s2), "+c" (len));
10356 return diff;
10357 }
10358 diff --git a/arch/x86/boot/compressed/Makefile b/arch/x86/boot/compressed/Makefile
10359 index 8a84501..b2d165f 100644
10360 --- a/arch/x86/boot/compressed/Makefile
10361 +++ b/arch/x86/boot/compressed/Makefile
10362 @@ -14,6 +14,9 @@ cflags-$(CONFIG_X86_64) := -mcmodel=small
10363 KBUILD_CFLAGS += $(cflags-y)
10364 KBUILD_CFLAGS += $(call cc-option,-ffreestanding)
10365 KBUILD_CFLAGS += $(call cc-option,-fno-stack-protector)
10366 +ifdef CONSTIFY_PLUGIN
10367 +KBUILD_CFLAGS += -fplugin-arg-constify_plugin-no-constify
10368 +endif
10369
10370 KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
10371 GCOV_PROFILE := n
10372 diff --git a/arch/x86/boot/compressed/eboot.c b/arch/x86/boot/compressed/eboot.c
10373 index c205035..5853587 100644
10374 --- a/arch/x86/boot/compressed/eboot.c
10375 +++ b/arch/x86/boot/compressed/eboot.c
10376 @@ -150,7 +150,6 @@ again:
10377 *addr = max_addr;
10378 }
10379
10380 -free_pool:
10381 efi_call_phys1(sys_table->boottime->free_pool, map);
10382
10383 fail:
10384 @@ -214,7 +213,6 @@ static efi_status_t low_alloc(unsigned long size, unsigned long align,
10385 if (i == map_size / desc_size)
10386 status = EFI_NOT_FOUND;
10387
10388 -free_pool:
10389 efi_call_phys1(sys_table->boottime->free_pool, map);
10390 fail:
10391 return status;
10392 diff --git a/arch/x86/boot/compressed/head_32.S b/arch/x86/boot/compressed/head_32.S
10393 index 1e3184f..0d11e2e 100644
10394 --- a/arch/x86/boot/compressed/head_32.S
10395 +++ b/arch/x86/boot/compressed/head_32.S
10396 @@ -118,7 +118,7 @@ preferred_addr:
10397 notl %eax
10398 andl %eax, %ebx
10399 #else
10400 - movl $LOAD_PHYSICAL_ADDR, %ebx
10401 + movl $____LOAD_PHYSICAL_ADDR, %ebx
10402 #endif
10403
10404 /* Target address to relocate to for decompression */
10405 @@ -204,7 +204,7 @@ relocated:
10406 * and where it was actually loaded.
10407 */
10408 movl %ebp, %ebx
10409 - subl $LOAD_PHYSICAL_ADDR, %ebx
10410 + subl $____LOAD_PHYSICAL_ADDR, %ebx
10411 jz 2f /* Nothing to be done if loaded at compiled addr. */
10412 /*
10413 * Process relocations.
10414 @@ -212,8 +212,7 @@ relocated:
10415
10416 1: subl $4, %edi
10417 movl (%edi), %ecx
10418 - testl %ecx, %ecx
10419 - jz 2f
10420 + jecxz 2f
10421 addl %ebx, -__PAGE_OFFSET(%ebx, %ecx)
10422 jmp 1b
10423 2:
10424 diff --git a/arch/x86/boot/compressed/head_64.S b/arch/x86/boot/compressed/head_64.S
10425 index f5d1aaa..cce11dc 100644
10426 --- a/arch/x86/boot/compressed/head_64.S
10427 +++ b/arch/x86/boot/compressed/head_64.S
10428 @@ -91,7 +91,7 @@ ENTRY(startup_32)
10429 notl %eax
10430 andl %eax, %ebx
10431 #else
10432 - movl $LOAD_PHYSICAL_ADDR, %ebx
10433 + movl $____LOAD_PHYSICAL_ADDR, %ebx
10434 #endif
10435
10436 /* Target address to relocate to for decompression */
10437 @@ -273,7 +273,7 @@ preferred_addr:
10438 notq %rax
10439 andq %rax, %rbp
10440 #else
10441 - movq $LOAD_PHYSICAL_ADDR, %rbp
10442 + movq $____LOAD_PHYSICAL_ADDR, %rbp
10443 #endif
10444
10445 /* Target address to relocate to for decompression */
10446 diff --git a/arch/x86/boot/compressed/misc.c b/arch/x86/boot/compressed/misc.c
10447 index 88f7ff6..ed695dd 100644
10448 --- a/arch/x86/boot/compressed/misc.c
10449 +++ b/arch/x86/boot/compressed/misc.c
10450 @@ -303,7 +303,7 @@ static void parse_elf(void *output)
10451 case PT_LOAD:
10452 #ifdef CONFIG_RELOCATABLE
10453 dest = output;
10454 - dest += (phdr->p_paddr - LOAD_PHYSICAL_ADDR);
10455 + dest += (phdr->p_paddr - ____LOAD_PHYSICAL_ADDR);
10456 #else
10457 dest = (void *)(phdr->p_paddr);
10458 #endif
10459 @@ -352,7 +352,7 @@ asmlinkage void decompress_kernel(void *rmode, memptr heap,
10460 error("Destination address too large");
10461 #endif
10462 #ifndef CONFIG_RELOCATABLE
10463 - if ((unsigned long)output != LOAD_PHYSICAL_ADDR)
10464 + if ((unsigned long)output != ____LOAD_PHYSICAL_ADDR)
10465 error("Wrong destination address");
10466 #endif
10467
10468 diff --git a/arch/x86/boot/cpucheck.c b/arch/x86/boot/cpucheck.c
10469 index 4d3ff03..e4972ff 100644
10470 --- a/arch/x86/boot/cpucheck.c
10471 +++ b/arch/x86/boot/cpucheck.c
10472 @@ -74,7 +74,7 @@ static int has_fpu(void)
10473 u16 fcw = -1, fsw = -1;
10474 u32 cr0;
10475
10476 - asm("movl %%cr0,%0" : "=r" (cr0));
10477 + asm volatile("movl %%cr0,%0" : "=r" (cr0));
10478 if (cr0 & (X86_CR0_EM|X86_CR0_TS)) {
10479 cr0 &= ~(X86_CR0_EM|X86_CR0_TS);
10480 asm volatile("movl %0,%%cr0" : : "r" (cr0));
10481 @@ -90,7 +90,7 @@ static int has_eflag(u32 mask)
10482 {
10483 u32 f0, f1;
10484
10485 - asm("pushfl ; "
10486 + asm volatile("pushfl ; "
10487 "pushfl ; "
10488 "popl %0 ; "
10489 "movl %0,%1 ; "
10490 @@ -115,7 +115,7 @@ static void get_flags(void)
10491 set_bit(X86_FEATURE_FPU, cpu.flags);
10492
10493 if (has_eflag(X86_EFLAGS_ID)) {
10494 - asm("cpuid"
10495 + asm volatile("cpuid"
10496 : "=a" (max_intel_level),
10497 "=b" (cpu_vendor[0]),
10498 "=d" (cpu_vendor[1]),
10499 @@ -124,7 +124,7 @@ static void get_flags(void)
10500
10501 if (max_intel_level >= 0x00000001 &&
10502 max_intel_level <= 0x0000ffff) {
10503 - asm("cpuid"
10504 + asm volatile("cpuid"
10505 : "=a" (tfms),
10506 "=c" (cpu.flags[4]),
10507 "=d" (cpu.flags[0])
10508 @@ -136,7 +136,7 @@ static void get_flags(void)
10509 cpu.model += ((tfms >> 16) & 0xf) << 4;
10510 }
10511
10512 - asm("cpuid"
10513 + asm volatile("cpuid"
10514 : "=a" (max_amd_level)
10515 : "a" (0x80000000)
10516 : "ebx", "ecx", "edx");
10517 @@ -144,7 +144,7 @@ static void get_flags(void)
10518 if (max_amd_level >= 0x80000001 &&
10519 max_amd_level <= 0x8000ffff) {
10520 u32 eax = 0x80000001;
10521 - asm("cpuid"
10522 + asm volatile("cpuid"
10523 : "+a" (eax),
10524 "=c" (cpu.flags[6]),
10525 "=d" (cpu.flags[1])
10526 @@ -203,9 +203,9 @@ int check_cpu(int *cpu_level_ptr, int *req_level_ptr, u32 **err_flags_ptr)
10527 u32 ecx = MSR_K7_HWCR;
10528 u32 eax, edx;
10529
10530 - asm("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
10531 + asm volatile("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
10532 eax &= ~(1 << 15);
10533 - asm("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
10534 + asm volatile("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
10535
10536 get_flags(); /* Make sure it really did something */
10537 err = check_flags();
10538 @@ -218,9 +218,9 @@ int check_cpu(int *cpu_level_ptr, int *req_level_ptr, u32 **err_flags_ptr)
10539 u32 ecx = MSR_VIA_FCR;
10540 u32 eax, edx;
10541
10542 - asm("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
10543 + asm volatile("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
10544 eax |= (1<<1)|(1<<7);
10545 - asm("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
10546 + asm volatile("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
10547
10548 set_bit(X86_FEATURE_CX8, cpu.flags);
10549 err = check_flags();
10550 @@ -231,12 +231,12 @@ int check_cpu(int *cpu_level_ptr, int *req_level_ptr, u32 **err_flags_ptr)
10551 u32 eax, edx;
10552 u32 level = 1;
10553
10554 - asm("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
10555 - asm("wrmsr" : : "a" (~0), "d" (edx), "c" (ecx));
10556 - asm("cpuid"
10557 + asm volatile("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
10558 + asm volatile("wrmsr" : : "a" (~0), "d" (edx), "c" (ecx));
10559 + asm volatile("cpuid"
10560 : "+a" (level), "=d" (cpu.flags[0])
10561 : : "ecx", "ebx");
10562 - asm("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
10563 + asm volatile("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
10564
10565 err = check_flags();
10566 }
10567 diff --git a/arch/x86/boot/header.S b/arch/x86/boot/header.S
10568 index 944ce59..87ee37a 100644
10569 --- a/arch/x86/boot/header.S
10570 +++ b/arch/x86/boot/header.S
10571 @@ -401,10 +401,14 @@ setup_data: .quad 0 # 64-bit physical pointer to
10572 # single linked list of
10573 # struct setup_data
10574
10575 -pref_address: .quad LOAD_PHYSICAL_ADDR # preferred load addr
10576 +pref_address: .quad ____LOAD_PHYSICAL_ADDR # preferred load addr
10577
10578 #define ZO_INIT_SIZE (ZO__end - ZO_startup_32 + ZO_z_extract_offset)
10579 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
10580 +#define VO_INIT_SIZE (VO__end - VO__text - __PAGE_OFFSET - ____LOAD_PHYSICAL_ADDR)
10581 +#else
10582 #define VO_INIT_SIZE (VO__end - VO__text)
10583 +#endif
10584 #if ZO_INIT_SIZE > VO_INIT_SIZE
10585 #define INIT_SIZE ZO_INIT_SIZE
10586 #else
10587 diff --git a/arch/x86/boot/memory.c b/arch/x86/boot/memory.c
10588 index db75d07..8e6d0af 100644
10589 --- a/arch/x86/boot/memory.c
10590 +++ b/arch/x86/boot/memory.c
10591 @@ -19,7 +19,7 @@
10592
10593 static int detect_memory_e820(void)
10594 {
10595 - int count = 0;
10596 + unsigned int count = 0;
10597 struct biosregs ireg, oreg;
10598 struct e820entry *desc = boot_params.e820_map;
10599 static struct e820entry buf; /* static so it is zeroed */
10600 diff --git a/arch/x86/boot/video-vesa.c b/arch/x86/boot/video-vesa.c
10601 index 11e8c6e..fdbb1ed 100644
10602 --- a/arch/x86/boot/video-vesa.c
10603 +++ b/arch/x86/boot/video-vesa.c
10604 @@ -200,6 +200,7 @@ static void vesa_store_pm_info(void)
10605
10606 boot_params.screen_info.vesapm_seg = oreg.es;
10607 boot_params.screen_info.vesapm_off = oreg.di;
10608 + boot_params.screen_info.vesapm_size = oreg.cx;
10609 }
10610
10611 /*
10612 diff --git a/arch/x86/boot/video.c b/arch/x86/boot/video.c
10613 index 43eda28..5ab5fdb 100644
10614 --- a/arch/x86/boot/video.c
10615 +++ b/arch/x86/boot/video.c
10616 @@ -96,7 +96,7 @@ static void store_mode_params(void)
10617 static unsigned int get_entry(void)
10618 {
10619 char entry_buf[4];
10620 - int i, len = 0;
10621 + unsigned int i, len = 0;
10622 int key;
10623 unsigned int v;
10624
10625 diff --git a/arch/x86/crypto/aes-x86_64-asm_64.S b/arch/x86/crypto/aes-x86_64-asm_64.S
10626 index 5b577d5..3c1fed4 100644
10627 --- a/arch/x86/crypto/aes-x86_64-asm_64.S
10628 +++ b/arch/x86/crypto/aes-x86_64-asm_64.S
10629 @@ -8,6 +8,8 @@
10630 * including this sentence is retained in full.
10631 */
10632
10633 +#include <asm/alternative-asm.h>
10634 +
10635 .extern crypto_ft_tab
10636 .extern crypto_it_tab
10637 .extern crypto_fl_tab
10638 @@ -71,6 +73,8 @@ FUNC: movq r1,r2; \
10639 je B192; \
10640 leaq 32(r9),r9;
10641
10642 +#define ret pax_force_retaddr 0, 1; ret
10643 +
10644 #define epilogue(r1,r2,r3,r4,r5,r6,r7,r8,r9) \
10645 movq r1,r2; \
10646 movq r3,r4; \
10647 diff --git a/arch/x86/crypto/aesni-intel_asm.S b/arch/x86/crypto/aesni-intel_asm.S
10648 index 3470624..201259d 100644
10649 --- a/arch/x86/crypto/aesni-intel_asm.S
10650 +++ b/arch/x86/crypto/aesni-intel_asm.S
10651 @@ -31,6 +31,7 @@
10652
10653 #include <linux/linkage.h>
10654 #include <asm/inst.h>
10655 +#include <asm/alternative-asm.h>
10656
10657 #ifdef __x86_64__
10658 .data
10659 @@ -1436,7 +1437,9 @@ _return_T_done_decrypt:
10660 pop %r14
10661 pop %r13
10662 pop %r12
10663 + pax_force_retaddr 0, 1
10664 ret
10665 +ENDPROC(aesni_gcm_dec)
10666
10667
10668 /*****************************************************************************
10669 @@ -1699,7 +1702,9 @@ _return_T_done_encrypt:
10670 pop %r14
10671 pop %r13
10672 pop %r12
10673 + pax_force_retaddr 0, 1
10674 ret
10675 +ENDPROC(aesni_gcm_enc)
10676
10677 #endif
10678
10679 @@ -1714,6 +1719,7 @@ _key_expansion_256a:
10680 pxor %xmm1, %xmm0
10681 movaps %xmm0, (TKEYP)
10682 add $0x10, TKEYP
10683 + pax_force_retaddr_bts
10684 ret
10685
10686 .align 4
10687 @@ -1738,6 +1744,7 @@ _key_expansion_192a:
10688 shufps $0b01001110, %xmm2, %xmm1
10689 movaps %xmm1, 0x10(TKEYP)
10690 add $0x20, TKEYP
10691 + pax_force_retaddr_bts
10692 ret
10693
10694 .align 4
10695 @@ -1757,6 +1764,7 @@ _key_expansion_192b:
10696
10697 movaps %xmm0, (TKEYP)
10698 add $0x10, TKEYP
10699 + pax_force_retaddr_bts
10700 ret
10701
10702 .align 4
10703 @@ -1769,6 +1777,7 @@ _key_expansion_256b:
10704 pxor %xmm1, %xmm2
10705 movaps %xmm2, (TKEYP)
10706 add $0x10, TKEYP
10707 + pax_force_retaddr_bts
10708 ret
10709
10710 /*
10711 @@ -1881,7 +1890,9 @@ ENTRY(aesni_set_key)
10712 #ifndef __x86_64__
10713 popl KEYP
10714 #endif
10715 + pax_force_retaddr 0, 1
10716 ret
10717 +ENDPROC(aesni_set_key)
10718
10719 /*
10720 * void aesni_enc(struct crypto_aes_ctx *ctx, u8 *dst, const u8 *src)
10721 @@ -1902,7 +1913,9 @@ ENTRY(aesni_enc)
10722 popl KLEN
10723 popl KEYP
10724 #endif
10725 + pax_force_retaddr 0, 1
10726 ret
10727 +ENDPROC(aesni_enc)
10728
10729 /*
10730 * _aesni_enc1: internal ABI
10731 @@ -1959,6 +1972,7 @@ _aesni_enc1:
10732 AESENC KEY STATE
10733 movaps 0x70(TKEYP), KEY
10734 AESENCLAST KEY STATE
10735 + pax_force_retaddr_bts
10736 ret
10737
10738 /*
10739 @@ -2067,6 +2081,7 @@ _aesni_enc4:
10740 AESENCLAST KEY STATE2
10741 AESENCLAST KEY STATE3
10742 AESENCLAST KEY STATE4
10743 + pax_force_retaddr_bts
10744 ret
10745
10746 /*
10747 @@ -2089,7 +2104,9 @@ ENTRY(aesni_dec)
10748 popl KLEN
10749 popl KEYP
10750 #endif
10751 + pax_force_retaddr 0, 1
10752 ret
10753 +ENDPROC(aesni_dec)
10754
10755 /*
10756 * _aesni_dec1: internal ABI
10757 @@ -2146,6 +2163,7 @@ _aesni_dec1:
10758 AESDEC KEY STATE
10759 movaps 0x70(TKEYP), KEY
10760 AESDECLAST KEY STATE
10761 + pax_force_retaddr_bts
10762 ret
10763
10764 /*
10765 @@ -2254,6 +2272,7 @@ _aesni_dec4:
10766 AESDECLAST KEY STATE2
10767 AESDECLAST KEY STATE3
10768 AESDECLAST KEY STATE4
10769 + pax_force_retaddr_bts
10770 ret
10771
10772 /*
10773 @@ -2311,7 +2330,9 @@ ENTRY(aesni_ecb_enc)
10774 popl KEYP
10775 popl LEN
10776 #endif
10777 + pax_force_retaddr 0, 1
10778 ret
10779 +ENDPROC(aesni_ecb_enc)
10780
10781 /*
10782 * void aesni_ecb_dec(struct crypto_aes_ctx *ctx, const u8 *dst, u8 *src,
10783 @@ -2369,7 +2390,9 @@ ENTRY(aesni_ecb_dec)
10784 popl KEYP
10785 popl LEN
10786 #endif
10787 + pax_force_retaddr 0, 1
10788 ret
10789 +ENDPROC(aesni_ecb_dec)
10790
10791 /*
10792 * void aesni_cbc_enc(struct crypto_aes_ctx *ctx, const u8 *dst, u8 *src,
10793 @@ -2410,7 +2433,9 @@ ENTRY(aesni_cbc_enc)
10794 popl LEN
10795 popl IVP
10796 #endif
10797 + pax_force_retaddr 0, 1
10798 ret
10799 +ENDPROC(aesni_cbc_enc)
10800
10801 /*
10802 * void aesni_cbc_dec(struct crypto_aes_ctx *ctx, const u8 *dst, u8 *src,
10803 @@ -2500,7 +2525,9 @@ ENTRY(aesni_cbc_dec)
10804 popl LEN
10805 popl IVP
10806 #endif
10807 + pax_force_retaddr 0, 1
10808 ret
10809 +ENDPROC(aesni_cbc_dec)
10810
10811 #ifdef __x86_64__
10812 .align 16
10813 @@ -2526,6 +2553,7 @@ _aesni_inc_init:
10814 mov $1, TCTR_LOW
10815 MOVQ_R64_XMM TCTR_LOW INC
10816 MOVQ_R64_XMM CTR TCTR_LOW
10817 + pax_force_retaddr_bts
10818 ret
10819
10820 /*
10821 @@ -2554,6 +2582,7 @@ _aesni_inc:
10822 .Linc_low:
10823 movaps CTR, IV
10824 PSHUFB_XMM BSWAP_MASK IV
10825 + pax_force_retaddr_bts
10826 ret
10827
10828 /*
10829 @@ -2614,5 +2643,7 @@ ENTRY(aesni_ctr_enc)
10830 .Lctr_enc_ret:
10831 movups IV, (IVP)
10832 .Lctr_enc_just_ret:
10833 + pax_force_retaddr 0, 1
10834 ret
10835 +ENDPROC(aesni_ctr_enc)
10836 #endif
10837 diff --git a/arch/x86/crypto/blowfish-x86_64-asm_64.S b/arch/x86/crypto/blowfish-x86_64-asm_64.S
10838 index 391d245..67f35c2 100644
10839 --- a/arch/x86/crypto/blowfish-x86_64-asm_64.S
10840 +++ b/arch/x86/crypto/blowfish-x86_64-asm_64.S
10841 @@ -20,6 +20,8 @@
10842 *
10843 */
10844
10845 +#include <asm/alternative-asm.h>
10846 +
10847 .file "blowfish-x86_64-asm.S"
10848 .text
10849
10850 @@ -151,9 +153,11 @@ __blowfish_enc_blk:
10851 jnz __enc_xor;
10852
10853 write_block();
10854 + pax_force_retaddr 0, 1
10855 ret;
10856 __enc_xor:
10857 xor_block();
10858 + pax_force_retaddr 0, 1
10859 ret;
10860
10861 .align 8
10862 @@ -188,6 +192,7 @@ blowfish_dec_blk:
10863
10864 movq %r11, %rbp;
10865
10866 + pax_force_retaddr 0, 1
10867 ret;
10868
10869 /**********************************************************************
10870 @@ -342,6 +347,7 @@ __blowfish_enc_blk_4way:
10871
10872 popq %rbx;
10873 popq %rbp;
10874 + pax_force_retaddr 0, 1
10875 ret;
10876
10877 __enc_xor4:
10878 @@ -349,6 +355,7 @@ __enc_xor4:
10879
10880 popq %rbx;
10881 popq %rbp;
10882 + pax_force_retaddr 0, 1
10883 ret;
10884
10885 .align 8
10886 @@ -386,5 +393,6 @@ blowfish_dec_blk_4way:
10887 popq %rbx;
10888 popq %rbp;
10889
10890 + pax_force_retaddr 0, 1
10891 ret;
10892
10893 diff --git a/arch/x86/crypto/camellia-x86_64-asm_64.S b/arch/x86/crypto/camellia-x86_64-asm_64.S
10894 index 0b33743..7a56206 100644
10895 --- a/arch/x86/crypto/camellia-x86_64-asm_64.S
10896 +++ b/arch/x86/crypto/camellia-x86_64-asm_64.S
10897 @@ -20,6 +20,8 @@
10898 *
10899 */
10900
10901 +#include <asm/alternative-asm.h>
10902 +
10903 .file "camellia-x86_64-asm_64.S"
10904 .text
10905
10906 @@ -229,12 +231,14 @@ __enc_done:
10907 enc_outunpack(mov, RT1);
10908
10909 movq RRBP, %rbp;
10910 + pax_force_retaddr 0, 1
10911 ret;
10912
10913 __enc_xor:
10914 enc_outunpack(xor, RT1);
10915
10916 movq RRBP, %rbp;
10917 + pax_force_retaddr 0, 1
10918 ret;
10919
10920 .global camellia_dec_blk;
10921 @@ -275,6 +279,7 @@ __dec_rounds16:
10922 dec_outunpack();
10923
10924 movq RRBP, %rbp;
10925 + pax_force_retaddr 0, 1
10926 ret;
10927
10928 /**********************************************************************
10929 @@ -468,6 +473,7 @@ __enc2_done:
10930
10931 movq RRBP, %rbp;
10932 popq %rbx;
10933 + pax_force_retaddr 0, 1
10934 ret;
10935
10936 __enc2_xor:
10937 @@ -475,6 +481,7 @@ __enc2_xor:
10938
10939 movq RRBP, %rbp;
10940 popq %rbx;
10941 + pax_force_retaddr 0, 1
10942 ret;
10943
10944 .global camellia_dec_blk_2way;
10945 @@ -517,4 +524,5 @@ __dec2_rounds16:
10946
10947 movq RRBP, %rbp;
10948 movq RXOR, %rbx;
10949 + pax_force_retaddr 0, 1
10950 ret;
10951 diff --git a/arch/x86/crypto/cast5-avx-x86_64-asm_64.S b/arch/x86/crypto/cast5-avx-x86_64-asm_64.S
10952 index 15b00ac..2071784 100644
10953 --- a/arch/x86/crypto/cast5-avx-x86_64-asm_64.S
10954 +++ b/arch/x86/crypto/cast5-avx-x86_64-asm_64.S
10955 @@ -23,6 +23,8 @@
10956 *
10957 */
10958
10959 +#include <asm/alternative-asm.h>
10960 +
10961 .file "cast5-avx-x86_64-asm_64.S"
10962
10963 .extern cast_s1
10964 @@ -281,6 +283,7 @@ __skip_enc:
10965 outunpack_blocks(RR3, RL3, RTMP, RX, RKM);
10966 outunpack_blocks(RR4, RL4, RTMP, RX, RKM);
10967
10968 + pax_force_retaddr 0, 1
10969 ret;
10970
10971 .align 16
10972 @@ -353,6 +356,7 @@ __dec_tail:
10973 outunpack_blocks(RR3, RL3, RTMP, RX, RKM);
10974 outunpack_blocks(RR4, RL4, RTMP, RX, RKM);
10975
10976 + pax_force_retaddr 0, 1
10977 ret;
10978
10979 __skip_dec:
10980 @@ -392,6 +396,7 @@ cast5_ecb_enc_16way:
10981 vmovdqu RR4, (6*4*4)(%r11);
10982 vmovdqu RL4, (7*4*4)(%r11);
10983
10984 + pax_force_retaddr
10985 ret;
10986
10987 .align 16
10988 @@ -427,6 +432,7 @@ cast5_ecb_dec_16way:
10989 vmovdqu RR4, (6*4*4)(%r11);
10990 vmovdqu RL4, (7*4*4)(%r11);
10991
10992 + pax_force_retaddr
10993 ret;
10994
10995 .align 16
10996 @@ -479,6 +485,7 @@ cast5_cbc_dec_16way:
10997
10998 popq %r12;
10999
11000 + pax_force_retaddr
11001 ret;
11002
11003 .align 16
11004 @@ -555,4 +562,5 @@ cast5_ctr_16way:
11005
11006 popq %r12;
11007
11008 + pax_force_retaddr
11009 ret;
11010 diff --git a/arch/x86/crypto/cast6-avx-x86_64-asm_64.S b/arch/x86/crypto/cast6-avx-x86_64-asm_64.S
11011 index 2569d0d..637c289 100644
11012 --- a/arch/x86/crypto/cast6-avx-x86_64-asm_64.S
11013 +++ b/arch/x86/crypto/cast6-avx-x86_64-asm_64.S
11014 @@ -23,6 +23,8 @@
11015 *
11016 */
11017
11018 +#include <asm/alternative-asm.h>
11019 +
11020 #include "glue_helper-asm-avx.S"
11021
11022 .file "cast6-avx-x86_64-asm_64.S"
11023 @@ -294,6 +296,7 @@ __cast6_enc_blk8:
11024 outunpack_blocks(RA1, RB1, RC1, RD1, RTMP, RX, RKRF, RKM);
11025 outunpack_blocks(RA2, RB2, RC2, RD2, RTMP, RX, RKRF, RKM);
11026
11027 + pax_force_retaddr 0, 1
11028 ret;
11029
11030 .align 8
11031 @@ -340,6 +343,7 @@ __cast6_dec_blk8:
11032 outunpack_blocks(RA1, RB1, RC1, RD1, RTMP, RX, RKRF, RKM);
11033 outunpack_blocks(RA2, RB2, RC2, RD2, RTMP, RX, RKRF, RKM);
11034
11035 + pax_force_retaddr 0, 1
11036 ret;
11037
11038 .align 8
11039 @@ -361,6 +365,7 @@ cast6_ecb_enc_8way:
11040
11041 store_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
11042
11043 + pax_force_retaddr
11044 ret;
11045
11046 .align 8
11047 @@ -382,6 +387,7 @@ cast6_ecb_dec_8way:
11048
11049 store_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
11050
11051 + pax_force_retaddr
11052 ret;
11053
11054 .align 8
11055 @@ -408,6 +414,7 @@ cast6_cbc_dec_8way:
11056
11057 popq %r12;
11058
11059 + pax_force_retaddr
11060 ret;
11061
11062 .align 8
11063 @@ -436,4 +443,5 @@ cast6_ctr_8way:
11064
11065 popq %r12;
11066
11067 + pax_force_retaddr
11068 ret;
11069 diff --git a/arch/x86/crypto/salsa20-x86_64-asm_64.S b/arch/x86/crypto/salsa20-x86_64-asm_64.S
11070 index 6214a9b..1f4fc9a 100644
11071 --- a/arch/x86/crypto/salsa20-x86_64-asm_64.S
11072 +++ b/arch/x86/crypto/salsa20-x86_64-asm_64.S
11073 @@ -1,3 +1,5 @@
11074 +#include <asm/alternative-asm.h>
11075 +
11076 # enter ECRYPT_encrypt_bytes
11077 .text
11078 .p2align 5
11079 @@ -790,6 +792,7 @@ ECRYPT_encrypt_bytes:
11080 add %r11,%rsp
11081 mov %rdi,%rax
11082 mov %rsi,%rdx
11083 + pax_force_retaddr 0, 1
11084 ret
11085 # bytesatleast65:
11086 ._bytesatleast65:
11087 @@ -891,6 +894,7 @@ ECRYPT_keysetup:
11088 add %r11,%rsp
11089 mov %rdi,%rax
11090 mov %rsi,%rdx
11091 + pax_force_retaddr
11092 ret
11093 # enter ECRYPT_ivsetup
11094 .text
11095 @@ -917,4 +921,5 @@ ECRYPT_ivsetup:
11096 add %r11,%rsp
11097 mov %rdi,%rax
11098 mov %rsi,%rdx
11099 + pax_force_retaddr
11100 ret
11101 diff --git a/arch/x86/crypto/serpent-avx-x86_64-asm_64.S b/arch/x86/crypto/serpent-avx-x86_64-asm_64.S
11102 index 02b0e9f..cf4cf5c 100644
11103 --- a/arch/x86/crypto/serpent-avx-x86_64-asm_64.S
11104 +++ b/arch/x86/crypto/serpent-avx-x86_64-asm_64.S
11105 @@ -24,6 +24,8 @@
11106 *
11107 */
11108
11109 +#include <asm/alternative-asm.h>
11110 +
11111 #include "glue_helper-asm-avx.S"
11112
11113 .file "serpent-avx-x86_64-asm_64.S"
11114 @@ -618,6 +620,7 @@ __serpent_enc_blk8_avx:
11115 write_blocks(RA1, RB1, RC1, RD1, RK0, RK1, RK2);
11116 write_blocks(RA2, RB2, RC2, RD2, RK0, RK1, RK2);
11117
11118 + pax_force_retaddr
11119 ret;
11120
11121 .align 8
11122 @@ -673,6 +676,7 @@ __serpent_dec_blk8_avx:
11123 write_blocks(RC1, RD1, RB1, RE1, RK0, RK1, RK2);
11124 write_blocks(RC2, RD2, RB2, RE2, RK0, RK1, RK2);
11125
11126 + pax_force_retaddr
11127 ret;
11128
11129 .align 8
11130 @@ -692,6 +696,7 @@ serpent_ecb_enc_8way_avx:
11131
11132 store_8way(%rsi, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
11133
11134 + pax_force_retaddr
11135 ret;
11136
11137 .align 8
11138 @@ -711,6 +716,7 @@ serpent_ecb_dec_8way_avx:
11139
11140 store_8way(%rsi, RC1, RD1, RB1, RE1, RC2, RD2, RB2, RE2);
11141
11142 + pax_force_retaddr
11143 ret;
11144
11145 .align 8
11146 @@ -730,6 +736,7 @@ serpent_cbc_dec_8way_avx:
11147
11148 store_cbc_8way(%rdx, %rsi, RC1, RD1, RB1, RE1, RC2, RD2, RB2, RE2);
11149
11150 + pax_force_retaddr
11151 ret;
11152
11153 .align 8
11154 @@ -751,4 +758,5 @@ serpent_ctr_8way_avx:
11155
11156 store_ctr_8way(%rdx, %rsi, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
11157
11158 + pax_force_retaddr
11159 ret;
11160 diff --git a/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S b/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S
11161 index 3ee1ff0..cbc568b 100644
11162 --- a/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S
11163 +++ b/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S
11164 @@ -24,6 +24,8 @@
11165 *
11166 */
11167
11168 +#include <asm/alternative-asm.h>
11169 +
11170 .file "serpent-sse2-x86_64-asm_64.S"
11171 .text
11172
11173 @@ -692,12 +694,14 @@ __serpent_enc_blk_8way:
11174 write_blocks(%rsi, RA1, RB1, RC1, RD1, RK0, RK1, RK2);
11175 write_blocks(%rax, RA2, RB2, RC2, RD2, RK0, RK1, RK2);
11176
11177 + pax_force_retaddr
11178 ret;
11179
11180 __enc_xor8:
11181 xor_blocks(%rsi, RA1, RB1, RC1, RD1, RK0, RK1, RK2);
11182 xor_blocks(%rax, RA2, RB2, RC2, RD2, RK0, RK1, RK2);
11183
11184 + pax_force_retaddr
11185 ret;
11186
11187 .align 8
11188 @@ -755,4 +759,5 @@ serpent_dec_blk_8way:
11189 write_blocks(%rsi, RC1, RD1, RB1, RE1, RK0, RK1, RK2);
11190 write_blocks(%rax, RC2, RD2, RB2, RE2, RK0, RK1, RK2);
11191
11192 + pax_force_retaddr
11193 ret;
11194 diff --git a/arch/x86/crypto/sha1_ssse3_asm.S b/arch/x86/crypto/sha1_ssse3_asm.S
11195 index 49d6987..df66bd4 100644
11196 --- a/arch/x86/crypto/sha1_ssse3_asm.S
11197 +++ b/arch/x86/crypto/sha1_ssse3_asm.S
11198 @@ -28,6 +28,8 @@
11199 * (at your option) any later version.
11200 */
11201
11202 +#include <asm/alternative-asm.h>
11203 +
11204 #define CTX %rdi // arg1
11205 #define BUF %rsi // arg2
11206 #define CNT %rdx // arg3
11207 @@ -104,6 +106,7 @@
11208 pop %r12
11209 pop %rbp
11210 pop %rbx
11211 + pax_force_retaddr 0, 1
11212 ret
11213
11214 .size \name, .-\name
11215 diff --git a/arch/x86/crypto/twofish-avx-x86_64-asm_64.S b/arch/x86/crypto/twofish-avx-x86_64-asm_64.S
11216 index ebac16b..8092eb9 100644
11217 --- a/arch/x86/crypto/twofish-avx-x86_64-asm_64.S
11218 +++ b/arch/x86/crypto/twofish-avx-x86_64-asm_64.S
11219 @@ -23,6 +23,8 @@
11220 *
11221 */
11222
11223 +#include <asm/alternative-asm.h>
11224 +
11225 #include "glue_helper-asm-avx.S"
11226
11227 .file "twofish-avx-x86_64-asm_64.S"
11228 @@ -283,6 +285,7 @@ __twofish_enc_blk8:
11229 outunpack_blocks(RC1, RD1, RA1, RB1, RK1, RX0, RY0, RK2);
11230 outunpack_blocks(RC2, RD2, RA2, RB2, RK1, RX0, RY0, RK2);
11231
11232 + pax_force_retaddr 0, 1
11233 ret;
11234
11235 .align 8
11236 @@ -324,6 +327,7 @@ __twofish_dec_blk8:
11237 outunpack_blocks(RA1, RB1, RC1, RD1, RK1, RX0, RY0, RK2);
11238 outunpack_blocks(RA2, RB2, RC2, RD2, RK1, RX0, RY0, RK2);
11239
11240 + pax_force_retaddr 0, 1
11241 ret;
11242
11243 .align 8
11244 @@ -345,6 +349,7 @@ twofish_ecb_enc_8way:
11245
11246 store_8way(%r11, RC1, RD1, RA1, RB1, RC2, RD2, RA2, RB2);
11247
11248 + pax_force_retaddr 0, 1
11249 ret;
11250
11251 .align 8
11252 @@ -366,6 +371,7 @@ twofish_ecb_dec_8way:
11253
11254 store_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
11255
11256 + pax_force_retaddr 0, 1
11257 ret;
11258
11259 .align 8
11260 @@ -392,6 +398,7 @@ twofish_cbc_dec_8way:
11261
11262 popq %r12;
11263
11264 + pax_force_retaddr 0, 1
11265 ret;
11266
11267 .align 8
11268 @@ -420,4 +427,5 @@ twofish_ctr_8way:
11269
11270 popq %r12;
11271
11272 + pax_force_retaddr 0, 1
11273 ret;
11274 diff --git a/arch/x86/crypto/twofish-x86_64-asm_64-3way.S b/arch/x86/crypto/twofish-x86_64-asm_64-3way.S
11275 index 5b012a2..36d5364 100644
11276 --- a/arch/x86/crypto/twofish-x86_64-asm_64-3way.S
11277 +++ b/arch/x86/crypto/twofish-x86_64-asm_64-3way.S
11278 @@ -20,6 +20,8 @@
11279 *
11280 */
11281
11282 +#include <asm/alternative-asm.h>
11283 +
11284 .file "twofish-x86_64-asm-3way.S"
11285 .text
11286
11287 @@ -260,6 +262,7 @@ __twofish_enc_blk_3way:
11288 popq %r13;
11289 popq %r14;
11290 popq %r15;
11291 + pax_force_retaddr 0, 1
11292 ret;
11293
11294 __enc_xor3:
11295 @@ -271,6 +274,7 @@ __enc_xor3:
11296 popq %r13;
11297 popq %r14;
11298 popq %r15;
11299 + pax_force_retaddr 0, 1
11300 ret;
11301
11302 .global twofish_dec_blk_3way
11303 @@ -312,5 +316,6 @@ twofish_dec_blk_3way:
11304 popq %r13;
11305 popq %r14;
11306 popq %r15;
11307 + pax_force_retaddr 0, 1
11308 ret;
11309
11310 diff --git a/arch/x86/crypto/twofish-x86_64-asm_64.S b/arch/x86/crypto/twofish-x86_64-asm_64.S
11311 index 7bcf3fc..f53832f 100644
11312 --- a/arch/x86/crypto/twofish-x86_64-asm_64.S
11313 +++ b/arch/x86/crypto/twofish-x86_64-asm_64.S
11314 @@ -21,6 +21,7 @@
11315 .text
11316
11317 #include <asm/asm-offsets.h>
11318 +#include <asm/alternative-asm.h>
11319
11320 #define a_offset 0
11321 #define b_offset 4
11322 @@ -268,6 +269,7 @@ twofish_enc_blk:
11323
11324 popq R1
11325 movq $1,%rax
11326 + pax_force_retaddr 0, 1
11327 ret
11328
11329 twofish_dec_blk:
11330 @@ -319,4 +321,5 @@ twofish_dec_blk:
11331
11332 popq R1
11333 movq $1,%rax
11334 + pax_force_retaddr 0, 1
11335 ret
11336 diff --git a/arch/x86/ia32/ia32_aout.c b/arch/x86/ia32/ia32_aout.c
11337 index a703af1..f5b9c36 100644
11338 --- a/arch/x86/ia32/ia32_aout.c
11339 +++ b/arch/x86/ia32/ia32_aout.c
11340 @@ -159,6 +159,8 @@ static int aout_core_dump(long signr, struct pt_regs *regs, struct file *file,
11341 unsigned long dump_start, dump_size;
11342 struct user32 dump;
11343
11344 + memset(&dump, 0, sizeof(dump));
11345 +
11346 fs = get_fs();
11347 set_fs(KERNEL_DS);
11348 has_dumped = 1;
11349 diff --git a/arch/x86/ia32/ia32_signal.c b/arch/x86/ia32/ia32_signal.c
11350 index a1daf4a..f8c4537 100644
11351 --- a/arch/x86/ia32/ia32_signal.c
11352 +++ b/arch/x86/ia32/ia32_signal.c
11353 @@ -348,7 +348,7 @@ static void __user *get_sigframe(struct k_sigaction *ka, struct pt_regs *regs,
11354 sp -= frame_size;
11355 /* Align the stack pointer according to the i386 ABI,
11356 * i.e. so that on function entry ((sp + 4) & 15) == 0. */
11357 - sp = ((sp + 4) & -16ul) - 4;
11358 + sp = ((sp - 12) & -16ul) - 4;
11359 return (void __user *) sp;
11360 }
11361
11362 @@ -406,7 +406,7 @@ int ia32_setup_frame(int sig, struct k_sigaction *ka,
11363 * These are actually not used anymore, but left because some
11364 * gdb versions depend on them as a marker.
11365 */
11366 - put_user_ex(*((u64 *)&code), (u64 __user *)frame->retcode);
11367 + put_user_ex(*((const u64 *)&code), (u64 __user *)frame->retcode);
11368 } put_user_catch(err);
11369
11370 if (err)
11371 @@ -448,7 +448,7 @@ int ia32_setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
11372 0xb8,
11373 __NR_ia32_rt_sigreturn,
11374 0x80cd,
11375 - 0,
11376 + 0
11377 };
11378
11379 frame = get_sigframe(ka, regs, sizeof(*frame), &fpstate);
11380 @@ -471,16 +471,18 @@ int ia32_setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
11381
11382 if (ka->sa.sa_flags & SA_RESTORER)
11383 restorer = ka->sa.sa_restorer;
11384 + else if (current->mm->context.vdso)
11385 + /* Return stub is in 32bit vsyscall page */
11386 + restorer = VDSO32_SYMBOL(current->mm->context.vdso, rt_sigreturn);
11387 else
11388 - restorer = VDSO32_SYMBOL(current->mm->context.vdso,
11389 - rt_sigreturn);
11390 + restorer = &frame->retcode;
11391 put_user_ex(ptr_to_compat(restorer), &frame->pretcode);
11392
11393 /*
11394 * Not actually used anymore, but left because some gdb
11395 * versions need it.
11396 */
11397 - put_user_ex(*((u64 *)&code), (u64 __user *)frame->retcode);
11398 + put_user_ex(*((const u64 *)&code), (u64 __user *)frame->retcode);
11399 } put_user_catch(err);
11400
11401 err |= copy_siginfo_to_user32(&frame->info, info);
11402 diff --git a/arch/x86/ia32/ia32entry.S b/arch/x86/ia32/ia32entry.S
11403 index 142c4ce..19b683f 100644
11404 --- a/arch/x86/ia32/ia32entry.S
11405 +++ b/arch/x86/ia32/ia32entry.S
11406 @@ -15,8 +15,10 @@
11407 #include <asm/irqflags.h>
11408 #include <asm/asm.h>
11409 #include <asm/smap.h>
11410 +#include <asm/pgtable.h>
11411 #include <linux/linkage.h>
11412 #include <linux/err.h>
11413 +#include <asm/alternative-asm.h>
11414
11415 /* Avoid __ASSEMBLER__'ifying <linux/audit.h> just for this. */
11416 #include <linux/elf-em.h>
11417 @@ -96,6 +98,32 @@ ENTRY(native_irq_enable_sysexit)
11418 ENDPROC(native_irq_enable_sysexit)
11419 #endif
11420
11421 + .macro pax_enter_kernel_user
11422 + pax_set_fptr_mask
11423 +#ifdef CONFIG_PAX_MEMORY_UDEREF
11424 + call pax_enter_kernel_user
11425 +#endif
11426 + .endm
11427 +
11428 + .macro pax_exit_kernel_user
11429 +#ifdef CONFIG_PAX_MEMORY_UDEREF
11430 + call pax_exit_kernel_user
11431 +#endif
11432 +#ifdef CONFIG_PAX_RANDKSTACK
11433 + pushq %rax
11434 + pushq %r11
11435 + call pax_randomize_kstack
11436 + popq %r11
11437 + popq %rax
11438 +#endif
11439 + .endm
11440 +
11441 +.macro pax_erase_kstack
11442 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
11443 + call pax_erase_kstack
11444 +#endif
11445 +.endm
11446 +
11447 /*
11448 * 32bit SYSENTER instruction entry.
11449 *
11450 @@ -122,12 +150,6 @@ ENTRY(ia32_sysenter_target)
11451 CFI_REGISTER rsp,rbp
11452 SWAPGS_UNSAFE_STACK
11453 movq PER_CPU_VAR(kernel_stack), %rsp
11454 - addq $(KERNEL_STACK_OFFSET),%rsp
11455 - /*
11456 - * No need to follow this irqs on/off section: the syscall
11457 - * disabled irqs, here we enable it straight after entry:
11458 - */
11459 - ENABLE_INTERRUPTS(CLBR_NONE)
11460 movl %ebp,%ebp /* zero extension */
11461 pushq_cfi $__USER32_DS
11462 /*CFI_REL_OFFSET ss,0*/
11463 @@ -135,24 +157,44 @@ ENTRY(ia32_sysenter_target)
11464 CFI_REL_OFFSET rsp,0
11465 pushfq_cfi
11466 /*CFI_REL_OFFSET rflags,0*/
11467 - movl TI_sysenter_return+THREAD_INFO(%rsp,3*8-KERNEL_STACK_OFFSET),%r10d
11468 - CFI_REGISTER rip,r10
11469 + orl $X86_EFLAGS_IF,(%rsp)
11470 + GET_THREAD_INFO(%r11)
11471 + movl TI_sysenter_return(%r11), %r11d
11472 + CFI_REGISTER rip,r11
11473 pushq_cfi $__USER32_CS
11474 /*CFI_REL_OFFSET cs,0*/
11475 movl %eax, %eax
11476 - pushq_cfi %r10
11477 + pushq_cfi %r11
11478 CFI_REL_OFFSET rip,0
11479 pushq_cfi %rax
11480 cld
11481 SAVE_ARGS 0,1,0
11482 + pax_enter_kernel_user
11483 +
11484 +#ifdef CONFIG_PAX_RANDKSTACK
11485 + pax_erase_kstack
11486 +#endif
11487 +
11488 + /*
11489 + * No need to follow this irqs on/off section: the syscall
11490 + * disabled irqs, here we enable it straight after entry:
11491 + */
11492 + ENABLE_INTERRUPTS(CLBR_NONE)
11493 /* no need to do an access_ok check here because rbp has been
11494 32bit zero extended */
11495 +
11496 +#ifdef CONFIG_PAX_MEMORY_UDEREF
11497 + mov $PAX_USER_SHADOW_BASE,%r11
11498 + add %r11,%rbp
11499 +#endif
11500 +
11501 ASM_STAC
11502 1: movl (%rbp),%ebp
11503 _ASM_EXTABLE(1b,ia32_badarg)
11504 ASM_CLAC
11505 - orl $TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11506 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11507 + GET_THREAD_INFO(%r11)
11508 + orl $TS_COMPAT,TI_status(%r11)
11509 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%r11)
11510 CFI_REMEMBER_STATE
11511 jnz sysenter_tracesys
11512 cmpq $(IA32_NR_syscalls-1),%rax
11513 @@ -162,12 +204,15 @@ sysenter_do_call:
11514 sysenter_dispatch:
11515 call *ia32_sys_call_table(,%rax,8)
11516 movq %rax,RAX-ARGOFFSET(%rsp)
11517 + GET_THREAD_INFO(%r11)
11518 DISABLE_INTERRUPTS(CLBR_NONE)
11519 TRACE_IRQS_OFF
11520 - testl $_TIF_ALLWORK_MASK,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11521 + testl $_TIF_ALLWORK_MASK,TI_flags(%r11)
11522 jnz sysexit_audit
11523 sysexit_from_sys_call:
11524 - andl $~TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11525 + pax_exit_kernel_user
11526 + pax_erase_kstack
11527 + andl $~TS_COMPAT,TI_status(%r11)
11528 /* clear IF, that popfq doesn't enable interrupts early */
11529 andl $~0x200,EFLAGS-R11(%rsp)
11530 movl RIP-R11(%rsp),%edx /* User %eip */
11531 @@ -193,6 +238,9 @@ sysexit_from_sys_call:
11532 movl %eax,%esi /* 2nd arg: syscall number */
11533 movl $AUDIT_ARCH_I386,%edi /* 1st arg: audit arch */
11534 call __audit_syscall_entry
11535 +
11536 + pax_erase_kstack
11537 +
11538 movl RAX-ARGOFFSET(%rsp),%eax /* reload syscall number */
11539 cmpq $(IA32_NR_syscalls-1),%rax
11540 ja ia32_badsys
11541 @@ -204,7 +252,7 @@ sysexit_from_sys_call:
11542 .endm
11543
11544 .macro auditsys_exit exit
11545 - testl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11546 + testl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT),TI_flags(%r11)
11547 jnz ia32_ret_from_sys_call
11548 TRACE_IRQS_ON
11549 ENABLE_INTERRUPTS(CLBR_NONE)
11550 @@ -215,11 +263,12 @@ sysexit_from_sys_call:
11551 1: setbe %al /* 1 if error, 0 if not */
11552 movzbl %al,%edi /* zero-extend that into %edi */
11553 call __audit_syscall_exit
11554 + GET_THREAD_INFO(%r11)
11555 movq RAX-ARGOFFSET(%rsp),%rax /* reload syscall return value */
11556 movl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT),%edi
11557 DISABLE_INTERRUPTS(CLBR_NONE)
11558 TRACE_IRQS_OFF
11559 - testl %edi,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11560 + testl %edi,TI_flags(%r11)
11561 jz \exit
11562 CLEAR_RREGS -ARGOFFSET
11563 jmp int_with_check
11564 @@ -237,7 +286,7 @@ sysexit_audit:
11565
11566 sysenter_tracesys:
11567 #ifdef CONFIG_AUDITSYSCALL
11568 - testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11569 + testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags(%r11)
11570 jz sysenter_auditsys
11571 #endif
11572 SAVE_REST
11573 @@ -249,6 +298,9 @@ sysenter_tracesys:
11574 RESTORE_REST
11575 cmpq $(IA32_NR_syscalls-1),%rax
11576 ja int_ret_from_sys_call /* sysenter_tracesys has set RAX(%rsp) */
11577 +
11578 + pax_erase_kstack
11579 +
11580 jmp sysenter_do_call
11581 CFI_ENDPROC
11582 ENDPROC(ia32_sysenter_target)
11583 @@ -276,19 +328,25 @@ ENDPROC(ia32_sysenter_target)
11584 ENTRY(ia32_cstar_target)
11585 CFI_STARTPROC32 simple
11586 CFI_SIGNAL_FRAME
11587 - CFI_DEF_CFA rsp,KERNEL_STACK_OFFSET
11588 + CFI_DEF_CFA rsp,0
11589 CFI_REGISTER rip,rcx
11590 /*CFI_REGISTER rflags,r11*/
11591 SWAPGS_UNSAFE_STACK
11592 movl %esp,%r8d
11593 CFI_REGISTER rsp,r8
11594 movq PER_CPU_VAR(kernel_stack),%rsp
11595 + SAVE_ARGS 8*6,0,0
11596 + pax_enter_kernel_user
11597 +
11598 +#ifdef CONFIG_PAX_RANDKSTACK
11599 + pax_erase_kstack
11600 +#endif
11601 +
11602 /*
11603 * No need to follow this irqs on/off section: the syscall
11604 * disabled irqs and here we enable it straight after entry:
11605 */
11606 ENABLE_INTERRUPTS(CLBR_NONE)
11607 - SAVE_ARGS 8,0,0
11608 movl %eax,%eax /* zero extension */
11609 movq %rax,ORIG_RAX-ARGOFFSET(%rsp)
11610 movq %rcx,RIP-ARGOFFSET(%rsp)
11611 @@ -304,12 +362,19 @@ ENTRY(ia32_cstar_target)
11612 /* no need to do an access_ok check here because r8 has been
11613 32bit zero extended */
11614 /* hardware stack frame is complete now */
11615 +
11616 +#ifdef CONFIG_PAX_MEMORY_UDEREF
11617 + mov $PAX_USER_SHADOW_BASE,%r11
11618 + add %r11,%r8
11619 +#endif
11620 +
11621 ASM_STAC
11622 1: movl (%r8),%r9d
11623 _ASM_EXTABLE(1b,ia32_badarg)
11624 ASM_CLAC
11625 - orl $TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11626 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11627 + GET_THREAD_INFO(%r11)
11628 + orl $TS_COMPAT,TI_status(%r11)
11629 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%r11)
11630 CFI_REMEMBER_STATE
11631 jnz cstar_tracesys
11632 cmpq $IA32_NR_syscalls-1,%rax
11633 @@ -319,12 +384,15 @@ cstar_do_call:
11634 cstar_dispatch:
11635 call *ia32_sys_call_table(,%rax,8)
11636 movq %rax,RAX-ARGOFFSET(%rsp)
11637 + GET_THREAD_INFO(%r11)
11638 DISABLE_INTERRUPTS(CLBR_NONE)
11639 TRACE_IRQS_OFF
11640 - testl $_TIF_ALLWORK_MASK,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11641 + testl $_TIF_ALLWORK_MASK,TI_flags(%r11)
11642 jnz sysretl_audit
11643 sysretl_from_sys_call:
11644 - andl $~TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11645 + pax_exit_kernel_user
11646 + pax_erase_kstack
11647 + andl $~TS_COMPAT,TI_status(%r11)
11648 RESTORE_ARGS 0,-ARG_SKIP,0,0,0
11649 movl RIP-ARGOFFSET(%rsp),%ecx
11650 CFI_REGISTER rip,rcx
11651 @@ -352,7 +420,7 @@ sysretl_audit:
11652
11653 cstar_tracesys:
11654 #ifdef CONFIG_AUDITSYSCALL
11655 - testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11656 + testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags(%r11)
11657 jz cstar_auditsys
11658 #endif
11659 xchgl %r9d,%ebp
11660 @@ -366,6 +434,9 @@ cstar_tracesys:
11661 xchgl %ebp,%r9d
11662 cmpq $(IA32_NR_syscalls-1),%rax
11663 ja int_ret_from_sys_call /* cstar_tracesys has set RAX(%rsp) */
11664 +
11665 + pax_erase_kstack
11666 +
11667 jmp cstar_do_call
11668 END(ia32_cstar_target)
11669
11670 @@ -407,19 +478,26 @@ ENTRY(ia32_syscall)
11671 CFI_REL_OFFSET rip,RIP-RIP
11672 PARAVIRT_ADJUST_EXCEPTION_FRAME
11673 SWAPGS
11674 - /*
11675 - * No need to follow this irqs on/off section: the syscall
11676 - * disabled irqs and here we enable it straight after entry:
11677 - */
11678 - ENABLE_INTERRUPTS(CLBR_NONE)
11679 movl %eax,%eax
11680 pushq_cfi %rax
11681 cld
11682 /* note the registers are not zero extended to the sf.
11683 this could be a problem. */
11684 SAVE_ARGS 0,1,0
11685 - orl $TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11686 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11687 + pax_enter_kernel_user
11688 +
11689 +#ifdef CONFIG_PAX_RANDKSTACK
11690 + pax_erase_kstack
11691 +#endif
11692 +
11693 + /*
11694 + * No need to follow this irqs on/off section: the syscall
11695 + * disabled irqs and here we enable it straight after entry:
11696 + */
11697 + ENABLE_INTERRUPTS(CLBR_NONE)
11698 + GET_THREAD_INFO(%r11)
11699 + orl $TS_COMPAT,TI_status(%r11)
11700 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%r11)
11701 jnz ia32_tracesys
11702 cmpq $(IA32_NR_syscalls-1),%rax
11703 ja ia32_badsys
11704 @@ -442,6 +520,9 @@ ia32_tracesys:
11705 RESTORE_REST
11706 cmpq $(IA32_NR_syscalls-1),%rax
11707 ja int_ret_from_sys_call /* ia32_tracesys has set RAX(%rsp) */
11708 +
11709 + pax_erase_kstack
11710 +
11711 jmp ia32_do_call
11712 END(ia32_syscall)
11713
11714 diff --git a/arch/x86/ia32/sys_ia32.c b/arch/x86/ia32/sys_ia32.c
11715 index d0b689b..34be51d 100644
11716 --- a/arch/x86/ia32/sys_ia32.c
11717 +++ b/arch/x86/ia32/sys_ia32.c
11718 @@ -69,8 +69,8 @@ asmlinkage long sys32_ftruncate64(unsigned int fd, unsigned long offset_low,
11719 */
11720 static int cp_stat64(struct stat64 __user *ubuf, struct kstat *stat)
11721 {
11722 - typeof(ubuf->st_uid) uid = 0;
11723 - typeof(ubuf->st_gid) gid = 0;
11724 + typeof(((struct stat64 *)0)->st_uid) uid = 0;
11725 + typeof(((struct stat64 *)0)->st_gid) gid = 0;
11726 SET_UID(uid, from_kuid_munged(current_user_ns(), stat->uid));
11727 SET_GID(gid, from_kgid_munged(current_user_ns(), stat->gid));
11728 if (!access_ok(VERIFY_WRITE, ubuf, sizeof(struct stat64)) ||
11729 @@ -303,7 +303,7 @@ asmlinkage long sys32_sched_rr_get_interval(compat_pid_t pid,
11730 mm_segment_t old_fs = get_fs();
11731
11732 set_fs(KERNEL_DS);
11733 - ret = sys_sched_rr_get_interval(pid, (struct timespec __user *)&t);
11734 + ret = sys_sched_rr_get_interval(pid, (struct timespec __force_user *)&t);
11735 set_fs(old_fs);
11736 if (put_compat_timespec(&t, interval))
11737 return -EFAULT;
11738 @@ -319,7 +319,7 @@ asmlinkage long sys32_rt_sigpending(compat_sigset_t __user *set,
11739 mm_segment_t old_fs = get_fs();
11740
11741 set_fs(KERNEL_DS);
11742 - ret = sys_rt_sigpending((sigset_t __user *)&s, sigsetsize);
11743 + ret = sys_rt_sigpending((sigset_t __force_user *)&s, sigsetsize);
11744 set_fs(old_fs);
11745 if (!ret) {
11746 switch (_NSIG_WORDS) {
11747 @@ -344,7 +344,7 @@ asmlinkage long sys32_rt_sigqueueinfo(int pid, int sig,
11748 if (copy_siginfo_from_user32(&info, uinfo))
11749 return -EFAULT;
11750 set_fs(KERNEL_DS);
11751 - ret = sys_rt_sigqueueinfo(pid, sig, (siginfo_t __user *)&info);
11752 + ret = sys_rt_sigqueueinfo(pid, sig, (siginfo_t __force_user *)&info);
11753 set_fs(old_fs);
11754 return ret;
11755 }
11756 @@ -376,7 +376,7 @@ asmlinkage long sys32_sendfile(int out_fd, int in_fd,
11757 return -EFAULT;
11758
11759 set_fs(KERNEL_DS);
11760 - ret = sys_sendfile(out_fd, in_fd, offset ? (off_t __user *)&of : NULL,
11761 + ret = sys_sendfile(out_fd, in_fd, offset ? (off_t __force_user *)&of : NULL,
11762 count);
11763 set_fs(old_fs);
11764
11765 diff --git a/arch/x86/include/asm/alternative-asm.h b/arch/x86/include/asm/alternative-asm.h
11766 index 372231c..a5aa1a1 100644
11767 --- a/arch/x86/include/asm/alternative-asm.h
11768 +++ b/arch/x86/include/asm/alternative-asm.h
11769 @@ -18,6 +18,45 @@
11770 .endm
11771 #endif
11772
11773 +#ifdef KERNEXEC_PLUGIN
11774 + .macro pax_force_retaddr_bts rip=0
11775 + btsq $63,\rip(%rsp)
11776 + .endm
11777 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_BTS
11778 + .macro pax_force_retaddr rip=0, reload=0
11779 + btsq $63,\rip(%rsp)
11780 + .endm
11781 + .macro pax_force_fptr ptr
11782 + btsq $63,\ptr
11783 + .endm
11784 + .macro pax_set_fptr_mask
11785 + .endm
11786 +#endif
11787 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR
11788 + .macro pax_force_retaddr rip=0, reload=0
11789 + .if \reload
11790 + pax_set_fptr_mask
11791 + .endif
11792 + orq %r10,\rip(%rsp)
11793 + .endm
11794 + .macro pax_force_fptr ptr
11795 + orq %r10,\ptr
11796 + .endm
11797 + .macro pax_set_fptr_mask
11798 + movabs $0x8000000000000000,%r10
11799 + .endm
11800 +#endif
11801 +#else
11802 + .macro pax_force_retaddr rip=0, reload=0
11803 + .endm
11804 + .macro pax_force_fptr ptr
11805 + .endm
11806 + .macro pax_force_retaddr_bts rip=0
11807 + .endm
11808 + .macro pax_set_fptr_mask
11809 + .endm
11810 +#endif
11811 +
11812 .macro altinstruction_entry orig alt feature orig_len alt_len
11813 .long \orig - .
11814 .long \alt - .
11815 diff --git a/arch/x86/include/asm/alternative.h b/arch/x86/include/asm/alternative.h
11816 index 58ed6d9..f1cbe58 100644
11817 --- a/arch/x86/include/asm/alternative.h
11818 +++ b/arch/x86/include/asm/alternative.h
11819 @@ -105,7 +105,7 @@ static inline int alternatives_text_reserved(void *start, void *end)
11820 ".pushsection .discard,\"aw\",@progbits\n" \
11821 DISCARD_ENTRY(1) \
11822 ".popsection\n" \
11823 - ".pushsection .altinstr_replacement, \"ax\"\n" \
11824 + ".pushsection .altinstr_replacement, \"a\"\n" \
11825 ALTINSTR_REPLACEMENT(newinstr, feature, 1) \
11826 ".popsection"
11827
11828 @@ -119,7 +119,7 @@ static inline int alternatives_text_reserved(void *start, void *end)
11829 DISCARD_ENTRY(1) \
11830 DISCARD_ENTRY(2) \
11831 ".popsection\n" \
11832 - ".pushsection .altinstr_replacement, \"ax\"\n" \
11833 + ".pushsection .altinstr_replacement, \"a\"\n" \
11834 ALTINSTR_REPLACEMENT(newinstr1, feature1, 1) \
11835 ALTINSTR_REPLACEMENT(newinstr2, feature2, 2) \
11836 ".popsection"
11837 diff --git a/arch/x86/include/asm/apic.h b/arch/x86/include/asm/apic.h
11838 index 3388034..050f0b9 100644
11839 --- a/arch/x86/include/asm/apic.h
11840 +++ b/arch/x86/include/asm/apic.h
11841 @@ -44,7 +44,7 @@ static inline void generic_apic_probe(void)
11842
11843 #ifdef CONFIG_X86_LOCAL_APIC
11844
11845 -extern unsigned int apic_verbosity;
11846 +extern int apic_verbosity;
11847 extern int local_apic_timer_c2_ok;
11848
11849 extern int disable_apic;
11850 diff --git a/arch/x86/include/asm/apm.h b/arch/x86/include/asm/apm.h
11851 index 20370c6..a2eb9b0 100644
11852 --- a/arch/x86/include/asm/apm.h
11853 +++ b/arch/x86/include/asm/apm.h
11854 @@ -34,7 +34,7 @@ static inline void apm_bios_call_asm(u32 func, u32 ebx_in, u32 ecx_in,
11855 __asm__ __volatile__(APM_DO_ZERO_SEGS
11856 "pushl %%edi\n\t"
11857 "pushl %%ebp\n\t"
11858 - "lcall *%%cs:apm_bios_entry\n\t"
11859 + "lcall *%%ss:apm_bios_entry\n\t"
11860 "setc %%al\n\t"
11861 "popl %%ebp\n\t"
11862 "popl %%edi\n\t"
11863 @@ -58,7 +58,7 @@ static inline u8 apm_bios_call_simple_asm(u32 func, u32 ebx_in,
11864 __asm__ __volatile__(APM_DO_ZERO_SEGS
11865 "pushl %%edi\n\t"
11866 "pushl %%ebp\n\t"
11867 - "lcall *%%cs:apm_bios_entry\n\t"
11868 + "lcall *%%ss:apm_bios_entry\n\t"
11869 "setc %%bl\n\t"
11870 "popl %%ebp\n\t"
11871 "popl %%edi\n\t"
11872 diff --git a/arch/x86/include/asm/atomic.h b/arch/x86/include/asm/atomic.h
11873 index 722aa3b..3a0bb27 100644
11874 --- a/arch/x86/include/asm/atomic.h
11875 +++ b/arch/x86/include/asm/atomic.h
11876 @@ -22,7 +22,18 @@
11877 */
11878 static inline int atomic_read(const atomic_t *v)
11879 {
11880 - return (*(volatile int *)&(v)->counter);
11881 + return (*(volatile const int *)&(v)->counter);
11882 +}
11883 +
11884 +/**
11885 + * atomic_read_unchecked - read atomic variable
11886 + * @v: pointer of type atomic_unchecked_t
11887 + *
11888 + * Atomically reads the value of @v.
11889 + */
11890 +static inline int atomic_read_unchecked(const atomic_unchecked_t *v)
11891 +{
11892 + return (*(volatile const int *)&(v)->counter);
11893 }
11894
11895 /**
11896 @@ -38,6 +49,18 @@ static inline void atomic_set(atomic_t *v, int i)
11897 }
11898
11899 /**
11900 + * atomic_set_unchecked - set atomic variable
11901 + * @v: pointer of type atomic_unchecked_t
11902 + * @i: required value
11903 + *
11904 + * Atomically sets the value of @v to @i.
11905 + */
11906 +static inline void atomic_set_unchecked(atomic_unchecked_t *v, int i)
11907 +{
11908 + v->counter = i;
11909 +}
11910 +
11911 +/**
11912 * atomic_add - add integer to atomic variable
11913 * @i: integer value to add
11914 * @v: pointer of type atomic_t
11915 @@ -46,7 +69,29 @@ static inline void atomic_set(atomic_t *v, int i)
11916 */
11917 static inline void atomic_add(int i, atomic_t *v)
11918 {
11919 - asm volatile(LOCK_PREFIX "addl %1,%0"
11920 + asm volatile(LOCK_PREFIX "addl %1,%0\n"
11921 +
11922 +#ifdef CONFIG_PAX_REFCOUNT
11923 + "jno 0f\n"
11924 + LOCK_PREFIX "subl %1,%0\n"
11925 + "int $4\n0:\n"
11926 + _ASM_EXTABLE(0b, 0b)
11927 +#endif
11928 +
11929 + : "+m" (v->counter)
11930 + : "ir" (i));
11931 +}
11932 +
11933 +/**
11934 + * atomic_add_unchecked - add integer to atomic variable
11935 + * @i: integer value to add
11936 + * @v: pointer of type atomic_unchecked_t
11937 + *
11938 + * Atomically adds @i to @v.
11939 + */
11940 +static inline void atomic_add_unchecked(int i, atomic_unchecked_t *v)
11941 +{
11942 + asm volatile(LOCK_PREFIX "addl %1,%0\n"
11943 : "+m" (v->counter)
11944 : "ir" (i));
11945 }
11946 @@ -60,7 +105,29 @@ static inline void atomic_add(int i, atomic_t *v)
11947 */
11948 static inline void atomic_sub(int i, atomic_t *v)
11949 {
11950 - asm volatile(LOCK_PREFIX "subl %1,%0"
11951 + asm volatile(LOCK_PREFIX "subl %1,%0\n"
11952 +
11953 +#ifdef CONFIG_PAX_REFCOUNT
11954 + "jno 0f\n"
11955 + LOCK_PREFIX "addl %1,%0\n"
11956 + "int $4\n0:\n"
11957 + _ASM_EXTABLE(0b, 0b)
11958 +#endif
11959 +
11960 + : "+m" (v->counter)
11961 + : "ir" (i));
11962 +}
11963 +
11964 +/**
11965 + * atomic_sub_unchecked - subtract integer from atomic variable
11966 + * @i: integer value to subtract
11967 + * @v: pointer of type atomic_unchecked_t
11968 + *
11969 + * Atomically subtracts @i from @v.
11970 + */
11971 +static inline void atomic_sub_unchecked(int i, atomic_unchecked_t *v)
11972 +{
11973 + asm volatile(LOCK_PREFIX "subl %1,%0\n"
11974 : "+m" (v->counter)
11975 : "ir" (i));
11976 }
11977 @@ -78,7 +145,16 @@ static inline int atomic_sub_and_test(int i, atomic_t *v)
11978 {
11979 unsigned char c;
11980
11981 - asm volatile(LOCK_PREFIX "subl %2,%0; sete %1"
11982 + asm volatile(LOCK_PREFIX "subl %2,%0\n"
11983 +
11984 +#ifdef CONFIG_PAX_REFCOUNT
11985 + "jno 0f\n"
11986 + LOCK_PREFIX "addl %2,%0\n"
11987 + "int $4\n0:\n"
11988 + _ASM_EXTABLE(0b, 0b)
11989 +#endif
11990 +
11991 + "sete %1\n"
11992 : "+m" (v->counter), "=qm" (c)
11993 : "ir" (i) : "memory");
11994 return c;
11995 @@ -92,7 +168,27 @@ static inline int atomic_sub_and_test(int i, atomic_t *v)
11996 */
11997 static inline void atomic_inc(atomic_t *v)
11998 {
11999 - asm volatile(LOCK_PREFIX "incl %0"
12000 + asm volatile(LOCK_PREFIX "incl %0\n"
12001 +
12002 +#ifdef CONFIG_PAX_REFCOUNT
12003 + "jno 0f\n"
12004 + LOCK_PREFIX "decl %0\n"
12005 + "int $4\n0:\n"
12006 + _ASM_EXTABLE(0b, 0b)
12007 +#endif
12008 +
12009 + : "+m" (v->counter));
12010 +}
12011 +
12012 +/**
12013 + * atomic_inc_unchecked - increment atomic variable
12014 + * @v: pointer of type atomic_unchecked_t
12015 + *
12016 + * Atomically increments @v by 1.
12017 + */
12018 +static inline void atomic_inc_unchecked(atomic_unchecked_t *v)
12019 +{
12020 + asm volatile(LOCK_PREFIX "incl %0\n"
12021 : "+m" (v->counter));
12022 }
12023
12024 @@ -104,7 +200,27 @@ static inline void atomic_inc(atomic_t *v)
12025 */
12026 static inline void atomic_dec(atomic_t *v)
12027 {
12028 - asm volatile(LOCK_PREFIX "decl %0"
12029 + asm volatile(LOCK_PREFIX "decl %0\n"
12030 +
12031 +#ifdef CONFIG_PAX_REFCOUNT
12032 + "jno 0f\n"
12033 + LOCK_PREFIX "incl %0\n"
12034 + "int $4\n0:\n"
12035 + _ASM_EXTABLE(0b, 0b)
12036 +#endif
12037 +
12038 + : "+m" (v->counter));
12039 +}
12040 +
12041 +/**
12042 + * atomic_dec_unchecked - decrement atomic variable
12043 + * @v: pointer of type atomic_unchecked_t
12044 + *
12045 + * Atomically decrements @v by 1.
12046 + */
12047 +static inline void atomic_dec_unchecked(atomic_unchecked_t *v)
12048 +{
12049 + asm volatile(LOCK_PREFIX "decl %0\n"
12050 : "+m" (v->counter));
12051 }
12052
12053 @@ -120,7 +236,16 @@ static inline int atomic_dec_and_test(atomic_t *v)
12054 {
12055 unsigned char c;
12056
12057 - asm volatile(LOCK_PREFIX "decl %0; sete %1"
12058 + asm volatile(LOCK_PREFIX "decl %0\n"
12059 +
12060 +#ifdef CONFIG_PAX_REFCOUNT
12061 + "jno 0f\n"
12062 + LOCK_PREFIX "incl %0\n"
12063 + "int $4\n0:\n"
12064 + _ASM_EXTABLE(0b, 0b)
12065 +#endif
12066 +
12067 + "sete %1\n"
12068 : "+m" (v->counter), "=qm" (c)
12069 : : "memory");
12070 return c != 0;
12071 @@ -138,7 +263,35 @@ static inline int atomic_inc_and_test(atomic_t *v)
12072 {
12073 unsigned char c;
12074
12075 - asm volatile(LOCK_PREFIX "incl %0; sete %1"
12076 + asm volatile(LOCK_PREFIX "incl %0\n"
12077 +
12078 +#ifdef CONFIG_PAX_REFCOUNT
12079 + "jno 0f\n"
12080 + LOCK_PREFIX "decl %0\n"
12081 + "int $4\n0:\n"
12082 + _ASM_EXTABLE(0b, 0b)
12083 +#endif
12084 +
12085 + "sete %1\n"
12086 + : "+m" (v->counter), "=qm" (c)
12087 + : : "memory");
12088 + return c != 0;
12089 +}
12090 +
12091 +/**
12092 + * atomic_inc_and_test_unchecked - increment and test
12093 + * @v: pointer of type atomic_unchecked_t
12094 + *
12095 + * Atomically increments @v by 1
12096 + * and returns true if the result is zero, or false for all
12097 + * other cases.
12098 + */
12099 +static inline int atomic_inc_and_test_unchecked(atomic_unchecked_t *v)
12100 +{
12101 + unsigned char c;
12102 +
12103 + asm volatile(LOCK_PREFIX "incl %0\n"
12104 + "sete %1\n"
12105 : "+m" (v->counter), "=qm" (c)
12106 : : "memory");
12107 return c != 0;
12108 @@ -157,7 +310,16 @@ static inline int atomic_add_negative(int i, atomic_t *v)
12109 {
12110 unsigned char c;
12111
12112 - asm volatile(LOCK_PREFIX "addl %2,%0; sets %1"
12113 + asm volatile(LOCK_PREFIX "addl %2,%0\n"
12114 +
12115 +#ifdef CONFIG_PAX_REFCOUNT
12116 + "jno 0f\n"
12117 + LOCK_PREFIX "subl %2,%0\n"
12118 + "int $4\n0:\n"
12119 + _ASM_EXTABLE(0b, 0b)
12120 +#endif
12121 +
12122 + "sets %1\n"
12123 : "+m" (v->counter), "=qm" (c)
12124 : "ir" (i) : "memory");
12125 return c;
12126 @@ -172,6 +334,18 @@ static inline int atomic_add_negative(int i, atomic_t *v)
12127 */
12128 static inline int atomic_add_return(int i, atomic_t *v)
12129 {
12130 + return i + xadd_check_overflow(&v->counter, i);
12131 +}
12132 +
12133 +/**
12134 + * atomic_add_return_unchecked - add integer and return
12135 + * @i: integer value to add
12136 + * @v: pointer of type atomic_unchecked_t
12137 + *
12138 + * Atomically adds @i to @v and returns @i + @v
12139 + */
12140 +static inline int atomic_add_return_unchecked(int i, atomic_unchecked_t *v)
12141 +{
12142 return i + xadd(&v->counter, i);
12143 }
12144
12145 @@ -188,6 +362,10 @@ static inline int atomic_sub_return(int i, atomic_t *v)
12146 }
12147
12148 #define atomic_inc_return(v) (atomic_add_return(1, v))
12149 +static inline int atomic_inc_return_unchecked(atomic_unchecked_t *v)
12150 +{
12151 + return atomic_add_return_unchecked(1, v);
12152 +}
12153 #define atomic_dec_return(v) (atomic_sub_return(1, v))
12154
12155 static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
12156 @@ -195,11 +373,21 @@ static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
12157 return cmpxchg(&v->counter, old, new);
12158 }
12159
12160 +static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *v, int old, int new)
12161 +{
12162 + return cmpxchg(&v->counter, old, new);
12163 +}
12164 +
12165 static inline int atomic_xchg(atomic_t *v, int new)
12166 {
12167 return xchg(&v->counter, new);
12168 }
12169
12170 +static inline int atomic_xchg_unchecked(atomic_unchecked_t *v, int new)
12171 +{
12172 + return xchg(&v->counter, new);
12173 +}
12174 +
12175 /**
12176 * __atomic_add_unless - add unless the number is already a given value
12177 * @v: pointer of type atomic_t
12178 @@ -211,12 +399,25 @@ static inline int atomic_xchg(atomic_t *v, int new)
12179 */
12180 static inline int __atomic_add_unless(atomic_t *v, int a, int u)
12181 {
12182 - int c, old;
12183 + int c, old, new;
12184 c = atomic_read(v);
12185 for (;;) {
12186 - if (unlikely(c == (u)))
12187 + if (unlikely(c == u))
12188 break;
12189 - old = atomic_cmpxchg((v), c, c + (a));
12190 +
12191 + asm volatile("addl %2,%0\n"
12192 +
12193 +#ifdef CONFIG_PAX_REFCOUNT
12194 + "jno 0f\n"
12195 + "subl %2,%0\n"
12196 + "int $4\n0:\n"
12197 + _ASM_EXTABLE(0b, 0b)
12198 +#endif
12199 +
12200 + : "=r" (new)
12201 + : "0" (c), "ir" (a));
12202 +
12203 + old = atomic_cmpxchg(v, c, new);
12204 if (likely(old == c))
12205 break;
12206 c = old;
12207 @@ -225,6 +426,49 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
12208 }
12209
12210 /**
12211 + * atomic_inc_not_zero_hint - increment if not null
12212 + * @v: pointer of type atomic_t
12213 + * @hint: probable value of the atomic before the increment
12214 + *
12215 + * This version of atomic_inc_not_zero() gives a hint of probable
12216 + * value of the atomic. This helps processor to not read the memory
12217 + * before doing the atomic read/modify/write cycle, lowering
12218 + * number of bus transactions on some arches.
12219 + *
12220 + * Returns: 0 if increment was not done, 1 otherwise.
12221 + */
12222 +#define atomic_inc_not_zero_hint atomic_inc_not_zero_hint
12223 +static inline int atomic_inc_not_zero_hint(atomic_t *v, int hint)
12224 +{
12225 + int val, c = hint, new;
12226 +
12227 + /* sanity test, should be removed by compiler if hint is a constant */
12228 + if (!hint)
12229 + return __atomic_add_unless(v, 1, 0);
12230 +
12231 + do {
12232 + asm volatile("incl %0\n"
12233 +
12234 +#ifdef CONFIG_PAX_REFCOUNT
12235 + "jno 0f\n"
12236 + "decl %0\n"
12237 + "int $4\n0:\n"
12238 + _ASM_EXTABLE(0b, 0b)
12239 +#endif
12240 +
12241 + : "=r" (new)
12242 + : "0" (c));
12243 +
12244 + val = atomic_cmpxchg(v, c, new);
12245 + if (val == c)
12246 + return 1;
12247 + c = val;
12248 + } while (c);
12249 +
12250 + return 0;
12251 +}
12252 +
12253 +/**
12254 * atomic_inc_short - increment of a short integer
12255 * @v: pointer to type int
12256 *
12257 @@ -253,14 +497,37 @@ static inline void atomic_or_long(unsigned long *v1, unsigned long v2)
12258 #endif
12259
12260 /* These are x86-specific, used by some header files */
12261 -#define atomic_clear_mask(mask, addr) \
12262 - asm volatile(LOCK_PREFIX "andl %0,%1" \
12263 - : : "r" (~(mask)), "m" (*(addr)) : "memory")
12264 +static inline void atomic_clear_mask(unsigned int mask, atomic_t *v)
12265 +{
12266 + asm volatile(LOCK_PREFIX "andl %1,%0"
12267 + : "+m" (v->counter)
12268 + : "r" (~(mask))
12269 + : "memory");
12270 +}
12271
12272 -#define atomic_set_mask(mask, addr) \
12273 - asm volatile(LOCK_PREFIX "orl %0,%1" \
12274 - : : "r" ((unsigned)(mask)), "m" (*(addr)) \
12275 - : "memory")
12276 +static inline void atomic_clear_mask_unchecked(unsigned int mask, atomic_unchecked_t *v)
12277 +{
12278 + asm volatile(LOCK_PREFIX "andl %1,%0"
12279 + : "+m" (v->counter)
12280 + : "r" (~(mask))
12281 + : "memory");
12282 +}
12283 +
12284 +static inline void atomic_set_mask(unsigned int mask, atomic_t *v)
12285 +{
12286 + asm volatile(LOCK_PREFIX "orl %1,%0"
12287 + : "+m" (v->counter)
12288 + : "r" (mask)
12289 + : "memory");
12290 +}
12291 +
12292 +static inline void atomic_set_mask_unchecked(unsigned int mask, atomic_unchecked_t *v)
12293 +{
12294 + asm volatile(LOCK_PREFIX "orl %1,%0"
12295 + : "+m" (v->counter)
12296 + : "r" (mask)
12297 + : "memory");
12298 +}
12299
12300 /* Atomic operations are already serializing on x86 */
12301 #define smp_mb__before_atomic_dec() barrier()
12302 diff --git a/arch/x86/include/asm/atomic64_32.h b/arch/x86/include/asm/atomic64_32.h
12303 index b154de7..aadebd8 100644
12304 --- a/arch/x86/include/asm/atomic64_32.h
12305 +++ b/arch/x86/include/asm/atomic64_32.h
12306 @@ -12,6 +12,14 @@ typedef struct {
12307 u64 __aligned(8) counter;
12308 } atomic64_t;
12309
12310 +#ifdef CONFIG_PAX_REFCOUNT
12311 +typedef struct {
12312 + u64 __aligned(8) counter;
12313 +} atomic64_unchecked_t;
12314 +#else
12315 +typedef atomic64_t atomic64_unchecked_t;
12316 +#endif
12317 +
12318 #define ATOMIC64_INIT(val) { (val) }
12319
12320 #define __ATOMIC64_DECL(sym) void atomic64_##sym(atomic64_t *, ...)
12321 @@ -37,21 +45,31 @@ typedef struct {
12322 ATOMIC64_DECL_ONE(sym##_386)
12323
12324 ATOMIC64_DECL_ONE(add_386);
12325 +ATOMIC64_DECL_ONE(add_unchecked_386);
12326 ATOMIC64_DECL_ONE(sub_386);
12327 +ATOMIC64_DECL_ONE(sub_unchecked_386);
12328 ATOMIC64_DECL_ONE(inc_386);
12329 +ATOMIC64_DECL_ONE(inc_unchecked_386);
12330 ATOMIC64_DECL_ONE(dec_386);
12331 +ATOMIC64_DECL_ONE(dec_unchecked_386);
12332 #endif
12333
12334 #define alternative_atomic64(f, out, in...) \
12335 __alternative_atomic64(f, f, ASM_OUTPUT2(out), ## in)
12336
12337 ATOMIC64_DECL(read);
12338 +ATOMIC64_DECL(read_unchecked);
12339 ATOMIC64_DECL(set);
12340 +ATOMIC64_DECL(set_unchecked);
12341 ATOMIC64_DECL(xchg);
12342 ATOMIC64_DECL(add_return);
12343 +ATOMIC64_DECL(add_return_unchecked);
12344 ATOMIC64_DECL(sub_return);
12345 +ATOMIC64_DECL(sub_return_unchecked);
12346 ATOMIC64_DECL(inc_return);
12347 +ATOMIC64_DECL(inc_return_unchecked);
12348 ATOMIC64_DECL(dec_return);
12349 +ATOMIC64_DECL(dec_return_unchecked);
12350 ATOMIC64_DECL(dec_if_positive);
12351 ATOMIC64_DECL(inc_not_zero);
12352 ATOMIC64_DECL(add_unless);
12353 @@ -77,6 +95,21 @@ static inline long long atomic64_cmpxchg(atomic64_t *v, long long o, long long n
12354 }
12355
12356 /**
12357 + * atomic64_cmpxchg_unchecked - cmpxchg atomic64 variable
12358 + * @p: pointer to type atomic64_unchecked_t
12359 + * @o: expected value
12360 + * @n: new value
12361 + *
12362 + * Atomically sets @v to @n if it was equal to @o and returns
12363 + * the old value.
12364 + */
12365 +
12366 +static inline long long atomic64_cmpxchg_unchecked(atomic64_unchecked_t *v, long long o, long long n)
12367 +{
12368 + return cmpxchg64(&v->counter, o, n);
12369 +}
12370 +
12371 +/**
12372 * atomic64_xchg - xchg atomic64 variable
12373 * @v: pointer to type atomic64_t
12374 * @n: value to assign
12375 @@ -112,6 +145,22 @@ static inline void atomic64_set(atomic64_t *v, long long i)
12376 }
12377
12378 /**
12379 + * atomic64_set_unchecked - set atomic64 variable
12380 + * @v: pointer to type atomic64_unchecked_t
12381 + * @n: value to assign
12382 + *
12383 + * Atomically sets the value of @v to @n.
12384 + */
12385 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, long long i)
12386 +{
12387 + unsigned high = (unsigned)(i >> 32);
12388 + unsigned low = (unsigned)i;
12389 + alternative_atomic64(set, /* no output */,
12390 + "S" (v), "b" (low), "c" (high)
12391 + : "eax", "edx", "memory");
12392 +}
12393 +
12394 +/**
12395 * atomic64_read - read atomic64 variable
12396 * @v: pointer to type atomic64_t
12397 *
12398 @@ -125,6 +174,19 @@ static inline long long atomic64_read(const atomic64_t *v)
12399 }
12400
12401 /**
12402 + * atomic64_read_unchecked - read atomic64 variable
12403 + * @v: pointer to type atomic64_unchecked_t
12404 + *
12405 + * Atomically reads the value of @v and returns it.
12406 + */
12407 +static inline long long atomic64_read_unchecked(atomic64_unchecked_t *v)
12408 +{
12409 + long long r;
12410 + alternative_atomic64(read, "=&A" (r), "c" (v) : "memory");
12411 + return r;
12412 + }
12413 +
12414 +/**
12415 * atomic64_add_return - add and return
12416 * @i: integer value to add
12417 * @v: pointer to type atomic64_t
12418 @@ -139,6 +201,21 @@ static inline long long atomic64_add_return(long long i, atomic64_t *v)
12419 return i;
12420 }
12421
12422 +/**
12423 + * atomic64_add_return_unchecked - add and return
12424 + * @i: integer value to add
12425 + * @v: pointer to type atomic64_unchecked_t
12426 + *
12427 + * Atomically adds @i to @v and returns @i + *@v
12428 + */
12429 +static inline long long atomic64_add_return_unchecked(long long i, atomic64_unchecked_t *v)
12430 +{
12431 + alternative_atomic64(add_return_unchecked,
12432 + ASM_OUTPUT2("+A" (i), "+c" (v)),
12433 + ASM_NO_INPUT_CLOBBER("memory"));
12434 + return i;
12435 +}
12436 +
12437 /*
12438 * Other variants with different arithmetic operators:
12439 */
12440 @@ -158,6 +235,14 @@ static inline long long atomic64_inc_return(atomic64_t *v)
12441 return a;
12442 }
12443
12444 +static inline long long atomic64_inc_return_unchecked(atomic64_unchecked_t *v)
12445 +{
12446 + long long a;
12447 + alternative_atomic64(inc_return_unchecked, "=&A" (a),
12448 + "S" (v) : "memory", "ecx");
12449 + return a;
12450 +}
12451 +
12452 static inline long long atomic64_dec_return(atomic64_t *v)
12453 {
12454 long long a;
12455 @@ -182,6 +267,21 @@ static inline long long atomic64_add(long long i, atomic64_t *v)
12456 }
12457
12458 /**
12459 + * atomic64_add_unchecked - add integer to atomic64 variable
12460 + * @i: integer value to add
12461 + * @v: pointer to type atomic64_unchecked_t
12462 + *
12463 + * Atomically adds @i to @v.
12464 + */
12465 +static inline long long atomic64_add_unchecked(long long i, atomic64_unchecked_t *v)
12466 +{
12467 + __alternative_atomic64(add_unchecked, add_return_unchecked,
12468 + ASM_OUTPUT2("+A" (i), "+c" (v)),
12469 + ASM_NO_INPUT_CLOBBER("memory"));
12470 + return i;
12471 +}
12472 +
12473 +/**
12474 * atomic64_sub - subtract the atomic64 variable
12475 * @i: integer value to subtract
12476 * @v: pointer to type atomic64_t
12477 diff --git a/arch/x86/include/asm/atomic64_64.h b/arch/x86/include/asm/atomic64_64.h
12478 index 0e1cbfc..5623683 100644
12479 --- a/arch/x86/include/asm/atomic64_64.h
12480 +++ b/arch/x86/include/asm/atomic64_64.h
12481 @@ -18,7 +18,19 @@
12482 */
12483 static inline long atomic64_read(const atomic64_t *v)
12484 {
12485 - return (*(volatile long *)&(v)->counter);
12486 + return (*(volatile const long *)&(v)->counter);
12487 +}
12488 +
12489 +/**
12490 + * atomic64_read_unchecked - read atomic64 variable
12491 + * @v: pointer of type atomic64_unchecked_t
12492 + *
12493 + * Atomically reads the value of @v.
12494 + * Doesn't imply a read memory barrier.
12495 + */
12496 +static inline long atomic64_read_unchecked(const atomic64_unchecked_t *v)
12497 +{
12498 + return (*(volatile const long *)&(v)->counter);
12499 }
12500
12501 /**
12502 @@ -34,6 +46,18 @@ static inline void atomic64_set(atomic64_t *v, long i)
12503 }
12504
12505 /**
12506 + * atomic64_set_unchecked - set atomic64 variable
12507 + * @v: pointer to type atomic64_unchecked_t
12508 + * @i: required value
12509 + *
12510 + * Atomically sets the value of @v to @i.
12511 + */
12512 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, long i)
12513 +{
12514 + v->counter = i;
12515 +}
12516 +
12517 +/**
12518 * atomic64_add - add integer to atomic64 variable
12519 * @i: integer value to add
12520 * @v: pointer to type atomic64_t
12521 @@ -42,6 +66,28 @@ static inline void atomic64_set(atomic64_t *v, long i)
12522 */
12523 static inline void atomic64_add(long i, atomic64_t *v)
12524 {
12525 + asm volatile(LOCK_PREFIX "addq %1,%0\n"
12526 +
12527 +#ifdef CONFIG_PAX_REFCOUNT
12528 + "jno 0f\n"
12529 + LOCK_PREFIX "subq %1,%0\n"
12530 + "int $4\n0:\n"
12531 + _ASM_EXTABLE(0b, 0b)
12532 +#endif
12533 +
12534 + : "=m" (v->counter)
12535 + : "er" (i), "m" (v->counter));
12536 +}
12537 +
12538 +/**
12539 + * atomic64_add_unchecked - add integer to atomic64 variable
12540 + * @i: integer value to add
12541 + * @v: pointer to type atomic64_unchecked_t
12542 + *
12543 + * Atomically adds @i to @v.
12544 + */
12545 +static inline void atomic64_add_unchecked(long i, atomic64_unchecked_t *v)
12546 +{
12547 asm volatile(LOCK_PREFIX "addq %1,%0"
12548 : "=m" (v->counter)
12549 : "er" (i), "m" (v->counter));
12550 @@ -56,7 +102,29 @@ static inline void atomic64_add(long i, atomic64_t *v)
12551 */
12552 static inline void atomic64_sub(long i, atomic64_t *v)
12553 {
12554 - asm volatile(LOCK_PREFIX "subq %1,%0"
12555 + asm volatile(LOCK_PREFIX "subq %1,%0\n"
12556 +
12557 +#ifdef CONFIG_PAX_REFCOUNT
12558 + "jno 0f\n"
12559 + LOCK_PREFIX "addq %1,%0\n"
12560 + "int $4\n0:\n"
12561 + _ASM_EXTABLE(0b, 0b)
12562 +#endif
12563 +
12564 + : "=m" (v->counter)
12565 + : "er" (i), "m" (v->counter));
12566 +}
12567 +
12568 +/**
12569 + * atomic64_sub_unchecked - subtract the atomic64 variable
12570 + * @i: integer value to subtract
12571 + * @v: pointer to type atomic64_unchecked_t
12572 + *
12573 + * Atomically subtracts @i from @v.
12574 + */
12575 +static inline void atomic64_sub_unchecked(long i, atomic64_unchecked_t *v)
12576 +{
12577 + asm volatile(LOCK_PREFIX "subq %1,%0\n"
12578 : "=m" (v->counter)
12579 : "er" (i), "m" (v->counter));
12580 }
12581 @@ -74,7 +142,16 @@ static inline int atomic64_sub_and_test(long i, atomic64_t *v)
12582 {
12583 unsigned char c;
12584
12585 - asm volatile(LOCK_PREFIX "subq %2,%0; sete %1"
12586 + asm volatile(LOCK_PREFIX "subq %2,%0\n"
12587 +
12588 +#ifdef CONFIG_PAX_REFCOUNT
12589 + "jno 0f\n"
12590 + LOCK_PREFIX "addq %2,%0\n"
12591 + "int $4\n0:\n"
12592 + _ASM_EXTABLE(0b, 0b)
12593 +#endif
12594 +
12595 + "sete %1\n"
12596 : "=m" (v->counter), "=qm" (c)
12597 : "er" (i), "m" (v->counter) : "memory");
12598 return c;
12599 @@ -88,6 +165,27 @@ static inline int atomic64_sub_and_test(long i, atomic64_t *v)
12600 */
12601 static inline void atomic64_inc(atomic64_t *v)
12602 {
12603 + asm volatile(LOCK_PREFIX "incq %0\n"
12604 +
12605 +#ifdef CONFIG_PAX_REFCOUNT
12606 + "jno 0f\n"
12607 + LOCK_PREFIX "decq %0\n"
12608 + "int $4\n0:\n"
12609 + _ASM_EXTABLE(0b, 0b)
12610 +#endif
12611 +
12612 + : "=m" (v->counter)
12613 + : "m" (v->counter));
12614 +}
12615 +
12616 +/**
12617 + * atomic64_inc_unchecked - increment atomic64 variable
12618 + * @v: pointer to type atomic64_unchecked_t
12619 + *
12620 + * Atomically increments @v by 1.
12621 + */
12622 +static inline void atomic64_inc_unchecked(atomic64_unchecked_t *v)
12623 +{
12624 asm volatile(LOCK_PREFIX "incq %0"
12625 : "=m" (v->counter)
12626 : "m" (v->counter));
12627 @@ -101,7 +199,28 @@ static inline void atomic64_inc(atomic64_t *v)
12628 */
12629 static inline void atomic64_dec(atomic64_t *v)
12630 {
12631 - asm volatile(LOCK_PREFIX "decq %0"
12632 + asm volatile(LOCK_PREFIX "decq %0\n"
12633 +
12634 +#ifdef CONFIG_PAX_REFCOUNT
12635 + "jno 0f\n"
12636 + LOCK_PREFIX "incq %0\n"
12637 + "int $4\n0:\n"
12638 + _ASM_EXTABLE(0b, 0b)
12639 +#endif
12640 +
12641 + : "=m" (v->counter)
12642 + : "m" (v->counter));
12643 +}
12644 +
12645 +/**
12646 + * atomic64_dec_unchecked - decrement atomic64 variable
12647 + * @v: pointer to type atomic64_t
12648 + *
12649 + * Atomically decrements @v by 1.
12650 + */
12651 +static inline void atomic64_dec_unchecked(atomic64_unchecked_t *v)
12652 +{
12653 + asm volatile(LOCK_PREFIX "decq %0\n"
12654 : "=m" (v->counter)
12655 : "m" (v->counter));
12656 }
12657 @@ -118,7 +237,16 @@ static inline int atomic64_dec_and_test(atomic64_t *v)
12658 {
12659 unsigned char c;
12660
12661 - asm volatile(LOCK_PREFIX "decq %0; sete %1"
12662 + asm volatile(LOCK_PREFIX "decq %0\n"
12663 +
12664 +#ifdef CONFIG_PAX_REFCOUNT
12665 + "jno 0f\n"
12666 + LOCK_PREFIX "incq %0\n"
12667 + "int $4\n0:\n"
12668 + _ASM_EXTABLE(0b, 0b)
12669 +#endif
12670 +
12671 + "sete %1\n"
12672 : "=m" (v->counter), "=qm" (c)
12673 : "m" (v->counter) : "memory");
12674 return c != 0;
12675 @@ -136,7 +264,16 @@ static inline int atomic64_inc_and_test(atomic64_t *v)
12676 {
12677 unsigned char c;
12678
12679 - asm volatile(LOCK_PREFIX "incq %0; sete %1"
12680 + asm volatile(LOCK_PREFIX "incq %0\n"
12681 +
12682 +#ifdef CONFIG_PAX_REFCOUNT
12683 + "jno 0f\n"
12684 + LOCK_PREFIX "decq %0\n"
12685 + "int $4\n0:\n"
12686 + _ASM_EXTABLE(0b, 0b)
12687 +#endif
12688 +
12689 + "sete %1\n"
12690 : "=m" (v->counter), "=qm" (c)
12691 : "m" (v->counter) : "memory");
12692 return c != 0;
12693 @@ -155,7 +292,16 @@ static inline int atomic64_add_negative(long i, atomic64_t *v)
12694 {
12695 unsigned char c;
12696
12697 - asm volatile(LOCK_PREFIX "addq %2,%0; sets %1"
12698 + asm volatile(LOCK_PREFIX "addq %2,%0\n"
12699 +
12700 +#ifdef CONFIG_PAX_REFCOUNT
12701 + "jno 0f\n"
12702 + LOCK_PREFIX "subq %2,%0\n"
12703 + "int $4\n0:\n"
12704 + _ASM_EXTABLE(0b, 0b)
12705 +#endif
12706 +
12707 + "sets %1\n"
12708 : "=m" (v->counter), "=qm" (c)
12709 : "er" (i), "m" (v->counter) : "memory");
12710 return c;
12711 @@ -170,6 +316,18 @@ static inline int atomic64_add_negative(long i, atomic64_t *v)
12712 */
12713 static inline long atomic64_add_return(long i, atomic64_t *v)
12714 {
12715 + return i + xadd_check_overflow(&v->counter, i);
12716 +}
12717 +
12718 +/**
12719 + * atomic64_add_return_unchecked - add and return
12720 + * @i: integer value to add
12721 + * @v: pointer to type atomic64_unchecked_t
12722 + *
12723 + * Atomically adds @i to @v and returns @i + @v
12724 + */
12725 +static inline long atomic64_add_return_unchecked(long i, atomic64_unchecked_t *v)
12726 +{
12727 return i + xadd(&v->counter, i);
12728 }
12729
12730 @@ -179,6 +337,10 @@ static inline long atomic64_sub_return(long i, atomic64_t *v)
12731 }
12732
12733 #define atomic64_inc_return(v) (atomic64_add_return(1, (v)))
12734 +static inline long atomic64_inc_return_unchecked(atomic64_unchecked_t *v)
12735 +{
12736 + return atomic64_add_return_unchecked(1, v);
12737 +}
12738 #define atomic64_dec_return(v) (atomic64_sub_return(1, (v)))
12739
12740 static inline long atomic64_cmpxchg(atomic64_t *v, long old, long new)
12741 @@ -186,6 +348,11 @@ static inline long atomic64_cmpxchg(atomic64_t *v, long old, long new)
12742 return cmpxchg(&v->counter, old, new);
12743 }
12744
12745 +static inline long atomic64_cmpxchg_unchecked(atomic64_unchecked_t *v, long old, long new)
12746 +{
12747 + return cmpxchg(&v->counter, old, new);
12748 +}
12749 +
12750 static inline long atomic64_xchg(atomic64_t *v, long new)
12751 {
12752 return xchg(&v->counter, new);
12753 @@ -202,17 +369,30 @@ static inline long atomic64_xchg(atomic64_t *v, long new)
12754 */
12755 static inline int atomic64_add_unless(atomic64_t *v, long a, long u)
12756 {
12757 - long c, old;
12758 + long c, old, new;
12759 c = atomic64_read(v);
12760 for (;;) {
12761 - if (unlikely(c == (u)))
12762 + if (unlikely(c == u))
12763 break;
12764 - old = atomic64_cmpxchg((v), c, c + (a));
12765 +
12766 + asm volatile("add %2,%0\n"
12767 +
12768 +#ifdef CONFIG_PAX_REFCOUNT
12769 + "jno 0f\n"
12770 + "sub %2,%0\n"
12771 + "int $4\n0:\n"
12772 + _ASM_EXTABLE(0b, 0b)
12773 +#endif
12774 +
12775 + : "=r" (new)
12776 + : "0" (c), "ir" (a));
12777 +
12778 + old = atomic64_cmpxchg(v, c, new);
12779 if (likely(old == c))
12780 break;
12781 c = old;
12782 }
12783 - return c != (u);
12784 + return c != u;
12785 }
12786
12787 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
12788 diff --git a/arch/x86/include/asm/bitops.h b/arch/x86/include/asm/bitops.h
12789 index 6dfd019..28e188d 100644
12790 --- a/arch/x86/include/asm/bitops.h
12791 +++ b/arch/x86/include/asm/bitops.h
12792 @@ -40,7 +40,7 @@
12793 * a mask operation on a byte.
12794 */
12795 #define IS_IMMEDIATE(nr) (__builtin_constant_p(nr))
12796 -#define CONST_MASK_ADDR(nr, addr) BITOP_ADDR((void *)(addr) + ((nr)>>3))
12797 +#define CONST_MASK_ADDR(nr, addr) BITOP_ADDR((volatile void *)(addr) + ((nr)>>3))
12798 #define CONST_MASK(nr) (1 << ((nr) & 7))
12799
12800 /**
12801 @@ -486,7 +486,7 @@ static inline int fls(int x)
12802 * at position 64.
12803 */
12804 #ifdef CONFIG_X86_64
12805 -static __always_inline int fls64(__u64 x)
12806 +static __always_inline long fls64(__u64 x)
12807 {
12808 int bitpos = -1;
12809 /*
12810 diff --git a/arch/x86/include/asm/boot.h b/arch/x86/include/asm/boot.h
12811 index 4fa687a..60f2d39 100644
12812 --- a/arch/x86/include/asm/boot.h
12813 +++ b/arch/x86/include/asm/boot.h
12814 @@ -6,10 +6,15 @@
12815 #include <uapi/asm/boot.h>
12816
12817 /* Physical address where kernel should be loaded. */
12818 -#define LOAD_PHYSICAL_ADDR ((CONFIG_PHYSICAL_START \
12819 +#define ____LOAD_PHYSICAL_ADDR ((CONFIG_PHYSICAL_START \
12820 + (CONFIG_PHYSICAL_ALIGN - 1)) \
12821 & ~(CONFIG_PHYSICAL_ALIGN - 1))
12822
12823 +#ifndef __ASSEMBLY__
12824 +extern unsigned char __LOAD_PHYSICAL_ADDR[];
12825 +#define LOAD_PHYSICAL_ADDR ((unsigned long)__LOAD_PHYSICAL_ADDR)
12826 +#endif
12827 +
12828 /* Minimum kernel alignment, as a power of two */
12829 #ifdef CONFIG_X86_64
12830 #define MIN_KERNEL_ALIGN_LG2 PMD_SHIFT
12831 diff --git a/arch/x86/include/asm/cache.h b/arch/x86/include/asm/cache.h
12832 index 48f99f1..d78ebf9 100644
12833 --- a/arch/x86/include/asm/cache.h
12834 +++ b/arch/x86/include/asm/cache.h
12835 @@ -5,12 +5,13 @@
12836
12837 /* L1 cache line size */
12838 #define L1_CACHE_SHIFT (CONFIG_X86_L1_CACHE_SHIFT)
12839 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
12840 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
12841
12842 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
12843 +#define __read_only __attribute__((__section__(".data..read_only")))
12844
12845 #define INTERNODE_CACHE_SHIFT CONFIG_X86_INTERNODE_CACHE_SHIFT
12846 -#define INTERNODE_CACHE_BYTES (1 << INTERNODE_CACHE_SHIFT)
12847 +#define INTERNODE_CACHE_BYTES (_AC(1,UL) << INTERNODE_CACHE_SHIFT)
12848
12849 #ifdef CONFIG_X86_VSMP
12850 #ifdef CONFIG_SMP
12851 diff --git a/arch/x86/include/asm/cacheflush.h b/arch/x86/include/asm/cacheflush.h
12852 index 9863ee3..4a1f8e1 100644
12853 --- a/arch/x86/include/asm/cacheflush.h
12854 +++ b/arch/x86/include/asm/cacheflush.h
12855 @@ -27,7 +27,7 @@ static inline unsigned long get_page_memtype(struct page *pg)
12856 unsigned long pg_flags = pg->flags & _PGMT_MASK;
12857
12858 if (pg_flags == _PGMT_DEFAULT)
12859 - return -1;
12860 + return ~0UL;
12861 else if (pg_flags == _PGMT_WC)
12862 return _PAGE_CACHE_WC;
12863 else if (pg_flags == _PGMT_UC_MINUS)
12864 diff --git a/arch/x86/include/asm/checksum_32.h b/arch/x86/include/asm/checksum_32.h
12865 index 46fc474..b02b0f9 100644
12866 --- a/arch/x86/include/asm/checksum_32.h
12867 +++ b/arch/x86/include/asm/checksum_32.h
12868 @@ -31,6 +31,14 @@ asmlinkage __wsum csum_partial_copy_generic(const void *src, void *dst,
12869 int len, __wsum sum,
12870 int *src_err_ptr, int *dst_err_ptr);
12871
12872 +asmlinkage __wsum csum_partial_copy_generic_to_user(const void *src, void *dst,
12873 + int len, __wsum sum,
12874 + int *src_err_ptr, int *dst_err_ptr);
12875 +
12876 +asmlinkage __wsum csum_partial_copy_generic_from_user(const void *src, void *dst,
12877 + int len, __wsum sum,
12878 + int *src_err_ptr, int *dst_err_ptr);
12879 +
12880 /*
12881 * Note: when you get a NULL pointer exception here this means someone
12882 * passed in an incorrect kernel address to one of these functions.
12883 @@ -50,7 +58,7 @@ static inline __wsum csum_partial_copy_from_user(const void __user *src,
12884 int *err_ptr)
12885 {
12886 might_sleep();
12887 - return csum_partial_copy_generic((__force void *)src, dst,
12888 + return csum_partial_copy_generic_from_user((__force void *)src, dst,
12889 len, sum, err_ptr, NULL);
12890 }
12891
12892 @@ -178,7 +186,7 @@ static inline __wsum csum_and_copy_to_user(const void *src,
12893 {
12894 might_sleep();
12895 if (access_ok(VERIFY_WRITE, dst, len))
12896 - return csum_partial_copy_generic(src, (__force void *)dst,
12897 + return csum_partial_copy_generic_to_user(src, (__force void *)dst,
12898 len, sum, NULL, err_ptr);
12899
12900 if (len)
12901 diff --git a/arch/x86/include/asm/cmpxchg.h b/arch/x86/include/asm/cmpxchg.h
12902 index 8d871ea..c1a0dc9 100644
12903 --- a/arch/x86/include/asm/cmpxchg.h
12904 +++ b/arch/x86/include/asm/cmpxchg.h
12905 @@ -14,8 +14,12 @@ extern void __cmpxchg_wrong_size(void)
12906 __compiletime_error("Bad argument size for cmpxchg");
12907 extern void __xadd_wrong_size(void)
12908 __compiletime_error("Bad argument size for xadd");
12909 +extern void __xadd_check_overflow_wrong_size(void)
12910 + __compiletime_error("Bad argument size for xadd_check_overflow");
12911 extern void __add_wrong_size(void)
12912 __compiletime_error("Bad argument size for add");
12913 +extern void __add_check_overflow_wrong_size(void)
12914 + __compiletime_error("Bad argument size for add_check_overflow");
12915
12916 /*
12917 * Constants for operation sizes. On 32-bit, the 64-bit size it set to
12918 @@ -67,6 +71,34 @@ extern void __add_wrong_size(void)
12919 __ret; \
12920 })
12921
12922 +#define __xchg_op_check_overflow(ptr, arg, op, lock) \
12923 + ({ \
12924 + __typeof__ (*(ptr)) __ret = (arg); \
12925 + switch (sizeof(*(ptr))) { \
12926 + case __X86_CASE_L: \
12927 + asm volatile (lock #op "l %0, %1\n" \
12928 + "jno 0f\n" \
12929 + "mov %0,%1\n" \
12930 + "int $4\n0:\n" \
12931 + _ASM_EXTABLE(0b, 0b) \
12932 + : "+r" (__ret), "+m" (*(ptr)) \
12933 + : : "memory", "cc"); \
12934 + break; \
12935 + case __X86_CASE_Q: \
12936 + asm volatile (lock #op "q %q0, %1\n" \
12937 + "jno 0f\n" \
12938 + "mov %0,%1\n" \
12939 + "int $4\n0:\n" \
12940 + _ASM_EXTABLE(0b, 0b) \
12941 + : "+r" (__ret), "+m" (*(ptr)) \
12942 + : : "memory", "cc"); \
12943 + break; \
12944 + default: \
12945 + __ ## op ## _check_overflow_wrong_size(); \
12946 + } \
12947 + __ret; \
12948 + })
12949 +
12950 /*
12951 * Note: no "lock" prefix even on SMP: xchg always implies lock anyway.
12952 * Since this is generally used to protect other memory information, we
12953 @@ -167,6 +199,9 @@ extern void __add_wrong_size(void)
12954 #define xadd_sync(ptr, inc) __xadd((ptr), (inc), "lock; ")
12955 #define xadd_local(ptr, inc) __xadd((ptr), (inc), "")
12956
12957 +#define __xadd_check_overflow(ptr, inc, lock) __xchg_op_check_overflow((ptr), (inc), xadd, lock)
12958 +#define xadd_check_overflow(ptr, inc) __xadd_check_overflow((ptr), (inc), LOCK_PREFIX)
12959 +
12960 #define __add(ptr, inc, lock) \
12961 ({ \
12962 __typeof__ (*(ptr)) __ret = (inc); \
12963 diff --git a/arch/x86/include/asm/cpufeature.h b/arch/x86/include/asm/cpufeature.h
12964 index 2d9075e..b75a844 100644
12965 --- a/arch/x86/include/asm/cpufeature.h
12966 +++ b/arch/x86/include/asm/cpufeature.h
12967 @@ -206,7 +206,7 @@
12968 #define X86_FEATURE_BMI1 (9*32+ 3) /* 1st group bit manipulation extensions */
12969 #define X86_FEATURE_HLE (9*32+ 4) /* Hardware Lock Elision */
12970 #define X86_FEATURE_AVX2 (9*32+ 5) /* AVX2 instructions */
12971 -#define X86_FEATURE_SMEP (9*32+ 7) /* Supervisor Mode Execution Protection */
12972 +#define X86_FEATURE_SMEP (9*32+ 7) /* Supervisor Mode Execution Prevention */
12973 #define X86_FEATURE_BMI2 (9*32+ 8) /* 2nd group bit manipulation extensions */
12974 #define X86_FEATURE_ERMS (9*32+ 9) /* Enhanced REP MOVSB/STOSB */
12975 #define X86_FEATURE_INVPCID (9*32+10) /* Invalidate Processor Context ID */
12976 @@ -375,7 +375,7 @@ static __always_inline __pure bool __static_cpu_has(u16 bit)
12977 ".section .discard,\"aw\",@progbits\n"
12978 " .byte 0xff + (4f-3f) - (2b-1b)\n" /* size check */
12979 ".previous\n"
12980 - ".section .altinstr_replacement,\"ax\"\n"
12981 + ".section .altinstr_replacement,\"a\"\n"
12982 "3: movb $1,%0\n"
12983 "4:\n"
12984 ".previous\n"
12985 diff --git a/arch/x86/include/asm/desc.h b/arch/x86/include/asm/desc.h
12986 index 8bf1c06..b6ae785 100644
12987 --- a/arch/x86/include/asm/desc.h
12988 +++ b/arch/x86/include/asm/desc.h
12989 @@ -4,6 +4,7 @@
12990 #include <asm/desc_defs.h>
12991 #include <asm/ldt.h>
12992 #include <asm/mmu.h>
12993 +#include <asm/pgtable.h>
12994
12995 #include <linux/smp.h>
12996 #include <linux/percpu.h>
12997 @@ -17,6 +18,7 @@ static inline void fill_ldt(struct desc_struct *desc, const struct user_desc *in
12998
12999 desc->type = (info->read_exec_only ^ 1) << 1;
13000 desc->type |= info->contents << 2;
13001 + desc->type |= info->seg_not_present ^ 1;
13002
13003 desc->s = 1;
13004 desc->dpl = 0x3;
13005 @@ -35,19 +37,14 @@ static inline void fill_ldt(struct desc_struct *desc, const struct user_desc *in
13006 }
13007
13008 extern struct desc_ptr idt_descr;
13009 -extern gate_desc idt_table[];
13010 extern struct desc_ptr nmi_idt_descr;
13011 -extern gate_desc nmi_idt_table[];
13012 -
13013 -struct gdt_page {
13014 - struct desc_struct gdt[GDT_ENTRIES];
13015 -} __attribute__((aligned(PAGE_SIZE)));
13016 -
13017 -DECLARE_PER_CPU_PAGE_ALIGNED(struct gdt_page, gdt_page);
13018 +extern gate_desc idt_table[256];
13019 +extern gate_desc nmi_idt_table[256];
13020
13021 +extern struct desc_struct cpu_gdt_table[NR_CPUS][PAGE_SIZE / sizeof(struct desc_struct)];
13022 static inline struct desc_struct *get_cpu_gdt_table(unsigned int cpu)
13023 {
13024 - return per_cpu(gdt_page, cpu).gdt;
13025 + return cpu_gdt_table[cpu];
13026 }
13027
13028 #ifdef CONFIG_X86_64
13029 @@ -72,8 +69,14 @@ static inline void pack_gate(gate_desc *gate, unsigned char type,
13030 unsigned long base, unsigned dpl, unsigned flags,
13031 unsigned short seg)
13032 {
13033 - gate->a = (seg << 16) | (base & 0xffff);
13034 - gate->b = (base & 0xffff0000) | (((0x80 | type | (dpl << 5)) & 0xff) << 8);
13035 + gate->gate.offset_low = base;
13036 + gate->gate.seg = seg;
13037 + gate->gate.reserved = 0;
13038 + gate->gate.type = type;
13039 + gate->gate.s = 0;
13040 + gate->gate.dpl = dpl;
13041 + gate->gate.p = 1;
13042 + gate->gate.offset_high = base >> 16;
13043 }
13044
13045 #endif
13046 @@ -118,12 +121,16 @@ static inline void paravirt_free_ldt(struct desc_struct *ldt, unsigned entries)
13047
13048 static inline void native_write_idt_entry(gate_desc *idt, int entry, const gate_desc *gate)
13049 {
13050 + pax_open_kernel();
13051 memcpy(&idt[entry], gate, sizeof(*gate));
13052 + pax_close_kernel();
13053 }
13054
13055 static inline void native_write_ldt_entry(struct desc_struct *ldt, int entry, const void *desc)
13056 {
13057 + pax_open_kernel();
13058 memcpy(&ldt[entry], desc, 8);
13059 + pax_close_kernel();
13060 }
13061
13062 static inline void
13063 @@ -137,7 +144,9 @@ native_write_gdt_entry(struct desc_struct *gdt, int entry, const void *desc, int
13064 default: size = sizeof(*gdt); break;
13065 }
13066
13067 + pax_open_kernel();
13068 memcpy(&gdt[entry], desc, size);
13069 + pax_close_kernel();
13070 }
13071
13072 static inline void pack_descriptor(struct desc_struct *desc, unsigned long base,
13073 @@ -210,7 +219,9 @@ static inline void native_set_ldt(const void *addr, unsigned int entries)
13074
13075 static inline void native_load_tr_desc(void)
13076 {
13077 + pax_open_kernel();
13078 asm volatile("ltr %w0"::"q" (GDT_ENTRY_TSS*8));
13079 + pax_close_kernel();
13080 }
13081
13082 static inline void native_load_gdt(const struct desc_ptr *dtr)
13083 @@ -247,8 +258,10 @@ static inline void native_load_tls(struct thread_struct *t, unsigned int cpu)
13084 struct desc_struct *gdt = get_cpu_gdt_table(cpu);
13085 unsigned int i;
13086
13087 + pax_open_kernel();
13088 for (i = 0; i < GDT_ENTRY_TLS_ENTRIES; i++)
13089 gdt[GDT_ENTRY_TLS_MIN + i] = t->tls_array[i];
13090 + pax_close_kernel();
13091 }
13092
13093 #define _LDT_empty(info) \
13094 @@ -287,7 +300,7 @@ static inline void load_LDT(mm_context_t *pc)
13095 preempt_enable();
13096 }
13097
13098 -static inline unsigned long get_desc_base(const struct desc_struct *desc)
13099 +static inline unsigned long __intentional_overflow(-1) get_desc_base(const struct desc_struct *desc)
13100 {
13101 return (unsigned)(desc->base0 | ((desc->base1) << 16) | ((desc->base2) << 24));
13102 }
13103 @@ -311,7 +324,7 @@ static inline void set_desc_limit(struct desc_struct *desc, unsigned long limit)
13104 }
13105
13106 #ifdef CONFIG_X86_64
13107 -static inline void set_nmi_gate(int gate, void *addr)
13108 +static inline void set_nmi_gate(int gate, const void *addr)
13109 {
13110 gate_desc s;
13111
13112 @@ -320,7 +333,7 @@ static inline void set_nmi_gate(int gate, void *addr)
13113 }
13114 #endif
13115
13116 -static inline void _set_gate(int gate, unsigned type, void *addr,
13117 +static inline void _set_gate(int gate, unsigned type, const void *addr,
13118 unsigned dpl, unsigned ist, unsigned seg)
13119 {
13120 gate_desc s;
13121 @@ -339,7 +352,7 @@ static inline void _set_gate(int gate, unsigned type, void *addr,
13122 * Pentium F0 0F bugfix can have resulted in the mapped
13123 * IDT being write-protected.
13124 */
13125 -static inline void set_intr_gate(unsigned int n, void *addr)
13126 +static inline void set_intr_gate(unsigned int n, const void *addr)
13127 {
13128 BUG_ON((unsigned)n > 0xFF);
13129 _set_gate(n, GATE_INTERRUPT, addr, 0, 0, __KERNEL_CS);
13130 @@ -369,19 +382,19 @@ static inline void alloc_intr_gate(unsigned int n, void *addr)
13131 /*
13132 * This routine sets up an interrupt gate at directory privilege level 3.
13133 */
13134 -static inline void set_system_intr_gate(unsigned int n, void *addr)
13135 +static inline void set_system_intr_gate(unsigned int n, const void *addr)
13136 {
13137 BUG_ON((unsigned)n > 0xFF);
13138 _set_gate(n, GATE_INTERRUPT, addr, 0x3, 0, __KERNEL_CS);
13139 }
13140
13141 -static inline void set_system_trap_gate(unsigned int n, void *addr)
13142 +static inline void set_system_trap_gate(unsigned int n, const void *addr)
13143 {
13144 BUG_ON((unsigned)n > 0xFF);
13145 _set_gate(n, GATE_TRAP, addr, 0x3, 0, __KERNEL_CS);
13146 }
13147
13148 -static inline void set_trap_gate(unsigned int n, void *addr)
13149 +static inline void set_trap_gate(unsigned int n, const void *addr)
13150 {
13151 BUG_ON((unsigned)n > 0xFF);
13152 _set_gate(n, GATE_TRAP, addr, 0, 0, __KERNEL_CS);
13153 @@ -390,19 +403,31 @@ static inline void set_trap_gate(unsigned int n, void *addr)
13154 static inline void set_task_gate(unsigned int n, unsigned int gdt_entry)
13155 {
13156 BUG_ON((unsigned)n > 0xFF);
13157 - _set_gate(n, GATE_TASK, (void *)0, 0, 0, (gdt_entry<<3));
13158 + _set_gate(n, GATE_TASK, (const void *)0, 0, 0, (gdt_entry<<3));
13159 }
13160
13161 -static inline void set_intr_gate_ist(int n, void *addr, unsigned ist)
13162 +static inline void set_intr_gate_ist(int n, const void *addr, unsigned ist)
13163 {
13164 BUG_ON((unsigned)n > 0xFF);
13165 _set_gate(n, GATE_INTERRUPT, addr, 0, ist, __KERNEL_CS);
13166 }
13167
13168 -static inline void set_system_intr_gate_ist(int n, void *addr, unsigned ist)
13169 +static inline void set_system_intr_gate_ist(int n, const void *addr, unsigned ist)
13170 {
13171 BUG_ON((unsigned)n > 0xFF);
13172 _set_gate(n, GATE_INTERRUPT, addr, 0x3, ist, __KERNEL_CS);
13173 }
13174
13175 +#ifdef CONFIG_X86_32
13176 +static inline void set_user_cs(unsigned long base, unsigned long limit, int cpu)
13177 +{
13178 + struct desc_struct d;
13179 +
13180 + if (likely(limit))
13181 + limit = (limit - 1UL) >> PAGE_SHIFT;
13182 + pack_descriptor(&d, base, limit, 0xFB, 0xC);
13183 + write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_DEFAULT_USER_CS, &d, DESCTYPE_S);
13184 +}
13185 +#endif
13186 +
13187 #endif /* _ASM_X86_DESC_H */
13188 diff --git a/arch/x86/include/asm/desc_defs.h b/arch/x86/include/asm/desc_defs.h
13189 index 278441f..b95a174 100644
13190 --- a/arch/x86/include/asm/desc_defs.h
13191 +++ b/arch/x86/include/asm/desc_defs.h
13192 @@ -31,6 +31,12 @@ struct desc_struct {
13193 unsigned base1: 8, type: 4, s: 1, dpl: 2, p: 1;
13194 unsigned limit: 4, avl: 1, l: 1, d: 1, g: 1, base2: 8;
13195 };
13196 + struct {
13197 + u16 offset_low;
13198 + u16 seg;
13199 + unsigned reserved: 8, type: 4, s: 1, dpl: 2, p: 1;
13200 + unsigned offset_high: 16;
13201 + } gate;
13202 };
13203 } __attribute__((packed));
13204
13205 diff --git a/arch/x86/include/asm/div64.h b/arch/x86/include/asm/div64.h
13206 index ced283a..ffe04cc 100644
13207 --- a/arch/x86/include/asm/div64.h
13208 +++ b/arch/x86/include/asm/div64.h
13209 @@ -39,7 +39,7 @@
13210 __mod; \
13211 })
13212
13213 -static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
13214 +static inline u64 __intentional_overflow(-1) div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
13215 {
13216 union {
13217 u64 v64;
13218 diff --git a/arch/x86/include/asm/elf.h b/arch/x86/include/asm/elf.h
13219 index 9c999c1..3860cb8 100644
13220 --- a/arch/x86/include/asm/elf.h
13221 +++ b/arch/x86/include/asm/elf.h
13222 @@ -243,7 +243,25 @@ extern int force_personality32;
13223 the loader. We need to make sure that it is out of the way of the program
13224 that it will "exec", and that there is sufficient room for the brk. */
13225
13226 +#ifdef CONFIG_PAX_SEGMEXEC
13227 +#define ELF_ET_DYN_BASE ((current->mm->pax_flags & MF_PAX_SEGMEXEC) ? SEGMEXEC_TASK_SIZE/3*2 : TASK_SIZE/3*2)
13228 +#else
13229 #define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
13230 +#endif
13231 +
13232 +#ifdef CONFIG_PAX_ASLR
13233 +#ifdef CONFIG_X86_32
13234 +#define PAX_ELF_ET_DYN_BASE 0x10000000UL
13235 +
13236 +#define PAX_DELTA_MMAP_LEN (current->mm->pax_flags & MF_PAX_SEGMEXEC ? 15 : 16)
13237 +#define PAX_DELTA_STACK_LEN (current->mm->pax_flags & MF_PAX_SEGMEXEC ? 15 : 16)
13238 +#else
13239 +#define PAX_ELF_ET_DYN_BASE 0x400000UL
13240 +
13241 +#define PAX_DELTA_MMAP_LEN ((test_thread_flag(TIF_ADDR32)) ? 16 : TASK_SIZE_MAX_SHIFT - PAGE_SHIFT - 3)
13242 +#define PAX_DELTA_STACK_LEN ((test_thread_flag(TIF_ADDR32)) ? 16 : TASK_SIZE_MAX_SHIFT - PAGE_SHIFT - 3)
13243 +#endif
13244 +#endif
13245
13246 /* This yields a mask that user programs can use to figure out what
13247 instruction set this CPU supports. This could be done in user space,
13248 @@ -296,16 +314,12 @@ do { \
13249
13250 #define ARCH_DLINFO \
13251 do { \
13252 - if (vdso_enabled) \
13253 - NEW_AUX_ENT(AT_SYSINFO_EHDR, \
13254 - (unsigned long)current->mm->context.vdso); \
13255 + NEW_AUX_ENT(AT_SYSINFO_EHDR, current->mm->context.vdso); \
13256 } while (0)
13257
13258 #define ARCH_DLINFO_X32 \
13259 do { \
13260 - if (vdso_enabled) \
13261 - NEW_AUX_ENT(AT_SYSINFO_EHDR, \
13262 - (unsigned long)current->mm->context.vdso); \
13263 + NEW_AUX_ENT(AT_SYSINFO_EHDR, current->mm->context.vdso); \
13264 } while (0)
13265
13266 #define AT_SYSINFO 32
13267 @@ -320,7 +334,7 @@ else \
13268
13269 #endif /* !CONFIG_X86_32 */
13270
13271 -#define VDSO_CURRENT_BASE ((unsigned long)current->mm->context.vdso)
13272 +#define VDSO_CURRENT_BASE (current->mm->context.vdso)
13273
13274 #define VDSO_ENTRY \
13275 ((unsigned long)VDSO32_SYMBOL(VDSO_CURRENT_BASE, vsyscall))
13276 @@ -336,9 +350,6 @@ extern int x32_setup_additional_pages(struct linux_binprm *bprm,
13277 extern int syscall32_setup_pages(struct linux_binprm *, int exstack);
13278 #define compat_arch_setup_additional_pages syscall32_setup_pages
13279
13280 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
13281 -#define arch_randomize_brk arch_randomize_brk
13282 -
13283 /*
13284 * True on X86_32 or when emulating IA32 on X86_64
13285 */
13286 diff --git a/arch/x86/include/asm/emergency-restart.h b/arch/x86/include/asm/emergency-restart.h
13287 index 75ce3f4..882e801 100644
13288 --- a/arch/x86/include/asm/emergency-restart.h
13289 +++ b/arch/x86/include/asm/emergency-restart.h
13290 @@ -13,6 +13,6 @@ enum reboot_type {
13291
13292 extern enum reboot_type reboot_type;
13293
13294 -extern void machine_emergency_restart(void);
13295 +extern void machine_emergency_restart(void) __noreturn;
13296
13297 #endif /* _ASM_X86_EMERGENCY_RESTART_H */
13298 diff --git a/arch/x86/include/asm/fpu-internal.h b/arch/x86/include/asm/fpu-internal.h
13299 index 41ab26e..a88c9e6 100644
13300 --- a/arch/x86/include/asm/fpu-internal.h
13301 +++ b/arch/x86/include/asm/fpu-internal.h
13302 @@ -126,7 +126,9 @@ static inline void sanitize_i387_state(struct task_struct *tsk)
13303 ({ \
13304 int err; \
13305 asm volatile(ASM_STAC "\n" \
13306 - "1:" #insn "\n\t" \
13307 + "1:" \
13308 + __copyuser_seg \
13309 + #insn "\n\t" \
13310 "2: " ASM_CLAC "\n" \
13311 ".section .fixup,\"ax\"\n" \
13312 "3: movl $-1,%[err]\n" \
13313 @@ -299,7 +301,7 @@ static inline int restore_fpu_checking(struct task_struct *tsk)
13314 "emms\n\t" /* clear stack tags */
13315 "fildl %P[addr]", /* set F?P to defined value */
13316 X86_FEATURE_FXSAVE_LEAK,
13317 - [addr] "m" (tsk->thread.fpu.has_fpu));
13318 + [addr] "m" (init_tss[raw_smp_processor_id()].x86_tss.sp0));
13319
13320 return fpu_restore_checking(&tsk->thread.fpu);
13321 }
13322 diff --git a/arch/x86/include/asm/futex.h b/arch/x86/include/asm/futex.h
13323 index be27ba1..8f13ff9 100644
13324 --- a/arch/x86/include/asm/futex.h
13325 +++ b/arch/x86/include/asm/futex.h
13326 @@ -12,6 +12,7 @@
13327 #include <asm/smap.h>
13328
13329 #define __futex_atomic_op1(insn, ret, oldval, uaddr, oparg) \
13330 + typecheck(u32 __user *, uaddr); \
13331 asm volatile("\t" ASM_STAC "\n" \
13332 "1:\t" insn "\n" \
13333 "2:\t" ASM_CLAC "\n" \
13334 @@ -20,15 +21,16 @@
13335 "\tjmp\t2b\n" \
13336 "\t.previous\n" \
13337 _ASM_EXTABLE(1b, 3b) \
13338 - : "=r" (oldval), "=r" (ret), "+m" (*uaddr) \
13339 + : "=r" (oldval), "=r" (ret), "+m" (*(u32 __user *)____m(uaddr)) \
13340 : "i" (-EFAULT), "0" (oparg), "1" (0))
13341
13342 #define __futex_atomic_op2(insn, ret, oldval, uaddr, oparg) \
13343 + typecheck(u32 __user *, uaddr); \
13344 asm volatile("\t" ASM_STAC "\n" \
13345 "1:\tmovl %2, %0\n" \
13346 "\tmovl\t%0, %3\n" \
13347 "\t" insn "\n" \
13348 - "2:\t" LOCK_PREFIX "cmpxchgl %3, %2\n" \
13349 + "2:\t" LOCK_PREFIX __copyuser_seg"cmpxchgl %3, %2\n" \
13350 "\tjnz\t1b\n" \
13351 "3:\t" ASM_CLAC "\n" \
13352 "\t.section .fixup,\"ax\"\n" \
13353 @@ -38,7 +40,7 @@
13354 _ASM_EXTABLE(1b, 4b) \
13355 _ASM_EXTABLE(2b, 4b) \
13356 : "=&a" (oldval), "=&r" (ret), \
13357 - "+m" (*uaddr), "=&r" (tem) \
13358 + "+m" (*(u32 __user *)____m(uaddr)), "=&r" (tem) \
13359 : "r" (oparg), "i" (-EFAULT), "1" (0))
13360
13361 static inline int futex_atomic_op_inuser(int encoded_op, u32 __user *uaddr)
13362 @@ -59,10 +61,10 @@ static inline int futex_atomic_op_inuser(int encoded_op, u32 __user *uaddr)
13363
13364 switch (op) {
13365 case FUTEX_OP_SET:
13366 - __futex_atomic_op1("xchgl %0, %2", ret, oldval, uaddr, oparg);
13367 + __futex_atomic_op1(__copyuser_seg"xchgl %0, %2", ret, oldval, uaddr, oparg);
13368 break;
13369 case FUTEX_OP_ADD:
13370 - __futex_atomic_op1(LOCK_PREFIX "xaddl %0, %2", ret, oldval,
13371 + __futex_atomic_op1(LOCK_PREFIX __copyuser_seg"xaddl %0, %2", ret, oldval,
13372 uaddr, oparg);
13373 break;
13374 case FUTEX_OP_OR:
13375 @@ -116,14 +118,14 @@ static inline int futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
13376 return -EFAULT;
13377
13378 asm volatile("\t" ASM_STAC "\n"
13379 - "1:\t" LOCK_PREFIX "cmpxchgl %4, %2\n"
13380 + "1:\t" LOCK_PREFIX __copyuser_seg"cmpxchgl %4, %2\n"
13381 "2:\t" ASM_CLAC "\n"
13382 "\t.section .fixup, \"ax\"\n"
13383 "3:\tmov %3, %0\n"
13384 "\tjmp 2b\n"
13385 "\t.previous\n"
13386 _ASM_EXTABLE(1b, 3b)
13387 - : "+r" (ret), "=a" (oldval), "+m" (*uaddr)
13388 + : "+r" (ret), "=a" (oldval), "+m" (*(u32 __user *)____m(uaddr))
13389 : "i" (-EFAULT), "r" (newval), "1" (oldval)
13390 : "memory"
13391 );
13392 diff --git a/arch/x86/include/asm/hw_irq.h b/arch/x86/include/asm/hw_irq.h
13393 index eb92a6e..b98b2f4 100644
13394 --- a/arch/x86/include/asm/hw_irq.h
13395 +++ b/arch/x86/include/asm/hw_irq.h
13396 @@ -136,8 +136,8 @@ extern void setup_ioapic_dest(void);
13397 extern void enable_IO_APIC(void);
13398
13399 /* Statistics */
13400 -extern atomic_t irq_err_count;
13401 -extern atomic_t irq_mis_count;
13402 +extern atomic_unchecked_t irq_err_count;
13403 +extern atomic_unchecked_t irq_mis_count;
13404
13405 /* EISA */
13406 extern void eisa_set_level_irq(unsigned int irq);
13407 diff --git a/arch/x86/include/asm/i8259.h b/arch/x86/include/asm/i8259.h
13408 index a203659..9889f1c 100644
13409 --- a/arch/x86/include/asm/i8259.h
13410 +++ b/arch/x86/include/asm/i8259.h
13411 @@ -62,7 +62,7 @@ struct legacy_pic {
13412 void (*init)(int auto_eoi);
13413 int (*irq_pending)(unsigned int irq);
13414 void (*make_irq)(unsigned int irq);
13415 -};
13416 +} __do_const;
13417
13418 extern struct legacy_pic *legacy_pic;
13419 extern struct legacy_pic null_legacy_pic;
13420 diff --git a/arch/x86/include/asm/io.h b/arch/x86/include/asm/io.h
13421 index d8e8eef..1765f78 100644
13422 --- a/arch/x86/include/asm/io.h
13423 +++ b/arch/x86/include/asm/io.h
13424 @@ -51,12 +51,12 @@ static inline void name(type val, volatile void __iomem *addr) \
13425 "m" (*(volatile type __force *)addr) barrier); }
13426
13427 build_mmio_read(readb, "b", unsigned char, "=q", :"memory")
13428 -build_mmio_read(readw, "w", unsigned short, "=r", :"memory")
13429 -build_mmio_read(readl, "l", unsigned int, "=r", :"memory")
13430 +build_mmio_read(__intentional_overflow(-1) readw, "w", unsigned short, "=r", :"memory")
13431 +build_mmio_read(__intentional_overflow(-1) readl, "l", unsigned int, "=r", :"memory")
13432
13433 build_mmio_read(__readb, "b", unsigned char, "=q", )
13434 -build_mmio_read(__readw, "w", unsigned short, "=r", )
13435 -build_mmio_read(__readl, "l", unsigned int, "=r", )
13436 +build_mmio_read(__intentional_overflow(-1) __readw, "w", unsigned short, "=r", )
13437 +build_mmio_read(__intentional_overflow(-1) __readl, "l", unsigned int, "=r", )
13438
13439 build_mmio_write(writeb, "b", unsigned char, "q", :"memory")
13440 build_mmio_write(writew, "w", unsigned short, "r", :"memory")
13441 @@ -184,7 +184,7 @@ static inline void __iomem *ioremap(resource_size_t offset, unsigned long size)
13442 return ioremap_nocache(offset, size);
13443 }
13444
13445 -extern void iounmap(volatile void __iomem *addr);
13446 +extern void iounmap(const volatile void __iomem *addr);
13447
13448 extern void set_iounmap_nonlazy(void);
13449
13450 @@ -194,6 +194,17 @@ extern void set_iounmap_nonlazy(void);
13451
13452 #include <linux/vmalloc.h>
13453
13454 +#define ARCH_HAS_VALID_PHYS_ADDR_RANGE
13455 +static inline int valid_phys_addr_range(unsigned long addr, size_t count)
13456 +{
13457 + return ((addr + count + PAGE_SIZE - 1) >> PAGE_SHIFT) < (1ULL << (boot_cpu_data.x86_phys_bits - PAGE_SHIFT)) ? 1 : 0;
13458 +}
13459 +
13460 +static inline int valid_mmap_phys_addr_range(unsigned long pfn, size_t count)
13461 +{
13462 + return (pfn + (count >> PAGE_SHIFT)) < (1ULL << (boot_cpu_data.x86_phys_bits - PAGE_SHIFT)) ? 1 : 0;
13463 +}
13464 +
13465 /*
13466 * Convert a virtual cached pointer to an uncached pointer
13467 */
13468 diff --git a/arch/x86/include/asm/irqflags.h b/arch/x86/include/asm/irqflags.h
13469 index bba3cf8..06bc8da 100644
13470 --- a/arch/x86/include/asm/irqflags.h
13471 +++ b/arch/x86/include/asm/irqflags.h
13472 @@ -141,6 +141,11 @@ static inline notrace unsigned long arch_local_irq_save(void)
13473 sti; \
13474 sysexit
13475
13476 +#define GET_CR0_INTO_RDI mov %cr0, %rdi
13477 +#define SET_RDI_INTO_CR0 mov %rdi, %cr0
13478 +#define GET_CR3_INTO_RDI mov %cr3, %rdi
13479 +#define SET_RDI_INTO_CR3 mov %rdi, %cr3
13480 +
13481 #else
13482 #define INTERRUPT_RETURN iret
13483 #define ENABLE_INTERRUPTS_SYSEXIT sti; sysexit
13484 diff --git a/arch/x86/include/asm/kprobes.h b/arch/x86/include/asm/kprobes.h
13485 index d3ddd17..c9fb0cc 100644
13486 --- a/arch/x86/include/asm/kprobes.h
13487 +++ b/arch/x86/include/asm/kprobes.h
13488 @@ -38,13 +38,8 @@ typedef u8 kprobe_opcode_t;
13489 #define RELATIVEJUMP_SIZE 5
13490 #define RELATIVECALL_OPCODE 0xe8
13491 #define RELATIVE_ADDR_SIZE 4
13492 -#define MAX_STACK_SIZE 64
13493 -#define MIN_STACK_SIZE(ADDR) \
13494 - (((MAX_STACK_SIZE) < (((unsigned long)current_thread_info()) + \
13495 - THREAD_SIZE - (unsigned long)(ADDR))) \
13496 - ? (MAX_STACK_SIZE) \
13497 - : (((unsigned long)current_thread_info()) + \
13498 - THREAD_SIZE - (unsigned long)(ADDR)))
13499 +#define MAX_STACK_SIZE 64UL
13500 +#define MIN_STACK_SIZE(ADDR) min(MAX_STACK_SIZE, current->thread.sp0 - (unsigned long)(ADDR))
13501
13502 #define flush_insn_slot(p) do { } while (0)
13503
13504 diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h
13505 index dc87b65..85039f9 100644
13506 --- a/arch/x86/include/asm/kvm_host.h
13507 +++ b/arch/x86/include/asm/kvm_host.h
13508 @@ -419,8 +419,8 @@ struct kvm_vcpu_arch {
13509 gpa_t time;
13510 struct pvclock_vcpu_time_info hv_clock;
13511 unsigned int hw_tsc_khz;
13512 - unsigned int time_offset;
13513 - struct page *time_page;
13514 + struct gfn_to_hva_cache pv_time;
13515 + bool pv_time_enabled;
13516 /* set guest stopped flag in pvclock flags field */
13517 bool pvclock_set_guest_stopped_request;
13518
13519 diff --git a/arch/x86/include/asm/local.h b/arch/x86/include/asm/local.h
13520 index 2d89e39..baee879 100644
13521 --- a/arch/x86/include/asm/local.h
13522 +++ b/arch/x86/include/asm/local.h
13523 @@ -10,33 +10,97 @@ typedef struct {
13524 atomic_long_t a;
13525 } local_t;
13526
13527 +typedef struct {
13528 + atomic_long_unchecked_t a;
13529 +} local_unchecked_t;
13530 +
13531 #define LOCAL_INIT(i) { ATOMIC_LONG_INIT(i) }
13532
13533 #define local_read(l) atomic_long_read(&(l)->a)
13534 +#define local_read_unchecked(l) atomic_long_read_unchecked(&(l)->a)
13535 #define local_set(l, i) atomic_long_set(&(l)->a, (i))
13536 +#define local_set_unchecked(l, i) atomic_long_set_unchecked(&(l)->a, (i))
13537
13538 static inline void local_inc(local_t *l)
13539 {
13540 - asm volatile(_ASM_INC "%0"
13541 + asm volatile(_ASM_INC "%0\n"
13542 +
13543 +#ifdef CONFIG_PAX_REFCOUNT
13544 + "jno 0f\n"
13545 + _ASM_DEC "%0\n"
13546 + "int $4\n0:\n"
13547 + _ASM_EXTABLE(0b, 0b)
13548 +#endif
13549 +
13550 + : "+m" (l->a.counter));
13551 +}
13552 +
13553 +static inline void local_inc_unchecked(local_unchecked_t *l)
13554 +{
13555 + asm volatile(_ASM_INC "%0\n"
13556 : "+m" (l->a.counter));
13557 }
13558
13559 static inline void local_dec(local_t *l)
13560 {
13561 - asm volatile(_ASM_DEC "%0"
13562 + asm volatile(_ASM_DEC "%0\n"
13563 +
13564 +#ifdef CONFIG_PAX_REFCOUNT
13565 + "jno 0f\n"
13566 + _ASM_INC "%0\n"
13567 + "int $4\n0:\n"
13568 + _ASM_EXTABLE(0b, 0b)
13569 +#endif
13570 +
13571 + : "+m" (l->a.counter));
13572 +}
13573 +
13574 +static inline void local_dec_unchecked(local_unchecked_t *l)
13575 +{
13576 + asm volatile(_ASM_DEC "%0\n"
13577 : "+m" (l->a.counter));
13578 }
13579
13580 static inline void local_add(long i, local_t *l)
13581 {
13582 - asm volatile(_ASM_ADD "%1,%0"
13583 + asm volatile(_ASM_ADD "%1,%0\n"
13584 +
13585 +#ifdef CONFIG_PAX_REFCOUNT
13586 + "jno 0f\n"
13587 + _ASM_SUB "%1,%0\n"
13588 + "int $4\n0:\n"
13589 + _ASM_EXTABLE(0b, 0b)
13590 +#endif
13591 +
13592 + : "+m" (l->a.counter)
13593 + : "ir" (i));
13594 +}
13595 +
13596 +static inline void local_add_unchecked(long i, local_unchecked_t *l)
13597 +{
13598 + asm volatile(_ASM_ADD "%1,%0\n"
13599 : "+m" (l->a.counter)
13600 : "ir" (i));
13601 }
13602
13603 static inline void local_sub(long i, local_t *l)
13604 {
13605 - asm volatile(_ASM_SUB "%1,%0"
13606 + asm volatile(_ASM_SUB "%1,%0\n"
13607 +
13608 +#ifdef CONFIG_PAX_REFCOUNT
13609 + "jno 0f\n"
13610 + _ASM_ADD "%1,%0\n"
13611 + "int $4\n0:\n"
13612 + _ASM_EXTABLE(0b, 0b)
13613 +#endif
13614 +
13615 + : "+m" (l->a.counter)
13616 + : "ir" (i));
13617 +}
13618 +
13619 +static inline void local_sub_unchecked(long i, local_unchecked_t *l)
13620 +{
13621 + asm volatile(_ASM_SUB "%1,%0\n"
13622 : "+m" (l->a.counter)
13623 : "ir" (i));
13624 }
13625 @@ -54,7 +118,16 @@ static inline int local_sub_and_test(long i, local_t *l)
13626 {
13627 unsigned char c;
13628
13629 - asm volatile(_ASM_SUB "%2,%0; sete %1"
13630 + asm volatile(_ASM_SUB "%2,%0\n"
13631 +
13632 +#ifdef CONFIG_PAX_REFCOUNT
13633 + "jno 0f\n"
13634 + _ASM_ADD "%2,%0\n"
13635 + "int $4\n0:\n"
13636 + _ASM_EXTABLE(0b, 0b)
13637 +#endif
13638 +
13639 + "sete %1\n"
13640 : "+m" (l->a.counter), "=qm" (c)
13641 : "ir" (i) : "memory");
13642 return c;
13643 @@ -72,7 +145,16 @@ static inline int local_dec_and_test(local_t *l)
13644 {
13645 unsigned char c;
13646
13647 - asm volatile(_ASM_DEC "%0; sete %1"
13648 + asm volatile(_ASM_DEC "%0\n"
13649 +
13650 +#ifdef CONFIG_PAX_REFCOUNT
13651 + "jno 0f\n"
13652 + _ASM_INC "%0\n"
13653 + "int $4\n0:\n"
13654 + _ASM_EXTABLE(0b, 0b)
13655 +#endif
13656 +
13657 + "sete %1\n"
13658 : "+m" (l->a.counter), "=qm" (c)
13659 : : "memory");
13660 return c != 0;
13661 @@ -90,7 +172,16 @@ static inline int local_inc_and_test(local_t *l)
13662 {
13663 unsigned char c;
13664
13665 - asm volatile(_ASM_INC "%0; sete %1"
13666 + asm volatile(_ASM_INC "%0\n"
13667 +
13668 +#ifdef CONFIG_PAX_REFCOUNT
13669 + "jno 0f\n"
13670 + _ASM_DEC "%0\n"
13671 + "int $4\n0:\n"
13672 + _ASM_EXTABLE(0b, 0b)
13673 +#endif
13674 +
13675 + "sete %1\n"
13676 : "+m" (l->a.counter), "=qm" (c)
13677 : : "memory");
13678 return c != 0;
13679 @@ -109,7 +200,16 @@ static inline int local_add_negative(long i, local_t *l)
13680 {
13681 unsigned char c;
13682
13683 - asm volatile(_ASM_ADD "%2,%0; sets %1"
13684 + asm volatile(_ASM_ADD "%2,%0\n"
13685 +
13686 +#ifdef CONFIG_PAX_REFCOUNT
13687 + "jno 0f\n"
13688 + _ASM_SUB "%2,%0\n"
13689 + "int $4\n0:\n"
13690 + _ASM_EXTABLE(0b, 0b)
13691 +#endif
13692 +
13693 + "sets %1\n"
13694 : "+m" (l->a.counter), "=qm" (c)
13695 : "ir" (i) : "memory");
13696 return c;
13697 @@ -125,6 +225,30 @@ static inline int local_add_negative(long i, local_t *l)
13698 static inline long local_add_return(long i, local_t *l)
13699 {
13700 long __i = i;
13701 + asm volatile(_ASM_XADD "%0, %1\n"
13702 +
13703 +#ifdef CONFIG_PAX_REFCOUNT
13704 + "jno 0f\n"
13705 + _ASM_MOV "%0,%1\n"
13706 + "int $4\n0:\n"
13707 + _ASM_EXTABLE(0b, 0b)
13708 +#endif
13709 +
13710 + : "+r" (i), "+m" (l->a.counter)
13711 + : : "memory");
13712 + return i + __i;
13713 +}
13714 +
13715 +/**
13716 + * local_add_return_unchecked - add and return
13717 + * @i: integer value to add
13718 + * @l: pointer to type local_unchecked_t
13719 + *
13720 + * Atomically adds @i to @l and returns @i + @l
13721 + */
13722 +static inline long local_add_return_unchecked(long i, local_unchecked_t *l)
13723 +{
13724 + long __i = i;
13725 asm volatile(_ASM_XADD "%0, %1;"
13726 : "+r" (i), "+m" (l->a.counter)
13727 : : "memory");
13728 @@ -141,6 +265,8 @@ static inline long local_sub_return(long i, local_t *l)
13729
13730 #define local_cmpxchg(l, o, n) \
13731 (cmpxchg_local(&((l)->a.counter), (o), (n)))
13732 +#define local_cmpxchg_unchecked(l, o, n) \
13733 + (cmpxchg_local(&((l)->a.counter), (o), (n)))
13734 /* Always has a lock prefix */
13735 #define local_xchg(l, n) (xchg(&((l)->a.counter), (n)))
13736
13737 diff --git a/arch/x86/include/asm/mman.h b/arch/x86/include/asm/mman.h
13738 new file mode 100644
13739 index 0000000..2bfd3ba
13740 --- /dev/null
13741 +++ b/arch/x86/include/asm/mman.h
13742 @@ -0,0 +1,15 @@
13743 +#ifndef _X86_MMAN_H
13744 +#define _X86_MMAN_H
13745 +
13746 +#include <uapi/asm/mman.h>
13747 +
13748 +#ifdef __KERNEL__
13749 +#ifndef __ASSEMBLY__
13750 +#ifdef CONFIG_X86_32
13751 +#define arch_mmap_check i386_mmap_check
13752 +int i386_mmap_check(unsigned long addr, unsigned long len, unsigned long flags);
13753 +#endif
13754 +#endif
13755 +#endif
13756 +
13757 +#endif /* X86_MMAN_H */
13758 diff --git a/arch/x86/include/asm/mmu.h b/arch/x86/include/asm/mmu.h
13759 index 5f55e69..e20bfb1 100644
13760 --- a/arch/x86/include/asm/mmu.h
13761 +++ b/arch/x86/include/asm/mmu.h
13762 @@ -9,7 +9,7 @@
13763 * we put the segment information here.
13764 */
13765 typedef struct {
13766 - void *ldt;
13767 + struct desc_struct *ldt;
13768 int size;
13769
13770 #ifdef CONFIG_X86_64
13771 @@ -18,7 +18,19 @@ typedef struct {
13772 #endif
13773
13774 struct mutex lock;
13775 - void *vdso;
13776 + unsigned long vdso;
13777 +
13778 +#ifdef CONFIG_X86_32
13779 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
13780 + unsigned long user_cs_base;
13781 + unsigned long user_cs_limit;
13782 +
13783 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_SMP)
13784 + cpumask_t cpu_user_cs_mask;
13785 +#endif
13786 +
13787 +#endif
13788 +#endif
13789 } mm_context_t;
13790
13791 #ifdef CONFIG_SMP
13792 diff --git a/arch/x86/include/asm/mmu_context.h b/arch/x86/include/asm/mmu_context.h
13793 index cdbf367..adb37ac 100644
13794 --- a/arch/x86/include/asm/mmu_context.h
13795 +++ b/arch/x86/include/asm/mmu_context.h
13796 @@ -24,6 +24,18 @@ void destroy_context(struct mm_struct *mm);
13797
13798 static inline void enter_lazy_tlb(struct mm_struct *mm, struct task_struct *tsk)
13799 {
13800 +
13801 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
13802 + unsigned int i;
13803 + pgd_t *pgd;
13804 +
13805 + pax_open_kernel();
13806 + pgd = get_cpu_pgd(smp_processor_id());
13807 + for (i = USER_PGD_PTRS; i < 2 * USER_PGD_PTRS; ++i)
13808 + set_pgd_batched(pgd+i, native_make_pgd(0));
13809 + pax_close_kernel();
13810 +#endif
13811 +
13812 #ifdef CONFIG_SMP
13813 if (this_cpu_read(cpu_tlbstate.state) == TLBSTATE_OK)
13814 this_cpu_write(cpu_tlbstate.state, TLBSTATE_LAZY);
13815 @@ -34,16 +46,30 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
13816 struct task_struct *tsk)
13817 {
13818 unsigned cpu = smp_processor_id();
13819 +#if defined(CONFIG_X86_32) && defined(CONFIG_SMP) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
13820 + int tlbstate = TLBSTATE_OK;
13821 +#endif
13822
13823 if (likely(prev != next)) {
13824 #ifdef CONFIG_SMP
13825 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
13826 + tlbstate = this_cpu_read(cpu_tlbstate.state);
13827 +#endif
13828 this_cpu_write(cpu_tlbstate.state, TLBSTATE_OK);
13829 this_cpu_write(cpu_tlbstate.active_mm, next);
13830 #endif
13831 cpumask_set_cpu(cpu, mm_cpumask(next));
13832
13833 /* Re-load page tables */
13834 +#ifdef CONFIG_PAX_PER_CPU_PGD
13835 + pax_open_kernel();
13836 + __clone_user_pgds(get_cpu_pgd(cpu), next->pgd);
13837 + __shadow_user_pgds(get_cpu_pgd(cpu) + USER_PGD_PTRS, next->pgd);
13838 + pax_close_kernel();
13839 + load_cr3(get_cpu_pgd(cpu));
13840 +#else
13841 load_cr3(next->pgd);
13842 +#endif
13843
13844 /* stop flush ipis for the previous mm */
13845 cpumask_clear_cpu(cpu, mm_cpumask(prev));
13846 @@ -53,9 +79,38 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
13847 */
13848 if (unlikely(prev->context.ldt != next->context.ldt))
13849 load_LDT_nolock(&next->context);
13850 - }
13851 +
13852 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_SMP)
13853 + if (!(__supported_pte_mask & _PAGE_NX)) {
13854 + smp_mb__before_clear_bit();
13855 + cpu_clear(cpu, prev->context.cpu_user_cs_mask);
13856 + smp_mb__after_clear_bit();
13857 + cpu_set(cpu, next->context.cpu_user_cs_mask);
13858 + }
13859 +#endif
13860 +
13861 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
13862 + if (unlikely(prev->context.user_cs_base != next->context.user_cs_base ||
13863 + prev->context.user_cs_limit != next->context.user_cs_limit))
13864 + set_user_cs(next->context.user_cs_base, next->context.user_cs_limit, cpu);
13865 #ifdef CONFIG_SMP
13866 + else if (unlikely(tlbstate != TLBSTATE_OK))
13867 + set_user_cs(next->context.user_cs_base, next->context.user_cs_limit, cpu);
13868 +#endif
13869 +#endif
13870 +
13871 + }
13872 else {
13873 +
13874 +#ifdef CONFIG_PAX_PER_CPU_PGD
13875 + pax_open_kernel();
13876 + __clone_user_pgds(get_cpu_pgd(cpu), next->pgd);
13877 + __shadow_user_pgds(get_cpu_pgd(cpu) + USER_PGD_PTRS, next->pgd);
13878 + pax_close_kernel();
13879 + load_cr3(get_cpu_pgd(cpu));
13880 +#endif
13881 +
13882 +#ifdef CONFIG_SMP
13883 this_cpu_write(cpu_tlbstate.state, TLBSTATE_OK);
13884 BUG_ON(this_cpu_read(cpu_tlbstate.active_mm) != next);
13885
13886 @@ -64,11 +119,28 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
13887 * tlb flush IPI delivery. We must reload CR3
13888 * to make sure to use no freed page tables.
13889 */
13890 +
13891 +#ifndef CONFIG_PAX_PER_CPU_PGD
13892 load_cr3(next->pgd);
13893 +#endif
13894 +
13895 load_LDT_nolock(&next->context);
13896 +
13897 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
13898 + if (!(__supported_pte_mask & _PAGE_NX))
13899 + cpu_set(cpu, next->context.cpu_user_cs_mask);
13900 +#endif
13901 +
13902 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
13903 +#ifdef CONFIG_PAX_PAGEEXEC
13904 + if (!((next->pax_flags & MF_PAX_PAGEEXEC) && (__supported_pte_mask & _PAGE_NX)))
13905 +#endif
13906 + set_user_cs(next->context.user_cs_base, next->context.user_cs_limit, cpu);
13907 +#endif
13908 +
13909 }
13910 +#endif
13911 }
13912 -#endif
13913 }
13914
13915 #define activate_mm(prev, next) \
13916 diff --git a/arch/x86/include/asm/module.h b/arch/x86/include/asm/module.h
13917 index e3b7819..b257c64 100644
13918 --- a/arch/x86/include/asm/module.h
13919 +++ b/arch/x86/include/asm/module.h
13920 @@ -5,6 +5,7 @@
13921
13922 #ifdef CONFIG_X86_64
13923 /* X86_64 does not define MODULE_PROC_FAMILY */
13924 +#define MODULE_PROC_FAMILY ""
13925 #elif defined CONFIG_M486
13926 #define MODULE_PROC_FAMILY "486 "
13927 #elif defined CONFIG_M586
13928 @@ -57,8 +58,20 @@
13929 #error unknown processor family
13930 #endif
13931
13932 -#ifdef CONFIG_X86_32
13933 -# define MODULE_ARCH_VERMAGIC MODULE_PROC_FAMILY
13934 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_BTS
13935 +#define MODULE_PAX_KERNEXEC "KERNEXEC_BTS "
13936 +#elif defined(CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR)
13937 +#define MODULE_PAX_KERNEXEC "KERNEXEC_OR "
13938 +#else
13939 +#define MODULE_PAX_KERNEXEC ""
13940 #endif
13941
13942 +#ifdef CONFIG_PAX_MEMORY_UDEREF
13943 +#define MODULE_PAX_UDEREF "UDEREF "
13944 +#else
13945 +#define MODULE_PAX_UDEREF ""
13946 +#endif
13947 +
13948 +#define MODULE_ARCH_VERMAGIC MODULE_PROC_FAMILY MODULE_PAX_KERNEXEC MODULE_PAX_UDEREF
13949 +
13950 #endif /* _ASM_X86_MODULE_H */
13951 diff --git a/arch/x86/include/asm/nmi.h b/arch/x86/include/asm/nmi.h
13952 index c0fa356..07a498a 100644
13953 --- a/arch/x86/include/asm/nmi.h
13954 +++ b/arch/x86/include/asm/nmi.h
13955 @@ -42,11 +42,11 @@ struct nmiaction {
13956 nmi_handler_t handler;
13957 unsigned long flags;
13958 const char *name;
13959 -};
13960 +} __do_const;
13961
13962 #define register_nmi_handler(t, fn, fg, n, init...) \
13963 ({ \
13964 - static struct nmiaction init fn##_na = { \
13965 + static const struct nmiaction init fn##_na = { \
13966 .handler = (fn), \
13967 .name = (n), \
13968 .flags = (fg), \
13969 @@ -54,7 +54,7 @@ struct nmiaction {
13970 __register_nmi_handler((t), &fn##_na); \
13971 })
13972
13973 -int __register_nmi_handler(unsigned int, struct nmiaction *);
13974 +int __register_nmi_handler(unsigned int, const struct nmiaction *);
13975
13976 void unregister_nmi_handler(unsigned int, const char *);
13977
13978 diff --git a/arch/x86/include/asm/page_64_types.h b/arch/x86/include/asm/page_64_types.h
13979 index 320f7bb..e89f8f8 100644
13980 --- a/arch/x86/include/asm/page_64_types.h
13981 +++ b/arch/x86/include/asm/page_64_types.h
13982 @@ -56,7 +56,7 @@ void copy_page(void *to, void *from);
13983
13984 /* duplicated to the one in bootmem.h */
13985 extern unsigned long max_pfn;
13986 -extern unsigned long phys_base;
13987 +extern const unsigned long phys_base;
13988
13989 extern unsigned long __phys_addr(unsigned long);
13990 #define __phys_reloc_hide(x) (x)
13991 diff --git a/arch/x86/include/asm/paravirt.h b/arch/x86/include/asm/paravirt.h
13992 index 5edd174..c395822 100644
13993 --- a/arch/x86/include/asm/paravirt.h
13994 +++ b/arch/x86/include/asm/paravirt.h
13995 @@ -564,7 +564,7 @@ static inline pmd_t __pmd(pmdval_t val)
13996 return (pmd_t) { ret };
13997 }
13998
13999 -static inline pmdval_t pmd_val(pmd_t pmd)
14000 +static inline __intentional_overflow(-1) pmdval_t pmd_val(pmd_t pmd)
14001 {
14002 pmdval_t ret;
14003
14004 @@ -630,6 +630,18 @@ static inline void set_pgd(pgd_t *pgdp, pgd_t pgd)
14005 val);
14006 }
14007
14008 +static inline void set_pgd_batched(pgd_t *pgdp, pgd_t pgd)
14009 +{
14010 + pgdval_t val = native_pgd_val(pgd);
14011 +
14012 + if (sizeof(pgdval_t) > sizeof(long))
14013 + PVOP_VCALL3(pv_mmu_ops.set_pgd_batched, pgdp,
14014 + val, (u64)val >> 32);
14015 + else
14016 + PVOP_VCALL2(pv_mmu_ops.set_pgd_batched, pgdp,
14017 + val);
14018 +}
14019 +
14020 static inline void pgd_clear(pgd_t *pgdp)
14021 {
14022 set_pgd(pgdp, __pgd(0));
14023 @@ -711,6 +723,21 @@ static inline void __set_fixmap(unsigned /* enum fixed_addresses */ idx,
14024 pv_mmu_ops.set_fixmap(idx, phys, flags);
14025 }
14026
14027 +#ifdef CONFIG_PAX_KERNEXEC
14028 +static inline unsigned long pax_open_kernel(void)
14029 +{
14030 + return PVOP_CALL0(unsigned long, pv_mmu_ops.pax_open_kernel);
14031 +}
14032 +
14033 +static inline unsigned long pax_close_kernel(void)
14034 +{
14035 + return PVOP_CALL0(unsigned long, pv_mmu_ops.pax_close_kernel);
14036 +}
14037 +#else
14038 +static inline unsigned long pax_open_kernel(void) { return 0; }
14039 +static inline unsigned long pax_close_kernel(void) { return 0; }
14040 +#endif
14041 +
14042 #if defined(CONFIG_SMP) && defined(CONFIG_PARAVIRT_SPINLOCKS)
14043
14044 static inline int arch_spin_is_locked(struct arch_spinlock *lock)
14045 @@ -927,7 +954,7 @@ extern void default_banner(void);
14046
14047 #define PARA_PATCH(struct, off) ((PARAVIRT_PATCH_##struct + (off)) / 4)
14048 #define PARA_SITE(ptype, clobbers, ops) _PVSITE(ptype, clobbers, ops, .long, 4)
14049 -#define PARA_INDIRECT(addr) *%cs:addr
14050 +#define PARA_INDIRECT(addr) *%ss:addr
14051 #endif
14052
14053 #define INTERRUPT_RETURN \
14054 @@ -1002,6 +1029,21 @@ extern void default_banner(void);
14055 PARA_SITE(PARA_PATCH(pv_cpu_ops, PV_CPU_irq_enable_sysexit), \
14056 CLBR_NONE, \
14057 jmp PARA_INDIRECT(pv_cpu_ops+PV_CPU_irq_enable_sysexit))
14058 +
14059 +#define GET_CR0_INTO_RDI \
14060 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_read_cr0); \
14061 + mov %rax,%rdi
14062 +
14063 +#define SET_RDI_INTO_CR0 \
14064 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_write_cr0)
14065 +
14066 +#define GET_CR3_INTO_RDI \
14067 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_read_cr3); \
14068 + mov %rax,%rdi
14069 +
14070 +#define SET_RDI_INTO_CR3 \
14071 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_write_cr3)
14072 +
14073 #endif /* CONFIG_X86_32 */
14074
14075 #endif /* __ASSEMBLY__ */
14076 diff --git a/arch/x86/include/asm/paravirt_types.h b/arch/x86/include/asm/paravirt_types.h
14077 index 142236e..5446ffbc 100644
14078 --- a/arch/x86/include/asm/paravirt_types.h
14079 +++ b/arch/x86/include/asm/paravirt_types.h
14080 @@ -84,7 +84,7 @@ struct pv_init_ops {
14081 */
14082 unsigned (*patch)(u8 type, u16 clobber, void *insnbuf,
14083 unsigned long addr, unsigned len);
14084 -};
14085 +} __no_const;
14086
14087
14088 struct pv_lazy_ops {
14089 @@ -97,7 +97,7 @@ struct pv_time_ops {
14090 unsigned long long (*sched_clock)(void);
14091 unsigned long long (*steal_clock)(int cpu);
14092 unsigned long (*get_tsc_khz)(void);
14093 -};
14094 +} __no_const;
14095
14096 struct pv_cpu_ops {
14097 /* hooks for various privileged instructions */
14098 @@ -191,7 +191,7 @@ struct pv_cpu_ops {
14099
14100 void (*start_context_switch)(struct task_struct *prev);
14101 void (*end_context_switch)(struct task_struct *next);
14102 -};
14103 +} __no_const;
14104
14105 struct pv_irq_ops {
14106 /*
14107 @@ -222,7 +222,7 @@ struct pv_apic_ops {
14108 unsigned long start_eip,
14109 unsigned long start_esp);
14110 #endif
14111 -};
14112 +} __no_const;
14113
14114 struct pv_mmu_ops {
14115 unsigned long (*read_cr2)(void);
14116 @@ -312,6 +312,7 @@ struct pv_mmu_ops {
14117 struct paravirt_callee_save make_pud;
14118
14119 void (*set_pgd)(pgd_t *pudp, pgd_t pgdval);
14120 + void (*set_pgd_batched)(pgd_t *pudp, pgd_t pgdval);
14121 #endif /* PAGETABLE_LEVELS == 4 */
14122 #endif /* PAGETABLE_LEVELS >= 3 */
14123
14124 @@ -323,6 +324,12 @@ struct pv_mmu_ops {
14125 an mfn. We can tell which is which from the index. */
14126 void (*set_fixmap)(unsigned /* enum fixed_addresses */ idx,
14127 phys_addr_t phys, pgprot_t flags);
14128 +
14129 +#ifdef CONFIG_PAX_KERNEXEC
14130 + unsigned long (*pax_open_kernel)(void);
14131 + unsigned long (*pax_close_kernel)(void);
14132 +#endif
14133 +
14134 };
14135
14136 struct arch_spinlock;
14137 @@ -333,7 +340,7 @@ struct pv_lock_ops {
14138 void (*spin_lock_flags)(struct arch_spinlock *lock, unsigned long flags);
14139 int (*spin_trylock)(struct arch_spinlock *lock);
14140 void (*spin_unlock)(struct arch_spinlock *lock);
14141 -};
14142 +} __no_const;
14143
14144 /* This contains all the paravirt structures: we get a convenient
14145 * number for each function using the offset which we use to indicate
14146 diff --git a/arch/x86/include/asm/pgalloc.h b/arch/x86/include/asm/pgalloc.h
14147 index b4389a4..7024269 100644
14148 --- a/arch/x86/include/asm/pgalloc.h
14149 +++ b/arch/x86/include/asm/pgalloc.h
14150 @@ -63,6 +63,13 @@ static inline void pmd_populate_kernel(struct mm_struct *mm,
14151 pmd_t *pmd, pte_t *pte)
14152 {
14153 paravirt_alloc_pte(mm, __pa(pte) >> PAGE_SHIFT);
14154 + set_pmd(pmd, __pmd(__pa(pte) | _KERNPG_TABLE));
14155 +}
14156 +
14157 +static inline void pmd_populate_user(struct mm_struct *mm,
14158 + pmd_t *pmd, pte_t *pte)
14159 +{
14160 + paravirt_alloc_pte(mm, __pa(pte) >> PAGE_SHIFT);
14161 set_pmd(pmd, __pmd(__pa(pte) | _PAGE_TABLE));
14162 }
14163
14164 @@ -99,12 +106,22 @@ static inline void __pmd_free_tlb(struct mmu_gather *tlb, pmd_t *pmd,
14165
14166 #ifdef CONFIG_X86_PAE
14167 extern void pud_populate(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd);
14168 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd)
14169 +{
14170 + pud_populate(mm, pudp, pmd);
14171 +}
14172 #else /* !CONFIG_X86_PAE */
14173 static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
14174 {
14175 paravirt_alloc_pmd(mm, __pa(pmd) >> PAGE_SHIFT);
14176 set_pud(pud, __pud(_PAGE_TABLE | __pa(pmd)));
14177 }
14178 +
14179 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
14180 +{
14181 + paravirt_alloc_pmd(mm, __pa(pmd) >> PAGE_SHIFT);
14182 + set_pud(pud, __pud(_KERNPG_TABLE | __pa(pmd)));
14183 +}
14184 #endif /* CONFIG_X86_PAE */
14185
14186 #if PAGETABLE_LEVELS > 3
14187 @@ -114,6 +131,12 @@ static inline void pgd_populate(struct mm_struct *mm, pgd_t *pgd, pud_t *pud)
14188 set_pgd(pgd, __pgd(_PAGE_TABLE | __pa(pud)));
14189 }
14190
14191 +static inline void pgd_populate_kernel(struct mm_struct *mm, pgd_t *pgd, pud_t *pud)
14192 +{
14193 + paravirt_alloc_pud(mm, __pa(pud) >> PAGE_SHIFT);
14194 + set_pgd(pgd, __pgd(_KERNPG_TABLE | __pa(pud)));
14195 +}
14196 +
14197 static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr)
14198 {
14199 return (pud_t *)get_zeroed_page(GFP_KERNEL|__GFP_REPEAT);
14200 diff --git a/arch/x86/include/asm/pgtable-2level.h b/arch/x86/include/asm/pgtable-2level.h
14201 index f2b489c..4f7e2e5 100644
14202 --- a/arch/x86/include/asm/pgtable-2level.h
14203 +++ b/arch/x86/include/asm/pgtable-2level.h
14204 @@ -18,7 +18,9 @@ static inline void native_set_pte(pte_t *ptep , pte_t pte)
14205
14206 static inline void native_set_pmd(pmd_t *pmdp, pmd_t pmd)
14207 {
14208 + pax_open_kernel();
14209 *pmdp = pmd;
14210 + pax_close_kernel();
14211 }
14212
14213 static inline void native_set_pte_atomic(pte_t *ptep, pte_t pte)
14214 diff --git a/arch/x86/include/asm/pgtable-3level.h b/arch/x86/include/asm/pgtable-3level.h
14215 index 4cc9f2b..5fd9226 100644
14216 --- a/arch/x86/include/asm/pgtable-3level.h
14217 +++ b/arch/x86/include/asm/pgtable-3level.h
14218 @@ -92,12 +92,16 @@ static inline void native_set_pte_atomic(pte_t *ptep, pte_t pte)
14219
14220 static inline void native_set_pmd(pmd_t *pmdp, pmd_t pmd)
14221 {
14222 + pax_open_kernel();
14223 set_64bit((unsigned long long *)(pmdp), native_pmd_val(pmd));
14224 + pax_close_kernel();
14225 }
14226
14227 static inline void native_set_pud(pud_t *pudp, pud_t pud)
14228 {
14229 + pax_open_kernel();
14230 set_64bit((unsigned long long *)(pudp), native_pud_val(pud));
14231 + pax_close_kernel();
14232 }
14233
14234 /*
14235 diff --git a/arch/x86/include/asm/pgtable.h b/arch/x86/include/asm/pgtable.h
14236 index 1c1a955..50f828c 100644
14237 --- a/arch/x86/include/asm/pgtable.h
14238 +++ b/arch/x86/include/asm/pgtable.h
14239 @@ -44,6 +44,7 @@ extern struct mm_struct *pgd_page_get_mm(struct page *page);
14240
14241 #ifndef __PAGETABLE_PUD_FOLDED
14242 #define set_pgd(pgdp, pgd) native_set_pgd(pgdp, pgd)
14243 +#define set_pgd_batched(pgdp, pgd) native_set_pgd_batched(pgdp, pgd)
14244 #define pgd_clear(pgd) native_pgd_clear(pgd)
14245 #endif
14246
14247 @@ -81,12 +82,51 @@ extern struct mm_struct *pgd_page_get_mm(struct page *page);
14248
14249 #define arch_end_context_switch(prev) do {} while(0)
14250
14251 +#define pax_open_kernel() native_pax_open_kernel()
14252 +#define pax_close_kernel() native_pax_close_kernel()
14253 #endif /* CONFIG_PARAVIRT */
14254
14255 +#define __HAVE_ARCH_PAX_OPEN_KERNEL
14256 +#define __HAVE_ARCH_PAX_CLOSE_KERNEL
14257 +
14258 +#ifdef CONFIG_PAX_KERNEXEC
14259 +static inline unsigned long native_pax_open_kernel(void)
14260 +{
14261 + unsigned long cr0;
14262 +
14263 + preempt_disable();
14264 + barrier();
14265 + cr0 = read_cr0() ^ X86_CR0_WP;
14266 + BUG_ON(cr0 & X86_CR0_WP);
14267 + write_cr0(cr0);
14268 + return cr0 ^ X86_CR0_WP;
14269 +}
14270 +
14271 +static inline unsigned long native_pax_close_kernel(void)
14272 +{
14273 + unsigned long cr0;
14274 +
14275 + cr0 = read_cr0() ^ X86_CR0_WP;
14276 + BUG_ON(!(cr0 & X86_CR0_WP));
14277 + write_cr0(cr0);
14278 + barrier();
14279 + preempt_enable_no_resched();
14280 + return cr0 ^ X86_CR0_WP;
14281 +}
14282 +#else
14283 +static inline unsigned long native_pax_open_kernel(void) { return 0; }
14284 +static inline unsigned long native_pax_close_kernel(void) { return 0; }
14285 +#endif
14286 +
14287 /*
14288 * The following only work if pte_present() is true.
14289 * Undefined behaviour if not..
14290 */
14291 +static inline int pte_user(pte_t pte)
14292 +{
14293 + return pte_val(pte) & _PAGE_USER;
14294 +}
14295 +
14296 static inline int pte_dirty(pte_t pte)
14297 {
14298 return pte_flags(pte) & _PAGE_DIRTY;
14299 @@ -200,9 +240,29 @@ static inline pte_t pte_wrprotect(pte_t pte)
14300 return pte_clear_flags(pte, _PAGE_RW);
14301 }
14302
14303 +static inline pte_t pte_mkread(pte_t pte)
14304 +{
14305 + return __pte(pte_val(pte) | _PAGE_USER);
14306 +}
14307 +
14308 static inline pte_t pte_mkexec(pte_t pte)
14309 {
14310 - return pte_clear_flags(pte, _PAGE_NX);
14311 +#ifdef CONFIG_X86_PAE
14312 + if (__supported_pte_mask & _PAGE_NX)
14313 + return pte_clear_flags(pte, _PAGE_NX);
14314 + else
14315 +#endif
14316 + return pte_set_flags(pte, _PAGE_USER);
14317 +}
14318 +
14319 +static inline pte_t pte_exprotect(pte_t pte)
14320 +{
14321 +#ifdef CONFIG_X86_PAE
14322 + if (__supported_pte_mask & _PAGE_NX)
14323 + return pte_set_flags(pte, _PAGE_NX);
14324 + else
14325 +#endif
14326 + return pte_clear_flags(pte, _PAGE_USER);
14327 }
14328
14329 static inline pte_t pte_mkdirty(pte_t pte)
14330 @@ -394,6 +454,15 @@ pte_t *populate_extra_pte(unsigned long vaddr);
14331 #endif
14332
14333 #ifndef __ASSEMBLY__
14334 +
14335 +#ifdef CONFIG_PAX_PER_CPU_PGD
14336 +extern pgd_t cpu_pgd[NR_CPUS][PTRS_PER_PGD];
14337 +static inline pgd_t *get_cpu_pgd(unsigned int cpu)
14338 +{
14339 + return cpu_pgd[cpu];
14340 +}
14341 +#endif
14342 +
14343 #include <linux/mm_types.h>
14344
14345 static inline int pte_none(pte_t pte)
14346 @@ -583,7 +652,7 @@ static inline pud_t *pud_offset(pgd_t *pgd, unsigned long address)
14347
14348 static inline int pgd_bad(pgd_t pgd)
14349 {
14350 - return (pgd_flags(pgd) & ~_PAGE_USER) != _KERNPG_TABLE;
14351 + return (pgd_flags(pgd) & ~(_PAGE_USER | _PAGE_NX)) != _KERNPG_TABLE;
14352 }
14353
14354 static inline int pgd_none(pgd_t pgd)
14355 @@ -606,7 +675,12 @@ static inline int pgd_none(pgd_t pgd)
14356 * pgd_offset() returns a (pgd_t *)
14357 * pgd_index() is used get the offset into the pgd page's array of pgd_t's;
14358 */
14359 -#define pgd_offset(mm, address) ((mm)->pgd + pgd_index((address)))
14360 +#define pgd_offset(mm, address) ((mm)->pgd + pgd_index(address))
14361 +
14362 +#ifdef CONFIG_PAX_PER_CPU_PGD
14363 +#define pgd_offset_cpu(cpu, address) (get_cpu_pgd(cpu) + pgd_index(address))
14364 +#endif
14365 +
14366 /*
14367 * a shortcut which implies the use of the kernel's pgd, instead
14368 * of a process's
14369 @@ -617,6 +691,20 @@ static inline int pgd_none(pgd_t pgd)
14370 #define KERNEL_PGD_BOUNDARY pgd_index(PAGE_OFFSET)
14371 #define KERNEL_PGD_PTRS (PTRS_PER_PGD - KERNEL_PGD_BOUNDARY)
14372
14373 +#ifdef CONFIG_X86_32
14374 +#define USER_PGD_PTRS KERNEL_PGD_BOUNDARY
14375 +#else
14376 +#define TASK_SIZE_MAX_SHIFT CONFIG_TASK_SIZE_MAX_SHIFT
14377 +#define USER_PGD_PTRS (_AC(1,UL) << (TASK_SIZE_MAX_SHIFT - PGDIR_SHIFT))
14378 +
14379 +#ifdef CONFIG_PAX_MEMORY_UDEREF
14380 +#define PAX_USER_SHADOW_BASE (_AC(1,UL) << TASK_SIZE_MAX_SHIFT)
14381 +#else
14382 +#define PAX_USER_SHADOW_BASE (_AC(0,UL))
14383 +#endif
14384 +
14385 +#endif
14386 +
14387 #ifndef __ASSEMBLY__
14388
14389 extern int direct_gbpages;
14390 @@ -781,11 +869,23 @@ static inline void pmdp_set_wrprotect(struct mm_struct *mm,
14391 * dst and src can be on the same page, but the range must not overlap,
14392 * and must not cross a page boundary.
14393 */
14394 -static inline void clone_pgd_range(pgd_t *dst, pgd_t *src, int count)
14395 +static inline void clone_pgd_range(pgd_t *dst, const pgd_t *src, int count)
14396 {
14397 - memcpy(dst, src, count * sizeof(pgd_t));
14398 + pax_open_kernel();
14399 + while (count--)
14400 + *dst++ = *src++;
14401 + pax_close_kernel();
14402 }
14403
14404 +#ifdef CONFIG_PAX_PER_CPU_PGD
14405 +extern void __clone_user_pgds(pgd_t *dst, const pgd_t *src);
14406 +#endif
14407 +
14408 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
14409 +extern void __shadow_user_pgds(pgd_t *dst, const pgd_t *src);
14410 +#else
14411 +static inline void __shadow_user_pgds(pgd_t *dst, const pgd_t *src) {}
14412 +#endif
14413
14414 #include <asm-generic/pgtable.h>
14415 #endif /* __ASSEMBLY__ */
14416 diff --git a/arch/x86/include/asm/pgtable_32.h b/arch/x86/include/asm/pgtable_32.h
14417 index 8faa215..a8a17ea 100644
14418 --- a/arch/x86/include/asm/pgtable_32.h
14419 +++ b/arch/x86/include/asm/pgtable_32.h
14420 @@ -25,9 +25,6 @@
14421 struct mm_struct;
14422 struct vm_area_struct;
14423
14424 -extern pgd_t swapper_pg_dir[1024];
14425 -extern pgd_t initial_page_table[1024];
14426 -
14427 static inline void pgtable_cache_init(void) { }
14428 static inline void check_pgt_cache(void) { }
14429 void paging_init(void);
14430 @@ -48,6 +45,12 @@ extern void set_pmd_pfn(unsigned long, unsigned long, pgprot_t);
14431 # include <asm/pgtable-2level.h>
14432 #endif
14433
14434 +extern pgd_t swapper_pg_dir[PTRS_PER_PGD];
14435 +extern pgd_t initial_page_table[PTRS_PER_PGD];
14436 +#ifdef CONFIG_X86_PAE
14437 +extern pmd_t swapper_pm_dir[PTRS_PER_PGD][PTRS_PER_PMD];
14438 +#endif
14439 +
14440 #if defined(CONFIG_HIGHPTE)
14441 #define pte_offset_map(dir, address) \
14442 ((pte_t *)kmap_atomic(pmd_page(*(dir))) + \
14443 @@ -62,7 +65,9 @@ extern void set_pmd_pfn(unsigned long, unsigned long, pgprot_t);
14444 /* Clear a kernel PTE and flush it from the TLB */
14445 #define kpte_clear_flush(ptep, vaddr) \
14446 do { \
14447 + pax_open_kernel(); \
14448 pte_clear(&init_mm, (vaddr), (ptep)); \
14449 + pax_close_kernel(); \
14450 __flush_tlb_one((vaddr)); \
14451 } while (0)
14452
14453 @@ -75,6 +80,9 @@ do { \
14454
14455 #endif /* !__ASSEMBLY__ */
14456
14457 +#define HAVE_ARCH_UNMAPPED_AREA
14458 +#define HAVE_ARCH_UNMAPPED_AREA_TOPDOWN
14459 +
14460 /*
14461 * kern_addr_valid() is (1) for FLATMEM and (0) for
14462 * SPARSEMEM and DISCONTIGMEM
14463 diff --git a/arch/x86/include/asm/pgtable_32_types.h b/arch/x86/include/asm/pgtable_32_types.h
14464 index ed5903b..c7fe163 100644
14465 --- a/arch/x86/include/asm/pgtable_32_types.h
14466 +++ b/arch/x86/include/asm/pgtable_32_types.h
14467 @@ -8,7 +8,7 @@
14468 */
14469 #ifdef CONFIG_X86_PAE
14470 # include <asm/pgtable-3level_types.h>
14471 -# define PMD_SIZE (1UL << PMD_SHIFT)
14472 +# define PMD_SIZE (_AC(1, UL) << PMD_SHIFT)
14473 # define PMD_MASK (~(PMD_SIZE - 1))
14474 #else
14475 # include <asm/pgtable-2level_types.h>
14476 @@ -46,6 +46,19 @@ extern bool __vmalloc_start_set; /* set once high_memory is set */
14477 # define VMALLOC_END (FIXADDR_START - 2 * PAGE_SIZE)
14478 #endif
14479
14480 +#ifdef CONFIG_PAX_KERNEXEC
14481 +#ifndef __ASSEMBLY__
14482 +extern unsigned char MODULES_EXEC_VADDR[];
14483 +extern unsigned char MODULES_EXEC_END[];
14484 +#endif
14485 +#include <asm/boot.h>
14486 +#define ktla_ktva(addr) (addr + LOAD_PHYSICAL_ADDR + PAGE_OFFSET)
14487 +#define ktva_ktla(addr) (addr - LOAD_PHYSICAL_ADDR - PAGE_OFFSET)
14488 +#else
14489 +#define ktla_ktva(addr) (addr)
14490 +#define ktva_ktla(addr) (addr)
14491 +#endif
14492 +
14493 #define MODULES_VADDR VMALLOC_START
14494 #define MODULES_END VMALLOC_END
14495 #define MODULES_LEN (MODULES_VADDR - MODULES_END)
14496 diff --git a/arch/x86/include/asm/pgtable_64.h b/arch/x86/include/asm/pgtable_64.h
14497 index 47356f9..deb94a2 100644
14498 --- a/arch/x86/include/asm/pgtable_64.h
14499 +++ b/arch/x86/include/asm/pgtable_64.h
14500 @@ -16,10 +16,14 @@
14501
14502 extern pud_t level3_kernel_pgt[512];
14503 extern pud_t level3_ident_pgt[512];
14504 +extern pud_t level3_vmalloc_start_pgt[512];
14505 +extern pud_t level3_vmalloc_end_pgt[512];
14506 +extern pud_t level3_vmemmap_pgt[512];
14507 +extern pud_t level2_vmemmap_pgt[512];
14508 extern pmd_t level2_kernel_pgt[512];
14509 extern pmd_t level2_fixmap_pgt[512];
14510 -extern pmd_t level2_ident_pgt[512];
14511 -extern pgd_t init_level4_pgt[];
14512 +extern pmd_t level2_ident_pgt[512*2];
14513 +extern pgd_t init_level4_pgt[512];
14514
14515 #define swapper_pg_dir init_level4_pgt
14516
14517 @@ -61,7 +65,9 @@ static inline void native_set_pte_atomic(pte_t *ptep, pte_t pte)
14518
14519 static inline void native_set_pmd(pmd_t *pmdp, pmd_t pmd)
14520 {
14521 + pax_open_kernel();
14522 *pmdp = pmd;
14523 + pax_close_kernel();
14524 }
14525
14526 static inline void native_pmd_clear(pmd_t *pmd)
14527 @@ -97,7 +103,9 @@ static inline pmd_t native_pmdp_get_and_clear(pmd_t *xp)
14528
14529 static inline void native_set_pud(pud_t *pudp, pud_t pud)
14530 {
14531 + pax_open_kernel();
14532 *pudp = pud;
14533 + pax_close_kernel();
14534 }
14535
14536 static inline void native_pud_clear(pud_t *pud)
14537 @@ -107,6 +115,13 @@ static inline void native_pud_clear(pud_t *pud)
14538
14539 static inline void native_set_pgd(pgd_t *pgdp, pgd_t pgd)
14540 {
14541 + pax_open_kernel();
14542 + *pgdp = pgd;
14543 + pax_close_kernel();
14544 +}
14545 +
14546 +static inline void native_set_pgd_batched(pgd_t *pgdp, pgd_t pgd)
14547 +{
14548 *pgdp = pgd;
14549 }
14550
14551 diff --git a/arch/x86/include/asm/pgtable_64_types.h b/arch/x86/include/asm/pgtable_64_types.h
14552 index 766ea16..5b96cb3 100644
14553 --- a/arch/x86/include/asm/pgtable_64_types.h
14554 +++ b/arch/x86/include/asm/pgtable_64_types.h
14555 @@ -59,5 +59,10 @@ typedef struct { pteval_t pte; } pte_t;
14556 #define MODULES_VADDR _AC(0xffffffffa0000000, UL)
14557 #define MODULES_END _AC(0xffffffffff000000, UL)
14558 #define MODULES_LEN (MODULES_END - MODULES_VADDR)
14559 +#define MODULES_EXEC_VADDR MODULES_VADDR
14560 +#define MODULES_EXEC_END MODULES_END
14561 +
14562 +#define ktla_ktva(addr) (addr)
14563 +#define ktva_ktla(addr) (addr)
14564
14565 #endif /* _ASM_X86_PGTABLE_64_DEFS_H */
14566 diff --git a/arch/x86/include/asm/pgtable_types.h b/arch/x86/include/asm/pgtable_types.h
14567 index 3c32db8..1ddccf5 100644
14568 --- a/arch/x86/include/asm/pgtable_types.h
14569 +++ b/arch/x86/include/asm/pgtable_types.h
14570 @@ -16,13 +16,12 @@
14571 #define _PAGE_BIT_PSE 7 /* 4 MB (or 2MB) page */
14572 #define _PAGE_BIT_PAT 7 /* on 4KB pages */
14573 #define _PAGE_BIT_GLOBAL 8 /* Global TLB entry PPro+ */
14574 -#define _PAGE_BIT_UNUSED1 9 /* available for programmer */
14575 +#define _PAGE_BIT_SPECIAL 9 /* special mappings, no associated struct page */
14576 #define _PAGE_BIT_IOMAP 10 /* flag used to indicate IO mapping */
14577 #define _PAGE_BIT_HIDDEN 11 /* hidden by kmemcheck */
14578 #define _PAGE_BIT_PAT_LARGE 12 /* On 2MB or 1GB pages */
14579 -#define _PAGE_BIT_SPECIAL _PAGE_BIT_UNUSED1
14580 -#define _PAGE_BIT_CPA_TEST _PAGE_BIT_UNUSED1
14581 -#define _PAGE_BIT_SPLITTING _PAGE_BIT_UNUSED1 /* only valid on a PSE pmd */
14582 +#define _PAGE_BIT_CPA_TEST _PAGE_BIT_SPECIAL
14583 +#define _PAGE_BIT_SPLITTING _PAGE_BIT_SPECIAL /* only valid on a PSE pmd */
14584 #define _PAGE_BIT_NX 63 /* No execute: only valid after cpuid check */
14585
14586 /* If _PAGE_BIT_PRESENT is clear, we use these: */
14587 @@ -40,7 +39,6 @@
14588 #define _PAGE_DIRTY (_AT(pteval_t, 1) << _PAGE_BIT_DIRTY)
14589 #define _PAGE_PSE (_AT(pteval_t, 1) << _PAGE_BIT_PSE)
14590 #define _PAGE_GLOBAL (_AT(pteval_t, 1) << _PAGE_BIT_GLOBAL)
14591 -#define _PAGE_UNUSED1 (_AT(pteval_t, 1) << _PAGE_BIT_UNUSED1)
14592 #define _PAGE_IOMAP (_AT(pteval_t, 1) << _PAGE_BIT_IOMAP)
14593 #define _PAGE_PAT (_AT(pteval_t, 1) << _PAGE_BIT_PAT)
14594 #define _PAGE_PAT_LARGE (_AT(pteval_t, 1) << _PAGE_BIT_PAT_LARGE)
14595 @@ -57,8 +55,10 @@
14596
14597 #if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
14598 #define _PAGE_NX (_AT(pteval_t, 1) << _PAGE_BIT_NX)
14599 -#else
14600 +#elif defined(CONFIG_KMEMCHECK)
14601 #define _PAGE_NX (_AT(pteval_t, 0))
14602 +#else
14603 +#define _PAGE_NX (_AT(pteval_t, 1) << _PAGE_BIT_HIDDEN)
14604 #endif
14605
14606 #define _PAGE_FILE (_AT(pteval_t, 1) << _PAGE_BIT_FILE)
14607 @@ -116,6 +116,9 @@
14608 #define PAGE_READONLY_EXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | \
14609 _PAGE_ACCESSED)
14610
14611 +#define PAGE_READONLY_NOEXEC PAGE_READONLY
14612 +#define PAGE_SHARED_NOEXEC PAGE_SHARED
14613 +
14614 #define __PAGE_KERNEL_EXEC \
14615 (_PAGE_PRESENT | _PAGE_RW | _PAGE_DIRTY | _PAGE_ACCESSED | _PAGE_GLOBAL)
14616 #define __PAGE_KERNEL (__PAGE_KERNEL_EXEC | _PAGE_NX)
14617 @@ -126,7 +129,7 @@
14618 #define __PAGE_KERNEL_WC (__PAGE_KERNEL | _PAGE_CACHE_WC)
14619 #define __PAGE_KERNEL_NOCACHE (__PAGE_KERNEL | _PAGE_PCD | _PAGE_PWT)
14620 #define __PAGE_KERNEL_UC_MINUS (__PAGE_KERNEL | _PAGE_PCD)
14621 -#define __PAGE_KERNEL_VSYSCALL (__PAGE_KERNEL_RX | _PAGE_USER)
14622 +#define __PAGE_KERNEL_VSYSCALL (__PAGE_KERNEL_RO | _PAGE_USER)
14623 #define __PAGE_KERNEL_VVAR (__PAGE_KERNEL_RO | _PAGE_USER)
14624 #define __PAGE_KERNEL_VVAR_NOCACHE (__PAGE_KERNEL_VVAR | _PAGE_PCD | _PAGE_PWT)
14625 #define __PAGE_KERNEL_LARGE (__PAGE_KERNEL | _PAGE_PSE)
14626 @@ -188,8 +191,8 @@
14627 * bits are combined, this will alow user to access the high address mapped
14628 * VDSO in the presence of CONFIG_COMPAT_VDSO
14629 */
14630 -#define PTE_IDENT_ATTR 0x003 /* PRESENT+RW */
14631 -#define PDE_IDENT_ATTR 0x067 /* PRESENT+RW+USER+DIRTY+ACCESSED */
14632 +#define PTE_IDENT_ATTR 0x063 /* PRESENT+RW+DIRTY+ACCESSED */
14633 +#define PDE_IDENT_ATTR 0x063 /* PRESENT+RW+DIRTY+ACCESSED */
14634 #define PGD_IDENT_ATTR 0x001 /* PRESENT (no other attributes) */
14635 #endif
14636
14637 @@ -227,7 +230,17 @@ static inline pgdval_t pgd_flags(pgd_t pgd)
14638 {
14639 return native_pgd_val(pgd) & PTE_FLAGS_MASK;
14640 }
14641 +#endif
14642
14643 +#if PAGETABLE_LEVELS == 3
14644 +#include <asm-generic/pgtable-nopud.h>
14645 +#endif
14646 +
14647 +#if PAGETABLE_LEVELS == 2
14648 +#include <asm-generic/pgtable-nopmd.h>
14649 +#endif
14650 +
14651 +#ifndef __ASSEMBLY__
14652 #if PAGETABLE_LEVELS > 3
14653 typedef struct { pudval_t pud; } pud_t;
14654
14655 @@ -241,8 +254,6 @@ static inline pudval_t native_pud_val(pud_t pud)
14656 return pud.pud;
14657 }
14658 #else
14659 -#include <asm-generic/pgtable-nopud.h>
14660 -
14661 static inline pudval_t native_pud_val(pud_t pud)
14662 {
14663 return native_pgd_val(pud.pgd);
14664 @@ -262,8 +273,6 @@ static inline pmdval_t native_pmd_val(pmd_t pmd)
14665 return pmd.pmd;
14666 }
14667 #else
14668 -#include <asm-generic/pgtable-nopmd.h>
14669 -
14670 static inline pmdval_t native_pmd_val(pmd_t pmd)
14671 {
14672 return native_pgd_val(pmd.pud.pgd);
14673 @@ -303,7 +312,6 @@ typedef struct page *pgtable_t;
14674
14675 extern pteval_t __supported_pte_mask;
14676 extern void set_nx(void);
14677 -extern int nx_enabled;
14678
14679 #define pgprot_writecombine pgprot_writecombine
14680 extern pgprot_t pgprot_writecombine(pgprot_t prot);
14681 diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h
14682 index 888184b..a07ac89 100644
14683 --- a/arch/x86/include/asm/processor.h
14684 +++ b/arch/x86/include/asm/processor.h
14685 @@ -287,7 +287,7 @@ struct tss_struct {
14686
14687 } ____cacheline_aligned;
14688
14689 -DECLARE_PER_CPU_SHARED_ALIGNED(struct tss_struct, init_tss);
14690 +extern struct tss_struct init_tss[NR_CPUS];
14691
14692 /*
14693 * Save the original ist values for checking stack pointers during debugging
14694 @@ -827,11 +827,18 @@ static inline void spin_lock_prefetch(const void *x)
14695 */
14696 #define TASK_SIZE PAGE_OFFSET
14697 #define TASK_SIZE_MAX TASK_SIZE
14698 +
14699 +#ifdef CONFIG_PAX_SEGMEXEC
14700 +#define SEGMEXEC_TASK_SIZE (TASK_SIZE / 2)
14701 +#define STACK_TOP ((current->mm->pax_flags & MF_PAX_SEGMEXEC)?SEGMEXEC_TASK_SIZE:TASK_SIZE)
14702 +#else
14703 #define STACK_TOP TASK_SIZE
14704 -#define STACK_TOP_MAX STACK_TOP
14705 +#endif
14706 +
14707 +#define STACK_TOP_MAX TASK_SIZE
14708
14709 #define INIT_THREAD { \
14710 - .sp0 = sizeof(init_stack) + (long)&init_stack, \
14711 + .sp0 = sizeof(init_stack) + (long)&init_stack - 8, \
14712 .vm86_info = NULL, \
14713 .sysenter_cs = __KERNEL_CS, \
14714 .io_bitmap_ptr = NULL, \
14715 @@ -845,7 +852,7 @@ static inline void spin_lock_prefetch(const void *x)
14716 */
14717 #define INIT_TSS { \
14718 .x86_tss = { \
14719 - .sp0 = sizeof(init_stack) + (long)&init_stack, \
14720 + .sp0 = sizeof(init_stack) + (long)&init_stack - 8, \
14721 .ss0 = __KERNEL_DS, \
14722 .ss1 = __KERNEL_CS, \
14723 .io_bitmap_base = INVALID_IO_BITMAP_OFFSET, \
14724 @@ -856,11 +863,7 @@ static inline void spin_lock_prefetch(const void *x)
14725 extern unsigned long thread_saved_pc(struct task_struct *tsk);
14726
14727 #define THREAD_SIZE_LONGS (THREAD_SIZE/sizeof(unsigned long))
14728 -#define KSTK_TOP(info) \
14729 -({ \
14730 - unsigned long *__ptr = (unsigned long *)(info); \
14731 - (unsigned long)(&__ptr[THREAD_SIZE_LONGS]); \
14732 -})
14733 +#define KSTK_TOP(info) ((container_of(info, struct task_struct, tinfo))->thread.sp0)
14734
14735 /*
14736 * The below -8 is to reserve 8 bytes on top of the ring0 stack.
14737 @@ -875,7 +878,7 @@ extern unsigned long thread_saved_pc(struct task_struct *tsk);
14738 #define task_pt_regs(task) \
14739 ({ \
14740 struct pt_regs *__regs__; \
14741 - __regs__ = (struct pt_regs *)(KSTK_TOP(task_stack_page(task))-8); \
14742 + __regs__ = (struct pt_regs *)((task)->thread.sp0); \
14743 __regs__ - 1; \
14744 })
14745
14746 @@ -885,13 +888,13 @@ extern unsigned long thread_saved_pc(struct task_struct *tsk);
14747 /*
14748 * User space process size. 47bits minus one guard page.
14749 */
14750 -#define TASK_SIZE_MAX ((1UL << 47) - PAGE_SIZE)
14751 +#define TASK_SIZE_MAX ((1UL << TASK_SIZE_MAX_SHIFT) - PAGE_SIZE)
14752
14753 /* This decides where the kernel will search for a free chunk of vm
14754 * space during mmap's.
14755 */
14756 #define IA32_PAGE_OFFSET ((current->personality & ADDR_LIMIT_3GB) ? \
14757 - 0xc0000000 : 0xFFFFe000)
14758 + 0xc0000000 : 0xFFFFf000)
14759
14760 #define TASK_SIZE (test_thread_flag(TIF_ADDR32) ? \
14761 IA32_PAGE_OFFSET : TASK_SIZE_MAX)
14762 @@ -902,11 +905,11 @@ extern unsigned long thread_saved_pc(struct task_struct *tsk);
14763 #define STACK_TOP_MAX TASK_SIZE_MAX
14764
14765 #define INIT_THREAD { \
14766 - .sp0 = (unsigned long)&init_stack + sizeof(init_stack) \
14767 + .sp0 = (unsigned long)&init_stack + sizeof(init_stack) - 16 \
14768 }
14769
14770 #define INIT_TSS { \
14771 - .x86_tss.sp0 = (unsigned long)&init_stack + sizeof(init_stack) \
14772 + .x86_tss.sp0 = (unsigned long)&init_stack + sizeof(init_stack) - 16 \
14773 }
14774
14775 /*
14776 @@ -934,6 +937,10 @@ extern void start_thread(struct pt_regs *regs, unsigned long new_ip,
14777 */
14778 #define TASK_UNMAPPED_BASE (PAGE_ALIGN(TASK_SIZE / 3))
14779
14780 +#ifdef CONFIG_PAX_SEGMEXEC
14781 +#define SEGMEXEC_TASK_UNMAPPED_BASE (PAGE_ALIGN(SEGMEXEC_TASK_SIZE / 3))
14782 +#endif
14783 +
14784 #define KSTK_EIP(task) (task_pt_regs(task)->ip)
14785
14786 /* Get/set a process' ability to use the timestamp counter instruction */
14787 @@ -994,12 +1001,12 @@ extern bool cpu_has_amd_erratum(const int *);
14788 #define cpu_has_amd_erratum(x) (false)
14789 #endif /* CONFIG_CPU_SUP_AMD */
14790
14791 -extern unsigned long arch_align_stack(unsigned long sp);
14792 +#define arch_align_stack(x) ((x) & ~0xfUL)
14793 extern void free_init_pages(char *what, unsigned long begin, unsigned long end);
14794
14795 void default_idle(void);
14796 bool set_pm_idle_to_default(void);
14797
14798 -void stop_this_cpu(void *dummy);
14799 +void stop_this_cpu(void *dummy) __noreturn;
14800
14801 #endif /* _ASM_X86_PROCESSOR_H */
14802 diff --git a/arch/x86/include/asm/ptrace.h b/arch/x86/include/asm/ptrace.h
14803 index 942a086..6c26446 100644
14804 --- a/arch/x86/include/asm/ptrace.h
14805 +++ b/arch/x86/include/asm/ptrace.h
14806 @@ -85,28 +85,29 @@ static inline unsigned long regs_return_value(struct pt_regs *regs)
14807 }
14808
14809 /*
14810 - * user_mode_vm(regs) determines whether a register set came from user mode.
14811 + * user_mode(regs) determines whether a register set came from user mode.
14812 * This is true if V8086 mode was enabled OR if the register set was from
14813 * protected mode with RPL-3 CS value. This tricky test checks that with
14814 * one comparison. Many places in the kernel can bypass this full check
14815 - * if they have already ruled out V8086 mode, so user_mode(regs) can be used.
14816 + * if they have already ruled out V8086 mode, so user_mode_novm(regs) can
14817 + * be used.
14818 */
14819 -static inline int user_mode(struct pt_regs *regs)
14820 +static inline int user_mode_novm(struct pt_regs *regs)
14821 {
14822 #ifdef CONFIG_X86_32
14823 return (regs->cs & SEGMENT_RPL_MASK) == USER_RPL;
14824 #else
14825 - return !!(regs->cs & 3);
14826 + return !!(regs->cs & SEGMENT_RPL_MASK);
14827 #endif
14828 }
14829
14830 -static inline int user_mode_vm(struct pt_regs *regs)
14831 +static inline int user_mode(struct pt_regs *regs)
14832 {
14833 #ifdef CONFIG_X86_32
14834 return ((regs->cs & SEGMENT_RPL_MASK) | (regs->flags & X86_VM_MASK)) >=
14835 USER_RPL;
14836 #else
14837 - return user_mode(regs);
14838 + return user_mode_novm(regs);
14839 #endif
14840 }
14841
14842 @@ -122,15 +123,16 @@ static inline int v8086_mode(struct pt_regs *regs)
14843 #ifdef CONFIG_X86_64
14844 static inline bool user_64bit_mode(struct pt_regs *regs)
14845 {
14846 + unsigned long cs = regs->cs & 0xffff;
14847 #ifndef CONFIG_PARAVIRT
14848 /*
14849 * On non-paravirt systems, this is the only long mode CPL 3
14850 * selector. We do not allow long mode selectors in the LDT.
14851 */
14852 - return regs->cs == __USER_CS;
14853 + return cs == __USER_CS;
14854 #else
14855 /* Headers are too twisted for this to go in paravirt.h. */
14856 - return regs->cs == __USER_CS || regs->cs == pv_info.extra_user_64bit_cs;
14857 + return cs == __USER_CS || cs == pv_info.extra_user_64bit_cs;
14858 #endif
14859 }
14860
14861 @@ -181,9 +183,11 @@ static inline unsigned long regs_get_register(struct pt_regs *regs,
14862 * Traps from the kernel do not save sp and ss.
14863 * Use the helper function to retrieve sp.
14864 */
14865 - if (offset == offsetof(struct pt_regs, sp) &&
14866 - regs->cs == __KERNEL_CS)
14867 - return kernel_stack_pointer(regs);
14868 + if (offset == offsetof(struct pt_regs, sp)) {
14869 + unsigned long cs = regs->cs & 0xffff;
14870 + if (cs == __KERNEL_CS || cs == __KERNEXEC_KERNEL_CS)
14871 + return kernel_stack_pointer(regs);
14872 + }
14873 #endif
14874 return *(unsigned long *)((unsigned long)regs + offset);
14875 }
14876 diff --git a/arch/x86/include/asm/realmode.h b/arch/x86/include/asm/realmode.h
14877 index fe1ec5b..dc5c3fe 100644
14878 --- a/arch/x86/include/asm/realmode.h
14879 +++ b/arch/x86/include/asm/realmode.h
14880 @@ -22,16 +22,14 @@ struct real_mode_header {
14881 #endif
14882 /* APM/BIOS reboot */
14883 u32 machine_real_restart_asm;
14884 -#ifdef CONFIG_X86_64
14885 u32 machine_real_restart_seg;
14886 -#endif
14887 };
14888
14889 /* This must match data at trampoline_32/64.S */
14890 struct trampoline_header {
14891 #ifdef CONFIG_X86_32
14892 u32 start;
14893 - u16 gdt_pad;
14894 + u16 boot_cs;
14895 u16 gdt_limit;
14896 u32 gdt_base;
14897 #else
14898 diff --git a/arch/x86/include/asm/reboot.h b/arch/x86/include/asm/reboot.h
14899 index a82c4f1..ac45053 100644
14900 --- a/arch/x86/include/asm/reboot.h
14901 +++ b/arch/x86/include/asm/reboot.h
14902 @@ -6,13 +6,13 @@
14903 struct pt_regs;
14904
14905 struct machine_ops {
14906 - void (*restart)(char *cmd);
14907 - void (*halt)(void);
14908 - void (*power_off)(void);
14909 + void (* __noreturn restart)(char *cmd);
14910 + void (* __noreturn halt)(void);
14911 + void (* __noreturn power_off)(void);
14912 void (*shutdown)(void);
14913 void (*crash_shutdown)(struct pt_regs *);
14914 - void (*emergency_restart)(void);
14915 -};
14916 + void (* __noreturn emergency_restart)(void);
14917 +} __no_const;
14918
14919 extern struct machine_ops machine_ops;
14920
14921 diff --git a/arch/x86/include/asm/rwsem.h b/arch/x86/include/asm/rwsem.h
14922 index 2dbe4a7..ce1db00 100644
14923 --- a/arch/x86/include/asm/rwsem.h
14924 +++ b/arch/x86/include/asm/rwsem.h
14925 @@ -64,6 +64,14 @@ static inline void __down_read(struct rw_semaphore *sem)
14926 {
14927 asm volatile("# beginning down_read\n\t"
14928 LOCK_PREFIX _ASM_INC "(%1)\n\t"
14929 +
14930 +#ifdef CONFIG_PAX_REFCOUNT
14931 + "jno 0f\n"
14932 + LOCK_PREFIX _ASM_DEC "(%1)\n"
14933 + "int $4\n0:\n"
14934 + _ASM_EXTABLE(0b, 0b)
14935 +#endif
14936 +
14937 /* adds 0x00000001 */
14938 " jns 1f\n"
14939 " call call_rwsem_down_read_failed\n"
14940 @@ -85,6 +93,14 @@ static inline int __down_read_trylock(struct rw_semaphore *sem)
14941 "1:\n\t"
14942 " mov %1,%2\n\t"
14943 " add %3,%2\n\t"
14944 +
14945 +#ifdef CONFIG_PAX_REFCOUNT
14946 + "jno 0f\n"
14947 + "sub %3,%2\n"
14948 + "int $4\n0:\n"
14949 + _ASM_EXTABLE(0b, 0b)
14950 +#endif
14951 +
14952 " jle 2f\n\t"
14953 LOCK_PREFIX " cmpxchg %2,%0\n\t"
14954 " jnz 1b\n\t"
14955 @@ -104,6 +120,14 @@ static inline void __down_write_nested(struct rw_semaphore *sem, int subclass)
14956 long tmp;
14957 asm volatile("# beginning down_write\n\t"
14958 LOCK_PREFIX " xadd %1,(%2)\n\t"
14959 +
14960 +#ifdef CONFIG_PAX_REFCOUNT
14961 + "jno 0f\n"
14962 + "mov %1,(%2)\n"
14963 + "int $4\n0:\n"
14964 + _ASM_EXTABLE(0b, 0b)
14965 +#endif
14966 +
14967 /* adds 0xffff0001, returns the old value */
14968 " test %1,%1\n\t"
14969 /* was the count 0 before? */
14970 @@ -141,6 +165,14 @@ static inline void __up_read(struct rw_semaphore *sem)
14971 long tmp;
14972 asm volatile("# beginning __up_read\n\t"
14973 LOCK_PREFIX " xadd %1,(%2)\n\t"
14974 +
14975 +#ifdef CONFIG_PAX_REFCOUNT
14976 + "jno 0f\n"
14977 + "mov %1,(%2)\n"
14978 + "int $4\n0:\n"
14979 + _ASM_EXTABLE(0b, 0b)
14980 +#endif
14981 +
14982 /* subtracts 1, returns the old value */
14983 " jns 1f\n\t"
14984 " call call_rwsem_wake\n" /* expects old value in %edx */
14985 @@ -159,6 +191,14 @@ static inline void __up_write(struct rw_semaphore *sem)
14986 long tmp;
14987 asm volatile("# beginning __up_write\n\t"
14988 LOCK_PREFIX " xadd %1,(%2)\n\t"
14989 +
14990 +#ifdef CONFIG_PAX_REFCOUNT
14991 + "jno 0f\n"
14992 + "mov %1,(%2)\n"
14993 + "int $4\n0:\n"
14994 + _ASM_EXTABLE(0b, 0b)
14995 +#endif
14996 +
14997 /* subtracts 0xffff0001, returns the old value */
14998 " jns 1f\n\t"
14999 " call call_rwsem_wake\n" /* expects old value in %edx */
15000 @@ -176,6 +216,14 @@ static inline void __downgrade_write(struct rw_semaphore *sem)
15001 {
15002 asm volatile("# beginning __downgrade_write\n\t"
15003 LOCK_PREFIX _ASM_ADD "%2,(%1)\n\t"
15004 +
15005 +#ifdef CONFIG_PAX_REFCOUNT
15006 + "jno 0f\n"
15007 + LOCK_PREFIX _ASM_SUB "%2,(%1)\n"
15008 + "int $4\n0:\n"
15009 + _ASM_EXTABLE(0b, 0b)
15010 +#endif
15011 +
15012 /*
15013 * transitions 0xZZZZ0001 -> 0xYYYY0001 (i386)
15014 * 0xZZZZZZZZ00000001 -> 0xYYYYYYYY00000001 (x86_64)
15015 @@ -194,7 +242,15 @@ static inline void __downgrade_write(struct rw_semaphore *sem)
15016 */
15017 static inline void rwsem_atomic_add(long delta, struct rw_semaphore *sem)
15018 {
15019 - asm volatile(LOCK_PREFIX _ASM_ADD "%1,%0"
15020 + asm volatile(LOCK_PREFIX _ASM_ADD "%1,%0\n"
15021 +
15022 +#ifdef CONFIG_PAX_REFCOUNT
15023 + "jno 0f\n"
15024 + LOCK_PREFIX _ASM_SUB "%1,%0\n"
15025 + "int $4\n0:\n"
15026 + _ASM_EXTABLE(0b, 0b)
15027 +#endif
15028 +
15029 : "+m" (sem->count)
15030 : "er" (delta));
15031 }
15032 @@ -204,7 +260,7 @@ static inline void rwsem_atomic_add(long delta, struct rw_semaphore *sem)
15033 */
15034 static inline long rwsem_atomic_update(long delta, struct rw_semaphore *sem)
15035 {
15036 - return delta + xadd(&sem->count, delta);
15037 + return delta + xadd_check_overflow(&sem->count, delta);
15038 }
15039
15040 #endif /* __KERNEL__ */
15041 diff --git a/arch/x86/include/asm/segment.h b/arch/x86/include/asm/segment.h
15042 index c48a950..c6d7468 100644
15043 --- a/arch/x86/include/asm/segment.h
15044 +++ b/arch/x86/include/asm/segment.h
15045 @@ -64,10 +64,15 @@
15046 * 26 - ESPFIX small SS
15047 * 27 - per-cpu [ offset to per-cpu data area ]
15048 * 28 - stack_canary-20 [ for stack protector ]
15049 - * 29 - unused
15050 - * 30 - unused
15051 + * 29 - PCI BIOS CS
15052 + * 30 - PCI BIOS DS
15053 * 31 - TSS for double fault handler
15054 */
15055 +#define GDT_ENTRY_KERNEXEC_EFI_CS (1)
15056 +#define GDT_ENTRY_KERNEXEC_EFI_DS (2)
15057 +#define __KERNEXEC_EFI_CS (GDT_ENTRY_KERNEXEC_EFI_CS*8)
15058 +#define __KERNEXEC_EFI_DS (GDT_ENTRY_KERNEXEC_EFI_DS*8)
15059 +
15060 #define GDT_ENTRY_TLS_MIN 6
15061 #define GDT_ENTRY_TLS_MAX (GDT_ENTRY_TLS_MIN + GDT_ENTRY_TLS_ENTRIES - 1)
15062
15063 @@ -79,6 +84,8 @@
15064
15065 #define GDT_ENTRY_KERNEL_CS (GDT_ENTRY_KERNEL_BASE+0)
15066
15067 +#define GDT_ENTRY_KERNEXEC_KERNEL_CS (4)
15068 +
15069 #define GDT_ENTRY_KERNEL_DS (GDT_ENTRY_KERNEL_BASE+1)
15070
15071 #define GDT_ENTRY_TSS (GDT_ENTRY_KERNEL_BASE+4)
15072 @@ -104,6 +111,12 @@
15073 #define __KERNEL_STACK_CANARY 0
15074 #endif
15075
15076 +#define GDT_ENTRY_PCIBIOS_CS (GDT_ENTRY_KERNEL_BASE+17)
15077 +#define __PCIBIOS_CS (GDT_ENTRY_PCIBIOS_CS * 8)
15078 +
15079 +#define GDT_ENTRY_PCIBIOS_DS (GDT_ENTRY_KERNEL_BASE+18)
15080 +#define __PCIBIOS_DS (GDT_ENTRY_PCIBIOS_DS * 8)
15081 +
15082 #define GDT_ENTRY_DOUBLEFAULT_TSS 31
15083
15084 /*
15085 @@ -141,7 +154,7 @@
15086 */
15087
15088 /* Matches PNP_CS32 and PNP_CS16 (they must be consecutive) */
15089 -#define SEGMENT_IS_PNP_CODE(x) (((x) & 0xf4) == GDT_ENTRY_PNPBIOS_BASE * 8)
15090 +#define SEGMENT_IS_PNP_CODE(x) (((x) & 0xFFFCU) == PNP_CS32 || ((x) & 0xFFFCU) == PNP_CS16)
15091
15092
15093 #else
15094 @@ -165,6 +178,8 @@
15095 #define __USER32_CS (GDT_ENTRY_DEFAULT_USER32_CS*8+3)
15096 #define __USER32_DS __USER_DS
15097
15098 +#define GDT_ENTRY_KERNEXEC_KERNEL_CS 7
15099 +
15100 #define GDT_ENTRY_TSS 8 /* needs two entries */
15101 #define GDT_ENTRY_LDT 10 /* needs two entries */
15102 #define GDT_ENTRY_TLS_MIN 12
15103 @@ -185,6 +200,7 @@
15104 #endif
15105
15106 #define __KERNEL_CS (GDT_ENTRY_KERNEL_CS*8)
15107 +#define __KERNEXEC_KERNEL_CS (GDT_ENTRY_KERNEXEC_KERNEL_CS*8)
15108 #define __KERNEL_DS (GDT_ENTRY_KERNEL_DS*8)
15109 #define __USER_DS (GDT_ENTRY_DEFAULT_USER_DS*8+3)
15110 #define __USER_CS (GDT_ENTRY_DEFAULT_USER_CS*8+3)
15111 @@ -265,7 +281,7 @@ static inline unsigned long get_limit(unsigned long segment)
15112 {
15113 unsigned long __limit;
15114 asm("lsll %1,%0" : "=r" (__limit) : "r" (segment));
15115 - return __limit + 1;
15116 + return __limit;
15117 }
15118
15119 #endif /* !__ASSEMBLY__ */
15120 diff --git a/arch/x86/include/asm/smp.h b/arch/x86/include/asm/smp.h
15121 index b073aae..39f9bdd 100644
15122 --- a/arch/x86/include/asm/smp.h
15123 +++ b/arch/x86/include/asm/smp.h
15124 @@ -36,7 +36,7 @@ DECLARE_PER_CPU_READ_MOSTLY(cpumask_var_t, cpu_core_map);
15125 /* cpus sharing the last level cache: */
15126 DECLARE_PER_CPU_READ_MOSTLY(cpumask_var_t, cpu_llc_shared_map);
15127 DECLARE_PER_CPU_READ_MOSTLY(u16, cpu_llc_id);
15128 -DECLARE_PER_CPU_READ_MOSTLY(int, cpu_number);
15129 +DECLARE_PER_CPU_READ_MOSTLY(unsigned int, cpu_number);
15130
15131 static inline struct cpumask *cpu_sibling_mask(int cpu)
15132 {
15133 @@ -79,7 +79,7 @@ struct smp_ops {
15134
15135 void (*send_call_func_ipi)(const struct cpumask *mask);
15136 void (*send_call_func_single_ipi)(int cpu);
15137 -};
15138 +} __no_const;
15139
15140 /* Globals due to paravirt */
15141 extern void set_cpu_sibling_map(int cpu);
15142 @@ -191,14 +191,8 @@ extern unsigned disabled_cpus __cpuinitdata;
15143 extern int safe_smp_processor_id(void);
15144
15145 #elif defined(CONFIG_X86_64_SMP)
15146 -#define raw_smp_processor_id() (this_cpu_read(cpu_number))
15147 -
15148 -#define stack_smp_processor_id() \
15149 -({ \
15150 - struct thread_info *ti; \
15151 - __asm__("andq %%rsp,%0; ":"=r" (ti) : "0" (CURRENT_MASK)); \
15152 - ti->cpu; \
15153 -})
15154 +#define raw_smp_processor_id() (this_cpu_read(cpu_number))
15155 +#define stack_smp_processor_id() raw_smp_processor_id()
15156 #define safe_smp_processor_id() smp_processor_id()
15157
15158 #endif
15159 diff --git a/arch/x86/include/asm/spinlock.h b/arch/x86/include/asm/spinlock.h
15160 index 33692ea..350a534 100644
15161 --- a/arch/x86/include/asm/spinlock.h
15162 +++ b/arch/x86/include/asm/spinlock.h
15163 @@ -172,6 +172,14 @@ static inline int arch_write_can_lock(arch_rwlock_t *lock)
15164 static inline void arch_read_lock(arch_rwlock_t *rw)
15165 {
15166 asm volatile(LOCK_PREFIX READ_LOCK_SIZE(dec) " (%0)\n\t"
15167 +
15168 +#ifdef CONFIG_PAX_REFCOUNT
15169 + "jno 0f\n"
15170 + LOCK_PREFIX READ_LOCK_SIZE(inc) " (%0)\n"
15171 + "int $4\n0:\n"
15172 + _ASM_EXTABLE(0b, 0b)
15173 +#endif
15174 +
15175 "jns 1f\n"
15176 "call __read_lock_failed\n\t"
15177 "1:\n"
15178 @@ -181,6 +189,14 @@ static inline void arch_read_lock(arch_rwlock_t *rw)
15179 static inline void arch_write_lock(arch_rwlock_t *rw)
15180 {
15181 asm volatile(LOCK_PREFIX WRITE_LOCK_SUB(%1) "(%0)\n\t"
15182 +
15183 +#ifdef CONFIG_PAX_REFCOUNT
15184 + "jno 0f\n"
15185 + LOCK_PREFIX WRITE_LOCK_ADD(%1) "(%0)\n"
15186 + "int $4\n0:\n"
15187 + _ASM_EXTABLE(0b, 0b)
15188 +#endif
15189 +
15190 "jz 1f\n"
15191 "call __write_lock_failed\n\t"
15192 "1:\n"
15193 @@ -210,13 +226,29 @@ static inline int arch_write_trylock(arch_rwlock_t *lock)
15194
15195 static inline void arch_read_unlock(arch_rwlock_t *rw)
15196 {
15197 - asm volatile(LOCK_PREFIX READ_LOCK_SIZE(inc) " %0"
15198 + asm volatile(LOCK_PREFIX READ_LOCK_SIZE(inc) " %0\n"
15199 +
15200 +#ifdef CONFIG_PAX_REFCOUNT
15201 + "jno 0f\n"
15202 + LOCK_PREFIX READ_LOCK_SIZE(dec) " %0\n"
15203 + "int $4\n0:\n"
15204 + _ASM_EXTABLE(0b, 0b)
15205 +#endif
15206 +
15207 :"+m" (rw->lock) : : "memory");
15208 }
15209
15210 static inline void arch_write_unlock(arch_rwlock_t *rw)
15211 {
15212 - asm volatile(LOCK_PREFIX WRITE_LOCK_ADD(%1) "%0"
15213 + asm volatile(LOCK_PREFIX WRITE_LOCK_ADD(%1) "%0\n"
15214 +
15215 +#ifdef CONFIG_PAX_REFCOUNT
15216 + "jno 0f\n"
15217 + LOCK_PREFIX WRITE_LOCK_SUB(%1) "%0\n"
15218 + "int $4\n0:\n"
15219 + _ASM_EXTABLE(0b, 0b)
15220 +#endif
15221 +
15222 : "+m" (rw->write) : "i" (RW_LOCK_BIAS) : "memory");
15223 }
15224
15225 diff --git a/arch/x86/include/asm/stackprotector.h b/arch/x86/include/asm/stackprotector.h
15226 index 6a99859..03cb807 100644
15227 --- a/arch/x86/include/asm/stackprotector.h
15228 +++ b/arch/x86/include/asm/stackprotector.h
15229 @@ -47,7 +47,7 @@
15230 * head_32 for boot CPU and setup_per_cpu_areas() for others.
15231 */
15232 #define GDT_STACK_CANARY_INIT \
15233 - [GDT_ENTRY_STACK_CANARY] = GDT_ENTRY_INIT(0x4090, 0, 0x18),
15234 + [GDT_ENTRY_STACK_CANARY] = GDT_ENTRY_INIT(0x4090, 0, 0x17),
15235
15236 /*
15237 * Initialize the stackprotector canary value.
15238 @@ -112,7 +112,7 @@ static inline void setup_stack_canary_segment(int cpu)
15239
15240 static inline void load_stack_canary_segment(void)
15241 {
15242 -#ifdef CONFIG_X86_32
15243 +#if defined(CONFIG_X86_32) && !defined(CONFIG_PAX_MEMORY_UDEREF)
15244 asm volatile ("mov %0, %%gs" : : "r" (0));
15245 #endif
15246 }
15247 diff --git a/arch/x86/include/asm/stacktrace.h b/arch/x86/include/asm/stacktrace.h
15248 index 70bbe39..4ae2bd4 100644
15249 --- a/arch/x86/include/asm/stacktrace.h
15250 +++ b/arch/x86/include/asm/stacktrace.h
15251 @@ -11,28 +11,20 @@
15252
15253 extern int kstack_depth_to_print;
15254
15255 -struct thread_info;
15256 +struct task_struct;
15257 struct stacktrace_ops;
15258
15259 -typedef unsigned long (*walk_stack_t)(struct thread_info *tinfo,
15260 - unsigned long *stack,
15261 - unsigned long bp,
15262 - const struct stacktrace_ops *ops,
15263 - void *data,
15264 - unsigned long *end,
15265 - int *graph);
15266 +typedef unsigned long walk_stack_t(struct task_struct *task,
15267 + void *stack_start,
15268 + unsigned long *stack,
15269 + unsigned long bp,
15270 + const struct stacktrace_ops *ops,
15271 + void *data,
15272 + unsigned long *end,
15273 + int *graph);
15274
15275 -extern unsigned long
15276 -print_context_stack(struct thread_info *tinfo,
15277 - unsigned long *stack, unsigned long bp,
15278 - const struct stacktrace_ops *ops, void *data,
15279 - unsigned long *end, int *graph);
15280 -
15281 -extern unsigned long
15282 -print_context_stack_bp(struct thread_info *tinfo,
15283 - unsigned long *stack, unsigned long bp,
15284 - const struct stacktrace_ops *ops, void *data,
15285 - unsigned long *end, int *graph);
15286 +extern walk_stack_t print_context_stack;
15287 +extern walk_stack_t print_context_stack_bp;
15288
15289 /* Generic stack tracer with callbacks */
15290
15291 @@ -40,7 +32,7 @@ struct stacktrace_ops {
15292 void (*address)(void *data, unsigned long address, int reliable);
15293 /* On negative return stop dumping */
15294 int (*stack)(void *data, char *name);
15295 - walk_stack_t walk_stack;
15296 + walk_stack_t *walk_stack;
15297 };
15298
15299 void dump_trace(struct task_struct *tsk, struct pt_regs *regs,
15300 diff --git a/arch/x86/include/asm/switch_to.h b/arch/x86/include/asm/switch_to.h
15301 index 4ec45b3..a4f0a8a 100644
15302 --- a/arch/x86/include/asm/switch_to.h
15303 +++ b/arch/x86/include/asm/switch_to.h
15304 @@ -108,7 +108,7 @@ do { \
15305 "call __switch_to\n\t" \
15306 "movq "__percpu_arg([current_task])",%%rsi\n\t" \
15307 __switch_canary \
15308 - "movq %P[thread_info](%%rsi),%%r8\n\t" \
15309 + "movq "__percpu_arg([thread_info])",%%r8\n\t" \
15310 "movq %%rax,%%rdi\n\t" \
15311 "testl %[_tif_fork],%P[ti_flags](%%r8)\n\t" \
15312 "jnz ret_from_fork\n\t" \
15313 @@ -119,7 +119,7 @@ do { \
15314 [threadrsp] "i" (offsetof(struct task_struct, thread.sp)), \
15315 [ti_flags] "i" (offsetof(struct thread_info, flags)), \
15316 [_tif_fork] "i" (_TIF_FORK), \
15317 - [thread_info] "i" (offsetof(struct task_struct, stack)), \
15318 + [thread_info] "m" (current_tinfo), \
15319 [current_task] "m" (current_task) \
15320 __switch_canary_iparam \
15321 : "memory", "cc" __EXTRA_CLOBBER)
15322 diff --git a/arch/x86/include/asm/thread_info.h b/arch/x86/include/asm/thread_info.h
15323 index 2d946e6..e453ec4 100644
15324 --- a/arch/x86/include/asm/thread_info.h
15325 +++ b/arch/x86/include/asm/thread_info.h
15326 @@ -10,6 +10,7 @@
15327 #include <linux/compiler.h>
15328 #include <asm/page.h>
15329 #include <asm/types.h>
15330 +#include <asm/percpu.h>
15331
15332 /*
15333 * low level task data that entry.S needs immediate access to
15334 @@ -24,7 +25,6 @@ struct exec_domain;
15335 #include <linux/atomic.h>
15336
15337 struct thread_info {
15338 - struct task_struct *task; /* main task structure */
15339 struct exec_domain *exec_domain; /* execution domain */
15340 __u32 flags; /* low level flags */
15341 __u32 status; /* thread synchronous flags */
15342 @@ -34,19 +34,13 @@ struct thread_info {
15343 mm_segment_t addr_limit;
15344 struct restart_block restart_block;
15345 void __user *sysenter_return;
15346 -#ifdef CONFIG_X86_32
15347 - unsigned long previous_esp; /* ESP of the previous stack in
15348 - case of nested (IRQ) stacks
15349 - */
15350 - __u8 supervisor_stack[0];
15351 -#endif
15352 + unsigned long lowest_stack;
15353 unsigned int sig_on_uaccess_error:1;
15354 unsigned int uaccess_err:1; /* uaccess failed */
15355 };
15356
15357 -#define INIT_THREAD_INFO(tsk) \
15358 +#define INIT_THREAD_INFO \
15359 { \
15360 - .task = &tsk, \
15361 .exec_domain = &default_exec_domain, \
15362 .flags = 0, \
15363 .cpu = 0, \
15364 @@ -57,7 +51,7 @@ struct thread_info {
15365 }, \
15366 }
15367
15368 -#define init_thread_info (init_thread_union.thread_info)
15369 +#define init_thread_info (init_thread_union.stack)
15370 #define init_stack (init_thread_union.stack)
15371
15372 #else /* !__ASSEMBLY__ */
15373 @@ -98,6 +92,7 @@ struct thread_info {
15374 #define TIF_SYSCALL_TRACEPOINT 28 /* syscall tracepoint instrumentation */
15375 #define TIF_ADDR32 29 /* 32-bit address space on 64 bits */
15376 #define TIF_X32 30 /* 32-bit native x86-64 binary */
15377 +#define TIF_GRSEC_SETXID 31 /* update credentials on syscall entry/exit */
15378
15379 #define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE)
15380 #define _TIF_NOTIFY_RESUME (1 << TIF_NOTIFY_RESUME)
15381 @@ -122,17 +117,18 @@ struct thread_info {
15382 #define _TIF_SYSCALL_TRACEPOINT (1 << TIF_SYSCALL_TRACEPOINT)
15383 #define _TIF_ADDR32 (1 << TIF_ADDR32)
15384 #define _TIF_X32 (1 << TIF_X32)
15385 +#define _TIF_GRSEC_SETXID (1 << TIF_GRSEC_SETXID)
15386
15387 /* work to do in syscall_trace_enter() */
15388 #define _TIF_WORK_SYSCALL_ENTRY \
15389 (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_EMU | _TIF_SYSCALL_AUDIT | \
15390 _TIF_SECCOMP | _TIF_SINGLESTEP | _TIF_SYSCALL_TRACEPOINT | \
15391 - _TIF_NOHZ)
15392 + _TIF_NOHZ | _TIF_GRSEC_SETXID)
15393
15394 /* work to do in syscall_trace_leave() */
15395 #define _TIF_WORK_SYSCALL_EXIT \
15396 (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | _TIF_SINGLESTEP | \
15397 - _TIF_SYSCALL_TRACEPOINT | _TIF_NOHZ)
15398 + _TIF_SYSCALL_TRACEPOINT | _TIF_NOHZ | _TIF_GRSEC_SETXID)
15399
15400 /* work to do on interrupt/exception return */
15401 #define _TIF_WORK_MASK \
15402 @@ -143,7 +139,7 @@ struct thread_info {
15403 /* work to do on any return to user space */
15404 #define _TIF_ALLWORK_MASK \
15405 ((0x0000FFFF & ~_TIF_SECCOMP) | _TIF_SYSCALL_TRACEPOINT | \
15406 - _TIF_NOHZ)
15407 + _TIF_NOHZ | _TIF_GRSEC_SETXID)
15408
15409 /* Only used for 64 bit */
15410 #define _TIF_DO_NOTIFY_MASK \
15411 @@ -159,45 +155,40 @@ struct thread_info {
15412
15413 #define PREEMPT_ACTIVE 0x10000000
15414
15415 -#ifdef CONFIG_X86_32
15416 -
15417 -#define STACK_WARN (THREAD_SIZE/8)
15418 -/*
15419 - * macros/functions for gaining access to the thread information structure
15420 - *
15421 - * preempt_count needs to be 1 initially, until the scheduler is functional.
15422 - */
15423 -#ifndef __ASSEMBLY__
15424 -
15425 -
15426 -/* how to get the current stack pointer from C */
15427 -register unsigned long current_stack_pointer asm("esp") __used;
15428 -
15429 -/* how to get the thread information struct from C */
15430 -static inline struct thread_info *current_thread_info(void)
15431 -{
15432 - return (struct thread_info *)
15433 - (current_stack_pointer & ~(THREAD_SIZE - 1));
15434 -}
15435 -
15436 -#else /* !__ASSEMBLY__ */
15437 -
15438 +#ifdef __ASSEMBLY__
15439 /* how to get the thread information struct from ASM */
15440 #define GET_THREAD_INFO(reg) \
15441 - movl $-THREAD_SIZE, reg; \
15442 - andl %esp, reg
15443 + mov PER_CPU_VAR(current_tinfo), reg
15444
15445 /* use this one if reg already contains %esp */
15446 -#define GET_THREAD_INFO_WITH_ESP(reg) \
15447 - andl $-THREAD_SIZE, reg
15448 +#define GET_THREAD_INFO_WITH_ESP(reg) GET_THREAD_INFO(reg)
15449 +#else
15450 +/* how to get the thread information struct from C */
15451 +DECLARE_PER_CPU(struct thread_info *, current_tinfo);
15452 +
15453 +static __always_inline struct thread_info *current_thread_info(void)
15454 +{
15455 + return this_cpu_read_stable(current_tinfo);
15456 +}
15457 +#endif
15458 +
15459 +#ifdef CONFIG_X86_32
15460 +
15461 +#define STACK_WARN (THREAD_SIZE/8)
15462 +/*
15463 + * macros/functions for gaining access to the thread information structure
15464 + *
15465 + * preempt_count needs to be 1 initially, until the scheduler is functional.
15466 + */
15467 +#ifndef __ASSEMBLY__
15468 +
15469 +/* how to get the current stack pointer from C */
15470 +register unsigned long current_stack_pointer asm("esp") __used;
15471
15472 #endif
15473
15474 #else /* X86_32 */
15475
15476 -#include <asm/percpu.h>
15477 -#define KERNEL_STACK_OFFSET (5*8)
15478 -
15479 /*
15480 * macros/functions for gaining access to the thread information structure
15481 * preempt_count needs to be 1 initially, until the scheduler is functional.
15482 @@ -205,27 +196,8 @@ static inline struct thread_info *current_thread_info(void)
15483 #ifndef __ASSEMBLY__
15484 DECLARE_PER_CPU(unsigned long, kernel_stack);
15485
15486 -static inline struct thread_info *current_thread_info(void)
15487 -{
15488 - struct thread_info *ti;
15489 - ti = (void *)(this_cpu_read_stable(kernel_stack) +
15490 - KERNEL_STACK_OFFSET - THREAD_SIZE);
15491 - return ti;
15492 -}
15493 -
15494 -#else /* !__ASSEMBLY__ */
15495 -
15496 -/* how to get the thread information struct from ASM */
15497 -#define GET_THREAD_INFO(reg) \
15498 - movq PER_CPU_VAR(kernel_stack),reg ; \
15499 - subq $(THREAD_SIZE-KERNEL_STACK_OFFSET),reg
15500 -
15501 -/*
15502 - * Same if PER_CPU_VAR(kernel_stack) is, perhaps with some offset, already in
15503 - * a certain register (to be used in assembler memory operands).
15504 - */
15505 -#define THREAD_INFO(reg, off) KERNEL_STACK_OFFSET+(off)-THREAD_SIZE(reg)
15506 -
15507 +/* how to get the current stack pointer from C */
15508 +register unsigned long current_stack_pointer asm("rsp") __used;
15509 #endif
15510
15511 #endif /* !X86_32 */
15512 @@ -286,5 +258,12 @@ static inline bool is_ia32_task(void)
15513 extern void arch_task_cache_init(void);
15514 extern int arch_dup_task_struct(struct task_struct *dst, struct task_struct *src);
15515 extern void arch_release_task_struct(struct task_struct *tsk);
15516 +
15517 +#define __HAVE_THREAD_FUNCTIONS
15518 +#define task_thread_info(task) (&(task)->tinfo)
15519 +#define task_stack_page(task) ((task)->stack)
15520 +#define setup_thread_stack(p, org) do {} while (0)
15521 +#define end_of_stack(p) ((unsigned long *)task_stack_page(p) + 1)
15522 +
15523 #endif
15524 #endif /* _ASM_X86_THREAD_INFO_H */
15525 diff --git a/arch/x86/include/asm/uaccess.h b/arch/x86/include/asm/uaccess.h
15526 index 1709801..0a60f2f 100644
15527 --- a/arch/x86/include/asm/uaccess.h
15528 +++ b/arch/x86/include/asm/uaccess.h
15529 @@ -7,6 +7,7 @@
15530 #include <linux/compiler.h>
15531 #include <linux/thread_info.h>
15532 #include <linux/string.h>
15533 +#include <linux/sched.h>
15534 #include <asm/asm.h>
15535 #include <asm/page.h>
15536 #include <asm/smap.h>
15537 @@ -29,7 +30,12 @@
15538
15539 #define get_ds() (KERNEL_DS)
15540 #define get_fs() (current_thread_info()->addr_limit)
15541 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
15542 +void __set_fs(mm_segment_t x);
15543 +void set_fs(mm_segment_t x);
15544 +#else
15545 #define set_fs(x) (current_thread_info()->addr_limit = (x))
15546 +#endif
15547
15548 #define segment_eq(a, b) ((a).seg == (b).seg)
15549
15550 @@ -77,8 +83,33 @@
15551 * checks that the pointer is in the user space range - after calling
15552 * this function, memory access functions may still return -EFAULT.
15553 */
15554 -#define access_ok(type, addr, size) \
15555 - (likely(__range_not_ok(addr, size, user_addr_max()) == 0))
15556 +#define __access_ok(type, addr, size) (likely(__range_not_ok(addr, size, user_addr_max()) == 0))
15557 +#define access_ok(type, addr, size) \
15558 +({ \
15559 + long __size = size; \
15560 + unsigned long __addr = (unsigned long)addr; \
15561 + unsigned long __addr_ao = __addr & PAGE_MASK; \
15562 + unsigned long __end_ao = __addr + __size - 1; \
15563 + bool __ret_ao = __range_not_ok(__addr, __size, user_addr_max()) == 0;\
15564 + if (__ret_ao && unlikely((__end_ao ^ __addr_ao) & PAGE_MASK)) { \
15565 + while(__addr_ao <= __end_ao) { \
15566 + char __c_ao; \
15567 + __addr_ao += PAGE_SIZE; \
15568 + if (__size > PAGE_SIZE) \
15569 + cond_resched(); \
15570 + if (__get_user(__c_ao, (char __user *)__addr)) \
15571 + break; \
15572 + if (type != VERIFY_WRITE) { \
15573 + __addr = __addr_ao; \
15574 + continue; \
15575 + } \
15576 + if (__put_user(__c_ao, (char __user *)__addr)) \
15577 + break; \
15578 + __addr = __addr_ao; \
15579 + } \
15580 + } \
15581 + __ret_ao; \
15582 +})
15583
15584 /*
15585 * The exception table consists of pairs of addresses relative to the
15586 @@ -189,13 +220,21 @@ extern int __get_user_bad(void);
15587 asm volatile("call __put_user_" #size : "=a" (__ret_pu) \
15588 : "0" ((typeof(*(ptr)))(x)), "c" (ptr) : "ebx")
15589
15590 -
15591 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
15592 +#define __copyuser_seg "gs;"
15593 +#define __COPYUSER_SET_ES "pushl %%gs; popl %%es\n"
15594 +#define __COPYUSER_RESTORE_ES "pushl %%ss; popl %%es\n"
15595 +#else
15596 +#define __copyuser_seg
15597 +#define __COPYUSER_SET_ES
15598 +#define __COPYUSER_RESTORE_ES
15599 +#endif
15600
15601 #ifdef CONFIG_X86_32
15602 #define __put_user_asm_u64(x, addr, err, errret) \
15603 asm volatile(ASM_STAC "\n" \
15604 - "1: movl %%eax,0(%2)\n" \
15605 - "2: movl %%edx,4(%2)\n" \
15606 + "1: "__copyuser_seg"movl %%eax,0(%2)\n" \
15607 + "2: "__copyuser_seg"movl %%edx,4(%2)\n" \
15608 "3: " ASM_CLAC "\n" \
15609 ".section .fixup,\"ax\"\n" \
15610 "4: movl %3,%0\n" \
15611 @@ -208,8 +247,8 @@ extern int __get_user_bad(void);
15612
15613 #define __put_user_asm_ex_u64(x, addr) \
15614 asm volatile(ASM_STAC "\n" \
15615 - "1: movl %%eax,0(%1)\n" \
15616 - "2: movl %%edx,4(%1)\n" \
15617 + "1: "__copyuser_seg"movl %%eax,0(%1)\n" \
15618 + "2: "__copyuser_seg"movl %%edx,4(%1)\n" \
15619 "3: " ASM_CLAC "\n" \
15620 _ASM_EXTABLE_EX(1b, 2b) \
15621 _ASM_EXTABLE_EX(2b, 3b) \
15622 @@ -259,7 +298,7 @@ extern void __put_user_8(void);
15623 __typeof__(*(ptr)) __pu_val; \
15624 __chk_user_ptr(ptr); \
15625 might_fault(); \
15626 - __pu_val = x; \
15627 + __pu_val = (x); \
15628 switch (sizeof(*(ptr))) { \
15629 case 1: \
15630 __put_user_x(1, __pu_val, ptr, __ret_pu); \
15631 @@ -358,7 +397,7 @@ do { \
15632
15633 #define __get_user_asm(x, addr, err, itype, rtype, ltype, errret) \
15634 asm volatile(ASM_STAC "\n" \
15635 - "1: mov"itype" %2,%"rtype"1\n" \
15636 + "1: "__copyuser_seg"mov"itype" %2,%"rtype"1\n"\
15637 "2: " ASM_CLAC "\n" \
15638 ".section .fixup,\"ax\"\n" \
15639 "3: mov %3,%0\n" \
15640 @@ -366,7 +405,7 @@ do { \
15641 " jmp 2b\n" \
15642 ".previous\n" \
15643 _ASM_EXTABLE(1b, 3b) \
15644 - : "=r" (err), ltype(x) \
15645 + : "=r" (err), ltype (x) \
15646 : "m" (__m(addr)), "i" (errret), "0" (err))
15647
15648 #define __get_user_size_ex(x, ptr, size) \
15649 @@ -391,7 +430,7 @@ do { \
15650 } while (0)
15651
15652 #define __get_user_asm_ex(x, addr, itype, rtype, ltype) \
15653 - asm volatile("1: mov"itype" %1,%"rtype"0\n" \
15654 + asm volatile("1: "__copyuser_seg"mov"itype" %1,%"rtype"0\n"\
15655 "2:\n" \
15656 _ASM_EXTABLE_EX(1b, 2b) \
15657 : ltype(x) : "m" (__m(addr)))
15658 @@ -408,13 +447,24 @@ do { \
15659 int __gu_err; \
15660 unsigned long __gu_val; \
15661 __get_user_size(__gu_val, (ptr), (size), __gu_err, -EFAULT); \
15662 - (x) = (__force __typeof__(*(ptr)))__gu_val; \
15663 + (x) = (__typeof__(*(ptr)))__gu_val; \
15664 __gu_err; \
15665 })
15666
15667 /* FIXME: this hack is definitely wrong -AK */
15668 struct __large_struct { unsigned long buf[100]; };
15669 -#define __m(x) (*(struct __large_struct __user *)(x))
15670 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
15671 +#define ____m(x) \
15672 +({ \
15673 + unsigned long ____x = (unsigned long)(x); \
15674 + if (____x < PAX_USER_SHADOW_BASE) \
15675 + ____x += PAX_USER_SHADOW_BASE; \
15676 + (void __user *)____x; \
15677 +})
15678 +#else
15679 +#define ____m(x) (x)
15680 +#endif
15681 +#define __m(x) (*(struct __large_struct __user *)____m(x))
15682
15683 /*
15684 * Tell gcc we read from memory instead of writing: this is because
15685 @@ -423,7 +473,7 @@ struct __large_struct { unsigned long buf[100]; };
15686 */
15687 #define __put_user_asm(x, addr, err, itype, rtype, ltype, errret) \
15688 asm volatile(ASM_STAC "\n" \
15689 - "1: mov"itype" %"rtype"1,%2\n" \
15690 + "1: "__copyuser_seg"mov"itype" %"rtype"1,%2\n"\
15691 "2: " ASM_CLAC "\n" \
15692 ".section .fixup,\"ax\"\n" \
15693 "3: mov %3,%0\n" \
15694 @@ -431,10 +481,10 @@ struct __large_struct { unsigned long buf[100]; };
15695 ".previous\n" \
15696 _ASM_EXTABLE(1b, 3b) \
15697 : "=r"(err) \
15698 - : ltype(x), "m" (__m(addr)), "i" (errret), "0" (err))
15699 + : ltype (x), "m" (__m(addr)), "i" (errret), "0" (err))
15700
15701 #define __put_user_asm_ex(x, addr, itype, rtype, ltype) \
15702 - asm volatile("1: mov"itype" %"rtype"0,%1\n" \
15703 + asm volatile("1: "__copyuser_seg"mov"itype" %"rtype"0,%1\n"\
15704 "2:\n" \
15705 _ASM_EXTABLE_EX(1b, 2b) \
15706 : : ltype(x), "m" (__m(addr)))
15707 @@ -473,8 +523,12 @@ struct __large_struct { unsigned long buf[100]; };
15708 * On error, the variable @x is set to zero.
15709 */
15710
15711 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
15712 +#define __get_user(x, ptr) get_user((x), (ptr))
15713 +#else
15714 #define __get_user(x, ptr) \
15715 __get_user_nocheck((x), (ptr), sizeof(*(ptr)))
15716 +#endif
15717
15718 /**
15719 * __put_user: - Write a simple value into user space, with less checking.
15720 @@ -496,8 +550,12 @@ struct __large_struct { unsigned long buf[100]; };
15721 * Returns zero on success, or -EFAULT on error.
15722 */
15723
15724 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
15725 +#define __put_user(x, ptr) put_user((x), (ptr))
15726 +#else
15727 #define __put_user(x, ptr) \
15728 __put_user_nocheck((__typeof__(*(ptr)))(x), (ptr), sizeof(*(ptr)))
15729 +#endif
15730
15731 #define __get_user_unaligned __get_user
15732 #define __put_user_unaligned __put_user
15733 @@ -515,7 +573,7 @@ struct __large_struct { unsigned long buf[100]; };
15734 #define get_user_ex(x, ptr) do { \
15735 unsigned long __gue_val; \
15736 __get_user_size_ex((__gue_val), (ptr), (sizeof(*(ptr)))); \
15737 - (x) = (__force __typeof__(*(ptr)))__gue_val; \
15738 + (x) = (__typeof__(*(ptr)))__gue_val; \
15739 } while (0)
15740
15741 #define put_user_try uaccess_try
15742 @@ -532,8 +590,8 @@ strncpy_from_user(char *dst, const char __user *src, long count);
15743 extern __must_check long strlen_user(const char __user *str);
15744 extern __must_check long strnlen_user(const char __user *str, long n);
15745
15746 -unsigned long __must_check clear_user(void __user *mem, unsigned long len);
15747 -unsigned long __must_check __clear_user(void __user *mem, unsigned long len);
15748 +unsigned long __must_check clear_user(void __user *mem, unsigned long len) __size_overflow(2);
15749 +unsigned long __must_check __clear_user(void __user *mem, unsigned long len) __size_overflow(2);
15750
15751 /*
15752 * movsl can be slow when source and dest are not both 8-byte aligned
15753 diff --git a/arch/x86/include/asm/uaccess_32.h b/arch/x86/include/asm/uaccess_32.h
15754 index 7f760a9..04b1c65 100644
15755 --- a/arch/x86/include/asm/uaccess_32.h
15756 +++ b/arch/x86/include/asm/uaccess_32.h
15757 @@ -11,15 +11,15 @@
15758 #include <asm/page.h>
15759
15760 unsigned long __must_check __copy_to_user_ll
15761 - (void __user *to, const void *from, unsigned long n);
15762 + (void __user *to, const void *from, unsigned long n) __size_overflow(3);
15763 unsigned long __must_check __copy_from_user_ll
15764 - (void *to, const void __user *from, unsigned long n);
15765 + (void *to, const void __user *from, unsigned long n) __size_overflow(3);
15766 unsigned long __must_check __copy_from_user_ll_nozero
15767 - (void *to, const void __user *from, unsigned long n);
15768 + (void *to, const void __user *from, unsigned long n) __size_overflow(3);
15769 unsigned long __must_check __copy_from_user_ll_nocache
15770 - (void *to, const void __user *from, unsigned long n);
15771 + (void *to, const void __user *from, unsigned long n) __size_overflow(3);
15772 unsigned long __must_check __copy_from_user_ll_nocache_nozero
15773 - (void *to, const void __user *from, unsigned long n);
15774 + (void *to, const void __user *from, unsigned long n) __size_overflow(3);
15775
15776 /**
15777 * __copy_to_user_inatomic: - Copy a block of data into user space, with less checking.
15778 @@ -43,6 +43,11 @@ unsigned long __must_check __copy_from_user_ll_nocache_nozero
15779 static __always_inline unsigned long __must_check
15780 __copy_to_user_inatomic(void __user *to, const void *from, unsigned long n)
15781 {
15782 + if ((long)n < 0)
15783 + return n;
15784 +
15785 + check_object_size(from, n, true);
15786 +
15787 if (__builtin_constant_p(n)) {
15788 unsigned long ret;
15789
15790 @@ -82,12 +87,16 @@ static __always_inline unsigned long __must_check
15791 __copy_to_user(void __user *to, const void *from, unsigned long n)
15792 {
15793 might_fault();
15794 +
15795 return __copy_to_user_inatomic(to, from, n);
15796 }
15797
15798 static __always_inline unsigned long
15799 __copy_from_user_inatomic(void *to, const void __user *from, unsigned long n)
15800 {
15801 + if ((long)n < 0)
15802 + return n;
15803 +
15804 /* Avoid zeroing the tail if the copy fails..
15805 * If 'n' is constant and 1, 2, or 4, we do still zero on a failure,
15806 * but as the zeroing behaviour is only significant when n is not
15807 @@ -137,6 +146,12 @@ static __always_inline unsigned long
15808 __copy_from_user(void *to, const void __user *from, unsigned long n)
15809 {
15810 might_fault();
15811 +
15812 + if ((long)n < 0)
15813 + return n;
15814 +
15815 + check_object_size(to, n, false);
15816 +
15817 if (__builtin_constant_p(n)) {
15818 unsigned long ret;
15819
15820 @@ -159,6 +174,10 @@ static __always_inline unsigned long __copy_from_user_nocache(void *to,
15821 const void __user *from, unsigned long n)
15822 {
15823 might_fault();
15824 +
15825 + if ((long)n < 0)
15826 + return n;
15827 +
15828 if (__builtin_constant_p(n)) {
15829 unsigned long ret;
15830
15831 @@ -181,15 +200,19 @@ static __always_inline unsigned long
15832 __copy_from_user_inatomic_nocache(void *to, const void __user *from,
15833 unsigned long n)
15834 {
15835 - return __copy_from_user_ll_nocache_nozero(to, from, n);
15836 + if ((long)n < 0)
15837 + return n;
15838 +
15839 + return __copy_from_user_ll_nocache_nozero(to, from, n);
15840 }
15841
15842 -unsigned long __must_check copy_to_user(void __user *to,
15843 - const void *from, unsigned long n);
15844 -unsigned long __must_check _copy_from_user(void *to,
15845 - const void __user *from,
15846 - unsigned long n);
15847 -
15848 +extern void copy_to_user_overflow(void)
15849 +#ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
15850 + __compiletime_error("copy_to_user() buffer size is not provably correct")
15851 +#else
15852 + __compiletime_warning("copy_to_user() buffer size is not provably correct")
15853 +#endif
15854 +;
15855
15856 extern void copy_from_user_overflow(void)
15857 #ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
15858 @@ -199,17 +222,60 @@ extern void copy_from_user_overflow(void)
15859 #endif
15860 ;
15861
15862 -static inline unsigned long __must_check copy_from_user(void *to,
15863 - const void __user *from,
15864 - unsigned long n)
15865 +/**
15866 + * copy_to_user: - Copy a block of data into user space.
15867 + * @to: Destination address, in user space.
15868 + * @from: Source address, in kernel space.
15869 + * @n: Number of bytes to copy.
15870 + *
15871 + * Context: User context only. This function may sleep.
15872 + *
15873 + * Copy data from kernel space to user space.
15874 + *
15875 + * Returns number of bytes that could not be copied.
15876 + * On success, this will be zero.
15877 + */
15878 +static inline unsigned long __must_check
15879 +copy_to_user(void __user *to, const void *from, unsigned long n)
15880 {
15881 - int sz = __compiletime_object_size(to);
15882 + size_t sz = __compiletime_object_size(from);
15883
15884 - if (likely(sz == -1 || sz >= n))
15885 - n = _copy_from_user(to, from, n);
15886 - else
15887 + if (unlikely(sz != (size_t)-1 && sz < n))
15888 + copy_to_user_overflow();
15889 + else if (access_ok(VERIFY_WRITE, to, n))
15890 + n = __copy_to_user(to, from, n);
15891 + return n;
15892 +}
15893 +
15894 +/**
15895 + * copy_from_user: - Copy a block of data from user space.
15896 + * @to: Destination address, in kernel space.
15897 + * @from: Source address, in user space.
15898 + * @n: Number of bytes to copy.
15899 + *
15900 + * Context: User context only. This function may sleep.
15901 + *
15902 + * Copy data from user space to kernel space.
15903 + *
15904 + * Returns number of bytes that could not be copied.
15905 + * On success, this will be zero.
15906 + *
15907 + * If some data could not be copied, this function will pad the copied
15908 + * data to the requested size using zero bytes.
15909 + */
15910 +static inline unsigned long __must_check
15911 +copy_from_user(void *to, const void __user *from, unsigned long n)
15912 +{
15913 + size_t sz = __compiletime_object_size(to);
15914 +
15915 + check_object_size(to, n, false);
15916 +
15917 + if (unlikely(sz != (size_t)-1 && sz < n))
15918 copy_from_user_overflow();
15919 -
15920 + else if (access_ok(VERIFY_READ, from, n))
15921 + n = __copy_from_user(to, from, n);
15922 + else if ((long)n > 0)
15923 + memset(to, 0, n);
15924 return n;
15925 }
15926
15927 diff --git a/arch/x86/include/asm/uaccess_64.h b/arch/x86/include/asm/uaccess_64.h
15928 index 142810c..747941a 100644
15929 --- a/arch/x86/include/asm/uaccess_64.h
15930 +++ b/arch/x86/include/asm/uaccess_64.h
15931 @@ -10,6 +10,9 @@
15932 #include <asm/alternative.h>
15933 #include <asm/cpufeature.h>
15934 #include <asm/page.h>
15935 +#include <asm/pgtable.h>
15936 +
15937 +#define set_fs(x) (current_thread_info()->addr_limit = (x))
15938
15939 /*
15940 * Copy To/From Userspace
15941 @@ -17,13 +20,13 @@
15942
15943 /* Handles exceptions in both to and from, but doesn't do access_ok */
15944 __must_check unsigned long
15945 -copy_user_enhanced_fast_string(void *to, const void *from, unsigned len);
15946 +copy_user_enhanced_fast_string(void *to, const void *from, unsigned len) __size_overflow(3);
15947 __must_check unsigned long
15948 -copy_user_generic_string(void *to, const void *from, unsigned len);
15949 +copy_user_generic_string(void *to, const void *from, unsigned len) __size_overflow(3);
15950 __must_check unsigned long
15951 -copy_user_generic_unrolled(void *to, const void *from, unsigned len);
15952 +copy_user_generic_unrolled(void *to, const void *from, unsigned len) __size_overflow(3);
15953
15954 -static __always_inline __must_check unsigned long
15955 +static __always_inline __must_check __size_overflow(3) unsigned long
15956 copy_user_generic(void *to, const void *from, unsigned len)
15957 {
15958 unsigned ret;
15959 @@ -41,142 +44,204 @@ copy_user_generic(void *to, const void *from, unsigned len)
15960 ASM_OUTPUT2("=a" (ret), "=D" (to), "=S" (from),
15961 "=d" (len)),
15962 "1" (to), "2" (from), "3" (len)
15963 - : "memory", "rcx", "r8", "r9", "r10", "r11");
15964 + : "memory", "rcx", "r8", "r9", "r11");
15965 return ret;
15966 }
15967
15968 +static __always_inline __must_check unsigned long
15969 +__copy_to_user(void __user *to, const void *from, unsigned long len) __size_overflow(3);
15970 +static __always_inline __must_check unsigned long
15971 +__copy_from_user(void *to, const void __user *from, unsigned long len) __size_overflow(3);
15972 __must_check unsigned long
15973 -_copy_to_user(void __user *to, const void *from, unsigned len);
15974 -__must_check unsigned long
15975 -_copy_from_user(void *to, const void __user *from, unsigned len);
15976 -__must_check unsigned long
15977 -copy_in_user(void __user *to, const void __user *from, unsigned len);
15978 +copy_in_user(void __user *to, const void __user *from, unsigned long len) __size_overflow(3);
15979 +
15980 +extern void copy_to_user_overflow(void)
15981 +#ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
15982 + __compiletime_error("copy_to_user() buffer size is not provably correct")
15983 +#else
15984 + __compiletime_warning("copy_to_user() buffer size is not provably correct")
15985 +#endif
15986 +;
15987 +
15988 +extern void copy_from_user_overflow(void)
15989 +#ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
15990 + __compiletime_error("copy_from_user() buffer size is not provably correct")
15991 +#else
15992 + __compiletime_warning("copy_from_user() buffer size is not provably correct")
15993 +#endif
15994 +;
15995
15996 static inline unsigned long __must_check copy_from_user(void *to,
15997 const void __user *from,
15998 unsigned long n)
15999 {
16000 - int sz = __compiletime_object_size(to);
16001 -
16002 might_fault();
16003 - if (likely(sz == -1 || sz >= n))
16004 - n = _copy_from_user(to, from, n);
16005 -#ifdef CONFIG_DEBUG_VM
16006 - else
16007 - WARN(1, "Buffer overflow detected!\n");
16008 -#endif
16009 +
16010 + check_object_size(to, n, false);
16011 +
16012 + if (access_ok(VERIFY_READ, from, n))
16013 + n = __copy_from_user(to, from, n);
16014 + else if (n < INT_MAX)
16015 + memset(to, 0, n);
16016 return n;
16017 }
16018
16019 static __always_inline __must_check
16020 -int copy_to_user(void __user *dst, const void *src, unsigned size)
16021 +int copy_to_user(void __user *dst, const void *src, unsigned long size)
16022 {
16023 might_fault();
16024
16025 - return _copy_to_user(dst, src, size);
16026 + if (access_ok(VERIFY_WRITE, dst, size))
16027 + size = __copy_to_user(dst, src, size);
16028 + return size;
16029 }
16030
16031 static __always_inline __must_check
16032 -int __copy_from_user(void *dst, const void __user *src, unsigned size)
16033 +unsigned long __copy_from_user(void *dst, const void __user *src, unsigned long size)
16034 {
16035 - int ret = 0;
16036 + size_t sz = __compiletime_object_size(dst);
16037 + unsigned ret = 0;
16038
16039 might_fault();
16040 +
16041 + if (size > INT_MAX)
16042 + return size;
16043 +
16044 + check_object_size(dst, size, false);
16045 +
16046 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16047 + if (!__access_ok(VERIFY_READ, src, size))
16048 + return size;
16049 +#endif
16050 +
16051 + if (unlikely(sz != (size_t)-1 && sz < size)) {
16052 + copy_from_user_overflow();
16053 + return size;
16054 + }
16055 +
16056 if (!__builtin_constant_p(size))
16057 - return copy_user_generic(dst, (__force void *)src, size);
16058 + return copy_user_generic(dst, (__force_kernel const void *)____m(src), size);
16059 switch (size) {
16060 - case 1:__get_user_asm(*(u8 *)dst, (u8 __user *)src,
16061 + case 1:__get_user_asm(*(u8 *)dst, (const u8 __user *)src,
16062 ret, "b", "b", "=q", 1);
16063 return ret;
16064 - case 2:__get_user_asm(*(u16 *)dst, (u16 __user *)src,
16065 + case 2:__get_user_asm(*(u16 *)dst, (const u16 __user *)src,
16066 ret, "w", "w", "=r", 2);
16067 return ret;
16068 - case 4:__get_user_asm(*(u32 *)dst, (u32 __user *)src,
16069 + case 4:__get_user_asm(*(u32 *)dst, (const u32 __user *)src,
16070 ret, "l", "k", "=r", 4);
16071 return ret;
16072 - case 8:__get_user_asm(*(u64 *)dst, (u64 __user *)src,
16073 + case 8:__get_user_asm(*(u64 *)dst, (const u64 __user *)src,
16074 ret, "q", "", "=r", 8);
16075 return ret;
16076 case 10:
16077 - __get_user_asm(*(u64 *)dst, (u64 __user *)src,
16078 + __get_user_asm(*(u64 *)dst, (const u64 __user *)src,
16079 ret, "q", "", "=r", 10);
16080 if (unlikely(ret))
16081 return ret;
16082 __get_user_asm(*(u16 *)(8 + (char *)dst),
16083 - (u16 __user *)(8 + (char __user *)src),
16084 + (const u16 __user *)(8 + (const char __user *)src),
16085 ret, "w", "w", "=r", 2);
16086 return ret;
16087 case 16:
16088 - __get_user_asm(*(u64 *)dst, (u64 __user *)src,
16089 + __get_user_asm(*(u64 *)dst, (const u64 __user *)src,
16090 ret, "q", "", "=r", 16);
16091 if (unlikely(ret))
16092 return ret;
16093 __get_user_asm(*(u64 *)(8 + (char *)dst),
16094 - (u64 __user *)(8 + (char __user *)src),
16095 + (const u64 __user *)(8 + (const char __user *)src),
16096 ret, "q", "", "=r", 8);
16097 return ret;
16098 default:
16099 - return copy_user_generic(dst, (__force void *)src, size);
16100 + return copy_user_generic(dst, (__force_kernel const void *)____m(src), size);
16101 }
16102 }
16103
16104 static __always_inline __must_check
16105 -int __copy_to_user(void __user *dst, const void *src, unsigned size)
16106 +unsigned long __copy_to_user(void __user *dst, const void *src, unsigned long size)
16107 {
16108 - int ret = 0;
16109 + size_t sz = __compiletime_object_size(src);
16110 + unsigned ret = 0;
16111
16112 might_fault();
16113 +
16114 + if (size > INT_MAX)
16115 + return size;
16116 +
16117 + check_object_size(src, size, true);
16118 +
16119 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16120 + if (!__access_ok(VERIFY_WRITE, dst, size))
16121 + return size;
16122 +#endif
16123 +
16124 + if (unlikely(sz != (size_t)-1 && sz < size)) {
16125 + copy_to_user_overflow();
16126 + return size;
16127 + }
16128 +
16129 if (!__builtin_constant_p(size))
16130 - return copy_user_generic((__force void *)dst, src, size);
16131 + return copy_user_generic((__force_kernel void *)____m(dst), src, size);
16132 switch (size) {
16133 - case 1:__put_user_asm(*(u8 *)src, (u8 __user *)dst,
16134 + case 1:__put_user_asm(*(const u8 *)src, (u8 __user *)dst,
16135 ret, "b", "b", "iq", 1);
16136 return ret;
16137 - case 2:__put_user_asm(*(u16 *)src, (u16 __user *)dst,
16138 + case 2:__put_user_asm(*(const u16 *)src, (u16 __user *)dst,
16139 ret, "w", "w", "ir", 2);
16140 return ret;
16141 - case 4:__put_user_asm(*(u32 *)src, (u32 __user *)dst,
16142 + case 4:__put_user_asm(*(const u32 *)src, (u32 __user *)dst,
16143 ret, "l", "k", "ir", 4);
16144 return ret;
16145 - case 8:__put_user_asm(*(u64 *)src, (u64 __user *)dst,
16146 + case 8:__put_user_asm(*(const u64 *)src, (u64 __user *)dst,
16147 ret, "q", "", "er", 8);
16148 return ret;
16149 case 10:
16150 - __put_user_asm(*(u64 *)src, (u64 __user *)dst,
16151 + __put_user_asm(*(const u64 *)src, (u64 __user *)dst,
16152 ret, "q", "", "er", 10);
16153 if (unlikely(ret))
16154 return ret;
16155 asm("":::"memory");
16156 - __put_user_asm(4[(u16 *)src], 4 + (u16 __user *)dst,
16157 + __put_user_asm(4[(const u16 *)src], 4 + (u16 __user *)dst,
16158 ret, "w", "w", "ir", 2);
16159 return ret;
16160 case 16:
16161 - __put_user_asm(*(u64 *)src, (u64 __user *)dst,
16162 + __put_user_asm(*(const u64 *)src, (u64 __user *)dst,
16163 ret, "q", "", "er", 16);
16164 if (unlikely(ret))
16165 return ret;
16166 asm("":::"memory");
16167 - __put_user_asm(1[(u64 *)src], 1 + (u64 __user *)dst,
16168 + __put_user_asm(1[(const u64 *)src], 1 + (u64 __user *)dst,
16169 ret, "q", "", "er", 8);
16170 return ret;
16171 default:
16172 - return copy_user_generic((__force void *)dst, src, size);
16173 + return copy_user_generic((__force_kernel void *)____m(dst), src, size);
16174 }
16175 }
16176
16177 static __always_inline __must_check
16178 -int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
16179 +unsigned long __copy_in_user(void __user *dst, const void __user *src, unsigned long size)
16180 {
16181 - int ret = 0;
16182 + unsigned ret = 0;
16183
16184 might_fault();
16185 +
16186 + if (size > INT_MAX)
16187 + return size;
16188 +
16189 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16190 + if (!__access_ok(VERIFY_READ, src, size))
16191 + return size;
16192 + if (!__access_ok(VERIFY_WRITE, dst, size))
16193 + return size;
16194 +#endif
16195 +
16196 if (!__builtin_constant_p(size))
16197 - return copy_user_generic((__force void *)dst,
16198 - (__force void *)src, size);
16199 + return copy_user_generic((__force_kernel void *)____m(dst),
16200 + (__force_kernel const void *)____m(src), size);
16201 switch (size) {
16202 case 1: {
16203 u8 tmp;
16204 - __get_user_asm(tmp, (u8 __user *)src,
16205 + __get_user_asm(tmp, (const u8 __user *)src,
16206 ret, "b", "b", "=q", 1);
16207 if (likely(!ret))
16208 __put_user_asm(tmp, (u8 __user *)dst,
16209 @@ -185,7 +250,7 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
16210 }
16211 case 2: {
16212 u16 tmp;
16213 - __get_user_asm(tmp, (u16 __user *)src,
16214 + __get_user_asm(tmp, (const u16 __user *)src,
16215 ret, "w", "w", "=r", 2);
16216 if (likely(!ret))
16217 __put_user_asm(tmp, (u16 __user *)dst,
16218 @@ -195,7 +260,7 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
16219
16220 case 4: {
16221 u32 tmp;
16222 - __get_user_asm(tmp, (u32 __user *)src,
16223 + __get_user_asm(tmp, (const u32 __user *)src,
16224 ret, "l", "k", "=r", 4);
16225 if (likely(!ret))
16226 __put_user_asm(tmp, (u32 __user *)dst,
16227 @@ -204,7 +269,7 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
16228 }
16229 case 8: {
16230 u64 tmp;
16231 - __get_user_asm(tmp, (u64 __user *)src,
16232 + __get_user_asm(tmp, (const u64 __user *)src,
16233 ret, "q", "", "=r", 8);
16234 if (likely(!ret))
16235 __put_user_asm(tmp, (u64 __user *)dst,
16236 @@ -212,41 +277,72 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
16237 return ret;
16238 }
16239 default:
16240 - return copy_user_generic((__force void *)dst,
16241 - (__force void *)src, size);
16242 + return copy_user_generic((__force_kernel void *)____m(dst),
16243 + (__force_kernel const void *)____m(src), size);
16244 }
16245 }
16246
16247 static __must_check __always_inline int
16248 -__copy_from_user_inatomic(void *dst, const void __user *src, unsigned size)
16249 +__copy_from_user_inatomic(void *dst, const void __user *src, unsigned long size)
16250 {
16251 - return copy_user_generic(dst, (__force const void *)src, size);
16252 + if (size > INT_MAX)
16253 + return size;
16254 +
16255 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16256 + if (!__access_ok(VERIFY_READ, src, size))
16257 + return size;
16258 +#endif
16259 +
16260 + return copy_user_generic(dst, (__force_kernel const void *)____m(src), size);
16261 }
16262
16263 -static __must_check __always_inline int
16264 -__copy_to_user_inatomic(void __user *dst, const void *src, unsigned size)
16265 +static __must_check __always_inline unsigned long
16266 +__copy_to_user_inatomic(void __user *dst, const void *src, unsigned long size)
16267 {
16268 - return copy_user_generic((__force void *)dst, src, size);
16269 + if (size > INT_MAX)
16270 + return size;
16271 +
16272 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16273 + if (!__access_ok(VERIFY_WRITE, dst, size))
16274 + return size;
16275 +#endif
16276 +
16277 + return copy_user_generic((__force_kernel void *)____m(dst), src, size);
16278 }
16279
16280 -extern long __copy_user_nocache(void *dst, const void __user *src,
16281 - unsigned size, int zerorest);
16282 +extern unsigned long __copy_user_nocache(void *dst, const void __user *src,
16283 + unsigned long size, int zerorest) __size_overflow(3);
16284
16285 -static inline int
16286 -__copy_from_user_nocache(void *dst, const void __user *src, unsigned size)
16287 +static inline unsigned long __copy_from_user_nocache(void *dst, const void __user *src, unsigned long size)
16288 {
16289 might_sleep();
16290 +
16291 + if (size > INT_MAX)
16292 + return size;
16293 +
16294 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16295 + if (!__access_ok(VERIFY_READ, src, size))
16296 + return size;
16297 +#endif
16298 +
16299 return __copy_user_nocache(dst, src, size, 1);
16300 }
16301
16302 -static inline int
16303 -__copy_from_user_inatomic_nocache(void *dst, const void __user *src,
16304 - unsigned size)
16305 +static inline unsigned long __copy_from_user_inatomic_nocache(void *dst, const void __user *src,
16306 + unsigned long size)
16307 {
16308 + if (size > INT_MAX)
16309 + return size;
16310 +
16311 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16312 + if (!__access_ok(VERIFY_READ, src, size))
16313 + return size;
16314 +#endif
16315 +
16316 return __copy_user_nocache(dst, src, size, 0);
16317 }
16318
16319 -unsigned long
16320 -copy_user_handle_tail(char *to, char *from, unsigned len, unsigned zerorest);
16321 +extern unsigned long
16322 +copy_user_handle_tail(char __user *to, char __user *from, unsigned long len, unsigned zerorest) __size_overflow(3);
16323
16324 #endif /* _ASM_X86_UACCESS_64_H */
16325 diff --git a/arch/x86/include/asm/word-at-a-time.h b/arch/x86/include/asm/word-at-a-time.h
16326 index 5b238981..77fdd78 100644
16327 --- a/arch/x86/include/asm/word-at-a-time.h
16328 +++ b/arch/x86/include/asm/word-at-a-time.h
16329 @@ -11,7 +11,7 @@
16330 * and shift, for example.
16331 */
16332 struct word_at_a_time {
16333 - const unsigned long one_bits, high_bits;
16334 + unsigned long one_bits, high_bits;
16335 };
16336
16337 #define WORD_AT_A_TIME_CONSTANTS { REPEAT_BYTE(0x01), REPEAT_BYTE(0x80) }
16338 diff --git a/arch/x86/include/asm/x86_init.h b/arch/x86/include/asm/x86_init.h
16339 index 5769349..a3d3e2a 100644
16340 --- a/arch/x86/include/asm/x86_init.h
16341 +++ b/arch/x86/include/asm/x86_init.h
16342 @@ -141,7 +141,7 @@ struct x86_init_ops {
16343 struct x86_init_timers timers;
16344 struct x86_init_iommu iommu;
16345 struct x86_init_pci pci;
16346 -};
16347 +} __no_const;
16348
16349 /**
16350 * struct x86_cpuinit_ops - platform specific cpu hotplug setups
16351 @@ -152,7 +152,7 @@ struct x86_cpuinit_ops {
16352 void (*setup_percpu_clockev)(void);
16353 void (*early_percpu_clock_init)(void);
16354 void (*fixup_cpu_id)(struct cpuinfo_x86 *c, int node);
16355 -};
16356 +} __no_const;
16357
16358 /**
16359 * struct x86_platform_ops - platform specific runtime functions
16360 @@ -178,7 +178,7 @@ struct x86_platform_ops {
16361 void (*save_sched_clock_state)(void);
16362 void (*restore_sched_clock_state)(void);
16363 void (*apic_post_init)(void);
16364 -};
16365 +} __no_const;
16366
16367 struct pci_dev;
16368
16369 @@ -187,14 +187,14 @@ struct x86_msi_ops {
16370 void (*teardown_msi_irq)(unsigned int irq);
16371 void (*teardown_msi_irqs)(struct pci_dev *dev);
16372 void (*restore_msi_irqs)(struct pci_dev *dev, int irq);
16373 -};
16374 +} __no_const;
16375
16376 struct x86_io_apic_ops {
16377 void (*init) (void);
16378 unsigned int (*read) (unsigned int apic, unsigned int reg);
16379 void (*write) (unsigned int apic, unsigned int reg, unsigned int value);
16380 void (*modify)(unsigned int apic, unsigned int reg, unsigned int value);
16381 -};
16382 +} __no_const;
16383
16384 extern struct x86_init_ops x86_init;
16385 extern struct x86_cpuinit_ops x86_cpuinit;
16386 diff --git a/arch/x86/include/asm/xsave.h b/arch/x86/include/asm/xsave.h
16387 index 0415cda..b43d877 100644
16388 --- a/arch/x86/include/asm/xsave.h
16389 +++ b/arch/x86/include/asm/xsave.h
16390 @@ -71,7 +71,9 @@ static inline int xsave_user(struct xsave_struct __user *buf)
16391 return -EFAULT;
16392
16393 __asm__ __volatile__(ASM_STAC "\n"
16394 - "1: .byte " REX_PREFIX "0x0f,0xae,0x27\n"
16395 + "1:"
16396 + __copyuser_seg
16397 + ".byte " REX_PREFIX "0x0f,0xae,0x27\n"
16398 "2: " ASM_CLAC "\n"
16399 ".section .fixup,\"ax\"\n"
16400 "3: movl $-1,%[err]\n"
16401 @@ -87,12 +89,14 @@ static inline int xsave_user(struct xsave_struct __user *buf)
16402 static inline int xrestore_user(struct xsave_struct __user *buf, u64 mask)
16403 {
16404 int err;
16405 - struct xsave_struct *xstate = ((__force struct xsave_struct *)buf);
16406 + struct xsave_struct *xstate = ((__force_kernel struct xsave_struct *)buf);
16407 u32 lmask = mask;
16408 u32 hmask = mask >> 32;
16409
16410 __asm__ __volatile__(ASM_STAC "\n"
16411 - "1: .byte " REX_PREFIX "0x0f,0xae,0x2f\n"
16412 + "1:"
16413 + __copyuser_seg
16414 + ".byte " REX_PREFIX "0x0f,0xae,0x2f\n"
16415 "2: " ASM_CLAC "\n"
16416 ".section .fixup,\"ax\"\n"
16417 "3: movl $-1,%[err]\n"
16418 diff --git a/arch/x86/include/uapi/asm/e820.h b/arch/x86/include/uapi/asm/e820.h
16419 index bbae024..e1528f9 100644
16420 --- a/arch/x86/include/uapi/asm/e820.h
16421 +++ b/arch/x86/include/uapi/asm/e820.h
16422 @@ -63,7 +63,7 @@ struct e820map {
16423 #define ISA_START_ADDRESS 0xa0000
16424 #define ISA_END_ADDRESS 0x100000
16425
16426 -#define BIOS_BEGIN 0x000a0000
16427 +#define BIOS_BEGIN 0x000c0000
16428 #define BIOS_END 0x00100000
16429
16430 #define BIOS_ROM_BASE 0xffe00000
16431 diff --git a/arch/x86/kernel/Makefile b/arch/x86/kernel/Makefile
16432 index 34e923a..0c6bb6e 100644
16433 --- a/arch/x86/kernel/Makefile
16434 +++ b/arch/x86/kernel/Makefile
16435 @@ -22,7 +22,7 @@ obj-y += time.o ioport.o ldt.o dumpstack.o nmi.o
16436 obj-y += setup.o x86_init.o i8259.o irqinit.o jump_label.o
16437 obj-$(CONFIG_IRQ_WORK) += irq_work.o
16438 obj-y += probe_roms.o
16439 -obj-$(CONFIG_X86_32) += i386_ksyms_32.o
16440 +obj-$(CONFIG_X86_32) += sys_i386_32.o i386_ksyms_32.o
16441 obj-$(CONFIG_X86_64) += sys_x86_64.o x8664_ksyms_64.o
16442 obj-y += syscall_$(BITS).o
16443 obj-$(CONFIG_X86_64) += vsyscall_64.o
16444 diff --git a/arch/x86/kernel/acpi/boot.c b/arch/x86/kernel/acpi/boot.c
16445 index bacf4b0..4ede72e 100644
16446 --- a/arch/x86/kernel/acpi/boot.c
16447 +++ b/arch/x86/kernel/acpi/boot.c
16448 @@ -1358,7 +1358,7 @@ static int __init dmi_ignore_irq0_timer_override(const struct dmi_system_id *d)
16449 * If your system is blacklisted here, but you find that acpi=force
16450 * works for you, please contact linux-acpi@vger.kernel.org
16451 */
16452 -static struct dmi_system_id __initdata acpi_dmi_table[] = {
16453 +static const struct dmi_system_id __initconst acpi_dmi_table[] = {
16454 /*
16455 * Boxes that need ACPI disabled
16456 */
16457 @@ -1433,7 +1433,7 @@ static struct dmi_system_id __initdata acpi_dmi_table[] = {
16458 };
16459
16460 /* second table for DMI checks that should run after early-quirks */
16461 -static struct dmi_system_id __initdata acpi_dmi_table_late[] = {
16462 +static const struct dmi_system_id __initconst acpi_dmi_table_late[] = {
16463 /*
16464 * HP laptops which use a DSDT reporting as HP/SB400/10000,
16465 * which includes some code which overrides all temperature
16466 diff --git a/arch/x86/kernel/acpi/sleep.c b/arch/x86/kernel/acpi/sleep.c
16467 index d5e0d71..6533e08 100644
16468 --- a/arch/x86/kernel/acpi/sleep.c
16469 +++ b/arch/x86/kernel/acpi/sleep.c
16470 @@ -74,8 +74,12 @@ int acpi_suspend_lowlevel(void)
16471 #else /* CONFIG_64BIT */
16472 #ifdef CONFIG_SMP
16473 stack_start = (unsigned long)temp_stack + sizeof(temp_stack);
16474 +
16475 + pax_open_kernel();
16476 early_gdt_descr.address =
16477 (unsigned long)get_cpu_gdt_table(smp_processor_id());
16478 + pax_close_kernel();
16479 +
16480 initial_gs = per_cpu_offset(smp_processor_id());
16481 #endif
16482 initial_code = (unsigned long)wakeup_long64;
16483 diff --git a/arch/x86/kernel/acpi/wakeup_32.S b/arch/x86/kernel/acpi/wakeup_32.S
16484 index 13ab720..95d5442 100644
16485 --- a/arch/x86/kernel/acpi/wakeup_32.S
16486 +++ b/arch/x86/kernel/acpi/wakeup_32.S
16487 @@ -30,13 +30,11 @@ wakeup_pmode_return:
16488 # and restore the stack ... but you need gdt for this to work
16489 movl saved_context_esp, %esp
16490
16491 - movl %cs:saved_magic, %eax
16492 - cmpl $0x12345678, %eax
16493 + cmpl $0x12345678, saved_magic
16494 jne bogus_magic
16495
16496 # jump to place where we left off
16497 - movl saved_eip, %eax
16498 - jmp *%eax
16499 + jmp *(saved_eip)
16500
16501 bogus_magic:
16502 jmp bogus_magic
16503 diff --git a/arch/x86/kernel/alternative.c b/arch/x86/kernel/alternative.c
16504 index ef5ccca..bd83949 100644
16505 --- a/arch/x86/kernel/alternative.c
16506 +++ b/arch/x86/kernel/alternative.c
16507 @@ -268,6 +268,13 @@ void __init_or_module apply_alternatives(struct alt_instr *start,
16508 */
16509 for (a = start; a < end; a++) {
16510 instr = (u8 *)&a->instr_offset + a->instr_offset;
16511 +
16512 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
16513 + instr += ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
16514 + if (instr < (u8 *)_text || (u8 *)_einittext <= instr)
16515 + instr -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
16516 +#endif
16517 +
16518 replacement = (u8 *)&a->repl_offset + a->repl_offset;
16519 BUG_ON(a->replacementlen > a->instrlen);
16520 BUG_ON(a->instrlen > sizeof(insnbuf));
16521 @@ -299,10 +306,16 @@ static void alternatives_smp_lock(const s32 *start, const s32 *end,
16522 for (poff = start; poff < end; poff++) {
16523 u8 *ptr = (u8 *)poff + *poff;
16524
16525 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
16526 + ptr += ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
16527 + if (ptr < (u8 *)_text || (u8 *)_einittext <= ptr)
16528 + ptr -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
16529 +#endif
16530 +
16531 if (!*poff || ptr < text || ptr >= text_end)
16532 continue;
16533 /* turn DS segment override prefix into lock prefix */
16534 - if (*ptr == 0x3e)
16535 + if (*ktla_ktva(ptr) == 0x3e)
16536 text_poke(ptr, ((unsigned char []){0xf0}), 1);
16537 }
16538 mutex_unlock(&text_mutex);
16539 @@ -317,10 +330,16 @@ static void alternatives_smp_unlock(const s32 *start, const s32 *end,
16540 for (poff = start; poff < end; poff++) {
16541 u8 *ptr = (u8 *)poff + *poff;
16542
16543 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
16544 + ptr += ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
16545 + if (ptr < (u8 *)_text || (u8 *)_einittext <= ptr)
16546 + ptr -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
16547 +#endif
16548 +
16549 if (!*poff || ptr < text || ptr >= text_end)
16550 continue;
16551 /* turn lock prefix into DS segment override prefix */
16552 - if (*ptr == 0xf0)
16553 + if (*ktla_ktva(ptr) == 0xf0)
16554 text_poke(ptr, ((unsigned char []){0x3E}), 1);
16555 }
16556 mutex_unlock(&text_mutex);
16557 @@ -468,7 +487,7 @@ void __init_or_module apply_paravirt(struct paravirt_patch_site *start,
16558
16559 BUG_ON(p->len > MAX_PATCH_LEN);
16560 /* prep the buffer with the original instructions */
16561 - memcpy(insnbuf, p->instr, p->len);
16562 + memcpy(insnbuf, ktla_ktva(p->instr), p->len);
16563 used = pv_init_ops.patch(p->instrtype, p->clobbers, insnbuf,
16564 (unsigned long)p->instr, p->len);
16565
16566 @@ -515,7 +534,7 @@ void __init alternative_instructions(void)
16567 if (!uniproc_patched || num_possible_cpus() == 1)
16568 free_init_pages("SMP alternatives",
16569 (unsigned long)__smp_locks,
16570 - (unsigned long)__smp_locks_end);
16571 + PAGE_ALIGN((unsigned long)__smp_locks_end));
16572 #endif
16573
16574 apply_paravirt(__parainstructions, __parainstructions_end);
16575 @@ -535,13 +554,17 @@ void __init alternative_instructions(void)
16576 * instructions. And on the local CPU you need to be protected again NMI or MCE
16577 * handlers seeing an inconsistent instruction while you patch.
16578 */
16579 -void *__init_or_module text_poke_early(void *addr, const void *opcode,
16580 +void *__kprobes text_poke_early(void *addr, const void *opcode,
16581 size_t len)
16582 {
16583 unsigned long flags;
16584 local_irq_save(flags);
16585 - memcpy(addr, opcode, len);
16586 +
16587 + pax_open_kernel();
16588 + memcpy(ktla_ktva(addr), opcode, len);
16589 sync_core();
16590 + pax_close_kernel();
16591 +
16592 local_irq_restore(flags);
16593 /* Could also do a CLFLUSH here to speed up CPU recovery; but
16594 that causes hangs on some VIA CPUs. */
16595 @@ -563,36 +586,22 @@ void *__init_or_module text_poke_early(void *addr, const void *opcode,
16596 */
16597 void *__kprobes text_poke(void *addr, const void *opcode, size_t len)
16598 {
16599 - unsigned long flags;
16600 - char *vaddr;
16601 + unsigned char *vaddr = ktla_ktva(addr);
16602 struct page *pages[2];
16603 - int i;
16604 + size_t i;
16605
16606 if (!core_kernel_text((unsigned long)addr)) {
16607 - pages[0] = vmalloc_to_page(addr);
16608 - pages[1] = vmalloc_to_page(addr + PAGE_SIZE);
16609 + pages[0] = vmalloc_to_page(vaddr);
16610 + pages[1] = vmalloc_to_page(vaddr + PAGE_SIZE);
16611 } else {
16612 - pages[0] = virt_to_page(addr);
16613 + pages[0] = virt_to_page(vaddr);
16614 WARN_ON(!PageReserved(pages[0]));
16615 - pages[1] = virt_to_page(addr + PAGE_SIZE);
16616 + pages[1] = virt_to_page(vaddr + PAGE_SIZE);
16617 }
16618 BUG_ON(!pages[0]);
16619 - local_irq_save(flags);
16620 - set_fixmap(FIX_TEXT_POKE0, page_to_phys(pages[0]));
16621 - if (pages[1])
16622 - set_fixmap(FIX_TEXT_POKE1, page_to_phys(pages[1]));
16623 - vaddr = (char *)fix_to_virt(FIX_TEXT_POKE0);
16624 - memcpy(&vaddr[(unsigned long)addr & ~PAGE_MASK], opcode, len);
16625 - clear_fixmap(FIX_TEXT_POKE0);
16626 - if (pages[1])
16627 - clear_fixmap(FIX_TEXT_POKE1);
16628 - local_flush_tlb();
16629 - sync_core();
16630 - /* Could also do a CLFLUSH here to speed up CPU recovery; but
16631 - that causes hangs on some VIA CPUs. */
16632 + text_poke_early(addr, opcode, len);
16633 for (i = 0; i < len; i++)
16634 - BUG_ON(((char *)addr)[i] != ((char *)opcode)[i]);
16635 - local_irq_restore(flags);
16636 + BUG_ON((vaddr)[i] != ((const unsigned char *)opcode)[i]);
16637 return addr;
16638 }
16639
16640 diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c
16641 index cbf5121..812b537 100644
16642 --- a/arch/x86/kernel/apic/apic.c
16643 +++ b/arch/x86/kernel/apic/apic.c
16644 @@ -189,7 +189,7 @@ int first_system_vector = 0xfe;
16645 /*
16646 * Debug level, exported for io_apic.c
16647 */
16648 -unsigned int apic_verbosity;
16649 +int apic_verbosity;
16650
16651 int pic_mode;
16652
16653 @@ -1956,7 +1956,7 @@ void smp_error_interrupt(struct pt_regs *regs)
16654 apic_write(APIC_ESR, 0);
16655 v1 = apic_read(APIC_ESR);
16656 ack_APIC_irq();
16657 - atomic_inc(&irq_err_count);
16658 + atomic_inc_unchecked(&irq_err_count);
16659
16660 apic_printk(APIC_DEBUG, KERN_DEBUG "APIC error on CPU%d: %02x(%02x)",
16661 smp_processor_id(), v0 , v1);
16662 diff --git a/arch/x86/kernel/apic/apic_flat_64.c b/arch/x86/kernel/apic/apic_flat_64.c
16663 index 00c77cf..2dc6a2d 100644
16664 --- a/arch/x86/kernel/apic/apic_flat_64.c
16665 +++ b/arch/x86/kernel/apic/apic_flat_64.c
16666 @@ -157,7 +157,7 @@ static int flat_probe(void)
16667 return 1;
16668 }
16669
16670 -static struct apic apic_flat = {
16671 +static struct apic apic_flat __read_only = {
16672 .name = "flat",
16673 .probe = flat_probe,
16674 .acpi_madt_oem_check = flat_acpi_madt_oem_check,
16675 @@ -271,7 +271,7 @@ static int physflat_probe(void)
16676 return 0;
16677 }
16678
16679 -static struct apic apic_physflat = {
16680 +static struct apic apic_physflat __read_only = {
16681
16682 .name = "physical flat",
16683 .probe = physflat_probe,
16684 diff --git a/arch/x86/kernel/apic/apic_noop.c b/arch/x86/kernel/apic/apic_noop.c
16685 index e145f28..2752888 100644
16686 --- a/arch/x86/kernel/apic/apic_noop.c
16687 +++ b/arch/x86/kernel/apic/apic_noop.c
16688 @@ -119,7 +119,7 @@ static void noop_apic_write(u32 reg, u32 v)
16689 WARN_ON_ONCE(cpu_has_apic && !disable_apic);
16690 }
16691
16692 -struct apic apic_noop = {
16693 +struct apic apic_noop __read_only = {
16694 .name = "noop",
16695 .probe = noop_probe,
16696 .acpi_madt_oem_check = NULL,
16697 diff --git a/arch/x86/kernel/apic/bigsmp_32.c b/arch/x86/kernel/apic/bigsmp_32.c
16698 index d50e364..543bee3 100644
16699 --- a/arch/x86/kernel/apic/bigsmp_32.c
16700 +++ b/arch/x86/kernel/apic/bigsmp_32.c
16701 @@ -152,7 +152,7 @@ static int probe_bigsmp(void)
16702 return dmi_bigsmp;
16703 }
16704
16705 -static struct apic apic_bigsmp = {
16706 +static struct apic apic_bigsmp __read_only = {
16707
16708 .name = "bigsmp",
16709 .probe = probe_bigsmp,
16710 diff --git a/arch/x86/kernel/apic/es7000_32.c b/arch/x86/kernel/apic/es7000_32.c
16711 index 0874799..a7a7892 100644
16712 --- a/arch/x86/kernel/apic/es7000_32.c
16713 +++ b/arch/x86/kernel/apic/es7000_32.c
16714 @@ -608,8 +608,7 @@ static int es7000_mps_oem_check_cluster(struct mpc_table *mpc, char *oem,
16715 return ret && es7000_apic_is_cluster();
16716 }
16717
16718 -/* We've been warned by a false positive warning.Use __refdata to keep calm. */
16719 -static struct apic __refdata apic_es7000_cluster = {
16720 +static struct apic apic_es7000_cluster __read_only = {
16721
16722 .name = "es7000",
16723 .probe = probe_es7000,
16724 @@ -675,7 +674,7 @@ static struct apic __refdata apic_es7000_cluster = {
16725 .x86_32_early_logical_apicid = es7000_early_logical_apicid,
16726 };
16727
16728 -static struct apic __refdata apic_es7000 = {
16729 +static struct apic apic_es7000 __read_only = {
16730
16731 .name = "es7000",
16732 .probe = probe_es7000,
16733 diff --git a/arch/x86/kernel/apic/io_apic.c b/arch/x86/kernel/apic/io_apic.c
16734 index b739d39..aebc14c 100644
16735 --- a/arch/x86/kernel/apic/io_apic.c
16736 +++ b/arch/x86/kernel/apic/io_apic.c
16737 @@ -1084,7 +1084,7 @@ int IO_APIC_get_PCI_irq_vector(int bus, int slot, int pin,
16738 }
16739 EXPORT_SYMBOL(IO_APIC_get_PCI_irq_vector);
16740
16741 -void lock_vector_lock(void)
16742 +void lock_vector_lock(void) __acquires(vector_lock)
16743 {
16744 /* Used to the online set of cpus does not change
16745 * during assign_irq_vector.
16746 @@ -1092,7 +1092,7 @@ void lock_vector_lock(void)
16747 raw_spin_lock(&vector_lock);
16748 }
16749
16750 -void unlock_vector_lock(void)
16751 +void unlock_vector_lock(void) __releases(vector_lock)
16752 {
16753 raw_spin_unlock(&vector_lock);
16754 }
16755 @@ -2399,7 +2399,7 @@ static void ack_apic_edge(struct irq_data *data)
16756 ack_APIC_irq();
16757 }
16758
16759 -atomic_t irq_mis_count;
16760 +atomic_unchecked_t irq_mis_count;
16761
16762 #ifdef CONFIG_GENERIC_PENDING_IRQ
16763 static bool io_apic_level_ack_pending(struct irq_cfg *cfg)
16764 @@ -2540,7 +2540,7 @@ static void ack_apic_level(struct irq_data *data)
16765 * at the cpu.
16766 */
16767 if (!(v & (1 << (i & 0x1f)))) {
16768 - atomic_inc(&irq_mis_count);
16769 + atomic_inc_unchecked(&irq_mis_count);
16770
16771 eoi_ioapic_irq(irq, cfg);
16772 }
16773 @@ -2567,11 +2567,13 @@ static void ir_print_prefix(struct irq_data *data, struct seq_file *p)
16774
16775 static void irq_remap_modify_chip_defaults(struct irq_chip *chip)
16776 {
16777 - chip->irq_print_chip = ir_print_prefix;
16778 - chip->irq_ack = ir_ack_apic_edge;
16779 - chip->irq_eoi = ir_ack_apic_level;
16780 + pax_open_kernel();
16781 + *(void **)&chip->irq_print_chip = ir_print_prefix;
16782 + *(void **)&chip->irq_ack = ir_ack_apic_edge;
16783 + *(void **)&chip->irq_eoi = ir_ack_apic_level;
16784
16785 - chip->irq_set_affinity = set_remapped_irq_affinity;
16786 + *(void **)&chip->irq_set_affinity = set_remapped_irq_affinity;
16787 + pax_close_kernel();
16788 }
16789 #endif /* CONFIG_IRQ_REMAP */
16790
16791 diff --git a/arch/x86/kernel/apic/numaq_32.c b/arch/x86/kernel/apic/numaq_32.c
16792 index d661ee9..791fd33 100644
16793 --- a/arch/x86/kernel/apic/numaq_32.c
16794 +++ b/arch/x86/kernel/apic/numaq_32.c
16795 @@ -455,8 +455,7 @@ static void numaq_setup_portio_remap(void)
16796 (u_long) xquad_portio, (u_long) num_quads*XQUAD_PORTIO_QUAD);
16797 }
16798
16799 -/* Use __refdata to keep false positive warning calm. */
16800 -static struct apic __refdata apic_numaq = {
16801 +static struct apic apic_numaq __read_only = {
16802
16803 .name = "NUMAQ",
16804 .probe = probe_numaq,
16805 diff --git a/arch/x86/kernel/apic/probe_32.c b/arch/x86/kernel/apic/probe_32.c
16806 index eb35ef9..f184a21 100644
16807 --- a/arch/x86/kernel/apic/probe_32.c
16808 +++ b/arch/x86/kernel/apic/probe_32.c
16809 @@ -72,7 +72,7 @@ static int probe_default(void)
16810 return 1;
16811 }
16812
16813 -static struct apic apic_default = {
16814 +static struct apic apic_default __read_only = {
16815
16816 .name = "default",
16817 .probe = probe_default,
16818 diff --git a/arch/x86/kernel/apic/summit_32.c b/arch/x86/kernel/apic/summit_32.c
16819 index 77c95c0..434f8a4 100644
16820 --- a/arch/x86/kernel/apic/summit_32.c
16821 +++ b/arch/x86/kernel/apic/summit_32.c
16822 @@ -486,7 +486,7 @@ void setup_summit(void)
16823 }
16824 #endif
16825
16826 -static struct apic apic_summit = {
16827 +static struct apic apic_summit __read_only = {
16828
16829 .name = "summit",
16830 .probe = probe_summit,
16831 diff --git a/arch/x86/kernel/apic/x2apic_cluster.c b/arch/x86/kernel/apic/x2apic_cluster.c
16832 index c88baa4..757aee1 100644
16833 --- a/arch/x86/kernel/apic/x2apic_cluster.c
16834 +++ b/arch/x86/kernel/apic/x2apic_cluster.c
16835 @@ -183,7 +183,7 @@ update_clusterinfo(struct notifier_block *nfb, unsigned long action, void *hcpu)
16836 return notifier_from_errno(err);
16837 }
16838
16839 -static struct notifier_block __refdata x2apic_cpu_notifier = {
16840 +static struct notifier_block x2apic_cpu_notifier = {
16841 .notifier_call = update_clusterinfo,
16842 };
16843
16844 @@ -235,7 +235,7 @@ static void cluster_vector_allocation_domain(int cpu, struct cpumask *retmask,
16845 cpumask_and(retmask, mask, per_cpu(cpus_in_cluster, cpu));
16846 }
16847
16848 -static struct apic apic_x2apic_cluster = {
16849 +static struct apic apic_x2apic_cluster __read_only = {
16850
16851 .name = "cluster x2apic",
16852 .probe = x2apic_cluster_probe,
16853 diff --git a/arch/x86/kernel/apic/x2apic_phys.c b/arch/x86/kernel/apic/x2apic_phys.c
16854 index 562a76d..a003c0f 100644
16855 --- a/arch/x86/kernel/apic/x2apic_phys.c
16856 +++ b/arch/x86/kernel/apic/x2apic_phys.c
16857 @@ -89,7 +89,7 @@ static int x2apic_phys_probe(void)
16858 return apic == &apic_x2apic_phys;
16859 }
16860
16861 -static struct apic apic_x2apic_phys = {
16862 +static struct apic apic_x2apic_phys __read_only = {
16863
16864 .name = "physical x2apic",
16865 .probe = x2apic_phys_probe,
16866 diff --git a/arch/x86/kernel/apic/x2apic_uv_x.c b/arch/x86/kernel/apic/x2apic_uv_x.c
16867 index 8cfade9..b9d04fc 100644
16868 --- a/arch/x86/kernel/apic/x2apic_uv_x.c
16869 +++ b/arch/x86/kernel/apic/x2apic_uv_x.c
16870 @@ -333,7 +333,7 @@ static int uv_probe(void)
16871 return apic == &apic_x2apic_uv_x;
16872 }
16873
16874 -static struct apic __refdata apic_x2apic_uv_x = {
16875 +static struct apic apic_x2apic_uv_x __read_only = {
16876
16877 .name = "UV large system",
16878 .probe = uv_probe,
16879 diff --git a/arch/x86/kernel/apm_32.c b/arch/x86/kernel/apm_32.c
16880 index d65464e..1035d31 100644
16881 --- a/arch/x86/kernel/apm_32.c
16882 +++ b/arch/x86/kernel/apm_32.c
16883 @@ -412,7 +412,7 @@ static DEFINE_MUTEX(apm_mutex);
16884 * This is for buggy BIOS's that refer to (real mode) segment 0x40
16885 * even though they are called in protected mode.
16886 */
16887 -static struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4092,
16888 +static const struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4093,
16889 (unsigned long)__va(0x400UL), PAGE_SIZE - 0x400 - 1);
16890
16891 static const char driver_version[] = "1.16ac"; /* no spaces */
16892 @@ -590,7 +590,10 @@ static long __apm_bios_call(void *_call)
16893 BUG_ON(cpu != 0);
16894 gdt = get_cpu_gdt_table(cpu);
16895 save_desc_40 = gdt[0x40 / 8];
16896 +
16897 + pax_open_kernel();
16898 gdt[0x40 / 8] = bad_bios_desc;
16899 + pax_close_kernel();
16900
16901 apm_irq_save(flags);
16902 APM_DO_SAVE_SEGS;
16903 @@ -599,7 +602,11 @@ static long __apm_bios_call(void *_call)
16904 &call->esi);
16905 APM_DO_RESTORE_SEGS;
16906 apm_irq_restore(flags);
16907 +
16908 + pax_open_kernel();
16909 gdt[0x40 / 8] = save_desc_40;
16910 + pax_close_kernel();
16911 +
16912 put_cpu();
16913
16914 return call->eax & 0xff;
16915 @@ -666,7 +673,10 @@ static long __apm_bios_call_simple(void *_call)
16916 BUG_ON(cpu != 0);
16917 gdt = get_cpu_gdt_table(cpu);
16918 save_desc_40 = gdt[0x40 / 8];
16919 +
16920 + pax_open_kernel();
16921 gdt[0x40 / 8] = bad_bios_desc;
16922 + pax_close_kernel();
16923
16924 apm_irq_save(flags);
16925 APM_DO_SAVE_SEGS;
16926 @@ -674,7 +684,11 @@ static long __apm_bios_call_simple(void *_call)
16927 &call->eax);
16928 APM_DO_RESTORE_SEGS;
16929 apm_irq_restore(flags);
16930 +
16931 + pax_open_kernel();
16932 gdt[0x40 / 8] = save_desc_40;
16933 + pax_close_kernel();
16934 +
16935 put_cpu();
16936 return error;
16937 }
16938 @@ -2345,12 +2359,15 @@ static int __init apm_init(void)
16939 * code to that CPU.
16940 */
16941 gdt = get_cpu_gdt_table(0);
16942 +
16943 + pax_open_kernel();
16944 set_desc_base(&gdt[APM_CS >> 3],
16945 (unsigned long)__va((unsigned long)apm_info.bios.cseg << 4));
16946 set_desc_base(&gdt[APM_CS_16 >> 3],
16947 (unsigned long)__va((unsigned long)apm_info.bios.cseg_16 << 4));
16948 set_desc_base(&gdt[APM_DS >> 3],
16949 (unsigned long)__va((unsigned long)apm_info.bios.dseg << 4));
16950 + pax_close_kernel();
16951
16952 proc_create("apm", 0, NULL, &apm_file_ops);
16953
16954 diff --git a/arch/x86/kernel/asm-offsets.c b/arch/x86/kernel/asm-offsets.c
16955 index 2861082..6d4718e 100644
16956 --- a/arch/x86/kernel/asm-offsets.c
16957 +++ b/arch/x86/kernel/asm-offsets.c
16958 @@ -33,6 +33,8 @@ void common(void) {
16959 OFFSET(TI_status, thread_info, status);
16960 OFFSET(TI_addr_limit, thread_info, addr_limit);
16961 OFFSET(TI_preempt_count, thread_info, preempt_count);
16962 + OFFSET(TI_lowest_stack, thread_info, lowest_stack);
16963 + DEFINE(TI_task_thread_sp0, offsetof(struct task_struct, thread.sp0) - offsetof(struct task_struct, tinfo));
16964
16965 BLANK();
16966 OFFSET(crypto_tfm_ctx_offset, crypto_tfm, __crt_ctx);
16967 @@ -53,8 +55,26 @@ void common(void) {
16968 OFFSET(PV_CPU_irq_enable_sysexit, pv_cpu_ops, irq_enable_sysexit);
16969 OFFSET(PV_CPU_read_cr0, pv_cpu_ops, read_cr0);
16970 OFFSET(PV_MMU_read_cr2, pv_mmu_ops, read_cr2);
16971 +
16972 +#ifdef CONFIG_PAX_KERNEXEC
16973 + OFFSET(PV_CPU_write_cr0, pv_cpu_ops, write_cr0);
16974 #endif
16975
16976 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16977 + OFFSET(PV_MMU_read_cr3, pv_mmu_ops, read_cr3);
16978 + OFFSET(PV_MMU_write_cr3, pv_mmu_ops, write_cr3);
16979 +#ifdef CONFIG_X86_64
16980 + OFFSET(PV_MMU_set_pgd_batched, pv_mmu_ops, set_pgd_batched);
16981 +#endif
16982 +#endif
16983 +
16984 +#endif
16985 +
16986 + BLANK();
16987 + DEFINE(PAGE_SIZE_asm, PAGE_SIZE);
16988 + DEFINE(PAGE_SHIFT_asm, PAGE_SHIFT);
16989 + DEFINE(THREAD_SIZE_asm, THREAD_SIZE);
16990 +
16991 #ifdef CONFIG_XEN
16992 BLANK();
16993 OFFSET(XEN_vcpu_info_mask, vcpu_info, evtchn_upcall_mask);
16994 diff --git a/arch/x86/kernel/asm-offsets_64.c b/arch/x86/kernel/asm-offsets_64.c
16995 index 1b4754f..fbb4227 100644
16996 --- a/arch/x86/kernel/asm-offsets_64.c
16997 +++ b/arch/x86/kernel/asm-offsets_64.c
16998 @@ -76,6 +76,7 @@ int main(void)
16999 BLANK();
17000 #undef ENTRY
17001
17002 + DEFINE(TSS_size, sizeof(struct tss_struct));
17003 OFFSET(TSS_ist, tss_struct, x86_tss.ist);
17004 BLANK();
17005
17006 diff --git a/arch/x86/kernel/cpu/Makefile b/arch/x86/kernel/cpu/Makefile
17007 index a0e067d..9c7db16 100644
17008 --- a/arch/x86/kernel/cpu/Makefile
17009 +++ b/arch/x86/kernel/cpu/Makefile
17010 @@ -8,10 +8,6 @@ CFLAGS_REMOVE_common.o = -pg
17011 CFLAGS_REMOVE_perf_event.o = -pg
17012 endif
17013
17014 -# Make sure load_percpu_segment has no stackprotector
17015 -nostackp := $(call cc-option, -fno-stack-protector)
17016 -CFLAGS_common.o := $(nostackp)
17017 -
17018 obj-y := intel_cacheinfo.o scattered.o topology.o
17019 obj-y += proc.o capflags.o powerflags.o common.o
17020 obj-y += vmware.o hypervisor.o mshyperv.o
17021 diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c
17022 index 15239ff..e23e04e 100644
17023 --- a/arch/x86/kernel/cpu/amd.c
17024 +++ b/arch/x86/kernel/cpu/amd.c
17025 @@ -733,7 +733,7 @@ static unsigned int __cpuinit amd_size_cache(struct cpuinfo_x86 *c,
17026 unsigned int size)
17027 {
17028 /* AMD errata T13 (order #21922) */
17029 - if ((c->x86 == 6)) {
17030 + if (c->x86 == 6) {
17031 /* Duron Rev A0 */
17032 if (c->x86_model == 3 && c->x86_mask == 0)
17033 size = 64;
17034 diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
17035 index 9c3ab43..51e6366 100644
17036 --- a/arch/x86/kernel/cpu/common.c
17037 +++ b/arch/x86/kernel/cpu/common.c
17038 @@ -86,60 +86,6 @@ static const struct cpu_dev __cpuinitconst default_cpu = {
17039
17040 static const struct cpu_dev *this_cpu __cpuinitdata = &default_cpu;
17041
17042 -DEFINE_PER_CPU_PAGE_ALIGNED(struct gdt_page, gdt_page) = { .gdt = {
17043 -#ifdef CONFIG_X86_64
17044 - /*
17045 - * We need valid kernel segments for data and code in long mode too
17046 - * IRET will check the segment types kkeil 2000/10/28
17047 - * Also sysret mandates a special GDT layout
17048 - *
17049 - * TLS descriptors are currently at a different place compared to i386.
17050 - * Hopefully nobody expects them at a fixed place (Wine?)
17051 - */
17052 - [GDT_ENTRY_KERNEL32_CS] = GDT_ENTRY_INIT(0xc09b, 0, 0xfffff),
17053 - [GDT_ENTRY_KERNEL_CS] = GDT_ENTRY_INIT(0xa09b, 0, 0xfffff),
17054 - [GDT_ENTRY_KERNEL_DS] = GDT_ENTRY_INIT(0xc093, 0, 0xfffff),
17055 - [GDT_ENTRY_DEFAULT_USER32_CS] = GDT_ENTRY_INIT(0xc0fb, 0, 0xfffff),
17056 - [GDT_ENTRY_DEFAULT_USER_DS] = GDT_ENTRY_INIT(0xc0f3, 0, 0xfffff),
17057 - [GDT_ENTRY_DEFAULT_USER_CS] = GDT_ENTRY_INIT(0xa0fb, 0, 0xfffff),
17058 -#else
17059 - [GDT_ENTRY_KERNEL_CS] = GDT_ENTRY_INIT(0xc09a, 0, 0xfffff),
17060 - [GDT_ENTRY_KERNEL_DS] = GDT_ENTRY_INIT(0xc092, 0, 0xfffff),
17061 - [GDT_ENTRY_DEFAULT_USER_CS] = GDT_ENTRY_INIT(0xc0fa, 0, 0xfffff),
17062 - [GDT_ENTRY_DEFAULT_USER_DS] = GDT_ENTRY_INIT(0xc0f2, 0, 0xfffff),
17063 - /*
17064 - * Segments used for calling PnP BIOS have byte granularity.
17065 - * They code segments and data segments have fixed 64k limits,
17066 - * the transfer segment sizes are set at run time.
17067 - */
17068 - /* 32-bit code */
17069 - [GDT_ENTRY_PNPBIOS_CS32] = GDT_ENTRY_INIT(0x409a, 0, 0xffff),
17070 - /* 16-bit code */
17071 - [GDT_ENTRY_PNPBIOS_CS16] = GDT_ENTRY_INIT(0x009a, 0, 0xffff),
17072 - /* 16-bit data */
17073 - [GDT_ENTRY_PNPBIOS_DS] = GDT_ENTRY_INIT(0x0092, 0, 0xffff),
17074 - /* 16-bit data */
17075 - [GDT_ENTRY_PNPBIOS_TS1] = GDT_ENTRY_INIT(0x0092, 0, 0),
17076 - /* 16-bit data */
17077 - [GDT_ENTRY_PNPBIOS_TS2] = GDT_ENTRY_INIT(0x0092, 0, 0),
17078 - /*
17079 - * The APM segments have byte granularity and their bases
17080 - * are set at run time. All have 64k limits.
17081 - */
17082 - /* 32-bit code */
17083 - [GDT_ENTRY_APMBIOS_BASE] = GDT_ENTRY_INIT(0x409a, 0, 0xffff),
17084 - /* 16-bit code */
17085 - [GDT_ENTRY_APMBIOS_BASE+1] = GDT_ENTRY_INIT(0x009a, 0, 0xffff),
17086 - /* data */
17087 - [GDT_ENTRY_APMBIOS_BASE+2] = GDT_ENTRY_INIT(0x4092, 0, 0xffff),
17088 -
17089 - [GDT_ENTRY_ESPFIX_SS] = GDT_ENTRY_INIT(0xc092, 0, 0xfffff),
17090 - [GDT_ENTRY_PERCPU] = GDT_ENTRY_INIT(0xc092, 0, 0xfffff),
17091 - GDT_STACK_CANARY_INIT
17092 -#endif
17093 -} };
17094 -EXPORT_PER_CPU_SYMBOL_GPL(gdt_page);
17095 -
17096 static int __init x86_xsave_setup(char *s)
17097 {
17098 setup_clear_cpu_cap(X86_FEATURE_XSAVE);
17099 @@ -389,7 +335,7 @@ void switch_to_new_gdt(int cpu)
17100 {
17101 struct desc_ptr gdt_descr;
17102
17103 - gdt_descr.address = (long)get_cpu_gdt_table(cpu);
17104 + gdt_descr.address = (unsigned long)get_cpu_gdt_table(cpu);
17105 gdt_descr.size = GDT_SIZE - 1;
17106 load_gdt(&gdt_descr);
17107 /* Reload the per-cpu base */
17108 @@ -885,6 +831,10 @@ static void __cpuinit identify_cpu(struct cpuinfo_x86 *c)
17109 /* Filter out anything that depends on CPUID levels we don't have */
17110 filter_cpuid_features(c, true);
17111
17112 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_SEGMEXEC) || defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF))
17113 + setup_clear_cpu_cap(X86_FEATURE_SEP);
17114 +#endif
17115 +
17116 /* If the model name is still unset, do table lookup. */
17117 if (!c->x86_model_id[0]) {
17118 const char *p;
17119 @@ -1068,10 +1018,12 @@ static __init int setup_disablecpuid(char *arg)
17120 }
17121 __setup("clearcpuid=", setup_disablecpuid);
17122
17123 +DEFINE_PER_CPU(struct thread_info *, current_tinfo) = &init_task.tinfo;
17124 +EXPORT_PER_CPU_SYMBOL(current_tinfo);
17125 +
17126 #ifdef CONFIG_X86_64
17127 struct desc_ptr idt_descr = { NR_VECTORS * 16 - 1, (unsigned long) idt_table };
17128 -struct desc_ptr nmi_idt_descr = { NR_VECTORS * 16 - 1,
17129 - (unsigned long) nmi_idt_table };
17130 +struct desc_ptr nmi_idt_descr = { NR_VECTORS * 16 - 1, (unsigned long) nmi_idt_table };
17131
17132 DEFINE_PER_CPU_FIRST(union irq_stack_union,
17133 irq_stack_union) __aligned(PAGE_SIZE);
17134 @@ -1085,7 +1037,7 @@ DEFINE_PER_CPU(struct task_struct *, current_task) ____cacheline_aligned =
17135 EXPORT_PER_CPU_SYMBOL(current_task);
17136
17137 DEFINE_PER_CPU(unsigned long, kernel_stack) =
17138 - (unsigned long)&init_thread_union - KERNEL_STACK_OFFSET + THREAD_SIZE;
17139 + (unsigned long)&init_thread_union - 16 + THREAD_SIZE;
17140 EXPORT_PER_CPU_SYMBOL(kernel_stack);
17141
17142 DEFINE_PER_CPU(char *, irq_stack_ptr) =
17143 @@ -1224,7 +1176,7 @@ void __cpuinit cpu_init(void)
17144 int i;
17145
17146 cpu = stack_smp_processor_id();
17147 - t = &per_cpu(init_tss, cpu);
17148 + t = init_tss + cpu;
17149 oist = &per_cpu(orig_ist, cpu);
17150
17151 #ifdef CONFIG_NUMA
17152 @@ -1250,7 +1202,7 @@ void __cpuinit cpu_init(void)
17153 switch_to_new_gdt(cpu);
17154 loadsegment(fs, 0);
17155
17156 - load_idt((const struct desc_ptr *)&idt_descr);
17157 + load_idt(&idt_descr);
17158
17159 memset(me->thread.tls_array, 0, GDT_ENTRY_TLS_ENTRIES * 8);
17160 syscall_init();
17161 @@ -1259,7 +1211,6 @@ void __cpuinit cpu_init(void)
17162 wrmsrl(MSR_KERNEL_GS_BASE, 0);
17163 barrier();
17164
17165 - x86_configure_nx();
17166 enable_x2apic();
17167
17168 /*
17169 @@ -1311,7 +1262,7 @@ void __cpuinit cpu_init(void)
17170 {
17171 int cpu = smp_processor_id();
17172 struct task_struct *curr = current;
17173 - struct tss_struct *t = &per_cpu(init_tss, cpu);
17174 + struct tss_struct *t = init_tss + cpu;
17175 struct thread_struct *thread = &curr->thread;
17176
17177 if (cpumask_test_and_set_cpu(cpu, cpu_initialized_mask)) {
17178 diff --git a/arch/x86/kernel/cpu/intel.c b/arch/x86/kernel/cpu/intel.c
17179 index fcaabd0..7b55a26 100644
17180 --- a/arch/x86/kernel/cpu/intel.c
17181 +++ b/arch/x86/kernel/cpu/intel.c
17182 @@ -174,7 +174,7 @@ static void __cpuinit trap_init_f00f_bug(void)
17183 * Update the IDT descriptor and reload the IDT so that
17184 * it uses the read-only mapped virtual address.
17185 */
17186 - idt_descr.address = fix_to_virt(FIX_F00F_IDT);
17187 + idt_descr.address = (struct desc_struct *)fix_to_virt(FIX_F00F_IDT);
17188 load_idt(&idt_descr);
17189 }
17190 #endif
17191 diff --git a/arch/x86/kernel/cpu/intel_cacheinfo.c b/arch/x86/kernel/cpu/intel_cacheinfo.c
17192 index 84c1309..39b7224 100644
17193 --- a/arch/x86/kernel/cpu/intel_cacheinfo.c
17194 +++ b/arch/x86/kernel/cpu/intel_cacheinfo.c
17195 @@ -1017,6 +1017,22 @@ static struct attribute *default_attrs[] = {
17196 };
17197
17198 #ifdef CONFIG_AMD_NB
17199 +static struct attribute *default_attrs_amd_nb[] = {
17200 + &type.attr,
17201 + &level.attr,
17202 + &coherency_line_size.attr,
17203 + &physical_line_partition.attr,
17204 + &ways_of_associativity.attr,
17205 + &number_of_sets.attr,
17206 + &size.attr,
17207 + &shared_cpu_map.attr,
17208 + &shared_cpu_list.attr,
17209 + NULL,
17210 + NULL,
17211 + NULL,
17212 + NULL
17213 +};
17214 +
17215 static struct attribute ** __cpuinit amd_l3_attrs(void)
17216 {
17217 static struct attribute **attrs;
17218 @@ -1027,18 +1043,7 @@ static struct attribute ** __cpuinit amd_l3_attrs(void)
17219
17220 n = ARRAY_SIZE(default_attrs);
17221
17222 - if (amd_nb_has_feature(AMD_NB_L3_INDEX_DISABLE))
17223 - n += 2;
17224 -
17225 - if (amd_nb_has_feature(AMD_NB_L3_PARTITIONING))
17226 - n += 1;
17227 -
17228 - attrs = kzalloc(n * sizeof (struct attribute *), GFP_KERNEL);
17229 - if (attrs == NULL)
17230 - return attrs = default_attrs;
17231 -
17232 - for (n = 0; default_attrs[n]; n++)
17233 - attrs[n] = default_attrs[n];
17234 + attrs = default_attrs_amd_nb;
17235
17236 if (amd_nb_has_feature(AMD_NB_L3_INDEX_DISABLE)) {
17237 attrs[n++] = &cache_disable_0.attr;
17238 @@ -1089,6 +1094,13 @@ static struct kobj_type ktype_cache = {
17239 .default_attrs = default_attrs,
17240 };
17241
17242 +#ifdef CONFIG_AMD_NB
17243 +static struct kobj_type ktype_cache_amd_nb = {
17244 + .sysfs_ops = &sysfs_ops,
17245 + .default_attrs = default_attrs_amd_nb,
17246 +};
17247 +#endif
17248 +
17249 static struct kobj_type ktype_percpu_entry = {
17250 .sysfs_ops = &sysfs_ops,
17251 };
17252 @@ -1154,20 +1166,26 @@ static int __cpuinit cache_add_dev(struct device *dev)
17253 return retval;
17254 }
17255
17256 +#ifdef CONFIG_AMD_NB
17257 + amd_l3_attrs();
17258 +#endif
17259 +
17260 for (i = 0; i < num_cache_leaves; i++) {
17261 + struct kobj_type *ktype;
17262 +
17263 this_object = INDEX_KOBJECT_PTR(cpu, i);
17264 this_object->cpu = cpu;
17265 this_object->index = i;
17266
17267 this_leaf = CPUID4_INFO_IDX(cpu, i);
17268
17269 - ktype_cache.default_attrs = default_attrs;
17270 + ktype = &ktype_cache;
17271 #ifdef CONFIG_AMD_NB
17272 if (this_leaf->base.nb)
17273 - ktype_cache.default_attrs = amd_l3_attrs();
17274 + ktype = &ktype_cache_amd_nb;
17275 #endif
17276 retval = kobject_init_and_add(&(this_object->kobj),
17277 - &ktype_cache,
17278 + ktype,
17279 per_cpu(ici_cache_kobject, cpu),
17280 "index%1lu", i);
17281 if (unlikely(retval)) {
17282 @@ -1222,7 +1240,7 @@ static int __cpuinit cacheinfo_cpu_callback(struct notifier_block *nfb,
17283 return NOTIFY_OK;
17284 }
17285
17286 -static struct notifier_block __cpuinitdata cacheinfo_cpu_notifier = {
17287 +static struct notifier_block cacheinfo_cpu_notifier = {
17288 .notifier_call = cacheinfo_cpu_callback,
17289 };
17290
17291 diff --git a/arch/x86/kernel/cpu/mcheck/mce.c b/arch/x86/kernel/cpu/mcheck/mce.c
17292 index 80dbda8..be16652 100644
17293 --- a/arch/x86/kernel/cpu/mcheck/mce.c
17294 +++ b/arch/x86/kernel/cpu/mcheck/mce.c
17295 @@ -45,6 +45,7 @@
17296 #include <asm/processor.h>
17297 #include <asm/mce.h>
17298 #include <asm/msr.h>
17299 +#include <asm/local.h>
17300
17301 #include "mce-internal.h"
17302
17303 @@ -246,7 +247,7 @@ static void print_mce(struct mce *m)
17304 !(m->mcgstatus & MCG_STATUS_EIPV) ? " !INEXACT!" : "",
17305 m->cs, m->ip);
17306
17307 - if (m->cs == __KERNEL_CS)
17308 + if (m->cs == __KERNEL_CS || m->cs == __KERNEXEC_KERNEL_CS)
17309 print_symbol("{%s}", m->ip);
17310 pr_cont("\n");
17311 }
17312 @@ -279,10 +280,10 @@ static void print_mce(struct mce *m)
17313
17314 #define PANIC_TIMEOUT 5 /* 5 seconds */
17315
17316 -static atomic_t mce_paniced;
17317 +static atomic_unchecked_t mce_paniced;
17318
17319 static int fake_panic;
17320 -static atomic_t mce_fake_paniced;
17321 +static atomic_unchecked_t mce_fake_paniced;
17322
17323 /* Panic in progress. Enable interrupts and wait for final IPI */
17324 static void wait_for_panic(void)
17325 @@ -306,7 +307,7 @@ static void mce_panic(char *msg, struct mce *final, char *exp)
17326 /*
17327 * Make sure only one CPU runs in machine check panic
17328 */
17329 - if (atomic_inc_return(&mce_paniced) > 1)
17330 + if (atomic_inc_return_unchecked(&mce_paniced) > 1)
17331 wait_for_panic();
17332 barrier();
17333
17334 @@ -314,7 +315,7 @@ static void mce_panic(char *msg, struct mce *final, char *exp)
17335 console_verbose();
17336 } else {
17337 /* Don't log too much for fake panic */
17338 - if (atomic_inc_return(&mce_fake_paniced) > 1)
17339 + if (atomic_inc_return_unchecked(&mce_fake_paniced) > 1)
17340 return;
17341 }
17342 /* First print corrected ones that are still unlogged */
17343 @@ -686,7 +687,7 @@ static int mce_timed_out(u64 *t)
17344 * might have been modified by someone else.
17345 */
17346 rmb();
17347 - if (atomic_read(&mce_paniced))
17348 + if (atomic_read_unchecked(&mce_paniced))
17349 wait_for_panic();
17350 if (!mca_cfg.monarch_timeout)
17351 goto out;
17352 @@ -1662,7 +1663,7 @@ static void unexpected_machine_check(struct pt_regs *regs, long error_code)
17353 }
17354
17355 /* Call the installed machine check handler for this CPU setup. */
17356 -void (*machine_check_vector)(struct pt_regs *, long error_code) =
17357 +void (*machine_check_vector)(struct pt_regs *, long error_code) __read_only =
17358 unexpected_machine_check;
17359
17360 /*
17361 @@ -1685,7 +1686,9 @@ void __cpuinit mcheck_cpu_init(struct cpuinfo_x86 *c)
17362 return;
17363 }
17364
17365 + pax_open_kernel();
17366 machine_check_vector = do_machine_check;
17367 + pax_close_kernel();
17368
17369 __mcheck_cpu_init_generic();
17370 __mcheck_cpu_init_vendor(c);
17371 @@ -1699,7 +1702,7 @@ void __cpuinit mcheck_cpu_init(struct cpuinfo_x86 *c)
17372 */
17373
17374 static DEFINE_SPINLOCK(mce_chrdev_state_lock);
17375 -static int mce_chrdev_open_count; /* #times opened */
17376 +static local_t mce_chrdev_open_count; /* #times opened */
17377 static int mce_chrdev_open_exclu; /* already open exclusive? */
17378
17379 static int mce_chrdev_open(struct inode *inode, struct file *file)
17380 @@ -1707,7 +1710,7 @@ static int mce_chrdev_open(struct inode *inode, struct file *file)
17381 spin_lock(&mce_chrdev_state_lock);
17382
17383 if (mce_chrdev_open_exclu ||
17384 - (mce_chrdev_open_count && (file->f_flags & O_EXCL))) {
17385 + (local_read(&mce_chrdev_open_count) && (file->f_flags & O_EXCL))) {
17386 spin_unlock(&mce_chrdev_state_lock);
17387
17388 return -EBUSY;
17389 @@ -1715,7 +1718,7 @@ static int mce_chrdev_open(struct inode *inode, struct file *file)
17390
17391 if (file->f_flags & O_EXCL)
17392 mce_chrdev_open_exclu = 1;
17393 - mce_chrdev_open_count++;
17394 + local_inc(&mce_chrdev_open_count);
17395
17396 spin_unlock(&mce_chrdev_state_lock);
17397
17398 @@ -1726,7 +1729,7 @@ static int mce_chrdev_release(struct inode *inode, struct file *file)
17399 {
17400 spin_lock(&mce_chrdev_state_lock);
17401
17402 - mce_chrdev_open_count--;
17403 + local_dec(&mce_chrdev_open_count);
17404 mce_chrdev_open_exclu = 0;
17405
17406 spin_unlock(&mce_chrdev_state_lock);
17407 @@ -2372,7 +2375,7 @@ mce_cpu_callback(struct notifier_block *nfb, unsigned long action, void *hcpu)
17408 return NOTIFY_OK;
17409 }
17410
17411 -static struct notifier_block mce_cpu_notifier __cpuinitdata = {
17412 +static struct notifier_block mce_cpu_notifier = {
17413 .notifier_call = mce_cpu_callback,
17414 };
17415
17416 @@ -2382,7 +2385,7 @@ static __init void mce_init_banks(void)
17417
17418 for (i = 0; i < mca_cfg.banks; i++) {
17419 struct mce_bank *b = &mce_banks[i];
17420 - struct device_attribute *a = &b->attr;
17421 + device_attribute_no_const *a = &b->attr;
17422
17423 sysfs_attr_init(&a->attr);
17424 a->attr.name = b->attrname;
17425 @@ -2450,7 +2453,7 @@ struct dentry *mce_get_debugfs_dir(void)
17426 static void mce_reset(void)
17427 {
17428 cpu_missing = 0;
17429 - atomic_set(&mce_fake_paniced, 0);
17430 + atomic_set_unchecked(&mce_fake_paniced, 0);
17431 atomic_set(&mce_executing, 0);
17432 atomic_set(&mce_callin, 0);
17433 atomic_set(&global_nwo, 0);
17434 diff --git a/arch/x86/kernel/cpu/mcheck/p5.c b/arch/x86/kernel/cpu/mcheck/p5.c
17435 index 2d5454c..51987eb 100644
17436 --- a/arch/x86/kernel/cpu/mcheck/p5.c
17437 +++ b/arch/x86/kernel/cpu/mcheck/p5.c
17438 @@ -11,6 +11,7 @@
17439 #include <asm/processor.h>
17440 #include <asm/mce.h>
17441 #include <asm/msr.h>
17442 +#include <asm/pgtable.h>
17443
17444 /* By default disabled */
17445 int mce_p5_enabled __read_mostly;
17446 @@ -49,7 +50,9 @@ void intel_p5_mcheck_init(struct cpuinfo_x86 *c)
17447 if (!cpu_has(c, X86_FEATURE_MCE))
17448 return;
17449
17450 + pax_open_kernel();
17451 machine_check_vector = pentium_machine_check;
17452 + pax_close_kernel();
17453 /* Make sure the vector pointer is visible before we enable MCEs: */
17454 wmb();
17455
17456 diff --git a/arch/x86/kernel/cpu/mcheck/therm_throt.c b/arch/x86/kernel/cpu/mcheck/therm_throt.c
17457 index 47a1870..8c019a7 100644
17458 --- a/arch/x86/kernel/cpu/mcheck/therm_throt.c
17459 +++ b/arch/x86/kernel/cpu/mcheck/therm_throt.c
17460 @@ -288,7 +288,7 @@ thermal_throttle_cpu_callback(struct notifier_block *nfb,
17461 return notifier_from_errno(err);
17462 }
17463
17464 -static struct notifier_block thermal_throttle_cpu_notifier __cpuinitdata =
17465 +static struct notifier_block thermal_throttle_cpu_notifier =
17466 {
17467 .notifier_call = thermal_throttle_cpu_callback,
17468 };
17469 diff --git a/arch/x86/kernel/cpu/mcheck/winchip.c b/arch/x86/kernel/cpu/mcheck/winchip.c
17470 index 2d7998f..17c9de1 100644
17471 --- a/arch/x86/kernel/cpu/mcheck/winchip.c
17472 +++ b/arch/x86/kernel/cpu/mcheck/winchip.c
17473 @@ -10,6 +10,7 @@
17474 #include <asm/processor.h>
17475 #include <asm/mce.h>
17476 #include <asm/msr.h>
17477 +#include <asm/pgtable.h>
17478
17479 /* Machine check handler for WinChip C6: */
17480 static void winchip_machine_check(struct pt_regs *regs, long error_code)
17481 @@ -23,7 +24,9 @@ void winchip_mcheck_init(struct cpuinfo_x86 *c)
17482 {
17483 u32 lo, hi;
17484
17485 + pax_open_kernel();
17486 machine_check_vector = winchip_machine_check;
17487 + pax_close_kernel();
17488 /* Make sure the vector pointer is visible before we enable MCEs: */
17489 wmb();
17490
17491 diff --git a/arch/x86/kernel/cpu/mtrr/main.c b/arch/x86/kernel/cpu/mtrr/main.c
17492 index 726bf96..81f0526 100644
17493 --- a/arch/x86/kernel/cpu/mtrr/main.c
17494 +++ b/arch/x86/kernel/cpu/mtrr/main.c
17495 @@ -62,7 +62,7 @@ static DEFINE_MUTEX(mtrr_mutex);
17496 u64 size_or_mask, size_and_mask;
17497 static bool mtrr_aps_delayed_init;
17498
17499 -static const struct mtrr_ops *mtrr_ops[X86_VENDOR_NUM];
17500 +static const struct mtrr_ops *mtrr_ops[X86_VENDOR_NUM] __read_only;
17501
17502 const struct mtrr_ops *mtrr_if;
17503
17504 diff --git a/arch/x86/kernel/cpu/mtrr/mtrr.h b/arch/x86/kernel/cpu/mtrr/mtrr.h
17505 index df5e41f..816c719 100644
17506 --- a/arch/x86/kernel/cpu/mtrr/mtrr.h
17507 +++ b/arch/x86/kernel/cpu/mtrr/mtrr.h
17508 @@ -25,7 +25,7 @@ struct mtrr_ops {
17509 int (*validate_add_page)(unsigned long base, unsigned long size,
17510 unsigned int type);
17511 int (*have_wrcomb)(void);
17512 -};
17513 +} __do_const;
17514
17515 extern int generic_get_free_region(unsigned long base, unsigned long size,
17516 int replace_reg);
17517 diff --git a/arch/x86/kernel/cpu/perf_event.c b/arch/x86/kernel/cpu/perf_event.c
17518 index 6774c17..72c1b22 100644
17519 --- a/arch/x86/kernel/cpu/perf_event.c
17520 +++ b/arch/x86/kernel/cpu/perf_event.c
17521 @@ -1305,7 +1305,7 @@ static void __init pmu_check_apic(void)
17522 pr_info("no hardware sampling interrupt available.\n");
17523 }
17524
17525 -static struct attribute_group x86_pmu_format_group = {
17526 +static attribute_group_no_const x86_pmu_format_group = {
17527 .name = "format",
17528 .attrs = NULL,
17529 };
17530 @@ -1313,7 +1313,7 @@ static struct attribute_group x86_pmu_format_group = {
17531 struct perf_pmu_events_attr {
17532 struct device_attribute attr;
17533 u64 id;
17534 -};
17535 +} __do_const;
17536
17537 /*
17538 * Remove all undefined events (x86_pmu.event_map(id) == 0)
17539 @@ -1381,7 +1381,7 @@ static struct attribute *events_attr[] = {
17540 NULL,
17541 };
17542
17543 -static struct attribute_group x86_pmu_events_group = {
17544 +static attribute_group_no_const x86_pmu_events_group = {
17545 .name = "events",
17546 .attrs = events_attr,
17547 };
17548 @@ -1880,7 +1880,7 @@ static unsigned long get_segment_base(unsigned int segment)
17549 if (idx > GDT_ENTRIES)
17550 return 0;
17551
17552 - desc = __this_cpu_ptr(&gdt_page.gdt[0]);
17553 + desc = get_cpu_gdt_table(smp_processor_id());
17554 }
17555
17556 return get_desc_base(desc + idx);
17557 @@ -1970,7 +1970,7 @@ perf_callchain_user(struct perf_callchain_entry *entry, struct pt_regs *regs)
17558 break;
17559
17560 perf_callchain_store(entry, frame.return_address);
17561 - fp = frame.next_frame;
17562 + fp = (const void __force_user *)frame.next_frame;
17563 }
17564 }
17565
17566 diff --git a/arch/x86/kernel/cpu/perf_event_intel.c b/arch/x86/kernel/cpu/perf_event_intel.c
17567 index 4914e94..60b06e3 100644
17568 --- a/arch/x86/kernel/cpu/perf_event_intel.c
17569 +++ b/arch/x86/kernel/cpu/perf_event_intel.c
17570 @@ -1958,10 +1958,10 @@ __init int intel_pmu_init(void)
17571 * v2 and above have a perf capabilities MSR
17572 */
17573 if (version > 1) {
17574 - u64 capabilities;
17575 + u64 capabilities = x86_pmu.intel_cap.capabilities;
17576
17577 - rdmsrl(MSR_IA32_PERF_CAPABILITIES, capabilities);
17578 - x86_pmu.intel_cap.capabilities = capabilities;
17579 + if (rdmsrl_safe(MSR_IA32_PERF_CAPABILITIES, &x86_pmu.intel_cap.capabilities))
17580 + x86_pmu.intel_cap.capabilities = capabilities;
17581 }
17582
17583 intel_ds_init();
17584 diff --git a/arch/x86/kernel/cpu/perf_event_intel_uncore.c b/arch/x86/kernel/cpu/perf_event_intel_uncore.c
17585 index b43200d..d235b3e 100644
17586 --- a/arch/x86/kernel/cpu/perf_event_intel_uncore.c
17587 +++ b/arch/x86/kernel/cpu/perf_event_intel_uncore.c
17588 @@ -2428,7 +2428,7 @@ static void __init uncore_types_exit(struct intel_uncore_type **types)
17589 static int __init uncore_type_init(struct intel_uncore_type *type)
17590 {
17591 struct intel_uncore_pmu *pmus;
17592 - struct attribute_group *events_group;
17593 + attribute_group_no_const *attr_group;
17594 struct attribute **attrs;
17595 int i, j;
17596
17597 @@ -2455,19 +2455,19 @@ static int __init uncore_type_init(struct intel_uncore_type *type)
17598 while (type->event_descs[i].attr.attr.name)
17599 i++;
17600
17601 - events_group = kzalloc(sizeof(struct attribute *) * (i + 1) +
17602 - sizeof(*events_group), GFP_KERNEL);
17603 - if (!events_group)
17604 + attr_group = kzalloc(sizeof(struct attribute *) * (i + 1) +
17605 + sizeof(*attr_group), GFP_KERNEL);
17606 + if (!attr_group)
17607 goto fail;
17608
17609 - attrs = (struct attribute **)(events_group + 1);
17610 - events_group->name = "events";
17611 - events_group->attrs = attrs;
17612 + attrs = (struct attribute **)(attr_group + 1);
17613 + attr_group->name = "events";
17614 + attr_group->attrs = attrs;
17615
17616 for (j = 0; j < i; j++)
17617 attrs[j] = &type->event_descs[j].attr.attr;
17618
17619 - type->events_group = events_group;
17620 + type->events_group = attr_group;
17621 }
17622
17623 type->pmu_group = &uncore_pmu_attr_group;
17624 @@ -2826,7 +2826,7 @@ static int
17625 return NOTIFY_OK;
17626 }
17627
17628 -static struct notifier_block uncore_cpu_nb __cpuinitdata = {
17629 +static struct notifier_block uncore_cpu_nb = {
17630 .notifier_call = uncore_cpu_notifier,
17631 /*
17632 * to migrate uncore events, our notifier should be executed
17633 diff --git a/arch/x86/kernel/cpu/perf_event_intel_uncore.h b/arch/x86/kernel/cpu/perf_event_intel_uncore.h
17634 index e68a455..975a932 100644
17635 --- a/arch/x86/kernel/cpu/perf_event_intel_uncore.h
17636 +++ b/arch/x86/kernel/cpu/perf_event_intel_uncore.h
17637 @@ -428,7 +428,7 @@ struct intel_uncore_box {
17638 struct uncore_event_desc {
17639 struct kobj_attribute attr;
17640 const char *config;
17641 -};
17642 +} __do_const;
17643
17644 #define INTEL_UNCORE_EVENT_DESC(_name, _config) \
17645 { \
17646 diff --git a/arch/x86/kernel/cpuid.c b/arch/x86/kernel/cpuid.c
17647 index 60c7891..9e911d3 100644
17648 --- a/arch/x86/kernel/cpuid.c
17649 +++ b/arch/x86/kernel/cpuid.c
17650 @@ -171,7 +171,7 @@ static int __cpuinit cpuid_class_cpu_callback(struct notifier_block *nfb,
17651 return notifier_from_errno(err);
17652 }
17653
17654 -static struct notifier_block __refdata cpuid_class_cpu_notifier =
17655 +static struct notifier_block cpuid_class_cpu_notifier =
17656 {
17657 .notifier_call = cpuid_class_cpu_callback,
17658 };
17659 diff --git a/arch/x86/kernel/crash.c b/arch/x86/kernel/crash.c
17660 index 74467fe..18793d5 100644
17661 --- a/arch/x86/kernel/crash.c
17662 +++ b/arch/x86/kernel/crash.c
17663 @@ -58,10 +58,8 @@ static void kdump_nmi_callback(int cpu, struct pt_regs *regs)
17664 {
17665 #ifdef CONFIG_X86_32
17666 struct pt_regs fixed_regs;
17667 -#endif
17668
17669 -#ifdef CONFIG_X86_32
17670 - if (!user_mode_vm(regs)) {
17671 + if (!user_mode(regs)) {
17672 crash_fixup_ss_esp(&fixed_regs, regs);
17673 regs = &fixed_regs;
17674 }
17675 diff --git a/arch/x86/kernel/doublefault_32.c b/arch/x86/kernel/doublefault_32.c
17676 index 37250fe..bf2ec74 100644
17677 --- a/arch/x86/kernel/doublefault_32.c
17678 +++ b/arch/x86/kernel/doublefault_32.c
17679 @@ -11,7 +11,7 @@
17680
17681 #define DOUBLEFAULT_STACKSIZE (1024)
17682 static unsigned long doublefault_stack[DOUBLEFAULT_STACKSIZE];
17683 -#define STACK_START (unsigned long)(doublefault_stack+DOUBLEFAULT_STACKSIZE)
17684 +#define STACK_START (unsigned long)(doublefault_stack+DOUBLEFAULT_STACKSIZE-2)
17685
17686 #define ptr_ok(x) ((x) > PAGE_OFFSET && (x) < PAGE_OFFSET + MAXMEM)
17687
17688 @@ -21,7 +21,7 @@ static void doublefault_fn(void)
17689 unsigned long gdt, tss;
17690
17691 store_gdt(&gdt_desc);
17692 - gdt = gdt_desc.address;
17693 + gdt = (unsigned long)gdt_desc.address;
17694
17695 printk(KERN_EMERG "PANIC: double fault, gdt at %08lx [%d bytes]\n", gdt, gdt_desc.size);
17696
17697 @@ -58,10 +58,10 @@ struct tss_struct doublefault_tss __cacheline_aligned = {
17698 /* 0x2 bit is always set */
17699 .flags = X86_EFLAGS_SF | 0x2,
17700 .sp = STACK_START,
17701 - .es = __USER_DS,
17702 + .es = __KERNEL_DS,
17703 .cs = __KERNEL_CS,
17704 .ss = __KERNEL_DS,
17705 - .ds = __USER_DS,
17706 + .ds = __KERNEL_DS,
17707 .fs = __KERNEL_PERCPU,
17708
17709 .__cr3 = __pa_nodebug(swapper_pg_dir),
17710 diff --git a/arch/x86/kernel/dumpstack.c b/arch/x86/kernel/dumpstack.c
17711 index ae42418b..787c16b 100644
17712 --- a/arch/x86/kernel/dumpstack.c
17713 +++ b/arch/x86/kernel/dumpstack.c
17714 @@ -2,6 +2,9 @@
17715 * Copyright (C) 1991, 1992 Linus Torvalds
17716 * Copyright (C) 2000, 2001, 2002 Andi Kleen, SuSE Labs
17717 */
17718 +#ifdef CONFIG_GRKERNSEC_HIDESYM
17719 +#define __INCLUDED_BY_HIDESYM 1
17720 +#endif
17721 #include <linux/kallsyms.h>
17722 #include <linux/kprobes.h>
17723 #include <linux/uaccess.h>
17724 @@ -35,16 +38,14 @@ void printk_address(unsigned long address, int reliable)
17725 static void
17726 print_ftrace_graph_addr(unsigned long addr, void *data,
17727 const struct stacktrace_ops *ops,
17728 - struct thread_info *tinfo, int *graph)
17729 + struct task_struct *task, int *graph)
17730 {
17731 - struct task_struct *task;
17732 unsigned long ret_addr;
17733 int index;
17734
17735 if (addr != (unsigned long)return_to_handler)
17736 return;
17737
17738 - task = tinfo->task;
17739 index = task->curr_ret_stack;
17740
17741 if (!task->ret_stack || index < *graph)
17742 @@ -61,7 +62,7 @@ print_ftrace_graph_addr(unsigned long addr, void *data,
17743 static inline void
17744 print_ftrace_graph_addr(unsigned long addr, void *data,
17745 const struct stacktrace_ops *ops,
17746 - struct thread_info *tinfo, int *graph)
17747 + struct task_struct *task, int *graph)
17748 { }
17749 #endif
17750
17751 @@ -72,10 +73,8 @@ print_ftrace_graph_addr(unsigned long addr, void *data,
17752 * severe exception (double fault, nmi, stack fault, debug, mce) hardware stack
17753 */
17754
17755 -static inline int valid_stack_ptr(struct thread_info *tinfo,
17756 - void *p, unsigned int size, void *end)
17757 +static inline int valid_stack_ptr(void *t, void *p, unsigned int size, void *end)
17758 {
17759 - void *t = tinfo;
17760 if (end) {
17761 if (p < end && p >= (end-THREAD_SIZE))
17762 return 1;
17763 @@ -86,14 +85,14 @@ static inline int valid_stack_ptr(struct thread_info *tinfo,
17764 }
17765
17766 unsigned long
17767 -print_context_stack(struct thread_info *tinfo,
17768 +print_context_stack(struct task_struct *task, void *stack_start,
17769 unsigned long *stack, unsigned long bp,
17770 const struct stacktrace_ops *ops, void *data,
17771 unsigned long *end, int *graph)
17772 {
17773 struct stack_frame *frame = (struct stack_frame *)bp;
17774
17775 - while (valid_stack_ptr(tinfo, stack, sizeof(*stack), end)) {
17776 + while (valid_stack_ptr(stack_start, stack, sizeof(*stack), end)) {
17777 unsigned long addr;
17778
17779 addr = *stack;
17780 @@ -105,7 +104,7 @@ print_context_stack(struct thread_info *tinfo,
17781 } else {
17782 ops->address(data, addr, 0);
17783 }
17784 - print_ftrace_graph_addr(addr, data, ops, tinfo, graph);
17785 + print_ftrace_graph_addr(addr, data, ops, task, graph);
17786 }
17787 stack++;
17788 }
17789 @@ -114,7 +113,7 @@ print_context_stack(struct thread_info *tinfo,
17790 EXPORT_SYMBOL_GPL(print_context_stack);
17791
17792 unsigned long
17793 -print_context_stack_bp(struct thread_info *tinfo,
17794 +print_context_stack_bp(struct task_struct *task, void *stack_start,
17795 unsigned long *stack, unsigned long bp,
17796 const struct stacktrace_ops *ops, void *data,
17797 unsigned long *end, int *graph)
17798 @@ -122,7 +121,7 @@ print_context_stack_bp(struct thread_info *tinfo,
17799 struct stack_frame *frame = (struct stack_frame *)bp;
17800 unsigned long *ret_addr = &frame->return_address;
17801
17802 - while (valid_stack_ptr(tinfo, ret_addr, sizeof(*ret_addr), end)) {
17803 + while (valid_stack_ptr(stack_start, ret_addr, sizeof(*ret_addr), end)) {
17804 unsigned long addr = *ret_addr;
17805
17806 if (!__kernel_text_address(addr))
17807 @@ -131,7 +130,7 @@ print_context_stack_bp(struct thread_info *tinfo,
17808 ops->address(data, addr, 1);
17809 frame = frame->next_frame;
17810 ret_addr = &frame->return_address;
17811 - print_ftrace_graph_addr(addr, data, ops, tinfo, graph);
17812 + print_ftrace_graph_addr(addr, data, ops, task, graph);
17813 }
17814
17815 return (unsigned long)frame;
17816 @@ -189,7 +188,7 @@ void dump_stack(void)
17817
17818 bp = stack_frame(current, NULL);
17819 printk("Pid: %d, comm: %.20s %s %s %.*s\n",
17820 - current->pid, current->comm, print_tainted(),
17821 + task_pid_nr(current), current->comm, print_tainted(),
17822 init_utsname()->release,
17823 (int)strcspn(init_utsname()->version, " "),
17824 init_utsname()->version);
17825 @@ -225,6 +224,8 @@ unsigned __kprobes long oops_begin(void)
17826 }
17827 EXPORT_SYMBOL_GPL(oops_begin);
17828
17829 +extern void gr_handle_kernel_exploit(void);
17830 +
17831 void __kprobes oops_end(unsigned long flags, struct pt_regs *regs, int signr)
17832 {
17833 if (regs && kexec_should_crash(current))
17834 @@ -246,7 +247,10 @@ void __kprobes oops_end(unsigned long flags, struct pt_regs *regs, int signr)
17835 panic("Fatal exception in interrupt");
17836 if (panic_on_oops)
17837 panic("Fatal exception");
17838 - do_exit(signr);
17839 +
17840 + gr_handle_kernel_exploit();
17841 +
17842 + do_group_exit(signr);
17843 }
17844
17845 int __kprobes __die(const char *str, struct pt_regs *regs, long err)
17846 @@ -274,7 +278,7 @@ int __kprobes __die(const char *str, struct pt_regs *regs, long err)
17847 print_modules();
17848 show_regs(regs);
17849 #ifdef CONFIG_X86_32
17850 - if (user_mode_vm(regs)) {
17851 + if (user_mode(regs)) {
17852 sp = regs->sp;
17853 ss = regs->ss & 0xffff;
17854 } else {
17855 @@ -302,7 +306,7 @@ void die(const char *str, struct pt_regs *regs, long err)
17856 unsigned long flags = oops_begin();
17857 int sig = SIGSEGV;
17858
17859 - if (!user_mode_vm(regs))
17860 + if (!user_mode(regs))
17861 report_bug(regs->ip, regs);
17862
17863 if (__die(str, regs, err))
17864 diff --git a/arch/x86/kernel/dumpstack_32.c b/arch/x86/kernel/dumpstack_32.c
17865 index 1038a41..db2c12b 100644
17866 --- a/arch/x86/kernel/dumpstack_32.c
17867 +++ b/arch/x86/kernel/dumpstack_32.c
17868 @@ -38,15 +38,13 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
17869 bp = stack_frame(task, regs);
17870
17871 for (;;) {
17872 - struct thread_info *context;
17873 + void *stack_start = (void *)((unsigned long)stack & ~(THREAD_SIZE-1));
17874
17875 - context = (struct thread_info *)
17876 - ((unsigned long)stack & (~(THREAD_SIZE - 1)));
17877 - bp = ops->walk_stack(context, stack, bp, ops, data, NULL, &graph);
17878 + bp = ops->walk_stack(task, stack_start, stack, bp, ops, data, NULL, &graph);
17879
17880 - stack = (unsigned long *)context->previous_esp;
17881 - if (!stack)
17882 + if (stack_start == task_stack_page(task))
17883 break;
17884 + stack = *(unsigned long **)stack_start;
17885 if (ops->stack(data, "IRQ") < 0)
17886 break;
17887 touch_nmi_watchdog();
17888 @@ -86,7 +84,7 @@ void show_regs(struct pt_regs *regs)
17889 {
17890 int i;
17891
17892 - __show_regs(regs, !user_mode_vm(regs));
17893 + __show_regs(regs, !user_mode(regs));
17894
17895 pr_emerg("Process %.*s (pid: %d, ti=%p task=%p task.ti=%p)\n",
17896 TASK_COMM_LEN, current->comm, task_pid_nr(current),
17897 @@ -95,21 +93,22 @@ void show_regs(struct pt_regs *regs)
17898 * When in-kernel, we also print out the stack and code at the
17899 * time of the fault..
17900 */
17901 - if (!user_mode_vm(regs)) {
17902 + if (!user_mode(regs)) {
17903 unsigned int code_prologue = code_bytes * 43 / 64;
17904 unsigned int code_len = code_bytes;
17905 unsigned char c;
17906 u8 *ip;
17907 + unsigned long cs_base = get_desc_base(&get_cpu_gdt_table(0)[(0xffff & regs->cs) >> 3]);
17908
17909 pr_emerg("Stack:\n");
17910 show_stack_log_lvl(NULL, regs, &regs->sp, 0, KERN_EMERG);
17911
17912 pr_emerg("Code:");
17913
17914 - ip = (u8 *)regs->ip - code_prologue;
17915 + ip = (u8 *)regs->ip - code_prologue + cs_base;
17916 if (ip < (u8 *)PAGE_OFFSET || probe_kernel_address(ip, c)) {
17917 /* try starting at IP */
17918 - ip = (u8 *)regs->ip;
17919 + ip = (u8 *)regs->ip + cs_base;
17920 code_len = code_len - code_prologue + 1;
17921 }
17922 for (i = 0; i < code_len; i++, ip++) {
17923 @@ -118,7 +117,7 @@ void show_regs(struct pt_regs *regs)
17924 pr_cont(" Bad EIP value.");
17925 break;
17926 }
17927 - if (ip == (u8 *)regs->ip)
17928 + if (ip == (u8 *)regs->ip + cs_base)
17929 pr_cont(" <%02x>", c);
17930 else
17931 pr_cont(" %02x", c);
17932 @@ -131,6 +130,7 @@ int is_valid_bugaddr(unsigned long ip)
17933 {
17934 unsigned short ud2;
17935
17936 + ip = ktla_ktva(ip);
17937 if (ip < PAGE_OFFSET)
17938 return 0;
17939 if (probe_kernel_address((unsigned short *)ip, ud2))
17940 @@ -138,3 +138,15 @@ int is_valid_bugaddr(unsigned long ip)
17941
17942 return ud2 == 0x0b0f;
17943 }
17944 +
17945 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
17946 +void pax_check_alloca(unsigned long size)
17947 +{
17948 + unsigned long sp = (unsigned long)&sp, stack_left;
17949 +
17950 + /* all kernel stacks are of the same size */
17951 + stack_left = sp & (THREAD_SIZE - 1);
17952 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
17953 +}
17954 +EXPORT_SYMBOL(pax_check_alloca);
17955 +#endif
17956 diff --git a/arch/x86/kernel/dumpstack_64.c b/arch/x86/kernel/dumpstack_64.c
17957 index b653675..51cc8c0 100644
17958 --- a/arch/x86/kernel/dumpstack_64.c
17959 +++ b/arch/x86/kernel/dumpstack_64.c
17960 @@ -119,9 +119,9 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
17961 unsigned long *irq_stack_end =
17962 (unsigned long *)per_cpu(irq_stack_ptr, cpu);
17963 unsigned used = 0;
17964 - struct thread_info *tinfo;
17965 int graph = 0;
17966 unsigned long dummy;
17967 + void *stack_start;
17968
17969 if (!task)
17970 task = current;
17971 @@ -142,10 +142,10 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
17972 * current stack address. If the stacks consist of nested
17973 * exceptions
17974 */
17975 - tinfo = task_thread_info(task);
17976 for (;;) {
17977 char *id;
17978 unsigned long *estack_end;
17979 +
17980 estack_end = in_exception_stack(cpu, (unsigned long)stack,
17981 &used, &id);
17982
17983 @@ -153,7 +153,7 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
17984 if (ops->stack(data, id) < 0)
17985 break;
17986
17987 - bp = ops->walk_stack(tinfo, stack, bp, ops,
17988 + bp = ops->walk_stack(task, estack_end - EXCEPTION_STKSZ, stack, bp, ops,
17989 data, estack_end, &graph);
17990 ops->stack(data, "<EOE>");
17991 /*
17992 @@ -161,6 +161,8 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
17993 * second-to-last pointer (index -2 to end) in the
17994 * exception stack:
17995 */
17996 + if ((u16)estack_end[-1] != __KERNEL_DS)
17997 + goto out;
17998 stack = (unsigned long *) estack_end[-2];
17999 continue;
18000 }
18001 @@ -172,7 +174,7 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
18002 if (in_irq_stack(stack, irq_stack, irq_stack_end)) {
18003 if (ops->stack(data, "IRQ") < 0)
18004 break;
18005 - bp = ops->walk_stack(tinfo, stack, bp,
18006 + bp = ops->walk_stack(task, irq_stack, stack, bp,
18007 ops, data, irq_stack_end, &graph);
18008 /*
18009 * We link to the next stack (which would be
18010 @@ -191,7 +193,9 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
18011 /*
18012 * This handles the process stack:
18013 */
18014 - bp = ops->walk_stack(tinfo, stack, bp, ops, data, NULL, &graph);
18015 + stack_start = (void *)((unsigned long)stack & ~(THREAD_SIZE-1));
18016 + bp = ops->walk_stack(task, stack_start, stack, bp, ops, data, NULL, &graph);
18017 +out:
18018 put_cpu();
18019 }
18020 EXPORT_SYMBOL(dump_trace);
18021 @@ -249,7 +253,7 @@ void show_regs(struct pt_regs *regs)
18022 {
18023 int i;
18024 unsigned long sp;
18025 - const int cpu = smp_processor_id();
18026 + const int cpu = raw_smp_processor_id();
18027 struct task_struct *cur = current;
18028
18029 sp = regs->sp;
18030 @@ -304,3 +308,50 @@ int is_valid_bugaddr(unsigned long ip)
18031
18032 return ud2 == 0x0b0f;
18033 }
18034 +
18035 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
18036 +void pax_check_alloca(unsigned long size)
18037 +{
18038 + unsigned long sp = (unsigned long)&sp, stack_start, stack_end;
18039 + unsigned cpu, used;
18040 + char *id;
18041 +
18042 + /* check the process stack first */
18043 + stack_start = (unsigned long)task_stack_page(current);
18044 + stack_end = stack_start + THREAD_SIZE;
18045 + if (likely(stack_start <= sp && sp < stack_end)) {
18046 + unsigned long stack_left = sp & (THREAD_SIZE - 1);
18047 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
18048 + return;
18049 + }
18050 +
18051 + cpu = get_cpu();
18052 +
18053 + /* check the irq stacks */
18054 + stack_end = (unsigned long)per_cpu(irq_stack_ptr, cpu);
18055 + stack_start = stack_end - IRQ_STACK_SIZE;
18056 + if (stack_start <= sp && sp < stack_end) {
18057 + unsigned long stack_left = sp & (IRQ_STACK_SIZE - 1);
18058 + put_cpu();
18059 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
18060 + return;
18061 + }
18062 +
18063 + /* check the exception stacks */
18064 + used = 0;
18065 + stack_end = (unsigned long)in_exception_stack(cpu, sp, &used, &id);
18066 + stack_start = stack_end - EXCEPTION_STKSZ;
18067 + if (stack_end && stack_start <= sp && sp < stack_end) {
18068 + unsigned long stack_left = sp & (EXCEPTION_STKSZ - 1);
18069 + put_cpu();
18070 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
18071 + return;
18072 + }
18073 +
18074 + put_cpu();
18075 +
18076 + /* unknown stack */
18077 + BUG();
18078 +}
18079 +EXPORT_SYMBOL(pax_check_alloca);
18080 +#endif
18081 diff --git a/arch/x86/kernel/early_printk.c b/arch/x86/kernel/early_printk.c
18082 index 9b9f18b..9fcaa04 100644
18083 --- a/arch/x86/kernel/early_printk.c
18084 +++ b/arch/x86/kernel/early_printk.c
18085 @@ -7,6 +7,7 @@
18086 #include <linux/pci_regs.h>
18087 #include <linux/pci_ids.h>
18088 #include <linux/errno.h>
18089 +#include <linux/sched.h>
18090 #include <asm/io.h>
18091 #include <asm/processor.h>
18092 #include <asm/fcntl.h>
18093 diff --git a/arch/x86/kernel/entry_32.S b/arch/x86/kernel/entry_32.S
18094 index 6ed91d9..6cc365b 100644
18095 --- a/arch/x86/kernel/entry_32.S
18096 +++ b/arch/x86/kernel/entry_32.S
18097 @@ -177,13 +177,153 @@
18098 /*CFI_REL_OFFSET gs, PT_GS*/
18099 .endm
18100 .macro SET_KERNEL_GS reg
18101 +
18102 +#ifdef CONFIG_CC_STACKPROTECTOR
18103 movl $(__KERNEL_STACK_CANARY), \reg
18104 +#elif defined(CONFIG_PAX_MEMORY_UDEREF)
18105 + movl $(__USER_DS), \reg
18106 +#else
18107 + xorl \reg, \reg
18108 +#endif
18109 +
18110 movl \reg, %gs
18111 .endm
18112
18113 #endif /* CONFIG_X86_32_LAZY_GS */
18114
18115 -.macro SAVE_ALL
18116 +.macro pax_enter_kernel
18117 +#ifdef CONFIG_PAX_KERNEXEC
18118 + call pax_enter_kernel
18119 +#endif
18120 +.endm
18121 +
18122 +.macro pax_exit_kernel
18123 +#ifdef CONFIG_PAX_KERNEXEC
18124 + call pax_exit_kernel
18125 +#endif
18126 +.endm
18127 +
18128 +#ifdef CONFIG_PAX_KERNEXEC
18129 +ENTRY(pax_enter_kernel)
18130 +#ifdef CONFIG_PARAVIRT
18131 + pushl %eax
18132 + pushl %ecx
18133 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_read_cr0)
18134 + mov %eax, %esi
18135 +#else
18136 + mov %cr0, %esi
18137 +#endif
18138 + bts $16, %esi
18139 + jnc 1f
18140 + mov %cs, %esi
18141 + cmp $__KERNEL_CS, %esi
18142 + jz 3f
18143 + ljmp $__KERNEL_CS, $3f
18144 +1: ljmp $__KERNEXEC_KERNEL_CS, $2f
18145 +2:
18146 +#ifdef CONFIG_PARAVIRT
18147 + mov %esi, %eax
18148 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_write_cr0)
18149 +#else
18150 + mov %esi, %cr0
18151 +#endif
18152 +3:
18153 +#ifdef CONFIG_PARAVIRT
18154 + popl %ecx
18155 + popl %eax
18156 +#endif
18157 + ret
18158 +ENDPROC(pax_enter_kernel)
18159 +
18160 +ENTRY(pax_exit_kernel)
18161 +#ifdef CONFIG_PARAVIRT
18162 + pushl %eax
18163 + pushl %ecx
18164 +#endif
18165 + mov %cs, %esi
18166 + cmp $__KERNEXEC_KERNEL_CS, %esi
18167 + jnz 2f
18168 +#ifdef CONFIG_PARAVIRT
18169 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_read_cr0);
18170 + mov %eax, %esi
18171 +#else
18172 + mov %cr0, %esi
18173 +#endif
18174 + btr $16, %esi
18175 + ljmp $__KERNEL_CS, $1f
18176 +1:
18177 +#ifdef CONFIG_PARAVIRT
18178 + mov %esi, %eax
18179 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_write_cr0);
18180 +#else
18181 + mov %esi, %cr0
18182 +#endif
18183 +2:
18184 +#ifdef CONFIG_PARAVIRT
18185 + popl %ecx
18186 + popl %eax
18187 +#endif
18188 + ret
18189 +ENDPROC(pax_exit_kernel)
18190 +#endif
18191 +
18192 +.macro pax_erase_kstack
18193 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
18194 + call pax_erase_kstack
18195 +#endif
18196 +.endm
18197 +
18198 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
18199 +/*
18200 + * ebp: thread_info
18201 + */
18202 +ENTRY(pax_erase_kstack)
18203 + pushl %edi
18204 + pushl %ecx
18205 + pushl %eax
18206 +
18207 + mov TI_lowest_stack(%ebp), %edi
18208 + mov $-0xBEEF, %eax
18209 + std
18210 +
18211 +1: mov %edi, %ecx
18212 + and $THREAD_SIZE_asm - 1, %ecx
18213 + shr $2, %ecx
18214 + repne scasl
18215 + jecxz 2f
18216 +
18217 + cmp $2*16, %ecx
18218 + jc 2f
18219 +
18220 + mov $2*16, %ecx
18221 + repe scasl
18222 + jecxz 2f
18223 + jne 1b
18224 +
18225 +2: cld
18226 + mov %esp, %ecx
18227 + sub %edi, %ecx
18228 +
18229 + cmp $THREAD_SIZE_asm, %ecx
18230 + jb 3f
18231 + ud2
18232 +3:
18233 +
18234 + shr $2, %ecx
18235 + rep stosl
18236 +
18237 + mov TI_task_thread_sp0(%ebp), %edi
18238 + sub $128, %edi
18239 + mov %edi, TI_lowest_stack(%ebp)
18240 +
18241 + popl %eax
18242 + popl %ecx
18243 + popl %edi
18244 + ret
18245 +ENDPROC(pax_erase_kstack)
18246 +#endif
18247 +
18248 +.macro __SAVE_ALL _DS
18249 cld
18250 PUSH_GS
18251 pushl_cfi %fs
18252 @@ -206,7 +346,7 @@
18253 CFI_REL_OFFSET ecx, 0
18254 pushl_cfi %ebx
18255 CFI_REL_OFFSET ebx, 0
18256 - movl $(__USER_DS), %edx
18257 + movl $\_DS, %edx
18258 movl %edx, %ds
18259 movl %edx, %es
18260 movl $(__KERNEL_PERCPU), %edx
18261 @@ -214,6 +354,15 @@
18262 SET_KERNEL_GS %edx
18263 .endm
18264
18265 +.macro SAVE_ALL
18266 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
18267 + __SAVE_ALL __KERNEL_DS
18268 + pax_enter_kernel
18269 +#else
18270 + __SAVE_ALL __USER_DS
18271 +#endif
18272 +.endm
18273 +
18274 .macro RESTORE_INT_REGS
18275 popl_cfi %ebx
18276 CFI_RESTORE ebx
18277 @@ -297,7 +446,7 @@ ENTRY(ret_from_fork)
18278 popfl_cfi
18279 jmp syscall_exit
18280 CFI_ENDPROC
18281 -END(ret_from_fork)
18282 +ENDPROC(ret_from_fork)
18283
18284 ENTRY(ret_from_kernel_thread)
18285 CFI_STARTPROC
18286 @@ -344,7 +493,15 @@ ret_from_intr:
18287 andl $SEGMENT_RPL_MASK, %eax
18288 #endif
18289 cmpl $USER_RPL, %eax
18290 +
18291 +#ifdef CONFIG_PAX_KERNEXEC
18292 + jae resume_userspace
18293 +
18294 + pax_exit_kernel
18295 + jmp resume_kernel
18296 +#else
18297 jb resume_kernel # not returning to v8086 or userspace
18298 +#endif
18299
18300 ENTRY(resume_userspace)
18301 LOCKDEP_SYS_EXIT
18302 @@ -356,8 +513,8 @@ ENTRY(resume_userspace)
18303 andl $_TIF_WORK_MASK, %ecx # is there any work to be done on
18304 # int/exception return?
18305 jne work_pending
18306 - jmp restore_all
18307 -END(ret_from_exception)
18308 + jmp restore_all_pax
18309 +ENDPROC(ret_from_exception)
18310
18311 #ifdef CONFIG_PREEMPT
18312 ENTRY(resume_kernel)
18313 @@ -372,7 +529,7 @@ need_resched:
18314 jz restore_all
18315 call preempt_schedule_irq
18316 jmp need_resched
18317 -END(resume_kernel)
18318 +ENDPROC(resume_kernel)
18319 #endif
18320 CFI_ENDPROC
18321 /*
18322 @@ -406,30 +563,45 @@ sysenter_past_esp:
18323 /*CFI_REL_OFFSET cs, 0*/
18324 /*
18325 * Push current_thread_info()->sysenter_return to the stack.
18326 - * A tiny bit of offset fixup is necessary - 4*4 means the 4 words
18327 - * pushed above; +8 corresponds to copy_thread's esp0 setting.
18328 */
18329 - pushl_cfi ((TI_sysenter_return)-THREAD_SIZE+8+4*4)(%esp)
18330 + pushl_cfi $0
18331 CFI_REL_OFFSET eip, 0
18332
18333 pushl_cfi %eax
18334 SAVE_ALL
18335 + GET_THREAD_INFO(%ebp)
18336 + movl TI_sysenter_return(%ebp),%ebp
18337 + movl %ebp,PT_EIP(%esp)
18338 ENABLE_INTERRUPTS(CLBR_NONE)
18339
18340 /*
18341 * Load the potential sixth argument from user stack.
18342 * Careful about security.
18343 */
18344 + movl PT_OLDESP(%esp),%ebp
18345 +
18346 +#ifdef CONFIG_PAX_MEMORY_UDEREF
18347 + mov PT_OLDSS(%esp),%ds
18348 +1: movl %ds:(%ebp),%ebp
18349 + push %ss
18350 + pop %ds
18351 +#else
18352 cmpl $__PAGE_OFFSET-3,%ebp
18353 jae syscall_fault
18354 ASM_STAC
18355 1: movl (%ebp),%ebp
18356 ASM_CLAC
18357 +#endif
18358 +
18359 movl %ebp,PT_EBP(%esp)
18360 _ASM_EXTABLE(1b,syscall_fault)
18361
18362 GET_THREAD_INFO(%ebp)
18363
18364 +#ifdef CONFIG_PAX_RANDKSTACK
18365 + pax_erase_kstack
18366 +#endif
18367 +
18368 testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%ebp)
18369 jnz sysenter_audit
18370 sysenter_do_call:
18371 @@ -444,12 +616,24 @@ sysenter_do_call:
18372 testl $_TIF_ALLWORK_MASK, %ecx
18373 jne sysexit_audit
18374 sysenter_exit:
18375 +
18376 +#ifdef CONFIG_PAX_RANDKSTACK
18377 + pushl_cfi %eax
18378 + movl %esp, %eax
18379 + call pax_randomize_kstack
18380 + popl_cfi %eax
18381 +#endif
18382 +
18383 + pax_erase_kstack
18384 +
18385 /* if something modifies registers it must also disable sysexit */
18386 movl PT_EIP(%esp), %edx
18387 movl PT_OLDESP(%esp), %ecx
18388 xorl %ebp,%ebp
18389 TRACE_IRQS_ON
18390 1: mov PT_FS(%esp), %fs
18391 +2: mov PT_DS(%esp), %ds
18392 +3: mov PT_ES(%esp), %es
18393 PTGS_TO_GS
18394 ENABLE_INTERRUPTS_SYSEXIT
18395
18396 @@ -466,6 +650,9 @@ sysenter_audit:
18397 movl %eax,%edx /* 2nd arg: syscall number */
18398 movl $AUDIT_ARCH_I386,%eax /* 1st arg: audit arch */
18399 call __audit_syscall_entry
18400 +
18401 + pax_erase_kstack
18402 +
18403 pushl_cfi %ebx
18404 movl PT_EAX(%esp),%eax /* reload syscall number */
18405 jmp sysenter_do_call
18406 @@ -491,10 +678,16 @@ sysexit_audit:
18407
18408 CFI_ENDPROC
18409 .pushsection .fixup,"ax"
18410 -2: movl $0,PT_FS(%esp)
18411 +4: movl $0,PT_FS(%esp)
18412 + jmp 1b
18413 +5: movl $0,PT_DS(%esp)
18414 + jmp 1b
18415 +6: movl $0,PT_ES(%esp)
18416 jmp 1b
18417 .popsection
18418 - _ASM_EXTABLE(1b,2b)
18419 + _ASM_EXTABLE(1b,4b)
18420 + _ASM_EXTABLE(2b,5b)
18421 + _ASM_EXTABLE(3b,6b)
18422 PTGS_TO_GS_EX
18423 ENDPROC(ia32_sysenter_target)
18424
18425 @@ -509,6 +702,11 @@ ENTRY(system_call)
18426 pushl_cfi %eax # save orig_eax
18427 SAVE_ALL
18428 GET_THREAD_INFO(%ebp)
18429 +
18430 +#ifdef CONFIG_PAX_RANDKSTACK
18431 + pax_erase_kstack
18432 +#endif
18433 +
18434 # system call tracing in operation / emulation
18435 testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%ebp)
18436 jnz syscall_trace_entry
18437 @@ -527,6 +725,15 @@ syscall_exit:
18438 testl $_TIF_ALLWORK_MASK, %ecx # current->work
18439 jne syscall_exit_work
18440
18441 +restore_all_pax:
18442 +
18443 +#ifdef CONFIG_PAX_RANDKSTACK
18444 + movl %esp, %eax
18445 + call pax_randomize_kstack
18446 +#endif
18447 +
18448 + pax_erase_kstack
18449 +
18450 restore_all:
18451 TRACE_IRQS_IRET
18452 restore_all_notrace:
18453 @@ -583,14 +790,34 @@ ldt_ss:
18454 * compensating for the offset by changing to the ESPFIX segment with
18455 * a base address that matches for the difference.
18456 */
18457 -#define GDT_ESPFIX_SS PER_CPU_VAR(gdt_page) + (GDT_ENTRY_ESPFIX_SS * 8)
18458 +#define GDT_ESPFIX_SS (GDT_ENTRY_ESPFIX_SS * 8)(%ebx)
18459 mov %esp, %edx /* load kernel esp */
18460 mov PT_OLDESP(%esp), %eax /* load userspace esp */
18461 mov %dx, %ax /* eax: new kernel esp */
18462 sub %eax, %edx /* offset (low word is 0) */
18463 +#ifdef CONFIG_SMP
18464 + movl PER_CPU_VAR(cpu_number), %ebx
18465 + shll $PAGE_SHIFT_asm, %ebx
18466 + addl $cpu_gdt_table, %ebx
18467 +#else
18468 + movl $cpu_gdt_table, %ebx
18469 +#endif
18470 shr $16, %edx
18471 - mov %dl, GDT_ESPFIX_SS + 4 /* bits 16..23 */
18472 - mov %dh, GDT_ESPFIX_SS + 7 /* bits 24..31 */
18473 +
18474 +#ifdef CONFIG_PAX_KERNEXEC
18475 + mov %cr0, %esi
18476 + btr $16, %esi
18477 + mov %esi, %cr0
18478 +#endif
18479 +
18480 + mov %dl, 4 + GDT_ESPFIX_SS /* bits 16..23 */
18481 + mov %dh, 7 + GDT_ESPFIX_SS /* bits 24..31 */
18482 +
18483 +#ifdef CONFIG_PAX_KERNEXEC
18484 + bts $16, %esi
18485 + mov %esi, %cr0
18486 +#endif
18487 +
18488 pushl_cfi $__ESPFIX_SS
18489 pushl_cfi %eax /* new kernel esp */
18490 /* Disable interrupts, but do not irqtrace this section: we
18491 @@ -619,20 +846,18 @@ work_resched:
18492 movl TI_flags(%ebp), %ecx
18493 andl $_TIF_WORK_MASK, %ecx # is there any work to be done other
18494 # than syscall tracing?
18495 - jz restore_all
18496 + jz restore_all_pax
18497 testb $_TIF_NEED_RESCHED, %cl
18498 jnz work_resched
18499
18500 work_notifysig: # deal with pending signals and
18501 # notify-resume requests
18502 + movl %esp, %eax
18503 #ifdef CONFIG_VM86
18504 testl $X86_EFLAGS_VM, PT_EFLAGS(%esp)
18505 - movl %esp, %eax
18506 jne work_notifysig_v86 # returning to kernel-space or
18507 # vm86-space
18508 1:
18509 -#else
18510 - movl %esp, %eax
18511 #endif
18512 TRACE_IRQS_ON
18513 ENABLE_INTERRUPTS(CLBR_NONE)
18514 @@ -653,7 +878,7 @@ work_notifysig_v86:
18515 movl %eax, %esp
18516 jmp 1b
18517 #endif
18518 -END(work_pending)
18519 +ENDPROC(work_pending)
18520
18521 # perform syscall exit tracing
18522 ALIGN
18523 @@ -661,11 +886,14 @@ syscall_trace_entry:
18524 movl $-ENOSYS,PT_EAX(%esp)
18525 movl %esp, %eax
18526 call syscall_trace_enter
18527 +
18528 + pax_erase_kstack
18529 +
18530 /* What it returned is what we'll actually use. */
18531 cmpl $(NR_syscalls), %eax
18532 jnae syscall_call
18533 jmp syscall_exit
18534 -END(syscall_trace_entry)
18535 +ENDPROC(syscall_trace_entry)
18536
18537 # perform syscall exit tracing
18538 ALIGN
18539 @@ -678,21 +906,25 @@ syscall_exit_work:
18540 movl %esp, %eax
18541 call syscall_trace_leave
18542 jmp resume_userspace
18543 -END(syscall_exit_work)
18544 +ENDPROC(syscall_exit_work)
18545 CFI_ENDPROC
18546
18547 RING0_INT_FRAME # can't unwind into user space anyway
18548 syscall_fault:
18549 +#ifdef CONFIG_PAX_MEMORY_UDEREF
18550 + push %ss
18551 + pop %ds
18552 +#endif
18553 ASM_CLAC
18554 GET_THREAD_INFO(%ebp)
18555 movl $-EFAULT,PT_EAX(%esp)
18556 jmp resume_userspace
18557 -END(syscall_fault)
18558 +ENDPROC(syscall_fault)
18559
18560 syscall_badsys:
18561 movl $-ENOSYS,PT_EAX(%esp)
18562 jmp resume_userspace
18563 -END(syscall_badsys)
18564 +ENDPROC(syscall_badsys)
18565 CFI_ENDPROC
18566 /*
18567 * End of kprobes section
18568 @@ -753,8 +985,15 @@ PTREGSCALL1(vm86old)
18569 * normal stack and adjusts ESP with the matching offset.
18570 */
18571 /* fixup the stack */
18572 - mov GDT_ESPFIX_SS + 4, %al /* bits 16..23 */
18573 - mov GDT_ESPFIX_SS + 7, %ah /* bits 24..31 */
18574 +#ifdef CONFIG_SMP
18575 + movl PER_CPU_VAR(cpu_number), %ebx
18576 + shll $PAGE_SHIFT_asm, %ebx
18577 + addl $cpu_gdt_table, %ebx
18578 +#else
18579 + movl $cpu_gdt_table, %ebx
18580 +#endif
18581 + mov 4 + GDT_ESPFIX_SS, %al /* bits 16..23 */
18582 + mov 7 + GDT_ESPFIX_SS, %ah /* bits 24..31 */
18583 shl $16, %eax
18584 addl %esp, %eax /* the adjusted stack pointer */
18585 pushl_cfi $__KERNEL_DS
18586 @@ -807,7 +1046,7 @@ vector=vector+1
18587 .endr
18588 2: jmp common_interrupt
18589 .endr
18590 -END(irq_entries_start)
18591 +ENDPROC(irq_entries_start)
18592
18593 .previous
18594 END(interrupt)
18595 @@ -858,7 +1097,7 @@ ENTRY(coprocessor_error)
18596 pushl_cfi $do_coprocessor_error
18597 jmp error_code
18598 CFI_ENDPROC
18599 -END(coprocessor_error)
18600 +ENDPROC(coprocessor_error)
18601
18602 ENTRY(simd_coprocessor_error)
18603 RING0_INT_FRAME
18604 @@ -880,7 +1119,7 @@ ENTRY(simd_coprocessor_error)
18605 #endif
18606 jmp error_code
18607 CFI_ENDPROC
18608 -END(simd_coprocessor_error)
18609 +ENDPROC(simd_coprocessor_error)
18610
18611 ENTRY(device_not_available)
18612 RING0_INT_FRAME
18613 @@ -889,18 +1128,18 @@ ENTRY(device_not_available)
18614 pushl_cfi $do_device_not_available
18615 jmp error_code
18616 CFI_ENDPROC
18617 -END(device_not_available)
18618 +ENDPROC(device_not_available)
18619
18620 #ifdef CONFIG_PARAVIRT
18621 ENTRY(native_iret)
18622 iret
18623 _ASM_EXTABLE(native_iret, iret_exc)
18624 -END(native_iret)
18625 +ENDPROC(native_iret)
18626
18627 ENTRY(native_irq_enable_sysexit)
18628 sti
18629 sysexit
18630 -END(native_irq_enable_sysexit)
18631 +ENDPROC(native_irq_enable_sysexit)
18632 #endif
18633
18634 ENTRY(overflow)
18635 @@ -910,7 +1149,7 @@ ENTRY(overflow)
18636 pushl_cfi $do_overflow
18637 jmp error_code
18638 CFI_ENDPROC
18639 -END(overflow)
18640 +ENDPROC(overflow)
18641
18642 ENTRY(bounds)
18643 RING0_INT_FRAME
18644 @@ -919,7 +1158,7 @@ ENTRY(bounds)
18645 pushl_cfi $do_bounds
18646 jmp error_code
18647 CFI_ENDPROC
18648 -END(bounds)
18649 +ENDPROC(bounds)
18650
18651 ENTRY(invalid_op)
18652 RING0_INT_FRAME
18653 @@ -928,7 +1167,7 @@ ENTRY(invalid_op)
18654 pushl_cfi $do_invalid_op
18655 jmp error_code
18656 CFI_ENDPROC
18657 -END(invalid_op)
18658 +ENDPROC(invalid_op)
18659
18660 ENTRY(coprocessor_segment_overrun)
18661 RING0_INT_FRAME
18662 @@ -937,7 +1176,7 @@ ENTRY(coprocessor_segment_overrun)
18663 pushl_cfi $do_coprocessor_segment_overrun
18664 jmp error_code
18665 CFI_ENDPROC
18666 -END(coprocessor_segment_overrun)
18667 +ENDPROC(coprocessor_segment_overrun)
18668
18669 ENTRY(invalid_TSS)
18670 RING0_EC_FRAME
18671 @@ -945,7 +1184,7 @@ ENTRY(invalid_TSS)
18672 pushl_cfi $do_invalid_TSS
18673 jmp error_code
18674 CFI_ENDPROC
18675 -END(invalid_TSS)
18676 +ENDPROC(invalid_TSS)
18677
18678 ENTRY(segment_not_present)
18679 RING0_EC_FRAME
18680 @@ -953,7 +1192,7 @@ ENTRY(segment_not_present)
18681 pushl_cfi $do_segment_not_present
18682 jmp error_code
18683 CFI_ENDPROC
18684 -END(segment_not_present)
18685 +ENDPROC(segment_not_present)
18686
18687 ENTRY(stack_segment)
18688 RING0_EC_FRAME
18689 @@ -961,7 +1200,7 @@ ENTRY(stack_segment)
18690 pushl_cfi $do_stack_segment
18691 jmp error_code
18692 CFI_ENDPROC
18693 -END(stack_segment)
18694 +ENDPROC(stack_segment)
18695
18696 ENTRY(alignment_check)
18697 RING0_EC_FRAME
18698 @@ -969,7 +1208,7 @@ ENTRY(alignment_check)
18699 pushl_cfi $do_alignment_check
18700 jmp error_code
18701 CFI_ENDPROC
18702 -END(alignment_check)
18703 +ENDPROC(alignment_check)
18704
18705 ENTRY(divide_error)
18706 RING0_INT_FRAME
18707 @@ -978,7 +1217,7 @@ ENTRY(divide_error)
18708 pushl_cfi $do_divide_error
18709 jmp error_code
18710 CFI_ENDPROC
18711 -END(divide_error)
18712 +ENDPROC(divide_error)
18713
18714 #ifdef CONFIG_X86_MCE
18715 ENTRY(machine_check)
18716 @@ -988,7 +1227,7 @@ ENTRY(machine_check)
18717 pushl_cfi machine_check_vector
18718 jmp error_code
18719 CFI_ENDPROC
18720 -END(machine_check)
18721 +ENDPROC(machine_check)
18722 #endif
18723
18724 ENTRY(spurious_interrupt_bug)
18725 @@ -998,7 +1237,7 @@ ENTRY(spurious_interrupt_bug)
18726 pushl_cfi $do_spurious_interrupt_bug
18727 jmp error_code
18728 CFI_ENDPROC
18729 -END(spurious_interrupt_bug)
18730 +ENDPROC(spurious_interrupt_bug)
18731 /*
18732 * End of kprobes section
18733 */
18734 @@ -1101,7 +1340,7 @@ BUILD_INTERRUPT3(xen_hvm_callback_vector, XEN_HVM_EVTCHN_CALLBACK,
18735
18736 ENTRY(mcount)
18737 ret
18738 -END(mcount)
18739 +ENDPROC(mcount)
18740
18741 ENTRY(ftrace_caller)
18742 cmpl $0, function_trace_stop
18743 @@ -1134,7 +1373,7 @@ ftrace_graph_call:
18744 .globl ftrace_stub
18745 ftrace_stub:
18746 ret
18747 -END(ftrace_caller)
18748 +ENDPROC(ftrace_caller)
18749
18750 ENTRY(ftrace_regs_caller)
18751 pushf /* push flags before compare (in cs location) */
18752 @@ -1235,7 +1474,7 @@ trace:
18753 popl %ecx
18754 popl %eax
18755 jmp ftrace_stub
18756 -END(mcount)
18757 +ENDPROC(mcount)
18758 #endif /* CONFIG_DYNAMIC_FTRACE */
18759 #endif /* CONFIG_FUNCTION_TRACER */
18760
18761 @@ -1253,7 +1492,7 @@ ENTRY(ftrace_graph_caller)
18762 popl %ecx
18763 popl %eax
18764 ret
18765 -END(ftrace_graph_caller)
18766 +ENDPROC(ftrace_graph_caller)
18767
18768 .globl return_to_handler
18769 return_to_handler:
18770 @@ -1309,15 +1548,18 @@ error_code:
18771 movl $-1, PT_ORIG_EAX(%esp) # no syscall to restart
18772 REG_TO_PTGS %ecx
18773 SET_KERNEL_GS %ecx
18774 - movl $(__USER_DS), %ecx
18775 + movl $(__KERNEL_DS), %ecx
18776 movl %ecx, %ds
18777 movl %ecx, %es
18778 +
18779 + pax_enter_kernel
18780 +
18781 TRACE_IRQS_OFF
18782 movl %esp,%eax # pt_regs pointer
18783 call *%edi
18784 jmp ret_from_exception
18785 CFI_ENDPROC
18786 -END(page_fault)
18787 +ENDPROC(page_fault)
18788
18789 /*
18790 * Debug traps and NMI can happen at the one SYSENTER instruction
18791 @@ -1360,7 +1602,7 @@ debug_stack_correct:
18792 call do_debug
18793 jmp ret_from_exception
18794 CFI_ENDPROC
18795 -END(debug)
18796 +ENDPROC(debug)
18797
18798 /*
18799 * NMI is doubly nasty. It can happen _while_ we're handling
18800 @@ -1398,6 +1640,9 @@ nmi_stack_correct:
18801 xorl %edx,%edx # zero error code
18802 movl %esp,%eax # pt_regs pointer
18803 call do_nmi
18804 +
18805 + pax_exit_kernel
18806 +
18807 jmp restore_all_notrace
18808 CFI_ENDPROC
18809
18810 @@ -1434,12 +1679,15 @@ nmi_espfix_stack:
18811 FIXUP_ESPFIX_STACK # %eax == %esp
18812 xorl %edx,%edx # zero error code
18813 call do_nmi
18814 +
18815 + pax_exit_kernel
18816 +
18817 RESTORE_REGS
18818 lss 12+4(%esp), %esp # back to espfix stack
18819 CFI_ADJUST_CFA_OFFSET -24
18820 jmp irq_return
18821 CFI_ENDPROC
18822 -END(nmi)
18823 +ENDPROC(nmi)
18824
18825 ENTRY(int3)
18826 RING0_INT_FRAME
18827 @@ -1452,14 +1700,14 @@ ENTRY(int3)
18828 call do_int3
18829 jmp ret_from_exception
18830 CFI_ENDPROC
18831 -END(int3)
18832 +ENDPROC(int3)
18833
18834 ENTRY(general_protection)
18835 RING0_EC_FRAME
18836 pushl_cfi $do_general_protection
18837 jmp error_code
18838 CFI_ENDPROC
18839 -END(general_protection)
18840 +ENDPROC(general_protection)
18841
18842 #ifdef CONFIG_KVM_GUEST
18843 ENTRY(async_page_fault)
18844 @@ -1468,7 +1716,7 @@ ENTRY(async_page_fault)
18845 pushl_cfi $do_async_page_fault
18846 jmp error_code
18847 CFI_ENDPROC
18848 -END(async_page_fault)
18849 +ENDPROC(async_page_fault)
18850 #endif
18851
18852 /*
18853 diff --git a/arch/x86/kernel/entry_64.S b/arch/x86/kernel/entry_64.S
18854 index cb3c591..bc63707 100644
18855 --- a/arch/x86/kernel/entry_64.S
18856 +++ b/arch/x86/kernel/entry_64.S
18857 @@ -59,6 +59,8 @@
18858 #include <asm/context_tracking.h>
18859 #include <asm/smap.h>
18860 #include <linux/err.h>
18861 +#include <asm/pgtable.h>
18862 +#include <asm/alternative-asm.h>
18863
18864 /* Avoid __ASSEMBLER__'ifying <linux/audit.h> just for this. */
18865 #include <linux/elf-em.h>
18866 @@ -80,8 +82,9 @@
18867 #ifdef CONFIG_DYNAMIC_FTRACE
18868
18869 ENTRY(function_hook)
18870 + pax_force_retaddr
18871 retq
18872 -END(function_hook)
18873 +ENDPROC(function_hook)
18874
18875 /* skip is set if stack has been adjusted */
18876 .macro ftrace_caller_setup skip=0
18877 @@ -122,8 +125,9 @@ GLOBAL(ftrace_graph_call)
18878 #endif
18879
18880 GLOBAL(ftrace_stub)
18881 + pax_force_retaddr
18882 retq
18883 -END(ftrace_caller)
18884 +ENDPROC(ftrace_caller)
18885
18886 ENTRY(ftrace_regs_caller)
18887 /* Save the current flags before compare (in SS location)*/
18888 @@ -191,7 +195,7 @@ ftrace_restore_flags:
18889 popfq
18890 jmp ftrace_stub
18891
18892 -END(ftrace_regs_caller)
18893 +ENDPROC(ftrace_regs_caller)
18894
18895
18896 #else /* ! CONFIG_DYNAMIC_FTRACE */
18897 @@ -212,6 +216,7 @@ ENTRY(function_hook)
18898 #endif
18899
18900 GLOBAL(ftrace_stub)
18901 + pax_force_retaddr
18902 retq
18903
18904 trace:
18905 @@ -225,12 +230,13 @@ trace:
18906 #endif
18907 subq $MCOUNT_INSN_SIZE, %rdi
18908
18909 + pax_force_fptr ftrace_trace_function
18910 call *ftrace_trace_function
18911
18912 MCOUNT_RESTORE_FRAME
18913
18914 jmp ftrace_stub
18915 -END(function_hook)
18916 +ENDPROC(function_hook)
18917 #endif /* CONFIG_DYNAMIC_FTRACE */
18918 #endif /* CONFIG_FUNCTION_TRACER */
18919
18920 @@ -252,8 +258,9 @@ ENTRY(ftrace_graph_caller)
18921
18922 MCOUNT_RESTORE_FRAME
18923
18924 + pax_force_retaddr
18925 retq
18926 -END(ftrace_graph_caller)
18927 +ENDPROC(ftrace_graph_caller)
18928
18929 GLOBAL(return_to_handler)
18930 subq $24, %rsp
18931 @@ -269,7 +276,9 @@ GLOBAL(return_to_handler)
18932 movq 8(%rsp), %rdx
18933 movq (%rsp), %rax
18934 addq $24, %rsp
18935 + pax_force_fptr %rdi
18936 jmp *%rdi
18937 +ENDPROC(return_to_handler)
18938 #endif
18939
18940
18941 @@ -284,6 +293,273 @@ ENTRY(native_usergs_sysret64)
18942 ENDPROC(native_usergs_sysret64)
18943 #endif /* CONFIG_PARAVIRT */
18944
18945 + .macro ljmpq sel, off
18946 +#if defined(CONFIG_MPSC) || defined(CONFIG_MCORE2) || defined (CONFIG_MATOM)
18947 + .byte 0x48; ljmp *1234f(%rip)
18948 + .pushsection .rodata
18949 + .align 16
18950 + 1234: .quad \off; .word \sel
18951 + .popsection
18952 +#else
18953 + pushq $\sel
18954 + pushq $\off
18955 + lretq
18956 +#endif
18957 + .endm
18958 +
18959 + .macro pax_enter_kernel
18960 + pax_set_fptr_mask
18961 +#ifdef CONFIG_PAX_KERNEXEC
18962 + call pax_enter_kernel
18963 +#endif
18964 + .endm
18965 +
18966 + .macro pax_exit_kernel
18967 +#ifdef CONFIG_PAX_KERNEXEC
18968 + call pax_exit_kernel
18969 +#endif
18970 + .endm
18971 +
18972 +#ifdef CONFIG_PAX_KERNEXEC
18973 +ENTRY(pax_enter_kernel)
18974 + pushq %rdi
18975 +
18976 +#ifdef CONFIG_PARAVIRT
18977 + PV_SAVE_REGS(CLBR_RDI)
18978 +#endif
18979 +
18980 + GET_CR0_INTO_RDI
18981 + bts $16,%rdi
18982 + jnc 3f
18983 + mov %cs,%edi
18984 + cmp $__KERNEL_CS,%edi
18985 + jnz 2f
18986 +1:
18987 +
18988 +#ifdef CONFIG_PARAVIRT
18989 + PV_RESTORE_REGS(CLBR_RDI)
18990 +#endif
18991 +
18992 + popq %rdi
18993 + pax_force_retaddr
18994 + retq
18995 +
18996 +2: ljmpq __KERNEL_CS,1f
18997 +3: ljmpq __KERNEXEC_KERNEL_CS,4f
18998 +4: SET_RDI_INTO_CR0
18999 + jmp 1b
19000 +ENDPROC(pax_enter_kernel)
19001 +
19002 +ENTRY(pax_exit_kernel)
19003 + pushq %rdi
19004 +
19005 +#ifdef CONFIG_PARAVIRT
19006 + PV_SAVE_REGS(CLBR_RDI)
19007 +#endif
19008 +
19009 + mov %cs,%rdi
19010 + cmp $__KERNEXEC_KERNEL_CS,%edi
19011 + jz 2f
19012 +1:
19013 +
19014 +#ifdef CONFIG_PARAVIRT
19015 + PV_RESTORE_REGS(CLBR_RDI);
19016 +#endif
19017 +
19018 + popq %rdi
19019 + pax_force_retaddr
19020 + retq
19021 +
19022 +2: GET_CR0_INTO_RDI
19023 + btr $16,%rdi
19024 + ljmpq __KERNEL_CS,3f
19025 +3: SET_RDI_INTO_CR0
19026 + jmp 1b
19027 +ENDPROC(pax_exit_kernel)
19028 +#endif
19029 +
19030 + .macro pax_enter_kernel_user
19031 + pax_set_fptr_mask
19032 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19033 + call pax_enter_kernel_user
19034 +#endif
19035 + .endm
19036 +
19037 + .macro pax_exit_kernel_user
19038 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19039 + call pax_exit_kernel_user
19040 +#endif
19041 +#ifdef CONFIG_PAX_RANDKSTACK
19042 + pushq %rax
19043 + call pax_randomize_kstack
19044 + popq %rax
19045 +#endif
19046 + .endm
19047 +
19048 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19049 +ENTRY(pax_enter_kernel_user)
19050 + pushq %rdi
19051 + pushq %rbx
19052 +
19053 +#ifdef CONFIG_PARAVIRT
19054 + PV_SAVE_REGS(CLBR_RDI)
19055 +#endif
19056 +
19057 + GET_CR3_INTO_RDI
19058 + mov %rdi,%rbx
19059 + add $__START_KERNEL_map,%rbx
19060 + sub phys_base(%rip),%rbx
19061 +
19062 +#ifdef CONFIG_PARAVIRT
19063 + pushq %rdi
19064 + cmpl $0, pv_info+PARAVIRT_enabled
19065 + jz 1f
19066 + i = 0
19067 + .rept USER_PGD_PTRS
19068 + mov i*8(%rbx),%rsi
19069 + mov $0,%sil
19070 + lea i*8(%rbx),%rdi
19071 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_set_pgd_batched)
19072 + i = i + 1
19073 + .endr
19074 + jmp 2f
19075 +1:
19076 +#endif
19077 +
19078 + i = 0
19079 + .rept USER_PGD_PTRS
19080 + movb $0,i*8(%rbx)
19081 + i = i + 1
19082 + .endr
19083 +
19084 +#ifdef CONFIG_PARAVIRT
19085 +2: popq %rdi
19086 +#endif
19087 + SET_RDI_INTO_CR3
19088 +
19089 +#ifdef CONFIG_PAX_KERNEXEC
19090 + GET_CR0_INTO_RDI
19091 + bts $16,%rdi
19092 + SET_RDI_INTO_CR0
19093 +#endif
19094 +
19095 +#ifdef CONFIG_PARAVIRT
19096 + PV_RESTORE_REGS(CLBR_RDI)
19097 +#endif
19098 +
19099 + popq %rbx
19100 + popq %rdi
19101 + pax_force_retaddr
19102 + retq
19103 +ENDPROC(pax_enter_kernel_user)
19104 +
19105 +ENTRY(pax_exit_kernel_user)
19106 + push %rdi
19107 +
19108 +#ifdef CONFIG_PARAVIRT
19109 + pushq %rbx
19110 + PV_SAVE_REGS(CLBR_RDI)
19111 +#endif
19112 +
19113 +#ifdef CONFIG_PAX_KERNEXEC
19114 + GET_CR0_INTO_RDI
19115 + btr $16,%rdi
19116 + SET_RDI_INTO_CR0
19117 +#endif
19118 +
19119 + GET_CR3_INTO_RDI
19120 + add $__START_KERNEL_map,%rdi
19121 + sub phys_base(%rip),%rdi
19122 +
19123 +#ifdef CONFIG_PARAVIRT
19124 + cmpl $0, pv_info+PARAVIRT_enabled
19125 + jz 1f
19126 + mov %rdi,%rbx
19127 + i = 0
19128 + .rept USER_PGD_PTRS
19129 + mov i*8(%rbx),%rsi
19130 + mov $0x67,%sil
19131 + lea i*8(%rbx),%rdi
19132 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_set_pgd_batched)
19133 + i = i + 1
19134 + .endr
19135 + jmp 2f
19136 +1:
19137 +#endif
19138 +
19139 + i = 0
19140 + .rept USER_PGD_PTRS
19141 + movb $0x67,i*8(%rdi)
19142 + i = i + 1
19143 + .endr
19144 +
19145 +#ifdef CONFIG_PARAVIRT
19146 +2: PV_RESTORE_REGS(CLBR_RDI)
19147 + popq %rbx
19148 +#endif
19149 +
19150 + popq %rdi
19151 + pax_force_retaddr
19152 + retq
19153 +ENDPROC(pax_exit_kernel_user)
19154 +#endif
19155 +
19156 +.macro pax_erase_kstack
19157 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
19158 + call pax_erase_kstack
19159 +#endif
19160 +.endm
19161 +
19162 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
19163 +ENTRY(pax_erase_kstack)
19164 + pushq %rdi
19165 + pushq %rcx
19166 + pushq %rax
19167 + pushq %r11
19168 +
19169 + GET_THREAD_INFO(%r11)
19170 + mov TI_lowest_stack(%r11), %rdi
19171 + mov $-0xBEEF, %rax
19172 + std
19173 +
19174 +1: mov %edi, %ecx
19175 + and $THREAD_SIZE_asm - 1, %ecx
19176 + shr $3, %ecx
19177 + repne scasq
19178 + jecxz 2f
19179 +
19180 + cmp $2*8, %ecx
19181 + jc 2f
19182 +
19183 + mov $2*8, %ecx
19184 + repe scasq
19185 + jecxz 2f
19186 + jne 1b
19187 +
19188 +2: cld
19189 + mov %esp, %ecx
19190 + sub %edi, %ecx
19191 +
19192 + cmp $THREAD_SIZE_asm, %rcx
19193 + jb 3f
19194 + ud2
19195 +3:
19196 +
19197 + shr $3, %ecx
19198 + rep stosq
19199 +
19200 + mov TI_task_thread_sp0(%r11), %rdi
19201 + sub $256, %rdi
19202 + mov %rdi, TI_lowest_stack(%r11)
19203 +
19204 + popq %r11
19205 + popq %rax
19206 + popq %rcx
19207 + popq %rdi
19208 + pax_force_retaddr
19209 + ret
19210 +ENDPROC(pax_erase_kstack)
19211 +#endif
19212
19213 .macro TRACE_IRQS_IRETQ offset=ARGOFFSET
19214 #ifdef CONFIG_TRACE_IRQFLAGS
19215 @@ -375,8 +651,8 @@ ENDPROC(native_usergs_sysret64)
19216 .endm
19217
19218 .macro UNFAKE_STACK_FRAME
19219 - addq $8*6, %rsp
19220 - CFI_ADJUST_CFA_OFFSET -(6*8)
19221 + addq $8*6 + ARG_SKIP, %rsp
19222 + CFI_ADJUST_CFA_OFFSET -(6*8 + ARG_SKIP)
19223 .endm
19224
19225 /*
19226 @@ -463,7 +739,7 @@ ENDPROC(native_usergs_sysret64)
19227 movq %rsp, %rsi
19228
19229 leaq -RBP(%rsp),%rdi /* arg1 for handler */
19230 - testl $3, CS-RBP(%rsi)
19231 + testb $3, CS-RBP(%rsi)
19232 je 1f
19233 SWAPGS
19234 /*
19235 @@ -498,9 +774,10 @@ ENTRY(save_rest)
19236 movq_cfi r15, R15+16
19237 movq %r11, 8(%rsp) /* return address */
19238 FIXUP_TOP_OF_STACK %r11, 16
19239 + pax_force_retaddr
19240 ret
19241 CFI_ENDPROC
19242 -END(save_rest)
19243 +ENDPROC(save_rest)
19244
19245 /* save complete stack frame */
19246 .pushsection .kprobes.text, "ax"
19247 @@ -529,9 +806,10 @@ ENTRY(save_paranoid)
19248 js 1f /* negative -> in kernel */
19249 SWAPGS
19250 xorl %ebx,%ebx
19251 -1: ret
19252 +1: pax_force_retaddr_bts
19253 + ret
19254 CFI_ENDPROC
19255 -END(save_paranoid)
19256 +ENDPROC(save_paranoid)
19257 .popsection
19258
19259 /*
19260 @@ -553,7 +831,7 @@ ENTRY(ret_from_fork)
19261
19262 RESTORE_REST
19263
19264 - testl $3, CS-ARGOFFSET(%rsp) # from kernel_thread?
19265 + testb $3, CS-ARGOFFSET(%rsp) # from kernel_thread?
19266 jz 1f
19267
19268 testl $_TIF_IA32, TI_flags(%rcx) # 32-bit compat task needs IRET
19269 @@ -571,7 +849,7 @@ ENTRY(ret_from_fork)
19270 RESTORE_REST
19271 jmp int_ret_from_sys_call
19272 CFI_ENDPROC
19273 -END(ret_from_fork)
19274 +ENDPROC(ret_from_fork)
19275
19276 /*
19277 * System call entry. Up to 6 arguments in registers are supported.
19278 @@ -608,7 +886,7 @@ END(ret_from_fork)
19279 ENTRY(system_call)
19280 CFI_STARTPROC simple
19281 CFI_SIGNAL_FRAME
19282 - CFI_DEF_CFA rsp,KERNEL_STACK_OFFSET
19283 + CFI_DEF_CFA rsp,0
19284 CFI_REGISTER rip,rcx
19285 /*CFI_REGISTER rflags,r11*/
19286 SWAPGS_UNSAFE_STACK
19287 @@ -621,16 +899,23 @@ GLOBAL(system_call_after_swapgs)
19288
19289 movq %rsp,PER_CPU_VAR(old_rsp)
19290 movq PER_CPU_VAR(kernel_stack),%rsp
19291 + SAVE_ARGS 8*6,0
19292 + pax_enter_kernel_user
19293 +
19294 +#ifdef CONFIG_PAX_RANDKSTACK
19295 + pax_erase_kstack
19296 +#endif
19297 +
19298 /*
19299 * No need to follow this irqs off/on section - it's straight
19300 * and short:
19301 */
19302 ENABLE_INTERRUPTS(CLBR_NONE)
19303 - SAVE_ARGS 8,0
19304 movq %rax,ORIG_RAX-ARGOFFSET(%rsp)
19305 movq %rcx,RIP-ARGOFFSET(%rsp)
19306 CFI_REL_OFFSET rip,RIP-ARGOFFSET
19307 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
19308 + GET_THREAD_INFO(%rcx)
19309 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%rcx)
19310 jnz tracesys
19311 system_call_fastpath:
19312 #if __SYSCALL_MASK == ~0
19313 @@ -640,7 +925,7 @@ system_call_fastpath:
19314 cmpl $__NR_syscall_max,%eax
19315 #endif
19316 ja badsys
19317 - movq %r10,%rcx
19318 + movq R10-ARGOFFSET(%rsp),%rcx
19319 call *sys_call_table(,%rax,8) # XXX: rip relative
19320 movq %rax,RAX-ARGOFFSET(%rsp)
19321 /*
19322 @@ -654,10 +939,13 @@ sysret_check:
19323 LOCKDEP_SYS_EXIT
19324 DISABLE_INTERRUPTS(CLBR_NONE)
19325 TRACE_IRQS_OFF
19326 - movl TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET),%edx
19327 + GET_THREAD_INFO(%rcx)
19328 + movl TI_flags(%rcx),%edx
19329 andl %edi,%edx
19330 jnz sysret_careful
19331 CFI_REMEMBER_STATE
19332 + pax_exit_kernel_user
19333 + pax_erase_kstack
19334 /*
19335 * sysretq will re-enable interrupts:
19336 */
19337 @@ -709,14 +997,18 @@ badsys:
19338 * jump back to the normal fast path.
19339 */
19340 auditsys:
19341 - movq %r10,%r9 /* 6th arg: 4th syscall arg */
19342 + movq R10-ARGOFFSET(%rsp),%r9 /* 6th arg: 4th syscall arg */
19343 movq %rdx,%r8 /* 5th arg: 3rd syscall arg */
19344 movq %rsi,%rcx /* 4th arg: 2nd syscall arg */
19345 movq %rdi,%rdx /* 3rd arg: 1st syscall arg */
19346 movq %rax,%rsi /* 2nd arg: syscall number */
19347 movl $AUDIT_ARCH_X86_64,%edi /* 1st arg: audit arch */
19348 call __audit_syscall_entry
19349 +
19350 + pax_erase_kstack
19351 +
19352 LOAD_ARGS 0 /* reload call-clobbered registers */
19353 + pax_set_fptr_mask
19354 jmp system_call_fastpath
19355
19356 /*
19357 @@ -737,7 +1029,7 @@ sysret_audit:
19358 /* Do syscall tracing */
19359 tracesys:
19360 #ifdef CONFIG_AUDITSYSCALL
19361 - testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
19362 + testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags(%rcx)
19363 jz auditsys
19364 #endif
19365 SAVE_REST
19366 @@ -745,12 +1037,16 @@ tracesys:
19367 FIXUP_TOP_OF_STACK %rdi
19368 movq %rsp,%rdi
19369 call syscall_trace_enter
19370 +
19371 + pax_erase_kstack
19372 +
19373 /*
19374 * Reload arg registers from stack in case ptrace changed them.
19375 * We don't reload %rax because syscall_trace_enter() returned
19376 * the value it wants us to use in the table lookup.
19377 */
19378 LOAD_ARGS ARGOFFSET, 1
19379 + pax_set_fptr_mask
19380 RESTORE_REST
19381 #if __SYSCALL_MASK == ~0
19382 cmpq $__NR_syscall_max,%rax
19383 @@ -759,7 +1055,7 @@ tracesys:
19384 cmpl $__NR_syscall_max,%eax
19385 #endif
19386 ja int_ret_from_sys_call /* RAX(%rsp) set to -ENOSYS above */
19387 - movq %r10,%rcx /* fixup for C */
19388 + movq R10-ARGOFFSET(%rsp),%rcx /* fixup for C */
19389 call *sys_call_table(,%rax,8)
19390 movq %rax,RAX-ARGOFFSET(%rsp)
19391 /* Use IRET because user could have changed frame */
19392 @@ -780,7 +1076,9 @@ GLOBAL(int_with_check)
19393 andl %edi,%edx
19394 jnz int_careful
19395 andl $~TS_COMPAT,TI_status(%rcx)
19396 - jmp retint_swapgs
19397 + pax_exit_kernel_user
19398 + pax_erase_kstack
19399 + jmp retint_swapgs_pax
19400
19401 /* Either reschedule or signal or syscall exit tracking needed. */
19402 /* First do a reschedule test. */
19403 @@ -826,7 +1124,7 @@ int_restore_rest:
19404 TRACE_IRQS_OFF
19405 jmp int_with_check
19406 CFI_ENDPROC
19407 -END(system_call)
19408 +ENDPROC(system_call)
19409
19410 /*
19411 * Certain special system calls that need to save a complete full stack frame.
19412 @@ -842,7 +1140,7 @@ ENTRY(\label)
19413 call \func
19414 jmp ptregscall_common
19415 CFI_ENDPROC
19416 -END(\label)
19417 +ENDPROC(\label)
19418 .endm
19419
19420 .macro FORK_LIKE func
19421 @@ -856,9 +1154,10 @@ ENTRY(stub_\func)
19422 DEFAULT_FRAME 0 8 /* offset 8: return address */
19423 call sys_\func
19424 RESTORE_TOP_OF_STACK %r11, 8
19425 + pax_force_retaddr
19426 ret $REST_SKIP /* pop extended registers */
19427 CFI_ENDPROC
19428 -END(stub_\func)
19429 +ENDPROC(stub_\func)
19430 .endm
19431
19432 FORK_LIKE clone
19433 @@ -875,9 +1174,10 @@ ENTRY(ptregscall_common)
19434 movq_cfi_restore R12+8, r12
19435 movq_cfi_restore RBP+8, rbp
19436 movq_cfi_restore RBX+8, rbx
19437 + pax_force_retaddr
19438 ret $REST_SKIP /* pop extended registers */
19439 CFI_ENDPROC
19440 -END(ptregscall_common)
19441 +ENDPROC(ptregscall_common)
19442
19443 ENTRY(stub_execve)
19444 CFI_STARTPROC
19445 @@ -891,7 +1191,7 @@ ENTRY(stub_execve)
19446 RESTORE_REST
19447 jmp int_ret_from_sys_call
19448 CFI_ENDPROC
19449 -END(stub_execve)
19450 +ENDPROC(stub_execve)
19451
19452 /*
19453 * sigreturn is special because it needs to restore all registers on return.
19454 @@ -909,7 +1209,7 @@ ENTRY(stub_rt_sigreturn)
19455 RESTORE_REST
19456 jmp int_ret_from_sys_call
19457 CFI_ENDPROC
19458 -END(stub_rt_sigreturn)
19459 +ENDPROC(stub_rt_sigreturn)
19460
19461 #ifdef CONFIG_X86_X32_ABI
19462 ENTRY(stub_x32_rt_sigreturn)
19463 @@ -975,7 +1275,7 @@ vector=vector+1
19464 2: jmp common_interrupt
19465 .endr
19466 CFI_ENDPROC
19467 -END(irq_entries_start)
19468 +ENDPROC(irq_entries_start)
19469
19470 .previous
19471 END(interrupt)
19472 @@ -995,6 +1295,16 @@ END(interrupt)
19473 subq $ORIG_RAX-RBP, %rsp
19474 CFI_ADJUST_CFA_OFFSET ORIG_RAX-RBP
19475 SAVE_ARGS_IRQ
19476 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19477 + testb $3, CS(%rdi)
19478 + jnz 1f
19479 + pax_enter_kernel
19480 + jmp 2f
19481 +1: pax_enter_kernel_user
19482 +2:
19483 +#else
19484 + pax_enter_kernel
19485 +#endif
19486 call \func
19487 .endm
19488
19489 @@ -1027,7 +1337,7 @@ ret_from_intr:
19490
19491 exit_intr:
19492 GET_THREAD_INFO(%rcx)
19493 - testl $3,CS-ARGOFFSET(%rsp)
19494 + testb $3,CS-ARGOFFSET(%rsp)
19495 je retint_kernel
19496
19497 /* Interrupt came from user space */
19498 @@ -1049,12 +1359,16 @@ retint_swapgs: /* return to user-space */
19499 * The iretq could re-enable interrupts:
19500 */
19501 DISABLE_INTERRUPTS(CLBR_ANY)
19502 + pax_exit_kernel_user
19503 +retint_swapgs_pax:
19504 TRACE_IRQS_IRETQ
19505 SWAPGS
19506 jmp restore_args
19507
19508 retint_restore_args: /* return to kernel space */
19509 DISABLE_INTERRUPTS(CLBR_ANY)
19510 + pax_exit_kernel
19511 + pax_force_retaddr (RIP-ARGOFFSET)
19512 /*
19513 * The iretq could re-enable interrupts:
19514 */
19515 @@ -1137,7 +1451,7 @@ ENTRY(retint_kernel)
19516 #endif
19517
19518 CFI_ENDPROC
19519 -END(common_interrupt)
19520 +ENDPROC(common_interrupt)
19521 /*
19522 * End of kprobes section
19523 */
19524 @@ -1155,7 +1469,7 @@ ENTRY(\sym)
19525 interrupt \do_sym
19526 jmp ret_from_intr
19527 CFI_ENDPROC
19528 -END(\sym)
19529 +ENDPROC(\sym)
19530 .endm
19531
19532 #ifdef CONFIG_SMP
19533 @@ -1211,12 +1525,22 @@ ENTRY(\sym)
19534 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
19535 call error_entry
19536 DEFAULT_FRAME 0
19537 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19538 + testb $3, CS(%rsp)
19539 + jnz 1f
19540 + pax_enter_kernel
19541 + jmp 2f
19542 +1: pax_enter_kernel_user
19543 +2:
19544 +#else
19545 + pax_enter_kernel
19546 +#endif
19547 movq %rsp,%rdi /* pt_regs pointer */
19548 xorl %esi,%esi /* no error code */
19549 call \do_sym
19550 jmp error_exit /* %ebx: no swapgs flag */
19551 CFI_ENDPROC
19552 -END(\sym)
19553 +ENDPROC(\sym)
19554 .endm
19555
19556 .macro paranoidzeroentry sym do_sym
19557 @@ -1229,15 +1553,25 @@ ENTRY(\sym)
19558 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
19559 call save_paranoid
19560 TRACE_IRQS_OFF
19561 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19562 + testb $3, CS(%rsp)
19563 + jnz 1f
19564 + pax_enter_kernel
19565 + jmp 2f
19566 +1: pax_enter_kernel_user
19567 +2:
19568 +#else
19569 + pax_enter_kernel
19570 +#endif
19571 movq %rsp,%rdi /* pt_regs pointer */
19572 xorl %esi,%esi /* no error code */
19573 call \do_sym
19574 jmp paranoid_exit /* %ebx: no swapgs flag */
19575 CFI_ENDPROC
19576 -END(\sym)
19577 +ENDPROC(\sym)
19578 .endm
19579
19580 -#define INIT_TSS_IST(x) PER_CPU_VAR(init_tss) + (TSS_ist + ((x) - 1) * 8)
19581 +#define INIT_TSS_IST(x) (TSS_ist + ((x) - 1) * 8)(%r12)
19582 .macro paranoidzeroentry_ist sym do_sym ist
19583 ENTRY(\sym)
19584 INTR_FRAME
19585 @@ -1248,14 +1582,30 @@ ENTRY(\sym)
19586 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
19587 call save_paranoid
19588 TRACE_IRQS_OFF_DEBUG
19589 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19590 + testb $3, CS(%rsp)
19591 + jnz 1f
19592 + pax_enter_kernel
19593 + jmp 2f
19594 +1: pax_enter_kernel_user
19595 +2:
19596 +#else
19597 + pax_enter_kernel
19598 +#endif
19599 movq %rsp,%rdi /* pt_regs pointer */
19600 xorl %esi,%esi /* no error code */
19601 +#ifdef CONFIG_SMP
19602 + imul $TSS_size, PER_CPU_VAR(cpu_number), %r12d
19603 + lea init_tss(%r12), %r12
19604 +#else
19605 + lea init_tss(%rip), %r12
19606 +#endif
19607 subq $EXCEPTION_STKSZ, INIT_TSS_IST(\ist)
19608 call \do_sym
19609 addq $EXCEPTION_STKSZ, INIT_TSS_IST(\ist)
19610 jmp paranoid_exit /* %ebx: no swapgs flag */
19611 CFI_ENDPROC
19612 -END(\sym)
19613 +ENDPROC(\sym)
19614 .endm
19615
19616 .macro errorentry sym do_sym
19617 @@ -1267,13 +1617,23 @@ ENTRY(\sym)
19618 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
19619 call error_entry
19620 DEFAULT_FRAME 0
19621 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19622 + testb $3, CS(%rsp)
19623 + jnz 1f
19624 + pax_enter_kernel
19625 + jmp 2f
19626 +1: pax_enter_kernel_user
19627 +2:
19628 +#else
19629 + pax_enter_kernel
19630 +#endif
19631 movq %rsp,%rdi /* pt_regs pointer */
19632 movq ORIG_RAX(%rsp),%rsi /* get error code */
19633 movq $-1,ORIG_RAX(%rsp) /* no syscall to restart */
19634 call \do_sym
19635 jmp error_exit /* %ebx: no swapgs flag */
19636 CFI_ENDPROC
19637 -END(\sym)
19638 +ENDPROC(\sym)
19639 .endm
19640
19641 /* error code is on the stack already */
19642 @@ -1287,13 +1647,23 @@ ENTRY(\sym)
19643 call save_paranoid
19644 DEFAULT_FRAME 0
19645 TRACE_IRQS_OFF
19646 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19647 + testb $3, CS(%rsp)
19648 + jnz 1f
19649 + pax_enter_kernel
19650 + jmp 2f
19651 +1: pax_enter_kernel_user
19652 +2:
19653 +#else
19654 + pax_enter_kernel
19655 +#endif
19656 movq %rsp,%rdi /* pt_regs pointer */
19657 movq ORIG_RAX(%rsp),%rsi /* get error code */
19658 movq $-1,ORIG_RAX(%rsp) /* no syscall to restart */
19659 call \do_sym
19660 jmp paranoid_exit /* %ebx: no swapgs flag */
19661 CFI_ENDPROC
19662 -END(\sym)
19663 +ENDPROC(\sym)
19664 .endm
19665
19666 zeroentry divide_error do_divide_error
19667 @@ -1323,9 +1693,10 @@ gs_change:
19668 2: mfence /* workaround */
19669 SWAPGS
19670 popfq_cfi
19671 + pax_force_retaddr
19672 ret
19673 CFI_ENDPROC
19674 -END(native_load_gs_index)
19675 +ENDPROC(native_load_gs_index)
19676
19677 _ASM_EXTABLE(gs_change,bad_gs)
19678 .section .fixup,"ax"
19679 @@ -1353,9 +1724,10 @@ ENTRY(call_softirq)
19680 CFI_DEF_CFA_REGISTER rsp
19681 CFI_ADJUST_CFA_OFFSET -8
19682 decl PER_CPU_VAR(irq_count)
19683 + pax_force_retaddr
19684 ret
19685 CFI_ENDPROC
19686 -END(call_softirq)
19687 +ENDPROC(call_softirq)
19688
19689 #ifdef CONFIG_XEN
19690 zeroentry xen_hypervisor_callback xen_do_hypervisor_callback
19691 @@ -1393,7 +1765,7 @@ ENTRY(xen_do_hypervisor_callback) # do_hypervisor_callback(struct *pt_regs)
19692 decl PER_CPU_VAR(irq_count)
19693 jmp error_exit
19694 CFI_ENDPROC
19695 -END(xen_do_hypervisor_callback)
19696 +ENDPROC(xen_do_hypervisor_callback)
19697
19698 /*
19699 * Hypervisor uses this for application faults while it executes.
19700 @@ -1452,7 +1824,7 @@ ENTRY(xen_failsafe_callback)
19701 SAVE_ALL
19702 jmp error_exit
19703 CFI_ENDPROC
19704 -END(xen_failsafe_callback)
19705 +ENDPROC(xen_failsafe_callback)
19706
19707 apicinterrupt XEN_HVM_EVTCHN_CALLBACK \
19708 xen_hvm_callback_vector xen_evtchn_do_upcall
19709 @@ -1501,16 +1873,31 @@ ENTRY(paranoid_exit)
19710 TRACE_IRQS_OFF_DEBUG
19711 testl %ebx,%ebx /* swapgs needed? */
19712 jnz paranoid_restore
19713 - testl $3,CS(%rsp)
19714 + testb $3,CS(%rsp)
19715 jnz paranoid_userspace
19716 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19717 + pax_exit_kernel
19718 + TRACE_IRQS_IRETQ 0
19719 + SWAPGS_UNSAFE_STACK
19720 + RESTORE_ALL 8
19721 + pax_force_retaddr_bts
19722 + jmp irq_return
19723 +#endif
19724 paranoid_swapgs:
19725 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19726 + pax_exit_kernel_user
19727 +#else
19728 + pax_exit_kernel
19729 +#endif
19730 TRACE_IRQS_IRETQ 0
19731 SWAPGS_UNSAFE_STACK
19732 RESTORE_ALL 8
19733 jmp irq_return
19734 paranoid_restore:
19735 + pax_exit_kernel
19736 TRACE_IRQS_IRETQ_DEBUG 0
19737 RESTORE_ALL 8
19738 + pax_force_retaddr_bts
19739 jmp irq_return
19740 paranoid_userspace:
19741 GET_THREAD_INFO(%rcx)
19742 @@ -1539,7 +1926,7 @@ paranoid_schedule:
19743 TRACE_IRQS_OFF
19744 jmp paranoid_userspace
19745 CFI_ENDPROC
19746 -END(paranoid_exit)
19747 +ENDPROC(paranoid_exit)
19748
19749 /*
19750 * Exception entry point. This expects an error code/orig_rax on the stack.
19751 @@ -1566,12 +1953,13 @@ ENTRY(error_entry)
19752 movq_cfi r14, R14+8
19753 movq_cfi r15, R15+8
19754 xorl %ebx,%ebx
19755 - testl $3,CS+8(%rsp)
19756 + testb $3,CS+8(%rsp)
19757 je error_kernelspace
19758 error_swapgs:
19759 SWAPGS
19760 error_sti:
19761 TRACE_IRQS_OFF
19762 + pax_force_retaddr_bts
19763 ret
19764
19765 /*
19766 @@ -1598,7 +1986,7 @@ bstep_iret:
19767 movq %rcx,RIP+8(%rsp)
19768 jmp error_swapgs
19769 CFI_ENDPROC
19770 -END(error_entry)
19771 +ENDPROC(error_entry)
19772
19773
19774 /* ebx: no swapgs flag (1: don't need swapgs, 0: need it) */
19775 @@ -1618,7 +2006,7 @@ ENTRY(error_exit)
19776 jnz retint_careful
19777 jmp retint_swapgs
19778 CFI_ENDPROC
19779 -END(error_exit)
19780 +ENDPROC(error_exit)
19781
19782 /*
19783 * Test if a given stack is an NMI stack or not.
19784 @@ -1676,9 +2064,11 @@ ENTRY(nmi)
19785 * If %cs was not the kernel segment, then the NMI triggered in user
19786 * space, which means it is definitely not nested.
19787 */
19788 + cmpl $__KERNEXEC_KERNEL_CS, 16(%rsp)
19789 + je 1f
19790 cmpl $__KERNEL_CS, 16(%rsp)
19791 jne first_nmi
19792 -
19793 +1:
19794 /*
19795 * Check the special variable on the stack to see if NMIs are
19796 * executing.
19797 @@ -1847,6 +2237,17 @@ end_repeat_nmi:
19798 */
19799 movq %cr2, %r12
19800
19801 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19802 + testb $3, CS(%rsp)
19803 + jnz 1f
19804 + pax_enter_kernel
19805 + jmp 2f
19806 +1: pax_enter_kernel_user
19807 +2:
19808 +#else
19809 + pax_enter_kernel
19810 +#endif
19811 +
19812 /* paranoidentry do_nmi, 0; without TRACE_IRQS_OFF */
19813 movq %rsp,%rdi
19814 movq $-1,%rsi
19815 @@ -1862,23 +2263,34 @@ end_repeat_nmi:
19816 testl %ebx,%ebx /* swapgs needed? */
19817 jnz nmi_restore
19818 nmi_swapgs:
19819 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19820 + pax_exit_kernel_user
19821 +#else
19822 + pax_exit_kernel
19823 +#endif
19824 SWAPGS_UNSAFE_STACK
19825 + RESTORE_ALL 6*8
19826 + /* Clear the NMI executing stack variable */
19827 + movq $0, 5*8(%rsp)
19828 + jmp irq_return
19829 nmi_restore:
19830 + pax_exit_kernel
19831 /* Pop the extra iret frame at once */
19832 RESTORE_ALL 6*8
19833 + pax_force_retaddr_bts
19834
19835 /* Clear the NMI executing stack variable */
19836 movq $0, 5*8(%rsp)
19837 jmp irq_return
19838 CFI_ENDPROC
19839 -END(nmi)
19840 +ENDPROC(nmi)
19841
19842 ENTRY(ignore_sysret)
19843 CFI_STARTPROC
19844 mov $-ENOSYS,%eax
19845 sysret
19846 CFI_ENDPROC
19847 -END(ignore_sysret)
19848 +ENDPROC(ignore_sysret)
19849
19850 /*
19851 * End of kprobes section
19852 diff --git a/arch/x86/kernel/ftrace.c b/arch/x86/kernel/ftrace.c
19853 index 1d41402..af9a46a 100644
19854 --- a/arch/x86/kernel/ftrace.c
19855 +++ b/arch/x86/kernel/ftrace.c
19856 @@ -105,6 +105,8 @@ ftrace_modify_code_direct(unsigned long ip, unsigned const char *old_code,
19857 {
19858 unsigned char replaced[MCOUNT_INSN_SIZE];
19859
19860 + ip = ktla_ktva(ip);
19861 +
19862 /*
19863 * Note: Due to modules and __init, code can
19864 * disappear and change, we need to protect against faulting
19865 @@ -227,7 +229,7 @@ int ftrace_update_ftrace_func(ftrace_func_t func)
19866 unsigned char old[MCOUNT_INSN_SIZE], *new;
19867 int ret;
19868
19869 - memcpy(old, &ftrace_call, MCOUNT_INSN_SIZE);
19870 + memcpy(old, (void *)ktla_ktva((unsigned long)ftrace_call), MCOUNT_INSN_SIZE);
19871 new = ftrace_call_replace(ip, (unsigned long)func);
19872
19873 /* See comment above by declaration of modifying_ftrace_code */
19874 @@ -238,7 +240,7 @@ int ftrace_update_ftrace_func(ftrace_func_t func)
19875 /* Also update the regs callback function */
19876 if (!ret) {
19877 ip = (unsigned long)(&ftrace_regs_call);
19878 - memcpy(old, &ftrace_regs_call, MCOUNT_INSN_SIZE);
19879 + memcpy(old, ktla_ktva((void *)&ftrace_regs_call), MCOUNT_INSN_SIZE);
19880 new = ftrace_call_replace(ip, (unsigned long)func);
19881 ret = ftrace_modify_code(ip, old, new);
19882 }
19883 @@ -279,7 +281,7 @@ static int ftrace_write(unsigned long ip, const char *val, int size)
19884 * kernel identity mapping to modify code.
19885 */
19886 if (within(ip, (unsigned long)_text, (unsigned long)_etext))
19887 - ip = (unsigned long)__va(__pa(ip));
19888 + ip = (unsigned long)__va(__pa(ktla_ktva(ip)));
19889
19890 return probe_kernel_write((void *)ip, val, size);
19891 }
19892 @@ -289,7 +291,7 @@ static int add_break(unsigned long ip, const char *old)
19893 unsigned char replaced[MCOUNT_INSN_SIZE];
19894 unsigned char brk = BREAKPOINT_INSTRUCTION;
19895
19896 - if (probe_kernel_read(replaced, (void *)ip, MCOUNT_INSN_SIZE))
19897 + if (probe_kernel_read(replaced, (void *)ktla_ktva(ip), MCOUNT_INSN_SIZE))
19898 return -EFAULT;
19899
19900 /* Make sure it is what we expect it to be */
19901 @@ -637,7 +639,7 @@ ftrace_modify_code(unsigned long ip, unsigned const char *old_code,
19902 return ret;
19903
19904 fail_update:
19905 - probe_kernel_write((void *)ip, &old_code[0], 1);
19906 + probe_kernel_write((void *)ktla_ktva(ip), &old_code[0], 1);
19907 goto out;
19908 }
19909
19910 @@ -670,6 +672,8 @@ static int ftrace_mod_jmp(unsigned long ip,
19911 {
19912 unsigned char code[MCOUNT_INSN_SIZE];
19913
19914 + ip = ktla_ktva(ip);
19915 +
19916 if (probe_kernel_read(code, (void *)ip, MCOUNT_INSN_SIZE))
19917 return -EFAULT;
19918
19919 diff --git a/arch/x86/kernel/head32.c b/arch/x86/kernel/head32.c
19920 index c18f59d..9c0c9f6 100644
19921 --- a/arch/x86/kernel/head32.c
19922 +++ b/arch/x86/kernel/head32.c
19923 @@ -18,6 +18,7 @@
19924 #include <asm/io_apic.h>
19925 #include <asm/bios_ebda.h>
19926 #include <asm/tlbflush.h>
19927 +#include <asm/boot.h>
19928
19929 static void __init i386_default_early_setup(void)
19930 {
19931 @@ -30,8 +31,7 @@ static void __init i386_default_early_setup(void)
19932
19933 void __init i386_start_kernel(void)
19934 {
19935 - memblock_reserve(__pa_symbol(&_text),
19936 - __pa_symbol(&__bss_stop) - __pa_symbol(&_text));
19937 + memblock_reserve(LOAD_PHYSICAL_ADDR, __pa_symbol(&__bss_stop) - LOAD_PHYSICAL_ADDR);
19938
19939 #ifdef CONFIG_BLK_DEV_INITRD
19940 /* Reserve INITRD */
19941 diff --git a/arch/x86/kernel/head_32.S b/arch/x86/kernel/head_32.S
19942 index c8932c7..d56b622 100644
19943 --- a/arch/x86/kernel/head_32.S
19944 +++ b/arch/x86/kernel/head_32.S
19945 @@ -26,6 +26,12 @@
19946 /* Physical address */
19947 #define pa(X) ((X) - __PAGE_OFFSET)
19948
19949 +#ifdef CONFIG_PAX_KERNEXEC
19950 +#define ta(X) (X)
19951 +#else
19952 +#define ta(X) ((X) - __PAGE_OFFSET)
19953 +#endif
19954 +
19955 /*
19956 * References to members of the new_cpu_data structure.
19957 */
19958 @@ -55,11 +61,7 @@
19959 * and small than max_low_pfn, otherwise will waste some page table entries
19960 */
19961
19962 -#if PTRS_PER_PMD > 1
19963 -#define PAGE_TABLE_SIZE(pages) (((pages) / PTRS_PER_PMD) + PTRS_PER_PGD)
19964 -#else
19965 -#define PAGE_TABLE_SIZE(pages) ((pages) / PTRS_PER_PGD)
19966 -#endif
19967 +#define PAGE_TABLE_SIZE(pages) ((pages) / PTRS_PER_PTE)
19968
19969 /* Number of possible pages in the lowmem region */
19970 LOWMEM_PAGES = (((1<<32) - __PAGE_OFFSET) >> PAGE_SHIFT)
19971 @@ -78,6 +80,12 @@ INIT_MAP_SIZE = PAGE_TABLE_SIZE(KERNEL_PAGES) * PAGE_SIZE
19972 RESERVE_BRK(pagetables, INIT_MAP_SIZE)
19973
19974 /*
19975 + * Real beginning of normal "text" segment
19976 + */
19977 +ENTRY(stext)
19978 +ENTRY(_stext)
19979 +
19980 +/*
19981 * 32-bit kernel entrypoint; only used by the boot CPU. On entry,
19982 * %esi points to the real-mode code as a 32-bit pointer.
19983 * CS and DS must be 4 GB flat segments, but we don't depend on
19984 @@ -85,6 +93,13 @@ RESERVE_BRK(pagetables, INIT_MAP_SIZE)
19985 * can.
19986 */
19987 __HEAD
19988 +
19989 +#ifdef CONFIG_PAX_KERNEXEC
19990 + jmp startup_32
19991 +/* PaX: fill first page in .text with int3 to catch NULL derefs in kernel mode */
19992 +.fill PAGE_SIZE-5,1,0xcc
19993 +#endif
19994 +
19995 ENTRY(startup_32)
19996 movl pa(stack_start),%ecx
19997
19998 @@ -106,6 +121,59 @@ ENTRY(startup_32)
19999 2:
20000 leal -__PAGE_OFFSET(%ecx),%esp
20001
20002 +#ifdef CONFIG_SMP
20003 + movl $pa(cpu_gdt_table),%edi
20004 + movl $__per_cpu_load,%eax
20005 + movw %ax,GDT_ENTRY_PERCPU * 8 + 2(%edi)
20006 + rorl $16,%eax
20007 + movb %al,GDT_ENTRY_PERCPU * 8 + 4(%edi)
20008 + movb %ah,GDT_ENTRY_PERCPU * 8 + 7(%edi)
20009 + movl $__per_cpu_end - 1,%eax
20010 + subl $__per_cpu_start,%eax
20011 + movw %ax,GDT_ENTRY_PERCPU * 8 + 0(%edi)
20012 +#endif
20013 +
20014 +#ifdef CONFIG_PAX_MEMORY_UDEREF
20015 + movl $NR_CPUS,%ecx
20016 + movl $pa(cpu_gdt_table),%edi
20017 +1:
20018 + movl $((((__PAGE_OFFSET-1) & 0xf0000000) >> 12) | 0x00c09700),GDT_ENTRY_KERNEL_DS * 8 + 4(%edi)
20019 + movl $((((__PAGE_OFFSET-1) & 0xf0000000) >> 12) | 0x00c0fb00),GDT_ENTRY_DEFAULT_USER_CS * 8 + 4(%edi)
20020 + movl $((((__PAGE_OFFSET-1) & 0xf0000000) >> 12) | 0x00c0f300),GDT_ENTRY_DEFAULT_USER_DS * 8 + 4(%edi)
20021 + addl $PAGE_SIZE_asm,%edi
20022 + loop 1b
20023 +#endif
20024 +
20025 +#ifdef CONFIG_PAX_KERNEXEC
20026 + movl $pa(boot_gdt),%edi
20027 + movl $__LOAD_PHYSICAL_ADDR,%eax
20028 + movw %ax,GDT_ENTRY_BOOT_CS * 8 + 2(%edi)
20029 + rorl $16,%eax
20030 + movb %al,GDT_ENTRY_BOOT_CS * 8 + 4(%edi)
20031 + movb %ah,GDT_ENTRY_BOOT_CS * 8 + 7(%edi)
20032 + rorl $16,%eax
20033 +
20034 + ljmp $(__BOOT_CS),$1f
20035 +1:
20036 +
20037 + movl $NR_CPUS,%ecx
20038 + movl $pa(cpu_gdt_table),%edi
20039 + addl $__PAGE_OFFSET,%eax
20040 +1:
20041 + movb $0xc0,GDT_ENTRY_KERNEL_CS * 8 + 6(%edi)
20042 + movb $0xc0,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 6(%edi)
20043 + movw %ax,GDT_ENTRY_KERNEL_CS * 8 + 2(%edi)
20044 + movw %ax,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 2(%edi)
20045 + rorl $16,%eax
20046 + movb %al,GDT_ENTRY_KERNEL_CS * 8 + 4(%edi)
20047 + movb %al,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 4(%edi)
20048 + movb %ah,GDT_ENTRY_KERNEL_CS * 8 + 7(%edi)
20049 + movb %ah,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 7(%edi)
20050 + rorl $16,%eax
20051 + addl $PAGE_SIZE_asm,%edi
20052 + loop 1b
20053 +#endif
20054 +
20055 /*
20056 * Clear BSS first so that there are no surprises...
20057 */
20058 @@ -196,8 +264,11 @@ ENTRY(startup_32)
20059 movl %eax, pa(max_pfn_mapped)
20060
20061 /* Do early initialization of the fixmap area */
20062 - movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,%eax
20063 - movl %eax,pa(initial_pg_pmd+0x1000*KPMDS-8)
20064 +#ifdef CONFIG_COMPAT_VDSO
20065 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR+_PAGE_USER,pa(initial_pg_pmd+0x1000*KPMDS-8)
20066 +#else
20067 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,pa(initial_pg_pmd+0x1000*KPMDS-8)
20068 +#endif
20069 #else /* Not PAE */
20070
20071 page_pde_offset = (__PAGE_OFFSET >> 20);
20072 @@ -227,8 +298,11 @@ page_pde_offset = (__PAGE_OFFSET >> 20);
20073 movl %eax, pa(max_pfn_mapped)
20074
20075 /* Do early initialization of the fixmap area */
20076 - movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,%eax
20077 - movl %eax,pa(initial_page_table+0xffc)
20078 +#ifdef CONFIG_COMPAT_VDSO
20079 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR+_PAGE_USER,pa(initial_page_table+0xffc)
20080 +#else
20081 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,pa(initial_page_table+0xffc)
20082 +#endif
20083 #endif
20084
20085 #ifdef CONFIG_PARAVIRT
20086 @@ -242,9 +316,7 @@ page_pde_offset = (__PAGE_OFFSET >> 20);
20087 cmpl $num_subarch_entries, %eax
20088 jae bad_subarch
20089
20090 - movl pa(subarch_entries)(,%eax,4), %eax
20091 - subl $__PAGE_OFFSET, %eax
20092 - jmp *%eax
20093 + jmp *pa(subarch_entries)(,%eax,4)
20094
20095 bad_subarch:
20096 WEAK(lguest_entry)
20097 @@ -256,10 +328,10 @@ WEAK(xen_entry)
20098 __INITDATA
20099
20100 subarch_entries:
20101 - .long default_entry /* normal x86/PC */
20102 - .long lguest_entry /* lguest hypervisor */
20103 - .long xen_entry /* Xen hypervisor */
20104 - .long default_entry /* Moorestown MID */
20105 + .long ta(default_entry) /* normal x86/PC */
20106 + .long ta(lguest_entry) /* lguest hypervisor */
20107 + .long ta(xen_entry) /* Xen hypervisor */
20108 + .long ta(default_entry) /* Moorestown MID */
20109 num_subarch_entries = (. - subarch_entries) / 4
20110 .previous
20111 #else
20112 @@ -335,6 +407,7 @@ default_entry:
20113 movl pa(mmu_cr4_features),%eax
20114 movl %eax,%cr4
20115
20116 +#ifdef CONFIG_X86_PAE
20117 testb $X86_CR4_PAE, %al # check if PAE is enabled
20118 jz 6f
20119
20120 @@ -363,6 +436,9 @@ default_entry:
20121 /* Make changes effective */
20122 wrmsr
20123
20124 + btsl $_PAGE_BIT_NX-32,pa(__supported_pte_mask+4)
20125 +#endif
20126 +
20127 6:
20128
20129 /*
20130 @@ -460,14 +536,20 @@ is386: movl $2,%ecx # set MP
20131 1: movl $(__KERNEL_DS),%eax # reload all the segment registers
20132 movl %eax,%ss # after changing gdt.
20133
20134 - movl $(__USER_DS),%eax # DS/ES contains default USER segment
20135 +# movl $(__KERNEL_DS),%eax # DS/ES contains default KERNEL segment
20136 movl %eax,%ds
20137 movl %eax,%es
20138
20139 movl $(__KERNEL_PERCPU), %eax
20140 movl %eax,%fs # set this cpu's percpu
20141
20142 +#ifdef CONFIG_CC_STACKPROTECTOR
20143 movl $(__KERNEL_STACK_CANARY),%eax
20144 +#elif defined(CONFIG_PAX_MEMORY_UDEREF)
20145 + movl $(__USER_DS),%eax
20146 +#else
20147 + xorl %eax,%eax
20148 +#endif
20149 movl %eax,%gs
20150
20151 xorl %eax,%eax # Clear LDT
20152 @@ -544,8 +626,11 @@ setup_once:
20153 * relocation. Manually set base address in stack canary
20154 * segment descriptor.
20155 */
20156 - movl $gdt_page,%eax
20157 + movl $cpu_gdt_table,%eax
20158 movl $stack_canary,%ecx
20159 +#ifdef CONFIG_SMP
20160 + addl $__per_cpu_load,%ecx
20161 +#endif
20162 movw %cx, 8 * GDT_ENTRY_STACK_CANARY + 2(%eax)
20163 shrl $16, %ecx
20164 movb %cl, 8 * GDT_ENTRY_STACK_CANARY + 4(%eax)
20165 @@ -576,7 +661,7 @@ ENDPROC(early_idt_handlers)
20166 /* This is global to keep gas from relaxing the jumps */
20167 ENTRY(early_idt_handler)
20168 cld
20169 - cmpl $2,%ss:early_recursion_flag
20170 + cmpl $1,%ss:early_recursion_flag
20171 je hlt_loop
20172 incl %ss:early_recursion_flag
20173
20174 @@ -614,8 +699,8 @@ ENTRY(early_idt_handler)
20175 pushl (20+6*4)(%esp) /* trapno */
20176 pushl $fault_msg
20177 call printk
20178 -#endif
20179 call dump_stack
20180 +#endif
20181 hlt_loop:
20182 hlt
20183 jmp hlt_loop
20184 @@ -634,8 +719,11 @@ ENDPROC(early_idt_handler)
20185 /* This is the default interrupt "handler" :-) */
20186 ALIGN
20187 ignore_int:
20188 - cld
20189 #ifdef CONFIG_PRINTK
20190 + cmpl $2,%ss:early_recursion_flag
20191 + je hlt_loop
20192 + incl %ss:early_recursion_flag
20193 + cld
20194 pushl %eax
20195 pushl %ecx
20196 pushl %edx
20197 @@ -644,9 +732,6 @@ ignore_int:
20198 movl $(__KERNEL_DS),%eax
20199 movl %eax,%ds
20200 movl %eax,%es
20201 - cmpl $2,early_recursion_flag
20202 - je hlt_loop
20203 - incl early_recursion_flag
20204 pushl 16(%esp)
20205 pushl 24(%esp)
20206 pushl 32(%esp)
20207 @@ -680,29 +765,43 @@ ENTRY(setup_once_ref)
20208 /*
20209 * BSS section
20210 */
20211 -__PAGE_ALIGNED_BSS
20212 - .align PAGE_SIZE
20213 #ifdef CONFIG_X86_PAE
20214 +.section .initial_pg_pmd,"a",@progbits
20215 initial_pg_pmd:
20216 .fill 1024*KPMDS,4,0
20217 #else
20218 +.section .initial_page_table,"a",@progbits
20219 ENTRY(initial_page_table)
20220 .fill 1024,4,0
20221 #endif
20222 +.section .initial_pg_fixmap,"a",@progbits
20223 initial_pg_fixmap:
20224 .fill 1024,4,0
20225 +.section .empty_zero_page,"a",@progbits
20226 ENTRY(empty_zero_page)
20227 .fill 4096,1,0
20228 +.section .swapper_pg_dir,"a",@progbits
20229 ENTRY(swapper_pg_dir)
20230 +#ifdef CONFIG_X86_PAE
20231 + .fill 4,8,0
20232 +#else
20233 .fill 1024,4,0
20234 +#endif
20235 +
20236 +/*
20237 + * The IDT has to be page-aligned to simplify the Pentium
20238 + * F0 0F bug workaround.. We have a special link segment
20239 + * for this.
20240 + */
20241 +.section .idt,"a",@progbits
20242 +ENTRY(idt_table)
20243 + .fill 256,8,0
20244
20245 /*
20246 * This starts the data section.
20247 */
20248 #ifdef CONFIG_X86_PAE
20249 -__PAGE_ALIGNED_DATA
20250 - /* Page-aligned for the benefit of paravirt? */
20251 - .align PAGE_SIZE
20252 +.section .initial_page_table,"a",@progbits
20253 ENTRY(initial_page_table)
20254 .long pa(initial_pg_pmd+PGD_IDENT_ATTR),0 /* low identity map */
20255 # if KPMDS == 3
20256 @@ -721,12 +820,20 @@ ENTRY(initial_page_table)
20257 # error "Kernel PMDs should be 1, 2 or 3"
20258 # endif
20259 .align PAGE_SIZE /* needs to be page-sized too */
20260 +
20261 +#ifdef CONFIG_PAX_PER_CPU_PGD
20262 +ENTRY(cpu_pgd)
20263 + .rept NR_CPUS
20264 + .fill 4,8,0
20265 + .endr
20266 +#endif
20267 +
20268 #endif
20269
20270 .data
20271 .balign 4
20272 ENTRY(stack_start)
20273 - .long init_thread_union+THREAD_SIZE
20274 + .long init_thread_union+THREAD_SIZE-8
20275
20276 __INITRODATA
20277 int_msg:
20278 @@ -754,7 +861,7 @@ fault_msg:
20279 * segment size, and 32-bit linear address value:
20280 */
20281
20282 - .data
20283 +.section .rodata,"a",@progbits
20284 .globl boot_gdt_descr
20285 .globl idt_descr
20286
20287 @@ -763,7 +870,7 @@ fault_msg:
20288 .word 0 # 32 bit align gdt_desc.address
20289 boot_gdt_descr:
20290 .word __BOOT_DS+7
20291 - .long boot_gdt - __PAGE_OFFSET
20292 + .long pa(boot_gdt)
20293
20294 .word 0 # 32-bit align idt_desc.address
20295 idt_descr:
20296 @@ -774,7 +881,7 @@ idt_descr:
20297 .word 0 # 32 bit align gdt_desc.address
20298 ENTRY(early_gdt_descr)
20299 .word GDT_ENTRIES*8-1
20300 - .long gdt_page /* Overwritten for secondary CPUs */
20301 + .long cpu_gdt_table /* Overwritten for secondary CPUs */
20302
20303 /*
20304 * The boot_gdt must mirror the equivalent in setup.S and is
20305 @@ -783,5 +890,65 @@ ENTRY(early_gdt_descr)
20306 .align L1_CACHE_BYTES
20307 ENTRY(boot_gdt)
20308 .fill GDT_ENTRY_BOOT_CS,8,0
20309 - .quad 0x00cf9a000000ffff /* kernel 4GB code at 0x00000000 */
20310 - .quad 0x00cf92000000ffff /* kernel 4GB data at 0x00000000 */
20311 + .quad 0x00cf9b000000ffff /* kernel 4GB code at 0x00000000 */
20312 + .quad 0x00cf93000000ffff /* kernel 4GB data at 0x00000000 */
20313 +
20314 + .align PAGE_SIZE_asm
20315 +ENTRY(cpu_gdt_table)
20316 + .rept NR_CPUS
20317 + .quad 0x0000000000000000 /* NULL descriptor */
20318 + .quad 0x0000000000000000 /* 0x0b reserved */
20319 + .quad 0x0000000000000000 /* 0x13 reserved */
20320 + .quad 0x0000000000000000 /* 0x1b reserved */
20321 +
20322 +#ifdef CONFIG_PAX_KERNEXEC
20323 + .quad 0x00cf9b000000ffff /* 0x20 alternate kernel 4GB code at 0x00000000 */
20324 +#else
20325 + .quad 0x0000000000000000 /* 0x20 unused */
20326 +#endif
20327 +
20328 + .quad 0x0000000000000000 /* 0x28 unused */
20329 + .quad 0x0000000000000000 /* 0x33 TLS entry 1 */
20330 + .quad 0x0000000000000000 /* 0x3b TLS entry 2 */
20331 + .quad 0x0000000000000000 /* 0x43 TLS entry 3 */
20332 + .quad 0x0000000000000000 /* 0x4b reserved */
20333 + .quad 0x0000000000000000 /* 0x53 reserved */
20334 + .quad 0x0000000000000000 /* 0x5b reserved */
20335 +
20336 + .quad 0x00cf9b000000ffff /* 0x60 kernel 4GB code at 0x00000000 */
20337 + .quad 0x00cf93000000ffff /* 0x68 kernel 4GB data at 0x00000000 */
20338 + .quad 0x00cffb000000ffff /* 0x73 user 4GB code at 0x00000000 */
20339 + .quad 0x00cff3000000ffff /* 0x7b user 4GB data at 0x00000000 */
20340 +
20341 + .quad 0x0000000000000000 /* 0x80 TSS descriptor */
20342 + .quad 0x0000000000000000 /* 0x88 LDT descriptor */
20343 +
20344 + /*
20345 + * Segments used for calling PnP BIOS have byte granularity.
20346 + * The code segments and data segments have fixed 64k limits,
20347 + * the transfer segment sizes are set at run time.
20348 + */
20349 + .quad 0x00409b000000ffff /* 0x90 32-bit code */
20350 + .quad 0x00009b000000ffff /* 0x98 16-bit code */
20351 + .quad 0x000093000000ffff /* 0xa0 16-bit data */
20352 + .quad 0x0000930000000000 /* 0xa8 16-bit data */
20353 + .quad 0x0000930000000000 /* 0xb0 16-bit data */
20354 +
20355 + /*
20356 + * The APM segments have byte granularity and their bases
20357 + * are set at run time. All have 64k limits.
20358 + */
20359 + .quad 0x00409b000000ffff /* 0xb8 APM CS code */
20360 + .quad 0x00009b000000ffff /* 0xc0 APM CS 16 code (16 bit) */
20361 + .quad 0x004093000000ffff /* 0xc8 APM DS data */
20362 +
20363 + .quad 0x00c0930000000000 /* 0xd0 - ESPFIX SS */
20364 + .quad 0x0040930000000000 /* 0xd8 - PERCPU */
20365 + .quad 0x0040910000000017 /* 0xe0 - STACK_CANARY */
20366 + .quad 0x0000000000000000 /* 0xe8 - PCIBIOS_CS */
20367 + .quad 0x0000000000000000 /* 0xf0 - PCIBIOS_DS */
20368 + .quad 0x0000000000000000 /* 0xf8 - GDT entry 31: double-fault TSS */
20369 +
20370 + /* Be sure this is zeroed to avoid false validations in Xen */
20371 + .fill PAGE_SIZE_asm - GDT_SIZE,1,0
20372 + .endr
20373 diff --git a/arch/x86/kernel/head_64.S b/arch/x86/kernel/head_64.S
20374 index 980053c..74d3b44 100644
20375 --- a/arch/x86/kernel/head_64.S
20376 +++ b/arch/x86/kernel/head_64.S
20377 @@ -20,6 +20,8 @@
20378 #include <asm/processor-flags.h>
20379 #include <asm/percpu.h>
20380 #include <asm/nops.h>
20381 +#include <asm/cpufeature.h>
20382 +#include <asm/alternative-asm.h>
20383
20384 #ifdef CONFIG_PARAVIRT
20385 #include <asm/asm-offsets.h>
20386 @@ -41,6 +43,12 @@ L4_PAGE_OFFSET = pgd_index(__PAGE_OFFSET)
20387 L3_PAGE_OFFSET = pud_index(__PAGE_OFFSET)
20388 L4_START_KERNEL = pgd_index(__START_KERNEL_map)
20389 L3_START_KERNEL = pud_index(__START_KERNEL_map)
20390 +L4_VMALLOC_START = pgd_index(VMALLOC_START)
20391 +L3_VMALLOC_START = pud_index(VMALLOC_START)
20392 +L4_VMALLOC_END = pgd_index(VMALLOC_END)
20393 +L3_VMALLOC_END = pud_index(VMALLOC_END)
20394 +L4_VMEMMAP_START = pgd_index(VMEMMAP_START)
20395 +L3_VMEMMAP_START = pud_index(VMEMMAP_START)
20396
20397 .text
20398 __HEAD
20399 @@ -88,35 +96,23 @@ startup_64:
20400 */
20401 addq %rbp, init_level4_pgt + 0(%rip)
20402 addq %rbp, init_level4_pgt + (L4_PAGE_OFFSET*8)(%rip)
20403 + addq %rbp, init_level4_pgt + (L4_VMALLOC_START*8)(%rip)
20404 + addq %rbp, init_level4_pgt + (L4_VMALLOC_END*8)(%rip)
20405 + addq %rbp, init_level4_pgt + (L4_VMEMMAP_START*8)(%rip)
20406 addq %rbp, init_level4_pgt + (L4_START_KERNEL*8)(%rip)
20407
20408 addq %rbp, level3_ident_pgt + 0(%rip)
20409 +#ifndef CONFIG_XEN
20410 + addq %rbp, level3_ident_pgt + 8(%rip)
20411 +#endif
20412
20413 - addq %rbp, level3_kernel_pgt + (510*8)(%rip)
20414 - addq %rbp, level3_kernel_pgt + (511*8)(%rip)
20415 + addq %rbp, level3_vmemmap_pgt + (L3_VMEMMAP_START*8)(%rip)
20416 +
20417 + addq %rbp, level3_kernel_pgt + (L3_START_KERNEL*8)(%rip)
20418 + addq %rbp, level3_kernel_pgt + (L3_START_KERNEL*8+8)(%rip)
20419
20420 addq %rbp, level2_fixmap_pgt + (506*8)(%rip)
20421 -
20422 - /* Add an Identity mapping if I am above 1G */
20423 - leaq _text(%rip), %rdi
20424 - andq $PMD_PAGE_MASK, %rdi
20425 -
20426 - movq %rdi, %rax
20427 - shrq $PUD_SHIFT, %rax
20428 - andq $(PTRS_PER_PUD - 1), %rax
20429 - jz ident_complete
20430 -
20431 - leaq (level2_spare_pgt - __START_KERNEL_map + _KERNPG_TABLE)(%rbp), %rdx
20432 - leaq level3_ident_pgt(%rip), %rbx
20433 - movq %rdx, 0(%rbx, %rax, 8)
20434 -
20435 - movq %rdi, %rax
20436 - shrq $PMD_SHIFT, %rax
20437 - andq $(PTRS_PER_PMD - 1), %rax
20438 - leaq __PAGE_KERNEL_IDENT_LARGE_EXEC(%rdi), %rdx
20439 - leaq level2_spare_pgt(%rip), %rbx
20440 - movq %rdx, 0(%rbx, %rax, 8)
20441 -ident_complete:
20442 + addq %rbp, level2_fixmap_pgt + (507*8)(%rip)
20443
20444 /*
20445 * Fixup the kernel text+data virtual addresses. Note that
20446 @@ -159,8 +155,8 @@ ENTRY(secondary_startup_64)
20447 * after the boot processor executes this code.
20448 */
20449
20450 - /* Enable PAE mode and PGE */
20451 - movl $(X86_CR4_PAE | X86_CR4_PGE), %eax
20452 + /* Enable PAE mode and PSE/PGE */
20453 + movl $(X86_CR4_PSE | X86_CR4_PAE | X86_CR4_PGE), %eax
20454 movq %rax, %cr4
20455
20456 /* Setup early boot stage 4 level pagetables. */
20457 @@ -182,9 +178,17 @@ ENTRY(secondary_startup_64)
20458 movl $MSR_EFER, %ecx
20459 rdmsr
20460 btsl $_EFER_SCE, %eax /* Enable System Call */
20461 - btl $20,%edi /* No Execute supported? */
20462 + btl $(X86_FEATURE_NX & 31),%edi /* No Execute supported? */
20463 jnc 1f
20464 btsl $_EFER_NX, %eax
20465 + leaq init_level4_pgt(%rip), %rdi
20466 +#ifndef CONFIG_EFI
20467 + btsq $_PAGE_BIT_NX, 8*L4_PAGE_OFFSET(%rdi)
20468 +#endif
20469 + btsq $_PAGE_BIT_NX, 8*L4_VMALLOC_START(%rdi)
20470 + btsq $_PAGE_BIT_NX, 8*L4_VMALLOC_END(%rdi)
20471 + btsq $_PAGE_BIT_NX, 8*L4_VMEMMAP_START(%rdi)
20472 + btsq $_PAGE_BIT_NX, __supported_pte_mask(%rip)
20473 1: wrmsr /* Make changes effective */
20474
20475 /* Setup cr0 */
20476 @@ -246,6 +250,7 @@ ENTRY(secondary_startup_64)
20477 * jump. In addition we need to ensure %cs is set so we make this
20478 * a far return.
20479 */
20480 + pax_set_fptr_mask
20481 movq initial_code(%rip),%rax
20482 pushq $0 # fake return address to stop unwinder
20483 pushq $__KERNEL_CS # set correct cs
20484 @@ -284,7 +289,7 @@ ENDPROC(start_cpu0)
20485 bad_address:
20486 jmp bad_address
20487
20488 - .section ".init.text","ax"
20489 + __INIT
20490 .globl early_idt_handlers
20491 early_idt_handlers:
20492 # 104(%rsp) %rflags
20493 @@ -343,7 +348,7 @@ ENTRY(early_idt_handler)
20494 call dump_stack
20495 #ifdef CONFIG_KALLSYMS
20496 leaq early_idt_ripmsg(%rip),%rdi
20497 - movq 40(%rsp),%rsi # %rip again
20498 + movq 88(%rsp),%rsi # %rip again
20499 call __print_symbol
20500 #endif
20501 #endif /* EARLY_PRINTK */
20502 @@ -363,11 +368,15 @@ ENTRY(early_idt_handler)
20503 addq $16,%rsp # drop vector number and error code
20504 decl early_recursion_flag(%rip)
20505 INTERRUPT_RETURN
20506 + .previous
20507
20508 + __INITDATA
20509 .balign 4
20510 early_recursion_flag:
20511 .long 0
20512 + .previous
20513
20514 + .section .rodata,"a",@progbits
20515 #ifdef CONFIG_EARLY_PRINTK
20516 early_idt_msg:
20517 .asciz "PANIC: early exception %02lx rip %lx:%lx error %lx cr2 %lx\n"
20518 @@ -376,6 +385,7 @@ early_idt_ripmsg:
20519 #endif /* CONFIG_EARLY_PRINTK */
20520 .previous
20521
20522 + .section .rodata,"a",@progbits
20523 #define NEXT_PAGE(name) \
20524 .balign PAGE_SIZE; \
20525 ENTRY(name)
20526 @@ -388,7 +398,6 @@ ENTRY(name)
20527 i = i + 1 ; \
20528 .endr
20529
20530 - .data
20531 /*
20532 * This default setting generates an ident mapping at address 0x100000
20533 * and a mapping for the kernel that precisely maps virtual address
20534 @@ -399,13 +408,41 @@ NEXT_PAGE(init_level4_pgt)
20535 .quad level3_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE
20536 .org init_level4_pgt + L4_PAGE_OFFSET*8, 0
20537 .quad level3_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE
20538 + .org init_level4_pgt + L4_VMALLOC_START*8, 0
20539 + .quad level3_vmalloc_start_pgt - __START_KERNEL_map + _KERNPG_TABLE
20540 + .org init_level4_pgt + L4_VMALLOC_END*8, 0
20541 + .quad level3_vmalloc_end_pgt - __START_KERNEL_map + _KERNPG_TABLE
20542 + .org init_level4_pgt + L4_VMEMMAP_START*8, 0
20543 + .quad level3_vmemmap_pgt - __START_KERNEL_map + _KERNPG_TABLE
20544 .org init_level4_pgt + L4_START_KERNEL*8, 0
20545 /* (2^48-(2*1024*1024*1024))/(2^39) = 511 */
20546 .quad level3_kernel_pgt - __START_KERNEL_map + _PAGE_TABLE
20547
20548 +#ifdef CONFIG_PAX_PER_CPU_PGD
20549 +NEXT_PAGE(cpu_pgd)
20550 + .rept NR_CPUS
20551 + .fill 512,8,0
20552 + .endr
20553 +#endif
20554 +
20555 NEXT_PAGE(level3_ident_pgt)
20556 .quad level2_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE
20557 +#ifdef CONFIG_XEN
20558 .fill 511,8,0
20559 +#else
20560 + .quad level2_ident_pgt + PAGE_SIZE - __START_KERNEL_map + _KERNPG_TABLE
20561 + .fill 510,8,0
20562 +#endif
20563 +
20564 +NEXT_PAGE(level3_vmalloc_start_pgt)
20565 + .fill 512,8,0
20566 +
20567 +NEXT_PAGE(level3_vmalloc_end_pgt)
20568 + .fill 512,8,0
20569 +
20570 +NEXT_PAGE(level3_vmemmap_pgt)
20571 + .fill L3_VMEMMAP_START,8,0
20572 + .quad level2_vmemmap_pgt - __START_KERNEL_map + _KERNPG_TABLE
20573
20574 NEXT_PAGE(level3_kernel_pgt)
20575 .fill L3_START_KERNEL,8,0
20576 @@ -413,20 +450,23 @@ NEXT_PAGE(level3_kernel_pgt)
20577 .quad level2_kernel_pgt - __START_KERNEL_map + _KERNPG_TABLE
20578 .quad level2_fixmap_pgt - __START_KERNEL_map + _PAGE_TABLE
20579
20580 +NEXT_PAGE(level2_vmemmap_pgt)
20581 + .fill 512,8,0
20582 +
20583 NEXT_PAGE(level2_fixmap_pgt)
20584 - .fill 506,8,0
20585 - .quad level1_fixmap_pgt - __START_KERNEL_map + _PAGE_TABLE
20586 - /* 8MB reserved for vsyscalls + a 2MB hole = 4 + 1 entries */
20587 - .fill 5,8,0
20588 + .fill 507,8,0
20589 + .quad level1_vsyscall_pgt - __START_KERNEL_map + _PAGE_TABLE
20590 + /* 6MB reserved for vsyscalls + a 2MB hole = 3 + 1 entries */
20591 + .fill 4,8,0
20592
20593 -NEXT_PAGE(level1_fixmap_pgt)
20594 +NEXT_PAGE(level1_vsyscall_pgt)
20595 .fill 512,8,0
20596
20597 -NEXT_PAGE(level2_ident_pgt)
20598 - /* Since I easily can, map the first 1G.
20599 + /* Since I easily can, map the first 2G.
20600 * Don't set NX because code runs from these pages.
20601 */
20602 - PMDS(0, __PAGE_KERNEL_IDENT_LARGE_EXEC, PTRS_PER_PMD)
20603 +NEXT_PAGE(level2_ident_pgt)
20604 + PMDS(0, __PAGE_KERNEL_IDENT_LARGE_EXEC, 2*PTRS_PER_PMD)
20605
20606 NEXT_PAGE(level2_kernel_pgt)
20607 /*
20608 @@ -439,37 +479,59 @@ NEXT_PAGE(level2_kernel_pgt)
20609 * If you want to increase this then increase MODULES_VADDR
20610 * too.)
20611 */
20612 - PMDS(0, __PAGE_KERNEL_LARGE_EXEC,
20613 - KERNEL_IMAGE_SIZE/PMD_SIZE)
20614 -
20615 -NEXT_PAGE(level2_spare_pgt)
20616 - .fill 512, 8, 0
20617 + PMDS(0, __PAGE_KERNEL_LARGE_EXEC, KERNEL_IMAGE_SIZE/PMD_SIZE)
20618
20619 #undef PMDS
20620 #undef NEXT_PAGE
20621
20622 - .data
20623 + .align PAGE_SIZE
20624 +ENTRY(cpu_gdt_table)
20625 + .rept NR_CPUS
20626 + .quad 0x0000000000000000 /* NULL descriptor */
20627 + .quad 0x00cf9b000000ffff /* __KERNEL32_CS */
20628 + .quad 0x00af9b000000ffff /* __KERNEL_CS */
20629 + .quad 0x00cf93000000ffff /* __KERNEL_DS */
20630 + .quad 0x00cffb000000ffff /* __USER32_CS */
20631 + .quad 0x00cff3000000ffff /* __USER_DS, __USER32_DS */
20632 + .quad 0x00affb000000ffff /* __USER_CS */
20633 +
20634 +#ifdef CONFIG_PAX_KERNEXEC
20635 + .quad 0x00af9b000000ffff /* __KERNEXEC_KERNEL_CS */
20636 +#else
20637 + .quad 0x0 /* unused */
20638 +#endif
20639 +
20640 + .quad 0,0 /* TSS */
20641 + .quad 0,0 /* LDT */
20642 + .quad 0,0,0 /* three TLS descriptors */
20643 + .quad 0x0000f40000000000 /* node/CPU stored in limit */
20644 + /* asm/segment.h:GDT_ENTRIES must match this */
20645 +
20646 + /* zero the remaining page */
20647 + .fill PAGE_SIZE / 8 - GDT_ENTRIES,8,0
20648 + .endr
20649 +
20650 .align 16
20651 .globl early_gdt_descr
20652 early_gdt_descr:
20653 .word GDT_ENTRIES*8-1
20654 early_gdt_descr_base:
20655 - .quad INIT_PER_CPU_VAR(gdt_page)
20656 + .quad cpu_gdt_table
20657
20658 ENTRY(phys_base)
20659 /* This must match the first entry in level2_kernel_pgt */
20660 .quad 0x0000000000000000
20661
20662 #include "../../x86/xen/xen-head.S"
20663 -
20664 - .section .bss, "aw", @nobits
20665 +
20666 + .section .rodata,"a",@progbits
20667 .align L1_CACHE_BYTES
20668 ENTRY(idt_table)
20669 - .skip IDT_ENTRIES * 16
20670 + .fill 512,8,0
20671
20672 .align L1_CACHE_BYTES
20673 ENTRY(nmi_idt_table)
20674 - .skip IDT_ENTRIES * 16
20675 + .fill 512,8,0
20676
20677 __PAGE_ALIGNED_BSS
20678 .align PAGE_SIZE
20679 diff --git a/arch/x86/kernel/i386_ksyms_32.c b/arch/x86/kernel/i386_ksyms_32.c
20680 index 9c3bd4a..e1d9b35 100644
20681 --- a/arch/x86/kernel/i386_ksyms_32.c
20682 +++ b/arch/x86/kernel/i386_ksyms_32.c
20683 @@ -20,8 +20,12 @@ extern void cmpxchg8b_emu(void);
20684 EXPORT_SYMBOL(cmpxchg8b_emu);
20685 #endif
20686
20687 +EXPORT_SYMBOL_GPL(cpu_gdt_table);
20688 +
20689 /* Networking helper routines. */
20690 EXPORT_SYMBOL(csum_partial_copy_generic);
20691 +EXPORT_SYMBOL(csum_partial_copy_generic_to_user);
20692 +EXPORT_SYMBOL(csum_partial_copy_generic_from_user);
20693
20694 EXPORT_SYMBOL(__get_user_1);
20695 EXPORT_SYMBOL(__get_user_2);
20696 @@ -36,3 +40,7 @@ EXPORT_SYMBOL(strstr);
20697
20698 EXPORT_SYMBOL(csum_partial);
20699 EXPORT_SYMBOL(empty_zero_page);
20700 +
20701 +#ifdef CONFIG_PAX_KERNEXEC
20702 +EXPORT_SYMBOL(__LOAD_PHYSICAL_ADDR);
20703 +#endif
20704 diff --git a/arch/x86/kernel/i387.c b/arch/x86/kernel/i387.c
20705 index 245a71d..89d9ce4 100644
20706 --- a/arch/x86/kernel/i387.c
20707 +++ b/arch/x86/kernel/i387.c
20708 @@ -55,7 +55,7 @@ static inline bool interrupted_kernel_fpu_idle(void)
20709 static inline bool interrupted_user_mode(void)
20710 {
20711 struct pt_regs *regs = get_irq_regs();
20712 - return regs && user_mode_vm(regs);
20713 + return regs && user_mode(regs);
20714 }
20715
20716 /*
20717 diff --git a/arch/x86/kernel/i8259.c b/arch/x86/kernel/i8259.c
20718 index 9a5c460..b332a4b 100644
20719 --- a/arch/x86/kernel/i8259.c
20720 +++ b/arch/x86/kernel/i8259.c
20721 @@ -209,7 +209,7 @@ spurious_8259A_irq:
20722 "spurious 8259A interrupt: IRQ%d.\n", irq);
20723 spurious_irq_mask |= irqmask;
20724 }
20725 - atomic_inc(&irq_err_count);
20726 + atomic_inc_unchecked(&irq_err_count);
20727 /*
20728 * Theoretically we do not have to handle this IRQ,
20729 * but in Linux this does not cause problems and is
20730 @@ -333,14 +333,16 @@ static void init_8259A(int auto_eoi)
20731 /* (slave's support for AEOI in flat mode is to be investigated) */
20732 outb_pic(SLAVE_ICW4_DEFAULT, PIC_SLAVE_IMR);
20733
20734 + pax_open_kernel();
20735 if (auto_eoi)
20736 /*
20737 * In AEOI mode we just have to mask the interrupt
20738 * when acking.
20739 */
20740 - i8259A_chip.irq_mask_ack = disable_8259A_irq;
20741 + *(void **)&i8259A_chip.irq_mask_ack = disable_8259A_irq;
20742 else
20743 - i8259A_chip.irq_mask_ack = mask_and_ack_8259A;
20744 + *(void **)&i8259A_chip.irq_mask_ack = mask_and_ack_8259A;
20745 + pax_close_kernel();
20746
20747 udelay(100); /* wait for 8259A to initialize */
20748
20749 diff --git a/arch/x86/kernel/io_delay.c b/arch/x86/kernel/io_delay.c
20750 index a979b5b..1d6db75 100644
20751 --- a/arch/x86/kernel/io_delay.c
20752 +++ b/arch/x86/kernel/io_delay.c
20753 @@ -58,7 +58,7 @@ static int __init dmi_io_delay_0xed_port(const struct dmi_system_id *id)
20754 * Quirk table for systems that misbehave (lock up, etc.) if port
20755 * 0x80 is used:
20756 */
20757 -static struct dmi_system_id __initdata io_delay_0xed_port_dmi_table[] = {
20758 +static const struct dmi_system_id __initconst io_delay_0xed_port_dmi_table[] = {
20759 {
20760 .callback = dmi_io_delay_0xed_port,
20761 .ident = "Compaq Presario V6000",
20762 diff --git a/arch/x86/kernel/ioport.c b/arch/x86/kernel/ioport.c
20763 index 8c96897..be66bfa 100644
20764 --- a/arch/x86/kernel/ioport.c
20765 +++ b/arch/x86/kernel/ioport.c
20766 @@ -6,6 +6,7 @@
20767 #include <linux/sched.h>
20768 #include <linux/kernel.h>
20769 #include <linux/capability.h>
20770 +#include <linux/security.h>
20771 #include <linux/errno.h>
20772 #include <linux/types.h>
20773 #include <linux/ioport.h>
20774 @@ -28,6 +29,12 @@ asmlinkage long sys_ioperm(unsigned long from, unsigned long num, int turn_on)
20775
20776 if ((from + num <= from) || (from + num > IO_BITMAP_BITS))
20777 return -EINVAL;
20778 +#ifdef CONFIG_GRKERNSEC_IO
20779 + if (turn_on && grsec_disable_privio) {
20780 + gr_handle_ioperm();
20781 + return -EPERM;
20782 + }
20783 +#endif
20784 if (turn_on && !capable(CAP_SYS_RAWIO))
20785 return -EPERM;
20786
20787 @@ -54,7 +61,7 @@ asmlinkage long sys_ioperm(unsigned long from, unsigned long num, int turn_on)
20788 * because the ->io_bitmap_max value must match the bitmap
20789 * contents:
20790 */
20791 - tss = &per_cpu(init_tss, get_cpu());
20792 + tss = init_tss + get_cpu();
20793
20794 if (turn_on)
20795 bitmap_clear(t->io_bitmap_ptr, from, num);
20796 @@ -102,6 +109,12 @@ long sys_iopl(unsigned int level, struct pt_regs *regs)
20797 return -EINVAL;
20798 /* Trying to gain more privileges? */
20799 if (level > old) {
20800 +#ifdef CONFIG_GRKERNSEC_IO
20801 + if (grsec_disable_privio) {
20802 + gr_handle_iopl();
20803 + return -EPERM;
20804 + }
20805 +#endif
20806 if (!capable(CAP_SYS_RAWIO))
20807 return -EPERM;
20808 }
20809 diff --git a/arch/x86/kernel/irq.c b/arch/x86/kernel/irq.c
20810 index e4595f1..ee3bfb8 100644
20811 --- a/arch/x86/kernel/irq.c
20812 +++ b/arch/x86/kernel/irq.c
20813 @@ -18,7 +18,7 @@
20814 #include <asm/mce.h>
20815 #include <asm/hw_irq.h>
20816
20817 -atomic_t irq_err_count;
20818 +atomic_unchecked_t irq_err_count;
20819
20820 /* Function pointer for generic interrupt vector handling */
20821 void (*x86_platform_ipi_callback)(void) = NULL;
20822 @@ -122,9 +122,9 @@ int arch_show_interrupts(struct seq_file *p, int prec)
20823 seq_printf(p, "%10u ", per_cpu(mce_poll_count, j));
20824 seq_printf(p, " Machine check polls\n");
20825 #endif
20826 - seq_printf(p, "%*s: %10u\n", prec, "ERR", atomic_read(&irq_err_count));
20827 + seq_printf(p, "%*s: %10u\n", prec, "ERR", atomic_read_unchecked(&irq_err_count));
20828 #if defined(CONFIG_X86_IO_APIC)
20829 - seq_printf(p, "%*s: %10u\n", prec, "MIS", atomic_read(&irq_mis_count));
20830 + seq_printf(p, "%*s: %10u\n", prec, "MIS", atomic_read_unchecked(&irq_mis_count));
20831 #endif
20832 return 0;
20833 }
20834 @@ -164,10 +164,10 @@ u64 arch_irq_stat_cpu(unsigned int cpu)
20835
20836 u64 arch_irq_stat(void)
20837 {
20838 - u64 sum = atomic_read(&irq_err_count);
20839 + u64 sum = atomic_read_unchecked(&irq_err_count);
20840
20841 #ifdef CONFIG_X86_IO_APIC
20842 - sum += atomic_read(&irq_mis_count);
20843 + sum += atomic_read_unchecked(&irq_mis_count);
20844 #endif
20845 return sum;
20846 }
20847 diff --git a/arch/x86/kernel/irq_32.c b/arch/x86/kernel/irq_32.c
20848 index 344faf8..355f60d 100644
20849 --- a/arch/x86/kernel/irq_32.c
20850 +++ b/arch/x86/kernel/irq_32.c
20851 @@ -39,7 +39,7 @@ static int check_stack_overflow(void)
20852 __asm__ __volatile__("andl %%esp,%0" :
20853 "=r" (sp) : "0" (THREAD_SIZE - 1));
20854
20855 - return sp < (sizeof(struct thread_info) + STACK_WARN);
20856 + return sp < STACK_WARN;
20857 }
20858
20859 static void print_stack_overflow(void)
20860 @@ -59,8 +59,8 @@ static inline void print_stack_overflow(void) { }
20861 * per-CPU IRQ handling contexts (thread information and stack)
20862 */
20863 union irq_ctx {
20864 - struct thread_info tinfo;
20865 - u32 stack[THREAD_SIZE/sizeof(u32)];
20866 + unsigned long previous_esp;
20867 + u32 stack[THREAD_SIZE/sizeof(u32)];
20868 } __attribute__((aligned(THREAD_SIZE)));
20869
20870 static DEFINE_PER_CPU(union irq_ctx *, hardirq_ctx);
20871 @@ -80,10 +80,9 @@ static void call_on_stack(void *func, void *stack)
20872 static inline int
20873 execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
20874 {
20875 - union irq_ctx *curctx, *irqctx;
20876 + union irq_ctx *irqctx;
20877 u32 *isp, arg1, arg2;
20878
20879 - curctx = (union irq_ctx *) current_thread_info();
20880 irqctx = __this_cpu_read(hardirq_ctx);
20881
20882 /*
20883 @@ -92,16 +91,16 @@ execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
20884 * handler) we can't do that and just have to keep using the
20885 * current stack (which is the irq stack already after all)
20886 */
20887 - if (unlikely(curctx == irqctx))
20888 + if (unlikely((void *)current_stack_pointer - (void *)irqctx < THREAD_SIZE))
20889 return 0;
20890
20891 /* build the stack frame on the IRQ stack */
20892 - isp = (u32 *) ((char *)irqctx + sizeof(*irqctx));
20893 - irqctx->tinfo.task = curctx->tinfo.task;
20894 - irqctx->tinfo.previous_esp = current_stack_pointer;
20895 + isp = (u32 *) ((char *)irqctx + sizeof(*irqctx) - 8);
20896 + irqctx->previous_esp = current_stack_pointer;
20897
20898 - /* Copy the preempt_count so that the [soft]irq checks work. */
20899 - irqctx->tinfo.preempt_count = curctx->tinfo.preempt_count;
20900 +#ifdef CONFIG_PAX_MEMORY_UDEREF
20901 + __set_fs(MAKE_MM_SEG(0));
20902 +#endif
20903
20904 if (unlikely(overflow))
20905 call_on_stack(print_stack_overflow, isp);
20906 @@ -113,6 +112,11 @@ execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
20907 : "0" (irq), "1" (desc), "2" (isp),
20908 "D" (desc->handle_irq)
20909 : "memory", "cc", "ecx");
20910 +
20911 +#ifdef CONFIG_PAX_MEMORY_UDEREF
20912 + __set_fs(current_thread_info()->addr_limit);
20913 +#endif
20914 +
20915 return 1;
20916 }
20917
20918 @@ -121,29 +125,14 @@ execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
20919 */
20920 void __cpuinit irq_ctx_init(int cpu)
20921 {
20922 - union irq_ctx *irqctx;
20923 -
20924 if (per_cpu(hardirq_ctx, cpu))
20925 return;
20926
20927 - irqctx = page_address(alloc_pages_node(cpu_to_node(cpu),
20928 - THREADINFO_GFP,
20929 - THREAD_SIZE_ORDER));
20930 - memset(&irqctx->tinfo, 0, sizeof(struct thread_info));
20931 - irqctx->tinfo.cpu = cpu;
20932 - irqctx->tinfo.preempt_count = HARDIRQ_OFFSET;
20933 - irqctx->tinfo.addr_limit = MAKE_MM_SEG(0);
20934 -
20935 - per_cpu(hardirq_ctx, cpu) = irqctx;
20936 -
20937 - irqctx = page_address(alloc_pages_node(cpu_to_node(cpu),
20938 - THREADINFO_GFP,
20939 - THREAD_SIZE_ORDER));
20940 - memset(&irqctx->tinfo, 0, sizeof(struct thread_info));
20941 - irqctx->tinfo.cpu = cpu;
20942 - irqctx->tinfo.addr_limit = MAKE_MM_SEG(0);
20943 -
20944 - per_cpu(softirq_ctx, cpu) = irqctx;
20945 + per_cpu(hardirq_ctx, cpu) = page_address(alloc_pages_node(cpu_to_node(cpu), THREADINFO_GFP, THREAD_SIZE_ORDER));
20946 + per_cpu(softirq_ctx, cpu) = page_address(alloc_pages_node(cpu_to_node(cpu), THREADINFO_GFP, THREAD_SIZE_ORDER));
20947 +
20948 + printk(KERN_DEBUG "CPU %u irqstacks, hard=%p soft=%p\n",
20949 + cpu, per_cpu(hardirq_ctx, cpu), per_cpu(softirq_ctx, cpu));
20950
20951 printk(KERN_DEBUG "CPU %u irqstacks, hard=%p soft=%p\n",
20952 cpu, per_cpu(hardirq_ctx, cpu), per_cpu(softirq_ctx, cpu));
20953 @@ -152,7 +141,6 @@ void __cpuinit irq_ctx_init(int cpu)
20954 asmlinkage void do_softirq(void)
20955 {
20956 unsigned long flags;
20957 - struct thread_info *curctx;
20958 union irq_ctx *irqctx;
20959 u32 *isp;
20960
20961 @@ -162,15 +150,22 @@ asmlinkage void do_softirq(void)
20962 local_irq_save(flags);
20963
20964 if (local_softirq_pending()) {
20965 - curctx = current_thread_info();
20966 irqctx = __this_cpu_read(softirq_ctx);
20967 - irqctx->tinfo.task = curctx->task;
20968 - irqctx->tinfo.previous_esp = current_stack_pointer;
20969 + irqctx->previous_esp = current_stack_pointer;
20970
20971 /* build the stack frame on the softirq stack */
20972 - isp = (u32 *) ((char *)irqctx + sizeof(*irqctx));
20973 + isp = (u32 *) ((char *)irqctx + sizeof(*irqctx) - 8);
20974 +
20975 +#ifdef CONFIG_PAX_MEMORY_UDEREF
20976 + __set_fs(MAKE_MM_SEG(0));
20977 +#endif
20978
20979 call_on_stack(__do_softirq, isp);
20980 +
20981 +#ifdef CONFIG_PAX_MEMORY_UDEREF
20982 + __set_fs(current_thread_info()->addr_limit);
20983 +#endif
20984 +
20985 /*
20986 * Shouldn't happen, we returned above if in_interrupt():
20987 */
20988 @@ -191,7 +186,7 @@ bool handle_irq(unsigned irq, struct pt_regs *regs)
20989 if (unlikely(!desc))
20990 return false;
20991
20992 - if (user_mode_vm(regs) || !execute_on_irq_stack(overflow, desc, irq)) {
20993 + if (user_mode(regs) || !execute_on_irq_stack(overflow, desc, irq)) {
20994 if (unlikely(overflow))
20995 print_stack_overflow();
20996 desc->handle_irq(irq, desc);
20997 diff --git a/arch/x86/kernel/irq_64.c b/arch/x86/kernel/irq_64.c
20998 index d04d3ec..ea4b374 100644
20999 --- a/arch/x86/kernel/irq_64.c
21000 +++ b/arch/x86/kernel/irq_64.c
21001 @@ -44,7 +44,7 @@ static inline void stack_overflow_check(struct pt_regs *regs)
21002 u64 estack_top, estack_bottom;
21003 u64 curbase = (u64)task_stack_page(current);
21004
21005 - if (user_mode_vm(regs))
21006 + if (user_mode(regs))
21007 return;
21008
21009 if (regs->sp >= curbase + sizeof(struct thread_info) +
21010 diff --git a/arch/x86/kernel/kdebugfs.c b/arch/x86/kernel/kdebugfs.c
21011 index dc1404b..bbc43e7 100644
21012 --- a/arch/x86/kernel/kdebugfs.c
21013 +++ b/arch/x86/kernel/kdebugfs.c
21014 @@ -27,7 +27,7 @@ struct setup_data_node {
21015 u32 len;
21016 };
21017
21018 -static ssize_t setup_data_read(struct file *file, char __user *user_buf,
21019 +static ssize_t __size_overflow(3) setup_data_read(struct file *file, char __user *user_buf,
21020 size_t count, loff_t *ppos)
21021 {
21022 struct setup_data_node *node = file->private_data;
21023 diff --git a/arch/x86/kernel/kgdb.c b/arch/x86/kernel/kgdb.c
21024 index 836f832..a8bda67 100644
21025 --- a/arch/x86/kernel/kgdb.c
21026 +++ b/arch/x86/kernel/kgdb.c
21027 @@ -127,11 +127,11 @@ char *dbg_get_reg(int regno, void *mem, struct pt_regs *regs)
21028 #ifdef CONFIG_X86_32
21029 switch (regno) {
21030 case GDB_SS:
21031 - if (!user_mode_vm(regs))
21032 + if (!user_mode(regs))
21033 *(unsigned long *)mem = __KERNEL_DS;
21034 break;
21035 case GDB_SP:
21036 - if (!user_mode_vm(regs))
21037 + if (!user_mode(regs))
21038 *(unsigned long *)mem = kernel_stack_pointer(regs);
21039 break;
21040 case GDB_GS:
21041 @@ -229,7 +229,10 @@ static void kgdb_correct_hw_break(void)
21042 bp->attr.bp_addr = breakinfo[breakno].addr;
21043 bp->attr.bp_len = breakinfo[breakno].len;
21044 bp->attr.bp_type = breakinfo[breakno].type;
21045 - info->address = breakinfo[breakno].addr;
21046 + if (breakinfo[breakno].type == X86_BREAKPOINT_EXECUTE)
21047 + info->address = ktla_ktva(breakinfo[breakno].addr);
21048 + else
21049 + info->address = breakinfo[breakno].addr;
21050 info->len = breakinfo[breakno].len;
21051 info->type = breakinfo[breakno].type;
21052 val = arch_install_hw_breakpoint(bp);
21053 @@ -476,12 +479,12 @@ int kgdb_arch_handle_exception(int e_vector, int signo, int err_code,
21054 case 'k':
21055 /* clear the trace bit */
21056 linux_regs->flags &= ~X86_EFLAGS_TF;
21057 - atomic_set(&kgdb_cpu_doing_single_step, -1);
21058 + atomic_set_unchecked(&kgdb_cpu_doing_single_step, -1);
21059
21060 /* set the trace bit if we're stepping */
21061 if (remcomInBuffer[0] == 's') {
21062 linux_regs->flags |= X86_EFLAGS_TF;
21063 - atomic_set(&kgdb_cpu_doing_single_step,
21064 + atomic_set_unchecked(&kgdb_cpu_doing_single_step,
21065 raw_smp_processor_id());
21066 }
21067
21068 @@ -546,7 +549,7 @@ static int __kgdb_notify(struct die_args *args, unsigned long cmd)
21069
21070 switch (cmd) {
21071 case DIE_DEBUG:
21072 - if (atomic_read(&kgdb_cpu_doing_single_step) != -1) {
21073 + if (atomic_read_unchecked(&kgdb_cpu_doing_single_step) != -1) {
21074 if (user_mode(regs))
21075 return single_step_cont(regs, args);
21076 break;
21077 @@ -751,11 +754,11 @@ int kgdb_arch_set_breakpoint(struct kgdb_bkpt *bpt)
21078 #endif /* CONFIG_DEBUG_RODATA */
21079
21080 bpt->type = BP_BREAKPOINT;
21081 - err = probe_kernel_read(bpt->saved_instr, (char *)bpt->bpt_addr,
21082 + err = probe_kernel_read(bpt->saved_instr, ktla_ktva((char *)bpt->bpt_addr),
21083 BREAK_INSTR_SIZE);
21084 if (err)
21085 return err;
21086 - err = probe_kernel_write((char *)bpt->bpt_addr,
21087 + err = probe_kernel_write(ktla_ktva((char *)bpt->bpt_addr),
21088 arch_kgdb_ops.gdb_bpt_instr, BREAK_INSTR_SIZE);
21089 #ifdef CONFIG_DEBUG_RODATA
21090 if (!err)
21091 @@ -768,7 +771,7 @@ int kgdb_arch_set_breakpoint(struct kgdb_bkpt *bpt)
21092 return -EBUSY;
21093 text_poke((void *)bpt->bpt_addr, arch_kgdb_ops.gdb_bpt_instr,
21094 BREAK_INSTR_SIZE);
21095 - err = probe_kernel_read(opc, (char *)bpt->bpt_addr, BREAK_INSTR_SIZE);
21096 + err = probe_kernel_read(opc, ktla_ktva((char *)bpt->bpt_addr), BREAK_INSTR_SIZE);
21097 if (err)
21098 return err;
21099 if (memcmp(opc, arch_kgdb_ops.gdb_bpt_instr, BREAK_INSTR_SIZE))
21100 @@ -793,13 +796,13 @@ int kgdb_arch_remove_breakpoint(struct kgdb_bkpt *bpt)
21101 if (mutex_is_locked(&text_mutex))
21102 goto knl_write;
21103 text_poke((void *)bpt->bpt_addr, bpt->saved_instr, BREAK_INSTR_SIZE);
21104 - err = probe_kernel_read(opc, (char *)bpt->bpt_addr, BREAK_INSTR_SIZE);
21105 + err = probe_kernel_read(opc, ktla_ktva((char *)bpt->bpt_addr), BREAK_INSTR_SIZE);
21106 if (err || memcmp(opc, bpt->saved_instr, BREAK_INSTR_SIZE))
21107 goto knl_write;
21108 return err;
21109 knl_write:
21110 #endif /* CONFIG_DEBUG_RODATA */
21111 - return probe_kernel_write((char *)bpt->bpt_addr,
21112 + return probe_kernel_write(ktla_ktva((char *)bpt->bpt_addr),
21113 (char *)bpt->saved_instr, BREAK_INSTR_SIZE);
21114 }
21115
21116 diff --git a/arch/x86/kernel/kprobes-opt.c b/arch/x86/kernel/kprobes-opt.c
21117 index c5e410e..ed5a7f0 100644
21118 --- a/arch/x86/kernel/kprobes-opt.c
21119 +++ b/arch/x86/kernel/kprobes-opt.c
21120 @@ -338,7 +338,7 @@ int __kprobes arch_prepare_optimized_kprobe(struct optimized_kprobe *op)
21121 * Verify if the address gap is in 2GB range, because this uses
21122 * a relative jump.
21123 */
21124 - rel = (long)op->optinsn.insn - (long)op->kp.addr + RELATIVEJUMP_SIZE;
21125 + rel = (long)op->optinsn.insn - ktla_ktva((long)op->kp.addr) + RELATIVEJUMP_SIZE;
21126 if (abs(rel) > 0x7fffffff)
21127 return -ERANGE;
21128
21129 @@ -353,16 +353,16 @@ int __kprobes arch_prepare_optimized_kprobe(struct optimized_kprobe *op)
21130 op->optinsn.size = ret;
21131
21132 /* Copy arch-dep-instance from template */
21133 - memcpy(buf, &optprobe_template_entry, TMPL_END_IDX);
21134 + memcpy(buf, ktla_ktva(&optprobe_template_entry), TMPL_END_IDX);
21135
21136 /* Set probe information */
21137 synthesize_set_arg1(buf + TMPL_MOVE_IDX, (unsigned long)op);
21138
21139 /* Set probe function call */
21140 - synthesize_relcall(buf + TMPL_CALL_IDX, optimized_callback);
21141 + synthesize_relcall(ktva_ktla(buf) + TMPL_CALL_IDX, optimized_callback);
21142
21143 /* Set returning jmp instruction at the tail of out-of-line buffer */
21144 - synthesize_reljump(buf + TMPL_END_IDX + op->optinsn.size,
21145 + synthesize_reljump(ktva_ktla(buf) + TMPL_END_IDX + op->optinsn.size,
21146 (u8 *)op->kp.addr + op->optinsn.size);
21147
21148 flush_icache_range((unsigned long) buf,
21149 @@ -385,7 +385,7 @@ static void __kprobes setup_optimize_kprobe(struct text_poke_param *tprm,
21150 ((long)op->kp.addr + RELATIVEJUMP_SIZE));
21151
21152 /* Backup instructions which will be replaced by jump address */
21153 - memcpy(op->optinsn.copied_insn, op->kp.addr + INT3_SIZE,
21154 + memcpy(op->optinsn.copied_insn, ktla_ktva(op->kp.addr) + INT3_SIZE,
21155 RELATIVE_ADDR_SIZE);
21156
21157 insn_buf[0] = RELATIVEJUMP_OPCODE;
21158 @@ -483,7 +483,7 @@ setup_detour_execution(struct kprobe *p, struct pt_regs *regs, int reenter)
21159 /* This kprobe is really able to run optimized path. */
21160 op = container_of(p, struct optimized_kprobe, kp);
21161 /* Detour through copied instructions */
21162 - regs->ip = (unsigned long)op->optinsn.insn + TMPL_END_IDX;
21163 + regs->ip = ktva_ktla((unsigned long)op->optinsn.insn) + TMPL_END_IDX;
21164 if (!reenter)
21165 reset_current_kprobe();
21166 preempt_enable_no_resched();
21167 diff --git a/arch/x86/kernel/kprobes.c b/arch/x86/kernel/kprobes.c
21168 index 57916c0..9e0b9d0 100644
21169 --- a/arch/x86/kernel/kprobes.c
21170 +++ b/arch/x86/kernel/kprobes.c
21171 @@ -119,9 +119,12 @@ static void __kprobes __synthesize_relative_insn(void *from, void *to, u8 op)
21172 s32 raddr;
21173 } __attribute__((packed)) *insn;
21174
21175 - insn = (struct __arch_relative_insn *)from;
21176 + insn = (struct __arch_relative_insn *)ktla_ktva(from);
21177 +
21178 + pax_open_kernel();
21179 insn->raddr = (s32)((long)(to) - ((long)(from) + 5));
21180 insn->op = op;
21181 + pax_close_kernel();
21182 }
21183
21184 /* Insert a jump instruction at address 'from', which jumps to address 'to'.*/
21185 @@ -164,7 +167,7 @@ int __kprobes can_boost(kprobe_opcode_t *opcodes)
21186 kprobe_opcode_t opcode;
21187 kprobe_opcode_t *orig_opcodes = opcodes;
21188
21189 - if (search_exception_tables((unsigned long)opcodes))
21190 + if (search_exception_tables(ktva_ktla((unsigned long)opcodes)))
21191 return 0; /* Page fault may occur on this address. */
21192
21193 retry:
21194 @@ -238,9 +241,9 @@ __recover_probed_insn(kprobe_opcode_t *buf, unsigned long addr)
21195 * for the first byte, we can recover the original instruction
21196 * from it and kp->opcode.
21197 */
21198 - memcpy(buf, kp->addr, MAX_INSN_SIZE * sizeof(kprobe_opcode_t));
21199 + memcpy(buf, ktla_ktva(kp->addr), MAX_INSN_SIZE * sizeof(kprobe_opcode_t));
21200 buf[0] = kp->opcode;
21201 - return (unsigned long)buf;
21202 + return ktva_ktla((unsigned long)buf);
21203 }
21204
21205 /*
21206 @@ -332,7 +335,9 @@ int __kprobes __copy_instruction(u8 *dest, u8 *src)
21207 /* Another subsystem puts a breakpoint, failed to recover */
21208 if (insn.opcode.bytes[0] == BREAKPOINT_INSTRUCTION)
21209 return 0;
21210 + pax_open_kernel();
21211 memcpy(dest, insn.kaddr, insn.length);
21212 + pax_close_kernel();
21213
21214 #ifdef CONFIG_X86_64
21215 if (insn_rip_relative(&insn)) {
21216 @@ -355,7 +360,9 @@ int __kprobes __copy_instruction(u8 *dest, u8 *src)
21217 newdisp = (u8 *) src + (s64) insn.displacement.value - (u8 *) dest;
21218 BUG_ON((s64) (s32) newdisp != newdisp); /* Sanity check. */
21219 disp = (u8 *) dest + insn_offset_displacement(&insn);
21220 + pax_open_kernel();
21221 *(s32 *) disp = (s32) newdisp;
21222 + pax_close_kernel();
21223 }
21224 #endif
21225 return insn.length;
21226 @@ -485,7 +492,7 @@ setup_singlestep(struct kprobe *p, struct pt_regs *regs, struct kprobe_ctlblk *k
21227 * nor set current_kprobe, because it doesn't use single
21228 * stepping.
21229 */
21230 - regs->ip = (unsigned long)p->ainsn.insn;
21231 + regs->ip = ktva_ktla((unsigned long)p->ainsn.insn);
21232 preempt_enable_no_resched();
21233 return;
21234 }
21235 @@ -502,9 +509,9 @@ setup_singlestep(struct kprobe *p, struct pt_regs *regs, struct kprobe_ctlblk *k
21236 regs->flags &= ~X86_EFLAGS_IF;
21237 /* single step inline if the instruction is an int3 */
21238 if (p->opcode == BREAKPOINT_INSTRUCTION)
21239 - regs->ip = (unsigned long)p->addr;
21240 + regs->ip = ktla_ktva((unsigned long)p->addr);
21241 else
21242 - regs->ip = (unsigned long)p->ainsn.insn;
21243 + regs->ip = ktva_ktla((unsigned long)p->ainsn.insn);
21244 }
21245
21246 /*
21247 @@ -600,7 +607,7 @@ static int __kprobes kprobe_handler(struct pt_regs *regs)
21248 setup_singlestep(p, regs, kcb, 0);
21249 return 1;
21250 }
21251 - } else if (*addr != BREAKPOINT_INSTRUCTION) {
21252 + } else if (*(kprobe_opcode_t *)ktla_ktva((unsigned long)addr) != BREAKPOINT_INSTRUCTION) {
21253 /*
21254 * The breakpoint instruction was removed right
21255 * after we hit it. Another cpu has removed
21256 @@ -651,6 +658,9 @@ static void __used __kprobes kretprobe_trampoline_holder(void)
21257 " movq %rax, 152(%rsp)\n"
21258 RESTORE_REGS_STRING
21259 " popfq\n"
21260 +#ifdef KERNEXEC_PLUGIN
21261 + " btsq $63,(%rsp)\n"
21262 +#endif
21263 #else
21264 " pushf\n"
21265 SAVE_REGS_STRING
21266 @@ -788,7 +798,7 @@ static void __kprobes
21267 resume_execution(struct kprobe *p, struct pt_regs *regs, struct kprobe_ctlblk *kcb)
21268 {
21269 unsigned long *tos = stack_addr(regs);
21270 - unsigned long copy_ip = (unsigned long)p->ainsn.insn;
21271 + unsigned long copy_ip = ktva_ktla((unsigned long)p->ainsn.insn);
21272 unsigned long orig_ip = (unsigned long)p->addr;
21273 kprobe_opcode_t *insn = p->ainsn.insn;
21274
21275 @@ -970,7 +980,7 @@ kprobe_exceptions_notify(struct notifier_block *self, unsigned long val, void *d
21276 struct die_args *args = data;
21277 int ret = NOTIFY_DONE;
21278
21279 - if (args->regs && user_mode_vm(args->regs))
21280 + if (args->regs && user_mode(args->regs))
21281 return ret;
21282
21283 switch (val) {
21284 diff --git a/arch/x86/kernel/kvm.c b/arch/x86/kernel/kvm.c
21285 index 9c2bd8b..bb1131c 100644
21286 --- a/arch/x86/kernel/kvm.c
21287 +++ b/arch/x86/kernel/kvm.c
21288 @@ -452,7 +452,7 @@ static int __cpuinit kvm_cpu_notify(struct notifier_block *self,
21289 return NOTIFY_OK;
21290 }
21291
21292 -static struct notifier_block __cpuinitdata kvm_cpu_notifier = {
21293 +static struct notifier_block kvm_cpu_notifier = {
21294 .notifier_call = kvm_cpu_notify,
21295 };
21296 #endif
21297 diff --git a/arch/x86/kernel/ldt.c b/arch/x86/kernel/ldt.c
21298 index ebc9873..1b9724b 100644
21299 --- a/arch/x86/kernel/ldt.c
21300 +++ b/arch/x86/kernel/ldt.c
21301 @@ -66,13 +66,13 @@ static int alloc_ldt(mm_context_t *pc, int mincount, int reload)
21302 if (reload) {
21303 #ifdef CONFIG_SMP
21304 preempt_disable();
21305 - load_LDT(pc);
21306 + load_LDT_nolock(pc);
21307 if (!cpumask_equal(mm_cpumask(current->mm),
21308 cpumask_of(smp_processor_id())))
21309 smp_call_function(flush_ldt, current->mm, 1);
21310 preempt_enable();
21311 #else
21312 - load_LDT(pc);
21313 + load_LDT_nolock(pc);
21314 #endif
21315 }
21316 if (oldsize) {
21317 @@ -94,7 +94,7 @@ static inline int copy_ldt(mm_context_t *new, mm_context_t *old)
21318 return err;
21319
21320 for (i = 0; i < old->size; i++)
21321 - write_ldt_entry(new->ldt, i, old->ldt + i * LDT_ENTRY_SIZE);
21322 + write_ldt_entry(new->ldt, i, old->ldt + i);
21323 return 0;
21324 }
21325
21326 @@ -115,6 +115,24 @@ int init_new_context(struct task_struct *tsk, struct mm_struct *mm)
21327 retval = copy_ldt(&mm->context, &old_mm->context);
21328 mutex_unlock(&old_mm->context.lock);
21329 }
21330 +
21331 + if (tsk == current) {
21332 + mm->context.vdso = 0;
21333 +
21334 +#ifdef CONFIG_X86_32
21335 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
21336 + mm->context.user_cs_base = 0UL;
21337 + mm->context.user_cs_limit = ~0UL;
21338 +
21339 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_SMP)
21340 + cpus_clear(mm->context.cpu_user_cs_mask);
21341 +#endif
21342 +
21343 +#endif
21344 +#endif
21345 +
21346 + }
21347 +
21348 return retval;
21349 }
21350
21351 @@ -229,6 +247,13 @@ static int write_ldt(void __user *ptr, unsigned long bytecount, int oldmode)
21352 }
21353 }
21354
21355 +#ifdef CONFIG_PAX_SEGMEXEC
21356 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (ldt_info.contents & MODIFY_LDT_CONTENTS_CODE)) {
21357 + error = -EINVAL;
21358 + goto out_unlock;
21359 + }
21360 +#endif
21361 +
21362 fill_ldt(&ldt, &ldt_info);
21363 if (oldmode)
21364 ldt.avl = 0;
21365 diff --git a/arch/x86/kernel/machine_kexec_32.c b/arch/x86/kernel/machine_kexec_32.c
21366 index 5b19e4d..6476a76 100644
21367 --- a/arch/x86/kernel/machine_kexec_32.c
21368 +++ b/arch/x86/kernel/machine_kexec_32.c
21369 @@ -26,7 +26,7 @@
21370 #include <asm/cacheflush.h>
21371 #include <asm/debugreg.h>
21372
21373 -static void set_idt(void *newidt, __u16 limit)
21374 +static void set_idt(struct desc_struct *newidt, __u16 limit)
21375 {
21376 struct desc_ptr curidt;
21377
21378 @@ -38,7 +38,7 @@ static void set_idt(void *newidt, __u16 limit)
21379 }
21380
21381
21382 -static void set_gdt(void *newgdt, __u16 limit)
21383 +static void set_gdt(struct desc_struct *newgdt, __u16 limit)
21384 {
21385 struct desc_ptr curgdt;
21386
21387 @@ -216,7 +216,7 @@ void machine_kexec(struct kimage *image)
21388 }
21389
21390 control_page = page_address(image->control_code_page);
21391 - memcpy(control_page, relocate_kernel, KEXEC_CONTROL_CODE_MAX_SIZE);
21392 + memcpy(control_page, (void *)ktla_ktva((unsigned long)relocate_kernel), KEXEC_CONTROL_CODE_MAX_SIZE);
21393
21394 relocate_kernel_ptr = control_page;
21395 page_list[PA_CONTROL_PAGE] = __pa(control_page);
21396 diff --git a/arch/x86/kernel/microcode_core.c b/arch/x86/kernel/microcode_core.c
21397 index 3a04b22..1d2eb09 100644
21398 --- a/arch/x86/kernel/microcode_core.c
21399 +++ b/arch/x86/kernel/microcode_core.c
21400 @@ -512,7 +512,7 @@ mc_cpu_callback(struct notifier_block *nb, unsigned long action, void *hcpu)
21401 return NOTIFY_OK;
21402 }
21403
21404 -static struct notifier_block __refdata mc_cpu_notifier = {
21405 +static struct notifier_block mc_cpu_notifier = {
21406 .notifier_call = mc_cpu_callback,
21407 };
21408
21409 diff --git a/arch/x86/kernel/microcode_intel.c b/arch/x86/kernel/microcode_intel.c
21410 index 3544aed..01ddc1c 100644
21411 --- a/arch/x86/kernel/microcode_intel.c
21412 +++ b/arch/x86/kernel/microcode_intel.c
21413 @@ -431,13 +431,13 @@ static enum ucode_state request_microcode_fw(int cpu, struct device *device,
21414
21415 static int get_ucode_user(void *to, const void *from, size_t n)
21416 {
21417 - return copy_from_user(to, from, n);
21418 + return copy_from_user(to, (const void __force_user *)from, n);
21419 }
21420
21421 static enum ucode_state
21422 request_microcode_user(int cpu, const void __user *buf, size_t size)
21423 {
21424 - return generic_load_microcode(cpu, (void *)buf, size, &get_ucode_user);
21425 + return generic_load_microcode(cpu, (__force_kernel void *)buf, size, &get_ucode_user);
21426 }
21427
21428 static void microcode_fini_cpu(int cpu)
21429 diff --git a/arch/x86/kernel/module.c b/arch/x86/kernel/module.c
21430 index 216a4d7..228255a 100644
21431 --- a/arch/x86/kernel/module.c
21432 +++ b/arch/x86/kernel/module.c
21433 @@ -43,15 +43,60 @@ do { \
21434 } while (0)
21435 #endif
21436
21437 -void *module_alloc(unsigned long size)
21438 +static inline void *__module_alloc(unsigned long size, pgprot_t prot)
21439 {
21440 - if (PAGE_ALIGN(size) > MODULES_LEN)
21441 + if (!size || PAGE_ALIGN(size) > MODULES_LEN)
21442 return NULL;
21443 return __vmalloc_node_range(size, 1, MODULES_VADDR, MODULES_END,
21444 - GFP_KERNEL | __GFP_HIGHMEM, PAGE_KERNEL_EXEC,
21445 + GFP_KERNEL | __GFP_HIGHMEM | __GFP_ZERO, prot,
21446 -1, __builtin_return_address(0));
21447 }
21448
21449 +void *module_alloc(unsigned long size)
21450 +{
21451 +
21452 +#ifdef CONFIG_PAX_KERNEXEC
21453 + return __module_alloc(size, PAGE_KERNEL);
21454 +#else
21455 + return __module_alloc(size, PAGE_KERNEL_EXEC);
21456 +#endif
21457 +
21458 +}
21459 +
21460 +#ifdef CONFIG_PAX_KERNEXEC
21461 +#ifdef CONFIG_X86_32
21462 +void *module_alloc_exec(unsigned long size)
21463 +{
21464 + struct vm_struct *area;
21465 +
21466 + if (size == 0)
21467 + return NULL;
21468 +
21469 + area = __get_vm_area(size, VM_ALLOC, (unsigned long)&MODULES_EXEC_VADDR, (unsigned long)&MODULES_EXEC_END);
21470 + return area ? area->addr : NULL;
21471 +}
21472 +EXPORT_SYMBOL(module_alloc_exec);
21473 +
21474 +void module_free_exec(struct module *mod, void *module_region)
21475 +{
21476 + vunmap(module_region);
21477 +}
21478 +EXPORT_SYMBOL(module_free_exec);
21479 +#else
21480 +void module_free_exec(struct module *mod, void *module_region)
21481 +{
21482 + module_free(mod, module_region);
21483 +}
21484 +EXPORT_SYMBOL(module_free_exec);
21485 +
21486 +void *module_alloc_exec(unsigned long size)
21487 +{
21488 + return __module_alloc(size, PAGE_KERNEL_RX);
21489 +}
21490 +EXPORT_SYMBOL(module_alloc_exec);
21491 +#endif
21492 +#endif
21493 +
21494 #ifdef CONFIG_X86_32
21495 int apply_relocate(Elf32_Shdr *sechdrs,
21496 const char *strtab,
21497 @@ -62,14 +107,16 @@ int apply_relocate(Elf32_Shdr *sechdrs,
21498 unsigned int i;
21499 Elf32_Rel *rel = (void *)sechdrs[relsec].sh_addr;
21500 Elf32_Sym *sym;
21501 - uint32_t *location;
21502 + uint32_t *plocation, location;
21503
21504 DEBUGP("Applying relocate section %u to %u\n",
21505 relsec, sechdrs[relsec].sh_info);
21506 for (i = 0; i < sechdrs[relsec].sh_size / sizeof(*rel); i++) {
21507 /* This is where to make the change */
21508 - location = (void *)sechdrs[sechdrs[relsec].sh_info].sh_addr
21509 - + rel[i].r_offset;
21510 + plocation = (void *)sechdrs[sechdrs[relsec].sh_info].sh_addr + rel[i].r_offset;
21511 + location = (uint32_t)plocation;
21512 + if (sechdrs[sechdrs[relsec].sh_info].sh_flags & SHF_EXECINSTR)
21513 + plocation = ktla_ktva((void *)plocation);
21514 /* This is the symbol it is referring to. Note that all
21515 undefined symbols have been resolved. */
21516 sym = (Elf32_Sym *)sechdrs[symindex].sh_addr
21517 @@ -78,11 +125,15 @@ int apply_relocate(Elf32_Shdr *sechdrs,
21518 switch (ELF32_R_TYPE(rel[i].r_info)) {
21519 case R_386_32:
21520 /* We add the value into the location given */
21521 - *location += sym->st_value;
21522 + pax_open_kernel();
21523 + *plocation += sym->st_value;
21524 + pax_close_kernel();
21525 break;
21526 case R_386_PC32:
21527 /* Add the value, subtract its position */
21528 - *location += sym->st_value - (uint32_t)location;
21529 + pax_open_kernel();
21530 + *plocation += sym->st_value - location;
21531 + pax_close_kernel();
21532 break;
21533 default:
21534 pr_err("%s: Unknown relocation: %u\n",
21535 @@ -127,21 +178,30 @@ int apply_relocate_add(Elf64_Shdr *sechdrs,
21536 case R_X86_64_NONE:
21537 break;
21538 case R_X86_64_64:
21539 + pax_open_kernel();
21540 *(u64 *)loc = val;
21541 + pax_close_kernel();
21542 break;
21543 case R_X86_64_32:
21544 + pax_open_kernel();
21545 *(u32 *)loc = val;
21546 + pax_close_kernel();
21547 if (val != *(u32 *)loc)
21548 goto overflow;
21549 break;
21550 case R_X86_64_32S:
21551 + pax_open_kernel();
21552 *(s32 *)loc = val;
21553 + pax_close_kernel();
21554 if ((s64)val != *(s32 *)loc)
21555 goto overflow;
21556 break;
21557 case R_X86_64_PC32:
21558 val -= (u64)loc;
21559 + pax_open_kernel();
21560 *(u32 *)loc = val;
21561 + pax_close_kernel();
21562 +
21563 #if 0
21564 if ((s64)val != *(s32 *)loc)
21565 goto overflow;
21566 diff --git a/arch/x86/kernel/msr.c b/arch/x86/kernel/msr.c
21567 index 4929502..686c291 100644
21568 --- a/arch/x86/kernel/msr.c
21569 +++ b/arch/x86/kernel/msr.c
21570 @@ -234,7 +234,7 @@ static int __cpuinit msr_class_cpu_callback(struct notifier_block *nfb,
21571 return notifier_from_errno(err);
21572 }
21573
21574 -static struct notifier_block __refdata msr_class_cpu_notifier = {
21575 +static struct notifier_block msr_class_cpu_notifier = {
21576 .notifier_call = msr_class_cpu_callback,
21577 };
21578
21579 diff --git a/arch/x86/kernel/nmi.c b/arch/x86/kernel/nmi.c
21580 index f84f5c5..f404e81 100644
21581 --- a/arch/x86/kernel/nmi.c
21582 +++ b/arch/x86/kernel/nmi.c
21583 @@ -105,7 +105,7 @@ static int __kprobes nmi_handle(unsigned int type, struct pt_regs *regs, bool b2
21584 return handled;
21585 }
21586
21587 -int __register_nmi_handler(unsigned int type, struct nmiaction *action)
21588 +int __register_nmi_handler(unsigned int type, const struct nmiaction *action)
21589 {
21590 struct nmi_desc *desc = nmi_to_desc(type);
21591 unsigned long flags;
21592 @@ -129,9 +129,9 @@ int __register_nmi_handler(unsigned int type, struct nmiaction *action)
21593 * event confuses some handlers (kdump uses this flag)
21594 */
21595 if (action->flags & NMI_FLAG_FIRST)
21596 - list_add_rcu(&action->list, &desc->head);
21597 + pax_list_add_rcu((struct list_head *)&action->list, &desc->head);
21598 else
21599 - list_add_tail_rcu(&action->list, &desc->head);
21600 + pax_list_add_tail_rcu((struct list_head *)&action->list, &desc->head);
21601
21602 spin_unlock_irqrestore(&desc->lock, flags);
21603 return 0;
21604 @@ -154,7 +154,7 @@ void unregister_nmi_handler(unsigned int type, const char *name)
21605 if (!strcmp(n->name, name)) {
21606 WARN(in_nmi(),
21607 "Trying to free NMI (%s) from NMI context!\n", n->name);
21608 - list_del_rcu(&n->list);
21609 + pax_list_del_rcu((struct list_head *)&n->list);
21610 break;
21611 }
21612 }
21613 @@ -479,6 +479,17 @@ static inline void nmi_nesting_postprocess(void)
21614 dotraplinkage notrace __kprobes void
21615 do_nmi(struct pt_regs *regs, long error_code)
21616 {
21617 +
21618 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
21619 + if (!user_mode(regs)) {
21620 + unsigned long cs = regs->cs & 0xFFFF;
21621 + unsigned long ip = ktva_ktla(regs->ip);
21622 +
21623 + if ((cs == __KERNEL_CS || cs == __KERNEXEC_KERNEL_CS) && ip <= (unsigned long)_etext)
21624 + regs->ip = ip;
21625 + }
21626 +#endif
21627 +
21628 nmi_nesting_preprocess(regs);
21629
21630 nmi_enter();
21631 diff --git a/arch/x86/kernel/nmi_selftest.c b/arch/x86/kernel/nmi_selftest.c
21632 index 6d9582e..f746287 100644
21633 --- a/arch/x86/kernel/nmi_selftest.c
21634 +++ b/arch/x86/kernel/nmi_selftest.c
21635 @@ -43,7 +43,7 @@ static void __init init_nmi_testsuite(void)
21636 {
21637 /* trap all the unknown NMIs we may generate */
21638 register_nmi_handler(NMI_UNKNOWN, nmi_unk_cb, 0, "nmi_selftest_unk",
21639 - __initdata);
21640 + __initconst);
21641 }
21642
21643 static void __init cleanup_nmi_testsuite(void)
21644 @@ -66,7 +66,7 @@ static void __init test_nmi_ipi(struct cpumask *mask)
21645 unsigned long timeout;
21646
21647 if (register_nmi_handler(NMI_LOCAL, test_nmi_ipi_callback,
21648 - NMI_FLAG_FIRST, "nmi_selftest", __initdata)) {
21649 + NMI_FLAG_FIRST, "nmi_selftest", __initconst)) {
21650 nmi_fail = FAILURE;
21651 return;
21652 }
21653 diff --git a/arch/x86/kernel/paravirt-spinlocks.c b/arch/x86/kernel/paravirt-spinlocks.c
21654 index 676b8c7..870ba04 100644
21655 --- a/arch/x86/kernel/paravirt-spinlocks.c
21656 +++ b/arch/x86/kernel/paravirt-spinlocks.c
21657 @@ -13,7 +13,7 @@ default_spin_lock_flags(arch_spinlock_t *lock, unsigned long flags)
21658 arch_spin_lock(lock);
21659 }
21660
21661 -struct pv_lock_ops pv_lock_ops = {
21662 +struct pv_lock_ops pv_lock_ops __read_only = {
21663 #ifdef CONFIG_SMP
21664 .spin_is_locked = __ticket_spin_is_locked,
21665 .spin_is_contended = __ticket_spin_is_contended,
21666 diff --git a/arch/x86/kernel/paravirt.c b/arch/x86/kernel/paravirt.c
21667 index 17fff18..5cfa0f4 100644
21668 --- a/arch/x86/kernel/paravirt.c
21669 +++ b/arch/x86/kernel/paravirt.c
21670 @@ -55,6 +55,9 @@ u64 _paravirt_ident_64(u64 x)
21671 {
21672 return x;
21673 }
21674 +#if defined(CONFIG_X86_32) && defined(CONFIG_X86_PAE)
21675 +PV_CALLEE_SAVE_REGS_THUNK(_paravirt_ident_64);
21676 +#endif
21677
21678 void __init default_banner(void)
21679 {
21680 @@ -147,15 +150,19 @@ unsigned paravirt_patch_default(u8 type, u16 clobbers, void *insnbuf,
21681 if (opfunc == NULL)
21682 /* If there's no function, patch it with a ud2a (BUG) */
21683 ret = paravirt_patch_insns(insnbuf, len, ud2a, ud2a+sizeof(ud2a));
21684 - else if (opfunc == _paravirt_nop)
21685 + else if (opfunc == (void *)_paravirt_nop)
21686 /* If the operation is a nop, then nop the callsite */
21687 ret = paravirt_patch_nop();
21688
21689 /* identity functions just return their single argument */
21690 - else if (opfunc == _paravirt_ident_32)
21691 + else if (opfunc == (void *)_paravirt_ident_32)
21692 ret = paravirt_patch_ident_32(insnbuf, len);
21693 - else if (opfunc == _paravirt_ident_64)
21694 + else if (opfunc == (void *)_paravirt_ident_64)
21695 ret = paravirt_patch_ident_64(insnbuf, len);
21696 +#if defined(CONFIG_X86_32) && defined(CONFIG_X86_PAE)
21697 + else if (opfunc == (void *)__raw_callee_save__paravirt_ident_64)
21698 + ret = paravirt_patch_ident_64(insnbuf, len);
21699 +#endif
21700
21701 else if (type == PARAVIRT_PATCH(pv_cpu_ops.iret) ||
21702 type == PARAVIRT_PATCH(pv_cpu_ops.irq_enable_sysexit) ||
21703 @@ -180,7 +187,7 @@ unsigned paravirt_patch_insns(void *insnbuf, unsigned len,
21704 if (insn_len > len || start == NULL)
21705 insn_len = len;
21706 else
21707 - memcpy(insnbuf, start, insn_len);
21708 + memcpy(insnbuf, ktla_ktva(start), insn_len);
21709
21710 return insn_len;
21711 }
21712 @@ -304,7 +311,7 @@ void arch_flush_lazy_mmu_mode(void)
21713 preempt_enable();
21714 }
21715
21716 -struct pv_info pv_info = {
21717 +struct pv_info pv_info __read_only = {
21718 .name = "bare hardware",
21719 .paravirt_enabled = 0,
21720 .kernel_rpl = 0,
21721 @@ -315,16 +322,16 @@ struct pv_info pv_info = {
21722 #endif
21723 };
21724
21725 -struct pv_init_ops pv_init_ops = {
21726 +struct pv_init_ops pv_init_ops __read_only = {
21727 .patch = native_patch,
21728 };
21729
21730 -struct pv_time_ops pv_time_ops = {
21731 +struct pv_time_ops pv_time_ops __read_only = {
21732 .sched_clock = native_sched_clock,
21733 .steal_clock = native_steal_clock,
21734 };
21735
21736 -struct pv_irq_ops pv_irq_ops = {
21737 +struct pv_irq_ops pv_irq_ops __read_only = {
21738 .save_fl = __PV_IS_CALLEE_SAVE(native_save_fl),
21739 .restore_fl = __PV_IS_CALLEE_SAVE(native_restore_fl),
21740 .irq_disable = __PV_IS_CALLEE_SAVE(native_irq_disable),
21741 @@ -336,7 +343,7 @@ struct pv_irq_ops pv_irq_ops = {
21742 #endif
21743 };
21744
21745 -struct pv_cpu_ops pv_cpu_ops = {
21746 +struct pv_cpu_ops pv_cpu_ops __read_only = {
21747 .cpuid = native_cpuid,
21748 .get_debugreg = native_get_debugreg,
21749 .set_debugreg = native_set_debugreg,
21750 @@ -395,21 +402,26 @@ struct pv_cpu_ops pv_cpu_ops = {
21751 .end_context_switch = paravirt_nop,
21752 };
21753
21754 -struct pv_apic_ops pv_apic_ops = {
21755 +struct pv_apic_ops pv_apic_ops __read_only= {
21756 #ifdef CONFIG_X86_LOCAL_APIC
21757 .startup_ipi_hook = paravirt_nop,
21758 #endif
21759 };
21760
21761 -#if defined(CONFIG_X86_32) && !defined(CONFIG_X86_PAE)
21762 +#ifdef CONFIG_X86_32
21763 +#ifdef CONFIG_X86_PAE
21764 +/* 64-bit pagetable entries */
21765 +#define PTE_IDENT PV_CALLEE_SAVE(_paravirt_ident_64)
21766 +#else
21767 /* 32-bit pagetable entries */
21768 #define PTE_IDENT __PV_IS_CALLEE_SAVE(_paravirt_ident_32)
21769 +#endif
21770 #else
21771 /* 64-bit pagetable entries */
21772 #define PTE_IDENT __PV_IS_CALLEE_SAVE(_paravirt_ident_64)
21773 #endif
21774
21775 -struct pv_mmu_ops pv_mmu_ops = {
21776 +struct pv_mmu_ops pv_mmu_ops __read_only = {
21777
21778 .read_cr2 = native_read_cr2,
21779 .write_cr2 = native_write_cr2,
21780 @@ -459,6 +471,7 @@ struct pv_mmu_ops pv_mmu_ops = {
21781 .make_pud = PTE_IDENT,
21782
21783 .set_pgd = native_set_pgd,
21784 + .set_pgd_batched = native_set_pgd_batched,
21785 #endif
21786 #endif /* PAGETABLE_LEVELS >= 3 */
21787
21788 @@ -478,6 +491,12 @@ struct pv_mmu_ops pv_mmu_ops = {
21789 },
21790
21791 .set_fixmap = native_set_fixmap,
21792 +
21793 +#ifdef CONFIG_PAX_KERNEXEC
21794 + .pax_open_kernel = native_pax_open_kernel,
21795 + .pax_close_kernel = native_pax_close_kernel,
21796 +#endif
21797 +
21798 };
21799
21800 EXPORT_SYMBOL_GPL(pv_time_ops);
21801 diff --git a/arch/x86/kernel/pci-iommu_table.c b/arch/x86/kernel/pci-iommu_table.c
21802 index 35ccf75..7a15747 100644
21803 --- a/arch/x86/kernel/pci-iommu_table.c
21804 +++ b/arch/x86/kernel/pci-iommu_table.c
21805 @@ -2,7 +2,7 @@
21806 #include <asm/iommu_table.h>
21807 #include <linux/string.h>
21808 #include <linux/kallsyms.h>
21809 -
21810 +#include <linux/sched.h>
21811
21812 #define DEBUG 1
21813
21814 diff --git a/arch/x86/kernel/pci-swiotlb.c b/arch/x86/kernel/pci-swiotlb.c
21815 index 6c483ba..d10ce2f 100644
21816 --- a/arch/x86/kernel/pci-swiotlb.c
21817 +++ b/arch/x86/kernel/pci-swiotlb.c
21818 @@ -32,7 +32,7 @@ static void x86_swiotlb_free_coherent(struct device *dev, size_t size,
21819 void *vaddr, dma_addr_t dma_addr,
21820 struct dma_attrs *attrs)
21821 {
21822 - swiotlb_free_coherent(dev, size, vaddr, dma_addr);
21823 + swiotlb_free_coherent(dev, size, vaddr, dma_addr, attrs);
21824 }
21825
21826 static struct dma_map_ops swiotlb_dma_ops = {
21827 diff --git a/arch/x86/kernel/process.c b/arch/x86/kernel/process.c
21828 index 2ed787f..f70c9f6 100644
21829 --- a/arch/x86/kernel/process.c
21830 +++ b/arch/x86/kernel/process.c
21831 @@ -36,7 +36,8 @@
21832 * section. Since TSS's are completely CPU-local, we want them
21833 * on exact cacheline boundaries, to eliminate cacheline ping-pong.
21834 */
21835 -DEFINE_PER_CPU_SHARED_ALIGNED(struct tss_struct, init_tss) = INIT_TSS;
21836 +struct tss_struct init_tss[NR_CPUS] ____cacheline_internodealigned_in_smp = { [0 ... NR_CPUS-1] = INIT_TSS };
21837 +EXPORT_SYMBOL(init_tss);
21838
21839 #ifdef CONFIG_X86_64
21840 static DEFINE_PER_CPU(unsigned char, is_idle);
21841 @@ -92,7 +93,7 @@ void arch_task_cache_init(void)
21842 task_xstate_cachep =
21843 kmem_cache_create("task_xstate", xstate_size,
21844 __alignof__(union thread_xstate),
21845 - SLAB_PANIC | SLAB_NOTRACK, NULL);
21846 + SLAB_PANIC | SLAB_NOTRACK | SLAB_USERCOPY, NULL);
21847 }
21848
21849 /*
21850 @@ -105,7 +106,7 @@ void exit_thread(void)
21851 unsigned long *bp = t->io_bitmap_ptr;
21852
21853 if (bp) {
21854 - struct tss_struct *tss = &per_cpu(init_tss, get_cpu());
21855 + struct tss_struct *tss = init_tss + get_cpu();
21856
21857 t->io_bitmap_ptr = NULL;
21858 clear_thread_flag(TIF_IO_BITMAP);
21859 @@ -136,7 +137,7 @@ void show_regs_common(void)
21860 board = dmi_get_system_info(DMI_BOARD_NAME);
21861
21862 printk(KERN_DEFAULT "Pid: %d, comm: %.20s %s %s %.*s %s %s%s%s\n",
21863 - current->pid, current->comm, print_tainted(),
21864 + task_pid_nr(current), current->comm, print_tainted(),
21865 init_utsname()->release,
21866 (int)strcspn(init_utsname()->version, " "),
21867 init_utsname()->version,
21868 @@ -149,6 +150,9 @@ void flush_thread(void)
21869 {
21870 struct task_struct *tsk = current;
21871
21872 +#if defined(CONFIG_X86_32) && !defined(CONFIG_CC_STACKPROTECTOR) && !defined(CONFIG_PAX_MEMORY_UDEREF)
21873 + loadsegment(gs, 0);
21874 +#endif
21875 flush_ptrace_hw_breakpoint(tsk);
21876 memset(tsk->thread.tls_array, 0, sizeof(tsk->thread.tls_array));
21877 drop_init_fpu(tsk);
21878 @@ -301,7 +305,7 @@ static void __exit_idle(void)
21879 void exit_idle(void)
21880 {
21881 /* idle loop has pid 0 */
21882 - if (current->pid)
21883 + if (task_pid_nr(current))
21884 return;
21885 __exit_idle();
21886 }
21887 @@ -404,7 +408,7 @@ bool set_pm_idle_to_default(void)
21888
21889 return ret;
21890 }
21891 -void stop_this_cpu(void *dummy)
21892 +__noreturn void stop_this_cpu(void *dummy)
21893 {
21894 local_irq_disable();
21895 /*
21896 @@ -632,16 +636,37 @@ static int __init idle_setup(char *str)
21897 }
21898 early_param("idle", idle_setup);
21899
21900 -unsigned long arch_align_stack(unsigned long sp)
21901 +#ifdef CONFIG_PAX_RANDKSTACK
21902 +void pax_randomize_kstack(struct pt_regs *regs)
21903 {
21904 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
21905 - sp -= get_random_int() % 8192;
21906 - return sp & ~0xf;
21907 -}
21908 + struct thread_struct *thread = &current->thread;
21909 + unsigned long time;
21910
21911 -unsigned long arch_randomize_brk(struct mm_struct *mm)
21912 -{
21913 - unsigned long range_end = mm->brk + 0x02000000;
21914 - return randomize_range(mm->brk, range_end, 0) ? : mm->brk;
21915 -}
21916 + if (!randomize_va_space)
21917 + return;
21918 +
21919 + if (v8086_mode(regs))
21920 + return;
21921
21922 + rdtscl(time);
21923 +
21924 + /* P4 seems to return a 0 LSB, ignore it */
21925 +#ifdef CONFIG_MPENTIUM4
21926 + time &= 0x3EUL;
21927 + time <<= 2;
21928 +#elif defined(CONFIG_X86_64)
21929 + time &= 0xFUL;
21930 + time <<= 4;
21931 +#else
21932 + time &= 0x1FUL;
21933 + time <<= 3;
21934 +#endif
21935 +
21936 + thread->sp0 ^= time;
21937 + load_sp0(init_tss + smp_processor_id(), thread);
21938 +
21939 +#ifdef CONFIG_X86_64
21940 + this_cpu_write(kernel_stack, thread->sp0);
21941 +#endif
21942 +}
21943 +#endif
21944 diff --git a/arch/x86/kernel/process_32.c b/arch/x86/kernel/process_32.c
21945 index b5a8905..d9cacac 100644
21946 --- a/arch/x86/kernel/process_32.c
21947 +++ b/arch/x86/kernel/process_32.c
21948 @@ -65,6 +65,7 @@ asmlinkage void ret_from_kernel_thread(void) __asm__("ret_from_kernel_thread");
21949 unsigned long thread_saved_pc(struct task_struct *tsk)
21950 {
21951 return ((unsigned long *)tsk->thread.sp)[3];
21952 +//XXX return tsk->thread.eip;
21953 }
21954
21955 void __show_regs(struct pt_regs *regs, int all)
21956 @@ -74,21 +75,20 @@ void __show_regs(struct pt_regs *regs, int all)
21957 unsigned long sp;
21958 unsigned short ss, gs;
21959
21960 - if (user_mode_vm(regs)) {
21961 + if (user_mode(regs)) {
21962 sp = regs->sp;
21963 ss = regs->ss & 0xffff;
21964 - gs = get_user_gs(regs);
21965 } else {
21966 sp = kernel_stack_pointer(regs);
21967 savesegment(ss, ss);
21968 - savesegment(gs, gs);
21969 }
21970 + gs = get_user_gs(regs);
21971
21972 show_regs_common();
21973
21974 printk(KERN_DEFAULT "EIP: %04x:[<%08lx>] EFLAGS: %08lx CPU: %d\n",
21975 (u16)regs->cs, regs->ip, regs->flags,
21976 - smp_processor_id());
21977 + raw_smp_processor_id());
21978 print_symbol("EIP is at %s\n", regs->ip);
21979
21980 printk(KERN_DEFAULT "EAX: %08lx EBX: %08lx ECX: %08lx EDX: %08lx\n",
21981 @@ -130,20 +130,21 @@ void release_thread(struct task_struct *dead_task)
21982 int copy_thread(unsigned long clone_flags, unsigned long sp,
21983 unsigned long arg, struct task_struct *p)
21984 {
21985 - struct pt_regs *childregs = task_pt_regs(p);
21986 + struct pt_regs *childregs = task_stack_page(p) + THREAD_SIZE - sizeof(struct pt_regs) - 8;
21987 struct task_struct *tsk;
21988 int err;
21989
21990 p->thread.sp = (unsigned long) childregs;
21991 p->thread.sp0 = (unsigned long) (childregs+1);
21992 + p->tinfo.lowest_stack = (unsigned long)task_stack_page(p);
21993
21994 if (unlikely(p->flags & PF_KTHREAD)) {
21995 /* kernel thread */
21996 memset(childregs, 0, sizeof(struct pt_regs));
21997 p->thread.ip = (unsigned long) ret_from_kernel_thread;
21998 - task_user_gs(p) = __KERNEL_STACK_CANARY;
21999 - childregs->ds = __USER_DS;
22000 - childregs->es = __USER_DS;
22001 + savesegment(gs, childregs->gs);
22002 + childregs->ds = __KERNEL_DS;
22003 + childregs->es = __KERNEL_DS;
22004 childregs->fs = __KERNEL_PERCPU;
22005 childregs->bx = sp; /* function */
22006 childregs->bp = arg;
22007 @@ -250,7 +251,7 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
22008 struct thread_struct *prev = &prev_p->thread,
22009 *next = &next_p->thread;
22010 int cpu = smp_processor_id();
22011 - struct tss_struct *tss = &per_cpu(init_tss, cpu);
22012 + struct tss_struct *tss = init_tss + cpu;
22013 fpu_switch_t fpu;
22014
22015 /* never put a printk in __switch_to... printk() calls wake_up*() indirectly */
22016 @@ -274,6 +275,10 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
22017 */
22018 lazy_save_gs(prev->gs);
22019
22020 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22021 + __set_fs(task_thread_info(next_p)->addr_limit);
22022 +#endif
22023 +
22024 /*
22025 * Load the per-thread Thread-Local Storage descriptor.
22026 */
22027 @@ -304,6 +309,9 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
22028 */
22029 arch_end_context_switch(next_p);
22030
22031 + this_cpu_write(current_task, next_p);
22032 + this_cpu_write(current_tinfo, &next_p->tinfo);
22033 +
22034 /*
22035 * Restore %gs if needed (which is common)
22036 */
22037 @@ -312,8 +320,6 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
22038
22039 switch_fpu_finish(next_p, fpu);
22040
22041 - this_cpu_write(current_task, next_p);
22042 -
22043 return prev_p;
22044 }
22045
22046 @@ -343,4 +349,3 @@ unsigned long get_wchan(struct task_struct *p)
22047 } while (count++ < 16);
22048 return 0;
22049 }
22050 -
22051 diff --git a/arch/x86/kernel/process_64.c b/arch/x86/kernel/process_64.c
22052 index 6e68a61..955a9a5 100644
22053 --- a/arch/x86/kernel/process_64.c
22054 +++ b/arch/x86/kernel/process_64.c
22055 @@ -152,10 +152,11 @@ int copy_thread(unsigned long clone_flags, unsigned long sp,
22056 struct pt_regs *childregs;
22057 struct task_struct *me = current;
22058
22059 - p->thread.sp0 = (unsigned long)task_stack_page(p) + THREAD_SIZE;
22060 + p->thread.sp0 = (unsigned long)task_stack_page(p) + THREAD_SIZE - 16;
22061 childregs = task_pt_regs(p);
22062 p->thread.sp = (unsigned long) childregs;
22063 p->thread.usersp = me->thread.usersp;
22064 + p->tinfo.lowest_stack = (unsigned long)task_stack_page(p);
22065 set_tsk_thread_flag(p, TIF_FORK);
22066 p->fpu_counter = 0;
22067 p->thread.io_bitmap_ptr = NULL;
22068 @@ -274,7 +275,7 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
22069 struct thread_struct *prev = &prev_p->thread;
22070 struct thread_struct *next = &next_p->thread;
22071 int cpu = smp_processor_id();
22072 - struct tss_struct *tss = &per_cpu(init_tss, cpu);
22073 + struct tss_struct *tss = init_tss + cpu;
22074 unsigned fsindex, gsindex;
22075 fpu_switch_t fpu;
22076
22077 @@ -356,10 +357,9 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
22078 prev->usersp = this_cpu_read(old_rsp);
22079 this_cpu_write(old_rsp, next->usersp);
22080 this_cpu_write(current_task, next_p);
22081 + this_cpu_write(current_tinfo, &next_p->tinfo);
22082
22083 - this_cpu_write(kernel_stack,
22084 - (unsigned long)task_stack_page(next_p) +
22085 - THREAD_SIZE - KERNEL_STACK_OFFSET);
22086 + this_cpu_write(kernel_stack, next->sp0);
22087
22088 /*
22089 * Now maybe reload the debug registers and handle I/O bitmaps
22090 @@ -428,12 +428,11 @@ unsigned long get_wchan(struct task_struct *p)
22091 if (!p || p == current || p->state == TASK_RUNNING)
22092 return 0;
22093 stack = (unsigned long)task_stack_page(p);
22094 - if (p->thread.sp < stack || p->thread.sp >= stack+THREAD_SIZE)
22095 + if (p->thread.sp < stack || p->thread.sp > stack+THREAD_SIZE-16-sizeof(u64))
22096 return 0;
22097 fp = *(u64 *)(p->thread.sp);
22098 do {
22099 - if (fp < (unsigned long)stack ||
22100 - fp >= (unsigned long)stack+THREAD_SIZE)
22101 + if (fp < stack || fp > stack+THREAD_SIZE-16-sizeof(u64))
22102 return 0;
22103 ip = *(u64 *)(fp+8);
22104 if (!in_sched_functions(ip))
22105 diff --git a/arch/x86/kernel/ptrace.c b/arch/x86/kernel/ptrace.c
22106 index b629bbe..0fa615a 100644
22107 --- a/arch/x86/kernel/ptrace.c
22108 +++ b/arch/x86/kernel/ptrace.c
22109 @@ -184,14 +184,13 @@ unsigned long kernel_stack_pointer(struct pt_regs *regs)
22110 {
22111 unsigned long context = (unsigned long)regs & ~(THREAD_SIZE - 1);
22112 unsigned long sp = (unsigned long)&regs->sp;
22113 - struct thread_info *tinfo;
22114
22115 - if (context == (sp & ~(THREAD_SIZE - 1)))
22116 + if (context == ((sp + 8) & ~(THREAD_SIZE - 1)))
22117 return sp;
22118
22119 - tinfo = (struct thread_info *)context;
22120 - if (tinfo->previous_esp)
22121 - return tinfo->previous_esp;
22122 + sp = *(unsigned long *)context;
22123 + if (sp)
22124 + return sp;
22125
22126 return (unsigned long)regs;
22127 }
22128 @@ -588,7 +587,7 @@ static void ptrace_triggered(struct perf_event *bp,
22129 static unsigned long ptrace_get_dr7(struct perf_event *bp[])
22130 {
22131 int i;
22132 - int dr7 = 0;
22133 + unsigned long dr7 = 0;
22134 struct arch_hw_breakpoint *info;
22135
22136 for (i = 0; i < HBP_NUM; i++) {
22137 @@ -856,7 +855,7 @@ long arch_ptrace(struct task_struct *child, long request,
22138 unsigned long addr, unsigned long data)
22139 {
22140 int ret;
22141 - unsigned long __user *datap = (unsigned long __user *)data;
22142 + unsigned long __user *datap = (__force unsigned long __user *)data;
22143
22144 switch (request) {
22145 /* read the word at location addr in the USER area. */
22146 @@ -941,14 +940,14 @@ long arch_ptrace(struct task_struct *child, long request,
22147 if ((int) addr < 0)
22148 return -EIO;
22149 ret = do_get_thread_area(child, addr,
22150 - (struct user_desc __user *)data);
22151 + (__force struct user_desc __user *) data);
22152 break;
22153
22154 case PTRACE_SET_THREAD_AREA:
22155 if ((int) addr < 0)
22156 return -EIO;
22157 ret = do_set_thread_area(child, addr,
22158 - (struct user_desc __user *)data, 0);
22159 + (__force struct user_desc __user *) data, 0);
22160 break;
22161 #endif
22162
22163 @@ -1326,7 +1325,7 @@ long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
22164
22165 #ifdef CONFIG_X86_64
22166
22167 -static struct user_regset x86_64_regsets[] __read_mostly = {
22168 +static user_regset_no_const x86_64_regsets[] __read_only = {
22169 [REGSET_GENERAL] = {
22170 .core_note_type = NT_PRSTATUS,
22171 .n = sizeof(struct user_regs_struct) / sizeof(long),
22172 @@ -1367,7 +1366,7 @@ static const struct user_regset_view user_x86_64_view = {
22173 #endif /* CONFIG_X86_64 */
22174
22175 #if defined CONFIG_X86_32 || defined CONFIG_IA32_EMULATION
22176 -static struct user_regset x86_32_regsets[] __read_mostly = {
22177 +static user_regset_no_const x86_32_regsets[] __read_only = {
22178 [REGSET_GENERAL] = {
22179 .core_note_type = NT_PRSTATUS,
22180 .n = sizeof(struct user_regs_struct32) / sizeof(u32),
22181 @@ -1420,7 +1419,7 @@ static const struct user_regset_view user_x86_32_view = {
22182 */
22183 u64 xstate_fx_sw_bytes[USER_XSTATE_FX_SW_WORDS];
22184
22185 -void update_regset_xstate_info(unsigned int size, u64 xstate_mask)
22186 +void __init update_regset_xstate_info(unsigned int size, u64 xstate_mask)
22187 {
22188 #ifdef CONFIG_X86_64
22189 x86_64_regsets[REGSET_XSTATE].n = size / sizeof(u64);
22190 @@ -1455,7 +1454,7 @@ static void fill_sigtrap_info(struct task_struct *tsk,
22191 memset(info, 0, sizeof(*info));
22192 info->si_signo = SIGTRAP;
22193 info->si_code = si_code;
22194 - info->si_addr = user_mode_vm(regs) ? (void __user *)regs->ip : NULL;
22195 + info->si_addr = user_mode(regs) ? (__force void __user *)regs->ip : NULL;
22196 }
22197
22198 void user_single_step_siginfo(struct task_struct *tsk,
22199 @@ -1484,6 +1483,10 @@ void send_sigtrap(struct task_struct *tsk, struct pt_regs *regs,
22200 # define IS_IA32 0
22201 #endif
22202
22203 +#ifdef CONFIG_GRKERNSEC_SETXID
22204 +extern void gr_delayed_cred_worker(void);
22205 +#endif
22206 +
22207 /*
22208 * We must return the syscall number to actually look up in the table.
22209 * This can be -1L to skip running any syscall at all.
22210 @@ -1494,6 +1497,11 @@ long syscall_trace_enter(struct pt_regs *regs)
22211
22212 user_exit();
22213
22214 +#ifdef CONFIG_GRKERNSEC_SETXID
22215 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
22216 + gr_delayed_cred_worker();
22217 +#endif
22218 +
22219 /*
22220 * If we stepped into a sysenter/syscall insn, it trapped in
22221 * kernel mode; do_debug() cleared TF and set TIF_SINGLESTEP.
22222 @@ -1549,6 +1557,11 @@ void syscall_trace_leave(struct pt_regs *regs)
22223 */
22224 user_exit();
22225
22226 +#ifdef CONFIG_GRKERNSEC_SETXID
22227 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
22228 + gr_delayed_cred_worker();
22229 +#endif
22230 +
22231 audit_syscall_exit(regs);
22232
22233 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
22234 diff --git a/arch/x86/kernel/pvclock.c b/arch/x86/kernel/pvclock.c
22235 index 2cb9470..ff1fd80 100644
22236 --- a/arch/x86/kernel/pvclock.c
22237 +++ b/arch/x86/kernel/pvclock.c
22238 @@ -43,11 +43,11 @@ unsigned long pvclock_tsc_khz(struct pvclock_vcpu_time_info *src)
22239 return pv_tsc_khz;
22240 }
22241
22242 -static atomic64_t last_value = ATOMIC64_INIT(0);
22243 +static atomic64_unchecked_t last_value = ATOMIC64_INIT(0);
22244
22245 void pvclock_resume(void)
22246 {
22247 - atomic64_set(&last_value, 0);
22248 + atomic64_set_unchecked(&last_value, 0);
22249 }
22250
22251 u8 pvclock_read_flags(struct pvclock_vcpu_time_info *src)
22252 @@ -92,11 +92,11 @@ cycle_t pvclock_clocksource_read(struct pvclock_vcpu_time_info *src)
22253 * updating at the same time, and one of them could be slightly behind,
22254 * making the assumption that last_value always go forward fail to hold.
22255 */
22256 - last = atomic64_read(&last_value);
22257 + last = atomic64_read_unchecked(&last_value);
22258 do {
22259 if (ret < last)
22260 return last;
22261 - last = atomic64_cmpxchg(&last_value, last, ret);
22262 + last = atomic64_cmpxchg_unchecked(&last_value, last, ret);
22263 } while (unlikely(last != ret));
22264
22265 return ret;
22266 diff --git a/arch/x86/kernel/reboot.c b/arch/x86/kernel/reboot.c
22267 index 76fa1e9..abf09ea 100644
22268 --- a/arch/x86/kernel/reboot.c
22269 +++ b/arch/x86/kernel/reboot.c
22270 @@ -36,7 +36,7 @@ void (*pm_power_off)(void);
22271 EXPORT_SYMBOL(pm_power_off);
22272
22273 static const struct desc_ptr no_idt = {};
22274 -static int reboot_mode;
22275 +static unsigned short reboot_mode;
22276 enum reboot_type reboot_type = BOOT_ACPI;
22277 int reboot_force;
22278
22279 @@ -157,6 +157,11 @@ static int __init set_bios_reboot(const struct dmi_system_id *d)
22280
22281 void __noreturn machine_real_restart(unsigned int type)
22282 {
22283 +
22284 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF))
22285 + struct desc_struct *gdt;
22286 +#endif
22287 +
22288 local_irq_disable();
22289
22290 /*
22291 @@ -184,7 +189,29 @@ void __noreturn machine_real_restart(unsigned int type)
22292
22293 /* Jump to the identity-mapped low memory code */
22294 #ifdef CONFIG_X86_32
22295 - asm volatile("jmpl *%0" : :
22296 +
22297 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
22298 + gdt = get_cpu_gdt_table(smp_processor_id());
22299 + pax_open_kernel();
22300 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22301 + gdt[GDT_ENTRY_KERNEL_DS].type = 3;
22302 + gdt[GDT_ENTRY_KERNEL_DS].limit = 0xf;
22303 + loadsegment(ds, __KERNEL_DS);
22304 + loadsegment(es, __KERNEL_DS);
22305 + loadsegment(ss, __KERNEL_DS);
22306 +#endif
22307 +#ifdef CONFIG_PAX_KERNEXEC
22308 + gdt[GDT_ENTRY_KERNEL_CS].base0 = 0;
22309 + gdt[GDT_ENTRY_KERNEL_CS].base1 = 0;
22310 + gdt[GDT_ENTRY_KERNEL_CS].base2 = 0;
22311 + gdt[GDT_ENTRY_KERNEL_CS].limit0 = 0xffff;
22312 + gdt[GDT_ENTRY_KERNEL_CS].limit = 0xf;
22313 + gdt[GDT_ENTRY_KERNEL_CS].g = 1;
22314 +#endif
22315 + pax_close_kernel();
22316 +#endif
22317 +
22318 + asm volatile("ljmpl *%0" : :
22319 "rm" (real_mode_header->machine_real_restart_asm),
22320 "a" (type));
22321 #else
22322 @@ -531,7 +558,7 @@ void __attribute__((weak)) mach_reboot_fixups(void)
22323 * try to force a triple fault and then cycle between hitting the keyboard
22324 * controller and doing that
22325 */
22326 -static void native_machine_emergency_restart(void)
22327 +static void __noreturn native_machine_emergency_restart(void)
22328 {
22329 int i;
22330 int attempt = 0;
22331 @@ -654,13 +681,13 @@ void native_machine_shutdown(void)
22332 #endif
22333 }
22334
22335 -static void __machine_emergency_restart(int emergency)
22336 +static void __noreturn __machine_emergency_restart(int emergency)
22337 {
22338 reboot_emergency = emergency;
22339 machine_ops.emergency_restart();
22340 }
22341
22342 -static void native_machine_restart(char *__unused)
22343 +static void __noreturn native_machine_restart(char *__unused)
22344 {
22345 pr_notice("machine restart\n");
22346
22347 @@ -669,7 +696,7 @@ static void native_machine_restart(char *__unused)
22348 __machine_emergency_restart(0);
22349 }
22350
22351 -static void native_machine_halt(void)
22352 +static void __noreturn native_machine_halt(void)
22353 {
22354 /* Stop other cpus and apics */
22355 machine_shutdown();
22356 @@ -679,7 +706,7 @@ static void native_machine_halt(void)
22357 stop_this_cpu(NULL);
22358 }
22359
22360 -static void native_machine_power_off(void)
22361 +static void __noreturn native_machine_power_off(void)
22362 {
22363 if (pm_power_off) {
22364 if (!reboot_force)
22365 @@ -688,9 +715,10 @@ static void native_machine_power_off(void)
22366 }
22367 /* A fallback in case there is no PM info available */
22368 tboot_shutdown(TB_SHUTDOWN_HALT);
22369 + unreachable();
22370 }
22371
22372 -struct machine_ops machine_ops = {
22373 +struct machine_ops machine_ops __read_only = {
22374 .power_off = native_machine_power_off,
22375 .shutdown = native_machine_shutdown,
22376 .emergency_restart = native_machine_emergency_restart,
22377 diff --git a/arch/x86/kernel/relocate_kernel_64.S b/arch/x86/kernel/relocate_kernel_64.S
22378 index 7a6f3b3..bed145d7 100644
22379 --- a/arch/x86/kernel/relocate_kernel_64.S
22380 +++ b/arch/x86/kernel/relocate_kernel_64.S
22381 @@ -11,6 +11,7 @@
22382 #include <asm/kexec.h>
22383 #include <asm/processor-flags.h>
22384 #include <asm/pgtable_types.h>
22385 +#include <asm/alternative-asm.h>
22386
22387 /*
22388 * Must be relocatable PIC code callable as a C function
22389 @@ -160,13 +161,14 @@ identity_mapped:
22390 xorq %rbp, %rbp
22391 xorq %r8, %r8
22392 xorq %r9, %r9
22393 - xorq %r10, %r9
22394 + xorq %r10, %r10
22395 xorq %r11, %r11
22396 xorq %r12, %r12
22397 xorq %r13, %r13
22398 xorq %r14, %r14
22399 xorq %r15, %r15
22400
22401 + pax_force_retaddr 0, 1
22402 ret
22403
22404 1:
22405 diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
22406 index 8b24289..d37b58b 100644
22407 --- a/arch/x86/kernel/setup.c
22408 +++ b/arch/x86/kernel/setup.c
22409 @@ -437,7 +437,7 @@ static void __init parse_setup_data(void)
22410
22411 switch (data->type) {
22412 case SETUP_E820_EXT:
22413 - parse_e820_ext(data);
22414 + parse_e820_ext((struct setup_data __force_kernel *)data);
22415 break;
22416 case SETUP_DTB:
22417 add_dtb(pa_data);
22418 @@ -706,7 +706,7 @@ static void __init trim_bios_range(void)
22419 * area (640->1Mb) as ram even though it is not.
22420 * take them out.
22421 */
22422 - e820_remove_range(BIOS_BEGIN, BIOS_END - BIOS_BEGIN, E820_RAM, 1);
22423 + e820_remove_range(ISA_START_ADDRESS, ISA_END_ADDRESS - ISA_START_ADDRESS, E820_RAM, 1);
22424
22425 sanitize_e820_map(e820.map, ARRAY_SIZE(e820.map), &e820.nr_map);
22426 }
22427 @@ -830,14 +830,14 @@ void __init setup_arch(char **cmdline_p)
22428
22429 if (!boot_params.hdr.root_flags)
22430 root_mountflags &= ~MS_RDONLY;
22431 - init_mm.start_code = (unsigned long) _text;
22432 - init_mm.end_code = (unsigned long) _etext;
22433 + init_mm.start_code = ktla_ktva((unsigned long) _text);
22434 + init_mm.end_code = ktla_ktva((unsigned long) _etext);
22435 init_mm.end_data = (unsigned long) _edata;
22436 init_mm.brk = _brk_end;
22437
22438 - code_resource.start = virt_to_phys(_text);
22439 - code_resource.end = virt_to_phys(_etext)-1;
22440 - data_resource.start = virt_to_phys(_etext);
22441 + code_resource.start = virt_to_phys(ktla_ktva(_text));
22442 + code_resource.end = virt_to_phys(ktla_ktva(_etext))-1;
22443 + data_resource.start = virt_to_phys(_sdata);
22444 data_resource.end = virt_to_phys(_edata)-1;
22445 bss_resource.start = virt_to_phys(&__bss_start);
22446 bss_resource.end = virt_to_phys(&__bss_stop)-1;
22447 diff --git a/arch/x86/kernel/setup_percpu.c b/arch/x86/kernel/setup_percpu.c
22448 index 5cdff03..80fa283 100644
22449 --- a/arch/x86/kernel/setup_percpu.c
22450 +++ b/arch/x86/kernel/setup_percpu.c
22451 @@ -21,19 +21,17 @@
22452 #include <asm/cpu.h>
22453 #include <asm/stackprotector.h>
22454
22455 -DEFINE_PER_CPU_READ_MOSTLY(int, cpu_number);
22456 +#ifdef CONFIG_SMP
22457 +DEFINE_PER_CPU_READ_MOSTLY(unsigned int, cpu_number);
22458 EXPORT_PER_CPU_SYMBOL(cpu_number);
22459 +#endif
22460
22461 -#ifdef CONFIG_X86_64
22462 #define BOOT_PERCPU_OFFSET ((unsigned long)__per_cpu_load)
22463 -#else
22464 -#define BOOT_PERCPU_OFFSET 0
22465 -#endif
22466
22467 DEFINE_PER_CPU(unsigned long, this_cpu_off) = BOOT_PERCPU_OFFSET;
22468 EXPORT_PER_CPU_SYMBOL(this_cpu_off);
22469
22470 -unsigned long __per_cpu_offset[NR_CPUS] __read_mostly = {
22471 +unsigned long __per_cpu_offset[NR_CPUS] __read_only = {
22472 [0 ... NR_CPUS-1] = BOOT_PERCPU_OFFSET,
22473 };
22474 EXPORT_SYMBOL(__per_cpu_offset);
22475 @@ -66,7 +64,7 @@ static bool __init pcpu_need_numa(void)
22476 {
22477 #ifdef CONFIG_NEED_MULTIPLE_NODES
22478 pg_data_t *last = NULL;
22479 - unsigned int cpu;
22480 + int cpu;
22481
22482 for_each_possible_cpu(cpu) {
22483 int node = early_cpu_to_node(cpu);
22484 @@ -155,10 +153,10 @@ static inline void setup_percpu_segment(int cpu)
22485 {
22486 #ifdef CONFIG_X86_32
22487 struct desc_struct gdt;
22488 + unsigned long base = per_cpu_offset(cpu);
22489
22490 - pack_descriptor(&gdt, per_cpu_offset(cpu), 0xFFFFF,
22491 - 0x2 | DESCTYPE_S, 0x8);
22492 - gdt.s = 1;
22493 + pack_descriptor(&gdt, base, (VMALLOC_END - base - 1) >> PAGE_SHIFT,
22494 + 0x83 | DESCTYPE_S, 0xC);
22495 write_gdt_entry(get_cpu_gdt_table(cpu),
22496 GDT_ENTRY_PERCPU, &gdt, DESCTYPE_S);
22497 #endif
22498 @@ -219,6 +217,11 @@ void __init setup_per_cpu_areas(void)
22499 /* alrighty, percpu areas up and running */
22500 delta = (unsigned long)pcpu_base_addr - (unsigned long)__per_cpu_start;
22501 for_each_possible_cpu(cpu) {
22502 +#ifdef CONFIG_CC_STACKPROTECTOR
22503 +#ifdef CONFIG_X86_32
22504 + unsigned long canary = per_cpu(stack_canary.canary, cpu);
22505 +#endif
22506 +#endif
22507 per_cpu_offset(cpu) = delta + pcpu_unit_offsets[cpu];
22508 per_cpu(this_cpu_off, cpu) = per_cpu_offset(cpu);
22509 per_cpu(cpu_number, cpu) = cpu;
22510 @@ -259,6 +262,12 @@ void __init setup_per_cpu_areas(void)
22511 */
22512 set_cpu_numa_node(cpu, early_cpu_to_node(cpu));
22513 #endif
22514 +#ifdef CONFIG_CC_STACKPROTECTOR
22515 +#ifdef CONFIG_X86_32
22516 + if (!cpu)
22517 + per_cpu(stack_canary.canary, cpu) = canary;
22518 +#endif
22519 +#endif
22520 /*
22521 * Up to this point, the boot CPU has been using .init.data
22522 * area. Reload any changed state for the boot CPU.
22523 diff --git a/arch/x86/kernel/signal.c b/arch/x86/kernel/signal.c
22524 index d6bf1f3..3ffce5a 100644
22525 --- a/arch/x86/kernel/signal.c
22526 +++ b/arch/x86/kernel/signal.c
22527 @@ -196,7 +196,7 @@ static unsigned long align_sigframe(unsigned long sp)
22528 * Align the stack pointer according to the i386 ABI,
22529 * i.e. so that on function entry ((sp + 4) & 15) == 0.
22530 */
22531 - sp = ((sp + 4) & -16ul) - 4;
22532 + sp = ((sp - 12) & -16ul) - 4;
22533 #else /* !CONFIG_X86_32 */
22534 sp = round_down(sp, 16) - 8;
22535 #endif
22536 @@ -304,9 +304,9 @@ __setup_frame(int sig, struct k_sigaction *ka, sigset_t *set,
22537 }
22538
22539 if (current->mm->context.vdso)
22540 - restorer = VDSO32_SYMBOL(current->mm->context.vdso, sigreturn);
22541 + restorer = (__force void __user *)VDSO32_SYMBOL(current->mm->context.vdso, sigreturn);
22542 else
22543 - restorer = &frame->retcode;
22544 + restorer = (void __user *)&frame->retcode;
22545 if (ka->sa.sa_flags & SA_RESTORER)
22546 restorer = ka->sa.sa_restorer;
22547
22548 @@ -320,7 +320,7 @@ __setup_frame(int sig, struct k_sigaction *ka, sigset_t *set,
22549 * reasons and because gdb uses it as a signature to notice
22550 * signal handler stack frames.
22551 */
22552 - err |= __put_user(*((u64 *)&retcode), (u64 *)frame->retcode);
22553 + err |= __put_user(*((u64 *)&retcode), (u64 __user *)frame->retcode);
22554
22555 if (err)
22556 return -EFAULT;
22557 @@ -367,7 +367,10 @@ static int __setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
22558 err |= __save_altstack(&frame->uc.uc_stack, regs->sp);
22559
22560 /* Set up to return from userspace. */
22561 - restorer = VDSO32_SYMBOL(current->mm->context.vdso, rt_sigreturn);
22562 + if (current->mm->context.vdso)
22563 + restorer = (__force void __user *)VDSO32_SYMBOL(current->mm->context.vdso, rt_sigreturn);
22564 + else
22565 + restorer = (void __user *)&frame->retcode;
22566 if (ka->sa.sa_flags & SA_RESTORER)
22567 restorer = ka->sa.sa_restorer;
22568 put_user_ex(restorer, &frame->pretcode);
22569 @@ -379,7 +382,7 @@ static int __setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
22570 * reasons and because gdb uses it as a signature to notice
22571 * signal handler stack frames.
22572 */
22573 - put_user_ex(*((u64 *)&rt_retcode), (u64 *)frame->retcode);
22574 + put_user_ex(*((u64 *)&rt_retcode), (u64 __user *)frame->retcode);
22575 } put_user_catch(err);
22576
22577 err |= copy_siginfo_to_user(&frame->info, info);
22578 diff --git a/arch/x86/kernel/smp.c b/arch/x86/kernel/smp.c
22579 index 48d2b7d..90d328a 100644
22580 --- a/arch/x86/kernel/smp.c
22581 +++ b/arch/x86/kernel/smp.c
22582 @@ -285,7 +285,7 @@ static int __init nonmi_ipi_setup(char *str)
22583
22584 __setup("nonmi_ipi", nonmi_ipi_setup);
22585
22586 -struct smp_ops smp_ops = {
22587 +struct smp_ops smp_ops __read_only = {
22588 .smp_prepare_boot_cpu = native_smp_prepare_boot_cpu,
22589 .smp_prepare_cpus = native_smp_prepare_cpus,
22590 .smp_cpus_done = native_smp_cpus_done,
22591 diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
22592 index ed0fe38..87fc692 100644
22593 --- a/arch/x86/kernel/smpboot.c
22594 +++ b/arch/x86/kernel/smpboot.c
22595 @@ -748,6 +748,7 @@ static int __cpuinit do_boot_cpu(int apicid, int cpu, struct task_struct *idle)
22596 idle->thread.sp = (unsigned long) (((struct pt_regs *)
22597 (THREAD_SIZE + task_stack_page(idle))) - 1);
22598 per_cpu(current_task, cpu) = idle;
22599 + per_cpu(current_tinfo, cpu) = &idle->tinfo;
22600
22601 #ifdef CONFIG_X86_32
22602 /* Stack for startup_32 can be just as for start_secondary onwards */
22603 @@ -755,11 +756,13 @@ static int __cpuinit do_boot_cpu(int apicid, int cpu, struct task_struct *idle)
22604 #else
22605 clear_tsk_thread_flag(idle, TIF_FORK);
22606 initial_gs = per_cpu_offset(cpu);
22607 - per_cpu(kernel_stack, cpu) =
22608 - (unsigned long)task_stack_page(idle) -
22609 - KERNEL_STACK_OFFSET + THREAD_SIZE;
22610 + per_cpu(kernel_stack, cpu) = (unsigned long)task_stack_page(idle) - 16 + THREAD_SIZE;
22611 #endif
22612 +
22613 + pax_open_kernel();
22614 early_gdt_descr.address = (unsigned long)get_cpu_gdt_table(cpu);
22615 + pax_close_kernel();
22616 +
22617 initial_code = (unsigned long)start_secondary;
22618 stack_start = idle->thread.sp;
22619
22620 @@ -908,6 +911,15 @@ int __cpuinit native_cpu_up(unsigned int cpu, struct task_struct *tidle)
22621 /* the FPU context is blank, nobody can own it */
22622 __cpu_disable_lazy_restore(cpu);
22623
22624 +#ifdef CONFIG_PAX_PER_CPU_PGD
22625 + clone_pgd_range(get_cpu_pgd(cpu) + KERNEL_PGD_BOUNDARY,
22626 + swapper_pg_dir + KERNEL_PGD_BOUNDARY,
22627 + KERNEL_PGD_PTRS);
22628 +#endif
22629 +
22630 + /* the FPU context is blank, nobody can own it */
22631 + __cpu_disable_lazy_restore(cpu);
22632 +
22633 err = do_boot_cpu(apicid, cpu, tidle);
22634 if (err) {
22635 pr_debug("do_boot_cpu failed %d\n", err);
22636 diff --git a/arch/x86/kernel/step.c b/arch/x86/kernel/step.c
22637 index 9b4d51d..5d28b58 100644
22638 --- a/arch/x86/kernel/step.c
22639 +++ b/arch/x86/kernel/step.c
22640 @@ -27,10 +27,10 @@ unsigned long convert_ip_to_linear(struct task_struct *child, struct pt_regs *re
22641 struct desc_struct *desc;
22642 unsigned long base;
22643
22644 - seg &= ~7UL;
22645 + seg >>= 3;
22646
22647 mutex_lock(&child->mm->context.lock);
22648 - if (unlikely((seg >> 3) >= child->mm->context.size))
22649 + if (unlikely(seg >= child->mm->context.size))
22650 addr = -1L; /* bogus selector, access would fault */
22651 else {
22652 desc = child->mm->context.ldt + seg;
22653 @@ -42,7 +42,8 @@ unsigned long convert_ip_to_linear(struct task_struct *child, struct pt_regs *re
22654 addr += base;
22655 }
22656 mutex_unlock(&child->mm->context.lock);
22657 - }
22658 + } else if (seg == __KERNEL_CS || seg == __KERNEXEC_KERNEL_CS)
22659 + addr = ktla_ktva(addr);
22660
22661 return addr;
22662 }
22663 @@ -53,6 +54,9 @@ static int is_setting_trap_flag(struct task_struct *child, struct pt_regs *regs)
22664 unsigned char opcode[15];
22665 unsigned long addr = convert_ip_to_linear(child, regs);
22666
22667 + if (addr == -EINVAL)
22668 + return 0;
22669 +
22670 copied = access_process_vm(child, addr, opcode, sizeof(opcode), 0);
22671 for (i = 0; i < copied; i++) {
22672 switch (opcode[i]) {
22673 diff --git a/arch/x86/kernel/sys_i386_32.c b/arch/x86/kernel/sys_i386_32.c
22674 new file mode 100644
22675 index 0000000..207bec6
22676 --- /dev/null
22677 +++ b/arch/x86/kernel/sys_i386_32.c
22678 @@ -0,0 +1,250 @@
22679 +/*
22680 + * This file contains various random system calls that
22681 + * have a non-standard calling sequence on the Linux/i386
22682 + * platform.
22683 + */
22684 +
22685 +#include <linux/errno.h>
22686 +#include <linux/sched.h>
22687 +#include <linux/mm.h>
22688 +#include <linux/fs.h>
22689 +#include <linux/smp.h>
22690 +#include <linux/sem.h>
22691 +#include <linux/msg.h>
22692 +#include <linux/shm.h>
22693 +#include <linux/stat.h>
22694 +#include <linux/syscalls.h>
22695 +#include <linux/mman.h>
22696 +#include <linux/file.h>
22697 +#include <linux/utsname.h>
22698 +#include <linux/ipc.h>
22699 +
22700 +#include <linux/uaccess.h>
22701 +#include <linux/unistd.h>
22702 +
22703 +#include <asm/syscalls.h>
22704 +
22705 +int i386_mmap_check(unsigned long addr, unsigned long len, unsigned long flags)
22706 +{
22707 + unsigned long pax_task_size = TASK_SIZE;
22708 +
22709 +#ifdef CONFIG_PAX_SEGMEXEC
22710 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC)
22711 + pax_task_size = SEGMEXEC_TASK_SIZE;
22712 +#endif
22713 +
22714 + if (flags & MAP_FIXED)
22715 + if (len > pax_task_size || addr > pax_task_size - len)
22716 + return -EINVAL;
22717 +
22718 + return 0;
22719 +}
22720 +
22721 +unsigned long
22722 +arch_get_unmapped_area(struct file *filp, unsigned long addr,
22723 + unsigned long len, unsigned long pgoff, unsigned long flags)
22724 +{
22725 + struct mm_struct *mm = current->mm;
22726 + struct vm_area_struct *vma;
22727 + unsigned long start_addr, pax_task_size = TASK_SIZE;
22728 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
22729 +
22730 +#ifdef CONFIG_PAX_SEGMEXEC
22731 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
22732 + pax_task_size = SEGMEXEC_TASK_SIZE;
22733 +#endif
22734 +
22735 + pax_task_size -= PAGE_SIZE;
22736 +
22737 + if (len > pax_task_size)
22738 + return -ENOMEM;
22739 +
22740 + if (flags & MAP_FIXED)
22741 + return addr;
22742 +
22743 +#ifdef CONFIG_PAX_RANDMMAP
22744 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
22745 +#endif
22746 +
22747 + if (addr) {
22748 + addr = PAGE_ALIGN(addr);
22749 + if (pax_task_size - len >= addr) {
22750 + vma = find_vma(mm, addr);
22751 + if (check_heap_stack_gap(vma, addr, len, offset))
22752 + return addr;
22753 + }
22754 + }
22755 + if (len > mm->cached_hole_size) {
22756 + start_addr = addr = mm->free_area_cache;
22757 + } else {
22758 + start_addr = addr = mm->mmap_base;
22759 + mm->cached_hole_size = 0;
22760 + }
22761 +
22762 +#ifdef CONFIG_PAX_PAGEEXEC
22763 + if (!(__supported_pte_mask & _PAGE_NX) && (mm->pax_flags & MF_PAX_PAGEEXEC) && (flags & MAP_EXECUTABLE) && start_addr >= mm->mmap_base) {
22764 + start_addr = 0x00110000UL;
22765 +
22766 +#ifdef CONFIG_PAX_RANDMMAP
22767 + if (mm->pax_flags & MF_PAX_RANDMMAP)
22768 + start_addr += mm->delta_mmap & 0x03FFF000UL;
22769 +#endif
22770 +
22771 + if (mm->start_brk <= start_addr && start_addr < mm->mmap_base)
22772 + start_addr = addr = mm->mmap_base;
22773 + else
22774 + addr = start_addr;
22775 + }
22776 +#endif
22777 +
22778 +full_search:
22779 + for (vma = find_vma(mm, addr); ; vma = vma->vm_next) {
22780 + /* At this point: (!vma || addr < vma->vm_end). */
22781 + if (pax_task_size - len < addr) {
22782 + /*
22783 + * Start a new search - just in case we missed
22784 + * some holes.
22785 + */
22786 + if (start_addr != mm->mmap_base) {
22787 + start_addr = addr = mm->mmap_base;
22788 + mm->cached_hole_size = 0;
22789 + goto full_search;
22790 + }
22791 + return -ENOMEM;
22792 + }
22793 + if (check_heap_stack_gap(vma, addr, len, offset))
22794 + break;
22795 + if (addr + mm->cached_hole_size < vma->vm_start)
22796 + mm->cached_hole_size = vma->vm_start - addr;
22797 + addr = vma->vm_end;
22798 + if (mm->start_brk <= addr && addr < mm->mmap_base) {
22799 + start_addr = addr = mm->mmap_base;
22800 + mm->cached_hole_size = 0;
22801 + goto full_search;
22802 + }
22803 + }
22804 +
22805 + /*
22806 + * Remember the place where we stopped the search:
22807 + */
22808 + mm->free_area_cache = addr + len;
22809 + return addr;
22810 +}
22811 +
22812 +unsigned long
22813 +arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
22814 + const unsigned long len, const unsigned long pgoff,
22815 + const unsigned long flags)
22816 +{
22817 + struct vm_area_struct *vma;
22818 + struct mm_struct *mm = current->mm;
22819 + unsigned long base = mm->mmap_base, addr = addr0, pax_task_size = TASK_SIZE;
22820 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
22821 +
22822 +#ifdef CONFIG_PAX_SEGMEXEC
22823 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
22824 + pax_task_size = SEGMEXEC_TASK_SIZE;
22825 +#endif
22826 +
22827 + pax_task_size -= PAGE_SIZE;
22828 +
22829 + /* requested length too big for entire address space */
22830 + if (len > pax_task_size)
22831 + return -ENOMEM;
22832 +
22833 + if (flags & MAP_FIXED)
22834 + return addr;
22835 +
22836 +#ifdef CONFIG_PAX_PAGEEXEC
22837 + if (!(__supported_pte_mask & _PAGE_NX) && (mm->pax_flags & MF_PAX_PAGEEXEC) && (flags & MAP_EXECUTABLE))
22838 + goto bottomup;
22839 +#endif
22840 +
22841 +#ifdef CONFIG_PAX_RANDMMAP
22842 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
22843 +#endif
22844 +
22845 + /* requesting a specific address */
22846 + if (addr) {
22847 + addr = PAGE_ALIGN(addr);
22848 + if (pax_task_size - len >= addr) {
22849 + vma = find_vma(mm, addr);
22850 + if (check_heap_stack_gap(vma, addr, len, offset))
22851 + return addr;
22852 + }
22853 + }
22854 +
22855 + /* check if free_area_cache is useful for us */
22856 + if (len <= mm->cached_hole_size) {
22857 + mm->cached_hole_size = 0;
22858 + mm->free_area_cache = mm->mmap_base;
22859 + }
22860 +
22861 + /* either no address requested or can't fit in requested address hole */
22862 + addr = mm->free_area_cache;
22863 +
22864 + /* make sure it can fit in the remaining address space */
22865 + if (addr > len) {
22866 + vma = find_vma(mm, addr-len);
22867 + if (check_heap_stack_gap(vma, addr - len, len, offset))
22868 + /* remember the address as a hint for next time */
22869 + return (mm->free_area_cache = addr-len);
22870 + }
22871 +
22872 + if (mm->mmap_base < len)
22873 + goto bottomup;
22874 +
22875 + addr = mm->mmap_base-len;
22876 +
22877 + do {
22878 + /*
22879 + * Lookup failure means no vma is above this address,
22880 + * else if new region fits below vma->vm_start,
22881 + * return with success:
22882 + */
22883 + vma = find_vma(mm, addr);
22884 + if (check_heap_stack_gap(vma, addr, len, offset))
22885 + /* remember the address as a hint for next time */
22886 + return (mm->free_area_cache = addr);
22887 +
22888 + /* remember the largest hole we saw so far */
22889 + if (addr + mm->cached_hole_size < vma->vm_start)
22890 + mm->cached_hole_size = vma->vm_start - addr;
22891 +
22892 + /* try just below the current vma->vm_start */
22893 + addr = skip_heap_stack_gap(vma, len, offset);
22894 + } while (!IS_ERR_VALUE(addr));
22895 +
22896 +bottomup:
22897 + /*
22898 + * A failed mmap() very likely causes application failure,
22899 + * so fall back to the bottom-up function here. This scenario
22900 + * can happen with large stack limits and large mmap()
22901 + * allocations.
22902 + */
22903 +
22904 +#ifdef CONFIG_PAX_SEGMEXEC
22905 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
22906 + mm->mmap_base = SEGMEXEC_TASK_UNMAPPED_BASE;
22907 + else
22908 +#endif
22909 +
22910 + mm->mmap_base = TASK_UNMAPPED_BASE;
22911 +
22912 +#ifdef CONFIG_PAX_RANDMMAP
22913 + if (mm->pax_flags & MF_PAX_RANDMMAP)
22914 + mm->mmap_base += mm->delta_mmap;
22915 +#endif
22916 +
22917 + mm->free_area_cache = mm->mmap_base;
22918 + mm->cached_hole_size = ~0UL;
22919 + addr = arch_get_unmapped_area(filp, addr0, len, pgoff, flags);
22920 + /*
22921 + * Restore the topdown base:
22922 + */
22923 + mm->mmap_base = base;
22924 + mm->free_area_cache = base;
22925 + mm->cached_hole_size = ~0UL;
22926 +
22927 + return addr;
22928 +}
22929 diff --git a/arch/x86/kernel/sys_x86_64.c b/arch/x86/kernel/sys_x86_64.c
22930 index 97ef74b..57a1882 100644
22931 --- a/arch/x86/kernel/sys_x86_64.c
22932 +++ b/arch/x86/kernel/sys_x86_64.c
22933 @@ -81,8 +81,8 @@ out:
22934 return error;
22935 }
22936
22937 -static void find_start_end(unsigned long flags, unsigned long *begin,
22938 - unsigned long *end)
22939 +static void find_start_end(struct mm_struct *mm, unsigned long flags,
22940 + unsigned long *begin, unsigned long *end)
22941 {
22942 if (!test_thread_flag(TIF_ADDR32) && (flags & MAP_32BIT)) {
22943 unsigned long new_begin;
22944 @@ -101,7 +101,7 @@ static void find_start_end(unsigned long flags, unsigned long *begin,
22945 *begin = new_begin;
22946 }
22947 } else {
22948 - *begin = TASK_UNMAPPED_BASE;
22949 + *begin = mm->mmap_base;
22950 *end = TASK_SIZE;
22951 }
22952 }
22953 @@ -114,20 +114,24 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
22954 struct vm_area_struct *vma;
22955 struct vm_unmapped_area_info info;
22956 unsigned long begin, end;
22957 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
22958
22959 if (flags & MAP_FIXED)
22960 return addr;
22961
22962 - find_start_end(flags, &begin, &end);
22963 + find_start_end(mm, flags, &begin, &end);
22964
22965 if (len > end)
22966 return -ENOMEM;
22967
22968 +#ifdef CONFIG_PAX_RANDMMAP
22969 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
22970 +#endif
22971 +
22972 if (addr) {
22973 addr = PAGE_ALIGN(addr);
22974 vma = find_vma(mm, addr);
22975 - if (end - len >= addr &&
22976 - (!vma || addr + len <= vma->vm_start))
22977 + if (end - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
22978 return addr;
22979 }
22980
22981 @@ -161,6 +165,10 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
22982 if (!test_thread_flag(TIF_ADDR32) && (flags & MAP_32BIT))
22983 goto bottomup;
22984
22985 +#ifdef CONFIG_PAX_RANDMMAP
22986 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
22987 +#endif
22988 +
22989 /* requesting a specific address */
22990 if (addr) {
22991 addr = PAGE_ALIGN(addr);
22992 diff --git a/arch/x86/kernel/tboot.c b/arch/x86/kernel/tboot.c
22993 index f84fe00..f41d9f1 100644
22994 --- a/arch/x86/kernel/tboot.c
22995 +++ b/arch/x86/kernel/tboot.c
22996 @@ -220,7 +220,7 @@ static int tboot_setup_sleep(void)
22997
22998 void tboot_shutdown(u32 shutdown_type)
22999 {
23000 - void (*shutdown)(void);
23001 + void (* __noreturn shutdown)(void);
23002
23003 if (!tboot_enabled())
23004 return;
23005 @@ -242,7 +242,7 @@ void tboot_shutdown(u32 shutdown_type)
23006
23007 switch_to_tboot_pt();
23008
23009 - shutdown = (void(*)(void))(unsigned long)tboot->shutdown_entry;
23010 + shutdown = (void *)tboot->shutdown_entry;
23011 shutdown();
23012
23013 /* should not reach here */
23014 @@ -300,7 +300,7 @@ static int tboot_sleep(u8 sleep_state, u32 pm1a_control, u32 pm1b_control)
23015 return 0;
23016 }
23017
23018 -static atomic_t ap_wfs_count;
23019 +static atomic_unchecked_t ap_wfs_count;
23020
23021 static int tboot_wait_for_aps(int num_aps)
23022 {
23023 @@ -324,16 +324,16 @@ static int __cpuinit tboot_cpu_callback(struct notifier_block *nfb,
23024 {
23025 switch (action) {
23026 case CPU_DYING:
23027 - atomic_inc(&ap_wfs_count);
23028 + atomic_inc_unchecked(&ap_wfs_count);
23029 if (num_online_cpus() == 1)
23030 - if (tboot_wait_for_aps(atomic_read(&ap_wfs_count)))
23031 + if (tboot_wait_for_aps(atomic_read_unchecked(&ap_wfs_count)))
23032 return NOTIFY_BAD;
23033 break;
23034 }
23035 return NOTIFY_OK;
23036 }
23037
23038 -static struct notifier_block tboot_cpu_notifier __cpuinitdata =
23039 +static struct notifier_block tboot_cpu_notifier =
23040 {
23041 .notifier_call = tboot_cpu_callback,
23042 };
23043 @@ -345,7 +345,7 @@ static __init int tboot_late_init(void)
23044
23045 tboot_create_trampoline();
23046
23047 - atomic_set(&ap_wfs_count, 0);
23048 + atomic_set_unchecked(&ap_wfs_count, 0);
23049 register_hotcpu_notifier(&tboot_cpu_notifier);
23050
23051 acpi_os_set_prepare_sleep(&tboot_sleep);
23052 diff --git a/arch/x86/kernel/time.c b/arch/x86/kernel/time.c
23053 index 24d3c91..d06b473 100644
23054 --- a/arch/x86/kernel/time.c
23055 +++ b/arch/x86/kernel/time.c
23056 @@ -30,9 +30,9 @@ unsigned long profile_pc(struct pt_regs *regs)
23057 {
23058 unsigned long pc = instruction_pointer(regs);
23059
23060 - if (!user_mode_vm(regs) && in_lock_functions(pc)) {
23061 + if (!user_mode(regs) && in_lock_functions(pc)) {
23062 #ifdef CONFIG_FRAME_POINTER
23063 - return *(unsigned long *)(regs->bp + sizeof(long));
23064 + return ktla_ktva(*(unsigned long *)(regs->bp + sizeof(long)));
23065 #else
23066 unsigned long *sp =
23067 (unsigned long *)kernel_stack_pointer(regs);
23068 @@ -41,11 +41,17 @@ unsigned long profile_pc(struct pt_regs *regs)
23069 * or above a saved flags. Eflags has bits 22-31 zero,
23070 * kernel addresses don't.
23071 */
23072 +
23073 +#ifdef CONFIG_PAX_KERNEXEC
23074 + return ktla_ktva(sp[0]);
23075 +#else
23076 if (sp[0] >> 22)
23077 return sp[0];
23078 if (sp[1] >> 22)
23079 return sp[1];
23080 #endif
23081 +
23082 +#endif
23083 }
23084 return pc;
23085 }
23086 diff --git a/arch/x86/kernel/tls.c b/arch/x86/kernel/tls.c
23087 index 9d9d2f9..cad418a 100644
23088 --- a/arch/x86/kernel/tls.c
23089 +++ b/arch/x86/kernel/tls.c
23090 @@ -84,6 +84,11 @@ int do_set_thread_area(struct task_struct *p, int idx,
23091 if (idx < GDT_ENTRY_TLS_MIN || idx > GDT_ENTRY_TLS_MAX)
23092 return -EINVAL;
23093
23094 +#ifdef CONFIG_PAX_SEGMEXEC
23095 + if ((p->mm->pax_flags & MF_PAX_SEGMEXEC) && (info.contents & MODIFY_LDT_CONTENTS_CODE))
23096 + return -EINVAL;
23097 +#endif
23098 +
23099 set_tls_desc(p, idx, &info, 1);
23100
23101 return 0;
23102 @@ -204,7 +209,7 @@ int regset_tls_set(struct task_struct *target, const struct user_regset *regset,
23103
23104 if (kbuf)
23105 info = kbuf;
23106 - else if (__copy_from_user(infobuf, ubuf, count))
23107 + else if (count > sizeof infobuf || __copy_from_user(infobuf, ubuf, count))
23108 return -EFAULT;
23109 else
23110 info = infobuf;
23111 diff --git a/arch/x86/kernel/traps.c b/arch/x86/kernel/traps.c
23112 index ecffca1..95c4d13 100644
23113 --- a/arch/x86/kernel/traps.c
23114 +++ b/arch/x86/kernel/traps.c
23115 @@ -68,12 +68,6 @@
23116 #include <asm/setup.h>
23117
23118 asmlinkage int system_call(void);
23119 -
23120 -/*
23121 - * The IDT has to be page-aligned to simplify the Pentium
23122 - * F0 0F bug workaround.
23123 - */
23124 -gate_desc idt_table[NR_VECTORS] __page_aligned_data = { { { { 0, 0 } } }, };
23125 #endif
23126
23127 DECLARE_BITMAP(used_vectors, NR_VECTORS);
23128 @@ -106,11 +100,11 @@ static inline void preempt_conditional_cli(struct pt_regs *regs)
23129 }
23130
23131 static int __kprobes
23132 -do_trap_no_signal(struct task_struct *tsk, int trapnr, char *str,
23133 +do_trap_no_signal(struct task_struct *tsk, int trapnr, const char *str,
23134 struct pt_regs *regs, long error_code)
23135 {
23136 #ifdef CONFIG_X86_32
23137 - if (regs->flags & X86_VM_MASK) {
23138 + if (v8086_mode(regs)) {
23139 /*
23140 * Traps 0, 1, 3, 4, and 5 should be forwarded to vm86.
23141 * On nmi (interrupt 2), do_trap should not be called.
23142 @@ -123,12 +117,24 @@ do_trap_no_signal(struct task_struct *tsk, int trapnr, char *str,
23143 return -1;
23144 }
23145 #endif
23146 - if (!user_mode(regs)) {
23147 + if (!user_mode_novm(regs)) {
23148 if (!fixup_exception(regs)) {
23149 tsk->thread.error_code = error_code;
23150 tsk->thread.trap_nr = trapnr;
23151 +
23152 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
23153 + if (trapnr == 12 && ((regs->cs & 0xFFFF) == __KERNEL_CS || (regs->cs & 0xFFFF) == __KERNEXEC_KERNEL_CS))
23154 + str = "PAX: suspicious stack segment fault";
23155 +#endif
23156 +
23157 die(str, regs, error_code);
23158 }
23159 +
23160 +#ifdef CONFIG_PAX_REFCOUNT
23161 + if (trapnr == 4)
23162 + pax_report_refcount_overflow(regs);
23163 +#endif
23164 +
23165 return 0;
23166 }
23167
23168 @@ -136,7 +142,7 @@ do_trap_no_signal(struct task_struct *tsk, int trapnr, char *str,
23169 }
23170
23171 static void __kprobes
23172 -do_trap(int trapnr, int signr, char *str, struct pt_regs *regs,
23173 +do_trap(int trapnr, int signr, const char *str, struct pt_regs *regs,
23174 long error_code, siginfo_t *info)
23175 {
23176 struct task_struct *tsk = current;
23177 @@ -160,7 +166,7 @@ do_trap(int trapnr, int signr, char *str, struct pt_regs *regs,
23178 if (show_unhandled_signals && unhandled_signal(tsk, signr) &&
23179 printk_ratelimit()) {
23180 pr_info("%s[%d] trap %s ip:%lx sp:%lx error:%lx",
23181 - tsk->comm, tsk->pid, str,
23182 + tsk->comm, task_pid_nr(tsk), str,
23183 regs->ip, regs->sp, error_code);
23184 print_vma_addr(" in ", regs->ip);
23185 pr_cont("\n");
23186 @@ -266,7 +272,7 @@ do_general_protection(struct pt_regs *regs, long error_code)
23187 conditional_sti(regs);
23188
23189 #ifdef CONFIG_X86_32
23190 - if (regs->flags & X86_VM_MASK) {
23191 + if (v8086_mode(regs)) {
23192 local_irq_enable();
23193 handle_vm86_fault((struct kernel_vm86_regs *) regs, error_code);
23194 goto exit;
23195 @@ -274,18 +280,42 @@ do_general_protection(struct pt_regs *regs, long error_code)
23196 #endif
23197
23198 tsk = current;
23199 - if (!user_mode(regs)) {
23200 + if (!user_mode_novm(regs)) {
23201 if (fixup_exception(regs))
23202 goto exit;
23203
23204 tsk->thread.error_code = error_code;
23205 tsk->thread.trap_nr = X86_TRAP_GP;
23206 if (notify_die(DIE_GPF, "general protection fault", regs, error_code,
23207 - X86_TRAP_GP, SIGSEGV) != NOTIFY_STOP)
23208 + X86_TRAP_GP, SIGSEGV) != NOTIFY_STOP) {
23209 +
23210 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
23211 + if ((regs->cs & 0xFFFF) == __KERNEL_CS || (regs->cs & 0xFFFF) == __KERNEXEC_KERNEL_CS)
23212 + die("PAX: suspicious general protection fault", regs, error_code);
23213 + else
23214 +#endif
23215 +
23216 die("general protection fault", regs, error_code);
23217 + }
23218 goto exit;
23219 }
23220
23221 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
23222 + if (!(__supported_pte_mask & _PAGE_NX) && tsk->mm && (tsk->mm->pax_flags & MF_PAX_PAGEEXEC)) {
23223 + struct mm_struct *mm = tsk->mm;
23224 + unsigned long limit;
23225 +
23226 + down_write(&mm->mmap_sem);
23227 + limit = mm->context.user_cs_limit;
23228 + if (limit < TASK_SIZE) {
23229 + track_exec_limit(mm, limit, TASK_SIZE, VM_EXEC);
23230 + up_write(&mm->mmap_sem);
23231 + return;
23232 + }
23233 + up_write(&mm->mmap_sem);
23234 + }
23235 +#endif
23236 +
23237 tsk->thread.error_code = error_code;
23238 tsk->thread.trap_nr = X86_TRAP_GP;
23239
23240 @@ -440,7 +470,7 @@ dotraplinkage void __kprobes do_debug(struct pt_regs *regs, long error_code)
23241 /* It's safe to allow irq's after DR6 has been saved */
23242 preempt_conditional_sti(regs);
23243
23244 - if (regs->flags & X86_VM_MASK) {
23245 + if (v8086_mode(regs)) {
23246 handle_vm86_trap((struct kernel_vm86_regs *) regs, error_code,
23247 X86_TRAP_DB);
23248 preempt_conditional_cli(regs);
23249 @@ -455,7 +485,7 @@ dotraplinkage void __kprobes do_debug(struct pt_regs *regs, long error_code)
23250 * We already checked v86 mode above, so we can check for kernel mode
23251 * by just checking the CPL of CS.
23252 */
23253 - if ((dr6 & DR_STEP) && !user_mode(regs)) {
23254 + if ((dr6 & DR_STEP) && !user_mode_novm(regs)) {
23255 tsk->thread.debugreg6 &= ~DR_STEP;
23256 set_tsk_thread_flag(tsk, TIF_SINGLESTEP);
23257 regs->flags &= ~X86_EFLAGS_TF;
23258 @@ -487,7 +517,7 @@ void math_error(struct pt_regs *regs, int error_code, int trapnr)
23259 return;
23260 conditional_sti(regs);
23261
23262 - if (!user_mode_vm(regs))
23263 + if (!user_mode(regs))
23264 {
23265 if (!fixup_exception(regs)) {
23266 task->thread.error_code = error_code;
23267 diff --git a/arch/x86/kernel/uprobes.c b/arch/x86/kernel/uprobes.c
23268 index c71025b..b117501 100644
23269 --- a/arch/x86/kernel/uprobes.c
23270 +++ b/arch/x86/kernel/uprobes.c
23271 @@ -629,7 +629,7 @@ int arch_uprobe_exception_notify(struct notifier_block *self, unsigned long val,
23272 int ret = NOTIFY_DONE;
23273
23274 /* We are only interested in userspace traps */
23275 - if (regs && !user_mode_vm(regs))
23276 + if (regs && !user_mode(regs))
23277 return NOTIFY_DONE;
23278
23279 switch (val) {
23280 diff --git a/arch/x86/kernel/verify_cpu.S b/arch/x86/kernel/verify_cpu.S
23281 index b9242ba..50c5edd 100644
23282 --- a/arch/x86/kernel/verify_cpu.S
23283 +++ b/arch/x86/kernel/verify_cpu.S
23284 @@ -20,6 +20,7 @@
23285 * arch/x86/boot/compressed/head_64.S: Boot cpu verification
23286 * arch/x86/kernel/trampoline_64.S: secondary processor verification
23287 * arch/x86/kernel/head_32.S: processor startup
23288 + * arch/x86/kernel/acpi/realmode/wakeup.S: 32bit processor resume
23289 *
23290 * verify_cpu, returns the status of longmode and SSE in register %eax.
23291 * 0: Success 1: Failure
23292 diff --git a/arch/x86/kernel/vm86_32.c b/arch/x86/kernel/vm86_32.c
23293 index 1dfe69c..a3df6f6 100644
23294 --- a/arch/x86/kernel/vm86_32.c
23295 +++ b/arch/x86/kernel/vm86_32.c
23296 @@ -43,6 +43,7 @@
23297 #include <linux/ptrace.h>
23298 #include <linux/audit.h>
23299 #include <linux/stddef.h>
23300 +#include <linux/grsecurity.h>
23301
23302 #include <asm/uaccess.h>
23303 #include <asm/io.h>
23304 @@ -150,7 +151,7 @@ struct pt_regs *save_v86_state(struct kernel_vm86_regs *regs)
23305 do_exit(SIGSEGV);
23306 }
23307
23308 - tss = &per_cpu(init_tss, get_cpu());
23309 + tss = init_tss + get_cpu();
23310 current->thread.sp0 = current->thread.saved_sp0;
23311 current->thread.sysenter_cs = __KERNEL_CS;
23312 load_sp0(tss, &current->thread);
23313 @@ -212,6 +213,13 @@ int sys_vm86old(struct vm86_struct __user *v86, struct pt_regs *regs)
23314 struct task_struct *tsk;
23315 int tmp, ret = -EPERM;
23316
23317 +#ifdef CONFIG_GRKERNSEC_VM86
23318 + if (!capable(CAP_SYS_RAWIO)) {
23319 + gr_handle_vm86();
23320 + goto out;
23321 + }
23322 +#endif
23323 +
23324 tsk = current;
23325 if (tsk->thread.saved_sp0)
23326 goto out;
23327 @@ -242,6 +250,14 @@ int sys_vm86(unsigned long cmd, unsigned long arg, struct pt_regs *regs)
23328 int tmp, ret;
23329 struct vm86plus_struct __user *v86;
23330
23331 +#ifdef CONFIG_GRKERNSEC_VM86
23332 + if (!capable(CAP_SYS_RAWIO)) {
23333 + gr_handle_vm86();
23334 + ret = -EPERM;
23335 + goto out;
23336 + }
23337 +#endif
23338 +
23339 tsk = current;
23340 switch (cmd) {
23341 case VM86_REQUEST_IRQ:
23342 @@ -328,7 +344,7 @@ static void do_sys_vm86(struct kernel_vm86_struct *info, struct task_struct *tsk
23343 tsk->thread.saved_fs = info->regs32->fs;
23344 tsk->thread.saved_gs = get_user_gs(info->regs32);
23345
23346 - tss = &per_cpu(init_tss, get_cpu());
23347 + tss = init_tss + get_cpu();
23348 tsk->thread.sp0 = (unsigned long) &info->VM86_TSS_ESP0;
23349 if (cpu_has_sep)
23350 tsk->thread.sysenter_cs = 0;
23351 @@ -535,7 +551,7 @@ static void do_int(struct kernel_vm86_regs *regs, int i,
23352 goto cannot_handle;
23353 if (i == 0x21 && is_revectored(AH(regs), &KVM86->int21_revectored))
23354 goto cannot_handle;
23355 - intr_ptr = (unsigned long __user *) (i << 2);
23356 + intr_ptr = (__force unsigned long __user *) (i << 2);
23357 if (get_user(segoffs, intr_ptr))
23358 goto cannot_handle;
23359 if ((segoffs >> 16) == BIOSSEG)
23360 diff --git a/arch/x86/kernel/vmlinux.lds.S b/arch/x86/kernel/vmlinux.lds.S
23361 index 22a1530..8fbaaad 100644
23362 --- a/arch/x86/kernel/vmlinux.lds.S
23363 +++ b/arch/x86/kernel/vmlinux.lds.S
23364 @@ -26,6 +26,13 @@
23365 #include <asm/page_types.h>
23366 #include <asm/cache.h>
23367 #include <asm/boot.h>
23368 +#include <asm/segment.h>
23369 +
23370 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
23371 +#define __KERNEL_TEXT_OFFSET (LOAD_OFFSET + ____LOAD_PHYSICAL_ADDR)
23372 +#else
23373 +#define __KERNEL_TEXT_OFFSET 0
23374 +#endif
23375
23376 #undef i386 /* in case the preprocessor is a 32bit one */
23377
23378 @@ -69,30 +76,43 @@ jiffies_64 = jiffies;
23379
23380 PHDRS {
23381 text PT_LOAD FLAGS(5); /* R_E */
23382 +#ifdef CONFIG_X86_32
23383 + module PT_LOAD FLAGS(5); /* R_E */
23384 +#endif
23385 +#ifdef CONFIG_XEN
23386 + rodata PT_LOAD FLAGS(5); /* R_E */
23387 +#else
23388 + rodata PT_LOAD FLAGS(4); /* R__ */
23389 +#endif
23390 data PT_LOAD FLAGS(6); /* RW_ */
23391 -#ifdef CONFIG_X86_64
23392 + init.begin PT_LOAD FLAGS(6); /* RW_ */
23393 #ifdef CONFIG_SMP
23394 percpu PT_LOAD FLAGS(6); /* RW_ */
23395 #endif
23396 + text.init PT_LOAD FLAGS(5); /* R_E */
23397 + text.exit PT_LOAD FLAGS(5); /* R_E */
23398 init PT_LOAD FLAGS(7); /* RWE */
23399 -#endif
23400 note PT_NOTE FLAGS(0); /* ___ */
23401 }
23402
23403 SECTIONS
23404 {
23405 #ifdef CONFIG_X86_32
23406 - . = LOAD_OFFSET + LOAD_PHYSICAL_ADDR;
23407 - phys_startup_32 = startup_32 - LOAD_OFFSET;
23408 + . = LOAD_OFFSET + ____LOAD_PHYSICAL_ADDR;
23409 #else
23410 - . = __START_KERNEL;
23411 - phys_startup_64 = startup_64 - LOAD_OFFSET;
23412 + . = __START_KERNEL;
23413 #endif
23414
23415 /* Text and read-only data */
23416 - .text : AT(ADDR(.text) - LOAD_OFFSET) {
23417 - _text = .;
23418 + .text (. - __KERNEL_TEXT_OFFSET): AT(ADDR(.text) - LOAD_OFFSET + __KERNEL_TEXT_OFFSET) {
23419 /* bootstrapping code */
23420 +#ifdef CONFIG_X86_32
23421 + phys_startup_32 = startup_32 - LOAD_OFFSET + __KERNEL_TEXT_OFFSET;
23422 +#else
23423 + phys_startup_64 = startup_64 - LOAD_OFFSET + __KERNEL_TEXT_OFFSET;
23424 +#endif
23425 + __LOAD_PHYSICAL_ADDR = . - LOAD_OFFSET + __KERNEL_TEXT_OFFSET;
23426 + _text = .;
23427 HEAD_TEXT
23428 #ifdef CONFIG_X86_32
23429 . = ALIGN(PAGE_SIZE);
23430 @@ -108,13 +128,48 @@ SECTIONS
23431 IRQENTRY_TEXT
23432 *(.fixup)
23433 *(.gnu.warning)
23434 - /* End of text section */
23435 - _etext = .;
23436 } :text = 0x9090
23437
23438 - NOTES :text :note
23439 + . += __KERNEL_TEXT_OFFSET;
23440
23441 - EXCEPTION_TABLE(16) :text = 0x9090
23442 +#ifdef CONFIG_X86_32
23443 + . = ALIGN(PAGE_SIZE);
23444 + .module.text : AT(ADDR(.module.text) - LOAD_OFFSET) {
23445 +
23446 +#if defined(CONFIG_PAX_KERNEXEC) && defined(CONFIG_MODULES)
23447 + MODULES_EXEC_VADDR = .;
23448 + BYTE(0)
23449 + . += (CONFIG_PAX_KERNEXEC_MODULE_TEXT * 1024 * 1024);
23450 + . = ALIGN(HPAGE_SIZE) - 1;
23451 + MODULES_EXEC_END = .;
23452 +#endif
23453 +
23454 + } :module
23455 +#endif
23456 +
23457 + .text.end : AT(ADDR(.text.end) - LOAD_OFFSET) {
23458 + /* End of text section */
23459 + BYTE(0)
23460 + _etext = . - __KERNEL_TEXT_OFFSET;
23461 + }
23462 +
23463 +#ifdef CONFIG_X86_32
23464 + . = ALIGN(PAGE_SIZE);
23465 + .rodata.page_aligned : AT(ADDR(.rodata.page_aligned) - LOAD_OFFSET) {
23466 + *(.idt)
23467 + . = ALIGN(PAGE_SIZE);
23468 + *(.empty_zero_page)
23469 + *(.initial_pg_fixmap)
23470 + *(.initial_pg_pmd)
23471 + *(.initial_page_table)
23472 + *(.swapper_pg_dir)
23473 + } :rodata
23474 +#endif
23475 +
23476 + . = ALIGN(PAGE_SIZE);
23477 + NOTES :rodata :note
23478 +
23479 + EXCEPTION_TABLE(16) :rodata
23480
23481 #if defined(CONFIG_DEBUG_RODATA)
23482 /* .text should occupy whole number of pages */
23483 @@ -126,16 +181,20 @@ SECTIONS
23484
23485 /* Data */
23486 .data : AT(ADDR(.data) - LOAD_OFFSET) {
23487 +
23488 +#ifdef CONFIG_PAX_KERNEXEC
23489 + . = ALIGN(HPAGE_SIZE);
23490 +#else
23491 + . = ALIGN(PAGE_SIZE);
23492 +#endif
23493 +
23494 /* Start of data section */
23495 _sdata = .;
23496
23497 /* init_task */
23498 INIT_TASK_DATA(THREAD_SIZE)
23499
23500 -#ifdef CONFIG_X86_32
23501 - /* 32 bit has nosave before _edata */
23502 NOSAVE_DATA
23503 -#endif
23504
23505 PAGE_ALIGNED_DATA(PAGE_SIZE)
23506
23507 @@ -176,12 +235,19 @@ SECTIONS
23508 #endif /* CONFIG_X86_64 */
23509
23510 /* Init code and data - will be freed after init */
23511 - . = ALIGN(PAGE_SIZE);
23512 .init.begin : AT(ADDR(.init.begin) - LOAD_OFFSET) {
23513 + BYTE(0)
23514 +
23515 +#ifdef CONFIG_PAX_KERNEXEC
23516 + . = ALIGN(HPAGE_SIZE);
23517 +#else
23518 + . = ALIGN(PAGE_SIZE);
23519 +#endif
23520 +
23521 __init_begin = .; /* paired with __init_end */
23522 - }
23523 + } :init.begin
23524
23525 -#if defined(CONFIG_X86_64) && defined(CONFIG_SMP)
23526 +#ifdef CONFIG_SMP
23527 /*
23528 * percpu offsets are zero-based on SMP. PERCPU_VADDR() changes the
23529 * output PHDR, so the next output section - .init.text - should
23530 @@ -190,12 +256,27 @@ SECTIONS
23531 PERCPU_VADDR(INTERNODE_CACHE_BYTES, 0, :percpu)
23532 #endif
23533
23534 - INIT_TEXT_SECTION(PAGE_SIZE)
23535 -#ifdef CONFIG_X86_64
23536 - :init
23537 -#endif
23538 + . = ALIGN(PAGE_SIZE);
23539 + init_begin = .;
23540 + .init.text (. - __KERNEL_TEXT_OFFSET): AT(init_begin - LOAD_OFFSET) {
23541 + VMLINUX_SYMBOL(_sinittext) = .;
23542 + INIT_TEXT
23543 + VMLINUX_SYMBOL(_einittext) = .;
23544 + . = ALIGN(PAGE_SIZE);
23545 + } :text.init
23546
23547 - INIT_DATA_SECTION(16)
23548 + /*
23549 + * .exit.text is discard at runtime, not link time, to deal with
23550 + * references from .altinstructions and .eh_frame
23551 + */
23552 + .exit.text : AT(ADDR(.exit.text) - LOAD_OFFSET + __KERNEL_TEXT_OFFSET) {
23553 + EXIT_TEXT
23554 + . = ALIGN(16);
23555 + } :text.exit
23556 + . = init_begin + SIZEOF(.init.text) + SIZEOF(.exit.text);
23557 +
23558 + . = ALIGN(PAGE_SIZE);
23559 + INIT_DATA_SECTION(16) :init
23560
23561 .x86_cpu_dev.init : AT(ADDR(.x86_cpu_dev.init) - LOAD_OFFSET) {
23562 __x86_cpu_dev_start = .;
23563 @@ -257,19 +338,12 @@ SECTIONS
23564 }
23565
23566 . = ALIGN(8);
23567 - /*
23568 - * .exit.text is discard at runtime, not link time, to deal with
23569 - * references from .altinstructions and .eh_frame
23570 - */
23571 - .exit.text : AT(ADDR(.exit.text) - LOAD_OFFSET) {
23572 - EXIT_TEXT
23573 - }
23574
23575 .exit.data : AT(ADDR(.exit.data) - LOAD_OFFSET) {
23576 EXIT_DATA
23577 }
23578
23579 -#if !defined(CONFIG_X86_64) || !defined(CONFIG_SMP)
23580 +#ifndef CONFIG_SMP
23581 PERCPU_SECTION(INTERNODE_CACHE_BYTES)
23582 #endif
23583
23584 @@ -288,16 +362,10 @@ SECTIONS
23585 .smp_locks : AT(ADDR(.smp_locks) - LOAD_OFFSET) {
23586 __smp_locks = .;
23587 *(.smp_locks)
23588 - . = ALIGN(PAGE_SIZE);
23589 __smp_locks_end = .;
23590 + . = ALIGN(PAGE_SIZE);
23591 }
23592
23593 -#ifdef CONFIG_X86_64
23594 - .data_nosave : AT(ADDR(.data_nosave) - LOAD_OFFSET) {
23595 - NOSAVE_DATA
23596 - }
23597 -#endif
23598 -
23599 /* BSS */
23600 . = ALIGN(PAGE_SIZE);
23601 .bss : AT(ADDR(.bss) - LOAD_OFFSET) {
23602 @@ -313,6 +381,7 @@ SECTIONS
23603 __brk_base = .;
23604 . += 64 * 1024; /* 64k alignment slop space */
23605 *(.brk_reservation) /* areas brk users have reserved */
23606 + . = ALIGN(HPAGE_SIZE);
23607 __brk_limit = .;
23608 }
23609
23610 @@ -339,13 +408,12 @@ SECTIONS
23611 * for the boot processor.
23612 */
23613 #define INIT_PER_CPU(x) init_per_cpu__##x = x + __per_cpu_load
23614 -INIT_PER_CPU(gdt_page);
23615 INIT_PER_CPU(irq_stack_union);
23616
23617 /*
23618 * Build-time check on the image size:
23619 */
23620 -. = ASSERT((_end - _text <= KERNEL_IMAGE_SIZE),
23621 +. = ASSERT((_end - _text - __KERNEL_TEXT_OFFSET <= KERNEL_IMAGE_SIZE),
23622 "kernel image bigger than KERNEL_IMAGE_SIZE");
23623
23624 #ifdef CONFIG_SMP
23625 diff --git a/arch/x86/kernel/vsyscall_64.c b/arch/x86/kernel/vsyscall_64.c
23626 index 9a907a6..f83f921 100644
23627 --- a/arch/x86/kernel/vsyscall_64.c
23628 +++ b/arch/x86/kernel/vsyscall_64.c
23629 @@ -56,15 +56,13 @@
23630 DEFINE_VVAR(int, vgetcpu_mode);
23631 DEFINE_VVAR(struct vsyscall_gtod_data, vsyscall_gtod_data);
23632
23633 -static enum { EMULATE, NATIVE, NONE } vsyscall_mode = EMULATE;
23634 +static enum { EMULATE, NONE } vsyscall_mode = EMULATE;
23635
23636 static int __init vsyscall_setup(char *str)
23637 {
23638 if (str) {
23639 if (!strcmp("emulate", str))
23640 vsyscall_mode = EMULATE;
23641 - else if (!strcmp("native", str))
23642 - vsyscall_mode = NATIVE;
23643 else if (!strcmp("none", str))
23644 vsyscall_mode = NONE;
23645 else
23646 @@ -323,8 +321,7 @@ do_ret:
23647 return true;
23648
23649 sigsegv:
23650 - force_sig(SIGSEGV, current);
23651 - return true;
23652 + do_group_exit(SIGKILL);
23653 }
23654
23655 /*
23656 @@ -377,10 +374,7 @@ void __init map_vsyscall(void)
23657 extern char __vvar_page;
23658 unsigned long physaddr_vvar_page = __pa_symbol(&__vvar_page);
23659
23660 - __set_fixmap(VSYSCALL_FIRST_PAGE, physaddr_vsyscall,
23661 - vsyscall_mode == NATIVE
23662 - ? PAGE_KERNEL_VSYSCALL
23663 - : PAGE_KERNEL_VVAR);
23664 + __set_fixmap(VSYSCALL_FIRST_PAGE, physaddr_vsyscall, PAGE_KERNEL_VVAR);
23665 BUILD_BUG_ON((unsigned long)__fix_to_virt(VSYSCALL_FIRST_PAGE) !=
23666 (unsigned long)VSYSCALL_START);
23667
23668 diff --git a/arch/x86/kernel/x8664_ksyms_64.c b/arch/x86/kernel/x8664_ksyms_64.c
23669 index 1330dd1..d220b99 100644
23670 --- a/arch/x86/kernel/x8664_ksyms_64.c
23671 +++ b/arch/x86/kernel/x8664_ksyms_64.c
23672 @@ -34,8 +34,6 @@ EXPORT_SYMBOL(copy_user_generic_string);
23673 EXPORT_SYMBOL(copy_user_generic_unrolled);
23674 EXPORT_SYMBOL(copy_user_enhanced_fast_string);
23675 EXPORT_SYMBOL(__copy_user_nocache);
23676 -EXPORT_SYMBOL(_copy_from_user);
23677 -EXPORT_SYMBOL(_copy_to_user);
23678
23679 EXPORT_SYMBOL(copy_page);
23680 EXPORT_SYMBOL(clear_page);
23681 diff --git a/arch/x86/kernel/x86_init.c b/arch/x86/kernel/x86_init.c
23682 index 7a3d075..6cb373d 100644
23683 --- a/arch/x86/kernel/x86_init.c
23684 +++ b/arch/x86/kernel/x86_init.c
23685 @@ -88,7 +88,7 @@ struct x86_init_ops x86_init __initdata = {
23686 },
23687 };
23688
23689 -struct x86_cpuinit_ops x86_cpuinit __cpuinitdata = {
23690 +struct x86_cpuinit_ops x86_cpuinit __cpuinitconst = {
23691 .early_percpu_clock_init = x86_init_noop,
23692 .setup_percpu_clockev = setup_secondary_APIC_clock,
23693 };
23694 @@ -96,7 +96,7 @@ struct x86_cpuinit_ops x86_cpuinit __cpuinitdata = {
23695 static void default_nmi_init(void) { };
23696 static int default_i8042_detect(void) { return 1; };
23697
23698 -struct x86_platform_ops x86_platform = {
23699 +struct x86_platform_ops x86_platform __read_only = {
23700 .calibrate_tsc = native_calibrate_tsc,
23701 .get_wallclock = mach_get_cmos_time,
23702 .set_wallclock = mach_set_rtc_mmss,
23703 @@ -110,14 +110,14 @@ struct x86_platform_ops x86_platform = {
23704 };
23705
23706 EXPORT_SYMBOL_GPL(x86_platform);
23707 -struct x86_msi_ops x86_msi = {
23708 +struct x86_msi_ops x86_msi __read_only = {
23709 .setup_msi_irqs = native_setup_msi_irqs,
23710 .teardown_msi_irq = native_teardown_msi_irq,
23711 .teardown_msi_irqs = default_teardown_msi_irqs,
23712 .restore_msi_irqs = default_restore_msi_irqs,
23713 };
23714
23715 -struct x86_io_apic_ops x86_io_apic_ops = {
23716 +struct x86_io_apic_ops x86_io_apic_ops __read_only = {
23717 .init = native_io_apic_init_mappings,
23718 .read = native_io_apic_read,
23719 .write = native_io_apic_write,
23720 diff --git a/arch/x86/kernel/xsave.c b/arch/x86/kernel/xsave.c
23721 index ada87a3..afea76d 100644
23722 --- a/arch/x86/kernel/xsave.c
23723 +++ b/arch/x86/kernel/xsave.c
23724 @@ -199,6 +199,7 @@ static inline int save_user_xstate(struct xsave_struct __user *buf)
23725 {
23726 int err;
23727
23728 + buf = (struct xsave_struct __user *)____m(buf);
23729 if (use_xsave())
23730 err = xsave_user(buf);
23731 else if (use_fxsr())
23732 @@ -311,6 +312,7 @@ sanitize_restored_xstate(struct task_struct *tsk,
23733 */
23734 static inline int restore_user_xstate(void __user *buf, u64 xbv, int fx_only)
23735 {
23736 + buf = (void __user *)____m(buf);
23737 if (use_xsave()) {
23738 if ((unsigned long)buf % 64 || fx_only) {
23739 u64 init_bv = pcntxt_mask & ~XSTATE_FPSSE;
23740 diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c
23741 index a20ecb5..d0e2194 100644
23742 --- a/arch/x86/kvm/cpuid.c
23743 +++ b/arch/x86/kvm/cpuid.c
23744 @@ -124,15 +124,20 @@ int kvm_vcpu_ioctl_set_cpuid2(struct kvm_vcpu *vcpu,
23745 struct kvm_cpuid2 *cpuid,
23746 struct kvm_cpuid_entry2 __user *entries)
23747 {
23748 - int r;
23749 + int r, i;
23750
23751 r = -E2BIG;
23752 if (cpuid->nent > KVM_MAX_CPUID_ENTRIES)
23753 goto out;
23754 r = -EFAULT;
23755 - if (copy_from_user(&vcpu->arch.cpuid_entries, entries,
23756 - cpuid->nent * sizeof(struct kvm_cpuid_entry2)))
23757 + if (!access_ok(VERIFY_READ, entries, cpuid->nent * sizeof(struct kvm_cpuid_entry2)))
23758 goto out;
23759 + for (i = 0; i < cpuid->nent; ++i) {
23760 + struct kvm_cpuid_entry2 cpuid_entry;
23761 + if (__copy_from_user(&cpuid_entry, entries + i, sizeof(cpuid_entry)))
23762 + goto out;
23763 + vcpu->arch.cpuid_entries[i] = cpuid_entry;
23764 + }
23765 vcpu->arch.cpuid_nent = cpuid->nent;
23766 kvm_apic_set_version(vcpu);
23767 kvm_x86_ops->cpuid_update(vcpu);
23768 @@ -147,15 +152,19 @@ int kvm_vcpu_ioctl_get_cpuid2(struct kvm_vcpu *vcpu,
23769 struct kvm_cpuid2 *cpuid,
23770 struct kvm_cpuid_entry2 __user *entries)
23771 {
23772 - int r;
23773 + int r, i;
23774
23775 r = -E2BIG;
23776 if (cpuid->nent < vcpu->arch.cpuid_nent)
23777 goto out;
23778 r = -EFAULT;
23779 - if (copy_to_user(entries, &vcpu->arch.cpuid_entries,
23780 - vcpu->arch.cpuid_nent * sizeof(struct kvm_cpuid_entry2)))
23781 + if (!access_ok(VERIFY_WRITE, entries, vcpu->arch.cpuid_nent * sizeof(struct kvm_cpuid_entry2)))
23782 goto out;
23783 + for (i = 0; i < vcpu->arch.cpuid_nent; ++i) {
23784 + struct kvm_cpuid_entry2 cpuid_entry = vcpu->arch.cpuid_entries[i];
23785 + if (__copy_to_user(entries + i, &cpuid_entry, sizeof(cpuid_entry)))
23786 + goto out;
23787 + }
23788 return 0;
23789
23790 out:
23791 diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
23792 index a27e763..54bfe43 100644
23793 --- a/arch/x86/kvm/emulate.c
23794 +++ b/arch/x86/kvm/emulate.c
23795 @@ -292,6 +292,7 @@ static void invalidate_registers(struct x86_emulate_ctxt *ctxt)
23796
23797 #define ____emulate_2op(ctxt, _op, _x, _y, _suffix, _dsttype) \
23798 do { \
23799 + unsigned long _tmp; \
23800 __asm__ __volatile__ ( \
23801 _PRE_EFLAGS("0", "4", "2") \
23802 _op _suffix " %"_x"3,%1; " \
23803 @@ -306,8 +307,6 @@ static void invalidate_registers(struct x86_emulate_ctxt *ctxt)
23804 /* Raw emulation: instruction has two explicit operands. */
23805 #define __emulate_2op_nobyte(ctxt,_op,_wx,_wy,_lx,_ly,_qx,_qy) \
23806 do { \
23807 - unsigned long _tmp; \
23808 - \
23809 switch ((ctxt)->dst.bytes) { \
23810 case 2: \
23811 ____emulate_2op(ctxt,_op,_wx,_wy,"w",u16); \
23812 @@ -323,7 +322,6 @@ static void invalidate_registers(struct x86_emulate_ctxt *ctxt)
23813
23814 #define __emulate_2op(ctxt,_op,_bx,_by,_wx,_wy,_lx,_ly,_qx,_qy) \
23815 do { \
23816 - unsigned long _tmp; \
23817 switch ((ctxt)->dst.bytes) { \
23818 case 1: \
23819 ____emulate_2op(ctxt,_op,_bx,_by,"b",u8); \
23820 diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
23821 index 9392f52..0e56d77 100644
23822 --- a/arch/x86/kvm/lapic.c
23823 +++ b/arch/x86/kvm/lapic.c
23824 @@ -55,7 +55,7 @@
23825 #define APIC_BUS_CYCLE_NS 1
23826
23827 /* #define apic_debug(fmt,arg...) printk(KERN_WARNING fmt,##arg) */
23828 -#define apic_debug(fmt, arg...)
23829 +#define apic_debug(fmt, arg...) do {} while (0)
23830
23831 #define APIC_LVT_NUM 6
23832 /* 14 is the version for Xeon and Pentium 8.4.8*/
23833 diff --git a/arch/x86/kvm/paging_tmpl.h b/arch/x86/kvm/paging_tmpl.h
23834 index 891eb6d..e027900 100644
23835 --- a/arch/x86/kvm/paging_tmpl.h
23836 +++ b/arch/x86/kvm/paging_tmpl.h
23837 @@ -208,7 +208,7 @@ retry_walk:
23838 if (unlikely(kvm_is_error_hva(host_addr)))
23839 goto error;
23840
23841 - ptep_user = (pt_element_t __user *)((void *)host_addr + offset);
23842 + ptep_user = (pt_element_t __force_user *)((void *)host_addr + offset);
23843 if (unlikely(__copy_from_user(&pte, ptep_user, sizeof(pte))))
23844 goto error;
23845 walker->ptep_user[walker->level - 1] = ptep_user;
23846 diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
23847 index d29d3cd..ec9d522 100644
23848 --- a/arch/x86/kvm/svm.c
23849 +++ b/arch/x86/kvm/svm.c
23850 @@ -3507,7 +3507,11 @@ static void reload_tss(struct kvm_vcpu *vcpu)
23851 int cpu = raw_smp_processor_id();
23852
23853 struct svm_cpu_data *sd = per_cpu(svm_data, cpu);
23854 +
23855 + pax_open_kernel();
23856 sd->tss_desc->type = 9; /* available 32/64-bit TSS */
23857 + pax_close_kernel();
23858 +
23859 load_TR_desc();
23860 }
23861
23862 @@ -3881,6 +3885,10 @@ static void svm_vcpu_run(struct kvm_vcpu *vcpu)
23863 #endif
23864 #endif
23865
23866 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
23867 + __set_fs(current_thread_info()->addr_limit);
23868 +#endif
23869 +
23870 reload_tss(vcpu);
23871
23872 local_irq_disable();
23873 diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
23874 index 9120ae1..238abc0 100644
23875 --- a/arch/x86/kvm/vmx.c
23876 +++ b/arch/x86/kvm/vmx.c
23877 @@ -1370,7 +1370,11 @@ static void reload_tss(void)
23878 struct desc_struct *descs;
23879
23880 descs = (void *)gdt->address;
23881 +
23882 + pax_open_kernel();
23883 descs[GDT_ENTRY_TSS].type = 9; /* available TSS */
23884 + pax_close_kernel();
23885 +
23886 load_TR_desc();
23887 }
23888
23889 @@ -1594,6 +1598,10 @@ static void vmx_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
23890 vmcs_writel(HOST_TR_BASE, kvm_read_tr_base()); /* 22.2.4 */
23891 vmcs_writel(HOST_GDTR_BASE, gdt->address); /* 22.2.4 */
23892
23893 +#ifdef CONFIG_PAX_PER_CPU_PGD
23894 + vmcs_writel(HOST_CR3, read_cr3()); /* 22.2.3 FIXME: shadow tables */
23895 +#endif
23896 +
23897 rdmsrl(MSR_IA32_SYSENTER_ESP, sysenter_esp);
23898 vmcs_writel(HOST_IA32_SYSENTER_ESP, sysenter_esp); /* 22.2.3 */
23899 vmx->loaded_vmcs->cpu = cpu;
23900 @@ -2738,8 +2746,11 @@ static __init int hardware_setup(void)
23901 if (!cpu_has_vmx_flexpriority())
23902 flexpriority_enabled = 0;
23903
23904 - if (!cpu_has_vmx_tpr_shadow())
23905 - kvm_x86_ops->update_cr8_intercept = NULL;
23906 + if (!cpu_has_vmx_tpr_shadow()) {
23907 + pax_open_kernel();
23908 + *(void **)&kvm_x86_ops->update_cr8_intercept = NULL;
23909 + pax_close_kernel();
23910 + }
23911
23912 if (enable_ept && !cpu_has_vmx_ept_2m_page())
23913 kvm_disable_largepages();
23914 @@ -3782,7 +3793,10 @@ static void vmx_set_constant_host_state(void)
23915
23916 vmcs_writel(HOST_CR0, read_cr0() & ~X86_CR0_TS); /* 22.2.3 */
23917 vmcs_writel(HOST_CR4, read_cr4()); /* 22.2.3, 22.2.5 */
23918 +
23919 +#ifndef CONFIG_PAX_PER_CPU_PGD
23920 vmcs_writel(HOST_CR3, read_cr3()); /* 22.2.3 FIXME: shadow tables */
23921 +#endif
23922
23923 vmcs_write16(HOST_CS_SELECTOR, __KERNEL_CS); /* 22.2.4 */
23924 #ifdef CONFIG_X86_64
23925 @@ -3803,7 +3817,7 @@ static void vmx_set_constant_host_state(void)
23926 native_store_idt(&dt);
23927 vmcs_writel(HOST_IDTR_BASE, dt.address); /* 22.2.4 */
23928
23929 - vmcs_writel(HOST_RIP, vmx_return); /* 22.2.5 */
23930 + vmcs_writel(HOST_RIP, ktla_ktva(vmx_return)); /* 22.2.5 */
23931
23932 rdmsr(MSR_IA32_SYSENTER_CS, low32, high32);
23933 vmcs_write32(HOST_IA32_SYSENTER_CS, low32);
23934 @@ -6355,6 +6369,12 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
23935 "jmp 2f \n\t"
23936 "1: " __ex(ASM_VMX_VMRESUME) "\n\t"
23937 "2: "
23938 +
23939 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
23940 + "ljmp %[cs],$3f\n\t"
23941 + "3: "
23942 +#endif
23943 +
23944 /* Save guest registers, load host registers, keep flags */
23945 "mov %0, %c[wordsize](%%" _ASM_SP ") \n\t"
23946 "pop %0 \n\t"
23947 @@ -6407,6 +6427,11 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
23948 #endif
23949 [cr2]"i"(offsetof(struct vcpu_vmx, vcpu.arch.cr2)),
23950 [wordsize]"i"(sizeof(ulong))
23951 +
23952 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
23953 + ,[cs]"i"(__KERNEL_CS)
23954 +#endif
23955 +
23956 : "cc", "memory"
23957 #ifdef CONFIG_X86_64
23958 , "rax", "rbx", "rdi", "rsi"
23959 @@ -6420,7 +6445,7 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
23960 if (debugctlmsr)
23961 update_debugctlmsr(debugctlmsr);
23962
23963 -#ifndef CONFIG_X86_64
23964 +#ifdef CONFIG_X86_32
23965 /*
23966 * The sysexit path does not restore ds/es, so we must set them to
23967 * a reasonable value ourselves.
23968 @@ -6429,8 +6454,18 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
23969 * may be executed in interrupt context, which saves and restore segments
23970 * around it, nullifying its effect.
23971 */
23972 - loadsegment(ds, __USER_DS);
23973 - loadsegment(es, __USER_DS);
23974 + loadsegment(ds, __KERNEL_DS);
23975 + loadsegment(es, __KERNEL_DS);
23976 + loadsegment(ss, __KERNEL_DS);
23977 +
23978 +#ifdef CONFIG_PAX_KERNEXEC
23979 + loadsegment(fs, __KERNEL_PERCPU);
23980 +#endif
23981 +
23982 +#ifdef CONFIG_PAX_MEMORY_UDEREF
23983 + __set_fs(current_thread_info()->addr_limit);
23984 +#endif
23985 +
23986 #endif
23987
23988 vcpu->arch.regs_avail = ~((1 << VCPU_REGS_RIP) | (1 << VCPU_REGS_RSP)
23989 diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
23990 index c243b81..b692af3 100644
23991 --- a/arch/x86/kvm/x86.c
23992 +++ b/arch/x86/kvm/x86.c
23993 @@ -1408,10 +1408,9 @@ static int kvm_guest_time_update(struct kvm_vcpu *v)
23994 unsigned long flags, this_tsc_khz;
23995 struct kvm_vcpu_arch *vcpu = &v->arch;
23996 struct kvm_arch *ka = &v->kvm->arch;
23997 - void *shared_kaddr;
23998 s64 kernel_ns, max_kernel_ns;
23999 u64 tsc_timestamp, host_tsc;
24000 - struct pvclock_vcpu_time_info *guest_hv_clock;
24001 + struct pvclock_vcpu_time_info guest_hv_clock;
24002 u8 pvclock_flags;
24003 bool use_master_clock;
24004
24005 @@ -1465,7 +1464,7 @@ static int kvm_guest_time_update(struct kvm_vcpu *v)
24006
24007 local_irq_restore(flags);
24008
24009 - if (!vcpu->time_page)
24010 + if (!vcpu->pv_time_enabled)
24011 return 0;
24012
24013 /*
24014 @@ -1527,12 +1526,12 @@ static int kvm_guest_time_update(struct kvm_vcpu *v)
24015 */
24016 vcpu->hv_clock.version += 2;
24017
24018 - shared_kaddr = kmap_atomic(vcpu->time_page);
24019 -
24020 - guest_hv_clock = shared_kaddr + vcpu->time_offset;
24021 + if (unlikely(kvm_read_guest_cached(v->kvm, &vcpu->pv_time,
24022 + &guest_hv_clock, sizeof(guest_hv_clock))))
24023 + return 0;
24024
24025 /* retain PVCLOCK_GUEST_STOPPED if set in guest copy */
24026 - pvclock_flags = (guest_hv_clock->flags & PVCLOCK_GUEST_STOPPED);
24027 + pvclock_flags = (guest_hv_clock.flags & PVCLOCK_GUEST_STOPPED);
24028
24029 if (vcpu->pvclock_set_guest_stopped_request) {
24030 pvclock_flags |= PVCLOCK_GUEST_STOPPED;
24031 @@ -1545,12 +1544,9 @@ static int kvm_guest_time_update(struct kvm_vcpu *v)
24032
24033 vcpu->hv_clock.flags = pvclock_flags;
24034
24035 - memcpy(shared_kaddr + vcpu->time_offset, &vcpu->hv_clock,
24036 - sizeof(vcpu->hv_clock));
24037 -
24038 - kunmap_atomic(shared_kaddr);
24039 -
24040 - mark_page_dirty(v->kvm, vcpu->time >> PAGE_SHIFT);
24041 + kvm_write_guest_cached(v->kvm, &vcpu->pv_time,
24042 + &vcpu->hv_clock,
24043 + sizeof(vcpu->hv_clock));
24044 return 0;
24045 }
24046
24047 @@ -1692,8 +1688,8 @@ static int xen_hvm_config(struct kvm_vcpu *vcpu, u64 data)
24048 {
24049 struct kvm *kvm = vcpu->kvm;
24050 int lm = is_long_mode(vcpu);
24051 - u8 *blob_addr = lm ? (u8 *)(long)kvm->arch.xen_hvm_config.blob_addr_64
24052 - : (u8 *)(long)kvm->arch.xen_hvm_config.blob_addr_32;
24053 + u8 __user *blob_addr = lm ? (u8 __user *)(long)kvm->arch.xen_hvm_config.blob_addr_64
24054 + : (u8 __user *)(long)kvm->arch.xen_hvm_config.blob_addr_32;
24055 u8 blob_size = lm ? kvm->arch.xen_hvm_config.blob_size_64
24056 : kvm->arch.xen_hvm_config.blob_size_32;
24057 u32 page_num = data & ~PAGE_MASK;
24058 @@ -1839,10 +1835,7 @@ static int kvm_pv_enable_async_pf(struct kvm_vcpu *vcpu, u64 data)
24059
24060 static void kvmclock_reset(struct kvm_vcpu *vcpu)
24061 {
24062 - if (vcpu->arch.time_page) {
24063 - kvm_release_page_dirty(vcpu->arch.time_page);
24064 - vcpu->arch.time_page = NULL;
24065 - }
24066 + vcpu->arch.pv_time_enabled = false;
24067 }
24068
24069 static void accumulate_steal_time(struct kvm_vcpu *vcpu)
24070 @@ -1948,6 +1941,7 @@ int kvm_set_msr_common(struct kvm_vcpu *vcpu, struct msr_data *msr_info)
24071 break;
24072 case MSR_KVM_SYSTEM_TIME_NEW:
24073 case MSR_KVM_SYSTEM_TIME: {
24074 + u64 gpa_offset;
24075 kvmclock_reset(vcpu);
24076
24077 vcpu->arch.time = data;
24078 @@ -1957,14 +1951,17 @@ int kvm_set_msr_common(struct kvm_vcpu *vcpu, struct msr_data *msr_info)
24079 if (!(data & 1))
24080 break;
24081
24082 - /* ...but clean it before doing the actual write */
24083 - vcpu->arch.time_offset = data & ~(PAGE_MASK | 1);
24084 + gpa_offset = data & ~(PAGE_MASK | 1);
24085
24086 - vcpu->arch.time_page =
24087 - gfn_to_page(vcpu->kvm, data >> PAGE_SHIFT);
24088 + /* Check that the address is 32-byte aligned. */
24089 + if (gpa_offset & (sizeof(struct pvclock_vcpu_time_info) - 1))
24090 + break;
24091
24092 - if (is_error_page(vcpu->arch.time_page))
24093 - vcpu->arch.time_page = NULL;
24094 + if (kvm_gfn_to_hva_cache_init(vcpu->kvm,
24095 + &vcpu->arch.pv_time, data & ~1ULL))
24096 + vcpu->arch.pv_time_enabled = false;
24097 + else
24098 + vcpu->arch.pv_time_enabled = true;
24099
24100 break;
24101 }
24102 @@ -2571,6 +2568,8 @@ long kvm_arch_dev_ioctl(struct file *filp,
24103 if (n < msr_list.nmsrs)
24104 goto out;
24105 r = -EFAULT;
24106 + if (num_msrs_to_save > ARRAY_SIZE(msrs_to_save))
24107 + goto out;
24108 if (copy_to_user(user_msr_list->indices, &msrs_to_save,
24109 num_msrs_to_save * sizeof(u32)))
24110 goto out;
24111 @@ -2700,7 +2699,7 @@ static int kvm_vcpu_ioctl_set_lapic(struct kvm_vcpu *vcpu,
24112 static int kvm_vcpu_ioctl_interrupt(struct kvm_vcpu *vcpu,
24113 struct kvm_interrupt *irq)
24114 {
24115 - if (irq->irq < 0 || irq->irq >= KVM_NR_INTERRUPTS)
24116 + if (irq->irq >= KVM_NR_INTERRUPTS)
24117 return -EINVAL;
24118 if (irqchip_in_kernel(vcpu->kvm))
24119 return -ENXIO;
24120 @@ -2967,7 +2966,7 @@ static int kvm_vcpu_ioctl_x86_set_xcrs(struct kvm_vcpu *vcpu,
24121 */
24122 static int kvm_set_guest_paused(struct kvm_vcpu *vcpu)
24123 {
24124 - if (!vcpu->arch.time_page)
24125 + if (!vcpu->arch.pv_time_enabled)
24126 return -EINVAL;
24127 vcpu->arch.pvclock_set_guest_stopped_request = true;
24128 kvm_make_request(KVM_REQ_CLOCK_UPDATE, vcpu);
24129 @@ -5213,7 +5212,7 @@ static struct notifier_block pvclock_gtod_notifier = {
24130 };
24131 #endif
24132
24133 -int kvm_arch_init(void *opaque)
24134 +int kvm_arch_init(const void *opaque)
24135 {
24136 int r;
24137 struct kvm_x86_ops *ops = (struct kvm_x86_ops *)opaque;
24138 @@ -6661,6 +6660,7 @@ int kvm_arch_vcpu_init(struct kvm_vcpu *vcpu)
24139 goto fail_free_wbinvd_dirty_mask;
24140
24141 vcpu->arch.ia32_tsc_adjust_msr = 0x0;
24142 + vcpu->arch.pv_time_enabled = false;
24143 kvm_async_pf_hash_reset(vcpu);
24144 kvm_pmu_init(vcpu);
24145
24146 diff --git a/arch/x86/lguest/boot.c b/arch/x86/lguest/boot.c
24147 index df4176c..23ce092 100644
24148 --- a/arch/x86/lguest/boot.c
24149 +++ b/arch/x86/lguest/boot.c
24150 @@ -1200,9 +1200,10 @@ static __init int early_put_chars(u32 vtermno, const char *buf, int count)
24151 * Rebooting also tells the Host we're finished, but the RESTART flag tells the
24152 * Launcher to reboot us.
24153 */
24154 -static void lguest_restart(char *reason)
24155 +static __noreturn void lguest_restart(char *reason)
24156 {
24157 hcall(LHCALL_SHUTDOWN, __pa(reason), LGUEST_SHUTDOWN_RESTART, 0, 0);
24158 + BUG();
24159 }
24160
24161 /*G:050
24162 diff --git a/arch/x86/lib/atomic64_386_32.S b/arch/x86/lib/atomic64_386_32.S
24163 index 00933d5..3a64af9 100644
24164 --- a/arch/x86/lib/atomic64_386_32.S
24165 +++ b/arch/x86/lib/atomic64_386_32.S
24166 @@ -48,6 +48,10 @@ BEGIN(read)
24167 movl (v), %eax
24168 movl 4(v), %edx
24169 RET_ENDP
24170 +BEGIN(read_unchecked)
24171 + movl (v), %eax
24172 + movl 4(v), %edx
24173 +RET_ENDP
24174 #undef v
24175
24176 #define v %esi
24177 @@ -55,6 +59,10 @@ BEGIN(set)
24178 movl %ebx, (v)
24179 movl %ecx, 4(v)
24180 RET_ENDP
24181 +BEGIN(set_unchecked)
24182 + movl %ebx, (v)
24183 + movl %ecx, 4(v)
24184 +RET_ENDP
24185 #undef v
24186
24187 #define v %esi
24188 @@ -70,6 +78,20 @@ RET_ENDP
24189 BEGIN(add)
24190 addl %eax, (v)
24191 adcl %edx, 4(v)
24192 +
24193 +#ifdef CONFIG_PAX_REFCOUNT
24194 + jno 0f
24195 + subl %eax, (v)
24196 + sbbl %edx, 4(v)
24197 + int $4
24198 +0:
24199 + _ASM_EXTABLE(0b, 0b)
24200 +#endif
24201 +
24202 +RET_ENDP
24203 +BEGIN(add_unchecked)
24204 + addl %eax, (v)
24205 + adcl %edx, 4(v)
24206 RET_ENDP
24207 #undef v
24208
24209 @@ -77,6 +99,24 @@ RET_ENDP
24210 BEGIN(add_return)
24211 addl (v), %eax
24212 adcl 4(v), %edx
24213 +
24214 +#ifdef CONFIG_PAX_REFCOUNT
24215 + into
24216 +1234:
24217 + _ASM_EXTABLE(1234b, 2f)
24218 +#endif
24219 +
24220 + movl %eax, (v)
24221 + movl %edx, 4(v)
24222 +
24223 +#ifdef CONFIG_PAX_REFCOUNT
24224 +2:
24225 +#endif
24226 +
24227 +RET_ENDP
24228 +BEGIN(add_return_unchecked)
24229 + addl (v), %eax
24230 + adcl 4(v), %edx
24231 movl %eax, (v)
24232 movl %edx, 4(v)
24233 RET_ENDP
24234 @@ -86,6 +126,20 @@ RET_ENDP
24235 BEGIN(sub)
24236 subl %eax, (v)
24237 sbbl %edx, 4(v)
24238 +
24239 +#ifdef CONFIG_PAX_REFCOUNT
24240 + jno 0f
24241 + addl %eax, (v)
24242 + adcl %edx, 4(v)
24243 + int $4
24244 +0:
24245 + _ASM_EXTABLE(0b, 0b)
24246 +#endif
24247 +
24248 +RET_ENDP
24249 +BEGIN(sub_unchecked)
24250 + subl %eax, (v)
24251 + sbbl %edx, 4(v)
24252 RET_ENDP
24253 #undef v
24254
24255 @@ -96,6 +150,27 @@ BEGIN(sub_return)
24256 sbbl $0, %edx
24257 addl (v), %eax
24258 adcl 4(v), %edx
24259 +
24260 +#ifdef CONFIG_PAX_REFCOUNT
24261 + into
24262 +1234:
24263 + _ASM_EXTABLE(1234b, 2f)
24264 +#endif
24265 +
24266 + movl %eax, (v)
24267 + movl %edx, 4(v)
24268 +
24269 +#ifdef CONFIG_PAX_REFCOUNT
24270 +2:
24271 +#endif
24272 +
24273 +RET_ENDP
24274 +BEGIN(sub_return_unchecked)
24275 + negl %edx
24276 + negl %eax
24277 + sbbl $0, %edx
24278 + addl (v), %eax
24279 + adcl 4(v), %edx
24280 movl %eax, (v)
24281 movl %edx, 4(v)
24282 RET_ENDP
24283 @@ -105,6 +180,20 @@ RET_ENDP
24284 BEGIN(inc)
24285 addl $1, (v)
24286 adcl $0, 4(v)
24287 +
24288 +#ifdef CONFIG_PAX_REFCOUNT
24289 + jno 0f
24290 + subl $1, (v)
24291 + sbbl $0, 4(v)
24292 + int $4
24293 +0:
24294 + _ASM_EXTABLE(0b, 0b)
24295 +#endif
24296 +
24297 +RET_ENDP
24298 +BEGIN(inc_unchecked)
24299 + addl $1, (v)
24300 + adcl $0, 4(v)
24301 RET_ENDP
24302 #undef v
24303
24304 @@ -114,6 +203,26 @@ BEGIN(inc_return)
24305 movl 4(v), %edx
24306 addl $1, %eax
24307 adcl $0, %edx
24308 +
24309 +#ifdef CONFIG_PAX_REFCOUNT
24310 + into
24311 +1234:
24312 + _ASM_EXTABLE(1234b, 2f)
24313 +#endif
24314 +
24315 + movl %eax, (v)
24316 + movl %edx, 4(v)
24317 +
24318 +#ifdef CONFIG_PAX_REFCOUNT
24319 +2:
24320 +#endif
24321 +
24322 +RET_ENDP
24323 +BEGIN(inc_return_unchecked)
24324 + movl (v), %eax
24325 + movl 4(v), %edx
24326 + addl $1, %eax
24327 + adcl $0, %edx
24328 movl %eax, (v)
24329 movl %edx, 4(v)
24330 RET_ENDP
24331 @@ -123,6 +232,20 @@ RET_ENDP
24332 BEGIN(dec)
24333 subl $1, (v)
24334 sbbl $0, 4(v)
24335 +
24336 +#ifdef CONFIG_PAX_REFCOUNT
24337 + jno 0f
24338 + addl $1, (v)
24339 + adcl $0, 4(v)
24340 + int $4
24341 +0:
24342 + _ASM_EXTABLE(0b, 0b)
24343 +#endif
24344 +
24345 +RET_ENDP
24346 +BEGIN(dec_unchecked)
24347 + subl $1, (v)
24348 + sbbl $0, 4(v)
24349 RET_ENDP
24350 #undef v
24351
24352 @@ -132,6 +255,26 @@ BEGIN(dec_return)
24353 movl 4(v), %edx
24354 subl $1, %eax
24355 sbbl $0, %edx
24356 +
24357 +#ifdef CONFIG_PAX_REFCOUNT
24358 + into
24359 +1234:
24360 + _ASM_EXTABLE(1234b, 2f)
24361 +#endif
24362 +
24363 + movl %eax, (v)
24364 + movl %edx, 4(v)
24365 +
24366 +#ifdef CONFIG_PAX_REFCOUNT
24367 +2:
24368 +#endif
24369 +
24370 +RET_ENDP
24371 +BEGIN(dec_return_unchecked)
24372 + movl (v), %eax
24373 + movl 4(v), %edx
24374 + subl $1, %eax
24375 + sbbl $0, %edx
24376 movl %eax, (v)
24377 movl %edx, 4(v)
24378 RET_ENDP
24379 @@ -143,6 +286,13 @@ BEGIN(add_unless)
24380 adcl %edx, %edi
24381 addl (v), %eax
24382 adcl 4(v), %edx
24383 +
24384 +#ifdef CONFIG_PAX_REFCOUNT
24385 + into
24386 +1234:
24387 + _ASM_EXTABLE(1234b, 2f)
24388 +#endif
24389 +
24390 cmpl %eax, %ecx
24391 je 3f
24392 1:
24393 @@ -168,6 +318,13 @@ BEGIN(inc_not_zero)
24394 1:
24395 addl $1, %eax
24396 adcl $0, %edx
24397 +
24398 +#ifdef CONFIG_PAX_REFCOUNT
24399 + into
24400 +1234:
24401 + _ASM_EXTABLE(1234b, 2f)
24402 +#endif
24403 +
24404 movl %eax, (v)
24405 movl %edx, 4(v)
24406 movl $1, %eax
24407 @@ -186,6 +343,13 @@ BEGIN(dec_if_positive)
24408 movl 4(v), %edx
24409 subl $1, %eax
24410 sbbl $0, %edx
24411 +
24412 +#ifdef CONFIG_PAX_REFCOUNT
24413 + into
24414 +1234:
24415 + _ASM_EXTABLE(1234b, 1f)
24416 +#endif
24417 +
24418 js 1f
24419 movl %eax, (v)
24420 movl %edx, 4(v)
24421 diff --git a/arch/x86/lib/atomic64_cx8_32.S b/arch/x86/lib/atomic64_cx8_32.S
24422 index f5cc9eb..51fa319 100644
24423 --- a/arch/x86/lib/atomic64_cx8_32.S
24424 +++ b/arch/x86/lib/atomic64_cx8_32.S
24425 @@ -35,10 +35,20 @@ ENTRY(atomic64_read_cx8)
24426 CFI_STARTPROC
24427
24428 read64 %ecx
24429 + pax_force_retaddr
24430 ret
24431 CFI_ENDPROC
24432 ENDPROC(atomic64_read_cx8)
24433
24434 +ENTRY(atomic64_read_unchecked_cx8)
24435 + CFI_STARTPROC
24436 +
24437 + read64 %ecx
24438 + pax_force_retaddr
24439 + ret
24440 + CFI_ENDPROC
24441 +ENDPROC(atomic64_read_unchecked_cx8)
24442 +
24443 ENTRY(atomic64_set_cx8)
24444 CFI_STARTPROC
24445
24446 @@ -48,10 +58,25 @@ ENTRY(atomic64_set_cx8)
24447 cmpxchg8b (%esi)
24448 jne 1b
24449
24450 + pax_force_retaddr
24451 ret
24452 CFI_ENDPROC
24453 ENDPROC(atomic64_set_cx8)
24454
24455 +ENTRY(atomic64_set_unchecked_cx8)
24456 + CFI_STARTPROC
24457 +
24458 +1:
24459 +/* we don't need LOCK_PREFIX since aligned 64-bit writes
24460 + * are atomic on 586 and newer */
24461 + cmpxchg8b (%esi)
24462 + jne 1b
24463 +
24464 + pax_force_retaddr
24465 + ret
24466 + CFI_ENDPROC
24467 +ENDPROC(atomic64_set_unchecked_cx8)
24468 +
24469 ENTRY(atomic64_xchg_cx8)
24470 CFI_STARTPROC
24471
24472 @@ -60,12 +85,13 @@ ENTRY(atomic64_xchg_cx8)
24473 cmpxchg8b (%esi)
24474 jne 1b
24475
24476 + pax_force_retaddr
24477 ret
24478 CFI_ENDPROC
24479 ENDPROC(atomic64_xchg_cx8)
24480
24481 -.macro addsub_return func ins insc
24482 -ENTRY(atomic64_\func\()_return_cx8)
24483 +.macro addsub_return func ins insc unchecked=""
24484 +ENTRY(atomic64_\func\()_return\unchecked\()_cx8)
24485 CFI_STARTPROC
24486 SAVE ebp
24487 SAVE ebx
24488 @@ -82,27 +108,44 @@ ENTRY(atomic64_\func\()_return_cx8)
24489 movl %edx, %ecx
24490 \ins\()l %esi, %ebx
24491 \insc\()l %edi, %ecx
24492 +
24493 +.ifb \unchecked
24494 +#ifdef CONFIG_PAX_REFCOUNT
24495 + into
24496 +2:
24497 + _ASM_EXTABLE(2b, 3f)
24498 +#endif
24499 +.endif
24500 +
24501 LOCK_PREFIX
24502 cmpxchg8b (%ebp)
24503 jne 1b
24504 -
24505 -10:
24506 movl %ebx, %eax
24507 movl %ecx, %edx
24508 +
24509 +.ifb \unchecked
24510 +#ifdef CONFIG_PAX_REFCOUNT
24511 +3:
24512 +#endif
24513 +.endif
24514 +
24515 RESTORE edi
24516 RESTORE esi
24517 RESTORE ebx
24518 RESTORE ebp
24519 + pax_force_retaddr
24520 ret
24521 CFI_ENDPROC
24522 -ENDPROC(atomic64_\func\()_return_cx8)
24523 +ENDPROC(atomic64_\func\()_return\unchecked\()_cx8)
24524 .endm
24525
24526 addsub_return add add adc
24527 addsub_return sub sub sbb
24528 +addsub_return add add adc _unchecked
24529 +addsub_return sub sub sbb _unchecked
24530
24531 -.macro incdec_return func ins insc
24532 -ENTRY(atomic64_\func\()_return_cx8)
24533 +.macro incdec_return func ins insc unchecked=""
24534 +ENTRY(atomic64_\func\()_return\unchecked\()_cx8)
24535 CFI_STARTPROC
24536 SAVE ebx
24537
24538 @@ -112,21 +155,39 @@ ENTRY(atomic64_\func\()_return_cx8)
24539 movl %edx, %ecx
24540 \ins\()l $1, %ebx
24541 \insc\()l $0, %ecx
24542 +
24543 +.ifb \unchecked
24544 +#ifdef CONFIG_PAX_REFCOUNT
24545 + into
24546 +2:
24547 + _ASM_EXTABLE(2b, 3f)
24548 +#endif
24549 +.endif
24550 +
24551 LOCK_PREFIX
24552 cmpxchg8b (%esi)
24553 jne 1b
24554
24555 -10:
24556 movl %ebx, %eax
24557 movl %ecx, %edx
24558 +
24559 +.ifb \unchecked
24560 +#ifdef CONFIG_PAX_REFCOUNT
24561 +3:
24562 +#endif
24563 +.endif
24564 +
24565 RESTORE ebx
24566 + pax_force_retaddr
24567 ret
24568 CFI_ENDPROC
24569 -ENDPROC(atomic64_\func\()_return_cx8)
24570 +ENDPROC(atomic64_\func\()_return\unchecked\()_cx8)
24571 .endm
24572
24573 incdec_return inc add adc
24574 incdec_return dec sub sbb
24575 +incdec_return inc add adc _unchecked
24576 +incdec_return dec sub sbb _unchecked
24577
24578 ENTRY(atomic64_dec_if_positive_cx8)
24579 CFI_STARTPROC
24580 @@ -138,6 +199,13 @@ ENTRY(atomic64_dec_if_positive_cx8)
24581 movl %edx, %ecx
24582 subl $1, %ebx
24583 sbb $0, %ecx
24584 +
24585 +#ifdef CONFIG_PAX_REFCOUNT
24586 + into
24587 +1234:
24588 + _ASM_EXTABLE(1234b, 2f)
24589 +#endif
24590 +
24591 js 2f
24592 LOCK_PREFIX
24593 cmpxchg8b (%esi)
24594 @@ -147,6 +215,7 @@ ENTRY(atomic64_dec_if_positive_cx8)
24595 movl %ebx, %eax
24596 movl %ecx, %edx
24597 RESTORE ebx
24598 + pax_force_retaddr
24599 ret
24600 CFI_ENDPROC
24601 ENDPROC(atomic64_dec_if_positive_cx8)
24602 @@ -171,6 +240,13 @@ ENTRY(atomic64_add_unless_cx8)
24603 movl %edx, %ecx
24604 addl %ebp, %ebx
24605 adcl %edi, %ecx
24606 +
24607 +#ifdef CONFIG_PAX_REFCOUNT
24608 + into
24609 +1234:
24610 + _ASM_EXTABLE(1234b, 3f)
24611 +#endif
24612 +
24613 LOCK_PREFIX
24614 cmpxchg8b (%esi)
24615 jne 1b
24616 @@ -181,6 +257,7 @@ ENTRY(atomic64_add_unless_cx8)
24617 CFI_ADJUST_CFA_OFFSET -8
24618 RESTORE ebx
24619 RESTORE ebp
24620 + pax_force_retaddr
24621 ret
24622 4:
24623 cmpl %edx, 4(%esp)
24624 @@ -203,6 +280,13 @@ ENTRY(atomic64_inc_not_zero_cx8)
24625 xorl %ecx, %ecx
24626 addl $1, %ebx
24627 adcl %edx, %ecx
24628 +
24629 +#ifdef CONFIG_PAX_REFCOUNT
24630 + into
24631 +1234:
24632 + _ASM_EXTABLE(1234b, 3f)
24633 +#endif
24634 +
24635 LOCK_PREFIX
24636 cmpxchg8b (%esi)
24637 jne 1b
24638 @@ -210,6 +294,7 @@ ENTRY(atomic64_inc_not_zero_cx8)
24639 movl $1, %eax
24640 3:
24641 RESTORE ebx
24642 + pax_force_retaddr
24643 ret
24644 CFI_ENDPROC
24645 ENDPROC(atomic64_inc_not_zero_cx8)
24646 diff --git a/arch/x86/lib/checksum_32.S b/arch/x86/lib/checksum_32.S
24647 index 2af5df3..62b1a5a 100644
24648 --- a/arch/x86/lib/checksum_32.S
24649 +++ b/arch/x86/lib/checksum_32.S
24650 @@ -29,7 +29,8 @@
24651 #include <asm/dwarf2.h>
24652 #include <asm/errno.h>
24653 #include <asm/asm.h>
24654 -
24655 +#include <asm/segment.h>
24656 +
24657 /*
24658 * computes a partial checksum, e.g. for TCP/UDP fragments
24659 */
24660 @@ -293,9 +294,24 @@ unsigned int csum_partial_copy_generic (const char *src, char *dst,
24661
24662 #define ARGBASE 16
24663 #define FP 12
24664 -
24665 -ENTRY(csum_partial_copy_generic)
24666 +
24667 +ENTRY(csum_partial_copy_generic_to_user)
24668 CFI_STARTPROC
24669 +
24670 +#ifdef CONFIG_PAX_MEMORY_UDEREF
24671 + pushl_cfi %gs
24672 + popl_cfi %es
24673 + jmp csum_partial_copy_generic
24674 +#endif
24675 +
24676 +ENTRY(csum_partial_copy_generic_from_user)
24677 +
24678 +#ifdef CONFIG_PAX_MEMORY_UDEREF
24679 + pushl_cfi %gs
24680 + popl_cfi %ds
24681 +#endif
24682 +
24683 +ENTRY(csum_partial_copy_generic)
24684 subl $4,%esp
24685 CFI_ADJUST_CFA_OFFSET 4
24686 pushl_cfi %edi
24687 @@ -317,7 +333,7 @@ ENTRY(csum_partial_copy_generic)
24688 jmp 4f
24689 SRC(1: movw (%esi), %bx )
24690 addl $2, %esi
24691 -DST( movw %bx, (%edi) )
24692 +DST( movw %bx, %es:(%edi) )
24693 addl $2, %edi
24694 addw %bx, %ax
24695 adcl $0, %eax
24696 @@ -329,30 +345,30 @@ DST( movw %bx, (%edi) )
24697 SRC(1: movl (%esi), %ebx )
24698 SRC( movl 4(%esi), %edx )
24699 adcl %ebx, %eax
24700 -DST( movl %ebx, (%edi) )
24701 +DST( movl %ebx, %es:(%edi) )
24702 adcl %edx, %eax
24703 -DST( movl %edx, 4(%edi) )
24704 +DST( movl %edx, %es:4(%edi) )
24705
24706 SRC( movl 8(%esi), %ebx )
24707 SRC( movl 12(%esi), %edx )
24708 adcl %ebx, %eax
24709 -DST( movl %ebx, 8(%edi) )
24710 +DST( movl %ebx, %es:8(%edi) )
24711 adcl %edx, %eax
24712 -DST( movl %edx, 12(%edi) )
24713 +DST( movl %edx, %es:12(%edi) )
24714
24715 SRC( movl 16(%esi), %ebx )
24716 SRC( movl 20(%esi), %edx )
24717 adcl %ebx, %eax
24718 -DST( movl %ebx, 16(%edi) )
24719 +DST( movl %ebx, %es:16(%edi) )
24720 adcl %edx, %eax
24721 -DST( movl %edx, 20(%edi) )
24722 +DST( movl %edx, %es:20(%edi) )
24723
24724 SRC( movl 24(%esi), %ebx )
24725 SRC( movl 28(%esi), %edx )
24726 adcl %ebx, %eax
24727 -DST( movl %ebx, 24(%edi) )
24728 +DST( movl %ebx, %es:24(%edi) )
24729 adcl %edx, %eax
24730 -DST( movl %edx, 28(%edi) )
24731 +DST( movl %edx, %es:28(%edi) )
24732
24733 lea 32(%esi), %esi
24734 lea 32(%edi), %edi
24735 @@ -366,7 +382,7 @@ DST( movl %edx, 28(%edi) )
24736 shrl $2, %edx # This clears CF
24737 SRC(3: movl (%esi), %ebx )
24738 adcl %ebx, %eax
24739 -DST( movl %ebx, (%edi) )
24740 +DST( movl %ebx, %es:(%edi) )
24741 lea 4(%esi), %esi
24742 lea 4(%edi), %edi
24743 dec %edx
24744 @@ -378,12 +394,12 @@ DST( movl %ebx, (%edi) )
24745 jb 5f
24746 SRC( movw (%esi), %cx )
24747 leal 2(%esi), %esi
24748 -DST( movw %cx, (%edi) )
24749 +DST( movw %cx, %es:(%edi) )
24750 leal 2(%edi), %edi
24751 je 6f
24752 shll $16,%ecx
24753 SRC(5: movb (%esi), %cl )
24754 -DST( movb %cl, (%edi) )
24755 +DST( movb %cl, %es:(%edi) )
24756 6: addl %ecx, %eax
24757 adcl $0, %eax
24758 7:
24759 @@ -394,7 +410,7 @@ DST( movb %cl, (%edi) )
24760
24761 6001:
24762 movl ARGBASE+20(%esp), %ebx # src_err_ptr
24763 - movl $-EFAULT, (%ebx)
24764 + movl $-EFAULT, %ss:(%ebx)
24765
24766 # zero the complete destination - computing the rest
24767 # is too much work
24768 @@ -407,11 +423,15 @@ DST( movb %cl, (%edi) )
24769
24770 6002:
24771 movl ARGBASE+24(%esp), %ebx # dst_err_ptr
24772 - movl $-EFAULT,(%ebx)
24773 + movl $-EFAULT,%ss:(%ebx)
24774 jmp 5000b
24775
24776 .previous
24777
24778 + pushl_cfi %ss
24779 + popl_cfi %ds
24780 + pushl_cfi %ss
24781 + popl_cfi %es
24782 popl_cfi %ebx
24783 CFI_RESTORE ebx
24784 popl_cfi %esi
24785 @@ -421,26 +441,43 @@ DST( movb %cl, (%edi) )
24786 popl_cfi %ecx # equivalent to addl $4,%esp
24787 ret
24788 CFI_ENDPROC
24789 -ENDPROC(csum_partial_copy_generic)
24790 +ENDPROC(csum_partial_copy_generic_to_user)
24791
24792 #else
24793
24794 /* Version for PentiumII/PPro */
24795
24796 #define ROUND1(x) \
24797 + nop; nop; nop; \
24798 SRC(movl x(%esi), %ebx ) ; \
24799 addl %ebx, %eax ; \
24800 - DST(movl %ebx, x(%edi) ) ;
24801 + DST(movl %ebx, %es:x(%edi)) ;
24802
24803 #define ROUND(x) \
24804 + nop; nop; nop; \
24805 SRC(movl x(%esi), %ebx ) ; \
24806 adcl %ebx, %eax ; \
24807 - DST(movl %ebx, x(%edi) ) ;
24808 + DST(movl %ebx, %es:x(%edi)) ;
24809
24810 #define ARGBASE 12
24811 -
24812 -ENTRY(csum_partial_copy_generic)
24813 +
24814 +ENTRY(csum_partial_copy_generic_to_user)
24815 CFI_STARTPROC
24816 +
24817 +#ifdef CONFIG_PAX_MEMORY_UDEREF
24818 + pushl_cfi %gs
24819 + popl_cfi %es
24820 + jmp csum_partial_copy_generic
24821 +#endif
24822 +
24823 +ENTRY(csum_partial_copy_generic_from_user)
24824 +
24825 +#ifdef CONFIG_PAX_MEMORY_UDEREF
24826 + pushl_cfi %gs
24827 + popl_cfi %ds
24828 +#endif
24829 +
24830 +ENTRY(csum_partial_copy_generic)
24831 pushl_cfi %ebx
24832 CFI_REL_OFFSET ebx, 0
24833 pushl_cfi %edi
24834 @@ -461,7 +498,7 @@ ENTRY(csum_partial_copy_generic)
24835 subl %ebx, %edi
24836 lea -1(%esi),%edx
24837 andl $-32,%edx
24838 - lea 3f(%ebx,%ebx), %ebx
24839 + lea 3f(%ebx,%ebx,2), %ebx
24840 testl %esi, %esi
24841 jmp *%ebx
24842 1: addl $64,%esi
24843 @@ -482,19 +519,19 @@ ENTRY(csum_partial_copy_generic)
24844 jb 5f
24845 SRC( movw (%esi), %dx )
24846 leal 2(%esi), %esi
24847 -DST( movw %dx, (%edi) )
24848 +DST( movw %dx, %es:(%edi) )
24849 leal 2(%edi), %edi
24850 je 6f
24851 shll $16,%edx
24852 5:
24853 SRC( movb (%esi), %dl )
24854 -DST( movb %dl, (%edi) )
24855 +DST( movb %dl, %es:(%edi) )
24856 6: addl %edx, %eax
24857 adcl $0, %eax
24858 7:
24859 .section .fixup, "ax"
24860 6001: movl ARGBASE+20(%esp), %ebx # src_err_ptr
24861 - movl $-EFAULT, (%ebx)
24862 + movl $-EFAULT, %ss:(%ebx)
24863 # zero the complete destination (computing the rest is too much work)
24864 movl ARGBASE+8(%esp),%edi # dst
24865 movl ARGBASE+12(%esp),%ecx # len
24866 @@ -502,10 +539,17 @@ DST( movb %dl, (%edi) )
24867 rep; stosb
24868 jmp 7b
24869 6002: movl ARGBASE+24(%esp), %ebx # dst_err_ptr
24870 - movl $-EFAULT, (%ebx)
24871 + movl $-EFAULT, %ss:(%ebx)
24872 jmp 7b
24873 .previous
24874
24875 +#ifdef CONFIG_PAX_MEMORY_UDEREF
24876 + pushl_cfi %ss
24877 + popl_cfi %ds
24878 + pushl_cfi %ss
24879 + popl_cfi %es
24880 +#endif
24881 +
24882 popl_cfi %esi
24883 CFI_RESTORE esi
24884 popl_cfi %edi
24885 @@ -514,7 +558,7 @@ DST( movb %dl, (%edi) )
24886 CFI_RESTORE ebx
24887 ret
24888 CFI_ENDPROC
24889 -ENDPROC(csum_partial_copy_generic)
24890 +ENDPROC(csum_partial_copy_generic_to_user)
24891
24892 #undef ROUND
24893 #undef ROUND1
24894 diff --git a/arch/x86/lib/clear_page_64.S b/arch/x86/lib/clear_page_64.S
24895 index f2145cf..cea889d 100644
24896 --- a/arch/x86/lib/clear_page_64.S
24897 +++ b/arch/x86/lib/clear_page_64.S
24898 @@ -11,6 +11,7 @@ ENTRY(clear_page_c)
24899 movl $4096/8,%ecx
24900 xorl %eax,%eax
24901 rep stosq
24902 + pax_force_retaddr
24903 ret
24904 CFI_ENDPROC
24905 ENDPROC(clear_page_c)
24906 @@ -20,6 +21,7 @@ ENTRY(clear_page_c_e)
24907 movl $4096,%ecx
24908 xorl %eax,%eax
24909 rep stosb
24910 + pax_force_retaddr
24911 ret
24912 CFI_ENDPROC
24913 ENDPROC(clear_page_c_e)
24914 @@ -43,6 +45,7 @@ ENTRY(clear_page)
24915 leaq 64(%rdi),%rdi
24916 jnz .Lloop
24917 nop
24918 + pax_force_retaddr
24919 ret
24920 CFI_ENDPROC
24921 .Lclear_page_end:
24922 @@ -58,7 +61,7 @@ ENDPROC(clear_page)
24923
24924 #include <asm/cpufeature.h>
24925
24926 - .section .altinstr_replacement,"ax"
24927 + .section .altinstr_replacement,"a"
24928 1: .byte 0xeb /* jmp <disp8> */
24929 .byte (clear_page_c - clear_page) - (2f - 1b) /* offset */
24930 2: .byte 0xeb /* jmp <disp8> */
24931 diff --git a/arch/x86/lib/cmpxchg16b_emu.S b/arch/x86/lib/cmpxchg16b_emu.S
24932 index 1e572c5..2a162cd 100644
24933 --- a/arch/x86/lib/cmpxchg16b_emu.S
24934 +++ b/arch/x86/lib/cmpxchg16b_emu.S
24935 @@ -53,11 +53,13 @@ this_cpu_cmpxchg16b_emu:
24936
24937 popf
24938 mov $1, %al
24939 + pax_force_retaddr
24940 ret
24941
24942 not_same:
24943 popf
24944 xor %al,%al
24945 + pax_force_retaddr
24946 ret
24947
24948 CFI_ENDPROC
24949 diff --git a/arch/x86/lib/copy_page_64.S b/arch/x86/lib/copy_page_64.S
24950 index 176cca6..1166c50 100644
24951 --- a/arch/x86/lib/copy_page_64.S
24952 +++ b/arch/x86/lib/copy_page_64.S
24953 @@ -9,6 +9,7 @@ copy_page_rep:
24954 CFI_STARTPROC
24955 movl $4096/8, %ecx
24956 rep movsq
24957 + pax_force_retaddr
24958 ret
24959 CFI_ENDPROC
24960 ENDPROC(copy_page_rep)
24961 @@ -20,12 +21,14 @@ ENDPROC(copy_page_rep)
24962
24963 ENTRY(copy_page)
24964 CFI_STARTPROC
24965 - subq $2*8, %rsp
24966 - CFI_ADJUST_CFA_OFFSET 2*8
24967 + subq $3*8, %rsp
24968 + CFI_ADJUST_CFA_OFFSET 3*8
24969 movq %rbx, (%rsp)
24970 CFI_REL_OFFSET rbx, 0
24971 movq %r12, 1*8(%rsp)
24972 CFI_REL_OFFSET r12, 1*8
24973 + movq %r13, 2*8(%rsp)
24974 + CFI_REL_OFFSET r13, 2*8
24975
24976 movl $(4096/64)-5, %ecx
24977 .p2align 4
24978 @@ -36,7 +39,7 @@ ENTRY(copy_page)
24979 movq 0x8*2(%rsi), %rdx
24980 movq 0x8*3(%rsi), %r8
24981 movq 0x8*4(%rsi), %r9
24982 - movq 0x8*5(%rsi), %r10
24983 + movq 0x8*5(%rsi), %r13
24984 movq 0x8*6(%rsi), %r11
24985 movq 0x8*7(%rsi), %r12
24986
24987 @@ -47,7 +50,7 @@ ENTRY(copy_page)
24988 movq %rdx, 0x8*2(%rdi)
24989 movq %r8, 0x8*3(%rdi)
24990 movq %r9, 0x8*4(%rdi)
24991 - movq %r10, 0x8*5(%rdi)
24992 + movq %r13, 0x8*5(%rdi)
24993 movq %r11, 0x8*6(%rdi)
24994 movq %r12, 0x8*7(%rdi)
24995
24996 @@ -66,7 +69,7 @@ ENTRY(copy_page)
24997 movq 0x8*2(%rsi), %rdx
24998 movq 0x8*3(%rsi), %r8
24999 movq 0x8*4(%rsi), %r9
25000 - movq 0x8*5(%rsi), %r10
25001 + movq 0x8*5(%rsi), %r13
25002 movq 0x8*6(%rsi), %r11
25003 movq 0x8*7(%rsi), %r12
25004
25005 @@ -75,7 +78,7 @@ ENTRY(copy_page)
25006 movq %rdx, 0x8*2(%rdi)
25007 movq %r8, 0x8*3(%rdi)
25008 movq %r9, 0x8*4(%rdi)
25009 - movq %r10, 0x8*5(%rdi)
25010 + movq %r13, 0x8*5(%rdi)
25011 movq %r11, 0x8*6(%rdi)
25012 movq %r12, 0x8*7(%rdi)
25013
25014 @@ -87,8 +90,11 @@ ENTRY(copy_page)
25015 CFI_RESTORE rbx
25016 movq 1*8(%rsp), %r12
25017 CFI_RESTORE r12
25018 - addq $2*8, %rsp
25019 - CFI_ADJUST_CFA_OFFSET -2*8
25020 + movq 2*8(%rsp), %r13
25021 + CFI_RESTORE r13
25022 + addq $3*8, %rsp
25023 + CFI_ADJUST_CFA_OFFSET -3*8
25024 + pax_force_retaddr
25025 ret
25026 .Lcopy_page_end:
25027 CFI_ENDPROC
25028 @@ -99,7 +105,7 @@ ENDPROC(copy_page)
25029
25030 #include <asm/cpufeature.h>
25031
25032 - .section .altinstr_replacement,"ax"
25033 + .section .altinstr_replacement,"a"
25034 1: .byte 0xeb /* jmp <disp8> */
25035 .byte (copy_page_rep - copy_page) - (2f - 1b) /* offset */
25036 2:
25037 diff --git a/arch/x86/lib/copy_user_64.S b/arch/x86/lib/copy_user_64.S
25038 index a30ca15..d25fab6 100644
25039 --- a/arch/x86/lib/copy_user_64.S
25040 +++ b/arch/x86/lib/copy_user_64.S
25041 @@ -18,6 +18,7 @@
25042 #include <asm/alternative-asm.h>
25043 #include <asm/asm.h>
25044 #include <asm/smap.h>
25045 +#include <asm/pgtable.h>
25046
25047 /*
25048 * By placing feature2 after feature1 in altinstructions section, we logically
25049 @@ -31,7 +32,7 @@
25050 .byte 0xe9 /* 32bit jump */
25051 .long \orig-1f /* by default jump to orig */
25052 1:
25053 - .section .altinstr_replacement,"ax"
25054 + .section .altinstr_replacement,"a"
25055 2: .byte 0xe9 /* near jump with 32bit immediate */
25056 .long \alt1-1b /* offset */ /* or alternatively to alt1 */
25057 3: .byte 0xe9 /* near jump with 32bit immediate */
25058 @@ -70,47 +71,20 @@
25059 #endif
25060 .endm
25061
25062 -/* Standard copy_to_user with segment limit checking */
25063 -ENTRY(_copy_to_user)
25064 - CFI_STARTPROC
25065 - GET_THREAD_INFO(%rax)
25066 - movq %rdi,%rcx
25067 - addq %rdx,%rcx
25068 - jc bad_to_user
25069 - cmpq TI_addr_limit(%rax),%rcx
25070 - ja bad_to_user
25071 - ALTERNATIVE_JUMP X86_FEATURE_REP_GOOD,X86_FEATURE_ERMS, \
25072 - copy_user_generic_unrolled,copy_user_generic_string, \
25073 - copy_user_enhanced_fast_string
25074 - CFI_ENDPROC
25075 -ENDPROC(_copy_to_user)
25076 -
25077 -/* Standard copy_from_user with segment limit checking */
25078 -ENTRY(_copy_from_user)
25079 - CFI_STARTPROC
25080 - GET_THREAD_INFO(%rax)
25081 - movq %rsi,%rcx
25082 - addq %rdx,%rcx
25083 - jc bad_from_user
25084 - cmpq TI_addr_limit(%rax),%rcx
25085 - ja bad_from_user
25086 - ALTERNATIVE_JUMP X86_FEATURE_REP_GOOD,X86_FEATURE_ERMS, \
25087 - copy_user_generic_unrolled,copy_user_generic_string, \
25088 - copy_user_enhanced_fast_string
25089 - CFI_ENDPROC
25090 -ENDPROC(_copy_from_user)
25091 -
25092 .section .fixup,"ax"
25093 /* must zero dest */
25094 ENTRY(bad_from_user)
25095 bad_from_user:
25096 CFI_STARTPROC
25097 + testl %edx,%edx
25098 + js bad_to_user
25099 movl %edx,%ecx
25100 xorl %eax,%eax
25101 rep
25102 stosb
25103 bad_to_user:
25104 movl %edx,%eax
25105 + pax_force_retaddr
25106 ret
25107 CFI_ENDPROC
25108 ENDPROC(bad_from_user)
25109 @@ -141,19 +115,19 @@ ENTRY(copy_user_generic_unrolled)
25110 jz 17f
25111 1: movq (%rsi),%r8
25112 2: movq 1*8(%rsi),%r9
25113 -3: movq 2*8(%rsi),%r10
25114 +3: movq 2*8(%rsi),%rax
25115 4: movq 3*8(%rsi),%r11
25116 5: movq %r8,(%rdi)
25117 6: movq %r9,1*8(%rdi)
25118 -7: movq %r10,2*8(%rdi)
25119 +7: movq %rax,2*8(%rdi)
25120 8: movq %r11,3*8(%rdi)
25121 9: movq 4*8(%rsi),%r8
25122 10: movq 5*8(%rsi),%r9
25123 -11: movq 6*8(%rsi),%r10
25124 +11: movq 6*8(%rsi),%rax
25125 12: movq 7*8(%rsi),%r11
25126 13: movq %r8,4*8(%rdi)
25127 14: movq %r9,5*8(%rdi)
25128 -15: movq %r10,6*8(%rdi)
25129 +15: movq %rax,6*8(%rdi)
25130 16: movq %r11,7*8(%rdi)
25131 leaq 64(%rsi),%rsi
25132 leaq 64(%rdi),%rdi
25133 @@ -180,6 +154,7 @@ ENTRY(copy_user_generic_unrolled)
25134 jnz 21b
25135 23: xor %eax,%eax
25136 ASM_CLAC
25137 + pax_force_retaddr
25138 ret
25139
25140 .section .fixup,"ax"
25141 @@ -251,6 +226,7 @@ ENTRY(copy_user_generic_string)
25142 movsb
25143 4: xorl %eax,%eax
25144 ASM_CLAC
25145 + pax_force_retaddr
25146 ret
25147
25148 .section .fixup,"ax"
25149 @@ -286,6 +262,7 @@ ENTRY(copy_user_enhanced_fast_string)
25150 movsb
25151 2: xorl %eax,%eax
25152 ASM_CLAC
25153 + pax_force_retaddr
25154 ret
25155
25156 .section .fixup,"ax"
25157 diff --git a/arch/x86/lib/copy_user_nocache_64.S b/arch/x86/lib/copy_user_nocache_64.S
25158 index 6a4f43c..f5f9e26 100644
25159 --- a/arch/x86/lib/copy_user_nocache_64.S
25160 +++ b/arch/x86/lib/copy_user_nocache_64.S
25161 @@ -8,6 +8,7 @@
25162
25163 #include <linux/linkage.h>
25164 #include <asm/dwarf2.h>
25165 +#include <asm/alternative-asm.h>
25166
25167 #define FIX_ALIGNMENT 1
25168
25169 @@ -16,6 +17,7 @@
25170 #include <asm/thread_info.h>
25171 #include <asm/asm.h>
25172 #include <asm/smap.h>
25173 +#include <asm/pgtable.h>
25174
25175 .macro ALIGN_DESTINATION
25176 #ifdef FIX_ALIGNMENT
25177 @@ -49,6 +51,15 @@
25178 */
25179 ENTRY(__copy_user_nocache)
25180 CFI_STARTPROC
25181 +
25182 +#ifdef CONFIG_PAX_MEMORY_UDEREF
25183 + mov $PAX_USER_SHADOW_BASE,%rcx
25184 + cmp %rcx,%rsi
25185 + jae 1f
25186 + add %rcx,%rsi
25187 +1:
25188 +#endif
25189 +
25190 ASM_STAC
25191 cmpl $8,%edx
25192 jb 20f /* less then 8 bytes, go to byte copy loop */
25193 @@ -59,19 +70,19 @@ ENTRY(__copy_user_nocache)
25194 jz 17f
25195 1: movq (%rsi),%r8
25196 2: movq 1*8(%rsi),%r9
25197 -3: movq 2*8(%rsi),%r10
25198 +3: movq 2*8(%rsi),%rax
25199 4: movq 3*8(%rsi),%r11
25200 5: movnti %r8,(%rdi)
25201 6: movnti %r9,1*8(%rdi)
25202 -7: movnti %r10,2*8(%rdi)
25203 +7: movnti %rax,2*8(%rdi)
25204 8: movnti %r11,3*8(%rdi)
25205 9: movq 4*8(%rsi),%r8
25206 10: movq 5*8(%rsi),%r9
25207 -11: movq 6*8(%rsi),%r10
25208 +11: movq 6*8(%rsi),%rax
25209 12: movq 7*8(%rsi),%r11
25210 13: movnti %r8,4*8(%rdi)
25211 14: movnti %r9,5*8(%rdi)
25212 -15: movnti %r10,6*8(%rdi)
25213 +15: movnti %rax,6*8(%rdi)
25214 16: movnti %r11,7*8(%rdi)
25215 leaq 64(%rsi),%rsi
25216 leaq 64(%rdi),%rdi
25217 @@ -99,6 +110,7 @@ ENTRY(__copy_user_nocache)
25218 23: xorl %eax,%eax
25219 ASM_CLAC
25220 sfence
25221 + pax_force_retaddr
25222 ret
25223
25224 .section .fixup,"ax"
25225 diff --git a/arch/x86/lib/csum-copy_64.S b/arch/x86/lib/csum-copy_64.S
25226 index 2419d5f..953ee51 100644
25227 --- a/arch/x86/lib/csum-copy_64.S
25228 +++ b/arch/x86/lib/csum-copy_64.S
25229 @@ -9,6 +9,7 @@
25230 #include <asm/dwarf2.h>
25231 #include <asm/errno.h>
25232 #include <asm/asm.h>
25233 +#include <asm/alternative-asm.h>
25234
25235 /*
25236 * Checksum copy with exception handling.
25237 @@ -220,6 +221,7 @@ ENTRY(csum_partial_copy_generic)
25238 CFI_RESTORE rbp
25239 addq $7*8, %rsp
25240 CFI_ADJUST_CFA_OFFSET -7*8
25241 + pax_force_retaddr 0, 1
25242 ret
25243 CFI_RESTORE_STATE
25244
25245 diff --git a/arch/x86/lib/csum-wrappers_64.c b/arch/x86/lib/csum-wrappers_64.c
25246 index 25b7ae8..169fafc 100644
25247 --- a/arch/x86/lib/csum-wrappers_64.c
25248 +++ b/arch/x86/lib/csum-wrappers_64.c
25249 @@ -52,7 +52,7 @@ csum_partial_copy_from_user(const void __user *src, void *dst,
25250 len -= 2;
25251 }
25252 }
25253 - isum = csum_partial_copy_generic((__force const void *)src,
25254 + isum = csum_partial_copy_generic((const void __force_kernel *)____m(src),
25255 dst, len, isum, errp, NULL);
25256 if (unlikely(*errp))
25257 goto out_err;
25258 @@ -105,7 +105,7 @@ csum_partial_copy_to_user(const void *src, void __user *dst,
25259 }
25260
25261 *errp = 0;
25262 - return csum_partial_copy_generic(src, (void __force *)dst,
25263 + return csum_partial_copy_generic(src, (void __force_kernel *)____m(dst),
25264 len, isum, NULL, errp);
25265 }
25266 EXPORT_SYMBOL(csum_partial_copy_to_user);
25267 diff --git a/arch/x86/lib/getuser.S b/arch/x86/lib/getuser.S
25268 index 156b9c8..b144132 100644
25269 --- a/arch/x86/lib/getuser.S
25270 +++ b/arch/x86/lib/getuser.S
25271 @@ -34,17 +34,40 @@
25272 #include <asm/thread_info.h>
25273 #include <asm/asm.h>
25274 #include <asm/smap.h>
25275 +#include <asm/segment.h>
25276 +#include <asm/pgtable.h>
25277 +#include <asm/alternative-asm.h>
25278 +
25279 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
25280 +#define __copyuser_seg gs;
25281 +#else
25282 +#define __copyuser_seg
25283 +#endif
25284
25285 .text
25286 ENTRY(__get_user_1)
25287 CFI_STARTPROC
25288 +
25289 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
25290 GET_THREAD_INFO(%_ASM_DX)
25291 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
25292 jae bad_get_user
25293 ASM_STAC
25294 -1: movzb (%_ASM_AX),%edx
25295 +
25296 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
25297 + mov $PAX_USER_SHADOW_BASE,%_ASM_DX
25298 + cmp %_ASM_DX,%_ASM_AX
25299 + jae 1234f
25300 + add %_ASM_DX,%_ASM_AX
25301 +1234:
25302 +#endif
25303 +
25304 +#endif
25305 +
25306 +1: __copyuser_seg movzb (%_ASM_AX),%edx
25307 xor %eax,%eax
25308 ASM_CLAC
25309 + pax_force_retaddr
25310 ret
25311 CFI_ENDPROC
25312 ENDPROC(__get_user_1)
25313 @@ -52,14 +75,28 @@ ENDPROC(__get_user_1)
25314 ENTRY(__get_user_2)
25315 CFI_STARTPROC
25316 add $1,%_ASM_AX
25317 +
25318 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
25319 jc bad_get_user
25320 GET_THREAD_INFO(%_ASM_DX)
25321 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
25322 jae bad_get_user
25323 ASM_STAC
25324 -2: movzwl -1(%_ASM_AX),%edx
25325 +
25326 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
25327 + mov $PAX_USER_SHADOW_BASE,%_ASM_DX
25328 + cmp %_ASM_DX,%_ASM_AX
25329 + jae 1234f
25330 + add %_ASM_DX,%_ASM_AX
25331 +1234:
25332 +#endif
25333 +
25334 +#endif
25335 +
25336 +2: __copyuser_seg movzwl -1(%_ASM_AX),%edx
25337 xor %eax,%eax
25338 ASM_CLAC
25339 + pax_force_retaddr
25340 ret
25341 CFI_ENDPROC
25342 ENDPROC(__get_user_2)
25343 @@ -67,14 +104,28 @@ ENDPROC(__get_user_2)
25344 ENTRY(__get_user_4)
25345 CFI_STARTPROC
25346 add $3,%_ASM_AX
25347 +
25348 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
25349 jc bad_get_user
25350 GET_THREAD_INFO(%_ASM_DX)
25351 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
25352 jae bad_get_user
25353 ASM_STAC
25354 -3: mov -3(%_ASM_AX),%edx
25355 +
25356 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
25357 + mov $PAX_USER_SHADOW_BASE,%_ASM_DX
25358 + cmp %_ASM_DX,%_ASM_AX
25359 + jae 1234f
25360 + add %_ASM_DX,%_ASM_AX
25361 +1234:
25362 +#endif
25363 +
25364 +#endif
25365 +
25366 +3: __copyuser_seg mov -3(%_ASM_AX),%edx
25367 xor %eax,%eax
25368 ASM_CLAC
25369 + pax_force_retaddr
25370 ret
25371 CFI_ENDPROC
25372 ENDPROC(__get_user_4)
25373 @@ -87,10 +138,20 @@ ENTRY(__get_user_8)
25374 GET_THREAD_INFO(%_ASM_DX)
25375 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
25376 jae bad_get_user
25377 +
25378 +#ifdef CONFIG_PAX_MEMORY_UDEREF
25379 + mov $PAX_USER_SHADOW_BASE,%_ASM_DX
25380 + cmp %_ASM_DX,%_ASM_AX
25381 + jae 1234f
25382 + add %_ASM_DX,%_ASM_AX
25383 +1234:
25384 +#endif
25385 +
25386 ASM_STAC
25387 4: movq -7(%_ASM_AX),%_ASM_DX
25388 xor %eax,%eax
25389 ASM_CLAC
25390 + pax_force_retaddr
25391 ret
25392 CFI_ENDPROC
25393 ENDPROC(__get_user_8)
25394 @@ -101,6 +162,7 @@ bad_get_user:
25395 xor %edx,%edx
25396 mov $(-EFAULT),%_ASM_AX
25397 ASM_CLAC
25398 + pax_force_retaddr
25399 ret
25400 CFI_ENDPROC
25401 END(bad_get_user)
25402 diff --git a/arch/x86/lib/insn.c b/arch/x86/lib/insn.c
25403 index 54fcffe..7be149e 100644
25404 --- a/arch/x86/lib/insn.c
25405 +++ b/arch/x86/lib/insn.c
25406 @@ -20,8 +20,10 @@
25407
25408 #ifdef __KERNEL__
25409 #include <linux/string.h>
25410 +#include <asm/pgtable_types.h>
25411 #else
25412 #include <string.h>
25413 +#define ktla_ktva(addr) addr
25414 #endif
25415 #include <asm/inat.h>
25416 #include <asm/insn.h>
25417 @@ -53,8 +55,8 @@
25418 void insn_init(struct insn *insn, const void *kaddr, int x86_64)
25419 {
25420 memset(insn, 0, sizeof(*insn));
25421 - insn->kaddr = kaddr;
25422 - insn->next_byte = kaddr;
25423 + insn->kaddr = ktla_ktva(kaddr);
25424 + insn->next_byte = ktla_ktva(kaddr);
25425 insn->x86_64 = x86_64 ? 1 : 0;
25426 insn->opnd_bytes = 4;
25427 if (x86_64)
25428 diff --git a/arch/x86/lib/iomap_copy_64.S b/arch/x86/lib/iomap_copy_64.S
25429 index 05a95e7..326f2fa 100644
25430 --- a/arch/x86/lib/iomap_copy_64.S
25431 +++ b/arch/x86/lib/iomap_copy_64.S
25432 @@ -17,6 +17,7 @@
25433
25434 #include <linux/linkage.h>
25435 #include <asm/dwarf2.h>
25436 +#include <asm/alternative-asm.h>
25437
25438 /*
25439 * override generic version in lib/iomap_copy.c
25440 @@ -25,6 +26,7 @@ ENTRY(__iowrite32_copy)
25441 CFI_STARTPROC
25442 movl %edx,%ecx
25443 rep movsd
25444 + pax_force_retaddr
25445 ret
25446 CFI_ENDPROC
25447 ENDPROC(__iowrite32_copy)
25448 diff --git a/arch/x86/lib/memcpy_64.S b/arch/x86/lib/memcpy_64.S
25449 index 1c273be..da9cc0e 100644
25450 --- a/arch/x86/lib/memcpy_64.S
25451 +++ b/arch/x86/lib/memcpy_64.S
25452 @@ -33,6 +33,7 @@
25453 rep movsq
25454 movl %edx, %ecx
25455 rep movsb
25456 + pax_force_retaddr
25457 ret
25458 .Lmemcpy_e:
25459 .previous
25460 @@ -49,6 +50,7 @@
25461 movq %rdi, %rax
25462 movq %rdx, %rcx
25463 rep movsb
25464 + pax_force_retaddr
25465 ret
25466 .Lmemcpy_e_e:
25467 .previous
25468 @@ -76,13 +78,13 @@ ENTRY(memcpy)
25469 */
25470 movq 0*8(%rsi), %r8
25471 movq 1*8(%rsi), %r9
25472 - movq 2*8(%rsi), %r10
25473 + movq 2*8(%rsi), %rcx
25474 movq 3*8(%rsi), %r11
25475 leaq 4*8(%rsi), %rsi
25476
25477 movq %r8, 0*8(%rdi)
25478 movq %r9, 1*8(%rdi)
25479 - movq %r10, 2*8(%rdi)
25480 + movq %rcx, 2*8(%rdi)
25481 movq %r11, 3*8(%rdi)
25482 leaq 4*8(%rdi), %rdi
25483 jae .Lcopy_forward_loop
25484 @@ -105,12 +107,12 @@ ENTRY(memcpy)
25485 subq $0x20, %rdx
25486 movq -1*8(%rsi), %r8
25487 movq -2*8(%rsi), %r9
25488 - movq -3*8(%rsi), %r10
25489 + movq -3*8(%rsi), %rcx
25490 movq -4*8(%rsi), %r11
25491 leaq -4*8(%rsi), %rsi
25492 movq %r8, -1*8(%rdi)
25493 movq %r9, -2*8(%rdi)
25494 - movq %r10, -3*8(%rdi)
25495 + movq %rcx, -3*8(%rdi)
25496 movq %r11, -4*8(%rdi)
25497 leaq -4*8(%rdi), %rdi
25498 jae .Lcopy_backward_loop
25499 @@ -130,12 +132,13 @@ ENTRY(memcpy)
25500 */
25501 movq 0*8(%rsi), %r8
25502 movq 1*8(%rsi), %r9
25503 - movq -2*8(%rsi, %rdx), %r10
25504 + movq -2*8(%rsi, %rdx), %rcx
25505 movq -1*8(%rsi, %rdx), %r11
25506 movq %r8, 0*8(%rdi)
25507 movq %r9, 1*8(%rdi)
25508 - movq %r10, -2*8(%rdi, %rdx)
25509 + movq %rcx, -2*8(%rdi, %rdx)
25510 movq %r11, -1*8(%rdi, %rdx)
25511 + pax_force_retaddr
25512 retq
25513 .p2align 4
25514 .Lless_16bytes:
25515 @@ -148,6 +151,7 @@ ENTRY(memcpy)
25516 movq -1*8(%rsi, %rdx), %r9
25517 movq %r8, 0*8(%rdi)
25518 movq %r9, -1*8(%rdi, %rdx)
25519 + pax_force_retaddr
25520 retq
25521 .p2align 4
25522 .Lless_8bytes:
25523 @@ -161,6 +165,7 @@ ENTRY(memcpy)
25524 movl -4(%rsi, %rdx), %r8d
25525 movl %ecx, (%rdi)
25526 movl %r8d, -4(%rdi, %rdx)
25527 + pax_force_retaddr
25528 retq
25529 .p2align 4
25530 .Lless_3bytes:
25531 @@ -179,6 +184,7 @@ ENTRY(memcpy)
25532 movb %cl, (%rdi)
25533
25534 .Lend:
25535 + pax_force_retaddr
25536 retq
25537 CFI_ENDPROC
25538 ENDPROC(memcpy)
25539 diff --git a/arch/x86/lib/memmove_64.S b/arch/x86/lib/memmove_64.S
25540 index ee16461..c39c199 100644
25541 --- a/arch/x86/lib/memmove_64.S
25542 +++ b/arch/x86/lib/memmove_64.S
25543 @@ -61,13 +61,13 @@ ENTRY(memmove)
25544 5:
25545 sub $0x20, %rdx
25546 movq 0*8(%rsi), %r11
25547 - movq 1*8(%rsi), %r10
25548 + movq 1*8(%rsi), %rcx
25549 movq 2*8(%rsi), %r9
25550 movq 3*8(%rsi), %r8
25551 leaq 4*8(%rsi), %rsi
25552
25553 movq %r11, 0*8(%rdi)
25554 - movq %r10, 1*8(%rdi)
25555 + movq %rcx, 1*8(%rdi)
25556 movq %r9, 2*8(%rdi)
25557 movq %r8, 3*8(%rdi)
25558 leaq 4*8(%rdi), %rdi
25559 @@ -81,10 +81,10 @@ ENTRY(memmove)
25560 4:
25561 movq %rdx, %rcx
25562 movq -8(%rsi, %rdx), %r11
25563 - lea -8(%rdi, %rdx), %r10
25564 + lea -8(%rdi, %rdx), %r9
25565 shrq $3, %rcx
25566 rep movsq
25567 - movq %r11, (%r10)
25568 + movq %r11, (%r9)
25569 jmp 13f
25570 .Lmemmove_end_forward:
25571
25572 @@ -95,14 +95,14 @@ ENTRY(memmove)
25573 7:
25574 movq %rdx, %rcx
25575 movq (%rsi), %r11
25576 - movq %rdi, %r10
25577 + movq %rdi, %r9
25578 leaq -8(%rsi, %rdx), %rsi
25579 leaq -8(%rdi, %rdx), %rdi
25580 shrq $3, %rcx
25581 std
25582 rep movsq
25583 cld
25584 - movq %r11, (%r10)
25585 + movq %r11, (%r9)
25586 jmp 13f
25587
25588 /*
25589 @@ -127,13 +127,13 @@ ENTRY(memmove)
25590 8:
25591 subq $0x20, %rdx
25592 movq -1*8(%rsi), %r11
25593 - movq -2*8(%rsi), %r10
25594 + movq -2*8(%rsi), %rcx
25595 movq -3*8(%rsi), %r9
25596 movq -4*8(%rsi), %r8
25597 leaq -4*8(%rsi), %rsi
25598
25599 movq %r11, -1*8(%rdi)
25600 - movq %r10, -2*8(%rdi)
25601 + movq %rcx, -2*8(%rdi)
25602 movq %r9, -3*8(%rdi)
25603 movq %r8, -4*8(%rdi)
25604 leaq -4*8(%rdi), %rdi
25605 @@ -151,11 +151,11 @@ ENTRY(memmove)
25606 * Move data from 16 bytes to 31 bytes.
25607 */
25608 movq 0*8(%rsi), %r11
25609 - movq 1*8(%rsi), %r10
25610 + movq 1*8(%rsi), %rcx
25611 movq -2*8(%rsi, %rdx), %r9
25612 movq -1*8(%rsi, %rdx), %r8
25613 movq %r11, 0*8(%rdi)
25614 - movq %r10, 1*8(%rdi)
25615 + movq %rcx, 1*8(%rdi)
25616 movq %r9, -2*8(%rdi, %rdx)
25617 movq %r8, -1*8(%rdi, %rdx)
25618 jmp 13f
25619 @@ -167,9 +167,9 @@ ENTRY(memmove)
25620 * Move data from 8 bytes to 15 bytes.
25621 */
25622 movq 0*8(%rsi), %r11
25623 - movq -1*8(%rsi, %rdx), %r10
25624 + movq -1*8(%rsi, %rdx), %r9
25625 movq %r11, 0*8(%rdi)
25626 - movq %r10, -1*8(%rdi, %rdx)
25627 + movq %r9, -1*8(%rdi, %rdx)
25628 jmp 13f
25629 10:
25630 cmpq $4, %rdx
25631 @@ -178,9 +178,9 @@ ENTRY(memmove)
25632 * Move data from 4 bytes to 7 bytes.
25633 */
25634 movl (%rsi), %r11d
25635 - movl -4(%rsi, %rdx), %r10d
25636 + movl -4(%rsi, %rdx), %r9d
25637 movl %r11d, (%rdi)
25638 - movl %r10d, -4(%rdi, %rdx)
25639 + movl %r9d, -4(%rdi, %rdx)
25640 jmp 13f
25641 11:
25642 cmp $2, %rdx
25643 @@ -189,9 +189,9 @@ ENTRY(memmove)
25644 * Move data from 2 bytes to 3 bytes.
25645 */
25646 movw (%rsi), %r11w
25647 - movw -2(%rsi, %rdx), %r10w
25648 + movw -2(%rsi, %rdx), %r9w
25649 movw %r11w, (%rdi)
25650 - movw %r10w, -2(%rdi, %rdx)
25651 + movw %r9w, -2(%rdi, %rdx)
25652 jmp 13f
25653 12:
25654 cmp $1, %rdx
25655 @@ -202,6 +202,7 @@ ENTRY(memmove)
25656 movb (%rsi), %r11b
25657 movb %r11b, (%rdi)
25658 13:
25659 + pax_force_retaddr
25660 retq
25661 CFI_ENDPROC
25662
25663 @@ -210,6 +211,7 @@ ENTRY(memmove)
25664 /* Forward moving data. */
25665 movq %rdx, %rcx
25666 rep movsb
25667 + pax_force_retaddr
25668 retq
25669 .Lmemmove_end_forward_efs:
25670 .previous
25671 diff --git a/arch/x86/lib/memset_64.S b/arch/x86/lib/memset_64.S
25672 index 2dcb380..963660a 100644
25673 --- a/arch/x86/lib/memset_64.S
25674 +++ b/arch/x86/lib/memset_64.S
25675 @@ -30,6 +30,7 @@
25676 movl %edx,%ecx
25677 rep stosb
25678 movq %r9,%rax
25679 + pax_force_retaddr
25680 ret
25681 .Lmemset_e:
25682 .previous
25683 @@ -52,6 +53,7 @@
25684 movq %rdx,%rcx
25685 rep stosb
25686 movq %r9,%rax
25687 + pax_force_retaddr
25688 ret
25689 .Lmemset_e_e:
25690 .previous
25691 @@ -59,7 +61,7 @@
25692 ENTRY(memset)
25693 ENTRY(__memset)
25694 CFI_STARTPROC
25695 - movq %rdi,%r10
25696 + movq %rdi,%r11
25697
25698 /* expand byte value */
25699 movzbl %sil,%ecx
25700 @@ -117,7 +119,8 @@ ENTRY(__memset)
25701 jnz .Lloop_1
25702
25703 .Lende:
25704 - movq %r10,%rax
25705 + movq %r11,%rax
25706 + pax_force_retaddr
25707 ret
25708
25709 CFI_RESTORE_STATE
25710 diff --git a/arch/x86/lib/mmx_32.c b/arch/x86/lib/mmx_32.c
25711 index c9f2d9b..e7fd2c0 100644
25712 --- a/arch/x86/lib/mmx_32.c
25713 +++ b/arch/x86/lib/mmx_32.c
25714 @@ -29,6 +29,7 @@ void *_mmx_memcpy(void *to, const void *from, size_t len)
25715 {
25716 void *p;
25717 int i;
25718 + unsigned long cr0;
25719
25720 if (unlikely(in_interrupt()))
25721 return __memcpy(to, from, len);
25722 @@ -39,44 +40,72 @@ void *_mmx_memcpy(void *to, const void *from, size_t len)
25723 kernel_fpu_begin();
25724
25725 __asm__ __volatile__ (
25726 - "1: prefetch (%0)\n" /* This set is 28 bytes */
25727 - " prefetch 64(%0)\n"
25728 - " prefetch 128(%0)\n"
25729 - " prefetch 192(%0)\n"
25730 - " prefetch 256(%0)\n"
25731 + "1: prefetch (%1)\n" /* This set is 28 bytes */
25732 + " prefetch 64(%1)\n"
25733 + " prefetch 128(%1)\n"
25734 + " prefetch 192(%1)\n"
25735 + " prefetch 256(%1)\n"
25736 "2: \n"
25737 ".section .fixup, \"ax\"\n"
25738 - "3: movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
25739 + "3: \n"
25740 +
25741 +#ifdef CONFIG_PAX_KERNEXEC
25742 + " movl %%cr0, %0\n"
25743 + " movl %0, %%eax\n"
25744 + " andl $0xFFFEFFFF, %%eax\n"
25745 + " movl %%eax, %%cr0\n"
25746 +#endif
25747 +
25748 + " movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
25749 +
25750 +#ifdef CONFIG_PAX_KERNEXEC
25751 + " movl %0, %%cr0\n"
25752 +#endif
25753 +
25754 " jmp 2b\n"
25755 ".previous\n"
25756 _ASM_EXTABLE(1b, 3b)
25757 - : : "r" (from));
25758 + : "=&r" (cr0) : "r" (from) : "ax");
25759
25760 for ( ; i > 5; i--) {
25761 __asm__ __volatile__ (
25762 - "1: prefetch 320(%0)\n"
25763 - "2: movq (%0), %%mm0\n"
25764 - " movq 8(%0), %%mm1\n"
25765 - " movq 16(%0), %%mm2\n"
25766 - " movq 24(%0), %%mm3\n"
25767 - " movq %%mm0, (%1)\n"
25768 - " movq %%mm1, 8(%1)\n"
25769 - " movq %%mm2, 16(%1)\n"
25770 - " movq %%mm3, 24(%1)\n"
25771 - " movq 32(%0), %%mm0\n"
25772 - " movq 40(%0), %%mm1\n"
25773 - " movq 48(%0), %%mm2\n"
25774 - " movq 56(%0), %%mm3\n"
25775 - " movq %%mm0, 32(%1)\n"
25776 - " movq %%mm1, 40(%1)\n"
25777 - " movq %%mm2, 48(%1)\n"
25778 - " movq %%mm3, 56(%1)\n"
25779 + "1: prefetch 320(%1)\n"
25780 + "2: movq (%1), %%mm0\n"
25781 + " movq 8(%1), %%mm1\n"
25782 + " movq 16(%1), %%mm2\n"
25783 + " movq 24(%1), %%mm3\n"
25784 + " movq %%mm0, (%2)\n"
25785 + " movq %%mm1, 8(%2)\n"
25786 + " movq %%mm2, 16(%2)\n"
25787 + " movq %%mm3, 24(%2)\n"
25788 + " movq 32(%1), %%mm0\n"
25789 + " movq 40(%1), %%mm1\n"
25790 + " movq 48(%1), %%mm2\n"
25791 + " movq 56(%1), %%mm3\n"
25792 + " movq %%mm0, 32(%2)\n"
25793 + " movq %%mm1, 40(%2)\n"
25794 + " movq %%mm2, 48(%2)\n"
25795 + " movq %%mm3, 56(%2)\n"
25796 ".section .fixup, \"ax\"\n"
25797 - "3: movw $0x05EB, 1b\n" /* jmp on 5 bytes */
25798 + "3:\n"
25799 +
25800 +#ifdef CONFIG_PAX_KERNEXEC
25801 + " movl %%cr0, %0\n"
25802 + " movl %0, %%eax\n"
25803 + " andl $0xFFFEFFFF, %%eax\n"
25804 + " movl %%eax, %%cr0\n"
25805 +#endif
25806 +
25807 + " movw $0x05EB, 1b\n" /* jmp on 5 bytes */
25808 +
25809 +#ifdef CONFIG_PAX_KERNEXEC
25810 + " movl %0, %%cr0\n"
25811 +#endif
25812 +
25813 " jmp 2b\n"
25814 ".previous\n"
25815 _ASM_EXTABLE(1b, 3b)
25816 - : : "r" (from), "r" (to) : "memory");
25817 + : "=&r" (cr0) : "r" (from), "r" (to) : "memory", "ax");
25818
25819 from += 64;
25820 to += 64;
25821 @@ -158,6 +187,7 @@ static void fast_clear_page(void *page)
25822 static void fast_copy_page(void *to, void *from)
25823 {
25824 int i;
25825 + unsigned long cr0;
25826
25827 kernel_fpu_begin();
25828
25829 @@ -166,42 +196,70 @@ static void fast_copy_page(void *to, void *from)
25830 * but that is for later. -AV
25831 */
25832 __asm__ __volatile__(
25833 - "1: prefetch (%0)\n"
25834 - " prefetch 64(%0)\n"
25835 - " prefetch 128(%0)\n"
25836 - " prefetch 192(%0)\n"
25837 - " prefetch 256(%0)\n"
25838 + "1: prefetch (%1)\n"
25839 + " prefetch 64(%1)\n"
25840 + " prefetch 128(%1)\n"
25841 + " prefetch 192(%1)\n"
25842 + " prefetch 256(%1)\n"
25843 "2: \n"
25844 ".section .fixup, \"ax\"\n"
25845 - "3: movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
25846 + "3: \n"
25847 +
25848 +#ifdef CONFIG_PAX_KERNEXEC
25849 + " movl %%cr0, %0\n"
25850 + " movl %0, %%eax\n"
25851 + " andl $0xFFFEFFFF, %%eax\n"
25852 + " movl %%eax, %%cr0\n"
25853 +#endif
25854 +
25855 + " movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
25856 +
25857 +#ifdef CONFIG_PAX_KERNEXEC
25858 + " movl %0, %%cr0\n"
25859 +#endif
25860 +
25861 " jmp 2b\n"
25862 ".previous\n"
25863 - _ASM_EXTABLE(1b, 3b) : : "r" (from));
25864 + _ASM_EXTABLE(1b, 3b) : "=&r" (cr0) : "r" (from) : "ax");
25865
25866 for (i = 0; i < (4096-320)/64; i++) {
25867 __asm__ __volatile__ (
25868 - "1: prefetch 320(%0)\n"
25869 - "2: movq (%0), %%mm0\n"
25870 - " movntq %%mm0, (%1)\n"
25871 - " movq 8(%0), %%mm1\n"
25872 - " movntq %%mm1, 8(%1)\n"
25873 - " movq 16(%0), %%mm2\n"
25874 - " movntq %%mm2, 16(%1)\n"
25875 - " movq 24(%0), %%mm3\n"
25876 - " movntq %%mm3, 24(%1)\n"
25877 - " movq 32(%0), %%mm4\n"
25878 - " movntq %%mm4, 32(%1)\n"
25879 - " movq 40(%0), %%mm5\n"
25880 - " movntq %%mm5, 40(%1)\n"
25881 - " movq 48(%0), %%mm6\n"
25882 - " movntq %%mm6, 48(%1)\n"
25883 - " movq 56(%0), %%mm7\n"
25884 - " movntq %%mm7, 56(%1)\n"
25885 + "1: prefetch 320(%1)\n"
25886 + "2: movq (%1), %%mm0\n"
25887 + " movntq %%mm0, (%2)\n"
25888 + " movq 8(%1), %%mm1\n"
25889 + " movntq %%mm1, 8(%2)\n"
25890 + " movq 16(%1), %%mm2\n"
25891 + " movntq %%mm2, 16(%2)\n"
25892 + " movq 24(%1), %%mm3\n"
25893 + " movntq %%mm3, 24(%2)\n"
25894 + " movq 32(%1), %%mm4\n"
25895 + " movntq %%mm4, 32(%2)\n"
25896 + " movq 40(%1), %%mm5\n"
25897 + " movntq %%mm5, 40(%2)\n"
25898 + " movq 48(%1), %%mm6\n"
25899 + " movntq %%mm6, 48(%2)\n"
25900 + " movq 56(%1), %%mm7\n"
25901 + " movntq %%mm7, 56(%2)\n"
25902 ".section .fixup, \"ax\"\n"
25903 - "3: movw $0x05EB, 1b\n" /* jmp on 5 bytes */
25904 + "3:\n"
25905 +
25906 +#ifdef CONFIG_PAX_KERNEXEC
25907 + " movl %%cr0, %0\n"
25908 + " movl %0, %%eax\n"
25909 + " andl $0xFFFEFFFF, %%eax\n"
25910 + " movl %%eax, %%cr0\n"
25911 +#endif
25912 +
25913 + " movw $0x05EB, 1b\n" /* jmp on 5 bytes */
25914 +
25915 +#ifdef CONFIG_PAX_KERNEXEC
25916 + " movl %0, %%cr0\n"
25917 +#endif
25918 +
25919 " jmp 2b\n"
25920 ".previous\n"
25921 - _ASM_EXTABLE(1b, 3b) : : "r" (from), "r" (to) : "memory");
25922 + _ASM_EXTABLE(1b, 3b) : "=&r" (cr0) : "r" (from), "r" (to) : "memory", "ax");
25923
25924 from += 64;
25925 to += 64;
25926 @@ -280,47 +338,76 @@ static void fast_clear_page(void *page)
25927 static void fast_copy_page(void *to, void *from)
25928 {
25929 int i;
25930 + unsigned long cr0;
25931
25932 kernel_fpu_begin();
25933
25934 __asm__ __volatile__ (
25935 - "1: prefetch (%0)\n"
25936 - " prefetch 64(%0)\n"
25937 - " prefetch 128(%0)\n"
25938 - " prefetch 192(%0)\n"
25939 - " prefetch 256(%0)\n"
25940 + "1: prefetch (%1)\n"
25941 + " prefetch 64(%1)\n"
25942 + " prefetch 128(%1)\n"
25943 + " prefetch 192(%1)\n"
25944 + " prefetch 256(%1)\n"
25945 "2: \n"
25946 ".section .fixup, \"ax\"\n"
25947 - "3: movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
25948 + "3: \n"
25949 +
25950 +#ifdef CONFIG_PAX_KERNEXEC
25951 + " movl %%cr0, %0\n"
25952 + " movl %0, %%eax\n"
25953 + " andl $0xFFFEFFFF, %%eax\n"
25954 + " movl %%eax, %%cr0\n"
25955 +#endif
25956 +
25957 + " movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
25958 +
25959 +#ifdef CONFIG_PAX_KERNEXEC
25960 + " movl %0, %%cr0\n"
25961 +#endif
25962 +
25963 " jmp 2b\n"
25964 ".previous\n"
25965 - _ASM_EXTABLE(1b, 3b) : : "r" (from));
25966 + _ASM_EXTABLE(1b, 3b) : "=&r" (cr0) : "r" (from) : "ax");
25967
25968 for (i = 0; i < 4096/64; i++) {
25969 __asm__ __volatile__ (
25970 - "1: prefetch 320(%0)\n"
25971 - "2: movq (%0), %%mm0\n"
25972 - " movq 8(%0), %%mm1\n"
25973 - " movq 16(%0), %%mm2\n"
25974 - " movq 24(%0), %%mm3\n"
25975 - " movq %%mm0, (%1)\n"
25976 - " movq %%mm1, 8(%1)\n"
25977 - " movq %%mm2, 16(%1)\n"
25978 - " movq %%mm3, 24(%1)\n"
25979 - " movq 32(%0), %%mm0\n"
25980 - " movq 40(%0), %%mm1\n"
25981 - " movq 48(%0), %%mm2\n"
25982 - " movq 56(%0), %%mm3\n"
25983 - " movq %%mm0, 32(%1)\n"
25984 - " movq %%mm1, 40(%1)\n"
25985 - " movq %%mm2, 48(%1)\n"
25986 - " movq %%mm3, 56(%1)\n"
25987 + "1: prefetch 320(%1)\n"
25988 + "2: movq (%1), %%mm0\n"
25989 + " movq 8(%1), %%mm1\n"
25990 + " movq 16(%1), %%mm2\n"
25991 + " movq 24(%1), %%mm3\n"
25992 + " movq %%mm0, (%2)\n"
25993 + " movq %%mm1, 8(%2)\n"
25994 + " movq %%mm2, 16(%2)\n"
25995 + " movq %%mm3, 24(%2)\n"
25996 + " movq 32(%1), %%mm0\n"
25997 + " movq 40(%1), %%mm1\n"
25998 + " movq 48(%1), %%mm2\n"
25999 + " movq 56(%1), %%mm3\n"
26000 + " movq %%mm0, 32(%2)\n"
26001 + " movq %%mm1, 40(%2)\n"
26002 + " movq %%mm2, 48(%2)\n"
26003 + " movq %%mm3, 56(%2)\n"
26004 ".section .fixup, \"ax\"\n"
26005 - "3: movw $0x05EB, 1b\n" /* jmp on 5 bytes */
26006 + "3:\n"
26007 +
26008 +#ifdef CONFIG_PAX_KERNEXEC
26009 + " movl %%cr0, %0\n"
26010 + " movl %0, %%eax\n"
26011 + " andl $0xFFFEFFFF, %%eax\n"
26012 + " movl %%eax, %%cr0\n"
26013 +#endif
26014 +
26015 + " movw $0x05EB, 1b\n" /* jmp on 5 bytes */
26016 +
26017 +#ifdef CONFIG_PAX_KERNEXEC
26018 + " movl %0, %%cr0\n"
26019 +#endif
26020 +
26021 " jmp 2b\n"
26022 ".previous\n"
26023 _ASM_EXTABLE(1b, 3b)
26024 - : : "r" (from), "r" (to) : "memory");
26025 + : "=&r" (cr0) : "r" (from), "r" (to) : "memory", "ax");
26026
26027 from += 64;
26028 to += 64;
26029 diff --git a/arch/x86/lib/msr-reg.S b/arch/x86/lib/msr-reg.S
26030 index f6d13ee..aca5f0b 100644
26031 --- a/arch/x86/lib/msr-reg.S
26032 +++ b/arch/x86/lib/msr-reg.S
26033 @@ -3,6 +3,7 @@
26034 #include <asm/dwarf2.h>
26035 #include <asm/asm.h>
26036 #include <asm/msr.h>
26037 +#include <asm/alternative-asm.h>
26038
26039 #ifdef CONFIG_X86_64
26040 /*
26041 @@ -16,7 +17,7 @@ ENTRY(\op\()_safe_regs)
26042 CFI_STARTPROC
26043 pushq_cfi %rbx
26044 pushq_cfi %rbp
26045 - movq %rdi, %r10 /* Save pointer */
26046 + movq %rdi, %r9 /* Save pointer */
26047 xorl %r11d, %r11d /* Return value */
26048 movl (%rdi), %eax
26049 movl 4(%rdi), %ecx
26050 @@ -27,16 +28,17 @@ ENTRY(\op\()_safe_regs)
26051 movl 28(%rdi), %edi
26052 CFI_REMEMBER_STATE
26053 1: \op
26054 -2: movl %eax, (%r10)
26055 +2: movl %eax, (%r9)
26056 movl %r11d, %eax /* Return value */
26057 - movl %ecx, 4(%r10)
26058 - movl %edx, 8(%r10)
26059 - movl %ebx, 12(%r10)
26060 - movl %ebp, 20(%r10)
26061 - movl %esi, 24(%r10)
26062 - movl %edi, 28(%r10)
26063 + movl %ecx, 4(%r9)
26064 + movl %edx, 8(%r9)
26065 + movl %ebx, 12(%r9)
26066 + movl %ebp, 20(%r9)
26067 + movl %esi, 24(%r9)
26068 + movl %edi, 28(%r9)
26069 popq_cfi %rbp
26070 popq_cfi %rbx
26071 + pax_force_retaddr
26072 ret
26073 3:
26074 CFI_RESTORE_STATE
26075 diff --git a/arch/x86/lib/putuser.S b/arch/x86/lib/putuser.S
26076 index fc6ba17..04471c5 100644
26077 --- a/arch/x86/lib/putuser.S
26078 +++ b/arch/x86/lib/putuser.S
26079 @@ -16,7 +16,9 @@
26080 #include <asm/errno.h>
26081 #include <asm/asm.h>
26082 #include <asm/smap.h>
26083 -
26084 +#include <asm/segment.h>
26085 +#include <asm/pgtable.h>
26086 +#include <asm/alternative-asm.h>
26087
26088 /*
26089 * __put_user_X
26090 @@ -30,57 +32,125 @@
26091 * as they get called from within inline assembly.
26092 */
26093
26094 -#define ENTER CFI_STARTPROC ; \
26095 - GET_THREAD_INFO(%_ASM_BX)
26096 -#define EXIT ASM_CLAC ; \
26097 - ret ; \
26098 +#define ENTER CFI_STARTPROC
26099 +#define EXIT ASM_CLAC ; \
26100 + pax_force_retaddr ; \
26101 + ret ; \
26102 CFI_ENDPROC
26103
26104 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
26105 +#define _DEST %_ASM_CX,%_ASM_BX
26106 +#else
26107 +#define _DEST %_ASM_CX
26108 +#endif
26109 +
26110 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
26111 +#define __copyuser_seg gs;
26112 +#else
26113 +#define __copyuser_seg
26114 +#endif
26115 +
26116 .text
26117 ENTRY(__put_user_1)
26118 ENTER
26119 +
26120 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
26121 + GET_THREAD_INFO(%_ASM_BX)
26122 cmp TI_addr_limit(%_ASM_BX),%_ASM_CX
26123 jae bad_put_user
26124 ASM_STAC
26125 -1: movb %al,(%_ASM_CX)
26126 +
26127 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
26128 + mov $PAX_USER_SHADOW_BASE,%_ASM_BX
26129 + cmp %_ASM_BX,%_ASM_CX
26130 + jb 1234f
26131 + xor %ebx,%ebx
26132 +1234:
26133 +#endif
26134 +
26135 +#endif
26136 +
26137 +1: __copyuser_seg movb %al,(_DEST)
26138 xor %eax,%eax
26139 EXIT
26140 ENDPROC(__put_user_1)
26141
26142 ENTRY(__put_user_2)
26143 ENTER
26144 +
26145 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
26146 + GET_THREAD_INFO(%_ASM_BX)
26147 mov TI_addr_limit(%_ASM_BX),%_ASM_BX
26148 sub $1,%_ASM_BX
26149 cmp %_ASM_BX,%_ASM_CX
26150 jae bad_put_user
26151 ASM_STAC
26152 -2: movw %ax,(%_ASM_CX)
26153 +
26154 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
26155 + mov $PAX_USER_SHADOW_BASE,%_ASM_BX
26156 + cmp %_ASM_BX,%_ASM_CX
26157 + jb 1234f
26158 + xor %ebx,%ebx
26159 +1234:
26160 +#endif
26161 +
26162 +#endif
26163 +
26164 +2: __copyuser_seg movw %ax,(_DEST)
26165 xor %eax,%eax
26166 EXIT
26167 ENDPROC(__put_user_2)
26168
26169 ENTRY(__put_user_4)
26170 ENTER
26171 +
26172 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
26173 + GET_THREAD_INFO(%_ASM_BX)
26174 mov TI_addr_limit(%_ASM_BX),%_ASM_BX
26175 sub $3,%_ASM_BX
26176 cmp %_ASM_BX,%_ASM_CX
26177 jae bad_put_user
26178 ASM_STAC
26179 -3: movl %eax,(%_ASM_CX)
26180 +
26181 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
26182 + mov $PAX_USER_SHADOW_BASE,%_ASM_BX
26183 + cmp %_ASM_BX,%_ASM_CX
26184 + jb 1234f
26185 + xor %ebx,%ebx
26186 +1234:
26187 +#endif
26188 +
26189 +#endif
26190 +
26191 +3: __copyuser_seg movl %eax,(_DEST)
26192 xor %eax,%eax
26193 EXIT
26194 ENDPROC(__put_user_4)
26195
26196 ENTRY(__put_user_8)
26197 ENTER
26198 +
26199 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
26200 + GET_THREAD_INFO(%_ASM_BX)
26201 mov TI_addr_limit(%_ASM_BX),%_ASM_BX
26202 sub $7,%_ASM_BX
26203 cmp %_ASM_BX,%_ASM_CX
26204 jae bad_put_user
26205 ASM_STAC
26206 -4: mov %_ASM_AX,(%_ASM_CX)
26207 +
26208 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
26209 + mov $PAX_USER_SHADOW_BASE,%_ASM_BX
26210 + cmp %_ASM_BX,%_ASM_CX
26211 + jb 1234f
26212 + xor %ebx,%ebx
26213 +1234:
26214 +#endif
26215 +
26216 +#endif
26217 +
26218 +4: __copyuser_seg mov %_ASM_AX,(_DEST)
26219 #ifdef CONFIG_X86_32
26220 -5: movl %edx,4(%_ASM_CX)
26221 +5: __copyuser_seg movl %edx,4(_DEST)
26222 #endif
26223 xor %eax,%eax
26224 EXIT
26225 diff --git a/arch/x86/lib/rwlock.S b/arch/x86/lib/rwlock.S
26226 index 1cad221..de671ee 100644
26227 --- a/arch/x86/lib/rwlock.S
26228 +++ b/arch/x86/lib/rwlock.S
26229 @@ -16,13 +16,34 @@ ENTRY(__write_lock_failed)
26230 FRAME
26231 0: LOCK_PREFIX
26232 WRITE_LOCK_ADD($RW_LOCK_BIAS) (%__lock_ptr)
26233 +
26234 +#ifdef CONFIG_PAX_REFCOUNT
26235 + jno 1234f
26236 + LOCK_PREFIX
26237 + WRITE_LOCK_SUB($RW_LOCK_BIAS) (%__lock_ptr)
26238 + int $4
26239 +1234:
26240 + _ASM_EXTABLE(1234b, 1234b)
26241 +#endif
26242 +
26243 1: rep; nop
26244 cmpl $WRITE_LOCK_CMP, (%__lock_ptr)
26245 jne 1b
26246 LOCK_PREFIX
26247 WRITE_LOCK_SUB($RW_LOCK_BIAS) (%__lock_ptr)
26248 +
26249 +#ifdef CONFIG_PAX_REFCOUNT
26250 + jno 1234f
26251 + LOCK_PREFIX
26252 + WRITE_LOCK_ADD($RW_LOCK_BIAS) (%__lock_ptr)
26253 + int $4
26254 +1234:
26255 + _ASM_EXTABLE(1234b, 1234b)
26256 +#endif
26257 +
26258 jnz 0b
26259 ENDFRAME
26260 + pax_force_retaddr
26261 ret
26262 CFI_ENDPROC
26263 END(__write_lock_failed)
26264 @@ -32,13 +53,34 @@ ENTRY(__read_lock_failed)
26265 FRAME
26266 0: LOCK_PREFIX
26267 READ_LOCK_SIZE(inc) (%__lock_ptr)
26268 +
26269 +#ifdef CONFIG_PAX_REFCOUNT
26270 + jno 1234f
26271 + LOCK_PREFIX
26272 + READ_LOCK_SIZE(dec) (%__lock_ptr)
26273 + int $4
26274 +1234:
26275 + _ASM_EXTABLE(1234b, 1234b)
26276 +#endif
26277 +
26278 1: rep; nop
26279 READ_LOCK_SIZE(cmp) $1, (%__lock_ptr)
26280 js 1b
26281 LOCK_PREFIX
26282 READ_LOCK_SIZE(dec) (%__lock_ptr)
26283 +
26284 +#ifdef CONFIG_PAX_REFCOUNT
26285 + jno 1234f
26286 + LOCK_PREFIX
26287 + READ_LOCK_SIZE(inc) (%__lock_ptr)
26288 + int $4
26289 +1234:
26290 + _ASM_EXTABLE(1234b, 1234b)
26291 +#endif
26292 +
26293 js 0b
26294 ENDFRAME
26295 + pax_force_retaddr
26296 ret
26297 CFI_ENDPROC
26298 END(__read_lock_failed)
26299 diff --git a/arch/x86/lib/rwsem.S b/arch/x86/lib/rwsem.S
26300 index 5dff5f0..cadebf4 100644
26301 --- a/arch/x86/lib/rwsem.S
26302 +++ b/arch/x86/lib/rwsem.S
26303 @@ -94,6 +94,7 @@ ENTRY(call_rwsem_down_read_failed)
26304 __ASM_SIZE(pop,_cfi) %__ASM_REG(dx)
26305 CFI_RESTORE __ASM_REG(dx)
26306 restore_common_regs
26307 + pax_force_retaddr
26308 ret
26309 CFI_ENDPROC
26310 ENDPROC(call_rwsem_down_read_failed)
26311 @@ -104,6 +105,7 @@ ENTRY(call_rwsem_down_write_failed)
26312 movq %rax,%rdi
26313 call rwsem_down_write_failed
26314 restore_common_regs
26315 + pax_force_retaddr
26316 ret
26317 CFI_ENDPROC
26318 ENDPROC(call_rwsem_down_write_failed)
26319 @@ -117,7 +119,8 @@ ENTRY(call_rwsem_wake)
26320 movq %rax,%rdi
26321 call rwsem_wake
26322 restore_common_regs
26323 -1: ret
26324 +1: pax_force_retaddr
26325 + ret
26326 CFI_ENDPROC
26327 ENDPROC(call_rwsem_wake)
26328
26329 @@ -131,6 +134,7 @@ ENTRY(call_rwsem_downgrade_wake)
26330 __ASM_SIZE(pop,_cfi) %__ASM_REG(dx)
26331 CFI_RESTORE __ASM_REG(dx)
26332 restore_common_regs
26333 + pax_force_retaddr
26334 ret
26335 CFI_ENDPROC
26336 ENDPROC(call_rwsem_downgrade_wake)
26337 diff --git a/arch/x86/lib/thunk_64.S b/arch/x86/lib/thunk_64.S
26338 index a63efd6..ccecad8 100644
26339 --- a/arch/x86/lib/thunk_64.S
26340 +++ b/arch/x86/lib/thunk_64.S
26341 @@ -8,6 +8,7 @@
26342 #include <linux/linkage.h>
26343 #include <asm/dwarf2.h>
26344 #include <asm/calling.h>
26345 +#include <asm/alternative-asm.h>
26346
26347 /* rdi: arg1 ... normal C conventions. rax is saved/restored. */
26348 .macro THUNK name, func, put_ret_addr_in_rdi=0
26349 @@ -41,5 +42,6 @@
26350 SAVE_ARGS
26351 restore:
26352 RESTORE_ARGS
26353 + pax_force_retaddr
26354 ret
26355 CFI_ENDPROC
26356 diff --git a/arch/x86/lib/usercopy_32.c b/arch/x86/lib/usercopy_32.c
26357 index f0312d7..9c39d63 100644
26358 --- a/arch/x86/lib/usercopy_32.c
26359 +++ b/arch/x86/lib/usercopy_32.c
26360 @@ -42,11 +42,13 @@ do { \
26361 int __d0; \
26362 might_fault(); \
26363 __asm__ __volatile__( \
26364 + __COPYUSER_SET_ES \
26365 ASM_STAC "\n" \
26366 "0: rep; stosl\n" \
26367 " movl %2,%0\n" \
26368 "1: rep; stosb\n" \
26369 "2: " ASM_CLAC "\n" \
26370 + __COPYUSER_RESTORE_ES \
26371 ".section .fixup,\"ax\"\n" \
26372 "3: lea 0(%2,%0,4),%0\n" \
26373 " jmp 2b\n" \
26374 @@ -98,7 +100,7 @@ EXPORT_SYMBOL(__clear_user);
26375
26376 #ifdef CONFIG_X86_INTEL_USERCOPY
26377 static unsigned long
26378 -__copy_user_intel(void __user *to, const void *from, unsigned long size)
26379 +__generic_copy_to_user_intel(void __user *to, const void *from, unsigned long size)
26380 {
26381 int d0, d1;
26382 __asm__ __volatile__(
26383 @@ -110,36 +112,36 @@ __copy_user_intel(void __user *to, const void *from, unsigned long size)
26384 " .align 2,0x90\n"
26385 "3: movl 0(%4), %%eax\n"
26386 "4: movl 4(%4), %%edx\n"
26387 - "5: movl %%eax, 0(%3)\n"
26388 - "6: movl %%edx, 4(%3)\n"
26389 + "5: "__copyuser_seg" movl %%eax, 0(%3)\n"
26390 + "6: "__copyuser_seg" movl %%edx, 4(%3)\n"
26391 "7: movl 8(%4), %%eax\n"
26392 "8: movl 12(%4),%%edx\n"
26393 - "9: movl %%eax, 8(%3)\n"
26394 - "10: movl %%edx, 12(%3)\n"
26395 + "9: "__copyuser_seg" movl %%eax, 8(%3)\n"
26396 + "10: "__copyuser_seg" movl %%edx, 12(%3)\n"
26397 "11: movl 16(%4), %%eax\n"
26398 "12: movl 20(%4), %%edx\n"
26399 - "13: movl %%eax, 16(%3)\n"
26400 - "14: movl %%edx, 20(%3)\n"
26401 + "13: "__copyuser_seg" movl %%eax, 16(%3)\n"
26402 + "14: "__copyuser_seg" movl %%edx, 20(%3)\n"
26403 "15: movl 24(%4), %%eax\n"
26404 "16: movl 28(%4), %%edx\n"
26405 - "17: movl %%eax, 24(%3)\n"
26406 - "18: movl %%edx, 28(%3)\n"
26407 + "17: "__copyuser_seg" movl %%eax, 24(%3)\n"
26408 + "18: "__copyuser_seg" movl %%edx, 28(%3)\n"
26409 "19: movl 32(%4), %%eax\n"
26410 "20: movl 36(%4), %%edx\n"
26411 - "21: movl %%eax, 32(%3)\n"
26412 - "22: movl %%edx, 36(%3)\n"
26413 + "21: "__copyuser_seg" movl %%eax, 32(%3)\n"
26414 + "22: "__copyuser_seg" movl %%edx, 36(%3)\n"
26415 "23: movl 40(%4), %%eax\n"
26416 "24: movl 44(%4), %%edx\n"
26417 - "25: movl %%eax, 40(%3)\n"
26418 - "26: movl %%edx, 44(%3)\n"
26419 + "25: "__copyuser_seg" movl %%eax, 40(%3)\n"
26420 + "26: "__copyuser_seg" movl %%edx, 44(%3)\n"
26421 "27: movl 48(%4), %%eax\n"
26422 "28: movl 52(%4), %%edx\n"
26423 - "29: movl %%eax, 48(%3)\n"
26424 - "30: movl %%edx, 52(%3)\n"
26425 + "29: "__copyuser_seg" movl %%eax, 48(%3)\n"
26426 + "30: "__copyuser_seg" movl %%edx, 52(%3)\n"
26427 "31: movl 56(%4), %%eax\n"
26428 "32: movl 60(%4), %%edx\n"
26429 - "33: movl %%eax, 56(%3)\n"
26430 - "34: movl %%edx, 60(%3)\n"
26431 + "33: "__copyuser_seg" movl %%eax, 56(%3)\n"
26432 + "34: "__copyuser_seg" movl %%edx, 60(%3)\n"
26433 " addl $-64, %0\n"
26434 " addl $64, %4\n"
26435 " addl $64, %3\n"
26436 @@ -149,10 +151,12 @@ __copy_user_intel(void __user *to, const void *from, unsigned long size)
26437 " shrl $2, %0\n"
26438 " andl $3, %%eax\n"
26439 " cld\n"
26440 + __COPYUSER_SET_ES
26441 "99: rep; movsl\n"
26442 "36: movl %%eax, %0\n"
26443 "37: rep; movsb\n"
26444 "100:\n"
26445 + __COPYUSER_RESTORE_ES
26446 ".section .fixup,\"ax\"\n"
26447 "101: lea 0(%%eax,%0,4),%0\n"
26448 " jmp 100b\n"
26449 @@ -202,46 +206,150 @@ __copy_user_intel(void __user *to, const void *from, unsigned long size)
26450 }
26451
26452 static unsigned long
26453 +__generic_copy_from_user_intel(void *to, const void __user *from, unsigned long size)
26454 +{
26455 + int d0, d1;
26456 + __asm__ __volatile__(
26457 + " .align 2,0x90\n"
26458 + "1: "__copyuser_seg" movl 32(%4), %%eax\n"
26459 + " cmpl $67, %0\n"
26460 + " jbe 3f\n"
26461 + "2: "__copyuser_seg" movl 64(%4), %%eax\n"
26462 + " .align 2,0x90\n"
26463 + "3: "__copyuser_seg" movl 0(%4), %%eax\n"
26464 + "4: "__copyuser_seg" movl 4(%4), %%edx\n"
26465 + "5: movl %%eax, 0(%3)\n"
26466 + "6: movl %%edx, 4(%3)\n"
26467 + "7: "__copyuser_seg" movl 8(%4), %%eax\n"
26468 + "8: "__copyuser_seg" movl 12(%4),%%edx\n"
26469 + "9: movl %%eax, 8(%3)\n"
26470 + "10: movl %%edx, 12(%3)\n"
26471 + "11: "__copyuser_seg" movl 16(%4), %%eax\n"
26472 + "12: "__copyuser_seg" movl 20(%4), %%edx\n"
26473 + "13: movl %%eax, 16(%3)\n"
26474 + "14: movl %%edx, 20(%3)\n"
26475 + "15: "__copyuser_seg" movl 24(%4), %%eax\n"
26476 + "16: "__copyuser_seg" movl 28(%4), %%edx\n"
26477 + "17: movl %%eax, 24(%3)\n"
26478 + "18: movl %%edx, 28(%3)\n"
26479 + "19: "__copyuser_seg" movl 32(%4), %%eax\n"
26480 + "20: "__copyuser_seg" movl 36(%4), %%edx\n"
26481 + "21: movl %%eax, 32(%3)\n"
26482 + "22: movl %%edx, 36(%3)\n"
26483 + "23: "__copyuser_seg" movl 40(%4), %%eax\n"
26484 + "24: "__copyuser_seg" movl 44(%4), %%edx\n"
26485 + "25: movl %%eax, 40(%3)\n"
26486 + "26: movl %%edx, 44(%3)\n"
26487 + "27: "__copyuser_seg" movl 48(%4), %%eax\n"
26488 + "28: "__copyuser_seg" movl 52(%4), %%edx\n"
26489 + "29: movl %%eax, 48(%3)\n"
26490 + "30: movl %%edx, 52(%3)\n"
26491 + "31: "__copyuser_seg" movl 56(%4), %%eax\n"
26492 + "32: "__copyuser_seg" movl 60(%4), %%edx\n"
26493 + "33: movl %%eax, 56(%3)\n"
26494 + "34: movl %%edx, 60(%3)\n"
26495 + " addl $-64, %0\n"
26496 + " addl $64, %4\n"
26497 + " addl $64, %3\n"
26498 + " cmpl $63, %0\n"
26499 + " ja 1b\n"
26500 + "35: movl %0, %%eax\n"
26501 + " shrl $2, %0\n"
26502 + " andl $3, %%eax\n"
26503 + " cld\n"
26504 + "99: rep; "__copyuser_seg" movsl\n"
26505 + "36: movl %%eax, %0\n"
26506 + "37: rep; "__copyuser_seg" movsb\n"
26507 + "100:\n"
26508 + ".section .fixup,\"ax\"\n"
26509 + "101: lea 0(%%eax,%0,4),%0\n"
26510 + " jmp 100b\n"
26511 + ".previous\n"
26512 + _ASM_EXTABLE(1b,100b)
26513 + _ASM_EXTABLE(2b,100b)
26514 + _ASM_EXTABLE(3b,100b)
26515 + _ASM_EXTABLE(4b,100b)
26516 + _ASM_EXTABLE(5b,100b)
26517 + _ASM_EXTABLE(6b,100b)
26518 + _ASM_EXTABLE(7b,100b)
26519 + _ASM_EXTABLE(8b,100b)
26520 + _ASM_EXTABLE(9b,100b)
26521 + _ASM_EXTABLE(10b,100b)
26522 + _ASM_EXTABLE(11b,100b)
26523 + _ASM_EXTABLE(12b,100b)
26524 + _ASM_EXTABLE(13b,100b)
26525 + _ASM_EXTABLE(14b,100b)
26526 + _ASM_EXTABLE(15b,100b)
26527 + _ASM_EXTABLE(16b,100b)
26528 + _ASM_EXTABLE(17b,100b)
26529 + _ASM_EXTABLE(18b,100b)
26530 + _ASM_EXTABLE(19b,100b)
26531 + _ASM_EXTABLE(20b,100b)
26532 + _ASM_EXTABLE(21b,100b)
26533 + _ASM_EXTABLE(22b,100b)
26534 + _ASM_EXTABLE(23b,100b)
26535 + _ASM_EXTABLE(24b,100b)
26536 + _ASM_EXTABLE(25b,100b)
26537 + _ASM_EXTABLE(26b,100b)
26538 + _ASM_EXTABLE(27b,100b)
26539 + _ASM_EXTABLE(28b,100b)
26540 + _ASM_EXTABLE(29b,100b)
26541 + _ASM_EXTABLE(30b,100b)
26542 + _ASM_EXTABLE(31b,100b)
26543 + _ASM_EXTABLE(32b,100b)
26544 + _ASM_EXTABLE(33b,100b)
26545 + _ASM_EXTABLE(34b,100b)
26546 + _ASM_EXTABLE(35b,100b)
26547 + _ASM_EXTABLE(36b,100b)
26548 + _ASM_EXTABLE(37b,100b)
26549 + _ASM_EXTABLE(99b,101b)
26550 + : "=&c"(size), "=&D" (d0), "=&S" (d1)
26551 + : "1"(to), "2"(from), "0"(size)
26552 + : "eax", "edx", "memory");
26553 + return size;
26554 +}
26555 +
26556 +static unsigned long __size_overflow(3)
26557 __copy_user_zeroing_intel(void *to, const void __user *from, unsigned long size)
26558 {
26559 int d0, d1;
26560 __asm__ __volatile__(
26561 " .align 2,0x90\n"
26562 - "0: movl 32(%4), %%eax\n"
26563 + "0: "__copyuser_seg" movl 32(%4), %%eax\n"
26564 " cmpl $67, %0\n"
26565 " jbe 2f\n"
26566 - "1: movl 64(%4), %%eax\n"
26567 + "1: "__copyuser_seg" movl 64(%4), %%eax\n"
26568 " .align 2,0x90\n"
26569 - "2: movl 0(%4), %%eax\n"
26570 - "21: movl 4(%4), %%edx\n"
26571 + "2: "__copyuser_seg" movl 0(%4), %%eax\n"
26572 + "21: "__copyuser_seg" movl 4(%4), %%edx\n"
26573 " movl %%eax, 0(%3)\n"
26574 " movl %%edx, 4(%3)\n"
26575 - "3: movl 8(%4), %%eax\n"
26576 - "31: movl 12(%4),%%edx\n"
26577 + "3: "__copyuser_seg" movl 8(%4), %%eax\n"
26578 + "31: "__copyuser_seg" movl 12(%4),%%edx\n"
26579 " movl %%eax, 8(%3)\n"
26580 " movl %%edx, 12(%3)\n"
26581 - "4: movl 16(%4), %%eax\n"
26582 - "41: movl 20(%4), %%edx\n"
26583 + "4: "__copyuser_seg" movl 16(%4), %%eax\n"
26584 + "41: "__copyuser_seg" movl 20(%4), %%edx\n"
26585 " movl %%eax, 16(%3)\n"
26586 " movl %%edx, 20(%3)\n"
26587 - "10: movl 24(%4), %%eax\n"
26588 - "51: movl 28(%4), %%edx\n"
26589 + "10: "__copyuser_seg" movl 24(%4), %%eax\n"
26590 + "51: "__copyuser_seg" movl 28(%4), %%edx\n"
26591 " movl %%eax, 24(%3)\n"
26592 " movl %%edx, 28(%3)\n"
26593 - "11: movl 32(%4), %%eax\n"
26594 - "61: movl 36(%4), %%edx\n"
26595 + "11: "__copyuser_seg" movl 32(%4), %%eax\n"
26596 + "61: "__copyuser_seg" movl 36(%4), %%edx\n"
26597 " movl %%eax, 32(%3)\n"
26598 " movl %%edx, 36(%3)\n"
26599 - "12: movl 40(%4), %%eax\n"
26600 - "71: movl 44(%4), %%edx\n"
26601 + "12: "__copyuser_seg" movl 40(%4), %%eax\n"
26602 + "71: "__copyuser_seg" movl 44(%4), %%edx\n"
26603 " movl %%eax, 40(%3)\n"
26604 " movl %%edx, 44(%3)\n"
26605 - "13: movl 48(%4), %%eax\n"
26606 - "81: movl 52(%4), %%edx\n"
26607 + "13: "__copyuser_seg" movl 48(%4), %%eax\n"
26608 + "81: "__copyuser_seg" movl 52(%4), %%edx\n"
26609 " movl %%eax, 48(%3)\n"
26610 " movl %%edx, 52(%3)\n"
26611 - "14: movl 56(%4), %%eax\n"
26612 - "91: movl 60(%4), %%edx\n"
26613 + "14: "__copyuser_seg" movl 56(%4), %%eax\n"
26614 + "91: "__copyuser_seg" movl 60(%4), %%edx\n"
26615 " movl %%eax, 56(%3)\n"
26616 " movl %%edx, 60(%3)\n"
26617 " addl $-64, %0\n"
26618 @@ -253,9 +361,9 @@ __copy_user_zeroing_intel(void *to, const void __user *from, unsigned long size)
26619 " shrl $2, %0\n"
26620 " andl $3, %%eax\n"
26621 " cld\n"
26622 - "6: rep; movsl\n"
26623 + "6: rep; "__copyuser_seg" movsl\n"
26624 " movl %%eax,%0\n"
26625 - "7: rep; movsb\n"
26626 + "7: rep; "__copyuser_seg" movsb\n"
26627 "8:\n"
26628 ".section .fixup,\"ax\"\n"
26629 "9: lea 0(%%eax,%0,4),%0\n"
26630 @@ -298,48 +406,48 @@ __copy_user_zeroing_intel(void *to, const void __user *from, unsigned long size)
26631 * hyoshiok@miraclelinux.com
26632 */
26633
26634 -static unsigned long __copy_user_zeroing_intel_nocache(void *to,
26635 +static unsigned long __size_overflow(3) __copy_user_zeroing_intel_nocache(void *to,
26636 const void __user *from, unsigned long size)
26637 {
26638 int d0, d1;
26639
26640 __asm__ __volatile__(
26641 " .align 2,0x90\n"
26642 - "0: movl 32(%4), %%eax\n"
26643 + "0: "__copyuser_seg" movl 32(%4), %%eax\n"
26644 " cmpl $67, %0\n"
26645 " jbe 2f\n"
26646 - "1: movl 64(%4), %%eax\n"
26647 + "1: "__copyuser_seg" movl 64(%4), %%eax\n"
26648 " .align 2,0x90\n"
26649 - "2: movl 0(%4), %%eax\n"
26650 - "21: movl 4(%4), %%edx\n"
26651 + "2: "__copyuser_seg" movl 0(%4), %%eax\n"
26652 + "21: "__copyuser_seg" movl 4(%4), %%edx\n"
26653 " movnti %%eax, 0(%3)\n"
26654 " movnti %%edx, 4(%3)\n"
26655 - "3: movl 8(%4), %%eax\n"
26656 - "31: movl 12(%4),%%edx\n"
26657 + "3: "__copyuser_seg" movl 8(%4), %%eax\n"
26658 + "31: "__copyuser_seg" movl 12(%4),%%edx\n"
26659 " movnti %%eax, 8(%3)\n"
26660 " movnti %%edx, 12(%3)\n"
26661 - "4: movl 16(%4), %%eax\n"
26662 - "41: movl 20(%4), %%edx\n"
26663 + "4: "__copyuser_seg" movl 16(%4), %%eax\n"
26664 + "41: "__copyuser_seg" movl 20(%4), %%edx\n"
26665 " movnti %%eax, 16(%3)\n"
26666 " movnti %%edx, 20(%3)\n"
26667 - "10: movl 24(%4), %%eax\n"
26668 - "51: movl 28(%4), %%edx\n"
26669 + "10: "__copyuser_seg" movl 24(%4), %%eax\n"
26670 + "51: "__copyuser_seg" movl 28(%4), %%edx\n"
26671 " movnti %%eax, 24(%3)\n"
26672 " movnti %%edx, 28(%3)\n"
26673 - "11: movl 32(%4), %%eax\n"
26674 - "61: movl 36(%4), %%edx\n"
26675 + "11: "__copyuser_seg" movl 32(%4), %%eax\n"
26676 + "61: "__copyuser_seg" movl 36(%4), %%edx\n"
26677 " movnti %%eax, 32(%3)\n"
26678 " movnti %%edx, 36(%3)\n"
26679 - "12: movl 40(%4), %%eax\n"
26680 - "71: movl 44(%4), %%edx\n"
26681 + "12: "__copyuser_seg" movl 40(%4), %%eax\n"
26682 + "71: "__copyuser_seg" movl 44(%4), %%edx\n"
26683 " movnti %%eax, 40(%3)\n"
26684 " movnti %%edx, 44(%3)\n"
26685 - "13: movl 48(%4), %%eax\n"
26686 - "81: movl 52(%4), %%edx\n"
26687 + "13: "__copyuser_seg" movl 48(%4), %%eax\n"
26688 + "81: "__copyuser_seg" movl 52(%4), %%edx\n"
26689 " movnti %%eax, 48(%3)\n"
26690 " movnti %%edx, 52(%3)\n"
26691 - "14: movl 56(%4), %%eax\n"
26692 - "91: movl 60(%4), %%edx\n"
26693 + "14: "__copyuser_seg" movl 56(%4), %%eax\n"
26694 + "91: "__copyuser_seg" movl 60(%4), %%edx\n"
26695 " movnti %%eax, 56(%3)\n"
26696 " movnti %%edx, 60(%3)\n"
26697 " addl $-64, %0\n"
26698 @@ -352,9 +460,9 @@ static unsigned long __copy_user_zeroing_intel_nocache(void *to,
26699 " shrl $2, %0\n"
26700 " andl $3, %%eax\n"
26701 " cld\n"
26702 - "6: rep; movsl\n"
26703 + "6: rep; "__copyuser_seg" movsl\n"
26704 " movl %%eax,%0\n"
26705 - "7: rep; movsb\n"
26706 + "7: rep; "__copyuser_seg" movsb\n"
26707 "8:\n"
26708 ".section .fixup,\"ax\"\n"
26709 "9: lea 0(%%eax,%0,4),%0\n"
26710 @@ -392,48 +500,48 @@ static unsigned long __copy_user_zeroing_intel_nocache(void *to,
26711 return size;
26712 }
26713
26714 -static unsigned long __copy_user_intel_nocache(void *to,
26715 +static unsigned long __size_overflow(3) __copy_user_intel_nocache(void *to,
26716 const void __user *from, unsigned long size)
26717 {
26718 int d0, d1;
26719
26720 __asm__ __volatile__(
26721 " .align 2,0x90\n"
26722 - "0: movl 32(%4), %%eax\n"
26723 + "0: "__copyuser_seg" movl 32(%4), %%eax\n"
26724 " cmpl $67, %0\n"
26725 " jbe 2f\n"
26726 - "1: movl 64(%4), %%eax\n"
26727 + "1: "__copyuser_seg" movl 64(%4), %%eax\n"
26728 " .align 2,0x90\n"
26729 - "2: movl 0(%4), %%eax\n"
26730 - "21: movl 4(%4), %%edx\n"
26731 + "2: "__copyuser_seg" movl 0(%4), %%eax\n"
26732 + "21: "__copyuser_seg" movl 4(%4), %%edx\n"
26733 " movnti %%eax, 0(%3)\n"
26734 " movnti %%edx, 4(%3)\n"
26735 - "3: movl 8(%4), %%eax\n"
26736 - "31: movl 12(%4),%%edx\n"
26737 + "3: "__copyuser_seg" movl 8(%4), %%eax\n"
26738 + "31: "__copyuser_seg" movl 12(%4),%%edx\n"
26739 " movnti %%eax, 8(%3)\n"
26740 " movnti %%edx, 12(%3)\n"
26741 - "4: movl 16(%4), %%eax\n"
26742 - "41: movl 20(%4), %%edx\n"
26743 + "4: "__copyuser_seg" movl 16(%4), %%eax\n"
26744 + "41: "__copyuser_seg" movl 20(%4), %%edx\n"
26745 " movnti %%eax, 16(%3)\n"
26746 " movnti %%edx, 20(%3)\n"
26747 - "10: movl 24(%4), %%eax\n"
26748 - "51: movl 28(%4), %%edx\n"
26749 + "10: "__copyuser_seg" movl 24(%4), %%eax\n"
26750 + "51: "__copyuser_seg" movl 28(%4), %%edx\n"
26751 " movnti %%eax, 24(%3)\n"
26752 " movnti %%edx, 28(%3)\n"
26753 - "11: movl 32(%4), %%eax\n"
26754 - "61: movl 36(%4), %%edx\n"
26755 + "11: "__copyuser_seg" movl 32(%4), %%eax\n"
26756 + "61: "__copyuser_seg" movl 36(%4), %%edx\n"
26757 " movnti %%eax, 32(%3)\n"
26758 " movnti %%edx, 36(%3)\n"
26759 - "12: movl 40(%4), %%eax\n"
26760 - "71: movl 44(%4), %%edx\n"
26761 + "12: "__copyuser_seg" movl 40(%4), %%eax\n"
26762 + "71: "__copyuser_seg" movl 44(%4), %%edx\n"
26763 " movnti %%eax, 40(%3)\n"
26764 " movnti %%edx, 44(%3)\n"
26765 - "13: movl 48(%4), %%eax\n"
26766 - "81: movl 52(%4), %%edx\n"
26767 + "13: "__copyuser_seg" movl 48(%4), %%eax\n"
26768 + "81: "__copyuser_seg" movl 52(%4), %%edx\n"
26769 " movnti %%eax, 48(%3)\n"
26770 " movnti %%edx, 52(%3)\n"
26771 - "14: movl 56(%4), %%eax\n"
26772 - "91: movl 60(%4), %%edx\n"
26773 + "14: "__copyuser_seg" movl 56(%4), %%eax\n"
26774 + "91: "__copyuser_seg" movl 60(%4), %%edx\n"
26775 " movnti %%eax, 56(%3)\n"
26776 " movnti %%edx, 60(%3)\n"
26777 " addl $-64, %0\n"
26778 @@ -446,9 +554,9 @@ static unsigned long __copy_user_intel_nocache(void *to,
26779 " shrl $2, %0\n"
26780 " andl $3, %%eax\n"
26781 " cld\n"
26782 - "6: rep; movsl\n"
26783 + "6: rep; "__copyuser_seg" movsl\n"
26784 " movl %%eax,%0\n"
26785 - "7: rep; movsb\n"
26786 + "7: rep; "__copyuser_seg" movsb\n"
26787 "8:\n"
26788 ".section .fixup,\"ax\"\n"
26789 "9: lea 0(%%eax,%0,4),%0\n"
26790 @@ -488,32 +596,36 @@ static unsigned long __copy_user_intel_nocache(void *to,
26791 */
26792 unsigned long __copy_user_zeroing_intel(void *to, const void __user *from,
26793 unsigned long size);
26794 -unsigned long __copy_user_intel(void __user *to, const void *from,
26795 +unsigned long __generic_copy_to_user_intel(void __user *to, const void *from,
26796 + unsigned long size);
26797 +unsigned long __generic_copy_from_user_intel(void *to, const void __user *from,
26798 unsigned long size);
26799 unsigned long __copy_user_zeroing_intel_nocache(void *to,
26800 const void __user *from, unsigned long size);
26801 #endif /* CONFIG_X86_INTEL_USERCOPY */
26802
26803 /* Generic arbitrary sized copy. */
26804 -#define __copy_user(to, from, size) \
26805 +#define __copy_user(to, from, size, prefix, set, restore) \
26806 do { \
26807 int __d0, __d1, __d2; \
26808 __asm__ __volatile__( \
26809 + set \
26810 " cmp $7,%0\n" \
26811 " jbe 1f\n" \
26812 " movl %1,%0\n" \
26813 " negl %0\n" \
26814 " andl $7,%0\n" \
26815 " subl %0,%3\n" \
26816 - "4: rep; movsb\n" \
26817 + "4: rep; "prefix"movsb\n" \
26818 " movl %3,%0\n" \
26819 " shrl $2,%0\n" \
26820 " andl $3,%3\n" \
26821 " .align 2,0x90\n" \
26822 - "0: rep; movsl\n" \
26823 + "0: rep; "prefix"movsl\n" \
26824 " movl %3,%0\n" \
26825 - "1: rep; movsb\n" \
26826 + "1: rep; "prefix"movsb\n" \
26827 "2:\n" \
26828 + restore \
26829 ".section .fixup,\"ax\"\n" \
26830 "5: addl %3,%0\n" \
26831 " jmp 2b\n" \
26832 @@ -538,14 +650,14 @@ do { \
26833 " negl %0\n" \
26834 " andl $7,%0\n" \
26835 " subl %0,%3\n" \
26836 - "4: rep; movsb\n" \
26837 + "4: rep; "__copyuser_seg"movsb\n" \
26838 " movl %3,%0\n" \
26839 " shrl $2,%0\n" \
26840 " andl $3,%3\n" \
26841 " .align 2,0x90\n" \
26842 - "0: rep; movsl\n" \
26843 + "0: rep; "__copyuser_seg"movsl\n" \
26844 " movl %3,%0\n" \
26845 - "1: rep; movsb\n" \
26846 + "1: rep; "__copyuser_seg"movsb\n" \
26847 "2:\n" \
26848 ".section .fixup,\"ax\"\n" \
26849 "5: addl %3,%0\n" \
26850 @@ -572,9 +684,9 @@ unsigned long __copy_to_user_ll(void __user *to, const void *from,
26851 {
26852 stac();
26853 if (movsl_is_ok(to, from, n))
26854 - __copy_user(to, from, n);
26855 + __copy_user(to, from, n, "", __COPYUSER_SET_ES, __COPYUSER_RESTORE_ES);
26856 else
26857 - n = __copy_user_intel(to, from, n);
26858 + n = __generic_copy_to_user_intel(to, from, n);
26859 clac();
26860 return n;
26861 }
26862 @@ -598,10 +710,9 @@ unsigned long __copy_from_user_ll_nozero(void *to, const void __user *from,
26863 {
26864 stac();
26865 if (movsl_is_ok(to, from, n))
26866 - __copy_user(to, from, n);
26867 + __copy_user(to, from, n, __copyuser_seg, "", "");
26868 else
26869 - n = __copy_user_intel((void __user *)to,
26870 - (const void *)from, n);
26871 + n = __generic_copy_from_user_intel(to, from, n);
26872 clac();
26873 return n;
26874 }
26875 @@ -632,66 +743,51 @@ unsigned long __copy_from_user_ll_nocache_nozero(void *to, const void __user *fr
26876 if (n > 64 && cpu_has_xmm2)
26877 n = __copy_user_intel_nocache(to, from, n);
26878 else
26879 - __copy_user(to, from, n);
26880 + __copy_user(to, from, n, __copyuser_seg, "", "");
26881 #else
26882 - __copy_user(to, from, n);
26883 + __copy_user(to, from, n, __copyuser_seg, "", "");
26884 #endif
26885 clac();
26886 return n;
26887 }
26888 EXPORT_SYMBOL(__copy_from_user_ll_nocache_nozero);
26889
26890 -/**
26891 - * copy_to_user: - Copy a block of data into user space.
26892 - * @to: Destination address, in user space.
26893 - * @from: Source address, in kernel space.
26894 - * @n: Number of bytes to copy.
26895 - *
26896 - * Context: User context only. This function may sleep.
26897 - *
26898 - * Copy data from kernel space to user space.
26899 - *
26900 - * Returns number of bytes that could not be copied.
26901 - * On success, this will be zero.
26902 - */
26903 -unsigned long
26904 -copy_to_user(void __user *to, const void *from, unsigned long n)
26905 -{
26906 - if (access_ok(VERIFY_WRITE, to, n))
26907 - n = __copy_to_user(to, from, n);
26908 - return n;
26909 -}
26910 -EXPORT_SYMBOL(copy_to_user);
26911 -
26912 -/**
26913 - * copy_from_user: - Copy a block of data from user space.
26914 - * @to: Destination address, in kernel space.
26915 - * @from: Source address, in user space.
26916 - * @n: Number of bytes to copy.
26917 - *
26918 - * Context: User context only. This function may sleep.
26919 - *
26920 - * Copy data from user space to kernel space.
26921 - *
26922 - * Returns number of bytes that could not be copied.
26923 - * On success, this will be zero.
26924 - *
26925 - * If some data could not be copied, this function will pad the copied
26926 - * data to the requested size using zero bytes.
26927 - */
26928 -unsigned long
26929 -_copy_from_user(void *to, const void __user *from, unsigned long n)
26930 -{
26931 - if (access_ok(VERIFY_READ, from, n))
26932 - n = __copy_from_user(to, from, n);
26933 - else
26934 - memset(to, 0, n);
26935 - return n;
26936 -}
26937 -EXPORT_SYMBOL(_copy_from_user);
26938 -
26939 void copy_from_user_overflow(void)
26940 {
26941 WARN(1, "Buffer overflow detected!\n");
26942 }
26943 EXPORT_SYMBOL(copy_from_user_overflow);
26944 +
26945 +void copy_to_user_overflow(void)
26946 +{
26947 + WARN(1, "Buffer overflow detected!\n");
26948 +}
26949 +EXPORT_SYMBOL(copy_to_user_overflow);
26950 +
26951 +#ifdef CONFIG_PAX_MEMORY_UDEREF
26952 +void __set_fs(mm_segment_t x)
26953 +{
26954 + switch (x.seg) {
26955 + case 0:
26956 + loadsegment(gs, 0);
26957 + break;
26958 + case TASK_SIZE_MAX:
26959 + loadsegment(gs, __USER_DS);
26960 + break;
26961 + case -1UL:
26962 + loadsegment(gs, __KERNEL_DS);
26963 + break;
26964 + default:
26965 + BUG();
26966 + }
26967 + return;
26968 +}
26969 +EXPORT_SYMBOL(__set_fs);
26970 +
26971 +void set_fs(mm_segment_t x)
26972 +{
26973 + current_thread_info()->addr_limit = x;
26974 + __set_fs(x);
26975 +}
26976 +EXPORT_SYMBOL(set_fs);
26977 +#endif
26978 diff --git a/arch/x86/lib/usercopy_64.c b/arch/x86/lib/usercopy_64.c
26979 index 05928aa..b33dea1 100644
26980 --- a/arch/x86/lib/usercopy_64.c
26981 +++ b/arch/x86/lib/usercopy_64.c
26982 @@ -39,7 +39,7 @@ unsigned long __clear_user(void __user *addr, unsigned long size)
26983 _ASM_EXTABLE(0b,3b)
26984 _ASM_EXTABLE(1b,2b)
26985 : [size8] "=&c"(size), [dst] "=&D" (__d0)
26986 - : [size1] "r"(size & 7), "[size8]" (size / 8), "[dst]"(addr),
26987 + : [size1] "r"(size & 7), "[size8]" (size / 8), "[dst]"(____m(addr)),
26988 [zero] "r" (0UL), [eight] "r" (8UL));
26989 clac();
26990 return size;
26991 @@ -54,12 +54,11 @@ unsigned long clear_user(void __user *to, unsigned long n)
26992 }
26993 EXPORT_SYMBOL(clear_user);
26994
26995 -unsigned long copy_in_user(void __user *to, const void __user *from, unsigned len)
26996 +unsigned long copy_in_user(void __user *to, const void __user *from, unsigned long len)
26997 {
26998 - if (access_ok(VERIFY_WRITE, to, len) && access_ok(VERIFY_READ, from, len)) {
26999 - return copy_user_generic((__force void *)to, (__force void *)from, len);
27000 - }
27001 - return len;
27002 + if (access_ok(VERIFY_WRITE, to, len) && access_ok(VERIFY_READ, from, len))
27003 + return copy_user_generic((void __force_kernel *)____m(to), (void __force_kernel *)____m(from), len);
27004 + return len;
27005 }
27006 EXPORT_SYMBOL(copy_in_user);
27007
27008 @@ -69,7 +68,7 @@ EXPORT_SYMBOL(copy_in_user);
27009 * it is not necessary to optimize tail handling.
27010 */
27011 unsigned long
27012 -copy_user_handle_tail(char *to, char *from, unsigned len, unsigned zerorest)
27013 +copy_user_handle_tail(char __user *to, char __user *from, unsigned long len, unsigned zerorest)
27014 {
27015 char c;
27016 unsigned zero_len;
27017 @@ -87,3 +86,15 @@ copy_user_handle_tail(char *to, char *from, unsigned len, unsigned zerorest)
27018 clac();
27019 return len;
27020 }
27021 +
27022 +void copy_from_user_overflow(void)
27023 +{
27024 + WARN(1, "Buffer overflow detected!\n");
27025 +}
27026 +EXPORT_SYMBOL(copy_from_user_overflow);
27027 +
27028 +void copy_to_user_overflow(void)
27029 +{
27030 + WARN(1, "Buffer overflow detected!\n");
27031 +}
27032 +EXPORT_SYMBOL(copy_to_user_overflow);
27033 diff --git a/arch/x86/mm/extable.c b/arch/x86/mm/extable.c
27034 index 903ec1e..c4166b2 100644
27035 --- a/arch/x86/mm/extable.c
27036 +++ b/arch/x86/mm/extable.c
27037 @@ -6,12 +6,24 @@
27038 static inline unsigned long
27039 ex_insn_addr(const struct exception_table_entry *x)
27040 {
27041 - return (unsigned long)&x->insn + x->insn;
27042 + unsigned long reloc = 0;
27043 +
27044 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
27045 + reloc = ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
27046 +#endif
27047 +
27048 + return (unsigned long)&x->insn + x->insn + reloc;
27049 }
27050 static inline unsigned long
27051 ex_fixup_addr(const struct exception_table_entry *x)
27052 {
27053 - return (unsigned long)&x->fixup + x->fixup;
27054 + unsigned long reloc = 0;
27055 +
27056 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
27057 + reloc = ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
27058 +#endif
27059 +
27060 + return (unsigned long)&x->fixup + x->fixup + reloc;
27061 }
27062
27063 int fixup_exception(struct pt_regs *regs)
27064 @@ -20,7 +32,7 @@ int fixup_exception(struct pt_regs *regs)
27065 unsigned long new_ip;
27066
27067 #ifdef CONFIG_PNPBIOS
27068 - if (unlikely(SEGMENT_IS_PNP_CODE(regs->cs))) {
27069 + if (unlikely(!v8086_mode(regs) && SEGMENT_IS_PNP_CODE(regs->cs))) {
27070 extern u32 pnp_bios_fault_eip, pnp_bios_fault_esp;
27071 extern u32 pnp_bios_is_utter_crap;
27072 pnp_bios_is_utter_crap = 1;
27073 @@ -145,6 +157,13 @@ void sort_extable(struct exception_table_entry *start,
27074 i += 4;
27075 p->fixup -= i;
27076 i += 4;
27077 +
27078 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
27079 + BUILD_BUG_ON(!IS_ENABLED(CONFIG_BUILDTIME_EXTABLE_SORT));
27080 + p->insn -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
27081 + p->fixup -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
27082 +#endif
27083 +
27084 }
27085 }
27086
27087 diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c
27088 index fb674fd..1be28b9 100644
27089 --- a/arch/x86/mm/fault.c
27090 +++ b/arch/x86/mm/fault.c
27091 @@ -13,12 +13,19 @@
27092 #include <linux/perf_event.h> /* perf_sw_event */
27093 #include <linux/hugetlb.h> /* hstate_index_to_shift */
27094 #include <linux/prefetch.h> /* prefetchw */
27095 +#include <linux/unistd.h>
27096 +#include <linux/compiler.h>
27097
27098 #include <asm/traps.h> /* dotraplinkage, ... */
27099 #include <asm/pgalloc.h> /* pgd_*(), ... */
27100 #include <asm/kmemcheck.h> /* kmemcheck_*(), ... */
27101 #include <asm/fixmap.h> /* VSYSCALL_START */
27102 #include <asm/context_tracking.h> /* exception_enter(), ... */
27103 +#include <asm/tlbflush.h>
27104 +
27105 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
27106 +#include <asm/stacktrace.h>
27107 +#endif
27108
27109 /*
27110 * Page fault error code bits:
27111 @@ -56,7 +63,7 @@ static inline int __kprobes notify_page_fault(struct pt_regs *regs)
27112 int ret = 0;
27113
27114 /* kprobe_running() needs smp_processor_id() */
27115 - if (kprobes_built_in() && !user_mode_vm(regs)) {
27116 + if (kprobes_built_in() && !user_mode(regs)) {
27117 preempt_disable();
27118 if (kprobe_running() && kprobe_fault_handler(regs, 14))
27119 ret = 1;
27120 @@ -117,7 +124,10 @@ check_prefetch_opcode(struct pt_regs *regs, unsigned char *instr,
27121 return !instr_lo || (instr_lo>>1) == 1;
27122 case 0x00:
27123 /* Prefetch instruction is 0x0F0D or 0x0F18 */
27124 - if (probe_kernel_address(instr, opcode))
27125 + if (user_mode(regs)) {
27126 + if (__copy_from_user_inatomic(&opcode, (unsigned char __force_user *)(instr), 1))
27127 + return 0;
27128 + } else if (probe_kernel_address(instr, opcode))
27129 return 0;
27130
27131 *prefetch = (instr_lo == 0xF) &&
27132 @@ -151,7 +161,10 @@ is_prefetch(struct pt_regs *regs, unsigned long error_code, unsigned long addr)
27133 while (instr < max_instr) {
27134 unsigned char opcode;
27135
27136 - if (probe_kernel_address(instr, opcode))
27137 + if (user_mode(regs)) {
27138 + if (__copy_from_user_inatomic(&opcode, (unsigned char __force_user *)(instr), 1))
27139 + break;
27140 + } else if (probe_kernel_address(instr, opcode))
27141 break;
27142
27143 instr++;
27144 @@ -182,6 +195,34 @@ force_sig_info_fault(int si_signo, int si_code, unsigned long address,
27145 force_sig_info(si_signo, &info, tsk);
27146 }
27147
27148 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
27149 +static bool pax_is_fetch_fault(struct pt_regs *regs, unsigned long error_code, unsigned long address);
27150 +#endif
27151 +
27152 +#ifdef CONFIG_PAX_EMUTRAMP
27153 +static int pax_handle_fetch_fault(struct pt_regs *regs);
27154 +#endif
27155 +
27156 +#ifdef CONFIG_PAX_PAGEEXEC
27157 +static inline pmd_t * pax_get_pmd(struct mm_struct *mm, unsigned long address)
27158 +{
27159 + pgd_t *pgd;
27160 + pud_t *pud;
27161 + pmd_t *pmd;
27162 +
27163 + pgd = pgd_offset(mm, address);
27164 + if (!pgd_present(*pgd))
27165 + return NULL;
27166 + pud = pud_offset(pgd, address);
27167 + if (!pud_present(*pud))
27168 + return NULL;
27169 + pmd = pmd_offset(pud, address);
27170 + if (!pmd_present(*pmd))
27171 + return NULL;
27172 + return pmd;
27173 +}
27174 +#endif
27175 +
27176 DEFINE_SPINLOCK(pgd_lock);
27177 LIST_HEAD(pgd_list);
27178
27179 @@ -232,10 +273,22 @@ void vmalloc_sync_all(void)
27180 for (address = VMALLOC_START & PMD_MASK;
27181 address >= TASK_SIZE && address < FIXADDR_TOP;
27182 address += PMD_SIZE) {
27183 +
27184 +#ifdef CONFIG_PAX_PER_CPU_PGD
27185 + unsigned long cpu;
27186 +#else
27187 struct page *page;
27188 +#endif
27189
27190 spin_lock(&pgd_lock);
27191 +
27192 +#ifdef CONFIG_PAX_PER_CPU_PGD
27193 + for (cpu = 0; cpu < nr_cpu_ids; ++cpu) {
27194 + pgd_t *pgd = get_cpu_pgd(cpu);
27195 + pmd_t *ret;
27196 +#else
27197 list_for_each_entry(page, &pgd_list, lru) {
27198 + pgd_t *pgd = page_address(page);
27199 spinlock_t *pgt_lock;
27200 pmd_t *ret;
27201
27202 @@ -243,8 +296,13 @@ void vmalloc_sync_all(void)
27203 pgt_lock = &pgd_page_get_mm(page)->page_table_lock;
27204
27205 spin_lock(pgt_lock);
27206 - ret = vmalloc_sync_one(page_address(page), address);
27207 +#endif
27208 +
27209 + ret = vmalloc_sync_one(pgd, address);
27210 +
27211 +#ifndef CONFIG_PAX_PER_CPU_PGD
27212 spin_unlock(pgt_lock);
27213 +#endif
27214
27215 if (!ret)
27216 break;
27217 @@ -278,6 +336,11 @@ static noinline __kprobes int vmalloc_fault(unsigned long address)
27218 * an interrupt in the middle of a task switch..
27219 */
27220 pgd_paddr = read_cr3();
27221 +
27222 +#ifdef CONFIG_PAX_PER_CPU_PGD
27223 + BUG_ON(__pa(get_cpu_pgd(smp_processor_id())) != (pgd_paddr & PHYSICAL_PAGE_MASK));
27224 +#endif
27225 +
27226 pmd_k = vmalloc_sync_one(__va(pgd_paddr), address);
27227 if (!pmd_k)
27228 return -1;
27229 @@ -373,7 +436,14 @@ static noinline __kprobes int vmalloc_fault(unsigned long address)
27230 * happen within a race in page table update. In the later
27231 * case just flush:
27232 */
27233 +
27234 +#ifdef CONFIG_PAX_PER_CPU_PGD
27235 + BUG_ON(__pa(get_cpu_pgd(smp_processor_id())) != (read_cr3() & PHYSICAL_PAGE_MASK));
27236 + pgd = pgd_offset_cpu(smp_processor_id(), address);
27237 +#else
27238 pgd = pgd_offset(current->active_mm, address);
27239 +#endif
27240 +
27241 pgd_ref = pgd_offset_k(address);
27242 if (pgd_none(*pgd_ref))
27243 return -1;
27244 @@ -541,7 +611,7 @@ static int is_errata93(struct pt_regs *regs, unsigned long address)
27245 static int is_errata100(struct pt_regs *regs, unsigned long address)
27246 {
27247 #ifdef CONFIG_X86_64
27248 - if ((regs->cs == __USER32_CS || (regs->cs & (1<<2))) && (address >> 32))
27249 + if ((regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT)) && (address >> 32))
27250 return 1;
27251 #endif
27252 return 0;
27253 @@ -568,7 +638,7 @@ static int is_f00f_bug(struct pt_regs *regs, unsigned long address)
27254 }
27255
27256 static const char nx_warning[] = KERN_CRIT
27257 -"kernel tried to execute NX-protected page - exploit attempt? (uid: %d)\n";
27258 +"kernel tried to execute NX-protected page - exploit attempt? (uid: %d, task: %s, pid: %d)\n";
27259
27260 static void
27261 show_fault_oops(struct pt_regs *regs, unsigned long error_code,
27262 @@ -577,15 +647,27 @@ show_fault_oops(struct pt_regs *regs, unsigned long error_code,
27263 if (!oops_may_print())
27264 return;
27265
27266 - if (error_code & PF_INSTR) {
27267 + if ((__supported_pte_mask & _PAGE_NX) && (error_code & PF_INSTR)) {
27268 unsigned int level;
27269
27270 pte_t *pte = lookup_address(address, &level);
27271
27272 if (pte && pte_present(*pte) && !pte_exec(*pte))
27273 - printk(nx_warning, from_kuid(&init_user_ns, current_uid()));
27274 + printk(nx_warning, from_kuid_munged(&init_user_ns, current_uid()), current->comm, task_pid_nr(current));
27275 }
27276
27277 +#ifdef CONFIG_PAX_KERNEXEC
27278 + if (init_mm.start_code <= address && address < init_mm.end_code) {
27279 + if (current->signal->curr_ip)
27280 + printk(KERN_ERR "PAX: From %pI4: %s:%d, uid/euid: %u/%u, attempted to modify kernel code\n",
27281 + &current->signal->curr_ip, current->comm, task_pid_nr(current),
27282 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
27283 + else
27284 + printk(KERN_ERR "PAX: %s:%d, uid/euid: %u/%u, attempted to modify kernel code\n", current->comm, task_pid_nr(current),
27285 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
27286 + }
27287 +#endif
27288 +
27289 printk(KERN_ALERT "BUG: unable to handle kernel ");
27290 if (address < PAGE_SIZE)
27291 printk(KERN_CONT "NULL pointer dereference");
27292 @@ -748,6 +830,22 @@ __bad_area_nosemaphore(struct pt_regs *regs, unsigned long error_code,
27293 return;
27294 }
27295 #endif
27296 +
27297 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
27298 + if (pax_is_fetch_fault(regs, error_code, address)) {
27299 +
27300 +#ifdef CONFIG_PAX_EMUTRAMP
27301 + switch (pax_handle_fetch_fault(regs)) {
27302 + case 2:
27303 + return;
27304 + }
27305 +#endif
27306 +
27307 + pax_report_fault(regs, (void *)regs->ip, (void *)regs->sp);
27308 + do_group_exit(SIGKILL);
27309 + }
27310 +#endif
27311 +
27312 /* Kernel addresses are always protection faults: */
27313 if (address >= TASK_SIZE)
27314 error_code |= PF_PROT;
27315 @@ -833,7 +931,7 @@ do_sigbus(struct pt_regs *regs, unsigned long error_code, unsigned long address,
27316 if (fault & (VM_FAULT_HWPOISON|VM_FAULT_HWPOISON_LARGE)) {
27317 printk(KERN_ERR
27318 "MCE: Killing %s:%d due to hardware memory corruption fault at %lx\n",
27319 - tsk->comm, tsk->pid, address);
27320 + tsk->comm, task_pid_nr(tsk), address);
27321 code = BUS_MCEERR_AR;
27322 }
27323 #endif
27324 @@ -896,6 +994,99 @@ static int spurious_fault_check(unsigned long error_code, pte_t *pte)
27325 return 1;
27326 }
27327
27328 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
27329 +static int pax_handle_pageexec_fault(struct pt_regs *regs, struct mm_struct *mm, unsigned long address, unsigned long error_code)
27330 +{
27331 + pte_t *pte;
27332 + pmd_t *pmd;
27333 + spinlock_t *ptl;
27334 + unsigned char pte_mask;
27335 +
27336 + if ((__supported_pte_mask & _PAGE_NX) || (error_code & (PF_PROT|PF_USER)) != (PF_PROT|PF_USER) || v8086_mode(regs) ||
27337 + !(mm->pax_flags & MF_PAX_PAGEEXEC))
27338 + return 0;
27339 +
27340 + /* PaX: it's our fault, let's handle it if we can */
27341 +
27342 + /* PaX: take a look at read faults before acquiring any locks */
27343 + if (unlikely(!(error_code & PF_WRITE) && (regs->ip == address))) {
27344 + /* instruction fetch attempt from a protected page in user mode */
27345 + up_read(&mm->mmap_sem);
27346 +
27347 +#ifdef CONFIG_PAX_EMUTRAMP
27348 + switch (pax_handle_fetch_fault(regs)) {
27349 + case 2:
27350 + return 1;
27351 + }
27352 +#endif
27353 +
27354 + pax_report_fault(regs, (void *)regs->ip, (void *)regs->sp);
27355 + do_group_exit(SIGKILL);
27356 + }
27357 +
27358 + pmd = pax_get_pmd(mm, address);
27359 + if (unlikely(!pmd))
27360 + return 0;
27361 +
27362 + pte = pte_offset_map_lock(mm, pmd, address, &ptl);
27363 + if (unlikely(!(pte_val(*pte) & _PAGE_PRESENT) || pte_user(*pte))) {
27364 + pte_unmap_unlock(pte, ptl);
27365 + return 0;
27366 + }
27367 +
27368 + if (unlikely((error_code & PF_WRITE) && !pte_write(*pte))) {
27369 + /* write attempt to a protected page in user mode */
27370 + pte_unmap_unlock(pte, ptl);
27371 + return 0;
27372 + }
27373 +
27374 +#ifdef CONFIG_SMP
27375 + if (likely(address > get_limit(regs->cs) && cpu_isset(smp_processor_id(), mm->context.cpu_user_cs_mask)))
27376 +#else
27377 + if (likely(address > get_limit(regs->cs)))
27378 +#endif
27379 + {
27380 + set_pte(pte, pte_mkread(*pte));
27381 + __flush_tlb_one(address);
27382 + pte_unmap_unlock(pte, ptl);
27383 + up_read(&mm->mmap_sem);
27384 + return 1;
27385 + }
27386 +
27387 + pte_mask = _PAGE_ACCESSED | _PAGE_USER | ((error_code & PF_WRITE) << (_PAGE_BIT_DIRTY-1));
27388 +
27389 + /*
27390 + * PaX: fill DTLB with user rights and retry
27391 + */
27392 + __asm__ __volatile__ (
27393 + "orb %2,(%1)\n"
27394 +#if defined(CONFIG_M586) || defined(CONFIG_M586TSC)
27395 +/*
27396 + * PaX: let this uncommented 'invlpg' remind us on the behaviour of Intel's
27397 + * (and AMD's) TLBs. namely, they do not cache PTEs that would raise *any*
27398 + * page fault when examined during a TLB load attempt. this is true not only
27399 + * for PTEs holding a non-present entry but also present entries that will
27400 + * raise a page fault (such as those set up by PaX, or the copy-on-write
27401 + * mechanism). in effect it means that we do *not* need to flush the TLBs
27402 + * for our target pages since their PTEs are simply not in the TLBs at all.
27403 +
27404 + * the best thing in omitting it is that we gain around 15-20% speed in the
27405 + * fast path of the page fault handler and can get rid of tracing since we
27406 + * can no longer flush unintended entries.
27407 + */
27408 + "invlpg (%0)\n"
27409 +#endif
27410 + __copyuser_seg"testb $0,(%0)\n"
27411 + "xorb %3,(%1)\n"
27412 + :
27413 + : "r" (address), "r" (pte), "q" (pte_mask), "i" (_PAGE_USER)
27414 + : "memory", "cc");
27415 + pte_unmap_unlock(pte, ptl);
27416 + up_read(&mm->mmap_sem);
27417 + return 1;
27418 +}
27419 +#endif
27420 +
27421 /*
27422 * Handle a spurious fault caused by a stale TLB entry.
27423 *
27424 @@ -968,6 +1159,9 @@ int show_unhandled_signals = 1;
27425 static inline int
27426 access_error(unsigned long error_code, struct vm_area_struct *vma)
27427 {
27428 + if ((__supported_pte_mask & _PAGE_NX) && (error_code & PF_INSTR) && !(vma->vm_flags & VM_EXEC))
27429 + return 1;
27430 +
27431 if (error_code & PF_WRITE) {
27432 /* write, present and write, not present: */
27433 if (unlikely(!(vma->vm_flags & VM_WRITE)))
27434 @@ -996,7 +1190,7 @@ static inline bool smap_violation(int error_code, struct pt_regs *regs)
27435 if (error_code & PF_USER)
27436 return false;
27437
27438 - if (!user_mode_vm(regs) && (regs->flags & X86_EFLAGS_AC))
27439 + if (!user_mode(regs) && (regs->flags & X86_EFLAGS_AC))
27440 return false;
27441
27442 return true;
27443 @@ -1012,18 +1206,33 @@ __do_page_fault(struct pt_regs *regs, unsigned long error_code)
27444 {
27445 struct vm_area_struct *vma;
27446 struct task_struct *tsk;
27447 - unsigned long address;
27448 struct mm_struct *mm;
27449 int fault;
27450 int write = error_code & PF_WRITE;
27451 unsigned int flags = FAULT_FLAG_ALLOW_RETRY | FAULT_FLAG_KILLABLE |
27452 (write ? FAULT_FLAG_WRITE : 0);
27453
27454 - tsk = current;
27455 - mm = tsk->mm;
27456 -
27457 /* Get the faulting address: */
27458 - address = read_cr2();
27459 + unsigned long address = read_cr2();
27460 +
27461 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
27462 + if (!user_mode(regs) && address < 2 * PAX_USER_SHADOW_BASE) {
27463 + if (!search_exception_tables(regs->ip)) {
27464 + printk(KERN_ERR "PAX: please report this to pageexec@freemail.hu\n");
27465 + bad_area_nosemaphore(regs, error_code, address);
27466 + return;
27467 + }
27468 + if (address < PAX_USER_SHADOW_BASE) {
27469 + printk(KERN_ERR "PAX: please report this to pageexec@freemail.hu\n");
27470 + printk(KERN_ERR "PAX: faulting IP: %pS\n", (void *)regs->ip);
27471 + show_trace_log_lvl(NULL, NULL, (void *)regs->sp, regs->bp, KERN_ERR);
27472 + } else
27473 + address -= PAX_USER_SHADOW_BASE;
27474 + }
27475 +#endif
27476 +
27477 + tsk = current;
27478 + mm = tsk->mm;
27479
27480 /*
27481 * Detect and handle instructions that would cause a page fault for
27482 @@ -1084,7 +1293,7 @@ __do_page_fault(struct pt_regs *regs, unsigned long error_code)
27483 * User-mode registers count as a user access even for any
27484 * potential system fault or CPU buglet:
27485 */
27486 - if (user_mode_vm(regs)) {
27487 + if (user_mode(regs)) {
27488 local_irq_enable();
27489 error_code |= PF_USER;
27490 } else {
27491 @@ -1146,6 +1355,11 @@ retry:
27492 might_sleep();
27493 }
27494
27495 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
27496 + if (pax_handle_pageexec_fault(regs, mm, address, error_code))
27497 + return;
27498 +#endif
27499 +
27500 vma = find_vma(mm, address);
27501 if (unlikely(!vma)) {
27502 bad_area(regs, error_code, address);
27503 @@ -1157,18 +1371,24 @@ retry:
27504 bad_area(regs, error_code, address);
27505 return;
27506 }
27507 - if (error_code & PF_USER) {
27508 - /*
27509 - * Accessing the stack below %sp is always a bug.
27510 - * The large cushion allows instructions like enter
27511 - * and pusha to work. ("enter $65535, $31" pushes
27512 - * 32 pointers and then decrements %sp by 65535.)
27513 - */
27514 - if (unlikely(address + 65536 + 32 * sizeof(unsigned long) < regs->sp)) {
27515 - bad_area(regs, error_code, address);
27516 - return;
27517 - }
27518 + /*
27519 + * Accessing the stack below %sp is always a bug.
27520 + * The large cushion allows instructions like enter
27521 + * and pusha to work. ("enter $65535, $31" pushes
27522 + * 32 pointers and then decrements %sp by 65535.)
27523 + */
27524 + if (unlikely(address + 65536 + 32 * sizeof(unsigned long) < task_pt_regs(tsk)->sp)) {
27525 + bad_area(regs, error_code, address);
27526 + return;
27527 }
27528 +
27529 +#ifdef CONFIG_PAX_SEGMEXEC
27530 + if (unlikely((mm->pax_flags & MF_PAX_SEGMEXEC) && vma->vm_end - SEGMEXEC_TASK_SIZE - 1 < address - SEGMEXEC_TASK_SIZE - 1)) {
27531 + bad_area(regs, error_code, address);
27532 + return;
27533 + }
27534 +#endif
27535 +
27536 if (unlikely(expand_stack(vma, address))) {
27537 bad_area(regs, error_code, address);
27538 return;
27539 @@ -1232,3 +1452,292 @@ do_page_fault(struct pt_regs *regs, unsigned long error_code)
27540 __do_page_fault(regs, error_code);
27541 exception_exit(regs);
27542 }
27543 +
27544 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
27545 +static bool pax_is_fetch_fault(struct pt_regs *regs, unsigned long error_code, unsigned long address)
27546 +{
27547 + struct mm_struct *mm = current->mm;
27548 + unsigned long ip = regs->ip;
27549 +
27550 + if (v8086_mode(regs))
27551 + ip = ((regs->cs & 0xffff) << 4) + (ip & 0xffff);
27552 +
27553 +#ifdef CONFIG_PAX_PAGEEXEC
27554 + if (mm->pax_flags & MF_PAX_PAGEEXEC) {
27555 + if ((__supported_pte_mask & _PAGE_NX) && (error_code & PF_INSTR))
27556 + return true;
27557 + if (!(error_code & (PF_PROT | PF_WRITE)) && ip == address)
27558 + return true;
27559 + return false;
27560 + }
27561 +#endif
27562 +
27563 +#ifdef CONFIG_PAX_SEGMEXEC
27564 + if (mm->pax_flags & MF_PAX_SEGMEXEC) {
27565 + if (!(error_code & (PF_PROT | PF_WRITE)) && (ip + SEGMEXEC_TASK_SIZE == address))
27566 + return true;
27567 + return false;
27568 + }
27569 +#endif
27570 +
27571 + return false;
27572 +}
27573 +#endif
27574 +
27575 +#ifdef CONFIG_PAX_EMUTRAMP
27576 +static int pax_handle_fetch_fault_32(struct pt_regs *regs)
27577 +{
27578 + int err;
27579 +
27580 + do { /* PaX: libffi trampoline emulation */
27581 + unsigned char mov, jmp;
27582 + unsigned int addr1, addr2;
27583 +
27584 +#ifdef CONFIG_X86_64
27585 + if ((regs->ip + 9) >> 32)
27586 + break;
27587 +#endif
27588 +
27589 + err = get_user(mov, (unsigned char __user *)regs->ip);
27590 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 1));
27591 + err |= get_user(jmp, (unsigned char __user *)(regs->ip + 5));
27592 + err |= get_user(addr2, (unsigned int __user *)(regs->ip + 6));
27593 +
27594 + if (err)
27595 + break;
27596 +
27597 + if (mov == 0xB8 && jmp == 0xE9) {
27598 + regs->ax = addr1;
27599 + regs->ip = (unsigned int)(regs->ip + addr2 + 10);
27600 + return 2;
27601 + }
27602 + } while (0);
27603 +
27604 + do { /* PaX: gcc trampoline emulation #1 */
27605 + unsigned char mov1, mov2;
27606 + unsigned short jmp;
27607 + unsigned int addr1, addr2;
27608 +
27609 +#ifdef CONFIG_X86_64
27610 + if ((regs->ip + 11) >> 32)
27611 + break;
27612 +#endif
27613 +
27614 + err = get_user(mov1, (unsigned char __user *)regs->ip);
27615 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 1));
27616 + err |= get_user(mov2, (unsigned char __user *)(regs->ip + 5));
27617 + err |= get_user(addr2, (unsigned int __user *)(regs->ip + 6));
27618 + err |= get_user(jmp, (unsigned short __user *)(regs->ip + 10));
27619 +
27620 + if (err)
27621 + break;
27622 +
27623 + if (mov1 == 0xB9 && mov2 == 0xB8 && jmp == 0xE0FF) {
27624 + regs->cx = addr1;
27625 + regs->ax = addr2;
27626 + regs->ip = addr2;
27627 + return 2;
27628 + }
27629 + } while (0);
27630 +
27631 + do { /* PaX: gcc trampoline emulation #2 */
27632 + unsigned char mov, jmp;
27633 + unsigned int addr1, addr2;
27634 +
27635 +#ifdef CONFIG_X86_64
27636 + if ((regs->ip + 9) >> 32)
27637 + break;
27638 +#endif
27639 +
27640 + err = get_user(mov, (unsigned char __user *)regs->ip);
27641 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 1));
27642 + err |= get_user(jmp, (unsigned char __user *)(regs->ip + 5));
27643 + err |= get_user(addr2, (unsigned int __user *)(regs->ip + 6));
27644 +
27645 + if (err)
27646 + break;
27647 +
27648 + if (mov == 0xB9 && jmp == 0xE9) {
27649 + regs->cx = addr1;
27650 + regs->ip = (unsigned int)(regs->ip + addr2 + 10);
27651 + return 2;
27652 + }
27653 + } while (0);
27654 +
27655 + return 1; /* PaX in action */
27656 +}
27657 +
27658 +#ifdef CONFIG_X86_64
27659 +static int pax_handle_fetch_fault_64(struct pt_regs *regs)
27660 +{
27661 + int err;
27662 +
27663 + do { /* PaX: libffi trampoline emulation */
27664 + unsigned short mov1, mov2, jmp1;
27665 + unsigned char stcclc, jmp2;
27666 + unsigned long addr1, addr2;
27667 +
27668 + err = get_user(mov1, (unsigned short __user *)regs->ip);
27669 + err |= get_user(addr1, (unsigned long __user *)(regs->ip + 2));
27670 + err |= get_user(mov2, (unsigned short __user *)(regs->ip + 10));
27671 + err |= get_user(addr2, (unsigned long __user *)(regs->ip + 12));
27672 + err |= get_user(stcclc, (unsigned char __user *)(regs->ip + 20));
27673 + err |= get_user(jmp1, (unsigned short __user *)(regs->ip + 21));
27674 + err |= get_user(jmp2, (unsigned char __user *)(regs->ip + 23));
27675 +
27676 + if (err)
27677 + break;
27678 +
27679 + if (mov1 == 0xBB49 && mov2 == 0xBA49 && (stcclc == 0xF8 || stcclc == 0xF9) && jmp1 == 0xFF49 && jmp2 == 0xE3) {
27680 + regs->r11 = addr1;
27681 + regs->r10 = addr2;
27682 + if (stcclc == 0xF8)
27683 + regs->flags &= ~X86_EFLAGS_CF;
27684 + else
27685 + regs->flags |= X86_EFLAGS_CF;
27686 + regs->ip = addr1;
27687 + return 2;
27688 + }
27689 + } while (0);
27690 +
27691 + do { /* PaX: gcc trampoline emulation #1 */
27692 + unsigned short mov1, mov2, jmp1;
27693 + unsigned char jmp2;
27694 + unsigned int addr1;
27695 + unsigned long addr2;
27696 +
27697 + err = get_user(mov1, (unsigned short __user *)regs->ip);
27698 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 2));
27699 + err |= get_user(mov2, (unsigned short __user *)(regs->ip + 6));
27700 + err |= get_user(addr2, (unsigned long __user *)(regs->ip + 8));
27701 + err |= get_user(jmp1, (unsigned short __user *)(regs->ip + 16));
27702 + err |= get_user(jmp2, (unsigned char __user *)(regs->ip + 18));
27703 +
27704 + if (err)
27705 + break;
27706 +
27707 + if (mov1 == 0xBB41 && mov2 == 0xBA49 && jmp1 == 0xFF49 && jmp2 == 0xE3) {
27708 + regs->r11 = addr1;
27709 + regs->r10 = addr2;
27710 + regs->ip = addr1;
27711 + return 2;
27712 + }
27713 + } while (0);
27714 +
27715 + do { /* PaX: gcc trampoline emulation #2 */
27716 + unsigned short mov1, mov2, jmp1;
27717 + unsigned char jmp2;
27718 + unsigned long addr1, addr2;
27719 +
27720 + err = get_user(mov1, (unsigned short __user *)regs->ip);
27721 + err |= get_user(addr1, (unsigned long __user *)(regs->ip + 2));
27722 + err |= get_user(mov2, (unsigned short __user *)(regs->ip + 10));
27723 + err |= get_user(addr2, (unsigned long __user *)(regs->ip + 12));
27724 + err |= get_user(jmp1, (unsigned short __user *)(regs->ip + 20));
27725 + err |= get_user(jmp2, (unsigned char __user *)(regs->ip + 22));
27726 +
27727 + if (err)
27728 + break;
27729 +
27730 + if (mov1 == 0xBB49 && mov2 == 0xBA49 && jmp1 == 0xFF49 && jmp2 == 0xE3) {
27731 + regs->r11 = addr1;
27732 + regs->r10 = addr2;
27733 + regs->ip = addr1;
27734 + return 2;
27735 + }
27736 + } while (0);
27737 +
27738 + return 1; /* PaX in action */
27739 +}
27740 +#endif
27741 +
27742 +/*
27743 + * PaX: decide what to do with offenders (regs->ip = fault address)
27744 + *
27745 + * returns 1 when task should be killed
27746 + * 2 when gcc trampoline was detected
27747 + */
27748 +static int pax_handle_fetch_fault(struct pt_regs *regs)
27749 +{
27750 + if (v8086_mode(regs))
27751 + return 1;
27752 +
27753 + if (!(current->mm->pax_flags & MF_PAX_EMUTRAMP))
27754 + return 1;
27755 +
27756 +#ifdef CONFIG_X86_32
27757 + return pax_handle_fetch_fault_32(regs);
27758 +#else
27759 + if (regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT))
27760 + return pax_handle_fetch_fault_32(regs);
27761 + else
27762 + return pax_handle_fetch_fault_64(regs);
27763 +#endif
27764 +}
27765 +#endif
27766 +
27767 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
27768 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
27769 +{
27770 + long i;
27771 +
27772 + printk(KERN_ERR "PAX: bytes at PC: ");
27773 + for (i = 0; i < 20; i++) {
27774 + unsigned char c;
27775 + if (get_user(c, (unsigned char __force_user *)pc+i))
27776 + printk(KERN_CONT "?? ");
27777 + else
27778 + printk(KERN_CONT "%02x ", c);
27779 + }
27780 + printk("\n");
27781 +
27782 + printk(KERN_ERR "PAX: bytes at SP-%lu: ", (unsigned long)sizeof(long));
27783 + for (i = -1; i < 80 / (long)sizeof(long); i++) {
27784 + unsigned long c;
27785 + if (get_user(c, (unsigned long __force_user *)sp+i)) {
27786 +#ifdef CONFIG_X86_32
27787 + printk(KERN_CONT "???????? ");
27788 +#else
27789 + if ((regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT)))
27790 + printk(KERN_CONT "???????? ???????? ");
27791 + else
27792 + printk(KERN_CONT "???????????????? ");
27793 +#endif
27794 + } else {
27795 +#ifdef CONFIG_X86_64
27796 + if ((regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT))) {
27797 + printk(KERN_CONT "%08x ", (unsigned int)c);
27798 + printk(KERN_CONT "%08x ", (unsigned int)(c >> 32));
27799 + } else
27800 +#endif
27801 + printk(KERN_CONT "%0*lx ", 2 * (int)sizeof(long), c);
27802 + }
27803 + }
27804 + printk("\n");
27805 +}
27806 +#endif
27807 +
27808 +/**
27809 + * probe_kernel_write(): safely attempt to write to a location
27810 + * @dst: address to write to
27811 + * @src: pointer to the data that shall be written
27812 + * @size: size of the data chunk
27813 + *
27814 + * Safely write to address @dst from the buffer at @src. If a kernel fault
27815 + * happens, handle that and return -EFAULT.
27816 + */
27817 +long notrace probe_kernel_write(void *dst, const void *src, size_t size)
27818 +{
27819 + long ret;
27820 + mm_segment_t old_fs = get_fs();
27821 +
27822 + set_fs(KERNEL_DS);
27823 + pagefault_disable();
27824 + pax_open_kernel();
27825 + ret = __copy_to_user_inatomic((void __force_user *)dst, src, size);
27826 + pax_close_kernel();
27827 + pagefault_enable();
27828 + set_fs(old_fs);
27829 +
27830 + return ret ? -EFAULT : 0;
27831 +}
27832 diff --git a/arch/x86/mm/gup.c b/arch/x86/mm/gup.c
27833 index dd74e46..7d26398 100644
27834 --- a/arch/x86/mm/gup.c
27835 +++ b/arch/x86/mm/gup.c
27836 @@ -255,7 +255,7 @@ int __get_user_pages_fast(unsigned long start, int nr_pages, int write,
27837 addr = start;
27838 len = (unsigned long) nr_pages << PAGE_SHIFT;
27839 end = start + len;
27840 - if (unlikely(!access_ok(write ? VERIFY_WRITE : VERIFY_READ,
27841 + if (unlikely(!__access_ok(write ? VERIFY_WRITE : VERIFY_READ,
27842 (void __user *)start, len)))
27843 return 0;
27844
27845 diff --git a/arch/x86/mm/highmem_32.c b/arch/x86/mm/highmem_32.c
27846 index 6f31ee5..8ee4164 100644
27847 --- a/arch/x86/mm/highmem_32.c
27848 +++ b/arch/x86/mm/highmem_32.c
27849 @@ -44,7 +44,11 @@ void *kmap_atomic_prot(struct page *page, pgprot_t prot)
27850 idx = type + KM_TYPE_NR*smp_processor_id();
27851 vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx);
27852 BUG_ON(!pte_none(*(kmap_pte-idx)));
27853 +
27854 + pax_open_kernel();
27855 set_pte(kmap_pte-idx, mk_pte(page, prot));
27856 + pax_close_kernel();
27857 +
27858 arch_flush_lazy_mmu_mode();
27859
27860 return (void *)vaddr;
27861 diff --git a/arch/x86/mm/hugetlbpage.c b/arch/x86/mm/hugetlbpage.c
27862 index ae1aa71..56316db 100644
27863 --- a/arch/x86/mm/hugetlbpage.c
27864 +++ b/arch/x86/mm/hugetlbpage.c
27865 @@ -279,6 +279,12 @@ static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *file,
27866 info.flags = 0;
27867 info.length = len;
27868 info.low_limit = TASK_UNMAPPED_BASE;
27869 +
27870 +#ifdef CONFIG_PAX_RANDMMAP
27871 + if (current->mm->pax_flags & MF_PAX_RANDMMAP)
27872 + info.low_limit += current->mm->delta_mmap;
27873 +#endif
27874 +
27875 info.high_limit = TASK_SIZE;
27876 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
27877 info.align_offset = 0;
27878 @@ -311,6 +317,12 @@ static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
27879 VM_BUG_ON(addr != -ENOMEM);
27880 info.flags = 0;
27881 info.low_limit = TASK_UNMAPPED_BASE;
27882 +
27883 +#ifdef CONFIG_PAX_RANDMMAP
27884 + if (current->mm->pax_flags & MF_PAX_RANDMMAP)
27885 + info.low_limit += current->mm->delta_mmap;
27886 +#endif
27887 +
27888 info.high_limit = TASK_SIZE;
27889 addr = vm_unmapped_area(&info);
27890 }
27891 @@ -325,10 +337,20 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
27892 struct hstate *h = hstate_file(file);
27893 struct mm_struct *mm = current->mm;
27894 struct vm_area_struct *vma;
27895 + unsigned long pax_task_size = TASK_SIZE;
27896 + unsigned long offset = gr_rand_threadstack_offset(mm, file, flags);
27897
27898 if (len & ~huge_page_mask(h))
27899 return -EINVAL;
27900 - if (len > TASK_SIZE)
27901 +
27902 +#ifdef CONFIG_PAX_SEGMEXEC
27903 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
27904 + pax_task_size = SEGMEXEC_TASK_SIZE;
27905 +#endif
27906 +
27907 + pax_task_size -= PAGE_SIZE;
27908 +
27909 + if (len > pax_task_size)
27910 return -ENOMEM;
27911
27912 if (flags & MAP_FIXED) {
27913 @@ -337,11 +359,14 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
27914 return addr;
27915 }
27916
27917 +#ifdef CONFIG_PAX_RANDMMAP
27918 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
27919 +#endif
27920 +
27921 if (addr) {
27922 addr = ALIGN(addr, huge_page_size(h));
27923 vma = find_vma(mm, addr);
27924 - if (TASK_SIZE - len >= addr &&
27925 - (!vma || addr + len <= vma->vm_start))
27926 + if (pax_task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
27927 return addr;
27928 }
27929 if (mm->get_unmapped_area == arch_get_unmapped_area)
27930 diff --git a/arch/x86/mm/init.c b/arch/x86/mm/init.c
27931 index d7aea41..0fc945b 100644
27932 --- a/arch/x86/mm/init.c
27933 +++ b/arch/x86/mm/init.c
27934 @@ -4,6 +4,7 @@
27935 #include <linux/swap.h>
27936 #include <linux/memblock.h>
27937 #include <linux/bootmem.h> /* for max_low_pfn */
27938 +#include <linux/tboot.h>
27939
27940 #include <asm/cacheflush.h>
27941 #include <asm/e820.h>
27942 @@ -16,6 +17,8 @@
27943 #include <asm/tlb.h>
27944 #include <asm/proto.h>
27945 #include <asm/dma.h> /* for MAX_DMA_PFN */
27946 +#include <asm/desc.h>
27947 +#include <asm/bios_ebda.h>
27948
27949 unsigned long __initdata pgt_buf_start;
27950 unsigned long __meminitdata pgt_buf_end;
27951 @@ -44,7 +47,7 @@ static void __init find_early_table_space(struct map_range *mr, int nr_range)
27952 {
27953 int i;
27954 unsigned long puds = 0, pmds = 0, ptes = 0, tables;
27955 - unsigned long start = 0, good_end;
27956 + unsigned long start = 0x100000, good_end;
27957 phys_addr_t base;
27958
27959 for (i = 0; i < nr_range; i++) {
27960 @@ -321,10 +324,40 @@ unsigned long __init_refok init_memory_mapping(unsigned long start,
27961 * Access has to be given to non-kernel-ram areas as well, these contain the PCI
27962 * mmio resources as well as potential bios/acpi data regions.
27963 */
27964 +
27965 +#ifdef CONFIG_GRKERNSEC_KMEM
27966 +static unsigned int ebda_start __read_only;
27967 +static unsigned int ebda_end __read_only;
27968 +#endif
27969 +
27970 int devmem_is_allowed(unsigned long pagenr)
27971 {
27972 - if (pagenr < 256)
27973 +#ifdef CONFIG_GRKERNSEC_KMEM
27974 + /* allow BDA */
27975 + if (!pagenr)
27976 return 1;
27977 + /* allow EBDA */
27978 + if (pagenr >= ebda_start && pagenr < ebda_end)
27979 + return 1;
27980 + /* if tboot is in use, allow access to its hardcoded serial log range */
27981 + if (tboot_enabled() && ((0x60000 >> PAGE_SHIFT) <= pagenr) && (pagenr < (0x68000 >> PAGE_SHIFT)))
27982 + return 1;
27983 +#else
27984 + if (!pagenr)
27985 + return 1;
27986 +#ifdef CONFIG_VM86
27987 + if (pagenr < (ISA_START_ADDRESS >> PAGE_SHIFT))
27988 + return 1;
27989 +#endif
27990 +#endif
27991 +
27992 + if ((ISA_START_ADDRESS >> PAGE_SHIFT) <= pagenr && pagenr < (ISA_END_ADDRESS >> PAGE_SHIFT))
27993 + return 1;
27994 +#ifdef CONFIG_GRKERNSEC_KMEM
27995 + /* throw out everything else below 1MB */
27996 + if (pagenr <= 256)
27997 + return 0;
27998 +#endif
27999 if (iomem_is_exclusive(pagenr << PAGE_SHIFT))
28000 return 0;
28001 if (!page_is_ram(pagenr))
28002 @@ -381,8 +414,117 @@ void free_init_pages(char *what, unsigned long begin, unsigned long end)
28003 #endif
28004 }
28005
28006 +#ifdef CONFIG_GRKERNSEC_KMEM
28007 +static inline void gr_init_ebda(void)
28008 +{
28009 + unsigned int ebda_addr;
28010 + unsigned int ebda_size = 0;
28011 +
28012 + ebda_addr = get_bios_ebda();
28013 + if (ebda_addr) {
28014 + ebda_size = *(unsigned char *)phys_to_virt(ebda_addr);
28015 + ebda_size <<= 10;
28016 + }
28017 + if (ebda_addr && ebda_size) {
28018 + ebda_start = ebda_addr >> PAGE_SHIFT;
28019 + ebda_end = min((unsigned int)PAGE_ALIGN(ebda_addr + ebda_size), (unsigned int)0xa0000) >> PAGE_SHIFT;
28020 + } else {
28021 + ebda_start = 0x9f000 >> PAGE_SHIFT;
28022 + ebda_end = 0xa0000 >> PAGE_SHIFT;
28023 + }
28024 +}
28025 +#else
28026 +static inline void gr_init_ebda(void) { }
28027 +#endif
28028 +
28029 void free_initmem(void)
28030 {
28031 +#ifdef CONFIG_PAX_KERNEXEC
28032 +#ifdef CONFIG_X86_32
28033 + /* PaX: limit KERNEL_CS to actual size */
28034 + unsigned long addr, limit;
28035 + struct desc_struct d;
28036 + int cpu;
28037 +#else
28038 + pgd_t *pgd;
28039 + pud_t *pud;
28040 + pmd_t *pmd;
28041 + unsigned long addr, end;
28042 +#endif
28043 +#endif
28044 +
28045 + gr_init_ebda();
28046 +
28047 +#ifdef CONFIG_PAX_KERNEXEC
28048 +#ifdef CONFIG_X86_32
28049 + limit = paravirt_enabled() ? ktva_ktla(0xffffffff) : (unsigned long)&_etext;
28050 + limit = (limit - 1UL) >> PAGE_SHIFT;
28051 +
28052 + memset(__LOAD_PHYSICAL_ADDR + PAGE_OFFSET, POISON_FREE_INITMEM, PAGE_SIZE);
28053 + for (cpu = 0; cpu < nr_cpu_ids; cpu++) {
28054 + pack_descriptor(&d, get_desc_base(&get_cpu_gdt_table(cpu)[GDT_ENTRY_KERNEL_CS]), limit, 0x9B, 0xC);
28055 + write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_KERNEL_CS, &d, DESCTYPE_S);
28056 + write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_KERNEXEC_KERNEL_CS, &d, DESCTYPE_S);
28057 + }
28058 +
28059 + /* PaX: make KERNEL_CS read-only */
28060 + addr = PFN_ALIGN(ktla_ktva((unsigned long)&_text));
28061 + if (!paravirt_enabled())
28062 + set_memory_ro(addr, (PFN_ALIGN(_sdata) - addr) >> PAGE_SHIFT);
28063 +/*
28064 + for (addr = ktla_ktva((unsigned long)&_text); addr < (unsigned long)&_sdata; addr += PMD_SIZE) {
28065 + pgd = pgd_offset_k(addr);
28066 + pud = pud_offset(pgd, addr);
28067 + pmd = pmd_offset(pud, addr);
28068 + set_pmd(pmd, __pmd(pmd_val(*pmd) & ~_PAGE_RW));
28069 + }
28070 +*/
28071 +#ifdef CONFIG_X86_PAE
28072 + set_memory_nx(PFN_ALIGN(__init_begin), (PFN_ALIGN(__init_end) - PFN_ALIGN(__init_begin)) >> PAGE_SHIFT);
28073 +/*
28074 + for (addr = (unsigned long)&__init_begin; addr < (unsigned long)&__init_end; addr += PMD_SIZE) {
28075 + pgd = pgd_offset_k(addr);
28076 + pud = pud_offset(pgd, addr);
28077 + pmd = pmd_offset(pud, addr);
28078 + set_pmd(pmd, __pmd(pmd_val(*pmd) | (_PAGE_NX & __supported_pte_mask)));
28079 + }
28080 +*/
28081 +#endif
28082 +
28083 +#ifdef CONFIG_MODULES
28084 + set_memory_4k((unsigned long)MODULES_EXEC_VADDR, (MODULES_EXEC_END - MODULES_EXEC_VADDR) >> PAGE_SHIFT);
28085 +#endif
28086 +
28087 +#else
28088 + /* PaX: make kernel code/rodata read-only, rest non-executable */
28089 + for (addr = __START_KERNEL_map; addr < __START_KERNEL_map + KERNEL_IMAGE_SIZE; addr += PMD_SIZE) {
28090 + pgd = pgd_offset_k(addr);
28091 + pud = pud_offset(pgd, addr);
28092 + pmd = pmd_offset(pud, addr);
28093 + if (!pmd_present(*pmd))
28094 + continue;
28095 + if ((unsigned long)_text <= addr && addr < (unsigned long)_sdata)
28096 + set_pmd(pmd, __pmd(pmd_val(*pmd) & ~_PAGE_RW));
28097 + else
28098 + set_pmd(pmd, __pmd(pmd_val(*pmd) | (_PAGE_NX & __supported_pte_mask)));
28099 + }
28100 +
28101 + addr = (unsigned long)__va(__pa(__START_KERNEL_map));
28102 + end = addr + KERNEL_IMAGE_SIZE;
28103 + for (; addr < end; addr += PMD_SIZE) {
28104 + pgd = pgd_offset_k(addr);
28105 + pud = pud_offset(pgd, addr);
28106 + pmd = pmd_offset(pud, addr);
28107 + if (!pmd_present(*pmd))
28108 + continue;
28109 + if ((unsigned long)__va(__pa(_text)) <= addr && addr < (unsigned long)__va(__pa(_sdata)))
28110 + set_pmd(pmd, __pmd(pmd_val(*pmd) & ~_PAGE_RW));
28111 + }
28112 +#endif
28113 +
28114 + flush_tlb_all();
28115 +#endif
28116 +
28117 free_init_pages("unused kernel memory",
28118 (unsigned long)(&__init_begin),
28119 (unsigned long)(&__init_end));
28120 diff --git a/arch/x86/mm/init_32.c b/arch/x86/mm/init_32.c
28121 index 745d66b..56bf568 100644
28122 --- a/arch/x86/mm/init_32.c
28123 +++ b/arch/x86/mm/init_32.c
28124 @@ -73,36 +73,6 @@ static __init void *alloc_low_page(void)
28125 }
28126
28127 /*
28128 - * Creates a middle page table and puts a pointer to it in the
28129 - * given global directory entry. This only returns the gd entry
28130 - * in non-PAE compilation mode, since the middle layer is folded.
28131 - */
28132 -static pmd_t * __init one_md_table_init(pgd_t *pgd)
28133 -{
28134 - pud_t *pud;
28135 - pmd_t *pmd_table;
28136 -
28137 -#ifdef CONFIG_X86_PAE
28138 - if (!(pgd_val(*pgd) & _PAGE_PRESENT)) {
28139 - if (after_bootmem)
28140 - pmd_table = (pmd_t *)alloc_bootmem_pages(PAGE_SIZE);
28141 - else
28142 - pmd_table = (pmd_t *)alloc_low_page();
28143 - paravirt_alloc_pmd(&init_mm, __pa(pmd_table) >> PAGE_SHIFT);
28144 - set_pgd(pgd, __pgd(__pa(pmd_table) | _PAGE_PRESENT));
28145 - pud = pud_offset(pgd, 0);
28146 - BUG_ON(pmd_table != pmd_offset(pud, 0));
28147 -
28148 - return pmd_table;
28149 - }
28150 -#endif
28151 - pud = pud_offset(pgd, 0);
28152 - pmd_table = pmd_offset(pud, 0);
28153 -
28154 - return pmd_table;
28155 -}
28156 -
28157 -/*
28158 * Create a page table and place a pointer to it in a middle page
28159 * directory entry:
28160 */
28161 @@ -122,13 +92,28 @@ static pte_t * __init one_page_table_init(pmd_t *pmd)
28162 page_table = (pte_t *)alloc_low_page();
28163
28164 paravirt_alloc_pte(&init_mm, __pa(page_table) >> PAGE_SHIFT);
28165 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
28166 + set_pmd(pmd, __pmd(__pa(page_table) | _KERNPG_TABLE));
28167 +#else
28168 set_pmd(pmd, __pmd(__pa(page_table) | _PAGE_TABLE));
28169 +#endif
28170 BUG_ON(page_table != pte_offset_kernel(pmd, 0));
28171 }
28172
28173 return pte_offset_kernel(pmd, 0);
28174 }
28175
28176 +static pmd_t * __init one_md_table_init(pgd_t *pgd)
28177 +{
28178 + pud_t *pud;
28179 + pmd_t *pmd_table;
28180 +
28181 + pud = pud_offset(pgd, 0);
28182 + pmd_table = pmd_offset(pud, 0);
28183 +
28184 + return pmd_table;
28185 +}
28186 +
28187 pmd_t * __init populate_extra_pmd(unsigned long vaddr)
28188 {
28189 int pgd_idx = pgd_index(vaddr);
28190 @@ -202,6 +187,7 @@ page_table_range_init(unsigned long start, unsigned long end, pgd_t *pgd_base)
28191 int pgd_idx, pmd_idx;
28192 unsigned long vaddr;
28193 pgd_t *pgd;
28194 + pud_t *pud;
28195 pmd_t *pmd;
28196 pte_t *pte = NULL;
28197
28198 @@ -211,8 +197,13 @@ page_table_range_init(unsigned long start, unsigned long end, pgd_t *pgd_base)
28199 pgd = pgd_base + pgd_idx;
28200
28201 for ( ; (pgd_idx < PTRS_PER_PGD) && (vaddr != end); pgd++, pgd_idx++) {
28202 - pmd = one_md_table_init(pgd);
28203 - pmd = pmd + pmd_index(vaddr);
28204 + pud = pud_offset(pgd, vaddr);
28205 + pmd = pmd_offset(pud, vaddr);
28206 +
28207 +#ifdef CONFIG_X86_PAE
28208 + paravirt_alloc_pmd(&init_mm, __pa(pmd) >> PAGE_SHIFT);
28209 +#endif
28210 +
28211 for (; (pmd_idx < PTRS_PER_PMD) && (vaddr != end);
28212 pmd++, pmd_idx++) {
28213 pte = page_table_kmap_check(one_page_table_init(pmd),
28214 @@ -224,11 +215,20 @@ page_table_range_init(unsigned long start, unsigned long end, pgd_t *pgd_base)
28215 }
28216 }
28217
28218 -static inline int is_kernel_text(unsigned long addr)
28219 +static inline int is_kernel_text(unsigned long start, unsigned long end)
28220 {
28221 - if (addr >= (unsigned long)_text && addr <= (unsigned long)__init_end)
28222 - return 1;
28223 - return 0;
28224 + if ((start > ktla_ktva((unsigned long)_etext) ||
28225 + end <= ktla_ktva((unsigned long)_stext)) &&
28226 + (start > ktla_ktva((unsigned long)_einittext) ||
28227 + end <= ktla_ktva((unsigned long)_sinittext)) &&
28228 +
28229 +#ifdef CONFIG_ACPI_SLEEP
28230 + (start > (unsigned long)__va(acpi_wakeup_address) + 0x4000 || end <= (unsigned long)__va(acpi_wakeup_address)) &&
28231 +#endif
28232 +
28233 + (start > (unsigned long)__va(0xfffff) || end <= (unsigned long)__va(0xc0000)))
28234 + return 0;
28235 + return 1;
28236 }
28237
28238 /*
28239 @@ -245,9 +245,10 @@ kernel_physical_mapping_init(unsigned long start,
28240 unsigned long last_map_addr = end;
28241 unsigned long start_pfn, end_pfn;
28242 pgd_t *pgd_base = swapper_pg_dir;
28243 - int pgd_idx, pmd_idx, pte_ofs;
28244 + unsigned int pgd_idx, pmd_idx, pte_ofs;
28245 unsigned long pfn;
28246 pgd_t *pgd;
28247 + pud_t *pud;
28248 pmd_t *pmd;
28249 pte_t *pte;
28250 unsigned pages_2m, pages_4k;
28251 @@ -280,8 +281,13 @@ repeat:
28252 pfn = start_pfn;
28253 pgd_idx = pgd_index((pfn<<PAGE_SHIFT) + PAGE_OFFSET);
28254 pgd = pgd_base + pgd_idx;
28255 - for (; pgd_idx < PTRS_PER_PGD; pgd++, pgd_idx++) {
28256 - pmd = one_md_table_init(pgd);
28257 + for (; pgd_idx < PTRS_PER_PGD && pfn < max_low_pfn; pgd++, pgd_idx++) {
28258 + pud = pud_offset(pgd, 0);
28259 + pmd = pmd_offset(pud, 0);
28260 +
28261 +#ifdef CONFIG_X86_PAE
28262 + paravirt_alloc_pmd(&init_mm, __pa(pmd) >> PAGE_SHIFT);
28263 +#endif
28264
28265 if (pfn >= end_pfn)
28266 continue;
28267 @@ -293,14 +299,13 @@ repeat:
28268 #endif
28269 for (; pmd_idx < PTRS_PER_PMD && pfn < end_pfn;
28270 pmd++, pmd_idx++) {
28271 - unsigned int addr = pfn * PAGE_SIZE + PAGE_OFFSET;
28272 + unsigned long address = pfn * PAGE_SIZE + PAGE_OFFSET;
28273
28274 /*
28275 * Map with big pages if possible, otherwise
28276 * create normal page tables:
28277 */
28278 if (use_pse) {
28279 - unsigned int addr2;
28280 pgprot_t prot = PAGE_KERNEL_LARGE;
28281 /*
28282 * first pass will use the same initial
28283 @@ -310,11 +315,7 @@ repeat:
28284 __pgprot(PTE_IDENT_ATTR |
28285 _PAGE_PSE);
28286
28287 - addr2 = (pfn + PTRS_PER_PTE-1) * PAGE_SIZE +
28288 - PAGE_OFFSET + PAGE_SIZE-1;
28289 -
28290 - if (is_kernel_text(addr) ||
28291 - is_kernel_text(addr2))
28292 + if (is_kernel_text(address, address + PMD_SIZE))
28293 prot = PAGE_KERNEL_LARGE_EXEC;
28294
28295 pages_2m++;
28296 @@ -331,7 +332,7 @@ repeat:
28297 pte_ofs = pte_index((pfn<<PAGE_SHIFT) + PAGE_OFFSET);
28298 pte += pte_ofs;
28299 for (; pte_ofs < PTRS_PER_PTE && pfn < end_pfn;
28300 - pte++, pfn++, pte_ofs++, addr += PAGE_SIZE) {
28301 + pte++, pfn++, pte_ofs++, address += PAGE_SIZE) {
28302 pgprot_t prot = PAGE_KERNEL;
28303 /*
28304 * first pass will use the same initial
28305 @@ -339,7 +340,7 @@ repeat:
28306 */
28307 pgprot_t init_prot = __pgprot(PTE_IDENT_ATTR);
28308
28309 - if (is_kernel_text(addr))
28310 + if (is_kernel_text(address, address + PAGE_SIZE))
28311 prot = PAGE_KERNEL_EXEC;
28312
28313 pages_4k++;
28314 @@ -465,7 +466,7 @@ void __init native_pagetable_init(void)
28315
28316 pud = pud_offset(pgd, va);
28317 pmd = pmd_offset(pud, va);
28318 - if (!pmd_present(*pmd))
28319 + if (!pmd_present(*pmd) || pmd_huge(*pmd))
28320 break;
28321
28322 pte = pte_offset_kernel(pmd, va);
28323 @@ -514,12 +515,10 @@ void __init early_ioremap_page_table_range_init(void)
28324
28325 static void __init pagetable_init(void)
28326 {
28327 - pgd_t *pgd_base = swapper_pg_dir;
28328 -
28329 - permanent_kmaps_init(pgd_base);
28330 + permanent_kmaps_init(swapper_pg_dir);
28331 }
28332
28333 -pteval_t __supported_pte_mask __read_mostly = ~(_PAGE_NX | _PAGE_GLOBAL | _PAGE_IOMAP);
28334 +pteval_t __supported_pte_mask __read_only = ~(_PAGE_NX | _PAGE_GLOBAL | _PAGE_IOMAP);
28335 EXPORT_SYMBOL_GPL(__supported_pte_mask);
28336
28337 /* user-defined highmem size */
28338 @@ -728,6 +727,12 @@ void __init mem_init(void)
28339
28340 pci_iommu_alloc();
28341
28342 +#ifdef CONFIG_PAX_PER_CPU_PGD
28343 + clone_pgd_range(get_cpu_pgd(0) + KERNEL_PGD_BOUNDARY,
28344 + swapper_pg_dir + KERNEL_PGD_BOUNDARY,
28345 + KERNEL_PGD_PTRS);
28346 +#endif
28347 +
28348 #ifdef CONFIG_FLATMEM
28349 BUG_ON(!mem_map);
28350 #endif
28351 @@ -754,7 +759,7 @@ void __init mem_init(void)
28352 reservedpages++;
28353
28354 codesize = (unsigned long) &_etext - (unsigned long) &_text;
28355 - datasize = (unsigned long) &_edata - (unsigned long) &_etext;
28356 + datasize = (unsigned long) &_edata - (unsigned long) &_sdata;
28357 initsize = (unsigned long) &__init_end - (unsigned long) &__init_begin;
28358
28359 printk(KERN_INFO "Memory: %luk/%luk available (%dk kernel code, "
28360 @@ -795,10 +800,10 @@ void __init mem_init(void)
28361 ((unsigned long)&__init_end -
28362 (unsigned long)&__init_begin) >> 10,
28363
28364 - (unsigned long)&_etext, (unsigned long)&_edata,
28365 - ((unsigned long)&_edata - (unsigned long)&_etext) >> 10,
28366 + (unsigned long)&_sdata, (unsigned long)&_edata,
28367 + ((unsigned long)&_edata - (unsigned long)&_sdata) >> 10,
28368
28369 - (unsigned long)&_text, (unsigned long)&_etext,
28370 + ktla_ktva((unsigned long)&_text), ktla_ktva((unsigned long)&_etext),
28371 ((unsigned long)&_etext - (unsigned long)&_text) >> 10);
28372
28373 /*
28374 @@ -876,6 +881,7 @@ void set_kernel_text_rw(void)
28375 if (!kernel_set_to_readonly)
28376 return;
28377
28378 + start = ktla_ktva(start);
28379 pr_debug("Set kernel text: %lx - %lx for read write\n",
28380 start, start+size);
28381
28382 @@ -890,6 +896,7 @@ void set_kernel_text_ro(void)
28383 if (!kernel_set_to_readonly)
28384 return;
28385
28386 + start = ktla_ktva(start);
28387 pr_debug("Set kernel text: %lx - %lx for read only\n",
28388 start, start+size);
28389
28390 @@ -918,6 +925,7 @@ void mark_rodata_ro(void)
28391 unsigned long start = PFN_ALIGN(_text);
28392 unsigned long size = PFN_ALIGN(_etext) - start;
28393
28394 + start = ktla_ktva(start);
28395 set_pages_ro(virt_to_page(start), size >> PAGE_SHIFT);
28396 printk(KERN_INFO "Write protecting the kernel text: %luk\n",
28397 size >> 10);
28398 diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
28399 index 75c9a6a..498d677 100644
28400 --- a/arch/x86/mm/init_64.c
28401 +++ b/arch/x86/mm/init_64.c
28402 @@ -74,7 +74,7 @@ early_param("gbpages", parse_direct_gbpages_on);
28403 * around without checking the pgd every time.
28404 */
28405
28406 -pteval_t __supported_pte_mask __read_mostly = ~_PAGE_IOMAP;
28407 +pteval_t __supported_pte_mask __read_only = ~(_PAGE_NX | _PAGE_IOMAP);
28408 EXPORT_SYMBOL_GPL(__supported_pte_mask);
28409
28410 int force_personality32;
28411 @@ -107,12 +107,22 @@ void sync_global_pgds(unsigned long start, unsigned long end)
28412
28413 for (address = start; address <= end; address += PGDIR_SIZE) {
28414 const pgd_t *pgd_ref = pgd_offset_k(address);
28415 +
28416 +#ifdef CONFIG_PAX_PER_CPU_PGD
28417 + unsigned long cpu;
28418 +#else
28419 struct page *page;
28420 +#endif
28421
28422 if (pgd_none(*pgd_ref))
28423 continue;
28424
28425 spin_lock(&pgd_lock);
28426 +
28427 +#ifdef CONFIG_PAX_PER_CPU_PGD
28428 + for (cpu = 0; cpu < nr_cpu_ids; ++cpu) {
28429 + pgd_t *pgd = pgd_offset_cpu(cpu, address);
28430 +#else
28431 list_for_each_entry(page, &pgd_list, lru) {
28432 pgd_t *pgd;
28433 spinlock_t *pgt_lock;
28434 @@ -121,6 +131,7 @@ void sync_global_pgds(unsigned long start, unsigned long end)
28435 /* the pgt_lock only for Xen */
28436 pgt_lock = &pgd_page_get_mm(page)->page_table_lock;
28437 spin_lock(pgt_lock);
28438 +#endif
28439
28440 if (pgd_none(*pgd))
28441 set_pgd(pgd, *pgd_ref);
28442 @@ -128,7 +139,10 @@ void sync_global_pgds(unsigned long start, unsigned long end)
28443 BUG_ON(pgd_page_vaddr(*pgd)
28444 != pgd_page_vaddr(*pgd_ref));
28445
28446 +#ifndef CONFIG_PAX_PER_CPU_PGD
28447 spin_unlock(pgt_lock);
28448 +#endif
28449 +
28450 }
28451 spin_unlock(&pgd_lock);
28452 }
28453 @@ -161,7 +175,7 @@ static pud_t *fill_pud(pgd_t *pgd, unsigned long vaddr)
28454 {
28455 if (pgd_none(*pgd)) {
28456 pud_t *pud = (pud_t *)spp_getpage();
28457 - pgd_populate(&init_mm, pgd, pud);
28458 + pgd_populate_kernel(&init_mm, pgd, pud);
28459 if (pud != pud_offset(pgd, 0))
28460 printk(KERN_ERR "PAGETABLE BUG #00! %p <-> %p\n",
28461 pud, pud_offset(pgd, 0));
28462 @@ -173,7 +187,7 @@ static pmd_t *fill_pmd(pud_t *pud, unsigned long vaddr)
28463 {
28464 if (pud_none(*pud)) {
28465 pmd_t *pmd = (pmd_t *) spp_getpage();
28466 - pud_populate(&init_mm, pud, pmd);
28467 + pud_populate_kernel(&init_mm, pud, pmd);
28468 if (pmd != pmd_offset(pud, 0))
28469 printk(KERN_ERR "PAGETABLE BUG #01! %p <-> %p\n",
28470 pmd, pmd_offset(pud, 0));
28471 @@ -202,7 +216,9 @@ void set_pte_vaddr_pud(pud_t *pud_page, unsigned long vaddr, pte_t new_pte)
28472 pmd = fill_pmd(pud, vaddr);
28473 pte = fill_pte(pmd, vaddr);
28474
28475 + pax_open_kernel();
28476 set_pte(pte, new_pte);
28477 + pax_close_kernel();
28478
28479 /*
28480 * It's enough to flush this one mapping.
28481 @@ -261,14 +277,12 @@ static void __init __init_extra_mapping(unsigned long phys, unsigned long size,
28482 pgd = pgd_offset_k((unsigned long)__va(phys));
28483 if (pgd_none(*pgd)) {
28484 pud = (pud_t *) spp_getpage();
28485 - set_pgd(pgd, __pgd(__pa(pud) | _KERNPG_TABLE |
28486 - _PAGE_USER));
28487 + set_pgd(pgd, __pgd(__pa(pud) | _PAGE_TABLE));
28488 }
28489 pud = pud_offset(pgd, (unsigned long)__va(phys));
28490 if (pud_none(*pud)) {
28491 pmd = (pmd_t *) spp_getpage();
28492 - set_pud(pud, __pud(__pa(pmd) | _KERNPG_TABLE |
28493 - _PAGE_USER));
28494 + set_pud(pud, __pud(__pa(pmd) | _PAGE_TABLE));
28495 }
28496 pmd = pmd_offset(pud, phys);
28497 BUG_ON(!pmd_none(*pmd));
28498 @@ -329,7 +343,7 @@ static __ref void *alloc_low_page(unsigned long *phys)
28499 if (pfn >= pgt_buf_top)
28500 panic("alloc_low_page: ran out of memory");
28501
28502 - adr = early_memremap(pfn * PAGE_SIZE, PAGE_SIZE);
28503 + adr = (void __force_kernel *)early_memremap(pfn * PAGE_SIZE, PAGE_SIZE);
28504 clear_page(adr);
28505 *phys = pfn * PAGE_SIZE;
28506 return adr;
28507 @@ -345,7 +359,7 @@ static __ref void *map_low_page(void *virt)
28508
28509 phys = __pa(virt);
28510 left = phys & (PAGE_SIZE - 1);
28511 - adr = early_memremap(phys & PAGE_MASK, PAGE_SIZE);
28512 + adr = (void __force_kernel *)early_memremap(phys & PAGE_MASK, PAGE_SIZE);
28513 adr = (void *)(((unsigned long)adr) | left);
28514
28515 return adr;
28516 @@ -553,7 +567,7 @@ phys_pud_init(pud_t *pud_page, unsigned long addr, unsigned long end,
28517 unmap_low_page(pmd);
28518
28519 spin_lock(&init_mm.page_table_lock);
28520 - pud_populate(&init_mm, pud, __va(pmd_phys));
28521 + pud_populate_kernel(&init_mm, pud, __va(pmd_phys));
28522 spin_unlock(&init_mm.page_table_lock);
28523 }
28524 __flush_tlb_all();
28525 @@ -599,7 +613,7 @@ kernel_physical_mapping_init(unsigned long start,
28526 unmap_low_page(pud);
28527
28528 spin_lock(&init_mm.page_table_lock);
28529 - pgd_populate(&init_mm, pgd, __va(pud_phys));
28530 + pgd_populate_kernel(&init_mm, pgd, __va(pud_phys));
28531 spin_unlock(&init_mm.page_table_lock);
28532 pgd_changed = true;
28533 }
28534 @@ -693,6 +707,12 @@ void __init mem_init(void)
28535
28536 pci_iommu_alloc();
28537
28538 +#ifdef CONFIG_PAX_PER_CPU_PGD
28539 + clone_pgd_range(get_cpu_pgd(0) + KERNEL_PGD_BOUNDARY,
28540 + swapper_pg_dir + KERNEL_PGD_BOUNDARY,
28541 + KERNEL_PGD_PTRS);
28542 +#endif
28543 +
28544 /* clear_bss() already clear the empty_zero_page */
28545
28546 reservedpages = 0;
28547 @@ -856,8 +876,8 @@ int kern_addr_valid(unsigned long addr)
28548 static struct vm_area_struct gate_vma = {
28549 .vm_start = VSYSCALL_START,
28550 .vm_end = VSYSCALL_START + (VSYSCALL_MAPPED_PAGES * PAGE_SIZE),
28551 - .vm_page_prot = PAGE_READONLY_EXEC,
28552 - .vm_flags = VM_READ | VM_EXEC
28553 + .vm_page_prot = PAGE_READONLY,
28554 + .vm_flags = VM_READ
28555 };
28556
28557 struct vm_area_struct *get_gate_vma(struct mm_struct *mm)
28558 @@ -891,7 +911,7 @@ int in_gate_area_no_mm(unsigned long addr)
28559
28560 const char *arch_vma_name(struct vm_area_struct *vma)
28561 {
28562 - if (vma->vm_mm && vma->vm_start == (long)vma->vm_mm->context.vdso)
28563 + if (vma->vm_mm && vma->vm_start == vma->vm_mm->context.vdso)
28564 return "[vdso]";
28565 if (vma == &gate_vma)
28566 return "[vsyscall]";
28567 diff --git a/arch/x86/mm/iomap_32.c b/arch/x86/mm/iomap_32.c
28568 index 7b179b4..6bd1777 100644
28569 --- a/arch/x86/mm/iomap_32.c
28570 +++ b/arch/x86/mm/iomap_32.c
28571 @@ -64,7 +64,11 @@ void *kmap_atomic_prot_pfn(unsigned long pfn, pgprot_t prot)
28572 type = kmap_atomic_idx_push();
28573 idx = type + KM_TYPE_NR * smp_processor_id();
28574 vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx);
28575 +
28576 + pax_open_kernel();
28577 set_pte(kmap_pte - idx, pfn_pte(pfn, prot));
28578 + pax_close_kernel();
28579 +
28580 arch_flush_lazy_mmu_mode();
28581
28582 return (void *)vaddr;
28583 diff --git a/arch/x86/mm/ioremap.c b/arch/x86/mm/ioremap.c
28584 index 78fe3f1..2f9433c 100644
28585 --- a/arch/x86/mm/ioremap.c
28586 +++ b/arch/x86/mm/ioremap.c
28587 @@ -97,7 +97,7 @@ static void __iomem *__ioremap_caller(resource_size_t phys_addr,
28588 for (pfn = phys_addr >> PAGE_SHIFT; pfn <= last_pfn; pfn++) {
28589 int is_ram = page_is_ram(pfn);
28590
28591 - if (is_ram && pfn_valid(pfn) && !PageReserved(pfn_to_page(pfn)))
28592 + if (is_ram && pfn_valid(pfn) && (pfn >= 0x100 || !PageReserved(pfn_to_page(pfn))))
28593 return NULL;
28594 WARN_ON_ONCE(is_ram);
28595 }
28596 @@ -256,7 +256,7 @@ EXPORT_SYMBOL(ioremap_prot);
28597 *
28598 * Caller must ensure there is only one unmapping for the same pointer.
28599 */
28600 -void iounmap(volatile void __iomem *addr)
28601 +void iounmap(const volatile void __iomem *addr)
28602 {
28603 struct vm_struct *p, *o;
28604
28605 @@ -315,6 +315,9 @@ void *xlate_dev_mem_ptr(unsigned long phys)
28606
28607 /* If page is RAM, we can use __va. Otherwise ioremap and unmap. */
28608 if (page_is_ram(start >> PAGE_SHIFT))
28609 +#ifdef CONFIG_HIGHMEM
28610 + if ((start >> PAGE_SHIFT) < max_low_pfn)
28611 +#endif
28612 return __va(phys);
28613
28614 addr = (void __force *)ioremap_cache(start, PAGE_SIZE);
28615 @@ -344,7 +347,7 @@ static int __init early_ioremap_debug_setup(char *str)
28616 early_param("early_ioremap_debug", early_ioremap_debug_setup);
28617
28618 static __initdata int after_paging_init;
28619 -static pte_t bm_pte[PAGE_SIZE/sizeof(pte_t)] __page_aligned_bss;
28620 +static pte_t bm_pte[PAGE_SIZE/sizeof(pte_t)] __read_only __aligned(PAGE_SIZE);
28621
28622 static inline pmd_t * __init early_ioremap_pmd(unsigned long addr)
28623 {
28624 @@ -381,8 +384,7 @@ void __init early_ioremap_init(void)
28625 slot_virt[i] = __fix_to_virt(FIX_BTMAP_BEGIN - NR_FIX_BTMAPS*i);
28626
28627 pmd = early_ioremap_pmd(fix_to_virt(FIX_BTMAP_BEGIN));
28628 - memset(bm_pte, 0, sizeof(bm_pte));
28629 - pmd_populate_kernel(&init_mm, pmd, bm_pte);
28630 + pmd_populate_user(&init_mm, pmd, bm_pte);
28631
28632 /*
28633 * The boot-ioremap range spans multiple pmds, for which
28634 diff --git a/arch/x86/mm/kmemcheck/kmemcheck.c b/arch/x86/mm/kmemcheck/kmemcheck.c
28635 index d87dd6d..bf3fa66 100644
28636 --- a/arch/x86/mm/kmemcheck/kmemcheck.c
28637 +++ b/arch/x86/mm/kmemcheck/kmemcheck.c
28638 @@ -622,9 +622,9 @@ bool kmemcheck_fault(struct pt_regs *regs, unsigned long address,
28639 * memory (e.g. tracked pages)? For now, we need this to avoid
28640 * invoking kmemcheck for PnP BIOS calls.
28641 */
28642 - if (regs->flags & X86_VM_MASK)
28643 + if (v8086_mode(regs))
28644 return false;
28645 - if (regs->cs != __KERNEL_CS)
28646 + if (regs->cs != __KERNEL_CS && regs->cs != __KERNEXEC_KERNEL_CS)
28647 return false;
28648
28649 pte = kmemcheck_pte_lookup(address);
28650 diff --git a/arch/x86/mm/mmap.c b/arch/x86/mm/mmap.c
28651 index 845df68..1d8d29f 100644
28652 --- a/arch/x86/mm/mmap.c
28653 +++ b/arch/x86/mm/mmap.c
28654 @@ -52,7 +52,7 @@ static unsigned int stack_maxrandom_size(void)
28655 * Leave an at least ~128 MB hole with possible stack randomization.
28656 */
28657 #define MIN_GAP (128*1024*1024UL + stack_maxrandom_size())
28658 -#define MAX_GAP (TASK_SIZE/6*5)
28659 +#define MAX_GAP (pax_task_size/6*5)
28660
28661 static int mmap_is_legacy(void)
28662 {
28663 @@ -82,27 +82,40 @@ static unsigned long mmap_rnd(void)
28664 return rnd << PAGE_SHIFT;
28665 }
28666
28667 -static unsigned long mmap_base(void)
28668 +static unsigned long mmap_base(struct mm_struct *mm)
28669 {
28670 unsigned long gap = rlimit(RLIMIT_STACK);
28671 + unsigned long pax_task_size = TASK_SIZE;
28672 +
28673 +#ifdef CONFIG_PAX_SEGMEXEC
28674 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
28675 + pax_task_size = SEGMEXEC_TASK_SIZE;
28676 +#endif
28677
28678 if (gap < MIN_GAP)
28679 gap = MIN_GAP;
28680 else if (gap > MAX_GAP)
28681 gap = MAX_GAP;
28682
28683 - return PAGE_ALIGN(TASK_SIZE - gap - mmap_rnd());
28684 + return PAGE_ALIGN(pax_task_size - gap - mmap_rnd());
28685 }
28686
28687 /*
28688 * Bottom-up (legacy) layout on X86_32 did not support randomization, X86_64
28689 * does, but not when emulating X86_32
28690 */
28691 -static unsigned long mmap_legacy_base(void)
28692 +static unsigned long mmap_legacy_base(struct mm_struct *mm)
28693 {
28694 - if (mmap_is_ia32())
28695 + if (mmap_is_ia32()) {
28696 +
28697 +#ifdef CONFIG_PAX_SEGMEXEC
28698 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
28699 + return SEGMEXEC_TASK_UNMAPPED_BASE;
28700 + else
28701 +#endif
28702 +
28703 return TASK_UNMAPPED_BASE;
28704 - else
28705 + } else
28706 return TASK_UNMAPPED_BASE + mmap_rnd();
28707 }
28708
28709 @@ -113,11 +126,23 @@ static unsigned long mmap_legacy_base(void)
28710 void arch_pick_mmap_layout(struct mm_struct *mm)
28711 {
28712 if (mmap_is_legacy()) {
28713 - mm->mmap_base = mmap_legacy_base();
28714 + mm->mmap_base = mmap_legacy_base(mm);
28715 +
28716 +#ifdef CONFIG_PAX_RANDMMAP
28717 + if (mm->pax_flags & MF_PAX_RANDMMAP)
28718 + mm->mmap_base += mm->delta_mmap;
28719 +#endif
28720 +
28721 mm->get_unmapped_area = arch_get_unmapped_area;
28722 mm->unmap_area = arch_unmap_area;
28723 } else {
28724 - mm->mmap_base = mmap_base();
28725 + mm->mmap_base = mmap_base(mm);
28726 +
28727 +#ifdef CONFIG_PAX_RANDMMAP
28728 + if (mm->pax_flags & MF_PAX_RANDMMAP)
28729 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
28730 +#endif
28731 +
28732 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
28733 mm->unmap_area = arch_unmap_area_topdown;
28734 }
28735 diff --git a/arch/x86/mm/mmio-mod.c b/arch/x86/mm/mmio-mod.c
28736 index dc0b727..f612039 100644
28737 --- a/arch/x86/mm/mmio-mod.c
28738 +++ b/arch/x86/mm/mmio-mod.c
28739 @@ -194,7 +194,7 @@ static void pre(struct kmmio_probe *p, struct pt_regs *regs,
28740 break;
28741 default:
28742 {
28743 - unsigned char *ip = (unsigned char *)instptr;
28744 + unsigned char *ip = (unsigned char *)ktla_ktva(instptr);
28745 my_trace->opcode = MMIO_UNKNOWN_OP;
28746 my_trace->width = 0;
28747 my_trace->value = (*ip) << 16 | *(ip + 1) << 8 |
28748 @@ -234,7 +234,7 @@ static void post(struct kmmio_probe *p, unsigned long condition,
28749 static void ioremap_trace_core(resource_size_t offset, unsigned long size,
28750 void __iomem *addr)
28751 {
28752 - static atomic_t next_id;
28753 + static atomic_unchecked_t next_id;
28754 struct remap_trace *trace = kmalloc(sizeof(*trace), GFP_KERNEL);
28755 /* These are page-unaligned. */
28756 struct mmiotrace_map map = {
28757 @@ -258,7 +258,7 @@ static void ioremap_trace_core(resource_size_t offset, unsigned long size,
28758 .private = trace
28759 },
28760 .phys = offset,
28761 - .id = atomic_inc_return(&next_id)
28762 + .id = atomic_inc_return_unchecked(&next_id)
28763 };
28764 map.map_id = trace->id;
28765
28766 @@ -290,7 +290,7 @@ void mmiotrace_ioremap(resource_size_t offset, unsigned long size,
28767 ioremap_trace_core(offset, size, addr);
28768 }
28769
28770 -static void iounmap_trace_core(volatile void __iomem *addr)
28771 +static void iounmap_trace_core(const volatile void __iomem *addr)
28772 {
28773 struct mmiotrace_map map = {
28774 .phys = 0,
28775 @@ -328,7 +328,7 @@ not_enabled:
28776 }
28777 }
28778
28779 -void mmiotrace_iounmap(volatile void __iomem *addr)
28780 +void mmiotrace_iounmap(const volatile void __iomem *addr)
28781 {
28782 might_sleep();
28783 if (is_enabled()) /* recheck and proper locking in *_core() */
28784 diff --git a/arch/x86/mm/numa.c b/arch/x86/mm/numa.c
28785 index 8504f36..5fc68f2 100644
28786 --- a/arch/x86/mm/numa.c
28787 +++ b/arch/x86/mm/numa.c
28788 @@ -478,7 +478,7 @@ static bool __init numa_meminfo_cover_memory(const struct numa_meminfo *mi)
28789 return true;
28790 }
28791
28792 -static int __init numa_register_memblks(struct numa_meminfo *mi)
28793 +static int __init __intentional_overflow(-1) numa_register_memblks(struct numa_meminfo *mi)
28794 {
28795 unsigned long uninitialized_var(pfn_align);
28796 int i, nid;
28797 diff --git a/arch/x86/mm/pageattr-test.c b/arch/x86/mm/pageattr-test.c
28798 index b008656..773eac2 100644
28799 --- a/arch/x86/mm/pageattr-test.c
28800 +++ b/arch/x86/mm/pageattr-test.c
28801 @@ -36,7 +36,7 @@ enum {
28802
28803 static int pte_testbit(pte_t pte)
28804 {
28805 - return pte_flags(pte) & _PAGE_UNUSED1;
28806 + return pte_flags(pte) & _PAGE_CPA_TEST;
28807 }
28808
28809 struct split_state {
28810 diff --git a/arch/x86/mm/pageattr.c b/arch/x86/mm/pageattr.c
28811 index a718e0d..77419bc 100644
28812 --- a/arch/x86/mm/pageattr.c
28813 +++ b/arch/x86/mm/pageattr.c
28814 @@ -261,7 +261,7 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
28815 */
28816 #ifdef CONFIG_PCI_BIOS
28817 if (pcibios_enabled && within(pfn, BIOS_BEGIN >> PAGE_SHIFT, BIOS_END >> PAGE_SHIFT))
28818 - pgprot_val(forbidden) |= _PAGE_NX;
28819 + pgprot_val(forbidden) |= _PAGE_NX & __supported_pte_mask;
28820 #endif
28821
28822 /*
28823 @@ -269,9 +269,10 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
28824 * Does not cover __inittext since that is gone later on. On
28825 * 64bit we do not enforce !NX on the low mapping
28826 */
28827 - if (within(address, (unsigned long)_text, (unsigned long)_etext))
28828 - pgprot_val(forbidden) |= _PAGE_NX;
28829 + if (within(address, ktla_ktva((unsigned long)_text), ktla_ktva((unsigned long)_etext)))
28830 + pgprot_val(forbidden) |= _PAGE_NX & __supported_pte_mask;
28831
28832 +#ifdef CONFIG_DEBUG_RODATA
28833 /*
28834 * The .rodata section needs to be read-only. Using the pfn
28835 * catches all aliases.
28836 @@ -279,6 +280,7 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
28837 if (within(pfn, __pa((unsigned long)__start_rodata) >> PAGE_SHIFT,
28838 __pa((unsigned long)__end_rodata) >> PAGE_SHIFT))
28839 pgprot_val(forbidden) |= _PAGE_RW;
28840 +#endif
28841
28842 #if defined(CONFIG_X86_64) && defined(CONFIG_DEBUG_RODATA)
28843 /*
28844 @@ -317,6 +319,13 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
28845 }
28846 #endif
28847
28848 +#ifdef CONFIG_PAX_KERNEXEC
28849 + if (within(pfn, __pa(ktla_ktva((unsigned long)&_text)), __pa((unsigned long)&_sdata))) {
28850 + pgprot_val(forbidden) |= _PAGE_RW;
28851 + pgprot_val(forbidden) |= _PAGE_NX & __supported_pte_mask;
28852 + }
28853 +#endif
28854 +
28855 prot = __pgprot(pgprot_val(prot) & ~pgprot_val(forbidden));
28856
28857 return prot;
28858 @@ -369,23 +378,37 @@ EXPORT_SYMBOL_GPL(lookup_address);
28859 static void __set_pmd_pte(pte_t *kpte, unsigned long address, pte_t pte)
28860 {
28861 /* change init_mm */
28862 + pax_open_kernel();
28863 set_pte_atomic(kpte, pte);
28864 +
28865 #ifdef CONFIG_X86_32
28866 if (!SHARED_KERNEL_PMD) {
28867 +
28868 +#ifdef CONFIG_PAX_PER_CPU_PGD
28869 + unsigned long cpu;
28870 +#else
28871 struct page *page;
28872 +#endif
28873
28874 +#ifdef CONFIG_PAX_PER_CPU_PGD
28875 + for (cpu = 0; cpu < nr_cpu_ids; ++cpu) {
28876 + pgd_t *pgd = get_cpu_pgd(cpu);
28877 +#else
28878 list_for_each_entry(page, &pgd_list, lru) {
28879 - pgd_t *pgd;
28880 + pgd_t *pgd = (pgd_t *)page_address(page);
28881 +#endif
28882 +
28883 pud_t *pud;
28884 pmd_t *pmd;
28885
28886 - pgd = (pgd_t *)page_address(page) + pgd_index(address);
28887 + pgd += pgd_index(address);
28888 pud = pud_offset(pgd, address);
28889 pmd = pmd_offset(pud, address);
28890 set_pte_atomic((pte_t *)pmd, pte);
28891 }
28892 }
28893 #endif
28894 + pax_close_kernel();
28895 }
28896
28897 static int
28898 diff --git a/arch/x86/mm/pat.c b/arch/x86/mm/pat.c
28899 index 0eb572e..92f5c1e 100644
28900 --- a/arch/x86/mm/pat.c
28901 +++ b/arch/x86/mm/pat.c
28902 @@ -376,7 +376,7 @@ int free_memtype(u64 start, u64 end)
28903
28904 if (!entry) {
28905 printk(KERN_INFO "%s:%d freeing invalid memtype [mem %#010Lx-%#010Lx]\n",
28906 - current->comm, current->pid, start, end - 1);
28907 + current->comm, task_pid_nr(current), start, end - 1);
28908 return -EINVAL;
28909 }
28910
28911 @@ -506,8 +506,8 @@ static inline int range_is_allowed(unsigned long pfn, unsigned long size)
28912
28913 while (cursor < to) {
28914 if (!devmem_is_allowed(pfn)) {
28915 - printk(KERN_INFO "Program %s tried to access /dev/mem between [mem %#010Lx-%#010Lx]\n",
28916 - current->comm, from, to - 1);
28917 + printk(KERN_INFO "Program %s tried to access /dev/mem between [mem %#010Lx-%#010Lx] (%#010Lx)\n",
28918 + current->comm, from, to - 1, cursor);
28919 return 0;
28920 }
28921 cursor += PAGE_SIZE;
28922 @@ -570,7 +570,7 @@ int kernel_map_sync_memtype(u64 base, unsigned long size, unsigned long flags)
28923 if (ioremap_change_attr((unsigned long)__va(base), id_sz, flags) < 0) {
28924 printk(KERN_INFO "%s:%d ioremap_change_attr failed %s "
28925 "for [mem %#010Lx-%#010Lx]\n",
28926 - current->comm, current->pid,
28927 + current->comm, task_pid_nr(current),
28928 cattr_name(flags),
28929 base, (unsigned long long)(base + size-1));
28930 return -EINVAL;
28931 @@ -605,7 +605,7 @@ static int reserve_pfn_range(u64 paddr, unsigned long size, pgprot_t *vma_prot,
28932 flags = lookup_memtype(paddr);
28933 if (want_flags != flags) {
28934 printk(KERN_WARNING "%s:%d map pfn RAM range req %s for [mem %#010Lx-%#010Lx], got %s\n",
28935 - current->comm, current->pid,
28936 + current->comm, task_pid_nr(current),
28937 cattr_name(want_flags),
28938 (unsigned long long)paddr,
28939 (unsigned long long)(paddr + size - 1),
28940 @@ -627,7 +627,7 @@ static int reserve_pfn_range(u64 paddr, unsigned long size, pgprot_t *vma_prot,
28941 free_memtype(paddr, paddr + size);
28942 printk(KERN_ERR "%s:%d map pfn expected mapping type %s"
28943 " for [mem %#010Lx-%#010Lx], got %s\n",
28944 - current->comm, current->pid,
28945 + current->comm, task_pid_nr(current),
28946 cattr_name(want_flags),
28947 (unsigned long long)paddr,
28948 (unsigned long long)(paddr + size - 1),
28949 diff --git a/arch/x86/mm/pf_in.c b/arch/x86/mm/pf_in.c
28950 index 9f0614d..92ae64a 100644
28951 --- a/arch/x86/mm/pf_in.c
28952 +++ b/arch/x86/mm/pf_in.c
28953 @@ -148,7 +148,7 @@ enum reason_type get_ins_type(unsigned long ins_addr)
28954 int i;
28955 enum reason_type rv = OTHERS;
28956
28957 - p = (unsigned char *)ins_addr;
28958 + p = (unsigned char *)ktla_ktva(ins_addr);
28959 p += skip_prefix(p, &prf);
28960 p += get_opcode(p, &opcode);
28961
28962 @@ -168,7 +168,7 @@ static unsigned int get_ins_reg_width(unsigned long ins_addr)
28963 struct prefix_bits prf;
28964 int i;
28965
28966 - p = (unsigned char *)ins_addr;
28967 + p = (unsigned char *)ktla_ktva(ins_addr);
28968 p += skip_prefix(p, &prf);
28969 p += get_opcode(p, &opcode);
28970
28971 @@ -191,7 +191,7 @@ unsigned int get_ins_mem_width(unsigned long ins_addr)
28972 struct prefix_bits prf;
28973 int i;
28974
28975 - p = (unsigned char *)ins_addr;
28976 + p = (unsigned char *)ktla_ktva(ins_addr);
28977 p += skip_prefix(p, &prf);
28978 p += get_opcode(p, &opcode);
28979
28980 @@ -415,7 +415,7 @@ unsigned long get_ins_reg_val(unsigned long ins_addr, struct pt_regs *regs)
28981 struct prefix_bits prf;
28982 int i;
28983
28984 - p = (unsigned char *)ins_addr;
28985 + p = (unsigned char *)ktla_ktva(ins_addr);
28986 p += skip_prefix(p, &prf);
28987 p += get_opcode(p, &opcode);
28988 for (i = 0; i < ARRAY_SIZE(reg_rop); i++)
28989 @@ -470,7 +470,7 @@ unsigned long get_ins_imm_val(unsigned long ins_addr)
28990 struct prefix_bits prf;
28991 int i;
28992
28993 - p = (unsigned char *)ins_addr;
28994 + p = (unsigned char *)ktla_ktva(ins_addr);
28995 p += skip_prefix(p, &prf);
28996 p += get_opcode(p, &opcode);
28997 for (i = 0; i < ARRAY_SIZE(imm_wop); i++)
28998 diff --git a/arch/x86/mm/pgtable.c b/arch/x86/mm/pgtable.c
28999 index e27fbf8..8b56dc9 100644
29000 --- a/arch/x86/mm/pgtable.c
29001 +++ b/arch/x86/mm/pgtable.c
29002 @@ -84,10 +84,64 @@ static inline void pgd_list_del(pgd_t *pgd)
29003 list_del(&page->lru);
29004 }
29005
29006 -#define UNSHARED_PTRS_PER_PGD \
29007 - (SHARED_KERNEL_PMD ? KERNEL_PGD_BOUNDARY : PTRS_PER_PGD)
29008 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
29009 +pgdval_t clone_pgd_mask __read_only = ~_PAGE_PRESENT;
29010
29011 +void __shadow_user_pgds(pgd_t *dst, const pgd_t *src)
29012 +{
29013 + unsigned int count = USER_PGD_PTRS;
29014
29015 + while (count--)
29016 + *dst++ = __pgd((pgd_val(*src++) | (_PAGE_NX & __supported_pte_mask)) & ~_PAGE_USER);
29017 +}
29018 +#endif
29019 +
29020 +#ifdef CONFIG_PAX_PER_CPU_PGD
29021 +void __clone_user_pgds(pgd_t *dst, const pgd_t *src)
29022 +{
29023 + unsigned int count = USER_PGD_PTRS;
29024 +
29025 + while (count--) {
29026 + pgd_t pgd;
29027 +
29028 +#ifdef CONFIG_X86_64
29029 + pgd = __pgd(pgd_val(*src++) | _PAGE_USER);
29030 +#else
29031 + pgd = *src++;
29032 +#endif
29033 +
29034 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
29035 + pgd = __pgd(pgd_val(pgd) & clone_pgd_mask);
29036 +#endif
29037 +
29038 + *dst++ = pgd;
29039 + }
29040 +
29041 +}
29042 +#endif
29043 +
29044 +#ifdef CONFIG_X86_64
29045 +#define pxd_t pud_t
29046 +#define pyd_t pgd_t
29047 +#define paravirt_release_pxd(pfn) paravirt_release_pud(pfn)
29048 +#define pxd_free(mm, pud) pud_free((mm), (pud))
29049 +#define pyd_populate(mm, pgd, pud) pgd_populate((mm), (pgd), (pud))
29050 +#define pyd_offset(mm, address) pgd_offset((mm), (address))
29051 +#define PYD_SIZE PGDIR_SIZE
29052 +#else
29053 +#define pxd_t pmd_t
29054 +#define pyd_t pud_t
29055 +#define paravirt_release_pxd(pfn) paravirt_release_pmd(pfn)
29056 +#define pxd_free(mm, pud) pmd_free((mm), (pud))
29057 +#define pyd_populate(mm, pgd, pud) pud_populate((mm), (pgd), (pud))
29058 +#define pyd_offset(mm, address) pud_offset((mm), (address))
29059 +#define PYD_SIZE PUD_SIZE
29060 +#endif
29061 +
29062 +#ifdef CONFIG_PAX_PER_CPU_PGD
29063 +static inline void pgd_ctor(struct mm_struct *mm, pgd_t *pgd) {}
29064 +static inline void pgd_dtor(pgd_t *pgd) {}
29065 +#else
29066 static void pgd_set_mm(pgd_t *pgd, struct mm_struct *mm)
29067 {
29068 BUILD_BUG_ON(sizeof(virt_to_page(pgd)->index) < sizeof(mm));
29069 @@ -128,6 +182,7 @@ static void pgd_dtor(pgd_t *pgd)
29070 pgd_list_del(pgd);
29071 spin_unlock(&pgd_lock);
29072 }
29073 +#endif
29074
29075 /*
29076 * List of all pgd's needed for non-PAE so it can invalidate entries
29077 @@ -140,7 +195,7 @@ static void pgd_dtor(pgd_t *pgd)
29078 * -- nyc
29079 */
29080
29081 -#ifdef CONFIG_X86_PAE
29082 +#if defined(CONFIG_X86_32) && defined(CONFIG_X86_PAE)
29083 /*
29084 * In PAE mode, we need to do a cr3 reload (=tlb flush) when
29085 * updating the top-level pagetable entries to guarantee the
29086 @@ -152,7 +207,7 @@ static void pgd_dtor(pgd_t *pgd)
29087 * not shared between pagetables (!SHARED_KERNEL_PMDS), we allocate
29088 * and initialize the kernel pmds here.
29089 */
29090 -#define PREALLOCATED_PMDS UNSHARED_PTRS_PER_PGD
29091 +#define PREALLOCATED_PXDS (SHARED_KERNEL_PMD ? KERNEL_PGD_BOUNDARY : PTRS_PER_PGD)
29092
29093 void pud_populate(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd)
29094 {
29095 @@ -170,36 +225,38 @@ void pud_populate(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd)
29096 */
29097 flush_tlb_mm(mm);
29098 }
29099 +#elif defined(CONFIG_X86_64) && defined(CONFIG_PAX_PER_CPU_PGD)
29100 +#define PREALLOCATED_PXDS USER_PGD_PTRS
29101 #else /* !CONFIG_X86_PAE */
29102
29103 /* No need to prepopulate any pagetable entries in non-PAE modes. */
29104 -#define PREALLOCATED_PMDS 0
29105 +#define PREALLOCATED_PXDS 0
29106
29107 #endif /* CONFIG_X86_PAE */
29108
29109 -static void free_pmds(pmd_t *pmds[])
29110 +static void free_pxds(pxd_t *pxds[])
29111 {
29112 int i;
29113
29114 - for(i = 0; i < PREALLOCATED_PMDS; i++)
29115 - if (pmds[i])
29116 - free_page((unsigned long)pmds[i]);
29117 + for(i = 0; i < PREALLOCATED_PXDS; i++)
29118 + if (pxds[i])
29119 + free_page((unsigned long)pxds[i]);
29120 }
29121
29122 -static int preallocate_pmds(pmd_t *pmds[])
29123 +static int preallocate_pxds(pxd_t *pxds[])
29124 {
29125 int i;
29126 bool failed = false;
29127
29128 - for(i = 0; i < PREALLOCATED_PMDS; i++) {
29129 - pmd_t *pmd = (pmd_t *)__get_free_page(PGALLOC_GFP);
29130 - if (pmd == NULL)
29131 + for(i = 0; i < PREALLOCATED_PXDS; i++) {
29132 + pxd_t *pxd = (pxd_t *)__get_free_page(PGALLOC_GFP);
29133 + if (pxd == NULL)
29134 failed = true;
29135 - pmds[i] = pmd;
29136 + pxds[i] = pxd;
29137 }
29138
29139 if (failed) {
29140 - free_pmds(pmds);
29141 + free_pxds(pxds);
29142 return -ENOMEM;
29143 }
29144
29145 @@ -212,51 +269,55 @@ static int preallocate_pmds(pmd_t *pmds[])
29146 * preallocate which never got a corresponding vma will need to be
29147 * freed manually.
29148 */
29149 -static void pgd_mop_up_pmds(struct mm_struct *mm, pgd_t *pgdp)
29150 +static void pgd_mop_up_pxds(struct mm_struct *mm, pgd_t *pgdp)
29151 {
29152 int i;
29153
29154 - for(i = 0; i < PREALLOCATED_PMDS; i++) {
29155 + for(i = 0; i < PREALLOCATED_PXDS; i++) {
29156 pgd_t pgd = pgdp[i];
29157
29158 if (pgd_val(pgd) != 0) {
29159 - pmd_t *pmd = (pmd_t *)pgd_page_vaddr(pgd);
29160 + pxd_t *pxd = (pxd_t *)pgd_page_vaddr(pgd);
29161
29162 - pgdp[i] = native_make_pgd(0);
29163 + set_pgd(pgdp + i, native_make_pgd(0));
29164
29165 - paravirt_release_pmd(pgd_val(pgd) >> PAGE_SHIFT);
29166 - pmd_free(mm, pmd);
29167 + paravirt_release_pxd(pgd_val(pgd) >> PAGE_SHIFT);
29168 + pxd_free(mm, pxd);
29169 }
29170 }
29171 }
29172
29173 -static void pgd_prepopulate_pmd(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmds[])
29174 +static void pgd_prepopulate_pxd(struct mm_struct *mm, pgd_t *pgd, pxd_t *pxds[])
29175 {
29176 - pud_t *pud;
29177 + pyd_t *pyd;
29178 unsigned long addr;
29179 int i;
29180
29181 - if (PREALLOCATED_PMDS == 0) /* Work around gcc-3.4.x bug */
29182 + if (PREALLOCATED_PXDS == 0) /* Work around gcc-3.4.x bug */
29183 return;
29184
29185 - pud = pud_offset(pgd, 0);
29186 +#ifdef CONFIG_X86_64
29187 + pyd = pyd_offset(mm, 0L);
29188 +#else
29189 + pyd = pyd_offset(pgd, 0L);
29190 +#endif
29191
29192 - for (addr = i = 0; i < PREALLOCATED_PMDS;
29193 - i++, pud++, addr += PUD_SIZE) {
29194 - pmd_t *pmd = pmds[i];
29195 + for (addr = i = 0; i < PREALLOCATED_PXDS;
29196 + i++, pyd++, addr += PYD_SIZE) {
29197 + pxd_t *pxd = pxds[i];
29198
29199 if (i >= KERNEL_PGD_BOUNDARY)
29200 - memcpy(pmd, (pmd_t *)pgd_page_vaddr(swapper_pg_dir[i]),
29201 - sizeof(pmd_t) * PTRS_PER_PMD);
29202 + memcpy(pxd, (pxd_t *)pgd_page_vaddr(swapper_pg_dir[i]),
29203 + sizeof(pxd_t) * PTRS_PER_PMD);
29204
29205 - pud_populate(mm, pud, pmd);
29206 + pyd_populate(mm, pyd, pxd);
29207 }
29208 }
29209
29210 pgd_t *pgd_alloc(struct mm_struct *mm)
29211 {
29212 pgd_t *pgd;
29213 - pmd_t *pmds[PREALLOCATED_PMDS];
29214 + pxd_t *pxds[PREALLOCATED_PXDS];
29215
29216 pgd = (pgd_t *)__get_free_page(PGALLOC_GFP);
29217
29218 @@ -265,11 +326,11 @@ pgd_t *pgd_alloc(struct mm_struct *mm)
29219
29220 mm->pgd = pgd;
29221
29222 - if (preallocate_pmds(pmds) != 0)
29223 + if (preallocate_pxds(pxds) != 0)
29224 goto out_free_pgd;
29225
29226 if (paravirt_pgd_alloc(mm) != 0)
29227 - goto out_free_pmds;
29228 + goto out_free_pxds;
29229
29230 /*
29231 * Make sure that pre-populating the pmds is atomic with
29232 @@ -279,14 +340,14 @@ pgd_t *pgd_alloc(struct mm_struct *mm)
29233 spin_lock(&pgd_lock);
29234
29235 pgd_ctor(mm, pgd);
29236 - pgd_prepopulate_pmd(mm, pgd, pmds);
29237 + pgd_prepopulate_pxd(mm, pgd, pxds);
29238
29239 spin_unlock(&pgd_lock);
29240
29241 return pgd;
29242
29243 -out_free_pmds:
29244 - free_pmds(pmds);
29245 +out_free_pxds:
29246 + free_pxds(pxds);
29247 out_free_pgd:
29248 free_page((unsigned long)pgd);
29249 out:
29250 @@ -295,7 +356,7 @@ out:
29251
29252 void pgd_free(struct mm_struct *mm, pgd_t *pgd)
29253 {
29254 - pgd_mop_up_pmds(mm, pgd);
29255 + pgd_mop_up_pxds(mm, pgd);
29256 pgd_dtor(pgd);
29257 paravirt_pgd_free(mm, pgd);
29258 free_page((unsigned long)pgd);
29259 diff --git a/arch/x86/mm/pgtable_32.c b/arch/x86/mm/pgtable_32.c
29260 index a69bcb8..19068ab 100644
29261 --- a/arch/x86/mm/pgtable_32.c
29262 +++ b/arch/x86/mm/pgtable_32.c
29263 @@ -47,10 +47,13 @@ void set_pte_vaddr(unsigned long vaddr, pte_t pteval)
29264 return;
29265 }
29266 pte = pte_offset_kernel(pmd, vaddr);
29267 +
29268 + pax_open_kernel();
29269 if (pte_val(pteval))
29270 set_pte_at(&init_mm, vaddr, pte, pteval);
29271 else
29272 pte_clear(&init_mm, vaddr, pte);
29273 + pax_close_kernel();
29274
29275 /*
29276 * It's enough to flush this one mapping.
29277 diff --git a/arch/x86/mm/physaddr.c b/arch/x86/mm/physaddr.c
29278 index d2e2735..5c6586f 100644
29279 --- a/arch/x86/mm/physaddr.c
29280 +++ b/arch/x86/mm/physaddr.c
29281 @@ -8,7 +8,7 @@
29282
29283 #ifdef CONFIG_X86_64
29284
29285 -unsigned long __phys_addr(unsigned long x)
29286 +unsigned long __intentional_overflow(-1) __phys_addr(unsigned long x)
29287 {
29288 if (x >= __START_KERNEL_map) {
29289 x -= __START_KERNEL_map;
29290 @@ -45,7 +45,7 @@ EXPORT_SYMBOL(__virt_addr_valid);
29291 #else
29292
29293 #ifdef CONFIG_DEBUG_VIRTUAL
29294 -unsigned long __phys_addr(unsigned long x)
29295 +unsigned long __intentional_overflow(-1) __phys_addr(unsigned long x)
29296 {
29297 /* VMALLOC_* aren't constants */
29298 VIRTUAL_BUG_ON(x < PAGE_OFFSET);
29299 diff --git a/arch/x86/mm/setup_nx.c b/arch/x86/mm/setup_nx.c
29300 index 410531d..0f16030 100644
29301 --- a/arch/x86/mm/setup_nx.c
29302 +++ b/arch/x86/mm/setup_nx.c
29303 @@ -5,8 +5,10 @@
29304 #include <asm/pgtable.h>
29305 #include <asm/proto.h>
29306
29307 +#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
29308 static int disable_nx __cpuinitdata;
29309
29310 +#ifndef CONFIG_PAX_PAGEEXEC
29311 /*
29312 * noexec = on|off
29313 *
29314 @@ -28,12 +30,17 @@ static int __init noexec_setup(char *str)
29315 return 0;
29316 }
29317 early_param("noexec", noexec_setup);
29318 +#endif
29319 +
29320 +#endif
29321
29322 void __cpuinit x86_configure_nx(void)
29323 {
29324 +#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
29325 if (cpu_has_nx && !disable_nx)
29326 __supported_pte_mask |= _PAGE_NX;
29327 else
29328 +#endif
29329 __supported_pte_mask &= ~_PAGE_NX;
29330 }
29331
29332 diff --git a/arch/x86/mm/tlb.c b/arch/x86/mm/tlb.c
29333 index 13a6b29..c2fff23 100644
29334 --- a/arch/x86/mm/tlb.c
29335 +++ b/arch/x86/mm/tlb.c
29336 @@ -48,7 +48,11 @@ void leave_mm(int cpu)
29337 BUG();
29338 if (cpumask_test_cpu(cpu, mm_cpumask(active_mm))) {
29339 cpumask_clear_cpu(cpu, mm_cpumask(active_mm));
29340 +
29341 +#ifndef CONFIG_PAX_PER_CPU_PGD
29342 load_cr3(swapper_pg_dir);
29343 +#endif
29344 +
29345 }
29346 }
29347 EXPORT_SYMBOL_GPL(leave_mm);
29348 diff --git a/arch/x86/net/bpf_jit.S b/arch/x86/net/bpf_jit.S
29349 index 877b9a1..a8ecf42 100644
29350 --- a/arch/x86/net/bpf_jit.S
29351 +++ b/arch/x86/net/bpf_jit.S
29352 @@ -9,6 +9,7 @@
29353 */
29354 #include <linux/linkage.h>
29355 #include <asm/dwarf2.h>
29356 +#include <asm/alternative-asm.h>
29357
29358 /*
29359 * Calling convention :
29360 @@ -35,6 +36,7 @@ sk_load_word_positive_offset:
29361 jle bpf_slow_path_word
29362 mov (SKBDATA,%rsi),%eax
29363 bswap %eax /* ntohl() */
29364 + pax_force_retaddr
29365 ret
29366
29367 sk_load_half:
29368 @@ -52,6 +54,7 @@ sk_load_half_positive_offset:
29369 jle bpf_slow_path_half
29370 movzwl (SKBDATA,%rsi),%eax
29371 rol $8,%ax # ntohs()
29372 + pax_force_retaddr
29373 ret
29374
29375 sk_load_byte:
29376 @@ -66,6 +69,7 @@ sk_load_byte_positive_offset:
29377 cmp %esi,%r9d /* if (offset >= hlen) goto bpf_slow_path_byte */
29378 jle bpf_slow_path_byte
29379 movzbl (SKBDATA,%rsi),%eax
29380 + pax_force_retaddr
29381 ret
29382
29383 /**
29384 @@ -87,6 +91,7 @@ sk_load_byte_msh_positive_offset:
29385 movzbl (SKBDATA,%rsi),%ebx
29386 and $15,%bl
29387 shl $2,%bl
29388 + pax_force_retaddr
29389 ret
29390
29391 /* rsi contains offset and can be scratched */
29392 @@ -109,6 +114,7 @@ bpf_slow_path_word:
29393 js bpf_error
29394 mov -12(%rbp),%eax
29395 bswap %eax
29396 + pax_force_retaddr
29397 ret
29398
29399 bpf_slow_path_half:
29400 @@ -117,12 +123,14 @@ bpf_slow_path_half:
29401 mov -12(%rbp),%ax
29402 rol $8,%ax
29403 movzwl %ax,%eax
29404 + pax_force_retaddr
29405 ret
29406
29407 bpf_slow_path_byte:
29408 bpf_slow_path_common(1)
29409 js bpf_error
29410 movzbl -12(%rbp),%eax
29411 + pax_force_retaddr
29412 ret
29413
29414 bpf_slow_path_byte_msh:
29415 @@ -133,6 +141,7 @@ bpf_slow_path_byte_msh:
29416 and $15,%al
29417 shl $2,%al
29418 xchg %eax,%ebx
29419 + pax_force_retaddr
29420 ret
29421
29422 #define sk_negative_common(SIZE) \
29423 @@ -157,6 +166,7 @@ sk_load_word_negative_offset:
29424 sk_negative_common(4)
29425 mov (%rax), %eax
29426 bswap %eax
29427 + pax_force_retaddr
29428 ret
29429
29430 bpf_slow_path_half_neg:
29431 @@ -168,6 +178,7 @@ sk_load_half_negative_offset:
29432 mov (%rax),%ax
29433 rol $8,%ax
29434 movzwl %ax,%eax
29435 + pax_force_retaddr
29436 ret
29437
29438 bpf_slow_path_byte_neg:
29439 @@ -177,6 +188,7 @@ sk_load_byte_negative_offset:
29440 .globl sk_load_byte_negative_offset
29441 sk_negative_common(1)
29442 movzbl (%rax), %eax
29443 + pax_force_retaddr
29444 ret
29445
29446 bpf_slow_path_byte_msh_neg:
29447 @@ -190,6 +202,7 @@ sk_load_byte_msh_negative_offset:
29448 and $15,%al
29449 shl $2,%al
29450 xchg %eax,%ebx
29451 + pax_force_retaddr
29452 ret
29453
29454 bpf_error:
29455 @@ -197,4 +210,5 @@ bpf_error:
29456 xor %eax,%eax
29457 mov -8(%rbp),%rbx
29458 leaveq
29459 + pax_force_retaddr
29460 ret
29461 diff --git a/arch/x86/net/bpf_jit_comp.c b/arch/x86/net/bpf_jit_comp.c
29462 index d11a470..3f9adff3 100644
29463 --- a/arch/x86/net/bpf_jit_comp.c
29464 +++ b/arch/x86/net/bpf_jit_comp.c
29465 @@ -12,6 +12,7 @@
29466 #include <linux/netdevice.h>
29467 #include <linux/filter.h>
29468 #include <linux/if_vlan.h>
29469 +#include <linux/random.h>
29470
29471 /*
29472 * Conventions :
29473 @@ -49,13 +50,87 @@ static inline u8 *emit_code(u8 *ptr, u32 bytes, unsigned int len)
29474 return ptr + len;
29475 }
29476
29477 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
29478 +#define MAX_INSTR_CODE_SIZE 96
29479 +#else
29480 +#define MAX_INSTR_CODE_SIZE 64
29481 +#endif
29482 +
29483 #define EMIT(bytes, len) do { prog = emit_code(prog, bytes, len); } while (0)
29484
29485 #define EMIT1(b1) EMIT(b1, 1)
29486 #define EMIT2(b1, b2) EMIT((b1) + ((b2) << 8), 2)
29487 #define EMIT3(b1, b2, b3) EMIT((b1) + ((b2) << 8) + ((b3) << 16), 3)
29488 #define EMIT4(b1, b2, b3, b4) EMIT((b1) + ((b2) << 8) + ((b3) << 16) + ((b4) << 24), 4)
29489 +
29490 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
29491 +/* original constant will appear in ecx */
29492 +#define DILUTE_CONST_SEQUENCE(_off, _key) \
29493 +do { \
29494 + /* mov ecx, randkey */ \
29495 + EMIT1(0xb9); \
29496 + EMIT(_key, 4); \
29497 + /* xor ecx, randkey ^ off */ \
29498 + EMIT2(0x81, 0xf1); \
29499 + EMIT((_key) ^ (_off), 4); \
29500 +} while (0)
29501 +
29502 +#define EMIT1_off32(b1, _off) \
29503 +do { \
29504 + switch (b1) { \
29505 + case 0x05: /* add eax, imm32 */ \
29506 + case 0x2d: /* sub eax, imm32 */ \
29507 + case 0x25: /* and eax, imm32 */ \
29508 + case 0x0d: /* or eax, imm32 */ \
29509 + case 0xb8: /* mov eax, imm32 */ \
29510 + case 0x3d: /* cmp eax, imm32 */ \
29511 + case 0xa9: /* test eax, imm32 */ \
29512 + DILUTE_CONST_SEQUENCE(_off, randkey); \
29513 + EMIT2((b1) - 4, 0xc8); /* convert imm instruction to eax, ecx */\
29514 + break; \
29515 + case 0xbb: /* mov ebx, imm32 */ \
29516 + DILUTE_CONST_SEQUENCE(_off, randkey); \
29517 + /* mov ebx, ecx */ \
29518 + EMIT2(0x89, 0xcb); \
29519 + break; \
29520 + case 0xbe: /* mov esi, imm32 */ \
29521 + DILUTE_CONST_SEQUENCE(_off, randkey); \
29522 + /* mov esi, ecx */ \
29523 + EMIT2(0x89, 0xce); \
29524 + break; \
29525 + case 0xe9: /* jmp rel imm32 */ \
29526 + EMIT1(b1); \
29527 + EMIT(_off, 4); \
29528 + /* prevent fall-through, we're not called if off = 0 */ \
29529 + EMIT(0xcccccccc, 4); \
29530 + EMIT(0xcccccccc, 4); \
29531 + break; \
29532 + default: \
29533 + EMIT1(b1); \
29534 + EMIT(_off, 4); \
29535 + } \
29536 +} while (0)
29537 +
29538 +#define EMIT2_off32(b1, b2, _off) \
29539 +do { \
29540 + if ((b1) == 0x8d && (b2) == 0xb3) { /* lea esi, [rbx+imm32] */ \
29541 + EMIT2(0x8d, 0xb3); /* lea esi, [rbx+randkey] */ \
29542 + EMIT(randkey, 4); \
29543 + EMIT2(0x8d, 0xb6); /* lea esi, [esi+off-randkey] */ \
29544 + EMIT((_off) - randkey, 4); \
29545 + } else if ((b1) == 0x69 && (b2) == 0xc0) { /* imul eax, imm32 */\
29546 + DILUTE_CONST_SEQUENCE(_off, randkey); \
29547 + /* imul eax, ecx */ \
29548 + EMIT3(0x0f, 0xaf, 0xc1); \
29549 + } else { \
29550 + EMIT2(b1, b2); \
29551 + EMIT(_off, 4); \
29552 + } \
29553 +} while (0)
29554 +#else
29555 #define EMIT1_off32(b1, off) do { EMIT1(b1); EMIT(off, 4);} while (0)
29556 +#define EMIT2_off32(b1, b2, off) do { EMIT2(b1, b2); EMIT(off, 4);} while (0)
29557 +#endif
29558
29559 #define CLEAR_A() EMIT2(0x31, 0xc0) /* xor %eax,%eax */
29560 #define CLEAR_X() EMIT2(0x31, 0xdb) /* xor %ebx,%ebx */
29561 @@ -90,6 +165,24 @@ do { \
29562 #define X86_JBE 0x76
29563 #define X86_JA 0x77
29564
29565 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
29566 +#define APPEND_FLOW_VERIFY() \
29567 +do { \
29568 + /* mov ecx, randkey */ \
29569 + EMIT1(0xb9); \
29570 + EMIT(randkey, 4); \
29571 + /* cmp ecx, randkey */ \
29572 + EMIT2(0x81, 0xf9); \
29573 + EMIT(randkey, 4); \
29574 + /* jz after 8 int 3s */ \
29575 + EMIT2(0x74, 0x08); \
29576 + EMIT(0xcccccccc, 4); \
29577 + EMIT(0xcccccccc, 4); \
29578 +} while (0)
29579 +#else
29580 +#define APPEND_FLOW_VERIFY() do { } while (0)
29581 +#endif
29582 +
29583 #define EMIT_COND_JMP(op, offset) \
29584 do { \
29585 if (is_near(offset)) \
29586 @@ -97,6 +190,7 @@ do { \
29587 else { \
29588 EMIT2(0x0f, op + 0x10); \
29589 EMIT(offset, 4); /* jxx .+off32 */ \
29590 + APPEND_FLOW_VERIFY(); \
29591 } \
29592 } while (0)
29593
29594 @@ -121,12 +215,17 @@ static inline void bpf_flush_icache(void *start, void *end)
29595 set_fs(old_fs);
29596 }
29597
29598 +struct bpf_jit_work {
29599 + struct work_struct work;
29600 + void *image;
29601 +};
29602 +
29603 #define CHOOSE_LOAD_FUNC(K, func) \
29604 ((int)K < 0 ? ((int)K >= SKF_LL_OFF ? func##_negative_offset : func) : func##_positive_offset)
29605
29606 void bpf_jit_compile(struct sk_filter *fp)
29607 {
29608 - u8 temp[64];
29609 + u8 temp[MAX_INSTR_CODE_SIZE];
29610 u8 *prog;
29611 unsigned int proglen, oldproglen = 0;
29612 int ilen, i;
29613 @@ -139,6 +238,9 @@ void bpf_jit_compile(struct sk_filter *fp)
29614 unsigned int *addrs;
29615 const struct sock_filter *filter = fp->insns;
29616 int flen = fp->len;
29617 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
29618 + unsigned int randkey;
29619 +#endif
29620
29621 if (!bpf_jit_enable)
29622 return;
29623 @@ -147,11 +249,19 @@ void bpf_jit_compile(struct sk_filter *fp)
29624 if (addrs == NULL)
29625 return;
29626
29627 + fp->work = kmalloc(sizeof(*fp->work), GFP_KERNEL);
29628 + if (!fp->work)
29629 + goto out;
29630 +
29631 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
29632 + randkey = get_random_int();
29633 +#endif
29634 +
29635 /* Before first pass, make a rough estimation of addrs[]
29636 - * each bpf instruction is translated to less than 64 bytes
29637 + * each bpf instruction is translated to less than MAX_INSTR_CODE_SIZE bytes
29638 */
29639 for (proglen = 0, i = 0; i < flen; i++) {
29640 - proglen += 64;
29641 + proglen += MAX_INSTR_CODE_SIZE;
29642 addrs[i] = proglen;
29643 }
29644 cleanup_addr = proglen; /* epilogue address */
29645 @@ -261,10 +371,8 @@ void bpf_jit_compile(struct sk_filter *fp)
29646 case BPF_S_ALU_MUL_K: /* A *= K */
29647 if (is_imm8(K))
29648 EMIT3(0x6b, 0xc0, K); /* imul imm8,%eax,%eax */
29649 - else {
29650 - EMIT2(0x69, 0xc0); /* imul imm32,%eax */
29651 - EMIT(K, 4);
29652 - }
29653 + else
29654 + EMIT2_off32(0x69, 0xc0, K); /* imul imm32,%eax */
29655 break;
29656 case BPF_S_ALU_DIV_X: /* A /= X; */
29657 seen |= SEEN_XREG;
29658 @@ -304,13 +412,23 @@ void bpf_jit_compile(struct sk_filter *fp)
29659 break;
29660 case BPF_S_ALU_MOD_K: /* A %= K; */
29661 EMIT2(0x31, 0xd2); /* xor %edx,%edx */
29662 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
29663 + DILUTE_CONST_SEQUENCE(K, randkey);
29664 +#else
29665 EMIT1(0xb9);EMIT(K, 4); /* mov imm32,%ecx */
29666 +#endif
29667 EMIT2(0xf7, 0xf1); /* div %ecx */
29668 EMIT2(0x89, 0xd0); /* mov %edx,%eax */
29669 break;
29670 case BPF_S_ALU_DIV_K: /* A = reciprocal_divide(A, K); */
29671 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
29672 + DILUTE_CONST_SEQUENCE(K, randkey);
29673 + // imul rax, rcx
29674 + EMIT4(0x48, 0x0f, 0xaf, 0xc1);
29675 +#else
29676 EMIT3(0x48, 0x69, 0xc0); /* imul imm32,%rax,%rax */
29677 EMIT(K, 4);
29678 +#endif
29679 EMIT4(0x48, 0xc1, 0xe8, 0x20); /* shr $0x20,%rax */
29680 break;
29681 case BPF_S_ALU_AND_X:
29682 @@ -564,8 +682,7 @@ common_load_ind: seen |= SEEN_DATAREF | SEEN_XREG;
29683 if (is_imm8(K)) {
29684 EMIT3(0x8d, 0x73, K); /* lea imm8(%rbx), %esi */
29685 } else {
29686 - EMIT2(0x8d, 0xb3); /* lea imm32(%rbx),%esi */
29687 - EMIT(K, 4);
29688 + EMIT2_off32(0x8d, 0xb3, K); /* lea imm32(%rbx),%esi */
29689 }
29690 } else {
29691 EMIT2(0x89,0xde); /* mov %ebx,%esi */
29692 @@ -648,17 +765,18 @@ cond_branch: f_offset = addrs[i + filter[i].jf] - addrs[i];
29693 break;
29694 default:
29695 /* hmm, too complex filter, give up with jit compiler */
29696 - goto out;
29697 + goto error;
29698 }
29699 ilen = prog - temp;
29700 if (image) {
29701 if (unlikely(proglen + ilen > oldproglen)) {
29702 pr_err("bpb_jit_compile fatal error\n");
29703 - kfree(addrs);
29704 - module_free(NULL, image);
29705 - return;
29706 + module_free_exec(NULL, image);
29707 + goto error;
29708 }
29709 + pax_open_kernel();
29710 memcpy(image + proglen, temp, ilen);
29711 + pax_close_kernel();
29712 }
29713 proglen += ilen;
29714 addrs[i] = proglen;
29715 @@ -679,11 +797,9 @@ cond_branch: f_offset = addrs[i + filter[i].jf] - addrs[i];
29716 break;
29717 }
29718 if (proglen == oldproglen) {
29719 - image = module_alloc(max_t(unsigned int,
29720 - proglen,
29721 - sizeof(struct work_struct)));
29722 + image = module_alloc_exec(proglen);
29723 if (!image)
29724 - goto out;
29725 + goto error;
29726 }
29727 oldproglen = proglen;
29728 }
29729 @@ -699,7 +815,10 @@ cond_branch: f_offset = addrs[i + filter[i].jf] - addrs[i];
29730 bpf_flush_icache(image, image + proglen);
29731
29732 fp->bpf_func = (void *)image;
29733 - }
29734 + } else
29735 +error:
29736 + kfree(fp->work);
29737 +
29738 out:
29739 kfree(addrs);
29740 return;
29741 @@ -707,18 +826,20 @@ out:
29742
29743 static void jit_free_defer(struct work_struct *arg)
29744 {
29745 - module_free(NULL, arg);
29746 + module_free_exec(NULL, ((struct bpf_jit_work *)arg)->image);
29747 + kfree(arg);
29748 }
29749
29750 /* run from softirq, we must use a work_struct to call
29751 - * module_free() from process context
29752 + * module_free_exec() from process context
29753 */
29754 void bpf_jit_free(struct sk_filter *fp)
29755 {
29756 if (fp->bpf_func != sk_run_filter) {
29757 - struct work_struct *work = (struct work_struct *)fp->bpf_func;
29758 + struct work_struct *work = &fp->work->work;
29759
29760 INIT_WORK(work, jit_free_defer);
29761 + fp->work->image = fp->bpf_func;
29762 schedule_work(work);
29763 }
29764 }
29765 diff --git a/arch/x86/oprofile/backtrace.c b/arch/x86/oprofile/backtrace.c
29766 index d6aa6e8..266395a 100644
29767 --- a/arch/x86/oprofile/backtrace.c
29768 +++ b/arch/x86/oprofile/backtrace.c
29769 @@ -46,11 +46,11 @@ dump_user_backtrace_32(struct stack_frame_ia32 *head)
29770 struct stack_frame_ia32 *fp;
29771 unsigned long bytes;
29772
29773 - bytes = copy_from_user_nmi(bufhead, head, sizeof(bufhead));
29774 + bytes = copy_from_user_nmi(bufhead, (const char __force_user *)head, sizeof(bufhead));
29775 if (bytes != sizeof(bufhead))
29776 return NULL;
29777
29778 - fp = (struct stack_frame_ia32 *) compat_ptr(bufhead[0].next_frame);
29779 + fp = (struct stack_frame_ia32 __force_kernel *) compat_ptr(bufhead[0].next_frame);
29780
29781 oprofile_add_trace(bufhead[0].return_address);
29782
29783 @@ -92,7 +92,7 @@ static struct stack_frame *dump_user_backtrace(struct stack_frame *head)
29784 struct stack_frame bufhead[2];
29785 unsigned long bytes;
29786
29787 - bytes = copy_from_user_nmi(bufhead, head, sizeof(bufhead));
29788 + bytes = copy_from_user_nmi(bufhead, (const char __force_user *)head, sizeof(bufhead));
29789 if (bytes != sizeof(bufhead))
29790 return NULL;
29791
29792 @@ -111,7 +111,7 @@ x86_backtrace(struct pt_regs * const regs, unsigned int depth)
29793 {
29794 struct stack_frame *head = (struct stack_frame *)frame_pointer(regs);
29795
29796 - if (!user_mode_vm(regs)) {
29797 + if (!user_mode(regs)) {
29798 unsigned long stack = kernel_stack_pointer(regs);
29799 if (depth)
29800 dump_trace(NULL, regs, (unsigned long *)stack, 0,
29801 diff --git a/arch/x86/oprofile/nmi_int.c b/arch/x86/oprofile/nmi_int.c
29802 index 48768df..ba9143c 100644
29803 --- a/arch/x86/oprofile/nmi_int.c
29804 +++ b/arch/x86/oprofile/nmi_int.c
29805 @@ -23,6 +23,7 @@
29806 #include <asm/nmi.h>
29807 #include <asm/msr.h>
29808 #include <asm/apic.h>
29809 +#include <asm/pgtable.h>
29810
29811 #include "op_counter.h"
29812 #include "op_x86_model.h"
29813 @@ -774,8 +775,11 @@ int __init op_nmi_init(struct oprofile_operations *ops)
29814 if (ret)
29815 return ret;
29816
29817 - if (!model->num_virt_counters)
29818 - model->num_virt_counters = model->num_counters;
29819 + if (!model->num_virt_counters) {
29820 + pax_open_kernel();
29821 + *(unsigned int *)&model->num_virt_counters = model->num_counters;
29822 + pax_close_kernel();
29823 + }
29824
29825 mux_init(ops);
29826
29827 diff --git a/arch/x86/oprofile/op_model_amd.c b/arch/x86/oprofile/op_model_amd.c
29828 index b2b9443..be58856 100644
29829 --- a/arch/x86/oprofile/op_model_amd.c
29830 +++ b/arch/x86/oprofile/op_model_amd.c
29831 @@ -519,9 +519,11 @@ static int op_amd_init(struct oprofile_operations *ops)
29832 num_counters = AMD64_NUM_COUNTERS;
29833 }
29834
29835 - op_amd_spec.num_counters = num_counters;
29836 - op_amd_spec.num_controls = num_counters;
29837 - op_amd_spec.num_virt_counters = max(num_counters, NUM_VIRT_COUNTERS);
29838 + pax_open_kernel();
29839 + *(unsigned int *)&op_amd_spec.num_counters = num_counters;
29840 + *(unsigned int *)&op_amd_spec.num_controls = num_counters;
29841 + *(unsigned int *)&op_amd_spec.num_virt_counters = max(num_counters, NUM_VIRT_COUNTERS);
29842 + pax_close_kernel();
29843
29844 return 0;
29845 }
29846 diff --git a/arch/x86/oprofile/op_model_ppro.c b/arch/x86/oprofile/op_model_ppro.c
29847 index d90528e..0127e2b 100644
29848 --- a/arch/x86/oprofile/op_model_ppro.c
29849 +++ b/arch/x86/oprofile/op_model_ppro.c
29850 @@ -19,6 +19,7 @@
29851 #include <asm/msr.h>
29852 #include <asm/apic.h>
29853 #include <asm/nmi.h>
29854 +#include <asm/pgtable.h>
29855
29856 #include "op_x86_model.h"
29857 #include "op_counter.h"
29858 @@ -221,8 +222,10 @@ static void arch_perfmon_setup_counters(void)
29859
29860 num_counters = min((int)eax.split.num_counters, OP_MAX_COUNTER);
29861
29862 - op_arch_perfmon_spec.num_counters = num_counters;
29863 - op_arch_perfmon_spec.num_controls = num_counters;
29864 + pax_open_kernel();
29865 + *(unsigned int *)&op_arch_perfmon_spec.num_counters = num_counters;
29866 + *(unsigned int *)&op_arch_perfmon_spec.num_controls = num_counters;
29867 + pax_close_kernel();
29868 }
29869
29870 static int arch_perfmon_init(struct oprofile_operations *ignore)
29871 diff --git a/arch/x86/oprofile/op_x86_model.h b/arch/x86/oprofile/op_x86_model.h
29872 index 71e8a67..6a313bb 100644
29873 --- a/arch/x86/oprofile/op_x86_model.h
29874 +++ b/arch/x86/oprofile/op_x86_model.h
29875 @@ -52,7 +52,7 @@ struct op_x86_model_spec {
29876 void (*switch_ctrl)(struct op_x86_model_spec const *model,
29877 struct op_msrs const * const msrs);
29878 #endif
29879 -};
29880 +} __do_const;
29881
29882 struct op_counter_config;
29883
29884 diff --git a/arch/x86/pci/amd_bus.c b/arch/x86/pci/amd_bus.c
29885 index e9e6ed5..e47ae67 100644
29886 --- a/arch/x86/pci/amd_bus.c
29887 +++ b/arch/x86/pci/amd_bus.c
29888 @@ -337,7 +337,7 @@ static int __cpuinit amd_cpu_notify(struct notifier_block *self,
29889 return NOTIFY_OK;
29890 }
29891
29892 -static struct notifier_block __cpuinitdata amd_cpu_notifier = {
29893 +static struct notifier_block amd_cpu_notifier = {
29894 .notifier_call = amd_cpu_notify,
29895 };
29896
29897 diff --git a/arch/x86/pci/irq.c b/arch/x86/pci/irq.c
29898 index 372e9b8..e775a6c 100644
29899 --- a/arch/x86/pci/irq.c
29900 +++ b/arch/x86/pci/irq.c
29901 @@ -50,7 +50,7 @@ struct irq_router {
29902 struct irq_router_handler {
29903 u16 vendor;
29904 int (*probe)(struct irq_router *r, struct pci_dev *router, u16 device);
29905 -};
29906 +} __do_const;
29907
29908 int (*pcibios_enable_irq)(struct pci_dev *dev) = pirq_enable_irq;
29909 void (*pcibios_disable_irq)(struct pci_dev *dev) = NULL;
29910 @@ -794,7 +794,7 @@ static __init int pico_router_probe(struct irq_router *r, struct pci_dev *router
29911 return 0;
29912 }
29913
29914 -static __initdata struct irq_router_handler pirq_routers[] = {
29915 +static __initconst const struct irq_router_handler pirq_routers[] = {
29916 { PCI_VENDOR_ID_INTEL, intel_router_probe },
29917 { PCI_VENDOR_ID_AL, ali_router_probe },
29918 { PCI_VENDOR_ID_ITE, ite_router_probe },
29919 @@ -821,7 +821,7 @@ static struct pci_dev *pirq_router_dev;
29920 static void __init pirq_find_router(struct irq_router *r)
29921 {
29922 struct irq_routing_table *rt = pirq_table;
29923 - struct irq_router_handler *h;
29924 + const struct irq_router_handler *h;
29925
29926 #ifdef CONFIG_PCI_BIOS
29927 if (!rt->signature) {
29928 @@ -1094,7 +1094,7 @@ static int __init fix_acer_tm360_irqrouting(const struct dmi_system_id *d)
29929 return 0;
29930 }
29931
29932 -static struct dmi_system_id __initdata pciirq_dmi_table[] = {
29933 +static const struct dmi_system_id __initconst pciirq_dmi_table[] = {
29934 {
29935 .callback = fix_broken_hp_bios_irq9,
29936 .ident = "HP Pavilion N5400 Series Laptop",
29937 diff --git a/arch/x86/pci/mrst.c b/arch/x86/pci/mrst.c
29938 index 6eb18c4..20d83de 100644
29939 --- a/arch/x86/pci/mrst.c
29940 +++ b/arch/x86/pci/mrst.c
29941 @@ -238,7 +238,9 @@ int __init pci_mrst_init(void)
29942 printk(KERN_INFO "Intel MID platform detected, using MID PCI ops\n");
29943 pci_mmcfg_late_init();
29944 pcibios_enable_irq = mrst_pci_irq_enable;
29945 - pci_root_ops = pci_mrst_ops;
29946 + pax_open_kernel();
29947 + memcpy((void *)&pci_root_ops, &pci_mrst_ops, sizeof(pci_mrst_ops));
29948 + pax_close_kernel();
29949 pci_soc_mode = 1;
29950 /* Continue with standard init */
29951 return 1;
29952 diff --git a/arch/x86/pci/pcbios.c b/arch/x86/pci/pcbios.c
29953 index c77b24a..c979855 100644
29954 --- a/arch/x86/pci/pcbios.c
29955 +++ b/arch/x86/pci/pcbios.c
29956 @@ -79,7 +79,7 @@ union bios32 {
29957 static struct {
29958 unsigned long address;
29959 unsigned short segment;
29960 -} bios32_indirect = { 0, __KERNEL_CS };
29961 +} bios32_indirect __read_only = { 0, __PCIBIOS_CS };
29962
29963 /*
29964 * Returns the entry point for the given service, NULL on error
29965 @@ -92,37 +92,80 @@ static unsigned long bios32_service(unsigned long service)
29966 unsigned long length; /* %ecx */
29967 unsigned long entry; /* %edx */
29968 unsigned long flags;
29969 + struct desc_struct d, *gdt;
29970
29971 local_irq_save(flags);
29972 - __asm__("lcall *(%%edi); cld"
29973 +
29974 + gdt = get_cpu_gdt_table(smp_processor_id());
29975 +
29976 + pack_descriptor(&d, 0UL, 0xFFFFFUL, 0x9B, 0xC);
29977 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_CS, &d, DESCTYPE_S);
29978 + pack_descriptor(&d, 0UL, 0xFFFFFUL, 0x93, 0xC);
29979 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_DS, &d, DESCTYPE_S);
29980 +
29981 + __asm__("movw %w7, %%ds; lcall *(%%edi); push %%ss; pop %%ds; cld"
29982 : "=a" (return_code),
29983 "=b" (address),
29984 "=c" (length),
29985 "=d" (entry)
29986 : "0" (service),
29987 "1" (0),
29988 - "D" (&bios32_indirect));
29989 + "D" (&bios32_indirect),
29990 + "r"(__PCIBIOS_DS)
29991 + : "memory");
29992 +
29993 + pax_open_kernel();
29994 + gdt[GDT_ENTRY_PCIBIOS_CS].a = 0;
29995 + gdt[GDT_ENTRY_PCIBIOS_CS].b = 0;
29996 + gdt[GDT_ENTRY_PCIBIOS_DS].a = 0;
29997 + gdt[GDT_ENTRY_PCIBIOS_DS].b = 0;
29998 + pax_close_kernel();
29999 +
30000 local_irq_restore(flags);
30001
30002 switch (return_code) {
30003 - case 0:
30004 - return address + entry;
30005 - case 0x80: /* Not present */
30006 - printk(KERN_WARNING "bios32_service(0x%lx): not present\n", service);
30007 - return 0;
30008 - default: /* Shouldn't happen */
30009 - printk(KERN_WARNING "bios32_service(0x%lx): returned 0x%x -- BIOS bug!\n",
30010 - service, return_code);
30011 + case 0: {
30012 + int cpu;
30013 + unsigned char flags;
30014 +
30015 + printk(KERN_INFO "bios32_service: base:%08lx length:%08lx entry:%08lx\n", address, length, entry);
30016 + if (address >= 0xFFFF0 || length > 0x100000 - address || length <= entry) {
30017 + printk(KERN_WARNING "bios32_service: not valid\n");
30018 return 0;
30019 + }
30020 + address = address + PAGE_OFFSET;
30021 + length += 16UL; /* some BIOSs underreport this... */
30022 + flags = 4;
30023 + if (length >= 64*1024*1024) {
30024 + length >>= PAGE_SHIFT;
30025 + flags |= 8;
30026 + }
30027 +
30028 + for (cpu = 0; cpu < nr_cpu_ids; cpu++) {
30029 + gdt = get_cpu_gdt_table(cpu);
30030 + pack_descriptor(&d, address, length, 0x9b, flags);
30031 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_CS, &d, DESCTYPE_S);
30032 + pack_descriptor(&d, address, length, 0x93, flags);
30033 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_DS, &d, DESCTYPE_S);
30034 + }
30035 + return entry;
30036 + }
30037 + case 0x80: /* Not present */
30038 + printk(KERN_WARNING "bios32_service(0x%lx): not present\n", service);
30039 + return 0;
30040 + default: /* Shouldn't happen */
30041 + printk(KERN_WARNING "bios32_service(0x%lx): returned 0x%x -- BIOS bug!\n",
30042 + service, return_code);
30043 + return 0;
30044 }
30045 }
30046
30047 static struct {
30048 unsigned long address;
30049 unsigned short segment;
30050 -} pci_indirect = { 0, __KERNEL_CS };
30051 +} pci_indirect __read_only = { 0, __PCIBIOS_CS };
30052
30053 -static int pci_bios_present;
30054 +static int pci_bios_present __read_only;
30055
30056 static int check_pcibios(void)
30057 {
30058 @@ -131,11 +174,13 @@ static int check_pcibios(void)
30059 unsigned long flags, pcibios_entry;
30060
30061 if ((pcibios_entry = bios32_service(PCI_SERVICE))) {
30062 - pci_indirect.address = pcibios_entry + PAGE_OFFSET;
30063 + pci_indirect.address = pcibios_entry;
30064
30065 local_irq_save(flags);
30066 - __asm__(
30067 - "lcall *(%%edi); cld\n\t"
30068 + __asm__("movw %w6, %%ds\n\t"
30069 + "lcall *%%ss:(%%edi); cld\n\t"
30070 + "push %%ss\n\t"
30071 + "pop %%ds\n\t"
30072 "jc 1f\n\t"
30073 "xor %%ah, %%ah\n"
30074 "1:"
30075 @@ -144,7 +189,8 @@ static int check_pcibios(void)
30076 "=b" (ebx),
30077 "=c" (ecx)
30078 : "1" (PCIBIOS_PCI_BIOS_PRESENT),
30079 - "D" (&pci_indirect)
30080 + "D" (&pci_indirect),
30081 + "r" (__PCIBIOS_DS)
30082 : "memory");
30083 local_irq_restore(flags);
30084
30085 @@ -189,7 +235,10 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
30086
30087 switch (len) {
30088 case 1:
30089 - __asm__("lcall *(%%esi); cld\n\t"
30090 + __asm__("movw %w6, %%ds\n\t"
30091 + "lcall *%%ss:(%%esi); cld\n\t"
30092 + "push %%ss\n\t"
30093 + "pop %%ds\n\t"
30094 "jc 1f\n\t"
30095 "xor %%ah, %%ah\n"
30096 "1:"
30097 @@ -198,7 +247,8 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
30098 : "1" (PCIBIOS_READ_CONFIG_BYTE),
30099 "b" (bx),
30100 "D" ((long)reg),
30101 - "S" (&pci_indirect));
30102 + "S" (&pci_indirect),
30103 + "r" (__PCIBIOS_DS));
30104 /*
30105 * Zero-extend the result beyond 8 bits, do not trust the
30106 * BIOS having done it:
30107 @@ -206,7 +256,10 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
30108 *value &= 0xff;
30109 break;
30110 case 2:
30111 - __asm__("lcall *(%%esi); cld\n\t"
30112 + __asm__("movw %w6, %%ds\n\t"
30113 + "lcall *%%ss:(%%esi); cld\n\t"
30114 + "push %%ss\n\t"
30115 + "pop %%ds\n\t"
30116 "jc 1f\n\t"
30117 "xor %%ah, %%ah\n"
30118 "1:"
30119 @@ -215,7 +268,8 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
30120 : "1" (PCIBIOS_READ_CONFIG_WORD),
30121 "b" (bx),
30122 "D" ((long)reg),
30123 - "S" (&pci_indirect));
30124 + "S" (&pci_indirect),
30125 + "r" (__PCIBIOS_DS));
30126 /*
30127 * Zero-extend the result beyond 16 bits, do not trust the
30128 * BIOS having done it:
30129 @@ -223,7 +277,10 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
30130 *value &= 0xffff;
30131 break;
30132 case 4:
30133 - __asm__("lcall *(%%esi); cld\n\t"
30134 + __asm__("movw %w6, %%ds\n\t"
30135 + "lcall *%%ss:(%%esi); cld\n\t"
30136 + "push %%ss\n\t"
30137 + "pop %%ds\n\t"
30138 "jc 1f\n\t"
30139 "xor %%ah, %%ah\n"
30140 "1:"
30141 @@ -232,7 +289,8 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
30142 : "1" (PCIBIOS_READ_CONFIG_DWORD),
30143 "b" (bx),
30144 "D" ((long)reg),
30145 - "S" (&pci_indirect));
30146 + "S" (&pci_indirect),
30147 + "r" (__PCIBIOS_DS));
30148 break;
30149 }
30150
30151 @@ -256,7 +314,10 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
30152
30153 switch (len) {
30154 case 1:
30155 - __asm__("lcall *(%%esi); cld\n\t"
30156 + __asm__("movw %w6, %%ds\n\t"
30157 + "lcall *%%ss:(%%esi); cld\n\t"
30158 + "push %%ss\n\t"
30159 + "pop %%ds\n\t"
30160 "jc 1f\n\t"
30161 "xor %%ah, %%ah\n"
30162 "1:"
30163 @@ -265,10 +326,14 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
30164 "c" (value),
30165 "b" (bx),
30166 "D" ((long)reg),
30167 - "S" (&pci_indirect));
30168 + "S" (&pci_indirect),
30169 + "r" (__PCIBIOS_DS));
30170 break;
30171 case 2:
30172 - __asm__("lcall *(%%esi); cld\n\t"
30173 + __asm__("movw %w6, %%ds\n\t"
30174 + "lcall *%%ss:(%%esi); cld\n\t"
30175 + "push %%ss\n\t"
30176 + "pop %%ds\n\t"
30177 "jc 1f\n\t"
30178 "xor %%ah, %%ah\n"
30179 "1:"
30180 @@ -277,10 +342,14 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
30181 "c" (value),
30182 "b" (bx),
30183 "D" ((long)reg),
30184 - "S" (&pci_indirect));
30185 + "S" (&pci_indirect),
30186 + "r" (__PCIBIOS_DS));
30187 break;
30188 case 4:
30189 - __asm__("lcall *(%%esi); cld\n\t"
30190 + __asm__("movw %w6, %%ds\n\t"
30191 + "lcall *%%ss:(%%esi); cld\n\t"
30192 + "push %%ss\n\t"
30193 + "pop %%ds\n\t"
30194 "jc 1f\n\t"
30195 "xor %%ah, %%ah\n"
30196 "1:"
30197 @@ -289,7 +358,8 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
30198 "c" (value),
30199 "b" (bx),
30200 "D" ((long)reg),
30201 - "S" (&pci_indirect));
30202 + "S" (&pci_indirect),
30203 + "r" (__PCIBIOS_DS));
30204 break;
30205 }
30206
30207 @@ -394,10 +464,13 @@ struct irq_routing_table * pcibios_get_irq_routing_table(void)
30208
30209 DBG("PCI: Fetching IRQ routing table... ");
30210 __asm__("push %%es\n\t"
30211 + "movw %w8, %%ds\n\t"
30212 "push %%ds\n\t"
30213 "pop %%es\n\t"
30214 - "lcall *(%%esi); cld\n\t"
30215 + "lcall *%%ss:(%%esi); cld\n\t"
30216 "pop %%es\n\t"
30217 + "push %%ss\n\t"
30218 + "pop %%ds\n"
30219 "jc 1f\n\t"
30220 "xor %%ah, %%ah\n"
30221 "1:"
30222 @@ -408,7 +481,8 @@ struct irq_routing_table * pcibios_get_irq_routing_table(void)
30223 "1" (0),
30224 "D" ((long) &opt),
30225 "S" (&pci_indirect),
30226 - "m" (opt)
30227 + "m" (opt),
30228 + "r" (__PCIBIOS_DS)
30229 : "memory");
30230 DBG("OK ret=%d, size=%d, map=%x\n", ret, opt.size, map);
30231 if (ret & 0xff00)
30232 @@ -432,7 +506,10 @@ int pcibios_set_irq_routing(struct pci_dev *dev, int pin, int irq)
30233 {
30234 int ret;
30235
30236 - __asm__("lcall *(%%esi); cld\n\t"
30237 + __asm__("movw %w5, %%ds\n\t"
30238 + "lcall *%%ss:(%%esi); cld\n\t"
30239 + "push %%ss\n\t"
30240 + "pop %%ds\n"
30241 "jc 1f\n\t"
30242 "xor %%ah, %%ah\n"
30243 "1:"
30244 @@ -440,7 +517,8 @@ int pcibios_set_irq_routing(struct pci_dev *dev, int pin, int irq)
30245 : "0" (PCIBIOS_SET_PCI_HW_INT),
30246 "b" ((dev->bus->number << 8) | dev->devfn),
30247 "c" ((irq << 8) | (pin + 10)),
30248 - "S" (&pci_indirect));
30249 + "S" (&pci_indirect),
30250 + "r" (__PCIBIOS_DS));
30251 return !(ret & 0xff00);
30252 }
30253 EXPORT_SYMBOL(pcibios_set_irq_routing);
30254 diff --git a/arch/x86/platform/efi/efi_32.c b/arch/x86/platform/efi/efi_32.c
30255 index 40e4469..1ab536e 100644
30256 --- a/arch/x86/platform/efi/efi_32.c
30257 +++ b/arch/x86/platform/efi/efi_32.c
30258 @@ -44,11 +44,22 @@ void efi_call_phys_prelog(void)
30259 {
30260 struct desc_ptr gdt_descr;
30261
30262 +#ifdef CONFIG_PAX_KERNEXEC
30263 + struct desc_struct d;
30264 +#endif
30265 +
30266 local_irq_save(efi_rt_eflags);
30267
30268 load_cr3(initial_page_table);
30269 __flush_tlb_all();
30270
30271 +#ifdef CONFIG_PAX_KERNEXEC
30272 + pack_descriptor(&d, 0, 0xFFFFF, 0x9B, 0xC);
30273 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_CS, &d, DESCTYPE_S);
30274 + pack_descriptor(&d, 0, 0xFFFFF, 0x93, 0xC);
30275 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_DS, &d, DESCTYPE_S);
30276 +#endif
30277 +
30278 gdt_descr.address = __pa(get_cpu_gdt_table(0));
30279 gdt_descr.size = GDT_SIZE - 1;
30280 load_gdt(&gdt_descr);
30281 @@ -58,6 +69,14 @@ void efi_call_phys_epilog(void)
30282 {
30283 struct desc_ptr gdt_descr;
30284
30285 +#ifdef CONFIG_PAX_KERNEXEC
30286 + struct desc_struct d;
30287 +
30288 + memset(&d, 0, sizeof d);
30289 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_CS, &d, DESCTYPE_S);
30290 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_DS, &d, DESCTYPE_S);
30291 +#endif
30292 +
30293 gdt_descr.address = (unsigned long)get_cpu_gdt_table(0);
30294 gdt_descr.size = GDT_SIZE - 1;
30295 load_gdt(&gdt_descr);
30296 diff --git a/arch/x86/platform/efi/efi_stub_32.S b/arch/x86/platform/efi/efi_stub_32.S
30297 index fbe66e6..eae5e38 100644
30298 --- a/arch/x86/platform/efi/efi_stub_32.S
30299 +++ b/arch/x86/platform/efi/efi_stub_32.S
30300 @@ -6,7 +6,9 @@
30301 */
30302
30303 #include <linux/linkage.h>
30304 +#include <linux/init.h>
30305 #include <asm/page_types.h>
30306 +#include <asm/segment.h>
30307
30308 /*
30309 * efi_call_phys(void *, ...) is a function with variable parameters.
30310 @@ -20,7 +22,7 @@
30311 * service functions will comply with gcc calling convention, too.
30312 */
30313
30314 -.text
30315 +__INIT
30316 ENTRY(efi_call_phys)
30317 /*
30318 * 0. The function can only be called in Linux kernel. So CS has been
30319 @@ -36,10 +38,24 @@ ENTRY(efi_call_phys)
30320 * The mapping of lower virtual memory has been created in prelog and
30321 * epilog.
30322 */
30323 - movl $1f, %edx
30324 - subl $__PAGE_OFFSET, %edx
30325 - jmp *%edx
30326 +#ifdef CONFIG_PAX_KERNEXEC
30327 + movl $(__KERNEXEC_EFI_DS), %edx
30328 + mov %edx, %ds
30329 + mov %edx, %es
30330 + mov %edx, %ss
30331 + addl $2f,(1f)
30332 + ljmp *(1f)
30333 +
30334 +__INITDATA
30335 +1: .long __LOAD_PHYSICAL_ADDR, __KERNEXEC_EFI_CS
30336 +.previous
30337 +
30338 +2:
30339 + subl $2b,(1b)
30340 +#else
30341 + jmp 1f-__PAGE_OFFSET
30342 1:
30343 +#endif
30344
30345 /*
30346 * 2. Now on the top of stack is the return
30347 @@ -47,14 +63,8 @@ ENTRY(efi_call_phys)
30348 * parameter 2, ..., param n. To make things easy, we save the return
30349 * address of efi_call_phys in a global variable.
30350 */
30351 - popl %edx
30352 - movl %edx, saved_return_addr
30353 - /* get the function pointer into ECX*/
30354 - popl %ecx
30355 - movl %ecx, efi_rt_function_ptr
30356 - movl $2f, %edx
30357 - subl $__PAGE_OFFSET, %edx
30358 - pushl %edx
30359 + popl (saved_return_addr)
30360 + popl (efi_rt_function_ptr)
30361
30362 /*
30363 * 3. Clear PG bit in %CR0.
30364 @@ -73,9 +83,8 @@ ENTRY(efi_call_phys)
30365 /*
30366 * 5. Call the physical function.
30367 */
30368 - jmp *%ecx
30369 + call *(efi_rt_function_ptr-__PAGE_OFFSET)
30370
30371 -2:
30372 /*
30373 * 6. After EFI runtime service returns, control will return to
30374 * following instruction. We'd better readjust stack pointer first.
30375 @@ -88,35 +97,36 @@ ENTRY(efi_call_phys)
30376 movl %cr0, %edx
30377 orl $0x80000000, %edx
30378 movl %edx, %cr0
30379 - jmp 1f
30380 -1:
30381 +
30382 /*
30383 * 8. Now restore the virtual mode from flat mode by
30384 * adding EIP with PAGE_OFFSET.
30385 */
30386 - movl $1f, %edx
30387 - jmp *%edx
30388 +#ifdef CONFIG_PAX_KERNEXEC
30389 + movl $(__KERNEL_DS), %edx
30390 + mov %edx, %ds
30391 + mov %edx, %es
30392 + mov %edx, %ss
30393 + ljmp $(__KERNEL_CS),$1f
30394 +#else
30395 + jmp 1f+__PAGE_OFFSET
30396 +#endif
30397 1:
30398
30399 /*
30400 * 9. Balance the stack. And because EAX contain the return value,
30401 * we'd better not clobber it.
30402 */
30403 - leal efi_rt_function_ptr, %edx
30404 - movl (%edx), %ecx
30405 - pushl %ecx
30406 + pushl (efi_rt_function_ptr)
30407
30408 /*
30409 - * 10. Push the saved return address onto the stack and return.
30410 + * 10. Return to the saved return address.
30411 */
30412 - leal saved_return_addr, %edx
30413 - movl (%edx), %ecx
30414 - pushl %ecx
30415 - ret
30416 + jmpl *(saved_return_addr)
30417 ENDPROC(efi_call_phys)
30418 .previous
30419
30420 -.data
30421 +__INITDATA
30422 saved_return_addr:
30423 .long 0
30424 efi_rt_function_ptr:
30425 diff --git a/arch/x86/platform/efi/efi_stub_64.S b/arch/x86/platform/efi/efi_stub_64.S
30426 index 4c07cca..2c8427d 100644
30427 --- a/arch/x86/platform/efi/efi_stub_64.S
30428 +++ b/arch/x86/platform/efi/efi_stub_64.S
30429 @@ -7,6 +7,7 @@
30430 */
30431
30432 #include <linux/linkage.h>
30433 +#include <asm/alternative-asm.h>
30434
30435 #define SAVE_XMM \
30436 mov %rsp, %rax; \
30437 @@ -40,6 +41,7 @@ ENTRY(efi_call0)
30438 call *%rdi
30439 addq $32, %rsp
30440 RESTORE_XMM
30441 + pax_force_retaddr 0, 1
30442 ret
30443 ENDPROC(efi_call0)
30444
30445 @@ -50,6 +52,7 @@ ENTRY(efi_call1)
30446 call *%rdi
30447 addq $32, %rsp
30448 RESTORE_XMM
30449 + pax_force_retaddr 0, 1
30450 ret
30451 ENDPROC(efi_call1)
30452
30453 @@ -60,6 +63,7 @@ ENTRY(efi_call2)
30454 call *%rdi
30455 addq $32, %rsp
30456 RESTORE_XMM
30457 + pax_force_retaddr 0, 1
30458 ret
30459 ENDPROC(efi_call2)
30460
30461 @@ -71,6 +75,7 @@ ENTRY(efi_call3)
30462 call *%rdi
30463 addq $32, %rsp
30464 RESTORE_XMM
30465 + pax_force_retaddr 0, 1
30466 ret
30467 ENDPROC(efi_call3)
30468
30469 @@ -83,6 +88,7 @@ ENTRY(efi_call4)
30470 call *%rdi
30471 addq $32, %rsp
30472 RESTORE_XMM
30473 + pax_force_retaddr 0, 1
30474 ret
30475 ENDPROC(efi_call4)
30476
30477 @@ -96,6 +102,7 @@ ENTRY(efi_call5)
30478 call *%rdi
30479 addq $48, %rsp
30480 RESTORE_XMM
30481 + pax_force_retaddr 0, 1
30482 ret
30483 ENDPROC(efi_call5)
30484
30485 @@ -112,5 +119,6 @@ ENTRY(efi_call6)
30486 call *%rdi
30487 addq $48, %rsp
30488 RESTORE_XMM
30489 + pax_force_retaddr 0, 1
30490 ret
30491 ENDPROC(efi_call6)
30492 diff --git a/arch/x86/platform/mrst/mrst.c b/arch/x86/platform/mrst/mrst.c
30493 index e31bcd8..f12dc46 100644
30494 --- a/arch/x86/platform/mrst/mrst.c
30495 +++ b/arch/x86/platform/mrst/mrst.c
30496 @@ -78,13 +78,15 @@ struct sfi_rtc_table_entry sfi_mrtc_array[SFI_MRTC_MAX];
30497 EXPORT_SYMBOL_GPL(sfi_mrtc_array);
30498 int sfi_mrtc_num;
30499
30500 -static void mrst_power_off(void)
30501 +static __noreturn void mrst_power_off(void)
30502 {
30503 + BUG();
30504 }
30505
30506 -static void mrst_reboot(void)
30507 +static __noreturn void mrst_reboot(void)
30508 {
30509 intel_scu_ipc_simple_command(IPCMSG_COLD_BOOT, 0);
30510 + BUG();
30511 }
30512
30513 /* parse all the mtimer info to a static mtimer array */
30514 diff --git a/arch/x86/platform/olpc/olpc_dt.c b/arch/x86/platform/olpc/olpc_dt.c
30515 index d6ee929..3637cb5 100644
30516 --- a/arch/x86/platform/olpc/olpc_dt.c
30517 +++ b/arch/x86/platform/olpc/olpc_dt.c
30518 @@ -156,7 +156,7 @@ void * __init prom_early_alloc(unsigned long size)
30519 return res;
30520 }
30521
30522 -static struct of_pdt_ops prom_olpc_ops __initdata = {
30523 +static struct of_pdt_ops prom_olpc_ops __initconst = {
30524 .nextprop = olpc_dt_nextprop,
30525 .getproplen = olpc_dt_getproplen,
30526 .getproperty = olpc_dt_getproperty,
30527 diff --git a/arch/x86/power/cpu.c b/arch/x86/power/cpu.c
30528 index 3c68768..07e82b8 100644
30529 --- a/arch/x86/power/cpu.c
30530 +++ b/arch/x86/power/cpu.c
30531 @@ -134,7 +134,7 @@ static void do_fpu_end(void)
30532 static void fix_processor_context(void)
30533 {
30534 int cpu = smp_processor_id();
30535 - struct tss_struct *t = &per_cpu(init_tss, cpu);
30536 + struct tss_struct *t = init_tss + cpu;
30537
30538 set_tss_desc(cpu, t); /*
30539 * This just modifies memory; should not be
30540 @@ -144,8 +144,6 @@ static void fix_processor_context(void)
30541 */
30542
30543 #ifdef CONFIG_X86_64
30544 - get_cpu_gdt_table(cpu)[GDT_ENTRY_TSS].type = 9;
30545 -
30546 syscall_init(); /* This sets MSR_*STAR and related */
30547 #endif
30548 load_TR_desc(); /* This does ltr */
30549 diff --git a/arch/x86/realmode/init.c b/arch/x86/realmode/init.c
30550 index cbca565..bae7133 100644
30551 --- a/arch/x86/realmode/init.c
30552 +++ b/arch/x86/realmode/init.c
30553 @@ -62,7 +62,13 @@ void __init setup_real_mode(void)
30554 __va(real_mode_header->trampoline_header);
30555
30556 #ifdef CONFIG_X86_32
30557 - trampoline_header->start = __pa(startup_32_smp);
30558 + trampoline_header->start = __pa(ktla_ktva(startup_32_smp));
30559 +
30560 +#ifdef CONFIG_PAX_KERNEXEC
30561 + trampoline_header->start -= LOAD_PHYSICAL_ADDR;
30562 +#endif
30563 +
30564 + trampoline_header->boot_cs = __BOOT_CS;
30565 trampoline_header->gdt_limit = __BOOT_DS + 7;
30566 trampoline_header->gdt_base = __pa(boot_gdt);
30567 #else
30568 diff --git a/arch/x86/realmode/rm/Makefile b/arch/x86/realmode/rm/Makefile
30569 index 8869287..d577672 100644
30570 --- a/arch/x86/realmode/rm/Makefile
30571 +++ b/arch/x86/realmode/rm/Makefile
30572 @@ -78,5 +78,8 @@ KBUILD_CFLAGS := $(LINUXINCLUDE) -m32 -g -Os -D_SETUP -D__KERNEL__ -D_WAKEUP \
30573 $(call cc-option, -fno-unit-at-a-time)) \
30574 $(call cc-option, -fno-stack-protector) \
30575 $(call cc-option, -mpreferred-stack-boundary=2)
30576 +ifdef CONSTIFY_PLUGIN
30577 +KBUILD_CFLAGS += -fplugin-arg-constify_plugin-no-constify
30578 +endif
30579 KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
30580 GCOV_PROFILE := n
30581 diff --git a/arch/x86/realmode/rm/header.S b/arch/x86/realmode/rm/header.S
30582 index a28221d..93c40f1 100644
30583 --- a/arch/x86/realmode/rm/header.S
30584 +++ b/arch/x86/realmode/rm/header.S
30585 @@ -30,7 +30,9 @@ GLOBAL(real_mode_header)
30586 #endif
30587 /* APM/BIOS reboot */
30588 .long pa_machine_real_restart_asm
30589 -#ifdef CONFIG_X86_64
30590 +#ifdef CONFIG_X86_32
30591 + .long __KERNEL_CS
30592 +#else
30593 .long __KERNEL32_CS
30594 #endif
30595 END(real_mode_header)
30596 diff --git a/arch/x86/realmode/rm/trampoline_32.S b/arch/x86/realmode/rm/trampoline_32.S
30597 index c1b2791..f9e31c7 100644
30598 --- a/arch/x86/realmode/rm/trampoline_32.S
30599 +++ b/arch/x86/realmode/rm/trampoline_32.S
30600 @@ -25,6 +25,12 @@
30601 #include <asm/page_types.h>
30602 #include "realmode.h"
30603
30604 +#ifdef CONFIG_PAX_KERNEXEC
30605 +#define ta(X) (X)
30606 +#else
30607 +#define ta(X) (pa_ ## X)
30608 +#endif
30609 +
30610 .text
30611 .code16
30612
30613 @@ -39,8 +45,6 @@ ENTRY(trampoline_start)
30614
30615 cli # We should be safe anyway
30616
30617 - movl tr_start, %eax # where we need to go
30618 -
30619 movl $0xA5A5A5A5, trampoline_status
30620 # write marker for master knows we're running
30621
30622 @@ -56,7 +60,7 @@ ENTRY(trampoline_start)
30623 movw $1, %dx # protected mode (PE) bit
30624 lmsw %dx # into protected mode
30625
30626 - ljmpl $__BOOT_CS, $pa_startup_32
30627 + ljmpl *(trampoline_header)
30628
30629 .section ".text32","ax"
30630 .code32
30631 @@ -67,7 +71,7 @@ ENTRY(startup_32) # note: also used from wakeup_asm.S
30632 .balign 8
30633 GLOBAL(trampoline_header)
30634 tr_start: .space 4
30635 - tr_gdt_pad: .space 2
30636 + tr_boot_cs: .space 2
30637 tr_gdt: .space 6
30638 END(trampoline_header)
30639
30640 diff --git a/arch/x86/realmode/rm/trampoline_64.S b/arch/x86/realmode/rm/trampoline_64.S
30641 index bb360dc..3e5945f 100644
30642 --- a/arch/x86/realmode/rm/trampoline_64.S
30643 +++ b/arch/x86/realmode/rm/trampoline_64.S
30644 @@ -107,7 +107,7 @@ ENTRY(startup_32)
30645 wrmsr
30646
30647 # Enable paging and in turn activate Long Mode
30648 - movl $(X86_CR0_PG | X86_CR0_WP | X86_CR0_PE), %eax
30649 + movl $(X86_CR0_PG | X86_CR0_PE), %eax
30650 movl %eax, %cr0
30651
30652 /*
30653 diff --git a/arch/x86/tools/relocs.c b/arch/x86/tools/relocs.c
30654 index 79d67bd..c7e1b90 100644
30655 --- a/arch/x86/tools/relocs.c
30656 +++ b/arch/x86/tools/relocs.c
30657 @@ -12,10 +12,13 @@
30658 #include <regex.h>
30659 #include <tools/le_byteshift.h>
30660
30661 +#include "../../../include/generated/autoconf.h"
30662 +
30663 static void die(char *fmt, ...);
30664
30665 #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
30666 static Elf32_Ehdr ehdr;
30667 +static Elf32_Phdr *phdr;
30668 static unsigned long reloc_count, reloc_idx;
30669 static unsigned long *relocs;
30670 static unsigned long reloc16_count, reloc16_idx;
30671 @@ -330,9 +333,39 @@ static void read_ehdr(FILE *fp)
30672 }
30673 }
30674
30675 +static void read_phdrs(FILE *fp)
30676 +{
30677 + unsigned int i;
30678 +
30679 + phdr = calloc(ehdr.e_phnum, sizeof(Elf32_Phdr));
30680 + if (!phdr) {
30681 + die("Unable to allocate %d program headers\n",
30682 + ehdr.e_phnum);
30683 + }
30684 + if (fseek(fp, ehdr.e_phoff, SEEK_SET) < 0) {
30685 + die("Seek to %d failed: %s\n",
30686 + ehdr.e_phoff, strerror(errno));
30687 + }
30688 + if (fread(phdr, sizeof(*phdr), ehdr.e_phnum, fp) != ehdr.e_phnum) {
30689 + die("Cannot read ELF program headers: %s\n",
30690 + strerror(errno));
30691 + }
30692 + for(i = 0; i < ehdr.e_phnum; i++) {
30693 + phdr[i].p_type = elf32_to_cpu(phdr[i].p_type);
30694 + phdr[i].p_offset = elf32_to_cpu(phdr[i].p_offset);
30695 + phdr[i].p_vaddr = elf32_to_cpu(phdr[i].p_vaddr);
30696 + phdr[i].p_paddr = elf32_to_cpu(phdr[i].p_paddr);
30697 + phdr[i].p_filesz = elf32_to_cpu(phdr[i].p_filesz);
30698 + phdr[i].p_memsz = elf32_to_cpu(phdr[i].p_memsz);
30699 + phdr[i].p_flags = elf32_to_cpu(phdr[i].p_flags);
30700 + phdr[i].p_align = elf32_to_cpu(phdr[i].p_align);
30701 + }
30702 +
30703 +}
30704 +
30705 static void read_shdrs(FILE *fp)
30706 {
30707 - int i;
30708 + unsigned int i;
30709 Elf32_Shdr shdr;
30710
30711 secs = calloc(ehdr.e_shnum, sizeof(struct section));
30712 @@ -367,7 +400,7 @@ static void read_shdrs(FILE *fp)
30713
30714 static void read_strtabs(FILE *fp)
30715 {
30716 - int i;
30717 + unsigned int i;
30718 for (i = 0; i < ehdr.e_shnum; i++) {
30719 struct section *sec = &secs[i];
30720 if (sec->shdr.sh_type != SHT_STRTAB) {
30721 @@ -392,7 +425,7 @@ static void read_strtabs(FILE *fp)
30722
30723 static void read_symtabs(FILE *fp)
30724 {
30725 - int i,j;
30726 + unsigned int i,j;
30727 for (i = 0; i < ehdr.e_shnum; i++) {
30728 struct section *sec = &secs[i];
30729 if (sec->shdr.sh_type != SHT_SYMTAB) {
30730 @@ -423,9 +456,11 @@ static void read_symtabs(FILE *fp)
30731 }
30732
30733
30734 -static void read_relocs(FILE *fp)
30735 +static void read_relocs(FILE *fp, int use_real_mode)
30736 {
30737 - int i,j;
30738 + unsigned int i,j;
30739 + uint32_t base;
30740 +
30741 for (i = 0; i < ehdr.e_shnum; i++) {
30742 struct section *sec = &secs[i];
30743 if (sec->shdr.sh_type != SHT_REL) {
30744 @@ -445,9 +480,22 @@ static void read_relocs(FILE *fp)
30745 die("Cannot read symbol table: %s\n",
30746 strerror(errno));
30747 }
30748 + base = 0;
30749 +
30750 +#ifdef CONFIG_X86_32
30751 + for (j = 0; !use_real_mode && j < ehdr.e_phnum; j++) {
30752 + if (phdr[j].p_type != PT_LOAD )
30753 + continue;
30754 + 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)
30755 + continue;
30756 + base = CONFIG_PAGE_OFFSET + phdr[j].p_paddr - phdr[j].p_vaddr;
30757 + break;
30758 + }
30759 +#endif
30760 +
30761 for (j = 0; j < sec->shdr.sh_size/sizeof(Elf32_Rel); j++) {
30762 Elf32_Rel *rel = &sec->reltab[j];
30763 - rel->r_offset = elf32_to_cpu(rel->r_offset);
30764 + rel->r_offset = elf32_to_cpu(rel->r_offset) + base;
30765 rel->r_info = elf32_to_cpu(rel->r_info);
30766 }
30767 }
30768 @@ -456,13 +504,13 @@ static void read_relocs(FILE *fp)
30769
30770 static void print_absolute_symbols(void)
30771 {
30772 - int i;
30773 + unsigned int i;
30774 printf("Absolute symbols\n");
30775 printf(" Num: Value Size Type Bind Visibility Name\n");
30776 for (i = 0; i < ehdr.e_shnum; i++) {
30777 struct section *sec = &secs[i];
30778 char *sym_strtab;
30779 - int j;
30780 + unsigned int j;
30781
30782 if (sec->shdr.sh_type != SHT_SYMTAB) {
30783 continue;
30784 @@ -489,14 +537,14 @@ static void print_absolute_symbols(void)
30785
30786 static void print_absolute_relocs(void)
30787 {
30788 - int i, printed = 0;
30789 + unsigned int i, printed = 0;
30790
30791 for (i = 0; i < ehdr.e_shnum; i++) {
30792 struct section *sec = &secs[i];
30793 struct section *sec_applies, *sec_symtab;
30794 char *sym_strtab;
30795 Elf32_Sym *sh_symtab;
30796 - int j;
30797 + unsigned int j;
30798 if (sec->shdr.sh_type != SHT_REL) {
30799 continue;
30800 }
30801 @@ -558,13 +606,13 @@ static void print_absolute_relocs(void)
30802 static void walk_relocs(void (*visit)(Elf32_Rel *rel, Elf32_Sym *sym),
30803 int use_real_mode)
30804 {
30805 - int i;
30806 + unsigned int i;
30807 /* Walk through the relocations */
30808 for (i = 0; i < ehdr.e_shnum; i++) {
30809 char *sym_strtab;
30810 Elf32_Sym *sh_symtab;
30811 struct section *sec_applies, *sec_symtab;
30812 - int j;
30813 + unsigned int j;
30814 struct section *sec = &secs[i];
30815
30816 if (sec->shdr.sh_type != SHT_REL) {
30817 @@ -588,6 +636,24 @@ static void walk_relocs(void (*visit)(Elf32_Rel *rel, Elf32_Sym *sym),
30818 sym = &sh_symtab[ELF32_R_SYM(rel->r_info)];
30819 r_type = ELF32_R_TYPE(rel->r_info);
30820
30821 + if (!use_real_mode) {
30822 + /* Don't relocate actual per-cpu variables, they are absolute indices, not addresses */
30823 + if (!strcmp(sec_name(sym->st_shndx), ".data..percpu") && strcmp(sym_name(sym_strtab, sym), "__per_cpu_load"))
30824 + continue;
30825 +
30826 +#if defined(CONFIG_PAX_KERNEXEC) && defined(CONFIG_X86_32)
30827 + /* Don't relocate actual code, they are relocated implicitly by the base address of KERNEL_CS */
30828 + if (!strcmp(sec_name(sym->st_shndx), ".text.end") && !strcmp(sym_name(sym_strtab, sym), "_etext"))
30829 + continue;
30830 + if (!strcmp(sec_name(sym->st_shndx), ".init.text"))
30831 + continue;
30832 + if (!strcmp(sec_name(sym->st_shndx), ".exit.text"))
30833 + continue;
30834 + if (!strcmp(sec_name(sym->st_shndx), ".text") && strcmp(sym_name(sym_strtab, sym), "__LOAD_PHYSICAL_ADDR"))
30835 + continue;
30836 +#endif
30837 + }
30838 +
30839 shn_abs = sym->st_shndx == SHN_ABS;
30840
30841 switch (r_type) {
30842 @@ -681,7 +747,7 @@ static int write32(unsigned int v, FILE *f)
30843
30844 static void emit_relocs(int as_text, int use_real_mode)
30845 {
30846 - int i;
30847 + unsigned int i;
30848 /* Count how many relocations I have and allocate space for them. */
30849 reloc_count = 0;
30850 walk_relocs(count_reloc, use_real_mode);
30851 @@ -808,10 +874,11 @@ int main(int argc, char **argv)
30852 fname, strerror(errno));
30853 }
30854 read_ehdr(fp);
30855 + read_phdrs(fp);
30856 read_shdrs(fp);
30857 read_strtabs(fp);
30858 read_symtabs(fp);
30859 - read_relocs(fp);
30860 + read_relocs(fp, use_real_mode);
30861 if (show_absolute_syms) {
30862 print_absolute_symbols();
30863 goto out;
30864 diff --git a/arch/x86/vdso/Makefile b/arch/x86/vdso/Makefile
30865 index fd14be1..e3c79c0 100644
30866 --- a/arch/x86/vdso/Makefile
30867 +++ b/arch/x86/vdso/Makefile
30868 @@ -181,7 +181,7 @@ quiet_cmd_vdso = VDSO $@
30869 -Wl,-T,$(filter %.lds,$^) $(filter %.o,$^) && \
30870 sh $(srctree)/$(src)/checkundef.sh '$(NM)' '$@'
30871
30872 -VDSO_LDFLAGS = -fPIC -shared $(call cc-ldoption, -Wl$(comma)--hash-style=sysv)
30873 +VDSO_LDFLAGS = -fPIC -shared -Wl,--no-undefined $(call cc-ldoption, -Wl$(comma)--hash-style=sysv)
30874 GCOV_PROFILE := n
30875
30876 #
30877 diff --git a/arch/x86/vdso/vdso32-setup.c b/arch/x86/vdso/vdso32-setup.c
30878 index 0faad64..39ef157 100644
30879 --- a/arch/x86/vdso/vdso32-setup.c
30880 +++ b/arch/x86/vdso/vdso32-setup.c
30881 @@ -25,6 +25,7 @@
30882 #include <asm/tlbflush.h>
30883 #include <asm/vdso.h>
30884 #include <asm/proto.h>
30885 +#include <asm/mman.h>
30886
30887 enum {
30888 VDSO_DISABLED = 0,
30889 @@ -226,7 +227,7 @@ static inline void map_compat_vdso(int map)
30890 void enable_sep_cpu(void)
30891 {
30892 int cpu = get_cpu();
30893 - struct tss_struct *tss = &per_cpu(init_tss, cpu);
30894 + struct tss_struct *tss = init_tss + cpu;
30895
30896 if (!boot_cpu_has(X86_FEATURE_SEP)) {
30897 put_cpu();
30898 @@ -249,7 +250,7 @@ static int __init gate_vma_init(void)
30899 gate_vma.vm_start = FIXADDR_USER_START;
30900 gate_vma.vm_end = FIXADDR_USER_END;
30901 gate_vma.vm_flags = VM_READ | VM_MAYREAD | VM_EXEC | VM_MAYEXEC;
30902 - gate_vma.vm_page_prot = __P101;
30903 + gate_vma.vm_page_prot = vm_get_page_prot(gate_vma.vm_flags);
30904
30905 return 0;
30906 }
30907 @@ -330,14 +331,14 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
30908 if (compat)
30909 addr = VDSO_HIGH_BASE;
30910 else {
30911 - addr = get_unmapped_area(NULL, 0, PAGE_SIZE, 0, 0);
30912 + addr = get_unmapped_area(NULL, 0, PAGE_SIZE, 0, MAP_EXECUTABLE);
30913 if (IS_ERR_VALUE(addr)) {
30914 ret = addr;
30915 goto up_fail;
30916 }
30917 }
30918
30919 - current->mm->context.vdso = (void *)addr;
30920 + current->mm->context.vdso = addr;
30921
30922 if (compat_uses_vma || !compat) {
30923 /*
30924 @@ -353,11 +354,11 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
30925 }
30926
30927 current_thread_info()->sysenter_return =
30928 - VDSO32_SYMBOL(addr, SYSENTER_RETURN);
30929 + (__force void __user *)VDSO32_SYMBOL(addr, SYSENTER_RETURN);
30930
30931 up_fail:
30932 if (ret)
30933 - current->mm->context.vdso = NULL;
30934 + current->mm->context.vdso = 0;
30935
30936 up_write(&mm->mmap_sem);
30937
30938 @@ -404,8 +405,14 @@ __initcall(ia32_binfmt_init);
30939
30940 const char *arch_vma_name(struct vm_area_struct *vma)
30941 {
30942 - if (vma->vm_mm && vma->vm_start == (long)vma->vm_mm->context.vdso)
30943 + if (vma->vm_mm && vma->vm_start == vma->vm_mm->context.vdso)
30944 return "[vdso]";
30945 +
30946 +#ifdef CONFIG_PAX_SEGMEXEC
30947 + if (vma->vm_mm && vma->vm_mirror && vma->vm_mirror->vm_start == vma->vm_mm->context.vdso)
30948 + return "[vdso]";
30949 +#endif
30950 +
30951 return NULL;
30952 }
30953
30954 @@ -415,7 +422,7 @@ struct vm_area_struct *get_gate_vma(struct mm_struct *mm)
30955 * Check to see if the corresponding task was created in compat vdso
30956 * mode.
30957 */
30958 - if (mm && mm->context.vdso == (void *)VDSO_HIGH_BASE)
30959 + if (mm && mm->context.vdso == VDSO_HIGH_BASE)
30960 return &gate_vma;
30961 return NULL;
30962 }
30963 diff --git a/arch/x86/vdso/vma.c b/arch/x86/vdso/vma.c
30964 index 431e875..cbb23f3 100644
30965 --- a/arch/x86/vdso/vma.c
30966 +++ b/arch/x86/vdso/vma.c
30967 @@ -16,8 +16,6 @@
30968 #include <asm/vdso.h>
30969 #include <asm/page.h>
30970
30971 -unsigned int __read_mostly vdso_enabled = 1;
30972 -
30973 extern char vdso_start[], vdso_end[];
30974 extern unsigned short vdso_sync_cpuid;
30975
30976 @@ -141,7 +139,6 @@ static unsigned long vdso_addr(unsigned long start, unsigned len)
30977 * unaligned here as a result of stack start randomization.
30978 */
30979 addr = PAGE_ALIGN(addr);
30980 - addr = align_vdso_addr(addr);
30981
30982 return addr;
30983 }
30984 @@ -154,30 +151,31 @@ static int setup_additional_pages(struct linux_binprm *bprm,
30985 unsigned size)
30986 {
30987 struct mm_struct *mm = current->mm;
30988 - unsigned long addr;
30989 + unsigned long addr = 0;
30990 int ret;
30991
30992 - if (!vdso_enabled)
30993 - return 0;
30994 -
30995 down_write(&mm->mmap_sem);
30996 +
30997 +#ifdef CONFIG_PAX_RANDMMAP
30998 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
30999 +#endif
31000 +
31001 addr = vdso_addr(mm->start_stack, size);
31002 + addr = align_vdso_addr(addr);
31003 addr = get_unmapped_area(NULL, addr, size, 0, 0);
31004 if (IS_ERR_VALUE(addr)) {
31005 ret = addr;
31006 goto up_fail;
31007 }
31008
31009 - current->mm->context.vdso = (void *)addr;
31010 + mm->context.vdso = addr;
31011
31012 ret = install_special_mapping(mm, addr, size,
31013 VM_READ|VM_EXEC|
31014 VM_MAYREAD|VM_MAYWRITE|VM_MAYEXEC,
31015 pages);
31016 - if (ret) {
31017 - current->mm->context.vdso = NULL;
31018 - goto up_fail;
31019 - }
31020 + if (ret)
31021 + mm->context.vdso = 0;
31022
31023 up_fail:
31024 up_write(&mm->mmap_sem);
31025 @@ -197,10 +195,3 @@ int x32_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
31026 vdsox32_size);
31027 }
31028 #endif
31029 -
31030 -static __init int vdso_setup(char *s)
31031 -{
31032 - vdso_enabled = simple_strtoul(s, NULL, 0);
31033 - return 0;
31034 -}
31035 -__setup("vdso=", vdso_setup);
31036 diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c
31037 index 2262003..f229ced 100644
31038 --- a/arch/x86/xen/enlighten.c
31039 +++ b/arch/x86/xen/enlighten.c
31040 @@ -100,8 +100,6 @@ EXPORT_SYMBOL_GPL(xen_start_info);
31041
31042 struct shared_info xen_dummy_shared_info;
31043
31044 -void *xen_initial_gdt;
31045 -
31046 RESERVE_BRK(shared_info_page_brk, PAGE_SIZE);
31047 __read_mostly int xen_have_vector_callback;
31048 EXPORT_SYMBOL_GPL(xen_have_vector_callback);
31049 @@ -496,8 +494,7 @@ static void xen_load_gdt(const struct desc_ptr *dtr)
31050 {
31051 unsigned long va = dtr->address;
31052 unsigned int size = dtr->size + 1;
31053 - unsigned pages = (size + PAGE_SIZE - 1) / PAGE_SIZE;
31054 - unsigned long frames[pages];
31055 + unsigned long frames[65536 / PAGE_SIZE];
31056 int f;
31057
31058 /*
31059 @@ -545,8 +542,7 @@ static void __init xen_load_gdt_boot(const struct desc_ptr *dtr)
31060 {
31061 unsigned long va = dtr->address;
31062 unsigned int size = dtr->size + 1;
31063 - unsigned pages = (size + PAGE_SIZE - 1) / PAGE_SIZE;
31064 - unsigned long frames[pages];
31065 + unsigned long frames[65536 / PAGE_SIZE];
31066 int f;
31067
31068 /*
31069 @@ -939,7 +935,7 @@ static u32 xen_safe_apic_wait_icr_idle(void)
31070 return 0;
31071 }
31072
31073 -static void set_xen_basic_apic_ops(void)
31074 +static void __init set_xen_basic_apic_ops(void)
31075 {
31076 apic->read = xen_apic_read;
31077 apic->write = xen_apic_write;
31078 @@ -1245,30 +1241,30 @@ static const struct pv_apic_ops xen_apic_ops __initconst = {
31079 #endif
31080 };
31081
31082 -static void xen_reboot(int reason)
31083 +static __noreturn void xen_reboot(int reason)
31084 {
31085 struct sched_shutdown r = { .reason = reason };
31086
31087 - if (HYPERVISOR_sched_op(SCHEDOP_shutdown, &r))
31088 - BUG();
31089 + HYPERVISOR_sched_op(SCHEDOP_shutdown, &r);
31090 + BUG();
31091 }
31092
31093 -static void xen_restart(char *msg)
31094 +static __noreturn void xen_restart(char *msg)
31095 {
31096 xen_reboot(SHUTDOWN_reboot);
31097 }
31098
31099 -static void xen_emergency_restart(void)
31100 +static __noreturn void xen_emergency_restart(void)
31101 {
31102 xen_reboot(SHUTDOWN_reboot);
31103 }
31104
31105 -static void xen_machine_halt(void)
31106 +static __noreturn void xen_machine_halt(void)
31107 {
31108 xen_reboot(SHUTDOWN_poweroff);
31109 }
31110
31111 -static void xen_machine_power_off(void)
31112 +static __noreturn void xen_machine_power_off(void)
31113 {
31114 if (pm_power_off)
31115 pm_power_off();
31116 @@ -1370,7 +1366,17 @@ asmlinkage void __init xen_start_kernel(void)
31117 __userpte_alloc_gfp &= ~__GFP_HIGHMEM;
31118
31119 /* Work out if we support NX */
31120 - x86_configure_nx();
31121 +#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
31122 + if ((cpuid_eax(0x80000000) & 0xffff0000) == 0x80000000 &&
31123 + (cpuid_edx(0x80000001) & (1U << (X86_FEATURE_NX & 31)))) {
31124 + unsigned l, h;
31125 +
31126 + __supported_pte_mask |= _PAGE_NX;
31127 + rdmsr(MSR_EFER, l, h);
31128 + l |= EFER_NX;
31129 + wrmsr(MSR_EFER, l, h);
31130 + }
31131 +#endif
31132
31133 xen_setup_features();
31134
31135 @@ -1399,14 +1405,7 @@ asmlinkage void __init xen_start_kernel(void)
31136 pv_mmu_ops.ptep_modify_prot_commit = xen_ptep_modify_prot_commit;
31137 }
31138
31139 - machine_ops = xen_machine_ops;
31140 -
31141 - /*
31142 - * The only reliable way to retain the initial address of the
31143 - * percpu gdt_page is to remember it here, so we can go and
31144 - * mark it RW later, when the initial percpu area is freed.
31145 - */
31146 - xen_initial_gdt = &per_cpu(gdt_page, 0);
31147 + memcpy((void *)&machine_ops, &xen_machine_ops, sizeof machine_ops);
31148
31149 xen_smp_init();
31150
31151 @@ -1598,7 +1597,7 @@ static int __cpuinit xen_hvm_cpu_notify(struct notifier_block *self,
31152 return NOTIFY_OK;
31153 }
31154
31155 -static struct notifier_block xen_hvm_cpu_notifier __cpuinitdata = {
31156 +static struct notifier_block xen_hvm_cpu_notifier = {
31157 .notifier_call = xen_hvm_cpu_notify,
31158 };
31159
31160 diff --git a/arch/x86/xen/mmu.c b/arch/x86/xen/mmu.c
31161 index 01de35c..0bda07b 100644
31162 --- a/arch/x86/xen/mmu.c
31163 +++ b/arch/x86/xen/mmu.c
31164 @@ -1881,6 +1881,9 @@ void __init xen_setup_kernel_pagetable(pgd_t *pgd, unsigned long max_pfn)
31165 /* L3_k[510] -> level2_kernel_pgt
31166 * L3_i[511] -> level2_fixmap_pgt */
31167 convert_pfn_mfn(level3_kernel_pgt);
31168 + convert_pfn_mfn(level3_vmalloc_start_pgt);
31169 + convert_pfn_mfn(level3_vmalloc_end_pgt);
31170 + convert_pfn_mfn(level3_vmemmap_pgt);
31171
31172 /* We get [511][511] and have Xen's version of level2_kernel_pgt */
31173 l3 = m2v(pgd[pgd_index(__START_KERNEL_map)].pgd);
31174 @@ -1910,8 +1913,12 @@ void __init xen_setup_kernel_pagetable(pgd_t *pgd, unsigned long max_pfn)
31175 set_page_prot(init_level4_pgt, PAGE_KERNEL_RO);
31176 set_page_prot(level3_ident_pgt, PAGE_KERNEL_RO);
31177 set_page_prot(level3_kernel_pgt, PAGE_KERNEL_RO);
31178 + set_page_prot(level3_vmalloc_start_pgt, PAGE_KERNEL_RO);
31179 + set_page_prot(level3_vmalloc_end_pgt, PAGE_KERNEL_RO);
31180 + set_page_prot(level3_vmemmap_pgt, PAGE_KERNEL_RO);
31181 set_page_prot(level3_user_vsyscall, PAGE_KERNEL_RO);
31182 set_page_prot(level2_ident_pgt, PAGE_KERNEL_RO);
31183 + set_page_prot(level2_vmemmap_pgt, PAGE_KERNEL_RO);
31184 set_page_prot(level2_kernel_pgt, PAGE_KERNEL_RO);
31185 set_page_prot(level2_fixmap_pgt, PAGE_KERNEL_RO);
31186
31187 @@ -2097,6 +2104,7 @@ static void __init xen_post_allocator_init(void)
31188 pv_mmu_ops.set_pud = xen_set_pud;
31189 #if PAGETABLE_LEVELS == 4
31190 pv_mmu_ops.set_pgd = xen_set_pgd;
31191 + pv_mmu_ops.set_pgd_batched = xen_set_pgd;
31192 #endif
31193
31194 /* This will work as long as patching hasn't happened yet
31195 @@ -2178,6 +2186,7 @@ static const struct pv_mmu_ops xen_mmu_ops __initconst = {
31196 .pud_val = PV_CALLEE_SAVE(xen_pud_val),
31197 .make_pud = PV_CALLEE_SAVE(xen_make_pud),
31198 .set_pgd = xen_set_pgd_hyper,
31199 + .set_pgd_batched = xen_set_pgd_hyper,
31200
31201 .alloc_pud = xen_alloc_pmd_init,
31202 .release_pud = xen_release_pmd_init,
31203 diff --git a/arch/x86/xen/smp.c b/arch/x86/xen/smp.c
31204 index 34bc4ce..c34aa24 100644
31205 --- a/arch/x86/xen/smp.c
31206 +++ b/arch/x86/xen/smp.c
31207 @@ -229,11 +229,6 @@ static void __init xen_smp_prepare_boot_cpu(void)
31208 {
31209 BUG_ON(smp_processor_id() != 0);
31210 native_smp_prepare_boot_cpu();
31211 -
31212 - /* We've switched to the "real" per-cpu gdt, so make sure the
31213 - old memory can be recycled */
31214 - make_lowmem_page_readwrite(xen_initial_gdt);
31215 -
31216 xen_filter_cpu_maps();
31217 xen_setup_vcpu_info_placement();
31218 }
31219 @@ -300,12 +295,12 @@ cpu_initialize_context(unsigned int cpu, struct task_struct *idle)
31220 gdt = get_cpu_gdt_table(cpu);
31221
31222 ctxt->flags = VGCF_IN_KERNEL;
31223 - ctxt->user_regs.ds = __USER_DS;
31224 - ctxt->user_regs.es = __USER_DS;
31225 + ctxt->user_regs.ds = __KERNEL_DS;
31226 + ctxt->user_regs.es = __KERNEL_DS;
31227 ctxt->user_regs.ss = __KERNEL_DS;
31228 #ifdef CONFIG_X86_32
31229 ctxt->user_regs.fs = __KERNEL_PERCPU;
31230 - ctxt->user_regs.gs = __KERNEL_STACK_CANARY;
31231 + savesegment(gs, ctxt->user_regs.gs);
31232 #else
31233 ctxt->gs_base_kernel = per_cpu_offset(cpu);
31234 #endif
31235 @@ -355,13 +350,12 @@ static int __cpuinit xen_cpu_up(unsigned int cpu, struct task_struct *idle)
31236 int rc;
31237
31238 per_cpu(current_task, cpu) = idle;
31239 + per_cpu(current_tinfo, cpu) = &idle->tinfo;
31240 #ifdef CONFIG_X86_32
31241 irq_ctx_init(cpu);
31242 #else
31243 clear_tsk_thread_flag(idle, TIF_FORK);
31244 - per_cpu(kernel_stack, cpu) =
31245 - (unsigned long)task_stack_page(idle) -
31246 - KERNEL_STACK_OFFSET + THREAD_SIZE;
31247 + per_cpu(kernel_stack, cpu) = (unsigned long)task_stack_page(idle) - 16 + THREAD_SIZE;
31248 #endif
31249 xen_setup_runstate_info(cpu);
31250 xen_setup_timer(cpu);
31251 @@ -630,7 +624,7 @@ static const struct smp_ops xen_smp_ops __initconst = {
31252
31253 void __init xen_smp_init(void)
31254 {
31255 - smp_ops = xen_smp_ops;
31256 + memcpy((void *)&smp_ops, &xen_smp_ops, sizeof smp_ops);
31257 xen_fill_possible_map();
31258 xen_init_spinlocks();
31259 }
31260 diff --git a/arch/x86/xen/xen-asm_32.S b/arch/x86/xen/xen-asm_32.S
31261 index 33ca6e4..0ded929 100644
31262 --- a/arch/x86/xen/xen-asm_32.S
31263 +++ b/arch/x86/xen/xen-asm_32.S
31264 @@ -84,14 +84,14 @@ ENTRY(xen_iret)
31265 ESP_OFFSET=4 # bytes pushed onto stack
31266
31267 /*
31268 - * Store vcpu_info pointer for easy access. Do it this way to
31269 - * avoid having to reload %fs
31270 + * Store vcpu_info pointer for easy access.
31271 */
31272 #ifdef CONFIG_SMP
31273 - GET_THREAD_INFO(%eax)
31274 - movl %ss:TI_cpu(%eax), %eax
31275 - movl %ss:__per_cpu_offset(,%eax,4), %eax
31276 - mov %ss:xen_vcpu(%eax), %eax
31277 + push %fs
31278 + mov $(__KERNEL_PERCPU), %eax
31279 + mov %eax, %fs
31280 + mov PER_CPU_VAR(xen_vcpu), %eax
31281 + pop %fs
31282 #else
31283 movl %ss:xen_vcpu, %eax
31284 #endif
31285 diff --git a/arch/x86/xen/xen-head.S b/arch/x86/xen/xen-head.S
31286 index 7faed58..ba4427c 100644
31287 --- a/arch/x86/xen/xen-head.S
31288 +++ b/arch/x86/xen/xen-head.S
31289 @@ -19,6 +19,17 @@ ENTRY(startup_xen)
31290 #ifdef CONFIG_X86_32
31291 mov %esi,xen_start_info
31292 mov $init_thread_union+THREAD_SIZE,%esp
31293 +#ifdef CONFIG_SMP
31294 + movl $cpu_gdt_table,%edi
31295 + movl $__per_cpu_load,%eax
31296 + movw %ax,__KERNEL_PERCPU + 2(%edi)
31297 + rorl $16,%eax
31298 + movb %al,__KERNEL_PERCPU + 4(%edi)
31299 + movb %ah,__KERNEL_PERCPU + 7(%edi)
31300 + movl $__per_cpu_end - 1,%eax
31301 + subl $__per_cpu_start,%eax
31302 + movw %ax,__KERNEL_PERCPU + 0(%edi)
31303 +#endif
31304 #else
31305 mov %rsi,xen_start_info
31306 mov $init_thread_union+THREAD_SIZE,%rsp
31307 diff --git a/arch/x86/xen/xen-ops.h b/arch/x86/xen/xen-ops.h
31308 index a95b417..b6dbd0b 100644
31309 --- a/arch/x86/xen/xen-ops.h
31310 +++ b/arch/x86/xen/xen-ops.h
31311 @@ -10,8 +10,6 @@
31312 extern const char xen_hypervisor_callback[];
31313 extern const char xen_failsafe_callback[];
31314
31315 -extern void *xen_initial_gdt;
31316 -
31317 struct trap_info;
31318 void xen_copy_trap_info(struct trap_info *traps);
31319
31320 diff --git a/arch/xtensa/variants/dc232b/include/variant/core.h b/arch/xtensa/variants/dc232b/include/variant/core.h
31321 index 525bd3d..ef888b1 100644
31322 --- a/arch/xtensa/variants/dc232b/include/variant/core.h
31323 +++ b/arch/xtensa/variants/dc232b/include/variant/core.h
31324 @@ -119,9 +119,9 @@
31325 ----------------------------------------------------------------------*/
31326
31327 #define XCHAL_ICACHE_LINESIZE 32 /* I-cache line size in bytes */
31328 -#define XCHAL_DCACHE_LINESIZE 32 /* D-cache line size in bytes */
31329 #define XCHAL_ICACHE_LINEWIDTH 5 /* log2(I line size in bytes) */
31330 #define XCHAL_DCACHE_LINEWIDTH 5 /* log2(D line size in bytes) */
31331 +#define XCHAL_DCACHE_LINESIZE (_AC(1,UL) << XCHAL_DCACHE_LINEWIDTH) /* D-cache line size in bytes */
31332
31333 #define XCHAL_ICACHE_SIZE 16384 /* I-cache size in bytes or 0 */
31334 #define XCHAL_DCACHE_SIZE 16384 /* D-cache size in bytes or 0 */
31335 diff --git a/arch/xtensa/variants/fsf/include/variant/core.h b/arch/xtensa/variants/fsf/include/variant/core.h
31336 index 2f33760..835e50a 100644
31337 --- a/arch/xtensa/variants/fsf/include/variant/core.h
31338 +++ b/arch/xtensa/variants/fsf/include/variant/core.h
31339 @@ -11,6 +11,7 @@
31340 #ifndef _XTENSA_CORE_H
31341 #define _XTENSA_CORE_H
31342
31343 +#include <linux/const.h>
31344
31345 /****************************************************************************
31346 Parameters Useful for Any Code, USER or PRIVILEGED
31347 @@ -112,9 +113,9 @@
31348 ----------------------------------------------------------------------*/
31349
31350 #define XCHAL_ICACHE_LINESIZE 16 /* I-cache line size in bytes */
31351 -#define XCHAL_DCACHE_LINESIZE 16 /* D-cache line size in bytes */
31352 #define XCHAL_ICACHE_LINEWIDTH 4 /* log2(I line size in bytes) */
31353 #define XCHAL_DCACHE_LINEWIDTH 4 /* log2(D line size in bytes) */
31354 +#define XCHAL_DCACHE_LINESIZE (_AC(1,UL) << XCHAL_DCACHE_LINEWIDTH) /* D-cache line size in bytes */
31355
31356 #define XCHAL_ICACHE_SIZE 8192 /* I-cache size in bytes or 0 */
31357 #define XCHAL_DCACHE_SIZE 8192 /* D-cache size in bytes or 0 */
31358 diff --git a/arch/xtensa/variants/s6000/include/variant/core.h b/arch/xtensa/variants/s6000/include/variant/core.h
31359 index af00795..2bb8105 100644
31360 --- a/arch/xtensa/variants/s6000/include/variant/core.h
31361 +++ b/arch/xtensa/variants/s6000/include/variant/core.h
31362 @@ -11,6 +11,7 @@
31363 #ifndef _XTENSA_CORE_CONFIGURATION_H
31364 #define _XTENSA_CORE_CONFIGURATION_H
31365
31366 +#include <linux/const.h>
31367
31368 /****************************************************************************
31369 Parameters Useful for Any Code, USER or PRIVILEGED
31370 @@ -118,9 +119,9 @@
31371 ----------------------------------------------------------------------*/
31372
31373 #define XCHAL_ICACHE_LINESIZE 16 /* I-cache line size in bytes */
31374 -#define XCHAL_DCACHE_LINESIZE 16 /* D-cache line size in bytes */
31375 #define XCHAL_ICACHE_LINEWIDTH 4 /* log2(I line size in bytes) */
31376 #define XCHAL_DCACHE_LINEWIDTH 4 /* log2(D line size in bytes) */
31377 +#define XCHAL_DCACHE_LINESIZE (_AC(1,UL) << XCHAL_DCACHE_LINEWIDTH) /* D-cache line size in bytes */
31378
31379 #define XCHAL_ICACHE_SIZE 32768 /* I-cache size in bytes or 0 */
31380 #define XCHAL_DCACHE_SIZE 32768 /* D-cache size in bytes or 0 */
31381 diff --git a/block/blk-iopoll.c b/block/blk-iopoll.c
31382 index 58916af..eb9dbcf6 100644
31383 --- a/block/blk-iopoll.c
31384 +++ b/block/blk-iopoll.c
31385 @@ -77,7 +77,7 @@ void blk_iopoll_complete(struct blk_iopoll *iopoll)
31386 }
31387 EXPORT_SYMBOL(blk_iopoll_complete);
31388
31389 -static void blk_iopoll_softirq(struct softirq_action *h)
31390 +static void blk_iopoll_softirq(void)
31391 {
31392 struct list_head *list = &__get_cpu_var(blk_cpu_iopoll);
31393 int rearm = 0, budget = blk_iopoll_budget;
31394 @@ -209,7 +209,7 @@ static int __cpuinit blk_iopoll_cpu_notify(struct notifier_block *self,
31395 return NOTIFY_OK;
31396 }
31397
31398 -static struct notifier_block __cpuinitdata blk_iopoll_cpu_notifier = {
31399 +static struct notifier_block blk_iopoll_cpu_notifier = {
31400 .notifier_call = blk_iopoll_cpu_notify,
31401 };
31402
31403 diff --git a/block/blk-map.c b/block/blk-map.c
31404 index 623e1cd..ca1e109 100644
31405 --- a/block/blk-map.c
31406 +++ b/block/blk-map.c
31407 @@ -302,7 +302,7 @@ int blk_rq_map_kern(struct request_queue *q, struct request *rq, void *kbuf,
31408 if (!len || !kbuf)
31409 return -EINVAL;
31410
31411 - do_copy = !blk_rq_aligned(q, addr, len) || object_is_on_stack(kbuf);
31412 + do_copy = !blk_rq_aligned(q, addr, len) || object_starts_on_stack(kbuf);
31413 if (do_copy)
31414 bio = bio_copy_kern(q, kbuf, len, gfp_mask, reading);
31415 else
31416 diff --git a/block/blk-softirq.c b/block/blk-softirq.c
31417 index 467c8de..f3628c5 100644
31418 --- a/block/blk-softirq.c
31419 +++ b/block/blk-softirq.c
31420 @@ -18,7 +18,7 @@ static DEFINE_PER_CPU(struct list_head, blk_cpu_done);
31421 * Softirq action handler - move entries to local list and loop over them
31422 * while passing them to the queue registered handler.
31423 */
31424 -static void blk_done_softirq(struct softirq_action *h)
31425 +static void blk_done_softirq(void)
31426 {
31427 struct list_head *cpu_list, local_list;
31428
31429 @@ -98,7 +98,7 @@ static int __cpuinit blk_cpu_notify(struct notifier_block *self,
31430 return NOTIFY_OK;
31431 }
31432
31433 -static struct notifier_block __cpuinitdata blk_cpu_notifier = {
31434 +static struct notifier_block blk_cpu_notifier = {
31435 .notifier_call = blk_cpu_notify,
31436 };
31437
31438 diff --git a/block/bsg.c b/block/bsg.c
31439 index ff64ae3..593560c 100644
31440 --- a/block/bsg.c
31441 +++ b/block/bsg.c
31442 @@ -176,16 +176,24 @@ static int blk_fill_sgv4_hdr_rq(struct request_queue *q, struct request *rq,
31443 struct sg_io_v4 *hdr, struct bsg_device *bd,
31444 fmode_t has_write_perm)
31445 {
31446 + unsigned char tmpcmd[sizeof(rq->__cmd)];
31447 + unsigned char *cmdptr;
31448 +
31449 if (hdr->request_len > BLK_MAX_CDB) {
31450 rq->cmd = kzalloc(hdr->request_len, GFP_KERNEL);
31451 if (!rq->cmd)
31452 return -ENOMEM;
31453 - }
31454 + cmdptr = rq->cmd;
31455 + } else
31456 + cmdptr = tmpcmd;
31457
31458 - if (copy_from_user(rq->cmd, (void __user *)(unsigned long)hdr->request,
31459 + if (copy_from_user(cmdptr, (void __user *)(unsigned long)hdr->request,
31460 hdr->request_len))
31461 return -EFAULT;
31462
31463 + if (cmdptr != rq->cmd)
31464 + memcpy(rq->cmd, cmdptr, hdr->request_len);
31465 +
31466 if (hdr->subprotocol == BSG_SUB_PROTOCOL_SCSI_CMD) {
31467 if (blk_verify_command(rq->cmd, has_write_perm))
31468 return -EPERM;
31469 diff --git a/block/compat_ioctl.c b/block/compat_ioctl.c
31470 index 7c668c8..db3521c 100644
31471 --- a/block/compat_ioctl.c
31472 +++ b/block/compat_ioctl.c
31473 @@ -340,7 +340,7 @@ static int compat_fd_ioctl(struct block_device *bdev, fmode_t mode,
31474 err |= __get_user(f->spec1, &uf->spec1);
31475 err |= __get_user(f->fmt_gap, &uf->fmt_gap);
31476 err |= __get_user(name, &uf->name);
31477 - f->name = compat_ptr(name);
31478 + f->name = (void __force_kernel *)compat_ptr(name);
31479 if (err) {
31480 err = -EFAULT;
31481 goto out;
31482 diff --git a/block/partitions/efi.c b/block/partitions/efi.c
31483 index b62fb88..bdab4c4 100644
31484 --- a/block/partitions/efi.c
31485 +++ b/block/partitions/efi.c
31486 @@ -234,14 +234,14 @@ static gpt_entry *alloc_read_gpt_entries(struct parsed_partitions *state,
31487 if (!gpt)
31488 return NULL;
31489
31490 + if (!le32_to_cpu(gpt->num_partition_entries))
31491 + return NULL;
31492 + pte = kcalloc(le32_to_cpu(gpt->num_partition_entries), le32_to_cpu(gpt->sizeof_partition_entry), GFP_KERNEL);
31493 + if (!pte)
31494 + return NULL;
31495 +
31496 count = le32_to_cpu(gpt->num_partition_entries) *
31497 le32_to_cpu(gpt->sizeof_partition_entry);
31498 - if (!count)
31499 - return NULL;
31500 - pte = kzalloc(count, GFP_KERNEL);
31501 - if (!pte)
31502 - return NULL;
31503 -
31504 if (read_lba(state, le64_to_cpu(gpt->partition_entry_lba),
31505 (u8 *) pte,
31506 count) < count) {
31507 diff --git a/block/scsi_ioctl.c b/block/scsi_ioctl.c
31508 index 9a87daa..fb17486 100644
31509 --- a/block/scsi_ioctl.c
31510 +++ b/block/scsi_ioctl.c
31511 @@ -223,8 +223,20 @@ EXPORT_SYMBOL(blk_verify_command);
31512 static int blk_fill_sghdr_rq(struct request_queue *q, struct request *rq,
31513 struct sg_io_hdr *hdr, fmode_t mode)
31514 {
31515 - if (copy_from_user(rq->cmd, hdr->cmdp, hdr->cmd_len))
31516 + unsigned char tmpcmd[sizeof(rq->__cmd)];
31517 + unsigned char *cmdptr;
31518 +
31519 + if (rq->cmd != rq->__cmd)
31520 + cmdptr = rq->cmd;
31521 + else
31522 + cmdptr = tmpcmd;
31523 +
31524 + if (copy_from_user(cmdptr, hdr->cmdp, hdr->cmd_len))
31525 return -EFAULT;
31526 +
31527 + if (cmdptr != rq->cmd)
31528 + memcpy(rq->cmd, cmdptr, hdr->cmd_len);
31529 +
31530 if (blk_verify_command(rq->cmd, mode & FMODE_WRITE))
31531 return -EPERM;
31532
31533 @@ -433,6 +445,8 @@ int sg_scsi_ioctl(struct request_queue *q, struct gendisk *disk, fmode_t mode,
31534 int err;
31535 unsigned int in_len, out_len, bytes, opcode, cmdlen;
31536 char *buffer = NULL, sense[SCSI_SENSE_BUFFERSIZE];
31537 + unsigned char tmpcmd[sizeof(rq->__cmd)];
31538 + unsigned char *cmdptr;
31539
31540 if (!sic)
31541 return -EINVAL;
31542 @@ -466,9 +480,18 @@ int sg_scsi_ioctl(struct request_queue *q, struct gendisk *disk, fmode_t mode,
31543 */
31544 err = -EFAULT;
31545 rq->cmd_len = cmdlen;
31546 - if (copy_from_user(rq->cmd, sic->data, cmdlen))
31547 +
31548 + if (rq->cmd != rq->__cmd)
31549 + cmdptr = rq->cmd;
31550 + else
31551 + cmdptr = tmpcmd;
31552 +
31553 + if (copy_from_user(cmdptr, sic->data, cmdlen))
31554 goto error;
31555
31556 + if (rq->cmd != cmdptr)
31557 + memcpy(rq->cmd, cmdptr, cmdlen);
31558 +
31559 if (in_len && copy_from_user(buffer, sic->data + cmdlen, in_len))
31560 goto error;
31561
31562 diff --git a/crypto/cryptd.c b/crypto/cryptd.c
31563 index 7bdd61b..afec999 100644
31564 --- a/crypto/cryptd.c
31565 +++ b/crypto/cryptd.c
31566 @@ -63,7 +63,7 @@ struct cryptd_blkcipher_ctx {
31567
31568 struct cryptd_blkcipher_request_ctx {
31569 crypto_completion_t complete;
31570 -};
31571 +} __no_const;
31572
31573 struct cryptd_hash_ctx {
31574 struct crypto_shash *child;
31575 @@ -80,7 +80,7 @@ struct cryptd_aead_ctx {
31576
31577 struct cryptd_aead_request_ctx {
31578 crypto_completion_t complete;
31579 -};
31580 +} __no_const;
31581
31582 static void cryptd_queue_worker(struct work_struct *work);
31583
31584 diff --git a/crypto/crypto_user.c b/crypto/crypto_user.c
31585 index f6d9baf..dfd511f 100644
31586 --- a/crypto/crypto_user.c
31587 +++ b/crypto/crypto_user.c
31588 @@ -30,6 +30,8 @@
31589
31590 #include "internal.h"
31591
31592 +#define null_terminated(x) (strnlen(x, sizeof(x)) < sizeof(x))
31593 +
31594 static DEFINE_MUTEX(crypto_cfg_mutex);
31595
31596 /* The crypto netlink socket */
31597 @@ -196,7 +198,10 @@ static int crypto_report(struct sk_buff *in_skb, struct nlmsghdr *in_nlh,
31598 struct crypto_dump_info info;
31599 int err;
31600
31601 - if (!p->cru_driver_name)
31602 + if (!null_terminated(p->cru_name) || !null_terminated(p->cru_driver_name))
31603 + return -EINVAL;
31604 +
31605 + if (!p->cru_driver_name[0])
31606 return -EINVAL;
31607
31608 alg = crypto_alg_match(p, 1);
31609 @@ -260,6 +265,9 @@ static int crypto_update_alg(struct sk_buff *skb, struct nlmsghdr *nlh,
31610 struct nlattr *priority = attrs[CRYPTOCFGA_PRIORITY_VAL];
31611 LIST_HEAD(list);
31612
31613 + if (!null_terminated(p->cru_name) || !null_terminated(p->cru_driver_name))
31614 + return -EINVAL;
31615 +
31616 if (priority && !strlen(p->cru_driver_name))
31617 return -EINVAL;
31618
31619 @@ -287,6 +295,9 @@ static int crypto_del_alg(struct sk_buff *skb, struct nlmsghdr *nlh,
31620 struct crypto_alg *alg;
31621 struct crypto_user_alg *p = nlmsg_data(nlh);
31622
31623 + if (!null_terminated(p->cru_name) || !null_terminated(p->cru_driver_name))
31624 + return -EINVAL;
31625 +
31626 alg = crypto_alg_match(p, 1);
31627 if (!alg)
31628 return -ENOENT;
31629 @@ -368,6 +379,9 @@ static int crypto_add_alg(struct sk_buff *skb, struct nlmsghdr *nlh,
31630 struct crypto_user_alg *p = nlmsg_data(nlh);
31631 struct nlattr *priority = attrs[CRYPTOCFGA_PRIORITY_VAL];
31632
31633 + if (!null_terminated(p->cru_name) || !null_terminated(p->cru_driver_name))
31634 + return -EINVAL;
31635 +
31636 if (strlen(p->cru_driver_name))
31637 exact = 1;
31638
31639 diff --git a/drivers/acpi/apei/apei-internal.h b/drivers/acpi/apei/apei-internal.h
31640 index f220d64..d359ad6 100644
31641 --- a/drivers/acpi/apei/apei-internal.h
31642 +++ b/drivers/acpi/apei/apei-internal.h
31643 @@ -20,7 +20,7 @@ typedef int (*apei_exec_ins_func_t)(struct apei_exec_context *ctx,
31644 struct apei_exec_ins_type {
31645 u32 flags;
31646 apei_exec_ins_func_t run;
31647 -};
31648 +} __do_const;
31649
31650 struct apei_exec_context {
31651 u32 ip;
31652 diff --git a/drivers/acpi/apei/cper.c b/drivers/acpi/apei/cper.c
31653 index e6defd8..c26a225 100644
31654 --- a/drivers/acpi/apei/cper.c
31655 +++ b/drivers/acpi/apei/cper.c
31656 @@ -38,12 +38,12 @@
31657 */
31658 u64 cper_next_record_id(void)
31659 {
31660 - static atomic64_t seq;
31661 + static atomic64_unchecked_t seq;
31662
31663 - if (!atomic64_read(&seq))
31664 - atomic64_set(&seq, ((u64)get_seconds()) << 32);
31665 + if (!atomic64_read_unchecked(&seq))
31666 + atomic64_set_unchecked(&seq, ((u64)get_seconds()) << 32);
31667
31668 - return atomic64_inc_return(&seq);
31669 + return atomic64_inc_return_unchecked(&seq);
31670 }
31671 EXPORT_SYMBOL_GPL(cper_next_record_id);
31672
31673 diff --git a/drivers/acpi/bgrt.c b/drivers/acpi/bgrt.c
31674 index be60399..778b33e8 100644
31675 --- a/drivers/acpi/bgrt.c
31676 +++ b/drivers/acpi/bgrt.c
31677 @@ -87,8 +87,10 @@ static int __init bgrt_init(void)
31678 return -ENODEV;
31679
31680 sysfs_bin_attr_init(&image_attr);
31681 - image_attr.private = bgrt_image;
31682 - image_attr.size = bgrt_image_size;
31683 + pax_open_kernel();
31684 + *(void **)&image_attr.private = bgrt_image;
31685 + *(size_t *)&image_attr.size = bgrt_image_size;
31686 + pax_close_kernel();
31687
31688 bgrt_kobj = kobject_create_and_add("bgrt", acpi_kobj);
31689 if (!bgrt_kobj)
31690 diff --git a/drivers/acpi/blacklist.c b/drivers/acpi/blacklist.c
31691 index cb96296..b81293b 100644
31692 --- a/drivers/acpi/blacklist.c
31693 +++ b/drivers/acpi/blacklist.c
31694 @@ -52,7 +52,7 @@ struct acpi_blacklist_item {
31695 u32 is_critical_error;
31696 };
31697
31698 -static struct dmi_system_id acpi_osi_dmi_table[] __initdata;
31699 +static const struct dmi_system_id acpi_osi_dmi_table[] __initconst;
31700
31701 /*
31702 * POLICY: If *anything* doesn't work, put it on the blacklist.
31703 @@ -193,7 +193,7 @@ static int __init dmi_disable_osi_win7(const struct dmi_system_id *d)
31704 return 0;
31705 }
31706
31707 -static struct dmi_system_id acpi_osi_dmi_table[] __initdata = {
31708 +static const struct dmi_system_id acpi_osi_dmi_table[] __initconst = {
31709 {
31710 .callback = dmi_disable_osi_vista,
31711 .ident = "Fujitsu Siemens",
31712 diff --git a/drivers/acpi/ec_sys.c b/drivers/acpi/ec_sys.c
31713 index 7586544..636a2f0 100644
31714 --- a/drivers/acpi/ec_sys.c
31715 +++ b/drivers/acpi/ec_sys.c
31716 @@ -12,6 +12,7 @@
31717 #include <linux/acpi.h>
31718 #include <linux/debugfs.h>
31719 #include <linux/module.h>
31720 +#include <linux/uaccess.h>
31721 #include "internal.h"
31722
31723 MODULE_AUTHOR("Thomas Renninger <trenn@suse.de>");
31724 @@ -34,7 +35,7 @@ static ssize_t acpi_ec_read_io(struct file *f, char __user *buf,
31725 * struct acpi_ec *ec = ((struct seq_file *)f->private_data)->private;
31726 */
31727 unsigned int size = EC_SPACE_SIZE;
31728 - u8 *data = (u8 *) buf;
31729 + u8 data;
31730 loff_t init_off = *off;
31731 int err = 0;
31732
31733 @@ -47,9 +48,11 @@ static ssize_t acpi_ec_read_io(struct file *f, char __user *buf,
31734 size = count;
31735
31736 while (size) {
31737 - err = ec_read(*off, &data[*off - init_off]);
31738 + err = ec_read(*off, &data);
31739 if (err)
31740 return err;
31741 + if (put_user(data, &buf[*off - init_off]))
31742 + return -EFAULT;
31743 *off += 1;
31744 size--;
31745 }
31746 @@ -65,7 +68,6 @@ static ssize_t acpi_ec_write_io(struct file *f, const char __user *buf,
31747
31748 unsigned int size = count;
31749 loff_t init_off = *off;
31750 - u8 *data = (u8 *) buf;
31751 int err = 0;
31752
31753 if (*off >= EC_SPACE_SIZE)
31754 @@ -76,7 +78,9 @@ static ssize_t acpi_ec_write_io(struct file *f, const char __user *buf,
31755 }
31756
31757 while (size) {
31758 - u8 byte_write = data[*off - init_off];
31759 + u8 byte_write;
31760 + if (get_user(byte_write, &buf[*off - init_off]))
31761 + return -EFAULT;
31762 err = ec_write(*off, byte_write);
31763 if (err)
31764 return err;
31765 diff --git a/drivers/acpi/processor_driver.c b/drivers/acpi/processor_driver.c
31766 index e83311b..142b5cc 100644
31767 --- a/drivers/acpi/processor_driver.c
31768 +++ b/drivers/acpi/processor_driver.c
31769 @@ -558,7 +558,7 @@ static int __cpuinit acpi_processor_add(struct acpi_device *device)
31770 return 0;
31771 #endif
31772
31773 - BUG_ON((pr->id >= nr_cpu_ids) || (pr->id < 0));
31774 + BUG_ON(pr->id >= nr_cpu_ids);
31775
31776 /*
31777 * Buggy BIOS check
31778 diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c
31779 index ed9a1cc..f4a354c 100644
31780 --- a/drivers/acpi/processor_idle.c
31781 +++ b/drivers/acpi/processor_idle.c
31782 @@ -1005,7 +1005,7 @@ static int acpi_processor_setup_cpuidle_states(struct acpi_processor *pr)
31783 {
31784 int i, count = CPUIDLE_DRIVER_STATE_START;
31785 struct acpi_processor_cx *cx;
31786 - struct cpuidle_state *state;
31787 + cpuidle_state_no_const *state;
31788 struct cpuidle_driver *drv = &acpi_idle_driver;
31789
31790 if (!pr->flags.power_setup_done)
31791 diff --git a/drivers/acpi/sysfs.c b/drivers/acpi/sysfs.c
31792 index ea61ca9..3fdd70d 100644
31793 --- a/drivers/acpi/sysfs.c
31794 +++ b/drivers/acpi/sysfs.c
31795 @@ -420,11 +420,11 @@ static u32 num_counters;
31796 static struct attribute **all_attrs;
31797 static u32 acpi_gpe_count;
31798
31799 -static struct attribute_group interrupt_stats_attr_group = {
31800 +static attribute_group_no_const interrupt_stats_attr_group = {
31801 .name = "interrupts",
31802 };
31803
31804 -static struct kobj_attribute *counter_attrs;
31805 +static kobj_attribute_no_const *counter_attrs;
31806
31807 static void delete_gpe_attr_array(void)
31808 {
31809 diff --git a/drivers/ata/libahci.c b/drivers/ata/libahci.c
31810 index 6cd7805..07facb3 100644
31811 --- a/drivers/ata/libahci.c
31812 +++ b/drivers/ata/libahci.c
31813 @@ -1230,7 +1230,7 @@ int ahci_kick_engine(struct ata_port *ap)
31814 }
31815 EXPORT_SYMBOL_GPL(ahci_kick_engine);
31816
31817 -static int ahci_exec_polled_cmd(struct ata_port *ap, int pmp,
31818 +static int __intentional_overflow(-1) ahci_exec_polled_cmd(struct ata_port *ap, int pmp,
31819 struct ata_taskfile *tf, int is_cmd, u16 flags,
31820 unsigned long timeout_msec)
31821 {
31822 diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
31823 index 46cd3f4..0871ad0 100644
31824 --- a/drivers/ata/libata-core.c
31825 +++ b/drivers/ata/libata-core.c
31826 @@ -4780,7 +4780,7 @@ void ata_qc_free(struct ata_queued_cmd *qc)
31827 struct ata_port *ap;
31828 unsigned int tag;
31829
31830 - WARN_ON_ONCE(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
31831 + BUG_ON(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
31832 ap = qc->ap;
31833
31834 qc->flags = 0;
31835 @@ -4796,7 +4796,7 @@ void __ata_qc_complete(struct ata_queued_cmd *qc)
31836 struct ata_port *ap;
31837 struct ata_link *link;
31838
31839 - WARN_ON_ONCE(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
31840 + BUG_ON(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
31841 WARN_ON_ONCE(!(qc->flags & ATA_QCFLAG_ACTIVE));
31842 ap = qc->ap;
31843 link = qc->dev->link;
31844 @@ -5892,6 +5892,7 @@ static void ata_finalize_port_ops(struct ata_port_operations *ops)
31845 return;
31846
31847 spin_lock(&lock);
31848 + pax_open_kernel();
31849
31850 for (cur = ops->inherits; cur; cur = cur->inherits) {
31851 void **inherit = (void **)cur;
31852 @@ -5905,8 +5906,9 @@ static void ata_finalize_port_ops(struct ata_port_operations *ops)
31853 if (IS_ERR(*pp))
31854 *pp = NULL;
31855
31856 - ops->inherits = NULL;
31857 + *(struct ata_port_operations **)&ops->inherits = NULL;
31858
31859 + pax_close_kernel();
31860 spin_unlock(&lock);
31861 }
31862
31863 diff --git a/drivers/ata/pata_arasan_cf.c b/drivers/ata/pata_arasan_cf.c
31864 index 405022d..fb70e53 100644
31865 --- a/drivers/ata/pata_arasan_cf.c
31866 +++ b/drivers/ata/pata_arasan_cf.c
31867 @@ -864,7 +864,9 @@ static int arasan_cf_probe(struct platform_device *pdev)
31868 /* Handle platform specific quirks */
31869 if (pdata->quirk) {
31870 if (pdata->quirk & CF_BROKEN_PIO) {
31871 - ap->ops->set_piomode = NULL;
31872 + pax_open_kernel();
31873 + *(void **)&ap->ops->set_piomode = NULL;
31874 + pax_close_kernel();
31875 ap->pio_mask = 0;
31876 }
31877 if (pdata->quirk & CF_BROKEN_MWDMA)
31878 diff --git a/drivers/atm/adummy.c b/drivers/atm/adummy.c
31879 index f9b983a..887b9d8 100644
31880 --- a/drivers/atm/adummy.c
31881 +++ b/drivers/atm/adummy.c
31882 @@ -114,7 +114,7 @@ adummy_send(struct atm_vcc *vcc, struct sk_buff *skb)
31883 vcc->pop(vcc, skb);
31884 else
31885 dev_kfree_skb_any(skb);
31886 - atomic_inc(&vcc->stats->tx);
31887 + atomic_inc_unchecked(&vcc->stats->tx);
31888
31889 return 0;
31890 }
31891 diff --git a/drivers/atm/ambassador.c b/drivers/atm/ambassador.c
31892 index 77a7480..05cde58 100644
31893 --- a/drivers/atm/ambassador.c
31894 +++ b/drivers/atm/ambassador.c
31895 @@ -454,7 +454,7 @@ static void tx_complete (amb_dev * dev, tx_out * tx) {
31896 PRINTD (DBG_FLOW|DBG_TX, "tx_complete %p %p", dev, tx);
31897
31898 // VC layer stats
31899 - atomic_inc(&ATM_SKB(skb)->vcc->stats->tx);
31900 + atomic_inc_unchecked(&ATM_SKB(skb)->vcc->stats->tx);
31901
31902 // free the descriptor
31903 kfree (tx_descr);
31904 @@ -495,7 +495,7 @@ static void rx_complete (amb_dev * dev, rx_out * rx) {
31905 dump_skb ("<<<", vc, skb);
31906
31907 // VC layer stats
31908 - atomic_inc(&atm_vcc->stats->rx);
31909 + atomic_inc_unchecked(&atm_vcc->stats->rx);
31910 __net_timestamp(skb);
31911 // end of our responsibility
31912 atm_vcc->push (atm_vcc, skb);
31913 @@ -510,7 +510,7 @@ static void rx_complete (amb_dev * dev, rx_out * rx) {
31914 } else {
31915 PRINTK (KERN_INFO, "dropped over-size frame");
31916 // should we count this?
31917 - atomic_inc(&atm_vcc->stats->rx_drop);
31918 + atomic_inc_unchecked(&atm_vcc->stats->rx_drop);
31919 }
31920
31921 } else {
31922 @@ -1338,7 +1338,7 @@ static int amb_send (struct atm_vcc * atm_vcc, struct sk_buff * skb) {
31923 }
31924
31925 if (check_area (skb->data, skb->len)) {
31926 - atomic_inc(&atm_vcc->stats->tx_err);
31927 + atomic_inc_unchecked(&atm_vcc->stats->tx_err);
31928 return -ENOMEM; // ?
31929 }
31930
31931 diff --git a/drivers/atm/atmtcp.c b/drivers/atm/atmtcp.c
31932 index b22d71c..d6e1049 100644
31933 --- a/drivers/atm/atmtcp.c
31934 +++ b/drivers/atm/atmtcp.c
31935 @@ -207,7 +207,7 @@ static int atmtcp_v_send(struct atm_vcc *vcc,struct sk_buff *skb)
31936 if (vcc->pop) vcc->pop(vcc,skb);
31937 else dev_kfree_skb(skb);
31938 if (dev_data) return 0;
31939 - atomic_inc(&vcc->stats->tx_err);
31940 + atomic_inc_unchecked(&vcc->stats->tx_err);
31941 return -ENOLINK;
31942 }
31943 size = skb->len+sizeof(struct atmtcp_hdr);
31944 @@ -215,7 +215,7 @@ static int atmtcp_v_send(struct atm_vcc *vcc,struct sk_buff *skb)
31945 if (!new_skb) {
31946 if (vcc->pop) vcc->pop(vcc,skb);
31947 else dev_kfree_skb(skb);
31948 - atomic_inc(&vcc->stats->tx_err);
31949 + atomic_inc_unchecked(&vcc->stats->tx_err);
31950 return -ENOBUFS;
31951 }
31952 hdr = (void *) skb_put(new_skb,sizeof(struct atmtcp_hdr));
31953 @@ -226,8 +226,8 @@ static int atmtcp_v_send(struct atm_vcc *vcc,struct sk_buff *skb)
31954 if (vcc->pop) vcc->pop(vcc,skb);
31955 else dev_kfree_skb(skb);
31956 out_vcc->push(out_vcc,new_skb);
31957 - atomic_inc(&vcc->stats->tx);
31958 - atomic_inc(&out_vcc->stats->rx);
31959 + atomic_inc_unchecked(&vcc->stats->tx);
31960 + atomic_inc_unchecked(&out_vcc->stats->rx);
31961 return 0;
31962 }
31963
31964 @@ -301,7 +301,7 @@ static int atmtcp_c_send(struct atm_vcc *vcc,struct sk_buff *skb)
31965 out_vcc = find_vcc(dev, ntohs(hdr->vpi), ntohs(hdr->vci));
31966 read_unlock(&vcc_sklist_lock);
31967 if (!out_vcc) {
31968 - atomic_inc(&vcc->stats->tx_err);
31969 + atomic_inc_unchecked(&vcc->stats->tx_err);
31970 goto done;
31971 }
31972 skb_pull(skb,sizeof(struct atmtcp_hdr));
31973 @@ -313,8 +313,8 @@ static int atmtcp_c_send(struct atm_vcc *vcc,struct sk_buff *skb)
31974 __net_timestamp(new_skb);
31975 skb_copy_from_linear_data(skb, skb_put(new_skb, skb->len), skb->len);
31976 out_vcc->push(out_vcc,new_skb);
31977 - atomic_inc(&vcc->stats->tx);
31978 - atomic_inc(&out_vcc->stats->rx);
31979 + atomic_inc_unchecked(&vcc->stats->tx);
31980 + atomic_inc_unchecked(&out_vcc->stats->rx);
31981 done:
31982 if (vcc->pop) vcc->pop(vcc,skb);
31983 else dev_kfree_skb(skb);
31984 diff --git a/drivers/atm/eni.c b/drivers/atm/eni.c
31985 index c1eb6fa..4c71be9 100644
31986 --- a/drivers/atm/eni.c
31987 +++ b/drivers/atm/eni.c
31988 @@ -522,7 +522,7 @@ static int rx_aal0(struct atm_vcc *vcc)
31989 DPRINTK(DEV_LABEL "(itf %d): trashing empty cell\n",
31990 vcc->dev->number);
31991 length = 0;
31992 - atomic_inc(&vcc->stats->rx_err);
31993 + atomic_inc_unchecked(&vcc->stats->rx_err);
31994 }
31995 else {
31996 length = ATM_CELL_SIZE-1; /* no HEC */
31997 @@ -577,7 +577,7 @@ static int rx_aal5(struct atm_vcc *vcc)
31998 size);
31999 }
32000 eff = length = 0;
32001 - atomic_inc(&vcc->stats->rx_err);
32002 + atomic_inc_unchecked(&vcc->stats->rx_err);
32003 }
32004 else {
32005 size = (descr & MID_RED_COUNT)*(ATM_CELL_PAYLOAD >> 2);
32006 @@ -594,7 +594,7 @@ static int rx_aal5(struct atm_vcc *vcc)
32007 "(VCI=%d,length=%ld,size=%ld (descr 0x%lx))\n",
32008 vcc->dev->number,vcc->vci,length,size << 2,descr);
32009 length = eff = 0;
32010 - atomic_inc(&vcc->stats->rx_err);
32011 + atomic_inc_unchecked(&vcc->stats->rx_err);
32012 }
32013 }
32014 skb = eff ? atm_alloc_charge(vcc,eff << 2,GFP_ATOMIC) : NULL;
32015 @@ -767,7 +767,7 @@ rx_dequeued++;
32016 vcc->push(vcc,skb);
32017 pushed++;
32018 }
32019 - atomic_inc(&vcc->stats->rx);
32020 + atomic_inc_unchecked(&vcc->stats->rx);
32021 }
32022 wake_up(&eni_dev->rx_wait);
32023 }
32024 @@ -1227,7 +1227,7 @@ static void dequeue_tx(struct atm_dev *dev)
32025 PCI_DMA_TODEVICE);
32026 if (vcc->pop) vcc->pop(vcc,skb);
32027 else dev_kfree_skb_irq(skb);
32028 - atomic_inc(&vcc->stats->tx);
32029 + atomic_inc_unchecked(&vcc->stats->tx);
32030 wake_up(&eni_dev->tx_wait);
32031 dma_complete++;
32032 }
32033 diff --git a/drivers/atm/firestream.c b/drivers/atm/firestream.c
32034 index b41c948..a002b17 100644
32035 --- a/drivers/atm/firestream.c
32036 +++ b/drivers/atm/firestream.c
32037 @@ -749,7 +749,7 @@ static void process_txdone_queue (struct fs_dev *dev, struct queue *q)
32038 }
32039 }
32040
32041 - atomic_inc(&ATM_SKB(skb)->vcc->stats->tx);
32042 + atomic_inc_unchecked(&ATM_SKB(skb)->vcc->stats->tx);
32043
32044 fs_dprintk (FS_DEBUG_TXMEM, "i");
32045 fs_dprintk (FS_DEBUG_ALLOC, "Free t-skb: %p\n", skb);
32046 @@ -816,7 +816,7 @@ static void process_incoming (struct fs_dev *dev, struct queue *q)
32047 #endif
32048 skb_put (skb, qe->p1 & 0xffff);
32049 ATM_SKB(skb)->vcc = atm_vcc;
32050 - atomic_inc(&atm_vcc->stats->rx);
32051 + atomic_inc_unchecked(&atm_vcc->stats->rx);
32052 __net_timestamp(skb);
32053 fs_dprintk (FS_DEBUG_ALLOC, "Free rec-skb: %p (pushed)\n", skb);
32054 atm_vcc->push (atm_vcc, skb);
32055 @@ -837,12 +837,12 @@ static void process_incoming (struct fs_dev *dev, struct queue *q)
32056 kfree (pe);
32057 }
32058 if (atm_vcc)
32059 - atomic_inc(&atm_vcc->stats->rx_drop);
32060 + atomic_inc_unchecked(&atm_vcc->stats->rx_drop);
32061 break;
32062 case 0x1f: /* Reassembly abort: no buffers. */
32063 /* Silently increment error counter. */
32064 if (atm_vcc)
32065 - atomic_inc(&atm_vcc->stats->rx_drop);
32066 + atomic_inc_unchecked(&atm_vcc->stats->rx_drop);
32067 break;
32068 default: /* Hmm. Haven't written the code to handle the others yet... -- REW */
32069 printk (KERN_WARNING "Don't know what to do with RX status %x: %s.\n",
32070 diff --git a/drivers/atm/fore200e.c b/drivers/atm/fore200e.c
32071 index 204814e..cede831 100644
32072 --- a/drivers/atm/fore200e.c
32073 +++ b/drivers/atm/fore200e.c
32074 @@ -931,9 +931,9 @@ fore200e_tx_irq(struct fore200e* fore200e)
32075 #endif
32076 /* check error condition */
32077 if (*entry->status & STATUS_ERROR)
32078 - atomic_inc(&vcc->stats->tx_err);
32079 + atomic_inc_unchecked(&vcc->stats->tx_err);
32080 else
32081 - atomic_inc(&vcc->stats->tx);
32082 + atomic_inc_unchecked(&vcc->stats->tx);
32083 }
32084 }
32085
32086 @@ -1082,7 +1082,7 @@ fore200e_push_rpd(struct fore200e* fore200e, struct atm_vcc* vcc, struct rpd* rp
32087 if (skb == NULL) {
32088 DPRINTK(2, "unable to alloc new skb, rx PDU length = %d\n", pdu_len);
32089
32090 - atomic_inc(&vcc->stats->rx_drop);
32091 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32092 return -ENOMEM;
32093 }
32094
32095 @@ -1125,14 +1125,14 @@ fore200e_push_rpd(struct fore200e* fore200e, struct atm_vcc* vcc, struct rpd* rp
32096
32097 dev_kfree_skb_any(skb);
32098
32099 - atomic_inc(&vcc->stats->rx_drop);
32100 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32101 return -ENOMEM;
32102 }
32103
32104 ASSERT(atomic_read(&sk_atm(vcc)->sk_wmem_alloc) >= 0);
32105
32106 vcc->push(vcc, skb);
32107 - atomic_inc(&vcc->stats->rx);
32108 + atomic_inc_unchecked(&vcc->stats->rx);
32109
32110 ASSERT(atomic_read(&sk_atm(vcc)->sk_wmem_alloc) >= 0);
32111
32112 @@ -1210,7 +1210,7 @@ fore200e_rx_irq(struct fore200e* fore200e)
32113 DPRINTK(2, "damaged PDU on %d.%d.%d\n",
32114 fore200e->atm_dev->number,
32115 entry->rpd->atm_header.vpi, entry->rpd->atm_header.vci);
32116 - atomic_inc(&vcc->stats->rx_err);
32117 + atomic_inc_unchecked(&vcc->stats->rx_err);
32118 }
32119 }
32120
32121 @@ -1655,7 +1655,7 @@ fore200e_send(struct atm_vcc *vcc, struct sk_buff *skb)
32122 goto retry_here;
32123 }
32124
32125 - atomic_inc(&vcc->stats->tx_err);
32126 + atomic_inc_unchecked(&vcc->stats->tx_err);
32127
32128 fore200e->tx_sat++;
32129 DPRINTK(2, "tx queue of device %s is saturated, PDU dropped - heartbeat is %08x\n",
32130 diff --git a/drivers/atm/he.c b/drivers/atm/he.c
32131 index 72b6960..cf9167a 100644
32132 --- a/drivers/atm/he.c
32133 +++ b/drivers/atm/he.c
32134 @@ -1699,7 +1699,7 @@ he_service_rbrq(struct he_dev *he_dev, int group)
32135
32136 if (RBRQ_HBUF_ERR(he_dev->rbrq_head)) {
32137 hprintk("HBUF_ERR! (cid 0x%x)\n", cid);
32138 - atomic_inc(&vcc->stats->rx_drop);
32139 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32140 goto return_host_buffers;
32141 }
32142
32143 @@ -1726,7 +1726,7 @@ he_service_rbrq(struct he_dev *he_dev, int group)
32144 RBRQ_LEN_ERR(he_dev->rbrq_head)
32145 ? "LEN_ERR" : "",
32146 vcc->vpi, vcc->vci);
32147 - atomic_inc(&vcc->stats->rx_err);
32148 + atomic_inc_unchecked(&vcc->stats->rx_err);
32149 goto return_host_buffers;
32150 }
32151
32152 @@ -1778,7 +1778,7 @@ he_service_rbrq(struct he_dev *he_dev, int group)
32153 vcc->push(vcc, skb);
32154 spin_lock(&he_dev->global_lock);
32155
32156 - atomic_inc(&vcc->stats->rx);
32157 + atomic_inc_unchecked(&vcc->stats->rx);
32158
32159 return_host_buffers:
32160 ++pdus_assembled;
32161 @@ -2104,7 +2104,7 @@ __enqueue_tpd(struct he_dev *he_dev, struct he_tpd *tpd, unsigned cid)
32162 tpd->vcc->pop(tpd->vcc, tpd->skb);
32163 else
32164 dev_kfree_skb_any(tpd->skb);
32165 - atomic_inc(&tpd->vcc->stats->tx_err);
32166 + atomic_inc_unchecked(&tpd->vcc->stats->tx_err);
32167 }
32168 pci_pool_free(he_dev->tpd_pool, tpd, TPD_ADDR(tpd->status));
32169 return;
32170 @@ -2516,7 +2516,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
32171 vcc->pop(vcc, skb);
32172 else
32173 dev_kfree_skb_any(skb);
32174 - atomic_inc(&vcc->stats->tx_err);
32175 + atomic_inc_unchecked(&vcc->stats->tx_err);
32176 return -EINVAL;
32177 }
32178
32179 @@ -2527,7 +2527,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
32180 vcc->pop(vcc, skb);
32181 else
32182 dev_kfree_skb_any(skb);
32183 - atomic_inc(&vcc->stats->tx_err);
32184 + atomic_inc_unchecked(&vcc->stats->tx_err);
32185 return -EINVAL;
32186 }
32187 #endif
32188 @@ -2539,7 +2539,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
32189 vcc->pop(vcc, skb);
32190 else
32191 dev_kfree_skb_any(skb);
32192 - atomic_inc(&vcc->stats->tx_err);
32193 + atomic_inc_unchecked(&vcc->stats->tx_err);
32194 spin_unlock_irqrestore(&he_dev->global_lock, flags);
32195 return -ENOMEM;
32196 }
32197 @@ -2581,7 +2581,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
32198 vcc->pop(vcc, skb);
32199 else
32200 dev_kfree_skb_any(skb);
32201 - atomic_inc(&vcc->stats->tx_err);
32202 + atomic_inc_unchecked(&vcc->stats->tx_err);
32203 spin_unlock_irqrestore(&he_dev->global_lock, flags);
32204 return -ENOMEM;
32205 }
32206 @@ -2612,7 +2612,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
32207 __enqueue_tpd(he_dev, tpd, cid);
32208 spin_unlock_irqrestore(&he_dev->global_lock, flags);
32209
32210 - atomic_inc(&vcc->stats->tx);
32211 + atomic_inc_unchecked(&vcc->stats->tx);
32212
32213 return 0;
32214 }
32215 diff --git a/drivers/atm/horizon.c b/drivers/atm/horizon.c
32216 index 1dc0519..1aadaf7 100644
32217 --- a/drivers/atm/horizon.c
32218 +++ b/drivers/atm/horizon.c
32219 @@ -1034,7 +1034,7 @@ static void rx_schedule (hrz_dev * dev, int irq) {
32220 {
32221 struct atm_vcc * vcc = ATM_SKB(skb)->vcc;
32222 // VC layer stats
32223 - atomic_inc(&vcc->stats->rx);
32224 + atomic_inc_unchecked(&vcc->stats->rx);
32225 __net_timestamp(skb);
32226 // end of our responsibility
32227 vcc->push (vcc, skb);
32228 @@ -1186,7 +1186,7 @@ static void tx_schedule (hrz_dev * const dev, int irq) {
32229 dev->tx_iovec = NULL;
32230
32231 // VC layer stats
32232 - atomic_inc(&ATM_SKB(skb)->vcc->stats->tx);
32233 + atomic_inc_unchecked(&ATM_SKB(skb)->vcc->stats->tx);
32234
32235 // free the skb
32236 hrz_kfree_skb (skb);
32237 diff --git a/drivers/atm/idt77252.c b/drivers/atm/idt77252.c
32238 index 272f009..a18ba55 100644
32239 --- a/drivers/atm/idt77252.c
32240 +++ b/drivers/atm/idt77252.c
32241 @@ -812,7 +812,7 @@ drain_scq(struct idt77252_dev *card, struct vc_map *vc)
32242 else
32243 dev_kfree_skb(skb);
32244
32245 - atomic_inc(&vcc->stats->tx);
32246 + atomic_inc_unchecked(&vcc->stats->tx);
32247 }
32248
32249 atomic_dec(&scq->used);
32250 @@ -1075,13 +1075,13 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
32251 if ((sb = dev_alloc_skb(64)) == NULL) {
32252 printk("%s: Can't allocate buffers for aal0.\n",
32253 card->name);
32254 - atomic_add(i, &vcc->stats->rx_drop);
32255 + atomic_add_unchecked(i, &vcc->stats->rx_drop);
32256 break;
32257 }
32258 if (!atm_charge(vcc, sb->truesize)) {
32259 RXPRINTK("%s: atm_charge() dropped aal0 packets.\n",
32260 card->name);
32261 - atomic_add(i - 1, &vcc->stats->rx_drop);
32262 + atomic_add_unchecked(i - 1, &vcc->stats->rx_drop);
32263 dev_kfree_skb(sb);
32264 break;
32265 }
32266 @@ -1098,7 +1098,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
32267 ATM_SKB(sb)->vcc = vcc;
32268 __net_timestamp(sb);
32269 vcc->push(vcc, sb);
32270 - atomic_inc(&vcc->stats->rx);
32271 + atomic_inc_unchecked(&vcc->stats->rx);
32272
32273 cell += ATM_CELL_PAYLOAD;
32274 }
32275 @@ -1135,13 +1135,13 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
32276 "(CDC: %08x)\n",
32277 card->name, len, rpp->len, readl(SAR_REG_CDC));
32278 recycle_rx_pool_skb(card, rpp);
32279 - atomic_inc(&vcc->stats->rx_err);
32280 + atomic_inc_unchecked(&vcc->stats->rx_err);
32281 return;
32282 }
32283 if (stat & SAR_RSQE_CRC) {
32284 RXPRINTK("%s: AAL5 CRC error.\n", card->name);
32285 recycle_rx_pool_skb(card, rpp);
32286 - atomic_inc(&vcc->stats->rx_err);
32287 + atomic_inc_unchecked(&vcc->stats->rx_err);
32288 return;
32289 }
32290 if (skb_queue_len(&rpp->queue) > 1) {
32291 @@ -1152,7 +1152,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
32292 RXPRINTK("%s: Can't alloc RX skb.\n",
32293 card->name);
32294 recycle_rx_pool_skb(card, rpp);
32295 - atomic_inc(&vcc->stats->rx_err);
32296 + atomic_inc_unchecked(&vcc->stats->rx_err);
32297 return;
32298 }
32299 if (!atm_charge(vcc, skb->truesize)) {
32300 @@ -1171,7 +1171,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
32301 __net_timestamp(skb);
32302
32303 vcc->push(vcc, skb);
32304 - atomic_inc(&vcc->stats->rx);
32305 + atomic_inc_unchecked(&vcc->stats->rx);
32306
32307 return;
32308 }
32309 @@ -1193,7 +1193,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
32310 __net_timestamp(skb);
32311
32312 vcc->push(vcc, skb);
32313 - atomic_inc(&vcc->stats->rx);
32314 + atomic_inc_unchecked(&vcc->stats->rx);
32315
32316 if (skb->truesize > SAR_FB_SIZE_3)
32317 add_rx_skb(card, 3, SAR_FB_SIZE_3, 1);
32318 @@ -1304,14 +1304,14 @@ idt77252_rx_raw(struct idt77252_dev *card)
32319 if (vcc->qos.aal != ATM_AAL0) {
32320 RPRINTK("%s: raw cell for non AAL0 vc %u.%u\n",
32321 card->name, vpi, vci);
32322 - atomic_inc(&vcc->stats->rx_drop);
32323 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32324 goto drop;
32325 }
32326
32327 if ((sb = dev_alloc_skb(64)) == NULL) {
32328 printk("%s: Can't allocate buffers for AAL0.\n",
32329 card->name);
32330 - atomic_inc(&vcc->stats->rx_err);
32331 + atomic_inc_unchecked(&vcc->stats->rx_err);
32332 goto drop;
32333 }
32334
32335 @@ -1330,7 +1330,7 @@ idt77252_rx_raw(struct idt77252_dev *card)
32336 ATM_SKB(sb)->vcc = vcc;
32337 __net_timestamp(sb);
32338 vcc->push(vcc, sb);
32339 - atomic_inc(&vcc->stats->rx);
32340 + atomic_inc_unchecked(&vcc->stats->rx);
32341
32342 drop:
32343 skb_pull(queue, 64);
32344 @@ -1955,13 +1955,13 @@ idt77252_send_skb(struct atm_vcc *vcc, struct sk_buff *skb, int oam)
32345
32346 if (vc == NULL) {
32347 printk("%s: NULL connection in send().\n", card->name);
32348 - atomic_inc(&vcc->stats->tx_err);
32349 + atomic_inc_unchecked(&vcc->stats->tx_err);
32350 dev_kfree_skb(skb);
32351 return -EINVAL;
32352 }
32353 if (!test_bit(VCF_TX, &vc->flags)) {
32354 printk("%s: Trying to transmit on a non-tx VC.\n", card->name);
32355 - atomic_inc(&vcc->stats->tx_err);
32356 + atomic_inc_unchecked(&vcc->stats->tx_err);
32357 dev_kfree_skb(skb);
32358 return -EINVAL;
32359 }
32360 @@ -1973,14 +1973,14 @@ idt77252_send_skb(struct atm_vcc *vcc, struct sk_buff *skb, int oam)
32361 break;
32362 default:
32363 printk("%s: Unsupported AAL: %d\n", card->name, vcc->qos.aal);
32364 - atomic_inc(&vcc->stats->tx_err);
32365 + atomic_inc_unchecked(&vcc->stats->tx_err);
32366 dev_kfree_skb(skb);
32367 return -EINVAL;
32368 }
32369
32370 if (skb_shinfo(skb)->nr_frags != 0) {
32371 printk("%s: No scatter-gather yet.\n", card->name);
32372 - atomic_inc(&vcc->stats->tx_err);
32373 + atomic_inc_unchecked(&vcc->stats->tx_err);
32374 dev_kfree_skb(skb);
32375 return -EINVAL;
32376 }
32377 @@ -1988,7 +1988,7 @@ idt77252_send_skb(struct atm_vcc *vcc, struct sk_buff *skb, int oam)
32378
32379 err = queue_skb(card, vc, skb, oam);
32380 if (err) {
32381 - atomic_inc(&vcc->stats->tx_err);
32382 + atomic_inc_unchecked(&vcc->stats->tx_err);
32383 dev_kfree_skb(skb);
32384 return err;
32385 }
32386 @@ -2011,7 +2011,7 @@ idt77252_send_oam(struct atm_vcc *vcc, void *cell, int flags)
32387 skb = dev_alloc_skb(64);
32388 if (!skb) {
32389 printk("%s: Out of memory in send_oam().\n", card->name);
32390 - atomic_inc(&vcc->stats->tx_err);
32391 + atomic_inc_unchecked(&vcc->stats->tx_err);
32392 return -ENOMEM;
32393 }
32394 atomic_add(skb->truesize, &sk_atm(vcc)->sk_wmem_alloc);
32395 diff --git a/drivers/atm/iphase.c b/drivers/atm/iphase.c
32396 index 4217f29..88f547a 100644
32397 --- a/drivers/atm/iphase.c
32398 +++ b/drivers/atm/iphase.c
32399 @@ -1145,7 +1145,7 @@ static int rx_pkt(struct atm_dev *dev)
32400 status = (u_short) (buf_desc_ptr->desc_mode);
32401 if (status & (RX_CER | RX_PTE | RX_OFL))
32402 {
32403 - atomic_inc(&vcc->stats->rx_err);
32404 + atomic_inc_unchecked(&vcc->stats->rx_err);
32405 IF_ERR(printk("IA: bad packet, dropping it");)
32406 if (status & RX_CER) {
32407 IF_ERR(printk(" cause: packet CRC error\n");)
32408 @@ -1168,7 +1168,7 @@ static int rx_pkt(struct atm_dev *dev)
32409 len = dma_addr - buf_addr;
32410 if (len > iadev->rx_buf_sz) {
32411 printk("Over %d bytes sdu received, dropped!!!\n", iadev->rx_buf_sz);
32412 - atomic_inc(&vcc->stats->rx_err);
32413 + atomic_inc_unchecked(&vcc->stats->rx_err);
32414 goto out_free_desc;
32415 }
32416
32417 @@ -1318,7 +1318,7 @@ static void rx_dle_intr(struct atm_dev *dev)
32418 ia_vcc = INPH_IA_VCC(vcc);
32419 if (ia_vcc == NULL)
32420 {
32421 - atomic_inc(&vcc->stats->rx_err);
32422 + atomic_inc_unchecked(&vcc->stats->rx_err);
32423 atm_return(vcc, skb->truesize);
32424 dev_kfree_skb_any(skb);
32425 goto INCR_DLE;
32426 @@ -1330,7 +1330,7 @@ static void rx_dle_intr(struct atm_dev *dev)
32427 if ((length > iadev->rx_buf_sz) || (length >
32428 (skb->len - sizeof(struct cpcs_trailer))))
32429 {
32430 - atomic_inc(&vcc->stats->rx_err);
32431 + atomic_inc_unchecked(&vcc->stats->rx_err);
32432 IF_ERR(printk("rx_dle_intr: Bad AAL5 trailer %d (skb len %d)",
32433 length, skb->len);)
32434 atm_return(vcc, skb->truesize);
32435 @@ -1346,7 +1346,7 @@ static void rx_dle_intr(struct atm_dev *dev)
32436
32437 IF_RX(printk("rx_dle_intr: skb push");)
32438 vcc->push(vcc,skb);
32439 - atomic_inc(&vcc->stats->rx);
32440 + atomic_inc_unchecked(&vcc->stats->rx);
32441 iadev->rx_pkt_cnt++;
32442 }
32443 INCR_DLE:
32444 @@ -2826,15 +2826,15 @@ static int ia_ioctl(struct atm_dev *dev, unsigned int cmd, void __user *arg)
32445 {
32446 struct k_sonet_stats *stats;
32447 stats = &PRIV(_ia_dev[board])->sonet_stats;
32448 - printk("section_bip: %d\n", atomic_read(&stats->section_bip));
32449 - printk("line_bip : %d\n", atomic_read(&stats->line_bip));
32450 - printk("path_bip : %d\n", atomic_read(&stats->path_bip));
32451 - printk("line_febe : %d\n", atomic_read(&stats->line_febe));
32452 - printk("path_febe : %d\n", atomic_read(&stats->path_febe));
32453 - printk("corr_hcs : %d\n", atomic_read(&stats->corr_hcs));
32454 - printk("uncorr_hcs : %d\n", atomic_read(&stats->uncorr_hcs));
32455 - printk("tx_cells : %d\n", atomic_read(&stats->tx_cells));
32456 - printk("rx_cells : %d\n", atomic_read(&stats->rx_cells));
32457 + printk("section_bip: %d\n", atomic_read_unchecked(&stats->section_bip));
32458 + printk("line_bip : %d\n", atomic_read_unchecked(&stats->line_bip));
32459 + printk("path_bip : %d\n", atomic_read_unchecked(&stats->path_bip));
32460 + printk("line_febe : %d\n", atomic_read_unchecked(&stats->line_febe));
32461 + printk("path_febe : %d\n", atomic_read_unchecked(&stats->path_febe));
32462 + printk("corr_hcs : %d\n", atomic_read_unchecked(&stats->corr_hcs));
32463 + printk("uncorr_hcs : %d\n", atomic_read_unchecked(&stats->uncorr_hcs));
32464 + printk("tx_cells : %d\n", atomic_read_unchecked(&stats->tx_cells));
32465 + printk("rx_cells : %d\n", atomic_read_unchecked(&stats->rx_cells));
32466 }
32467 ia_cmds.status = 0;
32468 break;
32469 @@ -2939,7 +2939,7 @@ static int ia_pkt_tx (struct atm_vcc *vcc, struct sk_buff *skb) {
32470 if ((desc == 0) || (desc > iadev->num_tx_desc))
32471 {
32472 IF_ERR(printk(DEV_LABEL "invalid desc for send: %d\n", desc);)
32473 - atomic_inc(&vcc->stats->tx);
32474 + atomic_inc_unchecked(&vcc->stats->tx);
32475 if (vcc->pop)
32476 vcc->pop(vcc, skb);
32477 else
32478 @@ -3044,14 +3044,14 @@ static int ia_pkt_tx (struct atm_vcc *vcc, struct sk_buff *skb) {
32479 ATM_DESC(skb) = vcc->vci;
32480 skb_queue_tail(&iadev->tx_dma_q, skb);
32481
32482 - atomic_inc(&vcc->stats->tx);
32483 + atomic_inc_unchecked(&vcc->stats->tx);
32484 iadev->tx_pkt_cnt++;
32485 /* Increment transaction counter */
32486 writel(2, iadev->dma+IPHASE5575_TX_COUNTER);
32487
32488 #if 0
32489 /* add flow control logic */
32490 - if (atomic_read(&vcc->stats->tx) % 20 == 0) {
32491 + if (atomic_read_unchecked(&vcc->stats->tx) % 20 == 0) {
32492 if (iavcc->vc_desc_cnt > 10) {
32493 vcc->tx_quota = vcc->tx_quota * 3 / 4;
32494 printk("Tx1: vcc->tx_quota = %d \n", (u32)vcc->tx_quota );
32495 diff --git a/drivers/atm/lanai.c b/drivers/atm/lanai.c
32496 index fa7d701..1e404c7 100644
32497 --- a/drivers/atm/lanai.c
32498 +++ b/drivers/atm/lanai.c
32499 @@ -1303,7 +1303,7 @@ static void lanai_send_one_aal5(struct lanai_dev *lanai,
32500 vcc_tx_add_aal5_trailer(lvcc, skb->len, 0, 0);
32501 lanai_endtx(lanai, lvcc);
32502 lanai_free_skb(lvcc->tx.atmvcc, skb);
32503 - atomic_inc(&lvcc->tx.atmvcc->stats->tx);
32504 + atomic_inc_unchecked(&lvcc->tx.atmvcc->stats->tx);
32505 }
32506
32507 /* Try to fill the buffer - don't call unless there is backlog */
32508 @@ -1426,7 +1426,7 @@ static void vcc_rx_aal5(struct lanai_vcc *lvcc, int endptr)
32509 ATM_SKB(skb)->vcc = lvcc->rx.atmvcc;
32510 __net_timestamp(skb);
32511 lvcc->rx.atmvcc->push(lvcc->rx.atmvcc, skb);
32512 - atomic_inc(&lvcc->rx.atmvcc->stats->rx);
32513 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx);
32514 out:
32515 lvcc->rx.buf.ptr = end;
32516 cardvcc_write(lvcc, endptr, vcc_rxreadptr);
32517 @@ -1667,7 +1667,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
32518 DPRINTK("(itf %d) got RX service entry 0x%X for non-AAL5 "
32519 "vcc %d\n", lanai->number, (unsigned int) s, vci);
32520 lanai->stats.service_rxnotaal5++;
32521 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
32522 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
32523 return 0;
32524 }
32525 if (likely(!(s & (SERVICE_TRASH | SERVICE_STREAM | SERVICE_CRCERR)))) {
32526 @@ -1679,7 +1679,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
32527 int bytes;
32528 read_unlock(&vcc_sklist_lock);
32529 DPRINTK("got trashed rx pdu on vci %d\n", vci);
32530 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
32531 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
32532 lvcc->stats.x.aal5.service_trash++;
32533 bytes = (SERVICE_GET_END(s) * 16) -
32534 (((unsigned long) lvcc->rx.buf.ptr) -
32535 @@ -1691,7 +1691,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
32536 }
32537 if (s & SERVICE_STREAM) {
32538 read_unlock(&vcc_sklist_lock);
32539 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
32540 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
32541 lvcc->stats.x.aal5.service_stream++;
32542 printk(KERN_ERR DEV_LABEL "(itf %d): Got AAL5 stream "
32543 "PDU on VCI %d!\n", lanai->number, vci);
32544 @@ -1699,7 +1699,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
32545 return 0;
32546 }
32547 DPRINTK("got rx crc error on vci %d\n", vci);
32548 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
32549 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
32550 lvcc->stats.x.aal5.service_rxcrc++;
32551 lvcc->rx.buf.ptr = &lvcc->rx.buf.start[SERVICE_GET_END(s) * 4];
32552 cardvcc_write(lvcc, SERVICE_GET_END(s), vcc_rxreadptr);
32553 diff --git a/drivers/atm/nicstar.c b/drivers/atm/nicstar.c
32554 index ed1d2b7..8cffc1f 100644
32555 --- a/drivers/atm/nicstar.c
32556 +++ b/drivers/atm/nicstar.c
32557 @@ -1654,7 +1654,7 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
32558 if ((vc = (vc_map *) vcc->dev_data) == NULL) {
32559 printk("nicstar%d: vcc->dev_data == NULL on ns_send().\n",
32560 card->index);
32561 - atomic_inc(&vcc->stats->tx_err);
32562 + atomic_inc_unchecked(&vcc->stats->tx_err);
32563 dev_kfree_skb_any(skb);
32564 return -EINVAL;
32565 }
32566 @@ -1662,7 +1662,7 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
32567 if (!vc->tx) {
32568 printk("nicstar%d: Trying to transmit on a non-tx VC.\n",
32569 card->index);
32570 - atomic_inc(&vcc->stats->tx_err);
32571 + atomic_inc_unchecked(&vcc->stats->tx_err);
32572 dev_kfree_skb_any(skb);
32573 return -EINVAL;
32574 }
32575 @@ -1670,14 +1670,14 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
32576 if (vcc->qos.aal != ATM_AAL5 && vcc->qos.aal != ATM_AAL0) {
32577 printk("nicstar%d: Only AAL0 and AAL5 are supported.\n",
32578 card->index);
32579 - atomic_inc(&vcc->stats->tx_err);
32580 + atomic_inc_unchecked(&vcc->stats->tx_err);
32581 dev_kfree_skb_any(skb);
32582 return -EINVAL;
32583 }
32584
32585 if (skb_shinfo(skb)->nr_frags != 0) {
32586 printk("nicstar%d: No scatter-gather yet.\n", card->index);
32587 - atomic_inc(&vcc->stats->tx_err);
32588 + atomic_inc_unchecked(&vcc->stats->tx_err);
32589 dev_kfree_skb_any(skb);
32590 return -EINVAL;
32591 }
32592 @@ -1725,11 +1725,11 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
32593 }
32594
32595 if (push_scqe(card, vc, scq, &scqe, skb) != 0) {
32596 - atomic_inc(&vcc->stats->tx_err);
32597 + atomic_inc_unchecked(&vcc->stats->tx_err);
32598 dev_kfree_skb_any(skb);
32599 return -EIO;
32600 }
32601 - atomic_inc(&vcc->stats->tx);
32602 + atomic_inc_unchecked(&vcc->stats->tx);
32603
32604 return 0;
32605 }
32606 @@ -2046,14 +2046,14 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32607 printk
32608 ("nicstar%d: Can't allocate buffers for aal0.\n",
32609 card->index);
32610 - atomic_add(i, &vcc->stats->rx_drop);
32611 + atomic_add_unchecked(i, &vcc->stats->rx_drop);
32612 break;
32613 }
32614 if (!atm_charge(vcc, sb->truesize)) {
32615 RXPRINTK
32616 ("nicstar%d: atm_charge() dropped aal0 packets.\n",
32617 card->index);
32618 - atomic_add(i - 1, &vcc->stats->rx_drop); /* already increased by 1 */
32619 + atomic_add_unchecked(i - 1, &vcc->stats->rx_drop); /* already increased by 1 */
32620 dev_kfree_skb_any(sb);
32621 break;
32622 }
32623 @@ -2068,7 +2068,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32624 ATM_SKB(sb)->vcc = vcc;
32625 __net_timestamp(sb);
32626 vcc->push(vcc, sb);
32627 - atomic_inc(&vcc->stats->rx);
32628 + atomic_inc_unchecked(&vcc->stats->rx);
32629 cell += ATM_CELL_PAYLOAD;
32630 }
32631
32632 @@ -2085,7 +2085,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32633 if (iovb == NULL) {
32634 printk("nicstar%d: Out of iovec buffers.\n",
32635 card->index);
32636 - atomic_inc(&vcc->stats->rx_drop);
32637 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32638 recycle_rx_buf(card, skb);
32639 return;
32640 }
32641 @@ -2109,7 +2109,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32642 small or large buffer itself. */
32643 } else if (NS_PRV_IOVCNT(iovb) >= NS_MAX_IOVECS) {
32644 printk("nicstar%d: received too big AAL5 SDU.\n", card->index);
32645 - atomic_inc(&vcc->stats->rx_err);
32646 + atomic_inc_unchecked(&vcc->stats->rx_err);
32647 recycle_iovec_rx_bufs(card, (struct iovec *)iovb->data,
32648 NS_MAX_IOVECS);
32649 NS_PRV_IOVCNT(iovb) = 0;
32650 @@ -2129,7 +2129,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32651 ("nicstar%d: Expected a small buffer, and this is not one.\n",
32652 card->index);
32653 which_list(card, skb);
32654 - atomic_inc(&vcc->stats->rx_err);
32655 + atomic_inc_unchecked(&vcc->stats->rx_err);
32656 recycle_rx_buf(card, skb);
32657 vc->rx_iov = NULL;
32658 recycle_iov_buf(card, iovb);
32659 @@ -2142,7 +2142,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32660 ("nicstar%d: Expected a large buffer, and this is not one.\n",
32661 card->index);
32662 which_list(card, skb);
32663 - atomic_inc(&vcc->stats->rx_err);
32664 + atomic_inc_unchecked(&vcc->stats->rx_err);
32665 recycle_iovec_rx_bufs(card, (struct iovec *)iovb->data,
32666 NS_PRV_IOVCNT(iovb));
32667 vc->rx_iov = NULL;
32668 @@ -2165,7 +2165,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32669 printk(" - PDU size mismatch.\n");
32670 else
32671 printk(".\n");
32672 - atomic_inc(&vcc->stats->rx_err);
32673 + atomic_inc_unchecked(&vcc->stats->rx_err);
32674 recycle_iovec_rx_bufs(card, (struct iovec *)iovb->data,
32675 NS_PRV_IOVCNT(iovb));
32676 vc->rx_iov = NULL;
32677 @@ -2179,7 +2179,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32678 /* skb points to a small buffer */
32679 if (!atm_charge(vcc, skb->truesize)) {
32680 push_rxbufs(card, skb);
32681 - atomic_inc(&vcc->stats->rx_drop);
32682 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32683 } else {
32684 skb_put(skb, len);
32685 dequeue_sm_buf(card, skb);
32686 @@ -2189,7 +2189,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32687 ATM_SKB(skb)->vcc = vcc;
32688 __net_timestamp(skb);
32689 vcc->push(vcc, skb);
32690 - atomic_inc(&vcc->stats->rx);
32691 + atomic_inc_unchecked(&vcc->stats->rx);
32692 }
32693 } else if (NS_PRV_IOVCNT(iovb) == 2) { /* One small plus one large buffer */
32694 struct sk_buff *sb;
32695 @@ -2200,7 +2200,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32696 if (len <= NS_SMBUFSIZE) {
32697 if (!atm_charge(vcc, sb->truesize)) {
32698 push_rxbufs(card, sb);
32699 - atomic_inc(&vcc->stats->rx_drop);
32700 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32701 } else {
32702 skb_put(sb, len);
32703 dequeue_sm_buf(card, sb);
32704 @@ -2210,7 +2210,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32705 ATM_SKB(sb)->vcc = vcc;
32706 __net_timestamp(sb);
32707 vcc->push(vcc, sb);
32708 - atomic_inc(&vcc->stats->rx);
32709 + atomic_inc_unchecked(&vcc->stats->rx);
32710 }
32711
32712 push_rxbufs(card, skb);
32713 @@ -2219,7 +2219,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32714
32715 if (!atm_charge(vcc, skb->truesize)) {
32716 push_rxbufs(card, skb);
32717 - atomic_inc(&vcc->stats->rx_drop);
32718 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32719 } else {
32720 dequeue_lg_buf(card, skb);
32721 #ifdef NS_USE_DESTRUCTORS
32722 @@ -2232,7 +2232,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32723 ATM_SKB(skb)->vcc = vcc;
32724 __net_timestamp(skb);
32725 vcc->push(vcc, skb);
32726 - atomic_inc(&vcc->stats->rx);
32727 + atomic_inc_unchecked(&vcc->stats->rx);
32728 }
32729
32730 push_rxbufs(card, sb);
32731 @@ -2253,7 +2253,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32732 printk
32733 ("nicstar%d: Out of huge buffers.\n",
32734 card->index);
32735 - atomic_inc(&vcc->stats->rx_drop);
32736 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32737 recycle_iovec_rx_bufs(card,
32738 (struct iovec *)
32739 iovb->data,
32740 @@ -2304,7 +2304,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32741 card->hbpool.count++;
32742 } else
32743 dev_kfree_skb_any(hb);
32744 - atomic_inc(&vcc->stats->rx_drop);
32745 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32746 } else {
32747 /* Copy the small buffer to the huge buffer */
32748 sb = (struct sk_buff *)iov->iov_base;
32749 @@ -2341,7 +2341,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32750 #endif /* NS_USE_DESTRUCTORS */
32751 __net_timestamp(hb);
32752 vcc->push(vcc, hb);
32753 - atomic_inc(&vcc->stats->rx);
32754 + atomic_inc_unchecked(&vcc->stats->rx);
32755 }
32756 }
32757
32758 diff --git a/drivers/atm/solos-pci.c b/drivers/atm/solos-pci.c
32759 index 0474a89..06ea4a1 100644
32760 --- a/drivers/atm/solos-pci.c
32761 +++ b/drivers/atm/solos-pci.c
32762 @@ -838,7 +838,7 @@ void solos_bh(unsigned long card_arg)
32763 }
32764 atm_charge(vcc, skb->truesize);
32765 vcc->push(vcc, skb);
32766 - atomic_inc(&vcc->stats->rx);
32767 + atomic_inc_unchecked(&vcc->stats->rx);
32768 break;
32769
32770 case PKT_STATUS:
32771 @@ -1117,7 +1117,7 @@ static uint32_t fpga_tx(struct solos_card *card)
32772 vcc = SKB_CB(oldskb)->vcc;
32773
32774 if (vcc) {
32775 - atomic_inc(&vcc->stats->tx);
32776 + atomic_inc_unchecked(&vcc->stats->tx);
32777 solos_pop(vcc, oldskb);
32778 } else {
32779 dev_kfree_skb_irq(oldskb);
32780 diff --git a/drivers/atm/suni.c b/drivers/atm/suni.c
32781 index 0215934..ce9f5b1 100644
32782 --- a/drivers/atm/suni.c
32783 +++ b/drivers/atm/suni.c
32784 @@ -49,8 +49,8 @@ static DEFINE_SPINLOCK(sunis_lock);
32785
32786
32787 #define ADD_LIMITED(s,v) \
32788 - atomic_add((v),&stats->s); \
32789 - if (atomic_read(&stats->s) < 0) atomic_set(&stats->s,INT_MAX);
32790 + atomic_add_unchecked((v),&stats->s); \
32791 + if (atomic_read_unchecked(&stats->s) < 0) atomic_set_unchecked(&stats->s,INT_MAX);
32792
32793
32794 static void suni_hz(unsigned long from_timer)
32795 diff --git a/drivers/atm/uPD98402.c b/drivers/atm/uPD98402.c
32796 index 5120a96..e2572bd 100644
32797 --- a/drivers/atm/uPD98402.c
32798 +++ b/drivers/atm/uPD98402.c
32799 @@ -42,7 +42,7 @@ static int fetch_stats(struct atm_dev *dev,struct sonet_stats __user *arg,int ze
32800 struct sonet_stats tmp;
32801 int error = 0;
32802
32803 - atomic_add(GET(HECCT),&PRIV(dev)->sonet_stats.uncorr_hcs);
32804 + atomic_add_unchecked(GET(HECCT),&PRIV(dev)->sonet_stats.uncorr_hcs);
32805 sonet_copy_stats(&PRIV(dev)->sonet_stats,&tmp);
32806 if (arg) error = copy_to_user(arg,&tmp,sizeof(tmp));
32807 if (zero && !error) {
32808 @@ -161,9 +161,9 @@ static int uPD98402_ioctl(struct atm_dev *dev,unsigned int cmd,void __user *arg)
32809
32810
32811 #define ADD_LIMITED(s,v) \
32812 - { atomic_add(GET(v),&PRIV(dev)->sonet_stats.s); \
32813 - if (atomic_read(&PRIV(dev)->sonet_stats.s) < 0) \
32814 - atomic_set(&PRIV(dev)->sonet_stats.s,INT_MAX); }
32815 + { atomic_add_unchecked(GET(v),&PRIV(dev)->sonet_stats.s); \
32816 + if (atomic_read_unchecked(&PRIV(dev)->sonet_stats.s) < 0) \
32817 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.s,INT_MAX); }
32818
32819
32820 static void stat_event(struct atm_dev *dev)
32821 @@ -194,7 +194,7 @@ static void uPD98402_int(struct atm_dev *dev)
32822 if (reason & uPD98402_INT_PFM) stat_event(dev);
32823 if (reason & uPD98402_INT_PCO) {
32824 (void) GET(PCOCR); /* clear interrupt cause */
32825 - atomic_add(GET(HECCT),
32826 + atomic_add_unchecked(GET(HECCT),
32827 &PRIV(dev)->sonet_stats.uncorr_hcs);
32828 }
32829 if ((reason & uPD98402_INT_RFO) &&
32830 @@ -222,9 +222,9 @@ static int uPD98402_start(struct atm_dev *dev)
32831 PUT(~(uPD98402_INT_PFM | uPD98402_INT_ALM | uPD98402_INT_RFO |
32832 uPD98402_INT_LOS),PIMR); /* enable them */
32833 (void) fetch_stats(dev,NULL,1); /* clear kernel counters */
32834 - atomic_set(&PRIV(dev)->sonet_stats.corr_hcs,-1);
32835 - atomic_set(&PRIV(dev)->sonet_stats.tx_cells,-1);
32836 - atomic_set(&PRIV(dev)->sonet_stats.rx_cells,-1);
32837 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.corr_hcs,-1);
32838 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.tx_cells,-1);
32839 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.rx_cells,-1);
32840 return 0;
32841 }
32842
32843 diff --git a/drivers/atm/zatm.c b/drivers/atm/zatm.c
32844 index 969c3c2..9b72956 100644
32845 --- a/drivers/atm/zatm.c
32846 +++ b/drivers/atm/zatm.c
32847 @@ -459,7 +459,7 @@ printk("dummy: 0x%08lx, 0x%08lx\n",dummy[0],dummy[1]);
32848 }
32849 if (!size) {
32850 dev_kfree_skb_irq(skb);
32851 - if (vcc) atomic_inc(&vcc->stats->rx_err);
32852 + if (vcc) atomic_inc_unchecked(&vcc->stats->rx_err);
32853 continue;
32854 }
32855 if (!atm_charge(vcc,skb->truesize)) {
32856 @@ -469,7 +469,7 @@ printk("dummy: 0x%08lx, 0x%08lx\n",dummy[0],dummy[1]);
32857 skb->len = size;
32858 ATM_SKB(skb)->vcc = vcc;
32859 vcc->push(vcc,skb);
32860 - atomic_inc(&vcc->stats->rx);
32861 + atomic_inc_unchecked(&vcc->stats->rx);
32862 }
32863 zout(pos & 0xffff,MTA(mbx));
32864 #if 0 /* probably a stupid idea */
32865 @@ -733,7 +733,7 @@ if (*ZATM_PRV_DSC(skb) != (uPD98401_TXPD_V | uPD98401_TXPD_DP |
32866 skb_queue_head(&zatm_vcc->backlog,skb);
32867 break;
32868 }
32869 - atomic_inc(&vcc->stats->tx);
32870 + atomic_inc_unchecked(&vcc->stats->tx);
32871 wake_up(&zatm_vcc->tx_wait);
32872 }
32873
32874 diff --git a/drivers/base/bus.c b/drivers/base/bus.c
32875 index 6856303..0602d70 100644
32876 --- a/drivers/base/bus.c
32877 +++ b/drivers/base/bus.c
32878 @@ -1163,7 +1163,7 @@ int subsys_interface_register(struct subsys_interface *sif)
32879 return -EINVAL;
32880
32881 mutex_lock(&subsys->p->mutex);
32882 - list_add_tail(&sif->node, &subsys->p->interfaces);
32883 + pax_list_add_tail((struct list_head *)&sif->node, &subsys->p->interfaces);
32884 if (sif->add_dev) {
32885 subsys_dev_iter_init(&iter, subsys, NULL, NULL);
32886 while ((dev = subsys_dev_iter_next(&iter)))
32887 @@ -1188,7 +1188,7 @@ void subsys_interface_unregister(struct subsys_interface *sif)
32888 subsys = sif->subsys;
32889
32890 mutex_lock(&subsys->p->mutex);
32891 - list_del_init(&sif->node);
32892 + pax_list_del_init((struct list_head *)&sif->node);
32893 if (sif->remove_dev) {
32894 subsys_dev_iter_init(&iter, subsys, NULL, NULL);
32895 while ((dev = subsys_dev_iter_next(&iter)))
32896 diff --git a/drivers/base/devtmpfs.c b/drivers/base/devtmpfs.c
32897 index 17cf7ca..7e553e1 100644
32898 --- a/drivers/base/devtmpfs.c
32899 +++ b/drivers/base/devtmpfs.c
32900 @@ -347,7 +347,7 @@ int devtmpfs_mount(const char *mntdir)
32901 if (!thread)
32902 return 0;
32903
32904 - err = sys_mount("devtmpfs", (char *)mntdir, "devtmpfs", MS_SILENT, NULL);
32905 + err = sys_mount((char __force_user *)"devtmpfs", (char __force_user *)mntdir, (char __force_user *)"devtmpfs", MS_SILENT, NULL);
32906 if (err)
32907 printk(KERN_INFO "devtmpfs: error mounting %i\n", err);
32908 else
32909 diff --git a/drivers/base/node.c b/drivers/base/node.c
32910 index fac124a..66bd4ab 100644
32911 --- a/drivers/base/node.c
32912 +++ b/drivers/base/node.c
32913 @@ -625,7 +625,7 @@ static ssize_t print_nodes_state(enum node_states state, char *buf)
32914 struct node_attr {
32915 struct device_attribute attr;
32916 enum node_states state;
32917 -};
32918 +} __do_const;
32919
32920 static ssize_t show_node_state(struct device *dev,
32921 struct device_attribute *attr, char *buf)
32922 diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c
32923 index acc3a8d..981c236 100644
32924 --- a/drivers/base/power/domain.c
32925 +++ b/drivers/base/power/domain.c
32926 @@ -1851,7 +1851,7 @@ int pm_genpd_attach_cpuidle(struct generic_pm_domain *genpd, int state)
32927 {
32928 struct cpuidle_driver *cpuidle_drv;
32929 struct gpd_cpu_data *cpu_data;
32930 - struct cpuidle_state *idle_state;
32931 + cpuidle_state_no_const *idle_state;
32932 int ret = 0;
32933
32934 if (IS_ERR_OR_NULL(genpd) || state < 0)
32935 @@ -1919,7 +1919,7 @@ int pm_genpd_name_attach_cpuidle(const char *name, int state)
32936 int pm_genpd_detach_cpuidle(struct generic_pm_domain *genpd)
32937 {
32938 struct gpd_cpu_data *cpu_data;
32939 - struct cpuidle_state *idle_state;
32940 + cpuidle_state_no_const *idle_state;
32941 int ret = 0;
32942
32943 if (IS_ERR_OR_NULL(genpd))
32944 diff --git a/drivers/base/power/wakeup.c b/drivers/base/power/wakeup.c
32945 index e6ee5e8..98ad7fc 100644
32946 --- a/drivers/base/power/wakeup.c
32947 +++ b/drivers/base/power/wakeup.c
32948 @@ -29,14 +29,14 @@ bool events_check_enabled __read_mostly;
32949 * They need to be modified together atomically, so it's better to use one
32950 * atomic variable to hold them both.
32951 */
32952 -static atomic_t combined_event_count = ATOMIC_INIT(0);
32953 +static atomic_unchecked_t combined_event_count = ATOMIC_INIT(0);
32954
32955 #define IN_PROGRESS_BITS (sizeof(int) * 4)
32956 #define MAX_IN_PROGRESS ((1 << IN_PROGRESS_BITS) - 1)
32957
32958 static void split_counters(unsigned int *cnt, unsigned int *inpr)
32959 {
32960 - unsigned int comb = atomic_read(&combined_event_count);
32961 + unsigned int comb = atomic_read_unchecked(&combined_event_count);
32962
32963 *cnt = (comb >> IN_PROGRESS_BITS);
32964 *inpr = comb & MAX_IN_PROGRESS;
32965 @@ -389,7 +389,7 @@ static void wakeup_source_activate(struct wakeup_source *ws)
32966 ws->start_prevent_time = ws->last_time;
32967
32968 /* Increment the counter of events in progress. */
32969 - cec = atomic_inc_return(&combined_event_count);
32970 + cec = atomic_inc_return_unchecked(&combined_event_count);
32971
32972 trace_wakeup_source_activate(ws->name, cec);
32973 }
32974 @@ -515,7 +515,7 @@ static void wakeup_source_deactivate(struct wakeup_source *ws)
32975 * Increment the counter of registered wakeup events and decrement the
32976 * couter of wakeup events in progress simultaneously.
32977 */
32978 - cec = atomic_add_return(MAX_IN_PROGRESS, &combined_event_count);
32979 + cec = atomic_add_return_unchecked(MAX_IN_PROGRESS, &combined_event_count);
32980 trace_wakeup_source_deactivate(ws->name, cec);
32981
32982 split_counters(&cnt, &inpr);
32983 diff --git a/drivers/base/syscore.c b/drivers/base/syscore.c
32984 index e8d11b6..7b1b36f 100644
32985 --- a/drivers/base/syscore.c
32986 +++ b/drivers/base/syscore.c
32987 @@ -21,7 +21,7 @@ static DEFINE_MUTEX(syscore_ops_lock);
32988 void register_syscore_ops(struct syscore_ops *ops)
32989 {
32990 mutex_lock(&syscore_ops_lock);
32991 - list_add_tail(&ops->node, &syscore_ops_list);
32992 + pax_list_add_tail((struct list_head *)&ops->node, &syscore_ops_list);
32993 mutex_unlock(&syscore_ops_lock);
32994 }
32995 EXPORT_SYMBOL_GPL(register_syscore_ops);
32996 @@ -33,7 +33,7 @@ EXPORT_SYMBOL_GPL(register_syscore_ops);
32997 void unregister_syscore_ops(struct syscore_ops *ops)
32998 {
32999 mutex_lock(&syscore_ops_lock);
33000 - list_del(&ops->node);
33001 + pax_list_del((struct list_head *)&ops->node);
33002 mutex_unlock(&syscore_ops_lock);
33003 }
33004 EXPORT_SYMBOL_GPL(unregister_syscore_ops);
33005 diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c
33006 index ade58bc..867143d 100644
33007 --- a/drivers/block/cciss.c
33008 +++ b/drivers/block/cciss.c
33009 @@ -1196,6 +1196,8 @@ static int cciss_ioctl32_passthru(struct block_device *bdev, fmode_t mode,
33010 int err;
33011 u32 cp;
33012
33013 + memset(&arg64, 0, sizeof(arg64));
33014 +
33015 err = 0;
33016 err |=
33017 copy_from_user(&arg64.LUN_info, &arg32->LUN_info,
33018 @@ -3005,7 +3007,7 @@ static void start_io(ctlr_info_t *h)
33019 while (!list_empty(&h->reqQ)) {
33020 c = list_entry(h->reqQ.next, CommandList_struct, list);
33021 /* can't do anything if fifo is full */
33022 - if ((h->access.fifo_full(h))) {
33023 + if ((h->access->fifo_full(h))) {
33024 dev_warn(&h->pdev->dev, "fifo full\n");
33025 break;
33026 }
33027 @@ -3015,7 +3017,7 @@ static void start_io(ctlr_info_t *h)
33028 h->Qdepth--;
33029
33030 /* Tell the controller execute command */
33031 - h->access.submit_command(h, c);
33032 + h->access->submit_command(h, c);
33033
33034 /* Put job onto the completed Q */
33035 addQ(&h->cmpQ, c);
33036 @@ -3441,17 +3443,17 @@ startio:
33037
33038 static inline unsigned long get_next_completion(ctlr_info_t *h)
33039 {
33040 - return h->access.command_completed(h);
33041 + return h->access->command_completed(h);
33042 }
33043
33044 static inline int interrupt_pending(ctlr_info_t *h)
33045 {
33046 - return h->access.intr_pending(h);
33047 + return h->access->intr_pending(h);
33048 }
33049
33050 static inline long interrupt_not_for_us(ctlr_info_t *h)
33051 {
33052 - return ((h->access.intr_pending(h) == 0) ||
33053 + return ((h->access->intr_pending(h) == 0) ||
33054 (h->interrupts_enabled == 0));
33055 }
33056
33057 @@ -3484,7 +3486,7 @@ static inline u32 next_command(ctlr_info_t *h)
33058 u32 a;
33059
33060 if (unlikely(!(h->transMethod & CFGTBL_Trans_Performant)))
33061 - return h->access.command_completed(h);
33062 + return h->access->command_completed(h);
33063
33064 if ((*(h->reply_pool_head) & 1) == (h->reply_pool_wraparound)) {
33065 a = *(h->reply_pool_head); /* Next cmd in ring buffer */
33066 @@ -4041,7 +4043,7 @@ static void cciss_put_controller_into_performant_mode(ctlr_info_t *h)
33067 trans_support & CFGTBL_Trans_use_short_tags);
33068
33069 /* Change the access methods to the performant access methods */
33070 - h->access = SA5_performant_access;
33071 + h->access = &SA5_performant_access;
33072 h->transMethod = CFGTBL_Trans_Performant;
33073
33074 return;
33075 @@ -4310,7 +4312,7 @@ static int cciss_pci_init(ctlr_info_t *h)
33076 if (prod_index < 0)
33077 return -ENODEV;
33078 h->product_name = products[prod_index].product_name;
33079 - h->access = *(products[prod_index].access);
33080 + h->access = products[prod_index].access;
33081
33082 if (cciss_board_disabled(h)) {
33083 dev_warn(&h->pdev->dev, "controller appears to be disabled\n");
33084 @@ -5032,7 +5034,7 @@ reinit_after_soft_reset:
33085 }
33086
33087 /* make sure the board interrupts are off */
33088 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
33089 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
33090 rc = cciss_request_irq(h, do_cciss_msix_intr, do_cciss_intx);
33091 if (rc)
33092 goto clean2;
33093 @@ -5082,7 +5084,7 @@ reinit_after_soft_reset:
33094 * fake ones to scoop up any residual completions.
33095 */
33096 spin_lock_irqsave(&h->lock, flags);
33097 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
33098 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
33099 spin_unlock_irqrestore(&h->lock, flags);
33100 free_irq(h->intr[h->intr_mode], h);
33101 rc = cciss_request_irq(h, cciss_msix_discard_completions,
33102 @@ -5102,9 +5104,9 @@ reinit_after_soft_reset:
33103 dev_info(&h->pdev->dev, "Board READY.\n");
33104 dev_info(&h->pdev->dev,
33105 "Waiting for stale completions to drain.\n");
33106 - h->access.set_intr_mask(h, CCISS_INTR_ON);
33107 + h->access->set_intr_mask(h, CCISS_INTR_ON);
33108 msleep(10000);
33109 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
33110 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
33111
33112 rc = controller_reset_failed(h->cfgtable);
33113 if (rc)
33114 @@ -5127,7 +5129,7 @@ reinit_after_soft_reset:
33115 cciss_scsi_setup(h);
33116
33117 /* Turn the interrupts on so we can service requests */
33118 - h->access.set_intr_mask(h, CCISS_INTR_ON);
33119 + h->access->set_intr_mask(h, CCISS_INTR_ON);
33120
33121 /* Get the firmware version */
33122 inq_buff = kzalloc(sizeof(InquiryData_struct), GFP_KERNEL);
33123 @@ -5199,7 +5201,7 @@ static void cciss_shutdown(struct pci_dev *pdev)
33124 kfree(flush_buf);
33125 if (return_code != IO_OK)
33126 dev_warn(&h->pdev->dev, "Error flushing cache\n");
33127 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
33128 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
33129 free_irq(h->intr[h->intr_mode], h);
33130 }
33131
33132 diff --git a/drivers/block/cciss.h b/drivers/block/cciss.h
33133 index 7fda30e..eb5dfe0 100644
33134 --- a/drivers/block/cciss.h
33135 +++ b/drivers/block/cciss.h
33136 @@ -101,7 +101,7 @@ struct ctlr_info
33137 /* information about each logical volume */
33138 drive_info_struct *drv[CISS_MAX_LUN];
33139
33140 - struct access_method access;
33141 + struct access_method *access;
33142
33143 /* queue and queue Info */
33144 struct list_head reqQ;
33145 diff --git a/drivers/block/cpqarray.c b/drivers/block/cpqarray.c
33146 index 3f08713..56a586a 100644
33147 --- a/drivers/block/cpqarray.c
33148 +++ b/drivers/block/cpqarray.c
33149 @@ -404,7 +404,7 @@ static int cpqarray_register_ctlr(int i, struct pci_dev *pdev)
33150 if (register_blkdev(COMPAQ_SMART2_MAJOR+i, hba[i]->devname)) {
33151 goto Enomem4;
33152 }
33153 - hba[i]->access.set_intr_mask(hba[i], 0);
33154 + hba[i]->access->set_intr_mask(hba[i], 0);
33155 if (request_irq(hba[i]->intr, do_ida_intr,
33156 IRQF_DISABLED|IRQF_SHARED, hba[i]->devname, hba[i]))
33157 {
33158 @@ -459,7 +459,7 @@ static int cpqarray_register_ctlr(int i, struct pci_dev *pdev)
33159 add_timer(&hba[i]->timer);
33160
33161 /* Enable IRQ now that spinlock and rate limit timer are set up */
33162 - hba[i]->access.set_intr_mask(hba[i], FIFO_NOT_EMPTY);
33163 + hba[i]->access->set_intr_mask(hba[i], FIFO_NOT_EMPTY);
33164
33165 for(j=0; j<NWD; j++) {
33166 struct gendisk *disk = ida_gendisk[i][j];
33167 @@ -694,7 +694,7 @@ DBGINFO(
33168 for(i=0; i<NR_PRODUCTS; i++) {
33169 if (board_id == products[i].board_id) {
33170 c->product_name = products[i].product_name;
33171 - c->access = *(products[i].access);
33172 + c->access = products[i].access;
33173 break;
33174 }
33175 }
33176 @@ -792,7 +792,7 @@ static int cpqarray_eisa_detect(void)
33177 hba[ctlr]->intr = intr;
33178 sprintf(hba[ctlr]->devname, "ida%d", nr_ctlr);
33179 hba[ctlr]->product_name = products[j].product_name;
33180 - hba[ctlr]->access = *(products[j].access);
33181 + hba[ctlr]->access = products[j].access;
33182 hba[ctlr]->ctlr = ctlr;
33183 hba[ctlr]->board_id = board_id;
33184 hba[ctlr]->pci_dev = NULL; /* not PCI */
33185 @@ -980,7 +980,7 @@ static void start_io(ctlr_info_t *h)
33186
33187 while((c = h->reqQ) != NULL) {
33188 /* Can't do anything if we're busy */
33189 - if (h->access.fifo_full(h) == 0)
33190 + if (h->access->fifo_full(h) == 0)
33191 return;
33192
33193 /* Get the first entry from the request Q */
33194 @@ -988,7 +988,7 @@ static void start_io(ctlr_info_t *h)
33195 h->Qdepth--;
33196
33197 /* Tell the controller to do our bidding */
33198 - h->access.submit_command(h, c);
33199 + h->access->submit_command(h, c);
33200
33201 /* Get onto the completion Q */
33202 addQ(&h->cmpQ, c);
33203 @@ -1050,7 +1050,7 @@ static irqreturn_t do_ida_intr(int irq, void *dev_id)
33204 unsigned long flags;
33205 __u32 a,a1;
33206
33207 - istat = h->access.intr_pending(h);
33208 + istat = h->access->intr_pending(h);
33209 /* Is this interrupt for us? */
33210 if (istat == 0)
33211 return IRQ_NONE;
33212 @@ -1061,7 +1061,7 @@ static irqreturn_t do_ida_intr(int irq, void *dev_id)
33213 */
33214 spin_lock_irqsave(IDA_LOCK(h->ctlr), flags);
33215 if (istat & FIFO_NOT_EMPTY) {
33216 - while((a = h->access.command_completed(h))) {
33217 + while((a = h->access->command_completed(h))) {
33218 a1 = a; a &= ~3;
33219 if ((c = h->cmpQ) == NULL)
33220 {
33221 @@ -1449,11 +1449,11 @@ static int sendcmd(
33222 /*
33223 * Disable interrupt
33224 */
33225 - info_p->access.set_intr_mask(info_p, 0);
33226 + info_p->access->set_intr_mask(info_p, 0);
33227 /* Make sure there is room in the command FIFO */
33228 /* Actually it should be completely empty at this time. */
33229 for (i = 200000; i > 0; i--) {
33230 - temp = info_p->access.fifo_full(info_p);
33231 + temp = info_p->access->fifo_full(info_p);
33232 if (temp != 0) {
33233 break;
33234 }
33235 @@ -1466,7 +1466,7 @@ DBG(
33236 /*
33237 * Send the cmd
33238 */
33239 - info_p->access.submit_command(info_p, c);
33240 + info_p->access->submit_command(info_p, c);
33241 complete = pollcomplete(ctlr);
33242
33243 pci_unmap_single(info_p->pci_dev, (dma_addr_t) c->req.sg[0].addr,
33244 @@ -1549,9 +1549,9 @@ static int revalidate_allvol(ctlr_info_t *host)
33245 * we check the new geometry. Then turn interrupts back on when
33246 * we're done.
33247 */
33248 - host->access.set_intr_mask(host, 0);
33249 + host->access->set_intr_mask(host, 0);
33250 getgeometry(ctlr);
33251 - host->access.set_intr_mask(host, FIFO_NOT_EMPTY);
33252 + host->access->set_intr_mask(host, FIFO_NOT_EMPTY);
33253
33254 for(i=0; i<NWD; i++) {
33255 struct gendisk *disk = ida_gendisk[ctlr][i];
33256 @@ -1591,7 +1591,7 @@ static int pollcomplete(int ctlr)
33257 /* Wait (up to 2 seconds) for a command to complete */
33258
33259 for (i = 200000; i > 0; i--) {
33260 - done = hba[ctlr]->access.command_completed(hba[ctlr]);
33261 + done = hba[ctlr]->access->command_completed(hba[ctlr]);
33262 if (done == 0) {
33263 udelay(10); /* a short fixed delay */
33264 } else
33265 diff --git a/drivers/block/cpqarray.h b/drivers/block/cpqarray.h
33266 index be73e9d..7fbf140 100644
33267 --- a/drivers/block/cpqarray.h
33268 +++ b/drivers/block/cpqarray.h
33269 @@ -99,7 +99,7 @@ struct ctlr_info {
33270 drv_info_t drv[NWD];
33271 struct proc_dir_entry *proc;
33272
33273 - struct access_method access;
33274 + struct access_method *access;
33275
33276 cmdlist_t *reqQ;
33277 cmdlist_t *cmpQ;
33278 diff --git a/drivers/block/drbd/drbd_int.h b/drivers/block/drbd/drbd_int.h
33279 index 6b51afa..17e1191 100644
33280 --- a/drivers/block/drbd/drbd_int.h
33281 +++ b/drivers/block/drbd/drbd_int.h
33282 @@ -582,7 +582,7 @@ struct drbd_epoch {
33283 struct drbd_tconn *tconn;
33284 struct list_head list;
33285 unsigned int barrier_nr;
33286 - atomic_t epoch_size; /* increased on every request added. */
33287 + atomic_unchecked_t epoch_size; /* increased on every request added. */
33288 atomic_t active; /* increased on every req. added, and dec on every finished. */
33289 unsigned long flags;
33290 };
33291 @@ -1011,7 +1011,7 @@ struct drbd_conf {
33292 int al_tr_cycle;
33293 int al_tr_pos; /* position of the next transaction in the journal */
33294 wait_queue_head_t seq_wait;
33295 - atomic_t packet_seq;
33296 + atomic_unchecked_t packet_seq;
33297 unsigned int peer_seq;
33298 spinlock_t peer_seq_lock;
33299 unsigned int minor;
33300 @@ -1527,7 +1527,7 @@ static inline int drbd_setsockopt(struct socket *sock, int level, int optname,
33301 char __user *uoptval;
33302 int err;
33303
33304 - uoptval = (char __user __force *)optval;
33305 + uoptval = (char __force_user *)optval;
33306
33307 set_fs(KERNEL_DS);
33308 if (level == SOL_SOCKET)
33309 diff --git a/drivers/block/drbd/drbd_main.c b/drivers/block/drbd/drbd_main.c
33310 index 8c13eeb..217adee 100644
33311 --- a/drivers/block/drbd/drbd_main.c
33312 +++ b/drivers/block/drbd/drbd_main.c
33313 @@ -1317,7 +1317,7 @@ static int _drbd_send_ack(struct drbd_conf *mdev, enum drbd_packet cmd,
33314 p->sector = sector;
33315 p->block_id = block_id;
33316 p->blksize = blksize;
33317 - p->seq_num = cpu_to_be32(atomic_inc_return(&mdev->packet_seq));
33318 + p->seq_num = cpu_to_be32(atomic_inc_return_unchecked(&mdev->packet_seq));
33319 return drbd_send_command(mdev, sock, cmd, sizeof(*p), NULL, 0);
33320 }
33321
33322 @@ -1619,7 +1619,7 @@ int drbd_send_dblock(struct drbd_conf *mdev, struct drbd_request *req)
33323 return -EIO;
33324 p->sector = cpu_to_be64(req->i.sector);
33325 p->block_id = (unsigned long)req;
33326 - p->seq_num = cpu_to_be32(atomic_inc_return(&mdev->packet_seq));
33327 + p->seq_num = cpu_to_be32(atomic_inc_return_unchecked(&mdev->packet_seq));
33328 dp_flags = bio_flags_to_wire(mdev, req->master_bio->bi_rw);
33329 if (mdev->state.conn >= C_SYNC_SOURCE &&
33330 mdev->state.conn <= C_PAUSED_SYNC_T)
33331 @@ -2574,8 +2574,8 @@ void conn_destroy(struct kref *kref)
33332 {
33333 struct drbd_tconn *tconn = container_of(kref, struct drbd_tconn, kref);
33334
33335 - if (atomic_read(&tconn->current_epoch->epoch_size) != 0)
33336 - conn_err(tconn, "epoch_size:%d\n", atomic_read(&tconn->current_epoch->epoch_size));
33337 + if (atomic_read_unchecked(&tconn->current_epoch->epoch_size) != 0)
33338 + conn_err(tconn, "epoch_size:%d\n", atomic_read_unchecked(&tconn->current_epoch->epoch_size));
33339 kfree(tconn->current_epoch);
33340
33341 idr_destroy(&tconn->volumes);
33342 diff --git a/drivers/block/drbd/drbd_receiver.c b/drivers/block/drbd/drbd_receiver.c
33343 index a9eccfc..f5efe87 100644
33344 --- a/drivers/block/drbd/drbd_receiver.c
33345 +++ b/drivers/block/drbd/drbd_receiver.c
33346 @@ -833,7 +833,7 @@ int drbd_connected(struct drbd_conf *mdev)
33347 {
33348 int err;
33349
33350 - atomic_set(&mdev->packet_seq, 0);
33351 + atomic_set_unchecked(&mdev->packet_seq, 0);
33352 mdev->peer_seq = 0;
33353
33354 mdev->state_mutex = mdev->tconn->agreed_pro_version < 100 ?
33355 @@ -1191,7 +1191,7 @@ static enum finish_epoch drbd_may_finish_epoch(struct drbd_tconn *tconn,
33356 do {
33357 next_epoch = NULL;
33358
33359 - epoch_size = atomic_read(&epoch->epoch_size);
33360 + epoch_size = atomic_read_unchecked(&epoch->epoch_size);
33361
33362 switch (ev & ~EV_CLEANUP) {
33363 case EV_PUT:
33364 @@ -1231,7 +1231,7 @@ static enum finish_epoch drbd_may_finish_epoch(struct drbd_tconn *tconn,
33365 rv = FE_DESTROYED;
33366 } else {
33367 epoch->flags = 0;
33368 - atomic_set(&epoch->epoch_size, 0);
33369 + atomic_set_unchecked(&epoch->epoch_size, 0);
33370 /* atomic_set(&epoch->active, 0); is already zero */
33371 if (rv == FE_STILL_LIVE)
33372 rv = FE_RECYCLED;
33373 @@ -1449,7 +1449,7 @@ static int receive_Barrier(struct drbd_tconn *tconn, struct packet_info *pi)
33374 conn_wait_active_ee_empty(tconn);
33375 drbd_flush(tconn);
33376
33377 - if (atomic_read(&tconn->current_epoch->epoch_size)) {
33378 + if (atomic_read_unchecked(&tconn->current_epoch->epoch_size)) {
33379 epoch = kmalloc(sizeof(struct drbd_epoch), GFP_NOIO);
33380 if (epoch)
33381 break;
33382 @@ -1462,11 +1462,11 @@ static int receive_Barrier(struct drbd_tconn *tconn, struct packet_info *pi)
33383 }
33384
33385 epoch->flags = 0;
33386 - atomic_set(&epoch->epoch_size, 0);
33387 + atomic_set_unchecked(&epoch->epoch_size, 0);
33388 atomic_set(&epoch->active, 0);
33389
33390 spin_lock(&tconn->epoch_lock);
33391 - if (atomic_read(&tconn->current_epoch->epoch_size)) {
33392 + if (atomic_read_unchecked(&tconn->current_epoch->epoch_size)) {
33393 list_add(&epoch->list, &tconn->current_epoch->list);
33394 tconn->current_epoch = epoch;
33395 tconn->epochs++;
33396 @@ -2170,7 +2170,7 @@ static int receive_Data(struct drbd_tconn *tconn, struct packet_info *pi)
33397
33398 err = wait_for_and_update_peer_seq(mdev, peer_seq);
33399 drbd_send_ack_dp(mdev, P_NEG_ACK, p, pi->size);
33400 - atomic_inc(&tconn->current_epoch->epoch_size);
33401 + atomic_inc_unchecked(&tconn->current_epoch->epoch_size);
33402 err2 = drbd_drain_block(mdev, pi->size);
33403 if (!err)
33404 err = err2;
33405 @@ -2204,7 +2204,7 @@ static int receive_Data(struct drbd_tconn *tconn, struct packet_info *pi)
33406
33407 spin_lock(&tconn->epoch_lock);
33408 peer_req->epoch = tconn->current_epoch;
33409 - atomic_inc(&peer_req->epoch->epoch_size);
33410 + atomic_inc_unchecked(&peer_req->epoch->epoch_size);
33411 atomic_inc(&peer_req->epoch->active);
33412 spin_unlock(&tconn->epoch_lock);
33413
33414 @@ -4346,7 +4346,7 @@ struct data_cmd {
33415 int expect_payload;
33416 size_t pkt_size;
33417 int (*fn)(struct drbd_tconn *, struct packet_info *);
33418 -};
33419 +} __do_const;
33420
33421 static struct data_cmd drbd_cmd_handler[] = {
33422 [P_DATA] = { 1, sizeof(struct p_data), receive_Data },
33423 @@ -4466,7 +4466,7 @@ static void conn_disconnect(struct drbd_tconn *tconn)
33424 if (!list_empty(&tconn->current_epoch->list))
33425 conn_err(tconn, "ASSERTION FAILED: tconn->current_epoch->list not empty\n");
33426 /* ok, no more ee's on the fly, it is safe to reset the epoch_size */
33427 - atomic_set(&tconn->current_epoch->epoch_size, 0);
33428 + atomic_set_unchecked(&tconn->current_epoch->epoch_size, 0);
33429 tconn->send.seen_any_write_yet = false;
33430
33431 conn_info(tconn, "Connection closed\n");
33432 @@ -5222,7 +5222,7 @@ static int tconn_finish_peer_reqs(struct drbd_tconn *tconn)
33433 struct asender_cmd {
33434 size_t pkt_size;
33435 int (*fn)(struct drbd_tconn *tconn, struct packet_info *);
33436 -};
33437 +} __do_const;
33438
33439 static struct asender_cmd asender_tbl[] = {
33440 [P_PING] = { 0, got_Ping },
33441 diff --git a/drivers/block/loop.c b/drivers/block/loop.c
33442 index 8bc6d39..f492563 100644
33443 --- a/drivers/block/loop.c
33444 +++ b/drivers/block/loop.c
33445 @@ -226,7 +226,7 @@ static int __do_lo_send_write(struct file *file,
33446 mm_segment_t old_fs = get_fs();
33447
33448 set_fs(get_ds());
33449 - bw = file->f_op->write(file, buf, len, &pos);
33450 + bw = file->f_op->write(file, (const char __force_user *)buf, len, &pos);
33451 set_fs(old_fs);
33452 if (likely(bw == len))
33453 return 0;
33454 diff --git a/drivers/cdrom/cdrom.c b/drivers/cdrom/cdrom.c
33455 index d620b44..587561e 100644
33456 --- a/drivers/cdrom/cdrom.c
33457 +++ b/drivers/cdrom/cdrom.c
33458 @@ -416,7 +416,6 @@ int register_cdrom(struct cdrom_device_info *cdi)
33459 ENSURE(reset, CDC_RESET);
33460 ENSURE(generic_packet, CDC_GENERIC_PACKET);
33461 cdi->mc_flags = 0;
33462 - cdo->n_minors = 0;
33463 cdi->options = CDO_USE_FFLAGS;
33464
33465 if (autoclose==1 && CDROM_CAN(CDC_CLOSE_TRAY))
33466 @@ -436,8 +435,11 @@ int register_cdrom(struct cdrom_device_info *cdi)
33467 else
33468 cdi->cdda_method = CDDA_OLD;
33469
33470 - if (!cdo->generic_packet)
33471 - cdo->generic_packet = cdrom_dummy_generic_packet;
33472 + if (!cdo->generic_packet) {
33473 + pax_open_kernel();
33474 + *(void **)&cdo->generic_packet = cdrom_dummy_generic_packet;
33475 + pax_close_kernel();
33476 + }
33477
33478 cdinfo(CD_REG_UNREG, "drive \"/dev/%s\" registered\n", cdi->name);
33479 mutex_lock(&cdrom_mutex);
33480 @@ -458,7 +460,6 @@ void unregister_cdrom(struct cdrom_device_info *cdi)
33481 if (cdi->exit)
33482 cdi->exit(cdi);
33483
33484 - cdi->ops->n_minors--;
33485 cdinfo(CD_REG_UNREG, "drive \"/dev/%s\" unregistered\n", cdi->name);
33486 }
33487
33488 diff --git a/drivers/cdrom/gdrom.c b/drivers/cdrom/gdrom.c
33489 index d59cdcb..11afddf 100644
33490 --- a/drivers/cdrom/gdrom.c
33491 +++ b/drivers/cdrom/gdrom.c
33492 @@ -491,7 +491,6 @@ static struct cdrom_device_ops gdrom_ops = {
33493 .audio_ioctl = gdrom_audio_ioctl,
33494 .capability = CDC_MULTI_SESSION | CDC_MEDIA_CHANGED |
33495 CDC_RESET | CDC_DRIVE_STATUS | CDC_CD_R,
33496 - .n_minors = 1,
33497 };
33498
33499 static int gdrom_bdops_open(struct block_device *bdev, fmode_t mode)
33500 diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig
33501 index 72bedad..8181ce1 100644
33502 --- a/drivers/char/Kconfig
33503 +++ b/drivers/char/Kconfig
33504 @@ -8,7 +8,8 @@ source "drivers/tty/Kconfig"
33505
33506 config DEVKMEM
33507 bool "/dev/kmem virtual device support"
33508 - default y
33509 + default n
33510 + depends on !GRKERNSEC_KMEM
33511 help
33512 Say Y here if you want to support the /dev/kmem device. The
33513 /dev/kmem device is rarely used, but can be used for certain
33514 @@ -581,6 +582,7 @@ config DEVPORT
33515 bool
33516 depends on !M68K
33517 depends on ISA || PCI
33518 + depends on !GRKERNSEC_KMEM
33519 default y
33520
33521 source "drivers/s390/char/Kconfig"
33522 diff --git a/drivers/char/agp/frontend.c b/drivers/char/agp/frontend.c
33523 index 2e04433..22afc64 100644
33524 --- a/drivers/char/agp/frontend.c
33525 +++ b/drivers/char/agp/frontend.c
33526 @@ -817,7 +817,7 @@ static int agpioc_reserve_wrap(struct agp_file_private *priv, void __user *arg)
33527 if (copy_from_user(&reserve, arg, sizeof(struct agp_region)))
33528 return -EFAULT;
33529
33530 - if ((unsigned) reserve.seg_count >= ~0U/sizeof(struct agp_segment))
33531 + if ((unsigned) reserve.seg_count >= ~0U/sizeof(struct agp_segment_priv))
33532 return -EFAULT;
33533
33534 client = agp_find_client_by_pid(reserve.pid);
33535 diff --git a/drivers/char/genrtc.c b/drivers/char/genrtc.c
33536 index 21cb980..f15107c 100644
33537 --- a/drivers/char/genrtc.c
33538 +++ b/drivers/char/genrtc.c
33539 @@ -272,6 +272,7 @@ static int gen_rtc_ioctl(struct file *file,
33540 switch (cmd) {
33541
33542 case RTC_PLL_GET:
33543 + memset(&pll, 0, sizeof(pll));
33544 if (get_rtc_pll(&pll))
33545 return -EINVAL;
33546 else
33547 diff --git a/drivers/char/hpet.c b/drivers/char/hpet.c
33548 index fe6d4be..89f32100 100644
33549 --- a/drivers/char/hpet.c
33550 +++ b/drivers/char/hpet.c
33551 @@ -571,7 +571,7 @@ static inline unsigned long hpet_time_div(struct hpets *hpets,
33552 }
33553
33554 static int
33555 -hpet_ioctl_common(struct hpet_dev *devp, int cmd, unsigned long arg,
33556 +hpet_ioctl_common(struct hpet_dev *devp, unsigned int cmd, unsigned long arg,
33557 struct hpet_info *info)
33558 {
33559 struct hpet_timer __iomem *timer;
33560 diff --git a/drivers/char/ipmi/ipmi_msghandler.c b/drivers/char/ipmi/ipmi_msghandler.c
33561 index 053201b0..8335cce 100644
33562 --- a/drivers/char/ipmi/ipmi_msghandler.c
33563 +++ b/drivers/char/ipmi/ipmi_msghandler.c
33564 @@ -420,7 +420,7 @@ struct ipmi_smi {
33565 struct proc_dir_entry *proc_dir;
33566 char proc_dir_name[10];
33567
33568 - atomic_t stats[IPMI_NUM_STATS];
33569 + atomic_unchecked_t stats[IPMI_NUM_STATS];
33570
33571 /*
33572 * run_to_completion duplicate of smb_info, smi_info
33573 @@ -453,9 +453,9 @@ static DEFINE_MUTEX(smi_watchers_mutex);
33574
33575
33576 #define ipmi_inc_stat(intf, stat) \
33577 - atomic_inc(&(intf)->stats[IPMI_STAT_ ## stat])
33578 + atomic_inc_unchecked(&(intf)->stats[IPMI_STAT_ ## stat])
33579 #define ipmi_get_stat(intf, stat) \
33580 - ((unsigned int) atomic_read(&(intf)->stats[IPMI_STAT_ ## stat]))
33581 + ((unsigned int) atomic_read_unchecked(&(intf)->stats[IPMI_STAT_ ## stat]))
33582
33583 static int is_lan_addr(struct ipmi_addr *addr)
33584 {
33585 @@ -2884,7 +2884,7 @@ int ipmi_register_smi(struct ipmi_smi_handlers *handlers,
33586 INIT_LIST_HEAD(&intf->cmd_rcvrs);
33587 init_waitqueue_head(&intf->waitq);
33588 for (i = 0; i < IPMI_NUM_STATS; i++)
33589 - atomic_set(&intf->stats[i], 0);
33590 + atomic_set_unchecked(&intf->stats[i], 0);
33591
33592 intf->proc_dir = NULL;
33593
33594 diff --git a/drivers/char/ipmi/ipmi_si_intf.c b/drivers/char/ipmi/ipmi_si_intf.c
33595 index 1c7fdcd..4899100 100644
33596 --- a/drivers/char/ipmi/ipmi_si_intf.c
33597 +++ b/drivers/char/ipmi/ipmi_si_intf.c
33598 @@ -275,7 +275,7 @@ struct smi_info {
33599 unsigned char slave_addr;
33600
33601 /* Counters and things for the proc filesystem. */
33602 - atomic_t stats[SI_NUM_STATS];
33603 + atomic_unchecked_t stats[SI_NUM_STATS];
33604
33605 struct task_struct *thread;
33606
33607 @@ -284,9 +284,9 @@ struct smi_info {
33608 };
33609
33610 #define smi_inc_stat(smi, stat) \
33611 - atomic_inc(&(smi)->stats[SI_STAT_ ## stat])
33612 + atomic_inc_unchecked(&(smi)->stats[SI_STAT_ ## stat])
33613 #define smi_get_stat(smi, stat) \
33614 - ((unsigned int) atomic_read(&(smi)->stats[SI_STAT_ ## stat]))
33615 + ((unsigned int) atomic_read_unchecked(&(smi)->stats[SI_STAT_ ## stat]))
33616
33617 #define SI_MAX_PARMS 4
33618
33619 @@ -3225,7 +3225,7 @@ static int try_smi_init(struct smi_info *new_smi)
33620 atomic_set(&new_smi->req_events, 0);
33621 new_smi->run_to_completion = 0;
33622 for (i = 0; i < SI_NUM_STATS; i++)
33623 - atomic_set(&new_smi->stats[i], 0);
33624 + atomic_set_unchecked(&new_smi->stats[i], 0);
33625
33626 new_smi->interrupt_disabled = 1;
33627 atomic_set(&new_smi->stop_operation, 0);
33628 diff --git a/drivers/char/mem.c b/drivers/char/mem.c
33629 index c6fa3bc..4ca3e42 100644
33630 --- a/drivers/char/mem.c
33631 +++ b/drivers/char/mem.c
33632 @@ -18,6 +18,7 @@
33633 #include <linux/raw.h>
33634 #include <linux/tty.h>
33635 #include <linux/capability.h>
33636 +#include <linux/security.h>
33637 #include <linux/ptrace.h>
33638 #include <linux/device.h>
33639 #include <linux/highmem.h>
33640 @@ -37,6 +38,10 @@
33641
33642 #define DEVPORT_MINOR 4
33643
33644 +#if defined(CONFIG_GRKERNSEC) && !defined(CONFIG_GRKERNSEC_NO_RBAC)
33645 +extern const struct file_operations grsec_fops;
33646 +#endif
33647 +
33648 static inline unsigned long size_inside_page(unsigned long start,
33649 unsigned long size)
33650 {
33651 @@ -68,9 +73,13 @@ static inline int range_is_allowed(unsigned long pfn, unsigned long size)
33652
33653 while (cursor < to) {
33654 if (!devmem_is_allowed(pfn)) {
33655 +#ifdef CONFIG_GRKERNSEC_KMEM
33656 + gr_handle_mem_readwrite(from, to);
33657 +#else
33658 printk(KERN_INFO
33659 "Program %s tried to access /dev/mem between %Lx->%Lx.\n",
33660 current->comm, from, to);
33661 +#endif
33662 return 0;
33663 }
33664 cursor += PAGE_SIZE;
33665 @@ -78,6 +87,11 @@ static inline int range_is_allowed(unsigned long pfn, unsigned long size)
33666 }
33667 return 1;
33668 }
33669 +#elif defined(CONFIG_GRKERNSEC_KMEM)
33670 +static inline int range_is_allowed(unsigned long pfn, unsigned long size)
33671 +{
33672 + return 0;
33673 +}
33674 #else
33675 static inline int range_is_allowed(unsigned long pfn, unsigned long size)
33676 {
33677 @@ -120,6 +134,7 @@ static ssize_t read_mem(struct file *file, char __user *buf,
33678
33679 while (count > 0) {
33680 unsigned long remaining;
33681 + char *temp;
33682
33683 sz = size_inside_page(p, count);
33684
33685 @@ -135,7 +150,23 @@ static ssize_t read_mem(struct file *file, char __user *buf,
33686 if (!ptr)
33687 return -EFAULT;
33688
33689 - remaining = copy_to_user(buf, ptr, sz);
33690 +#ifdef CONFIG_PAX_USERCOPY
33691 + temp = kmalloc(sz, GFP_KERNEL|GFP_USERCOPY);
33692 + if (!temp) {
33693 + unxlate_dev_mem_ptr(p, ptr);
33694 + return -ENOMEM;
33695 + }
33696 + memcpy(temp, ptr, sz);
33697 +#else
33698 + temp = ptr;
33699 +#endif
33700 +
33701 + remaining = copy_to_user(buf, temp, sz);
33702 +
33703 +#ifdef CONFIG_PAX_USERCOPY
33704 + kfree(temp);
33705 +#endif
33706 +
33707 unxlate_dev_mem_ptr(p, ptr);
33708 if (remaining)
33709 return -EFAULT;
33710 @@ -398,9 +429,8 @@ static ssize_t read_kmem(struct file *file, char __user *buf,
33711 size_t count, loff_t *ppos)
33712 {
33713 unsigned long p = *ppos;
33714 - ssize_t low_count, read, sz;
33715 + ssize_t low_count, read, sz, err = 0;
33716 char * kbuf; /* k-addr because vread() takes vmlist_lock rwlock */
33717 - int err = 0;
33718
33719 read = 0;
33720 if (p < (unsigned long) high_memory) {
33721 @@ -422,6 +452,8 @@ static ssize_t read_kmem(struct file *file, char __user *buf,
33722 }
33723 #endif
33724 while (low_count > 0) {
33725 + char *temp;
33726 +
33727 sz = size_inside_page(p, low_count);
33728
33729 /*
33730 @@ -431,7 +463,22 @@ static ssize_t read_kmem(struct file *file, char __user *buf,
33731 */
33732 kbuf = xlate_dev_kmem_ptr((char *)p);
33733
33734 - if (copy_to_user(buf, kbuf, sz))
33735 +#ifdef CONFIG_PAX_USERCOPY
33736 + temp = kmalloc(sz, GFP_KERNEL|GFP_USERCOPY);
33737 + if (!temp)
33738 + return -ENOMEM;
33739 + memcpy(temp, kbuf, sz);
33740 +#else
33741 + temp = kbuf;
33742 +#endif
33743 +
33744 + err = copy_to_user(buf, temp, sz);
33745 +
33746 +#ifdef CONFIG_PAX_USERCOPY
33747 + kfree(temp);
33748 +#endif
33749 +
33750 + if (err)
33751 return -EFAULT;
33752 buf += sz;
33753 p += sz;
33754 @@ -833,6 +880,9 @@ static const struct memdev {
33755 #ifdef CONFIG_CRASH_DUMP
33756 [12] = { "oldmem", 0, &oldmem_fops, NULL },
33757 #endif
33758 +#if defined(CONFIG_GRKERNSEC) && !defined(CONFIG_GRKERNSEC_NO_RBAC)
33759 + [13] = { "grsec",S_IRUSR | S_IWUGO, &grsec_fops, NULL },
33760 +#endif
33761 };
33762
33763 static int memory_open(struct inode *inode, struct file *filp)
33764 diff --git a/drivers/char/nvram.c b/drivers/char/nvram.c
33765 index 9df78e2..01ba9ae 100644
33766 --- a/drivers/char/nvram.c
33767 +++ b/drivers/char/nvram.c
33768 @@ -247,7 +247,7 @@ static ssize_t nvram_read(struct file *file, char __user *buf,
33769
33770 spin_unlock_irq(&rtc_lock);
33771
33772 - if (copy_to_user(buf, contents, tmp - contents))
33773 + if (tmp - contents > sizeof(contents) || copy_to_user(buf, contents, tmp - contents))
33774 return -EFAULT;
33775
33776 *ppos = i;
33777 diff --git a/drivers/char/pcmcia/synclink_cs.c b/drivers/char/pcmcia/synclink_cs.c
33778 index b66eaa0..2619d1b 100644
33779 --- a/drivers/char/pcmcia/synclink_cs.c
33780 +++ b/drivers/char/pcmcia/synclink_cs.c
33781 @@ -2348,9 +2348,9 @@ static void mgslpc_close(struct tty_struct *tty, struct file * filp)
33782
33783 if (debug_level >= DEBUG_LEVEL_INFO)
33784 printk("%s(%d):mgslpc_close(%s) entry, count=%d\n",
33785 - __FILE__,__LINE__, info->device_name, port->count);
33786 + __FILE__,__LINE__, info->device_name, atomic_read(&port->count));
33787
33788 - WARN_ON(!port->count);
33789 + WARN_ON(!atomic_read(&port->count));
33790
33791 if (tty_port_close_start(port, tty, filp) == 0)
33792 goto cleanup;
33793 @@ -2368,7 +2368,7 @@ static void mgslpc_close(struct tty_struct *tty, struct file * filp)
33794 cleanup:
33795 if (debug_level >= DEBUG_LEVEL_INFO)
33796 printk("%s(%d):mgslpc_close(%s) exit, count=%d\n", __FILE__,__LINE__,
33797 - tty->driver->name, port->count);
33798 + tty->driver->name, atomic_read(&port->count));
33799 }
33800
33801 /* Wait until the transmitter is empty.
33802 @@ -2510,7 +2510,7 @@ static int mgslpc_open(struct tty_struct *tty, struct file * filp)
33803
33804 if (debug_level >= DEBUG_LEVEL_INFO)
33805 printk("%s(%d):mgslpc_open(%s), old ref count = %d\n",
33806 - __FILE__,__LINE__,tty->driver->name, port->count);
33807 + __FILE__,__LINE__,tty->driver->name, atomic_read(&port->count));
33808
33809 /* If port is closing, signal caller to try again */
33810 if (tty_hung_up_p(filp) || port->flags & ASYNC_CLOSING){
33811 @@ -2530,11 +2530,11 @@ static int mgslpc_open(struct tty_struct *tty, struct file * filp)
33812 goto cleanup;
33813 }
33814 spin_lock(&port->lock);
33815 - port->count++;
33816 + atomic_inc(&port->count);
33817 spin_unlock(&port->lock);
33818 spin_unlock_irqrestore(&info->netlock, flags);
33819
33820 - if (port->count == 1) {
33821 + if (atomic_read(&port->count) == 1) {
33822 /* 1st open on this device, init hardware */
33823 retval = startup(info, tty);
33824 if (retval < 0)
33825 @@ -3889,7 +3889,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
33826 unsigned short new_crctype;
33827
33828 /* return error if TTY interface open */
33829 - if (info->port.count)
33830 + if (atomic_read(&info->port.count))
33831 return -EBUSY;
33832
33833 switch (encoding)
33834 @@ -3992,7 +3992,7 @@ static int hdlcdev_open(struct net_device *dev)
33835
33836 /* arbitrate between network and tty opens */
33837 spin_lock_irqsave(&info->netlock, flags);
33838 - if (info->port.count != 0 || info->netcount != 0) {
33839 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
33840 printk(KERN_WARNING "%s: hdlc_open returning busy\n", dev->name);
33841 spin_unlock_irqrestore(&info->netlock, flags);
33842 return -EBUSY;
33843 @@ -4081,7 +4081,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
33844 printk("%s:hdlcdev_ioctl(%s)\n",__FILE__,dev->name);
33845
33846 /* return error if TTY interface open */
33847 - if (info->port.count)
33848 + if (atomic_read(&info->port.count))
33849 return -EBUSY;
33850
33851 if (cmd != SIOCWANDEV)
33852 diff --git a/drivers/char/random.c b/drivers/char/random.c
33853 index 57d4b15..253207b 100644
33854 --- a/drivers/char/random.c
33855 +++ b/drivers/char/random.c
33856 @@ -272,8 +272,13 @@
33857 /*
33858 * Configuration information
33859 */
33860 +#ifdef CONFIG_GRKERNSEC_RANDNET
33861 +#define INPUT_POOL_WORDS 512
33862 +#define OUTPUT_POOL_WORDS 128
33863 +#else
33864 #define INPUT_POOL_WORDS 128
33865 #define OUTPUT_POOL_WORDS 32
33866 +#endif
33867 #define SEC_XFER_SIZE 512
33868 #define EXTRACT_SIZE 10
33869
33870 @@ -313,10 +318,17 @@ static struct poolinfo {
33871 int poolwords;
33872 int tap1, tap2, tap3, tap4, tap5;
33873 } poolinfo_table[] = {
33874 +#ifdef CONFIG_GRKERNSEC_RANDNET
33875 + /* x^512 + x^411 + x^308 + x^208 +x^104 + x + 1 -- 225 */
33876 + { 512, 411, 308, 208, 104, 1 },
33877 + /* x^128 + x^103 + x^76 + x^51 + x^25 + x + 1 -- 105 */
33878 + { 128, 103, 76, 51, 25, 1 },
33879 +#else
33880 /* x^128 + x^103 + x^76 + x^51 +x^25 + x + 1 -- 105 */
33881 { 128, 103, 76, 51, 25, 1 },
33882 /* x^32 + x^26 + x^20 + x^14 + x^7 + x + 1 -- 15 */
33883 { 32, 26, 20, 14, 7, 1 },
33884 +#endif
33885 #if 0
33886 /* x^2048 + x^1638 + x^1231 + x^819 + x^411 + x + 1 -- 115 */
33887 { 2048, 1638, 1231, 819, 411, 1 },
33888 @@ -524,8 +536,8 @@ static void _mix_pool_bytes(struct entropy_store *r, const void *in,
33889 input_rotate += i ? 7 : 14;
33890 }
33891
33892 - ACCESS_ONCE(r->input_rotate) = input_rotate;
33893 - ACCESS_ONCE(r->add_ptr) = i;
33894 + ACCESS_ONCE_RW(r->input_rotate) = input_rotate;
33895 + ACCESS_ONCE_RW(r->add_ptr) = i;
33896 smp_wmb();
33897
33898 if (out)
33899 @@ -1024,7 +1036,7 @@ static ssize_t extract_entropy_user(struct entropy_store *r, void __user *buf,
33900
33901 extract_buf(r, tmp);
33902 i = min_t(int, nbytes, EXTRACT_SIZE);
33903 - if (copy_to_user(buf, tmp, i)) {
33904 + if (i > sizeof(tmp) || copy_to_user(buf, tmp, i)) {
33905 ret = -EFAULT;
33906 break;
33907 }
33908 @@ -1360,7 +1372,7 @@ EXPORT_SYMBOL(generate_random_uuid);
33909 #include <linux/sysctl.h>
33910
33911 static int min_read_thresh = 8, min_write_thresh;
33912 -static int max_read_thresh = INPUT_POOL_WORDS * 32;
33913 +static int max_read_thresh = OUTPUT_POOL_WORDS * 32;
33914 static int max_write_thresh = INPUT_POOL_WORDS * 32;
33915 static char sysctl_bootid[16];
33916
33917 @@ -1376,7 +1388,7 @@ static char sysctl_bootid[16];
33918 static int proc_do_uuid(ctl_table *table, int write,
33919 void __user *buffer, size_t *lenp, loff_t *ppos)
33920 {
33921 - ctl_table fake_table;
33922 + ctl_table_no_const fake_table;
33923 unsigned char buf[64], tmp_uuid[16], *uuid;
33924
33925 uuid = table->data;
33926 diff --git a/drivers/char/sonypi.c b/drivers/char/sonypi.c
33927 index d780295..b29f3a8 100644
33928 --- a/drivers/char/sonypi.c
33929 +++ b/drivers/char/sonypi.c
33930 @@ -54,6 +54,7 @@
33931
33932 #include <asm/uaccess.h>
33933 #include <asm/io.h>
33934 +#include <asm/local.h>
33935
33936 #include <linux/sonypi.h>
33937
33938 @@ -490,7 +491,7 @@ static struct sonypi_device {
33939 spinlock_t fifo_lock;
33940 wait_queue_head_t fifo_proc_list;
33941 struct fasync_struct *fifo_async;
33942 - int open_count;
33943 + local_t open_count;
33944 int model;
33945 struct input_dev *input_jog_dev;
33946 struct input_dev *input_key_dev;
33947 @@ -897,7 +898,7 @@ static int sonypi_misc_fasync(int fd, struct file *filp, int on)
33948 static int sonypi_misc_release(struct inode *inode, struct file *file)
33949 {
33950 mutex_lock(&sonypi_device.lock);
33951 - sonypi_device.open_count--;
33952 + local_dec(&sonypi_device.open_count);
33953 mutex_unlock(&sonypi_device.lock);
33954 return 0;
33955 }
33956 @@ -906,9 +907,9 @@ static int sonypi_misc_open(struct inode *inode, struct file *file)
33957 {
33958 mutex_lock(&sonypi_device.lock);
33959 /* Flush input queue on first open */
33960 - if (!sonypi_device.open_count)
33961 + if (!local_read(&sonypi_device.open_count))
33962 kfifo_reset(&sonypi_device.fifo);
33963 - sonypi_device.open_count++;
33964 + local_inc(&sonypi_device.open_count);
33965 mutex_unlock(&sonypi_device.lock);
33966
33967 return 0;
33968 diff --git a/drivers/char/tpm/tpm.c b/drivers/char/tpm/tpm.c
33969 index 93211df..c7805f7 100644
33970 --- a/drivers/char/tpm/tpm.c
33971 +++ b/drivers/char/tpm/tpm.c
33972 @@ -410,7 +410,7 @@ static ssize_t tpm_transmit(struct tpm_chip *chip, const char *buf,
33973 chip->vendor.req_complete_val)
33974 goto out_recv;
33975
33976 - if ((status == chip->vendor.req_canceled)) {
33977 + if (status == chip->vendor.req_canceled) {
33978 dev_err(chip->dev, "Operation Canceled\n");
33979 rc = -ECANCELED;
33980 goto out;
33981 diff --git a/drivers/char/tpm/tpm_acpi.c b/drivers/char/tpm/tpm_acpi.c
33982 index 56051d0..11cf3b7 100644
33983 --- a/drivers/char/tpm/tpm_acpi.c
33984 +++ b/drivers/char/tpm/tpm_acpi.c
33985 @@ -98,11 +98,12 @@ int read_log(struct tpm_bios_log *log)
33986 virt = acpi_os_map_memory(start, len);
33987 if (!virt) {
33988 kfree(log->bios_event_log);
33989 + log->bios_event_log = NULL;
33990 printk("%s: ERROR - Unable to map memory\n", __func__);
33991 return -EIO;
33992 }
33993
33994 - memcpy_fromio(log->bios_event_log, virt, len);
33995 + memcpy_fromio(log->bios_event_log, (const char __force_kernel *)virt, len);
33996
33997 acpi_os_unmap_memory(virt, len);
33998 return 0;
33999 diff --git a/drivers/char/tpm/tpm_eventlog.c b/drivers/char/tpm/tpm_eventlog.c
34000 index 84ddc55..1d32f1e 100644
34001 --- a/drivers/char/tpm/tpm_eventlog.c
34002 +++ b/drivers/char/tpm/tpm_eventlog.c
34003 @@ -95,7 +95,7 @@ static void *tpm_bios_measurements_start(struct seq_file *m, loff_t *pos)
34004 event = addr;
34005
34006 if ((event->event_type == 0 && event->event_size == 0) ||
34007 - ((addr + sizeof(struct tcpa_event) + event->event_size) >= limit))
34008 + (event->event_size >= limit - addr - sizeof(struct tcpa_event)))
34009 return NULL;
34010
34011 return addr;
34012 @@ -120,7 +120,7 @@ static void *tpm_bios_measurements_next(struct seq_file *m, void *v,
34013 return NULL;
34014
34015 if ((event->event_type == 0 && event->event_size == 0) ||
34016 - ((v + sizeof(struct tcpa_event) + event->event_size) >= limit))
34017 + (event->event_size >= limit - v - sizeof(struct tcpa_event)))
34018 return NULL;
34019
34020 (*pos)++;
34021 @@ -213,7 +213,8 @@ static int tpm_binary_bios_measurements_show(struct seq_file *m, void *v)
34022 int i;
34023
34024 for (i = 0; i < sizeof(struct tcpa_event) + event->event_size; i++)
34025 - seq_putc(m, data[i]);
34026 + if (!seq_putc(m, data[i]))
34027 + return -EFAULT;
34028
34029 return 0;
34030 }
34031 diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c
34032 index ee4dbea..69c817b 100644
34033 --- a/drivers/char/virtio_console.c
34034 +++ b/drivers/char/virtio_console.c
34035 @@ -681,7 +681,7 @@ static ssize_t fill_readbuf(struct port *port, char *out_buf, size_t out_count,
34036 if (to_user) {
34037 ssize_t ret;
34038
34039 - ret = copy_to_user(out_buf, buf->buf + buf->offset, out_count);
34040 + ret = copy_to_user((char __force_user *)out_buf, buf->buf + buf->offset, out_count);
34041 if (ret)
34042 return -EFAULT;
34043 } else {
34044 @@ -780,7 +780,7 @@ static ssize_t port_fops_read(struct file *filp, char __user *ubuf,
34045 if (!port_has_data(port) && !port->host_connected)
34046 return 0;
34047
34048 - return fill_readbuf(port, ubuf, count, true);
34049 + return fill_readbuf(port, (char __force_kernel *)ubuf, count, true);
34050 }
34051
34052 static int wait_port_writable(struct port *port, bool nonblock)
34053 diff --git a/drivers/clocksource/arm_generic.c b/drivers/clocksource/arm_generic.c
34054 index 8ae1a61..9c00613 100644
34055 --- a/drivers/clocksource/arm_generic.c
34056 +++ b/drivers/clocksource/arm_generic.c
34057 @@ -181,7 +181,7 @@ static int __cpuinit arch_timer_cpu_notify(struct notifier_block *self,
34058 return NOTIFY_OK;
34059 }
34060
34061 -static struct notifier_block __cpuinitdata arch_timer_cpu_nb = {
34062 +static struct notifier_block arch_timer_cpu_nb = {
34063 .notifier_call = arch_timer_cpu_notify,
34064 };
34065
34066 diff --git a/drivers/cpufreq/acpi-cpufreq.c b/drivers/cpufreq/acpi-cpufreq.c
34067 index 7b0d49d..134fac9 100644
34068 --- a/drivers/cpufreq/acpi-cpufreq.c
34069 +++ b/drivers/cpufreq/acpi-cpufreq.c
34070 @@ -172,7 +172,7 @@ static ssize_t show_global_boost(struct kobject *kobj,
34071 return sprintf(buf, "%u\n", boost_enabled);
34072 }
34073
34074 -static struct global_attr global_boost = __ATTR(boost, 0644,
34075 +static global_attr_no_const global_boost = __ATTR(boost, 0644,
34076 show_global_boost,
34077 store_global_boost);
34078
34079 @@ -712,8 +712,11 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
34080 data->acpi_data = per_cpu_ptr(acpi_perf_data, cpu);
34081 per_cpu(acfreq_data, cpu) = data;
34082
34083 - if (cpu_has(c, X86_FEATURE_CONSTANT_TSC))
34084 - acpi_cpufreq_driver.flags |= CPUFREQ_CONST_LOOPS;
34085 + if (cpu_has(c, X86_FEATURE_CONSTANT_TSC)) {
34086 + pax_open_kernel();
34087 + *(u8 *)&acpi_cpufreq_driver.flags |= CPUFREQ_CONST_LOOPS;
34088 + pax_close_kernel();
34089 + }
34090
34091 result = acpi_processor_register_performance(data->acpi_data, cpu);
34092 if (result)
34093 @@ -835,7 +838,9 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
34094 policy->cur = acpi_cpufreq_guess_freq(data, policy->cpu);
34095 break;
34096 case ACPI_ADR_SPACE_FIXED_HARDWARE:
34097 - acpi_cpufreq_driver.get = get_cur_freq_on_cpu;
34098 + pax_open_kernel();
34099 + *(void **)&acpi_cpufreq_driver.get = get_cur_freq_on_cpu;
34100 + pax_close_kernel();
34101 policy->cur = get_cur_freq_on_cpu(cpu);
34102 break;
34103 default:
34104 @@ -846,8 +851,11 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
34105 acpi_processor_notify_smm(THIS_MODULE);
34106
34107 /* Check for APERF/MPERF support in hardware */
34108 - if (boot_cpu_has(X86_FEATURE_APERFMPERF))
34109 - acpi_cpufreq_driver.getavg = cpufreq_get_measured_perf;
34110 + if (boot_cpu_has(X86_FEATURE_APERFMPERF)) {
34111 + pax_open_kernel();
34112 + *(void **)&acpi_cpufreq_driver.getavg = cpufreq_get_measured_perf;
34113 + pax_close_kernel();
34114 + }
34115
34116 pr_debug("CPU%u - ACPI performance management activated.\n", cpu);
34117 for (i = 0; i < perf->state_count; i++)
34118 diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
34119 index 1f93dbd..305cef1 100644
34120 --- a/drivers/cpufreq/cpufreq.c
34121 +++ b/drivers/cpufreq/cpufreq.c
34122 @@ -1843,7 +1843,7 @@ static int __cpuinit cpufreq_cpu_callback(struct notifier_block *nfb,
34123 return NOTIFY_OK;
34124 }
34125
34126 -static struct notifier_block __refdata cpufreq_cpu_notifier = {
34127 +static struct notifier_block cpufreq_cpu_notifier = {
34128 .notifier_call = cpufreq_cpu_callback,
34129 };
34130
34131 @@ -1875,8 +1875,11 @@ int cpufreq_register_driver(struct cpufreq_driver *driver_data)
34132
34133 pr_debug("trying to register driver %s\n", driver_data->name);
34134
34135 - if (driver_data->setpolicy)
34136 - driver_data->flags |= CPUFREQ_CONST_LOOPS;
34137 + if (driver_data->setpolicy) {
34138 + pax_open_kernel();
34139 + *(u8 *)&driver_data->flags |= CPUFREQ_CONST_LOOPS;
34140 + pax_close_kernel();
34141 + }
34142
34143 spin_lock_irqsave(&cpufreq_driver_lock, flags);
34144 if (cpufreq_driver) {
34145 diff --git a/drivers/cpufreq/cpufreq_governor.c b/drivers/cpufreq/cpufreq_governor.c
34146 index 6c5f1d3..c7e2f35e 100644
34147 --- a/drivers/cpufreq/cpufreq_governor.c
34148 +++ b/drivers/cpufreq/cpufreq_governor.c
34149 @@ -243,7 +243,7 @@ int cpufreq_governor_dbs(struct dbs_data *dbs_data,
34150 * governor, thus we are bound to jiffes/HZ
34151 */
34152 if (dbs_data->governor == GOV_CONSERVATIVE) {
34153 - struct cs_ops *ops = dbs_data->gov_ops;
34154 + const struct cs_ops *ops = dbs_data->gov_ops;
34155
34156 cpufreq_register_notifier(ops->notifier_block,
34157 CPUFREQ_TRANSITION_NOTIFIER);
34158 @@ -251,7 +251,7 @@ int cpufreq_governor_dbs(struct dbs_data *dbs_data,
34159 dbs_data->min_sampling_rate = MIN_SAMPLING_RATE_RATIO *
34160 jiffies_to_usecs(10);
34161 } else {
34162 - struct od_ops *ops = dbs_data->gov_ops;
34163 + const struct od_ops *ops = dbs_data->gov_ops;
34164
34165 od_tuners->io_is_busy = ops->io_busy();
34166 }
34167 @@ -268,7 +268,7 @@ second_time:
34168 cs_dbs_info->enable = 1;
34169 cs_dbs_info->requested_freq = policy->cur;
34170 } else {
34171 - struct od_ops *ops = dbs_data->gov_ops;
34172 + const struct od_ops *ops = dbs_data->gov_ops;
34173 od_dbs_info->rate_mult = 1;
34174 od_dbs_info->sample_type = OD_NORMAL_SAMPLE;
34175 ops->powersave_bias_init_cpu(cpu);
34176 @@ -289,7 +289,7 @@ second_time:
34177 mutex_destroy(&cpu_cdbs->timer_mutex);
34178 dbs_data->enable--;
34179 if (!dbs_data->enable) {
34180 - struct cs_ops *ops = dbs_data->gov_ops;
34181 + const struct cs_ops *ops = dbs_data->gov_ops;
34182
34183 sysfs_remove_group(cpufreq_global_kobject,
34184 dbs_data->attr_group);
34185 diff --git a/drivers/cpufreq/cpufreq_governor.h b/drivers/cpufreq/cpufreq_governor.h
34186 index f661654..6c8e638 100644
34187 --- a/drivers/cpufreq/cpufreq_governor.h
34188 +++ b/drivers/cpufreq/cpufreq_governor.h
34189 @@ -142,7 +142,7 @@ struct dbs_data {
34190 void (*gov_check_cpu)(int cpu, unsigned int load);
34191
34192 /* Governor specific ops, see below */
34193 - void *gov_ops;
34194 + const void *gov_ops;
34195 };
34196
34197 /* Governor specific ops, will be passed to dbs_data->gov_ops */
34198 diff --git a/drivers/cpufreq/cpufreq_stats.c b/drivers/cpufreq/cpufreq_stats.c
34199 index 9d7732b..0b1a793 100644
34200 --- a/drivers/cpufreq/cpufreq_stats.c
34201 +++ b/drivers/cpufreq/cpufreq_stats.c
34202 @@ -340,7 +340,7 @@ static int __cpuinit cpufreq_stat_cpu_callback(struct notifier_block *nfb,
34203 }
34204
34205 /* priority=1 so this will get called before cpufreq_remove_dev */
34206 -static struct notifier_block cpufreq_stat_cpu_notifier __refdata = {
34207 +static struct notifier_block cpufreq_stat_cpu_notifier = {
34208 .notifier_call = cpufreq_stat_cpu_callback,
34209 .priority = 1,
34210 };
34211 diff --git a/drivers/cpufreq/p4-clockmod.c b/drivers/cpufreq/p4-clockmod.c
34212 index 827629c9..0bc6a03 100644
34213 --- a/drivers/cpufreq/p4-clockmod.c
34214 +++ b/drivers/cpufreq/p4-clockmod.c
34215 @@ -167,10 +167,14 @@ static unsigned int cpufreq_p4_get_frequency(struct cpuinfo_x86 *c)
34216 case 0x0F: /* Core Duo */
34217 case 0x16: /* Celeron Core */
34218 case 0x1C: /* Atom */
34219 - p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
34220 + pax_open_kernel();
34221 + *(u8 *)&p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
34222 + pax_close_kernel();
34223 return speedstep_get_frequency(SPEEDSTEP_CPU_PCORE);
34224 case 0x0D: /* Pentium M (Dothan) */
34225 - p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
34226 + pax_open_kernel();
34227 + *(u8 *)&p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
34228 + pax_close_kernel();
34229 /* fall through */
34230 case 0x09: /* Pentium M (Banias) */
34231 return speedstep_get_frequency(SPEEDSTEP_CPU_PM);
34232 @@ -182,7 +186,9 @@ static unsigned int cpufreq_p4_get_frequency(struct cpuinfo_x86 *c)
34233
34234 /* on P-4s, the TSC runs with constant frequency independent whether
34235 * throttling is active or not. */
34236 - p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
34237 + pax_open_kernel();
34238 + *(u8 *)&p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
34239 + pax_close_kernel();
34240
34241 if (speedstep_detect_processor() == SPEEDSTEP_CPU_P4M) {
34242 printk(KERN_WARNING PFX "Warning: Pentium 4-M detected. "
34243 diff --git a/drivers/cpufreq/speedstep-centrino.c b/drivers/cpufreq/speedstep-centrino.c
34244 index 3a953d5..f5993f6 100644
34245 --- a/drivers/cpufreq/speedstep-centrino.c
34246 +++ b/drivers/cpufreq/speedstep-centrino.c
34247 @@ -353,8 +353,11 @@ static int centrino_cpu_init(struct cpufreq_policy *policy)
34248 !cpu_has(cpu, X86_FEATURE_EST))
34249 return -ENODEV;
34250
34251 - if (cpu_has(cpu, X86_FEATURE_CONSTANT_TSC))
34252 - centrino_driver.flags |= CPUFREQ_CONST_LOOPS;
34253 + if (cpu_has(cpu, X86_FEATURE_CONSTANT_TSC)) {
34254 + pax_open_kernel();
34255 + *(u8 *)&centrino_driver.flags |= CPUFREQ_CONST_LOOPS;
34256 + pax_close_kernel();
34257 + }
34258
34259 if (policy->cpu != 0)
34260 return -ENODEV;
34261 diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c
34262 index e1f6860..f8de20b 100644
34263 --- a/drivers/cpuidle/cpuidle.c
34264 +++ b/drivers/cpuidle/cpuidle.c
34265 @@ -279,7 +279,7 @@ static int poll_idle(struct cpuidle_device *dev,
34266
34267 static void poll_idle_init(struct cpuidle_driver *drv)
34268 {
34269 - struct cpuidle_state *state = &drv->states[0];
34270 + cpuidle_state_no_const *state = &drv->states[0];
34271
34272 snprintf(state->name, CPUIDLE_NAME_LEN, "POLL");
34273 snprintf(state->desc, CPUIDLE_DESC_LEN, "CPUIDLE CORE POLL IDLE");
34274 diff --git a/drivers/cpuidle/governor.c b/drivers/cpuidle/governor.c
34275 index ea2f8e7..70ac501 100644
34276 --- a/drivers/cpuidle/governor.c
34277 +++ b/drivers/cpuidle/governor.c
34278 @@ -87,7 +87,7 @@ int cpuidle_register_governor(struct cpuidle_governor *gov)
34279 mutex_lock(&cpuidle_lock);
34280 if (__cpuidle_find_governor(gov->name) == NULL) {
34281 ret = 0;
34282 - list_add_tail(&gov->governor_list, &cpuidle_governors);
34283 + pax_list_add_tail((struct list_head *)&gov->governor_list, &cpuidle_governors);
34284 if (!cpuidle_curr_governor ||
34285 cpuidle_curr_governor->rating < gov->rating)
34286 cpuidle_switch_governor(gov);
34287 @@ -135,7 +135,7 @@ void cpuidle_unregister_governor(struct cpuidle_governor *gov)
34288 new_gov = cpuidle_replace_governor(gov->rating);
34289 cpuidle_switch_governor(new_gov);
34290 }
34291 - list_del(&gov->governor_list);
34292 + pax_list_del((struct list_head *)&gov->governor_list);
34293 mutex_unlock(&cpuidle_lock);
34294 }
34295
34296 diff --git a/drivers/cpuidle/sysfs.c b/drivers/cpuidle/sysfs.c
34297 index 428754a..8bdf9cc 100644
34298 --- a/drivers/cpuidle/sysfs.c
34299 +++ b/drivers/cpuidle/sysfs.c
34300 @@ -131,7 +131,7 @@ static struct attribute *cpuidle_switch_attrs[] = {
34301 NULL
34302 };
34303
34304 -static struct attribute_group cpuidle_attr_group = {
34305 +static attribute_group_no_const cpuidle_attr_group = {
34306 .attrs = cpuidle_default_attrs,
34307 .name = "cpuidle",
34308 };
34309 diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
34310 index 3b36797..289c16a 100644
34311 --- a/drivers/devfreq/devfreq.c
34312 +++ b/drivers/devfreq/devfreq.c
34313 @@ -588,7 +588,7 @@ int devfreq_add_governor(struct devfreq_governor *governor)
34314 goto err_out;
34315 }
34316
34317 - list_add(&governor->node, &devfreq_governor_list);
34318 + pax_list_add((struct list_head *)&governor->node, &devfreq_governor_list);
34319
34320 list_for_each_entry(devfreq, &devfreq_list, node) {
34321 int ret = 0;
34322 @@ -676,7 +676,7 @@ int devfreq_remove_governor(struct devfreq_governor *governor)
34323 }
34324 }
34325
34326 - list_del(&governor->node);
34327 + pax_list_del((struct list_head *)&governor->node);
34328 err_out:
34329 mutex_unlock(&devfreq_list_lock);
34330
34331 diff --git a/drivers/dma/sh/shdma.c b/drivers/dma/sh/shdma.c
34332 index b70709b..1d8d02a 100644
34333 --- a/drivers/dma/sh/shdma.c
34334 +++ b/drivers/dma/sh/shdma.c
34335 @@ -476,7 +476,7 @@ static int sh_dmae_nmi_handler(struct notifier_block *self,
34336 return ret;
34337 }
34338
34339 -static struct notifier_block sh_dmae_nmi_notifier __read_mostly = {
34340 +static struct notifier_block sh_dmae_nmi_notifier = {
34341 .notifier_call = sh_dmae_nmi_handler,
34342
34343 /* Run before NMI debug handler and KGDB */
34344 diff --git a/drivers/edac/edac_mc_sysfs.c b/drivers/edac/edac_mc_sysfs.c
34345 index 0ca1ca7..6e6f454 100644
34346 --- a/drivers/edac/edac_mc_sysfs.c
34347 +++ b/drivers/edac/edac_mc_sysfs.c
34348 @@ -148,7 +148,7 @@ static const char *edac_caps[] = {
34349 struct dev_ch_attribute {
34350 struct device_attribute attr;
34351 int channel;
34352 -};
34353 +} __do_const;
34354
34355 #define DEVICE_CHANNEL(_name, _mode, _show, _store, _var) \
34356 struct dev_ch_attribute dev_attr_legacy_##_name = \
34357 diff --git a/drivers/edac/edac_pci_sysfs.c b/drivers/edac/edac_pci_sysfs.c
34358 index 0056c4d..23b54d9 100644
34359 --- a/drivers/edac/edac_pci_sysfs.c
34360 +++ b/drivers/edac/edac_pci_sysfs.c
34361 @@ -26,8 +26,8 @@ static int edac_pci_log_pe = 1; /* log PCI parity errors */
34362 static int edac_pci_log_npe = 1; /* log PCI non-parity error errors */
34363 static int edac_pci_poll_msec = 1000; /* one second workq period */
34364
34365 -static atomic_t pci_parity_count = ATOMIC_INIT(0);
34366 -static atomic_t pci_nonparity_count = ATOMIC_INIT(0);
34367 +static atomic_unchecked_t pci_parity_count = ATOMIC_INIT(0);
34368 +static atomic_unchecked_t pci_nonparity_count = ATOMIC_INIT(0);
34369
34370 static struct kobject *edac_pci_top_main_kobj;
34371 static atomic_t edac_pci_sysfs_refcount = ATOMIC_INIT(0);
34372 @@ -235,7 +235,7 @@ struct edac_pci_dev_attribute {
34373 void *value;
34374 ssize_t(*show) (void *, char *);
34375 ssize_t(*store) (void *, const char *, size_t);
34376 -};
34377 +} __do_const;
34378
34379 /* Set of show/store abstract level functions for PCI Parity object */
34380 static ssize_t edac_pci_dev_show(struct kobject *kobj, struct attribute *attr,
34381 @@ -579,7 +579,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
34382 edac_printk(KERN_CRIT, EDAC_PCI,
34383 "Signaled System Error on %s\n",
34384 pci_name(dev));
34385 - atomic_inc(&pci_nonparity_count);
34386 + atomic_inc_unchecked(&pci_nonparity_count);
34387 }
34388
34389 if (status & (PCI_STATUS_PARITY)) {
34390 @@ -587,7 +587,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
34391 "Master Data Parity Error on %s\n",
34392 pci_name(dev));
34393
34394 - atomic_inc(&pci_parity_count);
34395 + atomic_inc_unchecked(&pci_parity_count);
34396 }
34397
34398 if (status & (PCI_STATUS_DETECTED_PARITY)) {
34399 @@ -595,7 +595,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
34400 "Detected Parity Error on %s\n",
34401 pci_name(dev));
34402
34403 - atomic_inc(&pci_parity_count);
34404 + atomic_inc_unchecked(&pci_parity_count);
34405 }
34406 }
34407
34408 @@ -618,7 +618,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
34409 edac_printk(KERN_CRIT, EDAC_PCI, "Bridge "
34410 "Signaled System Error on %s\n",
34411 pci_name(dev));
34412 - atomic_inc(&pci_nonparity_count);
34413 + atomic_inc_unchecked(&pci_nonparity_count);
34414 }
34415
34416 if (status & (PCI_STATUS_PARITY)) {
34417 @@ -626,7 +626,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
34418 "Master Data Parity Error on "
34419 "%s\n", pci_name(dev));
34420
34421 - atomic_inc(&pci_parity_count);
34422 + atomic_inc_unchecked(&pci_parity_count);
34423 }
34424
34425 if (status & (PCI_STATUS_DETECTED_PARITY)) {
34426 @@ -634,7 +634,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
34427 "Detected Parity Error on %s\n",
34428 pci_name(dev));
34429
34430 - atomic_inc(&pci_parity_count);
34431 + atomic_inc_unchecked(&pci_parity_count);
34432 }
34433 }
34434 }
34435 @@ -672,7 +672,7 @@ void edac_pci_do_parity_check(void)
34436 if (!check_pci_errors)
34437 return;
34438
34439 - before_count = atomic_read(&pci_parity_count);
34440 + before_count = atomic_read_unchecked(&pci_parity_count);
34441
34442 /* scan all PCI devices looking for a Parity Error on devices and
34443 * bridges.
34444 @@ -684,7 +684,7 @@ void edac_pci_do_parity_check(void)
34445 /* Only if operator has selected panic on PCI Error */
34446 if (edac_pci_get_panic_on_pe()) {
34447 /* If the count is different 'after' from 'before' */
34448 - if (before_count != atomic_read(&pci_parity_count))
34449 + if (before_count != atomic_read_unchecked(&pci_parity_count))
34450 panic("EDAC: PCI Parity Error");
34451 }
34452 }
34453 diff --git a/drivers/edac/mce_amd.h b/drivers/edac/mce_amd.h
34454 index 6796799..99e8377 100644
34455 --- a/drivers/edac/mce_amd.h
34456 +++ b/drivers/edac/mce_amd.h
34457 @@ -78,7 +78,7 @@ extern const char * const ii_msgs[];
34458 struct amd_decoder_ops {
34459 bool (*mc0_mce)(u16, u8);
34460 bool (*mc1_mce)(u16, u8);
34461 -};
34462 +} __no_const;
34463
34464 void amd_report_gart_errors(bool);
34465 void amd_register_ecc_decoder(void (*f)(int, struct mce *));
34466 diff --git a/drivers/firewire/core-card.c b/drivers/firewire/core-card.c
34467 index 57ea7f4..789e3c3 100644
34468 --- a/drivers/firewire/core-card.c
34469 +++ b/drivers/firewire/core-card.c
34470 @@ -680,7 +680,7 @@ EXPORT_SYMBOL_GPL(fw_card_release);
34471
34472 void fw_core_remove_card(struct fw_card *card)
34473 {
34474 - struct fw_card_driver dummy_driver = dummy_driver_template;
34475 + fw_card_driver_no_const dummy_driver = dummy_driver_template;
34476
34477 card->driver->update_phy_reg(card, 4,
34478 PHY_LINK_ACTIVE | PHY_CONTENDER, 0);
34479 diff --git a/drivers/firewire/core-cdev.c b/drivers/firewire/core-cdev.c
34480 index f8d2287..5aaf4db 100644
34481 --- a/drivers/firewire/core-cdev.c
34482 +++ b/drivers/firewire/core-cdev.c
34483 @@ -1365,8 +1365,7 @@ static int init_iso_resource(struct client *client,
34484 int ret;
34485
34486 if ((request->channels == 0 && request->bandwidth == 0) ||
34487 - request->bandwidth > BANDWIDTH_AVAILABLE_INITIAL ||
34488 - request->bandwidth < 0)
34489 + request->bandwidth > BANDWIDTH_AVAILABLE_INITIAL)
34490 return -EINVAL;
34491
34492 r = kmalloc(sizeof(*r), GFP_KERNEL);
34493 diff --git a/drivers/firewire/core-device.c b/drivers/firewire/core-device.c
34494 index af3e8aa..eb2f227 100644
34495 --- a/drivers/firewire/core-device.c
34496 +++ b/drivers/firewire/core-device.c
34497 @@ -232,7 +232,7 @@ EXPORT_SYMBOL(fw_device_enable_phys_dma);
34498 struct config_rom_attribute {
34499 struct device_attribute attr;
34500 u32 key;
34501 -};
34502 +} __do_const;
34503
34504 static ssize_t show_immediate(struct device *dev,
34505 struct device_attribute *dattr, char *buf)
34506 diff --git a/drivers/firewire/core-transaction.c b/drivers/firewire/core-transaction.c
34507 index 28a94c7..58da63a 100644
34508 --- a/drivers/firewire/core-transaction.c
34509 +++ b/drivers/firewire/core-transaction.c
34510 @@ -38,6 +38,7 @@
34511 #include <linux/timer.h>
34512 #include <linux/types.h>
34513 #include <linux/workqueue.h>
34514 +#include <linux/sched.h>
34515
34516 #include <asm/byteorder.h>
34517
34518 diff --git a/drivers/firewire/core.h b/drivers/firewire/core.h
34519 index 515a42c..5ecf3ba 100644
34520 --- a/drivers/firewire/core.h
34521 +++ b/drivers/firewire/core.h
34522 @@ -111,6 +111,7 @@ struct fw_card_driver {
34523
34524 int (*stop_iso)(struct fw_iso_context *ctx);
34525 };
34526 +typedef struct fw_card_driver __no_const fw_card_driver_no_const;
34527
34528 void fw_card_initialize(struct fw_card *card,
34529 const struct fw_card_driver *driver, struct device *device);
34530 diff --git a/drivers/firmware/dmi-id.c b/drivers/firmware/dmi-id.c
34531 index 94a58a0..f5eba42 100644
34532 --- a/drivers/firmware/dmi-id.c
34533 +++ b/drivers/firmware/dmi-id.c
34534 @@ -16,7 +16,7 @@
34535 struct dmi_device_attribute{
34536 struct device_attribute dev_attr;
34537 int field;
34538 -};
34539 +} __do_const;
34540 #define to_dmi_dev_attr(_dev_attr) \
34541 container_of(_dev_attr, struct dmi_device_attribute, dev_attr)
34542
34543 diff --git a/drivers/firmware/dmi_scan.c b/drivers/firmware/dmi_scan.c
34544 index 4cd392d..4b629e1 100644
34545 --- a/drivers/firmware/dmi_scan.c
34546 +++ b/drivers/firmware/dmi_scan.c
34547 @@ -490,11 +490,6 @@ void __init dmi_scan_machine(void)
34548 }
34549 }
34550 else {
34551 - /*
34552 - * no iounmap() for that ioremap(); it would be a no-op, but
34553 - * it's so early in setup that sucker gets confused into doing
34554 - * what it shouldn't if we actually call it.
34555 - */
34556 p = dmi_ioremap(0xF0000, 0x10000);
34557 if (p == NULL)
34558 goto error;
34559 @@ -769,7 +764,7 @@ int dmi_walk(void (*decode)(const struct dmi_header *, void *),
34560 if (buf == NULL)
34561 return -1;
34562
34563 - dmi_table(buf, dmi_len, dmi_num, decode, private_data);
34564 + dmi_table((char __force_kernel *)buf, dmi_len, dmi_num, decode, private_data);
34565
34566 iounmap(buf);
34567 return 0;
34568 diff --git a/drivers/firmware/efivars.c b/drivers/firmware/efivars.c
34569 index 2a2e145..73745e79 100644
34570 --- a/drivers/firmware/efivars.c
34571 +++ b/drivers/firmware/efivars.c
34572 @@ -133,7 +133,7 @@ struct efivar_attribute {
34573 };
34574
34575 static struct efivars __efivars;
34576 -static struct efivar_operations ops;
34577 +static efivar_operations_no_const ops __read_only;
34578
34579 #define PSTORE_EFI_ATTRIBUTES \
34580 (EFI_VARIABLE_NON_VOLATILE | \
34581 @@ -1798,7 +1798,7 @@ efivar_create_sysfs_entry(struct efivars *efivars,
34582 static int
34583 create_efivars_bin_attributes(struct efivars *efivars)
34584 {
34585 - struct bin_attribute *attr;
34586 + bin_attribute_no_const *attr;
34587 int error;
34588
34589 /* new_var */
34590 diff --git a/drivers/firmware/google/memconsole.c b/drivers/firmware/google/memconsole.c
34591 index 2a90ba6..07f3733 100644
34592 --- a/drivers/firmware/google/memconsole.c
34593 +++ b/drivers/firmware/google/memconsole.c
34594 @@ -147,7 +147,9 @@ static int __init memconsole_init(void)
34595 if (!found_memconsole())
34596 return -ENODEV;
34597
34598 - memconsole_bin_attr.size = memconsole_length;
34599 + pax_open_kernel();
34600 + *(size_t *)&memconsole_bin_attr.size = memconsole_length;
34601 + pax_close_kernel();
34602
34603 ret = sysfs_create_bin_file(firmware_kobj, &memconsole_bin_attr);
34604
34605 diff --git a/drivers/gpio/gpio-ich.c b/drivers/gpio/gpio-ich.c
34606 index 6f2306d..af9476a 100644
34607 --- a/drivers/gpio/gpio-ich.c
34608 +++ b/drivers/gpio/gpio-ich.c
34609 @@ -69,7 +69,7 @@ struct ichx_desc {
34610 /* Some chipsets have quirks, let these use their own request/get */
34611 int (*request)(struct gpio_chip *chip, unsigned offset);
34612 int (*get)(struct gpio_chip *chip, unsigned offset);
34613 -};
34614 +} __do_const;
34615
34616 static struct {
34617 spinlock_t lock;
34618 diff --git a/drivers/gpio/gpio-vr41xx.c b/drivers/gpio/gpio-vr41xx.c
34619 index 9902732..64b62dd 100644
34620 --- a/drivers/gpio/gpio-vr41xx.c
34621 +++ b/drivers/gpio/gpio-vr41xx.c
34622 @@ -204,7 +204,7 @@ static int giu_get_irq(unsigned int irq)
34623 printk(KERN_ERR "spurious GIU interrupt: %04x(%04x),%04x(%04x)\n",
34624 maskl, pendl, maskh, pendh);
34625
34626 - atomic_inc(&irq_err_count);
34627 + atomic_inc_unchecked(&irq_err_count);
34628
34629 return -EINVAL;
34630 }
34631 diff --git a/drivers/gpu/drm/drm_crtc_helper.c b/drivers/gpu/drm/drm_crtc_helper.c
34632 index 7b2d378..cc947ea 100644
34633 --- a/drivers/gpu/drm/drm_crtc_helper.c
34634 +++ b/drivers/gpu/drm/drm_crtc_helper.c
34635 @@ -319,7 +319,7 @@ static bool drm_encoder_crtc_ok(struct drm_encoder *encoder,
34636 struct drm_crtc *tmp;
34637 int crtc_mask = 1;
34638
34639 - WARN(!crtc, "checking null crtc?\n");
34640 + BUG_ON(!crtc);
34641
34642 dev = crtc->dev;
34643
34644 diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
34645 index be174ca..7f38143 100644
34646 --- a/drivers/gpu/drm/drm_drv.c
34647 +++ b/drivers/gpu/drm/drm_drv.c
34648 @@ -307,7 +307,7 @@ module_exit(drm_core_exit);
34649 /**
34650 * Copy and IOCTL return string to user space
34651 */
34652 -static int drm_copy_field(char *buf, size_t *buf_len, const char *value)
34653 +static int drm_copy_field(char __user *buf, size_t *buf_len, const char *value)
34654 {
34655 int len;
34656
34657 @@ -377,7 +377,7 @@ long drm_ioctl(struct file *filp,
34658 struct drm_file *file_priv = filp->private_data;
34659 struct drm_device *dev;
34660 struct drm_ioctl_desc *ioctl;
34661 - drm_ioctl_t *func;
34662 + drm_ioctl_no_const_t func;
34663 unsigned int nr = DRM_IOCTL_NR(cmd);
34664 int retcode = -EINVAL;
34665 char stack_kdata[128];
34666 @@ -390,7 +390,7 @@ long drm_ioctl(struct file *filp,
34667 return -ENODEV;
34668
34669 atomic_inc(&dev->ioctl_count);
34670 - atomic_inc(&dev->counts[_DRM_STAT_IOCTLS]);
34671 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_IOCTLS]);
34672 ++file_priv->ioctl_count;
34673
34674 DRM_DEBUG("pid=%d, cmd=0x%02x, nr=0x%02x, dev 0x%lx, auth=%d\n",
34675 diff --git a/drivers/gpu/drm/drm_fops.c b/drivers/gpu/drm/drm_fops.c
34676 index 133b413..fd68225 100644
34677 --- a/drivers/gpu/drm/drm_fops.c
34678 +++ b/drivers/gpu/drm/drm_fops.c
34679 @@ -71,7 +71,7 @@ static int drm_setup(struct drm_device * dev)
34680 }
34681
34682 for (i = 0; i < ARRAY_SIZE(dev->counts); i++)
34683 - atomic_set(&dev->counts[i], 0);
34684 + atomic_set_unchecked(&dev->counts[i], 0);
34685
34686 dev->sigdata.lock = NULL;
34687
34688 @@ -134,7 +134,7 @@ int drm_open(struct inode *inode, struct file *filp)
34689 if (drm_device_is_unplugged(dev))
34690 return -ENODEV;
34691
34692 - if (!dev->open_count++)
34693 + if (local_inc_return(&dev->open_count) == 1)
34694 need_setup = 1;
34695 mutex_lock(&dev->struct_mutex);
34696 old_mapping = dev->dev_mapping;
34697 @@ -149,7 +149,7 @@ int drm_open(struct inode *inode, struct file *filp)
34698 retcode = drm_open_helper(inode, filp, dev);
34699 if (retcode)
34700 goto err_undo;
34701 - atomic_inc(&dev->counts[_DRM_STAT_OPENS]);
34702 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_OPENS]);
34703 if (need_setup) {
34704 retcode = drm_setup(dev);
34705 if (retcode)
34706 @@ -164,7 +164,7 @@ err_undo:
34707 iput(container_of(dev->dev_mapping, struct inode, i_data));
34708 dev->dev_mapping = old_mapping;
34709 mutex_unlock(&dev->struct_mutex);
34710 - dev->open_count--;
34711 + local_dec(&dev->open_count);
34712 return retcode;
34713 }
34714 EXPORT_SYMBOL(drm_open);
34715 @@ -438,7 +438,7 @@ int drm_release(struct inode *inode, struct file *filp)
34716
34717 mutex_lock(&drm_global_mutex);
34718
34719 - DRM_DEBUG("open_count = %d\n", dev->open_count);
34720 + DRM_DEBUG("open_count = %ld\n", local_read(&dev->open_count));
34721
34722 if (dev->driver->preclose)
34723 dev->driver->preclose(dev, file_priv);
34724 @@ -447,10 +447,10 @@ int drm_release(struct inode *inode, struct file *filp)
34725 * Begin inline drm_release
34726 */
34727
34728 - DRM_DEBUG("pid = %d, device = 0x%lx, open_count = %d\n",
34729 + DRM_DEBUG("pid = %d, device = 0x%lx, open_count = %ld\n",
34730 task_pid_nr(current),
34731 (long)old_encode_dev(file_priv->minor->device),
34732 - dev->open_count);
34733 + local_read(&dev->open_count));
34734
34735 /* Release any auth tokens that might point to this file_priv,
34736 (do that under the drm_global_mutex) */
34737 @@ -547,8 +547,8 @@ int drm_release(struct inode *inode, struct file *filp)
34738 * End inline drm_release
34739 */
34740
34741 - atomic_inc(&dev->counts[_DRM_STAT_CLOSES]);
34742 - if (!--dev->open_count) {
34743 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_CLOSES]);
34744 + if (local_dec_and_test(&dev->open_count)) {
34745 if (atomic_read(&dev->ioctl_count)) {
34746 DRM_ERROR("Device busy: %d\n",
34747 atomic_read(&dev->ioctl_count));
34748 diff --git a/drivers/gpu/drm/drm_global.c b/drivers/gpu/drm/drm_global.c
34749 index f731116..629842c 100644
34750 --- a/drivers/gpu/drm/drm_global.c
34751 +++ b/drivers/gpu/drm/drm_global.c
34752 @@ -36,7 +36,7 @@
34753 struct drm_global_item {
34754 struct mutex mutex;
34755 void *object;
34756 - int refcount;
34757 + atomic_t refcount;
34758 };
34759
34760 static struct drm_global_item glob[DRM_GLOBAL_NUM];
34761 @@ -49,7 +49,7 @@ void drm_global_init(void)
34762 struct drm_global_item *item = &glob[i];
34763 mutex_init(&item->mutex);
34764 item->object = NULL;
34765 - item->refcount = 0;
34766 + atomic_set(&item->refcount, 0);
34767 }
34768 }
34769
34770 @@ -59,7 +59,7 @@ void drm_global_release(void)
34771 for (i = 0; i < DRM_GLOBAL_NUM; ++i) {
34772 struct drm_global_item *item = &glob[i];
34773 BUG_ON(item->object != NULL);
34774 - BUG_ON(item->refcount != 0);
34775 + BUG_ON(atomic_read(&item->refcount) != 0);
34776 }
34777 }
34778
34779 @@ -70,7 +70,7 @@ int drm_global_item_ref(struct drm_global_reference *ref)
34780 void *object;
34781
34782 mutex_lock(&item->mutex);
34783 - if (item->refcount == 0) {
34784 + if (atomic_read(&item->refcount) == 0) {
34785 item->object = kzalloc(ref->size, GFP_KERNEL);
34786 if (unlikely(item->object == NULL)) {
34787 ret = -ENOMEM;
34788 @@ -83,7 +83,7 @@ int drm_global_item_ref(struct drm_global_reference *ref)
34789 goto out_err;
34790
34791 }
34792 - ++item->refcount;
34793 + atomic_inc(&item->refcount);
34794 ref->object = item->object;
34795 object = item->object;
34796 mutex_unlock(&item->mutex);
34797 @@ -100,9 +100,9 @@ void drm_global_item_unref(struct drm_global_reference *ref)
34798 struct drm_global_item *item = &glob[ref->global_type];
34799
34800 mutex_lock(&item->mutex);
34801 - BUG_ON(item->refcount == 0);
34802 + BUG_ON(atomic_read(&item->refcount) == 0);
34803 BUG_ON(ref->object != item->object);
34804 - if (--item->refcount == 0) {
34805 + if (atomic_dec_and_test(&item->refcount)) {
34806 ref->release(ref);
34807 item->object = NULL;
34808 }
34809 diff --git a/drivers/gpu/drm/drm_info.c b/drivers/gpu/drm/drm_info.c
34810 index d4b20ce..77a8d41 100644
34811 --- a/drivers/gpu/drm/drm_info.c
34812 +++ b/drivers/gpu/drm/drm_info.c
34813 @@ -75,10 +75,14 @@ int drm_vm_info(struct seq_file *m, void *data)
34814 struct drm_local_map *map;
34815 struct drm_map_list *r_list;
34816
34817 - /* Hardcoded from _DRM_FRAME_BUFFER,
34818 - _DRM_REGISTERS, _DRM_SHM, _DRM_AGP, and
34819 - _DRM_SCATTER_GATHER and _DRM_CONSISTENT */
34820 - const char *types[] = { "FB", "REG", "SHM", "AGP", "SG", "PCI" };
34821 + static const char * const types[] = {
34822 + [_DRM_FRAME_BUFFER] = "FB",
34823 + [_DRM_REGISTERS] = "REG",
34824 + [_DRM_SHM] = "SHM",
34825 + [_DRM_AGP] = "AGP",
34826 + [_DRM_SCATTER_GATHER] = "SG",
34827 + [_DRM_CONSISTENT] = "PCI",
34828 + [_DRM_GEM] = "GEM" };
34829 const char *type;
34830 int i;
34831
34832 @@ -89,7 +93,7 @@ int drm_vm_info(struct seq_file *m, void *data)
34833 map = r_list->map;
34834 if (!map)
34835 continue;
34836 - if (map->type < 0 || map->type > 5)
34837 + if (map->type >= ARRAY_SIZE(types))
34838 type = "??";
34839 else
34840 type = types[map->type];
34841 @@ -253,7 +257,11 @@ int drm_vma_info(struct seq_file *m, void *data)
34842 vma->vm_flags & VM_MAYSHARE ? 's' : 'p',
34843 vma->vm_flags & VM_LOCKED ? 'l' : '-',
34844 vma->vm_flags & VM_IO ? 'i' : '-',
34845 +#ifdef CONFIG_GRKERNSEC_HIDESYM
34846 + 0);
34847 +#else
34848 vma->vm_pgoff);
34849 +#endif
34850
34851 #if defined(__i386__)
34852 pgprot = pgprot_val(vma->vm_page_prot);
34853 diff --git a/drivers/gpu/drm/drm_ioc32.c b/drivers/gpu/drm/drm_ioc32.c
34854 index 2f4c434..dd12cd2 100644
34855 --- a/drivers/gpu/drm/drm_ioc32.c
34856 +++ b/drivers/gpu/drm/drm_ioc32.c
34857 @@ -457,7 +457,7 @@ static int compat_drm_infobufs(struct file *file, unsigned int cmd,
34858 request = compat_alloc_user_space(nbytes);
34859 if (!access_ok(VERIFY_WRITE, request, nbytes))
34860 return -EFAULT;
34861 - list = (struct drm_buf_desc *) (request + 1);
34862 + list = (struct drm_buf_desc __user *) (request + 1);
34863
34864 if (__put_user(count, &request->count)
34865 || __put_user(list, &request->list))
34866 @@ -518,7 +518,7 @@ static int compat_drm_mapbufs(struct file *file, unsigned int cmd,
34867 request = compat_alloc_user_space(nbytes);
34868 if (!access_ok(VERIFY_WRITE, request, nbytes))
34869 return -EFAULT;
34870 - list = (struct drm_buf_pub *) (request + 1);
34871 + list = (struct drm_buf_pub __user *) (request + 1);
34872
34873 if (__put_user(count, &request->count)
34874 || __put_user(list, &request->list))
34875 @@ -1016,7 +1016,7 @@ static int compat_drm_wait_vblank(struct file *file, unsigned int cmd,
34876 return 0;
34877 }
34878
34879 -drm_ioctl_compat_t *drm_compat_ioctls[] = {
34880 +drm_ioctl_compat_t drm_compat_ioctls[] = {
34881 [DRM_IOCTL_NR(DRM_IOCTL_VERSION32)] = compat_drm_version,
34882 [DRM_IOCTL_NR(DRM_IOCTL_GET_UNIQUE32)] = compat_drm_getunique,
34883 [DRM_IOCTL_NR(DRM_IOCTL_GET_MAP32)] = compat_drm_getmap,
34884 @@ -1062,7 +1062,6 @@ drm_ioctl_compat_t *drm_compat_ioctls[] = {
34885 long drm_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
34886 {
34887 unsigned int nr = DRM_IOCTL_NR(cmd);
34888 - drm_ioctl_compat_t *fn;
34889 int ret;
34890
34891 /* Assume that ioctls without an explicit compat routine will just
34892 @@ -1072,10 +1071,8 @@ long drm_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
34893 if (nr >= ARRAY_SIZE(drm_compat_ioctls))
34894 return drm_ioctl(filp, cmd, arg);
34895
34896 - fn = drm_compat_ioctls[nr];
34897 -
34898 - if (fn != NULL)
34899 - ret = (*fn) (filp, cmd, arg);
34900 + if (drm_compat_ioctls[nr] != NULL)
34901 + ret = (*drm_compat_ioctls[nr]) (filp, cmd, arg);
34902 else
34903 ret = drm_ioctl(filp, cmd, arg);
34904
34905 diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c
34906 index e77bd8b..1571b85 100644
34907 --- a/drivers/gpu/drm/drm_ioctl.c
34908 +++ b/drivers/gpu/drm/drm_ioctl.c
34909 @@ -252,7 +252,7 @@ int drm_getstats(struct drm_device *dev, void *data,
34910 stats->data[i].value =
34911 (file_priv->master->lock.hw_lock ? file_priv->master->lock.hw_lock->lock : 0);
34912 else
34913 - stats->data[i].value = atomic_read(&dev->counts[i]);
34914 + stats->data[i].value = atomic_read_unchecked(&dev->counts[i]);
34915 stats->data[i].type = dev->types[i];
34916 }
34917
34918 diff --git a/drivers/gpu/drm/drm_lock.c b/drivers/gpu/drm/drm_lock.c
34919 index d752c96..fe08455 100644
34920 --- a/drivers/gpu/drm/drm_lock.c
34921 +++ b/drivers/gpu/drm/drm_lock.c
34922 @@ -86,7 +86,7 @@ int drm_lock(struct drm_device *dev, void *data, struct drm_file *file_priv)
34923 if (drm_lock_take(&master->lock, lock->context)) {
34924 master->lock.file_priv = file_priv;
34925 master->lock.lock_time = jiffies;
34926 - atomic_inc(&dev->counts[_DRM_STAT_LOCKS]);
34927 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_LOCKS]);
34928 break; /* Got lock */
34929 }
34930
34931 @@ -157,7 +157,7 @@ int drm_unlock(struct drm_device *dev, void *data, struct drm_file *file_priv)
34932 return -EINVAL;
34933 }
34934
34935 - atomic_inc(&dev->counts[_DRM_STAT_UNLOCKS]);
34936 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_UNLOCKS]);
34937
34938 if (drm_lock_free(&master->lock, lock->context)) {
34939 /* FIXME: Should really bail out here. */
34940 diff --git a/drivers/gpu/drm/drm_stub.c b/drivers/gpu/drm/drm_stub.c
34941 index 200e104..59facda 100644
34942 --- a/drivers/gpu/drm/drm_stub.c
34943 +++ b/drivers/gpu/drm/drm_stub.c
34944 @@ -516,7 +516,7 @@ void drm_unplug_dev(struct drm_device *dev)
34945
34946 drm_device_set_unplugged(dev);
34947
34948 - if (dev->open_count == 0) {
34949 + if (local_read(&dev->open_count) == 0) {
34950 drm_put_dev(dev);
34951 }
34952 mutex_unlock(&drm_global_mutex);
34953 diff --git a/drivers/gpu/drm/i810/i810_dma.c b/drivers/gpu/drm/i810/i810_dma.c
34954 index 004ecdf..db1f6e0 100644
34955 --- a/drivers/gpu/drm/i810/i810_dma.c
34956 +++ b/drivers/gpu/drm/i810/i810_dma.c
34957 @@ -945,8 +945,8 @@ static int i810_dma_vertex(struct drm_device *dev, void *data,
34958 dma->buflist[vertex->idx],
34959 vertex->discard, vertex->used);
34960
34961 - atomic_add(vertex->used, &dev->counts[_DRM_STAT_SECONDARY]);
34962 - atomic_inc(&dev->counts[_DRM_STAT_DMA]);
34963 + atomic_add_unchecked(vertex->used, &dev->counts[_DRM_STAT_SECONDARY]);
34964 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_DMA]);
34965 sarea_priv->last_enqueue = dev_priv->counter - 1;
34966 sarea_priv->last_dispatch = (int)hw_status[5];
34967
34968 @@ -1106,8 +1106,8 @@ static int i810_dma_mc(struct drm_device *dev, void *data,
34969 i810_dma_dispatch_mc(dev, dma->buflist[mc->idx], mc->used,
34970 mc->last_render);
34971
34972 - atomic_add(mc->used, &dev->counts[_DRM_STAT_SECONDARY]);
34973 - atomic_inc(&dev->counts[_DRM_STAT_DMA]);
34974 + atomic_add_unchecked(mc->used, &dev->counts[_DRM_STAT_SECONDARY]);
34975 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_DMA]);
34976 sarea_priv->last_enqueue = dev_priv->counter - 1;
34977 sarea_priv->last_dispatch = (int)hw_status[5];
34978
34979 diff --git a/drivers/gpu/drm/i810/i810_drv.h b/drivers/gpu/drm/i810/i810_drv.h
34980 index 6e0acad..93c8289 100644
34981 --- a/drivers/gpu/drm/i810/i810_drv.h
34982 +++ b/drivers/gpu/drm/i810/i810_drv.h
34983 @@ -108,8 +108,8 @@ typedef struct drm_i810_private {
34984 int page_flipping;
34985
34986 wait_queue_head_t irq_queue;
34987 - atomic_t irq_received;
34988 - atomic_t irq_emitted;
34989 + atomic_unchecked_t irq_received;
34990 + atomic_unchecked_t irq_emitted;
34991
34992 int front_offset;
34993 } drm_i810_private_t;
34994 diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c
34995 index 8a7c48b..72effc2 100644
34996 --- a/drivers/gpu/drm/i915/i915_debugfs.c
34997 +++ b/drivers/gpu/drm/i915/i915_debugfs.c
34998 @@ -496,7 +496,7 @@ static int i915_interrupt_info(struct seq_file *m, void *data)
34999 I915_READ(GTIMR));
35000 }
35001 seq_printf(m, "Interrupts received: %d\n",
35002 - atomic_read(&dev_priv->irq_received));
35003 + atomic_read_unchecked(&dev_priv->irq_received));
35004 for_each_ring(ring, dev_priv, i) {
35005 if (IS_GEN6(dev) || IS_GEN7(dev)) {
35006 seq_printf(m,
35007 diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c
35008 index 99daa89..84ebd44 100644
35009 --- a/drivers/gpu/drm/i915/i915_dma.c
35010 +++ b/drivers/gpu/drm/i915/i915_dma.c
35011 @@ -1253,7 +1253,7 @@ static bool i915_switcheroo_can_switch(struct pci_dev *pdev)
35012 bool can_switch;
35013
35014 spin_lock(&dev->count_lock);
35015 - can_switch = (dev->open_count == 0);
35016 + can_switch = (local_read(&dev->open_count) == 0);
35017 spin_unlock(&dev->count_lock);
35018 return can_switch;
35019 }
35020 diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
35021 index 7339a4b..445aaba 100644
35022 --- a/drivers/gpu/drm/i915/i915_drv.h
35023 +++ b/drivers/gpu/drm/i915/i915_drv.h
35024 @@ -656,7 +656,7 @@ typedef struct drm_i915_private {
35025 drm_dma_handle_t *status_page_dmah;
35026 struct resource mch_res;
35027
35028 - atomic_t irq_received;
35029 + atomic_unchecked_t irq_received;
35030
35031 /* protects the irq masks */
35032 spinlock_t irq_lock;
35033 @@ -1102,7 +1102,7 @@ struct drm_i915_gem_object {
35034 * will be page flipped away on the next vblank. When it
35035 * reaches 0, dev_priv->pending_flip_queue will be woken up.
35036 */
35037 - atomic_t pending_flip;
35038 + atomic_unchecked_t pending_flip;
35039 };
35040 #define to_gem_object(obj) (&((struct drm_i915_gem_object *)(obj))->base)
35041
35042 @@ -1633,7 +1633,7 @@ extern struct i2c_adapter *intel_gmbus_get_adapter(
35043 struct drm_i915_private *dev_priv, unsigned port);
35044 extern void intel_gmbus_set_speed(struct i2c_adapter *adapter, int speed);
35045 extern void intel_gmbus_force_bit(struct i2c_adapter *adapter, bool force_bit);
35046 -extern inline bool intel_gmbus_is_forced_bit(struct i2c_adapter *adapter)
35047 +static inline bool intel_gmbus_is_forced_bit(struct i2c_adapter *adapter)
35048 {
35049 return container_of(adapter, struct intel_gmbus, adapter)->force_bit;
35050 }
35051 diff --git a/drivers/gpu/drm/i915/i915_gem_execbuffer.c b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
35052 index 26d08bb..e24fb51 100644
35053 --- a/drivers/gpu/drm/i915/i915_gem_execbuffer.c
35054 +++ b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
35055 @@ -672,7 +672,7 @@ i915_gem_execbuffer_move_to_gpu(struct intel_ring_buffer *ring,
35056 i915_gem_clflush_object(obj);
35057
35058 if (obj->base.pending_write_domain)
35059 - flips |= atomic_read(&obj->pending_flip);
35060 + flips |= atomic_read_unchecked(&obj->pending_flip);
35061
35062 flush_domains |= obj->base.write_domain;
35063 }
35064 @@ -703,18 +703,23 @@ i915_gem_check_execbuffer(struct drm_i915_gem_execbuffer2 *exec)
35065
35066 static int
35067 validate_exec_list(struct drm_i915_gem_exec_object2 *exec,
35068 - int count)
35069 + unsigned int count)
35070 {
35071 - int i;
35072 + unsigned int i;
35073 + int relocs_total = 0;
35074 + int relocs_max = INT_MAX / sizeof(struct drm_i915_gem_relocation_entry);
35075
35076 for (i = 0; i < count; i++) {
35077 char __user *ptr = (char __user *)(uintptr_t)exec[i].relocs_ptr;
35078 int length; /* limited by fault_in_pages_readable() */
35079
35080 - /* First check for malicious input causing overflow */
35081 - if (exec[i].relocation_count >
35082 - INT_MAX / sizeof(struct drm_i915_gem_relocation_entry))
35083 + /* First check for malicious input causing overflow in
35084 + * the worst case where we need to allocate the entire
35085 + * relocation tree as a single array.
35086 + */
35087 + if (exec[i].relocation_count > relocs_max - relocs_total)
35088 return -EINVAL;
35089 + relocs_total += exec[i].relocation_count;
35090
35091 length = exec[i].relocation_count *
35092 sizeof(struct drm_i915_gem_relocation_entry);
35093 @@ -1197,7 +1202,7 @@ i915_gem_execbuffer2(struct drm_device *dev, void *data,
35094 return -ENOMEM;
35095 }
35096 ret = copy_from_user(exec2_list,
35097 - (struct drm_i915_relocation_entry __user *)
35098 + (struct drm_i915_gem_exec_object2 __user *)
35099 (uintptr_t) args->buffers_ptr,
35100 sizeof(*exec2_list) * args->buffer_count);
35101 if (ret != 0) {
35102 diff --git a/drivers/gpu/drm/i915/i915_ioc32.c b/drivers/gpu/drm/i915/i915_ioc32.c
35103 index 3c59584..500f2e9 100644
35104 --- a/drivers/gpu/drm/i915/i915_ioc32.c
35105 +++ b/drivers/gpu/drm/i915/i915_ioc32.c
35106 @@ -181,7 +181,7 @@ static int compat_i915_alloc(struct file *file, unsigned int cmd,
35107 (unsigned long)request);
35108 }
35109
35110 -static drm_ioctl_compat_t *i915_compat_ioctls[] = {
35111 +static drm_ioctl_compat_t i915_compat_ioctls[] = {
35112 [DRM_I915_BATCHBUFFER] = compat_i915_batchbuffer,
35113 [DRM_I915_CMDBUFFER] = compat_i915_cmdbuffer,
35114 [DRM_I915_GETPARAM] = compat_i915_getparam,
35115 @@ -202,18 +202,15 @@ static drm_ioctl_compat_t *i915_compat_ioctls[] = {
35116 long i915_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
35117 {
35118 unsigned int nr = DRM_IOCTL_NR(cmd);
35119 - drm_ioctl_compat_t *fn = NULL;
35120 int ret;
35121
35122 if (nr < DRM_COMMAND_BASE)
35123 return drm_compat_ioctl(filp, cmd, arg);
35124
35125 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(i915_compat_ioctls))
35126 - fn = i915_compat_ioctls[nr - DRM_COMMAND_BASE];
35127 -
35128 - if (fn != NULL)
35129 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(i915_compat_ioctls)) {
35130 + drm_ioctl_compat_t fn = i915_compat_ioctls[nr - DRM_COMMAND_BASE];
35131 ret = (*fn) (filp, cmd, arg);
35132 - else
35133 + } else
35134 ret = drm_ioctl(filp, cmd, arg);
35135
35136 return ret;
35137 diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c
35138 index fe84338..a863190 100644
35139 --- a/drivers/gpu/drm/i915/i915_irq.c
35140 +++ b/drivers/gpu/drm/i915/i915_irq.c
35141 @@ -535,7 +535,7 @@ static irqreturn_t valleyview_irq_handler(int irq, void *arg)
35142 u32 pipe_stats[I915_MAX_PIPES];
35143 bool blc_event;
35144
35145 - atomic_inc(&dev_priv->irq_received);
35146 + atomic_inc_unchecked(&dev_priv->irq_received);
35147
35148 while (true) {
35149 iir = I915_READ(VLV_IIR);
35150 @@ -688,7 +688,7 @@ static irqreturn_t ivybridge_irq_handler(int irq, void *arg)
35151 irqreturn_t ret = IRQ_NONE;
35152 int i;
35153
35154 - atomic_inc(&dev_priv->irq_received);
35155 + atomic_inc_unchecked(&dev_priv->irq_received);
35156
35157 /* disable master interrupt before clearing iir */
35158 de_ier = I915_READ(DEIER);
35159 @@ -760,7 +760,7 @@ static irqreturn_t ironlake_irq_handler(int irq, void *arg)
35160 int ret = IRQ_NONE;
35161 u32 de_iir, gt_iir, de_ier, pch_iir, pm_iir;
35162
35163 - atomic_inc(&dev_priv->irq_received);
35164 + atomic_inc_unchecked(&dev_priv->irq_received);
35165
35166 /* disable master interrupt before clearing iir */
35167 de_ier = I915_READ(DEIER);
35168 @@ -1787,7 +1787,7 @@ static void ironlake_irq_preinstall(struct drm_device *dev)
35169 {
35170 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
35171
35172 - atomic_set(&dev_priv->irq_received, 0);
35173 + atomic_set_unchecked(&dev_priv->irq_received, 0);
35174
35175 I915_WRITE(HWSTAM, 0xeffe);
35176
35177 @@ -1813,7 +1813,7 @@ static void valleyview_irq_preinstall(struct drm_device *dev)
35178 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
35179 int pipe;
35180
35181 - atomic_set(&dev_priv->irq_received, 0);
35182 + atomic_set_unchecked(&dev_priv->irq_received, 0);
35183
35184 /* VLV magic */
35185 I915_WRITE(VLV_IMR, 0);
35186 @@ -2108,7 +2108,7 @@ static void i8xx_irq_preinstall(struct drm_device * dev)
35187 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
35188 int pipe;
35189
35190 - atomic_set(&dev_priv->irq_received, 0);
35191 + atomic_set_unchecked(&dev_priv->irq_received, 0);
35192
35193 for_each_pipe(pipe)
35194 I915_WRITE(PIPESTAT(pipe), 0);
35195 @@ -2159,7 +2159,7 @@ static irqreturn_t i8xx_irq_handler(int irq, void *arg)
35196 I915_DISPLAY_PLANE_A_FLIP_PENDING_INTERRUPT |
35197 I915_DISPLAY_PLANE_B_FLIP_PENDING_INTERRUPT;
35198
35199 - atomic_inc(&dev_priv->irq_received);
35200 + atomic_inc_unchecked(&dev_priv->irq_received);
35201
35202 iir = I915_READ16(IIR);
35203 if (iir == 0)
35204 @@ -2244,7 +2244,7 @@ static void i915_irq_preinstall(struct drm_device * dev)
35205 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
35206 int pipe;
35207
35208 - atomic_set(&dev_priv->irq_received, 0);
35209 + atomic_set_unchecked(&dev_priv->irq_received, 0);
35210
35211 if (I915_HAS_HOTPLUG(dev)) {
35212 I915_WRITE(PORT_HOTPLUG_EN, 0);
35213 @@ -2339,7 +2339,7 @@ static irqreturn_t i915_irq_handler(int irq, void *arg)
35214 };
35215 int pipe, ret = IRQ_NONE;
35216
35217 - atomic_inc(&dev_priv->irq_received);
35218 + atomic_inc_unchecked(&dev_priv->irq_received);
35219
35220 iir = I915_READ(IIR);
35221 do {
35222 @@ -2465,7 +2465,7 @@ static void i965_irq_preinstall(struct drm_device * dev)
35223 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
35224 int pipe;
35225
35226 - atomic_set(&dev_priv->irq_received, 0);
35227 + atomic_set_unchecked(&dev_priv->irq_received, 0);
35228
35229 I915_WRITE(PORT_HOTPLUG_EN, 0);
35230 I915_WRITE(PORT_HOTPLUG_STAT, I915_READ(PORT_HOTPLUG_STAT));
35231 @@ -2572,7 +2572,7 @@ static irqreturn_t i965_irq_handler(int irq, void *arg)
35232 int irq_received;
35233 int ret = IRQ_NONE, pipe;
35234
35235 - atomic_inc(&dev_priv->irq_received);
35236 + atomic_inc_unchecked(&dev_priv->irq_received);
35237
35238 iir = I915_READ(IIR);
35239
35240 diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
35241 index 80aa1fc..85cfce3 100644
35242 --- a/drivers/gpu/drm/i915/intel_display.c
35243 +++ b/drivers/gpu/drm/i915/intel_display.c
35244 @@ -2255,7 +2255,7 @@ intel_finish_fb(struct drm_framebuffer *old_fb)
35245
35246 wait_event(dev_priv->pending_flip_queue,
35247 atomic_read(&dev_priv->mm.wedged) ||
35248 - atomic_read(&obj->pending_flip) == 0);
35249 + atomic_read_unchecked(&obj->pending_flip) == 0);
35250
35251 /* Big Hammer, we also need to ensure that any pending
35252 * MI_WAIT_FOR_EVENT inside a user batch buffer on the
35253 @@ -7122,8 +7122,7 @@ static void do_intel_finish_page_flip(struct drm_device *dev,
35254
35255 obj = work->old_fb_obj;
35256
35257 - atomic_clear_mask(1 << intel_crtc->plane,
35258 - &obj->pending_flip.counter);
35259 + atomic_clear_mask_unchecked(1 << intel_crtc->plane, &obj->pending_flip);
35260 wake_up(&dev_priv->pending_flip_queue);
35261
35262 queue_work(dev_priv->wq, &work->work);
35263 @@ -7490,7 +7489,7 @@ static int intel_crtc_page_flip(struct drm_crtc *crtc,
35264 /* Block clients from rendering to the new back buffer until
35265 * the flip occurs and the object is no longer visible.
35266 */
35267 - atomic_add(1 << intel_crtc->plane, &work->old_fb_obj->pending_flip);
35268 + atomic_add_unchecked(1 << intel_crtc->plane, &work->old_fb_obj->pending_flip);
35269 atomic_inc(&intel_crtc->unpin_work_count);
35270
35271 ret = dev_priv->display.queue_flip(dev, crtc, fb, obj);
35272 @@ -7507,7 +7506,7 @@ static int intel_crtc_page_flip(struct drm_crtc *crtc,
35273
35274 cleanup_pending:
35275 atomic_dec(&intel_crtc->unpin_work_count);
35276 - atomic_sub(1 << intel_crtc->plane, &work->old_fb_obj->pending_flip);
35277 + atomic_sub_unchecked(1 << intel_crtc->plane, &work->old_fb_obj->pending_flip);
35278 drm_gem_object_unreference(&work->old_fb_obj->base);
35279 drm_gem_object_unreference(&obj->base);
35280 mutex_unlock(&dev->struct_mutex);
35281 @@ -8849,13 +8848,13 @@ struct intel_quirk {
35282 int subsystem_vendor;
35283 int subsystem_device;
35284 void (*hook)(struct drm_device *dev);
35285 -};
35286 +} __do_const;
35287
35288 /* For systems that don't have a meaningful PCI subdevice/subvendor ID */
35289 struct intel_dmi_quirk {
35290 void (*hook)(struct drm_device *dev);
35291 const struct dmi_system_id (*dmi_id_list)[];
35292 -};
35293 +} __do_const;
35294
35295 static int intel_dmi_reverse_brightness(const struct dmi_system_id *id)
35296 {
35297 @@ -8863,18 +8862,20 @@ static int intel_dmi_reverse_brightness(const struct dmi_system_id *id)
35298 return 1;
35299 }
35300
35301 +static const struct dmi_system_id intel_dmi_quirks_table[] = {
35302 + {
35303 + .callback = intel_dmi_reverse_brightness,
35304 + .ident = "NCR Corporation",
35305 + .matches = {DMI_MATCH(DMI_SYS_VENDOR, "NCR Corporation"),
35306 + DMI_MATCH(DMI_PRODUCT_NAME, ""),
35307 + },
35308 + },
35309 + { } /* terminating entry */
35310 +};
35311 +
35312 static const struct intel_dmi_quirk intel_dmi_quirks[] = {
35313 {
35314 - .dmi_id_list = &(const struct dmi_system_id[]) {
35315 - {
35316 - .callback = intel_dmi_reverse_brightness,
35317 - .ident = "NCR Corporation",
35318 - .matches = {DMI_MATCH(DMI_SYS_VENDOR, "NCR Corporation"),
35319 - DMI_MATCH(DMI_PRODUCT_NAME, ""),
35320 - },
35321 - },
35322 - { } /* terminating entry */
35323 - },
35324 + .dmi_id_list = &intel_dmi_quirks_table,
35325 .hook = quirk_invert_brightness,
35326 },
35327 };
35328 diff --git a/drivers/gpu/drm/mga/mga_drv.h b/drivers/gpu/drm/mga/mga_drv.h
35329 index 54558a0..2d97005 100644
35330 --- a/drivers/gpu/drm/mga/mga_drv.h
35331 +++ b/drivers/gpu/drm/mga/mga_drv.h
35332 @@ -120,9 +120,9 @@ typedef struct drm_mga_private {
35333 u32 clear_cmd;
35334 u32 maccess;
35335
35336 - atomic_t vbl_received; /**< Number of vblanks received. */
35337 + atomic_unchecked_t vbl_received; /**< Number of vblanks received. */
35338 wait_queue_head_t fence_queue;
35339 - atomic_t last_fence_retired;
35340 + atomic_unchecked_t last_fence_retired;
35341 u32 next_fence_to_post;
35342
35343 unsigned int fb_cpp;
35344 diff --git a/drivers/gpu/drm/mga/mga_ioc32.c b/drivers/gpu/drm/mga/mga_ioc32.c
35345 index 709e90d..89a1c0d 100644
35346 --- a/drivers/gpu/drm/mga/mga_ioc32.c
35347 +++ b/drivers/gpu/drm/mga/mga_ioc32.c
35348 @@ -189,7 +189,7 @@ static int compat_mga_dma_bootstrap(struct file *file, unsigned int cmd,
35349 return 0;
35350 }
35351
35352 -drm_ioctl_compat_t *mga_compat_ioctls[] = {
35353 +drm_ioctl_compat_t mga_compat_ioctls[] = {
35354 [DRM_MGA_INIT] = compat_mga_init,
35355 [DRM_MGA_GETPARAM] = compat_mga_getparam,
35356 [DRM_MGA_DMA_BOOTSTRAP] = compat_mga_dma_bootstrap,
35357 @@ -207,18 +207,15 @@ drm_ioctl_compat_t *mga_compat_ioctls[] = {
35358 long mga_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
35359 {
35360 unsigned int nr = DRM_IOCTL_NR(cmd);
35361 - drm_ioctl_compat_t *fn = NULL;
35362 int ret;
35363
35364 if (nr < DRM_COMMAND_BASE)
35365 return drm_compat_ioctl(filp, cmd, arg);
35366
35367 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(mga_compat_ioctls))
35368 - fn = mga_compat_ioctls[nr - DRM_COMMAND_BASE];
35369 -
35370 - if (fn != NULL)
35371 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(mga_compat_ioctls)) {
35372 + drm_ioctl_compat_t fn = mga_compat_ioctls[nr - DRM_COMMAND_BASE];
35373 ret = (*fn) (filp, cmd, arg);
35374 - else
35375 + } else
35376 ret = drm_ioctl(filp, cmd, arg);
35377
35378 return ret;
35379 diff --git a/drivers/gpu/drm/mga/mga_irq.c b/drivers/gpu/drm/mga/mga_irq.c
35380 index 598c281..60d590e 100644
35381 --- a/drivers/gpu/drm/mga/mga_irq.c
35382 +++ b/drivers/gpu/drm/mga/mga_irq.c
35383 @@ -43,7 +43,7 @@ u32 mga_get_vblank_counter(struct drm_device *dev, int crtc)
35384 if (crtc != 0)
35385 return 0;
35386
35387 - return atomic_read(&dev_priv->vbl_received);
35388 + return atomic_read_unchecked(&dev_priv->vbl_received);
35389 }
35390
35391
35392 @@ -59,7 +59,7 @@ irqreturn_t mga_driver_irq_handler(DRM_IRQ_ARGS)
35393 /* VBLANK interrupt */
35394 if (status & MGA_VLINEPEN) {
35395 MGA_WRITE(MGA_ICLEAR, MGA_VLINEICLR);
35396 - atomic_inc(&dev_priv->vbl_received);
35397 + atomic_inc_unchecked(&dev_priv->vbl_received);
35398 drm_handle_vblank(dev, 0);
35399 handled = 1;
35400 }
35401 @@ -78,7 +78,7 @@ irqreturn_t mga_driver_irq_handler(DRM_IRQ_ARGS)
35402 if ((prim_start & ~0x03) != (prim_end & ~0x03))
35403 MGA_WRITE(MGA_PRIMEND, prim_end);
35404
35405 - atomic_inc(&dev_priv->last_fence_retired);
35406 + atomic_inc_unchecked(&dev_priv->last_fence_retired);
35407 DRM_WAKEUP(&dev_priv->fence_queue);
35408 handled = 1;
35409 }
35410 @@ -129,7 +129,7 @@ int mga_driver_fence_wait(struct drm_device *dev, unsigned int *sequence)
35411 * using fences.
35412 */
35413 DRM_WAIT_ON(ret, dev_priv->fence_queue, 3 * DRM_HZ,
35414 - (((cur_fence = atomic_read(&dev_priv->last_fence_retired))
35415 + (((cur_fence = atomic_read_unchecked(&dev_priv->last_fence_retired))
35416 - *sequence) <= (1 << 23)));
35417
35418 *sequence = cur_fence;
35419 diff --git a/drivers/gpu/drm/nouveau/nouveau_bios.c b/drivers/gpu/drm/nouveau/nouveau_bios.c
35420 index 865eddf..62c4cc3 100644
35421 --- a/drivers/gpu/drm/nouveau/nouveau_bios.c
35422 +++ b/drivers/gpu/drm/nouveau/nouveau_bios.c
35423 @@ -1015,7 +1015,7 @@ static int parse_bit_tmds_tbl_entry(struct drm_device *dev, struct nvbios *bios,
35424 struct bit_table {
35425 const char id;
35426 int (* const parse_fn)(struct drm_device *, struct nvbios *, struct bit_entry *);
35427 -};
35428 +} __no_const;
35429
35430 #define BIT_TABLE(id, funcid) ((struct bit_table){ id, parse_bit_##funcid##_tbl_entry })
35431
35432 diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.h b/drivers/gpu/drm/nouveau/nouveau_drm.h
35433 index aa89eb9..d45d38b 100644
35434 --- a/drivers/gpu/drm/nouveau/nouveau_drm.h
35435 +++ b/drivers/gpu/drm/nouveau/nouveau_drm.h
35436 @@ -80,7 +80,7 @@ struct nouveau_drm {
35437 struct drm_global_reference mem_global_ref;
35438 struct ttm_bo_global_ref bo_global_ref;
35439 struct ttm_bo_device bdev;
35440 - atomic_t validate_sequence;
35441 + atomic_unchecked_t validate_sequence;
35442 int (*move)(struct nouveau_channel *,
35443 struct ttm_buffer_object *,
35444 struct ttm_mem_reg *, struct ttm_mem_reg *);
35445 diff --git a/drivers/gpu/drm/nouveau/nouveau_fence.h b/drivers/gpu/drm/nouveau/nouveau_fence.h
35446 index cdb83ac..27f0a16 100644
35447 --- a/drivers/gpu/drm/nouveau/nouveau_fence.h
35448 +++ b/drivers/gpu/drm/nouveau/nouveau_fence.h
35449 @@ -43,7 +43,7 @@ struct nouveau_fence_priv {
35450 int (*sync)(struct nouveau_fence *, struct nouveau_channel *,
35451 struct nouveau_channel *);
35452 u32 (*read)(struct nouveau_channel *);
35453 -};
35454 +} __no_const;
35455
35456 #define nouveau_fence(drm) ((struct nouveau_fence_priv *)(drm)->fence)
35457
35458 diff --git a/drivers/gpu/drm/nouveau/nouveau_gem.c b/drivers/gpu/drm/nouveau/nouveau_gem.c
35459 index 8bf695c..9fbc90a 100644
35460 --- a/drivers/gpu/drm/nouveau/nouveau_gem.c
35461 +++ b/drivers/gpu/drm/nouveau/nouveau_gem.c
35462 @@ -321,7 +321,7 @@ validate_init(struct nouveau_channel *chan, struct drm_file *file_priv,
35463 int trycnt = 0;
35464 int ret, i;
35465
35466 - sequence = atomic_add_return(1, &drm->ttm.validate_sequence);
35467 + sequence = atomic_add_return_unchecked(1, &drm->ttm.validate_sequence);
35468 retry:
35469 if (++trycnt > 100000) {
35470 NV_ERROR(drm, "%s failed and gave up.\n", __func__);
35471 diff --git a/drivers/gpu/drm/nouveau/nouveau_ioc32.c b/drivers/gpu/drm/nouveau/nouveau_ioc32.c
35472 index 08214bc..9208577 100644
35473 --- a/drivers/gpu/drm/nouveau/nouveau_ioc32.c
35474 +++ b/drivers/gpu/drm/nouveau/nouveau_ioc32.c
35475 @@ -50,7 +50,7 @@ long nouveau_compat_ioctl(struct file *filp, unsigned int cmd,
35476 unsigned long arg)
35477 {
35478 unsigned int nr = DRM_IOCTL_NR(cmd);
35479 - drm_ioctl_compat_t *fn = NULL;
35480 + drm_ioctl_compat_t fn = NULL;
35481 int ret;
35482
35483 if (nr < DRM_COMMAND_BASE)
35484 diff --git a/drivers/gpu/drm/nouveau/nouveau_vga.c b/drivers/gpu/drm/nouveau/nouveau_vga.c
35485 index 25d3495..d81aaf6 100644
35486 --- a/drivers/gpu/drm/nouveau/nouveau_vga.c
35487 +++ b/drivers/gpu/drm/nouveau/nouveau_vga.c
35488 @@ -62,7 +62,7 @@ nouveau_switcheroo_can_switch(struct pci_dev *pdev)
35489 bool can_switch;
35490
35491 spin_lock(&dev->count_lock);
35492 - can_switch = (dev->open_count == 0);
35493 + can_switch = (local_read(&dev->open_count) == 0);
35494 spin_unlock(&dev->count_lock);
35495 return can_switch;
35496 }
35497 diff --git a/drivers/gpu/drm/r128/r128_cce.c b/drivers/gpu/drm/r128/r128_cce.c
35498 index d4660cf..70dbe65 100644
35499 --- a/drivers/gpu/drm/r128/r128_cce.c
35500 +++ b/drivers/gpu/drm/r128/r128_cce.c
35501 @@ -377,7 +377,7 @@ static int r128_do_init_cce(struct drm_device *dev, drm_r128_init_t *init)
35502
35503 /* GH: Simple idle check.
35504 */
35505 - atomic_set(&dev_priv->idle_count, 0);
35506 + atomic_set_unchecked(&dev_priv->idle_count, 0);
35507
35508 /* We don't support anything other than bus-mastering ring mode,
35509 * but the ring can be in either AGP or PCI space for the ring
35510 diff --git a/drivers/gpu/drm/r128/r128_drv.h b/drivers/gpu/drm/r128/r128_drv.h
35511 index 930c71b..499aded 100644
35512 --- a/drivers/gpu/drm/r128/r128_drv.h
35513 +++ b/drivers/gpu/drm/r128/r128_drv.h
35514 @@ -90,14 +90,14 @@ typedef struct drm_r128_private {
35515 int is_pci;
35516 unsigned long cce_buffers_offset;
35517
35518 - atomic_t idle_count;
35519 + atomic_unchecked_t idle_count;
35520
35521 int page_flipping;
35522 int current_page;
35523 u32 crtc_offset;
35524 u32 crtc_offset_cntl;
35525
35526 - atomic_t vbl_received;
35527 + atomic_unchecked_t vbl_received;
35528
35529 u32 color_fmt;
35530 unsigned int front_offset;
35531 diff --git a/drivers/gpu/drm/r128/r128_ioc32.c b/drivers/gpu/drm/r128/r128_ioc32.c
35532 index a954c54..9cc595c 100644
35533 --- a/drivers/gpu/drm/r128/r128_ioc32.c
35534 +++ b/drivers/gpu/drm/r128/r128_ioc32.c
35535 @@ -177,7 +177,7 @@ static int compat_r128_getparam(struct file *file, unsigned int cmd,
35536 return drm_ioctl(file, DRM_IOCTL_R128_GETPARAM, (unsigned long)getparam);
35537 }
35538
35539 -drm_ioctl_compat_t *r128_compat_ioctls[] = {
35540 +drm_ioctl_compat_t r128_compat_ioctls[] = {
35541 [DRM_R128_INIT] = compat_r128_init,
35542 [DRM_R128_DEPTH] = compat_r128_depth,
35543 [DRM_R128_STIPPLE] = compat_r128_stipple,
35544 @@ -196,18 +196,15 @@ drm_ioctl_compat_t *r128_compat_ioctls[] = {
35545 long r128_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
35546 {
35547 unsigned int nr = DRM_IOCTL_NR(cmd);
35548 - drm_ioctl_compat_t *fn = NULL;
35549 int ret;
35550
35551 if (nr < DRM_COMMAND_BASE)
35552 return drm_compat_ioctl(filp, cmd, arg);
35553
35554 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(r128_compat_ioctls))
35555 - fn = r128_compat_ioctls[nr - DRM_COMMAND_BASE];
35556 -
35557 - if (fn != NULL)
35558 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(r128_compat_ioctls)) {
35559 + drm_ioctl_compat_t fn = r128_compat_ioctls[nr - DRM_COMMAND_BASE];
35560 ret = (*fn) (filp, cmd, arg);
35561 - else
35562 + } else
35563 ret = drm_ioctl(filp, cmd, arg);
35564
35565 return ret;
35566 diff --git a/drivers/gpu/drm/r128/r128_irq.c b/drivers/gpu/drm/r128/r128_irq.c
35567 index 2ea4f09..d391371 100644
35568 --- a/drivers/gpu/drm/r128/r128_irq.c
35569 +++ b/drivers/gpu/drm/r128/r128_irq.c
35570 @@ -41,7 +41,7 @@ u32 r128_get_vblank_counter(struct drm_device *dev, int crtc)
35571 if (crtc != 0)
35572 return 0;
35573
35574 - return atomic_read(&dev_priv->vbl_received);
35575 + return atomic_read_unchecked(&dev_priv->vbl_received);
35576 }
35577
35578 irqreturn_t r128_driver_irq_handler(DRM_IRQ_ARGS)
35579 @@ -55,7 +55,7 @@ irqreturn_t r128_driver_irq_handler(DRM_IRQ_ARGS)
35580 /* VBLANK interrupt */
35581 if (status & R128_CRTC_VBLANK_INT) {
35582 R128_WRITE(R128_GEN_INT_STATUS, R128_CRTC_VBLANK_INT_AK);
35583 - atomic_inc(&dev_priv->vbl_received);
35584 + atomic_inc_unchecked(&dev_priv->vbl_received);
35585 drm_handle_vblank(dev, 0);
35586 return IRQ_HANDLED;
35587 }
35588 diff --git a/drivers/gpu/drm/r128/r128_state.c b/drivers/gpu/drm/r128/r128_state.c
35589 index 19bb7e6..de7e2a2 100644
35590 --- a/drivers/gpu/drm/r128/r128_state.c
35591 +++ b/drivers/gpu/drm/r128/r128_state.c
35592 @@ -320,10 +320,10 @@ static void r128_clear_box(drm_r128_private_t *dev_priv,
35593
35594 static void r128_cce_performance_boxes(drm_r128_private_t *dev_priv)
35595 {
35596 - if (atomic_read(&dev_priv->idle_count) == 0)
35597 + if (atomic_read_unchecked(&dev_priv->idle_count) == 0)
35598 r128_clear_box(dev_priv, 64, 4, 8, 8, 0, 255, 0);
35599 else
35600 - atomic_set(&dev_priv->idle_count, 0);
35601 + atomic_set_unchecked(&dev_priv->idle_count, 0);
35602 }
35603
35604 #endif
35605 diff --git a/drivers/gpu/drm/radeon/mkregtable.c b/drivers/gpu/drm/radeon/mkregtable.c
35606 index 5a82b6b..9e69c73 100644
35607 --- a/drivers/gpu/drm/radeon/mkregtable.c
35608 +++ b/drivers/gpu/drm/radeon/mkregtable.c
35609 @@ -637,14 +637,14 @@ static int parser_auth(struct table *t, const char *filename)
35610 regex_t mask_rex;
35611 regmatch_t match[4];
35612 char buf[1024];
35613 - size_t end;
35614 + long end;
35615 int len;
35616 int done = 0;
35617 int r;
35618 unsigned o;
35619 struct offset *offset;
35620 char last_reg_s[10];
35621 - int last_reg;
35622 + unsigned long last_reg;
35623
35624 if (regcomp
35625 (&mask_rex, "(0x[0-9a-fA-F]*) *([_a-zA-Z0-9]*)", REG_EXTENDED)) {
35626 diff --git a/drivers/gpu/drm/radeon/radeon_device.c b/drivers/gpu/drm/radeon/radeon_device.c
35627 index 0d6562b..a154330 100644
35628 --- a/drivers/gpu/drm/radeon/radeon_device.c
35629 +++ b/drivers/gpu/drm/radeon/radeon_device.c
35630 @@ -969,7 +969,7 @@ static bool radeon_switcheroo_can_switch(struct pci_dev *pdev)
35631 bool can_switch;
35632
35633 spin_lock(&dev->count_lock);
35634 - can_switch = (dev->open_count == 0);
35635 + can_switch = (local_read(&dev->open_count) == 0);
35636 spin_unlock(&dev->count_lock);
35637 return can_switch;
35638 }
35639 diff --git a/drivers/gpu/drm/radeon/radeon_drv.h b/drivers/gpu/drm/radeon/radeon_drv.h
35640 index e7fdf16..f4f6490 100644
35641 --- a/drivers/gpu/drm/radeon/radeon_drv.h
35642 +++ b/drivers/gpu/drm/radeon/radeon_drv.h
35643 @@ -255,7 +255,7 @@ typedef struct drm_radeon_private {
35644
35645 /* SW interrupt */
35646 wait_queue_head_t swi_queue;
35647 - atomic_t swi_emitted;
35648 + atomic_unchecked_t swi_emitted;
35649 int vblank_crtc;
35650 uint32_t irq_enable_reg;
35651 uint32_t r500_disp_irq_reg;
35652 diff --git a/drivers/gpu/drm/radeon/radeon_ioc32.c b/drivers/gpu/drm/radeon/radeon_ioc32.c
35653 index c180df8..5fd8186 100644
35654 --- a/drivers/gpu/drm/radeon/radeon_ioc32.c
35655 +++ b/drivers/gpu/drm/radeon/radeon_ioc32.c
35656 @@ -358,7 +358,7 @@ static int compat_radeon_cp_setparam(struct file *file, unsigned int cmd,
35657 request = compat_alloc_user_space(sizeof(*request));
35658 if (!access_ok(VERIFY_WRITE, request, sizeof(*request))
35659 || __put_user(req32.param, &request->param)
35660 - || __put_user((void __user *)(unsigned long)req32.value,
35661 + || __put_user((unsigned long)req32.value,
35662 &request->value))
35663 return -EFAULT;
35664
35665 @@ -368,7 +368,7 @@ static int compat_radeon_cp_setparam(struct file *file, unsigned int cmd,
35666 #define compat_radeon_cp_setparam NULL
35667 #endif /* X86_64 || IA64 */
35668
35669 -static drm_ioctl_compat_t *radeon_compat_ioctls[] = {
35670 +static drm_ioctl_compat_t radeon_compat_ioctls[] = {
35671 [DRM_RADEON_CP_INIT] = compat_radeon_cp_init,
35672 [DRM_RADEON_CLEAR] = compat_radeon_cp_clear,
35673 [DRM_RADEON_STIPPLE] = compat_radeon_cp_stipple,
35674 @@ -393,18 +393,15 @@ static drm_ioctl_compat_t *radeon_compat_ioctls[] = {
35675 long radeon_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
35676 {
35677 unsigned int nr = DRM_IOCTL_NR(cmd);
35678 - drm_ioctl_compat_t *fn = NULL;
35679 int ret;
35680
35681 if (nr < DRM_COMMAND_BASE)
35682 return drm_compat_ioctl(filp, cmd, arg);
35683
35684 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(radeon_compat_ioctls))
35685 - fn = radeon_compat_ioctls[nr - DRM_COMMAND_BASE];
35686 -
35687 - if (fn != NULL)
35688 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(radeon_compat_ioctls)) {
35689 + drm_ioctl_compat_t fn = radeon_compat_ioctls[nr - DRM_COMMAND_BASE];
35690 ret = (*fn) (filp, cmd, arg);
35691 - else
35692 + } else
35693 ret = drm_ioctl(filp, cmd, arg);
35694
35695 return ret;
35696 diff --git a/drivers/gpu/drm/radeon/radeon_irq.c b/drivers/gpu/drm/radeon/radeon_irq.c
35697 index e771033..a0bc6b3 100644
35698 --- a/drivers/gpu/drm/radeon/radeon_irq.c
35699 +++ b/drivers/gpu/drm/radeon/radeon_irq.c
35700 @@ -224,8 +224,8 @@ static int radeon_emit_irq(struct drm_device * dev)
35701 unsigned int ret;
35702 RING_LOCALS;
35703
35704 - atomic_inc(&dev_priv->swi_emitted);
35705 - ret = atomic_read(&dev_priv->swi_emitted);
35706 + atomic_inc_unchecked(&dev_priv->swi_emitted);
35707 + ret = atomic_read_unchecked(&dev_priv->swi_emitted);
35708
35709 BEGIN_RING(4);
35710 OUT_RING_REG(RADEON_LAST_SWI_REG, ret);
35711 @@ -351,7 +351,7 @@ int radeon_driver_irq_postinstall(struct drm_device *dev)
35712 drm_radeon_private_t *dev_priv =
35713 (drm_radeon_private_t *) dev->dev_private;
35714
35715 - atomic_set(&dev_priv->swi_emitted, 0);
35716 + atomic_set_unchecked(&dev_priv->swi_emitted, 0);
35717 DRM_INIT_WAITQUEUE(&dev_priv->swi_queue);
35718
35719 dev->max_vblank_count = 0x001fffff;
35720 diff --git a/drivers/gpu/drm/radeon/radeon_state.c b/drivers/gpu/drm/radeon/radeon_state.c
35721 index 8e9057b..af6dacb 100644
35722 --- a/drivers/gpu/drm/radeon/radeon_state.c
35723 +++ b/drivers/gpu/drm/radeon/radeon_state.c
35724 @@ -2166,7 +2166,7 @@ static int radeon_cp_clear(struct drm_device *dev, void *data, struct drm_file *
35725 if (sarea_priv->nbox > RADEON_NR_SAREA_CLIPRECTS)
35726 sarea_priv->nbox = RADEON_NR_SAREA_CLIPRECTS;
35727
35728 - if (DRM_COPY_FROM_USER(&depth_boxes, clear->depth_boxes,
35729 + if (sarea_priv->nbox > RADEON_NR_SAREA_CLIPRECTS || DRM_COPY_FROM_USER(&depth_boxes, clear->depth_boxes,
35730 sarea_priv->nbox * sizeof(depth_boxes[0])))
35731 return -EFAULT;
35732
35733 @@ -3029,7 +3029,7 @@ static int radeon_cp_getparam(struct drm_device *dev, void *data, struct drm_fil
35734 {
35735 drm_radeon_private_t *dev_priv = dev->dev_private;
35736 drm_radeon_getparam_t *param = data;
35737 - int value;
35738 + int value = 0;
35739
35740 DRM_DEBUG("pid=%d\n", DRM_CURRENTPID);
35741
35742 diff --git a/drivers/gpu/drm/radeon/radeon_ttm.c b/drivers/gpu/drm/radeon/radeon_ttm.c
35743 index 93f760e..8088227 100644
35744 --- a/drivers/gpu/drm/radeon/radeon_ttm.c
35745 +++ b/drivers/gpu/drm/radeon/radeon_ttm.c
35746 @@ -782,7 +782,7 @@ void radeon_ttm_set_active_vram_size(struct radeon_device *rdev, u64 size)
35747 man->size = size >> PAGE_SHIFT;
35748 }
35749
35750 -static struct vm_operations_struct radeon_ttm_vm_ops;
35751 +static vm_operations_struct_no_const radeon_ttm_vm_ops __read_only;
35752 static const struct vm_operations_struct *ttm_vm_ops = NULL;
35753
35754 static int radeon_ttm_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
35755 @@ -823,8 +823,10 @@ int radeon_mmap(struct file *filp, struct vm_area_struct *vma)
35756 }
35757 if (unlikely(ttm_vm_ops == NULL)) {
35758 ttm_vm_ops = vma->vm_ops;
35759 + pax_open_kernel();
35760 radeon_ttm_vm_ops = *ttm_vm_ops;
35761 radeon_ttm_vm_ops.fault = &radeon_ttm_fault;
35762 + pax_close_kernel();
35763 }
35764 vma->vm_ops = &radeon_ttm_vm_ops;
35765 return 0;
35766 @@ -862,28 +864,33 @@ static int radeon_ttm_debugfs_init(struct radeon_device *rdev)
35767 sprintf(radeon_mem_types_names[i], "radeon_vram_mm");
35768 else
35769 sprintf(radeon_mem_types_names[i], "radeon_gtt_mm");
35770 - radeon_mem_types_list[i].name = radeon_mem_types_names[i];
35771 - radeon_mem_types_list[i].show = &radeon_mm_dump_table;
35772 - radeon_mem_types_list[i].driver_features = 0;
35773 + pax_open_kernel();
35774 + *(const char **)&radeon_mem_types_list[i].name = radeon_mem_types_names[i];
35775 + *(void **)&radeon_mem_types_list[i].show = &radeon_mm_dump_table;
35776 + *(u32 *)&radeon_mem_types_list[i].driver_features = 0;
35777 if (i == 0)
35778 - radeon_mem_types_list[i].data = rdev->mman.bdev.man[TTM_PL_VRAM].priv;
35779 + *(void **)&radeon_mem_types_list[i].data = rdev->mman.bdev.man[TTM_PL_VRAM].priv;
35780 else
35781 - radeon_mem_types_list[i].data = rdev->mman.bdev.man[TTM_PL_TT].priv;
35782 -
35783 + *(void **)&radeon_mem_types_list[i].data = rdev->mman.bdev.man[TTM_PL_TT].priv;
35784 + pax_close_kernel();
35785 }
35786 /* Add ttm page pool to debugfs */
35787 sprintf(radeon_mem_types_names[i], "ttm_page_pool");
35788 - radeon_mem_types_list[i].name = radeon_mem_types_names[i];
35789 - radeon_mem_types_list[i].show = &ttm_page_alloc_debugfs;
35790 - radeon_mem_types_list[i].driver_features = 0;
35791 - radeon_mem_types_list[i++].data = NULL;
35792 + pax_open_kernel();
35793 + *(const char **)&radeon_mem_types_list[i].name = radeon_mem_types_names[i];
35794 + *(void **)&radeon_mem_types_list[i].show = &ttm_page_alloc_debugfs;
35795 + *(u32 *)&radeon_mem_types_list[i].driver_features = 0;
35796 + *(void **)&radeon_mem_types_list[i++].data = NULL;
35797 + pax_close_kernel();
35798 #ifdef CONFIG_SWIOTLB
35799 if (swiotlb_nr_tbl()) {
35800 sprintf(radeon_mem_types_names[i], "ttm_dma_page_pool");
35801 - radeon_mem_types_list[i].name = radeon_mem_types_names[i];
35802 - radeon_mem_types_list[i].show = &ttm_dma_page_alloc_debugfs;
35803 - radeon_mem_types_list[i].driver_features = 0;
35804 - radeon_mem_types_list[i++].data = NULL;
35805 + pax_open_kernel();
35806 + *(const char **)&radeon_mem_types_list[i].name = radeon_mem_types_names[i];
35807 + *(void **)&radeon_mem_types_list[i].show = &ttm_dma_page_alloc_debugfs;
35808 + *(u32 *)&radeon_mem_types_list[i].driver_features = 0;
35809 + *(void **)&radeon_mem_types_list[i++].data = NULL;
35810 + pax_close_kernel();
35811 }
35812 #endif
35813 return radeon_debugfs_add_files(rdev, radeon_mem_types_list, i);
35814 diff --git a/drivers/gpu/drm/radeon/rs690.c b/drivers/gpu/drm/radeon/rs690.c
35815 index 5706d2a..17aedaa 100644
35816 --- a/drivers/gpu/drm/radeon/rs690.c
35817 +++ b/drivers/gpu/drm/radeon/rs690.c
35818 @@ -304,9 +304,11 @@ static void rs690_crtc_bandwidth_compute(struct radeon_device *rdev,
35819 if (rdev->pm.max_bandwidth.full > rdev->pm.sideport_bandwidth.full &&
35820 rdev->pm.sideport_bandwidth.full)
35821 rdev->pm.max_bandwidth = rdev->pm.sideport_bandwidth;
35822 - read_delay_latency.full = dfixed_const(370 * 800 * 1000);
35823 + read_delay_latency.full = dfixed_const(800 * 1000);
35824 read_delay_latency.full = dfixed_div(read_delay_latency,
35825 rdev->pm.igp_sideport_mclk);
35826 + a.full = dfixed_const(370);
35827 + read_delay_latency.full = dfixed_mul(read_delay_latency, a);
35828 } else {
35829 if (rdev->pm.max_bandwidth.full > rdev->pm.k8_bandwidth.full &&
35830 rdev->pm.k8_bandwidth.full)
35831 diff --git a/drivers/gpu/drm/ttm/ttm_page_alloc.c b/drivers/gpu/drm/ttm/ttm_page_alloc.c
35832 index bd2a3b4..122d9ad 100644
35833 --- a/drivers/gpu/drm/ttm/ttm_page_alloc.c
35834 +++ b/drivers/gpu/drm/ttm/ttm_page_alloc.c
35835 @@ -394,9 +394,9 @@ static int ttm_pool_get_num_unused_pages(void)
35836 static int ttm_pool_mm_shrink(struct shrinker *shrink,
35837 struct shrink_control *sc)
35838 {
35839 - static atomic_t start_pool = ATOMIC_INIT(0);
35840 + static atomic_unchecked_t start_pool = ATOMIC_INIT(0);
35841 unsigned i;
35842 - unsigned pool_offset = atomic_add_return(1, &start_pool);
35843 + unsigned pool_offset = atomic_add_return_unchecked(1, &start_pool);
35844 struct ttm_page_pool *pool;
35845 int shrink_pages = sc->nr_to_scan;
35846
35847 diff --git a/drivers/gpu/drm/udl/udl_fb.c b/drivers/gpu/drm/udl/udl_fb.c
35848 index 1eb060c..188b1fc 100644
35849 --- a/drivers/gpu/drm/udl/udl_fb.c
35850 +++ b/drivers/gpu/drm/udl/udl_fb.c
35851 @@ -367,7 +367,6 @@ static int udl_fb_release(struct fb_info *info, int user)
35852 fb_deferred_io_cleanup(info);
35853 kfree(info->fbdefio);
35854 info->fbdefio = NULL;
35855 - info->fbops->fb_mmap = udl_fb_mmap;
35856 }
35857
35858 pr_warn("released /dev/fb%d user=%d count=%d\n",
35859 diff --git a/drivers/gpu/drm/via/via_drv.h b/drivers/gpu/drm/via/via_drv.h
35860 index 893a650..6190d3b 100644
35861 --- a/drivers/gpu/drm/via/via_drv.h
35862 +++ b/drivers/gpu/drm/via/via_drv.h
35863 @@ -51,7 +51,7 @@ typedef struct drm_via_ring_buffer {
35864 typedef uint32_t maskarray_t[5];
35865
35866 typedef struct drm_via_irq {
35867 - atomic_t irq_received;
35868 + atomic_unchecked_t irq_received;
35869 uint32_t pending_mask;
35870 uint32_t enable_mask;
35871 wait_queue_head_t irq_queue;
35872 @@ -75,7 +75,7 @@ typedef struct drm_via_private {
35873 struct timeval last_vblank;
35874 int last_vblank_valid;
35875 unsigned usec_per_vblank;
35876 - atomic_t vbl_received;
35877 + atomic_unchecked_t vbl_received;
35878 drm_via_state_t hc_state;
35879 char pci_buf[VIA_PCI_BUF_SIZE];
35880 const uint32_t *fire_offsets[VIA_FIRE_BUF_SIZE];
35881 diff --git a/drivers/gpu/drm/via/via_irq.c b/drivers/gpu/drm/via/via_irq.c
35882 index ac98964..5dbf512 100644
35883 --- a/drivers/gpu/drm/via/via_irq.c
35884 +++ b/drivers/gpu/drm/via/via_irq.c
35885 @@ -101,7 +101,7 @@ u32 via_get_vblank_counter(struct drm_device *dev, int crtc)
35886 if (crtc != 0)
35887 return 0;
35888
35889 - return atomic_read(&dev_priv->vbl_received);
35890 + return atomic_read_unchecked(&dev_priv->vbl_received);
35891 }
35892
35893 irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
35894 @@ -116,8 +116,8 @@ irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
35895
35896 status = VIA_READ(VIA_REG_INTERRUPT);
35897 if (status & VIA_IRQ_VBLANK_PENDING) {
35898 - atomic_inc(&dev_priv->vbl_received);
35899 - if (!(atomic_read(&dev_priv->vbl_received) & 0x0F)) {
35900 + atomic_inc_unchecked(&dev_priv->vbl_received);
35901 + if (!(atomic_read_unchecked(&dev_priv->vbl_received) & 0x0F)) {
35902 do_gettimeofday(&cur_vblank);
35903 if (dev_priv->last_vblank_valid) {
35904 dev_priv->usec_per_vblank =
35905 @@ -127,7 +127,7 @@ irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
35906 dev_priv->last_vblank = cur_vblank;
35907 dev_priv->last_vblank_valid = 1;
35908 }
35909 - if (!(atomic_read(&dev_priv->vbl_received) & 0xFF)) {
35910 + if (!(atomic_read_unchecked(&dev_priv->vbl_received) & 0xFF)) {
35911 DRM_DEBUG("US per vblank is: %u\n",
35912 dev_priv->usec_per_vblank);
35913 }
35914 @@ -137,7 +137,7 @@ irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
35915
35916 for (i = 0; i < dev_priv->num_irqs; ++i) {
35917 if (status & cur_irq->pending_mask) {
35918 - atomic_inc(&cur_irq->irq_received);
35919 + atomic_inc_unchecked(&cur_irq->irq_received);
35920 DRM_WAKEUP(&cur_irq->irq_queue);
35921 handled = 1;
35922 if (dev_priv->irq_map[drm_via_irq_dma0_td] == i)
35923 @@ -242,11 +242,11 @@ via_driver_irq_wait(struct drm_device *dev, unsigned int irq, int force_sequence
35924 DRM_WAIT_ON(ret, cur_irq->irq_queue, 3 * DRM_HZ,
35925 ((VIA_READ(masks[irq][2]) & masks[irq][3]) ==
35926 masks[irq][4]));
35927 - cur_irq_sequence = atomic_read(&cur_irq->irq_received);
35928 + cur_irq_sequence = atomic_read_unchecked(&cur_irq->irq_received);
35929 } else {
35930 DRM_WAIT_ON(ret, cur_irq->irq_queue, 3 * DRM_HZ,
35931 (((cur_irq_sequence =
35932 - atomic_read(&cur_irq->irq_received)) -
35933 + atomic_read_unchecked(&cur_irq->irq_received)) -
35934 *sequence) <= (1 << 23)));
35935 }
35936 *sequence = cur_irq_sequence;
35937 @@ -284,7 +284,7 @@ void via_driver_irq_preinstall(struct drm_device *dev)
35938 }
35939
35940 for (i = 0; i < dev_priv->num_irqs; ++i) {
35941 - atomic_set(&cur_irq->irq_received, 0);
35942 + atomic_set_unchecked(&cur_irq->irq_received, 0);
35943 cur_irq->enable_mask = dev_priv->irq_masks[i][0];
35944 cur_irq->pending_mask = dev_priv->irq_masks[i][1];
35945 DRM_INIT_WAITQUEUE(&cur_irq->irq_queue);
35946 @@ -366,7 +366,7 @@ int via_wait_irq(struct drm_device *dev, void *data, struct drm_file *file_priv)
35947 switch (irqwait->request.type & ~VIA_IRQ_FLAGS_MASK) {
35948 case VIA_IRQ_RELATIVE:
35949 irqwait->request.sequence +=
35950 - atomic_read(&cur_irq->irq_received);
35951 + atomic_read_unchecked(&cur_irq->irq_received);
35952 irqwait->request.type &= ~_DRM_VBLANK_RELATIVE;
35953 case VIA_IRQ_ABSOLUTE:
35954 break;
35955 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
35956 index 13aeda7..4a952d1 100644
35957 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
35958 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
35959 @@ -290,7 +290,7 @@ struct vmw_private {
35960 * Fencing and IRQs.
35961 */
35962
35963 - atomic_t marker_seq;
35964 + atomic_unchecked_t marker_seq;
35965 wait_queue_head_t fence_queue;
35966 wait_queue_head_t fifo_queue;
35967 int fence_queue_waiters; /* Protected by hw_mutex */
35968 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c b/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
35969 index 3eb1486..0a47ee9 100644
35970 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
35971 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
35972 @@ -137,7 +137,7 @@ int vmw_fifo_init(struct vmw_private *dev_priv, struct vmw_fifo_state *fifo)
35973 (unsigned int) min,
35974 (unsigned int) fifo->capabilities);
35975
35976 - atomic_set(&dev_priv->marker_seq, dev_priv->last_read_seqno);
35977 + atomic_set_unchecked(&dev_priv->marker_seq, dev_priv->last_read_seqno);
35978 iowrite32(dev_priv->last_read_seqno, fifo_mem + SVGA_FIFO_FENCE);
35979 vmw_marker_queue_init(&fifo->marker_queue);
35980 return vmw_fifo_send_fence(dev_priv, &dummy);
35981 @@ -355,7 +355,7 @@ void *vmw_fifo_reserve(struct vmw_private *dev_priv, uint32_t bytes)
35982 if (reserveable)
35983 iowrite32(bytes, fifo_mem +
35984 SVGA_FIFO_RESERVED);
35985 - return fifo_mem + (next_cmd >> 2);
35986 + return (__le32 __force_kernel *)fifo_mem + (next_cmd >> 2);
35987 } else {
35988 need_bounce = true;
35989 }
35990 @@ -475,7 +475,7 @@ int vmw_fifo_send_fence(struct vmw_private *dev_priv, uint32_t *seqno)
35991
35992 fm = vmw_fifo_reserve(dev_priv, bytes);
35993 if (unlikely(fm == NULL)) {
35994 - *seqno = atomic_read(&dev_priv->marker_seq);
35995 + *seqno = atomic_read_unchecked(&dev_priv->marker_seq);
35996 ret = -ENOMEM;
35997 (void)vmw_fallback_wait(dev_priv, false, true, *seqno,
35998 false, 3*HZ);
35999 @@ -483,7 +483,7 @@ int vmw_fifo_send_fence(struct vmw_private *dev_priv, uint32_t *seqno)
36000 }
36001
36002 do {
36003 - *seqno = atomic_add_return(1, &dev_priv->marker_seq);
36004 + *seqno = atomic_add_return_unchecked(1, &dev_priv->marker_seq);
36005 } while (*seqno == 0);
36006
36007 if (!(fifo_state->capabilities & SVGA_FIFO_CAP_FENCE)) {
36008 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c b/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c
36009 index 4640adb..e1384ed 100644
36010 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c
36011 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c
36012 @@ -107,7 +107,7 @@ bool vmw_seqno_passed(struct vmw_private *dev_priv,
36013 * emitted. Then the fence is stale and signaled.
36014 */
36015
36016 - ret = ((atomic_read(&dev_priv->marker_seq) - seqno)
36017 + ret = ((atomic_read_unchecked(&dev_priv->marker_seq) - seqno)
36018 > VMW_FENCE_WRAP);
36019
36020 return ret;
36021 @@ -138,7 +138,7 @@ int vmw_fallback_wait(struct vmw_private *dev_priv,
36022
36023 if (fifo_idle)
36024 down_read(&fifo_state->rwsem);
36025 - signal_seq = atomic_read(&dev_priv->marker_seq);
36026 + signal_seq = atomic_read_unchecked(&dev_priv->marker_seq);
36027 ret = 0;
36028
36029 for (;;) {
36030 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c b/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c
36031 index 8a8725c..afed796 100644
36032 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c
36033 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c
36034 @@ -151,7 +151,7 @@ int vmw_wait_lag(struct vmw_private *dev_priv,
36035 while (!vmw_lag_lt(queue, us)) {
36036 spin_lock(&queue->lock);
36037 if (list_empty(&queue->head))
36038 - seqno = atomic_read(&dev_priv->marker_seq);
36039 + seqno = atomic_read_unchecked(&dev_priv->marker_seq);
36040 else {
36041 marker = list_first_entry(&queue->head,
36042 struct vmw_marker, head);
36043 diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
36044 index ceb3040..6160c5c 100644
36045 --- a/drivers/hid/hid-core.c
36046 +++ b/drivers/hid/hid-core.c
36047 @@ -2242,7 +2242,7 @@ EXPORT_SYMBOL_GPL(hid_ignore);
36048
36049 int hid_add_device(struct hid_device *hdev)
36050 {
36051 - static atomic_t id = ATOMIC_INIT(0);
36052 + static atomic_unchecked_t id = ATOMIC_INIT(0);
36053 int ret;
36054
36055 if (WARN_ON(hdev->status & HID_STAT_ADDED))
36056 @@ -2276,7 +2276,7 @@ int hid_add_device(struct hid_device *hdev)
36057 /* XXX hack, any other cleaner solution after the driver core
36058 * is converted to allow more than 20 bytes as the device name? */
36059 dev_set_name(&hdev->dev, "%04X:%04X:%04X.%04X", hdev->bus,
36060 - hdev->vendor, hdev->product, atomic_inc_return(&id));
36061 + hdev->vendor, hdev->product, atomic_inc_return_unchecked(&id));
36062
36063 hid_debug_register(hdev, dev_name(&hdev->dev));
36064 ret = device_add(&hdev->dev);
36065 diff --git a/drivers/hid/hid-wiimote-debug.c b/drivers/hid/hid-wiimote-debug.c
36066 index eec3291..8ed706b 100644
36067 --- a/drivers/hid/hid-wiimote-debug.c
36068 +++ b/drivers/hid/hid-wiimote-debug.c
36069 @@ -66,7 +66,7 @@ static ssize_t wiidebug_eeprom_read(struct file *f, char __user *u, size_t s,
36070 else if (size == 0)
36071 return -EIO;
36072
36073 - if (copy_to_user(u, buf, size))
36074 + if (size > sizeof(buf) || copy_to_user(u, buf, size))
36075 return -EFAULT;
36076
36077 *off += size;
36078 diff --git a/drivers/hv/channel.c b/drivers/hv/channel.c
36079 index 773a2f2..7ce08bc 100644
36080 --- a/drivers/hv/channel.c
36081 +++ b/drivers/hv/channel.c
36082 @@ -394,8 +394,8 @@ int vmbus_establish_gpadl(struct vmbus_channel *channel, void *kbuffer,
36083 int ret = 0;
36084 int t;
36085
36086 - next_gpadl_handle = atomic_read(&vmbus_connection.next_gpadl_handle);
36087 - atomic_inc(&vmbus_connection.next_gpadl_handle);
36088 + next_gpadl_handle = atomic_read_unchecked(&vmbus_connection.next_gpadl_handle);
36089 + atomic_inc_unchecked(&vmbus_connection.next_gpadl_handle);
36090
36091 ret = create_gpadl_header(kbuffer, size, &msginfo, &msgcount);
36092 if (ret)
36093 diff --git a/drivers/hv/hv.c b/drivers/hv/hv.c
36094 index 3648f8f..30ef30d 100644
36095 --- a/drivers/hv/hv.c
36096 +++ b/drivers/hv/hv.c
36097 @@ -111,7 +111,7 @@ static u64 do_hypercall(u64 control, void *input, void *output)
36098 u64 output_address = (output) ? virt_to_phys(output) : 0;
36099 u32 output_address_hi = output_address >> 32;
36100 u32 output_address_lo = output_address & 0xFFFFFFFF;
36101 - void *hypercall_page = hv_context.hypercall_page;
36102 + void *hypercall_page = ktva_ktla(hv_context.hypercall_page);
36103
36104 __asm__ __volatile__ ("call *%8" : "=d"(hv_status_hi),
36105 "=a"(hv_status_lo) : "d" (control_hi),
36106 diff --git a/drivers/hv/hyperv_vmbus.h b/drivers/hv/hyperv_vmbus.h
36107 index d8d1fad..b91caf7 100644
36108 --- a/drivers/hv/hyperv_vmbus.h
36109 +++ b/drivers/hv/hyperv_vmbus.h
36110 @@ -594,7 +594,7 @@ enum vmbus_connect_state {
36111 struct vmbus_connection {
36112 enum vmbus_connect_state conn_state;
36113
36114 - atomic_t next_gpadl_handle;
36115 + atomic_unchecked_t next_gpadl_handle;
36116
36117 /*
36118 * Represents channel interrupts. Each bit position represents a
36119 diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
36120 index 8e1a9ec..4687821 100644
36121 --- a/drivers/hv/vmbus_drv.c
36122 +++ b/drivers/hv/vmbus_drv.c
36123 @@ -629,10 +629,10 @@ int vmbus_device_register(struct hv_device *child_device_obj)
36124 {
36125 int ret = 0;
36126
36127 - static atomic_t device_num = ATOMIC_INIT(0);
36128 + static atomic_unchecked_t device_num = ATOMIC_INIT(0);
36129
36130 dev_set_name(&child_device_obj->device, "vmbus_0_%d",
36131 - atomic_inc_return(&device_num));
36132 + atomic_inc_return_unchecked(&device_num));
36133
36134 child_device_obj->device.bus = &hv_bus;
36135 child_device_obj->device.parent = &hv_acpi_dev->dev;
36136 diff --git a/drivers/hwmon/acpi_power_meter.c b/drivers/hwmon/acpi_power_meter.c
36137 index 1672e2a..4a6297c 100644
36138 --- a/drivers/hwmon/acpi_power_meter.c
36139 +++ b/drivers/hwmon/acpi_power_meter.c
36140 @@ -117,7 +117,7 @@ struct sensor_template {
36141 struct device_attribute *devattr,
36142 const char *buf, size_t count);
36143 int index;
36144 -};
36145 +} __do_const;
36146
36147 /* Averaging interval */
36148 static int update_avg_interval(struct acpi_power_meter_resource *resource)
36149 @@ -629,7 +629,7 @@ static int register_attrs(struct acpi_power_meter_resource *resource,
36150 struct sensor_template *attrs)
36151 {
36152 struct device *dev = &resource->acpi_dev->dev;
36153 - struct sensor_device_attribute *sensors =
36154 + sensor_device_attribute_no_const *sensors =
36155 &resource->sensors[resource->num_sensors];
36156 int res = 0;
36157
36158 diff --git a/drivers/hwmon/applesmc.c b/drivers/hwmon/applesmc.c
36159 index b41baff..4953e4d 100644
36160 --- a/drivers/hwmon/applesmc.c
36161 +++ b/drivers/hwmon/applesmc.c
36162 @@ -1084,7 +1084,7 @@ static int applesmc_create_nodes(struct applesmc_node_group *groups, int num)
36163 {
36164 struct applesmc_node_group *grp;
36165 struct applesmc_dev_attr *node;
36166 - struct attribute *attr;
36167 + attribute_no_const *attr;
36168 int ret, i;
36169
36170 for (grp = groups; grp->format; grp++) {
36171 diff --git a/drivers/hwmon/asus_atk0110.c b/drivers/hwmon/asus_atk0110.c
36172 index 56dbcfb..9874bf1 100644
36173 --- a/drivers/hwmon/asus_atk0110.c
36174 +++ b/drivers/hwmon/asus_atk0110.c
36175 @@ -152,10 +152,10 @@ MODULE_DEVICE_TABLE(acpi, atk_ids);
36176 struct atk_sensor_data {
36177 struct list_head list;
36178 struct atk_data *data;
36179 - struct device_attribute label_attr;
36180 - struct device_attribute input_attr;
36181 - struct device_attribute limit1_attr;
36182 - struct device_attribute limit2_attr;
36183 + device_attribute_no_const label_attr;
36184 + device_attribute_no_const input_attr;
36185 + device_attribute_no_const limit1_attr;
36186 + device_attribute_no_const limit2_attr;
36187 char label_attr_name[ATTR_NAME_SIZE];
36188 char input_attr_name[ATTR_NAME_SIZE];
36189 char limit1_attr_name[ATTR_NAME_SIZE];
36190 @@ -275,7 +275,7 @@ static ssize_t atk_name_show(struct device *dev,
36191 static struct device_attribute atk_name_attr =
36192 __ATTR(name, 0444, atk_name_show, NULL);
36193
36194 -static void atk_init_attribute(struct device_attribute *attr, char *name,
36195 +static void atk_init_attribute(device_attribute_no_const *attr, char *name,
36196 sysfs_show_func show)
36197 {
36198 sysfs_attr_init(&attr->attr);
36199 diff --git a/drivers/hwmon/coretemp.c b/drivers/hwmon/coretemp.c
36200 index d64923d..72591e8 100644
36201 --- a/drivers/hwmon/coretemp.c
36202 +++ b/drivers/hwmon/coretemp.c
36203 @@ -790,7 +790,7 @@ static int __cpuinit coretemp_cpu_callback(struct notifier_block *nfb,
36204 return NOTIFY_OK;
36205 }
36206
36207 -static struct notifier_block coretemp_cpu_notifier __refdata = {
36208 +static struct notifier_block coretemp_cpu_notifier = {
36209 .notifier_call = coretemp_cpu_callback,
36210 };
36211
36212 diff --git a/drivers/hwmon/ibmaem.c b/drivers/hwmon/ibmaem.c
36213 index a14f634..2916ee2 100644
36214 --- a/drivers/hwmon/ibmaem.c
36215 +++ b/drivers/hwmon/ibmaem.c
36216 @@ -925,7 +925,7 @@ static int aem_register_sensors(struct aem_data *data,
36217 struct aem_rw_sensor_template *rw)
36218 {
36219 struct device *dev = &data->pdev->dev;
36220 - struct sensor_device_attribute *sensors = data->sensors;
36221 + sensor_device_attribute_no_const *sensors = data->sensors;
36222 int err;
36223
36224 /* Set up read-only sensors */
36225 diff --git a/drivers/hwmon/pmbus/pmbus_core.c b/drivers/hwmon/pmbus/pmbus_core.c
36226 index 7d19b1b..8fdaaac 100644
36227 --- a/drivers/hwmon/pmbus/pmbus_core.c
36228 +++ b/drivers/hwmon/pmbus/pmbus_core.c
36229 @@ -811,7 +811,7 @@ static ssize_t pmbus_show_label(struct device *dev,
36230
36231 #define PMBUS_ADD_ATTR(data, _name, _idx, _mode, _type, _show, _set) \
36232 do { \
36233 - struct sensor_device_attribute *a \
36234 + sensor_device_attribute_no_const *a \
36235 = &data->_type##s[data->num_##_type##s].attribute; \
36236 BUG_ON(data->num_attributes >= data->max_attributes); \
36237 sysfs_attr_init(&a->dev_attr.attr); \
36238 diff --git a/drivers/hwmon/sht15.c b/drivers/hwmon/sht15.c
36239 index 8047fed..1e956f0 100644
36240 --- a/drivers/hwmon/sht15.c
36241 +++ b/drivers/hwmon/sht15.c
36242 @@ -169,7 +169,7 @@ struct sht15_data {
36243 int supply_uV;
36244 bool supply_uV_valid;
36245 struct work_struct update_supply_work;
36246 - atomic_t interrupt_handled;
36247 + atomic_unchecked_t interrupt_handled;
36248 };
36249
36250 /**
36251 @@ -512,13 +512,13 @@ static int sht15_measurement(struct sht15_data *data,
36252 return ret;
36253
36254 gpio_direction_input(data->pdata->gpio_data);
36255 - atomic_set(&data->interrupt_handled, 0);
36256 + atomic_set_unchecked(&data->interrupt_handled, 0);
36257
36258 enable_irq(gpio_to_irq(data->pdata->gpio_data));
36259 if (gpio_get_value(data->pdata->gpio_data) == 0) {
36260 disable_irq_nosync(gpio_to_irq(data->pdata->gpio_data));
36261 /* Only relevant if the interrupt hasn't occurred. */
36262 - if (!atomic_read(&data->interrupt_handled))
36263 + if (!atomic_read_unchecked(&data->interrupt_handled))
36264 schedule_work(&data->read_work);
36265 }
36266 ret = wait_event_timeout(data->wait_queue,
36267 @@ -785,7 +785,7 @@ static irqreturn_t sht15_interrupt_fired(int irq, void *d)
36268
36269 /* First disable the interrupt */
36270 disable_irq_nosync(irq);
36271 - atomic_inc(&data->interrupt_handled);
36272 + atomic_inc_unchecked(&data->interrupt_handled);
36273 /* Then schedule a reading work struct */
36274 if (data->state != SHT15_READING_NOTHING)
36275 schedule_work(&data->read_work);
36276 @@ -807,11 +807,11 @@ static void sht15_bh_read_data(struct work_struct *work_s)
36277 * If not, then start the interrupt again - care here as could
36278 * have gone low in meantime so verify it hasn't!
36279 */
36280 - atomic_set(&data->interrupt_handled, 0);
36281 + atomic_set_unchecked(&data->interrupt_handled, 0);
36282 enable_irq(gpio_to_irq(data->pdata->gpio_data));
36283 /* If still not occurred or another handler was scheduled */
36284 if (gpio_get_value(data->pdata->gpio_data)
36285 - || atomic_read(&data->interrupt_handled))
36286 + || atomic_read_unchecked(&data->interrupt_handled))
36287 return;
36288 }
36289
36290 diff --git a/drivers/hwmon/via-cputemp.c b/drivers/hwmon/via-cputemp.c
36291 index 76f157b..9c0db1b 100644
36292 --- a/drivers/hwmon/via-cputemp.c
36293 +++ b/drivers/hwmon/via-cputemp.c
36294 @@ -296,7 +296,7 @@ static int __cpuinit via_cputemp_cpu_callback(struct notifier_block *nfb,
36295 return NOTIFY_OK;
36296 }
36297
36298 -static struct notifier_block via_cputemp_cpu_notifier __refdata = {
36299 +static struct notifier_block via_cputemp_cpu_notifier = {
36300 .notifier_call = via_cputemp_cpu_callback,
36301 };
36302
36303 diff --git a/drivers/i2c/busses/i2c-amd756-s4882.c b/drivers/i2c/busses/i2c-amd756-s4882.c
36304 index 378fcb5..5e91fa8 100644
36305 --- a/drivers/i2c/busses/i2c-amd756-s4882.c
36306 +++ b/drivers/i2c/busses/i2c-amd756-s4882.c
36307 @@ -43,7 +43,7 @@
36308 extern struct i2c_adapter amd756_smbus;
36309
36310 static struct i2c_adapter *s4882_adapter;
36311 -static struct i2c_algorithm *s4882_algo;
36312 +static i2c_algorithm_no_const *s4882_algo;
36313
36314 /* Wrapper access functions for multiplexed SMBus */
36315 static DEFINE_MUTEX(amd756_lock);
36316 diff --git a/drivers/i2c/busses/i2c-nforce2-s4985.c b/drivers/i2c/busses/i2c-nforce2-s4985.c
36317 index 29015eb..af2d8e9 100644
36318 --- a/drivers/i2c/busses/i2c-nforce2-s4985.c
36319 +++ b/drivers/i2c/busses/i2c-nforce2-s4985.c
36320 @@ -41,7 +41,7 @@
36321 extern struct i2c_adapter *nforce2_smbus;
36322
36323 static struct i2c_adapter *s4985_adapter;
36324 -static struct i2c_algorithm *s4985_algo;
36325 +static i2c_algorithm_no_const *s4985_algo;
36326
36327 /* Wrapper access functions for multiplexed SMBus */
36328 static DEFINE_MUTEX(nforce2_lock);
36329 diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c
36330 index 8126824..55a2798 100644
36331 --- a/drivers/ide/ide-cd.c
36332 +++ b/drivers/ide/ide-cd.c
36333 @@ -768,7 +768,7 @@ static void cdrom_do_block_pc(ide_drive_t *drive, struct request *rq)
36334 alignment = queue_dma_alignment(q) | q->dma_pad_mask;
36335 if ((unsigned long)buf & alignment
36336 || blk_rq_bytes(rq) & q->dma_pad_mask
36337 - || object_is_on_stack(buf))
36338 + || object_starts_on_stack(buf))
36339 drive->dma = 0;
36340 }
36341 }
36342 diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c
36343 index 8848f16..f8e6dd8 100644
36344 --- a/drivers/iio/industrialio-core.c
36345 +++ b/drivers/iio/industrialio-core.c
36346 @@ -506,7 +506,7 @@ static ssize_t iio_write_channel_info(struct device *dev,
36347 }
36348
36349 static
36350 -int __iio_device_attr_init(struct device_attribute *dev_attr,
36351 +int __iio_device_attr_init(device_attribute_no_const *dev_attr,
36352 const char *postfix,
36353 struct iio_chan_spec const *chan,
36354 ssize_t (*readfunc)(struct device *dev,
36355 diff --git a/drivers/infiniband/core/cm.c b/drivers/infiniband/core/cm.c
36356 index 394fea2..c833880 100644
36357 --- a/drivers/infiniband/core/cm.c
36358 +++ b/drivers/infiniband/core/cm.c
36359 @@ -114,7 +114,7 @@ static char const counter_group_names[CM_COUNTER_GROUPS]
36360
36361 struct cm_counter_group {
36362 struct kobject obj;
36363 - atomic_long_t counter[CM_ATTR_COUNT];
36364 + atomic_long_unchecked_t counter[CM_ATTR_COUNT];
36365 };
36366
36367 struct cm_counter_attribute {
36368 @@ -1394,7 +1394,7 @@ static void cm_dup_req_handler(struct cm_work *work,
36369 struct ib_mad_send_buf *msg = NULL;
36370 int ret;
36371
36372 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36373 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36374 counter[CM_REQ_COUNTER]);
36375
36376 /* Quick state check to discard duplicate REQs. */
36377 @@ -1778,7 +1778,7 @@ static void cm_dup_rep_handler(struct cm_work *work)
36378 if (!cm_id_priv)
36379 return;
36380
36381 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36382 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36383 counter[CM_REP_COUNTER]);
36384 ret = cm_alloc_response_msg(work->port, work->mad_recv_wc, &msg);
36385 if (ret)
36386 @@ -1945,7 +1945,7 @@ static int cm_rtu_handler(struct cm_work *work)
36387 if (cm_id_priv->id.state != IB_CM_REP_SENT &&
36388 cm_id_priv->id.state != IB_CM_MRA_REP_RCVD) {
36389 spin_unlock_irq(&cm_id_priv->lock);
36390 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36391 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36392 counter[CM_RTU_COUNTER]);
36393 goto out;
36394 }
36395 @@ -2128,7 +2128,7 @@ static int cm_dreq_handler(struct cm_work *work)
36396 cm_id_priv = cm_acquire_id(dreq_msg->remote_comm_id,
36397 dreq_msg->local_comm_id);
36398 if (!cm_id_priv) {
36399 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36400 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36401 counter[CM_DREQ_COUNTER]);
36402 cm_issue_drep(work->port, work->mad_recv_wc);
36403 return -EINVAL;
36404 @@ -2153,7 +2153,7 @@ static int cm_dreq_handler(struct cm_work *work)
36405 case IB_CM_MRA_REP_RCVD:
36406 break;
36407 case IB_CM_TIMEWAIT:
36408 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36409 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36410 counter[CM_DREQ_COUNTER]);
36411 if (cm_alloc_response_msg(work->port, work->mad_recv_wc, &msg))
36412 goto unlock;
36413 @@ -2167,7 +2167,7 @@ static int cm_dreq_handler(struct cm_work *work)
36414 cm_free_msg(msg);
36415 goto deref;
36416 case IB_CM_DREQ_RCVD:
36417 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36418 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36419 counter[CM_DREQ_COUNTER]);
36420 goto unlock;
36421 default:
36422 @@ -2534,7 +2534,7 @@ static int cm_mra_handler(struct cm_work *work)
36423 ib_modify_mad(cm_id_priv->av.port->mad_agent,
36424 cm_id_priv->msg, timeout)) {
36425 if (cm_id_priv->id.lap_state == IB_CM_MRA_LAP_RCVD)
36426 - atomic_long_inc(&work->port->
36427 + atomic_long_inc_unchecked(&work->port->
36428 counter_group[CM_RECV_DUPLICATES].
36429 counter[CM_MRA_COUNTER]);
36430 goto out;
36431 @@ -2543,7 +2543,7 @@ static int cm_mra_handler(struct cm_work *work)
36432 break;
36433 case IB_CM_MRA_REQ_RCVD:
36434 case IB_CM_MRA_REP_RCVD:
36435 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36436 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36437 counter[CM_MRA_COUNTER]);
36438 /* fall through */
36439 default:
36440 @@ -2705,7 +2705,7 @@ static int cm_lap_handler(struct cm_work *work)
36441 case IB_CM_LAP_IDLE:
36442 break;
36443 case IB_CM_MRA_LAP_SENT:
36444 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36445 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36446 counter[CM_LAP_COUNTER]);
36447 if (cm_alloc_response_msg(work->port, work->mad_recv_wc, &msg))
36448 goto unlock;
36449 @@ -2721,7 +2721,7 @@ static int cm_lap_handler(struct cm_work *work)
36450 cm_free_msg(msg);
36451 goto deref;
36452 case IB_CM_LAP_RCVD:
36453 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36454 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36455 counter[CM_LAP_COUNTER]);
36456 goto unlock;
36457 default:
36458 @@ -3005,7 +3005,7 @@ static int cm_sidr_req_handler(struct cm_work *work)
36459 cur_cm_id_priv = cm_insert_remote_sidr(cm_id_priv);
36460 if (cur_cm_id_priv) {
36461 spin_unlock_irq(&cm.lock);
36462 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36463 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36464 counter[CM_SIDR_REQ_COUNTER]);
36465 goto out; /* Duplicate message. */
36466 }
36467 @@ -3217,10 +3217,10 @@ static void cm_send_handler(struct ib_mad_agent *mad_agent,
36468 if (!msg->context[0] && (attr_index != CM_REJ_COUNTER))
36469 msg->retries = 1;
36470
36471 - atomic_long_add(1 + msg->retries,
36472 + atomic_long_add_unchecked(1 + msg->retries,
36473 &port->counter_group[CM_XMIT].counter[attr_index]);
36474 if (msg->retries)
36475 - atomic_long_add(msg->retries,
36476 + atomic_long_add_unchecked(msg->retries,
36477 &port->counter_group[CM_XMIT_RETRIES].
36478 counter[attr_index]);
36479
36480 @@ -3430,7 +3430,7 @@ static void cm_recv_handler(struct ib_mad_agent *mad_agent,
36481 }
36482
36483 attr_id = be16_to_cpu(mad_recv_wc->recv_buf.mad->mad_hdr.attr_id);
36484 - atomic_long_inc(&port->counter_group[CM_RECV].
36485 + atomic_long_inc_unchecked(&port->counter_group[CM_RECV].
36486 counter[attr_id - CM_ATTR_ID_OFFSET]);
36487
36488 work = kmalloc(sizeof *work + sizeof(struct ib_sa_path_rec) * paths,
36489 @@ -3635,7 +3635,7 @@ static ssize_t cm_show_counter(struct kobject *obj, struct attribute *attr,
36490 cm_attr = container_of(attr, struct cm_counter_attribute, attr);
36491
36492 return sprintf(buf, "%ld\n",
36493 - atomic_long_read(&group->counter[cm_attr->index]));
36494 + atomic_long_read_unchecked(&group->counter[cm_attr->index]));
36495 }
36496
36497 static const struct sysfs_ops cm_counter_ops = {
36498 diff --git a/drivers/infiniband/core/fmr_pool.c b/drivers/infiniband/core/fmr_pool.c
36499 index 176c8f9..2627b62 100644
36500 --- a/drivers/infiniband/core/fmr_pool.c
36501 +++ b/drivers/infiniband/core/fmr_pool.c
36502 @@ -98,8 +98,8 @@ struct ib_fmr_pool {
36503
36504 struct task_struct *thread;
36505
36506 - atomic_t req_ser;
36507 - atomic_t flush_ser;
36508 + atomic_unchecked_t req_ser;
36509 + atomic_unchecked_t flush_ser;
36510
36511 wait_queue_head_t force_wait;
36512 };
36513 @@ -180,10 +180,10 @@ static int ib_fmr_cleanup_thread(void *pool_ptr)
36514 struct ib_fmr_pool *pool = pool_ptr;
36515
36516 do {
36517 - if (atomic_read(&pool->flush_ser) - atomic_read(&pool->req_ser) < 0) {
36518 + if (atomic_read_unchecked(&pool->flush_ser) - atomic_read_unchecked(&pool->req_ser) < 0) {
36519 ib_fmr_batch_release(pool);
36520
36521 - atomic_inc(&pool->flush_ser);
36522 + atomic_inc_unchecked(&pool->flush_ser);
36523 wake_up_interruptible(&pool->force_wait);
36524
36525 if (pool->flush_function)
36526 @@ -191,7 +191,7 @@ static int ib_fmr_cleanup_thread(void *pool_ptr)
36527 }
36528
36529 set_current_state(TASK_INTERRUPTIBLE);
36530 - if (atomic_read(&pool->flush_ser) - atomic_read(&pool->req_ser) >= 0 &&
36531 + if (atomic_read_unchecked(&pool->flush_ser) - atomic_read_unchecked(&pool->req_ser) >= 0 &&
36532 !kthread_should_stop())
36533 schedule();
36534 __set_current_state(TASK_RUNNING);
36535 @@ -283,8 +283,8 @@ struct ib_fmr_pool *ib_create_fmr_pool(struct ib_pd *pd,
36536 pool->dirty_watermark = params->dirty_watermark;
36537 pool->dirty_len = 0;
36538 spin_lock_init(&pool->pool_lock);
36539 - atomic_set(&pool->req_ser, 0);
36540 - atomic_set(&pool->flush_ser, 0);
36541 + atomic_set_unchecked(&pool->req_ser, 0);
36542 + atomic_set_unchecked(&pool->flush_ser, 0);
36543 init_waitqueue_head(&pool->force_wait);
36544
36545 pool->thread = kthread_run(ib_fmr_cleanup_thread,
36546 @@ -412,11 +412,11 @@ int ib_flush_fmr_pool(struct ib_fmr_pool *pool)
36547 }
36548 spin_unlock_irq(&pool->pool_lock);
36549
36550 - serial = atomic_inc_return(&pool->req_ser);
36551 + serial = atomic_inc_return_unchecked(&pool->req_ser);
36552 wake_up_process(pool->thread);
36553
36554 if (wait_event_interruptible(pool->force_wait,
36555 - atomic_read(&pool->flush_ser) - serial >= 0))
36556 + atomic_read_unchecked(&pool->flush_ser) - serial >= 0))
36557 return -EINTR;
36558
36559 return 0;
36560 @@ -526,7 +526,7 @@ int ib_fmr_pool_unmap(struct ib_pool_fmr *fmr)
36561 } else {
36562 list_add_tail(&fmr->list, &pool->dirty_list);
36563 if (++pool->dirty_len >= pool->dirty_watermark) {
36564 - atomic_inc(&pool->req_ser);
36565 + atomic_inc_unchecked(&pool->req_ser);
36566 wake_up_process(pool->thread);
36567 }
36568 }
36569 diff --git a/drivers/infiniband/hw/cxgb4/mem.c b/drivers/infiniband/hw/cxgb4/mem.c
36570 index afd8179..598063f 100644
36571 --- a/drivers/infiniband/hw/cxgb4/mem.c
36572 +++ b/drivers/infiniband/hw/cxgb4/mem.c
36573 @@ -122,7 +122,7 @@ static int write_tpt_entry(struct c4iw_rdev *rdev, u32 reset_tpt_entry,
36574 int err;
36575 struct fw_ri_tpte tpt;
36576 u32 stag_idx;
36577 - static atomic_t key;
36578 + static atomic_unchecked_t key;
36579
36580 if (c4iw_fatal_error(rdev))
36581 return -EIO;
36582 @@ -139,7 +139,7 @@ static int write_tpt_entry(struct c4iw_rdev *rdev, u32 reset_tpt_entry,
36583 if (rdev->stats.stag.cur > rdev->stats.stag.max)
36584 rdev->stats.stag.max = rdev->stats.stag.cur;
36585 mutex_unlock(&rdev->stats.lock);
36586 - *stag = (stag_idx << 8) | (atomic_inc_return(&key) & 0xff);
36587 + *stag = (stag_idx << 8) | (atomic_inc_return_unchecked(&key) & 0xff);
36588 }
36589 PDBG("%s stag_state 0x%0x type 0x%0x pdid 0x%0x, stag_idx 0x%x\n",
36590 __func__, stag_state, type, pdid, stag_idx);
36591 diff --git a/drivers/infiniband/hw/ipath/ipath_rc.c b/drivers/infiniband/hw/ipath/ipath_rc.c
36592 index 79b3dbc..96e5fcc 100644
36593 --- a/drivers/infiniband/hw/ipath/ipath_rc.c
36594 +++ b/drivers/infiniband/hw/ipath/ipath_rc.c
36595 @@ -1868,7 +1868,7 @@ void ipath_rc_rcv(struct ipath_ibdev *dev, struct ipath_ib_header *hdr,
36596 struct ib_atomic_eth *ateth;
36597 struct ipath_ack_entry *e;
36598 u64 vaddr;
36599 - atomic64_t *maddr;
36600 + atomic64_unchecked_t *maddr;
36601 u64 sdata;
36602 u32 rkey;
36603 u8 next;
36604 @@ -1903,11 +1903,11 @@ void ipath_rc_rcv(struct ipath_ibdev *dev, struct ipath_ib_header *hdr,
36605 IB_ACCESS_REMOTE_ATOMIC)))
36606 goto nack_acc_unlck;
36607 /* Perform atomic OP and save result. */
36608 - maddr = (atomic64_t *) qp->r_sge.sge.vaddr;
36609 + maddr = (atomic64_unchecked_t *) qp->r_sge.sge.vaddr;
36610 sdata = be64_to_cpu(ateth->swap_data);
36611 e = &qp->s_ack_queue[qp->r_head_ack_queue];
36612 e->atomic_data = (opcode == OP(FETCH_ADD)) ?
36613 - (u64) atomic64_add_return(sdata, maddr) - sdata :
36614 + (u64) atomic64_add_return_unchecked(sdata, maddr) - sdata :
36615 (u64) cmpxchg((u64 *) qp->r_sge.sge.vaddr,
36616 be64_to_cpu(ateth->compare_data),
36617 sdata);
36618 diff --git a/drivers/infiniband/hw/ipath/ipath_ruc.c b/drivers/infiniband/hw/ipath/ipath_ruc.c
36619 index 1f95bba..9530f87 100644
36620 --- a/drivers/infiniband/hw/ipath/ipath_ruc.c
36621 +++ b/drivers/infiniband/hw/ipath/ipath_ruc.c
36622 @@ -266,7 +266,7 @@ static void ipath_ruc_loopback(struct ipath_qp *sqp)
36623 unsigned long flags;
36624 struct ib_wc wc;
36625 u64 sdata;
36626 - atomic64_t *maddr;
36627 + atomic64_unchecked_t *maddr;
36628 enum ib_wc_status send_status;
36629
36630 /*
36631 @@ -382,11 +382,11 @@ again:
36632 IB_ACCESS_REMOTE_ATOMIC)))
36633 goto acc_err;
36634 /* Perform atomic OP and save result. */
36635 - maddr = (atomic64_t *) qp->r_sge.sge.vaddr;
36636 + maddr = (atomic64_unchecked_t *) qp->r_sge.sge.vaddr;
36637 sdata = wqe->wr.wr.atomic.compare_add;
36638 *(u64 *) sqp->s_sge.sge.vaddr =
36639 (wqe->wr.opcode == IB_WR_ATOMIC_FETCH_AND_ADD) ?
36640 - (u64) atomic64_add_return(sdata, maddr) - sdata :
36641 + (u64) atomic64_add_return_unchecked(sdata, maddr) - sdata :
36642 (u64) cmpxchg((u64 *) qp->r_sge.sge.vaddr,
36643 sdata, wqe->wr.wr.atomic.swap);
36644 goto send_comp;
36645 diff --git a/drivers/infiniband/hw/mthca/mthca_cmd.c b/drivers/infiniband/hw/mthca/mthca_cmd.c
36646 index 9d3e5c1..d9afe4a 100644
36647 --- a/drivers/infiniband/hw/mthca/mthca_cmd.c
36648 +++ b/drivers/infiniband/hw/mthca/mthca_cmd.c
36649 @@ -772,7 +772,7 @@ static void mthca_setup_cmd_doorbells(struct mthca_dev *dev, u64 base)
36650 mthca_dbg(dev, "Mapped doorbell page for posting FW commands\n");
36651 }
36652
36653 -int mthca_QUERY_FW(struct mthca_dev *dev)
36654 +int __intentional_overflow(-1) mthca_QUERY_FW(struct mthca_dev *dev)
36655 {
36656 struct mthca_mailbox *mailbox;
36657 u32 *outbox;
36658 diff --git a/drivers/infiniband/hw/mthca/mthca_mr.c b/drivers/infiniband/hw/mthca/mthca_mr.c
36659 index ed9a989..e0c5871 100644
36660 --- a/drivers/infiniband/hw/mthca/mthca_mr.c
36661 +++ b/drivers/infiniband/hw/mthca/mthca_mr.c
36662 @@ -426,7 +426,7 @@ static inline u32 adjust_key(struct mthca_dev *dev, u32 key)
36663 return key;
36664 }
36665
36666 -int mthca_mr_alloc(struct mthca_dev *dev, u32 pd, int buffer_size_shift,
36667 +int __intentional_overflow(-1) mthca_mr_alloc(struct mthca_dev *dev, u32 pd, int buffer_size_shift,
36668 u64 iova, u64 total_size, u32 access, struct mthca_mr *mr)
36669 {
36670 struct mthca_mailbox *mailbox;
36671 diff --git a/drivers/infiniband/hw/nes/nes.c b/drivers/infiniband/hw/nes/nes.c
36672 index 5b152a3..c1f3e83 100644
36673 --- a/drivers/infiniband/hw/nes/nes.c
36674 +++ b/drivers/infiniband/hw/nes/nes.c
36675 @@ -98,7 +98,7 @@ MODULE_PARM_DESC(limit_maxrdreqsz, "Limit max read request size to 256 Bytes");
36676 LIST_HEAD(nes_adapter_list);
36677 static LIST_HEAD(nes_dev_list);
36678
36679 -atomic_t qps_destroyed;
36680 +atomic_unchecked_t qps_destroyed;
36681
36682 static unsigned int ee_flsh_adapter;
36683 static unsigned int sysfs_nonidx_addr;
36684 @@ -267,7 +267,7 @@ static void nes_cqp_rem_ref_callback(struct nes_device *nesdev, struct nes_cqp_r
36685 struct nes_qp *nesqp = cqp_request->cqp_callback_pointer;
36686 struct nes_adapter *nesadapter = nesdev->nesadapter;
36687
36688 - atomic_inc(&qps_destroyed);
36689 + atomic_inc_unchecked(&qps_destroyed);
36690
36691 /* Free the control structures */
36692
36693 diff --git a/drivers/infiniband/hw/nes/nes.h b/drivers/infiniband/hw/nes/nes.h
36694 index 33cc589..3bd6538 100644
36695 --- a/drivers/infiniband/hw/nes/nes.h
36696 +++ b/drivers/infiniband/hw/nes/nes.h
36697 @@ -177,17 +177,17 @@ extern unsigned int nes_debug_level;
36698 extern unsigned int wqm_quanta;
36699 extern struct list_head nes_adapter_list;
36700
36701 -extern atomic_t cm_connects;
36702 -extern atomic_t cm_accepts;
36703 -extern atomic_t cm_disconnects;
36704 -extern atomic_t cm_closes;
36705 -extern atomic_t cm_connecteds;
36706 -extern atomic_t cm_connect_reqs;
36707 -extern atomic_t cm_rejects;
36708 -extern atomic_t mod_qp_timouts;
36709 -extern atomic_t qps_created;
36710 -extern atomic_t qps_destroyed;
36711 -extern atomic_t sw_qps_destroyed;
36712 +extern atomic_unchecked_t cm_connects;
36713 +extern atomic_unchecked_t cm_accepts;
36714 +extern atomic_unchecked_t cm_disconnects;
36715 +extern atomic_unchecked_t cm_closes;
36716 +extern atomic_unchecked_t cm_connecteds;
36717 +extern atomic_unchecked_t cm_connect_reqs;
36718 +extern atomic_unchecked_t cm_rejects;
36719 +extern atomic_unchecked_t mod_qp_timouts;
36720 +extern atomic_unchecked_t qps_created;
36721 +extern atomic_unchecked_t qps_destroyed;
36722 +extern atomic_unchecked_t sw_qps_destroyed;
36723 extern u32 mh_detected;
36724 extern u32 mh_pauses_sent;
36725 extern u32 cm_packets_sent;
36726 @@ -196,16 +196,16 @@ extern u32 cm_packets_created;
36727 extern u32 cm_packets_received;
36728 extern u32 cm_packets_dropped;
36729 extern u32 cm_packets_retrans;
36730 -extern atomic_t cm_listens_created;
36731 -extern atomic_t cm_listens_destroyed;
36732 +extern atomic_unchecked_t cm_listens_created;
36733 +extern atomic_unchecked_t cm_listens_destroyed;
36734 extern u32 cm_backlog_drops;
36735 -extern atomic_t cm_loopbacks;
36736 -extern atomic_t cm_nodes_created;
36737 -extern atomic_t cm_nodes_destroyed;
36738 -extern atomic_t cm_accel_dropped_pkts;
36739 -extern atomic_t cm_resets_recvd;
36740 -extern atomic_t pau_qps_created;
36741 -extern atomic_t pau_qps_destroyed;
36742 +extern atomic_unchecked_t cm_loopbacks;
36743 +extern atomic_unchecked_t cm_nodes_created;
36744 +extern atomic_unchecked_t cm_nodes_destroyed;
36745 +extern atomic_unchecked_t cm_accel_dropped_pkts;
36746 +extern atomic_unchecked_t cm_resets_recvd;
36747 +extern atomic_unchecked_t pau_qps_created;
36748 +extern atomic_unchecked_t pau_qps_destroyed;
36749
36750 extern u32 int_mod_timer_init;
36751 extern u32 int_mod_cq_depth_256;
36752 diff --git a/drivers/infiniband/hw/nes/nes_cm.c b/drivers/infiniband/hw/nes/nes_cm.c
36753 index 22ea67e..dcbe3bc 100644
36754 --- a/drivers/infiniband/hw/nes/nes_cm.c
36755 +++ b/drivers/infiniband/hw/nes/nes_cm.c
36756 @@ -68,14 +68,14 @@ u32 cm_packets_dropped;
36757 u32 cm_packets_retrans;
36758 u32 cm_packets_created;
36759 u32 cm_packets_received;
36760 -atomic_t cm_listens_created;
36761 -atomic_t cm_listens_destroyed;
36762 +atomic_unchecked_t cm_listens_created;
36763 +atomic_unchecked_t cm_listens_destroyed;
36764 u32 cm_backlog_drops;
36765 -atomic_t cm_loopbacks;
36766 -atomic_t cm_nodes_created;
36767 -atomic_t cm_nodes_destroyed;
36768 -atomic_t cm_accel_dropped_pkts;
36769 -atomic_t cm_resets_recvd;
36770 +atomic_unchecked_t cm_loopbacks;
36771 +atomic_unchecked_t cm_nodes_created;
36772 +atomic_unchecked_t cm_nodes_destroyed;
36773 +atomic_unchecked_t cm_accel_dropped_pkts;
36774 +atomic_unchecked_t cm_resets_recvd;
36775
36776 static inline int mini_cm_accelerated(struct nes_cm_core *, struct nes_cm_node *);
36777 static struct nes_cm_listener *mini_cm_listen(struct nes_cm_core *, struct nes_vnic *, struct nes_cm_info *);
36778 @@ -148,13 +148,13 @@ static struct nes_cm_ops nes_cm_api = {
36779
36780 static struct nes_cm_core *g_cm_core;
36781
36782 -atomic_t cm_connects;
36783 -atomic_t cm_accepts;
36784 -atomic_t cm_disconnects;
36785 -atomic_t cm_closes;
36786 -atomic_t cm_connecteds;
36787 -atomic_t cm_connect_reqs;
36788 -atomic_t cm_rejects;
36789 +atomic_unchecked_t cm_connects;
36790 +atomic_unchecked_t cm_accepts;
36791 +atomic_unchecked_t cm_disconnects;
36792 +atomic_unchecked_t cm_closes;
36793 +atomic_unchecked_t cm_connecteds;
36794 +atomic_unchecked_t cm_connect_reqs;
36795 +atomic_unchecked_t cm_rejects;
36796
36797 int nes_add_ref_cm_node(struct nes_cm_node *cm_node)
36798 {
36799 @@ -1272,7 +1272,7 @@ static int mini_cm_dec_refcnt_listen(struct nes_cm_core *cm_core,
36800 kfree(listener);
36801 listener = NULL;
36802 ret = 0;
36803 - atomic_inc(&cm_listens_destroyed);
36804 + atomic_inc_unchecked(&cm_listens_destroyed);
36805 } else {
36806 spin_unlock_irqrestore(&cm_core->listen_list_lock, flags);
36807 }
36808 @@ -1466,7 +1466,7 @@ static struct nes_cm_node *make_cm_node(struct nes_cm_core *cm_core,
36809 cm_node->rem_mac);
36810
36811 add_hte_node(cm_core, cm_node);
36812 - atomic_inc(&cm_nodes_created);
36813 + atomic_inc_unchecked(&cm_nodes_created);
36814
36815 return cm_node;
36816 }
36817 @@ -1524,7 +1524,7 @@ static int rem_ref_cm_node(struct nes_cm_core *cm_core,
36818 }
36819
36820 atomic_dec(&cm_core->node_cnt);
36821 - atomic_inc(&cm_nodes_destroyed);
36822 + atomic_inc_unchecked(&cm_nodes_destroyed);
36823 nesqp = cm_node->nesqp;
36824 if (nesqp) {
36825 nesqp->cm_node = NULL;
36826 @@ -1588,7 +1588,7 @@ static int process_options(struct nes_cm_node *cm_node, u8 *optionsloc,
36827
36828 static void drop_packet(struct sk_buff *skb)
36829 {
36830 - atomic_inc(&cm_accel_dropped_pkts);
36831 + atomic_inc_unchecked(&cm_accel_dropped_pkts);
36832 dev_kfree_skb_any(skb);
36833 }
36834
36835 @@ -1651,7 +1651,7 @@ static void handle_rst_pkt(struct nes_cm_node *cm_node, struct sk_buff *skb,
36836 {
36837
36838 int reset = 0; /* whether to send reset in case of err.. */
36839 - atomic_inc(&cm_resets_recvd);
36840 + atomic_inc_unchecked(&cm_resets_recvd);
36841 nes_debug(NES_DBG_CM, "Received Reset, cm_node = %p, state = %u."
36842 " refcnt=%d\n", cm_node, cm_node->state,
36843 atomic_read(&cm_node->ref_count));
36844 @@ -2292,7 +2292,7 @@ static struct nes_cm_node *mini_cm_connect(struct nes_cm_core *cm_core,
36845 rem_ref_cm_node(cm_node->cm_core, cm_node);
36846 return NULL;
36847 }
36848 - atomic_inc(&cm_loopbacks);
36849 + atomic_inc_unchecked(&cm_loopbacks);
36850 loopbackremotenode->loopbackpartner = cm_node;
36851 loopbackremotenode->tcp_cntxt.rcv_wscale =
36852 NES_CM_DEFAULT_RCV_WND_SCALE;
36853 @@ -2567,7 +2567,7 @@ static int mini_cm_recv_pkt(struct nes_cm_core *cm_core,
36854 nes_queue_mgt_skbs(skb, nesvnic, cm_node->nesqp);
36855 else {
36856 rem_ref_cm_node(cm_core, cm_node);
36857 - atomic_inc(&cm_accel_dropped_pkts);
36858 + atomic_inc_unchecked(&cm_accel_dropped_pkts);
36859 dev_kfree_skb_any(skb);
36860 }
36861 break;
36862 @@ -2875,7 +2875,7 @@ static int nes_cm_disconn_true(struct nes_qp *nesqp)
36863
36864 if ((cm_id) && (cm_id->event_handler)) {
36865 if (issue_disconn) {
36866 - atomic_inc(&cm_disconnects);
36867 + atomic_inc_unchecked(&cm_disconnects);
36868 cm_event.event = IW_CM_EVENT_DISCONNECT;
36869 cm_event.status = disconn_status;
36870 cm_event.local_addr = cm_id->local_addr;
36871 @@ -2897,7 +2897,7 @@ static int nes_cm_disconn_true(struct nes_qp *nesqp)
36872 }
36873
36874 if (issue_close) {
36875 - atomic_inc(&cm_closes);
36876 + atomic_inc_unchecked(&cm_closes);
36877 nes_disconnect(nesqp, 1);
36878
36879 cm_id->provider_data = nesqp;
36880 @@ -3033,7 +3033,7 @@ int nes_accept(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
36881
36882 nes_debug(NES_DBG_CM, "QP%u, cm_node=%p, jiffies = %lu listener = %p\n",
36883 nesqp->hwqp.qp_id, cm_node, jiffies, cm_node->listener);
36884 - atomic_inc(&cm_accepts);
36885 + atomic_inc_unchecked(&cm_accepts);
36886
36887 nes_debug(NES_DBG_CM, "netdev refcnt = %u.\n",
36888 netdev_refcnt_read(nesvnic->netdev));
36889 @@ -3228,7 +3228,7 @@ int nes_reject(struct iw_cm_id *cm_id, const void *pdata, u8 pdata_len)
36890 struct nes_cm_core *cm_core;
36891 u8 *start_buff;
36892
36893 - atomic_inc(&cm_rejects);
36894 + atomic_inc_unchecked(&cm_rejects);
36895 cm_node = (struct nes_cm_node *)cm_id->provider_data;
36896 loopback = cm_node->loopbackpartner;
36897 cm_core = cm_node->cm_core;
36898 @@ -3288,7 +3288,7 @@ int nes_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
36899 ntohl(cm_id->local_addr.sin_addr.s_addr),
36900 ntohs(cm_id->local_addr.sin_port));
36901
36902 - atomic_inc(&cm_connects);
36903 + atomic_inc_unchecked(&cm_connects);
36904 nesqp->active_conn = 1;
36905
36906 /* cache the cm_id in the qp */
36907 @@ -3398,7 +3398,7 @@ int nes_create_listen(struct iw_cm_id *cm_id, int backlog)
36908 g_cm_core->api->stop_listener(g_cm_core, (void *)cm_node);
36909 return err;
36910 }
36911 - atomic_inc(&cm_listens_created);
36912 + atomic_inc_unchecked(&cm_listens_created);
36913 }
36914
36915 cm_id->add_ref(cm_id);
36916 @@ -3499,7 +3499,7 @@ static void cm_event_connected(struct nes_cm_event *event)
36917
36918 if (nesqp->destroyed)
36919 return;
36920 - atomic_inc(&cm_connecteds);
36921 + atomic_inc_unchecked(&cm_connecteds);
36922 nes_debug(NES_DBG_CM, "QP%u attempting to connect to 0x%08X:0x%04X on"
36923 " local port 0x%04X. jiffies = %lu.\n",
36924 nesqp->hwqp.qp_id,
36925 @@ -3679,7 +3679,7 @@ static void cm_event_reset(struct nes_cm_event *event)
36926
36927 cm_id->add_ref(cm_id);
36928 ret = cm_id->event_handler(cm_id, &cm_event);
36929 - atomic_inc(&cm_closes);
36930 + atomic_inc_unchecked(&cm_closes);
36931 cm_event.event = IW_CM_EVENT_CLOSE;
36932 cm_event.status = 0;
36933 cm_event.provider_data = cm_id->provider_data;
36934 @@ -3715,7 +3715,7 @@ static void cm_event_mpa_req(struct nes_cm_event *event)
36935 return;
36936 cm_id = cm_node->cm_id;
36937
36938 - atomic_inc(&cm_connect_reqs);
36939 + atomic_inc_unchecked(&cm_connect_reqs);
36940 nes_debug(NES_DBG_CM, "cm_node = %p - cm_id = %p, jiffies = %lu\n",
36941 cm_node, cm_id, jiffies);
36942
36943 @@ -3755,7 +3755,7 @@ static void cm_event_mpa_reject(struct nes_cm_event *event)
36944 return;
36945 cm_id = cm_node->cm_id;
36946
36947 - atomic_inc(&cm_connect_reqs);
36948 + atomic_inc_unchecked(&cm_connect_reqs);
36949 nes_debug(NES_DBG_CM, "cm_node = %p - cm_id = %p, jiffies = %lu\n",
36950 cm_node, cm_id, jiffies);
36951
36952 diff --git a/drivers/infiniband/hw/nes/nes_mgt.c b/drivers/infiniband/hw/nes/nes_mgt.c
36953 index 4166452..fc952c3 100644
36954 --- a/drivers/infiniband/hw/nes/nes_mgt.c
36955 +++ b/drivers/infiniband/hw/nes/nes_mgt.c
36956 @@ -40,8 +40,8 @@
36957 #include "nes.h"
36958 #include "nes_mgt.h"
36959
36960 -atomic_t pau_qps_created;
36961 -atomic_t pau_qps_destroyed;
36962 +atomic_unchecked_t pau_qps_created;
36963 +atomic_unchecked_t pau_qps_destroyed;
36964
36965 static void nes_replenish_mgt_rq(struct nes_vnic_mgt *mgtvnic)
36966 {
36967 @@ -621,7 +621,7 @@ void nes_destroy_pau_qp(struct nes_device *nesdev, struct nes_qp *nesqp)
36968 {
36969 struct sk_buff *skb;
36970 unsigned long flags;
36971 - atomic_inc(&pau_qps_destroyed);
36972 + atomic_inc_unchecked(&pau_qps_destroyed);
36973
36974 /* Free packets that have not yet been forwarded */
36975 /* Lock is acquired by skb_dequeue when removing the skb */
36976 @@ -810,7 +810,7 @@ static void nes_mgt_ce_handler(struct nes_device *nesdev, struct nes_hw_nic_cq *
36977 cq->cq_vbase[head].cqe_words[NES_NIC_CQE_HASH_RCVNXT]);
36978 skb_queue_head_init(&nesqp->pau_list);
36979 spin_lock_init(&nesqp->pau_lock);
36980 - atomic_inc(&pau_qps_created);
36981 + atomic_inc_unchecked(&pau_qps_created);
36982 nes_change_quad_hash(nesdev, mgtvnic->nesvnic, nesqp);
36983 }
36984
36985 diff --git a/drivers/infiniband/hw/nes/nes_nic.c b/drivers/infiniband/hw/nes/nes_nic.c
36986 index 9542e16..a008c40 100644
36987 --- a/drivers/infiniband/hw/nes/nes_nic.c
36988 +++ b/drivers/infiniband/hw/nes/nes_nic.c
36989 @@ -1273,39 +1273,39 @@ static void nes_netdev_get_ethtool_stats(struct net_device *netdev,
36990 target_stat_values[++index] = mh_detected;
36991 target_stat_values[++index] = mh_pauses_sent;
36992 target_stat_values[++index] = nesvnic->endnode_ipv4_tcp_retransmits;
36993 - target_stat_values[++index] = atomic_read(&cm_connects);
36994 - target_stat_values[++index] = atomic_read(&cm_accepts);
36995 - target_stat_values[++index] = atomic_read(&cm_disconnects);
36996 - target_stat_values[++index] = atomic_read(&cm_connecteds);
36997 - target_stat_values[++index] = atomic_read(&cm_connect_reqs);
36998 - target_stat_values[++index] = atomic_read(&cm_rejects);
36999 - target_stat_values[++index] = atomic_read(&mod_qp_timouts);
37000 - target_stat_values[++index] = atomic_read(&qps_created);
37001 - target_stat_values[++index] = atomic_read(&sw_qps_destroyed);
37002 - target_stat_values[++index] = atomic_read(&qps_destroyed);
37003 - target_stat_values[++index] = atomic_read(&cm_closes);
37004 + target_stat_values[++index] = atomic_read_unchecked(&cm_connects);
37005 + target_stat_values[++index] = atomic_read_unchecked(&cm_accepts);
37006 + target_stat_values[++index] = atomic_read_unchecked(&cm_disconnects);
37007 + target_stat_values[++index] = atomic_read_unchecked(&cm_connecteds);
37008 + target_stat_values[++index] = atomic_read_unchecked(&cm_connect_reqs);
37009 + target_stat_values[++index] = atomic_read_unchecked(&cm_rejects);
37010 + target_stat_values[++index] = atomic_read_unchecked(&mod_qp_timouts);
37011 + target_stat_values[++index] = atomic_read_unchecked(&qps_created);
37012 + target_stat_values[++index] = atomic_read_unchecked(&sw_qps_destroyed);
37013 + target_stat_values[++index] = atomic_read_unchecked(&qps_destroyed);
37014 + target_stat_values[++index] = atomic_read_unchecked(&cm_closes);
37015 target_stat_values[++index] = cm_packets_sent;
37016 target_stat_values[++index] = cm_packets_bounced;
37017 target_stat_values[++index] = cm_packets_created;
37018 target_stat_values[++index] = cm_packets_received;
37019 target_stat_values[++index] = cm_packets_dropped;
37020 target_stat_values[++index] = cm_packets_retrans;
37021 - target_stat_values[++index] = atomic_read(&cm_listens_created);
37022 - target_stat_values[++index] = atomic_read(&cm_listens_destroyed);
37023 + target_stat_values[++index] = atomic_read_unchecked(&cm_listens_created);
37024 + target_stat_values[++index] = atomic_read_unchecked(&cm_listens_destroyed);
37025 target_stat_values[++index] = cm_backlog_drops;
37026 - target_stat_values[++index] = atomic_read(&cm_loopbacks);
37027 - target_stat_values[++index] = atomic_read(&cm_nodes_created);
37028 - target_stat_values[++index] = atomic_read(&cm_nodes_destroyed);
37029 - target_stat_values[++index] = atomic_read(&cm_accel_dropped_pkts);
37030 - target_stat_values[++index] = atomic_read(&cm_resets_recvd);
37031 + target_stat_values[++index] = atomic_read_unchecked(&cm_loopbacks);
37032 + target_stat_values[++index] = atomic_read_unchecked(&cm_nodes_created);
37033 + target_stat_values[++index] = atomic_read_unchecked(&cm_nodes_destroyed);
37034 + target_stat_values[++index] = atomic_read_unchecked(&cm_accel_dropped_pkts);
37035 + target_stat_values[++index] = atomic_read_unchecked(&cm_resets_recvd);
37036 target_stat_values[++index] = nesadapter->free_4kpbl;
37037 target_stat_values[++index] = nesadapter->free_256pbl;
37038 target_stat_values[++index] = int_mod_timer_init;
37039 target_stat_values[++index] = nesvnic->lro_mgr.stats.aggregated;
37040 target_stat_values[++index] = nesvnic->lro_mgr.stats.flushed;
37041 target_stat_values[++index] = nesvnic->lro_mgr.stats.no_desc;
37042 - target_stat_values[++index] = atomic_read(&pau_qps_created);
37043 - target_stat_values[++index] = atomic_read(&pau_qps_destroyed);
37044 + target_stat_values[++index] = atomic_read_unchecked(&pau_qps_created);
37045 + target_stat_values[++index] = atomic_read_unchecked(&pau_qps_destroyed);
37046 }
37047
37048 /**
37049 diff --git a/drivers/infiniband/hw/nes/nes_verbs.c b/drivers/infiniband/hw/nes/nes_verbs.c
37050 index 07e4fba..685f041 100644
37051 --- a/drivers/infiniband/hw/nes/nes_verbs.c
37052 +++ b/drivers/infiniband/hw/nes/nes_verbs.c
37053 @@ -46,9 +46,9 @@
37054
37055 #include <rdma/ib_umem.h>
37056
37057 -atomic_t mod_qp_timouts;
37058 -atomic_t qps_created;
37059 -atomic_t sw_qps_destroyed;
37060 +atomic_unchecked_t mod_qp_timouts;
37061 +atomic_unchecked_t qps_created;
37062 +atomic_unchecked_t sw_qps_destroyed;
37063
37064 static void nes_unregister_ofa_device(struct nes_ib_device *nesibdev);
37065
37066 @@ -1131,7 +1131,7 @@ static struct ib_qp *nes_create_qp(struct ib_pd *ibpd,
37067 if (init_attr->create_flags)
37068 return ERR_PTR(-EINVAL);
37069
37070 - atomic_inc(&qps_created);
37071 + atomic_inc_unchecked(&qps_created);
37072 switch (init_attr->qp_type) {
37073 case IB_QPT_RC:
37074 if (nes_drv_opt & NES_DRV_OPT_NO_INLINE_DATA) {
37075 @@ -1462,7 +1462,7 @@ static int nes_destroy_qp(struct ib_qp *ibqp)
37076 struct iw_cm_event cm_event;
37077 int ret = 0;
37078
37079 - atomic_inc(&sw_qps_destroyed);
37080 + atomic_inc_unchecked(&sw_qps_destroyed);
37081 nesqp->destroyed = 1;
37082
37083 /* Blow away the connection if it exists. */
37084 diff --git a/drivers/infiniband/hw/qib/qib.h b/drivers/infiniband/hw/qib/qib.h
37085 index 4d11575..3e890e5 100644
37086 --- a/drivers/infiniband/hw/qib/qib.h
37087 +++ b/drivers/infiniband/hw/qib/qib.h
37088 @@ -51,6 +51,7 @@
37089 #include <linux/completion.h>
37090 #include <linux/kref.h>
37091 #include <linux/sched.h>
37092 +#include <linux/slab.h>
37093
37094 #include "qib_common.h"
37095 #include "qib_verbs.h"
37096 diff --git a/drivers/input/gameport/gameport.c b/drivers/input/gameport/gameport.c
37097 index da739d9..da1c7f4 100644
37098 --- a/drivers/input/gameport/gameport.c
37099 +++ b/drivers/input/gameport/gameport.c
37100 @@ -487,14 +487,14 @@ EXPORT_SYMBOL(gameport_set_phys);
37101 */
37102 static void gameport_init_port(struct gameport *gameport)
37103 {
37104 - static atomic_t gameport_no = ATOMIC_INIT(0);
37105 + static atomic_unchecked_t gameport_no = ATOMIC_INIT(0);
37106
37107 __module_get(THIS_MODULE);
37108
37109 mutex_init(&gameport->drv_mutex);
37110 device_initialize(&gameport->dev);
37111 dev_set_name(&gameport->dev, "gameport%lu",
37112 - (unsigned long)atomic_inc_return(&gameport_no) - 1);
37113 + (unsigned long)atomic_inc_return_unchecked(&gameport_no) - 1);
37114 gameport->dev.bus = &gameport_bus;
37115 gameport->dev.release = gameport_release_port;
37116 if (gameport->parent)
37117 diff --git a/drivers/input/input.c b/drivers/input/input.c
37118 index c044699..174d71a 100644
37119 --- a/drivers/input/input.c
37120 +++ b/drivers/input/input.c
37121 @@ -2019,7 +2019,7 @@ static void devm_input_device_unregister(struct device *dev, void *res)
37122 */
37123 int input_register_device(struct input_dev *dev)
37124 {
37125 - static atomic_t input_no = ATOMIC_INIT(0);
37126 + static atomic_unchecked_t input_no = ATOMIC_INIT(0);
37127 struct input_devres *devres = NULL;
37128 struct input_handler *handler;
37129 unsigned int packet_size;
37130 @@ -2074,7 +2074,7 @@ int input_register_device(struct input_dev *dev)
37131 dev->setkeycode = input_default_setkeycode;
37132
37133 dev_set_name(&dev->dev, "input%ld",
37134 - (unsigned long) atomic_inc_return(&input_no) - 1);
37135 + (unsigned long) atomic_inc_return_unchecked(&input_no) - 1);
37136
37137 error = device_add(&dev->dev);
37138 if (error)
37139 diff --git a/drivers/input/joystick/sidewinder.c b/drivers/input/joystick/sidewinder.c
37140 index 04c69af..5f92d00 100644
37141 --- a/drivers/input/joystick/sidewinder.c
37142 +++ b/drivers/input/joystick/sidewinder.c
37143 @@ -30,6 +30,7 @@
37144 #include <linux/kernel.h>
37145 #include <linux/module.h>
37146 #include <linux/slab.h>
37147 +#include <linux/sched.h>
37148 #include <linux/init.h>
37149 #include <linux/input.h>
37150 #include <linux/gameport.h>
37151 diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
37152 index d6cbfe9..6225402 100644
37153 --- a/drivers/input/joystick/xpad.c
37154 +++ b/drivers/input/joystick/xpad.c
37155 @@ -735,7 +735,7 @@ static void xpad_led_set(struct led_classdev *led_cdev,
37156
37157 static int xpad_led_probe(struct usb_xpad *xpad)
37158 {
37159 - static atomic_t led_seq = ATOMIC_INIT(0);
37160 + static atomic_unchecked_t led_seq = ATOMIC_INIT(0);
37161 long led_no;
37162 struct xpad_led *led;
37163 struct led_classdev *led_cdev;
37164 @@ -748,7 +748,7 @@ static int xpad_led_probe(struct usb_xpad *xpad)
37165 if (!led)
37166 return -ENOMEM;
37167
37168 - led_no = (long)atomic_inc_return(&led_seq) - 1;
37169 + led_no = (long)atomic_inc_return_unchecked(&led_seq) - 1;
37170
37171 snprintf(led->name, sizeof(led->name), "xpad%ld", led_no);
37172 led->xpad = xpad;
37173 diff --git a/drivers/input/mouse/psmouse.h b/drivers/input/mouse/psmouse.h
37174 index fe1df23..5b710f3 100644
37175 --- a/drivers/input/mouse/psmouse.h
37176 +++ b/drivers/input/mouse/psmouse.h
37177 @@ -115,7 +115,7 @@ struct psmouse_attribute {
37178 ssize_t (*set)(struct psmouse *psmouse, void *data,
37179 const char *buf, size_t count);
37180 bool protect;
37181 -};
37182 +} __do_const;
37183 #define to_psmouse_attr(a) container_of((a), struct psmouse_attribute, dattr)
37184
37185 ssize_t psmouse_attr_show_helper(struct device *dev, struct device_attribute *attr,
37186 diff --git a/drivers/input/mousedev.c b/drivers/input/mousedev.c
37187 index 4c842c3..590b0bf 100644
37188 --- a/drivers/input/mousedev.c
37189 +++ b/drivers/input/mousedev.c
37190 @@ -738,7 +738,7 @@ static ssize_t mousedev_read(struct file *file, char __user *buffer,
37191
37192 spin_unlock_irq(&client->packet_lock);
37193
37194 - if (copy_to_user(buffer, data, count))
37195 + if (count > sizeof(data) || copy_to_user(buffer, data, count))
37196 return -EFAULT;
37197
37198 return count;
37199 diff --git a/drivers/input/serio/serio.c b/drivers/input/serio/serio.c
37200 index 25fc597..558bf3b 100644
37201 --- a/drivers/input/serio/serio.c
37202 +++ b/drivers/input/serio/serio.c
37203 @@ -496,7 +496,7 @@ static void serio_release_port(struct device *dev)
37204 */
37205 static void serio_init_port(struct serio *serio)
37206 {
37207 - static atomic_t serio_no = ATOMIC_INIT(0);
37208 + static atomic_unchecked_t serio_no = ATOMIC_INIT(0);
37209
37210 __module_get(THIS_MODULE);
37211
37212 @@ -507,7 +507,7 @@ static void serio_init_port(struct serio *serio)
37213 mutex_init(&serio->drv_mutex);
37214 device_initialize(&serio->dev);
37215 dev_set_name(&serio->dev, "serio%ld",
37216 - (long)atomic_inc_return(&serio_no) - 1);
37217 + (long)atomic_inc_return_unchecked(&serio_no) - 1);
37218 serio->dev.bus = &serio_bus;
37219 serio->dev.release = serio_release_port;
37220 serio->dev.groups = serio_device_attr_groups;
37221 diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
37222 index ddbdaca..be18a78 100644
37223 --- a/drivers/iommu/iommu.c
37224 +++ b/drivers/iommu/iommu.c
37225 @@ -554,7 +554,7 @@ static struct notifier_block iommu_bus_nb = {
37226 static void iommu_bus_init(struct bus_type *bus, struct iommu_ops *ops)
37227 {
37228 bus_register_notifier(bus, &iommu_bus_nb);
37229 - bus_for_each_dev(bus, NULL, ops, add_iommu_group);
37230 + bus_for_each_dev(bus, NULL, (void *)ops, add_iommu_group);
37231 }
37232
37233 /**
37234 diff --git a/drivers/isdn/capi/capi.c b/drivers/isdn/capi/capi.c
37235 index 89562a8..218999b 100644
37236 --- a/drivers/isdn/capi/capi.c
37237 +++ b/drivers/isdn/capi/capi.c
37238 @@ -81,8 +81,8 @@ struct capiminor {
37239
37240 struct capi20_appl *ap;
37241 u32 ncci;
37242 - atomic_t datahandle;
37243 - atomic_t msgid;
37244 + atomic_unchecked_t datahandle;
37245 + atomic_unchecked_t msgid;
37246
37247 struct tty_port port;
37248 int ttyinstop;
37249 @@ -391,7 +391,7 @@ gen_data_b3_resp_for(struct capiminor *mp, struct sk_buff *skb)
37250 capimsg_setu16(s, 2, mp->ap->applid);
37251 capimsg_setu8 (s, 4, CAPI_DATA_B3);
37252 capimsg_setu8 (s, 5, CAPI_RESP);
37253 - capimsg_setu16(s, 6, atomic_inc_return(&mp->msgid));
37254 + capimsg_setu16(s, 6, atomic_inc_return_unchecked(&mp->msgid));
37255 capimsg_setu32(s, 8, mp->ncci);
37256 capimsg_setu16(s, 12, datahandle);
37257 }
37258 @@ -512,14 +512,14 @@ static void handle_minor_send(struct capiminor *mp)
37259 mp->outbytes -= len;
37260 spin_unlock_bh(&mp->outlock);
37261
37262 - datahandle = atomic_inc_return(&mp->datahandle);
37263 + datahandle = atomic_inc_return_unchecked(&mp->datahandle);
37264 skb_push(skb, CAPI_DATA_B3_REQ_LEN);
37265 memset(skb->data, 0, CAPI_DATA_B3_REQ_LEN);
37266 capimsg_setu16(skb->data, 0, CAPI_DATA_B3_REQ_LEN);
37267 capimsg_setu16(skb->data, 2, mp->ap->applid);
37268 capimsg_setu8 (skb->data, 4, CAPI_DATA_B3);
37269 capimsg_setu8 (skb->data, 5, CAPI_REQ);
37270 - capimsg_setu16(skb->data, 6, atomic_inc_return(&mp->msgid));
37271 + capimsg_setu16(skb->data, 6, atomic_inc_return_unchecked(&mp->msgid));
37272 capimsg_setu32(skb->data, 8, mp->ncci); /* NCCI */
37273 capimsg_setu32(skb->data, 12, (u32)(long)skb->data);/* Data32 */
37274 capimsg_setu16(skb->data, 16, len); /* Data length */
37275 diff --git a/drivers/isdn/gigaset/interface.c b/drivers/isdn/gigaset/interface.c
37276 index 67abf3f..076b3a6 100644
37277 --- a/drivers/isdn/gigaset/interface.c
37278 +++ b/drivers/isdn/gigaset/interface.c
37279 @@ -160,9 +160,9 @@ static int if_open(struct tty_struct *tty, struct file *filp)
37280 }
37281 tty->driver_data = cs;
37282
37283 - ++cs->port.count;
37284 + atomic_inc(&cs->port.count);
37285
37286 - if (cs->port.count == 1) {
37287 + if (atomic_read(&cs->port.count) == 1) {
37288 tty_port_tty_set(&cs->port, tty);
37289 tty->low_latency = 1;
37290 }
37291 @@ -186,9 +186,9 @@ static void if_close(struct tty_struct *tty, struct file *filp)
37292
37293 if (!cs->connected)
37294 gig_dbg(DEBUG_IF, "not connected"); /* nothing to do */
37295 - else if (!cs->port.count)
37296 + else if (!atomic_read(&cs->port.count))
37297 dev_warn(cs->dev, "%s: device not opened\n", __func__);
37298 - else if (!--cs->port.count)
37299 + else if (!atomic_dec_return(&cs->port.count))
37300 tty_port_tty_set(&cs->port, NULL);
37301
37302 mutex_unlock(&cs->mutex);
37303 diff --git a/drivers/isdn/hardware/avm/b1.c b/drivers/isdn/hardware/avm/b1.c
37304 index 821f7ac..28d4030 100644
37305 --- a/drivers/isdn/hardware/avm/b1.c
37306 +++ b/drivers/isdn/hardware/avm/b1.c
37307 @@ -176,7 +176,7 @@ int b1_load_t4file(avmcard *card, capiloaddatapart *t4file)
37308 }
37309 if (left) {
37310 if (t4file->user) {
37311 - if (copy_from_user(buf, dp, left))
37312 + if (left > sizeof buf || copy_from_user(buf, dp, left))
37313 return -EFAULT;
37314 } else {
37315 memcpy(buf, dp, left);
37316 @@ -224,7 +224,7 @@ int b1_load_config(avmcard *card, capiloaddatapart *config)
37317 }
37318 if (left) {
37319 if (config->user) {
37320 - if (copy_from_user(buf, dp, left))
37321 + if (left > sizeof buf || copy_from_user(buf, dp, left))
37322 return -EFAULT;
37323 } else {
37324 memcpy(buf, dp, left);
37325 diff --git a/drivers/isdn/i4l/isdn_tty.c b/drivers/isdn/i4l/isdn_tty.c
37326 index e09dc8a..15e2efb 100644
37327 --- a/drivers/isdn/i4l/isdn_tty.c
37328 +++ b/drivers/isdn/i4l/isdn_tty.c
37329 @@ -1513,9 +1513,9 @@ isdn_tty_open(struct tty_struct *tty, struct file *filp)
37330
37331 #ifdef ISDN_DEBUG_MODEM_OPEN
37332 printk(KERN_DEBUG "isdn_tty_open %s, count = %d\n", tty->name,
37333 - port->count);
37334 + atomic_read(&port->count));
37335 #endif
37336 - port->count++;
37337 + atomic_inc(&port->count);
37338 port->tty = tty;
37339 /*
37340 * Start up serial port
37341 @@ -1559,7 +1559,7 @@ isdn_tty_close(struct tty_struct *tty, struct file *filp)
37342 #endif
37343 return;
37344 }
37345 - if ((tty->count == 1) && (port->count != 1)) {
37346 + if ((tty->count == 1) && (atomic_read(&port->count) != 1)) {
37347 /*
37348 * Uh, oh. tty->count is 1, which means that the tty
37349 * structure will be freed. Info->count should always
37350 @@ -1568,15 +1568,15 @@ isdn_tty_close(struct tty_struct *tty, struct file *filp)
37351 * serial port won't be shutdown.
37352 */
37353 printk(KERN_ERR "isdn_tty_close: bad port count; tty->count is 1, "
37354 - "info->count is %d\n", port->count);
37355 - port->count = 1;
37356 + "info->count is %d\n", atomic_read(&port->count));
37357 + atomic_set(&port->count, 1);
37358 }
37359 - if (--port->count < 0) {
37360 + if (atomic_dec_return(&port->count) < 0) {
37361 printk(KERN_ERR "isdn_tty_close: bad port count for ttyi%d: %d\n",
37362 - info->line, port->count);
37363 - port->count = 0;
37364 + info->line, atomic_read(&port->count));
37365 + atomic_set(&port->count, 0);
37366 }
37367 - if (port->count) {
37368 + if (atomic_read(&port->count)) {
37369 #ifdef ISDN_DEBUG_MODEM_OPEN
37370 printk(KERN_DEBUG "isdn_tty_close after info->count != 0\n");
37371 #endif
37372 @@ -1630,7 +1630,7 @@ isdn_tty_hangup(struct tty_struct *tty)
37373 if (isdn_tty_paranoia_check(info, tty->name, "isdn_tty_hangup"))
37374 return;
37375 isdn_tty_shutdown(info);
37376 - port->count = 0;
37377 + atomic_set(&port->count, 0);
37378 port->flags &= ~ASYNC_NORMAL_ACTIVE;
37379 port->tty = NULL;
37380 wake_up_interruptible(&port->open_wait);
37381 @@ -1975,7 +1975,7 @@ isdn_tty_find_icall(int di, int ch, setup_parm *setup)
37382 for (i = 0; i < ISDN_MAX_CHANNELS; i++) {
37383 modem_info *info = &dev->mdm.info[i];
37384
37385 - if (info->port.count == 0)
37386 + if (atomic_read(&info->port.count) == 0)
37387 continue;
37388 if ((info->emu.mdmreg[REG_SI1] & si2bit[si1]) && /* SI1 is matching */
37389 (info->emu.mdmreg[REG_SI2] == si2)) { /* SI2 is matching */
37390 diff --git a/drivers/isdn/icn/icn.c b/drivers/isdn/icn/icn.c
37391 index e74df7c..03a03ba 100644
37392 --- a/drivers/isdn/icn/icn.c
37393 +++ b/drivers/isdn/icn/icn.c
37394 @@ -1045,7 +1045,7 @@ icn_writecmd(const u_char *buf, int len, int user, icn_card *card)
37395 if (count > len)
37396 count = len;
37397 if (user) {
37398 - if (copy_from_user(msg, buf, count))
37399 + if (count > sizeof msg || copy_from_user(msg, buf, count))
37400 return -EFAULT;
37401 } else
37402 memcpy(msg, buf, count);
37403 diff --git a/drivers/leds/leds-clevo-mail.c b/drivers/leds/leds-clevo-mail.c
37404 index 6a8405d..0bd1c7e 100644
37405 --- a/drivers/leds/leds-clevo-mail.c
37406 +++ b/drivers/leds/leds-clevo-mail.c
37407 @@ -40,7 +40,7 @@ static int __init clevo_mail_led_dmi_callback(const struct dmi_system_id *id)
37408 * detected as working, but in reality it is not) as low as
37409 * possible.
37410 */
37411 -static struct dmi_system_id __initdata clevo_mail_led_dmi_table[] = {
37412 +static const struct dmi_system_id __initconst clevo_mail_led_dmi_table[] = {
37413 {
37414 .callback = clevo_mail_led_dmi_callback,
37415 .ident = "Clevo D410J",
37416 diff --git a/drivers/leds/leds-ss4200.c b/drivers/leds/leds-ss4200.c
37417 index ec9b287..65c9bf4 100644
37418 --- a/drivers/leds/leds-ss4200.c
37419 +++ b/drivers/leds/leds-ss4200.c
37420 @@ -92,7 +92,7 @@ MODULE_PARM_DESC(nodetect, "Skip DMI-based hardware detection");
37421 * detected as working, but in reality it is not) as low as
37422 * possible.
37423 */
37424 -static struct dmi_system_id __initdata nas_led_whitelist[] = {
37425 +static const struct dmi_system_id __initconst nas_led_whitelist[] = {
37426 {
37427 .callback = ss4200_led_dmi_callback,
37428 .ident = "Intel SS4200-E",
37429 diff --git a/drivers/lguest/core.c b/drivers/lguest/core.c
37430 index a5ebc00..982886f 100644
37431 --- a/drivers/lguest/core.c
37432 +++ b/drivers/lguest/core.c
37433 @@ -92,9 +92,17 @@ static __init int map_switcher(void)
37434 * it's worked so far. The end address needs +1 because __get_vm_area
37435 * allocates an extra guard page, so we need space for that.
37436 */
37437 +
37438 +#if defined(CONFIG_MODULES) && defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
37439 + switcher_vma = __get_vm_area(TOTAL_SWITCHER_PAGES * PAGE_SIZE,
37440 + VM_ALLOC | VM_KERNEXEC, SWITCHER_ADDR, SWITCHER_ADDR
37441 + + (TOTAL_SWITCHER_PAGES+1) * PAGE_SIZE);
37442 +#else
37443 switcher_vma = __get_vm_area(TOTAL_SWITCHER_PAGES * PAGE_SIZE,
37444 VM_ALLOC, SWITCHER_ADDR, SWITCHER_ADDR
37445 + (TOTAL_SWITCHER_PAGES+1) * PAGE_SIZE);
37446 +#endif
37447 +
37448 if (!switcher_vma) {
37449 err = -ENOMEM;
37450 printk("lguest: could not map switcher pages high\n");
37451 @@ -119,7 +127,7 @@ static __init int map_switcher(void)
37452 * Now the Switcher is mapped at the right address, we can't fail!
37453 * Copy in the compiled-in Switcher code (from x86/switcher_32.S).
37454 */
37455 - memcpy(switcher_vma->addr, start_switcher_text,
37456 + memcpy(switcher_vma->addr, ktla_ktva(start_switcher_text),
37457 end_switcher_text - start_switcher_text);
37458
37459 printk(KERN_INFO "lguest: mapped switcher at %p\n",
37460 diff --git a/drivers/lguest/page_tables.c b/drivers/lguest/page_tables.c
37461 index 3b62be16..e33134a 100644
37462 --- a/drivers/lguest/page_tables.c
37463 +++ b/drivers/lguest/page_tables.c
37464 @@ -532,7 +532,7 @@ void pin_page(struct lg_cpu *cpu, unsigned long vaddr)
37465 /*:*/
37466
37467 #ifdef CONFIG_X86_PAE
37468 -static void release_pmd(pmd_t *spmd)
37469 +static void __intentional_overflow(-1) release_pmd(pmd_t *spmd)
37470 {
37471 /* If the entry's not present, there's nothing to release. */
37472 if (pmd_flags(*spmd) & _PAGE_PRESENT) {
37473 diff --git a/drivers/lguest/x86/core.c b/drivers/lguest/x86/core.c
37474 index 4af12e1..0e89afe 100644
37475 --- a/drivers/lguest/x86/core.c
37476 +++ b/drivers/lguest/x86/core.c
37477 @@ -59,7 +59,7 @@ static struct {
37478 /* Offset from where switcher.S was compiled to where we've copied it */
37479 static unsigned long switcher_offset(void)
37480 {
37481 - return SWITCHER_ADDR - (unsigned long)start_switcher_text;
37482 + return SWITCHER_ADDR - (unsigned long)ktla_ktva(start_switcher_text);
37483 }
37484
37485 /* This cpu's struct lguest_pages. */
37486 @@ -100,7 +100,13 @@ static void copy_in_guest_info(struct lg_cpu *cpu, struct lguest_pages *pages)
37487 * These copies are pretty cheap, so we do them unconditionally: */
37488 /* Save the current Host top-level page directory.
37489 */
37490 +
37491 +#ifdef CONFIG_PAX_PER_CPU_PGD
37492 + pages->state.host_cr3 = read_cr3();
37493 +#else
37494 pages->state.host_cr3 = __pa(current->mm->pgd);
37495 +#endif
37496 +
37497 /*
37498 * Set up the Guest's page tables to see this CPU's pages (and no
37499 * other CPU's pages).
37500 @@ -476,7 +482,7 @@ void __init lguest_arch_host_init(void)
37501 * compiled-in switcher code and the high-mapped copy we just made.
37502 */
37503 for (i = 0; i < IDT_ENTRIES; i++)
37504 - default_idt_entries[i] += switcher_offset();
37505 + default_idt_entries[i] = ktla_ktva(default_idt_entries[i]) + switcher_offset();
37506
37507 /*
37508 * Set up the Switcher's per-cpu areas.
37509 @@ -559,7 +565,7 @@ void __init lguest_arch_host_init(void)
37510 * it will be undisturbed when we switch. To change %cs and jump we
37511 * need this structure to feed to Intel's "lcall" instruction.
37512 */
37513 - lguest_entry.offset = (long)switch_to_guest + switcher_offset();
37514 + lguest_entry.offset = (long)ktla_ktva(switch_to_guest) + switcher_offset();
37515 lguest_entry.segment = LGUEST_CS;
37516
37517 /*
37518 diff --git a/drivers/lguest/x86/switcher_32.S b/drivers/lguest/x86/switcher_32.S
37519 index 40634b0..4f5855e 100644
37520 --- a/drivers/lguest/x86/switcher_32.S
37521 +++ b/drivers/lguest/x86/switcher_32.S
37522 @@ -87,6 +87,7 @@
37523 #include <asm/page.h>
37524 #include <asm/segment.h>
37525 #include <asm/lguest.h>
37526 +#include <asm/processor-flags.h>
37527
37528 // We mark the start of the code to copy
37529 // It's placed in .text tho it's never run here
37530 @@ -149,6 +150,13 @@ ENTRY(switch_to_guest)
37531 // Changes type when we load it: damn Intel!
37532 // For after we switch over our page tables
37533 // That entry will be read-only: we'd crash.
37534 +
37535 +#ifdef CONFIG_PAX_KERNEXEC
37536 + mov %cr0, %edx
37537 + xor $X86_CR0_WP, %edx
37538 + mov %edx, %cr0
37539 +#endif
37540 +
37541 movl $(GDT_ENTRY_TSS*8), %edx
37542 ltr %dx
37543
37544 @@ -157,9 +165,15 @@ ENTRY(switch_to_guest)
37545 // Let's clear it again for our return.
37546 // The GDT descriptor of the Host
37547 // Points to the table after two "size" bytes
37548 - movl (LGUEST_PAGES_host_gdt_desc+2)(%eax), %edx
37549 + movl (LGUEST_PAGES_host_gdt_desc+2)(%eax), %eax
37550 // Clear "used" from type field (byte 5, bit 2)
37551 - andb $0xFD, (GDT_ENTRY_TSS*8 + 5)(%edx)
37552 + andb $0xFD, (GDT_ENTRY_TSS*8 + 5)(%eax)
37553 +
37554 +#ifdef CONFIG_PAX_KERNEXEC
37555 + mov %cr0, %eax
37556 + xor $X86_CR0_WP, %eax
37557 + mov %eax, %cr0
37558 +#endif
37559
37560 // Once our page table's switched, the Guest is live!
37561 // The Host fades as we run this final step.
37562 @@ -295,13 +309,12 @@ deliver_to_host:
37563 // I consulted gcc, and it gave
37564 // These instructions, which I gladly credit:
37565 leal (%edx,%ebx,8), %eax
37566 - movzwl (%eax),%edx
37567 - movl 4(%eax), %eax
37568 - xorw %ax, %ax
37569 - orl %eax, %edx
37570 + movl 4(%eax), %edx
37571 + movw (%eax), %dx
37572 // Now the address of the handler's in %edx
37573 // We call it now: its "iret" drops us home.
37574 - jmp *%edx
37575 + ljmp $__KERNEL_CS, $1f
37576 +1: jmp *%edx
37577
37578 // Every interrupt can come to us here
37579 // But we must truly tell each apart.
37580 diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c
37581 index 7155945..4bcc562 100644
37582 --- a/drivers/md/bitmap.c
37583 +++ b/drivers/md/bitmap.c
37584 @@ -1779,7 +1779,7 @@ void bitmap_status(struct seq_file *seq, struct bitmap *bitmap)
37585 chunk_kb ? "KB" : "B");
37586 if (bitmap->storage.file) {
37587 seq_printf(seq, ", file: ");
37588 - seq_path(seq, &bitmap->storage.file->f_path, " \t\n");
37589 + seq_path(seq, &bitmap->storage.file->f_path, " \t\n\\");
37590 }
37591
37592 seq_printf(seq, "\n");
37593 diff --git a/drivers/md/dm-ioctl.c b/drivers/md/dm-ioctl.c
37594 index eee353d..74504c4 100644
37595 --- a/drivers/md/dm-ioctl.c
37596 +++ b/drivers/md/dm-ioctl.c
37597 @@ -1632,7 +1632,7 @@ static int validate_params(uint cmd, struct dm_ioctl *param)
37598 cmd == DM_LIST_VERSIONS_CMD)
37599 return 0;
37600
37601 - if ((cmd == DM_DEV_CREATE_CMD)) {
37602 + if (cmd == DM_DEV_CREATE_CMD) {
37603 if (!*param->name) {
37604 DMWARN("name not supplied when creating device");
37605 return -EINVAL;
37606 diff --git a/drivers/md/dm-raid1.c b/drivers/md/dm-raid1.c
37607 index 7f24190..0e18099 100644
37608 --- a/drivers/md/dm-raid1.c
37609 +++ b/drivers/md/dm-raid1.c
37610 @@ -40,7 +40,7 @@ enum dm_raid1_error {
37611
37612 struct mirror {
37613 struct mirror_set *ms;
37614 - atomic_t error_count;
37615 + atomic_unchecked_t error_count;
37616 unsigned long error_type;
37617 struct dm_dev *dev;
37618 sector_t offset;
37619 @@ -183,7 +183,7 @@ static struct mirror *get_valid_mirror(struct mirror_set *ms)
37620 struct mirror *m;
37621
37622 for (m = ms->mirror; m < ms->mirror + ms->nr_mirrors; m++)
37623 - if (!atomic_read(&m->error_count))
37624 + if (!atomic_read_unchecked(&m->error_count))
37625 return m;
37626
37627 return NULL;
37628 @@ -215,7 +215,7 @@ static void fail_mirror(struct mirror *m, enum dm_raid1_error error_type)
37629 * simple way to tell if a device has encountered
37630 * errors.
37631 */
37632 - atomic_inc(&m->error_count);
37633 + atomic_inc_unchecked(&m->error_count);
37634
37635 if (test_and_set_bit(error_type, &m->error_type))
37636 return;
37637 @@ -406,7 +406,7 @@ static struct mirror *choose_mirror(struct mirror_set *ms, sector_t sector)
37638 struct mirror *m = get_default_mirror(ms);
37639
37640 do {
37641 - if (likely(!atomic_read(&m->error_count)))
37642 + if (likely(!atomic_read_unchecked(&m->error_count)))
37643 return m;
37644
37645 if (m-- == ms->mirror)
37646 @@ -420,7 +420,7 @@ static int default_ok(struct mirror *m)
37647 {
37648 struct mirror *default_mirror = get_default_mirror(m->ms);
37649
37650 - return !atomic_read(&default_mirror->error_count);
37651 + return !atomic_read_unchecked(&default_mirror->error_count);
37652 }
37653
37654 static int mirror_available(struct mirror_set *ms, struct bio *bio)
37655 @@ -557,7 +557,7 @@ static void do_reads(struct mirror_set *ms, struct bio_list *reads)
37656 */
37657 if (likely(region_in_sync(ms, region, 1)))
37658 m = choose_mirror(ms, bio->bi_sector);
37659 - else if (m && atomic_read(&m->error_count))
37660 + else if (m && atomic_read_unchecked(&m->error_count))
37661 m = NULL;
37662
37663 if (likely(m))
37664 @@ -924,7 +924,7 @@ static int get_mirror(struct mirror_set *ms, struct dm_target *ti,
37665 }
37666
37667 ms->mirror[mirror].ms = ms;
37668 - atomic_set(&(ms->mirror[mirror].error_count), 0);
37669 + atomic_set_unchecked(&(ms->mirror[mirror].error_count), 0);
37670 ms->mirror[mirror].error_type = 0;
37671 ms->mirror[mirror].offset = offset;
37672
37673 @@ -1337,7 +1337,7 @@ static void mirror_resume(struct dm_target *ti)
37674 */
37675 static char device_status_char(struct mirror *m)
37676 {
37677 - if (!atomic_read(&(m->error_count)))
37678 + if (!atomic_read_unchecked(&(m->error_count)))
37679 return 'A';
37680
37681 return (test_bit(DM_RAID1_FLUSH_ERROR, &(m->error_type))) ? 'F' :
37682 diff --git a/drivers/md/dm-stripe.c b/drivers/md/dm-stripe.c
37683 index aaecefa..23b3026 100644
37684 --- a/drivers/md/dm-stripe.c
37685 +++ b/drivers/md/dm-stripe.c
37686 @@ -20,7 +20,7 @@ struct stripe {
37687 struct dm_dev *dev;
37688 sector_t physical_start;
37689
37690 - atomic_t error_count;
37691 + atomic_unchecked_t error_count;
37692 };
37693
37694 struct stripe_c {
37695 @@ -184,7 +184,7 @@ static int stripe_ctr(struct dm_target *ti, unsigned int argc, char **argv)
37696 kfree(sc);
37697 return r;
37698 }
37699 - atomic_set(&(sc->stripe[i].error_count), 0);
37700 + atomic_set_unchecked(&(sc->stripe[i].error_count), 0);
37701 }
37702
37703 ti->private = sc;
37704 @@ -325,7 +325,7 @@ static void stripe_status(struct dm_target *ti, status_type_t type,
37705 DMEMIT("%d ", sc->stripes);
37706 for (i = 0; i < sc->stripes; i++) {
37707 DMEMIT("%s ", sc->stripe[i].dev->name);
37708 - buffer[i] = atomic_read(&(sc->stripe[i].error_count)) ?
37709 + buffer[i] = atomic_read_unchecked(&(sc->stripe[i].error_count)) ?
37710 'D' : 'A';
37711 }
37712 buffer[i] = '\0';
37713 @@ -370,8 +370,8 @@ static int stripe_end_io(struct dm_target *ti, struct bio *bio, int error)
37714 */
37715 for (i = 0; i < sc->stripes; i++)
37716 if (!strcmp(sc->stripe[i].dev->name, major_minor)) {
37717 - atomic_inc(&(sc->stripe[i].error_count));
37718 - if (atomic_read(&(sc->stripe[i].error_count)) <
37719 + atomic_inc_unchecked(&(sc->stripe[i].error_count));
37720 + if (atomic_read_unchecked(&(sc->stripe[i].error_count)) <
37721 DM_IO_ERROR_THRESHOLD)
37722 schedule_work(&sc->trigger_event);
37723 }
37724 diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c
37725 index daf25d0..d74f49f 100644
37726 --- a/drivers/md/dm-table.c
37727 +++ b/drivers/md/dm-table.c
37728 @@ -390,7 +390,7 @@ static int device_area_is_invalid(struct dm_target *ti, struct dm_dev *dev,
37729 if (!dev_size)
37730 return 0;
37731
37732 - if ((start >= dev_size) || (start + len > dev_size)) {
37733 + if ((start >= dev_size) || (len > dev_size - start)) {
37734 DMWARN("%s: %s too small for target: "
37735 "start=%llu, len=%llu, dev_size=%llu",
37736 dm_device_name(ti->table->md), bdevname(bdev, b),
37737 diff --git a/drivers/md/dm-thin-metadata.c b/drivers/md/dm-thin-metadata.c
37738 index 4d6e853..a234157 100644
37739 --- a/drivers/md/dm-thin-metadata.c
37740 +++ b/drivers/md/dm-thin-metadata.c
37741 @@ -397,7 +397,7 @@ static void __setup_btree_details(struct dm_pool_metadata *pmd)
37742 {
37743 pmd->info.tm = pmd->tm;
37744 pmd->info.levels = 2;
37745 - pmd->info.value_type.context = pmd->data_sm;
37746 + pmd->info.value_type.context = (dm_space_map_no_const *)pmd->data_sm;
37747 pmd->info.value_type.size = sizeof(__le64);
37748 pmd->info.value_type.inc = data_block_inc;
37749 pmd->info.value_type.dec = data_block_dec;
37750 @@ -416,7 +416,7 @@ static void __setup_btree_details(struct dm_pool_metadata *pmd)
37751
37752 pmd->bl_info.tm = pmd->tm;
37753 pmd->bl_info.levels = 1;
37754 - pmd->bl_info.value_type.context = pmd->data_sm;
37755 + pmd->bl_info.value_type.context = (dm_space_map_no_const *)pmd->data_sm;
37756 pmd->bl_info.value_type.size = sizeof(__le64);
37757 pmd->bl_info.value_type.inc = data_block_inc;
37758 pmd->bl_info.value_type.dec = data_block_dec;
37759 diff --git a/drivers/md/dm.c b/drivers/md/dm.c
37760 index 0d8f086..f5a91d5 100644
37761 --- a/drivers/md/dm.c
37762 +++ b/drivers/md/dm.c
37763 @@ -170,9 +170,9 @@ struct mapped_device {
37764 /*
37765 * Event handling.
37766 */
37767 - atomic_t event_nr;
37768 + atomic_unchecked_t event_nr;
37769 wait_queue_head_t eventq;
37770 - atomic_t uevent_seq;
37771 + atomic_unchecked_t uevent_seq;
37772 struct list_head uevent_list;
37773 spinlock_t uevent_lock; /* Protect access to uevent_list */
37774
37775 @@ -1872,8 +1872,8 @@ static struct mapped_device *alloc_dev(int minor)
37776 rwlock_init(&md->map_lock);
37777 atomic_set(&md->holders, 1);
37778 atomic_set(&md->open_count, 0);
37779 - atomic_set(&md->event_nr, 0);
37780 - atomic_set(&md->uevent_seq, 0);
37781 + atomic_set_unchecked(&md->event_nr, 0);
37782 + atomic_set_unchecked(&md->uevent_seq, 0);
37783 INIT_LIST_HEAD(&md->uevent_list);
37784 spin_lock_init(&md->uevent_lock);
37785
37786 @@ -2026,7 +2026,7 @@ static void event_callback(void *context)
37787
37788 dm_send_uevents(&uevents, &disk_to_dev(md->disk)->kobj);
37789
37790 - atomic_inc(&md->event_nr);
37791 + atomic_inc_unchecked(&md->event_nr);
37792 wake_up(&md->eventq);
37793 }
37794
37795 @@ -2683,18 +2683,18 @@ int dm_kobject_uevent(struct mapped_device *md, enum kobject_action action,
37796
37797 uint32_t dm_next_uevent_seq(struct mapped_device *md)
37798 {
37799 - return atomic_add_return(1, &md->uevent_seq);
37800 + return atomic_add_return_unchecked(1, &md->uevent_seq);
37801 }
37802
37803 uint32_t dm_get_event_nr(struct mapped_device *md)
37804 {
37805 - return atomic_read(&md->event_nr);
37806 + return atomic_read_unchecked(&md->event_nr);
37807 }
37808
37809 int dm_wait_event(struct mapped_device *md, int event_nr)
37810 {
37811 return wait_event_interruptible(md->eventq,
37812 - (event_nr != atomic_read(&md->event_nr)));
37813 + (event_nr != atomic_read_unchecked(&md->event_nr)));
37814 }
37815
37816 void dm_uevent_add(struct mapped_device *md, struct list_head *elist)
37817 diff --git a/drivers/md/md.c b/drivers/md/md.c
37818 index f363135..9b38815 100644
37819 --- a/drivers/md/md.c
37820 +++ b/drivers/md/md.c
37821 @@ -240,10 +240,10 @@ EXPORT_SYMBOL_GPL(md_trim_bio);
37822 * start build, activate spare
37823 */
37824 static DECLARE_WAIT_QUEUE_HEAD(md_event_waiters);
37825 -static atomic_t md_event_count;
37826 +static atomic_unchecked_t md_event_count;
37827 void md_new_event(struct mddev *mddev)
37828 {
37829 - atomic_inc(&md_event_count);
37830 + atomic_inc_unchecked(&md_event_count);
37831 wake_up(&md_event_waiters);
37832 }
37833 EXPORT_SYMBOL_GPL(md_new_event);
37834 @@ -253,7 +253,7 @@ EXPORT_SYMBOL_GPL(md_new_event);
37835 */
37836 static void md_new_event_inintr(struct mddev *mddev)
37837 {
37838 - atomic_inc(&md_event_count);
37839 + atomic_inc_unchecked(&md_event_count);
37840 wake_up(&md_event_waiters);
37841 }
37842
37843 @@ -1507,7 +1507,7 @@ static int super_1_load(struct md_rdev *rdev, struct md_rdev *refdev, int minor_
37844 if ((le32_to_cpu(sb->feature_map) & MD_FEATURE_RESHAPE_ACTIVE) &&
37845 (le32_to_cpu(sb->feature_map) & MD_FEATURE_NEW_OFFSET))
37846 rdev->new_data_offset += (s32)le32_to_cpu(sb->new_offset);
37847 - atomic_set(&rdev->corrected_errors, le32_to_cpu(sb->cnt_corrected_read));
37848 + atomic_set_unchecked(&rdev->corrected_errors, le32_to_cpu(sb->cnt_corrected_read));
37849
37850 rdev->sb_size = le32_to_cpu(sb->max_dev) * 2 + 256;
37851 bmask = queue_logical_block_size(rdev->bdev->bd_disk->queue)-1;
37852 @@ -1751,7 +1751,7 @@ static void super_1_sync(struct mddev *mddev, struct md_rdev *rdev)
37853 else
37854 sb->resync_offset = cpu_to_le64(0);
37855
37856 - sb->cnt_corrected_read = cpu_to_le32(atomic_read(&rdev->corrected_errors));
37857 + sb->cnt_corrected_read = cpu_to_le32(atomic_read_unchecked(&rdev->corrected_errors));
37858
37859 sb->raid_disks = cpu_to_le32(mddev->raid_disks);
37860 sb->size = cpu_to_le64(mddev->dev_sectors);
37861 @@ -2751,7 +2751,7 @@ __ATTR(state, S_IRUGO|S_IWUSR, state_show, state_store);
37862 static ssize_t
37863 errors_show(struct md_rdev *rdev, char *page)
37864 {
37865 - return sprintf(page, "%d\n", atomic_read(&rdev->corrected_errors));
37866 + return sprintf(page, "%d\n", atomic_read_unchecked(&rdev->corrected_errors));
37867 }
37868
37869 static ssize_t
37870 @@ -2760,7 +2760,7 @@ errors_store(struct md_rdev *rdev, const char *buf, size_t len)
37871 char *e;
37872 unsigned long n = simple_strtoul(buf, &e, 10);
37873 if (*buf && (*e == 0 || *e == '\n')) {
37874 - atomic_set(&rdev->corrected_errors, n);
37875 + atomic_set_unchecked(&rdev->corrected_errors, n);
37876 return len;
37877 }
37878 return -EINVAL;
37879 @@ -3210,8 +3210,8 @@ int md_rdev_init(struct md_rdev *rdev)
37880 rdev->sb_loaded = 0;
37881 rdev->bb_page = NULL;
37882 atomic_set(&rdev->nr_pending, 0);
37883 - atomic_set(&rdev->read_errors, 0);
37884 - atomic_set(&rdev->corrected_errors, 0);
37885 + atomic_set_unchecked(&rdev->read_errors, 0);
37886 + atomic_set_unchecked(&rdev->corrected_errors, 0);
37887
37888 INIT_LIST_HEAD(&rdev->same_set);
37889 init_waitqueue_head(&rdev->blocked_wait);
37890 @@ -6987,7 +6987,7 @@ static int md_seq_show(struct seq_file *seq, void *v)
37891
37892 spin_unlock(&pers_lock);
37893 seq_printf(seq, "\n");
37894 - seq->poll_event = atomic_read(&md_event_count);
37895 + seq->poll_event = atomic_read_unchecked(&md_event_count);
37896 return 0;
37897 }
37898 if (v == (void*)2) {
37899 @@ -7090,7 +7090,7 @@ static int md_seq_open(struct inode *inode, struct file *file)
37900 return error;
37901
37902 seq = file->private_data;
37903 - seq->poll_event = atomic_read(&md_event_count);
37904 + seq->poll_event = atomic_read_unchecked(&md_event_count);
37905 return error;
37906 }
37907
37908 @@ -7104,7 +7104,7 @@ static unsigned int mdstat_poll(struct file *filp, poll_table *wait)
37909 /* always allow read */
37910 mask = POLLIN | POLLRDNORM;
37911
37912 - if (seq->poll_event != atomic_read(&md_event_count))
37913 + if (seq->poll_event != atomic_read_unchecked(&md_event_count))
37914 mask |= POLLERR | POLLPRI;
37915 return mask;
37916 }
37917 @@ -7148,7 +7148,7 @@ static int is_mddev_idle(struct mddev *mddev, int init)
37918 struct gendisk *disk = rdev->bdev->bd_contains->bd_disk;
37919 curr_events = (int)part_stat_read(&disk->part0, sectors[0]) +
37920 (int)part_stat_read(&disk->part0, sectors[1]) -
37921 - atomic_read(&disk->sync_io);
37922 + atomic_read_unchecked(&disk->sync_io);
37923 /* sync IO will cause sync_io to increase before the disk_stats
37924 * as sync_io is counted when a request starts, and
37925 * disk_stats is counted when it completes.
37926 diff --git a/drivers/md/md.h b/drivers/md/md.h
37927 index eca59c3..7c42285 100644
37928 --- a/drivers/md/md.h
37929 +++ b/drivers/md/md.h
37930 @@ -94,13 +94,13 @@ struct md_rdev {
37931 * only maintained for arrays that
37932 * support hot removal
37933 */
37934 - atomic_t read_errors; /* number of consecutive read errors that
37935 + atomic_unchecked_t read_errors; /* number of consecutive read errors that
37936 * we have tried to ignore.
37937 */
37938 struct timespec last_read_error; /* monotonic time since our
37939 * last read error
37940 */
37941 - atomic_t corrected_errors; /* number of corrected read errors,
37942 + atomic_unchecked_t corrected_errors; /* number of corrected read errors,
37943 * for reporting to userspace and storing
37944 * in superblock.
37945 */
37946 @@ -434,7 +434,7 @@ static inline void rdev_dec_pending(struct md_rdev *rdev, struct mddev *mddev)
37947
37948 static inline void md_sync_acct(struct block_device *bdev, unsigned long nr_sectors)
37949 {
37950 - atomic_add(nr_sectors, &bdev->bd_contains->bd_disk->sync_io);
37951 + atomic_add_unchecked(nr_sectors, &bdev->bd_contains->bd_disk->sync_io);
37952 }
37953
37954 struct md_personality
37955 diff --git a/drivers/md/persistent-data/dm-space-map.h b/drivers/md/persistent-data/dm-space-map.h
37956 index 1cbfc6b..56e1dbb 100644
37957 --- a/drivers/md/persistent-data/dm-space-map.h
37958 +++ b/drivers/md/persistent-data/dm-space-map.h
37959 @@ -60,6 +60,7 @@ struct dm_space_map {
37960 int (*root_size)(struct dm_space_map *sm, size_t *result);
37961 int (*copy_root)(struct dm_space_map *sm, void *copy_to_here_le, size_t len);
37962 };
37963 +typedef struct dm_space_map __no_const dm_space_map_no_const;
37964
37965 /*----------------------------------------------------------------*/
37966
37967 diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
37968 index 75b1f89..00ba344 100644
37969 --- a/drivers/md/raid1.c
37970 +++ b/drivers/md/raid1.c
37971 @@ -1819,7 +1819,7 @@ static int fix_sync_read_error(struct r1bio *r1_bio)
37972 if (r1_sync_page_io(rdev, sect, s,
37973 bio->bi_io_vec[idx].bv_page,
37974 READ) != 0)
37975 - atomic_add(s, &rdev->corrected_errors);
37976 + atomic_add_unchecked(s, &rdev->corrected_errors);
37977 }
37978 sectors -= s;
37979 sect += s;
37980 @@ -2041,7 +2041,7 @@ static void fix_read_error(struct r1conf *conf, int read_disk,
37981 test_bit(In_sync, &rdev->flags)) {
37982 if (r1_sync_page_io(rdev, sect, s,
37983 conf->tmppage, READ)) {
37984 - atomic_add(s, &rdev->corrected_errors);
37985 + atomic_add_unchecked(s, &rdev->corrected_errors);
37986 printk(KERN_INFO
37987 "md/raid1:%s: read error corrected "
37988 "(%d sectors at %llu on %s)\n",
37989 diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
37990 index 8d925dc..11d674f 100644
37991 --- a/drivers/md/raid10.c
37992 +++ b/drivers/md/raid10.c
37993 @@ -1878,7 +1878,7 @@ static void end_sync_read(struct bio *bio, int error)
37994 /* The write handler will notice the lack of
37995 * R10BIO_Uptodate and record any errors etc
37996 */
37997 - atomic_add(r10_bio->sectors,
37998 + atomic_add_unchecked(r10_bio->sectors,
37999 &conf->mirrors[d].rdev->corrected_errors);
38000
38001 /* for reconstruct, we always reschedule after a read.
38002 @@ -2227,7 +2227,7 @@ static void check_decay_read_errors(struct mddev *mddev, struct md_rdev *rdev)
38003 {
38004 struct timespec cur_time_mon;
38005 unsigned long hours_since_last;
38006 - unsigned int read_errors = atomic_read(&rdev->read_errors);
38007 + unsigned int read_errors = atomic_read_unchecked(&rdev->read_errors);
38008
38009 ktime_get_ts(&cur_time_mon);
38010
38011 @@ -2249,9 +2249,9 @@ static void check_decay_read_errors(struct mddev *mddev, struct md_rdev *rdev)
38012 * overflowing the shift of read_errors by hours_since_last.
38013 */
38014 if (hours_since_last >= 8 * sizeof(read_errors))
38015 - atomic_set(&rdev->read_errors, 0);
38016 + atomic_set_unchecked(&rdev->read_errors, 0);
38017 else
38018 - atomic_set(&rdev->read_errors, read_errors >> hours_since_last);
38019 + atomic_set_unchecked(&rdev->read_errors, read_errors >> hours_since_last);
38020 }
38021
38022 static int r10_sync_page_io(struct md_rdev *rdev, sector_t sector,
38023 @@ -2305,8 +2305,8 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
38024 return;
38025
38026 check_decay_read_errors(mddev, rdev);
38027 - atomic_inc(&rdev->read_errors);
38028 - if (atomic_read(&rdev->read_errors) > max_read_errors) {
38029 + atomic_inc_unchecked(&rdev->read_errors);
38030 + if (atomic_read_unchecked(&rdev->read_errors) > max_read_errors) {
38031 char b[BDEVNAME_SIZE];
38032 bdevname(rdev->bdev, b);
38033
38034 @@ -2314,7 +2314,7 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
38035 "md/raid10:%s: %s: Raid device exceeded "
38036 "read_error threshold [cur %d:max %d]\n",
38037 mdname(mddev), b,
38038 - atomic_read(&rdev->read_errors), max_read_errors);
38039 + atomic_read_unchecked(&rdev->read_errors), max_read_errors);
38040 printk(KERN_NOTICE
38041 "md/raid10:%s: %s: Failing raid device\n",
38042 mdname(mddev), b);
38043 @@ -2469,7 +2469,7 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
38044 sect +
38045 choose_data_offset(r10_bio, rdev)),
38046 bdevname(rdev->bdev, b));
38047 - atomic_add(s, &rdev->corrected_errors);
38048 + atomic_add_unchecked(s, &rdev->corrected_errors);
38049 }
38050
38051 rdev_dec_pending(rdev, mddev);
38052 diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
38053 index 19d77a0..56051b92 100644
38054 --- a/drivers/md/raid5.c
38055 +++ b/drivers/md/raid5.c
38056 @@ -1797,21 +1797,21 @@ static void raid5_end_read_request(struct bio * bi, int error)
38057 mdname(conf->mddev), STRIPE_SECTORS,
38058 (unsigned long long)s,
38059 bdevname(rdev->bdev, b));
38060 - atomic_add(STRIPE_SECTORS, &rdev->corrected_errors);
38061 + atomic_add_unchecked(STRIPE_SECTORS, &rdev->corrected_errors);
38062 clear_bit(R5_ReadError, &sh->dev[i].flags);
38063 clear_bit(R5_ReWrite, &sh->dev[i].flags);
38064 } else if (test_bit(R5_ReadNoMerge, &sh->dev[i].flags))
38065 clear_bit(R5_ReadNoMerge, &sh->dev[i].flags);
38066
38067 - if (atomic_read(&rdev->read_errors))
38068 - atomic_set(&rdev->read_errors, 0);
38069 + if (atomic_read_unchecked(&rdev->read_errors))
38070 + atomic_set_unchecked(&rdev->read_errors, 0);
38071 } else {
38072 const char *bdn = bdevname(rdev->bdev, b);
38073 int retry = 0;
38074 int set_bad = 0;
38075
38076 clear_bit(R5_UPTODATE, &sh->dev[i].flags);
38077 - atomic_inc(&rdev->read_errors);
38078 + atomic_inc_unchecked(&rdev->read_errors);
38079 if (test_bit(R5_ReadRepl, &sh->dev[i].flags))
38080 printk_ratelimited(
38081 KERN_WARNING
38082 @@ -1839,7 +1839,7 @@ static void raid5_end_read_request(struct bio * bi, int error)
38083 mdname(conf->mddev),
38084 (unsigned long long)s,
38085 bdn);
38086 - } else if (atomic_read(&rdev->read_errors)
38087 + } else if (atomic_read_unchecked(&rdev->read_errors)
38088 > conf->max_nr_stripes)
38089 printk(KERN_WARNING
38090 "md/raid:%s: Too many read errors, failing device %s.\n",
38091 diff --git a/drivers/media/dvb-core/dvbdev.c b/drivers/media/dvb-core/dvbdev.c
38092 index d33101a..6b13069 100644
38093 --- a/drivers/media/dvb-core/dvbdev.c
38094 +++ b/drivers/media/dvb-core/dvbdev.c
38095 @@ -192,7 +192,7 @@ int dvb_register_device(struct dvb_adapter *adap, struct dvb_device **pdvbdev,
38096 const struct dvb_device *template, void *priv, int type)
38097 {
38098 struct dvb_device *dvbdev;
38099 - struct file_operations *dvbdevfops;
38100 + file_operations_no_const *dvbdevfops;
38101 struct device *clsdev;
38102 int minor;
38103 int id;
38104 diff --git a/drivers/media/dvb-frontends/dib3000.h b/drivers/media/dvb-frontends/dib3000.h
38105 index 404f63a..4796533 100644
38106 --- a/drivers/media/dvb-frontends/dib3000.h
38107 +++ b/drivers/media/dvb-frontends/dib3000.h
38108 @@ -39,7 +39,7 @@ struct dib_fe_xfer_ops
38109 int (*fifo_ctrl)(struct dvb_frontend *fe, int onoff);
38110 int (*pid_ctrl)(struct dvb_frontend *fe, int index, int pid, int onoff);
38111 int (*tuner_pass_ctrl)(struct dvb_frontend *fe, int onoff, u8 pll_ctrl);
38112 -};
38113 +} __no_const;
38114
38115 #if defined(CONFIG_DVB_DIB3000MB) || (defined(CONFIG_DVB_DIB3000MB_MODULE) && defined(MODULE))
38116 extern struct dvb_frontend* dib3000mb_attach(const struct dib3000_config* config,
38117 diff --git a/drivers/media/platform/omap/omap_vout.c b/drivers/media/platform/omap/omap_vout.c
38118 index 8e9a668..78d6310 100644
38119 --- a/drivers/media/platform/omap/omap_vout.c
38120 +++ b/drivers/media/platform/omap/omap_vout.c
38121 @@ -63,7 +63,6 @@ enum omap_vout_channels {
38122 OMAP_VIDEO2,
38123 };
38124
38125 -static struct videobuf_queue_ops video_vbq_ops;
38126 /* Variables configurable through module params*/
38127 static u32 video1_numbuffers = 3;
38128 static u32 video2_numbuffers = 3;
38129 @@ -1012,6 +1011,12 @@ static int omap_vout_open(struct file *file)
38130 {
38131 struct videobuf_queue *q;
38132 struct omap_vout_device *vout = NULL;
38133 + static struct videobuf_queue_ops video_vbq_ops = {
38134 + .buf_setup = omap_vout_buffer_setup,
38135 + .buf_prepare = omap_vout_buffer_prepare,
38136 + .buf_release = omap_vout_buffer_release,
38137 + .buf_queue = omap_vout_buffer_queue,
38138 + };
38139
38140 vout = video_drvdata(file);
38141 v4l2_dbg(1, debug, &vout->vid_dev->v4l2_dev, "Entering %s\n", __func__);
38142 @@ -1029,10 +1034,6 @@ static int omap_vout_open(struct file *file)
38143 vout->type = V4L2_BUF_TYPE_VIDEO_OUTPUT;
38144
38145 q = &vout->vbq;
38146 - video_vbq_ops.buf_setup = omap_vout_buffer_setup;
38147 - video_vbq_ops.buf_prepare = omap_vout_buffer_prepare;
38148 - video_vbq_ops.buf_release = omap_vout_buffer_release;
38149 - video_vbq_ops.buf_queue = omap_vout_buffer_queue;
38150 spin_lock_init(&vout->vbq_lock);
38151
38152 videobuf_queue_dma_contig_init(q, &video_vbq_ops, q->dev,
38153 diff --git a/drivers/media/platform/s5p-tv/mixer.h b/drivers/media/platform/s5p-tv/mixer.h
38154 index b671e20..34088b7 100644
38155 --- a/drivers/media/platform/s5p-tv/mixer.h
38156 +++ b/drivers/media/platform/s5p-tv/mixer.h
38157 @@ -155,7 +155,7 @@ struct mxr_layer {
38158 /** layer index (unique identifier) */
38159 int idx;
38160 /** callbacks for layer methods */
38161 - struct mxr_layer_ops ops;
38162 + struct mxr_layer_ops *ops;
38163 /** format array */
38164 const struct mxr_format **fmt_array;
38165 /** size of format array */
38166 diff --git a/drivers/media/platform/s5p-tv/mixer_grp_layer.c b/drivers/media/platform/s5p-tv/mixer_grp_layer.c
38167 index b93a21f..2535195 100644
38168 --- a/drivers/media/platform/s5p-tv/mixer_grp_layer.c
38169 +++ b/drivers/media/platform/s5p-tv/mixer_grp_layer.c
38170 @@ -235,7 +235,7 @@ struct mxr_layer *mxr_graph_layer_create(struct mxr_device *mdev, int idx)
38171 {
38172 struct mxr_layer *layer;
38173 int ret;
38174 - struct mxr_layer_ops ops = {
38175 + static struct mxr_layer_ops ops = {
38176 .release = mxr_graph_layer_release,
38177 .buffer_set = mxr_graph_buffer_set,
38178 .stream_set = mxr_graph_stream_set,
38179 diff --git a/drivers/media/platform/s5p-tv/mixer_reg.c b/drivers/media/platform/s5p-tv/mixer_reg.c
38180 index 3b1670a..595c939 100644
38181 --- a/drivers/media/platform/s5p-tv/mixer_reg.c
38182 +++ b/drivers/media/platform/s5p-tv/mixer_reg.c
38183 @@ -276,7 +276,7 @@ static void mxr_irq_layer_handle(struct mxr_layer *layer)
38184 layer->update_buf = next;
38185 }
38186
38187 - layer->ops.buffer_set(layer, layer->update_buf);
38188 + layer->ops->buffer_set(layer, layer->update_buf);
38189
38190 if (done && done != layer->shadow_buf)
38191 vb2_buffer_done(&done->vb, VB2_BUF_STATE_DONE);
38192 diff --git a/drivers/media/platform/s5p-tv/mixer_video.c b/drivers/media/platform/s5p-tv/mixer_video.c
38193 index 1f3b743..e839271 100644
38194 --- a/drivers/media/platform/s5p-tv/mixer_video.c
38195 +++ b/drivers/media/platform/s5p-tv/mixer_video.c
38196 @@ -208,7 +208,7 @@ static void mxr_layer_default_geo(struct mxr_layer *layer)
38197 layer->geo.src.height = layer->geo.src.full_height;
38198
38199 mxr_geometry_dump(mdev, &layer->geo);
38200 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
38201 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
38202 mxr_geometry_dump(mdev, &layer->geo);
38203 }
38204
38205 @@ -226,7 +226,7 @@ static void mxr_layer_update_output(struct mxr_layer *layer)
38206 layer->geo.dst.full_width = mbus_fmt.width;
38207 layer->geo.dst.full_height = mbus_fmt.height;
38208 layer->geo.dst.field = mbus_fmt.field;
38209 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
38210 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
38211
38212 mxr_geometry_dump(mdev, &layer->geo);
38213 }
38214 @@ -332,7 +332,7 @@ static int mxr_s_fmt(struct file *file, void *priv,
38215 /* set source size to highest accepted value */
38216 geo->src.full_width = max(geo->dst.full_width, pix->width);
38217 geo->src.full_height = max(geo->dst.full_height, pix->height);
38218 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
38219 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
38220 mxr_geometry_dump(mdev, &layer->geo);
38221 /* set cropping to total visible screen */
38222 geo->src.width = pix->width;
38223 @@ -340,12 +340,12 @@ static int mxr_s_fmt(struct file *file, void *priv,
38224 geo->src.x_offset = 0;
38225 geo->src.y_offset = 0;
38226 /* assure consistency of geometry */
38227 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_CROP, MXR_NO_OFFSET);
38228 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_CROP, MXR_NO_OFFSET);
38229 mxr_geometry_dump(mdev, &layer->geo);
38230 /* set full size to lowest possible value */
38231 geo->src.full_width = 0;
38232 geo->src.full_height = 0;
38233 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
38234 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
38235 mxr_geometry_dump(mdev, &layer->geo);
38236
38237 /* returning results */
38238 @@ -472,7 +472,7 @@ static int mxr_s_selection(struct file *file, void *fh,
38239 target->width = s->r.width;
38240 target->height = s->r.height;
38241
38242 - layer->ops.fix_geometry(layer, stage, s->flags);
38243 + layer->ops->fix_geometry(layer, stage, s->flags);
38244
38245 /* retrieve update selection rectangle */
38246 res.left = target->x_offset;
38247 @@ -937,13 +937,13 @@ static int start_streaming(struct vb2_queue *vq, unsigned int count)
38248 mxr_output_get(mdev);
38249
38250 mxr_layer_update_output(layer);
38251 - layer->ops.format_set(layer);
38252 + layer->ops->format_set(layer);
38253 /* enabling layer in hardware */
38254 spin_lock_irqsave(&layer->enq_slock, flags);
38255 layer->state = MXR_LAYER_STREAMING;
38256 spin_unlock_irqrestore(&layer->enq_slock, flags);
38257
38258 - layer->ops.stream_set(layer, MXR_ENABLE);
38259 + layer->ops->stream_set(layer, MXR_ENABLE);
38260 mxr_streamer_get(mdev);
38261
38262 return 0;
38263 @@ -1013,7 +1013,7 @@ static int stop_streaming(struct vb2_queue *vq)
38264 spin_unlock_irqrestore(&layer->enq_slock, flags);
38265
38266 /* disabling layer in hardware */
38267 - layer->ops.stream_set(layer, MXR_DISABLE);
38268 + layer->ops->stream_set(layer, MXR_DISABLE);
38269 /* remove one streamer */
38270 mxr_streamer_put(mdev);
38271 /* allow changes in output configuration */
38272 @@ -1052,8 +1052,8 @@ void mxr_base_layer_unregister(struct mxr_layer *layer)
38273
38274 void mxr_layer_release(struct mxr_layer *layer)
38275 {
38276 - if (layer->ops.release)
38277 - layer->ops.release(layer);
38278 + if (layer->ops->release)
38279 + layer->ops->release(layer);
38280 }
38281
38282 void mxr_base_layer_release(struct mxr_layer *layer)
38283 @@ -1079,7 +1079,7 @@ struct mxr_layer *mxr_base_layer_create(struct mxr_device *mdev,
38284
38285 layer->mdev = mdev;
38286 layer->idx = idx;
38287 - layer->ops = *ops;
38288 + layer->ops = ops;
38289
38290 spin_lock_init(&layer->enq_slock);
38291 INIT_LIST_HEAD(&layer->enq_list);
38292 diff --git a/drivers/media/platform/s5p-tv/mixer_vp_layer.c b/drivers/media/platform/s5p-tv/mixer_vp_layer.c
38293 index 3d13a63..da31bf1 100644
38294 --- a/drivers/media/platform/s5p-tv/mixer_vp_layer.c
38295 +++ b/drivers/media/platform/s5p-tv/mixer_vp_layer.c
38296 @@ -206,7 +206,7 @@ struct mxr_layer *mxr_vp_layer_create(struct mxr_device *mdev, int idx)
38297 {
38298 struct mxr_layer *layer;
38299 int ret;
38300 - struct mxr_layer_ops ops = {
38301 + static struct mxr_layer_ops ops = {
38302 .release = mxr_vp_layer_release,
38303 .buffer_set = mxr_vp_buffer_set,
38304 .stream_set = mxr_vp_stream_set,
38305 diff --git a/drivers/media/radio/radio-cadet.c b/drivers/media/radio/radio-cadet.c
38306 index 643d80a..56bb96b 100644
38307 --- a/drivers/media/radio/radio-cadet.c
38308 +++ b/drivers/media/radio/radio-cadet.c
38309 @@ -302,6 +302,8 @@ static ssize_t cadet_read(struct file *file, char __user *data, size_t count, lo
38310 unsigned char readbuf[RDS_BUFFER];
38311 int i = 0;
38312
38313 + if (count > RDS_BUFFER)
38314 + return -EFAULT;
38315 mutex_lock(&dev->lock);
38316 if (dev->rdsstat == 0)
38317 cadet_start_rds(dev);
38318 @@ -317,7 +319,7 @@ static ssize_t cadet_read(struct file *file, char __user *data, size_t count, lo
38319 while (i < count && dev->rdsin != dev->rdsout)
38320 readbuf[i++] = dev->rdsbuf[dev->rdsout++];
38321
38322 - if (i && copy_to_user(data, readbuf, i))
38323 + if (i > sizeof(readbuf) || copy_to_user(data, readbuf, i))
38324 i = -EFAULT;
38325 unlock:
38326 mutex_unlock(&dev->lock);
38327 diff --git a/drivers/media/usb/dvb-usb/cxusb.c b/drivers/media/usb/dvb-usb/cxusb.c
38328 index 3940bb0..fb3952a 100644
38329 --- a/drivers/media/usb/dvb-usb/cxusb.c
38330 +++ b/drivers/media/usb/dvb-usb/cxusb.c
38331 @@ -1068,7 +1068,7 @@ static struct dib0070_config dib7070p_dib0070_config = {
38332
38333 struct dib0700_adapter_state {
38334 int (*set_param_save) (struct dvb_frontend *);
38335 -};
38336 +} __no_const;
38337
38338 static int dib7070_set_param_override(struct dvb_frontend *fe)
38339 {
38340 diff --git a/drivers/media/usb/dvb-usb/dw2102.c b/drivers/media/usb/dvb-usb/dw2102.c
38341 index 9382895..ac8093c 100644
38342 --- a/drivers/media/usb/dvb-usb/dw2102.c
38343 +++ b/drivers/media/usb/dvb-usb/dw2102.c
38344 @@ -95,7 +95,7 @@ struct su3000_state {
38345
38346 struct s6x0_state {
38347 int (*old_set_voltage)(struct dvb_frontend *f, fe_sec_voltage_t v);
38348 -};
38349 +} __no_const;
38350
38351 /* debug */
38352 static int dvb_usb_dw2102_debug;
38353 diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c
38354 index aa6e7c7..4cd8061 100644
38355 --- a/drivers/media/v4l2-core/v4l2-ioctl.c
38356 +++ b/drivers/media/v4l2-core/v4l2-ioctl.c
38357 @@ -1923,7 +1923,8 @@ struct v4l2_ioctl_info {
38358 struct file *file, void *fh, void *p);
38359 } u;
38360 void (*debug)(const void *arg, bool write_only);
38361 -};
38362 +} __do_const;
38363 +typedef struct v4l2_ioctl_info __no_const v4l2_ioctl_info_no_const;
38364
38365 /* This control needs a priority check */
38366 #define INFO_FL_PRIO (1 << 0)
38367 @@ -2108,7 +2109,7 @@ static long __video_do_ioctl(struct file *file,
38368 struct video_device *vfd = video_devdata(file);
38369 const struct v4l2_ioctl_ops *ops = vfd->ioctl_ops;
38370 bool write_only = false;
38371 - struct v4l2_ioctl_info default_info;
38372 + v4l2_ioctl_info_no_const default_info;
38373 const struct v4l2_ioctl_info *info;
38374 void *fh = file->private_data;
38375 struct v4l2_fh *vfh = NULL;
38376 diff --git a/drivers/memstick/host/r592.c b/drivers/memstick/host/r592.c
38377 index 29b2172..a7c5b31 100644
38378 --- a/drivers/memstick/host/r592.c
38379 +++ b/drivers/memstick/host/r592.c
38380 @@ -454,7 +454,7 @@ static int r592_transfer_fifo_pio(struct r592_device *dev)
38381 /* Executes one TPC (data is read/written from small or large fifo) */
38382 static void r592_execute_tpc(struct r592_device *dev)
38383 {
38384 - bool is_write = dev->req->tpc >= MS_TPC_SET_RW_REG_ADRS;
38385 + bool is_write;
38386 int len, error;
38387 u32 status, reg;
38388
38389 @@ -463,6 +463,7 @@ static void r592_execute_tpc(struct r592_device *dev)
38390 return;
38391 }
38392
38393 + is_write = dev->req->tpc >= MS_TPC_SET_RW_REG_ADRS;
38394 len = dev->req->long_data ?
38395 dev->req->sg.length : dev->req->data_len;
38396
38397 diff --git a/drivers/message/fusion/mptbase.c b/drivers/message/fusion/mptbase.c
38398 index fb69baa..3aeea2e 100644
38399 --- a/drivers/message/fusion/mptbase.c
38400 +++ b/drivers/message/fusion/mptbase.c
38401 @@ -6755,8 +6755,13 @@ static int mpt_iocinfo_proc_show(struct seq_file *m, void *v)
38402 seq_printf(m, " MaxChainDepth = 0x%02x frames\n", ioc->facts.MaxChainDepth);
38403 seq_printf(m, " MinBlockSize = 0x%02x bytes\n", 4*ioc->facts.BlockSize);
38404
38405 +#ifdef CONFIG_GRKERNSEC_HIDESYM
38406 + seq_printf(m, " RequestFrames @ 0x%p (Dma @ 0x%p)\n", NULL, NULL);
38407 +#else
38408 seq_printf(m, " RequestFrames @ 0x%p (Dma @ 0x%p)\n",
38409 (void *)ioc->req_frames, (void *)(ulong)ioc->req_frames_dma);
38410 +#endif
38411 +
38412 /*
38413 * Rounding UP to nearest 4-kB boundary here...
38414 */
38415 @@ -6769,7 +6774,11 @@ static int mpt_iocinfo_proc_show(struct seq_file *m, void *v)
38416 ioc->facts.GlobalCredits);
38417
38418 seq_printf(m, " Frames @ 0x%p (Dma @ 0x%p)\n",
38419 +#ifdef CONFIG_GRKERNSEC_HIDESYM
38420 + NULL, NULL);
38421 +#else
38422 (void *)ioc->alloc, (void *)(ulong)ioc->alloc_dma);
38423 +#endif
38424 sz = (ioc->reply_sz * ioc->reply_depth) + 128;
38425 seq_printf(m, " {CurRepSz=%d} x {CurRepDepth=%d} = %d bytes ^= 0x%x\n",
38426 ioc->reply_sz, ioc->reply_depth, ioc->reply_sz*ioc->reply_depth, sz);
38427 diff --git a/drivers/message/fusion/mptsas.c b/drivers/message/fusion/mptsas.c
38428 index fa43c39..daeb158 100644
38429 --- a/drivers/message/fusion/mptsas.c
38430 +++ b/drivers/message/fusion/mptsas.c
38431 @@ -446,6 +446,23 @@ mptsas_is_end_device(struct mptsas_devinfo * attached)
38432 return 0;
38433 }
38434
38435 +static inline void
38436 +mptsas_set_rphy(MPT_ADAPTER *ioc, struct mptsas_phyinfo *phy_info, struct sas_rphy *rphy)
38437 +{
38438 + if (phy_info->port_details) {
38439 + phy_info->port_details->rphy = rphy;
38440 + dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "sas_rphy_add: rphy=%p\n",
38441 + ioc->name, rphy));
38442 + }
38443 +
38444 + if (rphy) {
38445 + dsaswideprintk(ioc, dev_printk(KERN_DEBUG,
38446 + &rphy->dev, MYIOC_s_FMT "add:", ioc->name));
38447 + dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "rphy=%p release=%p\n",
38448 + ioc->name, rphy, rphy->dev.release));
38449 + }
38450 +}
38451 +
38452 /* no mutex */
38453 static void
38454 mptsas_port_delete(MPT_ADAPTER *ioc, struct mptsas_portinfo_details * port_details)
38455 @@ -484,23 +501,6 @@ mptsas_get_rphy(struct mptsas_phyinfo *phy_info)
38456 return NULL;
38457 }
38458
38459 -static inline void
38460 -mptsas_set_rphy(MPT_ADAPTER *ioc, struct mptsas_phyinfo *phy_info, struct sas_rphy *rphy)
38461 -{
38462 - if (phy_info->port_details) {
38463 - phy_info->port_details->rphy = rphy;
38464 - dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "sas_rphy_add: rphy=%p\n",
38465 - ioc->name, rphy));
38466 - }
38467 -
38468 - if (rphy) {
38469 - dsaswideprintk(ioc, dev_printk(KERN_DEBUG,
38470 - &rphy->dev, MYIOC_s_FMT "add:", ioc->name));
38471 - dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "rphy=%p release=%p\n",
38472 - ioc->name, rphy, rphy->dev.release));
38473 - }
38474 -}
38475 -
38476 static inline struct sas_port *
38477 mptsas_get_port(struct mptsas_phyinfo *phy_info)
38478 {
38479 diff --git a/drivers/message/fusion/mptscsih.c b/drivers/message/fusion/mptscsih.c
38480 index 164afa7..b6b2e74 100644
38481 --- a/drivers/message/fusion/mptscsih.c
38482 +++ b/drivers/message/fusion/mptscsih.c
38483 @@ -1271,15 +1271,16 @@ mptscsih_info(struct Scsi_Host *SChost)
38484
38485 h = shost_priv(SChost);
38486
38487 - if (h) {
38488 - if (h->info_kbuf == NULL)
38489 - if ((h->info_kbuf = kmalloc(0x1000 /* 4Kb */, GFP_KERNEL)) == NULL)
38490 - return h->info_kbuf;
38491 - h->info_kbuf[0] = '\0';
38492 + if (!h)
38493 + return NULL;
38494
38495 - mpt_print_ioc_summary(h->ioc, h->info_kbuf, &size, 0, 0);
38496 - h->info_kbuf[size-1] = '\0';
38497 - }
38498 + if (h->info_kbuf == NULL)
38499 + if ((h->info_kbuf = kmalloc(0x1000 /* 4Kb */, GFP_KERNEL)) == NULL)
38500 + return h->info_kbuf;
38501 + h->info_kbuf[0] = '\0';
38502 +
38503 + mpt_print_ioc_summary(h->ioc, h->info_kbuf, &size, 0, 0);
38504 + h->info_kbuf[size-1] = '\0';
38505
38506 return h->info_kbuf;
38507 }
38508 diff --git a/drivers/message/i2o/i2o_proc.c b/drivers/message/i2o/i2o_proc.c
38509 index 8001aa6..b137580 100644
38510 --- a/drivers/message/i2o/i2o_proc.c
38511 +++ b/drivers/message/i2o/i2o_proc.c
38512 @@ -255,12 +255,6 @@ static char *scsi_devices[] = {
38513 "Array Controller Device"
38514 };
38515
38516 -static char *chtostr(char *tmp, u8 *chars, int n)
38517 -{
38518 - tmp[0] = 0;
38519 - return strncat(tmp, (char *)chars, n);
38520 -}
38521 -
38522 static int i2o_report_query_status(struct seq_file *seq, int block_status,
38523 char *group)
38524 {
38525 @@ -790,7 +784,6 @@ static int i2o_seq_show_ddm_table(struct seq_file *seq, void *v)
38526 } *result;
38527
38528 i2o_exec_execute_ddm_table ddm_table;
38529 - char tmp[28 + 1];
38530
38531 result = kmalloc(sizeof(*result), GFP_KERNEL);
38532 if (!result)
38533 @@ -825,8 +818,7 @@ static int i2o_seq_show_ddm_table(struct seq_file *seq, void *v)
38534
38535 seq_printf(seq, "%-#7x", ddm_table.i2o_vendor_id);
38536 seq_printf(seq, "%-#8x", ddm_table.module_id);
38537 - seq_printf(seq, "%-29s",
38538 - chtostr(tmp, ddm_table.module_name_version, 28));
38539 + seq_printf(seq, "%-.28s", ddm_table.module_name_version);
38540 seq_printf(seq, "%9d ", ddm_table.data_size);
38541 seq_printf(seq, "%8d", ddm_table.code_size);
38542
38543 @@ -893,7 +885,6 @@ static int i2o_seq_show_drivers_stored(struct seq_file *seq, void *v)
38544
38545 i2o_driver_result_table *result;
38546 i2o_driver_store_table *dst;
38547 - char tmp[28 + 1];
38548
38549 result = kmalloc(sizeof(i2o_driver_result_table), GFP_KERNEL);
38550 if (result == NULL)
38551 @@ -928,9 +919,8 @@ static int i2o_seq_show_drivers_stored(struct seq_file *seq, void *v)
38552
38553 seq_printf(seq, "%-#7x", dst->i2o_vendor_id);
38554 seq_printf(seq, "%-#8x", dst->module_id);
38555 - seq_printf(seq, "%-29s",
38556 - chtostr(tmp, dst->module_name_version, 28));
38557 - seq_printf(seq, "%-9s", chtostr(tmp, dst->date, 8));
38558 + seq_printf(seq, "%-.28s", dst->module_name_version);
38559 + seq_printf(seq, "%-.8s", dst->date);
38560 seq_printf(seq, "%8d ", dst->module_size);
38561 seq_printf(seq, "%8d ", dst->mpb_size);
38562 seq_printf(seq, "0x%04x", dst->module_flags);
38563 @@ -1250,7 +1240,6 @@ static int i2o_seq_show_dev_identity(struct seq_file *seq, void *v)
38564 // == (allow) 512d bytes (max)
38565 static u16 *work16 = (u16 *) work32;
38566 int token;
38567 - char tmp[16 + 1];
38568
38569 token = i2o_parm_field_get(d, 0xF100, -1, &work32, sizeof(work32));
38570
38571 @@ -1262,14 +1251,10 @@ static int i2o_seq_show_dev_identity(struct seq_file *seq, void *v)
38572 seq_printf(seq, "Device Class : %s\n", i2o_get_class_name(work16[0]));
38573 seq_printf(seq, "Owner TID : %0#5x\n", work16[2]);
38574 seq_printf(seq, "Parent TID : %0#5x\n", work16[3]);
38575 - seq_printf(seq, "Vendor info : %s\n",
38576 - chtostr(tmp, (u8 *) (work32 + 2), 16));
38577 - seq_printf(seq, "Product info : %s\n",
38578 - chtostr(tmp, (u8 *) (work32 + 6), 16));
38579 - seq_printf(seq, "Description : %s\n",
38580 - chtostr(tmp, (u8 *) (work32 + 10), 16));
38581 - seq_printf(seq, "Product rev. : %s\n",
38582 - chtostr(tmp, (u8 *) (work32 + 14), 8));
38583 + seq_printf(seq, "Vendor info : %.16s\n", (u8 *) (work32 + 2));
38584 + seq_printf(seq, "Product info : %.16s\n", (u8 *) (work32 + 6));
38585 + seq_printf(seq, "Description : %.16s\n", (u8 *) (work32 + 10));
38586 + seq_printf(seq, "Product rev. : %.8s\n", (u8 *) (work32 + 14));
38587
38588 seq_printf(seq, "Serial number : ");
38589 print_serial_number(seq, (u8 *) (work32 + 16),
38590 @@ -1306,8 +1291,6 @@ static int i2o_seq_show_ddm_identity(struct seq_file *seq, void *v)
38591 u8 pad[256]; // allow up to 256 byte (max) serial number
38592 } result;
38593
38594 - char tmp[24 + 1];
38595 -
38596 token = i2o_parm_field_get(d, 0xF101, -1, &result, sizeof(result));
38597
38598 if (token < 0) {
38599 @@ -1316,10 +1299,8 @@ static int i2o_seq_show_ddm_identity(struct seq_file *seq, void *v)
38600 }
38601
38602 seq_printf(seq, "Registering DDM TID : 0x%03x\n", result.ddm_tid);
38603 - seq_printf(seq, "Module name : %s\n",
38604 - chtostr(tmp, result.module_name, 24));
38605 - seq_printf(seq, "Module revision : %s\n",
38606 - chtostr(tmp, result.module_rev, 8));
38607 + seq_printf(seq, "Module name : %.24s\n", result.module_name);
38608 + seq_printf(seq, "Module revision : %.8s\n", result.module_rev);
38609
38610 seq_printf(seq, "Serial number : ");
38611 print_serial_number(seq, result.serial_number, sizeof(result) - 36);
38612 @@ -1343,8 +1324,6 @@ static int i2o_seq_show_uinfo(struct seq_file *seq, void *v)
38613 u8 instance_number[4];
38614 } result;
38615
38616 - char tmp[64 + 1];
38617 -
38618 token = i2o_parm_field_get(d, 0xF102, -1, &result, sizeof(result));
38619
38620 if (token < 0) {
38621 @@ -1352,14 +1331,10 @@ static int i2o_seq_show_uinfo(struct seq_file *seq, void *v)
38622 return 0;
38623 }
38624
38625 - seq_printf(seq, "Device name : %s\n",
38626 - chtostr(tmp, result.device_name, 64));
38627 - seq_printf(seq, "Service name : %s\n",
38628 - chtostr(tmp, result.service_name, 64));
38629 - seq_printf(seq, "Physical name : %s\n",
38630 - chtostr(tmp, result.physical_location, 64));
38631 - seq_printf(seq, "Instance number : %s\n",
38632 - chtostr(tmp, result.instance_number, 4));
38633 + seq_printf(seq, "Device name : %.64s\n", result.device_name);
38634 + seq_printf(seq, "Service name : %.64s\n", result.service_name);
38635 + seq_printf(seq, "Physical name : %.64s\n", result.physical_location);
38636 + seq_printf(seq, "Instance number : %.4s\n", result.instance_number);
38637
38638 return 0;
38639 }
38640 diff --git a/drivers/message/i2o/iop.c b/drivers/message/i2o/iop.c
38641 index a8c08f3..155fe3d 100644
38642 --- a/drivers/message/i2o/iop.c
38643 +++ b/drivers/message/i2o/iop.c
38644 @@ -111,10 +111,10 @@ u32 i2o_cntxt_list_add(struct i2o_controller * c, void *ptr)
38645
38646 spin_lock_irqsave(&c->context_list_lock, flags);
38647
38648 - if (unlikely(atomic_inc_and_test(&c->context_list_counter)))
38649 - atomic_inc(&c->context_list_counter);
38650 + if (unlikely(atomic_inc_and_test_unchecked(&c->context_list_counter)))
38651 + atomic_inc_unchecked(&c->context_list_counter);
38652
38653 - entry->context = atomic_read(&c->context_list_counter);
38654 + entry->context = atomic_read_unchecked(&c->context_list_counter);
38655
38656 list_add(&entry->list, &c->context_list);
38657
38658 @@ -1077,7 +1077,7 @@ struct i2o_controller *i2o_iop_alloc(void)
38659
38660 #if BITS_PER_LONG == 64
38661 spin_lock_init(&c->context_list_lock);
38662 - atomic_set(&c->context_list_counter, 0);
38663 + atomic_set_unchecked(&c->context_list_counter, 0);
38664 INIT_LIST_HEAD(&c->context_list);
38665 #endif
38666
38667 diff --git a/drivers/mfd/janz-cmodio.c b/drivers/mfd/janz-cmodio.c
38668 index 45ece11..8efa218 100644
38669 --- a/drivers/mfd/janz-cmodio.c
38670 +++ b/drivers/mfd/janz-cmodio.c
38671 @@ -13,6 +13,7 @@
38672
38673 #include <linux/kernel.h>
38674 #include <linux/module.h>
38675 +#include <linux/slab.h>
38676 #include <linux/init.h>
38677 #include <linux/pci.h>
38678 #include <linux/interrupt.h>
38679 diff --git a/drivers/mfd/twl4030-irq.c b/drivers/mfd/twl4030-irq.c
38680 index a5f9888..1c0ed56 100644
38681 --- a/drivers/mfd/twl4030-irq.c
38682 +++ b/drivers/mfd/twl4030-irq.c
38683 @@ -35,6 +35,7 @@
38684 #include <linux/of.h>
38685 #include <linux/irqdomain.h>
38686 #include <linux/i2c/twl.h>
38687 +#include <asm/pgtable.h>
38688
38689 #include "twl-core.h"
38690
38691 @@ -728,10 +729,12 @@ int twl4030_init_irq(struct device *dev, int irq_num)
38692 * Install an irq handler for each of the SIH modules;
38693 * clone dummy irq_chip since PIH can't *do* anything
38694 */
38695 - twl4030_irq_chip = dummy_irq_chip;
38696 - twl4030_irq_chip.name = "twl4030";
38697 + pax_open_kernel();
38698 + memcpy((void *)&twl4030_irq_chip, &dummy_irq_chip, sizeof twl4030_irq_chip);
38699 + *(const char **)&twl4030_irq_chip.name = "twl4030";
38700
38701 - twl4030_sih_irq_chip.irq_ack = dummy_irq_chip.irq_ack;
38702 + *(void **)&twl4030_sih_irq_chip.irq_ack = dummy_irq_chip.irq_ack;
38703 + pax_close_kernel();
38704
38705 for (i = irq_base; i < irq_end; i++) {
38706 irq_set_chip_and_handler(i, &twl4030_irq_chip,
38707 diff --git a/drivers/mfd/twl6030-irq.c b/drivers/mfd/twl6030-irq.c
38708 index 277a8db..0e0b754 100644
38709 --- a/drivers/mfd/twl6030-irq.c
38710 +++ b/drivers/mfd/twl6030-irq.c
38711 @@ -387,10 +387,12 @@ int twl6030_init_irq(struct device *dev, int irq_num)
38712 * install an irq handler for each of the modules;
38713 * clone dummy irq_chip since PIH can't *do* anything
38714 */
38715 - twl6030_irq_chip = dummy_irq_chip;
38716 - twl6030_irq_chip.name = "twl6030";
38717 - twl6030_irq_chip.irq_set_type = NULL;
38718 - twl6030_irq_chip.irq_set_wake = twl6030_irq_set_wake;
38719 + pax_open_kernel();
38720 + memcpy((void *)&twl6030_irq_chip, &dummy_irq_chip, sizeof twl6030_irq_chip);
38721 + *(const char **)&twl6030_irq_chip.name = "twl6030";
38722 + *(void **)&twl6030_irq_chip.irq_set_type = NULL;
38723 + *(void **)&twl6030_irq_chip.irq_set_wake = twl6030_irq_set_wake;
38724 + pax_close_kernel();
38725
38726 for (i = irq_base; i < irq_end; i++) {
38727 irq_set_chip_and_handler(i, &twl6030_irq_chip,
38728 diff --git a/drivers/misc/c2port/core.c b/drivers/misc/c2port/core.c
38729 index f428d86..274c368 100644
38730 --- a/drivers/misc/c2port/core.c
38731 +++ b/drivers/misc/c2port/core.c
38732 @@ -924,7 +924,9 @@ struct c2port_device *c2port_device_register(char *name,
38733 mutex_init(&c2dev->mutex);
38734
38735 /* Create binary file */
38736 - c2port_bin_attrs.size = ops->blocks_num * ops->block_size;
38737 + pax_open_kernel();
38738 + *(size_t *)&c2port_bin_attrs.size = ops->blocks_num * ops->block_size;
38739 + pax_close_kernel();
38740 ret = device_create_bin_file(c2dev->dev, &c2port_bin_attrs);
38741 if (unlikely(ret))
38742 goto error_device_create_bin_file;
38743 diff --git a/drivers/misc/kgdbts.c b/drivers/misc/kgdbts.c
38744 index 3aa9a96..59cf685 100644
38745 --- a/drivers/misc/kgdbts.c
38746 +++ b/drivers/misc/kgdbts.c
38747 @@ -832,7 +832,7 @@ static void run_plant_and_detach_test(int is_early)
38748 char before[BREAK_INSTR_SIZE];
38749 char after[BREAK_INSTR_SIZE];
38750
38751 - probe_kernel_read(before, (char *)kgdbts_break_test,
38752 + probe_kernel_read(before, ktla_ktva((char *)kgdbts_break_test),
38753 BREAK_INSTR_SIZE);
38754 init_simple_test();
38755 ts.tst = plant_and_detach_test;
38756 @@ -840,7 +840,7 @@ static void run_plant_and_detach_test(int is_early)
38757 /* Activate test with initial breakpoint */
38758 if (!is_early)
38759 kgdb_breakpoint();
38760 - probe_kernel_read(after, (char *)kgdbts_break_test,
38761 + probe_kernel_read(after, ktla_ktva((char *)kgdbts_break_test),
38762 BREAK_INSTR_SIZE);
38763 if (memcmp(before, after, BREAK_INSTR_SIZE)) {
38764 printk(KERN_CRIT "kgdbts: ERROR kgdb corrupted memory\n");
38765 diff --git a/drivers/misc/lis3lv02d/lis3lv02d.c b/drivers/misc/lis3lv02d/lis3lv02d.c
38766 index 4a87e5c..76bdf5c 100644
38767 --- a/drivers/misc/lis3lv02d/lis3lv02d.c
38768 +++ b/drivers/misc/lis3lv02d/lis3lv02d.c
38769 @@ -498,7 +498,7 @@ static irqreturn_t lis302dl_interrupt(int irq, void *data)
38770 * the lid is closed. This leads to interrupts as soon as a little move
38771 * is done.
38772 */
38773 - atomic_inc(&lis3->count);
38774 + atomic_inc_unchecked(&lis3->count);
38775
38776 wake_up_interruptible(&lis3->misc_wait);
38777 kill_fasync(&lis3->async_queue, SIGIO, POLL_IN);
38778 @@ -584,7 +584,7 @@ static int lis3lv02d_misc_open(struct inode *inode, struct file *file)
38779 if (lis3->pm_dev)
38780 pm_runtime_get_sync(lis3->pm_dev);
38781
38782 - atomic_set(&lis3->count, 0);
38783 + atomic_set_unchecked(&lis3->count, 0);
38784 return 0;
38785 }
38786
38787 @@ -617,7 +617,7 @@ static ssize_t lis3lv02d_misc_read(struct file *file, char __user *buf,
38788 add_wait_queue(&lis3->misc_wait, &wait);
38789 while (true) {
38790 set_current_state(TASK_INTERRUPTIBLE);
38791 - data = atomic_xchg(&lis3->count, 0);
38792 + data = atomic_xchg_unchecked(&lis3->count, 0);
38793 if (data)
38794 break;
38795
38796 @@ -658,7 +658,7 @@ static unsigned int lis3lv02d_misc_poll(struct file *file, poll_table *wait)
38797 struct lis3lv02d, miscdev);
38798
38799 poll_wait(file, &lis3->misc_wait, wait);
38800 - if (atomic_read(&lis3->count))
38801 + if (atomic_read_unchecked(&lis3->count))
38802 return POLLIN | POLLRDNORM;
38803 return 0;
38804 }
38805 diff --git a/drivers/misc/lis3lv02d/lis3lv02d.h b/drivers/misc/lis3lv02d/lis3lv02d.h
38806 index c439c82..1f20f57 100644
38807 --- a/drivers/misc/lis3lv02d/lis3lv02d.h
38808 +++ b/drivers/misc/lis3lv02d/lis3lv02d.h
38809 @@ -297,7 +297,7 @@ struct lis3lv02d {
38810 struct input_polled_dev *idev; /* input device */
38811 struct platform_device *pdev; /* platform device */
38812 struct regulator_bulk_data regulators[2];
38813 - atomic_t count; /* interrupt count after last read */
38814 + atomic_unchecked_t count; /* interrupt count after last read */
38815 union axis_conversion ac; /* hw -> logical axis */
38816 int mapped_btns[3];
38817
38818 diff --git a/drivers/misc/sgi-gru/gruhandles.c b/drivers/misc/sgi-gru/gruhandles.c
38819 index 2f30bad..c4c13d0 100644
38820 --- a/drivers/misc/sgi-gru/gruhandles.c
38821 +++ b/drivers/misc/sgi-gru/gruhandles.c
38822 @@ -44,8 +44,8 @@ static void update_mcs_stats(enum mcs_op op, unsigned long clks)
38823 unsigned long nsec;
38824
38825 nsec = CLKS2NSEC(clks);
38826 - atomic_long_inc(&mcs_op_statistics[op].count);
38827 - atomic_long_add(nsec, &mcs_op_statistics[op].total);
38828 + atomic_long_inc_unchecked(&mcs_op_statistics[op].count);
38829 + atomic_long_add_unchecked(nsec, &mcs_op_statistics[op].total);
38830 if (mcs_op_statistics[op].max < nsec)
38831 mcs_op_statistics[op].max = nsec;
38832 }
38833 diff --git a/drivers/misc/sgi-gru/gruprocfs.c b/drivers/misc/sgi-gru/gruprocfs.c
38834 index 950dbe9..eeef0f8 100644
38835 --- a/drivers/misc/sgi-gru/gruprocfs.c
38836 +++ b/drivers/misc/sgi-gru/gruprocfs.c
38837 @@ -32,9 +32,9 @@
38838
38839 #define printstat(s, f) printstat_val(s, &gru_stats.f, #f)
38840
38841 -static void printstat_val(struct seq_file *s, atomic_long_t *v, char *id)
38842 +static void printstat_val(struct seq_file *s, atomic_long_unchecked_t *v, char *id)
38843 {
38844 - unsigned long val = atomic_long_read(v);
38845 + unsigned long val = atomic_long_read_unchecked(v);
38846
38847 seq_printf(s, "%16lu %s\n", val, id);
38848 }
38849 @@ -134,8 +134,8 @@ static int mcs_statistics_show(struct seq_file *s, void *p)
38850
38851 seq_printf(s, "%-20s%12s%12s%12s\n", "#id", "count", "aver-clks", "max-clks");
38852 for (op = 0; op < mcsop_last; op++) {
38853 - count = atomic_long_read(&mcs_op_statistics[op].count);
38854 - total = atomic_long_read(&mcs_op_statistics[op].total);
38855 + count = atomic_long_read_unchecked(&mcs_op_statistics[op].count);
38856 + total = atomic_long_read_unchecked(&mcs_op_statistics[op].total);
38857 max = mcs_op_statistics[op].max;
38858 seq_printf(s, "%-20s%12ld%12ld%12ld\n", id[op], count,
38859 count ? total / count : 0, max);
38860 diff --git a/drivers/misc/sgi-gru/grutables.h b/drivers/misc/sgi-gru/grutables.h
38861 index 5c3ce24..4915ccb 100644
38862 --- a/drivers/misc/sgi-gru/grutables.h
38863 +++ b/drivers/misc/sgi-gru/grutables.h
38864 @@ -167,82 +167,82 @@ extern unsigned int gru_max_gids;
38865 * GRU statistics.
38866 */
38867 struct gru_stats_s {
38868 - atomic_long_t vdata_alloc;
38869 - atomic_long_t vdata_free;
38870 - atomic_long_t gts_alloc;
38871 - atomic_long_t gts_free;
38872 - atomic_long_t gms_alloc;
38873 - atomic_long_t gms_free;
38874 - atomic_long_t gts_double_allocate;
38875 - atomic_long_t assign_context;
38876 - atomic_long_t assign_context_failed;
38877 - atomic_long_t free_context;
38878 - atomic_long_t load_user_context;
38879 - atomic_long_t load_kernel_context;
38880 - atomic_long_t lock_kernel_context;
38881 - atomic_long_t unlock_kernel_context;
38882 - atomic_long_t steal_user_context;
38883 - atomic_long_t steal_kernel_context;
38884 - atomic_long_t steal_context_failed;
38885 - atomic_long_t nopfn;
38886 - atomic_long_t asid_new;
38887 - atomic_long_t asid_next;
38888 - atomic_long_t asid_wrap;
38889 - atomic_long_t asid_reuse;
38890 - atomic_long_t intr;
38891 - atomic_long_t intr_cbr;
38892 - atomic_long_t intr_tfh;
38893 - atomic_long_t intr_spurious;
38894 - atomic_long_t intr_mm_lock_failed;
38895 - atomic_long_t call_os;
38896 - atomic_long_t call_os_wait_queue;
38897 - atomic_long_t user_flush_tlb;
38898 - atomic_long_t user_unload_context;
38899 - atomic_long_t user_exception;
38900 - atomic_long_t set_context_option;
38901 - atomic_long_t check_context_retarget_intr;
38902 - atomic_long_t check_context_unload;
38903 - atomic_long_t tlb_dropin;
38904 - atomic_long_t tlb_preload_page;
38905 - atomic_long_t tlb_dropin_fail_no_asid;
38906 - atomic_long_t tlb_dropin_fail_upm;
38907 - atomic_long_t tlb_dropin_fail_invalid;
38908 - atomic_long_t tlb_dropin_fail_range_active;
38909 - atomic_long_t tlb_dropin_fail_idle;
38910 - atomic_long_t tlb_dropin_fail_fmm;
38911 - atomic_long_t tlb_dropin_fail_no_exception;
38912 - atomic_long_t tfh_stale_on_fault;
38913 - atomic_long_t mmu_invalidate_range;
38914 - atomic_long_t mmu_invalidate_page;
38915 - atomic_long_t flush_tlb;
38916 - atomic_long_t flush_tlb_gru;
38917 - atomic_long_t flush_tlb_gru_tgh;
38918 - atomic_long_t flush_tlb_gru_zero_asid;
38919 + atomic_long_unchecked_t vdata_alloc;
38920 + atomic_long_unchecked_t vdata_free;
38921 + atomic_long_unchecked_t gts_alloc;
38922 + atomic_long_unchecked_t gts_free;
38923 + atomic_long_unchecked_t gms_alloc;
38924 + atomic_long_unchecked_t gms_free;
38925 + atomic_long_unchecked_t gts_double_allocate;
38926 + atomic_long_unchecked_t assign_context;
38927 + atomic_long_unchecked_t assign_context_failed;
38928 + atomic_long_unchecked_t free_context;
38929 + atomic_long_unchecked_t load_user_context;
38930 + atomic_long_unchecked_t load_kernel_context;
38931 + atomic_long_unchecked_t lock_kernel_context;
38932 + atomic_long_unchecked_t unlock_kernel_context;
38933 + atomic_long_unchecked_t steal_user_context;
38934 + atomic_long_unchecked_t steal_kernel_context;
38935 + atomic_long_unchecked_t steal_context_failed;
38936 + atomic_long_unchecked_t nopfn;
38937 + atomic_long_unchecked_t asid_new;
38938 + atomic_long_unchecked_t asid_next;
38939 + atomic_long_unchecked_t asid_wrap;
38940 + atomic_long_unchecked_t asid_reuse;
38941 + atomic_long_unchecked_t intr;
38942 + atomic_long_unchecked_t intr_cbr;
38943 + atomic_long_unchecked_t intr_tfh;
38944 + atomic_long_unchecked_t intr_spurious;
38945 + atomic_long_unchecked_t intr_mm_lock_failed;
38946 + atomic_long_unchecked_t call_os;
38947 + atomic_long_unchecked_t call_os_wait_queue;
38948 + atomic_long_unchecked_t user_flush_tlb;
38949 + atomic_long_unchecked_t user_unload_context;
38950 + atomic_long_unchecked_t user_exception;
38951 + atomic_long_unchecked_t set_context_option;
38952 + atomic_long_unchecked_t check_context_retarget_intr;
38953 + atomic_long_unchecked_t check_context_unload;
38954 + atomic_long_unchecked_t tlb_dropin;
38955 + atomic_long_unchecked_t tlb_preload_page;
38956 + atomic_long_unchecked_t tlb_dropin_fail_no_asid;
38957 + atomic_long_unchecked_t tlb_dropin_fail_upm;
38958 + atomic_long_unchecked_t tlb_dropin_fail_invalid;
38959 + atomic_long_unchecked_t tlb_dropin_fail_range_active;
38960 + atomic_long_unchecked_t tlb_dropin_fail_idle;
38961 + atomic_long_unchecked_t tlb_dropin_fail_fmm;
38962 + atomic_long_unchecked_t tlb_dropin_fail_no_exception;
38963 + atomic_long_unchecked_t tfh_stale_on_fault;
38964 + atomic_long_unchecked_t mmu_invalidate_range;
38965 + atomic_long_unchecked_t mmu_invalidate_page;
38966 + atomic_long_unchecked_t flush_tlb;
38967 + atomic_long_unchecked_t flush_tlb_gru;
38968 + atomic_long_unchecked_t flush_tlb_gru_tgh;
38969 + atomic_long_unchecked_t flush_tlb_gru_zero_asid;
38970
38971 - atomic_long_t copy_gpa;
38972 - atomic_long_t read_gpa;
38973 + atomic_long_unchecked_t copy_gpa;
38974 + atomic_long_unchecked_t read_gpa;
38975
38976 - atomic_long_t mesq_receive;
38977 - atomic_long_t mesq_receive_none;
38978 - atomic_long_t mesq_send;
38979 - atomic_long_t mesq_send_failed;
38980 - atomic_long_t mesq_noop;
38981 - atomic_long_t mesq_send_unexpected_error;
38982 - atomic_long_t mesq_send_lb_overflow;
38983 - atomic_long_t mesq_send_qlimit_reached;
38984 - atomic_long_t mesq_send_amo_nacked;
38985 - atomic_long_t mesq_send_put_nacked;
38986 - atomic_long_t mesq_page_overflow;
38987 - atomic_long_t mesq_qf_locked;
38988 - atomic_long_t mesq_qf_noop_not_full;
38989 - atomic_long_t mesq_qf_switch_head_failed;
38990 - atomic_long_t mesq_qf_unexpected_error;
38991 - atomic_long_t mesq_noop_unexpected_error;
38992 - atomic_long_t mesq_noop_lb_overflow;
38993 - atomic_long_t mesq_noop_qlimit_reached;
38994 - atomic_long_t mesq_noop_amo_nacked;
38995 - atomic_long_t mesq_noop_put_nacked;
38996 - atomic_long_t mesq_noop_page_overflow;
38997 + atomic_long_unchecked_t mesq_receive;
38998 + atomic_long_unchecked_t mesq_receive_none;
38999 + atomic_long_unchecked_t mesq_send;
39000 + atomic_long_unchecked_t mesq_send_failed;
39001 + atomic_long_unchecked_t mesq_noop;
39002 + atomic_long_unchecked_t mesq_send_unexpected_error;
39003 + atomic_long_unchecked_t mesq_send_lb_overflow;
39004 + atomic_long_unchecked_t mesq_send_qlimit_reached;
39005 + atomic_long_unchecked_t mesq_send_amo_nacked;
39006 + atomic_long_unchecked_t mesq_send_put_nacked;
39007 + atomic_long_unchecked_t mesq_page_overflow;
39008 + atomic_long_unchecked_t mesq_qf_locked;
39009 + atomic_long_unchecked_t mesq_qf_noop_not_full;
39010 + atomic_long_unchecked_t mesq_qf_switch_head_failed;
39011 + atomic_long_unchecked_t mesq_qf_unexpected_error;
39012 + atomic_long_unchecked_t mesq_noop_unexpected_error;
39013 + atomic_long_unchecked_t mesq_noop_lb_overflow;
39014 + atomic_long_unchecked_t mesq_noop_qlimit_reached;
39015 + atomic_long_unchecked_t mesq_noop_amo_nacked;
39016 + atomic_long_unchecked_t mesq_noop_put_nacked;
39017 + atomic_long_unchecked_t mesq_noop_page_overflow;
39018
39019 };
39020
39021 @@ -251,8 +251,8 @@ enum mcs_op {cchop_allocate, cchop_start, cchop_interrupt, cchop_interrupt_sync,
39022 tghop_invalidate, mcsop_last};
39023
39024 struct mcs_op_statistic {
39025 - atomic_long_t count;
39026 - atomic_long_t total;
39027 + atomic_long_unchecked_t count;
39028 + atomic_long_unchecked_t total;
39029 unsigned long max;
39030 };
39031
39032 @@ -275,7 +275,7 @@ extern struct mcs_op_statistic mcs_op_statistics[mcsop_last];
39033
39034 #define STAT(id) do { \
39035 if (gru_options & OPT_STATS) \
39036 - atomic_long_inc(&gru_stats.id); \
39037 + atomic_long_inc_unchecked(&gru_stats.id); \
39038 } while (0)
39039
39040 #ifdef CONFIG_SGI_GRU_DEBUG
39041 diff --git a/drivers/misc/sgi-xp/xp.h b/drivers/misc/sgi-xp/xp.h
39042 index c862cd4..0d176fe 100644
39043 --- a/drivers/misc/sgi-xp/xp.h
39044 +++ b/drivers/misc/sgi-xp/xp.h
39045 @@ -288,7 +288,7 @@ struct xpc_interface {
39046 xpc_notify_func, void *);
39047 void (*received) (short, int, void *);
39048 enum xp_retval (*partid_to_nasids) (short, void *);
39049 -};
39050 +} __no_const;
39051
39052 extern struct xpc_interface xpc_interface;
39053
39054 diff --git a/drivers/misc/sgi-xp/xpc.h b/drivers/misc/sgi-xp/xpc.h
39055 index b94d5f7..7f494c5 100644
39056 --- a/drivers/misc/sgi-xp/xpc.h
39057 +++ b/drivers/misc/sgi-xp/xpc.h
39058 @@ -835,6 +835,7 @@ struct xpc_arch_operations {
39059 void (*received_payload) (struct xpc_channel *, void *);
39060 void (*notify_senders_of_disconnect) (struct xpc_channel *);
39061 };
39062 +typedef struct xpc_arch_operations __no_const xpc_arch_operations_no_const;
39063
39064 /* struct xpc_partition act_state values (for XPC HB) */
39065
39066 @@ -876,7 +877,7 @@ extern struct xpc_registration xpc_registrations[];
39067 /* found in xpc_main.c */
39068 extern struct device *xpc_part;
39069 extern struct device *xpc_chan;
39070 -extern struct xpc_arch_operations xpc_arch_ops;
39071 +extern xpc_arch_operations_no_const xpc_arch_ops;
39072 extern int xpc_disengage_timelimit;
39073 extern int xpc_disengage_timedout;
39074 extern int xpc_activate_IRQ_rcvd;
39075 diff --git a/drivers/misc/sgi-xp/xpc_main.c b/drivers/misc/sgi-xp/xpc_main.c
39076 index d971817..33bdca5 100644
39077 --- a/drivers/misc/sgi-xp/xpc_main.c
39078 +++ b/drivers/misc/sgi-xp/xpc_main.c
39079 @@ -166,7 +166,7 @@ static struct notifier_block xpc_die_notifier = {
39080 .notifier_call = xpc_system_die,
39081 };
39082
39083 -struct xpc_arch_operations xpc_arch_ops;
39084 +xpc_arch_operations_no_const xpc_arch_ops;
39085
39086 /*
39087 * Timer function to enforce the timelimit on the partition disengage.
39088 @@ -1210,7 +1210,7 @@ xpc_system_die(struct notifier_block *nb, unsigned long event, void *_die_args)
39089
39090 if (((die_args->trapnr == X86_TRAP_MF) ||
39091 (die_args->trapnr == X86_TRAP_XF)) &&
39092 - !user_mode_vm(die_args->regs))
39093 + !user_mode(die_args->regs))
39094 xpc_die_deactivate();
39095
39096 break;
39097 diff --git a/drivers/mmc/core/mmc_ops.c b/drivers/mmc/core/mmc_ops.c
39098 index 6d8f701..35b6369 100644
39099 --- a/drivers/mmc/core/mmc_ops.c
39100 +++ b/drivers/mmc/core/mmc_ops.c
39101 @@ -247,7 +247,7 @@ mmc_send_cxd_data(struct mmc_card *card, struct mmc_host *host,
39102 void *data_buf;
39103 int is_on_stack;
39104
39105 - is_on_stack = object_is_on_stack(buf);
39106 + is_on_stack = object_starts_on_stack(buf);
39107 if (is_on_stack) {
39108 /*
39109 * dma onto stack is unsafe/nonportable, but callers to this
39110 diff --git a/drivers/mmc/host/dw_mmc.h b/drivers/mmc/host/dw_mmc.h
39111 index 53b8fd9..615b462 100644
39112 --- a/drivers/mmc/host/dw_mmc.h
39113 +++ b/drivers/mmc/host/dw_mmc.h
39114 @@ -205,5 +205,5 @@ struct dw_mci_drv_data {
39115 int (*parse_dt)(struct dw_mci *host);
39116 int (*setup_bus)(struct dw_mci *host,
39117 struct device_node *slot_np, u8 bus_width);
39118 -};
39119 +} __do_const;
39120 #endif /* _DW_MMC_H_ */
39121 diff --git a/drivers/mmc/host/sdhci-s3c.c b/drivers/mmc/host/sdhci-s3c.c
39122 index 82a8de1..3c56ccb 100644
39123 --- a/drivers/mmc/host/sdhci-s3c.c
39124 +++ b/drivers/mmc/host/sdhci-s3c.c
39125 @@ -721,9 +721,11 @@ static int sdhci_s3c_probe(struct platform_device *pdev)
39126 * we can use overriding functions instead of default.
39127 */
39128 if (host->quirks & SDHCI_QUIRK_NONSTANDARD_CLOCK) {
39129 - sdhci_s3c_ops.set_clock = sdhci_cmu_set_clock;
39130 - sdhci_s3c_ops.get_min_clock = sdhci_cmu_get_min_clock;
39131 - sdhci_s3c_ops.get_max_clock = sdhci_cmu_get_max_clock;
39132 + pax_open_kernel();
39133 + *(void **)&sdhci_s3c_ops.set_clock = sdhci_cmu_set_clock;
39134 + *(void **)&sdhci_s3c_ops.get_min_clock = sdhci_cmu_get_min_clock;
39135 + *(void **)&sdhci_s3c_ops.get_max_clock = sdhci_cmu_get_max_clock;
39136 + pax_close_kernel();
39137 }
39138
39139 /* It supports additional host capabilities if needed */
39140 diff --git a/drivers/mtd/devices/doc2000.c b/drivers/mtd/devices/doc2000.c
39141 index a4eb8b5..8c0628f 100644
39142 --- a/drivers/mtd/devices/doc2000.c
39143 +++ b/drivers/mtd/devices/doc2000.c
39144 @@ -753,7 +753,7 @@ static int doc_write(struct mtd_info *mtd, loff_t to, size_t len,
39145
39146 /* The ECC will not be calculated correctly if less than 512 is written */
39147 /* DBB-
39148 - if (len != 0x200 && eccbuf)
39149 + if (len != 0x200)
39150 printk(KERN_WARNING
39151 "ECC needs a full sector write (adr: %lx size %lx)\n",
39152 (long) to, (long) len);
39153 diff --git a/drivers/mtd/nand/denali.c b/drivers/mtd/nand/denali.c
39154 index 0c8bb6b..6f35deb 100644
39155 --- a/drivers/mtd/nand/denali.c
39156 +++ b/drivers/mtd/nand/denali.c
39157 @@ -24,6 +24,7 @@
39158 #include <linux/slab.h>
39159 #include <linux/mtd/mtd.h>
39160 #include <linux/module.h>
39161 +#include <linux/slab.h>
39162
39163 #include "denali.h"
39164
39165 diff --git a/drivers/mtd/nftlmount.c b/drivers/mtd/nftlmount.c
39166 index 51b9d6a..52af9a7 100644
39167 --- a/drivers/mtd/nftlmount.c
39168 +++ b/drivers/mtd/nftlmount.c
39169 @@ -24,6 +24,7 @@
39170 #include <asm/errno.h>
39171 #include <linux/delay.h>
39172 #include <linux/slab.h>
39173 +#include <linux/sched.h>
39174 #include <linux/mtd/mtd.h>
39175 #include <linux/mtd/nand.h>
39176 #include <linux/mtd/nftl.h>
39177 diff --git a/drivers/mtd/sm_ftl.c b/drivers/mtd/sm_ftl.c
39178 index 8dd6ba5..419cc1d 100644
39179 --- a/drivers/mtd/sm_ftl.c
39180 +++ b/drivers/mtd/sm_ftl.c
39181 @@ -56,7 +56,7 @@ ssize_t sm_attr_show(struct device *dev, struct device_attribute *attr,
39182 #define SM_CIS_VENDOR_OFFSET 0x59
39183 struct attribute_group *sm_create_sysfs_attributes(struct sm_ftl *ftl)
39184 {
39185 - struct attribute_group *attr_group;
39186 + attribute_group_no_const *attr_group;
39187 struct attribute **attributes;
39188 struct sm_sysfs_attribute *vendor_attribute;
39189
39190 diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
39191 index a079da17..f86ffd5 100644
39192 --- a/drivers/net/bonding/bond_main.c
39193 +++ b/drivers/net/bonding/bond_main.c
39194 @@ -4862,7 +4862,7 @@ static unsigned int bond_get_num_tx_queues(void)
39195 return tx_queues;
39196 }
39197
39198 -static struct rtnl_link_ops bond_link_ops __read_mostly = {
39199 +static struct rtnl_link_ops bond_link_ops = {
39200 .kind = "bond",
39201 .priv_size = sizeof(struct bonding),
39202 .setup = bond_setup,
39203 diff --git a/drivers/net/ethernet/8390/ax88796.c b/drivers/net/ethernet/8390/ax88796.c
39204 index 70dba5d..11a0919 100644
39205 --- a/drivers/net/ethernet/8390/ax88796.c
39206 +++ b/drivers/net/ethernet/8390/ax88796.c
39207 @@ -872,9 +872,11 @@ static int ax_probe(struct platform_device *pdev)
39208 if (ax->plat->reg_offsets)
39209 ei_local->reg_offset = ax->plat->reg_offsets;
39210 else {
39211 + resource_size_t _mem_size = mem_size;
39212 + do_div(_mem_size, 0x18);
39213 ei_local->reg_offset = ax->reg_offsets;
39214 for (ret = 0; ret < 0x18; ret++)
39215 - ax->reg_offsets[ret] = (mem_size / 0x18) * ret;
39216 + ax->reg_offsets[ret] = _mem_size * ret;
39217 }
39218
39219 if (!request_mem_region(mem->start, mem_size, pdev->name)) {
39220 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
39221 index 0991534..8098e92 100644
39222 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
39223 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
39224 @@ -1094,7 +1094,7 @@ static inline u8 bnx2x_get_path_func_num(struct bnx2x *bp)
39225 static inline void bnx2x_init_bp_objs(struct bnx2x *bp)
39226 {
39227 /* RX_MODE controlling object */
39228 - bnx2x_init_rx_mode_obj(bp, &bp->rx_mode_obj);
39229 + bnx2x_init_rx_mode_obj(bp);
39230
39231 /* multicast configuration controlling object */
39232 bnx2x_init_mcast_obj(bp, &bp->mcast_obj, bp->fp->cl_id, bp->fp->cid,
39233 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
39234 index 09b625e..15b16fe 100644
39235 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
39236 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
39237 @@ -2375,15 +2375,14 @@ int bnx2x_config_rx_mode(struct bnx2x *bp,
39238 return rc;
39239 }
39240
39241 -void bnx2x_init_rx_mode_obj(struct bnx2x *bp,
39242 - struct bnx2x_rx_mode_obj *o)
39243 +void bnx2x_init_rx_mode_obj(struct bnx2x *bp)
39244 {
39245 if (CHIP_IS_E1x(bp)) {
39246 - o->wait_comp = bnx2x_empty_rx_mode_wait;
39247 - o->config_rx_mode = bnx2x_set_rx_mode_e1x;
39248 + bp->rx_mode_obj.wait_comp = bnx2x_empty_rx_mode_wait;
39249 + bp->rx_mode_obj.config_rx_mode = bnx2x_set_rx_mode_e1x;
39250 } else {
39251 - o->wait_comp = bnx2x_wait_rx_mode_comp_e2;
39252 - o->config_rx_mode = bnx2x_set_rx_mode_e2;
39253 + bp->rx_mode_obj.wait_comp = bnx2x_wait_rx_mode_comp_e2;
39254 + bp->rx_mode_obj.config_rx_mode = bnx2x_set_rx_mode_e2;
39255 }
39256 }
39257
39258 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
39259 index adbd91b..58ec94a 100644
39260 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
39261 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
39262 @@ -1293,8 +1293,7 @@ int bnx2x_vlan_mac_move(struct bnx2x *bp,
39263
39264 /********************* RX MODE ****************/
39265
39266 -void bnx2x_init_rx_mode_obj(struct bnx2x *bp,
39267 - struct bnx2x_rx_mode_obj *o);
39268 +void bnx2x_init_rx_mode_obj(struct bnx2x *bp);
39269
39270 /**
39271 * bnx2x_config_rx_mode - Send and RX_MODE ramrod according to the provided parameters.
39272 diff --git a/drivers/net/ethernet/broadcom/tg3.h b/drivers/net/ethernet/broadcom/tg3.h
39273 index d330e81..ce1fb9a 100644
39274 --- a/drivers/net/ethernet/broadcom/tg3.h
39275 +++ b/drivers/net/ethernet/broadcom/tg3.h
39276 @@ -146,6 +146,7 @@
39277 #define CHIPREV_ID_5750_A0 0x4000
39278 #define CHIPREV_ID_5750_A1 0x4001
39279 #define CHIPREV_ID_5750_A3 0x4003
39280 +#define CHIPREV_ID_5750_C1 0x4201
39281 #define CHIPREV_ID_5750_C2 0x4202
39282 #define CHIPREV_ID_5752_A0_HW 0x5000
39283 #define CHIPREV_ID_5752_A0 0x6000
39284 diff --git a/drivers/net/ethernet/chelsio/cxgb3/l2t.h b/drivers/net/ethernet/chelsio/cxgb3/l2t.h
39285 index 8cffcdf..aadf043 100644
39286 --- a/drivers/net/ethernet/chelsio/cxgb3/l2t.h
39287 +++ b/drivers/net/ethernet/chelsio/cxgb3/l2t.h
39288 @@ -87,7 +87,7 @@ typedef void (*arp_failure_handler_func)(struct t3cdev * dev,
39289 */
39290 struct l2t_skb_cb {
39291 arp_failure_handler_func arp_failure_handler;
39292 -};
39293 +} __no_const;
39294
39295 #define L2T_SKB_CB(skb) ((struct l2t_skb_cb *)(skb)->cb)
39296
39297 diff --git a/drivers/net/ethernet/dec/tulip/de4x5.c b/drivers/net/ethernet/dec/tulip/de4x5.c
39298 index 4c83003..2a2a5b9 100644
39299 --- a/drivers/net/ethernet/dec/tulip/de4x5.c
39300 +++ b/drivers/net/ethernet/dec/tulip/de4x5.c
39301 @@ -5388,7 +5388,7 @@ de4x5_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
39302 for (i=0; i<ETH_ALEN; i++) {
39303 tmp.addr[i] = dev->dev_addr[i];
39304 }
39305 - if (copy_to_user(ioc->data, tmp.addr, ioc->len)) return -EFAULT;
39306 + if (ioc->len > sizeof tmp.addr || copy_to_user(ioc->data, tmp.addr, ioc->len)) return -EFAULT;
39307 break;
39308
39309 case DE4X5_SET_HWADDR: /* Set the hardware address */
39310 @@ -5428,7 +5428,7 @@ de4x5_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
39311 spin_lock_irqsave(&lp->lock, flags);
39312 memcpy(&statbuf, &lp->pktStats, ioc->len);
39313 spin_unlock_irqrestore(&lp->lock, flags);
39314 - if (copy_to_user(ioc->data, &statbuf, ioc->len))
39315 + if (ioc->len > sizeof statbuf || copy_to_user(ioc->data, &statbuf, ioc->len))
39316 return -EFAULT;
39317 break;
39318 }
39319 diff --git a/drivers/net/ethernet/emulex/benet/be_main.c b/drivers/net/ethernet/emulex/benet/be_main.c
39320 index 4d6f3c5..6169e60 100644
39321 --- a/drivers/net/ethernet/emulex/benet/be_main.c
39322 +++ b/drivers/net/ethernet/emulex/benet/be_main.c
39323 @@ -455,7 +455,7 @@ static void accumulate_16bit_val(u32 *acc, u16 val)
39324
39325 if (wrapped)
39326 newacc += 65536;
39327 - ACCESS_ONCE(*acc) = newacc;
39328 + ACCESS_ONCE_RW(*acc) = newacc;
39329 }
39330
39331 void be_parse_stats(struct be_adapter *adapter)
39332 diff --git a/drivers/net/ethernet/faraday/ftgmac100.c b/drivers/net/ethernet/faraday/ftgmac100.c
39333 index 74d749e..eefb1bd 100644
39334 --- a/drivers/net/ethernet/faraday/ftgmac100.c
39335 +++ b/drivers/net/ethernet/faraday/ftgmac100.c
39336 @@ -31,6 +31,8 @@
39337 #include <linux/netdevice.h>
39338 #include <linux/phy.h>
39339 #include <linux/platform_device.h>
39340 +#include <linux/interrupt.h>
39341 +#include <linux/irqreturn.h>
39342 #include <net/ip.h>
39343
39344 #include "ftgmac100.h"
39345 diff --git a/drivers/net/ethernet/faraday/ftmac100.c b/drivers/net/ethernet/faraday/ftmac100.c
39346 index b901a01..1ff32ee 100644
39347 --- a/drivers/net/ethernet/faraday/ftmac100.c
39348 +++ b/drivers/net/ethernet/faraday/ftmac100.c
39349 @@ -31,6 +31,8 @@
39350 #include <linux/module.h>
39351 #include <linux/netdevice.h>
39352 #include <linux/platform_device.h>
39353 +#include <linux/interrupt.h>
39354 +#include <linux/irqreturn.h>
39355
39356 #include "ftmac100.h"
39357
39358 diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
39359 index bb9256a..56d8752 100644
39360 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
39361 +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
39362 @@ -806,7 +806,7 @@ void ixgbe_ptp_start_cyclecounter(struct ixgbe_adapter *adapter)
39363 }
39364
39365 /* update the base incval used to calculate frequency adjustment */
39366 - ACCESS_ONCE(adapter->base_incval) = incval;
39367 + ACCESS_ONCE_RW(adapter->base_incval) = incval;
39368 smp_mb();
39369
39370 /* need lock to prevent incorrect read while modifying cyclecounter */
39371 diff --git a/drivers/net/ethernet/neterion/vxge/vxge-config.c b/drivers/net/ethernet/neterion/vxge/vxge-config.c
39372 index fbe5363..266b4e3 100644
39373 --- a/drivers/net/ethernet/neterion/vxge/vxge-config.c
39374 +++ b/drivers/net/ethernet/neterion/vxge/vxge-config.c
39375 @@ -3461,7 +3461,10 @@ __vxge_hw_fifo_create(struct __vxge_hw_vpath_handle *vp,
39376 struct __vxge_hw_fifo *fifo;
39377 struct vxge_hw_fifo_config *config;
39378 u32 txdl_size, txdl_per_memblock;
39379 - struct vxge_hw_mempool_cbs fifo_mp_callback;
39380 + static struct vxge_hw_mempool_cbs fifo_mp_callback = {
39381 + .item_func_alloc = __vxge_hw_fifo_mempool_item_alloc,
39382 + };
39383 +
39384 struct __vxge_hw_virtualpath *vpath;
39385
39386 if ((vp == NULL) || (attr == NULL)) {
39387 @@ -3544,8 +3547,6 @@ __vxge_hw_fifo_create(struct __vxge_hw_vpath_handle *vp,
39388 goto exit;
39389 }
39390
39391 - fifo_mp_callback.item_func_alloc = __vxge_hw_fifo_mempool_item_alloc;
39392 -
39393 fifo->mempool =
39394 __vxge_hw_mempool_create(vpath->hldev,
39395 fifo->config->memblock_size,
39396 diff --git a/drivers/net/ethernet/realtek/r8169.c b/drivers/net/ethernet/realtek/r8169.c
39397 index 998974f..ecd26db 100644
39398 --- a/drivers/net/ethernet/realtek/r8169.c
39399 +++ b/drivers/net/ethernet/realtek/r8169.c
39400 @@ -741,22 +741,22 @@ struct rtl8169_private {
39401 struct mdio_ops {
39402 void (*write)(struct rtl8169_private *, int, int);
39403 int (*read)(struct rtl8169_private *, int);
39404 - } mdio_ops;
39405 + } __no_const mdio_ops;
39406
39407 struct pll_power_ops {
39408 void (*down)(struct rtl8169_private *);
39409 void (*up)(struct rtl8169_private *);
39410 - } pll_power_ops;
39411 + } __no_const pll_power_ops;
39412
39413 struct jumbo_ops {
39414 void (*enable)(struct rtl8169_private *);
39415 void (*disable)(struct rtl8169_private *);
39416 - } jumbo_ops;
39417 + } __no_const jumbo_ops;
39418
39419 struct csi_ops {
39420 void (*write)(struct rtl8169_private *, int, int);
39421 u32 (*read)(struct rtl8169_private *, int);
39422 - } csi_ops;
39423 + } __no_const csi_ops;
39424
39425 int (*set_speed)(struct net_device *, u8 aneg, u16 sp, u8 dpx, u32 adv);
39426 int (*get_settings)(struct net_device *, struct ethtool_cmd *);
39427 diff --git a/drivers/net/ethernet/sfc/ptp.c b/drivers/net/ethernet/sfc/ptp.c
39428 index 0767043f..08c2553 100644
39429 --- a/drivers/net/ethernet/sfc/ptp.c
39430 +++ b/drivers/net/ethernet/sfc/ptp.c
39431 @@ -553,7 +553,7 @@ static int efx_ptp_synchronize(struct efx_nic *efx, unsigned int num_readings)
39432 (u32)((u64)ptp->start.dma_addr >> 32));
39433
39434 /* Clear flag that signals MC ready */
39435 - ACCESS_ONCE(*start) = 0;
39436 + ACCESS_ONCE_RW(*start) = 0;
39437 efx_mcdi_rpc_start(efx, MC_CMD_PTP, synch_buf,
39438 MC_CMD_PTP_IN_SYNCHRONIZE_LEN);
39439
39440 diff --git a/drivers/net/ethernet/stmicro/stmmac/mmc_core.c b/drivers/net/ethernet/stmicro/stmmac/mmc_core.c
39441 index 0c74a70..3bc6f68 100644
39442 --- a/drivers/net/ethernet/stmicro/stmmac/mmc_core.c
39443 +++ b/drivers/net/ethernet/stmicro/stmmac/mmc_core.c
39444 @@ -140,8 +140,8 @@ void dwmac_mmc_ctrl(void __iomem *ioaddr, unsigned int mode)
39445
39446 writel(value, ioaddr + MMC_CNTRL);
39447
39448 - pr_debug("stmmac: MMC ctrl register (offset 0x%x): 0x%08x\n",
39449 - MMC_CNTRL, value);
39450 +// pr_debug("stmmac: MMC ctrl register (offset 0x%x): 0x%08x\n",
39451 +// MMC_CNTRL, value);
39452 }
39453
39454 /* To mask all all interrupts.*/
39455 diff --git a/drivers/net/hyperv/hyperv_net.h b/drivers/net/hyperv/hyperv_net.h
39456 index e6fe0d8..2b7d752 100644
39457 --- a/drivers/net/hyperv/hyperv_net.h
39458 +++ b/drivers/net/hyperv/hyperv_net.h
39459 @@ -101,7 +101,7 @@ struct rndis_device {
39460
39461 enum rndis_device_state state;
39462 bool link_state;
39463 - atomic_t new_req_id;
39464 + atomic_unchecked_t new_req_id;
39465
39466 spinlock_t request_lock;
39467 struct list_head req_list;
39468 diff --git a/drivers/net/hyperv/rndis_filter.c b/drivers/net/hyperv/rndis_filter.c
39469 index 2b657d4..9903bc0 100644
39470 --- a/drivers/net/hyperv/rndis_filter.c
39471 +++ b/drivers/net/hyperv/rndis_filter.c
39472 @@ -107,7 +107,7 @@ static struct rndis_request *get_rndis_request(struct rndis_device *dev,
39473 * template
39474 */
39475 set = &rndis_msg->msg.set_req;
39476 - set->req_id = atomic_inc_return(&dev->new_req_id);
39477 + set->req_id = atomic_inc_return_unchecked(&dev->new_req_id);
39478
39479 /* Add to the request list */
39480 spin_lock_irqsave(&dev->request_lock, flags);
39481 @@ -758,7 +758,7 @@ static void rndis_filter_halt_device(struct rndis_device *dev)
39482
39483 /* Setup the rndis set */
39484 halt = &request->request_msg.msg.halt_req;
39485 - halt->req_id = atomic_inc_return(&dev->new_req_id);
39486 + halt->req_id = atomic_inc_return_unchecked(&dev->new_req_id);
39487
39488 /* Ignore return since this msg is optional. */
39489 rndis_filter_send_request(dev, request);
39490 diff --git a/drivers/net/ieee802154/fakehard.c b/drivers/net/ieee802154/fakehard.c
39491 index 1e9cb0b..7839125 100644
39492 --- a/drivers/net/ieee802154/fakehard.c
39493 +++ b/drivers/net/ieee802154/fakehard.c
39494 @@ -386,7 +386,7 @@ static int ieee802154fake_probe(struct platform_device *pdev)
39495 phy->transmit_power = 0xbf;
39496
39497 dev->netdev_ops = &fake_ops;
39498 - dev->ml_priv = &fake_mlme;
39499 + dev->ml_priv = (void *)&fake_mlme;
39500
39501 priv = netdev_priv(dev);
39502 priv->phy = phy;
39503 diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c
39504 index e5cb723..1fc0461 100644
39505 --- a/drivers/net/macvlan.c
39506 +++ b/drivers/net/macvlan.c
39507 @@ -852,13 +852,15 @@ static const struct nla_policy macvlan_policy[IFLA_MACVLAN_MAX + 1] = {
39508 int macvlan_link_register(struct rtnl_link_ops *ops)
39509 {
39510 /* common fields */
39511 - ops->priv_size = sizeof(struct macvlan_dev);
39512 - ops->validate = macvlan_validate;
39513 - ops->maxtype = IFLA_MACVLAN_MAX;
39514 - ops->policy = macvlan_policy;
39515 - ops->changelink = macvlan_changelink;
39516 - ops->get_size = macvlan_get_size;
39517 - ops->fill_info = macvlan_fill_info;
39518 + pax_open_kernel();
39519 + *(size_t *)&ops->priv_size = sizeof(struct macvlan_dev);
39520 + *(void **)&ops->validate = macvlan_validate;
39521 + *(int *)&ops->maxtype = IFLA_MACVLAN_MAX;
39522 + *(const void **)&ops->policy = macvlan_policy;
39523 + *(void **)&ops->changelink = macvlan_changelink;
39524 + *(void **)&ops->get_size = macvlan_get_size;
39525 + *(void **)&ops->fill_info = macvlan_fill_info;
39526 + pax_close_kernel();
39527
39528 return rtnl_link_register(ops);
39529 };
39530 @@ -914,7 +916,7 @@ static int macvlan_device_event(struct notifier_block *unused,
39531 return NOTIFY_DONE;
39532 }
39533
39534 -static struct notifier_block macvlan_notifier_block __read_mostly = {
39535 +static struct notifier_block macvlan_notifier_block = {
39536 .notifier_call = macvlan_device_event,
39537 };
39538
39539 diff --git a/drivers/net/macvtap.c b/drivers/net/macvtap.c
39540 index 0f0f9ce..0ca5819 100644
39541 --- a/drivers/net/macvtap.c
39542 +++ b/drivers/net/macvtap.c
39543 @@ -1100,7 +1100,7 @@ static int macvtap_device_event(struct notifier_block *unused,
39544 return NOTIFY_DONE;
39545 }
39546
39547 -static struct notifier_block macvtap_notifier_block __read_mostly = {
39548 +static struct notifier_block macvtap_notifier_block = {
39549 .notifier_call = macvtap_device_event,
39550 };
39551
39552 diff --git a/drivers/net/phy/mdio-bitbang.c b/drivers/net/phy/mdio-bitbang.c
39553 index daec9b0..6428fcb 100644
39554 --- a/drivers/net/phy/mdio-bitbang.c
39555 +++ b/drivers/net/phy/mdio-bitbang.c
39556 @@ -234,6 +234,7 @@ void free_mdio_bitbang(struct mii_bus *bus)
39557 struct mdiobb_ctrl *ctrl = bus->priv;
39558
39559 module_put(ctrl->ops->owner);
39560 + mdiobus_unregister(bus);
39561 mdiobus_free(bus);
39562 }
39563 EXPORT_SYMBOL(free_mdio_bitbang);
39564 diff --git a/drivers/net/ppp/ppp_generic.c b/drivers/net/ppp/ppp_generic.c
39565 index 508570e..f706dc7 100644
39566 --- a/drivers/net/ppp/ppp_generic.c
39567 +++ b/drivers/net/ppp/ppp_generic.c
39568 @@ -999,7 +999,6 @@ ppp_net_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
39569 void __user *addr = (void __user *) ifr->ifr_ifru.ifru_data;
39570 struct ppp_stats stats;
39571 struct ppp_comp_stats cstats;
39572 - char *vers;
39573
39574 switch (cmd) {
39575 case SIOCGPPPSTATS:
39576 @@ -1021,8 +1020,7 @@ ppp_net_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
39577 break;
39578
39579 case SIOCGPPPVER:
39580 - vers = PPP_VERSION;
39581 - if (copy_to_user(addr, vers, strlen(vers) + 1))
39582 + if (copy_to_user(addr, PPP_VERSION, sizeof(PPP_VERSION)))
39583 break;
39584 err = 0;
39585 break;
39586 diff --git a/drivers/net/team/team.c b/drivers/net/team/team.c
39587 index 8efe47a..a8075c5 100644
39588 --- a/drivers/net/team/team.c
39589 +++ b/drivers/net/team/team.c
39590 @@ -2603,7 +2603,7 @@ static int team_device_event(struct notifier_block *unused,
39591 return NOTIFY_DONE;
39592 }
39593
39594 -static struct notifier_block team_notifier_block __read_mostly = {
39595 +static struct notifier_block team_notifier_block = {
39596 .notifier_call = team_device_event,
39597 };
39598
39599 diff --git a/drivers/net/tun.c b/drivers/net/tun.c
39600 index cb95fe5..a5bdab5 100644
39601 --- a/drivers/net/tun.c
39602 +++ b/drivers/net/tun.c
39603 @@ -1838,7 +1838,7 @@ unlock:
39604 }
39605
39606 static long __tun_chr_ioctl(struct file *file, unsigned int cmd,
39607 - unsigned long arg, int ifreq_len)
39608 + unsigned long arg, size_t ifreq_len)
39609 {
39610 struct tun_file *tfile = file->private_data;
39611 struct tun_struct *tun;
39612 @@ -1850,6 +1850,9 @@ static long __tun_chr_ioctl(struct file *file, unsigned int cmd,
39613 int vnet_hdr_sz;
39614 int ret;
39615
39616 + if (ifreq_len > sizeof ifr)
39617 + return -EFAULT;
39618 +
39619 if (cmd == TUNSETIFF || cmd == TUNSETQUEUE || _IOC_TYPE(cmd) == 0x89) {
39620 if (copy_from_user(&ifr, argp, ifreq_len))
39621 return -EFAULT;
39622 diff --git a/drivers/net/usb/hso.c b/drivers/net/usb/hso.c
39623 index cd8ccb2..cff5144 100644
39624 --- a/drivers/net/usb/hso.c
39625 +++ b/drivers/net/usb/hso.c
39626 @@ -71,7 +71,7 @@
39627 #include <asm/byteorder.h>
39628 #include <linux/serial_core.h>
39629 #include <linux/serial.h>
39630 -
39631 +#include <asm/local.h>
39632
39633 #define MOD_AUTHOR "Option Wireless"
39634 #define MOD_DESCRIPTION "USB High Speed Option driver"
39635 @@ -1180,7 +1180,7 @@ static void put_rxbuf_data_and_resubmit_ctrl_urb(struct hso_serial *serial)
39636 struct urb *urb;
39637
39638 urb = serial->rx_urb[0];
39639 - if (serial->port.count > 0) {
39640 + if (atomic_read(&serial->port.count) > 0) {
39641 count = put_rxbuf_data(urb, serial);
39642 if (count == -1)
39643 return;
39644 @@ -1216,7 +1216,7 @@ static void hso_std_serial_read_bulk_callback(struct urb *urb)
39645 DUMP1(urb->transfer_buffer, urb->actual_length);
39646
39647 /* Anyone listening? */
39648 - if (serial->port.count == 0)
39649 + if (atomic_read(&serial->port.count) == 0)
39650 return;
39651
39652 if (status == 0) {
39653 @@ -1298,8 +1298,7 @@ static int hso_serial_open(struct tty_struct *tty, struct file *filp)
39654 tty_port_tty_set(&serial->port, tty);
39655
39656 /* check for port already opened, if not set the termios */
39657 - serial->port.count++;
39658 - if (serial->port.count == 1) {
39659 + if (atomic_inc_return(&serial->port.count) == 1) {
39660 serial->rx_state = RX_IDLE;
39661 /* Force default termio settings */
39662 _hso_serial_set_termios(tty, NULL);
39663 @@ -1311,7 +1310,7 @@ static int hso_serial_open(struct tty_struct *tty, struct file *filp)
39664 result = hso_start_serial_device(serial->parent, GFP_KERNEL);
39665 if (result) {
39666 hso_stop_serial_device(serial->parent);
39667 - serial->port.count--;
39668 + atomic_dec(&serial->port.count);
39669 kref_put(&serial->parent->ref, hso_serial_ref_free);
39670 }
39671 } else {
39672 @@ -1348,10 +1347,10 @@ static void hso_serial_close(struct tty_struct *tty, struct file *filp)
39673
39674 /* reset the rts and dtr */
39675 /* do the actual close */
39676 - serial->port.count--;
39677 + atomic_dec(&serial->port.count);
39678
39679 - if (serial->port.count <= 0) {
39680 - serial->port.count = 0;
39681 + if (atomic_read(&serial->port.count) <= 0) {
39682 + atomic_set(&serial->port.count, 0);
39683 tty_port_tty_set(&serial->port, NULL);
39684 if (!usb_gone)
39685 hso_stop_serial_device(serial->parent);
39686 @@ -1427,7 +1426,7 @@ static void hso_serial_set_termios(struct tty_struct *tty, struct ktermios *old)
39687
39688 /* the actual setup */
39689 spin_lock_irqsave(&serial->serial_lock, flags);
39690 - if (serial->port.count)
39691 + if (atomic_read(&serial->port.count))
39692 _hso_serial_set_termios(tty, old);
39693 else
39694 tty->termios = *old;
39695 @@ -1886,7 +1885,7 @@ static void intr_callback(struct urb *urb)
39696 D1("Pending read interrupt on port %d\n", i);
39697 spin_lock(&serial->serial_lock);
39698 if (serial->rx_state == RX_IDLE &&
39699 - serial->port.count > 0) {
39700 + atomic_read(&serial->port.count) > 0) {
39701 /* Setup and send a ctrl req read on
39702 * port i */
39703 if (!serial->rx_urb_filled[0]) {
39704 @@ -3079,7 +3078,7 @@ static int hso_resume(struct usb_interface *iface)
39705 /* Start all serial ports */
39706 for (i = 0; i < HSO_SERIAL_TTY_MINORS; i++) {
39707 if (serial_table[i] && (serial_table[i]->interface == iface)) {
39708 - if (dev2ser(serial_table[i])->port.count) {
39709 + if (atomic_read(&dev2ser(serial_table[i])->port.count)) {
39710 result =
39711 hso_start_serial_device(serial_table[i], GFP_NOIO);
39712 hso_kick_transmit(dev2ser(serial_table[i]));
39713 diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c
39714 index 6993bfa..9053a34 100644
39715 --- a/drivers/net/vxlan.c
39716 +++ b/drivers/net/vxlan.c
39717 @@ -1428,7 +1428,7 @@ nla_put_failure:
39718 return -EMSGSIZE;
39719 }
39720
39721 -static struct rtnl_link_ops vxlan_link_ops __read_mostly = {
39722 +static struct rtnl_link_ops vxlan_link_ops = {
39723 .kind = "vxlan",
39724 .maxtype = IFLA_VXLAN_MAX,
39725 .policy = vxlan_policy,
39726 diff --git a/drivers/net/wireless/at76c50x-usb.c b/drivers/net/wireless/at76c50x-usb.c
39727 index 77fa428..996b355 100644
39728 --- a/drivers/net/wireless/at76c50x-usb.c
39729 +++ b/drivers/net/wireless/at76c50x-usb.c
39730 @@ -353,7 +353,7 @@ static int at76_dfu_get_state(struct usb_device *udev, u8 *state)
39731 }
39732
39733 /* Convert timeout from the DFU status to jiffies */
39734 -static inline unsigned long at76_get_timeout(struct dfu_status *s)
39735 +static inline unsigned long __intentional_overflow(-1) at76_get_timeout(struct dfu_status *s)
39736 {
39737 return msecs_to_jiffies((s->poll_timeout[2] << 16)
39738 | (s->poll_timeout[1] << 8)
39739 diff --git a/drivers/net/wireless/ath/ath9k/ar9002_mac.c b/drivers/net/wireless/ath/ath9k/ar9002_mac.c
39740 index 8d78253..bebbb68 100644
39741 --- a/drivers/net/wireless/ath/ath9k/ar9002_mac.c
39742 +++ b/drivers/net/wireless/ath/ath9k/ar9002_mac.c
39743 @@ -184,8 +184,8 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
39744 ads->ds_txstatus6 = ads->ds_txstatus7 = 0;
39745 ads->ds_txstatus8 = ads->ds_txstatus9 = 0;
39746
39747 - ACCESS_ONCE(ads->ds_link) = i->link;
39748 - ACCESS_ONCE(ads->ds_data) = i->buf_addr[0];
39749 + ACCESS_ONCE_RW(ads->ds_link) = i->link;
39750 + ACCESS_ONCE_RW(ads->ds_data) = i->buf_addr[0];
39751
39752 ctl1 = i->buf_len[0] | (i->is_last ? 0 : AR_TxMore);
39753 ctl6 = SM(i->keytype, AR_EncrType);
39754 @@ -199,26 +199,26 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
39755
39756 if ((i->is_first || i->is_last) &&
39757 i->aggr != AGGR_BUF_MIDDLE && i->aggr != AGGR_BUF_LAST) {
39758 - ACCESS_ONCE(ads->ds_ctl2) = set11nTries(i->rates, 0)
39759 + ACCESS_ONCE_RW(ads->ds_ctl2) = set11nTries(i->rates, 0)
39760 | set11nTries(i->rates, 1)
39761 | set11nTries(i->rates, 2)
39762 | set11nTries(i->rates, 3)
39763 | (i->dur_update ? AR_DurUpdateEna : 0)
39764 | SM(0, AR_BurstDur);
39765
39766 - ACCESS_ONCE(ads->ds_ctl3) = set11nRate(i->rates, 0)
39767 + ACCESS_ONCE_RW(ads->ds_ctl3) = set11nRate(i->rates, 0)
39768 | set11nRate(i->rates, 1)
39769 | set11nRate(i->rates, 2)
39770 | set11nRate(i->rates, 3);
39771 } else {
39772 - ACCESS_ONCE(ads->ds_ctl2) = 0;
39773 - ACCESS_ONCE(ads->ds_ctl3) = 0;
39774 + ACCESS_ONCE_RW(ads->ds_ctl2) = 0;
39775 + ACCESS_ONCE_RW(ads->ds_ctl3) = 0;
39776 }
39777
39778 if (!i->is_first) {
39779 - ACCESS_ONCE(ads->ds_ctl0) = 0;
39780 - ACCESS_ONCE(ads->ds_ctl1) = ctl1;
39781 - ACCESS_ONCE(ads->ds_ctl6) = ctl6;
39782 + ACCESS_ONCE_RW(ads->ds_ctl0) = 0;
39783 + ACCESS_ONCE_RW(ads->ds_ctl1) = ctl1;
39784 + ACCESS_ONCE_RW(ads->ds_ctl6) = ctl6;
39785 return;
39786 }
39787
39788 @@ -243,7 +243,7 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
39789 break;
39790 }
39791
39792 - ACCESS_ONCE(ads->ds_ctl0) = (i->pkt_len & AR_FrameLen)
39793 + ACCESS_ONCE_RW(ads->ds_ctl0) = (i->pkt_len & AR_FrameLen)
39794 | (i->flags & ATH9K_TXDESC_VMF ? AR_VirtMoreFrag : 0)
39795 | SM(i->txpower, AR_XmitPower)
39796 | (i->flags & ATH9K_TXDESC_VEOL ? AR_VEOL : 0)
39797 @@ -253,19 +253,19 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
39798 | (i->flags & ATH9K_TXDESC_RTSENA ? AR_RTSEnable :
39799 (i->flags & ATH9K_TXDESC_CTSENA ? AR_CTSEnable : 0));
39800
39801 - ACCESS_ONCE(ads->ds_ctl1) = ctl1;
39802 - ACCESS_ONCE(ads->ds_ctl6) = ctl6;
39803 + ACCESS_ONCE_RW(ads->ds_ctl1) = ctl1;
39804 + ACCESS_ONCE_RW(ads->ds_ctl6) = ctl6;
39805
39806 if (i->aggr == AGGR_BUF_MIDDLE || i->aggr == AGGR_BUF_LAST)
39807 return;
39808
39809 - ACCESS_ONCE(ads->ds_ctl4) = set11nPktDurRTSCTS(i->rates, 0)
39810 + ACCESS_ONCE_RW(ads->ds_ctl4) = set11nPktDurRTSCTS(i->rates, 0)
39811 | set11nPktDurRTSCTS(i->rates, 1);
39812
39813 - ACCESS_ONCE(ads->ds_ctl5) = set11nPktDurRTSCTS(i->rates, 2)
39814 + ACCESS_ONCE_RW(ads->ds_ctl5) = set11nPktDurRTSCTS(i->rates, 2)
39815 | set11nPktDurRTSCTS(i->rates, 3);
39816
39817 - ACCESS_ONCE(ads->ds_ctl7) = set11nRateFlags(i->rates, 0)
39818 + ACCESS_ONCE_RW(ads->ds_ctl7) = set11nRateFlags(i->rates, 0)
39819 | set11nRateFlags(i->rates, 1)
39820 | set11nRateFlags(i->rates, 2)
39821 | set11nRateFlags(i->rates, 3)
39822 diff --git a/drivers/net/wireless/ath/ath9k/ar9003_mac.c b/drivers/net/wireless/ath/ath9k/ar9003_mac.c
39823 index 301bf72..3f5654f 100644
39824 --- a/drivers/net/wireless/ath/ath9k/ar9003_mac.c
39825 +++ b/drivers/net/wireless/ath/ath9k/ar9003_mac.c
39826 @@ -39,47 +39,47 @@ ar9003_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
39827 (i->qcu << AR_TxQcuNum_S) | desc_len;
39828
39829 checksum += val;
39830 - ACCESS_ONCE(ads->info) = val;
39831 + ACCESS_ONCE_RW(ads->info) = val;
39832
39833 checksum += i->link;
39834 - ACCESS_ONCE(ads->link) = i->link;
39835 + ACCESS_ONCE_RW(ads->link) = i->link;
39836
39837 checksum += i->buf_addr[0];
39838 - ACCESS_ONCE(ads->data0) = i->buf_addr[0];
39839 + ACCESS_ONCE_RW(ads->data0) = i->buf_addr[0];
39840 checksum += i->buf_addr[1];
39841 - ACCESS_ONCE(ads->data1) = i->buf_addr[1];
39842 + ACCESS_ONCE_RW(ads->data1) = i->buf_addr[1];
39843 checksum += i->buf_addr[2];
39844 - ACCESS_ONCE(ads->data2) = i->buf_addr[2];
39845 + ACCESS_ONCE_RW(ads->data2) = i->buf_addr[2];
39846 checksum += i->buf_addr[3];
39847 - ACCESS_ONCE(ads->data3) = i->buf_addr[3];
39848 + ACCESS_ONCE_RW(ads->data3) = i->buf_addr[3];
39849
39850 checksum += (val = (i->buf_len[0] << AR_BufLen_S) & AR_BufLen);
39851 - ACCESS_ONCE(ads->ctl3) = val;
39852 + ACCESS_ONCE_RW(ads->ctl3) = val;
39853 checksum += (val = (i->buf_len[1] << AR_BufLen_S) & AR_BufLen);
39854 - ACCESS_ONCE(ads->ctl5) = val;
39855 + ACCESS_ONCE_RW(ads->ctl5) = val;
39856 checksum += (val = (i->buf_len[2] << AR_BufLen_S) & AR_BufLen);
39857 - ACCESS_ONCE(ads->ctl7) = val;
39858 + ACCESS_ONCE_RW(ads->ctl7) = val;
39859 checksum += (val = (i->buf_len[3] << AR_BufLen_S) & AR_BufLen);
39860 - ACCESS_ONCE(ads->ctl9) = val;
39861 + ACCESS_ONCE_RW(ads->ctl9) = val;
39862
39863 checksum = (u16) (((checksum & 0xffff) + (checksum >> 16)) & 0xffff);
39864 - ACCESS_ONCE(ads->ctl10) = checksum;
39865 + ACCESS_ONCE_RW(ads->ctl10) = checksum;
39866
39867 if (i->is_first || i->is_last) {
39868 - ACCESS_ONCE(ads->ctl13) = set11nTries(i->rates, 0)
39869 + ACCESS_ONCE_RW(ads->ctl13) = set11nTries(i->rates, 0)
39870 | set11nTries(i->rates, 1)
39871 | set11nTries(i->rates, 2)
39872 | set11nTries(i->rates, 3)
39873 | (i->dur_update ? AR_DurUpdateEna : 0)
39874 | SM(0, AR_BurstDur);
39875
39876 - ACCESS_ONCE(ads->ctl14) = set11nRate(i->rates, 0)
39877 + ACCESS_ONCE_RW(ads->ctl14) = set11nRate(i->rates, 0)
39878 | set11nRate(i->rates, 1)
39879 | set11nRate(i->rates, 2)
39880 | set11nRate(i->rates, 3);
39881 } else {
39882 - ACCESS_ONCE(ads->ctl13) = 0;
39883 - ACCESS_ONCE(ads->ctl14) = 0;
39884 + ACCESS_ONCE_RW(ads->ctl13) = 0;
39885 + ACCESS_ONCE_RW(ads->ctl14) = 0;
39886 }
39887
39888 ads->ctl20 = 0;
39889 @@ -89,17 +89,17 @@ ar9003_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
39890
39891 ctl17 = SM(i->keytype, AR_EncrType);
39892 if (!i->is_first) {
39893 - ACCESS_ONCE(ads->ctl11) = 0;
39894 - ACCESS_ONCE(ads->ctl12) = i->is_last ? 0 : AR_TxMore;
39895 - ACCESS_ONCE(ads->ctl15) = 0;
39896 - ACCESS_ONCE(ads->ctl16) = 0;
39897 - ACCESS_ONCE(ads->ctl17) = ctl17;
39898 - ACCESS_ONCE(ads->ctl18) = 0;
39899 - ACCESS_ONCE(ads->ctl19) = 0;
39900 + ACCESS_ONCE_RW(ads->ctl11) = 0;
39901 + ACCESS_ONCE_RW(ads->ctl12) = i->is_last ? 0 : AR_TxMore;
39902 + ACCESS_ONCE_RW(ads->ctl15) = 0;
39903 + ACCESS_ONCE_RW(ads->ctl16) = 0;
39904 + ACCESS_ONCE_RW(ads->ctl17) = ctl17;
39905 + ACCESS_ONCE_RW(ads->ctl18) = 0;
39906 + ACCESS_ONCE_RW(ads->ctl19) = 0;
39907 return;
39908 }
39909
39910 - ACCESS_ONCE(ads->ctl11) = (i->pkt_len & AR_FrameLen)
39911 + ACCESS_ONCE_RW(ads->ctl11) = (i->pkt_len & AR_FrameLen)
39912 | (i->flags & ATH9K_TXDESC_VMF ? AR_VirtMoreFrag : 0)
39913 | SM(i->txpower, AR_XmitPower)
39914 | (i->flags & ATH9K_TXDESC_VEOL ? AR_VEOL : 0)
39915 @@ -135,22 +135,22 @@ ar9003_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
39916 val = (i->flags & ATH9K_TXDESC_PAPRD) >> ATH9K_TXDESC_PAPRD_S;
39917 ctl12 |= SM(val, AR_PAPRDChainMask);
39918
39919 - ACCESS_ONCE(ads->ctl12) = ctl12;
39920 - ACCESS_ONCE(ads->ctl17) = ctl17;
39921 + ACCESS_ONCE_RW(ads->ctl12) = ctl12;
39922 + ACCESS_ONCE_RW(ads->ctl17) = ctl17;
39923
39924 - ACCESS_ONCE(ads->ctl15) = set11nPktDurRTSCTS(i->rates, 0)
39925 + ACCESS_ONCE_RW(ads->ctl15) = set11nPktDurRTSCTS(i->rates, 0)
39926 | set11nPktDurRTSCTS(i->rates, 1);
39927
39928 - ACCESS_ONCE(ads->ctl16) = set11nPktDurRTSCTS(i->rates, 2)
39929 + ACCESS_ONCE_RW(ads->ctl16) = set11nPktDurRTSCTS(i->rates, 2)
39930 | set11nPktDurRTSCTS(i->rates, 3);
39931
39932 - ACCESS_ONCE(ads->ctl18) = set11nRateFlags(i->rates, 0)
39933 + ACCESS_ONCE_RW(ads->ctl18) = set11nRateFlags(i->rates, 0)
39934 | set11nRateFlags(i->rates, 1)
39935 | set11nRateFlags(i->rates, 2)
39936 | set11nRateFlags(i->rates, 3)
39937 | SM(i->rtscts_rate, AR_RTSCTSRate);
39938
39939 - ACCESS_ONCE(ads->ctl19) = AR_Not_Sounding;
39940 + ACCESS_ONCE_RW(ads->ctl19) = AR_Not_Sounding;
39941 }
39942
39943 static u16 ar9003_calc_ptr_chksum(struct ar9003_txc *ads)
39944 diff --git a/drivers/net/wireless/ath/ath9k/hw.h b/drivers/net/wireless/ath/ath9k/hw.h
39945 index 9d26fc5..60d9f14 100644
39946 --- a/drivers/net/wireless/ath/ath9k/hw.h
39947 +++ b/drivers/net/wireless/ath/ath9k/hw.h
39948 @@ -658,7 +658,7 @@ struct ath_hw_private_ops {
39949
39950 /* ANI */
39951 void (*ani_cache_ini_regs)(struct ath_hw *ah);
39952 -};
39953 +} __no_const;
39954
39955 /**
39956 * struct ath_hw_ops - callbacks used by hardware code and driver code
39957 @@ -688,7 +688,7 @@ struct ath_hw_ops {
39958 void (*antdiv_comb_conf_set)(struct ath_hw *ah,
39959 struct ath_hw_antcomb_conf *antconf);
39960 void (*antctrl_shared_chain_lnadiv)(struct ath_hw *hw, bool enable);
39961 -};
39962 +} __no_const;
39963
39964 struct ath_nf_limits {
39965 s16 max;
39966 diff --git a/drivers/net/wireless/iwlegacy/3945-mac.c b/drivers/net/wireless/iwlegacy/3945-mac.c
39967 index 3726cd6..b655808 100644
39968 --- a/drivers/net/wireless/iwlegacy/3945-mac.c
39969 +++ b/drivers/net/wireless/iwlegacy/3945-mac.c
39970 @@ -3615,7 +3615,9 @@ il3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
39971 */
39972 if (il3945_mod_params.disable_hw_scan) {
39973 D_INFO("Disabling hw_scan\n");
39974 - il3945_mac_ops.hw_scan = NULL;
39975 + pax_open_kernel();
39976 + *(void **)&il3945_mac_ops.hw_scan = NULL;
39977 + pax_close_kernel();
39978 }
39979
39980 D_INFO("*** LOAD DRIVER ***\n");
39981 diff --git a/drivers/net/wireless/iwlwifi/dvm/debugfs.c b/drivers/net/wireless/iwlwifi/dvm/debugfs.c
39982 index 5b9533e..7733880 100644
39983 --- a/drivers/net/wireless/iwlwifi/dvm/debugfs.c
39984 +++ b/drivers/net/wireless/iwlwifi/dvm/debugfs.c
39985 @@ -203,7 +203,7 @@ static ssize_t iwl_dbgfs_sram_write(struct file *file,
39986 {
39987 struct iwl_priv *priv = file->private_data;
39988 char buf[64];
39989 - int buf_size;
39990 + size_t buf_size;
39991 u32 offset, len;
39992
39993 memset(buf, 0, sizeof(buf));
39994 @@ -473,7 +473,7 @@ static ssize_t iwl_dbgfs_rx_handlers_write(struct file *file,
39995 struct iwl_priv *priv = file->private_data;
39996
39997 char buf[8];
39998 - int buf_size;
39999 + size_t buf_size;
40000 u32 reset_flag;
40001
40002 memset(buf, 0, sizeof(buf));
40003 @@ -554,7 +554,7 @@ static ssize_t iwl_dbgfs_disable_ht40_write(struct file *file,
40004 {
40005 struct iwl_priv *priv = file->private_data;
40006 char buf[8];
40007 - int buf_size;
40008 + size_t buf_size;
40009 int ht40;
40010
40011 memset(buf, 0, sizeof(buf));
40012 @@ -606,7 +606,7 @@ static ssize_t iwl_dbgfs_sleep_level_override_write(struct file *file,
40013 {
40014 struct iwl_priv *priv = file->private_data;
40015 char buf[8];
40016 - int buf_size;
40017 + size_t buf_size;
40018 int value;
40019
40020 memset(buf, 0, sizeof(buf));
40021 @@ -1871,7 +1871,7 @@ static ssize_t iwl_dbgfs_clear_ucode_statistics_write(struct file *file,
40022 {
40023 struct iwl_priv *priv = file->private_data;
40024 char buf[8];
40025 - int buf_size;
40026 + size_t buf_size;
40027 int clear;
40028
40029 memset(buf, 0, sizeof(buf));
40030 @@ -1916,7 +1916,7 @@ static ssize_t iwl_dbgfs_ucode_tracing_write(struct file *file,
40031 {
40032 struct iwl_priv *priv = file->private_data;
40033 char buf[8];
40034 - int buf_size;
40035 + size_t buf_size;
40036 int trace;
40037
40038 memset(buf, 0, sizeof(buf));
40039 @@ -1987,7 +1987,7 @@ static ssize_t iwl_dbgfs_missed_beacon_write(struct file *file,
40040 {
40041 struct iwl_priv *priv = file->private_data;
40042 char buf[8];
40043 - int buf_size;
40044 + size_t buf_size;
40045 int missed;
40046
40047 memset(buf, 0, sizeof(buf));
40048 @@ -2028,7 +2028,7 @@ static ssize_t iwl_dbgfs_plcp_delta_write(struct file *file,
40049
40050 struct iwl_priv *priv = file->private_data;
40051 char buf[8];
40052 - int buf_size;
40053 + size_t buf_size;
40054 int plcp;
40055
40056 memset(buf, 0, sizeof(buf));
40057 @@ -2088,7 +2088,7 @@ static ssize_t iwl_dbgfs_txfifo_flush_write(struct file *file,
40058
40059 struct iwl_priv *priv = file->private_data;
40060 char buf[8];
40061 - int buf_size;
40062 + size_t buf_size;
40063 int flush;
40064
40065 memset(buf, 0, sizeof(buf));
40066 @@ -2178,7 +2178,7 @@ static ssize_t iwl_dbgfs_protection_mode_write(struct file *file,
40067
40068 struct iwl_priv *priv = file->private_data;
40069 char buf[8];
40070 - int buf_size;
40071 + size_t buf_size;
40072 int rts;
40073
40074 if (!priv->cfg->ht_params)
40075 @@ -2220,7 +2220,7 @@ static ssize_t iwl_dbgfs_echo_test_write(struct file *file,
40076 {
40077 struct iwl_priv *priv = file->private_data;
40078 char buf[8];
40079 - int buf_size;
40080 + size_t buf_size;
40081
40082 memset(buf, 0, sizeof(buf));
40083 buf_size = min(count, sizeof(buf) - 1);
40084 @@ -2256,7 +2256,7 @@ static ssize_t iwl_dbgfs_log_event_write(struct file *file,
40085 struct iwl_priv *priv = file->private_data;
40086 u32 event_log_flag;
40087 char buf[8];
40088 - int buf_size;
40089 + size_t buf_size;
40090
40091 /* check that the interface is up */
40092 if (!iwl_is_ready(priv))
40093 @@ -2310,7 +2310,7 @@ static ssize_t iwl_dbgfs_calib_disabled_write(struct file *file,
40094 struct iwl_priv *priv = file->private_data;
40095 char buf[8];
40096 u32 calib_disabled;
40097 - int buf_size;
40098 + size_t buf_size;
40099
40100 memset(buf, 0, sizeof(buf));
40101 buf_size = min(count, sizeof(buf) - 1);
40102 diff --git a/drivers/net/wireless/iwlwifi/pcie/trans.c b/drivers/net/wireless/iwlwifi/pcie/trans.c
40103 index 35708b9..31f7754 100644
40104 --- a/drivers/net/wireless/iwlwifi/pcie/trans.c
40105 +++ b/drivers/net/wireless/iwlwifi/pcie/trans.c
40106 @@ -1100,7 +1100,7 @@ static ssize_t iwl_dbgfs_interrupt_write(struct file *file,
40107 struct isr_statistics *isr_stats = &trans_pcie->isr_stats;
40108
40109 char buf[8];
40110 - int buf_size;
40111 + size_t buf_size;
40112 u32 reset_flag;
40113
40114 memset(buf, 0, sizeof(buf));
40115 @@ -1121,7 +1121,7 @@ static ssize_t iwl_dbgfs_csr_write(struct file *file,
40116 {
40117 struct iwl_trans *trans = file->private_data;
40118 char buf[8];
40119 - int buf_size;
40120 + size_t buf_size;
40121 int csr;
40122
40123 memset(buf, 0, sizeof(buf));
40124 diff --git a/drivers/net/wireless/mac80211_hwsim.c b/drivers/net/wireless/mac80211_hwsim.c
40125 index ff90855..e46d223 100644
40126 --- a/drivers/net/wireless/mac80211_hwsim.c
40127 +++ b/drivers/net/wireless/mac80211_hwsim.c
40128 @@ -2062,25 +2062,19 @@ static int __init init_mac80211_hwsim(void)
40129
40130 if (channels > 1) {
40131 hwsim_if_comb.num_different_channels = channels;
40132 - mac80211_hwsim_ops.hw_scan = mac80211_hwsim_hw_scan;
40133 - mac80211_hwsim_ops.cancel_hw_scan =
40134 - mac80211_hwsim_cancel_hw_scan;
40135 - mac80211_hwsim_ops.sw_scan_start = NULL;
40136 - mac80211_hwsim_ops.sw_scan_complete = NULL;
40137 - mac80211_hwsim_ops.remain_on_channel =
40138 - mac80211_hwsim_roc;
40139 - mac80211_hwsim_ops.cancel_remain_on_channel =
40140 - mac80211_hwsim_croc;
40141 - mac80211_hwsim_ops.add_chanctx =
40142 - mac80211_hwsim_add_chanctx;
40143 - mac80211_hwsim_ops.remove_chanctx =
40144 - mac80211_hwsim_remove_chanctx;
40145 - mac80211_hwsim_ops.change_chanctx =
40146 - mac80211_hwsim_change_chanctx;
40147 - mac80211_hwsim_ops.assign_vif_chanctx =
40148 - mac80211_hwsim_assign_vif_chanctx;
40149 - mac80211_hwsim_ops.unassign_vif_chanctx =
40150 - mac80211_hwsim_unassign_vif_chanctx;
40151 + pax_open_kernel();
40152 + *(void **)&mac80211_hwsim_ops.hw_scan = mac80211_hwsim_hw_scan;
40153 + *(void **)&mac80211_hwsim_ops.cancel_hw_scan = mac80211_hwsim_cancel_hw_scan;
40154 + *(void **)&mac80211_hwsim_ops.sw_scan_start = NULL;
40155 + *(void **)&mac80211_hwsim_ops.sw_scan_complete = NULL;
40156 + *(void **)&mac80211_hwsim_ops.remain_on_channel = mac80211_hwsim_roc;
40157 + *(void **)&mac80211_hwsim_ops.cancel_remain_on_channel = mac80211_hwsim_croc;
40158 + *(void **)&mac80211_hwsim_ops.add_chanctx = mac80211_hwsim_add_chanctx;
40159 + *(void **)&mac80211_hwsim_ops.remove_chanctx = mac80211_hwsim_remove_chanctx;
40160 + *(void **)&mac80211_hwsim_ops.change_chanctx = mac80211_hwsim_change_chanctx;
40161 + *(void **)&mac80211_hwsim_ops.assign_vif_chanctx = mac80211_hwsim_assign_vif_chanctx;
40162 + *(void **)&mac80211_hwsim_ops.unassign_vif_chanctx = mac80211_hwsim_unassign_vif_chanctx;
40163 + pax_close_kernel();
40164 }
40165
40166 spin_lock_init(&hwsim_radio_lock);
40167 diff --git a/drivers/net/wireless/rndis_wlan.c b/drivers/net/wireless/rndis_wlan.c
40168 index abe1d03..fb02c22 100644
40169 --- a/drivers/net/wireless/rndis_wlan.c
40170 +++ b/drivers/net/wireless/rndis_wlan.c
40171 @@ -1238,7 +1238,7 @@ static int set_rts_threshold(struct usbnet *usbdev, u32 rts_threshold)
40172
40173 netdev_dbg(usbdev->net, "%s(): %i\n", __func__, rts_threshold);
40174
40175 - if (rts_threshold < 0 || rts_threshold > 2347)
40176 + if (rts_threshold > 2347)
40177 rts_threshold = 2347;
40178
40179 tmp = cpu_to_le32(rts_threshold);
40180 diff --git a/drivers/net/wireless/rt2x00/rt2x00.h b/drivers/net/wireless/rt2x00/rt2x00.h
40181 index 0751b35..246ba3e 100644
40182 --- a/drivers/net/wireless/rt2x00/rt2x00.h
40183 +++ b/drivers/net/wireless/rt2x00/rt2x00.h
40184 @@ -398,7 +398,7 @@ struct rt2x00_intf {
40185 * for hardware which doesn't support hardware
40186 * sequence counting.
40187 */
40188 - atomic_t seqno;
40189 + atomic_unchecked_t seqno;
40190 };
40191
40192 static inline struct rt2x00_intf* vif_to_intf(struct ieee80211_vif *vif)
40193 diff --git a/drivers/net/wireless/rt2x00/rt2x00queue.c b/drivers/net/wireless/rt2x00/rt2x00queue.c
40194 index e488b94..14b6a0c 100644
40195 --- a/drivers/net/wireless/rt2x00/rt2x00queue.c
40196 +++ b/drivers/net/wireless/rt2x00/rt2x00queue.c
40197 @@ -240,9 +240,9 @@ static void rt2x00queue_create_tx_descriptor_seq(struct rt2x00_dev *rt2x00dev,
40198 * sequence counter given by mac80211.
40199 */
40200 if (test_bit(ENTRY_TXD_FIRST_FRAGMENT, &txdesc->flags))
40201 - seqno = atomic_add_return(0x10, &intf->seqno);
40202 + seqno = atomic_add_return_unchecked(0x10, &intf->seqno);
40203 else
40204 - seqno = atomic_read(&intf->seqno);
40205 + seqno = atomic_read_unchecked(&intf->seqno);
40206
40207 hdr->seq_ctrl &= cpu_to_le16(IEEE80211_SCTL_FRAG);
40208 hdr->seq_ctrl |= cpu_to_le16(seqno);
40209 diff --git a/drivers/net/wireless/ti/wl1251/sdio.c b/drivers/net/wireless/ti/wl1251/sdio.c
40210 index e57ee48..541cf6c 100644
40211 --- a/drivers/net/wireless/ti/wl1251/sdio.c
40212 +++ b/drivers/net/wireless/ti/wl1251/sdio.c
40213 @@ -269,13 +269,17 @@ static int wl1251_sdio_probe(struct sdio_func *func,
40214
40215 irq_set_irq_type(wl->irq, IRQ_TYPE_EDGE_RISING);
40216
40217 - wl1251_sdio_ops.enable_irq = wl1251_enable_line_irq;
40218 - wl1251_sdio_ops.disable_irq = wl1251_disable_line_irq;
40219 + pax_open_kernel();
40220 + *(void **)&wl1251_sdio_ops.enable_irq = wl1251_enable_line_irq;
40221 + *(void **)&wl1251_sdio_ops.disable_irq = wl1251_disable_line_irq;
40222 + pax_close_kernel();
40223
40224 wl1251_info("using dedicated interrupt line");
40225 } else {
40226 - wl1251_sdio_ops.enable_irq = wl1251_sdio_enable_irq;
40227 - wl1251_sdio_ops.disable_irq = wl1251_sdio_disable_irq;
40228 + pax_open_kernel();
40229 + *(void **)&wl1251_sdio_ops.enable_irq = wl1251_sdio_enable_irq;
40230 + *(void **)&wl1251_sdio_ops.disable_irq = wl1251_sdio_disable_irq;
40231 + pax_close_kernel();
40232
40233 wl1251_info("using SDIO interrupt");
40234 }
40235 diff --git a/drivers/net/wireless/ti/wl12xx/main.c b/drivers/net/wireless/ti/wl12xx/main.c
40236 index e5f5f8f..fdf15b7 100644
40237 --- a/drivers/net/wireless/ti/wl12xx/main.c
40238 +++ b/drivers/net/wireless/ti/wl12xx/main.c
40239 @@ -644,7 +644,9 @@ static int wl12xx_identify_chip(struct wl1271 *wl)
40240 sizeof(wl->conf.mem));
40241
40242 /* read data preparation is only needed by wl127x */
40243 - wl->ops->prepare_read = wl127x_prepare_read;
40244 + pax_open_kernel();
40245 + *(void **)&wl->ops->prepare_read = wl127x_prepare_read;
40246 + pax_close_kernel();
40247
40248 wlcore_set_min_fw_ver(wl, WL127X_CHIP_VER, WL127X_IFTYPE_VER,
40249 WL127X_MAJOR_VER, WL127X_SUBTYPE_VER,
40250 @@ -665,7 +667,9 @@ static int wl12xx_identify_chip(struct wl1271 *wl)
40251 sizeof(wl->conf.mem));
40252
40253 /* read data preparation is only needed by wl127x */
40254 - wl->ops->prepare_read = wl127x_prepare_read;
40255 + pax_open_kernel();
40256 + *(void **)&wl->ops->prepare_read = wl127x_prepare_read;
40257 + pax_close_kernel();
40258
40259 wlcore_set_min_fw_ver(wl, WL127X_CHIP_VER, WL127X_IFTYPE_VER,
40260 WL127X_MAJOR_VER, WL127X_SUBTYPE_VER,
40261 diff --git a/drivers/net/wireless/ti/wl18xx/main.c b/drivers/net/wireless/ti/wl18xx/main.c
40262 index 8d8c1f8..e754844 100644
40263 --- a/drivers/net/wireless/ti/wl18xx/main.c
40264 +++ b/drivers/net/wireless/ti/wl18xx/main.c
40265 @@ -1489,8 +1489,10 @@ static int wl18xx_setup(struct wl1271 *wl)
40266 }
40267
40268 if (!checksum_param) {
40269 - wl18xx_ops.set_rx_csum = NULL;
40270 - wl18xx_ops.init_vif = NULL;
40271 + pax_open_kernel();
40272 + *(void **)&wl18xx_ops.set_rx_csum = NULL;
40273 + *(void **)&wl18xx_ops.init_vif = NULL;
40274 + pax_close_kernel();
40275 }
40276
40277 /* Enable 11a Band only if we have 5G antennas */
40278 diff --git a/drivers/oprofile/buffer_sync.c b/drivers/oprofile/buffer_sync.c
40279 index d93b2b6..ae50401 100644
40280 --- a/drivers/oprofile/buffer_sync.c
40281 +++ b/drivers/oprofile/buffer_sync.c
40282 @@ -332,7 +332,7 @@ static void add_data(struct op_entry *entry, struct mm_struct *mm)
40283 if (cookie == NO_COOKIE)
40284 offset = pc;
40285 if (cookie == INVALID_COOKIE) {
40286 - atomic_inc(&oprofile_stats.sample_lost_no_mapping);
40287 + atomic_inc_unchecked(&oprofile_stats.sample_lost_no_mapping);
40288 offset = pc;
40289 }
40290 if (cookie != last_cookie) {
40291 @@ -376,14 +376,14 @@ add_sample(struct mm_struct *mm, struct op_sample *s, int in_kernel)
40292 /* add userspace sample */
40293
40294 if (!mm) {
40295 - atomic_inc(&oprofile_stats.sample_lost_no_mm);
40296 + atomic_inc_unchecked(&oprofile_stats.sample_lost_no_mm);
40297 return 0;
40298 }
40299
40300 cookie = lookup_dcookie(mm, s->eip, &offset);
40301
40302 if (cookie == INVALID_COOKIE) {
40303 - atomic_inc(&oprofile_stats.sample_lost_no_mapping);
40304 + atomic_inc_unchecked(&oprofile_stats.sample_lost_no_mapping);
40305 return 0;
40306 }
40307
40308 @@ -552,7 +552,7 @@ void sync_buffer(int cpu)
40309 /* ignore backtraces if failed to add a sample */
40310 if (state == sb_bt_start) {
40311 state = sb_bt_ignore;
40312 - atomic_inc(&oprofile_stats.bt_lost_no_mapping);
40313 + atomic_inc_unchecked(&oprofile_stats.bt_lost_no_mapping);
40314 }
40315 }
40316 release_mm(mm);
40317 diff --git a/drivers/oprofile/event_buffer.c b/drivers/oprofile/event_buffer.c
40318 index c0cc4e7..44d4e54 100644
40319 --- a/drivers/oprofile/event_buffer.c
40320 +++ b/drivers/oprofile/event_buffer.c
40321 @@ -53,7 +53,7 @@ void add_event_entry(unsigned long value)
40322 }
40323
40324 if (buffer_pos == buffer_size) {
40325 - atomic_inc(&oprofile_stats.event_lost_overflow);
40326 + atomic_inc_unchecked(&oprofile_stats.event_lost_overflow);
40327 return;
40328 }
40329
40330 diff --git a/drivers/oprofile/oprof.c b/drivers/oprofile/oprof.c
40331 index ed2c3ec..deda85a 100644
40332 --- a/drivers/oprofile/oprof.c
40333 +++ b/drivers/oprofile/oprof.c
40334 @@ -110,7 +110,7 @@ static void switch_worker(struct work_struct *work)
40335 if (oprofile_ops.switch_events())
40336 return;
40337
40338 - atomic_inc(&oprofile_stats.multiplex_counter);
40339 + atomic_inc_unchecked(&oprofile_stats.multiplex_counter);
40340 start_switch_worker();
40341 }
40342
40343 diff --git a/drivers/oprofile/oprofile_files.c b/drivers/oprofile/oprofile_files.c
40344 index 84a208d..d61b0a1 100644
40345 --- a/drivers/oprofile/oprofile_files.c
40346 +++ b/drivers/oprofile/oprofile_files.c
40347 @@ -27,7 +27,7 @@ unsigned long oprofile_time_slice;
40348
40349 #ifdef CONFIG_OPROFILE_EVENT_MULTIPLEX
40350
40351 -static ssize_t timeout_read(struct file *file, char __user *buf,
40352 +static ssize_t __intentional_overflow(-1) timeout_read(struct file *file, char __user *buf,
40353 size_t count, loff_t *offset)
40354 {
40355 return oprofilefs_ulong_to_user(jiffies_to_msecs(oprofile_time_slice),
40356 diff --git a/drivers/oprofile/oprofile_stats.c b/drivers/oprofile/oprofile_stats.c
40357 index 917d28e..d62d981 100644
40358 --- a/drivers/oprofile/oprofile_stats.c
40359 +++ b/drivers/oprofile/oprofile_stats.c
40360 @@ -30,11 +30,11 @@ void oprofile_reset_stats(void)
40361 cpu_buf->sample_invalid_eip = 0;
40362 }
40363
40364 - atomic_set(&oprofile_stats.sample_lost_no_mm, 0);
40365 - atomic_set(&oprofile_stats.sample_lost_no_mapping, 0);
40366 - atomic_set(&oprofile_stats.event_lost_overflow, 0);
40367 - atomic_set(&oprofile_stats.bt_lost_no_mapping, 0);
40368 - atomic_set(&oprofile_stats.multiplex_counter, 0);
40369 + atomic_set_unchecked(&oprofile_stats.sample_lost_no_mm, 0);
40370 + atomic_set_unchecked(&oprofile_stats.sample_lost_no_mapping, 0);
40371 + atomic_set_unchecked(&oprofile_stats.event_lost_overflow, 0);
40372 + atomic_set_unchecked(&oprofile_stats.bt_lost_no_mapping, 0);
40373 + atomic_set_unchecked(&oprofile_stats.multiplex_counter, 0);
40374 }
40375
40376
40377 diff --git a/drivers/oprofile/oprofile_stats.h b/drivers/oprofile/oprofile_stats.h
40378 index 38b6fc0..b5cbfce 100644
40379 --- a/drivers/oprofile/oprofile_stats.h
40380 +++ b/drivers/oprofile/oprofile_stats.h
40381 @@ -13,11 +13,11 @@
40382 #include <linux/atomic.h>
40383
40384 struct oprofile_stat_struct {
40385 - atomic_t sample_lost_no_mm;
40386 - atomic_t sample_lost_no_mapping;
40387 - atomic_t bt_lost_no_mapping;
40388 - atomic_t event_lost_overflow;
40389 - atomic_t multiplex_counter;
40390 + atomic_unchecked_t sample_lost_no_mm;
40391 + atomic_unchecked_t sample_lost_no_mapping;
40392 + atomic_unchecked_t bt_lost_no_mapping;
40393 + atomic_unchecked_t event_lost_overflow;
40394 + atomic_unchecked_t multiplex_counter;
40395 };
40396
40397 extern struct oprofile_stat_struct oprofile_stats;
40398 diff --git a/drivers/oprofile/oprofilefs.c b/drivers/oprofile/oprofilefs.c
40399 index 849357c..b83c1e0 100644
40400 --- a/drivers/oprofile/oprofilefs.c
40401 +++ b/drivers/oprofile/oprofilefs.c
40402 @@ -185,7 +185,7 @@ static const struct file_operations atomic_ro_fops = {
40403
40404
40405 int oprofilefs_create_ro_atomic(struct super_block *sb, struct dentry *root,
40406 - char const *name, atomic_t *val)
40407 + char const *name, atomic_unchecked_t *val)
40408 {
40409 return __oprofilefs_create_file(sb, root, name,
40410 &atomic_ro_fops, 0444, val);
40411 diff --git a/drivers/oprofile/timer_int.c b/drivers/oprofile/timer_int.c
40412 index 93404f7..4a313d8 100644
40413 --- a/drivers/oprofile/timer_int.c
40414 +++ b/drivers/oprofile/timer_int.c
40415 @@ -93,7 +93,7 @@ static int __cpuinit oprofile_cpu_notify(struct notifier_block *self,
40416 return NOTIFY_OK;
40417 }
40418
40419 -static struct notifier_block __refdata oprofile_cpu_notifier = {
40420 +static struct notifier_block oprofile_cpu_notifier = {
40421 .notifier_call = oprofile_cpu_notify,
40422 };
40423
40424 diff --git a/drivers/parport/procfs.c b/drivers/parport/procfs.c
40425 index 3f56bc0..707d642 100644
40426 --- a/drivers/parport/procfs.c
40427 +++ b/drivers/parport/procfs.c
40428 @@ -64,7 +64,7 @@ static int do_active_device(ctl_table *table, int write,
40429
40430 *ppos += len;
40431
40432 - return copy_to_user(result, buffer, len) ? -EFAULT : 0;
40433 + return (len > sizeof buffer || copy_to_user(result, buffer, len)) ? -EFAULT : 0;
40434 }
40435
40436 #ifdef CONFIG_PARPORT_1284
40437 @@ -106,7 +106,7 @@ static int do_autoprobe(ctl_table *table, int write,
40438
40439 *ppos += len;
40440
40441 - return copy_to_user (result, buffer, len) ? -EFAULT : 0;
40442 + return (len > sizeof buffer || copy_to_user (result, buffer, len)) ? -EFAULT : 0;
40443 }
40444 #endif /* IEEE1284.3 support. */
40445
40446 diff --git a/drivers/pci/hotplug/acpiphp_ibm.c b/drivers/pci/hotplug/acpiphp_ibm.c
40447 index c35e8ad..fc33beb 100644
40448 --- a/drivers/pci/hotplug/acpiphp_ibm.c
40449 +++ b/drivers/pci/hotplug/acpiphp_ibm.c
40450 @@ -464,7 +464,9 @@ static int __init ibm_acpiphp_init(void)
40451 goto init_cleanup;
40452 }
40453
40454 - ibm_apci_table_attr.size = ibm_get_table_from_acpi(NULL);
40455 + pax_open_kernel();
40456 + *(size_t *)&ibm_apci_table_attr.size = ibm_get_table_from_acpi(NULL);
40457 + pax_close_kernel();
40458 retval = sysfs_create_bin_file(sysdir, &ibm_apci_table_attr);
40459
40460 return retval;
40461 diff --git a/drivers/pci/hotplug/cpcihp_generic.c b/drivers/pci/hotplug/cpcihp_generic.c
40462 index a6a71c4..c91097b 100644
40463 --- a/drivers/pci/hotplug/cpcihp_generic.c
40464 +++ b/drivers/pci/hotplug/cpcihp_generic.c
40465 @@ -73,7 +73,6 @@ static u16 port;
40466 static unsigned int enum_bit;
40467 static u8 enum_mask;
40468
40469 -static struct cpci_hp_controller_ops generic_hpc_ops;
40470 static struct cpci_hp_controller generic_hpc;
40471
40472 static int __init validate_parameters(void)
40473 @@ -139,6 +138,10 @@ static int query_enum(void)
40474 return ((value & enum_mask) == enum_mask);
40475 }
40476
40477 +static struct cpci_hp_controller_ops generic_hpc_ops = {
40478 + .query_enum = query_enum,
40479 +};
40480 +
40481 static int __init cpcihp_generic_init(void)
40482 {
40483 int status;
40484 @@ -165,7 +168,6 @@ static int __init cpcihp_generic_init(void)
40485 pci_dev_put(dev);
40486
40487 memset(&generic_hpc, 0, sizeof (struct cpci_hp_controller));
40488 - generic_hpc_ops.query_enum = query_enum;
40489 generic_hpc.ops = &generic_hpc_ops;
40490
40491 status = cpci_hp_register_controller(&generic_hpc);
40492 diff --git a/drivers/pci/hotplug/cpcihp_zt5550.c b/drivers/pci/hotplug/cpcihp_zt5550.c
40493 index 449b4bb..257e2e8 100644
40494 --- a/drivers/pci/hotplug/cpcihp_zt5550.c
40495 +++ b/drivers/pci/hotplug/cpcihp_zt5550.c
40496 @@ -59,7 +59,6 @@
40497 /* local variables */
40498 static bool debug;
40499 static bool poll;
40500 -static struct cpci_hp_controller_ops zt5550_hpc_ops;
40501 static struct cpci_hp_controller zt5550_hpc;
40502
40503 /* Primary cPCI bus bridge device */
40504 @@ -205,6 +204,10 @@ static int zt5550_hc_disable_irq(void)
40505 return 0;
40506 }
40507
40508 +static struct cpci_hp_controller_ops zt5550_hpc_ops = {
40509 + .query_enum = zt5550_hc_query_enum,
40510 +};
40511 +
40512 static int zt5550_hc_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
40513 {
40514 int status;
40515 @@ -216,16 +219,17 @@ static int zt5550_hc_init_one (struct pci_dev *pdev, const struct pci_device_id
40516 dbg("returned from zt5550_hc_config");
40517
40518 memset(&zt5550_hpc, 0, sizeof (struct cpci_hp_controller));
40519 - zt5550_hpc_ops.query_enum = zt5550_hc_query_enum;
40520 zt5550_hpc.ops = &zt5550_hpc_ops;
40521 if(!poll) {
40522 zt5550_hpc.irq = hc_dev->irq;
40523 zt5550_hpc.irq_flags = IRQF_SHARED;
40524 zt5550_hpc.dev_id = hc_dev;
40525
40526 - zt5550_hpc_ops.enable_irq = zt5550_hc_enable_irq;
40527 - zt5550_hpc_ops.disable_irq = zt5550_hc_disable_irq;
40528 - zt5550_hpc_ops.check_irq = zt5550_hc_check_irq;
40529 + pax_open_kernel();
40530 + *(void **)&zt5550_hpc_ops.enable_irq = zt5550_hc_enable_irq;
40531 + *(void **)&zt5550_hpc_ops.disable_irq = zt5550_hc_disable_irq;
40532 + *(void **)&zt5550_hpc_ops.check_irq = zt5550_hc_check_irq;
40533 + pax_open_kernel();
40534 } else {
40535 info("using ENUM# polling mode");
40536 }
40537 diff --git a/drivers/pci/hotplug/cpqphp_nvram.c b/drivers/pci/hotplug/cpqphp_nvram.c
40538 index 76ba8a1..20ca857 100644
40539 --- a/drivers/pci/hotplug/cpqphp_nvram.c
40540 +++ b/drivers/pci/hotplug/cpqphp_nvram.c
40541 @@ -428,9 +428,13 @@ static u32 store_HRT (void __iomem *rom_start)
40542
40543 void compaq_nvram_init (void __iomem *rom_start)
40544 {
40545 +
40546 +#ifndef CONFIG_PAX_KERNEXEC
40547 if (rom_start) {
40548 compaq_int15_entry_point = (rom_start + ROM_INT15_PHY_ADDR - ROM_PHY_ADDR);
40549 }
40550 +#endif
40551 +
40552 dbg("int15 entry = %p\n", compaq_int15_entry_point);
40553
40554 /* initialize our int15 lock */
40555 diff --git a/drivers/pci/hotplug/pci_hotplug_core.c b/drivers/pci/hotplug/pci_hotplug_core.c
40556 index 202f4a9..8ee47d0 100644
40557 --- a/drivers/pci/hotplug/pci_hotplug_core.c
40558 +++ b/drivers/pci/hotplug/pci_hotplug_core.c
40559 @@ -448,8 +448,10 @@ int __pci_hp_register(struct hotplug_slot *slot, struct pci_bus *bus,
40560 return -EINVAL;
40561 }
40562
40563 - slot->ops->owner = owner;
40564 - slot->ops->mod_name = mod_name;
40565 + pax_open_kernel();
40566 + *(struct module **)&slot->ops->owner = owner;
40567 + *(const char **)&slot->ops->mod_name = mod_name;
40568 + pax_close_kernel();
40569
40570 mutex_lock(&pci_hp_mutex);
40571 /*
40572 diff --git a/drivers/pci/hotplug/pciehp_core.c b/drivers/pci/hotplug/pciehp_core.c
40573 index 939bd1d..a1459c9 100644
40574 --- a/drivers/pci/hotplug/pciehp_core.c
40575 +++ b/drivers/pci/hotplug/pciehp_core.c
40576 @@ -91,7 +91,7 @@ static int init_slot(struct controller *ctrl)
40577 struct slot *slot = ctrl->slot;
40578 struct hotplug_slot *hotplug = NULL;
40579 struct hotplug_slot_info *info = NULL;
40580 - struct hotplug_slot_ops *ops = NULL;
40581 + hotplug_slot_ops_no_const *ops = NULL;
40582 char name[SLOT_NAME_SIZE];
40583 int retval = -ENOMEM;
40584
40585 diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
40586 index 9c6e9bb..2916736 100644
40587 --- a/drivers/pci/pci-sysfs.c
40588 +++ b/drivers/pci/pci-sysfs.c
40589 @@ -1071,7 +1071,7 @@ static int pci_create_attr(struct pci_dev *pdev, int num, int write_combine)
40590 {
40591 /* allocate attribute structure, piggyback attribute name */
40592 int name_len = write_combine ? 13 : 10;
40593 - struct bin_attribute *res_attr;
40594 + bin_attribute_no_const *res_attr;
40595 int retval;
40596
40597 res_attr = kzalloc(sizeof(*res_attr) + name_len, GFP_ATOMIC);
40598 @@ -1256,7 +1256,7 @@ static struct device_attribute reset_attr = __ATTR(reset, 0200, NULL, reset_stor
40599 static int pci_create_capabilities_sysfs(struct pci_dev *dev)
40600 {
40601 int retval;
40602 - struct bin_attribute *attr;
40603 + bin_attribute_no_const *attr;
40604
40605 /* If the device has VPD, try to expose it in sysfs. */
40606 if (dev->vpd) {
40607 @@ -1303,7 +1303,7 @@ int __must_check pci_create_sysfs_dev_files (struct pci_dev *pdev)
40608 {
40609 int retval;
40610 int rom_size = 0;
40611 - struct bin_attribute *attr;
40612 + bin_attribute_no_const *attr;
40613
40614 if (!sysfs_initialized)
40615 return -EACCES;
40616 diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
40617 index e851829..a1a7196 100644
40618 --- a/drivers/pci/pci.h
40619 +++ b/drivers/pci/pci.h
40620 @@ -98,7 +98,7 @@ struct pci_vpd_ops {
40621 struct pci_vpd {
40622 unsigned int len;
40623 const struct pci_vpd_ops *ops;
40624 - struct bin_attribute *attr; /* descriptor for sysfs VPD entry */
40625 + bin_attribute_no_const *attr; /* descriptor for sysfs VPD entry */
40626 };
40627
40628 extern int pci_vpd_pci22_init(struct pci_dev *dev);
40629 diff --git a/drivers/pci/pcie/aspm.c b/drivers/pci/pcie/aspm.c
40630 index 8474b6a..ee81993 100644
40631 --- a/drivers/pci/pcie/aspm.c
40632 +++ b/drivers/pci/pcie/aspm.c
40633 @@ -27,9 +27,9 @@
40634 #define MODULE_PARAM_PREFIX "pcie_aspm."
40635
40636 /* Note: those are not register definitions */
40637 -#define ASPM_STATE_L0S_UP (1) /* Upstream direction L0s state */
40638 -#define ASPM_STATE_L0S_DW (2) /* Downstream direction L0s state */
40639 -#define ASPM_STATE_L1 (4) /* L1 state */
40640 +#define ASPM_STATE_L0S_UP (1U) /* Upstream direction L0s state */
40641 +#define ASPM_STATE_L0S_DW (2U) /* Downstream direction L0s state */
40642 +#define ASPM_STATE_L1 (4U) /* L1 state */
40643 #define ASPM_STATE_L0S (ASPM_STATE_L0S_UP | ASPM_STATE_L0S_DW)
40644 #define ASPM_STATE_ALL (ASPM_STATE_L0S | ASPM_STATE_L1)
40645
40646 diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
40647 index 6186f03..1a78714 100644
40648 --- a/drivers/pci/probe.c
40649 +++ b/drivers/pci/probe.c
40650 @@ -173,7 +173,7 @@ int __pci_read_base(struct pci_dev *dev, enum pci_bar_type type,
40651 struct pci_bus_region region;
40652 bool bar_too_big = false, bar_disabled = false;
40653
40654 - mask = type ? PCI_ROM_ADDRESS_MASK : ~0;
40655 + mask = type ? (u32)PCI_ROM_ADDRESS_MASK : ~0;
40656
40657 /* No printks while decoding is disabled! */
40658 if (!dev->mmio_always_on) {
40659 diff --git a/drivers/pci/proc.c b/drivers/pci/proc.c
40660 index 9b8505c..f00870a 100644
40661 --- a/drivers/pci/proc.c
40662 +++ b/drivers/pci/proc.c
40663 @@ -465,7 +465,16 @@ static const struct file_operations proc_bus_pci_dev_operations = {
40664 static int __init pci_proc_init(void)
40665 {
40666 struct pci_dev *dev = NULL;
40667 +
40668 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
40669 +#ifdef CONFIG_GRKERNSEC_PROC_USER
40670 + proc_bus_pci_dir = proc_mkdir_mode("bus/pci", S_IRUSR | S_IXUSR, NULL);
40671 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
40672 + proc_bus_pci_dir = proc_mkdir_mode("bus/pci", S_IRUSR | S_IXUSR | S_IRGRP | S_IXGRP, NULL);
40673 +#endif
40674 +#else
40675 proc_bus_pci_dir = proc_mkdir("bus/pci", NULL);
40676 +#endif
40677 proc_create("devices", 0, proc_bus_pci_dir,
40678 &proc_bus_pci_dev_operations);
40679 proc_initialized = 1;
40680 diff --git a/drivers/platform/x86/msi-laptop.c b/drivers/platform/x86/msi-laptop.c
40681 index 2111dbb..79e434b 100644
40682 --- a/drivers/platform/x86/msi-laptop.c
40683 +++ b/drivers/platform/x86/msi-laptop.c
40684 @@ -820,12 +820,14 @@ static int __init load_scm_model_init(struct platform_device *sdev)
40685 int result;
40686
40687 /* allow userland write sysfs file */
40688 - dev_attr_bluetooth.store = store_bluetooth;
40689 - dev_attr_wlan.store = store_wlan;
40690 - dev_attr_threeg.store = store_threeg;
40691 - dev_attr_bluetooth.attr.mode |= S_IWUSR;
40692 - dev_attr_wlan.attr.mode |= S_IWUSR;
40693 - dev_attr_threeg.attr.mode |= S_IWUSR;
40694 + pax_open_kernel();
40695 + *(void **)&dev_attr_bluetooth.store = store_bluetooth;
40696 + *(void **)&dev_attr_wlan.store = store_wlan;
40697 + *(void **)&dev_attr_threeg.store = store_threeg;
40698 + *(umode_t *)&dev_attr_bluetooth.attr.mode |= S_IWUSR;
40699 + *(umode_t *)&dev_attr_wlan.attr.mode |= S_IWUSR;
40700 + *(umode_t *)&dev_attr_threeg.attr.mode |= S_IWUSR;
40701 + pax_close_kernel();
40702
40703 /* disable hardware control by fn key */
40704 result = ec_read(MSI_STANDARD_EC_SCM_LOAD_ADDRESS, &data);
40705 diff --git a/drivers/platform/x86/sony-laptop.c b/drivers/platform/x86/sony-laptop.c
40706 index 0fe987f..6f3d5c3 100644
40707 --- a/drivers/platform/x86/sony-laptop.c
40708 +++ b/drivers/platform/x86/sony-laptop.c
40709 @@ -2356,7 +2356,7 @@ static void sony_nc_lid_resume_cleanup(struct platform_device *pd)
40710 }
40711
40712 /* High speed charging function */
40713 -static struct device_attribute *hsc_handle;
40714 +static device_attribute_no_const *hsc_handle;
40715
40716 static ssize_t sony_nc_highspeed_charging_store(struct device *dev,
40717 struct device_attribute *attr,
40718 diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c
40719 index f946ca7..f25c833 100644
40720 --- a/drivers/platform/x86/thinkpad_acpi.c
40721 +++ b/drivers/platform/x86/thinkpad_acpi.c
40722 @@ -2097,7 +2097,7 @@ static int hotkey_mask_get(void)
40723 return 0;
40724 }
40725
40726 -void static hotkey_mask_warn_incomplete_mask(void)
40727 +static void hotkey_mask_warn_incomplete_mask(void)
40728 {
40729 /* log only what the user can fix... */
40730 const u32 wantedmask = hotkey_driver_mask &
40731 @@ -2328,11 +2328,6 @@ static void hotkey_read_nvram(struct tp_nvram_state *n, const u32 m)
40732 }
40733 }
40734
40735 -static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
40736 - struct tp_nvram_state *newn,
40737 - const u32 event_mask)
40738 -{
40739 -
40740 #define TPACPI_COMPARE_KEY(__scancode, __member) \
40741 do { \
40742 if ((event_mask & (1 << __scancode)) && \
40743 @@ -2346,36 +2341,42 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
40744 tpacpi_hotkey_send_key(__scancode); \
40745 } while (0)
40746
40747 - void issue_volchange(const unsigned int oldvol,
40748 - const unsigned int newvol)
40749 - {
40750 - unsigned int i = oldvol;
40751 +static void issue_volchange(const unsigned int oldvol,
40752 + const unsigned int newvol,
40753 + const u32 event_mask)
40754 +{
40755 + unsigned int i = oldvol;
40756
40757 - while (i > newvol) {
40758 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEDOWN);
40759 - i--;
40760 - }
40761 - while (i < newvol) {
40762 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEUP);
40763 - i++;
40764 - }
40765 + while (i > newvol) {
40766 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEDOWN);
40767 + i--;
40768 }
40769 + while (i < newvol) {
40770 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEUP);
40771 + i++;
40772 + }
40773 +}
40774
40775 - void issue_brightnesschange(const unsigned int oldbrt,
40776 - const unsigned int newbrt)
40777 - {
40778 - unsigned int i = oldbrt;
40779 +static void issue_brightnesschange(const unsigned int oldbrt,
40780 + const unsigned int newbrt,
40781 + const u32 event_mask)
40782 +{
40783 + unsigned int i = oldbrt;
40784
40785 - while (i > newbrt) {
40786 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNEND);
40787 - i--;
40788 - }
40789 - while (i < newbrt) {
40790 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNHOME);
40791 - i++;
40792 - }
40793 + while (i > newbrt) {
40794 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNEND);
40795 + i--;
40796 + }
40797 + while (i < newbrt) {
40798 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNHOME);
40799 + i++;
40800 }
40801 +}
40802
40803 +static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
40804 + struct tp_nvram_state *newn,
40805 + const u32 event_mask)
40806 +{
40807 TPACPI_COMPARE_KEY(TP_ACPI_HOTKEYSCAN_THINKPAD, thinkpad_toggle);
40808 TPACPI_COMPARE_KEY(TP_ACPI_HOTKEYSCAN_FNSPACE, zoom_toggle);
40809 TPACPI_COMPARE_KEY(TP_ACPI_HOTKEYSCAN_FNF7, display_toggle);
40810 @@ -2409,7 +2410,7 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
40811 oldn->volume_level != newn->volume_level) {
40812 /* recently muted, or repeated mute keypress, or
40813 * multiple presses ending in mute */
40814 - issue_volchange(oldn->volume_level, newn->volume_level);
40815 + issue_volchange(oldn->volume_level, newn->volume_level, event_mask);
40816 TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_MUTE);
40817 }
40818 } else {
40819 @@ -2419,7 +2420,7 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
40820 TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEUP);
40821 }
40822 if (oldn->volume_level != newn->volume_level) {
40823 - issue_volchange(oldn->volume_level, newn->volume_level);
40824 + issue_volchange(oldn->volume_level, newn->volume_level, event_mask);
40825 } else if (oldn->volume_toggle != newn->volume_toggle) {
40826 /* repeated vol up/down keypress at end of scale ? */
40827 if (newn->volume_level == 0)
40828 @@ -2432,7 +2433,8 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
40829 /* handle brightness */
40830 if (oldn->brightness_level != newn->brightness_level) {
40831 issue_brightnesschange(oldn->brightness_level,
40832 - newn->brightness_level);
40833 + newn->brightness_level,
40834 + event_mask);
40835 } else if (oldn->brightness_toggle != newn->brightness_toggle) {
40836 /* repeated key presses that didn't change state */
40837 if (newn->brightness_level == 0)
40838 @@ -2441,10 +2443,10 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
40839 && !tp_features.bright_unkfw)
40840 TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNHOME);
40841 }
40842 +}
40843
40844 #undef TPACPI_COMPARE_KEY
40845 #undef TPACPI_MAY_SEND_KEY
40846 -}
40847
40848 /*
40849 * Polling driver
40850 diff --git a/drivers/pnp/pnpbios/bioscalls.c b/drivers/pnp/pnpbios/bioscalls.c
40851 index 769d265..a3a05ca 100644
40852 --- a/drivers/pnp/pnpbios/bioscalls.c
40853 +++ b/drivers/pnp/pnpbios/bioscalls.c
40854 @@ -58,7 +58,7 @@ do { \
40855 set_desc_limit(&gdt[(selname) >> 3], (size) - 1); \
40856 } while(0)
40857
40858 -static struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4092,
40859 +static const struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4093,
40860 (unsigned long)__va(0x400UL), PAGE_SIZE - 0x400 - 1);
40861
40862 /*
40863 @@ -95,7 +95,10 @@ static inline u16 call_pnp_bios(u16 func, u16 arg1, u16 arg2, u16 arg3,
40864
40865 cpu = get_cpu();
40866 save_desc_40 = get_cpu_gdt_table(cpu)[0x40 / 8];
40867 +
40868 + pax_open_kernel();
40869 get_cpu_gdt_table(cpu)[0x40 / 8] = bad_bios_desc;
40870 + pax_close_kernel();
40871
40872 /* On some boxes IRQ's during PnP BIOS calls are deadly. */
40873 spin_lock_irqsave(&pnp_bios_lock, flags);
40874 @@ -133,7 +136,10 @@ static inline u16 call_pnp_bios(u16 func, u16 arg1, u16 arg2, u16 arg3,
40875 :"memory");
40876 spin_unlock_irqrestore(&pnp_bios_lock, flags);
40877
40878 + pax_open_kernel();
40879 get_cpu_gdt_table(cpu)[0x40 / 8] = save_desc_40;
40880 + pax_close_kernel();
40881 +
40882 put_cpu();
40883
40884 /* If we get here and this is set then the PnP BIOS faulted on us. */
40885 @@ -467,7 +473,7 @@ int pnp_bios_read_escd(char *data, u32 nvram_base)
40886 return status;
40887 }
40888
40889 -void pnpbios_calls_init(union pnp_bios_install_struct *header)
40890 +void __init pnpbios_calls_init(union pnp_bios_install_struct *header)
40891 {
40892 int i;
40893
40894 @@ -475,6 +481,8 @@ void pnpbios_calls_init(union pnp_bios_install_struct *header)
40895 pnp_bios_callpoint.offset = header->fields.pm16offset;
40896 pnp_bios_callpoint.segment = PNP_CS16;
40897
40898 + pax_open_kernel();
40899 +
40900 for_each_possible_cpu(i) {
40901 struct desc_struct *gdt = get_cpu_gdt_table(i);
40902 if (!gdt)
40903 @@ -486,4 +494,6 @@ void pnpbios_calls_init(union pnp_bios_install_struct *header)
40904 set_desc_base(&gdt[GDT_ENTRY_PNPBIOS_DS],
40905 (unsigned long)__va(header->fields.pm16dseg));
40906 }
40907 +
40908 + pax_close_kernel();
40909 }
40910 diff --git a/drivers/pnp/resource.c b/drivers/pnp/resource.c
40911 index 3e6db1c..1fbbdae 100644
40912 --- a/drivers/pnp/resource.c
40913 +++ b/drivers/pnp/resource.c
40914 @@ -360,7 +360,7 @@ int pnp_check_irq(struct pnp_dev *dev, struct resource *res)
40915 return 1;
40916
40917 /* check if the resource is valid */
40918 - if (*irq < 0 || *irq > 15)
40919 + if (*irq > 15)
40920 return 0;
40921
40922 /* check if the resource is reserved */
40923 @@ -424,7 +424,7 @@ int pnp_check_dma(struct pnp_dev *dev, struct resource *res)
40924 return 1;
40925
40926 /* check if the resource is valid */
40927 - if (*dma < 0 || *dma == 4 || *dma > 7)
40928 + if (*dma == 4 || *dma > 7)
40929 return 0;
40930
40931 /* check if the resource is reserved */
40932 diff --git a/drivers/power/pda_power.c b/drivers/power/pda_power.c
40933 index 7df7c5f..bd48c47 100644
40934 --- a/drivers/power/pda_power.c
40935 +++ b/drivers/power/pda_power.c
40936 @@ -37,7 +37,11 @@ static int polling;
40937
40938 #ifdef CONFIG_USB_OTG_UTILS
40939 static struct usb_phy *transceiver;
40940 -static struct notifier_block otg_nb;
40941 +static int otg_handle_notification(struct notifier_block *nb,
40942 + unsigned long event, void *unused);
40943 +static struct notifier_block otg_nb = {
40944 + .notifier_call = otg_handle_notification
40945 +};
40946 #endif
40947
40948 static struct regulator *ac_draw;
40949 @@ -369,7 +373,6 @@ static int pda_power_probe(struct platform_device *pdev)
40950
40951 #ifdef CONFIG_USB_OTG_UTILS
40952 if (!IS_ERR_OR_NULL(transceiver) && pdata->use_otg_notifier) {
40953 - otg_nb.notifier_call = otg_handle_notification;
40954 ret = usb_register_notifier(transceiver, &otg_nb);
40955 if (ret) {
40956 dev_err(dev, "failure to register otg notifier\n");
40957 diff --git a/drivers/power/power_supply.h b/drivers/power/power_supply.h
40958 index cc439fd..8fa30df 100644
40959 --- a/drivers/power/power_supply.h
40960 +++ b/drivers/power/power_supply.h
40961 @@ -16,12 +16,12 @@ struct power_supply;
40962
40963 #ifdef CONFIG_SYSFS
40964
40965 -extern void power_supply_init_attrs(struct device_type *dev_type);
40966 +extern void power_supply_init_attrs(void);
40967 extern int power_supply_uevent(struct device *dev, struct kobj_uevent_env *env);
40968
40969 #else
40970
40971 -static inline void power_supply_init_attrs(struct device_type *dev_type) {}
40972 +static inline void power_supply_init_attrs(void) {}
40973 #define power_supply_uevent NULL
40974
40975 #endif /* CONFIG_SYSFS */
40976 diff --git a/drivers/power/power_supply_core.c b/drivers/power/power_supply_core.c
40977 index 8a7cfb3..72e6e9b 100644
40978 --- a/drivers/power/power_supply_core.c
40979 +++ b/drivers/power/power_supply_core.c
40980 @@ -24,7 +24,10 @@
40981 struct class *power_supply_class;
40982 EXPORT_SYMBOL_GPL(power_supply_class);
40983
40984 -static struct device_type power_supply_dev_type;
40985 +extern const struct attribute_group *power_supply_attr_groups[];
40986 +static struct device_type power_supply_dev_type = {
40987 + .groups = power_supply_attr_groups,
40988 +};
40989
40990 static int __power_supply_changed_work(struct device *dev, void *data)
40991 {
40992 @@ -393,7 +396,7 @@ static int __init power_supply_class_init(void)
40993 return PTR_ERR(power_supply_class);
40994
40995 power_supply_class->dev_uevent = power_supply_uevent;
40996 - power_supply_init_attrs(&power_supply_dev_type);
40997 + power_supply_init_attrs();
40998
40999 return 0;
41000 }
41001 diff --git a/drivers/power/power_supply_sysfs.c b/drivers/power/power_supply_sysfs.c
41002 index 40fa3b7..d9c2e0e 100644
41003 --- a/drivers/power/power_supply_sysfs.c
41004 +++ b/drivers/power/power_supply_sysfs.c
41005 @@ -229,17 +229,15 @@ static struct attribute_group power_supply_attr_group = {
41006 .is_visible = power_supply_attr_is_visible,
41007 };
41008
41009 -static const struct attribute_group *power_supply_attr_groups[] = {
41010 +const struct attribute_group *power_supply_attr_groups[] = {
41011 &power_supply_attr_group,
41012 NULL,
41013 };
41014
41015 -void power_supply_init_attrs(struct device_type *dev_type)
41016 +void power_supply_init_attrs(void)
41017 {
41018 int i;
41019
41020 - dev_type->groups = power_supply_attr_groups;
41021 -
41022 for (i = 0; i < ARRAY_SIZE(power_supply_attrs); i++)
41023 __power_supply_attrs[i] = &power_supply_attrs[i].attr;
41024 }
41025 diff --git a/drivers/regulator/max8660.c b/drivers/regulator/max8660.c
41026 index 4d7c635..9860196 100644
41027 --- a/drivers/regulator/max8660.c
41028 +++ b/drivers/regulator/max8660.c
41029 @@ -333,8 +333,10 @@ static int max8660_probe(struct i2c_client *client,
41030 max8660->shadow_regs[MAX8660_OVER1] = 5;
41031 } else {
41032 /* Otherwise devices can be toggled via software */
41033 - max8660_dcdc_ops.enable = max8660_dcdc_enable;
41034 - max8660_dcdc_ops.disable = max8660_dcdc_disable;
41035 + pax_open_kernel();
41036 + *(void **)&max8660_dcdc_ops.enable = max8660_dcdc_enable;
41037 + *(void **)&max8660_dcdc_ops.disable = max8660_dcdc_disable;
41038 + pax_close_kernel();
41039 }
41040
41041 /*
41042 diff --git a/drivers/regulator/max8973-regulator.c b/drivers/regulator/max8973-regulator.c
41043 index 9a8ea91..c483dd9 100644
41044 --- a/drivers/regulator/max8973-regulator.c
41045 +++ b/drivers/regulator/max8973-regulator.c
41046 @@ -401,9 +401,11 @@ static int max8973_probe(struct i2c_client *client,
41047 if (!pdata->enable_ext_control) {
41048 max->desc.enable_reg = MAX8973_VOUT;
41049 max->desc.enable_mask = MAX8973_VOUT_ENABLE;
41050 - max8973_dcdc_ops.enable = regulator_enable_regmap;
41051 - max8973_dcdc_ops.disable = regulator_disable_regmap;
41052 - max8973_dcdc_ops.is_enabled = regulator_is_enabled_regmap;
41053 + pax_open_kernel();
41054 + *(void **)&max8973_dcdc_ops.enable = regulator_enable_regmap;
41055 + *(void **)&max8973_dcdc_ops.disable = regulator_disable_regmap;
41056 + *(void **)&max8973_dcdc_ops.is_enabled = regulator_is_enabled_regmap;
41057 + pax_close_kernel();
41058 }
41059
41060 max->enable_external_control = pdata->enable_ext_control;
41061 diff --git a/drivers/regulator/mc13892-regulator.c b/drivers/regulator/mc13892-regulator.c
41062 index 0d84b1f..c2da6ac 100644
41063 --- a/drivers/regulator/mc13892-regulator.c
41064 +++ b/drivers/regulator/mc13892-regulator.c
41065 @@ -540,10 +540,12 @@ static int mc13892_regulator_probe(struct platform_device *pdev)
41066 }
41067 mc13xxx_unlock(mc13892);
41068
41069 - mc13892_regulators[MC13892_VCAM].desc.ops->set_mode
41070 + pax_open_kernel();
41071 + *(void **)&mc13892_regulators[MC13892_VCAM].desc.ops->set_mode
41072 = mc13892_vcam_set_mode;
41073 - mc13892_regulators[MC13892_VCAM].desc.ops->get_mode
41074 + *(void **)&mc13892_regulators[MC13892_VCAM].desc.ops->get_mode
41075 = mc13892_vcam_get_mode;
41076 + pax_close_kernel();
41077
41078 mc13xxx_data = mc13xxx_parse_regulators_dt(pdev, mc13892_regulators,
41079 ARRAY_SIZE(mc13892_regulators));
41080 diff --git a/drivers/rtc/rtc-cmos.c b/drivers/rtc/rtc-cmos.c
41081 index 16630aa..6afc992 100644
41082 --- a/drivers/rtc/rtc-cmos.c
41083 +++ b/drivers/rtc/rtc-cmos.c
41084 @@ -724,7 +724,9 @@ cmos_do_probe(struct device *dev, struct resource *ports, int rtc_irq)
41085 hpet_rtc_timer_init();
41086
41087 /* export at least the first block of NVRAM */
41088 - nvram.size = address_space - NVRAM_OFFSET;
41089 + pax_open_kernel();
41090 + *(size_t *)&nvram.size = address_space - NVRAM_OFFSET;
41091 + pax_close_kernel();
41092 retval = sysfs_create_bin_file(&dev->kobj, &nvram);
41093 if (retval < 0) {
41094 dev_dbg(dev, "can't create nvram file? %d\n", retval);
41095 diff --git a/drivers/rtc/rtc-dev.c b/drivers/rtc/rtc-dev.c
41096 index 9a86b4b..3a383dc 100644
41097 --- a/drivers/rtc/rtc-dev.c
41098 +++ b/drivers/rtc/rtc-dev.c
41099 @@ -14,6 +14,7 @@
41100 #include <linux/module.h>
41101 #include <linux/rtc.h>
41102 #include <linux/sched.h>
41103 +#include <linux/grsecurity.h>
41104 #include "rtc-core.h"
41105
41106 static dev_t rtc_devt;
41107 @@ -345,6 +346,8 @@ static long rtc_dev_ioctl(struct file *file,
41108 if (copy_from_user(&tm, uarg, sizeof(tm)))
41109 return -EFAULT;
41110
41111 + gr_log_timechange();
41112 +
41113 return rtc_set_time(rtc, &tm);
41114
41115 case RTC_PIE_ON:
41116 diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c
41117 index e0d0ba4..3c65868 100644
41118 --- a/drivers/rtc/rtc-ds1307.c
41119 +++ b/drivers/rtc/rtc-ds1307.c
41120 @@ -106,7 +106,7 @@ struct ds1307 {
41121 u8 offset; /* register's offset */
41122 u8 regs[11];
41123 u16 nvram_offset;
41124 - struct bin_attribute *nvram;
41125 + bin_attribute_no_const *nvram;
41126 enum ds_type type;
41127 unsigned long flags;
41128 #define HAS_NVRAM 0 /* bit 0 == sysfs file active */
41129 diff --git a/drivers/rtc/rtc-m48t59.c b/drivers/rtc/rtc-m48t59.c
41130 index 130f29a..6179d03 100644
41131 --- a/drivers/rtc/rtc-m48t59.c
41132 +++ b/drivers/rtc/rtc-m48t59.c
41133 @@ -482,7 +482,9 @@ static int m48t59_rtc_probe(struct platform_device *pdev)
41134 goto out;
41135 }
41136
41137 - m48t59_nvram_attr.size = pdata->offset;
41138 + pax_open_kernel();
41139 + *(size_t *)&m48t59_nvram_attr.size = pdata->offset;
41140 + pax_close_kernel();
41141
41142 ret = sysfs_create_bin_file(&pdev->dev.kobj, &m48t59_nvram_attr);
41143 if (ret) {
41144 diff --git a/drivers/scsi/bfa/bfa_fcpim.h b/drivers/scsi/bfa/bfa_fcpim.h
41145 index e693af6..2e525b6 100644
41146 --- a/drivers/scsi/bfa/bfa_fcpim.h
41147 +++ b/drivers/scsi/bfa/bfa_fcpim.h
41148 @@ -36,7 +36,7 @@ struct bfa_iotag_s {
41149
41150 struct bfa_itn_s {
41151 bfa_isr_func_t isr;
41152 -};
41153 +} __no_const;
41154
41155 void bfa_itn_create(struct bfa_s *bfa, struct bfa_rport_s *rport,
41156 void (*isr)(struct bfa_s *bfa, struct bfi_msg_s *m));
41157 diff --git a/drivers/scsi/bfa/bfa_ioc.h b/drivers/scsi/bfa/bfa_ioc.h
41158 index 23a90e7..9cf04ee 100644
41159 --- a/drivers/scsi/bfa/bfa_ioc.h
41160 +++ b/drivers/scsi/bfa/bfa_ioc.h
41161 @@ -258,7 +258,7 @@ struct bfa_ioc_cbfn_s {
41162 bfa_ioc_disable_cbfn_t disable_cbfn;
41163 bfa_ioc_hbfail_cbfn_t hbfail_cbfn;
41164 bfa_ioc_reset_cbfn_t reset_cbfn;
41165 -};
41166 +} __no_const;
41167
41168 /*
41169 * IOC event notification mechanism.
41170 @@ -346,7 +346,7 @@ struct bfa_ioc_hwif_s {
41171 void (*ioc_sync_ack) (struct bfa_ioc_s *ioc);
41172 bfa_boolean_t (*ioc_sync_complete) (struct bfa_ioc_s *ioc);
41173 bfa_boolean_t (*ioc_lpu_read_stat) (struct bfa_ioc_s *ioc);
41174 -};
41175 +} __no_const;
41176
41177 /*
41178 * Queue element to wait for room in request queue. FIFO order is
41179 diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c
41180 index 593085a..47aa999 100644
41181 --- a/drivers/scsi/hosts.c
41182 +++ b/drivers/scsi/hosts.c
41183 @@ -42,7 +42,7 @@
41184 #include "scsi_logging.h"
41185
41186
41187 -static atomic_t scsi_host_next_hn = ATOMIC_INIT(0); /* host_no for next new host */
41188 +static atomic_unchecked_t scsi_host_next_hn = ATOMIC_INIT(0); /* host_no for next new host */
41189
41190
41191 static void scsi_host_cls_release(struct device *dev)
41192 @@ -361,7 +361,7 @@ struct Scsi_Host *scsi_host_alloc(struct scsi_host_template *sht, int privsize)
41193 * subtract one because we increment first then return, but we need to
41194 * know what the next host number was before increment
41195 */
41196 - shost->host_no = atomic_inc_return(&scsi_host_next_hn) - 1;
41197 + shost->host_no = atomic_inc_return_unchecked(&scsi_host_next_hn) - 1;
41198 shost->dma_channel = 0xff;
41199
41200 /* These three are default values which can be overridden */
41201 diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
41202 index 4f33806..afd6f60 100644
41203 --- a/drivers/scsi/hpsa.c
41204 +++ b/drivers/scsi/hpsa.c
41205 @@ -554,7 +554,7 @@ static inline u32 next_command(struct ctlr_info *h, u8 q)
41206 unsigned long flags;
41207
41208 if (unlikely(!(h->transMethod & CFGTBL_Trans_Performant)))
41209 - return h->access.command_completed(h, q);
41210 + return h->access->command_completed(h, q);
41211
41212 if ((rq->head[rq->current_entry] & 1) == rq->wraparound) {
41213 a = rq->head[rq->current_entry];
41214 @@ -3374,7 +3374,7 @@ static void start_io(struct ctlr_info *h)
41215 while (!list_empty(&h->reqQ)) {
41216 c = list_entry(h->reqQ.next, struct CommandList, list);
41217 /* can't do anything if fifo is full */
41218 - if ((h->access.fifo_full(h))) {
41219 + if ((h->access->fifo_full(h))) {
41220 dev_warn(&h->pdev->dev, "fifo full\n");
41221 break;
41222 }
41223 @@ -3396,7 +3396,7 @@ static void start_io(struct ctlr_info *h)
41224
41225 /* Tell the controller execute command */
41226 spin_unlock_irqrestore(&h->lock, flags);
41227 - h->access.submit_command(h, c);
41228 + h->access->submit_command(h, c);
41229 spin_lock_irqsave(&h->lock, flags);
41230 }
41231 spin_unlock_irqrestore(&h->lock, flags);
41232 @@ -3404,17 +3404,17 @@ static void start_io(struct ctlr_info *h)
41233
41234 static inline unsigned long get_next_completion(struct ctlr_info *h, u8 q)
41235 {
41236 - return h->access.command_completed(h, q);
41237 + return h->access->command_completed(h, q);
41238 }
41239
41240 static inline bool interrupt_pending(struct ctlr_info *h)
41241 {
41242 - return h->access.intr_pending(h);
41243 + return h->access->intr_pending(h);
41244 }
41245
41246 static inline long interrupt_not_for_us(struct ctlr_info *h)
41247 {
41248 - return (h->access.intr_pending(h) == 0) ||
41249 + return (h->access->intr_pending(h) == 0) ||
41250 (h->interrupts_enabled == 0);
41251 }
41252
41253 @@ -4316,7 +4316,7 @@ static int hpsa_pci_init(struct ctlr_info *h)
41254 if (prod_index < 0)
41255 return -ENODEV;
41256 h->product_name = products[prod_index].product_name;
41257 - h->access = *(products[prod_index].access);
41258 + h->access = products[prod_index].access;
41259
41260 pci_disable_link_state(h->pdev, PCIE_LINK_STATE_L0S |
41261 PCIE_LINK_STATE_L1 | PCIE_LINK_STATE_CLKPM);
41262 @@ -4598,7 +4598,7 @@ static void controller_lockup_detected(struct ctlr_info *h)
41263
41264 assert_spin_locked(&lockup_detector_lock);
41265 remove_ctlr_from_lockup_detector_list(h);
41266 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
41267 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
41268 spin_lock_irqsave(&h->lock, flags);
41269 h->lockup_detected = readl(h->vaddr + SA5_SCRATCHPAD_OFFSET);
41270 spin_unlock_irqrestore(&h->lock, flags);
41271 @@ -4775,7 +4775,7 @@ reinit_after_soft_reset:
41272 }
41273
41274 /* make sure the board interrupts are off */
41275 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
41276 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
41277
41278 if (hpsa_request_irq(h, do_hpsa_intr_msi, do_hpsa_intr_intx))
41279 goto clean2;
41280 @@ -4809,7 +4809,7 @@ reinit_after_soft_reset:
41281 * fake ones to scoop up any residual completions.
41282 */
41283 spin_lock_irqsave(&h->lock, flags);
41284 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
41285 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
41286 spin_unlock_irqrestore(&h->lock, flags);
41287 free_irqs(h);
41288 rc = hpsa_request_irq(h, hpsa_msix_discard_completions,
41289 @@ -4828,9 +4828,9 @@ reinit_after_soft_reset:
41290 dev_info(&h->pdev->dev, "Board READY.\n");
41291 dev_info(&h->pdev->dev,
41292 "Waiting for stale completions to drain.\n");
41293 - h->access.set_intr_mask(h, HPSA_INTR_ON);
41294 + h->access->set_intr_mask(h, HPSA_INTR_ON);
41295 msleep(10000);
41296 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
41297 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
41298
41299 rc = controller_reset_failed(h->cfgtable);
41300 if (rc)
41301 @@ -4851,7 +4851,7 @@ reinit_after_soft_reset:
41302 }
41303
41304 /* Turn the interrupts on so we can service requests */
41305 - h->access.set_intr_mask(h, HPSA_INTR_ON);
41306 + h->access->set_intr_mask(h, HPSA_INTR_ON);
41307
41308 hpsa_hba_inquiry(h);
41309 hpsa_register_scsi(h); /* hook ourselves into SCSI subsystem */
41310 @@ -4903,7 +4903,7 @@ static void hpsa_shutdown(struct pci_dev *pdev)
41311 * To write all data in the battery backed cache to disks
41312 */
41313 hpsa_flush_cache(h);
41314 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
41315 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
41316 hpsa_free_irqs_and_disable_msix(h);
41317 }
41318
41319 @@ -5071,7 +5071,7 @@ static void hpsa_enter_performant_mode(struct ctlr_info *h, u32 use_short_tags)
41320 return;
41321 }
41322 /* Change the access methods to the performant access methods */
41323 - h->access = SA5_performant_access;
41324 + h->access = &SA5_performant_access;
41325 h->transMethod = CFGTBL_Trans_Performant;
41326 }
41327
41328 diff --git a/drivers/scsi/hpsa.h b/drivers/scsi/hpsa.h
41329 index 9816479..c5d4e97 100644
41330 --- a/drivers/scsi/hpsa.h
41331 +++ b/drivers/scsi/hpsa.h
41332 @@ -79,7 +79,7 @@ struct ctlr_info {
41333 unsigned int msix_vector;
41334 unsigned int msi_vector;
41335 int intr_mode; /* either PERF_MODE_INT or SIMPLE_MODE_INT */
41336 - struct access_method access;
41337 + struct access_method *access;
41338
41339 /* queue and queue Info */
41340 struct list_head reqQ;
41341 diff --git a/drivers/scsi/libfc/fc_exch.c b/drivers/scsi/libfc/fc_exch.c
41342 index c772d8d..35c362c 100644
41343 --- a/drivers/scsi/libfc/fc_exch.c
41344 +++ b/drivers/scsi/libfc/fc_exch.c
41345 @@ -100,12 +100,12 @@ struct fc_exch_mgr {
41346 u16 pool_max_index;
41347
41348 struct {
41349 - atomic_t no_free_exch;
41350 - atomic_t no_free_exch_xid;
41351 - atomic_t xid_not_found;
41352 - atomic_t xid_busy;
41353 - atomic_t seq_not_found;
41354 - atomic_t non_bls_resp;
41355 + atomic_unchecked_t no_free_exch;
41356 + atomic_unchecked_t no_free_exch_xid;
41357 + atomic_unchecked_t xid_not_found;
41358 + atomic_unchecked_t xid_busy;
41359 + atomic_unchecked_t seq_not_found;
41360 + atomic_unchecked_t non_bls_resp;
41361 } stats;
41362 };
41363
41364 @@ -725,7 +725,7 @@ static struct fc_exch *fc_exch_em_alloc(struct fc_lport *lport,
41365 /* allocate memory for exchange */
41366 ep = mempool_alloc(mp->ep_pool, GFP_ATOMIC);
41367 if (!ep) {
41368 - atomic_inc(&mp->stats.no_free_exch);
41369 + atomic_inc_unchecked(&mp->stats.no_free_exch);
41370 goto out;
41371 }
41372 memset(ep, 0, sizeof(*ep));
41373 @@ -786,7 +786,7 @@ out:
41374 return ep;
41375 err:
41376 spin_unlock_bh(&pool->lock);
41377 - atomic_inc(&mp->stats.no_free_exch_xid);
41378 + atomic_inc_unchecked(&mp->stats.no_free_exch_xid);
41379 mempool_free(ep, mp->ep_pool);
41380 return NULL;
41381 }
41382 @@ -929,7 +929,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
41383 xid = ntohs(fh->fh_ox_id); /* we originated exch */
41384 ep = fc_exch_find(mp, xid);
41385 if (!ep) {
41386 - atomic_inc(&mp->stats.xid_not_found);
41387 + atomic_inc_unchecked(&mp->stats.xid_not_found);
41388 reject = FC_RJT_OX_ID;
41389 goto out;
41390 }
41391 @@ -959,7 +959,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
41392 ep = fc_exch_find(mp, xid);
41393 if ((f_ctl & FC_FC_FIRST_SEQ) && fc_sof_is_init(fr_sof(fp))) {
41394 if (ep) {
41395 - atomic_inc(&mp->stats.xid_busy);
41396 + atomic_inc_unchecked(&mp->stats.xid_busy);
41397 reject = FC_RJT_RX_ID;
41398 goto rel;
41399 }
41400 @@ -970,7 +970,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
41401 }
41402 xid = ep->xid; /* get our XID */
41403 } else if (!ep) {
41404 - atomic_inc(&mp->stats.xid_not_found);
41405 + atomic_inc_unchecked(&mp->stats.xid_not_found);
41406 reject = FC_RJT_RX_ID; /* XID not found */
41407 goto out;
41408 }
41409 @@ -987,7 +987,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
41410 } else {
41411 sp = &ep->seq;
41412 if (sp->id != fh->fh_seq_id) {
41413 - atomic_inc(&mp->stats.seq_not_found);
41414 + atomic_inc_unchecked(&mp->stats.seq_not_found);
41415 if (f_ctl & FC_FC_END_SEQ) {
41416 /*
41417 * Update sequence_id based on incoming last
41418 @@ -1437,22 +1437,22 @@ static void fc_exch_recv_seq_resp(struct fc_exch_mgr *mp, struct fc_frame *fp)
41419
41420 ep = fc_exch_find(mp, ntohs(fh->fh_ox_id));
41421 if (!ep) {
41422 - atomic_inc(&mp->stats.xid_not_found);
41423 + atomic_inc_unchecked(&mp->stats.xid_not_found);
41424 goto out;
41425 }
41426 if (ep->esb_stat & ESB_ST_COMPLETE) {
41427 - atomic_inc(&mp->stats.xid_not_found);
41428 + atomic_inc_unchecked(&mp->stats.xid_not_found);
41429 goto rel;
41430 }
41431 if (ep->rxid == FC_XID_UNKNOWN)
41432 ep->rxid = ntohs(fh->fh_rx_id);
41433 if (ep->sid != 0 && ep->sid != ntoh24(fh->fh_d_id)) {
41434 - atomic_inc(&mp->stats.xid_not_found);
41435 + atomic_inc_unchecked(&mp->stats.xid_not_found);
41436 goto rel;
41437 }
41438 if (ep->did != ntoh24(fh->fh_s_id) &&
41439 ep->did != FC_FID_FLOGI) {
41440 - atomic_inc(&mp->stats.xid_not_found);
41441 + atomic_inc_unchecked(&mp->stats.xid_not_found);
41442 goto rel;
41443 }
41444 sof = fr_sof(fp);
41445 @@ -1461,7 +1461,7 @@ static void fc_exch_recv_seq_resp(struct fc_exch_mgr *mp, struct fc_frame *fp)
41446 sp->ssb_stat |= SSB_ST_RESP;
41447 sp->id = fh->fh_seq_id;
41448 } else if (sp->id != fh->fh_seq_id) {
41449 - atomic_inc(&mp->stats.seq_not_found);
41450 + atomic_inc_unchecked(&mp->stats.seq_not_found);
41451 goto rel;
41452 }
41453
41454 @@ -1525,9 +1525,9 @@ static void fc_exch_recv_resp(struct fc_exch_mgr *mp, struct fc_frame *fp)
41455 sp = fc_seq_lookup_orig(mp, fp); /* doesn't hold sequence */
41456
41457 if (!sp)
41458 - atomic_inc(&mp->stats.xid_not_found);
41459 + atomic_inc_unchecked(&mp->stats.xid_not_found);
41460 else
41461 - atomic_inc(&mp->stats.non_bls_resp);
41462 + atomic_inc_unchecked(&mp->stats.non_bls_resp);
41463
41464 fc_frame_free(fp);
41465 }
41466 @@ -2174,13 +2174,13 @@ void fc_exch_update_stats(struct fc_lport *lport)
41467
41468 list_for_each_entry(ema, &lport->ema_list, ema_list) {
41469 mp = ema->mp;
41470 - st->fc_no_free_exch += atomic_read(&mp->stats.no_free_exch);
41471 + st->fc_no_free_exch += atomic_read_unchecked(&mp->stats.no_free_exch);
41472 st->fc_no_free_exch_xid +=
41473 - atomic_read(&mp->stats.no_free_exch_xid);
41474 - st->fc_xid_not_found += atomic_read(&mp->stats.xid_not_found);
41475 - st->fc_xid_busy += atomic_read(&mp->stats.xid_busy);
41476 - st->fc_seq_not_found += atomic_read(&mp->stats.seq_not_found);
41477 - st->fc_non_bls_resp += atomic_read(&mp->stats.non_bls_resp);
41478 + atomic_read_unchecked(&mp->stats.no_free_exch_xid);
41479 + st->fc_xid_not_found += atomic_read_unchecked(&mp->stats.xid_not_found);
41480 + st->fc_xid_busy += atomic_read_unchecked(&mp->stats.xid_busy);
41481 + st->fc_seq_not_found += atomic_read_unchecked(&mp->stats.seq_not_found);
41482 + st->fc_non_bls_resp += atomic_read_unchecked(&mp->stats.non_bls_resp);
41483 }
41484 }
41485 EXPORT_SYMBOL(fc_exch_update_stats);
41486 diff --git a/drivers/scsi/libsas/sas_ata.c b/drivers/scsi/libsas/sas_ata.c
41487 index bdb81cd..d3c7c2c 100644
41488 --- a/drivers/scsi/libsas/sas_ata.c
41489 +++ b/drivers/scsi/libsas/sas_ata.c
41490 @@ -554,7 +554,7 @@ static struct ata_port_operations sas_sata_ops = {
41491 .postreset = ata_std_postreset,
41492 .error_handler = ata_std_error_handler,
41493 .post_internal_cmd = sas_ata_post_internal,
41494 - .qc_defer = ata_std_qc_defer,
41495 + .qc_defer = ata_std_qc_defer,
41496 .qc_prep = ata_noop_qc_prep,
41497 .qc_issue = sas_ata_qc_issue,
41498 .qc_fill_rtf = sas_ata_qc_fill_rtf,
41499 diff --git a/drivers/scsi/lpfc/lpfc.h b/drivers/scsi/lpfc/lpfc.h
41500 index df4c13a..a51e90c 100644
41501 --- a/drivers/scsi/lpfc/lpfc.h
41502 +++ b/drivers/scsi/lpfc/lpfc.h
41503 @@ -424,7 +424,7 @@ struct lpfc_vport {
41504 struct dentry *debug_nodelist;
41505 struct dentry *vport_debugfs_root;
41506 struct lpfc_debugfs_trc *disc_trc;
41507 - atomic_t disc_trc_cnt;
41508 + atomic_unchecked_t disc_trc_cnt;
41509 #endif
41510 uint8_t stat_data_enabled;
41511 uint8_t stat_data_blocked;
41512 @@ -842,8 +842,8 @@ struct lpfc_hba {
41513 struct timer_list fabric_block_timer;
41514 unsigned long bit_flags;
41515 #define FABRIC_COMANDS_BLOCKED 0
41516 - atomic_t num_rsrc_err;
41517 - atomic_t num_cmd_success;
41518 + atomic_unchecked_t num_rsrc_err;
41519 + atomic_unchecked_t num_cmd_success;
41520 unsigned long last_rsrc_error_time;
41521 unsigned long last_ramp_down_time;
41522 unsigned long last_ramp_up_time;
41523 @@ -879,7 +879,7 @@ struct lpfc_hba {
41524
41525 struct dentry *debug_slow_ring_trc;
41526 struct lpfc_debugfs_trc *slow_ring_trc;
41527 - atomic_t slow_ring_trc_cnt;
41528 + atomic_unchecked_t slow_ring_trc_cnt;
41529 /* iDiag debugfs sub-directory */
41530 struct dentry *idiag_root;
41531 struct dentry *idiag_pci_cfg;
41532 diff --git a/drivers/scsi/lpfc/lpfc_debugfs.c b/drivers/scsi/lpfc/lpfc_debugfs.c
41533 index f63f5ff..de29189 100644
41534 --- a/drivers/scsi/lpfc/lpfc_debugfs.c
41535 +++ b/drivers/scsi/lpfc/lpfc_debugfs.c
41536 @@ -106,7 +106,7 @@ MODULE_PARM_DESC(lpfc_debugfs_mask_disc_trc,
41537
41538 #include <linux/debugfs.h>
41539
41540 -static atomic_t lpfc_debugfs_seq_trc_cnt = ATOMIC_INIT(0);
41541 +static atomic_unchecked_t lpfc_debugfs_seq_trc_cnt = ATOMIC_INIT(0);
41542 static unsigned long lpfc_debugfs_start_time = 0L;
41543
41544 /* iDiag */
41545 @@ -147,7 +147,7 @@ lpfc_debugfs_disc_trc_data(struct lpfc_vport *vport, char *buf, int size)
41546 lpfc_debugfs_enable = 0;
41547
41548 len = 0;
41549 - index = (atomic_read(&vport->disc_trc_cnt) + 1) &
41550 + index = (atomic_read_unchecked(&vport->disc_trc_cnt) + 1) &
41551 (lpfc_debugfs_max_disc_trc - 1);
41552 for (i = index; i < lpfc_debugfs_max_disc_trc; i++) {
41553 dtp = vport->disc_trc + i;
41554 @@ -213,7 +213,7 @@ lpfc_debugfs_slow_ring_trc_data(struct lpfc_hba *phba, char *buf, int size)
41555 lpfc_debugfs_enable = 0;
41556
41557 len = 0;
41558 - index = (atomic_read(&phba->slow_ring_trc_cnt) + 1) &
41559 + index = (atomic_read_unchecked(&phba->slow_ring_trc_cnt) + 1) &
41560 (lpfc_debugfs_max_slow_ring_trc - 1);
41561 for (i = index; i < lpfc_debugfs_max_slow_ring_trc; i++) {
41562 dtp = phba->slow_ring_trc + i;
41563 @@ -646,14 +646,14 @@ lpfc_debugfs_disc_trc(struct lpfc_vport *vport, int mask, char *fmt,
41564 !vport || !vport->disc_trc)
41565 return;
41566
41567 - index = atomic_inc_return(&vport->disc_trc_cnt) &
41568 + index = atomic_inc_return_unchecked(&vport->disc_trc_cnt) &
41569 (lpfc_debugfs_max_disc_trc - 1);
41570 dtp = vport->disc_trc + index;
41571 dtp->fmt = fmt;
41572 dtp->data1 = data1;
41573 dtp->data2 = data2;
41574 dtp->data3 = data3;
41575 - dtp->seq_cnt = atomic_inc_return(&lpfc_debugfs_seq_trc_cnt);
41576 + dtp->seq_cnt = atomic_inc_return_unchecked(&lpfc_debugfs_seq_trc_cnt);
41577 dtp->jif = jiffies;
41578 #endif
41579 return;
41580 @@ -684,14 +684,14 @@ lpfc_debugfs_slow_ring_trc(struct lpfc_hba *phba, char *fmt,
41581 !phba || !phba->slow_ring_trc)
41582 return;
41583
41584 - index = atomic_inc_return(&phba->slow_ring_trc_cnt) &
41585 + index = atomic_inc_return_unchecked(&phba->slow_ring_trc_cnt) &
41586 (lpfc_debugfs_max_slow_ring_trc - 1);
41587 dtp = phba->slow_ring_trc + index;
41588 dtp->fmt = fmt;
41589 dtp->data1 = data1;
41590 dtp->data2 = data2;
41591 dtp->data3 = data3;
41592 - dtp->seq_cnt = atomic_inc_return(&lpfc_debugfs_seq_trc_cnt);
41593 + dtp->seq_cnt = atomic_inc_return_unchecked(&lpfc_debugfs_seq_trc_cnt);
41594 dtp->jif = jiffies;
41595 #endif
41596 return;
41597 @@ -4182,7 +4182,7 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport)
41598 "slow_ring buffer\n");
41599 goto debug_failed;
41600 }
41601 - atomic_set(&phba->slow_ring_trc_cnt, 0);
41602 + atomic_set_unchecked(&phba->slow_ring_trc_cnt, 0);
41603 memset(phba->slow_ring_trc, 0,
41604 (sizeof(struct lpfc_debugfs_trc) *
41605 lpfc_debugfs_max_slow_ring_trc));
41606 @@ -4228,7 +4228,7 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport)
41607 "buffer\n");
41608 goto debug_failed;
41609 }
41610 - atomic_set(&vport->disc_trc_cnt, 0);
41611 + atomic_set_unchecked(&vport->disc_trc_cnt, 0);
41612
41613 snprintf(name, sizeof(name), "discovery_trace");
41614 vport->debug_disc_trc =
41615 diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c
41616 index 89ad558..76956c4 100644
41617 --- a/drivers/scsi/lpfc/lpfc_init.c
41618 +++ b/drivers/scsi/lpfc/lpfc_init.c
41619 @@ -10618,8 +10618,10 @@ lpfc_init(void)
41620 "misc_register returned with status %d", error);
41621
41622 if (lpfc_enable_npiv) {
41623 - lpfc_transport_functions.vport_create = lpfc_vport_create;
41624 - lpfc_transport_functions.vport_delete = lpfc_vport_delete;
41625 + pax_open_kernel();
41626 + *(void **)&lpfc_transport_functions.vport_create = lpfc_vport_create;
41627 + *(void **)&lpfc_transport_functions.vport_delete = lpfc_vport_delete;
41628 + pax_close_kernel();
41629 }
41630 lpfc_transport_template =
41631 fc_attach_transport(&lpfc_transport_functions);
41632 diff --git a/drivers/scsi/lpfc/lpfc_scsi.c b/drivers/scsi/lpfc/lpfc_scsi.c
41633 index 60e5a17..ff7a793 100644
41634 --- a/drivers/scsi/lpfc/lpfc_scsi.c
41635 +++ b/drivers/scsi/lpfc/lpfc_scsi.c
41636 @@ -305,7 +305,7 @@ lpfc_rampdown_queue_depth(struct lpfc_hba *phba)
41637 uint32_t evt_posted;
41638
41639 spin_lock_irqsave(&phba->hbalock, flags);
41640 - atomic_inc(&phba->num_rsrc_err);
41641 + atomic_inc_unchecked(&phba->num_rsrc_err);
41642 phba->last_rsrc_error_time = jiffies;
41643
41644 if ((phba->last_ramp_down_time + QUEUE_RAMP_DOWN_INTERVAL) > jiffies) {
41645 @@ -346,7 +346,7 @@ lpfc_rampup_queue_depth(struct lpfc_vport *vport,
41646 unsigned long flags;
41647 struct lpfc_hba *phba = vport->phba;
41648 uint32_t evt_posted;
41649 - atomic_inc(&phba->num_cmd_success);
41650 + atomic_inc_unchecked(&phba->num_cmd_success);
41651
41652 if (vport->cfg_lun_queue_depth <= queue_depth)
41653 return;
41654 @@ -390,8 +390,8 @@ lpfc_ramp_down_queue_handler(struct lpfc_hba *phba)
41655 unsigned long num_rsrc_err, num_cmd_success;
41656 int i;
41657
41658 - num_rsrc_err = atomic_read(&phba->num_rsrc_err);
41659 - num_cmd_success = atomic_read(&phba->num_cmd_success);
41660 + num_rsrc_err = atomic_read_unchecked(&phba->num_rsrc_err);
41661 + num_cmd_success = atomic_read_unchecked(&phba->num_cmd_success);
41662
41663 /*
41664 * The error and success command counters are global per
41665 @@ -419,8 +419,8 @@ lpfc_ramp_down_queue_handler(struct lpfc_hba *phba)
41666 }
41667 }
41668 lpfc_destroy_vport_work_array(phba, vports);
41669 - atomic_set(&phba->num_rsrc_err, 0);
41670 - atomic_set(&phba->num_cmd_success, 0);
41671 + atomic_set_unchecked(&phba->num_rsrc_err, 0);
41672 + atomic_set_unchecked(&phba->num_cmd_success, 0);
41673 }
41674
41675 /**
41676 @@ -454,8 +454,8 @@ lpfc_ramp_up_queue_handler(struct lpfc_hba *phba)
41677 }
41678 }
41679 lpfc_destroy_vport_work_array(phba, vports);
41680 - atomic_set(&phba->num_rsrc_err, 0);
41681 - atomic_set(&phba->num_cmd_success, 0);
41682 + atomic_set_unchecked(&phba->num_rsrc_err, 0);
41683 + atomic_set_unchecked(&phba->num_cmd_success, 0);
41684 }
41685
41686 /**
41687 diff --git a/drivers/scsi/pmcraid.c b/drivers/scsi/pmcraid.c
41688 index b46f5e9..c4c4ccb 100644
41689 --- a/drivers/scsi/pmcraid.c
41690 +++ b/drivers/scsi/pmcraid.c
41691 @@ -200,8 +200,8 @@ static int pmcraid_slave_alloc(struct scsi_device *scsi_dev)
41692 res->scsi_dev = scsi_dev;
41693 scsi_dev->hostdata = res;
41694 res->change_detected = 0;
41695 - atomic_set(&res->read_failures, 0);
41696 - atomic_set(&res->write_failures, 0);
41697 + atomic_set_unchecked(&res->read_failures, 0);
41698 + atomic_set_unchecked(&res->write_failures, 0);
41699 rc = 0;
41700 }
41701 spin_unlock_irqrestore(&pinstance->resource_lock, lock_flags);
41702 @@ -2676,9 +2676,9 @@ static int pmcraid_error_handler(struct pmcraid_cmd *cmd)
41703
41704 /* If this was a SCSI read/write command keep count of errors */
41705 if (SCSI_CMD_TYPE(scsi_cmd->cmnd[0]) == SCSI_READ_CMD)
41706 - atomic_inc(&res->read_failures);
41707 + atomic_inc_unchecked(&res->read_failures);
41708 else if (SCSI_CMD_TYPE(scsi_cmd->cmnd[0]) == SCSI_WRITE_CMD)
41709 - atomic_inc(&res->write_failures);
41710 + atomic_inc_unchecked(&res->write_failures);
41711
41712 if (!RES_IS_GSCSI(res->cfg_entry) &&
41713 masked_ioasc != PMCRAID_IOASC_HW_DEVICE_BUS_STATUS_ERROR) {
41714 @@ -3534,7 +3534,7 @@ static int pmcraid_queuecommand_lck(
41715 * block of scsi_cmd which is re-used (e.g. cancel/abort), which uses
41716 * hrrq_id assigned here in queuecommand
41717 */
41718 - ioarcb->hrrq_id = atomic_add_return(1, &(pinstance->last_message_id)) %
41719 + ioarcb->hrrq_id = atomic_add_return_unchecked(1, &(pinstance->last_message_id)) %
41720 pinstance->num_hrrq;
41721 cmd->cmd_done = pmcraid_io_done;
41722
41723 @@ -3859,7 +3859,7 @@ static long pmcraid_ioctl_passthrough(
41724 * block of scsi_cmd which is re-used (e.g. cancel/abort), which uses
41725 * hrrq_id assigned here in queuecommand
41726 */
41727 - ioarcb->hrrq_id = atomic_add_return(1, &(pinstance->last_message_id)) %
41728 + ioarcb->hrrq_id = atomic_add_return_unchecked(1, &(pinstance->last_message_id)) %
41729 pinstance->num_hrrq;
41730
41731 if (request_size) {
41732 @@ -4497,7 +4497,7 @@ static void pmcraid_worker_function(struct work_struct *workp)
41733
41734 pinstance = container_of(workp, struct pmcraid_instance, worker_q);
41735 /* add resources only after host is added into system */
41736 - if (!atomic_read(&pinstance->expose_resources))
41737 + if (!atomic_read_unchecked(&pinstance->expose_resources))
41738 return;
41739
41740 fw_version = be16_to_cpu(pinstance->inq_data->fw_version);
41741 @@ -5324,8 +5324,8 @@ static int pmcraid_init_instance(struct pci_dev *pdev, struct Scsi_Host *host,
41742 init_waitqueue_head(&pinstance->reset_wait_q);
41743
41744 atomic_set(&pinstance->outstanding_cmds, 0);
41745 - atomic_set(&pinstance->last_message_id, 0);
41746 - atomic_set(&pinstance->expose_resources, 0);
41747 + atomic_set_unchecked(&pinstance->last_message_id, 0);
41748 + atomic_set_unchecked(&pinstance->expose_resources, 0);
41749
41750 INIT_LIST_HEAD(&pinstance->free_res_q);
41751 INIT_LIST_HEAD(&pinstance->used_res_q);
41752 @@ -6038,7 +6038,7 @@ static int pmcraid_probe(struct pci_dev *pdev,
41753 /* Schedule worker thread to handle CCN and take care of adding and
41754 * removing devices to OS
41755 */
41756 - atomic_set(&pinstance->expose_resources, 1);
41757 + atomic_set_unchecked(&pinstance->expose_resources, 1);
41758 schedule_work(&pinstance->worker_q);
41759 return rc;
41760
41761 diff --git a/drivers/scsi/pmcraid.h b/drivers/scsi/pmcraid.h
41762 index e1d150f..6c6df44 100644
41763 --- a/drivers/scsi/pmcraid.h
41764 +++ b/drivers/scsi/pmcraid.h
41765 @@ -748,7 +748,7 @@ struct pmcraid_instance {
41766 struct pmcraid_isr_param hrrq_vector[PMCRAID_NUM_MSIX_VECTORS];
41767
41768 /* Message id as filled in last fired IOARCB, used to identify HRRQ */
41769 - atomic_t last_message_id;
41770 + atomic_unchecked_t last_message_id;
41771
41772 /* configuration table */
41773 struct pmcraid_config_table *cfg_table;
41774 @@ -777,7 +777,7 @@ struct pmcraid_instance {
41775 atomic_t outstanding_cmds;
41776
41777 /* should add/delete resources to mid-layer now ?*/
41778 - atomic_t expose_resources;
41779 + atomic_unchecked_t expose_resources;
41780
41781
41782
41783 @@ -813,8 +813,8 @@ struct pmcraid_resource_entry {
41784 struct pmcraid_config_table_entry_ext cfg_entry_ext;
41785 };
41786 struct scsi_device *scsi_dev; /* Link scsi_device structure */
41787 - atomic_t read_failures; /* count of failed READ commands */
41788 - atomic_t write_failures; /* count of failed WRITE commands */
41789 + atomic_unchecked_t read_failures; /* count of failed READ commands */
41790 + atomic_unchecked_t write_failures; /* count of failed WRITE commands */
41791
41792 /* To indicate add/delete/modify during CCN */
41793 u8 change_detected;
41794 diff --git a/drivers/scsi/qla2xxx/qla_attr.c b/drivers/scsi/qla2xxx/qla_attr.c
41795 index 83d7984..a27d947 100644
41796 --- a/drivers/scsi/qla2xxx/qla_attr.c
41797 +++ b/drivers/scsi/qla2xxx/qla_attr.c
41798 @@ -1969,7 +1969,7 @@ qla24xx_vport_disable(struct fc_vport *fc_vport, bool disable)
41799 return 0;
41800 }
41801
41802 -struct fc_function_template qla2xxx_transport_functions = {
41803 +fc_function_template_no_const qla2xxx_transport_functions = {
41804
41805 .show_host_node_name = 1,
41806 .show_host_port_name = 1,
41807 @@ -2016,7 +2016,7 @@ struct fc_function_template qla2xxx_transport_functions = {
41808 .bsg_timeout = qla24xx_bsg_timeout,
41809 };
41810
41811 -struct fc_function_template qla2xxx_transport_vport_functions = {
41812 +fc_function_template_no_const qla2xxx_transport_vport_functions = {
41813
41814 .show_host_node_name = 1,
41815 .show_host_port_name = 1,
41816 diff --git a/drivers/scsi/qla2xxx/qla_gbl.h b/drivers/scsi/qla2xxx/qla_gbl.h
41817 index 2411d1a..4673766 100644
41818 --- a/drivers/scsi/qla2xxx/qla_gbl.h
41819 +++ b/drivers/scsi/qla2xxx/qla_gbl.h
41820 @@ -515,8 +515,8 @@ extern void qla2x00_get_sym_node_name(scsi_qla_host_t *, uint8_t *);
41821 struct device_attribute;
41822 extern struct device_attribute *qla2x00_host_attrs[];
41823 struct fc_function_template;
41824 -extern struct fc_function_template qla2xxx_transport_functions;
41825 -extern struct fc_function_template qla2xxx_transport_vport_functions;
41826 +extern fc_function_template_no_const qla2xxx_transport_functions;
41827 +extern fc_function_template_no_const qla2xxx_transport_vport_functions;
41828 extern void qla2x00_alloc_sysfs_attr(scsi_qla_host_t *);
41829 extern void qla2x00_free_sysfs_attr(scsi_qla_host_t *);
41830 extern void qla2x00_init_host_attr(scsi_qla_host_t *);
41831 diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
41832 index 10d23f8..a7d5d4c 100644
41833 --- a/drivers/scsi/qla2xxx/qla_os.c
41834 +++ b/drivers/scsi/qla2xxx/qla_os.c
41835 @@ -1472,8 +1472,10 @@ qla2x00_config_dma_addressing(struct qla_hw_data *ha)
41836 !pci_set_consistent_dma_mask(ha->pdev, DMA_BIT_MASK(64))) {
41837 /* Ok, a 64bit DMA mask is applicable. */
41838 ha->flags.enable_64bit_addressing = 1;
41839 - ha->isp_ops->calc_req_entries = qla2x00_calc_iocbs_64;
41840 - ha->isp_ops->build_iocbs = qla2x00_build_scsi_iocbs_64;
41841 + pax_open_kernel();
41842 + *(void **)&ha->isp_ops->calc_req_entries = qla2x00_calc_iocbs_64;
41843 + *(void **)&ha->isp_ops->build_iocbs = qla2x00_build_scsi_iocbs_64;
41844 + pax_close_kernel();
41845 return;
41846 }
41847 }
41848 diff --git a/drivers/scsi/qla4xxx/ql4_def.h b/drivers/scsi/qla4xxx/ql4_def.h
41849 index 329d553..f20d31d 100644
41850 --- a/drivers/scsi/qla4xxx/ql4_def.h
41851 +++ b/drivers/scsi/qla4xxx/ql4_def.h
41852 @@ -273,7 +273,7 @@ struct ddb_entry {
41853 * (4000 only) */
41854 atomic_t relogin_timer; /* Max Time to wait for
41855 * relogin to complete */
41856 - atomic_t relogin_retry_count; /* Num of times relogin has been
41857 + atomic_unchecked_t relogin_retry_count; /* Num of times relogin has been
41858 * retried */
41859 uint32_t default_time2wait; /* Default Min time between
41860 * relogins (+aens) */
41861 diff --git a/drivers/scsi/qla4xxx/ql4_os.c b/drivers/scsi/qla4xxx/ql4_os.c
41862 index 4cec123..7c1329f 100644
41863 --- a/drivers/scsi/qla4xxx/ql4_os.c
41864 +++ b/drivers/scsi/qla4xxx/ql4_os.c
41865 @@ -2621,12 +2621,12 @@ static void qla4xxx_check_relogin_flash_ddb(struct iscsi_cls_session *cls_sess)
41866 */
41867 if (!iscsi_is_session_online(cls_sess)) {
41868 /* Reset retry relogin timer */
41869 - atomic_inc(&ddb_entry->relogin_retry_count);
41870 + atomic_inc_unchecked(&ddb_entry->relogin_retry_count);
41871 DEBUG2(ql4_printk(KERN_INFO, ha,
41872 "%s: index[%d] relogin timed out-retrying"
41873 " relogin (%d), retry (%d)\n", __func__,
41874 ddb_entry->fw_ddb_index,
41875 - atomic_read(&ddb_entry->relogin_retry_count),
41876 + atomic_read_unchecked(&ddb_entry->relogin_retry_count),
41877 ddb_entry->default_time2wait + 4));
41878 set_bit(DPC_RELOGIN_DEVICE, &ha->dpc_flags);
41879 atomic_set(&ddb_entry->retry_relogin_timer,
41880 @@ -4738,7 +4738,7 @@ static void qla4xxx_setup_flash_ddb_entry(struct scsi_qla_host *ha,
41881
41882 atomic_set(&ddb_entry->retry_relogin_timer, INVALID_ENTRY);
41883 atomic_set(&ddb_entry->relogin_timer, 0);
41884 - atomic_set(&ddb_entry->relogin_retry_count, 0);
41885 + atomic_set_unchecked(&ddb_entry->relogin_retry_count, 0);
41886 def_timeout = le16_to_cpu(ddb_entry->fw_ddb_entry.def_timeout);
41887 ddb_entry->default_relogin_timeout =
41888 (def_timeout > LOGIN_TOV) && (def_timeout < LOGIN_TOV * 10) ?
41889 diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
41890 index 2c0d0ec..4e8681a 100644
41891 --- a/drivers/scsi/scsi.c
41892 +++ b/drivers/scsi/scsi.c
41893 @@ -661,7 +661,7 @@ int scsi_dispatch_cmd(struct scsi_cmnd *cmd)
41894 unsigned long timeout;
41895 int rtn = 0;
41896
41897 - atomic_inc(&cmd->device->iorequest_cnt);
41898 + atomic_inc_unchecked(&cmd->device->iorequest_cnt);
41899
41900 /* check if the device is still usable */
41901 if (unlikely(cmd->device->sdev_state == SDEV_DEL)) {
41902 diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
41903 index f1bf5af..f67e943 100644
41904 --- a/drivers/scsi/scsi_lib.c
41905 +++ b/drivers/scsi/scsi_lib.c
41906 @@ -1454,7 +1454,7 @@ static void scsi_kill_request(struct request *req, struct request_queue *q)
41907 shost = sdev->host;
41908 scsi_init_cmd_errh(cmd);
41909 cmd->result = DID_NO_CONNECT << 16;
41910 - atomic_inc(&cmd->device->iorequest_cnt);
41911 + atomic_inc_unchecked(&cmd->device->iorequest_cnt);
41912
41913 /*
41914 * SCSI request completion path will do scsi_device_unbusy(),
41915 @@ -1480,9 +1480,9 @@ static void scsi_softirq_done(struct request *rq)
41916
41917 INIT_LIST_HEAD(&cmd->eh_entry);
41918
41919 - atomic_inc(&cmd->device->iodone_cnt);
41920 + atomic_inc_unchecked(&cmd->device->iodone_cnt);
41921 if (cmd->result)
41922 - atomic_inc(&cmd->device->ioerr_cnt);
41923 + atomic_inc_unchecked(&cmd->device->ioerr_cnt);
41924
41925 disposition = scsi_decide_disposition(cmd);
41926 if (disposition != SUCCESS &&
41927 diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
41928 index 931a7d9..0c2a754 100644
41929 --- a/drivers/scsi/scsi_sysfs.c
41930 +++ b/drivers/scsi/scsi_sysfs.c
41931 @@ -658,7 +658,7 @@ show_iostat_##field(struct device *dev, struct device_attribute *attr, \
41932 char *buf) \
41933 { \
41934 struct scsi_device *sdev = to_scsi_device(dev); \
41935 - unsigned long long count = atomic_read(&sdev->field); \
41936 + unsigned long long count = atomic_read_unchecked(&sdev->field); \
41937 return snprintf(buf, 20, "0x%llx\n", count); \
41938 } \
41939 static DEVICE_ATTR(field, S_IRUGO, show_iostat_##field, NULL)
41940 diff --git a/drivers/scsi/scsi_tgt_lib.c b/drivers/scsi/scsi_tgt_lib.c
41941 index 84a1fdf..693b0d6 100644
41942 --- a/drivers/scsi/scsi_tgt_lib.c
41943 +++ b/drivers/scsi/scsi_tgt_lib.c
41944 @@ -362,7 +362,7 @@ static int scsi_map_user_pages(struct scsi_tgt_cmd *tcmd, struct scsi_cmnd *cmd,
41945 int err;
41946
41947 dprintk("%lx %u\n", uaddr, len);
41948 - err = blk_rq_map_user(q, rq, NULL, (void *)uaddr, len, GFP_KERNEL);
41949 + err = blk_rq_map_user(q, rq, NULL, (void __user *)uaddr, len, GFP_KERNEL);
41950 if (err) {
41951 /*
41952 * TODO: need to fixup sg_tablesize, max_segment_size,
41953 diff --git a/drivers/scsi/scsi_transport_fc.c b/drivers/scsi/scsi_transport_fc.c
41954 index e894ca7..de9d7660 100644
41955 --- a/drivers/scsi/scsi_transport_fc.c
41956 +++ b/drivers/scsi/scsi_transport_fc.c
41957 @@ -498,7 +498,7 @@ static DECLARE_TRANSPORT_CLASS(fc_vport_class,
41958 * Netlink Infrastructure
41959 */
41960
41961 -static atomic_t fc_event_seq;
41962 +static atomic_unchecked_t fc_event_seq;
41963
41964 /**
41965 * fc_get_event_number - Obtain the next sequential FC event number
41966 @@ -511,7 +511,7 @@ static atomic_t fc_event_seq;
41967 u32
41968 fc_get_event_number(void)
41969 {
41970 - return atomic_add_return(1, &fc_event_seq);
41971 + return atomic_add_return_unchecked(1, &fc_event_seq);
41972 }
41973 EXPORT_SYMBOL(fc_get_event_number);
41974
41975 @@ -659,7 +659,7 @@ static __init int fc_transport_init(void)
41976 {
41977 int error;
41978
41979 - atomic_set(&fc_event_seq, 0);
41980 + atomic_set_unchecked(&fc_event_seq, 0);
41981
41982 error = transport_class_register(&fc_host_class);
41983 if (error)
41984 @@ -849,7 +849,7 @@ static int fc_str_to_dev_loss(const char *buf, unsigned long *val)
41985 char *cp;
41986
41987 *val = simple_strtoul(buf, &cp, 0);
41988 - if ((*cp && (*cp != '\n')) || (*val < 0))
41989 + if (*cp && (*cp != '\n'))
41990 return -EINVAL;
41991 /*
41992 * Check for overflow; dev_loss_tmo is u32
41993 diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c
41994 index 31969f2..2b348f0 100644
41995 --- a/drivers/scsi/scsi_transport_iscsi.c
41996 +++ b/drivers/scsi/scsi_transport_iscsi.c
41997 @@ -79,7 +79,7 @@ struct iscsi_internal {
41998 struct transport_container session_cont;
41999 };
42000
42001 -static atomic_t iscsi_session_nr; /* sysfs session id for next new session */
42002 +static atomic_unchecked_t iscsi_session_nr; /* sysfs session id for next new session */
42003 static struct workqueue_struct *iscsi_eh_timer_workq;
42004
42005 static DEFINE_IDA(iscsi_sess_ida);
42006 @@ -1064,7 +1064,7 @@ int iscsi_add_session(struct iscsi_cls_session *session, unsigned int target_id)
42007 int err;
42008
42009 ihost = shost->shost_data;
42010 - session->sid = atomic_add_return(1, &iscsi_session_nr);
42011 + session->sid = atomic_add_return_unchecked(1, &iscsi_session_nr);
42012
42013 if (target_id == ISCSI_MAX_TARGET) {
42014 id = ida_simple_get(&iscsi_sess_ida, 0, 0, GFP_KERNEL);
42015 @@ -2943,7 +2943,7 @@ static __init int iscsi_transport_init(void)
42016 printk(KERN_INFO "Loading iSCSI transport class v%s.\n",
42017 ISCSI_TRANSPORT_VERSION);
42018
42019 - atomic_set(&iscsi_session_nr, 0);
42020 + atomic_set_unchecked(&iscsi_session_nr, 0);
42021
42022 err = class_register(&iscsi_transport_class);
42023 if (err)
42024 diff --git a/drivers/scsi/scsi_transport_srp.c b/drivers/scsi/scsi_transport_srp.c
42025 index f379c7f..e8fc69c 100644
42026 --- a/drivers/scsi/scsi_transport_srp.c
42027 +++ b/drivers/scsi/scsi_transport_srp.c
42028 @@ -33,7 +33,7 @@
42029 #include "scsi_transport_srp_internal.h"
42030
42031 struct srp_host_attrs {
42032 - atomic_t next_port_id;
42033 + atomic_unchecked_t next_port_id;
42034 };
42035 #define to_srp_host_attrs(host) ((struct srp_host_attrs *)(host)->shost_data)
42036
42037 @@ -61,7 +61,7 @@ static int srp_host_setup(struct transport_container *tc, struct device *dev,
42038 struct Scsi_Host *shost = dev_to_shost(dev);
42039 struct srp_host_attrs *srp_host = to_srp_host_attrs(shost);
42040
42041 - atomic_set(&srp_host->next_port_id, 0);
42042 + atomic_set_unchecked(&srp_host->next_port_id, 0);
42043 return 0;
42044 }
42045
42046 @@ -210,7 +210,7 @@ struct srp_rport *srp_rport_add(struct Scsi_Host *shost,
42047 memcpy(rport->port_id, ids->port_id, sizeof(rport->port_id));
42048 rport->roles = ids->roles;
42049
42050 - id = atomic_inc_return(&to_srp_host_attrs(shost)->next_port_id);
42051 + id = atomic_inc_return_unchecked(&to_srp_host_attrs(shost)->next_port_id);
42052 dev_set_name(&rport->dev, "port-%d:%d", shost->host_no, id);
42053
42054 transport_setup_device(&rport->dev);
42055 diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
42056 index 7992635..609faf8 100644
42057 --- a/drivers/scsi/sd.c
42058 +++ b/drivers/scsi/sd.c
42059 @@ -2909,7 +2909,7 @@ static int sd_probe(struct device *dev)
42060 sdkp->disk = gd;
42061 sdkp->index = index;
42062 atomic_set(&sdkp->openers, 0);
42063 - atomic_set(&sdkp->device->ioerr_cnt, 0);
42064 + atomic_set_unchecked(&sdkp->device->ioerr_cnt, 0);
42065
42066 if (!sdp->request_queue->rq_timeout) {
42067 if (sdp->type != TYPE_MOD)
42068 diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
42069 index be2c9a6..275525c 100644
42070 --- a/drivers/scsi/sg.c
42071 +++ b/drivers/scsi/sg.c
42072 @@ -1101,7 +1101,7 @@ sg_ioctl(struct file *filp, unsigned int cmd_in, unsigned long arg)
42073 sdp->disk->disk_name,
42074 MKDEV(SCSI_GENERIC_MAJOR, sdp->index),
42075 NULL,
42076 - (char *)arg);
42077 + (char __user *)arg);
42078 case BLKTRACESTART:
42079 return blk_trace_startstop(sdp->device->request_queue, 1);
42080 case BLKTRACESTOP:
42081 diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
42082 index 19ee901..6e8c2ef 100644
42083 --- a/drivers/spi/spi.c
42084 +++ b/drivers/spi/spi.c
42085 @@ -1616,7 +1616,7 @@ int spi_bus_unlock(struct spi_master *master)
42086 EXPORT_SYMBOL_GPL(spi_bus_unlock);
42087
42088 /* portable code must never pass more than 32 bytes */
42089 -#define SPI_BUFSIZ max(32,SMP_CACHE_BYTES)
42090 +#define SPI_BUFSIZ max(32UL,SMP_CACHE_BYTES)
42091
42092 static u8 *buf;
42093
42094 diff --git a/drivers/staging/iio/iio_hwmon.c b/drivers/staging/iio/iio_hwmon.c
42095 index c7a5f97..71ecd35 100644
42096 --- a/drivers/staging/iio/iio_hwmon.c
42097 +++ b/drivers/staging/iio/iio_hwmon.c
42098 @@ -72,7 +72,7 @@ static void iio_hwmon_free_attrs(struct iio_hwmon_state *st)
42099 static int iio_hwmon_probe(struct platform_device *pdev)
42100 {
42101 struct iio_hwmon_state *st;
42102 - struct sensor_device_attribute *a;
42103 + sensor_device_attribute_no_const *a;
42104 int ret, i;
42105 int in_i = 1, temp_i = 1, curr_i = 1;
42106 enum iio_chan_type type;
42107 diff --git a/drivers/staging/octeon/ethernet-rx.c b/drivers/staging/octeon/ethernet-rx.c
42108 index 34afc16..ffe44dd 100644
42109 --- a/drivers/staging/octeon/ethernet-rx.c
42110 +++ b/drivers/staging/octeon/ethernet-rx.c
42111 @@ -421,11 +421,11 @@ static int cvm_oct_napi_poll(struct napi_struct *napi, int budget)
42112 /* Increment RX stats for virtual ports */
42113 if (work->ipprt >= CVMX_PIP_NUM_INPUT_PORTS) {
42114 #ifdef CONFIG_64BIT
42115 - atomic64_add(1, (atomic64_t *)&priv->stats.rx_packets);
42116 - atomic64_add(skb->len, (atomic64_t *)&priv->stats.rx_bytes);
42117 + atomic64_add_unchecked(1, (atomic64_unchecked_t *)&priv->stats.rx_packets);
42118 + atomic64_add_unchecked(skb->len, (atomic64_unchecked_t *)&priv->stats.rx_bytes);
42119 #else
42120 - atomic_add(1, (atomic_t *)&priv->stats.rx_packets);
42121 - atomic_add(skb->len, (atomic_t *)&priv->stats.rx_bytes);
42122 + atomic_add_unchecked(1, (atomic_unchecked_t *)&priv->stats.rx_packets);
42123 + atomic_add_unchecked(skb->len, (atomic_unchecked_t *)&priv->stats.rx_bytes);
42124 #endif
42125 }
42126 netif_receive_skb(skb);
42127 @@ -437,9 +437,9 @@ static int cvm_oct_napi_poll(struct napi_struct *napi, int budget)
42128 dev->name);
42129 */
42130 #ifdef CONFIG_64BIT
42131 - atomic64_add(1, (atomic64_t *)&priv->stats.rx_dropped);
42132 + atomic64_unchecked_add(1, (atomic64_unchecked_t *)&priv->stats.rx_dropped);
42133 #else
42134 - atomic_add(1, (atomic_t *)&priv->stats.rx_dropped);
42135 + atomic_add_unchecked(1, (atomic_unchecked_t *)&priv->stats.rx_dropped);
42136 #endif
42137 dev_kfree_skb_irq(skb);
42138 }
42139 diff --git a/drivers/staging/octeon/ethernet.c b/drivers/staging/octeon/ethernet.c
42140 index ef32dc1..a159d68 100644
42141 --- a/drivers/staging/octeon/ethernet.c
42142 +++ b/drivers/staging/octeon/ethernet.c
42143 @@ -252,11 +252,11 @@ static struct net_device_stats *cvm_oct_common_get_stats(struct net_device *dev)
42144 * since the RX tasklet also increments it.
42145 */
42146 #ifdef CONFIG_64BIT
42147 - atomic64_add(rx_status.dropped_packets,
42148 - (atomic64_t *)&priv->stats.rx_dropped);
42149 + atomic64_add_unchecked(rx_status.dropped_packets,
42150 + (atomic64_unchecked_t *)&priv->stats.rx_dropped);
42151 #else
42152 - atomic_add(rx_status.dropped_packets,
42153 - (atomic_t *)&priv->stats.rx_dropped);
42154 + atomic_add_unchecked(rx_status.dropped_packets,
42155 + (atomic_unchecked_t *)&priv->stats.rx_dropped);
42156 #endif
42157 }
42158
42159 diff --git a/drivers/staging/ramster/tmem.c b/drivers/staging/ramster/tmem.c
42160 index a2b7e03..aaf3630 100644
42161 --- a/drivers/staging/ramster/tmem.c
42162 +++ b/drivers/staging/ramster/tmem.c
42163 @@ -50,25 +50,25 @@
42164 * A tmem host implementation must use this function to register callbacks
42165 * for memory allocation.
42166 */
42167 -static struct tmem_hostops tmem_hostops;
42168 +static struct tmem_hostops *tmem_hostops;
42169
42170 static void tmem_objnode_tree_init(void);
42171
42172 void tmem_register_hostops(struct tmem_hostops *m)
42173 {
42174 tmem_objnode_tree_init();
42175 - tmem_hostops = *m;
42176 + tmem_hostops = m;
42177 }
42178
42179 /*
42180 * A tmem host implementation must use this function to register
42181 * callbacks for a page-accessible memory (PAM) implementation.
42182 */
42183 -static struct tmem_pamops tmem_pamops;
42184 +static struct tmem_pamops *tmem_pamops;
42185
42186 void tmem_register_pamops(struct tmem_pamops *m)
42187 {
42188 - tmem_pamops = *m;
42189 + tmem_pamops = m;
42190 }
42191
42192 /*
42193 @@ -174,7 +174,7 @@ static void tmem_obj_init(struct tmem_obj *obj, struct tmem_hashbucket *hb,
42194 obj->pampd_count = 0;
42195 #ifdef CONFIG_RAMSTER
42196 if (tmem_pamops.new_obj != NULL)
42197 - (*tmem_pamops.new_obj)(obj);
42198 + (tmem_pamops->new_obj)(obj);
42199 #endif
42200 SET_SENTINEL(obj, OBJ);
42201
42202 @@ -210,7 +210,7 @@ static void tmem_pool_flush(struct tmem_pool *pool, bool destroy)
42203 rbnode = rb_next(rbnode);
42204 tmem_pampd_destroy_all_in_obj(obj, true);
42205 tmem_obj_free(obj, hb);
42206 - (*tmem_hostops.obj_free)(obj, pool);
42207 + (tmem_hostops->obj_free)(obj, pool);
42208 }
42209 spin_unlock(&hb->lock);
42210 }
42211 @@ -261,7 +261,7 @@ static struct tmem_objnode *tmem_objnode_alloc(struct tmem_obj *obj)
42212 ASSERT_SENTINEL(obj, OBJ);
42213 BUG_ON(obj->pool == NULL);
42214 ASSERT_SENTINEL(obj->pool, POOL);
42215 - objnode = (*tmem_hostops.objnode_alloc)(obj->pool);
42216 + objnode = (tmem_hostops->objnode_alloc)(obj->pool);
42217 if (unlikely(objnode == NULL))
42218 goto out;
42219 objnode->obj = obj;
42220 @@ -290,7 +290,7 @@ static void tmem_objnode_free(struct tmem_objnode *objnode)
42221 ASSERT_SENTINEL(pool, POOL);
42222 objnode->obj->objnode_count--;
42223 objnode->obj = NULL;
42224 - (*tmem_hostops.objnode_free)(objnode, pool);
42225 + (tmem_hostops->objnode_free)(objnode, pool);
42226 }
42227
42228 /*
42229 @@ -348,7 +348,7 @@ static void *tmem_pampd_replace_in_obj(struct tmem_obj *obj, uint32_t index,
42230 void *old_pampd = *(void **)slot;
42231 *(void **)slot = new_pampd;
42232 if (!no_free)
42233 - (*tmem_pamops.free)(old_pampd, obj->pool,
42234 + (tmem_pamops->free)(old_pampd, obj->pool,
42235 NULL, 0, false);
42236 ret = new_pampd;
42237 }
42238 @@ -505,7 +505,7 @@ static void tmem_objnode_node_destroy(struct tmem_obj *obj,
42239 if (objnode->slots[i]) {
42240 if (ht == 1) {
42241 obj->pampd_count--;
42242 - (*tmem_pamops.free)(objnode->slots[i],
42243 + (tmem_pamops->free)(objnode->slots[i],
42244 obj->pool, NULL, 0, true);
42245 objnode->slots[i] = NULL;
42246 continue;
42247 @@ -524,7 +524,7 @@ static void tmem_pampd_destroy_all_in_obj(struct tmem_obj *obj,
42248 return;
42249 if (obj->objnode_tree_height == 0) {
42250 obj->pampd_count--;
42251 - (*tmem_pamops.free)(obj->objnode_tree_root,
42252 + (tmem_pamops->free)(obj->objnode_tree_root,
42253 obj->pool, NULL, 0, true);
42254 } else {
42255 tmem_objnode_node_destroy(obj, obj->objnode_tree_root,
42256 @@ -535,7 +535,7 @@ static void tmem_pampd_destroy_all_in_obj(struct tmem_obj *obj,
42257 obj->objnode_tree_root = NULL;
42258 #ifdef CONFIG_RAMSTER
42259 if (tmem_pamops.free_obj != NULL)
42260 - (*tmem_pamops.free_obj)(obj->pool, obj, pool_destroy);
42261 + (tmem_pamops->free_obj)(obj->pool, obj, pool_destroy);
42262 #endif
42263 }
42264
42265 @@ -574,7 +574,7 @@ int tmem_put(struct tmem_pool *pool, struct tmem_oid *oidp, uint32_t index,
42266 /* if found, is a dup put, flush the old one */
42267 pampd_del = tmem_pampd_delete_from_obj(obj, index);
42268 BUG_ON(pampd_del != pampd);
42269 - (*tmem_pamops.free)(pampd, pool, oidp, index, true);
42270 + (tmem_pamops->free)(pampd, pool, oidp, index, true);
42271 if (obj->pampd_count == 0) {
42272 objnew = obj;
42273 objfound = NULL;
42274 @@ -582,7 +582,7 @@ int tmem_put(struct tmem_pool *pool, struct tmem_oid *oidp, uint32_t index,
42275 pampd = NULL;
42276 }
42277 } else {
42278 - obj = objnew = (*tmem_hostops.obj_alloc)(pool);
42279 + obj = objnew = (tmem_hostops->obj_alloc)(pool);
42280 if (unlikely(obj == NULL)) {
42281 ret = -ENOMEM;
42282 goto out;
42283 @@ -597,16 +597,16 @@ int tmem_put(struct tmem_pool *pool, struct tmem_oid *oidp, uint32_t index,
42284 if (unlikely(ret == -ENOMEM))
42285 /* may have partially built objnode tree ("stump") */
42286 goto delete_and_free;
42287 - (*tmem_pamops.create_finish)(pampd, is_ephemeral(pool));
42288 + (tmem_pamops->create_finish)(pampd, is_ephemeral(pool));
42289 goto out;
42290
42291 delete_and_free:
42292 (void)tmem_pampd_delete_from_obj(obj, index);
42293 if (pampd)
42294 - (*tmem_pamops.free)(pampd, pool, NULL, 0, true);
42295 + (tmem_pamops->free)(pampd, pool, NULL, 0, true);
42296 if (objnew) {
42297 tmem_obj_free(objnew, hb);
42298 - (*tmem_hostops.obj_free)(objnew, pool);
42299 + (tmem_hostops->obj_free)(objnew, pool);
42300 }
42301 out:
42302 spin_unlock(&hb->lock);
42303 @@ -651,7 +651,7 @@ void tmem_localify_finish(struct tmem_obj *obj, uint32_t index,
42304 if (pampd != NULL) {
42305 BUG_ON(obj == NULL);
42306 (void)tmem_pampd_replace_in_obj(obj, index, pampd, 1);
42307 - (*tmem_pamops.create_finish)(pampd, is_ephemeral(obj->pool));
42308 + (tmem_pamops->create_finish)(pampd, is_ephemeral(obj->pool));
42309 } else if (delete) {
42310 BUG_ON(obj == NULL);
42311 (void)tmem_pampd_delete_from_obj(obj, index);
42312 @@ -671,7 +671,7 @@ static int tmem_repatriate(void **ppampd, struct tmem_hashbucket *hb,
42313 int ret = 0;
42314
42315 if (!is_ephemeral(pool))
42316 - new_pampd = (*tmem_pamops.repatriate_preload)(
42317 + new_pampd = (tmem_pamops->repatriate_preload)(
42318 old_pampd, pool, oidp, index, &intransit);
42319 if (intransit)
42320 ret = -EAGAIN;
42321 @@ -680,7 +680,7 @@ static int tmem_repatriate(void **ppampd, struct tmem_hashbucket *hb,
42322 /* must release the hb->lock else repatriate can't sleep */
42323 spin_unlock(&hb->lock);
42324 if (!intransit)
42325 - ret = (*tmem_pamops.repatriate)(old_pampd, new_pampd, pool,
42326 + ret = (tmem_pamops->repatriate)(old_pampd, new_pampd, pool,
42327 oidp, index, free, data);
42328 if (ret == -EAGAIN) {
42329 /* rare I think, but should cond_resched()??? */
42330 @@ -714,7 +714,7 @@ int tmem_replace(struct tmem_pool *pool, struct tmem_oid *oidp,
42331 new_pampd = tmem_pampd_replace_in_obj(obj, index, new_pampd, 0);
42332 /* if we bug here, pamops wasn't properly set up for ramster */
42333 BUG_ON(tmem_pamops.replace_in_obj == NULL);
42334 - ret = (*tmem_pamops.replace_in_obj)(new_pampd, obj);
42335 + ret = (tmem_pamops->replace_in_obj)(new_pampd, obj);
42336 out:
42337 spin_unlock(&hb->lock);
42338 return ret;
42339 @@ -776,15 +776,15 @@ int tmem_get(struct tmem_pool *pool, struct tmem_oid *oidp, uint32_t index,
42340 if (free) {
42341 if (obj->pampd_count == 0) {
42342 tmem_obj_free(obj, hb);
42343 - (*tmem_hostops.obj_free)(obj, pool);
42344 + (tmem_hostops->obj_free)(obj, pool);
42345 obj = NULL;
42346 }
42347 }
42348 if (free)
42349 - ret = (*tmem_pamops.get_data_and_free)(
42350 + ret = (tmem_pamops->get_data_and_free)(
42351 data, sizep, raw, pampd, pool, oidp, index);
42352 else
42353 - ret = (*tmem_pamops.get_data)(
42354 + ret = (tmem_pamops->get_data)(
42355 data, sizep, raw, pampd, pool, oidp, index);
42356 if (ret < 0)
42357 goto out;
42358 @@ -816,10 +816,10 @@ int tmem_flush_page(struct tmem_pool *pool,
42359 pampd = tmem_pampd_delete_from_obj(obj, index);
42360 if (pampd == NULL)
42361 goto out;
42362 - (*tmem_pamops.free)(pampd, pool, oidp, index, true);
42363 + (tmem_pamops->free)(pampd, pool, oidp, index, true);
42364 if (obj->pampd_count == 0) {
42365 tmem_obj_free(obj, hb);
42366 - (*tmem_hostops.obj_free)(obj, pool);
42367 + (tmem_hostops->obj_free)(obj, pool);
42368 }
42369 ret = 0;
42370
42371 @@ -844,7 +844,7 @@ int tmem_flush_object(struct tmem_pool *pool, struct tmem_oid *oidp)
42372 goto out;
42373 tmem_pampd_destroy_all_in_obj(obj, false);
42374 tmem_obj_free(obj, hb);
42375 - (*tmem_hostops.obj_free)(obj, pool);
42376 + (tmem_hostops->obj_free)(obj, pool);
42377 ret = 0;
42378
42379 out:
42380 diff --git a/drivers/staging/rtl8712/rtl871x_io.h b/drivers/staging/rtl8712/rtl871x_io.h
42381 index dc23395..cf7e9b1 100644
42382 --- a/drivers/staging/rtl8712/rtl871x_io.h
42383 +++ b/drivers/staging/rtl8712/rtl871x_io.h
42384 @@ -108,7 +108,7 @@ struct _io_ops {
42385 u8 *pmem);
42386 u32 (*_write_port)(struct intf_hdl *pintfhdl, u32 addr, u32 cnt,
42387 u8 *pmem);
42388 -};
42389 +} __no_const;
42390
42391 struct io_req {
42392 struct list_head list;
42393 diff --git a/drivers/staging/sbe-2t3e3/netdev.c b/drivers/staging/sbe-2t3e3/netdev.c
42394 index 1f5088b..0e59820 100644
42395 --- a/drivers/staging/sbe-2t3e3/netdev.c
42396 +++ b/drivers/staging/sbe-2t3e3/netdev.c
42397 @@ -51,7 +51,7 @@ static int t3e3_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
42398 t3e3_if_config(sc, cmd_2t3e3, (char *)&param, &resp, &rlen);
42399
42400 if (rlen)
42401 - if (copy_to_user(data, &resp, rlen))
42402 + if (rlen > sizeof resp || copy_to_user(data, &resp, rlen))
42403 return -EFAULT;
42404
42405 return 0;
42406 diff --git a/drivers/staging/usbip/vhci.h b/drivers/staging/usbip/vhci.h
42407 index 5dddc4d..34fcb2f 100644
42408 --- a/drivers/staging/usbip/vhci.h
42409 +++ b/drivers/staging/usbip/vhci.h
42410 @@ -83,7 +83,7 @@ struct vhci_hcd {
42411 unsigned resuming:1;
42412 unsigned long re_timeout;
42413
42414 - atomic_t seqnum;
42415 + atomic_unchecked_t seqnum;
42416
42417 /*
42418 * NOTE:
42419 diff --git a/drivers/staging/usbip/vhci_hcd.c b/drivers/staging/usbip/vhci_hcd.c
42420 index c3aa219..bf8b3de 100644
42421 --- a/drivers/staging/usbip/vhci_hcd.c
42422 +++ b/drivers/staging/usbip/vhci_hcd.c
42423 @@ -451,7 +451,7 @@ static void vhci_tx_urb(struct urb *urb)
42424 return;
42425 }
42426
42427 - priv->seqnum = atomic_inc_return(&the_controller->seqnum);
42428 + priv->seqnum = atomic_inc_return_unchecked(&the_controller->seqnum);
42429 if (priv->seqnum == 0xffff)
42430 dev_info(&urb->dev->dev, "seqnum max\n");
42431
42432 @@ -703,7 +703,7 @@ static int vhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status)
42433 return -ENOMEM;
42434 }
42435
42436 - unlink->seqnum = atomic_inc_return(&the_controller->seqnum);
42437 + unlink->seqnum = atomic_inc_return_unchecked(&the_controller->seqnum);
42438 if (unlink->seqnum == 0xffff)
42439 pr_info("seqnum max\n");
42440
42441 @@ -907,7 +907,7 @@ static int vhci_start(struct usb_hcd *hcd)
42442 vdev->rhport = rhport;
42443 }
42444
42445 - atomic_set(&vhci->seqnum, 0);
42446 + atomic_set_unchecked(&vhci->seqnum, 0);
42447 spin_lock_init(&vhci->lock);
42448
42449 hcd->power_budget = 0; /* no limit */
42450 diff --git a/drivers/staging/usbip/vhci_rx.c b/drivers/staging/usbip/vhci_rx.c
42451 index ba5f1c0..11d8122 100644
42452 --- a/drivers/staging/usbip/vhci_rx.c
42453 +++ b/drivers/staging/usbip/vhci_rx.c
42454 @@ -77,7 +77,7 @@ static void vhci_recv_ret_submit(struct vhci_device *vdev,
42455 if (!urb) {
42456 pr_err("cannot find a urb of seqnum %u\n", pdu->base.seqnum);
42457 pr_info("max seqnum %d\n",
42458 - atomic_read(&the_controller->seqnum));
42459 + atomic_read_unchecked(&the_controller->seqnum));
42460 usbip_event_add(ud, VDEV_EVENT_ERROR_TCP);
42461 return;
42462 }
42463 diff --git a/drivers/staging/vt6655/hostap.c b/drivers/staging/vt6655/hostap.c
42464 index 5f13890..36a044b 100644
42465 --- a/drivers/staging/vt6655/hostap.c
42466 +++ b/drivers/staging/vt6655/hostap.c
42467 @@ -73,14 +73,13 @@ static int msglevel =MSG_LEVEL_INFO;
42468 *
42469 */
42470
42471 +static net_device_ops_no_const apdev_netdev_ops;
42472 +
42473 static int hostap_enable_hostapd(PSDevice pDevice, int rtnl_locked)
42474 {
42475 PSDevice apdev_priv;
42476 struct net_device *dev = pDevice->dev;
42477 int ret;
42478 - const struct net_device_ops apdev_netdev_ops = {
42479 - .ndo_start_xmit = pDevice->tx_80211,
42480 - };
42481
42482 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%s: Enabling hostapd mode\n", dev->name);
42483
42484 @@ -92,6 +91,8 @@ static int hostap_enable_hostapd(PSDevice pDevice, int rtnl_locked)
42485 *apdev_priv = *pDevice;
42486 memcpy(pDevice->apdev->dev_addr, dev->dev_addr, ETH_ALEN);
42487
42488 + /* only half broken now */
42489 + apdev_netdev_ops.ndo_start_xmit = pDevice->tx_80211;
42490 pDevice->apdev->netdev_ops = &apdev_netdev_ops;
42491
42492 pDevice->apdev->type = ARPHRD_IEEE80211;
42493 diff --git a/drivers/staging/vt6656/hostap.c b/drivers/staging/vt6656/hostap.c
42494 index 26a7d0e..897b083 100644
42495 --- a/drivers/staging/vt6656/hostap.c
42496 +++ b/drivers/staging/vt6656/hostap.c
42497 @@ -60,14 +60,13 @@ static int msglevel =MSG_LEVEL_INFO;
42498 *
42499 */
42500
42501 +static net_device_ops_no_const apdev_netdev_ops;
42502 +
42503 static int hostap_enable_hostapd(PSDevice pDevice, int rtnl_locked)
42504 {
42505 PSDevice apdev_priv;
42506 struct net_device *dev = pDevice->dev;
42507 int ret;
42508 - const struct net_device_ops apdev_netdev_ops = {
42509 - .ndo_start_xmit = pDevice->tx_80211,
42510 - };
42511
42512 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%s: Enabling hostapd mode\n", dev->name);
42513
42514 @@ -79,6 +78,8 @@ static int hostap_enable_hostapd(PSDevice pDevice, int rtnl_locked)
42515 *apdev_priv = *pDevice;
42516 memcpy(pDevice->apdev->dev_addr, dev->dev_addr, ETH_ALEN);
42517
42518 + /* only half broken now */
42519 + apdev_netdev_ops.ndo_start_xmit = pDevice->tx_80211;
42520 pDevice->apdev->netdev_ops = &apdev_netdev_ops;
42521
42522 pDevice->apdev->type = ARPHRD_IEEE80211;
42523 diff --git a/drivers/staging/zcache/tmem.c b/drivers/staging/zcache/tmem.c
42524 index 56c8e60..1920c63 100644
42525 --- a/drivers/staging/zcache/tmem.c
42526 +++ b/drivers/staging/zcache/tmem.c
42527 @@ -39,7 +39,7 @@
42528 * A tmem host implementation must use this function to register callbacks
42529 * for memory allocation.
42530 */
42531 -static struct tmem_hostops tmem_hostops;
42532 +static tmem_hostops_no_const tmem_hostops;
42533
42534 static void tmem_objnode_tree_init(void);
42535
42536 @@ -53,7 +53,7 @@ void tmem_register_hostops(struct tmem_hostops *m)
42537 * A tmem host implementation must use this function to register
42538 * callbacks for a page-accessible memory (PAM) implementation
42539 */
42540 -static struct tmem_pamops tmem_pamops;
42541 +static tmem_pamops_no_const tmem_pamops;
42542
42543 void tmem_register_pamops(struct tmem_pamops *m)
42544 {
42545 diff --git a/drivers/staging/zcache/tmem.h b/drivers/staging/zcache/tmem.h
42546 index 0d4aa82..f7832d4 100644
42547 --- a/drivers/staging/zcache/tmem.h
42548 +++ b/drivers/staging/zcache/tmem.h
42549 @@ -180,6 +180,7 @@ struct tmem_pamops {
42550 void (*new_obj)(struct tmem_obj *);
42551 int (*replace_in_obj)(void *, struct tmem_obj *);
42552 };
42553 +typedef struct tmem_pamops __no_const tmem_pamops_no_const;
42554 extern void tmem_register_pamops(struct tmem_pamops *m);
42555
42556 /* memory allocation methods provided by the host implementation */
42557 @@ -189,6 +190,7 @@ struct tmem_hostops {
42558 struct tmem_objnode *(*objnode_alloc)(struct tmem_pool *);
42559 void (*objnode_free)(struct tmem_objnode *, struct tmem_pool *);
42560 };
42561 +typedef struct tmem_hostops __no_const tmem_hostops_no_const;
42562 extern void tmem_register_hostops(struct tmem_hostops *m);
42563
42564 /* core tmem accessor functions */
42565 diff --git a/drivers/target/target_core_device.c b/drivers/target/target_core_device.c
42566 index 96f4981..4daaa7e 100644
42567 --- a/drivers/target/target_core_device.c
42568 +++ b/drivers/target/target_core_device.c
42569 @@ -1370,7 +1370,7 @@ struct se_device *target_alloc_device(struct se_hba *hba, const char *name)
42570 spin_lock_init(&dev->se_port_lock);
42571 spin_lock_init(&dev->se_tmr_lock);
42572 spin_lock_init(&dev->qf_cmd_lock);
42573 - atomic_set(&dev->dev_ordered_id, 0);
42574 + atomic_set_unchecked(&dev->dev_ordered_id, 0);
42575 INIT_LIST_HEAD(&dev->t10_wwn.t10_vpd_list);
42576 spin_lock_init(&dev->t10_wwn.t10_vpd_lock);
42577 INIT_LIST_HEAD(&dev->t10_pr.registration_list);
42578 diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c
42579 index bd587b7..173daf3 100644
42580 --- a/drivers/target/target_core_transport.c
42581 +++ b/drivers/target/target_core_transport.c
42582 @@ -1077,7 +1077,7 @@ transport_check_alloc_task_attr(struct se_cmd *cmd)
42583 * Used to determine when ORDERED commands should go from
42584 * Dormant to Active status.
42585 */
42586 - cmd->se_ordered_id = atomic_inc_return(&dev->dev_ordered_id);
42587 + cmd->se_ordered_id = atomic_inc_return_unchecked(&dev->dev_ordered_id);
42588 smp_mb__after_atomic_inc();
42589 pr_debug("Allocated se_ordered_id: %u for Task Attr: 0x%02x on %s\n",
42590 cmd->se_ordered_id, cmd->sam_task_attr,
42591 diff --git a/drivers/tty/cyclades.c b/drivers/tty/cyclades.c
42592 index b09c8d1f..c4225c0 100644
42593 --- a/drivers/tty/cyclades.c
42594 +++ b/drivers/tty/cyclades.c
42595 @@ -1589,10 +1589,10 @@ static int cy_open(struct tty_struct *tty, struct file *filp)
42596 printk(KERN_DEBUG "cyc:cy_open ttyC%d, count = %d\n", info->line,
42597 info->port.count);
42598 #endif
42599 - info->port.count++;
42600 + atomic_inc(&info->port.count);
42601 #ifdef CY_DEBUG_COUNT
42602 printk(KERN_DEBUG "cyc:cy_open (%d): incrementing count to %d\n",
42603 - current->pid, info->port.count);
42604 + current->pid, atomic_read(&info->port.count));
42605 #endif
42606
42607 /*
42608 @@ -3991,7 +3991,7 @@ static int cyclades_proc_show(struct seq_file *m, void *v)
42609 for (j = 0; j < cy_card[i].nports; j++) {
42610 info = &cy_card[i].ports[j];
42611
42612 - if (info->port.count) {
42613 + if (atomic_read(&info->port.count)) {
42614 /* XXX is the ldisc num worth this? */
42615 struct tty_struct *tty;
42616 struct tty_ldisc *ld;
42617 diff --git a/drivers/tty/hvc/hvc_console.c b/drivers/tty/hvc/hvc_console.c
42618 index 13ee53b..418d164 100644
42619 --- a/drivers/tty/hvc/hvc_console.c
42620 +++ b/drivers/tty/hvc/hvc_console.c
42621 @@ -338,7 +338,7 @@ static int hvc_open(struct tty_struct *tty, struct file * filp)
42622
42623 spin_lock_irqsave(&hp->port.lock, flags);
42624 /* Check and then increment for fast path open. */
42625 - if (hp->port.count++ > 0) {
42626 + if (atomic_inc_return(&hp->port.count) > 1) {
42627 spin_unlock_irqrestore(&hp->port.lock, flags);
42628 hvc_kick();
42629 return 0;
42630 @@ -388,7 +388,7 @@ static void hvc_close(struct tty_struct *tty, struct file * filp)
42631
42632 spin_lock_irqsave(&hp->port.lock, flags);
42633
42634 - if (--hp->port.count == 0) {
42635 + if (atomic_dec_return(&hp->port.count) == 0) {
42636 spin_unlock_irqrestore(&hp->port.lock, flags);
42637 /* We are done with the tty pointer now. */
42638 tty_port_tty_set(&hp->port, NULL);
42639 @@ -406,9 +406,9 @@ static void hvc_close(struct tty_struct *tty, struct file * filp)
42640 */
42641 tty_wait_until_sent_from_close(tty, HVC_CLOSE_WAIT);
42642 } else {
42643 - if (hp->port.count < 0)
42644 + if (atomic_read(&hp->port.count) < 0)
42645 printk(KERN_ERR "hvc_close %X: oops, count is %d\n",
42646 - hp->vtermno, hp->port.count);
42647 + hp->vtermno, atomic_read(&hp->port.count));
42648 spin_unlock_irqrestore(&hp->port.lock, flags);
42649 }
42650 }
42651 @@ -438,12 +438,12 @@ static void hvc_hangup(struct tty_struct *tty)
42652 * open->hangup case this can be called after the final close so prevent
42653 * that from happening for now.
42654 */
42655 - if (hp->port.count <= 0) {
42656 + if (atomic_read(&hp->port.count) <= 0) {
42657 spin_unlock_irqrestore(&hp->port.lock, flags);
42658 return;
42659 }
42660
42661 - hp->port.count = 0;
42662 + atomic_set(&hp->port.count, 0);
42663 spin_unlock_irqrestore(&hp->port.lock, flags);
42664 tty_port_tty_set(&hp->port, NULL);
42665
42666 @@ -491,7 +491,7 @@ static int hvc_write(struct tty_struct *tty, const unsigned char *buf, int count
42667 return -EPIPE;
42668
42669 /* FIXME what's this (unprotected) check for? */
42670 - if (hp->port.count <= 0)
42671 + if (atomic_read(&hp->port.count) <= 0)
42672 return -EIO;
42673
42674 spin_lock_irqsave(&hp->lock, flags);
42675 diff --git a/drivers/tty/hvc/hvcs.c b/drivers/tty/hvc/hvcs.c
42676 index 8776357..b2d4afd 100644
42677 --- a/drivers/tty/hvc/hvcs.c
42678 +++ b/drivers/tty/hvc/hvcs.c
42679 @@ -83,6 +83,7 @@
42680 #include <asm/hvcserver.h>
42681 #include <asm/uaccess.h>
42682 #include <asm/vio.h>
42683 +#include <asm/local.h>
42684
42685 /*
42686 * 1.3.0 -> 1.3.1 In hvcs_open memset(..,0x00,..) instead of memset(..,0x3F,00).
42687 @@ -416,7 +417,7 @@ static ssize_t hvcs_vterm_state_store(struct device *dev, struct device_attribut
42688
42689 spin_lock_irqsave(&hvcsd->lock, flags);
42690
42691 - if (hvcsd->port.count > 0) {
42692 + if (atomic_read(&hvcsd->port.count) > 0) {
42693 spin_unlock_irqrestore(&hvcsd->lock, flags);
42694 printk(KERN_INFO "HVCS: vterm state unchanged. "
42695 "The hvcs device node is still in use.\n");
42696 @@ -1132,7 +1133,7 @@ static int hvcs_install(struct tty_driver *driver, struct tty_struct *tty)
42697 }
42698 }
42699
42700 - hvcsd->port.count = 0;
42701 + atomic_set(&hvcsd->port.count, 0);
42702 hvcsd->port.tty = tty;
42703 tty->driver_data = hvcsd;
42704
42705 @@ -1185,7 +1186,7 @@ static int hvcs_open(struct tty_struct *tty, struct file *filp)
42706 unsigned long flags;
42707
42708 spin_lock_irqsave(&hvcsd->lock, flags);
42709 - hvcsd->port.count++;
42710 + atomic_inc(&hvcsd->port.count);
42711 hvcsd->todo_mask |= HVCS_SCHED_READ;
42712 spin_unlock_irqrestore(&hvcsd->lock, flags);
42713
42714 @@ -1221,7 +1222,7 @@ static void hvcs_close(struct tty_struct *tty, struct file *filp)
42715 hvcsd = tty->driver_data;
42716
42717 spin_lock_irqsave(&hvcsd->lock, flags);
42718 - if (--hvcsd->port.count == 0) {
42719 + if (atomic_dec_and_test(&hvcsd->port.count)) {
42720
42721 vio_disable_interrupts(hvcsd->vdev);
42722
42723 @@ -1246,10 +1247,10 @@ static void hvcs_close(struct tty_struct *tty, struct file *filp)
42724
42725 free_irq(irq, hvcsd);
42726 return;
42727 - } else if (hvcsd->port.count < 0) {
42728 + } else if (atomic_read(&hvcsd->port.count) < 0) {
42729 printk(KERN_ERR "HVCS: vty-server@%X open_count: %d"
42730 " is missmanaged.\n",
42731 - hvcsd->vdev->unit_address, hvcsd->port.count);
42732 + hvcsd->vdev->unit_address, atomic_read(&hvcsd->port.count));
42733 }
42734
42735 spin_unlock_irqrestore(&hvcsd->lock, flags);
42736 @@ -1271,7 +1272,7 @@ static void hvcs_hangup(struct tty_struct * tty)
42737
42738 spin_lock_irqsave(&hvcsd->lock, flags);
42739 /* Preserve this so that we know how many kref refs to put */
42740 - temp_open_count = hvcsd->port.count;
42741 + temp_open_count = atomic_read(&hvcsd->port.count);
42742
42743 /*
42744 * Don't kref put inside the spinlock because the destruction
42745 @@ -1286,7 +1287,7 @@ static void hvcs_hangup(struct tty_struct * tty)
42746 tty->driver_data = NULL;
42747 hvcsd->port.tty = NULL;
42748
42749 - hvcsd->port.count = 0;
42750 + atomic_set(&hvcsd->port.count, 0);
42751
42752 /* This will drop any buffered data on the floor which is OK in a hangup
42753 * scenario. */
42754 @@ -1357,7 +1358,7 @@ static int hvcs_write(struct tty_struct *tty,
42755 * the middle of a write operation? This is a crummy place to do this
42756 * but we want to keep it all in the spinlock.
42757 */
42758 - if (hvcsd->port.count <= 0) {
42759 + if (atomic_read(&hvcsd->port.count) <= 0) {
42760 spin_unlock_irqrestore(&hvcsd->lock, flags);
42761 return -ENODEV;
42762 }
42763 @@ -1431,7 +1432,7 @@ static int hvcs_write_room(struct tty_struct *tty)
42764 {
42765 struct hvcs_struct *hvcsd = tty->driver_data;
42766
42767 - if (!hvcsd || hvcsd->port.count <= 0)
42768 + if (!hvcsd || atomic_read(&hvcsd->port.count) <= 0)
42769 return 0;
42770
42771 return HVCS_BUFF_LEN - hvcsd->chars_in_buffer;
42772 diff --git a/drivers/tty/ipwireless/tty.c b/drivers/tty/ipwireless/tty.c
42773 index 2cde13d..645d78f 100644
42774 --- a/drivers/tty/ipwireless/tty.c
42775 +++ b/drivers/tty/ipwireless/tty.c
42776 @@ -29,6 +29,7 @@
42777 #include <linux/tty_driver.h>
42778 #include <linux/tty_flip.h>
42779 #include <linux/uaccess.h>
42780 +#include <asm/local.h>
42781
42782 #include "tty.h"
42783 #include "network.h"
42784 @@ -99,10 +100,10 @@ static int ipw_open(struct tty_struct *linux_tty, struct file *filp)
42785 mutex_unlock(&tty->ipw_tty_mutex);
42786 return -ENODEV;
42787 }
42788 - if (tty->port.count == 0)
42789 + if (atomic_read(&tty->port.count) == 0)
42790 tty->tx_bytes_queued = 0;
42791
42792 - tty->port.count++;
42793 + atomic_inc(&tty->port.count);
42794
42795 tty->port.tty = linux_tty;
42796 linux_tty->driver_data = tty;
42797 @@ -118,9 +119,7 @@ static int ipw_open(struct tty_struct *linux_tty, struct file *filp)
42798
42799 static void do_ipw_close(struct ipw_tty *tty)
42800 {
42801 - tty->port.count--;
42802 -
42803 - if (tty->port.count == 0) {
42804 + if (atomic_dec_return(&tty->port.count) == 0) {
42805 struct tty_struct *linux_tty = tty->port.tty;
42806
42807 if (linux_tty != NULL) {
42808 @@ -141,7 +140,7 @@ static void ipw_hangup(struct tty_struct *linux_tty)
42809 return;
42810
42811 mutex_lock(&tty->ipw_tty_mutex);
42812 - if (tty->port.count == 0) {
42813 + if (atomic_read(&tty->port.count) == 0) {
42814 mutex_unlock(&tty->ipw_tty_mutex);
42815 return;
42816 }
42817 @@ -170,7 +169,7 @@ void ipwireless_tty_received(struct ipw_tty *tty, unsigned char *data,
42818 return;
42819 }
42820
42821 - if (!tty->port.count) {
42822 + if (!atomic_read(&tty->port.count)) {
42823 mutex_unlock(&tty->ipw_tty_mutex);
42824 return;
42825 }
42826 @@ -212,7 +211,7 @@ static int ipw_write(struct tty_struct *linux_tty,
42827 return -ENODEV;
42828
42829 mutex_lock(&tty->ipw_tty_mutex);
42830 - if (!tty->port.count) {
42831 + if (!atomic_read(&tty->port.count)) {
42832 mutex_unlock(&tty->ipw_tty_mutex);
42833 return -EINVAL;
42834 }
42835 @@ -252,7 +251,7 @@ static int ipw_write_room(struct tty_struct *linux_tty)
42836 if (!tty)
42837 return -ENODEV;
42838
42839 - if (!tty->port.count)
42840 + if (!atomic_read(&tty->port.count))
42841 return -EINVAL;
42842
42843 room = IPWIRELESS_TX_QUEUE_SIZE - tty->tx_bytes_queued;
42844 @@ -294,7 +293,7 @@ static int ipw_chars_in_buffer(struct tty_struct *linux_tty)
42845 if (!tty)
42846 return 0;
42847
42848 - if (!tty->port.count)
42849 + if (!atomic_read(&tty->port.count))
42850 return 0;
42851
42852 return tty->tx_bytes_queued;
42853 @@ -375,7 +374,7 @@ static int ipw_tiocmget(struct tty_struct *linux_tty)
42854 if (!tty)
42855 return -ENODEV;
42856
42857 - if (!tty->port.count)
42858 + if (!atomic_read(&tty->port.count))
42859 return -EINVAL;
42860
42861 return get_control_lines(tty);
42862 @@ -391,7 +390,7 @@ ipw_tiocmset(struct tty_struct *linux_tty,
42863 if (!tty)
42864 return -ENODEV;
42865
42866 - if (!tty->port.count)
42867 + if (!atomic_read(&tty->port.count))
42868 return -EINVAL;
42869
42870 return set_control_lines(tty, set, clear);
42871 @@ -405,7 +404,7 @@ static int ipw_ioctl(struct tty_struct *linux_tty,
42872 if (!tty)
42873 return -ENODEV;
42874
42875 - if (!tty->port.count)
42876 + if (!atomic_read(&tty->port.count))
42877 return -EINVAL;
42878
42879 /* FIXME: Exactly how is the tty object locked here .. */
42880 @@ -561,7 +560,7 @@ void ipwireless_tty_free(struct ipw_tty *tty)
42881 * are gone */
42882 mutex_lock(&ttyj->ipw_tty_mutex);
42883 }
42884 - while (ttyj->port.count)
42885 + while (atomic_read(&ttyj->port.count))
42886 do_ipw_close(ttyj);
42887 ipwireless_disassociate_network_ttys(network,
42888 ttyj->channel_idx);
42889 diff --git a/drivers/tty/moxa.c b/drivers/tty/moxa.c
42890 index f9d2850..b006f04 100644
42891 --- a/drivers/tty/moxa.c
42892 +++ b/drivers/tty/moxa.c
42893 @@ -1193,7 +1193,7 @@ static int moxa_open(struct tty_struct *tty, struct file *filp)
42894 }
42895
42896 ch = &brd->ports[port % MAX_PORTS_PER_BOARD];
42897 - ch->port.count++;
42898 + atomic_inc(&ch->port.count);
42899 tty->driver_data = ch;
42900 tty_port_tty_set(&ch->port, tty);
42901 mutex_lock(&ch->port.mutex);
42902 diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c
42903 index bfd6771..e0d93c4 100644
42904 --- a/drivers/tty/n_gsm.c
42905 +++ b/drivers/tty/n_gsm.c
42906 @@ -1636,7 +1636,7 @@ static struct gsm_dlci *gsm_dlci_alloc(struct gsm_mux *gsm, int addr)
42907 spin_lock_init(&dlci->lock);
42908 mutex_init(&dlci->mutex);
42909 dlci->fifo = &dlci->_fifo;
42910 - if (kfifo_alloc(&dlci->_fifo, 4096, GFP_KERNEL) < 0) {
42911 + if (kfifo_alloc(&dlci->_fifo, 4096, GFP_KERNEL)) {
42912 kfree(dlci);
42913 return NULL;
42914 }
42915 @@ -2936,7 +2936,7 @@ static int gsmtty_open(struct tty_struct *tty, struct file *filp)
42916 struct gsm_dlci *dlci = tty->driver_data;
42917 struct tty_port *port = &dlci->port;
42918
42919 - port->count++;
42920 + atomic_inc(&port->count);
42921 dlci_get(dlci);
42922 dlci_get(dlci->gsm->dlci[0]);
42923 mux_get(dlci->gsm);
42924 diff --git a/drivers/tty/n_tty.c b/drivers/tty/n_tty.c
42925 index 19083ef..6e34e97 100644
42926 --- a/drivers/tty/n_tty.c
42927 +++ b/drivers/tty/n_tty.c
42928 @@ -2196,6 +2196,7 @@ void n_tty_inherit_ops(struct tty_ldisc_ops *ops)
42929 {
42930 *ops = tty_ldisc_N_TTY;
42931 ops->owner = NULL;
42932 - ops->refcount = ops->flags = 0;
42933 + atomic_set(&ops->refcount, 0);
42934 + ops->flags = 0;
42935 }
42936 EXPORT_SYMBOL_GPL(n_tty_inherit_ops);
42937 diff --git a/drivers/tty/pty.c b/drivers/tty/pty.c
42938 index ac35c90..c47deac 100644
42939 --- a/drivers/tty/pty.c
42940 +++ b/drivers/tty/pty.c
42941 @@ -790,8 +790,10 @@ static void __init unix98_pty_init(void)
42942 panic("Couldn't register Unix98 pts driver");
42943
42944 /* Now create the /dev/ptmx special device */
42945 + pax_open_kernel();
42946 tty_default_fops(&ptmx_fops);
42947 - ptmx_fops.open = ptmx_open;
42948 + *(void **)&ptmx_fops.open = ptmx_open;
42949 + pax_close_kernel();
42950
42951 cdev_init(&ptmx_cdev, &ptmx_fops);
42952 if (cdev_add(&ptmx_cdev, MKDEV(TTYAUX_MAJOR, 2), 1) ||
42953 diff --git a/drivers/tty/rocket.c b/drivers/tty/rocket.c
42954 index e42009a..566a036 100644
42955 --- a/drivers/tty/rocket.c
42956 +++ b/drivers/tty/rocket.c
42957 @@ -925,7 +925,7 @@ static int rp_open(struct tty_struct *tty, struct file *filp)
42958 tty->driver_data = info;
42959 tty_port_tty_set(port, tty);
42960
42961 - if (port->count++ == 0) {
42962 + if (atomic_inc_return(&port->count) == 1) {
42963 atomic_inc(&rp_num_ports_open);
42964
42965 #ifdef ROCKET_DEBUG_OPEN
42966 @@ -934,7 +934,7 @@ static int rp_open(struct tty_struct *tty, struct file *filp)
42967 #endif
42968 }
42969 #ifdef ROCKET_DEBUG_OPEN
42970 - printk(KERN_INFO "rp_open ttyR%d, count=%d\n", info->line, info->port.count);
42971 + printk(KERN_INFO "rp_open ttyR%d, count=%d\n", info->line, atomic-read(&info->port.count));
42972 #endif
42973
42974 /*
42975 @@ -1529,7 +1529,7 @@ static void rp_hangup(struct tty_struct *tty)
42976 spin_unlock_irqrestore(&info->port.lock, flags);
42977 return;
42978 }
42979 - if (info->port.count)
42980 + if (atomic_read(&info->port.count))
42981 atomic_dec(&rp_num_ports_open);
42982 clear_bit((info->aiop * 8) + info->chan, (void *) &xmit_flags[info->board]);
42983 spin_unlock_irqrestore(&info->port.lock, flags);
42984 diff --git a/drivers/tty/serial/kgdboc.c b/drivers/tty/serial/kgdboc.c
42985 index 1002054..dd644a8 100644
42986 --- a/drivers/tty/serial/kgdboc.c
42987 +++ b/drivers/tty/serial/kgdboc.c
42988 @@ -24,8 +24,9 @@
42989 #define MAX_CONFIG_LEN 40
42990
42991 static struct kgdb_io kgdboc_io_ops;
42992 +static struct kgdb_io kgdboc_io_ops_console;
42993
42994 -/* -1 = init not run yet, 0 = unconfigured, 1 = configured. */
42995 +/* -1 = init not run yet, 0 = unconfigured, 1/2 = configured. */
42996 static int configured = -1;
42997
42998 static char config[MAX_CONFIG_LEN];
42999 @@ -151,6 +152,8 @@ static void cleanup_kgdboc(void)
43000 kgdboc_unregister_kbd();
43001 if (configured == 1)
43002 kgdb_unregister_io_module(&kgdboc_io_ops);
43003 + else if (configured == 2)
43004 + kgdb_unregister_io_module(&kgdboc_io_ops_console);
43005 }
43006
43007 static int configure_kgdboc(void)
43008 @@ -160,13 +163,13 @@ static int configure_kgdboc(void)
43009 int err;
43010 char *cptr = config;
43011 struct console *cons;
43012 + int is_console = 0;
43013
43014 err = kgdboc_option_setup(config);
43015 if (err || !strlen(config) || isspace(config[0]))
43016 goto noconfig;
43017
43018 err = -ENODEV;
43019 - kgdboc_io_ops.is_console = 0;
43020 kgdb_tty_driver = NULL;
43021
43022 kgdboc_use_kms = 0;
43023 @@ -187,7 +190,7 @@ static int configure_kgdboc(void)
43024 int idx;
43025 if (cons->device && cons->device(cons, &idx) == p &&
43026 idx == tty_line) {
43027 - kgdboc_io_ops.is_console = 1;
43028 + is_console = 1;
43029 break;
43030 }
43031 cons = cons->next;
43032 @@ -197,7 +200,13 @@ static int configure_kgdboc(void)
43033 kgdb_tty_line = tty_line;
43034
43035 do_register:
43036 - err = kgdb_register_io_module(&kgdboc_io_ops);
43037 + if (is_console) {
43038 + err = kgdb_register_io_module(&kgdboc_io_ops_console);
43039 + configured = 2;
43040 + } else {
43041 + err = kgdb_register_io_module(&kgdboc_io_ops);
43042 + configured = 1;
43043 + }
43044 if (err)
43045 goto noconfig;
43046
43047 @@ -205,8 +214,6 @@ do_register:
43048 if (err)
43049 goto nmi_con_failed;
43050
43051 - configured = 1;
43052 -
43053 return 0;
43054
43055 nmi_con_failed:
43056 @@ -223,7 +230,7 @@ noconfig:
43057 static int __init init_kgdboc(void)
43058 {
43059 /* Already configured? */
43060 - if (configured == 1)
43061 + if (configured >= 1)
43062 return 0;
43063
43064 return configure_kgdboc();
43065 @@ -272,7 +279,7 @@ static int param_set_kgdboc_var(const char *kmessage, struct kernel_param *kp)
43066 if (config[len - 1] == '\n')
43067 config[len - 1] = '\0';
43068
43069 - if (configured == 1)
43070 + if (configured >= 1)
43071 cleanup_kgdboc();
43072
43073 /* Go and configure with the new params. */
43074 @@ -312,6 +319,15 @@ static struct kgdb_io kgdboc_io_ops = {
43075 .post_exception = kgdboc_post_exp_handler,
43076 };
43077
43078 +static struct kgdb_io kgdboc_io_ops_console = {
43079 + .name = "kgdboc",
43080 + .read_char = kgdboc_get_char,
43081 + .write_char = kgdboc_put_char,
43082 + .pre_exception = kgdboc_pre_exp_handler,
43083 + .post_exception = kgdboc_post_exp_handler,
43084 + .is_console = 1
43085 +};
43086 +
43087 #ifdef CONFIG_KGDB_SERIAL_CONSOLE
43088 /* This is only available if kgdboc is a built in for early debugging */
43089 static int __init kgdboc_early_init(char *opt)
43090 diff --git a/drivers/tty/serial/samsung.c b/drivers/tty/serial/samsung.c
43091 index e514b3a..c73d614 100644
43092 --- a/drivers/tty/serial/samsung.c
43093 +++ b/drivers/tty/serial/samsung.c
43094 @@ -453,11 +453,16 @@ static void s3c24xx_serial_shutdown(struct uart_port *port)
43095 }
43096 }
43097
43098 +static int s3c64xx_serial_startup(struct uart_port *port);
43099 static int s3c24xx_serial_startup(struct uart_port *port)
43100 {
43101 struct s3c24xx_uart_port *ourport = to_ourport(port);
43102 int ret;
43103
43104 + /* Startup sequence is different for s3c64xx and higher SoC's */
43105 + if (s3c24xx_serial_has_interrupt_mask(port))
43106 + return s3c64xx_serial_startup(port);
43107 +
43108 dbg("s3c24xx_serial_startup: port=%p (%08lx,%p)\n",
43109 port->mapbase, port->membase);
43110
43111 @@ -1122,10 +1127,6 @@ static int s3c24xx_serial_init_port(struct s3c24xx_uart_port *ourport,
43112 /* setup info for port */
43113 port->dev = &platdev->dev;
43114
43115 - /* Startup sequence is different for s3c64xx and higher SoC's */
43116 - if (s3c24xx_serial_has_interrupt_mask(port))
43117 - s3c24xx_serial_ops.startup = s3c64xx_serial_startup;
43118 -
43119 port->uartclk = 1;
43120
43121 if (cfg->uart_flags & UPF_CONS_FLOW) {
43122 diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
43123 index 2c7230a..2104f16 100644
43124 --- a/drivers/tty/serial/serial_core.c
43125 +++ b/drivers/tty/serial/serial_core.c
43126 @@ -1455,7 +1455,7 @@ static void uart_hangup(struct tty_struct *tty)
43127 uart_flush_buffer(tty);
43128 uart_shutdown(tty, state);
43129 spin_lock_irqsave(&port->lock, flags);
43130 - port->count = 0;
43131 + atomic_set(&port->count, 0);
43132 clear_bit(ASYNCB_NORMAL_ACTIVE, &port->flags);
43133 spin_unlock_irqrestore(&port->lock, flags);
43134 tty_port_tty_set(port, NULL);
43135 @@ -1551,7 +1551,7 @@ static int uart_open(struct tty_struct *tty, struct file *filp)
43136 goto end;
43137 }
43138
43139 - port->count++;
43140 + atomic_inc(&port->count);
43141 if (!state->uart_port || state->uart_port->flags & UPF_DEAD) {
43142 retval = -ENXIO;
43143 goto err_dec_count;
43144 @@ -1578,7 +1578,7 @@ static int uart_open(struct tty_struct *tty, struct file *filp)
43145 /*
43146 * Make sure the device is in D0 state.
43147 */
43148 - if (port->count == 1)
43149 + if (atomic_read(&port->count) == 1)
43150 uart_change_pm(state, 0);
43151
43152 /*
43153 @@ -1596,7 +1596,7 @@ static int uart_open(struct tty_struct *tty, struct file *filp)
43154 end:
43155 return retval;
43156 err_dec_count:
43157 - port->count--;
43158 + atomic_inc(&port->count);
43159 mutex_unlock(&port->mutex);
43160 goto end;
43161 }
43162 diff --git a/drivers/tty/synclink.c b/drivers/tty/synclink.c
43163 index 9e071f6..f30ae69 100644
43164 --- a/drivers/tty/synclink.c
43165 +++ b/drivers/tty/synclink.c
43166 @@ -3095,7 +3095,7 @@ static void mgsl_close(struct tty_struct *tty, struct file * filp)
43167
43168 if (debug_level >= DEBUG_LEVEL_INFO)
43169 printk("%s(%d):mgsl_close(%s) entry, count=%d\n",
43170 - __FILE__,__LINE__, info->device_name, info->port.count);
43171 + __FILE__,__LINE__, info->device_name, atomic_read(&info->port.count));
43172
43173 if (tty_port_close_start(&info->port, tty, filp) == 0)
43174 goto cleanup;
43175 @@ -3113,7 +3113,7 @@ static void mgsl_close(struct tty_struct *tty, struct file * filp)
43176 cleanup:
43177 if (debug_level >= DEBUG_LEVEL_INFO)
43178 printk("%s(%d):mgsl_close(%s) exit, count=%d\n", __FILE__,__LINE__,
43179 - tty->driver->name, info->port.count);
43180 + tty->driver->name, atomic_read(&info->port.count));
43181
43182 } /* end of mgsl_close() */
43183
43184 @@ -3212,8 +3212,8 @@ static void mgsl_hangup(struct tty_struct *tty)
43185
43186 mgsl_flush_buffer(tty);
43187 shutdown(info);
43188 -
43189 - info->port.count = 0;
43190 +
43191 + atomic_set(&info->port.count, 0);
43192 info->port.flags &= ~ASYNC_NORMAL_ACTIVE;
43193 info->port.tty = NULL;
43194
43195 @@ -3302,12 +3302,12 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
43196
43197 if (debug_level >= DEBUG_LEVEL_INFO)
43198 printk("%s(%d):block_til_ready before block on %s count=%d\n",
43199 - __FILE__,__LINE__, tty->driver->name, port->count );
43200 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
43201
43202 spin_lock_irqsave(&info->irq_spinlock, flags);
43203 if (!tty_hung_up_p(filp)) {
43204 extra_count = true;
43205 - port->count--;
43206 + atomic_dec(&port->count);
43207 }
43208 spin_unlock_irqrestore(&info->irq_spinlock, flags);
43209 port->blocked_open++;
43210 @@ -3336,7 +3336,7 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
43211
43212 if (debug_level >= DEBUG_LEVEL_INFO)
43213 printk("%s(%d):block_til_ready blocking on %s count=%d\n",
43214 - __FILE__,__LINE__, tty->driver->name, port->count );
43215 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
43216
43217 tty_unlock(tty);
43218 schedule();
43219 @@ -3348,12 +3348,12 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
43220
43221 /* FIXME: Racy on hangup during close wait */
43222 if (extra_count)
43223 - port->count++;
43224 + atomic_inc(&port->count);
43225 port->blocked_open--;
43226
43227 if (debug_level >= DEBUG_LEVEL_INFO)
43228 printk("%s(%d):block_til_ready after blocking on %s count=%d\n",
43229 - __FILE__,__LINE__, tty->driver->name, port->count );
43230 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
43231
43232 if (!retval)
43233 port->flags |= ASYNC_NORMAL_ACTIVE;
43234 @@ -3405,7 +3405,7 @@ static int mgsl_open(struct tty_struct *tty, struct file * filp)
43235
43236 if (debug_level >= DEBUG_LEVEL_INFO)
43237 printk("%s(%d):mgsl_open(%s), old ref count = %d\n",
43238 - __FILE__,__LINE__,tty->driver->name, info->port.count);
43239 + __FILE__,__LINE__,tty->driver->name, atomic_read(&info->port.count));
43240
43241 /* If port is closing, signal caller to try again */
43242 if (tty_hung_up_p(filp) || info->port.flags & ASYNC_CLOSING){
43243 @@ -3424,10 +3424,10 @@ static int mgsl_open(struct tty_struct *tty, struct file * filp)
43244 spin_unlock_irqrestore(&info->netlock, flags);
43245 goto cleanup;
43246 }
43247 - info->port.count++;
43248 + atomic_inc(&info->port.count);
43249 spin_unlock_irqrestore(&info->netlock, flags);
43250
43251 - if (info->port.count == 1) {
43252 + if (atomic_read(&info->port.count) == 1) {
43253 /* 1st open on this device, init hardware */
43254 retval = startup(info);
43255 if (retval < 0)
43256 @@ -3451,8 +3451,8 @@ cleanup:
43257 if (retval) {
43258 if (tty->count == 1)
43259 info->port.tty = NULL; /* tty layer will release tty struct */
43260 - if(info->port.count)
43261 - info->port.count--;
43262 + if (atomic_read(&info->port.count))
43263 + atomic_dec(&info->port.count);
43264 }
43265
43266 return retval;
43267 @@ -7662,7 +7662,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
43268 unsigned short new_crctype;
43269
43270 /* return error if TTY interface open */
43271 - if (info->port.count)
43272 + if (atomic_read(&info->port.count))
43273 return -EBUSY;
43274
43275 switch (encoding)
43276 @@ -7757,7 +7757,7 @@ static int hdlcdev_open(struct net_device *dev)
43277
43278 /* arbitrate between network and tty opens */
43279 spin_lock_irqsave(&info->netlock, flags);
43280 - if (info->port.count != 0 || info->netcount != 0) {
43281 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
43282 printk(KERN_WARNING "%s: hdlc_open returning busy\n", dev->name);
43283 spin_unlock_irqrestore(&info->netlock, flags);
43284 return -EBUSY;
43285 @@ -7843,7 +7843,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
43286 printk("%s:hdlcdev_ioctl(%s)\n",__FILE__,dev->name);
43287
43288 /* return error if TTY interface open */
43289 - if (info->port.count)
43290 + if (atomic_read(&info->port.count))
43291 return -EBUSY;
43292
43293 if (cmd != SIOCWANDEV)
43294 diff --git a/drivers/tty/synclink_gt.c b/drivers/tty/synclink_gt.c
43295 index aba1e59..877ac33 100644
43296 --- a/drivers/tty/synclink_gt.c
43297 +++ b/drivers/tty/synclink_gt.c
43298 @@ -671,7 +671,7 @@ static int open(struct tty_struct *tty, struct file *filp)
43299 tty->driver_data = info;
43300 info->port.tty = tty;
43301
43302 - DBGINFO(("%s open, old ref count = %d\n", info->device_name, info->port.count));
43303 + DBGINFO(("%s open, old ref count = %d\n", info->device_name, atomic_read(&info->port.count)));
43304
43305 /* If port is closing, signal caller to try again */
43306 if (tty_hung_up_p(filp) || info->port.flags & ASYNC_CLOSING){
43307 @@ -692,10 +692,10 @@ static int open(struct tty_struct *tty, struct file *filp)
43308 mutex_unlock(&info->port.mutex);
43309 goto cleanup;
43310 }
43311 - info->port.count++;
43312 + atomic_inc(&info->port.count);
43313 spin_unlock_irqrestore(&info->netlock, flags);
43314
43315 - if (info->port.count == 1) {
43316 + if (atomic_read(&info->port.count) == 1) {
43317 /* 1st open on this device, init hardware */
43318 retval = startup(info);
43319 if (retval < 0) {
43320 @@ -716,8 +716,8 @@ cleanup:
43321 if (retval) {
43322 if (tty->count == 1)
43323 info->port.tty = NULL; /* tty layer will release tty struct */
43324 - if(info->port.count)
43325 - info->port.count--;
43326 + if(atomic_read(&info->port.count))
43327 + atomic_dec(&info->port.count);
43328 }
43329
43330 DBGINFO(("%s open rc=%d\n", info->device_name, retval));
43331 @@ -730,7 +730,7 @@ static void close(struct tty_struct *tty, struct file *filp)
43332
43333 if (sanity_check(info, tty->name, "close"))
43334 return;
43335 - DBGINFO(("%s close entry, count=%d\n", info->device_name, info->port.count));
43336 + DBGINFO(("%s close entry, count=%d\n", info->device_name, atomic_read(&info->port.count)));
43337
43338 if (tty_port_close_start(&info->port, tty, filp) == 0)
43339 goto cleanup;
43340 @@ -747,7 +747,7 @@ static void close(struct tty_struct *tty, struct file *filp)
43341 tty_port_close_end(&info->port, tty);
43342 info->port.tty = NULL;
43343 cleanup:
43344 - DBGINFO(("%s close exit, count=%d\n", tty->driver->name, info->port.count));
43345 + DBGINFO(("%s close exit, count=%d\n", tty->driver->name, atomic_read(&info->port.count)));
43346 }
43347
43348 static void hangup(struct tty_struct *tty)
43349 @@ -765,7 +765,7 @@ static void hangup(struct tty_struct *tty)
43350 shutdown(info);
43351
43352 spin_lock_irqsave(&info->port.lock, flags);
43353 - info->port.count = 0;
43354 + atomic_set(&info->port.count, 0);
43355 info->port.flags &= ~ASYNC_NORMAL_ACTIVE;
43356 info->port.tty = NULL;
43357 spin_unlock_irqrestore(&info->port.lock, flags);
43358 @@ -1450,7 +1450,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
43359 unsigned short new_crctype;
43360
43361 /* return error if TTY interface open */
43362 - if (info->port.count)
43363 + if (atomic_read(&info->port.count))
43364 return -EBUSY;
43365
43366 DBGINFO(("%s hdlcdev_attach\n", info->device_name));
43367 @@ -1545,7 +1545,7 @@ static int hdlcdev_open(struct net_device *dev)
43368
43369 /* arbitrate between network and tty opens */
43370 spin_lock_irqsave(&info->netlock, flags);
43371 - if (info->port.count != 0 || info->netcount != 0) {
43372 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
43373 DBGINFO(("%s hdlc_open busy\n", dev->name));
43374 spin_unlock_irqrestore(&info->netlock, flags);
43375 return -EBUSY;
43376 @@ -1630,7 +1630,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
43377 DBGINFO(("%s hdlcdev_ioctl\n", dev->name));
43378
43379 /* return error if TTY interface open */
43380 - if (info->port.count)
43381 + if (atomic_read(&info->port.count))
43382 return -EBUSY;
43383
43384 if (cmd != SIOCWANDEV)
43385 @@ -2419,7 +2419,7 @@ static irqreturn_t slgt_interrupt(int dummy, void *dev_id)
43386 if (port == NULL)
43387 continue;
43388 spin_lock(&port->lock);
43389 - if ((port->port.count || port->netcount) &&
43390 + if ((atomic_read(&port->port.count) || port->netcount) &&
43391 port->pending_bh && !port->bh_running &&
43392 !port->bh_requested) {
43393 DBGISR(("%s bh queued\n", port->device_name));
43394 @@ -3308,7 +3308,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
43395 spin_lock_irqsave(&info->lock, flags);
43396 if (!tty_hung_up_p(filp)) {
43397 extra_count = true;
43398 - port->count--;
43399 + atomic_dec(&port->count);
43400 }
43401 spin_unlock_irqrestore(&info->lock, flags);
43402 port->blocked_open++;
43403 @@ -3345,7 +3345,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
43404 remove_wait_queue(&port->open_wait, &wait);
43405
43406 if (extra_count)
43407 - port->count++;
43408 + atomic_inc(&port->count);
43409 port->blocked_open--;
43410
43411 if (!retval)
43412 diff --git a/drivers/tty/synclinkmp.c b/drivers/tty/synclinkmp.c
43413 index fd43fb6..34704ad 100644
43414 --- a/drivers/tty/synclinkmp.c
43415 +++ b/drivers/tty/synclinkmp.c
43416 @@ -751,7 +751,7 @@ static int open(struct tty_struct *tty, struct file *filp)
43417
43418 if (debug_level >= DEBUG_LEVEL_INFO)
43419 printk("%s(%d):%s open(), old ref count = %d\n",
43420 - __FILE__,__LINE__,tty->driver->name, info->port.count);
43421 + __FILE__,__LINE__,tty->driver->name, atomic_read(&info->port.count));
43422
43423 /* If port is closing, signal caller to try again */
43424 if (tty_hung_up_p(filp) || info->port.flags & ASYNC_CLOSING){
43425 @@ -770,10 +770,10 @@ static int open(struct tty_struct *tty, struct file *filp)
43426 spin_unlock_irqrestore(&info->netlock, flags);
43427 goto cleanup;
43428 }
43429 - info->port.count++;
43430 + atomic_inc(&info->port.count);
43431 spin_unlock_irqrestore(&info->netlock, flags);
43432
43433 - if (info->port.count == 1) {
43434 + if (atomic_read(&info->port.count) == 1) {
43435 /* 1st open on this device, init hardware */
43436 retval = startup(info);
43437 if (retval < 0)
43438 @@ -797,8 +797,8 @@ cleanup:
43439 if (retval) {
43440 if (tty->count == 1)
43441 info->port.tty = NULL; /* tty layer will release tty struct */
43442 - if(info->port.count)
43443 - info->port.count--;
43444 + if(atomic_read(&info->port.count))
43445 + atomic_dec(&info->port.count);
43446 }
43447
43448 return retval;
43449 @@ -816,7 +816,7 @@ static void close(struct tty_struct *tty, struct file *filp)
43450
43451 if (debug_level >= DEBUG_LEVEL_INFO)
43452 printk("%s(%d):%s close() entry, count=%d\n",
43453 - __FILE__,__LINE__, info->device_name, info->port.count);
43454 + __FILE__,__LINE__, info->device_name, atomic_read(&info->port.count));
43455
43456 if (tty_port_close_start(&info->port, tty, filp) == 0)
43457 goto cleanup;
43458 @@ -835,7 +835,7 @@ static void close(struct tty_struct *tty, struct file *filp)
43459 cleanup:
43460 if (debug_level >= DEBUG_LEVEL_INFO)
43461 printk("%s(%d):%s close() exit, count=%d\n", __FILE__,__LINE__,
43462 - tty->driver->name, info->port.count);
43463 + tty->driver->name, atomic_read(&info->port.count));
43464 }
43465
43466 /* Called by tty_hangup() when a hangup is signaled.
43467 @@ -858,7 +858,7 @@ static void hangup(struct tty_struct *tty)
43468 shutdown(info);
43469
43470 spin_lock_irqsave(&info->port.lock, flags);
43471 - info->port.count = 0;
43472 + atomic_set(&info->port.count, 0);
43473 info->port.flags &= ~ASYNC_NORMAL_ACTIVE;
43474 info->port.tty = NULL;
43475 spin_unlock_irqrestore(&info->port.lock, flags);
43476 @@ -1566,7 +1566,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
43477 unsigned short new_crctype;
43478
43479 /* return error if TTY interface open */
43480 - if (info->port.count)
43481 + if (atomic_read(&info->port.count))
43482 return -EBUSY;
43483
43484 switch (encoding)
43485 @@ -1661,7 +1661,7 @@ static int hdlcdev_open(struct net_device *dev)
43486
43487 /* arbitrate between network and tty opens */
43488 spin_lock_irqsave(&info->netlock, flags);
43489 - if (info->port.count != 0 || info->netcount != 0) {
43490 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
43491 printk(KERN_WARNING "%s: hdlc_open returning busy\n", dev->name);
43492 spin_unlock_irqrestore(&info->netlock, flags);
43493 return -EBUSY;
43494 @@ -1747,7 +1747,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
43495 printk("%s:hdlcdev_ioctl(%s)\n",__FILE__,dev->name);
43496
43497 /* return error if TTY interface open */
43498 - if (info->port.count)
43499 + if (atomic_read(&info->port.count))
43500 return -EBUSY;
43501
43502 if (cmd != SIOCWANDEV)
43503 @@ -2632,7 +2632,7 @@ static irqreturn_t synclinkmp_interrupt(int dummy, void *dev_id)
43504 * do not request bottom half processing if the
43505 * device is not open in a normal mode.
43506 */
43507 - if ( port && (port->port.count || port->netcount) &&
43508 + if ( port && (atomic_read(&port->port.count) || port->netcount) &&
43509 port->pending_bh && !port->bh_running &&
43510 !port->bh_requested ) {
43511 if ( debug_level >= DEBUG_LEVEL_ISR )
43512 @@ -3330,12 +3330,12 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
43513
43514 if (debug_level >= DEBUG_LEVEL_INFO)
43515 printk("%s(%d):%s block_til_ready() before block, count=%d\n",
43516 - __FILE__,__LINE__, tty->driver->name, port->count );
43517 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
43518
43519 spin_lock_irqsave(&info->lock, flags);
43520 if (!tty_hung_up_p(filp)) {
43521 extra_count = true;
43522 - port->count--;
43523 + atomic_dec(&port->count);
43524 }
43525 spin_unlock_irqrestore(&info->lock, flags);
43526 port->blocked_open++;
43527 @@ -3364,7 +3364,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
43528
43529 if (debug_level >= DEBUG_LEVEL_INFO)
43530 printk("%s(%d):%s block_til_ready() count=%d\n",
43531 - __FILE__,__LINE__, tty->driver->name, port->count );
43532 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
43533
43534 tty_unlock(tty);
43535 schedule();
43536 @@ -3375,12 +3375,12 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
43537 remove_wait_queue(&port->open_wait, &wait);
43538
43539 if (extra_count)
43540 - port->count++;
43541 + atomic_inc(&port->count);
43542 port->blocked_open--;
43543
43544 if (debug_level >= DEBUG_LEVEL_INFO)
43545 printk("%s(%d):%s block_til_ready() after, count=%d\n",
43546 - __FILE__,__LINE__, tty->driver->name, port->count );
43547 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
43548
43549 if (!retval)
43550 port->flags |= ASYNC_NORMAL_ACTIVE;
43551 diff --git a/drivers/tty/sysrq.c b/drivers/tty/sysrq.c
43552 index b3c4a25..723916f 100644
43553 --- a/drivers/tty/sysrq.c
43554 +++ b/drivers/tty/sysrq.c
43555 @@ -867,7 +867,7 @@ EXPORT_SYMBOL(unregister_sysrq_key);
43556 static ssize_t write_sysrq_trigger(struct file *file, const char __user *buf,
43557 size_t count, loff_t *ppos)
43558 {
43559 - if (count) {
43560 + if (count && capable(CAP_SYS_ADMIN)) {
43561 char c;
43562
43563 if (get_user(c, buf))
43564 diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
43565 index da9fde8..c07975f 100644
43566 --- a/drivers/tty/tty_io.c
43567 +++ b/drivers/tty/tty_io.c
43568 @@ -3391,7 +3391,7 @@ EXPORT_SYMBOL_GPL(get_current_tty);
43569
43570 void tty_default_fops(struct file_operations *fops)
43571 {
43572 - *fops = tty_fops;
43573 + memcpy((void *)fops, &tty_fops, sizeof(tty_fops));
43574 }
43575
43576 /*
43577 diff --git a/drivers/tty/tty_ldisc.c b/drivers/tty/tty_ldisc.c
43578 index c578229..45aa9ee 100644
43579 --- a/drivers/tty/tty_ldisc.c
43580 +++ b/drivers/tty/tty_ldisc.c
43581 @@ -56,7 +56,7 @@ static void put_ldisc(struct tty_ldisc *ld)
43582 if (atomic_dec_and_test(&ld->users)) {
43583 struct tty_ldisc_ops *ldo = ld->ops;
43584
43585 - ldo->refcount--;
43586 + atomic_dec(&ldo->refcount);
43587 module_put(ldo->owner);
43588 raw_spin_unlock_irqrestore(&tty_ldisc_lock, flags);
43589
43590 @@ -91,7 +91,7 @@ int tty_register_ldisc(int disc, struct tty_ldisc_ops *new_ldisc)
43591 raw_spin_lock_irqsave(&tty_ldisc_lock, flags);
43592 tty_ldiscs[disc] = new_ldisc;
43593 new_ldisc->num = disc;
43594 - new_ldisc->refcount = 0;
43595 + atomic_set(&new_ldisc->refcount, 0);
43596 raw_spin_unlock_irqrestore(&tty_ldisc_lock, flags);
43597
43598 return ret;
43599 @@ -119,7 +119,7 @@ int tty_unregister_ldisc(int disc)
43600 return -EINVAL;
43601
43602 raw_spin_lock_irqsave(&tty_ldisc_lock, flags);
43603 - if (tty_ldiscs[disc]->refcount)
43604 + if (atomic_read(&tty_ldiscs[disc]->refcount))
43605 ret = -EBUSY;
43606 else
43607 tty_ldiscs[disc] = NULL;
43608 @@ -140,7 +140,7 @@ static struct tty_ldisc_ops *get_ldops(int disc)
43609 if (ldops) {
43610 ret = ERR_PTR(-EAGAIN);
43611 if (try_module_get(ldops->owner)) {
43612 - ldops->refcount++;
43613 + atomic_inc(&ldops->refcount);
43614 ret = ldops;
43615 }
43616 }
43617 @@ -153,7 +153,7 @@ static void put_ldops(struct tty_ldisc_ops *ldops)
43618 unsigned long flags;
43619
43620 raw_spin_lock_irqsave(&tty_ldisc_lock, flags);
43621 - ldops->refcount--;
43622 + atomic_dec(&ldops->refcount);
43623 module_put(ldops->owner);
43624 raw_spin_unlock_irqrestore(&tty_ldisc_lock, flags);
43625 }
43626 diff --git a/drivers/tty/tty_port.c b/drivers/tty/tty_port.c
43627 index b7ff59d..7c6105e 100644
43628 --- a/drivers/tty/tty_port.c
43629 +++ b/drivers/tty/tty_port.c
43630 @@ -218,7 +218,7 @@ void tty_port_hangup(struct tty_port *port)
43631 unsigned long flags;
43632
43633 spin_lock_irqsave(&port->lock, flags);
43634 - port->count = 0;
43635 + atomic_set(&port->count, 0);
43636 port->flags &= ~ASYNC_NORMAL_ACTIVE;
43637 if (port->tty) {
43638 set_bit(TTY_IO_ERROR, &port->tty->flags);
43639 @@ -344,7 +344,7 @@ int tty_port_block_til_ready(struct tty_port *port,
43640 /* The port lock protects the port counts */
43641 spin_lock_irqsave(&port->lock, flags);
43642 if (!tty_hung_up_p(filp))
43643 - port->count--;
43644 + atomic_dec(&port->count);
43645 port->blocked_open++;
43646 spin_unlock_irqrestore(&port->lock, flags);
43647
43648 @@ -386,7 +386,7 @@ int tty_port_block_til_ready(struct tty_port *port,
43649 we must not mess that up further */
43650 spin_lock_irqsave(&port->lock, flags);
43651 if (!tty_hung_up_p(filp))
43652 - port->count++;
43653 + atomic_inc(&port->count);
43654 port->blocked_open--;
43655 if (retval == 0)
43656 port->flags |= ASYNC_NORMAL_ACTIVE;
43657 @@ -406,19 +406,19 @@ int tty_port_close_start(struct tty_port *port,
43658 return 0;
43659 }
43660
43661 - if (tty->count == 1 && port->count != 1) {
43662 + if (tty->count == 1 && atomic_read(&port->count) != 1) {
43663 printk(KERN_WARNING
43664 "tty_port_close_start: tty->count = 1 port count = %d.\n",
43665 - port->count);
43666 - port->count = 1;
43667 + atomic_read(&port->count));
43668 + atomic_set(&port->count, 1);
43669 }
43670 - if (--port->count < 0) {
43671 + if (atomic_dec_return(&port->count) < 0) {
43672 printk(KERN_WARNING "tty_port_close_start: count = %d\n",
43673 - port->count);
43674 - port->count = 0;
43675 + atomic_read(&port->count));
43676 + atomic_set(&port->count, 0);
43677 }
43678
43679 - if (port->count) {
43680 + if (atomic_read(&port->count)) {
43681 spin_unlock_irqrestore(&port->lock, flags);
43682 if (port->ops->drop)
43683 port->ops->drop(port);
43684 @@ -516,7 +516,7 @@ int tty_port_open(struct tty_port *port, struct tty_struct *tty,
43685 {
43686 spin_lock_irq(&port->lock);
43687 if (!tty_hung_up_p(filp))
43688 - ++port->count;
43689 + atomic_inc(&port->count);
43690 spin_unlock_irq(&port->lock);
43691 tty_port_tty_set(port, tty);
43692
43693 diff --git a/drivers/tty/vt/keyboard.c b/drivers/tty/vt/keyboard.c
43694 index 681765b..d3ccdf2 100644
43695 --- a/drivers/tty/vt/keyboard.c
43696 +++ b/drivers/tty/vt/keyboard.c
43697 @@ -660,6 +660,16 @@ static void k_spec(struct vc_data *vc, unsigned char value, char up_flag)
43698 kbd->kbdmode == VC_OFF) &&
43699 value != KVAL(K_SAK))
43700 return; /* SAK is allowed even in raw mode */
43701 +
43702 +#if defined(CONFIG_GRKERNSEC_PROC) || defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
43703 + {
43704 + void *func = fn_handler[value];
43705 + if (func == fn_show_state || func == fn_show_ptregs ||
43706 + func == fn_show_mem)
43707 + return;
43708 + }
43709 +#endif
43710 +
43711 fn_handler[value](vc);
43712 }
43713
43714 @@ -1808,9 +1818,6 @@ int vt_do_kdsk_ioctl(int cmd, struct kbentry __user *user_kbe, int perm,
43715 if (copy_from_user(&tmp, user_kbe, sizeof(struct kbentry)))
43716 return -EFAULT;
43717
43718 - if (!capable(CAP_SYS_TTY_CONFIG))
43719 - perm = 0;
43720 -
43721 switch (cmd) {
43722 case KDGKBENT:
43723 /* Ensure another thread doesn't free it under us */
43724 @@ -1825,6 +1832,9 @@ int vt_do_kdsk_ioctl(int cmd, struct kbentry __user *user_kbe, int perm,
43725 spin_unlock_irqrestore(&kbd_event_lock, flags);
43726 return put_user(val, &user_kbe->kb_value);
43727 case KDSKBENT:
43728 + if (!capable(CAP_SYS_TTY_CONFIG))
43729 + perm = 0;
43730 +
43731 if (!perm)
43732 return -EPERM;
43733 if (!i && v == K_NOSUCHMAP) {
43734 @@ -1915,9 +1925,6 @@ int vt_do_kdgkb_ioctl(int cmd, struct kbsentry __user *user_kdgkb, int perm)
43735 int i, j, k;
43736 int ret;
43737
43738 - if (!capable(CAP_SYS_TTY_CONFIG))
43739 - perm = 0;
43740 -
43741 kbs = kmalloc(sizeof(*kbs), GFP_KERNEL);
43742 if (!kbs) {
43743 ret = -ENOMEM;
43744 @@ -1951,6 +1958,9 @@ int vt_do_kdgkb_ioctl(int cmd, struct kbsentry __user *user_kdgkb, int perm)
43745 kfree(kbs);
43746 return ((p && *p) ? -EOVERFLOW : 0);
43747 case KDSKBSENT:
43748 + if (!capable(CAP_SYS_TTY_CONFIG))
43749 + perm = 0;
43750 +
43751 if (!perm) {
43752 ret = -EPERM;
43753 goto reterr;
43754 diff --git a/drivers/uio/uio.c b/drivers/uio/uio.c
43755 index 5110f36..8dc0a74 100644
43756 --- a/drivers/uio/uio.c
43757 +++ b/drivers/uio/uio.c
43758 @@ -25,6 +25,7 @@
43759 #include <linux/kobject.h>
43760 #include <linux/cdev.h>
43761 #include <linux/uio_driver.h>
43762 +#include <asm/local.h>
43763
43764 #define UIO_MAX_DEVICES (1U << MINORBITS)
43765
43766 @@ -32,10 +33,10 @@ struct uio_device {
43767 struct module *owner;
43768 struct device *dev;
43769 int minor;
43770 - atomic_t event;
43771 + atomic_unchecked_t event;
43772 struct fasync_struct *async_queue;
43773 wait_queue_head_t wait;
43774 - int vma_count;
43775 + local_t vma_count;
43776 struct uio_info *info;
43777 struct kobject *map_dir;
43778 struct kobject *portio_dir;
43779 @@ -242,7 +243,7 @@ static ssize_t show_event(struct device *dev,
43780 struct device_attribute *attr, char *buf)
43781 {
43782 struct uio_device *idev = dev_get_drvdata(dev);
43783 - return sprintf(buf, "%u\n", (unsigned int)atomic_read(&idev->event));
43784 + return sprintf(buf, "%u\n", (unsigned int)atomic_read_unchecked(&idev->event));
43785 }
43786
43787 static struct device_attribute uio_class_attributes[] = {
43788 @@ -408,7 +409,7 @@ void uio_event_notify(struct uio_info *info)
43789 {
43790 struct uio_device *idev = info->uio_dev;
43791
43792 - atomic_inc(&idev->event);
43793 + atomic_inc_unchecked(&idev->event);
43794 wake_up_interruptible(&idev->wait);
43795 kill_fasync(&idev->async_queue, SIGIO, POLL_IN);
43796 }
43797 @@ -461,7 +462,7 @@ static int uio_open(struct inode *inode, struct file *filep)
43798 }
43799
43800 listener->dev = idev;
43801 - listener->event_count = atomic_read(&idev->event);
43802 + listener->event_count = atomic_read_unchecked(&idev->event);
43803 filep->private_data = listener;
43804
43805 if (idev->info->open) {
43806 @@ -512,7 +513,7 @@ static unsigned int uio_poll(struct file *filep, poll_table *wait)
43807 return -EIO;
43808
43809 poll_wait(filep, &idev->wait, wait);
43810 - if (listener->event_count != atomic_read(&idev->event))
43811 + if (listener->event_count != atomic_read_unchecked(&idev->event))
43812 return POLLIN | POLLRDNORM;
43813 return 0;
43814 }
43815 @@ -537,7 +538,7 @@ static ssize_t uio_read(struct file *filep, char __user *buf,
43816 do {
43817 set_current_state(TASK_INTERRUPTIBLE);
43818
43819 - event_count = atomic_read(&idev->event);
43820 + event_count = atomic_read_unchecked(&idev->event);
43821 if (event_count != listener->event_count) {
43822 if (copy_to_user(buf, &event_count, count))
43823 retval = -EFAULT;
43824 @@ -606,13 +607,13 @@ static int uio_find_mem_index(struct vm_area_struct *vma)
43825 static void uio_vma_open(struct vm_area_struct *vma)
43826 {
43827 struct uio_device *idev = vma->vm_private_data;
43828 - idev->vma_count++;
43829 + local_inc(&idev->vma_count);
43830 }
43831
43832 static void uio_vma_close(struct vm_area_struct *vma)
43833 {
43834 struct uio_device *idev = vma->vm_private_data;
43835 - idev->vma_count--;
43836 + local_dec(&idev->vma_count);
43837 }
43838
43839 static int uio_vma_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
43840 @@ -819,7 +820,7 @@ int __uio_register_device(struct module *owner,
43841 idev->owner = owner;
43842 idev->info = info;
43843 init_waitqueue_head(&idev->wait);
43844 - atomic_set(&idev->event, 0);
43845 + atomic_set_unchecked(&idev->event, 0);
43846
43847 ret = uio_get_minor(idev);
43848 if (ret)
43849 diff --git a/drivers/usb/atm/cxacru.c b/drivers/usb/atm/cxacru.c
43850 index b7eb86a..36d28af 100644
43851 --- a/drivers/usb/atm/cxacru.c
43852 +++ b/drivers/usb/atm/cxacru.c
43853 @@ -473,7 +473,7 @@ static ssize_t cxacru_sysfs_store_adsl_config(struct device *dev,
43854 ret = sscanf(buf + pos, "%x=%x%n", &index, &value, &tmp);
43855 if (ret < 2)
43856 return -EINVAL;
43857 - if (index < 0 || index > 0x7f)
43858 + if (index > 0x7f)
43859 return -EINVAL;
43860 pos += tmp;
43861
43862 diff --git a/drivers/usb/atm/usbatm.c b/drivers/usb/atm/usbatm.c
43863 index 35f10bf..6a38a0b 100644
43864 --- a/drivers/usb/atm/usbatm.c
43865 +++ b/drivers/usb/atm/usbatm.c
43866 @@ -333,7 +333,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
43867 if (printk_ratelimit())
43868 atm_warn(instance, "%s: OAM not supported (vpi %d, vci %d)!\n",
43869 __func__, vpi, vci);
43870 - atomic_inc(&vcc->stats->rx_err);
43871 + atomic_inc_unchecked(&vcc->stats->rx_err);
43872 return;
43873 }
43874
43875 @@ -361,7 +361,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
43876 if (length > ATM_MAX_AAL5_PDU) {
43877 atm_rldbg(instance, "%s: bogus length %u (vcc: 0x%p)!\n",
43878 __func__, length, vcc);
43879 - atomic_inc(&vcc->stats->rx_err);
43880 + atomic_inc_unchecked(&vcc->stats->rx_err);
43881 goto out;
43882 }
43883
43884 @@ -370,14 +370,14 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
43885 if (sarb->len < pdu_length) {
43886 atm_rldbg(instance, "%s: bogus pdu_length %u (sarb->len: %u, vcc: 0x%p)!\n",
43887 __func__, pdu_length, sarb->len, vcc);
43888 - atomic_inc(&vcc->stats->rx_err);
43889 + atomic_inc_unchecked(&vcc->stats->rx_err);
43890 goto out;
43891 }
43892
43893 if (crc32_be(~0, skb_tail_pointer(sarb) - pdu_length, pdu_length) != 0xc704dd7b) {
43894 atm_rldbg(instance, "%s: packet failed crc check (vcc: 0x%p)!\n",
43895 __func__, vcc);
43896 - atomic_inc(&vcc->stats->rx_err);
43897 + atomic_inc_unchecked(&vcc->stats->rx_err);
43898 goto out;
43899 }
43900
43901 @@ -389,7 +389,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
43902 if (printk_ratelimit())
43903 atm_err(instance, "%s: no memory for skb (length: %u)!\n",
43904 __func__, length);
43905 - atomic_inc(&vcc->stats->rx_drop);
43906 + atomic_inc_unchecked(&vcc->stats->rx_drop);
43907 goto out;
43908 }
43909
43910 @@ -417,7 +417,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
43911
43912 vcc->push(vcc, skb);
43913
43914 - atomic_inc(&vcc->stats->rx);
43915 + atomic_inc_unchecked(&vcc->stats->rx);
43916 out:
43917 skb_trim(sarb, 0);
43918 }
43919 @@ -623,7 +623,7 @@ static void usbatm_tx_process(unsigned long data)
43920 struct atm_vcc *vcc = UDSL_SKB(skb)->atm.vcc;
43921
43922 usbatm_pop(vcc, skb);
43923 - atomic_inc(&vcc->stats->tx);
43924 + atomic_inc_unchecked(&vcc->stats->tx);
43925
43926 skb = skb_dequeue(&instance->sndqueue);
43927 }
43928 @@ -779,11 +779,11 @@ static int usbatm_atm_proc_read(struct atm_dev *atm_dev, loff_t * pos, char *pag
43929 if (!left--)
43930 return sprintf(page,
43931 "AAL5: tx %d ( %d err ), rx %d ( %d err, %d drop )\n",
43932 - atomic_read(&atm_dev->stats.aal5.tx),
43933 - atomic_read(&atm_dev->stats.aal5.tx_err),
43934 - atomic_read(&atm_dev->stats.aal5.rx),
43935 - atomic_read(&atm_dev->stats.aal5.rx_err),
43936 - atomic_read(&atm_dev->stats.aal5.rx_drop));
43937 + atomic_read_unchecked(&atm_dev->stats.aal5.tx),
43938 + atomic_read_unchecked(&atm_dev->stats.aal5.tx_err),
43939 + atomic_read_unchecked(&atm_dev->stats.aal5.rx),
43940 + atomic_read_unchecked(&atm_dev->stats.aal5.rx_err),
43941 + atomic_read_unchecked(&atm_dev->stats.aal5.rx_drop));
43942
43943 if (!left--) {
43944 if (instance->disconnected)
43945 diff --git a/drivers/usb/core/devices.c b/drivers/usb/core/devices.c
43946 index cbacea9..246cccd 100644
43947 --- a/drivers/usb/core/devices.c
43948 +++ b/drivers/usb/core/devices.c
43949 @@ -126,7 +126,7 @@ static const char format_endpt[] =
43950 * time it gets called.
43951 */
43952 static struct device_connect_event {
43953 - atomic_t count;
43954 + atomic_unchecked_t count;
43955 wait_queue_head_t wait;
43956 } device_event = {
43957 .count = ATOMIC_INIT(1),
43958 @@ -164,7 +164,7 @@ static const struct class_info clas_info[] = {
43959
43960 void usbfs_conn_disc_event(void)
43961 {
43962 - atomic_add(2, &device_event.count);
43963 + atomic_add_unchecked(2, &device_event.count);
43964 wake_up(&device_event.wait);
43965 }
43966
43967 @@ -645,7 +645,7 @@ static unsigned int usb_device_poll(struct file *file,
43968
43969 poll_wait(file, &device_event.wait, wait);
43970
43971 - event_count = atomic_read(&device_event.count);
43972 + event_count = atomic_read_unchecked(&device_event.count);
43973 if (file->f_version != event_count) {
43974 file->f_version = event_count;
43975 return POLLIN | POLLRDNORM;
43976 diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
43977 index 8e64adf..9a33a3c 100644
43978 --- a/drivers/usb/core/hcd.c
43979 +++ b/drivers/usb/core/hcd.c
43980 @@ -1522,7 +1522,7 @@ int usb_hcd_submit_urb (struct urb *urb, gfp_t mem_flags)
43981 */
43982 usb_get_urb(urb);
43983 atomic_inc(&urb->use_count);
43984 - atomic_inc(&urb->dev->urbnum);
43985 + atomic_inc_unchecked(&urb->dev->urbnum);
43986 usbmon_urb_submit(&hcd->self, urb);
43987
43988 /* NOTE requirements on root-hub callers (usbfs and the hub
43989 @@ -1549,7 +1549,7 @@ int usb_hcd_submit_urb (struct urb *urb, gfp_t mem_flags)
43990 urb->hcpriv = NULL;
43991 INIT_LIST_HEAD(&urb->urb_list);
43992 atomic_dec(&urb->use_count);
43993 - atomic_dec(&urb->dev->urbnum);
43994 + atomic_dec_unchecked(&urb->dev->urbnum);
43995 if (atomic_read(&urb->reject))
43996 wake_up(&usb_kill_urb_queue);
43997 usb_put_urb(urb);
43998 diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c
43999 index 131f736..99004c3 100644
44000 --- a/drivers/usb/core/message.c
44001 +++ b/drivers/usb/core/message.c
44002 @@ -129,7 +129,7 @@ static int usb_internal_control_msg(struct usb_device *usb_dev,
44003 * method can wait for it to complete. Since you don't have a handle on the
44004 * URB used, you can't cancel the request.
44005 */
44006 -int usb_control_msg(struct usb_device *dev, unsigned int pipe, __u8 request,
44007 +int __intentional_overflow(-1) usb_control_msg(struct usb_device *dev, unsigned int pipe, __u8 request,
44008 __u8 requesttype, __u16 value, __u16 index, void *data,
44009 __u16 size, int timeout)
44010 {
44011 diff --git a/drivers/usb/core/sysfs.c b/drivers/usb/core/sysfs.c
44012 index 818e4a0..0fc9589 100644
44013 --- a/drivers/usb/core/sysfs.c
44014 +++ b/drivers/usb/core/sysfs.c
44015 @@ -226,7 +226,7 @@ show_urbnum(struct device *dev, struct device_attribute *attr, char *buf)
44016 struct usb_device *udev;
44017
44018 udev = to_usb_device(dev);
44019 - return sprintf(buf, "%d\n", atomic_read(&udev->urbnum));
44020 + return sprintf(buf, "%d\n", atomic_read_unchecked(&udev->urbnum));
44021 }
44022 static DEVICE_ATTR(urbnum, S_IRUGO, show_urbnum, NULL);
44023
44024 diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c
44025 index f81b925..78d22ec 100644
44026 --- a/drivers/usb/core/usb.c
44027 +++ b/drivers/usb/core/usb.c
44028 @@ -388,7 +388,7 @@ struct usb_device *usb_alloc_dev(struct usb_device *parent,
44029 set_dev_node(&dev->dev, dev_to_node(bus->controller));
44030 dev->state = USB_STATE_ATTACHED;
44031 dev->lpm_disable_count = 1;
44032 - atomic_set(&dev->urbnum, 0);
44033 + atomic_set_unchecked(&dev->urbnum, 0);
44034
44035 INIT_LIST_HEAD(&dev->ep0.urb_list);
44036 dev->ep0.desc.bLength = USB_DT_ENDPOINT_SIZE;
44037 diff --git a/drivers/usb/early/ehci-dbgp.c b/drivers/usb/early/ehci-dbgp.c
44038 index 5e29dde..eca992f 100644
44039 --- a/drivers/usb/early/ehci-dbgp.c
44040 +++ b/drivers/usb/early/ehci-dbgp.c
44041 @@ -98,7 +98,8 @@ static inline u32 dbgp_len_update(u32 x, u32 len)
44042
44043 #ifdef CONFIG_KGDB
44044 static struct kgdb_io kgdbdbgp_io_ops;
44045 -#define dbgp_kgdb_mode (dbg_io_ops == &kgdbdbgp_io_ops)
44046 +static struct kgdb_io kgdbdbgp_io_ops_console;
44047 +#define dbgp_kgdb_mode (dbg_io_ops == &kgdbdbgp_io_ops || dbg_io_ops == &kgdbdbgp_io_ops_console)
44048 #else
44049 #define dbgp_kgdb_mode (0)
44050 #endif
44051 @@ -1047,6 +1048,13 @@ static struct kgdb_io kgdbdbgp_io_ops = {
44052 .write_char = kgdbdbgp_write_char,
44053 };
44054
44055 +static struct kgdb_io kgdbdbgp_io_ops_console = {
44056 + .name = "kgdbdbgp",
44057 + .read_char = kgdbdbgp_read_char,
44058 + .write_char = kgdbdbgp_write_char,
44059 + .is_console = 1
44060 +};
44061 +
44062 static int kgdbdbgp_wait_time;
44063
44064 static int __init kgdbdbgp_parse_config(char *str)
44065 @@ -1062,8 +1070,10 @@ static int __init kgdbdbgp_parse_config(char *str)
44066 ptr++;
44067 kgdbdbgp_wait_time = simple_strtoul(ptr, &ptr, 10);
44068 }
44069 - kgdb_register_io_module(&kgdbdbgp_io_ops);
44070 - kgdbdbgp_io_ops.is_console = early_dbgp_console.index != -1;
44071 + if (early_dbgp_console.index != -1)
44072 + kgdb_register_io_module(&kgdbdbgp_io_ops_console);
44073 + else
44074 + kgdb_register_io_module(&kgdbdbgp_io_ops);
44075
44076 return 0;
44077 }
44078 diff --git a/drivers/usb/gadget/u_serial.c b/drivers/usb/gadget/u_serial.c
44079 index 598dcc1..032dd4f 100644
44080 --- a/drivers/usb/gadget/u_serial.c
44081 +++ b/drivers/usb/gadget/u_serial.c
44082 @@ -735,9 +735,9 @@ static int gs_open(struct tty_struct *tty, struct file *file)
44083 spin_lock_irq(&port->port_lock);
44084
44085 /* already open? Great. */
44086 - if (port->port.count) {
44087 + if (atomic_read(&port->port.count)) {
44088 status = 0;
44089 - port->port.count++;
44090 + atomic_inc(&port->port.count);
44091
44092 /* currently opening/closing? wait ... */
44093 } else if (port->openclose) {
44094 @@ -796,7 +796,7 @@ static int gs_open(struct tty_struct *tty, struct file *file)
44095 tty->driver_data = port;
44096 port->port.tty = tty;
44097
44098 - port->port.count = 1;
44099 + atomic_set(&port->port.count, 1);
44100 port->openclose = false;
44101
44102 /* if connected, start the I/O stream */
44103 @@ -838,11 +838,11 @@ static void gs_close(struct tty_struct *tty, struct file *file)
44104
44105 spin_lock_irq(&port->port_lock);
44106
44107 - if (port->port.count != 1) {
44108 - if (port->port.count == 0)
44109 + if (atomic_read(&port->port.count) != 1) {
44110 + if (atomic_read(&port->port.count) == 0)
44111 WARN_ON(1);
44112 else
44113 - --port->port.count;
44114 + atomic_dec(&port->port.count);
44115 goto exit;
44116 }
44117
44118 @@ -852,7 +852,7 @@ static void gs_close(struct tty_struct *tty, struct file *file)
44119 * and sleep if necessary
44120 */
44121 port->openclose = true;
44122 - port->port.count = 0;
44123 + atomic_set(&port->port.count, 0);
44124
44125 gser = port->port_usb;
44126 if (gser && gser->disconnect)
44127 @@ -1159,7 +1159,7 @@ static int gs_closed(struct gs_port *port)
44128 int cond;
44129
44130 spin_lock_irq(&port->port_lock);
44131 - cond = (port->port.count == 0) && !port->openclose;
44132 + cond = (atomic_read(&port->port.count) == 0) && !port->openclose;
44133 spin_unlock_irq(&port->port_lock);
44134 return cond;
44135 }
44136 @@ -1273,7 +1273,7 @@ int gserial_connect(struct gserial *gser, u8 port_num)
44137 /* if it's already open, start I/O ... and notify the serial
44138 * protocol about open/close status (connect/disconnect).
44139 */
44140 - if (port->port.count) {
44141 + if (atomic_read(&port->port.count)) {
44142 pr_debug("gserial_connect: start ttyGS%d\n", port->port_num);
44143 gs_start_io(port);
44144 if (gser->connect)
44145 @@ -1320,7 +1320,7 @@ void gserial_disconnect(struct gserial *gser)
44146
44147 port->port_usb = NULL;
44148 gser->ioport = NULL;
44149 - if (port->port.count > 0 || port->openclose) {
44150 + if (atomic_read(&port->port.count) > 0 || port->openclose) {
44151 wake_up_interruptible(&port->drain_wait);
44152 if (port->port.tty)
44153 tty_hangup(port->port.tty);
44154 @@ -1336,7 +1336,7 @@ void gserial_disconnect(struct gserial *gser)
44155
44156 /* finally, free any unused/unusable I/O buffers */
44157 spin_lock_irqsave(&port->port_lock, flags);
44158 - if (port->port.count == 0 && !port->openclose)
44159 + if (atomic_read(&port->port.count) == 0 && !port->openclose)
44160 gs_buf_free(&port->port_write_buf);
44161 gs_free_requests(gser->out, &port->read_pool, NULL);
44162 gs_free_requests(gser->out, &port->read_queue, NULL);
44163 diff --git a/drivers/usb/serial/console.c b/drivers/usb/serial/console.c
44164 index 5f3bcd3..bfca43f 100644
44165 --- a/drivers/usb/serial/console.c
44166 +++ b/drivers/usb/serial/console.c
44167 @@ -124,7 +124,7 @@ static int usb_console_setup(struct console *co, char *options)
44168
44169 info->port = port;
44170
44171 - ++port->port.count;
44172 + atomic_inc(&port->port.count);
44173 if (!test_bit(ASYNCB_INITIALIZED, &port->port.flags)) {
44174 if (serial->type->set_termios) {
44175 /*
44176 @@ -174,7 +174,7 @@ static int usb_console_setup(struct console *co, char *options)
44177 }
44178 /* Now that any required fake tty operations are completed restore
44179 * the tty port count */
44180 - --port->port.count;
44181 + atomic_dec(&port->port.count);
44182 /* The console is special in terms of closing the device so
44183 * indicate this port is now acting as a system console. */
44184 port->port.console = 1;
44185 @@ -187,7 +187,7 @@ static int usb_console_setup(struct console *co, char *options)
44186 free_tty:
44187 kfree(tty);
44188 reset_open_count:
44189 - port->port.count = 0;
44190 + atomic_set(&port->port.count, 0);
44191 usb_autopm_put_interface(serial->interface);
44192 error_get_interface:
44193 usb_serial_put(serial);
44194 diff --git a/drivers/usb/storage/usb.h b/drivers/usb/storage/usb.h
44195 index 75f70f0..d467e1a 100644
44196 --- a/drivers/usb/storage/usb.h
44197 +++ b/drivers/usb/storage/usb.h
44198 @@ -63,7 +63,7 @@ struct us_unusual_dev {
44199 __u8 useProtocol;
44200 __u8 useTransport;
44201 int (*initFunction)(struct us_data *);
44202 -};
44203 +} __do_const;
44204
44205
44206 /* Dynamic bitflag definitions (us->dflags): used in set_bit() etc. */
44207 diff --git a/drivers/usb/wusbcore/wa-hc.h b/drivers/usb/wusbcore/wa-hc.h
44208 index d6bea3e..60b250e 100644
44209 --- a/drivers/usb/wusbcore/wa-hc.h
44210 +++ b/drivers/usb/wusbcore/wa-hc.h
44211 @@ -192,7 +192,7 @@ struct wahc {
44212 struct list_head xfer_delayed_list;
44213 spinlock_t xfer_list_lock;
44214 struct work_struct xfer_work;
44215 - atomic_t xfer_id_count;
44216 + atomic_unchecked_t xfer_id_count;
44217 };
44218
44219
44220 @@ -246,7 +246,7 @@ static inline void wa_init(struct wahc *wa)
44221 INIT_LIST_HEAD(&wa->xfer_delayed_list);
44222 spin_lock_init(&wa->xfer_list_lock);
44223 INIT_WORK(&wa->xfer_work, wa_urb_enqueue_run);
44224 - atomic_set(&wa->xfer_id_count, 1);
44225 + atomic_set_unchecked(&wa->xfer_id_count, 1);
44226 }
44227
44228 /**
44229 diff --git a/drivers/usb/wusbcore/wa-xfer.c b/drivers/usb/wusbcore/wa-xfer.c
44230 index 57c01ab..8a05959 100644
44231 --- a/drivers/usb/wusbcore/wa-xfer.c
44232 +++ b/drivers/usb/wusbcore/wa-xfer.c
44233 @@ -296,7 +296,7 @@ out:
44234 */
44235 static void wa_xfer_id_init(struct wa_xfer *xfer)
44236 {
44237 - xfer->id = atomic_add_return(1, &xfer->wa->xfer_id_count);
44238 + xfer->id = atomic_add_return_unchecked(1, &xfer->wa->xfer_id_count);
44239 }
44240
44241 /*
44242 diff --git a/drivers/video/aty/aty128fb.c b/drivers/video/aty/aty128fb.c
44243 index 8c55011..eed4ae1a 100644
44244 --- a/drivers/video/aty/aty128fb.c
44245 +++ b/drivers/video/aty/aty128fb.c
44246 @@ -149,7 +149,7 @@ enum {
44247 };
44248
44249 /* Must match above enum */
44250 -static char * const r128_family[] = {
44251 +static const char * const r128_family[] = {
44252 "AGP",
44253 "PCI",
44254 "PRO AGP",
44255 diff --git a/drivers/video/aty/atyfb_base.c b/drivers/video/aty/atyfb_base.c
44256 index 4f27fdc..d3537e6 100644
44257 --- a/drivers/video/aty/atyfb_base.c
44258 +++ b/drivers/video/aty/atyfb_base.c
44259 @@ -1325,10 +1325,14 @@ static int atyfb_set_par(struct fb_info *info)
44260 par->accel_flags = var->accel_flags; /* hack */
44261
44262 if (var->accel_flags) {
44263 - info->fbops->fb_sync = atyfb_sync;
44264 + pax_open_kernel();
44265 + *(void **)&info->fbops->fb_sync = atyfb_sync;
44266 + pax_close_kernel();
44267 info->flags &= ~FBINFO_HWACCEL_DISABLED;
44268 } else {
44269 - info->fbops->fb_sync = NULL;
44270 + pax_open_kernel();
44271 + *(void **)&info->fbops->fb_sync = NULL;
44272 + pax_close_kernel();
44273 info->flags |= FBINFO_HWACCEL_DISABLED;
44274 }
44275
44276 diff --git a/drivers/video/aty/mach64_cursor.c b/drivers/video/aty/mach64_cursor.c
44277 index 95ec042..e6affdd 100644
44278 --- a/drivers/video/aty/mach64_cursor.c
44279 +++ b/drivers/video/aty/mach64_cursor.c
44280 @@ -7,6 +7,7 @@
44281 #include <linux/string.h>
44282
44283 #include <asm/io.h>
44284 +#include <asm/pgtable.h>
44285
44286 #ifdef __sparc__
44287 #include <asm/fbio.h>
44288 @@ -208,7 +209,9 @@ int aty_init_cursor(struct fb_info *info)
44289 info->sprite.buf_align = 16; /* and 64 lines tall. */
44290 info->sprite.flags = FB_PIXMAP_IO;
44291
44292 - info->fbops->fb_cursor = atyfb_cursor;
44293 + pax_open_kernel();
44294 + *(void **)&info->fbops->fb_cursor = atyfb_cursor;
44295 + pax_close_kernel();
44296
44297 return 0;
44298 }
44299 diff --git a/drivers/video/backlight/kb3886_bl.c b/drivers/video/backlight/kb3886_bl.c
44300 index 6c5ed6b..b727c88 100644
44301 --- a/drivers/video/backlight/kb3886_bl.c
44302 +++ b/drivers/video/backlight/kb3886_bl.c
44303 @@ -78,7 +78,7 @@ static struct kb3886bl_machinfo *bl_machinfo;
44304 static unsigned long kb3886bl_flags;
44305 #define KB3886BL_SUSPENDED 0x01
44306
44307 -static struct dmi_system_id __initdata kb3886bl_device_table[] = {
44308 +static const struct dmi_system_id __initconst kb3886bl_device_table[] = {
44309 {
44310 .ident = "Sahara Touch-iT",
44311 .matches = {
44312 diff --git a/drivers/video/fb_defio.c b/drivers/video/fb_defio.c
44313 index 88cad6b..dd746c7 100644
44314 --- a/drivers/video/fb_defio.c
44315 +++ b/drivers/video/fb_defio.c
44316 @@ -206,7 +206,9 @@ void fb_deferred_io_init(struct fb_info *info)
44317
44318 BUG_ON(!fbdefio);
44319 mutex_init(&fbdefio->lock);
44320 - info->fbops->fb_mmap = fb_deferred_io_mmap;
44321 + pax_open_kernel();
44322 + *(void **)&info->fbops->fb_mmap = fb_deferred_io_mmap;
44323 + pax_close_kernel();
44324 INIT_DELAYED_WORK(&info->deferred_work, fb_deferred_io_work);
44325 INIT_LIST_HEAD(&fbdefio->pagelist);
44326 if (fbdefio->delay == 0) /* set a default of 1 s */
44327 @@ -237,7 +239,7 @@ void fb_deferred_io_cleanup(struct fb_info *info)
44328 page->mapping = NULL;
44329 }
44330
44331 - info->fbops->fb_mmap = NULL;
44332 + *(void **)&info->fbops->fb_mmap = NULL;
44333 mutex_destroy(&fbdefio->lock);
44334 }
44335 EXPORT_SYMBOL_GPL(fb_deferred_io_cleanup);
44336 diff --git a/drivers/video/fbcmap.c b/drivers/video/fbcmap.c
44337 index 5c3960d..15cf8fc 100644
44338 --- a/drivers/video/fbcmap.c
44339 +++ b/drivers/video/fbcmap.c
44340 @@ -285,8 +285,7 @@ int fb_set_user_cmap(struct fb_cmap_user *cmap, struct fb_info *info)
44341 rc = -ENODEV;
44342 goto out;
44343 }
44344 - if (cmap->start < 0 || (!info->fbops->fb_setcolreg &&
44345 - !info->fbops->fb_setcmap)) {
44346 + if (!info->fbops->fb_setcolreg && !info->fbops->fb_setcmap) {
44347 rc = -EINVAL;
44348 goto out1;
44349 }
44350 diff --git a/drivers/video/fbmem.c b/drivers/video/fbmem.c
44351 index dc61c12..e29796e 100644
44352 --- a/drivers/video/fbmem.c
44353 +++ b/drivers/video/fbmem.c
44354 @@ -428,7 +428,7 @@ static void fb_do_show_logo(struct fb_info *info, struct fb_image *image,
44355 image->dx += image->width + 8;
44356 }
44357 } else if (rotate == FB_ROTATE_UD) {
44358 - for (x = 0; x < num && image->dx >= 0; x++) {
44359 + for (x = 0; x < num && (__s32)image->dx >= 0; x++) {
44360 info->fbops->fb_imageblit(info, image);
44361 image->dx -= image->width + 8;
44362 }
44363 @@ -440,7 +440,7 @@ static void fb_do_show_logo(struct fb_info *info, struct fb_image *image,
44364 image->dy += image->height + 8;
44365 }
44366 } else if (rotate == FB_ROTATE_CCW) {
44367 - for (x = 0; x < num && image->dy >= 0; x++) {
44368 + for (x = 0; x < num && (__s32)image->dy >= 0; x++) {
44369 info->fbops->fb_imageblit(info, image);
44370 image->dy -= image->height + 8;
44371 }
44372 @@ -1166,7 +1166,7 @@ static long do_fb_ioctl(struct fb_info *info, unsigned int cmd,
44373 return -EFAULT;
44374 if (con2fb.console < 1 || con2fb.console > MAX_NR_CONSOLES)
44375 return -EINVAL;
44376 - if (con2fb.framebuffer < 0 || con2fb.framebuffer >= FB_MAX)
44377 + if (con2fb.framebuffer >= FB_MAX)
44378 return -EINVAL;
44379 if (!registered_fb[con2fb.framebuffer])
44380 request_module("fb%d", con2fb.framebuffer);
44381 diff --git a/drivers/video/i810/i810_accel.c b/drivers/video/i810/i810_accel.c
44382 index 7672d2e..b56437f 100644
44383 --- a/drivers/video/i810/i810_accel.c
44384 +++ b/drivers/video/i810/i810_accel.c
44385 @@ -73,6 +73,7 @@ static inline int wait_for_space(struct fb_info *info, u32 space)
44386 }
44387 }
44388 printk("ringbuffer lockup!!!\n");
44389 + printk("head:%u tail:%u iring.size:%u space:%u\n", head, tail, par->iring.size, space);
44390 i810_report_error(mmio);
44391 par->dev_flags |= LOCKUP;
44392 info->pixmap.scan_align = 1;
44393 diff --git a/drivers/video/logo/logo_linux_clut224.ppm b/drivers/video/logo/logo_linux_clut224.ppm
44394 index 3c14e43..eafa544 100644
44395 --- a/drivers/video/logo/logo_linux_clut224.ppm
44396 +++ b/drivers/video/logo/logo_linux_clut224.ppm
44397 @@ -1,1604 +1,1123 @@
44398 P3
44399 -# Standard 224-color Linux logo
44400 80 80
44401 255
44402 - 0 0 0 0 0 0 0 0 0 0 0 0
44403 - 0 0 0 0 0 0 0 0 0 0 0 0
44404 - 0 0 0 0 0 0 0 0 0 0 0 0
44405 - 0 0 0 0 0 0 0 0 0 0 0 0
44406 - 0 0 0 0 0 0 0 0 0 0 0 0
44407 - 0 0 0 0 0 0 0 0 0 0 0 0
44408 - 0 0 0 0 0 0 0 0 0 0 0 0
44409 - 0 0 0 0 0 0 0 0 0 0 0 0
44410 - 0 0 0 0 0 0 0 0 0 0 0 0
44411 - 6 6 6 6 6 6 10 10 10 10 10 10
44412 - 10 10 10 6 6 6 6 6 6 6 6 6
44413 - 0 0 0 0 0 0 0 0 0 0 0 0
44414 - 0 0 0 0 0 0 0 0 0 0 0 0
44415 - 0 0 0 0 0 0 0 0 0 0 0 0
44416 - 0 0 0 0 0 0 0 0 0 0 0 0
44417 - 0 0 0 0 0 0 0 0 0 0 0 0
44418 - 0 0 0 0 0 0 0 0 0 0 0 0
44419 - 0 0 0 0 0 0 0 0 0 0 0 0
44420 - 0 0 0 0 0 0 0 0 0 0 0 0
44421 - 0 0 0 0 0 0 0 0 0 0 0 0
44422 - 0 0 0 0 0 0 0 0 0 0 0 0
44423 - 0 0 0 0 0 0 0 0 0 0 0 0
44424 - 0 0 0 0 0 0 0 0 0 0 0 0
44425 - 0 0 0 0 0 0 0 0 0 0 0 0
44426 - 0 0 0 0 0 0 0 0 0 0 0 0
44427 - 0 0 0 0 0 0 0 0 0 0 0 0
44428 - 0 0 0 0 0 0 0 0 0 0 0 0
44429 - 0 0 0 0 0 0 0 0 0 0 0 0
44430 - 0 0 0 6 6 6 10 10 10 14 14 14
44431 - 22 22 22 26 26 26 30 30 30 34 34 34
44432 - 30 30 30 30 30 30 26 26 26 18 18 18
44433 - 14 14 14 10 10 10 6 6 6 0 0 0
44434 - 0 0 0 0 0 0 0 0 0 0 0 0
44435 - 0 0 0 0 0 0 0 0 0 0 0 0
44436 - 0 0 0 0 0 0 0 0 0 0 0 0
44437 - 0 0 0 0 0 0 0 0 0 0 0 0
44438 - 0 0 0 0 0 0 0 0 0 0 0 0
44439 - 0 0 0 0 0 0 0 0 0 0 0 0
44440 - 0 0 0 0 0 0 0 0 0 0 0 0
44441 - 0 0 0 0 0 0 0 0 0 0 0 0
44442 - 0 0 0 0 0 0 0 0 0 0 0 0
44443 - 0 0 0 0 0 1 0 0 1 0 0 0
44444 - 0 0 0 0 0 0 0 0 0 0 0 0
44445 - 0 0 0 0 0 0 0 0 0 0 0 0
44446 - 0 0 0 0 0 0 0 0 0 0 0 0
44447 - 0 0 0 0 0 0 0 0 0 0 0 0
44448 - 0 0 0 0 0 0 0 0 0 0 0 0
44449 - 0 0 0 0 0 0 0 0 0 0 0 0
44450 - 6 6 6 14 14 14 26 26 26 42 42 42
44451 - 54 54 54 66 66 66 78 78 78 78 78 78
44452 - 78 78 78 74 74 74 66 66 66 54 54 54
44453 - 42 42 42 26 26 26 18 18 18 10 10 10
44454 - 6 6 6 0 0 0 0 0 0 0 0 0
44455 - 0 0 0 0 0 0 0 0 0 0 0 0
44456 - 0 0 0 0 0 0 0 0 0 0 0 0
44457 - 0 0 0 0 0 0 0 0 0 0 0 0
44458 - 0 0 0 0 0 0 0 0 0 0 0 0
44459 - 0 0 0 0 0 0 0 0 0 0 0 0
44460 - 0 0 0 0 0 0 0 0 0 0 0 0
44461 - 0 0 0 0 0 0 0 0 0 0 0 0
44462 - 0 0 0 0 0 0 0 0 0 0 0 0
44463 - 0 0 1 0 0 0 0 0 0 0 0 0
44464 - 0 0 0 0 0 0 0 0 0 0 0 0
44465 - 0 0 0 0 0 0 0 0 0 0 0 0
44466 - 0 0 0 0 0 0 0 0 0 0 0 0
44467 - 0 0 0 0 0 0 0 0 0 0 0 0
44468 - 0 0 0 0 0 0 0 0 0 0 0 0
44469 - 0 0 0 0 0 0 0 0 0 10 10 10
44470 - 22 22 22 42 42 42 66 66 66 86 86 86
44471 - 66 66 66 38 38 38 38 38 38 22 22 22
44472 - 26 26 26 34 34 34 54 54 54 66 66 66
44473 - 86 86 86 70 70 70 46 46 46 26 26 26
44474 - 14 14 14 6 6 6 0 0 0 0 0 0
44475 - 0 0 0 0 0 0 0 0 0 0 0 0
44476 - 0 0 0 0 0 0 0 0 0 0 0 0
44477 - 0 0 0 0 0 0 0 0 0 0 0 0
44478 - 0 0 0 0 0 0 0 0 0 0 0 0
44479 - 0 0 0 0 0 0 0 0 0 0 0 0
44480 - 0 0 0 0 0 0 0 0 0 0 0 0
44481 - 0 0 0 0 0 0 0 0 0 0 0 0
44482 - 0 0 0 0 0 0 0 0 0 0 0 0
44483 - 0 0 1 0 0 1 0 0 1 0 0 0
44484 - 0 0 0 0 0 0 0 0 0 0 0 0
44485 - 0 0 0 0 0 0 0 0 0 0 0 0
44486 - 0 0 0 0 0 0 0 0 0 0 0 0
44487 - 0 0 0 0 0 0 0 0 0 0 0 0
44488 - 0 0 0 0 0 0 0 0 0 0 0 0
44489 - 0 0 0 0 0 0 10 10 10 26 26 26
44490 - 50 50 50 82 82 82 58 58 58 6 6 6
44491 - 2 2 6 2 2 6 2 2 6 2 2 6
44492 - 2 2 6 2 2 6 2 2 6 2 2 6
44493 - 6 6 6 54 54 54 86 86 86 66 66 66
44494 - 38 38 38 18 18 18 6 6 6 0 0 0
44495 - 0 0 0 0 0 0 0 0 0 0 0 0
44496 - 0 0 0 0 0 0 0 0 0 0 0 0
44497 - 0 0 0 0 0 0 0 0 0 0 0 0
44498 - 0 0 0 0 0 0 0 0 0 0 0 0
44499 - 0 0 0 0 0 0 0 0 0 0 0 0
44500 - 0 0 0 0 0 0 0 0 0 0 0 0
44501 - 0 0 0 0 0 0 0 0 0 0 0 0
44502 - 0 0 0 0 0 0 0 0 0 0 0 0
44503 - 0 0 0 0 0 0 0 0 0 0 0 0
44504 - 0 0 0 0 0 0 0 0 0 0 0 0
44505 - 0 0 0 0 0 0 0 0 0 0 0 0
44506 - 0 0 0 0 0 0 0 0 0 0 0 0
44507 - 0 0 0 0 0 0 0 0 0 0 0 0
44508 - 0 0 0 0 0 0 0 0 0 0 0 0
44509 - 0 0 0 6 6 6 22 22 22 50 50 50
44510 - 78 78 78 34 34 34 2 2 6 2 2 6
44511 - 2 2 6 2 2 6 2 2 6 2 2 6
44512 - 2 2 6 2 2 6 2 2 6 2 2 6
44513 - 2 2 6 2 2 6 6 6 6 70 70 70
44514 - 78 78 78 46 46 46 22 22 22 6 6 6
44515 - 0 0 0 0 0 0 0 0 0 0 0 0
44516 - 0 0 0 0 0 0 0 0 0 0 0 0
44517 - 0 0 0 0 0 0 0 0 0 0 0 0
44518 - 0 0 0 0 0 0 0 0 0 0 0 0
44519 - 0 0 0 0 0 0 0 0 0 0 0 0
44520 - 0 0 0 0 0 0 0 0 0 0 0 0
44521 - 0 0 0 0 0 0 0 0 0 0 0 0
44522 - 0 0 0 0 0 0 0 0 0 0 0 0
44523 - 0 0 1 0 0 1 0 0 1 0 0 0
44524 - 0 0 0 0 0 0 0 0 0 0 0 0
44525 - 0 0 0 0 0 0 0 0 0 0 0 0
44526 - 0 0 0 0 0 0 0 0 0 0 0 0
44527 - 0 0 0 0 0 0 0 0 0 0 0 0
44528 - 0 0 0 0 0 0 0 0 0 0 0 0
44529 - 6 6 6 18 18 18 42 42 42 82 82 82
44530 - 26 26 26 2 2 6 2 2 6 2 2 6
44531 - 2 2 6 2 2 6 2 2 6 2 2 6
44532 - 2 2 6 2 2 6 2 2 6 14 14 14
44533 - 46 46 46 34 34 34 6 6 6 2 2 6
44534 - 42 42 42 78 78 78 42 42 42 18 18 18
44535 - 6 6 6 0 0 0 0 0 0 0 0 0
44536 - 0 0 0 0 0 0 0 0 0 0 0 0
44537 - 0 0 0 0 0 0 0 0 0 0 0 0
44538 - 0 0 0 0 0 0 0 0 0 0 0 0
44539 - 0 0 0 0 0 0 0 0 0 0 0 0
44540 - 0 0 0 0 0 0 0 0 0 0 0 0
44541 - 0 0 0 0 0 0 0 0 0 0 0 0
44542 - 0 0 0 0 0 0 0 0 0 0 0 0
44543 - 0 0 1 0 0 0 0 0 1 0 0 0
44544 - 0 0 0 0 0 0 0 0 0 0 0 0
44545 - 0 0 0 0 0 0 0 0 0 0 0 0
44546 - 0 0 0 0 0 0 0 0 0 0 0 0
44547 - 0 0 0 0 0 0 0 0 0 0 0 0
44548 - 0 0 0 0 0 0 0 0 0 0 0 0
44549 - 10 10 10 30 30 30 66 66 66 58 58 58
44550 - 2 2 6 2 2 6 2 2 6 2 2 6
44551 - 2 2 6 2 2 6 2 2 6 2 2 6
44552 - 2 2 6 2 2 6 2 2 6 26 26 26
44553 - 86 86 86 101 101 101 46 46 46 10 10 10
44554 - 2 2 6 58 58 58 70 70 70 34 34 34
44555 - 10 10 10 0 0 0 0 0 0 0 0 0
44556 - 0 0 0 0 0 0 0 0 0 0 0 0
44557 - 0 0 0 0 0 0 0 0 0 0 0 0
44558 - 0 0 0 0 0 0 0 0 0 0 0 0
44559 - 0 0 0 0 0 0 0 0 0 0 0 0
44560 - 0 0 0 0 0 0 0 0 0 0 0 0
44561 - 0 0 0 0 0 0 0 0 0 0 0 0
44562 - 0 0 0 0 0 0 0 0 0 0 0 0
44563 - 0 0 1 0 0 1 0 0 1 0 0 0
44564 - 0 0 0 0 0 0 0 0 0 0 0 0
44565 - 0 0 0 0 0 0 0 0 0 0 0 0
44566 - 0 0 0 0 0 0 0 0 0 0 0 0
44567 - 0 0 0 0 0 0 0 0 0 0 0 0
44568 - 0 0 0 0 0 0 0 0 0 0 0 0
44569 - 14 14 14 42 42 42 86 86 86 10 10 10
44570 - 2 2 6 2 2 6 2 2 6 2 2 6
44571 - 2 2 6 2 2 6 2 2 6 2 2 6
44572 - 2 2 6 2 2 6 2 2 6 30 30 30
44573 - 94 94 94 94 94 94 58 58 58 26 26 26
44574 - 2 2 6 6 6 6 78 78 78 54 54 54
44575 - 22 22 22 6 6 6 0 0 0 0 0 0
44576 - 0 0 0 0 0 0 0 0 0 0 0 0
44577 - 0 0 0 0 0 0 0 0 0 0 0 0
44578 - 0 0 0 0 0 0 0 0 0 0 0 0
44579 - 0 0 0 0 0 0 0 0 0 0 0 0
44580 - 0 0 0 0 0 0 0 0 0 0 0 0
44581 - 0 0 0 0 0 0 0 0 0 0 0 0
44582 - 0 0 0 0 0 0 0 0 0 0 0 0
44583 - 0 0 0 0 0 0 0 0 0 0 0 0
44584 - 0 0 0 0 0 0 0 0 0 0 0 0
44585 - 0 0 0 0 0 0 0 0 0 0 0 0
44586 - 0 0 0 0 0 0 0 0 0 0 0 0
44587 - 0 0 0 0 0 0 0 0 0 0 0 0
44588 - 0 0 0 0 0 0 0 0 0 6 6 6
44589 - 22 22 22 62 62 62 62 62 62 2 2 6
44590 - 2 2 6 2 2 6 2 2 6 2 2 6
44591 - 2 2 6 2 2 6 2 2 6 2 2 6
44592 - 2 2 6 2 2 6 2 2 6 26 26 26
44593 - 54 54 54 38 38 38 18 18 18 10 10 10
44594 - 2 2 6 2 2 6 34 34 34 82 82 82
44595 - 38 38 38 14 14 14 0 0 0 0 0 0
44596 - 0 0 0 0 0 0 0 0 0 0 0 0
44597 - 0 0 0 0 0 0 0 0 0 0 0 0
44598 - 0 0 0 0 0 0 0 0 0 0 0 0
44599 - 0 0 0 0 0 0 0 0 0 0 0 0
44600 - 0 0 0 0 0 0 0 0 0 0 0 0
44601 - 0 0 0 0 0 0 0 0 0 0 0 0
44602 - 0 0 0 0 0 0 0 0 0 0 0 0
44603 - 0 0 0 0 0 1 0 0 1 0 0 0
44604 - 0 0 0 0 0 0 0 0 0 0 0 0
44605 - 0 0 0 0 0 0 0 0 0 0 0 0
44606 - 0 0 0 0 0 0 0 0 0 0 0 0
44607 - 0 0 0 0 0 0 0 0 0 0 0 0
44608 - 0 0 0 0 0 0 0 0 0 6 6 6
44609 - 30 30 30 78 78 78 30 30 30 2 2 6
44610 - 2 2 6 2 2 6 2 2 6 2 2 6
44611 - 2 2 6 2 2 6 2 2 6 2 2 6
44612 - 2 2 6 2 2 6 2 2 6 10 10 10
44613 - 10 10 10 2 2 6 2 2 6 2 2 6
44614 - 2 2 6 2 2 6 2 2 6 78 78 78
44615 - 50 50 50 18 18 18 6 6 6 0 0 0
44616 - 0 0 0 0 0 0 0 0 0 0 0 0
44617 - 0 0 0 0 0 0 0 0 0 0 0 0
44618 - 0 0 0 0 0 0 0 0 0 0 0 0
44619 - 0 0 0 0 0 0 0 0 0 0 0 0
44620 - 0 0 0 0 0 0 0 0 0 0 0 0
44621 - 0 0 0 0 0 0 0 0 0 0 0 0
44622 - 0 0 0 0 0 0 0 0 0 0 0 0
44623 - 0 0 1 0 0 0 0 0 0 0 0 0
44624 - 0 0 0 0 0 0 0 0 0 0 0 0
44625 - 0 0 0 0 0 0 0 0 0 0 0 0
44626 - 0 0 0 0 0 0 0 0 0 0 0 0
44627 - 0 0 0 0 0 0 0 0 0 0 0 0
44628 - 0 0 0 0 0 0 0 0 0 10 10 10
44629 - 38 38 38 86 86 86 14 14 14 2 2 6
44630 - 2 2 6 2 2 6 2 2 6 2 2 6
44631 - 2 2 6 2 2 6 2 2 6 2 2 6
44632 - 2 2 6 2 2 6 2 2 6 2 2 6
44633 - 2 2 6 2 2 6 2 2 6 2 2 6
44634 - 2 2 6 2 2 6 2 2 6 54 54 54
44635 - 66 66 66 26 26 26 6 6 6 0 0 0
44636 - 0 0 0 0 0 0 0 0 0 0 0 0
44637 - 0 0 0 0 0 0 0 0 0 0 0 0
44638 - 0 0 0 0 0 0 0 0 0 0 0 0
44639 - 0 0 0 0 0 0 0 0 0 0 0 0
44640 - 0 0 0 0 0 0 0 0 0 0 0 0
44641 - 0 0 0 0 0 0 0 0 0 0 0 0
44642 - 0 0 0 0 0 0 0 0 0 0 0 0
44643 - 0 0 0 0 0 1 0 0 1 0 0 0
44644 - 0 0 0 0 0 0 0 0 0 0 0 0
44645 - 0 0 0 0 0 0 0 0 0 0 0 0
44646 - 0 0 0 0 0 0 0 0 0 0 0 0
44647 - 0 0 0 0 0 0 0 0 0 0 0 0
44648 - 0 0 0 0 0 0 0 0 0 14 14 14
44649 - 42 42 42 82 82 82 2 2 6 2 2 6
44650 - 2 2 6 6 6 6 10 10 10 2 2 6
44651 - 2 2 6 2 2 6 2 2 6 2 2 6
44652 - 2 2 6 2 2 6 2 2 6 6 6 6
44653 - 14 14 14 10 10 10 2 2 6 2 2 6
44654 - 2 2 6 2 2 6 2 2 6 18 18 18
44655 - 82 82 82 34 34 34 10 10 10 0 0 0
44656 - 0 0 0 0 0 0 0 0 0 0 0 0
44657 - 0 0 0 0 0 0 0 0 0 0 0 0
44658 - 0 0 0 0 0 0 0 0 0 0 0 0
44659 - 0 0 0 0 0 0 0 0 0 0 0 0
44660 - 0 0 0 0 0 0 0 0 0 0 0 0
44661 - 0 0 0 0 0 0 0 0 0 0 0 0
44662 - 0 0 0 0 0 0 0 0 0 0 0 0
44663 - 0 0 1 0 0 0 0 0 0 0 0 0
44664 - 0 0 0 0 0 0 0 0 0 0 0 0
44665 - 0 0 0 0 0 0 0 0 0 0 0 0
44666 - 0 0 0 0 0 0 0 0 0 0 0 0
44667 - 0 0 0 0 0 0 0 0 0 0 0 0
44668 - 0 0 0 0 0 0 0 0 0 14 14 14
44669 - 46 46 46 86 86 86 2 2 6 2 2 6
44670 - 6 6 6 6 6 6 22 22 22 34 34 34
44671 - 6 6 6 2 2 6 2 2 6 2 2 6
44672 - 2 2 6 2 2 6 18 18 18 34 34 34
44673 - 10 10 10 50 50 50 22 22 22 2 2 6
44674 - 2 2 6 2 2 6 2 2 6 10 10 10
44675 - 86 86 86 42 42 42 14 14 14 0 0 0
44676 - 0 0 0 0 0 0 0 0 0 0 0 0
44677 - 0 0 0 0 0 0 0 0 0 0 0 0
44678 - 0 0 0 0 0 0 0 0 0 0 0 0
44679 - 0 0 0 0 0 0 0 0 0 0 0 0
44680 - 0 0 0 0 0 0 0 0 0 0 0 0
44681 - 0 0 0 0 0 0 0 0 0 0 0 0
44682 - 0 0 0 0 0 0 0 0 0 0 0 0
44683 - 0 0 1 0 0 1 0 0 1 0 0 0
44684 - 0 0 0 0 0 0 0 0 0 0 0 0
44685 - 0 0 0 0 0 0 0 0 0 0 0 0
44686 - 0 0 0 0 0 0 0 0 0 0 0 0
44687 - 0 0 0 0 0 0 0 0 0 0 0 0
44688 - 0 0 0 0 0 0 0 0 0 14 14 14
44689 - 46 46 46 86 86 86 2 2 6 2 2 6
44690 - 38 38 38 116 116 116 94 94 94 22 22 22
44691 - 22 22 22 2 2 6 2 2 6 2 2 6
44692 - 14 14 14 86 86 86 138 138 138 162 162 162
44693 -154 154 154 38 38 38 26 26 26 6 6 6
44694 - 2 2 6 2 2 6 2 2 6 2 2 6
44695 - 86 86 86 46 46 46 14 14 14 0 0 0
44696 - 0 0 0 0 0 0 0 0 0 0 0 0
44697 - 0 0 0 0 0 0 0 0 0 0 0 0
44698 - 0 0 0 0 0 0 0 0 0 0 0 0
44699 - 0 0 0 0 0 0 0 0 0 0 0 0
44700 - 0 0 0 0 0 0 0 0 0 0 0 0
44701 - 0 0 0 0 0 0 0 0 0 0 0 0
44702 - 0 0 0 0 0 0 0 0 0 0 0 0
44703 - 0 0 0 0 0 0 0 0 0 0 0 0
44704 - 0 0 0 0 0 0 0 0 0 0 0 0
44705 - 0 0 0 0 0 0 0 0 0 0 0 0
44706 - 0 0 0 0 0 0 0 0 0 0 0 0
44707 - 0 0 0 0 0 0 0 0 0 0 0 0
44708 - 0 0 0 0 0 0 0 0 0 14 14 14
44709 - 46 46 46 86 86 86 2 2 6 14 14 14
44710 -134 134 134 198 198 198 195 195 195 116 116 116
44711 - 10 10 10 2 2 6 2 2 6 6 6 6
44712 -101 98 89 187 187 187 210 210 210 218 218 218
44713 -214 214 214 134 134 134 14 14 14 6 6 6
44714 - 2 2 6 2 2 6 2 2 6 2 2 6
44715 - 86 86 86 50 50 50 18 18 18 6 6 6
44716 - 0 0 0 0 0 0 0 0 0 0 0 0
44717 - 0 0 0 0 0 0 0 0 0 0 0 0
44718 - 0 0 0 0 0 0 0 0 0 0 0 0
44719 - 0 0 0 0 0 0 0 0 0 0 0 0
44720 - 0 0 0 0 0 0 0 0 0 0 0 0
44721 - 0 0 0 0 0 0 0 0 0 0 0 0
44722 - 0 0 0 0 0 0 0 0 1 0 0 0
44723 - 0 0 1 0 0 1 0 0 1 0 0 0
44724 - 0 0 0 0 0 0 0 0 0 0 0 0
44725 - 0 0 0 0 0 0 0 0 0 0 0 0
44726 - 0 0 0 0 0 0 0 0 0 0 0 0
44727 - 0 0 0 0 0 0 0 0 0 0 0 0
44728 - 0 0 0 0 0 0 0 0 0 14 14 14
44729 - 46 46 46 86 86 86 2 2 6 54 54 54
44730 -218 218 218 195 195 195 226 226 226 246 246 246
44731 - 58 58 58 2 2 6 2 2 6 30 30 30
44732 -210 210 210 253 253 253 174 174 174 123 123 123
44733 -221 221 221 234 234 234 74 74 74 2 2 6
44734 - 2 2 6 2 2 6 2 2 6 2 2 6
44735 - 70 70 70 58 58 58 22 22 22 6 6 6
44736 - 0 0 0 0 0 0 0 0 0 0 0 0
44737 - 0 0 0 0 0 0 0 0 0 0 0 0
44738 - 0 0 0 0 0 0 0 0 0 0 0 0
44739 - 0 0 0 0 0 0 0 0 0 0 0 0
44740 - 0 0 0 0 0 0 0 0 0 0 0 0
44741 - 0 0 0 0 0 0 0 0 0 0 0 0
44742 - 0 0 0 0 0 0 0 0 0 0 0 0
44743 - 0 0 0 0 0 0 0 0 0 0 0 0
44744 - 0 0 0 0 0 0 0 0 0 0 0 0
44745 - 0 0 0 0 0 0 0 0 0 0 0 0
44746 - 0 0 0 0 0 0 0 0 0 0 0 0
44747 - 0 0 0 0 0 0 0 0 0 0 0 0
44748 - 0 0 0 0 0 0 0 0 0 14 14 14
44749 - 46 46 46 82 82 82 2 2 6 106 106 106
44750 -170 170 170 26 26 26 86 86 86 226 226 226
44751 -123 123 123 10 10 10 14 14 14 46 46 46
44752 -231 231 231 190 190 190 6 6 6 70 70 70
44753 - 90 90 90 238 238 238 158 158 158 2 2 6
44754 - 2 2 6 2 2 6 2 2 6 2 2 6
44755 - 70 70 70 58 58 58 22 22 22 6 6 6
44756 - 0 0 0 0 0 0 0 0 0 0 0 0
44757 - 0 0 0 0 0 0 0 0 0 0 0 0
44758 - 0 0 0 0 0 0 0 0 0 0 0 0
44759 - 0 0 0 0 0 0 0 0 0 0 0 0
44760 - 0 0 0 0 0 0 0 0 0 0 0 0
44761 - 0 0 0 0 0 0 0 0 0 0 0 0
44762 - 0 0 0 0 0 0 0 0 1 0 0 0
44763 - 0 0 1 0 0 1 0 0 1 0 0 0
44764 - 0 0 0 0 0 0 0 0 0 0 0 0
44765 - 0 0 0 0 0 0 0 0 0 0 0 0
44766 - 0 0 0 0 0 0 0 0 0 0 0 0
44767 - 0 0 0 0 0 0 0 0 0 0 0 0
44768 - 0 0 0 0 0 0 0 0 0 14 14 14
44769 - 42 42 42 86 86 86 6 6 6 116 116 116
44770 -106 106 106 6 6 6 70 70 70 149 149 149
44771 -128 128 128 18 18 18 38 38 38 54 54 54
44772 -221 221 221 106 106 106 2 2 6 14 14 14
44773 - 46 46 46 190 190 190 198 198 198 2 2 6
44774 - 2 2 6 2 2 6 2 2 6 2 2 6
44775 - 74 74 74 62 62 62 22 22 22 6 6 6
44776 - 0 0 0 0 0 0 0 0 0 0 0 0
44777 - 0 0 0 0 0 0 0 0 0 0 0 0
44778 - 0 0 0 0 0 0 0 0 0 0 0 0
44779 - 0 0 0 0 0 0 0 0 0 0 0 0
44780 - 0 0 0 0 0 0 0 0 0 0 0 0
44781 - 0 0 0 0 0 0 0 0 0 0 0 0
44782 - 0 0 0 0 0 0 0 0 1 0 0 0
44783 - 0 0 1 0 0 0 0 0 1 0 0 0
44784 - 0 0 0 0 0 0 0 0 0 0 0 0
44785 - 0 0 0 0 0 0 0 0 0 0 0 0
44786 - 0 0 0 0 0 0 0 0 0 0 0 0
44787 - 0 0 0 0 0 0 0 0 0 0 0 0
44788 - 0 0 0 0 0 0 0 0 0 14 14 14
44789 - 42 42 42 94 94 94 14 14 14 101 101 101
44790 -128 128 128 2 2 6 18 18 18 116 116 116
44791 -118 98 46 121 92 8 121 92 8 98 78 10
44792 -162 162 162 106 106 106 2 2 6 2 2 6
44793 - 2 2 6 195 195 195 195 195 195 6 6 6
44794 - 2 2 6 2 2 6 2 2 6 2 2 6
44795 - 74 74 74 62 62 62 22 22 22 6 6 6
44796 - 0 0 0 0 0 0 0 0 0 0 0 0
44797 - 0 0 0 0 0 0 0 0 0 0 0 0
44798 - 0 0 0 0 0 0 0 0 0 0 0 0
44799 - 0 0 0 0 0 0 0 0 0 0 0 0
44800 - 0 0 0 0 0 0 0 0 0 0 0 0
44801 - 0 0 0 0 0 0 0 0 0 0 0 0
44802 - 0 0 0 0 0 0 0 0 1 0 0 1
44803 - 0 0 1 0 0 0 0 0 1 0 0 0
44804 - 0 0 0 0 0 0 0 0 0 0 0 0
44805 - 0 0 0 0 0 0 0 0 0 0 0 0
44806 - 0 0 0 0 0 0 0 0 0 0 0 0
44807 - 0 0 0 0 0 0 0 0 0 0 0 0
44808 - 0 0 0 0 0 0 0 0 0 10 10 10
44809 - 38 38 38 90 90 90 14 14 14 58 58 58
44810 -210 210 210 26 26 26 54 38 6 154 114 10
44811 -226 170 11 236 186 11 225 175 15 184 144 12
44812 -215 174 15 175 146 61 37 26 9 2 2 6
44813 - 70 70 70 246 246 246 138 138 138 2 2 6
44814 - 2 2 6 2 2 6 2 2 6 2 2 6
44815 - 70 70 70 66 66 66 26 26 26 6 6 6
44816 - 0 0 0 0 0 0 0 0 0 0 0 0
44817 - 0 0 0 0 0 0 0 0 0 0 0 0
44818 - 0 0 0 0 0 0 0 0 0 0 0 0
44819 - 0 0 0 0 0 0 0 0 0 0 0 0
44820 - 0 0 0 0 0 0 0 0 0 0 0 0
44821 - 0 0 0 0 0 0 0 0 0 0 0 0
44822 - 0 0 0 0 0 0 0 0 0 0 0 0
44823 - 0 0 0 0 0 0 0 0 0 0 0 0
44824 - 0 0 0 0 0 0 0 0 0 0 0 0
44825 - 0 0 0 0 0 0 0 0 0 0 0 0
44826 - 0 0 0 0 0 0 0 0 0 0 0 0
44827 - 0 0 0 0 0 0 0 0 0 0 0 0
44828 - 0 0 0 0 0 0 0 0 0 10 10 10
44829 - 38 38 38 86 86 86 14 14 14 10 10 10
44830 -195 195 195 188 164 115 192 133 9 225 175 15
44831 -239 182 13 234 190 10 232 195 16 232 200 30
44832 -245 207 45 241 208 19 232 195 16 184 144 12
44833 -218 194 134 211 206 186 42 42 42 2 2 6
44834 - 2 2 6 2 2 6 2 2 6 2 2 6
44835 - 50 50 50 74 74 74 30 30 30 6 6 6
44836 - 0 0 0 0 0 0 0 0 0 0 0 0
44837 - 0 0 0 0 0 0 0 0 0 0 0 0
44838 - 0 0 0 0 0 0 0 0 0 0 0 0
44839 - 0 0 0 0 0 0 0 0 0 0 0 0
44840 - 0 0 0 0 0 0 0 0 0 0 0 0
44841 - 0 0 0 0 0 0 0 0 0 0 0 0
44842 - 0 0 0 0 0 0 0 0 0 0 0 0
44843 - 0 0 0 0 0 0 0 0 0 0 0 0
44844 - 0 0 0 0 0 0 0 0 0 0 0 0
44845 - 0 0 0 0 0 0 0 0 0 0 0 0
44846 - 0 0 0 0 0 0 0 0 0 0 0 0
44847 - 0 0 0 0 0 0 0 0 0 0 0 0
44848 - 0 0 0 0 0 0 0 0 0 10 10 10
44849 - 34 34 34 86 86 86 14 14 14 2 2 6
44850 -121 87 25 192 133 9 219 162 10 239 182 13
44851 -236 186 11 232 195 16 241 208 19 244 214 54
44852 -246 218 60 246 218 38 246 215 20 241 208 19
44853 -241 208 19 226 184 13 121 87 25 2 2 6
44854 - 2 2 6 2 2 6 2 2 6 2 2 6
44855 - 50 50 50 82 82 82 34 34 34 10 10 10
44856 - 0 0 0 0 0 0 0 0 0 0 0 0
44857 - 0 0 0 0 0 0 0 0 0 0 0 0
44858 - 0 0 0 0 0 0 0 0 0 0 0 0
44859 - 0 0 0 0 0 0 0 0 0 0 0 0
44860 - 0 0 0 0 0 0 0 0 0 0 0 0
44861 - 0 0 0 0 0 0 0 0 0 0 0 0
44862 - 0 0 0 0 0 0 0 0 0 0 0 0
44863 - 0 0 0 0 0 0 0 0 0 0 0 0
44864 - 0 0 0 0 0 0 0 0 0 0 0 0
44865 - 0 0 0 0 0 0 0 0 0 0 0 0
44866 - 0 0 0 0 0 0 0 0 0 0 0 0
44867 - 0 0 0 0 0 0 0 0 0 0 0 0
44868 - 0 0 0 0 0 0 0 0 0 10 10 10
44869 - 34 34 34 82 82 82 30 30 30 61 42 6
44870 -180 123 7 206 145 10 230 174 11 239 182 13
44871 -234 190 10 238 202 15 241 208 19 246 218 74
44872 -246 218 38 246 215 20 246 215 20 246 215 20
44873 -226 184 13 215 174 15 184 144 12 6 6 6
44874 - 2 2 6 2 2 6 2 2 6 2 2 6
44875 - 26 26 26 94 94 94 42 42 42 14 14 14
44876 - 0 0 0 0 0 0 0 0 0 0 0 0
44877 - 0 0 0 0 0 0 0 0 0 0 0 0
44878 - 0 0 0 0 0 0 0 0 0 0 0 0
44879 - 0 0 0 0 0 0 0 0 0 0 0 0
44880 - 0 0 0 0 0 0 0 0 0 0 0 0
44881 - 0 0 0 0 0 0 0 0 0 0 0 0
44882 - 0 0 0 0 0 0 0 0 0 0 0 0
44883 - 0 0 0 0 0 0 0 0 0 0 0 0
44884 - 0 0 0 0 0 0 0 0 0 0 0 0
44885 - 0 0 0 0 0 0 0 0 0 0 0 0
44886 - 0 0 0 0 0 0 0 0 0 0 0 0
44887 - 0 0 0 0 0 0 0 0 0 0 0 0
44888 - 0 0 0 0 0 0 0 0 0 10 10 10
44889 - 30 30 30 78 78 78 50 50 50 104 69 6
44890 -192 133 9 216 158 10 236 178 12 236 186 11
44891 -232 195 16 241 208 19 244 214 54 245 215 43
44892 -246 215 20 246 215 20 241 208 19 198 155 10
44893 -200 144 11 216 158 10 156 118 10 2 2 6
44894 - 2 2 6 2 2 6 2 2 6 2 2 6
44895 - 6 6 6 90 90 90 54 54 54 18 18 18
44896 - 6 6 6 0 0 0 0 0 0 0 0 0
44897 - 0 0 0 0 0 0 0 0 0 0 0 0
44898 - 0 0 0 0 0 0 0 0 0 0 0 0
44899 - 0 0 0 0 0 0 0 0 0 0 0 0
44900 - 0 0 0 0 0 0 0 0 0 0 0 0
44901 - 0 0 0 0 0 0 0 0 0 0 0 0
44902 - 0 0 0 0 0 0 0 0 0 0 0 0
44903 - 0 0 0 0 0 0 0 0 0 0 0 0
44904 - 0 0 0 0 0 0 0 0 0 0 0 0
44905 - 0 0 0 0 0 0 0 0 0 0 0 0
44906 - 0 0 0 0 0 0 0 0 0 0 0 0
44907 - 0 0 0 0 0 0 0 0 0 0 0 0
44908 - 0 0 0 0 0 0 0 0 0 10 10 10
44909 - 30 30 30 78 78 78 46 46 46 22 22 22
44910 -137 92 6 210 162 10 239 182 13 238 190 10
44911 -238 202 15 241 208 19 246 215 20 246 215 20
44912 -241 208 19 203 166 17 185 133 11 210 150 10
44913 -216 158 10 210 150 10 102 78 10 2 2 6
44914 - 6 6 6 54 54 54 14 14 14 2 2 6
44915 - 2 2 6 62 62 62 74 74 74 30 30 30
44916 - 10 10 10 0 0 0 0 0 0 0 0 0
44917 - 0 0 0 0 0 0 0 0 0 0 0 0
44918 - 0 0 0 0 0 0 0 0 0 0 0 0
44919 - 0 0 0 0 0 0 0 0 0 0 0 0
44920 - 0 0 0 0 0 0 0 0 0 0 0 0
44921 - 0 0 0 0 0 0 0 0 0 0 0 0
44922 - 0 0 0 0 0 0 0 0 0 0 0 0
44923 - 0 0 0 0 0 0 0 0 0 0 0 0
44924 - 0 0 0 0 0 0 0 0 0 0 0 0
44925 - 0 0 0 0 0 0 0 0 0 0 0 0
44926 - 0 0 0 0 0 0 0 0 0 0 0 0
44927 - 0 0 0 0 0 0 0 0 0 0 0 0
44928 - 0 0 0 0 0 0 0 0 0 10 10 10
44929 - 34 34 34 78 78 78 50 50 50 6 6 6
44930 - 94 70 30 139 102 15 190 146 13 226 184 13
44931 -232 200 30 232 195 16 215 174 15 190 146 13
44932 -168 122 10 192 133 9 210 150 10 213 154 11
44933 -202 150 34 182 157 106 101 98 89 2 2 6
44934 - 2 2 6 78 78 78 116 116 116 58 58 58
44935 - 2 2 6 22 22 22 90 90 90 46 46 46
44936 - 18 18 18 6 6 6 0 0 0 0 0 0
44937 - 0 0 0 0 0 0 0 0 0 0 0 0
44938 - 0 0 0 0 0 0 0 0 0 0 0 0
44939 - 0 0 0 0 0 0 0 0 0 0 0 0
44940 - 0 0 0 0 0 0 0 0 0 0 0 0
44941 - 0 0 0 0 0 0 0 0 0 0 0 0
44942 - 0 0 0 0 0 0 0 0 0 0 0 0
44943 - 0 0 0 0 0 0 0 0 0 0 0 0
44944 - 0 0 0 0 0 0 0 0 0 0 0 0
44945 - 0 0 0 0 0 0 0 0 0 0 0 0
44946 - 0 0 0 0 0 0 0 0 0 0 0 0
44947 - 0 0 0 0 0 0 0 0 0 0 0 0
44948 - 0 0 0 0 0 0 0 0 0 10 10 10
44949 - 38 38 38 86 86 86 50 50 50 6 6 6
44950 -128 128 128 174 154 114 156 107 11 168 122 10
44951 -198 155 10 184 144 12 197 138 11 200 144 11
44952 -206 145 10 206 145 10 197 138 11 188 164 115
44953 -195 195 195 198 198 198 174 174 174 14 14 14
44954 - 2 2 6 22 22 22 116 116 116 116 116 116
44955 - 22 22 22 2 2 6 74 74 74 70 70 70
44956 - 30 30 30 10 10 10 0 0 0 0 0 0
44957 - 0 0 0 0 0 0 0 0 0 0 0 0
44958 - 0 0 0 0 0 0 0 0 0 0 0 0
44959 - 0 0 0 0 0 0 0 0 0 0 0 0
44960 - 0 0 0 0 0 0 0 0 0 0 0 0
44961 - 0 0 0 0 0 0 0 0 0 0 0 0
44962 - 0 0 0 0 0 0 0 0 0 0 0 0
44963 - 0 0 0 0 0 0 0 0 0 0 0 0
44964 - 0 0 0 0 0 0 0 0 0 0 0 0
44965 - 0 0 0 0 0 0 0 0 0 0 0 0
44966 - 0 0 0 0 0 0 0 0 0 0 0 0
44967 - 0 0 0 0 0 0 0 0 0 0 0 0
44968 - 0 0 0 0 0 0 6 6 6 18 18 18
44969 - 50 50 50 101 101 101 26 26 26 10 10 10
44970 -138 138 138 190 190 190 174 154 114 156 107 11
44971 -197 138 11 200 144 11 197 138 11 192 133 9
44972 -180 123 7 190 142 34 190 178 144 187 187 187
44973 -202 202 202 221 221 221 214 214 214 66 66 66
44974 - 2 2 6 2 2 6 50 50 50 62 62 62
44975 - 6 6 6 2 2 6 10 10 10 90 90 90
44976 - 50 50 50 18 18 18 6 6 6 0 0 0
44977 - 0 0 0 0 0 0 0 0 0 0 0 0
44978 - 0 0 0 0 0 0 0 0 0 0 0 0
44979 - 0 0 0 0 0 0 0 0 0 0 0 0
44980 - 0 0 0 0 0 0 0 0 0 0 0 0
44981 - 0 0 0 0 0 0 0 0 0 0 0 0
44982 - 0 0 0 0 0 0 0 0 0 0 0 0
44983 - 0 0 0 0 0 0 0 0 0 0 0 0
44984 - 0 0 0 0 0 0 0 0 0 0 0 0
44985 - 0 0 0 0 0 0 0 0 0 0 0 0
44986 - 0 0 0 0 0 0 0 0 0 0 0 0
44987 - 0 0 0 0 0 0 0 0 0 0 0 0
44988 - 0 0 0 0 0 0 10 10 10 34 34 34
44989 - 74 74 74 74 74 74 2 2 6 6 6 6
44990 -144 144 144 198 198 198 190 190 190 178 166 146
44991 -154 121 60 156 107 11 156 107 11 168 124 44
44992 -174 154 114 187 187 187 190 190 190 210 210 210
44993 -246 246 246 253 253 253 253 253 253 182 182 182
44994 - 6 6 6 2 2 6 2 2 6 2 2 6
44995 - 2 2 6 2 2 6 2 2 6 62 62 62
44996 - 74 74 74 34 34 34 14 14 14 0 0 0
44997 - 0 0 0 0 0 0 0 0 0 0 0 0
44998 - 0 0 0 0 0 0 0 0 0 0 0 0
44999 - 0 0 0 0 0 0 0 0 0 0 0 0
45000 - 0 0 0 0 0 0 0 0 0 0 0 0
45001 - 0 0 0 0 0 0 0 0 0 0 0 0
45002 - 0 0 0 0 0 0 0 0 0 0 0 0
45003 - 0 0 0 0 0 0 0 0 0 0 0 0
45004 - 0 0 0 0 0 0 0 0 0 0 0 0
45005 - 0 0 0 0 0 0 0 0 0 0 0 0
45006 - 0 0 0 0 0 0 0 0 0 0 0 0
45007 - 0 0 0 0 0 0 0 0 0 0 0 0
45008 - 0 0 0 10 10 10 22 22 22 54 54 54
45009 - 94 94 94 18 18 18 2 2 6 46 46 46
45010 -234 234 234 221 221 221 190 190 190 190 190 190
45011 -190 190 190 187 187 187 187 187 187 190 190 190
45012 -190 190 190 195 195 195 214 214 214 242 242 242
45013 -253 253 253 253 253 253 253 253 253 253 253 253
45014 - 82 82 82 2 2 6 2 2 6 2 2 6
45015 - 2 2 6 2 2 6 2 2 6 14 14 14
45016 - 86 86 86 54 54 54 22 22 22 6 6 6
45017 - 0 0 0 0 0 0 0 0 0 0 0 0
45018 - 0 0 0 0 0 0 0 0 0 0 0 0
45019 - 0 0 0 0 0 0 0 0 0 0 0 0
45020 - 0 0 0 0 0 0 0 0 0 0 0 0
45021 - 0 0 0 0 0 0 0 0 0 0 0 0
45022 - 0 0 0 0 0 0 0 0 0 0 0 0
45023 - 0 0 0 0 0 0 0 0 0 0 0 0
45024 - 0 0 0 0 0 0 0 0 0 0 0 0
45025 - 0 0 0 0 0 0 0 0 0 0 0 0
45026 - 0 0 0 0 0 0 0 0 0 0 0 0
45027 - 0 0 0 0 0 0 0 0 0 0 0 0
45028 - 6 6 6 18 18 18 46 46 46 90 90 90
45029 - 46 46 46 18 18 18 6 6 6 182 182 182
45030 -253 253 253 246 246 246 206 206 206 190 190 190
45031 -190 190 190 190 190 190 190 190 190 190 190 190
45032 -206 206 206 231 231 231 250 250 250 253 253 253
45033 -253 253 253 253 253 253 253 253 253 253 253 253
45034 -202 202 202 14 14 14 2 2 6 2 2 6
45035 - 2 2 6 2 2 6 2 2 6 2 2 6
45036 - 42 42 42 86 86 86 42 42 42 18 18 18
45037 - 6 6 6 0 0 0 0 0 0 0 0 0
45038 - 0 0 0 0 0 0 0 0 0 0 0 0
45039 - 0 0 0 0 0 0 0 0 0 0 0 0
45040 - 0 0 0 0 0 0 0 0 0 0 0 0
45041 - 0 0 0 0 0 0 0 0 0 0 0 0
45042 - 0 0 0 0 0 0 0 0 0 0 0 0
45043 - 0 0 0 0 0 0 0 0 0 0 0 0
45044 - 0 0 0 0 0 0 0 0 0 0 0 0
45045 - 0 0 0 0 0 0 0 0 0 0 0 0
45046 - 0 0 0 0 0 0 0 0 0 0 0 0
45047 - 0 0 0 0 0 0 0 0 0 6 6 6
45048 - 14 14 14 38 38 38 74 74 74 66 66 66
45049 - 2 2 6 6 6 6 90 90 90 250 250 250
45050 -253 253 253 253 253 253 238 238 238 198 198 198
45051 -190 190 190 190 190 190 195 195 195 221 221 221
45052 -246 246 246 253 253 253 253 253 253 253 253 253
45053 -253 253 253 253 253 253 253 253 253 253 253 253
45054 -253 253 253 82 82 82 2 2 6 2 2 6
45055 - 2 2 6 2 2 6 2 2 6 2 2 6
45056 - 2 2 6 78 78 78 70 70 70 34 34 34
45057 - 14 14 14 6 6 6 0 0 0 0 0 0
45058 - 0 0 0 0 0 0 0 0 0 0 0 0
45059 - 0 0 0 0 0 0 0 0 0 0 0 0
45060 - 0 0 0 0 0 0 0 0 0 0 0 0
45061 - 0 0 0 0 0 0 0 0 0 0 0 0
45062 - 0 0 0 0 0 0 0 0 0 0 0 0
45063 - 0 0 0 0 0 0 0 0 0 0 0 0
45064 - 0 0 0 0 0 0 0 0 0 0 0 0
45065 - 0 0 0 0 0 0 0 0 0 0 0 0
45066 - 0 0 0 0 0 0 0 0 0 0 0 0
45067 - 0 0 0 0 0 0 0 0 0 14 14 14
45068 - 34 34 34 66 66 66 78 78 78 6 6 6
45069 - 2 2 6 18 18 18 218 218 218 253 253 253
45070 -253 253 253 253 253 253 253 253 253 246 246 246
45071 -226 226 226 231 231 231 246 246 246 253 253 253
45072 -253 253 253 253 253 253 253 253 253 253 253 253
45073 -253 253 253 253 253 253 253 253 253 253 253 253
45074 -253 253 253 178 178 178 2 2 6 2 2 6
45075 - 2 2 6 2 2 6 2 2 6 2 2 6
45076 - 2 2 6 18 18 18 90 90 90 62 62 62
45077 - 30 30 30 10 10 10 0 0 0 0 0 0
45078 - 0 0 0 0 0 0 0 0 0 0 0 0
45079 - 0 0 0 0 0 0 0 0 0 0 0 0
45080 - 0 0 0 0 0 0 0 0 0 0 0 0
45081 - 0 0 0 0 0 0 0 0 0 0 0 0
45082 - 0 0 0 0 0 0 0 0 0 0 0 0
45083 - 0 0 0 0 0 0 0 0 0 0 0 0
45084 - 0 0 0 0 0 0 0 0 0 0 0 0
45085 - 0 0 0 0 0 0 0 0 0 0 0 0
45086 - 0 0 0 0 0 0 0 0 0 0 0 0
45087 - 0 0 0 0 0 0 10 10 10 26 26 26
45088 - 58 58 58 90 90 90 18 18 18 2 2 6
45089 - 2 2 6 110 110 110 253 253 253 253 253 253
45090 -253 253 253 253 253 253 253 253 253 253 253 253
45091 -250 250 250 253 253 253 253 253 253 253 253 253
45092 -253 253 253 253 253 253 253 253 253 253 253 253
45093 -253 253 253 253 253 253 253 253 253 253 253 253
45094 -253 253 253 231 231 231 18 18 18 2 2 6
45095 - 2 2 6 2 2 6 2 2 6 2 2 6
45096 - 2 2 6 2 2 6 18 18 18 94 94 94
45097 - 54 54 54 26 26 26 10 10 10 0 0 0
45098 - 0 0 0 0 0 0 0 0 0 0 0 0
45099 - 0 0 0 0 0 0 0 0 0 0 0 0
45100 - 0 0 0 0 0 0 0 0 0 0 0 0
45101 - 0 0 0 0 0 0 0 0 0 0 0 0
45102 - 0 0 0 0 0 0 0 0 0 0 0 0
45103 - 0 0 0 0 0 0 0 0 0 0 0 0
45104 - 0 0 0 0 0 0 0 0 0 0 0 0
45105 - 0 0 0 0 0 0 0 0 0 0 0 0
45106 - 0 0 0 0 0 0 0 0 0 0 0 0
45107 - 0 0 0 6 6 6 22 22 22 50 50 50
45108 - 90 90 90 26 26 26 2 2 6 2 2 6
45109 - 14 14 14 195 195 195 250 250 250 253 253 253
45110 -253 253 253 253 253 253 253 253 253 253 253 253
45111 -253 253 253 253 253 253 253 253 253 253 253 253
45112 -253 253 253 253 253 253 253 253 253 253 253 253
45113 -253 253 253 253 253 253 253 253 253 253 253 253
45114 -250 250 250 242 242 242 54 54 54 2 2 6
45115 - 2 2 6 2 2 6 2 2 6 2 2 6
45116 - 2 2 6 2 2 6 2 2 6 38 38 38
45117 - 86 86 86 50 50 50 22 22 22 6 6 6
45118 - 0 0 0 0 0 0 0 0 0 0 0 0
45119 - 0 0 0 0 0 0 0 0 0 0 0 0
45120 - 0 0 0 0 0 0 0 0 0 0 0 0
45121 - 0 0 0 0 0 0 0 0 0 0 0 0
45122 - 0 0 0 0 0 0 0 0 0 0 0 0
45123 - 0 0 0 0 0 0 0 0 0 0 0 0
45124 - 0 0 0 0 0 0 0 0 0 0 0 0
45125 - 0 0 0 0 0 0 0 0 0 0 0 0
45126 - 0 0 0 0 0 0 0 0 0 0 0 0
45127 - 6 6 6 14 14 14 38 38 38 82 82 82
45128 - 34 34 34 2 2 6 2 2 6 2 2 6
45129 - 42 42 42 195 195 195 246 246 246 253 253 253
45130 -253 253 253 253 253 253 253 253 253 250 250 250
45131 -242 242 242 242 242 242 250 250 250 253 253 253
45132 -253 253 253 253 253 253 253 253 253 253 253 253
45133 -253 253 253 250 250 250 246 246 246 238 238 238
45134 -226 226 226 231 231 231 101 101 101 6 6 6
45135 - 2 2 6 2 2 6 2 2 6 2 2 6
45136 - 2 2 6 2 2 6 2 2 6 2 2 6
45137 - 38 38 38 82 82 82 42 42 42 14 14 14
45138 - 6 6 6 0 0 0 0 0 0 0 0 0
45139 - 0 0 0 0 0 0 0 0 0 0 0 0
45140 - 0 0 0 0 0 0 0 0 0 0 0 0
45141 - 0 0 0 0 0 0 0 0 0 0 0 0
45142 - 0 0 0 0 0 0 0 0 0 0 0 0
45143 - 0 0 0 0 0 0 0 0 0 0 0 0
45144 - 0 0 0 0 0 0 0 0 0 0 0 0
45145 - 0 0 0 0 0 0 0 0 0 0 0 0
45146 - 0 0 0 0 0 0 0 0 0 0 0 0
45147 - 10 10 10 26 26 26 62 62 62 66 66 66
45148 - 2 2 6 2 2 6 2 2 6 6 6 6
45149 - 70 70 70 170 170 170 206 206 206 234 234 234
45150 -246 246 246 250 250 250 250 250 250 238 238 238
45151 -226 226 226 231 231 231 238 238 238 250 250 250
45152 -250 250 250 250 250 250 246 246 246 231 231 231
45153 -214 214 214 206 206 206 202 202 202 202 202 202
45154 -198 198 198 202 202 202 182 182 182 18 18 18
45155 - 2 2 6 2 2 6 2 2 6 2 2 6
45156 - 2 2 6 2 2 6 2 2 6 2 2 6
45157 - 2 2 6 62 62 62 66 66 66 30 30 30
45158 - 10 10 10 0 0 0 0 0 0 0 0 0
45159 - 0 0 0 0 0 0 0 0 0 0 0 0
45160 - 0 0 0 0 0 0 0 0 0 0 0 0
45161 - 0 0 0 0 0 0 0 0 0 0 0 0
45162 - 0 0 0 0 0 0 0 0 0 0 0 0
45163 - 0 0 0 0 0 0 0 0 0 0 0 0
45164 - 0 0 0 0 0 0 0 0 0 0 0 0
45165 - 0 0 0 0 0 0 0 0 0 0 0 0
45166 - 0 0 0 0 0 0 0 0 0 0 0 0
45167 - 14 14 14 42 42 42 82 82 82 18 18 18
45168 - 2 2 6 2 2 6 2 2 6 10 10 10
45169 - 94 94 94 182 182 182 218 218 218 242 242 242
45170 -250 250 250 253 253 253 253 253 253 250 250 250
45171 -234 234 234 253 253 253 253 253 253 253 253 253
45172 -253 253 253 253 253 253 253 253 253 246 246 246
45173 -238 238 238 226 226 226 210 210 210 202 202 202
45174 -195 195 195 195 195 195 210 210 210 158 158 158
45175 - 6 6 6 14 14 14 50 50 50 14 14 14
45176 - 2 2 6 2 2 6 2 2 6 2 2 6
45177 - 2 2 6 6 6 6 86 86 86 46 46 46
45178 - 18 18 18 6 6 6 0 0 0 0 0 0
45179 - 0 0 0 0 0 0 0 0 0 0 0 0
45180 - 0 0 0 0 0 0 0 0 0 0 0 0
45181 - 0 0 0 0 0 0 0 0 0 0 0 0
45182 - 0 0 0 0 0 0 0 0 0 0 0 0
45183 - 0 0 0 0 0 0 0 0 0 0 0 0
45184 - 0 0 0 0 0 0 0 0 0 0 0 0
45185 - 0 0 0 0 0 0 0 0 0 0 0 0
45186 - 0 0 0 0 0 0 0 0 0 6 6 6
45187 - 22 22 22 54 54 54 70 70 70 2 2 6
45188 - 2 2 6 10 10 10 2 2 6 22 22 22
45189 -166 166 166 231 231 231 250 250 250 253 253 253
45190 -253 253 253 253 253 253 253 253 253 250 250 250
45191 -242 242 242 253 253 253 253 253 253 253 253 253
45192 -253 253 253 253 253 253 253 253 253 253 253 253
45193 -253 253 253 253 253 253 253 253 253 246 246 246
45194 -231 231 231 206 206 206 198 198 198 226 226 226
45195 - 94 94 94 2 2 6 6 6 6 38 38 38
45196 - 30 30 30 2 2 6 2 2 6 2 2 6
45197 - 2 2 6 2 2 6 62 62 62 66 66 66
45198 - 26 26 26 10 10 10 0 0 0 0 0 0
45199 - 0 0 0 0 0 0 0 0 0 0 0 0
45200 - 0 0 0 0 0 0 0 0 0 0 0 0
45201 - 0 0 0 0 0 0 0 0 0 0 0 0
45202 - 0 0 0 0 0 0 0 0 0 0 0 0
45203 - 0 0 0 0 0 0 0 0 0 0 0 0
45204 - 0 0 0 0 0 0 0 0 0 0 0 0
45205 - 0 0 0 0 0 0 0 0 0 0 0 0
45206 - 0 0 0 0 0 0 0 0 0 10 10 10
45207 - 30 30 30 74 74 74 50 50 50 2 2 6
45208 - 26 26 26 26 26 26 2 2 6 106 106 106
45209 -238 238 238 253 253 253 253 253 253 253 253 253
45210 -253 253 253 253 253 253 253 253 253 253 253 253
45211 -253 253 253 253 253 253 253 253 253 253 253 253
45212 -253 253 253 253 253 253 253 253 253 253 253 253
45213 -253 253 253 253 253 253 253 253 253 253 253 253
45214 -253 253 253 246 246 246 218 218 218 202 202 202
45215 -210 210 210 14 14 14 2 2 6 2 2 6
45216 - 30 30 30 22 22 22 2 2 6 2 2 6
45217 - 2 2 6 2 2 6 18 18 18 86 86 86
45218 - 42 42 42 14 14 14 0 0 0 0 0 0
45219 - 0 0 0 0 0 0 0 0 0 0 0 0
45220 - 0 0 0 0 0 0 0 0 0 0 0 0
45221 - 0 0 0 0 0 0 0 0 0 0 0 0
45222 - 0 0 0 0 0 0 0 0 0 0 0 0
45223 - 0 0 0 0 0 0 0 0 0 0 0 0
45224 - 0 0 0 0 0 0 0 0 0 0 0 0
45225 - 0 0 0 0 0 0 0 0 0 0 0 0
45226 - 0 0 0 0 0 0 0 0 0 14 14 14
45227 - 42 42 42 90 90 90 22 22 22 2 2 6
45228 - 42 42 42 2 2 6 18 18 18 218 218 218
45229 -253 253 253 253 253 253 253 253 253 253 253 253
45230 -253 253 253 253 253 253 253 253 253 253 253 253
45231 -253 253 253 253 253 253 253 253 253 253 253 253
45232 -253 253 253 253 253 253 253 253 253 253 253 253
45233 -253 253 253 253 253 253 253 253 253 253 253 253
45234 -253 253 253 253 253 253 250 250 250 221 221 221
45235 -218 218 218 101 101 101 2 2 6 14 14 14
45236 - 18 18 18 38 38 38 10 10 10 2 2 6
45237 - 2 2 6 2 2 6 2 2 6 78 78 78
45238 - 58 58 58 22 22 22 6 6 6 0 0 0
45239 - 0 0 0 0 0 0 0 0 0 0 0 0
45240 - 0 0 0 0 0 0 0 0 0 0 0 0
45241 - 0 0 0 0 0 0 0 0 0 0 0 0
45242 - 0 0 0 0 0 0 0 0 0 0 0 0
45243 - 0 0 0 0 0 0 0 0 0 0 0 0
45244 - 0 0 0 0 0 0 0 0 0 0 0 0
45245 - 0 0 0 0 0 0 0 0 0 0 0 0
45246 - 0 0 0 0 0 0 6 6 6 18 18 18
45247 - 54 54 54 82 82 82 2 2 6 26 26 26
45248 - 22 22 22 2 2 6 123 123 123 253 253 253
45249 -253 253 253 253 253 253 253 253 253 253 253 253
45250 -253 253 253 253 253 253 253 253 253 253 253 253
45251 -253 253 253 253 253 253 253 253 253 253 253 253
45252 -253 253 253 253 253 253 253 253 253 253 253 253
45253 -253 253 253 253 253 253 253 253 253 253 253 253
45254 -253 253 253 253 253 253 253 253 253 250 250 250
45255 -238 238 238 198 198 198 6 6 6 38 38 38
45256 - 58 58 58 26 26 26 38 38 38 2 2 6
45257 - 2 2 6 2 2 6 2 2 6 46 46 46
45258 - 78 78 78 30 30 30 10 10 10 0 0 0
45259 - 0 0 0 0 0 0 0 0 0 0 0 0
45260 - 0 0 0 0 0 0 0 0 0 0 0 0
45261 - 0 0 0 0 0 0 0 0 0 0 0 0
45262 - 0 0 0 0 0 0 0 0 0 0 0 0
45263 - 0 0 0 0 0 0 0 0 0 0 0 0
45264 - 0 0 0 0 0 0 0 0 0 0 0 0
45265 - 0 0 0 0 0 0 0 0 0 0 0 0
45266 - 0 0 0 0 0 0 10 10 10 30 30 30
45267 - 74 74 74 58 58 58 2 2 6 42 42 42
45268 - 2 2 6 22 22 22 231 231 231 253 253 253
45269 -253 253 253 253 253 253 253 253 253 253 253 253
45270 -253 253 253 253 253 253 253 253 253 250 250 250
45271 -253 253 253 253 253 253 253 253 253 253 253 253
45272 -253 253 253 253 253 253 253 253 253 253 253 253
45273 -253 253 253 253 253 253 253 253 253 253 253 253
45274 -253 253 253 253 253 253 253 253 253 253 253 253
45275 -253 253 253 246 246 246 46 46 46 38 38 38
45276 - 42 42 42 14 14 14 38 38 38 14 14 14
45277 - 2 2 6 2 2 6 2 2 6 6 6 6
45278 - 86 86 86 46 46 46 14 14 14 0 0 0
45279 - 0 0 0 0 0 0 0 0 0 0 0 0
45280 - 0 0 0 0 0 0 0 0 0 0 0 0
45281 - 0 0 0 0 0 0 0 0 0 0 0 0
45282 - 0 0 0 0 0 0 0 0 0 0 0 0
45283 - 0 0 0 0 0 0 0 0 0 0 0 0
45284 - 0 0 0 0 0 0 0 0 0 0 0 0
45285 - 0 0 0 0 0 0 0 0 0 0 0 0
45286 - 0 0 0 6 6 6 14 14 14 42 42 42
45287 - 90 90 90 18 18 18 18 18 18 26 26 26
45288 - 2 2 6 116 116 116 253 253 253 253 253 253
45289 -253 253 253 253 253 253 253 253 253 253 253 253
45290 -253 253 253 253 253 253 250 250 250 238 238 238
45291 -253 253 253 253 253 253 253 253 253 253 253 253
45292 -253 253 253 253 253 253 253 253 253 253 253 253
45293 -253 253 253 253 253 253 253 253 253 253 253 253
45294 -253 253 253 253 253 253 253 253 253 253 253 253
45295 -253 253 253 253 253 253 94 94 94 6 6 6
45296 - 2 2 6 2 2 6 10 10 10 34 34 34
45297 - 2 2 6 2 2 6 2 2 6 2 2 6
45298 - 74 74 74 58 58 58 22 22 22 6 6 6
45299 - 0 0 0 0 0 0 0 0 0 0 0 0
45300 - 0 0 0 0 0 0 0 0 0 0 0 0
45301 - 0 0 0 0 0 0 0 0 0 0 0 0
45302 - 0 0 0 0 0 0 0 0 0 0 0 0
45303 - 0 0 0 0 0 0 0 0 0 0 0 0
45304 - 0 0 0 0 0 0 0 0 0 0 0 0
45305 - 0 0 0 0 0 0 0 0 0 0 0 0
45306 - 0 0 0 10 10 10 26 26 26 66 66 66
45307 - 82 82 82 2 2 6 38 38 38 6 6 6
45308 - 14 14 14 210 210 210 253 253 253 253 253 253
45309 -253 253 253 253 253 253 253 253 253 253 253 253
45310 -253 253 253 253 253 253 246 246 246 242 242 242
45311 -253 253 253 253 253 253 253 253 253 253 253 253
45312 -253 253 253 253 253 253 253 253 253 253 253 253
45313 -253 253 253 253 253 253 253 253 253 253 253 253
45314 -253 253 253 253 253 253 253 253 253 253 253 253
45315 -253 253 253 253 253 253 144 144 144 2 2 6
45316 - 2 2 6 2 2 6 2 2 6 46 46 46
45317 - 2 2 6 2 2 6 2 2 6 2 2 6
45318 - 42 42 42 74 74 74 30 30 30 10 10 10
45319 - 0 0 0 0 0 0 0 0 0 0 0 0
45320 - 0 0 0 0 0 0 0 0 0 0 0 0
45321 - 0 0 0 0 0 0 0 0 0 0 0 0
45322 - 0 0 0 0 0 0 0 0 0 0 0 0
45323 - 0 0 0 0 0 0 0 0 0 0 0 0
45324 - 0 0 0 0 0 0 0 0 0 0 0 0
45325 - 0 0 0 0 0 0 0 0 0 0 0 0
45326 - 6 6 6 14 14 14 42 42 42 90 90 90
45327 - 26 26 26 6 6 6 42 42 42 2 2 6
45328 - 74 74 74 250 250 250 253 253 253 253 253 253
45329 -253 253 253 253 253 253 253 253 253 253 253 253
45330 -253 253 253 253 253 253 242 242 242 242 242 242
45331 -253 253 253 253 253 253 253 253 253 253 253 253
45332 -253 253 253 253 253 253 253 253 253 253 253 253
45333 -253 253 253 253 253 253 253 253 253 253 253 253
45334 -253 253 253 253 253 253 253 253 253 253 253 253
45335 -253 253 253 253 253 253 182 182 182 2 2 6
45336 - 2 2 6 2 2 6 2 2 6 46 46 46
45337 - 2 2 6 2 2 6 2 2 6 2 2 6
45338 - 10 10 10 86 86 86 38 38 38 10 10 10
45339 - 0 0 0 0 0 0 0 0 0 0 0 0
45340 - 0 0 0 0 0 0 0 0 0 0 0 0
45341 - 0 0 0 0 0 0 0 0 0 0 0 0
45342 - 0 0 0 0 0 0 0 0 0 0 0 0
45343 - 0 0 0 0 0 0 0 0 0 0 0 0
45344 - 0 0 0 0 0 0 0 0 0 0 0 0
45345 - 0 0 0 0 0 0 0 0 0 0 0 0
45346 - 10 10 10 26 26 26 66 66 66 82 82 82
45347 - 2 2 6 22 22 22 18 18 18 2 2 6
45348 -149 149 149 253 253 253 253 253 253 253 253 253
45349 -253 253 253 253 253 253 253 253 253 253 253 253
45350 -253 253 253 253 253 253 234 234 234 242 242 242
45351 -253 253 253 253 253 253 253 253 253 253 253 253
45352 -253 253 253 253 253 253 253 253 253 253 253 253
45353 -253 253 253 253 253 253 253 253 253 253 253 253
45354 -253 253 253 253 253 253 253 253 253 253 253 253
45355 -253 253 253 253 253 253 206 206 206 2 2 6
45356 - 2 2 6 2 2 6 2 2 6 38 38 38
45357 - 2 2 6 2 2 6 2 2 6 2 2 6
45358 - 6 6 6 86 86 86 46 46 46 14 14 14
45359 - 0 0 0 0 0 0 0 0 0 0 0 0
45360 - 0 0 0 0 0 0 0 0 0 0 0 0
45361 - 0 0 0 0 0 0 0 0 0 0 0 0
45362 - 0 0 0 0 0 0 0 0 0 0 0 0
45363 - 0 0 0 0 0 0 0 0 0 0 0 0
45364 - 0 0 0 0 0 0 0 0 0 0 0 0
45365 - 0 0 0 0 0 0 0 0 0 6 6 6
45366 - 18 18 18 46 46 46 86 86 86 18 18 18
45367 - 2 2 6 34 34 34 10 10 10 6 6 6
45368 -210 210 210 253 253 253 253 253 253 253 253 253
45369 -253 253 253 253 253 253 253 253 253 253 253 253
45370 -253 253 253 253 253 253 234 234 234 242 242 242
45371 -253 253 253 253 253 253 253 253 253 253 253 253
45372 -253 253 253 253 253 253 253 253 253 253 253 253
45373 -253 253 253 253 253 253 253 253 253 253 253 253
45374 -253 253 253 253 253 253 253 253 253 253 253 253
45375 -253 253 253 253 253 253 221 221 221 6 6 6
45376 - 2 2 6 2 2 6 6 6 6 30 30 30
45377 - 2 2 6 2 2 6 2 2 6 2 2 6
45378 - 2 2 6 82 82 82 54 54 54 18 18 18
45379 - 6 6 6 0 0 0 0 0 0 0 0 0
45380 - 0 0 0 0 0 0 0 0 0 0 0 0
45381 - 0 0 0 0 0 0 0 0 0 0 0 0
45382 - 0 0 0 0 0 0 0 0 0 0 0 0
45383 - 0 0 0 0 0 0 0 0 0 0 0 0
45384 - 0 0 0 0 0 0 0 0 0 0 0 0
45385 - 0 0 0 0 0 0 0 0 0 10 10 10
45386 - 26 26 26 66 66 66 62 62 62 2 2 6
45387 - 2 2 6 38 38 38 10 10 10 26 26 26
45388 -238 238 238 253 253 253 253 253 253 253 253 253
45389 -253 253 253 253 253 253 253 253 253 253 253 253
45390 -253 253 253 253 253 253 231 231 231 238 238 238
45391 -253 253 253 253 253 253 253 253 253 253 253 253
45392 -253 253 253 253 253 253 253 253 253 253 253 253
45393 -253 253 253 253 253 253 253 253 253 253 253 253
45394 -253 253 253 253 253 253 253 253 253 253 253 253
45395 -253 253 253 253 253 253 231 231 231 6 6 6
45396 - 2 2 6 2 2 6 10 10 10 30 30 30
45397 - 2 2 6 2 2 6 2 2 6 2 2 6
45398 - 2 2 6 66 66 66 58 58 58 22 22 22
45399 - 6 6 6 0 0 0 0 0 0 0 0 0
45400 - 0 0 0 0 0 0 0 0 0 0 0 0
45401 - 0 0 0 0 0 0 0 0 0 0 0 0
45402 - 0 0 0 0 0 0 0 0 0 0 0 0
45403 - 0 0 0 0 0 0 0 0 0 0 0 0
45404 - 0 0 0 0 0 0 0 0 0 0 0 0
45405 - 0 0 0 0 0 0 0 0 0 10 10 10
45406 - 38 38 38 78 78 78 6 6 6 2 2 6
45407 - 2 2 6 46 46 46 14 14 14 42 42 42
45408 -246 246 246 253 253 253 253 253 253 253 253 253
45409 -253 253 253 253 253 253 253 253 253 253 253 253
45410 -253 253 253 253 253 253 231 231 231 242 242 242
45411 -253 253 253 253 253 253 253 253 253 253 253 253
45412 -253 253 253 253 253 253 253 253 253 253 253 253
45413 -253 253 253 253 253 253 253 253 253 253 253 253
45414 -253 253 253 253 253 253 253 253 253 253 253 253
45415 -253 253 253 253 253 253 234 234 234 10 10 10
45416 - 2 2 6 2 2 6 22 22 22 14 14 14
45417 - 2 2 6 2 2 6 2 2 6 2 2 6
45418 - 2 2 6 66 66 66 62 62 62 22 22 22
45419 - 6 6 6 0 0 0 0 0 0 0 0 0
45420 - 0 0 0 0 0 0 0 0 0 0 0 0
45421 - 0 0 0 0 0 0 0 0 0 0 0 0
45422 - 0 0 0 0 0 0 0 0 0 0 0 0
45423 - 0 0 0 0 0 0 0 0 0 0 0 0
45424 - 0 0 0 0 0 0 0 0 0 0 0 0
45425 - 0 0 0 0 0 0 6 6 6 18 18 18
45426 - 50 50 50 74 74 74 2 2 6 2 2 6
45427 - 14 14 14 70 70 70 34 34 34 62 62 62
45428 -250 250 250 253 253 253 253 253 253 253 253 253
45429 -253 253 253 253 253 253 253 253 253 253 253 253
45430 -253 253 253 253 253 253 231 231 231 246 246 246
45431 -253 253 253 253 253 253 253 253 253 253 253 253
45432 -253 253 253 253 253 253 253 253 253 253 253 253
45433 -253 253 253 253 253 253 253 253 253 253 253 253
45434 -253 253 253 253 253 253 253 253 253 253 253 253
45435 -253 253 253 253 253 253 234 234 234 14 14 14
45436 - 2 2 6 2 2 6 30 30 30 2 2 6
45437 - 2 2 6 2 2 6 2 2 6 2 2 6
45438 - 2 2 6 66 66 66 62 62 62 22 22 22
45439 - 6 6 6 0 0 0 0 0 0 0 0 0
45440 - 0 0 0 0 0 0 0 0 0 0 0 0
45441 - 0 0 0 0 0 0 0 0 0 0 0 0
45442 - 0 0 0 0 0 0 0 0 0 0 0 0
45443 - 0 0 0 0 0 0 0 0 0 0 0 0
45444 - 0 0 0 0 0 0 0 0 0 0 0 0
45445 - 0 0 0 0 0 0 6 6 6 18 18 18
45446 - 54 54 54 62 62 62 2 2 6 2 2 6
45447 - 2 2 6 30 30 30 46 46 46 70 70 70
45448 -250 250 250 253 253 253 253 253 253 253 253 253
45449 -253 253 253 253 253 253 253 253 253 253 253 253
45450 -253 253 253 253 253 253 231 231 231 246 246 246
45451 -253 253 253 253 253 253 253 253 253 253 253 253
45452 -253 253 253 253 253 253 253 253 253 253 253 253
45453 -253 253 253 253 253 253 253 253 253 253 253 253
45454 -253 253 253 253 253 253 253 253 253 253 253 253
45455 -253 253 253 253 253 253 226 226 226 10 10 10
45456 - 2 2 6 6 6 6 30 30 30 2 2 6
45457 - 2 2 6 2 2 6 2 2 6 2 2 6
45458 - 2 2 6 66 66 66 58 58 58 22 22 22
45459 - 6 6 6 0 0 0 0 0 0 0 0 0
45460 - 0 0 0 0 0 0 0 0 0 0 0 0
45461 - 0 0 0 0 0 0 0 0 0 0 0 0
45462 - 0 0 0 0 0 0 0 0 0 0 0 0
45463 - 0 0 0 0 0 0 0 0 0 0 0 0
45464 - 0 0 0 0 0 0 0 0 0 0 0 0
45465 - 0 0 0 0 0 0 6 6 6 22 22 22
45466 - 58 58 58 62 62 62 2 2 6 2 2 6
45467 - 2 2 6 2 2 6 30 30 30 78 78 78
45468 -250 250 250 253 253 253 253 253 253 253 253 253
45469 -253 253 253 253 253 253 253 253 253 253 253 253
45470 -253 253 253 253 253 253 231 231 231 246 246 246
45471 -253 253 253 253 253 253 253 253 253 253 253 253
45472 -253 253 253 253 253 253 253 253 253 253 253 253
45473 -253 253 253 253 253 253 253 253 253 253 253 253
45474 -253 253 253 253 253 253 253 253 253 253 253 253
45475 -253 253 253 253 253 253 206 206 206 2 2 6
45476 - 22 22 22 34 34 34 18 14 6 22 22 22
45477 - 26 26 26 18 18 18 6 6 6 2 2 6
45478 - 2 2 6 82 82 82 54 54 54 18 18 18
45479 - 6 6 6 0 0 0 0 0 0 0 0 0
45480 - 0 0 0 0 0 0 0 0 0 0 0 0
45481 - 0 0 0 0 0 0 0 0 0 0 0 0
45482 - 0 0 0 0 0 0 0 0 0 0 0 0
45483 - 0 0 0 0 0 0 0 0 0 0 0 0
45484 - 0 0 0 0 0 0 0 0 0 0 0 0
45485 - 0 0 0 0 0 0 6 6 6 26 26 26
45486 - 62 62 62 106 106 106 74 54 14 185 133 11
45487 -210 162 10 121 92 8 6 6 6 62 62 62
45488 -238 238 238 253 253 253 253 253 253 253 253 253
45489 -253 253 253 253 253 253 253 253 253 253 253 253
45490 -253 253 253 253 253 253 231 231 231 246 246 246
45491 -253 253 253 253 253 253 253 253 253 253 253 253
45492 -253 253 253 253 253 253 253 253 253 253 253 253
45493 -253 253 253 253 253 253 253 253 253 253 253 253
45494 -253 253 253 253 253 253 253 253 253 253 253 253
45495 -253 253 253 253 253 253 158 158 158 18 18 18
45496 - 14 14 14 2 2 6 2 2 6 2 2 6
45497 - 6 6 6 18 18 18 66 66 66 38 38 38
45498 - 6 6 6 94 94 94 50 50 50 18 18 18
45499 - 6 6 6 0 0 0 0 0 0 0 0 0
45500 - 0 0 0 0 0 0 0 0 0 0 0 0
45501 - 0 0 0 0 0 0 0 0 0 0 0 0
45502 - 0 0 0 0 0 0 0 0 0 0 0 0
45503 - 0 0 0 0 0 0 0 0 0 0 0 0
45504 - 0 0 0 0 0 0 0 0 0 6 6 6
45505 - 10 10 10 10 10 10 18 18 18 38 38 38
45506 - 78 78 78 142 134 106 216 158 10 242 186 14
45507 -246 190 14 246 190 14 156 118 10 10 10 10
45508 - 90 90 90 238 238 238 253 253 253 253 253 253
45509 -253 253 253 253 253 253 253 253 253 253 253 253
45510 -253 253 253 253 253 253 231 231 231 250 250 250
45511 -253 253 253 253 253 253 253 253 253 253 253 253
45512 -253 253 253 253 253 253 253 253 253 253 253 253
45513 -253 253 253 253 253 253 253 253 253 253 253 253
45514 -253 253 253 253 253 253 253 253 253 246 230 190
45515 -238 204 91 238 204 91 181 142 44 37 26 9
45516 - 2 2 6 2 2 6 2 2 6 2 2 6
45517 - 2 2 6 2 2 6 38 38 38 46 46 46
45518 - 26 26 26 106 106 106 54 54 54 18 18 18
45519 - 6 6 6 0 0 0 0 0 0 0 0 0
45520 - 0 0 0 0 0 0 0 0 0 0 0 0
45521 - 0 0 0 0 0 0 0 0 0 0 0 0
45522 - 0 0 0 0 0 0 0 0 0 0 0 0
45523 - 0 0 0 0 0 0 0 0 0 0 0 0
45524 - 0 0 0 6 6 6 14 14 14 22 22 22
45525 - 30 30 30 38 38 38 50 50 50 70 70 70
45526 -106 106 106 190 142 34 226 170 11 242 186 14
45527 -246 190 14 246 190 14 246 190 14 154 114 10
45528 - 6 6 6 74 74 74 226 226 226 253 253 253
45529 -253 253 253 253 253 253 253 253 253 253 253 253
45530 -253 253 253 253 253 253 231 231 231 250 250 250
45531 -253 253 253 253 253 253 253 253 253 253 253 253
45532 -253 253 253 253 253 253 253 253 253 253 253 253
45533 -253 253 253 253 253 253 253 253 253 253 253 253
45534 -253 253 253 253 253 253 253 253 253 228 184 62
45535 -241 196 14 241 208 19 232 195 16 38 30 10
45536 - 2 2 6 2 2 6 2 2 6 2 2 6
45537 - 2 2 6 6 6 6 30 30 30 26 26 26
45538 -203 166 17 154 142 90 66 66 66 26 26 26
45539 - 6 6 6 0 0 0 0 0 0 0 0 0
45540 - 0 0 0 0 0 0 0 0 0 0 0 0
45541 - 0 0 0 0 0 0 0 0 0 0 0 0
45542 - 0 0 0 0 0 0 0 0 0 0 0 0
45543 - 0 0 0 0 0 0 0 0 0 0 0 0
45544 - 6 6 6 18 18 18 38 38 38 58 58 58
45545 - 78 78 78 86 86 86 101 101 101 123 123 123
45546 -175 146 61 210 150 10 234 174 13 246 186 14
45547 -246 190 14 246 190 14 246 190 14 238 190 10
45548 -102 78 10 2 2 6 46 46 46 198 198 198
45549 -253 253 253 253 253 253 253 253 253 253 253 253
45550 -253 253 253 253 253 253 234 234 234 242 242 242
45551 -253 253 253 253 253 253 253 253 253 253 253 253
45552 -253 253 253 253 253 253 253 253 253 253 253 253
45553 -253 253 253 253 253 253 253 253 253 253 253 253
45554 -253 253 253 253 253 253 253 253 253 224 178 62
45555 -242 186 14 241 196 14 210 166 10 22 18 6
45556 - 2 2 6 2 2 6 2 2 6 2 2 6
45557 - 2 2 6 2 2 6 6 6 6 121 92 8
45558 -238 202 15 232 195 16 82 82 82 34 34 34
45559 - 10 10 10 0 0 0 0 0 0 0 0 0
45560 - 0 0 0 0 0 0 0 0 0 0 0 0
45561 - 0 0 0 0 0 0 0 0 0 0 0 0
45562 - 0 0 0 0 0 0 0 0 0 0 0 0
45563 - 0 0 0 0 0 0 0 0 0 0 0 0
45564 - 14 14 14 38 38 38 70 70 70 154 122 46
45565 -190 142 34 200 144 11 197 138 11 197 138 11
45566 -213 154 11 226 170 11 242 186 14 246 190 14
45567 -246 190 14 246 190 14 246 190 14 246 190 14
45568 -225 175 15 46 32 6 2 2 6 22 22 22
45569 -158 158 158 250 250 250 253 253 253 253 253 253
45570 -253 253 253 253 253 253 253 253 253 253 253 253
45571 -253 253 253 253 253 253 253 253 253 253 253 253
45572 -253 253 253 253 253 253 253 253 253 253 253 253
45573 -253 253 253 253 253 253 253 253 253 253 253 253
45574 -253 253 253 250 250 250 242 242 242 224 178 62
45575 -239 182 13 236 186 11 213 154 11 46 32 6
45576 - 2 2 6 2 2 6 2 2 6 2 2 6
45577 - 2 2 6 2 2 6 61 42 6 225 175 15
45578 -238 190 10 236 186 11 112 100 78 42 42 42
45579 - 14 14 14 0 0 0 0 0 0 0 0 0
45580 - 0 0 0 0 0 0 0 0 0 0 0 0
45581 - 0 0 0 0 0 0 0 0 0 0 0 0
45582 - 0 0 0 0 0 0 0 0 0 0 0 0
45583 - 0 0 0 0 0 0 0 0 0 6 6 6
45584 - 22 22 22 54 54 54 154 122 46 213 154 11
45585 -226 170 11 230 174 11 226 170 11 226 170 11
45586 -236 178 12 242 186 14 246 190 14 246 190 14
45587 -246 190 14 246 190 14 246 190 14 246 190 14
45588 -241 196 14 184 144 12 10 10 10 2 2 6
45589 - 6 6 6 116 116 116 242 242 242 253 253 253
45590 -253 253 253 253 253 253 253 253 253 253 253 253
45591 -253 253 253 253 253 253 253 253 253 253 253 253
45592 -253 253 253 253 253 253 253 253 253 253 253 253
45593 -253 253 253 253 253 253 253 253 253 253 253 253
45594 -253 253 253 231 231 231 198 198 198 214 170 54
45595 -236 178 12 236 178 12 210 150 10 137 92 6
45596 - 18 14 6 2 2 6 2 2 6 2 2 6
45597 - 6 6 6 70 47 6 200 144 11 236 178 12
45598 -239 182 13 239 182 13 124 112 88 58 58 58
45599 - 22 22 22 6 6 6 0 0 0 0 0 0
45600 - 0 0 0 0 0 0 0 0 0 0 0 0
45601 - 0 0 0 0 0 0 0 0 0 0 0 0
45602 - 0 0 0 0 0 0 0 0 0 0 0 0
45603 - 0 0 0 0 0 0 0 0 0 10 10 10
45604 - 30 30 30 70 70 70 180 133 36 226 170 11
45605 -239 182 13 242 186 14 242 186 14 246 186 14
45606 -246 190 14 246 190 14 246 190 14 246 190 14
45607 -246 190 14 246 190 14 246 190 14 246 190 14
45608 -246 190 14 232 195 16 98 70 6 2 2 6
45609 - 2 2 6 2 2 6 66 66 66 221 221 221
45610 -253 253 253 253 253 253 253 253 253 253 253 253
45611 -253 253 253 253 253 253 253 253 253 253 253 253
45612 -253 253 253 253 253 253 253 253 253 253 253 253
45613 -253 253 253 253 253 253 253 253 253 253 253 253
45614 -253 253 253 206 206 206 198 198 198 214 166 58
45615 -230 174 11 230 174 11 216 158 10 192 133 9
45616 -163 110 8 116 81 8 102 78 10 116 81 8
45617 -167 114 7 197 138 11 226 170 11 239 182 13
45618 -242 186 14 242 186 14 162 146 94 78 78 78
45619 - 34 34 34 14 14 14 6 6 6 0 0 0
45620 - 0 0 0 0 0 0 0 0 0 0 0 0
45621 - 0 0 0 0 0 0 0 0 0 0 0 0
45622 - 0 0 0 0 0 0 0 0 0 0 0 0
45623 - 0 0 0 0 0 0 0 0 0 6 6 6
45624 - 30 30 30 78 78 78 190 142 34 226 170 11
45625 -239 182 13 246 190 14 246 190 14 246 190 14
45626 -246 190 14 246 190 14 246 190 14 246 190 14
45627 -246 190 14 246 190 14 246 190 14 246 190 14
45628 -246 190 14 241 196 14 203 166 17 22 18 6
45629 - 2 2 6 2 2 6 2 2 6 38 38 38
45630 -218 218 218 253 253 253 253 253 253 253 253 253
45631 -253 253 253 253 253 253 253 253 253 253 253 253
45632 -253 253 253 253 253 253 253 253 253 253 253 253
45633 -253 253 253 253 253 253 253 253 253 253 253 253
45634 -250 250 250 206 206 206 198 198 198 202 162 69
45635 -226 170 11 236 178 12 224 166 10 210 150 10
45636 -200 144 11 197 138 11 192 133 9 197 138 11
45637 -210 150 10 226 170 11 242 186 14 246 190 14
45638 -246 190 14 246 186 14 225 175 15 124 112 88
45639 - 62 62 62 30 30 30 14 14 14 6 6 6
45640 - 0 0 0 0 0 0 0 0 0 0 0 0
45641 - 0 0 0 0 0 0 0 0 0 0 0 0
45642 - 0 0 0 0 0 0 0 0 0 0 0 0
45643 - 0 0 0 0 0 0 0 0 0 10 10 10
45644 - 30 30 30 78 78 78 174 135 50 224 166 10
45645 -239 182 13 246 190 14 246 190 14 246 190 14
45646 -246 190 14 246 190 14 246 190 14 246 190 14
45647 -246 190 14 246 190 14 246 190 14 246 190 14
45648 -246 190 14 246 190 14 241 196 14 139 102 15
45649 - 2 2 6 2 2 6 2 2 6 2 2 6
45650 - 78 78 78 250 250 250 253 253 253 253 253 253
45651 -253 253 253 253 253 253 253 253 253 253 253 253
45652 -253 253 253 253 253 253 253 253 253 253 253 253
45653 -253 253 253 253 253 253 253 253 253 253 253 253
45654 -250 250 250 214 214 214 198 198 198 190 150 46
45655 -219 162 10 236 178 12 234 174 13 224 166 10
45656 -216 158 10 213 154 11 213 154 11 216 158 10
45657 -226 170 11 239 182 13 246 190 14 246 190 14
45658 -246 190 14 246 190 14 242 186 14 206 162 42
45659 -101 101 101 58 58 58 30 30 30 14 14 14
45660 - 6 6 6 0 0 0 0 0 0 0 0 0
45661 - 0 0 0 0 0 0 0 0 0 0 0 0
45662 - 0 0 0 0 0 0 0 0 0 0 0 0
45663 - 0 0 0 0 0 0 0 0 0 10 10 10
45664 - 30 30 30 74 74 74 174 135 50 216 158 10
45665 -236 178 12 246 190 14 246 190 14 246 190 14
45666 -246 190 14 246 190 14 246 190 14 246 190 14
45667 -246 190 14 246 190 14 246 190 14 246 190 14
45668 -246 190 14 246 190 14 241 196 14 226 184 13
45669 - 61 42 6 2 2 6 2 2 6 2 2 6
45670 - 22 22 22 238 238 238 253 253 253 253 253 253
45671 -253 253 253 253 253 253 253 253 253 253 253 253
45672 -253 253 253 253 253 253 253 253 253 253 253 253
45673 -253 253 253 253 253 253 253 253 253 253 253 253
45674 -253 253 253 226 226 226 187 187 187 180 133 36
45675 -216 158 10 236 178 12 239 182 13 236 178 12
45676 -230 174 11 226 170 11 226 170 11 230 174 11
45677 -236 178 12 242 186 14 246 190 14 246 190 14
45678 -246 190 14 246 190 14 246 186 14 239 182 13
45679 -206 162 42 106 106 106 66 66 66 34 34 34
45680 - 14 14 14 6 6 6 0 0 0 0 0 0
45681 - 0 0 0 0 0 0 0 0 0 0 0 0
45682 - 0 0 0 0 0 0 0 0 0 0 0 0
45683 - 0 0 0 0 0 0 0 0 0 6 6 6
45684 - 26 26 26 70 70 70 163 133 67 213 154 11
45685 -236 178 12 246 190 14 246 190 14 246 190 14
45686 -246 190 14 246 190 14 246 190 14 246 190 14
45687 -246 190 14 246 190 14 246 190 14 246 190 14
45688 -246 190 14 246 190 14 246 190 14 241 196 14
45689 -190 146 13 18 14 6 2 2 6 2 2 6
45690 - 46 46 46 246 246 246 253 253 253 253 253 253
45691 -253 253 253 253 253 253 253 253 253 253 253 253
45692 -253 253 253 253 253 253 253 253 253 253 253 253
45693 -253 253 253 253 253 253 253 253 253 253 253 253
45694 -253 253 253 221 221 221 86 86 86 156 107 11
45695 -216 158 10 236 178 12 242 186 14 246 186 14
45696 -242 186 14 239 182 13 239 182 13 242 186 14
45697 -242 186 14 246 186 14 246 190 14 246 190 14
45698 -246 190 14 246 190 14 246 190 14 246 190 14
45699 -242 186 14 225 175 15 142 122 72 66 66 66
45700 - 30 30 30 10 10 10 0 0 0 0 0 0
45701 - 0 0 0 0 0 0 0 0 0 0 0 0
45702 - 0 0 0 0 0 0 0 0 0 0 0 0
45703 - 0 0 0 0 0 0 0 0 0 6 6 6
45704 - 26 26 26 70 70 70 163 133 67 210 150 10
45705 -236 178 12 246 190 14 246 190 14 246 190 14
45706 -246 190 14 246 190 14 246 190 14 246 190 14
45707 -246 190 14 246 190 14 246 190 14 246 190 14
45708 -246 190 14 246 190 14 246 190 14 246 190 14
45709 -232 195 16 121 92 8 34 34 34 106 106 106
45710 -221 221 221 253 253 253 253 253 253 253 253 253
45711 -253 253 253 253 253 253 253 253 253 253 253 253
45712 -253 253 253 253 253 253 253 253 253 253 253 253
45713 -253 253 253 253 253 253 253 253 253 253 253 253
45714 -242 242 242 82 82 82 18 14 6 163 110 8
45715 -216 158 10 236 178 12 242 186 14 246 190 14
45716 -246 190 14 246 190 14 246 190 14 246 190 14
45717 -246 190 14 246 190 14 246 190 14 246 190 14
45718 -246 190 14 246 190 14 246 190 14 246 190 14
45719 -246 190 14 246 190 14 242 186 14 163 133 67
45720 - 46 46 46 18 18 18 6 6 6 0 0 0
45721 - 0 0 0 0 0 0 0 0 0 0 0 0
45722 - 0 0 0 0 0 0 0 0 0 0 0 0
45723 - 0 0 0 0 0 0 0 0 0 10 10 10
45724 - 30 30 30 78 78 78 163 133 67 210 150 10
45725 -236 178 12 246 186 14 246 190 14 246 190 14
45726 -246 190 14 246 190 14 246 190 14 246 190 14
45727 -246 190 14 246 190 14 246 190 14 246 190 14
45728 -246 190 14 246 190 14 246 190 14 246 190 14
45729 -241 196 14 215 174 15 190 178 144 253 253 253
45730 -253 253 253 253 253 253 253 253 253 253 253 253
45731 -253 253 253 253 253 253 253 253 253 253 253 253
45732 -253 253 253 253 253 253 253 253 253 253 253 253
45733 -253 253 253 253 253 253 253 253 253 218 218 218
45734 - 58 58 58 2 2 6 22 18 6 167 114 7
45735 -216 158 10 236 178 12 246 186 14 246 190 14
45736 -246 190 14 246 190 14 246 190 14 246 190 14
45737 -246 190 14 246 190 14 246 190 14 246 190 14
45738 -246 190 14 246 190 14 246 190 14 246 190 14
45739 -246 190 14 246 186 14 242 186 14 190 150 46
45740 - 54 54 54 22 22 22 6 6 6 0 0 0
45741 - 0 0 0 0 0 0 0 0 0 0 0 0
45742 - 0 0 0 0 0 0 0 0 0 0 0 0
45743 - 0 0 0 0 0 0 0 0 0 14 14 14
45744 - 38 38 38 86 86 86 180 133 36 213 154 11
45745 -236 178 12 246 186 14 246 190 14 246 190 14
45746 -246 190 14 246 190 14 246 190 14 246 190 14
45747 -246 190 14 246 190 14 246 190 14 246 190 14
45748 -246 190 14 246 190 14 246 190 14 246 190 14
45749 -246 190 14 232 195 16 190 146 13 214 214 214
45750 -253 253 253 253 253 253 253 253 253 253 253 253
45751 -253 253 253 253 253 253 253 253 253 253 253 253
45752 -253 253 253 253 253 253 253 253 253 253 253 253
45753 -253 253 253 250 250 250 170 170 170 26 26 26
45754 - 2 2 6 2 2 6 37 26 9 163 110 8
45755 -219 162 10 239 182 13 246 186 14 246 190 14
45756 -246 190 14 246 190 14 246 190 14 246 190 14
45757 -246 190 14 246 190 14 246 190 14 246 190 14
45758 -246 190 14 246 190 14 246 190 14 246 190 14
45759 -246 186 14 236 178 12 224 166 10 142 122 72
45760 - 46 46 46 18 18 18 6 6 6 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 6 6 6 18 18 18
45764 - 50 50 50 109 106 95 192 133 9 224 166 10
45765 -242 186 14 246 190 14 246 190 14 246 190 14
45766 -246 190 14 246 190 14 246 190 14 246 190 14
45767 -246 190 14 246 190 14 246 190 14 246 190 14
45768 -246 190 14 246 190 14 246 190 14 246 190 14
45769 -242 186 14 226 184 13 210 162 10 142 110 46
45770 -226 226 226 253 253 253 253 253 253 253 253 253
45771 -253 253 253 253 253 253 253 253 253 253 253 253
45772 -253 253 253 253 253 253 253 253 253 253 253 253
45773 -198 198 198 66 66 66 2 2 6 2 2 6
45774 - 2 2 6 2 2 6 50 34 6 156 107 11
45775 -219 162 10 239 182 13 246 186 14 246 190 14
45776 -246 190 14 246 190 14 246 190 14 246 190 14
45777 -246 190 14 246 190 14 246 190 14 246 190 14
45778 -246 190 14 246 190 14 246 190 14 242 186 14
45779 -234 174 13 213 154 11 154 122 46 66 66 66
45780 - 30 30 30 10 10 10 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 6 6 6 22 22 22
45784 - 58 58 58 154 121 60 206 145 10 234 174 13
45785 -242 186 14 246 186 14 246 190 14 246 190 14
45786 -246 190 14 246 190 14 246 190 14 246 190 14
45787 -246 190 14 246 190 14 246 190 14 246 190 14
45788 -246 190 14 246 190 14 246 190 14 246 190 14
45789 -246 186 14 236 178 12 210 162 10 163 110 8
45790 - 61 42 6 138 138 138 218 218 218 250 250 250
45791 -253 253 253 253 253 253 253 253 253 250 250 250
45792 -242 242 242 210 210 210 144 144 144 66 66 66
45793 - 6 6 6 2 2 6 2 2 6 2 2 6
45794 - 2 2 6 2 2 6 61 42 6 163 110 8
45795 -216 158 10 236 178 12 246 190 14 246 190 14
45796 -246 190 14 246 190 14 246 190 14 246 190 14
45797 -246 190 14 246 190 14 246 190 14 246 190 14
45798 -246 190 14 239 182 13 230 174 11 216 158 10
45799 -190 142 34 124 112 88 70 70 70 38 38 38
45800 - 18 18 18 6 6 6 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 6 6 6 22 22 22
45804 - 62 62 62 168 124 44 206 145 10 224 166 10
45805 -236 178 12 239 182 13 242 186 14 242 186 14
45806 -246 186 14 246 190 14 246 190 14 246 190 14
45807 -246 190 14 246 190 14 246 190 14 246 190 14
45808 -246 190 14 246 190 14 246 190 14 246 190 14
45809 -246 190 14 236 178 12 216 158 10 175 118 6
45810 - 80 54 7 2 2 6 6 6 6 30 30 30
45811 - 54 54 54 62 62 62 50 50 50 38 38 38
45812 - 14 14 14 2 2 6 2 2 6 2 2 6
45813 - 2 2 6 2 2 6 2 2 6 2 2 6
45814 - 2 2 6 6 6 6 80 54 7 167 114 7
45815 -213 154 11 236 178 12 246 190 14 246 190 14
45816 -246 190 14 246 190 14 246 190 14 246 190 14
45817 -246 190 14 242 186 14 239 182 13 239 182 13
45818 -230 174 11 210 150 10 174 135 50 124 112 88
45819 - 82 82 82 54 54 54 34 34 34 18 18 18
45820 - 6 6 6 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 6 6 6 18 18 18
45824 - 50 50 50 158 118 36 192 133 9 200 144 11
45825 -216 158 10 219 162 10 224 166 10 226 170 11
45826 -230 174 11 236 178 12 239 182 13 239 182 13
45827 -242 186 14 246 186 14 246 190 14 246 190 14
45828 -246 190 14 246 190 14 246 190 14 246 190 14
45829 -246 186 14 230 174 11 210 150 10 163 110 8
45830 -104 69 6 10 10 10 2 2 6 2 2 6
45831 - 2 2 6 2 2 6 2 2 6 2 2 6
45832 - 2 2 6 2 2 6 2 2 6 2 2 6
45833 - 2 2 6 2 2 6 2 2 6 2 2 6
45834 - 2 2 6 6 6 6 91 60 6 167 114 7
45835 -206 145 10 230 174 11 242 186 14 246 190 14
45836 -246 190 14 246 190 14 246 186 14 242 186 14
45837 -239 182 13 230 174 11 224 166 10 213 154 11
45838 -180 133 36 124 112 88 86 86 86 58 58 58
45839 - 38 38 38 22 22 22 10 10 10 6 6 6
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 14 14 14
45844 - 34 34 34 70 70 70 138 110 50 158 118 36
45845 -167 114 7 180 123 7 192 133 9 197 138 11
45846 -200 144 11 206 145 10 213 154 11 219 162 10
45847 -224 166 10 230 174 11 239 182 13 242 186 14
45848 -246 186 14 246 186 14 246 186 14 246 186 14
45849 -239 182 13 216 158 10 185 133 11 152 99 6
45850 -104 69 6 18 14 6 2 2 6 2 2 6
45851 - 2 2 6 2 2 6 2 2 6 2 2 6
45852 - 2 2 6 2 2 6 2 2 6 2 2 6
45853 - 2 2 6 2 2 6 2 2 6 2 2 6
45854 - 2 2 6 6 6 6 80 54 7 152 99 6
45855 -192 133 9 219 162 10 236 178 12 239 182 13
45856 -246 186 14 242 186 14 239 182 13 236 178 12
45857 -224 166 10 206 145 10 192 133 9 154 121 60
45858 - 94 94 94 62 62 62 42 42 42 22 22 22
45859 - 14 14 14 6 6 6 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 6 6 6
45864 - 18 18 18 34 34 34 58 58 58 78 78 78
45865 -101 98 89 124 112 88 142 110 46 156 107 11
45866 -163 110 8 167 114 7 175 118 6 180 123 7
45867 -185 133 11 197 138 11 210 150 10 219 162 10
45868 -226 170 11 236 178 12 236 178 12 234 174 13
45869 -219 162 10 197 138 11 163 110 8 130 83 6
45870 - 91 60 6 10 10 10 2 2 6 2 2 6
45871 - 18 18 18 38 38 38 38 38 38 38 38 38
45872 - 38 38 38 38 38 38 38 38 38 38 38 38
45873 - 38 38 38 38 38 38 26 26 26 2 2 6
45874 - 2 2 6 6 6 6 70 47 6 137 92 6
45875 -175 118 6 200 144 11 219 162 10 230 174 11
45876 -234 174 13 230 174 11 219 162 10 210 150 10
45877 -192 133 9 163 110 8 124 112 88 82 82 82
45878 - 50 50 50 30 30 30 14 14 14 6 6 6
45879 - 0 0 0 0 0 0 0 0 0 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 - 6 6 6 14 14 14 22 22 22 34 34 34
45885 - 42 42 42 58 58 58 74 74 74 86 86 86
45886 -101 98 89 122 102 70 130 98 46 121 87 25
45887 -137 92 6 152 99 6 163 110 8 180 123 7
45888 -185 133 11 197 138 11 206 145 10 200 144 11
45889 -180 123 7 156 107 11 130 83 6 104 69 6
45890 - 50 34 6 54 54 54 110 110 110 101 98 89
45891 - 86 86 86 82 82 82 78 78 78 78 78 78
45892 - 78 78 78 78 78 78 78 78 78 78 78 78
45893 - 78 78 78 82 82 82 86 86 86 94 94 94
45894 -106 106 106 101 101 101 86 66 34 124 80 6
45895 -156 107 11 180 123 7 192 133 9 200 144 11
45896 -206 145 10 200 144 11 192 133 9 175 118 6
45897 -139 102 15 109 106 95 70 70 70 42 42 42
45898 - 22 22 22 10 10 10 0 0 0 0 0 0
45899 - 0 0 0 0 0 0 0 0 0 0 0 0
45900 - 0 0 0 0 0 0 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 6 6 6 10 10 10
45905 - 14 14 14 22 22 22 30 30 30 38 38 38
45906 - 50 50 50 62 62 62 74 74 74 90 90 90
45907 -101 98 89 112 100 78 121 87 25 124 80 6
45908 -137 92 6 152 99 6 152 99 6 152 99 6
45909 -138 86 6 124 80 6 98 70 6 86 66 30
45910 -101 98 89 82 82 82 58 58 58 46 46 46
45911 - 38 38 38 34 34 34 34 34 34 34 34 34
45912 - 34 34 34 34 34 34 34 34 34 34 34 34
45913 - 34 34 34 34 34 34 38 38 38 42 42 42
45914 - 54 54 54 82 82 82 94 86 76 91 60 6
45915 -134 86 6 156 107 11 167 114 7 175 118 6
45916 -175 118 6 167 114 7 152 99 6 121 87 25
45917 -101 98 89 62 62 62 34 34 34 18 18 18
45918 - 6 6 6 0 0 0 0 0 0 0 0 0
45919 - 0 0 0 0 0 0 0 0 0 0 0 0
45920 - 0 0 0 0 0 0 0 0 0 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 - 0 0 0 6 6 6 6 6 6 10 10 10
45926 - 18 18 18 22 22 22 30 30 30 42 42 42
45927 - 50 50 50 66 66 66 86 86 86 101 98 89
45928 -106 86 58 98 70 6 104 69 6 104 69 6
45929 -104 69 6 91 60 6 82 62 34 90 90 90
45930 - 62 62 62 38 38 38 22 22 22 14 14 14
45931 - 10 10 10 10 10 10 10 10 10 10 10 10
45932 - 10 10 10 10 10 10 6 6 6 10 10 10
45933 - 10 10 10 10 10 10 10 10 10 14 14 14
45934 - 22 22 22 42 42 42 70 70 70 89 81 66
45935 - 80 54 7 104 69 6 124 80 6 137 92 6
45936 -134 86 6 116 81 8 100 82 52 86 86 86
45937 - 58 58 58 30 30 30 14 14 14 6 6 6
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 0 0 0
45945 - 0 0 0 0 0 0 0 0 0 0 0 0
45946 - 0 0 0 6 6 6 10 10 10 14 14 14
45947 - 18 18 18 26 26 26 38 38 38 54 54 54
45948 - 70 70 70 86 86 86 94 86 76 89 81 66
45949 - 89 81 66 86 86 86 74 74 74 50 50 50
45950 - 30 30 30 14 14 14 6 6 6 0 0 0
45951 - 0 0 0 0 0 0 0 0 0 0 0 0
45952 - 0 0 0 0 0 0 0 0 0 0 0 0
45953 - 0 0 0 0 0 0 0 0 0 0 0 0
45954 - 6 6 6 18 18 18 34 34 34 58 58 58
45955 - 82 82 82 89 81 66 89 81 66 89 81 66
45956 - 94 86 66 94 86 76 74 74 74 50 50 50
45957 - 26 26 26 14 14 14 6 6 6 0 0 0
45958 - 0 0 0 0 0 0 0 0 0 0 0 0
45959 - 0 0 0 0 0 0 0 0 0 0 0 0
45960 - 0 0 0 0 0 0 0 0 0 0 0 0
45961 - 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 0 0 0
45965 - 0 0 0 0 0 0 0 0 0 0 0 0
45966 - 0 0 0 0 0 0 0 0 0 0 0 0
45967 - 6 6 6 6 6 6 14 14 14 18 18 18
45968 - 30 30 30 38 38 38 46 46 46 54 54 54
45969 - 50 50 50 42 42 42 30 30 30 18 18 18
45970 - 10 10 10 0 0 0 0 0 0 0 0 0
45971 - 0 0 0 0 0 0 0 0 0 0 0 0
45972 - 0 0 0 0 0 0 0 0 0 0 0 0
45973 - 0 0 0 0 0 0 0 0 0 0 0 0
45974 - 0 0 0 6 6 6 14 14 14 26 26 26
45975 - 38 38 38 50 50 50 58 58 58 58 58 58
45976 - 54 54 54 42 42 42 30 30 30 18 18 18
45977 - 10 10 10 0 0 0 0 0 0 0 0 0
45978 - 0 0 0 0 0 0 0 0 0 0 0 0
45979 - 0 0 0 0 0 0 0 0 0 0 0 0
45980 - 0 0 0 0 0 0 0 0 0 0 0 0
45981 - 0 0 0 0 0 0 0 0 0 0 0 0
45982 - 0 0 0 0 0 0 0 0 0 0 0 0
45983 - 0 0 0 0 0 0 0 0 0 0 0 0
45984 - 0 0 0 0 0 0 0 0 0 0 0 0
45985 - 0 0 0 0 0 0 0 0 0 0 0 0
45986 - 0 0 0 0 0 0 0 0 0 0 0 0
45987 - 0 0 0 0 0 0 0 0 0 6 6 6
45988 - 6 6 6 10 10 10 14 14 14 18 18 18
45989 - 18 18 18 14 14 14 10 10 10 6 6 6
45990 - 0 0 0 0 0 0 0 0 0 0 0 0
45991 - 0 0 0 0 0 0 0 0 0 0 0 0
45992 - 0 0 0 0 0 0 0 0 0 0 0 0
45993 - 0 0 0 0 0 0 0 0 0 0 0 0
45994 - 0 0 0 0 0 0 0 0 0 6 6 6
45995 - 14 14 14 18 18 18 22 22 22 22 22 22
45996 - 18 18 18 14 14 14 10 10 10 6 6 6
45997 - 0 0 0 0 0 0 0 0 0 0 0 0
45998 - 0 0 0 0 0 0 0 0 0 0 0 0
45999 - 0 0 0 0 0 0 0 0 0 0 0 0
46000 - 0 0 0 0 0 0 0 0 0 0 0 0
46001 - 0 0 0 0 0 0 0 0 0 0 0 0
46002 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46003 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46004 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46005 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46006 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46007 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46008 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46009 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46010 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46011 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46012 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46013 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46014 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46015 +4 4 4 4 4 4
46016 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46017 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46018 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46019 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46020 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46021 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46022 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46023 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46024 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46025 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46026 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46027 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46028 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46029 +4 4 4 4 4 4
46030 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46031 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46032 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46033 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46034 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46035 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46036 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46037 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46038 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46039 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46040 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46041 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46042 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46043 +4 4 4 4 4 4
46044 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46045 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46046 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46047 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46048 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46049 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46050 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46051 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46052 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46053 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46054 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46055 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46056 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46057 +4 4 4 4 4 4
46058 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46059 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46060 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46061 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46062 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46063 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46064 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46065 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46066 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46067 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46068 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46069 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46070 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46071 +4 4 4 4 4 4
46072 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46073 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46074 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46075 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46076 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46077 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46078 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46079 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46080 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46081 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46082 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46083 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46084 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46085 +4 4 4 4 4 4
46086 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46087 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46088 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46089 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46090 +4 4 4 4 4 4 4 4 4 3 3 3 0 0 0 0 0 0
46091 +0 0 0 0 0 0 0 0 0 0 0 0 3 3 3 4 4 4
46092 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46093 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46094 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46095 +4 4 4 4 4 4 4 4 4 4 4 4 1 1 1 0 0 0
46096 +0 0 0 3 3 3 4 4 4 4 4 4 4 4 4 4 4 4
46097 +4 4 4 4 4 4 4 4 4 2 1 0 2 1 0 3 2 2
46098 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46099 +4 4 4 4 4 4
46100 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46101 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46102 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46103 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46104 +4 4 4 4 4 4 2 2 2 0 0 0 3 4 3 26 28 28
46105 +37 38 37 37 38 37 14 17 19 2 2 2 0 0 0 2 2 2
46106 +5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46107 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46108 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46109 +4 4 4 4 4 4 3 3 3 0 0 0 1 1 1 6 6 6
46110 +2 2 2 0 0 0 3 3 3 4 4 4 4 4 4 4 4 4
46111 +4 4 5 3 3 3 1 0 0 0 0 0 1 0 0 0 0 0
46112 +1 1 1 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46113 +4 4 4 4 4 4
46114 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46115 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46116 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46117 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46118 +2 2 2 0 0 0 0 0 0 14 17 19 60 74 84 137 136 137
46119 +153 152 153 137 136 137 125 124 125 60 73 81 6 6 6 3 1 0
46120 +0 0 0 3 3 3 4 4 4 4 4 4 4 4 4 4 4 4
46121 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46122 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46123 +4 4 4 4 4 4 0 0 0 4 4 4 41 54 63 125 124 125
46124 +60 73 81 6 6 6 4 0 0 3 3 3 4 4 4 4 4 4
46125 +4 4 4 0 0 0 6 9 11 41 54 63 41 65 82 22 30 35
46126 +2 2 2 2 1 0 4 4 4 4 4 4 4 4 4 4 4 4
46127 +4 4 4 4 4 4
46128 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46129 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46130 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46131 +4 4 4 4 4 4 5 5 5 5 5 5 2 2 2 0 0 0
46132 +4 0 0 6 6 6 41 54 63 137 136 137 174 174 174 167 166 167
46133 +165 164 165 165 164 165 163 162 163 163 162 163 125 124 125 41 54 63
46134 +1 1 1 0 0 0 0 0 0 3 3 3 5 5 5 4 4 4
46135 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46136 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 5 5 5
46137 +3 3 3 2 0 0 4 0 0 60 73 81 156 155 156 167 166 167
46138 +163 162 163 85 115 134 5 7 8 0 0 0 4 4 4 5 5 5
46139 +0 0 0 2 5 5 55 98 126 90 154 193 90 154 193 72 125 159
46140 +37 51 59 2 0 0 1 1 1 4 5 5 4 4 4 4 4 4
46141 +4 4 4 4 4 4
46142 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46143 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46144 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46145 +4 4 4 5 5 5 4 4 4 1 1 1 0 0 0 3 3 3
46146 +37 38 37 125 124 125 163 162 163 174 174 174 158 157 158 158 157 158
46147 +156 155 156 156 155 156 158 157 158 165 164 165 174 174 174 166 165 166
46148 +125 124 125 16 19 21 1 0 0 0 0 0 0 0 0 4 4 4
46149 +5 5 5 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
46150 +4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 1 1 1
46151 +0 0 0 0 0 0 37 38 37 153 152 153 174 174 174 158 157 158
46152 +174 174 174 163 162 163 37 38 37 4 3 3 4 0 0 1 1 1
46153 +0 0 0 22 40 52 101 161 196 101 161 196 90 154 193 101 161 196
46154 +64 123 161 14 17 19 0 0 0 4 4 4 4 4 4 4 4 4
46155 +4 4 4 4 4 4
46156 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46157 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46158 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
46159 +5 5 5 2 2 2 0 0 0 4 0 0 24 26 27 85 115 134
46160 +156 155 156 174 174 174 167 166 167 156 155 156 154 153 154 157 156 157
46161 +156 155 156 156 155 156 155 154 155 153 152 153 158 157 158 167 166 167
46162 +174 174 174 156 155 156 60 74 84 16 19 21 0 0 0 0 0 0
46163 +1 1 1 5 5 5 5 5 5 4 4 4 4 4 4 4 4 4
46164 +4 4 4 5 5 5 6 6 6 3 3 3 0 0 0 4 0 0
46165 +13 16 17 60 73 81 137 136 137 165 164 165 156 155 156 153 152 153
46166 +174 174 174 177 184 187 60 73 81 3 1 0 0 0 0 1 1 2
46167 +22 30 35 64 123 161 136 185 209 90 154 193 90 154 193 90 154 193
46168 +90 154 193 21 29 34 0 0 0 3 2 2 4 4 5 4 4 4
46169 +4 4 4 4 4 4
46170 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46171 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46172 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 3 3 3
46173 +0 0 0 0 0 0 10 13 16 60 74 84 157 156 157 174 174 174
46174 +174 174 174 158 157 158 153 152 153 154 153 154 156 155 156 155 154 155
46175 +156 155 156 155 154 155 154 153 154 157 156 157 154 153 154 153 152 153
46176 +163 162 163 174 174 174 177 184 187 137 136 137 60 73 81 13 16 17
46177 +4 0 0 0 0 0 3 3 3 5 5 5 4 4 4 4 4 4
46178 +5 5 5 4 4 4 1 1 1 0 0 0 3 3 3 41 54 63
46179 +131 129 131 174 174 174 174 174 174 174 174 174 167 166 167 174 174 174
46180 +190 197 201 137 136 137 24 26 27 4 0 0 16 21 25 50 82 103
46181 +90 154 193 136 185 209 90 154 193 101 161 196 101 161 196 101 161 196
46182 +31 91 132 3 6 7 0 0 0 4 4 4 4 4 4 4 4 4
46183 +4 4 4 4 4 4
46184 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46185 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46186 +4 4 4 4 4 4 4 4 4 2 2 2 0 0 0 4 0 0
46187 +4 0 0 43 57 68 137 136 137 177 184 187 174 174 174 163 162 163
46188 +155 154 155 155 154 155 156 155 156 155 154 155 158 157 158 165 164 165
46189 +167 166 167 166 165 166 163 162 163 157 156 157 155 154 155 155 154 155
46190 +153 152 153 156 155 156 167 166 167 174 174 174 174 174 174 131 129 131
46191 +41 54 63 5 5 5 0 0 0 0 0 0 3 3 3 4 4 4
46192 +1 1 1 0 0 0 1 0 0 26 28 28 125 124 125 174 174 174
46193 +177 184 187 174 174 174 174 174 174 156 155 156 131 129 131 137 136 137
46194 +125 124 125 24 26 27 4 0 0 41 65 82 90 154 193 136 185 209
46195 +136 185 209 101 161 196 53 118 160 37 112 160 90 154 193 34 86 122
46196 +7 12 15 0 0 0 4 4 4 4 4 4 4 4 4 4 4 4
46197 +4 4 4 4 4 4
46198 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46199 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46200 +4 4 4 3 3 3 0 0 0 0 0 0 5 5 5 37 38 37
46201 +125 124 125 167 166 167 174 174 174 167 166 167 158 157 158 155 154 155
46202 +156 155 156 156 155 156 156 155 156 163 162 163 167 166 167 155 154 155
46203 +137 136 137 153 152 153 156 155 156 165 164 165 163 162 163 156 155 156
46204 +156 155 156 156 155 156 155 154 155 158 157 158 166 165 166 174 174 174
46205 +167 166 167 125 124 125 37 38 37 1 0 0 0 0 0 0 0 0
46206 +0 0 0 24 26 27 60 74 84 158 157 158 174 174 174 174 174 174
46207 +166 165 166 158 157 158 125 124 125 41 54 63 13 16 17 6 6 6
46208 +6 6 6 37 38 37 80 127 157 136 185 209 101 161 196 101 161 196
46209 +90 154 193 28 67 93 6 10 14 13 20 25 13 20 25 6 10 14
46210 +1 1 2 4 3 3 4 4 4 4 4 4 4 4 4 4 4 4
46211 +4 4 4 4 4 4
46212 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46213 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46214 +1 1 1 1 0 0 4 3 3 37 38 37 60 74 84 153 152 153
46215 +167 166 167 167 166 167 158 157 158 154 153 154 155 154 155 156 155 156
46216 +157 156 157 158 157 158 167 166 167 167 166 167 131 129 131 43 57 68
46217 +26 28 28 37 38 37 60 73 81 131 129 131 165 164 165 166 165 166
46218 +158 157 158 155 154 155 156 155 156 156 155 156 156 155 156 158 157 158
46219 +165 164 165 174 174 174 163 162 163 60 74 84 16 19 21 13 16 17
46220 +60 73 81 131 129 131 174 174 174 174 174 174 167 166 167 165 164 165
46221 +137 136 137 60 73 81 24 26 27 4 0 0 4 0 0 16 19 21
46222 +52 104 138 101 161 196 136 185 209 136 185 209 90 154 193 27 99 146
46223 +13 20 25 4 5 7 2 5 5 4 5 7 1 1 2 0 0 0
46224 +4 4 4 4 4 4 3 3 3 2 2 2 2 2 2 4 4 4
46225 +4 4 4 4 4 4
46226 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46227 +4 4 4 4 4 4 4 4 4 4 4 4 3 3 3 0 0 0
46228 +0 0 0 13 16 17 60 73 81 137 136 137 174 174 174 166 165 166
46229 +158 157 158 156 155 156 157 156 157 156 155 156 155 154 155 158 157 158
46230 +167 166 167 174 174 174 153 152 153 60 73 81 16 19 21 4 0 0
46231 +4 0 0 4 0 0 6 6 6 26 28 28 60 74 84 158 157 158
46232 +174 174 174 166 165 166 157 156 157 155 154 155 156 155 156 156 155 156
46233 +155 154 155 158 157 158 167 166 167 167 166 167 131 129 131 125 124 125
46234 +137 136 137 167 166 167 167 166 167 174 174 174 158 157 158 125 124 125
46235 +16 19 21 4 0 0 4 0 0 10 13 16 49 76 92 107 159 188
46236 +136 185 209 136 185 209 90 154 193 26 108 161 22 40 52 6 10 14
46237 +2 3 3 1 1 2 1 1 2 4 4 5 4 4 5 4 4 5
46238 +4 4 5 2 2 1 0 0 0 0 0 0 0 0 0 2 2 2
46239 +4 4 4 4 4 4
46240 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46241 +4 4 4 5 5 5 3 3 3 0 0 0 1 0 0 4 0 0
46242 +37 51 59 131 129 131 167 166 167 167 166 167 163 162 163 157 156 157
46243 +157 156 157 155 154 155 153 152 153 157 156 157 167 166 167 174 174 174
46244 +153 152 153 125 124 125 37 38 37 4 0 0 4 0 0 4 0 0
46245 +4 3 3 4 3 3 4 0 0 6 6 6 4 0 0 37 38 37
46246 +125 124 125 174 174 174 174 174 174 165 164 165 156 155 156 154 153 154
46247 +156 155 156 156 155 156 155 154 155 163 162 163 158 157 158 163 162 163
46248 +174 174 174 174 174 174 174 174 174 125 124 125 37 38 37 0 0 0
46249 +4 0 0 6 9 11 41 54 63 90 154 193 136 185 209 146 190 211
46250 +136 185 209 37 112 160 22 40 52 6 10 14 3 6 7 1 1 2
46251 +1 1 2 3 3 3 1 1 2 3 3 3 4 4 4 4 4 4
46252 +2 2 2 2 0 0 16 19 21 37 38 37 24 26 27 0 0 0
46253 +0 0 0 4 4 4
46254 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 5 5 5
46255 +4 4 4 0 0 0 0 0 0 0 0 0 26 28 28 120 125 127
46256 +158 157 158 174 174 174 165 164 165 157 156 157 155 154 155 156 155 156
46257 +153 152 153 153 152 153 167 166 167 174 174 174 174 174 174 125 124 125
46258 +37 38 37 4 0 0 0 0 0 4 0 0 4 3 3 4 4 4
46259 +4 4 4 4 4 4 5 5 5 4 0 0 4 0 0 4 0 0
46260 +4 3 3 43 57 68 137 136 137 174 174 174 174 174 174 165 164 165
46261 +154 153 154 153 152 153 153 152 153 153 152 153 163 162 163 174 174 174
46262 +174 174 174 153 152 153 60 73 81 6 6 6 4 0 0 4 3 3
46263 +32 43 50 80 127 157 136 185 209 146 190 211 146 190 211 90 154 193
46264 +28 67 93 28 67 93 40 71 93 3 6 7 1 1 2 2 5 5
46265 +50 82 103 79 117 143 26 37 45 0 0 0 3 3 3 1 1 1
46266 +0 0 0 41 54 63 137 136 137 174 174 174 153 152 153 60 73 81
46267 +2 0 0 0 0 0
46268 +4 4 4 4 4 4 4 4 4 4 4 4 6 6 6 2 2 2
46269 +0 0 0 2 0 0 24 26 27 60 74 84 153 152 153 174 174 174
46270 +174 174 174 157 156 157 154 153 154 156 155 156 154 153 154 153 152 153
46271 +165 164 165 174 174 174 177 184 187 137 136 137 43 57 68 6 6 6
46272 +4 0 0 2 0 0 3 3 3 5 5 5 5 5 5 4 4 4
46273 +4 4 4 4 4 4 4 4 4 5 5 5 6 6 6 4 3 3
46274 +4 0 0 4 0 0 24 26 27 60 73 81 153 152 153 174 174 174
46275 +174 174 174 158 157 158 158 157 158 174 174 174 174 174 174 158 157 158
46276 +60 74 84 24 26 27 4 0 0 4 0 0 17 23 27 59 113 148
46277 +136 185 209 191 222 234 146 190 211 136 185 209 31 91 132 7 11 13
46278 +22 40 52 101 161 196 90 154 193 6 9 11 3 4 4 43 95 132
46279 +136 185 209 172 205 220 55 98 126 0 0 0 0 0 0 2 0 0
46280 +26 28 28 153 152 153 177 184 187 167 166 167 177 184 187 165 164 165
46281 +37 38 37 0 0 0
46282 +4 4 4 4 4 4 5 5 5 5 5 5 1 1 1 0 0 0
46283 +13 16 17 60 73 81 137 136 137 174 174 174 174 174 174 165 164 165
46284 +153 152 153 153 152 153 155 154 155 154 153 154 158 157 158 174 174 174
46285 +177 184 187 163 162 163 60 73 81 16 19 21 4 0 0 4 0 0
46286 +4 3 3 4 4 4 5 5 5 5 5 5 4 4 4 5 5 5
46287 +5 5 5 5 5 5 5 5 5 4 4 4 4 4 4 5 5 5
46288 +6 6 6 4 0 0 4 0 0 4 0 0 24 26 27 60 74 84
46289 +166 165 166 174 174 174 177 184 187 165 164 165 125 124 125 24 26 27
46290 +4 0 0 4 0 0 5 5 5 50 82 103 136 185 209 172 205 220
46291 +146 190 211 136 185 209 26 108 161 22 40 52 7 12 15 44 81 103
46292 +71 116 144 28 67 93 37 51 59 41 65 82 100 139 164 101 161 196
46293 +90 154 193 90 154 193 28 67 93 0 0 0 0 0 0 26 28 28
46294 +125 124 125 167 166 167 163 162 163 153 152 153 163 162 163 174 174 174
46295 +85 115 134 4 0 0
46296 +4 4 4 5 5 5 4 4 4 1 0 0 4 0 0 34 47 55
46297 +125 124 125 174 174 174 174 174 174 167 166 167 157 156 157 153 152 153
46298 +155 154 155 155 154 155 158 157 158 166 165 166 167 166 167 154 153 154
46299 +125 124 125 26 28 28 4 0 0 4 0 0 4 0 0 5 5 5
46300 +5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 1 1 1
46301 +0 0 0 0 0 0 1 1 1 4 4 4 4 4 4 4 4 4
46302 +5 5 5 5 5 5 4 3 3 4 0 0 4 0 0 6 6 6
46303 +37 38 37 131 129 131 137 136 137 37 38 37 0 0 0 4 0 0
46304 +4 5 5 43 61 72 90 154 193 172 205 220 146 190 211 136 185 209
46305 +90 154 193 28 67 93 13 20 25 43 61 72 71 116 144 44 81 103
46306 +2 5 5 7 11 13 59 113 148 101 161 196 90 154 193 28 67 93
46307 +13 20 25 6 10 14 0 0 0 13 16 17 60 73 81 137 136 137
46308 +166 165 166 158 157 158 156 155 156 154 153 154 167 166 167 174 174 174
46309 +60 73 81 4 0 0
46310 +4 4 4 4 4 4 0 0 0 3 3 3 60 74 84 174 174 174
46311 +174 174 174 167 166 167 163 162 163 155 154 155 157 156 157 155 154 155
46312 +156 155 156 163 162 163 167 166 167 158 157 158 125 124 125 37 38 37
46313 +4 3 3 4 0 0 4 0 0 6 6 6 6 6 6 5 5 5
46314 +4 4 4 4 4 4 4 4 4 1 1 1 0 0 0 2 3 3
46315 +10 13 16 7 11 13 1 0 0 0 0 0 2 2 1 4 4 4
46316 +4 4 4 4 4 4 4 4 4 5 5 5 4 3 3 4 0 0
46317 +4 0 0 7 11 13 13 16 17 4 0 0 3 3 3 34 47 55
46318 +80 127 157 146 190 211 172 205 220 136 185 209 136 185 209 136 185 209
46319 +28 67 93 22 40 52 55 98 126 55 98 126 21 29 34 7 11 13
46320 +50 82 103 101 161 196 101 161 196 35 83 115 13 20 25 2 2 1
46321 +1 1 2 1 1 2 37 51 59 131 129 131 174 174 174 174 174 174
46322 +167 166 167 163 162 163 163 162 163 167 166 167 174 174 174 125 124 125
46323 +16 19 21 4 0 0
46324 +4 4 4 4 0 0 4 0 0 60 74 84 174 174 174 174 174 174
46325 +158 157 158 155 154 155 155 154 155 156 155 156 155 154 155 158 157 158
46326 +167 166 167 165 164 165 131 129 131 60 73 81 13 16 17 4 0 0
46327 +4 0 0 4 3 3 6 6 6 4 3 3 5 5 5 4 4 4
46328 +4 4 4 3 2 2 0 0 0 0 0 0 7 11 13 45 69 86
46329 +80 127 157 71 116 144 43 61 72 7 11 13 0 0 0 1 1 1
46330 +4 3 3 4 4 4 4 4 4 4 4 4 6 6 6 5 5 5
46331 +3 2 2 4 0 0 1 0 0 21 29 34 59 113 148 136 185 209
46332 +146 190 211 136 185 209 136 185 209 136 185 209 136 185 209 136 185 209
46333 +68 124 159 44 81 103 22 40 52 13 16 17 43 61 72 90 154 193
46334 +136 185 209 59 113 148 21 29 34 3 4 3 1 1 1 0 0 0
46335 +24 26 27 125 124 125 163 162 163 174 174 174 166 165 166 165 164 165
46336 +163 162 163 125 124 125 125 124 125 125 124 125 125 124 125 26 28 28
46337 +4 0 0 4 3 3
46338 +3 3 3 0 0 0 24 26 27 153 152 153 177 184 187 158 157 158
46339 +156 155 156 156 155 156 155 154 155 155 154 155 165 164 165 174 174 174
46340 +155 154 155 60 74 84 26 28 28 4 0 0 4 0 0 3 1 0
46341 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 3 3
46342 +2 0 0 0 0 0 0 0 0 32 43 50 72 125 159 101 161 196
46343 +136 185 209 101 161 196 101 161 196 79 117 143 32 43 50 0 0 0
46344 +0 0 0 2 2 2 4 4 4 4 4 4 3 3 3 1 0 0
46345 +0 0 0 4 5 5 49 76 92 101 161 196 146 190 211 146 190 211
46346 +136 185 209 136 185 209 136 185 209 136 185 209 136 185 209 90 154 193
46347 +28 67 93 13 16 17 37 51 59 80 127 157 136 185 209 90 154 193
46348 +22 40 52 6 9 11 3 4 3 2 2 1 16 19 21 60 73 81
46349 +137 136 137 163 162 163 158 157 158 166 165 166 167 166 167 153 152 153
46350 +60 74 84 37 38 37 6 6 6 13 16 17 4 0 0 1 0 0
46351 +3 2 2 4 4 4
46352 +3 2 2 4 0 0 37 38 37 137 136 137 167 166 167 158 157 158
46353 +157 156 157 154 153 154 157 156 157 167 166 167 174 174 174 125 124 125
46354 +37 38 37 4 0 0 4 0 0 4 0 0 4 3 3 4 4 4
46355 +4 4 4 4 4 4 5 5 5 5 5 5 1 1 1 0 0 0
46356 +0 0 0 16 21 25 55 98 126 90 154 193 136 185 209 101 161 196
46357 +101 161 196 101 161 196 136 185 209 136 185 209 101 161 196 55 98 126
46358 +14 17 19 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
46359 +22 40 52 90 154 193 146 190 211 146 190 211 136 185 209 136 185 209
46360 +136 185 209 136 185 209 136 185 209 101 161 196 35 83 115 7 11 13
46361 +17 23 27 59 113 148 136 185 209 101 161 196 34 86 122 7 12 15
46362 +2 5 5 3 4 3 6 6 6 60 73 81 131 129 131 163 162 163
46363 +166 165 166 174 174 174 174 174 174 163 162 163 125 124 125 41 54 63
46364 +13 16 17 4 0 0 4 0 0 4 0 0 1 0 0 2 2 2
46365 +4 4 4 4 4 4
46366 +1 1 1 2 1 0 43 57 68 137 136 137 153 152 153 153 152 153
46367 +163 162 163 156 155 156 165 164 165 167 166 167 60 74 84 6 6 6
46368 +4 0 0 4 0 0 5 5 5 4 4 4 4 4 4 4 4 4
46369 +4 5 5 6 6 6 4 3 3 0 0 0 0 0 0 11 15 18
46370 +40 71 93 100 139 164 101 161 196 101 161 196 101 161 196 101 161 196
46371 +101 161 196 101 161 196 101 161 196 101 161 196 136 185 209 136 185 209
46372 +101 161 196 45 69 86 6 6 6 0 0 0 17 23 27 55 98 126
46373 +136 185 209 146 190 211 136 185 209 136 185 209 136 185 209 136 185 209
46374 +136 185 209 136 185 209 90 154 193 22 40 52 7 11 13 50 82 103
46375 +136 185 209 136 185 209 53 118 160 22 40 52 7 11 13 2 5 5
46376 +3 4 3 37 38 37 125 124 125 157 156 157 166 165 166 167 166 167
46377 +174 174 174 174 174 174 137 136 137 60 73 81 4 0 0 4 0 0
46378 +4 0 0 4 0 0 5 5 5 3 3 3 3 3 3 4 4 4
46379 +4 4 4 4 4 4
46380 +4 0 0 4 0 0 41 54 63 137 136 137 125 124 125 131 129 131
46381 +155 154 155 167 166 167 174 174 174 60 74 84 6 6 6 4 0 0
46382 +4 3 3 6 6 6 4 4 4 4 4 4 4 4 4 5 5 5
46383 +4 4 4 1 1 1 0 0 0 3 6 7 41 65 82 72 125 159
46384 +101 161 196 101 161 196 101 161 196 90 154 193 90 154 193 101 161 196
46385 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 136 185 209
46386 +136 185 209 136 185 209 80 127 157 55 98 126 101 161 196 146 190 211
46387 +136 185 209 136 185 209 136 185 209 101 161 196 136 185 209 101 161 196
46388 +136 185 209 101 161 196 35 83 115 22 30 35 101 161 196 172 205 220
46389 +90 154 193 28 67 93 7 11 13 2 5 5 3 4 3 13 16 17
46390 +85 115 134 167 166 167 174 174 174 174 174 174 174 174 174 174 174 174
46391 +167 166 167 60 74 84 13 16 17 4 0 0 4 0 0 4 3 3
46392 +6 6 6 5 5 5 4 4 4 5 5 5 4 4 4 5 5 5
46393 +5 5 5 5 5 5
46394 +1 1 1 4 0 0 41 54 63 137 136 137 137 136 137 125 124 125
46395 +131 129 131 167 166 167 157 156 157 37 38 37 6 6 6 4 0 0
46396 +6 6 6 5 5 5 4 4 4 4 4 4 4 5 5 2 2 1
46397 +0 0 0 0 0 0 26 37 45 58 111 146 101 161 196 101 161 196
46398 +101 161 196 90 154 193 90 154 193 90 154 193 101 161 196 101 161 196
46399 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
46400 +101 161 196 136 185 209 136 185 209 136 185 209 146 190 211 136 185 209
46401 +136 185 209 101 161 196 136 185 209 136 185 209 101 161 196 136 185 209
46402 +101 161 196 136 185 209 136 185 209 136 185 209 136 185 209 16 89 141
46403 +7 11 13 2 5 5 2 5 5 13 16 17 60 73 81 154 154 154
46404 +174 174 174 174 174 174 174 174 174 174 174 174 163 162 163 125 124 125
46405 +24 26 27 4 0 0 4 0 0 4 0 0 5 5 5 5 5 5
46406 +4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 5 5 5
46407 +5 5 5 4 4 4
46408 +4 0 0 6 6 6 37 38 37 137 136 137 137 136 137 131 129 131
46409 +131 129 131 153 152 153 131 129 131 26 28 28 4 0 0 4 3 3
46410 +6 6 6 4 4 4 4 4 4 4 4 4 0 0 0 0 0 0
46411 +13 20 25 51 88 114 90 154 193 101 161 196 101 161 196 90 154 193
46412 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 101 161 196
46413 +101 161 196 101 161 196 101 161 196 101 161 196 136 185 209 101 161 196
46414 +101 161 196 136 185 209 101 161 196 136 185 209 136 185 209 101 161 196
46415 +136 185 209 101 161 196 136 185 209 101 161 196 101 161 196 101 161 196
46416 +136 185 209 136 185 209 136 185 209 37 112 160 21 29 34 5 7 8
46417 +2 5 5 13 16 17 43 57 68 131 129 131 174 174 174 174 174 174
46418 +174 174 174 167 166 167 157 156 157 125 124 125 37 38 37 4 0 0
46419 +4 0 0 4 0 0 5 5 5 5 5 5 4 4 4 4 4 4
46420 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46421 +4 4 4 4 4 4
46422 +1 1 1 4 0 0 41 54 63 153 152 153 137 136 137 137 136 137
46423 +137 136 137 153 152 153 125 124 125 24 26 27 4 0 0 3 2 2
46424 +4 4 4 4 4 4 4 3 3 4 0 0 3 6 7 43 61 72
46425 +64 123 161 101 161 196 90 154 193 90 154 193 90 154 193 90 154 193
46426 +90 154 193 90 154 193 90 154 193 90 154 193 101 161 196 90 154 193
46427 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
46428 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
46429 +136 185 209 101 161 196 101 161 196 136 185 209 136 185 209 101 161 196
46430 +101 161 196 90 154 193 28 67 93 13 16 17 7 11 13 3 6 7
46431 +37 51 59 125 124 125 163 162 163 174 174 174 167 166 167 166 165 166
46432 +167 166 167 131 129 131 60 73 81 4 0 0 4 0 0 4 0 0
46433 +3 3 3 5 5 5 6 6 6 4 4 4 4 4 4 4 4 4
46434 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46435 +4 4 4 4 4 4
46436 +4 0 0 4 0 0 41 54 63 137 136 137 153 152 153 137 136 137
46437 +153 152 153 157 156 157 125 124 125 24 26 27 0 0 0 2 2 2
46438 +4 4 4 4 4 4 2 0 0 0 0 0 28 67 93 90 154 193
46439 +90 154 193 90 154 193 90 154 193 90 154 193 64 123 161 90 154 193
46440 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 101 161 196
46441 +90 154 193 101 161 196 101 161 196 101 161 196 90 154 193 136 185 209
46442 +101 161 196 101 161 196 136 185 209 101 161 196 136 185 209 101 161 196
46443 +101 161 196 101 161 196 136 185 209 101 161 196 101 161 196 90 154 193
46444 +35 83 115 13 16 17 3 6 7 2 5 5 13 16 17 60 74 84
46445 +154 154 154 166 165 166 165 164 165 158 157 158 163 162 163 157 156 157
46446 +60 74 84 13 16 17 4 0 0 4 0 0 3 2 2 4 4 4
46447 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46448 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46449 +4 4 4 4 4 4
46450 +1 1 1 4 0 0 41 54 63 157 156 157 155 154 155 137 136 137
46451 +153 152 153 158 157 158 137 136 137 26 28 28 2 0 0 2 2 2
46452 +4 4 4 4 4 4 1 0 0 6 10 14 34 86 122 90 154 193
46453 +64 123 161 90 154 193 64 123 161 90 154 193 90 154 193 90 154 193
46454 +64 123 161 90 154 193 90 154 193 90 154 193 90 154 193 90 154 193
46455 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
46456 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
46457 +136 185 209 101 161 196 136 185 209 90 154 193 26 108 161 22 40 52
46458 +13 16 17 5 7 8 2 5 5 2 5 5 37 38 37 165 164 165
46459 +174 174 174 163 162 163 154 154 154 165 164 165 167 166 167 60 73 81
46460 +6 6 6 4 0 0 4 0 0 4 4 4 4 4 4 4 4 4
46461 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46462 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46463 +4 4 4 4 4 4
46464 +4 0 0 6 6 6 41 54 63 156 155 156 158 157 158 153 152 153
46465 +156 155 156 165 164 165 137 136 137 26 28 28 0 0 0 2 2 2
46466 +4 4 5 4 4 4 2 0 0 7 12 15 31 96 139 64 123 161
46467 +90 154 193 64 123 161 90 154 193 90 154 193 64 123 161 90 154 193
46468 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 90 154 193
46469 +90 154 193 90 154 193 90 154 193 101 161 196 101 161 196 101 161 196
46470 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 136 185 209
46471 +101 161 196 136 185 209 26 108 161 22 40 52 7 11 13 5 7 8
46472 +2 5 5 2 5 5 2 5 5 2 2 1 37 38 37 158 157 158
46473 +174 174 174 154 154 154 156 155 156 167 166 167 165 164 165 37 38 37
46474 +4 0 0 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
46475 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46476 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46477 +4 4 4 4 4 4
46478 +3 1 0 4 0 0 60 73 81 157 156 157 163 162 163 153 152 153
46479 +158 157 158 167 166 167 137 136 137 26 28 28 2 0 0 2 2 2
46480 +4 5 5 4 4 4 4 0 0 7 12 15 24 86 132 26 108 161
46481 +37 112 160 64 123 161 90 154 193 64 123 161 90 154 193 90 154 193
46482 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 90 154 193
46483 +90 154 193 101 161 196 90 154 193 101 161 196 101 161 196 101 161 196
46484 +101 161 196 101 161 196 101 161 196 136 185 209 101 161 196 136 185 209
46485 +90 154 193 35 83 115 13 16 17 13 16 17 7 11 13 3 6 7
46486 +5 7 8 6 6 6 3 4 3 2 2 1 30 32 34 154 154 154
46487 +167 166 167 154 154 154 154 154 154 174 174 174 165 164 165 37 38 37
46488 +6 6 6 4 0 0 6 6 6 4 4 4 4 4 4 4 4 4
46489 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46490 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46491 +4 4 4 4 4 4
46492 +4 0 0 4 0 0 41 54 63 163 162 163 166 165 166 154 154 154
46493 +163 162 163 174 174 174 137 136 137 26 28 28 0 0 0 2 2 2
46494 +4 5 5 4 4 5 1 1 2 6 10 14 28 67 93 18 97 151
46495 +18 97 151 18 97 151 26 108 161 37 112 160 37 112 160 90 154 193
46496 +64 123 161 90 154 193 90 154 193 90 154 193 90 154 193 101 161 196
46497 +90 154 193 101 161 196 101 161 196 90 154 193 101 161 196 101 161 196
46498 +101 161 196 101 161 196 101 161 196 136 185 209 90 154 193 16 89 141
46499 +13 20 25 7 11 13 5 7 8 5 7 8 2 5 5 4 5 5
46500 +3 4 3 4 5 5 3 4 3 0 0 0 37 38 37 158 157 158
46501 +174 174 174 158 157 158 158 157 158 167 166 167 174 174 174 41 54 63
46502 +4 0 0 3 2 2 5 5 5 4 4 4 4 4 4 4 4 4
46503 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46504 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46505 +4 4 4 4 4 4
46506 +1 1 1 4 0 0 60 73 81 165 164 165 174 174 174 158 157 158
46507 +167 166 167 174 174 174 153 152 153 26 28 28 2 0 0 2 2 2
46508 +4 5 5 4 4 4 4 0 0 7 12 15 10 87 144 10 87 144
46509 +18 97 151 18 97 151 18 97 151 26 108 161 26 108 161 26 108 161
46510 +26 108 161 37 112 160 53 118 160 90 154 193 90 154 193 90 154 193
46511 +90 154 193 90 154 193 101 161 196 101 161 196 101 161 196 101 161 196
46512 +101 161 196 136 185 209 90 154 193 26 108 161 22 40 52 13 16 17
46513 +7 11 13 3 6 7 5 7 8 5 7 8 2 5 5 4 5 5
46514 +4 5 5 6 6 6 3 4 3 0 0 0 30 32 34 158 157 158
46515 +174 174 174 156 155 156 155 154 155 165 164 165 154 153 154 37 38 37
46516 +4 0 0 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
46517 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46518 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46519 +4 4 4 4 4 4
46520 +4 0 0 4 0 0 60 73 81 167 166 167 174 174 174 163 162 163
46521 +174 174 174 174 174 174 153 152 153 26 28 28 0 0 0 3 3 3
46522 +5 5 5 4 4 4 1 1 2 7 12 15 28 67 93 18 97 151
46523 +18 97 151 18 97 151 18 97 151 18 97 151 18 97 151 26 108 161
46524 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
46525 +90 154 193 26 108 161 90 154 193 90 154 193 90 154 193 101 161 196
46526 +101 161 196 26 108 161 22 40 52 13 16 17 7 11 13 2 5 5
46527 +2 5 5 6 6 6 2 5 5 4 5 5 4 5 5 4 5 5
46528 +3 4 3 5 5 5 3 4 3 2 0 0 30 32 34 137 136 137
46529 +153 152 153 137 136 137 131 129 131 137 136 137 131 129 131 37 38 37
46530 +4 0 0 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
46531 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46532 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46533 +4 4 4 4 4 4
46534 +1 1 1 4 0 0 60 73 81 167 166 167 174 174 174 166 165 166
46535 +174 174 174 177 184 187 153 152 153 30 32 34 1 0 0 3 3 3
46536 +5 5 5 4 3 3 4 0 0 7 12 15 10 87 144 10 87 144
46537 +18 97 151 18 97 151 18 97 151 26 108 161 26 108 161 26 108 161
46538 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
46539 +26 108 161 26 108 161 26 108 161 90 154 193 90 154 193 26 108 161
46540 +35 83 115 13 16 17 7 11 13 5 7 8 3 6 7 5 7 8
46541 +2 5 5 6 6 6 4 5 5 4 5 5 3 4 3 4 5 5
46542 +3 4 3 6 6 6 3 4 3 0 0 0 26 28 28 125 124 125
46543 +131 129 131 125 124 125 125 124 125 131 129 131 131 129 131 37 38 37
46544 +4 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
46545 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46546 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46547 +4 4 4 4 4 4
46548 +3 1 0 4 0 0 60 73 81 174 174 174 177 184 187 167 166 167
46549 +174 174 174 177 184 187 153 152 153 30 32 34 0 0 0 3 3 3
46550 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 18 97 151
46551 +18 97 151 18 97 151 18 97 151 18 97 151 18 97 151 26 108 161
46552 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
46553 +26 108 161 90 154 193 26 108 161 26 108 161 24 86 132 13 20 25
46554 +7 11 13 13 20 25 22 40 52 5 7 8 3 4 3 3 4 3
46555 +4 5 5 3 4 3 4 5 5 3 4 3 4 5 5 3 4 3
46556 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 125 124 125
46557 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
46558 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
46559 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46560 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46561 +4 4 4 4 4 4
46562 +1 1 1 4 0 0 60 73 81 174 174 174 177 184 187 174 174 174
46563 +174 174 174 190 197 201 157 156 157 30 32 34 1 0 0 3 3 3
46564 +5 5 5 4 3 3 4 0 0 7 12 15 10 87 144 10 87 144
46565 +18 97 151 19 95 150 19 95 150 18 97 151 18 97 151 26 108 161
46566 +18 97 151 26 108 161 26 108 161 26 108 161 26 108 161 90 154 193
46567 +26 108 161 26 108 161 26 108 161 22 40 52 2 5 5 3 4 3
46568 +28 67 93 37 112 160 34 86 122 2 5 5 3 4 3 3 4 3
46569 +3 4 3 3 4 3 3 4 3 2 2 1 3 4 3 4 4 4
46570 +4 5 5 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
46571 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
46572 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
46573 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46574 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46575 +4 4 4 4 4 4
46576 +4 0 0 4 0 0 60 73 81 174 174 174 177 184 187 174 174 174
46577 +174 174 174 190 197 201 158 157 158 30 32 34 0 0 0 2 2 2
46578 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 18 97 151
46579 +10 87 144 19 95 150 19 95 150 18 97 151 18 97 151 18 97 151
46580 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
46581 +18 97 151 22 40 52 2 5 5 2 2 1 22 40 52 26 108 161
46582 +90 154 193 37 112 160 22 40 52 3 4 3 13 20 25 22 30 35
46583 +3 6 7 1 1 1 2 2 2 6 9 11 5 5 5 4 3 3
46584 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 131 129 131
46585 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
46586 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
46587 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46588 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46589 +4 4 4 4 4 4
46590 +1 1 1 4 0 0 60 73 81 177 184 187 193 200 203 174 174 174
46591 +177 184 187 193 200 203 163 162 163 30 32 34 4 0 0 2 2 2
46592 +5 5 5 4 3 3 4 0 0 6 10 14 24 86 132 10 87 144
46593 +10 87 144 10 87 144 19 95 150 19 95 150 19 95 150 18 97 151
46594 +26 108 161 26 108 161 26 108 161 90 154 193 26 108 161 28 67 93
46595 +6 10 14 2 5 5 13 20 25 24 86 132 37 112 160 90 154 193
46596 +10 87 144 7 12 15 2 5 5 28 67 93 37 112 160 28 67 93
46597 +2 2 1 7 12 15 35 83 115 28 67 93 3 6 7 1 0 0
46598 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
46599 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
46600 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
46601 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46602 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46603 +4 4 4 4 4 4
46604 +4 0 0 4 0 0 60 73 81 174 174 174 190 197 201 174 174 174
46605 +177 184 187 193 200 203 163 162 163 30 32 34 0 0 0 2 2 2
46606 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 10 87 144
46607 +10 87 144 16 89 141 19 95 150 10 87 144 26 108 161 26 108 161
46608 +26 108 161 26 108 161 26 108 161 28 67 93 6 10 14 1 1 2
46609 +7 12 15 28 67 93 26 108 161 16 89 141 24 86 132 21 29 34
46610 +3 4 3 21 29 34 37 112 160 37 112 160 27 99 146 21 29 34
46611 +21 29 34 26 108 161 90 154 193 35 83 115 1 1 2 2 0 0
46612 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 125 124 125
46613 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
46614 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
46615 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46616 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46617 +4 4 4 4 4 4
46618 +3 1 0 4 0 0 60 73 81 193 200 203 193 200 203 174 174 174
46619 +190 197 201 193 200 203 165 164 165 37 38 37 4 0 0 2 2 2
46620 +5 5 5 4 3 3 4 0 0 6 10 14 24 86 132 10 87 144
46621 +10 87 144 10 87 144 16 89 141 18 97 151 18 97 151 10 87 144
46622 +24 86 132 24 86 132 13 20 25 4 5 7 4 5 7 22 40 52
46623 +18 97 151 37 112 160 26 108 161 7 12 15 1 1 1 0 0 0
46624 +28 67 93 37 112 160 26 108 161 28 67 93 22 40 52 28 67 93
46625 +26 108 161 90 154 193 26 108 161 10 87 144 0 0 0 2 0 0
46626 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
46627 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
46628 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
46629 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46630 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46631 +4 4 4 4 4 4
46632 +4 0 0 6 6 6 60 73 81 174 174 174 193 200 203 174 174 174
46633 +190 197 201 193 200 203 165 164 165 30 32 34 0 0 0 2 2 2
46634 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 10 87 144
46635 +10 87 144 10 87 144 10 87 144 18 97 151 28 67 93 6 10 14
46636 +0 0 0 1 1 2 4 5 7 13 20 25 16 89 141 26 108 161
46637 +26 108 161 26 108 161 24 86 132 6 9 11 2 3 3 22 40 52
46638 +37 112 160 16 89 141 22 40 52 28 67 93 26 108 161 26 108 161
46639 +90 154 193 26 108 161 26 108 161 28 67 93 1 1 1 4 0 0
46640 +4 4 4 5 5 5 3 3 3 4 0 0 26 28 28 124 126 130
46641 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
46642 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
46643 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46644 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46645 +4 4 4 4 4 4
46646 +4 0 0 4 0 0 60 73 81 193 200 203 193 200 203 174 174 174
46647 +193 200 203 193 200 203 167 166 167 37 38 37 4 0 0 2 2 2
46648 +5 5 5 4 4 4 4 0 0 6 10 14 28 67 93 10 87 144
46649 +10 87 144 10 87 144 18 97 151 10 87 144 13 20 25 4 5 7
46650 +1 1 2 1 1 1 22 40 52 26 108 161 26 108 161 26 108 161
46651 +26 108 161 26 108 161 26 108 161 24 86 132 22 40 52 22 40 52
46652 +22 40 52 22 40 52 10 87 144 26 108 161 26 108 161 26 108 161
46653 +26 108 161 26 108 161 90 154 193 10 87 144 0 0 0 4 0 0
46654 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
46655 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
46656 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
46657 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46658 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46659 +4 4 4 4 4 4
46660 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
46661 +190 197 201 205 212 215 167 166 167 30 32 34 0 0 0 2 2 2
46662 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 10 87 144
46663 +10 87 144 10 87 144 10 87 144 10 87 144 22 40 52 1 1 2
46664 +2 0 0 1 1 2 24 86 132 26 108 161 26 108 161 26 108 161
46665 +26 108 161 19 95 150 16 89 141 10 87 144 22 40 52 22 40 52
46666 +10 87 144 26 108 161 37 112 160 26 108 161 26 108 161 26 108 161
46667 +26 108 161 26 108 161 26 108 161 28 67 93 2 0 0 3 1 0
46668 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 131 129 131
46669 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
46670 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
46671 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46672 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46673 +4 4 4 4 4 4
46674 +4 0 0 4 0 0 60 73 81 220 221 221 190 197 201 174 174 174
46675 +193 200 203 193 200 203 174 174 174 37 38 37 4 0 0 2 2 2
46676 +5 5 5 4 4 4 3 2 2 1 1 2 13 20 25 10 87 144
46677 +10 87 144 10 87 144 10 87 144 10 87 144 10 87 144 13 20 25
46678 +13 20 25 22 40 52 10 87 144 18 97 151 18 97 151 26 108 161
46679 +10 87 144 13 20 25 6 10 14 21 29 34 24 86 132 18 97 151
46680 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
46681 +26 108 161 90 154 193 18 97 151 13 20 25 0 0 0 4 3 3
46682 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
46683 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
46684 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
46685 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46686 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46687 +4 4 4 4 4 4
46688 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
46689 +190 197 201 220 221 221 167 166 167 30 32 34 1 0 0 2 2 2
46690 +5 5 5 4 4 4 4 4 5 2 5 5 4 5 7 13 20 25
46691 +28 67 93 10 87 144 10 87 144 10 87 144 10 87 144 10 87 144
46692 +10 87 144 10 87 144 18 97 151 10 87 144 18 97 151 18 97 151
46693 +28 67 93 2 3 3 0 0 0 28 67 93 26 108 161 26 108 161
46694 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
46695 +26 108 161 10 87 144 13 20 25 1 1 2 3 2 2 4 4 4
46696 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 131 129 131
46697 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
46698 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
46699 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46700 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46701 +4 4 4 4 4 4
46702 +4 0 0 4 0 0 60 73 81 220 221 221 190 197 201 174 174 174
46703 +193 200 203 193 200 203 174 174 174 26 28 28 4 0 0 4 3 3
46704 +5 5 5 4 4 4 4 4 4 4 4 5 1 1 2 2 5 5
46705 +4 5 7 22 40 52 10 87 144 10 87 144 18 97 151 10 87 144
46706 +10 87 144 10 87 144 10 87 144 10 87 144 10 87 144 18 97 151
46707 +10 87 144 28 67 93 22 40 52 10 87 144 26 108 161 18 97 151
46708 +18 97 151 18 97 151 26 108 161 26 108 161 26 108 161 26 108 161
46709 +22 40 52 1 1 2 0 0 0 2 3 3 4 4 4 4 4 4
46710 +4 4 4 5 5 5 4 4 4 0 0 0 26 28 28 131 129 131
46711 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
46712 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
46713 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46714 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46715 +4 4 4 4 4 4
46716 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
46717 +190 197 201 220 221 221 190 197 201 41 54 63 4 0 0 2 2 2
46718 +6 6 6 4 4 4 4 4 4 4 4 5 4 4 5 3 3 3
46719 +1 1 2 1 1 2 6 10 14 22 40 52 10 87 144 18 97 151
46720 +18 97 151 10 87 144 10 87 144 10 87 144 18 97 151 10 87 144
46721 +10 87 144 18 97 151 26 108 161 18 97 151 18 97 151 10 87 144
46722 +26 108 161 26 108 161 26 108 161 10 87 144 28 67 93 6 10 14
46723 +1 1 2 1 1 2 4 3 3 4 4 5 4 4 4 4 4 4
46724 +5 5 5 5 5 5 1 1 1 4 0 0 37 51 59 137 136 137
46725 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
46726 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
46727 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46728 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46729 +4 4 4 4 4 4
46730 +4 0 0 4 0 0 60 73 81 220 221 221 193 200 203 174 174 174
46731 +193 200 203 193 200 203 220 221 221 137 136 137 13 16 17 4 0 0
46732 +2 2 2 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5
46733 +4 4 5 4 3 3 1 1 2 4 5 7 13 20 25 28 67 93
46734 +10 87 144 10 87 144 10 87 144 10 87 144 10 87 144 10 87 144
46735 +10 87 144 18 97 151 18 97 151 10 87 144 18 97 151 26 108 161
46736 +26 108 161 18 97 151 28 67 93 6 10 14 0 0 0 0 0 0
46737 +2 3 3 4 5 5 4 4 5 4 4 4 4 4 4 5 5 5
46738 +3 3 3 1 1 1 0 0 0 16 19 21 125 124 125 137 136 137
46739 +131 129 131 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
46740 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
46741 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46742 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46743 +4 4 4 4 4 4
46744 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
46745 +193 200 203 190 197 201 220 221 221 220 221 221 153 152 153 30 32 34
46746 +0 0 0 0 0 0 2 2 2 4 4 4 4 4 4 4 4 4
46747 +4 4 4 4 5 5 4 5 7 1 1 2 1 1 2 4 5 7
46748 +13 20 25 28 67 93 10 87 144 18 97 151 10 87 144 10 87 144
46749 +10 87 144 10 87 144 10 87 144 18 97 151 26 108 161 18 97 151
46750 +28 67 93 7 12 15 0 0 0 0 0 0 2 2 1 4 4 4
46751 +4 5 5 4 5 5 4 4 4 4 4 4 3 3 3 0 0 0
46752 +0 0 0 0 0 0 37 38 37 125 124 125 158 157 158 131 129 131
46753 +125 124 125 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
46754 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
46755 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46756 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46757 +4 4 4 4 4 4
46758 +4 3 3 4 0 0 41 54 63 193 200 203 220 221 221 174 174 174
46759 +193 200 203 193 200 203 193 200 203 220 221 221 244 246 246 193 200 203
46760 +120 125 127 5 5 5 1 0 0 0 0 0 1 1 1 4 4 4
46761 +4 4 4 4 4 4 4 5 5 4 5 5 4 4 5 1 1 2
46762 +4 5 7 4 5 7 22 40 52 10 87 144 10 87 144 10 87 144
46763 +10 87 144 10 87 144 18 97 151 10 87 144 10 87 144 13 20 25
46764 +4 5 7 2 3 3 1 1 2 4 4 4 4 5 5 4 4 4
46765 +4 4 4 4 4 4 4 4 4 1 1 1 0 0 0 1 1 2
46766 +24 26 27 60 74 84 153 152 153 163 162 163 137 136 137 125 124 125
46767 +125 124 125 125 124 125 125 124 125 137 136 137 125 124 125 26 28 28
46768 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
46769 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46770 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46771 +4 4 4 4 4 4
46772 +4 0 0 6 6 6 26 28 28 156 155 156 220 221 221 220 221 221
46773 +174 174 174 193 200 203 193 200 203 193 200 203 205 212 215 220 221 221
46774 +220 221 221 167 166 167 60 73 81 7 11 13 0 0 0 0 0 0
46775 +3 3 3 4 4 4 4 4 4 4 4 4 4 4 5 4 4 5
46776 +4 4 5 1 1 2 1 1 2 4 5 7 22 40 52 10 87 144
46777 +10 87 144 10 87 144 10 87 144 22 40 52 4 5 7 1 1 2
46778 +1 1 2 4 4 5 4 4 4 4 4 4 4 4 4 4 4 4
46779 +5 5 5 2 2 2 0 0 0 4 0 0 16 19 21 60 73 81
46780 +137 136 137 167 166 167 158 157 158 137 136 137 131 129 131 131 129 131
46781 +125 124 125 125 124 125 131 129 131 155 154 155 60 74 84 5 7 8
46782 +0 0 0 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46783 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46784 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46785 +4 4 4 4 4 4
46786 +5 5 5 4 0 0 4 0 0 60 73 81 193 200 203 220 221 221
46787 +193 200 203 193 200 203 193 200 203 193 200 203 205 212 215 220 221 221
46788 +220 221 221 220 221 221 220 221 221 137 136 137 43 57 68 6 6 6
46789 +4 0 0 1 1 1 4 4 4 4 4 4 4 4 4 4 4 4
46790 +4 4 5 4 4 5 3 2 2 1 1 2 2 5 5 13 20 25
46791 +22 40 52 22 40 52 13 20 25 2 3 3 1 1 2 3 3 3
46792 +4 5 7 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46793 +1 1 1 0 0 0 2 3 3 41 54 63 131 129 131 166 165 166
46794 +166 165 166 155 154 155 153 152 153 137 136 137 137 136 137 125 124 125
46795 +125 124 125 137 136 137 137 136 137 125 124 125 37 38 37 4 3 3
46796 +4 3 3 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
46797 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46798 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46799 +4 4 4 4 4 4
46800 +4 3 3 6 6 6 6 6 6 13 16 17 60 73 81 167 166 167
46801 +220 221 221 220 221 221 220 221 221 193 200 203 193 200 203 193 200 203
46802 +205 212 215 220 221 221 220 221 221 244 246 246 205 212 215 125 124 125
46803 +24 26 27 0 0 0 0 0 0 2 2 2 5 5 5 5 5 5
46804 +4 4 4 4 4 4 4 4 4 4 4 5 1 1 2 4 5 7
46805 +4 5 7 4 5 7 1 1 2 3 2 2 4 4 5 4 4 4
46806 +4 4 4 4 4 4 5 5 5 4 4 4 0 0 0 0 0 0
46807 +2 0 0 26 28 28 125 124 125 174 174 174 174 174 174 166 165 166
46808 +156 155 156 153 152 153 137 136 137 137 136 137 131 129 131 137 136 137
46809 +137 136 137 137 136 137 60 74 84 30 32 34 4 0 0 4 0 0
46810 +5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46811 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46812 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46813 +4 4 4 4 4 4
46814 +5 5 5 6 6 6 4 0 0 4 0 0 6 6 6 26 28 28
46815 +125 124 125 174 174 174 220 221 221 220 221 221 220 221 221 193 200 203
46816 +205 212 215 220 221 221 205 212 215 220 221 221 220 221 221 244 246 246
46817 +193 200 203 60 74 84 13 16 17 4 0 0 0 0 0 3 3 3
46818 +5 5 5 5 5 5 4 4 4 4 4 4 4 4 5 3 3 3
46819 +1 1 2 3 3 3 4 4 5 4 4 5 4 4 4 4 4 4
46820 +5 5 5 5 5 5 2 2 2 0 0 0 0 0 0 13 16 17
46821 +60 74 84 174 174 174 193 200 203 174 174 174 167 166 167 163 162 163
46822 +153 152 153 153 152 153 137 136 137 137 136 137 153 152 153 137 136 137
46823 +125 124 125 41 54 63 24 26 27 4 0 0 4 0 0 5 5 5
46824 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46825 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46826 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46827 +4 4 4 4 4 4
46828 +4 3 3 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
46829 +6 6 6 37 38 37 131 129 131 220 221 221 220 221 221 220 221 221
46830 +193 200 203 193 200 203 220 221 221 205 212 215 220 221 221 244 246 246
46831 +244 246 246 244 246 246 174 174 174 41 54 63 0 0 0 0 0 0
46832 +0 0 0 4 4 4 5 5 5 5 5 5 4 4 4 4 4 5
46833 +4 4 5 4 4 5 4 4 4 4 4 4 6 6 6 6 6 6
46834 +3 3 3 0 0 0 2 0 0 13 16 17 60 73 81 156 155 156
46835 +220 221 221 193 200 203 174 174 174 165 164 165 163 162 163 154 153 154
46836 +153 152 153 153 152 153 158 157 158 163 162 163 137 136 137 60 73 81
46837 +13 16 17 4 0 0 4 0 0 4 3 3 4 4 4 4 4 4
46838 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46839 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46840 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46841 +4 4 4 4 4 4
46842 +5 5 5 4 3 3 4 3 3 6 6 6 6 6 6 6 6 6
46843 +6 6 6 6 6 6 6 6 6 37 38 37 167 166 167 244 246 246
46844 +244 246 246 220 221 221 205 212 215 205 212 215 220 221 221 193 200 203
46845 +220 221 221 244 246 246 244 246 246 244 246 246 137 136 137 37 38 37
46846 +3 2 2 0 0 0 1 1 1 5 5 5 5 5 5 4 4 4
46847 +4 4 4 4 4 4 4 4 4 5 5 5 4 4 4 1 1 1
46848 +0 0 0 5 5 5 43 57 68 153 152 153 193 200 203 220 221 221
46849 +177 184 187 174 174 174 167 166 167 166 165 166 158 157 158 157 156 157
46850 +158 157 158 166 165 166 156 155 156 85 115 134 13 16 17 4 0 0
46851 +4 0 0 4 0 0 5 5 5 5 5 5 4 4 4 4 4 4
46852 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46853 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46854 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46855 +4 4 4 4 4 4
46856 +5 5 5 4 3 3 6 6 6 6 6 6 4 0 0 6 6 6
46857 +6 6 6 6 6 6 6 6 6 6 6 6 13 16 17 60 73 81
46858 +177 184 187 220 221 221 220 221 221 220 221 221 205 212 215 220 221 221
46859 +220 221 221 205 212 215 220 221 221 244 246 246 244 246 246 205 212 215
46860 +125 124 125 30 32 34 0 0 0 0 0 0 2 2 2 5 5 5
46861 +4 4 4 4 4 4 4 4 4 1 1 1 0 0 0 1 0 0
46862 +37 38 37 131 129 131 205 212 215 220 221 221 193 200 203 174 174 174
46863 +174 174 174 174 174 174 167 166 167 165 164 165 166 165 166 167 166 167
46864 +158 157 158 125 124 125 37 38 37 4 0 0 4 0 0 4 0 0
46865 +4 3 3 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
46866 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46867 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46868 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46869 +4 4 4 4 4 4
46870 +4 4 4 5 5 5 4 3 3 4 3 3 6 6 6 6 6 6
46871 +4 0 0 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
46872 +26 28 28 125 124 125 205 212 215 220 221 221 220 221 221 220 221 221
46873 +205 212 215 220 221 221 205 212 215 220 221 221 220 221 221 244 246 246
46874 +244 246 246 190 197 201 60 74 84 16 19 21 4 0 0 0 0 0
46875 +0 0 0 0 0 0 0 0 0 0 0 0 16 19 21 120 125 127
46876 +177 184 187 220 221 221 205 212 215 177 184 187 174 174 174 177 184 187
46877 +174 174 174 174 174 174 167 166 167 174 174 174 166 165 166 137 136 137
46878 +60 73 81 13 16 17 4 0 0 4 0 0 4 3 3 6 6 6
46879 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46880 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46881 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46882 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46883 +4 4 4 4 4 4
46884 +5 5 5 4 3 3 5 5 5 4 3 3 6 6 6 4 0 0
46885 +6 6 6 6 6 6 4 0 0 6 6 6 4 0 0 6 6 6
46886 +6 6 6 6 6 6 37 38 37 137 136 137 193 200 203 220 221 221
46887 +220 221 221 205 212 215 220 221 221 205 212 215 205 212 215 220 221 221
46888 +220 221 221 220 221 221 244 246 246 166 165 166 43 57 68 2 2 2
46889 +0 0 0 4 0 0 16 19 21 60 73 81 157 156 157 202 210 214
46890 +220 221 221 193 200 203 177 184 187 177 184 187 177 184 187 174 174 174
46891 +174 174 174 174 174 174 174 174 174 157 156 157 60 74 84 24 26 27
46892 +4 0 0 4 0 0 4 0 0 6 6 6 4 4 4 4 4 4
46893 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46894 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46895 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46896 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46897 +4 4 4 4 4 4
46898 +4 4 4 4 4 4 5 5 5 4 3 3 5 5 5 6 6 6
46899 +6 6 6 4 0 0 6 6 6 6 6 6 6 6 6 4 0 0
46900 +4 0 0 4 0 0 6 6 6 24 26 27 60 73 81 167 166 167
46901 +220 221 221 220 221 221 220 221 221 205 212 215 205 212 215 205 212 215
46902 +205 212 215 220 221 221 220 221 221 220 221 221 205 212 215 137 136 137
46903 +60 74 84 125 124 125 137 136 137 190 197 201 220 221 221 193 200 203
46904 +177 184 187 177 184 187 177 184 187 174 174 174 174 174 174 177 184 187
46905 +190 197 201 174 174 174 125 124 125 37 38 37 6 6 6 4 0 0
46906 +4 0 0 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46907 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46908 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46909 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46910 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46911 +4 4 4 4 4 4
46912 +4 4 4 4 4 4 5 5 5 5 5 5 4 3 3 6 6 6
46913 +4 0 0 6 6 6 6 6 6 6 6 6 4 0 0 6 6 6
46914 +6 6 6 6 6 6 4 0 0 4 0 0 6 6 6 6 6 6
46915 +125 124 125 193 200 203 244 246 246 220 221 221 205 212 215 205 212 215
46916 +205 212 215 193 200 203 205 212 215 205 212 215 220 221 221 220 221 221
46917 +193 200 203 193 200 203 205 212 215 193 200 203 193 200 203 177 184 187
46918 +190 197 201 190 197 201 174 174 174 190 197 201 193 200 203 190 197 201
46919 +153 152 153 60 73 81 4 0 0 4 0 0 4 0 0 3 2 2
46920 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46921 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46922 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46923 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46924 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46925 +4 4 4 4 4 4
46926 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 4 3 3
46927 +6 6 6 4 3 3 4 3 3 4 3 3 6 6 6 6 6 6
46928 +4 0 0 6 6 6 6 6 6 6 6 6 4 0 0 4 0 0
46929 +4 0 0 26 28 28 131 129 131 220 221 221 244 246 246 220 221 221
46930 +205 212 215 193 200 203 205 212 215 193 200 203 193 200 203 205 212 215
46931 +220 221 221 193 200 203 193 200 203 193 200 203 190 197 201 174 174 174
46932 +174 174 174 190 197 201 193 200 203 193 200 203 167 166 167 125 124 125
46933 +6 6 6 4 0 0 4 0 0 4 3 3 4 4 4 4 4 4
46934 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46935 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46936 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46937 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46938 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46939 +4 4 4 4 4 4
46940 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
46941 +5 5 5 4 3 3 5 5 5 6 6 6 4 3 3 5 5 5
46942 +6 6 6 6 6 6 4 0 0 6 6 6 6 6 6 6 6 6
46943 +4 0 0 4 0 0 6 6 6 41 54 63 158 157 158 220 221 221
46944 +220 221 221 220 221 221 193 200 203 193 200 203 193 200 203 190 197 201
46945 +190 197 201 190 197 201 190 197 201 190 197 201 174 174 174 193 200 203
46946 +193 200 203 220 221 221 174 174 174 125 124 125 37 38 37 4 0 0
46947 +4 0 0 4 3 3 6 6 6 4 4 4 4 4 4 4 4 4
46948 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46949 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46950 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46951 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46952 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46953 +4 4 4 4 4 4
46954 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46955 +4 4 4 5 5 5 4 3 3 4 3 3 4 3 3 5 5 5
46956 +4 3 3 6 6 6 5 5 5 4 3 3 6 6 6 6 6 6
46957 +6 6 6 6 6 6 4 0 0 4 0 0 13 16 17 60 73 81
46958 +174 174 174 220 221 221 220 221 221 205 212 215 190 197 201 174 174 174
46959 +193 200 203 174 174 174 190 197 201 174 174 174 193 200 203 220 221 221
46960 +193 200 203 131 129 131 37 38 37 6 6 6 4 0 0 4 0 0
46961 +6 6 6 6 6 6 4 3 3 5 5 5 4 4 4 4 4 4
46962 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46963 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46964 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46965 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46966 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46967 +4 4 4 4 4 4
46968 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46969 +4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 5 5 5
46970 +5 5 5 4 3 3 4 3 3 5 5 5 4 3 3 4 3 3
46971 +5 5 5 6 6 6 6 6 6 4 0 0 6 6 6 6 6 6
46972 +6 6 6 125 124 125 174 174 174 220 221 221 220 221 221 193 200 203
46973 +193 200 203 193 200 203 193 200 203 193 200 203 220 221 221 158 157 158
46974 +60 73 81 6 6 6 4 0 0 4 0 0 5 5 5 6 6 6
46975 +5 5 5 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
46976 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46977 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46978 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46979 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46980 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46981 +4 4 4 4 4 4
46982 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46983 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46984 +4 4 4 5 5 5 5 5 5 4 3 3 5 5 5 4 3 3
46985 +5 5 5 5 5 5 6 6 6 6 6 6 4 0 0 4 0 0
46986 +4 0 0 4 0 0 26 28 28 125 124 125 174 174 174 193 200 203
46987 +193 200 203 174 174 174 193 200 203 167 166 167 125 124 125 6 6 6
46988 +6 6 6 6 6 6 4 0 0 6 6 6 6 6 6 5 5 5
46989 +4 3 3 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
46990 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46991 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46992 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46993 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46994 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46995 +4 4 4 4 4 4
46996 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46997 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46998 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
46999 +4 3 3 6 6 6 4 0 0 6 6 6 6 6 6 6 6 6
47000 +6 6 6 4 0 0 4 0 0 6 6 6 37 38 37 125 124 125
47001 +153 152 153 131 129 131 125 124 125 37 38 37 6 6 6 6 6 6
47002 +6 6 6 4 0 0 6 6 6 6 6 6 4 3 3 5 5 5
47003 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47004 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47005 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47006 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47007 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47008 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47009 +4 4 4 4 4 4
47010 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47011 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47012 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47013 +4 4 4 5 5 5 5 5 5 4 3 3 5 5 5 4 3 3
47014 +6 6 6 6 6 6 4 0 0 4 0 0 6 6 6 6 6 6
47015 +24 26 27 24 26 27 6 6 6 6 6 6 6 6 6 4 0 0
47016 +6 6 6 6 6 6 4 0 0 6 6 6 5 5 5 4 3 3
47017 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47018 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47019 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47020 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47021 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47022 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47023 +4 4 4 4 4 4
47024 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47025 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47026 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47027 +4 4 4 4 4 4 5 5 5 4 3 3 5 5 5 6 6 6
47028 +4 0 0 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
47029 +6 6 6 6 6 6 6 6 6 4 0 0 6 6 6 6 6 6
47030 +4 0 0 6 6 6 6 6 6 4 3 3 5 5 5 4 4 4
47031 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47032 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47033 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47034 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47035 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47036 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47037 +4 4 4 4 4 4
47038 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47039 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47040 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47041 +4 4 4 4 4 4 4 4 4 5 5 5 4 3 3 5 5 5
47042 +5 5 5 5 5 5 4 0 0 6 6 6 4 0 0 6 6 6
47043 +6 6 6 6 6 6 6 6 6 4 0 0 6 6 6 4 0 0
47044 +6 6 6 4 3 3 5 5 5 4 3 3 5 5 5 4 4 4
47045 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47046 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47047 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47048 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47049 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47050 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47051 +4 4 4 4 4 4
47052 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47053 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47054 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47055 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
47056 +4 3 3 6 6 6 4 3 3 6 6 6 6 6 6 6 6 6
47057 +4 0 0 6 6 6 4 0 0 6 6 6 6 6 6 6 6 6
47058 +6 6 6 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47059 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47060 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47061 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47062 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47063 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47064 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47065 +4 4 4 4 4 4
47066 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47067 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47068 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47069 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47070 +4 4 4 5 5 5 4 3 3 5 5 5 4 0 0 6 6 6
47071 +6 6 6 4 0 0 6 6 6 6 6 6 4 0 0 6 6 6
47072 +4 3 3 5 5 5 5 5 5 4 4 4 4 4 4 4 4 4
47073 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47074 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47075 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47076 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47077 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47078 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47079 +4 4 4 4 4 4
47080 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47081 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47082 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47083 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47084 +4 4 4 5 5 5 4 3 3 5 5 5 6 6 6 4 3 3
47085 +4 3 3 6 6 6 6 6 6 4 3 3 6 6 6 4 3 3
47086 +5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47087 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47088 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47089 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47090 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47091 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47092 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47093 +4 4 4 4 4 4
47094 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47095 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47096 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47097 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47098 +4 4 4 4 4 4 4 4 4 5 5 5 4 3 3 6 6 6
47099 +5 5 5 4 3 3 4 3 3 4 3 3 5 5 5 5 5 5
47100 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47101 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47102 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47103 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47104 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47105 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47106 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47107 +4 4 4 4 4 4
47108 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47109 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47110 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47111 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47112 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 4 3 3
47113 +5 5 5 4 3 3 5 5 5 5 5 5 4 4 4 4 4 4
47114 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47115 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47116 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47117 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47118 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47119 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47120 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47121 +4 4 4 4 4 4
47122 diff --git a/drivers/video/mb862xx/mb862xxfb_accel.c b/drivers/video/mb862xx/mb862xxfb_accel.c
47123 index fe92eed..106e085 100644
47124 --- a/drivers/video/mb862xx/mb862xxfb_accel.c
47125 +++ b/drivers/video/mb862xx/mb862xxfb_accel.c
47126 @@ -312,14 +312,18 @@ void mb862xxfb_init_accel(struct fb_info *info, int xres)
47127 struct mb862xxfb_par *par = info->par;
47128
47129 if (info->var.bits_per_pixel == 32) {
47130 - info->fbops->fb_fillrect = cfb_fillrect;
47131 - info->fbops->fb_copyarea = cfb_copyarea;
47132 - info->fbops->fb_imageblit = cfb_imageblit;
47133 + pax_open_kernel();
47134 + *(void **)&info->fbops->fb_fillrect = cfb_fillrect;
47135 + *(void **)&info->fbops->fb_copyarea = cfb_copyarea;
47136 + *(void **)&info->fbops->fb_imageblit = cfb_imageblit;
47137 + pax_close_kernel();
47138 } else {
47139 outreg(disp, GC_L0EM, 3);
47140 - info->fbops->fb_fillrect = mb86290fb_fillrect;
47141 - info->fbops->fb_copyarea = mb86290fb_copyarea;
47142 - info->fbops->fb_imageblit = mb86290fb_imageblit;
47143 + pax_open_kernel();
47144 + *(void **)&info->fbops->fb_fillrect = mb86290fb_fillrect;
47145 + *(void **)&info->fbops->fb_copyarea = mb86290fb_copyarea;
47146 + *(void **)&info->fbops->fb_imageblit = mb86290fb_imageblit;
47147 + pax_close_kernel();
47148 }
47149 outreg(draw, GDC_REG_DRAW_BASE, 0);
47150 outreg(draw, GDC_REG_MODE_MISC, 0x8000);
47151 diff --git a/drivers/video/nvidia/nvidia.c b/drivers/video/nvidia/nvidia.c
47152 index ff22871..b129bed 100644
47153 --- a/drivers/video/nvidia/nvidia.c
47154 +++ b/drivers/video/nvidia/nvidia.c
47155 @@ -669,19 +669,23 @@ static int nvidiafb_set_par(struct fb_info *info)
47156 info->fix.line_length = (info->var.xres_virtual *
47157 info->var.bits_per_pixel) >> 3;
47158 if (info->var.accel_flags) {
47159 - info->fbops->fb_imageblit = nvidiafb_imageblit;
47160 - info->fbops->fb_fillrect = nvidiafb_fillrect;
47161 - info->fbops->fb_copyarea = nvidiafb_copyarea;
47162 - info->fbops->fb_sync = nvidiafb_sync;
47163 + pax_open_kernel();
47164 + *(void **)&info->fbops->fb_imageblit = nvidiafb_imageblit;
47165 + *(void **)&info->fbops->fb_fillrect = nvidiafb_fillrect;
47166 + *(void **)&info->fbops->fb_copyarea = nvidiafb_copyarea;
47167 + *(void **)&info->fbops->fb_sync = nvidiafb_sync;
47168 + pax_close_kernel();
47169 info->pixmap.scan_align = 4;
47170 info->flags &= ~FBINFO_HWACCEL_DISABLED;
47171 info->flags |= FBINFO_READS_FAST;
47172 NVResetGraphics(info);
47173 } else {
47174 - info->fbops->fb_imageblit = cfb_imageblit;
47175 - info->fbops->fb_fillrect = cfb_fillrect;
47176 - info->fbops->fb_copyarea = cfb_copyarea;
47177 - info->fbops->fb_sync = NULL;
47178 + pax_open_kernel();
47179 + *(void **)&info->fbops->fb_imageblit = cfb_imageblit;
47180 + *(void **)&info->fbops->fb_fillrect = cfb_fillrect;
47181 + *(void **)&info->fbops->fb_copyarea = cfb_copyarea;
47182 + *(void **)&info->fbops->fb_sync = NULL;
47183 + pax_close_kernel();
47184 info->pixmap.scan_align = 1;
47185 info->flags |= FBINFO_HWACCEL_DISABLED;
47186 info->flags &= ~FBINFO_READS_FAST;
47187 @@ -1173,8 +1177,11 @@ static int nvidia_set_fbinfo(struct fb_info *info)
47188 info->pixmap.size = 8 * 1024;
47189 info->pixmap.flags = FB_PIXMAP_SYSTEM;
47190
47191 - if (!hwcur)
47192 - info->fbops->fb_cursor = NULL;
47193 + if (!hwcur) {
47194 + pax_open_kernel();
47195 + *(void **)&info->fbops->fb_cursor = NULL;
47196 + pax_close_kernel();
47197 + }
47198
47199 info->var.accel_flags = (!noaccel);
47200
47201 diff --git a/drivers/video/s1d13xxxfb.c b/drivers/video/s1d13xxxfb.c
47202 index 76d9053..dec2bfd 100644
47203 --- a/drivers/video/s1d13xxxfb.c
47204 +++ b/drivers/video/s1d13xxxfb.c
47205 @@ -881,8 +881,10 @@ static int s1d13xxxfb_probe(struct platform_device *pdev)
47206
47207 switch(prod_id) {
47208 case S1D13506_PROD_ID: /* activate acceleration */
47209 - s1d13xxxfb_fbops.fb_fillrect = s1d13xxxfb_bitblt_solidfill;
47210 - s1d13xxxfb_fbops.fb_copyarea = s1d13xxxfb_bitblt_copyarea;
47211 + pax_open_kernel();
47212 + *(void **)&s1d13xxxfb_fbops.fb_fillrect = s1d13xxxfb_bitblt_solidfill;
47213 + *(void **)&s1d13xxxfb_fbops.fb_copyarea = s1d13xxxfb_bitblt_copyarea;
47214 + pax_close_kernel();
47215 info->flags = FBINFO_DEFAULT | FBINFO_HWACCEL_YPAN |
47216 FBINFO_HWACCEL_FILLRECT | FBINFO_HWACCEL_COPYAREA;
47217 break;
47218 diff --git a/drivers/video/smscufx.c b/drivers/video/smscufx.c
47219 index 97bd662..39fab85 100644
47220 --- a/drivers/video/smscufx.c
47221 +++ b/drivers/video/smscufx.c
47222 @@ -1171,7 +1171,9 @@ static int ufx_ops_release(struct fb_info *info, int user)
47223 fb_deferred_io_cleanup(info);
47224 kfree(info->fbdefio);
47225 info->fbdefio = NULL;
47226 - info->fbops->fb_mmap = ufx_ops_mmap;
47227 + pax_open_kernel();
47228 + *(void **)&info->fbops->fb_mmap = ufx_ops_mmap;
47229 + pax_close_kernel();
47230 }
47231
47232 pr_debug("released /dev/fb%d user=%d count=%d",
47233 diff --git a/drivers/video/udlfb.c b/drivers/video/udlfb.c
47234 index 86d449e..8e04dc5 100644
47235 --- a/drivers/video/udlfb.c
47236 +++ b/drivers/video/udlfb.c
47237 @@ -619,11 +619,11 @@ int dlfb_handle_damage(struct dlfb_data *dev, int x, int y,
47238 dlfb_urb_completion(urb);
47239
47240 error:
47241 - atomic_add(bytes_sent, &dev->bytes_sent);
47242 - atomic_add(bytes_identical, &dev->bytes_identical);
47243 - atomic_add(width*height*2, &dev->bytes_rendered);
47244 + atomic_add_unchecked(bytes_sent, &dev->bytes_sent);
47245 + atomic_add_unchecked(bytes_identical, &dev->bytes_identical);
47246 + atomic_add_unchecked(width*height*2, &dev->bytes_rendered);
47247 end_cycles = get_cycles();
47248 - atomic_add(((unsigned int) ((end_cycles - start_cycles)
47249 + atomic_add_unchecked(((unsigned int) ((end_cycles - start_cycles)
47250 >> 10)), /* Kcycles */
47251 &dev->cpu_kcycles_used);
47252
47253 @@ -744,11 +744,11 @@ static void dlfb_dpy_deferred_io(struct fb_info *info,
47254 dlfb_urb_completion(urb);
47255
47256 error:
47257 - atomic_add(bytes_sent, &dev->bytes_sent);
47258 - atomic_add(bytes_identical, &dev->bytes_identical);
47259 - atomic_add(bytes_rendered, &dev->bytes_rendered);
47260 + atomic_add_unchecked(bytes_sent, &dev->bytes_sent);
47261 + atomic_add_unchecked(bytes_identical, &dev->bytes_identical);
47262 + atomic_add_unchecked(bytes_rendered, &dev->bytes_rendered);
47263 end_cycles = get_cycles();
47264 - atomic_add(((unsigned int) ((end_cycles - start_cycles)
47265 + atomic_add_unchecked(((unsigned int) ((end_cycles - start_cycles)
47266 >> 10)), /* Kcycles */
47267 &dev->cpu_kcycles_used);
47268 }
47269 @@ -989,7 +989,9 @@ static int dlfb_ops_release(struct fb_info *info, int user)
47270 fb_deferred_io_cleanup(info);
47271 kfree(info->fbdefio);
47272 info->fbdefio = NULL;
47273 - info->fbops->fb_mmap = dlfb_ops_mmap;
47274 + pax_open_kernel();
47275 + *(void **)&info->fbops->fb_mmap = dlfb_ops_mmap;
47276 + pax_close_kernel();
47277 }
47278
47279 pr_warn("released /dev/fb%d user=%d count=%d\n",
47280 @@ -1372,7 +1374,7 @@ static ssize_t metrics_bytes_rendered_show(struct device *fbdev,
47281 struct fb_info *fb_info = dev_get_drvdata(fbdev);
47282 struct dlfb_data *dev = fb_info->par;
47283 return snprintf(buf, PAGE_SIZE, "%u\n",
47284 - atomic_read(&dev->bytes_rendered));
47285 + atomic_read_unchecked(&dev->bytes_rendered));
47286 }
47287
47288 static ssize_t metrics_bytes_identical_show(struct device *fbdev,
47289 @@ -1380,7 +1382,7 @@ static ssize_t metrics_bytes_identical_show(struct device *fbdev,
47290 struct fb_info *fb_info = dev_get_drvdata(fbdev);
47291 struct dlfb_data *dev = fb_info->par;
47292 return snprintf(buf, PAGE_SIZE, "%u\n",
47293 - atomic_read(&dev->bytes_identical));
47294 + atomic_read_unchecked(&dev->bytes_identical));
47295 }
47296
47297 static ssize_t metrics_bytes_sent_show(struct device *fbdev,
47298 @@ -1388,7 +1390,7 @@ static ssize_t metrics_bytes_sent_show(struct device *fbdev,
47299 struct fb_info *fb_info = dev_get_drvdata(fbdev);
47300 struct dlfb_data *dev = fb_info->par;
47301 return snprintf(buf, PAGE_SIZE, "%u\n",
47302 - atomic_read(&dev->bytes_sent));
47303 + atomic_read_unchecked(&dev->bytes_sent));
47304 }
47305
47306 static ssize_t metrics_cpu_kcycles_used_show(struct device *fbdev,
47307 @@ -1396,7 +1398,7 @@ static ssize_t metrics_cpu_kcycles_used_show(struct device *fbdev,
47308 struct fb_info *fb_info = dev_get_drvdata(fbdev);
47309 struct dlfb_data *dev = fb_info->par;
47310 return snprintf(buf, PAGE_SIZE, "%u\n",
47311 - atomic_read(&dev->cpu_kcycles_used));
47312 + atomic_read_unchecked(&dev->cpu_kcycles_used));
47313 }
47314
47315 static ssize_t edid_show(
47316 @@ -1456,10 +1458,10 @@ static ssize_t metrics_reset_store(struct device *fbdev,
47317 struct fb_info *fb_info = dev_get_drvdata(fbdev);
47318 struct dlfb_data *dev = fb_info->par;
47319
47320 - atomic_set(&dev->bytes_rendered, 0);
47321 - atomic_set(&dev->bytes_identical, 0);
47322 - atomic_set(&dev->bytes_sent, 0);
47323 - atomic_set(&dev->cpu_kcycles_used, 0);
47324 + atomic_set_unchecked(&dev->bytes_rendered, 0);
47325 + atomic_set_unchecked(&dev->bytes_identical, 0);
47326 + atomic_set_unchecked(&dev->bytes_sent, 0);
47327 + atomic_set_unchecked(&dev->cpu_kcycles_used, 0);
47328
47329 return count;
47330 }
47331 diff --git a/drivers/video/uvesafb.c b/drivers/video/uvesafb.c
47332 index b75db01..ad2f34a 100644
47333 --- a/drivers/video/uvesafb.c
47334 +++ b/drivers/video/uvesafb.c
47335 @@ -19,6 +19,7 @@
47336 #include <linux/io.h>
47337 #include <linux/mutex.h>
47338 #include <linux/slab.h>
47339 +#include <linux/moduleloader.h>
47340 #include <video/edid.h>
47341 #include <video/uvesafb.h>
47342 #ifdef CONFIG_X86
47343 @@ -569,10 +570,32 @@ static int uvesafb_vbe_getpmi(struct uvesafb_ktask *task,
47344 if ((task->t.regs.eax & 0xffff) != 0x4f || task->t.regs.es < 0xc000) {
47345 par->pmi_setpal = par->ypan = 0;
47346 } else {
47347 +
47348 +#ifdef CONFIG_PAX_KERNEXEC
47349 +#ifdef CONFIG_MODULES
47350 + par->pmi_code = module_alloc_exec((u16)task->t.regs.ecx);
47351 +#endif
47352 + if (!par->pmi_code) {
47353 + par->pmi_setpal = par->ypan = 0;
47354 + return 0;
47355 + }
47356 +#endif
47357 +
47358 par->pmi_base = (u16 *)phys_to_virt(((u32)task->t.regs.es << 4)
47359 + task->t.regs.edi);
47360 +
47361 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
47362 + pax_open_kernel();
47363 + memcpy(par->pmi_code, par->pmi_base, (u16)task->t.regs.ecx);
47364 + pax_close_kernel();
47365 +
47366 + par->pmi_start = ktva_ktla(par->pmi_code + par->pmi_base[1]);
47367 + par->pmi_pal = ktva_ktla(par->pmi_code + par->pmi_base[2]);
47368 +#else
47369 par->pmi_start = (u8 *)par->pmi_base + par->pmi_base[1];
47370 par->pmi_pal = (u8 *)par->pmi_base + par->pmi_base[2];
47371 +#endif
47372 +
47373 printk(KERN_INFO "uvesafb: protected mode interface info at "
47374 "%04x:%04x\n",
47375 (u16)task->t.regs.es, (u16)task->t.regs.edi);
47376 @@ -817,13 +840,14 @@ static int uvesafb_vbe_init(struct fb_info *info)
47377 par->ypan = ypan;
47378
47379 if (par->pmi_setpal || par->ypan) {
47380 +#if !defined(CONFIG_MODULES) || !defined(CONFIG_PAX_KERNEXEC)
47381 if (__supported_pte_mask & _PAGE_NX) {
47382 par->pmi_setpal = par->ypan = 0;
47383 printk(KERN_WARNING "uvesafb: NX protection is actively."
47384 "We have better not to use the PMI.\n");
47385 - } else {
47386 + } else
47387 +#endif
47388 uvesafb_vbe_getpmi(task, par);
47389 - }
47390 }
47391 #else
47392 /* The protected mode interface is not available on non-x86. */
47393 @@ -1457,8 +1481,11 @@ static void uvesafb_init_info(struct fb_info *info, struct vbe_mode_ib *mode)
47394 info->fix.ywrapstep = (par->ypan > 1) ? 1 : 0;
47395
47396 /* Disable blanking if the user requested so. */
47397 - if (!blank)
47398 - info->fbops->fb_blank = NULL;
47399 + if (!blank) {
47400 + pax_open_kernel();
47401 + *(void **)&info->fbops->fb_blank = NULL;
47402 + pax_close_kernel();
47403 + }
47404
47405 /*
47406 * Find out how much IO memory is required for the mode with
47407 @@ -1534,8 +1561,11 @@ static void uvesafb_init_info(struct fb_info *info, struct vbe_mode_ib *mode)
47408 info->flags = FBINFO_FLAG_DEFAULT |
47409 (par->ypan ? FBINFO_HWACCEL_YPAN : 0);
47410
47411 - if (!par->ypan)
47412 - info->fbops->fb_pan_display = NULL;
47413 + if (!par->ypan) {
47414 + pax_open_kernel();
47415 + *(void **)&info->fbops->fb_pan_display = NULL;
47416 + pax_close_kernel();
47417 + }
47418 }
47419
47420 static void uvesafb_init_mtrr(struct fb_info *info)
47421 @@ -1836,6 +1866,11 @@ out:
47422 if (par->vbe_modes)
47423 kfree(par->vbe_modes);
47424
47425 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
47426 + if (par->pmi_code)
47427 + module_free_exec(NULL, par->pmi_code);
47428 +#endif
47429 +
47430 framebuffer_release(info);
47431 return err;
47432 }
47433 @@ -1862,6 +1897,12 @@ static int uvesafb_remove(struct platform_device *dev)
47434 kfree(par->vbe_state_orig);
47435 if (par->vbe_state_saved)
47436 kfree(par->vbe_state_saved);
47437 +
47438 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
47439 + if (par->pmi_code)
47440 + module_free_exec(NULL, par->pmi_code);
47441 +#endif
47442 +
47443 }
47444
47445 framebuffer_release(info);
47446 diff --git a/drivers/video/vesafb.c b/drivers/video/vesafb.c
47447 index 501b340..d80aa17 100644
47448 --- a/drivers/video/vesafb.c
47449 +++ b/drivers/video/vesafb.c
47450 @@ -9,6 +9,7 @@
47451 */
47452
47453 #include <linux/module.h>
47454 +#include <linux/moduleloader.h>
47455 #include <linux/kernel.h>
47456 #include <linux/errno.h>
47457 #include <linux/string.h>
47458 @@ -52,8 +53,8 @@ static int vram_remap __initdata; /* Set amount of memory to be used */
47459 static int vram_total __initdata; /* Set total amount of memory */
47460 static int pmi_setpal __read_mostly = 1; /* pmi for palette changes ??? */
47461 static int ypan __read_mostly; /* 0..nothing, 1..ypan, 2..ywrap */
47462 -static void (*pmi_start)(void) __read_mostly;
47463 -static void (*pmi_pal) (void) __read_mostly;
47464 +static void (*pmi_start)(void) __read_only;
47465 +static void (*pmi_pal) (void) __read_only;
47466 static int depth __read_mostly;
47467 static int vga_compat __read_mostly;
47468 /* --------------------------------------------------------------------- */
47469 @@ -233,6 +234,7 @@ static int __init vesafb_probe(struct platform_device *dev)
47470 unsigned int size_vmode;
47471 unsigned int size_remap;
47472 unsigned int size_total;
47473 + void *pmi_code = NULL;
47474
47475 if (screen_info.orig_video_isVGA != VIDEO_TYPE_VLFB)
47476 return -ENODEV;
47477 @@ -275,10 +277,6 @@ static int __init vesafb_probe(struct platform_device *dev)
47478 size_remap = size_total;
47479 vesafb_fix.smem_len = size_remap;
47480
47481 -#ifndef __i386__
47482 - screen_info.vesapm_seg = 0;
47483 -#endif
47484 -
47485 if (!request_mem_region(vesafb_fix.smem_start, size_total, "vesafb")) {
47486 printk(KERN_WARNING
47487 "vesafb: cannot reserve video memory at 0x%lx\n",
47488 @@ -307,9 +305,21 @@ static int __init vesafb_probe(struct platform_device *dev)
47489 printk(KERN_INFO "vesafb: mode is %dx%dx%d, linelength=%d, pages=%d\n",
47490 vesafb_defined.xres, vesafb_defined.yres, vesafb_defined.bits_per_pixel, vesafb_fix.line_length, screen_info.pages);
47491
47492 +#ifdef __i386__
47493 +
47494 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
47495 + pmi_code = module_alloc_exec(screen_info.vesapm_size);
47496 + if (!pmi_code)
47497 +#elif !defined(CONFIG_PAX_KERNEXEC)
47498 + if (0)
47499 +#endif
47500 +
47501 +#endif
47502 + screen_info.vesapm_seg = 0;
47503 +
47504 if (screen_info.vesapm_seg) {
47505 - printk(KERN_INFO "vesafb: protected mode interface info at %04x:%04x\n",
47506 - screen_info.vesapm_seg,screen_info.vesapm_off);
47507 + printk(KERN_INFO "vesafb: protected mode interface info at %04x:%04x %04x bytes\n",
47508 + screen_info.vesapm_seg,screen_info.vesapm_off,screen_info.vesapm_size);
47509 }
47510
47511 if (screen_info.vesapm_seg < 0xc000)
47512 @@ -317,9 +327,25 @@ static int __init vesafb_probe(struct platform_device *dev)
47513
47514 if (ypan || pmi_setpal) {
47515 unsigned short *pmi_base;
47516 +
47517 pmi_base = (unsigned short*)phys_to_virt(((unsigned long)screen_info.vesapm_seg << 4) + screen_info.vesapm_off);
47518 - pmi_start = (void*)((char*)pmi_base + pmi_base[1]);
47519 - pmi_pal = (void*)((char*)pmi_base + pmi_base[2]);
47520 +
47521 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
47522 + pax_open_kernel();
47523 + memcpy(pmi_code, pmi_base, screen_info.vesapm_size);
47524 +#else
47525 + pmi_code = pmi_base;
47526 +#endif
47527 +
47528 + pmi_start = (void*)((char*)pmi_code + pmi_base[1]);
47529 + pmi_pal = (void*)((char*)pmi_code + pmi_base[2]);
47530 +
47531 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
47532 + pmi_start = ktva_ktla(pmi_start);
47533 + pmi_pal = ktva_ktla(pmi_pal);
47534 + pax_close_kernel();
47535 +#endif
47536 +
47537 printk(KERN_INFO "vesafb: pmi: set display start = %p, set palette = %p\n",pmi_start,pmi_pal);
47538 if (pmi_base[3]) {
47539 printk(KERN_INFO "vesafb: pmi: ports = ");
47540 @@ -472,8 +498,11 @@ static int __init vesafb_probe(struct platform_device *dev)
47541 info->flags = FBINFO_FLAG_DEFAULT | FBINFO_MISC_FIRMWARE |
47542 (ypan ? FBINFO_HWACCEL_YPAN : 0);
47543
47544 - if (!ypan)
47545 - info->fbops->fb_pan_display = NULL;
47546 + if (!ypan) {
47547 + pax_open_kernel();
47548 + *(void **)&info->fbops->fb_pan_display = NULL;
47549 + pax_close_kernel();
47550 + }
47551
47552 if (fb_alloc_cmap(&info->cmap, 256, 0) < 0) {
47553 err = -ENOMEM;
47554 @@ -488,6 +517,11 @@ static int __init vesafb_probe(struct platform_device *dev)
47555 info->node, info->fix.id);
47556 return 0;
47557 err:
47558 +
47559 +#if defined(__i386__) && defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
47560 + module_free_exec(NULL, pmi_code);
47561 +#endif
47562 +
47563 if (info->screen_base)
47564 iounmap(info->screen_base);
47565 framebuffer_release(info);
47566 diff --git a/drivers/video/via/via_clock.h b/drivers/video/via/via_clock.h
47567 index 88714ae..16c2e11 100644
47568 --- a/drivers/video/via/via_clock.h
47569 +++ b/drivers/video/via/via_clock.h
47570 @@ -56,7 +56,7 @@ struct via_clock {
47571
47572 void (*set_engine_pll_state)(u8 state);
47573 void (*set_engine_pll)(struct via_pll_config config);
47574 -};
47575 +} __no_const;
47576
47577
47578 static inline u32 get_pll_internal_frequency(u32 ref_freq,
47579 diff --git a/drivers/xen/xenfs/xenstored.c b/drivers/xen/xenfs/xenstored.c
47580 index fef20db..d28b1ab 100644
47581 --- a/drivers/xen/xenfs/xenstored.c
47582 +++ b/drivers/xen/xenfs/xenstored.c
47583 @@ -24,7 +24,12 @@ static int xsd_release(struct inode *inode, struct file *file)
47584 static int xsd_kva_open(struct inode *inode, struct file *file)
47585 {
47586 file->private_data = (void *)kasprintf(GFP_KERNEL, "0x%p",
47587 +#ifdef CONFIG_GRKERNSEC_HIDESYM
47588 + NULL);
47589 +#else
47590 xen_store_interface);
47591 +#endif
47592 +
47593 if (!file->private_data)
47594 return -ENOMEM;
47595 return 0;
47596 diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c
47597 index 890bed5..17ae73e 100644
47598 --- a/fs/9p/vfs_inode.c
47599 +++ b/fs/9p/vfs_inode.c
47600 @@ -1329,7 +1329,7 @@ static void *v9fs_vfs_follow_link(struct dentry *dentry, struct nameidata *nd)
47601 void
47602 v9fs_vfs_put_link(struct dentry *dentry, struct nameidata *nd, void *p)
47603 {
47604 - char *s = nd_get_link(nd);
47605 + const char *s = nd_get_link(nd);
47606
47607 p9_debug(P9_DEBUG_VFS, " %s %s\n",
47608 dentry->d_name.name, IS_ERR(s) ? "<error>" : s);
47609 diff --git a/fs/Kconfig.binfmt b/fs/Kconfig.binfmt
47610 index 0efd152..b5802ad 100644
47611 --- a/fs/Kconfig.binfmt
47612 +++ b/fs/Kconfig.binfmt
47613 @@ -89,7 +89,7 @@ config HAVE_AOUT
47614
47615 config BINFMT_AOUT
47616 tristate "Kernel support for a.out and ECOFF binaries"
47617 - depends on HAVE_AOUT
47618 + depends on HAVE_AOUT && BROKEN
47619 ---help---
47620 A.out (Assembler.OUTput) is a set of formats for libraries and
47621 executables used in the earliest versions of UNIX. Linux used
47622 diff --git a/fs/aio.c b/fs/aio.c
47623 index 71f613c..9d01f1f 100644
47624 --- a/fs/aio.c
47625 +++ b/fs/aio.c
47626 @@ -111,7 +111,7 @@ static int aio_setup_ring(struct kioctx *ctx)
47627 size += sizeof(struct io_event) * nr_events;
47628 nr_pages = (size + PAGE_SIZE-1) >> PAGE_SHIFT;
47629
47630 - if (nr_pages < 0)
47631 + if (nr_pages <= 0)
47632 return -EINVAL;
47633
47634 nr_events = (PAGE_SIZE * nr_pages - sizeof(struct aio_ring)) / sizeof(struct io_event);
47635 @@ -1373,18 +1373,19 @@ static ssize_t aio_fsync(struct kiocb *iocb)
47636 static ssize_t aio_setup_vectored_rw(int type, struct kiocb *kiocb, bool compat)
47637 {
47638 ssize_t ret;
47639 + struct iovec iovstack;
47640
47641 #ifdef CONFIG_COMPAT
47642 if (compat)
47643 ret = compat_rw_copy_check_uvector(type,
47644 (struct compat_iovec __user *)kiocb->ki_buf,
47645 - kiocb->ki_nbytes, 1, &kiocb->ki_inline_vec,
47646 + kiocb->ki_nbytes, 1, &iovstack,
47647 &kiocb->ki_iovec);
47648 else
47649 #endif
47650 ret = rw_copy_check_uvector(type,
47651 (struct iovec __user *)kiocb->ki_buf,
47652 - kiocb->ki_nbytes, 1, &kiocb->ki_inline_vec,
47653 + kiocb->ki_nbytes, 1, &iovstack,
47654 &kiocb->ki_iovec);
47655 if (ret < 0)
47656 goto out;
47657 @@ -1393,6 +1394,10 @@ static ssize_t aio_setup_vectored_rw(int type, struct kiocb *kiocb, bool compat)
47658 if (ret < 0)
47659 goto out;
47660
47661 + if (kiocb->ki_iovec == &iovstack) {
47662 + kiocb->ki_inline_vec = iovstack;
47663 + kiocb->ki_iovec = &kiocb->ki_inline_vec;
47664 + }
47665 kiocb->ki_nr_segs = kiocb->ki_nbytes;
47666 kiocb->ki_cur_seg = 0;
47667 /* ki_nbytes/left now reflect bytes instead of segs */
47668 diff --git a/fs/attr.c b/fs/attr.c
47669 index 1449adb..a2038c2 100644
47670 --- a/fs/attr.c
47671 +++ b/fs/attr.c
47672 @@ -102,6 +102,7 @@ int inode_newsize_ok(const struct inode *inode, loff_t offset)
47673 unsigned long limit;
47674
47675 limit = rlimit(RLIMIT_FSIZE);
47676 + gr_learn_resource(current, RLIMIT_FSIZE, (unsigned long)offset, 1);
47677 if (limit != RLIM_INFINITY && offset > limit)
47678 goto out_sig;
47679 if (offset > inode->i_sb->s_maxbytes)
47680 diff --git a/fs/autofs4/waitq.c b/fs/autofs4/waitq.c
47681 index 03bc1d3..6205356 100644
47682 --- a/fs/autofs4/waitq.c
47683 +++ b/fs/autofs4/waitq.c
47684 @@ -61,7 +61,7 @@ static int autofs4_write(struct autofs_sb_info *sbi,
47685 {
47686 unsigned long sigpipe, flags;
47687 mm_segment_t fs;
47688 - const char *data = (const char *)addr;
47689 + const char __user *data = (const char __force_user *)addr;
47690 ssize_t wr = 0;
47691
47692 sigpipe = sigismember(&current->pending.signal, SIGPIPE);
47693 @@ -348,6 +348,10 @@ static int validate_request(struct autofs_wait_queue **wait,
47694 return 1;
47695 }
47696
47697 +#ifdef CONFIG_GRKERNSEC_HIDESYM
47698 +static atomic_unchecked_t autofs_dummy_name_id = ATOMIC_INIT(0);
47699 +#endif
47700 +
47701 int autofs4_wait(struct autofs_sb_info *sbi, struct dentry *dentry,
47702 enum autofs_notify notify)
47703 {
47704 @@ -381,7 +385,12 @@ int autofs4_wait(struct autofs_sb_info *sbi, struct dentry *dentry,
47705
47706 /* If this is a direct mount request create a dummy name */
47707 if (IS_ROOT(dentry) && autofs_type_trigger(sbi->type))
47708 +#ifdef CONFIG_GRKERNSEC_HIDESYM
47709 + /* this name does get written to userland via autofs4_write() */
47710 + qstr.len = sprintf(name, "%08x", atomic_inc_return_unchecked(&autofs_dummy_name_id));
47711 +#else
47712 qstr.len = sprintf(name, "%p", dentry);
47713 +#endif
47714 else {
47715 qstr.len = autofs4_getpath(sbi, dentry, &name);
47716 if (!qstr.len) {
47717 diff --git a/fs/befs/endian.h b/fs/befs/endian.h
47718 index 2722387..c8dd2a7 100644
47719 --- a/fs/befs/endian.h
47720 +++ b/fs/befs/endian.h
47721 @@ -11,7 +11,7 @@
47722
47723 #include <asm/byteorder.h>
47724
47725 -static inline u64
47726 +static inline u64 __intentional_overflow(-1)
47727 fs64_to_cpu(const struct super_block *sb, fs64 n)
47728 {
47729 if (BEFS_SB(sb)->byte_order == BEFS_BYTESEX_LE)
47730 @@ -29,7 +29,7 @@ cpu_to_fs64(const struct super_block *sb, u64 n)
47731 return (__force fs64)cpu_to_be64(n);
47732 }
47733
47734 -static inline u32
47735 +static inline u32 __intentional_overflow(-1)
47736 fs32_to_cpu(const struct super_block *sb, fs32 n)
47737 {
47738 if (BEFS_SB(sb)->byte_order == BEFS_BYTESEX_LE)
47739 diff --git a/fs/befs/linuxvfs.c b/fs/befs/linuxvfs.c
47740 index 2b3bda8..6a2d4be 100644
47741 --- a/fs/befs/linuxvfs.c
47742 +++ b/fs/befs/linuxvfs.c
47743 @@ -510,7 +510,7 @@ static void befs_put_link(struct dentry *dentry, struct nameidata *nd, void *p)
47744 {
47745 befs_inode_info *befs_ino = BEFS_I(dentry->d_inode);
47746 if (befs_ino->i_flags & BEFS_LONG_SYMLINK) {
47747 - char *link = nd_get_link(nd);
47748 + const char *link = nd_get_link(nd);
47749 if (!IS_ERR(link))
47750 kfree(link);
47751 }
47752 diff --git a/fs/binfmt_aout.c b/fs/binfmt_aout.c
47753 index 6043567..16a9239 100644
47754 --- a/fs/binfmt_aout.c
47755 +++ b/fs/binfmt_aout.c
47756 @@ -16,6 +16,7 @@
47757 #include <linux/string.h>
47758 #include <linux/fs.h>
47759 #include <linux/file.h>
47760 +#include <linux/security.h>
47761 #include <linux/stat.h>
47762 #include <linux/fcntl.h>
47763 #include <linux/ptrace.h>
47764 @@ -59,6 +60,8 @@ static int aout_core_dump(struct coredump_params *cprm)
47765 #endif
47766 # define START_STACK(u) ((void __user *)u.start_stack)
47767
47768 + memset(&dump, 0, sizeof(dump));
47769 +
47770 fs = get_fs();
47771 set_fs(KERNEL_DS);
47772 has_dumped = 1;
47773 @@ -70,10 +73,12 @@ static int aout_core_dump(struct coredump_params *cprm)
47774
47775 /* If the size of the dump file exceeds the rlimit, then see what would happen
47776 if we wrote the stack, but not the data area. */
47777 + gr_learn_resource(current, RLIMIT_CORE, (dump.u_dsize + dump.u_ssize+1) * PAGE_SIZE, 1);
47778 if ((dump.u_dsize + dump.u_ssize+1) * PAGE_SIZE > cprm->limit)
47779 dump.u_dsize = 0;
47780
47781 /* Make sure we have enough room to write the stack and data areas. */
47782 + gr_learn_resource(current, RLIMIT_CORE, (dump.u_ssize + 1) * PAGE_SIZE, 1);
47783 if ((dump.u_ssize + 1) * PAGE_SIZE > cprm->limit)
47784 dump.u_ssize = 0;
47785
47786 @@ -234,6 +239,8 @@ static int load_aout_binary(struct linux_binprm * bprm)
47787 rlim = rlimit(RLIMIT_DATA);
47788 if (rlim >= RLIM_INFINITY)
47789 rlim = ~0;
47790 +
47791 + gr_learn_resource(current, RLIMIT_DATA, ex.a_data + ex.a_bss, 1);
47792 if (ex.a_data + ex.a_bss > rlim)
47793 return -ENOMEM;
47794
47795 @@ -268,6 +275,27 @@ static int load_aout_binary(struct linux_binprm * bprm)
47796
47797 install_exec_creds(bprm);
47798
47799 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
47800 + current->mm->pax_flags = 0UL;
47801 +#endif
47802 +
47803 +#ifdef CONFIG_PAX_PAGEEXEC
47804 + if (!(N_FLAGS(ex) & F_PAX_PAGEEXEC)) {
47805 + current->mm->pax_flags |= MF_PAX_PAGEEXEC;
47806 +
47807 +#ifdef CONFIG_PAX_EMUTRAMP
47808 + if (N_FLAGS(ex) & F_PAX_EMUTRAMP)
47809 + current->mm->pax_flags |= MF_PAX_EMUTRAMP;
47810 +#endif
47811 +
47812 +#ifdef CONFIG_PAX_MPROTECT
47813 + if (!(N_FLAGS(ex) & F_PAX_MPROTECT))
47814 + current->mm->pax_flags |= MF_PAX_MPROTECT;
47815 +#endif
47816 +
47817 + }
47818 +#endif
47819 +
47820 if (N_MAGIC(ex) == OMAGIC) {
47821 unsigned long text_addr, map_size;
47822 loff_t pos;
47823 @@ -333,7 +361,7 @@ static int load_aout_binary(struct linux_binprm * bprm)
47824 }
47825
47826 error = vm_mmap(bprm->file, N_DATADDR(ex), ex.a_data,
47827 - PROT_READ | PROT_WRITE | PROT_EXEC,
47828 + PROT_READ | PROT_WRITE,
47829 MAP_FIXED | MAP_PRIVATE | MAP_DENYWRITE | MAP_EXECUTABLE,
47830 fd_offset + ex.a_text);
47831 if (error != N_DATADDR(ex)) {
47832 diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c
47833 index 0c42cdb..12478dd 100644
47834 --- a/fs/binfmt_elf.c
47835 +++ b/fs/binfmt_elf.c
47836 @@ -33,6 +33,7 @@
47837 #include <linux/elf.h>
47838 #include <linux/utsname.h>
47839 #include <linux/coredump.h>
47840 +#include <linux/xattr.h>
47841 #include <asm/uaccess.h>
47842 #include <asm/param.h>
47843 #include <asm/page.h>
47844 @@ -59,6 +60,10 @@ static int elf_core_dump(struct coredump_params *cprm);
47845 #define elf_core_dump NULL
47846 #endif
47847
47848 +#ifdef CONFIG_PAX_MPROTECT
47849 +static void elf_handle_mprotect(struct vm_area_struct *vma, unsigned long newflags);
47850 +#endif
47851 +
47852 #if ELF_EXEC_PAGESIZE > PAGE_SIZE
47853 #define ELF_MIN_ALIGN ELF_EXEC_PAGESIZE
47854 #else
47855 @@ -78,6 +83,11 @@ static struct linux_binfmt elf_format = {
47856 .load_binary = load_elf_binary,
47857 .load_shlib = load_elf_library,
47858 .core_dump = elf_core_dump,
47859 +
47860 +#ifdef CONFIG_PAX_MPROTECT
47861 + .handle_mprotect= elf_handle_mprotect,
47862 +#endif
47863 +
47864 .min_coredump = ELF_EXEC_PAGESIZE,
47865 };
47866
47867 @@ -85,6 +95,8 @@ static struct linux_binfmt elf_format = {
47868
47869 static int set_brk(unsigned long start, unsigned long end)
47870 {
47871 + unsigned long e = end;
47872 +
47873 start = ELF_PAGEALIGN(start);
47874 end = ELF_PAGEALIGN(end);
47875 if (end > start) {
47876 @@ -93,7 +105,7 @@ static int set_brk(unsigned long start, unsigned long end)
47877 if (BAD_ADDR(addr))
47878 return addr;
47879 }
47880 - current->mm->start_brk = current->mm->brk = end;
47881 + current->mm->start_brk = current->mm->brk = e;
47882 return 0;
47883 }
47884
47885 @@ -154,12 +166,13 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
47886 elf_addr_t __user *u_rand_bytes;
47887 const char *k_platform = ELF_PLATFORM;
47888 const char *k_base_platform = ELF_BASE_PLATFORM;
47889 - unsigned char k_rand_bytes[16];
47890 + u32 k_rand_bytes[4];
47891 int items;
47892 elf_addr_t *elf_info;
47893 int ei_index = 0;
47894 const struct cred *cred = current_cred();
47895 struct vm_area_struct *vma;
47896 + unsigned long saved_auxv[AT_VECTOR_SIZE];
47897
47898 /*
47899 * In some cases (e.g. Hyper-Threading), we want to avoid L1
47900 @@ -201,8 +214,12 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
47901 * Generate 16 random bytes for userspace PRNG seeding.
47902 */
47903 get_random_bytes(k_rand_bytes, sizeof(k_rand_bytes));
47904 - u_rand_bytes = (elf_addr_t __user *)
47905 - STACK_ALLOC(p, sizeof(k_rand_bytes));
47906 + srandom32(k_rand_bytes[0] ^ random32());
47907 + srandom32(k_rand_bytes[1] ^ random32());
47908 + srandom32(k_rand_bytes[2] ^ random32());
47909 + srandom32(k_rand_bytes[3] ^ random32());
47910 + p = STACK_ROUND(p, sizeof(k_rand_bytes));
47911 + u_rand_bytes = (elf_addr_t __user *) p;
47912 if (__copy_to_user(u_rand_bytes, k_rand_bytes, sizeof(k_rand_bytes)))
47913 return -EFAULT;
47914
47915 @@ -314,9 +331,11 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
47916 return -EFAULT;
47917 current->mm->env_end = p;
47918
47919 + memcpy(saved_auxv, elf_info, ei_index * sizeof(elf_addr_t));
47920 +
47921 /* Put the elf_info on the stack in the right place. */
47922 sp = (elf_addr_t __user *)envp + 1;
47923 - if (copy_to_user(sp, elf_info, ei_index * sizeof(elf_addr_t)))
47924 + if (copy_to_user(sp, saved_auxv, ei_index * sizeof(elf_addr_t)))
47925 return -EFAULT;
47926 return 0;
47927 }
47928 @@ -380,15 +399,14 @@ static unsigned long total_mapping_size(struct elf_phdr *cmds, int nr)
47929 an ELF header */
47930
47931 static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
47932 - struct file *interpreter, unsigned long *interp_map_addr,
47933 - unsigned long no_base)
47934 + struct file *interpreter, unsigned long no_base)
47935 {
47936 struct elf_phdr *elf_phdata;
47937 struct elf_phdr *eppnt;
47938 - unsigned long load_addr = 0;
47939 + unsigned long load_addr = 0, pax_task_size = TASK_SIZE;
47940 int load_addr_set = 0;
47941 unsigned long last_bss = 0, elf_bss = 0;
47942 - unsigned long error = ~0UL;
47943 + unsigned long error = -EINVAL;
47944 unsigned long total_size;
47945 int retval, i, size;
47946
47947 @@ -434,6 +452,11 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
47948 goto out_close;
47949 }
47950
47951 +#ifdef CONFIG_PAX_SEGMEXEC
47952 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC)
47953 + pax_task_size = SEGMEXEC_TASK_SIZE;
47954 +#endif
47955 +
47956 eppnt = elf_phdata;
47957 for (i = 0; i < interp_elf_ex->e_phnum; i++, eppnt++) {
47958 if (eppnt->p_type == PT_LOAD) {
47959 @@ -457,8 +480,6 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
47960 map_addr = elf_map(interpreter, load_addr + vaddr,
47961 eppnt, elf_prot, elf_type, total_size);
47962 total_size = 0;
47963 - if (!*interp_map_addr)
47964 - *interp_map_addr = map_addr;
47965 error = map_addr;
47966 if (BAD_ADDR(map_addr))
47967 goto out_close;
47968 @@ -477,8 +498,8 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
47969 k = load_addr + eppnt->p_vaddr;
47970 if (BAD_ADDR(k) ||
47971 eppnt->p_filesz > eppnt->p_memsz ||
47972 - eppnt->p_memsz > TASK_SIZE ||
47973 - TASK_SIZE - eppnt->p_memsz < k) {
47974 + eppnt->p_memsz > pax_task_size ||
47975 + pax_task_size - eppnt->p_memsz < k) {
47976 error = -ENOMEM;
47977 goto out_close;
47978 }
47979 @@ -530,6 +551,315 @@ out:
47980 return error;
47981 }
47982
47983 +#ifdef CONFIG_PAX_PT_PAX_FLAGS
47984 +#ifdef CONFIG_PAX_SOFTMODE
47985 +static unsigned long pax_parse_pt_pax_softmode(const struct elf_phdr * const elf_phdata)
47986 +{
47987 + unsigned long pax_flags = 0UL;
47988 +
47989 +#ifdef CONFIG_PAX_PAGEEXEC
47990 + if (elf_phdata->p_flags & PF_PAGEEXEC)
47991 + pax_flags |= MF_PAX_PAGEEXEC;
47992 +#endif
47993 +
47994 +#ifdef CONFIG_PAX_SEGMEXEC
47995 + if (elf_phdata->p_flags & PF_SEGMEXEC)
47996 + pax_flags |= MF_PAX_SEGMEXEC;
47997 +#endif
47998 +
47999 +#ifdef CONFIG_PAX_EMUTRAMP
48000 + if ((elf_phdata->p_flags & PF_EMUTRAMP) && (pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)))
48001 + pax_flags |= MF_PAX_EMUTRAMP;
48002 +#endif
48003 +
48004 +#ifdef CONFIG_PAX_MPROTECT
48005 + if (elf_phdata->p_flags & PF_MPROTECT)
48006 + pax_flags |= MF_PAX_MPROTECT;
48007 +#endif
48008 +
48009 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
48010 + if (randomize_va_space && (elf_phdata->p_flags & PF_RANDMMAP))
48011 + pax_flags |= MF_PAX_RANDMMAP;
48012 +#endif
48013 +
48014 + return pax_flags;
48015 +}
48016 +#endif
48017 +
48018 +static unsigned long pax_parse_pt_pax_hardmode(const struct elf_phdr * const elf_phdata)
48019 +{
48020 + unsigned long pax_flags = 0UL;
48021 +
48022 +#ifdef CONFIG_PAX_PAGEEXEC
48023 + if (!(elf_phdata->p_flags & PF_NOPAGEEXEC))
48024 + pax_flags |= MF_PAX_PAGEEXEC;
48025 +#endif
48026 +
48027 +#ifdef CONFIG_PAX_SEGMEXEC
48028 + if (!(elf_phdata->p_flags & PF_NOSEGMEXEC))
48029 + pax_flags |= MF_PAX_SEGMEXEC;
48030 +#endif
48031 +
48032 +#ifdef CONFIG_PAX_EMUTRAMP
48033 + if (!(elf_phdata->p_flags & PF_NOEMUTRAMP))
48034 + pax_flags |= MF_PAX_EMUTRAMP;
48035 +#endif
48036 +
48037 +#ifdef CONFIG_PAX_MPROTECT
48038 + if (!(elf_phdata->p_flags & PF_NOMPROTECT))
48039 + pax_flags |= MF_PAX_MPROTECT;
48040 +#endif
48041 +
48042 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
48043 + if (randomize_va_space && !(elf_phdata->p_flags & PF_NORANDMMAP))
48044 + pax_flags |= MF_PAX_RANDMMAP;
48045 +#endif
48046 +
48047 + return pax_flags;
48048 +}
48049 +#endif
48050 +
48051 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
48052 +#ifdef CONFIG_PAX_SOFTMODE
48053 +static unsigned long pax_parse_xattr_pax_softmode(unsigned long pax_flags_softmode)
48054 +{
48055 + unsigned long pax_flags = 0UL;
48056 +
48057 +#ifdef CONFIG_PAX_PAGEEXEC
48058 + if (pax_flags_softmode & MF_PAX_PAGEEXEC)
48059 + pax_flags |= MF_PAX_PAGEEXEC;
48060 +#endif
48061 +
48062 +#ifdef CONFIG_PAX_SEGMEXEC
48063 + if (pax_flags_softmode & MF_PAX_SEGMEXEC)
48064 + pax_flags |= MF_PAX_SEGMEXEC;
48065 +#endif
48066 +
48067 +#ifdef CONFIG_PAX_EMUTRAMP
48068 + if (pax_flags_softmode & MF_PAX_EMUTRAMP)
48069 + pax_flags |= MF_PAX_EMUTRAMP;
48070 +#endif
48071 +
48072 +#ifdef CONFIG_PAX_MPROTECT
48073 + if (pax_flags_softmode & MF_PAX_MPROTECT)
48074 + pax_flags |= MF_PAX_MPROTECT;
48075 +#endif
48076 +
48077 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
48078 + if (randomize_va_space && (pax_flags_softmode & MF_PAX_RANDMMAP))
48079 + pax_flags |= MF_PAX_RANDMMAP;
48080 +#endif
48081 +
48082 + return pax_flags;
48083 +}
48084 +#endif
48085 +
48086 +static unsigned long pax_parse_xattr_pax_hardmode(unsigned long pax_flags_hardmode)
48087 +{
48088 + unsigned long pax_flags = 0UL;
48089 +
48090 +#ifdef CONFIG_PAX_PAGEEXEC
48091 + if (!(pax_flags_hardmode & MF_PAX_PAGEEXEC))
48092 + pax_flags |= MF_PAX_PAGEEXEC;
48093 +#endif
48094 +
48095 +#ifdef CONFIG_PAX_SEGMEXEC
48096 + if (!(pax_flags_hardmode & MF_PAX_SEGMEXEC))
48097 + pax_flags |= MF_PAX_SEGMEXEC;
48098 +#endif
48099 +
48100 +#ifdef CONFIG_PAX_EMUTRAMP
48101 + if (!(pax_flags_hardmode & MF_PAX_EMUTRAMP))
48102 + pax_flags |= MF_PAX_EMUTRAMP;
48103 +#endif
48104 +
48105 +#ifdef CONFIG_PAX_MPROTECT
48106 + if (!(pax_flags_hardmode & MF_PAX_MPROTECT))
48107 + pax_flags |= MF_PAX_MPROTECT;
48108 +#endif
48109 +
48110 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
48111 + if (randomize_va_space && !(pax_flags_hardmode & MF_PAX_RANDMMAP))
48112 + pax_flags |= MF_PAX_RANDMMAP;
48113 +#endif
48114 +
48115 + return pax_flags;
48116 +}
48117 +#endif
48118 +
48119 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
48120 +static unsigned long pax_parse_ei_pax(const struct elfhdr * const elf_ex)
48121 +{
48122 + unsigned long pax_flags = 0UL;
48123 +
48124 +#ifdef CONFIG_PAX_EI_PAX
48125 +
48126 +#ifdef CONFIG_PAX_PAGEEXEC
48127 + if (!(elf_ex->e_ident[EI_PAX] & EF_PAX_PAGEEXEC))
48128 + pax_flags |= MF_PAX_PAGEEXEC;
48129 +#endif
48130 +
48131 +#ifdef CONFIG_PAX_SEGMEXEC
48132 + if (!(elf_ex->e_ident[EI_PAX] & EF_PAX_SEGMEXEC))
48133 + pax_flags |= MF_PAX_SEGMEXEC;
48134 +#endif
48135 +
48136 +#ifdef CONFIG_PAX_EMUTRAMP
48137 + if ((pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) && (elf_ex->e_ident[EI_PAX] & EF_PAX_EMUTRAMP))
48138 + pax_flags |= MF_PAX_EMUTRAMP;
48139 +#endif
48140 +
48141 +#ifdef CONFIG_PAX_MPROTECT
48142 + if ((pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) && !(elf_ex->e_ident[EI_PAX] & EF_PAX_MPROTECT))
48143 + pax_flags |= MF_PAX_MPROTECT;
48144 +#endif
48145 +
48146 +#ifdef CONFIG_PAX_ASLR
48147 + if (randomize_va_space && !(elf_ex->e_ident[EI_PAX] & EF_PAX_RANDMMAP))
48148 + pax_flags |= MF_PAX_RANDMMAP;
48149 +#endif
48150 +
48151 +#else
48152 +
48153 +#ifdef CONFIG_PAX_PAGEEXEC
48154 + pax_flags |= MF_PAX_PAGEEXEC;
48155 +#endif
48156 +
48157 +#ifdef CONFIG_PAX_SEGMEXEC
48158 + pax_flags |= MF_PAX_SEGMEXEC;
48159 +#endif
48160 +
48161 +#ifdef CONFIG_PAX_MPROTECT
48162 + pax_flags |= MF_PAX_MPROTECT;
48163 +#endif
48164 +
48165 +#ifdef CONFIG_PAX_RANDMMAP
48166 + if (randomize_va_space)
48167 + pax_flags |= MF_PAX_RANDMMAP;
48168 +#endif
48169 +
48170 +#endif
48171 +
48172 + return pax_flags;
48173 +}
48174 +
48175 +static unsigned long pax_parse_pt_pax(const struct elfhdr * const elf_ex, const struct elf_phdr * const elf_phdata)
48176 +{
48177 +
48178 +#ifdef CONFIG_PAX_PT_PAX_FLAGS
48179 + unsigned long i;
48180 +
48181 + for (i = 0UL; i < elf_ex->e_phnum; i++)
48182 + if (elf_phdata[i].p_type == PT_PAX_FLAGS) {
48183 + if (((elf_phdata[i].p_flags & PF_PAGEEXEC) && (elf_phdata[i].p_flags & PF_NOPAGEEXEC)) ||
48184 + ((elf_phdata[i].p_flags & PF_SEGMEXEC) && (elf_phdata[i].p_flags & PF_NOSEGMEXEC)) ||
48185 + ((elf_phdata[i].p_flags & PF_EMUTRAMP) && (elf_phdata[i].p_flags & PF_NOEMUTRAMP)) ||
48186 + ((elf_phdata[i].p_flags & PF_MPROTECT) && (elf_phdata[i].p_flags & PF_NOMPROTECT)) ||
48187 + ((elf_phdata[i].p_flags & PF_RANDMMAP) && (elf_phdata[i].p_flags & PF_NORANDMMAP)))
48188 + return ~0UL;
48189 +
48190 +#ifdef CONFIG_PAX_SOFTMODE
48191 + if (pax_softmode)
48192 + return pax_parse_pt_pax_softmode(&elf_phdata[i]);
48193 + else
48194 +#endif
48195 +
48196 + return pax_parse_pt_pax_hardmode(&elf_phdata[i]);
48197 + break;
48198 + }
48199 +#endif
48200 +
48201 + return ~0UL;
48202 +}
48203 +
48204 +static unsigned long pax_parse_xattr_pax(struct file * const file)
48205 +{
48206 +
48207 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
48208 + ssize_t xattr_size, i;
48209 + unsigned char xattr_value[5];
48210 + unsigned long pax_flags_hardmode = 0UL, pax_flags_softmode = 0UL;
48211 +
48212 + xattr_size = vfs_getxattr(file->f_path.dentry, XATTR_NAME_PAX_FLAGS, xattr_value, sizeof xattr_value);
48213 + if (xattr_size <= 0 || xattr_size > 5)
48214 + return ~0UL;
48215 +
48216 + for (i = 0; i < xattr_size; i++)
48217 + switch (xattr_value[i]) {
48218 + default:
48219 + return ~0UL;
48220 +
48221 +#define parse_flag(option1, option2, flag) \
48222 + case option1: \
48223 + if (pax_flags_hardmode & MF_PAX_##flag) \
48224 + return ~0UL; \
48225 + pax_flags_hardmode |= MF_PAX_##flag; \
48226 + break; \
48227 + case option2: \
48228 + if (pax_flags_softmode & MF_PAX_##flag) \
48229 + return ~0UL; \
48230 + pax_flags_softmode |= MF_PAX_##flag; \
48231 + break;
48232 +
48233 + parse_flag('p', 'P', PAGEEXEC);
48234 + parse_flag('e', 'E', EMUTRAMP);
48235 + parse_flag('m', 'M', MPROTECT);
48236 + parse_flag('r', 'R', RANDMMAP);
48237 + parse_flag('s', 'S', SEGMEXEC);
48238 +
48239 +#undef parse_flag
48240 + }
48241 +
48242 + if (pax_flags_hardmode & pax_flags_softmode)
48243 + return ~0UL;
48244 +
48245 +#ifdef CONFIG_PAX_SOFTMODE
48246 + if (pax_softmode)
48247 + return pax_parse_xattr_pax_softmode(pax_flags_softmode);
48248 + else
48249 +#endif
48250 +
48251 + return pax_parse_xattr_pax_hardmode(pax_flags_hardmode);
48252 +#else
48253 + return ~0UL;
48254 +#endif
48255 +
48256 +}
48257 +
48258 +static long pax_parse_pax_flags(const struct elfhdr * const elf_ex, const struct elf_phdr * const elf_phdata, struct file * const file)
48259 +{
48260 + unsigned long pax_flags, pt_pax_flags, xattr_pax_flags;
48261 +
48262 + pax_flags = pax_parse_ei_pax(elf_ex);
48263 + pt_pax_flags = pax_parse_pt_pax(elf_ex, elf_phdata);
48264 + xattr_pax_flags = pax_parse_xattr_pax(file);
48265 +
48266 + if (pt_pax_flags == ~0UL)
48267 + pt_pax_flags = xattr_pax_flags;
48268 + else if (xattr_pax_flags == ~0UL)
48269 + xattr_pax_flags = pt_pax_flags;
48270 + if (pt_pax_flags != xattr_pax_flags)
48271 + return -EINVAL;
48272 + if (pt_pax_flags != ~0UL)
48273 + pax_flags = pt_pax_flags;
48274 +
48275 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_PAX_SEGMEXEC)
48276 + if ((pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) == (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
48277 + if ((__supported_pte_mask & _PAGE_NX))
48278 + pax_flags &= ~MF_PAX_SEGMEXEC;
48279 + else
48280 + pax_flags &= ~MF_PAX_PAGEEXEC;
48281 + }
48282 +#endif
48283 +
48284 + if (0 > pax_check_flags(&pax_flags))
48285 + return -EINVAL;
48286 +
48287 + current->mm->pax_flags = pax_flags;
48288 + return 0;
48289 +}
48290 +#endif
48291 +
48292 /*
48293 * These are the functions used to load ELF style executables and shared
48294 * libraries. There is no binary dependent code anywhere else.
48295 @@ -546,6 +876,11 @@ static unsigned long randomize_stack_top(unsigned long stack_top)
48296 {
48297 unsigned int random_variable = 0;
48298
48299 +#ifdef CONFIG_PAX_RANDUSTACK
48300 + if (current->mm->pax_flags & MF_PAX_RANDMMAP)
48301 + return stack_top - current->mm->delta_stack;
48302 +#endif
48303 +
48304 if ((current->flags & PF_RANDOMIZE) &&
48305 !(current->personality & ADDR_NO_RANDOMIZE)) {
48306 random_variable = get_random_int() & STACK_RND_MASK;
48307 @@ -564,7 +899,7 @@ static int load_elf_binary(struct linux_binprm *bprm)
48308 unsigned long load_addr = 0, load_bias = 0;
48309 int load_addr_set = 0;
48310 char * elf_interpreter = NULL;
48311 - unsigned long error;
48312 + unsigned long error = 0;
48313 struct elf_phdr *elf_ppnt, *elf_phdata;
48314 unsigned long elf_bss, elf_brk;
48315 int retval, i;
48316 @@ -574,12 +909,12 @@ static int load_elf_binary(struct linux_binprm *bprm)
48317 unsigned long start_code, end_code, start_data, end_data;
48318 unsigned long reloc_func_desc __maybe_unused = 0;
48319 int executable_stack = EXSTACK_DEFAULT;
48320 - unsigned long def_flags = 0;
48321 struct pt_regs *regs = current_pt_regs();
48322 struct {
48323 struct elfhdr elf_ex;
48324 struct elfhdr interp_elf_ex;
48325 } *loc;
48326 + unsigned long pax_task_size = TASK_SIZE;
48327
48328 loc = kmalloc(sizeof(*loc), GFP_KERNEL);
48329 if (!loc) {
48330 @@ -715,11 +1050,81 @@ static int load_elf_binary(struct linux_binprm *bprm)
48331 goto out_free_dentry;
48332
48333 /* OK, This is the point of no return */
48334 - current->mm->def_flags = def_flags;
48335 +
48336 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
48337 + current->mm->pax_flags = 0UL;
48338 +#endif
48339 +
48340 +#ifdef CONFIG_PAX_DLRESOLVE
48341 + current->mm->call_dl_resolve = 0UL;
48342 +#endif
48343 +
48344 +#if defined(CONFIG_PPC32) && defined(CONFIG_PAX_EMUSIGRT)
48345 + current->mm->call_syscall = 0UL;
48346 +#endif
48347 +
48348 +#ifdef CONFIG_PAX_ASLR
48349 + current->mm->delta_mmap = 0UL;
48350 + current->mm->delta_stack = 0UL;
48351 +#endif
48352 +
48353 + current->mm->def_flags = 0;
48354 +
48355 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
48356 + if (0 > pax_parse_pax_flags(&loc->elf_ex, elf_phdata, bprm->file)) {
48357 + send_sig(SIGKILL, current, 0);
48358 + goto out_free_dentry;
48359 + }
48360 +#endif
48361 +
48362 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
48363 + pax_set_initial_flags(bprm);
48364 +#elif defined(CONFIG_PAX_HOOK_ACL_FLAGS)
48365 + if (pax_set_initial_flags_func)
48366 + (pax_set_initial_flags_func)(bprm);
48367 +#endif
48368 +
48369 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
48370 + if ((current->mm->pax_flags & MF_PAX_PAGEEXEC) && !(__supported_pte_mask & _PAGE_NX)) {
48371 + current->mm->context.user_cs_limit = PAGE_SIZE;
48372 + current->mm->def_flags |= VM_PAGEEXEC;
48373 + }
48374 +#endif
48375 +
48376 +#ifdef CONFIG_PAX_SEGMEXEC
48377 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC) {
48378 + current->mm->context.user_cs_base = SEGMEXEC_TASK_SIZE;
48379 + current->mm->context.user_cs_limit = TASK_SIZE-SEGMEXEC_TASK_SIZE;
48380 + pax_task_size = SEGMEXEC_TASK_SIZE;
48381 + current->mm->def_flags |= VM_NOHUGEPAGE;
48382 + }
48383 +#endif
48384 +
48385 +#if defined(CONFIG_ARCH_TRACK_EXEC_LIMIT) || defined(CONFIG_PAX_SEGMEXEC)
48386 + if (current->mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
48387 + set_user_cs(current->mm->context.user_cs_base, current->mm->context.user_cs_limit, get_cpu());
48388 + put_cpu();
48389 + }
48390 +#endif
48391
48392 /* Do this immediately, since STACK_TOP as used in setup_arg_pages
48393 may depend on the personality. */
48394 SET_PERSONALITY(loc->elf_ex);
48395 +
48396 +#ifdef CONFIG_PAX_ASLR
48397 + if (current->mm->pax_flags & MF_PAX_RANDMMAP) {
48398 + current->mm->delta_mmap = (pax_get_random_long() & ((1UL << PAX_DELTA_MMAP_LEN)-1)) << PAGE_SHIFT;
48399 + current->mm->delta_stack = (pax_get_random_long() & ((1UL << PAX_DELTA_STACK_LEN)-1)) << PAGE_SHIFT;
48400 + }
48401 +#endif
48402 +
48403 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
48404 + if (current->mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
48405 + executable_stack = EXSTACK_DISABLE_X;
48406 + current->personality &= ~READ_IMPLIES_EXEC;
48407 + } else
48408 +#endif
48409 +
48410 if (elf_read_implies_exec(loc->elf_ex, executable_stack))
48411 current->personality |= READ_IMPLIES_EXEC;
48412
48413 @@ -810,6 +1215,20 @@ static int load_elf_binary(struct linux_binprm *bprm)
48414 #else
48415 load_bias = ELF_PAGESTART(ELF_ET_DYN_BASE - vaddr);
48416 #endif
48417 +
48418 +#ifdef CONFIG_PAX_RANDMMAP
48419 + /* PaX: randomize base address at the default exe base if requested */
48420 + if ((current->mm->pax_flags & MF_PAX_RANDMMAP) && elf_interpreter) {
48421 +#ifdef CONFIG_SPARC64
48422 + load_bias = (pax_get_random_long() & ((1UL << PAX_DELTA_MMAP_LEN) - 1)) << (PAGE_SHIFT+1);
48423 +#else
48424 + load_bias = (pax_get_random_long() & ((1UL << PAX_DELTA_MMAP_LEN) - 1)) << PAGE_SHIFT;
48425 +#endif
48426 + load_bias = ELF_PAGESTART(PAX_ELF_ET_DYN_BASE - vaddr + load_bias);
48427 + elf_flags |= MAP_FIXED;
48428 + }
48429 +#endif
48430 +
48431 }
48432
48433 error = elf_map(bprm->file, load_bias + vaddr, elf_ppnt,
48434 @@ -842,9 +1261,9 @@ static int load_elf_binary(struct linux_binprm *bprm)
48435 * allowed task size. Note that p_filesz must always be
48436 * <= p_memsz so it is only necessary to check p_memsz.
48437 */
48438 - if (BAD_ADDR(k) || elf_ppnt->p_filesz > elf_ppnt->p_memsz ||
48439 - elf_ppnt->p_memsz > TASK_SIZE ||
48440 - TASK_SIZE - elf_ppnt->p_memsz < k) {
48441 + if (k >= pax_task_size || elf_ppnt->p_filesz > elf_ppnt->p_memsz ||
48442 + elf_ppnt->p_memsz > pax_task_size ||
48443 + pax_task_size - elf_ppnt->p_memsz < k) {
48444 /* set_brk can never work. Avoid overflows. */
48445 send_sig(SIGKILL, current, 0);
48446 retval = -EINVAL;
48447 @@ -883,17 +1302,45 @@ static int load_elf_binary(struct linux_binprm *bprm)
48448 goto out_free_dentry;
48449 }
48450 if (likely(elf_bss != elf_brk) && unlikely(padzero(elf_bss))) {
48451 - send_sig(SIGSEGV, current, 0);
48452 - retval = -EFAULT; /* Nobody gets to see this, but.. */
48453 - goto out_free_dentry;
48454 + /*
48455 + * This bss-zeroing can fail if the ELF
48456 + * file specifies odd protections. So
48457 + * we don't check the return value
48458 + */
48459 }
48460
48461 +#ifdef CONFIG_PAX_RANDMMAP
48462 + if (current->mm->pax_flags & MF_PAX_RANDMMAP) {
48463 + unsigned long start, size, flags, vm_flags;
48464 +
48465 + start = ELF_PAGEALIGN(elf_brk);
48466 + size = PAGE_SIZE + ((pax_get_random_long() & ((1UL << 22) - 1UL)) << 4);
48467 + flags = MAP_FIXED | MAP_PRIVATE;
48468 + vm_flags = VM_DONTEXPAND | VM_DONTDUMP;
48469 +
48470 + down_write(&current->mm->mmap_sem);
48471 + start = get_unmapped_area(NULL, start, PAGE_ALIGN(size), 0, flags);
48472 + retval = -ENOMEM;
48473 + if (!IS_ERR_VALUE(start) && !find_vma_intersection(current->mm, start, start + size + PAGE_SIZE)) {
48474 +// if (current->personality & ADDR_NO_RANDOMIZE)
48475 +// vm_flags |= VM_READ | VM_MAYREAD;
48476 + start = mmap_region(NULL, start, PAGE_ALIGN(size), flags, vm_flags, 0);
48477 + up_write(&current->mm->mmap_sem);
48478 + retval = IS_ERR_VALUE(start) ? start : 0;
48479 + } else
48480 + up_write(&current->mm->mmap_sem);
48481 + if (retval == 0)
48482 + retval = set_brk(start + size, start + size + PAGE_SIZE);
48483 + if (retval < 0) {
48484 + send_sig(SIGKILL, current, 0);
48485 + goto out_free_dentry;
48486 + }
48487 + }
48488 +#endif
48489 +
48490 if (elf_interpreter) {
48491 - unsigned long interp_map_addr = 0;
48492 -
48493 elf_entry = load_elf_interp(&loc->interp_elf_ex,
48494 interpreter,
48495 - &interp_map_addr,
48496 load_bias);
48497 if (!IS_ERR((void *)elf_entry)) {
48498 /*
48499 @@ -1115,7 +1562,7 @@ static bool always_dump_vma(struct vm_area_struct *vma)
48500 * Decide what to dump of a segment, part, all or none.
48501 */
48502 static unsigned long vma_dump_size(struct vm_area_struct *vma,
48503 - unsigned long mm_flags)
48504 + unsigned long mm_flags, long signr)
48505 {
48506 #define FILTER(type) (mm_flags & (1UL << MMF_DUMP_##type))
48507
48508 @@ -1152,7 +1599,7 @@ static unsigned long vma_dump_size(struct vm_area_struct *vma,
48509 if (vma->vm_file == NULL)
48510 return 0;
48511
48512 - if (FILTER(MAPPED_PRIVATE))
48513 + if (signr == SIGKILL || FILTER(MAPPED_PRIVATE))
48514 goto whole;
48515
48516 /*
48517 @@ -1374,9 +1821,9 @@ static void fill_auxv_note(struct memelfnote *note, struct mm_struct *mm)
48518 {
48519 elf_addr_t *auxv = (elf_addr_t *) mm->saved_auxv;
48520 int i = 0;
48521 - do
48522 + do {
48523 i += 2;
48524 - while (auxv[i - 2] != AT_NULL);
48525 + } while (auxv[i - 2] != AT_NULL);
48526 fill_note(note, "CORE", NT_AUXV, i * sizeof(elf_addr_t), auxv);
48527 }
48528
48529 @@ -2006,14 +2453,14 @@ static void fill_extnum_info(struct elfhdr *elf, struct elf_shdr *shdr4extnum,
48530 }
48531
48532 static size_t elf_core_vma_data_size(struct vm_area_struct *gate_vma,
48533 - unsigned long mm_flags)
48534 + struct coredump_params *cprm)
48535 {
48536 struct vm_area_struct *vma;
48537 size_t size = 0;
48538
48539 for (vma = first_vma(current, gate_vma); vma != NULL;
48540 vma = next_vma(vma, gate_vma))
48541 - size += vma_dump_size(vma, mm_flags);
48542 + size += vma_dump_size(vma, cprm->mm_flags, cprm->siginfo->si_signo);
48543 return size;
48544 }
48545
48546 @@ -2107,7 +2554,7 @@ static int elf_core_dump(struct coredump_params *cprm)
48547
48548 dataoff = offset = roundup(offset, ELF_EXEC_PAGESIZE);
48549
48550 - offset += elf_core_vma_data_size(gate_vma, cprm->mm_flags);
48551 + offset += elf_core_vma_data_size(gate_vma, cprm);
48552 offset += elf_core_extra_data_size();
48553 e_shoff = offset;
48554
48555 @@ -2121,10 +2568,12 @@ static int elf_core_dump(struct coredump_params *cprm)
48556 offset = dataoff;
48557
48558 size += sizeof(*elf);
48559 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
48560 if (size > cprm->limit || !dump_write(cprm->file, elf, sizeof(*elf)))
48561 goto end_coredump;
48562
48563 size += sizeof(*phdr4note);
48564 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
48565 if (size > cprm->limit
48566 || !dump_write(cprm->file, phdr4note, sizeof(*phdr4note)))
48567 goto end_coredump;
48568 @@ -2138,7 +2587,7 @@ static int elf_core_dump(struct coredump_params *cprm)
48569 phdr.p_offset = offset;
48570 phdr.p_vaddr = vma->vm_start;
48571 phdr.p_paddr = 0;
48572 - phdr.p_filesz = vma_dump_size(vma, cprm->mm_flags);
48573 + phdr.p_filesz = vma_dump_size(vma, cprm->mm_flags, cprm->siginfo->si_signo);
48574 phdr.p_memsz = vma->vm_end - vma->vm_start;
48575 offset += phdr.p_filesz;
48576 phdr.p_flags = vma->vm_flags & VM_READ ? PF_R : 0;
48577 @@ -2149,6 +2598,7 @@ static int elf_core_dump(struct coredump_params *cprm)
48578 phdr.p_align = ELF_EXEC_PAGESIZE;
48579
48580 size += sizeof(phdr);
48581 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
48582 if (size > cprm->limit
48583 || !dump_write(cprm->file, &phdr, sizeof(phdr)))
48584 goto end_coredump;
48585 @@ -2173,7 +2623,7 @@ static int elf_core_dump(struct coredump_params *cprm)
48586 unsigned long addr;
48587 unsigned long end;
48588
48589 - end = vma->vm_start + vma_dump_size(vma, cprm->mm_flags);
48590 + end = vma->vm_start + vma_dump_size(vma, cprm->mm_flags, cprm->siginfo->si_signo);
48591
48592 for (addr = vma->vm_start; addr < end; addr += PAGE_SIZE) {
48593 struct page *page;
48594 @@ -2182,6 +2632,7 @@ static int elf_core_dump(struct coredump_params *cprm)
48595 page = get_dump_page(addr);
48596 if (page) {
48597 void *kaddr = kmap(page);
48598 + gr_learn_resource(current, RLIMIT_CORE, size + PAGE_SIZE, 1);
48599 stop = ((size += PAGE_SIZE) > cprm->limit) ||
48600 !dump_write(cprm->file, kaddr,
48601 PAGE_SIZE);
48602 @@ -2199,6 +2650,7 @@ static int elf_core_dump(struct coredump_params *cprm)
48603
48604 if (e_phnum == PN_XNUM) {
48605 size += sizeof(*shdr4extnum);
48606 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
48607 if (size > cprm->limit
48608 || !dump_write(cprm->file, shdr4extnum,
48609 sizeof(*shdr4extnum)))
48610 @@ -2219,6 +2671,97 @@ out:
48611
48612 #endif /* CONFIG_ELF_CORE */
48613
48614 +#ifdef CONFIG_PAX_MPROTECT
48615 +/* PaX: non-PIC ELF libraries need relocations on their executable segments
48616 + * therefore we'll grant them VM_MAYWRITE once during their life. Similarly
48617 + * we'll remove VM_MAYWRITE for good on RELRO segments.
48618 + *
48619 + * The checks favour ld-linux.so behaviour which operates on a per ELF segment
48620 + * basis because we want to allow the common case and not the special ones.
48621 + */
48622 +static void elf_handle_mprotect(struct vm_area_struct *vma, unsigned long newflags)
48623 +{
48624 + struct elfhdr elf_h;
48625 + struct elf_phdr elf_p;
48626 + unsigned long i;
48627 + unsigned long oldflags;
48628 + bool is_textrel_rw, is_textrel_rx, is_relro;
48629 +
48630 + if (!(vma->vm_mm->pax_flags & MF_PAX_MPROTECT))
48631 + return;
48632 +
48633 + oldflags = vma->vm_flags & (VM_MAYEXEC | VM_MAYWRITE | VM_MAYREAD | VM_EXEC | VM_WRITE | VM_READ);
48634 + newflags &= VM_MAYEXEC | VM_MAYWRITE | VM_MAYREAD | VM_EXEC | VM_WRITE | VM_READ;
48635 +
48636 +#ifdef CONFIG_PAX_ELFRELOCS
48637 + /* possible TEXTREL */
48638 + is_textrel_rw = vma->vm_file && !vma->anon_vma && oldflags == (VM_MAYEXEC | VM_MAYREAD | VM_EXEC | VM_READ) && newflags == (VM_WRITE | VM_READ);
48639 + 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);
48640 +#else
48641 + is_textrel_rw = false;
48642 + is_textrel_rx = false;
48643 +#endif
48644 +
48645 + /* possible RELRO */
48646 + is_relro = vma->vm_file && vma->anon_vma && oldflags == (VM_MAYWRITE | VM_MAYREAD | VM_READ) && newflags == (VM_MAYWRITE | VM_MAYREAD | VM_READ);
48647 +
48648 + if (!is_textrel_rw && !is_textrel_rx && !is_relro)
48649 + return;
48650 +
48651 + if (sizeof(elf_h) != kernel_read(vma->vm_file, 0UL, (char *)&elf_h, sizeof(elf_h)) ||
48652 + memcmp(elf_h.e_ident, ELFMAG, SELFMAG) ||
48653 +
48654 +#ifdef CONFIG_PAX_ETEXECRELOCS
48655 + ((is_textrel_rw || is_textrel_rx) && (elf_h.e_type != ET_DYN && elf_h.e_type != ET_EXEC)) ||
48656 +#else
48657 + ((is_textrel_rw || is_textrel_rx) && elf_h.e_type != ET_DYN) ||
48658 +#endif
48659 +
48660 + (is_relro && (elf_h.e_type != ET_DYN && elf_h.e_type != ET_EXEC)) ||
48661 + !elf_check_arch(&elf_h) ||
48662 + elf_h.e_phentsize != sizeof(struct elf_phdr) ||
48663 + elf_h.e_phnum > 65536UL / sizeof(struct elf_phdr))
48664 + return;
48665 +
48666 + for (i = 0UL; i < elf_h.e_phnum; i++) {
48667 + if (sizeof(elf_p) != kernel_read(vma->vm_file, elf_h.e_phoff + i*sizeof(elf_p), (char *)&elf_p, sizeof(elf_p)))
48668 + return;
48669 + switch (elf_p.p_type) {
48670 + case PT_DYNAMIC:
48671 + if (!is_textrel_rw && !is_textrel_rx)
48672 + continue;
48673 + i = 0UL;
48674 + while ((i+1) * sizeof(elf_dyn) <= elf_p.p_filesz) {
48675 + elf_dyn dyn;
48676 +
48677 + if (sizeof(dyn) != kernel_read(vma->vm_file, elf_p.p_offset + i*sizeof(dyn), (char *)&dyn, sizeof(dyn)))
48678 + return;
48679 + if (dyn.d_tag == DT_NULL)
48680 + return;
48681 + if (dyn.d_tag == DT_TEXTREL || (dyn.d_tag == DT_FLAGS && (dyn.d_un.d_val & DF_TEXTREL))) {
48682 + gr_log_textrel(vma);
48683 + if (is_textrel_rw)
48684 + vma->vm_flags |= VM_MAYWRITE;
48685 + else
48686 + /* PaX: disallow write access after relocs are done, hopefully noone else needs it... */
48687 + vma->vm_flags &= ~VM_MAYWRITE;
48688 + return;
48689 + }
48690 + i++;
48691 + }
48692 + return;
48693 +
48694 + case PT_GNU_RELRO:
48695 + if (!is_relro)
48696 + continue;
48697 + if ((elf_p.p_offset >> PAGE_SHIFT) == vma->vm_pgoff && ELF_PAGEALIGN(elf_p.p_memsz) == vma->vm_end - vma->vm_start)
48698 + vma->vm_flags &= ~VM_MAYWRITE;
48699 + return;
48700 + }
48701 + }
48702 +}
48703 +#endif
48704 +
48705 static int __init init_elf_binfmt(void)
48706 {
48707 register_binfmt(&elf_format);
48708 diff --git a/fs/binfmt_flat.c b/fs/binfmt_flat.c
48709 index b563719..3868998 100644
48710 --- a/fs/binfmt_flat.c
48711 +++ b/fs/binfmt_flat.c
48712 @@ -562,7 +562,9 @@ static int load_flat_file(struct linux_binprm * bprm,
48713 realdatastart = (unsigned long) -ENOMEM;
48714 printk("Unable to allocate RAM for process data, errno %d\n",
48715 (int)-realdatastart);
48716 + down_write(&current->mm->mmap_sem);
48717 vm_munmap(textpos, text_len);
48718 + up_write(&current->mm->mmap_sem);
48719 ret = realdatastart;
48720 goto err;
48721 }
48722 @@ -586,8 +588,10 @@ static int load_flat_file(struct linux_binprm * bprm,
48723 }
48724 if (IS_ERR_VALUE(result)) {
48725 printk("Unable to read data+bss, errno %d\n", (int)-result);
48726 + down_write(&current->mm->mmap_sem);
48727 vm_munmap(textpos, text_len);
48728 vm_munmap(realdatastart, len);
48729 + up_write(&current->mm->mmap_sem);
48730 ret = result;
48731 goto err;
48732 }
48733 @@ -654,8 +658,10 @@ static int load_flat_file(struct linux_binprm * bprm,
48734 }
48735 if (IS_ERR_VALUE(result)) {
48736 printk("Unable to read code+data+bss, errno %d\n",(int)-result);
48737 + down_write(&current->mm->mmap_sem);
48738 vm_munmap(textpos, text_len + data_len + extra +
48739 MAX_SHARED_LIBS * sizeof(unsigned long));
48740 + up_write(&current->mm->mmap_sem);
48741 ret = result;
48742 goto err;
48743 }
48744 diff --git a/fs/bio.c b/fs/bio.c
48745 index b96fc6c..431d628 100644
48746 --- a/fs/bio.c
48747 +++ b/fs/bio.c
48748 @@ -818,7 +818,7 @@ struct bio *bio_copy_user_iov(struct request_queue *q,
48749 /*
48750 * Overflow, abort
48751 */
48752 - if (end < start)
48753 + if (end < start || end - start > INT_MAX - nr_pages)
48754 return ERR_PTR(-EINVAL);
48755
48756 nr_pages += end - start;
48757 @@ -952,7 +952,7 @@ static struct bio *__bio_map_user_iov(struct request_queue *q,
48758 /*
48759 * Overflow, abort
48760 */
48761 - if (end < start)
48762 + if (end < start || end - start > INT_MAX - nr_pages)
48763 return ERR_PTR(-EINVAL);
48764
48765 nr_pages += end - start;
48766 @@ -1214,7 +1214,7 @@ static void bio_copy_kern_endio(struct bio *bio, int err)
48767 const int read = bio_data_dir(bio) == READ;
48768 struct bio_map_data *bmd = bio->bi_private;
48769 int i;
48770 - char *p = bmd->sgvecs[0].iov_base;
48771 + char *p = (char __force_kernel *)bmd->sgvecs[0].iov_base;
48772
48773 __bio_for_each_segment(bvec, bio, i, 0) {
48774 char *addr = page_address(bvec->bv_page);
48775 diff --git a/fs/block_dev.c b/fs/block_dev.c
48776 index 78edf76..da14f3f 100644
48777 --- a/fs/block_dev.c
48778 +++ b/fs/block_dev.c
48779 @@ -651,7 +651,7 @@ static bool bd_may_claim(struct block_device *bdev, struct block_device *whole,
48780 else if (bdev->bd_contains == bdev)
48781 return true; /* is a whole device which isn't held */
48782
48783 - else if (whole->bd_holder == bd_may_claim)
48784 + else if (whole->bd_holder == (void *)bd_may_claim)
48785 return true; /* is a partition of a device that is being partitioned */
48786 else if (whole->bd_holder != NULL)
48787 return false; /* is a partition of a held device */
48788 diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c
48789 index eea5da7..88fead70 100644
48790 --- a/fs/btrfs/ctree.c
48791 +++ b/fs/btrfs/ctree.c
48792 @@ -1033,9 +1033,12 @@ static noinline int __btrfs_cow_block(struct btrfs_trans_handle *trans,
48793 free_extent_buffer(buf);
48794 add_root_to_dirty_list(root);
48795 } else {
48796 - if (root->root_key.objectid == BTRFS_TREE_RELOC_OBJECTID)
48797 - parent_start = parent->start;
48798 - else
48799 + if (root->root_key.objectid == BTRFS_TREE_RELOC_OBJECTID) {
48800 + if (parent)
48801 + parent_start = parent->start;
48802 + else
48803 + parent_start = 0;
48804 + } else
48805 parent_start = 0;
48806
48807 WARN_ON(trans->transid != btrfs_header_generation(parent));
48808 diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
48809 index 659ea81..0f63c1a 100644
48810 --- a/fs/btrfs/inode.c
48811 +++ b/fs/btrfs/inode.c
48812 @@ -7300,7 +7300,7 @@ fail:
48813 return -ENOMEM;
48814 }
48815
48816 -static int btrfs_getattr(struct vfsmount *mnt,
48817 +int btrfs_getattr(struct vfsmount *mnt,
48818 struct dentry *dentry, struct kstat *stat)
48819 {
48820 struct inode *inode = dentry->d_inode;
48821 @@ -7314,6 +7314,14 @@ static int btrfs_getattr(struct vfsmount *mnt,
48822 return 0;
48823 }
48824
48825 +EXPORT_SYMBOL(btrfs_getattr);
48826 +
48827 +dev_t get_btrfs_dev_from_inode(struct inode *inode)
48828 +{
48829 + return BTRFS_I(inode)->root->anon_dev;
48830 +}
48831 +EXPORT_SYMBOL(get_btrfs_dev_from_inode);
48832 +
48833 /*
48834 * If a file is moved, it will inherit the cow and compression flags of the new
48835 * directory.
48836 diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
48837 index 338f259..b657640 100644
48838 --- a/fs/btrfs/ioctl.c
48839 +++ b/fs/btrfs/ioctl.c
48840 @@ -3033,9 +3033,12 @@ long btrfs_ioctl_space_info(struct btrfs_root *root, void __user *arg)
48841 for (i = 0; i < num_types; i++) {
48842 struct btrfs_space_info *tmp;
48843
48844 + /* Don't copy in more than we allocated */
48845 if (!slot_count)
48846 break;
48847
48848 + slot_count--;
48849 +
48850 info = NULL;
48851 rcu_read_lock();
48852 list_for_each_entry_rcu(tmp, &root->fs_info->space_info,
48853 @@ -3057,10 +3060,7 @@ long btrfs_ioctl_space_info(struct btrfs_root *root, void __user *arg)
48854 memcpy(dest, &space, sizeof(space));
48855 dest++;
48856 space_args.total_spaces++;
48857 - slot_count--;
48858 }
48859 - if (!slot_count)
48860 - break;
48861 }
48862 up_read(&info->groups_sem);
48863 }
48864 diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c
48865 index 300e09a..9fe4539 100644
48866 --- a/fs/btrfs/relocation.c
48867 +++ b/fs/btrfs/relocation.c
48868 @@ -1269,7 +1269,7 @@ static int __update_reloc_root(struct btrfs_root *root, int del)
48869 }
48870 spin_unlock(&rc->reloc_root_tree.lock);
48871
48872 - BUG_ON((struct btrfs_root *)node->data != root);
48873 + BUG_ON(!node || (struct btrfs_root *)node->data != root);
48874
48875 if (!del) {
48876 spin_lock(&rc->reloc_root_tree.lock);
48877 diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
48878 index d8982e9..29a85fa 100644
48879 --- a/fs/btrfs/super.c
48880 +++ b/fs/btrfs/super.c
48881 @@ -267,7 +267,7 @@ void __btrfs_abort_transaction(struct btrfs_trans_handle *trans,
48882 function, line, errstr);
48883 return;
48884 }
48885 - ACCESS_ONCE(trans->transaction->aborted) = errno;
48886 + ACCESS_ONCE_RW(trans->transaction->aborted) = errno;
48887 __btrfs_std_error(root->fs_info, function, line, errno, NULL);
48888 }
48889 /*
48890 diff --git a/fs/cachefiles/bind.c b/fs/cachefiles/bind.c
48891 index 622f469..e8d2d55 100644
48892 --- a/fs/cachefiles/bind.c
48893 +++ b/fs/cachefiles/bind.c
48894 @@ -39,13 +39,11 @@ int cachefiles_daemon_bind(struct cachefiles_cache *cache, char *args)
48895 args);
48896
48897 /* start by checking things over */
48898 - ASSERT(cache->fstop_percent >= 0 &&
48899 - cache->fstop_percent < cache->fcull_percent &&
48900 + ASSERT(cache->fstop_percent < cache->fcull_percent &&
48901 cache->fcull_percent < cache->frun_percent &&
48902 cache->frun_percent < 100);
48903
48904 - ASSERT(cache->bstop_percent >= 0 &&
48905 - cache->bstop_percent < cache->bcull_percent &&
48906 + ASSERT(cache->bstop_percent < cache->bcull_percent &&
48907 cache->bcull_percent < cache->brun_percent &&
48908 cache->brun_percent < 100);
48909
48910 diff --git a/fs/cachefiles/daemon.c b/fs/cachefiles/daemon.c
48911 index 0a1467b..6a53245 100644
48912 --- a/fs/cachefiles/daemon.c
48913 +++ b/fs/cachefiles/daemon.c
48914 @@ -196,7 +196,7 @@ static ssize_t cachefiles_daemon_read(struct file *file, char __user *_buffer,
48915 if (n > buflen)
48916 return -EMSGSIZE;
48917
48918 - if (copy_to_user(_buffer, buffer, n) != 0)
48919 + if (n > sizeof(buffer) || copy_to_user(_buffer, buffer, n) != 0)
48920 return -EFAULT;
48921
48922 return n;
48923 @@ -222,7 +222,7 @@ static ssize_t cachefiles_daemon_write(struct file *file,
48924 if (test_bit(CACHEFILES_DEAD, &cache->flags))
48925 return -EIO;
48926
48927 - if (datalen < 0 || datalen > PAGE_SIZE - 1)
48928 + if (datalen > PAGE_SIZE - 1)
48929 return -EOPNOTSUPP;
48930
48931 /* drag the command string into the kernel so we can parse it */
48932 @@ -386,7 +386,7 @@ static int cachefiles_daemon_fstop(struct cachefiles_cache *cache, char *args)
48933 if (args[0] != '%' || args[1] != '\0')
48934 return -EINVAL;
48935
48936 - if (fstop < 0 || fstop >= cache->fcull_percent)
48937 + if (fstop >= cache->fcull_percent)
48938 return cachefiles_daemon_range_error(cache, args);
48939
48940 cache->fstop_percent = fstop;
48941 @@ -458,7 +458,7 @@ static int cachefiles_daemon_bstop(struct cachefiles_cache *cache, char *args)
48942 if (args[0] != '%' || args[1] != '\0')
48943 return -EINVAL;
48944
48945 - if (bstop < 0 || bstop >= cache->bcull_percent)
48946 + if (bstop >= cache->bcull_percent)
48947 return cachefiles_daemon_range_error(cache, args);
48948
48949 cache->bstop_percent = bstop;
48950 diff --git a/fs/cachefiles/internal.h b/fs/cachefiles/internal.h
48951 index 4938251..7e01445 100644
48952 --- a/fs/cachefiles/internal.h
48953 +++ b/fs/cachefiles/internal.h
48954 @@ -59,7 +59,7 @@ struct cachefiles_cache {
48955 wait_queue_head_t daemon_pollwq; /* poll waitqueue for daemon */
48956 struct rb_root active_nodes; /* active nodes (can't be culled) */
48957 rwlock_t active_lock; /* lock for active_nodes */
48958 - atomic_t gravecounter; /* graveyard uniquifier */
48959 + atomic_unchecked_t gravecounter; /* graveyard uniquifier */
48960 unsigned frun_percent; /* when to stop culling (% files) */
48961 unsigned fcull_percent; /* when to start culling (% files) */
48962 unsigned fstop_percent; /* when to stop allocating (% files) */
48963 @@ -171,19 +171,19 @@ extern int cachefiles_check_in_use(struct cachefiles_cache *cache,
48964 * proc.c
48965 */
48966 #ifdef CONFIG_CACHEFILES_HISTOGRAM
48967 -extern atomic_t cachefiles_lookup_histogram[HZ];
48968 -extern atomic_t cachefiles_mkdir_histogram[HZ];
48969 -extern atomic_t cachefiles_create_histogram[HZ];
48970 +extern atomic_unchecked_t cachefiles_lookup_histogram[HZ];
48971 +extern atomic_unchecked_t cachefiles_mkdir_histogram[HZ];
48972 +extern atomic_unchecked_t cachefiles_create_histogram[HZ];
48973
48974 extern int __init cachefiles_proc_init(void);
48975 extern void cachefiles_proc_cleanup(void);
48976 static inline
48977 -void cachefiles_hist(atomic_t histogram[], unsigned long start_jif)
48978 +void cachefiles_hist(atomic_unchecked_t histogram[], unsigned long start_jif)
48979 {
48980 unsigned long jif = jiffies - start_jif;
48981 if (jif >= HZ)
48982 jif = HZ - 1;
48983 - atomic_inc(&histogram[jif]);
48984 + atomic_inc_unchecked(&histogram[jif]);
48985 }
48986
48987 #else
48988 diff --git a/fs/cachefiles/namei.c b/fs/cachefiles/namei.c
48989 index 8c01c5fc..15f982e 100644
48990 --- a/fs/cachefiles/namei.c
48991 +++ b/fs/cachefiles/namei.c
48992 @@ -317,7 +317,7 @@ try_again:
48993 /* first step is to make up a grave dentry in the graveyard */
48994 sprintf(nbuffer, "%08x%08x",
48995 (uint32_t) get_seconds(),
48996 - (uint32_t) atomic_inc_return(&cache->gravecounter));
48997 + (uint32_t) atomic_inc_return_unchecked(&cache->gravecounter));
48998
48999 /* do the multiway lock magic */
49000 trap = lock_rename(cache->graveyard, dir);
49001 diff --git a/fs/cachefiles/proc.c b/fs/cachefiles/proc.c
49002 index eccd339..4c1d995 100644
49003 --- a/fs/cachefiles/proc.c
49004 +++ b/fs/cachefiles/proc.c
49005 @@ -14,9 +14,9 @@
49006 #include <linux/seq_file.h>
49007 #include "internal.h"
49008
49009 -atomic_t cachefiles_lookup_histogram[HZ];
49010 -atomic_t cachefiles_mkdir_histogram[HZ];
49011 -atomic_t cachefiles_create_histogram[HZ];
49012 +atomic_unchecked_t cachefiles_lookup_histogram[HZ];
49013 +atomic_unchecked_t cachefiles_mkdir_histogram[HZ];
49014 +atomic_unchecked_t cachefiles_create_histogram[HZ];
49015
49016 /*
49017 * display the latency histogram
49018 @@ -35,9 +35,9 @@ static int cachefiles_histogram_show(struct seq_file *m, void *v)
49019 return 0;
49020 default:
49021 index = (unsigned long) v - 3;
49022 - x = atomic_read(&cachefiles_lookup_histogram[index]);
49023 - y = atomic_read(&cachefiles_mkdir_histogram[index]);
49024 - z = atomic_read(&cachefiles_create_histogram[index]);
49025 + x = atomic_read_unchecked(&cachefiles_lookup_histogram[index]);
49026 + y = atomic_read_unchecked(&cachefiles_mkdir_histogram[index]);
49027 + z = atomic_read_unchecked(&cachefiles_create_histogram[index]);
49028 if (x == 0 && y == 0 && z == 0)
49029 return 0;
49030
49031 diff --git a/fs/cachefiles/rdwr.c b/fs/cachefiles/rdwr.c
49032 index 4809922..aab2c39 100644
49033 --- a/fs/cachefiles/rdwr.c
49034 +++ b/fs/cachefiles/rdwr.c
49035 @@ -965,7 +965,7 @@ int cachefiles_write_page(struct fscache_storage *op, struct page *page)
49036 old_fs = get_fs();
49037 set_fs(KERNEL_DS);
49038 ret = file->f_op->write(
49039 - file, (const void __user *) data, len, &pos);
49040 + file, (const void __force_user *) data, len, &pos);
49041 set_fs(old_fs);
49042 kunmap(page);
49043 if (ret != len)
49044 diff --git a/fs/ceph/dir.c b/fs/ceph/dir.c
49045 index 8c1aabe..bbf856a 100644
49046 --- a/fs/ceph/dir.c
49047 +++ b/fs/ceph/dir.c
49048 @@ -243,7 +243,7 @@ static int ceph_readdir(struct file *filp, void *dirent, filldir_t filldir)
49049 struct ceph_fs_client *fsc = ceph_inode_to_client(inode);
49050 struct ceph_mds_client *mdsc = fsc->mdsc;
49051 unsigned frag = fpos_frag(filp->f_pos);
49052 - int off = fpos_off(filp->f_pos);
49053 + unsigned int off = fpos_off(filp->f_pos);
49054 int err;
49055 u32 ftype;
49056 struct ceph_mds_reply_info_parsed *rinfo;
49057 diff --git a/fs/cifs/cifs_debug.c b/fs/cifs/cifs_debug.c
49058 index d9ea6ed..1e6c8ac 100644
49059 --- a/fs/cifs/cifs_debug.c
49060 +++ b/fs/cifs/cifs_debug.c
49061 @@ -267,8 +267,8 @@ static ssize_t cifs_stats_proc_write(struct file *file,
49062
49063 if (c == '1' || c == 'y' || c == 'Y' || c == '0') {
49064 #ifdef CONFIG_CIFS_STATS2
49065 - atomic_set(&totBufAllocCount, 0);
49066 - atomic_set(&totSmBufAllocCount, 0);
49067 + atomic_set_unchecked(&totBufAllocCount, 0);
49068 + atomic_set_unchecked(&totSmBufAllocCount, 0);
49069 #endif /* CONFIG_CIFS_STATS2 */
49070 spin_lock(&cifs_tcp_ses_lock);
49071 list_for_each(tmp1, &cifs_tcp_ses_list) {
49072 @@ -281,7 +281,7 @@ static ssize_t cifs_stats_proc_write(struct file *file,
49073 tcon = list_entry(tmp3,
49074 struct cifs_tcon,
49075 tcon_list);
49076 - atomic_set(&tcon->num_smbs_sent, 0);
49077 + atomic_set_unchecked(&tcon->num_smbs_sent, 0);
49078 if (server->ops->clear_stats)
49079 server->ops->clear_stats(tcon);
49080 }
49081 @@ -313,8 +313,8 @@ static int cifs_stats_proc_show(struct seq_file *m, void *v)
49082 smBufAllocCount.counter, cifs_min_small);
49083 #ifdef CONFIG_CIFS_STATS2
49084 seq_printf(m, "Total Large %d Small %d Allocations\n",
49085 - atomic_read(&totBufAllocCount),
49086 - atomic_read(&totSmBufAllocCount));
49087 + atomic_read_unchecked(&totBufAllocCount),
49088 + atomic_read_unchecked(&totSmBufAllocCount));
49089 #endif /* CONFIG_CIFS_STATS2 */
49090
49091 seq_printf(m, "Operations (MIDs): %d\n", atomic_read(&midCount));
49092 @@ -343,7 +343,7 @@ static int cifs_stats_proc_show(struct seq_file *m, void *v)
49093 if (tcon->need_reconnect)
49094 seq_puts(m, "\tDISCONNECTED ");
49095 seq_printf(m, "\nSMBs: %d",
49096 - atomic_read(&tcon->num_smbs_sent));
49097 + atomic_read_unchecked(&tcon->num_smbs_sent));
49098 if (server->ops->print_stats)
49099 server->ops->print_stats(m, tcon);
49100 }
49101 diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c
49102 index e328339..322228b 100644
49103 --- a/fs/cifs/cifsfs.c
49104 +++ b/fs/cifs/cifsfs.c
49105 @@ -1002,7 +1002,7 @@ cifs_init_request_bufs(void)
49106 /* cERROR(1, "CIFSMaxBufSize %d 0x%x",CIFSMaxBufSize,CIFSMaxBufSize); */
49107 cifs_req_cachep = kmem_cache_create("cifs_request",
49108 CIFSMaxBufSize + max_hdr_size, 0,
49109 - SLAB_HWCACHE_ALIGN, NULL);
49110 + SLAB_HWCACHE_ALIGN | SLAB_USERCOPY, NULL);
49111 if (cifs_req_cachep == NULL)
49112 return -ENOMEM;
49113
49114 @@ -1029,7 +1029,7 @@ cifs_init_request_bufs(void)
49115 efficient to alloc 1 per page off the slab compared to 17K (5page)
49116 alloc of large cifs buffers even when page debugging is on */
49117 cifs_sm_req_cachep = kmem_cache_create("cifs_small_rq",
49118 - MAX_CIFS_SMALL_BUFFER_SIZE, 0, SLAB_HWCACHE_ALIGN,
49119 + MAX_CIFS_SMALL_BUFFER_SIZE, 0, SLAB_HWCACHE_ALIGN | SLAB_USERCOPY,
49120 NULL);
49121 if (cifs_sm_req_cachep == NULL) {
49122 mempool_destroy(cifs_req_poolp);
49123 @@ -1114,8 +1114,8 @@ init_cifs(void)
49124 atomic_set(&bufAllocCount, 0);
49125 atomic_set(&smBufAllocCount, 0);
49126 #ifdef CONFIG_CIFS_STATS2
49127 - atomic_set(&totBufAllocCount, 0);
49128 - atomic_set(&totSmBufAllocCount, 0);
49129 + atomic_set_unchecked(&totBufAllocCount, 0);
49130 + atomic_set_unchecked(&totSmBufAllocCount, 0);
49131 #endif /* CONFIG_CIFS_STATS2 */
49132
49133 atomic_set(&midCount, 0);
49134 diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h
49135 index e6899ce..d6b2920 100644
49136 --- a/fs/cifs/cifsglob.h
49137 +++ b/fs/cifs/cifsglob.h
49138 @@ -751,35 +751,35 @@ struct cifs_tcon {
49139 __u16 Flags; /* optional support bits */
49140 enum statusEnum tidStatus;
49141 #ifdef CONFIG_CIFS_STATS
49142 - atomic_t num_smbs_sent;
49143 + atomic_unchecked_t num_smbs_sent;
49144 union {
49145 struct {
49146 - atomic_t num_writes;
49147 - atomic_t num_reads;
49148 - atomic_t num_flushes;
49149 - atomic_t num_oplock_brks;
49150 - atomic_t num_opens;
49151 - atomic_t num_closes;
49152 - atomic_t num_deletes;
49153 - atomic_t num_mkdirs;
49154 - atomic_t num_posixopens;
49155 - atomic_t num_posixmkdirs;
49156 - atomic_t num_rmdirs;
49157 - atomic_t num_renames;
49158 - atomic_t num_t2renames;
49159 - atomic_t num_ffirst;
49160 - atomic_t num_fnext;
49161 - atomic_t num_fclose;
49162 - atomic_t num_hardlinks;
49163 - atomic_t num_symlinks;
49164 - atomic_t num_locks;
49165 - atomic_t num_acl_get;
49166 - atomic_t num_acl_set;
49167 + atomic_unchecked_t num_writes;
49168 + atomic_unchecked_t num_reads;
49169 + atomic_unchecked_t num_flushes;
49170 + atomic_unchecked_t num_oplock_brks;
49171 + atomic_unchecked_t num_opens;
49172 + atomic_unchecked_t num_closes;
49173 + atomic_unchecked_t num_deletes;
49174 + atomic_unchecked_t num_mkdirs;
49175 + atomic_unchecked_t num_posixopens;
49176 + atomic_unchecked_t num_posixmkdirs;
49177 + atomic_unchecked_t num_rmdirs;
49178 + atomic_unchecked_t num_renames;
49179 + atomic_unchecked_t num_t2renames;
49180 + atomic_unchecked_t num_ffirst;
49181 + atomic_unchecked_t num_fnext;
49182 + atomic_unchecked_t num_fclose;
49183 + atomic_unchecked_t num_hardlinks;
49184 + atomic_unchecked_t num_symlinks;
49185 + atomic_unchecked_t num_locks;
49186 + atomic_unchecked_t num_acl_get;
49187 + atomic_unchecked_t num_acl_set;
49188 } cifs_stats;
49189 #ifdef CONFIG_CIFS_SMB2
49190 struct {
49191 - atomic_t smb2_com_sent[NUMBER_OF_SMB2_COMMANDS];
49192 - atomic_t smb2_com_failed[NUMBER_OF_SMB2_COMMANDS];
49193 + atomic_unchecked_t smb2_com_sent[NUMBER_OF_SMB2_COMMANDS];
49194 + atomic_unchecked_t smb2_com_failed[NUMBER_OF_SMB2_COMMANDS];
49195 } smb2_stats;
49196 #endif /* CONFIG_CIFS_SMB2 */
49197 } stats;
49198 @@ -1080,7 +1080,7 @@ convert_delimiter(char *path, char delim)
49199 }
49200
49201 #ifdef CONFIG_CIFS_STATS
49202 -#define cifs_stats_inc atomic_inc
49203 +#define cifs_stats_inc atomic_inc_unchecked
49204
49205 static inline void cifs_stats_bytes_written(struct cifs_tcon *tcon,
49206 unsigned int bytes)
49207 @@ -1445,8 +1445,8 @@ GLOBAL_EXTERN atomic_t tconInfoReconnectCount;
49208 /* Various Debug counters */
49209 GLOBAL_EXTERN atomic_t bufAllocCount; /* current number allocated */
49210 #ifdef CONFIG_CIFS_STATS2
49211 -GLOBAL_EXTERN atomic_t totBufAllocCount; /* total allocated over all time */
49212 -GLOBAL_EXTERN atomic_t totSmBufAllocCount;
49213 +GLOBAL_EXTERN atomic_unchecked_t totBufAllocCount; /* total allocated over all time */
49214 +GLOBAL_EXTERN atomic_unchecked_t totSmBufAllocCount;
49215 #endif
49216 GLOBAL_EXTERN atomic_t smBufAllocCount;
49217 GLOBAL_EXTERN atomic_t midCount;
49218 diff --git a/fs/cifs/link.c b/fs/cifs/link.c
49219 index 51dc2fb..1e12a33 100644
49220 --- a/fs/cifs/link.c
49221 +++ b/fs/cifs/link.c
49222 @@ -616,7 +616,7 @@ symlink_exit:
49223
49224 void cifs_put_link(struct dentry *direntry, struct nameidata *nd, void *cookie)
49225 {
49226 - char *p = nd_get_link(nd);
49227 + const char *p = nd_get_link(nd);
49228 if (!IS_ERR(p))
49229 kfree(p);
49230 }
49231 diff --git a/fs/cifs/misc.c b/fs/cifs/misc.c
49232 index 3a00c0d..42d901c 100644
49233 --- a/fs/cifs/misc.c
49234 +++ b/fs/cifs/misc.c
49235 @@ -169,7 +169,7 @@ cifs_buf_get(void)
49236 memset(ret_buf, 0, buf_size + 3);
49237 atomic_inc(&bufAllocCount);
49238 #ifdef CONFIG_CIFS_STATS2
49239 - atomic_inc(&totBufAllocCount);
49240 + atomic_inc_unchecked(&totBufAllocCount);
49241 #endif /* CONFIG_CIFS_STATS2 */
49242 }
49243
49244 @@ -204,7 +204,7 @@ cifs_small_buf_get(void)
49245 /* memset(ret_buf, 0, sizeof(struct smb_hdr) + 27);*/
49246 atomic_inc(&smBufAllocCount);
49247 #ifdef CONFIG_CIFS_STATS2
49248 - atomic_inc(&totSmBufAllocCount);
49249 + atomic_inc_unchecked(&totSmBufAllocCount);
49250 #endif /* CONFIG_CIFS_STATS2 */
49251
49252 }
49253 diff --git a/fs/cifs/smb1ops.c b/fs/cifs/smb1ops.c
49254 index 47bc5a8..10decbe 100644
49255 --- a/fs/cifs/smb1ops.c
49256 +++ b/fs/cifs/smb1ops.c
49257 @@ -586,27 +586,27 @@ static void
49258 cifs_clear_stats(struct cifs_tcon *tcon)
49259 {
49260 #ifdef CONFIG_CIFS_STATS
49261 - atomic_set(&tcon->stats.cifs_stats.num_writes, 0);
49262 - atomic_set(&tcon->stats.cifs_stats.num_reads, 0);
49263 - atomic_set(&tcon->stats.cifs_stats.num_flushes, 0);
49264 - atomic_set(&tcon->stats.cifs_stats.num_oplock_brks, 0);
49265 - atomic_set(&tcon->stats.cifs_stats.num_opens, 0);
49266 - atomic_set(&tcon->stats.cifs_stats.num_posixopens, 0);
49267 - atomic_set(&tcon->stats.cifs_stats.num_posixmkdirs, 0);
49268 - atomic_set(&tcon->stats.cifs_stats.num_closes, 0);
49269 - atomic_set(&tcon->stats.cifs_stats.num_deletes, 0);
49270 - atomic_set(&tcon->stats.cifs_stats.num_mkdirs, 0);
49271 - atomic_set(&tcon->stats.cifs_stats.num_rmdirs, 0);
49272 - atomic_set(&tcon->stats.cifs_stats.num_renames, 0);
49273 - atomic_set(&tcon->stats.cifs_stats.num_t2renames, 0);
49274 - atomic_set(&tcon->stats.cifs_stats.num_ffirst, 0);
49275 - atomic_set(&tcon->stats.cifs_stats.num_fnext, 0);
49276 - atomic_set(&tcon->stats.cifs_stats.num_fclose, 0);
49277 - atomic_set(&tcon->stats.cifs_stats.num_hardlinks, 0);
49278 - atomic_set(&tcon->stats.cifs_stats.num_symlinks, 0);
49279 - atomic_set(&tcon->stats.cifs_stats.num_locks, 0);
49280 - atomic_set(&tcon->stats.cifs_stats.num_acl_get, 0);
49281 - atomic_set(&tcon->stats.cifs_stats.num_acl_set, 0);
49282 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_writes, 0);
49283 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_reads, 0);
49284 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_flushes, 0);
49285 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_oplock_brks, 0);
49286 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_opens, 0);
49287 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_posixopens, 0);
49288 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_posixmkdirs, 0);
49289 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_closes, 0);
49290 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_deletes, 0);
49291 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_mkdirs, 0);
49292 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_rmdirs, 0);
49293 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_renames, 0);
49294 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_t2renames, 0);
49295 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_ffirst, 0);
49296 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_fnext, 0);
49297 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_fclose, 0);
49298 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_hardlinks, 0);
49299 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_symlinks, 0);
49300 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_locks, 0);
49301 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_acl_get, 0);
49302 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_acl_set, 0);
49303 #endif
49304 }
49305
49306 @@ -615,36 +615,36 @@ cifs_print_stats(struct seq_file *m, struct cifs_tcon *tcon)
49307 {
49308 #ifdef CONFIG_CIFS_STATS
49309 seq_printf(m, " Oplocks breaks: %d",
49310 - atomic_read(&tcon->stats.cifs_stats.num_oplock_brks));
49311 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_oplock_brks));
49312 seq_printf(m, "\nReads: %d Bytes: %llu",
49313 - atomic_read(&tcon->stats.cifs_stats.num_reads),
49314 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_reads),
49315 (long long)(tcon->bytes_read));
49316 seq_printf(m, "\nWrites: %d Bytes: %llu",
49317 - atomic_read(&tcon->stats.cifs_stats.num_writes),
49318 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_writes),
49319 (long long)(tcon->bytes_written));
49320 seq_printf(m, "\nFlushes: %d",
49321 - atomic_read(&tcon->stats.cifs_stats.num_flushes));
49322 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_flushes));
49323 seq_printf(m, "\nLocks: %d HardLinks: %d Symlinks: %d",
49324 - atomic_read(&tcon->stats.cifs_stats.num_locks),
49325 - atomic_read(&tcon->stats.cifs_stats.num_hardlinks),
49326 - atomic_read(&tcon->stats.cifs_stats.num_symlinks));
49327 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_locks),
49328 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_hardlinks),
49329 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_symlinks));
49330 seq_printf(m, "\nOpens: %d Closes: %d Deletes: %d",
49331 - atomic_read(&tcon->stats.cifs_stats.num_opens),
49332 - atomic_read(&tcon->stats.cifs_stats.num_closes),
49333 - atomic_read(&tcon->stats.cifs_stats.num_deletes));
49334 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_opens),
49335 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_closes),
49336 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_deletes));
49337 seq_printf(m, "\nPosix Opens: %d Posix Mkdirs: %d",
49338 - atomic_read(&tcon->stats.cifs_stats.num_posixopens),
49339 - atomic_read(&tcon->stats.cifs_stats.num_posixmkdirs));
49340 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_posixopens),
49341 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_posixmkdirs));
49342 seq_printf(m, "\nMkdirs: %d Rmdirs: %d",
49343 - atomic_read(&tcon->stats.cifs_stats.num_mkdirs),
49344 - atomic_read(&tcon->stats.cifs_stats.num_rmdirs));
49345 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_mkdirs),
49346 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_rmdirs));
49347 seq_printf(m, "\nRenames: %d T2 Renames %d",
49348 - atomic_read(&tcon->stats.cifs_stats.num_renames),
49349 - atomic_read(&tcon->stats.cifs_stats.num_t2renames));
49350 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_renames),
49351 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_t2renames));
49352 seq_printf(m, "\nFindFirst: %d FNext %d FClose %d",
49353 - atomic_read(&tcon->stats.cifs_stats.num_ffirst),
49354 - atomic_read(&tcon->stats.cifs_stats.num_fnext),
49355 - atomic_read(&tcon->stats.cifs_stats.num_fclose));
49356 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_ffirst),
49357 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_fnext),
49358 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_fclose));
49359 #endif
49360 }
49361
49362 diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c
49363 index bceffe7..cd1ae59 100644
49364 --- a/fs/cifs/smb2ops.c
49365 +++ b/fs/cifs/smb2ops.c
49366 @@ -274,8 +274,8 @@ smb2_clear_stats(struct cifs_tcon *tcon)
49367 #ifdef CONFIG_CIFS_STATS
49368 int i;
49369 for (i = 0; i < NUMBER_OF_SMB2_COMMANDS; i++) {
49370 - atomic_set(&tcon->stats.smb2_stats.smb2_com_sent[i], 0);
49371 - atomic_set(&tcon->stats.smb2_stats.smb2_com_failed[i], 0);
49372 + atomic_set_unchecked(&tcon->stats.smb2_stats.smb2_com_sent[i], 0);
49373 + atomic_set_unchecked(&tcon->stats.smb2_stats.smb2_com_failed[i], 0);
49374 }
49375 #endif
49376 }
49377 @@ -284,66 +284,66 @@ static void
49378 smb2_print_stats(struct seq_file *m, struct cifs_tcon *tcon)
49379 {
49380 #ifdef CONFIG_CIFS_STATS
49381 - atomic_t *sent = tcon->stats.smb2_stats.smb2_com_sent;
49382 - atomic_t *failed = tcon->stats.smb2_stats.smb2_com_failed;
49383 + atomic_unchecked_t *sent = tcon->stats.smb2_stats.smb2_com_sent;
49384 + atomic_unchecked_t *failed = tcon->stats.smb2_stats.smb2_com_failed;
49385 seq_printf(m, "\nNegotiates: %d sent %d failed",
49386 - atomic_read(&sent[SMB2_NEGOTIATE_HE]),
49387 - atomic_read(&failed[SMB2_NEGOTIATE_HE]));
49388 + atomic_read_unchecked(&sent[SMB2_NEGOTIATE_HE]),
49389 + atomic_read_unchecked(&failed[SMB2_NEGOTIATE_HE]));
49390 seq_printf(m, "\nSessionSetups: %d sent %d failed",
49391 - atomic_read(&sent[SMB2_SESSION_SETUP_HE]),
49392 - atomic_read(&failed[SMB2_SESSION_SETUP_HE]));
49393 + atomic_read_unchecked(&sent[SMB2_SESSION_SETUP_HE]),
49394 + atomic_read_unchecked(&failed[SMB2_SESSION_SETUP_HE]));
49395 #define SMB2LOGOFF 0x0002 /* trivial request/resp */
49396 seq_printf(m, "\nLogoffs: %d sent %d failed",
49397 - atomic_read(&sent[SMB2_LOGOFF_HE]),
49398 - atomic_read(&failed[SMB2_LOGOFF_HE]));
49399 + atomic_read_unchecked(&sent[SMB2_LOGOFF_HE]),
49400 + atomic_read_unchecked(&failed[SMB2_LOGOFF_HE]));
49401 seq_printf(m, "\nTreeConnects: %d sent %d failed",
49402 - atomic_read(&sent[SMB2_TREE_CONNECT_HE]),
49403 - atomic_read(&failed[SMB2_TREE_CONNECT_HE]));
49404 + atomic_read_unchecked(&sent[SMB2_TREE_CONNECT_HE]),
49405 + atomic_read_unchecked(&failed[SMB2_TREE_CONNECT_HE]));
49406 seq_printf(m, "\nTreeDisconnects: %d sent %d failed",
49407 - atomic_read(&sent[SMB2_TREE_DISCONNECT_HE]),
49408 - atomic_read(&failed[SMB2_TREE_DISCONNECT_HE]));
49409 + atomic_read_unchecked(&sent[SMB2_TREE_DISCONNECT_HE]),
49410 + atomic_read_unchecked(&failed[SMB2_TREE_DISCONNECT_HE]));
49411 seq_printf(m, "\nCreates: %d sent %d failed",
49412 - atomic_read(&sent[SMB2_CREATE_HE]),
49413 - atomic_read(&failed[SMB2_CREATE_HE]));
49414 + atomic_read_unchecked(&sent[SMB2_CREATE_HE]),
49415 + atomic_read_unchecked(&failed[SMB2_CREATE_HE]));
49416 seq_printf(m, "\nCloses: %d sent %d failed",
49417 - atomic_read(&sent[SMB2_CLOSE_HE]),
49418 - atomic_read(&failed[SMB2_CLOSE_HE]));
49419 + atomic_read_unchecked(&sent[SMB2_CLOSE_HE]),
49420 + atomic_read_unchecked(&failed[SMB2_CLOSE_HE]));
49421 seq_printf(m, "\nFlushes: %d sent %d failed",
49422 - atomic_read(&sent[SMB2_FLUSH_HE]),
49423 - atomic_read(&failed[SMB2_FLUSH_HE]));
49424 + atomic_read_unchecked(&sent[SMB2_FLUSH_HE]),
49425 + atomic_read_unchecked(&failed[SMB2_FLUSH_HE]));
49426 seq_printf(m, "\nReads: %d sent %d failed",
49427 - atomic_read(&sent[SMB2_READ_HE]),
49428 - atomic_read(&failed[SMB2_READ_HE]));
49429 + atomic_read_unchecked(&sent[SMB2_READ_HE]),
49430 + atomic_read_unchecked(&failed[SMB2_READ_HE]));
49431 seq_printf(m, "\nWrites: %d sent %d failed",
49432 - atomic_read(&sent[SMB2_WRITE_HE]),
49433 - atomic_read(&failed[SMB2_WRITE_HE]));
49434 + atomic_read_unchecked(&sent[SMB2_WRITE_HE]),
49435 + atomic_read_unchecked(&failed[SMB2_WRITE_HE]));
49436 seq_printf(m, "\nLocks: %d sent %d failed",
49437 - atomic_read(&sent[SMB2_LOCK_HE]),
49438 - atomic_read(&failed[SMB2_LOCK_HE]));
49439 + atomic_read_unchecked(&sent[SMB2_LOCK_HE]),
49440 + atomic_read_unchecked(&failed[SMB2_LOCK_HE]));
49441 seq_printf(m, "\nIOCTLs: %d sent %d failed",
49442 - atomic_read(&sent[SMB2_IOCTL_HE]),
49443 - atomic_read(&failed[SMB2_IOCTL_HE]));
49444 + atomic_read_unchecked(&sent[SMB2_IOCTL_HE]),
49445 + atomic_read_unchecked(&failed[SMB2_IOCTL_HE]));
49446 seq_printf(m, "\nCancels: %d sent %d failed",
49447 - atomic_read(&sent[SMB2_CANCEL_HE]),
49448 - atomic_read(&failed[SMB2_CANCEL_HE]));
49449 + atomic_read_unchecked(&sent[SMB2_CANCEL_HE]),
49450 + atomic_read_unchecked(&failed[SMB2_CANCEL_HE]));
49451 seq_printf(m, "\nEchos: %d sent %d failed",
49452 - atomic_read(&sent[SMB2_ECHO_HE]),
49453 - atomic_read(&failed[SMB2_ECHO_HE]));
49454 + atomic_read_unchecked(&sent[SMB2_ECHO_HE]),
49455 + atomic_read_unchecked(&failed[SMB2_ECHO_HE]));
49456 seq_printf(m, "\nQueryDirectories: %d sent %d failed",
49457 - atomic_read(&sent[SMB2_QUERY_DIRECTORY_HE]),
49458 - atomic_read(&failed[SMB2_QUERY_DIRECTORY_HE]));
49459 + atomic_read_unchecked(&sent[SMB2_QUERY_DIRECTORY_HE]),
49460 + atomic_read_unchecked(&failed[SMB2_QUERY_DIRECTORY_HE]));
49461 seq_printf(m, "\nChangeNotifies: %d sent %d failed",
49462 - atomic_read(&sent[SMB2_CHANGE_NOTIFY_HE]),
49463 - atomic_read(&failed[SMB2_CHANGE_NOTIFY_HE]));
49464 + atomic_read_unchecked(&sent[SMB2_CHANGE_NOTIFY_HE]),
49465 + atomic_read_unchecked(&failed[SMB2_CHANGE_NOTIFY_HE]));
49466 seq_printf(m, "\nQueryInfos: %d sent %d failed",
49467 - atomic_read(&sent[SMB2_QUERY_INFO_HE]),
49468 - atomic_read(&failed[SMB2_QUERY_INFO_HE]));
49469 + atomic_read_unchecked(&sent[SMB2_QUERY_INFO_HE]),
49470 + atomic_read_unchecked(&failed[SMB2_QUERY_INFO_HE]));
49471 seq_printf(m, "\nSetInfos: %d sent %d failed",
49472 - atomic_read(&sent[SMB2_SET_INFO_HE]),
49473 - atomic_read(&failed[SMB2_SET_INFO_HE]));
49474 + atomic_read_unchecked(&sent[SMB2_SET_INFO_HE]),
49475 + atomic_read_unchecked(&failed[SMB2_SET_INFO_HE]));
49476 seq_printf(m, "\nOplockBreaks: %d sent %d failed",
49477 - atomic_read(&sent[SMB2_OPLOCK_BREAK_HE]),
49478 - atomic_read(&failed[SMB2_OPLOCK_BREAK_HE]));
49479 + atomic_read_unchecked(&sent[SMB2_OPLOCK_BREAK_HE]),
49480 + atomic_read_unchecked(&failed[SMB2_OPLOCK_BREAK_HE]));
49481 #endif
49482 }
49483
49484 diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c
49485 index 41d9d07..dbb4772 100644
49486 --- a/fs/cifs/smb2pdu.c
49487 +++ b/fs/cifs/smb2pdu.c
49488 @@ -1761,8 +1761,7 @@ SMB2_query_directory(const unsigned int xid, struct cifs_tcon *tcon,
49489 default:
49490 cERROR(1, "info level %u isn't supported",
49491 srch_inf->info_level);
49492 - rc = -EINVAL;
49493 - goto qdir_exit;
49494 + return -EINVAL;
49495 }
49496
49497 req->FileIndex = cpu_to_le32(index);
49498 diff --git a/fs/coda/cache.c b/fs/coda/cache.c
49499 index 958ae0e..505c9d0 100644
49500 --- a/fs/coda/cache.c
49501 +++ b/fs/coda/cache.c
49502 @@ -24,7 +24,7 @@
49503 #include "coda_linux.h"
49504 #include "coda_cache.h"
49505
49506 -static atomic_t permission_epoch = ATOMIC_INIT(0);
49507 +static atomic_unchecked_t permission_epoch = ATOMIC_INIT(0);
49508
49509 /* replace or extend an acl cache hit */
49510 void coda_cache_enter(struct inode *inode, int mask)
49511 @@ -32,7 +32,7 @@ void coda_cache_enter(struct inode *inode, int mask)
49512 struct coda_inode_info *cii = ITOC(inode);
49513
49514 spin_lock(&cii->c_lock);
49515 - cii->c_cached_epoch = atomic_read(&permission_epoch);
49516 + cii->c_cached_epoch = atomic_read_unchecked(&permission_epoch);
49517 if (cii->c_uid != current_fsuid()) {
49518 cii->c_uid = current_fsuid();
49519 cii->c_cached_perm = mask;
49520 @@ -46,14 +46,14 @@ void coda_cache_clear_inode(struct inode *inode)
49521 {
49522 struct coda_inode_info *cii = ITOC(inode);
49523 spin_lock(&cii->c_lock);
49524 - cii->c_cached_epoch = atomic_read(&permission_epoch) - 1;
49525 + cii->c_cached_epoch = atomic_read_unchecked(&permission_epoch) - 1;
49526 spin_unlock(&cii->c_lock);
49527 }
49528
49529 /* remove all acl caches */
49530 void coda_cache_clear_all(struct super_block *sb)
49531 {
49532 - atomic_inc(&permission_epoch);
49533 + atomic_inc_unchecked(&permission_epoch);
49534 }
49535
49536
49537 @@ -66,7 +66,7 @@ int coda_cache_check(struct inode *inode, int mask)
49538 spin_lock(&cii->c_lock);
49539 hit = (mask & cii->c_cached_perm) == mask &&
49540 cii->c_uid == current_fsuid() &&
49541 - cii->c_cached_epoch == atomic_read(&permission_epoch);
49542 + cii->c_cached_epoch == atomic_read_unchecked(&permission_epoch);
49543 spin_unlock(&cii->c_lock);
49544
49545 return hit;
49546 diff --git a/fs/compat.c b/fs/compat.c
49547 index a06dcbc..dacb6d3 100644
49548 --- a/fs/compat.c
49549 +++ b/fs/compat.c
49550 @@ -54,7 +54,7 @@
49551 #include <asm/ioctls.h>
49552 #include "internal.h"
49553
49554 -int compat_log = 1;
49555 +int compat_log = 0;
49556
49557 int compat_printk(const char *fmt, ...)
49558 {
49559 @@ -490,7 +490,7 @@ compat_sys_io_setup(unsigned nr_reqs, u32 __user *ctx32p)
49560
49561 set_fs(KERNEL_DS);
49562 /* The __user pointer cast is valid because of the set_fs() */
49563 - ret = sys_io_setup(nr_reqs, (aio_context_t __user *) &ctx64);
49564 + ret = sys_io_setup(nr_reqs, (aio_context_t __force_user *) &ctx64);
49565 set_fs(oldfs);
49566 /* truncating is ok because it's a user address */
49567 if (!ret)
49568 @@ -548,7 +548,7 @@ ssize_t compat_rw_copy_check_uvector(int type,
49569 goto out;
49570
49571 ret = -EINVAL;
49572 - if (nr_segs > UIO_MAXIOV || nr_segs < 0)
49573 + if (nr_segs > UIO_MAXIOV)
49574 goto out;
49575 if (nr_segs > fast_segs) {
49576 ret = -ENOMEM;
49577 @@ -835,6 +835,7 @@ struct compat_old_linux_dirent {
49578
49579 struct compat_readdir_callback {
49580 struct compat_old_linux_dirent __user *dirent;
49581 + struct file * file;
49582 int result;
49583 };
49584
49585 @@ -852,6 +853,10 @@ static int compat_fillonedir(void *__buf, const char *name, int namlen,
49586 buf->result = -EOVERFLOW;
49587 return -EOVERFLOW;
49588 }
49589 +
49590 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
49591 + return 0;
49592 +
49593 buf->result++;
49594 dirent = buf->dirent;
49595 if (!access_ok(VERIFY_WRITE, dirent,
49596 @@ -882,6 +887,7 @@ asmlinkage long compat_sys_old_readdir(unsigned int fd,
49597
49598 buf.result = 0;
49599 buf.dirent = dirent;
49600 + buf.file = f.file;
49601
49602 error = vfs_readdir(f.file, compat_fillonedir, &buf);
49603 if (buf.result)
49604 @@ -901,6 +907,7 @@ struct compat_linux_dirent {
49605 struct compat_getdents_callback {
49606 struct compat_linux_dirent __user *current_dir;
49607 struct compat_linux_dirent __user *previous;
49608 + struct file * file;
49609 int count;
49610 int error;
49611 };
49612 @@ -922,6 +929,10 @@ static int compat_filldir(void *__buf, const char *name, int namlen,
49613 buf->error = -EOVERFLOW;
49614 return -EOVERFLOW;
49615 }
49616 +
49617 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
49618 + return 0;
49619 +
49620 dirent = buf->previous;
49621 if (dirent) {
49622 if (__put_user(offset, &dirent->d_off))
49623 @@ -967,6 +978,7 @@ asmlinkage long compat_sys_getdents(unsigned int fd,
49624 buf.previous = NULL;
49625 buf.count = count;
49626 buf.error = 0;
49627 + buf.file = f.file;
49628
49629 error = vfs_readdir(f.file, compat_filldir, &buf);
49630 if (error >= 0)
49631 @@ -987,6 +999,7 @@ asmlinkage long compat_sys_getdents(unsigned int fd,
49632 struct compat_getdents_callback64 {
49633 struct linux_dirent64 __user *current_dir;
49634 struct linux_dirent64 __user *previous;
49635 + struct file * file;
49636 int count;
49637 int error;
49638 };
49639 @@ -1003,6 +1016,10 @@ static int compat_filldir64(void * __buf, const char * name, int namlen, loff_t
49640 buf->error = -EINVAL; /* only used if we fail.. */
49641 if (reclen > buf->count)
49642 return -EINVAL;
49643 +
49644 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
49645 + return 0;
49646 +
49647 dirent = buf->previous;
49648
49649 if (dirent) {
49650 @@ -1052,13 +1069,14 @@ asmlinkage long compat_sys_getdents64(unsigned int fd,
49651 buf.previous = NULL;
49652 buf.count = count;
49653 buf.error = 0;
49654 + buf.file = f.file;
49655
49656 error = vfs_readdir(f.file, compat_filldir64, &buf);
49657 if (error >= 0)
49658 error = buf.error;
49659 lastdirent = buf.previous;
49660 if (lastdirent) {
49661 - typeof(lastdirent->d_off) d_off = f.file->f_pos;
49662 + typeof(((struct linux_dirent64 *)0)->d_off) d_off = f.file->f_pos;
49663 if (__put_user_unaligned(d_off, &lastdirent->d_off))
49664 error = -EFAULT;
49665 else
49666 diff --git a/fs/compat_binfmt_elf.c b/fs/compat_binfmt_elf.c
49667 index a81147e..20bf2b5 100644
49668 --- a/fs/compat_binfmt_elf.c
49669 +++ b/fs/compat_binfmt_elf.c
49670 @@ -30,11 +30,13 @@
49671 #undef elf_phdr
49672 #undef elf_shdr
49673 #undef elf_note
49674 +#undef elf_dyn
49675 #undef elf_addr_t
49676 #define elfhdr elf32_hdr
49677 #define elf_phdr elf32_phdr
49678 #define elf_shdr elf32_shdr
49679 #define elf_note elf32_note
49680 +#define elf_dyn Elf32_Dyn
49681 #define elf_addr_t Elf32_Addr
49682
49683 /*
49684 diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c
49685 index e2f57a0..3c78771 100644
49686 --- a/fs/compat_ioctl.c
49687 +++ b/fs/compat_ioctl.c
49688 @@ -623,7 +623,7 @@ static int serial_struct_ioctl(unsigned fd, unsigned cmd,
49689 return -EFAULT;
49690 if (__get_user(udata, &ss32->iomem_base))
49691 return -EFAULT;
49692 - ss.iomem_base = compat_ptr(udata);
49693 + ss.iomem_base = (unsigned char __force_kernel *)compat_ptr(udata);
49694 if (__get_user(ss.iomem_reg_shift, &ss32->iomem_reg_shift) ||
49695 __get_user(ss.port_high, &ss32->port_high))
49696 return -EFAULT;
49697 @@ -798,7 +798,7 @@ static int compat_ioctl_preallocate(struct file *file,
49698 copy_in_user(&p->l_len, &p32->l_len, sizeof(s64)) ||
49699 copy_in_user(&p->l_sysid, &p32->l_sysid, sizeof(s32)) ||
49700 copy_in_user(&p->l_pid, &p32->l_pid, sizeof(u32)) ||
49701 - copy_in_user(&p->l_pad, &p32->l_pad, 4*sizeof(u32)))
49702 + copy_in_user(p->l_pad, &p32->l_pad, 4*sizeof(u32)))
49703 return -EFAULT;
49704
49705 return ioctl_preallocate(file, p);
49706 @@ -1620,8 +1620,8 @@ asmlinkage long compat_sys_ioctl(unsigned int fd, unsigned int cmd,
49707 static int __init init_sys32_ioctl_cmp(const void *p, const void *q)
49708 {
49709 unsigned int a, b;
49710 - a = *(unsigned int *)p;
49711 - b = *(unsigned int *)q;
49712 + a = *(const unsigned int *)p;
49713 + b = *(const unsigned int *)q;
49714 if (a > b)
49715 return 1;
49716 if (a < b)
49717 diff --git a/fs/configfs/dir.c b/fs/configfs/dir.c
49718 index 712b10f..c33c4ca 100644
49719 --- a/fs/configfs/dir.c
49720 +++ b/fs/configfs/dir.c
49721 @@ -1037,10 +1037,11 @@ static int configfs_dump(struct configfs_dirent *sd, int level)
49722 static int configfs_depend_prep(struct dentry *origin,
49723 struct config_item *target)
49724 {
49725 - struct configfs_dirent *child_sd, *sd = origin->d_fsdata;
49726 + struct configfs_dirent *child_sd, *sd;
49727 int ret = 0;
49728
49729 - BUG_ON(!origin || !sd);
49730 + BUG_ON(!origin || !origin->d_fsdata);
49731 + sd = origin->d_fsdata;
49732
49733 if (sd->s_element == target) /* Boo-yah */
49734 goto out;
49735 @@ -1564,7 +1565,8 @@ static int configfs_readdir(struct file * filp, void * dirent, filldir_t filldir
49736 }
49737 for (p=q->next; p!= &parent_sd->s_children; p=p->next) {
49738 struct configfs_dirent *next;
49739 - const char * name;
49740 + const unsigned char * name;
49741 + char d_name[sizeof(next->s_dentry->d_iname)];
49742 int len;
49743 struct inode *inode = NULL;
49744
49745 @@ -1574,7 +1576,12 @@ static int configfs_readdir(struct file * filp, void * dirent, filldir_t filldir
49746 continue;
49747
49748 name = configfs_get_name(next);
49749 - len = strlen(name);
49750 + if (next->s_dentry && name == next->s_dentry->d_iname) {
49751 + len = next->s_dentry->d_name.len;
49752 + memcpy(d_name, name, len);
49753 + name = d_name;
49754 + } else
49755 + len = strlen(name);
49756
49757 /*
49758 * We'll have a dentry and an inode for
49759 diff --git a/fs/coredump.c b/fs/coredump.c
49760 index 1774932..5812106 100644
49761 --- a/fs/coredump.c
49762 +++ b/fs/coredump.c
49763 @@ -52,7 +52,7 @@ struct core_name {
49764 char *corename;
49765 int used, size;
49766 };
49767 -static atomic_t call_count = ATOMIC_INIT(1);
49768 +static atomic_unchecked_t call_count = ATOMIC_INIT(1);
49769
49770 /* The maximal length of core_pattern is also specified in sysctl.c */
49771
49772 @@ -60,7 +60,7 @@ static int expand_corename(struct core_name *cn)
49773 {
49774 char *old_corename = cn->corename;
49775
49776 - cn->size = CORENAME_MAX_SIZE * atomic_inc_return(&call_count);
49777 + cn->size = CORENAME_MAX_SIZE * atomic_inc_return_unchecked(&call_count);
49778 cn->corename = krealloc(old_corename, cn->size, GFP_KERNEL);
49779
49780 if (!cn->corename) {
49781 @@ -157,7 +157,7 @@ static int format_corename(struct core_name *cn, struct coredump_params *cprm)
49782 int pid_in_pattern = 0;
49783 int err = 0;
49784
49785 - cn->size = CORENAME_MAX_SIZE * atomic_read(&call_count);
49786 + cn->size = CORENAME_MAX_SIZE * atomic_read_unchecked(&call_count);
49787 cn->corename = kmalloc(cn->size, GFP_KERNEL);
49788 cn->used = 0;
49789
49790 @@ -414,17 +414,17 @@ static void wait_for_dump_helpers(struct file *file)
49791 pipe = file->f_path.dentry->d_inode->i_pipe;
49792
49793 pipe_lock(pipe);
49794 - pipe->readers++;
49795 - pipe->writers--;
49796 + atomic_inc(&pipe->readers);
49797 + atomic_dec(&pipe->writers);
49798
49799 - while ((pipe->readers > 1) && (!signal_pending(current))) {
49800 + while ((atomic_read(&pipe->readers) > 1) && (!signal_pending(current))) {
49801 wake_up_interruptible_sync(&pipe->wait);
49802 kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN);
49803 pipe_wait(pipe);
49804 }
49805
49806 - pipe->readers--;
49807 - pipe->writers++;
49808 + atomic_dec(&pipe->readers);
49809 + atomic_inc(&pipe->writers);
49810 pipe_unlock(pipe);
49811
49812 }
49813 @@ -471,7 +471,8 @@ void do_coredump(siginfo_t *siginfo)
49814 int ispipe;
49815 struct files_struct *displaced;
49816 bool need_nonrelative = false;
49817 - static atomic_t core_dump_count = ATOMIC_INIT(0);
49818 + static atomic_unchecked_t core_dump_count = ATOMIC_INIT(0);
49819 + long signr = siginfo->si_signo;
49820 struct coredump_params cprm = {
49821 .siginfo = siginfo,
49822 .regs = signal_pt_regs(),
49823 @@ -484,7 +485,10 @@ void do_coredump(siginfo_t *siginfo)
49824 .mm_flags = mm->flags,
49825 };
49826
49827 - audit_core_dumps(siginfo->si_signo);
49828 + audit_core_dumps(signr);
49829 +
49830 + if (signr == SIGSEGV || signr == SIGBUS || signr == SIGKILL || signr == SIGILL)
49831 + gr_handle_brute_attach(cprm.mm_flags);
49832
49833 binfmt = mm->binfmt;
49834 if (!binfmt || !binfmt->core_dump)
49835 @@ -508,7 +512,7 @@ void do_coredump(siginfo_t *siginfo)
49836 need_nonrelative = true;
49837 }
49838
49839 - retval = coredump_wait(siginfo->si_signo, &core_state);
49840 + retval = coredump_wait(signr, &core_state);
49841 if (retval < 0)
49842 goto fail_creds;
49843
49844 @@ -556,7 +560,7 @@ void do_coredump(siginfo_t *siginfo)
49845 }
49846 cprm.limit = RLIM_INFINITY;
49847
49848 - dump_count = atomic_inc_return(&core_dump_count);
49849 + dump_count = atomic_inc_return_unchecked(&core_dump_count);
49850 if (core_pipe_limit && (core_pipe_limit < dump_count)) {
49851 printk(KERN_WARNING "Pid %d(%s) over core_pipe_limit\n",
49852 task_tgid_vnr(current), current->comm);
49853 @@ -583,6 +587,8 @@ void do_coredump(siginfo_t *siginfo)
49854 } else {
49855 struct inode *inode;
49856
49857 + gr_learn_resource(current, RLIMIT_CORE, binfmt->min_coredump, 1);
49858 +
49859 if (cprm.limit < binfmt->min_coredump)
49860 goto fail_unlock;
49861
49862 @@ -640,7 +646,7 @@ close_fail:
49863 filp_close(cprm.file, NULL);
49864 fail_dropcount:
49865 if (ispipe)
49866 - atomic_dec(&core_dump_count);
49867 + atomic_dec_unchecked(&core_dump_count);
49868 fail_unlock:
49869 kfree(cn.corename);
49870 fail_corename:
49871 @@ -659,7 +665,7 @@ fail:
49872 */
49873 int dump_write(struct file *file, const void *addr, int nr)
49874 {
49875 - return access_ok(VERIFY_READ, addr, nr) && file->f_op->write(file, addr, nr, &file->f_pos) == nr;
49876 + return access_ok(VERIFY_READ, addr, nr) && file->f_op->write(file, (const char __force_user *)addr, nr, &file->f_pos) == nr;
49877 }
49878 EXPORT_SYMBOL(dump_write);
49879
49880 diff --git a/fs/dcache.c b/fs/dcache.c
49881 index 19153a0..428c2f5 100644
49882 --- a/fs/dcache.c
49883 +++ b/fs/dcache.c
49884 @@ -3133,7 +3133,7 @@ void __init vfs_caches_init(unsigned long mempages)
49885 mempages -= reserve;
49886
49887 names_cachep = kmem_cache_create("names_cache", PATH_MAX, 0,
49888 - SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
49889 + SLAB_HWCACHE_ALIGN|SLAB_PANIC|SLAB_USERCOPY, NULL);
49890
49891 dcache_init();
49892 inode_init();
49893 diff --git a/fs/debugfs/inode.c b/fs/debugfs/inode.c
49894 index a5f12b7..4ee8a6f 100644
49895 --- a/fs/debugfs/inode.c
49896 +++ b/fs/debugfs/inode.c
49897 @@ -415,7 +415,11 @@ EXPORT_SYMBOL_GPL(debugfs_create_file);
49898 */
49899 struct dentry *debugfs_create_dir(const char *name, struct dentry *parent)
49900 {
49901 +#ifdef CONFIG_GRKERNSEC_SYSFS_RESTRICT
49902 + return __create_file(name, S_IFDIR | S_IRWXU,
49903 +#else
49904 return __create_file(name, S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO,
49905 +#endif
49906 parent, NULL, NULL);
49907 }
49908 EXPORT_SYMBOL_GPL(debugfs_create_dir);
49909 diff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c
49910 index cc7709e..7e7211f 100644
49911 --- a/fs/ecryptfs/inode.c
49912 +++ b/fs/ecryptfs/inode.c
49913 @@ -674,7 +674,7 @@ static int ecryptfs_readlink_lower(struct dentry *dentry, char **buf,
49914 old_fs = get_fs();
49915 set_fs(get_ds());
49916 rc = lower_dentry->d_inode->i_op->readlink(lower_dentry,
49917 - (char __user *)lower_buf,
49918 + (char __force_user *)lower_buf,
49919 PATH_MAX);
49920 set_fs(old_fs);
49921 if (rc < 0)
49922 @@ -706,7 +706,7 @@ out:
49923 static void
49924 ecryptfs_put_link(struct dentry *dentry, struct nameidata *nd, void *ptr)
49925 {
49926 - char *buf = nd_get_link(nd);
49927 + const char *buf = nd_get_link(nd);
49928 if (!IS_ERR(buf)) {
49929 /* Free the char* */
49930 kfree(buf);
49931 diff --git a/fs/ecryptfs/miscdev.c b/fs/ecryptfs/miscdev.c
49932 index 412e6ed..4292d22 100644
49933 --- a/fs/ecryptfs/miscdev.c
49934 +++ b/fs/ecryptfs/miscdev.c
49935 @@ -315,7 +315,7 @@ check_list:
49936 goto out_unlock_msg_ctx;
49937 i = PKT_TYPE_SIZE + PKT_CTR_SIZE;
49938 if (msg_ctx->msg) {
49939 - if (copy_to_user(&buf[i], packet_length, packet_length_size))
49940 + if (packet_length_size > sizeof(packet_length) || copy_to_user(&buf[i], packet_length, packet_length_size))
49941 goto out_unlock_msg_ctx;
49942 i += packet_length_size;
49943 if (copy_to_user(&buf[i], msg_ctx->msg, msg_ctx->msg_size))
49944 diff --git a/fs/ecryptfs/read_write.c b/fs/ecryptfs/read_write.c
49945 index b2a34a1..162fa69 100644
49946 --- a/fs/ecryptfs/read_write.c
49947 +++ b/fs/ecryptfs/read_write.c
49948 @@ -48,7 +48,7 @@ int ecryptfs_write_lower(struct inode *ecryptfs_inode, char *data,
49949 return -EIO;
49950 fs_save = get_fs();
49951 set_fs(get_ds());
49952 - rc = vfs_write(lower_file, data, size, &offset);
49953 + rc = vfs_write(lower_file, (const char __force_user *)data, size, &offset);
49954 set_fs(fs_save);
49955 mark_inode_dirty_sync(ecryptfs_inode);
49956 return rc;
49957 @@ -244,7 +244,7 @@ int ecryptfs_read_lower(char *data, loff_t offset, size_t size,
49958 return -EIO;
49959 fs_save = get_fs();
49960 set_fs(get_ds());
49961 - rc = vfs_read(lower_file, data, size, &offset);
49962 + rc = vfs_read(lower_file, (char __force_user *)data, size, &offset);
49963 set_fs(fs_save);
49964 return rc;
49965 }
49966 diff --git a/fs/exec.c b/fs/exec.c
49967 index 20df02c..09b65a1 100644
49968 --- a/fs/exec.c
49969 +++ b/fs/exec.c
49970 @@ -55,6 +55,17 @@
49971 #include <linux/pipe_fs_i.h>
49972 #include <linux/oom.h>
49973 #include <linux/compat.h>
49974 +#include <linux/random.h>
49975 +#include <linux/seq_file.h>
49976 +#include <linux/coredump.h>
49977 +#include <linux/mman.h>
49978 +
49979 +#ifdef CONFIG_PAX_REFCOUNT
49980 +#include <linux/kallsyms.h>
49981 +#include <linux/kdebug.h>
49982 +#endif
49983 +
49984 +#include <trace/events/fs.h>
49985
49986 #include <asm/uaccess.h>
49987 #include <asm/mmu_context.h>
49988 @@ -66,6 +77,18 @@
49989
49990 #include <trace/events/sched.h>
49991
49992 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
49993 +void __weak pax_set_initial_flags(struct linux_binprm *bprm)
49994 +{
49995 + 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");
49996 +}
49997 +#endif
49998 +
49999 +#ifdef CONFIG_PAX_HOOK_ACL_FLAGS
50000 +void (*pax_set_initial_flags_func)(struct linux_binprm *bprm);
50001 +EXPORT_SYMBOL(pax_set_initial_flags_func);
50002 +#endif
50003 +
50004 int suid_dumpable = 0;
50005
50006 static LIST_HEAD(formats);
50007 @@ -75,8 +98,8 @@ void __register_binfmt(struct linux_binfmt * fmt, int insert)
50008 {
50009 BUG_ON(!fmt);
50010 write_lock(&binfmt_lock);
50011 - insert ? list_add(&fmt->lh, &formats) :
50012 - list_add_tail(&fmt->lh, &formats);
50013 + insert ? pax_list_add((struct list_head *)&fmt->lh, &formats) :
50014 + pax_list_add_tail((struct list_head *)&fmt->lh, &formats);
50015 write_unlock(&binfmt_lock);
50016 }
50017
50018 @@ -85,7 +108,7 @@ EXPORT_SYMBOL(__register_binfmt);
50019 void unregister_binfmt(struct linux_binfmt * fmt)
50020 {
50021 write_lock(&binfmt_lock);
50022 - list_del(&fmt->lh);
50023 + pax_list_del((struct list_head *)&fmt->lh);
50024 write_unlock(&binfmt_lock);
50025 }
50026
50027 @@ -180,18 +203,10 @@ static struct page *get_arg_page(struct linux_binprm *bprm, unsigned long pos,
50028 int write)
50029 {
50030 struct page *page;
50031 - int ret;
50032
50033 -#ifdef CONFIG_STACK_GROWSUP
50034 - if (write) {
50035 - ret = expand_downwards(bprm->vma, pos);
50036 - if (ret < 0)
50037 - return NULL;
50038 - }
50039 -#endif
50040 - ret = get_user_pages(current, bprm->mm, pos,
50041 - 1, write, 1, &page, NULL);
50042 - if (ret <= 0)
50043 + if (0 > expand_downwards(bprm->vma, pos))
50044 + return NULL;
50045 + if (0 >= get_user_pages(current, bprm->mm, pos, 1, write, 1, &page, NULL))
50046 return NULL;
50047
50048 if (write) {
50049 @@ -207,6 +222,17 @@ static struct page *get_arg_page(struct linux_binprm *bprm, unsigned long pos,
50050 if (size <= ARG_MAX)
50051 return page;
50052
50053 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
50054 + // only allow 512KB for argv+env on suid/sgid binaries
50055 + // to prevent easy ASLR exhaustion
50056 + if (((!uid_eq(bprm->cred->euid, current_euid())) ||
50057 + (!gid_eq(bprm->cred->egid, current_egid()))) &&
50058 + (size > (512 * 1024))) {
50059 + put_page(page);
50060 + return NULL;
50061 + }
50062 +#endif
50063 +
50064 /*
50065 * Limit to 1/4-th the stack size for the argv+env strings.
50066 * This ensures that:
50067 @@ -266,6 +292,11 @@ static int __bprm_mm_init(struct linux_binprm *bprm)
50068 vma->vm_end = STACK_TOP_MAX;
50069 vma->vm_start = vma->vm_end - PAGE_SIZE;
50070 vma->vm_flags = VM_STACK_FLAGS | VM_STACK_INCOMPLETE_SETUP;
50071 +
50072 +#ifdef CONFIG_PAX_SEGMEXEC
50073 + vma->vm_flags &= ~(VM_EXEC | VM_MAYEXEC);
50074 +#endif
50075 +
50076 vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
50077 INIT_LIST_HEAD(&vma->anon_vma_chain);
50078
50079 @@ -276,6 +307,12 @@ static int __bprm_mm_init(struct linux_binprm *bprm)
50080 mm->stack_vm = mm->total_vm = 1;
50081 up_write(&mm->mmap_sem);
50082 bprm->p = vma->vm_end - sizeof(void *);
50083 +
50084 +#ifdef CONFIG_PAX_RANDUSTACK
50085 + if (randomize_va_space)
50086 + bprm->p ^= random32() & ~PAGE_MASK;
50087 +#endif
50088 +
50089 return 0;
50090 err:
50091 up_write(&mm->mmap_sem);
50092 @@ -396,7 +433,7 @@ struct user_arg_ptr {
50093 } ptr;
50094 };
50095
50096 -static const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr)
50097 +const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr)
50098 {
50099 const char __user *native;
50100
50101 @@ -405,14 +442,14 @@ static const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr)
50102 compat_uptr_t compat;
50103
50104 if (get_user(compat, argv.ptr.compat + nr))
50105 - return ERR_PTR(-EFAULT);
50106 + return (const char __force_user *)ERR_PTR(-EFAULT);
50107
50108 return compat_ptr(compat);
50109 }
50110 #endif
50111
50112 if (get_user(native, argv.ptr.native + nr))
50113 - return ERR_PTR(-EFAULT);
50114 + return (const char __force_user *)ERR_PTR(-EFAULT);
50115
50116 return native;
50117 }
50118 @@ -431,7 +468,7 @@ static int count(struct user_arg_ptr argv, int max)
50119 if (!p)
50120 break;
50121
50122 - if (IS_ERR(p))
50123 + if (IS_ERR((const char __force_kernel *)p))
50124 return -EFAULT;
50125
50126 if (i >= max)
50127 @@ -466,7 +503,7 @@ static int copy_strings(int argc, struct user_arg_ptr argv,
50128
50129 ret = -EFAULT;
50130 str = get_user_arg_ptr(argv, argc);
50131 - if (IS_ERR(str))
50132 + if (IS_ERR((const char __force_kernel *)str))
50133 goto out;
50134
50135 len = strnlen_user(str, MAX_ARG_STRLEN);
50136 @@ -548,7 +585,7 @@ int copy_strings_kernel(int argc, const char *const *__argv,
50137 int r;
50138 mm_segment_t oldfs = get_fs();
50139 struct user_arg_ptr argv = {
50140 - .ptr.native = (const char __user *const __user *)__argv,
50141 + .ptr.native = (const char __force_user *const __force_user *)__argv,
50142 };
50143
50144 set_fs(KERNEL_DS);
50145 @@ -583,7 +620,8 @@ static int shift_arg_pages(struct vm_area_struct *vma, unsigned long shift)
50146 unsigned long new_end = old_end - shift;
50147 struct mmu_gather tlb;
50148
50149 - BUG_ON(new_start > new_end);
50150 + if (new_start >= new_end || new_start < mmap_min_addr)
50151 + return -ENOMEM;
50152
50153 /*
50154 * ensure there are no vmas between where we want to go
50155 @@ -592,6 +630,10 @@ static int shift_arg_pages(struct vm_area_struct *vma, unsigned long shift)
50156 if (vma != find_vma(mm, new_start))
50157 return -EFAULT;
50158
50159 +#ifdef CONFIG_PAX_SEGMEXEC
50160 + BUG_ON(pax_find_mirror_vma(vma));
50161 +#endif
50162 +
50163 /*
50164 * cover the whole range: [new_start, old_end)
50165 */
50166 @@ -672,10 +714,6 @@ int setup_arg_pages(struct linux_binprm *bprm,
50167 stack_top = arch_align_stack(stack_top);
50168 stack_top = PAGE_ALIGN(stack_top);
50169
50170 - if (unlikely(stack_top < mmap_min_addr) ||
50171 - unlikely(vma->vm_end - vma->vm_start >= stack_top - mmap_min_addr))
50172 - return -ENOMEM;
50173 -
50174 stack_shift = vma->vm_end - stack_top;
50175
50176 bprm->p -= stack_shift;
50177 @@ -687,8 +725,28 @@ int setup_arg_pages(struct linux_binprm *bprm,
50178 bprm->exec -= stack_shift;
50179
50180 down_write(&mm->mmap_sem);
50181 +
50182 + /* Move stack pages down in memory. */
50183 + if (stack_shift) {
50184 + ret = shift_arg_pages(vma, stack_shift);
50185 + if (ret)
50186 + goto out_unlock;
50187 + }
50188 +
50189 vm_flags = VM_STACK_FLAGS;
50190
50191 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
50192 + if (mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
50193 + vm_flags &= ~VM_EXEC;
50194 +
50195 +#ifdef CONFIG_PAX_MPROTECT
50196 + if (mm->pax_flags & MF_PAX_MPROTECT)
50197 + vm_flags &= ~VM_MAYEXEC;
50198 +#endif
50199 +
50200 + }
50201 +#endif
50202 +
50203 /*
50204 * Adjust stack execute permissions; explicitly enable for
50205 * EXSTACK_ENABLE_X, disable for EXSTACK_DISABLE_X and leave alone
50206 @@ -707,13 +765,6 @@ int setup_arg_pages(struct linux_binprm *bprm,
50207 goto out_unlock;
50208 BUG_ON(prev != vma);
50209
50210 - /* Move stack pages down in memory. */
50211 - if (stack_shift) {
50212 - ret = shift_arg_pages(vma, stack_shift);
50213 - if (ret)
50214 - goto out_unlock;
50215 - }
50216 -
50217 /* mprotect_fixup is overkill to remove the temporary stack flags */
50218 vma->vm_flags &= ~VM_STACK_INCOMPLETE_SETUP;
50219
50220 @@ -737,6 +788,27 @@ int setup_arg_pages(struct linux_binprm *bprm,
50221 #endif
50222 current->mm->start_stack = bprm->p;
50223 ret = expand_stack(vma, stack_base);
50224 +
50225 +#if !defined(CONFIG_STACK_GROWSUP) && defined(CONFIG_PAX_RANDMMAP)
50226 + if (!ret && (mm->pax_flags & MF_PAX_RANDMMAP) && STACK_TOP <= 0xFFFFFFFFU && STACK_TOP > vma->vm_end) {
50227 + unsigned long size, flags, vm_flags;
50228 +
50229 + size = STACK_TOP - vma->vm_end;
50230 + flags = MAP_FIXED | MAP_PRIVATE;
50231 + vm_flags = VM_NONE | VM_DONTEXPAND | VM_DONTDUMP;
50232 +
50233 + ret = vma->vm_end != mmap_region(NULL, vma->vm_end, size, flags, vm_flags, 0);
50234 +
50235 +#ifdef CONFIG_X86
50236 + if (!ret) {
50237 + size = mmap_min_addr + ((mm->delta_mmap ^ mm->delta_stack) & (0xFFUL << PAGE_SHIFT));
50238 + ret = 0 != mmap_region(NULL, 0, PAGE_ALIGN(size), flags, vm_flags, 0);
50239 + }
50240 +#endif
50241 +
50242 + }
50243 +#endif
50244 +
50245 if (ret)
50246 ret = -EFAULT;
50247
50248 @@ -772,6 +844,8 @@ struct file *open_exec(const char *name)
50249
50250 fsnotify_open(file);
50251
50252 + trace_open_exec(name);
50253 +
50254 err = deny_write_access(file);
50255 if (err)
50256 goto exit;
50257 @@ -795,7 +869,7 @@ int kernel_read(struct file *file, loff_t offset,
50258 old_fs = get_fs();
50259 set_fs(get_ds());
50260 /* The cast to a user pointer is valid due to the set_fs() */
50261 - result = vfs_read(file, (void __user *)addr, count, &pos);
50262 + result = vfs_read(file, (void __force_user *)addr, count, &pos);
50263 set_fs(old_fs);
50264 return result;
50265 }
50266 @@ -1247,7 +1321,7 @@ static int check_unsafe_exec(struct linux_binprm *bprm)
50267 }
50268 rcu_read_unlock();
50269
50270 - if (p->fs->users > n_fs) {
50271 + if (atomic_read(&p->fs->users) > n_fs) {
50272 bprm->unsafe |= LSM_UNSAFE_SHARE;
50273 } else {
50274 res = -EAGAIN;
50275 @@ -1447,6 +1521,31 @@ int search_binary_handler(struct linux_binprm *bprm)
50276
50277 EXPORT_SYMBOL(search_binary_handler);
50278
50279 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
50280 +static DEFINE_PER_CPU(u64, exec_counter);
50281 +static int __init init_exec_counters(void)
50282 +{
50283 + unsigned int cpu;
50284 +
50285 + for_each_possible_cpu(cpu) {
50286 + per_cpu(exec_counter, cpu) = (u64)cpu;
50287 + }
50288 +
50289 + return 0;
50290 +}
50291 +early_initcall(init_exec_counters);
50292 +static inline void increment_exec_counter(void)
50293 +{
50294 + BUILD_BUG_ON(NR_CPUS > (1 << 16));
50295 + current->exec_id = this_cpu_add_return(exec_counter, 1 << 16);
50296 +}
50297 +#else
50298 +static inline void increment_exec_counter(void) {}
50299 +#endif
50300 +
50301 +extern void gr_handle_exec_args(struct linux_binprm *bprm,
50302 + struct user_arg_ptr argv);
50303 +
50304 /*
50305 * sys_execve() executes a new program.
50306 */
50307 @@ -1454,6 +1553,11 @@ static int do_execve_common(const char *filename,
50308 struct user_arg_ptr argv,
50309 struct user_arg_ptr envp)
50310 {
50311 +#ifdef CONFIG_GRKERNSEC
50312 + struct file *old_exec_file;
50313 + struct acl_subject_label *old_acl;
50314 + struct rlimit old_rlim[RLIM_NLIMITS];
50315 +#endif
50316 struct linux_binprm *bprm;
50317 struct file *file;
50318 struct files_struct *displaced;
50319 @@ -1461,6 +1565,8 @@ static int do_execve_common(const char *filename,
50320 int retval;
50321 const struct cred *cred = current_cred();
50322
50323 + gr_learn_resource(current, RLIMIT_NPROC, atomic_read(&current->cred->user->processes), 1);
50324 +
50325 /*
50326 * We move the actual failure in case of RLIMIT_NPROC excess from
50327 * set*uid() to execve() because too many poorly written programs
50328 @@ -1501,12 +1607,27 @@ static int do_execve_common(const char *filename,
50329 if (IS_ERR(file))
50330 goto out_unmark;
50331
50332 + if (gr_ptrace_readexec(file, bprm->unsafe)) {
50333 + retval = -EPERM;
50334 + goto out_file;
50335 + }
50336 +
50337 sched_exec();
50338
50339 bprm->file = file;
50340 bprm->filename = filename;
50341 bprm->interp = filename;
50342
50343 + if (gr_process_user_ban()) {
50344 + retval = -EPERM;
50345 + goto out_file;
50346 + }
50347 +
50348 + if (!gr_acl_handle_execve(file->f_dentry, file->f_vfsmnt)) {
50349 + retval = -EACCES;
50350 + goto out_file;
50351 + }
50352 +
50353 retval = bprm_mm_init(bprm);
50354 if (retval)
50355 goto out_file;
50356 @@ -1523,24 +1644,65 @@ static int do_execve_common(const char *filename,
50357 if (retval < 0)
50358 goto out;
50359
50360 +#ifdef CONFIG_GRKERNSEC
50361 + old_acl = current->acl;
50362 + memcpy(old_rlim, current->signal->rlim, sizeof(old_rlim));
50363 + old_exec_file = current->exec_file;
50364 + get_file(file);
50365 + current->exec_file = file;
50366 +#endif
50367 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
50368 + /* limit suid stack to 8MB
50369 + * we saved the old limits above and will restore them if this exec fails
50370 + */
50371 + if (((!uid_eq(bprm->cred->euid, current_euid())) || (!gid_eq(bprm->cred->egid, current_egid()))) &&
50372 + (old_rlim[RLIMIT_STACK].rlim_cur > (8 * 1024 * 1024)))
50373 + current->signal->rlim[RLIMIT_STACK].rlim_cur = 8 * 1024 * 1024;
50374 +#endif
50375 +
50376 + if (!gr_tpe_allow(file)) {
50377 + retval = -EACCES;
50378 + goto out_fail;
50379 + }
50380 +
50381 + if (gr_check_crash_exec(file)) {
50382 + retval = -EACCES;
50383 + goto out_fail;
50384 + }
50385 +
50386 + retval = gr_set_proc_label(file->f_dentry, file->f_vfsmnt,
50387 + bprm->unsafe);
50388 + if (retval < 0)
50389 + goto out_fail;
50390 +
50391 retval = copy_strings_kernel(1, &bprm->filename, bprm);
50392 if (retval < 0)
50393 - goto out;
50394 + goto out_fail;
50395
50396 bprm->exec = bprm->p;
50397 retval = copy_strings(bprm->envc, envp, bprm);
50398 if (retval < 0)
50399 - goto out;
50400 + goto out_fail;
50401
50402 retval = copy_strings(bprm->argc, argv, bprm);
50403 if (retval < 0)
50404 - goto out;
50405 + goto out_fail;
50406 +
50407 + gr_log_chroot_exec(file->f_dentry, file->f_vfsmnt);
50408 +
50409 + gr_handle_exec_args(bprm, argv);
50410
50411 retval = search_binary_handler(bprm);
50412 if (retval < 0)
50413 - goto out;
50414 + goto out_fail;
50415 +#ifdef CONFIG_GRKERNSEC
50416 + if (old_exec_file)
50417 + fput(old_exec_file);
50418 +#endif
50419
50420 /* execve succeeded */
50421 +
50422 + increment_exec_counter();
50423 current->fs->in_exec = 0;
50424 current->in_execve = 0;
50425 acct_update_integrals(current);
50426 @@ -1549,6 +1711,14 @@ static int do_execve_common(const char *filename,
50427 put_files_struct(displaced);
50428 return retval;
50429
50430 +out_fail:
50431 +#ifdef CONFIG_GRKERNSEC
50432 + current->acl = old_acl;
50433 + memcpy(current->signal->rlim, old_rlim, sizeof(old_rlim));
50434 + fput(current->exec_file);
50435 + current->exec_file = old_exec_file;
50436 +#endif
50437 +
50438 out:
50439 if (bprm->mm) {
50440 acct_arg_size(bprm, 0);
50441 @@ -1697,3 +1867,253 @@ asmlinkage long compat_sys_execve(const char __user * filename,
50442 return error;
50443 }
50444 #endif
50445 +
50446 +int pax_check_flags(unsigned long *flags)
50447 +{
50448 + int retval = 0;
50449 +
50450 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_SEGMEXEC)
50451 + if (*flags & MF_PAX_SEGMEXEC)
50452 + {
50453 + *flags &= ~MF_PAX_SEGMEXEC;
50454 + retval = -EINVAL;
50455 + }
50456 +#endif
50457 +
50458 + if ((*flags & MF_PAX_PAGEEXEC)
50459 +
50460 +#ifdef CONFIG_PAX_PAGEEXEC
50461 + && (*flags & MF_PAX_SEGMEXEC)
50462 +#endif
50463 +
50464 + )
50465 + {
50466 + *flags &= ~MF_PAX_PAGEEXEC;
50467 + retval = -EINVAL;
50468 + }
50469 +
50470 + if ((*flags & MF_PAX_MPROTECT)
50471 +
50472 +#ifdef CONFIG_PAX_MPROTECT
50473 + && !(*flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC))
50474 +#endif
50475 +
50476 + )
50477 + {
50478 + *flags &= ~MF_PAX_MPROTECT;
50479 + retval = -EINVAL;
50480 + }
50481 +
50482 + if ((*flags & MF_PAX_EMUTRAMP)
50483 +
50484 +#ifdef CONFIG_PAX_EMUTRAMP
50485 + && !(*flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC))
50486 +#endif
50487 +
50488 + )
50489 + {
50490 + *flags &= ~MF_PAX_EMUTRAMP;
50491 + retval = -EINVAL;
50492 + }
50493 +
50494 + return retval;
50495 +}
50496 +
50497 +EXPORT_SYMBOL(pax_check_flags);
50498 +
50499 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
50500 +void pax_report_fault(struct pt_regs *regs, void *pc, void *sp)
50501 +{
50502 + struct task_struct *tsk = current;
50503 + struct mm_struct *mm = current->mm;
50504 + char *buffer_exec = (char *)__get_free_page(GFP_KERNEL);
50505 + char *buffer_fault = (char *)__get_free_page(GFP_KERNEL);
50506 + char *path_exec = NULL;
50507 + char *path_fault = NULL;
50508 + unsigned long start = 0UL, end = 0UL, offset = 0UL;
50509 + siginfo_t info = { };
50510 +
50511 + if (buffer_exec && buffer_fault) {
50512 + struct vm_area_struct *vma, *vma_exec = NULL, *vma_fault = NULL;
50513 +
50514 + down_read(&mm->mmap_sem);
50515 + vma = mm->mmap;
50516 + while (vma && (!vma_exec || !vma_fault)) {
50517 + if (vma->vm_file && mm->exe_file == vma->vm_file && (vma->vm_flags & VM_EXEC))
50518 + vma_exec = vma;
50519 + if (vma->vm_start <= (unsigned long)pc && (unsigned long)pc < vma->vm_end)
50520 + vma_fault = vma;
50521 + vma = vma->vm_next;
50522 + }
50523 + if (vma_exec) {
50524 + path_exec = d_path(&vma_exec->vm_file->f_path, buffer_exec, PAGE_SIZE);
50525 + if (IS_ERR(path_exec))
50526 + path_exec = "<path too long>";
50527 + else {
50528 + path_exec = mangle_path(buffer_exec, path_exec, "\t\n\\");
50529 + if (path_exec) {
50530 + *path_exec = 0;
50531 + path_exec = buffer_exec;
50532 + } else
50533 + path_exec = "<path too long>";
50534 + }
50535 + }
50536 + if (vma_fault) {
50537 + start = vma_fault->vm_start;
50538 + end = vma_fault->vm_end;
50539 + offset = vma_fault->vm_pgoff << PAGE_SHIFT;
50540 + if (vma_fault->vm_file) {
50541 + path_fault = d_path(&vma_fault->vm_file->f_path, buffer_fault, PAGE_SIZE);
50542 + if (IS_ERR(path_fault))
50543 + path_fault = "<path too long>";
50544 + else {
50545 + path_fault = mangle_path(buffer_fault, path_fault, "\t\n\\");
50546 + if (path_fault) {
50547 + *path_fault = 0;
50548 + path_fault = buffer_fault;
50549 + } else
50550 + path_fault = "<path too long>";
50551 + }
50552 + } else
50553 + path_fault = "<anonymous mapping>";
50554 + }
50555 + up_read(&mm->mmap_sem);
50556 + }
50557 + if (tsk->signal->curr_ip)
50558 + printk(KERN_ERR "PAX: From %pI4: execution attempt in: %s, %08lx-%08lx %08lx\n", &tsk->signal->curr_ip, path_fault, start, end, offset);
50559 + else
50560 + printk(KERN_ERR "PAX: execution attempt in: %s, %08lx-%08lx %08lx\n", path_fault, start, end, offset);
50561 + 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),
50562 + from_kuid_munged(&init_user_ns, task_uid(tsk)), from_kuid_munged(&init_user_ns, task_euid(tsk)), pc, sp);
50563 + free_page((unsigned long)buffer_exec);
50564 + free_page((unsigned long)buffer_fault);
50565 + pax_report_insns(regs, pc, sp);
50566 + info.si_signo = SIGKILL;
50567 + info.si_errno = 0;
50568 + info.si_code = SI_KERNEL;
50569 + info.si_pid = 0;
50570 + info.si_uid = 0;
50571 + do_coredump(&info);
50572 +}
50573 +#endif
50574 +
50575 +#ifdef CONFIG_PAX_REFCOUNT
50576 +void pax_report_refcount_overflow(struct pt_regs *regs)
50577 +{
50578 + if (current->signal->curr_ip)
50579 + printk(KERN_ERR "PAX: From %pI4: refcount overflow detected in: %s:%d, uid/euid: %u/%u\n",
50580 + &current->signal->curr_ip, current->comm, task_pid_nr(current),
50581 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
50582 + else
50583 + printk(KERN_ERR "PAX: refcount overflow detected in: %s:%d, uid/euid: %u/%u\n", current->comm, task_pid_nr(current),
50584 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
50585 + print_symbol(KERN_ERR "PAX: refcount overflow occured at: %s\n", instruction_pointer(regs));
50586 + show_regs(regs);
50587 + force_sig_info(SIGKILL, SEND_SIG_FORCED, current);
50588 +}
50589 +#endif
50590 +
50591 +#ifdef CONFIG_PAX_USERCOPY
50592 +/* 0: not at all, 1: fully, 2: fully inside frame, -1: partially (implies an error) */
50593 +static noinline int check_stack_object(const void *obj, unsigned long len)
50594 +{
50595 + const void * const stack = task_stack_page(current);
50596 + const void * const stackend = stack + THREAD_SIZE;
50597 +
50598 +#if defined(CONFIG_FRAME_POINTER) && defined(CONFIG_X86)
50599 + const void *frame = NULL;
50600 + const void *oldframe;
50601 +#endif
50602 +
50603 + if (obj + len < obj)
50604 + return -1;
50605 +
50606 + if (obj + len <= stack || stackend <= obj)
50607 + return 0;
50608 +
50609 + if (obj < stack || stackend < obj + len)
50610 + return -1;
50611 +
50612 +#if defined(CONFIG_FRAME_POINTER) && defined(CONFIG_X86)
50613 + oldframe = __builtin_frame_address(1);
50614 + if (oldframe)
50615 + frame = __builtin_frame_address(2);
50616 + /*
50617 + low ----------------------------------------------> high
50618 + [saved bp][saved ip][args][local vars][saved bp][saved ip]
50619 + ^----------------^
50620 + allow copies only within here
50621 + */
50622 + while (stack <= frame && frame < stackend) {
50623 + /* if obj + len extends past the last frame, this
50624 + check won't pass and the next frame will be 0,
50625 + causing us to bail out and correctly report
50626 + the copy as invalid
50627 + */
50628 + if (obj + len <= frame)
50629 + return obj >= oldframe + 2 * sizeof(void *) ? 2 : -1;
50630 + oldframe = frame;
50631 + frame = *(const void * const *)frame;
50632 + }
50633 + return -1;
50634 +#else
50635 + return 1;
50636 +#endif
50637 +}
50638 +
50639 +static __noreturn void pax_report_usercopy(const void *ptr, unsigned long len, bool to, const char *type)
50640 +{
50641 + if (current->signal->curr_ip)
50642 + printk(KERN_ERR "PAX: From %pI4: kernel memory %s attempt detected %s %p (%s) (%lu bytes)\n",
50643 + &current->signal->curr_ip, to ? "leak" : "overwrite", to ? "from" : "to", ptr, type ? : "unknown", len);
50644 + else
50645 + printk(KERN_ERR "PAX: kernel memory %s attempt detected %s %p (%s) (%lu bytes)\n",
50646 + to ? "leak" : "overwrite", to ? "from" : "to", ptr, type ? : "unknown", len);
50647 + dump_stack();
50648 + gr_handle_kernel_exploit();
50649 + do_group_exit(SIGKILL);
50650 +}
50651 +#endif
50652 +
50653 +void __check_object_size(const void *ptr, unsigned long n, bool to)
50654 +{
50655 +
50656 +#ifdef CONFIG_PAX_USERCOPY
50657 + const char *type;
50658 +
50659 + if (!n)
50660 + return;
50661 +
50662 + type = check_heap_object(ptr, n);
50663 + if (!type) {
50664 + if (check_stack_object(ptr, n) != -1)
50665 + return;
50666 + type = "<process stack>";
50667 + }
50668 +
50669 + pax_report_usercopy(ptr, n, to, type);
50670 +#endif
50671 +
50672 +}
50673 +EXPORT_SYMBOL(__check_object_size);
50674 +
50675 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
50676 +void pax_track_stack(void)
50677 +{
50678 + unsigned long sp = (unsigned long)&sp;
50679 + if (sp < current_thread_info()->lowest_stack &&
50680 + sp > (unsigned long)task_stack_page(current))
50681 + current_thread_info()->lowest_stack = sp;
50682 +}
50683 +EXPORT_SYMBOL(pax_track_stack);
50684 +#endif
50685 +
50686 +#ifdef CONFIG_PAX_SIZE_OVERFLOW
50687 +void report_size_overflow(const char *file, unsigned int line, const char *func, const char *ssa_name)
50688 +{
50689 + printk(KERN_ERR "PAX: size overflow detected in function %s %s:%u %s", func, file, line, ssa_name);
50690 + dump_stack();
50691 + do_group_exit(SIGKILL);
50692 +}
50693 +EXPORT_SYMBOL(report_size_overflow);
50694 +#endif
50695 diff --git a/fs/ext2/balloc.c b/fs/ext2/balloc.c
50696 index 2616d0e..2ffdec9 100644
50697 --- a/fs/ext2/balloc.c
50698 +++ b/fs/ext2/balloc.c
50699 @@ -1190,10 +1190,10 @@ static int ext2_has_free_blocks(struct ext2_sb_info *sbi)
50700
50701 free_blocks = percpu_counter_read_positive(&sbi->s_freeblocks_counter);
50702 root_blocks = le32_to_cpu(sbi->s_es->s_r_blocks_count);
50703 - if (free_blocks < root_blocks + 1 && !capable(CAP_SYS_RESOURCE) &&
50704 + if (free_blocks < root_blocks + 1 &&
50705 !uid_eq(sbi->s_resuid, current_fsuid()) &&
50706 (gid_eq(sbi->s_resgid, GLOBAL_ROOT_GID) ||
50707 - !in_group_p (sbi->s_resgid))) {
50708 + !in_group_p (sbi->s_resgid)) && !capable_nolog(CAP_SYS_RESOURCE)) {
50709 return 0;
50710 }
50711 return 1;
50712 diff --git a/fs/ext3/balloc.c b/fs/ext3/balloc.c
50713 index 22548f5..41521d8 100644
50714 --- a/fs/ext3/balloc.c
50715 +++ b/fs/ext3/balloc.c
50716 @@ -1438,10 +1438,10 @@ static int ext3_has_free_blocks(struct ext3_sb_info *sbi, int use_reservation)
50717
50718 free_blocks = percpu_counter_read_positive(&sbi->s_freeblocks_counter);
50719 root_blocks = le32_to_cpu(sbi->s_es->s_r_blocks_count);
50720 - if (free_blocks < root_blocks + 1 && !capable(CAP_SYS_RESOURCE) &&
50721 + if (free_blocks < root_blocks + 1 &&
50722 !use_reservation && !uid_eq(sbi->s_resuid, current_fsuid()) &&
50723 (gid_eq(sbi->s_resgid, GLOBAL_ROOT_GID) ||
50724 - !in_group_p (sbi->s_resgid))) {
50725 + !in_group_p (sbi->s_resgid)) && !capable_nolog(CAP_SYS_RESOURCE)) {
50726 return 0;
50727 }
50728 return 1;
50729 diff --git a/fs/ext4/balloc.c b/fs/ext4/balloc.c
50730 index 92e68b3..115d987 100644
50731 --- a/fs/ext4/balloc.c
50732 +++ b/fs/ext4/balloc.c
50733 @@ -505,8 +505,8 @@ static int ext4_has_free_clusters(struct ext4_sb_info *sbi,
50734 /* Hm, nope. Are (enough) root reserved clusters available? */
50735 if (uid_eq(sbi->s_resuid, current_fsuid()) ||
50736 (!gid_eq(sbi->s_resgid, GLOBAL_ROOT_GID) && in_group_p(sbi->s_resgid)) ||
50737 - capable(CAP_SYS_RESOURCE) ||
50738 - (flags & EXT4_MB_USE_ROOT_BLOCKS)) {
50739 + (flags & EXT4_MB_USE_ROOT_BLOCKS) ||
50740 + capable_nolog(CAP_SYS_RESOURCE)) {
50741
50742 if (free_clusters >= (nclusters + dirty_clusters))
50743 return 1;
50744 diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
50745 index 8462eb3..4a71af6 100644
50746 --- a/fs/ext4/ext4.h
50747 +++ b/fs/ext4/ext4.h
50748 @@ -1265,19 +1265,19 @@ struct ext4_sb_info {
50749 unsigned long s_mb_last_start;
50750
50751 /* stats for buddy allocator */
50752 - atomic_t s_bal_reqs; /* number of reqs with len > 1 */
50753 - atomic_t s_bal_success; /* we found long enough chunks */
50754 - atomic_t s_bal_allocated; /* in blocks */
50755 - atomic_t s_bal_ex_scanned; /* total extents scanned */
50756 - atomic_t s_bal_goals; /* goal hits */
50757 - atomic_t s_bal_breaks; /* too long searches */
50758 - atomic_t s_bal_2orders; /* 2^order hits */
50759 + atomic_unchecked_t s_bal_reqs; /* number of reqs with len > 1 */
50760 + atomic_unchecked_t s_bal_success; /* we found long enough chunks */
50761 + atomic_unchecked_t s_bal_allocated; /* in blocks */
50762 + atomic_unchecked_t s_bal_ex_scanned; /* total extents scanned */
50763 + atomic_unchecked_t s_bal_goals; /* goal hits */
50764 + atomic_unchecked_t s_bal_breaks; /* too long searches */
50765 + atomic_unchecked_t s_bal_2orders; /* 2^order hits */
50766 spinlock_t s_bal_lock;
50767 unsigned long s_mb_buddies_generated;
50768 unsigned long long s_mb_generation_time;
50769 - atomic_t s_mb_lost_chunks;
50770 - atomic_t s_mb_preallocated;
50771 - atomic_t s_mb_discarded;
50772 + atomic_unchecked_t s_mb_lost_chunks;
50773 + atomic_unchecked_t s_mb_preallocated;
50774 + atomic_unchecked_t s_mb_discarded;
50775 atomic_t s_lock_busy;
50776
50777 /* locality groups */
50778 diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
50779 index 28bbf9b..75ca7c1 100644
50780 --- a/fs/ext4/mballoc.c
50781 +++ b/fs/ext4/mballoc.c
50782 @@ -1747,7 +1747,7 @@ void ext4_mb_simple_scan_group(struct ext4_allocation_context *ac,
50783 BUG_ON(ac->ac_b_ex.fe_len != ac->ac_g_ex.fe_len);
50784
50785 if (EXT4_SB(sb)->s_mb_stats)
50786 - atomic_inc(&EXT4_SB(sb)->s_bal_2orders);
50787 + atomic_inc_unchecked(&EXT4_SB(sb)->s_bal_2orders);
50788
50789 break;
50790 }
50791 @@ -2044,7 +2044,7 @@ repeat:
50792 ac->ac_status = AC_STATUS_CONTINUE;
50793 ac->ac_flags |= EXT4_MB_HINT_FIRST;
50794 cr = 3;
50795 - atomic_inc(&sbi->s_mb_lost_chunks);
50796 + atomic_inc_unchecked(&sbi->s_mb_lost_chunks);
50797 goto repeat;
50798 }
50799 }
50800 @@ -2552,25 +2552,25 @@ int ext4_mb_release(struct super_block *sb)
50801 if (sbi->s_mb_stats) {
50802 ext4_msg(sb, KERN_INFO,
50803 "mballoc: %u blocks %u reqs (%u success)",
50804 - atomic_read(&sbi->s_bal_allocated),
50805 - atomic_read(&sbi->s_bal_reqs),
50806 - atomic_read(&sbi->s_bal_success));
50807 + atomic_read_unchecked(&sbi->s_bal_allocated),
50808 + atomic_read_unchecked(&sbi->s_bal_reqs),
50809 + atomic_read_unchecked(&sbi->s_bal_success));
50810 ext4_msg(sb, KERN_INFO,
50811 "mballoc: %u extents scanned, %u goal hits, "
50812 "%u 2^N hits, %u breaks, %u lost",
50813 - atomic_read(&sbi->s_bal_ex_scanned),
50814 - atomic_read(&sbi->s_bal_goals),
50815 - atomic_read(&sbi->s_bal_2orders),
50816 - atomic_read(&sbi->s_bal_breaks),
50817 - atomic_read(&sbi->s_mb_lost_chunks));
50818 + atomic_read_unchecked(&sbi->s_bal_ex_scanned),
50819 + atomic_read_unchecked(&sbi->s_bal_goals),
50820 + atomic_read_unchecked(&sbi->s_bal_2orders),
50821 + atomic_read_unchecked(&sbi->s_bal_breaks),
50822 + atomic_read_unchecked(&sbi->s_mb_lost_chunks));
50823 ext4_msg(sb, KERN_INFO,
50824 "mballoc: %lu generated and it took %Lu",
50825 sbi->s_mb_buddies_generated,
50826 sbi->s_mb_generation_time);
50827 ext4_msg(sb, KERN_INFO,
50828 "mballoc: %u preallocated, %u discarded",
50829 - atomic_read(&sbi->s_mb_preallocated),
50830 - atomic_read(&sbi->s_mb_discarded));
50831 + atomic_read_unchecked(&sbi->s_mb_preallocated),
50832 + atomic_read_unchecked(&sbi->s_mb_discarded));
50833 }
50834
50835 free_percpu(sbi->s_locality_groups);
50836 @@ -3060,16 +3060,16 @@ static void ext4_mb_collect_stats(struct ext4_allocation_context *ac)
50837 struct ext4_sb_info *sbi = EXT4_SB(ac->ac_sb);
50838
50839 if (sbi->s_mb_stats && ac->ac_g_ex.fe_len > 1) {
50840 - atomic_inc(&sbi->s_bal_reqs);
50841 - atomic_add(ac->ac_b_ex.fe_len, &sbi->s_bal_allocated);
50842 + atomic_inc_unchecked(&sbi->s_bal_reqs);
50843 + atomic_add_unchecked(ac->ac_b_ex.fe_len, &sbi->s_bal_allocated);
50844 if (ac->ac_b_ex.fe_len >= ac->ac_o_ex.fe_len)
50845 - atomic_inc(&sbi->s_bal_success);
50846 - atomic_add(ac->ac_found, &sbi->s_bal_ex_scanned);
50847 + atomic_inc_unchecked(&sbi->s_bal_success);
50848 + atomic_add_unchecked(ac->ac_found, &sbi->s_bal_ex_scanned);
50849 if (ac->ac_g_ex.fe_start == ac->ac_b_ex.fe_start &&
50850 ac->ac_g_ex.fe_group == ac->ac_b_ex.fe_group)
50851 - atomic_inc(&sbi->s_bal_goals);
50852 + atomic_inc_unchecked(&sbi->s_bal_goals);
50853 if (ac->ac_found > sbi->s_mb_max_to_scan)
50854 - atomic_inc(&sbi->s_bal_breaks);
50855 + atomic_inc_unchecked(&sbi->s_bal_breaks);
50856 }
50857
50858 if (ac->ac_op == EXT4_MB_HISTORY_ALLOC)
50859 @@ -3469,7 +3469,7 @@ ext4_mb_new_inode_pa(struct ext4_allocation_context *ac)
50860 trace_ext4_mb_new_inode_pa(ac, pa);
50861
50862 ext4_mb_use_inode_pa(ac, pa);
50863 - atomic_add(pa->pa_free, &sbi->s_mb_preallocated);
50864 + atomic_add_unchecked(pa->pa_free, &sbi->s_mb_preallocated);
50865
50866 ei = EXT4_I(ac->ac_inode);
50867 grp = ext4_get_group_info(sb, ac->ac_b_ex.fe_group);
50868 @@ -3529,7 +3529,7 @@ ext4_mb_new_group_pa(struct ext4_allocation_context *ac)
50869 trace_ext4_mb_new_group_pa(ac, pa);
50870
50871 ext4_mb_use_group_pa(ac, pa);
50872 - atomic_add(pa->pa_free, &EXT4_SB(sb)->s_mb_preallocated);
50873 + atomic_add_unchecked(pa->pa_free, &EXT4_SB(sb)->s_mb_preallocated);
50874
50875 grp = ext4_get_group_info(sb, ac->ac_b_ex.fe_group);
50876 lg = ac->ac_lg;
50877 @@ -3618,7 +3618,7 @@ ext4_mb_release_inode_pa(struct ext4_buddy *e4b, struct buffer_head *bitmap_bh,
50878 * from the bitmap and continue.
50879 */
50880 }
50881 - atomic_add(free, &sbi->s_mb_discarded);
50882 + atomic_add_unchecked(free, &sbi->s_mb_discarded);
50883
50884 return err;
50885 }
50886 @@ -3636,7 +3636,7 @@ ext4_mb_release_group_pa(struct ext4_buddy *e4b,
50887 ext4_get_group_no_and_offset(sb, pa->pa_pstart, &group, &bit);
50888 BUG_ON(group != e4b->bd_group && pa->pa_len != 0);
50889 mb_free_blocks(pa->pa_inode, e4b, bit, pa->pa_len);
50890 - atomic_add(pa->pa_len, &EXT4_SB(sb)->s_mb_discarded);
50891 + atomic_add_unchecked(pa->pa_len, &EXT4_SB(sb)->s_mb_discarded);
50892 trace_ext4_mballoc_discard(sb, NULL, group, bit, pa->pa_len);
50893
50894 return 0;
50895 diff --git a/fs/ext4/super.c b/fs/ext4/super.c
50896 index 5fa223d..12fa738 100644
50897 --- a/fs/ext4/super.c
50898 +++ b/fs/ext4/super.c
50899 @@ -2429,7 +2429,7 @@ struct ext4_attr {
50900 ssize_t (*store)(struct ext4_attr *, struct ext4_sb_info *,
50901 const char *, size_t);
50902 int offset;
50903 -};
50904 +} __do_const;
50905
50906 static int parse_strtoul(const char *buf,
50907 unsigned long max, unsigned long *value)
50908 diff --git a/fs/fcntl.c b/fs/fcntl.c
50909 index 71a600a..20d87b1 100644
50910 --- a/fs/fcntl.c
50911 +++ b/fs/fcntl.c
50912 @@ -107,6 +107,11 @@ int __f_setown(struct file *filp, struct pid *pid, enum pid_type type,
50913 if (err)
50914 return err;
50915
50916 + if (gr_handle_chroot_fowner(pid, type))
50917 + return -ENOENT;
50918 + if (gr_check_protected_task_fowner(pid, type))
50919 + return -EACCES;
50920 +
50921 f_modown(filp, pid, type, force);
50922 return 0;
50923 }
50924 diff --git a/fs/fhandle.c b/fs/fhandle.c
50925 index 999ff5c..41f4109 100644
50926 --- a/fs/fhandle.c
50927 +++ b/fs/fhandle.c
50928 @@ -67,8 +67,7 @@ static long do_sys_name_to_handle(struct path *path,
50929 } else
50930 retval = 0;
50931 /* copy the mount id */
50932 - if (copy_to_user(mnt_id, &real_mount(path->mnt)->mnt_id,
50933 - sizeof(*mnt_id)) ||
50934 + if (put_user(real_mount(path->mnt)->mnt_id, mnt_id) ||
50935 copy_to_user(ufh, handle,
50936 sizeof(struct file_handle) + handle_bytes))
50937 retval = -EFAULT;
50938 diff --git a/fs/fifo.c b/fs/fifo.c
50939 index cf6f434..3d7942c 100644
50940 --- a/fs/fifo.c
50941 +++ b/fs/fifo.c
50942 @@ -59,10 +59,10 @@ static int fifo_open(struct inode *inode, struct file *filp)
50943 */
50944 filp->f_op = &read_pipefifo_fops;
50945 pipe->r_counter++;
50946 - if (pipe->readers++ == 0)
50947 + if (atomic_inc_return(&pipe->readers) == 1)
50948 wake_up_partner(inode);
50949
50950 - if (!pipe->writers) {
50951 + if (!atomic_read(&pipe->writers)) {
50952 if ((filp->f_flags & O_NONBLOCK)) {
50953 /* suppress POLLHUP until we have
50954 * seen a writer */
50955 @@ -81,15 +81,15 @@ static int fifo_open(struct inode *inode, struct file *filp)
50956 * errno=ENXIO when there is no process reading the FIFO.
50957 */
50958 ret = -ENXIO;
50959 - if ((filp->f_flags & O_NONBLOCK) && !pipe->readers)
50960 + if ((filp->f_flags & O_NONBLOCK) && !atomic_read(&pipe->readers))
50961 goto err;
50962
50963 filp->f_op = &write_pipefifo_fops;
50964 pipe->w_counter++;
50965 - if (!pipe->writers++)
50966 + if (atomic_inc_return(&pipe->writers) == 1)
50967 wake_up_partner(inode);
50968
50969 - if (!pipe->readers) {
50970 + if (!atomic_read(&pipe->readers)) {
50971 if (wait_for_partner(inode, &pipe->r_counter))
50972 goto err_wr;
50973 }
50974 @@ -104,11 +104,11 @@ static int fifo_open(struct inode *inode, struct file *filp)
50975 */
50976 filp->f_op = &rdwr_pipefifo_fops;
50977
50978 - pipe->readers++;
50979 - pipe->writers++;
50980 + atomic_inc(&pipe->readers);
50981 + atomic_inc(&pipe->writers);
50982 pipe->r_counter++;
50983 pipe->w_counter++;
50984 - if (pipe->readers == 1 || pipe->writers == 1)
50985 + if (atomic_read(&pipe->readers) == 1 || atomic_read(&pipe->writers) == 1)
50986 wake_up_partner(inode);
50987 break;
50988
50989 @@ -122,19 +122,19 @@ static int fifo_open(struct inode *inode, struct file *filp)
50990 return 0;
50991
50992 err_rd:
50993 - if (!--pipe->readers)
50994 + if (atomic_dec_and_test(&pipe->readers))
50995 wake_up_interruptible(&pipe->wait);
50996 ret = -ERESTARTSYS;
50997 goto err;
50998
50999 err_wr:
51000 - if (!--pipe->writers)
51001 + if (atomic_dec_and_test(&pipe->writers))
51002 wake_up_interruptible(&pipe->wait);
51003 ret = -ERESTARTSYS;
51004 goto err;
51005
51006 err:
51007 - if (!pipe->readers && !pipe->writers)
51008 + if (!atomic_read(&pipe->readers) && !atomic_read(&pipe->writers))
51009 free_pipe_info(inode);
51010
51011 err_nocleanup:
51012 diff --git a/fs/file.c b/fs/file.c
51013 index 2b3570b..c57924b 100644
51014 --- a/fs/file.c
51015 +++ b/fs/file.c
51016 @@ -16,6 +16,7 @@
51017 #include <linux/slab.h>
51018 #include <linux/vmalloc.h>
51019 #include <linux/file.h>
51020 +#include <linux/security.h>
51021 #include <linux/fdtable.h>
51022 #include <linux/bitops.h>
51023 #include <linux/interrupt.h>
51024 @@ -892,6 +893,7 @@ int replace_fd(unsigned fd, struct file *file, unsigned flags)
51025 if (!file)
51026 return __close_fd(files, fd);
51027
51028 + gr_learn_resource(current, RLIMIT_NOFILE, fd, 0);
51029 if (fd >= rlimit(RLIMIT_NOFILE))
51030 return -EBADF;
51031
51032 @@ -918,6 +920,7 @@ SYSCALL_DEFINE3(dup3, unsigned int, oldfd, unsigned int, newfd, int, flags)
51033 if (unlikely(oldfd == newfd))
51034 return -EINVAL;
51035
51036 + gr_learn_resource(current, RLIMIT_NOFILE, newfd, 0);
51037 if (newfd >= rlimit(RLIMIT_NOFILE))
51038 return -EBADF;
51039
51040 @@ -973,6 +976,7 @@ SYSCALL_DEFINE1(dup, unsigned int, fildes)
51041 int f_dupfd(unsigned int from, struct file *file, unsigned flags)
51042 {
51043 int err;
51044 + gr_learn_resource(current, RLIMIT_NOFILE, from, 0);
51045 if (from >= rlimit(RLIMIT_NOFILE))
51046 return -EINVAL;
51047 err = alloc_fd(from, flags);
51048 diff --git a/fs/filesystems.c b/fs/filesystems.c
51049 index da165f6..3671bdb 100644
51050 --- a/fs/filesystems.c
51051 +++ b/fs/filesystems.c
51052 @@ -273,7 +273,12 @@ struct file_system_type *get_fs_type(const char *name)
51053 int len = dot ? dot - name : strlen(name);
51054
51055 fs = __get_fs_type(name, len);
51056 +
51057 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
51058 + if (!fs && (___request_module(true, "grsec_modharden_fs", "%.*s", len, name) == 0))
51059 +#else
51060 if (!fs && (request_module("%.*s", len, name) == 0))
51061 +#endif
51062 fs = __get_fs_type(name, len);
51063
51064 if (dot && fs && !(fs->fs_flags & FS_HAS_SUBTYPE)) {
51065 diff --git a/fs/fs_struct.c b/fs/fs_struct.c
51066 index fe6ca58..65318cf 100644
51067 --- a/fs/fs_struct.c
51068 +++ b/fs/fs_struct.c
51069 @@ -4,6 +4,7 @@
51070 #include <linux/path.h>
51071 #include <linux/slab.h>
51072 #include <linux/fs_struct.h>
51073 +#include <linux/grsecurity.h>
51074 #include "internal.h"
51075
51076 /*
51077 @@ -19,6 +20,7 @@ void set_fs_root(struct fs_struct *fs, struct path *path)
51078 write_seqcount_begin(&fs->seq);
51079 old_root = fs->root;
51080 fs->root = *path;
51081 + gr_set_chroot_entries(current, path);
51082 write_seqcount_end(&fs->seq);
51083 spin_unlock(&fs->lock);
51084 if (old_root.dentry)
51085 @@ -53,6 +55,21 @@ static inline int replace_path(struct path *p, const struct path *old, const str
51086 return 1;
51087 }
51088
51089 +static inline int replace_root_path(struct task_struct *task, struct path *p, const struct path *old, struct path *new)
51090 +{
51091 + if (likely(p->dentry != old->dentry || p->mnt != old->mnt))
51092 + return 0;
51093 + *p = *new;
51094 +
51095 + /* This function is only called from pivot_root(). Leave our
51096 + gr_chroot_dentry and is_chrooted flags as-is, so that a
51097 + pivoted root isn't treated as a chroot
51098 + */
51099 + //gr_set_chroot_entries(task, new);
51100 +
51101 + return 1;
51102 +}
51103 +
51104 void chroot_fs_refs(struct path *old_root, struct path *new_root)
51105 {
51106 struct task_struct *g, *p;
51107 @@ -67,7 +84,7 @@ void chroot_fs_refs(struct path *old_root, struct path *new_root)
51108 int hits = 0;
51109 spin_lock(&fs->lock);
51110 write_seqcount_begin(&fs->seq);
51111 - hits += replace_path(&fs->root, old_root, new_root);
51112 + hits += replace_root_path(p, &fs->root, old_root, new_root);
51113 hits += replace_path(&fs->pwd, old_root, new_root);
51114 write_seqcount_end(&fs->seq);
51115 while (hits--) {
51116 @@ -99,7 +116,8 @@ void exit_fs(struct task_struct *tsk)
51117 task_lock(tsk);
51118 spin_lock(&fs->lock);
51119 tsk->fs = NULL;
51120 - kill = !--fs->users;
51121 + gr_clear_chroot_entries(tsk);
51122 + kill = !atomic_dec_return(&fs->users);
51123 spin_unlock(&fs->lock);
51124 task_unlock(tsk);
51125 if (kill)
51126 @@ -112,7 +130,7 @@ struct fs_struct *copy_fs_struct(struct fs_struct *old)
51127 struct fs_struct *fs = kmem_cache_alloc(fs_cachep, GFP_KERNEL);
51128 /* We don't need to lock fs - think why ;-) */
51129 if (fs) {
51130 - fs->users = 1;
51131 + atomic_set(&fs->users, 1);
51132 fs->in_exec = 0;
51133 spin_lock_init(&fs->lock);
51134 seqcount_init(&fs->seq);
51135 @@ -121,6 +139,9 @@ struct fs_struct *copy_fs_struct(struct fs_struct *old)
51136 spin_lock(&old->lock);
51137 fs->root = old->root;
51138 path_get(&fs->root);
51139 + /* instead of calling gr_set_chroot_entries here,
51140 + we call it from every caller of this function
51141 + */
51142 fs->pwd = old->pwd;
51143 path_get(&fs->pwd);
51144 spin_unlock(&old->lock);
51145 @@ -139,8 +160,9 @@ int unshare_fs_struct(void)
51146
51147 task_lock(current);
51148 spin_lock(&fs->lock);
51149 - kill = !--fs->users;
51150 + kill = !atomic_dec_return(&fs->users);
51151 current->fs = new_fs;
51152 + gr_set_chroot_entries(current, &new_fs->root);
51153 spin_unlock(&fs->lock);
51154 task_unlock(current);
51155
51156 @@ -153,13 +175,13 @@ EXPORT_SYMBOL_GPL(unshare_fs_struct);
51157
51158 int current_umask(void)
51159 {
51160 - return current->fs->umask;
51161 + return current->fs->umask | gr_acl_umask();
51162 }
51163 EXPORT_SYMBOL(current_umask);
51164
51165 /* to be mentioned only in INIT_TASK */
51166 struct fs_struct init_fs = {
51167 - .users = 1,
51168 + .users = ATOMIC_INIT(1),
51169 .lock = __SPIN_LOCK_UNLOCKED(init_fs.lock),
51170 .seq = SEQCNT_ZERO,
51171 .umask = 0022,
51172 diff --git a/fs/fscache/cookie.c b/fs/fscache/cookie.c
51173 index 8dcb114..b1072e2 100644
51174 --- a/fs/fscache/cookie.c
51175 +++ b/fs/fscache/cookie.c
51176 @@ -68,11 +68,11 @@ struct fscache_cookie *__fscache_acquire_cookie(
51177 parent ? (char *) parent->def->name : "<no-parent>",
51178 def->name, netfs_data);
51179
51180 - fscache_stat(&fscache_n_acquires);
51181 + fscache_stat_unchecked(&fscache_n_acquires);
51182
51183 /* if there's no parent cookie, then we don't create one here either */
51184 if (!parent) {
51185 - fscache_stat(&fscache_n_acquires_null);
51186 + fscache_stat_unchecked(&fscache_n_acquires_null);
51187 _leave(" [no parent]");
51188 return NULL;
51189 }
51190 @@ -87,7 +87,7 @@ struct fscache_cookie *__fscache_acquire_cookie(
51191 /* allocate and initialise a cookie */
51192 cookie = kmem_cache_alloc(fscache_cookie_jar, GFP_KERNEL);
51193 if (!cookie) {
51194 - fscache_stat(&fscache_n_acquires_oom);
51195 + fscache_stat_unchecked(&fscache_n_acquires_oom);
51196 _leave(" [ENOMEM]");
51197 return NULL;
51198 }
51199 @@ -109,13 +109,13 @@ struct fscache_cookie *__fscache_acquire_cookie(
51200
51201 switch (cookie->def->type) {
51202 case FSCACHE_COOKIE_TYPE_INDEX:
51203 - fscache_stat(&fscache_n_cookie_index);
51204 + fscache_stat_unchecked(&fscache_n_cookie_index);
51205 break;
51206 case FSCACHE_COOKIE_TYPE_DATAFILE:
51207 - fscache_stat(&fscache_n_cookie_data);
51208 + fscache_stat_unchecked(&fscache_n_cookie_data);
51209 break;
51210 default:
51211 - fscache_stat(&fscache_n_cookie_special);
51212 + fscache_stat_unchecked(&fscache_n_cookie_special);
51213 break;
51214 }
51215
51216 @@ -126,13 +126,13 @@ struct fscache_cookie *__fscache_acquire_cookie(
51217 if (fscache_acquire_non_index_cookie(cookie) < 0) {
51218 atomic_dec(&parent->n_children);
51219 __fscache_cookie_put(cookie);
51220 - fscache_stat(&fscache_n_acquires_nobufs);
51221 + fscache_stat_unchecked(&fscache_n_acquires_nobufs);
51222 _leave(" = NULL");
51223 return NULL;
51224 }
51225 }
51226
51227 - fscache_stat(&fscache_n_acquires_ok);
51228 + fscache_stat_unchecked(&fscache_n_acquires_ok);
51229 _leave(" = %p", cookie);
51230 return cookie;
51231 }
51232 @@ -168,7 +168,7 @@ static int fscache_acquire_non_index_cookie(struct fscache_cookie *cookie)
51233 cache = fscache_select_cache_for_object(cookie->parent);
51234 if (!cache) {
51235 up_read(&fscache_addremove_sem);
51236 - fscache_stat(&fscache_n_acquires_no_cache);
51237 + fscache_stat_unchecked(&fscache_n_acquires_no_cache);
51238 _leave(" = -ENOMEDIUM [no cache]");
51239 return -ENOMEDIUM;
51240 }
51241 @@ -256,12 +256,12 @@ static int fscache_alloc_object(struct fscache_cache *cache,
51242 object = cache->ops->alloc_object(cache, cookie);
51243 fscache_stat_d(&fscache_n_cop_alloc_object);
51244 if (IS_ERR(object)) {
51245 - fscache_stat(&fscache_n_object_no_alloc);
51246 + fscache_stat_unchecked(&fscache_n_object_no_alloc);
51247 ret = PTR_ERR(object);
51248 goto error;
51249 }
51250
51251 - fscache_stat(&fscache_n_object_alloc);
51252 + fscache_stat_unchecked(&fscache_n_object_alloc);
51253
51254 object->debug_id = atomic_inc_return(&fscache_object_debug_id);
51255
51256 @@ -378,7 +378,7 @@ void __fscache_invalidate(struct fscache_cookie *cookie)
51257
51258 _enter("{%s}", cookie->def->name);
51259
51260 - fscache_stat(&fscache_n_invalidates);
51261 + fscache_stat_unchecked(&fscache_n_invalidates);
51262
51263 /* Only permit invalidation of data files. Invalidating an index will
51264 * require the caller to release all its attachments to the tree rooted
51265 @@ -437,10 +437,10 @@ void __fscache_update_cookie(struct fscache_cookie *cookie)
51266 struct fscache_object *object;
51267 struct hlist_node *_p;
51268
51269 - fscache_stat(&fscache_n_updates);
51270 + fscache_stat_unchecked(&fscache_n_updates);
51271
51272 if (!cookie) {
51273 - fscache_stat(&fscache_n_updates_null);
51274 + fscache_stat_unchecked(&fscache_n_updates_null);
51275 _leave(" [no cookie]");
51276 return;
51277 }
51278 @@ -474,12 +474,12 @@ void __fscache_relinquish_cookie(struct fscache_cookie *cookie, int retire)
51279 struct fscache_object *object;
51280 unsigned long event;
51281
51282 - fscache_stat(&fscache_n_relinquishes);
51283 + fscache_stat_unchecked(&fscache_n_relinquishes);
51284 if (retire)
51285 - fscache_stat(&fscache_n_relinquishes_retire);
51286 + fscache_stat_unchecked(&fscache_n_relinquishes_retire);
51287
51288 if (!cookie) {
51289 - fscache_stat(&fscache_n_relinquishes_null);
51290 + fscache_stat_unchecked(&fscache_n_relinquishes_null);
51291 _leave(" [no cookie]");
51292 return;
51293 }
51294 @@ -495,7 +495,7 @@ void __fscache_relinquish_cookie(struct fscache_cookie *cookie, int retire)
51295
51296 /* wait for the cookie to finish being instantiated (or to fail) */
51297 if (test_bit(FSCACHE_COOKIE_CREATING, &cookie->flags)) {
51298 - fscache_stat(&fscache_n_relinquishes_waitcrt);
51299 + fscache_stat_unchecked(&fscache_n_relinquishes_waitcrt);
51300 wait_on_bit(&cookie->flags, FSCACHE_COOKIE_CREATING,
51301 fscache_wait_bit, TASK_UNINTERRUPTIBLE);
51302 }
51303 diff --git a/fs/fscache/internal.h b/fs/fscache/internal.h
51304 index ee38fef..0a326d4 100644
51305 --- a/fs/fscache/internal.h
51306 +++ b/fs/fscache/internal.h
51307 @@ -148,101 +148,101 @@ extern void fscache_proc_cleanup(void);
51308 * stats.c
51309 */
51310 #ifdef CONFIG_FSCACHE_STATS
51311 -extern atomic_t fscache_n_ops_processed[FSCACHE_MAX_THREADS];
51312 -extern atomic_t fscache_n_objs_processed[FSCACHE_MAX_THREADS];
51313 +extern atomic_unchecked_t fscache_n_ops_processed[FSCACHE_MAX_THREADS];
51314 +extern atomic_unchecked_t fscache_n_objs_processed[FSCACHE_MAX_THREADS];
51315
51316 -extern atomic_t fscache_n_op_pend;
51317 -extern atomic_t fscache_n_op_run;
51318 -extern atomic_t fscache_n_op_enqueue;
51319 -extern atomic_t fscache_n_op_deferred_release;
51320 -extern atomic_t fscache_n_op_release;
51321 -extern atomic_t fscache_n_op_gc;
51322 -extern atomic_t fscache_n_op_cancelled;
51323 -extern atomic_t fscache_n_op_rejected;
51324 +extern atomic_unchecked_t fscache_n_op_pend;
51325 +extern atomic_unchecked_t fscache_n_op_run;
51326 +extern atomic_unchecked_t fscache_n_op_enqueue;
51327 +extern atomic_unchecked_t fscache_n_op_deferred_release;
51328 +extern atomic_unchecked_t fscache_n_op_release;
51329 +extern atomic_unchecked_t fscache_n_op_gc;
51330 +extern atomic_unchecked_t fscache_n_op_cancelled;
51331 +extern atomic_unchecked_t fscache_n_op_rejected;
51332
51333 -extern atomic_t fscache_n_attr_changed;
51334 -extern atomic_t fscache_n_attr_changed_ok;
51335 -extern atomic_t fscache_n_attr_changed_nobufs;
51336 -extern atomic_t fscache_n_attr_changed_nomem;
51337 -extern atomic_t fscache_n_attr_changed_calls;
51338 +extern atomic_unchecked_t fscache_n_attr_changed;
51339 +extern atomic_unchecked_t fscache_n_attr_changed_ok;
51340 +extern atomic_unchecked_t fscache_n_attr_changed_nobufs;
51341 +extern atomic_unchecked_t fscache_n_attr_changed_nomem;
51342 +extern atomic_unchecked_t fscache_n_attr_changed_calls;
51343
51344 -extern atomic_t fscache_n_allocs;
51345 -extern atomic_t fscache_n_allocs_ok;
51346 -extern atomic_t fscache_n_allocs_wait;
51347 -extern atomic_t fscache_n_allocs_nobufs;
51348 -extern atomic_t fscache_n_allocs_intr;
51349 -extern atomic_t fscache_n_allocs_object_dead;
51350 -extern atomic_t fscache_n_alloc_ops;
51351 -extern atomic_t fscache_n_alloc_op_waits;
51352 +extern atomic_unchecked_t fscache_n_allocs;
51353 +extern atomic_unchecked_t fscache_n_allocs_ok;
51354 +extern atomic_unchecked_t fscache_n_allocs_wait;
51355 +extern atomic_unchecked_t fscache_n_allocs_nobufs;
51356 +extern atomic_unchecked_t fscache_n_allocs_intr;
51357 +extern atomic_unchecked_t fscache_n_allocs_object_dead;
51358 +extern atomic_unchecked_t fscache_n_alloc_ops;
51359 +extern atomic_unchecked_t fscache_n_alloc_op_waits;
51360
51361 -extern atomic_t fscache_n_retrievals;
51362 -extern atomic_t fscache_n_retrievals_ok;
51363 -extern atomic_t fscache_n_retrievals_wait;
51364 -extern atomic_t fscache_n_retrievals_nodata;
51365 -extern atomic_t fscache_n_retrievals_nobufs;
51366 -extern atomic_t fscache_n_retrievals_intr;
51367 -extern atomic_t fscache_n_retrievals_nomem;
51368 -extern atomic_t fscache_n_retrievals_object_dead;
51369 -extern atomic_t fscache_n_retrieval_ops;
51370 -extern atomic_t fscache_n_retrieval_op_waits;
51371 +extern atomic_unchecked_t fscache_n_retrievals;
51372 +extern atomic_unchecked_t fscache_n_retrievals_ok;
51373 +extern atomic_unchecked_t fscache_n_retrievals_wait;
51374 +extern atomic_unchecked_t fscache_n_retrievals_nodata;
51375 +extern atomic_unchecked_t fscache_n_retrievals_nobufs;
51376 +extern atomic_unchecked_t fscache_n_retrievals_intr;
51377 +extern atomic_unchecked_t fscache_n_retrievals_nomem;
51378 +extern atomic_unchecked_t fscache_n_retrievals_object_dead;
51379 +extern atomic_unchecked_t fscache_n_retrieval_ops;
51380 +extern atomic_unchecked_t fscache_n_retrieval_op_waits;
51381
51382 -extern atomic_t fscache_n_stores;
51383 -extern atomic_t fscache_n_stores_ok;
51384 -extern atomic_t fscache_n_stores_again;
51385 -extern atomic_t fscache_n_stores_nobufs;
51386 -extern atomic_t fscache_n_stores_oom;
51387 -extern atomic_t fscache_n_store_ops;
51388 -extern atomic_t fscache_n_store_calls;
51389 -extern atomic_t fscache_n_store_pages;
51390 -extern atomic_t fscache_n_store_radix_deletes;
51391 -extern atomic_t fscache_n_store_pages_over_limit;
51392 +extern atomic_unchecked_t fscache_n_stores;
51393 +extern atomic_unchecked_t fscache_n_stores_ok;
51394 +extern atomic_unchecked_t fscache_n_stores_again;
51395 +extern atomic_unchecked_t fscache_n_stores_nobufs;
51396 +extern atomic_unchecked_t fscache_n_stores_oom;
51397 +extern atomic_unchecked_t fscache_n_store_ops;
51398 +extern atomic_unchecked_t fscache_n_store_calls;
51399 +extern atomic_unchecked_t fscache_n_store_pages;
51400 +extern atomic_unchecked_t fscache_n_store_radix_deletes;
51401 +extern atomic_unchecked_t fscache_n_store_pages_over_limit;
51402
51403 -extern atomic_t fscache_n_store_vmscan_not_storing;
51404 -extern atomic_t fscache_n_store_vmscan_gone;
51405 -extern atomic_t fscache_n_store_vmscan_busy;
51406 -extern atomic_t fscache_n_store_vmscan_cancelled;
51407 -extern atomic_t fscache_n_store_vmscan_wait;
51408 +extern atomic_unchecked_t fscache_n_store_vmscan_not_storing;
51409 +extern atomic_unchecked_t fscache_n_store_vmscan_gone;
51410 +extern atomic_unchecked_t fscache_n_store_vmscan_busy;
51411 +extern atomic_unchecked_t fscache_n_store_vmscan_cancelled;
51412 +extern atomic_unchecked_t fscache_n_store_vmscan_wait;
51413
51414 -extern atomic_t fscache_n_marks;
51415 -extern atomic_t fscache_n_uncaches;
51416 +extern atomic_unchecked_t fscache_n_marks;
51417 +extern atomic_unchecked_t fscache_n_uncaches;
51418
51419 -extern atomic_t fscache_n_acquires;
51420 -extern atomic_t fscache_n_acquires_null;
51421 -extern atomic_t fscache_n_acquires_no_cache;
51422 -extern atomic_t fscache_n_acquires_ok;
51423 -extern atomic_t fscache_n_acquires_nobufs;
51424 -extern atomic_t fscache_n_acquires_oom;
51425 +extern atomic_unchecked_t fscache_n_acquires;
51426 +extern atomic_unchecked_t fscache_n_acquires_null;
51427 +extern atomic_unchecked_t fscache_n_acquires_no_cache;
51428 +extern atomic_unchecked_t fscache_n_acquires_ok;
51429 +extern atomic_unchecked_t fscache_n_acquires_nobufs;
51430 +extern atomic_unchecked_t fscache_n_acquires_oom;
51431
51432 -extern atomic_t fscache_n_invalidates;
51433 -extern atomic_t fscache_n_invalidates_run;
51434 +extern atomic_unchecked_t fscache_n_invalidates;
51435 +extern atomic_unchecked_t fscache_n_invalidates_run;
51436
51437 -extern atomic_t fscache_n_updates;
51438 -extern atomic_t fscache_n_updates_null;
51439 -extern atomic_t fscache_n_updates_run;
51440 +extern atomic_unchecked_t fscache_n_updates;
51441 +extern atomic_unchecked_t fscache_n_updates_null;
51442 +extern atomic_unchecked_t fscache_n_updates_run;
51443
51444 -extern atomic_t fscache_n_relinquishes;
51445 -extern atomic_t fscache_n_relinquishes_null;
51446 -extern atomic_t fscache_n_relinquishes_waitcrt;
51447 -extern atomic_t fscache_n_relinquishes_retire;
51448 +extern atomic_unchecked_t fscache_n_relinquishes;
51449 +extern atomic_unchecked_t fscache_n_relinquishes_null;
51450 +extern atomic_unchecked_t fscache_n_relinquishes_waitcrt;
51451 +extern atomic_unchecked_t fscache_n_relinquishes_retire;
51452
51453 -extern atomic_t fscache_n_cookie_index;
51454 -extern atomic_t fscache_n_cookie_data;
51455 -extern atomic_t fscache_n_cookie_special;
51456 +extern atomic_unchecked_t fscache_n_cookie_index;
51457 +extern atomic_unchecked_t fscache_n_cookie_data;
51458 +extern atomic_unchecked_t fscache_n_cookie_special;
51459
51460 -extern atomic_t fscache_n_object_alloc;
51461 -extern atomic_t fscache_n_object_no_alloc;
51462 -extern atomic_t fscache_n_object_lookups;
51463 -extern atomic_t fscache_n_object_lookups_negative;
51464 -extern atomic_t fscache_n_object_lookups_positive;
51465 -extern atomic_t fscache_n_object_lookups_timed_out;
51466 -extern atomic_t fscache_n_object_created;
51467 -extern atomic_t fscache_n_object_avail;
51468 -extern atomic_t fscache_n_object_dead;
51469 +extern atomic_unchecked_t fscache_n_object_alloc;
51470 +extern atomic_unchecked_t fscache_n_object_no_alloc;
51471 +extern atomic_unchecked_t fscache_n_object_lookups;
51472 +extern atomic_unchecked_t fscache_n_object_lookups_negative;
51473 +extern atomic_unchecked_t fscache_n_object_lookups_positive;
51474 +extern atomic_unchecked_t fscache_n_object_lookups_timed_out;
51475 +extern atomic_unchecked_t fscache_n_object_created;
51476 +extern atomic_unchecked_t fscache_n_object_avail;
51477 +extern atomic_unchecked_t fscache_n_object_dead;
51478
51479 -extern atomic_t fscache_n_checkaux_none;
51480 -extern atomic_t fscache_n_checkaux_okay;
51481 -extern atomic_t fscache_n_checkaux_update;
51482 -extern atomic_t fscache_n_checkaux_obsolete;
51483 +extern atomic_unchecked_t fscache_n_checkaux_none;
51484 +extern atomic_unchecked_t fscache_n_checkaux_okay;
51485 +extern atomic_unchecked_t fscache_n_checkaux_update;
51486 +extern atomic_unchecked_t fscache_n_checkaux_obsolete;
51487
51488 extern atomic_t fscache_n_cop_alloc_object;
51489 extern atomic_t fscache_n_cop_lookup_object;
51490 @@ -267,6 +267,11 @@ static inline void fscache_stat(atomic_t *stat)
51491 atomic_inc(stat);
51492 }
51493
51494 +static inline void fscache_stat_unchecked(atomic_unchecked_t *stat)
51495 +{
51496 + atomic_inc_unchecked(stat);
51497 +}
51498 +
51499 static inline void fscache_stat_d(atomic_t *stat)
51500 {
51501 atomic_dec(stat);
51502 @@ -279,6 +284,7 @@ extern const struct file_operations fscache_stats_fops;
51503
51504 #define __fscache_stat(stat) (NULL)
51505 #define fscache_stat(stat) do {} while (0)
51506 +#define fscache_stat_unchecked(stat) do {} while (0)
51507 #define fscache_stat_d(stat) do {} while (0)
51508 #endif
51509
51510 diff --git a/fs/fscache/object.c b/fs/fscache/object.c
51511 index 50d41c1..10ee117 100644
51512 --- a/fs/fscache/object.c
51513 +++ b/fs/fscache/object.c
51514 @@ -143,7 +143,7 @@ static void fscache_object_state_machine(struct fscache_object *object)
51515 /* Invalidate an object on disk */
51516 case FSCACHE_OBJECT_INVALIDATING:
51517 clear_bit(FSCACHE_OBJECT_EV_INVALIDATE, &object->events);
51518 - fscache_stat(&fscache_n_invalidates_run);
51519 + fscache_stat_unchecked(&fscache_n_invalidates_run);
51520 fscache_stat(&fscache_n_cop_invalidate_object);
51521 fscache_invalidate_object(object);
51522 fscache_stat_d(&fscache_n_cop_invalidate_object);
51523 @@ -153,7 +153,7 @@ static void fscache_object_state_machine(struct fscache_object *object)
51524 /* update the object metadata on disk */
51525 case FSCACHE_OBJECT_UPDATING:
51526 clear_bit(FSCACHE_OBJECT_EV_UPDATE, &object->events);
51527 - fscache_stat(&fscache_n_updates_run);
51528 + fscache_stat_unchecked(&fscache_n_updates_run);
51529 fscache_stat(&fscache_n_cop_update_object);
51530 object->cache->ops->update_object(object);
51531 fscache_stat_d(&fscache_n_cop_update_object);
51532 @@ -242,7 +242,7 @@ static void fscache_object_state_machine(struct fscache_object *object)
51533 spin_lock(&object->lock);
51534 object->state = FSCACHE_OBJECT_DEAD;
51535 spin_unlock(&object->lock);
51536 - fscache_stat(&fscache_n_object_dead);
51537 + fscache_stat_unchecked(&fscache_n_object_dead);
51538 goto terminal_transit;
51539
51540 /* handle the parent cache of this object being withdrawn from
51541 @@ -257,7 +257,7 @@ static void fscache_object_state_machine(struct fscache_object *object)
51542 spin_lock(&object->lock);
51543 object->state = FSCACHE_OBJECT_DEAD;
51544 spin_unlock(&object->lock);
51545 - fscache_stat(&fscache_n_object_dead);
51546 + fscache_stat_unchecked(&fscache_n_object_dead);
51547 goto terminal_transit;
51548
51549 /* complain about the object being woken up once it is
51550 @@ -495,7 +495,7 @@ static void fscache_lookup_object(struct fscache_object *object)
51551 parent->cookie->def->name, cookie->def->name,
51552 object->cache->tag->name);
51553
51554 - fscache_stat(&fscache_n_object_lookups);
51555 + fscache_stat_unchecked(&fscache_n_object_lookups);
51556 fscache_stat(&fscache_n_cop_lookup_object);
51557 ret = object->cache->ops->lookup_object(object);
51558 fscache_stat_d(&fscache_n_cop_lookup_object);
51559 @@ -506,7 +506,7 @@ static void fscache_lookup_object(struct fscache_object *object)
51560 if (ret == -ETIMEDOUT) {
51561 /* probably stuck behind another object, so move this one to
51562 * the back of the queue */
51563 - fscache_stat(&fscache_n_object_lookups_timed_out);
51564 + fscache_stat_unchecked(&fscache_n_object_lookups_timed_out);
51565 set_bit(FSCACHE_OBJECT_EV_REQUEUE, &object->events);
51566 }
51567
51568 @@ -529,7 +529,7 @@ void fscache_object_lookup_negative(struct fscache_object *object)
51569
51570 spin_lock(&object->lock);
51571 if (object->state == FSCACHE_OBJECT_LOOKING_UP) {
51572 - fscache_stat(&fscache_n_object_lookups_negative);
51573 + fscache_stat_unchecked(&fscache_n_object_lookups_negative);
51574
51575 /* transit here to allow write requests to begin stacking up
51576 * and read requests to begin returning ENODATA */
51577 @@ -575,7 +575,7 @@ void fscache_obtained_object(struct fscache_object *object)
51578 * result, in which case there may be data available */
51579 spin_lock(&object->lock);
51580 if (object->state == FSCACHE_OBJECT_LOOKING_UP) {
51581 - fscache_stat(&fscache_n_object_lookups_positive);
51582 + fscache_stat_unchecked(&fscache_n_object_lookups_positive);
51583
51584 clear_bit(FSCACHE_COOKIE_NO_DATA_YET, &cookie->flags);
51585
51586 @@ -589,7 +589,7 @@ void fscache_obtained_object(struct fscache_object *object)
51587 set_bit(FSCACHE_OBJECT_EV_REQUEUE, &object->events);
51588 } else {
51589 ASSERTCMP(object->state, ==, FSCACHE_OBJECT_CREATING);
51590 - fscache_stat(&fscache_n_object_created);
51591 + fscache_stat_unchecked(&fscache_n_object_created);
51592
51593 object->state = FSCACHE_OBJECT_AVAILABLE;
51594 spin_unlock(&object->lock);
51595 @@ -634,7 +634,7 @@ static void fscache_object_available(struct fscache_object *object)
51596 fscache_enqueue_dependents(object);
51597
51598 fscache_hist(fscache_obj_instantiate_histogram, object->lookup_jif);
51599 - fscache_stat(&fscache_n_object_avail);
51600 + fscache_stat_unchecked(&fscache_n_object_avail);
51601
51602 _leave("");
51603 }
51604 @@ -894,7 +894,7 @@ enum fscache_checkaux fscache_check_aux(struct fscache_object *object,
51605 enum fscache_checkaux result;
51606
51607 if (!object->cookie->def->check_aux) {
51608 - fscache_stat(&fscache_n_checkaux_none);
51609 + fscache_stat_unchecked(&fscache_n_checkaux_none);
51610 return FSCACHE_CHECKAUX_OKAY;
51611 }
51612
51613 @@ -903,17 +903,17 @@ enum fscache_checkaux fscache_check_aux(struct fscache_object *object,
51614 switch (result) {
51615 /* entry okay as is */
51616 case FSCACHE_CHECKAUX_OKAY:
51617 - fscache_stat(&fscache_n_checkaux_okay);
51618 + fscache_stat_unchecked(&fscache_n_checkaux_okay);
51619 break;
51620
51621 /* entry requires update */
51622 case FSCACHE_CHECKAUX_NEEDS_UPDATE:
51623 - fscache_stat(&fscache_n_checkaux_update);
51624 + fscache_stat_unchecked(&fscache_n_checkaux_update);
51625 break;
51626
51627 /* entry requires deletion */
51628 case FSCACHE_CHECKAUX_OBSOLETE:
51629 - fscache_stat(&fscache_n_checkaux_obsolete);
51630 + fscache_stat_unchecked(&fscache_n_checkaux_obsolete);
51631 break;
51632
51633 default:
51634 diff --git a/fs/fscache/operation.c b/fs/fscache/operation.c
51635 index 762a9ec..2023284 100644
51636 --- a/fs/fscache/operation.c
51637 +++ b/fs/fscache/operation.c
51638 @@ -17,7 +17,7 @@
51639 #include <linux/slab.h>
51640 #include "internal.h"
51641
51642 -atomic_t fscache_op_debug_id;
51643 +atomic_unchecked_t fscache_op_debug_id;
51644 EXPORT_SYMBOL(fscache_op_debug_id);
51645
51646 /**
51647 @@ -39,7 +39,7 @@ void fscache_enqueue_operation(struct fscache_operation *op)
51648 ASSERTCMP(atomic_read(&op->usage), >, 0);
51649 ASSERTCMP(op->state, ==, FSCACHE_OP_ST_IN_PROGRESS);
51650
51651 - fscache_stat(&fscache_n_op_enqueue);
51652 + fscache_stat_unchecked(&fscache_n_op_enqueue);
51653 switch (op->flags & FSCACHE_OP_TYPE) {
51654 case FSCACHE_OP_ASYNC:
51655 _debug("queue async");
51656 @@ -73,7 +73,7 @@ static void fscache_run_op(struct fscache_object *object,
51657 wake_up_bit(&op->flags, FSCACHE_OP_WAITING);
51658 if (op->processor)
51659 fscache_enqueue_operation(op);
51660 - fscache_stat(&fscache_n_op_run);
51661 + fscache_stat_unchecked(&fscache_n_op_run);
51662 }
51663
51664 /*
51665 @@ -105,11 +105,11 @@ int fscache_submit_exclusive_op(struct fscache_object *object,
51666 if (object->n_in_progress > 0) {
51667 atomic_inc(&op->usage);
51668 list_add_tail(&op->pend_link, &object->pending_ops);
51669 - fscache_stat(&fscache_n_op_pend);
51670 + fscache_stat_unchecked(&fscache_n_op_pend);
51671 } else if (!list_empty(&object->pending_ops)) {
51672 atomic_inc(&op->usage);
51673 list_add_tail(&op->pend_link, &object->pending_ops);
51674 - fscache_stat(&fscache_n_op_pend);
51675 + fscache_stat_unchecked(&fscache_n_op_pend);
51676 fscache_start_operations(object);
51677 } else {
51678 ASSERTCMP(object->n_in_progress, ==, 0);
51679 @@ -125,7 +125,7 @@ int fscache_submit_exclusive_op(struct fscache_object *object,
51680 object->n_exclusive++; /* reads and writes must wait */
51681 atomic_inc(&op->usage);
51682 list_add_tail(&op->pend_link, &object->pending_ops);
51683 - fscache_stat(&fscache_n_op_pend);
51684 + fscache_stat_unchecked(&fscache_n_op_pend);
51685 ret = 0;
51686 } else {
51687 /* If we're in any other state, there must have been an I/O
51688 @@ -215,11 +215,11 @@ int fscache_submit_op(struct fscache_object *object,
51689 if (object->n_exclusive > 0) {
51690 atomic_inc(&op->usage);
51691 list_add_tail(&op->pend_link, &object->pending_ops);
51692 - fscache_stat(&fscache_n_op_pend);
51693 + fscache_stat_unchecked(&fscache_n_op_pend);
51694 } else if (!list_empty(&object->pending_ops)) {
51695 atomic_inc(&op->usage);
51696 list_add_tail(&op->pend_link, &object->pending_ops);
51697 - fscache_stat(&fscache_n_op_pend);
51698 + fscache_stat_unchecked(&fscache_n_op_pend);
51699 fscache_start_operations(object);
51700 } else {
51701 ASSERTCMP(object->n_exclusive, ==, 0);
51702 @@ -231,12 +231,12 @@ int fscache_submit_op(struct fscache_object *object,
51703 object->n_ops++;
51704 atomic_inc(&op->usage);
51705 list_add_tail(&op->pend_link, &object->pending_ops);
51706 - fscache_stat(&fscache_n_op_pend);
51707 + fscache_stat_unchecked(&fscache_n_op_pend);
51708 ret = 0;
51709 } else if (object->state == FSCACHE_OBJECT_DYING ||
51710 object->state == FSCACHE_OBJECT_LC_DYING ||
51711 object->state == FSCACHE_OBJECT_WITHDRAWING) {
51712 - fscache_stat(&fscache_n_op_rejected);
51713 + fscache_stat_unchecked(&fscache_n_op_rejected);
51714 op->state = FSCACHE_OP_ST_CANCELLED;
51715 ret = -ENOBUFS;
51716 } else if (!test_bit(FSCACHE_IOERROR, &object->cache->flags)) {
51717 @@ -315,7 +315,7 @@ int fscache_cancel_op(struct fscache_operation *op,
51718 ret = -EBUSY;
51719 if (op->state == FSCACHE_OP_ST_PENDING) {
51720 ASSERT(!list_empty(&op->pend_link));
51721 - fscache_stat(&fscache_n_op_cancelled);
51722 + fscache_stat_unchecked(&fscache_n_op_cancelled);
51723 list_del_init(&op->pend_link);
51724 if (do_cancel)
51725 do_cancel(op);
51726 @@ -347,7 +347,7 @@ void fscache_cancel_all_ops(struct fscache_object *object)
51727 while (!list_empty(&object->pending_ops)) {
51728 op = list_entry(object->pending_ops.next,
51729 struct fscache_operation, pend_link);
51730 - fscache_stat(&fscache_n_op_cancelled);
51731 + fscache_stat_unchecked(&fscache_n_op_cancelled);
51732 list_del_init(&op->pend_link);
51733
51734 ASSERTCMP(op->state, ==, FSCACHE_OP_ST_PENDING);
51735 @@ -419,7 +419,7 @@ void fscache_put_operation(struct fscache_operation *op)
51736 op->state, ==, FSCACHE_OP_ST_CANCELLED);
51737 op->state = FSCACHE_OP_ST_DEAD;
51738
51739 - fscache_stat(&fscache_n_op_release);
51740 + fscache_stat_unchecked(&fscache_n_op_release);
51741
51742 if (op->release) {
51743 op->release(op);
51744 @@ -442,7 +442,7 @@ void fscache_put_operation(struct fscache_operation *op)
51745 * lock, and defer it otherwise */
51746 if (!spin_trylock(&object->lock)) {
51747 _debug("defer put");
51748 - fscache_stat(&fscache_n_op_deferred_release);
51749 + fscache_stat_unchecked(&fscache_n_op_deferred_release);
51750
51751 cache = object->cache;
51752 spin_lock(&cache->op_gc_list_lock);
51753 @@ -495,7 +495,7 @@ void fscache_operation_gc(struct work_struct *work)
51754
51755 _debug("GC DEFERRED REL OBJ%x OP%x",
51756 object->debug_id, op->debug_id);
51757 - fscache_stat(&fscache_n_op_gc);
51758 + fscache_stat_unchecked(&fscache_n_op_gc);
51759
51760 ASSERTCMP(atomic_read(&op->usage), ==, 0);
51761 ASSERTCMP(op->state, ==, FSCACHE_OP_ST_DEAD);
51762 diff --git a/fs/fscache/page.c b/fs/fscache/page.c
51763 index ff000e5..c44ec6d 100644
51764 --- a/fs/fscache/page.c
51765 +++ b/fs/fscache/page.c
51766 @@ -61,7 +61,7 @@ try_again:
51767 val = radix_tree_lookup(&cookie->stores, page->index);
51768 if (!val) {
51769 rcu_read_unlock();
51770 - fscache_stat(&fscache_n_store_vmscan_not_storing);
51771 + fscache_stat_unchecked(&fscache_n_store_vmscan_not_storing);
51772 __fscache_uncache_page(cookie, page);
51773 return true;
51774 }
51775 @@ -91,11 +91,11 @@ try_again:
51776 spin_unlock(&cookie->stores_lock);
51777
51778 if (xpage) {
51779 - fscache_stat(&fscache_n_store_vmscan_cancelled);
51780 - fscache_stat(&fscache_n_store_radix_deletes);
51781 + fscache_stat_unchecked(&fscache_n_store_vmscan_cancelled);
51782 + fscache_stat_unchecked(&fscache_n_store_radix_deletes);
51783 ASSERTCMP(xpage, ==, page);
51784 } else {
51785 - fscache_stat(&fscache_n_store_vmscan_gone);
51786 + fscache_stat_unchecked(&fscache_n_store_vmscan_gone);
51787 }
51788
51789 wake_up_bit(&cookie->flags, 0);
51790 @@ -110,11 +110,11 @@ page_busy:
51791 * sleeping on memory allocation, so we may need to impose a timeout
51792 * too. */
51793 if (!(gfp & __GFP_WAIT)) {
51794 - fscache_stat(&fscache_n_store_vmscan_busy);
51795 + fscache_stat_unchecked(&fscache_n_store_vmscan_busy);
51796 return false;
51797 }
51798
51799 - fscache_stat(&fscache_n_store_vmscan_wait);
51800 + fscache_stat_unchecked(&fscache_n_store_vmscan_wait);
51801 __fscache_wait_on_page_write(cookie, page);
51802 gfp &= ~__GFP_WAIT;
51803 goto try_again;
51804 @@ -140,7 +140,7 @@ static void fscache_end_page_write(struct fscache_object *object,
51805 FSCACHE_COOKIE_STORING_TAG);
51806 if (!radix_tree_tag_get(&cookie->stores, page->index,
51807 FSCACHE_COOKIE_PENDING_TAG)) {
51808 - fscache_stat(&fscache_n_store_radix_deletes);
51809 + fscache_stat_unchecked(&fscache_n_store_radix_deletes);
51810 xpage = radix_tree_delete(&cookie->stores, page->index);
51811 }
51812 spin_unlock(&cookie->stores_lock);
51813 @@ -161,7 +161,7 @@ static void fscache_attr_changed_op(struct fscache_operation *op)
51814
51815 _enter("{OBJ%x OP%x}", object->debug_id, op->debug_id);
51816
51817 - fscache_stat(&fscache_n_attr_changed_calls);
51818 + fscache_stat_unchecked(&fscache_n_attr_changed_calls);
51819
51820 if (fscache_object_is_active(object)) {
51821 fscache_stat(&fscache_n_cop_attr_changed);
51822 @@ -187,11 +187,11 @@ int __fscache_attr_changed(struct fscache_cookie *cookie)
51823
51824 ASSERTCMP(cookie->def->type, !=, FSCACHE_COOKIE_TYPE_INDEX);
51825
51826 - fscache_stat(&fscache_n_attr_changed);
51827 + fscache_stat_unchecked(&fscache_n_attr_changed);
51828
51829 op = kzalloc(sizeof(*op), GFP_KERNEL);
51830 if (!op) {
51831 - fscache_stat(&fscache_n_attr_changed_nomem);
51832 + fscache_stat_unchecked(&fscache_n_attr_changed_nomem);
51833 _leave(" = -ENOMEM");
51834 return -ENOMEM;
51835 }
51836 @@ -209,7 +209,7 @@ int __fscache_attr_changed(struct fscache_cookie *cookie)
51837 if (fscache_submit_exclusive_op(object, op) < 0)
51838 goto nobufs;
51839 spin_unlock(&cookie->lock);
51840 - fscache_stat(&fscache_n_attr_changed_ok);
51841 + fscache_stat_unchecked(&fscache_n_attr_changed_ok);
51842 fscache_put_operation(op);
51843 _leave(" = 0");
51844 return 0;
51845 @@ -217,7 +217,7 @@ int __fscache_attr_changed(struct fscache_cookie *cookie)
51846 nobufs:
51847 spin_unlock(&cookie->lock);
51848 kfree(op);
51849 - fscache_stat(&fscache_n_attr_changed_nobufs);
51850 + fscache_stat_unchecked(&fscache_n_attr_changed_nobufs);
51851 _leave(" = %d", -ENOBUFS);
51852 return -ENOBUFS;
51853 }
51854 @@ -255,7 +255,7 @@ static struct fscache_retrieval *fscache_alloc_retrieval(
51855 /* allocate a retrieval operation and attempt to submit it */
51856 op = kzalloc(sizeof(*op), GFP_NOIO);
51857 if (!op) {
51858 - fscache_stat(&fscache_n_retrievals_nomem);
51859 + fscache_stat_unchecked(&fscache_n_retrievals_nomem);
51860 return NULL;
51861 }
51862
51863 @@ -283,13 +283,13 @@ static int fscache_wait_for_deferred_lookup(struct fscache_cookie *cookie)
51864 return 0;
51865 }
51866
51867 - fscache_stat(&fscache_n_retrievals_wait);
51868 + fscache_stat_unchecked(&fscache_n_retrievals_wait);
51869
51870 jif = jiffies;
51871 if (wait_on_bit(&cookie->flags, FSCACHE_COOKIE_LOOKING_UP,
51872 fscache_wait_bit_interruptible,
51873 TASK_INTERRUPTIBLE) != 0) {
51874 - fscache_stat(&fscache_n_retrievals_intr);
51875 + fscache_stat_unchecked(&fscache_n_retrievals_intr);
51876 _leave(" = -ERESTARTSYS");
51877 return -ERESTARTSYS;
51878 }
51879 @@ -318,8 +318,8 @@ static void fscache_do_cancel_retrieval(struct fscache_operation *_op)
51880 */
51881 static int fscache_wait_for_retrieval_activation(struct fscache_object *object,
51882 struct fscache_retrieval *op,
51883 - atomic_t *stat_op_waits,
51884 - atomic_t *stat_object_dead)
51885 + atomic_unchecked_t *stat_op_waits,
51886 + atomic_unchecked_t *stat_object_dead)
51887 {
51888 int ret;
51889
51890 @@ -327,7 +327,7 @@ static int fscache_wait_for_retrieval_activation(struct fscache_object *object,
51891 goto check_if_dead;
51892
51893 _debug(">>> WT");
51894 - fscache_stat(stat_op_waits);
51895 + fscache_stat_unchecked(stat_op_waits);
51896 if (wait_on_bit(&op->op.flags, FSCACHE_OP_WAITING,
51897 fscache_wait_bit_interruptible,
51898 TASK_INTERRUPTIBLE) != 0) {
51899 @@ -344,14 +344,14 @@ static int fscache_wait_for_retrieval_activation(struct fscache_object *object,
51900
51901 check_if_dead:
51902 if (op->op.state == FSCACHE_OP_ST_CANCELLED) {
51903 - fscache_stat(stat_object_dead);
51904 + fscache_stat_unchecked(stat_object_dead);
51905 _leave(" = -ENOBUFS [cancelled]");
51906 return -ENOBUFS;
51907 }
51908 if (unlikely(fscache_object_is_dead(object))) {
51909 pr_err("%s() = -ENOBUFS [obj dead %d]\n", __func__, op->op.state);
51910 fscache_cancel_op(&op->op, fscache_do_cancel_retrieval);
51911 - fscache_stat(stat_object_dead);
51912 + fscache_stat_unchecked(stat_object_dead);
51913 return -ENOBUFS;
51914 }
51915 return 0;
51916 @@ -378,7 +378,7 @@ int __fscache_read_or_alloc_page(struct fscache_cookie *cookie,
51917
51918 _enter("%p,%p,,,", cookie, page);
51919
51920 - fscache_stat(&fscache_n_retrievals);
51921 + fscache_stat_unchecked(&fscache_n_retrievals);
51922
51923 if (hlist_empty(&cookie->backing_objects))
51924 goto nobufs;
51925 @@ -417,7 +417,7 @@ int __fscache_read_or_alloc_page(struct fscache_cookie *cookie,
51926 goto nobufs_unlock_dec;
51927 spin_unlock(&cookie->lock);
51928
51929 - fscache_stat(&fscache_n_retrieval_ops);
51930 + fscache_stat_unchecked(&fscache_n_retrieval_ops);
51931
51932 /* pin the netfs read context in case we need to do the actual netfs
51933 * read because we've encountered a cache read failure */
51934 @@ -447,15 +447,15 @@ int __fscache_read_or_alloc_page(struct fscache_cookie *cookie,
51935
51936 error:
51937 if (ret == -ENOMEM)
51938 - fscache_stat(&fscache_n_retrievals_nomem);
51939 + fscache_stat_unchecked(&fscache_n_retrievals_nomem);
51940 else if (ret == -ERESTARTSYS)
51941 - fscache_stat(&fscache_n_retrievals_intr);
51942 + fscache_stat_unchecked(&fscache_n_retrievals_intr);
51943 else if (ret == -ENODATA)
51944 - fscache_stat(&fscache_n_retrievals_nodata);
51945 + fscache_stat_unchecked(&fscache_n_retrievals_nodata);
51946 else if (ret < 0)
51947 - fscache_stat(&fscache_n_retrievals_nobufs);
51948 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
51949 else
51950 - fscache_stat(&fscache_n_retrievals_ok);
51951 + fscache_stat_unchecked(&fscache_n_retrievals_ok);
51952
51953 fscache_put_retrieval(op);
51954 _leave(" = %d", ret);
51955 @@ -467,7 +467,7 @@ nobufs_unlock:
51956 spin_unlock(&cookie->lock);
51957 kfree(op);
51958 nobufs:
51959 - fscache_stat(&fscache_n_retrievals_nobufs);
51960 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
51961 _leave(" = -ENOBUFS");
51962 return -ENOBUFS;
51963 }
51964 @@ -505,7 +505,7 @@ int __fscache_read_or_alloc_pages(struct fscache_cookie *cookie,
51965
51966 _enter("%p,,%d,,,", cookie, *nr_pages);
51967
51968 - fscache_stat(&fscache_n_retrievals);
51969 + fscache_stat_unchecked(&fscache_n_retrievals);
51970
51971 if (hlist_empty(&cookie->backing_objects))
51972 goto nobufs;
51973 @@ -541,7 +541,7 @@ int __fscache_read_or_alloc_pages(struct fscache_cookie *cookie,
51974 goto nobufs_unlock_dec;
51975 spin_unlock(&cookie->lock);
51976
51977 - fscache_stat(&fscache_n_retrieval_ops);
51978 + fscache_stat_unchecked(&fscache_n_retrieval_ops);
51979
51980 /* pin the netfs read context in case we need to do the actual netfs
51981 * read because we've encountered a cache read failure */
51982 @@ -571,15 +571,15 @@ int __fscache_read_or_alloc_pages(struct fscache_cookie *cookie,
51983
51984 error:
51985 if (ret == -ENOMEM)
51986 - fscache_stat(&fscache_n_retrievals_nomem);
51987 + fscache_stat_unchecked(&fscache_n_retrievals_nomem);
51988 else if (ret == -ERESTARTSYS)
51989 - fscache_stat(&fscache_n_retrievals_intr);
51990 + fscache_stat_unchecked(&fscache_n_retrievals_intr);
51991 else if (ret == -ENODATA)
51992 - fscache_stat(&fscache_n_retrievals_nodata);
51993 + fscache_stat_unchecked(&fscache_n_retrievals_nodata);
51994 else if (ret < 0)
51995 - fscache_stat(&fscache_n_retrievals_nobufs);
51996 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
51997 else
51998 - fscache_stat(&fscache_n_retrievals_ok);
51999 + fscache_stat_unchecked(&fscache_n_retrievals_ok);
52000
52001 fscache_put_retrieval(op);
52002 _leave(" = %d", ret);
52003 @@ -591,7 +591,7 @@ nobufs_unlock:
52004 spin_unlock(&cookie->lock);
52005 kfree(op);
52006 nobufs:
52007 - fscache_stat(&fscache_n_retrievals_nobufs);
52008 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
52009 _leave(" = -ENOBUFS");
52010 return -ENOBUFS;
52011 }
52012 @@ -615,7 +615,7 @@ int __fscache_alloc_page(struct fscache_cookie *cookie,
52013
52014 _enter("%p,%p,,,", cookie, page);
52015
52016 - fscache_stat(&fscache_n_allocs);
52017 + fscache_stat_unchecked(&fscache_n_allocs);
52018
52019 if (hlist_empty(&cookie->backing_objects))
52020 goto nobufs;
52021 @@ -647,7 +647,7 @@ int __fscache_alloc_page(struct fscache_cookie *cookie,
52022 goto nobufs_unlock;
52023 spin_unlock(&cookie->lock);
52024
52025 - fscache_stat(&fscache_n_alloc_ops);
52026 + fscache_stat_unchecked(&fscache_n_alloc_ops);
52027
52028 ret = fscache_wait_for_retrieval_activation(
52029 object, op,
52030 @@ -663,11 +663,11 @@ int __fscache_alloc_page(struct fscache_cookie *cookie,
52031
52032 error:
52033 if (ret == -ERESTARTSYS)
52034 - fscache_stat(&fscache_n_allocs_intr);
52035 + fscache_stat_unchecked(&fscache_n_allocs_intr);
52036 else if (ret < 0)
52037 - fscache_stat(&fscache_n_allocs_nobufs);
52038 + fscache_stat_unchecked(&fscache_n_allocs_nobufs);
52039 else
52040 - fscache_stat(&fscache_n_allocs_ok);
52041 + fscache_stat_unchecked(&fscache_n_allocs_ok);
52042
52043 fscache_put_retrieval(op);
52044 _leave(" = %d", ret);
52045 @@ -677,7 +677,7 @@ nobufs_unlock:
52046 spin_unlock(&cookie->lock);
52047 kfree(op);
52048 nobufs:
52049 - fscache_stat(&fscache_n_allocs_nobufs);
52050 + fscache_stat_unchecked(&fscache_n_allocs_nobufs);
52051 _leave(" = -ENOBUFS");
52052 return -ENOBUFS;
52053 }
52054 @@ -736,7 +736,7 @@ static void fscache_write_op(struct fscache_operation *_op)
52055
52056 spin_lock(&cookie->stores_lock);
52057
52058 - fscache_stat(&fscache_n_store_calls);
52059 + fscache_stat_unchecked(&fscache_n_store_calls);
52060
52061 /* find a page to store */
52062 page = NULL;
52063 @@ -747,7 +747,7 @@ static void fscache_write_op(struct fscache_operation *_op)
52064 page = results[0];
52065 _debug("gang %d [%lx]", n, page->index);
52066 if (page->index > op->store_limit) {
52067 - fscache_stat(&fscache_n_store_pages_over_limit);
52068 + fscache_stat_unchecked(&fscache_n_store_pages_over_limit);
52069 goto superseded;
52070 }
52071
52072 @@ -759,7 +759,7 @@ static void fscache_write_op(struct fscache_operation *_op)
52073 spin_unlock(&cookie->stores_lock);
52074 spin_unlock(&object->lock);
52075
52076 - fscache_stat(&fscache_n_store_pages);
52077 + fscache_stat_unchecked(&fscache_n_store_pages);
52078 fscache_stat(&fscache_n_cop_write_page);
52079 ret = object->cache->ops->write_page(op, page);
52080 fscache_stat_d(&fscache_n_cop_write_page);
52081 @@ -860,7 +860,7 @@ int __fscache_write_page(struct fscache_cookie *cookie,
52082 ASSERTCMP(cookie->def->type, !=, FSCACHE_COOKIE_TYPE_INDEX);
52083 ASSERT(PageFsCache(page));
52084
52085 - fscache_stat(&fscache_n_stores);
52086 + fscache_stat_unchecked(&fscache_n_stores);
52087
52088 if (test_bit(FSCACHE_COOKIE_INVALIDATING, &cookie->flags)) {
52089 _leave(" = -ENOBUFS [invalidating]");
52090 @@ -916,7 +916,7 @@ int __fscache_write_page(struct fscache_cookie *cookie,
52091 spin_unlock(&cookie->stores_lock);
52092 spin_unlock(&object->lock);
52093
52094 - op->op.debug_id = atomic_inc_return(&fscache_op_debug_id);
52095 + op->op.debug_id = atomic_inc_return_unchecked(&fscache_op_debug_id);
52096 op->store_limit = object->store_limit;
52097
52098 if (fscache_submit_op(object, &op->op) < 0)
52099 @@ -924,8 +924,8 @@ int __fscache_write_page(struct fscache_cookie *cookie,
52100
52101 spin_unlock(&cookie->lock);
52102 radix_tree_preload_end();
52103 - fscache_stat(&fscache_n_store_ops);
52104 - fscache_stat(&fscache_n_stores_ok);
52105 + fscache_stat_unchecked(&fscache_n_store_ops);
52106 + fscache_stat_unchecked(&fscache_n_stores_ok);
52107
52108 /* the work queue now carries its own ref on the object */
52109 fscache_put_operation(&op->op);
52110 @@ -933,14 +933,14 @@ int __fscache_write_page(struct fscache_cookie *cookie,
52111 return 0;
52112
52113 already_queued:
52114 - fscache_stat(&fscache_n_stores_again);
52115 + fscache_stat_unchecked(&fscache_n_stores_again);
52116 already_pending:
52117 spin_unlock(&cookie->stores_lock);
52118 spin_unlock(&object->lock);
52119 spin_unlock(&cookie->lock);
52120 radix_tree_preload_end();
52121 kfree(op);
52122 - fscache_stat(&fscache_n_stores_ok);
52123 + fscache_stat_unchecked(&fscache_n_stores_ok);
52124 _leave(" = 0");
52125 return 0;
52126
52127 @@ -959,14 +959,14 @@ nobufs:
52128 spin_unlock(&cookie->lock);
52129 radix_tree_preload_end();
52130 kfree(op);
52131 - fscache_stat(&fscache_n_stores_nobufs);
52132 + fscache_stat_unchecked(&fscache_n_stores_nobufs);
52133 _leave(" = -ENOBUFS");
52134 return -ENOBUFS;
52135
52136 nomem_free:
52137 kfree(op);
52138 nomem:
52139 - fscache_stat(&fscache_n_stores_oom);
52140 + fscache_stat_unchecked(&fscache_n_stores_oom);
52141 _leave(" = -ENOMEM");
52142 return -ENOMEM;
52143 }
52144 @@ -984,7 +984,7 @@ void __fscache_uncache_page(struct fscache_cookie *cookie, struct page *page)
52145 ASSERTCMP(cookie->def->type, !=, FSCACHE_COOKIE_TYPE_INDEX);
52146 ASSERTCMP(page, !=, NULL);
52147
52148 - fscache_stat(&fscache_n_uncaches);
52149 + fscache_stat_unchecked(&fscache_n_uncaches);
52150
52151 /* cache withdrawal may beat us to it */
52152 if (!PageFsCache(page))
52153 @@ -1035,7 +1035,7 @@ void fscache_mark_page_cached(struct fscache_retrieval *op, struct page *page)
52154 struct fscache_cookie *cookie = op->op.object->cookie;
52155
52156 #ifdef CONFIG_FSCACHE_STATS
52157 - atomic_inc(&fscache_n_marks);
52158 + atomic_inc_unchecked(&fscache_n_marks);
52159 #endif
52160
52161 _debug("- mark %p{%lx}", page, page->index);
52162 diff --git a/fs/fscache/stats.c b/fs/fscache/stats.c
52163 index 8179e8b..5072cc7 100644
52164 --- a/fs/fscache/stats.c
52165 +++ b/fs/fscache/stats.c
52166 @@ -18,99 +18,99 @@
52167 /*
52168 * operation counters
52169 */
52170 -atomic_t fscache_n_op_pend;
52171 -atomic_t fscache_n_op_run;
52172 -atomic_t fscache_n_op_enqueue;
52173 -atomic_t fscache_n_op_requeue;
52174 -atomic_t fscache_n_op_deferred_release;
52175 -atomic_t fscache_n_op_release;
52176 -atomic_t fscache_n_op_gc;
52177 -atomic_t fscache_n_op_cancelled;
52178 -atomic_t fscache_n_op_rejected;
52179 +atomic_unchecked_t fscache_n_op_pend;
52180 +atomic_unchecked_t fscache_n_op_run;
52181 +atomic_unchecked_t fscache_n_op_enqueue;
52182 +atomic_unchecked_t fscache_n_op_requeue;
52183 +atomic_unchecked_t fscache_n_op_deferred_release;
52184 +atomic_unchecked_t fscache_n_op_release;
52185 +atomic_unchecked_t fscache_n_op_gc;
52186 +atomic_unchecked_t fscache_n_op_cancelled;
52187 +atomic_unchecked_t fscache_n_op_rejected;
52188
52189 -atomic_t fscache_n_attr_changed;
52190 -atomic_t fscache_n_attr_changed_ok;
52191 -atomic_t fscache_n_attr_changed_nobufs;
52192 -atomic_t fscache_n_attr_changed_nomem;
52193 -atomic_t fscache_n_attr_changed_calls;
52194 +atomic_unchecked_t fscache_n_attr_changed;
52195 +atomic_unchecked_t fscache_n_attr_changed_ok;
52196 +atomic_unchecked_t fscache_n_attr_changed_nobufs;
52197 +atomic_unchecked_t fscache_n_attr_changed_nomem;
52198 +atomic_unchecked_t fscache_n_attr_changed_calls;
52199
52200 -atomic_t fscache_n_allocs;
52201 -atomic_t fscache_n_allocs_ok;
52202 -atomic_t fscache_n_allocs_wait;
52203 -atomic_t fscache_n_allocs_nobufs;
52204 -atomic_t fscache_n_allocs_intr;
52205 -atomic_t fscache_n_allocs_object_dead;
52206 -atomic_t fscache_n_alloc_ops;
52207 -atomic_t fscache_n_alloc_op_waits;
52208 +atomic_unchecked_t fscache_n_allocs;
52209 +atomic_unchecked_t fscache_n_allocs_ok;
52210 +atomic_unchecked_t fscache_n_allocs_wait;
52211 +atomic_unchecked_t fscache_n_allocs_nobufs;
52212 +atomic_unchecked_t fscache_n_allocs_intr;
52213 +atomic_unchecked_t fscache_n_allocs_object_dead;
52214 +atomic_unchecked_t fscache_n_alloc_ops;
52215 +atomic_unchecked_t fscache_n_alloc_op_waits;
52216
52217 -atomic_t fscache_n_retrievals;
52218 -atomic_t fscache_n_retrievals_ok;
52219 -atomic_t fscache_n_retrievals_wait;
52220 -atomic_t fscache_n_retrievals_nodata;
52221 -atomic_t fscache_n_retrievals_nobufs;
52222 -atomic_t fscache_n_retrievals_intr;
52223 -atomic_t fscache_n_retrievals_nomem;
52224 -atomic_t fscache_n_retrievals_object_dead;
52225 -atomic_t fscache_n_retrieval_ops;
52226 -atomic_t fscache_n_retrieval_op_waits;
52227 +atomic_unchecked_t fscache_n_retrievals;
52228 +atomic_unchecked_t fscache_n_retrievals_ok;
52229 +atomic_unchecked_t fscache_n_retrievals_wait;
52230 +atomic_unchecked_t fscache_n_retrievals_nodata;
52231 +atomic_unchecked_t fscache_n_retrievals_nobufs;
52232 +atomic_unchecked_t fscache_n_retrievals_intr;
52233 +atomic_unchecked_t fscache_n_retrievals_nomem;
52234 +atomic_unchecked_t fscache_n_retrievals_object_dead;
52235 +atomic_unchecked_t fscache_n_retrieval_ops;
52236 +atomic_unchecked_t fscache_n_retrieval_op_waits;
52237
52238 -atomic_t fscache_n_stores;
52239 -atomic_t fscache_n_stores_ok;
52240 -atomic_t fscache_n_stores_again;
52241 -atomic_t fscache_n_stores_nobufs;
52242 -atomic_t fscache_n_stores_oom;
52243 -atomic_t fscache_n_store_ops;
52244 -atomic_t fscache_n_store_calls;
52245 -atomic_t fscache_n_store_pages;
52246 -atomic_t fscache_n_store_radix_deletes;
52247 -atomic_t fscache_n_store_pages_over_limit;
52248 +atomic_unchecked_t fscache_n_stores;
52249 +atomic_unchecked_t fscache_n_stores_ok;
52250 +atomic_unchecked_t fscache_n_stores_again;
52251 +atomic_unchecked_t fscache_n_stores_nobufs;
52252 +atomic_unchecked_t fscache_n_stores_oom;
52253 +atomic_unchecked_t fscache_n_store_ops;
52254 +atomic_unchecked_t fscache_n_store_calls;
52255 +atomic_unchecked_t fscache_n_store_pages;
52256 +atomic_unchecked_t fscache_n_store_radix_deletes;
52257 +atomic_unchecked_t fscache_n_store_pages_over_limit;
52258
52259 -atomic_t fscache_n_store_vmscan_not_storing;
52260 -atomic_t fscache_n_store_vmscan_gone;
52261 -atomic_t fscache_n_store_vmscan_busy;
52262 -atomic_t fscache_n_store_vmscan_cancelled;
52263 -atomic_t fscache_n_store_vmscan_wait;
52264 +atomic_unchecked_t fscache_n_store_vmscan_not_storing;
52265 +atomic_unchecked_t fscache_n_store_vmscan_gone;
52266 +atomic_unchecked_t fscache_n_store_vmscan_busy;
52267 +atomic_unchecked_t fscache_n_store_vmscan_cancelled;
52268 +atomic_unchecked_t fscache_n_store_vmscan_wait;
52269
52270 -atomic_t fscache_n_marks;
52271 -atomic_t fscache_n_uncaches;
52272 +atomic_unchecked_t fscache_n_marks;
52273 +atomic_unchecked_t fscache_n_uncaches;
52274
52275 -atomic_t fscache_n_acquires;
52276 -atomic_t fscache_n_acquires_null;
52277 -atomic_t fscache_n_acquires_no_cache;
52278 -atomic_t fscache_n_acquires_ok;
52279 -atomic_t fscache_n_acquires_nobufs;
52280 -atomic_t fscache_n_acquires_oom;
52281 +atomic_unchecked_t fscache_n_acquires;
52282 +atomic_unchecked_t fscache_n_acquires_null;
52283 +atomic_unchecked_t fscache_n_acquires_no_cache;
52284 +atomic_unchecked_t fscache_n_acquires_ok;
52285 +atomic_unchecked_t fscache_n_acquires_nobufs;
52286 +atomic_unchecked_t fscache_n_acquires_oom;
52287
52288 -atomic_t fscache_n_invalidates;
52289 -atomic_t fscache_n_invalidates_run;
52290 +atomic_unchecked_t fscache_n_invalidates;
52291 +atomic_unchecked_t fscache_n_invalidates_run;
52292
52293 -atomic_t fscache_n_updates;
52294 -atomic_t fscache_n_updates_null;
52295 -atomic_t fscache_n_updates_run;
52296 +atomic_unchecked_t fscache_n_updates;
52297 +atomic_unchecked_t fscache_n_updates_null;
52298 +atomic_unchecked_t fscache_n_updates_run;
52299
52300 -atomic_t fscache_n_relinquishes;
52301 -atomic_t fscache_n_relinquishes_null;
52302 -atomic_t fscache_n_relinquishes_waitcrt;
52303 -atomic_t fscache_n_relinquishes_retire;
52304 +atomic_unchecked_t fscache_n_relinquishes;
52305 +atomic_unchecked_t fscache_n_relinquishes_null;
52306 +atomic_unchecked_t fscache_n_relinquishes_waitcrt;
52307 +atomic_unchecked_t fscache_n_relinquishes_retire;
52308
52309 -atomic_t fscache_n_cookie_index;
52310 -atomic_t fscache_n_cookie_data;
52311 -atomic_t fscache_n_cookie_special;
52312 +atomic_unchecked_t fscache_n_cookie_index;
52313 +atomic_unchecked_t fscache_n_cookie_data;
52314 +atomic_unchecked_t fscache_n_cookie_special;
52315
52316 -atomic_t fscache_n_object_alloc;
52317 -atomic_t fscache_n_object_no_alloc;
52318 -atomic_t fscache_n_object_lookups;
52319 -atomic_t fscache_n_object_lookups_negative;
52320 -atomic_t fscache_n_object_lookups_positive;
52321 -atomic_t fscache_n_object_lookups_timed_out;
52322 -atomic_t fscache_n_object_created;
52323 -atomic_t fscache_n_object_avail;
52324 -atomic_t fscache_n_object_dead;
52325 +atomic_unchecked_t fscache_n_object_alloc;
52326 +atomic_unchecked_t fscache_n_object_no_alloc;
52327 +atomic_unchecked_t fscache_n_object_lookups;
52328 +atomic_unchecked_t fscache_n_object_lookups_negative;
52329 +atomic_unchecked_t fscache_n_object_lookups_positive;
52330 +atomic_unchecked_t fscache_n_object_lookups_timed_out;
52331 +atomic_unchecked_t fscache_n_object_created;
52332 +atomic_unchecked_t fscache_n_object_avail;
52333 +atomic_unchecked_t fscache_n_object_dead;
52334
52335 -atomic_t fscache_n_checkaux_none;
52336 -atomic_t fscache_n_checkaux_okay;
52337 -atomic_t fscache_n_checkaux_update;
52338 -atomic_t fscache_n_checkaux_obsolete;
52339 +atomic_unchecked_t fscache_n_checkaux_none;
52340 +atomic_unchecked_t fscache_n_checkaux_okay;
52341 +atomic_unchecked_t fscache_n_checkaux_update;
52342 +atomic_unchecked_t fscache_n_checkaux_obsolete;
52343
52344 atomic_t fscache_n_cop_alloc_object;
52345 atomic_t fscache_n_cop_lookup_object;
52346 @@ -138,118 +138,118 @@ static int fscache_stats_show(struct seq_file *m, void *v)
52347 seq_puts(m, "FS-Cache statistics\n");
52348
52349 seq_printf(m, "Cookies: idx=%u dat=%u spc=%u\n",
52350 - atomic_read(&fscache_n_cookie_index),
52351 - atomic_read(&fscache_n_cookie_data),
52352 - atomic_read(&fscache_n_cookie_special));
52353 + atomic_read_unchecked(&fscache_n_cookie_index),
52354 + atomic_read_unchecked(&fscache_n_cookie_data),
52355 + atomic_read_unchecked(&fscache_n_cookie_special));
52356
52357 seq_printf(m, "Objects: alc=%u nal=%u avl=%u ded=%u\n",
52358 - atomic_read(&fscache_n_object_alloc),
52359 - atomic_read(&fscache_n_object_no_alloc),
52360 - atomic_read(&fscache_n_object_avail),
52361 - atomic_read(&fscache_n_object_dead));
52362 + atomic_read_unchecked(&fscache_n_object_alloc),
52363 + atomic_read_unchecked(&fscache_n_object_no_alloc),
52364 + atomic_read_unchecked(&fscache_n_object_avail),
52365 + atomic_read_unchecked(&fscache_n_object_dead));
52366 seq_printf(m, "ChkAux : non=%u ok=%u upd=%u obs=%u\n",
52367 - atomic_read(&fscache_n_checkaux_none),
52368 - atomic_read(&fscache_n_checkaux_okay),
52369 - atomic_read(&fscache_n_checkaux_update),
52370 - atomic_read(&fscache_n_checkaux_obsolete));
52371 + atomic_read_unchecked(&fscache_n_checkaux_none),
52372 + atomic_read_unchecked(&fscache_n_checkaux_okay),
52373 + atomic_read_unchecked(&fscache_n_checkaux_update),
52374 + atomic_read_unchecked(&fscache_n_checkaux_obsolete));
52375
52376 seq_printf(m, "Pages : mrk=%u unc=%u\n",
52377 - atomic_read(&fscache_n_marks),
52378 - atomic_read(&fscache_n_uncaches));
52379 + atomic_read_unchecked(&fscache_n_marks),
52380 + atomic_read_unchecked(&fscache_n_uncaches));
52381
52382 seq_printf(m, "Acquire: n=%u nul=%u noc=%u ok=%u nbf=%u"
52383 " oom=%u\n",
52384 - atomic_read(&fscache_n_acquires),
52385 - atomic_read(&fscache_n_acquires_null),
52386 - atomic_read(&fscache_n_acquires_no_cache),
52387 - atomic_read(&fscache_n_acquires_ok),
52388 - atomic_read(&fscache_n_acquires_nobufs),
52389 - atomic_read(&fscache_n_acquires_oom));
52390 + atomic_read_unchecked(&fscache_n_acquires),
52391 + atomic_read_unchecked(&fscache_n_acquires_null),
52392 + atomic_read_unchecked(&fscache_n_acquires_no_cache),
52393 + atomic_read_unchecked(&fscache_n_acquires_ok),
52394 + atomic_read_unchecked(&fscache_n_acquires_nobufs),
52395 + atomic_read_unchecked(&fscache_n_acquires_oom));
52396
52397 seq_printf(m, "Lookups: n=%u neg=%u pos=%u crt=%u tmo=%u\n",
52398 - atomic_read(&fscache_n_object_lookups),
52399 - atomic_read(&fscache_n_object_lookups_negative),
52400 - atomic_read(&fscache_n_object_lookups_positive),
52401 - atomic_read(&fscache_n_object_created),
52402 - atomic_read(&fscache_n_object_lookups_timed_out));
52403 + atomic_read_unchecked(&fscache_n_object_lookups),
52404 + atomic_read_unchecked(&fscache_n_object_lookups_negative),
52405 + atomic_read_unchecked(&fscache_n_object_lookups_positive),
52406 + atomic_read_unchecked(&fscache_n_object_created),
52407 + atomic_read_unchecked(&fscache_n_object_lookups_timed_out));
52408
52409 seq_printf(m, "Invals : n=%u run=%u\n",
52410 - atomic_read(&fscache_n_invalidates),
52411 - atomic_read(&fscache_n_invalidates_run));
52412 + atomic_read_unchecked(&fscache_n_invalidates),
52413 + atomic_read_unchecked(&fscache_n_invalidates_run));
52414
52415 seq_printf(m, "Updates: n=%u nul=%u run=%u\n",
52416 - atomic_read(&fscache_n_updates),
52417 - atomic_read(&fscache_n_updates_null),
52418 - atomic_read(&fscache_n_updates_run));
52419 + atomic_read_unchecked(&fscache_n_updates),
52420 + atomic_read_unchecked(&fscache_n_updates_null),
52421 + atomic_read_unchecked(&fscache_n_updates_run));
52422
52423 seq_printf(m, "Relinqs: n=%u nul=%u wcr=%u rtr=%u\n",
52424 - atomic_read(&fscache_n_relinquishes),
52425 - atomic_read(&fscache_n_relinquishes_null),
52426 - atomic_read(&fscache_n_relinquishes_waitcrt),
52427 - atomic_read(&fscache_n_relinquishes_retire));
52428 + atomic_read_unchecked(&fscache_n_relinquishes),
52429 + atomic_read_unchecked(&fscache_n_relinquishes_null),
52430 + atomic_read_unchecked(&fscache_n_relinquishes_waitcrt),
52431 + atomic_read_unchecked(&fscache_n_relinquishes_retire));
52432
52433 seq_printf(m, "AttrChg: n=%u ok=%u nbf=%u oom=%u run=%u\n",
52434 - atomic_read(&fscache_n_attr_changed),
52435 - atomic_read(&fscache_n_attr_changed_ok),
52436 - atomic_read(&fscache_n_attr_changed_nobufs),
52437 - atomic_read(&fscache_n_attr_changed_nomem),
52438 - atomic_read(&fscache_n_attr_changed_calls));
52439 + atomic_read_unchecked(&fscache_n_attr_changed),
52440 + atomic_read_unchecked(&fscache_n_attr_changed_ok),
52441 + atomic_read_unchecked(&fscache_n_attr_changed_nobufs),
52442 + atomic_read_unchecked(&fscache_n_attr_changed_nomem),
52443 + atomic_read_unchecked(&fscache_n_attr_changed_calls));
52444
52445 seq_printf(m, "Allocs : n=%u ok=%u wt=%u nbf=%u int=%u\n",
52446 - atomic_read(&fscache_n_allocs),
52447 - atomic_read(&fscache_n_allocs_ok),
52448 - atomic_read(&fscache_n_allocs_wait),
52449 - atomic_read(&fscache_n_allocs_nobufs),
52450 - atomic_read(&fscache_n_allocs_intr));
52451 + atomic_read_unchecked(&fscache_n_allocs),
52452 + atomic_read_unchecked(&fscache_n_allocs_ok),
52453 + atomic_read_unchecked(&fscache_n_allocs_wait),
52454 + atomic_read_unchecked(&fscache_n_allocs_nobufs),
52455 + atomic_read_unchecked(&fscache_n_allocs_intr));
52456 seq_printf(m, "Allocs : ops=%u owt=%u abt=%u\n",
52457 - atomic_read(&fscache_n_alloc_ops),
52458 - atomic_read(&fscache_n_alloc_op_waits),
52459 - atomic_read(&fscache_n_allocs_object_dead));
52460 + atomic_read_unchecked(&fscache_n_alloc_ops),
52461 + atomic_read_unchecked(&fscache_n_alloc_op_waits),
52462 + atomic_read_unchecked(&fscache_n_allocs_object_dead));
52463
52464 seq_printf(m, "Retrvls: n=%u ok=%u wt=%u nod=%u nbf=%u"
52465 " int=%u oom=%u\n",
52466 - atomic_read(&fscache_n_retrievals),
52467 - atomic_read(&fscache_n_retrievals_ok),
52468 - atomic_read(&fscache_n_retrievals_wait),
52469 - atomic_read(&fscache_n_retrievals_nodata),
52470 - atomic_read(&fscache_n_retrievals_nobufs),
52471 - atomic_read(&fscache_n_retrievals_intr),
52472 - atomic_read(&fscache_n_retrievals_nomem));
52473 + atomic_read_unchecked(&fscache_n_retrievals),
52474 + atomic_read_unchecked(&fscache_n_retrievals_ok),
52475 + atomic_read_unchecked(&fscache_n_retrievals_wait),
52476 + atomic_read_unchecked(&fscache_n_retrievals_nodata),
52477 + atomic_read_unchecked(&fscache_n_retrievals_nobufs),
52478 + atomic_read_unchecked(&fscache_n_retrievals_intr),
52479 + atomic_read_unchecked(&fscache_n_retrievals_nomem));
52480 seq_printf(m, "Retrvls: ops=%u owt=%u abt=%u\n",
52481 - atomic_read(&fscache_n_retrieval_ops),
52482 - atomic_read(&fscache_n_retrieval_op_waits),
52483 - atomic_read(&fscache_n_retrievals_object_dead));
52484 + atomic_read_unchecked(&fscache_n_retrieval_ops),
52485 + atomic_read_unchecked(&fscache_n_retrieval_op_waits),
52486 + atomic_read_unchecked(&fscache_n_retrievals_object_dead));
52487
52488 seq_printf(m, "Stores : n=%u ok=%u agn=%u nbf=%u oom=%u\n",
52489 - atomic_read(&fscache_n_stores),
52490 - atomic_read(&fscache_n_stores_ok),
52491 - atomic_read(&fscache_n_stores_again),
52492 - atomic_read(&fscache_n_stores_nobufs),
52493 - atomic_read(&fscache_n_stores_oom));
52494 + atomic_read_unchecked(&fscache_n_stores),
52495 + atomic_read_unchecked(&fscache_n_stores_ok),
52496 + atomic_read_unchecked(&fscache_n_stores_again),
52497 + atomic_read_unchecked(&fscache_n_stores_nobufs),
52498 + atomic_read_unchecked(&fscache_n_stores_oom));
52499 seq_printf(m, "Stores : ops=%u run=%u pgs=%u rxd=%u olm=%u\n",
52500 - atomic_read(&fscache_n_store_ops),
52501 - atomic_read(&fscache_n_store_calls),
52502 - atomic_read(&fscache_n_store_pages),
52503 - atomic_read(&fscache_n_store_radix_deletes),
52504 - atomic_read(&fscache_n_store_pages_over_limit));
52505 + atomic_read_unchecked(&fscache_n_store_ops),
52506 + atomic_read_unchecked(&fscache_n_store_calls),
52507 + atomic_read_unchecked(&fscache_n_store_pages),
52508 + atomic_read_unchecked(&fscache_n_store_radix_deletes),
52509 + atomic_read_unchecked(&fscache_n_store_pages_over_limit));
52510
52511 seq_printf(m, "VmScan : nos=%u gon=%u bsy=%u can=%u wt=%u\n",
52512 - atomic_read(&fscache_n_store_vmscan_not_storing),
52513 - atomic_read(&fscache_n_store_vmscan_gone),
52514 - atomic_read(&fscache_n_store_vmscan_busy),
52515 - atomic_read(&fscache_n_store_vmscan_cancelled),
52516 - atomic_read(&fscache_n_store_vmscan_wait));
52517 + atomic_read_unchecked(&fscache_n_store_vmscan_not_storing),
52518 + atomic_read_unchecked(&fscache_n_store_vmscan_gone),
52519 + atomic_read_unchecked(&fscache_n_store_vmscan_busy),
52520 + atomic_read_unchecked(&fscache_n_store_vmscan_cancelled),
52521 + atomic_read_unchecked(&fscache_n_store_vmscan_wait));
52522
52523 seq_printf(m, "Ops : pend=%u run=%u enq=%u can=%u rej=%u\n",
52524 - atomic_read(&fscache_n_op_pend),
52525 - atomic_read(&fscache_n_op_run),
52526 - atomic_read(&fscache_n_op_enqueue),
52527 - atomic_read(&fscache_n_op_cancelled),
52528 - atomic_read(&fscache_n_op_rejected));
52529 + atomic_read_unchecked(&fscache_n_op_pend),
52530 + atomic_read_unchecked(&fscache_n_op_run),
52531 + atomic_read_unchecked(&fscache_n_op_enqueue),
52532 + atomic_read_unchecked(&fscache_n_op_cancelled),
52533 + atomic_read_unchecked(&fscache_n_op_rejected));
52534 seq_printf(m, "Ops : dfr=%u rel=%u gc=%u\n",
52535 - atomic_read(&fscache_n_op_deferred_release),
52536 - atomic_read(&fscache_n_op_release),
52537 - atomic_read(&fscache_n_op_gc));
52538 + atomic_read_unchecked(&fscache_n_op_deferred_release),
52539 + atomic_read_unchecked(&fscache_n_op_release),
52540 + atomic_read_unchecked(&fscache_n_op_gc));
52541
52542 seq_printf(m, "CacheOp: alo=%d luo=%d luc=%d gro=%d\n",
52543 atomic_read(&fscache_n_cop_alloc_object),
52544 diff --git a/fs/fuse/cuse.c b/fs/fuse/cuse.c
52545 index e397b67..b0d8709 100644
52546 --- a/fs/fuse/cuse.c
52547 +++ b/fs/fuse/cuse.c
52548 @@ -593,10 +593,12 @@ static int __init cuse_init(void)
52549 INIT_LIST_HEAD(&cuse_conntbl[i]);
52550
52551 /* inherit and extend fuse_dev_operations */
52552 - cuse_channel_fops = fuse_dev_operations;
52553 - cuse_channel_fops.owner = THIS_MODULE;
52554 - cuse_channel_fops.open = cuse_channel_open;
52555 - cuse_channel_fops.release = cuse_channel_release;
52556 + pax_open_kernel();
52557 + memcpy((void *)&cuse_channel_fops, &fuse_dev_operations, sizeof(fuse_dev_operations));
52558 + *(void **)&cuse_channel_fops.owner = THIS_MODULE;
52559 + *(void **)&cuse_channel_fops.open = cuse_channel_open;
52560 + *(void **)&cuse_channel_fops.release = cuse_channel_release;
52561 + pax_close_kernel();
52562
52563 cuse_class = class_create(THIS_MODULE, "cuse");
52564 if (IS_ERR(cuse_class))
52565 diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c
52566 index e83351a..41e3c9c 100644
52567 --- a/fs/fuse/dev.c
52568 +++ b/fs/fuse/dev.c
52569 @@ -1236,7 +1236,7 @@ static ssize_t fuse_dev_splice_read(struct file *in, loff_t *ppos,
52570 ret = 0;
52571 pipe_lock(pipe);
52572
52573 - if (!pipe->readers) {
52574 + if (!atomic_read(&pipe->readers)) {
52575 send_sig(SIGPIPE, current, 0);
52576 if (!ret)
52577 ret = -EPIPE;
52578 diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c
52579 index 315e1f8..91f890c 100644
52580 --- a/fs/fuse/dir.c
52581 +++ b/fs/fuse/dir.c
52582 @@ -1233,7 +1233,7 @@ static char *read_link(struct dentry *dentry)
52583 return link;
52584 }
52585
52586 -static void free_link(char *link)
52587 +static void free_link(const char *link)
52588 {
52589 if (!IS_ERR(link))
52590 free_page((unsigned long) link);
52591 diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c
52592 index 2b6f569..fcb4d1f 100644
52593 --- a/fs/gfs2/inode.c
52594 +++ b/fs/gfs2/inode.c
52595 @@ -1499,7 +1499,7 @@ out:
52596
52597 static void gfs2_put_link(struct dentry *dentry, struct nameidata *nd, void *p)
52598 {
52599 - char *s = nd_get_link(nd);
52600 + const char *s = nd_get_link(nd);
52601 if (!IS_ERR(s))
52602 kfree(s);
52603 }
52604 diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
52605 index 78bde32..767e906 100644
52606 --- a/fs/hugetlbfs/inode.c
52607 +++ b/fs/hugetlbfs/inode.c
52608 @@ -152,6 +152,7 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
52609 struct mm_struct *mm = current->mm;
52610 struct vm_area_struct *vma;
52611 struct hstate *h = hstate_file(file);
52612 + unsigned long offset = gr_rand_threadstack_offset(mm, file, flags);
52613 struct vm_unmapped_area_info info;
52614
52615 if (len & ~huge_page_mask(h))
52616 @@ -165,17 +166,26 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
52617 return addr;
52618 }
52619
52620 +#ifdef CONFIG_PAX_RANDMMAP
52621 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
52622 +#endif
52623 +
52624 if (addr) {
52625 addr = ALIGN(addr, huge_page_size(h));
52626 vma = find_vma(mm, addr);
52627 - if (TASK_SIZE - len >= addr &&
52628 - (!vma || addr + len <= vma->vm_start))
52629 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
52630 return addr;
52631 }
52632
52633 info.flags = 0;
52634 info.length = len;
52635 info.low_limit = TASK_UNMAPPED_BASE;
52636 +
52637 +#ifdef CONFIG_PAX_RANDMMAP
52638 + if (mm->pax_flags & MF_PAX_RANDMMAP)
52639 + info.low_limit += mm->delta_mmap;
52640 +#endif
52641 +
52642 info.high_limit = TASK_SIZE;
52643 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
52644 info.align_offset = 0;
52645 @@ -897,7 +907,7 @@ static struct file_system_type hugetlbfs_fs_type = {
52646 .kill_sb = kill_litter_super,
52647 };
52648
52649 -static struct vfsmount *hugetlbfs_vfsmount[HUGE_MAX_HSTATE];
52650 +struct vfsmount *hugetlbfs_vfsmount[HUGE_MAX_HSTATE];
52651
52652 static int can_do_hugetlb_shm(void)
52653 {
52654 diff --git a/fs/inode.c b/fs/inode.c
52655 index 14084b7..29af1d9 100644
52656 --- a/fs/inode.c
52657 +++ b/fs/inode.c
52658 @@ -880,8 +880,8 @@ unsigned int get_next_ino(void)
52659
52660 #ifdef CONFIG_SMP
52661 if (unlikely((res & (LAST_INO_BATCH-1)) == 0)) {
52662 - static atomic_t shared_last_ino;
52663 - int next = atomic_add_return(LAST_INO_BATCH, &shared_last_ino);
52664 + static atomic_unchecked_t shared_last_ino;
52665 + int next = atomic_add_return_unchecked(LAST_INO_BATCH, &shared_last_ino);
52666
52667 res = next - LAST_INO_BATCH;
52668 }
52669 diff --git a/fs/jffs2/erase.c b/fs/jffs2/erase.c
52670 index 4a6cf28..d3a29d3 100644
52671 --- a/fs/jffs2/erase.c
52672 +++ b/fs/jffs2/erase.c
52673 @@ -452,7 +452,8 @@ static void jffs2_mark_erased_block(struct jffs2_sb_info *c, struct jffs2_eraseb
52674 struct jffs2_unknown_node marker = {
52675 .magic = cpu_to_je16(JFFS2_MAGIC_BITMASK),
52676 .nodetype = cpu_to_je16(JFFS2_NODETYPE_CLEANMARKER),
52677 - .totlen = cpu_to_je32(c->cleanmarker_size)
52678 + .totlen = cpu_to_je32(c->cleanmarker_size),
52679 + .hdr_crc = cpu_to_je32(0)
52680 };
52681
52682 jffs2_prealloc_raw_node_refs(c, jeb, 1);
52683 diff --git a/fs/jffs2/wbuf.c b/fs/jffs2/wbuf.c
52684 index a6597d6..41b30ec 100644
52685 --- a/fs/jffs2/wbuf.c
52686 +++ b/fs/jffs2/wbuf.c
52687 @@ -1023,7 +1023,8 @@ static const struct jffs2_unknown_node oob_cleanmarker =
52688 {
52689 .magic = constant_cpu_to_je16(JFFS2_MAGIC_BITMASK),
52690 .nodetype = constant_cpu_to_je16(JFFS2_NODETYPE_CLEANMARKER),
52691 - .totlen = constant_cpu_to_je32(8)
52692 + .totlen = constant_cpu_to_je32(8),
52693 + .hdr_crc = constant_cpu_to_je32(0)
52694 };
52695
52696 /*
52697 diff --git a/fs/jfs/super.c b/fs/jfs/super.c
52698 index 1a543be..a4e1363 100644
52699 --- a/fs/jfs/super.c
52700 +++ b/fs/jfs/super.c
52701 @@ -225,7 +225,7 @@ static const match_table_t tokens = {
52702 static int parse_options(char *options, struct super_block *sb, s64 *newLVSize,
52703 int *flag)
52704 {
52705 - void *nls_map = (void *)-1; /* -1: no change; NULL: none */
52706 + const void *nls_map = (const void *)-1; /* -1: no change; NULL: none */
52707 char *p;
52708 struct jfs_sb_info *sbi = JFS_SBI(sb);
52709
52710 @@ -253,7 +253,7 @@ static int parse_options(char *options, struct super_block *sb, s64 *newLVSize,
52711 /* Don't do anything ;-) */
52712 break;
52713 case Opt_iocharset:
52714 - if (nls_map && nls_map != (void *) -1)
52715 + if (nls_map && nls_map != (const void *) -1)
52716 unload_nls(nls_map);
52717 if (!strcmp(args[0].from, "none"))
52718 nls_map = NULL;
52719 @@ -855,7 +855,7 @@ static int __init init_jfs_fs(void)
52720
52721 jfs_inode_cachep =
52722 kmem_cache_create("jfs_ip", sizeof(struct jfs_inode_info), 0,
52723 - SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD,
52724 + SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD|SLAB_USERCOPY,
52725 init_once);
52726 if (jfs_inode_cachep == NULL)
52727 return -ENOMEM;
52728 diff --git a/fs/libfs.c b/fs/libfs.c
52729 index 916da8c..1588998 100644
52730 --- a/fs/libfs.c
52731 +++ b/fs/libfs.c
52732 @@ -165,6 +165,9 @@ int dcache_readdir(struct file * filp, void * dirent, filldir_t filldir)
52733
52734 for (p=q->next; p != &dentry->d_subdirs; p=p->next) {
52735 struct dentry *next;
52736 + char d_name[sizeof(next->d_iname)];
52737 + const unsigned char *name;
52738 +
52739 next = list_entry(p, struct dentry, d_u.d_child);
52740 spin_lock_nested(&next->d_lock, DENTRY_D_LOCK_NESTED);
52741 if (!simple_positive(next)) {
52742 @@ -174,7 +177,12 @@ int dcache_readdir(struct file * filp, void * dirent, filldir_t filldir)
52743
52744 spin_unlock(&next->d_lock);
52745 spin_unlock(&dentry->d_lock);
52746 - if (filldir(dirent, next->d_name.name,
52747 + name = next->d_name.name;
52748 + if (name == next->d_iname) {
52749 + memcpy(d_name, name, next->d_name.len);
52750 + name = d_name;
52751 + }
52752 + if (filldir(dirent, name,
52753 next->d_name.len, filp->f_pos,
52754 next->d_inode->i_ino,
52755 dt_type(next->d_inode)) < 0)
52756 diff --git a/fs/lockd/clntproc.c b/fs/lockd/clntproc.c
52757 index 52e5120..808936e 100644
52758 --- a/fs/lockd/clntproc.c
52759 +++ b/fs/lockd/clntproc.c
52760 @@ -36,11 +36,11 @@ static const struct rpc_call_ops nlmclnt_cancel_ops;
52761 /*
52762 * Cookie counter for NLM requests
52763 */
52764 -static atomic_t nlm_cookie = ATOMIC_INIT(0x1234);
52765 +static atomic_unchecked_t nlm_cookie = ATOMIC_INIT(0x1234);
52766
52767 void nlmclnt_next_cookie(struct nlm_cookie *c)
52768 {
52769 - u32 cookie = atomic_inc_return(&nlm_cookie);
52770 + u32 cookie = atomic_inc_return_unchecked(&nlm_cookie);
52771
52772 memcpy(c->data, &cookie, 4);
52773 c->len=4;
52774 diff --git a/fs/locks.c b/fs/locks.c
52775 index a94e331..060bce3 100644
52776 --- a/fs/locks.c
52777 +++ b/fs/locks.c
52778 @@ -2064,16 +2064,16 @@ void locks_remove_flock(struct file *filp)
52779 return;
52780
52781 if (filp->f_op && filp->f_op->flock) {
52782 - struct file_lock fl = {
52783 + struct file_lock flock = {
52784 .fl_pid = current->tgid,
52785 .fl_file = filp,
52786 .fl_flags = FL_FLOCK,
52787 .fl_type = F_UNLCK,
52788 .fl_end = OFFSET_MAX,
52789 };
52790 - filp->f_op->flock(filp, F_SETLKW, &fl);
52791 - if (fl.fl_ops && fl.fl_ops->fl_release_private)
52792 - fl.fl_ops->fl_release_private(&fl);
52793 + filp->f_op->flock(filp, F_SETLKW, &flock);
52794 + if (flock.fl_ops && flock.fl_ops->fl_release_private)
52795 + flock.fl_ops->fl_release_private(&flock);
52796 }
52797
52798 lock_flocks();
52799 diff --git a/fs/namei.c b/fs/namei.c
52800 index ec97aef..e67718d 100644
52801 --- a/fs/namei.c
52802 +++ b/fs/namei.c
52803 @@ -319,16 +319,32 @@ int generic_permission(struct inode *inode, int mask)
52804 if (ret != -EACCES)
52805 return ret;
52806
52807 +#ifdef CONFIG_GRKERNSEC
52808 + /* we'll block if we have to log due to a denied capability use */
52809 + if (mask & MAY_NOT_BLOCK)
52810 + return -ECHILD;
52811 +#endif
52812 +
52813 if (S_ISDIR(inode->i_mode)) {
52814 /* DACs are overridable for directories */
52815 - if (inode_capable(inode, CAP_DAC_OVERRIDE))
52816 - return 0;
52817 if (!(mask & MAY_WRITE))
52818 - if (inode_capable(inode, CAP_DAC_READ_SEARCH))
52819 + if (inode_capable_nolog(inode, CAP_DAC_OVERRIDE) ||
52820 + inode_capable(inode, CAP_DAC_READ_SEARCH))
52821 return 0;
52822 + if (inode_capable(inode, CAP_DAC_OVERRIDE))
52823 + return 0;
52824 return -EACCES;
52825 }
52826 /*
52827 + * Searching includes executable on directories, else just read.
52828 + */
52829 + mask &= MAY_READ | MAY_WRITE | MAY_EXEC;
52830 + if (mask == MAY_READ)
52831 + if (inode_capable_nolog(inode, CAP_DAC_OVERRIDE) ||
52832 + inode_capable(inode, CAP_DAC_READ_SEARCH))
52833 + return 0;
52834 +
52835 + /*
52836 * Read/write DACs are always overridable.
52837 * Executable DACs are overridable when there is
52838 * at least one exec bit set.
52839 @@ -337,14 +353,6 @@ int generic_permission(struct inode *inode, int mask)
52840 if (inode_capable(inode, CAP_DAC_OVERRIDE))
52841 return 0;
52842
52843 - /*
52844 - * Searching includes executable on directories, else just read.
52845 - */
52846 - mask &= MAY_READ | MAY_WRITE | MAY_EXEC;
52847 - if (mask == MAY_READ)
52848 - if (inode_capable(inode, CAP_DAC_READ_SEARCH))
52849 - return 0;
52850 -
52851 return -EACCES;
52852 }
52853
52854 @@ -824,7 +832,7 @@ follow_link(struct path *link, struct nameidata *nd, void **p)
52855 {
52856 struct dentry *dentry = link->dentry;
52857 int error;
52858 - char *s;
52859 + const char *s;
52860
52861 BUG_ON(nd->flags & LOOKUP_RCU);
52862
52863 @@ -845,6 +853,12 @@ follow_link(struct path *link, struct nameidata *nd, void **p)
52864 if (error)
52865 goto out_put_nd_path;
52866
52867 + if (gr_handle_follow_link(dentry->d_parent->d_inode,
52868 + dentry->d_inode, dentry, nd->path.mnt)) {
52869 + error = -EACCES;
52870 + goto out_put_nd_path;
52871 + }
52872 +
52873 nd->last_type = LAST_BIND;
52874 *p = dentry->d_inode->i_op->follow_link(dentry, nd);
52875 error = PTR_ERR(*p);
52876 @@ -1594,6 +1608,8 @@ static inline int nested_symlink(struct path *path, struct nameidata *nd)
52877 break;
52878 res = walk_component(nd, path, &nd->last,
52879 nd->last_type, LOOKUP_FOLLOW);
52880 + if (res >= 0 && gr_handle_symlink_owner(&link, nd->inode))
52881 + res = -EACCES;
52882 put_link(nd, &link, cookie);
52883 } while (res > 0);
52884
52885 @@ -1692,7 +1708,7 @@ EXPORT_SYMBOL(full_name_hash);
52886 static inline unsigned long hash_name(const char *name, unsigned int *hashp)
52887 {
52888 unsigned long a, b, adata, bdata, mask, hash, len;
52889 - const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
52890 + static const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
52891
52892 hash = a = 0;
52893 len = -sizeof(unsigned long);
52894 @@ -1977,6 +1993,8 @@ static int path_lookupat(int dfd, const char *name,
52895 if (err)
52896 break;
52897 err = lookup_last(nd, &path);
52898 + if (!err && gr_handle_symlink_owner(&link, nd->inode))
52899 + err = -EACCES;
52900 put_link(nd, &link, cookie);
52901 }
52902 }
52903 @@ -1984,6 +2002,13 @@ static int path_lookupat(int dfd, const char *name,
52904 if (!err)
52905 err = complete_walk(nd);
52906
52907 + if (!err && !(nd->flags & LOOKUP_PARENT)) {
52908 + if (!gr_acl_handle_hidden_file(nd->path.dentry, nd->path.mnt)) {
52909 + path_put(&nd->path);
52910 + err = -ENOENT;
52911 + }
52912 + }
52913 +
52914 if (!err && nd->flags & LOOKUP_DIRECTORY) {
52915 if (!nd->inode->i_op->lookup) {
52916 path_put(&nd->path);
52917 @@ -2011,8 +2036,15 @@ static int filename_lookup(int dfd, struct filename *name,
52918 retval = path_lookupat(dfd, name->name,
52919 flags | LOOKUP_REVAL, nd);
52920
52921 - if (likely(!retval))
52922 + if (likely(!retval)) {
52923 audit_inode(name, nd->path.dentry, flags & LOOKUP_PARENT);
52924 + if (name->name[0] != '/' && nd->path.dentry && nd->inode) {
52925 + if (!gr_chroot_fchdir(nd->path.dentry, nd->path.mnt)) {
52926 + path_put(&nd->path);
52927 + return -ENOENT;
52928 + }
52929 + }
52930 + }
52931 return retval;
52932 }
52933
52934 @@ -2390,6 +2422,13 @@ static int may_open(struct path *path, int acc_mode, int flag)
52935 if (flag & O_NOATIME && !inode_owner_or_capable(inode))
52936 return -EPERM;
52937
52938 + if (gr_handle_rofs_blockwrite(dentry, path->mnt, acc_mode))
52939 + return -EPERM;
52940 + if (gr_handle_rawio(inode))
52941 + return -EPERM;
52942 + if (!gr_acl_handle_open(dentry, path->mnt, acc_mode))
52943 + return -EACCES;
52944 +
52945 return 0;
52946 }
52947
52948 @@ -2611,7 +2650,7 @@ looked_up:
52949 * cleared otherwise prior to returning.
52950 */
52951 static int lookup_open(struct nameidata *nd, struct path *path,
52952 - struct file *file,
52953 + struct path *link, struct file *file,
52954 const struct open_flags *op,
52955 bool got_write, int *opened)
52956 {
52957 @@ -2646,6 +2685,17 @@ static int lookup_open(struct nameidata *nd, struct path *path,
52958 /* Negative dentry, just create the file */
52959 if (!dentry->d_inode && (op->open_flag & O_CREAT)) {
52960 umode_t mode = op->mode;
52961 +
52962 + if (link && gr_handle_symlink_owner(link, dir->d_inode)) {
52963 + error = -EACCES;
52964 + goto out_dput;
52965 + }
52966 +
52967 + if (!gr_acl_handle_creat(dentry, dir, nd->path.mnt, op->open_flag, op->acc_mode, mode)) {
52968 + error = -EACCES;
52969 + goto out_dput;
52970 + }
52971 +
52972 if (!IS_POSIXACL(dir->d_inode))
52973 mode &= ~current_umask();
52974 /*
52975 @@ -2667,6 +2717,8 @@ static int lookup_open(struct nameidata *nd, struct path *path,
52976 nd->flags & LOOKUP_EXCL);
52977 if (error)
52978 goto out_dput;
52979 + else
52980 + gr_handle_create(dentry, nd->path.mnt);
52981 }
52982 out_no_open:
52983 path->dentry = dentry;
52984 @@ -2681,7 +2733,7 @@ out_dput:
52985 /*
52986 * Handle the last step of open()
52987 */
52988 -static int do_last(struct nameidata *nd, struct path *path,
52989 +static int do_last(struct nameidata *nd, struct path *path, struct path *link,
52990 struct file *file, const struct open_flags *op,
52991 int *opened, struct filename *name)
52992 {
52993 @@ -2710,16 +2762,32 @@ static int do_last(struct nameidata *nd, struct path *path,
52994 error = complete_walk(nd);
52995 if (error)
52996 return error;
52997 + if (!gr_acl_handle_hidden_file(nd->path.dentry, nd->path.mnt)) {
52998 + error = -ENOENT;
52999 + goto out;
53000 + }
53001 audit_inode(name, nd->path.dentry, 0);
53002 if (open_flag & O_CREAT) {
53003 error = -EISDIR;
53004 goto out;
53005 }
53006 + if (link && gr_handle_symlink_owner(link, nd->inode)) {
53007 + error = -EACCES;
53008 + goto out;
53009 + }
53010 goto finish_open;
53011 case LAST_BIND:
53012 error = complete_walk(nd);
53013 if (error)
53014 return error;
53015 + if (!gr_acl_handle_hidden_file(dir, nd->path.mnt)) {
53016 + error = -ENOENT;
53017 + goto out;
53018 + }
53019 + if (link && gr_handle_symlink_owner(link, nd->inode)) {
53020 + error = -EACCES;
53021 + goto out;
53022 + }
53023 audit_inode(name, dir, 0);
53024 goto finish_open;
53025 }
53026 @@ -2768,7 +2836,7 @@ retry_lookup:
53027 */
53028 }
53029 mutex_lock(&dir->d_inode->i_mutex);
53030 - error = lookup_open(nd, path, file, op, got_write, opened);
53031 + error = lookup_open(nd, path, link, file, op, got_write, opened);
53032 mutex_unlock(&dir->d_inode->i_mutex);
53033
53034 if (error <= 0) {
53035 @@ -2792,11 +2860,28 @@ retry_lookup:
53036 goto finish_open_created;
53037 }
53038
53039 + if (!gr_acl_handle_hidden_file(path->dentry, nd->path.mnt)) {
53040 + error = -ENOENT;
53041 + goto exit_dput;
53042 + }
53043 + if (link && gr_handle_symlink_owner(link, path->dentry->d_inode)) {
53044 + error = -EACCES;
53045 + goto exit_dput;
53046 + }
53047 +
53048 /*
53049 * create/update audit record if it already exists.
53050 */
53051 - if (path->dentry->d_inode)
53052 + if (path->dentry->d_inode) {
53053 + /* only check if O_CREAT is specified, all other checks need to go
53054 + into may_open */
53055 + if (gr_handle_fifo(path->dentry, path->mnt, dir, open_flag, acc_mode)) {
53056 + error = -EACCES;
53057 + goto exit_dput;
53058 + }
53059 +
53060 audit_inode(name, path->dentry, 0);
53061 + }
53062
53063 /*
53064 * If atomic_open() acquired write access it is dropped now due to
53065 @@ -2837,6 +2922,11 @@ finish_lookup:
53066 }
53067 }
53068 BUG_ON(inode != path->dentry->d_inode);
53069 + /* if we're resolving a symlink to another symlink */
53070 + if (link && gr_handle_symlink_owner(link, inode)) {
53071 + error = -EACCES;
53072 + goto out;
53073 + }
53074 return 1;
53075 }
53076
53077 @@ -2846,7 +2936,6 @@ finish_lookup:
53078 save_parent.dentry = nd->path.dentry;
53079 save_parent.mnt = mntget(path->mnt);
53080 nd->path.dentry = path->dentry;
53081 -
53082 }
53083 nd->inode = inode;
53084 /* Why this, you ask? _Now_ we might have grown LOOKUP_JUMPED... */
53085 @@ -2855,6 +2944,16 @@ finish_lookup:
53086 path_put(&save_parent);
53087 return error;
53088 }
53089 +
53090 + if (!gr_acl_handle_hidden_file(nd->path.dentry, nd->path.mnt)) {
53091 + error = -ENOENT;
53092 + goto out;
53093 + }
53094 + if (link && gr_handle_symlink_owner(link, nd->inode)) {
53095 + error = -EACCES;
53096 + goto out;
53097 + }
53098 +
53099 error = -EISDIR;
53100 if ((open_flag & O_CREAT) && S_ISDIR(nd->inode->i_mode))
53101 goto out;
53102 @@ -2953,7 +3052,7 @@ static struct file *path_openat(int dfd, struct filename *pathname,
53103 if (unlikely(error))
53104 goto out;
53105
53106 - error = do_last(nd, &path, file, op, &opened, pathname);
53107 + error = do_last(nd, &path, NULL, file, op, &opened, pathname);
53108 while (unlikely(error > 0)) { /* trailing symlink */
53109 struct path link = path;
53110 void *cookie;
53111 @@ -2971,7 +3070,7 @@ static struct file *path_openat(int dfd, struct filename *pathname,
53112 error = follow_link(&link, nd, &cookie);
53113 if (unlikely(error))
53114 break;
53115 - error = do_last(nd, &path, file, op, &opened, pathname);
53116 + error = do_last(nd, &path, &link, file, op, &opened, pathname);
53117 put_link(nd, &link, cookie);
53118 }
53119 out:
53120 @@ -3071,8 +3170,12 @@ struct dentry *kern_path_create(int dfd, const char *pathname,
53121 goto unlock;
53122
53123 error = -EEXIST;
53124 - if (dentry->d_inode)
53125 + if (dentry->d_inode) {
53126 + if (!gr_acl_handle_hidden_file(dentry, nd.path.mnt)) {
53127 + error = -ENOENT;
53128 + }
53129 goto fail;
53130 + }
53131 /*
53132 * Special case - lookup gave negative, but... we had foo/bar/
53133 * From the vfs_mknod() POV we just have a negative dentry -
53134 @@ -3124,6 +3227,20 @@ struct dentry *user_path_create(int dfd, const char __user *pathname,
53135 }
53136 EXPORT_SYMBOL(user_path_create);
53137
53138 +static struct dentry *user_path_create_with_name(int dfd, const char __user *pathname, struct path *path, struct filename **to, unsigned int lookup_flags)
53139 +{
53140 + struct filename *tmp = getname(pathname);
53141 + struct dentry *res;
53142 + if (IS_ERR(tmp))
53143 + return ERR_CAST(tmp);
53144 + res = kern_path_create(dfd, tmp->name, path, lookup_flags);
53145 + if (IS_ERR(res))
53146 + putname(tmp);
53147 + else
53148 + *to = tmp;
53149 + return res;
53150 +}
53151 +
53152 int vfs_mknod(struct inode *dir, struct dentry *dentry, umode_t mode, dev_t dev)
53153 {
53154 int error = may_create(dir, dentry);
53155 @@ -3186,6 +3303,17 @@ retry:
53156
53157 if (!IS_POSIXACL(path.dentry->d_inode))
53158 mode &= ~current_umask();
53159 +
53160 + if (gr_handle_chroot_mknod(dentry, path.mnt, mode)) {
53161 + error = -EPERM;
53162 + goto out;
53163 + }
53164 +
53165 + if (!gr_acl_handle_mknod(dentry, path.dentry, path.mnt, mode)) {
53166 + error = -EACCES;
53167 + goto out;
53168 + }
53169 +
53170 error = security_path_mknod(&path, dentry, mode, dev);
53171 if (error)
53172 goto out;
53173 @@ -3202,6 +3330,8 @@ retry:
53174 break;
53175 }
53176 out:
53177 + if (!error)
53178 + gr_handle_create(dentry, path.mnt);
53179 done_path_create(&path, dentry);
53180 if (retry_estale(error, lookup_flags)) {
53181 lookup_flags |= LOOKUP_REVAL;
53182 @@ -3254,9 +3384,16 @@ retry:
53183
53184 if (!IS_POSIXACL(path.dentry->d_inode))
53185 mode &= ~current_umask();
53186 + if (!gr_acl_handle_mkdir(dentry, path.dentry, path.mnt)) {
53187 + error = -EACCES;
53188 + goto out;
53189 + }
53190 error = security_path_mkdir(&path, dentry, mode);
53191 if (!error)
53192 error = vfs_mkdir(path.dentry->d_inode, dentry, mode);
53193 + if (!error)
53194 + gr_handle_create(dentry, path.mnt);
53195 +out:
53196 done_path_create(&path, dentry);
53197 if (retry_estale(error, lookup_flags)) {
53198 lookup_flags |= LOOKUP_REVAL;
53199 @@ -3337,6 +3474,8 @@ static long do_rmdir(int dfd, const char __user *pathname)
53200 struct filename *name;
53201 struct dentry *dentry;
53202 struct nameidata nd;
53203 + ino_t saved_ino = 0;
53204 + dev_t saved_dev = 0;
53205 unsigned int lookup_flags = 0;
53206 retry:
53207 name = user_path_parent(dfd, pathname, &nd, lookup_flags);
53208 @@ -3369,10 +3508,21 @@ retry:
53209 error = -ENOENT;
53210 goto exit3;
53211 }
53212 +
53213 + saved_ino = dentry->d_inode->i_ino;
53214 + saved_dev = gr_get_dev_from_dentry(dentry);
53215 +
53216 + if (!gr_acl_handle_rmdir(dentry, nd.path.mnt)) {
53217 + error = -EACCES;
53218 + goto exit3;
53219 + }
53220 +
53221 error = security_path_rmdir(&nd.path, dentry);
53222 if (error)
53223 goto exit3;
53224 error = vfs_rmdir(nd.path.dentry->d_inode, dentry);
53225 + if (!error && (saved_dev || saved_ino))
53226 + gr_handle_delete(saved_ino, saved_dev);
53227 exit3:
53228 dput(dentry);
53229 exit2:
53230 @@ -3438,6 +3588,8 @@ static long do_unlinkat(int dfd, const char __user *pathname)
53231 struct dentry *dentry;
53232 struct nameidata nd;
53233 struct inode *inode = NULL;
53234 + ino_t saved_ino = 0;
53235 + dev_t saved_dev = 0;
53236 unsigned int lookup_flags = 0;
53237 retry:
53238 name = user_path_parent(dfd, pathname, &nd, lookup_flags);
53239 @@ -3464,10 +3616,22 @@ retry:
53240 if (!inode)
53241 goto slashes;
53242 ihold(inode);
53243 +
53244 + if (inode->i_nlink <= 1) {
53245 + saved_ino = inode->i_ino;
53246 + saved_dev = gr_get_dev_from_dentry(dentry);
53247 + }
53248 + if (!gr_acl_handle_unlink(dentry, nd.path.mnt)) {
53249 + error = -EACCES;
53250 + goto exit2;
53251 + }
53252 +
53253 error = security_path_unlink(&nd.path, dentry);
53254 if (error)
53255 goto exit2;
53256 error = vfs_unlink(nd.path.dentry->d_inode, dentry);
53257 + if (!error && (saved_ino || saved_dev))
53258 + gr_handle_delete(saved_ino, saved_dev);
53259 exit2:
53260 dput(dentry);
53261 }
53262 @@ -3545,9 +3709,17 @@ retry:
53263 if (IS_ERR(dentry))
53264 goto out_putname;
53265
53266 + if (!gr_acl_handle_symlink(dentry, path.dentry, path.mnt, from)) {
53267 + error = -EACCES;
53268 + goto out;
53269 + }
53270 +
53271 error = security_path_symlink(&path, dentry, from->name);
53272 if (!error)
53273 error = vfs_symlink(path.dentry->d_inode, dentry, from->name);
53274 + if (!error)
53275 + gr_handle_create(dentry, path.mnt);
53276 +out:
53277 done_path_create(&path, dentry);
53278 if (retry_estale(error, lookup_flags)) {
53279 lookup_flags |= LOOKUP_REVAL;
53280 @@ -3621,6 +3793,7 @@ SYSCALL_DEFINE5(linkat, int, olddfd, const char __user *, oldname,
53281 {
53282 struct dentry *new_dentry;
53283 struct path old_path, new_path;
53284 + struct filename *to = NULL;
53285 int how = 0;
53286 int error;
53287
53288 @@ -3644,7 +3817,7 @@ retry:
53289 if (error)
53290 return error;
53291
53292 - new_dentry = user_path_create(newdfd, newname, &new_path,
53293 + new_dentry = user_path_create_with_name(newdfd, newname, &new_path, &to,
53294 (how & LOOKUP_REVAL));
53295 error = PTR_ERR(new_dentry);
53296 if (IS_ERR(new_dentry))
53297 @@ -3656,11 +3829,28 @@ retry:
53298 error = may_linkat(&old_path);
53299 if (unlikely(error))
53300 goto out_dput;
53301 +
53302 + if (gr_handle_hardlink(old_path.dentry, old_path.mnt,
53303 + old_path.dentry->d_inode,
53304 + old_path.dentry->d_inode->i_mode, to)) {
53305 + error = -EACCES;
53306 + goto out_dput;
53307 + }
53308 +
53309 + if (!gr_acl_handle_link(new_dentry, new_path.dentry, new_path.mnt,
53310 + old_path.dentry, old_path.mnt, to)) {
53311 + error = -EACCES;
53312 + goto out_dput;
53313 + }
53314 +
53315 error = security_path_link(old_path.dentry, &new_path, new_dentry);
53316 if (error)
53317 goto out_dput;
53318 error = vfs_link(old_path.dentry, new_path.dentry->d_inode, new_dentry);
53319 + if (!error)
53320 + gr_handle_create(new_dentry, new_path.mnt);
53321 out_dput:
53322 + putname(to);
53323 done_path_create(&new_path, new_dentry);
53324 if (retry_estale(error, how)) {
53325 how |= LOOKUP_REVAL;
53326 @@ -3906,12 +4096,21 @@ retry:
53327 if (new_dentry == trap)
53328 goto exit5;
53329
53330 + error = gr_acl_handle_rename(new_dentry, new_dir, newnd.path.mnt,
53331 + old_dentry, old_dir->d_inode, oldnd.path.mnt,
53332 + to);
53333 + if (error)
53334 + goto exit5;
53335 +
53336 error = security_path_rename(&oldnd.path, old_dentry,
53337 &newnd.path, new_dentry);
53338 if (error)
53339 goto exit5;
53340 error = vfs_rename(old_dir->d_inode, old_dentry,
53341 new_dir->d_inode, new_dentry);
53342 + if (!error)
53343 + gr_handle_rename(old_dir->d_inode, new_dir->d_inode, old_dentry,
53344 + new_dentry, oldnd.path.mnt, new_dentry->d_inode ? 1 : 0);
53345 exit5:
53346 dput(new_dentry);
53347 exit4:
53348 @@ -3943,6 +4142,8 @@ SYSCALL_DEFINE2(rename, const char __user *, oldname, const char __user *, newna
53349
53350 int vfs_readlink(struct dentry *dentry, char __user *buffer, int buflen, const char *link)
53351 {
53352 + char tmpbuf[64];
53353 + const char *newlink;
53354 int len;
53355
53356 len = PTR_ERR(link);
53357 @@ -3952,7 +4153,14 @@ int vfs_readlink(struct dentry *dentry, char __user *buffer, int buflen, const c
53358 len = strlen(link);
53359 if (len > (unsigned) buflen)
53360 len = buflen;
53361 - if (copy_to_user(buffer, link, len))
53362 +
53363 + if (len < sizeof(tmpbuf)) {
53364 + memcpy(tmpbuf, link, len);
53365 + newlink = tmpbuf;
53366 + } else
53367 + newlink = link;
53368 +
53369 + if (copy_to_user(buffer, newlink, len))
53370 len = -EFAULT;
53371 out:
53372 return len;
53373 diff --git a/fs/namespace.c b/fs/namespace.c
53374 index a51054f..f9b53e5 100644
53375 --- a/fs/namespace.c
53376 +++ b/fs/namespace.c
53377 @@ -1215,6 +1215,9 @@ static int do_umount(struct mount *mnt, int flags)
53378 if (!(sb->s_flags & MS_RDONLY))
53379 retval = do_remount_sb(sb, MS_RDONLY, NULL, 0);
53380 up_write(&sb->s_umount);
53381 +
53382 + gr_log_remount(mnt->mnt_devname, retval);
53383 +
53384 return retval;
53385 }
53386
53387 @@ -1234,6 +1237,9 @@ static int do_umount(struct mount *mnt, int flags)
53388 br_write_unlock(&vfsmount_lock);
53389 up_write(&namespace_sem);
53390 release_mounts(&umount_list);
53391 +
53392 + gr_log_unmount(mnt->mnt_devname, retval);
53393 +
53394 return retval;
53395 }
53396
53397 @@ -2287,6 +2293,16 @@ long do_mount(const char *dev_name, const char *dir_name,
53398 MS_NOATIME | MS_NODIRATIME | MS_RELATIME| MS_KERNMOUNT |
53399 MS_STRICTATIME);
53400
53401 + if (gr_handle_rofs_mount(path.dentry, path.mnt, mnt_flags)) {
53402 + retval = -EPERM;
53403 + goto dput_out;
53404 + }
53405 +
53406 + if (gr_handle_chroot_mount(path.dentry, path.mnt, dev_name)) {
53407 + retval = -EPERM;
53408 + goto dput_out;
53409 + }
53410 +
53411 if (flags & MS_REMOUNT)
53412 retval = do_remount(&path, flags & ~MS_REMOUNT, mnt_flags,
53413 data_page);
53414 @@ -2301,6 +2317,9 @@ long do_mount(const char *dev_name, const char *dir_name,
53415 dev_name, data_page);
53416 dput_out:
53417 path_put(&path);
53418 +
53419 + gr_log_mount(dev_name, dir_name, retval);
53420 +
53421 return retval;
53422 }
53423
53424 @@ -2587,6 +2606,11 @@ SYSCALL_DEFINE2(pivot_root, const char __user *, new_root,
53425 if (error)
53426 goto out2;
53427
53428 + if (gr_handle_chroot_pivot()) {
53429 + error = -EPERM;
53430 + goto out2;
53431 + }
53432 +
53433 get_fs_root(current->fs, &root);
53434 error = lock_mount(&old);
53435 if (error)
53436 @@ -2790,7 +2814,7 @@ static int mntns_install(struct nsproxy *nsproxy, void *ns)
53437 !nsown_capable(CAP_SYS_ADMIN))
53438 return -EPERM;
53439
53440 - if (fs->users != 1)
53441 + if (atomic_read(&fs->users) != 1)
53442 return -EINVAL;
53443
53444 get_mnt_ns(mnt_ns);
53445 diff --git a/fs/nfs/callback_xdr.c b/fs/nfs/callback_xdr.c
53446 index 59461c9..b17c57e 100644
53447 --- a/fs/nfs/callback_xdr.c
53448 +++ b/fs/nfs/callback_xdr.c
53449 @@ -51,7 +51,7 @@ struct callback_op {
53450 callback_decode_arg_t decode_args;
53451 callback_encode_res_t encode_res;
53452 long res_maxsize;
53453 -};
53454 +} __do_const;
53455
53456 static struct callback_op callback_ops[];
53457
53458 diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
53459 index ebeb94c..ff35337 100644
53460 --- a/fs/nfs/inode.c
53461 +++ b/fs/nfs/inode.c
53462 @@ -1042,16 +1042,16 @@ static int nfs_size_need_update(const struct inode *inode, const struct nfs_fatt
53463 return nfs_size_to_loff_t(fattr->size) > i_size_read(inode);
53464 }
53465
53466 -static atomic_long_t nfs_attr_generation_counter;
53467 +static atomic_long_unchecked_t nfs_attr_generation_counter;
53468
53469 static unsigned long nfs_read_attr_generation_counter(void)
53470 {
53471 - return atomic_long_read(&nfs_attr_generation_counter);
53472 + return atomic_long_read_unchecked(&nfs_attr_generation_counter);
53473 }
53474
53475 unsigned long nfs_inc_attr_generation_counter(void)
53476 {
53477 - return atomic_long_inc_return(&nfs_attr_generation_counter);
53478 + return atomic_long_inc_return_unchecked(&nfs_attr_generation_counter);
53479 }
53480
53481 void nfs_fattr_init(struct nfs_fattr *fattr)
53482 diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c
53483 index 9d1c5db..1e13db8 100644
53484 --- a/fs/nfsd/nfs4proc.c
53485 +++ b/fs/nfsd/nfs4proc.c
53486 @@ -1097,7 +1097,7 @@ struct nfsd4_operation {
53487 nfsd4op_rsize op_rsize_bop;
53488 stateid_getter op_get_currentstateid;
53489 stateid_setter op_set_currentstateid;
53490 -};
53491 +} __do_const;
53492
53493 static struct nfsd4_operation nfsd4_ops[];
53494
53495 diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
53496 index 0dc1158..ccf0338 100644
53497 --- a/fs/nfsd/nfs4xdr.c
53498 +++ b/fs/nfsd/nfs4xdr.c
53499 @@ -1456,7 +1456,7 @@ nfsd4_decode_notsupp(struct nfsd4_compoundargs *argp, void *p)
53500
53501 typedef __be32(*nfsd4_dec)(struct nfsd4_compoundargs *argp, void *);
53502
53503 -static nfsd4_dec nfsd4_dec_ops[] = {
53504 +static const nfsd4_dec nfsd4_dec_ops[] = {
53505 [OP_ACCESS] = (nfsd4_dec)nfsd4_decode_access,
53506 [OP_CLOSE] = (nfsd4_dec)nfsd4_decode_close,
53507 [OP_COMMIT] = (nfsd4_dec)nfsd4_decode_commit,
53508 @@ -1496,7 +1496,7 @@ static nfsd4_dec nfsd4_dec_ops[] = {
53509 [OP_RELEASE_LOCKOWNER] = (nfsd4_dec)nfsd4_decode_release_lockowner,
53510 };
53511
53512 -static nfsd4_dec nfsd41_dec_ops[] = {
53513 +static const nfsd4_dec nfsd41_dec_ops[] = {
53514 [OP_ACCESS] = (nfsd4_dec)nfsd4_decode_access,
53515 [OP_CLOSE] = (nfsd4_dec)nfsd4_decode_close,
53516 [OP_COMMIT] = (nfsd4_dec)nfsd4_decode_commit,
53517 @@ -1558,7 +1558,7 @@ static nfsd4_dec nfsd41_dec_ops[] = {
53518 };
53519
53520 struct nfsd4_minorversion_ops {
53521 - nfsd4_dec *decoders;
53522 + const nfsd4_dec *decoders;
53523 int nops;
53524 };
53525
53526 diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c
53527 index d586117..143d568 100644
53528 --- a/fs/nfsd/vfs.c
53529 +++ b/fs/nfsd/vfs.c
53530 @@ -939,7 +939,7 @@ nfsd_vfs_read(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
53531 } else {
53532 oldfs = get_fs();
53533 set_fs(KERNEL_DS);
53534 - host_err = vfs_readv(file, (struct iovec __user *)vec, vlen, &offset);
53535 + host_err = vfs_readv(file, (struct iovec __force_user *)vec, vlen, &offset);
53536 set_fs(oldfs);
53537 }
53538
53539 @@ -1025,7 +1025,7 @@ nfsd_vfs_write(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
53540
53541 /* Write the data. */
53542 oldfs = get_fs(); set_fs(KERNEL_DS);
53543 - host_err = vfs_writev(file, (struct iovec __user *)vec, vlen, &offset);
53544 + host_err = vfs_writev(file, (struct iovec __force_user *)vec, vlen, &offset);
53545 set_fs(oldfs);
53546 if (host_err < 0)
53547 goto out_nfserr;
53548 @@ -1571,7 +1571,7 @@ nfsd_readlink(struct svc_rqst *rqstp, struct svc_fh *fhp, char *buf, int *lenp)
53549 */
53550
53551 oldfs = get_fs(); set_fs(KERNEL_DS);
53552 - host_err = inode->i_op->readlink(path.dentry, (char __user *)buf, *lenp);
53553 + host_err = inode->i_op->readlink(path.dentry, (char __force_user *)buf, *lenp);
53554 set_fs(oldfs);
53555
53556 if (host_err < 0)
53557 diff --git a/fs/nls/nls_base.c b/fs/nls/nls_base.c
53558 index fea6bd5..8ee9d81 100644
53559 --- a/fs/nls/nls_base.c
53560 +++ b/fs/nls/nls_base.c
53561 @@ -234,20 +234,22 @@ EXPORT_SYMBOL(utf16s_to_utf8s);
53562
53563 int register_nls(struct nls_table * nls)
53564 {
53565 - struct nls_table ** tmp = &tables;
53566 + struct nls_table *tmp = tables;
53567
53568 if (nls->next)
53569 return -EBUSY;
53570
53571 spin_lock(&nls_lock);
53572 - while (*tmp) {
53573 - if (nls == *tmp) {
53574 + while (tmp) {
53575 + if (nls == tmp) {
53576 spin_unlock(&nls_lock);
53577 return -EBUSY;
53578 }
53579 - tmp = &(*tmp)->next;
53580 + tmp = tmp->next;
53581 }
53582 - nls->next = tables;
53583 + pax_open_kernel();
53584 + *(struct nls_table **)&nls->next = tables;
53585 + pax_close_kernel();
53586 tables = nls;
53587 spin_unlock(&nls_lock);
53588 return 0;
53589 @@ -255,12 +257,14 @@ int register_nls(struct nls_table * nls)
53590
53591 int unregister_nls(struct nls_table * nls)
53592 {
53593 - struct nls_table ** tmp = &tables;
53594 + struct nls_table * const * tmp = &tables;
53595
53596 spin_lock(&nls_lock);
53597 while (*tmp) {
53598 if (nls == *tmp) {
53599 - *tmp = nls->next;
53600 + pax_open_kernel();
53601 + *(struct nls_table **)tmp = nls->next;
53602 + pax_close_kernel();
53603 spin_unlock(&nls_lock);
53604 return 0;
53605 }
53606 diff --git a/fs/nls/nls_euc-jp.c b/fs/nls/nls_euc-jp.c
53607 index 7424929..35f6be5 100644
53608 --- a/fs/nls/nls_euc-jp.c
53609 +++ b/fs/nls/nls_euc-jp.c
53610 @@ -561,8 +561,10 @@ static int __init init_nls_euc_jp(void)
53611 p_nls = load_nls("cp932");
53612
53613 if (p_nls) {
53614 - table.charset2upper = p_nls->charset2upper;
53615 - table.charset2lower = p_nls->charset2lower;
53616 + pax_open_kernel();
53617 + *(const unsigned char **)&table.charset2upper = p_nls->charset2upper;
53618 + *(const unsigned char **)&table.charset2lower = p_nls->charset2lower;
53619 + pax_close_kernel();
53620 return register_nls(&table);
53621 }
53622
53623 diff --git a/fs/nls/nls_koi8-ru.c b/fs/nls/nls_koi8-ru.c
53624 index e7bc1d7..06bd4bb 100644
53625 --- a/fs/nls/nls_koi8-ru.c
53626 +++ b/fs/nls/nls_koi8-ru.c
53627 @@ -63,8 +63,10 @@ static int __init init_nls_koi8_ru(void)
53628 p_nls = load_nls("koi8-u");
53629
53630 if (p_nls) {
53631 - table.charset2upper = p_nls->charset2upper;
53632 - table.charset2lower = p_nls->charset2lower;
53633 + pax_open_kernel();
53634 + *(const unsigned char **)&table.charset2upper = p_nls->charset2upper;
53635 + *(const unsigned char **)&table.charset2lower = p_nls->charset2lower;
53636 + pax_close_kernel();
53637 return register_nls(&table);
53638 }
53639
53640 diff --git a/fs/notify/fanotify/fanotify_user.c b/fs/notify/fanotify/fanotify_user.c
53641 index 9ff4a5e..deb1f0f 100644
53642 --- a/fs/notify/fanotify/fanotify_user.c
53643 +++ b/fs/notify/fanotify/fanotify_user.c
53644 @@ -251,8 +251,8 @@ static ssize_t copy_event_to_user(struct fsnotify_group *group,
53645
53646 fd = fanotify_event_metadata.fd;
53647 ret = -EFAULT;
53648 - if (copy_to_user(buf, &fanotify_event_metadata,
53649 - fanotify_event_metadata.event_len))
53650 + if (fanotify_event_metadata.event_len > sizeof fanotify_event_metadata ||
53651 + copy_to_user(buf, &fanotify_event_metadata, fanotify_event_metadata.event_len))
53652 goto out_close_fd;
53653
53654 ret = prepare_for_access_response(group, event, fd);
53655 diff --git a/fs/notify/notification.c b/fs/notify/notification.c
53656 index 7b51b05..5ea5ef6 100644
53657 --- a/fs/notify/notification.c
53658 +++ b/fs/notify/notification.c
53659 @@ -57,7 +57,7 @@ static struct kmem_cache *fsnotify_event_holder_cachep;
53660 * get set to 0 so it will never get 'freed'
53661 */
53662 static struct fsnotify_event *q_overflow_event;
53663 -static atomic_t fsnotify_sync_cookie = ATOMIC_INIT(0);
53664 +static atomic_unchecked_t fsnotify_sync_cookie = ATOMIC_INIT(0);
53665
53666 /**
53667 * fsnotify_get_cookie - return a unique cookie for use in synchronizing events.
53668 @@ -65,7 +65,7 @@ static atomic_t fsnotify_sync_cookie = ATOMIC_INIT(0);
53669 */
53670 u32 fsnotify_get_cookie(void)
53671 {
53672 - return atomic_inc_return(&fsnotify_sync_cookie);
53673 + return atomic_inc_return_unchecked(&fsnotify_sync_cookie);
53674 }
53675 EXPORT_SYMBOL_GPL(fsnotify_get_cookie);
53676
53677 diff --git a/fs/ntfs/dir.c b/fs/ntfs/dir.c
53678 index 99e3610..02c1068 100644
53679 --- a/fs/ntfs/dir.c
53680 +++ b/fs/ntfs/dir.c
53681 @@ -1329,7 +1329,7 @@ find_next_index_buffer:
53682 ia = (INDEX_ALLOCATION*)(kaddr + (ia_pos & ~PAGE_CACHE_MASK &
53683 ~(s64)(ndir->itype.index.block_size - 1)));
53684 /* Bounds checks. */
53685 - if (unlikely((u8*)ia < kaddr || (u8*)ia > kaddr + PAGE_CACHE_SIZE)) {
53686 + if (unlikely(!kaddr || (u8*)ia < kaddr || (u8*)ia > kaddr + PAGE_CACHE_SIZE)) {
53687 ntfs_error(sb, "Out of bounds check failed. Corrupt directory "
53688 "inode 0x%lx or driver bug.", vdir->i_ino);
53689 goto err_out;
53690 diff --git a/fs/ntfs/file.c b/fs/ntfs/file.c
53691 index 5b2d4f0..c6de396 100644
53692 --- a/fs/ntfs/file.c
53693 +++ b/fs/ntfs/file.c
53694 @@ -2242,6 +2242,6 @@ const struct inode_operations ntfs_file_inode_ops = {
53695 #endif /* NTFS_RW */
53696 };
53697
53698 -const struct file_operations ntfs_empty_file_ops = {};
53699 +const struct file_operations ntfs_empty_file_ops __read_only;
53700
53701 -const struct inode_operations ntfs_empty_inode_ops = {};
53702 +const struct inode_operations ntfs_empty_inode_ops __read_only;
53703 diff --git a/fs/ocfs2/localalloc.c b/fs/ocfs2/localalloc.c
53704 index a9f78c7..ed8a381 100644
53705 --- a/fs/ocfs2/localalloc.c
53706 +++ b/fs/ocfs2/localalloc.c
53707 @@ -1279,7 +1279,7 @@ static int ocfs2_local_alloc_slide_window(struct ocfs2_super *osb,
53708 goto bail;
53709 }
53710
53711 - atomic_inc(&osb->alloc_stats.moves);
53712 + atomic_inc_unchecked(&osb->alloc_stats.moves);
53713
53714 bail:
53715 if (handle)
53716 diff --git a/fs/ocfs2/ocfs2.h b/fs/ocfs2/ocfs2.h
53717 index d355e6e..578d905 100644
53718 --- a/fs/ocfs2/ocfs2.h
53719 +++ b/fs/ocfs2/ocfs2.h
53720 @@ -235,11 +235,11 @@ enum ocfs2_vol_state
53721
53722 struct ocfs2_alloc_stats
53723 {
53724 - atomic_t moves;
53725 - atomic_t local_data;
53726 - atomic_t bitmap_data;
53727 - atomic_t bg_allocs;
53728 - atomic_t bg_extends;
53729 + atomic_unchecked_t moves;
53730 + atomic_unchecked_t local_data;
53731 + atomic_unchecked_t bitmap_data;
53732 + atomic_unchecked_t bg_allocs;
53733 + atomic_unchecked_t bg_extends;
53734 };
53735
53736 enum ocfs2_local_alloc_state
53737 diff --git a/fs/ocfs2/suballoc.c b/fs/ocfs2/suballoc.c
53738 index b7e74b5..19c6536 100644
53739 --- a/fs/ocfs2/suballoc.c
53740 +++ b/fs/ocfs2/suballoc.c
53741 @@ -872,7 +872,7 @@ static int ocfs2_reserve_suballoc_bits(struct ocfs2_super *osb,
53742 mlog_errno(status);
53743 goto bail;
53744 }
53745 - atomic_inc(&osb->alloc_stats.bg_extends);
53746 + atomic_inc_unchecked(&osb->alloc_stats.bg_extends);
53747
53748 /* You should never ask for this much metadata */
53749 BUG_ON(bits_wanted >
53750 @@ -2007,7 +2007,7 @@ int ocfs2_claim_metadata(handle_t *handle,
53751 mlog_errno(status);
53752 goto bail;
53753 }
53754 - atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
53755 + atomic_inc_unchecked(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
53756
53757 *suballoc_loc = res.sr_bg_blkno;
53758 *suballoc_bit_start = res.sr_bit_offset;
53759 @@ -2171,7 +2171,7 @@ int ocfs2_claim_new_inode_at_loc(handle_t *handle,
53760 trace_ocfs2_claim_new_inode_at_loc((unsigned long long)di_blkno,
53761 res->sr_bits);
53762
53763 - atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
53764 + atomic_inc_unchecked(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
53765
53766 BUG_ON(res->sr_bits != 1);
53767
53768 @@ -2213,7 +2213,7 @@ int ocfs2_claim_new_inode(handle_t *handle,
53769 mlog_errno(status);
53770 goto bail;
53771 }
53772 - atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
53773 + atomic_inc_unchecked(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
53774
53775 BUG_ON(res.sr_bits != 1);
53776
53777 @@ -2317,7 +2317,7 @@ int __ocfs2_claim_clusters(handle_t *handle,
53778 cluster_start,
53779 num_clusters);
53780 if (!status)
53781 - atomic_inc(&osb->alloc_stats.local_data);
53782 + atomic_inc_unchecked(&osb->alloc_stats.local_data);
53783 } else {
53784 if (min_clusters > (osb->bitmap_cpg - 1)) {
53785 /* The only paths asking for contiguousness
53786 @@ -2343,7 +2343,7 @@ int __ocfs2_claim_clusters(handle_t *handle,
53787 ocfs2_desc_bitmap_to_cluster_off(ac->ac_inode,
53788 res.sr_bg_blkno,
53789 res.sr_bit_offset);
53790 - atomic_inc(&osb->alloc_stats.bitmap_data);
53791 + atomic_inc_unchecked(&osb->alloc_stats.bitmap_data);
53792 *num_clusters = res.sr_bits;
53793 }
53794 }
53795 diff --git a/fs/ocfs2/super.c b/fs/ocfs2/super.c
53796 index 0e91ec2..f4b3fc6 100644
53797 --- a/fs/ocfs2/super.c
53798 +++ b/fs/ocfs2/super.c
53799 @@ -301,11 +301,11 @@ static int ocfs2_osb_dump(struct ocfs2_super *osb, char *buf, int len)
53800 "%10s => GlobalAllocs: %d LocalAllocs: %d "
53801 "SubAllocs: %d LAWinMoves: %d SAExtends: %d\n",
53802 "Stats",
53803 - atomic_read(&osb->alloc_stats.bitmap_data),
53804 - atomic_read(&osb->alloc_stats.local_data),
53805 - atomic_read(&osb->alloc_stats.bg_allocs),
53806 - atomic_read(&osb->alloc_stats.moves),
53807 - atomic_read(&osb->alloc_stats.bg_extends));
53808 + atomic_read_unchecked(&osb->alloc_stats.bitmap_data),
53809 + atomic_read_unchecked(&osb->alloc_stats.local_data),
53810 + atomic_read_unchecked(&osb->alloc_stats.bg_allocs),
53811 + atomic_read_unchecked(&osb->alloc_stats.moves),
53812 + atomic_read_unchecked(&osb->alloc_stats.bg_extends));
53813
53814 out += snprintf(buf + out, len - out,
53815 "%10s => State: %u Descriptor: %llu Size: %u bits "
53816 @@ -2121,11 +2121,11 @@ static int ocfs2_initialize_super(struct super_block *sb,
53817 spin_lock_init(&osb->osb_xattr_lock);
53818 ocfs2_init_steal_slots(osb);
53819
53820 - atomic_set(&osb->alloc_stats.moves, 0);
53821 - atomic_set(&osb->alloc_stats.local_data, 0);
53822 - atomic_set(&osb->alloc_stats.bitmap_data, 0);
53823 - atomic_set(&osb->alloc_stats.bg_allocs, 0);
53824 - atomic_set(&osb->alloc_stats.bg_extends, 0);
53825 + atomic_set_unchecked(&osb->alloc_stats.moves, 0);
53826 + atomic_set_unchecked(&osb->alloc_stats.local_data, 0);
53827 + atomic_set_unchecked(&osb->alloc_stats.bitmap_data, 0);
53828 + atomic_set_unchecked(&osb->alloc_stats.bg_allocs, 0);
53829 + atomic_set_unchecked(&osb->alloc_stats.bg_extends, 0);
53830
53831 /* Copy the blockcheck stats from the superblock probe */
53832 osb->osb_ecc_stats = *stats;
53833 diff --git a/fs/open.c b/fs/open.c
53834 index 9b33c0c..2ffcca2 100644
53835 --- a/fs/open.c
53836 +++ b/fs/open.c
53837 @@ -31,6 +31,8 @@
53838 #include <linux/ima.h>
53839 #include <linux/dnotify.h>
53840
53841 +#define CREATE_TRACE_POINTS
53842 +#include <trace/events/fs.h>
53843 #include "internal.h"
53844
53845 int do_truncate(struct dentry *dentry, loff_t length, unsigned int time_attrs,
53846 @@ -101,6 +103,8 @@ long vfs_truncate(struct path *path, loff_t length)
53847 error = locks_verify_truncate(inode, NULL, length);
53848 if (!error)
53849 error = security_path_truncate(path);
53850 + if (!error && !gr_acl_handle_truncate(path->dentry, path->mnt))
53851 + error = -EACCES;
53852 if (!error)
53853 error = do_truncate(path->dentry, length, 0, NULL);
53854
53855 @@ -178,6 +182,8 @@ static long do_sys_ftruncate(unsigned int fd, loff_t length, int small)
53856 error = locks_verify_truncate(inode, f.file, length);
53857 if (!error)
53858 error = security_path_truncate(&f.file->f_path);
53859 + if (!error && !gr_acl_handle_truncate(f.file->f_path.dentry, f.file->f_path.mnt))
53860 + error = -EACCES;
53861 if (!error)
53862 error = do_truncate(dentry, length, ATTR_MTIME|ATTR_CTIME, f.file);
53863 sb_end_write(inode->i_sb);
53864 @@ -373,6 +379,9 @@ retry:
53865 if (__mnt_is_readonly(path.mnt))
53866 res = -EROFS;
53867
53868 + if (!res && !gr_acl_handle_access(path.dentry, path.mnt, mode))
53869 + res = -EACCES;
53870 +
53871 out_path_release:
53872 path_put(&path);
53873 if (retry_estale(res, lookup_flags)) {
53874 @@ -404,6 +413,8 @@ retry:
53875 if (error)
53876 goto dput_and_out;
53877
53878 + gr_log_chdir(path.dentry, path.mnt);
53879 +
53880 set_fs_pwd(current->fs, &path);
53881
53882 dput_and_out:
53883 @@ -433,6 +444,13 @@ SYSCALL_DEFINE1(fchdir, unsigned int, fd)
53884 goto out_putf;
53885
53886 error = inode_permission(inode, MAY_EXEC | MAY_CHDIR);
53887 +
53888 + if (!error && !gr_chroot_fchdir(f.file->f_path.dentry, f.file->f_path.mnt))
53889 + error = -EPERM;
53890 +
53891 + if (!error)
53892 + gr_log_chdir(f.file->f_path.dentry, f.file->f_path.mnt);
53893 +
53894 if (!error)
53895 set_fs_pwd(current->fs, &f.file->f_path);
53896 out_putf:
53897 @@ -462,7 +480,13 @@ retry:
53898 if (error)
53899 goto dput_and_out;
53900
53901 + if (gr_handle_chroot_chroot(path.dentry, path.mnt))
53902 + goto dput_and_out;
53903 +
53904 set_fs_root(current->fs, &path);
53905 +
53906 + gr_handle_chroot_chdir(&path);
53907 +
53908 error = 0;
53909 dput_and_out:
53910 path_put(&path);
53911 @@ -484,6 +508,16 @@ static int chmod_common(struct path *path, umode_t mode)
53912 if (error)
53913 return error;
53914 mutex_lock(&inode->i_mutex);
53915 +
53916 + if (!gr_acl_handle_chmod(path->dentry, path->mnt, &mode)) {
53917 + error = -EACCES;
53918 + goto out_unlock;
53919 + }
53920 + if (gr_handle_chroot_chmod(path->dentry, path->mnt, mode)) {
53921 + error = -EACCES;
53922 + goto out_unlock;
53923 + }
53924 +
53925 error = security_path_chmod(path, mode);
53926 if (error)
53927 goto out_unlock;
53928 @@ -544,6 +578,9 @@ static int chown_common(struct path *path, uid_t user, gid_t group)
53929 uid = make_kuid(current_user_ns(), user);
53930 gid = make_kgid(current_user_ns(), group);
53931
53932 + if (!gr_acl_handle_chown(path->dentry, path->mnt))
53933 + return -EACCES;
53934 +
53935 newattrs.ia_valid = ATTR_CTIME;
53936 if (user != (uid_t) -1) {
53937 if (!uid_valid(uid))
53938 @@ -960,6 +997,7 @@ long do_sys_open(int dfd, const char __user *filename, int flags, umode_t mode)
53939 } else {
53940 fsnotify_open(f);
53941 fd_install(fd, f);
53942 + trace_do_sys_open(tmp->name, flags, mode);
53943 }
53944 }
53945 putname(tmp);
53946 diff --git a/fs/pipe.c b/fs/pipe.c
53947 index 8e2e73f..1ef1048 100644
53948 --- a/fs/pipe.c
53949 +++ b/fs/pipe.c
53950 @@ -438,9 +438,9 @@ redo:
53951 }
53952 if (bufs) /* More to do? */
53953 continue;
53954 - if (!pipe->writers)
53955 + if (!atomic_read(&pipe->writers))
53956 break;
53957 - if (!pipe->waiting_writers) {
53958 + if (!atomic_read(&pipe->waiting_writers)) {
53959 /* syscall merging: Usually we must not sleep
53960 * if O_NONBLOCK is set, or if we got some data.
53961 * But if a writer sleeps in kernel space, then
53962 @@ -504,7 +504,7 @@ pipe_write(struct kiocb *iocb, const struct iovec *_iov,
53963 mutex_lock(&inode->i_mutex);
53964 pipe = inode->i_pipe;
53965
53966 - if (!pipe->readers) {
53967 + if (!atomic_read(&pipe->readers)) {
53968 send_sig(SIGPIPE, current, 0);
53969 ret = -EPIPE;
53970 goto out;
53971 @@ -553,7 +553,7 @@ redo1:
53972 for (;;) {
53973 int bufs;
53974
53975 - if (!pipe->readers) {
53976 + if (!atomic_read(&pipe->readers)) {
53977 send_sig(SIGPIPE, current, 0);
53978 if (!ret)
53979 ret = -EPIPE;
53980 @@ -644,9 +644,9 @@ redo2:
53981 kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN);
53982 do_wakeup = 0;
53983 }
53984 - pipe->waiting_writers++;
53985 + atomic_inc(&pipe->waiting_writers);
53986 pipe_wait(pipe);
53987 - pipe->waiting_writers--;
53988 + atomic_dec(&pipe->waiting_writers);
53989 }
53990 out:
53991 mutex_unlock(&inode->i_mutex);
53992 @@ -716,7 +716,7 @@ pipe_poll(struct file *filp, poll_table *wait)
53993 mask = 0;
53994 if (filp->f_mode & FMODE_READ) {
53995 mask = (nrbufs > 0) ? POLLIN | POLLRDNORM : 0;
53996 - if (!pipe->writers && filp->f_version != pipe->w_counter)
53997 + if (!atomic_read(&pipe->writers) && filp->f_version != pipe->w_counter)
53998 mask |= POLLHUP;
53999 }
54000
54001 @@ -726,7 +726,7 @@ pipe_poll(struct file *filp, poll_table *wait)
54002 * Most Unices do not set POLLERR for FIFOs but on Linux they
54003 * behave exactly like pipes for poll().
54004 */
54005 - if (!pipe->readers)
54006 + if (!atomic_read(&pipe->readers))
54007 mask |= POLLERR;
54008 }
54009
54010 @@ -740,10 +740,10 @@ pipe_release(struct inode *inode, int decr, int decw)
54011
54012 mutex_lock(&inode->i_mutex);
54013 pipe = inode->i_pipe;
54014 - pipe->readers -= decr;
54015 - pipe->writers -= decw;
54016 + atomic_sub(decr, &pipe->readers);
54017 + atomic_sub(decw, &pipe->writers);
54018
54019 - if (!pipe->readers && !pipe->writers) {
54020 + if (!atomic_read(&pipe->readers) && !atomic_read(&pipe->writers)) {
54021 free_pipe_info(inode);
54022 } else {
54023 wake_up_interruptible_sync_poll(&pipe->wait, POLLIN | POLLOUT | POLLRDNORM | POLLWRNORM | POLLERR | POLLHUP);
54024 @@ -833,7 +833,7 @@ pipe_read_open(struct inode *inode, struct file *filp)
54025
54026 if (inode->i_pipe) {
54027 ret = 0;
54028 - inode->i_pipe->readers++;
54029 + atomic_inc(&inode->i_pipe->readers);
54030 }
54031
54032 mutex_unlock(&inode->i_mutex);
54033 @@ -850,7 +850,7 @@ pipe_write_open(struct inode *inode, struct file *filp)
54034
54035 if (inode->i_pipe) {
54036 ret = 0;
54037 - inode->i_pipe->writers++;
54038 + atomic_inc(&inode->i_pipe->writers);
54039 }
54040
54041 mutex_unlock(&inode->i_mutex);
54042 @@ -871,9 +871,9 @@ pipe_rdwr_open(struct inode *inode, struct file *filp)
54043 if (inode->i_pipe) {
54044 ret = 0;
54045 if (filp->f_mode & FMODE_READ)
54046 - inode->i_pipe->readers++;
54047 + atomic_inc(&inode->i_pipe->readers);
54048 if (filp->f_mode & FMODE_WRITE)
54049 - inode->i_pipe->writers++;
54050 + atomic_inc(&inode->i_pipe->writers);
54051 }
54052
54053 mutex_unlock(&inode->i_mutex);
54054 @@ -965,7 +965,7 @@ void free_pipe_info(struct inode *inode)
54055 inode->i_pipe = NULL;
54056 }
54057
54058 -static struct vfsmount *pipe_mnt __read_mostly;
54059 +struct vfsmount *pipe_mnt __read_mostly;
54060
54061 /*
54062 * pipefs_dname() is called from d_path().
54063 @@ -995,7 +995,8 @@ static struct inode * get_pipe_inode(void)
54064 goto fail_iput;
54065 inode->i_pipe = pipe;
54066
54067 - pipe->readers = pipe->writers = 1;
54068 + atomic_set(&pipe->readers, 1);
54069 + atomic_set(&pipe->writers, 1);
54070 inode->i_fop = &rdwr_pipefifo_fops;
54071
54072 /*
54073 diff --git a/fs/proc/Kconfig b/fs/proc/Kconfig
54074 index 15af622..0e9f4467 100644
54075 --- a/fs/proc/Kconfig
54076 +++ b/fs/proc/Kconfig
54077 @@ -30,12 +30,12 @@ config PROC_FS
54078
54079 config PROC_KCORE
54080 bool "/proc/kcore support" if !ARM
54081 - depends on PROC_FS && MMU
54082 + depends on PROC_FS && MMU && !GRKERNSEC_PROC_ADD
54083
54084 config PROC_VMCORE
54085 bool "/proc/vmcore support"
54086 - depends on PROC_FS && CRASH_DUMP
54087 - default y
54088 + depends on PROC_FS && CRASH_DUMP && !GRKERNSEC
54089 + default n
54090 help
54091 Exports the dump image of crashed kernel in ELF format.
54092
54093 @@ -59,8 +59,8 @@ config PROC_SYSCTL
54094 limited in memory.
54095
54096 config PROC_PAGE_MONITOR
54097 - default y
54098 - depends on PROC_FS && MMU
54099 + default n
54100 + depends on PROC_FS && MMU && !GRKERNSEC
54101 bool "Enable /proc page monitoring" if EXPERT
54102 help
54103 Various /proc files exist to monitor process memory utilization:
54104 diff --git a/fs/proc/array.c b/fs/proc/array.c
54105 index 6a91e6f..e54dbc14 100644
54106 --- a/fs/proc/array.c
54107 +++ b/fs/proc/array.c
54108 @@ -60,6 +60,7 @@
54109 #include <linux/tty.h>
54110 #include <linux/string.h>
54111 #include <linux/mman.h>
54112 +#include <linux/grsecurity.h>
54113 #include <linux/proc_fs.h>
54114 #include <linux/ioport.h>
54115 #include <linux/uaccess.h>
54116 @@ -362,6 +363,21 @@ static void task_cpus_allowed(struct seq_file *m, struct task_struct *task)
54117 seq_putc(m, '\n');
54118 }
54119
54120 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
54121 +static inline void task_pax(struct seq_file *m, struct task_struct *p)
54122 +{
54123 + if (p->mm)
54124 + seq_printf(m, "PaX:\t%c%c%c%c%c\n",
54125 + p->mm->pax_flags & MF_PAX_PAGEEXEC ? 'P' : 'p',
54126 + p->mm->pax_flags & MF_PAX_EMUTRAMP ? 'E' : 'e',
54127 + p->mm->pax_flags & MF_PAX_MPROTECT ? 'M' : 'm',
54128 + p->mm->pax_flags & MF_PAX_RANDMMAP ? 'R' : 'r',
54129 + p->mm->pax_flags & MF_PAX_SEGMEXEC ? 'S' : 's');
54130 + else
54131 + seq_printf(m, "PaX:\t-----\n");
54132 +}
54133 +#endif
54134 +
54135 int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
54136 struct pid *pid, struct task_struct *task)
54137 {
54138 @@ -380,9 +396,24 @@ int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
54139 task_cpus_allowed(m, task);
54140 cpuset_task_status_allowed(m, task);
54141 task_context_switch_counts(m, task);
54142 +
54143 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
54144 + task_pax(m, task);
54145 +#endif
54146 +
54147 +#if defined(CONFIG_GRKERNSEC) && !defined(CONFIG_GRKERNSEC_NO_RBAC)
54148 + task_grsec_rbac(m, task);
54149 +#endif
54150 +
54151 return 0;
54152 }
54153
54154 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
54155 +#define PAX_RAND_FLAGS(_mm) (_mm != NULL && _mm != current->mm && \
54156 + (_mm->pax_flags & MF_PAX_RANDMMAP || \
54157 + _mm->pax_flags & MF_PAX_SEGMEXEC))
54158 +#endif
54159 +
54160 static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
54161 struct pid *pid, struct task_struct *task, int whole)
54162 {
54163 @@ -404,6 +435,13 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
54164 char tcomm[sizeof(task->comm)];
54165 unsigned long flags;
54166
54167 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
54168 + if (current->exec_id != m->exec_id) {
54169 + gr_log_badprocpid("stat");
54170 + return 0;
54171 + }
54172 +#endif
54173 +
54174 state = *get_task_state(task);
54175 vsize = eip = esp = 0;
54176 permitted = ptrace_may_access(task, PTRACE_MODE_READ | PTRACE_MODE_NOAUDIT);
54177 @@ -475,6 +513,19 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
54178 gtime = task->gtime;
54179 }
54180
54181 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
54182 + if (PAX_RAND_FLAGS(mm)) {
54183 + eip = 0;
54184 + esp = 0;
54185 + wchan = 0;
54186 + }
54187 +#endif
54188 +#ifdef CONFIG_GRKERNSEC_HIDESYM
54189 + wchan = 0;
54190 + eip =0;
54191 + esp =0;
54192 +#endif
54193 +
54194 /* scale priority and nice values from timeslices to -20..20 */
54195 /* to make it look like a "normal" Unix priority/nice value */
54196 priority = task_prio(task);
54197 @@ -511,9 +562,15 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
54198 seq_put_decimal_ull(m, ' ', vsize);
54199 seq_put_decimal_ull(m, ' ', mm ? get_mm_rss(mm) : 0);
54200 seq_put_decimal_ull(m, ' ', rsslim);
54201 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
54202 + seq_put_decimal_ull(m, ' ', PAX_RAND_FLAGS(mm) ? 1 : (mm ? (permitted ? mm->start_code : 1) : 0));
54203 + seq_put_decimal_ull(m, ' ', PAX_RAND_FLAGS(mm) ? 1 : (mm ? (permitted ? mm->end_code : 1) : 0));
54204 + seq_put_decimal_ull(m, ' ', PAX_RAND_FLAGS(mm) ? 0 : ((permitted && mm) ? mm->start_stack : 0));
54205 +#else
54206 seq_put_decimal_ull(m, ' ', mm ? (permitted ? mm->start_code : 1) : 0);
54207 seq_put_decimal_ull(m, ' ', mm ? (permitted ? mm->end_code : 1) : 0);
54208 seq_put_decimal_ull(m, ' ', (permitted && mm) ? mm->start_stack : 0);
54209 +#endif
54210 seq_put_decimal_ull(m, ' ', esp);
54211 seq_put_decimal_ull(m, ' ', eip);
54212 /* The signal information here is obsolete.
54213 @@ -535,7 +592,11 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
54214 seq_put_decimal_ull(m, ' ', cputime_to_clock_t(gtime));
54215 seq_put_decimal_ll(m, ' ', cputime_to_clock_t(cgtime));
54216
54217 - if (mm && permitted) {
54218 + if (mm && permitted
54219 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
54220 + && !PAX_RAND_FLAGS(mm)
54221 +#endif
54222 + ) {
54223 seq_put_decimal_ull(m, ' ', mm->start_data);
54224 seq_put_decimal_ull(m, ' ', mm->end_data);
54225 seq_put_decimal_ull(m, ' ', mm->start_brk);
54226 @@ -573,8 +634,15 @@ int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns,
54227 struct pid *pid, struct task_struct *task)
54228 {
54229 unsigned long size = 0, resident = 0, shared = 0, text = 0, data = 0;
54230 - struct mm_struct *mm = get_task_mm(task);
54231 + struct mm_struct *mm;
54232
54233 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
54234 + if (current->exec_id != m->exec_id) {
54235 + gr_log_badprocpid("statm");
54236 + return 0;
54237 + }
54238 +#endif
54239 + mm = get_task_mm(task);
54240 if (mm) {
54241 size = task_statm(mm, &shared, &text, &data, &resident);
54242 mmput(mm);
54243 @@ -597,6 +665,13 @@ int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns,
54244 return 0;
54245 }
54246
54247 +#ifdef CONFIG_GRKERNSEC_PROC_IPADDR
54248 +int proc_pid_ipaddr(struct task_struct *task, char *buffer)
54249 +{
54250 + return sprintf(buffer, "%pI4\n", &task->signal->curr_ip);
54251 +}
54252 +#endif
54253 +
54254 #ifdef CONFIG_CHECKPOINT_RESTORE
54255 static struct pid *
54256 get_children_pid(struct inode *inode, struct pid *pid_prev, loff_t pos)
54257 diff --git a/fs/proc/base.c b/fs/proc/base.c
54258 index 9b43ff77..ba3e990 100644
54259 --- a/fs/proc/base.c
54260 +++ b/fs/proc/base.c
54261 @@ -111,6 +111,14 @@ struct pid_entry {
54262 union proc_op op;
54263 };
54264
54265 +struct getdents_callback {
54266 + struct linux_dirent __user * current_dir;
54267 + struct linux_dirent __user * previous;
54268 + struct file * file;
54269 + int count;
54270 + int error;
54271 +};
54272 +
54273 #define NOD(NAME, MODE, IOP, FOP, OP) { \
54274 .name = (NAME), \
54275 .len = sizeof(NAME) - 1, \
54276 @@ -208,6 +216,9 @@ static int proc_pid_cmdline(struct task_struct *task, char * buffer)
54277 if (!mm->arg_end)
54278 goto out_mm; /* Shh! No looking before we're done */
54279
54280 + if (gr_acl_handle_procpidmem(task))
54281 + goto out_mm;
54282 +
54283 len = mm->arg_end - mm->arg_start;
54284
54285 if (len > PAGE_SIZE)
54286 @@ -235,12 +246,28 @@ out:
54287 return res;
54288 }
54289
54290 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
54291 +#define PAX_RAND_FLAGS(_mm) (_mm != NULL && _mm != current->mm && \
54292 + (_mm->pax_flags & MF_PAX_RANDMMAP || \
54293 + _mm->pax_flags & MF_PAX_SEGMEXEC))
54294 +#endif
54295 +
54296 static int proc_pid_auxv(struct task_struct *task, char *buffer)
54297 {
54298 struct mm_struct *mm = mm_access(task, PTRACE_MODE_READ);
54299 int res = PTR_ERR(mm);
54300 if (mm && !IS_ERR(mm)) {
54301 unsigned int nwords = 0;
54302 +
54303 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
54304 + /* allow if we're currently ptracing this task */
54305 + if (PAX_RAND_FLAGS(mm) &&
54306 + (!(task->ptrace & PT_PTRACED) || (task->parent != current))) {
54307 + mmput(mm);
54308 + return 0;
54309 + }
54310 +#endif
54311 +
54312 do {
54313 nwords += 2;
54314 } while (mm->saved_auxv[nwords - 2] != 0); /* AT_NULL */
54315 @@ -254,7 +281,7 @@ static int proc_pid_auxv(struct task_struct *task, char *buffer)
54316 }
54317
54318
54319 -#ifdef CONFIG_KALLSYMS
54320 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
54321 /*
54322 * Provides a wchan file via kallsyms in a proper one-value-per-file format.
54323 * Returns the resolved symbol. If that fails, simply return the address.
54324 @@ -293,7 +320,7 @@ static void unlock_trace(struct task_struct *task)
54325 mutex_unlock(&task->signal->cred_guard_mutex);
54326 }
54327
54328 -#ifdef CONFIG_STACKTRACE
54329 +#if defined(CONFIG_STACKTRACE) && !defined(CONFIG_GRKERNSEC_HIDESYM)
54330
54331 #define MAX_STACK_TRACE_DEPTH 64
54332
54333 @@ -485,7 +512,7 @@ static int proc_pid_limits(struct task_struct *task, char *buffer)
54334 return count;
54335 }
54336
54337 -#ifdef CONFIG_HAVE_ARCH_TRACEHOOK
54338 +#if defined(CONFIG_HAVE_ARCH_TRACEHOOK) && !defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
54339 static int proc_pid_syscall(struct task_struct *task, char *buffer)
54340 {
54341 long nr;
54342 @@ -514,7 +541,7 @@ static int proc_pid_syscall(struct task_struct *task, char *buffer)
54343 /************************************************************************/
54344
54345 /* permission checks */
54346 -static int proc_fd_access_allowed(struct inode *inode)
54347 +static int proc_fd_access_allowed(struct inode *inode, unsigned int log)
54348 {
54349 struct task_struct *task;
54350 int allowed = 0;
54351 @@ -524,7 +551,10 @@ static int proc_fd_access_allowed(struct inode *inode)
54352 */
54353 task = get_proc_task(inode);
54354 if (task) {
54355 - allowed = ptrace_may_access(task, PTRACE_MODE_READ);
54356 + if (log)
54357 + allowed = ptrace_may_access(task, PTRACE_MODE_READ);
54358 + else
54359 + allowed = ptrace_may_access(task, PTRACE_MODE_READ | PTRACE_MODE_NOAUDIT);
54360 put_task_struct(task);
54361 }
54362 return allowed;
54363 @@ -555,10 +585,35 @@ static bool has_pid_permissions(struct pid_namespace *pid,
54364 struct task_struct *task,
54365 int hide_pid_min)
54366 {
54367 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
54368 + return false;
54369 +
54370 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
54371 + rcu_read_lock();
54372 + {
54373 + const struct cred *tmpcred = current_cred();
54374 + const struct cred *cred = __task_cred(task);
54375 +
54376 + if (uid_eq(tmpcred->uid, GLOBAL_ROOT_UID) || uid_eq(tmpcred->uid, cred->uid)
54377 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
54378 + || in_group_p(grsec_proc_gid)
54379 +#endif
54380 + ) {
54381 + rcu_read_unlock();
54382 + return true;
54383 + }
54384 + }
54385 + rcu_read_unlock();
54386 +
54387 + if (!pid->hide_pid)
54388 + return false;
54389 +#endif
54390 +
54391 if (pid->hide_pid < hide_pid_min)
54392 return true;
54393 if (in_group_p(pid->pid_gid))
54394 return true;
54395 +
54396 return ptrace_may_access(task, PTRACE_MODE_READ);
54397 }
54398
54399 @@ -576,7 +631,11 @@ static int proc_pid_permission(struct inode *inode, int mask)
54400 put_task_struct(task);
54401
54402 if (!has_perms) {
54403 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
54404 + {
54405 +#else
54406 if (pid->hide_pid == 2) {
54407 +#endif
54408 /*
54409 * Let's make getdents(), stat(), and open()
54410 * consistent with each other. If a process
54411 @@ -674,6 +733,11 @@ static int __mem_open(struct inode *inode, struct file *file, unsigned int mode)
54412 if (!task)
54413 return -ESRCH;
54414
54415 + if (gr_acl_handle_procpidmem(task)) {
54416 + put_task_struct(task);
54417 + return -EPERM;
54418 + }
54419 +
54420 mm = mm_access(task, mode);
54421 put_task_struct(task);
54422
54423 @@ -689,6 +753,10 @@ static int __mem_open(struct inode *inode, struct file *file, unsigned int mode)
54424
54425 file->private_data = mm;
54426
54427 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
54428 + file->f_version = current->exec_id;
54429 +#endif
54430 +
54431 return 0;
54432 }
54433
54434 @@ -710,6 +778,17 @@ static ssize_t mem_rw(struct file *file, char __user *buf,
54435 ssize_t copied;
54436 char *page;
54437
54438 +#ifdef CONFIG_GRKERNSEC
54439 + if (write)
54440 + return -EPERM;
54441 +#endif
54442 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
54443 + if (file->f_version != current->exec_id) {
54444 + gr_log_badprocpid("mem");
54445 + return 0;
54446 + }
54447 +#endif
54448 +
54449 if (!mm)
54450 return 0;
54451
54452 @@ -814,6 +893,13 @@ static ssize_t environ_read(struct file *file, char __user *buf,
54453 if (!mm)
54454 return 0;
54455
54456 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
54457 + if (file->f_version != current->exec_id) {
54458 + gr_log_badprocpid("environ");
54459 + return 0;
54460 + }
54461 +#endif
54462 +
54463 page = (char *)__get_free_page(GFP_TEMPORARY);
54464 if (!page)
54465 return -ENOMEM;
54466 @@ -1429,7 +1515,7 @@ static void *proc_pid_follow_link(struct dentry *dentry, struct nameidata *nd)
54467 int error = -EACCES;
54468
54469 /* Are we allowed to snoop on the tasks file descriptors? */
54470 - if (!proc_fd_access_allowed(inode))
54471 + if (!proc_fd_access_allowed(inode, 0))
54472 goto out;
54473
54474 error = PROC_I(inode)->op.proc_get_link(dentry, &path);
54475 @@ -1473,8 +1559,18 @@ static int proc_pid_readlink(struct dentry * dentry, char __user * buffer, int b
54476 struct path path;
54477
54478 /* Are we allowed to snoop on the tasks file descriptors? */
54479 - if (!proc_fd_access_allowed(inode))
54480 - goto out;
54481 + /* logging this is needed for learning on chromium to work properly,
54482 + but we don't want to flood the logs from 'ps' which does a readlink
54483 + on /proc/fd/2 of tasks in the listing, nor do we want 'ps' to learn
54484 + CAP_SYS_PTRACE as it's not necessary for its basic functionality
54485 + */
54486 + if (dentry->d_name.name[0] == '2' && dentry->d_name.name[1] == '\0') {
54487 + if (!proc_fd_access_allowed(inode,0))
54488 + goto out;
54489 + } else {
54490 + if (!proc_fd_access_allowed(inode,1))
54491 + goto out;
54492 + }
54493
54494 error = PROC_I(inode)->op.proc_get_link(dentry, &path);
54495 if (error)
54496 @@ -1524,7 +1620,11 @@ struct inode *proc_pid_make_inode(struct super_block * sb, struct task_struct *t
54497 rcu_read_lock();
54498 cred = __task_cred(task);
54499 inode->i_uid = cred->euid;
54500 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
54501 + inode->i_gid = grsec_proc_gid;
54502 +#else
54503 inode->i_gid = cred->egid;
54504 +#endif
54505 rcu_read_unlock();
54506 }
54507 security_task_to_inode(task, inode);
54508 @@ -1560,10 +1660,19 @@ int pid_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat)
54509 return -ENOENT;
54510 }
54511 if ((inode->i_mode == (S_IFDIR|S_IRUGO|S_IXUGO)) ||
54512 +#ifdef CONFIG_GRKERNSEC_PROC_USER
54513 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IXUSR)) ||
54514 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
54515 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IRGRP|S_IXUSR|S_IXGRP)) ||
54516 +#endif
54517 task_dumpable(task)) {
54518 cred = __task_cred(task);
54519 stat->uid = cred->euid;
54520 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
54521 + stat->gid = grsec_proc_gid;
54522 +#else
54523 stat->gid = cred->egid;
54524 +#endif
54525 }
54526 }
54527 rcu_read_unlock();
54528 @@ -1601,11 +1710,20 @@ int pid_revalidate(struct dentry *dentry, unsigned int flags)
54529
54530 if (task) {
54531 if ((inode->i_mode == (S_IFDIR|S_IRUGO|S_IXUGO)) ||
54532 +#ifdef CONFIG_GRKERNSEC_PROC_USER
54533 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IXUSR)) ||
54534 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
54535 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IRGRP|S_IXUSR|S_IXGRP)) ||
54536 +#endif
54537 task_dumpable(task)) {
54538 rcu_read_lock();
54539 cred = __task_cred(task);
54540 inode->i_uid = cred->euid;
54541 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
54542 + inode->i_gid = grsec_proc_gid;
54543 +#else
54544 inode->i_gid = cred->egid;
54545 +#endif
54546 rcu_read_unlock();
54547 } else {
54548 inode->i_uid = GLOBAL_ROOT_UID;
54549 @@ -2058,6 +2176,9 @@ static struct dentry *proc_pident_lookup(struct inode *dir,
54550 if (!task)
54551 goto out_no_task;
54552
54553 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
54554 + goto out;
54555 +
54556 /*
54557 * Yes, it does not scale. And it should not. Don't add
54558 * new entries into /proc/<tgid>/ without very good reasons.
54559 @@ -2102,6 +2223,9 @@ static int proc_pident_readdir(struct file *filp,
54560 if (!task)
54561 goto out_no_task;
54562
54563 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
54564 + goto out;
54565 +
54566 ret = 0;
54567 i = filp->f_pos;
54568 switch (i) {
54569 @@ -2515,7 +2639,7 @@ static const struct pid_entry tgid_base_stuff[] = {
54570 REG("autogroup", S_IRUGO|S_IWUSR, proc_pid_sched_autogroup_operations),
54571 #endif
54572 REG("comm", S_IRUGO|S_IWUSR, proc_pid_set_comm_operations),
54573 -#ifdef CONFIG_HAVE_ARCH_TRACEHOOK
54574 +#if defined(CONFIG_HAVE_ARCH_TRACEHOOK) && !defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
54575 INF("syscall", S_IRUGO, proc_pid_syscall),
54576 #endif
54577 INF("cmdline", S_IRUGO, proc_pid_cmdline),
54578 @@ -2540,10 +2664,10 @@ static const struct pid_entry tgid_base_stuff[] = {
54579 #ifdef CONFIG_SECURITY
54580 DIR("attr", S_IRUGO|S_IXUGO, proc_attr_dir_inode_operations, proc_attr_dir_operations),
54581 #endif
54582 -#ifdef CONFIG_KALLSYMS
54583 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
54584 INF("wchan", S_IRUGO, proc_pid_wchan),
54585 #endif
54586 -#ifdef CONFIG_STACKTRACE
54587 +#if defined(CONFIG_STACKTRACE) && !defined(CONFIG_GRKERNSEC_HIDESYM)
54588 ONE("stack", S_IRUGO, proc_pid_stack),
54589 #endif
54590 #ifdef CONFIG_SCHEDSTATS
54591 @@ -2577,6 +2701,9 @@ static const struct pid_entry tgid_base_stuff[] = {
54592 #ifdef CONFIG_HARDWALL
54593 INF("hardwall", S_IRUGO, proc_pid_hardwall),
54594 #endif
54595 +#ifdef CONFIG_GRKERNSEC_PROC_IPADDR
54596 + INF("ipaddr", S_IRUSR, proc_pid_ipaddr),
54597 +#endif
54598 #ifdef CONFIG_USER_NS
54599 REG("uid_map", S_IRUGO|S_IWUSR, proc_uid_map_operations),
54600 REG("gid_map", S_IRUGO|S_IWUSR, proc_gid_map_operations),
54601 @@ -2705,7 +2832,14 @@ static struct dentry *proc_pid_instantiate(struct inode *dir,
54602 if (!inode)
54603 goto out;
54604
54605 +#ifdef CONFIG_GRKERNSEC_PROC_USER
54606 + inode->i_mode = S_IFDIR|S_IRUSR|S_IXUSR;
54607 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
54608 + inode->i_gid = grsec_proc_gid;
54609 + inode->i_mode = S_IFDIR|S_IRUSR|S_IRGRP|S_IXUSR|S_IXGRP;
54610 +#else
54611 inode->i_mode = S_IFDIR|S_IRUGO|S_IXUGO;
54612 +#endif
54613 inode->i_op = &proc_tgid_base_inode_operations;
54614 inode->i_fop = &proc_tgid_base_operations;
54615 inode->i_flags|=S_IMMUTABLE;
54616 @@ -2743,7 +2877,11 @@ struct dentry *proc_pid_lookup(struct inode *dir, struct dentry * dentry, unsign
54617 if (!task)
54618 goto out;
54619
54620 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
54621 + goto out_put_task;
54622 +
54623 result = proc_pid_instantiate(dir, dentry, task, NULL);
54624 +out_put_task:
54625 put_task_struct(task);
54626 out:
54627 return result;
54628 @@ -2806,6 +2944,8 @@ static int proc_pid_fill_cache(struct file *filp, void *dirent, filldir_t filldi
54629 static int fake_filldir(void *buf, const char *name, int namelen,
54630 loff_t offset, u64 ino, unsigned d_type)
54631 {
54632 + struct getdents_callback * __buf = (struct getdents_callback *) buf;
54633 + __buf->error = -EINVAL;
54634 return 0;
54635 }
54636
54637 @@ -2857,7 +2997,7 @@ static const struct pid_entry tid_base_stuff[] = {
54638 REG("sched", S_IRUGO|S_IWUSR, proc_pid_sched_operations),
54639 #endif
54640 REG("comm", S_IRUGO|S_IWUSR, proc_pid_set_comm_operations),
54641 -#ifdef CONFIG_HAVE_ARCH_TRACEHOOK
54642 +#if defined(CONFIG_HAVE_ARCH_TRACEHOOK) && !defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
54643 INF("syscall", S_IRUGO, proc_pid_syscall),
54644 #endif
54645 INF("cmdline", S_IRUGO, proc_pid_cmdline),
54646 @@ -2884,10 +3024,10 @@ static const struct pid_entry tid_base_stuff[] = {
54647 #ifdef CONFIG_SECURITY
54648 DIR("attr", S_IRUGO|S_IXUGO, proc_attr_dir_inode_operations, proc_attr_dir_operations),
54649 #endif
54650 -#ifdef CONFIG_KALLSYMS
54651 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
54652 INF("wchan", S_IRUGO, proc_pid_wchan),
54653 #endif
54654 -#ifdef CONFIG_STACKTRACE
54655 +#if defined(CONFIG_STACKTRACE) && !defined(CONFIG_GRKERNSEC_HIDESYM)
54656 ONE("stack", S_IRUGO, proc_pid_stack),
54657 #endif
54658 #ifdef CONFIG_SCHEDSTATS
54659 diff --git a/fs/proc/cmdline.c b/fs/proc/cmdline.c
54660 index 82676e3..5f8518a 100644
54661 --- a/fs/proc/cmdline.c
54662 +++ b/fs/proc/cmdline.c
54663 @@ -23,7 +23,11 @@ static const struct file_operations cmdline_proc_fops = {
54664
54665 static int __init proc_cmdline_init(void)
54666 {
54667 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
54668 + proc_create_grsec("cmdline", 0, NULL, &cmdline_proc_fops);
54669 +#else
54670 proc_create("cmdline", 0, NULL, &cmdline_proc_fops);
54671 +#endif
54672 return 0;
54673 }
54674 module_init(proc_cmdline_init);
54675 diff --git a/fs/proc/devices.c b/fs/proc/devices.c
54676 index b143471..bb105e5 100644
54677 --- a/fs/proc/devices.c
54678 +++ b/fs/proc/devices.c
54679 @@ -64,7 +64,11 @@ static const struct file_operations proc_devinfo_operations = {
54680
54681 static int __init proc_devices_init(void)
54682 {
54683 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
54684 + proc_create_grsec("devices", 0, NULL, &proc_devinfo_operations);
54685 +#else
54686 proc_create("devices", 0, NULL, &proc_devinfo_operations);
54687 +#endif
54688 return 0;
54689 }
54690 module_init(proc_devices_init);
54691 diff --git a/fs/proc/fd.c b/fs/proc/fd.c
54692 index d7a4a28..0201742 100644
54693 --- a/fs/proc/fd.c
54694 +++ b/fs/proc/fd.c
54695 @@ -25,7 +25,8 @@ static int seq_show(struct seq_file *m, void *v)
54696 if (!task)
54697 return -ENOENT;
54698
54699 - files = get_files_struct(task);
54700 + if (!gr_acl_handle_procpidmem(task))
54701 + files = get_files_struct(task);
54702 put_task_struct(task);
54703
54704 if (files) {
54705 @@ -302,11 +303,21 @@ static struct dentry *proc_lookupfd(struct inode *dir, struct dentry *dentry,
54706 */
54707 int proc_fd_permission(struct inode *inode, int mask)
54708 {
54709 + struct task_struct *task;
54710 int rv = generic_permission(inode, mask);
54711 - if (rv == 0)
54712 - return 0;
54713 +
54714 if (task_pid(current) == proc_pid(inode))
54715 rv = 0;
54716 +
54717 + task = get_proc_task(inode);
54718 + if (task == NULL)
54719 + return rv;
54720 +
54721 + if (gr_acl_handle_procpidmem(task))
54722 + rv = -EACCES;
54723 +
54724 + put_task_struct(task);
54725 +
54726 return rv;
54727 }
54728
54729 diff --git a/fs/proc/inode.c b/fs/proc/inode.c
54730 index 439ae688..c21ac36 100644
54731 --- a/fs/proc/inode.c
54732 +++ b/fs/proc/inode.c
54733 @@ -21,11 +21,17 @@
54734 #include <linux/seq_file.h>
54735 #include <linux/slab.h>
54736 #include <linux/mount.h>
54737 +#include <linux/grsecurity.h>
54738
54739 #include <asm/uaccess.h>
54740
54741 #include "internal.h"
54742
54743 +#ifdef CONFIG_PROC_SYSCTL
54744 +extern const struct inode_operations proc_sys_inode_operations;
54745 +extern const struct inode_operations proc_sys_dir_operations;
54746 +#endif
54747 +
54748 static void proc_evict_inode(struct inode *inode)
54749 {
54750 struct proc_dir_entry *de;
54751 @@ -53,6 +59,13 @@ static void proc_evict_inode(struct inode *inode)
54752 ns = PROC_I(inode)->ns;
54753 if (ns_ops && ns)
54754 ns_ops->put(ns);
54755 +
54756 +#ifdef CONFIG_PROC_SYSCTL
54757 + if (inode->i_op == &proc_sys_inode_operations ||
54758 + inode->i_op == &proc_sys_dir_operations)
54759 + gr_handle_delete(inode->i_ino, inode->i_sb->s_dev);
54760 +#endif
54761 +
54762 }
54763
54764 static struct kmem_cache * proc_inode_cachep;
54765 @@ -457,7 +470,11 @@ struct inode *proc_get_inode(struct super_block *sb, struct proc_dir_entry *de)
54766 if (de->mode) {
54767 inode->i_mode = de->mode;
54768 inode->i_uid = de->uid;
54769 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
54770 + inode->i_gid = grsec_proc_gid;
54771 +#else
54772 inode->i_gid = de->gid;
54773 +#endif
54774 }
54775 if (de->size)
54776 inode->i_size = de->size;
54777 diff --git a/fs/proc/internal.h b/fs/proc/internal.h
54778 index 252544c..04395b9 100644
54779 --- a/fs/proc/internal.h
54780 +++ b/fs/proc/internal.h
54781 @@ -55,6 +55,9 @@ extern int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
54782 struct pid *pid, struct task_struct *task);
54783 extern int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns,
54784 struct pid *pid, struct task_struct *task);
54785 +#ifdef CONFIG_GRKERNSEC_PROC_IPADDR
54786 +extern int proc_pid_ipaddr(struct task_struct *task, char *buffer);
54787 +#endif
54788 extern loff_t mem_lseek(struct file *file, loff_t offset, int orig);
54789
54790 extern const struct file_operations proc_tid_children_operations;
54791 diff --git a/fs/proc/kcore.c b/fs/proc/kcore.c
54792 index e96d4f1..8b116ed 100644
54793 --- a/fs/proc/kcore.c
54794 +++ b/fs/proc/kcore.c
54795 @@ -480,9 +480,10 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
54796 * the addresses in the elf_phdr on our list.
54797 */
54798 start = kc_offset_to_vaddr(*fpos - elf_buflen);
54799 - if ((tsz = (PAGE_SIZE - (start & ~PAGE_MASK))) > buflen)
54800 + tsz = PAGE_SIZE - (start & ~PAGE_MASK);
54801 + if (tsz > buflen)
54802 tsz = buflen;
54803 -
54804 +
54805 while (buflen) {
54806 struct kcore_list *m;
54807
54808 @@ -511,20 +512,23 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
54809 kfree(elf_buf);
54810 } else {
54811 if (kern_addr_valid(start)) {
54812 - unsigned long n;
54813 + char *elf_buf;
54814 + mm_segment_t oldfs;
54815
54816 - n = copy_to_user(buffer, (char *)start, tsz);
54817 - /*
54818 - * We cannot distinguish between fault on source
54819 - * and fault on destination. When this happens
54820 - * we clear too and hope it will trigger the
54821 - * EFAULT again.
54822 - */
54823 - if (n) {
54824 - if (clear_user(buffer + tsz - n,
54825 - n))
54826 + elf_buf = kmalloc(tsz, GFP_KERNEL);
54827 + if (!elf_buf)
54828 + return -ENOMEM;
54829 + oldfs = get_fs();
54830 + set_fs(KERNEL_DS);
54831 + if (!__copy_from_user(elf_buf, (const void __user *)start, tsz)) {
54832 + set_fs(oldfs);
54833 + if (copy_to_user(buffer, elf_buf, tsz)) {
54834 + kfree(elf_buf);
54835 return -EFAULT;
54836 + }
54837 }
54838 + set_fs(oldfs);
54839 + kfree(elf_buf);
54840 } else {
54841 if (clear_user(buffer, tsz))
54842 return -EFAULT;
54843 @@ -544,6 +548,9 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
54844
54845 static int open_kcore(struct inode *inode, struct file *filp)
54846 {
54847 +#if defined(CONFIG_GRKERNSEC_PROC_ADD) || defined(CONFIG_GRKERNSEC_HIDESYM)
54848 + return -EPERM;
54849 +#endif
54850 if (!capable(CAP_SYS_RAWIO))
54851 return -EPERM;
54852 if (kcore_need_update)
54853 diff --git a/fs/proc/meminfo.c b/fs/proc/meminfo.c
54854 index 80e4645..53e5fcf 100644
54855 --- a/fs/proc/meminfo.c
54856 +++ b/fs/proc/meminfo.c
54857 @@ -158,7 +158,7 @@ static int meminfo_proc_show(struct seq_file *m, void *v)
54858 vmi.used >> 10,
54859 vmi.largest_chunk >> 10
54860 #ifdef CONFIG_MEMORY_FAILURE
54861 - ,atomic_long_read(&mce_bad_pages) << (PAGE_SHIFT - 10)
54862 + ,atomic_long_read_unchecked(&mce_bad_pages) << (PAGE_SHIFT - 10)
54863 #endif
54864 #ifdef CONFIG_TRANSPARENT_HUGEPAGE
54865 ,K(global_page_state(NR_ANON_TRANSPARENT_HUGEPAGES) *
54866 diff --git a/fs/proc/nommu.c b/fs/proc/nommu.c
54867 index b1822dd..df622cb 100644
54868 --- a/fs/proc/nommu.c
54869 +++ b/fs/proc/nommu.c
54870 @@ -66,7 +66,7 @@ static int nommu_region_show(struct seq_file *m, struct vm_region *region)
54871 if (len < 1)
54872 len = 1;
54873 seq_printf(m, "%*c", len, ' ');
54874 - seq_path(m, &file->f_path, "");
54875 + seq_path(m, &file->f_path, "\n\\");
54876 }
54877
54878 seq_putc(m, '\n');
54879 diff --git a/fs/proc/proc_net.c b/fs/proc/proc_net.c
54880 index fe72cd0..21b52ff 100644
54881 --- a/fs/proc/proc_net.c
54882 +++ b/fs/proc/proc_net.c
54883 @@ -23,6 +23,7 @@
54884 #include <linux/nsproxy.h>
54885 #include <net/net_namespace.h>
54886 #include <linux/seq_file.h>
54887 +#include <linux/grsecurity.h>
54888
54889 #include "internal.h"
54890
54891 @@ -105,6 +106,17 @@ static struct net *get_proc_task_net(struct inode *dir)
54892 struct task_struct *task;
54893 struct nsproxy *ns;
54894 struct net *net = NULL;
54895 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
54896 + const struct cred *cred = current_cred();
54897 +#endif
54898 +
54899 +#ifdef CONFIG_GRKERNSEC_PROC_USER
54900 + if (!uid_eq(cred->fsuid, GLOBAL_ROOT_UID))
54901 + return net;
54902 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
54903 + if (!uid_eq(cred->fsuid, GLOBAL_ROOT_UID) && !in_group_p(grsec_proc_gid))
54904 + return net;
54905 +#endif
54906
54907 rcu_read_lock();
54908 task = pid_task(proc_pid(dir), PIDTYPE_PID);
54909 diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c
54910 index 1827d88..43b0279 100644
54911 --- a/fs/proc/proc_sysctl.c
54912 +++ b/fs/proc/proc_sysctl.c
54913 @@ -12,11 +12,15 @@
54914 #include <linux/module.h>
54915 #include "internal.h"
54916
54917 +extern int gr_handle_chroot_sysctl(const int op);
54918 +extern int gr_handle_sysctl_mod(const char *dirname, const char *name,
54919 + const int op);
54920 +
54921 static const struct dentry_operations proc_sys_dentry_operations;
54922 static const struct file_operations proc_sys_file_operations;
54923 -static const struct inode_operations proc_sys_inode_operations;
54924 +const struct inode_operations proc_sys_inode_operations;
54925 static const struct file_operations proc_sys_dir_file_operations;
54926 -static const struct inode_operations proc_sys_dir_operations;
54927 +const struct inode_operations proc_sys_dir_operations;
54928
54929 void proc_sys_poll_notify(struct ctl_table_poll *poll)
54930 {
54931 @@ -466,6 +470,9 @@ static struct dentry *proc_sys_lookup(struct inode *dir, struct dentry *dentry,
54932
54933 err = NULL;
54934 d_set_d_op(dentry, &proc_sys_dentry_operations);
54935 +
54936 + gr_handle_proc_create(dentry, inode);
54937 +
54938 d_add(dentry, inode);
54939
54940 out:
54941 @@ -481,6 +488,7 @@ static ssize_t proc_sys_call_handler(struct file *filp, void __user *buf,
54942 struct inode *inode = filp->f_path.dentry->d_inode;
54943 struct ctl_table_header *head = grab_header(inode);
54944 struct ctl_table *table = PROC_I(inode)->sysctl_entry;
54945 + int op = write ? MAY_WRITE : MAY_READ;
54946 ssize_t error;
54947 size_t res;
54948
54949 @@ -492,7 +500,7 @@ static ssize_t proc_sys_call_handler(struct file *filp, void __user *buf,
54950 * and won't be until we finish.
54951 */
54952 error = -EPERM;
54953 - if (sysctl_perm(head, table, write ? MAY_WRITE : MAY_READ))
54954 + if (sysctl_perm(head, table, op))
54955 goto out;
54956
54957 /* if that can happen at all, it should be -EINVAL, not -EISDIR */
54958 @@ -500,6 +508,22 @@ static ssize_t proc_sys_call_handler(struct file *filp, void __user *buf,
54959 if (!table->proc_handler)
54960 goto out;
54961
54962 +#ifdef CONFIG_GRKERNSEC
54963 + error = -EPERM;
54964 + if (gr_handle_chroot_sysctl(op))
54965 + goto out;
54966 + dget(filp->f_path.dentry);
54967 + if (gr_handle_sysctl_mod(filp->f_path.dentry->d_parent->d_name.name, table->procname, op)) {
54968 + dput(filp->f_path.dentry);
54969 + goto out;
54970 + }
54971 + dput(filp->f_path.dentry);
54972 + if (!gr_acl_handle_open(filp->f_path.dentry, filp->f_path.mnt, op))
54973 + goto out;
54974 + if (write && !capable(CAP_SYS_ADMIN))
54975 + goto out;
54976 +#endif
54977 +
54978 /* careful: calling conventions are nasty here */
54979 res = count;
54980 error = table->proc_handler(table, write, buf, &res, ppos);
54981 @@ -597,6 +621,9 @@ static int proc_sys_fill_cache(struct file *filp, void *dirent,
54982 return -ENOMEM;
54983 } else {
54984 d_set_d_op(child, &proc_sys_dentry_operations);
54985 +
54986 + gr_handle_proc_create(child, inode);
54987 +
54988 d_add(child, inode);
54989 }
54990 } else {
54991 @@ -640,6 +667,9 @@ static int scan(struct ctl_table_header *head, ctl_table *table,
54992 if ((*pos)++ < file->f_pos)
54993 return 0;
54994
54995 + if (!gr_acl_handle_hidden_file(file->f_path.dentry, file->f_path.mnt))
54996 + return 0;
54997 +
54998 if (unlikely(S_ISLNK(table->mode)))
54999 res = proc_sys_link_fill_cache(file, dirent, filldir, head, table);
55000 else
55001 @@ -750,6 +780,9 @@ static int proc_sys_getattr(struct vfsmount *mnt, struct dentry *dentry, struct
55002 if (IS_ERR(head))
55003 return PTR_ERR(head);
55004
55005 + if (table && !gr_acl_handle_hidden_file(dentry, mnt))
55006 + return -ENOENT;
55007 +
55008 generic_fillattr(inode, stat);
55009 if (table)
55010 stat->mode = (stat->mode & S_IFMT) | table->mode;
55011 @@ -772,13 +805,13 @@ static const struct file_operations proc_sys_dir_file_operations = {
55012 .llseek = generic_file_llseek,
55013 };
55014
55015 -static const struct inode_operations proc_sys_inode_operations = {
55016 +const struct inode_operations proc_sys_inode_operations = {
55017 .permission = proc_sys_permission,
55018 .setattr = proc_sys_setattr,
55019 .getattr = proc_sys_getattr,
55020 };
55021
55022 -static const struct inode_operations proc_sys_dir_operations = {
55023 +const struct inode_operations proc_sys_dir_operations = {
55024 .lookup = proc_sys_lookup,
55025 .permission = proc_sys_permission,
55026 .setattr = proc_sys_setattr,
55027 @@ -854,7 +887,7 @@ static struct ctl_dir *find_subdir(struct ctl_dir *dir,
55028 static struct ctl_dir *new_dir(struct ctl_table_set *set,
55029 const char *name, int namelen)
55030 {
55031 - struct ctl_table *table;
55032 + ctl_table_no_const *table;
55033 struct ctl_dir *new;
55034 struct ctl_node *node;
55035 char *new_name;
55036 @@ -866,7 +899,7 @@ static struct ctl_dir *new_dir(struct ctl_table_set *set,
55037 return NULL;
55038
55039 node = (struct ctl_node *)(new + 1);
55040 - table = (struct ctl_table *)(node + 1);
55041 + table = (ctl_table_no_const *)(node + 1);
55042 new_name = (char *)(table + 2);
55043 memcpy(new_name, name, namelen);
55044 new_name[namelen] = '\0';
55045 @@ -1035,7 +1068,8 @@ static int sysctl_check_table(const char *path, struct ctl_table *table)
55046 static struct ctl_table_header *new_links(struct ctl_dir *dir, struct ctl_table *table,
55047 struct ctl_table_root *link_root)
55048 {
55049 - struct ctl_table *link_table, *entry, *link;
55050 + ctl_table_no_const *link_table, *link;
55051 + struct ctl_table *entry;
55052 struct ctl_table_header *links;
55053 struct ctl_node *node;
55054 char *link_name;
55055 @@ -1058,7 +1092,7 @@ static struct ctl_table_header *new_links(struct ctl_dir *dir, struct ctl_table
55056 return NULL;
55057
55058 node = (struct ctl_node *)(links + 1);
55059 - link_table = (struct ctl_table *)(node + nr_entries);
55060 + link_table = (ctl_table_no_const *)(node + nr_entries);
55061 link_name = (char *)&link_table[nr_entries + 1];
55062
55063 for (link = link_table, entry = table; entry->procname; link++, entry++) {
55064 @@ -1306,8 +1340,8 @@ static int register_leaf_sysctl_tables(const char *path, char *pos,
55065 struct ctl_table_header ***subheader, struct ctl_table_set *set,
55066 struct ctl_table *table)
55067 {
55068 - struct ctl_table *ctl_table_arg = NULL;
55069 - struct ctl_table *entry, *files;
55070 + ctl_table_no_const *ctl_table_arg = NULL, *files = NULL;
55071 + struct ctl_table *entry;
55072 int nr_files = 0;
55073 int nr_dirs = 0;
55074 int err = -ENOMEM;
55075 @@ -1319,10 +1353,9 @@ static int register_leaf_sysctl_tables(const char *path, char *pos,
55076 nr_files++;
55077 }
55078
55079 - files = table;
55080 /* If there are mixed files and directories we need a new table */
55081 if (nr_dirs && nr_files) {
55082 - struct ctl_table *new;
55083 + ctl_table_no_const *new;
55084 files = kzalloc(sizeof(struct ctl_table) * (nr_files + 1),
55085 GFP_KERNEL);
55086 if (!files)
55087 @@ -1340,7 +1373,7 @@ static int register_leaf_sysctl_tables(const char *path, char *pos,
55088 /* Register everything except a directory full of subdirectories */
55089 if (nr_files || !nr_dirs) {
55090 struct ctl_table_header *header;
55091 - header = __register_sysctl_table(set, path, files);
55092 + header = __register_sysctl_table(set, path, files ? files : table);
55093 if (!header) {
55094 kfree(ctl_table_arg);
55095 goto out;
55096 diff --git a/fs/proc/root.c b/fs/proc/root.c
55097 index c6e9fac..a740964 100644
55098 --- a/fs/proc/root.c
55099 +++ b/fs/proc/root.c
55100 @@ -176,7 +176,15 @@ void __init proc_root_init(void)
55101 #ifdef CONFIG_PROC_DEVICETREE
55102 proc_device_tree_init();
55103 #endif
55104 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
55105 +#ifdef CONFIG_GRKERNSEC_PROC_USER
55106 + proc_mkdir_mode("bus", S_IRUSR | S_IXUSR, NULL);
55107 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
55108 + proc_mkdir_mode("bus", S_IRUSR | S_IXUSR | S_IRGRP | S_IXGRP, NULL);
55109 +#endif
55110 +#else
55111 proc_mkdir("bus", NULL);
55112 +#endif
55113 proc_sys_init();
55114 }
55115
55116 diff --git a/fs/proc/self.c b/fs/proc/self.c
55117 index aa5cc3b..c91a5d0 100644
55118 --- a/fs/proc/self.c
55119 +++ b/fs/proc/self.c
55120 @@ -37,7 +37,7 @@ static void *proc_self_follow_link(struct dentry *dentry, struct nameidata *nd)
55121 static void proc_self_put_link(struct dentry *dentry, struct nameidata *nd,
55122 void *cookie)
55123 {
55124 - char *s = nd_get_link(nd);
55125 + const char *s = nd_get_link(nd);
55126 if (!IS_ERR(s))
55127 kfree(s);
55128 }
55129 diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
55130 index ca5ce7f..02c1cf0 100644
55131 --- a/fs/proc/task_mmu.c
55132 +++ b/fs/proc/task_mmu.c
55133 @@ -11,12 +11,19 @@
55134 #include <linux/rmap.h>
55135 #include <linux/swap.h>
55136 #include <linux/swapops.h>
55137 +#include <linux/grsecurity.h>
55138
55139 #include <asm/elf.h>
55140 #include <asm/uaccess.h>
55141 #include <asm/tlbflush.h>
55142 #include "internal.h"
55143
55144 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55145 +#define PAX_RAND_FLAGS(_mm) (_mm != NULL && _mm != current->mm && \
55146 + (_mm->pax_flags & MF_PAX_RANDMMAP || \
55147 + _mm->pax_flags & MF_PAX_SEGMEXEC))
55148 +#endif
55149 +
55150 void task_mem(struct seq_file *m, struct mm_struct *mm)
55151 {
55152 unsigned long data, text, lib, swap;
55153 @@ -52,8 +59,13 @@ void task_mem(struct seq_file *m, struct mm_struct *mm)
55154 "VmExe:\t%8lu kB\n"
55155 "VmLib:\t%8lu kB\n"
55156 "VmPTE:\t%8lu kB\n"
55157 - "VmSwap:\t%8lu kB\n",
55158 - hiwater_vm << (PAGE_SHIFT-10),
55159 + "VmSwap:\t%8lu kB\n"
55160 +
55161 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
55162 + "CsBase:\t%8lx\nCsLim:\t%8lx\n"
55163 +#endif
55164 +
55165 + ,hiwater_vm << (PAGE_SHIFT-10),
55166 total_vm << (PAGE_SHIFT-10),
55167 mm->locked_vm << (PAGE_SHIFT-10),
55168 mm->pinned_vm << (PAGE_SHIFT-10),
55169 @@ -62,7 +74,19 @@ void task_mem(struct seq_file *m, struct mm_struct *mm)
55170 data << (PAGE_SHIFT-10),
55171 mm->stack_vm << (PAGE_SHIFT-10), text, lib,
55172 (PTRS_PER_PTE*sizeof(pte_t)*mm->nr_ptes) >> 10,
55173 - swap << (PAGE_SHIFT-10));
55174 + swap << (PAGE_SHIFT-10)
55175 +
55176 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
55177 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55178 + , PAX_RAND_FLAGS(mm) ? 0 : mm->context.user_cs_base
55179 + , PAX_RAND_FLAGS(mm) ? 0 : mm->context.user_cs_limit
55180 +#else
55181 + , mm->context.user_cs_base
55182 + , mm->context.user_cs_limit
55183 +#endif
55184 +#endif
55185 +
55186 + );
55187 }
55188
55189 unsigned long task_vsize(struct mm_struct *mm)
55190 @@ -277,13 +301,13 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
55191 pgoff = ((loff_t)vma->vm_pgoff) << PAGE_SHIFT;
55192 }
55193
55194 - /* We don't show the stack guard page in /proc/maps */
55195 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55196 + start = PAX_RAND_FLAGS(mm) ? 0UL : vma->vm_start;
55197 + end = PAX_RAND_FLAGS(mm) ? 0UL : vma->vm_end;
55198 +#else
55199 start = vma->vm_start;
55200 - if (stack_guard_page_start(vma, start))
55201 - start += PAGE_SIZE;
55202 end = vma->vm_end;
55203 - if (stack_guard_page_end(vma, end))
55204 - end -= PAGE_SIZE;
55205 +#endif
55206
55207 seq_printf(m, "%08lx-%08lx %c%c%c%c %08llx %02x:%02x %lu %n",
55208 start,
55209 @@ -292,7 +316,11 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
55210 flags & VM_WRITE ? 'w' : '-',
55211 flags & VM_EXEC ? 'x' : '-',
55212 flags & VM_MAYSHARE ? 's' : 'p',
55213 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55214 + PAX_RAND_FLAGS(mm) ? 0UL : pgoff,
55215 +#else
55216 pgoff,
55217 +#endif
55218 MAJOR(dev), MINOR(dev), ino, &len);
55219
55220 /*
55221 @@ -301,7 +329,7 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
55222 */
55223 if (file) {
55224 pad_len_spaces(m, len);
55225 - seq_path(m, &file->f_path, "\n");
55226 + seq_path(m, &file->f_path, "\n\\");
55227 goto done;
55228 }
55229
55230 @@ -327,8 +355,9 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
55231 * Thread stack in /proc/PID/task/TID/maps or
55232 * the main process stack.
55233 */
55234 - if (!is_pid || (vma->vm_start <= mm->start_stack &&
55235 - vma->vm_end >= mm->start_stack)) {
55236 + if (!is_pid || (vma->vm_flags & (VM_GROWSDOWN | VM_GROWSUP)) ||
55237 + (vma->vm_start <= mm->start_stack &&
55238 + vma->vm_end >= mm->start_stack)) {
55239 name = "[stack]";
55240 } else {
55241 /* Thread stack in /proc/PID/maps */
55242 @@ -352,6 +381,13 @@ static int show_map(struct seq_file *m, void *v, int is_pid)
55243 struct proc_maps_private *priv = m->private;
55244 struct task_struct *task = priv->task;
55245
55246 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55247 + if (current->exec_id != m->exec_id) {
55248 + gr_log_badprocpid("maps");
55249 + return 0;
55250 + }
55251 +#endif
55252 +
55253 show_map_vma(m, vma, is_pid);
55254
55255 if (m->count < m->size) /* vma is copied successfully */
55256 @@ -589,12 +625,23 @@ static int show_smap(struct seq_file *m, void *v, int is_pid)
55257 .private = &mss,
55258 };
55259
55260 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55261 + if (current->exec_id != m->exec_id) {
55262 + gr_log_badprocpid("smaps");
55263 + return 0;
55264 + }
55265 +#endif
55266 memset(&mss, 0, sizeof mss);
55267 - mss.vma = vma;
55268 - /* mmap_sem is held in m_start */
55269 - if (vma->vm_mm && !is_vm_hugetlb_page(vma))
55270 - walk_page_range(vma->vm_start, vma->vm_end, &smaps_walk);
55271 -
55272 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55273 + if (!PAX_RAND_FLAGS(vma->vm_mm)) {
55274 +#endif
55275 + mss.vma = vma;
55276 + /* mmap_sem is held in m_start */
55277 + if (vma->vm_mm && !is_vm_hugetlb_page(vma))
55278 + walk_page_range(vma->vm_start, vma->vm_end, &smaps_walk);
55279 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55280 + }
55281 +#endif
55282 show_map_vma(m, vma, is_pid);
55283
55284 seq_printf(m,
55285 @@ -612,7 +659,11 @@ static int show_smap(struct seq_file *m, void *v, int is_pid)
55286 "KernelPageSize: %8lu kB\n"
55287 "MMUPageSize: %8lu kB\n"
55288 "Locked: %8lu kB\n",
55289 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55290 + PAX_RAND_FLAGS(vma->vm_mm) ? 0UL : (vma->vm_end - vma->vm_start) >> 10,
55291 +#else
55292 (vma->vm_end - vma->vm_start) >> 10,
55293 +#endif
55294 mss.resident >> 10,
55295 (unsigned long)(mss.pss >> (10 + PSS_SHIFT)),
55296 mss.shared_clean >> 10,
55297 @@ -1264,6 +1315,13 @@ static int show_numa_map(struct seq_file *m, void *v, int is_pid)
55298 int n;
55299 char buffer[50];
55300
55301 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55302 + if (current->exec_id != m->exec_id) {
55303 + gr_log_badprocpid("numa_maps");
55304 + return 0;
55305 + }
55306 +#endif
55307 +
55308 if (!mm)
55309 return 0;
55310
55311 @@ -1281,11 +1339,15 @@ static int show_numa_map(struct seq_file *m, void *v, int is_pid)
55312 mpol_to_str(buffer, sizeof(buffer), pol);
55313 mpol_cond_put(pol);
55314
55315 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55316 + seq_printf(m, "%08lx %s", PAX_RAND_FLAGS(vma->vm_mm) ? 0UL : vma->vm_start, buffer);
55317 +#else
55318 seq_printf(m, "%08lx %s", vma->vm_start, buffer);
55319 +#endif
55320
55321 if (file) {
55322 seq_printf(m, " file=");
55323 - seq_path(m, &file->f_path, "\n\t= ");
55324 + seq_path(m, &file->f_path, "\n\t\\= ");
55325 } else if (vma->vm_start <= mm->brk && vma->vm_end >= mm->start_brk) {
55326 seq_printf(m, " heap");
55327 } else {
55328 diff --git a/fs/proc/task_nommu.c b/fs/proc/task_nommu.c
55329 index 1ccfa53..0848f95 100644
55330 --- a/fs/proc/task_nommu.c
55331 +++ b/fs/proc/task_nommu.c
55332 @@ -51,7 +51,7 @@ void task_mem(struct seq_file *m, struct mm_struct *mm)
55333 else
55334 bytes += kobjsize(mm);
55335
55336 - if (current->fs && current->fs->users > 1)
55337 + if (current->fs && atomic_read(&current->fs->users) > 1)
55338 sbytes += kobjsize(current->fs);
55339 else
55340 bytes += kobjsize(current->fs);
55341 @@ -168,7 +168,7 @@ static int nommu_vma_show(struct seq_file *m, struct vm_area_struct *vma,
55342
55343 if (file) {
55344 pad_len_spaces(m, len);
55345 - seq_path(m, &file->f_path, "");
55346 + seq_path(m, &file->f_path, "\n\\");
55347 } else if (mm) {
55348 pid_t tid = vm_is_stack(priv->task, vma, is_pid);
55349
55350 diff --git a/fs/qnx6/qnx6.h b/fs/qnx6/qnx6.h
55351 index b00fcc9..e0c6381 100644
55352 --- a/fs/qnx6/qnx6.h
55353 +++ b/fs/qnx6/qnx6.h
55354 @@ -74,7 +74,7 @@ enum {
55355 BYTESEX_BE,
55356 };
55357
55358 -static inline __u64 fs64_to_cpu(struct qnx6_sb_info *sbi, __fs64 n)
55359 +static inline __u64 __intentional_overflow(-1) fs64_to_cpu(struct qnx6_sb_info *sbi, __fs64 n)
55360 {
55361 if (sbi->s_bytesex == BYTESEX_LE)
55362 return le64_to_cpu((__force __le64)n);
55363 @@ -90,7 +90,7 @@ static inline __fs64 cpu_to_fs64(struct qnx6_sb_info *sbi, __u64 n)
55364 return (__force __fs64)cpu_to_be64(n);
55365 }
55366
55367 -static inline __u32 fs32_to_cpu(struct qnx6_sb_info *sbi, __fs32 n)
55368 +static inline __u32 __intentional_overflow(-1) fs32_to_cpu(struct qnx6_sb_info *sbi, __fs32 n)
55369 {
55370 if (sbi->s_bytesex == BYTESEX_LE)
55371 return le32_to_cpu((__force __le32)n);
55372 diff --git a/fs/quota/netlink.c b/fs/quota/netlink.c
55373 index 16e8abb..2dcf914 100644
55374 --- a/fs/quota/netlink.c
55375 +++ b/fs/quota/netlink.c
55376 @@ -33,7 +33,7 @@ static struct genl_family quota_genl_family = {
55377 void quota_send_warning(struct kqid qid, dev_t dev,
55378 const char warntype)
55379 {
55380 - static atomic_t seq;
55381 + static atomic_unchecked_t seq;
55382 struct sk_buff *skb;
55383 void *msg_head;
55384 int ret;
55385 @@ -49,7 +49,7 @@ void quota_send_warning(struct kqid qid, dev_t dev,
55386 "VFS: Not enough memory to send quota warning.\n");
55387 return;
55388 }
55389 - msg_head = genlmsg_put(skb, 0, atomic_add_return(1, &seq),
55390 + msg_head = genlmsg_put(skb, 0, atomic_add_return_unchecked(1, &seq),
55391 &quota_genl_family, 0, QUOTA_NL_C_WARNING);
55392 if (!msg_head) {
55393 printk(KERN_ERR
55394 diff --git a/fs/readdir.c b/fs/readdir.c
55395 index 5e69ef5..e5d9099 100644
55396 --- a/fs/readdir.c
55397 +++ b/fs/readdir.c
55398 @@ -17,6 +17,7 @@
55399 #include <linux/security.h>
55400 #include <linux/syscalls.h>
55401 #include <linux/unistd.h>
55402 +#include <linux/namei.h>
55403
55404 #include <asm/uaccess.h>
55405
55406 @@ -67,6 +68,7 @@ struct old_linux_dirent {
55407
55408 struct readdir_callback {
55409 struct old_linux_dirent __user * dirent;
55410 + struct file * file;
55411 int result;
55412 };
55413
55414 @@ -84,6 +86,10 @@ static int fillonedir(void * __buf, const char * name, int namlen, loff_t offset
55415 buf->result = -EOVERFLOW;
55416 return -EOVERFLOW;
55417 }
55418 +
55419 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
55420 + return 0;
55421 +
55422 buf->result++;
55423 dirent = buf->dirent;
55424 if (!access_ok(VERIFY_WRITE, dirent,
55425 @@ -114,6 +120,7 @@ SYSCALL_DEFINE3(old_readdir, unsigned int, fd,
55426
55427 buf.result = 0;
55428 buf.dirent = dirent;
55429 + buf.file = f.file;
55430
55431 error = vfs_readdir(f.file, fillonedir, &buf);
55432 if (buf.result)
55433 @@ -139,6 +146,7 @@ struct linux_dirent {
55434 struct getdents_callback {
55435 struct linux_dirent __user * current_dir;
55436 struct linux_dirent __user * previous;
55437 + struct file * file;
55438 int count;
55439 int error;
55440 };
55441 @@ -160,6 +168,10 @@ static int filldir(void * __buf, const char * name, int namlen, loff_t offset,
55442 buf->error = -EOVERFLOW;
55443 return -EOVERFLOW;
55444 }
55445 +
55446 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
55447 + return 0;
55448 +
55449 dirent = buf->previous;
55450 if (dirent) {
55451 if (__put_user(offset, &dirent->d_off))
55452 @@ -205,6 +217,7 @@ SYSCALL_DEFINE3(getdents, unsigned int, fd,
55453 buf.previous = NULL;
55454 buf.count = count;
55455 buf.error = 0;
55456 + buf.file = f.file;
55457
55458 error = vfs_readdir(f.file, filldir, &buf);
55459 if (error >= 0)
55460 @@ -223,6 +236,7 @@ SYSCALL_DEFINE3(getdents, unsigned int, fd,
55461 struct getdents_callback64 {
55462 struct linux_dirent64 __user * current_dir;
55463 struct linux_dirent64 __user * previous;
55464 + struct file *file;
55465 int count;
55466 int error;
55467 };
55468 @@ -238,6 +252,10 @@ static int filldir64(void * __buf, const char * name, int namlen, loff_t offset,
55469 buf->error = -EINVAL; /* only used if we fail.. */
55470 if (reclen > buf->count)
55471 return -EINVAL;
55472 +
55473 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
55474 + return 0;
55475 +
55476 dirent = buf->previous;
55477 if (dirent) {
55478 if (__put_user(offset, &dirent->d_off))
55479 @@ -283,6 +301,7 @@ SYSCALL_DEFINE3(getdents64, unsigned int, fd,
55480
55481 buf.current_dir = dirent;
55482 buf.previous = NULL;
55483 + buf.file = f.file;
55484 buf.count = count;
55485 buf.error = 0;
55486
55487 @@ -291,7 +310,7 @@ SYSCALL_DEFINE3(getdents64, unsigned int, fd,
55488 error = buf.error;
55489 lastdirent = buf.previous;
55490 if (lastdirent) {
55491 - typeof(lastdirent->d_off) d_off = f.file->f_pos;
55492 + typeof(((struct linux_dirent64 *)0)->d_off) d_off = f.file->f_pos;
55493 if (__put_user(d_off, &lastdirent->d_off))
55494 error = -EFAULT;
55495 else
55496 diff --git a/fs/reiserfs/do_balan.c b/fs/reiserfs/do_balan.c
55497 index 2b7882b..1c5ef48 100644
55498 --- a/fs/reiserfs/do_balan.c
55499 +++ b/fs/reiserfs/do_balan.c
55500 @@ -2051,7 +2051,7 @@ void do_balance(struct tree_balance *tb, /* tree_balance structure */
55501 return;
55502 }
55503
55504 - atomic_inc(&(fs_generation(tb->tb_sb)));
55505 + atomic_inc_unchecked(&(fs_generation(tb->tb_sb)));
55506 do_balance_starts(tb);
55507
55508 /* balance leaf returns 0 except if combining L R and S into
55509 diff --git a/fs/reiserfs/procfs.c b/fs/reiserfs/procfs.c
55510 index e60e870..f40ac16 100644
55511 --- a/fs/reiserfs/procfs.c
55512 +++ b/fs/reiserfs/procfs.c
55513 @@ -112,7 +112,7 @@ static int show_super(struct seq_file *m, struct super_block *sb)
55514 "SMALL_TAILS " : "NO_TAILS ",
55515 replay_only(sb) ? "REPLAY_ONLY " : "",
55516 convert_reiserfs(sb) ? "CONV " : "",
55517 - atomic_read(&r->s_generation_counter),
55518 + atomic_read_unchecked(&r->s_generation_counter),
55519 SF(s_disk_reads), SF(s_disk_writes), SF(s_fix_nodes),
55520 SF(s_do_balance), SF(s_unneeded_left_neighbor),
55521 SF(s_good_search_by_key_reada), SF(s_bmaps),
55522 diff --git a/fs/reiserfs/reiserfs.h b/fs/reiserfs/reiserfs.h
55523 index 157e474..65a6114 100644
55524 --- a/fs/reiserfs/reiserfs.h
55525 +++ b/fs/reiserfs/reiserfs.h
55526 @@ -453,7 +453,7 @@ struct reiserfs_sb_info {
55527 /* Comment? -Hans */
55528 wait_queue_head_t s_wait;
55529 /* To be obsoleted soon by per buffer seals.. -Hans */
55530 - atomic_t s_generation_counter; // increased by one every time the
55531 + atomic_unchecked_t s_generation_counter; // increased by one every time the
55532 // tree gets re-balanced
55533 unsigned long s_properties; /* File system properties. Currently holds
55534 on-disk FS format */
55535 @@ -1978,7 +1978,7 @@ static inline loff_t max_reiserfs_offset(struct inode *inode)
55536 #define REISERFS_USER_MEM 1 /* reiserfs user memory mode */
55537
55538 #define fs_generation(s) (REISERFS_SB(s)->s_generation_counter)
55539 -#define get_generation(s) atomic_read (&fs_generation(s))
55540 +#define get_generation(s) atomic_read_unchecked (&fs_generation(s))
55541 #define FILESYSTEM_CHANGED_TB(tb) (get_generation((tb)->tb_sb) != (tb)->fs_gen)
55542 #define __fs_changed(gen,s) (gen != get_generation (s))
55543 #define fs_changed(gen,s) \
55544 diff --git a/fs/select.c b/fs/select.c
55545 index 2ef72d9..f213b17 100644
55546 --- a/fs/select.c
55547 +++ b/fs/select.c
55548 @@ -20,6 +20,7 @@
55549 #include <linux/export.h>
55550 #include <linux/slab.h>
55551 #include <linux/poll.h>
55552 +#include <linux/security.h>
55553 #include <linux/personality.h> /* for STICKY_TIMEOUTS */
55554 #include <linux/file.h>
55555 #include <linux/fdtable.h>
55556 @@ -826,6 +827,7 @@ int do_sys_poll(struct pollfd __user *ufds, unsigned int nfds,
55557 struct poll_list *walk = head;
55558 unsigned long todo = nfds;
55559
55560 + gr_learn_resource(current, RLIMIT_NOFILE, nfds, 1);
55561 if (nfds > rlimit(RLIMIT_NOFILE))
55562 return -EINVAL;
55563
55564 diff --git a/fs/seq_file.c b/fs/seq_file.c
55565 index f2bc3df..239d4f6 100644
55566 --- a/fs/seq_file.c
55567 +++ b/fs/seq_file.c
55568 @@ -10,6 +10,7 @@
55569 #include <linux/seq_file.h>
55570 #include <linux/slab.h>
55571 #include <linux/cred.h>
55572 +#include <linux/sched.h>
55573
55574 #include <asm/uaccess.h>
55575 #include <asm/page.h>
55576 @@ -60,6 +61,9 @@ int seq_open(struct file *file, const struct seq_operations *op)
55577 #ifdef CONFIG_USER_NS
55578 p->user_ns = file->f_cred->user_ns;
55579 #endif
55580 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55581 + p->exec_id = current->exec_id;
55582 +#endif
55583
55584 /*
55585 * Wrappers around seq_open(e.g. swaps_open) need to be
55586 @@ -96,7 +100,7 @@ static int traverse(struct seq_file *m, loff_t offset)
55587 return 0;
55588 }
55589 if (!m->buf) {
55590 - m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL);
55591 + m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL | GFP_USERCOPY);
55592 if (!m->buf)
55593 return -ENOMEM;
55594 }
55595 @@ -136,7 +140,7 @@ static int traverse(struct seq_file *m, loff_t offset)
55596 Eoverflow:
55597 m->op->stop(m, p);
55598 kfree(m->buf);
55599 - m->buf = kmalloc(m->size <<= 1, GFP_KERNEL);
55600 + m->buf = kmalloc(m->size <<= 1, GFP_KERNEL | GFP_USERCOPY);
55601 return !m->buf ? -ENOMEM : -EAGAIN;
55602 }
55603
55604 @@ -191,7 +195,7 @@ ssize_t seq_read(struct file *file, char __user *buf, size_t size, loff_t *ppos)
55605
55606 /* grab buffer if we didn't have one */
55607 if (!m->buf) {
55608 - m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL);
55609 + m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL | GFP_USERCOPY);
55610 if (!m->buf)
55611 goto Enomem;
55612 }
55613 @@ -232,7 +236,7 @@ ssize_t seq_read(struct file *file, char __user *buf, size_t size, loff_t *ppos)
55614 goto Fill;
55615 m->op->stop(m, p);
55616 kfree(m->buf);
55617 - m->buf = kmalloc(m->size <<= 1, GFP_KERNEL);
55618 + m->buf = kmalloc(m->size <<= 1, GFP_KERNEL | GFP_USERCOPY);
55619 if (!m->buf)
55620 goto Enomem;
55621 m->count = 0;
55622 @@ -581,7 +585,7 @@ static void single_stop(struct seq_file *p, void *v)
55623 int single_open(struct file *file, int (*show)(struct seq_file *, void *),
55624 void *data)
55625 {
55626 - struct seq_operations *op = kmalloc(sizeof(*op), GFP_KERNEL);
55627 + seq_operations_no_const *op = kzalloc(sizeof(*op), GFP_KERNEL);
55628 int res = -ENOMEM;
55629
55630 if (op) {
55631 diff --git a/fs/splice.c b/fs/splice.c
55632 index 6909d89..5b2e8f9 100644
55633 --- a/fs/splice.c
55634 +++ b/fs/splice.c
55635 @@ -194,7 +194,7 @@ ssize_t splice_to_pipe(struct pipe_inode_info *pipe,
55636 pipe_lock(pipe);
55637
55638 for (;;) {
55639 - if (!pipe->readers) {
55640 + if (!atomic_read(&pipe->readers)) {
55641 send_sig(SIGPIPE, current, 0);
55642 if (!ret)
55643 ret = -EPIPE;
55644 @@ -248,9 +248,9 @@ ssize_t splice_to_pipe(struct pipe_inode_info *pipe,
55645 do_wakeup = 0;
55646 }
55647
55648 - pipe->waiting_writers++;
55649 + atomic_inc(&pipe->waiting_writers);
55650 pipe_wait(pipe);
55651 - pipe->waiting_writers--;
55652 + atomic_dec(&pipe->waiting_writers);
55653 }
55654
55655 pipe_unlock(pipe);
55656 @@ -563,7 +563,7 @@ static ssize_t kernel_readv(struct file *file, const struct iovec *vec,
55657 old_fs = get_fs();
55658 set_fs(get_ds());
55659 /* The cast to a user pointer is valid due to the set_fs() */
55660 - res = vfs_readv(file, (const struct iovec __user *)vec, vlen, &pos);
55661 + res = vfs_readv(file, (const struct iovec __force_user *)vec, vlen, &pos);
55662 set_fs(old_fs);
55663
55664 return res;
55665 @@ -578,7 +578,7 @@ static ssize_t kernel_write(struct file *file, const char *buf, size_t count,
55666 old_fs = get_fs();
55667 set_fs(get_ds());
55668 /* The cast to a user pointer is valid due to the set_fs() */
55669 - res = vfs_write(file, (const char __user *)buf, count, &pos);
55670 + res = vfs_write(file, (const char __force_user *)buf, count, &pos);
55671 set_fs(old_fs);
55672
55673 return res;
55674 @@ -630,7 +630,7 @@ ssize_t default_file_splice_read(struct file *in, loff_t *ppos,
55675 goto err;
55676
55677 this_len = min_t(size_t, len, PAGE_CACHE_SIZE - offset);
55678 - vec[i].iov_base = (void __user *) page_address(page);
55679 + vec[i].iov_base = (void __force_user *) page_address(page);
55680 vec[i].iov_len = this_len;
55681 spd.pages[i] = page;
55682 spd.nr_pages++;
55683 @@ -851,10 +851,10 @@ EXPORT_SYMBOL(splice_from_pipe_feed);
55684 int splice_from_pipe_next(struct pipe_inode_info *pipe, struct splice_desc *sd)
55685 {
55686 while (!pipe->nrbufs) {
55687 - if (!pipe->writers)
55688 + if (!atomic_read(&pipe->writers))
55689 return 0;
55690
55691 - if (!pipe->waiting_writers && sd->num_spliced)
55692 + if (!atomic_read(&pipe->waiting_writers) && sd->num_spliced)
55693 return 0;
55694
55695 if (sd->flags & SPLICE_F_NONBLOCK)
55696 @@ -1189,7 +1189,7 @@ ssize_t splice_direct_to_actor(struct file *in, struct splice_desc *sd,
55697 * out of the pipe right after the splice_to_pipe(). So set
55698 * PIPE_READERS appropriately.
55699 */
55700 - pipe->readers = 1;
55701 + atomic_set(&pipe->readers, 1);
55702
55703 current->splice_pipe = pipe;
55704 }
55705 @@ -1738,9 +1738,9 @@ static int ipipe_prep(struct pipe_inode_info *pipe, unsigned int flags)
55706 ret = -ERESTARTSYS;
55707 break;
55708 }
55709 - if (!pipe->writers)
55710 + if (!atomic_read(&pipe->writers))
55711 break;
55712 - if (!pipe->waiting_writers) {
55713 + if (!atomic_read(&pipe->waiting_writers)) {
55714 if (flags & SPLICE_F_NONBLOCK) {
55715 ret = -EAGAIN;
55716 break;
55717 @@ -1772,7 +1772,7 @@ static int opipe_prep(struct pipe_inode_info *pipe, unsigned int flags)
55718 pipe_lock(pipe);
55719
55720 while (pipe->nrbufs >= pipe->buffers) {
55721 - if (!pipe->readers) {
55722 + if (!atomic_read(&pipe->readers)) {
55723 send_sig(SIGPIPE, current, 0);
55724 ret = -EPIPE;
55725 break;
55726 @@ -1785,9 +1785,9 @@ static int opipe_prep(struct pipe_inode_info *pipe, unsigned int flags)
55727 ret = -ERESTARTSYS;
55728 break;
55729 }
55730 - pipe->waiting_writers++;
55731 + atomic_inc(&pipe->waiting_writers);
55732 pipe_wait(pipe);
55733 - pipe->waiting_writers--;
55734 + atomic_dec(&pipe->waiting_writers);
55735 }
55736
55737 pipe_unlock(pipe);
55738 @@ -1823,14 +1823,14 @@ retry:
55739 pipe_double_lock(ipipe, opipe);
55740
55741 do {
55742 - if (!opipe->readers) {
55743 + if (!atomic_read(&opipe->readers)) {
55744 send_sig(SIGPIPE, current, 0);
55745 if (!ret)
55746 ret = -EPIPE;
55747 break;
55748 }
55749
55750 - if (!ipipe->nrbufs && !ipipe->writers)
55751 + if (!ipipe->nrbufs && !atomic_read(&ipipe->writers))
55752 break;
55753
55754 /*
55755 @@ -1927,7 +1927,7 @@ static int link_pipe(struct pipe_inode_info *ipipe,
55756 pipe_double_lock(ipipe, opipe);
55757
55758 do {
55759 - if (!opipe->readers) {
55760 + if (!atomic_read(&opipe->readers)) {
55761 send_sig(SIGPIPE, current, 0);
55762 if (!ret)
55763 ret = -EPIPE;
55764 @@ -1972,7 +1972,7 @@ static int link_pipe(struct pipe_inode_info *ipipe,
55765 * return EAGAIN if we have the potential of some data in the
55766 * future, otherwise just return 0
55767 */
55768 - if (!ret && ipipe->waiting_writers && (flags & SPLICE_F_NONBLOCK))
55769 + if (!ret && atomic_read(&ipipe->waiting_writers) && (flags & SPLICE_F_NONBLOCK))
55770 ret = -EAGAIN;
55771
55772 pipe_unlock(ipipe);
55773 diff --git a/fs/stat.c b/fs/stat.c
55774 index 14f4545..9b7f55b 100644
55775 --- a/fs/stat.c
55776 +++ b/fs/stat.c
55777 @@ -28,8 +28,13 @@ void generic_fillattr(struct inode *inode, struct kstat *stat)
55778 stat->gid = inode->i_gid;
55779 stat->rdev = inode->i_rdev;
55780 stat->size = i_size_read(inode);
55781 - stat->atime = inode->i_atime;
55782 - stat->mtime = inode->i_mtime;
55783 + if (is_sidechannel_device(inode) && !capable_nolog(CAP_MKNOD)) {
55784 + stat->atime = inode->i_ctime;
55785 + stat->mtime = inode->i_ctime;
55786 + } else {
55787 + stat->atime = inode->i_atime;
55788 + stat->mtime = inode->i_mtime;
55789 + }
55790 stat->ctime = inode->i_ctime;
55791 stat->blksize = (1 << inode->i_blkbits);
55792 stat->blocks = inode->i_blocks;
55793 @@ -46,8 +51,14 @@ int vfs_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat)
55794 if (retval)
55795 return retval;
55796
55797 - if (inode->i_op->getattr)
55798 - return inode->i_op->getattr(mnt, dentry, stat);
55799 + if (inode->i_op->getattr) {
55800 + retval = inode->i_op->getattr(mnt, dentry, stat);
55801 + if (!retval && is_sidechannel_device(inode) && !capable_nolog(CAP_MKNOD)) {
55802 + stat->atime = stat->ctime;
55803 + stat->mtime = stat->ctime;
55804 + }
55805 + return retval;
55806 + }
55807
55808 generic_fillattr(inode, stat);
55809 return 0;
55810 diff --git a/fs/sysfs/dir.c b/fs/sysfs/dir.c
55811 index 2fbdff6..5530a61 100644
55812 --- a/fs/sysfs/dir.c
55813 +++ b/fs/sysfs/dir.c
55814 @@ -685,6 +685,18 @@ static int create_dir(struct kobject *kobj, struct sysfs_dirent *parent_sd,
55815 struct sysfs_dirent *sd;
55816 int rc;
55817
55818 +#ifdef CONFIG_GRKERNSEC_SYSFS_RESTRICT
55819 + const char *parent_name = parent_sd->s_name;
55820 +
55821 + mode = S_IFDIR | S_IRWXU;
55822 +
55823 + if ((!strcmp(parent_name, "") && (!strcmp(name, "devices") || !strcmp(name, "fs"))) ||
55824 + (!strcmp(parent_name, "devices") && !strcmp(name, "system")) ||
55825 + (!strcmp(parent_name, "fs") && (!strcmp(name, "selinux") || !strcmp(name, "fuse"))) ||
55826 + (!strcmp(parent_name, "system") && !strcmp(name, "cpu")))
55827 + mode = S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO;
55828 +#endif
55829 +
55830 /* allocate */
55831 sd = sysfs_new_dirent(name, mode, SYSFS_DIR);
55832 if (!sd)
55833 diff --git a/fs/sysfs/file.c b/fs/sysfs/file.c
55834 index 602f56d..6853db8 100644
55835 --- a/fs/sysfs/file.c
55836 +++ b/fs/sysfs/file.c
55837 @@ -37,7 +37,7 @@ static DEFINE_SPINLOCK(sysfs_open_dirent_lock);
55838
55839 struct sysfs_open_dirent {
55840 atomic_t refcnt;
55841 - atomic_t event;
55842 + atomic_unchecked_t event;
55843 wait_queue_head_t poll;
55844 struct list_head buffers; /* goes through sysfs_buffer.list */
55845 };
55846 @@ -81,7 +81,7 @@ static int fill_read_buffer(struct dentry * dentry, struct sysfs_buffer * buffer
55847 if (!sysfs_get_active(attr_sd))
55848 return -ENODEV;
55849
55850 - buffer->event = atomic_read(&attr_sd->s_attr.open->event);
55851 + buffer->event = atomic_read_unchecked(&attr_sd->s_attr.open->event);
55852 count = ops->show(kobj, attr_sd->s_attr.attr, buffer->page);
55853
55854 sysfs_put_active(attr_sd);
55855 @@ -287,7 +287,7 @@ static int sysfs_get_open_dirent(struct sysfs_dirent *sd,
55856 return -ENOMEM;
55857
55858 atomic_set(&new_od->refcnt, 0);
55859 - atomic_set(&new_od->event, 1);
55860 + atomic_set_unchecked(&new_od->event, 1);
55861 init_waitqueue_head(&new_od->poll);
55862 INIT_LIST_HEAD(&new_od->buffers);
55863 goto retry;
55864 @@ -432,7 +432,7 @@ static unsigned int sysfs_poll(struct file *filp, poll_table *wait)
55865
55866 sysfs_put_active(attr_sd);
55867
55868 - if (buffer->event != atomic_read(&od->event))
55869 + if (buffer->event != atomic_read_unchecked(&od->event))
55870 goto trigger;
55871
55872 return DEFAULT_POLLMASK;
55873 @@ -451,7 +451,7 @@ void sysfs_notify_dirent(struct sysfs_dirent *sd)
55874
55875 od = sd->s_attr.open;
55876 if (od) {
55877 - atomic_inc(&od->event);
55878 + atomic_inc_unchecked(&od->event);
55879 wake_up_interruptible(&od->poll);
55880 }
55881
55882 diff --git a/fs/sysfs/symlink.c b/fs/sysfs/symlink.c
55883 index 3c9eb56..9dea5be 100644
55884 --- a/fs/sysfs/symlink.c
55885 +++ b/fs/sysfs/symlink.c
55886 @@ -286,7 +286,7 @@ static void *sysfs_follow_link(struct dentry *dentry, struct nameidata *nd)
55887
55888 static void sysfs_put_link(struct dentry *dentry, struct nameidata *nd, void *cookie)
55889 {
55890 - char *page = nd_get_link(nd);
55891 + const char *page = nd_get_link(nd);
55892 if (!IS_ERR(page))
55893 free_page((unsigned long)page);
55894 }
55895 diff --git a/fs/sysv/sysv.h b/fs/sysv/sysv.h
55896 index 69d4889..a810bd4 100644
55897 --- a/fs/sysv/sysv.h
55898 +++ b/fs/sysv/sysv.h
55899 @@ -188,7 +188,7 @@ static inline u32 PDP_swab(u32 x)
55900 #endif
55901 }
55902
55903 -static inline __u32 fs32_to_cpu(struct sysv_sb_info *sbi, __fs32 n)
55904 +static inline __u32 __intentional_overflow(-1) fs32_to_cpu(struct sysv_sb_info *sbi, __fs32 n)
55905 {
55906 if (sbi->s_bytesex == BYTESEX_PDP)
55907 return PDP_swab((__force __u32)n);
55908 diff --git a/fs/ubifs/io.c b/fs/ubifs/io.c
55909 index e18b988..f1d4ad0f 100644
55910 --- a/fs/ubifs/io.c
55911 +++ b/fs/ubifs/io.c
55912 @@ -155,7 +155,7 @@ int ubifs_leb_change(struct ubifs_info *c, int lnum, const void *buf, int len)
55913 return err;
55914 }
55915
55916 -int ubifs_leb_unmap(struct ubifs_info *c, int lnum)
55917 +int __intentional_overflow(-1) ubifs_leb_unmap(struct ubifs_info *c, int lnum)
55918 {
55919 int err;
55920
55921 diff --git a/fs/udf/misc.c b/fs/udf/misc.c
55922 index c175b4d..8f36a16 100644
55923 --- a/fs/udf/misc.c
55924 +++ b/fs/udf/misc.c
55925 @@ -289,7 +289,7 @@ void udf_new_tag(char *data, uint16_t ident, uint16_t version, uint16_t snum,
55926
55927 u8 udf_tag_checksum(const struct tag *t)
55928 {
55929 - u8 *data = (u8 *)t;
55930 + const u8 *data = (const u8 *)t;
55931 u8 checksum = 0;
55932 int i;
55933 for (i = 0; i < sizeof(struct tag); ++i)
55934 diff --git a/fs/ufs/swab.h b/fs/ufs/swab.h
55935 index 8d974c4..b82f6ec 100644
55936 --- a/fs/ufs/swab.h
55937 +++ b/fs/ufs/swab.h
55938 @@ -22,7 +22,7 @@ enum {
55939 BYTESEX_BE
55940 };
55941
55942 -static inline u64
55943 +static inline u64 __intentional_overflow(-1)
55944 fs64_to_cpu(struct super_block *sbp, __fs64 n)
55945 {
55946 if (UFS_SB(sbp)->s_bytesex == BYTESEX_LE)
55947 @@ -40,7 +40,7 @@ cpu_to_fs64(struct super_block *sbp, u64 n)
55948 return (__force __fs64)cpu_to_be64(n);
55949 }
55950
55951 -static inline u32
55952 +static inline u32 __intentional_overflow(-1)
55953 fs32_to_cpu(struct super_block *sbp, __fs32 n)
55954 {
55955 if (UFS_SB(sbp)->s_bytesex == BYTESEX_LE)
55956 diff --git a/fs/utimes.c b/fs/utimes.c
55957 index f4fb7ec..3fe03c0 100644
55958 --- a/fs/utimes.c
55959 +++ b/fs/utimes.c
55960 @@ -1,6 +1,7 @@
55961 #include <linux/compiler.h>
55962 #include <linux/file.h>
55963 #include <linux/fs.h>
55964 +#include <linux/security.h>
55965 #include <linux/linkage.h>
55966 #include <linux/mount.h>
55967 #include <linux/namei.h>
55968 @@ -101,6 +102,12 @@ static int utimes_common(struct path *path, struct timespec *times)
55969 goto mnt_drop_write_and_out;
55970 }
55971 }
55972 +
55973 + if (!gr_acl_handle_utime(path->dentry, path->mnt)) {
55974 + error = -EACCES;
55975 + goto mnt_drop_write_and_out;
55976 + }
55977 +
55978 mutex_lock(&inode->i_mutex);
55979 error = notify_change(path->dentry, &newattrs);
55980 mutex_unlock(&inode->i_mutex);
55981 diff --git a/fs/xattr.c b/fs/xattr.c
55982 index 3377dff..4feded6 100644
55983 --- a/fs/xattr.c
55984 +++ b/fs/xattr.c
55985 @@ -319,7 +319,7 @@ EXPORT_SYMBOL_GPL(vfs_removexattr);
55986 * Extended attribute SET operations
55987 */
55988 static long
55989 -setxattr(struct dentry *d, const char __user *name, const void __user *value,
55990 +setxattr(struct path *path, const char __user *name, const void __user *value,
55991 size_t size, int flags)
55992 {
55993 int error;
55994 @@ -355,7 +355,12 @@ setxattr(struct dentry *d, const char __user *name, const void __user *value,
55995 posix_acl_fix_xattr_from_user(kvalue, size);
55996 }
55997
55998 - error = vfs_setxattr(d, kname, kvalue, size, flags);
55999 + if (!gr_acl_handle_setxattr(path->dentry, path->mnt)) {
56000 + error = -EACCES;
56001 + goto out;
56002 + }
56003 +
56004 + error = vfs_setxattr(path->dentry, kname, kvalue, size, flags);
56005 out:
56006 if (vvalue)
56007 vfree(vvalue);
56008 @@ -377,7 +382,7 @@ retry:
56009 return error;
56010 error = mnt_want_write(path.mnt);
56011 if (!error) {
56012 - error = setxattr(path.dentry, name, value, size, flags);
56013 + error = setxattr(&path, name, value, size, flags);
56014 mnt_drop_write(path.mnt);
56015 }
56016 path_put(&path);
56017 @@ -401,7 +406,7 @@ retry:
56018 return error;
56019 error = mnt_want_write(path.mnt);
56020 if (!error) {
56021 - error = setxattr(path.dentry, name, value, size, flags);
56022 + error = setxattr(&path, name, value, size, flags);
56023 mnt_drop_write(path.mnt);
56024 }
56025 path_put(&path);
56026 @@ -416,16 +421,14 @@ SYSCALL_DEFINE5(fsetxattr, int, fd, const char __user *, name,
56027 const void __user *,value, size_t, size, int, flags)
56028 {
56029 struct fd f = fdget(fd);
56030 - struct dentry *dentry;
56031 int error = -EBADF;
56032
56033 if (!f.file)
56034 return error;
56035 - dentry = f.file->f_path.dentry;
56036 - audit_inode(NULL, dentry, 0);
56037 + audit_inode(NULL, f.file->f_path.dentry, 0);
56038 error = mnt_want_write_file(f.file);
56039 if (!error) {
56040 - error = setxattr(dentry, name, value, size, flags);
56041 + error = setxattr(&f.file->f_path, name, value, size, flags);
56042 mnt_drop_write_file(f.file);
56043 }
56044 fdput(f);
56045 diff --git a/fs/xattr_acl.c b/fs/xattr_acl.c
56046 index 9fbea87..6b19972 100644
56047 --- a/fs/xattr_acl.c
56048 +++ b/fs/xattr_acl.c
56049 @@ -76,8 +76,8 @@ struct posix_acl *
56050 posix_acl_from_xattr(struct user_namespace *user_ns,
56051 const void *value, size_t size)
56052 {
56053 - posix_acl_xattr_header *header = (posix_acl_xattr_header *)value;
56054 - posix_acl_xattr_entry *entry = (posix_acl_xattr_entry *)(header+1), *end;
56055 + const posix_acl_xattr_header *header = (const posix_acl_xattr_header *)value;
56056 + const posix_acl_xattr_entry *entry = (const posix_acl_xattr_entry *)(header+1), *end;
56057 int count;
56058 struct posix_acl *acl;
56059 struct posix_acl_entry *acl_e;
56060 diff --git a/fs/xfs/xfs_bmap.c b/fs/xfs/xfs_bmap.c
56061 index 572a858..12a9b0d 100644
56062 --- a/fs/xfs/xfs_bmap.c
56063 +++ b/fs/xfs/xfs_bmap.c
56064 @@ -192,7 +192,7 @@ xfs_bmap_validate_ret(
56065 int nmap,
56066 int ret_nmap);
56067 #else
56068 -#define xfs_bmap_validate_ret(bno,len,flags,mval,onmap,nmap)
56069 +#define xfs_bmap_validate_ret(bno,len,flags,mval,onmap,nmap) do {} while (0)
56070 #endif /* DEBUG */
56071
56072 STATIC int
56073 diff --git a/fs/xfs/xfs_dir2_sf.c b/fs/xfs/xfs_dir2_sf.c
56074 index 1b9fc3e..e1bdde0 100644
56075 --- a/fs/xfs/xfs_dir2_sf.c
56076 +++ b/fs/xfs/xfs_dir2_sf.c
56077 @@ -851,7 +851,15 @@ xfs_dir2_sf_getdents(
56078 }
56079
56080 ino = xfs_dir2_sfe_get_ino(sfp, sfep);
56081 - if (filldir(dirent, (char *)sfep->name, sfep->namelen,
56082 + if (dp->i_df.if_u1.if_data == dp->i_df.if_u2.if_inline_data) {
56083 + char name[sfep->namelen];
56084 + memcpy(name, sfep->name, sfep->namelen);
56085 + if (filldir(dirent, name, sfep->namelen,
56086 + off & 0x7fffffff, ino, DT_UNKNOWN)) {
56087 + *offset = off & 0x7fffffff;
56088 + return 0;
56089 + }
56090 + } else if (filldir(dirent, (char *)sfep->name, sfep->namelen,
56091 off & 0x7fffffff, ino, DT_UNKNOWN)) {
56092 *offset = off & 0x7fffffff;
56093 return 0;
56094 diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c
56095 index c1c3ef8..0952438 100644
56096 --- a/fs/xfs/xfs_ioctl.c
56097 +++ b/fs/xfs/xfs_ioctl.c
56098 @@ -127,7 +127,7 @@ xfs_find_handle(
56099 }
56100
56101 error = -EFAULT;
56102 - if (copy_to_user(hreq->ohandle, &handle, hsize) ||
56103 + if (hsize > sizeof handle || copy_to_user(hreq->ohandle, &handle, hsize) ||
56104 copy_to_user(hreq->ohandlen, &hsize, sizeof(__s32)))
56105 goto out_put;
56106
56107 diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c
56108 index d82efaa..0904a8e 100644
56109 --- a/fs/xfs/xfs_iops.c
56110 +++ b/fs/xfs/xfs_iops.c
56111 @@ -395,7 +395,7 @@ xfs_vn_put_link(
56112 struct nameidata *nd,
56113 void *p)
56114 {
56115 - char *s = nd_get_link(nd);
56116 + const char *s = nd_get_link(nd);
56117
56118 if (!IS_ERR(s))
56119 kfree(s);
56120 diff --git a/grsecurity/Kconfig b/grsecurity/Kconfig
56121 new file mode 100644
56122 index 0000000..92247e4
56123 --- /dev/null
56124 +++ b/grsecurity/Kconfig
56125 @@ -0,0 +1,1021 @@
56126 +#
56127 +# grecurity configuration
56128 +#
56129 +menu "Memory Protections"
56130 +depends on GRKERNSEC
56131 +
56132 +config GRKERNSEC_KMEM
56133 + bool "Deny reading/writing to /dev/kmem, /dev/mem, and /dev/port"
56134 + default y if GRKERNSEC_CONFIG_AUTO
56135 + select STRICT_DEVMEM if (X86 || ARM || TILE || S390)
56136 + help
56137 + If you say Y here, /dev/kmem and /dev/mem won't be allowed to
56138 + be written to or read from to modify or leak the contents of the running
56139 + kernel. /dev/port will also not be allowed to be opened and support
56140 + for /dev/cpu/*/msr will be removed. If you have module
56141 + support disabled, enabling this will close up five ways that are
56142 + currently used to insert malicious code into the running kernel.
56143 +
56144 + Even with all these features enabled, we still highly recommend that
56145 + you use the RBAC system, as it is still possible for an attacker to
56146 + modify the running kernel through privileged I/O granted by ioperm/iopl.
56147 +
56148 + If you are not using XFree86, you may be able to stop this additional
56149 + case by enabling the 'Disable privileged I/O' option. Though nothing
56150 + legitimately writes to /dev/kmem, XFree86 does need to write to /dev/mem,
56151 + but only to video memory, which is the only writing we allow in this
56152 + case. If /dev/kmem or /dev/mem are mmaped without PROT_WRITE, they will
56153 + not be allowed to mprotect it with PROT_WRITE later.
56154 + Enabling this feature will prevent the "cpupower" and "powertop" tools
56155 + from working.
56156 +
56157 + It is highly recommended that you say Y here if you meet all the
56158 + conditions above.
56159 +
56160 +config GRKERNSEC_VM86
56161 + bool "Restrict VM86 mode"
56162 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER)
56163 + depends on X86_32
56164 +
56165 + help
56166 + If you say Y here, only processes with CAP_SYS_RAWIO will be able to
56167 + make use of a special execution mode on 32bit x86 processors called
56168 + Virtual 8086 (VM86) mode. XFree86 may need vm86 mode for certain
56169 + video cards and will still work with this option enabled. The purpose
56170 + of the option is to prevent exploitation of emulation errors in
56171 + virtualization of vm86 mode like the one discovered in VMWare in 2009.
56172 + Nearly all users should be able to enable this option.
56173 +
56174 +config GRKERNSEC_IO
56175 + bool "Disable privileged I/O"
56176 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER)
56177 + depends on X86
56178 + select RTC_CLASS
56179 + select RTC_INTF_DEV
56180 + select RTC_DRV_CMOS
56181 +
56182 + help
56183 + If you say Y here, all ioperm and iopl calls will return an error.
56184 + Ioperm and iopl can be used to modify the running kernel.
56185 + Unfortunately, some programs need this access to operate properly,
56186 + the most notable of which are XFree86 and hwclock. hwclock can be
56187 + remedied by having RTC support in the kernel, so real-time
56188 + clock support is enabled if this option is enabled, to ensure
56189 + that hwclock operates correctly. XFree86 still will not
56190 + operate correctly with this option enabled, so DO NOT CHOOSE Y
56191 + IF YOU USE XFree86. If you use XFree86 and you still want to
56192 + protect your kernel against modification, use the RBAC system.
56193 +
56194 +config GRKERNSEC_JIT_HARDEN
56195 + bool "Harden BPF JIT against spray attacks"
56196 + default y if GRKERNSEC_CONFIG_AUTO
56197 + depends on BPF_JIT
56198 + help
56199 + If you say Y here, the native code generated by the kernel's Berkeley
56200 + Packet Filter (BPF) JIT engine will be hardened against JIT-spraying
56201 + attacks that attempt to fit attacker-beneficial instructions in
56202 + 32bit immediate fields of JIT-generated native instructions. The
56203 + attacker will generally aim to cause an unintended instruction sequence
56204 + of JIT-generated native code to execute by jumping into the middle of
56205 + a generated instruction. This feature effectively randomizes the 32bit
56206 + immediate constants present in the generated code to thwart such attacks.
56207 +
56208 + If you're using KERNEXEC, it's recommended that you enable this option
56209 + to supplement the hardening of the kernel.
56210 +
56211 +config GRKERNSEC_RAND_THREADSTACK
56212 + bool "Insert random gaps between thread stacks"
56213 + default y if GRKERNSEC_CONFIG_AUTO
56214 + depends on PAX_RANDMMAP && !PPC
56215 + help
56216 + If you say Y here, a random-sized gap will be enforced between allocated
56217 + thread stacks. Glibc's NPTL and other threading libraries that
56218 + pass MAP_STACK to the kernel for thread stack allocation are supported.
56219 + The implementation currently provides 8 bits of entropy for the gap.
56220 +
56221 + Many distributions do not compile threaded remote services with the
56222 + -fstack-check argument to GCC, causing the variable-sized stack-based
56223 + allocator, alloca(), to not probe the stack on allocation. This
56224 + permits an unbounded alloca() to skip over any guard page and potentially
56225 + modify another thread's stack reliably. An enforced random gap
56226 + reduces the reliability of such an attack and increases the chance
56227 + that such a read/write to another thread's stack instead lands in
56228 + an unmapped area, causing a crash and triggering grsecurity's
56229 + anti-bruteforcing logic.
56230 +
56231 +config GRKERNSEC_PROC_MEMMAP
56232 + bool "Harden ASLR against information leaks and entropy reduction"
56233 + default y if (GRKERNSEC_CONFIG_AUTO || PAX_NOEXEC || PAX_ASLR)
56234 + depends on PAX_NOEXEC || PAX_ASLR
56235 + help
56236 + If you say Y here, the /proc/<pid>/maps and /proc/<pid>/stat files will
56237 + give no information about the addresses of its mappings if
56238 + PaX features that rely on random addresses are enabled on the task.
56239 + In addition to sanitizing this information and disabling other
56240 + dangerous sources of information, this option causes reads of sensitive
56241 + /proc/<pid> entries where the file descriptor was opened in a different
56242 + task than the one performing the read. Such attempts are logged.
56243 + This option also limits argv/env strings for suid/sgid binaries
56244 + to 512KB to prevent a complete exhaustion of the stack entropy provided
56245 + by ASLR. Finally, it places an 8MB stack resource limit on suid/sgid
56246 + binaries to prevent alternative mmap layouts from being abused.
56247 +
56248 + If you use PaX it is essential that you say Y here as it closes up
56249 + several holes that make full ASLR useless locally.
56250 +
56251 +config GRKERNSEC_BRUTE
56252 + bool "Deter exploit bruteforcing"
56253 + default y if GRKERNSEC_CONFIG_AUTO
56254 + help
56255 + If you say Y here, attempts to bruteforce exploits against forking
56256 + daemons such as apache or sshd, as well as against suid/sgid binaries
56257 + will be deterred. When a child of a forking daemon is killed by PaX
56258 + or crashes due to an illegal instruction or other suspicious signal,
56259 + the parent process will be delayed 30 seconds upon every subsequent
56260 + fork until the administrator is able to assess the situation and
56261 + restart the daemon.
56262 + In the suid/sgid case, the attempt is logged, the user has all their
56263 + processes terminated, and they are prevented from executing any further
56264 + processes for 15 minutes.
56265 + It is recommended that you also enable signal logging in the auditing
56266 + section so that logs are generated when a process triggers a suspicious
56267 + signal.
56268 + If the sysctl option is enabled, a sysctl option with name
56269 + "deter_bruteforce" is created.
56270 +
56271 +
56272 +config GRKERNSEC_MODHARDEN
56273 + bool "Harden module auto-loading"
56274 + default y if GRKERNSEC_CONFIG_AUTO
56275 + depends on MODULES
56276 + help
56277 + If you say Y here, module auto-loading in response to use of some
56278 + feature implemented by an unloaded module will be restricted to
56279 + root users. Enabling this option helps defend against attacks
56280 + by unprivileged users who abuse the auto-loading behavior to
56281 + cause a vulnerable module to load that is then exploited.
56282 +
56283 + If this option prevents a legitimate use of auto-loading for a
56284 + non-root user, the administrator can execute modprobe manually
56285 + with the exact name of the module mentioned in the alert log.
56286 + Alternatively, the administrator can add the module to the list
56287 + of modules loaded at boot by modifying init scripts.
56288 +
56289 + Modification of init scripts will most likely be needed on
56290 + Ubuntu servers with encrypted home directory support enabled,
56291 + as the first non-root user logging in will cause the ecb(aes),
56292 + ecb(aes)-all, cbc(aes), and cbc(aes)-all modules to be loaded.
56293 +
56294 +config GRKERNSEC_HIDESYM
56295 + bool "Hide kernel symbols"
56296 + default y if GRKERNSEC_CONFIG_AUTO
56297 + select PAX_USERCOPY_SLABS
56298 + help
56299 + If you say Y here, getting information on loaded modules, and
56300 + displaying all kernel symbols through a syscall will be restricted
56301 + to users with CAP_SYS_MODULE. For software compatibility reasons,
56302 + /proc/kallsyms will be restricted to the root user. The RBAC
56303 + system can hide that entry even from root.
56304 +
56305 + This option also prevents leaking of kernel addresses through
56306 + several /proc entries.
56307 +
56308 + Note that this option is only effective provided the following
56309 + conditions are met:
56310 + 1) The kernel using grsecurity is not precompiled by some distribution
56311 + 2) You have also enabled GRKERNSEC_DMESG
56312 + 3) You are using the RBAC system and hiding other files such as your
56313 + kernel image and System.map. Alternatively, enabling this option
56314 + causes the permissions on /boot, /lib/modules, and the kernel
56315 + source directory to change at compile time to prevent
56316 + reading by non-root users.
56317 + If the above conditions are met, this option will aid in providing a
56318 + useful protection against local kernel exploitation of overflows
56319 + and arbitrary read/write vulnerabilities.
56320 +
56321 +config GRKERNSEC_KERN_LOCKOUT
56322 + bool "Active kernel exploit response"
56323 + default y if GRKERNSEC_CONFIG_AUTO
56324 + depends on X86 || ARM || PPC || SPARC
56325 + help
56326 + If you say Y here, when a PaX alert is triggered due to suspicious
56327 + activity in the kernel (from KERNEXEC/UDEREF/USERCOPY)
56328 + or an OOPS occurs due to bad memory accesses, instead of just
56329 + terminating the offending process (and potentially allowing
56330 + a subsequent exploit from the same user), we will take one of two
56331 + actions:
56332 + If the user was root, we will panic the system
56333 + If the user was non-root, we will log the attempt, terminate
56334 + all processes owned by the user, then prevent them from creating
56335 + any new processes until the system is restarted
56336 + This deters repeated kernel exploitation/bruteforcing attempts
56337 + and is useful for later forensics.
56338 +
56339 +endmenu
56340 +menu "Role Based Access Control Options"
56341 +depends on GRKERNSEC
56342 +
56343 +config GRKERNSEC_RBAC_DEBUG
56344 + bool
56345 +
56346 +config GRKERNSEC_NO_RBAC
56347 + bool "Disable RBAC system"
56348 + help
56349 + If you say Y here, the /dev/grsec device will be removed from the kernel,
56350 + preventing the RBAC system from being enabled. You should only say Y
56351 + here if you have no intention of using the RBAC system, so as to prevent
56352 + an attacker with root access from misusing the RBAC system to hide files
56353 + and processes when loadable module support and /dev/[k]mem have been
56354 + locked down.
56355 +
56356 +config GRKERNSEC_ACL_HIDEKERN
56357 + bool "Hide kernel processes"
56358 + help
56359 + If you say Y here, all kernel threads will be hidden to all
56360 + processes but those whose subject has the "view hidden processes"
56361 + flag.
56362 +
56363 +config GRKERNSEC_ACL_MAXTRIES
56364 + int "Maximum tries before password lockout"
56365 + default 3
56366 + help
56367 + This option enforces the maximum number of times a user can attempt
56368 + to authorize themselves with the grsecurity RBAC system before being
56369 + denied the ability to attempt authorization again for a specified time.
56370 + The lower the number, the harder it will be to brute-force a password.
56371 +
56372 +config GRKERNSEC_ACL_TIMEOUT
56373 + int "Time to wait after max password tries, in seconds"
56374 + default 30
56375 + help
56376 + This option specifies the time the user must wait after attempting to
56377 + authorize to the RBAC system with the maximum number of invalid
56378 + passwords. The higher the number, the harder it will be to brute-force
56379 + a password.
56380 +
56381 +endmenu
56382 +menu "Filesystem Protections"
56383 +depends on GRKERNSEC
56384 +
56385 +config GRKERNSEC_PROC
56386 + bool "Proc restrictions"
56387 + default y if GRKERNSEC_CONFIG_AUTO
56388 + help
56389 + If you say Y here, the permissions of the /proc filesystem
56390 + will be altered to enhance system security and privacy. You MUST
56391 + choose either a user only restriction or a user and group restriction.
56392 + Depending upon the option you choose, you can either restrict users to
56393 + see only the processes they themselves run, or choose a group that can
56394 + view all processes and files normally restricted to root if you choose
56395 + the "restrict to user only" option. NOTE: If you're running identd or
56396 + ntpd as a non-root user, you will have to run it as the group you
56397 + specify here.
56398 +
56399 +config GRKERNSEC_PROC_USER
56400 + bool "Restrict /proc to user only"
56401 + depends on GRKERNSEC_PROC
56402 + help
56403 + If you say Y here, non-root users will only be able to view their own
56404 + processes, and restricts them from viewing network-related information,
56405 + and viewing kernel symbol and module information.
56406 +
56407 +config GRKERNSEC_PROC_USERGROUP
56408 + bool "Allow special group"
56409 + default y if GRKERNSEC_CONFIG_AUTO
56410 + depends on GRKERNSEC_PROC && !GRKERNSEC_PROC_USER
56411 + help
56412 + If you say Y here, you will be able to select a group that will be
56413 + able to view all processes and network-related information. If you've
56414 + enabled GRKERNSEC_HIDESYM, kernel and symbol information may still
56415 + remain hidden. This option is useful if you want to run identd as
56416 + a non-root user. The group you select may also be chosen at boot time
56417 + via "grsec_proc_gid=" on the kernel commandline.
56418 +
56419 +config GRKERNSEC_PROC_GID
56420 + int "GID for special group"
56421 + depends on GRKERNSEC_PROC_USERGROUP
56422 + default 1001
56423 +
56424 +config GRKERNSEC_PROC_ADD
56425 + bool "Additional restrictions"
56426 + default y if GRKERNSEC_CONFIG_AUTO
56427 + depends on GRKERNSEC_PROC_USER || GRKERNSEC_PROC_USERGROUP
56428 + help
56429 + If you say Y here, additional restrictions will be placed on
56430 + /proc that keep normal users from viewing device information and
56431 + slabinfo information that could be useful for exploits.
56432 +
56433 +config GRKERNSEC_LINK
56434 + bool "Linking restrictions"
56435 + default y if GRKERNSEC_CONFIG_AUTO
56436 + help
56437 + If you say Y here, /tmp race exploits will be prevented, since users
56438 + will no longer be able to follow symlinks owned by other users in
56439 + world-writable +t directories (e.g. /tmp), unless the owner of the
56440 + symlink is the owner of the directory. users will also not be
56441 + able to hardlink to files they do not own. If the sysctl option is
56442 + enabled, a sysctl option with name "linking_restrictions" is created.
56443 +
56444 +config GRKERNSEC_SYMLINKOWN
56445 + bool "Kernel-enforced SymlinksIfOwnerMatch"
56446 + default y if GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER
56447 + help
56448 + Apache's SymlinksIfOwnerMatch option has an inherent race condition
56449 + that prevents it from being used as a security feature. As Apache
56450 + verifies the symlink by performing a stat() against the target of
56451 + the symlink before it is followed, an attacker can setup a symlink
56452 + to point to a same-owned file, then replace the symlink with one
56453 + that targets another user's file just after Apache "validates" the
56454 + symlink -- a classic TOCTOU race. If you say Y here, a complete,
56455 + race-free replacement for Apache's "SymlinksIfOwnerMatch" option
56456 + will be in place for the group you specify. If the sysctl option
56457 + is enabled, a sysctl option with name "enforce_symlinksifowner" is
56458 + created.
56459 +
56460 +config GRKERNSEC_SYMLINKOWN_GID
56461 + int "GID for users with kernel-enforced SymlinksIfOwnerMatch"
56462 + depends on GRKERNSEC_SYMLINKOWN
56463 + default 1006
56464 + help
56465 + Setting this GID determines what group kernel-enforced
56466 + SymlinksIfOwnerMatch will be enabled for. If the sysctl option
56467 + is enabled, a sysctl option with name "symlinkown_gid" is created.
56468 +
56469 +config GRKERNSEC_FIFO
56470 + bool "FIFO restrictions"
56471 + default y if GRKERNSEC_CONFIG_AUTO
56472 + help
56473 + If you say Y here, users will not be able to write to FIFOs they don't
56474 + own in world-writable +t directories (e.g. /tmp), unless the owner of
56475 + the FIFO is the same owner of the directory it's held in. If the sysctl
56476 + option is enabled, a sysctl option with name "fifo_restrictions" is
56477 + created.
56478 +
56479 +config GRKERNSEC_SYSFS_RESTRICT
56480 + bool "Sysfs/debugfs restriction"
56481 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER)
56482 + depends on SYSFS
56483 + help
56484 + If you say Y here, sysfs (the pseudo-filesystem mounted at /sys) and
56485 + any filesystem normally mounted under it (e.g. debugfs) will be
56486 + mostly accessible only by root. These filesystems generally provide access
56487 + to hardware and debug information that isn't appropriate for unprivileged
56488 + users of the system. Sysfs and debugfs have also become a large source
56489 + of new vulnerabilities, ranging from infoleaks to local compromise.
56490 + There has been very little oversight with an eye toward security involved
56491 + in adding new exporters of information to these filesystems, so their
56492 + use is discouraged.
56493 + For reasons of compatibility, a few directories have been whitelisted
56494 + for access by non-root users:
56495 + /sys/fs/selinux
56496 + /sys/fs/fuse
56497 + /sys/devices/system/cpu
56498 +
56499 +config GRKERNSEC_ROFS
56500 + bool "Runtime read-only mount protection"
56501 + help
56502 + If you say Y here, a sysctl option with name "romount_protect" will
56503 + be created. By setting this option to 1 at runtime, filesystems
56504 + will be protected in the following ways:
56505 + * No new writable mounts will be allowed
56506 + * Existing read-only mounts won't be able to be remounted read/write
56507 + * Write operations will be denied on all block devices
56508 + This option acts independently of grsec_lock: once it is set to 1,
56509 + it cannot be turned off. Therefore, please be mindful of the resulting
56510 + behavior if this option is enabled in an init script on a read-only
56511 + filesystem. This feature is mainly intended for secure embedded systems.
56512 +
56513 +config GRKERNSEC_DEVICE_SIDECHANNEL
56514 + bool "Eliminate stat/notify-based device sidechannels"
56515 + default y if GRKERNSEC_CONFIG_AUTO
56516 + help
56517 + If you say Y here, timing analyses on block or character
56518 + devices like /dev/ptmx using stat or inotify/dnotify/fanotify
56519 + will be thwarted for unprivileged users. If a process without
56520 + CAP_MKNOD stats such a device, the last access and last modify times
56521 + will match the device's create time. No access or modify events
56522 + will be triggered through inotify/dnotify/fanotify for such devices.
56523 + This feature will prevent attacks that may at a minimum
56524 + allow an attacker to determine the administrator's password length.
56525 +
56526 +config GRKERNSEC_CHROOT
56527 + bool "Chroot jail restrictions"
56528 + default y if GRKERNSEC_CONFIG_AUTO
56529 + help
56530 + If you say Y here, you will be able to choose several options that will
56531 + make breaking out of a chrooted jail much more difficult. If you
56532 + encounter no software incompatibilities with the following options, it
56533 + is recommended that you enable each one.
56534 +
56535 +config GRKERNSEC_CHROOT_MOUNT
56536 + bool "Deny mounts"
56537 + default y if GRKERNSEC_CONFIG_AUTO
56538 + depends on GRKERNSEC_CHROOT
56539 + help
56540 + If you say Y here, processes inside a chroot will not be able to
56541 + mount or remount filesystems. If the sysctl option is enabled, a
56542 + sysctl option with name "chroot_deny_mount" is created.
56543 +
56544 +config GRKERNSEC_CHROOT_DOUBLE
56545 + bool "Deny double-chroots"
56546 + default y if GRKERNSEC_CONFIG_AUTO
56547 + depends on GRKERNSEC_CHROOT
56548 + help
56549 + If you say Y here, processes inside a chroot will not be able to chroot
56550 + again outside the chroot. This is a widely used method of breaking
56551 + out of a chroot jail and should not be allowed. If the sysctl
56552 + option is enabled, a sysctl option with name
56553 + "chroot_deny_chroot" is created.
56554 +
56555 +config GRKERNSEC_CHROOT_PIVOT
56556 + bool "Deny pivot_root in chroot"
56557 + default y if GRKERNSEC_CONFIG_AUTO
56558 + depends on GRKERNSEC_CHROOT
56559 + help
56560 + If you say Y here, processes inside a chroot will not be able to use
56561 + a function called pivot_root() that was introduced in Linux 2.3.41. It
56562 + works similar to chroot in that it changes the root filesystem. This
56563 + function could be misused in a chrooted process to attempt to break out
56564 + of the chroot, and therefore should not be allowed. If the sysctl
56565 + option is enabled, a sysctl option with name "chroot_deny_pivot" is
56566 + created.
56567 +
56568 +config GRKERNSEC_CHROOT_CHDIR
56569 + bool "Enforce chdir(\"/\") on all chroots"
56570 + default y if GRKERNSEC_CONFIG_AUTO
56571 + depends on GRKERNSEC_CHROOT
56572 + help
56573 + If you say Y here, the current working directory of all newly-chrooted
56574 + applications will be set to the the root directory of the chroot.
56575 + The man page on chroot(2) states:
56576 + Note that this call does not change the current working
56577 + directory, so that `.' can be outside the tree rooted at
56578 + `/'. In particular, the super-user can escape from a
56579 + `chroot jail' by doing `mkdir foo; chroot foo; cd ..'.
56580 +
56581 + It is recommended that you say Y here, since it's not known to break
56582 + any software. If the sysctl option is enabled, a sysctl option with
56583 + name "chroot_enforce_chdir" is created.
56584 +
56585 +config GRKERNSEC_CHROOT_CHMOD
56586 + bool "Deny (f)chmod +s"
56587 + default y if GRKERNSEC_CONFIG_AUTO
56588 + depends on GRKERNSEC_CHROOT
56589 + help
56590 + If you say Y here, processes inside a chroot will not be able to chmod
56591 + or fchmod files to make them have suid or sgid bits. This protects
56592 + against another published method of breaking a chroot. If the sysctl
56593 + option is enabled, a sysctl option with name "chroot_deny_chmod" is
56594 + created.
56595 +
56596 +config GRKERNSEC_CHROOT_FCHDIR
56597 + bool "Deny fchdir out of chroot"
56598 + default y if GRKERNSEC_CONFIG_AUTO
56599 + depends on GRKERNSEC_CHROOT
56600 + help
56601 + If you say Y here, a well-known method of breaking chroots by fchdir'ing
56602 + to a file descriptor of the chrooting process that points to a directory
56603 + outside the filesystem will be stopped. If the sysctl option
56604 + is enabled, a sysctl option with name "chroot_deny_fchdir" is created.
56605 +
56606 +config GRKERNSEC_CHROOT_MKNOD
56607 + bool "Deny mknod"
56608 + default y if GRKERNSEC_CONFIG_AUTO
56609 + depends on GRKERNSEC_CHROOT
56610 + help
56611 + If you say Y here, processes inside a chroot will not be allowed to
56612 + mknod. The problem with using mknod inside a chroot is that it
56613 + would allow an attacker to create a device entry that is the same
56614 + as one on the physical root of your system, which could range from
56615 + anything from the console device to a device for your harddrive (which
56616 + they could then use to wipe the drive or steal data). It is recommended
56617 + that you say Y here, unless you run into software incompatibilities.
56618 + If the sysctl option is enabled, a sysctl option with name
56619 + "chroot_deny_mknod" is created.
56620 +
56621 +config GRKERNSEC_CHROOT_SHMAT
56622 + bool "Deny shmat() out of chroot"
56623 + default y if GRKERNSEC_CONFIG_AUTO
56624 + depends on GRKERNSEC_CHROOT
56625 + help
56626 + If you say Y here, processes inside a chroot will not be able to attach
56627 + to shared memory segments that were created outside of the chroot jail.
56628 + It is recommended that you say Y here. If the sysctl option is enabled,
56629 + a sysctl option with name "chroot_deny_shmat" is created.
56630 +
56631 +config GRKERNSEC_CHROOT_UNIX
56632 + bool "Deny access to abstract AF_UNIX sockets out of chroot"
56633 + default y if GRKERNSEC_CONFIG_AUTO
56634 + depends on GRKERNSEC_CHROOT
56635 + help
56636 + If you say Y here, processes inside a chroot will not be able to
56637 + connect to abstract (meaning not belonging to a filesystem) Unix
56638 + domain sockets that were bound outside of a chroot. It is recommended
56639 + that you say Y here. If the sysctl option is enabled, a sysctl option
56640 + with name "chroot_deny_unix" is created.
56641 +
56642 +config GRKERNSEC_CHROOT_FINDTASK
56643 + bool "Protect outside processes"
56644 + default y if GRKERNSEC_CONFIG_AUTO
56645 + depends on GRKERNSEC_CHROOT
56646 + help
56647 + If you say Y here, processes inside a chroot will not be able to
56648 + kill, send signals with fcntl, ptrace, capget, getpgid, setpgid,
56649 + getsid, or view any process outside of the chroot. If the sysctl
56650 + option is enabled, a sysctl option with name "chroot_findtask" is
56651 + created.
56652 +
56653 +config GRKERNSEC_CHROOT_NICE
56654 + bool "Restrict priority changes"
56655 + default y if GRKERNSEC_CONFIG_AUTO
56656 + depends on GRKERNSEC_CHROOT
56657 + help
56658 + If you say Y here, processes inside a chroot will not be able to raise
56659 + the priority of processes in the chroot, or alter the priority of
56660 + processes outside the chroot. This provides more security than simply
56661 + removing CAP_SYS_NICE from the process' capability set. If the
56662 + sysctl option is enabled, a sysctl option with name "chroot_restrict_nice"
56663 + is created.
56664 +
56665 +config GRKERNSEC_CHROOT_SYSCTL
56666 + bool "Deny sysctl writes"
56667 + default y if GRKERNSEC_CONFIG_AUTO
56668 + depends on GRKERNSEC_CHROOT
56669 + help
56670 + If you say Y here, an attacker in a chroot will not be able to
56671 + write to sysctl entries, either by sysctl(2) or through a /proc
56672 + interface. It is strongly recommended that you say Y here. If the
56673 + sysctl option is enabled, a sysctl option with name
56674 + "chroot_deny_sysctl" is created.
56675 +
56676 +config GRKERNSEC_CHROOT_CAPS
56677 + bool "Capability restrictions"
56678 + default y if GRKERNSEC_CONFIG_AUTO
56679 + depends on GRKERNSEC_CHROOT
56680 + help
56681 + If you say Y here, the capabilities on all processes within a
56682 + chroot jail will be lowered to stop module insertion, raw i/o,
56683 + system and net admin tasks, rebooting the system, modifying immutable
56684 + files, modifying IPC owned by another, and changing the system time.
56685 + This is left an option because it can break some apps. Disable this
56686 + if your chrooted apps are having problems performing those kinds of
56687 + tasks. If the sysctl option is enabled, a sysctl option with
56688 + name "chroot_caps" is created.
56689 +
56690 +endmenu
56691 +menu "Kernel Auditing"
56692 +depends on GRKERNSEC
56693 +
56694 +config GRKERNSEC_AUDIT_GROUP
56695 + bool "Single group for auditing"
56696 + help
56697 + If you say Y here, the exec and chdir logging features will only operate
56698 + on a group you specify. This option is recommended if you only want to
56699 + watch certain users instead of having a large amount of logs from the
56700 + entire system. If the sysctl option is enabled, a sysctl option with
56701 + name "audit_group" is created.
56702 +
56703 +config GRKERNSEC_AUDIT_GID
56704 + int "GID for auditing"
56705 + depends on GRKERNSEC_AUDIT_GROUP
56706 + default 1007
56707 +
56708 +config GRKERNSEC_EXECLOG
56709 + bool "Exec logging"
56710 + help
56711 + If you say Y here, all execve() calls will be logged (since the
56712 + other exec*() calls are frontends to execve(), all execution
56713 + will be logged). Useful for shell-servers that like to keep track
56714 + of their users. If the sysctl option is enabled, a sysctl option with
56715 + name "exec_logging" is created.
56716 + WARNING: This option when enabled will produce a LOT of logs, especially
56717 + on an active system.
56718 +
56719 +config GRKERNSEC_RESLOG
56720 + bool "Resource logging"
56721 + default y if GRKERNSEC_CONFIG_AUTO
56722 + help
56723 + If you say Y here, all attempts to overstep resource limits will
56724 + be logged with the resource name, the requested size, and the current
56725 + limit. It is highly recommended that you say Y here. If the sysctl
56726 + option is enabled, a sysctl option with name "resource_logging" is
56727 + created. If the RBAC system is enabled, the sysctl value is ignored.
56728 +
56729 +config GRKERNSEC_CHROOT_EXECLOG
56730 + bool "Log execs within chroot"
56731 + help
56732 + If you say Y here, all executions inside a chroot jail will be logged
56733 + to syslog. This can cause a large amount of logs if certain
56734 + applications (eg. djb's daemontools) are installed on the system, and
56735 + is therefore left as an option. If the sysctl option is enabled, a
56736 + sysctl option with name "chroot_execlog" is created.
56737 +
56738 +config GRKERNSEC_AUDIT_PTRACE
56739 + bool "Ptrace logging"
56740 + help
56741 + If you say Y here, all attempts to attach to a process via ptrace
56742 + will be logged. If the sysctl option is enabled, a sysctl option
56743 + with name "audit_ptrace" is created.
56744 +
56745 +config GRKERNSEC_AUDIT_CHDIR
56746 + bool "Chdir logging"
56747 + help
56748 + If you say Y here, all chdir() calls will be logged. If the sysctl
56749 + option is enabled, a sysctl option with name "audit_chdir" is created.
56750 +
56751 +config GRKERNSEC_AUDIT_MOUNT
56752 + bool "(Un)Mount logging"
56753 + help
56754 + If you say Y here, all mounts and unmounts will be logged. If the
56755 + sysctl option is enabled, a sysctl option with name "audit_mount" is
56756 + created.
56757 +
56758 +config GRKERNSEC_SIGNAL
56759 + bool "Signal logging"
56760 + default y if GRKERNSEC_CONFIG_AUTO
56761 + help
56762 + If you say Y here, certain important signals will be logged, such as
56763 + SIGSEGV, which will as a result inform you of when a error in a program
56764 + occurred, which in some cases could mean a possible exploit attempt.
56765 + If the sysctl option is enabled, a sysctl option with name
56766 + "signal_logging" is created.
56767 +
56768 +config GRKERNSEC_FORKFAIL
56769 + bool "Fork failure logging"
56770 + help
56771 + If you say Y here, all failed fork() attempts will be logged.
56772 + This could suggest a fork bomb, or someone attempting to overstep
56773 + their process limit. If the sysctl option is enabled, a sysctl option
56774 + with name "forkfail_logging" is created.
56775 +
56776 +config GRKERNSEC_TIME
56777 + bool "Time change logging"
56778 + default y if GRKERNSEC_CONFIG_AUTO
56779 + help
56780 + If you say Y here, any changes of the system clock will be logged.
56781 + If the sysctl option is enabled, a sysctl option with name
56782 + "timechange_logging" is created.
56783 +
56784 +config GRKERNSEC_PROC_IPADDR
56785 + bool "/proc/<pid>/ipaddr support"
56786 + default y if GRKERNSEC_CONFIG_AUTO
56787 + help
56788 + If you say Y here, a new entry will be added to each /proc/<pid>
56789 + directory that contains the IP address of the person using the task.
56790 + The IP is carried across local TCP and AF_UNIX stream sockets.
56791 + This information can be useful for IDS/IPSes to perform remote response
56792 + to a local attack. The entry is readable by only the owner of the
56793 + process (and root if he has CAP_DAC_OVERRIDE, which can be removed via
56794 + the RBAC system), and thus does not create privacy concerns.
56795 +
56796 +config GRKERNSEC_RWXMAP_LOG
56797 + bool 'Denied RWX mmap/mprotect logging'
56798 + default y if GRKERNSEC_CONFIG_AUTO
56799 + depends on PAX_MPROTECT && !PAX_EMUPLT && !PAX_EMUSIGRT
56800 + help
56801 + If you say Y here, calls to mmap() and mprotect() with explicit
56802 + usage of PROT_WRITE and PROT_EXEC together will be logged when
56803 + denied by the PAX_MPROTECT feature. If the sysctl option is
56804 + enabled, a sysctl option with name "rwxmap_logging" is created.
56805 +
56806 +config GRKERNSEC_AUDIT_TEXTREL
56807 + bool 'ELF text relocations logging (READ HELP)'
56808 + depends on PAX_MPROTECT
56809 + help
56810 + If you say Y here, text relocations will be logged with the filename
56811 + of the offending library or binary. The purpose of the feature is
56812 + to help Linux distribution developers get rid of libraries and
56813 + binaries that need text relocations which hinder the future progress
56814 + of PaX. Only Linux distribution developers should say Y here, and
56815 + never on a production machine, as this option creates an information
56816 + leak that could aid an attacker in defeating the randomization of
56817 + a single memory region. If the sysctl option is enabled, a sysctl
56818 + option with name "audit_textrel" is created.
56819 +
56820 +endmenu
56821 +
56822 +menu "Executable Protections"
56823 +depends on GRKERNSEC
56824 +
56825 +config GRKERNSEC_DMESG
56826 + bool "Dmesg(8) restriction"
56827 + default y if GRKERNSEC_CONFIG_AUTO
56828 + help
56829 + If you say Y here, non-root users will not be able to use dmesg(8)
56830 + to view the contents of the kernel's circular log buffer.
56831 + The kernel's log buffer often contains kernel addresses and other
56832 + identifying information useful to an attacker in fingerprinting a
56833 + system for a targeted exploit.
56834 + If the sysctl option is enabled, a sysctl option with name "dmesg" is
56835 + created.
56836 +
56837 +config GRKERNSEC_HARDEN_PTRACE
56838 + bool "Deter ptrace-based process snooping"
56839 + default y if GRKERNSEC_CONFIG_AUTO
56840 + help
56841 + If you say Y here, TTY sniffers and other malicious monitoring
56842 + programs implemented through ptrace will be defeated. If you
56843 + have been using the RBAC system, this option has already been
56844 + enabled for several years for all users, with the ability to make
56845 + fine-grained exceptions.
56846 +
56847 + This option only affects the ability of non-root users to ptrace
56848 + processes that are not a descendent of the ptracing process.
56849 + This means that strace ./binary and gdb ./binary will still work,
56850 + but attaching to arbitrary processes will not. If the sysctl
56851 + option is enabled, a sysctl option with name "harden_ptrace" is
56852 + created.
56853 +
56854 +config GRKERNSEC_PTRACE_READEXEC
56855 + bool "Require read access to ptrace sensitive binaries"
56856 + default y if GRKERNSEC_CONFIG_AUTO
56857 + help
56858 + If you say Y here, unprivileged users will not be able to ptrace unreadable
56859 + binaries. This option is useful in environments that
56860 + remove the read bits (e.g. file mode 4711) from suid binaries to
56861 + prevent infoleaking of their contents. This option adds
56862 + consistency to the use of that file mode, as the binary could normally
56863 + be read out when run without privileges while ptracing.
56864 +
56865 + If the sysctl option is enabled, a sysctl option with name "ptrace_readexec"
56866 + is created.
56867 +
56868 +config GRKERNSEC_SETXID
56869 + bool "Enforce consistent multithreaded privileges"
56870 + default y if GRKERNSEC_CONFIG_AUTO
56871 + depends on (X86 || SPARC64 || PPC || ARM || MIPS)
56872 + help
56873 + If you say Y here, a change from a root uid to a non-root uid
56874 + in a multithreaded application will cause the resulting uids,
56875 + gids, supplementary groups, and capabilities in that thread
56876 + to be propagated to the other threads of the process. In most
56877 + cases this is unnecessary, as glibc will emulate this behavior
56878 + on behalf of the application. Other libcs do not act in the
56879 + same way, allowing the other threads of the process to continue
56880 + running with root privileges. If the sysctl option is enabled,
56881 + a sysctl option with name "consistent_setxid" is created.
56882 +
56883 +config GRKERNSEC_TPE
56884 + bool "Trusted Path Execution (TPE)"
56885 + default y if GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER
56886 + help
56887 + If you say Y here, you will be able to choose a gid to add to the
56888 + supplementary groups of users you want to mark as "untrusted."
56889 + These users will not be able to execute any files that are not in
56890 + root-owned directories writable only by root. If the sysctl option
56891 + is enabled, a sysctl option with name "tpe" is created.
56892 +
56893 +config GRKERNSEC_TPE_ALL
56894 + bool "Partially restrict all non-root users"
56895 + depends on GRKERNSEC_TPE
56896 + help
56897 + If you say Y here, all non-root users will be covered under
56898 + a weaker TPE restriction. This is separate from, and in addition to,
56899 + the main TPE options that you have selected elsewhere. Thus, if a
56900 + "trusted" GID is chosen, this restriction applies to even that GID.
56901 + Under this restriction, all non-root users will only be allowed to
56902 + execute files in directories they own that are not group or
56903 + world-writable, or in directories owned by root and writable only by
56904 + root. If the sysctl option is enabled, a sysctl option with name
56905 + "tpe_restrict_all" is created.
56906 +
56907 +config GRKERNSEC_TPE_INVERT
56908 + bool "Invert GID option"
56909 + depends on GRKERNSEC_TPE
56910 + help
56911 + If you say Y here, the group you specify in the TPE configuration will
56912 + decide what group TPE restrictions will be *disabled* for. This
56913 + option is useful if you want TPE restrictions to be applied to most
56914 + users on the system. If the sysctl option is enabled, a sysctl option
56915 + with name "tpe_invert" is created. Unlike other sysctl options, this
56916 + entry will default to on for backward-compatibility.
56917 +
56918 +config GRKERNSEC_TPE_GID
56919 + int
56920 + default GRKERNSEC_TPE_UNTRUSTED_GID if (GRKERNSEC_TPE && !GRKERNSEC_TPE_INVERT)
56921 + default GRKERNSEC_TPE_TRUSTED_GID if (GRKERNSEC_TPE && GRKERNSEC_TPE_INVERT)
56922 +
56923 +config GRKERNSEC_TPE_UNTRUSTED_GID
56924 + int "GID for TPE-untrusted users"
56925 + depends on GRKERNSEC_TPE && !GRKERNSEC_TPE_INVERT
56926 + default 1005
56927 + help
56928 + Setting this GID determines what group TPE restrictions will be
56929 + *enabled* for. If the sysctl option is enabled, a sysctl option
56930 + with name "tpe_gid" is created.
56931 +
56932 +config GRKERNSEC_TPE_TRUSTED_GID
56933 + int "GID for TPE-trusted users"
56934 + depends on GRKERNSEC_TPE && GRKERNSEC_TPE_INVERT
56935 + default 1005
56936 + help
56937 + Setting this GID determines what group TPE restrictions will be
56938 + *disabled* for. If the sysctl option is enabled, a sysctl option
56939 + with name "tpe_gid" is created.
56940 +
56941 +endmenu
56942 +menu "Network Protections"
56943 +depends on GRKERNSEC
56944 +
56945 +config GRKERNSEC_RANDNET
56946 + bool "Larger entropy pools"
56947 + default y if GRKERNSEC_CONFIG_AUTO
56948 + help
56949 + If you say Y here, the entropy pools used for many features of Linux
56950 + and grsecurity will be doubled in size. Since several grsecurity
56951 + features use additional randomness, it is recommended that you say Y
56952 + here. Saying Y here has a similar effect as modifying
56953 + /proc/sys/kernel/random/poolsize.
56954 +
56955 +config GRKERNSEC_BLACKHOLE
56956 + bool "TCP/UDP blackhole and LAST_ACK DoS prevention"
56957 + default y if GRKERNSEC_CONFIG_AUTO
56958 + depends on NET
56959 + help
56960 + If you say Y here, neither TCP resets nor ICMP
56961 + destination-unreachable packets will be sent in response to packets
56962 + sent to ports for which no associated listening process exists.
56963 + This feature supports both IPV4 and IPV6 and exempts the
56964 + loopback interface from blackholing. Enabling this feature
56965 + makes a host more resilient to DoS attacks and reduces network
56966 + visibility against scanners.
56967 +
56968 + The blackhole feature as-implemented is equivalent to the FreeBSD
56969 + blackhole feature, as it prevents RST responses to all packets, not
56970 + just SYNs. Under most application behavior this causes no
56971 + problems, but applications (like haproxy) may not close certain
56972 + connections in a way that cleanly terminates them on the remote
56973 + end, leaving the remote host in LAST_ACK state. Because of this
56974 + side-effect and to prevent intentional LAST_ACK DoSes, this
56975 + feature also adds automatic mitigation against such attacks.
56976 + The mitigation drastically reduces the amount of time a socket
56977 + can spend in LAST_ACK state. If you're using haproxy and not
56978 + all servers it connects to have this option enabled, consider
56979 + disabling this feature on the haproxy host.
56980 +
56981 + If the sysctl option is enabled, two sysctl options with names
56982 + "ip_blackhole" and "lastack_retries" will be created.
56983 + While "ip_blackhole" takes the standard zero/non-zero on/off
56984 + toggle, "lastack_retries" uses the same kinds of values as
56985 + "tcp_retries1" and "tcp_retries2". The default value of 4
56986 + prevents a socket from lasting more than 45 seconds in LAST_ACK
56987 + state.
56988 +
56989 +config GRKERNSEC_NO_SIMULT_CONNECT
56990 + bool "Disable TCP Simultaneous Connect"
56991 + default y if GRKERNSEC_CONFIG_AUTO
56992 + depends on NET
56993 + help
56994 + If you say Y here, a feature by Willy Tarreau will be enabled that
56995 + removes a weakness in Linux's strict implementation of TCP that
56996 + allows two clients to connect to each other without either entering
56997 + a listening state. The weakness allows an attacker to easily prevent
56998 + a client from connecting to a known server provided the source port
56999 + for the connection is guessed correctly.
57000 +
57001 + As the weakness could be used to prevent an antivirus or IPS from
57002 + fetching updates, or prevent an SSL gateway from fetching a CRL,
57003 + it should be eliminated by enabling this option. Though Linux is
57004 + one of few operating systems supporting simultaneous connect, it
57005 + has no legitimate use in practice and is rarely supported by firewalls.
57006 +
57007 +config GRKERNSEC_SOCKET
57008 + bool "Socket restrictions"
57009 + depends on NET
57010 + help
57011 + If you say Y here, you will be able to choose from several options.
57012 + If you assign a GID on your system and add it to the supplementary
57013 + groups of users you want to restrict socket access to, this patch
57014 + will perform up to three things, based on the option(s) you choose.
57015 +
57016 +config GRKERNSEC_SOCKET_ALL
57017 + bool "Deny any sockets to group"
57018 + depends on GRKERNSEC_SOCKET
57019 + help
57020 + If you say Y here, you will be able to choose a GID of whose users will
57021 + be unable to connect to other hosts from your machine or run server
57022 + applications from your machine. If the sysctl option is enabled, a
57023 + sysctl option with name "socket_all" is created.
57024 +
57025 +config GRKERNSEC_SOCKET_ALL_GID
57026 + int "GID to deny all sockets for"
57027 + depends on GRKERNSEC_SOCKET_ALL
57028 + default 1004
57029 + help
57030 + Here you can choose the GID to disable socket access for. Remember to
57031 + add the users you want socket access disabled for to the GID
57032 + specified here. If the sysctl option is enabled, a sysctl option
57033 + with name "socket_all_gid" is created.
57034 +
57035 +config GRKERNSEC_SOCKET_CLIENT
57036 + bool "Deny client sockets to group"
57037 + depends on GRKERNSEC_SOCKET
57038 + help
57039 + If you say Y here, you will be able to choose a GID of whose users will
57040 + be unable to connect to other hosts from your machine, but will be
57041 + able to run servers. If this option is enabled, all users in the group
57042 + you specify will have to use passive mode when initiating ftp transfers
57043 + from the shell on your machine. If the sysctl option is enabled, a
57044 + sysctl option with name "socket_client" is created.
57045 +
57046 +config GRKERNSEC_SOCKET_CLIENT_GID
57047 + int "GID to deny client sockets for"
57048 + depends on GRKERNSEC_SOCKET_CLIENT
57049 + default 1003
57050 + help
57051 + Here you can choose the GID to disable client socket access for.
57052 + Remember to add the users you want client socket access disabled for to
57053 + the GID specified here. If the sysctl option is enabled, a sysctl
57054 + option with name "socket_client_gid" is created.
57055 +
57056 +config GRKERNSEC_SOCKET_SERVER
57057 + bool "Deny server sockets to group"
57058 + depends on GRKERNSEC_SOCKET
57059 + help
57060 + If you say Y here, you will be able to choose a GID of whose users will
57061 + be unable to run server applications from your machine. If the sysctl
57062 + option is enabled, a sysctl option with name "socket_server" is created.
57063 +
57064 +config GRKERNSEC_SOCKET_SERVER_GID
57065 + int "GID to deny server sockets for"
57066 + depends on GRKERNSEC_SOCKET_SERVER
57067 + default 1002
57068 + help
57069 + Here you can choose the GID to disable server socket access for.
57070 + Remember to add the users you want server socket access disabled for to
57071 + the GID specified here. If the sysctl option is enabled, a sysctl
57072 + option with name "socket_server_gid" is created.
57073 +
57074 +endmenu
57075 +menu "Sysctl Support"
57076 +depends on GRKERNSEC && SYSCTL
57077 +
57078 +config GRKERNSEC_SYSCTL
57079 + bool "Sysctl support"
57080 + default y if GRKERNSEC_CONFIG_AUTO
57081 + help
57082 + If you say Y here, you will be able to change the options that
57083 + grsecurity runs with at bootup, without having to recompile your
57084 + kernel. You can echo values to files in /proc/sys/kernel/grsecurity
57085 + to enable (1) or disable (0) various features. All the sysctl entries
57086 + are mutable until the "grsec_lock" entry is set to a non-zero value.
57087 + All features enabled in the kernel configuration are disabled at boot
57088 + if you do not say Y to the "Turn on features by default" option.
57089 + All options should be set at startup, and the grsec_lock entry should
57090 + be set to a non-zero value after all the options are set.
57091 + *THIS IS EXTREMELY IMPORTANT*
57092 +
57093 +config GRKERNSEC_SYSCTL_DISTRO
57094 + bool "Extra sysctl support for distro makers (READ HELP)"
57095 + depends on GRKERNSEC_SYSCTL && GRKERNSEC_IO
57096 + help
57097 + If you say Y here, additional sysctl options will be created
57098 + for features that affect processes running as root. Therefore,
57099 + it is critical when using this option that the grsec_lock entry be
57100 + enabled after boot. Only distros with prebuilt kernel packages
57101 + with this option enabled that can ensure grsec_lock is enabled
57102 + after boot should use this option.
57103 + *Failure to set grsec_lock after boot makes all grsec features
57104 + this option covers useless*
57105 +
57106 + Currently this option creates the following sysctl entries:
57107 + "Disable Privileged I/O": "disable_priv_io"
57108 +
57109 +config GRKERNSEC_SYSCTL_ON
57110 + bool "Turn on features by default"
57111 + default y if GRKERNSEC_CONFIG_AUTO
57112 + depends on GRKERNSEC_SYSCTL
57113 + help
57114 + If you say Y here, instead of having all features enabled in the
57115 + kernel configuration disabled at boot time, the features will be
57116 + enabled at boot time. It is recommended you say Y here unless
57117 + there is some reason you would want all sysctl-tunable features to
57118 + be disabled by default. As mentioned elsewhere, it is important
57119 + to enable the grsec_lock entry once you have finished modifying
57120 + the sysctl entries.
57121 +
57122 +endmenu
57123 +menu "Logging Options"
57124 +depends on GRKERNSEC
57125 +
57126 +config GRKERNSEC_FLOODTIME
57127 + int "Seconds in between log messages (minimum)"
57128 + default 10
57129 + help
57130 + This option allows you to enforce the number of seconds between
57131 + grsecurity log messages. The default should be suitable for most
57132 + people, however, if you choose to change it, choose a value small enough
57133 + to allow informative logs to be produced, but large enough to
57134 + prevent flooding.
57135 +
57136 +config GRKERNSEC_FLOODBURST
57137 + int "Number of messages in a burst (maximum)"
57138 + default 6
57139 + help
57140 + This option allows you to choose the maximum number of messages allowed
57141 + within the flood time interval you chose in a separate option. The
57142 + default should be suitable for most people, however if you find that
57143 + many of your logs are being interpreted as flooding, you may want to
57144 + raise this value.
57145 +
57146 +endmenu
57147 diff --git a/grsecurity/Makefile b/grsecurity/Makefile
57148 new file mode 100644
57149 index 0000000..1b9afa9
57150 --- /dev/null
57151 +++ b/grsecurity/Makefile
57152 @@ -0,0 +1,38 @@
57153 +# grsecurity's ACL system was originally written in 2001 by Michael Dalton
57154 +# during 2001-2009 it has been completely redesigned by Brad Spengler
57155 +# into an RBAC system
57156 +#
57157 +# All code in this directory and various hooks inserted throughout the kernel
57158 +# are copyright Brad Spengler - Open Source Security, Inc., and released
57159 +# under the GPL v2 or higher
57160 +
57161 +KBUILD_CFLAGS += -Werror
57162 +
57163 +obj-y = grsec_chdir.o grsec_chroot.o grsec_exec.o grsec_fifo.o grsec_fork.o \
57164 + grsec_mount.o grsec_sig.o grsec_sysctl.o \
57165 + grsec_time.o grsec_tpe.o grsec_link.o grsec_pax.o grsec_ptrace.o
57166 +
57167 +obj-$(CONFIG_GRKERNSEC) += grsec_init.o grsum.o gracl.o gracl_segv.o \
57168 + gracl_cap.o gracl_alloc.o gracl_shm.o grsec_mem.o gracl_fs.o \
57169 + gracl_learn.o grsec_log.o
57170 +obj-$(CONFIG_GRKERNSEC_RESLOG) += gracl_res.o
57171 +
57172 +ifdef CONFIG_NET
57173 +obj-y += grsec_sock.o
57174 +obj-$(CONFIG_GRKERNSEC) += gracl_ip.o
57175 +endif
57176 +
57177 +ifndef CONFIG_GRKERNSEC
57178 +obj-y += grsec_disabled.o
57179 +endif
57180 +
57181 +ifdef CONFIG_GRKERNSEC_HIDESYM
57182 +extra-y := grsec_hidesym.o
57183 +$(obj)/grsec_hidesym.o:
57184 + @-chmod -f 500 /boot
57185 + @-chmod -f 500 /lib/modules
57186 + @-chmod -f 500 /lib64/modules
57187 + @-chmod -f 500 /lib32/modules
57188 + @-chmod -f 700 .
57189 + @echo ' grsec: protected kernel image paths'
57190 +endif
57191 diff --git a/grsecurity/gracl.c b/grsecurity/gracl.c
57192 new file mode 100644
57193 index 0000000..ab45812
57194 --- /dev/null
57195 +++ b/grsecurity/gracl.c
57196 @@ -0,0 +1,4071 @@
57197 +#include <linux/kernel.h>
57198 +#include <linux/module.h>
57199 +#include <linux/sched.h>
57200 +#include <linux/mm.h>
57201 +#include <linux/file.h>
57202 +#include <linux/fs.h>
57203 +#include <linux/namei.h>
57204 +#include <linux/mount.h>
57205 +#include <linux/tty.h>
57206 +#include <linux/proc_fs.h>
57207 +#include <linux/lglock.h>
57208 +#include <linux/slab.h>
57209 +#include <linux/vmalloc.h>
57210 +#include <linux/types.h>
57211 +#include <linux/sysctl.h>
57212 +#include <linux/netdevice.h>
57213 +#include <linux/ptrace.h>
57214 +#include <linux/gracl.h>
57215 +#include <linux/gralloc.h>
57216 +#include <linux/security.h>
57217 +#include <linux/grinternal.h>
57218 +#include <linux/pid_namespace.h>
57219 +#include <linux/stop_machine.h>
57220 +#include <linux/fdtable.h>
57221 +#include <linux/percpu.h>
57222 +#include <linux/lglock.h>
57223 +#include <linux/hugetlb.h>
57224 +#include <linux/posix-timers.h>
57225 +#include "../fs/mount.h"
57226 +
57227 +#include <asm/uaccess.h>
57228 +#include <asm/errno.h>
57229 +#include <asm/mman.h>
57230 +
57231 +extern struct lglock vfsmount_lock;
57232 +
57233 +static struct acl_role_db acl_role_set;
57234 +static struct name_db name_set;
57235 +static struct inodev_db inodev_set;
57236 +
57237 +/* for keeping track of userspace pointers used for subjects, so we
57238 + can share references in the kernel as well
57239 +*/
57240 +
57241 +static struct path real_root;
57242 +
57243 +static struct acl_subj_map_db subj_map_set;
57244 +
57245 +static struct acl_role_label *default_role;
57246 +
57247 +static struct acl_role_label *role_list;
57248 +
57249 +static u16 acl_sp_role_value;
57250 +
57251 +extern char *gr_shared_page[4];
57252 +static DEFINE_MUTEX(gr_dev_mutex);
57253 +DEFINE_RWLOCK(gr_inode_lock);
57254 +
57255 +struct gr_arg *gr_usermode;
57256 +
57257 +static unsigned int gr_status __read_only = GR_STATUS_INIT;
57258 +
57259 +extern int chkpw(struct gr_arg *entry, unsigned char *salt, unsigned char *sum);
57260 +extern void gr_clear_learn_entries(void);
57261 +
57262 +unsigned char *gr_system_salt;
57263 +unsigned char *gr_system_sum;
57264 +
57265 +static struct sprole_pw **acl_special_roles = NULL;
57266 +static __u16 num_sprole_pws = 0;
57267 +
57268 +static struct acl_role_label *kernel_role = NULL;
57269 +
57270 +static unsigned int gr_auth_attempts = 0;
57271 +static unsigned long gr_auth_expires = 0UL;
57272 +
57273 +#ifdef CONFIG_NET
57274 +extern struct vfsmount *sock_mnt;
57275 +#endif
57276 +
57277 +extern struct vfsmount *pipe_mnt;
57278 +extern struct vfsmount *shm_mnt;
57279 +
57280 +#ifdef CONFIG_HUGETLBFS
57281 +extern struct vfsmount *hugetlbfs_vfsmount[HUGE_MAX_HSTATE];
57282 +#endif
57283 +
57284 +static struct acl_object_label *fakefs_obj_rw;
57285 +static struct acl_object_label *fakefs_obj_rwx;
57286 +
57287 +extern int gr_init_uidset(void);
57288 +extern void gr_free_uidset(void);
57289 +extern void gr_remove_uid(uid_t uid);
57290 +extern int gr_find_uid(uid_t uid);
57291 +
57292 +__inline__ int
57293 +gr_acl_is_enabled(void)
57294 +{
57295 + return (gr_status & GR_READY);
57296 +}
57297 +
57298 +#ifdef CONFIG_BTRFS_FS
57299 +extern dev_t get_btrfs_dev_from_inode(struct inode *inode);
57300 +extern int btrfs_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat);
57301 +#endif
57302 +
57303 +static inline dev_t __get_dev(const struct dentry *dentry)
57304 +{
57305 +#ifdef CONFIG_BTRFS_FS
57306 + if (dentry->d_inode->i_op && dentry->d_inode->i_op->getattr == &btrfs_getattr)
57307 + return get_btrfs_dev_from_inode(dentry->d_inode);
57308 + else
57309 +#endif
57310 + return dentry->d_inode->i_sb->s_dev;
57311 +}
57312 +
57313 +dev_t gr_get_dev_from_dentry(struct dentry *dentry)
57314 +{
57315 + return __get_dev(dentry);
57316 +}
57317 +
57318 +static char gr_task_roletype_to_char(struct task_struct *task)
57319 +{
57320 + switch (task->role->roletype &
57321 + (GR_ROLE_DEFAULT | GR_ROLE_USER | GR_ROLE_GROUP |
57322 + GR_ROLE_SPECIAL)) {
57323 + case GR_ROLE_DEFAULT:
57324 + return 'D';
57325 + case GR_ROLE_USER:
57326 + return 'U';
57327 + case GR_ROLE_GROUP:
57328 + return 'G';
57329 + case GR_ROLE_SPECIAL:
57330 + return 'S';
57331 + }
57332 +
57333 + return 'X';
57334 +}
57335 +
57336 +char gr_roletype_to_char(void)
57337 +{
57338 + return gr_task_roletype_to_char(current);
57339 +}
57340 +
57341 +__inline__ int
57342 +gr_acl_tpe_check(void)
57343 +{
57344 + if (unlikely(!(gr_status & GR_READY)))
57345 + return 0;
57346 + if (current->role->roletype & GR_ROLE_TPE)
57347 + return 1;
57348 + else
57349 + return 0;
57350 +}
57351 +
57352 +int
57353 +gr_handle_rawio(const struct inode *inode)
57354 +{
57355 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
57356 + if (inode && S_ISBLK(inode->i_mode) &&
57357 + grsec_enable_chroot_caps && proc_is_chrooted(current) &&
57358 + !capable(CAP_SYS_RAWIO))
57359 + return 1;
57360 +#endif
57361 + return 0;
57362 +}
57363 +
57364 +static int
57365 +gr_streq(const char *a, const char *b, const unsigned int lena, const unsigned int lenb)
57366 +{
57367 + if (likely(lena != lenb))
57368 + return 0;
57369 +
57370 + return !memcmp(a, b, lena);
57371 +}
57372 +
57373 +static int prepend(char **buffer, int *buflen, const char *str, int namelen)
57374 +{
57375 + *buflen -= namelen;
57376 + if (*buflen < 0)
57377 + return -ENAMETOOLONG;
57378 + *buffer -= namelen;
57379 + memcpy(*buffer, str, namelen);
57380 + return 0;
57381 +}
57382 +
57383 +static int prepend_name(char **buffer, int *buflen, struct qstr *name)
57384 +{
57385 + return prepend(buffer, buflen, name->name, name->len);
57386 +}
57387 +
57388 +static int prepend_path(const struct path *path, struct path *root,
57389 + char **buffer, int *buflen)
57390 +{
57391 + struct dentry *dentry = path->dentry;
57392 + struct vfsmount *vfsmnt = path->mnt;
57393 + struct mount *mnt = real_mount(vfsmnt);
57394 + bool slash = false;
57395 + int error = 0;
57396 +
57397 + while (dentry != root->dentry || vfsmnt != root->mnt) {
57398 + struct dentry * parent;
57399 +
57400 + if (dentry == vfsmnt->mnt_root || IS_ROOT(dentry)) {
57401 + /* Global root? */
57402 + if (!mnt_has_parent(mnt)) {
57403 + goto out;
57404 + }
57405 + dentry = mnt->mnt_mountpoint;
57406 + mnt = mnt->mnt_parent;
57407 + vfsmnt = &mnt->mnt;
57408 + continue;
57409 + }
57410 + parent = dentry->d_parent;
57411 + prefetch(parent);
57412 + spin_lock(&dentry->d_lock);
57413 + error = prepend_name(buffer, buflen, &dentry->d_name);
57414 + spin_unlock(&dentry->d_lock);
57415 + if (!error)
57416 + error = prepend(buffer, buflen, "/", 1);
57417 + if (error)
57418 + break;
57419 +
57420 + slash = true;
57421 + dentry = parent;
57422 + }
57423 +
57424 +out:
57425 + if (!error && !slash)
57426 + error = prepend(buffer, buflen, "/", 1);
57427 +
57428 + return error;
57429 +}
57430 +
57431 +/* this must be called with vfsmount_lock and rename_lock held */
57432 +
57433 +static char *__our_d_path(const struct path *path, struct path *root,
57434 + char *buf, int buflen)
57435 +{
57436 + char *res = buf + buflen;
57437 + int error;
57438 +
57439 + prepend(&res, &buflen, "\0", 1);
57440 + error = prepend_path(path, root, &res, &buflen);
57441 + if (error)
57442 + return ERR_PTR(error);
57443 +
57444 + return res;
57445 +}
57446 +
57447 +static char *
57448 +gen_full_path(struct path *path, struct path *root, char *buf, int buflen)
57449 +{
57450 + char *retval;
57451 +
57452 + retval = __our_d_path(path, root, buf, buflen);
57453 + if (unlikely(IS_ERR(retval)))
57454 + retval = strcpy(buf, "<path too long>");
57455 + else if (unlikely(retval[1] == '/' && retval[2] == '\0'))
57456 + retval[1] = '\0';
57457 +
57458 + return retval;
57459 +}
57460 +
57461 +static char *
57462 +__d_real_path(const struct dentry *dentry, const struct vfsmount *vfsmnt,
57463 + char *buf, int buflen)
57464 +{
57465 + struct path path;
57466 + char *res;
57467 +
57468 + path.dentry = (struct dentry *)dentry;
57469 + path.mnt = (struct vfsmount *)vfsmnt;
57470 +
57471 + /* we can use real_root.dentry, real_root.mnt, because this is only called
57472 + by the RBAC system */
57473 + res = gen_full_path(&path, &real_root, buf, buflen);
57474 +
57475 + return res;
57476 +}
57477 +
57478 +static char *
57479 +d_real_path(const struct dentry *dentry, const struct vfsmount *vfsmnt,
57480 + char *buf, int buflen)
57481 +{
57482 + char *res;
57483 + struct path path;
57484 + struct path root;
57485 + struct task_struct *reaper = init_pid_ns.child_reaper;
57486 +
57487 + path.dentry = (struct dentry *)dentry;
57488 + path.mnt = (struct vfsmount *)vfsmnt;
57489 +
57490 + /* we can't use real_root.dentry, real_root.mnt, because they belong only to the RBAC system */
57491 + get_fs_root(reaper->fs, &root);
57492 +
57493 + write_seqlock(&rename_lock);
57494 + br_read_lock(&vfsmount_lock);
57495 + res = gen_full_path(&path, &root, buf, buflen);
57496 + br_read_unlock(&vfsmount_lock);
57497 + write_sequnlock(&rename_lock);
57498 +
57499 + path_put(&root);
57500 + return res;
57501 +}
57502 +
57503 +static char *
57504 +gr_to_filename_rbac(const struct dentry *dentry, const struct vfsmount *mnt)
57505 +{
57506 + char *ret;
57507 + write_seqlock(&rename_lock);
57508 + br_read_lock(&vfsmount_lock);
57509 + ret = __d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0],smp_processor_id()),
57510 + PAGE_SIZE);
57511 + br_read_unlock(&vfsmount_lock);
57512 + write_sequnlock(&rename_lock);
57513 + return ret;
57514 +}
57515 +
57516 +static char *
57517 +gr_to_proc_filename_rbac(const struct dentry *dentry, const struct vfsmount *mnt)
57518 +{
57519 + char *ret;
57520 + char *buf;
57521 + int buflen;
57522 +
57523 + write_seqlock(&rename_lock);
57524 + br_read_lock(&vfsmount_lock);
57525 + buf = per_cpu_ptr(gr_shared_page[0], smp_processor_id());
57526 + ret = __d_real_path(dentry, mnt, buf, PAGE_SIZE - 6);
57527 + buflen = (int)(ret - buf);
57528 + if (buflen >= 5)
57529 + prepend(&ret, &buflen, "/proc", 5);
57530 + else
57531 + ret = strcpy(buf, "<path too long>");
57532 + br_read_unlock(&vfsmount_lock);
57533 + write_sequnlock(&rename_lock);
57534 + return ret;
57535 +}
57536 +
57537 +char *
57538 +gr_to_filename_nolock(const struct dentry *dentry, const struct vfsmount *mnt)
57539 +{
57540 + return __d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0],smp_processor_id()),
57541 + PAGE_SIZE);
57542 +}
57543 +
57544 +char *
57545 +gr_to_filename(const struct dentry *dentry, const struct vfsmount *mnt)
57546 +{
57547 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0], smp_processor_id()),
57548 + PAGE_SIZE);
57549 +}
57550 +
57551 +char *
57552 +gr_to_filename1(const struct dentry *dentry, const struct vfsmount *mnt)
57553 +{
57554 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[1], smp_processor_id()),
57555 + PAGE_SIZE);
57556 +}
57557 +
57558 +char *
57559 +gr_to_filename2(const struct dentry *dentry, const struct vfsmount *mnt)
57560 +{
57561 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[2], smp_processor_id()),
57562 + PAGE_SIZE);
57563 +}
57564 +
57565 +char *
57566 +gr_to_filename3(const struct dentry *dentry, const struct vfsmount *mnt)
57567 +{
57568 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[3], smp_processor_id()),
57569 + PAGE_SIZE);
57570 +}
57571 +
57572 +__inline__ __u32
57573 +to_gr_audit(const __u32 reqmode)
57574 +{
57575 + /* masks off auditable permission flags, then shifts them to create
57576 + auditing flags, and adds the special case of append auditing if
57577 + we're requesting write */
57578 + return (((reqmode & ~GR_AUDITS) << 10) | ((reqmode & GR_WRITE) ? GR_AUDIT_APPEND : 0));
57579 +}
57580 +
57581 +struct acl_subject_label *
57582 +lookup_subject_map(const struct acl_subject_label *userp)
57583 +{
57584 + unsigned int index = gr_shash(userp, subj_map_set.s_size);
57585 + struct subject_map *match;
57586 +
57587 + match = subj_map_set.s_hash[index];
57588 +
57589 + while (match && match->user != userp)
57590 + match = match->next;
57591 +
57592 + if (match != NULL)
57593 + return match->kernel;
57594 + else
57595 + return NULL;
57596 +}
57597 +
57598 +static void
57599 +insert_subj_map_entry(struct subject_map *subjmap)
57600 +{
57601 + unsigned int index = gr_shash(subjmap->user, subj_map_set.s_size);
57602 + struct subject_map **curr;
57603 +
57604 + subjmap->prev = NULL;
57605 +
57606 + curr = &subj_map_set.s_hash[index];
57607 + if (*curr != NULL)
57608 + (*curr)->prev = subjmap;
57609 +
57610 + subjmap->next = *curr;
57611 + *curr = subjmap;
57612 +
57613 + return;
57614 +}
57615 +
57616 +static struct acl_role_label *
57617 +lookup_acl_role_label(const struct task_struct *task, const uid_t uid,
57618 + const gid_t gid)
57619 +{
57620 + unsigned int index = gr_rhash(uid, GR_ROLE_USER, acl_role_set.r_size);
57621 + struct acl_role_label *match;
57622 + struct role_allowed_ip *ipp;
57623 + unsigned int x;
57624 + u32 curr_ip = task->signal->curr_ip;
57625 +
57626 + task->signal->saved_ip = curr_ip;
57627 +
57628 + match = acl_role_set.r_hash[index];
57629 +
57630 + while (match) {
57631 + if ((match->roletype & (GR_ROLE_DOMAIN | GR_ROLE_USER)) == (GR_ROLE_DOMAIN | GR_ROLE_USER)) {
57632 + for (x = 0; x < match->domain_child_num; x++) {
57633 + if (match->domain_children[x] == uid)
57634 + goto found;
57635 + }
57636 + } else if (match->uidgid == uid && match->roletype & GR_ROLE_USER)
57637 + break;
57638 + match = match->next;
57639 + }
57640 +found:
57641 + if (match == NULL) {
57642 + try_group:
57643 + index = gr_rhash(gid, GR_ROLE_GROUP, acl_role_set.r_size);
57644 + match = acl_role_set.r_hash[index];
57645 +
57646 + while (match) {
57647 + if ((match->roletype & (GR_ROLE_DOMAIN | GR_ROLE_GROUP)) == (GR_ROLE_DOMAIN | GR_ROLE_GROUP)) {
57648 + for (x = 0; x < match->domain_child_num; x++) {
57649 + if (match->domain_children[x] == gid)
57650 + goto found2;
57651 + }
57652 + } else if (match->uidgid == gid && match->roletype & GR_ROLE_GROUP)
57653 + break;
57654 + match = match->next;
57655 + }
57656 +found2:
57657 + if (match == NULL)
57658 + match = default_role;
57659 + if (match->allowed_ips == NULL)
57660 + return match;
57661 + else {
57662 + for (ipp = match->allowed_ips; ipp; ipp = ipp->next) {
57663 + if (likely
57664 + ((ntohl(curr_ip) & ipp->netmask) ==
57665 + (ntohl(ipp->addr) & ipp->netmask)))
57666 + return match;
57667 + }
57668 + match = default_role;
57669 + }
57670 + } else if (match->allowed_ips == NULL) {
57671 + return match;
57672 + } else {
57673 + for (ipp = match->allowed_ips; ipp; ipp = ipp->next) {
57674 + if (likely
57675 + ((ntohl(curr_ip) & ipp->netmask) ==
57676 + (ntohl(ipp->addr) & ipp->netmask)))
57677 + return match;
57678 + }
57679 + goto try_group;
57680 + }
57681 +
57682 + return match;
57683 +}
57684 +
57685 +struct acl_subject_label *
57686 +lookup_acl_subj_label(const ino_t ino, const dev_t dev,
57687 + const struct acl_role_label *role)
57688 +{
57689 + unsigned int index = gr_fhash(ino, dev, role->subj_hash_size);
57690 + struct acl_subject_label *match;
57691 +
57692 + match = role->subj_hash[index];
57693 +
57694 + while (match && (match->inode != ino || match->device != dev ||
57695 + (match->mode & GR_DELETED))) {
57696 + match = match->next;
57697 + }
57698 +
57699 + if (match && !(match->mode & GR_DELETED))
57700 + return match;
57701 + else
57702 + return NULL;
57703 +}
57704 +
57705 +struct acl_subject_label *
57706 +lookup_acl_subj_label_deleted(const ino_t ino, const dev_t dev,
57707 + const struct acl_role_label *role)
57708 +{
57709 + unsigned int index = gr_fhash(ino, dev, role->subj_hash_size);
57710 + struct acl_subject_label *match;
57711 +
57712 + match = role->subj_hash[index];
57713 +
57714 + while (match && (match->inode != ino || match->device != dev ||
57715 + !(match->mode & GR_DELETED))) {
57716 + match = match->next;
57717 + }
57718 +
57719 + if (match && (match->mode & GR_DELETED))
57720 + return match;
57721 + else
57722 + return NULL;
57723 +}
57724 +
57725 +static struct acl_object_label *
57726 +lookup_acl_obj_label(const ino_t ino, const dev_t dev,
57727 + const struct acl_subject_label *subj)
57728 +{
57729 + unsigned int index = gr_fhash(ino, dev, subj->obj_hash_size);
57730 + struct acl_object_label *match;
57731 +
57732 + match = subj->obj_hash[index];
57733 +
57734 + while (match && (match->inode != ino || match->device != dev ||
57735 + (match->mode & GR_DELETED))) {
57736 + match = match->next;
57737 + }
57738 +
57739 + if (match && !(match->mode & GR_DELETED))
57740 + return match;
57741 + else
57742 + return NULL;
57743 +}
57744 +
57745 +static struct acl_object_label *
57746 +lookup_acl_obj_label_create(const ino_t ino, const dev_t dev,
57747 + const struct acl_subject_label *subj)
57748 +{
57749 + unsigned int index = gr_fhash(ino, dev, subj->obj_hash_size);
57750 + struct acl_object_label *match;
57751 +
57752 + match = subj->obj_hash[index];
57753 +
57754 + while (match && (match->inode != ino || match->device != dev ||
57755 + !(match->mode & GR_DELETED))) {
57756 + match = match->next;
57757 + }
57758 +
57759 + if (match && (match->mode & GR_DELETED))
57760 + return match;
57761 +
57762 + match = subj->obj_hash[index];
57763 +
57764 + while (match && (match->inode != ino || match->device != dev ||
57765 + (match->mode & GR_DELETED))) {
57766 + match = match->next;
57767 + }
57768 +
57769 + if (match && !(match->mode & GR_DELETED))
57770 + return match;
57771 + else
57772 + return NULL;
57773 +}
57774 +
57775 +static struct name_entry *
57776 +lookup_name_entry(const char *name)
57777 +{
57778 + unsigned int len = strlen(name);
57779 + unsigned int key = full_name_hash(name, len);
57780 + unsigned int index = key % name_set.n_size;
57781 + struct name_entry *match;
57782 +
57783 + match = name_set.n_hash[index];
57784 +
57785 + while (match && (match->key != key || !gr_streq(match->name, name, match->len, len)))
57786 + match = match->next;
57787 +
57788 + return match;
57789 +}
57790 +
57791 +static struct name_entry *
57792 +lookup_name_entry_create(const char *name)
57793 +{
57794 + unsigned int len = strlen(name);
57795 + unsigned int key = full_name_hash(name, len);
57796 + unsigned int index = key % name_set.n_size;
57797 + struct name_entry *match;
57798 +
57799 + match = name_set.n_hash[index];
57800 +
57801 + while (match && (match->key != key || !gr_streq(match->name, name, match->len, len) ||
57802 + !match->deleted))
57803 + match = match->next;
57804 +
57805 + if (match && match->deleted)
57806 + return match;
57807 +
57808 + match = name_set.n_hash[index];
57809 +
57810 + while (match && (match->key != key || !gr_streq(match->name, name, match->len, len) ||
57811 + match->deleted))
57812 + match = match->next;
57813 +
57814 + if (match && !match->deleted)
57815 + return match;
57816 + else
57817 + return NULL;
57818 +}
57819 +
57820 +static struct inodev_entry *
57821 +lookup_inodev_entry(const ino_t ino, const dev_t dev)
57822 +{
57823 + unsigned int index = gr_fhash(ino, dev, inodev_set.i_size);
57824 + struct inodev_entry *match;
57825 +
57826 + match = inodev_set.i_hash[index];
57827 +
57828 + while (match && (match->nentry->inode != ino || match->nentry->device != dev))
57829 + match = match->next;
57830 +
57831 + return match;
57832 +}
57833 +
57834 +static void
57835 +insert_inodev_entry(struct inodev_entry *entry)
57836 +{
57837 + unsigned int index = gr_fhash(entry->nentry->inode, entry->nentry->device,
57838 + inodev_set.i_size);
57839 + struct inodev_entry **curr;
57840 +
57841 + entry->prev = NULL;
57842 +
57843 + curr = &inodev_set.i_hash[index];
57844 + if (*curr != NULL)
57845 + (*curr)->prev = entry;
57846 +
57847 + entry->next = *curr;
57848 + *curr = entry;
57849 +
57850 + return;
57851 +}
57852 +
57853 +static void
57854 +__insert_acl_role_label(struct acl_role_label *role, uid_t uidgid)
57855 +{
57856 + unsigned int index =
57857 + gr_rhash(uidgid, role->roletype & (GR_ROLE_USER | GR_ROLE_GROUP), acl_role_set.r_size);
57858 + struct acl_role_label **curr;
57859 + struct acl_role_label *tmp, *tmp2;
57860 +
57861 + curr = &acl_role_set.r_hash[index];
57862 +
57863 + /* simple case, slot is empty, just set it to our role */
57864 + if (*curr == NULL) {
57865 + *curr = role;
57866 + } else {
57867 + /* example:
57868 + 1 -> 2 -> 3 (adding 2 -> 3 to here)
57869 + 2 -> 3
57870 + */
57871 + /* first check to see if we can already be reached via this slot */
57872 + tmp = *curr;
57873 + while (tmp && tmp != role)
57874 + tmp = tmp->next;
57875 + if (tmp == role) {
57876 + /* we don't need to add ourselves to this slot's chain */
57877 + return;
57878 + }
57879 + /* we need to add ourselves to this chain, two cases */
57880 + if (role->next == NULL) {
57881 + /* simple case, append the current chain to our role */
57882 + role->next = *curr;
57883 + *curr = role;
57884 + } else {
57885 + /* 1 -> 2 -> 3 -> 4
57886 + 2 -> 3 -> 4
57887 + 3 -> 4 (adding 1 -> 2 -> 3 -> 4 to here)
57888 + */
57889 + /* trickier case: walk our role's chain until we find
57890 + the role for the start of the current slot's chain */
57891 + tmp = role;
57892 + tmp2 = *curr;
57893 + while (tmp->next && tmp->next != tmp2)
57894 + tmp = tmp->next;
57895 + if (tmp->next == tmp2) {
57896 + /* from example above, we found 3, so just
57897 + replace this slot's chain with ours */
57898 + *curr = role;
57899 + } else {
57900 + /* we didn't find a subset of our role's chain
57901 + in the current slot's chain, so append their
57902 + chain to ours, and set us as the first role in
57903 + the slot's chain
57904 +
57905 + we could fold this case with the case above,
57906 + but making it explicit for clarity
57907 + */
57908 + tmp->next = tmp2;
57909 + *curr = role;
57910 + }
57911 + }
57912 + }
57913 +
57914 + return;
57915 +}
57916 +
57917 +static void
57918 +insert_acl_role_label(struct acl_role_label *role)
57919 +{
57920 + int i;
57921 +
57922 + if (role_list == NULL) {
57923 + role_list = role;
57924 + role->prev = NULL;
57925 + } else {
57926 + role->prev = role_list;
57927 + role_list = role;
57928 + }
57929 +
57930 + /* used for hash chains */
57931 + role->next = NULL;
57932 +
57933 + if (role->roletype & GR_ROLE_DOMAIN) {
57934 + for (i = 0; i < role->domain_child_num; i++)
57935 + __insert_acl_role_label(role, role->domain_children[i]);
57936 + } else
57937 + __insert_acl_role_label(role, role->uidgid);
57938 +}
57939 +
57940 +static int
57941 +insert_name_entry(char *name, const ino_t inode, const dev_t device, __u8 deleted)
57942 +{
57943 + struct name_entry **curr, *nentry;
57944 + struct inodev_entry *ientry;
57945 + unsigned int len = strlen(name);
57946 + unsigned int key = full_name_hash(name, len);
57947 + unsigned int index = key % name_set.n_size;
57948 +
57949 + curr = &name_set.n_hash[index];
57950 +
57951 + while (*curr && ((*curr)->key != key || !gr_streq((*curr)->name, name, (*curr)->len, len)))
57952 + curr = &((*curr)->next);
57953 +
57954 + if (*curr != NULL)
57955 + return 1;
57956 +
57957 + nentry = acl_alloc(sizeof (struct name_entry));
57958 + if (nentry == NULL)
57959 + return 0;
57960 + ientry = acl_alloc(sizeof (struct inodev_entry));
57961 + if (ientry == NULL)
57962 + return 0;
57963 + ientry->nentry = nentry;
57964 +
57965 + nentry->key = key;
57966 + nentry->name = name;
57967 + nentry->inode = inode;
57968 + nentry->device = device;
57969 + nentry->len = len;
57970 + nentry->deleted = deleted;
57971 +
57972 + nentry->prev = NULL;
57973 + curr = &name_set.n_hash[index];
57974 + if (*curr != NULL)
57975 + (*curr)->prev = nentry;
57976 + nentry->next = *curr;
57977 + *curr = nentry;
57978 +
57979 + /* insert us into the table searchable by inode/dev */
57980 + insert_inodev_entry(ientry);
57981 +
57982 + return 1;
57983 +}
57984 +
57985 +static void
57986 +insert_acl_obj_label(struct acl_object_label *obj,
57987 + struct acl_subject_label *subj)
57988 +{
57989 + unsigned int index =
57990 + gr_fhash(obj->inode, obj->device, subj->obj_hash_size);
57991 + struct acl_object_label **curr;
57992 +
57993 +
57994 + obj->prev = NULL;
57995 +
57996 + curr = &subj->obj_hash[index];
57997 + if (*curr != NULL)
57998 + (*curr)->prev = obj;
57999 +
58000 + obj->next = *curr;
58001 + *curr = obj;
58002 +
58003 + return;
58004 +}
58005 +
58006 +static void
58007 +insert_acl_subj_label(struct acl_subject_label *obj,
58008 + struct acl_role_label *role)
58009 +{
58010 + unsigned int index = gr_fhash(obj->inode, obj->device, role->subj_hash_size);
58011 + struct acl_subject_label **curr;
58012 +
58013 + obj->prev = NULL;
58014 +
58015 + curr = &role->subj_hash[index];
58016 + if (*curr != NULL)
58017 + (*curr)->prev = obj;
58018 +
58019 + obj->next = *curr;
58020 + *curr = obj;
58021 +
58022 + return;
58023 +}
58024 +
58025 +/* allocating chained hash tables, so optimal size is where lambda ~ 1 */
58026 +
58027 +static void *
58028 +create_table(__u32 * len, int elementsize)
58029 +{
58030 + unsigned int table_sizes[] = {
58031 + 7, 13, 31, 61, 127, 251, 509, 1021, 2039, 4093, 8191, 16381,
58032 + 32749, 65521, 131071, 262139, 524287, 1048573, 2097143,
58033 + 4194301, 8388593, 16777213, 33554393, 67108859
58034 + };
58035 + void *newtable = NULL;
58036 + unsigned int pwr = 0;
58037 +
58038 + while ((pwr < ((sizeof (table_sizes) / sizeof (table_sizes[0])) - 1)) &&
58039 + table_sizes[pwr] <= *len)
58040 + pwr++;
58041 +
58042 + if (table_sizes[pwr] <= *len || (table_sizes[pwr] > ULONG_MAX / elementsize))
58043 + return newtable;
58044 +
58045 + if ((table_sizes[pwr] * elementsize) <= PAGE_SIZE)
58046 + newtable =
58047 + kmalloc(table_sizes[pwr] * elementsize, GFP_KERNEL);
58048 + else
58049 + newtable = vmalloc(table_sizes[pwr] * elementsize);
58050 +
58051 + *len = table_sizes[pwr];
58052 +
58053 + return newtable;
58054 +}
58055 +
58056 +static int
58057 +init_variables(const struct gr_arg *arg)
58058 +{
58059 + struct task_struct *reaper = init_pid_ns.child_reaper;
58060 + unsigned int stacksize;
58061 +
58062 + subj_map_set.s_size = arg->role_db.num_subjects;
58063 + acl_role_set.r_size = arg->role_db.num_roles + arg->role_db.num_domain_children;
58064 + name_set.n_size = arg->role_db.num_objects;
58065 + inodev_set.i_size = arg->role_db.num_objects;
58066 +
58067 + if (!subj_map_set.s_size || !acl_role_set.r_size ||
58068 + !name_set.n_size || !inodev_set.i_size)
58069 + return 1;
58070 +
58071 + if (!gr_init_uidset())
58072 + return 1;
58073 +
58074 + /* set up the stack that holds allocation info */
58075 +
58076 + stacksize = arg->role_db.num_pointers + 5;
58077 +
58078 + if (!acl_alloc_stack_init(stacksize))
58079 + return 1;
58080 +
58081 + /* grab reference for the real root dentry and vfsmount */
58082 + get_fs_root(reaper->fs, &real_root);
58083 +
58084 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
58085 + printk(KERN_ALERT "Obtained real root device=%d, inode=%lu\n", __get_dev(real_root.dentry), real_root.dentry->d_inode->i_ino);
58086 +#endif
58087 +
58088 + fakefs_obj_rw = acl_alloc(sizeof(struct acl_object_label));
58089 + if (fakefs_obj_rw == NULL)
58090 + return 1;
58091 + fakefs_obj_rw->mode = GR_FIND | GR_READ | GR_WRITE;
58092 +
58093 + fakefs_obj_rwx = acl_alloc(sizeof(struct acl_object_label));
58094 + if (fakefs_obj_rwx == NULL)
58095 + return 1;
58096 + fakefs_obj_rwx->mode = GR_FIND | GR_READ | GR_WRITE | GR_EXEC;
58097 +
58098 + subj_map_set.s_hash =
58099 + (struct subject_map **) create_table(&subj_map_set.s_size, sizeof(void *));
58100 + acl_role_set.r_hash =
58101 + (struct acl_role_label **) create_table(&acl_role_set.r_size, sizeof(void *));
58102 + name_set.n_hash = (struct name_entry **) create_table(&name_set.n_size, sizeof(void *));
58103 + inodev_set.i_hash =
58104 + (struct inodev_entry **) create_table(&inodev_set.i_size, sizeof(void *));
58105 +
58106 + if (!subj_map_set.s_hash || !acl_role_set.r_hash ||
58107 + !name_set.n_hash || !inodev_set.i_hash)
58108 + return 1;
58109 +
58110 + memset(subj_map_set.s_hash, 0,
58111 + sizeof(struct subject_map *) * subj_map_set.s_size);
58112 + memset(acl_role_set.r_hash, 0,
58113 + sizeof (struct acl_role_label *) * acl_role_set.r_size);
58114 + memset(name_set.n_hash, 0,
58115 + sizeof (struct name_entry *) * name_set.n_size);
58116 + memset(inodev_set.i_hash, 0,
58117 + sizeof (struct inodev_entry *) * inodev_set.i_size);
58118 +
58119 + return 0;
58120 +}
58121 +
58122 +/* free information not needed after startup
58123 + currently contains user->kernel pointer mappings for subjects
58124 +*/
58125 +
58126 +static void
58127 +free_init_variables(void)
58128 +{
58129 + __u32 i;
58130 +
58131 + if (subj_map_set.s_hash) {
58132 + for (i = 0; i < subj_map_set.s_size; i++) {
58133 + if (subj_map_set.s_hash[i]) {
58134 + kfree(subj_map_set.s_hash[i]);
58135 + subj_map_set.s_hash[i] = NULL;
58136 + }
58137 + }
58138 +
58139 + if ((subj_map_set.s_size * sizeof (struct subject_map *)) <=
58140 + PAGE_SIZE)
58141 + kfree(subj_map_set.s_hash);
58142 + else
58143 + vfree(subj_map_set.s_hash);
58144 + }
58145 +
58146 + return;
58147 +}
58148 +
58149 +static void
58150 +free_variables(void)
58151 +{
58152 + struct acl_subject_label *s;
58153 + struct acl_role_label *r;
58154 + struct task_struct *task, *task2;
58155 + unsigned int x;
58156 +
58157 + gr_clear_learn_entries();
58158 +
58159 + read_lock(&tasklist_lock);
58160 + do_each_thread(task2, task) {
58161 + task->acl_sp_role = 0;
58162 + task->acl_role_id = 0;
58163 + task->acl = NULL;
58164 + task->role = NULL;
58165 + } while_each_thread(task2, task);
58166 + read_unlock(&tasklist_lock);
58167 +
58168 + /* release the reference to the real root dentry and vfsmount */
58169 + path_put(&real_root);
58170 + memset(&real_root, 0, sizeof(real_root));
58171 +
58172 + /* free all object hash tables */
58173 +
58174 + FOR_EACH_ROLE_START(r)
58175 + if (r->subj_hash == NULL)
58176 + goto next_role;
58177 + FOR_EACH_SUBJECT_START(r, s, x)
58178 + if (s->obj_hash == NULL)
58179 + break;
58180 + if ((s->obj_hash_size * sizeof (struct acl_object_label *)) <= PAGE_SIZE)
58181 + kfree(s->obj_hash);
58182 + else
58183 + vfree(s->obj_hash);
58184 + FOR_EACH_SUBJECT_END(s, x)
58185 + FOR_EACH_NESTED_SUBJECT_START(r, s)
58186 + if (s->obj_hash == NULL)
58187 + break;
58188 + if ((s->obj_hash_size * sizeof (struct acl_object_label *)) <= PAGE_SIZE)
58189 + kfree(s->obj_hash);
58190 + else
58191 + vfree(s->obj_hash);
58192 + FOR_EACH_NESTED_SUBJECT_END(s)
58193 + if ((r->subj_hash_size * sizeof (struct acl_subject_label *)) <= PAGE_SIZE)
58194 + kfree(r->subj_hash);
58195 + else
58196 + vfree(r->subj_hash);
58197 + r->subj_hash = NULL;
58198 +next_role:
58199 + FOR_EACH_ROLE_END(r)
58200 +
58201 + acl_free_all();
58202 +
58203 + if (acl_role_set.r_hash) {
58204 + if ((acl_role_set.r_size * sizeof (struct acl_role_label *)) <=
58205 + PAGE_SIZE)
58206 + kfree(acl_role_set.r_hash);
58207 + else
58208 + vfree(acl_role_set.r_hash);
58209 + }
58210 + if (name_set.n_hash) {
58211 + if ((name_set.n_size * sizeof (struct name_entry *)) <=
58212 + PAGE_SIZE)
58213 + kfree(name_set.n_hash);
58214 + else
58215 + vfree(name_set.n_hash);
58216 + }
58217 +
58218 + if (inodev_set.i_hash) {
58219 + if ((inodev_set.i_size * sizeof (struct inodev_entry *)) <=
58220 + PAGE_SIZE)
58221 + kfree(inodev_set.i_hash);
58222 + else
58223 + vfree(inodev_set.i_hash);
58224 + }
58225 +
58226 + gr_free_uidset();
58227 +
58228 + memset(&name_set, 0, sizeof (struct name_db));
58229 + memset(&inodev_set, 0, sizeof (struct inodev_db));
58230 + memset(&acl_role_set, 0, sizeof (struct acl_role_db));
58231 + memset(&subj_map_set, 0, sizeof (struct acl_subj_map_db));
58232 +
58233 + default_role = NULL;
58234 + kernel_role = NULL;
58235 + role_list = NULL;
58236 +
58237 + return;
58238 +}
58239 +
58240 +static __u32
58241 +count_user_objs(struct acl_object_label *userp)
58242 +{
58243 + struct acl_object_label o_tmp;
58244 + __u32 num = 0;
58245 +
58246 + while (userp) {
58247 + if (copy_from_user(&o_tmp, userp,
58248 + sizeof (struct acl_object_label)))
58249 + break;
58250 +
58251 + userp = o_tmp.prev;
58252 + num++;
58253 + }
58254 +
58255 + return num;
58256 +}
58257 +
58258 +static struct acl_subject_label *
58259 +do_copy_user_subj(struct acl_subject_label *userp, struct acl_role_label *role, int *already_copied);
58260 +
58261 +static int
58262 +copy_user_glob(struct acl_object_label *obj)
58263 +{
58264 + struct acl_object_label *g_tmp, **guser;
58265 + unsigned int len;
58266 + char *tmp;
58267 +
58268 + if (obj->globbed == NULL)
58269 + return 0;
58270 +
58271 + guser = &obj->globbed;
58272 + while (*guser) {
58273 + g_tmp = (struct acl_object_label *)
58274 + acl_alloc(sizeof (struct acl_object_label));
58275 + if (g_tmp == NULL)
58276 + return -ENOMEM;
58277 +
58278 + if (copy_from_user(g_tmp, *guser,
58279 + sizeof (struct acl_object_label)))
58280 + return -EFAULT;
58281 +
58282 + len = strnlen_user(g_tmp->filename, PATH_MAX);
58283 +
58284 + if (!len || len >= PATH_MAX)
58285 + return -EINVAL;
58286 +
58287 + if ((tmp = (char *) acl_alloc(len)) == NULL)
58288 + return -ENOMEM;
58289 +
58290 + if (copy_from_user(tmp, g_tmp->filename, len))
58291 + return -EFAULT;
58292 + tmp[len-1] = '\0';
58293 + g_tmp->filename = tmp;
58294 +
58295 + *guser = g_tmp;
58296 + guser = &(g_tmp->next);
58297 + }
58298 +
58299 + return 0;
58300 +}
58301 +
58302 +static int
58303 +copy_user_objs(struct acl_object_label *userp, struct acl_subject_label *subj,
58304 + struct acl_role_label *role)
58305 +{
58306 + struct acl_object_label *o_tmp;
58307 + unsigned int len;
58308 + int ret;
58309 + char *tmp;
58310 +
58311 + while (userp) {
58312 + if ((o_tmp = (struct acl_object_label *)
58313 + acl_alloc(sizeof (struct acl_object_label))) == NULL)
58314 + return -ENOMEM;
58315 +
58316 + if (copy_from_user(o_tmp, userp,
58317 + sizeof (struct acl_object_label)))
58318 + return -EFAULT;
58319 +
58320 + userp = o_tmp->prev;
58321 +
58322 + len = strnlen_user(o_tmp->filename, PATH_MAX);
58323 +
58324 + if (!len || len >= PATH_MAX)
58325 + return -EINVAL;
58326 +
58327 + if ((tmp = (char *) acl_alloc(len)) == NULL)
58328 + return -ENOMEM;
58329 +
58330 + if (copy_from_user(tmp, o_tmp->filename, len))
58331 + return -EFAULT;
58332 + tmp[len-1] = '\0';
58333 + o_tmp->filename = tmp;
58334 +
58335 + insert_acl_obj_label(o_tmp, subj);
58336 + if (!insert_name_entry(o_tmp->filename, o_tmp->inode,
58337 + o_tmp->device, (o_tmp->mode & GR_DELETED) ? 1 : 0))
58338 + return -ENOMEM;
58339 +
58340 + ret = copy_user_glob(o_tmp);
58341 + if (ret)
58342 + return ret;
58343 +
58344 + if (o_tmp->nested) {
58345 + int already_copied;
58346 +
58347 + o_tmp->nested = do_copy_user_subj(o_tmp->nested, role, &already_copied);
58348 + if (IS_ERR(o_tmp->nested))
58349 + return PTR_ERR(o_tmp->nested);
58350 +
58351 + /* insert into nested subject list if we haven't copied this one yet
58352 + to prevent duplicate entries */
58353 + if (!already_copied) {
58354 + o_tmp->nested->next = role->hash->first;
58355 + role->hash->first = o_tmp->nested;
58356 + }
58357 + }
58358 + }
58359 +
58360 + return 0;
58361 +}
58362 +
58363 +static __u32
58364 +count_user_subjs(struct acl_subject_label *userp)
58365 +{
58366 + struct acl_subject_label s_tmp;
58367 + __u32 num = 0;
58368 +
58369 + while (userp) {
58370 + if (copy_from_user(&s_tmp, userp,
58371 + sizeof (struct acl_subject_label)))
58372 + break;
58373 +
58374 + userp = s_tmp.prev;
58375 + }
58376 +
58377 + return num;
58378 +}
58379 +
58380 +static int
58381 +copy_user_allowedips(struct acl_role_label *rolep)
58382 +{
58383 + struct role_allowed_ip *ruserip, *rtmp = NULL, *rlast;
58384 +
58385 + ruserip = rolep->allowed_ips;
58386 +
58387 + while (ruserip) {
58388 + rlast = rtmp;
58389 +
58390 + if ((rtmp = (struct role_allowed_ip *)
58391 + acl_alloc(sizeof (struct role_allowed_ip))) == NULL)
58392 + return -ENOMEM;
58393 +
58394 + if (copy_from_user(rtmp, ruserip,
58395 + sizeof (struct role_allowed_ip)))
58396 + return -EFAULT;
58397 +
58398 + ruserip = rtmp->prev;
58399 +
58400 + if (!rlast) {
58401 + rtmp->prev = NULL;
58402 + rolep->allowed_ips = rtmp;
58403 + } else {
58404 + rlast->next = rtmp;
58405 + rtmp->prev = rlast;
58406 + }
58407 +
58408 + if (!ruserip)
58409 + rtmp->next = NULL;
58410 + }
58411 +
58412 + return 0;
58413 +}
58414 +
58415 +static int
58416 +copy_user_transitions(struct acl_role_label *rolep)
58417 +{
58418 + struct role_transition *rusertp, *rtmp = NULL, *rlast;
58419 +
58420 + unsigned int len;
58421 + char *tmp;
58422 +
58423 + rusertp = rolep->transitions;
58424 +
58425 + while (rusertp) {
58426 + rlast = rtmp;
58427 +
58428 + if ((rtmp = (struct role_transition *)
58429 + acl_alloc(sizeof (struct role_transition))) == NULL)
58430 + return -ENOMEM;
58431 +
58432 + if (copy_from_user(rtmp, rusertp,
58433 + sizeof (struct role_transition)))
58434 + return -EFAULT;
58435 +
58436 + rusertp = rtmp->prev;
58437 +
58438 + len = strnlen_user(rtmp->rolename, GR_SPROLE_LEN);
58439 +
58440 + if (!len || len >= GR_SPROLE_LEN)
58441 + return -EINVAL;
58442 +
58443 + if ((tmp = (char *) acl_alloc(len)) == NULL)
58444 + return -ENOMEM;
58445 +
58446 + if (copy_from_user(tmp, rtmp->rolename, len))
58447 + return -EFAULT;
58448 + tmp[len-1] = '\0';
58449 + rtmp->rolename = tmp;
58450 +
58451 + if (!rlast) {
58452 + rtmp->prev = NULL;
58453 + rolep->transitions = rtmp;
58454 + } else {
58455 + rlast->next = rtmp;
58456 + rtmp->prev = rlast;
58457 + }
58458 +
58459 + if (!rusertp)
58460 + rtmp->next = NULL;
58461 + }
58462 +
58463 + return 0;
58464 +}
58465 +
58466 +static struct acl_subject_label *
58467 +do_copy_user_subj(struct acl_subject_label *userp, struct acl_role_label *role, int *already_copied)
58468 +{
58469 + struct acl_subject_label *s_tmp = NULL, *s_tmp2;
58470 + unsigned int len;
58471 + char *tmp;
58472 + __u32 num_objs;
58473 + struct acl_ip_label **i_tmp, *i_utmp2;
58474 + struct gr_hash_struct ghash;
58475 + struct subject_map *subjmap;
58476 + unsigned int i_num;
58477 + int err;
58478 +
58479 + if (already_copied != NULL)
58480 + *already_copied = 0;
58481 +
58482 + s_tmp = lookup_subject_map(userp);
58483 +
58484 + /* we've already copied this subject into the kernel, just return
58485 + the reference to it, and don't copy it over again
58486 + */
58487 + if (s_tmp) {
58488 + if (already_copied != NULL)
58489 + *already_copied = 1;
58490 + return(s_tmp);
58491 + }
58492 +
58493 + if ((s_tmp = (struct acl_subject_label *)
58494 + acl_alloc(sizeof (struct acl_subject_label))) == NULL)
58495 + return ERR_PTR(-ENOMEM);
58496 +
58497 + subjmap = (struct subject_map *)kmalloc(sizeof (struct subject_map), GFP_KERNEL);
58498 + if (subjmap == NULL)
58499 + return ERR_PTR(-ENOMEM);
58500 +
58501 + subjmap->user = userp;
58502 + subjmap->kernel = s_tmp;
58503 + insert_subj_map_entry(subjmap);
58504 +
58505 + if (copy_from_user(s_tmp, userp,
58506 + sizeof (struct acl_subject_label)))
58507 + return ERR_PTR(-EFAULT);
58508 +
58509 + len = strnlen_user(s_tmp->filename, PATH_MAX);
58510 +
58511 + if (!len || len >= PATH_MAX)
58512 + return ERR_PTR(-EINVAL);
58513 +
58514 + if ((tmp = (char *) acl_alloc(len)) == NULL)
58515 + return ERR_PTR(-ENOMEM);
58516 +
58517 + if (copy_from_user(tmp, s_tmp->filename, len))
58518 + return ERR_PTR(-EFAULT);
58519 + tmp[len-1] = '\0';
58520 + s_tmp->filename = tmp;
58521 +
58522 + if (!strcmp(s_tmp->filename, "/"))
58523 + role->root_label = s_tmp;
58524 +
58525 + if (copy_from_user(&ghash, s_tmp->hash, sizeof(struct gr_hash_struct)))
58526 + return ERR_PTR(-EFAULT);
58527 +
58528 + /* copy user and group transition tables */
58529 +
58530 + if (s_tmp->user_trans_num) {
58531 + uid_t *uidlist;
58532 +
58533 + uidlist = (uid_t *)acl_alloc_num(s_tmp->user_trans_num, sizeof(uid_t));
58534 + if (uidlist == NULL)
58535 + return ERR_PTR(-ENOMEM);
58536 + if (copy_from_user(uidlist, s_tmp->user_transitions, s_tmp->user_trans_num * sizeof(uid_t)))
58537 + return ERR_PTR(-EFAULT);
58538 +
58539 + s_tmp->user_transitions = uidlist;
58540 + }
58541 +
58542 + if (s_tmp->group_trans_num) {
58543 + gid_t *gidlist;
58544 +
58545 + gidlist = (gid_t *)acl_alloc_num(s_tmp->group_trans_num, sizeof(gid_t));
58546 + if (gidlist == NULL)
58547 + return ERR_PTR(-ENOMEM);
58548 + if (copy_from_user(gidlist, s_tmp->group_transitions, s_tmp->group_trans_num * sizeof(gid_t)))
58549 + return ERR_PTR(-EFAULT);
58550 +
58551 + s_tmp->group_transitions = gidlist;
58552 + }
58553 +
58554 + /* set up object hash table */
58555 + num_objs = count_user_objs(ghash.first);
58556 +
58557 + s_tmp->obj_hash_size = num_objs;
58558 + s_tmp->obj_hash =
58559 + (struct acl_object_label **)
58560 + create_table(&(s_tmp->obj_hash_size), sizeof(void *));
58561 +
58562 + if (!s_tmp->obj_hash)
58563 + return ERR_PTR(-ENOMEM);
58564 +
58565 + memset(s_tmp->obj_hash, 0,
58566 + s_tmp->obj_hash_size *
58567 + sizeof (struct acl_object_label *));
58568 +
58569 + /* add in objects */
58570 + err = copy_user_objs(ghash.first, s_tmp, role);
58571 +
58572 + if (err)
58573 + return ERR_PTR(err);
58574 +
58575 + /* set pointer for parent subject */
58576 + if (s_tmp->parent_subject) {
58577 + s_tmp2 = do_copy_user_subj(s_tmp->parent_subject, role, NULL);
58578 +
58579 + if (IS_ERR(s_tmp2))
58580 + return s_tmp2;
58581 +
58582 + s_tmp->parent_subject = s_tmp2;
58583 + }
58584 +
58585 + /* add in ip acls */
58586 +
58587 + if (!s_tmp->ip_num) {
58588 + s_tmp->ips = NULL;
58589 + goto insert;
58590 + }
58591 +
58592 + i_tmp =
58593 + (struct acl_ip_label **) acl_alloc_num(s_tmp->ip_num,
58594 + sizeof (struct acl_ip_label *));
58595 +
58596 + if (!i_tmp)
58597 + return ERR_PTR(-ENOMEM);
58598 +
58599 + for (i_num = 0; i_num < s_tmp->ip_num; i_num++) {
58600 + *(i_tmp + i_num) =
58601 + (struct acl_ip_label *)
58602 + acl_alloc(sizeof (struct acl_ip_label));
58603 + if (!*(i_tmp + i_num))
58604 + return ERR_PTR(-ENOMEM);
58605 +
58606 + if (copy_from_user
58607 + (&i_utmp2, s_tmp->ips + i_num,
58608 + sizeof (struct acl_ip_label *)))
58609 + return ERR_PTR(-EFAULT);
58610 +
58611 + if (copy_from_user
58612 + (*(i_tmp + i_num), i_utmp2,
58613 + sizeof (struct acl_ip_label)))
58614 + return ERR_PTR(-EFAULT);
58615 +
58616 + if ((*(i_tmp + i_num))->iface == NULL)
58617 + continue;
58618 +
58619 + len = strnlen_user((*(i_tmp + i_num))->iface, IFNAMSIZ);
58620 + if (!len || len >= IFNAMSIZ)
58621 + return ERR_PTR(-EINVAL);
58622 + tmp = acl_alloc(len);
58623 + if (tmp == NULL)
58624 + return ERR_PTR(-ENOMEM);
58625 + if (copy_from_user(tmp, (*(i_tmp + i_num))->iface, len))
58626 + return ERR_PTR(-EFAULT);
58627 + (*(i_tmp + i_num))->iface = tmp;
58628 + }
58629 +
58630 + s_tmp->ips = i_tmp;
58631 +
58632 +insert:
58633 + if (!insert_name_entry(s_tmp->filename, s_tmp->inode,
58634 + s_tmp->device, (s_tmp->mode & GR_DELETED) ? 1 : 0))
58635 + return ERR_PTR(-ENOMEM);
58636 +
58637 + return s_tmp;
58638 +}
58639 +
58640 +static int
58641 +copy_user_subjs(struct acl_subject_label *userp, struct acl_role_label *role)
58642 +{
58643 + struct acl_subject_label s_pre;
58644 + struct acl_subject_label * ret;
58645 + int err;
58646 +
58647 + while (userp) {
58648 + if (copy_from_user(&s_pre, userp,
58649 + sizeof (struct acl_subject_label)))
58650 + return -EFAULT;
58651 +
58652 + ret = do_copy_user_subj(userp, role, NULL);
58653 +
58654 + err = PTR_ERR(ret);
58655 + if (IS_ERR(ret))
58656 + return err;
58657 +
58658 + insert_acl_subj_label(ret, role);
58659 +
58660 + userp = s_pre.prev;
58661 + }
58662 +
58663 + return 0;
58664 +}
58665 +
58666 +static int
58667 +copy_user_acl(struct gr_arg *arg)
58668 +{
58669 + struct acl_role_label *r_tmp = NULL, **r_utmp, *r_utmp2;
58670 + struct acl_subject_label *subj_list;
58671 + struct sprole_pw *sptmp;
58672 + struct gr_hash_struct *ghash;
58673 + uid_t *domainlist;
58674 + unsigned int r_num;
58675 + unsigned int len;
58676 + char *tmp;
58677 + int err = 0;
58678 + __u16 i;
58679 + __u32 num_subjs;
58680 +
58681 + /* we need a default and kernel role */
58682 + if (arg->role_db.num_roles < 2)
58683 + return -EINVAL;
58684 +
58685 + /* copy special role authentication info from userspace */
58686 +
58687 + num_sprole_pws = arg->num_sprole_pws;
58688 + acl_special_roles = (struct sprole_pw **) acl_alloc_num(num_sprole_pws, sizeof(struct sprole_pw *));
58689 +
58690 + if (!acl_special_roles && num_sprole_pws)
58691 + return -ENOMEM;
58692 +
58693 + for (i = 0; i < num_sprole_pws; i++) {
58694 + sptmp = (struct sprole_pw *) acl_alloc(sizeof(struct sprole_pw));
58695 + if (!sptmp)
58696 + return -ENOMEM;
58697 + if (copy_from_user(sptmp, arg->sprole_pws + i,
58698 + sizeof (struct sprole_pw)))
58699 + return -EFAULT;
58700 +
58701 + len = strnlen_user(sptmp->rolename, GR_SPROLE_LEN);
58702 +
58703 + if (!len || len >= GR_SPROLE_LEN)
58704 + return -EINVAL;
58705 +
58706 + if ((tmp = (char *) acl_alloc(len)) == NULL)
58707 + return -ENOMEM;
58708 +
58709 + if (copy_from_user(tmp, sptmp->rolename, len))
58710 + return -EFAULT;
58711 +
58712 + tmp[len-1] = '\0';
58713 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
58714 + printk(KERN_ALERT "Copying special role %s\n", tmp);
58715 +#endif
58716 + sptmp->rolename = tmp;
58717 + acl_special_roles[i] = sptmp;
58718 + }
58719 +
58720 + r_utmp = (struct acl_role_label **) arg->role_db.r_table;
58721 +
58722 + for (r_num = 0; r_num < arg->role_db.num_roles; r_num++) {
58723 + r_tmp = acl_alloc(sizeof (struct acl_role_label));
58724 +
58725 + if (!r_tmp)
58726 + return -ENOMEM;
58727 +
58728 + if (copy_from_user(&r_utmp2, r_utmp + r_num,
58729 + sizeof (struct acl_role_label *)))
58730 + return -EFAULT;
58731 +
58732 + if (copy_from_user(r_tmp, r_utmp2,
58733 + sizeof (struct acl_role_label)))
58734 + return -EFAULT;
58735 +
58736 + len = strnlen_user(r_tmp->rolename, GR_SPROLE_LEN);
58737 +
58738 + if (!len || len >= PATH_MAX)
58739 + return -EINVAL;
58740 +
58741 + if ((tmp = (char *) acl_alloc(len)) == NULL)
58742 + return -ENOMEM;
58743 +
58744 + if (copy_from_user(tmp, r_tmp->rolename, len))
58745 + return -EFAULT;
58746 +
58747 + tmp[len-1] = '\0';
58748 + r_tmp->rolename = tmp;
58749 +
58750 + if (!strcmp(r_tmp->rolename, "default")
58751 + && (r_tmp->roletype & GR_ROLE_DEFAULT)) {
58752 + default_role = r_tmp;
58753 + } else if (!strcmp(r_tmp->rolename, ":::kernel:::")) {
58754 + kernel_role = r_tmp;
58755 + }
58756 +
58757 + if ((ghash = (struct gr_hash_struct *) acl_alloc(sizeof(struct gr_hash_struct))) == NULL)
58758 + return -ENOMEM;
58759 +
58760 + if (copy_from_user(ghash, r_tmp->hash, sizeof(struct gr_hash_struct)))
58761 + return -EFAULT;
58762 +
58763 + r_tmp->hash = ghash;
58764 +
58765 + num_subjs = count_user_subjs(r_tmp->hash->first);
58766 +
58767 + r_tmp->subj_hash_size = num_subjs;
58768 + r_tmp->subj_hash =
58769 + (struct acl_subject_label **)
58770 + create_table(&(r_tmp->subj_hash_size), sizeof(void *));
58771 +
58772 + if (!r_tmp->subj_hash)
58773 + return -ENOMEM;
58774 +
58775 + err = copy_user_allowedips(r_tmp);
58776 + if (err)
58777 + return err;
58778 +
58779 + /* copy domain info */
58780 + if (r_tmp->domain_children != NULL) {
58781 + domainlist = acl_alloc_num(r_tmp->domain_child_num, sizeof(uid_t));
58782 + if (domainlist == NULL)
58783 + return -ENOMEM;
58784 +
58785 + if (copy_from_user(domainlist, r_tmp->domain_children, r_tmp->domain_child_num * sizeof(uid_t)))
58786 + return -EFAULT;
58787 +
58788 + r_tmp->domain_children = domainlist;
58789 + }
58790 +
58791 + err = copy_user_transitions(r_tmp);
58792 + if (err)
58793 + return err;
58794 +
58795 + memset(r_tmp->subj_hash, 0,
58796 + r_tmp->subj_hash_size *
58797 + sizeof (struct acl_subject_label *));
58798 +
58799 + /* acquire the list of subjects, then NULL out
58800 + the list prior to parsing the subjects for this role,
58801 + as during this parsing the list is replaced with a list
58802 + of *nested* subjects for the role
58803 + */
58804 + subj_list = r_tmp->hash->first;
58805 +
58806 + /* set nested subject list to null */
58807 + r_tmp->hash->first = NULL;
58808 +
58809 + err = copy_user_subjs(subj_list, r_tmp);
58810 +
58811 + if (err)
58812 + return err;
58813 +
58814 + insert_acl_role_label(r_tmp);
58815 + }
58816 +
58817 + if (default_role == NULL || kernel_role == NULL)
58818 + return -EINVAL;
58819 +
58820 + return err;
58821 +}
58822 +
58823 +static int
58824 +gracl_init(struct gr_arg *args)
58825 +{
58826 + int error = 0;
58827 +
58828 + memcpy(gr_system_salt, args->salt, GR_SALT_LEN);
58829 + memcpy(gr_system_sum, args->sum, GR_SHA_LEN);
58830 +
58831 + if (init_variables(args)) {
58832 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_INITF_ACL_MSG, GR_VERSION);
58833 + error = -ENOMEM;
58834 + free_variables();
58835 + goto out;
58836 + }
58837 +
58838 + error = copy_user_acl(args);
58839 + free_init_variables();
58840 + if (error) {
58841 + free_variables();
58842 + goto out;
58843 + }
58844 +
58845 + if ((error = gr_set_acls(0))) {
58846 + free_variables();
58847 + goto out;
58848 + }
58849 +
58850 + pax_open_kernel();
58851 + gr_status |= GR_READY;
58852 + pax_close_kernel();
58853 +
58854 + out:
58855 + return error;
58856 +}
58857 +
58858 +/* derived from glibc fnmatch() 0: match, 1: no match*/
58859 +
58860 +static int
58861 +glob_match(const char *p, const char *n)
58862 +{
58863 + char c;
58864 +
58865 + while ((c = *p++) != '\0') {
58866 + switch (c) {
58867 + case '?':
58868 + if (*n == '\0')
58869 + return 1;
58870 + else if (*n == '/')
58871 + return 1;
58872 + break;
58873 + case '\\':
58874 + if (*n != c)
58875 + return 1;
58876 + break;
58877 + case '*':
58878 + for (c = *p++; c == '?' || c == '*'; c = *p++) {
58879 + if (*n == '/')
58880 + return 1;
58881 + else if (c == '?') {
58882 + if (*n == '\0')
58883 + return 1;
58884 + else
58885 + ++n;
58886 + }
58887 + }
58888 + if (c == '\0') {
58889 + return 0;
58890 + } else {
58891 + const char *endp;
58892 +
58893 + if ((endp = strchr(n, '/')) == NULL)
58894 + endp = n + strlen(n);
58895 +
58896 + if (c == '[') {
58897 + for (--p; n < endp; ++n)
58898 + if (!glob_match(p, n))
58899 + return 0;
58900 + } else if (c == '/') {
58901 + while (*n != '\0' && *n != '/')
58902 + ++n;
58903 + if (*n == '/' && !glob_match(p, n + 1))
58904 + return 0;
58905 + } else {
58906 + for (--p; n < endp; ++n)
58907 + if (*n == c && !glob_match(p, n))
58908 + return 0;
58909 + }
58910 +
58911 + return 1;
58912 + }
58913 + case '[':
58914 + {
58915 + int not;
58916 + char cold;
58917 +
58918 + if (*n == '\0' || *n == '/')
58919 + return 1;
58920 +
58921 + not = (*p == '!' || *p == '^');
58922 + if (not)
58923 + ++p;
58924 +
58925 + c = *p++;
58926 + for (;;) {
58927 + unsigned char fn = (unsigned char)*n;
58928 +
58929 + if (c == '\0')
58930 + return 1;
58931 + else {
58932 + if (c == fn)
58933 + goto matched;
58934 + cold = c;
58935 + c = *p++;
58936 +
58937 + if (c == '-' && *p != ']') {
58938 + unsigned char cend = *p++;
58939 +
58940 + if (cend == '\0')
58941 + return 1;
58942 +
58943 + if (cold <= fn && fn <= cend)
58944 + goto matched;
58945 +
58946 + c = *p++;
58947 + }
58948 + }
58949 +
58950 + if (c == ']')
58951 + break;
58952 + }
58953 + if (!not)
58954 + return 1;
58955 + break;
58956 + matched:
58957 + while (c != ']') {
58958 + if (c == '\0')
58959 + return 1;
58960 +
58961 + c = *p++;
58962 + }
58963 + if (not)
58964 + return 1;
58965 + }
58966 + break;
58967 + default:
58968 + if (c != *n)
58969 + return 1;
58970 + }
58971 +
58972 + ++n;
58973 + }
58974 +
58975 + if (*n == '\0')
58976 + return 0;
58977 +
58978 + if (*n == '/')
58979 + return 0;
58980 +
58981 + return 1;
58982 +}
58983 +
58984 +static struct acl_object_label *
58985 +chk_glob_label(struct acl_object_label *globbed,
58986 + const struct dentry *dentry, const struct vfsmount *mnt, char **path)
58987 +{
58988 + struct acl_object_label *tmp;
58989 +
58990 + if (*path == NULL)
58991 + *path = gr_to_filename_nolock(dentry, mnt);
58992 +
58993 + tmp = globbed;
58994 +
58995 + while (tmp) {
58996 + if (!glob_match(tmp->filename, *path))
58997 + return tmp;
58998 + tmp = tmp->next;
58999 + }
59000 +
59001 + return NULL;
59002 +}
59003 +
59004 +static struct acl_object_label *
59005 +__full_lookup(const struct dentry *orig_dentry, const struct vfsmount *orig_mnt,
59006 + const ino_t curr_ino, const dev_t curr_dev,
59007 + const struct acl_subject_label *subj, char **path, const int checkglob)
59008 +{
59009 + struct acl_subject_label *tmpsubj;
59010 + struct acl_object_label *retval;
59011 + struct acl_object_label *retval2;
59012 +
59013 + tmpsubj = (struct acl_subject_label *) subj;
59014 + read_lock(&gr_inode_lock);
59015 + do {
59016 + retval = lookup_acl_obj_label(curr_ino, curr_dev, tmpsubj);
59017 + if (retval) {
59018 + if (checkglob && retval->globbed) {
59019 + retval2 = chk_glob_label(retval->globbed, orig_dentry, orig_mnt, path);
59020 + if (retval2)
59021 + retval = retval2;
59022 + }
59023 + break;
59024 + }
59025 + } while ((tmpsubj = tmpsubj->parent_subject));
59026 + read_unlock(&gr_inode_lock);
59027 +
59028 + return retval;
59029 +}
59030 +
59031 +static __inline__ struct acl_object_label *
59032 +full_lookup(const struct dentry *orig_dentry, const struct vfsmount *orig_mnt,
59033 + struct dentry *curr_dentry,
59034 + const struct acl_subject_label *subj, char **path, const int checkglob)
59035 +{
59036 + int newglob = checkglob;
59037 + ino_t inode;
59038 + dev_t device;
59039 +
59040 + /* if we aren't checking a subdirectory of the original path yet, don't do glob checking
59041 + as we don't want a / * rule to match instead of the / object
59042 + don't do this for create lookups that call this function though, since they're looking up
59043 + on the parent and thus need globbing checks on all paths
59044 + */
59045 + if (orig_dentry == curr_dentry && newglob != GR_CREATE_GLOB)
59046 + newglob = GR_NO_GLOB;
59047 +
59048 + spin_lock(&curr_dentry->d_lock);
59049 + inode = curr_dentry->d_inode->i_ino;
59050 + device = __get_dev(curr_dentry);
59051 + spin_unlock(&curr_dentry->d_lock);
59052 +
59053 + return __full_lookup(orig_dentry, orig_mnt, inode, device, subj, path, newglob);
59054 +}
59055 +
59056 +#ifdef CONFIG_HUGETLBFS
59057 +static inline bool
59058 +is_hugetlbfs_mnt(const struct vfsmount *mnt)
59059 +{
59060 + int i;
59061 + for (i = 0; i < HUGE_MAX_HSTATE; i++) {
59062 + if (unlikely(hugetlbfs_vfsmount[i] == mnt))
59063 + return true;
59064 + }
59065 +
59066 + return false;
59067 +}
59068 +#endif
59069 +
59070 +static struct acl_object_label *
59071 +__chk_obj_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
59072 + const struct acl_subject_label *subj, char *path, const int checkglob)
59073 +{
59074 + struct dentry *dentry = (struct dentry *) l_dentry;
59075 + struct vfsmount *mnt = (struct vfsmount *) l_mnt;
59076 + struct mount *real_mnt = real_mount(mnt);
59077 + struct acl_object_label *retval;
59078 + struct dentry *parent;
59079 +
59080 + write_seqlock(&rename_lock);
59081 + br_read_lock(&vfsmount_lock);
59082 +
59083 + if (unlikely((mnt == shm_mnt && dentry->d_inode->i_nlink == 0) || mnt == pipe_mnt ||
59084 +#ifdef CONFIG_NET
59085 + mnt == sock_mnt ||
59086 +#endif
59087 +#ifdef CONFIG_HUGETLBFS
59088 + (is_hugetlbfs_mnt(mnt) && dentry->d_inode->i_nlink == 0) ||
59089 +#endif
59090 + /* ignore Eric Biederman */
59091 + IS_PRIVATE(l_dentry->d_inode))) {
59092 + retval = (subj->mode & GR_SHMEXEC) ? fakefs_obj_rwx : fakefs_obj_rw;
59093 + goto out;
59094 + }
59095 +
59096 + for (;;) {
59097 + if (dentry == real_root.dentry && mnt == real_root.mnt)
59098 + break;
59099 +
59100 + if (dentry == mnt->mnt_root || IS_ROOT(dentry)) {
59101 + if (!mnt_has_parent(real_mnt))
59102 + break;
59103 +
59104 + retval = full_lookup(l_dentry, l_mnt, dentry, subj, &path, checkglob);
59105 + if (retval != NULL)
59106 + goto out;
59107 +
59108 + dentry = real_mnt->mnt_mountpoint;
59109 + real_mnt = real_mnt->mnt_parent;
59110 + mnt = &real_mnt->mnt;
59111 + continue;
59112 + }
59113 +
59114 + parent = dentry->d_parent;
59115 + retval = full_lookup(l_dentry, l_mnt, dentry, subj, &path, checkglob);
59116 + if (retval != NULL)
59117 + goto out;
59118 +
59119 + dentry = parent;
59120 + }
59121 +
59122 + retval = full_lookup(l_dentry, l_mnt, dentry, subj, &path, checkglob);
59123 +
59124 + /* real_root is pinned so we don't have to hold a reference */
59125 + if (retval == NULL)
59126 + retval = full_lookup(l_dentry, l_mnt, real_root.dentry, subj, &path, checkglob);
59127 +out:
59128 + br_read_unlock(&vfsmount_lock);
59129 + write_sequnlock(&rename_lock);
59130 +
59131 + BUG_ON(retval == NULL);
59132 +
59133 + return retval;
59134 +}
59135 +
59136 +static __inline__ struct acl_object_label *
59137 +chk_obj_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
59138 + const struct acl_subject_label *subj)
59139 +{
59140 + char *path = NULL;
59141 + return __chk_obj_label(l_dentry, l_mnt, subj, path, GR_REG_GLOB);
59142 +}
59143 +
59144 +static __inline__ struct acl_object_label *
59145 +chk_obj_label_noglob(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
59146 + const struct acl_subject_label *subj)
59147 +{
59148 + char *path = NULL;
59149 + return __chk_obj_label(l_dentry, l_mnt, subj, path, GR_NO_GLOB);
59150 +}
59151 +
59152 +static __inline__ struct acl_object_label *
59153 +chk_obj_create_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
59154 + const struct acl_subject_label *subj, char *path)
59155 +{
59156 + return __chk_obj_label(l_dentry, l_mnt, subj, path, GR_CREATE_GLOB);
59157 +}
59158 +
59159 +static struct acl_subject_label *
59160 +chk_subj_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
59161 + const struct acl_role_label *role)
59162 +{
59163 + struct dentry *dentry = (struct dentry *) l_dentry;
59164 + struct vfsmount *mnt = (struct vfsmount *) l_mnt;
59165 + struct mount *real_mnt = real_mount(mnt);
59166 + struct acl_subject_label *retval;
59167 + struct dentry *parent;
59168 +
59169 + write_seqlock(&rename_lock);
59170 + br_read_lock(&vfsmount_lock);
59171 +
59172 + for (;;) {
59173 + if (dentry == real_root.dentry && mnt == real_root.mnt)
59174 + break;
59175 + if (dentry == mnt->mnt_root || IS_ROOT(dentry)) {
59176 + if (!mnt_has_parent(real_mnt))
59177 + break;
59178 +
59179 + spin_lock(&dentry->d_lock);
59180 + read_lock(&gr_inode_lock);
59181 + retval =
59182 + lookup_acl_subj_label(dentry->d_inode->i_ino,
59183 + __get_dev(dentry), role);
59184 + read_unlock(&gr_inode_lock);
59185 + spin_unlock(&dentry->d_lock);
59186 + if (retval != NULL)
59187 + goto out;
59188 +
59189 + dentry = real_mnt->mnt_mountpoint;
59190 + real_mnt = real_mnt->mnt_parent;
59191 + mnt = &real_mnt->mnt;
59192 + continue;
59193 + }
59194 +
59195 + spin_lock(&dentry->d_lock);
59196 + read_lock(&gr_inode_lock);
59197 + retval = lookup_acl_subj_label(dentry->d_inode->i_ino,
59198 + __get_dev(dentry), role);
59199 + read_unlock(&gr_inode_lock);
59200 + parent = dentry->d_parent;
59201 + spin_unlock(&dentry->d_lock);
59202 +
59203 + if (retval != NULL)
59204 + goto out;
59205 +
59206 + dentry = parent;
59207 + }
59208 +
59209 + spin_lock(&dentry->d_lock);
59210 + read_lock(&gr_inode_lock);
59211 + retval = lookup_acl_subj_label(dentry->d_inode->i_ino,
59212 + __get_dev(dentry), role);
59213 + read_unlock(&gr_inode_lock);
59214 + spin_unlock(&dentry->d_lock);
59215 +
59216 + if (unlikely(retval == NULL)) {
59217 + /* real_root is pinned, we don't need to hold a reference */
59218 + read_lock(&gr_inode_lock);
59219 + retval = lookup_acl_subj_label(real_root.dentry->d_inode->i_ino,
59220 + __get_dev(real_root.dentry), role);
59221 + read_unlock(&gr_inode_lock);
59222 + }
59223 +out:
59224 + br_read_unlock(&vfsmount_lock);
59225 + write_sequnlock(&rename_lock);
59226 +
59227 + BUG_ON(retval == NULL);
59228 +
59229 + return retval;
59230 +}
59231 +
59232 +static void
59233 +gr_log_learn(const struct dentry *dentry, const struct vfsmount *mnt, const __u32 mode)
59234 +{
59235 + struct task_struct *task = current;
59236 + const struct cred *cred = current_cred();
59237 +
59238 + security_learn(GR_LEARN_AUDIT_MSG, task->role->rolename, task->role->roletype,
59239 + GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), task->exec_file ? gr_to_filename1(task->exec_file->f_path.dentry,
59240 + task->exec_file->f_path.mnt) : task->acl->filename, task->acl->filename,
59241 + 1UL, 1UL, gr_to_filename(dentry, mnt), (unsigned long) mode, &task->signal->saved_ip);
59242 +
59243 + return;
59244 +}
59245 +
59246 +static void
59247 +gr_log_learn_uid_change(const kuid_t real, const kuid_t effective, const kuid_t fs)
59248 +{
59249 + struct task_struct *task = current;
59250 + const struct cred *cred = current_cred();
59251 +
59252 + security_learn(GR_ID_LEARN_MSG, task->role->rolename, task->role->roletype,
59253 + GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), task->exec_file ? gr_to_filename1(task->exec_file->f_path.dentry,
59254 + task->exec_file->f_path.mnt) : task->acl->filename, task->acl->filename,
59255 + 'u', GR_GLOBAL_UID(real), GR_GLOBAL_UID(effective), GR_GLOBAL_UID(fs), &task->signal->saved_ip);
59256 +
59257 + return;
59258 +}
59259 +
59260 +static void
59261 +gr_log_learn_gid_change(const kgid_t real, const kgid_t effective, const kgid_t fs)
59262 +{
59263 + struct task_struct *task = current;
59264 + const struct cred *cred = current_cred();
59265 +
59266 + security_learn(GR_ID_LEARN_MSG, task->role->rolename, task->role->roletype,
59267 + GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), task->exec_file ? gr_to_filename1(task->exec_file->f_path.dentry,
59268 + task->exec_file->f_path.mnt) : task->acl->filename, task->acl->filename,
59269 + 'g', GR_GLOBAL_GID(real), GR_GLOBAL_GID(effective), GR_GLOBAL_GID(fs), &task->signal->saved_ip);
59270 +
59271 + return;
59272 +}
59273 +
59274 +__u32
59275 +gr_search_file(const struct dentry * dentry, const __u32 mode,
59276 + const struct vfsmount * mnt)
59277 +{
59278 + __u32 retval = mode;
59279 + struct acl_subject_label *curracl;
59280 + struct acl_object_label *currobj;
59281 +
59282 + if (unlikely(!(gr_status & GR_READY)))
59283 + return (mode & ~GR_AUDITS);
59284 +
59285 + curracl = current->acl;
59286 +
59287 + currobj = chk_obj_label(dentry, mnt, curracl);
59288 + retval = currobj->mode & mode;
59289 +
59290 + /* if we're opening a specified transfer file for writing
59291 + (e.g. /dev/initctl), then transfer our role to init
59292 + */
59293 + if (unlikely(currobj->mode & GR_INIT_TRANSFER && retval & GR_WRITE &&
59294 + current->role->roletype & GR_ROLE_PERSIST)) {
59295 + struct task_struct *task = init_pid_ns.child_reaper;
59296 +
59297 + if (task->role != current->role) {
59298 + task->acl_sp_role = 0;
59299 + task->acl_role_id = current->acl_role_id;
59300 + task->role = current->role;
59301 + rcu_read_lock();
59302 + read_lock(&grsec_exec_file_lock);
59303 + gr_apply_subject_to_task(task);
59304 + read_unlock(&grsec_exec_file_lock);
59305 + rcu_read_unlock();
59306 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_INIT_TRANSFER_MSG);
59307 + }
59308 + }
59309 +
59310 + if (unlikely
59311 + ((curracl->mode & (GR_LEARN | GR_INHERITLEARN)) && !(mode & GR_NOPTRACE)
59312 + && (retval != (mode & ~(GR_AUDITS | GR_SUPPRESS))))) {
59313 + __u32 new_mode = mode;
59314 +
59315 + new_mode &= ~(GR_AUDITS | GR_SUPPRESS);
59316 +
59317 + retval = new_mode;
59318 +
59319 + if (new_mode & GR_EXEC && curracl->mode & GR_INHERITLEARN)
59320 + new_mode |= GR_INHERIT;
59321 +
59322 + if (!(mode & GR_NOLEARN))
59323 + gr_log_learn(dentry, mnt, new_mode);
59324 + }
59325 +
59326 + return retval;
59327 +}
59328 +
59329 +struct acl_object_label *gr_get_create_object(const struct dentry *new_dentry,
59330 + const struct dentry *parent,
59331 + const struct vfsmount *mnt)
59332 +{
59333 + struct name_entry *match;
59334 + struct acl_object_label *matchpo;
59335 + struct acl_subject_label *curracl;
59336 + char *path;
59337 +
59338 + if (unlikely(!(gr_status & GR_READY)))
59339 + return NULL;
59340 +
59341 + preempt_disable();
59342 + path = gr_to_filename_rbac(new_dentry, mnt);
59343 + match = lookup_name_entry_create(path);
59344 +
59345 + curracl = current->acl;
59346 +
59347 + if (match) {
59348 + read_lock(&gr_inode_lock);
59349 + matchpo = lookup_acl_obj_label_create(match->inode, match->device, curracl);
59350 + read_unlock(&gr_inode_lock);
59351 +
59352 + if (matchpo) {
59353 + preempt_enable();
59354 + return matchpo;
59355 + }
59356 + }
59357 +
59358 + // lookup parent
59359 +
59360 + matchpo = chk_obj_create_label(parent, mnt, curracl, path);
59361 +
59362 + preempt_enable();
59363 + return matchpo;
59364 +}
59365 +
59366 +__u32
59367 +gr_check_create(const struct dentry * new_dentry, const struct dentry * parent,
59368 + const struct vfsmount * mnt, const __u32 mode)
59369 +{
59370 + struct acl_object_label *matchpo;
59371 + __u32 retval;
59372 +
59373 + if (unlikely(!(gr_status & GR_READY)))
59374 + return (mode & ~GR_AUDITS);
59375 +
59376 + matchpo = gr_get_create_object(new_dentry, parent, mnt);
59377 +
59378 + retval = matchpo->mode & mode;
59379 +
59380 + if ((retval != (mode & ~(GR_AUDITS | GR_SUPPRESS)))
59381 + && (current->acl->mode & (GR_LEARN | GR_INHERITLEARN))) {
59382 + __u32 new_mode = mode;
59383 +
59384 + new_mode &= ~(GR_AUDITS | GR_SUPPRESS);
59385 +
59386 + gr_log_learn(new_dentry, mnt, new_mode);
59387 + return new_mode;
59388 + }
59389 +
59390 + return retval;
59391 +}
59392 +
59393 +__u32
59394 +gr_check_link(const struct dentry * new_dentry,
59395 + const struct dentry * parent_dentry,
59396 + const struct vfsmount * parent_mnt,
59397 + const struct dentry * old_dentry, const struct vfsmount * old_mnt)
59398 +{
59399 + struct acl_object_label *obj;
59400 + __u32 oldmode, newmode;
59401 + __u32 needmode;
59402 + __u32 checkmodes = GR_FIND | GR_APPEND | GR_WRITE | GR_EXEC | GR_SETID | GR_READ |
59403 + GR_DELETE | GR_INHERIT;
59404 +
59405 + if (unlikely(!(gr_status & GR_READY)))
59406 + return (GR_CREATE | GR_LINK);
59407 +
59408 + obj = chk_obj_label(old_dentry, old_mnt, current->acl);
59409 + oldmode = obj->mode;
59410 +
59411 + obj = gr_get_create_object(new_dentry, parent_dentry, parent_mnt);
59412 + newmode = obj->mode;
59413 +
59414 + needmode = newmode & checkmodes;
59415 +
59416 + // old name for hardlink must have at least the permissions of the new name
59417 + if ((oldmode & needmode) != needmode)
59418 + goto bad;
59419 +
59420 + // if old name had restrictions/auditing, make sure the new name does as well
59421 + needmode = oldmode & (GR_NOPTRACE | GR_PTRACERD | GR_INHERIT | GR_AUDITS);
59422 +
59423 + // don't allow hardlinking of suid/sgid/fcapped files without permission
59424 + if (is_privileged_binary(old_dentry))
59425 + needmode |= GR_SETID;
59426 +
59427 + if ((newmode & needmode) != needmode)
59428 + goto bad;
59429 +
59430 + // enforce minimum permissions
59431 + if ((newmode & (GR_CREATE | GR_LINK)) == (GR_CREATE | GR_LINK))
59432 + return newmode;
59433 +bad:
59434 + needmode = oldmode;
59435 + if (is_privileged_binary(old_dentry))
59436 + needmode |= GR_SETID;
59437 +
59438 + if (current->acl->mode & (GR_LEARN | GR_INHERITLEARN)) {
59439 + gr_log_learn(old_dentry, old_mnt, needmode | GR_CREATE | GR_LINK);
59440 + return (GR_CREATE | GR_LINK);
59441 + } else if (newmode & GR_SUPPRESS)
59442 + return GR_SUPPRESS;
59443 + else
59444 + return 0;
59445 +}
59446 +
59447 +int
59448 +gr_check_hidden_task(const struct task_struct *task)
59449 +{
59450 + if (unlikely(!(gr_status & GR_READY)))
59451 + return 0;
59452 +
59453 + if (!(task->acl->mode & GR_PROCFIND) && !(current->acl->mode & GR_VIEW))
59454 + return 1;
59455 +
59456 + return 0;
59457 +}
59458 +
59459 +int
59460 +gr_check_protected_task(const struct task_struct *task)
59461 +{
59462 + if (unlikely(!(gr_status & GR_READY) || !task))
59463 + return 0;
59464 +
59465 + if ((task->acl->mode & GR_PROTECTED) && !(current->acl->mode & GR_KILL) &&
59466 + task->acl != current->acl)
59467 + return 1;
59468 +
59469 + return 0;
59470 +}
59471 +
59472 +int
59473 +gr_check_protected_task_fowner(struct pid *pid, enum pid_type type)
59474 +{
59475 + struct task_struct *p;
59476 + int ret = 0;
59477 +
59478 + if (unlikely(!(gr_status & GR_READY) || !pid))
59479 + return ret;
59480 +
59481 + read_lock(&tasklist_lock);
59482 + do_each_pid_task(pid, type, p) {
59483 + if ((p->acl->mode & GR_PROTECTED) && !(current->acl->mode & GR_KILL) &&
59484 + p->acl != current->acl) {
59485 + ret = 1;
59486 + goto out;
59487 + }
59488 + } while_each_pid_task(pid, type, p);
59489 +out:
59490 + read_unlock(&tasklist_lock);
59491 +
59492 + return ret;
59493 +}
59494 +
59495 +void
59496 +gr_copy_label(struct task_struct *tsk)
59497 +{
59498 + tsk->signal->used_accept = 0;
59499 + tsk->acl_sp_role = 0;
59500 + tsk->acl_role_id = current->acl_role_id;
59501 + tsk->acl = current->acl;
59502 + tsk->role = current->role;
59503 + tsk->signal->curr_ip = current->signal->curr_ip;
59504 + tsk->signal->saved_ip = current->signal->saved_ip;
59505 + if (current->exec_file)
59506 + get_file(current->exec_file);
59507 + tsk->exec_file = current->exec_file;
59508 + tsk->is_writable = current->is_writable;
59509 + if (unlikely(current->signal->used_accept)) {
59510 + current->signal->curr_ip = 0;
59511 + current->signal->saved_ip = 0;
59512 + }
59513 +
59514 + return;
59515 +}
59516 +
59517 +static void
59518 +gr_set_proc_res(struct task_struct *task)
59519 +{
59520 + struct acl_subject_label *proc;
59521 + unsigned short i;
59522 +
59523 + proc = task->acl;
59524 +
59525 + if (proc->mode & (GR_LEARN | GR_INHERITLEARN))
59526 + return;
59527 +
59528 + for (i = 0; i < RLIM_NLIMITS; i++) {
59529 + if (!(proc->resmask & (1 << i)))
59530 + continue;
59531 +
59532 + task->signal->rlim[i].rlim_cur = proc->res[i].rlim_cur;
59533 + task->signal->rlim[i].rlim_max = proc->res[i].rlim_max;
59534 +
59535 + if (i == RLIMIT_CPU)
59536 + update_rlimit_cpu(task, proc->res[i].rlim_cur);
59537 + }
59538 +
59539 + return;
59540 +}
59541 +
59542 +extern int __gr_process_user_ban(struct user_struct *user);
59543 +
59544 +int
59545 +gr_check_user_change(kuid_t real, kuid_t effective, kuid_t fs)
59546 +{
59547 + unsigned int i;
59548 + __u16 num;
59549 + uid_t *uidlist;
59550 + uid_t curuid;
59551 + int realok = 0;
59552 + int effectiveok = 0;
59553 + int fsok = 0;
59554 + uid_t globalreal, globaleffective, globalfs;
59555 +
59556 +#if defined(CONFIG_GRKERNSEC_KERN_LOCKOUT) || defined(CONFIG_GRKERNSEC_BRUTE)
59557 + struct user_struct *user;
59558 +
59559 + if (!uid_valid(real))
59560 + goto skipit;
59561 +
59562 + /* find user based on global namespace */
59563 +
59564 + globalreal = GR_GLOBAL_UID(real);
59565 +
59566 + user = find_user(make_kuid(&init_user_ns, globalreal));
59567 + if (user == NULL)
59568 + goto skipit;
59569 +
59570 + if (__gr_process_user_ban(user)) {
59571 + /* for find_user */
59572 + free_uid(user);
59573 + return 1;
59574 + }
59575 +
59576 + /* for find_user */
59577 + free_uid(user);
59578 +
59579 +skipit:
59580 +#endif
59581 +
59582 + if (unlikely(!(gr_status & GR_READY)))
59583 + return 0;
59584 +
59585 + if (current->acl->mode & (GR_LEARN | GR_INHERITLEARN))
59586 + gr_log_learn_uid_change(real, effective, fs);
59587 +
59588 + num = current->acl->user_trans_num;
59589 + uidlist = current->acl->user_transitions;
59590 +
59591 + if (uidlist == NULL)
59592 + return 0;
59593 +
59594 + if (!uid_valid(real)) {
59595 + realok = 1;
59596 + globalreal = (uid_t)-1;
59597 + } else {
59598 + globalreal = GR_GLOBAL_UID(real);
59599 + }
59600 + if (!uid_valid(effective)) {
59601 + effectiveok = 1;
59602 + globaleffective = (uid_t)-1;
59603 + } else {
59604 + globaleffective = GR_GLOBAL_UID(effective);
59605 + }
59606 + if (!uid_valid(fs)) {
59607 + fsok = 1;
59608 + globalfs = (uid_t)-1;
59609 + } else {
59610 + globalfs = GR_GLOBAL_UID(fs);
59611 + }
59612 +
59613 + if (current->acl->user_trans_type & GR_ID_ALLOW) {
59614 + for (i = 0; i < num; i++) {
59615 + curuid = uidlist[i];
59616 + if (globalreal == curuid)
59617 + realok = 1;
59618 + if (globaleffective == curuid)
59619 + effectiveok = 1;
59620 + if (globalfs == curuid)
59621 + fsok = 1;
59622 + }
59623 + } else if (current->acl->user_trans_type & GR_ID_DENY) {
59624 + for (i = 0; i < num; i++) {
59625 + curuid = uidlist[i];
59626 + if (globalreal == curuid)
59627 + break;
59628 + if (globaleffective == curuid)
59629 + break;
59630 + if (globalfs == curuid)
59631 + break;
59632 + }
59633 + /* not in deny list */
59634 + if (i == num) {
59635 + realok = 1;
59636 + effectiveok = 1;
59637 + fsok = 1;
59638 + }
59639 + }
59640 +
59641 + if (realok && effectiveok && fsok)
59642 + return 0;
59643 + else {
59644 + gr_log_int(GR_DONT_AUDIT, GR_USRCHANGE_ACL_MSG, realok ? (effectiveok ? (fsok ? 0 : globalfs) : globaleffective) : globalreal);
59645 + return 1;
59646 + }
59647 +}
59648 +
59649 +int
59650 +gr_check_group_change(kgid_t real, kgid_t effective, kgid_t fs)
59651 +{
59652 + unsigned int i;
59653 + __u16 num;
59654 + gid_t *gidlist;
59655 + gid_t curgid;
59656 + int realok = 0;
59657 + int effectiveok = 0;
59658 + int fsok = 0;
59659 + gid_t globalreal, globaleffective, globalfs;
59660 +
59661 + if (unlikely(!(gr_status & GR_READY)))
59662 + return 0;
59663 +
59664 + if (current->acl->mode & (GR_LEARN | GR_INHERITLEARN))
59665 + gr_log_learn_gid_change(real, effective, fs);
59666 +
59667 + num = current->acl->group_trans_num;
59668 + gidlist = current->acl->group_transitions;
59669 +
59670 + if (gidlist == NULL)
59671 + return 0;
59672 +
59673 + if (!gid_valid(real)) {
59674 + realok = 1;
59675 + globalreal = (gid_t)-1;
59676 + } else {
59677 + globalreal = GR_GLOBAL_GID(real);
59678 + }
59679 + if (!gid_valid(effective)) {
59680 + effectiveok = 1;
59681 + globaleffective = (gid_t)-1;
59682 + } else {
59683 + globaleffective = GR_GLOBAL_GID(effective);
59684 + }
59685 + if (!gid_valid(fs)) {
59686 + fsok = 1;
59687 + globalfs = (gid_t)-1;
59688 + } else {
59689 + globalfs = GR_GLOBAL_GID(fs);
59690 + }
59691 +
59692 + if (current->acl->group_trans_type & GR_ID_ALLOW) {
59693 + for (i = 0; i < num; i++) {
59694 + curgid = gidlist[i];
59695 + if (globalreal == curgid)
59696 + realok = 1;
59697 + if (globaleffective == curgid)
59698 + effectiveok = 1;
59699 + if (globalfs == curgid)
59700 + fsok = 1;
59701 + }
59702 + } else if (current->acl->group_trans_type & GR_ID_DENY) {
59703 + for (i = 0; i < num; i++) {
59704 + curgid = gidlist[i];
59705 + if (globalreal == curgid)
59706 + break;
59707 + if (globaleffective == curgid)
59708 + break;
59709 + if (globalfs == curgid)
59710 + break;
59711 + }
59712 + /* not in deny list */
59713 + if (i == num) {
59714 + realok = 1;
59715 + effectiveok = 1;
59716 + fsok = 1;
59717 + }
59718 + }
59719 +
59720 + if (realok && effectiveok && fsok)
59721 + return 0;
59722 + else {
59723 + gr_log_int(GR_DONT_AUDIT, GR_GRPCHANGE_ACL_MSG, realok ? (effectiveok ? (fsok ? 0 : globalfs) : globaleffective) : globalreal);
59724 + return 1;
59725 + }
59726 +}
59727 +
59728 +extern int gr_acl_is_capable(const int cap);
59729 +
59730 +void
59731 +gr_set_role_label(struct task_struct *task, const kuid_t kuid, const kgid_t kgid)
59732 +{
59733 + struct acl_role_label *role = task->role;
59734 + struct acl_subject_label *subj = NULL;
59735 + struct acl_object_label *obj;
59736 + struct file *filp;
59737 + uid_t uid;
59738 + gid_t gid;
59739 +
59740 + if (unlikely(!(gr_status & GR_READY)))
59741 + return;
59742 +
59743 + uid = GR_GLOBAL_UID(kuid);
59744 + gid = GR_GLOBAL_GID(kgid);
59745 +
59746 + filp = task->exec_file;
59747 +
59748 + /* kernel process, we'll give them the kernel role */
59749 + if (unlikely(!filp)) {
59750 + task->role = kernel_role;
59751 + task->acl = kernel_role->root_label;
59752 + return;
59753 + } else if (!task->role || !(task->role->roletype & GR_ROLE_SPECIAL))
59754 + role = lookup_acl_role_label(task, uid, gid);
59755 +
59756 + /* don't change the role if we're not a privileged process */
59757 + if (role && task->role != role &&
59758 + (((role->roletype & GR_ROLE_USER) && !gr_acl_is_capable(CAP_SETUID)) ||
59759 + ((role->roletype & GR_ROLE_GROUP) && !gr_acl_is_capable(CAP_SETGID))))
59760 + return;
59761 +
59762 + /* perform subject lookup in possibly new role
59763 + we can use this result below in the case where role == task->role
59764 + */
59765 + subj = chk_subj_label(filp->f_path.dentry, filp->f_path.mnt, role);
59766 +
59767 + /* if we changed uid/gid, but result in the same role
59768 + and are using inheritance, don't lose the inherited subject
59769 + if current subject is other than what normal lookup
59770 + would result in, we arrived via inheritance, don't
59771 + lose subject
59772 + */
59773 + if (role != task->role || (!(task->acl->mode & GR_INHERITLEARN) &&
59774 + (subj == task->acl)))
59775 + task->acl = subj;
59776 +
59777 + task->role = role;
59778 +
59779 + task->is_writable = 0;
59780 +
59781 + /* ignore additional mmap checks for processes that are writable
59782 + by the default ACL */
59783 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, default_role->root_label);
59784 + if (unlikely(obj->mode & GR_WRITE))
59785 + task->is_writable = 1;
59786 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, task->role->root_label);
59787 + if (unlikely(obj->mode & GR_WRITE))
59788 + task->is_writable = 1;
59789 +
59790 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
59791 + 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);
59792 +#endif
59793 +
59794 + gr_set_proc_res(task);
59795 +
59796 + return;
59797 +}
59798 +
59799 +int
59800 +gr_set_proc_label(const struct dentry *dentry, const struct vfsmount *mnt,
59801 + const int unsafe_flags)
59802 +{
59803 + struct task_struct *task = current;
59804 + struct acl_subject_label *newacl;
59805 + struct acl_object_label *obj;
59806 + __u32 retmode;
59807 +
59808 + if (unlikely(!(gr_status & GR_READY)))
59809 + return 0;
59810 +
59811 + newacl = chk_subj_label(dentry, mnt, task->role);
59812 +
59813 + /* special handling for if we did an strace -f -p <pid> from an admin role, where pid then
59814 + did an exec
59815 + */
59816 + rcu_read_lock();
59817 + read_lock(&tasklist_lock);
59818 + if (task->ptrace && task->parent && ((task->parent->role->roletype & GR_ROLE_GOD) ||
59819 + (task->parent->acl->mode & GR_POVERRIDE))) {
59820 + read_unlock(&tasklist_lock);
59821 + rcu_read_unlock();
59822 + goto skip_check;
59823 + }
59824 + read_unlock(&tasklist_lock);
59825 + rcu_read_unlock();
59826 +
59827 + if (unsafe_flags && !(task->acl->mode & GR_POVERRIDE) && (task->acl != newacl) &&
59828 + !(task->role->roletype & GR_ROLE_GOD) &&
59829 + !gr_search_file(dentry, GR_PTRACERD, mnt) &&
59830 + !(task->acl->mode & (GR_LEARN | GR_INHERITLEARN))) {
59831 + if (unsafe_flags & LSM_UNSAFE_SHARE)
59832 + gr_log_fs_generic(GR_DONT_AUDIT, GR_UNSAFESHARE_EXEC_ACL_MSG, dentry, mnt);
59833 + else
59834 + gr_log_fs_generic(GR_DONT_AUDIT, GR_PTRACE_EXEC_ACL_MSG, dentry, mnt);
59835 + return -EACCES;
59836 + }
59837 +
59838 +skip_check:
59839 +
59840 + obj = chk_obj_label(dentry, mnt, task->acl);
59841 + retmode = obj->mode & (GR_INHERIT | GR_AUDIT_INHERIT);
59842 +
59843 + if (!(task->acl->mode & GR_INHERITLEARN) &&
59844 + ((newacl->mode & GR_LEARN) || !(retmode & GR_INHERIT))) {
59845 + if (obj->nested)
59846 + task->acl = obj->nested;
59847 + else
59848 + task->acl = newacl;
59849 + } else if (retmode & GR_INHERIT && retmode & GR_AUDIT_INHERIT)
59850 + gr_log_str_fs(GR_DO_AUDIT, GR_INHERIT_ACL_MSG, task->acl->filename, dentry, mnt);
59851 +
59852 + task->is_writable = 0;
59853 +
59854 + /* ignore additional mmap checks for processes that are writable
59855 + by the default ACL */
59856 + obj = chk_obj_label(dentry, mnt, default_role->root_label);
59857 + if (unlikely(obj->mode & GR_WRITE))
59858 + task->is_writable = 1;
59859 + obj = chk_obj_label(dentry, mnt, task->role->root_label);
59860 + if (unlikely(obj->mode & GR_WRITE))
59861 + task->is_writable = 1;
59862 +
59863 + gr_set_proc_res(task);
59864 +
59865 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
59866 + 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);
59867 +#endif
59868 + return 0;
59869 +}
59870 +
59871 +/* always called with valid inodev ptr */
59872 +static void
59873 +do_handle_delete(struct inodev_entry *inodev, const ino_t ino, const dev_t dev)
59874 +{
59875 + struct acl_object_label *matchpo;
59876 + struct acl_subject_label *matchps;
59877 + struct acl_subject_label *subj;
59878 + struct acl_role_label *role;
59879 + unsigned int x;
59880 +
59881 + FOR_EACH_ROLE_START(role)
59882 + FOR_EACH_SUBJECT_START(role, subj, x)
59883 + if ((matchpo = lookup_acl_obj_label(ino, dev, subj)) != NULL)
59884 + matchpo->mode |= GR_DELETED;
59885 + FOR_EACH_SUBJECT_END(subj,x)
59886 + FOR_EACH_NESTED_SUBJECT_START(role, subj)
59887 + /* nested subjects aren't in the role's subj_hash table */
59888 + if ((matchpo = lookup_acl_obj_label(ino, dev, subj)) != NULL)
59889 + matchpo->mode |= GR_DELETED;
59890 + FOR_EACH_NESTED_SUBJECT_END(subj)
59891 + if ((matchps = lookup_acl_subj_label(ino, dev, role)) != NULL)
59892 + matchps->mode |= GR_DELETED;
59893 + FOR_EACH_ROLE_END(role)
59894 +
59895 + inodev->nentry->deleted = 1;
59896 +
59897 + return;
59898 +}
59899 +
59900 +void
59901 +gr_handle_delete(const ino_t ino, const dev_t dev)
59902 +{
59903 + struct inodev_entry *inodev;
59904 +
59905 + if (unlikely(!(gr_status & GR_READY)))
59906 + return;
59907 +
59908 + write_lock(&gr_inode_lock);
59909 + inodev = lookup_inodev_entry(ino, dev);
59910 + if (inodev != NULL)
59911 + do_handle_delete(inodev, ino, dev);
59912 + write_unlock(&gr_inode_lock);
59913 +
59914 + return;
59915 +}
59916 +
59917 +static void
59918 +update_acl_obj_label(const ino_t oldinode, const dev_t olddevice,
59919 + const ino_t newinode, const dev_t newdevice,
59920 + struct acl_subject_label *subj)
59921 +{
59922 + unsigned int index = gr_fhash(oldinode, olddevice, subj->obj_hash_size);
59923 + struct acl_object_label *match;
59924 +
59925 + match = subj->obj_hash[index];
59926 +
59927 + while (match && (match->inode != oldinode ||
59928 + match->device != olddevice ||
59929 + !(match->mode & GR_DELETED)))
59930 + match = match->next;
59931 +
59932 + if (match && (match->inode == oldinode)
59933 + && (match->device == olddevice)
59934 + && (match->mode & GR_DELETED)) {
59935 + if (match->prev == NULL) {
59936 + subj->obj_hash[index] = match->next;
59937 + if (match->next != NULL)
59938 + match->next->prev = NULL;
59939 + } else {
59940 + match->prev->next = match->next;
59941 + if (match->next != NULL)
59942 + match->next->prev = match->prev;
59943 + }
59944 + match->prev = NULL;
59945 + match->next = NULL;
59946 + match->inode = newinode;
59947 + match->device = newdevice;
59948 + match->mode &= ~GR_DELETED;
59949 +
59950 + insert_acl_obj_label(match, subj);
59951 + }
59952 +
59953 + return;
59954 +}
59955 +
59956 +static void
59957 +update_acl_subj_label(const ino_t oldinode, const dev_t olddevice,
59958 + const ino_t newinode, const dev_t newdevice,
59959 + struct acl_role_label *role)
59960 +{
59961 + unsigned int index = gr_fhash(oldinode, olddevice, role->subj_hash_size);
59962 + struct acl_subject_label *match;
59963 +
59964 + match = role->subj_hash[index];
59965 +
59966 + while (match && (match->inode != oldinode ||
59967 + match->device != olddevice ||
59968 + !(match->mode & GR_DELETED)))
59969 + match = match->next;
59970 +
59971 + if (match && (match->inode == oldinode)
59972 + && (match->device == olddevice)
59973 + && (match->mode & GR_DELETED)) {
59974 + if (match->prev == NULL) {
59975 + role->subj_hash[index] = match->next;
59976 + if (match->next != NULL)
59977 + match->next->prev = NULL;
59978 + } else {
59979 + match->prev->next = match->next;
59980 + if (match->next != NULL)
59981 + match->next->prev = match->prev;
59982 + }
59983 + match->prev = NULL;
59984 + match->next = NULL;
59985 + match->inode = newinode;
59986 + match->device = newdevice;
59987 + match->mode &= ~GR_DELETED;
59988 +
59989 + insert_acl_subj_label(match, role);
59990 + }
59991 +
59992 + return;
59993 +}
59994 +
59995 +static void
59996 +update_inodev_entry(const ino_t oldinode, const dev_t olddevice,
59997 + const ino_t newinode, const dev_t newdevice)
59998 +{
59999 + unsigned int index = gr_fhash(oldinode, olddevice, inodev_set.i_size);
60000 + struct inodev_entry *match;
60001 +
60002 + match = inodev_set.i_hash[index];
60003 +
60004 + while (match && (match->nentry->inode != oldinode ||
60005 + match->nentry->device != olddevice || !match->nentry->deleted))
60006 + match = match->next;
60007 +
60008 + if (match && (match->nentry->inode == oldinode)
60009 + && (match->nentry->device == olddevice) &&
60010 + match->nentry->deleted) {
60011 + if (match->prev == NULL) {
60012 + inodev_set.i_hash[index] = match->next;
60013 + if (match->next != NULL)
60014 + match->next->prev = NULL;
60015 + } else {
60016 + match->prev->next = match->next;
60017 + if (match->next != NULL)
60018 + match->next->prev = match->prev;
60019 + }
60020 + match->prev = NULL;
60021 + match->next = NULL;
60022 + match->nentry->inode = newinode;
60023 + match->nentry->device = newdevice;
60024 + match->nentry->deleted = 0;
60025 +
60026 + insert_inodev_entry(match);
60027 + }
60028 +
60029 + return;
60030 +}
60031 +
60032 +static void
60033 +__do_handle_create(const struct name_entry *matchn, ino_t ino, dev_t dev)
60034 +{
60035 + struct acl_subject_label *subj;
60036 + struct acl_role_label *role;
60037 + unsigned int x;
60038 +
60039 + FOR_EACH_ROLE_START(role)
60040 + update_acl_subj_label(matchn->inode, matchn->device, ino, dev, role);
60041 +
60042 + FOR_EACH_NESTED_SUBJECT_START(role, subj)
60043 + if ((subj->inode == ino) && (subj->device == dev)) {
60044 + subj->inode = ino;
60045 + subj->device = dev;
60046 + }
60047 + /* nested subjects aren't in the role's subj_hash table */
60048 + update_acl_obj_label(matchn->inode, matchn->device,
60049 + ino, dev, subj);
60050 + FOR_EACH_NESTED_SUBJECT_END(subj)
60051 + FOR_EACH_SUBJECT_START(role, subj, x)
60052 + update_acl_obj_label(matchn->inode, matchn->device,
60053 + ino, dev, subj);
60054 + FOR_EACH_SUBJECT_END(subj,x)
60055 + FOR_EACH_ROLE_END(role)
60056 +
60057 + update_inodev_entry(matchn->inode, matchn->device, ino, dev);
60058 +
60059 + return;
60060 +}
60061 +
60062 +static void
60063 +do_handle_create(const struct name_entry *matchn, const struct dentry *dentry,
60064 + const struct vfsmount *mnt)
60065 +{
60066 + ino_t ino = dentry->d_inode->i_ino;
60067 + dev_t dev = __get_dev(dentry);
60068 +
60069 + __do_handle_create(matchn, ino, dev);
60070 +
60071 + return;
60072 +}
60073 +
60074 +void
60075 +gr_handle_create(const struct dentry *dentry, const struct vfsmount *mnt)
60076 +{
60077 + struct name_entry *matchn;
60078 +
60079 + if (unlikely(!(gr_status & GR_READY)))
60080 + return;
60081 +
60082 + preempt_disable();
60083 + matchn = lookup_name_entry(gr_to_filename_rbac(dentry, mnt));
60084 +
60085 + if (unlikely((unsigned long)matchn)) {
60086 + write_lock(&gr_inode_lock);
60087 + do_handle_create(matchn, dentry, mnt);
60088 + write_unlock(&gr_inode_lock);
60089 + }
60090 + preempt_enable();
60091 +
60092 + return;
60093 +}
60094 +
60095 +void
60096 +gr_handle_proc_create(const struct dentry *dentry, const struct inode *inode)
60097 +{
60098 + struct name_entry *matchn;
60099 +
60100 + if (unlikely(!(gr_status & GR_READY)))
60101 + return;
60102 +
60103 + preempt_disable();
60104 + matchn = lookup_name_entry(gr_to_proc_filename_rbac(dentry, init_pid_ns.proc_mnt));
60105 +
60106 + if (unlikely((unsigned long)matchn)) {
60107 + write_lock(&gr_inode_lock);
60108 + __do_handle_create(matchn, inode->i_ino, inode->i_sb->s_dev);
60109 + write_unlock(&gr_inode_lock);
60110 + }
60111 + preempt_enable();
60112 +
60113 + return;
60114 +}
60115 +
60116 +void
60117 +gr_handle_rename(struct inode *old_dir, struct inode *new_dir,
60118 + struct dentry *old_dentry,
60119 + struct dentry *new_dentry,
60120 + struct vfsmount *mnt, const __u8 replace)
60121 +{
60122 + struct name_entry *matchn;
60123 + struct inodev_entry *inodev;
60124 + struct inode *inode = new_dentry->d_inode;
60125 + ino_t old_ino = old_dentry->d_inode->i_ino;
60126 + dev_t old_dev = __get_dev(old_dentry);
60127 +
60128 + /* vfs_rename swaps the name and parent link for old_dentry and
60129 + new_dentry
60130 + at this point, old_dentry has the new name, parent link, and inode
60131 + for the renamed file
60132 + if a file is being replaced by a rename, new_dentry has the inode
60133 + and name for the replaced file
60134 + */
60135 +
60136 + if (unlikely(!(gr_status & GR_READY)))
60137 + return;
60138 +
60139 + preempt_disable();
60140 + matchn = lookup_name_entry(gr_to_filename_rbac(old_dentry, mnt));
60141 +
60142 + /* we wouldn't have to check d_inode if it weren't for
60143 + NFS silly-renaming
60144 + */
60145 +
60146 + write_lock(&gr_inode_lock);
60147 + if (unlikely(replace && inode)) {
60148 + ino_t new_ino = inode->i_ino;
60149 + dev_t new_dev = __get_dev(new_dentry);
60150 +
60151 + inodev = lookup_inodev_entry(new_ino, new_dev);
60152 + if (inodev != NULL && ((inode->i_nlink <= 1) || S_ISDIR(inode->i_mode)))
60153 + do_handle_delete(inodev, new_ino, new_dev);
60154 + }
60155 +
60156 + inodev = lookup_inodev_entry(old_ino, old_dev);
60157 + if (inodev != NULL && ((old_dentry->d_inode->i_nlink <= 1) || S_ISDIR(old_dentry->d_inode->i_mode)))
60158 + do_handle_delete(inodev, old_ino, old_dev);
60159 +
60160 + if (unlikely((unsigned long)matchn))
60161 + do_handle_create(matchn, old_dentry, mnt);
60162 +
60163 + write_unlock(&gr_inode_lock);
60164 + preempt_enable();
60165 +
60166 + return;
60167 +}
60168 +
60169 +static int
60170 +lookup_special_role_auth(__u16 mode, const char *rolename, unsigned char **salt,
60171 + unsigned char **sum)
60172 +{
60173 + struct acl_role_label *r;
60174 + struct role_allowed_ip *ipp;
60175 + struct role_transition *trans;
60176 + unsigned int i;
60177 + int found = 0;
60178 + u32 curr_ip = current->signal->curr_ip;
60179 +
60180 + current->signal->saved_ip = curr_ip;
60181 +
60182 + /* check transition table */
60183 +
60184 + for (trans = current->role->transitions; trans; trans = trans->next) {
60185 + if (!strcmp(rolename, trans->rolename)) {
60186 + found = 1;
60187 + break;
60188 + }
60189 + }
60190 +
60191 + if (!found)
60192 + return 0;
60193 +
60194 + /* handle special roles that do not require authentication
60195 + and check ip */
60196 +
60197 + FOR_EACH_ROLE_START(r)
60198 + if (!strcmp(rolename, r->rolename) &&
60199 + (r->roletype & GR_ROLE_SPECIAL)) {
60200 + found = 0;
60201 + if (r->allowed_ips != NULL) {
60202 + for (ipp = r->allowed_ips; ipp; ipp = ipp->next) {
60203 + if ((ntohl(curr_ip) & ipp->netmask) ==
60204 + (ntohl(ipp->addr) & ipp->netmask))
60205 + found = 1;
60206 + }
60207 + } else
60208 + found = 2;
60209 + if (!found)
60210 + return 0;
60211 +
60212 + if (((mode == GR_SPROLE) && (r->roletype & GR_ROLE_NOPW)) ||
60213 + ((mode == GR_SPROLEPAM) && (r->roletype & GR_ROLE_PAM))) {
60214 + *salt = NULL;
60215 + *sum = NULL;
60216 + return 1;
60217 + }
60218 + }
60219 + FOR_EACH_ROLE_END(r)
60220 +
60221 + for (i = 0; i < num_sprole_pws; i++) {
60222 + if (!strcmp(rolename, acl_special_roles[i]->rolename)) {
60223 + *salt = acl_special_roles[i]->salt;
60224 + *sum = acl_special_roles[i]->sum;
60225 + return 1;
60226 + }
60227 + }
60228 +
60229 + return 0;
60230 +}
60231 +
60232 +static void
60233 +assign_special_role(char *rolename)
60234 +{
60235 + struct acl_object_label *obj;
60236 + struct acl_role_label *r;
60237 + struct acl_role_label *assigned = NULL;
60238 + struct task_struct *tsk;
60239 + struct file *filp;
60240 +
60241 + FOR_EACH_ROLE_START(r)
60242 + if (!strcmp(rolename, r->rolename) &&
60243 + (r->roletype & GR_ROLE_SPECIAL)) {
60244 + assigned = r;
60245 + break;
60246 + }
60247 + FOR_EACH_ROLE_END(r)
60248 +
60249 + if (!assigned)
60250 + return;
60251 +
60252 + read_lock(&tasklist_lock);
60253 + read_lock(&grsec_exec_file_lock);
60254 +
60255 + tsk = current->real_parent;
60256 + if (tsk == NULL)
60257 + goto out_unlock;
60258 +
60259 + filp = tsk->exec_file;
60260 + if (filp == NULL)
60261 + goto out_unlock;
60262 +
60263 + tsk->is_writable = 0;
60264 +
60265 + tsk->acl_sp_role = 1;
60266 + tsk->acl_role_id = ++acl_sp_role_value;
60267 + tsk->role = assigned;
60268 + tsk->acl = chk_subj_label(filp->f_path.dentry, filp->f_path.mnt, tsk->role);
60269 +
60270 + /* ignore additional mmap checks for processes that are writable
60271 + by the default ACL */
60272 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, default_role->root_label);
60273 + if (unlikely(obj->mode & GR_WRITE))
60274 + tsk->is_writable = 1;
60275 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, tsk->role->root_label);
60276 + if (unlikely(obj->mode & GR_WRITE))
60277 + tsk->is_writable = 1;
60278 +
60279 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
60280 + 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));
60281 +#endif
60282 +
60283 +out_unlock:
60284 + read_unlock(&grsec_exec_file_lock);
60285 + read_unlock(&tasklist_lock);
60286 + return;
60287 +}
60288 +
60289 +int gr_check_secure_terminal(struct task_struct *task)
60290 +{
60291 + struct task_struct *p, *p2, *p3;
60292 + struct files_struct *files;
60293 + struct fdtable *fdt;
60294 + struct file *our_file = NULL, *file;
60295 + int i;
60296 +
60297 + if (task->signal->tty == NULL)
60298 + return 1;
60299 +
60300 + files = get_files_struct(task);
60301 + if (files != NULL) {
60302 + rcu_read_lock();
60303 + fdt = files_fdtable(files);
60304 + for (i=0; i < fdt->max_fds; i++) {
60305 + file = fcheck_files(files, i);
60306 + if (file && (our_file == NULL) && (file->private_data == task->signal->tty)) {
60307 + get_file(file);
60308 + our_file = file;
60309 + }
60310 + }
60311 + rcu_read_unlock();
60312 + put_files_struct(files);
60313 + }
60314 +
60315 + if (our_file == NULL)
60316 + return 1;
60317 +
60318 + read_lock(&tasklist_lock);
60319 + do_each_thread(p2, p) {
60320 + files = get_files_struct(p);
60321 + if (files == NULL ||
60322 + (p->signal && p->signal->tty == task->signal->tty)) {
60323 + if (files != NULL)
60324 + put_files_struct(files);
60325 + continue;
60326 + }
60327 + rcu_read_lock();
60328 + fdt = files_fdtable(files);
60329 + for (i=0; i < fdt->max_fds; i++) {
60330 + file = fcheck_files(files, i);
60331 + if (file && S_ISCHR(file->f_path.dentry->d_inode->i_mode) &&
60332 + file->f_path.dentry->d_inode->i_rdev == our_file->f_path.dentry->d_inode->i_rdev) {
60333 + p3 = task;
60334 + while (task_pid_nr(p3) > 0) {
60335 + if (p3 == p)
60336 + break;
60337 + p3 = p3->real_parent;
60338 + }
60339 + if (p3 == p)
60340 + break;
60341 + gr_log_ttysniff(GR_DONT_AUDIT_GOOD, GR_TTYSNIFF_ACL_MSG, p);
60342 + gr_handle_alertkill(p);
60343 + rcu_read_unlock();
60344 + put_files_struct(files);
60345 + read_unlock(&tasklist_lock);
60346 + fput(our_file);
60347 + return 0;
60348 + }
60349 + }
60350 + rcu_read_unlock();
60351 + put_files_struct(files);
60352 + } while_each_thread(p2, p);
60353 + read_unlock(&tasklist_lock);
60354 +
60355 + fput(our_file);
60356 + return 1;
60357 +}
60358 +
60359 +static int gr_rbac_disable(void *unused)
60360 +{
60361 + pax_open_kernel();
60362 + gr_status &= ~GR_READY;
60363 + pax_close_kernel();
60364 +
60365 + return 0;
60366 +}
60367 +
60368 +ssize_t
60369 +write_grsec_handler(struct file *file, const char * buf, size_t count, loff_t *ppos)
60370 +{
60371 + struct gr_arg_wrapper uwrap;
60372 + unsigned char *sprole_salt = NULL;
60373 + unsigned char *sprole_sum = NULL;
60374 + int error = sizeof (struct gr_arg_wrapper);
60375 + int error2 = 0;
60376 +
60377 + mutex_lock(&gr_dev_mutex);
60378 +
60379 + if ((gr_status & GR_READY) && !(current->acl->mode & GR_KERNELAUTH)) {
60380 + error = -EPERM;
60381 + goto out;
60382 + }
60383 +
60384 + if (count != sizeof (struct gr_arg_wrapper)) {
60385 + gr_log_int_int(GR_DONT_AUDIT_GOOD, GR_DEV_ACL_MSG, (int)count, (int)sizeof(struct gr_arg_wrapper));
60386 + error = -EINVAL;
60387 + goto out;
60388 + }
60389 +
60390 +
60391 + if (gr_auth_expires && time_after_eq(get_seconds(), gr_auth_expires)) {
60392 + gr_auth_expires = 0;
60393 + gr_auth_attempts = 0;
60394 + }
60395 +
60396 + if (copy_from_user(&uwrap, buf, sizeof (struct gr_arg_wrapper))) {
60397 + error = -EFAULT;
60398 + goto out;
60399 + }
60400 +
60401 + if ((uwrap.version != GRSECURITY_VERSION) || (uwrap.size != sizeof(struct gr_arg))) {
60402 + error = -EINVAL;
60403 + goto out;
60404 + }
60405 +
60406 + if (copy_from_user(gr_usermode, uwrap.arg, sizeof (struct gr_arg))) {
60407 + error = -EFAULT;
60408 + goto out;
60409 + }
60410 +
60411 + if (gr_usermode->mode != GR_SPROLE && gr_usermode->mode != GR_SPROLEPAM &&
60412 + gr_auth_attempts >= CONFIG_GRKERNSEC_ACL_MAXTRIES &&
60413 + time_after(gr_auth_expires, get_seconds())) {
60414 + error = -EBUSY;
60415 + goto out;
60416 + }
60417 +
60418 + /* if non-root trying to do anything other than use a special role,
60419 + do not attempt authentication, do not count towards authentication
60420 + locking
60421 + */
60422 +
60423 + if (gr_usermode->mode != GR_SPROLE && gr_usermode->mode != GR_STATUS &&
60424 + gr_usermode->mode != GR_UNSPROLE && gr_usermode->mode != GR_SPROLEPAM &&
60425 + gr_is_global_nonroot(current_uid())) {
60426 + error = -EPERM;
60427 + goto out;
60428 + }
60429 +
60430 + /* ensure pw and special role name are null terminated */
60431 +
60432 + gr_usermode->pw[GR_PW_LEN - 1] = '\0';
60433 + gr_usermode->sp_role[GR_SPROLE_LEN - 1] = '\0';
60434 +
60435 + /* Okay.
60436 + * We have our enough of the argument structure..(we have yet
60437 + * to copy_from_user the tables themselves) . Copy the tables
60438 + * only if we need them, i.e. for loading operations. */
60439 +
60440 + switch (gr_usermode->mode) {
60441 + case GR_STATUS:
60442 + if (gr_status & GR_READY) {
60443 + error = 1;
60444 + if (!gr_check_secure_terminal(current))
60445 + error = 3;
60446 + } else
60447 + error = 2;
60448 + goto out;
60449 + case GR_SHUTDOWN:
60450 + if ((gr_status & GR_READY)
60451 + && !(chkpw(gr_usermode, gr_system_salt, gr_system_sum))) {
60452 + stop_machine(gr_rbac_disable, NULL, NULL);
60453 + free_variables();
60454 + memset(gr_usermode, 0, sizeof (struct gr_arg));
60455 + memset(gr_system_salt, 0, GR_SALT_LEN);
60456 + memset(gr_system_sum, 0, GR_SHA_LEN);
60457 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SHUTS_ACL_MSG);
60458 + } else if (gr_status & GR_READY) {
60459 + gr_log_noargs(GR_DONT_AUDIT, GR_SHUTF_ACL_MSG);
60460 + error = -EPERM;
60461 + } else {
60462 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SHUTI_ACL_MSG);
60463 + error = -EAGAIN;
60464 + }
60465 + break;
60466 + case GR_ENABLE:
60467 + if (!(gr_status & GR_READY) && !(error2 = gracl_init(gr_usermode)))
60468 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_ENABLE_ACL_MSG, GR_VERSION);
60469 + else {
60470 + if (gr_status & GR_READY)
60471 + error = -EAGAIN;
60472 + else
60473 + error = error2;
60474 + gr_log_str(GR_DONT_AUDIT, GR_ENABLEF_ACL_MSG, GR_VERSION);
60475 + }
60476 + break;
60477 + case GR_RELOAD:
60478 + if (!(gr_status & GR_READY)) {
60479 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_RELOADI_ACL_MSG, GR_VERSION);
60480 + error = -EAGAIN;
60481 + } else if (!(chkpw(gr_usermode, gr_system_salt, gr_system_sum))) {
60482 + stop_machine(gr_rbac_disable, NULL, NULL);
60483 + free_variables();
60484 + error2 = gracl_init(gr_usermode);
60485 + if (!error2)
60486 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_RELOAD_ACL_MSG, GR_VERSION);
60487 + else {
60488 + gr_log_str(GR_DONT_AUDIT, GR_RELOADF_ACL_MSG, GR_VERSION);
60489 + error = error2;
60490 + }
60491 + } else {
60492 + gr_log_str(GR_DONT_AUDIT, GR_RELOADF_ACL_MSG, GR_VERSION);
60493 + error = -EPERM;
60494 + }
60495 + break;
60496 + case GR_SEGVMOD:
60497 + if (unlikely(!(gr_status & GR_READY))) {
60498 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SEGVMODI_ACL_MSG);
60499 + error = -EAGAIN;
60500 + break;
60501 + }
60502 +
60503 + if (!(chkpw(gr_usermode, gr_system_salt, gr_system_sum))) {
60504 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SEGVMODS_ACL_MSG);
60505 + if (gr_usermode->segv_device && gr_usermode->segv_inode) {
60506 + struct acl_subject_label *segvacl;
60507 + segvacl =
60508 + lookup_acl_subj_label(gr_usermode->segv_inode,
60509 + gr_usermode->segv_device,
60510 + current->role);
60511 + if (segvacl) {
60512 + segvacl->crashes = 0;
60513 + segvacl->expires = 0;
60514 + }
60515 + } else if (gr_find_uid(gr_usermode->segv_uid) >= 0) {
60516 + gr_remove_uid(gr_usermode->segv_uid);
60517 + }
60518 + } else {
60519 + gr_log_noargs(GR_DONT_AUDIT, GR_SEGVMODF_ACL_MSG);
60520 + error = -EPERM;
60521 + }
60522 + break;
60523 + case GR_SPROLE:
60524 + case GR_SPROLEPAM:
60525 + if (unlikely(!(gr_status & GR_READY))) {
60526 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SPROLEI_ACL_MSG);
60527 + error = -EAGAIN;
60528 + break;
60529 + }
60530 +
60531 + if (current->role->expires && time_after_eq(get_seconds(), current->role->expires)) {
60532 + current->role->expires = 0;
60533 + current->role->auth_attempts = 0;
60534 + }
60535 +
60536 + if (current->role->auth_attempts >= CONFIG_GRKERNSEC_ACL_MAXTRIES &&
60537 + time_after(current->role->expires, get_seconds())) {
60538 + error = -EBUSY;
60539 + goto out;
60540 + }
60541 +
60542 + if (lookup_special_role_auth
60543 + (gr_usermode->mode, gr_usermode->sp_role, &sprole_salt, &sprole_sum)
60544 + && ((!sprole_salt && !sprole_sum)
60545 + || !(chkpw(gr_usermode, sprole_salt, sprole_sum)))) {
60546 + char *p = "";
60547 + assign_special_role(gr_usermode->sp_role);
60548 + read_lock(&tasklist_lock);
60549 + if (current->real_parent)
60550 + p = current->real_parent->role->rolename;
60551 + read_unlock(&tasklist_lock);
60552 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_SPROLES_ACL_MSG,
60553 + p, acl_sp_role_value);
60554 + } else {
60555 + gr_log_str(GR_DONT_AUDIT, GR_SPROLEF_ACL_MSG, gr_usermode->sp_role);
60556 + error = -EPERM;
60557 + if(!(current->role->auth_attempts++))
60558 + current->role->expires = get_seconds() + CONFIG_GRKERNSEC_ACL_TIMEOUT;
60559 +
60560 + goto out;
60561 + }
60562 + break;
60563 + case GR_UNSPROLE:
60564 + if (unlikely(!(gr_status & GR_READY))) {
60565 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_UNSPROLEI_ACL_MSG);
60566 + error = -EAGAIN;
60567 + break;
60568 + }
60569 +
60570 + if (current->role->roletype & GR_ROLE_SPECIAL) {
60571 + char *p = "";
60572 + int i = 0;
60573 +
60574 + read_lock(&tasklist_lock);
60575 + if (current->real_parent) {
60576 + p = current->real_parent->role->rolename;
60577 + i = current->real_parent->acl_role_id;
60578 + }
60579 + read_unlock(&tasklist_lock);
60580 +
60581 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_UNSPROLES_ACL_MSG, p, i);
60582 + gr_set_acls(1);
60583 + } else {
60584 + error = -EPERM;
60585 + goto out;
60586 + }
60587 + break;
60588 + default:
60589 + gr_log_int(GR_DONT_AUDIT, GR_INVMODE_ACL_MSG, gr_usermode->mode);
60590 + error = -EINVAL;
60591 + break;
60592 + }
60593 +
60594 + if (error != -EPERM)
60595 + goto out;
60596 +
60597 + if(!(gr_auth_attempts++))
60598 + gr_auth_expires = get_seconds() + CONFIG_GRKERNSEC_ACL_TIMEOUT;
60599 +
60600 + out:
60601 + mutex_unlock(&gr_dev_mutex);
60602 + return error;
60603 +}
60604 +
60605 +/* must be called with
60606 + rcu_read_lock();
60607 + read_lock(&tasklist_lock);
60608 + read_lock(&grsec_exec_file_lock);
60609 +*/
60610 +int gr_apply_subject_to_task(struct task_struct *task)
60611 +{
60612 + struct acl_object_label *obj;
60613 + char *tmpname;
60614 + struct acl_subject_label *tmpsubj;
60615 + struct file *filp;
60616 + struct name_entry *nmatch;
60617 +
60618 + filp = task->exec_file;
60619 + if (filp == NULL)
60620 + return 0;
60621 +
60622 + /* the following is to apply the correct subject
60623 + on binaries running when the RBAC system
60624 + is enabled, when the binaries have been
60625 + replaced or deleted since their execution
60626 + -----
60627 + when the RBAC system starts, the inode/dev
60628 + from exec_file will be one the RBAC system
60629 + is unaware of. It only knows the inode/dev
60630 + of the present file on disk, or the absence
60631 + of it.
60632 + */
60633 + preempt_disable();
60634 + tmpname = gr_to_filename_rbac(filp->f_path.dentry, filp->f_path.mnt);
60635 +
60636 + nmatch = lookup_name_entry(tmpname);
60637 + preempt_enable();
60638 + tmpsubj = NULL;
60639 + if (nmatch) {
60640 + if (nmatch->deleted)
60641 + tmpsubj = lookup_acl_subj_label_deleted(nmatch->inode, nmatch->device, task->role);
60642 + else
60643 + tmpsubj = lookup_acl_subj_label(nmatch->inode, nmatch->device, task->role);
60644 + if (tmpsubj != NULL)
60645 + task->acl = tmpsubj;
60646 + }
60647 + if (tmpsubj == NULL)
60648 + task->acl = chk_subj_label(filp->f_path.dentry, filp->f_path.mnt,
60649 + task->role);
60650 + if (task->acl) {
60651 + task->is_writable = 0;
60652 + /* ignore additional mmap checks for processes that are writable
60653 + by the default ACL */
60654 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, default_role->root_label);
60655 + if (unlikely(obj->mode & GR_WRITE))
60656 + task->is_writable = 1;
60657 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, task->role->root_label);
60658 + if (unlikely(obj->mode & GR_WRITE))
60659 + task->is_writable = 1;
60660 +
60661 + gr_set_proc_res(task);
60662 +
60663 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
60664 + 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);
60665 +#endif
60666 + } else {
60667 + return 1;
60668 + }
60669 +
60670 + return 0;
60671 +}
60672 +
60673 +int
60674 +gr_set_acls(const int type)
60675 +{
60676 + struct task_struct *task, *task2;
60677 + struct acl_role_label *role = current->role;
60678 + __u16 acl_role_id = current->acl_role_id;
60679 + const struct cred *cred;
60680 + int ret;
60681 +
60682 + rcu_read_lock();
60683 + read_lock(&tasklist_lock);
60684 + read_lock(&grsec_exec_file_lock);
60685 + do_each_thread(task2, task) {
60686 + /* check to see if we're called from the exit handler,
60687 + if so, only replace ACLs that have inherited the admin
60688 + ACL */
60689 +
60690 + if (type && (task->role != role ||
60691 + task->acl_role_id != acl_role_id))
60692 + continue;
60693 +
60694 + task->acl_role_id = 0;
60695 + task->acl_sp_role = 0;
60696 +
60697 + if (task->exec_file) {
60698 + cred = __task_cred(task);
60699 + task->role = lookup_acl_role_label(task, GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid));
60700 + ret = gr_apply_subject_to_task(task);
60701 + if (ret) {
60702 + read_unlock(&grsec_exec_file_lock);
60703 + read_unlock(&tasklist_lock);
60704 + rcu_read_unlock();
60705 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_DEFACL_MSG, task->comm, task_pid_nr(task));
60706 + return ret;
60707 + }
60708 + } else {
60709 + // it's a kernel process
60710 + task->role = kernel_role;
60711 + task->acl = kernel_role->root_label;
60712 +#ifdef CONFIG_GRKERNSEC_ACL_HIDEKERN
60713 + task->acl->mode &= ~GR_PROCFIND;
60714 +#endif
60715 + }
60716 + } while_each_thread(task2, task);
60717 + read_unlock(&grsec_exec_file_lock);
60718 + read_unlock(&tasklist_lock);
60719 + rcu_read_unlock();
60720 +
60721 + return 0;
60722 +}
60723 +
60724 +#if defined(CONFIG_GRKERNSEC_RESLOG) || !defined(CONFIG_GRKERNSEC_NO_RBAC)
60725 +static const unsigned long res_learn_bumps[GR_NLIMITS] = {
60726 + [RLIMIT_CPU] = GR_RLIM_CPU_BUMP,
60727 + [RLIMIT_FSIZE] = GR_RLIM_FSIZE_BUMP,
60728 + [RLIMIT_DATA] = GR_RLIM_DATA_BUMP,
60729 + [RLIMIT_STACK] = GR_RLIM_STACK_BUMP,
60730 + [RLIMIT_CORE] = GR_RLIM_CORE_BUMP,
60731 + [RLIMIT_RSS] = GR_RLIM_RSS_BUMP,
60732 + [RLIMIT_NPROC] = GR_RLIM_NPROC_BUMP,
60733 + [RLIMIT_NOFILE] = GR_RLIM_NOFILE_BUMP,
60734 + [RLIMIT_MEMLOCK] = GR_RLIM_MEMLOCK_BUMP,
60735 + [RLIMIT_AS] = GR_RLIM_AS_BUMP,
60736 + [RLIMIT_LOCKS] = GR_RLIM_LOCKS_BUMP,
60737 + [RLIMIT_SIGPENDING] = GR_RLIM_SIGPENDING_BUMP,
60738 + [RLIMIT_MSGQUEUE] = GR_RLIM_MSGQUEUE_BUMP,
60739 + [RLIMIT_NICE] = GR_RLIM_NICE_BUMP,
60740 + [RLIMIT_RTPRIO] = GR_RLIM_RTPRIO_BUMP,
60741 + [RLIMIT_RTTIME] = GR_RLIM_RTTIME_BUMP
60742 +};
60743 +
60744 +void
60745 +gr_learn_resource(const struct task_struct *task,
60746 + const int res, const unsigned long wanted, const int gt)
60747 +{
60748 + struct acl_subject_label *acl;
60749 + const struct cred *cred;
60750 +
60751 + if (unlikely((gr_status & GR_READY) &&
60752 + task->acl && (task->acl->mode & (GR_LEARN | GR_INHERITLEARN))))
60753 + goto skip_reslog;
60754 +
60755 + gr_log_resource(task, res, wanted, gt);
60756 +skip_reslog:
60757 +
60758 + if (unlikely(!(gr_status & GR_READY) || !wanted || res >= GR_NLIMITS))
60759 + return;
60760 +
60761 + acl = task->acl;
60762 +
60763 + if (likely(!acl || !(acl->mode & (GR_LEARN | GR_INHERITLEARN)) ||
60764 + !(acl->resmask & (1 << (unsigned short) res))))
60765 + return;
60766 +
60767 + if (wanted >= acl->res[res].rlim_cur) {
60768 + unsigned long res_add;
60769 +
60770 + res_add = wanted + res_learn_bumps[res];
60771 +
60772 + acl->res[res].rlim_cur = res_add;
60773 +
60774 + if (wanted > acl->res[res].rlim_max)
60775 + acl->res[res].rlim_max = res_add;
60776 +
60777 + /* only log the subject filename, since resource logging is supported for
60778 + single-subject learning only */
60779 + rcu_read_lock();
60780 + cred = __task_cred(task);
60781 + security_learn(GR_LEARN_AUDIT_MSG, task->role->rolename,
60782 + task->role->roletype, GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), acl->filename,
60783 + acl->filename, acl->res[res].rlim_cur, acl->res[res].rlim_max,
60784 + "", (unsigned long) res, &task->signal->saved_ip);
60785 + rcu_read_unlock();
60786 + }
60787 +
60788 + return;
60789 +}
60790 +EXPORT_SYMBOL(gr_learn_resource);
60791 +#endif
60792 +
60793 +#if defined(CONFIG_PAX_HAVE_ACL_FLAGS) && (defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR))
60794 +void
60795 +pax_set_initial_flags(struct linux_binprm *bprm)
60796 +{
60797 + struct task_struct *task = current;
60798 + struct acl_subject_label *proc;
60799 + unsigned long flags;
60800 +
60801 + if (unlikely(!(gr_status & GR_READY)))
60802 + return;
60803 +
60804 + flags = pax_get_flags(task);
60805 +
60806 + proc = task->acl;
60807 +
60808 + if (proc->pax_flags & GR_PAX_DISABLE_PAGEEXEC)
60809 + flags &= ~MF_PAX_PAGEEXEC;
60810 + if (proc->pax_flags & GR_PAX_DISABLE_SEGMEXEC)
60811 + flags &= ~MF_PAX_SEGMEXEC;
60812 + if (proc->pax_flags & GR_PAX_DISABLE_RANDMMAP)
60813 + flags &= ~MF_PAX_RANDMMAP;
60814 + if (proc->pax_flags & GR_PAX_DISABLE_EMUTRAMP)
60815 + flags &= ~MF_PAX_EMUTRAMP;
60816 + if (proc->pax_flags & GR_PAX_DISABLE_MPROTECT)
60817 + flags &= ~MF_PAX_MPROTECT;
60818 +
60819 + if (proc->pax_flags & GR_PAX_ENABLE_PAGEEXEC)
60820 + flags |= MF_PAX_PAGEEXEC;
60821 + if (proc->pax_flags & GR_PAX_ENABLE_SEGMEXEC)
60822 + flags |= MF_PAX_SEGMEXEC;
60823 + if (proc->pax_flags & GR_PAX_ENABLE_RANDMMAP)
60824 + flags |= MF_PAX_RANDMMAP;
60825 + if (proc->pax_flags & GR_PAX_ENABLE_EMUTRAMP)
60826 + flags |= MF_PAX_EMUTRAMP;
60827 + if (proc->pax_flags & GR_PAX_ENABLE_MPROTECT)
60828 + flags |= MF_PAX_MPROTECT;
60829 +
60830 + pax_set_flags(task, flags);
60831 +
60832 + return;
60833 +}
60834 +#endif
60835 +
60836 +int
60837 +gr_handle_proc_ptrace(struct task_struct *task)
60838 +{
60839 + struct file *filp;
60840 + struct task_struct *tmp = task;
60841 + struct task_struct *curtemp = current;
60842 + __u32 retmode;
60843 +
60844 +#ifndef CONFIG_GRKERNSEC_HARDEN_PTRACE
60845 + if (unlikely(!(gr_status & GR_READY)))
60846 + return 0;
60847 +#endif
60848 +
60849 + read_lock(&tasklist_lock);
60850 + read_lock(&grsec_exec_file_lock);
60851 + filp = task->exec_file;
60852 +
60853 + while (task_pid_nr(tmp) > 0) {
60854 + if (tmp == curtemp)
60855 + break;
60856 + tmp = tmp->real_parent;
60857 + }
60858 +
60859 + if (!filp || (task_pid_nr(tmp) == 0 && ((grsec_enable_harden_ptrace && gr_is_global_nonroot(current_uid()) && !(gr_status & GR_READY)) ||
60860 + ((gr_status & GR_READY) && !(current->acl->mode & GR_RELAXPTRACE))))) {
60861 + read_unlock(&grsec_exec_file_lock);
60862 + read_unlock(&tasklist_lock);
60863 + return 1;
60864 + }
60865 +
60866 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
60867 + if (!(gr_status & GR_READY)) {
60868 + read_unlock(&grsec_exec_file_lock);
60869 + read_unlock(&tasklist_lock);
60870 + return 0;
60871 + }
60872 +#endif
60873 +
60874 + retmode = gr_search_file(filp->f_path.dentry, GR_NOPTRACE, filp->f_path.mnt);
60875 + read_unlock(&grsec_exec_file_lock);
60876 + read_unlock(&tasklist_lock);
60877 +
60878 + if (retmode & GR_NOPTRACE)
60879 + return 1;
60880 +
60881 + if (!(current->acl->mode & GR_POVERRIDE) && !(current->role->roletype & GR_ROLE_GOD)
60882 + && (current->acl != task->acl || (current->acl != current->role->root_label
60883 + && task_pid_nr(current) != task_pid_nr(task))))
60884 + return 1;
60885 +
60886 + return 0;
60887 +}
60888 +
60889 +void task_grsec_rbac(struct seq_file *m, struct task_struct *p)
60890 +{
60891 + if (unlikely(!(gr_status & GR_READY)))
60892 + return;
60893 +
60894 + if (!(current->role->roletype & GR_ROLE_GOD))
60895 + return;
60896 +
60897 + seq_printf(m, "RBAC:\t%.64s:%c:%.950s\n",
60898 + p->role->rolename, gr_task_roletype_to_char(p),
60899 + p->acl->filename);
60900 +}
60901 +
60902 +int
60903 +gr_handle_ptrace(struct task_struct *task, const long request)
60904 +{
60905 + struct task_struct *tmp = task;
60906 + struct task_struct *curtemp = current;
60907 + __u32 retmode;
60908 +
60909 +#ifndef CONFIG_GRKERNSEC_HARDEN_PTRACE
60910 + if (unlikely(!(gr_status & GR_READY)))
60911 + return 0;
60912 +#endif
60913 + if (request == PTRACE_ATTACH || request == PTRACE_SEIZE) {
60914 + read_lock(&tasklist_lock);
60915 + while (task_pid_nr(tmp) > 0) {
60916 + if (tmp == curtemp)
60917 + break;
60918 + tmp = tmp->real_parent;
60919 + }
60920 +
60921 + if (task_pid_nr(tmp) == 0 && ((grsec_enable_harden_ptrace && gr_is_global_nonroot(current_uid()) && !(gr_status & GR_READY)) ||
60922 + ((gr_status & GR_READY) && !(current->acl->mode & GR_RELAXPTRACE)))) {
60923 + read_unlock(&tasklist_lock);
60924 + gr_log_ptrace(GR_DONT_AUDIT, GR_PTRACE_ACL_MSG, task);
60925 + return 1;
60926 + }
60927 + read_unlock(&tasklist_lock);
60928 + }
60929 +
60930 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
60931 + if (!(gr_status & GR_READY))
60932 + return 0;
60933 +#endif
60934 +
60935 + read_lock(&grsec_exec_file_lock);
60936 + if (unlikely(!task->exec_file)) {
60937 + read_unlock(&grsec_exec_file_lock);
60938 + return 0;
60939 + }
60940 +
60941 + retmode = gr_search_file(task->exec_file->f_path.dentry, GR_PTRACERD | GR_NOPTRACE, task->exec_file->f_path.mnt);
60942 + read_unlock(&grsec_exec_file_lock);
60943 +
60944 + if (retmode & GR_NOPTRACE) {
60945 + gr_log_ptrace(GR_DONT_AUDIT, GR_PTRACE_ACL_MSG, task);
60946 + return 1;
60947 + }
60948 +
60949 + if (retmode & GR_PTRACERD) {
60950 + switch (request) {
60951 + case PTRACE_SEIZE:
60952 + case PTRACE_POKETEXT:
60953 + case PTRACE_POKEDATA:
60954 + case PTRACE_POKEUSR:
60955 +#if !defined(CONFIG_PPC32) && !defined(CONFIG_PPC64) && !defined(CONFIG_PARISC) && !defined(CONFIG_ALPHA) && !defined(CONFIG_IA64)
60956 + case PTRACE_SETREGS:
60957 + case PTRACE_SETFPREGS:
60958 +#endif
60959 +#ifdef CONFIG_X86
60960 + case PTRACE_SETFPXREGS:
60961 +#endif
60962 +#ifdef CONFIG_ALTIVEC
60963 + case PTRACE_SETVRREGS:
60964 +#endif
60965 + return 1;
60966 + default:
60967 + return 0;
60968 + }
60969 + } else if (!(current->acl->mode & GR_POVERRIDE) &&
60970 + !(current->role->roletype & GR_ROLE_GOD) &&
60971 + (current->acl != task->acl)) {
60972 + gr_log_ptrace(GR_DONT_AUDIT, GR_PTRACE_ACL_MSG, task);
60973 + return 1;
60974 + }
60975 +
60976 + return 0;
60977 +}
60978 +
60979 +static int is_writable_mmap(const struct file *filp)
60980 +{
60981 + struct task_struct *task = current;
60982 + struct acl_object_label *obj, *obj2;
60983 +
60984 + if (gr_status & GR_READY && !(task->acl->mode & GR_OVERRIDE) &&
60985 + !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))) {
60986 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, default_role->root_label);
60987 + obj2 = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt,
60988 + task->role->root_label);
60989 + if (unlikely((obj->mode & GR_WRITE) || (obj2->mode & GR_WRITE))) {
60990 + gr_log_fs_generic(GR_DONT_AUDIT, GR_WRITLIB_ACL_MSG, filp->f_path.dentry, filp->f_path.mnt);
60991 + return 1;
60992 + }
60993 + }
60994 + return 0;
60995 +}
60996 +
60997 +int
60998 +gr_acl_handle_mmap(const struct file *file, const unsigned long prot)
60999 +{
61000 + __u32 mode;
61001 +
61002 + if (unlikely(!file || !(prot & PROT_EXEC)))
61003 + return 1;
61004 +
61005 + if (is_writable_mmap(file))
61006 + return 0;
61007 +
61008 + mode =
61009 + gr_search_file(file->f_path.dentry,
61010 + GR_EXEC | GR_AUDIT_EXEC | GR_SUPPRESS,
61011 + file->f_path.mnt);
61012 +
61013 + if (!gr_tpe_allow(file))
61014 + return 0;
61015 +
61016 + if (unlikely(!(mode & GR_EXEC) && !(mode & GR_SUPPRESS))) {
61017 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, GR_MMAP_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
61018 + return 0;
61019 + } else if (unlikely(!(mode & GR_EXEC))) {
61020 + return 0;
61021 + } else if (unlikely(mode & GR_EXEC && mode & GR_AUDIT_EXEC)) {
61022 + gr_log_fs_rbac_generic(GR_DO_AUDIT, GR_MMAP_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
61023 + return 1;
61024 + }
61025 +
61026 + return 1;
61027 +}
61028 +
61029 +int
61030 +gr_acl_handle_mprotect(const struct file *file, const unsigned long prot)
61031 +{
61032 + __u32 mode;
61033 +
61034 + if (unlikely(!file || !(prot & PROT_EXEC)))
61035 + return 1;
61036 +
61037 + if (is_writable_mmap(file))
61038 + return 0;
61039 +
61040 + mode =
61041 + gr_search_file(file->f_path.dentry,
61042 + GR_EXEC | GR_AUDIT_EXEC | GR_SUPPRESS,
61043 + file->f_path.mnt);
61044 +
61045 + if (!gr_tpe_allow(file))
61046 + return 0;
61047 +
61048 + if (unlikely(!(mode & GR_EXEC) && !(mode & GR_SUPPRESS))) {
61049 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, GR_MPROTECT_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
61050 + return 0;
61051 + } else if (unlikely(!(mode & GR_EXEC))) {
61052 + return 0;
61053 + } else if (unlikely(mode & GR_EXEC && mode & GR_AUDIT_EXEC)) {
61054 + gr_log_fs_rbac_generic(GR_DO_AUDIT, GR_MPROTECT_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
61055 + return 1;
61056 + }
61057 +
61058 + return 1;
61059 +}
61060 +
61061 +void
61062 +gr_acl_handle_psacct(struct task_struct *task, const long code)
61063 +{
61064 + unsigned long runtime;
61065 + unsigned long cputime;
61066 + unsigned int wday, cday;
61067 + __u8 whr, chr;
61068 + __u8 wmin, cmin;
61069 + __u8 wsec, csec;
61070 + struct timespec timeval;
61071 +
61072 + if (unlikely(!(gr_status & GR_READY) || !task->acl ||
61073 + !(task->acl->mode & GR_PROCACCT)))
61074 + return;
61075 +
61076 + do_posix_clock_monotonic_gettime(&timeval);
61077 + runtime = timeval.tv_sec - task->start_time.tv_sec;
61078 + wday = runtime / (3600 * 24);
61079 + runtime -= wday * (3600 * 24);
61080 + whr = runtime / 3600;
61081 + runtime -= whr * 3600;
61082 + wmin = runtime / 60;
61083 + runtime -= wmin * 60;
61084 + wsec = runtime;
61085 +
61086 + cputime = (task->utime + task->stime) / HZ;
61087 + cday = cputime / (3600 * 24);
61088 + cputime -= cday * (3600 * 24);
61089 + chr = cputime / 3600;
61090 + cputime -= chr * 3600;
61091 + cmin = cputime / 60;
61092 + cputime -= cmin * 60;
61093 + csec = cputime;
61094 +
61095 + gr_log_procacct(GR_DO_AUDIT, GR_ACL_PROCACCT_MSG, task, wday, whr, wmin, wsec, cday, chr, cmin, csec, code);
61096 +
61097 + return;
61098 +}
61099 +
61100 +void gr_set_kernel_label(struct task_struct *task)
61101 +{
61102 + if (gr_status & GR_READY) {
61103 + task->role = kernel_role;
61104 + task->acl = kernel_role->root_label;
61105 + }
61106 + return;
61107 +}
61108 +
61109 +#ifdef CONFIG_TASKSTATS
61110 +int gr_is_taskstats_denied(int pid)
61111 +{
61112 + struct task_struct *task;
61113 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
61114 + const struct cred *cred;
61115 +#endif
61116 + int ret = 0;
61117 +
61118 + /* restrict taskstats viewing to un-chrooted root users
61119 + who have the 'view' subject flag if the RBAC system is enabled
61120 + */
61121 +
61122 + rcu_read_lock();
61123 + read_lock(&tasklist_lock);
61124 + task = find_task_by_vpid(pid);
61125 + if (task) {
61126 +#ifdef CONFIG_GRKERNSEC_CHROOT
61127 + if (proc_is_chrooted(task))
61128 + ret = -EACCES;
61129 +#endif
61130 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
61131 + cred = __task_cred(task);
61132 +#ifdef CONFIG_GRKERNSEC_PROC_USER
61133 + if (gr_is_global_nonroot(cred->uid))
61134 + ret = -EACCES;
61135 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
61136 + if (gr_is_global_nonroot(cred->uid) && !groups_search(cred->group_info, grsec_proc_gid))
61137 + ret = -EACCES;
61138 +#endif
61139 +#endif
61140 + if (gr_status & GR_READY) {
61141 + if (!(task->acl->mode & GR_VIEW))
61142 + ret = -EACCES;
61143 + }
61144 + } else
61145 + ret = -ENOENT;
61146 +
61147 + read_unlock(&tasklist_lock);
61148 + rcu_read_unlock();
61149 +
61150 + return ret;
61151 +}
61152 +#endif
61153 +
61154 +/* AUXV entries are filled via a descendant of search_binary_handler
61155 + after we've already applied the subject for the target
61156 +*/
61157 +int gr_acl_enable_at_secure(void)
61158 +{
61159 + if (unlikely(!(gr_status & GR_READY)))
61160 + return 0;
61161 +
61162 + if (current->acl->mode & GR_ATSECURE)
61163 + return 1;
61164 +
61165 + return 0;
61166 +}
61167 +
61168 +int gr_acl_handle_filldir(const struct file *file, const char *name, const unsigned int namelen, const ino_t ino)
61169 +{
61170 + struct task_struct *task = current;
61171 + struct dentry *dentry = file->f_path.dentry;
61172 + struct vfsmount *mnt = file->f_path.mnt;
61173 + struct acl_object_label *obj, *tmp;
61174 + struct acl_subject_label *subj;
61175 + unsigned int bufsize;
61176 + int is_not_root;
61177 + char *path;
61178 + dev_t dev = __get_dev(dentry);
61179 +
61180 + if (unlikely(!(gr_status & GR_READY)))
61181 + return 1;
61182 +
61183 + if (task->acl->mode & (GR_LEARN | GR_INHERITLEARN))
61184 + return 1;
61185 +
61186 + /* ignore Eric Biederman */
61187 + if (IS_PRIVATE(dentry->d_inode))
61188 + return 1;
61189 +
61190 + subj = task->acl;
61191 + read_lock(&gr_inode_lock);
61192 + do {
61193 + obj = lookup_acl_obj_label(ino, dev, subj);
61194 + if (obj != NULL) {
61195 + read_unlock(&gr_inode_lock);
61196 + return (obj->mode & GR_FIND) ? 1 : 0;
61197 + }
61198 + } while ((subj = subj->parent_subject));
61199 + read_unlock(&gr_inode_lock);
61200 +
61201 + /* this is purely an optimization since we're looking for an object
61202 + for the directory we're doing a readdir on
61203 + if it's possible for any globbed object to match the entry we're
61204 + filling into the directory, then the object we find here will be
61205 + an anchor point with attached globbed objects
61206 + */
61207 + obj = chk_obj_label_noglob(dentry, mnt, task->acl);
61208 + if (obj->globbed == NULL)
61209 + return (obj->mode & GR_FIND) ? 1 : 0;
61210 +
61211 + is_not_root = ((obj->filename[0] == '/') &&
61212 + (obj->filename[1] == '\0')) ? 0 : 1;
61213 + bufsize = PAGE_SIZE - namelen - is_not_root;
61214 +
61215 + /* check bufsize > PAGE_SIZE || bufsize == 0 */
61216 + if (unlikely((bufsize - 1) > (PAGE_SIZE - 1)))
61217 + return 1;
61218 +
61219 + preempt_disable();
61220 + path = d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0], smp_processor_id()),
61221 + bufsize);
61222 +
61223 + bufsize = strlen(path);
61224 +
61225 + /* if base is "/", don't append an additional slash */
61226 + if (is_not_root)
61227 + *(path + bufsize) = '/';
61228 + memcpy(path + bufsize + is_not_root, name, namelen);
61229 + *(path + bufsize + namelen + is_not_root) = '\0';
61230 +
61231 + tmp = obj->globbed;
61232 + while (tmp) {
61233 + if (!glob_match(tmp->filename, path)) {
61234 + preempt_enable();
61235 + return (tmp->mode & GR_FIND) ? 1 : 0;
61236 + }
61237 + tmp = tmp->next;
61238 + }
61239 + preempt_enable();
61240 + return (obj->mode & GR_FIND) ? 1 : 0;
61241 +}
61242 +
61243 +void gr_put_exec_file(struct task_struct *task)
61244 +{
61245 + struct file *filp;
61246 +
61247 + write_lock(&grsec_exec_file_lock);
61248 + filp = task->exec_file;
61249 + task->exec_file = NULL;
61250 + write_unlock(&grsec_exec_file_lock);
61251 +
61252 + if (filp)
61253 + fput(filp);
61254 +
61255 + return;
61256 +}
61257 +
61258 +
61259 +#ifdef CONFIG_NETFILTER_XT_MATCH_GRADM_MODULE
61260 +EXPORT_SYMBOL(gr_acl_is_enabled);
61261 +#endif
61262 +EXPORT_SYMBOL(gr_set_kernel_label);
61263 +#ifdef CONFIG_SECURITY
61264 +EXPORT_SYMBOL(gr_check_user_change);
61265 +EXPORT_SYMBOL(gr_check_group_change);
61266 +#endif
61267 +
61268 diff --git a/grsecurity/gracl_alloc.c b/grsecurity/gracl_alloc.c
61269 new file mode 100644
61270 index 0000000..34fefda
61271 --- /dev/null
61272 +++ b/grsecurity/gracl_alloc.c
61273 @@ -0,0 +1,105 @@
61274 +#include <linux/kernel.h>
61275 +#include <linux/mm.h>
61276 +#include <linux/slab.h>
61277 +#include <linux/vmalloc.h>
61278 +#include <linux/gracl.h>
61279 +#include <linux/grsecurity.h>
61280 +
61281 +static unsigned long alloc_stack_next = 1;
61282 +static unsigned long alloc_stack_size = 1;
61283 +static void **alloc_stack;
61284 +
61285 +static __inline__ int
61286 +alloc_pop(void)
61287 +{
61288 + if (alloc_stack_next == 1)
61289 + return 0;
61290 +
61291 + kfree(alloc_stack[alloc_stack_next - 2]);
61292 +
61293 + alloc_stack_next--;
61294 +
61295 + return 1;
61296 +}
61297 +
61298 +static __inline__ int
61299 +alloc_push(void *buf)
61300 +{
61301 + if (alloc_stack_next >= alloc_stack_size)
61302 + return 1;
61303 +
61304 + alloc_stack[alloc_stack_next - 1] = buf;
61305 +
61306 + alloc_stack_next++;
61307 +
61308 + return 0;
61309 +}
61310 +
61311 +void *
61312 +acl_alloc(unsigned long len)
61313 +{
61314 + void *ret = NULL;
61315 +
61316 + if (!len || len > PAGE_SIZE)
61317 + goto out;
61318 +
61319 + ret = kmalloc(len, GFP_KERNEL);
61320 +
61321 + if (ret) {
61322 + if (alloc_push(ret)) {
61323 + kfree(ret);
61324 + ret = NULL;
61325 + }
61326 + }
61327 +
61328 +out:
61329 + return ret;
61330 +}
61331 +
61332 +void *
61333 +acl_alloc_num(unsigned long num, unsigned long len)
61334 +{
61335 + if (!len || (num > (PAGE_SIZE / len)))
61336 + return NULL;
61337 +
61338 + return acl_alloc(num * len);
61339 +}
61340 +
61341 +void
61342 +acl_free_all(void)
61343 +{
61344 + if (gr_acl_is_enabled() || !alloc_stack)
61345 + return;
61346 +
61347 + while (alloc_pop()) ;
61348 +
61349 + if (alloc_stack) {
61350 + if ((alloc_stack_size * sizeof (void *)) <= PAGE_SIZE)
61351 + kfree(alloc_stack);
61352 + else
61353 + vfree(alloc_stack);
61354 + }
61355 +
61356 + alloc_stack = NULL;
61357 + alloc_stack_size = 1;
61358 + alloc_stack_next = 1;
61359 +
61360 + return;
61361 +}
61362 +
61363 +int
61364 +acl_alloc_stack_init(unsigned long size)
61365 +{
61366 + if ((size * sizeof (void *)) <= PAGE_SIZE)
61367 + alloc_stack =
61368 + (void **) kmalloc(size * sizeof (void *), GFP_KERNEL);
61369 + else
61370 + alloc_stack = (void **) vmalloc(size * sizeof (void *));
61371 +
61372 + alloc_stack_size = size;
61373 +
61374 + if (!alloc_stack)
61375 + return 0;
61376 + else
61377 + return 1;
61378 +}
61379 diff --git a/grsecurity/gracl_cap.c b/grsecurity/gracl_cap.c
61380 new file mode 100644
61381 index 0000000..bdd51ea
61382 --- /dev/null
61383 +++ b/grsecurity/gracl_cap.c
61384 @@ -0,0 +1,110 @@
61385 +#include <linux/kernel.h>
61386 +#include <linux/module.h>
61387 +#include <linux/sched.h>
61388 +#include <linux/gracl.h>
61389 +#include <linux/grsecurity.h>
61390 +#include <linux/grinternal.h>
61391 +
61392 +extern const char *captab_log[];
61393 +extern int captab_log_entries;
61394 +
61395 +int gr_task_acl_is_capable(const struct task_struct *task, const struct cred *cred, const int cap)
61396 +{
61397 + struct acl_subject_label *curracl;
61398 + kernel_cap_t cap_drop = __cap_empty_set, cap_mask = __cap_empty_set;
61399 + kernel_cap_t cap_audit = __cap_empty_set;
61400 +
61401 + if (!gr_acl_is_enabled())
61402 + return 1;
61403 +
61404 + curracl = task->acl;
61405 +
61406 + cap_drop = curracl->cap_lower;
61407 + cap_mask = curracl->cap_mask;
61408 + cap_audit = curracl->cap_invert_audit;
61409 +
61410 + while ((curracl = curracl->parent_subject)) {
61411 + /* if the cap isn't specified in the current computed mask but is specified in the
61412 + current level subject, and is lowered in the current level subject, then add
61413 + it to the set of dropped capabilities
61414 + otherwise, add the current level subject's mask to the current computed mask
61415 + */
61416 + if (!cap_raised(cap_mask, cap) && cap_raised(curracl->cap_mask, cap)) {
61417 + cap_raise(cap_mask, cap);
61418 + if (cap_raised(curracl->cap_lower, cap))
61419 + cap_raise(cap_drop, cap);
61420 + if (cap_raised(curracl->cap_invert_audit, cap))
61421 + cap_raise(cap_audit, cap);
61422 + }
61423 + }
61424 +
61425 + if (!cap_raised(cap_drop, cap)) {
61426 + if (cap_raised(cap_audit, cap))
61427 + gr_log_cap(GR_DO_AUDIT, GR_CAP_ACL_MSG2, task, captab_log[cap]);
61428 + return 1;
61429 + }
61430 +
61431 + curracl = task->acl;
61432 +
61433 + if ((curracl->mode & (GR_LEARN | GR_INHERITLEARN))
61434 + && cap_raised(cred->cap_effective, cap)) {
61435 + security_learn(GR_LEARN_AUDIT_MSG, task->role->rolename,
61436 + task->role->roletype, GR_GLOBAL_UID(cred->uid),
61437 + GR_GLOBAL_GID(cred->gid), task->exec_file ?
61438 + gr_to_filename(task->exec_file->f_path.dentry,
61439 + task->exec_file->f_path.mnt) : curracl->filename,
61440 + curracl->filename, 0UL,
61441 + 0UL, "", (unsigned long) cap, &task->signal->saved_ip);
61442 + return 1;
61443 + }
61444 +
61445 + if ((cap >= 0) && (cap < captab_log_entries) && cap_raised(cred->cap_effective, cap) && !cap_raised(cap_audit, cap))
61446 + gr_log_cap(GR_DONT_AUDIT, GR_CAP_ACL_MSG, task, captab_log[cap]);
61447 +
61448 + return 0;
61449 +}
61450 +
61451 +int
61452 +gr_acl_is_capable(const int cap)
61453 +{
61454 + return gr_task_acl_is_capable(current, current_cred(), cap);
61455 +}
61456 +
61457 +int gr_task_acl_is_capable_nolog(const struct task_struct *task, const int cap)
61458 +{
61459 + struct acl_subject_label *curracl;
61460 + kernel_cap_t cap_drop = __cap_empty_set, cap_mask = __cap_empty_set;
61461 +
61462 + if (!gr_acl_is_enabled())
61463 + return 1;
61464 +
61465 + curracl = task->acl;
61466 +
61467 + cap_drop = curracl->cap_lower;
61468 + cap_mask = curracl->cap_mask;
61469 +
61470 + while ((curracl = curracl->parent_subject)) {
61471 + /* if the cap isn't specified in the current computed mask but is specified in the
61472 + current level subject, and is lowered in the current level subject, then add
61473 + it to the set of dropped capabilities
61474 + otherwise, add the current level subject's mask to the current computed mask
61475 + */
61476 + if (!cap_raised(cap_mask, cap) && cap_raised(curracl->cap_mask, cap)) {
61477 + cap_raise(cap_mask, cap);
61478 + if (cap_raised(curracl->cap_lower, cap))
61479 + cap_raise(cap_drop, cap);
61480 + }
61481 + }
61482 +
61483 + if (!cap_raised(cap_drop, cap))
61484 + return 1;
61485 +
61486 + return 0;
61487 +}
61488 +
61489 +int
61490 +gr_acl_is_capable_nolog(const int cap)
61491 +{
61492 + return gr_task_acl_is_capable_nolog(current, cap);
61493 +}
61494 +
61495 diff --git a/grsecurity/gracl_fs.c b/grsecurity/gracl_fs.c
61496 new file mode 100644
61497 index 0000000..a340c17
61498 --- /dev/null
61499 +++ b/grsecurity/gracl_fs.c
61500 @@ -0,0 +1,431 @@
61501 +#include <linux/kernel.h>
61502 +#include <linux/sched.h>
61503 +#include <linux/types.h>
61504 +#include <linux/fs.h>
61505 +#include <linux/file.h>
61506 +#include <linux/stat.h>
61507 +#include <linux/grsecurity.h>
61508 +#include <linux/grinternal.h>
61509 +#include <linux/gracl.h>
61510 +
61511 +umode_t
61512 +gr_acl_umask(void)
61513 +{
61514 + if (unlikely(!gr_acl_is_enabled()))
61515 + return 0;
61516 +
61517 + return current->role->umask;
61518 +}
61519 +
61520 +__u32
61521 +gr_acl_handle_hidden_file(const struct dentry * dentry,
61522 + const struct vfsmount * mnt)
61523 +{
61524 + __u32 mode;
61525 +
61526 + if (unlikely(!dentry->d_inode))
61527 + return GR_FIND;
61528 +
61529 + mode =
61530 + gr_search_file(dentry, GR_FIND | GR_AUDIT_FIND | GR_SUPPRESS, mnt);
61531 +
61532 + if (unlikely(mode & GR_FIND && mode & GR_AUDIT_FIND)) {
61533 + gr_log_fs_rbac_generic(GR_DO_AUDIT, GR_HIDDEN_ACL_MSG, dentry, mnt);
61534 + return mode;
61535 + } else if (unlikely(!(mode & GR_FIND) && !(mode & GR_SUPPRESS))) {
61536 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, GR_HIDDEN_ACL_MSG, dentry, mnt);
61537 + return 0;
61538 + } else if (unlikely(!(mode & GR_FIND)))
61539 + return 0;
61540 +
61541 + return GR_FIND;
61542 +}
61543 +
61544 +__u32
61545 +gr_acl_handle_open(const struct dentry * dentry, const struct vfsmount * mnt,
61546 + int acc_mode)
61547 +{
61548 + __u32 reqmode = GR_FIND;
61549 + __u32 mode;
61550 +
61551 + if (unlikely(!dentry->d_inode))
61552 + return reqmode;
61553 +
61554 + if (acc_mode & MAY_APPEND)
61555 + reqmode |= GR_APPEND;
61556 + else if (acc_mode & MAY_WRITE)
61557 + reqmode |= GR_WRITE;
61558 + if ((acc_mode & MAY_READ) && !S_ISDIR(dentry->d_inode->i_mode))
61559 + reqmode |= GR_READ;
61560 +
61561 + mode =
61562 + gr_search_file(dentry, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS,
61563 + mnt);
61564 +
61565 + if (unlikely(((mode & reqmode) == reqmode) && mode & GR_AUDITS)) {
61566 + gr_log_fs_rbac_mode2(GR_DO_AUDIT, GR_OPEN_ACL_MSG, dentry, mnt,
61567 + reqmode & GR_READ ? " reading" : "",
61568 + reqmode & GR_WRITE ? " writing" : reqmode &
61569 + GR_APPEND ? " appending" : "");
61570 + return reqmode;
61571 + } else
61572 + if (unlikely((mode & reqmode) != reqmode && !(mode & GR_SUPPRESS)))
61573 + {
61574 + gr_log_fs_rbac_mode2(GR_DONT_AUDIT, GR_OPEN_ACL_MSG, dentry, mnt,
61575 + reqmode & GR_READ ? " reading" : "",
61576 + reqmode & GR_WRITE ? " writing" : reqmode &
61577 + GR_APPEND ? " appending" : "");
61578 + return 0;
61579 + } else if (unlikely((mode & reqmode) != reqmode))
61580 + return 0;
61581 +
61582 + return reqmode;
61583 +}
61584 +
61585 +__u32
61586 +gr_acl_handle_creat(const struct dentry * dentry,
61587 + const struct dentry * p_dentry,
61588 + const struct vfsmount * p_mnt, int open_flags, int acc_mode,
61589 + const int imode)
61590 +{
61591 + __u32 reqmode = GR_WRITE | GR_CREATE;
61592 + __u32 mode;
61593 +
61594 + if (acc_mode & MAY_APPEND)
61595 + reqmode |= GR_APPEND;
61596 + // if a directory was required or the directory already exists, then
61597 + // don't count this open as a read
61598 + if ((acc_mode & MAY_READ) &&
61599 + !((open_flags & O_DIRECTORY) || (dentry->d_inode && S_ISDIR(dentry->d_inode->i_mode))))
61600 + reqmode |= GR_READ;
61601 + if ((open_flags & O_CREAT) &&
61602 + ((imode & S_ISUID) || ((imode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))))
61603 + reqmode |= GR_SETID;
61604 +
61605 + mode =
61606 + gr_check_create(dentry, p_dentry, p_mnt,
61607 + reqmode | to_gr_audit(reqmode) | GR_SUPPRESS);
61608 +
61609 + if (unlikely(((mode & reqmode) == reqmode) && mode & GR_AUDITS)) {
61610 + gr_log_fs_rbac_mode2(GR_DO_AUDIT, GR_CREATE_ACL_MSG, dentry, p_mnt,
61611 + reqmode & GR_READ ? " reading" : "",
61612 + reqmode & GR_WRITE ? " writing" : reqmode &
61613 + GR_APPEND ? " appending" : "");
61614 + return reqmode;
61615 + } else
61616 + if (unlikely((mode & reqmode) != reqmode && !(mode & GR_SUPPRESS)))
61617 + {
61618 + gr_log_fs_rbac_mode2(GR_DONT_AUDIT, GR_CREATE_ACL_MSG, dentry, p_mnt,
61619 + reqmode & GR_READ ? " reading" : "",
61620 + reqmode & GR_WRITE ? " writing" : reqmode &
61621 + GR_APPEND ? " appending" : "");
61622 + return 0;
61623 + } else if (unlikely((mode & reqmode) != reqmode))
61624 + return 0;
61625 +
61626 + return reqmode;
61627 +}
61628 +
61629 +__u32
61630 +gr_acl_handle_access(const struct dentry * dentry, const struct vfsmount * mnt,
61631 + const int fmode)
61632 +{
61633 + __u32 mode, reqmode = GR_FIND;
61634 +
61635 + if ((fmode & S_IXOTH) && !S_ISDIR(dentry->d_inode->i_mode))
61636 + reqmode |= GR_EXEC;
61637 + if (fmode & S_IWOTH)
61638 + reqmode |= GR_WRITE;
61639 + if (fmode & S_IROTH)
61640 + reqmode |= GR_READ;
61641 +
61642 + mode =
61643 + gr_search_file(dentry, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS,
61644 + mnt);
61645 +
61646 + if (unlikely(((mode & reqmode) == reqmode) && mode & GR_AUDITS)) {
61647 + gr_log_fs_rbac_mode3(GR_DO_AUDIT, GR_ACCESS_ACL_MSG, dentry, mnt,
61648 + reqmode & GR_READ ? " reading" : "",
61649 + reqmode & GR_WRITE ? " writing" : "",
61650 + reqmode & GR_EXEC ? " executing" : "");
61651 + return reqmode;
61652 + } else
61653 + if (unlikely((mode & reqmode) != reqmode && !(mode & GR_SUPPRESS)))
61654 + {
61655 + gr_log_fs_rbac_mode3(GR_DONT_AUDIT, GR_ACCESS_ACL_MSG, dentry, mnt,
61656 + reqmode & GR_READ ? " reading" : "",
61657 + reqmode & GR_WRITE ? " writing" : "",
61658 + reqmode & GR_EXEC ? " executing" : "");
61659 + return 0;
61660 + } else if (unlikely((mode & reqmode) != reqmode))
61661 + return 0;
61662 +
61663 + return reqmode;
61664 +}
61665 +
61666 +static __u32 generic_fs_handler(const struct dentry *dentry, const struct vfsmount *mnt, __u32 reqmode, const char *fmt)
61667 +{
61668 + __u32 mode;
61669 +
61670 + mode = gr_search_file(dentry, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS, mnt);
61671 +
61672 + if (unlikely(((mode & (reqmode)) == (reqmode)) && mode & GR_AUDITS)) {
61673 + gr_log_fs_rbac_generic(GR_DO_AUDIT, fmt, dentry, mnt);
61674 + return mode;
61675 + } else if (unlikely((mode & (reqmode)) != (reqmode) && !(mode & GR_SUPPRESS))) {
61676 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, fmt, dentry, mnt);
61677 + return 0;
61678 + } else if (unlikely((mode & (reqmode)) != (reqmode)))
61679 + return 0;
61680 +
61681 + return (reqmode);
61682 +}
61683 +
61684 +__u32
61685 +gr_acl_handle_rmdir(const struct dentry * dentry, const struct vfsmount * mnt)
61686 +{
61687 + return generic_fs_handler(dentry, mnt, GR_WRITE | GR_DELETE , GR_RMDIR_ACL_MSG);
61688 +}
61689 +
61690 +__u32
61691 +gr_acl_handle_unlink(const struct dentry *dentry, const struct vfsmount *mnt)
61692 +{
61693 + return generic_fs_handler(dentry, mnt, GR_WRITE | GR_DELETE , GR_UNLINK_ACL_MSG);
61694 +}
61695 +
61696 +__u32
61697 +gr_acl_handle_truncate(const struct dentry *dentry, const struct vfsmount *mnt)
61698 +{
61699 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_TRUNCATE_ACL_MSG);
61700 +}
61701 +
61702 +__u32
61703 +gr_acl_handle_utime(const struct dentry *dentry, const struct vfsmount *mnt)
61704 +{
61705 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_ATIME_ACL_MSG);
61706 +}
61707 +
61708 +__u32
61709 +gr_acl_handle_chmod(const struct dentry *dentry, const struct vfsmount *mnt,
61710 + umode_t *modeptr)
61711 +{
61712 + umode_t mode;
61713 +
61714 + *modeptr &= ~gr_acl_umask();
61715 + mode = *modeptr;
61716 +
61717 + if (unlikely(dentry->d_inode && S_ISSOCK(dentry->d_inode->i_mode)))
61718 + return 1;
61719 +
61720 + if (unlikely(dentry->d_inode && !S_ISDIR(dentry->d_inode->i_mode) &&
61721 + ((mode & S_ISUID) || ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))))) {
61722 + return generic_fs_handler(dentry, mnt, GR_WRITE | GR_SETID,
61723 + GR_CHMOD_ACL_MSG);
61724 + } else {
61725 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_CHMOD_ACL_MSG);
61726 + }
61727 +}
61728 +
61729 +__u32
61730 +gr_acl_handle_chown(const struct dentry *dentry, const struct vfsmount *mnt)
61731 +{
61732 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_CHOWN_ACL_MSG);
61733 +}
61734 +
61735 +__u32
61736 +gr_acl_handle_setxattr(const struct dentry *dentry, const struct vfsmount *mnt)
61737 +{
61738 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_SETXATTR_ACL_MSG);
61739 +}
61740 +
61741 +__u32
61742 +gr_acl_handle_execve(const struct dentry *dentry, const struct vfsmount *mnt)
61743 +{
61744 + return generic_fs_handler(dentry, mnt, GR_EXEC, GR_EXEC_ACL_MSG);
61745 +}
61746 +
61747 +__u32
61748 +gr_acl_handle_unix(const struct dentry *dentry, const struct vfsmount *mnt)
61749 +{
61750 + return generic_fs_handler(dentry, mnt, GR_READ | GR_WRITE,
61751 + GR_UNIXCONNECT_ACL_MSG);
61752 +}
61753 +
61754 +/* hardlinks require at minimum create and link permission,
61755 + any additional privilege required is based on the
61756 + privilege of the file being linked to
61757 +*/
61758 +__u32
61759 +gr_acl_handle_link(const struct dentry * new_dentry,
61760 + const struct dentry * parent_dentry,
61761 + const struct vfsmount * parent_mnt,
61762 + const struct dentry * old_dentry,
61763 + const struct vfsmount * old_mnt, const struct filename *to)
61764 +{
61765 + __u32 mode;
61766 + __u32 needmode = GR_CREATE | GR_LINK;
61767 + __u32 needaudit = GR_AUDIT_CREATE | GR_AUDIT_LINK;
61768 +
61769 + mode =
61770 + gr_check_link(new_dentry, parent_dentry, parent_mnt, old_dentry,
61771 + old_mnt);
61772 +
61773 + if (unlikely(((mode & needmode) == needmode) && (mode & needaudit))) {
61774 + gr_log_fs_rbac_str(GR_DO_AUDIT, GR_LINK_ACL_MSG, old_dentry, old_mnt, to->name);
61775 + return mode;
61776 + } else if (unlikely(((mode & needmode) != needmode) && !(mode & GR_SUPPRESS))) {
61777 + gr_log_fs_rbac_str(GR_DONT_AUDIT, GR_LINK_ACL_MSG, old_dentry, old_mnt, to->name);
61778 + return 0;
61779 + } else if (unlikely((mode & needmode) != needmode))
61780 + return 0;
61781 +
61782 + return 1;
61783 +}
61784 +
61785 +__u32
61786 +gr_acl_handle_symlink(const struct dentry * new_dentry,
61787 + const struct dentry * parent_dentry,
61788 + const struct vfsmount * parent_mnt, const struct filename *from)
61789 +{
61790 + __u32 needmode = GR_WRITE | GR_CREATE;
61791 + __u32 mode;
61792 +
61793 + mode =
61794 + gr_check_create(new_dentry, parent_dentry, parent_mnt,
61795 + GR_CREATE | GR_AUDIT_CREATE |
61796 + GR_WRITE | GR_AUDIT_WRITE | GR_SUPPRESS);
61797 +
61798 + if (unlikely(mode & GR_WRITE && mode & GR_AUDITS)) {
61799 + gr_log_fs_str_rbac(GR_DO_AUDIT, GR_SYMLINK_ACL_MSG, from->name, new_dentry, parent_mnt);
61800 + return mode;
61801 + } else if (unlikely(((mode & needmode) != needmode) && !(mode & GR_SUPPRESS))) {
61802 + gr_log_fs_str_rbac(GR_DONT_AUDIT, GR_SYMLINK_ACL_MSG, from->name, new_dentry, parent_mnt);
61803 + return 0;
61804 + } else if (unlikely((mode & needmode) != needmode))
61805 + return 0;
61806 +
61807 + return (GR_WRITE | GR_CREATE);
61808 +}
61809 +
61810 +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)
61811 +{
61812 + __u32 mode;
61813 +
61814 + mode = gr_check_create(new_dentry, parent_dentry, parent_mnt, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS);
61815 +
61816 + if (unlikely(((mode & (reqmode)) == (reqmode)) && mode & GR_AUDITS)) {
61817 + gr_log_fs_rbac_generic(GR_DO_AUDIT, fmt, new_dentry, parent_mnt);
61818 + return mode;
61819 + } else if (unlikely((mode & (reqmode)) != (reqmode) && !(mode & GR_SUPPRESS))) {
61820 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, fmt, new_dentry, parent_mnt);
61821 + return 0;
61822 + } else if (unlikely((mode & (reqmode)) != (reqmode)))
61823 + return 0;
61824 +
61825 + return (reqmode);
61826 +}
61827 +
61828 +__u32
61829 +gr_acl_handle_mknod(const struct dentry * new_dentry,
61830 + const struct dentry * parent_dentry,
61831 + const struct vfsmount * parent_mnt,
61832 + const int mode)
61833 +{
61834 + __u32 reqmode = GR_WRITE | GR_CREATE;
61835 + if (unlikely((mode & S_ISUID) || ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))))
61836 + reqmode |= GR_SETID;
61837 +
61838 + return generic_fs_create_handler(new_dentry, parent_dentry, parent_mnt,
61839 + reqmode, GR_MKNOD_ACL_MSG);
61840 +}
61841 +
61842 +__u32
61843 +gr_acl_handle_mkdir(const struct dentry *new_dentry,
61844 + const struct dentry *parent_dentry,
61845 + const struct vfsmount *parent_mnt)
61846 +{
61847 + return generic_fs_create_handler(new_dentry, parent_dentry, parent_mnt,
61848 + GR_WRITE | GR_CREATE, GR_MKDIR_ACL_MSG);
61849 +}
61850 +
61851 +#define RENAME_CHECK_SUCCESS(old, new) \
61852 + (((old & (GR_WRITE | GR_READ)) == (GR_WRITE | GR_READ)) && \
61853 + ((new & (GR_WRITE | GR_READ)) == (GR_WRITE | GR_READ)))
61854 +
61855 +int
61856 +gr_acl_handle_rename(struct dentry *new_dentry,
61857 + struct dentry *parent_dentry,
61858 + const struct vfsmount *parent_mnt,
61859 + struct dentry *old_dentry,
61860 + struct inode *old_parent_inode,
61861 + struct vfsmount *old_mnt, const struct filename *newname)
61862 +{
61863 + __u32 comp1, comp2;
61864 + int error = 0;
61865 +
61866 + if (unlikely(!gr_acl_is_enabled()))
61867 + return 0;
61868 +
61869 + if (!new_dentry->d_inode) {
61870 + comp1 = gr_check_create(new_dentry, parent_dentry, parent_mnt,
61871 + GR_READ | GR_WRITE | GR_CREATE | GR_AUDIT_READ |
61872 + GR_AUDIT_WRITE | GR_AUDIT_CREATE | GR_SUPPRESS);
61873 + comp2 = gr_search_file(old_dentry, GR_READ | GR_WRITE |
61874 + GR_DELETE | GR_AUDIT_DELETE |
61875 + GR_AUDIT_READ | GR_AUDIT_WRITE |
61876 + GR_SUPPRESS, old_mnt);
61877 + } else {
61878 + comp1 = gr_search_file(new_dentry, GR_READ | GR_WRITE |
61879 + GR_CREATE | GR_DELETE |
61880 + GR_AUDIT_CREATE | GR_AUDIT_DELETE |
61881 + GR_AUDIT_READ | GR_AUDIT_WRITE |
61882 + GR_SUPPRESS, parent_mnt);
61883 + comp2 =
61884 + gr_search_file(old_dentry,
61885 + GR_READ | GR_WRITE | GR_AUDIT_READ |
61886 + GR_DELETE | GR_AUDIT_DELETE |
61887 + GR_AUDIT_WRITE | GR_SUPPRESS, old_mnt);
61888 + }
61889 +
61890 + if (RENAME_CHECK_SUCCESS(comp1, comp2) &&
61891 + ((comp1 & GR_AUDITS) || (comp2 & GR_AUDITS)))
61892 + gr_log_fs_rbac_str(GR_DO_AUDIT, GR_RENAME_ACL_MSG, old_dentry, old_mnt, newname->name);
61893 + else if (!RENAME_CHECK_SUCCESS(comp1, comp2) && !(comp1 & GR_SUPPRESS)
61894 + && !(comp2 & GR_SUPPRESS)) {
61895 + gr_log_fs_rbac_str(GR_DONT_AUDIT, GR_RENAME_ACL_MSG, old_dentry, old_mnt, newname->name);
61896 + error = -EACCES;
61897 + } else if (unlikely(!RENAME_CHECK_SUCCESS(comp1, comp2)))
61898 + error = -EACCES;
61899 +
61900 + return error;
61901 +}
61902 +
61903 +void
61904 +gr_acl_handle_exit(void)
61905 +{
61906 + u16 id;
61907 + char *rolename;
61908 +
61909 + if (unlikely(current->acl_sp_role && gr_acl_is_enabled() &&
61910 + !(current->role->roletype & GR_ROLE_PERSIST))) {
61911 + id = current->acl_role_id;
61912 + rolename = current->role->rolename;
61913 + gr_set_acls(1);
61914 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_SPROLEL_ACL_MSG, rolename, id);
61915 + }
61916 +
61917 + gr_put_exec_file(current);
61918 + return;
61919 +}
61920 +
61921 +int
61922 +gr_acl_handle_procpidmem(const struct task_struct *task)
61923 +{
61924 + if (unlikely(!gr_acl_is_enabled()))
61925 + return 0;
61926 +
61927 + if (task != current && task->acl->mode & GR_PROTPROCFD)
61928 + return -EACCES;
61929 +
61930 + return 0;
61931 +}
61932 diff --git a/grsecurity/gracl_ip.c b/grsecurity/gracl_ip.c
61933 new file mode 100644
61934 index 0000000..4699807
61935 --- /dev/null
61936 +++ b/grsecurity/gracl_ip.c
61937 @@ -0,0 +1,384 @@
61938 +#include <linux/kernel.h>
61939 +#include <asm/uaccess.h>
61940 +#include <asm/errno.h>
61941 +#include <net/sock.h>
61942 +#include <linux/file.h>
61943 +#include <linux/fs.h>
61944 +#include <linux/net.h>
61945 +#include <linux/in.h>
61946 +#include <linux/skbuff.h>
61947 +#include <linux/ip.h>
61948 +#include <linux/udp.h>
61949 +#include <linux/types.h>
61950 +#include <linux/sched.h>
61951 +#include <linux/netdevice.h>
61952 +#include <linux/inetdevice.h>
61953 +#include <linux/gracl.h>
61954 +#include <linux/grsecurity.h>
61955 +#include <linux/grinternal.h>
61956 +
61957 +#define GR_BIND 0x01
61958 +#define GR_CONNECT 0x02
61959 +#define GR_INVERT 0x04
61960 +#define GR_BINDOVERRIDE 0x08
61961 +#define GR_CONNECTOVERRIDE 0x10
61962 +#define GR_SOCK_FAMILY 0x20
61963 +
61964 +static const char * gr_protocols[IPPROTO_MAX] = {
61965 + "ip", "icmp", "igmp", "ggp", "ipencap", "st", "tcp", "cbt",
61966 + "egp", "igp", "bbn-rcc", "nvp", "pup", "argus", "emcon", "xnet",
61967 + "chaos", "udp", "mux", "dcn", "hmp", "prm", "xns-idp", "trunk-1",
61968 + "trunk-2", "leaf-1", "leaf-2", "rdp", "irtp", "iso-tp4", "netblt", "mfe-nsp",
61969 + "merit-inp", "sep", "3pc", "idpr", "xtp", "ddp", "idpr-cmtp", "tp++",
61970 + "il", "ipv6", "sdrp", "ipv6-route", "ipv6-frag", "idrp", "rsvp", "gre",
61971 + "mhrp", "bna", "ipv6-crypt", "ipv6-auth", "i-nlsp", "swipe", "narp", "mobile",
61972 + "tlsp", "skip", "ipv6-icmp", "ipv6-nonxt", "ipv6-opts", "unknown:61", "cftp", "unknown:63",
61973 + "sat-expak", "kryptolan", "rvd", "ippc", "unknown:68", "sat-mon", "visa", "ipcv",
61974 + "cpnx", "cphb", "wsn", "pvp", "br-sat-mon", "sun-nd", "wb-mon", "wb-expak",
61975 + "iso-ip", "vmtp", "secure-vmtp", "vines", "ttp", "nfsnet-igp", "dgp", "tcf",
61976 + "eigrp", "ospf", "sprite-rpc", "larp", "mtp", "ax.25", "ipip", "micp",
61977 + "scc-sp", "etherip", "encap", "unknown:99", "gmtp", "ifmp", "pnni", "pim",
61978 + "aris", "scps", "qnx", "a/n", "ipcomp", "snp", "compaq-peer", "ipx-in-ip",
61979 + "vrrp", "pgm", "unknown:114", "l2tp", "ddx", "iatp", "stp", "srp",
61980 + "uti", "smp", "sm", "ptp", "isis", "fire", "crtp", "crdup",
61981 + "sscopmce", "iplt", "sps", "pipe", "sctp", "fc", "unkown:134", "unknown:135",
61982 + "unknown:136", "unknown:137", "unknown:138", "unknown:139", "unknown:140", "unknown:141", "unknown:142", "unknown:143",
61983 + "unknown:144", "unknown:145", "unknown:146", "unknown:147", "unknown:148", "unknown:149", "unknown:150", "unknown:151",
61984 + "unknown:152", "unknown:153", "unknown:154", "unknown:155", "unknown:156", "unknown:157", "unknown:158", "unknown:159",
61985 + "unknown:160", "unknown:161", "unknown:162", "unknown:163", "unknown:164", "unknown:165", "unknown:166", "unknown:167",
61986 + "unknown:168", "unknown:169", "unknown:170", "unknown:171", "unknown:172", "unknown:173", "unknown:174", "unknown:175",
61987 + "unknown:176", "unknown:177", "unknown:178", "unknown:179", "unknown:180", "unknown:181", "unknown:182", "unknown:183",
61988 + "unknown:184", "unknown:185", "unknown:186", "unknown:187", "unknown:188", "unknown:189", "unknown:190", "unknown:191",
61989 + "unknown:192", "unknown:193", "unknown:194", "unknown:195", "unknown:196", "unknown:197", "unknown:198", "unknown:199",
61990 + "unknown:200", "unknown:201", "unknown:202", "unknown:203", "unknown:204", "unknown:205", "unknown:206", "unknown:207",
61991 + "unknown:208", "unknown:209", "unknown:210", "unknown:211", "unknown:212", "unknown:213", "unknown:214", "unknown:215",
61992 + "unknown:216", "unknown:217", "unknown:218", "unknown:219", "unknown:220", "unknown:221", "unknown:222", "unknown:223",
61993 + "unknown:224", "unknown:225", "unknown:226", "unknown:227", "unknown:228", "unknown:229", "unknown:230", "unknown:231",
61994 + "unknown:232", "unknown:233", "unknown:234", "unknown:235", "unknown:236", "unknown:237", "unknown:238", "unknown:239",
61995 + "unknown:240", "unknown:241", "unknown:242", "unknown:243", "unknown:244", "unknown:245", "unknown:246", "unknown:247",
61996 + "unknown:248", "unknown:249", "unknown:250", "unknown:251", "unknown:252", "unknown:253", "unknown:254", "unknown:255",
61997 + };
61998 +
61999 +static const char * gr_socktypes[SOCK_MAX] = {
62000 + "unknown:0", "stream", "dgram", "raw", "rdm", "seqpacket", "unknown:6",
62001 + "unknown:7", "unknown:8", "unknown:9", "packet"
62002 + };
62003 +
62004 +static const char * gr_sockfamilies[AF_MAX+1] = {
62005 + "unspec", "unix", "inet", "ax25", "ipx", "appletalk", "netrom", "bridge", "atmpvc", "x25",
62006 + "inet6", "rose", "decnet", "netbeui", "security", "key", "netlink", "packet", "ash",
62007 + "econet", "atmsvc", "rds", "sna", "irda", "ppox", "wanpipe", "llc", "fam_27", "fam_28",
62008 + "tipc", "bluetooth", "iucv", "rxrpc", "isdn", "phonet", "ieee802154", "ciaf"
62009 + };
62010 +
62011 +const char *
62012 +gr_proto_to_name(unsigned char proto)
62013 +{
62014 + return gr_protocols[proto];
62015 +}
62016 +
62017 +const char *
62018 +gr_socktype_to_name(unsigned char type)
62019 +{
62020 + return gr_socktypes[type];
62021 +}
62022 +
62023 +const char *
62024 +gr_sockfamily_to_name(unsigned char family)
62025 +{
62026 + return gr_sockfamilies[family];
62027 +}
62028 +
62029 +int
62030 +gr_search_socket(const int domain, const int type, const int protocol)
62031 +{
62032 + struct acl_subject_label *curr;
62033 + const struct cred *cred = current_cred();
62034 +
62035 + if (unlikely(!gr_acl_is_enabled()))
62036 + goto exit;
62037 +
62038 + if ((domain < 0) || (type < 0) || (protocol < 0) ||
62039 + (domain >= AF_MAX) || (type >= SOCK_MAX) || (protocol >= IPPROTO_MAX))
62040 + goto exit; // let the kernel handle it
62041 +
62042 + curr = current->acl;
62043 +
62044 + if (curr->sock_families[domain / 32] & (1 << (domain % 32))) {
62045 + /* the family is allowed, if this is PF_INET allow it only if
62046 + the extra sock type/protocol checks pass */
62047 + if (domain == PF_INET)
62048 + goto inet_check;
62049 + goto exit;
62050 + } else {
62051 + if (curr->mode & (GR_LEARN | GR_INHERITLEARN)) {
62052 + __u32 fakeip = 0;
62053 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
62054 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
62055 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
62056 + gr_to_filename(current->exec_file->f_path.dentry,
62057 + current->exec_file->f_path.mnt) :
62058 + curr->filename, curr->filename,
62059 + &fakeip, domain, 0, 0, GR_SOCK_FAMILY,
62060 + &current->signal->saved_ip);
62061 + goto exit;
62062 + }
62063 + goto exit_fail;
62064 + }
62065 +
62066 +inet_check:
62067 + /* the rest of this checking is for IPv4 only */
62068 + if (!curr->ips)
62069 + goto exit;
62070 +
62071 + if ((curr->ip_type & (1 << type)) &&
62072 + (curr->ip_proto[protocol / 32] & (1 << (protocol % 32))))
62073 + goto exit;
62074 +
62075 + if (curr->mode & (GR_LEARN | GR_INHERITLEARN)) {
62076 + /* we don't place acls on raw sockets , and sometimes
62077 + dgram/ip sockets are opened for ioctl and not
62078 + bind/connect, so we'll fake a bind learn log */
62079 + if (type == SOCK_RAW || type == SOCK_PACKET) {
62080 + __u32 fakeip = 0;
62081 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
62082 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
62083 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
62084 + gr_to_filename(current->exec_file->f_path.dentry,
62085 + current->exec_file->f_path.mnt) :
62086 + curr->filename, curr->filename,
62087 + &fakeip, 0, type,
62088 + protocol, GR_CONNECT, &current->signal->saved_ip);
62089 + } else if ((type == SOCK_DGRAM) && (protocol == IPPROTO_IP)) {
62090 + __u32 fakeip = 0;
62091 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
62092 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
62093 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
62094 + gr_to_filename(current->exec_file->f_path.dentry,
62095 + current->exec_file->f_path.mnt) :
62096 + curr->filename, curr->filename,
62097 + &fakeip, 0, type,
62098 + protocol, GR_BIND, &current->signal->saved_ip);
62099 + }
62100 + /* we'll log when they use connect or bind */
62101 + goto exit;
62102 + }
62103 +
62104 +exit_fail:
62105 + if (domain == PF_INET)
62106 + gr_log_str3(GR_DONT_AUDIT, GR_SOCK_MSG, gr_sockfamily_to_name(domain),
62107 + gr_socktype_to_name(type), gr_proto_to_name(protocol));
62108 + else
62109 + gr_log_str2_int(GR_DONT_AUDIT, GR_SOCK_NOINET_MSG, gr_sockfamily_to_name(domain),
62110 + gr_socktype_to_name(type), protocol);
62111 +
62112 + return 0;
62113 +exit:
62114 + return 1;
62115 +}
62116 +
62117 +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)
62118 +{
62119 + if ((ip->mode & mode) &&
62120 + (ip_port >= ip->low) &&
62121 + (ip_port <= ip->high) &&
62122 + ((ntohl(ip_addr) & our_netmask) ==
62123 + (ntohl(our_addr) & our_netmask))
62124 + && (ip->proto[protocol / 32] & (1 << (protocol % 32)))
62125 + && (ip->type & (1 << type))) {
62126 + if (ip->mode & GR_INVERT)
62127 + return 2; // specifically denied
62128 + else
62129 + return 1; // allowed
62130 + }
62131 +
62132 + return 0; // not specifically allowed, may continue parsing
62133 +}
62134 +
62135 +static int
62136 +gr_search_connectbind(const int full_mode, struct sock *sk,
62137 + struct sockaddr_in *addr, const int type)
62138 +{
62139 + char iface[IFNAMSIZ] = {0};
62140 + struct acl_subject_label *curr;
62141 + struct acl_ip_label *ip;
62142 + struct inet_sock *isk;
62143 + struct net_device *dev;
62144 + struct in_device *idev;
62145 + unsigned long i;
62146 + int ret;
62147 + int mode = full_mode & (GR_BIND | GR_CONNECT);
62148 + __u32 ip_addr = 0;
62149 + __u32 our_addr;
62150 + __u32 our_netmask;
62151 + char *p;
62152 + __u16 ip_port = 0;
62153 + const struct cred *cred = current_cred();
62154 +
62155 + if (unlikely(!gr_acl_is_enabled() || sk->sk_family != PF_INET))
62156 + return 0;
62157 +
62158 + curr = current->acl;
62159 + isk = inet_sk(sk);
62160 +
62161 + /* INADDR_ANY overriding for binds, inaddr_any_override is already in network order */
62162 + if ((full_mode & GR_BINDOVERRIDE) && addr->sin_addr.s_addr == htonl(INADDR_ANY) && curr->inaddr_any_override != 0)
62163 + addr->sin_addr.s_addr = curr->inaddr_any_override;
62164 + if ((full_mode & GR_CONNECT) && isk->inet_saddr == htonl(INADDR_ANY) && curr->inaddr_any_override != 0) {
62165 + struct sockaddr_in saddr;
62166 + int err;
62167 +
62168 + saddr.sin_family = AF_INET;
62169 + saddr.sin_addr.s_addr = curr->inaddr_any_override;
62170 + saddr.sin_port = isk->inet_sport;
62171 +
62172 + err = security_socket_bind(sk->sk_socket, (struct sockaddr *)&saddr, sizeof(struct sockaddr_in));
62173 + if (err)
62174 + return err;
62175 +
62176 + err = sk->sk_socket->ops->bind(sk->sk_socket, (struct sockaddr *)&saddr, sizeof(struct sockaddr_in));
62177 + if (err)
62178 + return err;
62179 + }
62180 +
62181 + if (!curr->ips)
62182 + return 0;
62183 +
62184 + ip_addr = addr->sin_addr.s_addr;
62185 + ip_port = ntohs(addr->sin_port);
62186 +
62187 + if (curr->mode & (GR_LEARN | GR_INHERITLEARN)) {
62188 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
62189 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
62190 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
62191 + gr_to_filename(current->exec_file->f_path.dentry,
62192 + current->exec_file->f_path.mnt) :
62193 + curr->filename, curr->filename,
62194 + &ip_addr, ip_port, type,
62195 + sk->sk_protocol, mode, &current->signal->saved_ip);
62196 + return 0;
62197 + }
62198 +
62199 + for (i = 0; i < curr->ip_num; i++) {
62200 + ip = *(curr->ips + i);
62201 + if (ip->iface != NULL) {
62202 + strncpy(iface, ip->iface, IFNAMSIZ - 1);
62203 + p = strchr(iface, ':');
62204 + if (p != NULL)
62205 + *p = '\0';
62206 + dev = dev_get_by_name(sock_net(sk), iface);
62207 + if (dev == NULL)
62208 + continue;
62209 + idev = in_dev_get(dev);
62210 + if (idev == NULL) {
62211 + dev_put(dev);
62212 + continue;
62213 + }
62214 + rcu_read_lock();
62215 + for_ifa(idev) {
62216 + if (!strcmp(ip->iface, ifa->ifa_label)) {
62217 + our_addr = ifa->ifa_address;
62218 + our_netmask = 0xffffffff;
62219 + ret = check_ip_policy(ip, ip_addr, ip_port, sk->sk_protocol, mode, type, our_addr, our_netmask);
62220 + if (ret == 1) {
62221 + rcu_read_unlock();
62222 + in_dev_put(idev);
62223 + dev_put(dev);
62224 + return 0;
62225 + } else if (ret == 2) {
62226 + rcu_read_unlock();
62227 + in_dev_put(idev);
62228 + dev_put(dev);
62229 + goto denied;
62230 + }
62231 + }
62232 + } endfor_ifa(idev);
62233 + rcu_read_unlock();
62234 + in_dev_put(idev);
62235 + dev_put(dev);
62236 + } else {
62237 + our_addr = ip->addr;
62238 + our_netmask = ip->netmask;
62239 + ret = check_ip_policy(ip, ip_addr, ip_port, sk->sk_protocol, mode, type, our_addr, our_netmask);
62240 + if (ret == 1)
62241 + return 0;
62242 + else if (ret == 2)
62243 + goto denied;
62244 + }
62245 + }
62246 +
62247 +denied:
62248 + if (mode == GR_BIND)
62249 + 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));
62250 + else if (mode == GR_CONNECT)
62251 + 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));
62252 +
62253 + return -EACCES;
62254 +}
62255 +
62256 +int
62257 +gr_search_connect(struct socket *sock, struct sockaddr_in *addr)
62258 +{
62259 + /* always allow disconnection of dgram sockets with connect */
62260 + if (addr->sin_family == AF_UNSPEC)
62261 + return 0;
62262 + return gr_search_connectbind(GR_CONNECT | GR_CONNECTOVERRIDE, sock->sk, addr, sock->type);
62263 +}
62264 +
62265 +int
62266 +gr_search_bind(struct socket *sock, struct sockaddr_in *addr)
62267 +{
62268 + return gr_search_connectbind(GR_BIND | GR_BINDOVERRIDE, sock->sk, addr, sock->type);
62269 +}
62270 +
62271 +int gr_search_listen(struct socket *sock)
62272 +{
62273 + struct sock *sk = sock->sk;
62274 + struct sockaddr_in addr;
62275 +
62276 + addr.sin_addr.s_addr = inet_sk(sk)->inet_saddr;
62277 + addr.sin_port = inet_sk(sk)->inet_sport;
62278 +
62279 + return gr_search_connectbind(GR_BIND | GR_CONNECTOVERRIDE, sock->sk, &addr, sock->type);
62280 +}
62281 +
62282 +int gr_search_accept(struct socket *sock)
62283 +{
62284 + struct sock *sk = sock->sk;
62285 + struct sockaddr_in addr;
62286 +
62287 + addr.sin_addr.s_addr = inet_sk(sk)->inet_saddr;
62288 + addr.sin_port = inet_sk(sk)->inet_sport;
62289 +
62290 + return gr_search_connectbind(GR_BIND | GR_CONNECTOVERRIDE, sock->sk, &addr, sock->type);
62291 +}
62292 +
62293 +int
62294 +gr_search_udp_sendmsg(struct sock *sk, struct sockaddr_in *addr)
62295 +{
62296 + if (addr)
62297 + return gr_search_connectbind(GR_CONNECT, sk, addr, SOCK_DGRAM);
62298 + else {
62299 + struct sockaddr_in sin;
62300 + const struct inet_sock *inet = inet_sk(sk);
62301 +
62302 + sin.sin_addr.s_addr = inet->inet_daddr;
62303 + sin.sin_port = inet->inet_dport;
62304 +
62305 + return gr_search_connectbind(GR_CONNECT | GR_CONNECTOVERRIDE, sk, &sin, SOCK_DGRAM);
62306 + }
62307 +}
62308 +
62309 +int
62310 +gr_search_udp_recvmsg(struct sock *sk, const struct sk_buff *skb)
62311 +{
62312 + struct sockaddr_in sin;
62313 +
62314 + if (unlikely(skb->len < sizeof (struct udphdr)))
62315 + return 0; // skip this packet
62316 +
62317 + sin.sin_addr.s_addr = ip_hdr(skb)->saddr;
62318 + sin.sin_port = udp_hdr(skb)->source;
62319 +
62320 + return gr_search_connectbind(GR_CONNECT | GR_CONNECTOVERRIDE, sk, &sin, SOCK_DGRAM);
62321 +}
62322 diff --git a/grsecurity/gracl_learn.c b/grsecurity/gracl_learn.c
62323 new file mode 100644
62324 index 0000000..25f54ef
62325 --- /dev/null
62326 +++ b/grsecurity/gracl_learn.c
62327 @@ -0,0 +1,207 @@
62328 +#include <linux/kernel.h>
62329 +#include <linux/mm.h>
62330 +#include <linux/sched.h>
62331 +#include <linux/poll.h>
62332 +#include <linux/string.h>
62333 +#include <linux/file.h>
62334 +#include <linux/types.h>
62335 +#include <linux/vmalloc.h>
62336 +#include <linux/grinternal.h>
62337 +
62338 +extern ssize_t write_grsec_handler(struct file * file, const char __user * buf,
62339 + size_t count, loff_t *ppos);
62340 +extern int gr_acl_is_enabled(void);
62341 +
62342 +static DECLARE_WAIT_QUEUE_HEAD(learn_wait);
62343 +static int gr_learn_attached;
62344 +
62345 +/* use a 512k buffer */
62346 +#define LEARN_BUFFER_SIZE (512 * 1024)
62347 +
62348 +static DEFINE_SPINLOCK(gr_learn_lock);
62349 +static DEFINE_MUTEX(gr_learn_user_mutex);
62350 +
62351 +/* we need to maintain two buffers, so that the kernel context of grlearn
62352 + uses a semaphore around the userspace copying, and the other kernel contexts
62353 + use a spinlock when copying into the buffer, since they cannot sleep
62354 +*/
62355 +static char *learn_buffer;
62356 +static char *learn_buffer_user;
62357 +static int learn_buffer_len;
62358 +static int learn_buffer_user_len;
62359 +
62360 +static ssize_t
62361 +read_learn(struct file *file, char __user * buf, size_t count, loff_t * ppos)
62362 +{
62363 + DECLARE_WAITQUEUE(wait, current);
62364 + ssize_t retval = 0;
62365 +
62366 + add_wait_queue(&learn_wait, &wait);
62367 + set_current_state(TASK_INTERRUPTIBLE);
62368 + do {
62369 + mutex_lock(&gr_learn_user_mutex);
62370 + spin_lock(&gr_learn_lock);
62371 + if (learn_buffer_len)
62372 + break;
62373 + spin_unlock(&gr_learn_lock);
62374 + mutex_unlock(&gr_learn_user_mutex);
62375 + if (file->f_flags & O_NONBLOCK) {
62376 + retval = -EAGAIN;
62377 + goto out;
62378 + }
62379 + if (signal_pending(current)) {
62380 + retval = -ERESTARTSYS;
62381 + goto out;
62382 + }
62383 +
62384 + schedule();
62385 + } while (1);
62386 +
62387 + memcpy(learn_buffer_user, learn_buffer, learn_buffer_len);
62388 + learn_buffer_user_len = learn_buffer_len;
62389 + retval = learn_buffer_len;
62390 + learn_buffer_len = 0;
62391 +
62392 + spin_unlock(&gr_learn_lock);
62393 +
62394 + if (copy_to_user(buf, learn_buffer_user, learn_buffer_user_len))
62395 + retval = -EFAULT;
62396 +
62397 + mutex_unlock(&gr_learn_user_mutex);
62398 +out:
62399 + set_current_state(TASK_RUNNING);
62400 + remove_wait_queue(&learn_wait, &wait);
62401 + return retval;
62402 +}
62403 +
62404 +static unsigned int
62405 +poll_learn(struct file * file, poll_table * wait)
62406 +{
62407 + poll_wait(file, &learn_wait, wait);
62408 +
62409 + if (learn_buffer_len)
62410 + return (POLLIN | POLLRDNORM);
62411 +
62412 + return 0;
62413 +}
62414 +
62415 +void
62416 +gr_clear_learn_entries(void)
62417 +{
62418 + char *tmp;
62419 +
62420 + mutex_lock(&gr_learn_user_mutex);
62421 + spin_lock(&gr_learn_lock);
62422 + tmp = learn_buffer;
62423 + learn_buffer = NULL;
62424 + spin_unlock(&gr_learn_lock);
62425 + if (tmp)
62426 + vfree(tmp);
62427 + if (learn_buffer_user != NULL) {
62428 + vfree(learn_buffer_user);
62429 + learn_buffer_user = NULL;
62430 + }
62431 + learn_buffer_len = 0;
62432 + mutex_unlock(&gr_learn_user_mutex);
62433 +
62434 + return;
62435 +}
62436 +
62437 +void
62438 +gr_add_learn_entry(const char *fmt, ...)
62439 +{
62440 + va_list args;
62441 + unsigned int len;
62442 +
62443 + if (!gr_learn_attached)
62444 + return;
62445 +
62446 + spin_lock(&gr_learn_lock);
62447 +
62448 + /* leave a gap at the end so we know when it's "full" but don't have to
62449 + compute the exact length of the string we're trying to append
62450 + */
62451 + if (learn_buffer_len > LEARN_BUFFER_SIZE - 16384) {
62452 + spin_unlock(&gr_learn_lock);
62453 + wake_up_interruptible(&learn_wait);
62454 + return;
62455 + }
62456 + if (learn_buffer == NULL) {
62457 + spin_unlock(&gr_learn_lock);
62458 + return;
62459 + }
62460 +
62461 + va_start(args, fmt);
62462 + len = vsnprintf(learn_buffer + learn_buffer_len, LEARN_BUFFER_SIZE - learn_buffer_len, fmt, args);
62463 + va_end(args);
62464 +
62465 + learn_buffer_len += len + 1;
62466 +
62467 + spin_unlock(&gr_learn_lock);
62468 + wake_up_interruptible(&learn_wait);
62469 +
62470 + return;
62471 +}
62472 +
62473 +static int
62474 +open_learn(struct inode *inode, struct file *file)
62475 +{
62476 + if (file->f_mode & FMODE_READ && gr_learn_attached)
62477 + return -EBUSY;
62478 + if (file->f_mode & FMODE_READ) {
62479 + int retval = 0;
62480 + mutex_lock(&gr_learn_user_mutex);
62481 + if (learn_buffer == NULL)
62482 + learn_buffer = vmalloc(LEARN_BUFFER_SIZE);
62483 + if (learn_buffer_user == NULL)
62484 + learn_buffer_user = vmalloc(LEARN_BUFFER_SIZE);
62485 + if (learn_buffer == NULL) {
62486 + retval = -ENOMEM;
62487 + goto out_error;
62488 + }
62489 + if (learn_buffer_user == NULL) {
62490 + retval = -ENOMEM;
62491 + goto out_error;
62492 + }
62493 + learn_buffer_len = 0;
62494 + learn_buffer_user_len = 0;
62495 + gr_learn_attached = 1;
62496 +out_error:
62497 + mutex_unlock(&gr_learn_user_mutex);
62498 + return retval;
62499 + }
62500 + return 0;
62501 +}
62502 +
62503 +static int
62504 +close_learn(struct inode *inode, struct file *file)
62505 +{
62506 + if (file->f_mode & FMODE_READ) {
62507 + char *tmp = NULL;
62508 + mutex_lock(&gr_learn_user_mutex);
62509 + spin_lock(&gr_learn_lock);
62510 + tmp = learn_buffer;
62511 + learn_buffer = NULL;
62512 + spin_unlock(&gr_learn_lock);
62513 + if (tmp)
62514 + vfree(tmp);
62515 + if (learn_buffer_user != NULL) {
62516 + vfree(learn_buffer_user);
62517 + learn_buffer_user = NULL;
62518 + }
62519 + learn_buffer_len = 0;
62520 + learn_buffer_user_len = 0;
62521 + gr_learn_attached = 0;
62522 + mutex_unlock(&gr_learn_user_mutex);
62523 + }
62524 +
62525 + return 0;
62526 +}
62527 +
62528 +const struct file_operations grsec_fops = {
62529 + .read = read_learn,
62530 + .write = write_grsec_handler,
62531 + .open = open_learn,
62532 + .release = close_learn,
62533 + .poll = poll_learn,
62534 +};
62535 diff --git a/grsecurity/gracl_res.c b/grsecurity/gracl_res.c
62536 new file mode 100644
62537 index 0000000..39645c9
62538 --- /dev/null
62539 +++ b/grsecurity/gracl_res.c
62540 @@ -0,0 +1,68 @@
62541 +#include <linux/kernel.h>
62542 +#include <linux/sched.h>
62543 +#include <linux/gracl.h>
62544 +#include <linux/grinternal.h>
62545 +
62546 +static const char *restab_log[] = {
62547 + [RLIMIT_CPU] = "RLIMIT_CPU",
62548 + [RLIMIT_FSIZE] = "RLIMIT_FSIZE",
62549 + [RLIMIT_DATA] = "RLIMIT_DATA",
62550 + [RLIMIT_STACK] = "RLIMIT_STACK",
62551 + [RLIMIT_CORE] = "RLIMIT_CORE",
62552 + [RLIMIT_RSS] = "RLIMIT_RSS",
62553 + [RLIMIT_NPROC] = "RLIMIT_NPROC",
62554 + [RLIMIT_NOFILE] = "RLIMIT_NOFILE",
62555 + [RLIMIT_MEMLOCK] = "RLIMIT_MEMLOCK",
62556 + [RLIMIT_AS] = "RLIMIT_AS",
62557 + [RLIMIT_LOCKS] = "RLIMIT_LOCKS",
62558 + [RLIMIT_SIGPENDING] = "RLIMIT_SIGPENDING",
62559 + [RLIMIT_MSGQUEUE] = "RLIMIT_MSGQUEUE",
62560 + [RLIMIT_NICE] = "RLIMIT_NICE",
62561 + [RLIMIT_RTPRIO] = "RLIMIT_RTPRIO",
62562 + [RLIMIT_RTTIME] = "RLIMIT_RTTIME",
62563 + [GR_CRASH_RES] = "RLIMIT_CRASH"
62564 +};
62565 +
62566 +void
62567 +gr_log_resource(const struct task_struct *task,
62568 + const int res, const unsigned long wanted, const int gt)
62569 +{
62570 + const struct cred *cred;
62571 + unsigned long rlim;
62572 +
62573 + if (!gr_acl_is_enabled() && !grsec_resource_logging)
62574 + return;
62575 +
62576 + // not yet supported resource
62577 + if (unlikely(!restab_log[res]))
62578 + return;
62579 +
62580 + if (res == RLIMIT_CPU || res == RLIMIT_RTTIME)
62581 + rlim = task_rlimit_max(task, res);
62582 + else
62583 + rlim = task_rlimit(task, res);
62584 +
62585 + if (likely((rlim == RLIM_INFINITY) || (gt && wanted <= rlim) || (!gt && wanted < rlim)))
62586 + return;
62587 +
62588 + rcu_read_lock();
62589 + cred = __task_cred(task);
62590 +
62591 + if (res == RLIMIT_NPROC &&
62592 + (cap_raised(cred->cap_effective, CAP_SYS_ADMIN) ||
62593 + cap_raised(cred->cap_effective, CAP_SYS_RESOURCE)))
62594 + goto out_rcu_unlock;
62595 + else if (res == RLIMIT_MEMLOCK &&
62596 + cap_raised(cred->cap_effective, CAP_IPC_LOCK))
62597 + goto out_rcu_unlock;
62598 + else if (res == RLIMIT_NICE && cap_raised(cred->cap_effective, CAP_SYS_NICE))
62599 + goto out_rcu_unlock;
62600 + rcu_read_unlock();
62601 +
62602 + gr_log_res_ulong2_str(GR_DONT_AUDIT, GR_RESOURCE_MSG, task, wanted, restab_log[res], rlim);
62603 +
62604 + return;
62605 +out_rcu_unlock:
62606 + rcu_read_unlock();
62607 + return;
62608 +}
62609 diff --git a/grsecurity/gracl_segv.c b/grsecurity/gracl_segv.c
62610 new file mode 100644
62611 index 0000000..8c8fc9d
62612 --- /dev/null
62613 +++ b/grsecurity/gracl_segv.c
62614 @@ -0,0 +1,303 @@
62615 +#include <linux/kernel.h>
62616 +#include <linux/mm.h>
62617 +#include <asm/uaccess.h>
62618 +#include <asm/errno.h>
62619 +#include <asm/mman.h>
62620 +#include <net/sock.h>
62621 +#include <linux/file.h>
62622 +#include <linux/fs.h>
62623 +#include <linux/net.h>
62624 +#include <linux/in.h>
62625 +#include <linux/slab.h>
62626 +#include <linux/types.h>
62627 +#include <linux/sched.h>
62628 +#include <linux/timer.h>
62629 +#include <linux/gracl.h>
62630 +#include <linux/grsecurity.h>
62631 +#include <linux/grinternal.h>
62632 +
62633 +static struct crash_uid *uid_set;
62634 +static unsigned short uid_used;
62635 +static DEFINE_SPINLOCK(gr_uid_lock);
62636 +extern rwlock_t gr_inode_lock;
62637 +extern struct acl_subject_label *
62638 + lookup_acl_subj_label(const ino_t inode, const dev_t dev,
62639 + struct acl_role_label *role);
62640 +
62641 +#ifdef CONFIG_BTRFS_FS
62642 +extern dev_t get_btrfs_dev_from_inode(struct inode *inode);
62643 +extern int btrfs_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat);
62644 +#endif
62645 +
62646 +static inline dev_t __get_dev(const struct dentry *dentry)
62647 +{
62648 +#ifdef CONFIG_BTRFS_FS
62649 + if (dentry->d_inode->i_op && dentry->d_inode->i_op->getattr == &btrfs_getattr)
62650 + return get_btrfs_dev_from_inode(dentry->d_inode);
62651 + else
62652 +#endif
62653 + return dentry->d_inode->i_sb->s_dev;
62654 +}
62655 +
62656 +int
62657 +gr_init_uidset(void)
62658 +{
62659 + uid_set =
62660 + kmalloc(GR_UIDTABLE_MAX * sizeof (struct crash_uid), GFP_KERNEL);
62661 + uid_used = 0;
62662 +
62663 + return uid_set ? 1 : 0;
62664 +}
62665 +
62666 +void
62667 +gr_free_uidset(void)
62668 +{
62669 + if (uid_set)
62670 + kfree(uid_set);
62671 +
62672 + return;
62673 +}
62674 +
62675 +int
62676 +gr_find_uid(const uid_t uid)
62677 +{
62678 + struct crash_uid *tmp = uid_set;
62679 + uid_t buid;
62680 + int low = 0, high = uid_used - 1, mid;
62681 +
62682 + while (high >= low) {
62683 + mid = (low + high) >> 1;
62684 + buid = tmp[mid].uid;
62685 + if (buid == uid)
62686 + return mid;
62687 + if (buid > uid)
62688 + high = mid - 1;
62689 + if (buid < uid)
62690 + low = mid + 1;
62691 + }
62692 +
62693 + return -1;
62694 +}
62695 +
62696 +static __inline__ void
62697 +gr_insertsort(void)
62698 +{
62699 + unsigned short i, j;
62700 + struct crash_uid index;
62701 +
62702 + for (i = 1; i < uid_used; i++) {
62703 + index = uid_set[i];
62704 + j = i;
62705 + while ((j > 0) && uid_set[j - 1].uid > index.uid) {
62706 + uid_set[j] = uid_set[j - 1];
62707 + j--;
62708 + }
62709 + uid_set[j] = index;
62710 + }
62711 +
62712 + return;
62713 +}
62714 +
62715 +static __inline__ void
62716 +gr_insert_uid(const kuid_t kuid, const unsigned long expires)
62717 +{
62718 + int loc;
62719 + uid_t uid = GR_GLOBAL_UID(kuid);
62720 +
62721 + if (uid_used == GR_UIDTABLE_MAX)
62722 + return;
62723 +
62724 + loc = gr_find_uid(uid);
62725 +
62726 + if (loc >= 0) {
62727 + uid_set[loc].expires = expires;
62728 + return;
62729 + }
62730 +
62731 + uid_set[uid_used].uid = uid;
62732 + uid_set[uid_used].expires = expires;
62733 + uid_used++;
62734 +
62735 + gr_insertsort();
62736 +
62737 + return;
62738 +}
62739 +
62740 +void
62741 +gr_remove_uid(const unsigned short loc)
62742 +{
62743 + unsigned short i;
62744 +
62745 + for (i = loc + 1; i < uid_used; i++)
62746 + uid_set[i - 1] = uid_set[i];
62747 +
62748 + uid_used--;
62749 +
62750 + return;
62751 +}
62752 +
62753 +int
62754 +gr_check_crash_uid(const kuid_t kuid)
62755 +{
62756 + int loc;
62757 + int ret = 0;
62758 + uid_t uid;
62759 +
62760 + if (unlikely(!gr_acl_is_enabled()))
62761 + return 0;
62762 +
62763 + uid = GR_GLOBAL_UID(kuid);
62764 +
62765 + spin_lock(&gr_uid_lock);
62766 + loc = gr_find_uid(uid);
62767 +
62768 + if (loc < 0)
62769 + goto out_unlock;
62770 +
62771 + if (time_before_eq(uid_set[loc].expires, get_seconds()))
62772 + gr_remove_uid(loc);
62773 + else
62774 + ret = 1;
62775 +
62776 +out_unlock:
62777 + spin_unlock(&gr_uid_lock);
62778 + return ret;
62779 +}
62780 +
62781 +static __inline__ int
62782 +proc_is_setxid(const struct cred *cred)
62783 +{
62784 + if (!uid_eq(cred->uid, cred->euid) || !uid_eq(cred->uid, cred->suid) ||
62785 + !uid_eq(cred->uid, cred->fsuid))
62786 + return 1;
62787 + if (!gid_eq(cred->gid, cred->egid) || !gid_eq(cred->gid, cred->sgid) ||
62788 + !gid_eq(cred->gid, cred->fsgid))
62789 + return 1;
62790 +
62791 + return 0;
62792 +}
62793 +
62794 +extern int gr_fake_force_sig(int sig, struct task_struct *t);
62795 +
62796 +void
62797 +gr_handle_crash(struct task_struct *task, const int sig)
62798 +{
62799 + struct acl_subject_label *curr;
62800 + struct task_struct *tsk, *tsk2;
62801 + const struct cred *cred;
62802 + const struct cred *cred2;
62803 +
62804 + if (sig != SIGSEGV && sig != SIGKILL && sig != SIGBUS && sig != SIGILL)
62805 + return;
62806 +
62807 + if (unlikely(!gr_acl_is_enabled()))
62808 + return;
62809 +
62810 + curr = task->acl;
62811 +
62812 + if (!(curr->resmask & (1 << GR_CRASH_RES)))
62813 + return;
62814 +
62815 + if (time_before_eq(curr->expires, get_seconds())) {
62816 + curr->expires = 0;
62817 + curr->crashes = 0;
62818 + }
62819 +
62820 + curr->crashes++;
62821 +
62822 + if (!curr->expires)
62823 + curr->expires = get_seconds() + curr->res[GR_CRASH_RES].rlim_max;
62824 +
62825 + if ((curr->crashes >= curr->res[GR_CRASH_RES].rlim_cur) &&
62826 + time_after(curr->expires, get_seconds())) {
62827 + rcu_read_lock();
62828 + cred = __task_cred(task);
62829 + if (gr_is_global_nonroot(cred->uid) && proc_is_setxid(cred)) {
62830 + gr_log_crash1(GR_DONT_AUDIT, GR_SEGVSTART_ACL_MSG, task, curr->res[GR_CRASH_RES].rlim_max);
62831 + spin_lock(&gr_uid_lock);
62832 + gr_insert_uid(cred->uid, curr->expires);
62833 + spin_unlock(&gr_uid_lock);
62834 + curr->expires = 0;
62835 + curr->crashes = 0;
62836 + read_lock(&tasklist_lock);
62837 + do_each_thread(tsk2, tsk) {
62838 + cred2 = __task_cred(tsk);
62839 + if (tsk != task && uid_eq(cred2->uid, cred->uid))
62840 + gr_fake_force_sig(SIGKILL, tsk);
62841 + } while_each_thread(tsk2, tsk);
62842 + read_unlock(&tasklist_lock);
62843 + } else {
62844 + gr_log_crash2(GR_DONT_AUDIT, GR_SEGVNOSUID_ACL_MSG, task, curr->res[GR_CRASH_RES].rlim_max);
62845 + read_lock(&tasklist_lock);
62846 + read_lock(&grsec_exec_file_lock);
62847 + do_each_thread(tsk2, tsk) {
62848 + if (likely(tsk != task)) {
62849 + // if this thread has the same subject as the one that triggered
62850 + // RES_CRASH and it's the same binary, kill it
62851 + if (tsk->acl == task->acl && tsk->exec_file == task->exec_file)
62852 + gr_fake_force_sig(SIGKILL, tsk);
62853 + }
62854 + } while_each_thread(tsk2, tsk);
62855 + read_unlock(&grsec_exec_file_lock);
62856 + read_unlock(&tasklist_lock);
62857 + }
62858 + rcu_read_unlock();
62859 + }
62860 +
62861 + return;
62862 +}
62863 +
62864 +int
62865 +gr_check_crash_exec(const struct file *filp)
62866 +{
62867 + struct acl_subject_label *curr;
62868 +
62869 + if (unlikely(!gr_acl_is_enabled()))
62870 + return 0;
62871 +
62872 + read_lock(&gr_inode_lock);
62873 + curr = lookup_acl_subj_label(filp->f_path.dentry->d_inode->i_ino,
62874 + __get_dev(filp->f_path.dentry),
62875 + current->role);
62876 + read_unlock(&gr_inode_lock);
62877 +
62878 + if (!curr || !(curr->resmask & (1 << GR_CRASH_RES)) ||
62879 + (!curr->crashes && !curr->expires))
62880 + return 0;
62881 +
62882 + if ((curr->crashes >= curr->res[GR_CRASH_RES].rlim_cur) &&
62883 + time_after(curr->expires, get_seconds()))
62884 + return 1;
62885 + else if (time_before_eq(curr->expires, get_seconds())) {
62886 + curr->crashes = 0;
62887 + curr->expires = 0;
62888 + }
62889 +
62890 + return 0;
62891 +}
62892 +
62893 +void
62894 +gr_handle_alertkill(struct task_struct *task)
62895 +{
62896 + struct acl_subject_label *curracl;
62897 + __u32 curr_ip;
62898 + struct task_struct *p, *p2;
62899 +
62900 + if (unlikely(!gr_acl_is_enabled()))
62901 + return;
62902 +
62903 + curracl = task->acl;
62904 + curr_ip = task->signal->curr_ip;
62905 +
62906 + if ((curracl->mode & GR_KILLIPPROC) && curr_ip) {
62907 + read_lock(&tasklist_lock);
62908 + do_each_thread(p2, p) {
62909 + if (p->signal->curr_ip == curr_ip)
62910 + gr_fake_force_sig(SIGKILL, p);
62911 + } while_each_thread(p2, p);
62912 + read_unlock(&tasklist_lock);
62913 + } else if (curracl->mode & GR_KILLPROC)
62914 + gr_fake_force_sig(SIGKILL, task);
62915 +
62916 + return;
62917 +}
62918 diff --git a/grsecurity/gracl_shm.c b/grsecurity/gracl_shm.c
62919 new file mode 100644
62920 index 0000000..98011b0
62921 --- /dev/null
62922 +++ b/grsecurity/gracl_shm.c
62923 @@ -0,0 +1,40 @@
62924 +#include <linux/kernel.h>
62925 +#include <linux/mm.h>
62926 +#include <linux/sched.h>
62927 +#include <linux/file.h>
62928 +#include <linux/ipc.h>
62929 +#include <linux/gracl.h>
62930 +#include <linux/grsecurity.h>
62931 +#include <linux/grinternal.h>
62932 +
62933 +int
62934 +gr_handle_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
62935 + const time_t shm_createtime, const kuid_t cuid, const int shmid)
62936 +{
62937 + struct task_struct *task;
62938 +
62939 + if (!gr_acl_is_enabled())
62940 + return 1;
62941 +
62942 + rcu_read_lock();
62943 + read_lock(&tasklist_lock);
62944 +
62945 + task = find_task_by_vpid(shm_cprid);
62946 +
62947 + if (unlikely(!task))
62948 + task = find_task_by_vpid(shm_lapid);
62949 +
62950 + if (unlikely(task && (time_before_eq((unsigned long)task->start_time.tv_sec, (unsigned long)shm_createtime) ||
62951 + (task_pid_nr(task) == shm_lapid)) &&
62952 + (task->acl->mode & GR_PROTSHM) &&
62953 + (task->acl != current->acl))) {
62954 + read_unlock(&tasklist_lock);
62955 + rcu_read_unlock();
62956 + gr_log_int3(GR_DONT_AUDIT, GR_SHMAT_ACL_MSG, GR_GLOBAL_UID(cuid), shm_cprid, shmid);
62957 + return 0;
62958 + }
62959 + read_unlock(&tasklist_lock);
62960 + rcu_read_unlock();
62961 +
62962 + return 1;
62963 +}
62964 diff --git a/grsecurity/grsec_chdir.c b/grsecurity/grsec_chdir.c
62965 new file mode 100644
62966 index 0000000..bc0be01
62967 --- /dev/null
62968 +++ b/grsecurity/grsec_chdir.c
62969 @@ -0,0 +1,19 @@
62970 +#include <linux/kernel.h>
62971 +#include <linux/sched.h>
62972 +#include <linux/fs.h>
62973 +#include <linux/file.h>
62974 +#include <linux/grsecurity.h>
62975 +#include <linux/grinternal.h>
62976 +
62977 +void
62978 +gr_log_chdir(const struct dentry *dentry, const struct vfsmount *mnt)
62979 +{
62980 +#ifdef CONFIG_GRKERNSEC_AUDIT_CHDIR
62981 + if ((grsec_enable_chdir && grsec_enable_group &&
62982 + in_group_p(grsec_audit_gid)) || (grsec_enable_chdir &&
62983 + !grsec_enable_group)) {
62984 + gr_log_fs_generic(GR_DO_AUDIT, GR_CHDIR_AUDIT_MSG, dentry, mnt);
62985 + }
62986 +#endif
62987 + return;
62988 +}
62989 diff --git a/grsecurity/grsec_chroot.c b/grsecurity/grsec_chroot.c
62990 new file mode 100644
62991 index 0000000..6d2de57
62992 --- /dev/null
62993 +++ b/grsecurity/grsec_chroot.c
62994 @@ -0,0 +1,357 @@
62995 +#include <linux/kernel.h>
62996 +#include <linux/module.h>
62997 +#include <linux/sched.h>
62998 +#include <linux/file.h>
62999 +#include <linux/fs.h>
63000 +#include <linux/mount.h>
63001 +#include <linux/types.h>
63002 +#include "../fs/mount.h"
63003 +#include <linux/grsecurity.h>
63004 +#include <linux/grinternal.h>
63005 +
63006 +void gr_set_chroot_entries(struct task_struct *task, struct path *path)
63007 +{
63008 +#ifdef CONFIG_GRKERNSEC
63009 + if (task_pid_nr(task) > 1 && path->dentry != init_task.fs->root.dentry &&
63010 + path->dentry != task->nsproxy->mnt_ns->root->mnt.mnt_root)
63011 + task->gr_is_chrooted = 1;
63012 + else
63013 + task->gr_is_chrooted = 0;
63014 +
63015 + task->gr_chroot_dentry = path->dentry;
63016 +#endif
63017 + return;
63018 +}
63019 +
63020 +void gr_clear_chroot_entries(struct task_struct *task)
63021 +{
63022 +#ifdef CONFIG_GRKERNSEC
63023 + task->gr_is_chrooted = 0;
63024 + task->gr_chroot_dentry = NULL;
63025 +#endif
63026 + return;
63027 +}
63028 +
63029 +int
63030 +gr_handle_chroot_unix(const pid_t pid)
63031 +{
63032 +#ifdef CONFIG_GRKERNSEC_CHROOT_UNIX
63033 + struct task_struct *p;
63034 +
63035 + if (unlikely(!grsec_enable_chroot_unix))
63036 + return 1;
63037 +
63038 + if (likely(!proc_is_chrooted(current)))
63039 + return 1;
63040 +
63041 + rcu_read_lock();
63042 + read_lock(&tasklist_lock);
63043 + p = find_task_by_vpid_unrestricted(pid);
63044 + if (unlikely(p && !have_same_root(current, p))) {
63045 + read_unlock(&tasklist_lock);
63046 + rcu_read_unlock();
63047 + gr_log_noargs(GR_DONT_AUDIT, GR_UNIX_CHROOT_MSG);
63048 + return 0;
63049 + }
63050 + read_unlock(&tasklist_lock);
63051 + rcu_read_unlock();
63052 +#endif
63053 + return 1;
63054 +}
63055 +
63056 +int
63057 +gr_handle_chroot_nice(void)
63058 +{
63059 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
63060 + if (grsec_enable_chroot_nice && proc_is_chrooted(current)) {
63061 + gr_log_noargs(GR_DONT_AUDIT, GR_NICE_CHROOT_MSG);
63062 + return -EPERM;
63063 + }
63064 +#endif
63065 + return 0;
63066 +}
63067 +
63068 +int
63069 +gr_handle_chroot_setpriority(struct task_struct *p, const int niceval)
63070 +{
63071 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
63072 + if (grsec_enable_chroot_nice && (niceval < task_nice(p))
63073 + && proc_is_chrooted(current)) {
63074 + gr_log_str_int(GR_DONT_AUDIT, GR_PRIORITY_CHROOT_MSG, p->comm, task_pid_nr(p));
63075 + return -EACCES;
63076 + }
63077 +#endif
63078 + return 0;
63079 +}
63080 +
63081 +int
63082 +gr_handle_chroot_fowner(struct pid *pid, enum pid_type type)
63083 +{
63084 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
63085 + struct task_struct *p;
63086 + int ret = 0;
63087 + if (!grsec_enable_chroot_findtask || !proc_is_chrooted(current) || !pid)
63088 + return ret;
63089 +
63090 + read_lock(&tasklist_lock);
63091 + do_each_pid_task(pid, type, p) {
63092 + if (!have_same_root(current, p)) {
63093 + ret = 1;
63094 + goto out;
63095 + }
63096 + } while_each_pid_task(pid, type, p);
63097 +out:
63098 + read_unlock(&tasklist_lock);
63099 + return ret;
63100 +#endif
63101 + return 0;
63102 +}
63103 +
63104 +int
63105 +gr_pid_is_chrooted(struct task_struct *p)
63106 +{
63107 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
63108 + if (!grsec_enable_chroot_findtask || !proc_is_chrooted(current) || p == NULL)
63109 + return 0;
63110 +
63111 + if ((p->exit_state & (EXIT_ZOMBIE | EXIT_DEAD)) ||
63112 + !have_same_root(current, p)) {
63113 + return 1;
63114 + }
63115 +#endif
63116 + return 0;
63117 +}
63118 +
63119 +EXPORT_SYMBOL(gr_pid_is_chrooted);
63120 +
63121 +#if defined(CONFIG_GRKERNSEC_CHROOT_DOUBLE) || defined(CONFIG_GRKERNSEC_CHROOT_FCHDIR)
63122 +int gr_is_outside_chroot(const struct dentry *u_dentry, const struct vfsmount *u_mnt)
63123 +{
63124 + struct path path, currentroot;
63125 + int ret = 0;
63126 +
63127 + path.dentry = (struct dentry *)u_dentry;
63128 + path.mnt = (struct vfsmount *)u_mnt;
63129 + get_fs_root(current->fs, &currentroot);
63130 + if (path_is_under(&path, &currentroot))
63131 + ret = 1;
63132 + path_put(&currentroot);
63133 +
63134 + return ret;
63135 +}
63136 +#endif
63137 +
63138 +int
63139 +gr_chroot_fchdir(struct dentry *u_dentry, struct vfsmount *u_mnt)
63140 +{
63141 +#ifdef CONFIG_GRKERNSEC_CHROOT_FCHDIR
63142 + if (!grsec_enable_chroot_fchdir)
63143 + return 1;
63144 +
63145 + if (!proc_is_chrooted(current))
63146 + return 1;
63147 + else if (!gr_is_outside_chroot(u_dentry, u_mnt)) {
63148 + gr_log_fs_generic(GR_DONT_AUDIT, GR_CHROOT_FCHDIR_MSG, u_dentry, u_mnt);
63149 + return 0;
63150 + }
63151 +#endif
63152 + return 1;
63153 +}
63154 +
63155 +int
63156 +gr_chroot_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
63157 + const time_t shm_createtime)
63158 +{
63159 +#ifdef CONFIG_GRKERNSEC_CHROOT_SHMAT
63160 + struct task_struct *p;
63161 + time_t starttime;
63162 +
63163 + if (unlikely(!grsec_enable_chroot_shmat))
63164 + return 1;
63165 +
63166 + if (likely(!proc_is_chrooted(current)))
63167 + return 1;
63168 +
63169 + rcu_read_lock();
63170 + read_lock(&tasklist_lock);
63171 +
63172 + if ((p = find_task_by_vpid_unrestricted(shm_cprid))) {
63173 + starttime = p->start_time.tv_sec;
63174 + if (time_before_eq((unsigned long)starttime, (unsigned long)shm_createtime)) {
63175 + if (have_same_root(current, p)) {
63176 + goto allow;
63177 + } else {
63178 + read_unlock(&tasklist_lock);
63179 + rcu_read_unlock();
63180 + gr_log_noargs(GR_DONT_AUDIT, GR_SHMAT_CHROOT_MSG);
63181 + return 0;
63182 + }
63183 + }
63184 + /* creator exited, pid reuse, fall through to next check */
63185 + }
63186 + if ((p = find_task_by_vpid_unrestricted(shm_lapid))) {
63187 + if (unlikely(!have_same_root(current, p))) {
63188 + read_unlock(&tasklist_lock);
63189 + rcu_read_unlock();
63190 + gr_log_noargs(GR_DONT_AUDIT, GR_SHMAT_CHROOT_MSG);
63191 + return 0;
63192 + }
63193 + }
63194 +
63195 +allow:
63196 + read_unlock(&tasklist_lock);
63197 + rcu_read_unlock();
63198 +#endif
63199 + return 1;
63200 +}
63201 +
63202 +void
63203 +gr_log_chroot_exec(const struct dentry *dentry, const struct vfsmount *mnt)
63204 +{
63205 +#ifdef CONFIG_GRKERNSEC_CHROOT_EXECLOG
63206 + if (grsec_enable_chroot_execlog && proc_is_chrooted(current))
63207 + gr_log_fs_generic(GR_DO_AUDIT, GR_EXEC_CHROOT_MSG, dentry, mnt);
63208 +#endif
63209 + return;
63210 +}
63211 +
63212 +int
63213 +gr_handle_chroot_mknod(const struct dentry *dentry,
63214 + const struct vfsmount *mnt, const int mode)
63215 +{
63216 +#ifdef CONFIG_GRKERNSEC_CHROOT_MKNOD
63217 + if (grsec_enable_chroot_mknod && !S_ISFIFO(mode) && !S_ISREG(mode) &&
63218 + proc_is_chrooted(current)) {
63219 + gr_log_fs_generic(GR_DONT_AUDIT, GR_MKNOD_CHROOT_MSG, dentry, mnt);
63220 + return -EPERM;
63221 + }
63222 +#endif
63223 + return 0;
63224 +}
63225 +
63226 +int
63227 +gr_handle_chroot_mount(const struct dentry *dentry,
63228 + const struct vfsmount *mnt, const char *dev_name)
63229 +{
63230 +#ifdef CONFIG_GRKERNSEC_CHROOT_MOUNT
63231 + if (grsec_enable_chroot_mount && proc_is_chrooted(current)) {
63232 + gr_log_str_fs(GR_DONT_AUDIT, GR_MOUNT_CHROOT_MSG, dev_name ? dev_name : "none", dentry, mnt);
63233 + return -EPERM;
63234 + }
63235 +#endif
63236 + return 0;
63237 +}
63238 +
63239 +int
63240 +gr_handle_chroot_pivot(void)
63241 +{
63242 +#ifdef CONFIG_GRKERNSEC_CHROOT_PIVOT
63243 + if (grsec_enable_chroot_pivot && proc_is_chrooted(current)) {
63244 + gr_log_noargs(GR_DONT_AUDIT, GR_PIVOT_CHROOT_MSG);
63245 + return -EPERM;
63246 + }
63247 +#endif
63248 + return 0;
63249 +}
63250 +
63251 +int
63252 +gr_handle_chroot_chroot(const struct dentry *dentry, const struct vfsmount *mnt)
63253 +{
63254 +#ifdef CONFIG_GRKERNSEC_CHROOT_DOUBLE
63255 + if (grsec_enable_chroot_double && proc_is_chrooted(current) &&
63256 + !gr_is_outside_chroot(dentry, mnt)) {
63257 + gr_log_fs_generic(GR_DONT_AUDIT, GR_CHROOT_CHROOT_MSG, dentry, mnt);
63258 + return -EPERM;
63259 + }
63260 +#endif
63261 + return 0;
63262 +}
63263 +
63264 +extern const char *captab_log[];
63265 +extern int captab_log_entries;
63266 +
63267 +int
63268 +gr_task_chroot_is_capable(const struct task_struct *task, const struct cred *cred, const int cap)
63269 +{
63270 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
63271 + if (grsec_enable_chroot_caps && proc_is_chrooted(task)) {
63272 + kernel_cap_t chroot_caps = GR_CHROOT_CAPS;
63273 + if (cap_raised(chroot_caps, cap)) {
63274 + if (cap_raised(cred->cap_effective, cap) && cap < captab_log_entries) {
63275 + gr_log_cap(GR_DONT_AUDIT, GR_CAP_CHROOT_MSG, task, captab_log[cap]);
63276 + }
63277 + return 0;
63278 + }
63279 + }
63280 +#endif
63281 + return 1;
63282 +}
63283 +
63284 +int
63285 +gr_chroot_is_capable(const int cap)
63286 +{
63287 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
63288 + return gr_task_chroot_is_capable(current, current_cred(), cap);
63289 +#endif
63290 + return 1;
63291 +}
63292 +
63293 +int
63294 +gr_task_chroot_is_capable_nolog(const struct task_struct *task, const int cap)
63295 +{
63296 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
63297 + if (grsec_enable_chroot_caps && proc_is_chrooted(task)) {
63298 + kernel_cap_t chroot_caps = GR_CHROOT_CAPS;
63299 + if (cap_raised(chroot_caps, cap)) {
63300 + return 0;
63301 + }
63302 + }
63303 +#endif
63304 + return 1;
63305 +}
63306 +
63307 +int
63308 +gr_chroot_is_capable_nolog(const int cap)
63309 +{
63310 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
63311 + return gr_task_chroot_is_capable_nolog(current, cap);
63312 +#endif
63313 + return 1;
63314 +}
63315 +
63316 +int
63317 +gr_handle_chroot_sysctl(const int op)
63318 +{
63319 +#ifdef CONFIG_GRKERNSEC_CHROOT_SYSCTL
63320 + if (grsec_enable_chroot_sysctl && (op & MAY_WRITE) &&
63321 + proc_is_chrooted(current))
63322 + return -EACCES;
63323 +#endif
63324 + return 0;
63325 +}
63326 +
63327 +void
63328 +gr_handle_chroot_chdir(struct path *path)
63329 +{
63330 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHDIR
63331 + if (grsec_enable_chroot_chdir)
63332 + set_fs_pwd(current->fs, path);
63333 +#endif
63334 + return;
63335 +}
63336 +
63337 +int
63338 +gr_handle_chroot_chmod(const struct dentry *dentry,
63339 + const struct vfsmount *mnt, const int mode)
63340 +{
63341 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHMOD
63342 + /* allow chmod +s on directories, but not files */
63343 + if (grsec_enable_chroot_chmod && !S_ISDIR(dentry->d_inode->i_mode) &&
63344 + ((mode & S_ISUID) || ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))) &&
63345 + proc_is_chrooted(current)) {
63346 + gr_log_fs_generic(GR_DONT_AUDIT, GR_CHMOD_CHROOT_MSG, dentry, mnt);
63347 + return -EPERM;
63348 + }
63349 +#endif
63350 + return 0;
63351 +}
63352 diff --git a/grsecurity/grsec_disabled.c b/grsecurity/grsec_disabled.c
63353 new file mode 100644
63354 index 0000000..207d409
63355 --- /dev/null
63356 +++ b/grsecurity/grsec_disabled.c
63357 @@ -0,0 +1,434 @@
63358 +#include <linux/kernel.h>
63359 +#include <linux/module.h>
63360 +#include <linux/sched.h>
63361 +#include <linux/file.h>
63362 +#include <linux/fs.h>
63363 +#include <linux/kdev_t.h>
63364 +#include <linux/net.h>
63365 +#include <linux/in.h>
63366 +#include <linux/ip.h>
63367 +#include <linux/skbuff.h>
63368 +#include <linux/sysctl.h>
63369 +
63370 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
63371 +void
63372 +pax_set_initial_flags(struct linux_binprm *bprm)
63373 +{
63374 + return;
63375 +}
63376 +#endif
63377 +
63378 +#ifdef CONFIG_SYSCTL
63379 +__u32
63380 +gr_handle_sysctl(const struct ctl_table * table, const int op)
63381 +{
63382 + return 0;
63383 +}
63384 +#endif
63385 +
63386 +#ifdef CONFIG_TASKSTATS
63387 +int gr_is_taskstats_denied(int pid)
63388 +{
63389 + return 0;
63390 +}
63391 +#endif
63392 +
63393 +int
63394 +gr_acl_is_enabled(void)
63395 +{
63396 + return 0;
63397 +}
63398 +
63399 +void
63400 +gr_handle_proc_create(const struct dentry *dentry, const struct inode *inode)
63401 +{
63402 + return;
63403 +}
63404 +
63405 +int
63406 +gr_handle_rawio(const struct inode *inode)
63407 +{
63408 + return 0;
63409 +}
63410 +
63411 +void
63412 +gr_acl_handle_psacct(struct task_struct *task, const long code)
63413 +{
63414 + return;
63415 +}
63416 +
63417 +int
63418 +gr_handle_ptrace(struct task_struct *task, const long request)
63419 +{
63420 + return 0;
63421 +}
63422 +
63423 +int
63424 +gr_handle_proc_ptrace(struct task_struct *task)
63425 +{
63426 + return 0;
63427 +}
63428 +
63429 +int
63430 +gr_set_acls(const int type)
63431 +{
63432 + return 0;
63433 +}
63434 +
63435 +int
63436 +gr_check_hidden_task(const struct task_struct *tsk)
63437 +{
63438 + return 0;
63439 +}
63440 +
63441 +int
63442 +gr_check_protected_task(const struct task_struct *task)
63443 +{
63444 + return 0;
63445 +}
63446 +
63447 +int
63448 +gr_check_protected_task_fowner(struct pid *pid, enum pid_type type)
63449 +{
63450 + return 0;
63451 +}
63452 +
63453 +void
63454 +gr_copy_label(struct task_struct *tsk)
63455 +{
63456 + return;
63457 +}
63458 +
63459 +void
63460 +gr_set_pax_flags(struct task_struct *task)
63461 +{
63462 + return;
63463 +}
63464 +
63465 +int
63466 +gr_set_proc_label(const struct dentry *dentry, const struct vfsmount *mnt,
63467 + const int unsafe_share)
63468 +{
63469 + return 0;
63470 +}
63471 +
63472 +void
63473 +gr_handle_delete(const ino_t ino, const dev_t dev)
63474 +{
63475 + return;
63476 +}
63477 +
63478 +void
63479 +gr_handle_create(const struct dentry *dentry, const struct vfsmount *mnt)
63480 +{
63481 + return;
63482 +}
63483 +
63484 +void
63485 +gr_handle_crash(struct task_struct *task, const int sig)
63486 +{
63487 + return;
63488 +}
63489 +
63490 +int
63491 +gr_check_crash_exec(const struct file *filp)
63492 +{
63493 + return 0;
63494 +}
63495 +
63496 +int
63497 +gr_check_crash_uid(const kuid_t uid)
63498 +{
63499 + return 0;
63500 +}
63501 +
63502 +void
63503 +gr_handle_rename(struct inode *old_dir, struct inode *new_dir,
63504 + struct dentry *old_dentry,
63505 + struct dentry *new_dentry,
63506 + struct vfsmount *mnt, const __u8 replace)
63507 +{
63508 + return;
63509 +}
63510 +
63511 +int
63512 +gr_search_socket(const int family, const int type, const int protocol)
63513 +{
63514 + return 1;
63515 +}
63516 +
63517 +int
63518 +gr_search_connectbind(const int mode, const struct socket *sock,
63519 + const struct sockaddr_in *addr)
63520 +{
63521 + return 0;
63522 +}
63523 +
63524 +void
63525 +gr_handle_alertkill(struct task_struct *task)
63526 +{
63527 + return;
63528 +}
63529 +
63530 +__u32
63531 +gr_acl_handle_execve(const struct dentry * dentry, const struct vfsmount * mnt)
63532 +{
63533 + return 1;
63534 +}
63535 +
63536 +__u32
63537 +gr_acl_handle_hidden_file(const struct dentry * dentry,
63538 + const struct vfsmount * mnt)
63539 +{
63540 + return 1;
63541 +}
63542 +
63543 +__u32
63544 +gr_acl_handle_open(const struct dentry * dentry, const struct vfsmount * mnt,
63545 + int acc_mode)
63546 +{
63547 + return 1;
63548 +}
63549 +
63550 +__u32
63551 +gr_acl_handle_rmdir(const struct dentry * dentry, const struct vfsmount * mnt)
63552 +{
63553 + return 1;
63554 +}
63555 +
63556 +__u32
63557 +gr_acl_handle_unlink(const struct dentry * dentry, const struct vfsmount * mnt)
63558 +{
63559 + return 1;
63560 +}
63561 +
63562 +int
63563 +gr_acl_handle_mmap(const struct file *file, const unsigned long prot,
63564 + unsigned int *vm_flags)
63565 +{
63566 + return 1;
63567 +}
63568 +
63569 +__u32
63570 +gr_acl_handle_truncate(const struct dentry * dentry,
63571 + const struct vfsmount * mnt)
63572 +{
63573 + return 1;
63574 +}
63575 +
63576 +__u32
63577 +gr_acl_handle_utime(const struct dentry * dentry, const struct vfsmount * mnt)
63578 +{
63579 + return 1;
63580 +}
63581 +
63582 +__u32
63583 +gr_acl_handle_access(const struct dentry * dentry,
63584 + const struct vfsmount * mnt, const int fmode)
63585 +{
63586 + return 1;
63587 +}
63588 +
63589 +__u32
63590 +gr_acl_handle_chmod(const struct dentry * dentry, const struct vfsmount * mnt,
63591 + umode_t *mode)
63592 +{
63593 + return 1;
63594 +}
63595 +
63596 +__u32
63597 +gr_acl_handle_chown(const struct dentry * dentry, const struct vfsmount * mnt)
63598 +{
63599 + return 1;
63600 +}
63601 +
63602 +__u32
63603 +gr_acl_handle_setxattr(const struct dentry * dentry, const struct vfsmount * mnt)
63604 +{
63605 + return 1;
63606 +}
63607 +
63608 +void
63609 +grsecurity_init(void)
63610 +{
63611 + return;
63612 +}
63613 +
63614 +umode_t gr_acl_umask(void)
63615 +{
63616 + return 0;
63617 +}
63618 +
63619 +__u32
63620 +gr_acl_handle_mknod(const struct dentry * new_dentry,
63621 + const struct dentry * parent_dentry,
63622 + const struct vfsmount * parent_mnt,
63623 + const int mode)
63624 +{
63625 + return 1;
63626 +}
63627 +
63628 +__u32
63629 +gr_acl_handle_mkdir(const struct dentry * new_dentry,
63630 + const struct dentry * parent_dentry,
63631 + const struct vfsmount * parent_mnt)
63632 +{
63633 + return 1;
63634 +}
63635 +
63636 +__u32
63637 +gr_acl_handle_symlink(const struct dentry * new_dentry,
63638 + const struct dentry * parent_dentry,
63639 + const struct vfsmount * parent_mnt, const struct filename *from)
63640 +{
63641 + return 1;
63642 +}
63643 +
63644 +__u32
63645 +gr_acl_handle_link(const struct dentry * new_dentry,
63646 + const struct dentry * parent_dentry,
63647 + const struct vfsmount * parent_mnt,
63648 + const struct dentry * old_dentry,
63649 + const struct vfsmount * old_mnt, const struct filename *to)
63650 +{
63651 + return 1;
63652 +}
63653 +
63654 +int
63655 +gr_acl_handle_rename(const struct dentry *new_dentry,
63656 + const struct dentry *parent_dentry,
63657 + const struct vfsmount *parent_mnt,
63658 + const struct dentry *old_dentry,
63659 + const struct inode *old_parent_inode,
63660 + const struct vfsmount *old_mnt, const struct filename *newname)
63661 +{
63662 + return 0;
63663 +}
63664 +
63665 +int
63666 +gr_acl_handle_filldir(const struct file *file, const char *name,
63667 + const int namelen, const ino_t ino)
63668 +{
63669 + return 1;
63670 +}
63671 +
63672 +int
63673 +gr_handle_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
63674 + const time_t shm_createtime, const kuid_t cuid, const int shmid)
63675 +{
63676 + return 1;
63677 +}
63678 +
63679 +int
63680 +gr_search_bind(const struct socket *sock, const struct sockaddr_in *addr)
63681 +{
63682 + return 0;
63683 +}
63684 +
63685 +int
63686 +gr_search_accept(const struct socket *sock)
63687 +{
63688 + return 0;
63689 +}
63690 +
63691 +int
63692 +gr_search_listen(const struct socket *sock)
63693 +{
63694 + return 0;
63695 +}
63696 +
63697 +int
63698 +gr_search_connect(const struct socket *sock, const struct sockaddr_in *addr)
63699 +{
63700 + return 0;
63701 +}
63702 +
63703 +__u32
63704 +gr_acl_handle_unix(const struct dentry * dentry, const struct vfsmount * mnt)
63705 +{
63706 + return 1;
63707 +}
63708 +
63709 +__u32
63710 +gr_acl_handle_creat(const struct dentry * dentry,
63711 + const struct dentry * p_dentry,
63712 + const struct vfsmount * p_mnt, int open_flags, int acc_mode,
63713 + const int imode)
63714 +{
63715 + return 1;
63716 +}
63717 +
63718 +void
63719 +gr_acl_handle_exit(void)
63720 +{
63721 + return;
63722 +}
63723 +
63724 +int
63725 +gr_acl_handle_mprotect(const struct file *file, const unsigned long prot)
63726 +{
63727 + return 1;
63728 +}
63729 +
63730 +void
63731 +gr_set_role_label(const kuid_t uid, const kgid_t gid)
63732 +{
63733 + return;
63734 +}
63735 +
63736 +int
63737 +gr_acl_handle_procpidmem(const struct task_struct *task)
63738 +{
63739 + return 0;
63740 +}
63741 +
63742 +int
63743 +gr_search_udp_recvmsg(const struct sock *sk, const struct sk_buff *skb)
63744 +{
63745 + return 0;
63746 +}
63747 +
63748 +int
63749 +gr_search_udp_sendmsg(const struct sock *sk, const struct sockaddr_in *addr)
63750 +{
63751 + return 0;
63752 +}
63753 +
63754 +void
63755 +gr_set_kernel_label(struct task_struct *task)
63756 +{
63757 + return;
63758 +}
63759 +
63760 +int
63761 +gr_check_user_change(kuid_t real, kuid_t effective, kuid_t fs)
63762 +{
63763 + return 0;
63764 +}
63765 +
63766 +int
63767 +gr_check_group_change(kgid_t real, kgid_t effective, kgid_t fs)
63768 +{
63769 + return 0;
63770 +}
63771 +
63772 +int gr_acl_enable_at_secure(void)
63773 +{
63774 + return 0;
63775 +}
63776 +
63777 +dev_t gr_get_dev_from_dentry(struct dentry *dentry)
63778 +{
63779 + return dentry->d_inode->i_sb->s_dev;
63780 +}
63781 +
63782 +void gr_put_exec_file(struct task_struct *task)
63783 +{
63784 + return;
63785 +}
63786 +
63787 +EXPORT_SYMBOL(gr_set_kernel_label);
63788 +#ifdef CONFIG_SECURITY
63789 +EXPORT_SYMBOL(gr_check_user_change);
63790 +EXPORT_SYMBOL(gr_check_group_change);
63791 +#endif
63792 diff --git a/grsecurity/grsec_exec.c b/grsecurity/grsec_exec.c
63793 new file mode 100644
63794 index 0000000..387032b
63795 --- /dev/null
63796 +++ b/grsecurity/grsec_exec.c
63797 @@ -0,0 +1,187 @@
63798 +#include <linux/kernel.h>
63799 +#include <linux/sched.h>
63800 +#include <linux/file.h>
63801 +#include <linux/binfmts.h>
63802 +#include <linux/fs.h>
63803 +#include <linux/types.h>
63804 +#include <linux/grdefs.h>
63805 +#include <linux/grsecurity.h>
63806 +#include <linux/grinternal.h>
63807 +#include <linux/capability.h>
63808 +#include <linux/module.h>
63809 +#include <linux/compat.h>
63810 +
63811 +#include <asm/uaccess.h>
63812 +
63813 +#ifdef CONFIG_GRKERNSEC_EXECLOG
63814 +static char gr_exec_arg_buf[132];
63815 +static DEFINE_MUTEX(gr_exec_arg_mutex);
63816 +#endif
63817 +
63818 +struct user_arg_ptr {
63819 +#ifdef CONFIG_COMPAT
63820 + bool is_compat;
63821 +#endif
63822 + union {
63823 + const char __user *const __user *native;
63824 +#ifdef CONFIG_COMPAT
63825 + const compat_uptr_t __user *compat;
63826 +#endif
63827 + } ptr;
63828 +};
63829 +
63830 +extern const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr);
63831 +
63832 +void
63833 +gr_handle_exec_args(struct linux_binprm *bprm, struct user_arg_ptr argv)
63834 +{
63835 +#ifdef CONFIG_GRKERNSEC_EXECLOG
63836 + char *grarg = gr_exec_arg_buf;
63837 + unsigned int i, x, execlen = 0;
63838 + char c;
63839 +
63840 + if (!((grsec_enable_execlog && grsec_enable_group &&
63841 + in_group_p(grsec_audit_gid))
63842 + || (grsec_enable_execlog && !grsec_enable_group)))
63843 + return;
63844 +
63845 + mutex_lock(&gr_exec_arg_mutex);
63846 + memset(grarg, 0, sizeof(gr_exec_arg_buf));
63847 +
63848 + for (i = 0; i < bprm->argc && execlen < 128; i++) {
63849 + const char __user *p;
63850 + unsigned int len;
63851 +
63852 + p = get_user_arg_ptr(argv, i);
63853 + if (IS_ERR(p))
63854 + goto log;
63855 +
63856 + len = strnlen_user(p, 128 - execlen);
63857 + if (len > 128 - execlen)
63858 + len = 128 - execlen;
63859 + else if (len > 0)
63860 + len--;
63861 + if (copy_from_user(grarg + execlen, p, len))
63862 + goto log;
63863 +
63864 + /* rewrite unprintable characters */
63865 + for (x = 0; x < len; x++) {
63866 + c = *(grarg + execlen + x);
63867 + if (c < 32 || c > 126)
63868 + *(grarg + execlen + x) = ' ';
63869 + }
63870 +
63871 + execlen += len;
63872 + *(grarg + execlen) = ' ';
63873 + *(grarg + execlen + 1) = '\0';
63874 + execlen++;
63875 + }
63876 +
63877 + log:
63878 + gr_log_fs_str(GR_DO_AUDIT, GR_EXEC_AUDIT_MSG, bprm->file->f_path.dentry,
63879 + bprm->file->f_path.mnt, grarg);
63880 + mutex_unlock(&gr_exec_arg_mutex);
63881 +#endif
63882 + return;
63883 +}
63884 +
63885 +#ifdef CONFIG_GRKERNSEC
63886 +extern int gr_acl_is_capable(const int cap);
63887 +extern int gr_acl_is_capable_nolog(const int cap);
63888 +extern int gr_task_acl_is_capable(const struct task_struct *task, const struct cred *cred, const int cap);
63889 +extern int gr_task_acl_is_capable_nolog(const struct task_struct *task, const int cap);
63890 +extern int gr_chroot_is_capable(const int cap);
63891 +extern int gr_chroot_is_capable_nolog(const int cap);
63892 +extern int gr_task_chroot_is_capable(const struct task_struct *task, const struct cred *cred, const int cap);
63893 +extern int gr_task_chroot_is_capable_nolog(const struct task_struct *task, const int cap);
63894 +#endif
63895 +
63896 +const char *captab_log[] = {
63897 + "CAP_CHOWN",
63898 + "CAP_DAC_OVERRIDE",
63899 + "CAP_DAC_READ_SEARCH",
63900 + "CAP_FOWNER",
63901 + "CAP_FSETID",
63902 + "CAP_KILL",
63903 + "CAP_SETGID",
63904 + "CAP_SETUID",
63905 + "CAP_SETPCAP",
63906 + "CAP_LINUX_IMMUTABLE",
63907 + "CAP_NET_BIND_SERVICE",
63908 + "CAP_NET_BROADCAST",
63909 + "CAP_NET_ADMIN",
63910 + "CAP_NET_RAW",
63911 + "CAP_IPC_LOCK",
63912 + "CAP_IPC_OWNER",
63913 + "CAP_SYS_MODULE",
63914 + "CAP_SYS_RAWIO",
63915 + "CAP_SYS_CHROOT",
63916 + "CAP_SYS_PTRACE",
63917 + "CAP_SYS_PACCT",
63918 + "CAP_SYS_ADMIN",
63919 + "CAP_SYS_BOOT",
63920 + "CAP_SYS_NICE",
63921 + "CAP_SYS_RESOURCE",
63922 + "CAP_SYS_TIME",
63923 + "CAP_SYS_TTY_CONFIG",
63924 + "CAP_MKNOD",
63925 + "CAP_LEASE",
63926 + "CAP_AUDIT_WRITE",
63927 + "CAP_AUDIT_CONTROL",
63928 + "CAP_SETFCAP",
63929 + "CAP_MAC_OVERRIDE",
63930 + "CAP_MAC_ADMIN",
63931 + "CAP_SYSLOG",
63932 + "CAP_WAKE_ALARM"
63933 +};
63934 +
63935 +int captab_log_entries = sizeof(captab_log)/sizeof(captab_log[0]);
63936 +
63937 +int gr_is_capable(const int cap)
63938 +{
63939 +#ifdef CONFIG_GRKERNSEC
63940 + if (gr_acl_is_capable(cap) && gr_chroot_is_capable(cap))
63941 + return 1;
63942 + return 0;
63943 +#else
63944 + return 1;
63945 +#endif
63946 +}
63947 +
63948 +int gr_task_is_capable(const struct task_struct *task, const struct cred *cred, const int cap)
63949 +{
63950 +#ifdef CONFIG_GRKERNSEC
63951 + if (gr_task_acl_is_capable(task, cred, cap) && gr_task_chroot_is_capable(task, cred, cap))
63952 + return 1;
63953 + return 0;
63954 +#else
63955 + return 1;
63956 +#endif
63957 +}
63958 +
63959 +int gr_is_capable_nolog(const int cap)
63960 +{
63961 +#ifdef CONFIG_GRKERNSEC
63962 + if (gr_acl_is_capable_nolog(cap) && gr_chroot_is_capable_nolog(cap))
63963 + return 1;
63964 + return 0;
63965 +#else
63966 + return 1;
63967 +#endif
63968 +}
63969 +
63970 +int gr_task_is_capable_nolog(const struct task_struct *task, const int cap)
63971 +{
63972 +#ifdef CONFIG_GRKERNSEC
63973 + if (gr_task_acl_is_capable_nolog(task, cap) && gr_task_chroot_is_capable_nolog(task, cap))
63974 + return 1;
63975 + return 0;
63976 +#else
63977 + return 1;
63978 +#endif
63979 +}
63980 +
63981 +EXPORT_SYMBOL(gr_is_capable);
63982 +EXPORT_SYMBOL(gr_is_capable_nolog);
63983 +EXPORT_SYMBOL(gr_task_is_capable);
63984 +EXPORT_SYMBOL(gr_task_is_capable_nolog);
63985 diff --git a/grsecurity/grsec_fifo.c b/grsecurity/grsec_fifo.c
63986 new file mode 100644
63987 index 0000000..06cc6ea
63988 --- /dev/null
63989 +++ b/grsecurity/grsec_fifo.c
63990 @@ -0,0 +1,24 @@
63991 +#include <linux/kernel.h>
63992 +#include <linux/sched.h>
63993 +#include <linux/fs.h>
63994 +#include <linux/file.h>
63995 +#include <linux/grinternal.h>
63996 +
63997 +int
63998 +gr_handle_fifo(const struct dentry *dentry, const struct vfsmount *mnt,
63999 + const struct dentry *dir, const int flag, const int acc_mode)
64000 +{
64001 +#ifdef CONFIG_GRKERNSEC_FIFO
64002 + const struct cred *cred = current_cred();
64003 +
64004 + if (grsec_enable_fifo && S_ISFIFO(dentry->d_inode->i_mode) &&
64005 + !(flag & O_EXCL) && (dir->d_inode->i_mode & S_ISVTX) &&
64006 + !uid_eq(dentry->d_inode->i_uid, dir->d_inode->i_uid) &&
64007 + !uid_eq(cred->fsuid, dentry->d_inode->i_uid)) {
64008 + if (!inode_permission(dentry->d_inode, acc_mode))
64009 + 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));
64010 + return -EACCES;
64011 + }
64012 +#endif
64013 + return 0;
64014 +}
64015 diff --git a/grsecurity/grsec_fork.c b/grsecurity/grsec_fork.c
64016 new file mode 100644
64017 index 0000000..8ca18bf
64018 --- /dev/null
64019 +++ b/grsecurity/grsec_fork.c
64020 @@ -0,0 +1,23 @@
64021 +#include <linux/kernel.h>
64022 +#include <linux/sched.h>
64023 +#include <linux/grsecurity.h>
64024 +#include <linux/grinternal.h>
64025 +#include <linux/errno.h>
64026 +
64027 +void
64028 +gr_log_forkfail(const int retval)
64029 +{
64030 +#ifdef CONFIG_GRKERNSEC_FORKFAIL
64031 + if (grsec_enable_forkfail && (retval == -EAGAIN || retval == -ENOMEM)) {
64032 + switch (retval) {
64033 + case -EAGAIN:
64034 + gr_log_str(GR_DONT_AUDIT, GR_FAILFORK_MSG, "EAGAIN");
64035 + break;
64036 + case -ENOMEM:
64037 + gr_log_str(GR_DONT_AUDIT, GR_FAILFORK_MSG, "ENOMEM");
64038 + break;
64039 + }
64040 + }
64041 +#endif
64042 + return;
64043 +}
64044 diff --git a/grsecurity/grsec_init.c b/grsecurity/grsec_init.c
64045 new file mode 100644
64046 index 0000000..a862e9f
64047 --- /dev/null
64048 +++ b/grsecurity/grsec_init.c
64049 @@ -0,0 +1,283 @@
64050 +#include <linux/kernel.h>
64051 +#include <linux/sched.h>
64052 +#include <linux/mm.h>
64053 +#include <linux/gracl.h>
64054 +#include <linux/slab.h>
64055 +#include <linux/vmalloc.h>
64056 +#include <linux/percpu.h>
64057 +#include <linux/module.h>
64058 +
64059 +int grsec_enable_ptrace_readexec;
64060 +int grsec_enable_setxid;
64061 +int grsec_enable_symlinkown;
64062 +kgid_t grsec_symlinkown_gid;
64063 +int grsec_enable_brute;
64064 +int grsec_enable_link;
64065 +int grsec_enable_dmesg;
64066 +int grsec_enable_harden_ptrace;
64067 +int grsec_enable_fifo;
64068 +int grsec_enable_execlog;
64069 +int grsec_enable_signal;
64070 +int grsec_enable_forkfail;
64071 +int grsec_enable_audit_ptrace;
64072 +int grsec_enable_time;
64073 +int grsec_enable_audit_textrel;
64074 +int grsec_enable_group;
64075 +kgid_t grsec_audit_gid;
64076 +int grsec_enable_chdir;
64077 +int grsec_enable_mount;
64078 +int grsec_enable_rofs;
64079 +int grsec_enable_chroot_findtask;
64080 +int grsec_enable_chroot_mount;
64081 +int grsec_enable_chroot_shmat;
64082 +int grsec_enable_chroot_fchdir;
64083 +int grsec_enable_chroot_double;
64084 +int grsec_enable_chroot_pivot;
64085 +int grsec_enable_chroot_chdir;
64086 +int grsec_enable_chroot_chmod;
64087 +int grsec_enable_chroot_mknod;
64088 +int grsec_enable_chroot_nice;
64089 +int grsec_enable_chroot_execlog;
64090 +int grsec_enable_chroot_caps;
64091 +int grsec_enable_chroot_sysctl;
64092 +int grsec_enable_chroot_unix;
64093 +int grsec_enable_tpe;
64094 +kgid_t grsec_tpe_gid;
64095 +int grsec_enable_blackhole;
64096 +#ifdef CONFIG_IPV6_MODULE
64097 +EXPORT_SYMBOL(grsec_enable_blackhole);
64098 +#endif
64099 +int grsec_lastack_retries;
64100 +int grsec_enable_tpe_all;
64101 +int grsec_enable_tpe_invert;
64102 +int grsec_enable_socket_all;
64103 +kgid_t grsec_socket_all_gid;
64104 +int grsec_enable_socket_client;
64105 +kgid_t grsec_socket_client_gid;
64106 +int grsec_enable_socket_server;
64107 +kgid_t grsec_socket_server_gid;
64108 +int grsec_resource_logging;
64109 +int grsec_disable_privio;
64110 +int grsec_enable_log_rwxmaps;
64111 +int grsec_lock;
64112 +
64113 +DEFINE_SPINLOCK(grsec_alert_lock);
64114 +unsigned long grsec_alert_wtime = 0;
64115 +unsigned long grsec_alert_fyet = 0;
64116 +
64117 +DEFINE_SPINLOCK(grsec_audit_lock);
64118 +
64119 +DEFINE_RWLOCK(grsec_exec_file_lock);
64120 +
64121 +char *gr_shared_page[4];
64122 +
64123 +char *gr_alert_log_fmt;
64124 +char *gr_audit_log_fmt;
64125 +char *gr_alert_log_buf;
64126 +char *gr_audit_log_buf;
64127 +
64128 +extern struct gr_arg *gr_usermode;
64129 +extern unsigned char *gr_system_salt;
64130 +extern unsigned char *gr_system_sum;
64131 +
64132 +void __init
64133 +grsecurity_init(void)
64134 +{
64135 + int j;
64136 + /* create the per-cpu shared pages */
64137 +
64138 +#ifdef CONFIG_X86
64139 + memset((char *)(0x41a + PAGE_OFFSET), 0, 36);
64140 +#endif
64141 +
64142 + for (j = 0; j < 4; j++) {
64143 + gr_shared_page[j] = (char *)__alloc_percpu(PAGE_SIZE, __alignof__(unsigned long long));
64144 + if (gr_shared_page[j] == NULL) {
64145 + panic("Unable to allocate grsecurity shared page");
64146 + return;
64147 + }
64148 + }
64149 +
64150 + /* allocate log buffers */
64151 + gr_alert_log_fmt = kmalloc(512, GFP_KERNEL);
64152 + if (!gr_alert_log_fmt) {
64153 + panic("Unable to allocate grsecurity alert log format buffer");
64154 + return;
64155 + }
64156 + gr_audit_log_fmt = kmalloc(512, GFP_KERNEL);
64157 + if (!gr_audit_log_fmt) {
64158 + panic("Unable to allocate grsecurity audit log format buffer");
64159 + return;
64160 + }
64161 + gr_alert_log_buf = (char *) get_zeroed_page(GFP_KERNEL);
64162 + if (!gr_alert_log_buf) {
64163 + panic("Unable to allocate grsecurity alert log buffer");
64164 + return;
64165 + }
64166 + gr_audit_log_buf = (char *) get_zeroed_page(GFP_KERNEL);
64167 + if (!gr_audit_log_buf) {
64168 + panic("Unable to allocate grsecurity audit log buffer");
64169 + return;
64170 + }
64171 +
64172 + /* allocate memory for authentication structure */
64173 + gr_usermode = kmalloc(sizeof(struct gr_arg), GFP_KERNEL);
64174 + gr_system_salt = kmalloc(GR_SALT_LEN, GFP_KERNEL);
64175 + gr_system_sum = kmalloc(GR_SHA_LEN, GFP_KERNEL);
64176 +
64177 + if (!gr_usermode || !gr_system_salt || !gr_system_sum) {
64178 + panic("Unable to allocate grsecurity authentication structure");
64179 + return;
64180 + }
64181 +
64182 +
64183 +#ifdef CONFIG_GRKERNSEC_IO
64184 +#if !defined(CONFIG_GRKERNSEC_SYSCTL_DISTRO)
64185 + grsec_disable_privio = 1;
64186 +#elif defined(CONFIG_GRKERNSEC_SYSCTL_ON)
64187 + grsec_disable_privio = 1;
64188 +#else
64189 + grsec_disable_privio = 0;
64190 +#endif
64191 +#endif
64192 +
64193 +#ifdef CONFIG_GRKERNSEC_TPE_INVERT
64194 + /* for backward compatibility, tpe_invert always defaults to on if
64195 + enabled in the kernel
64196 + */
64197 + grsec_enable_tpe_invert = 1;
64198 +#endif
64199 +
64200 +#if !defined(CONFIG_GRKERNSEC_SYSCTL) || defined(CONFIG_GRKERNSEC_SYSCTL_ON)
64201 +#ifndef CONFIG_GRKERNSEC_SYSCTL
64202 + grsec_lock = 1;
64203 +#endif
64204 +
64205 +#ifdef CONFIG_GRKERNSEC_AUDIT_TEXTREL
64206 + grsec_enable_audit_textrel = 1;
64207 +#endif
64208 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
64209 + grsec_enable_log_rwxmaps = 1;
64210 +#endif
64211 +#ifdef CONFIG_GRKERNSEC_AUDIT_GROUP
64212 + grsec_enable_group = 1;
64213 + grsec_audit_gid = KGIDT_INIT(CONFIG_GRKERNSEC_AUDIT_GID);
64214 +#endif
64215 +#ifdef CONFIG_GRKERNSEC_PTRACE_READEXEC
64216 + grsec_enable_ptrace_readexec = 1;
64217 +#endif
64218 +#ifdef CONFIG_GRKERNSEC_AUDIT_CHDIR
64219 + grsec_enable_chdir = 1;
64220 +#endif
64221 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
64222 + grsec_enable_harden_ptrace = 1;
64223 +#endif
64224 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
64225 + grsec_enable_mount = 1;
64226 +#endif
64227 +#ifdef CONFIG_GRKERNSEC_LINK
64228 + grsec_enable_link = 1;
64229 +#endif
64230 +#ifdef CONFIG_GRKERNSEC_BRUTE
64231 + grsec_enable_brute = 1;
64232 +#endif
64233 +#ifdef CONFIG_GRKERNSEC_DMESG
64234 + grsec_enable_dmesg = 1;
64235 +#endif
64236 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
64237 + grsec_enable_blackhole = 1;
64238 + grsec_lastack_retries = 4;
64239 +#endif
64240 +#ifdef CONFIG_GRKERNSEC_FIFO
64241 + grsec_enable_fifo = 1;
64242 +#endif
64243 +#ifdef CONFIG_GRKERNSEC_EXECLOG
64244 + grsec_enable_execlog = 1;
64245 +#endif
64246 +#ifdef CONFIG_GRKERNSEC_SETXID
64247 + grsec_enable_setxid = 1;
64248 +#endif
64249 +#ifdef CONFIG_GRKERNSEC_SIGNAL
64250 + grsec_enable_signal = 1;
64251 +#endif
64252 +#ifdef CONFIG_GRKERNSEC_FORKFAIL
64253 + grsec_enable_forkfail = 1;
64254 +#endif
64255 +#ifdef CONFIG_GRKERNSEC_TIME
64256 + grsec_enable_time = 1;
64257 +#endif
64258 +#ifdef CONFIG_GRKERNSEC_RESLOG
64259 + grsec_resource_logging = 1;
64260 +#endif
64261 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
64262 + grsec_enable_chroot_findtask = 1;
64263 +#endif
64264 +#ifdef CONFIG_GRKERNSEC_CHROOT_UNIX
64265 + grsec_enable_chroot_unix = 1;
64266 +#endif
64267 +#ifdef CONFIG_GRKERNSEC_CHROOT_MOUNT
64268 + grsec_enable_chroot_mount = 1;
64269 +#endif
64270 +#ifdef CONFIG_GRKERNSEC_CHROOT_FCHDIR
64271 + grsec_enable_chroot_fchdir = 1;
64272 +#endif
64273 +#ifdef CONFIG_GRKERNSEC_CHROOT_SHMAT
64274 + grsec_enable_chroot_shmat = 1;
64275 +#endif
64276 +#ifdef CONFIG_GRKERNSEC_AUDIT_PTRACE
64277 + grsec_enable_audit_ptrace = 1;
64278 +#endif
64279 +#ifdef CONFIG_GRKERNSEC_CHROOT_DOUBLE
64280 + grsec_enable_chroot_double = 1;
64281 +#endif
64282 +#ifdef CONFIG_GRKERNSEC_CHROOT_PIVOT
64283 + grsec_enable_chroot_pivot = 1;
64284 +#endif
64285 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHDIR
64286 + grsec_enable_chroot_chdir = 1;
64287 +#endif
64288 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHMOD
64289 + grsec_enable_chroot_chmod = 1;
64290 +#endif
64291 +#ifdef CONFIG_GRKERNSEC_CHROOT_MKNOD
64292 + grsec_enable_chroot_mknod = 1;
64293 +#endif
64294 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
64295 + grsec_enable_chroot_nice = 1;
64296 +#endif
64297 +#ifdef CONFIG_GRKERNSEC_CHROOT_EXECLOG
64298 + grsec_enable_chroot_execlog = 1;
64299 +#endif
64300 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
64301 + grsec_enable_chroot_caps = 1;
64302 +#endif
64303 +#ifdef CONFIG_GRKERNSEC_CHROOT_SYSCTL
64304 + grsec_enable_chroot_sysctl = 1;
64305 +#endif
64306 +#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
64307 + grsec_enable_symlinkown = 1;
64308 + grsec_symlinkown_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SYMLINKOWN_GID);
64309 +#endif
64310 +#ifdef CONFIG_GRKERNSEC_TPE
64311 + grsec_enable_tpe = 1;
64312 + grsec_tpe_gid = KGIDT_INIT(CONFIG_GRKERNSEC_TPE_GID);
64313 +#ifdef CONFIG_GRKERNSEC_TPE_ALL
64314 + grsec_enable_tpe_all = 1;
64315 +#endif
64316 +#endif
64317 +#ifdef CONFIG_GRKERNSEC_SOCKET_ALL
64318 + grsec_enable_socket_all = 1;
64319 + grsec_socket_all_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SOCKET_ALL_GID);
64320 +#endif
64321 +#ifdef CONFIG_GRKERNSEC_SOCKET_CLIENT
64322 + grsec_enable_socket_client = 1;
64323 + grsec_socket_client_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SOCKET_CLIENT_GID);
64324 +#endif
64325 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
64326 + grsec_enable_socket_server = 1;
64327 + grsec_socket_server_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SOCKET_SERVER_GID);
64328 +#endif
64329 +#endif
64330 +
64331 + return;
64332 +}
64333 diff --git a/grsecurity/grsec_link.c b/grsecurity/grsec_link.c
64334 new file mode 100644
64335 index 0000000..5e05e20
64336 --- /dev/null
64337 +++ b/grsecurity/grsec_link.c
64338 @@ -0,0 +1,58 @@
64339 +#include <linux/kernel.h>
64340 +#include <linux/sched.h>
64341 +#include <linux/fs.h>
64342 +#include <linux/file.h>
64343 +#include <linux/grinternal.h>
64344 +
64345 +int gr_handle_symlink_owner(const struct path *link, const struct inode *target)
64346 +{
64347 +#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
64348 + const struct inode *link_inode = link->dentry->d_inode;
64349 +
64350 + if (grsec_enable_symlinkown && in_group_p(grsec_symlinkown_gid) &&
64351 + /* ignore root-owned links, e.g. /proc/self */
64352 + gr_is_global_nonroot(link_inode->i_uid) && target &&
64353 + !uid_eq(link_inode->i_uid, target->i_uid)) {
64354 + gr_log_fs_int2(GR_DONT_AUDIT, GR_SYMLINKOWNER_MSG, link->dentry, link->mnt, link_inode->i_uid, target->i_uid);
64355 + return 1;
64356 + }
64357 +#endif
64358 + return 0;
64359 +}
64360 +
64361 +int
64362 +gr_handle_follow_link(const struct inode *parent,
64363 + const struct inode *inode,
64364 + const struct dentry *dentry, const struct vfsmount *mnt)
64365 +{
64366 +#ifdef CONFIG_GRKERNSEC_LINK
64367 + const struct cred *cred = current_cred();
64368 +
64369 + if (grsec_enable_link && S_ISLNK(inode->i_mode) &&
64370 + (parent->i_mode & S_ISVTX) && !uid_eq(parent->i_uid, inode->i_uid) &&
64371 + (parent->i_mode & S_IWOTH) && !uid_eq(cred->fsuid, inode->i_uid)) {
64372 + gr_log_fs_int2(GR_DONT_AUDIT, GR_SYMLINK_MSG, dentry, mnt, inode->i_uid, inode->i_gid);
64373 + return -EACCES;
64374 + }
64375 +#endif
64376 + return 0;
64377 +}
64378 +
64379 +int
64380 +gr_handle_hardlink(const struct dentry *dentry,
64381 + const struct vfsmount *mnt,
64382 + struct inode *inode, const int mode, const struct filename *to)
64383 +{
64384 +#ifdef CONFIG_GRKERNSEC_LINK
64385 + const struct cred *cred = current_cred();
64386 +
64387 + if (grsec_enable_link && !uid_eq(cred->fsuid, inode->i_uid) &&
64388 + (!S_ISREG(mode) || is_privileged_binary(dentry) ||
64389 + (inode_permission(inode, MAY_READ | MAY_WRITE))) &&
64390 + !capable(CAP_FOWNER) && gr_is_global_nonroot(cred->uid)) {
64391 + gr_log_fs_int2_str(GR_DONT_AUDIT, GR_HARDLINK_MSG, dentry, mnt, inode->i_uid, inode->i_gid, to->name);
64392 + return -EPERM;
64393 + }
64394 +#endif
64395 + return 0;
64396 +}
64397 diff --git a/grsecurity/grsec_log.c b/grsecurity/grsec_log.c
64398 new file mode 100644
64399 index 0000000..7c06085
64400 --- /dev/null
64401 +++ b/grsecurity/grsec_log.c
64402 @@ -0,0 +1,326 @@
64403 +#include <linux/kernel.h>
64404 +#include <linux/sched.h>
64405 +#include <linux/file.h>
64406 +#include <linux/tty.h>
64407 +#include <linux/fs.h>
64408 +#include <linux/grinternal.h>
64409 +
64410 +#ifdef CONFIG_TREE_PREEMPT_RCU
64411 +#define DISABLE_PREEMPT() preempt_disable()
64412 +#define ENABLE_PREEMPT() preempt_enable()
64413 +#else
64414 +#define DISABLE_PREEMPT()
64415 +#define ENABLE_PREEMPT()
64416 +#endif
64417 +
64418 +#define BEGIN_LOCKS(x) \
64419 + DISABLE_PREEMPT(); \
64420 + rcu_read_lock(); \
64421 + read_lock(&tasklist_lock); \
64422 + read_lock(&grsec_exec_file_lock); \
64423 + if (x != GR_DO_AUDIT) \
64424 + spin_lock(&grsec_alert_lock); \
64425 + else \
64426 + spin_lock(&grsec_audit_lock)
64427 +
64428 +#define END_LOCKS(x) \
64429 + if (x != GR_DO_AUDIT) \
64430 + spin_unlock(&grsec_alert_lock); \
64431 + else \
64432 + spin_unlock(&grsec_audit_lock); \
64433 + read_unlock(&grsec_exec_file_lock); \
64434 + read_unlock(&tasklist_lock); \
64435 + rcu_read_unlock(); \
64436 + ENABLE_PREEMPT(); \
64437 + if (x == GR_DONT_AUDIT) \
64438 + gr_handle_alertkill(current)
64439 +
64440 +enum {
64441 + FLOODING,
64442 + NO_FLOODING
64443 +};
64444 +
64445 +extern char *gr_alert_log_fmt;
64446 +extern char *gr_audit_log_fmt;
64447 +extern char *gr_alert_log_buf;
64448 +extern char *gr_audit_log_buf;
64449 +
64450 +static int gr_log_start(int audit)
64451 +{
64452 + char *loglevel = (audit == GR_DO_AUDIT) ? KERN_INFO : KERN_ALERT;
64453 + char *fmt = (audit == GR_DO_AUDIT) ? gr_audit_log_fmt : gr_alert_log_fmt;
64454 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
64455 +#if (CONFIG_GRKERNSEC_FLOODTIME > 0 && CONFIG_GRKERNSEC_FLOODBURST > 0)
64456 + unsigned long curr_secs = get_seconds();
64457 +
64458 + if (audit == GR_DO_AUDIT)
64459 + goto set_fmt;
64460 +
64461 + if (!grsec_alert_wtime || time_after(curr_secs, grsec_alert_wtime + CONFIG_GRKERNSEC_FLOODTIME)) {
64462 + grsec_alert_wtime = curr_secs;
64463 + grsec_alert_fyet = 0;
64464 + } else if (time_before_eq(curr_secs, grsec_alert_wtime + CONFIG_GRKERNSEC_FLOODTIME)
64465 + && (grsec_alert_fyet < CONFIG_GRKERNSEC_FLOODBURST)) {
64466 + grsec_alert_fyet++;
64467 + } else if (grsec_alert_fyet == CONFIG_GRKERNSEC_FLOODBURST) {
64468 + grsec_alert_wtime = curr_secs;
64469 + grsec_alert_fyet++;
64470 + printk(KERN_ALERT "grsec: more alerts, logging disabled for %d seconds\n", CONFIG_GRKERNSEC_FLOODTIME);
64471 + return FLOODING;
64472 + }
64473 + else return FLOODING;
64474 +
64475 +set_fmt:
64476 +#endif
64477 + memset(buf, 0, PAGE_SIZE);
64478 + if (current->signal->curr_ip && gr_acl_is_enabled()) {
64479 + sprintf(fmt, "%s%s", loglevel, "grsec: From %pI4: (%.64s:%c:%.950s) ");
64480 + snprintf(buf, PAGE_SIZE - 1, fmt, &current->signal->curr_ip, current->role->rolename, gr_roletype_to_char(), current->acl->filename);
64481 + } else if (current->signal->curr_ip) {
64482 + sprintf(fmt, "%s%s", loglevel, "grsec: From %pI4: ");
64483 + snprintf(buf, PAGE_SIZE - 1, fmt, &current->signal->curr_ip);
64484 + } else if (gr_acl_is_enabled()) {
64485 + sprintf(fmt, "%s%s", loglevel, "grsec: (%.64s:%c:%.950s) ");
64486 + snprintf(buf, PAGE_SIZE - 1, fmt, current->role->rolename, gr_roletype_to_char(), current->acl->filename);
64487 + } else {
64488 + sprintf(fmt, "%s%s", loglevel, "grsec: ");
64489 + strcpy(buf, fmt);
64490 + }
64491 +
64492 + return NO_FLOODING;
64493 +}
64494 +
64495 +static void gr_log_middle(int audit, const char *msg, va_list ap)
64496 + __attribute__ ((format (printf, 2, 0)));
64497 +
64498 +static void gr_log_middle(int audit, const char *msg, va_list ap)
64499 +{
64500 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
64501 + unsigned int len = strlen(buf);
64502 +
64503 + vsnprintf(buf + len, PAGE_SIZE - len - 1, msg, ap);
64504 +
64505 + return;
64506 +}
64507 +
64508 +static void gr_log_middle_varargs(int audit, const char *msg, ...)
64509 + __attribute__ ((format (printf, 2, 3)));
64510 +
64511 +static void gr_log_middle_varargs(int audit, const char *msg, ...)
64512 +{
64513 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
64514 + unsigned int len = strlen(buf);
64515 + va_list ap;
64516 +
64517 + va_start(ap, msg);
64518 + vsnprintf(buf + len, PAGE_SIZE - len - 1, msg, ap);
64519 + va_end(ap);
64520 +
64521 + return;
64522 +}
64523 +
64524 +static void gr_log_end(int audit, int append_default)
64525 +{
64526 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
64527 + if (append_default) {
64528 + struct task_struct *task = current;
64529 + struct task_struct *parent = task->real_parent;
64530 + const struct cred *cred = __task_cred(task);
64531 + const struct cred *pcred = __task_cred(parent);
64532 + unsigned int len = strlen(buf);
64533 +
64534 + 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));
64535 + }
64536 +
64537 + printk("%s\n", buf);
64538 +
64539 + return;
64540 +}
64541 +
64542 +void gr_log_varargs(int audit, const char *msg, int argtypes, ...)
64543 +{
64544 + int logtype;
64545 + char *result = (audit == GR_DO_AUDIT) ? "successful" : "denied";
64546 + char *str1 = NULL, *str2 = NULL, *str3 = NULL;
64547 + void *voidptr = NULL;
64548 + int num1 = 0, num2 = 0;
64549 + unsigned long ulong1 = 0, ulong2 = 0;
64550 + struct dentry *dentry = NULL;
64551 + struct vfsmount *mnt = NULL;
64552 + struct file *file = NULL;
64553 + struct task_struct *task = NULL;
64554 + const struct cred *cred, *pcred;
64555 + va_list ap;
64556 +
64557 + BEGIN_LOCKS(audit);
64558 + logtype = gr_log_start(audit);
64559 + if (logtype == FLOODING) {
64560 + END_LOCKS(audit);
64561 + return;
64562 + }
64563 + va_start(ap, argtypes);
64564 + switch (argtypes) {
64565 + case GR_TTYSNIFF:
64566 + task = va_arg(ap, struct task_struct *);
64567 + 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));
64568 + break;
64569 + case GR_SYSCTL_HIDDEN:
64570 + str1 = va_arg(ap, char *);
64571 + gr_log_middle_varargs(audit, msg, result, str1);
64572 + break;
64573 + case GR_RBAC:
64574 + dentry = va_arg(ap, struct dentry *);
64575 + mnt = va_arg(ap, struct vfsmount *);
64576 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt));
64577 + break;
64578 + case GR_RBAC_STR:
64579 + dentry = va_arg(ap, struct dentry *);
64580 + mnt = va_arg(ap, struct vfsmount *);
64581 + str1 = va_arg(ap, char *);
64582 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt), str1);
64583 + break;
64584 + case GR_STR_RBAC:
64585 + str1 = va_arg(ap, char *);
64586 + dentry = va_arg(ap, struct dentry *);
64587 + mnt = va_arg(ap, struct vfsmount *);
64588 + gr_log_middle_varargs(audit, msg, result, str1, gr_to_filename(dentry, mnt));
64589 + break;
64590 + case GR_RBAC_MODE2:
64591 + dentry = va_arg(ap, struct dentry *);
64592 + mnt = va_arg(ap, struct vfsmount *);
64593 + str1 = va_arg(ap, char *);
64594 + str2 = va_arg(ap, char *);
64595 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt), str1, str2);
64596 + break;
64597 + case GR_RBAC_MODE3:
64598 + dentry = va_arg(ap, struct dentry *);
64599 + mnt = va_arg(ap, struct vfsmount *);
64600 + str1 = va_arg(ap, char *);
64601 + str2 = va_arg(ap, char *);
64602 + str3 = va_arg(ap, char *);
64603 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt), str1, str2, str3);
64604 + break;
64605 + case GR_FILENAME:
64606 + dentry = va_arg(ap, struct dentry *);
64607 + mnt = va_arg(ap, struct vfsmount *);
64608 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt));
64609 + break;
64610 + case GR_STR_FILENAME:
64611 + str1 = va_arg(ap, char *);
64612 + dentry = va_arg(ap, struct dentry *);
64613 + mnt = va_arg(ap, struct vfsmount *);
64614 + gr_log_middle_varargs(audit, msg, str1, gr_to_filename(dentry, mnt));
64615 + break;
64616 + case GR_FILENAME_STR:
64617 + dentry = va_arg(ap, struct dentry *);
64618 + mnt = va_arg(ap, struct vfsmount *);
64619 + str1 = va_arg(ap, char *);
64620 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt), str1);
64621 + break;
64622 + case GR_FILENAME_TWO_INT:
64623 + dentry = va_arg(ap, struct dentry *);
64624 + mnt = va_arg(ap, struct vfsmount *);
64625 + num1 = va_arg(ap, int);
64626 + num2 = va_arg(ap, int);
64627 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt), num1, num2);
64628 + break;
64629 + case GR_FILENAME_TWO_INT_STR:
64630 + dentry = va_arg(ap, struct dentry *);
64631 + mnt = va_arg(ap, struct vfsmount *);
64632 + num1 = va_arg(ap, int);
64633 + num2 = va_arg(ap, int);
64634 + str1 = va_arg(ap, char *);
64635 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt), num1, num2, str1);
64636 + break;
64637 + case GR_TEXTREL:
64638 + file = va_arg(ap, struct file *);
64639 + ulong1 = va_arg(ap, unsigned long);
64640 + ulong2 = va_arg(ap, unsigned long);
64641 + gr_log_middle_varargs(audit, msg, file ? gr_to_filename(file->f_path.dentry, file->f_path.mnt) : "<anonymous mapping>", ulong1, ulong2);
64642 + break;
64643 + case GR_PTRACE:
64644 + task = va_arg(ap, struct task_struct *);
64645 + 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));
64646 + break;
64647 + case GR_RESOURCE:
64648 + task = va_arg(ap, struct task_struct *);
64649 + cred = __task_cred(task);
64650 + pcred = __task_cred(task->real_parent);
64651 + ulong1 = va_arg(ap, unsigned long);
64652 + str1 = va_arg(ap, char *);
64653 + ulong2 = va_arg(ap, unsigned long);
64654 + 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));
64655 + break;
64656 + case GR_CAP:
64657 + task = va_arg(ap, struct task_struct *);
64658 + cred = __task_cred(task);
64659 + pcred = __task_cred(task->real_parent);
64660 + str1 = va_arg(ap, char *);
64661 + 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));
64662 + break;
64663 + case GR_SIG:
64664 + str1 = va_arg(ap, char *);
64665 + voidptr = va_arg(ap, void *);
64666 + gr_log_middle_varargs(audit, msg, str1, voidptr);
64667 + break;
64668 + case GR_SIG2:
64669 + task = va_arg(ap, struct task_struct *);
64670 + cred = __task_cred(task);
64671 + pcred = __task_cred(task->real_parent);
64672 + num1 = va_arg(ap, int);
64673 + 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));
64674 + break;
64675 + case GR_CRASH1:
64676 + task = va_arg(ap, struct task_struct *);
64677 + cred = __task_cred(task);
64678 + pcred = __task_cred(task->real_parent);
64679 + ulong1 = va_arg(ap, unsigned long);
64680 + 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);
64681 + break;
64682 + case GR_CRASH2:
64683 + task = va_arg(ap, struct task_struct *);
64684 + cred = __task_cred(task);
64685 + pcred = __task_cred(task->real_parent);
64686 + ulong1 = va_arg(ap, unsigned long);
64687 + 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);
64688 + break;
64689 + case GR_RWXMAP:
64690 + file = va_arg(ap, struct file *);
64691 + gr_log_middle_varargs(audit, msg, file ? gr_to_filename(file->f_path.dentry, file->f_path.mnt) : "<anonymous mapping>");
64692 + break;
64693 + case GR_PSACCT:
64694 + {
64695 + unsigned int wday, cday;
64696 + __u8 whr, chr;
64697 + __u8 wmin, cmin;
64698 + __u8 wsec, csec;
64699 + char cur_tty[64] = { 0 };
64700 + char parent_tty[64] = { 0 };
64701 +
64702 + task = va_arg(ap, struct task_struct *);
64703 + wday = va_arg(ap, unsigned int);
64704 + cday = va_arg(ap, unsigned int);
64705 + whr = va_arg(ap, int);
64706 + chr = va_arg(ap, int);
64707 + wmin = va_arg(ap, int);
64708 + cmin = va_arg(ap, int);
64709 + wsec = va_arg(ap, int);
64710 + csec = va_arg(ap, int);
64711 + ulong1 = va_arg(ap, unsigned long);
64712 + cred = __task_cred(task);
64713 + pcred = __task_cred(task->real_parent);
64714 +
64715 + 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));
64716 + }
64717 + break;
64718 + default:
64719 + gr_log_middle(audit, msg, ap);
64720 + }
64721 + va_end(ap);
64722 + // these don't need DEFAULTSECARGS printed on the end
64723 + if (argtypes == GR_CRASH1 || argtypes == GR_CRASH2)
64724 + gr_log_end(audit, 0);
64725 + else
64726 + gr_log_end(audit, 1);
64727 + END_LOCKS(audit);
64728 +}
64729 diff --git a/grsecurity/grsec_mem.c b/grsecurity/grsec_mem.c
64730 new file mode 100644
64731 index 0000000..f536303
64732 --- /dev/null
64733 +++ b/grsecurity/grsec_mem.c
64734 @@ -0,0 +1,40 @@
64735 +#include <linux/kernel.h>
64736 +#include <linux/sched.h>
64737 +#include <linux/mm.h>
64738 +#include <linux/mman.h>
64739 +#include <linux/grinternal.h>
64740 +
64741 +void
64742 +gr_handle_ioperm(void)
64743 +{
64744 + gr_log_noargs(GR_DONT_AUDIT, GR_IOPERM_MSG);
64745 + return;
64746 +}
64747 +
64748 +void
64749 +gr_handle_iopl(void)
64750 +{
64751 + gr_log_noargs(GR_DONT_AUDIT, GR_IOPL_MSG);
64752 + return;
64753 +}
64754 +
64755 +void
64756 +gr_handle_mem_readwrite(u64 from, u64 to)
64757 +{
64758 + gr_log_two_u64(GR_DONT_AUDIT, GR_MEM_READWRITE_MSG, from, to);
64759 + return;
64760 +}
64761 +
64762 +void
64763 +gr_handle_vm86(void)
64764 +{
64765 + gr_log_noargs(GR_DONT_AUDIT, GR_VM86_MSG);
64766 + return;
64767 +}
64768 +
64769 +void
64770 +gr_log_badprocpid(const char *entry)
64771 +{
64772 + gr_log_str(GR_DONT_AUDIT, GR_BADPROCPID_MSG, entry);
64773 + return;
64774 +}
64775 diff --git a/grsecurity/grsec_mount.c b/grsecurity/grsec_mount.c
64776 new file mode 100644
64777 index 0000000..2131422
64778 --- /dev/null
64779 +++ b/grsecurity/grsec_mount.c
64780 @@ -0,0 +1,62 @@
64781 +#include <linux/kernel.h>
64782 +#include <linux/sched.h>
64783 +#include <linux/mount.h>
64784 +#include <linux/grsecurity.h>
64785 +#include <linux/grinternal.h>
64786 +
64787 +void
64788 +gr_log_remount(const char *devname, const int retval)
64789 +{
64790 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
64791 + if (grsec_enable_mount && (retval >= 0))
64792 + gr_log_str(GR_DO_AUDIT, GR_REMOUNT_AUDIT_MSG, devname ? devname : "none");
64793 +#endif
64794 + return;
64795 +}
64796 +
64797 +void
64798 +gr_log_unmount(const char *devname, const int retval)
64799 +{
64800 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
64801 + if (grsec_enable_mount && (retval >= 0))
64802 + gr_log_str(GR_DO_AUDIT, GR_UNMOUNT_AUDIT_MSG, devname ? devname : "none");
64803 +#endif
64804 + return;
64805 +}
64806 +
64807 +void
64808 +gr_log_mount(const char *from, const char *to, const int retval)
64809 +{
64810 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
64811 + if (grsec_enable_mount && (retval >= 0))
64812 + gr_log_str_str(GR_DO_AUDIT, GR_MOUNT_AUDIT_MSG, from ? from : "none", to);
64813 +#endif
64814 + return;
64815 +}
64816 +
64817 +int
64818 +gr_handle_rofs_mount(struct dentry *dentry, struct vfsmount *mnt, int mnt_flags)
64819 +{
64820 +#ifdef CONFIG_GRKERNSEC_ROFS
64821 + if (grsec_enable_rofs && !(mnt_flags & MNT_READONLY)) {
64822 + gr_log_fs_generic(GR_DO_AUDIT, GR_ROFS_MOUNT_MSG, dentry, mnt);
64823 + return -EPERM;
64824 + } else
64825 + return 0;
64826 +#endif
64827 + return 0;
64828 +}
64829 +
64830 +int
64831 +gr_handle_rofs_blockwrite(struct dentry *dentry, struct vfsmount *mnt, int acc_mode)
64832 +{
64833 +#ifdef CONFIG_GRKERNSEC_ROFS
64834 + if (grsec_enable_rofs && (acc_mode & MAY_WRITE) &&
64835 + dentry->d_inode && S_ISBLK(dentry->d_inode->i_mode)) {
64836 + gr_log_fs_generic(GR_DO_AUDIT, GR_ROFS_BLOCKWRITE_MSG, dentry, mnt);
64837 + return -EPERM;
64838 + } else
64839 + return 0;
64840 +#endif
64841 + return 0;
64842 +}
64843 diff --git a/grsecurity/grsec_pax.c b/grsecurity/grsec_pax.c
64844 new file mode 100644
64845 index 0000000..a3b12a0
64846 --- /dev/null
64847 +++ b/grsecurity/grsec_pax.c
64848 @@ -0,0 +1,36 @@
64849 +#include <linux/kernel.h>
64850 +#include <linux/sched.h>
64851 +#include <linux/mm.h>
64852 +#include <linux/file.h>
64853 +#include <linux/grinternal.h>
64854 +#include <linux/grsecurity.h>
64855 +
64856 +void
64857 +gr_log_textrel(struct vm_area_struct * vma)
64858 +{
64859 +#ifdef CONFIG_GRKERNSEC_AUDIT_TEXTREL
64860 + if (grsec_enable_audit_textrel)
64861 + gr_log_textrel_ulong_ulong(GR_DO_AUDIT, GR_TEXTREL_AUDIT_MSG, vma->vm_file, vma->vm_start, vma->vm_pgoff);
64862 +#endif
64863 + return;
64864 +}
64865 +
64866 +void
64867 +gr_log_rwxmmap(struct file *file)
64868 +{
64869 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
64870 + if (grsec_enable_log_rwxmaps)
64871 + gr_log_rwxmap(GR_DONT_AUDIT, GR_RWXMMAP_MSG, file);
64872 +#endif
64873 + return;
64874 +}
64875 +
64876 +void
64877 +gr_log_rwxmprotect(struct file *file)
64878 +{
64879 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
64880 + if (grsec_enable_log_rwxmaps)
64881 + gr_log_rwxmap(GR_DONT_AUDIT, GR_RWXMPROTECT_MSG, file);
64882 +#endif
64883 + return;
64884 +}
64885 diff --git a/grsecurity/grsec_ptrace.c b/grsecurity/grsec_ptrace.c
64886 new file mode 100644
64887 index 0000000..f7f29aa
64888 --- /dev/null
64889 +++ b/grsecurity/grsec_ptrace.c
64890 @@ -0,0 +1,30 @@
64891 +#include <linux/kernel.h>
64892 +#include <linux/sched.h>
64893 +#include <linux/grinternal.h>
64894 +#include <linux/security.h>
64895 +
64896 +void
64897 +gr_audit_ptrace(struct task_struct *task)
64898 +{
64899 +#ifdef CONFIG_GRKERNSEC_AUDIT_PTRACE
64900 + if (grsec_enable_audit_ptrace)
64901 + gr_log_ptrace(GR_DO_AUDIT, GR_PTRACE_AUDIT_MSG, task);
64902 +#endif
64903 + return;
64904 +}
64905 +
64906 +int
64907 +gr_ptrace_readexec(struct file *file, int unsafe_flags)
64908 +{
64909 +#ifdef CONFIG_GRKERNSEC_PTRACE_READEXEC
64910 + const struct dentry *dentry = file->f_path.dentry;
64911 + const struct vfsmount *mnt = file->f_path.mnt;
64912 +
64913 + if (grsec_enable_ptrace_readexec && (unsafe_flags & LSM_UNSAFE_PTRACE) &&
64914 + (inode_permission(dentry->d_inode, MAY_READ) || !gr_acl_handle_open(dentry, mnt, MAY_READ))) {
64915 + gr_log_fs_generic(GR_DONT_AUDIT, GR_PTRACE_READEXEC_MSG, dentry, mnt);
64916 + return -EACCES;
64917 + }
64918 +#endif
64919 + return 0;
64920 +}
64921 diff --git a/grsecurity/grsec_sig.c b/grsecurity/grsec_sig.c
64922 new file mode 100644
64923 index 0000000..e09715a
64924 --- /dev/null
64925 +++ b/grsecurity/grsec_sig.c
64926 @@ -0,0 +1,222 @@
64927 +#include <linux/kernel.h>
64928 +#include <linux/sched.h>
64929 +#include <linux/delay.h>
64930 +#include <linux/grsecurity.h>
64931 +#include <linux/grinternal.h>
64932 +#include <linux/hardirq.h>
64933 +
64934 +char *signames[] = {
64935 + [SIGSEGV] = "Segmentation fault",
64936 + [SIGILL] = "Illegal instruction",
64937 + [SIGABRT] = "Abort",
64938 + [SIGBUS] = "Invalid alignment/Bus error"
64939 +};
64940 +
64941 +void
64942 +gr_log_signal(const int sig, const void *addr, const struct task_struct *t)
64943 +{
64944 +#ifdef CONFIG_GRKERNSEC_SIGNAL
64945 + if (grsec_enable_signal && ((sig == SIGSEGV) || (sig == SIGILL) ||
64946 + (sig == SIGABRT) || (sig == SIGBUS))) {
64947 + if (task_pid_nr(t) == task_pid_nr(current)) {
64948 + gr_log_sig_addr(GR_DONT_AUDIT_GOOD, GR_UNISIGLOG_MSG, signames[sig], addr);
64949 + } else {
64950 + gr_log_sig_task(GR_DONT_AUDIT_GOOD, GR_DUALSIGLOG_MSG, t, sig);
64951 + }
64952 + }
64953 +#endif
64954 + return;
64955 +}
64956 +
64957 +int
64958 +gr_handle_signal(const struct task_struct *p, const int sig)
64959 +{
64960 +#ifdef CONFIG_GRKERNSEC
64961 + /* ignore the 0 signal for protected task checks */
64962 + if (task_pid_nr(current) > 1 && sig && gr_check_protected_task(p)) {
64963 + gr_log_sig_task(GR_DONT_AUDIT, GR_SIG_ACL_MSG, p, sig);
64964 + return -EPERM;
64965 + } else if (gr_pid_is_chrooted((struct task_struct *)p)) {
64966 + return -EPERM;
64967 + }
64968 +#endif
64969 + return 0;
64970 +}
64971 +
64972 +#ifdef CONFIG_GRKERNSEC
64973 +extern int specific_send_sig_info(int sig, struct siginfo *info, struct task_struct *t);
64974 +
64975 +int gr_fake_force_sig(int sig, struct task_struct *t)
64976 +{
64977 + unsigned long int flags;
64978 + int ret, blocked, ignored;
64979 + struct k_sigaction *action;
64980 +
64981 + spin_lock_irqsave(&t->sighand->siglock, flags);
64982 + action = &t->sighand->action[sig-1];
64983 + ignored = action->sa.sa_handler == SIG_IGN;
64984 + blocked = sigismember(&t->blocked, sig);
64985 + if (blocked || ignored) {
64986 + action->sa.sa_handler = SIG_DFL;
64987 + if (blocked) {
64988 + sigdelset(&t->blocked, sig);
64989 + recalc_sigpending_and_wake(t);
64990 + }
64991 + }
64992 + if (action->sa.sa_handler == SIG_DFL)
64993 + t->signal->flags &= ~SIGNAL_UNKILLABLE;
64994 + ret = specific_send_sig_info(sig, SEND_SIG_PRIV, t);
64995 +
64996 + spin_unlock_irqrestore(&t->sighand->siglock, flags);
64997 +
64998 + return ret;
64999 +}
65000 +#endif
65001 +
65002 +#ifdef CONFIG_GRKERNSEC_BRUTE
65003 +#define GR_USER_BAN_TIME (15 * 60)
65004 +#define GR_DAEMON_BRUTE_TIME (30 * 60)
65005 +
65006 +static int __get_dumpable(unsigned long mm_flags)
65007 +{
65008 + int ret;
65009 +
65010 + ret = mm_flags & MMF_DUMPABLE_MASK;
65011 + return (ret >= 2) ? 2 : ret;
65012 +}
65013 +#endif
65014 +
65015 +void gr_handle_brute_attach(unsigned long mm_flags)
65016 +{
65017 +#ifdef CONFIG_GRKERNSEC_BRUTE
65018 + struct task_struct *p = current;
65019 + kuid_t uid = GLOBAL_ROOT_UID;
65020 + int daemon = 0;
65021 +
65022 + if (!grsec_enable_brute)
65023 + return;
65024 +
65025 + rcu_read_lock();
65026 + read_lock(&tasklist_lock);
65027 + read_lock(&grsec_exec_file_lock);
65028 + if (p->real_parent && p->real_parent->exec_file == p->exec_file) {
65029 + p->real_parent->brute_expires = get_seconds() + GR_DAEMON_BRUTE_TIME;
65030 + p->real_parent->brute = 1;
65031 + daemon = 1;
65032 + } else {
65033 + const struct cred *cred = __task_cred(p), *cred2;
65034 + struct task_struct *tsk, *tsk2;
65035 +
65036 + if (!__get_dumpable(mm_flags) && gr_is_global_nonroot(cred->uid)) {
65037 + struct user_struct *user;
65038 +
65039 + uid = cred->uid;
65040 +
65041 + /* this is put upon execution past expiration */
65042 + user = find_user(uid);
65043 + if (user == NULL)
65044 + goto unlock;
65045 + user->banned = 1;
65046 + user->ban_expires = get_seconds() + GR_USER_BAN_TIME;
65047 + if (user->ban_expires == ~0UL)
65048 + user->ban_expires--;
65049 +
65050 + do_each_thread(tsk2, tsk) {
65051 + cred2 = __task_cred(tsk);
65052 + if (tsk != p && uid_eq(cred2->uid, uid))
65053 + gr_fake_force_sig(SIGKILL, tsk);
65054 + } while_each_thread(tsk2, tsk);
65055 + }
65056 + }
65057 +unlock:
65058 + read_unlock(&grsec_exec_file_lock);
65059 + read_unlock(&tasklist_lock);
65060 + rcu_read_unlock();
65061 +
65062 + if (gr_is_global_nonroot(uid))
65063 + printk(KERN_ALERT "grsec: bruteforce prevention initiated against uid %u, banning for %d minutes\n",
65064 + GR_GLOBAL_UID(uid), GR_USER_BAN_TIME / 60);
65065 + else if (daemon)
65066 + gr_log_noargs(GR_DONT_AUDIT, GR_BRUTE_DAEMON_MSG);
65067 +
65068 +#endif
65069 + return;
65070 +}
65071 +
65072 +void gr_handle_brute_check(void)
65073 +{
65074 +#ifdef CONFIG_GRKERNSEC_BRUTE
65075 + struct task_struct *p = current;
65076 +
65077 + if (unlikely(p->brute)) {
65078 + if (!grsec_enable_brute)
65079 + p->brute = 0;
65080 + else if (time_before(get_seconds(), p->brute_expires))
65081 + msleep(30 * 1000);
65082 + }
65083 +#endif
65084 + return;
65085 +}
65086 +
65087 +void gr_handle_kernel_exploit(void)
65088 +{
65089 +#ifdef CONFIG_GRKERNSEC_KERN_LOCKOUT
65090 + const struct cred *cred;
65091 + struct task_struct *tsk, *tsk2;
65092 + struct user_struct *user;
65093 + kuid_t uid;
65094 +
65095 + if (in_irq() || in_serving_softirq() || in_nmi())
65096 + panic("grsec: halting the system due to suspicious kernel crash caused in interrupt context");
65097 +
65098 + uid = current_uid();
65099 +
65100 + if (gr_is_global_root(uid))
65101 + panic("grsec: halting the system due to suspicious kernel crash caused by root");
65102 + else {
65103 + /* kill all the processes of this user, hold a reference
65104 + to their creds struct, and prevent them from creating
65105 + another process until system reset
65106 + */
65107 + printk(KERN_ALERT "grsec: banning user with uid %u until system restart for suspicious kernel crash\n",
65108 + GR_GLOBAL_UID(uid));
65109 + /* we intentionally leak this ref */
65110 + user = get_uid(current->cred->user);
65111 + if (user) {
65112 + user->banned = 1;
65113 + user->ban_expires = ~0UL;
65114 + }
65115 +
65116 + read_lock(&tasklist_lock);
65117 + do_each_thread(tsk2, tsk) {
65118 + cred = __task_cred(tsk);
65119 + if (uid_eq(cred->uid, uid))
65120 + gr_fake_force_sig(SIGKILL, tsk);
65121 + } while_each_thread(tsk2, tsk);
65122 + read_unlock(&tasklist_lock);
65123 + }
65124 +#endif
65125 +}
65126 +
65127 +int __gr_process_user_ban(struct user_struct *user)
65128 +{
65129 +#if defined(CONFIG_GRKERNSEC_KERN_LOCKOUT) || defined(CONFIG_GRKERNSEC_BRUTE)
65130 + if (unlikely(user->banned)) {
65131 + if (user->ban_expires != ~0UL && time_after_eq(get_seconds(), user->ban_expires)) {
65132 + user->banned = 0;
65133 + user->ban_expires = 0;
65134 + free_uid(user);
65135 + } else
65136 + return -EPERM;
65137 + }
65138 +#endif
65139 + return 0;
65140 +}
65141 +
65142 +int gr_process_user_ban(void)
65143 +{
65144 +#if defined(CONFIG_GRKERNSEC_KERN_LOCKOUT) || defined(CONFIG_GRKERNSEC_BRUTE)
65145 + return __gr_process_user_ban(current->cred->user);
65146 +#endif
65147 + return 0;
65148 +}
65149 diff --git a/grsecurity/grsec_sock.c b/grsecurity/grsec_sock.c
65150 new file mode 100644
65151 index 0000000..4030d57
65152 --- /dev/null
65153 +++ b/grsecurity/grsec_sock.c
65154 @@ -0,0 +1,244 @@
65155 +#include <linux/kernel.h>
65156 +#include <linux/module.h>
65157 +#include <linux/sched.h>
65158 +#include <linux/file.h>
65159 +#include <linux/net.h>
65160 +#include <linux/in.h>
65161 +#include <linux/ip.h>
65162 +#include <net/sock.h>
65163 +#include <net/inet_sock.h>
65164 +#include <linux/grsecurity.h>
65165 +#include <linux/grinternal.h>
65166 +#include <linux/gracl.h>
65167 +
65168 +extern int gr_search_udp_recvmsg(const struct sock *sk, const struct sk_buff *skb);
65169 +extern int gr_search_udp_sendmsg(const struct sock *sk, const struct sockaddr_in *addr);
65170 +
65171 +EXPORT_SYMBOL(gr_search_udp_recvmsg);
65172 +EXPORT_SYMBOL(gr_search_udp_sendmsg);
65173 +
65174 +#ifdef CONFIG_UNIX_MODULE
65175 +EXPORT_SYMBOL(gr_acl_handle_unix);
65176 +EXPORT_SYMBOL(gr_acl_handle_mknod);
65177 +EXPORT_SYMBOL(gr_handle_chroot_unix);
65178 +EXPORT_SYMBOL(gr_handle_create);
65179 +#endif
65180 +
65181 +#ifdef CONFIG_GRKERNSEC
65182 +#define gr_conn_table_size 32749
65183 +struct conn_table_entry {
65184 + struct conn_table_entry *next;
65185 + struct signal_struct *sig;
65186 +};
65187 +
65188 +struct conn_table_entry *gr_conn_table[gr_conn_table_size];
65189 +DEFINE_SPINLOCK(gr_conn_table_lock);
65190 +
65191 +extern const char * gr_socktype_to_name(unsigned char type);
65192 +extern const char * gr_proto_to_name(unsigned char proto);
65193 +extern const char * gr_sockfamily_to_name(unsigned char family);
65194 +
65195 +static __inline__ int
65196 +conn_hash(__u32 saddr, __u32 daddr, __u16 sport, __u16 dport, unsigned int size)
65197 +{
65198 + return ((daddr + saddr + (sport << 8) + (dport << 16)) % size);
65199 +}
65200 +
65201 +static __inline__ int
65202 +conn_match(const struct signal_struct *sig, __u32 saddr, __u32 daddr,
65203 + __u16 sport, __u16 dport)
65204 +{
65205 + if (unlikely(sig->gr_saddr == saddr && sig->gr_daddr == daddr &&
65206 + sig->gr_sport == sport && sig->gr_dport == dport))
65207 + return 1;
65208 + else
65209 + return 0;
65210 +}
65211 +
65212 +static void gr_add_to_task_ip_table_nolock(struct signal_struct *sig, struct conn_table_entry *newent)
65213 +{
65214 + struct conn_table_entry **match;
65215 + unsigned int index;
65216 +
65217 + index = conn_hash(sig->gr_saddr, sig->gr_daddr,
65218 + sig->gr_sport, sig->gr_dport,
65219 + gr_conn_table_size);
65220 +
65221 + newent->sig = sig;
65222 +
65223 + match = &gr_conn_table[index];
65224 + newent->next = *match;
65225 + *match = newent;
65226 +
65227 + return;
65228 +}
65229 +
65230 +static void gr_del_task_from_ip_table_nolock(struct signal_struct *sig)
65231 +{
65232 + struct conn_table_entry *match, *last = NULL;
65233 + unsigned int index;
65234 +
65235 + index = conn_hash(sig->gr_saddr, sig->gr_daddr,
65236 + sig->gr_sport, sig->gr_dport,
65237 + gr_conn_table_size);
65238 +
65239 + match = gr_conn_table[index];
65240 + while (match && !conn_match(match->sig,
65241 + sig->gr_saddr, sig->gr_daddr, sig->gr_sport,
65242 + sig->gr_dport)) {
65243 + last = match;
65244 + match = match->next;
65245 + }
65246 +
65247 + if (match) {
65248 + if (last)
65249 + last->next = match->next;
65250 + else
65251 + gr_conn_table[index] = NULL;
65252 + kfree(match);
65253 + }
65254 +
65255 + return;
65256 +}
65257 +
65258 +static struct signal_struct * gr_lookup_task_ip_table(__u32 saddr, __u32 daddr,
65259 + __u16 sport, __u16 dport)
65260 +{
65261 + struct conn_table_entry *match;
65262 + unsigned int index;
65263 +
65264 + index = conn_hash(saddr, daddr, sport, dport, gr_conn_table_size);
65265 +
65266 + match = gr_conn_table[index];
65267 + while (match && !conn_match(match->sig, saddr, daddr, sport, dport))
65268 + match = match->next;
65269 +
65270 + if (match)
65271 + return match->sig;
65272 + else
65273 + return NULL;
65274 +}
65275 +
65276 +#endif
65277 +
65278 +void gr_update_task_in_ip_table(struct task_struct *task, const struct inet_sock *inet)
65279 +{
65280 +#ifdef CONFIG_GRKERNSEC
65281 + struct signal_struct *sig = task->signal;
65282 + struct conn_table_entry *newent;
65283 +
65284 + newent = kmalloc(sizeof(struct conn_table_entry), GFP_ATOMIC);
65285 + if (newent == NULL)
65286 + return;
65287 + /* no bh lock needed since we are called with bh disabled */
65288 + spin_lock(&gr_conn_table_lock);
65289 + gr_del_task_from_ip_table_nolock(sig);
65290 + sig->gr_saddr = inet->inet_rcv_saddr;
65291 + sig->gr_daddr = inet->inet_daddr;
65292 + sig->gr_sport = inet->inet_sport;
65293 + sig->gr_dport = inet->inet_dport;
65294 + gr_add_to_task_ip_table_nolock(sig, newent);
65295 + spin_unlock(&gr_conn_table_lock);
65296 +#endif
65297 + return;
65298 +}
65299 +
65300 +void gr_del_task_from_ip_table(struct task_struct *task)
65301 +{
65302 +#ifdef CONFIG_GRKERNSEC
65303 + spin_lock_bh(&gr_conn_table_lock);
65304 + gr_del_task_from_ip_table_nolock(task->signal);
65305 + spin_unlock_bh(&gr_conn_table_lock);
65306 +#endif
65307 + return;
65308 +}
65309 +
65310 +void
65311 +gr_attach_curr_ip(const struct sock *sk)
65312 +{
65313 +#ifdef CONFIG_GRKERNSEC
65314 + struct signal_struct *p, *set;
65315 + const struct inet_sock *inet = inet_sk(sk);
65316 +
65317 + if (unlikely(sk->sk_protocol != IPPROTO_TCP))
65318 + return;
65319 +
65320 + set = current->signal;
65321 +
65322 + spin_lock_bh(&gr_conn_table_lock);
65323 + p = gr_lookup_task_ip_table(inet->inet_daddr, inet->inet_rcv_saddr,
65324 + inet->inet_dport, inet->inet_sport);
65325 + if (unlikely(p != NULL)) {
65326 + set->curr_ip = p->curr_ip;
65327 + set->used_accept = 1;
65328 + gr_del_task_from_ip_table_nolock(p);
65329 + spin_unlock_bh(&gr_conn_table_lock);
65330 + return;
65331 + }
65332 + spin_unlock_bh(&gr_conn_table_lock);
65333 +
65334 + set->curr_ip = inet->inet_daddr;
65335 + set->used_accept = 1;
65336 +#endif
65337 + return;
65338 +}
65339 +
65340 +int
65341 +gr_handle_sock_all(const int family, const int type, const int protocol)
65342 +{
65343 +#ifdef CONFIG_GRKERNSEC_SOCKET_ALL
65344 + if (grsec_enable_socket_all && in_group_p(grsec_socket_all_gid) &&
65345 + (family != AF_UNIX)) {
65346 + if (family == AF_INET)
65347 + gr_log_str3(GR_DONT_AUDIT, GR_SOCK_MSG, gr_sockfamily_to_name(family), gr_socktype_to_name(type), gr_proto_to_name(protocol));
65348 + else
65349 + gr_log_str2_int(GR_DONT_AUDIT, GR_SOCK_NOINET_MSG, gr_sockfamily_to_name(family), gr_socktype_to_name(type), protocol);
65350 + return -EACCES;
65351 + }
65352 +#endif
65353 + return 0;
65354 +}
65355 +
65356 +int
65357 +gr_handle_sock_server(const struct sockaddr *sck)
65358 +{
65359 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
65360 + if (grsec_enable_socket_server &&
65361 + in_group_p(grsec_socket_server_gid) &&
65362 + sck && (sck->sa_family != AF_UNIX) &&
65363 + (sck->sa_family != AF_LOCAL)) {
65364 + gr_log_noargs(GR_DONT_AUDIT, GR_BIND_MSG);
65365 + return -EACCES;
65366 + }
65367 +#endif
65368 + return 0;
65369 +}
65370 +
65371 +int
65372 +gr_handle_sock_server_other(const struct sock *sck)
65373 +{
65374 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
65375 + if (grsec_enable_socket_server &&
65376 + in_group_p(grsec_socket_server_gid) &&
65377 + sck && (sck->sk_family != AF_UNIX) &&
65378 + (sck->sk_family != AF_LOCAL)) {
65379 + gr_log_noargs(GR_DONT_AUDIT, GR_BIND_MSG);
65380 + return -EACCES;
65381 + }
65382 +#endif
65383 + return 0;
65384 +}
65385 +
65386 +int
65387 +gr_handle_sock_client(const struct sockaddr *sck)
65388 +{
65389 +#ifdef CONFIG_GRKERNSEC_SOCKET_CLIENT
65390 + if (grsec_enable_socket_client && in_group_p(grsec_socket_client_gid) &&
65391 + sck && (sck->sa_family != AF_UNIX) &&
65392 + (sck->sa_family != AF_LOCAL)) {
65393 + gr_log_noargs(GR_DONT_AUDIT, GR_CONNECT_MSG);
65394 + return -EACCES;
65395 + }
65396 +#endif
65397 + return 0;
65398 +}
65399 diff --git a/grsecurity/grsec_sysctl.c b/grsecurity/grsec_sysctl.c
65400 new file mode 100644
65401 index 0000000..f55ef0f
65402 --- /dev/null
65403 +++ b/grsecurity/grsec_sysctl.c
65404 @@ -0,0 +1,469 @@
65405 +#include <linux/kernel.h>
65406 +#include <linux/sched.h>
65407 +#include <linux/sysctl.h>
65408 +#include <linux/grsecurity.h>
65409 +#include <linux/grinternal.h>
65410 +
65411 +int
65412 +gr_handle_sysctl_mod(const char *dirname, const char *name, const int op)
65413 +{
65414 +#ifdef CONFIG_GRKERNSEC_SYSCTL
65415 + if (dirname == NULL || name == NULL)
65416 + return 0;
65417 + if (!strcmp(dirname, "grsecurity") && grsec_lock && (op & MAY_WRITE)) {
65418 + gr_log_str(GR_DONT_AUDIT, GR_SYSCTL_MSG, name);
65419 + return -EACCES;
65420 + }
65421 +#endif
65422 + return 0;
65423 +}
65424 +
65425 +#ifdef CONFIG_GRKERNSEC_ROFS
65426 +static int __maybe_unused one = 1;
65427 +#endif
65428 +
65429 +#if defined(CONFIG_GRKERNSEC_SYSCTL) || defined(CONFIG_GRKERNSEC_ROFS)
65430 +struct ctl_table grsecurity_table[] = {
65431 +#ifdef CONFIG_GRKERNSEC_SYSCTL
65432 +#ifdef CONFIG_GRKERNSEC_SYSCTL_DISTRO
65433 +#ifdef CONFIG_GRKERNSEC_IO
65434 + {
65435 + .procname = "disable_priv_io",
65436 + .data = &grsec_disable_privio,
65437 + .maxlen = sizeof(int),
65438 + .mode = 0600,
65439 + .proc_handler = &proc_dointvec,
65440 + },
65441 +#endif
65442 +#endif
65443 +#ifdef CONFIG_GRKERNSEC_LINK
65444 + {
65445 + .procname = "linking_restrictions",
65446 + .data = &grsec_enable_link,
65447 + .maxlen = sizeof(int),
65448 + .mode = 0600,
65449 + .proc_handler = &proc_dointvec,
65450 + },
65451 +#endif
65452 +#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
65453 + {
65454 + .procname = "enforce_symlinksifowner",
65455 + .data = &grsec_enable_symlinkown,
65456 + .maxlen = sizeof(int),
65457 + .mode = 0600,
65458 + .proc_handler = &proc_dointvec,
65459 + },
65460 + {
65461 + .procname = "symlinkown_gid",
65462 + .data = &grsec_symlinkown_gid,
65463 + .maxlen = sizeof(int),
65464 + .mode = 0600,
65465 + .proc_handler = &proc_dointvec,
65466 + },
65467 +#endif
65468 +#ifdef CONFIG_GRKERNSEC_BRUTE
65469 + {
65470 + .procname = "deter_bruteforce",
65471 + .data = &grsec_enable_brute,
65472 + .maxlen = sizeof(int),
65473 + .mode = 0600,
65474 + .proc_handler = &proc_dointvec,
65475 + },
65476 +#endif
65477 +#ifdef CONFIG_GRKERNSEC_FIFO
65478 + {
65479 + .procname = "fifo_restrictions",
65480 + .data = &grsec_enable_fifo,
65481 + .maxlen = sizeof(int),
65482 + .mode = 0600,
65483 + .proc_handler = &proc_dointvec,
65484 + },
65485 +#endif
65486 +#ifdef CONFIG_GRKERNSEC_PTRACE_READEXEC
65487 + {
65488 + .procname = "ptrace_readexec",
65489 + .data = &grsec_enable_ptrace_readexec,
65490 + .maxlen = sizeof(int),
65491 + .mode = 0600,
65492 + .proc_handler = &proc_dointvec,
65493 + },
65494 +#endif
65495 +#ifdef CONFIG_GRKERNSEC_SETXID
65496 + {
65497 + .procname = "consistent_setxid",
65498 + .data = &grsec_enable_setxid,
65499 + .maxlen = sizeof(int),
65500 + .mode = 0600,
65501 + .proc_handler = &proc_dointvec,
65502 + },
65503 +#endif
65504 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
65505 + {
65506 + .procname = "ip_blackhole",
65507 + .data = &grsec_enable_blackhole,
65508 + .maxlen = sizeof(int),
65509 + .mode = 0600,
65510 + .proc_handler = &proc_dointvec,
65511 + },
65512 + {
65513 + .procname = "lastack_retries",
65514 + .data = &grsec_lastack_retries,
65515 + .maxlen = sizeof(int),
65516 + .mode = 0600,
65517 + .proc_handler = &proc_dointvec,
65518 + },
65519 +#endif
65520 +#ifdef CONFIG_GRKERNSEC_EXECLOG
65521 + {
65522 + .procname = "exec_logging",
65523 + .data = &grsec_enable_execlog,
65524 + .maxlen = sizeof(int),
65525 + .mode = 0600,
65526 + .proc_handler = &proc_dointvec,
65527 + },
65528 +#endif
65529 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
65530 + {
65531 + .procname = "rwxmap_logging",
65532 + .data = &grsec_enable_log_rwxmaps,
65533 + .maxlen = sizeof(int),
65534 + .mode = 0600,
65535 + .proc_handler = &proc_dointvec,
65536 + },
65537 +#endif
65538 +#ifdef CONFIG_GRKERNSEC_SIGNAL
65539 + {
65540 + .procname = "signal_logging",
65541 + .data = &grsec_enable_signal,
65542 + .maxlen = sizeof(int),
65543 + .mode = 0600,
65544 + .proc_handler = &proc_dointvec,
65545 + },
65546 +#endif
65547 +#ifdef CONFIG_GRKERNSEC_FORKFAIL
65548 + {
65549 + .procname = "forkfail_logging",
65550 + .data = &grsec_enable_forkfail,
65551 + .maxlen = sizeof(int),
65552 + .mode = 0600,
65553 + .proc_handler = &proc_dointvec,
65554 + },
65555 +#endif
65556 +#ifdef CONFIG_GRKERNSEC_TIME
65557 + {
65558 + .procname = "timechange_logging",
65559 + .data = &grsec_enable_time,
65560 + .maxlen = sizeof(int),
65561 + .mode = 0600,
65562 + .proc_handler = &proc_dointvec,
65563 + },
65564 +#endif
65565 +#ifdef CONFIG_GRKERNSEC_CHROOT_SHMAT
65566 + {
65567 + .procname = "chroot_deny_shmat",
65568 + .data = &grsec_enable_chroot_shmat,
65569 + .maxlen = sizeof(int),
65570 + .mode = 0600,
65571 + .proc_handler = &proc_dointvec,
65572 + },
65573 +#endif
65574 +#ifdef CONFIG_GRKERNSEC_CHROOT_UNIX
65575 + {
65576 + .procname = "chroot_deny_unix",
65577 + .data = &grsec_enable_chroot_unix,
65578 + .maxlen = sizeof(int),
65579 + .mode = 0600,
65580 + .proc_handler = &proc_dointvec,
65581 + },
65582 +#endif
65583 +#ifdef CONFIG_GRKERNSEC_CHROOT_MOUNT
65584 + {
65585 + .procname = "chroot_deny_mount",
65586 + .data = &grsec_enable_chroot_mount,
65587 + .maxlen = sizeof(int),
65588 + .mode = 0600,
65589 + .proc_handler = &proc_dointvec,
65590 + },
65591 +#endif
65592 +#ifdef CONFIG_GRKERNSEC_CHROOT_FCHDIR
65593 + {
65594 + .procname = "chroot_deny_fchdir",
65595 + .data = &grsec_enable_chroot_fchdir,
65596 + .maxlen = sizeof(int),
65597 + .mode = 0600,
65598 + .proc_handler = &proc_dointvec,
65599 + },
65600 +#endif
65601 +#ifdef CONFIG_GRKERNSEC_CHROOT_DOUBLE
65602 + {
65603 + .procname = "chroot_deny_chroot",
65604 + .data = &grsec_enable_chroot_double,
65605 + .maxlen = sizeof(int),
65606 + .mode = 0600,
65607 + .proc_handler = &proc_dointvec,
65608 + },
65609 +#endif
65610 +#ifdef CONFIG_GRKERNSEC_CHROOT_PIVOT
65611 + {
65612 + .procname = "chroot_deny_pivot",
65613 + .data = &grsec_enable_chroot_pivot,
65614 + .maxlen = sizeof(int),
65615 + .mode = 0600,
65616 + .proc_handler = &proc_dointvec,
65617 + },
65618 +#endif
65619 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHDIR
65620 + {
65621 + .procname = "chroot_enforce_chdir",
65622 + .data = &grsec_enable_chroot_chdir,
65623 + .maxlen = sizeof(int),
65624 + .mode = 0600,
65625 + .proc_handler = &proc_dointvec,
65626 + },
65627 +#endif
65628 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHMOD
65629 + {
65630 + .procname = "chroot_deny_chmod",
65631 + .data = &grsec_enable_chroot_chmod,
65632 + .maxlen = sizeof(int),
65633 + .mode = 0600,
65634 + .proc_handler = &proc_dointvec,
65635 + },
65636 +#endif
65637 +#ifdef CONFIG_GRKERNSEC_CHROOT_MKNOD
65638 + {
65639 + .procname = "chroot_deny_mknod",
65640 + .data = &grsec_enable_chroot_mknod,
65641 + .maxlen = sizeof(int),
65642 + .mode = 0600,
65643 + .proc_handler = &proc_dointvec,
65644 + },
65645 +#endif
65646 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
65647 + {
65648 + .procname = "chroot_restrict_nice",
65649 + .data = &grsec_enable_chroot_nice,
65650 + .maxlen = sizeof(int),
65651 + .mode = 0600,
65652 + .proc_handler = &proc_dointvec,
65653 + },
65654 +#endif
65655 +#ifdef CONFIG_GRKERNSEC_CHROOT_EXECLOG
65656 + {
65657 + .procname = "chroot_execlog",
65658 + .data = &grsec_enable_chroot_execlog,
65659 + .maxlen = sizeof(int),
65660 + .mode = 0600,
65661 + .proc_handler = &proc_dointvec,
65662 + },
65663 +#endif
65664 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
65665 + {
65666 + .procname = "chroot_caps",
65667 + .data = &grsec_enable_chroot_caps,
65668 + .maxlen = sizeof(int),
65669 + .mode = 0600,
65670 + .proc_handler = &proc_dointvec,
65671 + },
65672 +#endif
65673 +#ifdef CONFIG_GRKERNSEC_CHROOT_SYSCTL
65674 + {
65675 + .procname = "chroot_deny_sysctl",
65676 + .data = &grsec_enable_chroot_sysctl,
65677 + .maxlen = sizeof(int),
65678 + .mode = 0600,
65679 + .proc_handler = &proc_dointvec,
65680 + },
65681 +#endif
65682 +#ifdef CONFIG_GRKERNSEC_TPE
65683 + {
65684 + .procname = "tpe",
65685 + .data = &grsec_enable_tpe,
65686 + .maxlen = sizeof(int),
65687 + .mode = 0600,
65688 + .proc_handler = &proc_dointvec,
65689 + },
65690 + {
65691 + .procname = "tpe_gid",
65692 + .data = &grsec_tpe_gid,
65693 + .maxlen = sizeof(int),
65694 + .mode = 0600,
65695 + .proc_handler = &proc_dointvec,
65696 + },
65697 +#endif
65698 +#ifdef CONFIG_GRKERNSEC_TPE_INVERT
65699 + {
65700 + .procname = "tpe_invert",
65701 + .data = &grsec_enable_tpe_invert,
65702 + .maxlen = sizeof(int),
65703 + .mode = 0600,
65704 + .proc_handler = &proc_dointvec,
65705 + },
65706 +#endif
65707 +#ifdef CONFIG_GRKERNSEC_TPE_ALL
65708 + {
65709 + .procname = "tpe_restrict_all",
65710 + .data = &grsec_enable_tpe_all,
65711 + .maxlen = sizeof(int),
65712 + .mode = 0600,
65713 + .proc_handler = &proc_dointvec,
65714 + },
65715 +#endif
65716 +#ifdef CONFIG_GRKERNSEC_SOCKET_ALL
65717 + {
65718 + .procname = "socket_all",
65719 + .data = &grsec_enable_socket_all,
65720 + .maxlen = sizeof(int),
65721 + .mode = 0600,
65722 + .proc_handler = &proc_dointvec,
65723 + },
65724 + {
65725 + .procname = "socket_all_gid",
65726 + .data = &grsec_socket_all_gid,
65727 + .maxlen = sizeof(int),
65728 + .mode = 0600,
65729 + .proc_handler = &proc_dointvec,
65730 + },
65731 +#endif
65732 +#ifdef CONFIG_GRKERNSEC_SOCKET_CLIENT
65733 + {
65734 + .procname = "socket_client",
65735 + .data = &grsec_enable_socket_client,
65736 + .maxlen = sizeof(int),
65737 + .mode = 0600,
65738 + .proc_handler = &proc_dointvec,
65739 + },
65740 + {
65741 + .procname = "socket_client_gid",
65742 + .data = &grsec_socket_client_gid,
65743 + .maxlen = sizeof(int),
65744 + .mode = 0600,
65745 + .proc_handler = &proc_dointvec,
65746 + },
65747 +#endif
65748 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
65749 + {
65750 + .procname = "socket_server",
65751 + .data = &grsec_enable_socket_server,
65752 + .maxlen = sizeof(int),
65753 + .mode = 0600,
65754 + .proc_handler = &proc_dointvec,
65755 + },
65756 + {
65757 + .procname = "socket_server_gid",
65758 + .data = &grsec_socket_server_gid,
65759 + .maxlen = sizeof(int),
65760 + .mode = 0600,
65761 + .proc_handler = &proc_dointvec,
65762 + },
65763 +#endif
65764 +#ifdef CONFIG_GRKERNSEC_AUDIT_GROUP
65765 + {
65766 + .procname = "audit_group",
65767 + .data = &grsec_enable_group,
65768 + .maxlen = sizeof(int),
65769 + .mode = 0600,
65770 + .proc_handler = &proc_dointvec,
65771 + },
65772 + {
65773 + .procname = "audit_gid",
65774 + .data = &grsec_audit_gid,
65775 + .maxlen = sizeof(int),
65776 + .mode = 0600,
65777 + .proc_handler = &proc_dointvec,
65778 + },
65779 +#endif
65780 +#ifdef CONFIG_GRKERNSEC_AUDIT_CHDIR
65781 + {
65782 + .procname = "audit_chdir",
65783 + .data = &grsec_enable_chdir,
65784 + .maxlen = sizeof(int),
65785 + .mode = 0600,
65786 + .proc_handler = &proc_dointvec,
65787 + },
65788 +#endif
65789 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
65790 + {
65791 + .procname = "audit_mount",
65792 + .data = &grsec_enable_mount,
65793 + .maxlen = sizeof(int),
65794 + .mode = 0600,
65795 + .proc_handler = &proc_dointvec,
65796 + },
65797 +#endif
65798 +#ifdef CONFIG_GRKERNSEC_AUDIT_TEXTREL
65799 + {
65800 + .procname = "audit_textrel",
65801 + .data = &grsec_enable_audit_textrel,
65802 + .maxlen = sizeof(int),
65803 + .mode = 0600,
65804 + .proc_handler = &proc_dointvec,
65805 + },
65806 +#endif
65807 +#ifdef CONFIG_GRKERNSEC_DMESG
65808 + {
65809 + .procname = "dmesg",
65810 + .data = &grsec_enable_dmesg,
65811 + .maxlen = sizeof(int),
65812 + .mode = 0600,
65813 + .proc_handler = &proc_dointvec,
65814 + },
65815 +#endif
65816 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
65817 + {
65818 + .procname = "chroot_findtask",
65819 + .data = &grsec_enable_chroot_findtask,
65820 + .maxlen = sizeof(int),
65821 + .mode = 0600,
65822 + .proc_handler = &proc_dointvec,
65823 + },
65824 +#endif
65825 +#ifdef CONFIG_GRKERNSEC_RESLOG
65826 + {
65827 + .procname = "resource_logging",
65828 + .data = &grsec_resource_logging,
65829 + .maxlen = sizeof(int),
65830 + .mode = 0600,
65831 + .proc_handler = &proc_dointvec,
65832 + },
65833 +#endif
65834 +#ifdef CONFIG_GRKERNSEC_AUDIT_PTRACE
65835 + {
65836 + .procname = "audit_ptrace",
65837 + .data = &grsec_enable_audit_ptrace,
65838 + .maxlen = sizeof(int),
65839 + .mode = 0600,
65840 + .proc_handler = &proc_dointvec,
65841 + },
65842 +#endif
65843 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
65844 + {
65845 + .procname = "harden_ptrace",
65846 + .data = &grsec_enable_harden_ptrace,
65847 + .maxlen = sizeof(int),
65848 + .mode = 0600,
65849 + .proc_handler = &proc_dointvec,
65850 + },
65851 +#endif
65852 + {
65853 + .procname = "grsec_lock",
65854 + .data = &grsec_lock,
65855 + .maxlen = sizeof(int),
65856 + .mode = 0600,
65857 + .proc_handler = &proc_dointvec,
65858 + },
65859 +#endif
65860 +#ifdef CONFIG_GRKERNSEC_ROFS
65861 + {
65862 + .procname = "romount_protect",
65863 + .data = &grsec_enable_rofs,
65864 + .maxlen = sizeof(int),
65865 + .mode = 0600,
65866 + .proc_handler = &proc_dointvec_minmax,
65867 + .extra1 = &one,
65868 + .extra2 = &one,
65869 + },
65870 +#endif
65871 + { }
65872 +};
65873 +#endif
65874 diff --git a/grsecurity/grsec_time.c b/grsecurity/grsec_time.c
65875 new file mode 100644
65876 index 0000000..0dc13c3
65877 --- /dev/null
65878 +++ b/grsecurity/grsec_time.c
65879 @@ -0,0 +1,16 @@
65880 +#include <linux/kernel.h>
65881 +#include <linux/sched.h>
65882 +#include <linux/grinternal.h>
65883 +#include <linux/module.h>
65884 +
65885 +void
65886 +gr_log_timechange(void)
65887 +{
65888 +#ifdef CONFIG_GRKERNSEC_TIME
65889 + if (grsec_enable_time)
65890 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_TIME_MSG);
65891 +#endif
65892 + return;
65893 +}
65894 +
65895 +EXPORT_SYMBOL(gr_log_timechange);
65896 diff --git a/grsecurity/grsec_tpe.c b/grsecurity/grsec_tpe.c
65897 new file mode 100644
65898 index 0000000..ee57dcf
65899 --- /dev/null
65900 +++ b/grsecurity/grsec_tpe.c
65901 @@ -0,0 +1,73 @@
65902 +#include <linux/kernel.h>
65903 +#include <linux/sched.h>
65904 +#include <linux/file.h>
65905 +#include <linux/fs.h>
65906 +#include <linux/grinternal.h>
65907 +
65908 +extern int gr_acl_tpe_check(void);
65909 +
65910 +int
65911 +gr_tpe_allow(const struct file *file)
65912 +{
65913 +#ifdef CONFIG_GRKERNSEC
65914 + struct inode *inode = file->f_path.dentry->d_parent->d_inode;
65915 + const struct cred *cred = current_cred();
65916 + char *msg = NULL;
65917 + char *msg2 = NULL;
65918 +
65919 + // never restrict root
65920 + if (gr_is_global_root(cred->uid))
65921 + return 1;
65922 +
65923 + if (grsec_enable_tpe) {
65924 +#ifdef CONFIG_GRKERNSEC_TPE_INVERT
65925 + if (grsec_enable_tpe_invert && !in_group_p(grsec_tpe_gid))
65926 + msg = "not being in trusted group";
65927 + else if (!grsec_enable_tpe_invert && in_group_p(grsec_tpe_gid))
65928 + msg = "being in untrusted group";
65929 +#else
65930 + if (in_group_p(grsec_tpe_gid))
65931 + msg = "being in untrusted group";
65932 +#endif
65933 + }
65934 + if (!msg && gr_acl_tpe_check())
65935 + msg = "being in untrusted role";
65936 +
65937 + // not in any affected group/role
65938 + if (!msg)
65939 + goto next_check;
65940 +
65941 + if (gr_is_global_nonroot(inode->i_uid))
65942 + msg2 = "file in non-root-owned directory";
65943 + else if (inode->i_mode & S_IWOTH)
65944 + msg2 = "file in world-writable directory";
65945 + else if (inode->i_mode & S_IWGRP)
65946 + msg2 = "file in group-writable directory";
65947 +
65948 + if (msg && msg2) {
65949 + char fullmsg[70] = {0};
65950 + snprintf(fullmsg, sizeof(fullmsg)-1, "%s and %s", msg, msg2);
65951 + gr_log_str_fs(GR_DONT_AUDIT, GR_EXEC_TPE_MSG, fullmsg, file->f_path.dentry, file->f_path.mnt);
65952 + return 0;
65953 + }
65954 + msg = NULL;
65955 +next_check:
65956 +#ifdef CONFIG_GRKERNSEC_TPE_ALL
65957 + if (!grsec_enable_tpe || !grsec_enable_tpe_all)
65958 + return 1;
65959 +
65960 + if (gr_is_global_nonroot(inode->i_uid) && !uid_eq(inode->i_uid, cred->uid))
65961 + msg = "directory not owned by user";
65962 + else if (inode->i_mode & S_IWOTH)
65963 + msg = "file in world-writable directory";
65964 + else if (inode->i_mode & S_IWGRP)
65965 + msg = "file in group-writable directory";
65966 +
65967 + if (msg) {
65968 + gr_log_str_fs(GR_DONT_AUDIT, GR_EXEC_TPE_MSG, msg, file->f_path.dentry, file->f_path.mnt);
65969 + return 0;
65970 + }
65971 +#endif
65972 +#endif
65973 + return 1;
65974 +}
65975 diff --git a/grsecurity/grsum.c b/grsecurity/grsum.c
65976 new file mode 100644
65977 index 0000000..9f7b1ac
65978 --- /dev/null
65979 +++ b/grsecurity/grsum.c
65980 @@ -0,0 +1,61 @@
65981 +#include <linux/err.h>
65982 +#include <linux/kernel.h>
65983 +#include <linux/sched.h>
65984 +#include <linux/mm.h>
65985 +#include <linux/scatterlist.h>
65986 +#include <linux/crypto.h>
65987 +#include <linux/gracl.h>
65988 +
65989 +
65990 +#if !defined(CONFIG_CRYPTO) || defined(CONFIG_CRYPTO_MODULE) || !defined(CONFIG_CRYPTO_SHA256) || defined(CONFIG_CRYPTO_SHA256_MODULE)
65991 +#error "crypto and sha256 must be built into the kernel"
65992 +#endif
65993 +
65994 +int
65995 +chkpw(struct gr_arg *entry, unsigned char *salt, unsigned char *sum)
65996 +{
65997 + char *p;
65998 + struct crypto_hash *tfm;
65999 + struct hash_desc desc;
66000 + struct scatterlist sg;
66001 + unsigned char temp_sum[GR_SHA_LEN];
66002 + volatile int retval = 0;
66003 + volatile int dummy = 0;
66004 + unsigned int i;
66005 +
66006 + sg_init_table(&sg, 1);
66007 +
66008 + tfm = crypto_alloc_hash("sha256", 0, CRYPTO_ALG_ASYNC);
66009 + if (IS_ERR(tfm)) {
66010 + /* should never happen, since sha256 should be built in */
66011 + return 1;
66012 + }
66013 +
66014 + desc.tfm = tfm;
66015 + desc.flags = 0;
66016 +
66017 + crypto_hash_init(&desc);
66018 +
66019 + p = salt;
66020 + sg_set_buf(&sg, p, GR_SALT_LEN);
66021 + crypto_hash_update(&desc, &sg, sg.length);
66022 +
66023 + p = entry->pw;
66024 + sg_set_buf(&sg, p, strlen(p));
66025 +
66026 + crypto_hash_update(&desc, &sg, sg.length);
66027 +
66028 + crypto_hash_final(&desc, temp_sum);
66029 +
66030 + memset(entry->pw, 0, GR_PW_LEN);
66031 +
66032 + for (i = 0; i < GR_SHA_LEN; i++)
66033 + if (sum[i] != temp_sum[i])
66034 + retval = 1;
66035 + else
66036 + dummy = 1; // waste a cycle
66037 +
66038 + crypto_free_hash(tfm);
66039 +
66040 + return retval;
66041 +}
66042 diff --git a/include/asm-generic/4level-fixup.h b/include/asm-generic/4level-fixup.h
66043 index 77ff547..181834f 100644
66044 --- a/include/asm-generic/4level-fixup.h
66045 +++ b/include/asm-generic/4level-fixup.h
66046 @@ -13,8 +13,10 @@
66047 #define pmd_alloc(mm, pud, address) \
66048 ((unlikely(pgd_none(*(pud))) && __pmd_alloc(mm, pud, address))? \
66049 NULL: pmd_offset(pud, address))
66050 +#define pmd_alloc_kernel(mm, pud, address) pmd_alloc((mm), (pud), (address))
66051
66052 #define pud_alloc(mm, pgd, address) (pgd)
66053 +#define pud_alloc_kernel(mm, pgd, address) pud_alloc((mm), (pgd), (address))
66054 #define pud_offset(pgd, start) (pgd)
66055 #define pud_none(pud) 0
66056 #define pud_bad(pud) 0
66057 diff --git a/include/asm-generic/atomic-long.h b/include/asm-generic/atomic-long.h
66058 index b7babf0..04ad282 100644
66059 --- a/include/asm-generic/atomic-long.h
66060 +++ b/include/asm-generic/atomic-long.h
66061 @@ -22,6 +22,12 @@
66062
66063 typedef atomic64_t atomic_long_t;
66064
66065 +#ifdef CONFIG_PAX_REFCOUNT
66066 +typedef atomic64_unchecked_t atomic_long_unchecked_t;
66067 +#else
66068 +typedef atomic64_t atomic_long_unchecked_t;
66069 +#endif
66070 +
66071 #define ATOMIC_LONG_INIT(i) ATOMIC64_INIT(i)
66072
66073 static inline long atomic_long_read(atomic_long_t *l)
66074 @@ -31,6 +37,15 @@ static inline long atomic_long_read(atomic_long_t *l)
66075 return (long)atomic64_read(v);
66076 }
66077
66078 +#ifdef CONFIG_PAX_REFCOUNT
66079 +static inline long atomic_long_read_unchecked(atomic_long_unchecked_t *l)
66080 +{
66081 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
66082 +
66083 + return (long)atomic64_read_unchecked(v);
66084 +}
66085 +#endif
66086 +
66087 static inline void atomic_long_set(atomic_long_t *l, long i)
66088 {
66089 atomic64_t *v = (atomic64_t *)l;
66090 @@ -38,6 +53,15 @@ static inline void atomic_long_set(atomic_long_t *l, long i)
66091 atomic64_set(v, i);
66092 }
66093
66094 +#ifdef CONFIG_PAX_REFCOUNT
66095 +static inline void atomic_long_set_unchecked(atomic_long_unchecked_t *l, long i)
66096 +{
66097 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
66098 +
66099 + atomic64_set_unchecked(v, i);
66100 +}
66101 +#endif
66102 +
66103 static inline void atomic_long_inc(atomic_long_t *l)
66104 {
66105 atomic64_t *v = (atomic64_t *)l;
66106 @@ -45,6 +69,15 @@ static inline void atomic_long_inc(atomic_long_t *l)
66107 atomic64_inc(v);
66108 }
66109
66110 +#ifdef CONFIG_PAX_REFCOUNT
66111 +static inline void atomic_long_inc_unchecked(atomic_long_unchecked_t *l)
66112 +{
66113 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
66114 +
66115 + atomic64_inc_unchecked(v);
66116 +}
66117 +#endif
66118 +
66119 static inline void atomic_long_dec(atomic_long_t *l)
66120 {
66121 atomic64_t *v = (atomic64_t *)l;
66122 @@ -52,6 +85,15 @@ static inline void atomic_long_dec(atomic_long_t *l)
66123 atomic64_dec(v);
66124 }
66125
66126 +#ifdef CONFIG_PAX_REFCOUNT
66127 +static inline void atomic_long_dec_unchecked(atomic_long_unchecked_t *l)
66128 +{
66129 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
66130 +
66131 + atomic64_dec_unchecked(v);
66132 +}
66133 +#endif
66134 +
66135 static inline void atomic_long_add(long i, atomic_long_t *l)
66136 {
66137 atomic64_t *v = (atomic64_t *)l;
66138 @@ -59,6 +101,15 @@ static inline void atomic_long_add(long i, atomic_long_t *l)
66139 atomic64_add(i, v);
66140 }
66141
66142 +#ifdef CONFIG_PAX_REFCOUNT
66143 +static inline void atomic_long_add_unchecked(long i, atomic_long_unchecked_t *l)
66144 +{
66145 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
66146 +
66147 + atomic64_add_unchecked(i, v);
66148 +}
66149 +#endif
66150 +
66151 static inline void atomic_long_sub(long i, atomic_long_t *l)
66152 {
66153 atomic64_t *v = (atomic64_t *)l;
66154 @@ -66,6 +117,15 @@ static inline void atomic_long_sub(long i, atomic_long_t *l)
66155 atomic64_sub(i, v);
66156 }
66157
66158 +#ifdef CONFIG_PAX_REFCOUNT
66159 +static inline void atomic_long_sub_unchecked(long i, atomic_long_unchecked_t *l)
66160 +{
66161 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
66162 +
66163 + atomic64_sub_unchecked(i, v);
66164 +}
66165 +#endif
66166 +
66167 static inline int atomic_long_sub_and_test(long i, atomic_long_t *l)
66168 {
66169 atomic64_t *v = (atomic64_t *)l;
66170 @@ -101,6 +161,15 @@ static inline long atomic_long_add_return(long i, atomic_long_t *l)
66171 return (long)atomic64_add_return(i, v);
66172 }
66173
66174 +#ifdef CONFIG_PAX_REFCOUNT
66175 +static inline long atomic_long_add_return_unchecked(long i, atomic_long_unchecked_t *l)
66176 +{
66177 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
66178 +
66179 + return (long)atomic64_add_return_unchecked(i, v);
66180 +}
66181 +#endif
66182 +
66183 static inline long atomic_long_sub_return(long i, atomic_long_t *l)
66184 {
66185 atomic64_t *v = (atomic64_t *)l;
66186 @@ -115,6 +184,15 @@ static inline long atomic_long_inc_return(atomic_long_t *l)
66187 return (long)atomic64_inc_return(v);
66188 }
66189
66190 +#ifdef CONFIG_PAX_REFCOUNT
66191 +static inline long atomic_long_inc_return_unchecked(atomic_long_unchecked_t *l)
66192 +{
66193 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
66194 +
66195 + return (long)atomic64_inc_return_unchecked(v);
66196 +}
66197 +#endif
66198 +
66199 static inline long atomic_long_dec_return(atomic_long_t *l)
66200 {
66201 atomic64_t *v = (atomic64_t *)l;
66202 @@ -140,6 +218,12 @@ static inline long atomic_long_add_unless(atomic_long_t *l, long a, long u)
66203
66204 typedef atomic_t atomic_long_t;
66205
66206 +#ifdef CONFIG_PAX_REFCOUNT
66207 +typedef atomic_unchecked_t atomic_long_unchecked_t;
66208 +#else
66209 +typedef atomic_t atomic_long_unchecked_t;
66210 +#endif
66211 +
66212 #define ATOMIC_LONG_INIT(i) ATOMIC_INIT(i)
66213 static inline long atomic_long_read(atomic_long_t *l)
66214 {
66215 @@ -148,6 +232,15 @@ static inline long atomic_long_read(atomic_long_t *l)
66216 return (long)atomic_read(v);
66217 }
66218
66219 +#ifdef CONFIG_PAX_REFCOUNT
66220 +static inline long atomic_long_read_unchecked(atomic_long_unchecked_t *l)
66221 +{
66222 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
66223 +
66224 + return (long)atomic_read_unchecked(v);
66225 +}
66226 +#endif
66227 +
66228 static inline void atomic_long_set(atomic_long_t *l, long i)
66229 {
66230 atomic_t *v = (atomic_t *)l;
66231 @@ -155,6 +248,15 @@ static inline void atomic_long_set(atomic_long_t *l, long i)
66232 atomic_set(v, i);
66233 }
66234
66235 +#ifdef CONFIG_PAX_REFCOUNT
66236 +static inline void atomic_long_set_unchecked(atomic_long_unchecked_t *l, long i)
66237 +{
66238 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
66239 +
66240 + atomic_set_unchecked(v, i);
66241 +}
66242 +#endif
66243 +
66244 static inline void atomic_long_inc(atomic_long_t *l)
66245 {
66246 atomic_t *v = (atomic_t *)l;
66247 @@ -162,6 +264,15 @@ static inline void atomic_long_inc(atomic_long_t *l)
66248 atomic_inc(v);
66249 }
66250
66251 +#ifdef CONFIG_PAX_REFCOUNT
66252 +static inline void atomic_long_inc_unchecked(atomic_long_unchecked_t *l)
66253 +{
66254 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
66255 +
66256 + atomic_inc_unchecked(v);
66257 +}
66258 +#endif
66259 +
66260 static inline void atomic_long_dec(atomic_long_t *l)
66261 {
66262 atomic_t *v = (atomic_t *)l;
66263 @@ -169,6 +280,15 @@ static inline void atomic_long_dec(atomic_long_t *l)
66264 atomic_dec(v);
66265 }
66266
66267 +#ifdef CONFIG_PAX_REFCOUNT
66268 +static inline void atomic_long_dec_unchecked(atomic_long_unchecked_t *l)
66269 +{
66270 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
66271 +
66272 + atomic_dec_unchecked(v);
66273 +}
66274 +#endif
66275 +
66276 static inline void atomic_long_add(long i, atomic_long_t *l)
66277 {
66278 atomic_t *v = (atomic_t *)l;
66279 @@ -176,6 +296,15 @@ static inline void atomic_long_add(long i, atomic_long_t *l)
66280 atomic_add(i, v);
66281 }
66282
66283 +#ifdef CONFIG_PAX_REFCOUNT
66284 +static inline void atomic_long_add_unchecked(long i, atomic_long_unchecked_t *l)
66285 +{
66286 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
66287 +
66288 + atomic_add_unchecked(i, v);
66289 +}
66290 +#endif
66291 +
66292 static inline void atomic_long_sub(long i, atomic_long_t *l)
66293 {
66294 atomic_t *v = (atomic_t *)l;
66295 @@ -183,6 +312,15 @@ static inline void atomic_long_sub(long i, atomic_long_t *l)
66296 atomic_sub(i, v);
66297 }
66298
66299 +#ifdef CONFIG_PAX_REFCOUNT
66300 +static inline void atomic_long_sub_unchecked(long i, atomic_long_unchecked_t *l)
66301 +{
66302 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
66303 +
66304 + atomic_sub_unchecked(i, v);
66305 +}
66306 +#endif
66307 +
66308 static inline int atomic_long_sub_and_test(long i, atomic_long_t *l)
66309 {
66310 atomic_t *v = (atomic_t *)l;
66311 @@ -218,6 +356,16 @@ static inline long atomic_long_add_return(long i, atomic_long_t *l)
66312 return (long)atomic_add_return(i, v);
66313 }
66314
66315 +#ifdef CONFIG_PAX_REFCOUNT
66316 +static inline long atomic_long_add_return_unchecked(long i, atomic_long_unchecked_t *l)
66317 +{
66318 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
66319 +
66320 + return (long)atomic_add_return_unchecked(i, v);
66321 +}
66322 +
66323 +#endif
66324 +
66325 static inline long atomic_long_sub_return(long i, atomic_long_t *l)
66326 {
66327 atomic_t *v = (atomic_t *)l;
66328 @@ -232,6 +380,15 @@ static inline long atomic_long_inc_return(atomic_long_t *l)
66329 return (long)atomic_inc_return(v);
66330 }
66331
66332 +#ifdef CONFIG_PAX_REFCOUNT
66333 +static inline long atomic_long_inc_return_unchecked(atomic_long_unchecked_t *l)
66334 +{
66335 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
66336 +
66337 + return (long)atomic_inc_return_unchecked(v);
66338 +}
66339 +#endif
66340 +
66341 static inline long atomic_long_dec_return(atomic_long_t *l)
66342 {
66343 atomic_t *v = (atomic_t *)l;
66344 @@ -255,4 +412,57 @@ static inline long atomic_long_add_unless(atomic_long_t *l, long a, long u)
66345
66346 #endif /* BITS_PER_LONG == 64 */
66347
66348 +#ifdef CONFIG_PAX_REFCOUNT
66349 +static inline void pax_refcount_needs_these_functions(void)
66350 +{
66351 + atomic_read_unchecked((atomic_unchecked_t *)NULL);
66352 + atomic_set_unchecked((atomic_unchecked_t *)NULL, 0);
66353 + atomic_add_unchecked(0, (atomic_unchecked_t *)NULL);
66354 + atomic_sub_unchecked(0, (atomic_unchecked_t *)NULL);
66355 + atomic_inc_unchecked((atomic_unchecked_t *)NULL);
66356 + (void)atomic_inc_and_test_unchecked((atomic_unchecked_t *)NULL);
66357 + atomic_inc_return_unchecked((atomic_unchecked_t *)NULL);
66358 + atomic_add_return_unchecked(0, (atomic_unchecked_t *)NULL);
66359 + atomic_dec_unchecked((atomic_unchecked_t *)NULL);
66360 + atomic_cmpxchg_unchecked((atomic_unchecked_t *)NULL, 0, 0);
66361 + (void)atomic_xchg_unchecked((atomic_unchecked_t *)NULL, 0);
66362 +#ifdef CONFIG_X86
66363 + atomic_clear_mask_unchecked(0, NULL);
66364 + atomic_set_mask_unchecked(0, NULL);
66365 +#endif
66366 +
66367 + atomic_long_read_unchecked((atomic_long_unchecked_t *)NULL);
66368 + atomic_long_set_unchecked((atomic_long_unchecked_t *)NULL, 0);
66369 + atomic_long_add_unchecked(0, (atomic_long_unchecked_t *)NULL);
66370 + atomic_long_sub_unchecked(0, (atomic_long_unchecked_t *)NULL);
66371 + atomic_long_inc_unchecked((atomic_long_unchecked_t *)NULL);
66372 + atomic_long_add_return_unchecked(0, (atomic_long_unchecked_t *)NULL);
66373 + atomic_long_inc_return_unchecked((atomic_long_unchecked_t *)NULL);
66374 + atomic_long_dec_unchecked((atomic_long_unchecked_t *)NULL);
66375 +}
66376 +#else
66377 +#define atomic_read_unchecked(v) atomic_read(v)
66378 +#define atomic_set_unchecked(v, i) atomic_set((v), (i))
66379 +#define atomic_add_unchecked(i, v) atomic_add((i), (v))
66380 +#define atomic_sub_unchecked(i, v) atomic_sub((i), (v))
66381 +#define atomic_inc_unchecked(v) atomic_inc(v)
66382 +#define atomic_inc_and_test_unchecked(v) atomic_inc_and_test(v)
66383 +#define atomic_inc_return_unchecked(v) atomic_inc_return(v)
66384 +#define atomic_add_return_unchecked(i, v) atomic_add_return((i), (v))
66385 +#define atomic_dec_unchecked(v) atomic_dec(v)
66386 +#define atomic_cmpxchg_unchecked(v, o, n) atomic_cmpxchg((v), (o), (n))
66387 +#define atomic_xchg_unchecked(v, i) atomic_xchg((v), (i))
66388 +#define atomic_clear_mask_unchecked(mask, v) atomic_clear_mask((mask), (v))
66389 +#define atomic_set_mask_unchecked(mask, v) atomic_set_mask((mask), (v))
66390 +
66391 +#define atomic_long_read_unchecked(v) atomic_long_read(v)
66392 +#define atomic_long_set_unchecked(v, i) atomic_long_set((v), (i))
66393 +#define atomic_long_add_unchecked(i, v) atomic_long_add((i), (v))
66394 +#define atomic_long_sub_unchecked(i, v) atomic_long_sub((i), (v))
66395 +#define atomic_long_inc_unchecked(v) atomic_long_inc(v)
66396 +#define atomic_long_add_return_unchecked(i, v) atomic_long_add_return((i), (v))
66397 +#define atomic_long_inc_return_unchecked(v) atomic_long_inc_return(v)
66398 +#define atomic_long_dec_unchecked(v) atomic_long_dec(v)
66399 +#endif
66400 +
66401 #endif /* _ASM_GENERIC_ATOMIC_LONG_H */
66402 diff --git a/include/asm-generic/atomic.h b/include/asm-generic/atomic.h
66403 index 1ced641..c896ee8 100644
66404 --- a/include/asm-generic/atomic.h
66405 +++ b/include/asm-generic/atomic.h
66406 @@ -159,7 +159,7 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
66407 * Atomically clears the bits set in @mask from @v
66408 */
66409 #ifndef atomic_clear_mask
66410 -static inline void atomic_clear_mask(unsigned long mask, atomic_t *v)
66411 +static inline void atomic_clear_mask(unsigned int mask, atomic_t *v)
66412 {
66413 unsigned long flags;
66414
66415 diff --git a/include/asm-generic/atomic64.h b/include/asm-generic/atomic64.h
66416 index b18ce4f..2ee2843 100644
66417 --- a/include/asm-generic/atomic64.h
66418 +++ b/include/asm-generic/atomic64.h
66419 @@ -16,6 +16,8 @@ typedef struct {
66420 long long counter;
66421 } atomic64_t;
66422
66423 +typedef atomic64_t atomic64_unchecked_t;
66424 +
66425 #define ATOMIC64_INIT(i) { (i) }
66426
66427 extern long long atomic64_read(const atomic64_t *v);
66428 @@ -39,4 +41,14 @@ extern int atomic64_add_unless(atomic64_t *v, long long a, long long u);
66429 #define atomic64_dec_and_test(v) (atomic64_dec_return((v)) == 0)
66430 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1LL, 0LL)
66431
66432 +#define atomic64_read_unchecked(v) atomic64_read(v)
66433 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
66434 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
66435 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
66436 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
66437 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
66438 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
66439 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
66440 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
66441 +
66442 #endif /* _ASM_GENERIC_ATOMIC64_H */
66443 diff --git a/include/asm-generic/cache.h b/include/asm-generic/cache.h
66444 index 1bfcfe5..e04c5c9 100644
66445 --- a/include/asm-generic/cache.h
66446 +++ b/include/asm-generic/cache.h
66447 @@ -6,7 +6,7 @@
66448 * cache lines need to provide their own cache.h.
66449 */
66450
66451 -#define L1_CACHE_SHIFT 5
66452 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
66453 +#define L1_CACHE_SHIFT 5UL
66454 +#define L1_CACHE_BYTES (1UL << L1_CACHE_SHIFT)
66455
66456 #endif /* __ASM_GENERIC_CACHE_H */
66457 diff --git a/include/asm-generic/emergency-restart.h b/include/asm-generic/emergency-restart.h
66458 index 0d68a1e..b74a761 100644
66459 --- a/include/asm-generic/emergency-restart.h
66460 +++ b/include/asm-generic/emergency-restart.h
66461 @@ -1,7 +1,7 @@
66462 #ifndef _ASM_GENERIC_EMERGENCY_RESTART_H
66463 #define _ASM_GENERIC_EMERGENCY_RESTART_H
66464
66465 -static inline void machine_emergency_restart(void)
66466 +static inline __noreturn void machine_emergency_restart(void)
66467 {
66468 machine_restart(NULL);
66469 }
66470 diff --git a/include/asm-generic/kmap_types.h b/include/asm-generic/kmap_types.h
66471 index 90f99c7..00ce236 100644
66472 --- a/include/asm-generic/kmap_types.h
66473 +++ b/include/asm-generic/kmap_types.h
66474 @@ -2,9 +2,9 @@
66475 #define _ASM_GENERIC_KMAP_TYPES_H
66476
66477 #ifdef __WITH_KM_FENCE
66478 -# define KM_TYPE_NR 41
66479 +# define KM_TYPE_NR 42
66480 #else
66481 -# define KM_TYPE_NR 20
66482 +# define KM_TYPE_NR 21
66483 #endif
66484
66485 #endif
66486 diff --git a/include/asm-generic/local.h b/include/asm-generic/local.h
66487 index 9ceb03b..62b0b8f 100644
66488 --- a/include/asm-generic/local.h
66489 +++ b/include/asm-generic/local.h
66490 @@ -23,24 +23,37 @@ typedef struct
66491 atomic_long_t a;
66492 } local_t;
66493
66494 +typedef struct {
66495 + atomic_long_unchecked_t a;
66496 +} local_unchecked_t;
66497 +
66498 #define LOCAL_INIT(i) { ATOMIC_LONG_INIT(i) }
66499
66500 #define local_read(l) atomic_long_read(&(l)->a)
66501 +#define local_read_unchecked(l) atomic_long_read_unchecked(&(l)->a)
66502 #define local_set(l,i) atomic_long_set((&(l)->a),(i))
66503 +#define local_set_unchecked(l,i) atomic_long_set_unchecked((&(l)->a),(i))
66504 #define local_inc(l) atomic_long_inc(&(l)->a)
66505 +#define local_inc_unchecked(l) atomic_long_inc_unchecked(&(l)->a)
66506 #define local_dec(l) atomic_long_dec(&(l)->a)
66507 +#define local_dec_unchecked(l) atomic_long_dec_unchecked(&(l)->a)
66508 #define local_add(i,l) atomic_long_add((i),(&(l)->a))
66509 +#define local_add_unchecked(i,l) atomic_long_add_unchecked((i),(&(l)->a))
66510 #define local_sub(i,l) atomic_long_sub((i),(&(l)->a))
66511 +#define local_sub_unchecked(i,l) atomic_long_sub_unchecked((i),(&(l)->a))
66512
66513 #define local_sub_and_test(i, l) atomic_long_sub_and_test((i), (&(l)->a))
66514 #define local_dec_and_test(l) atomic_long_dec_and_test(&(l)->a)
66515 #define local_inc_and_test(l) atomic_long_inc_and_test(&(l)->a)
66516 #define local_add_negative(i, l) atomic_long_add_negative((i), (&(l)->a))
66517 #define local_add_return(i, l) atomic_long_add_return((i), (&(l)->a))
66518 +#define local_add_return_unchecked(i, l) atomic_long_add_return_unchecked((i), (&(l)->a))
66519 #define local_sub_return(i, l) atomic_long_sub_return((i), (&(l)->a))
66520 #define local_inc_return(l) atomic_long_inc_return(&(l)->a)
66521 +#define local_dec_return(l) atomic_long_dec_return(&(l)->a)
66522
66523 #define local_cmpxchg(l, o, n) atomic_long_cmpxchg((&(l)->a), (o), (n))
66524 +#define local_cmpxchg_unchecked(l, o, n) atomic_long_cmpxchg((&(l)->a), (o), (n))
66525 #define local_xchg(l, n) atomic_long_xchg((&(l)->a), (n))
66526 #define local_add_unless(l, _a, u) atomic_long_add_unless((&(l)->a), (_a), (u))
66527 #define local_inc_not_zero(l) atomic_long_inc_not_zero(&(l)->a)
66528 diff --git a/include/asm-generic/pgtable-nopmd.h b/include/asm-generic/pgtable-nopmd.h
66529 index 725612b..9cc513a 100644
66530 --- a/include/asm-generic/pgtable-nopmd.h
66531 +++ b/include/asm-generic/pgtable-nopmd.h
66532 @@ -1,14 +1,19 @@
66533 #ifndef _PGTABLE_NOPMD_H
66534 #define _PGTABLE_NOPMD_H
66535
66536 -#ifndef __ASSEMBLY__
66537 -
66538 #include <asm-generic/pgtable-nopud.h>
66539
66540 -struct mm_struct;
66541 -
66542 #define __PAGETABLE_PMD_FOLDED
66543
66544 +#define PMD_SHIFT PUD_SHIFT
66545 +#define PTRS_PER_PMD 1
66546 +#define PMD_SIZE (_AC(1,UL) << PMD_SHIFT)
66547 +#define PMD_MASK (~(PMD_SIZE-1))
66548 +
66549 +#ifndef __ASSEMBLY__
66550 +
66551 +struct mm_struct;
66552 +
66553 /*
66554 * Having the pmd type consist of a pud gets the size right, and allows
66555 * us to conceptually access the pud entry that this pmd is folded into
66556 @@ -16,11 +21,6 @@ struct mm_struct;
66557 */
66558 typedef struct { pud_t pud; } pmd_t;
66559
66560 -#define PMD_SHIFT PUD_SHIFT
66561 -#define PTRS_PER_PMD 1
66562 -#define PMD_SIZE (1UL << PMD_SHIFT)
66563 -#define PMD_MASK (~(PMD_SIZE-1))
66564 -
66565 /*
66566 * The "pud_xxx()" functions here are trivial for a folded two-level
66567 * setup: the pmd is never bad, and a pmd always exists (as it's folded
66568 diff --git a/include/asm-generic/pgtable-nopud.h b/include/asm-generic/pgtable-nopud.h
66569 index 810431d..0ec4804f 100644
66570 --- a/include/asm-generic/pgtable-nopud.h
66571 +++ b/include/asm-generic/pgtable-nopud.h
66572 @@ -1,10 +1,15 @@
66573 #ifndef _PGTABLE_NOPUD_H
66574 #define _PGTABLE_NOPUD_H
66575
66576 -#ifndef __ASSEMBLY__
66577 -
66578 #define __PAGETABLE_PUD_FOLDED
66579
66580 +#define PUD_SHIFT PGDIR_SHIFT
66581 +#define PTRS_PER_PUD 1
66582 +#define PUD_SIZE (_AC(1,UL) << PUD_SHIFT)
66583 +#define PUD_MASK (~(PUD_SIZE-1))
66584 +
66585 +#ifndef __ASSEMBLY__
66586 +
66587 /*
66588 * Having the pud type consist of a pgd gets the size right, and allows
66589 * us to conceptually access the pgd entry that this pud is folded into
66590 @@ -12,11 +17,6 @@
66591 */
66592 typedef struct { pgd_t pgd; } pud_t;
66593
66594 -#define PUD_SHIFT PGDIR_SHIFT
66595 -#define PTRS_PER_PUD 1
66596 -#define PUD_SIZE (1UL << PUD_SHIFT)
66597 -#define PUD_MASK (~(PUD_SIZE-1))
66598 -
66599 /*
66600 * The "pgd_xxx()" functions here are trivial for a folded two-level
66601 * setup: the pud is never bad, and a pud always exists (as it's folded
66602 @@ -29,6 +29,7 @@ static inline void pgd_clear(pgd_t *pgd) { }
66603 #define pud_ERROR(pud) (pgd_ERROR((pud).pgd))
66604
66605 #define pgd_populate(mm, pgd, pud) do { } while (0)
66606 +#define pgd_populate_kernel(mm, pgd, pud) do { } while (0)
66607 /*
66608 * (puds are folded into pgds so this doesn't get actually called,
66609 * but the define is needed for a generic inline function.)
66610 diff --git a/include/asm-generic/pgtable.h b/include/asm-generic/pgtable.h
66611 index 5cf680a..4b74d62 100644
66612 --- a/include/asm-generic/pgtable.h
66613 +++ b/include/asm-generic/pgtable.h
66614 @@ -688,6 +688,14 @@ static inline pmd_t pmd_mknuma(pmd_t pmd)
66615 }
66616 #endif /* CONFIG_NUMA_BALANCING */
66617
66618 +#ifndef __HAVE_ARCH_PAX_OPEN_KERNEL
66619 +static inline unsigned long pax_open_kernel(void) { return 0; }
66620 +#endif
66621 +
66622 +#ifndef __HAVE_ARCH_PAX_CLOSE_KERNEL
66623 +static inline unsigned long pax_close_kernel(void) { return 0; }
66624 +#endif
66625 +
66626 #endif /* CONFIG_MMU */
66627
66628 #endif /* !__ASSEMBLY__ */
66629 diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
66630 index d1ea7ce..b1ebf2a 100644
66631 --- a/include/asm-generic/vmlinux.lds.h
66632 +++ b/include/asm-generic/vmlinux.lds.h
66633 @@ -218,6 +218,7 @@
66634 .rodata : AT(ADDR(.rodata) - LOAD_OFFSET) { \
66635 VMLINUX_SYMBOL(__start_rodata) = .; \
66636 *(.rodata) *(.rodata.*) \
66637 + *(.data..read_only) \
66638 *(__vermagic) /* Kernel version magic */ \
66639 . = ALIGN(8); \
66640 VMLINUX_SYMBOL(__start___tracepoints_ptrs) = .; \
66641 @@ -725,17 +726,18 @@
66642 * section in the linker script will go there too. @phdr should have
66643 * a leading colon.
66644 *
66645 - * Note that this macros defines __per_cpu_load as an absolute symbol.
66646 + * Note that this macros defines per_cpu_load as an absolute symbol.
66647 * If there is no need to put the percpu section at a predetermined
66648 * address, use PERCPU_SECTION.
66649 */
66650 #define PERCPU_VADDR(cacheline, vaddr, phdr) \
66651 - VMLINUX_SYMBOL(__per_cpu_load) = .; \
66652 - .data..percpu vaddr : AT(VMLINUX_SYMBOL(__per_cpu_load) \
66653 + per_cpu_load = .; \
66654 + .data..percpu vaddr : AT(VMLINUX_SYMBOL(per_cpu_load) \
66655 - LOAD_OFFSET) { \
66656 + VMLINUX_SYMBOL(__per_cpu_load) = . + per_cpu_load; \
66657 PERCPU_INPUT(cacheline) \
66658 } phdr \
66659 - . = VMLINUX_SYMBOL(__per_cpu_load) + SIZEOF(.data..percpu);
66660 + . = VMLINUX_SYMBOL(per_cpu_load) + SIZEOF(.data..percpu);
66661
66662 /**
66663 * PERCPU_SECTION - define output section for percpu area, simple version
66664 diff --git a/include/crypto/algapi.h b/include/crypto/algapi.h
66665 index 418d270..bfd2794 100644
66666 --- a/include/crypto/algapi.h
66667 +++ b/include/crypto/algapi.h
66668 @@ -34,7 +34,7 @@ struct crypto_type {
66669 unsigned int maskclear;
66670 unsigned int maskset;
66671 unsigned int tfmsize;
66672 -};
66673 +} __do_const;
66674
66675 struct crypto_instance {
66676 struct crypto_alg alg;
66677 diff --git a/include/drm/drmP.h b/include/drm/drmP.h
66678 index fad21c9..ab858bc 100644
66679 --- a/include/drm/drmP.h
66680 +++ b/include/drm/drmP.h
66681 @@ -72,6 +72,7 @@
66682 #include <linux/workqueue.h>
66683 #include <linux/poll.h>
66684 #include <asm/pgalloc.h>
66685 +#include <asm/local.h>
66686 #include <drm/drm.h>
66687 #include <drm/drm_sarea.h>
66688
66689 @@ -293,10 +294,12 @@ do { \
66690 * \param cmd command.
66691 * \param arg argument.
66692 */
66693 -typedef int drm_ioctl_t(struct drm_device *dev, void *data,
66694 +typedef int (* const drm_ioctl_t)(struct drm_device *dev, void *data,
66695 + struct drm_file *file_priv);
66696 +typedef int (* drm_ioctl_no_const_t)(struct drm_device *dev, void *data,
66697 struct drm_file *file_priv);
66698
66699 -typedef int drm_ioctl_compat_t(struct file *filp, unsigned int cmd,
66700 +typedef int (* const drm_ioctl_compat_t)(struct file *filp, unsigned int cmd,
66701 unsigned long arg);
66702
66703 #define DRM_IOCTL_NR(n) _IOC_NR(n)
66704 @@ -311,9 +314,9 @@ typedef int drm_ioctl_compat_t(struct file *filp, unsigned int cmd,
66705 struct drm_ioctl_desc {
66706 unsigned int cmd;
66707 int flags;
66708 - drm_ioctl_t *func;
66709 + drm_ioctl_t func;
66710 unsigned int cmd_drv;
66711 -};
66712 +} __do_const;
66713
66714 /**
66715 * Creates a driver or general drm_ioctl_desc array entry for the given
66716 @@ -995,7 +998,7 @@ struct drm_info_list {
66717 int (*show)(struct seq_file*, void*); /** show callback */
66718 u32 driver_features; /**< Required driver features for this entry */
66719 void *data;
66720 -};
66721 +} __do_const;
66722
66723 /**
66724 * debugfs node structure. This structure represents a debugfs file.
66725 @@ -1068,7 +1071,7 @@ struct drm_device {
66726
66727 /** \name Usage Counters */
66728 /*@{ */
66729 - int open_count; /**< Outstanding files open */
66730 + local_t open_count; /**< Outstanding files open */
66731 atomic_t ioctl_count; /**< Outstanding IOCTLs pending */
66732 atomic_t vma_count; /**< Outstanding vma areas open */
66733 int buf_use; /**< Buffers in use -- cannot alloc */
66734 @@ -1079,7 +1082,7 @@ struct drm_device {
66735 /*@{ */
66736 unsigned long counters;
66737 enum drm_stat_type types[15];
66738 - atomic_t counts[15];
66739 + atomic_unchecked_t counts[15];
66740 /*@} */
66741
66742 struct list_head filelist;
66743 diff --git a/include/drm/drm_crtc_helper.h b/include/drm/drm_crtc_helper.h
66744 index f43d556..94d9343 100644
66745 --- a/include/drm/drm_crtc_helper.h
66746 +++ b/include/drm/drm_crtc_helper.h
66747 @@ -109,7 +109,7 @@ struct drm_encoder_helper_funcs {
66748 struct drm_connector *connector);
66749 /* disable encoder when not in use - more explicit than dpms off */
66750 void (*disable)(struct drm_encoder *encoder);
66751 -};
66752 +} __no_const;
66753
66754 /**
66755 * drm_connector_helper_funcs - helper operations for connectors
66756 diff --git a/include/drm/ttm/ttm_memory.h b/include/drm/ttm/ttm_memory.h
66757 index 72dcbe8..8db58d7 100644
66758 --- a/include/drm/ttm/ttm_memory.h
66759 +++ b/include/drm/ttm/ttm_memory.h
66760 @@ -48,7 +48,7 @@
66761
66762 struct ttm_mem_shrink {
66763 int (*do_shrink) (struct ttm_mem_shrink *);
66764 -};
66765 +} __no_const;
66766
66767 /**
66768 * struct ttm_mem_global - Global memory accounting structure.
66769 diff --git a/include/keys/asymmetric-subtype.h b/include/keys/asymmetric-subtype.h
66770 index 4b840e8..155d235 100644
66771 --- a/include/keys/asymmetric-subtype.h
66772 +++ b/include/keys/asymmetric-subtype.h
66773 @@ -37,7 +37,7 @@ struct asymmetric_key_subtype {
66774 /* Verify the signature on a key of this subtype (optional) */
66775 int (*verify_signature)(const struct key *key,
66776 const struct public_key_signature *sig);
66777 -};
66778 +} __do_const;
66779
66780 /**
66781 * asymmetric_key_subtype - Get the subtype from an asymmetric key
66782 diff --git a/include/linux/atmdev.h b/include/linux/atmdev.h
66783 index c1da539..1dcec55 100644
66784 --- a/include/linux/atmdev.h
66785 +++ b/include/linux/atmdev.h
66786 @@ -28,7 +28,7 @@ struct compat_atm_iobuf {
66787 #endif
66788
66789 struct k_atm_aal_stats {
66790 -#define __HANDLE_ITEM(i) atomic_t i
66791 +#define __HANDLE_ITEM(i) atomic_unchecked_t i
66792 __AAL_STAT_ITEMS
66793 #undef __HANDLE_ITEM
66794 };
66795 @@ -200,7 +200,7 @@ struct atmdev_ops { /* only send is required */
66796 int (*change_qos)(struct atm_vcc *vcc,struct atm_qos *qos,int flags);
66797 int (*proc_read)(struct atm_dev *dev,loff_t *pos,char *page);
66798 struct module *owner;
66799 -};
66800 +} __do_const ;
66801
66802 struct atmphy_ops {
66803 int (*start)(struct atm_dev *dev);
66804 diff --git a/include/linux/binfmts.h b/include/linux/binfmts.h
66805 index 0530b98..96a8ac0 100644
66806 --- a/include/linux/binfmts.h
66807 +++ b/include/linux/binfmts.h
66808 @@ -73,8 +73,9 @@ struct linux_binfmt {
66809 int (*load_binary)(struct linux_binprm *);
66810 int (*load_shlib)(struct file *);
66811 int (*core_dump)(struct coredump_params *cprm);
66812 + void (*handle_mprotect)(struct vm_area_struct *vma, unsigned long newflags);
66813 unsigned long min_coredump; /* minimal dump size */
66814 -};
66815 +} __do_const;
66816
66817 extern void __register_binfmt(struct linux_binfmt *fmt, int insert);
66818
66819 diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
66820 index f94bc83..62b9cfe 100644
66821 --- a/include/linux/blkdev.h
66822 +++ b/include/linux/blkdev.h
66823 @@ -1498,7 +1498,7 @@ struct block_device_operations {
66824 /* this callback is with swap_lock and sometimes page table lock held */
66825 void (*swap_slot_free_notify) (struct block_device *, unsigned long);
66826 struct module *owner;
66827 -};
66828 +} __do_const;
66829
66830 extern int __blkdev_driver_ioctl(struct block_device *, fmode_t, unsigned int,
66831 unsigned long);
66832 diff --git a/include/linux/blktrace_api.h b/include/linux/blktrace_api.h
66833 index 7c2e030..b72475d 100644
66834 --- a/include/linux/blktrace_api.h
66835 +++ b/include/linux/blktrace_api.h
66836 @@ -23,7 +23,7 @@ struct blk_trace {
66837 struct dentry *dir;
66838 struct dentry *dropped_file;
66839 struct dentry *msg_file;
66840 - atomic_t dropped;
66841 + atomic_unchecked_t dropped;
66842 };
66843
66844 extern int blk_trace_ioctl(struct block_device *, unsigned, char __user *);
66845 diff --git a/include/linux/cache.h b/include/linux/cache.h
66846 index 4c57065..4307975 100644
66847 --- a/include/linux/cache.h
66848 +++ b/include/linux/cache.h
66849 @@ -16,6 +16,10 @@
66850 #define __read_mostly
66851 #endif
66852
66853 +#ifndef __read_only
66854 +#define __read_only __read_mostly
66855 +#endif
66856 +
66857 #ifndef ____cacheline_aligned
66858 #define ____cacheline_aligned __attribute__((__aligned__(SMP_CACHE_BYTES)))
66859 #endif
66860 diff --git a/include/linux/capability.h b/include/linux/capability.h
66861 index 98503b7..cc36d18 100644
66862 --- a/include/linux/capability.h
66863 +++ b/include/linux/capability.h
66864 @@ -211,8 +211,13 @@ extern bool capable(int cap);
66865 extern bool ns_capable(struct user_namespace *ns, int cap);
66866 extern bool nsown_capable(int cap);
66867 extern bool inode_capable(const struct inode *inode, int cap);
66868 +extern bool capable_nolog(int cap);
66869 +extern bool ns_capable_nolog(struct user_namespace *ns, int cap);
66870 +extern bool inode_capable_nolog(const struct inode *inode, int cap);
66871
66872 /* audit system wants to get cap info from files as well */
66873 extern int get_vfs_caps_from_disk(const struct dentry *dentry, struct cpu_vfs_cap_data *cpu_caps);
66874
66875 +extern int is_privileged_binary(const struct dentry *dentry);
66876 +
66877 #endif /* !_LINUX_CAPABILITY_H */
66878 diff --git a/include/linux/cdrom.h b/include/linux/cdrom.h
66879 index 8609d57..86e4d79 100644
66880 --- a/include/linux/cdrom.h
66881 +++ b/include/linux/cdrom.h
66882 @@ -87,7 +87,6 @@ struct cdrom_device_ops {
66883
66884 /* driver specifications */
66885 const int capability; /* capability flags */
66886 - int n_minors; /* number of active minor devices */
66887 /* handle uniform packets for scsi type devices (scsi,atapi) */
66888 int (*generic_packet) (struct cdrom_device_info *,
66889 struct packet_command *);
66890 diff --git a/include/linux/cleancache.h b/include/linux/cleancache.h
66891 index 42e55de..1cd0e66 100644
66892 --- a/include/linux/cleancache.h
66893 +++ b/include/linux/cleancache.h
66894 @@ -31,7 +31,7 @@ struct cleancache_ops {
66895 void (*invalidate_page)(int, struct cleancache_filekey, pgoff_t);
66896 void (*invalidate_inode)(int, struct cleancache_filekey);
66897 void (*invalidate_fs)(int);
66898 -};
66899 +} __no_const;
66900
66901 extern struct cleancache_ops
66902 cleancache_register_ops(struct cleancache_ops *ops);
66903 diff --git a/include/linux/compat.h b/include/linux/compat.h
66904 index dec7e2d..45db13f 100644
66905 --- a/include/linux/compat.h
66906 +++ b/include/linux/compat.h
66907 @@ -311,14 +311,14 @@ long compat_sys_msgsnd(int first, int second, int third, void __user *uptr);
66908 long compat_sys_msgrcv(int first, int second, int msgtyp, int third,
66909 int version, void __user *uptr);
66910 long compat_sys_shmat(int first, int second, compat_uptr_t third, int version,
66911 - void __user *uptr);
66912 + void __user *uptr) __intentional_overflow(0);
66913 #else
66914 long compat_sys_semctl(int semid, int semnum, int cmd, int arg);
66915 long compat_sys_msgsnd(int msqid, struct compat_msgbuf __user *msgp,
66916 compat_ssize_t msgsz, int msgflg);
66917 long compat_sys_msgrcv(int msqid, struct compat_msgbuf __user *msgp,
66918 compat_ssize_t msgsz, long msgtyp, int msgflg);
66919 -long compat_sys_shmat(int shmid, compat_uptr_t shmaddr, int shmflg);
66920 +long compat_sys_shmat(int shmid, compat_uptr_t shmaddr, int shmflg) __intentional_overflow(0);
66921 #endif
66922 long compat_sys_msgctl(int first, int second, void __user *uptr);
66923 long compat_sys_shmctl(int first, int second, void __user *uptr);
66924 @@ -414,7 +414,7 @@ extern int compat_ptrace_request(struct task_struct *child,
66925 extern long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
66926 compat_ulong_t addr, compat_ulong_t data);
66927 asmlinkage long compat_sys_ptrace(compat_long_t request, compat_long_t pid,
66928 - compat_long_t addr, compat_long_t data);
66929 + compat_ulong_t addr, compat_ulong_t data);
66930
66931 /*
66932 * epoll (fs/eventpoll.c) compat bits follow ...
66933 diff --git a/include/linux/compiler-gcc4.h b/include/linux/compiler-gcc4.h
66934 index 662fd1b..e801992 100644
66935 --- a/include/linux/compiler-gcc4.h
66936 +++ b/include/linux/compiler-gcc4.h
66937 @@ -34,6 +34,21 @@
66938 #define __UNIQUE_ID(prefix) __PASTE(__PASTE(__UNIQUE_ID_, prefix), __COUNTER__)
66939
66940 #if __GNUC_MINOR__ >= 5
66941 +
66942 +#ifdef CONSTIFY_PLUGIN
66943 +#define __no_const __attribute__((no_const))
66944 +#define __do_const __attribute__((do_const))
66945 +#endif
66946 +
66947 +#ifdef SIZE_OVERFLOW_PLUGIN
66948 +#define __size_overflow(...) __attribute__((size_overflow(__VA_ARGS__)))
66949 +#define __intentional_overflow(...) __attribute__((intentional_overflow(__VA_ARGS__)))
66950 +#endif
66951 +
66952 +#ifdef LATENT_ENTROPY_PLUGIN
66953 +#define __latent_entropy __attribute__((latent_entropy))
66954 +#endif
66955 +
66956 /*
66957 * Mark a position in code as unreachable. This can be used to
66958 * suppress control flow warnings after asm blocks that transfer
66959 @@ -49,6 +64,11 @@
66960 #define __noclone __attribute__((__noclone__))
66961
66962 #endif
66963 +
66964 +#define __alloc_size(...) __attribute((alloc_size(__VA_ARGS__)))
66965 +#define __bos(ptr, arg) __builtin_object_size((ptr), (arg))
66966 +#define __bos0(ptr) __bos((ptr), 0)
66967 +#define __bos1(ptr) __bos((ptr), 1)
66968 #endif
66969
66970 #if __GNUC_MINOR__ >= 6
66971 diff --git a/include/linux/compiler.h b/include/linux/compiler.h
66972 index dd852b7..72924c0 100644
66973 --- a/include/linux/compiler.h
66974 +++ b/include/linux/compiler.h
66975 @@ -5,11 +5,14 @@
66976
66977 #ifdef __CHECKER__
66978 # define __user __attribute__((noderef, address_space(1)))
66979 +# define __force_user __force __user
66980 # define __kernel __attribute__((address_space(0)))
66981 +# define __force_kernel __force __kernel
66982 # define __safe __attribute__((safe))
66983 # define __force __attribute__((force))
66984 # define __nocast __attribute__((nocast))
66985 # define __iomem __attribute__((noderef, address_space(2)))
66986 +# define __force_iomem __force __iomem
66987 # define __must_hold(x) __attribute__((context(x,1,1)))
66988 # define __acquires(x) __attribute__((context(x,0,1)))
66989 # define __releases(x) __attribute__((context(x,1,0)))
66990 @@ -17,20 +20,48 @@
66991 # define __release(x) __context__(x,-1)
66992 # define __cond_lock(x,c) ((c) ? ({ __acquire(x); 1; }) : 0)
66993 # define __percpu __attribute__((noderef, address_space(3)))
66994 +# define __force_percpu __force __percpu
66995 #ifdef CONFIG_SPARSE_RCU_POINTER
66996 # define __rcu __attribute__((noderef, address_space(4)))
66997 +# define __force_rcu __force __rcu
66998 #else
66999 # define __rcu
67000 +# define __force_rcu
67001 #endif
67002 extern void __chk_user_ptr(const volatile void __user *);
67003 extern void __chk_io_ptr(const volatile void __iomem *);
67004 +#elif defined(CHECKER_PLUGIN)
67005 +//# define __user
67006 +//# define __force_user
67007 +//# define __kernel
67008 +//# define __force_kernel
67009 +# define __safe
67010 +# define __force
67011 +# define __nocast
67012 +# define __iomem
67013 +# define __force_iomem
67014 +# define __chk_user_ptr(x) (void)0
67015 +# define __chk_io_ptr(x) (void)0
67016 +# define __builtin_warning(x, y...) (1)
67017 +# define __acquires(x)
67018 +# define __releases(x)
67019 +# define __acquire(x) (void)0
67020 +# define __release(x) (void)0
67021 +# define __cond_lock(x,c) (c)
67022 +# define __percpu
67023 +# define __force_percpu
67024 +# define __rcu
67025 +# define __force_rcu
67026 #else
67027 # define __user
67028 +# define __force_user
67029 # define __kernel
67030 +# define __force_kernel
67031 # define __safe
67032 # define __force
67033 # define __nocast
67034 # define __iomem
67035 +# define __force_iomem
67036 # define __chk_user_ptr(x) (void)0
67037 # define __chk_io_ptr(x) (void)0
67038 # define __builtin_warning(x, y...) (1)
67039 @@ -41,7 +72,9 @@ extern void __chk_io_ptr(const volatile void __iomem *);
67040 # define __release(x) (void)0
67041 # define __cond_lock(x,c) (c)
67042 # define __percpu
67043 +# define __force_percpu
67044 # define __rcu
67045 +# define __force_rcu
67046 #endif
67047
67048 /* Indirect macros required for expanded argument pasting, eg. __LINE__. */
67049 @@ -275,6 +308,26 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
67050 # define __attribute_const__ /* unimplemented */
67051 #endif
67052
67053 +#ifndef __no_const
67054 +# define __no_const
67055 +#endif
67056 +
67057 +#ifndef __do_const
67058 +# define __do_const
67059 +#endif
67060 +
67061 +#ifndef __size_overflow
67062 +# define __size_overflow(...)
67063 +#endif
67064 +
67065 +#ifndef __intentional_overflow
67066 +# define __intentional_overflow(...)
67067 +#endif
67068 +
67069 +#ifndef __latent_entropy
67070 +# define __latent_entropy
67071 +#endif
67072 +
67073 /*
67074 * Tell gcc if a function is cold. The compiler will assume any path
67075 * directly leading to the call is unlikely.
67076 @@ -284,6 +337,22 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
67077 #define __cold
67078 #endif
67079
67080 +#ifndef __alloc_size
67081 +#define __alloc_size(...)
67082 +#endif
67083 +
67084 +#ifndef __bos
67085 +#define __bos(ptr, arg)
67086 +#endif
67087 +
67088 +#ifndef __bos0
67089 +#define __bos0(ptr)
67090 +#endif
67091 +
67092 +#ifndef __bos1
67093 +#define __bos1(ptr)
67094 +#endif
67095 +
67096 /* Simple shorthand for a section definition */
67097 #ifndef __section
67098 # define __section(S) __attribute__ ((__section__(#S)))
67099 @@ -323,6 +392,7 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
67100 * use is to mediate communication between process-level code and irq/NMI
67101 * handlers, all running on the same CPU.
67102 */
67103 -#define ACCESS_ONCE(x) (*(volatile typeof(x) *)&(x))
67104 +#define ACCESS_ONCE(x) (*(volatile const typeof(x) *)&(x))
67105 +#define ACCESS_ONCE_RW(x) (*(volatile typeof(x) *)&(x))
67106
67107 #endif /* __LINUX_COMPILER_H */
67108 diff --git a/include/linux/completion.h b/include/linux/completion.h
67109 index 51494e6..0fd1b61 100644
67110 --- a/include/linux/completion.h
67111 +++ b/include/linux/completion.h
67112 @@ -78,13 +78,13 @@ static inline void init_completion(struct completion *x)
67113
67114 extern void wait_for_completion(struct completion *);
67115 extern int wait_for_completion_interruptible(struct completion *x);
67116 -extern int wait_for_completion_killable(struct completion *x);
67117 +extern int wait_for_completion_killable(struct completion *x) __intentional_overflow(-1);
67118 extern unsigned long wait_for_completion_timeout(struct completion *x,
67119 unsigned long timeout);
67120 extern long wait_for_completion_interruptible_timeout(
67121 - struct completion *x, unsigned long timeout);
67122 + struct completion *x, unsigned long timeout) __intentional_overflow(-1);
67123 extern long wait_for_completion_killable_timeout(
67124 - struct completion *x, unsigned long timeout);
67125 + struct completion *x, unsigned long timeout) __intentional_overflow(-1);
67126 extern bool try_wait_for_completion(struct completion *x);
67127 extern bool completion_done(struct completion *x);
67128
67129 diff --git a/include/linux/configfs.h b/include/linux/configfs.h
67130 index 34025df..d94bbbc 100644
67131 --- a/include/linux/configfs.h
67132 +++ b/include/linux/configfs.h
67133 @@ -125,7 +125,7 @@ struct configfs_attribute {
67134 const char *ca_name;
67135 struct module *ca_owner;
67136 umode_t ca_mode;
67137 -};
67138 +} __do_const;
67139
67140 /*
67141 * Users often need to create attribute structures for their configurable
67142 diff --git a/include/linux/cpu.h b/include/linux/cpu.h
67143 index ce7a074..01ab8ac 100644
67144 --- a/include/linux/cpu.h
67145 +++ b/include/linux/cpu.h
67146 @@ -115,7 +115,7 @@ enum {
67147 /* Need to know about CPUs going up/down? */
67148 #if defined(CONFIG_HOTPLUG_CPU) || !defined(MODULE)
67149 #define cpu_notifier(fn, pri) { \
67150 - static struct notifier_block fn##_nb __cpuinitdata = \
67151 + static struct notifier_block fn##_nb = \
67152 { .notifier_call = fn, .priority = pri }; \
67153 register_cpu_notifier(&fn##_nb); \
67154 }
67155 diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h
67156 index a55b88e..fba90c5 100644
67157 --- a/include/linux/cpufreq.h
67158 +++ b/include/linux/cpufreq.h
67159 @@ -240,7 +240,7 @@ struct cpufreq_driver {
67160 int (*suspend) (struct cpufreq_policy *policy);
67161 int (*resume) (struct cpufreq_policy *policy);
67162 struct freq_attr **attr;
67163 -};
67164 +} __do_const;
67165
67166 /* flags */
67167
67168 @@ -299,6 +299,7 @@ struct global_attr {
67169 ssize_t (*store)(struct kobject *a, struct attribute *b,
67170 const char *c, size_t count);
67171 };
67172 +typedef struct global_attr __no_const global_attr_no_const;
67173
67174 #define define_one_global_ro(_name) \
67175 static struct global_attr _name = \
67176 diff --git a/include/linux/cpuidle.h b/include/linux/cpuidle.h
67177 index 24cd1037..20a63aae 100644
67178 --- a/include/linux/cpuidle.h
67179 +++ b/include/linux/cpuidle.h
67180 @@ -54,7 +54,8 @@ struct cpuidle_state {
67181 int index);
67182
67183 int (*enter_dead) (struct cpuidle_device *dev, int index);
67184 -};
67185 +} __do_const;
67186 +typedef struct cpuidle_state __no_const cpuidle_state_no_const;
67187
67188 /* Idle State Flags */
67189 #define CPUIDLE_FLAG_TIME_VALID (0x01) /* is residency time measurable? */
67190 @@ -216,7 +217,7 @@ struct cpuidle_governor {
67191 void (*reflect) (struct cpuidle_device *dev, int index);
67192
67193 struct module *owner;
67194 -};
67195 +} __do_const;
67196
67197 #ifdef CONFIG_CPU_IDLE
67198
67199 diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h
67200 index 0325602..5e9feff 100644
67201 --- a/include/linux/cpumask.h
67202 +++ b/include/linux/cpumask.h
67203 @@ -118,17 +118,17 @@ static inline unsigned int cpumask_first(const struct cpumask *srcp)
67204 }
67205
67206 /* Valid inputs for n are -1 and 0. */
67207 -static inline unsigned int cpumask_next(int n, const struct cpumask *srcp)
67208 +static inline unsigned int __intentional_overflow(-1) cpumask_next(int n, const struct cpumask *srcp)
67209 {
67210 return n+1;
67211 }
67212
67213 -static inline unsigned int cpumask_next_zero(int n, const struct cpumask *srcp)
67214 +static inline unsigned int __intentional_overflow(-1) cpumask_next_zero(int n, const struct cpumask *srcp)
67215 {
67216 return n+1;
67217 }
67218
67219 -static inline unsigned int cpumask_next_and(int n,
67220 +static inline unsigned int __intentional_overflow(-1) cpumask_next_and(int n,
67221 const struct cpumask *srcp,
67222 const struct cpumask *andp)
67223 {
67224 @@ -167,7 +167,7 @@ static inline unsigned int cpumask_first(const struct cpumask *srcp)
67225 *
67226 * Returns >= nr_cpu_ids if no further cpus set.
67227 */
67228 -static inline unsigned int cpumask_next(int n, const struct cpumask *srcp)
67229 +static inline unsigned int __intentional_overflow(-1) cpumask_next(int n, const struct cpumask *srcp)
67230 {
67231 /* -1 is a legal arg here. */
67232 if (n != -1)
67233 @@ -182,7 +182,7 @@ static inline unsigned int cpumask_next(int n, const struct cpumask *srcp)
67234 *
67235 * Returns >= nr_cpu_ids if no further cpus unset.
67236 */
67237 -static inline unsigned int cpumask_next_zero(int n, const struct cpumask *srcp)
67238 +static inline unsigned int __intentional_overflow(-1) cpumask_next_zero(int n, const struct cpumask *srcp)
67239 {
67240 /* -1 is a legal arg here. */
67241 if (n != -1)
67242 @@ -190,7 +190,7 @@ static inline unsigned int cpumask_next_zero(int n, const struct cpumask *srcp)
67243 return find_next_zero_bit(cpumask_bits(srcp), nr_cpumask_bits, n+1);
67244 }
67245
67246 -int cpumask_next_and(int n, const struct cpumask *, const struct cpumask *);
67247 +int cpumask_next_and(int n, const struct cpumask *, const struct cpumask *) __intentional_overflow(-1);
67248 int cpumask_any_but(const struct cpumask *mask, unsigned int cpu);
67249
67250 /**
67251 diff --git a/include/linux/cred.h b/include/linux/cred.h
67252 index 04421e8..6bce4ef 100644
67253 --- a/include/linux/cred.h
67254 +++ b/include/linux/cred.h
67255 @@ -194,6 +194,9 @@ static inline void validate_creds_for_do_exit(struct task_struct *tsk)
67256 static inline void validate_process_creds(void)
67257 {
67258 }
67259 +static inline void validate_task_creds(struct task_struct *task)
67260 +{
67261 +}
67262 #endif
67263
67264 /**
67265 diff --git a/include/linux/crypto.h b/include/linux/crypto.h
67266 index b92eadf..b4ecdc1 100644
67267 --- a/include/linux/crypto.h
67268 +++ b/include/linux/crypto.h
67269 @@ -373,7 +373,7 @@ struct cipher_tfm {
67270 const u8 *key, unsigned int keylen);
67271 void (*cit_encrypt_one)(struct crypto_tfm *tfm, u8 *dst, const u8 *src);
67272 void (*cit_decrypt_one)(struct crypto_tfm *tfm, u8 *dst, const u8 *src);
67273 -};
67274 +} __no_const;
67275
67276 struct hash_tfm {
67277 int (*init)(struct hash_desc *desc);
67278 @@ -394,13 +394,13 @@ struct compress_tfm {
67279 int (*cot_decompress)(struct crypto_tfm *tfm,
67280 const u8 *src, unsigned int slen,
67281 u8 *dst, unsigned int *dlen);
67282 -};
67283 +} __no_const;
67284
67285 struct rng_tfm {
67286 int (*rng_gen_random)(struct crypto_rng *tfm, u8 *rdata,
67287 unsigned int dlen);
67288 int (*rng_reset)(struct crypto_rng *tfm, u8 *seed, unsigned int slen);
67289 -};
67290 +} __no_const;
67291
67292 #define crt_ablkcipher crt_u.ablkcipher
67293 #define crt_aead crt_u.aead
67294 diff --git a/include/linux/ctype.h b/include/linux/ctype.h
67295 index 8acfe31..6ffccd63 100644
67296 --- a/include/linux/ctype.h
67297 +++ b/include/linux/ctype.h
67298 @@ -56,7 +56,7 @@ static inline unsigned char __toupper(unsigned char c)
67299 * Fast implementation of tolower() for internal usage. Do not use in your
67300 * code.
67301 */
67302 -static inline char _tolower(const char c)
67303 +static inline unsigned char _tolower(const unsigned char c)
67304 {
67305 return c | 0x20;
67306 }
67307 diff --git a/include/linux/decompress/mm.h b/include/linux/decompress/mm.h
67308 index 7925bf0..d5143d2 100644
67309 --- a/include/linux/decompress/mm.h
67310 +++ b/include/linux/decompress/mm.h
67311 @@ -77,7 +77,7 @@ static void free(void *where)
67312 * warnings when not needed (indeed large_malloc / large_free are not
67313 * needed by inflate */
67314
67315 -#define malloc(a) kmalloc(a, GFP_KERNEL)
67316 +#define malloc(a) kmalloc((a), GFP_KERNEL)
67317 #define free(a) kfree(a)
67318
67319 #define large_malloc(a) vmalloc(a)
67320 diff --git a/include/linux/devfreq.h b/include/linux/devfreq.h
67321 index e83ef39..33e0eb3 100644
67322 --- a/include/linux/devfreq.h
67323 +++ b/include/linux/devfreq.h
67324 @@ -114,7 +114,7 @@ struct devfreq_governor {
67325 int (*get_target_freq)(struct devfreq *this, unsigned long *freq);
67326 int (*event_handler)(struct devfreq *devfreq,
67327 unsigned int event, void *data);
67328 -};
67329 +} __do_const;
67330
67331 /**
67332 * struct devfreq - Device devfreq structure
67333 diff --git a/include/linux/device.h b/include/linux/device.h
67334 index 43dcda9..7a1fb65 100644
67335 --- a/include/linux/device.h
67336 +++ b/include/linux/device.h
67337 @@ -294,7 +294,7 @@ struct subsys_interface {
67338 struct list_head node;
67339 int (*add_dev)(struct device *dev, struct subsys_interface *sif);
67340 int (*remove_dev)(struct device *dev, struct subsys_interface *sif);
67341 -};
67342 +} __do_const;
67343
67344 int subsys_interface_register(struct subsys_interface *sif);
67345 void subsys_interface_unregister(struct subsys_interface *sif);
67346 @@ -474,7 +474,7 @@ struct device_type {
67347 void (*release)(struct device *dev);
67348
67349 const struct dev_pm_ops *pm;
67350 -};
67351 +} __do_const;
67352
67353 /* interface for exporting device attributes */
67354 struct device_attribute {
67355 @@ -484,11 +484,12 @@ struct device_attribute {
67356 ssize_t (*store)(struct device *dev, struct device_attribute *attr,
67357 const char *buf, size_t count);
67358 };
67359 +typedef struct device_attribute __no_const device_attribute_no_const;
67360
67361 struct dev_ext_attribute {
67362 struct device_attribute attr;
67363 void *var;
67364 -};
67365 +} __do_const;
67366
67367 ssize_t device_show_ulong(struct device *dev, struct device_attribute *attr,
67368 char *buf);
67369 diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h
67370 index 94af418..b1ca7a2 100644
67371 --- a/include/linux/dma-mapping.h
67372 +++ b/include/linux/dma-mapping.h
67373 @@ -54,7 +54,7 @@ struct dma_map_ops {
67374 u64 (*get_required_mask)(struct device *dev);
67375 #endif
67376 int is_phys;
67377 -};
67378 +} __do_const;
67379
67380 #define DMA_BIT_MASK(n) (((n) == 64) ? ~0ULL : ((1ULL<<(n))-1))
67381
67382 diff --git a/include/linux/dmaengine.h b/include/linux/dmaengine.h
67383 index d3201e4..8281e63 100644
67384 --- a/include/linux/dmaengine.h
67385 +++ b/include/linux/dmaengine.h
67386 @@ -1018,9 +1018,9 @@ struct dma_pinned_list {
67387 struct dma_pinned_list *dma_pin_iovec_pages(struct iovec *iov, size_t len);
67388 void dma_unpin_iovec_pages(struct dma_pinned_list* pinned_list);
67389
67390 -dma_cookie_t dma_memcpy_to_iovec(struct dma_chan *chan, struct iovec *iov,
67391 +dma_cookie_t __intentional_overflow(0) dma_memcpy_to_iovec(struct dma_chan *chan, struct iovec *iov,
67392 struct dma_pinned_list *pinned_list, unsigned char *kdata, size_t len);
67393 -dma_cookie_t dma_memcpy_pg_to_iovec(struct dma_chan *chan, struct iovec *iov,
67394 +dma_cookie_t __intentional_overflow(0) dma_memcpy_pg_to_iovec(struct dma_chan *chan, struct iovec *iov,
67395 struct dma_pinned_list *pinned_list, struct page *page,
67396 unsigned int offset, size_t len);
67397
67398 diff --git a/include/linux/efi.h b/include/linux/efi.h
67399 index 7a9498a..155713d 100644
67400 --- a/include/linux/efi.h
67401 +++ b/include/linux/efi.h
67402 @@ -733,6 +733,7 @@ struct efivar_operations {
67403 efi_set_variable_t *set_variable;
67404 efi_query_variable_info_t *query_variable_info;
67405 };
67406 +typedef struct efivar_operations __no_const efivar_operations_no_const;
67407
67408 struct efivars {
67409 /*
67410 diff --git a/include/linux/elf.h b/include/linux/elf.h
67411 index 8c9048e..16a4665 100644
67412 --- a/include/linux/elf.h
67413 +++ b/include/linux/elf.h
67414 @@ -20,6 +20,7 @@ extern Elf32_Dyn _DYNAMIC [];
67415 #define elf_note elf32_note
67416 #define elf_addr_t Elf32_Off
67417 #define Elf_Half Elf32_Half
67418 +#define elf_dyn Elf32_Dyn
67419
67420 #else
67421
67422 @@ -30,6 +31,7 @@ extern Elf64_Dyn _DYNAMIC [];
67423 #define elf_note elf64_note
67424 #define elf_addr_t Elf64_Off
67425 #define Elf_Half Elf64_Half
67426 +#define elf_dyn Elf64_Dyn
67427
67428 #endif
67429
67430 diff --git a/include/linux/err.h b/include/linux/err.h
67431 index f2edce2..cc2082c 100644
67432 --- a/include/linux/err.h
67433 +++ b/include/linux/err.h
67434 @@ -19,12 +19,12 @@
67435
67436 #define IS_ERR_VALUE(x) unlikely((x) >= (unsigned long)-MAX_ERRNO)
67437
67438 -static inline void * __must_check ERR_PTR(long error)
67439 +static inline void * __must_check __intentional_overflow(-1) ERR_PTR(long error)
67440 {
67441 return (void *) error;
67442 }
67443
67444 -static inline long __must_check PTR_ERR(const void *ptr)
67445 +static inline long __must_check __intentional_overflow(-1) PTR_ERR(const void *ptr)
67446 {
67447 return (long) ptr;
67448 }
67449 diff --git a/include/linux/extcon.h b/include/linux/extcon.h
67450 index fcb51c8..bdafcf6 100644
67451 --- a/include/linux/extcon.h
67452 +++ b/include/linux/extcon.h
67453 @@ -134,7 +134,7 @@ struct extcon_dev {
67454 /* /sys/class/extcon/.../mutually_exclusive/... */
67455 struct attribute_group attr_g_muex;
67456 struct attribute **attrs_muex;
67457 - struct device_attribute *d_attrs_muex;
67458 + device_attribute_no_const *d_attrs_muex;
67459 };
67460
67461 /**
67462 diff --git a/include/linux/fb.h b/include/linux/fb.h
67463 index c7a9571..02eeffe 100644
67464 --- a/include/linux/fb.h
67465 +++ b/include/linux/fb.h
67466 @@ -302,7 +302,7 @@ struct fb_ops {
67467 /* called at KDB enter and leave time to prepare the console */
67468 int (*fb_debug_enter)(struct fb_info *info);
67469 int (*fb_debug_leave)(struct fb_info *info);
67470 -};
67471 +} __do_const;
67472
67473 #ifdef CONFIG_FB_TILEBLITTING
67474 #define FB_TILE_CURSOR_NONE 0
67475 diff --git a/include/linux/filter.h b/include/linux/filter.h
67476 index c45eabc..baa0be5 100644
67477 --- a/include/linux/filter.h
67478 +++ b/include/linux/filter.h
67479 @@ -20,6 +20,7 @@ struct compat_sock_fprog {
67480
67481 struct sk_buff;
67482 struct sock;
67483 +struct bpf_jit_work;
67484
67485 struct sk_filter
67486 {
67487 @@ -27,6 +28,9 @@ struct sk_filter
67488 unsigned int len; /* Number of filter blocks */
67489 unsigned int (*bpf_func)(const struct sk_buff *skb,
67490 const struct sock_filter *filter);
67491 +#ifdef CONFIG_BPF_JIT
67492 + struct bpf_jit_work *work;
67493 +#endif
67494 struct rcu_head rcu;
67495 struct sock_filter insns[0];
67496 };
67497 diff --git a/include/linux/frontswap.h b/include/linux/frontswap.h
67498 index 3044254..9767f41 100644
67499 --- a/include/linux/frontswap.h
67500 +++ b/include/linux/frontswap.h
67501 @@ -11,7 +11,7 @@ struct frontswap_ops {
67502 int (*load)(unsigned, pgoff_t, struct page *);
67503 void (*invalidate_page)(unsigned, pgoff_t);
67504 void (*invalidate_area)(unsigned);
67505 -};
67506 +} __no_const;
67507
67508 extern bool frontswap_enabled;
67509 extern struct frontswap_ops
67510 diff --git a/include/linux/fs.h b/include/linux/fs.h
67511 index 7617ee0..b575199 100644
67512 --- a/include/linux/fs.h
67513 +++ b/include/linux/fs.h
67514 @@ -1541,7 +1541,8 @@ struct file_operations {
67515 long (*fallocate)(struct file *file, int mode, loff_t offset,
67516 loff_t len);
67517 int (*show_fdinfo)(struct seq_file *m, struct file *f);
67518 -};
67519 +} __do_const;
67520 +typedef struct file_operations __no_const file_operations_no_const;
67521
67522 struct inode_operations {
67523 struct dentry * (*lookup) (struct inode *,struct dentry *, unsigned int);
67524 @@ -2665,4 +2666,14 @@ static inline void inode_has_no_xattr(struct inode *inode)
67525 inode->i_flags |= S_NOSEC;
67526 }
67527
67528 +static inline bool is_sidechannel_device(const struct inode *inode)
67529 +{
67530 +#ifdef CONFIG_GRKERNSEC_DEVICE_SIDECHANNEL
67531 + umode_t mode = inode->i_mode;
67532 + return ((S_ISCHR(mode) || S_ISBLK(mode)) && (mode & (S_IROTH | S_IWOTH)));
67533 +#else
67534 + return false;
67535 +#endif
67536 +}
67537 +
67538 #endif /* _LINUX_FS_H */
67539 diff --git a/include/linux/fs_struct.h b/include/linux/fs_struct.h
67540 index d0ae3a8..0244b34 100644
67541 --- a/include/linux/fs_struct.h
67542 +++ b/include/linux/fs_struct.h
67543 @@ -6,7 +6,7 @@
67544 #include <linux/seqlock.h>
67545
67546 struct fs_struct {
67547 - int users;
67548 + atomic_t users;
67549 spinlock_t lock;
67550 seqcount_t seq;
67551 int umask;
67552 diff --git a/include/linux/fscache-cache.h b/include/linux/fscache-cache.h
67553 index 5dfa0aa..6acf322 100644
67554 --- a/include/linux/fscache-cache.h
67555 +++ b/include/linux/fscache-cache.h
67556 @@ -112,7 +112,7 @@ struct fscache_operation {
67557 fscache_operation_release_t release;
67558 };
67559
67560 -extern atomic_t fscache_op_debug_id;
67561 +extern atomic_unchecked_t fscache_op_debug_id;
67562 extern void fscache_op_work_func(struct work_struct *work);
67563
67564 extern void fscache_enqueue_operation(struct fscache_operation *);
67565 @@ -134,7 +134,7 @@ static inline void fscache_operation_init(struct fscache_operation *op,
67566 INIT_WORK(&op->work, fscache_op_work_func);
67567 atomic_set(&op->usage, 1);
67568 op->state = FSCACHE_OP_ST_INITIALISED;
67569 - op->debug_id = atomic_inc_return(&fscache_op_debug_id);
67570 + op->debug_id = atomic_inc_return_unchecked(&fscache_op_debug_id);
67571 op->processor = processor;
67572 op->release = release;
67573 INIT_LIST_HEAD(&op->pend_link);
67574 diff --git a/include/linux/fscache.h b/include/linux/fscache.h
67575 index 7a08623..4c07b0f 100644
67576 --- a/include/linux/fscache.h
67577 +++ b/include/linux/fscache.h
67578 @@ -152,7 +152,7 @@ struct fscache_cookie_def {
67579 * - this is mandatory for any object that may have data
67580 */
67581 void (*now_uncached)(void *cookie_netfs_data);
67582 -};
67583 +} __do_const;
67584
67585 /*
67586 * fscache cached network filesystem type
67587 diff --git a/include/linux/fsnotify.h b/include/linux/fsnotify.h
67588 index 0fbfb46..508eb0d 100644
67589 --- a/include/linux/fsnotify.h
67590 +++ b/include/linux/fsnotify.h
67591 @@ -195,6 +195,9 @@ static inline void fsnotify_access(struct file *file)
67592 struct inode *inode = path->dentry->d_inode;
67593 __u32 mask = FS_ACCESS;
67594
67595 + if (is_sidechannel_device(inode))
67596 + return;
67597 +
67598 if (S_ISDIR(inode->i_mode))
67599 mask |= FS_ISDIR;
67600
67601 @@ -213,6 +216,9 @@ static inline void fsnotify_modify(struct file *file)
67602 struct inode *inode = path->dentry->d_inode;
67603 __u32 mask = FS_MODIFY;
67604
67605 + if (is_sidechannel_device(inode))
67606 + return;
67607 +
67608 if (S_ISDIR(inode->i_mode))
67609 mask |= FS_ISDIR;
67610
67611 @@ -315,7 +321,7 @@ static inline void fsnotify_change(struct dentry *dentry, unsigned int ia_valid)
67612 */
67613 static inline const unsigned char *fsnotify_oldname_init(const unsigned char *name)
67614 {
67615 - return kstrdup(name, GFP_KERNEL);
67616 + return (const unsigned char *)kstrdup((const char *)name, GFP_KERNEL);
67617 }
67618
67619 /*
67620 diff --git a/include/linux/ftrace_event.h b/include/linux/ftrace_event.h
67621 index a3d4895..ddd2a50 100644
67622 --- a/include/linux/ftrace_event.h
67623 +++ b/include/linux/ftrace_event.h
67624 @@ -272,7 +272,7 @@ extern int trace_define_field(struct ftrace_event_call *call, const char *type,
67625 extern int trace_add_event_call(struct ftrace_event_call *call);
67626 extern void trace_remove_event_call(struct ftrace_event_call *call);
67627
67628 -#define is_signed_type(type) (((type)(-1)) < 0)
67629 +#define is_signed_type(type) (((type)(-1)) < (type)1)
67630
67631 int trace_set_clr_event(const char *system, const char *event, int set);
67632
67633 diff --git a/include/linux/genhd.h b/include/linux/genhd.h
67634 index 79b8bba..86b539e 100644
67635 --- a/include/linux/genhd.h
67636 +++ b/include/linux/genhd.h
67637 @@ -194,7 +194,7 @@ struct gendisk {
67638 struct kobject *slave_dir;
67639
67640 struct timer_rand_state *random;
67641 - atomic_t sync_io; /* RAID */
67642 + atomic_unchecked_t sync_io; /* RAID */
67643 struct disk_events *ev;
67644 #ifdef CONFIG_BLK_DEV_INTEGRITY
67645 struct blk_integrity *integrity;
67646 diff --git a/include/linux/genl_magic_func.h b/include/linux/genl_magic_func.h
67647 index 023bc34..b02b46a 100644
67648 --- a/include/linux/genl_magic_func.h
67649 +++ b/include/linux/genl_magic_func.h
67650 @@ -246,7 +246,7 @@ const char *CONCAT_(GENL_MAGIC_FAMILY, _genl_cmd_to_str)(__u8 cmd)
67651 },
67652
67653 #define ZZZ_genl_ops CONCAT_(GENL_MAGIC_FAMILY, _genl_ops)
67654 -static struct genl_ops ZZZ_genl_ops[] __read_mostly = {
67655 +static struct genl_ops ZZZ_genl_ops[] = {
67656 #include GENL_MAGIC_INCLUDE_FILE
67657 };
67658
67659 diff --git a/include/linux/gfp.h b/include/linux/gfp.h
67660 index 0f615eb..5c3832f 100644
67661 --- a/include/linux/gfp.h
67662 +++ b/include/linux/gfp.h
67663 @@ -35,6 +35,13 @@ struct vm_area_struct;
67664 #define ___GFP_NO_KSWAPD 0x400000u
67665 #define ___GFP_OTHER_NODE 0x800000u
67666 #define ___GFP_WRITE 0x1000000u
67667 +
67668 +#ifdef CONFIG_PAX_USERCOPY_SLABS
67669 +#define ___GFP_USERCOPY 0x2000000u
67670 +#else
67671 +#define ___GFP_USERCOPY 0
67672 +#endif
67673 +
67674 /* If the above are modified, __GFP_BITS_SHIFT may need updating */
67675
67676 /*
67677 @@ -92,6 +99,7 @@ struct vm_area_struct;
67678 #define __GFP_OTHER_NODE ((__force gfp_t)___GFP_OTHER_NODE) /* On behalf of other node */
67679 #define __GFP_KMEMCG ((__force gfp_t)___GFP_KMEMCG) /* Allocation comes from a memcg-accounted resource */
67680 #define __GFP_WRITE ((__force gfp_t)___GFP_WRITE) /* Allocator intends to dirty page */
67681 +#define __GFP_USERCOPY ((__force gfp_t)___GFP_USERCOPY)/* Allocator intends to copy page to/from userland */
67682
67683 /*
67684 * This may seem redundant, but it's a way of annotating false positives vs.
67685 @@ -99,7 +107,7 @@ struct vm_area_struct;
67686 */
67687 #define __GFP_NOTRACK_FALSE_POSITIVE (__GFP_NOTRACK)
67688
67689 -#define __GFP_BITS_SHIFT 25 /* Room for N __GFP_FOO bits */
67690 +#define __GFP_BITS_SHIFT 26 /* Room for N __GFP_FOO bits */
67691 #define __GFP_BITS_MASK ((__force gfp_t)((1 << __GFP_BITS_SHIFT) - 1))
67692
67693 /* This equals 0, but use constants in case they ever change */
67694 @@ -153,6 +161,8 @@ struct vm_area_struct;
67695 /* 4GB DMA on some platforms */
67696 #define GFP_DMA32 __GFP_DMA32
67697
67698 +#define GFP_USERCOPY __GFP_USERCOPY
67699 +
67700 /* Convert GFP flags to their corresponding migrate type */
67701 static inline int allocflags_to_migratetype(gfp_t gfp_flags)
67702 {
67703 diff --git a/include/linux/gracl.h b/include/linux/gracl.h
67704 new file mode 100644
67705 index 0000000..ebe6d72
67706 --- /dev/null
67707 +++ b/include/linux/gracl.h
67708 @@ -0,0 +1,319 @@
67709 +#ifndef GR_ACL_H
67710 +#define GR_ACL_H
67711 +
67712 +#include <linux/grdefs.h>
67713 +#include <linux/resource.h>
67714 +#include <linux/capability.h>
67715 +#include <linux/dcache.h>
67716 +#include <asm/resource.h>
67717 +
67718 +/* Major status information */
67719 +
67720 +#define GR_VERSION "grsecurity 2.9.1"
67721 +#define GRSECURITY_VERSION 0x2901
67722 +
67723 +enum {
67724 + GR_SHUTDOWN = 0,
67725 + GR_ENABLE = 1,
67726 + GR_SPROLE = 2,
67727 + GR_RELOAD = 3,
67728 + GR_SEGVMOD = 4,
67729 + GR_STATUS = 5,
67730 + GR_UNSPROLE = 6,
67731 + GR_PASSSET = 7,
67732 + GR_SPROLEPAM = 8,
67733 +};
67734 +
67735 +/* Password setup definitions
67736 + * kernel/grhash.c */
67737 +enum {
67738 + GR_PW_LEN = 128,
67739 + GR_SALT_LEN = 16,
67740 + GR_SHA_LEN = 32,
67741 +};
67742 +
67743 +enum {
67744 + GR_SPROLE_LEN = 64,
67745 +};
67746 +
67747 +enum {
67748 + GR_NO_GLOB = 0,
67749 + GR_REG_GLOB,
67750 + GR_CREATE_GLOB
67751 +};
67752 +
67753 +#define GR_NLIMITS 32
67754 +
67755 +/* Begin Data Structures */
67756 +
67757 +struct sprole_pw {
67758 + unsigned char *rolename;
67759 + unsigned char salt[GR_SALT_LEN];
67760 + unsigned char sum[GR_SHA_LEN]; /* 256-bit SHA hash of the password */
67761 +};
67762 +
67763 +struct name_entry {
67764 + __u32 key;
67765 + ino_t inode;
67766 + dev_t device;
67767 + char *name;
67768 + __u16 len;
67769 + __u8 deleted;
67770 + struct name_entry *prev;
67771 + struct name_entry *next;
67772 +};
67773 +
67774 +struct inodev_entry {
67775 + struct name_entry *nentry;
67776 + struct inodev_entry *prev;
67777 + struct inodev_entry *next;
67778 +};
67779 +
67780 +struct acl_role_db {
67781 + struct acl_role_label **r_hash;
67782 + __u32 r_size;
67783 +};
67784 +
67785 +struct inodev_db {
67786 + struct inodev_entry **i_hash;
67787 + __u32 i_size;
67788 +};
67789 +
67790 +struct name_db {
67791 + struct name_entry **n_hash;
67792 + __u32 n_size;
67793 +};
67794 +
67795 +struct crash_uid {
67796 + uid_t uid;
67797 + unsigned long expires;
67798 +};
67799 +
67800 +struct gr_hash_struct {
67801 + void **table;
67802 + void **nametable;
67803 + void *first;
67804 + __u32 table_size;
67805 + __u32 used_size;
67806 + int type;
67807 +};
67808 +
67809 +/* Userspace Grsecurity ACL data structures */
67810 +
67811 +struct acl_subject_label {
67812 + char *filename;
67813 + ino_t inode;
67814 + dev_t device;
67815 + __u32 mode;
67816 + kernel_cap_t cap_mask;
67817 + kernel_cap_t cap_lower;
67818 + kernel_cap_t cap_invert_audit;
67819 +
67820 + struct rlimit res[GR_NLIMITS];
67821 + __u32 resmask;
67822 +
67823 + __u8 user_trans_type;
67824 + __u8 group_trans_type;
67825 + uid_t *user_transitions;
67826 + gid_t *group_transitions;
67827 + __u16 user_trans_num;
67828 + __u16 group_trans_num;
67829 +
67830 + __u32 sock_families[2];
67831 + __u32 ip_proto[8];
67832 + __u32 ip_type;
67833 + struct acl_ip_label **ips;
67834 + __u32 ip_num;
67835 + __u32 inaddr_any_override;
67836 +
67837 + __u32 crashes;
67838 + unsigned long expires;
67839 +
67840 + struct acl_subject_label *parent_subject;
67841 + struct gr_hash_struct *hash;
67842 + struct acl_subject_label *prev;
67843 + struct acl_subject_label *next;
67844 +
67845 + struct acl_object_label **obj_hash;
67846 + __u32 obj_hash_size;
67847 + __u16 pax_flags;
67848 +};
67849 +
67850 +struct role_allowed_ip {
67851 + __u32 addr;
67852 + __u32 netmask;
67853 +
67854 + struct role_allowed_ip *prev;
67855 + struct role_allowed_ip *next;
67856 +};
67857 +
67858 +struct role_transition {
67859 + char *rolename;
67860 +
67861 + struct role_transition *prev;
67862 + struct role_transition *next;
67863 +};
67864 +
67865 +struct acl_role_label {
67866 + char *rolename;
67867 + uid_t uidgid;
67868 + __u16 roletype;
67869 +
67870 + __u16 auth_attempts;
67871 + unsigned long expires;
67872 +
67873 + struct acl_subject_label *root_label;
67874 + struct gr_hash_struct *hash;
67875 +
67876 + struct acl_role_label *prev;
67877 + struct acl_role_label *next;
67878 +
67879 + struct role_transition *transitions;
67880 + struct role_allowed_ip *allowed_ips;
67881 + uid_t *domain_children;
67882 + __u16 domain_child_num;
67883 +
67884 + umode_t umask;
67885 +
67886 + struct acl_subject_label **subj_hash;
67887 + __u32 subj_hash_size;
67888 +};
67889 +
67890 +struct user_acl_role_db {
67891 + struct acl_role_label **r_table;
67892 + __u32 num_pointers; /* Number of allocations to track */
67893 + __u32 num_roles; /* Number of roles */
67894 + __u32 num_domain_children; /* Number of domain children */
67895 + __u32 num_subjects; /* Number of subjects */
67896 + __u32 num_objects; /* Number of objects */
67897 +};
67898 +
67899 +struct acl_object_label {
67900 + char *filename;
67901 + ino_t inode;
67902 + dev_t device;
67903 + __u32 mode;
67904 +
67905 + struct acl_subject_label *nested;
67906 + struct acl_object_label *globbed;
67907 +
67908 + /* next two structures not used */
67909 +
67910 + struct acl_object_label *prev;
67911 + struct acl_object_label *next;
67912 +};
67913 +
67914 +struct acl_ip_label {
67915 + char *iface;
67916 + __u32 addr;
67917 + __u32 netmask;
67918 + __u16 low, high;
67919 + __u8 mode;
67920 + __u32 type;
67921 + __u32 proto[8];
67922 +
67923 + /* next two structures not used */
67924 +
67925 + struct acl_ip_label *prev;
67926 + struct acl_ip_label *next;
67927 +};
67928 +
67929 +struct gr_arg {
67930 + struct user_acl_role_db role_db;
67931 + unsigned char pw[GR_PW_LEN];
67932 + unsigned char salt[GR_SALT_LEN];
67933 + unsigned char sum[GR_SHA_LEN];
67934 + unsigned char sp_role[GR_SPROLE_LEN];
67935 + struct sprole_pw *sprole_pws;
67936 + dev_t segv_device;
67937 + ino_t segv_inode;
67938 + uid_t segv_uid;
67939 + __u16 num_sprole_pws;
67940 + __u16 mode;
67941 +};
67942 +
67943 +struct gr_arg_wrapper {
67944 + struct gr_arg *arg;
67945 + __u32 version;
67946 + __u32 size;
67947 +};
67948 +
67949 +struct subject_map {
67950 + struct acl_subject_label *user;
67951 + struct acl_subject_label *kernel;
67952 + struct subject_map *prev;
67953 + struct subject_map *next;
67954 +};
67955 +
67956 +struct acl_subj_map_db {
67957 + struct subject_map **s_hash;
67958 + __u32 s_size;
67959 +};
67960 +
67961 +/* End Data Structures Section */
67962 +
67963 +/* Hash functions generated by empirical testing by Brad Spengler
67964 + Makes good use of the low bits of the inode. Generally 0-1 times
67965 + in loop for successful match. 0-3 for unsuccessful match.
67966 + Shift/add algorithm with modulus of table size and an XOR*/
67967 +
67968 +static __inline__ unsigned int
67969 +gr_rhash(const uid_t uid, const __u16 type, const unsigned int sz)
67970 +{
67971 + return ((((uid + type) << (16 + type)) ^ uid) % sz);
67972 +}
67973 +
67974 + static __inline__ unsigned int
67975 +gr_shash(const struct acl_subject_label *userp, const unsigned int sz)
67976 +{
67977 + return ((const unsigned long)userp % sz);
67978 +}
67979 +
67980 +static __inline__ unsigned int
67981 +gr_fhash(const ino_t ino, const dev_t dev, const unsigned int sz)
67982 +{
67983 + return (((ino + dev) ^ ((ino << 13) + (ino << 23) + (dev << 9))) % sz);
67984 +}
67985 +
67986 +static __inline__ unsigned int
67987 +gr_nhash(const char *name, const __u16 len, const unsigned int sz)
67988 +{
67989 + return full_name_hash((const unsigned char *)name, len) % sz;
67990 +}
67991 +
67992 +#define FOR_EACH_ROLE_START(role) \
67993 + role = role_list; \
67994 + while (role) {
67995 +
67996 +#define FOR_EACH_ROLE_END(role) \
67997 + role = role->prev; \
67998 + }
67999 +
68000 +#define FOR_EACH_SUBJECT_START(role,subj,iter) \
68001 + subj = NULL; \
68002 + iter = 0; \
68003 + while (iter < role->subj_hash_size) { \
68004 + if (subj == NULL) \
68005 + subj = role->subj_hash[iter]; \
68006 + if (subj == NULL) { \
68007 + iter++; \
68008 + continue; \
68009 + }
68010 +
68011 +#define FOR_EACH_SUBJECT_END(subj,iter) \
68012 + subj = subj->next; \
68013 + if (subj == NULL) \
68014 + iter++; \
68015 + }
68016 +
68017 +
68018 +#define FOR_EACH_NESTED_SUBJECT_START(role,subj) \
68019 + subj = role->hash->first; \
68020 + while (subj != NULL) {
68021 +
68022 +#define FOR_EACH_NESTED_SUBJECT_END(subj) \
68023 + subj = subj->next; \
68024 + }
68025 +
68026 +#endif
68027 +
68028 diff --git a/include/linux/gralloc.h b/include/linux/gralloc.h
68029 new file mode 100644
68030 index 0000000..323ecf2
68031 --- /dev/null
68032 +++ b/include/linux/gralloc.h
68033 @@ -0,0 +1,9 @@
68034 +#ifndef __GRALLOC_H
68035 +#define __GRALLOC_H
68036 +
68037 +void acl_free_all(void);
68038 +int acl_alloc_stack_init(unsigned long size);
68039 +void *acl_alloc(unsigned long len);
68040 +void *acl_alloc_num(unsigned long num, unsigned long len);
68041 +
68042 +#endif
68043 diff --git a/include/linux/grdefs.h b/include/linux/grdefs.h
68044 new file mode 100644
68045 index 0000000..be66033
68046 --- /dev/null
68047 +++ b/include/linux/grdefs.h
68048 @@ -0,0 +1,140 @@
68049 +#ifndef GRDEFS_H
68050 +#define GRDEFS_H
68051 +
68052 +/* Begin grsecurity status declarations */
68053 +
68054 +enum {
68055 + GR_READY = 0x01,
68056 + GR_STATUS_INIT = 0x00 // disabled state
68057 +};
68058 +
68059 +/* Begin ACL declarations */
68060 +
68061 +/* Role flags */
68062 +
68063 +enum {
68064 + GR_ROLE_USER = 0x0001,
68065 + GR_ROLE_GROUP = 0x0002,
68066 + GR_ROLE_DEFAULT = 0x0004,
68067 + GR_ROLE_SPECIAL = 0x0008,
68068 + GR_ROLE_AUTH = 0x0010,
68069 + GR_ROLE_NOPW = 0x0020,
68070 + GR_ROLE_GOD = 0x0040,
68071 + GR_ROLE_LEARN = 0x0080,
68072 + GR_ROLE_TPE = 0x0100,
68073 + GR_ROLE_DOMAIN = 0x0200,
68074 + GR_ROLE_PAM = 0x0400,
68075 + GR_ROLE_PERSIST = 0x0800
68076 +};
68077 +
68078 +/* ACL Subject and Object mode flags */
68079 +enum {
68080 + GR_DELETED = 0x80000000
68081 +};
68082 +
68083 +/* ACL Object-only mode flags */
68084 +enum {
68085 + GR_READ = 0x00000001,
68086 + GR_APPEND = 0x00000002,
68087 + GR_WRITE = 0x00000004,
68088 + GR_EXEC = 0x00000008,
68089 + GR_FIND = 0x00000010,
68090 + GR_INHERIT = 0x00000020,
68091 + GR_SETID = 0x00000040,
68092 + GR_CREATE = 0x00000080,
68093 + GR_DELETE = 0x00000100,
68094 + GR_LINK = 0x00000200,
68095 + GR_AUDIT_READ = 0x00000400,
68096 + GR_AUDIT_APPEND = 0x00000800,
68097 + GR_AUDIT_WRITE = 0x00001000,
68098 + GR_AUDIT_EXEC = 0x00002000,
68099 + GR_AUDIT_FIND = 0x00004000,
68100 + GR_AUDIT_INHERIT= 0x00008000,
68101 + GR_AUDIT_SETID = 0x00010000,
68102 + GR_AUDIT_CREATE = 0x00020000,
68103 + GR_AUDIT_DELETE = 0x00040000,
68104 + GR_AUDIT_LINK = 0x00080000,
68105 + GR_PTRACERD = 0x00100000,
68106 + GR_NOPTRACE = 0x00200000,
68107 + GR_SUPPRESS = 0x00400000,
68108 + GR_NOLEARN = 0x00800000,
68109 + GR_INIT_TRANSFER= 0x01000000
68110 +};
68111 +
68112 +#define GR_AUDITS (GR_AUDIT_READ | GR_AUDIT_WRITE | GR_AUDIT_APPEND | GR_AUDIT_EXEC | \
68113 + GR_AUDIT_FIND | GR_AUDIT_INHERIT | GR_AUDIT_SETID | \
68114 + GR_AUDIT_CREATE | GR_AUDIT_DELETE | GR_AUDIT_LINK)
68115 +
68116 +/* ACL subject-only mode flags */
68117 +enum {
68118 + GR_KILL = 0x00000001,
68119 + GR_VIEW = 0x00000002,
68120 + GR_PROTECTED = 0x00000004,
68121 + GR_LEARN = 0x00000008,
68122 + GR_OVERRIDE = 0x00000010,
68123 + /* just a placeholder, this mode is only used in userspace */
68124 + GR_DUMMY = 0x00000020,
68125 + GR_PROTSHM = 0x00000040,
68126 + GR_KILLPROC = 0x00000080,
68127 + GR_KILLIPPROC = 0x00000100,
68128 + /* just a placeholder, this mode is only used in userspace */
68129 + GR_NOTROJAN = 0x00000200,
68130 + GR_PROTPROCFD = 0x00000400,
68131 + GR_PROCACCT = 0x00000800,
68132 + GR_RELAXPTRACE = 0x00001000,
68133 + //GR_NESTED = 0x00002000,
68134 + GR_INHERITLEARN = 0x00004000,
68135 + GR_PROCFIND = 0x00008000,
68136 + GR_POVERRIDE = 0x00010000,
68137 + GR_KERNELAUTH = 0x00020000,
68138 + GR_ATSECURE = 0x00040000,
68139 + GR_SHMEXEC = 0x00080000
68140 +};
68141 +
68142 +enum {
68143 + GR_PAX_ENABLE_SEGMEXEC = 0x0001,
68144 + GR_PAX_ENABLE_PAGEEXEC = 0x0002,
68145 + GR_PAX_ENABLE_MPROTECT = 0x0004,
68146 + GR_PAX_ENABLE_RANDMMAP = 0x0008,
68147 + GR_PAX_ENABLE_EMUTRAMP = 0x0010,
68148 + GR_PAX_DISABLE_SEGMEXEC = 0x0100,
68149 + GR_PAX_DISABLE_PAGEEXEC = 0x0200,
68150 + GR_PAX_DISABLE_MPROTECT = 0x0400,
68151 + GR_PAX_DISABLE_RANDMMAP = 0x0800,
68152 + GR_PAX_DISABLE_EMUTRAMP = 0x1000,
68153 +};
68154 +
68155 +enum {
68156 + GR_ID_USER = 0x01,
68157 + GR_ID_GROUP = 0x02,
68158 +};
68159 +
68160 +enum {
68161 + GR_ID_ALLOW = 0x01,
68162 + GR_ID_DENY = 0x02,
68163 +};
68164 +
68165 +#define GR_CRASH_RES 31
68166 +#define GR_UIDTABLE_MAX 500
68167 +
68168 +/* begin resource learning section */
68169 +enum {
68170 + GR_RLIM_CPU_BUMP = 60,
68171 + GR_RLIM_FSIZE_BUMP = 50000,
68172 + GR_RLIM_DATA_BUMP = 10000,
68173 + GR_RLIM_STACK_BUMP = 1000,
68174 + GR_RLIM_CORE_BUMP = 10000,
68175 + GR_RLIM_RSS_BUMP = 500000,
68176 + GR_RLIM_NPROC_BUMP = 1,
68177 + GR_RLIM_NOFILE_BUMP = 5,
68178 + GR_RLIM_MEMLOCK_BUMP = 50000,
68179 + GR_RLIM_AS_BUMP = 500000,
68180 + GR_RLIM_LOCKS_BUMP = 2,
68181 + GR_RLIM_SIGPENDING_BUMP = 5,
68182 + GR_RLIM_MSGQUEUE_BUMP = 10000,
68183 + GR_RLIM_NICE_BUMP = 1,
68184 + GR_RLIM_RTPRIO_BUMP = 1,
68185 + GR_RLIM_RTTIME_BUMP = 1000000
68186 +};
68187 +
68188 +#endif
68189 diff --git a/include/linux/grinternal.h b/include/linux/grinternal.h
68190 new file mode 100644
68191 index 0000000..9bb6662
68192 --- /dev/null
68193 +++ b/include/linux/grinternal.h
68194 @@ -0,0 +1,215 @@
68195 +#ifndef __GRINTERNAL_H
68196 +#define __GRINTERNAL_H
68197 +
68198 +#ifdef CONFIG_GRKERNSEC
68199 +
68200 +#include <linux/fs.h>
68201 +#include <linux/mnt_namespace.h>
68202 +#include <linux/nsproxy.h>
68203 +#include <linux/gracl.h>
68204 +#include <linux/grdefs.h>
68205 +#include <linux/grmsg.h>
68206 +
68207 +void gr_add_learn_entry(const char *fmt, ...)
68208 + __attribute__ ((format (printf, 1, 2)));
68209 +__u32 gr_search_file(const struct dentry *dentry, const __u32 mode,
68210 + const struct vfsmount *mnt);
68211 +__u32 gr_check_create(const struct dentry *new_dentry,
68212 + const struct dentry *parent,
68213 + const struct vfsmount *mnt, const __u32 mode);
68214 +int gr_check_protected_task(const struct task_struct *task);
68215 +__u32 to_gr_audit(const __u32 reqmode);
68216 +int gr_set_acls(const int type);
68217 +int gr_apply_subject_to_task(struct task_struct *task);
68218 +int gr_acl_is_enabled(void);
68219 +char gr_roletype_to_char(void);
68220 +
68221 +void gr_handle_alertkill(struct task_struct *task);
68222 +char *gr_to_filename(const struct dentry *dentry,
68223 + const struct vfsmount *mnt);
68224 +char *gr_to_filename1(const struct dentry *dentry,
68225 + const struct vfsmount *mnt);
68226 +char *gr_to_filename2(const struct dentry *dentry,
68227 + const struct vfsmount *mnt);
68228 +char *gr_to_filename3(const struct dentry *dentry,
68229 + const struct vfsmount *mnt);
68230 +
68231 +extern int grsec_enable_ptrace_readexec;
68232 +extern int grsec_enable_harden_ptrace;
68233 +extern int grsec_enable_link;
68234 +extern int grsec_enable_fifo;
68235 +extern int grsec_enable_execve;
68236 +extern int grsec_enable_shm;
68237 +extern int grsec_enable_execlog;
68238 +extern int grsec_enable_signal;
68239 +extern int grsec_enable_audit_ptrace;
68240 +extern int grsec_enable_forkfail;
68241 +extern int grsec_enable_time;
68242 +extern int grsec_enable_rofs;
68243 +extern int grsec_enable_chroot_shmat;
68244 +extern int grsec_enable_chroot_mount;
68245 +extern int grsec_enable_chroot_double;
68246 +extern int grsec_enable_chroot_pivot;
68247 +extern int grsec_enable_chroot_chdir;
68248 +extern int grsec_enable_chroot_chmod;
68249 +extern int grsec_enable_chroot_mknod;
68250 +extern int grsec_enable_chroot_fchdir;
68251 +extern int grsec_enable_chroot_nice;
68252 +extern int grsec_enable_chroot_execlog;
68253 +extern int grsec_enable_chroot_caps;
68254 +extern int grsec_enable_chroot_sysctl;
68255 +extern int grsec_enable_chroot_unix;
68256 +extern int grsec_enable_symlinkown;
68257 +extern kgid_t grsec_symlinkown_gid;
68258 +extern int grsec_enable_tpe;
68259 +extern kgid_t grsec_tpe_gid;
68260 +extern int grsec_enable_tpe_all;
68261 +extern int grsec_enable_tpe_invert;
68262 +extern int grsec_enable_socket_all;
68263 +extern kgid_t grsec_socket_all_gid;
68264 +extern int grsec_enable_socket_client;
68265 +extern kgid_t grsec_socket_client_gid;
68266 +extern int grsec_enable_socket_server;
68267 +extern kgid_t grsec_socket_server_gid;
68268 +extern kgid_t grsec_audit_gid;
68269 +extern int grsec_enable_group;
68270 +extern int grsec_enable_audit_textrel;
68271 +extern int grsec_enable_log_rwxmaps;
68272 +extern int grsec_enable_mount;
68273 +extern int grsec_enable_chdir;
68274 +extern int grsec_resource_logging;
68275 +extern int grsec_enable_blackhole;
68276 +extern int grsec_lastack_retries;
68277 +extern int grsec_enable_brute;
68278 +extern int grsec_lock;
68279 +
68280 +extern spinlock_t grsec_alert_lock;
68281 +extern unsigned long grsec_alert_wtime;
68282 +extern unsigned long grsec_alert_fyet;
68283 +
68284 +extern spinlock_t grsec_audit_lock;
68285 +
68286 +extern rwlock_t grsec_exec_file_lock;
68287 +
68288 +#define gr_task_fullpath(tsk) ((tsk)->exec_file ? \
68289 + gr_to_filename2((tsk)->exec_file->f_path.dentry, \
68290 + (tsk)->exec_file->f_vfsmnt) : "/")
68291 +
68292 +#define gr_parent_task_fullpath(tsk) ((tsk)->real_parent->exec_file ? \
68293 + gr_to_filename3((tsk)->real_parent->exec_file->f_path.dentry, \
68294 + (tsk)->real_parent->exec_file->f_vfsmnt) : "/")
68295 +
68296 +#define gr_task_fullpath0(tsk) ((tsk)->exec_file ? \
68297 + gr_to_filename((tsk)->exec_file->f_path.dentry, \
68298 + (tsk)->exec_file->f_vfsmnt) : "/")
68299 +
68300 +#define gr_parent_task_fullpath0(tsk) ((tsk)->real_parent->exec_file ? \
68301 + gr_to_filename1((tsk)->real_parent->exec_file->f_path.dentry, \
68302 + (tsk)->real_parent->exec_file->f_vfsmnt) : "/")
68303 +
68304 +#define proc_is_chrooted(tsk_a) ((tsk_a)->gr_is_chrooted)
68305 +
68306 +#define have_same_root(tsk_a,tsk_b) ((tsk_a)->gr_chroot_dentry == (tsk_b)->gr_chroot_dentry)
68307 +
68308 +#define GR_CHROOT_CAPS {{ \
68309 + CAP_TO_MASK(CAP_LINUX_IMMUTABLE) | CAP_TO_MASK(CAP_NET_ADMIN) | \
68310 + CAP_TO_MASK(CAP_SYS_MODULE) | CAP_TO_MASK(CAP_SYS_RAWIO) | \
68311 + CAP_TO_MASK(CAP_SYS_PACCT) | CAP_TO_MASK(CAP_SYS_ADMIN) | \
68312 + CAP_TO_MASK(CAP_SYS_BOOT) | CAP_TO_MASK(CAP_SYS_TIME) | \
68313 + CAP_TO_MASK(CAP_NET_RAW) | CAP_TO_MASK(CAP_SYS_TTY_CONFIG) | \
68314 + CAP_TO_MASK(CAP_IPC_OWNER) | CAP_TO_MASK(CAP_SETFCAP), \
68315 + CAP_TO_MASK(CAP_SYSLOG) | CAP_TO_MASK(CAP_MAC_ADMIN) }}
68316 +
68317 +#define security_learn(normal_msg,args...) \
68318 +({ \
68319 + read_lock(&grsec_exec_file_lock); \
68320 + gr_add_learn_entry(normal_msg "\n", ## args); \
68321 + read_unlock(&grsec_exec_file_lock); \
68322 +})
68323 +
68324 +enum {
68325 + GR_DO_AUDIT,
68326 + GR_DONT_AUDIT,
68327 + /* used for non-audit messages that we shouldn't kill the task on */
68328 + GR_DONT_AUDIT_GOOD
68329 +};
68330 +
68331 +enum {
68332 + GR_TTYSNIFF,
68333 + GR_RBAC,
68334 + GR_RBAC_STR,
68335 + GR_STR_RBAC,
68336 + GR_RBAC_MODE2,
68337 + GR_RBAC_MODE3,
68338 + GR_FILENAME,
68339 + GR_SYSCTL_HIDDEN,
68340 + GR_NOARGS,
68341 + GR_ONE_INT,
68342 + GR_ONE_INT_TWO_STR,
68343 + GR_ONE_STR,
68344 + GR_STR_INT,
68345 + GR_TWO_STR_INT,
68346 + GR_TWO_INT,
68347 + GR_TWO_U64,
68348 + GR_THREE_INT,
68349 + GR_FIVE_INT_TWO_STR,
68350 + GR_TWO_STR,
68351 + GR_THREE_STR,
68352 + GR_FOUR_STR,
68353 + GR_STR_FILENAME,
68354 + GR_FILENAME_STR,
68355 + GR_FILENAME_TWO_INT,
68356 + GR_FILENAME_TWO_INT_STR,
68357 + GR_TEXTREL,
68358 + GR_PTRACE,
68359 + GR_RESOURCE,
68360 + GR_CAP,
68361 + GR_SIG,
68362 + GR_SIG2,
68363 + GR_CRASH1,
68364 + GR_CRASH2,
68365 + GR_PSACCT,
68366 + GR_RWXMAP
68367 +};
68368 +
68369 +#define gr_log_hidden_sysctl(audit, msg, str) gr_log_varargs(audit, msg, GR_SYSCTL_HIDDEN, str)
68370 +#define gr_log_ttysniff(audit, msg, task) gr_log_varargs(audit, msg, GR_TTYSNIFF, task)
68371 +#define gr_log_fs_rbac_generic(audit, msg, dentry, mnt) gr_log_varargs(audit, msg, GR_RBAC, dentry, mnt)
68372 +#define gr_log_fs_rbac_str(audit, msg, dentry, mnt, str) gr_log_varargs(audit, msg, GR_RBAC_STR, dentry, mnt, str)
68373 +#define gr_log_fs_str_rbac(audit, msg, str, dentry, mnt) gr_log_varargs(audit, msg, GR_STR_RBAC, str, dentry, mnt)
68374 +#define gr_log_fs_rbac_mode2(audit, msg, dentry, mnt, str1, str2) gr_log_varargs(audit, msg, GR_RBAC_MODE2, dentry, mnt, str1, str2)
68375 +#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)
68376 +#define gr_log_fs_generic(audit, msg, dentry, mnt) gr_log_varargs(audit, msg, GR_FILENAME, dentry, mnt)
68377 +#define gr_log_noargs(audit, msg) gr_log_varargs(audit, msg, GR_NOARGS)
68378 +#define gr_log_int(audit, msg, num) gr_log_varargs(audit, msg, GR_ONE_INT, num)
68379 +#define gr_log_int_str2(audit, msg, num, str1, str2) gr_log_varargs(audit, msg, GR_ONE_INT_TWO_STR, num, str1, str2)
68380 +#define gr_log_str(audit, msg, str) gr_log_varargs(audit, msg, GR_ONE_STR, str)
68381 +#define gr_log_str_int(audit, msg, str, num) gr_log_varargs(audit, msg, GR_STR_INT, str, num)
68382 +#define gr_log_int_int(audit, msg, num1, num2) gr_log_varargs(audit, msg, GR_TWO_INT, num1, num2)
68383 +#define gr_log_two_u64(audit, msg, num1, num2) gr_log_varargs(audit, msg, GR_TWO_U64, num1, num2)
68384 +#define gr_log_int3(audit, msg, num1, num2, num3) gr_log_varargs(audit, msg, GR_THREE_INT, num1, num2, num3)
68385 +#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)
68386 +#define gr_log_str_str(audit, msg, str1, str2) gr_log_varargs(audit, msg, GR_TWO_STR, str1, str2)
68387 +#define gr_log_str2_int(audit, msg, str1, str2, num) gr_log_varargs(audit, msg, GR_TWO_STR_INT, str1, str2, num)
68388 +#define gr_log_str3(audit, msg, str1, str2, str3) gr_log_varargs(audit, msg, GR_THREE_STR, str1, str2, str3)
68389 +#define gr_log_str4(audit, msg, str1, str2, str3, str4) gr_log_varargs(audit, msg, GR_FOUR_STR, str1, str2, str3, str4)
68390 +#define gr_log_str_fs(audit, msg, str, dentry, mnt) gr_log_varargs(audit, msg, GR_STR_FILENAME, str, dentry, mnt)
68391 +#define gr_log_fs_str(audit, msg, dentry, mnt, str) gr_log_varargs(audit, msg, GR_FILENAME_STR, dentry, mnt, str)
68392 +#define gr_log_fs_int2(audit, msg, dentry, mnt, num1, num2) gr_log_varargs(audit, msg, GR_FILENAME_TWO_INT, dentry, mnt, num1, num2)
68393 +#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)
68394 +#define gr_log_textrel_ulong_ulong(audit, msg, file, ulong1, ulong2) gr_log_varargs(audit, msg, GR_TEXTREL, file, ulong1, ulong2)
68395 +#define gr_log_ptrace(audit, msg, task) gr_log_varargs(audit, msg, GR_PTRACE, task)
68396 +#define gr_log_res_ulong2_str(audit, msg, task, ulong1, str, ulong2) gr_log_varargs(audit, msg, GR_RESOURCE, task, ulong1, str, ulong2)
68397 +#define gr_log_cap(audit, msg, task, str) gr_log_varargs(audit, msg, GR_CAP, task, str)
68398 +#define gr_log_sig_addr(audit, msg, str, addr) gr_log_varargs(audit, msg, GR_SIG, str, addr)
68399 +#define gr_log_sig_task(audit, msg, task, num) gr_log_varargs(audit, msg, GR_SIG2, task, num)
68400 +#define gr_log_crash1(audit, msg, task, ulong) gr_log_varargs(audit, msg, GR_CRASH1, task, ulong)
68401 +#define gr_log_crash2(audit, msg, task, ulong1) gr_log_varargs(audit, msg, GR_CRASH2, task, ulong1)
68402 +#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)
68403 +#define gr_log_rwxmap(audit, msg, str) gr_log_varargs(audit, msg, GR_RWXMAP, str)
68404 +
68405 +void gr_log_varargs(int audit, const char *msg, int argtypes, ...);
68406 +
68407 +#endif
68408 +
68409 +#endif
68410 diff --git a/include/linux/grmsg.h b/include/linux/grmsg.h
68411 new file mode 100644
68412 index 0000000..2bd4c8d
68413 --- /dev/null
68414 +++ b/include/linux/grmsg.h
68415 @@ -0,0 +1,111 @@
68416 +#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"
68417 +#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"
68418 +#define GR_PTRACE_ACL_MSG "denied ptrace of %.950s(%.16s:%d) by "
68419 +#define GR_STOPMOD_MSG "denied modification of module state by "
68420 +#define GR_ROFS_BLOCKWRITE_MSG "denied write to block device %.950s by "
68421 +#define GR_ROFS_MOUNT_MSG "denied writable mount of %.950s by "
68422 +#define GR_IOPERM_MSG "denied use of ioperm() by "
68423 +#define GR_IOPL_MSG "denied use of iopl() by "
68424 +#define GR_SHMAT_ACL_MSG "denied attach of shared memory of UID %u, PID %d, ID %u by "
68425 +#define GR_UNIX_CHROOT_MSG "denied connect() to abstract AF_UNIX socket outside of chroot by "
68426 +#define GR_SHMAT_CHROOT_MSG "denied attach of shared memory outside of chroot by "
68427 +#define GR_MEM_READWRITE_MSG "denied access of range %Lx -> %Lx in /dev/mem by "
68428 +#define GR_SYMLINK_MSG "not following symlink %.950s owned by %d.%d by "
68429 +#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"
68430 +#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"
68431 +#define GR_HIDDEN_ACL_MSG "%s access to hidden file %.950s by "
68432 +#define GR_OPEN_ACL_MSG "%s open of %.950s for%s%s by "
68433 +#define GR_CREATE_ACL_MSG "%s create of %.950s for%s%s by "
68434 +#define GR_FIFO_MSG "denied writing FIFO %.950s of %d.%d by "
68435 +#define GR_MKNOD_CHROOT_MSG "denied mknod of %.950s from chroot by "
68436 +#define GR_MKNOD_ACL_MSG "%s mknod of %.950s by "
68437 +#define GR_UNIXCONNECT_ACL_MSG "%s connect() to the unix domain socket %.950s by "
68438 +#define GR_TTYSNIFF_ACL_MSG "terminal being sniffed by IP:%pI4 %.480s[%.16s:%d], parent %.480s[%.16s:%d] against "
68439 +#define GR_MKDIR_ACL_MSG "%s mkdir of %.950s by "
68440 +#define GR_RMDIR_ACL_MSG "%s rmdir of %.950s by "
68441 +#define GR_UNLINK_ACL_MSG "%s unlink of %.950s by "
68442 +#define GR_SYMLINK_ACL_MSG "%s symlink from %.480s to %.480s by "
68443 +#define GR_HARDLINK_MSG "denied hardlink of %.930s (owned by %d.%d) to %.30s for "
68444 +#define GR_LINK_ACL_MSG "%s link of %.480s to %.480s by "
68445 +#define GR_INHERIT_ACL_MSG "successful inherit of %.480s's ACL for %.480s by "
68446 +#define GR_RENAME_ACL_MSG "%s rename of %.480s to %.480s by "
68447 +#define GR_UNSAFESHARE_EXEC_ACL_MSG "denied exec with cloned fs of %.950s by "
68448 +#define GR_PTRACE_EXEC_ACL_MSG "denied ptrace of %.950s by "
68449 +#define GR_EXEC_ACL_MSG "%s execution of %.950s by "
68450 +#define GR_EXEC_TPE_MSG "denied untrusted exec (due to %.70s) of %.950s by "
68451 +#define GR_SEGVSTART_ACL_MSG "possible exploit bruteforcing on " DEFAULTSECMSG " banning uid %u from login for %lu seconds"
68452 +#define GR_SEGVNOSUID_ACL_MSG "possible exploit bruteforcing on " DEFAULTSECMSG " banning execution for %lu seconds"
68453 +#define GR_MOUNT_CHROOT_MSG "denied mount of %.256s as %.930s from chroot by "
68454 +#define GR_PIVOT_CHROOT_MSG "denied pivot_root from chroot by "
68455 +#define GR_TRUNCATE_ACL_MSG "%s truncate of %.950s by "
68456 +#define GR_ATIME_ACL_MSG "%s access time change of %.950s by "
68457 +#define GR_ACCESS_ACL_MSG "%s access of %.950s for%s%s%s by "
68458 +#define GR_CHROOT_CHROOT_MSG "denied double chroot to %.950s by "
68459 +#define GR_CHMOD_CHROOT_MSG "denied chmod +s of %.950s by "
68460 +#define GR_CHMOD_ACL_MSG "%s chmod of %.950s by "
68461 +#define GR_CHROOT_FCHDIR_MSG "denied fchdir outside of chroot to %.950s by "
68462 +#define GR_CHOWN_ACL_MSG "%s chown of %.950s by "
68463 +#define GR_SETXATTR_ACL_MSG "%s setting extended attributes of %.950s by "
68464 +#define GR_WRITLIB_ACL_MSG "denied load of writable library %.950s by "
68465 +#define GR_INITF_ACL_MSG "init_variables() failed %s by "
68466 +#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"
68467 +#define GR_DEV_ACL_MSG "/dev/grsec: %d bytes sent %d required, being fed garbage by "
68468 +#define GR_SHUTS_ACL_MSG "shutdown auth success for "
68469 +#define GR_SHUTF_ACL_MSG "shutdown auth failure for "
68470 +#define GR_SHUTI_ACL_MSG "ignoring shutdown for disabled RBAC system for "
68471 +#define GR_SEGVMODS_ACL_MSG "segvmod auth success for "
68472 +#define GR_SEGVMODF_ACL_MSG "segvmod auth failure for "
68473 +#define GR_SEGVMODI_ACL_MSG "ignoring segvmod for disabled RBAC system for "
68474 +#define GR_ENABLE_ACL_MSG "%s RBAC system loaded by "
68475 +#define GR_ENABLEF_ACL_MSG "unable to load %s for "
68476 +#define GR_RELOADI_ACL_MSG "ignoring reload request for disabled RBAC system"
68477 +#define GR_RELOAD_ACL_MSG "%s RBAC system reloaded by "
68478 +#define GR_RELOADF_ACL_MSG "failed reload of %s for "
68479 +#define GR_SPROLEI_ACL_MSG "ignoring change to special role for disabled RBAC system for "
68480 +#define GR_SPROLES_ACL_MSG "successful change to special role %s (id %d) by "
68481 +#define GR_SPROLEL_ACL_MSG "special role %s (id %d) exited by "
68482 +#define GR_SPROLEF_ACL_MSG "special role %s failure for "
68483 +#define GR_UNSPROLEI_ACL_MSG "ignoring unauth of special role for disabled RBAC system for "
68484 +#define GR_UNSPROLES_ACL_MSG "successful unauth of special role %s (id %d) by "
68485 +#define GR_INVMODE_ACL_MSG "invalid mode %d by "
68486 +#define GR_PRIORITY_CHROOT_MSG "denied priority change of process (%.16s:%d) by "
68487 +#define GR_FAILFORK_MSG "failed fork with errno %s by "
68488 +#define GR_NICE_CHROOT_MSG "denied priority change by "
68489 +#define GR_UNISIGLOG_MSG "%.32s occurred at %p in "
68490 +#define GR_DUALSIGLOG_MSG "signal %d sent to " DEFAULTSECMSG " by "
68491 +#define GR_SIG_ACL_MSG "denied send of signal %d to protected task " DEFAULTSECMSG " by "
68492 +#define GR_SYSCTL_MSG "denied modification of grsecurity sysctl value : %.32s by "
68493 +#define GR_SYSCTL_ACL_MSG "%s sysctl of %.950s for%s%s by "
68494 +#define GR_TIME_MSG "time set by "
68495 +#define GR_DEFACL_MSG "fatal: unable to find subject for (%.16s:%d), loaded by "
68496 +#define GR_MMAP_ACL_MSG "%s executable mmap of %.950s by "
68497 +#define GR_MPROTECT_ACL_MSG "%s executable mprotect of %.950s by "
68498 +#define GR_SOCK_MSG "denied socket(%.16s,%.16s,%.16s) by "
68499 +#define GR_SOCK_NOINET_MSG "denied socket(%.16s,%.16s,%d) by "
68500 +#define GR_BIND_MSG "denied bind() by "
68501 +#define GR_CONNECT_MSG "denied connect() by "
68502 +#define GR_BIND_ACL_MSG "denied bind() to %pI4 port %u sock type %.16s protocol %.16s by "
68503 +#define GR_CONNECT_ACL_MSG "denied connect() to %pI4 port %u sock type %.16s protocol %.16s by "
68504 +#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"
68505 +#define GR_EXEC_CHROOT_MSG "exec of %.980s within chroot by process "
68506 +#define GR_CAP_ACL_MSG "use of %s denied for "
68507 +#define GR_CAP_CHROOT_MSG "use of %s in chroot denied for "
68508 +#define GR_CAP_ACL_MSG2 "use of %s permitted for "
68509 +#define GR_USRCHANGE_ACL_MSG "change to uid %u denied for "
68510 +#define GR_GRPCHANGE_ACL_MSG "change to gid %u denied for "
68511 +#define GR_REMOUNT_AUDIT_MSG "remount of %.256s by "
68512 +#define GR_UNMOUNT_AUDIT_MSG "unmount of %.256s by "
68513 +#define GR_MOUNT_AUDIT_MSG "mount of %.256s to %.256s by "
68514 +#define GR_CHDIR_AUDIT_MSG "chdir to %.980s by "
68515 +#define GR_EXEC_AUDIT_MSG "exec of %.930s (%.128s) by "
68516 +#define GR_RESOURCE_MSG "denied resource overstep by requesting %lu for %.16s against limit %lu for "
68517 +#define GR_RWXMMAP_MSG "denied RWX mmap of %.950s by "
68518 +#define GR_RWXMPROTECT_MSG "denied RWX mprotect of %.950s by "
68519 +#define GR_TEXTREL_AUDIT_MSG "text relocation in %s, VMA:0x%08lx 0x%08lx by "
68520 +#define GR_VM86_MSG "denied use of vm86 by "
68521 +#define GR_PTRACE_AUDIT_MSG "process %.950s(%.16s:%d) attached to via ptrace by "
68522 +#define GR_PTRACE_READEXEC_MSG "denied ptrace of unreadable binary %.950s by "
68523 +#define GR_INIT_TRANSFER_MSG "persistent special role transferred privilege to init by "
68524 +#define GR_BADPROCPID_MSG "denied read of sensitive /proc/pid/%s entry via fd passed across exec by "
68525 +#define GR_SYMLINKOWNER_MSG "denied following symlink %.950s since symlink owner %u does not match target owner %u, by "
68526 +#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 "
68527 diff --git a/include/linux/grsecurity.h b/include/linux/grsecurity.h
68528 new file mode 100644
68529 index 0000000..8da63a4
68530 --- /dev/null
68531 +++ b/include/linux/grsecurity.h
68532 @@ -0,0 +1,242 @@
68533 +#ifndef GR_SECURITY_H
68534 +#define GR_SECURITY_H
68535 +#include <linux/fs.h>
68536 +#include <linux/fs_struct.h>
68537 +#include <linux/binfmts.h>
68538 +#include <linux/gracl.h>
68539 +
68540 +/* notify of brain-dead configs */
68541 +#if defined(CONFIG_GRKERNSEC_PROC_USER) && defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
68542 +#error "CONFIG_GRKERNSEC_PROC_USER and CONFIG_GRKERNSEC_PROC_USERGROUP cannot both be enabled."
68543 +#endif
68544 +#if defined(CONFIG_PAX_NOEXEC) && !defined(CONFIG_PAX_PAGEEXEC) && !defined(CONFIG_PAX_SEGMEXEC) && !defined(CONFIG_PAX_KERNEXEC)
68545 +#error "CONFIG_PAX_NOEXEC enabled, but PAGEEXEC, SEGMEXEC, and KERNEXEC are disabled."
68546 +#endif
68547 +#if defined(CONFIG_PAX_ASLR) && !defined(CONFIG_PAX_RANDKSTACK) && !defined(CONFIG_PAX_RANDUSTACK) && !defined(CONFIG_PAX_RANDMMAP)
68548 +#error "CONFIG_PAX_ASLR enabled, but RANDKSTACK, RANDUSTACK, and RANDMMAP are disabled."
68549 +#endif
68550 +#if defined(CONFIG_PAX) && !defined(CONFIG_PAX_NOEXEC) && !defined(CONFIG_PAX_ASLR)
68551 +#error "CONFIG_PAX enabled, but no PaX options are enabled."
68552 +#endif
68553 +
68554 +void gr_handle_brute_attach(unsigned long mm_flags);
68555 +void gr_handle_brute_check(void);
68556 +void gr_handle_kernel_exploit(void);
68557 +int gr_process_user_ban(void);
68558 +
68559 +char gr_roletype_to_char(void);
68560 +
68561 +int gr_acl_enable_at_secure(void);
68562 +
68563 +int gr_check_user_change(kuid_t real, kuid_t effective, kuid_t fs);
68564 +int gr_check_group_change(kgid_t real, kgid_t effective, kgid_t fs);
68565 +
68566 +void gr_del_task_from_ip_table(struct task_struct *p);
68567 +
68568 +int gr_pid_is_chrooted(struct task_struct *p);
68569 +int gr_handle_chroot_fowner(struct pid *pid, enum pid_type type);
68570 +int gr_handle_chroot_nice(void);
68571 +int gr_handle_chroot_sysctl(const int op);
68572 +int gr_handle_chroot_setpriority(struct task_struct *p,
68573 + const int niceval);
68574 +int gr_chroot_fchdir(struct dentry *u_dentry, struct vfsmount *u_mnt);
68575 +int gr_handle_chroot_chroot(const struct dentry *dentry,
68576 + const struct vfsmount *mnt);
68577 +void gr_handle_chroot_chdir(struct path *path);
68578 +int gr_handle_chroot_chmod(const struct dentry *dentry,
68579 + const struct vfsmount *mnt, const int mode);
68580 +int gr_handle_chroot_mknod(const struct dentry *dentry,
68581 + const struct vfsmount *mnt, const int mode);
68582 +int gr_handle_chroot_mount(const struct dentry *dentry,
68583 + const struct vfsmount *mnt,
68584 + const char *dev_name);
68585 +int gr_handle_chroot_pivot(void);
68586 +int gr_handle_chroot_unix(const pid_t pid);
68587 +
68588 +int gr_handle_rawio(const struct inode *inode);
68589 +
68590 +void gr_handle_ioperm(void);
68591 +void gr_handle_iopl(void);
68592 +
68593 +umode_t gr_acl_umask(void);
68594 +
68595 +int gr_tpe_allow(const struct file *file);
68596 +
68597 +void gr_set_chroot_entries(struct task_struct *task, struct path *path);
68598 +void gr_clear_chroot_entries(struct task_struct *task);
68599 +
68600 +void gr_log_forkfail(const int retval);
68601 +void gr_log_timechange(void);
68602 +void gr_log_signal(const int sig, const void *addr, const struct task_struct *t);
68603 +void gr_log_chdir(const struct dentry *dentry,
68604 + const struct vfsmount *mnt);
68605 +void gr_log_chroot_exec(const struct dentry *dentry,
68606 + const struct vfsmount *mnt);
68607 +void gr_log_remount(const char *devname, const int retval);
68608 +void gr_log_unmount(const char *devname, const int retval);
68609 +void gr_log_mount(const char *from, const char *to, const int retval);
68610 +void gr_log_textrel(struct vm_area_struct *vma);
68611 +void gr_log_rwxmmap(struct file *file);
68612 +void gr_log_rwxmprotect(struct file *file);
68613 +
68614 +int gr_handle_follow_link(const struct inode *parent,
68615 + const struct inode *inode,
68616 + const struct dentry *dentry,
68617 + const struct vfsmount *mnt);
68618 +int gr_handle_fifo(const struct dentry *dentry,
68619 + const struct vfsmount *mnt,
68620 + const struct dentry *dir, const int flag,
68621 + const int acc_mode);
68622 +int gr_handle_hardlink(const struct dentry *dentry,
68623 + const struct vfsmount *mnt,
68624 + struct inode *inode,
68625 + const int mode, const struct filename *to);
68626 +
68627 +int gr_is_capable(const int cap);
68628 +int gr_is_capable_nolog(const int cap);
68629 +int gr_task_is_capable(const struct task_struct *task, const struct cred *cred, const int cap);
68630 +int gr_task_is_capable_nolog(const struct task_struct *task, const int cap);
68631 +
68632 +void gr_copy_label(struct task_struct *tsk);
68633 +void gr_handle_crash(struct task_struct *task, const int sig);
68634 +int gr_handle_signal(const struct task_struct *p, const int sig);
68635 +int gr_check_crash_uid(const kuid_t uid);
68636 +int gr_check_protected_task(const struct task_struct *task);
68637 +int gr_check_protected_task_fowner(struct pid *pid, enum pid_type type);
68638 +int gr_acl_handle_mmap(const struct file *file,
68639 + const unsigned long prot);
68640 +int gr_acl_handle_mprotect(const struct file *file,
68641 + const unsigned long prot);
68642 +int gr_check_hidden_task(const struct task_struct *tsk);
68643 +__u32 gr_acl_handle_truncate(const struct dentry *dentry,
68644 + const struct vfsmount *mnt);
68645 +__u32 gr_acl_handle_utime(const struct dentry *dentry,
68646 + const struct vfsmount *mnt);
68647 +__u32 gr_acl_handle_access(const struct dentry *dentry,
68648 + const struct vfsmount *mnt, const int fmode);
68649 +__u32 gr_acl_handle_chmod(const struct dentry *dentry,
68650 + const struct vfsmount *mnt, umode_t *mode);
68651 +__u32 gr_acl_handle_chown(const struct dentry *dentry,
68652 + const struct vfsmount *mnt);
68653 +__u32 gr_acl_handle_setxattr(const struct dentry *dentry,
68654 + const struct vfsmount *mnt);
68655 +int gr_handle_ptrace(struct task_struct *task, const long request);
68656 +int gr_handle_proc_ptrace(struct task_struct *task);
68657 +__u32 gr_acl_handle_execve(const struct dentry *dentry,
68658 + const struct vfsmount *mnt);
68659 +int gr_check_crash_exec(const struct file *filp);
68660 +int gr_acl_is_enabled(void);
68661 +void gr_set_kernel_label(struct task_struct *task);
68662 +void gr_set_role_label(struct task_struct *task, const kuid_t uid,
68663 + const kgid_t gid);
68664 +int gr_set_proc_label(const struct dentry *dentry,
68665 + const struct vfsmount *mnt,
68666 + const int unsafe_flags);
68667 +__u32 gr_acl_handle_hidden_file(const struct dentry *dentry,
68668 + const struct vfsmount *mnt);
68669 +__u32 gr_acl_handle_open(const struct dentry *dentry,
68670 + const struct vfsmount *mnt, int acc_mode);
68671 +__u32 gr_acl_handle_creat(const struct dentry *dentry,
68672 + const struct dentry *p_dentry,
68673 + const struct vfsmount *p_mnt,
68674 + int open_flags, int acc_mode, const int imode);
68675 +void gr_handle_create(const struct dentry *dentry,
68676 + const struct vfsmount *mnt);
68677 +void gr_handle_proc_create(const struct dentry *dentry,
68678 + const struct inode *inode);
68679 +__u32 gr_acl_handle_mknod(const struct dentry *new_dentry,
68680 + const struct dentry *parent_dentry,
68681 + const struct vfsmount *parent_mnt,
68682 + const int mode);
68683 +__u32 gr_acl_handle_mkdir(const struct dentry *new_dentry,
68684 + const struct dentry *parent_dentry,
68685 + const struct vfsmount *parent_mnt);
68686 +__u32 gr_acl_handle_rmdir(const struct dentry *dentry,
68687 + const struct vfsmount *mnt);
68688 +void gr_handle_delete(const ino_t ino, const dev_t dev);
68689 +__u32 gr_acl_handle_unlink(const struct dentry *dentry,
68690 + const struct vfsmount *mnt);
68691 +__u32 gr_acl_handle_symlink(const struct dentry *new_dentry,
68692 + const struct dentry *parent_dentry,
68693 + const struct vfsmount *parent_mnt,
68694 + const struct filename *from);
68695 +__u32 gr_acl_handle_link(const struct dentry *new_dentry,
68696 + const struct dentry *parent_dentry,
68697 + const struct vfsmount *parent_mnt,
68698 + const struct dentry *old_dentry,
68699 + const struct vfsmount *old_mnt, const struct filename *to);
68700 +int gr_handle_symlink_owner(const struct path *link, const struct inode *target);
68701 +int gr_acl_handle_rename(struct dentry *new_dentry,
68702 + struct dentry *parent_dentry,
68703 + const struct vfsmount *parent_mnt,
68704 + struct dentry *old_dentry,
68705 + struct inode *old_parent_inode,
68706 + struct vfsmount *old_mnt, const struct filename *newname);
68707 +void gr_handle_rename(struct inode *old_dir, struct inode *new_dir,
68708 + struct dentry *old_dentry,
68709 + struct dentry *new_dentry,
68710 + struct vfsmount *mnt, const __u8 replace);
68711 +__u32 gr_check_link(const struct dentry *new_dentry,
68712 + const struct dentry *parent_dentry,
68713 + const struct vfsmount *parent_mnt,
68714 + const struct dentry *old_dentry,
68715 + const struct vfsmount *old_mnt);
68716 +int gr_acl_handle_filldir(const struct file *file, const char *name,
68717 + const unsigned int namelen, const ino_t ino);
68718 +
68719 +__u32 gr_acl_handle_unix(const struct dentry *dentry,
68720 + const struct vfsmount *mnt);
68721 +void gr_acl_handle_exit(void);
68722 +void gr_acl_handle_psacct(struct task_struct *task, const long code);
68723 +int gr_acl_handle_procpidmem(const struct task_struct *task);
68724 +int gr_handle_rofs_mount(struct dentry *dentry, struct vfsmount *mnt, int mnt_flags);
68725 +int gr_handle_rofs_blockwrite(struct dentry *dentry, struct vfsmount *mnt, int acc_mode);
68726 +void gr_audit_ptrace(struct task_struct *task);
68727 +dev_t gr_get_dev_from_dentry(struct dentry *dentry);
68728 +void gr_put_exec_file(struct task_struct *task);
68729 +
68730 +int gr_ptrace_readexec(struct file *file, int unsafe_flags);
68731 +
68732 +#if defined(CONFIG_GRKERNSEC) && (defined(CONFIG_GRKERNSEC_RESLOG) || !defined(CONFIG_GRKERNSEC_NO_RBAC))
68733 +extern void gr_learn_resource(const struct task_struct *task, const int res,
68734 + const unsigned long wanted, const int gt);
68735 +#else
68736 +static inline void gr_learn_resource(const struct task_struct *task, const int res,
68737 + const unsigned long wanted, const int gt)
68738 +{
68739 +}
68740 +#endif
68741 +
68742 +#ifdef CONFIG_GRKERNSEC_RESLOG
68743 +extern void gr_log_resource(const struct task_struct *task, const int res,
68744 + const unsigned long wanted, const int gt);
68745 +#else
68746 +static inline void gr_log_resource(const struct task_struct *task, const int res,
68747 + const unsigned long wanted, const int gt)
68748 +{
68749 +}
68750 +#endif
68751 +
68752 +#ifdef CONFIG_GRKERNSEC
68753 +void task_grsec_rbac(struct seq_file *m, struct task_struct *p);
68754 +void gr_handle_vm86(void);
68755 +void gr_handle_mem_readwrite(u64 from, u64 to);
68756 +
68757 +void gr_log_badprocpid(const char *entry);
68758 +
68759 +extern int grsec_enable_dmesg;
68760 +extern int grsec_disable_privio;
68761 +
68762 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
68763 +extern kgid_t grsec_proc_gid;
68764 +#endif
68765 +
68766 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
68767 +extern int grsec_enable_chroot_findtask;
68768 +#endif
68769 +#ifdef CONFIG_GRKERNSEC_SETXID
68770 +extern int grsec_enable_setxid;
68771 +#endif
68772 +#endif
68773 +
68774 +#endif
68775 diff --git a/include/linux/grsock.h b/include/linux/grsock.h
68776 new file mode 100644
68777 index 0000000..e7ffaaf
68778 --- /dev/null
68779 +++ b/include/linux/grsock.h
68780 @@ -0,0 +1,19 @@
68781 +#ifndef __GRSOCK_H
68782 +#define __GRSOCK_H
68783 +
68784 +extern void gr_attach_curr_ip(const struct sock *sk);
68785 +extern int gr_handle_sock_all(const int family, const int type,
68786 + const int protocol);
68787 +extern int gr_handle_sock_server(const struct sockaddr *sck);
68788 +extern int gr_handle_sock_server_other(const struct sock *sck);
68789 +extern int gr_handle_sock_client(const struct sockaddr *sck);
68790 +extern int gr_search_connect(struct socket * sock,
68791 + struct sockaddr_in * addr);
68792 +extern int gr_search_bind(struct socket * sock,
68793 + struct sockaddr_in * addr);
68794 +extern int gr_search_listen(struct socket * sock);
68795 +extern int gr_search_accept(struct socket * sock);
68796 +extern int gr_search_socket(const int domain, const int type,
68797 + const int protocol);
68798 +
68799 +#endif
68800 diff --git a/include/linux/highmem.h b/include/linux/highmem.h
68801 index ef788b5..ac41b7b 100644
68802 --- a/include/linux/highmem.h
68803 +++ b/include/linux/highmem.h
68804 @@ -189,6 +189,18 @@ static inline void clear_highpage(struct page *page)
68805 kunmap_atomic(kaddr);
68806 }
68807
68808 +static inline void sanitize_highpage(struct page *page)
68809 +{
68810 + void *kaddr;
68811 + unsigned long flags;
68812 +
68813 + local_irq_save(flags);
68814 + kaddr = kmap_atomic(page);
68815 + clear_page(kaddr);
68816 + kunmap_atomic(kaddr);
68817 + local_irq_restore(flags);
68818 +}
68819 +
68820 static inline void zero_user_segments(struct page *page,
68821 unsigned start1, unsigned end1,
68822 unsigned start2, unsigned end2)
68823 diff --git a/include/linux/hwmon-sysfs.h b/include/linux/hwmon-sysfs.h
68824 index 1c7b89a..7f52502 100644
68825 --- a/include/linux/hwmon-sysfs.h
68826 +++ b/include/linux/hwmon-sysfs.h
68827 @@ -25,7 +25,8 @@
68828 struct sensor_device_attribute{
68829 struct device_attribute dev_attr;
68830 int index;
68831 -};
68832 +} __do_const;
68833 +typedef struct sensor_device_attribute __no_const sensor_device_attribute_no_const;
68834 #define to_sensor_dev_attr(_dev_attr) \
68835 container_of(_dev_attr, struct sensor_device_attribute, dev_attr)
68836
68837 @@ -41,7 +42,7 @@ struct sensor_device_attribute_2 {
68838 struct device_attribute dev_attr;
68839 u8 index;
68840 u8 nr;
68841 -};
68842 +} __do_const;
68843 #define to_sensor_dev_attr_2(_dev_attr) \
68844 container_of(_dev_attr, struct sensor_device_attribute_2, dev_attr)
68845
68846 diff --git a/include/linux/i2c.h b/include/linux/i2c.h
68847 index d0c4db7..61b3577 100644
68848 --- a/include/linux/i2c.h
68849 +++ b/include/linux/i2c.h
68850 @@ -369,6 +369,7 @@ struct i2c_algorithm {
68851 /* To determine what the adapter supports */
68852 u32 (*functionality) (struct i2c_adapter *);
68853 };
68854 +typedef struct i2c_algorithm __no_const i2c_algorithm_no_const;
68855
68856 /*
68857 * i2c_adapter is the structure used to identify a physical i2c bus along
68858 diff --git a/include/linux/i2o.h b/include/linux/i2o.h
68859 index d23c3c2..eb63c81 100644
68860 --- a/include/linux/i2o.h
68861 +++ b/include/linux/i2o.h
68862 @@ -565,7 +565,7 @@ struct i2o_controller {
68863 struct i2o_device *exec; /* Executive */
68864 #if BITS_PER_LONG == 64
68865 spinlock_t context_list_lock; /* lock for context_list */
68866 - atomic_t context_list_counter; /* needed for unique contexts */
68867 + atomic_unchecked_t context_list_counter; /* needed for unique contexts */
68868 struct list_head context_list; /* list of context id's
68869 and pointers */
68870 #endif
68871 diff --git a/include/linux/if_pppox.h b/include/linux/if_pppox.h
68872 index aff7ad8..3942bbd 100644
68873 --- a/include/linux/if_pppox.h
68874 +++ b/include/linux/if_pppox.h
68875 @@ -76,7 +76,7 @@ struct pppox_proto {
68876 int (*ioctl)(struct socket *sock, unsigned int cmd,
68877 unsigned long arg);
68878 struct module *owner;
68879 -};
68880 +} __do_const;
68881
68882 extern int register_pppox_proto(int proto_num, const struct pppox_proto *pp);
68883 extern void unregister_pppox_proto(int proto_num);
68884 diff --git a/include/linux/init.h b/include/linux/init.h
68885 index 10ed4f4..8e8490d 100644
68886 --- a/include/linux/init.h
68887 +++ b/include/linux/init.h
68888 @@ -39,9 +39,36 @@
68889 * Also note, that this data cannot be "const".
68890 */
68891
68892 +#ifdef MODULE
68893 +#define add_init_latent_entropy
68894 +#define add_devinit_latent_entropy
68895 +#define add_cpuinit_latent_entropy
68896 +#define add_meminit_latent_entropy
68897 +#else
68898 +#define add_init_latent_entropy __latent_entropy
68899 +
68900 +#ifdef CONFIG_HOTPLUG
68901 +#define add_devinit_latent_entropy
68902 +#else
68903 +#define add_devinit_latent_entropy __latent_entropy
68904 +#endif
68905 +
68906 +#ifdef CONFIG_HOTPLUG_CPU
68907 +#define add_cpuinit_latent_entropy
68908 +#else
68909 +#define add_cpuinit_latent_entropy __latent_entropy
68910 +#endif
68911 +
68912 +#ifdef CONFIG_MEMORY_HOTPLUG
68913 +#define add_meminit_latent_entropy
68914 +#else
68915 +#define add_meminit_latent_entropy __latent_entropy
68916 +#endif
68917 +#endif
68918 +
68919 /* These are for everybody (although not all archs will actually
68920 discard it in modules) */
68921 -#define __init __section(.init.text) __cold notrace
68922 +#define __init __section(.init.text) __cold notrace add_init_latent_entropy
68923 #define __initdata __section(.init.data)
68924 #define __initconst __constsection(.init.rodata)
68925 #define __exitdata __section(.exit.data)
68926 @@ -94,7 +121,7 @@
68927 #define __exit __section(.exit.text) __exitused __cold notrace
68928
68929 /* Used for HOTPLUG_CPU */
68930 -#define __cpuinit __section(.cpuinit.text) __cold notrace
68931 +#define __cpuinit __section(.cpuinit.text) __cold notrace add_cpuinit_latent_entropy
68932 #define __cpuinitdata __section(.cpuinit.data)
68933 #define __cpuinitconst __constsection(.cpuinit.rodata)
68934 #define __cpuexit __section(.cpuexit.text) __exitused __cold notrace
68935 @@ -102,7 +129,7 @@
68936 #define __cpuexitconst __constsection(.cpuexit.rodata)
68937
68938 /* Used for MEMORY_HOTPLUG */
68939 -#define __meminit __section(.meminit.text) __cold notrace
68940 +#define __meminit __section(.meminit.text) __cold notrace add_meminit_latent_entropy
68941 #define __meminitdata __section(.meminit.data)
68942 #define __meminitconst __constsection(.meminit.rodata)
68943 #define __memexit __section(.memexit.text) __exitused __cold notrace
68944 diff --git a/include/linux/init_task.h b/include/linux/init_task.h
68945 index 6d087c5..401cab8 100644
68946 --- a/include/linux/init_task.h
68947 +++ b/include/linux/init_task.h
68948 @@ -143,6 +143,12 @@ extern struct task_group root_task_group;
68949
68950 #define INIT_TASK_COMM "swapper"
68951
68952 +#ifdef CONFIG_X86
68953 +#define INIT_TASK_THREAD_INFO .tinfo = INIT_THREAD_INFO,
68954 +#else
68955 +#define INIT_TASK_THREAD_INFO
68956 +#endif
68957 +
68958 /*
68959 * INIT_TASK is used to set up the first task table, touch at
68960 * your own risk!. Base=0, limit=0x1fffff (=2MB)
68961 @@ -182,6 +188,7 @@ extern struct task_group root_task_group;
68962 RCU_POINTER_INITIALIZER(cred, &init_cred), \
68963 .comm = INIT_TASK_COMM, \
68964 .thread = INIT_THREAD, \
68965 + INIT_TASK_THREAD_INFO \
68966 .fs = &init_fs, \
68967 .files = &init_files, \
68968 .signal = &init_signals, \
68969 diff --git a/include/linux/interrupt.h b/include/linux/interrupt.h
68970 index 5fa5afe..ac55b25 100644
68971 --- a/include/linux/interrupt.h
68972 +++ b/include/linux/interrupt.h
68973 @@ -430,7 +430,7 @@ enum
68974 /* map softirq index to softirq name. update 'softirq_to_name' in
68975 * kernel/softirq.c when adding a new softirq.
68976 */
68977 -extern char *softirq_to_name[NR_SOFTIRQS];
68978 +extern const char * const softirq_to_name[NR_SOFTIRQS];
68979
68980 /* softirq mask and active fields moved to irq_cpustat_t in
68981 * asm/hardirq.h to get better cache usage. KAO
68982 @@ -438,12 +438,12 @@ extern char *softirq_to_name[NR_SOFTIRQS];
68983
68984 struct softirq_action
68985 {
68986 - void (*action)(struct softirq_action *);
68987 -};
68988 + void (*action)(void);
68989 +} __no_const;
68990
68991 asmlinkage void do_softirq(void);
68992 asmlinkage void __do_softirq(void);
68993 -extern void open_softirq(int nr, void (*action)(struct softirq_action *));
68994 +extern void open_softirq(int nr, void (*action)(void));
68995 extern void softirq_init(void);
68996 extern void __raise_softirq_irqoff(unsigned int nr);
68997
68998 diff --git a/include/linux/iommu.h b/include/linux/iommu.h
68999 index f3b99e1..9b73cee 100644
69000 --- a/include/linux/iommu.h
69001 +++ b/include/linux/iommu.h
69002 @@ -101,7 +101,7 @@ struct iommu_ops {
69003 int (*domain_set_attr)(struct iommu_domain *domain,
69004 enum iommu_attr attr, void *data);
69005 unsigned long pgsize_bitmap;
69006 -};
69007 +} __do_const;
69008
69009 #define IOMMU_GROUP_NOTIFY_ADD_DEVICE 1 /* Device added */
69010 #define IOMMU_GROUP_NOTIFY_DEL_DEVICE 2 /* Pre Device removed */
69011 diff --git a/include/linux/irq.h b/include/linux/irq.h
69012 index fdf2c4a..5332486 100644
69013 --- a/include/linux/irq.h
69014 +++ b/include/linux/irq.h
69015 @@ -328,7 +328,8 @@ struct irq_chip {
69016 void (*irq_print_chip)(struct irq_data *data, struct seq_file *p);
69017
69018 unsigned long flags;
69019 -};
69020 +} __do_const;
69021 +typedef struct irq_chip __no_const irq_chip_no_const;
69022
69023 /*
69024 * irq_chip specific flags
69025 diff --git a/include/linux/kallsyms.h b/include/linux/kallsyms.h
69026 index 6883e19..06992b1 100644
69027 --- a/include/linux/kallsyms.h
69028 +++ b/include/linux/kallsyms.h
69029 @@ -15,7 +15,8 @@
69030
69031 struct module;
69032
69033 -#ifdef CONFIG_KALLSYMS
69034 +#if !defined(__INCLUDED_BY_HIDESYM) || !defined(CONFIG_KALLSYMS)
69035 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
69036 /* Lookup the address for a symbol. Returns 0 if not found. */
69037 unsigned long kallsyms_lookup_name(const char *name);
69038
69039 @@ -106,6 +107,17 @@ static inline int lookup_symbol_attrs(unsigned long addr, unsigned long *size, u
69040 /* Stupid that this does nothing, but I didn't create this mess. */
69041 #define __print_symbol(fmt, addr)
69042 #endif /*CONFIG_KALLSYMS*/
69043 +#else /* when included by kallsyms.c, vsnprintf.c, or
69044 + arch/x86/kernel/dumpstack.c, with HIDESYM enabled */
69045 +extern void __print_symbol(const char *fmt, unsigned long address);
69046 +extern int sprint_backtrace(char *buffer, unsigned long address);
69047 +extern int sprint_symbol(char *buffer, unsigned long address);
69048 +extern int sprint_symbol_no_offset(char *buffer, unsigned long address);
69049 +const char *kallsyms_lookup(unsigned long addr,
69050 + unsigned long *symbolsize,
69051 + unsigned long *offset,
69052 + char **modname, char *namebuf);
69053 +#endif
69054
69055 /* This macro allows us to keep printk typechecking */
69056 static __printf(1, 2)
69057 diff --git a/include/linux/key-type.h b/include/linux/key-type.h
69058 index 518a53a..5e28358 100644
69059 --- a/include/linux/key-type.h
69060 +++ b/include/linux/key-type.h
69061 @@ -125,7 +125,7 @@ struct key_type {
69062 /* internal fields */
69063 struct list_head link; /* link in types list */
69064 struct lock_class_key lock_class; /* key->sem lock class */
69065 -};
69066 +} __do_const;
69067
69068 extern struct key_type key_type_keyring;
69069
69070 diff --git a/include/linux/kgdb.h b/include/linux/kgdb.h
69071 index 4dff0c6..1ca9b72 100644
69072 --- a/include/linux/kgdb.h
69073 +++ b/include/linux/kgdb.h
69074 @@ -53,7 +53,7 @@ extern int kgdb_connected;
69075 extern int kgdb_io_module_registered;
69076
69077 extern atomic_t kgdb_setting_breakpoint;
69078 -extern atomic_t kgdb_cpu_doing_single_step;
69079 +extern atomic_unchecked_t kgdb_cpu_doing_single_step;
69080
69081 extern struct task_struct *kgdb_usethread;
69082 extern struct task_struct *kgdb_contthread;
69083 @@ -255,7 +255,7 @@ struct kgdb_arch {
69084 void (*correct_hw_break)(void);
69085
69086 void (*enable_nmi)(bool on);
69087 -};
69088 +} __do_const;
69089
69090 /**
69091 * struct kgdb_io - Describe the interface for an I/O driver to talk with KGDB.
69092 @@ -280,7 +280,7 @@ struct kgdb_io {
69093 void (*pre_exception) (void);
69094 void (*post_exception) (void);
69095 int is_console;
69096 -};
69097 +} __do_const;
69098
69099 extern struct kgdb_arch arch_kgdb_ops;
69100
69101 diff --git a/include/linux/kmod.h b/include/linux/kmod.h
69102 index 5398d58..5883a34 100644
69103 --- a/include/linux/kmod.h
69104 +++ b/include/linux/kmod.h
69105 @@ -34,6 +34,8 @@ extern char modprobe_path[]; /* for sysctl */
69106 * usually useless though. */
69107 extern __printf(2, 3)
69108 int __request_module(bool wait, const char *name, ...);
69109 +extern __printf(3, 4)
69110 +int ___request_module(bool wait, char *param_name, const char *name, ...);
69111 #define request_module(mod...) __request_module(true, mod)
69112 #define request_module_nowait(mod...) __request_module(false, mod)
69113 #define try_then_request_module(x, mod...) \
69114 diff --git a/include/linux/kobject.h b/include/linux/kobject.h
69115 index 939b112..ed6ed51 100644
69116 --- a/include/linux/kobject.h
69117 +++ b/include/linux/kobject.h
69118 @@ -111,7 +111,7 @@ struct kobj_type {
69119 struct attribute **default_attrs;
69120 const struct kobj_ns_type_operations *(*child_ns_type)(struct kobject *kobj);
69121 const void *(*namespace)(struct kobject *kobj);
69122 -};
69123 +} __do_const;
69124
69125 struct kobj_uevent_env {
69126 char *envp[UEVENT_NUM_ENVP];
69127 @@ -134,6 +134,7 @@ struct kobj_attribute {
69128 ssize_t (*store)(struct kobject *kobj, struct kobj_attribute *attr,
69129 const char *buf, size_t count);
69130 };
69131 +typedef struct kobj_attribute __no_const kobj_attribute_no_const;
69132
69133 extern const struct sysfs_ops kobj_sysfs_ops;
69134
69135 diff --git a/include/linux/kobject_ns.h b/include/linux/kobject_ns.h
69136 index f66b065..c2c29b4 100644
69137 --- a/include/linux/kobject_ns.h
69138 +++ b/include/linux/kobject_ns.h
69139 @@ -43,7 +43,7 @@ struct kobj_ns_type_operations {
69140 const void *(*netlink_ns)(struct sock *sk);
69141 const void *(*initial_ns)(void);
69142 void (*drop_ns)(void *);
69143 -};
69144 +} __do_const;
69145
69146 int kobj_ns_type_register(const struct kobj_ns_type_operations *ops);
69147 int kobj_ns_type_registered(enum kobj_ns_type type);
69148 diff --git a/include/linux/kref.h b/include/linux/kref.h
69149 index 4972e6e..de4d19b 100644
69150 --- a/include/linux/kref.h
69151 +++ b/include/linux/kref.h
69152 @@ -64,7 +64,7 @@ static inline void kref_get(struct kref *kref)
69153 static inline int kref_sub(struct kref *kref, unsigned int count,
69154 void (*release)(struct kref *kref))
69155 {
69156 - WARN_ON(release == NULL);
69157 + BUG_ON(release == NULL);
69158
69159 if (atomic_sub_and_test((int) count, &kref->refcount)) {
69160 release(kref);
69161 diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
69162 index 2c497ab..afe32f5 100644
69163 --- a/include/linux/kvm_host.h
69164 +++ b/include/linux/kvm_host.h
69165 @@ -418,7 +418,7 @@ void kvm_vcpu_uninit(struct kvm_vcpu *vcpu);
69166 int __must_check vcpu_load(struct kvm_vcpu *vcpu);
69167 void vcpu_put(struct kvm_vcpu *vcpu);
69168
69169 -int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
69170 +int kvm_init(const void *opaque, unsigned vcpu_size, unsigned vcpu_align,
69171 struct module *module);
69172 void kvm_exit(void);
69173
69174 @@ -574,7 +574,7 @@ int kvm_arch_vcpu_ioctl_set_guest_debug(struct kvm_vcpu *vcpu,
69175 struct kvm_guest_debug *dbg);
69176 int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run);
69177
69178 -int kvm_arch_init(void *opaque);
69179 +int kvm_arch_init(const void *opaque);
69180 void kvm_arch_exit(void);
69181
69182 int kvm_arch_vcpu_init(struct kvm_vcpu *vcpu);
69183 diff --git a/include/linux/libata.h b/include/linux/libata.h
69184 index 649e5f8..ead5194 100644
69185 --- a/include/linux/libata.h
69186 +++ b/include/linux/libata.h
69187 @@ -915,7 +915,7 @@ struct ata_port_operations {
69188 * fields must be pointers.
69189 */
69190 const struct ata_port_operations *inherits;
69191 -};
69192 +} __do_const;
69193
69194 struct ata_port_info {
69195 unsigned long flags;
69196 diff --git a/include/linux/list.h b/include/linux/list.h
69197 index cc6d2aa..c10ee83 100644
69198 --- a/include/linux/list.h
69199 +++ b/include/linux/list.h
69200 @@ -112,6 +112,19 @@ extern void __list_del_entry(struct list_head *entry);
69201 extern void list_del(struct list_head *entry);
69202 #endif
69203
69204 +extern void __pax_list_add(struct list_head *new,
69205 + struct list_head *prev,
69206 + struct list_head *next);
69207 +static inline void pax_list_add(struct list_head *new, struct list_head *head)
69208 +{
69209 + __pax_list_add(new, head, head->next);
69210 +}
69211 +static inline void pax_list_add_tail(struct list_head *new, struct list_head *head)
69212 +{
69213 + __pax_list_add(new, head->prev, head);
69214 +}
69215 +extern void pax_list_del(struct list_head *entry);
69216 +
69217 /**
69218 * list_replace - replace old entry by new one
69219 * @old : the element to be replaced
69220 @@ -145,6 +158,8 @@ static inline void list_del_init(struct list_head *entry)
69221 INIT_LIST_HEAD(entry);
69222 }
69223
69224 +extern void pax_list_del_init(struct list_head *entry);
69225 +
69226 /**
69227 * list_move - delete from one list and add as another's head
69228 * @list: the entry to move
69229 diff --git a/include/linux/math64.h b/include/linux/math64.h
69230 index b8ba855..0148090 100644
69231 --- a/include/linux/math64.h
69232 +++ b/include/linux/math64.h
69233 @@ -14,7 +14,7 @@
69234 * This is commonly provided by 32bit archs to provide an optimized 64bit
69235 * divide.
69236 */
69237 -static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
69238 +static inline u64 __intentional_overflow(-1) div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
69239 {
69240 *remainder = dividend % divisor;
69241 return dividend / divisor;
69242 @@ -50,7 +50,7 @@ static inline s64 div64_s64(s64 dividend, s64 divisor)
69243 #define div64_long(x,y) div_s64((x),(y))
69244
69245 #ifndef div_u64_rem
69246 -static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
69247 +static inline u64 __intentional_overflow(-1) div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
69248 {
69249 *remainder = do_div(dividend, divisor);
69250 return dividend;
69251 @@ -79,7 +79,7 @@ extern s64 div64_s64(s64 dividend, s64 divisor);
69252 * divide.
69253 */
69254 #ifndef div_u64
69255 -static inline u64 div_u64(u64 dividend, u32 divisor)
69256 +static inline u64 __intentional_overflow(-1) div_u64(u64 dividend, u32 divisor)
69257 {
69258 u32 remainder;
69259 return div_u64_rem(dividend, divisor, &remainder);
69260 diff --git a/include/linux/mm.h b/include/linux/mm.h
69261 index 66e2f7c..a398fb2 100644
69262 --- a/include/linux/mm.h
69263 +++ b/include/linux/mm.h
69264 @@ -101,6 +101,11 @@ extern unsigned int kobjsize(const void *objp);
69265 #define VM_HUGETLB 0x00400000 /* Huge TLB Page VM */
69266 #define VM_NONLINEAR 0x00800000 /* Is non-linear (remap_file_pages) */
69267 #define VM_ARCH_1 0x01000000 /* Architecture-specific flag */
69268 +
69269 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
69270 +#define VM_PAGEEXEC 0x02000000 /* vma->vm_page_prot needs special handling */
69271 +#endif
69272 +
69273 #define VM_DONTDUMP 0x04000000 /* Do not include in the core dump */
69274
69275 #define VM_MIXEDMAP 0x10000000 /* Can contain "struct page" and pure PFN pages */
69276 @@ -231,6 +236,7 @@ struct vm_operations_struct {
69277 int (*remap_pages)(struct vm_area_struct *vma, unsigned long addr,
69278 unsigned long size, pgoff_t pgoff);
69279 };
69280 +typedef struct vm_operations_struct __no_const vm_operations_struct_no_const;
69281
69282 struct mmu_gather;
69283 struct inode;
69284 @@ -1068,34 +1074,6 @@ int set_page_dirty(struct page *page);
69285 int set_page_dirty_lock(struct page *page);
69286 int clear_page_dirty_for_io(struct page *page);
69287
69288 -/* Is the vma a continuation of the stack vma above it? */
69289 -static inline int vma_growsdown(struct vm_area_struct *vma, unsigned long addr)
69290 -{
69291 - return vma && (vma->vm_end == addr) && (vma->vm_flags & VM_GROWSDOWN);
69292 -}
69293 -
69294 -static inline int stack_guard_page_start(struct vm_area_struct *vma,
69295 - unsigned long addr)
69296 -{
69297 - return (vma->vm_flags & VM_GROWSDOWN) &&
69298 - (vma->vm_start == addr) &&
69299 - !vma_growsdown(vma->vm_prev, addr);
69300 -}
69301 -
69302 -/* Is the vma a continuation of the stack vma below it? */
69303 -static inline int vma_growsup(struct vm_area_struct *vma, unsigned long addr)
69304 -{
69305 - return vma && (vma->vm_start == addr) && (vma->vm_flags & VM_GROWSUP);
69306 -}
69307 -
69308 -static inline int stack_guard_page_end(struct vm_area_struct *vma,
69309 - unsigned long addr)
69310 -{
69311 - return (vma->vm_flags & VM_GROWSUP) &&
69312 - (vma->vm_end == addr) &&
69313 - !vma_growsup(vma->vm_next, addr);
69314 -}
69315 -
69316 extern pid_t
69317 vm_is_stack(struct task_struct *task, struct vm_area_struct *vma, int in_group);
69318
69319 @@ -1198,6 +1176,15 @@ static inline void sync_mm_rss(struct mm_struct *mm)
69320 }
69321 #endif
69322
69323 +#ifdef CONFIG_MMU
69324 +pgprot_t vm_get_page_prot(vm_flags_t vm_flags);
69325 +#else
69326 +static inline pgprot_t vm_get_page_prot(vm_flags_t vm_flags)
69327 +{
69328 + return __pgprot(0);
69329 +}
69330 +#endif
69331 +
69332 int vma_wants_writenotify(struct vm_area_struct *vma);
69333
69334 extern pte_t *__get_locked_pte(struct mm_struct *mm, unsigned long addr,
69335 @@ -1216,8 +1203,15 @@ static inline int __pud_alloc(struct mm_struct *mm, pgd_t *pgd,
69336 {
69337 return 0;
69338 }
69339 +
69340 +static inline int __pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd,
69341 + unsigned long address)
69342 +{
69343 + return 0;
69344 +}
69345 #else
69346 int __pud_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long address);
69347 +int __pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd, unsigned long address);
69348 #endif
69349
69350 #ifdef __PAGETABLE_PMD_FOLDED
69351 @@ -1226,8 +1220,15 @@ static inline int __pmd_alloc(struct mm_struct *mm, pud_t *pud,
69352 {
69353 return 0;
69354 }
69355 +
69356 +static inline int __pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud,
69357 + unsigned long address)
69358 +{
69359 + return 0;
69360 +}
69361 #else
69362 int __pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address);
69363 +int __pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud, unsigned long address);
69364 #endif
69365
69366 int __pte_alloc(struct mm_struct *mm, struct vm_area_struct *vma,
69367 @@ -1245,11 +1246,23 @@ static inline pud_t *pud_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long a
69368 NULL: pud_offset(pgd, address);
69369 }
69370
69371 +static inline pud_t *pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd, unsigned long address)
69372 +{
69373 + return (unlikely(pgd_none(*pgd)) && __pud_alloc_kernel(mm, pgd, address))?
69374 + NULL: pud_offset(pgd, address);
69375 +}
69376 +
69377 static inline pmd_t *pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address)
69378 {
69379 return (unlikely(pud_none(*pud)) && __pmd_alloc(mm, pud, address))?
69380 NULL: pmd_offset(pud, address);
69381 }
69382 +
69383 +static inline pmd_t *pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud, unsigned long address)
69384 +{
69385 + return (unlikely(pud_none(*pud)) && __pmd_alloc_kernel(mm, pud, address))?
69386 + NULL: pmd_offset(pud, address);
69387 +}
69388 #endif /* CONFIG_MMU && !__ARCH_HAS_4LEVEL_HACK */
69389
69390 #if USE_SPLIT_PTLOCKS
69391 @@ -1479,6 +1492,7 @@ extern unsigned long do_mmap_pgoff(struct file *, unsigned long,
69392 unsigned long, unsigned long,
69393 unsigned long, unsigned long);
69394 extern int do_munmap(struct mm_struct *, unsigned long, size_t);
69395 +extern int __do_munmap(struct mm_struct *, unsigned long, size_t);
69396
69397 /* These take the mm semaphore themselves */
69398 extern unsigned long vm_brk(unsigned long, unsigned long);
69399 @@ -1573,6 +1587,10 @@ extern struct vm_area_struct * find_vma(struct mm_struct * mm, unsigned long add
69400 extern struct vm_area_struct * find_vma_prev(struct mm_struct * mm, unsigned long addr,
69401 struct vm_area_struct **pprev);
69402
69403 +extern struct vm_area_struct *pax_find_mirror_vma(struct vm_area_struct *vma);
69404 +extern __must_check long pax_mirror_vma(struct vm_area_struct *vma_m, struct vm_area_struct *vma);
69405 +extern void pax_mirror_file_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m, spinlock_t *ptl);
69406 +
69407 /* Look up the first VMA which intersects the interval start_addr..end_addr-1,
69408 NULL if none. Assume start_addr < end_addr. */
69409 static inline struct vm_area_struct * find_vma_intersection(struct mm_struct * mm, unsigned long start_addr, unsigned long end_addr)
69410 @@ -1601,15 +1619,6 @@ static inline struct vm_area_struct *find_exact_vma(struct mm_struct *mm,
69411 return vma;
69412 }
69413
69414 -#ifdef CONFIG_MMU
69415 -pgprot_t vm_get_page_prot(unsigned long vm_flags);
69416 -#else
69417 -static inline pgprot_t vm_get_page_prot(unsigned long vm_flags)
69418 -{
69419 - return __pgprot(0);
69420 -}
69421 -#endif
69422 -
69423 #ifdef CONFIG_ARCH_USES_NUMA_PROT_NONE
69424 unsigned long change_prot_numa(struct vm_area_struct *vma,
69425 unsigned long start, unsigned long end);
69426 @@ -1649,6 +1658,11 @@ void vm_stat_account(struct mm_struct *, unsigned long, struct file *, long);
69427 static inline void vm_stat_account(struct mm_struct *mm,
69428 unsigned long flags, struct file *file, long pages)
69429 {
69430 +
69431 +#ifdef CONFIG_PAX_RANDMMAP
69432 + if (!(mm->pax_flags & MF_PAX_RANDMMAP) || (flags & (VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)))
69433 +#endif
69434 +
69435 mm->total_vm += pages;
69436 }
69437 #endif /* CONFIG_PROC_FS */
69438 @@ -1721,7 +1735,7 @@ extern int unpoison_memory(unsigned long pfn);
69439 extern int sysctl_memory_failure_early_kill;
69440 extern int sysctl_memory_failure_recovery;
69441 extern void shake_page(struct page *p, int access);
69442 -extern atomic_long_t mce_bad_pages;
69443 +extern atomic_long_unchecked_t mce_bad_pages;
69444 extern int soft_offline_page(struct page *page, int flags);
69445
69446 extern void dump_page(struct page *page);
69447 @@ -1752,5 +1766,11 @@ static inline unsigned int debug_guardpage_minorder(void) { return 0; }
69448 static inline bool page_is_guard(struct page *page) { return false; }
69449 #endif /* CONFIG_DEBUG_PAGEALLOC */
69450
69451 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
69452 +extern void track_exec_limit(struct mm_struct *mm, unsigned long start, unsigned long end, unsigned long prot);
69453 +#else
69454 +static inline void track_exec_limit(struct mm_struct *mm, unsigned long start, unsigned long end, unsigned long prot) {}
69455 +#endif
69456 +
69457 #endif /* __KERNEL__ */
69458 #endif /* _LINUX_MM_H */
69459 diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h
69460 index f8f5162..3aaf20f 100644
69461 --- a/include/linux/mm_types.h
69462 +++ b/include/linux/mm_types.h
69463 @@ -288,6 +288,8 @@ struct vm_area_struct {
69464 #ifdef CONFIG_NUMA
69465 struct mempolicy *vm_policy; /* NUMA policy for the VMA */
69466 #endif
69467 +
69468 + struct vm_area_struct *vm_mirror;/* PaX: mirror vma or NULL */
69469 };
69470
69471 struct core_thread {
69472 @@ -436,6 +438,24 @@ struct mm_struct {
69473 int first_nid;
69474 #endif
69475 struct uprobes_state uprobes_state;
69476 +
69477 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
69478 + unsigned long pax_flags;
69479 +#endif
69480 +
69481 +#ifdef CONFIG_PAX_DLRESOLVE
69482 + unsigned long call_dl_resolve;
69483 +#endif
69484 +
69485 +#if defined(CONFIG_PPC32) && defined(CONFIG_PAX_EMUSIGRT)
69486 + unsigned long call_syscall;
69487 +#endif
69488 +
69489 +#ifdef CONFIG_PAX_ASLR
69490 + unsigned long delta_mmap; /* randomized offset */
69491 + unsigned long delta_stack; /* randomized offset */
69492 +#endif
69493 +
69494 };
69495
69496 /* first nid will either be a valid NID or one of these values */
69497 diff --git a/include/linux/mmiotrace.h b/include/linux/mmiotrace.h
69498 index c5d5278..f0b68c8 100644
69499 --- a/include/linux/mmiotrace.h
69500 +++ b/include/linux/mmiotrace.h
69501 @@ -46,7 +46,7 @@ extern int kmmio_handler(struct pt_regs *regs, unsigned long addr);
69502 /* Called from ioremap.c */
69503 extern void mmiotrace_ioremap(resource_size_t offset, unsigned long size,
69504 void __iomem *addr);
69505 -extern void mmiotrace_iounmap(volatile void __iomem *addr);
69506 +extern void mmiotrace_iounmap(const volatile void __iomem *addr);
69507
69508 /* For anyone to insert markers. Remember trailing newline. */
69509 extern __printf(1, 2) int mmiotrace_printk(const char *fmt, ...);
69510 @@ -66,7 +66,7 @@ static inline void mmiotrace_ioremap(resource_size_t offset,
69511 {
69512 }
69513
69514 -static inline void mmiotrace_iounmap(volatile void __iomem *addr)
69515 +static inline void mmiotrace_iounmap(const volatile void __iomem *addr)
69516 {
69517 }
69518
69519 diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
69520 index 73b64a3..6562925 100644
69521 --- a/include/linux/mmzone.h
69522 +++ b/include/linux/mmzone.h
69523 @@ -412,7 +412,7 @@ struct zone {
69524 unsigned long flags; /* zone flags, see below */
69525
69526 /* Zone statistics */
69527 - atomic_long_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
69528 + atomic_long_unchecked_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
69529
69530 /*
69531 * The target ratio of ACTIVE_ANON to INACTIVE_ANON pages on
69532 diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h
69533 index fed3def..c933f99 100644
69534 --- a/include/linux/mod_devicetable.h
69535 +++ b/include/linux/mod_devicetable.h
69536 @@ -12,7 +12,7 @@
69537 typedef unsigned long kernel_ulong_t;
69538 #endif
69539
69540 -#define PCI_ANY_ID (~0)
69541 +#define PCI_ANY_ID ((__u16)~0)
69542
69543 struct pci_device_id {
69544 __u32 vendor, device; /* Vendor and device ID or PCI_ANY_ID*/
69545 @@ -139,7 +139,7 @@ struct usb_device_id {
69546 #define USB_DEVICE_ID_MATCH_INT_PROTOCOL 0x0200
69547 #define USB_DEVICE_ID_MATCH_INT_NUMBER 0x0400
69548
69549 -#define HID_ANY_ID (~0)
69550 +#define HID_ANY_ID (~0U)
69551 #define HID_BUS_ANY 0xffff
69552 #define HID_GROUP_ANY 0x0000
69553
69554 @@ -498,7 +498,7 @@ struct dmi_system_id {
69555 const char *ident;
69556 struct dmi_strmatch matches[4];
69557 void *driver_data;
69558 -};
69559 +} __do_const;
69560 /*
69561 * struct dmi_device_id appears during expansion of
69562 * "MODULE_DEVICE_TABLE(dmi, x)". Compiler doesn't look inside it
69563 diff --git a/include/linux/module.h b/include/linux/module.h
69564 index 1375ee3..ced8177 100644
69565 --- a/include/linux/module.h
69566 +++ b/include/linux/module.h
69567 @@ -17,9 +17,11 @@
69568 #include <linux/moduleparam.h>
69569 #include <linux/tracepoint.h>
69570 #include <linux/export.h>
69571 +#include <linux/fs.h>
69572
69573 #include <linux/percpu.h>
69574 #include <asm/module.h>
69575 +#include <asm/pgtable.h>
69576
69577 /* In stripped ARM and x86-64 modules, ~ is surprisingly rare. */
69578 #define MODULE_SIG_STRING "~Module signature appended~\n"
69579 @@ -54,12 +56,13 @@ struct module_attribute {
69580 int (*test)(struct module *);
69581 void (*free)(struct module *);
69582 };
69583 +typedef struct module_attribute __no_const module_attribute_no_const;
69584
69585 struct module_version_attribute {
69586 struct module_attribute mattr;
69587 const char *module_name;
69588 const char *version;
69589 -} __attribute__ ((__aligned__(sizeof(void *))));
69590 +} __do_const __attribute__ ((__aligned__(sizeof(void *))));
69591
69592 extern ssize_t __modver_version_show(struct module_attribute *,
69593 struct module_kobject *, char *);
69594 @@ -232,7 +235,7 @@ struct module
69595
69596 /* Sysfs stuff. */
69597 struct module_kobject mkobj;
69598 - struct module_attribute *modinfo_attrs;
69599 + module_attribute_no_const *modinfo_attrs;
69600 const char *version;
69601 const char *srcversion;
69602 struct kobject *holders_dir;
69603 @@ -281,19 +284,16 @@ struct module
69604 int (*init)(void);
69605
69606 /* If this is non-NULL, vfree after init() returns */
69607 - void *module_init;
69608 + void *module_init_rx, *module_init_rw;
69609
69610 /* Here is the actual code + data, vfree'd on unload. */
69611 - void *module_core;
69612 + void *module_core_rx, *module_core_rw;
69613
69614 /* Here are the sizes of the init and core sections */
69615 - unsigned int init_size, core_size;
69616 + unsigned int init_size_rw, core_size_rw;
69617
69618 /* The size of the executable code in each section. */
69619 - unsigned int init_text_size, core_text_size;
69620 -
69621 - /* Size of RO sections of the module (text+rodata) */
69622 - unsigned int init_ro_size, core_ro_size;
69623 + unsigned int init_size_rx, core_size_rx;
69624
69625 /* Arch-specific module values */
69626 struct mod_arch_specific arch;
69627 @@ -349,6 +349,10 @@ struct module
69628 #ifdef CONFIG_EVENT_TRACING
69629 struct ftrace_event_call **trace_events;
69630 unsigned int num_trace_events;
69631 + struct file_operations trace_id;
69632 + struct file_operations trace_enable;
69633 + struct file_operations trace_format;
69634 + struct file_operations trace_filter;
69635 #endif
69636 #ifdef CONFIG_FTRACE_MCOUNT_RECORD
69637 unsigned int num_ftrace_callsites;
69638 @@ -396,16 +400,46 @@ bool is_module_address(unsigned long addr);
69639 bool is_module_percpu_address(unsigned long addr);
69640 bool is_module_text_address(unsigned long addr);
69641
69642 +static inline int within_module_range(unsigned long addr, void *start, unsigned long size)
69643 +{
69644 +
69645 +#ifdef CONFIG_PAX_KERNEXEC
69646 + if (ktla_ktva(addr) >= (unsigned long)start &&
69647 + ktla_ktva(addr) < (unsigned long)start + size)
69648 + return 1;
69649 +#endif
69650 +
69651 + return ((void *)addr >= start && (void *)addr < start + size);
69652 +}
69653 +
69654 +static inline int within_module_core_rx(unsigned long addr, struct module *mod)
69655 +{
69656 + return within_module_range(addr, mod->module_core_rx, mod->core_size_rx);
69657 +}
69658 +
69659 +static inline int within_module_core_rw(unsigned long addr, struct module *mod)
69660 +{
69661 + return within_module_range(addr, mod->module_core_rw, mod->core_size_rw);
69662 +}
69663 +
69664 +static inline int within_module_init_rx(unsigned long addr, struct module *mod)
69665 +{
69666 + return within_module_range(addr, mod->module_init_rx, mod->init_size_rx);
69667 +}
69668 +
69669 +static inline int within_module_init_rw(unsigned long addr, struct module *mod)
69670 +{
69671 + return within_module_range(addr, mod->module_init_rw, mod->init_size_rw);
69672 +}
69673 +
69674 static inline int within_module_core(unsigned long addr, struct module *mod)
69675 {
69676 - return (unsigned long)mod->module_core <= addr &&
69677 - addr < (unsigned long)mod->module_core + mod->core_size;
69678 + return within_module_core_rx(addr, mod) || within_module_core_rw(addr, mod);
69679 }
69680
69681 static inline int within_module_init(unsigned long addr, struct module *mod)
69682 {
69683 - return (unsigned long)mod->module_init <= addr &&
69684 - addr < (unsigned long)mod->module_init + mod->init_size;
69685 + return within_module_init_rx(addr, mod) || within_module_init_rw(addr, mod);
69686 }
69687
69688 /* Search for module by name: must hold module_mutex. */
69689 diff --git a/include/linux/moduleloader.h b/include/linux/moduleloader.h
69690 index 560ca53..5ee8d73 100644
69691 --- a/include/linux/moduleloader.h
69692 +++ b/include/linux/moduleloader.h
69693 @@ -23,11 +23,23 @@ unsigned int arch_mod_section_prepend(struct module *mod, unsigned int section);
69694
69695 /* Allocator used for allocating struct module, core sections and init
69696 sections. Returns NULL on failure. */
69697 -void *module_alloc(unsigned long size);
69698 +void *module_alloc(unsigned long size) __size_overflow(1);
69699 +
69700 +#ifdef CONFIG_PAX_KERNEXEC
69701 +void *module_alloc_exec(unsigned long size) __size_overflow(1);
69702 +#else
69703 +#define module_alloc_exec(x) module_alloc(x)
69704 +#endif
69705
69706 /* Free memory returned from module_alloc. */
69707 void module_free(struct module *mod, void *module_region);
69708
69709 +#ifdef CONFIG_PAX_KERNEXEC
69710 +void module_free_exec(struct module *mod, void *module_region);
69711 +#else
69712 +#define module_free_exec(x, y) module_free((x), (y))
69713 +#endif
69714 +
69715 /*
69716 * Apply the given relocation to the (simplified) ELF. Return -error
69717 * or 0.
69718 @@ -45,7 +57,9 @@ static inline int apply_relocate(Elf_Shdr *sechdrs,
69719 unsigned int relsec,
69720 struct module *me)
69721 {
69722 +#ifdef CONFIG_MODULES
69723 printk(KERN_ERR "module %s: REL relocation unsupported\n", me->name);
69724 +#endif
69725 return -ENOEXEC;
69726 }
69727 #endif
69728 @@ -67,7 +81,9 @@ static inline int apply_relocate_add(Elf_Shdr *sechdrs,
69729 unsigned int relsec,
69730 struct module *me)
69731 {
69732 +#ifdef CONFIG_MODULES
69733 printk(KERN_ERR "module %s: REL relocation unsupported\n", me->name);
69734 +#endif
69735 return -ENOEXEC;
69736 }
69737 #endif
69738 diff --git a/include/linux/moduleparam.h b/include/linux/moduleparam.h
69739 index 137b419..fe663ec 100644
69740 --- a/include/linux/moduleparam.h
69741 +++ b/include/linux/moduleparam.h
69742 @@ -284,7 +284,7 @@ static inline void __kernel_param_unlock(void)
69743 * @len is usually just sizeof(string).
69744 */
69745 #define module_param_string(name, string, len, perm) \
69746 - static const struct kparam_string __param_string_##name \
69747 + static const struct kparam_string __param_string_##name __used \
69748 = { len, string }; \
69749 __module_param_call(MODULE_PARAM_PREFIX, name, \
69750 &param_ops_string, \
69751 @@ -423,7 +423,7 @@ extern int param_set_bint(const char *val, const struct kernel_param *kp);
69752 */
69753 #define module_param_array_named(name, array, type, nump, perm) \
69754 param_check_##type(name, &(array)[0]); \
69755 - static const struct kparam_array __param_arr_##name \
69756 + static const struct kparam_array __param_arr_##name __used \
69757 = { .max = ARRAY_SIZE(array), .num = nump, \
69758 .ops = &param_ops_##type, \
69759 .elemsize = sizeof(array[0]), .elem = array }; \
69760 diff --git a/include/linux/namei.h b/include/linux/namei.h
69761 index 5a5ff57..5ae5070 100644
69762 --- a/include/linux/namei.h
69763 +++ b/include/linux/namei.h
69764 @@ -19,7 +19,7 @@ struct nameidata {
69765 unsigned seq;
69766 int last_type;
69767 unsigned depth;
69768 - char *saved_names[MAX_NESTED_LINKS + 1];
69769 + const char *saved_names[MAX_NESTED_LINKS + 1];
69770 };
69771
69772 /*
69773 @@ -84,12 +84,12 @@ extern void unlock_rename(struct dentry *, struct dentry *);
69774
69775 extern void nd_jump_link(struct nameidata *nd, struct path *path);
69776
69777 -static inline void nd_set_link(struct nameidata *nd, char *path)
69778 +static inline void nd_set_link(struct nameidata *nd, const char *path)
69779 {
69780 nd->saved_names[nd->depth] = path;
69781 }
69782
69783 -static inline char *nd_get_link(struct nameidata *nd)
69784 +static inline const char *nd_get_link(const struct nameidata *nd)
69785 {
69786 return nd->saved_names[nd->depth];
69787 }
69788 diff --git a/include/linux/net.h b/include/linux/net.h
69789 index aa16731..514b875 100644
69790 --- a/include/linux/net.h
69791 +++ b/include/linux/net.h
69792 @@ -183,7 +183,7 @@ struct net_proto_family {
69793 int (*create)(struct net *net, struct socket *sock,
69794 int protocol, int kern);
69795 struct module *owner;
69796 -};
69797 +} __do_const;
69798
69799 struct iovec;
69800 struct kvec;
69801 diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
69802 index 9ef07d0..130a5d9 100644
69803 --- a/include/linux/netdevice.h
69804 +++ b/include/linux/netdevice.h
69805 @@ -1012,6 +1012,7 @@ struct net_device_ops {
69806 u32 pid, u32 seq,
69807 struct net_device *dev);
69808 };
69809 +typedef struct net_device_ops __no_const net_device_ops_no_const;
69810
69811 /*
69812 * The DEVICE structure.
69813 @@ -1078,7 +1079,7 @@ struct net_device {
69814 int iflink;
69815
69816 struct net_device_stats stats;
69817 - atomic_long_t rx_dropped; /* dropped packets by core network
69818 + atomic_long_unchecked_t rx_dropped; /* dropped packets by core network
69819 * Do not use this in drivers.
69820 */
69821
69822 diff --git a/include/linux/netfilter.h b/include/linux/netfilter.h
69823 index ee14284..bc65d63 100644
69824 --- a/include/linux/netfilter.h
69825 +++ b/include/linux/netfilter.h
69826 @@ -82,7 +82,7 @@ struct nf_sockopt_ops {
69827 #endif
69828 /* Use the module struct to lock set/get code in place */
69829 struct module *owner;
69830 -};
69831 +} __do_const;
69832
69833 /* Function to register/unregister hook points. */
69834 int nf_register_hook(struct nf_hook_ops *reg);
69835 diff --git a/include/linux/netfilter/ipset/ip_set.h b/include/linux/netfilter/ipset/ip_set.h
69836 index 7958e84..ed74d7a 100644
69837 --- a/include/linux/netfilter/ipset/ip_set.h
69838 +++ b/include/linux/netfilter/ipset/ip_set.h
69839 @@ -98,7 +98,7 @@ struct ip_set_type_variant {
69840 /* Return true if "b" set is the same as "a"
69841 * according to the create set parameters */
69842 bool (*same_set)(const struct ip_set *a, const struct ip_set *b);
69843 -};
69844 +} __do_const;
69845
69846 /* The core set type structure */
69847 struct ip_set_type {
69848 diff --git a/include/linux/netfilter/nfnetlink.h b/include/linux/netfilter/nfnetlink.h
69849 index 4966dde..7d8ce06 100644
69850 --- a/include/linux/netfilter/nfnetlink.h
69851 +++ b/include/linux/netfilter/nfnetlink.h
69852 @@ -16,7 +16,7 @@ struct nfnl_callback {
69853 const struct nlattr * const cda[]);
69854 const struct nla_policy *policy; /* netlink attribute policy */
69855 const u_int16_t attr_count; /* number of nlattr's */
69856 -};
69857 +} __do_const;
69858
69859 struct nfnetlink_subsystem {
69860 const char *name;
69861 diff --git a/include/linux/netfilter/xt_gradm.h b/include/linux/netfilter/xt_gradm.h
69862 new file mode 100644
69863 index 0000000..33f4af8
69864 --- /dev/null
69865 +++ b/include/linux/netfilter/xt_gradm.h
69866 @@ -0,0 +1,9 @@
69867 +#ifndef _LINUX_NETFILTER_XT_GRADM_H
69868 +#define _LINUX_NETFILTER_XT_GRADM_H 1
69869 +
69870 +struct xt_gradm_mtinfo {
69871 + __u16 flags;
69872 + __u16 invflags;
69873 +};
69874 +
69875 +#endif
69876 diff --git a/include/linux/nls.h b/include/linux/nls.h
69877 index 5dc635f..35f5e11 100644
69878 --- a/include/linux/nls.h
69879 +++ b/include/linux/nls.h
69880 @@ -31,7 +31,7 @@ struct nls_table {
69881 const unsigned char *charset2upper;
69882 struct module *owner;
69883 struct nls_table *next;
69884 -};
69885 +} __do_const;
69886
69887 /* this value hold the maximum octet of charset */
69888 #define NLS_MAX_CHARSET_SIZE 6 /* for UTF-8 */
69889 diff --git a/include/linux/notifier.h b/include/linux/notifier.h
69890 index d65746e..62e72c2 100644
69891 --- a/include/linux/notifier.h
69892 +++ b/include/linux/notifier.h
69893 @@ -51,7 +51,8 @@ struct notifier_block {
69894 int (*notifier_call)(struct notifier_block *, unsigned long, void *);
69895 struct notifier_block __rcu *next;
69896 int priority;
69897 -};
69898 +} __do_const;
69899 +typedef struct notifier_block __no_const notifier_block_no_const;
69900
69901 struct atomic_notifier_head {
69902 spinlock_t lock;
69903 diff --git a/include/linux/oprofile.h b/include/linux/oprofile.h
69904 index a4c5624..79d6d88 100644
69905 --- a/include/linux/oprofile.h
69906 +++ b/include/linux/oprofile.h
69907 @@ -139,9 +139,9 @@ int oprofilefs_create_ulong(struct super_block * sb, struct dentry * root,
69908 int oprofilefs_create_ro_ulong(struct super_block * sb, struct dentry * root,
69909 char const * name, ulong * val);
69910
69911 -/** Create a file for read-only access to an atomic_t. */
69912 +/** Create a file for read-only access to an atomic_unchecked_t. */
69913 int oprofilefs_create_ro_atomic(struct super_block * sb, struct dentry * root,
69914 - char const * name, atomic_t * val);
69915 + char const * name, atomic_unchecked_t * val);
69916
69917 /** create a directory */
69918 struct dentry * oprofilefs_mkdir(struct super_block * sb, struct dentry * root,
69919 diff --git a/include/linux/pci_hotplug.h b/include/linux/pci_hotplug.h
69920 index 45fc162..01a4068 100644
69921 --- a/include/linux/pci_hotplug.h
69922 +++ b/include/linux/pci_hotplug.h
69923 @@ -80,7 +80,8 @@ struct hotplug_slot_ops {
69924 int (*get_attention_status) (struct hotplug_slot *slot, u8 *value);
69925 int (*get_latch_status) (struct hotplug_slot *slot, u8 *value);
69926 int (*get_adapter_status) (struct hotplug_slot *slot, u8 *value);
69927 -};
69928 +} __do_const;
69929 +typedef struct hotplug_slot_ops __no_const hotplug_slot_ops_no_const;
69930
69931 /**
69932 * struct hotplug_slot_info - used to notify the hotplug pci core of the state of the slot
69933 diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h
69934 index a280650..2b67b91 100644
69935 --- a/include/linux/perf_event.h
69936 +++ b/include/linux/perf_event.h
69937 @@ -328,8 +328,8 @@ struct perf_event {
69938
69939 enum perf_event_active_state state;
69940 unsigned int attach_state;
69941 - local64_t count;
69942 - atomic64_t child_count;
69943 + local64_t count; /* PaX: fix it one day */
69944 + atomic64_unchecked_t child_count;
69945
69946 /*
69947 * These are the total time in nanoseconds that the event
69948 @@ -380,8 +380,8 @@ struct perf_event {
69949 * These accumulate total time (in nanoseconds) that children
69950 * events have been enabled and running, respectively.
69951 */
69952 - atomic64_t child_total_time_enabled;
69953 - atomic64_t child_total_time_running;
69954 + atomic64_unchecked_t child_total_time_enabled;
69955 + atomic64_unchecked_t child_total_time_running;
69956
69957 /*
69958 * Protect attach/detach and child_list:
69959 @@ -807,7 +807,7 @@ static inline void perf_restore_debug_store(void) { }
69960 */
69961 #define perf_cpu_notifier(fn) \
69962 do { \
69963 - static struct notifier_block fn##_nb __cpuinitdata = \
69964 + static struct notifier_block fn##_nb = \
69965 { .notifier_call = fn, .priority = CPU_PRI_PERF }; \
69966 unsigned long cpu = smp_processor_id(); \
69967 unsigned long flags; \
69968 diff --git a/include/linux/pipe_fs_i.h b/include/linux/pipe_fs_i.h
69969 index ad1a427..6419649 100644
69970 --- a/include/linux/pipe_fs_i.h
69971 +++ b/include/linux/pipe_fs_i.h
69972 @@ -45,9 +45,9 @@ struct pipe_buffer {
69973 struct pipe_inode_info {
69974 wait_queue_head_t wait;
69975 unsigned int nrbufs, curbuf, buffers;
69976 - unsigned int readers;
69977 - unsigned int writers;
69978 - unsigned int waiting_writers;
69979 + atomic_t readers;
69980 + atomic_t writers;
69981 + atomic_t waiting_writers;
69982 unsigned int r_counter;
69983 unsigned int w_counter;
69984 struct page *tmp_page;
69985 diff --git a/include/linux/platform_data/usb-ehci-s5p.h b/include/linux/platform_data/usb-ehci-s5p.h
69986 index 5f28cae..3d23723 100644
69987 --- a/include/linux/platform_data/usb-ehci-s5p.h
69988 +++ b/include/linux/platform_data/usb-ehci-s5p.h
69989 @@ -14,7 +14,7 @@
69990 struct s5p_ehci_platdata {
69991 int (*phy_init)(struct platform_device *pdev, int type);
69992 int (*phy_exit)(struct platform_device *pdev, int type);
69993 -};
69994 +} __no_const;
69995
69996 extern void s5p_ehci_set_platdata(struct s5p_ehci_platdata *pd);
69997
69998 diff --git a/include/linux/platform_data/usb-exynos.h b/include/linux/platform_data/usb-exynos.h
69999 index c256c59..8ea94c7 100644
70000 --- a/include/linux/platform_data/usb-exynos.h
70001 +++ b/include/linux/platform_data/usb-exynos.h
70002 @@ -14,7 +14,7 @@
70003 struct exynos4_ohci_platdata {
70004 int (*phy_init)(struct platform_device *pdev, int type);
70005 int (*phy_exit)(struct platform_device *pdev, int type);
70006 -};
70007 +} __no_const;
70008
70009 extern void exynos4_ohci_set_platdata(struct exynos4_ohci_platdata *pd);
70010
70011 diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h
70012 index 7c1d252..c5c773e 100644
70013 --- a/include/linux/pm_domain.h
70014 +++ b/include/linux/pm_domain.h
70015 @@ -48,7 +48,7 @@ struct gpd_dev_ops {
70016
70017 struct gpd_cpu_data {
70018 unsigned int saved_exit_latency;
70019 - struct cpuidle_state *idle_state;
70020 + cpuidle_state_no_const *idle_state;
70021 };
70022
70023 struct generic_pm_domain {
70024 diff --git a/include/linux/pm_runtime.h b/include/linux/pm_runtime.h
70025 index f271860..6b3bec5 100644
70026 --- a/include/linux/pm_runtime.h
70027 +++ b/include/linux/pm_runtime.h
70028 @@ -97,7 +97,7 @@ static inline bool pm_runtime_callbacks_present(struct device *dev)
70029
70030 static inline void pm_runtime_mark_last_busy(struct device *dev)
70031 {
70032 - ACCESS_ONCE(dev->power.last_busy) = jiffies;
70033 + ACCESS_ONCE_RW(dev->power.last_busy) = jiffies;
70034 }
70035
70036 #else /* !CONFIG_PM_RUNTIME */
70037 diff --git a/include/linux/pnp.h b/include/linux/pnp.h
70038 index 195aafc..49a7bc2 100644
70039 --- a/include/linux/pnp.h
70040 +++ b/include/linux/pnp.h
70041 @@ -297,7 +297,7 @@ static inline void pnp_set_drvdata(struct pnp_dev *pdev, void *data)
70042 struct pnp_fixup {
70043 char id[7];
70044 void (*quirk_function) (struct pnp_dev * dev); /* fixup function */
70045 -};
70046 +} __do_const;
70047
70048 /* config parameters */
70049 #define PNP_CONFIG_NORMAL 0x0001
70050 diff --git a/include/linux/poison.h b/include/linux/poison.h
70051 index 2110a81..13a11bb 100644
70052 --- a/include/linux/poison.h
70053 +++ b/include/linux/poison.h
70054 @@ -19,8 +19,8 @@
70055 * under normal circumstances, used to verify that nobody uses
70056 * non-initialized list entries.
70057 */
70058 -#define LIST_POISON1 ((void *) 0x00100100 + POISON_POINTER_DELTA)
70059 -#define LIST_POISON2 ((void *) 0x00200200 + POISON_POINTER_DELTA)
70060 +#define LIST_POISON1 ((void *) (long)0xFFFFFF01)
70061 +#define LIST_POISON2 ((void *) (long)0xFFFFFF02)
70062
70063 /********** include/linux/timer.h **********/
70064 /*
70065 diff --git a/include/linux/power/smartreflex.h b/include/linux/power/smartreflex.h
70066 index c0f44c2..1572583 100644
70067 --- a/include/linux/power/smartreflex.h
70068 +++ b/include/linux/power/smartreflex.h
70069 @@ -238,7 +238,7 @@ struct omap_sr_class_data {
70070 int (*notify)(struct omap_sr *sr, u32 status);
70071 u8 notify_flags;
70072 u8 class_type;
70073 -};
70074 +} __do_const;
70075
70076 /**
70077 * struct omap_sr_nvalue_table - Smartreflex n-target value info
70078 diff --git a/include/linux/ppp-comp.h b/include/linux/ppp-comp.h
70079 index 4ea1d37..80f4b33 100644
70080 --- a/include/linux/ppp-comp.h
70081 +++ b/include/linux/ppp-comp.h
70082 @@ -84,7 +84,7 @@ struct compressor {
70083 struct module *owner;
70084 /* Extra skb space needed by the compressor algorithm */
70085 unsigned int comp_extra;
70086 -};
70087 +} __do_const;
70088
70089 /*
70090 * The return value from decompress routine is the length of the
70091 diff --git a/include/linux/printk.h b/include/linux/printk.h
70092 index 9afc01e..92c32e8 100644
70093 --- a/include/linux/printk.h
70094 +++ b/include/linux/printk.h
70095 @@ -101,6 +101,8 @@ void early_printk(const char *fmt, ...);
70096 extern int printk_needs_cpu(int cpu);
70097 extern void printk_tick(void);
70098
70099 +extern int kptr_restrict;
70100 +
70101 #ifdef CONFIG_PRINTK
70102 asmlinkage __printf(5, 0)
70103 int vprintk_emit(int facility, int level,
70104 @@ -135,7 +137,6 @@ extern bool printk_timed_ratelimit(unsigned long *caller_jiffies,
70105
70106 extern int printk_delay_msec;
70107 extern int dmesg_restrict;
70108 -extern int kptr_restrict;
70109
70110 void log_buf_kexec_setup(void);
70111 void __init setup_log_buf(int early);
70112 diff --git a/include/linux/proc_fs.h b/include/linux/proc_fs.h
70113 index 32676b3..8f7a182 100644
70114 --- a/include/linux/proc_fs.h
70115 +++ b/include/linux/proc_fs.h
70116 @@ -159,6 +159,18 @@ static inline struct proc_dir_entry *proc_create(const char *name, umode_t mode,
70117 return proc_create_data(name, mode, parent, proc_fops, NULL);
70118 }
70119
70120 +static inline struct proc_dir_entry *proc_create_grsec(const char *name, umode_t mode,
70121 + struct proc_dir_entry *parent, const struct file_operations *proc_fops)
70122 +{
70123 +#ifdef CONFIG_GRKERNSEC_PROC_USER
70124 + return proc_create_data(name, S_IRUSR, parent, proc_fops, NULL);
70125 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
70126 + return proc_create_data(name, S_IRUSR | S_IRGRP, parent, proc_fops, NULL);
70127 +#else
70128 + return proc_create_data(name, mode, parent, proc_fops, NULL);
70129 +#endif
70130 +}
70131 +
70132 static inline struct proc_dir_entry *create_proc_read_entry(const char *name,
70133 umode_t mode, struct proc_dir_entry *base,
70134 read_proc_t *read_proc, void * data)
70135 diff --git a/include/linux/random.h b/include/linux/random.h
70136 index d984608..d6f0042 100644
70137 --- a/include/linux/random.h
70138 +++ b/include/linux/random.h
70139 @@ -39,6 +39,11 @@ void prandom_seed(u32 seed);
70140 u32 prandom_u32_state(struct rnd_state *);
70141 void prandom_bytes_state(struct rnd_state *state, void *buf, int nbytes);
70142
70143 +static inline unsigned long pax_get_random_long(void)
70144 +{
70145 + return prandom_u32() + (sizeof(long) > 4 ? (unsigned long)prandom_u32() << 32 : 0);
70146 +}
70147 +
70148 /*
70149 * Handle minimum values for seeds
70150 */
70151 diff --git a/include/linux/rculist.h b/include/linux/rculist.h
70152 index c92dd28..08f4eab 100644
70153 --- a/include/linux/rculist.h
70154 +++ b/include/linux/rculist.h
70155 @@ -44,6 +44,9 @@ extern void __list_add_rcu(struct list_head *new,
70156 struct list_head *prev, struct list_head *next);
70157 #endif
70158
70159 +extern void __pax_list_add_rcu(struct list_head *new,
70160 + struct list_head *prev, struct list_head *next);
70161 +
70162 /**
70163 * list_add_rcu - add a new entry to rcu-protected list
70164 * @new: new entry to be added
70165 @@ -65,6 +68,11 @@ static inline void list_add_rcu(struct list_head *new, struct list_head *head)
70166 __list_add_rcu(new, head, head->next);
70167 }
70168
70169 +static inline void pax_list_add_rcu(struct list_head *new, struct list_head *head)
70170 +{
70171 + __pax_list_add_rcu(new, head, head->next);
70172 +}
70173 +
70174 /**
70175 * list_add_tail_rcu - add a new entry to rcu-protected list
70176 * @new: new entry to be added
70177 @@ -87,6 +95,12 @@ static inline void list_add_tail_rcu(struct list_head *new,
70178 __list_add_rcu(new, head->prev, head);
70179 }
70180
70181 +static inline void pax_list_add_tail_rcu(struct list_head *new,
70182 + struct list_head *head)
70183 +{
70184 + __pax_list_add_rcu(new, head->prev, head);
70185 +}
70186 +
70187 /**
70188 * list_del_rcu - deletes entry from list without re-initialization
70189 * @entry: the element to delete from the list.
70190 @@ -117,6 +131,8 @@ static inline void list_del_rcu(struct list_head *entry)
70191 entry->prev = LIST_POISON2;
70192 }
70193
70194 +extern void pax_list_del_rcu(struct list_head *entry);
70195 +
70196 /**
70197 * hlist_del_init_rcu - deletes entry from hash list with re-initialization
70198 * @n: the element to delete from the hash list.
70199 diff --git a/include/linux/reboot.h b/include/linux/reboot.h
70200 index 23b3630..e1bc12b 100644
70201 --- a/include/linux/reboot.h
70202 +++ b/include/linux/reboot.h
70203 @@ -18,9 +18,9 @@ extern int unregister_reboot_notifier(struct notifier_block *);
70204 * Architecture-specific implementations of sys_reboot commands.
70205 */
70206
70207 -extern void machine_restart(char *cmd);
70208 -extern void machine_halt(void);
70209 -extern void machine_power_off(void);
70210 +extern void machine_restart(char *cmd) __noreturn;
70211 +extern void machine_halt(void) __noreturn;
70212 +extern void machine_power_off(void) __noreturn;
70213
70214 extern void machine_shutdown(void);
70215 struct pt_regs;
70216 @@ -31,9 +31,9 @@ extern void machine_crash_shutdown(struct pt_regs *);
70217 */
70218
70219 extern void kernel_restart_prepare(char *cmd);
70220 -extern void kernel_restart(char *cmd);
70221 -extern void kernel_halt(void);
70222 -extern void kernel_power_off(void);
70223 +extern void kernel_restart(char *cmd) __noreturn;
70224 +extern void kernel_halt(void) __noreturn;
70225 +extern void kernel_power_off(void) __noreturn;
70226
70227 extern int C_A_D; /* for sysctl */
70228 void ctrl_alt_del(void);
70229 @@ -47,7 +47,7 @@ extern int orderly_poweroff(bool force);
70230 * Emergency restart, callable from an interrupt handler.
70231 */
70232
70233 -extern void emergency_restart(void);
70234 +extern void emergency_restart(void) __noreturn;
70235 #include <asm/emergency-restart.h>
70236
70237 #endif /* _LINUX_REBOOT_H */
70238 diff --git a/include/linux/regset.h b/include/linux/regset.h
70239 index 8e0c9fe..ac4d221 100644
70240 --- a/include/linux/regset.h
70241 +++ b/include/linux/regset.h
70242 @@ -161,7 +161,8 @@ struct user_regset {
70243 unsigned int align;
70244 unsigned int bias;
70245 unsigned int core_note_type;
70246 -};
70247 +} __do_const;
70248 +typedef struct user_regset __no_const user_regset_no_const;
70249
70250 /**
70251 * struct user_regset_view - available regsets
70252 diff --git a/include/linux/relay.h b/include/linux/relay.h
70253 index 91cacc3..b55ff74 100644
70254 --- a/include/linux/relay.h
70255 +++ b/include/linux/relay.h
70256 @@ -160,7 +160,7 @@ struct rchan_callbacks
70257 * The callback should return 0 if successful, negative if not.
70258 */
70259 int (*remove_buf_file)(struct dentry *dentry);
70260 -};
70261 +} __no_const;
70262
70263 /*
70264 * CONFIG_RELAY kernel API, kernel/relay.c
70265 diff --git a/include/linux/rio.h b/include/linux/rio.h
70266 index a3e7842..d973ca6 100644
70267 --- a/include/linux/rio.h
70268 +++ b/include/linux/rio.h
70269 @@ -339,7 +339,7 @@ struct rio_ops {
70270 int (*map_inb)(struct rio_mport *mport, dma_addr_t lstart,
70271 u64 rstart, u32 size, u32 flags);
70272 void (*unmap_inb)(struct rio_mport *mport, dma_addr_t lstart);
70273 -};
70274 +} __no_const;
70275
70276 #define RIO_RESOURCE_MEM 0x00000100
70277 #define RIO_RESOURCE_DOORBELL 0x00000200
70278 diff --git a/include/linux/rmap.h b/include/linux/rmap.h
70279 index c20635c..2f5def4 100644
70280 --- a/include/linux/rmap.h
70281 +++ b/include/linux/rmap.h
70282 @@ -145,8 +145,8 @@ static inline void anon_vma_unlock_read(struct anon_vma *anon_vma)
70283 void anon_vma_init(void); /* create anon_vma_cachep */
70284 int anon_vma_prepare(struct vm_area_struct *);
70285 void unlink_anon_vmas(struct vm_area_struct *);
70286 -int anon_vma_clone(struct vm_area_struct *, struct vm_area_struct *);
70287 -int anon_vma_fork(struct vm_area_struct *, struct vm_area_struct *);
70288 +int anon_vma_clone(struct vm_area_struct *, const struct vm_area_struct *);
70289 +int anon_vma_fork(struct vm_area_struct *, const struct vm_area_struct *);
70290
70291 static inline void anon_vma_merge(struct vm_area_struct *vma,
70292 struct vm_area_struct *next)
70293 diff --git a/include/linux/sched.h b/include/linux/sched.h
70294 index d211247..eac6c2c 100644
70295 --- a/include/linux/sched.h
70296 +++ b/include/linux/sched.h
70297 @@ -61,6 +61,7 @@ struct bio_list;
70298 struct fs_struct;
70299 struct perf_event_context;
70300 struct blk_plug;
70301 +struct linux_binprm;
70302
70303 /*
70304 * List of flags we want to share for kernel threads,
70305 @@ -327,7 +328,7 @@ extern char __sched_text_start[], __sched_text_end[];
70306 extern int in_sched_functions(unsigned long addr);
70307
70308 #define MAX_SCHEDULE_TIMEOUT LONG_MAX
70309 -extern signed long schedule_timeout(signed long timeout);
70310 +extern signed long schedule_timeout(signed long timeout) __intentional_overflow(-1);
70311 extern signed long schedule_timeout_interruptible(signed long timeout);
70312 extern signed long schedule_timeout_killable(signed long timeout);
70313 extern signed long schedule_timeout_uninterruptible(signed long timeout);
70314 @@ -354,10 +355,23 @@ struct user_namespace;
70315 #define DEFAULT_MAX_MAP_COUNT (USHRT_MAX - MAPCOUNT_ELF_CORE_MARGIN)
70316
70317 extern int sysctl_max_map_count;
70318 +extern unsigned long sysctl_heap_stack_gap;
70319
70320 #include <linux/aio.h>
70321
70322 #ifdef CONFIG_MMU
70323 +
70324 +#ifdef CONFIG_GRKERNSEC_RAND_THREADSTACK
70325 +extern unsigned long gr_rand_threadstack_offset(const struct mm_struct *mm, const struct file *filp, unsigned long flags);
70326 +#else
70327 +static inline unsigned long gr_rand_threadstack_offset(const struct mm_struct *mm, const struct file *filp, unsigned long flags)
70328 +{
70329 + return 0;
70330 +}
70331 +#endif
70332 +
70333 +extern bool check_heap_stack_gap(const struct vm_area_struct *vma, unsigned long addr, unsigned long len, unsigned long offset);
70334 +extern unsigned long skip_heap_stack_gap(const struct vm_area_struct *vma, unsigned long len, unsigned long offset);
70335 extern void arch_pick_mmap_layout(struct mm_struct *mm);
70336 extern unsigned long
70337 arch_get_unmapped_area(struct file *, unsigned long, unsigned long,
70338 @@ -639,6 +653,17 @@ struct signal_struct {
70339 #ifdef CONFIG_TASKSTATS
70340 struct taskstats *stats;
70341 #endif
70342 +
70343 +#ifdef CONFIG_GRKERNSEC
70344 + u32 curr_ip;
70345 + u32 saved_ip;
70346 + u32 gr_saddr;
70347 + u32 gr_daddr;
70348 + u16 gr_sport;
70349 + u16 gr_dport;
70350 + u8 used_accept:1;
70351 +#endif
70352 +
70353 #ifdef CONFIG_AUDIT
70354 unsigned audit_tty;
70355 struct tty_audit_buf *tty_audit_buf;
70356 @@ -717,6 +742,11 @@ struct user_struct {
70357 struct key *session_keyring; /* UID's default session keyring */
70358 #endif
70359
70360 +#if defined(CONFIG_GRKERNSEC_KERN_LOCKOUT) || defined(CONFIG_GRKERNSEC_BRUTE)
70361 + unsigned int banned;
70362 + unsigned long ban_expires;
70363 +#endif
70364 +
70365 /* Hash table maintenance information */
70366 struct hlist_node uidhash_node;
70367 kuid_t uid;
70368 @@ -1116,7 +1146,7 @@ struct sched_class {
70369 #ifdef CONFIG_FAIR_GROUP_SCHED
70370 void (*task_move_group) (struct task_struct *p, int on_rq);
70371 #endif
70372 -};
70373 +} __do_const;
70374
70375 struct load_weight {
70376 unsigned long weight, inv_weight;
70377 @@ -1360,8 +1390,8 @@ struct task_struct {
70378 struct list_head thread_group;
70379
70380 struct completion *vfork_done; /* for vfork() */
70381 - int __user *set_child_tid; /* CLONE_CHILD_SETTID */
70382 - int __user *clear_child_tid; /* CLONE_CHILD_CLEARTID */
70383 + pid_t __user *set_child_tid; /* CLONE_CHILD_SETTID */
70384 + pid_t __user *clear_child_tid; /* CLONE_CHILD_CLEARTID */
70385
70386 cputime_t utime, stime, utimescaled, stimescaled;
70387 cputime_t gtime;
70388 @@ -1377,11 +1407,6 @@ struct task_struct {
70389 struct task_cputime cputime_expires;
70390 struct list_head cpu_timers[3];
70391
70392 -/* process credentials */
70393 - const struct cred __rcu *real_cred; /* objective and real subjective task
70394 - * credentials (COW) */
70395 - const struct cred __rcu *cred; /* effective (overridable) subjective task
70396 - * credentials (COW) */
70397 char comm[TASK_COMM_LEN]; /* executable name excluding path
70398 - access with [gs]et_task_comm (which lock
70399 it with task_lock())
70400 @@ -1398,6 +1423,10 @@ struct task_struct {
70401 #endif
70402 /* CPU-specific state of this task */
70403 struct thread_struct thread;
70404 +/* thread_info moved to task_struct */
70405 +#ifdef CONFIG_X86
70406 + struct thread_info tinfo;
70407 +#endif
70408 /* filesystem information */
70409 struct fs_struct *fs;
70410 /* open file information */
70411 @@ -1471,6 +1500,10 @@ struct task_struct {
70412 gfp_t lockdep_reclaim_gfp;
70413 #endif
70414
70415 +/* process credentials */
70416 + const struct cred __rcu *real_cred; /* objective and real subjective task
70417 + * credentials (COW) */
70418 +
70419 /* journalling filesystem info */
70420 void *journal_info;
70421
70422 @@ -1509,6 +1542,10 @@ struct task_struct {
70423 /* cg_list protected by css_set_lock and tsk->alloc_lock */
70424 struct list_head cg_list;
70425 #endif
70426 +
70427 + const struct cred __rcu *cred; /* effective (overridable) subjective task
70428 + * credentials (COW) */
70429 +
70430 #ifdef CONFIG_FUTEX
70431 struct robust_list_head __user *robust_list;
70432 #ifdef CONFIG_COMPAT
70433 @@ -1605,8 +1642,74 @@ struct task_struct {
70434 #ifdef CONFIG_UPROBES
70435 struct uprobe_task *utask;
70436 #endif
70437 +
70438 +#ifdef CONFIG_GRKERNSEC
70439 + /* grsecurity */
70440 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
70441 + u64 exec_id;
70442 +#endif
70443 +#ifdef CONFIG_GRKERNSEC_SETXID
70444 + const struct cred *delayed_cred;
70445 +#endif
70446 + struct dentry *gr_chroot_dentry;
70447 + struct acl_subject_label *acl;
70448 + struct acl_role_label *role;
70449 + struct file *exec_file;
70450 + unsigned long brute_expires;
70451 + u16 acl_role_id;
70452 + /* is this the task that authenticated to the special role */
70453 + u8 acl_sp_role;
70454 + u8 is_writable;
70455 + u8 brute;
70456 + u8 gr_is_chrooted;
70457 +#endif
70458 +
70459 };
70460
70461 +#define MF_PAX_PAGEEXEC 0x01000000 /* Paging based non-executable pages */
70462 +#define MF_PAX_EMUTRAMP 0x02000000 /* Emulate trampolines */
70463 +#define MF_PAX_MPROTECT 0x04000000 /* Restrict mprotect() */
70464 +#define MF_PAX_RANDMMAP 0x08000000 /* Randomize mmap() base */
70465 +/*#define MF_PAX_RANDEXEC 0x10000000*/ /* Randomize ET_EXEC base */
70466 +#define MF_PAX_SEGMEXEC 0x20000000 /* Segmentation based non-executable pages */
70467 +
70468 +#ifdef CONFIG_PAX_SOFTMODE
70469 +extern int pax_softmode;
70470 +#endif
70471 +
70472 +extern int pax_check_flags(unsigned long *);
70473 +
70474 +/* if tsk != current then task_lock must be held on it */
70475 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
70476 +static inline unsigned long pax_get_flags(struct task_struct *tsk)
70477 +{
70478 + if (likely(tsk->mm))
70479 + return tsk->mm->pax_flags;
70480 + else
70481 + return 0UL;
70482 +}
70483 +
70484 +/* if tsk != current then task_lock must be held on it */
70485 +static inline long pax_set_flags(struct task_struct *tsk, unsigned long flags)
70486 +{
70487 + if (likely(tsk->mm)) {
70488 + tsk->mm->pax_flags = flags;
70489 + return 0;
70490 + }
70491 + return -EINVAL;
70492 +}
70493 +#endif
70494 +
70495 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
70496 +extern void pax_set_initial_flags(struct linux_binprm *bprm);
70497 +#elif defined(CONFIG_PAX_HOOK_ACL_FLAGS)
70498 +extern void (*pax_set_initial_flags_func)(struct linux_binprm *bprm);
70499 +#endif
70500 +
70501 +extern void pax_report_fault(struct pt_regs *regs, void *pc, void *sp);
70502 +extern void pax_report_insns(struct pt_regs *regs, void *pc, void *sp);
70503 +extern void pax_report_refcount_overflow(struct pt_regs *regs);
70504 +
70505 /* Future-safe accessor for struct task_struct's cpus_allowed. */
70506 #define tsk_cpus_allowed(tsk) (&(tsk)->cpus_allowed)
70507
70508 @@ -1696,7 +1799,7 @@ struct pid_namespace;
70509 pid_t __task_pid_nr_ns(struct task_struct *task, enum pid_type type,
70510 struct pid_namespace *ns);
70511
70512 -static inline pid_t task_pid_nr(struct task_struct *tsk)
70513 +static inline pid_t task_pid_nr(const struct task_struct *tsk)
70514 {
70515 return tsk->pid;
70516 }
70517 @@ -2155,7 +2258,9 @@ void yield(void);
70518 extern struct exec_domain default_exec_domain;
70519
70520 union thread_union {
70521 +#ifndef CONFIG_X86
70522 struct thread_info thread_info;
70523 +#endif
70524 unsigned long stack[THREAD_SIZE/sizeof(long)];
70525 };
70526
70527 @@ -2188,6 +2293,7 @@ extern struct pid_namespace init_pid_ns;
70528 */
70529
70530 extern struct task_struct *find_task_by_vpid(pid_t nr);
70531 +extern struct task_struct *find_task_by_vpid_unrestricted(pid_t nr);
70532 extern struct task_struct *find_task_by_pid_ns(pid_t nr,
70533 struct pid_namespace *ns);
70534
70535 @@ -2344,7 +2450,7 @@ extern void __cleanup_sighand(struct sighand_struct *);
70536 extern void exit_itimers(struct signal_struct *);
70537 extern void flush_itimer_signals(void);
70538
70539 -extern void do_group_exit(int);
70540 +extern __noreturn void do_group_exit(int);
70541
70542 extern int allow_signal(int);
70543 extern int disallow_signal(int);
70544 @@ -2545,9 +2651,9 @@ static inline unsigned long *end_of_stack(struct task_struct *p)
70545
70546 #endif
70547
70548 -static inline int object_is_on_stack(void *obj)
70549 +static inline int object_starts_on_stack(void *obj)
70550 {
70551 - void *stack = task_stack_page(current);
70552 + const void *stack = task_stack_page(current);
70553
70554 return (obj >= stack) && (obj < (stack + THREAD_SIZE));
70555 }
70556 diff --git a/include/linux/security.h b/include/linux/security.h
70557 index eee7478..290f7ba 100644
70558 --- a/include/linux/security.h
70559 +++ b/include/linux/security.h
70560 @@ -26,6 +26,7 @@
70561 #include <linux/capability.h>
70562 #include <linux/slab.h>
70563 #include <linux/err.h>
70564 +#include <linux/grsecurity.h>
70565
70566 struct linux_binprm;
70567 struct cred;
70568 diff --git a/include/linux/seq_file.h b/include/linux/seq_file.h
70569 index 68a04a3..866e6a1 100644
70570 --- a/include/linux/seq_file.h
70571 +++ b/include/linux/seq_file.h
70572 @@ -26,6 +26,9 @@ struct seq_file {
70573 struct mutex lock;
70574 const struct seq_operations *op;
70575 int poll_event;
70576 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
70577 + u64 exec_id;
70578 +#endif
70579 #ifdef CONFIG_USER_NS
70580 struct user_namespace *user_ns;
70581 #endif
70582 @@ -38,6 +41,7 @@ struct seq_operations {
70583 void * (*next) (struct seq_file *m, void *v, loff_t *pos);
70584 int (*show) (struct seq_file *m, void *v);
70585 };
70586 +typedef struct seq_operations __no_const seq_operations_no_const;
70587
70588 #define SEQ_SKIP 1
70589
70590 diff --git a/include/linux/shm.h b/include/linux/shm.h
70591 index 429c199..4d42e38 100644
70592 --- a/include/linux/shm.h
70593 +++ b/include/linux/shm.h
70594 @@ -21,6 +21,10 @@ struct shmid_kernel /* private to the kernel */
70595
70596 /* The task created the shm object. NULL if the task is dead. */
70597 struct task_struct *shm_creator;
70598 +#ifdef CONFIG_GRKERNSEC
70599 + time_t shm_createtime;
70600 + pid_t shm_lapid;
70601 +#endif
70602 };
70603
70604 /* shm_mode upper byte flags */
70605 diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
70606 index 320e976..fd52553 100644
70607 --- a/include/linux/skbuff.h
70608 +++ b/include/linux/skbuff.h
70609 @@ -590,7 +590,7 @@ extern bool skb_try_coalesce(struct sk_buff *to, struct sk_buff *from,
70610 extern struct sk_buff *__alloc_skb(unsigned int size,
70611 gfp_t priority, int flags, int node);
70612 extern struct sk_buff *build_skb(void *data, unsigned int frag_size);
70613 -static inline struct sk_buff *alloc_skb(unsigned int size,
70614 +static inline struct sk_buff * __intentional_overflow(0) alloc_skb(unsigned int size,
70615 gfp_t priority)
70616 {
70617 return __alloc_skb(size, priority, 0, NUMA_NO_NODE);
70618 @@ -700,7 +700,7 @@ static inline struct skb_shared_hwtstamps *skb_hwtstamps(struct sk_buff *skb)
70619 */
70620 static inline int skb_queue_empty(const struct sk_buff_head *list)
70621 {
70622 - return list->next == (struct sk_buff *)list;
70623 + return list->next == (const struct sk_buff *)list;
70624 }
70625
70626 /**
70627 @@ -713,7 +713,7 @@ static inline int skb_queue_empty(const struct sk_buff_head *list)
70628 static inline bool skb_queue_is_last(const struct sk_buff_head *list,
70629 const struct sk_buff *skb)
70630 {
70631 - return skb->next == (struct sk_buff *)list;
70632 + return skb->next == (const struct sk_buff *)list;
70633 }
70634
70635 /**
70636 @@ -726,7 +726,7 @@ static inline bool skb_queue_is_last(const struct sk_buff_head *list,
70637 static inline bool skb_queue_is_first(const struct sk_buff_head *list,
70638 const struct sk_buff *skb)
70639 {
70640 - return skb->prev == (struct sk_buff *)list;
70641 + return skb->prev == (const struct sk_buff *)list;
70642 }
70643
70644 /**
70645 @@ -1722,7 +1722,7 @@ static inline int pskb_network_may_pull(struct sk_buff *skb, unsigned int len)
70646 * NET_IP_ALIGN(2) + ethernet_header(14) + IP_header(20/40) + ports(8)
70647 */
70648 #ifndef NET_SKB_PAD
70649 -#define NET_SKB_PAD max(32, L1_CACHE_BYTES)
70650 +#define NET_SKB_PAD max(_AC(32,UL), L1_CACHE_BYTES)
70651 #endif
70652
70653 extern int ___pskb_trim(struct sk_buff *skb, unsigned int len);
70654 @@ -2300,7 +2300,7 @@ extern struct sk_buff *skb_recv_datagram(struct sock *sk, unsigned flags,
70655 int noblock, int *err);
70656 extern unsigned int datagram_poll(struct file *file, struct socket *sock,
70657 struct poll_table_struct *wait);
70658 -extern int skb_copy_datagram_iovec(const struct sk_buff *from,
70659 +extern int __intentional_overflow(0) skb_copy_datagram_iovec(const struct sk_buff *from,
70660 int offset, struct iovec *to,
70661 int size);
70662 extern int skb_copy_and_csum_datagram_iovec(struct sk_buff *skb,
70663 diff --git a/include/linux/slab.h b/include/linux/slab.h
70664 index 5d168d7..720bff3 100644
70665 --- a/include/linux/slab.h
70666 +++ b/include/linux/slab.h
70667 @@ -12,13 +12,20 @@
70668 #include <linux/gfp.h>
70669 #include <linux/types.h>
70670 #include <linux/workqueue.h>
70671 -
70672 +#include <linux/err.h>
70673
70674 /*
70675 * Flags to pass to kmem_cache_create().
70676 * The ones marked DEBUG are only valid if CONFIG_SLAB_DEBUG is set.
70677 */
70678 #define SLAB_DEBUG_FREE 0x00000100UL /* DEBUG: Perform (expensive) checks on free */
70679 +
70680 +#ifdef CONFIG_PAX_USERCOPY_SLABS
70681 +#define SLAB_USERCOPY 0x00000200UL /* PaX: Allow copying objs to/from userland */
70682 +#else
70683 +#define SLAB_USERCOPY 0x00000000UL
70684 +#endif
70685 +
70686 #define SLAB_RED_ZONE 0x00000400UL /* DEBUG: Red zone objs in a cache */
70687 #define SLAB_POISON 0x00000800UL /* DEBUG: Poison objects */
70688 #define SLAB_HWCACHE_ALIGN 0x00002000UL /* Align objs on cache lines */
70689 @@ -89,10 +96,13 @@
70690 * ZERO_SIZE_PTR can be passed to kfree though in the same way that NULL can.
70691 * Both make kfree a no-op.
70692 */
70693 -#define ZERO_SIZE_PTR ((void *)16)
70694 +#define ZERO_SIZE_PTR \
70695 +({ \
70696 + BUILD_BUG_ON(!(MAX_ERRNO & ~PAGE_MASK));\
70697 + (void *)(-MAX_ERRNO-1L); \
70698 +})
70699
70700 -#define ZERO_OR_NULL_PTR(x) ((unsigned long)(x) <= \
70701 - (unsigned long)ZERO_SIZE_PTR)
70702 +#define ZERO_OR_NULL_PTR(x) ((unsigned long)(x) - 1 >= (unsigned long)ZERO_SIZE_PTR - 1)
70703
70704 /*
70705 * Common fields provided in kmem_cache by all slab allocators
70706 @@ -112,7 +122,7 @@ struct kmem_cache {
70707 unsigned int align; /* Alignment as calculated */
70708 unsigned long flags; /* Active flags on the slab */
70709 const char *name; /* Slab name for sysfs */
70710 - int refcount; /* Use counter */
70711 + atomic_t refcount; /* Use counter */
70712 void (*ctor)(void *); /* Called on object slot creation */
70713 struct list_head list; /* List of all slab caches on the system */
70714 };
70715 @@ -232,6 +242,8 @@ void * __must_check krealloc(const void *, size_t, gfp_t);
70716 void kfree(const void *);
70717 void kzfree(const void *);
70718 size_t ksize(const void *);
70719 +const char *check_heap_object(const void *ptr, unsigned long n);
70720 +bool is_usercopy_object(const void *ptr);
70721
70722 /*
70723 * Allocator specific definitions. These are mainly used to establish optimized
70724 @@ -311,6 +323,7 @@ size_t ksize(const void *);
70725 * for general use, and so are not documented here. For a full list of
70726 * potential flags, always refer to linux/gfp.h.
70727 */
70728 +
70729 static inline void *kmalloc_array(size_t n, size_t size, gfp_t flags)
70730 {
70731 if (size != 0 && n > SIZE_MAX / size)
70732 @@ -370,7 +383,7 @@ static inline void *kmem_cache_alloc_node(struct kmem_cache *cachep,
70733 #if defined(CONFIG_DEBUG_SLAB) || defined(CONFIG_SLUB) || \
70734 (defined(CONFIG_SLAB) && defined(CONFIG_TRACING)) || \
70735 (defined(CONFIG_SLOB) && defined(CONFIG_TRACING))
70736 -extern void *__kmalloc_track_caller(size_t, gfp_t, unsigned long);
70737 +extern void *__kmalloc_track_caller(size_t, gfp_t, unsigned long) __size_overflow(1);
70738 #define kmalloc_track_caller(size, flags) \
70739 __kmalloc_track_caller(size, flags, _RET_IP_)
70740 #else
70741 @@ -390,7 +403,7 @@ extern void *__kmalloc_track_caller(size_t, gfp_t, unsigned long);
70742 #if defined(CONFIG_DEBUG_SLAB) || defined(CONFIG_SLUB) || \
70743 (defined(CONFIG_SLAB) && defined(CONFIG_TRACING)) || \
70744 (defined(CONFIG_SLOB) && defined(CONFIG_TRACING))
70745 -extern void *__kmalloc_node_track_caller(size_t, gfp_t, int, unsigned long);
70746 +extern void *__kmalloc_node_track_caller(size_t, gfp_t, int, unsigned long) __size_overflow(1);
70747 #define kmalloc_node_track_caller(size, flags, node) \
70748 __kmalloc_node_track_caller(size, flags, node, \
70749 _RET_IP_)
70750 diff --git a/include/linux/slab_def.h b/include/linux/slab_def.h
70751 index 8bb6e0e..8eb0dbe 100644
70752 --- a/include/linux/slab_def.h
70753 +++ b/include/linux/slab_def.h
70754 @@ -52,7 +52,7 @@ struct kmem_cache {
70755 /* 4) cache creation/removal */
70756 const char *name;
70757 struct list_head list;
70758 - int refcount;
70759 + atomic_t refcount;
70760 int object_size;
70761 int align;
70762
70763 @@ -68,10 +68,10 @@ struct kmem_cache {
70764 unsigned long node_allocs;
70765 unsigned long node_frees;
70766 unsigned long node_overflow;
70767 - atomic_t allochit;
70768 - atomic_t allocmiss;
70769 - atomic_t freehit;
70770 - atomic_t freemiss;
70771 + atomic_unchecked_t allochit;
70772 + atomic_unchecked_t allocmiss;
70773 + atomic_unchecked_t freehit;
70774 + atomic_unchecked_t freemiss;
70775
70776 /*
70777 * If debugging is enabled, then the allocator can add additional
70778 @@ -111,11 +111,16 @@ struct cache_sizes {
70779 #ifdef CONFIG_ZONE_DMA
70780 struct kmem_cache *cs_dmacachep;
70781 #endif
70782 +
70783 +#ifdef CONFIG_PAX_USERCOPY_SLABS
70784 + struct kmem_cache *cs_usercopycachep;
70785 +#endif
70786 +
70787 };
70788 extern struct cache_sizes malloc_sizes[];
70789
70790 void *kmem_cache_alloc(struct kmem_cache *, gfp_t);
70791 -void *__kmalloc(size_t size, gfp_t flags);
70792 +void *__kmalloc(size_t size, gfp_t flags) __size_overflow(1);
70793
70794 #ifdef CONFIG_TRACING
70795 extern void *kmem_cache_alloc_trace(struct kmem_cache *, gfp_t, size_t);
70796 @@ -152,6 +157,13 @@ found:
70797 cachep = malloc_sizes[i].cs_dmacachep;
70798 else
70799 #endif
70800 +
70801 +#ifdef CONFIG_PAX_USERCOPY_SLABS
70802 + if (flags & GFP_USERCOPY)
70803 + cachep = malloc_sizes[i].cs_usercopycachep;
70804 + else
70805 +#endif
70806 +
70807 cachep = malloc_sizes[i].cs_cachep;
70808
70809 ret = kmem_cache_alloc_trace(cachep, flags, size);
70810 @@ -162,7 +174,7 @@ found:
70811 }
70812
70813 #ifdef CONFIG_NUMA
70814 -extern void *__kmalloc_node(size_t size, gfp_t flags, int node);
70815 +extern void *__kmalloc_node(size_t size, gfp_t flags, int node) __size_overflow(1);
70816 extern void *kmem_cache_alloc_node(struct kmem_cache *, gfp_t flags, int node);
70817
70818 #ifdef CONFIG_TRACING
70819 @@ -205,6 +217,13 @@ found:
70820 cachep = malloc_sizes[i].cs_dmacachep;
70821 else
70822 #endif
70823 +
70824 +#ifdef CONFIG_PAX_USERCOPY_SLABS
70825 + if (flags & GFP_USERCOPY)
70826 + cachep = malloc_sizes[i].cs_usercopycachep;
70827 + else
70828 +#endif
70829 +
70830 cachep = malloc_sizes[i].cs_cachep;
70831
70832 return kmem_cache_alloc_node_trace(cachep, flags, node, size);
70833 diff --git a/include/linux/slob_def.h b/include/linux/slob_def.h
70834 index f28e14a..7831211 100644
70835 --- a/include/linux/slob_def.h
70836 +++ b/include/linux/slob_def.h
70837 @@ -11,7 +11,7 @@ static __always_inline void *kmem_cache_alloc(struct kmem_cache *cachep,
70838 return kmem_cache_alloc_node(cachep, flags, NUMA_NO_NODE);
70839 }
70840
70841 -void *__kmalloc_node(size_t size, gfp_t flags, int node);
70842 +void *__kmalloc_node(size_t size, gfp_t flags, int node) __size_overflow(1);
70843
70844 static __always_inline void *kmalloc_node(size_t size, gfp_t flags, int node)
70845 {
70846 @@ -31,7 +31,7 @@ static __always_inline void *kmalloc(size_t size, gfp_t flags)
70847 return __kmalloc_node(size, flags, NUMA_NO_NODE);
70848 }
70849
70850 -static __always_inline void *__kmalloc(size_t size, gfp_t flags)
70851 +static __always_inline __size_overflow(1) void *__kmalloc(size_t size, gfp_t flags)
70852 {
70853 return kmalloc(size, flags);
70854 }
70855 diff --git a/include/linux/slub_def.h b/include/linux/slub_def.h
70856 index 9db4825..ed42fb5 100644
70857 --- a/include/linux/slub_def.h
70858 +++ b/include/linux/slub_def.h
70859 @@ -91,7 +91,7 @@ struct kmem_cache {
70860 struct kmem_cache_order_objects max;
70861 struct kmem_cache_order_objects min;
70862 gfp_t allocflags; /* gfp flags to use on each alloc */
70863 - int refcount; /* Refcount for slab cache destroy */
70864 + atomic_t refcount; /* Refcount for slab cache destroy */
70865 void (*ctor)(void *);
70866 int inuse; /* Offset to metadata */
70867 int align; /* Alignment */
70868 @@ -156,7 +156,7 @@ extern struct kmem_cache *kmalloc_caches[SLUB_PAGE_SHIFT];
70869 * Sorry that the following has to be that ugly but some versions of GCC
70870 * have trouble with constant propagation and loops.
70871 */
70872 -static __always_inline int kmalloc_index(size_t size)
70873 +static __always_inline __size_overflow(1) int kmalloc_index(size_t size)
70874 {
70875 if (!size)
70876 return 0;
70877 @@ -221,7 +221,7 @@ static __always_inline struct kmem_cache *kmalloc_slab(size_t size)
70878 }
70879
70880 void *kmem_cache_alloc(struct kmem_cache *, gfp_t);
70881 -void *__kmalloc(size_t size, gfp_t flags);
70882 +void *__kmalloc(size_t size, gfp_t flags) __alloc_size(1) __size_overflow(1);
70883
70884 static __always_inline void *
70885 kmalloc_order(size_t size, gfp_t flags, unsigned int order)
70886 @@ -265,7 +265,7 @@ kmalloc_order_trace(size_t size, gfp_t flags, unsigned int order)
70887 }
70888 #endif
70889
70890 -static __always_inline void *kmalloc_large(size_t size, gfp_t flags)
70891 +static __always_inline __size_overflow(1) void *kmalloc_large(size_t size, gfp_t flags)
70892 {
70893 unsigned int order = get_order(size);
70894 return kmalloc_order_trace(size, flags, order);
70895 @@ -290,7 +290,7 @@ static __always_inline void *kmalloc(size_t size, gfp_t flags)
70896 }
70897
70898 #ifdef CONFIG_NUMA
70899 -void *__kmalloc_node(size_t size, gfp_t flags, int node);
70900 +void *__kmalloc_node(size_t size, gfp_t flags, int node) __size_overflow(1);
70901 void *kmem_cache_alloc_node(struct kmem_cache *, gfp_t flags, int node);
70902
70903 #ifdef CONFIG_TRACING
70904 diff --git a/include/linux/sock_diag.h b/include/linux/sock_diag.h
70905 index e8d702e..0a56eb4 100644
70906 --- a/include/linux/sock_diag.h
70907 +++ b/include/linux/sock_diag.h
70908 @@ -10,7 +10,7 @@ struct sock;
70909 struct sock_diag_handler {
70910 __u8 family;
70911 int (*dump)(struct sk_buff *skb, struct nlmsghdr *nlh);
70912 -};
70913 +} __do_const;
70914
70915 int sock_diag_register(const struct sock_diag_handler *h);
70916 void sock_diag_unregister(const struct sock_diag_handler *h);
70917 diff --git a/include/linux/sonet.h b/include/linux/sonet.h
70918 index 680f9a3..f13aeb0 100644
70919 --- a/include/linux/sonet.h
70920 +++ b/include/linux/sonet.h
70921 @@ -7,7 +7,7 @@
70922 #include <uapi/linux/sonet.h>
70923
70924 struct k_sonet_stats {
70925 -#define __HANDLE_ITEM(i) atomic_t i
70926 +#define __HANDLE_ITEM(i) atomic_unchecked_t i
70927 __SONET_ITEMS
70928 #undef __HANDLE_ITEM
70929 };
70930 diff --git a/include/linux/sunrpc/clnt.h b/include/linux/sunrpc/clnt.h
70931 index 34206b8..3db7f1c 100644
70932 --- a/include/linux/sunrpc/clnt.h
70933 +++ b/include/linux/sunrpc/clnt.h
70934 @@ -96,7 +96,7 @@ struct rpc_procinfo {
70935 unsigned int p_timer; /* Which RTT timer to use */
70936 u32 p_statidx; /* Which procedure to account */
70937 const char * p_name; /* name of procedure */
70938 -};
70939 +} __do_const;
70940
70941 #ifdef __KERNEL__
70942
70943 @@ -176,9 +176,9 @@ static inline unsigned short rpc_get_port(const struct sockaddr *sap)
70944 {
70945 switch (sap->sa_family) {
70946 case AF_INET:
70947 - return ntohs(((struct sockaddr_in *)sap)->sin_port);
70948 + return ntohs(((const struct sockaddr_in *)sap)->sin_port);
70949 case AF_INET6:
70950 - return ntohs(((struct sockaddr_in6 *)sap)->sin6_port);
70951 + return ntohs(((const struct sockaddr_in6 *)sap)->sin6_port);
70952 }
70953 return 0;
70954 }
70955 @@ -211,7 +211,7 @@ static inline bool __rpc_cmp_addr4(const struct sockaddr *sap1,
70956 static inline bool __rpc_copy_addr4(struct sockaddr *dst,
70957 const struct sockaddr *src)
70958 {
70959 - const struct sockaddr_in *ssin = (struct sockaddr_in *) src;
70960 + const struct sockaddr_in *ssin = (const struct sockaddr_in *) src;
70961 struct sockaddr_in *dsin = (struct sockaddr_in *) dst;
70962
70963 dsin->sin_family = ssin->sin_family;
70964 @@ -314,7 +314,7 @@ static inline u32 rpc_get_scope_id(const struct sockaddr *sa)
70965 if (sa->sa_family != AF_INET6)
70966 return 0;
70967
70968 - return ((struct sockaddr_in6 *) sa)->sin6_scope_id;
70969 + return ((const struct sockaddr_in6 *) sa)->sin6_scope_id;
70970 }
70971
70972 #endif /* __KERNEL__ */
70973 diff --git a/include/linux/sunrpc/svc.h b/include/linux/sunrpc/svc.h
70974 index 676ddf5..4c519a1 100644
70975 --- a/include/linux/sunrpc/svc.h
70976 +++ b/include/linux/sunrpc/svc.h
70977 @@ -410,7 +410,7 @@ struct svc_procedure {
70978 unsigned int pc_count; /* call count */
70979 unsigned int pc_cachetype; /* cache info (NFS) */
70980 unsigned int pc_xdrressize; /* maximum size of XDR reply */
70981 -};
70982 +} __do_const;
70983
70984 /*
70985 * Function prototypes.
70986 diff --git a/include/linux/sunrpc/svc_rdma.h b/include/linux/sunrpc/svc_rdma.h
70987 index 0b8e3e6..33e0a01 100644
70988 --- a/include/linux/sunrpc/svc_rdma.h
70989 +++ b/include/linux/sunrpc/svc_rdma.h
70990 @@ -53,15 +53,15 @@ extern unsigned int svcrdma_ord;
70991 extern unsigned int svcrdma_max_requests;
70992 extern unsigned int svcrdma_max_req_size;
70993
70994 -extern atomic_t rdma_stat_recv;
70995 -extern atomic_t rdma_stat_read;
70996 -extern atomic_t rdma_stat_write;
70997 -extern atomic_t rdma_stat_sq_starve;
70998 -extern atomic_t rdma_stat_rq_starve;
70999 -extern atomic_t rdma_stat_rq_poll;
71000 -extern atomic_t rdma_stat_rq_prod;
71001 -extern atomic_t rdma_stat_sq_poll;
71002 -extern atomic_t rdma_stat_sq_prod;
71003 +extern atomic_unchecked_t rdma_stat_recv;
71004 +extern atomic_unchecked_t rdma_stat_read;
71005 +extern atomic_unchecked_t rdma_stat_write;
71006 +extern atomic_unchecked_t rdma_stat_sq_starve;
71007 +extern atomic_unchecked_t rdma_stat_rq_starve;
71008 +extern atomic_unchecked_t rdma_stat_rq_poll;
71009 +extern atomic_unchecked_t rdma_stat_rq_prod;
71010 +extern atomic_unchecked_t rdma_stat_sq_poll;
71011 +extern atomic_unchecked_t rdma_stat_sq_prod;
71012
71013 #define RPCRDMA_VERSION 1
71014
71015 diff --git a/include/linux/sunrpc/svcauth.h b/include/linux/sunrpc/svcauth.h
71016 index dd74084a..7f509d5 100644
71017 --- a/include/linux/sunrpc/svcauth.h
71018 +++ b/include/linux/sunrpc/svcauth.h
71019 @@ -109,7 +109,7 @@ struct auth_ops {
71020 int (*release)(struct svc_rqst *rq);
71021 void (*domain_release)(struct auth_domain *);
71022 int (*set_client)(struct svc_rqst *rq);
71023 -};
71024 +} __do_const;
71025
71026 #define SVC_GARBAGE 1
71027 #define SVC_SYSERR 2
71028 diff --git a/include/linux/swiotlb.h b/include/linux/swiotlb.h
71029 index 071d62c..4ccc7ac 100644
71030 --- a/include/linux/swiotlb.h
71031 +++ b/include/linux/swiotlb.h
71032 @@ -59,7 +59,8 @@ extern void
71033
71034 extern void
71035 swiotlb_free_coherent(struct device *hwdev, size_t size,
71036 - void *vaddr, dma_addr_t dma_handle);
71037 + void *vaddr, dma_addr_t dma_handle,
71038 + struct dma_attrs *attrs);
71039
71040 extern dma_addr_t swiotlb_map_page(struct device *dev, struct page *page,
71041 unsigned long offset, size_t size,
71042 diff --git a/include/linux/syscore_ops.h b/include/linux/syscore_ops.h
71043 index 27b3b0b..e093dd9 100644
71044 --- a/include/linux/syscore_ops.h
71045 +++ b/include/linux/syscore_ops.h
71046 @@ -16,7 +16,7 @@ struct syscore_ops {
71047 int (*suspend)(void);
71048 void (*resume)(void);
71049 void (*shutdown)(void);
71050 -};
71051 +} __do_const;
71052
71053 extern void register_syscore_ops(struct syscore_ops *ops);
71054 extern void unregister_syscore_ops(struct syscore_ops *ops);
71055 diff --git a/include/linux/sysctl.h b/include/linux/sysctl.h
71056 index 14a8ff2..af52bad 100644
71057 --- a/include/linux/sysctl.h
71058 +++ b/include/linux/sysctl.h
71059 @@ -34,13 +34,13 @@ struct ctl_table_root;
71060 struct ctl_table_header;
71061 struct ctl_dir;
71062
71063 -typedef struct ctl_table ctl_table;
71064 -
71065 typedef int proc_handler (struct ctl_table *ctl, int write,
71066 void __user *buffer, size_t *lenp, loff_t *ppos);
71067
71068 extern int proc_dostring(struct ctl_table *, int,
71069 void __user *, size_t *, loff_t *);
71070 +extern int proc_dostring_modpriv(struct ctl_table *, int,
71071 + void __user *, size_t *, loff_t *);
71072 extern int proc_dointvec(struct ctl_table *, int,
71073 void __user *, size_t *, loff_t *);
71074 extern int proc_dointvec_minmax(struct ctl_table *, int,
71075 @@ -115,7 +115,9 @@ struct ctl_table
71076 struct ctl_table_poll *poll;
71077 void *extra1;
71078 void *extra2;
71079 -};
71080 +} __do_const;
71081 +typedef struct ctl_table __no_const ctl_table_no_const;
71082 +typedef struct ctl_table ctl_table;
71083
71084 struct ctl_node {
71085 struct rb_node node;
71086 diff --git a/include/linux/sysfs.h b/include/linux/sysfs.h
71087 index 381f06d..dc16cc7 100644
71088 --- a/include/linux/sysfs.h
71089 +++ b/include/linux/sysfs.h
71090 @@ -31,7 +31,8 @@ struct attribute {
71091 struct lock_class_key *key;
71092 struct lock_class_key skey;
71093 #endif
71094 -};
71095 +} __do_const;
71096 +typedef struct attribute __no_const attribute_no_const;
71097
71098 /**
71099 * sysfs_attr_init - initialize a dynamically allocated sysfs attribute
71100 @@ -59,8 +60,8 @@ struct attribute_group {
71101 umode_t (*is_visible)(struct kobject *,
71102 struct attribute *, int);
71103 struct attribute **attrs;
71104 -};
71105 -
71106 +} __do_const;
71107 +typedef struct attribute_group __no_const attribute_group_no_const;
71108
71109
71110 /**
71111 @@ -107,7 +108,8 @@ struct bin_attribute {
71112 char *, loff_t, size_t);
71113 int (*mmap)(struct file *, struct kobject *, struct bin_attribute *attr,
71114 struct vm_area_struct *vma);
71115 -};
71116 +} __do_const;
71117 +typedef struct bin_attribute __no_const bin_attribute_no_const;
71118
71119 /**
71120 * sysfs_bin_attr_init - initialize a dynamically allocated bin_attribute
71121 diff --git a/include/linux/sysrq.h b/include/linux/sysrq.h
71122 index 7faf933..4657127 100644
71123 --- a/include/linux/sysrq.h
71124 +++ b/include/linux/sysrq.h
71125 @@ -15,7 +15,9 @@
71126 #define _LINUX_SYSRQ_H
71127
71128 #include <linux/errno.h>
71129 +#include <linux/compiler.h>
71130 #include <linux/types.h>
71131 +#include <linux/compiler.h>
71132
71133 /* Enable/disable SYSRQ support by default (0==no, 1==yes). */
71134 #define SYSRQ_DEFAULT_ENABLE 1
71135 @@ -36,7 +38,7 @@ struct sysrq_key_op {
71136 char *help_msg;
71137 char *action_msg;
71138 int enable_mask;
71139 -};
71140 +} __do_const;
71141
71142 #ifdef CONFIG_MAGIC_SYSRQ
71143
71144 diff --git a/include/linux/thread_info.h b/include/linux/thread_info.h
71145 index e7e0473..39b7b52 100644
71146 --- a/include/linux/thread_info.h
71147 +++ b/include/linux/thread_info.h
71148 @@ -148,6 +148,15 @@ static inline bool test_and_clear_restore_sigmask(void)
71149 #error "no set_restore_sigmask() provided and default one won't work"
71150 #endif
71151
71152 +extern void __check_object_size(const void *ptr, unsigned long n, bool to);
71153 +static inline void check_object_size(const void *ptr, unsigned long n, bool to)
71154 +{
71155 +#ifndef CONFIG_PAX_USERCOPY_DEBUG
71156 + if (!__builtin_constant_p(n))
71157 +#endif
71158 + __check_object_size(ptr, n, to);
71159 +}
71160 +
71161 #endif /* __KERNEL__ */
71162
71163 #endif /* _LINUX_THREAD_INFO_H */
71164 diff --git a/include/linux/tty.h b/include/linux/tty.h
71165 index 8db1b56..c16a040 100644
71166 --- a/include/linux/tty.h
71167 +++ b/include/linux/tty.h
71168 @@ -194,7 +194,7 @@ struct tty_port {
71169 const struct tty_port_operations *ops; /* Port operations */
71170 spinlock_t lock; /* Lock protecting tty field */
71171 int blocked_open; /* Waiting to open */
71172 - int count; /* Usage count */
71173 + atomic_t count; /* Usage count */
71174 wait_queue_head_t open_wait; /* Open waiters */
71175 wait_queue_head_t close_wait; /* Close waiters */
71176 wait_queue_head_t delta_msr_wait; /* Modem status change */
71177 @@ -490,7 +490,7 @@ extern int tty_port_open(struct tty_port *port,
71178 struct tty_struct *tty, struct file *filp);
71179 static inline int tty_port_users(struct tty_port *port)
71180 {
71181 - return port->count + port->blocked_open;
71182 + return atomic_read(&port->count) + port->blocked_open;
71183 }
71184
71185 extern int tty_register_ldisc(int disc, struct tty_ldisc_ops *new_ldisc);
71186 diff --git a/include/linux/tty_driver.h b/include/linux/tty_driver.h
71187 index dd976cf..e272742 100644
71188 --- a/include/linux/tty_driver.h
71189 +++ b/include/linux/tty_driver.h
71190 @@ -284,7 +284,7 @@ struct tty_operations {
71191 void (*poll_put_char)(struct tty_driver *driver, int line, char ch);
71192 #endif
71193 const struct file_operations *proc_fops;
71194 -};
71195 +} __do_const;
71196
71197 struct tty_driver {
71198 int magic; /* magic number for this structure */
71199 diff --git a/include/linux/tty_ldisc.h b/include/linux/tty_ldisc.h
71200 index fb79dd8d..07d4773 100644
71201 --- a/include/linux/tty_ldisc.h
71202 +++ b/include/linux/tty_ldisc.h
71203 @@ -149,7 +149,7 @@ struct tty_ldisc_ops {
71204
71205 struct module *owner;
71206
71207 - int refcount;
71208 + atomic_t refcount;
71209 };
71210
71211 struct tty_ldisc {
71212 diff --git a/include/linux/types.h b/include/linux/types.h
71213 index 4d118ba..c3ee9bf 100644
71214 --- a/include/linux/types.h
71215 +++ b/include/linux/types.h
71216 @@ -176,10 +176,26 @@ typedef struct {
71217 int counter;
71218 } atomic_t;
71219
71220 +#ifdef CONFIG_PAX_REFCOUNT
71221 +typedef struct {
71222 + int counter;
71223 +} atomic_unchecked_t;
71224 +#else
71225 +typedef atomic_t atomic_unchecked_t;
71226 +#endif
71227 +
71228 #ifdef CONFIG_64BIT
71229 typedef struct {
71230 long counter;
71231 } atomic64_t;
71232 +
71233 +#ifdef CONFIG_PAX_REFCOUNT
71234 +typedef struct {
71235 + long counter;
71236 +} atomic64_unchecked_t;
71237 +#else
71238 +typedef atomic64_t atomic64_unchecked_t;
71239 +#endif
71240 #endif
71241
71242 struct list_head {
71243 diff --git a/include/linux/uaccess.h b/include/linux/uaccess.h
71244 index 5ca0951..ab496a5 100644
71245 --- a/include/linux/uaccess.h
71246 +++ b/include/linux/uaccess.h
71247 @@ -76,11 +76,11 @@ static inline unsigned long __copy_from_user_nocache(void *to,
71248 long ret; \
71249 mm_segment_t old_fs = get_fs(); \
71250 \
71251 - set_fs(KERNEL_DS); \
71252 pagefault_disable(); \
71253 - ret = __copy_from_user_inatomic(&(retval), (__force typeof(retval) __user *)(addr), sizeof(retval)); \
71254 - pagefault_enable(); \
71255 + set_fs(KERNEL_DS); \
71256 + ret = __copy_from_user_inatomic(&(retval), (typeof(retval) __force_user *)(addr), sizeof(retval)); \
71257 set_fs(old_fs); \
71258 + pagefault_enable(); \
71259 ret; \
71260 })
71261
71262 diff --git a/include/linux/uidgid.h b/include/linux/uidgid.h
71263 index 8e522cbc..aa8572d 100644
71264 --- a/include/linux/uidgid.h
71265 +++ b/include/linux/uidgid.h
71266 @@ -197,4 +197,9 @@ static inline bool kgid_has_mapping(struct user_namespace *ns, kgid_t gid)
71267
71268 #endif /* CONFIG_USER_NS */
71269
71270 +#define GR_GLOBAL_UID(x) from_kuid_munged(&init_user_ns, (x))
71271 +#define GR_GLOBAL_GID(x) from_kgid_munged(&init_user_ns, (x))
71272 +#define gr_is_global_root(x) uid_eq((x), GLOBAL_ROOT_UID)
71273 +#define gr_is_global_nonroot(x) (!uid_eq((x), GLOBAL_ROOT_UID))
71274 +
71275 #endif /* _LINUX_UIDGID_H */
71276 diff --git a/include/linux/unaligned/access_ok.h b/include/linux/unaligned/access_ok.h
71277 index 99c1b4d..562e6f3 100644
71278 --- a/include/linux/unaligned/access_ok.h
71279 +++ b/include/linux/unaligned/access_ok.h
71280 @@ -4,34 +4,34 @@
71281 #include <linux/kernel.h>
71282 #include <asm/byteorder.h>
71283
71284 -static inline u16 get_unaligned_le16(const void *p)
71285 +static inline u16 __intentional_overflow(-1) get_unaligned_le16(const void *p)
71286 {
71287 - return le16_to_cpup((__le16 *)p);
71288 + return le16_to_cpup((const __le16 *)p);
71289 }
71290
71291 -static inline u32 get_unaligned_le32(const void *p)
71292 +static inline u32 __intentional_overflow(-1) get_unaligned_le32(const void *p)
71293 {
71294 - return le32_to_cpup((__le32 *)p);
71295 + return le32_to_cpup((const __le32 *)p);
71296 }
71297
71298 -static inline u64 get_unaligned_le64(const void *p)
71299 +static inline u64 __intentional_overflow(-1) get_unaligned_le64(const void *p)
71300 {
71301 - return le64_to_cpup((__le64 *)p);
71302 + return le64_to_cpup((const __le64 *)p);
71303 }
71304
71305 -static inline u16 get_unaligned_be16(const void *p)
71306 +static inline u16 __intentional_overflow(-1) get_unaligned_be16(const void *p)
71307 {
71308 - return be16_to_cpup((__be16 *)p);
71309 + return be16_to_cpup((const __be16 *)p);
71310 }
71311
71312 -static inline u32 get_unaligned_be32(const void *p)
71313 +static inline u32 __intentional_overflow(-1) get_unaligned_be32(const void *p)
71314 {
71315 - return be32_to_cpup((__be32 *)p);
71316 + return be32_to_cpup((const __be32 *)p);
71317 }
71318
71319 -static inline u64 get_unaligned_be64(const void *p)
71320 +static inline u64 __intentional_overflow(-1) get_unaligned_be64(const void *p)
71321 {
71322 - return be64_to_cpup((__be64 *)p);
71323 + return be64_to_cpup((const __be64 *)p);
71324 }
71325
71326 static inline void put_unaligned_le16(u16 val, void *p)
71327 diff --git a/include/linux/usb.h b/include/linux/usb.h
71328 index 4d22d0f..8d0e8f8 100644
71329 --- a/include/linux/usb.h
71330 +++ b/include/linux/usb.h
71331 @@ -554,7 +554,7 @@ struct usb_device {
71332 int maxchild;
71333
71334 u32 quirks;
71335 - atomic_t urbnum;
71336 + atomic_unchecked_t urbnum;
71337
71338 unsigned long active_duration;
71339
71340 @@ -1604,7 +1604,7 @@ void usb_buffer_unmap_sg(const struct usb_device *dev, int is_in,
71341
71342 extern int usb_control_msg(struct usb_device *dev, unsigned int pipe,
71343 __u8 request, __u8 requesttype, __u16 value, __u16 index,
71344 - void *data, __u16 size, int timeout);
71345 + void *data, __u16 size, int timeout) __intentional_overflow(-1);
71346 extern int usb_interrupt_msg(struct usb_device *usb_dev, unsigned int pipe,
71347 void *data, int len, int *actual_length, int timeout);
71348 extern int usb_bulk_msg(struct usb_device *usb_dev, unsigned int pipe,
71349 diff --git a/include/linux/usb/renesas_usbhs.h b/include/linux/usb/renesas_usbhs.h
71350 index c5d36c6..108f4f9 100644
71351 --- a/include/linux/usb/renesas_usbhs.h
71352 +++ b/include/linux/usb/renesas_usbhs.h
71353 @@ -39,7 +39,7 @@ enum {
71354 */
71355 struct renesas_usbhs_driver_callback {
71356 int (*notify_hotplug)(struct platform_device *pdev);
71357 -};
71358 +} __no_const;
71359
71360 /*
71361 * callback functions for platform
71362 diff --git a/include/linux/user_namespace.h b/include/linux/user_namespace.h
71363 index b9bd2e6..4ce0093 100644
71364 --- a/include/linux/user_namespace.h
71365 +++ b/include/linux/user_namespace.h
71366 @@ -21,7 +21,7 @@ struct user_namespace {
71367 struct uid_gid_map uid_map;
71368 struct uid_gid_map gid_map;
71369 struct uid_gid_map projid_map;
71370 - struct kref kref;
71371 + atomic_t count;
71372 struct user_namespace *parent;
71373 kuid_t owner;
71374 kgid_t group;
71375 @@ -35,18 +35,18 @@ extern struct user_namespace init_user_ns;
71376 static inline struct user_namespace *get_user_ns(struct user_namespace *ns)
71377 {
71378 if (ns)
71379 - kref_get(&ns->kref);
71380 + atomic_inc(&ns->count);
71381 return ns;
71382 }
71383
71384 extern int create_user_ns(struct cred *new);
71385 extern int unshare_userns(unsigned long unshare_flags, struct cred **new_cred);
71386 -extern void free_user_ns(struct kref *kref);
71387 +extern void free_user_ns(struct user_namespace *ns);
71388
71389 static inline void put_user_ns(struct user_namespace *ns)
71390 {
71391 - if (ns)
71392 - kref_put(&ns->kref, free_user_ns);
71393 + if (ns && atomic_dec_and_test(&ns->count))
71394 + free_user_ns(ns);
71395 }
71396
71397 struct seq_operations;
71398 diff --git a/include/linux/vermagic.h b/include/linux/vermagic.h
71399 index 6f8fbcf..8259001 100644
71400 --- a/include/linux/vermagic.h
71401 +++ b/include/linux/vermagic.h
71402 @@ -25,9 +25,35 @@
71403 #define MODULE_ARCH_VERMAGIC ""
71404 #endif
71405
71406 +#ifdef CONFIG_PAX_REFCOUNT
71407 +#define MODULE_PAX_REFCOUNT "REFCOUNT "
71408 +#else
71409 +#define MODULE_PAX_REFCOUNT ""
71410 +#endif
71411 +
71412 +#ifdef CONSTIFY_PLUGIN
71413 +#define MODULE_CONSTIFY_PLUGIN "CONSTIFY_PLUGIN "
71414 +#else
71415 +#define MODULE_CONSTIFY_PLUGIN ""
71416 +#endif
71417 +
71418 +#ifdef STACKLEAK_PLUGIN
71419 +#define MODULE_STACKLEAK_PLUGIN "STACKLEAK_PLUGIN "
71420 +#else
71421 +#define MODULE_STACKLEAK_PLUGIN ""
71422 +#endif
71423 +
71424 +#ifdef CONFIG_GRKERNSEC
71425 +#define MODULE_GRSEC "GRSEC "
71426 +#else
71427 +#define MODULE_GRSEC ""
71428 +#endif
71429 +
71430 #define VERMAGIC_STRING \
71431 UTS_RELEASE " " \
71432 MODULE_VERMAGIC_SMP MODULE_VERMAGIC_PREEMPT \
71433 MODULE_VERMAGIC_MODULE_UNLOAD MODULE_VERMAGIC_MODVERSIONS \
71434 - MODULE_ARCH_VERMAGIC
71435 + MODULE_ARCH_VERMAGIC \
71436 + MODULE_PAX_REFCOUNT MODULE_CONSTIFY_PLUGIN MODULE_STACKLEAK_PLUGIN \
71437 + MODULE_GRSEC
71438
71439 diff --git a/include/linux/vmalloc.h b/include/linux/vmalloc.h
71440 index 6071e91..ca6a489 100644
71441 --- a/include/linux/vmalloc.h
71442 +++ b/include/linux/vmalloc.h
71443 @@ -14,6 +14,11 @@ struct vm_area_struct; /* vma defining user mapping in mm_types.h */
71444 #define VM_USERMAP 0x00000008 /* suitable for remap_vmalloc_range */
71445 #define VM_VPAGES 0x00000010 /* buffer for pages was vmalloc'ed */
71446 #define VM_UNLIST 0x00000020 /* vm_struct is not listed in vmlist */
71447 +
71448 +#if defined(CONFIG_MODULES) && defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
71449 +#define VM_KERNEXEC 0x00000040 /* allocate from executable kernel memory range */
71450 +#endif
71451 +
71452 /* bits [20..32] reserved for arch specific ioremap internals */
71453
71454 /*
71455 @@ -62,7 +67,7 @@ extern void *vmalloc_32_user(unsigned long size);
71456 extern void *__vmalloc(unsigned long size, gfp_t gfp_mask, pgprot_t prot);
71457 extern void *__vmalloc_node_range(unsigned long size, unsigned long align,
71458 unsigned long start, unsigned long end, gfp_t gfp_mask,
71459 - pgprot_t prot, int node, const void *caller);
71460 + pgprot_t prot, int node, const void *caller) __size_overflow(1);
71461 extern void vfree(const void *addr);
71462
71463 extern void *vmap(struct page **pages, unsigned int count,
71464 @@ -124,8 +129,8 @@ extern struct vm_struct *alloc_vm_area(size_t size, pte_t **ptes);
71465 extern void free_vm_area(struct vm_struct *area);
71466
71467 /* for /dev/kmem */
71468 -extern long vread(char *buf, char *addr, unsigned long count);
71469 -extern long vwrite(char *buf, char *addr, unsigned long count);
71470 +extern long vread(char *buf, char *addr, unsigned long count) __size_overflow(3);
71471 +extern long vwrite(char *buf, char *addr, unsigned long count) __size_overflow(3);
71472
71473 /*
71474 * Internals. Dont't use..
71475 diff --git a/include/linux/vmstat.h b/include/linux/vmstat.h
71476 index a13291f..af51fa3 100644
71477 --- a/include/linux/vmstat.h
71478 +++ b/include/linux/vmstat.h
71479 @@ -95,18 +95,18 @@ static inline void vm_events_fold_cpu(int cpu)
71480 /*
71481 * Zone based page accounting with per cpu differentials.
71482 */
71483 -extern atomic_long_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
71484 +extern atomic_long_unchecked_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
71485
71486 static inline void zone_page_state_add(long x, struct zone *zone,
71487 enum zone_stat_item item)
71488 {
71489 - atomic_long_add(x, &zone->vm_stat[item]);
71490 - atomic_long_add(x, &vm_stat[item]);
71491 + atomic_long_add_unchecked(x, &zone->vm_stat[item]);
71492 + atomic_long_add_unchecked(x, &vm_stat[item]);
71493 }
71494
71495 static inline unsigned long global_page_state(enum zone_stat_item item)
71496 {
71497 - long x = atomic_long_read(&vm_stat[item]);
71498 + long x = atomic_long_read_unchecked(&vm_stat[item]);
71499 #ifdef CONFIG_SMP
71500 if (x < 0)
71501 x = 0;
71502 @@ -117,7 +117,7 @@ static inline unsigned long global_page_state(enum zone_stat_item item)
71503 static inline unsigned long zone_page_state(struct zone *zone,
71504 enum zone_stat_item item)
71505 {
71506 - long x = atomic_long_read(&zone->vm_stat[item]);
71507 + long x = atomic_long_read_unchecked(&zone->vm_stat[item]);
71508 #ifdef CONFIG_SMP
71509 if (x < 0)
71510 x = 0;
71511 @@ -134,7 +134,7 @@ static inline unsigned long zone_page_state(struct zone *zone,
71512 static inline unsigned long zone_page_state_snapshot(struct zone *zone,
71513 enum zone_stat_item item)
71514 {
71515 - long x = atomic_long_read(&zone->vm_stat[item]);
71516 + long x = atomic_long_read_unchecked(&zone->vm_stat[item]);
71517
71518 #ifdef CONFIG_SMP
71519 int cpu;
71520 @@ -226,8 +226,8 @@ static inline void __mod_zone_page_state(struct zone *zone,
71521
71522 static inline void __inc_zone_state(struct zone *zone, enum zone_stat_item item)
71523 {
71524 - atomic_long_inc(&zone->vm_stat[item]);
71525 - atomic_long_inc(&vm_stat[item]);
71526 + atomic_long_inc_unchecked(&zone->vm_stat[item]);
71527 + atomic_long_inc_unchecked(&vm_stat[item]);
71528 }
71529
71530 static inline void __inc_zone_page_state(struct page *page,
71531 @@ -238,8 +238,8 @@ static inline void __inc_zone_page_state(struct page *page,
71532
71533 static inline void __dec_zone_state(struct zone *zone, enum zone_stat_item item)
71534 {
71535 - atomic_long_dec(&zone->vm_stat[item]);
71536 - atomic_long_dec(&vm_stat[item]);
71537 + atomic_long_dec_unchecked(&zone->vm_stat[item]);
71538 + atomic_long_dec_unchecked(&vm_stat[item]);
71539 }
71540
71541 static inline void __dec_zone_page_state(struct page *page,
71542 diff --git a/include/linux/xattr.h b/include/linux/xattr.h
71543 index fdbafc6..b7ffd47 100644
71544 --- a/include/linux/xattr.h
71545 +++ b/include/linux/xattr.h
71546 @@ -28,7 +28,7 @@ struct xattr_handler {
71547 size_t size, int handler_flags);
71548 int (*set)(struct dentry *dentry, const char *name, const void *buffer,
71549 size_t size, int flags, int handler_flags);
71550 -};
71551 +} __do_const;
71552
71553 struct xattr {
71554 char *name;
71555 diff --git a/include/linux/zlib.h b/include/linux/zlib.h
71556 index 9c5a6b4..09c9438 100644
71557 --- a/include/linux/zlib.h
71558 +++ b/include/linux/zlib.h
71559 @@ -31,6 +31,7 @@
71560 #define _ZLIB_H
71561
71562 #include <linux/zconf.h>
71563 +#include <linux/compiler.h>
71564
71565 /* zlib deflate based on ZLIB_VERSION "1.1.3" */
71566 /* zlib inflate based on ZLIB_VERSION "1.2.3" */
71567 @@ -179,7 +180,7 @@ typedef z_stream *z_streamp;
71568
71569 /* basic functions */
71570
71571 -extern int zlib_deflate_workspacesize (int windowBits, int memLevel);
71572 +extern int zlib_deflate_workspacesize (int windowBits, int memLevel) __intentional_overflow(0);
71573 /*
71574 Returns the number of bytes that needs to be allocated for a per-
71575 stream workspace with the specified parameters. A pointer to this
71576 diff --git a/include/media/v4l2-dev.h b/include/media/v4l2-dev.h
71577 index 95d1c91..6798cca 100644
71578 --- a/include/media/v4l2-dev.h
71579 +++ b/include/media/v4l2-dev.h
71580 @@ -76,7 +76,7 @@ struct v4l2_file_operations {
71581 int (*mmap) (struct file *, struct vm_area_struct *);
71582 int (*open) (struct file *);
71583 int (*release) (struct file *);
71584 -};
71585 +} __do_const;
71586
71587 /*
71588 * Newer version of video_device, handled by videodev2.c
71589 diff --git a/include/media/v4l2-ioctl.h b/include/media/v4l2-ioctl.h
71590 index 4118ad1..cb7e25f 100644
71591 --- a/include/media/v4l2-ioctl.h
71592 +++ b/include/media/v4l2-ioctl.h
71593 @@ -284,7 +284,6 @@ struct v4l2_ioctl_ops {
71594 bool valid_prio, int cmd, void *arg);
71595 };
71596
71597 -
71598 /* v4l debugging and diagnostics */
71599
71600 /* Debug bitmask flags to be used on V4L2 */
71601 diff --git a/include/net/9p/transport.h b/include/net/9p/transport.h
71602 index adcbb20..62c2559 100644
71603 --- a/include/net/9p/transport.h
71604 +++ b/include/net/9p/transport.h
71605 @@ -57,7 +57,7 @@ struct p9_trans_module {
71606 int (*cancel) (struct p9_client *, struct p9_req_t *req);
71607 int (*zc_request)(struct p9_client *, struct p9_req_t *,
71608 char *, char *, int , int, int, int);
71609 -};
71610 +} __do_const;
71611
71612 void v9fs_register_trans(struct p9_trans_module *m);
71613 void v9fs_unregister_trans(struct p9_trans_module *m);
71614 diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h
71615 index 7588ef4..e62d35f 100644
71616 --- a/include/net/bluetooth/l2cap.h
71617 +++ b/include/net/bluetooth/l2cap.h
71618 @@ -552,7 +552,7 @@ struct l2cap_ops {
71619 void (*defer) (struct l2cap_chan *chan);
71620 struct sk_buff *(*alloc_skb) (struct l2cap_chan *chan,
71621 unsigned long len, int nb);
71622 -};
71623 +} __do_const;
71624
71625 struct l2cap_conn {
71626 struct hci_conn *hcon;
71627 diff --git a/include/net/caif/cfctrl.h b/include/net/caif/cfctrl.h
71628 index 9e5425b..8136ffc 100644
71629 --- a/include/net/caif/cfctrl.h
71630 +++ b/include/net/caif/cfctrl.h
71631 @@ -52,7 +52,7 @@ struct cfctrl_rsp {
71632 void (*radioset_rsp)(void);
71633 void (*reject_rsp)(struct cflayer *layer, u8 linkid,
71634 struct cflayer *client_layer);
71635 -};
71636 +} __no_const;
71637
71638 /* Link Setup Parameters for CAIF-Links. */
71639 struct cfctrl_link_param {
71640 @@ -101,8 +101,8 @@ struct cfctrl_request_info {
71641 struct cfctrl {
71642 struct cfsrvl serv;
71643 struct cfctrl_rsp res;
71644 - atomic_t req_seq_no;
71645 - atomic_t rsp_seq_no;
71646 + atomic_unchecked_t req_seq_no;
71647 + atomic_unchecked_t rsp_seq_no;
71648 struct list_head list;
71649 /* Protects from simultaneous access to first_req list */
71650 spinlock_t info_list_lock;
71651 diff --git a/include/net/flow.h b/include/net/flow.h
71652 index 628e11b..4c475df 100644
71653 --- a/include/net/flow.h
71654 +++ b/include/net/flow.h
71655 @@ -221,6 +221,6 @@ extern struct flow_cache_object *flow_cache_lookup(
71656
71657 extern void flow_cache_flush(void);
71658 extern void flow_cache_flush_deferred(void);
71659 -extern atomic_t flow_cache_genid;
71660 +extern atomic_unchecked_t flow_cache_genid;
71661
71662 #endif
71663 diff --git a/include/net/genetlink.h b/include/net/genetlink.h
71664 index bdfbe68..4402ebe 100644
71665 --- a/include/net/genetlink.h
71666 +++ b/include/net/genetlink.h
71667 @@ -118,7 +118,7 @@ struct genl_ops {
71668 struct netlink_callback *cb);
71669 int (*done)(struct netlink_callback *cb);
71670 struct list_head ops_list;
71671 -};
71672 +} __do_const;
71673
71674 extern int genl_register_family(struct genl_family *family);
71675 extern int genl_register_family_with_ops(struct genl_family *family,
71676 diff --git a/include/net/gro_cells.h b/include/net/gro_cells.h
71677 index e5062c9..48a9a4b 100644
71678 --- a/include/net/gro_cells.h
71679 +++ b/include/net/gro_cells.h
71680 @@ -29,7 +29,7 @@ static inline void gro_cells_receive(struct gro_cells *gcells, struct sk_buff *s
71681 cell += skb_get_rx_queue(skb) & gcells->gro_cells_mask;
71682
71683 if (skb_queue_len(&cell->napi_skbs) > netdev_max_backlog) {
71684 - atomic_long_inc(&dev->rx_dropped);
71685 + atomic_long_inc_unchecked(&dev->rx_dropped);
71686 kfree_skb(skb);
71687 return;
71688 }
71689 @@ -73,8 +73,8 @@ static inline int gro_cells_init(struct gro_cells *gcells, struct net_device *de
71690 int i;
71691
71692 gcells->gro_cells_mask = roundup_pow_of_two(netif_get_num_default_rss_queues()) - 1;
71693 - gcells->cells = kcalloc(sizeof(struct gro_cell),
71694 - gcells->gro_cells_mask + 1,
71695 + gcells->cells = kcalloc(gcells->gro_cells_mask + 1,
71696 + sizeof(struct gro_cell),
71697 GFP_KERNEL);
71698 if (!gcells->cells)
71699 return -ENOMEM;
71700 diff --git a/include/net/inet_connection_sock.h b/include/net/inet_connection_sock.h
71701 index 1832927..ce39aea 100644
71702 --- a/include/net/inet_connection_sock.h
71703 +++ b/include/net/inet_connection_sock.h
71704 @@ -62,7 +62,7 @@ struct inet_connection_sock_af_ops {
71705 void (*addr2sockaddr)(struct sock *sk, struct sockaddr *);
71706 int (*bind_conflict)(const struct sock *sk,
71707 const struct inet_bind_bucket *tb, bool relax);
71708 -};
71709 +} __do_const;
71710
71711 /** inet_connection_sock - INET connection oriented sock
71712 *
71713 diff --git a/include/net/inetpeer.h b/include/net/inetpeer.h
71714 index 53f464d..ba76aaa 100644
71715 --- a/include/net/inetpeer.h
71716 +++ b/include/net/inetpeer.h
71717 @@ -47,8 +47,8 @@ struct inet_peer {
71718 */
71719 union {
71720 struct {
71721 - atomic_t rid; /* Frag reception counter */
71722 - atomic_t ip_id_count; /* IP ID for the next packet */
71723 + atomic_unchecked_t rid; /* Frag reception counter */
71724 + atomic_unchecked_t ip_id_count; /* IP ID for the next packet */
71725 };
71726 struct rcu_head rcu;
71727 struct inet_peer *gc_next;
71728 @@ -182,11 +182,11 @@ static inline int inet_getid(struct inet_peer *p, int more)
71729 more++;
71730 inet_peer_refcheck(p);
71731 do {
71732 - old = atomic_read(&p->ip_id_count);
71733 + old = atomic_read_unchecked(&p->ip_id_count);
71734 new = old + more;
71735 if (!new)
71736 new = 1;
71737 - } while (atomic_cmpxchg(&p->ip_id_count, old, new) != old);
71738 + } while (atomic_cmpxchg_unchecked(&p->ip_id_count, old, new) != old);
71739 return new;
71740 }
71741
71742 diff --git a/include/net/ip.h b/include/net/ip.h
71743 index a68f838..74518ab 100644
71744 --- a/include/net/ip.h
71745 +++ b/include/net/ip.h
71746 @@ -202,7 +202,7 @@ extern struct local_ports {
71747 } sysctl_local_ports;
71748 extern void inet_get_local_port_range(int *low, int *high);
71749
71750 -extern unsigned long *sysctl_local_reserved_ports;
71751 +extern unsigned long sysctl_local_reserved_ports[65536 / 8 / sizeof(unsigned long)];
71752 static inline int inet_is_reserved_local_port(int port)
71753 {
71754 return test_bit(port, sysctl_local_reserved_ports);
71755 diff --git a/include/net/ip_fib.h b/include/net/ip_fib.h
71756 index 9497be1..5a4fafe 100644
71757 --- a/include/net/ip_fib.h
71758 +++ b/include/net/ip_fib.h
71759 @@ -169,7 +169,7 @@ extern __be32 fib_info_update_nh_saddr(struct net *net, struct fib_nh *nh);
71760
71761 #define FIB_RES_SADDR(net, res) \
71762 ((FIB_RES_NH(res).nh_saddr_genid == \
71763 - atomic_read(&(net)->ipv4.dev_addr_genid)) ? \
71764 + atomic_read_unchecked(&(net)->ipv4.dev_addr_genid)) ? \
71765 FIB_RES_NH(res).nh_saddr : \
71766 fib_info_update_nh_saddr((net), &FIB_RES_NH(res)))
71767 #define FIB_RES_GW(res) (FIB_RES_NH(res).nh_gw)
71768 diff --git a/include/net/ip_vs.h b/include/net/ip_vs.h
71769 index 68c69d5..bdab192 100644
71770 --- a/include/net/ip_vs.h
71771 +++ b/include/net/ip_vs.h
71772 @@ -599,7 +599,7 @@ struct ip_vs_conn {
71773 struct ip_vs_conn *control; /* Master control connection */
71774 atomic_t n_control; /* Number of controlled ones */
71775 struct ip_vs_dest *dest; /* real server */
71776 - atomic_t in_pkts; /* incoming packet counter */
71777 + atomic_unchecked_t in_pkts; /* incoming packet counter */
71778
71779 /* packet transmitter for different forwarding methods. If it
71780 mangles the packet, it must return NF_DROP or better NF_STOLEN,
71781 @@ -737,7 +737,7 @@ struct ip_vs_dest {
71782 __be16 port; /* port number of the server */
71783 union nf_inet_addr addr; /* IP address of the server */
71784 volatile unsigned int flags; /* dest status flags */
71785 - atomic_t conn_flags; /* flags to copy to conn */
71786 + atomic_unchecked_t conn_flags; /* flags to copy to conn */
71787 atomic_t weight; /* server weight */
71788
71789 atomic_t refcnt; /* reference counter */
71790 @@ -980,11 +980,11 @@ struct netns_ipvs {
71791 /* ip_vs_lblc */
71792 int sysctl_lblc_expiration;
71793 struct ctl_table_header *lblc_ctl_header;
71794 - struct ctl_table *lblc_ctl_table;
71795 + ctl_table_no_const *lblc_ctl_table;
71796 /* ip_vs_lblcr */
71797 int sysctl_lblcr_expiration;
71798 struct ctl_table_header *lblcr_ctl_header;
71799 - struct ctl_table *lblcr_ctl_table;
71800 + ctl_table_no_const *lblcr_ctl_table;
71801 /* ip_vs_est */
71802 struct list_head est_list; /* estimator list */
71803 spinlock_t est_lock;
71804 diff --git a/include/net/irda/ircomm_tty.h b/include/net/irda/ircomm_tty.h
71805 index 80ffde3..968b0f4 100644
71806 --- a/include/net/irda/ircomm_tty.h
71807 +++ b/include/net/irda/ircomm_tty.h
71808 @@ -35,6 +35,7 @@
71809 #include <linux/termios.h>
71810 #include <linux/timer.h>
71811 #include <linux/tty.h> /* struct tty_struct */
71812 +#include <asm/local.h>
71813
71814 #include <net/irda/irias_object.h>
71815 #include <net/irda/ircomm_core.h>
71816 diff --git a/include/net/iucv/af_iucv.h b/include/net/iucv/af_iucv.h
71817 index cc7c197..9f2da2a 100644
71818 --- a/include/net/iucv/af_iucv.h
71819 +++ b/include/net/iucv/af_iucv.h
71820 @@ -141,7 +141,7 @@ struct iucv_sock {
71821 struct iucv_sock_list {
71822 struct hlist_head head;
71823 rwlock_t lock;
71824 - atomic_t autobind_name;
71825 + atomic_unchecked_t autobind_name;
71826 };
71827
71828 unsigned int iucv_sock_poll(struct file *file, struct socket *sock,
71829 diff --git a/include/net/llc_c_ac.h b/include/net/llc_c_ac.h
71830 index df83f69..9b640b8 100644
71831 --- a/include/net/llc_c_ac.h
71832 +++ b/include/net/llc_c_ac.h
71833 @@ -87,7 +87,7 @@
71834 #define LLC_CONN_AC_STOP_SENDACK_TMR 70
71835 #define LLC_CONN_AC_START_SENDACK_TMR_IF_NOT_RUNNING 71
71836
71837 -typedef int (*llc_conn_action_t)(struct sock *sk, struct sk_buff *skb);
71838 +typedef int (* const llc_conn_action_t)(struct sock *sk, struct sk_buff *skb);
71839
71840 extern int llc_conn_ac_clear_remote_busy(struct sock *sk, struct sk_buff *skb);
71841 extern int llc_conn_ac_conn_ind(struct sock *sk, struct sk_buff *skb);
71842 diff --git a/include/net/llc_c_ev.h b/include/net/llc_c_ev.h
71843 index 6ca3113..f8026dd 100644
71844 --- a/include/net/llc_c_ev.h
71845 +++ b/include/net/llc_c_ev.h
71846 @@ -125,8 +125,8 @@ static __inline__ struct llc_conn_state_ev *llc_conn_ev(struct sk_buff *skb)
71847 return (struct llc_conn_state_ev *)skb->cb;
71848 }
71849
71850 -typedef int (*llc_conn_ev_t)(struct sock *sk, struct sk_buff *skb);
71851 -typedef int (*llc_conn_ev_qfyr_t)(struct sock *sk, struct sk_buff *skb);
71852 +typedef int (* const llc_conn_ev_t)(struct sock *sk, struct sk_buff *skb);
71853 +typedef int (* const llc_conn_ev_qfyr_t)(struct sock *sk, struct sk_buff *skb);
71854
71855 extern int llc_conn_ev_conn_req(struct sock *sk, struct sk_buff *skb);
71856 extern int llc_conn_ev_data_req(struct sock *sk, struct sk_buff *skb);
71857 diff --git a/include/net/llc_c_st.h b/include/net/llc_c_st.h
71858 index 0e79cfb..f46db31 100644
71859 --- a/include/net/llc_c_st.h
71860 +++ b/include/net/llc_c_st.h
71861 @@ -37,7 +37,7 @@ struct llc_conn_state_trans {
71862 u8 next_state;
71863 llc_conn_ev_qfyr_t *ev_qualifiers;
71864 llc_conn_action_t *ev_actions;
71865 -};
71866 +} __do_const;
71867
71868 struct llc_conn_state {
71869 u8 current_state;
71870 diff --git a/include/net/llc_s_ac.h b/include/net/llc_s_ac.h
71871 index 37a3bbd..55a4241 100644
71872 --- a/include/net/llc_s_ac.h
71873 +++ b/include/net/llc_s_ac.h
71874 @@ -23,7 +23,7 @@
71875 #define SAP_ACT_TEST_IND 9
71876
71877 /* All action functions must look like this */
71878 -typedef int (*llc_sap_action_t)(struct llc_sap *sap, struct sk_buff *skb);
71879 +typedef int (* const llc_sap_action_t)(struct llc_sap *sap, struct sk_buff *skb);
71880
71881 extern int llc_sap_action_unitdata_ind(struct llc_sap *sap,
71882 struct sk_buff *skb);
71883 diff --git a/include/net/llc_s_st.h b/include/net/llc_s_st.h
71884 index 567c681..cd73ac0 100644
71885 --- a/include/net/llc_s_st.h
71886 +++ b/include/net/llc_s_st.h
71887 @@ -20,7 +20,7 @@ struct llc_sap_state_trans {
71888 llc_sap_ev_t ev;
71889 u8 next_state;
71890 llc_sap_action_t *ev_actions;
71891 -};
71892 +} __do_const;
71893
71894 struct llc_sap_state {
71895 u8 curr_state;
71896 diff --git a/include/net/mac80211.h b/include/net/mac80211.h
71897 index ee50c5e..1bc3b1a 100644
71898 --- a/include/net/mac80211.h
71899 +++ b/include/net/mac80211.h
71900 @@ -3996,7 +3996,7 @@ struct rate_control_ops {
71901 void (*add_sta_debugfs)(void *priv, void *priv_sta,
71902 struct dentry *dir);
71903 void (*remove_sta_debugfs)(void *priv, void *priv_sta);
71904 -};
71905 +} __do_const;
71906
71907 static inline int rate_supported(struct ieee80211_sta *sta,
71908 enum ieee80211_band band,
71909 diff --git a/include/net/neighbour.h b/include/net/neighbour.h
71910 index 0dab173..1b76af0 100644
71911 --- a/include/net/neighbour.h
71912 +++ b/include/net/neighbour.h
71913 @@ -123,7 +123,7 @@ struct neigh_ops {
71914 void (*error_report)(struct neighbour *, struct sk_buff *);
71915 int (*output)(struct neighbour *, struct sk_buff *);
71916 int (*connected_output)(struct neighbour *, struct sk_buff *);
71917 -};
71918 +} __do_const;
71919
71920 struct pneigh_entry {
71921 struct pneigh_entry *next;
71922 diff --git a/include/net/net_namespace.h b/include/net/net_namespace.h
71923 index de644bc..351fd4e 100644
71924 --- a/include/net/net_namespace.h
71925 +++ b/include/net/net_namespace.h
71926 @@ -115,7 +115,7 @@ struct net {
71927 #endif
71928 struct netns_ipvs *ipvs;
71929 struct sock *diag_nlsk;
71930 - atomic_t rt_genid;
71931 + atomic_unchecked_t rt_genid;
71932 };
71933
71934 /*
71935 @@ -282,7 +282,7 @@ struct pernet_operations {
71936 void (*exit_batch)(struct list_head *net_exit_list);
71937 int *id;
71938 size_t size;
71939 -};
71940 +} __do_const;
71941
71942 /*
71943 * Use these carefully. If you implement a network device and it
71944 @@ -330,12 +330,12 @@ static inline void unregister_net_sysctl_table(struct ctl_table_header *header)
71945
71946 static inline int rt_genid(struct net *net)
71947 {
71948 - return atomic_read(&net->rt_genid);
71949 + return atomic_read_unchecked(&net->rt_genid);
71950 }
71951
71952 static inline void rt_genid_bump(struct net *net)
71953 {
71954 - atomic_inc(&net->rt_genid);
71955 + atomic_inc_unchecked(&net->rt_genid);
71956 }
71957
71958 #endif /* __NET_NET_NAMESPACE_H */
71959 diff --git a/include/net/netdma.h b/include/net/netdma.h
71960 index 8ba8ce2..99b7fff 100644
71961 --- a/include/net/netdma.h
71962 +++ b/include/net/netdma.h
71963 @@ -24,7 +24,7 @@
71964 #include <linux/dmaengine.h>
71965 #include <linux/skbuff.h>
71966
71967 -int dma_skb_copy_datagram_iovec(struct dma_chan* chan,
71968 +int __intentional_overflow(3,5) dma_skb_copy_datagram_iovec(struct dma_chan* chan,
71969 struct sk_buff *skb, int offset, struct iovec *to,
71970 size_t len, struct dma_pinned_list *pinned_list);
71971
71972 diff --git a/include/net/netlink.h b/include/net/netlink.h
71973 index 9690b0f..87aded7 100644
71974 --- a/include/net/netlink.h
71975 +++ b/include/net/netlink.h
71976 @@ -534,7 +534,7 @@ static inline void *nlmsg_get_pos(struct sk_buff *skb)
71977 static inline void nlmsg_trim(struct sk_buff *skb, const void *mark)
71978 {
71979 if (mark)
71980 - skb_trim(skb, (unsigned char *) mark - skb->data);
71981 + skb_trim(skb, (const unsigned char *) mark - skb->data);
71982 }
71983
71984 /**
71985 diff --git a/include/net/netns/conntrack.h b/include/net/netns/conntrack.h
71986 index 923cb20..deae816 100644
71987 --- a/include/net/netns/conntrack.h
71988 +++ b/include/net/netns/conntrack.h
71989 @@ -12,10 +12,10 @@ struct nf_conntrack_ecache;
71990 struct nf_proto_net {
71991 #ifdef CONFIG_SYSCTL
71992 struct ctl_table_header *ctl_table_header;
71993 - struct ctl_table *ctl_table;
71994 + ctl_table_no_const *ctl_table;
71995 #ifdef CONFIG_NF_CONNTRACK_PROC_COMPAT
71996 struct ctl_table_header *ctl_compat_header;
71997 - struct ctl_table *ctl_compat_table;
71998 + ctl_table_no_const *ctl_compat_table;
71999 #endif
72000 #endif
72001 unsigned int users;
72002 @@ -58,7 +58,7 @@ struct nf_ip_net {
72003 struct nf_icmp_net icmpv6;
72004 #if defined(CONFIG_SYSCTL) && defined(CONFIG_NF_CONNTRACK_PROC_COMPAT)
72005 struct ctl_table_header *ctl_table_header;
72006 - struct ctl_table *ctl_table;
72007 + ctl_table_no_const *ctl_table;
72008 #endif
72009 };
72010
72011 diff --git a/include/net/netns/ipv4.h b/include/net/netns/ipv4.h
72012 index 2ae2b83..dbdc85e 100644
72013 --- a/include/net/netns/ipv4.h
72014 +++ b/include/net/netns/ipv4.h
72015 @@ -64,7 +64,7 @@ struct netns_ipv4 {
72016 kgid_t sysctl_ping_group_range[2];
72017 long sysctl_tcp_mem[3];
72018
72019 - atomic_t dev_addr_genid;
72020 + atomic_unchecked_t dev_addr_genid;
72021
72022 #ifdef CONFIG_IP_MROUTE
72023 #ifndef CONFIG_IP_MROUTE_MULTIPLE_TABLES
72024 diff --git a/include/net/protocol.h b/include/net/protocol.h
72025 index 047c047..b9dad15 100644
72026 --- a/include/net/protocol.h
72027 +++ b/include/net/protocol.h
72028 @@ -44,7 +44,7 @@ struct net_protocol {
72029 void (*err_handler)(struct sk_buff *skb, u32 info);
72030 unsigned int no_policy:1,
72031 netns_ok:1;
72032 -};
72033 +} __do_const;
72034
72035 #if IS_ENABLED(CONFIG_IPV6)
72036 struct inet6_protocol {
72037 @@ -57,7 +57,7 @@ struct inet6_protocol {
72038 u8 type, u8 code, int offset,
72039 __be32 info);
72040 unsigned int flags; /* INET6_PROTO_xxx */
72041 -};
72042 +} __do_const;
72043
72044 #define INET6_PROTO_NOPOLICY 0x1
72045 #define INET6_PROTO_FINAL 0x2
72046 diff --git a/include/net/rtnetlink.h b/include/net/rtnetlink.h
72047 index 5a15fab..d799ea7 100644
72048 --- a/include/net/rtnetlink.h
72049 +++ b/include/net/rtnetlink.h
72050 @@ -81,7 +81,7 @@ struct rtnl_link_ops {
72051 const struct net_device *dev);
72052 unsigned int (*get_num_tx_queues)(void);
72053 unsigned int (*get_num_rx_queues)(void);
72054 -};
72055 +} __do_const;
72056
72057 extern int __rtnl_link_register(struct rtnl_link_ops *ops);
72058 extern void __rtnl_link_unregister(struct rtnl_link_ops *ops);
72059 diff --git a/include/net/sctp/sctp.h b/include/net/sctp/sctp.h
72060 index 7fdf298..197e9f7 100644
72061 --- a/include/net/sctp/sctp.h
72062 +++ b/include/net/sctp/sctp.h
72063 @@ -330,9 +330,9 @@ do { \
72064
72065 #else /* SCTP_DEBUG */
72066
72067 -#define SCTP_DEBUG_PRINTK(whatever...)
72068 -#define SCTP_DEBUG_PRINTK_CONT(fmt, args...)
72069 -#define SCTP_DEBUG_PRINTK_IPADDR(whatever...)
72070 +#define SCTP_DEBUG_PRINTK(whatever...) do {} while (0)
72071 +#define SCTP_DEBUG_PRINTK_CONT(fmt, args...) do {} while (0)
72072 +#define SCTP_DEBUG_PRINTK_IPADDR(whatever...) do {} while (0)
72073 #define SCTP_ENABLE_DEBUG
72074 #define SCTP_DISABLE_DEBUG
72075 #define SCTP_ASSERT(expr, str, func)
72076 diff --git a/include/net/sctp/sm.h b/include/net/sctp/sm.h
72077 index 2a82d13..62a31c2 100644
72078 --- a/include/net/sctp/sm.h
72079 +++ b/include/net/sctp/sm.h
72080 @@ -87,7 +87,7 @@ typedef void (sctp_timer_event_t) (unsigned long);
72081 typedef struct {
72082 sctp_state_fn_t *fn;
72083 const char *name;
72084 -} sctp_sm_table_entry_t;
72085 +} __do_const sctp_sm_table_entry_t;
72086
72087 /* A naming convention of "sctp_sf_xxx" applies to all the state functions
72088 * currently in use.
72089 @@ -299,7 +299,7 @@ __u32 sctp_generate_tag(const struct sctp_endpoint *);
72090 __u32 sctp_generate_tsn(const struct sctp_endpoint *);
72091
72092 /* Extern declarations for major data structures. */
72093 -extern sctp_timer_event_t *sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES];
72094 +extern sctp_timer_event_t * const sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES];
72095
72096
72097 /* Get the size of a DATA chunk payload. */
72098 diff --git a/include/net/sctp/structs.h b/include/net/sctp/structs.h
72099 index fdeb85a..1329d95 100644
72100 --- a/include/net/sctp/structs.h
72101 +++ b/include/net/sctp/structs.h
72102 @@ -517,7 +517,7 @@ struct sctp_pf {
72103 struct sctp_association *asoc);
72104 void (*addr_v4map) (struct sctp_sock *, union sctp_addr *);
72105 struct sctp_af *af;
72106 -};
72107 +} __do_const;
72108
72109
72110 /* Structure to track chunk fragments that have been acked, but peer
72111 diff --git a/include/net/sock.h b/include/net/sock.h
72112 index 25afaa0..8bb0070 100644
72113 --- a/include/net/sock.h
72114 +++ b/include/net/sock.h
72115 @@ -322,7 +322,7 @@ struct sock {
72116 #ifdef CONFIG_RPS
72117 __u32 sk_rxhash;
72118 #endif
72119 - atomic_t sk_drops;
72120 + atomic_unchecked_t sk_drops;
72121 int sk_rcvbuf;
72122
72123 struct sk_filter __rcu *sk_filter;
72124 @@ -1781,7 +1781,7 @@ static inline void sk_nocaps_add(struct sock *sk, netdev_features_t flags)
72125 }
72126
72127 static inline int skb_do_copy_data_nocache(struct sock *sk, struct sk_buff *skb,
72128 - char __user *from, char *to,
72129 + char __user *from, unsigned char *to,
72130 int copy, int offset)
72131 {
72132 if (skb->ip_summed == CHECKSUM_NONE) {
72133 @@ -2040,7 +2040,7 @@ static inline void sk_stream_moderate_sndbuf(struct sock *sk)
72134 }
72135 }
72136
72137 -struct sk_buff *sk_stream_alloc_skb(struct sock *sk, int size, gfp_t gfp);
72138 +struct sk_buff * __intentional_overflow(0) sk_stream_alloc_skb(struct sock *sk, int size, gfp_t gfp);
72139
72140 /**
72141 * sk_page_frag - return an appropriate page_frag
72142 diff --git a/include/net/tcp.h b/include/net/tcp.h
72143 index aed42c7..43890c6 100644
72144 --- a/include/net/tcp.h
72145 +++ b/include/net/tcp.h
72146 @@ -530,7 +530,7 @@ extern void tcp_retransmit_timer(struct sock *sk);
72147 extern void tcp_xmit_retransmit_queue(struct sock *);
72148 extern void tcp_simple_retransmit(struct sock *);
72149 extern int tcp_trim_head(struct sock *, struct sk_buff *, u32);
72150 -extern int tcp_fragment(struct sock *, struct sk_buff *, u32, unsigned int);
72151 +extern int __intentional_overflow(3) tcp_fragment(struct sock *, struct sk_buff *, u32, unsigned int);
72152
72153 extern void tcp_send_probe0(struct sock *);
72154 extern void tcp_send_partial(struct sock *);
72155 @@ -701,8 +701,8 @@ struct tcp_skb_cb {
72156 struct inet6_skb_parm h6;
72157 #endif
72158 } header; /* For incoming frames */
72159 - __u32 seq; /* Starting sequence number */
72160 - __u32 end_seq; /* SEQ + FIN + SYN + datalen */
72161 + __u32 seq __intentional_overflow(0); /* Starting sequence number */
72162 + __u32 end_seq __intentional_overflow(0); /* SEQ + FIN + SYN + datalen */
72163 __u32 when; /* used to compute rtt's */
72164 __u8 tcp_flags; /* TCP header flags. (tcp[13]) */
72165
72166 @@ -716,7 +716,7 @@ struct tcp_skb_cb {
72167
72168 __u8 ip_dsfield; /* IPv4 tos or IPv6 dsfield */
72169 /* 1 byte hole */
72170 - __u32 ack_seq; /* Sequence number ACK'd */
72171 + __u32 ack_seq __intentional_overflow(0); /* Sequence number ACK'd */
72172 };
72173
72174 #define TCP_SKB_CB(__skb) ((struct tcp_skb_cb *)&((__skb)->cb[0]))
72175 diff --git a/include/net/xfrm.h b/include/net/xfrm.h
72176 index 63445ed..d6fc34f 100644
72177 --- a/include/net/xfrm.h
72178 +++ b/include/net/xfrm.h
72179 @@ -304,7 +304,7 @@ struct xfrm_policy_afinfo {
72180 struct net_device *dev,
72181 const struct flowi *fl);
72182 struct dst_entry *(*blackhole_route)(struct net *net, struct dst_entry *orig);
72183 -};
72184 +} __do_const;
72185
72186 extern int xfrm_policy_register_afinfo(struct xfrm_policy_afinfo *afinfo);
72187 extern int xfrm_policy_unregister_afinfo(struct xfrm_policy_afinfo *afinfo);
72188 @@ -340,7 +340,7 @@ struct xfrm_state_afinfo {
72189 struct sk_buff *skb);
72190 int (*transport_finish)(struct sk_buff *skb,
72191 int async);
72192 -};
72193 +} __do_const;
72194
72195 extern int xfrm_state_register_afinfo(struct xfrm_state_afinfo *afinfo);
72196 extern int xfrm_state_unregister_afinfo(struct xfrm_state_afinfo *afinfo);
72197 @@ -423,7 +423,7 @@ struct xfrm_mode {
72198 struct module *owner;
72199 unsigned int encap;
72200 int flags;
72201 -};
72202 +} __do_const;
72203
72204 /* Flags for xfrm_mode. */
72205 enum {
72206 @@ -514,7 +514,7 @@ struct xfrm_policy {
72207 struct timer_list timer;
72208
72209 struct flow_cache_object flo;
72210 - atomic_t genid;
72211 + atomic_unchecked_t genid;
72212 u32 priority;
72213 u32 index;
72214 struct xfrm_mark mark;
72215 diff --git a/include/rdma/iw_cm.h b/include/rdma/iw_cm.h
72216 index 1a046b1..ee0bef0 100644
72217 --- a/include/rdma/iw_cm.h
72218 +++ b/include/rdma/iw_cm.h
72219 @@ -122,7 +122,7 @@ struct iw_cm_verbs {
72220 int backlog);
72221
72222 int (*destroy_listen)(struct iw_cm_id *cm_id);
72223 -};
72224 +} __no_const;
72225
72226 /**
72227 * iw_create_cm_id - Create an IW CM identifier.
72228 diff --git a/include/scsi/libfc.h b/include/scsi/libfc.h
72229 index 399162b..b337f1a 100644
72230 --- a/include/scsi/libfc.h
72231 +++ b/include/scsi/libfc.h
72232 @@ -762,6 +762,7 @@ struct libfc_function_template {
72233 */
72234 void (*disc_stop_final) (struct fc_lport *);
72235 };
72236 +typedef struct libfc_function_template __no_const libfc_function_template_no_const;
72237
72238 /**
72239 * struct fc_disc - Discovery context
72240 @@ -866,7 +867,7 @@ struct fc_lport {
72241 struct fc_vport *vport;
72242
72243 /* Operational Information */
72244 - struct libfc_function_template tt;
72245 + libfc_function_template_no_const tt;
72246 u8 link_up;
72247 u8 qfull;
72248 enum fc_lport_state state;
72249 diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h
72250 index e65c62e..aa2e5a2 100644
72251 --- a/include/scsi/scsi_device.h
72252 +++ b/include/scsi/scsi_device.h
72253 @@ -170,9 +170,9 @@ struct scsi_device {
72254 unsigned int max_device_blocked; /* what device_blocked counts down from */
72255 #define SCSI_DEFAULT_DEVICE_BLOCKED 3
72256
72257 - atomic_t iorequest_cnt;
72258 - atomic_t iodone_cnt;
72259 - atomic_t ioerr_cnt;
72260 + atomic_unchecked_t iorequest_cnt;
72261 + atomic_unchecked_t iodone_cnt;
72262 + atomic_unchecked_t ioerr_cnt;
72263
72264 struct device sdev_gendev,
72265 sdev_dev;
72266 diff --git a/include/scsi/scsi_transport_fc.h b/include/scsi/scsi_transport_fc.h
72267 index b797e8f..8e2c3aa 100644
72268 --- a/include/scsi/scsi_transport_fc.h
72269 +++ b/include/scsi/scsi_transport_fc.h
72270 @@ -751,7 +751,8 @@ struct fc_function_template {
72271 unsigned long show_host_system_hostname:1;
72272
72273 unsigned long disable_target_scan:1;
72274 -};
72275 +} __do_const;
72276 +typedef struct fc_function_template __no_const fc_function_template_no_const;
72277
72278
72279 /**
72280 diff --git a/include/sound/soc.h b/include/sound/soc.h
72281 index bc56738..a4be132 100644
72282 --- a/include/sound/soc.h
72283 +++ b/include/sound/soc.h
72284 @@ -771,7 +771,7 @@ struct snd_soc_codec_driver {
72285 /* probe ordering - for components with runtime dependencies */
72286 int probe_order;
72287 int remove_order;
72288 -};
72289 +} __do_const;
72290
72291 /* SoC platform interface */
72292 struct snd_soc_platform_driver {
72293 @@ -817,7 +817,7 @@ struct snd_soc_platform_driver {
72294 unsigned int (*read)(struct snd_soc_platform *, unsigned int);
72295 int (*write)(struct snd_soc_platform *, unsigned int, unsigned int);
72296 int (*bespoke_trigger)(struct snd_pcm_substream *, int);
72297 -};
72298 +} __do_const;
72299
72300 struct snd_soc_platform {
72301 const char *name;
72302 diff --git a/include/target/target_core_base.h b/include/target/target_core_base.h
72303 index 663e34a..91b306a 100644
72304 --- a/include/target/target_core_base.h
72305 +++ b/include/target/target_core_base.h
72306 @@ -654,7 +654,7 @@ struct se_device {
72307 spinlock_t stats_lock;
72308 /* Active commands on this virtual SE device */
72309 atomic_t simple_cmds;
72310 - atomic_t dev_ordered_id;
72311 + atomic_unchecked_t dev_ordered_id;
72312 atomic_t dev_ordered_sync;
72313 atomic_t dev_qf_count;
72314 int export_count;
72315 diff --git a/include/trace/events/fs.h b/include/trace/events/fs.h
72316 new file mode 100644
72317 index 0000000..fb634b7
72318 --- /dev/null
72319 +++ b/include/trace/events/fs.h
72320 @@ -0,0 +1,53 @@
72321 +#undef TRACE_SYSTEM
72322 +#define TRACE_SYSTEM fs
72323 +
72324 +#if !defined(_TRACE_FS_H) || defined(TRACE_HEADER_MULTI_READ)
72325 +#define _TRACE_FS_H
72326 +
72327 +#include <linux/fs.h>
72328 +#include <linux/tracepoint.h>
72329 +
72330 +TRACE_EVENT(do_sys_open,
72331 +
72332 + TP_PROTO(const char *filename, int flags, int mode),
72333 +
72334 + TP_ARGS(filename, flags, mode),
72335 +
72336 + TP_STRUCT__entry(
72337 + __string( filename, filename )
72338 + __field( int, flags )
72339 + __field( int, mode )
72340 + ),
72341 +
72342 + TP_fast_assign(
72343 + __assign_str(filename, filename);
72344 + __entry->flags = flags;
72345 + __entry->mode = mode;
72346 + ),
72347 +
72348 + TP_printk("\"%s\" %x %o",
72349 + __get_str(filename), __entry->flags, __entry->mode)
72350 +);
72351 +
72352 +TRACE_EVENT(open_exec,
72353 +
72354 + TP_PROTO(const char *filename),
72355 +
72356 + TP_ARGS(filename),
72357 +
72358 + TP_STRUCT__entry(
72359 + __string( filename, filename )
72360 + ),
72361 +
72362 + TP_fast_assign(
72363 + __assign_str(filename, filename);
72364 + ),
72365 +
72366 + TP_printk("\"%s\"",
72367 + __get_str(filename))
72368 +);
72369 +
72370 +#endif /* _TRACE_FS_H */
72371 +
72372 +/* This part must be outside protection */
72373 +#include <trace/define_trace.h>
72374 diff --git a/include/trace/events/irq.h b/include/trace/events/irq.h
72375 index 1c09820..7f5ec79 100644
72376 --- a/include/trace/events/irq.h
72377 +++ b/include/trace/events/irq.h
72378 @@ -36,7 +36,7 @@ struct softirq_action;
72379 */
72380 TRACE_EVENT(irq_handler_entry,
72381
72382 - TP_PROTO(int irq, struct irqaction *action),
72383 + TP_PROTO(int irq, const struct irqaction *action),
72384
72385 TP_ARGS(irq, action),
72386
72387 @@ -66,7 +66,7 @@ TRACE_EVENT(irq_handler_entry,
72388 */
72389 TRACE_EVENT(irq_handler_exit,
72390
72391 - TP_PROTO(int irq, struct irqaction *action, int ret),
72392 + TP_PROTO(int irq, const struct irqaction *action, int ret),
72393
72394 TP_ARGS(irq, action, ret),
72395
72396 diff --git a/include/uapi/linux/a.out.h b/include/uapi/linux/a.out.h
72397 index 7caf44c..23c6f27 100644
72398 --- a/include/uapi/linux/a.out.h
72399 +++ b/include/uapi/linux/a.out.h
72400 @@ -39,6 +39,14 @@ enum machine_type {
72401 M_MIPS2 = 152 /* MIPS R6000/R4000 binary */
72402 };
72403
72404 +/* Constants for the N_FLAGS field */
72405 +#define F_PAX_PAGEEXEC 1 /* Paging based non-executable pages */
72406 +#define F_PAX_EMUTRAMP 2 /* Emulate trampolines */
72407 +#define F_PAX_MPROTECT 4 /* Restrict mprotect() */
72408 +#define F_PAX_RANDMMAP 8 /* Randomize mmap() base */
72409 +/*#define F_PAX_RANDEXEC 16*/ /* Randomize ET_EXEC base */
72410 +#define F_PAX_SEGMEXEC 32 /* Segmentation based non-executable pages */
72411 +
72412 #if !defined (N_MAGIC)
72413 #define N_MAGIC(exec) ((exec).a_info & 0xffff)
72414 #endif
72415 diff --git a/include/uapi/linux/byteorder/little_endian.h b/include/uapi/linux/byteorder/little_endian.h
72416 index d876736..ccce5c0 100644
72417 --- a/include/uapi/linux/byteorder/little_endian.h
72418 +++ b/include/uapi/linux/byteorder/little_endian.h
72419 @@ -42,51 +42,51 @@
72420
72421 static inline __le64 __cpu_to_le64p(const __u64 *p)
72422 {
72423 - return (__force __le64)*p;
72424 + return (__force const __le64)*p;
72425 }
72426 -static inline __u64 __le64_to_cpup(const __le64 *p)
72427 +static inline __u64 __intentional_overflow(-1) __le64_to_cpup(const __le64 *p)
72428 {
72429 - return (__force __u64)*p;
72430 + return (__force const __u64)*p;
72431 }
72432 static inline __le32 __cpu_to_le32p(const __u32 *p)
72433 {
72434 - return (__force __le32)*p;
72435 + return (__force const __le32)*p;
72436 }
72437 static inline __u32 __le32_to_cpup(const __le32 *p)
72438 {
72439 - return (__force __u32)*p;
72440 + return (__force const __u32)*p;
72441 }
72442 static inline __le16 __cpu_to_le16p(const __u16 *p)
72443 {
72444 - return (__force __le16)*p;
72445 + return (__force const __le16)*p;
72446 }
72447 static inline __u16 __le16_to_cpup(const __le16 *p)
72448 {
72449 - return (__force __u16)*p;
72450 + return (__force const __u16)*p;
72451 }
72452 static inline __be64 __cpu_to_be64p(const __u64 *p)
72453 {
72454 - return (__force __be64)__swab64p(p);
72455 + return (__force const __be64)__swab64p(p);
72456 }
72457 static inline __u64 __be64_to_cpup(const __be64 *p)
72458 {
72459 - return __swab64p((__u64 *)p);
72460 + return __swab64p((const __u64 *)p);
72461 }
72462 static inline __be32 __cpu_to_be32p(const __u32 *p)
72463 {
72464 - return (__force __be32)__swab32p(p);
72465 + return (__force const __be32)__swab32p(p);
72466 }
72467 -static inline __u32 __be32_to_cpup(const __be32 *p)
72468 +static inline __u32 __intentional_overflow(-1) __be32_to_cpup(const __be32 *p)
72469 {
72470 - return __swab32p((__u32 *)p);
72471 + return __swab32p((const __u32 *)p);
72472 }
72473 static inline __be16 __cpu_to_be16p(const __u16 *p)
72474 {
72475 - return (__force __be16)__swab16p(p);
72476 + return (__force const __be16)__swab16p(p);
72477 }
72478 static inline __u16 __be16_to_cpup(const __be16 *p)
72479 {
72480 - return __swab16p((__u16 *)p);
72481 + return __swab16p((const __u16 *)p);
72482 }
72483 #define __cpu_to_le64s(x) do { (void)(x); } while (0)
72484 #define __le64_to_cpus(x) do { (void)(x); } while (0)
72485 diff --git a/include/uapi/linux/elf.h b/include/uapi/linux/elf.h
72486 index 126a817..d522bd1 100644
72487 --- a/include/uapi/linux/elf.h
72488 +++ b/include/uapi/linux/elf.h
72489 @@ -37,6 +37,17 @@ typedef __s64 Elf64_Sxword;
72490 #define PT_GNU_EH_FRAME 0x6474e550
72491
72492 #define PT_GNU_STACK (PT_LOOS + 0x474e551)
72493 +#define PT_GNU_RELRO (PT_LOOS + 0x474e552)
72494 +
72495 +#define PT_PAX_FLAGS (PT_LOOS + 0x5041580)
72496 +
72497 +/* Constants for the e_flags field */
72498 +#define EF_PAX_PAGEEXEC 1 /* Paging based non-executable pages */
72499 +#define EF_PAX_EMUTRAMP 2 /* Emulate trampolines */
72500 +#define EF_PAX_MPROTECT 4 /* Restrict mprotect() */
72501 +#define EF_PAX_RANDMMAP 8 /* Randomize mmap() base */
72502 +/*#define EF_PAX_RANDEXEC 16*/ /* Randomize ET_EXEC base */
72503 +#define EF_PAX_SEGMEXEC 32 /* Segmentation based non-executable pages */
72504
72505 /*
72506 * Extended Numbering
72507 @@ -94,6 +105,8 @@ typedef __s64 Elf64_Sxword;
72508 #define DT_DEBUG 21
72509 #define DT_TEXTREL 22
72510 #define DT_JMPREL 23
72511 +#define DT_FLAGS 30
72512 + #define DF_TEXTREL 0x00000004
72513 #define DT_ENCODING 32
72514 #define OLD_DT_LOOS 0x60000000
72515 #define DT_LOOS 0x6000000d
72516 @@ -240,6 +253,19 @@ typedef struct elf64_hdr {
72517 #define PF_W 0x2
72518 #define PF_X 0x1
72519
72520 +#define PF_PAGEEXEC (1U << 4) /* Enable PAGEEXEC */
72521 +#define PF_NOPAGEEXEC (1U << 5) /* Disable PAGEEXEC */
72522 +#define PF_SEGMEXEC (1U << 6) /* Enable SEGMEXEC */
72523 +#define PF_NOSEGMEXEC (1U << 7) /* Disable SEGMEXEC */
72524 +#define PF_MPROTECT (1U << 8) /* Enable MPROTECT */
72525 +#define PF_NOMPROTECT (1U << 9) /* Disable MPROTECT */
72526 +/*#define PF_RANDEXEC (1U << 10)*/ /* Enable RANDEXEC */
72527 +/*#define PF_NORANDEXEC (1U << 11)*/ /* Disable RANDEXEC */
72528 +#define PF_EMUTRAMP (1U << 12) /* Enable EMUTRAMP */
72529 +#define PF_NOEMUTRAMP (1U << 13) /* Disable EMUTRAMP */
72530 +#define PF_RANDMMAP (1U << 14) /* Enable RANDMMAP */
72531 +#define PF_NORANDMMAP (1U << 15) /* Disable RANDMMAP */
72532 +
72533 typedef struct elf32_phdr{
72534 Elf32_Word p_type;
72535 Elf32_Off p_offset;
72536 @@ -332,6 +358,8 @@ typedef struct elf64_shdr {
72537 #define EI_OSABI 7
72538 #define EI_PAD 8
72539
72540 +#define EI_PAX 14
72541 +
72542 #define ELFMAG0 0x7f /* EI_MAG */
72543 #define ELFMAG1 'E'
72544 #define ELFMAG2 'L'
72545 diff --git a/include/uapi/linux/personality.h b/include/uapi/linux/personality.h
72546 index aa169c4..6a2771d 100644
72547 --- a/include/uapi/linux/personality.h
72548 +++ b/include/uapi/linux/personality.h
72549 @@ -30,6 +30,7 @@ enum {
72550 #define PER_CLEAR_ON_SETID (READ_IMPLIES_EXEC | \
72551 ADDR_NO_RANDOMIZE | \
72552 ADDR_COMPAT_LAYOUT | \
72553 + ADDR_LIMIT_3GB | \
72554 MMAP_PAGE_ZERO)
72555
72556 /*
72557 diff --git a/include/uapi/linux/screen_info.h b/include/uapi/linux/screen_info.h
72558 index 7530e74..e714828 100644
72559 --- a/include/uapi/linux/screen_info.h
72560 +++ b/include/uapi/linux/screen_info.h
72561 @@ -43,7 +43,8 @@ struct screen_info {
72562 __u16 pages; /* 0x32 */
72563 __u16 vesa_attributes; /* 0x34 */
72564 __u32 capabilities; /* 0x36 */
72565 - __u8 _reserved[6]; /* 0x3a */
72566 + __u16 vesapm_size; /* 0x3a */
72567 + __u8 _reserved[4]; /* 0x3c */
72568 } __attribute__((packed));
72569
72570 #define VIDEO_TYPE_MDA 0x10 /* Monochrome Text Display */
72571 diff --git a/include/uapi/linux/swab.h b/include/uapi/linux/swab.h
72572 index 0e011eb..82681b1 100644
72573 --- a/include/uapi/linux/swab.h
72574 +++ b/include/uapi/linux/swab.h
72575 @@ -43,7 +43,7 @@
72576 * ___swab16, ___swab32, ___swab64, ___swahw32, ___swahb32
72577 */
72578
72579 -static inline __attribute_const__ __u16 __fswab16(__u16 val)
72580 +static inline __intentional_overflow(-1) __attribute_const__ __u16 __fswab16(__u16 val)
72581 {
72582 #ifdef __HAVE_BUILTIN_BSWAP16__
72583 return __builtin_bswap16(val);
72584 @@ -54,7 +54,7 @@ static inline __attribute_const__ __u16 __fswab16(__u16 val)
72585 #endif
72586 }
72587
72588 -static inline __attribute_const__ __u32 __fswab32(__u32 val)
72589 +static inline __intentional_overflow(-1) __attribute_const__ __u32 __fswab32(__u32 val)
72590 {
72591 #ifdef __HAVE_BUILTIN_BSWAP32__
72592 return __builtin_bswap32(val);
72593 @@ -65,7 +65,7 @@ static inline __attribute_const__ __u32 __fswab32(__u32 val)
72594 #endif
72595 }
72596
72597 -static inline __attribute_const__ __u64 __fswab64(__u64 val)
72598 +static inline __intentional_overflow(-1) __attribute_const__ __u64 __fswab64(__u64 val)
72599 {
72600 #ifdef __HAVE_BUILTIN_BSWAP64__
72601 return __builtin_bswap64(val);
72602 diff --git a/include/uapi/linux/sysctl.h b/include/uapi/linux/sysctl.h
72603 index 6d67213..8dab561 100644
72604 --- a/include/uapi/linux/sysctl.h
72605 +++ b/include/uapi/linux/sysctl.h
72606 @@ -155,7 +155,11 @@ enum
72607 KERN_PANIC_ON_NMI=76, /* int: whether we will panic on an unrecovered */
72608 };
72609
72610 -
72611 +#ifdef CONFIG_PAX_SOFTMODE
72612 +enum {
72613 + PAX_SOFTMODE=1 /* PaX: disable/enable soft mode */
72614 +};
72615 +#endif
72616
72617 /* CTL_VM names: */
72618 enum
72619 diff --git a/include/uapi/linux/xattr.h b/include/uapi/linux/xattr.h
72620 index 26607bd..588b65f 100644
72621 --- a/include/uapi/linux/xattr.h
72622 +++ b/include/uapi/linux/xattr.h
72623 @@ -60,5 +60,9 @@
72624 #define XATTR_POSIX_ACL_DEFAULT "posix_acl_default"
72625 #define XATTR_NAME_POSIX_ACL_DEFAULT XATTR_SYSTEM_PREFIX XATTR_POSIX_ACL_DEFAULT
72626
72627 +/* User namespace */
72628 +#define XATTR_PAX_PREFIX XATTR_USER_PREFIX "pax."
72629 +#define XATTR_PAX_FLAGS_SUFFIX "flags"
72630 +#define XATTR_NAME_PAX_FLAGS XATTR_PAX_PREFIX XATTR_PAX_FLAGS_SUFFIX
72631
72632 #endif /* _UAPI_LINUX_XATTR_H */
72633 diff --git a/include/video/udlfb.h b/include/video/udlfb.h
72634 index f9466fa..f4e2b81 100644
72635 --- a/include/video/udlfb.h
72636 +++ b/include/video/udlfb.h
72637 @@ -53,10 +53,10 @@ struct dlfb_data {
72638 u32 pseudo_palette[256];
72639 int blank_mode; /*one of FB_BLANK_ */
72640 /* blit-only rendering path metrics, exposed through sysfs */
72641 - atomic_t bytes_rendered; /* raw pixel-bytes driver asked to render */
72642 - atomic_t bytes_identical; /* saved effort with backbuffer comparison */
72643 - atomic_t bytes_sent; /* to usb, after compression including overhead */
72644 - atomic_t cpu_kcycles_used; /* transpired during pixel processing */
72645 + atomic_unchecked_t bytes_rendered; /* raw pixel-bytes driver asked to render */
72646 + atomic_unchecked_t bytes_identical; /* saved effort with backbuffer comparison */
72647 + atomic_unchecked_t bytes_sent; /* to usb, after compression including overhead */
72648 + atomic_unchecked_t cpu_kcycles_used; /* transpired during pixel processing */
72649 };
72650
72651 #define NR_USB_REQUEST_I2C_SUB_IO 0x02
72652 diff --git a/include/video/uvesafb.h b/include/video/uvesafb.h
72653 index 0993a22..32ba2fe 100644
72654 --- a/include/video/uvesafb.h
72655 +++ b/include/video/uvesafb.h
72656 @@ -177,6 +177,7 @@ struct uvesafb_par {
72657 u8 ypan; /* 0 - nothing, 1 - ypan, 2 - ywrap */
72658 u8 pmi_setpal; /* PMI for palette changes */
72659 u16 *pmi_base; /* protected mode interface location */
72660 + u8 *pmi_code; /* protected mode code location */
72661 void *pmi_start;
72662 void *pmi_pal;
72663 u8 *vbe_state_orig; /*
72664 diff --git a/init/Kconfig b/init/Kconfig
72665 index be8b7f5..1eeca9b 100644
72666 --- a/init/Kconfig
72667 +++ b/init/Kconfig
72668 @@ -990,6 +990,7 @@ endif # CGROUPS
72669
72670 config CHECKPOINT_RESTORE
72671 bool "Checkpoint/restore support" if EXPERT
72672 + depends on !GRKERNSEC
72673 default n
72674 help
72675 Enables additional kernel features in a sake of checkpoint/restore.
72676 @@ -1468,7 +1469,7 @@ config SLUB_DEBUG
72677
72678 config COMPAT_BRK
72679 bool "Disable heap randomization"
72680 - default y
72681 + default n
72682 help
72683 Randomizing heap placement makes heap exploits harder, but it
72684 also breaks ancient binaries (including anything libc5 based).
72685 @@ -1711,7 +1712,7 @@ config INIT_ALL_POSSIBLE
72686 config STOP_MACHINE
72687 bool
72688 default y
72689 - depends on (SMP && MODULE_UNLOAD) || HOTPLUG_CPU
72690 + depends on (SMP && MODULE_UNLOAD) || HOTPLUG_CPU || GRKERNSEC
72691 help
72692 Need stop_machine() primitive.
72693
72694 diff --git a/init/Makefile b/init/Makefile
72695 index 7bc47ee..6da2dc7 100644
72696 --- a/init/Makefile
72697 +++ b/init/Makefile
72698 @@ -2,6 +2,9 @@
72699 # Makefile for the linux kernel.
72700 #
72701
72702 +ccflags-y := $(GCC_PLUGINS_CFLAGS)
72703 +asflags-y := $(GCC_PLUGINS_AFLAGS)
72704 +
72705 obj-y := main.o version.o mounts.o
72706 ifneq ($(CONFIG_BLK_DEV_INITRD),y)
72707 obj-y += noinitramfs.o
72708 diff --git a/init/do_mounts.c b/init/do_mounts.c
72709 index 1d1b634..a1c810f 100644
72710 --- a/init/do_mounts.c
72711 +++ b/init/do_mounts.c
72712 @@ -355,11 +355,11 @@ static void __init get_fs_names(char *page)
72713 static int __init do_mount_root(char *name, char *fs, int flags, void *data)
72714 {
72715 struct super_block *s;
72716 - int err = sys_mount(name, "/root", fs, flags, data);
72717 + int err = sys_mount((char __force_user *)name, (char __force_user *)"/root", (char __force_user *)fs, flags, (void __force_user *)data);
72718 if (err)
72719 return err;
72720
72721 - sys_chdir("/root");
72722 + sys_chdir((const char __force_user *)"/root");
72723 s = current->fs->pwd.dentry->d_sb;
72724 ROOT_DEV = s->s_dev;
72725 printk(KERN_INFO
72726 @@ -480,18 +480,18 @@ void __init change_floppy(char *fmt, ...)
72727 va_start(args, fmt);
72728 vsprintf(buf, fmt, args);
72729 va_end(args);
72730 - fd = sys_open("/dev/root", O_RDWR | O_NDELAY, 0);
72731 + fd = sys_open((char __user *)"/dev/root", O_RDWR | O_NDELAY, 0);
72732 if (fd >= 0) {
72733 sys_ioctl(fd, FDEJECT, 0);
72734 sys_close(fd);
72735 }
72736 printk(KERN_NOTICE "VFS: Insert %s and press ENTER\n", buf);
72737 - fd = sys_open("/dev/console", O_RDWR, 0);
72738 + fd = sys_open((__force const char __user *)"/dev/console", O_RDWR, 0);
72739 if (fd >= 0) {
72740 sys_ioctl(fd, TCGETS, (long)&termios);
72741 termios.c_lflag &= ~ICANON;
72742 sys_ioctl(fd, TCSETSF, (long)&termios);
72743 - sys_read(fd, &c, 1);
72744 + sys_read(fd, (char __user *)&c, 1);
72745 termios.c_lflag |= ICANON;
72746 sys_ioctl(fd, TCSETSF, (long)&termios);
72747 sys_close(fd);
72748 @@ -585,6 +585,6 @@ void __init prepare_namespace(void)
72749 mount_root();
72750 out:
72751 devtmpfs_mount("dev");
72752 - sys_mount(".", "/", NULL, MS_MOVE, NULL);
72753 - sys_chroot(".");
72754 + sys_mount((char __force_user *)".", (char __force_user *)"/", NULL, MS_MOVE, NULL);
72755 + sys_chroot((const char __force_user *)".");
72756 }
72757 diff --git a/init/do_mounts.h b/init/do_mounts.h
72758 index f5b978a..69dbfe8 100644
72759 --- a/init/do_mounts.h
72760 +++ b/init/do_mounts.h
72761 @@ -15,15 +15,15 @@ extern int root_mountflags;
72762
72763 static inline int create_dev(char *name, dev_t dev)
72764 {
72765 - sys_unlink(name);
72766 - return sys_mknod(name, S_IFBLK|0600, new_encode_dev(dev));
72767 + sys_unlink((char __force_user *)name);
72768 + return sys_mknod((char __force_user *)name, S_IFBLK|0600, new_encode_dev(dev));
72769 }
72770
72771 #if BITS_PER_LONG == 32
72772 static inline u32 bstat(char *name)
72773 {
72774 struct stat64 stat;
72775 - if (sys_stat64(name, &stat) != 0)
72776 + if (sys_stat64((char __force_user *)name, (struct stat64 __force_user *)&stat) != 0)
72777 return 0;
72778 if (!S_ISBLK(stat.st_mode))
72779 return 0;
72780 @@ -35,7 +35,7 @@ static inline u32 bstat(char *name)
72781 static inline u32 bstat(char *name)
72782 {
72783 struct stat stat;
72784 - if (sys_newstat(name, &stat) != 0)
72785 + if (sys_newstat((const char __force_user *)name, (struct stat __force_user *)&stat) != 0)
72786 return 0;
72787 if (!S_ISBLK(stat.st_mode))
72788 return 0;
72789 diff --git a/init/do_mounts_initrd.c b/init/do_mounts_initrd.c
72790 index f9acf71..1e19144 100644
72791 --- a/init/do_mounts_initrd.c
72792 +++ b/init/do_mounts_initrd.c
72793 @@ -58,8 +58,8 @@ static void __init handle_initrd(void)
72794 create_dev("/dev/root.old", Root_RAM0);
72795 /* mount initrd on rootfs' /root */
72796 mount_block_root("/dev/root.old", root_mountflags & ~MS_RDONLY);
72797 - sys_mkdir("/old", 0700);
72798 - sys_chdir("/old");
72799 + sys_mkdir((const char __force_user *)"/old", 0700);
72800 + sys_chdir((const char __force_user *)"/old");
72801
72802 /*
72803 * In case that a resume from disk is carried out by linuxrc or one of
72804 @@ -73,31 +73,31 @@ static void __init handle_initrd(void)
72805 current->flags &= ~PF_FREEZER_SKIP;
72806
72807 /* move initrd to rootfs' /old */
72808 - sys_mount("..", ".", NULL, MS_MOVE, NULL);
72809 + sys_mount((char __force_user *)"..", (char __force_user *)".", NULL, MS_MOVE, NULL);
72810 /* switch root and cwd back to / of rootfs */
72811 - sys_chroot("..");
72812 + sys_chroot((const char __force_user *)"..");
72813
72814 if (new_decode_dev(real_root_dev) == Root_RAM0) {
72815 - sys_chdir("/old");
72816 + sys_chdir((const char __force_user *)"/old");
72817 return;
72818 }
72819
72820 - sys_chdir("/");
72821 + sys_chdir((const char __force_user *)"/");
72822 ROOT_DEV = new_decode_dev(real_root_dev);
72823 mount_root();
72824
72825 printk(KERN_NOTICE "Trying to move old root to /initrd ... ");
72826 - error = sys_mount("/old", "/root/initrd", NULL, MS_MOVE, NULL);
72827 + error = sys_mount((char __force_user *)"/old", (char __force_user *)"/root/initrd", NULL, MS_MOVE, NULL);
72828 if (!error)
72829 printk("okay\n");
72830 else {
72831 - int fd = sys_open("/dev/root.old", O_RDWR, 0);
72832 + int fd = sys_open((const char __force_user *)"/dev/root.old", O_RDWR, 0);
72833 if (error == -ENOENT)
72834 printk("/initrd does not exist. Ignored.\n");
72835 else
72836 printk("failed\n");
72837 printk(KERN_NOTICE "Unmounting old root\n");
72838 - sys_umount("/old", MNT_DETACH);
72839 + sys_umount((char __force_user *)"/old", MNT_DETACH);
72840 printk(KERN_NOTICE "Trying to free ramdisk memory ... ");
72841 if (fd < 0) {
72842 error = fd;
72843 @@ -120,11 +120,11 @@ int __init initrd_load(void)
72844 * mounted in the normal path.
72845 */
72846 if (rd_load_image("/initrd.image") && ROOT_DEV != Root_RAM0) {
72847 - sys_unlink("/initrd.image");
72848 + sys_unlink((const char __force_user *)"/initrd.image");
72849 handle_initrd();
72850 return 1;
72851 }
72852 }
72853 - sys_unlink("/initrd.image");
72854 + sys_unlink((const char __force_user *)"/initrd.image");
72855 return 0;
72856 }
72857 diff --git a/init/do_mounts_md.c b/init/do_mounts_md.c
72858 index 8cb6db5..d729f50 100644
72859 --- a/init/do_mounts_md.c
72860 +++ b/init/do_mounts_md.c
72861 @@ -180,7 +180,7 @@ static void __init md_setup_drive(void)
72862 partitioned ? "_d" : "", minor,
72863 md_setup_args[ent].device_names);
72864
72865 - fd = sys_open(name, 0, 0);
72866 + fd = sys_open((char __force_user *)name, 0, 0);
72867 if (fd < 0) {
72868 printk(KERN_ERR "md: open failed - cannot start "
72869 "array %s\n", name);
72870 @@ -243,7 +243,7 @@ static void __init md_setup_drive(void)
72871 * array without it
72872 */
72873 sys_close(fd);
72874 - fd = sys_open(name, 0, 0);
72875 + fd = sys_open((char __force_user *)name, 0, 0);
72876 sys_ioctl(fd, BLKRRPART, 0);
72877 }
72878 sys_close(fd);
72879 @@ -293,7 +293,7 @@ static void __init autodetect_raid(void)
72880
72881 wait_for_device_probe();
72882
72883 - fd = sys_open("/dev/md0", 0, 0);
72884 + fd = sys_open((const char __force_user *) "/dev/md0", 0, 0);
72885 if (fd >= 0) {
72886 sys_ioctl(fd, RAID_AUTORUN, raid_autopart);
72887 sys_close(fd);
72888 diff --git a/init/init_task.c b/init/init_task.c
72889 index 8b2f399..f0797c9 100644
72890 --- a/init/init_task.c
72891 +++ b/init/init_task.c
72892 @@ -20,5 +20,9 @@ EXPORT_SYMBOL(init_task);
72893 * Initial thread structure. Alignment of this is handled by a special
72894 * linker map entry.
72895 */
72896 +#ifdef CONFIG_X86
72897 +union thread_union init_thread_union __init_task_data;
72898 +#else
72899 union thread_union init_thread_union __init_task_data =
72900 { INIT_THREAD_INFO(init_task) };
72901 +#endif
72902 diff --git a/init/initramfs.c b/init/initramfs.c
72903 index 84c6bf1..8899338 100644
72904 --- a/init/initramfs.c
72905 +++ b/init/initramfs.c
72906 @@ -84,7 +84,7 @@ static void __init free_hash(void)
72907 }
72908 }
72909
72910 -static long __init do_utime(char *filename, time_t mtime)
72911 +static long __init do_utime(char __force_user *filename, time_t mtime)
72912 {
72913 struct timespec t[2];
72914
72915 @@ -119,7 +119,7 @@ static void __init dir_utime(void)
72916 struct dir_entry *de, *tmp;
72917 list_for_each_entry_safe(de, tmp, &dir_list, list) {
72918 list_del(&de->list);
72919 - do_utime(de->name, de->mtime);
72920 + do_utime((char __force_user *)de->name, de->mtime);
72921 kfree(de->name);
72922 kfree(de);
72923 }
72924 @@ -281,7 +281,7 @@ static int __init maybe_link(void)
72925 if (nlink >= 2) {
72926 char *old = find_link(major, minor, ino, mode, collected);
72927 if (old)
72928 - return (sys_link(old, collected) < 0) ? -1 : 1;
72929 + return (sys_link((char __force_user *)old, (char __force_user *)collected) < 0) ? -1 : 1;
72930 }
72931 return 0;
72932 }
72933 @@ -290,11 +290,11 @@ static void __init clean_path(char *path, umode_t mode)
72934 {
72935 struct stat st;
72936
72937 - if (!sys_newlstat(path, &st) && (st.st_mode^mode) & S_IFMT) {
72938 + if (!sys_newlstat((char __force_user *)path, (struct stat __force_user *)&st) && (st.st_mode^mode) & S_IFMT) {
72939 if (S_ISDIR(st.st_mode))
72940 - sys_rmdir(path);
72941 + sys_rmdir((char __force_user *)path);
72942 else
72943 - sys_unlink(path);
72944 + sys_unlink((char __force_user *)path);
72945 }
72946 }
72947
72948 @@ -315,7 +315,7 @@ static int __init do_name(void)
72949 int openflags = O_WRONLY|O_CREAT;
72950 if (ml != 1)
72951 openflags |= O_TRUNC;
72952 - wfd = sys_open(collected, openflags, mode);
72953 + wfd = sys_open((char __force_user *)collected, openflags, mode);
72954
72955 if (wfd >= 0) {
72956 sys_fchown(wfd, uid, gid);
72957 @@ -327,17 +327,17 @@ static int __init do_name(void)
72958 }
72959 }
72960 } else if (S_ISDIR(mode)) {
72961 - sys_mkdir(collected, mode);
72962 - sys_chown(collected, uid, gid);
72963 - sys_chmod(collected, mode);
72964 + sys_mkdir((char __force_user *)collected, mode);
72965 + sys_chown((char __force_user *)collected, uid, gid);
72966 + sys_chmod((char __force_user *)collected, mode);
72967 dir_add(collected, mtime);
72968 } else if (S_ISBLK(mode) || S_ISCHR(mode) ||
72969 S_ISFIFO(mode) || S_ISSOCK(mode)) {
72970 if (maybe_link() == 0) {
72971 - sys_mknod(collected, mode, rdev);
72972 - sys_chown(collected, uid, gid);
72973 - sys_chmod(collected, mode);
72974 - do_utime(collected, mtime);
72975 + sys_mknod((char __force_user *)collected, mode, rdev);
72976 + sys_chown((char __force_user *)collected, uid, gid);
72977 + sys_chmod((char __force_user *)collected, mode);
72978 + do_utime((char __force_user *)collected, mtime);
72979 }
72980 }
72981 return 0;
72982 @@ -346,15 +346,15 @@ static int __init do_name(void)
72983 static int __init do_copy(void)
72984 {
72985 if (count >= body_len) {
72986 - sys_write(wfd, victim, body_len);
72987 + sys_write(wfd, (char __force_user *)victim, body_len);
72988 sys_close(wfd);
72989 - do_utime(vcollected, mtime);
72990 + do_utime((char __force_user *)vcollected, mtime);
72991 kfree(vcollected);
72992 eat(body_len);
72993 state = SkipIt;
72994 return 0;
72995 } else {
72996 - sys_write(wfd, victim, count);
72997 + sys_write(wfd, (char __force_user *)victim, count);
72998 body_len -= count;
72999 eat(count);
73000 return 1;
73001 @@ -365,9 +365,9 @@ static int __init do_symlink(void)
73002 {
73003 collected[N_ALIGN(name_len) + body_len] = '\0';
73004 clean_path(collected, 0);
73005 - sys_symlink(collected + N_ALIGN(name_len), collected);
73006 - sys_lchown(collected, uid, gid);
73007 - do_utime(collected, mtime);
73008 + sys_symlink((char __force_user *)collected + N_ALIGN(name_len), (char __force_user *)collected);
73009 + sys_lchown((char __force_user *)collected, uid, gid);
73010 + do_utime((char __force_user *)collected, mtime);
73011 state = SkipIt;
73012 next_state = Reset;
73013 return 0;
73014 diff --git a/init/main.c b/init/main.c
73015 index cee4b5c..360e10a 100644
73016 --- a/init/main.c
73017 +++ b/init/main.c
73018 @@ -96,6 +96,8 @@ static inline void mark_rodata_ro(void) { }
73019 extern void tc_init(void);
73020 #endif
73021
73022 +extern void grsecurity_init(void);
73023 +
73024 /*
73025 * Debug helper: via this flag we know that we are in 'early bootup code'
73026 * where only the boot processor is running with IRQ disabled. This means
73027 @@ -149,6 +151,61 @@ static int __init set_reset_devices(char *str)
73028
73029 __setup("reset_devices", set_reset_devices);
73030
73031 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
73032 +kgid_t grsec_proc_gid = KGIDT_INIT(CONFIG_GRKERNSEC_PROC_GID);
73033 +static int __init setup_grsec_proc_gid(char *str)
73034 +{
73035 + grsec_proc_gid = KGIDT_INIT(simple_strtol(str, NULL, 0));
73036 + return 1;
73037 +}
73038 +__setup("grsec_proc_gid=", setup_grsec_proc_gid);
73039 +#endif
73040 +
73041 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
73042 +extern char pax_enter_kernel_user[];
73043 +extern char pax_exit_kernel_user[];
73044 +extern pgdval_t clone_pgd_mask;
73045 +#endif
73046 +
73047 +#if defined(CONFIG_X86) && defined(CONFIG_PAX_MEMORY_UDEREF)
73048 +static int __init setup_pax_nouderef(char *str)
73049 +{
73050 +#ifdef CONFIG_X86_32
73051 + unsigned int cpu;
73052 + struct desc_struct *gdt;
73053 +
73054 + for (cpu = 0; cpu < nr_cpu_ids; cpu++) {
73055 + gdt = get_cpu_gdt_table(cpu);
73056 + gdt[GDT_ENTRY_KERNEL_DS].type = 3;
73057 + gdt[GDT_ENTRY_KERNEL_DS].limit = 0xf;
73058 + gdt[GDT_ENTRY_DEFAULT_USER_CS].limit = 0xf;
73059 + gdt[GDT_ENTRY_DEFAULT_USER_DS].limit = 0xf;
73060 + }
73061 + loadsegment(ds, __KERNEL_DS);
73062 + loadsegment(es, __KERNEL_DS);
73063 + loadsegment(ss, __KERNEL_DS);
73064 +#else
73065 + memcpy(pax_enter_kernel_user, (unsigned char []){0xc3}, 1);
73066 + memcpy(pax_exit_kernel_user, (unsigned char []){0xc3}, 1);
73067 + clone_pgd_mask = ~(pgdval_t)0UL;
73068 +#endif
73069 +
73070 + return 0;
73071 +}
73072 +early_param("pax_nouderef", setup_pax_nouderef);
73073 +#endif
73074 +
73075 +#ifdef CONFIG_PAX_SOFTMODE
73076 +int pax_softmode;
73077 +
73078 +static int __init setup_pax_softmode(char *str)
73079 +{
73080 + get_option(&str, &pax_softmode);
73081 + return 1;
73082 +}
73083 +__setup("pax_softmode=", setup_pax_softmode);
73084 +#endif
73085 +
73086 static const char * argv_init[MAX_INIT_ARGS+2] = { "init", NULL, };
73087 const char * envp_init[MAX_INIT_ENVS+2] = { "HOME=/", "TERM=linux", NULL, };
73088 static const char *panic_later, *panic_param;
73089 @@ -681,6 +738,7 @@ int __init_or_module do_one_initcall(initcall_t fn)
73090 {
73091 int count = preempt_count();
73092 int ret;
73093 + const char *msg1 = "", *msg2 = "";
73094
73095 if (initcall_debug)
73096 ret = do_one_initcall_debug(fn);
73097 @@ -693,15 +751,15 @@ int __init_or_module do_one_initcall(initcall_t fn)
73098 sprintf(msgbuf, "error code %d ", ret);
73099
73100 if (preempt_count() != count) {
73101 - strlcat(msgbuf, "preemption imbalance ", sizeof(msgbuf));
73102 + msg1 = " preemption imbalance";
73103 preempt_count() = count;
73104 }
73105 if (irqs_disabled()) {
73106 - strlcat(msgbuf, "disabled interrupts ", sizeof(msgbuf));
73107 + msg2 = " disabled interrupts";
73108 local_irq_enable();
73109 }
73110 - if (msgbuf[0]) {
73111 - printk("initcall %pF returned with %s\n", fn, msgbuf);
73112 + if (msgbuf[0] || *msg1 || *msg2) {
73113 + printk("initcall %pF returned with %s%s%s\n", fn, msgbuf, msg1, msg2);
73114 }
73115
73116 return ret;
73117 @@ -755,8 +813,14 @@ static void __init do_initcall_level(int level)
73118 level, level,
73119 &repair_env_string);
73120
73121 - for (fn = initcall_levels[level]; fn < initcall_levels[level+1]; fn++)
73122 + for (fn = initcall_levels[level]; fn < initcall_levels[level+1]; fn++) {
73123 do_one_initcall(*fn);
73124 +
73125 +#ifdef LATENT_ENTROPY_PLUGIN
73126 + add_device_randomness((const void *)&latent_entropy, sizeof(latent_entropy));
73127 +#endif
73128 +
73129 + }
73130 }
73131
73132 static void __init do_initcalls(void)
73133 @@ -790,8 +854,14 @@ static void __init do_pre_smp_initcalls(void)
73134 {
73135 initcall_t *fn;
73136
73137 - for (fn = __initcall_start; fn < __initcall0_start; fn++)
73138 + for (fn = __initcall_start; fn < __initcall0_start; fn++) {
73139 do_one_initcall(*fn);
73140 +
73141 +#ifdef LATENT_ENTROPY_PLUGIN
73142 + add_device_randomness((const void *)&latent_entropy, sizeof(latent_entropy));
73143 +#endif
73144 +
73145 + }
73146 }
73147
73148 static int run_init_process(const char *init_filename)
73149 @@ -877,7 +947,7 @@ static noinline void __init kernel_init_freeable(void)
73150 do_basic_setup();
73151
73152 /* Open the /dev/console on the rootfs, this should never fail */
73153 - if (sys_open((const char __user *) "/dev/console", O_RDWR, 0) < 0)
73154 + if (sys_open((const char __force_user *) "/dev/console", O_RDWR, 0) < 0)
73155 printk(KERN_WARNING "Warning: unable to open an initial console.\n");
73156
73157 (void) sys_dup(0);
73158 @@ -890,11 +960,13 @@ static noinline void __init kernel_init_freeable(void)
73159 if (!ramdisk_execute_command)
73160 ramdisk_execute_command = "/init";
73161
73162 - if (sys_access((const char __user *) ramdisk_execute_command, 0) != 0) {
73163 + if (sys_access((const char __force_user *) ramdisk_execute_command, 0) != 0) {
73164 ramdisk_execute_command = NULL;
73165 prepare_namespace();
73166 }
73167
73168 + grsecurity_init();
73169 +
73170 /*
73171 * Ok, we have completed the initial bootup, and
73172 * we're essentially up and running. Get rid of the
73173 diff --git a/ipc/ipc_sysctl.c b/ipc/ipc_sysctl.c
73174 index 130dfec..cc88451 100644
73175 --- a/ipc/ipc_sysctl.c
73176 +++ b/ipc/ipc_sysctl.c
73177 @@ -30,7 +30,7 @@ static void *get_ipc(ctl_table *table)
73178 static int proc_ipc_dointvec(ctl_table *table, int write,
73179 void __user *buffer, size_t *lenp, loff_t *ppos)
73180 {
73181 - struct ctl_table ipc_table;
73182 + ctl_table_no_const ipc_table;
73183
73184 memcpy(&ipc_table, table, sizeof(ipc_table));
73185 ipc_table.data = get_ipc(table);
73186 @@ -41,7 +41,7 @@ static int proc_ipc_dointvec(ctl_table *table, int write,
73187 static int proc_ipc_dointvec_minmax(ctl_table *table, int write,
73188 void __user *buffer, size_t *lenp, loff_t *ppos)
73189 {
73190 - struct ctl_table ipc_table;
73191 + ctl_table_no_const ipc_table;
73192
73193 memcpy(&ipc_table, table, sizeof(ipc_table));
73194 ipc_table.data = get_ipc(table);
73195 @@ -65,7 +65,7 @@ static int proc_ipc_dointvec_minmax_orphans(ctl_table *table, int write,
73196 static int proc_ipc_callback_dointvec(ctl_table *table, int write,
73197 void __user *buffer, size_t *lenp, loff_t *ppos)
73198 {
73199 - struct ctl_table ipc_table;
73200 + ctl_table_no_const ipc_table;
73201 size_t lenp_bef = *lenp;
73202 int rc;
73203
73204 @@ -88,7 +88,7 @@ static int proc_ipc_callback_dointvec(ctl_table *table, int write,
73205 static int proc_ipc_doulongvec_minmax(ctl_table *table, int write,
73206 void __user *buffer, size_t *lenp, loff_t *ppos)
73207 {
73208 - struct ctl_table ipc_table;
73209 + ctl_table_no_const ipc_table;
73210 memcpy(&ipc_table, table, sizeof(ipc_table));
73211 ipc_table.data = get_ipc(table);
73212
73213 @@ -122,7 +122,7 @@ static void ipc_auto_callback(int val)
73214 static int proc_ipcauto_dointvec_minmax(ctl_table *table, int write,
73215 void __user *buffer, size_t *lenp, loff_t *ppos)
73216 {
73217 - struct ctl_table ipc_table;
73218 + ctl_table_no_const ipc_table;
73219 size_t lenp_bef = *lenp;
73220 int oldval;
73221 int rc;
73222 diff --git a/ipc/mq_sysctl.c b/ipc/mq_sysctl.c
73223 index 383d638..943fdbb 100644
73224 --- a/ipc/mq_sysctl.c
73225 +++ b/ipc/mq_sysctl.c
73226 @@ -25,7 +25,7 @@ static void *get_mq(ctl_table *table)
73227 static int proc_mq_dointvec_minmax(ctl_table *table, int write,
73228 void __user *buffer, size_t *lenp, loff_t *ppos)
73229 {
73230 - struct ctl_table mq_table;
73231 + ctl_table_no_const mq_table;
73232 memcpy(&mq_table, table, sizeof(mq_table));
73233 mq_table.data = get_mq(table);
73234
73235 diff --git a/ipc/mqueue.c b/ipc/mqueue.c
73236 index 71a3ca1..cc330ee 100644
73237 --- a/ipc/mqueue.c
73238 +++ b/ipc/mqueue.c
73239 @@ -278,6 +278,7 @@ static struct inode *mqueue_get_inode(struct super_block *sb,
73240 mq_bytes = mq_treesize + (info->attr.mq_maxmsg *
73241 info->attr.mq_msgsize);
73242
73243 + gr_learn_resource(current, RLIMIT_MSGQUEUE, u->mq_bytes + mq_bytes, 1);
73244 spin_lock(&mq_lock);
73245 if (u->mq_bytes + mq_bytes < u->mq_bytes ||
73246 u->mq_bytes + mq_bytes > rlimit(RLIMIT_MSGQUEUE)) {
73247 diff --git a/ipc/msg.c b/ipc/msg.c
73248 index 31cd1bf..362ea07 100644
73249 --- a/ipc/msg.c
73250 +++ b/ipc/msg.c
73251 @@ -309,18 +309,19 @@ static inline int msg_security(struct kern_ipc_perm *ipcp, int msgflg)
73252 return security_msg_queue_associate(msq, msgflg);
73253 }
73254
73255 +static struct ipc_ops msg_ops = {
73256 + .getnew = newque,
73257 + .associate = msg_security,
73258 + .more_checks = NULL
73259 +};
73260 +
73261 SYSCALL_DEFINE2(msgget, key_t, key, int, msgflg)
73262 {
73263 struct ipc_namespace *ns;
73264 - struct ipc_ops msg_ops;
73265 struct ipc_params msg_params;
73266
73267 ns = current->nsproxy->ipc_ns;
73268
73269 - msg_ops.getnew = newque;
73270 - msg_ops.associate = msg_security;
73271 - msg_ops.more_checks = NULL;
73272 -
73273 msg_params.key = key;
73274 msg_params.flg = msgflg;
73275
73276 diff --git a/ipc/sem.c b/ipc/sem.c
73277 index 58d31f1..cce7a55 100644
73278 --- a/ipc/sem.c
73279 +++ b/ipc/sem.c
73280 @@ -364,10 +364,15 @@ static inline int sem_more_checks(struct kern_ipc_perm *ipcp,
73281 return 0;
73282 }
73283
73284 +static struct ipc_ops sem_ops = {
73285 + .getnew = newary,
73286 + .associate = sem_security,
73287 + .more_checks = sem_more_checks
73288 +};
73289 +
73290 SYSCALL_DEFINE3(semget, key_t, key, int, nsems, int, semflg)
73291 {
73292 struct ipc_namespace *ns;
73293 - struct ipc_ops sem_ops;
73294 struct ipc_params sem_params;
73295
73296 ns = current->nsproxy->ipc_ns;
73297 @@ -375,10 +380,6 @@ SYSCALL_DEFINE3(semget, key_t, key, int, nsems, int, semflg)
73298 if (nsems < 0 || nsems > ns->sc_semmsl)
73299 return -EINVAL;
73300
73301 - sem_ops.getnew = newary;
73302 - sem_ops.associate = sem_security;
73303 - sem_ops.more_checks = sem_more_checks;
73304 -
73305 sem_params.key = key;
73306 sem_params.flg = semflg;
73307 sem_params.u.nsems = nsems;
73308 diff --git a/ipc/shm.c b/ipc/shm.c
73309 index 4fa6d8f..55cff14 100644
73310 --- a/ipc/shm.c
73311 +++ b/ipc/shm.c
73312 @@ -69,6 +69,14 @@ static void shm_destroy (struct ipc_namespace *ns, struct shmid_kernel *shp);
73313 static int sysvipc_shm_proc_show(struct seq_file *s, void *it);
73314 #endif
73315
73316 +#ifdef CONFIG_GRKERNSEC
73317 +extern int gr_handle_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
73318 + const time_t shm_createtime, const kuid_t cuid,
73319 + const int shmid);
73320 +extern int gr_chroot_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
73321 + const time_t shm_createtime);
73322 +#endif
73323 +
73324 void shm_init_ns(struct ipc_namespace *ns)
73325 {
73326 ns->shm_ctlmax = SHMMAX;
73327 @@ -521,6 +529,14 @@ static int newseg(struct ipc_namespace *ns, struct ipc_params *params)
73328 shp->shm_lprid = 0;
73329 shp->shm_atim = shp->shm_dtim = 0;
73330 shp->shm_ctim = get_seconds();
73331 +#ifdef CONFIG_GRKERNSEC
73332 + {
73333 + struct timespec timeval;
73334 + do_posix_clock_monotonic_gettime(&timeval);
73335 +
73336 + shp->shm_createtime = timeval.tv_sec;
73337 + }
73338 +#endif
73339 shp->shm_segsz = size;
73340 shp->shm_nattch = 0;
73341 shp->shm_file = file;
73342 @@ -572,18 +588,19 @@ static inline int shm_more_checks(struct kern_ipc_perm *ipcp,
73343 return 0;
73344 }
73345
73346 +static struct ipc_ops shm_ops = {
73347 + .getnew = newseg,
73348 + .associate = shm_security,
73349 + .more_checks = shm_more_checks
73350 +};
73351 +
73352 SYSCALL_DEFINE3(shmget, key_t, key, size_t, size, int, shmflg)
73353 {
73354 struct ipc_namespace *ns;
73355 - struct ipc_ops shm_ops;
73356 struct ipc_params shm_params;
73357
73358 ns = current->nsproxy->ipc_ns;
73359
73360 - shm_ops.getnew = newseg;
73361 - shm_ops.associate = shm_security;
73362 - shm_ops.more_checks = shm_more_checks;
73363 -
73364 shm_params.key = key;
73365 shm_params.flg = shmflg;
73366 shm_params.u.size = size;
73367 @@ -1004,6 +1021,12 @@ long do_shmat(int shmid, char __user *shmaddr, int shmflg, ulong *raddr,
73368 f_mode = FMODE_READ | FMODE_WRITE;
73369 }
73370 if (shmflg & SHM_EXEC) {
73371 +
73372 +#ifdef CONFIG_PAX_MPROTECT
73373 + if (current->mm->pax_flags & MF_PAX_MPROTECT)
73374 + goto out;
73375 +#endif
73376 +
73377 prot |= PROT_EXEC;
73378 acc_mode |= S_IXUGO;
73379 }
73380 @@ -1027,9 +1050,21 @@ long do_shmat(int shmid, char __user *shmaddr, int shmflg, ulong *raddr,
73381 if (err)
73382 goto out_unlock;
73383
73384 +#ifdef CONFIG_GRKERNSEC
73385 + if (!gr_handle_shmat(shp->shm_cprid, shp->shm_lapid, shp->shm_createtime,
73386 + shp->shm_perm.cuid, shmid) ||
73387 + !gr_chroot_shmat(shp->shm_cprid, shp->shm_lapid, shp->shm_createtime)) {
73388 + err = -EACCES;
73389 + goto out_unlock;
73390 + }
73391 +#endif
73392 +
73393 path = shp->shm_file->f_path;
73394 path_get(&path);
73395 shp->shm_nattch++;
73396 +#ifdef CONFIG_GRKERNSEC
73397 + shp->shm_lapid = current->pid;
73398 +#endif
73399 size = i_size_read(path.dentry->d_inode);
73400 shm_unlock(shp);
73401
73402 diff --git a/kernel/acct.c b/kernel/acct.c
73403 index 051e071..15e0920 100644
73404 --- a/kernel/acct.c
73405 +++ b/kernel/acct.c
73406 @@ -550,7 +550,7 @@ static void do_acct_process(struct bsd_acct_struct *acct,
73407 */
73408 flim = current->signal->rlim[RLIMIT_FSIZE].rlim_cur;
73409 current->signal->rlim[RLIMIT_FSIZE].rlim_cur = RLIM_INFINITY;
73410 - file->f_op->write(file, (char *)&ac,
73411 + file->f_op->write(file, (char __force_user *)&ac,
73412 sizeof(acct_t), &file->f_pos);
73413 current->signal->rlim[RLIMIT_FSIZE].rlim_cur = flim;
73414 set_fs(fs);
73415 diff --git a/kernel/audit.c b/kernel/audit.c
73416 index d596e53..dbef3c3 100644
73417 --- a/kernel/audit.c
73418 +++ b/kernel/audit.c
73419 @@ -116,7 +116,7 @@ u32 audit_sig_sid = 0;
73420 3) suppressed due to audit_rate_limit
73421 4) suppressed due to audit_backlog_limit
73422 */
73423 -static atomic_t audit_lost = ATOMIC_INIT(0);
73424 +static atomic_unchecked_t audit_lost = ATOMIC_INIT(0);
73425
73426 /* The netlink socket. */
73427 static struct sock *audit_sock;
73428 @@ -238,7 +238,7 @@ void audit_log_lost(const char *message)
73429 unsigned long now;
73430 int print;
73431
73432 - atomic_inc(&audit_lost);
73433 + atomic_inc_unchecked(&audit_lost);
73434
73435 print = (audit_failure == AUDIT_FAIL_PANIC || !audit_rate_limit);
73436
73437 @@ -257,7 +257,7 @@ void audit_log_lost(const char *message)
73438 printk(KERN_WARNING
73439 "audit: audit_lost=%d audit_rate_limit=%d "
73440 "audit_backlog_limit=%d\n",
73441 - atomic_read(&audit_lost),
73442 + atomic_read_unchecked(&audit_lost),
73443 audit_rate_limit,
73444 audit_backlog_limit);
73445 audit_panic(message);
73446 @@ -681,7 +681,7 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
73447 status_set.pid = audit_pid;
73448 status_set.rate_limit = audit_rate_limit;
73449 status_set.backlog_limit = audit_backlog_limit;
73450 - status_set.lost = atomic_read(&audit_lost);
73451 + status_set.lost = atomic_read_unchecked(&audit_lost);
73452 status_set.backlog = skb_queue_len(&audit_skb_queue);
73453 audit_send_reply(NETLINK_CB(skb).portid, seq, AUDIT_GET, 0, 0,
73454 &status_set, sizeof(status_set));
73455 diff --git a/kernel/auditsc.c b/kernel/auditsc.c
73456 index a371f85..da826c1 100644
73457 --- a/kernel/auditsc.c
73458 +++ b/kernel/auditsc.c
73459 @@ -2292,7 +2292,7 @@ int auditsc_get_stamp(struct audit_context *ctx,
73460 }
73461
73462 /* global counter which is incremented every time something logs in */
73463 -static atomic_t session_id = ATOMIC_INIT(0);
73464 +static atomic_unchecked_t session_id = ATOMIC_INIT(0);
73465
73466 /**
73467 * audit_set_loginuid - set current task's audit_context loginuid
73468 @@ -2316,7 +2316,7 @@ int audit_set_loginuid(kuid_t loginuid)
73469 return -EPERM;
73470 #endif /* CONFIG_AUDIT_LOGINUID_IMMUTABLE */
73471
73472 - sessionid = atomic_inc_return(&session_id);
73473 + sessionid = atomic_inc_return_unchecked(&session_id);
73474 if (context && context->in_syscall) {
73475 struct audit_buffer *ab;
73476
73477 diff --git a/kernel/capability.c b/kernel/capability.c
73478 index 493d972..f87dfbd 100644
73479 --- a/kernel/capability.c
73480 +++ b/kernel/capability.c
73481 @@ -202,6 +202,9 @@ SYSCALL_DEFINE2(capget, cap_user_header_t, header, cap_user_data_t, dataptr)
73482 * before modification is attempted and the application
73483 * fails.
73484 */
73485 + if (tocopy > ARRAY_SIZE(kdata))
73486 + return -EFAULT;
73487 +
73488 if (copy_to_user(dataptr, kdata, tocopy
73489 * sizeof(struct __user_cap_data_struct))) {
73490 return -EFAULT;
73491 @@ -303,10 +306,11 @@ bool has_ns_capability(struct task_struct *t,
73492 int ret;
73493
73494 rcu_read_lock();
73495 - ret = security_capable(__task_cred(t), ns, cap);
73496 + ret = security_capable(__task_cred(t), ns, cap) == 0 &&
73497 + gr_task_is_capable(t, __task_cred(t), cap);
73498 rcu_read_unlock();
73499
73500 - return (ret == 0);
73501 + return ret;
73502 }
73503
73504 /**
73505 @@ -343,10 +347,10 @@ bool has_ns_capability_noaudit(struct task_struct *t,
73506 int ret;
73507
73508 rcu_read_lock();
73509 - ret = security_capable_noaudit(__task_cred(t), ns, cap);
73510 + ret = security_capable_noaudit(__task_cred(t), ns, cap) == 0 && gr_task_is_capable_nolog(t, cap);
73511 rcu_read_unlock();
73512
73513 - return (ret == 0);
73514 + return ret;
73515 }
73516
73517 /**
73518 @@ -384,7 +388,7 @@ bool ns_capable(struct user_namespace *ns, int cap)
73519 BUG();
73520 }
73521
73522 - if (security_capable(current_cred(), ns, cap) == 0) {
73523 + if (security_capable(current_cred(), ns, cap) == 0 && gr_is_capable(cap)) {
73524 current->flags |= PF_SUPERPRIV;
73525 return true;
73526 }
73527 @@ -392,6 +396,21 @@ bool ns_capable(struct user_namespace *ns, int cap)
73528 }
73529 EXPORT_SYMBOL(ns_capable);
73530
73531 +bool ns_capable_nolog(struct user_namespace *ns, int cap)
73532 +{
73533 + if (unlikely(!cap_valid(cap))) {
73534 + printk(KERN_CRIT "capable_nolog() called with invalid cap=%u\n", cap);
73535 + BUG();
73536 + }
73537 +
73538 + if (security_capable_noaudit(current_cred(), ns, cap) == 0 && gr_is_capable_nolog(cap)) {
73539 + current->flags |= PF_SUPERPRIV;
73540 + return true;
73541 + }
73542 + return false;
73543 +}
73544 +EXPORT_SYMBOL(ns_capable_nolog);
73545 +
73546 /**
73547 * capable - Determine if the current task has a superior capability in effect
73548 * @cap: The capability to be tested for
73549 @@ -408,6 +427,12 @@ bool capable(int cap)
73550 }
73551 EXPORT_SYMBOL(capable);
73552
73553 +bool capable_nolog(int cap)
73554 +{
73555 + return ns_capable_nolog(&init_user_ns, cap);
73556 +}
73557 +EXPORT_SYMBOL(capable_nolog);
73558 +
73559 /**
73560 * nsown_capable - Check superior capability to one's own user_ns
73561 * @cap: The capability in question
73562 @@ -440,3 +465,10 @@ bool inode_capable(const struct inode *inode, int cap)
73563
73564 return ns_capable(ns, cap) && kuid_has_mapping(ns, inode->i_uid);
73565 }
73566 +
73567 +bool inode_capable_nolog(const struct inode *inode, int cap)
73568 +{
73569 + struct user_namespace *ns = current_user_ns();
73570 +
73571 + return ns_capable_nolog(ns, cap) && kuid_has_mapping(ns, inode->i_uid);
73572 +}
73573 diff --git a/kernel/cgroup.c b/kernel/cgroup.c
73574 index 1e23664..570a83d 100644
73575 --- a/kernel/cgroup.c
73576 +++ b/kernel/cgroup.c
73577 @@ -5543,7 +5543,7 @@ static int cgroup_css_links_read(struct cgroup *cont,
73578 struct css_set *cg = link->cg;
73579 struct task_struct *task;
73580 int count = 0;
73581 - seq_printf(seq, "css_set %p\n", cg);
73582 + seq_printf(seq, "css_set %pK\n", cg);
73583 list_for_each_entry(task, &cg->tasks, cg_list) {
73584 if (count++ > MAX_TASKS_SHOWN_PER_CSS) {
73585 seq_puts(seq, " ...\n");
73586 diff --git a/kernel/compat.c b/kernel/compat.c
73587 index 36700e9..73d770c 100644
73588 --- a/kernel/compat.c
73589 +++ b/kernel/compat.c
73590 @@ -13,6 +13,7 @@
73591
73592 #include <linux/linkage.h>
73593 #include <linux/compat.h>
73594 +#include <linux/module.h>
73595 #include <linux/errno.h>
73596 #include <linux/time.h>
73597 #include <linux/signal.h>
73598 @@ -220,7 +221,7 @@ static long compat_nanosleep_restart(struct restart_block *restart)
73599 mm_segment_t oldfs;
73600 long ret;
73601
73602 - restart->nanosleep.rmtp = (struct timespec __user *) &rmt;
73603 + restart->nanosleep.rmtp = (struct timespec __force_user *) &rmt;
73604 oldfs = get_fs();
73605 set_fs(KERNEL_DS);
73606 ret = hrtimer_nanosleep_restart(restart);
73607 @@ -252,7 +253,7 @@ asmlinkage long compat_sys_nanosleep(struct compat_timespec __user *rqtp,
73608 oldfs = get_fs();
73609 set_fs(KERNEL_DS);
73610 ret = hrtimer_nanosleep(&tu,
73611 - rmtp ? (struct timespec __user *)&rmt : NULL,
73612 + rmtp ? (struct timespec __force_user *)&rmt : NULL,
73613 HRTIMER_MODE_REL, CLOCK_MONOTONIC);
73614 set_fs(oldfs);
73615
73616 @@ -361,7 +362,7 @@ asmlinkage long compat_sys_sigpending(compat_old_sigset_t __user *set)
73617 mm_segment_t old_fs = get_fs();
73618
73619 set_fs(KERNEL_DS);
73620 - ret = sys_sigpending((old_sigset_t __user *) &s);
73621 + ret = sys_sigpending((old_sigset_t __force_user *) &s);
73622 set_fs(old_fs);
73623 if (ret == 0)
73624 ret = put_user(s, set);
73625 @@ -451,7 +452,7 @@ asmlinkage long compat_sys_old_getrlimit(unsigned int resource,
73626 mm_segment_t old_fs = get_fs();
73627
73628 set_fs(KERNEL_DS);
73629 - ret = sys_old_getrlimit(resource, &r);
73630 + ret = sys_old_getrlimit(resource, (struct rlimit __force_user *)&r);
73631 set_fs(old_fs);
73632
73633 if (!ret) {
73634 @@ -523,7 +524,7 @@ asmlinkage long compat_sys_getrusage(int who, struct compat_rusage __user *ru)
73635 mm_segment_t old_fs = get_fs();
73636
73637 set_fs(KERNEL_DS);
73638 - ret = sys_getrusage(who, (struct rusage __user *) &r);
73639 + ret = sys_getrusage(who, (struct rusage __force_user *) &r);
73640 set_fs(old_fs);
73641
73642 if (ret)
73643 @@ -552,8 +553,8 @@ COMPAT_SYSCALL_DEFINE4(wait4,
73644 set_fs (KERNEL_DS);
73645 ret = sys_wait4(pid,
73646 (stat_addr ?
73647 - (unsigned int __user *) &status : NULL),
73648 - options, (struct rusage __user *) &r);
73649 + (unsigned int __force_user *) &status : NULL),
73650 + options, (struct rusage __force_user *) &r);
73651 set_fs (old_fs);
73652
73653 if (ret > 0) {
73654 @@ -579,8 +580,8 @@ COMPAT_SYSCALL_DEFINE5(waitid,
73655 memset(&info, 0, sizeof(info));
73656
73657 set_fs(KERNEL_DS);
73658 - ret = sys_waitid(which, pid, (siginfo_t __user *)&info, options,
73659 - uru ? (struct rusage __user *)&ru : NULL);
73660 + ret = sys_waitid(which, pid, (siginfo_t __force_user *)&info, options,
73661 + uru ? (struct rusage __force_user *)&ru : NULL);
73662 set_fs(old_fs);
73663
73664 if ((ret < 0) || (info.si_signo == 0))
73665 @@ -714,8 +715,8 @@ long compat_sys_timer_settime(timer_t timer_id, int flags,
73666 oldfs = get_fs();
73667 set_fs(KERNEL_DS);
73668 err = sys_timer_settime(timer_id, flags,
73669 - (struct itimerspec __user *) &newts,
73670 - (struct itimerspec __user *) &oldts);
73671 + (struct itimerspec __force_user *) &newts,
73672 + (struct itimerspec __force_user *) &oldts);
73673 set_fs(oldfs);
73674 if (!err && old && put_compat_itimerspec(old, &oldts))
73675 return -EFAULT;
73676 @@ -732,7 +733,7 @@ long compat_sys_timer_gettime(timer_t timer_id,
73677 oldfs = get_fs();
73678 set_fs(KERNEL_DS);
73679 err = sys_timer_gettime(timer_id,
73680 - (struct itimerspec __user *) &ts);
73681 + (struct itimerspec __force_user *) &ts);
73682 set_fs(oldfs);
73683 if (!err && put_compat_itimerspec(setting, &ts))
73684 return -EFAULT;
73685 @@ -751,7 +752,7 @@ long compat_sys_clock_settime(clockid_t which_clock,
73686 oldfs = get_fs();
73687 set_fs(KERNEL_DS);
73688 err = sys_clock_settime(which_clock,
73689 - (struct timespec __user *) &ts);
73690 + (struct timespec __force_user *) &ts);
73691 set_fs(oldfs);
73692 return err;
73693 }
73694 @@ -766,7 +767,7 @@ long compat_sys_clock_gettime(clockid_t which_clock,
73695 oldfs = get_fs();
73696 set_fs(KERNEL_DS);
73697 err = sys_clock_gettime(which_clock,
73698 - (struct timespec __user *) &ts);
73699 + (struct timespec __force_user *) &ts);
73700 set_fs(oldfs);
73701 if (!err && put_compat_timespec(&ts, tp))
73702 return -EFAULT;
73703 @@ -786,7 +787,7 @@ long compat_sys_clock_adjtime(clockid_t which_clock,
73704
73705 oldfs = get_fs();
73706 set_fs(KERNEL_DS);
73707 - ret = sys_clock_adjtime(which_clock, (struct timex __user *) &txc);
73708 + ret = sys_clock_adjtime(which_clock, (struct timex __force_user *) &txc);
73709 set_fs(oldfs);
73710
73711 err = compat_put_timex(utp, &txc);
73712 @@ -806,7 +807,7 @@ long compat_sys_clock_getres(clockid_t which_clock,
73713 oldfs = get_fs();
73714 set_fs(KERNEL_DS);
73715 err = sys_clock_getres(which_clock,
73716 - (struct timespec __user *) &ts);
73717 + (struct timespec __force_user *) &ts);
73718 set_fs(oldfs);
73719 if (!err && tp && put_compat_timespec(&ts, tp))
73720 return -EFAULT;
73721 @@ -818,9 +819,9 @@ static long compat_clock_nanosleep_restart(struct restart_block *restart)
73722 long err;
73723 mm_segment_t oldfs;
73724 struct timespec tu;
73725 - struct compat_timespec *rmtp = restart->nanosleep.compat_rmtp;
73726 + struct compat_timespec __user *rmtp = restart->nanosleep.compat_rmtp;
73727
73728 - restart->nanosleep.rmtp = (struct timespec __user *) &tu;
73729 + restart->nanosleep.rmtp = (struct timespec __force_user *) &tu;
73730 oldfs = get_fs();
73731 set_fs(KERNEL_DS);
73732 err = clock_nanosleep_restart(restart);
73733 @@ -852,8 +853,8 @@ long compat_sys_clock_nanosleep(clockid_t which_clock, int flags,
73734 oldfs = get_fs();
73735 set_fs(KERNEL_DS);
73736 err = sys_clock_nanosleep(which_clock, flags,
73737 - (struct timespec __user *) &in,
73738 - (struct timespec __user *) &out);
73739 + (struct timespec __force_user *) &in,
73740 + (struct timespec __force_user *) &out);
73741 set_fs(oldfs);
73742
73743 if ((err == -ERESTART_RESTARTBLOCK) && rmtp &&
73744 diff --git a/kernel/configs.c b/kernel/configs.c
73745 index 42e8fa0..9e7406b 100644
73746 --- a/kernel/configs.c
73747 +++ b/kernel/configs.c
73748 @@ -74,8 +74,19 @@ static int __init ikconfig_init(void)
73749 struct proc_dir_entry *entry;
73750
73751 /* create the current config file */
73752 +#if defined(CONFIG_GRKERNSEC_PROC_ADD) || defined(CONFIG_GRKERNSEC_HIDESYM)
73753 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_HIDESYM)
73754 + entry = proc_create("config.gz", S_IFREG | S_IRUSR, NULL,
73755 + &ikconfig_file_ops);
73756 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
73757 + entry = proc_create("config.gz", S_IFREG | S_IRUSR | S_IRGRP, NULL,
73758 + &ikconfig_file_ops);
73759 +#endif
73760 +#else
73761 entry = proc_create("config.gz", S_IFREG | S_IRUGO, NULL,
73762 &ikconfig_file_ops);
73763 +#endif
73764 +
73765 if (!entry)
73766 return -ENOMEM;
73767
73768 diff --git a/kernel/cred.c b/kernel/cred.c
73769 index e0573a4..3874e41 100644
73770 --- a/kernel/cred.c
73771 +++ b/kernel/cred.c
73772 @@ -164,6 +164,16 @@ void exit_creds(struct task_struct *tsk)
73773 validate_creds(cred);
73774 alter_cred_subscribers(cred, -1);
73775 put_cred(cred);
73776 +
73777 +#ifdef CONFIG_GRKERNSEC_SETXID
73778 + cred = (struct cred *) tsk->delayed_cred;
73779 + if (cred != NULL) {
73780 + tsk->delayed_cred = NULL;
73781 + validate_creds(cred);
73782 + alter_cred_subscribers(cred, -1);
73783 + put_cred(cred);
73784 + }
73785 +#endif
73786 }
73787
73788 /**
73789 @@ -411,7 +421,7 @@ static bool cred_cap_issubset(const struct cred *set, const struct cred *subset)
73790 * Always returns 0 thus allowing this function to be tail-called at the end
73791 * of, say, sys_setgid().
73792 */
73793 -int commit_creds(struct cred *new)
73794 +static int __commit_creds(struct cred *new)
73795 {
73796 struct task_struct *task = current;
73797 const struct cred *old = task->real_cred;
73798 @@ -430,6 +440,8 @@ int commit_creds(struct cred *new)
73799
73800 get_cred(new); /* we will require a ref for the subj creds too */
73801
73802 + gr_set_role_label(task, new->uid, new->gid);
73803 +
73804 /* dumpability changes */
73805 if (!uid_eq(old->euid, new->euid) ||
73806 !gid_eq(old->egid, new->egid) ||
73807 @@ -479,6 +491,102 @@ int commit_creds(struct cred *new)
73808 put_cred(old);
73809 return 0;
73810 }
73811 +#ifdef CONFIG_GRKERNSEC_SETXID
73812 +extern int set_user(struct cred *new);
73813 +
73814 +void gr_delayed_cred_worker(void)
73815 +{
73816 + const struct cred *new = current->delayed_cred;
73817 + struct cred *ncred;
73818 +
73819 + current->delayed_cred = NULL;
73820 +
73821 + if (!uid_eq(current_uid(), GLOBAL_ROOT_UID) && new != NULL) {
73822 + // from doing get_cred on it when queueing this
73823 + put_cred(new);
73824 + return;
73825 + } else if (new == NULL)
73826 + return;
73827 +
73828 + ncred = prepare_creds();
73829 + if (!ncred)
73830 + goto die;
73831 + // uids
73832 + ncred->uid = new->uid;
73833 + ncred->euid = new->euid;
73834 + ncred->suid = new->suid;
73835 + ncred->fsuid = new->fsuid;
73836 + // gids
73837 + ncred->gid = new->gid;
73838 + ncred->egid = new->egid;
73839 + ncred->sgid = new->sgid;
73840 + ncred->fsgid = new->fsgid;
73841 + // groups
73842 + if (set_groups(ncred, new->group_info) < 0) {
73843 + abort_creds(ncred);
73844 + goto die;
73845 + }
73846 + // caps
73847 + ncred->securebits = new->securebits;
73848 + ncred->cap_inheritable = new->cap_inheritable;
73849 + ncred->cap_permitted = new->cap_permitted;
73850 + ncred->cap_effective = new->cap_effective;
73851 + ncred->cap_bset = new->cap_bset;
73852 +
73853 + if (set_user(ncred)) {
73854 + abort_creds(ncred);
73855 + goto die;
73856 + }
73857 +
73858 + // from doing get_cred on it when queueing this
73859 + put_cred(new);
73860 +
73861 + __commit_creds(ncred);
73862 + return;
73863 +die:
73864 + // from doing get_cred on it when queueing this
73865 + put_cred(new);
73866 + do_group_exit(SIGKILL);
73867 +}
73868 +#endif
73869 +
73870 +int commit_creds(struct cred *new)
73871 +{
73872 +#ifdef CONFIG_GRKERNSEC_SETXID
73873 + int ret;
73874 + int schedule_it = 0;
73875 + struct task_struct *t;
73876 +
73877 + /* we won't get called with tasklist_lock held for writing
73878 + and interrupts disabled as the cred struct in that case is
73879 + init_cred
73880 + */
73881 + if (grsec_enable_setxid && !current_is_single_threaded() &&
73882 + uid_eq(current_uid(), GLOBAL_ROOT_UID) &&
73883 + !uid_eq(new->uid, GLOBAL_ROOT_UID)) {
73884 + schedule_it = 1;
73885 + }
73886 + ret = __commit_creds(new);
73887 + if (schedule_it) {
73888 + rcu_read_lock();
73889 + read_lock(&tasklist_lock);
73890 + for (t = next_thread(current); t != current;
73891 + t = next_thread(t)) {
73892 + if (t->delayed_cred == NULL) {
73893 + t->delayed_cred = get_cred(new);
73894 + set_tsk_thread_flag(t, TIF_GRSEC_SETXID);
73895 + set_tsk_need_resched(t);
73896 + }
73897 + }
73898 + read_unlock(&tasklist_lock);
73899 + rcu_read_unlock();
73900 + }
73901 + return ret;
73902 +#else
73903 + return __commit_creds(new);
73904 +#endif
73905 +}
73906 +
73907 EXPORT_SYMBOL(commit_creds);
73908
73909 /**
73910 diff --git a/kernel/debug/debug_core.c b/kernel/debug/debug_core.c
73911 index 9a61738..c5c8f3a 100644
73912 --- a/kernel/debug/debug_core.c
73913 +++ b/kernel/debug/debug_core.c
73914 @@ -122,7 +122,7 @@ static DEFINE_RAW_SPINLOCK(dbg_slave_lock);
73915 */
73916 static atomic_t masters_in_kgdb;
73917 static atomic_t slaves_in_kgdb;
73918 -static atomic_t kgdb_break_tasklet_var;
73919 +static atomic_unchecked_t kgdb_break_tasklet_var;
73920 atomic_t kgdb_setting_breakpoint;
73921
73922 struct task_struct *kgdb_usethread;
73923 @@ -132,7 +132,7 @@ int kgdb_single_step;
73924 static pid_t kgdb_sstep_pid;
73925
73926 /* to keep track of the CPU which is doing the single stepping*/
73927 -atomic_t kgdb_cpu_doing_single_step = ATOMIC_INIT(-1);
73928 +atomic_unchecked_t kgdb_cpu_doing_single_step = ATOMIC_INIT(-1);
73929
73930 /*
73931 * If you are debugging a problem where roundup (the collection of
73932 @@ -540,7 +540,7 @@ return_normal:
73933 * kernel will only try for the value of sstep_tries before
73934 * giving up and continuing on.
73935 */
73936 - if (atomic_read(&kgdb_cpu_doing_single_step) != -1 &&
73937 + if (atomic_read_unchecked(&kgdb_cpu_doing_single_step) != -1 &&
73938 (kgdb_info[cpu].task &&
73939 kgdb_info[cpu].task->pid != kgdb_sstep_pid) && --sstep_tries) {
73940 atomic_set(&kgdb_active, -1);
73941 @@ -634,8 +634,8 @@ cpu_master_loop:
73942 }
73943
73944 kgdb_restore:
73945 - if (atomic_read(&kgdb_cpu_doing_single_step) != -1) {
73946 - int sstep_cpu = atomic_read(&kgdb_cpu_doing_single_step);
73947 + if (atomic_read_unchecked(&kgdb_cpu_doing_single_step) != -1) {
73948 + int sstep_cpu = atomic_read_unchecked(&kgdb_cpu_doing_single_step);
73949 if (kgdb_info[sstep_cpu].task)
73950 kgdb_sstep_pid = kgdb_info[sstep_cpu].task->pid;
73951 else
73952 @@ -887,18 +887,18 @@ static void kgdb_unregister_callbacks(void)
73953 static void kgdb_tasklet_bpt(unsigned long ing)
73954 {
73955 kgdb_breakpoint();
73956 - atomic_set(&kgdb_break_tasklet_var, 0);
73957 + atomic_set_unchecked(&kgdb_break_tasklet_var, 0);
73958 }
73959
73960 static DECLARE_TASKLET(kgdb_tasklet_breakpoint, kgdb_tasklet_bpt, 0);
73961
73962 void kgdb_schedule_breakpoint(void)
73963 {
73964 - if (atomic_read(&kgdb_break_tasklet_var) ||
73965 + if (atomic_read_unchecked(&kgdb_break_tasklet_var) ||
73966 atomic_read(&kgdb_active) != -1 ||
73967 atomic_read(&kgdb_setting_breakpoint))
73968 return;
73969 - atomic_inc(&kgdb_break_tasklet_var);
73970 + atomic_inc_unchecked(&kgdb_break_tasklet_var);
73971 tasklet_schedule(&kgdb_tasklet_breakpoint);
73972 }
73973 EXPORT_SYMBOL_GPL(kgdb_schedule_breakpoint);
73974 diff --git a/kernel/debug/kdb/kdb_main.c b/kernel/debug/kdb/kdb_main.c
73975 index 8875254..7cf4928 100644
73976 --- a/kernel/debug/kdb/kdb_main.c
73977 +++ b/kernel/debug/kdb/kdb_main.c
73978 @@ -1974,7 +1974,7 @@ static int kdb_lsmod(int argc, const char **argv)
73979 continue;
73980
73981 kdb_printf("%-20s%8u 0x%p ", mod->name,
73982 - mod->core_size, (void *)mod);
73983 + mod->core_size_rx + mod->core_size_rw, (void *)mod);
73984 #ifdef CONFIG_MODULE_UNLOAD
73985 kdb_printf("%4ld ", module_refcount(mod));
73986 #endif
73987 @@ -1984,7 +1984,7 @@ static int kdb_lsmod(int argc, const char **argv)
73988 kdb_printf(" (Loading)");
73989 else
73990 kdb_printf(" (Live)");
73991 - kdb_printf(" 0x%p", mod->module_core);
73992 + kdb_printf(" 0x%p 0x%p", mod->module_core_rx, mod->module_core_rw);
73993
73994 #ifdef CONFIG_MODULE_UNLOAD
73995 {
73996 diff --git a/kernel/events/core.c b/kernel/events/core.c
73997 index 7b6646a..3cb1135 100644
73998 --- a/kernel/events/core.c
73999 +++ b/kernel/events/core.c
74000 @@ -182,7 +182,7 @@ int perf_proc_update_handler(struct ctl_table *table, int write,
74001 return 0;
74002 }
74003
74004 -static atomic64_t perf_event_id;
74005 +static atomic64_unchecked_t perf_event_id;
74006
74007 static void cpu_ctx_sched_out(struct perf_cpu_context *cpuctx,
74008 enum event_type_t event_type);
74009 @@ -2677,7 +2677,7 @@ static void __perf_event_read(void *info)
74010
74011 static inline u64 perf_event_count(struct perf_event *event)
74012 {
74013 - return local64_read(&event->count) + atomic64_read(&event->child_count);
74014 + return local64_read(&event->count) + atomic64_read_unchecked(&event->child_count);
74015 }
74016
74017 static u64 perf_event_read(struct perf_event *event)
74018 @@ -3007,9 +3007,9 @@ u64 perf_event_read_value(struct perf_event *event, u64 *enabled, u64 *running)
74019 mutex_lock(&event->child_mutex);
74020 total += perf_event_read(event);
74021 *enabled += event->total_time_enabled +
74022 - atomic64_read(&event->child_total_time_enabled);
74023 + atomic64_read_unchecked(&event->child_total_time_enabled);
74024 *running += event->total_time_running +
74025 - atomic64_read(&event->child_total_time_running);
74026 + atomic64_read_unchecked(&event->child_total_time_running);
74027
74028 list_for_each_entry(child, &event->child_list, child_list) {
74029 total += perf_event_read(child);
74030 @@ -3412,10 +3412,10 @@ void perf_event_update_userpage(struct perf_event *event)
74031 userpg->offset -= local64_read(&event->hw.prev_count);
74032
74033 userpg->time_enabled = enabled +
74034 - atomic64_read(&event->child_total_time_enabled);
74035 + atomic64_read_unchecked(&event->child_total_time_enabled);
74036
74037 userpg->time_running = running +
74038 - atomic64_read(&event->child_total_time_running);
74039 + atomic64_read_unchecked(&event->child_total_time_running);
74040
74041 arch_perf_update_userpage(userpg, now);
74042
74043 @@ -3974,11 +3974,11 @@ static void perf_output_read_one(struct perf_output_handle *handle,
74044 values[n++] = perf_event_count(event);
74045 if (read_format & PERF_FORMAT_TOTAL_TIME_ENABLED) {
74046 values[n++] = enabled +
74047 - atomic64_read(&event->child_total_time_enabled);
74048 + atomic64_read_unchecked(&event->child_total_time_enabled);
74049 }
74050 if (read_format & PERF_FORMAT_TOTAL_TIME_RUNNING) {
74051 values[n++] = running +
74052 - atomic64_read(&event->child_total_time_running);
74053 + atomic64_read_unchecked(&event->child_total_time_running);
74054 }
74055 if (read_format & PERF_FORMAT_ID)
74056 values[n++] = primary_event_id(event);
74057 @@ -4721,12 +4721,12 @@ static void perf_event_mmap_event(struct perf_mmap_event *mmap_event)
74058 * need to add enough zero bytes after the string to handle
74059 * the 64bit alignment we do later.
74060 */
74061 - buf = kzalloc(PATH_MAX + sizeof(u64), GFP_KERNEL);
74062 + buf = kzalloc(PATH_MAX, GFP_KERNEL);
74063 if (!buf) {
74064 name = strncpy(tmp, "//enomem", sizeof(tmp));
74065 goto got_name;
74066 }
74067 - name = d_path(&file->f_path, buf, PATH_MAX);
74068 + name = d_path(&file->f_path, buf, PATH_MAX - sizeof(u64));
74069 if (IS_ERR(name)) {
74070 name = strncpy(tmp, "//toolong", sizeof(tmp));
74071 goto got_name;
74072 @@ -6165,7 +6165,7 @@ perf_event_alloc(struct perf_event_attr *attr, int cpu,
74073 event->parent = parent_event;
74074
74075 event->ns = get_pid_ns(task_active_pid_ns(current));
74076 - event->id = atomic64_inc_return(&perf_event_id);
74077 + event->id = atomic64_inc_return_unchecked(&perf_event_id);
74078
74079 event->state = PERF_EVENT_STATE_INACTIVE;
74080
74081 @@ -6790,10 +6790,10 @@ static void sync_child_event(struct perf_event *child_event,
74082 /*
74083 * Add back the child's count to the parent's count:
74084 */
74085 - atomic64_add(child_val, &parent_event->child_count);
74086 - atomic64_add(child_event->total_time_enabled,
74087 + atomic64_add_unchecked(child_val, &parent_event->child_count);
74088 + atomic64_add_unchecked(child_event->total_time_enabled,
74089 &parent_event->child_total_time_enabled);
74090 - atomic64_add(child_event->total_time_running,
74091 + atomic64_add_unchecked(child_event->total_time_running,
74092 &parent_event->child_total_time_running);
74093
74094 /*
74095 diff --git a/kernel/exit.c b/kernel/exit.c
74096 index b4df219..f13c02d 100644
74097 --- a/kernel/exit.c
74098 +++ b/kernel/exit.c
74099 @@ -170,6 +170,10 @@ void release_task(struct task_struct * p)
74100 struct task_struct *leader;
74101 int zap_leader;
74102 repeat:
74103 +#ifdef CONFIG_NET
74104 + gr_del_task_from_ip_table(p);
74105 +#endif
74106 +
74107 /* don't need to get the RCU readlock here - the process is dead and
74108 * can't be modifying its own credentials. But shut RCU-lockdep up */
74109 rcu_read_lock();
74110 @@ -338,7 +342,7 @@ int allow_signal(int sig)
74111 * know it'll be handled, so that they don't get converted to
74112 * SIGKILL or just silently dropped.
74113 */
74114 - current->sighand->action[(sig)-1].sa.sa_handler = (void __user *)2;
74115 + current->sighand->action[(sig)-1].sa.sa_handler = (__force void __user *)2;
74116 recalc_sigpending();
74117 spin_unlock_irq(&current->sighand->siglock);
74118 return 0;
74119 @@ -708,6 +712,8 @@ void do_exit(long code)
74120 struct task_struct *tsk = current;
74121 int group_dead;
74122
74123 + set_fs(USER_DS);
74124 +
74125 profile_task_exit(tsk);
74126
74127 WARN_ON(blk_needs_flush_plug(tsk));
74128 @@ -724,7 +730,6 @@ void do_exit(long code)
74129 * mm_release()->clear_child_tid() from writing to a user-controlled
74130 * kernel address.
74131 */
74132 - set_fs(USER_DS);
74133
74134 ptrace_event(PTRACE_EVENT_EXIT, code);
74135
74136 @@ -783,6 +788,9 @@ void do_exit(long code)
74137 tsk->exit_code = code;
74138 taskstats_exit(tsk, group_dead);
74139
74140 + gr_acl_handle_psacct(tsk, code);
74141 + gr_acl_handle_exit();
74142 +
74143 exit_mm(tsk);
74144
74145 if (group_dead)
74146 @@ -903,7 +911,7 @@ SYSCALL_DEFINE1(exit, int, error_code)
74147 * Take down every thread in the group. This is called by fatal signals
74148 * as well as by sys_exit_group (below).
74149 */
74150 -void
74151 +__noreturn void
74152 do_group_exit(int exit_code)
74153 {
74154 struct signal_struct *sig = current->signal;
74155 diff --git a/kernel/fork.c b/kernel/fork.c
74156 index 5630e52..0cee608 100644
74157 --- a/kernel/fork.c
74158 +++ b/kernel/fork.c
74159 @@ -318,7 +318,7 @@ static struct task_struct *dup_task_struct(struct task_struct *orig)
74160 *stackend = STACK_END_MAGIC; /* for overflow detection */
74161
74162 #ifdef CONFIG_CC_STACKPROTECTOR
74163 - tsk->stack_canary = get_random_int();
74164 + tsk->stack_canary = pax_get_random_long();
74165 #endif
74166
74167 /*
74168 @@ -344,13 +344,81 @@ free_tsk:
74169 }
74170
74171 #ifdef CONFIG_MMU
74172 +static struct vm_area_struct *dup_vma(struct mm_struct *mm, struct mm_struct *oldmm, struct vm_area_struct *mpnt)
74173 +{
74174 + struct vm_area_struct *tmp;
74175 + unsigned long charge;
74176 + struct mempolicy *pol;
74177 + struct file *file;
74178 +
74179 + charge = 0;
74180 + if (mpnt->vm_flags & VM_ACCOUNT) {
74181 + unsigned long len = vma_pages(mpnt);
74182 +
74183 + if (security_vm_enough_memory_mm(oldmm, len)) /* sic */
74184 + goto fail_nomem;
74185 + charge = len;
74186 + }
74187 + tmp = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
74188 + if (!tmp)
74189 + goto fail_nomem;
74190 + *tmp = *mpnt;
74191 + tmp->vm_mm = mm;
74192 + INIT_LIST_HEAD(&tmp->anon_vma_chain);
74193 + pol = mpol_dup(vma_policy(mpnt));
74194 + if (IS_ERR(pol))
74195 + goto fail_nomem_policy;
74196 + vma_set_policy(tmp, pol);
74197 + if (anon_vma_fork(tmp, mpnt))
74198 + goto fail_nomem_anon_vma_fork;
74199 + tmp->vm_flags &= ~VM_LOCKED;
74200 + tmp->vm_next = tmp->vm_prev = NULL;
74201 + tmp->vm_mirror = NULL;
74202 + file = tmp->vm_file;
74203 + if (file) {
74204 + struct inode *inode = file->f_path.dentry->d_inode;
74205 + struct address_space *mapping = file->f_mapping;
74206 +
74207 + get_file(file);
74208 + if (tmp->vm_flags & VM_DENYWRITE)
74209 + atomic_dec(&inode->i_writecount);
74210 + mutex_lock(&mapping->i_mmap_mutex);
74211 + if (tmp->vm_flags & VM_SHARED)
74212 + mapping->i_mmap_writable++;
74213 + flush_dcache_mmap_lock(mapping);
74214 + /* insert tmp into the share list, just after mpnt */
74215 + if (unlikely(tmp->vm_flags & VM_NONLINEAR))
74216 + vma_nonlinear_insert(tmp, &mapping->i_mmap_nonlinear);
74217 + else
74218 + vma_interval_tree_insert_after(tmp, mpnt, &mapping->i_mmap);
74219 + flush_dcache_mmap_unlock(mapping);
74220 + mutex_unlock(&mapping->i_mmap_mutex);
74221 + }
74222 +
74223 + /*
74224 + * Clear hugetlb-related page reserves for children. This only
74225 + * affects MAP_PRIVATE mappings. Faults generated by the child
74226 + * are not guaranteed to succeed, even if read-only
74227 + */
74228 + if (is_vm_hugetlb_page(tmp))
74229 + reset_vma_resv_huge_pages(tmp);
74230 +
74231 + return tmp;
74232 +
74233 +fail_nomem_anon_vma_fork:
74234 + mpol_put(pol);
74235 +fail_nomem_policy:
74236 + kmem_cache_free(vm_area_cachep, tmp);
74237 +fail_nomem:
74238 + vm_unacct_memory(charge);
74239 + return NULL;
74240 +}
74241 +
74242 static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
74243 {
74244 struct vm_area_struct *mpnt, *tmp, *prev, **pprev;
74245 struct rb_node **rb_link, *rb_parent;
74246 int retval;
74247 - unsigned long charge;
74248 - struct mempolicy *pol;
74249
74250 uprobe_start_dup_mmap();
74251 down_write(&oldmm->mmap_sem);
74252 @@ -364,8 +432,8 @@ static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
74253 mm->locked_vm = 0;
74254 mm->mmap = NULL;
74255 mm->mmap_cache = NULL;
74256 - mm->free_area_cache = oldmm->mmap_base;
74257 - mm->cached_hole_size = ~0UL;
74258 + mm->free_area_cache = oldmm->free_area_cache;
74259 + mm->cached_hole_size = oldmm->cached_hole_size;
74260 mm->map_count = 0;
74261 cpumask_clear(mm_cpumask(mm));
74262 mm->mm_rb = RB_ROOT;
74263 @@ -381,57 +449,15 @@ static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
74264
74265 prev = NULL;
74266 for (mpnt = oldmm->mmap; mpnt; mpnt = mpnt->vm_next) {
74267 - struct file *file;
74268 -
74269 if (mpnt->vm_flags & VM_DONTCOPY) {
74270 vm_stat_account(mm, mpnt->vm_flags, mpnt->vm_file,
74271 -vma_pages(mpnt));
74272 continue;
74273 }
74274 - charge = 0;
74275 - if (mpnt->vm_flags & VM_ACCOUNT) {
74276 - unsigned long len = vma_pages(mpnt);
74277 -
74278 - if (security_vm_enough_memory_mm(oldmm, len)) /* sic */
74279 - goto fail_nomem;
74280 - charge = len;
74281 - }
74282 - tmp = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
74283 - if (!tmp)
74284 - goto fail_nomem;
74285 - *tmp = *mpnt;
74286 - INIT_LIST_HEAD(&tmp->anon_vma_chain);
74287 - pol = mpol_dup(vma_policy(mpnt));
74288 - retval = PTR_ERR(pol);
74289 - if (IS_ERR(pol))
74290 - goto fail_nomem_policy;
74291 - vma_set_policy(tmp, pol);
74292 - tmp->vm_mm = mm;
74293 - if (anon_vma_fork(tmp, mpnt))
74294 - goto fail_nomem_anon_vma_fork;
74295 - tmp->vm_flags &= ~VM_LOCKED;
74296 - tmp->vm_next = tmp->vm_prev = NULL;
74297 - file = tmp->vm_file;
74298 - if (file) {
74299 - struct inode *inode = file->f_path.dentry->d_inode;
74300 - struct address_space *mapping = file->f_mapping;
74301 -
74302 - get_file(file);
74303 - if (tmp->vm_flags & VM_DENYWRITE)
74304 - atomic_dec(&inode->i_writecount);
74305 - mutex_lock(&mapping->i_mmap_mutex);
74306 - if (tmp->vm_flags & VM_SHARED)
74307 - mapping->i_mmap_writable++;
74308 - flush_dcache_mmap_lock(mapping);
74309 - /* insert tmp into the share list, just after mpnt */
74310 - if (unlikely(tmp->vm_flags & VM_NONLINEAR))
74311 - vma_nonlinear_insert(tmp,
74312 - &mapping->i_mmap_nonlinear);
74313 - else
74314 - vma_interval_tree_insert_after(tmp, mpnt,
74315 - &mapping->i_mmap);
74316 - flush_dcache_mmap_unlock(mapping);
74317 - mutex_unlock(&mapping->i_mmap_mutex);
74318 + tmp = dup_vma(mm, oldmm, mpnt);
74319 + if (!tmp) {
74320 + retval = -ENOMEM;
74321 + goto out;
74322 }
74323
74324 /*
74325 @@ -463,6 +489,31 @@ static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
74326 if (retval)
74327 goto out;
74328 }
74329 +
74330 +#ifdef CONFIG_PAX_SEGMEXEC
74331 + if (oldmm->pax_flags & MF_PAX_SEGMEXEC) {
74332 + struct vm_area_struct *mpnt_m;
74333 +
74334 + for (mpnt = oldmm->mmap, mpnt_m = mm->mmap; mpnt; mpnt = mpnt->vm_next, mpnt_m = mpnt_m->vm_next) {
74335 + BUG_ON(!mpnt_m || mpnt_m->vm_mirror || mpnt->vm_mm != oldmm || mpnt_m->vm_mm != mm);
74336 +
74337 + if (!mpnt->vm_mirror)
74338 + continue;
74339 +
74340 + if (mpnt->vm_end <= SEGMEXEC_TASK_SIZE) {
74341 + BUG_ON(mpnt->vm_mirror->vm_mirror != mpnt);
74342 + mpnt->vm_mirror = mpnt_m;
74343 + } else {
74344 + BUG_ON(mpnt->vm_mirror->vm_mirror == mpnt || mpnt->vm_mirror->vm_mirror->vm_mm != mm);
74345 + mpnt_m->vm_mirror = mpnt->vm_mirror->vm_mirror;
74346 + mpnt_m->vm_mirror->vm_mirror = mpnt_m;
74347 + mpnt->vm_mirror->vm_mirror = mpnt;
74348 + }
74349 + }
74350 + BUG_ON(mpnt_m);
74351 + }
74352 +#endif
74353 +
74354 /* a new mm has just been created */
74355 arch_dup_mmap(oldmm, mm);
74356 retval = 0;
74357 @@ -472,14 +523,6 @@ out:
74358 up_write(&oldmm->mmap_sem);
74359 uprobe_end_dup_mmap();
74360 return retval;
74361 -fail_nomem_anon_vma_fork:
74362 - mpol_put(pol);
74363 -fail_nomem_policy:
74364 - kmem_cache_free(vm_area_cachep, tmp);
74365 -fail_nomem:
74366 - retval = -ENOMEM;
74367 - vm_unacct_memory(charge);
74368 - goto out;
74369 }
74370
74371 static inline int mm_alloc_pgd(struct mm_struct *mm)
74372 @@ -694,8 +737,8 @@ struct mm_struct *mm_access(struct task_struct *task, unsigned int mode)
74373 return ERR_PTR(err);
74374
74375 mm = get_task_mm(task);
74376 - if (mm && mm != current->mm &&
74377 - !ptrace_may_access(task, mode)) {
74378 + if (mm && ((mm != current->mm && !ptrace_may_access(task, mode)) ||
74379 + (mode == PTRACE_MODE_ATTACH && (gr_handle_proc_ptrace(task) || gr_acl_handle_procpidmem(task))))) {
74380 mmput(mm);
74381 mm = ERR_PTR(-EACCES);
74382 }
74383 @@ -917,13 +960,20 @@ static int copy_fs(unsigned long clone_flags, struct task_struct *tsk)
74384 spin_unlock(&fs->lock);
74385 return -EAGAIN;
74386 }
74387 - fs->users++;
74388 + atomic_inc(&fs->users);
74389 spin_unlock(&fs->lock);
74390 return 0;
74391 }
74392 tsk->fs = copy_fs_struct(fs);
74393 if (!tsk->fs)
74394 return -ENOMEM;
74395 + /* Carry through gr_chroot_dentry and is_chrooted instead
74396 + of recomputing it here. Already copied when the task struct
74397 + is duplicated. This allows pivot_root to not be treated as
74398 + a chroot
74399 + */
74400 + //gr_set_chroot_entries(tsk, &tsk->fs->root);
74401 +
74402 return 0;
74403 }
74404
74405 @@ -1196,6 +1246,9 @@ static struct task_struct *copy_process(unsigned long clone_flags,
74406 DEBUG_LOCKS_WARN_ON(!p->softirqs_enabled);
74407 #endif
74408 retval = -EAGAIN;
74409 +
74410 + gr_learn_resource(p, RLIMIT_NPROC, atomic_read(&p->real_cred->user->processes), 0);
74411 +
74412 if (atomic_read(&p->real_cred->user->processes) >=
74413 task_rlimit(p, RLIMIT_NPROC)) {
74414 if (!capable(CAP_SYS_ADMIN) && !capable(CAP_SYS_RESOURCE) &&
74415 @@ -1435,6 +1488,11 @@ static struct task_struct *copy_process(unsigned long clone_flags,
74416 goto bad_fork_free_pid;
74417 }
74418
74419 + /* synchronizes with gr_set_acls()
74420 + we need to call this past the point of no return for fork()
74421 + */
74422 + gr_copy_label(p);
74423 +
74424 if (clone_flags & CLONE_THREAD) {
74425 current->signal->nr_threads++;
74426 atomic_inc(&current->signal->live);
74427 @@ -1518,6 +1576,8 @@ bad_fork_cleanup_count:
74428 bad_fork_free:
74429 free_task(p);
74430 fork_out:
74431 + gr_log_forkfail(retval);
74432 +
74433 return ERR_PTR(retval);
74434 }
74435
74436 @@ -1568,6 +1628,23 @@ long do_fork(unsigned long clone_flags,
74437 return -EINVAL;
74438 }
74439
74440 +#ifdef CONFIG_GRKERNSEC
74441 + if (clone_flags & CLONE_NEWUSER) {
74442 + /*
74443 + * This doesn't really inspire confidence:
74444 + * http://marc.info/?l=linux-kernel&m=135543612731939&w=2
74445 + * http://marc.info/?l=linux-kernel&m=135545831607095&w=2
74446 + * Increases kernel attack surface in areas developers
74447 + * previously cared little about ("low importance due
74448 + * to requiring "root" capability")
74449 + * To be removed when this code receives *proper* review
74450 + */
74451 + if (!capable(CAP_SYS_ADMIN) || !capable(CAP_SETUID) ||
74452 + !capable(CAP_SETGID))
74453 + return -EPERM;
74454 + }
74455 +#endif
74456 +
74457 /*
74458 * Determine whether and which event to report to ptracer. When
74459 * called from kernel_thread or CLONE_UNTRACED is explicitly
74460 @@ -1602,6 +1679,8 @@ long do_fork(unsigned long clone_flags,
74461 if (clone_flags & CLONE_PARENT_SETTID)
74462 put_user(nr, parent_tidptr);
74463
74464 + gr_handle_brute_check();
74465 +
74466 if (clone_flags & CLONE_VFORK) {
74467 p->vfork_done = &vfork;
74468 init_completion(&vfork);
74469 @@ -1755,7 +1834,7 @@ static int unshare_fs(unsigned long unshare_flags, struct fs_struct **new_fsp)
74470 return 0;
74471
74472 /* don't need lock here; in the worst case we'll do useless copy */
74473 - if (fs->users == 1)
74474 + if (atomic_read(&fs->users) == 1)
74475 return 0;
74476
74477 *new_fsp = copy_fs_struct(fs);
74478 @@ -1869,7 +1948,8 @@ SYSCALL_DEFINE1(unshare, unsigned long, unshare_flags)
74479 fs = current->fs;
74480 spin_lock(&fs->lock);
74481 current->fs = new_fs;
74482 - if (--fs->users)
74483 + gr_set_chroot_entries(current, &current->fs->root);
74484 + if (atomic_dec_return(&fs->users))
74485 new_fs = NULL;
74486 else
74487 new_fs = fs;
74488 diff --git a/kernel/futex.c b/kernel/futex.c
74489 index 8879430..31696f1 100644
74490 --- a/kernel/futex.c
74491 +++ b/kernel/futex.c
74492 @@ -54,6 +54,7 @@
74493 #include <linux/mount.h>
74494 #include <linux/pagemap.h>
74495 #include <linux/syscalls.h>
74496 +#include <linux/ptrace.h>
74497 #include <linux/signal.h>
74498 #include <linux/export.h>
74499 #include <linux/magic.h>
74500 @@ -239,6 +240,11 @@ get_futex_key(u32 __user *uaddr, int fshared, union futex_key *key, int rw)
74501 struct page *page, *page_head;
74502 int err, ro = 0;
74503
74504 +#ifdef CONFIG_PAX_SEGMEXEC
74505 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && address >= SEGMEXEC_TASK_SIZE)
74506 + return -EFAULT;
74507 +#endif
74508 +
74509 /*
74510 * The futex address must be "naturally" aligned.
74511 */
74512 @@ -2731,6 +2737,7 @@ static int __init futex_init(void)
74513 {
74514 u32 curval;
74515 int i;
74516 + mm_segment_t oldfs;
74517
74518 /*
74519 * This will fail and we want it. Some arch implementations do
74520 @@ -2742,8 +2749,11 @@ static int __init futex_init(void)
74521 * implementation, the non-functional ones will return
74522 * -ENOSYS.
74523 */
74524 + oldfs = get_fs();
74525 + set_fs(USER_DS);
74526 if (cmpxchg_futex_value_locked(&curval, NULL, 0, 0) == -EFAULT)
74527 futex_cmpxchg_enabled = 1;
74528 + set_fs(oldfs);
74529
74530 for (i = 0; i < ARRAY_SIZE(futex_queues); i++) {
74531 plist_head_init(&futex_queues[i].chain);
74532 diff --git a/kernel/gcov/base.c b/kernel/gcov/base.c
74533 index 9b22d03..6295b62 100644
74534 --- a/kernel/gcov/base.c
74535 +++ b/kernel/gcov/base.c
74536 @@ -102,11 +102,6 @@ void gcov_enable_events(void)
74537 }
74538
74539 #ifdef CONFIG_MODULES
74540 -static inline int within(void *addr, void *start, unsigned long size)
74541 -{
74542 - return ((addr >= start) && (addr < start + size));
74543 -}
74544 -
74545 /* Update list and generate events when modules are unloaded. */
74546 static int gcov_module_notifier(struct notifier_block *nb, unsigned long event,
74547 void *data)
74548 @@ -121,7 +116,7 @@ static int gcov_module_notifier(struct notifier_block *nb, unsigned long event,
74549 prev = NULL;
74550 /* Remove entries located in module from linked list. */
74551 for (info = gcov_info_head; info; info = info->next) {
74552 - if (within(info, mod->module_core, mod->core_size)) {
74553 + if (within_module_core_rw((unsigned long)info, mod)) {
74554 if (prev)
74555 prev->next = info->next;
74556 else
74557 diff --git a/kernel/hrtimer.c b/kernel/hrtimer.c
74558 index cdd5607..c3fc919 100644
74559 --- a/kernel/hrtimer.c
74560 +++ b/kernel/hrtimer.c
74561 @@ -1407,7 +1407,7 @@ void hrtimer_peek_ahead_timers(void)
74562 local_irq_restore(flags);
74563 }
74564
74565 -static void run_hrtimer_softirq(struct softirq_action *h)
74566 +static void run_hrtimer_softirq(void)
74567 {
74568 struct hrtimer_cpu_base *cpu_base = &__get_cpu_var(hrtimer_bases);
74569
74570 @@ -1751,7 +1751,7 @@ static int __cpuinit hrtimer_cpu_notify(struct notifier_block *self,
74571 return NOTIFY_OK;
74572 }
74573
74574 -static struct notifier_block __cpuinitdata hrtimers_nb = {
74575 +static struct notifier_block hrtimers_nb = {
74576 .notifier_call = hrtimer_cpu_notify,
74577 };
74578
74579 diff --git a/kernel/jump_label.c b/kernel/jump_label.c
74580 index 60f48fa..7f3a770 100644
74581 --- a/kernel/jump_label.c
74582 +++ b/kernel/jump_label.c
74583 @@ -13,6 +13,7 @@
74584 #include <linux/sort.h>
74585 #include <linux/err.h>
74586 #include <linux/static_key.h>
74587 +#include <linux/mm.h>
74588
74589 #ifdef HAVE_JUMP_LABEL
74590
74591 @@ -50,7 +51,9 @@ jump_label_sort_entries(struct jump_entry *start, struct jump_entry *stop)
74592
74593 size = (((unsigned long)stop - (unsigned long)start)
74594 / sizeof(struct jump_entry));
74595 + pax_open_kernel();
74596 sort(start, size, sizeof(struct jump_entry), jump_label_cmp, NULL);
74597 + pax_close_kernel();
74598 }
74599
74600 static void jump_label_update(struct static_key *key, int enable);
74601 @@ -357,10 +360,12 @@ static void jump_label_invalidate_module_init(struct module *mod)
74602 struct jump_entry *iter_stop = iter_start + mod->num_jump_entries;
74603 struct jump_entry *iter;
74604
74605 + pax_open_kernel();
74606 for (iter = iter_start; iter < iter_stop; iter++) {
74607 if (within_module_init(iter->code, mod))
74608 iter->code = 0;
74609 }
74610 + pax_close_kernel();
74611 }
74612
74613 static int
74614 diff --git a/kernel/kallsyms.c b/kernel/kallsyms.c
74615 index 2169fee..706ccca 100644
74616 --- a/kernel/kallsyms.c
74617 +++ b/kernel/kallsyms.c
74618 @@ -11,6 +11,9 @@
74619 * Changed the compression method from stem compression to "table lookup"
74620 * compression (see scripts/kallsyms.c for a more complete description)
74621 */
74622 +#ifdef CONFIG_GRKERNSEC_HIDESYM
74623 +#define __INCLUDED_BY_HIDESYM 1
74624 +#endif
74625 #include <linux/kallsyms.h>
74626 #include <linux/module.h>
74627 #include <linux/init.h>
74628 @@ -53,12 +56,33 @@ extern const unsigned long kallsyms_markers[] __attribute__((weak));
74629
74630 static inline int is_kernel_inittext(unsigned long addr)
74631 {
74632 + if (system_state != SYSTEM_BOOTING)
74633 + return 0;
74634 +
74635 if (addr >= (unsigned long)_sinittext
74636 && addr <= (unsigned long)_einittext)
74637 return 1;
74638 return 0;
74639 }
74640
74641 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
74642 +#ifdef CONFIG_MODULES
74643 +static inline int is_module_text(unsigned long addr)
74644 +{
74645 + if ((unsigned long)MODULES_EXEC_VADDR <= addr && addr <= (unsigned long)MODULES_EXEC_END)
74646 + return 1;
74647 +
74648 + addr = ktla_ktva(addr);
74649 + return (unsigned long)MODULES_EXEC_VADDR <= addr && addr <= (unsigned long)MODULES_EXEC_END;
74650 +}
74651 +#else
74652 +static inline int is_module_text(unsigned long addr)
74653 +{
74654 + return 0;
74655 +}
74656 +#endif
74657 +#endif
74658 +
74659 static inline int is_kernel_text(unsigned long addr)
74660 {
74661 if ((addr >= (unsigned long)_stext && addr <= (unsigned long)_etext) ||
74662 @@ -69,13 +93,28 @@ static inline int is_kernel_text(unsigned long addr)
74663
74664 static inline int is_kernel(unsigned long addr)
74665 {
74666 +
74667 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
74668 + if (is_kernel_text(addr) || is_kernel_inittext(addr))
74669 + return 1;
74670 +
74671 + if (ktla_ktva((unsigned long)_text) <= addr && addr < (unsigned long)_end)
74672 +#else
74673 if (addr >= (unsigned long)_stext && addr <= (unsigned long)_end)
74674 +#endif
74675 +
74676 return 1;
74677 return in_gate_area_no_mm(addr);
74678 }
74679
74680 static int is_ksym_addr(unsigned long addr)
74681 {
74682 +
74683 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
74684 + if (is_module_text(addr))
74685 + return 0;
74686 +#endif
74687 +
74688 if (all_var)
74689 return is_kernel(addr);
74690
74691 @@ -470,7 +509,6 @@ static unsigned long get_ksymbol_core(struct kallsym_iter *iter)
74692
74693 static void reset_iter(struct kallsym_iter *iter, loff_t new_pos)
74694 {
74695 - iter->name[0] = '\0';
74696 iter->nameoff = get_symbol_offset(new_pos);
74697 iter->pos = new_pos;
74698 }
74699 @@ -518,6 +556,11 @@ static int s_show(struct seq_file *m, void *p)
74700 {
74701 struct kallsym_iter *iter = m->private;
74702
74703 +#ifdef CONFIG_GRKERNSEC_HIDESYM
74704 + if (!uid_eq(current_uid(), GLOBAL_ROOT_UID))
74705 + return 0;
74706 +#endif
74707 +
74708 /* Some debugging symbols have no name. Ignore them. */
74709 if (!iter->name[0])
74710 return 0;
74711 @@ -531,6 +574,7 @@ static int s_show(struct seq_file *m, void *p)
74712 */
74713 type = iter->exported ? toupper(iter->type) :
74714 tolower(iter->type);
74715 +
74716 seq_printf(m, "%pK %c %s\t[%s]\n", (void *)iter->value,
74717 type, iter->name, iter->module_name);
74718 } else
74719 @@ -556,7 +600,7 @@ static int kallsyms_open(struct inode *inode, struct file *file)
74720 struct kallsym_iter *iter;
74721 int ret;
74722
74723 - iter = kmalloc(sizeof(*iter), GFP_KERNEL);
74724 + iter = kzalloc(sizeof(*iter), GFP_KERNEL);
74725 if (!iter)
74726 return -ENOMEM;
74727 reset_iter(iter, 0);
74728 diff --git a/kernel/kcmp.c b/kernel/kcmp.c
74729 index e30ac0f..3528cac 100644
74730 --- a/kernel/kcmp.c
74731 +++ b/kernel/kcmp.c
74732 @@ -99,6 +99,10 @@ SYSCALL_DEFINE5(kcmp, pid_t, pid1, pid_t, pid2, int, type,
74733 struct task_struct *task1, *task2;
74734 int ret;
74735
74736 +#ifdef CONFIG_GRKERNSEC
74737 + return -ENOSYS;
74738 +#endif
74739 +
74740 rcu_read_lock();
74741
74742 /*
74743 diff --git a/kernel/kexec.c b/kernel/kexec.c
74744 index 5e4bd78..00c5b91 100644
74745 --- a/kernel/kexec.c
74746 +++ b/kernel/kexec.c
74747 @@ -1045,7 +1045,8 @@ asmlinkage long compat_sys_kexec_load(unsigned long entry,
74748 unsigned long flags)
74749 {
74750 struct compat_kexec_segment in;
74751 - struct kexec_segment out, __user *ksegments;
74752 + struct kexec_segment out;
74753 + struct kexec_segment __user *ksegments;
74754 unsigned long i, result;
74755
74756 /* Don't allow clients that don't understand the native
74757 diff --git a/kernel/kmod.c b/kernel/kmod.c
74758 index 0023a87..9c0c068 100644
74759 --- a/kernel/kmod.c
74760 +++ b/kernel/kmod.c
74761 @@ -74,7 +74,7 @@ static void free_modprobe_argv(struct subprocess_info *info)
74762 kfree(info->argv);
74763 }
74764
74765 -static int call_modprobe(char *module_name, int wait)
74766 +static int call_modprobe(char *module_name, char *module_param, int wait)
74767 {
74768 static char *envp[] = {
74769 "HOME=/",
74770 @@ -83,7 +83,7 @@ static int call_modprobe(char *module_name, int wait)
74771 NULL
74772 };
74773
74774 - char **argv = kmalloc(sizeof(char *[5]), GFP_KERNEL);
74775 + char **argv = kmalloc(sizeof(char *[6]), GFP_KERNEL);
74776 if (!argv)
74777 goto out;
74778
74779 @@ -95,7 +95,8 @@ static int call_modprobe(char *module_name, int wait)
74780 argv[1] = "-q";
74781 argv[2] = "--";
74782 argv[3] = module_name; /* check free_modprobe_argv() */
74783 - argv[4] = NULL;
74784 + argv[4] = module_param;
74785 + argv[5] = NULL;
74786
74787 return call_usermodehelper_fns(modprobe_path, argv, envp,
74788 wait | UMH_KILLABLE, NULL, free_modprobe_argv, NULL);
74789 @@ -120,9 +121,8 @@ out:
74790 * If module auto-loading support is disabled then this function
74791 * becomes a no-operation.
74792 */
74793 -int __request_module(bool wait, const char *fmt, ...)
74794 +static int ____request_module(bool wait, char *module_param, const char *fmt, va_list ap)
74795 {
74796 - va_list args;
74797 char module_name[MODULE_NAME_LEN];
74798 unsigned int max_modprobes;
74799 int ret;
74800 @@ -130,9 +130,7 @@ int __request_module(bool wait, const char *fmt, ...)
74801 #define MAX_KMOD_CONCURRENT 50 /* Completely arbitrary value - KAO */
74802 static int kmod_loop_msg;
74803
74804 - va_start(args, fmt);
74805 - ret = vsnprintf(module_name, MODULE_NAME_LEN, fmt, args);
74806 - va_end(args);
74807 + ret = vsnprintf(module_name, MODULE_NAME_LEN, fmt, ap);
74808 if (ret >= MODULE_NAME_LEN)
74809 return -ENAMETOOLONG;
74810
74811 @@ -140,6 +138,20 @@ int __request_module(bool wait, const char *fmt, ...)
74812 if (ret)
74813 return ret;
74814
74815 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
74816 + if (uid_eq(current_uid(), GLOBAL_ROOT_UID)) {
74817 + /* hack to workaround consolekit/udisks stupidity */
74818 + read_lock(&tasklist_lock);
74819 + if (!strcmp(current->comm, "mount") &&
74820 + current->real_parent && !strncmp(current->real_parent->comm, "udisk", 5)) {
74821 + read_unlock(&tasklist_lock);
74822 + printk(KERN_ALERT "grsec: denied attempt to auto-load fs module %.64s by udisks\n", module_name);
74823 + return -EPERM;
74824 + }
74825 + read_unlock(&tasklist_lock);
74826 + }
74827 +#endif
74828 +
74829 /* If modprobe needs a service that is in a module, we get a recursive
74830 * loop. Limit the number of running kmod threads to max_threads/2 or
74831 * MAX_KMOD_CONCURRENT, whichever is the smaller. A cleaner method
74832 @@ -168,11 +180,52 @@ int __request_module(bool wait, const char *fmt, ...)
74833
74834 trace_module_request(module_name, wait, _RET_IP_);
74835
74836 - ret = call_modprobe(module_name, wait ? UMH_WAIT_PROC : UMH_WAIT_EXEC);
74837 + ret = call_modprobe(module_name, module_param, wait ? UMH_WAIT_PROC : UMH_WAIT_EXEC);
74838
74839 atomic_dec(&kmod_concurrent);
74840 return ret;
74841 }
74842 +
74843 +int ___request_module(bool wait, char *module_param, const char *fmt, ...)
74844 +{
74845 + va_list args;
74846 + int ret;
74847 +
74848 + va_start(args, fmt);
74849 + ret = ____request_module(wait, module_param, fmt, args);
74850 + va_end(args);
74851 +
74852 + return ret;
74853 +}
74854 +
74855 +int __request_module(bool wait, const char *fmt, ...)
74856 +{
74857 + va_list args;
74858 + int ret;
74859 +
74860 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
74861 + if (!uid_eq(current_uid(), GLOBAL_ROOT_UID)) {
74862 + char module_param[MODULE_NAME_LEN];
74863 +
74864 + memset(module_param, 0, sizeof(module_param));
74865 +
74866 + snprintf(module_param, sizeof(module_param) - 1, "grsec_modharden_normal%u_", GR_GLOBAL_UID(current_uid()));
74867 +
74868 + va_start(args, fmt);
74869 + ret = ____request_module(wait, module_param, fmt, args);
74870 + va_end(args);
74871 +
74872 + return ret;
74873 + }
74874 +#endif
74875 +
74876 + va_start(args, fmt);
74877 + ret = ____request_module(wait, NULL, fmt, args);
74878 + va_end(args);
74879 +
74880 + return ret;
74881 +}
74882 +
74883 EXPORT_SYMBOL(__request_module);
74884 #endif /* CONFIG_MODULES */
74885
74886 @@ -283,7 +336,7 @@ static int wait_for_helper(void *data)
74887 *
74888 * Thus the __user pointer cast is valid here.
74889 */
74890 - sys_wait4(pid, (int __user *)&ret, 0, NULL);
74891 + sys_wait4(pid, (int __force_user *)&ret, 0, NULL);
74892
74893 /*
74894 * If ret is 0, either ____call_usermodehelper failed and the
74895 @@ -635,7 +688,7 @@ EXPORT_SYMBOL(call_usermodehelper_fns);
74896 static int proc_cap_handler(struct ctl_table *table, int write,
74897 void __user *buffer, size_t *lenp, loff_t *ppos)
74898 {
74899 - struct ctl_table t;
74900 + ctl_table_no_const t;
74901 unsigned long cap_array[_KERNEL_CAPABILITY_U32S];
74902 kernel_cap_t new_cap;
74903 int err, i;
74904 diff --git a/kernel/kprobes.c b/kernel/kprobes.c
74905 index 098f396..fe85ff1 100644
74906 --- a/kernel/kprobes.c
74907 +++ b/kernel/kprobes.c
74908 @@ -185,7 +185,7 @@ static kprobe_opcode_t __kprobes *__get_insn_slot(struct kprobe_insn_cache *c)
74909 * kernel image and loaded module images reside. This is required
74910 * so x86_64 can correctly handle the %rip-relative fixups.
74911 */
74912 - kip->insns = module_alloc(PAGE_SIZE);
74913 + kip->insns = module_alloc_exec(PAGE_SIZE);
74914 if (!kip->insns) {
74915 kfree(kip);
74916 return NULL;
74917 @@ -225,7 +225,7 @@ static int __kprobes collect_one_slot(struct kprobe_insn_page *kip, int idx)
74918 */
74919 if (!list_is_singular(&kip->list)) {
74920 list_del(&kip->list);
74921 - module_free(NULL, kip->insns);
74922 + module_free_exec(NULL, kip->insns);
74923 kfree(kip);
74924 }
74925 return 1;
74926 @@ -2063,7 +2063,7 @@ static int __init init_kprobes(void)
74927 {
74928 int i, err = 0;
74929 unsigned long offset = 0, size = 0;
74930 - char *modname, namebuf[128];
74931 + char *modname, namebuf[KSYM_NAME_LEN];
74932 const char *symbol_name;
74933 void *addr;
74934 struct kprobe_blackpoint *kb;
74935 @@ -2148,11 +2148,11 @@ static void __kprobes report_probe(struct seq_file *pi, struct kprobe *p,
74936 kprobe_type = "k";
74937
74938 if (sym)
74939 - seq_printf(pi, "%p %s %s+0x%x %s ",
74940 + seq_printf(pi, "%pK %s %s+0x%x %s ",
74941 p->addr, kprobe_type, sym, offset,
74942 (modname ? modname : " "));
74943 else
74944 - seq_printf(pi, "%p %s %p ",
74945 + seq_printf(pi, "%pK %s %pK ",
74946 p->addr, kprobe_type, p->addr);
74947
74948 if (!pp)
74949 @@ -2190,7 +2190,7 @@ static int __kprobes show_kprobe_addr(struct seq_file *pi, void *v)
74950 const char *sym = NULL;
74951 unsigned int i = *(loff_t *) v;
74952 unsigned long offset = 0;
74953 - char *modname, namebuf[128];
74954 + char *modname, namebuf[KSYM_NAME_LEN];
74955
74956 head = &kprobe_table[i];
74957 preempt_disable();
74958 diff --git a/kernel/ksysfs.c b/kernel/ksysfs.c
74959 index 6ada93c..dce7d5d 100644
74960 --- a/kernel/ksysfs.c
74961 +++ b/kernel/ksysfs.c
74962 @@ -46,6 +46,8 @@ static ssize_t uevent_helper_store(struct kobject *kobj,
74963 {
74964 if (count+1 > UEVENT_HELPER_PATH_LEN)
74965 return -ENOENT;
74966 + if (!capable(CAP_SYS_ADMIN))
74967 + return -EPERM;
74968 memcpy(uevent_helper, buf, count);
74969 uevent_helper[count] = '\0';
74970 if (count && uevent_helper[count-1] == '\n')
74971 @@ -172,7 +174,7 @@ static ssize_t notes_read(struct file *filp, struct kobject *kobj,
74972 return count;
74973 }
74974
74975 -static struct bin_attribute notes_attr = {
74976 +static bin_attribute_no_const notes_attr __read_only = {
74977 .attr = {
74978 .name = "notes",
74979 .mode = S_IRUGO,
74980 diff --git a/kernel/lockdep.c b/kernel/lockdep.c
74981 index 7981e5b..7f2105c 100644
74982 --- a/kernel/lockdep.c
74983 +++ b/kernel/lockdep.c
74984 @@ -590,6 +590,10 @@ static int static_obj(void *obj)
74985 end = (unsigned long) &_end,
74986 addr = (unsigned long) obj;
74987
74988 +#ifdef CONFIG_PAX_KERNEXEC
74989 + start = ktla_ktva(start);
74990 +#endif
74991 +
74992 /*
74993 * static variable?
74994 */
74995 @@ -730,6 +734,7 @@ register_lock_class(struct lockdep_map *lock, unsigned int subclass, int force)
74996 if (!static_obj(lock->key)) {
74997 debug_locks_off();
74998 printk("INFO: trying to register non-static key.\n");
74999 + printk("lock:%pS key:%pS.\n", lock, lock->key);
75000 printk("the code is fine but needs lockdep annotation.\n");
75001 printk("turning off the locking correctness validator.\n");
75002 dump_stack();
75003 @@ -3078,7 +3083,7 @@ static int __lock_acquire(struct lockdep_map *lock, unsigned int subclass,
75004 if (!class)
75005 return 0;
75006 }
75007 - atomic_inc((atomic_t *)&class->ops);
75008 + atomic_inc_unchecked((atomic_unchecked_t *)&class->ops);
75009 if (very_verbose(class)) {
75010 printk("\nacquire class [%p] %s", class->key, class->name);
75011 if (class->name_version > 1)
75012 diff --git a/kernel/lockdep_proc.c b/kernel/lockdep_proc.c
75013 index b2c71c5..7b88d63 100644
75014 --- a/kernel/lockdep_proc.c
75015 +++ b/kernel/lockdep_proc.c
75016 @@ -65,7 +65,7 @@ static int l_show(struct seq_file *m, void *v)
75017 return 0;
75018 }
75019
75020 - seq_printf(m, "%p", class->key);
75021 + seq_printf(m, "%pK", class->key);
75022 #ifdef CONFIG_DEBUG_LOCKDEP
75023 seq_printf(m, " OPS:%8ld", class->ops);
75024 #endif
75025 @@ -83,7 +83,7 @@ static int l_show(struct seq_file *m, void *v)
75026
75027 list_for_each_entry(entry, &class->locks_after, entry) {
75028 if (entry->distance == 1) {
75029 - seq_printf(m, " -> [%p] ", entry->class->key);
75030 + seq_printf(m, " -> [%pK] ", entry->class->key);
75031 print_name(m, entry->class);
75032 seq_puts(m, "\n");
75033 }
75034 @@ -152,7 +152,7 @@ static int lc_show(struct seq_file *m, void *v)
75035 if (!class->key)
75036 continue;
75037
75038 - seq_printf(m, "[%p] ", class->key);
75039 + seq_printf(m, "[%pK] ", class->key);
75040 print_name(m, class);
75041 seq_puts(m, "\n");
75042 }
75043 @@ -495,7 +495,7 @@ static void seq_stats(struct seq_file *m, struct lock_stat_data *data)
75044 if (!i)
75045 seq_line(m, '-', 40-namelen, namelen);
75046
75047 - snprintf(ip, sizeof(ip), "[<%p>]",
75048 + snprintf(ip, sizeof(ip), "[<%pK>]",
75049 (void *)class->contention_point[i]);
75050 seq_printf(m, "%40s %14lu %29s %pS\n",
75051 name, stats->contention_point[i],
75052 @@ -510,7 +510,7 @@ static void seq_stats(struct seq_file *m, struct lock_stat_data *data)
75053 if (!i)
75054 seq_line(m, '-', 40-namelen, namelen);
75055
75056 - snprintf(ip, sizeof(ip), "[<%p>]",
75057 + snprintf(ip, sizeof(ip), "[<%pK>]",
75058 (void *)class->contending_point[i]);
75059 seq_printf(m, "%40s %14lu %29s %pS\n",
75060 name, stats->contending_point[i],
75061 diff --git a/kernel/module.c b/kernel/module.c
75062 index eab0827..f488603 100644
75063 --- a/kernel/module.c
75064 +++ b/kernel/module.c
75065 @@ -61,6 +61,7 @@
75066 #include <linux/pfn.h>
75067 #include <linux/bsearch.h>
75068 #include <linux/fips.h>
75069 +#include <linux/grsecurity.h>
75070 #include <uapi/linux/module.h>
75071 #include "module-internal.h"
75072
75073 @@ -156,7 +157,8 @@ static BLOCKING_NOTIFIER_HEAD(module_notify_list);
75074
75075 /* Bounds of module allocation, for speeding __module_address.
75076 * Protected by module_mutex. */
75077 -static unsigned long module_addr_min = -1UL, module_addr_max = 0;
75078 +static unsigned long module_addr_min_rw = -1UL, module_addr_max_rw = 0;
75079 +static unsigned long module_addr_min_rx = -1UL, module_addr_max_rx = 0;
75080
75081 int register_module_notifier(struct notifier_block * nb)
75082 {
75083 @@ -322,7 +324,7 @@ bool each_symbol_section(bool (*fn)(const struct symsearch *arr,
75084 return true;
75085
75086 list_for_each_entry_rcu(mod, &modules, list) {
75087 - struct symsearch arr[] = {
75088 + struct symsearch modarr[] = {
75089 { mod->syms, mod->syms + mod->num_syms, mod->crcs,
75090 NOT_GPL_ONLY, false },
75091 { mod->gpl_syms, mod->gpl_syms + mod->num_gpl_syms,
75092 @@ -347,7 +349,7 @@ bool each_symbol_section(bool (*fn)(const struct symsearch *arr,
75093 if (mod->state == MODULE_STATE_UNFORMED)
75094 continue;
75095
75096 - if (each_symbol_in_section(arr, ARRAY_SIZE(arr), mod, fn, data))
75097 + if (each_symbol_in_section(modarr, ARRAY_SIZE(modarr), mod, fn, data))
75098 return true;
75099 }
75100 return false;
75101 @@ -484,7 +486,7 @@ static inline void __percpu *mod_percpu(struct module *mod)
75102 static int percpu_modalloc(struct module *mod,
75103 unsigned long size, unsigned long align)
75104 {
75105 - if (align > PAGE_SIZE) {
75106 + if (align-1 >= PAGE_SIZE) {
75107 printk(KERN_WARNING "%s: per-cpu alignment %li > %li\n",
75108 mod->name, align, PAGE_SIZE);
75109 align = PAGE_SIZE;
75110 @@ -1088,7 +1090,7 @@ struct module_attribute module_uevent =
75111 static ssize_t show_coresize(struct module_attribute *mattr,
75112 struct module_kobject *mk, char *buffer)
75113 {
75114 - return sprintf(buffer, "%u\n", mk->mod->core_size);
75115 + return sprintf(buffer, "%u\n", mk->mod->core_size_rx + mk->mod->core_size_rw);
75116 }
75117
75118 static struct module_attribute modinfo_coresize =
75119 @@ -1097,7 +1099,7 @@ static struct module_attribute modinfo_coresize =
75120 static ssize_t show_initsize(struct module_attribute *mattr,
75121 struct module_kobject *mk, char *buffer)
75122 {
75123 - return sprintf(buffer, "%u\n", mk->mod->init_size);
75124 + return sprintf(buffer, "%u\n", mk->mod->init_size_rx + mk->mod->init_size_rw);
75125 }
75126
75127 static struct module_attribute modinfo_initsize =
75128 @@ -1311,7 +1313,7 @@ resolve_symbol_wait(struct module *mod,
75129 */
75130 #ifdef CONFIG_SYSFS
75131
75132 -#ifdef CONFIG_KALLSYMS
75133 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
75134 static inline bool sect_empty(const Elf_Shdr *sect)
75135 {
75136 return !(sect->sh_flags & SHF_ALLOC) || sect->sh_size == 0;
75137 @@ -1451,7 +1453,7 @@ static void add_notes_attrs(struct module *mod, const struct load_info *info)
75138 {
75139 unsigned int notes, loaded, i;
75140 struct module_notes_attrs *notes_attrs;
75141 - struct bin_attribute *nattr;
75142 + bin_attribute_no_const *nattr;
75143
75144 /* failed to create section attributes, so can't create notes */
75145 if (!mod->sect_attrs)
75146 @@ -1563,7 +1565,7 @@ static void del_usage_links(struct module *mod)
75147 static int module_add_modinfo_attrs(struct module *mod)
75148 {
75149 struct module_attribute *attr;
75150 - struct module_attribute *temp_attr;
75151 + module_attribute_no_const *temp_attr;
75152 int error = 0;
75153 int i;
75154
75155 @@ -1777,21 +1779,21 @@ static void set_section_ro_nx(void *base,
75156
75157 static void unset_module_core_ro_nx(struct module *mod)
75158 {
75159 - set_page_attributes(mod->module_core + mod->core_text_size,
75160 - mod->module_core + mod->core_size,
75161 + set_page_attributes(mod->module_core_rw,
75162 + mod->module_core_rw + mod->core_size_rw,
75163 set_memory_x);
75164 - set_page_attributes(mod->module_core,
75165 - mod->module_core + mod->core_ro_size,
75166 + set_page_attributes(mod->module_core_rx,
75167 + mod->module_core_rx + mod->core_size_rx,
75168 set_memory_rw);
75169 }
75170
75171 static void unset_module_init_ro_nx(struct module *mod)
75172 {
75173 - set_page_attributes(mod->module_init + mod->init_text_size,
75174 - mod->module_init + mod->init_size,
75175 + set_page_attributes(mod->module_init_rw,
75176 + mod->module_init_rw + mod->init_size_rw,
75177 set_memory_x);
75178 - set_page_attributes(mod->module_init,
75179 - mod->module_init + mod->init_ro_size,
75180 + set_page_attributes(mod->module_init_rx,
75181 + mod->module_init_rx + mod->init_size_rx,
75182 set_memory_rw);
75183 }
75184
75185 @@ -1804,14 +1806,14 @@ void set_all_modules_text_rw(void)
75186 list_for_each_entry_rcu(mod, &modules, list) {
75187 if (mod->state == MODULE_STATE_UNFORMED)
75188 continue;
75189 - if ((mod->module_core) && (mod->core_text_size)) {
75190 - set_page_attributes(mod->module_core,
75191 - mod->module_core + mod->core_text_size,
75192 + if ((mod->module_core_rx) && (mod->core_size_rx)) {
75193 + set_page_attributes(mod->module_core_rx,
75194 + mod->module_core_rx + mod->core_size_rx,
75195 set_memory_rw);
75196 }
75197 - if ((mod->module_init) && (mod->init_text_size)) {
75198 - set_page_attributes(mod->module_init,
75199 - mod->module_init + mod->init_text_size,
75200 + if ((mod->module_init_rx) && (mod->init_size_rx)) {
75201 + set_page_attributes(mod->module_init_rx,
75202 + mod->module_init_rx + mod->init_size_rx,
75203 set_memory_rw);
75204 }
75205 }
75206 @@ -1827,14 +1829,14 @@ void set_all_modules_text_ro(void)
75207 list_for_each_entry_rcu(mod, &modules, list) {
75208 if (mod->state == MODULE_STATE_UNFORMED)
75209 continue;
75210 - if ((mod->module_core) && (mod->core_text_size)) {
75211 - set_page_attributes(mod->module_core,
75212 - mod->module_core + mod->core_text_size,
75213 + if ((mod->module_core_rx) && (mod->core_size_rx)) {
75214 + set_page_attributes(mod->module_core_rx,
75215 + mod->module_core_rx + mod->core_size_rx,
75216 set_memory_ro);
75217 }
75218 - if ((mod->module_init) && (mod->init_text_size)) {
75219 - set_page_attributes(mod->module_init,
75220 - mod->module_init + mod->init_text_size,
75221 + if ((mod->module_init_rx) && (mod->init_size_rx)) {
75222 + set_page_attributes(mod->module_init_rx,
75223 + mod->module_init_rx + mod->init_size_rx,
75224 set_memory_ro);
75225 }
75226 }
75227 @@ -1880,16 +1882,19 @@ static void free_module(struct module *mod)
75228
75229 /* This may be NULL, but that's OK */
75230 unset_module_init_ro_nx(mod);
75231 - module_free(mod, mod->module_init);
75232 + module_free(mod, mod->module_init_rw);
75233 + module_free_exec(mod, mod->module_init_rx);
75234 kfree(mod->args);
75235 percpu_modfree(mod);
75236
75237 /* Free lock-classes: */
75238 - lockdep_free_key_range(mod->module_core, mod->core_size);
75239 + lockdep_free_key_range(mod->module_core_rx, mod->core_size_rx);
75240 + lockdep_free_key_range(mod->module_core_rw, mod->core_size_rw);
75241
75242 /* Finally, free the core (containing the module structure) */
75243 unset_module_core_ro_nx(mod);
75244 - module_free(mod, mod->module_core);
75245 + module_free_exec(mod, mod->module_core_rx);
75246 + module_free(mod, mod->module_core_rw);
75247
75248 #ifdef CONFIG_MPU
75249 update_protections(current->mm);
75250 @@ -1959,9 +1964,31 @@ static int simplify_symbols(struct module *mod, const struct load_info *info)
75251 int ret = 0;
75252 const struct kernel_symbol *ksym;
75253
75254 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
75255 + int is_fs_load = 0;
75256 + int register_filesystem_found = 0;
75257 + char *p;
75258 +
75259 + p = strstr(mod->args, "grsec_modharden_fs");
75260 + if (p) {
75261 + char *endptr = p + sizeof("grsec_modharden_fs") - 1;
75262 + /* copy \0 as well */
75263 + memmove(p, endptr, strlen(mod->args) - (unsigned int)(endptr - mod->args) + 1);
75264 + is_fs_load = 1;
75265 + }
75266 +#endif
75267 +
75268 for (i = 1; i < symsec->sh_size / sizeof(Elf_Sym); i++) {
75269 const char *name = info->strtab + sym[i].st_name;
75270
75271 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
75272 + /* it's a real shame this will never get ripped and copied
75273 + upstream! ;(
75274 + */
75275 + if (is_fs_load && !strcmp(name, "register_filesystem"))
75276 + register_filesystem_found = 1;
75277 +#endif
75278 +
75279 switch (sym[i].st_shndx) {
75280 case SHN_COMMON:
75281 /* We compiled with -fno-common. These are not
75282 @@ -1982,7 +2009,9 @@ static int simplify_symbols(struct module *mod, const struct load_info *info)
75283 ksym = resolve_symbol_wait(mod, info, name);
75284 /* Ok if resolved. */
75285 if (ksym && !IS_ERR(ksym)) {
75286 + pax_open_kernel();
75287 sym[i].st_value = ksym->value;
75288 + pax_close_kernel();
75289 break;
75290 }
75291
75292 @@ -2001,11 +2030,20 @@ static int simplify_symbols(struct module *mod, const struct load_info *info)
75293 secbase = (unsigned long)mod_percpu(mod);
75294 else
75295 secbase = info->sechdrs[sym[i].st_shndx].sh_addr;
75296 + pax_open_kernel();
75297 sym[i].st_value += secbase;
75298 + pax_close_kernel();
75299 break;
75300 }
75301 }
75302
75303 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
75304 + if (is_fs_load && !register_filesystem_found) {
75305 + printk(KERN_ALERT "grsec: Denied attempt to load non-fs module %.64s through mount\n", mod->name);
75306 + ret = -EPERM;
75307 + }
75308 +#endif
75309 +
75310 return ret;
75311 }
75312
75313 @@ -2089,22 +2127,12 @@ static void layout_sections(struct module *mod, struct load_info *info)
75314 || s->sh_entsize != ~0UL
75315 || strstarts(sname, ".init"))
75316 continue;
75317 - s->sh_entsize = get_offset(mod, &mod->core_size, s, i);
75318 + if ((s->sh_flags & SHF_WRITE) || !(s->sh_flags & SHF_ALLOC))
75319 + s->sh_entsize = get_offset(mod, &mod->core_size_rw, s, i);
75320 + else
75321 + s->sh_entsize = get_offset(mod, &mod->core_size_rx, s, i);
75322 pr_debug("\t%s\n", sname);
75323 }
75324 - switch (m) {
75325 - case 0: /* executable */
75326 - mod->core_size = debug_align(mod->core_size);
75327 - mod->core_text_size = mod->core_size;
75328 - break;
75329 - case 1: /* RO: text and ro-data */
75330 - mod->core_size = debug_align(mod->core_size);
75331 - mod->core_ro_size = mod->core_size;
75332 - break;
75333 - case 3: /* whole core */
75334 - mod->core_size = debug_align(mod->core_size);
75335 - break;
75336 - }
75337 }
75338
75339 pr_debug("Init section allocation order:\n");
75340 @@ -2118,23 +2146,13 @@ static void layout_sections(struct module *mod, struct load_info *info)
75341 || s->sh_entsize != ~0UL
75342 || !strstarts(sname, ".init"))
75343 continue;
75344 - s->sh_entsize = (get_offset(mod, &mod->init_size, s, i)
75345 - | INIT_OFFSET_MASK);
75346 + if ((s->sh_flags & SHF_WRITE) || !(s->sh_flags & SHF_ALLOC))
75347 + s->sh_entsize = get_offset(mod, &mod->init_size_rw, s, i);
75348 + else
75349 + s->sh_entsize = get_offset(mod, &mod->init_size_rx, s, i);
75350 + s->sh_entsize |= INIT_OFFSET_MASK;
75351 pr_debug("\t%s\n", sname);
75352 }
75353 - switch (m) {
75354 - case 0: /* executable */
75355 - mod->init_size = debug_align(mod->init_size);
75356 - mod->init_text_size = mod->init_size;
75357 - break;
75358 - case 1: /* RO: text and ro-data */
75359 - mod->init_size = debug_align(mod->init_size);
75360 - mod->init_ro_size = mod->init_size;
75361 - break;
75362 - case 3: /* whole init */
75363 - mod->init_size = debug_align(mod->init_size);
75364 - break;
75365 - }
75366 }
75367 }
75368
75369 @@ -2306,7 +2324,7 @@ static void layout_symtab(struct module *mod, struct load_info *info)
75370
75371 /* Put symbol section at end of init part of module. */
75372 symsect->sh_flags |= SHF_ALLOC;
75373 - symsect->sh_entsize = get_offset(mod, &mod->init_size, symsect,
75374 + symsect->sh_entsize = get_offset(mod, &mod->init_size_rx, symsect,
75375 info->index.sym) | INIT_OFFSET_MASK;
75376 pr_debug("\t%s\n", info->secstrings + symsect->sh_name);
75377
75378 @@ -2323,13 +2341,13 @@ static void layout_symtab(struct module *mod, struct load_info *info)
75379 }
75380
75381 /* Append room for core symbols at end of core part. */
75382 - info->symoffs = ALIGN(mod->core_size, symsect->sh_addralign ?: 1);
75383 - info->stroffs = mod->core_size = info->symoffs + ndst * sizeof(Elf_Sym);
75384 - mod->core_size += strtab_size;
75385 + info->symoffs = ALIGN(mod->core_size_rx, symsect->sh_addralign ?: 1);
75386 + info->stroffs = mod->core_size_rx = info->symoffs + ndst * sizeof(Elf_Sym);
75387 + mod->core_size_rx += strtab_size;
75388
75389 /* Put string table section at end of init part of module. */
75390 strsect->sh_flags |= SHF_ALLOC;
75391 - strsect->sh_entsize = get_offset(mod, &mod->init_size, strsect,
75392 + strsect->sh_entsize = get_offset(mod, &mod->init_size_rx, strsect,
75393 info->index.str) | INIT_OFFSET_MASK;
75394 pr_debug("\t%s\n", info->secstrings + strsect->sh_name);
75395 }
75396 @@ -2347,12 +2365,14 @@ static void add_kallsyms(struct module *mod, const struct load_info *info)
75397 /* Make sure we get permanent strtab: don't use info->strtab. */
75398 mod->strtab = (void *)info->sechdrs[info->index.str].sh_addr;
75399
75400 + pax_open_kernel();
75401 +
75402 /* Set types up while we still have access to sections. */
75403 for (i = 0; i < mod->num_symtab; i++)
75404 mod->symtab[i].st_info = elf_type(&mod->symtab[i], info);
75405
75406 - mod->core_symtab = dst = mod->module_core + info->symoffs;
75407 - mod->core_strtab = s = mod->module_core + info->stroffs;
75408 + mod->core_symtab = dst = mod->module_core_rx + info->symoffs;
75409 + mod->core_strtab = s = mod->module_core_rx + info->stroffs;
75410 src = mod->symtab;
75411 for (ndst = i = 0; i < mod->num_symtab; i++) {
75412 if (i == 0 ||
75413 @@ -2364,6 +2384,8 @@ static void add_kallsyms(struct module *mod, const struct load_info *info)
75414 }
75415 }
75416 mod->core_num_syms = ndst;
75417 +
75418 + pax_close_kernel();
75419 }
75420 #else
75421 static inline void layout_symtab(struct module *mod, struct load_info *info)
75422 @@ -2397,17 +2419,33 @@ void * __weak module_alloc(unsigned long size)
75423 return vmalloc_exec(size);
75424 }
75425
75426 -static void *module_alloc_update_bounds(unsigned long size)
75427 +static void *module_alloc_update_bounds_rw(unsigned long size)
75428 {
75429 void *ret = module_alloc(size);
75430
75431 if (ret) {
75432 mutex_lock(&module_mutex);
75433 /* Update module bounds. */
75434 - if ((unsigned long)ret < module_addr_min)
75435 - module_addr_min = (unsigned long)ret;
75436 - if ((unsigned long)ret + size > module_addr_max)
75437 - module_addr_max = (unsigned long)ret + size;
75438 + if ((unsigned long)ret < module_addr_min_rw)
75439 + module_addr_min_rw = (unsigned long)ret;
75440 + if ((unsigned long)ret + size > module_addr_max_rw)
75441 + module_addr_max_rw = (unsigned long)ret + size;
75442 + mutex_unlock(&module_mutex);
75443 + }
75444 + return ret;
75445 +}
75446 +
75447 +static void *module_alloc_update_bounds_rx(unsigned long size)
75448 +{
75449 + void *ret = module_alloc_exec(size);
75450 +
75451 + if (ret) {
75452 + mutex_lock(&module_mutex);
75453 + /* Update module bounds. */
75454 + if ((unsigned long)ret < module_addr_min_rx)
75455 + module_addr_min_rx = (unsigned long)ret;
75456 + if ((unsigned long)ret + size > module_addr_max_rx)
75457 + module_addr_max_rx = (unsigned long)ret + size;
75458 mutex_unlock(&module_mutex);
75459 }
75460 return ret;
75461 @@ -2683,8 +2721,14 @@ static struct module *setup_load_info(struct load_info *info, int flags)
75462 static int check_modinfo(struct module *mod, struct load_info *info, int flags)
75463 {
75464 const char *modmagic = get_modinfo(info, "vermagic");
75465 + const char *license = get_modinfo(info, "license");
75466 int err;
75467
75468 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR
75469 + if (!license || !license_is_gpl_compatible(license))
75470 + return -ENOEXEC;
75471 +#endif
75472 +
75473 if (flags & MODULE_INIT_IGNORE_VERMAGIC)
75474 modmagic = NULL;
75475
75476 @@ -2710,7 +2754,7 @@ static int check_modinfo(struct module *mod, struct load_info *info, int flags)
75477 }
75478
75479 /* Set up license info based on the info section */
75480 - set_license(mod, get_modinfo(info, "license"));
75481 + set_license(mod, license);
75482
75483 return 0;
75484 }
75485 @@ -2804,7 +2848,7 @@ static int move_module(struct module *mod, struct load_info *info)
75486 void *ptr;
75487
75488 /* Do the allocs. */
75489 - ptr = module_alloc_update_bounds(mod->core_size);
75490 + ptr = module_alloc_update_bounds_rw(mod->core_size_rw);
75491 /*
75492 * The pointer to this block is stored in the module structure
75493 * which is inside the block. Just mark it as not being a
75494 @@ -2814,11 +2858,11 @@ static int move_module(struct module *mod, struct load_info *info)
75495 if (!ptr)
75496 return -ENOMEM;
75497
75498 - memset(ptr, 0, mod->core_size);
75499 - mod->module_core = ptr;
75500 + memset(ptr, 0, mod->core_size_rw);
75501 + mod->module_core_rw = ptr;
75502
75503 - if (mod->init_size) {
75504 - ptr = module_alloc_update_bounds(mod->init_size);
75505 + if (mod->init_size_rw) {
75506 + ptr = module_alloc_update_bounds_rw(mod->init_size_rw);
75507 /*
75508 * The pointer to this block is stored in the module structure
75509 * which is inside the block. This block doesn't need to be
75510 @@ -2827,13 +2871,45 @@ static int move_module(struct module *mod, struct load_info *info)
75511 */
75512 kmemleak_ignore(ptr);
75513 if (!ptr) {
75514 - module_free(mod, mod->module_core);
75515 + module_free(mod, mod->module_core_rw);
75516 return -ENOMEM;
75517 }
75518 - memset(ptr, 0, mod->init_size);
75519 - mod->module_init = ptr;
75520 + memset(ptr, 0, mod->init_size_rw);
75521 + mod->module_init_rw = ptr;
75522 } else
75523 - mod->module_init = NULL;
75524 + mod->module_init_rw = NULL;
75525 +
75526 + ptr = module_alloc_update_bounds_rx(mod->core_size_rx);
75527 + kmemleak_not_leak(ptr);
75528 + if (!ptr) {
75529 + if (mod->module_init_rw)
75530 + module_free(mod, mod->module_init_rw);
75531 + module_free(mod, mod->module_core_rw);
75532 + return -ENOMEM;
75533 + }
75534 +
75535 + pax_open_kernel();
75536 + memset(ptr, 0, mod->core_size_rx);
75537 + pax_close_kernel();
75538 + mod->module_core_rx = ptr;
75539 +
75540 + if (mod->init_size_rx) {
75541 + ptr = module_alloc_update_bounds_rx(mod->init_size_rx);
75542 + kmemleak_ignore(ptr);
75543 + if (!ptr && mod->init_size_rx) {
75544 + module_free_exec(mod, mod->module_core_rx);
75545 + if (mod->module_init_rw)
75546 + module_free(mod, mod->module_init_rw);
75547 + module_free(mod, mod->module_core_rw);
75548 + return -ENOMEM;
75549 + }
75550 +
75551 + pax_open_kernel();
75552 + memset(ptr, 0, mod->init_size_rx);
75553 + pax_close_kernel();
75554 + mod->module_init_rx = ptr;
75555 + } else
75556 + mod->module_init_rx = NULL;
75557
75558 /* Transfer each section which specifies SHF_ALLOC */
75559 pr_debug("final section addresses:\n");
75560 @@ -2844,16 +2920,45 @@ static int move_module(struct module *mod, struct load_info *info)
75561 if (!(shdr->sh_flags & SHF_ALLOC))
75562 continue;
75563
75564 - if (shdr->sh_entsize & INIT_OFFSET_MASK)
75565 - dest = mod->module_init
75566 - + (shdr->sh_entsize & ~INIT_OFFSET_MASK);
75567 - else
75568 - dest = mod->module_core + shdr->sh_entsize;
75569 + if (shdr->sh_entsize & INIT_OFFSET_MASK) {
75570 + if ((shdr->sh_flags & SHF_WRITE) || !(shdr->sh_flags & SHF_ALLOC))
75571 + dest = mod->module_init_rw
75572 + + (shdr->sh_entsize & ~INIT_OFFSET_MASK);
75573 + else
75574 + dest = mod->module_init_rx
75575 + + (shdr->sh_entsize & ~INIT_OFFSET_MASK);
75576 + } else {
75577 + if ((shdr->sh_flags & SHF_WRITE) || !(shdr->sh_flags & SHF_ALLOC))
75578 + dest = mod->module_core_rw + shdr->sh_entsize;
75579 + else
75580 + dest = mod->module_core_rx + shdr->sh_entsize;
75581 + }
75582 +
75583 + if (shdr->sh_type != SHT_NOBITS) {
75584 +
75585 +#ifdef CONFIG_PAX_KERNEXEC
75586 +#ifdef CONFIG_X86_64
75587 + if ((shdr->sh_flags & SHF_WRITE) && (shdr->sh_flags & SHF_EXECINSTR))
75588 + set_memory_x((unsigned long)dest, (shdr->sh_size + PAGE_SIZE) >> PAGE_SHIFT);
75589 +#endif
75590 + if (!(shdr->sh_flags & SHF_WRITE) && (shdr->sh_flags & SHF_ALLOC)) {
75591 + pax_open_kernel();
75592 + memcpy(dest, (void *)shdr->sh_addr, shdr->sh_size);
75593 + pax_close_kernel();
75594 + } else
75595 +#endif
75596
75597 - if (shdr->sh_type != SHT_NOBITS)
75598 memcpy(dest, (void *)shdr->sh_addr, shdr->sh_size);
75599 + }
75600 /* Update sh_addr to point to copy in image. */
75601 - shdr->sh_addr = (unsigned long)dest;
75602 +
75603 +#ifdef CONFIG_PAX_KERNEXEC
75604 + if (shdr->sh_flags & SHF_EXECINSTR)
75605 + shdr->sh_addr = ktva_ktla((unsigned long)dest);
75606 + else
75607 +#endif
75608 +
75609 + shdr->sh_addr = (unsigned long)dest;
75610 pr_debug("\t0x%lx %s\n",
75611 (long)shdr->sh_addr, info->secstrings + shdr->sh_name);
75612 }
75613 @@ -2908,12 +3013,12 @@ static void flush_module_icache(const struct module *mod)
75614 * Do it before processing of module parameters, so the module
75615 * can provide parameter accessor functions of its own.
75616 */
75617 - if (mod->module_init)
75618 - flush_icache_range((unsigned long)mod->module_init,
75619 - (unsigned long)mod->module_init
75620 - + mod->init_size);
75621 - flush_icache_range((unsigned long)mod->module_core,
75622 - (unsigned long)mod->module_core + mod->core_size);
75623 + if (mod->module_init_rx)
75624 + flush_icache_range((unsigned long)mod->module_init_rx,
75625 + (unsigned long)mod->module_init_rx
75626 + + mod->init_size_rx);
75627 + flush_icache_range((unsigned long)mod->module_core_rx,
75628 + (unsigned long)mod->module_core_rx + mod->core_size_rx);
75629
75630 set_fs(old_fs);
75631 }
75632 @@ -2983,8 +3088,10 @@ out:
75633 static void module_deallocate(struct module *mod, struct load_info *info)
75634 {
75635 percpu_modfree(mod);
75636 - module_free(mod, mod->module_init);
75637 - module_free(mod, mod->module_core);
75638 + module_free_exec(mod, mod->module_init_rx);
75639 + module_free_exec(mod, mod->module_core_rx);
75640 + module_free(mod, mod->module_init_rw);
75641 + module_free(mod, mod->module_core_rw);
75642 }
75643
75644 int __weak module_finalize(const Elf_Ehdr *hdr,
75645 @@ -2997,7 +3104,9 @@ int __weak module_finalize(const Elf_Ehdr *hdr,
75646 static int post_relocation(struct module *mod, const struct load_info *info)
75647 {
75648 /* Sort exception table now relocations are done. */
75649 + pax_open_kernel();
75650 sort_extable(mod->extable, mod->extable + mod->num_exentries);
75651 + pax_close_kernel();
75652
75653 /* Copy relocated percpu area over. */
75654 percpu_modcopy(mod, (void *)info->sechdrs[info->index.pcpu].sh_addr,
75655 @@ -3051,16 +3160,16 @@ static int do_init_module(struct module *mod)
75656 MODULE_STATE_COMING, mod);
75657
75658 /* Set RO and NX regions for core */
75659 - set_section_ro_nx(mod->module_core,
75660 - mod->core_text_size,
75661 - mod->core_ro_size,
75662 - mod->core_size);
75663 + set_section_ro_nx(mod->module_core_rx,
75664 + mod->core_size_rx,
75665 + mod->core_size_rx,
75666 + mod->core_size_rx);
75667
75668 /* Set RO and NX regions for init */
75669 - set_section_ro_nx(mod->module_init,
75670 - mod->init_text_size,
75671 - mod->init_ro_size,
75672 - mod->init_size);
75673 + set_section_ro_nx(mod->module_init_rx,
75674 + mod->init_size_rx,
75675 + mod->init_size_rx,
75676 + mod->init_size_rx);
75677
75678 do_mod_ctors(mod);
75679 /* Start the module */
75680 @@ -3122,11 +3231,12 @@ static int do_init_module(struct module *mod)
75681 mod->strtab = mod->core_strtab;
75682 #endif
75683 unset_module_init_ro_nx(mod);
75684 - module_free(mod, mod->module_init);
75685 - mod->module_init = NULL;
75686 - mod->init_size = 0;
75687 - mod->init_ro_size = 0;
75688 - mod->init_text_size = 0;
75689 + module_free(mod, mod->module_init_rw);
75690 + module_free_exec(mod, mod->module_init_rx);
75691 + mod->module_init_rw = NULL;
75692 + mod->module_init_rx = NULL;
75693 + mod->init_size_rw = 0;
75694 + mod->init_size_rx = 0;
75695 mutex_unlock(&module_mutex);
75696 wake_up_all(&module_wq);
75697
75698 @@ -3209,9 +3319,38 @@ again:
75699 if (err)
75700 goto free_unload;
75701
75702 + /* Now copy in args */
75703 + mod->args = strndup_user(uargs, ~0UL >> 1);
75704 + if (IS_ERR(mod->args)) {
75705 + err = PTR_ERR(mod->args);
75706 + goto free_unload;
75707 + }
75708 +
75709 /* Set up MODINFO_ATTR fields */
75710 setup_modinfo(mod, info);
75711
75712 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
75713 + {
75714 + char *p, *p2;
75715 +
75716 + if (strstr(mod->args, "grsec_modharden_netdev")) {
75717 + 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);
75718 + err = -EPERM;
75719 + goto free_modinfo;
75720 + } else if ((p = strstr(mod->args, "grsec_modharden_normal"))) {
75721 + p += sizeof("grsec_modharden_normal") - 1;
75722 + p2 = strstr(p, "_");
75723 + if (p2) {
75724 + *p2 = '\0';
75725 + printk(KERN_ALERT "grsec: denied kernel module auto-load of %.64s by uid %.9s\n", mod->name, p);
75726 + *p2 = '_';
75727 + }
75728 + err = -EPERM;
75729 + goto free_modinfo;
75730 + }
75731 + }
75732 +#endif
75733 +
75734 /* Fix up syms, so that st_value is a pointer to location. */
75735 err = simplify_symbols(mod, info);
75736 if (err < 0)
75737 @@ -3227,13 +3366,6 @@ again:
75738
75739 flush_module_icache(mod);
75740
75741 - /* Now copy in args */
75742 - mod->args = strndup_user(uargs, ~0UL >> 1);
75743 - if (IS_ERR(mod->args)) {
75744 - err = PTR_ERR(mod->args);
75745 - goto free_arch_cleanup;
75746 - }
75747 -
75748 dynamic_debug_setup(info->debug, info->num_debug);
75749
75750 mutex_lock(&module_mutex);
75751 @@ -3278,11 +3410,10 @@ again:
75752 mutex_unlock(&module_mutex);
75753 dynamic_debug_remove(info->debug);
75754 synchronize_sched();
75755 - kfree(mod->args);
75756 - free_arch_cleanup:
75757 module_arch_cleanup(mod);
75758 free_modinfo:
75759 free_modinfo(mod);
75760 + kfree(mod->args);
75761 free_unload:
75762 module_unload_free(mod);
75763 unlink_mod:
75764 @@ -3365,10 +3496,16 @@ static const char *get_ksymbol(struct module *mod,
75765 unsigned long nextval;
75766
75767 /* At worse, next value is at end of module */
75768 - if (within_module_init(addr, mod))
75769 - nextval = (unsigned long)mod->module_init+mod->init_text_size;
75770 + if (within_module_init_rx(addr, mod))
75771 + nextval = (unsigned long)mod->module_init_rx+mod->init_size_rx;
75772 + else if (within_module_init_rw(addr, mod))
75773 + nextval = (unsigned long)mod->module_init_rw+mod->init_size_rw;
75774 + else if (within_module_core_rx(addr, mod))
75775 + nextval = (unsigned long)mod->module_core_rx+mod->core_size_rx;
75776 + else if (within_module_core_rw(addr, mod))
75777 + nextval = (unsigned long)mod->module_core_rw+mod->core_size_rw;
75778 else
75779 - nextval = (unsigned long)mod->module_core+mod->core_text_size;
75780 + return NULL;
75781
75782 /* Scan for closest preceding symbol, and next symbol. (ELF
75783 starts real symbols at 1). */
75784 @@ -3621,7 +3758,7 @@ static int m_show(struct seq_file *m, void *p)
75785 return 0;
75786
75787 seq_printf(m, "%s %u",
75788 - mod->name, mod->init_size + mod->core_size);
75789 + mod->name, mod->init_size_rx + mod->init_size_rw + mod->core_size_rx + mod->core_size_rw);
75790 print_unload_info(m, mod);
75791
75792 /* Informative for users. */
75793 @@ -3630,7 +3767,7 @@ static int m_show(struct seq_file *m, void *p)
75794 mod->state == MODULE_STATE_COMING ? "Loading":
75795 "Live");
75796 /* Used by oprofile and other similar tools. */
75797 - seq_printf(m, " 0x%pK", mod->module_core);
75798 + seq_printf(m, " 0x%pK 0x%pK", mod->module_core_rx, mod->module_core_rw);
75799
75800 /* Taints info */
75801 if (mod->taints)
75802 @@ -3666,7 +3803,17 @@ static const struct file_operations proc_modules_operations = {
75803
75804 static int __init proc_modules_init(void)
75805 {
75806 +#ifndef CONFIG_GRKERNSEC_HIDESYM
75807 +#ifdef CONFIG_GRKERNSEC_PROC_USER
75808 + proc_create("modules", S_IRUSR, NULL, &proc_modules_operations);
75809 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
75810 + proc_create("modules", S_IRUSR | S_IRGRP, NULL, &proc_modules_operations);
75811 +#else
75812 proc_create("modules", 0, NULL, &proc_modules_operations);
75813 +#endif
75814 +#else
75815 + proc_create("modules", S_IRUSR, NULL, &proc_modules_operations);
75816 +#endif
75817 return 0;
75818 }
75819 module_init(proc_modules_init);
75820 @@ -3727,14 +3874,14 @@ struct module *__module_address(unsigned long addr)
75821 {
75822 struct module *mod;
75823
75824 - if (addr < module_addr_min || addr > module_addr_max)
75825 + if ((addr < module_addr_min_rx || addr > module_addr_max_rx) &&
75826 + (addr < module_addr_min_rw || addr > module_addr_max_rw))
75827 return NULL;
75828
75829 list_for_each_entry_rcu(mod, &modules, list) {
75830 if (mod->state == MODULE_STATE_UNFORMED)
75831 continue;
75832 - if (within_module_core(addr, mod)
75833 - || within_module_init(addr, mod))
75834 + if (within_module_init(addr, mod) || within_module_core(addr, mod))
75835 return mod;
75836 }
75837 return NULL;
75838 @@ -3769,11 +3916,20 @@ bool is_module_text_address(unsigned long addr)
75839 */
75840 struct module *__module_text_address(unsigned long addr)
75841 {
75842 - struct module *mod = __module_address(addr);
75843 + struct module *mod;
75844 +
75845 +#ifdef CONFIG_X86_32
75846 + addr = ktla_ktva(addr);
75847 +#endif
75848 +
75849 + if (addr < module_addr_min_rx || addr > module_addr_max_rx)
75850 + return NULL;
75851 +
75852 + mod = __module_address(addr);
75853 +
75854 if (mod) {
75855 /* Make sure it's within the text section. */
75856 - if (!within(addr, mod->module_init, mod->init_text_size)
75857 - && !within(addr, mod->module_core, mod->core_text_size))
75858 + if (!within_module_init_rx(addr, mod) && !within_module_core_rx(addr, mod))
75859 mod = NULL;
75860 }
75861 return mod;
75862 diff --git a/kernel/mutex-debug.c b/kernel/mutex-debug.c
75863 index 7e3443f..b2a1e6b 100644
75864 --- a/kernel/mutex-debug.c
75865 +++ b/kernel/mutex-debug.c
75866 @@ -49,21 +49,21 @@ void debug_mutex_free_waiter(struct mutex_waiter *waiter)
75867 }
75868
75869 void debug_mutex_add_waiter(struct mutex *lock, struct mutex_waiter *waiter,
75870 - struct thread_info *ti)
75871 + struct task_struct *task)
75872 {
75873 SMP_DEBUG_LOCKS_WARN_ON(!spin_is_locked(&lock->wait_lock));
75874
75875 /* Mark the current thread as blocked on the lock: */
75876 - ti->task->blocked_on = waiter;
75877 + task->blocked_on = waiter;
75878 }
75879
75880 void mutex_remove_waiter(struct mutex *lock, struct mutex_waiter *waiter,
75881 - struct thread_info *ti)
75882 + struct task_struct *task)
75883 {
75884 DEBUG_LOCKS_WARN_ON(list_empty(&waiter->list));
75885 - DEBUG_LOCKS_WARN_ON(waiter->task != ti->task);
75886 - DEBUG_LOCKS_WARN_ON(ti->task->blocked_on != waiter);
75887 - ti->task->blocked_on = NULL;
75888 + DEBUG_LOCKS_WARN_ON(waiter->task != task);
75889 + DEBUG_LOCKS_WARN_ON(task->blocked_on != waiter);
75890 + task->blocked_on = NULL;
75891
75892 list_del_init(&waiter->list);
75893 waiter->task = NULL;
75894 diff --git a/kernel/mutex-debug.h b/kernel/mutex-debug.h
75895 index 0799fd3..d06ae3b 100644
75896 --- a/kernel/mutex-debug.h
75897 +++ b/kernel/mutex-debug.h
75898 @@ -20,9 +20,9 @@ extern void debug_mutex_wake_waiter(struct mutex *lock,
75899 extern void debug_mutex_free_waiter(struct mutex_waiter *waiter);
75900 extern void debug_mutex_add_waiter(struct mutex *lock,
75901 struct mutex_waiter *waiter,
75902 - struct thread_info *ti);
75903 + struct task_struct *task);
75904 extern void mutex_remove_waiter(struct mutex *lock, struct mutex_waiter *waiter,
75905 - struct thread_info *ti);
75906 + struct task_struct *task);
75907 extern void debug_mutex_unlock(struct mutex *lock);
75908 extern void debug_mutex_init(struct mutex *lock, const char *name,
75909 struct lock_class_key *key);
75910 diff --git a/kernel/mutex.c b/kernel/mutex.c
75911 index a307cc9..27fd2e9 100644
75912 --- a/kernel/mutex.c
75913 +++ b/kernel/mutex.c
75914 @@ -198,7 +198,7 @@ __mutex_lock_common(struct mutex *lock, long state, unsigned int subclass,
75915 spin_lock_mutex(&lock->wait_lock, flags);
75916
75917 debug_mutex_lock_common(lock, &waiter);
75918 - debug_mutex_add_waiter(lock, &waiter, task_thread_info(task));
75919 + debug_mutex_add_waiter(lock, &waiter, task);
75920
75921 /* add waiting tasks to the end of the waitqueue (FIFO): */
75922 list_add_tail(&waiter.list, &lock->wait_list);
75923 @@ -227,8 +227,7 @@ __mutex_lock_common(struct mutex *lock, long state, unsigned int subclass,
75924 * TASK_UNINTERRUPTIBLE case.)
75925 */
75926 if (unlikely(signal_pending_state(state, task))) {
75927 - mutex_remove_waiter(lock, &waiter,
75928 - task_thread_info(task));
75929 + mutex_remove_waiter(lock, &waiter, task);
75930 mutex_release(&lock->dep_map, 1, ip);
75931 spin_unlock_mutex(&lock->wait_lock, flags);
75932
75933 @@ -247,7 +246,7 @@ __mutex_lock_common(struct mutex *lock, long state, unsigned int subclass,
75934 done:
75935 lock_acquired(&lock->dep_map, ip);
75936 /* got the lock - rejoice! */
75937 - mutex_remove_waiter(lock, &waiter, current_thread_info());
75938 + mutex_remove_waiter(lock, &waiter, task);
75939 mutex_set_owner(lock);
75940
75941 /* set it to 0 if there are no waiters left: */
75942 diff --git a/kernel/notifier.c b/kernel/notifier.c
75943 index 2d5cc4c..d9ea600 100644
75944 --- a/kernel/notifier.c
75945 +++ b/kernel/notifier.c
75946 @@ -5,6 +5,7 @@
75947 #include <linux/rcupdate.h>
75948 #include <linux/vmalloc.h>
75949 #include <linux/reboot.h>
75950 +#include <linux/mm.h>
75951
75952 /*
75953 * Notifier list for kernel code which wants to be called
75954 @@ -24,10 +25,12 @@ static int notifier_chain_register(struct notifier_block **nl,
75955 while ((*nl) != NULL) {
75956 if (n->priority > (*nl)->priority)
75957 break;
75958 - nl = &((*nl)->next);
75959 + nl = (struct notifier_block **)&((*nl)->next);
75960 }
75961 - n->next = *nl;
75962 + pax_open_kernel();
75963 + *(const void **)&n->next = *nl;
75964 rcu_assign_pointer(*nl, n);
75965 + pax_close_kernel();
75966 return 0;
75967 }
75968
75969 @@ -39,10 +42,12 @@ static int notifier_chain_cond_register(struct notifier_block **nl,
75970 return 0;
75971 if (n->priority > (*nl)->priority)
75972 break;
75973 - nl = &((*nl)->next);
75974 + nl = (struct notifier_block **)&((*nl)->next);
75975 }
75976 - n->next = *nl;
75977 + pax_open_kernel();
75978 + *(const void **)&n->next = *nl;
75979 rcu_assign_pointer(*nl, n);
75980 + pax_close_kernel();
75981 return 0;
75982 }
75983
75984 @@ -51,10 +56,12 @@ static int notifier_chain_unregister(struct notifier_block **nl,
75985 {
75986 while ((*nl) != NULL) {
75987 if ((*nl) == n) {
75988 + pax_open_kernel();
75989 rcu_assign_pointer(*nl, n->next);
75990 + pax_close_kernel();
75991 return 0;
75992 }
75993 - nl = &((*nl)->next);
75994 + nl = (struct notifier_block **)&((*nl)->next);
75995 }
75996 return -ENOENT;
75997 }
75998 diff --git a/kernel/panic.c b/kernel/panic.c
75999 index e1b2822..5edc1d9 100644
76000 --- a/kernel/panic.c
76001 +++ b/kernel/panic.c
76002 @@ -410,7 +410,7 @@ static void warn_slowpath_common(const char *file, int line, void *caller,
76003 const char *board;
76004
76005 printk(KERN_WARNING "------------[ cut here ]------------\n");
76006 - printk(KERN_WARNING "WARNING: at %s:%d %pS()\n", file, line, caller);
76007 + printk(KERN_WARNING "WARNING: at %s:%d %pA()\n", file, line, caller);
76008 board = dmi_get_system_info(DMI_PRODUCT_NAME);
76009 if (board)
76010 printk(KERN_WARNING "Hardware name: %s\n", board);
76011 @@ -465,7 +465,8 @@ EXPORT_SYMBOL(warn_slowpath_null);
76012 */
76013 void __stack_chk_fail(void)
76014 {
76015 - panic("stack-protector: Kernel stack is corrupted in: %p\n",
76016 + dump_stack();
76017 + panic("stack-protector: Kernel stack is corrupted in: %pA\n",
76018 __builtin_return_address(0));
76019 }
76020 EXPORT_SYMBOL(__stack_chk_fail);
76021 diff --git a/kernel/pid.c b/kernel/pid.c
76022 index f2c6a68..4922d97 100644
76023 --- a/kernel/pid.c
76024 +++ b/kernel/pid.c
76025 @@ -33,6 +33,7 @@
76026 #include <linux/rculist.h>
76027 #include <linux/bootmem.h>
76028 #include <linux/hash.h>
76029 +#include <linux/security.h>
76030 #include <linux/pid_namespace.h>
76031 #include <linux/init_task.h>
76032 #include <linux/syscalls.h>
76033 @@ -46,7 +47,7 @@ struct pid init_struct_pid = INIT_STRUCT_PID;
76034
76035 int pid_max = PID_MAX_DEFAULT;
76036
76037 -#define RESERVED_PIDS 300
76038 +#define RESERVED_PIDS 500
76039
76040 int pid_max_min = RESERVED_PIDS + 1;
76041 int pid_max_max = PID_MAX_LIMIT;
76042 @@ -441,10 +442,18 @@ EXPORT_SYMBOL(pid_task);
76043 */
76044 struct task_struct *find_task_by_pid_ns(pid_t nr, struct pid_namespace *ns)
76045 {
76046 + struct task_struct *task;
76047 +
76048 rcu_lockdep_assert(rcu_read_lock_held(),
76049 "find_task_by_pid_ns() needs rcu_read_lock()"
76050 " protection");
76051 - return pid_task(find_pid_ns(nr, ns), PIDTYPE_PID);
76052 +
76053 + task = pid_task(find_pid_ns(nr, ns), PIDTYPE_PID);
76054 +
76055 + if (gr_pid_is_chrooted(task))
76056 + return NULL;
76057 +
76058 + return task;
76059 }
76060
76061 struct task_struct *find_task_by_vpid(pid_t vnr)
76062 @@ -452,6 +461,14 @@ struct task_struct *find_task_by_vpid(pid_t vnr)
76063 return find_task_by_pid_ns(vnr, task_active_pid_ns(current));
76064 }
76065
76066 +struct task_struct *find_task_by_vpid_unrestricted(pid_t vnr)
76067 +{
76068 + rcu_lockdep_assert(rcu_read_lock_held(),
76069 + "find_task_by_pid_ns() needs rcu_read_lock()"
76070 + " protection");
76071 + return pid_task(find_pid_ns(vnr, task_active_pid_ns(current)), PIDTYPE_PID);
76072 +}
76073 +
76074 struct pid *get_task_pid(struct task_struct *task, enum pid_type type)
76075 {
76076 struct pid *pid;
76077 diff --git a/kernel/pid_namespace.c b/kernel/pid_namespace.c
76078 index c1c3dc1..bbeaf31 100644
76079 --- a/kernel/pid_namespace.c
76080 +++ b/kernel/pid_namespace.c
76081 @@ -248,7 +248,7 @@ static int pid_ns_ctl_handler(struct ctl_table *table, int write,
76082 void __user *buffer, size_t *lenp, loff_t *ppos)
76083 {
76084 struct pid_namespace *pid_ns = task_active_pid_ns(current);
76085 - struct ctl_table tmp = *table;
76086 + ctl_table_no_const tmp = *table;
76087
76088 if (write && !ns_capable(pid_ns->user_ns, CAP_SYS_ADMIN))
76089 return -EPERM;
76090 diff --git a/kernel/posix-cpu-timers.c b/kernel/posix-cpu-timers.c
76091 index 942ca27..111e609 100644
76092 --- a/kernel/posix-cpu-timers.c
76093 +++ b/kernel/posix-cpu-timers.c
76094 @@ -1576,14 +1576,14 @@ struct k_clock clock_posix_cpu = {
76095
76096 static __init int init_posix_cpu_timers(void)
76097 {
76098 - struct k_clock process = {
76099 + static struct k_clock process = {
76100 .clock_getres = process_cpu_clock_getres,
76101 .clock_get = process_cpu_clock_get,
76102 .timer_create = process_cpu_timer_create,
76103 .nsleep = process_cpu_nsleep,
76104 .nsleep_restart = process_cpu_nsleep_restart,
76105 };
76106 - struct k_clock thread = {
76107 + static struct k_clock thread = {
76108 .clock_getres = thread_cpu_clock_getres,
76109 .clock_get = thread_cpu_clock_get,
76110 .timer_create = thread_cpu_timer_create,
76111 diff --git a/kernel/posix-timers.c b/kernel/posix-timers.c
76112 index e885be1..380fe76 100644
76113 --- a/kernel/posix-timers.c
76114 +++ b/kernel/posix-timers.c
76115 @@ -43,6 +43,7 @@
76116 #include <linux/idr.h>
76117 #include <linux/posix-clock.h>
76118 #include <linux/posix-timers.h>
76119 +#include <linux/grsecurity.h>
76120 #include <linux/syscalls.h>
76121 #include <linux/wait.h>
76122 #include <linux/workqueue.h>
76123 @@ -129,7 +130,7 @@ static DEFINE_SPINLOCK(idr_lock);
76124 * which we beg off on and pass to do_sys_settimeofday().
76125 */
76126
76127 -static struct k_clock posix_clocks[MAX_CLOCKS];
76128 +static struct k_clock *posix_clocks[MAX_CLOCKS];
76129
76130 /*
76131 * These ones are defined below.
76132 @@ -227,7 +228,7 @@ static int posix_get_boottime(const clockid_t which_clock, struct timespec *tp)
76133 */
76134 static __init int init_posix_timers(void)
76135 {
76136 - struct k_clock clock_realtime = {
76137 + static struct k_clock clock_realtime = {
76138 .clock_getres = hrtimer_get_res,
76139 .clock_get = posix_clock_realtime_get,
76140 .clock_set = posix_clock_realtime_set,
76141 @@ -239,7 +240,7 @@ static __init int init_posix_timers(void)
76142 .timer_get = common_timer_get,
76143 .timer_del = common_timer_del,
76144 };
76145 - struct k_clock clock_monotonic = {
76146 + static struct k_clock clock_monotonic = {
76147 .clock_getres = hrtimer_get_res,
76148 .clock_get = posix_ktime_get_ts,
76149 .nsleep = common_nsleep,
76150 @@ -249,19 +250,19 @@ static __init int init_posix_timers(void)
76151 .timer_get = common_timer_get,
76152 .timer_del = common_timer_del,
76153 };
76154 - struct k_clock clock_monotonic_raw = {
76155 + static struct k_clock clock_monotonic_raw = {
76156 .clock_getres = hrtimer_get_res,
76157 .clock_get = posix_get_monotonic_raw,
76158 };
76159 - struct k_clock clock_realtime_coarse = {
76160 + static struct k_clock clock_realtime_coarse = {
76161 .clock_getres = posix_get_coarse_res,
76162 .clock_get = posix_get_realtime_coarse,
76163 };
76164 - struct k_clock clock_monotonic_coarse = {
76165 + static struct k_clock clock_monotonic_coarse = {
76166 .clock_getres = posix_get_coarse_res,
76167 .clock_get = posix_get_monotonic_coarse,
76168 };
76169 - struct k_clock clock_boottime = {
76170 + static struct k_clock clock_boottime = {
76171 .clock_getres = hrtimer_get_res,
76172 .clock_get = posix_get_boottime,
76173 .nsleep = common_nsleep,
76174 @@ -473,7 +474,7 @@ void posix_timers_register_clock(const clockid_t clock_id,
76175 return;
76176 }
76177
76178 - posix_clocks[clock_id] = *new_clock;
76179 + posix_clocks[clock_id] = new_clock;
76180 }
76181 EXPORT_SYMBOL_GPL(posix_timers_register_clock);
76182
76183 @@ -519,9 +520,9 @@ static struct k_clock *clockid_to_kclock(const clockid_t id)
76184 return (id & CLOCKFD_MASK) == CLOCKFD ?
76185 &clock_posix_dynamic : &clock_posix_cpu;
76186
76187 - if (id >= MAX_CLOCKS || !posix_clocks[id].clock_getres)
76188 + if (id >= MAX_CLOCKS || !posix_clocks[id] || !posix_clocks[id]->clock_getres)
76189 return NULL;
76190 - return &posix_clocks[id];
76191 + return posix_clocks[id];
76192 }
76193
76194 static int common_timer_create(struct k_itimer *new_timer)
76195 @@ -966,6 +967,13 @@ SYSCALL_DEFINE2(clock_settime, const clockid_t, which_clock,
76196 if (copy_from_user(&new_tp, tp, sizeof (*tp)))
76197 return -EFAULT;
76198
76199 + /* only the CLOCK_REALTIME clock can be set, all other clocks
76200 + have their clock_set fptr set to a nosettime dummy function
76201 + CLOCK_REALTIME has a NULL clock_set fptr which causes it to
76202 + call common_clock_set, which calls do_sys_settimeofday, which
76203 + we hook
76204 + */
76205 +
76206 return kc->clock_set(which_clock, &new_tp);
76207 }
76208
76209 diff --git a/kernel/power/process.c b/kernel/power/process.c
76210 index d5a258b..4271191 100644
76211 --- a/kernel/power/process.c
76212 +++ b/kernel/power/process.c
76213 @@ -33,6 +33,7 @@ static int try_to_freeze_tasks(bool user_only)
76214 u64 elapsed_csecs64;
76215 unsigned int elapsed_csecs;
76216 bool wakeup = false;
76217 + bool timedout = false;
76218
76219 do_gettimeofday(&start);
76220
76221 @@ -43,13 +44,20 @@ static int try_to_freeze_tasks(bool user_only)
76222
76223 while (true) {
76224 todo = 0;
76225 + if (time_after(jiffies, end_time))
76226 + timedout = true;
76227 read_lock(&tasklist_lock);
76228 do_each_thread(g, p) {
76229 if (p == current || !freeze_task(p))
76230 continue;
76231
76232 - if (!freezer_should_skip(p))
76233 + if (!freezer_should_skip(p)) {
76234 todo++;
76235 + if (timedout) {
76236 + printk(KERN_ERR "Task refusing to freeze:\n");
76237 + sched_show_task(p);
76238 + }
76239 + }
76240 } while_each_thread(g, p);
76241 read_unlock(&tasklist_lock);
76242
76243 @@ -58,7 +66,7 @@ static int try_to_freeze_tasks(bool user_only)
76244 todo += wq_busy;
76245 }
76246
76247 - if (!todo || time_after(jiffies, end_time))
76248 + if (!todo || timedout)
76249 break;
76250
76251 if (pm_wakeup_pending()) {
76252 diff --git a/kernel/printk.c b/kernel/printk.c
76253 index 267ce78..2487112 100644
76254 --- a/kernel/printk.c
76255 +++ b/kernel/printk.c
76256 @@ -609,11 +609,17 @@ static unsigned int devkmsg_poll(struct file *file, poll_table *wait)
76257 return ret;
76258 }
76259
76260 +static int check_syslog_permissions(int type, bool from_file);
76261 +
76262 static int devkmsg_open(struct inode *inode, struct file *file)
76263 {
76264 struct devkmsg_user *user;
76265 int err;
76266
76267 + err = check_syslog_permissions(SYSLOG_ACTION_OPEN, SYSLOG_FROM_FILE);
76268 + if (err)
76269 + return err;
76270 +
76271 /* write-only does not need any file context */
76272 if ((file->f_flags & O_ACCMODE) == O_WRONLY)
76273 return 0;
76274 @@ -822,7 +828,7 @@ static int syslog_action_restricted(int type)
76275 if (dmesg_restrict)
76276 return 1;
76277 /* Unless restricted, we allow "read all" and "get buffer size" for everybody */
76278 - return type != SYSLOG_ACTION_READ_ALL && type != SYSLOG_ACTION_SIZE_BUFFER;
76279 + return type != SYSLOG_ACTION_OPEN && type != SYSLOG_ACTION_READ_ALL && type != SYSLOG_ACTION_SIZE_BUFFER;
76280 }
76281
76282 static int check_syslog_permissions(int type, bool from_file)
76283 @@ -834,6 +840,11 @@ static int check_syslog_permissions(int type, bool from_file)
76284 if (from_file && type != SYSLOG_ACTION_OPEN)
76285 return 0;
76286
76287 +#ifdef CONFIG_GRKERNSEC_DMESG
76288 + if (grsec_enable_dmesg && !capable(CAP_SYSLOG) && !capable_nolog(CAP_SYS_ADMIN))
76289 + return -EPERM;
76290 +#endif
76291 +
76292 if (syslog_action_restricted(type)) {
76293 if (capable(CAP_SYSLOG))
76294 return 0;
76295 diff --git a/kernel/profile.c b/kernel/profile.c
76296 index 1f39181..86093471 100644
76297 --- a/kernel/profile.c
76298 +++ b/kernel/profile.c
76299 @@ -40,7 +40,7 @@ struct profile_hit {
76300 /* Oprofile timer tick hook */
76301 static int (*timer_hook)(struct pt_regs *) __read_mostly;
76302
76303 -static atomic_t *prof_buffer;
76304 +static atomic_unchecked_t *prof_buffer;
76305 static unsigned long prof_len, prof_shift;
76306
76307 int prof_on __read_mostly;
76308 @@ -282,7 +282,7 @@ static void profile_flip_buffers(void)
76309 hits[i].pc = 0;
76310 continue;
76311 }
76312 - atomic_add(hits[i].hits, &prof_buffer[hits[i].pc]);
76313 + atomic_add_unchecked(hits[i].hits, &prof_buffer[hits[i].pc]);
76314 hits[i].hits = hits[i].pc = 0;
76315 }
76316 }
76317 @@ -343,9 +343,9 @@ static void do_profile_hits(int type, void *__pc, unsigned int nr_hits)
76318 * Add the current hit(s) and flush the write-queue out
76319 * to the global buffer:
76320 */
76321 - atomic_add(nr_hits, &prof_buffer[pc]);
76322 + atomic_add_unchecked(nr_hits, &prof_buffer[pc]);
76323 for (i = 0; i < NR_PROFILE_HIT; ++i) {
76324 - atomic_add(hits[i].hits, &prof_buffer[hits[i].pc]);
76325 + atomic_add_unchecked(hits[i].hits, &prof_buffer[hits[i].pc]);
76326 hits[i].pc = hits[i].hits = 0;
76327 }
76328 out:
76329 @@ -420,7 +420,7 @@ static void do_profile_hits(int type, void *__pc, unsigned int nr_hits)
76330 {
76331 unsigned long pc;
76332 pc = ((unsigned long)__pc - (unsigned long)_stext) >> prof_shift;
76333 - atomic_add(nr_hits, &prof_buffer[min(pc, prof_len - 1)]);
76334 + atomic_add_unchecked(nr_hits, &prof_buffer[min(pc, prof_len - 1)]);
76335 }
76336 #endif /* !CONFIG_SMP */
76337
76338 @@ -518,7 +518,7 @@ read_profile(struct file *file, char __user *buf, size_t count, loff_t *ppos)
76339 return -EFAULT;
76340 buf++; p++; count--; read++;
76341 }
76342 - pnt = (char *)prof_buffer + p - sizeof(atomic_t);
76343 + pnt = (char *)prof_buffer + p - sizeof(atomic_unchecked_t);
76344 if (copy_to_user(buf, (void *)pnt, count))
76345 return -EFAULT;
76346 read += count;
76347 @@ -549,7 +549,7 @@ static ssize_t write_profile(struct file *file, const char __user *buf,
76348 }
76349 #endif
76350 profile_discard_flip_buffers();
76351 - memset(prof_buffer, 0, prof_len * sizeof(atomic_t));
76352 + memset(prof_buffer, 0, prof_len * sizeof(atomic_unchecked_t));
76353 return count;
76354 }
76355
76356 diff --git a/kernel/ptrace.c b/kernel/ptrace.c
76357 index 6cbeaae..cfe7ff0 100644
76358 --- a/kernel/ptrace.c
76359 +++ b/kernel/ptrace.c
76360 @@ -324,7 +324,7 @@ static int ptrace_attach(struct task_struct *task, long request,
76361 if (seize)
76362 flags |= PT_SEIZED;
76363 rcu_read_lock();
76364 - if (ns_capable(__task_cred(task)->user_ns, CAP_SYS_PTRACE))
76365 + if (ns_capable_nolog(__task_cred(task)->user_ns, CAP_SYS_PTRACE))
76366 flags |= PT_PTRACE_CAP;
76367 rcu_read_unlock();
76368 task->ptrace = flags;
76369 @@ -535,7 +535,7 @@ int ptrace_readdata(struct task_struct *tsk, unsigned long src, char __user *dst
76370 break;
76371 return -EIO;
76372 }
76373 - if (copy_to_user(dst, buf, retval))
76374 + if (retval > sizeof(buf) || copy_to_user(dst, buf, retval))
76375 return -EFAULT;
76376 copied += retval;
76377 src += retval;
76378 @@ -720,7 +720,7 @@ int ptrace_request(struct task_struct *child, long request,
76379 bool seized = child->ptrace & PT_SEIZED;
76380 int ret = -EIO;
76381 siginfo_t siginfo, *si;
76382 - void __user *datavp = (void __user *) data;
76383 + void __user *datavp = (__force void __user *) data;
76384 unsigned long __user *datalp = datavp;
76385 unsigned long flags;
76386
76387 @@ -922,14 +922,21 @@ SYSCALL_DEFINE4(ptrace, long, request, long, pid, unsigned long, addr,
76388 goto out;
76389 }
76390
76391 + if (gr_handle_ptrace(child, request)) {
76392 + ret = -EPERM;
76393 + goto out_put_task_struct;
76394 + }
76395 +
76396 if (request == PTRACE_ATTACH || request == PTRACE_SEIZE) {
76397 ret = ptrace_attach(child, request, addr, data);
76398 /*
76399 * Some architectures need to do book-keeping after
76400 * a ptrace attach.
76401 */
76402 - if (!ret)
76403 + if (!ret) {
76404 arch_ptrace_attach(child);
76405 + gr_audit_ptrace(child);
76406 + }
76407 goto out_put_task_struct;
76408 }
76409
76410 @@ -957,7 +964,7 @@ int generic_ptrace_peekdata(struct task_struct *tsk, unsigned long addr,
76411 copied = access_process_vm(tsk, addr, &tmp, sizeof(tmp), 0);
76412 if (copied != sizeof(tmp))
76413 return -EIO;
76414 - return put_user(tmp, (unsigned long __user *)data);
76415 + return put_user(tmp, (__force unsigned long __user *)data);
76416 }
76417
76418 int generic_ptrace_pokedata(struct task_struct *tsk, unsigned long addr,
76419 @@ -1051,7 +1058,7 @@ int compat_ptrace_request(struct task_struct *child, compat_long_t request,
76420 }
76421
76422 asmlinkage long compat_sys_ptrace(compat_long_t request, compat_long_t pid,
76423 - compat_long_t addr, compat_long_t data)
76424 + compat_ulong_t addr, compat_ulong_t data)
76425 {
76426 struct task_struct *child;
76427 long ret;
76428 @@ -1067,14 +1074,21 @@ asmlinkage long compat_sys_ptrace(compat_long_t request, compat_long_t pid,
76429 goto out;
76430 }
76431
76432 + if (gr_handle_ptrace(child, request)) {
76433 + ret = -EPERM;
76434 + goto out_put_task_struct;
76435 + }
76436 +
76437 if (request == PTRACE_ATTACH || request == PTRACE_SEIZE) {
76438 ret = ptrace_attach(child, request, addr, data);
76439 /*
76440 * Some architectures need to do book-keeping after
76441 * a ptrace attach.
76442 */
76443 - if (!ret)
76444 + if (!ret) {
76445 arch_ptrace_attach(child);
76446 + gr_audit_ptrace(child);
76447 + }
76448 goto out_put_task_struct;
76449 }
76450
76451 diff --git a/kernel/rcutiny.c b/kernel/rcutiny.c
76452 index e7dce58..ad0d7b7 100644
76453 --- a/kernel/rcutiny.c
76454 +++ b/kernel/rcutiny.c
76455 @@ -46,7 +46,7 @@
76456 struct rcu_ctrlblk;
76457 static void invoke_rcu_callbacks(void);
76458 static void __rcu_process_callbacks(struct rcu_ctrlblk *rcp);
76459 -static void rcu_process_callbacks(struct softirq_action *unused);
76460 +static void rcu_process_callbacks(void);
76461 static void __call_rcu(struct rcu_head *head,
76462 void (*func)(struct rcu_head *rcu),
76463 struct rcu_ctrlblk *rcp);
76464 @@ -310,7 +310,7 @@ static void __rcu_process_callbacks(struct rcu_ctrlblk *rcp)
76465 rcu_is_callbacks_kthread()));
76466 }
76467
76468 -static void rcu_process_callbacks(struct softirq_action *unused)
76469 +static void rcu_process_callbacks(void)
76470 {
76471 __rcu_process_callbacks(&rcu_sched_ctrlblk);
76472 __rcu_process_callbacks(&rcu_bh_ctrlblk);
76473 diff --git a/kernel/rcutiny_plugin.h b/kernel/rcutiny_plugin.h
76474 index f85016a..91cb03b 100644
76475 --- a/kernel/rcutiny_plugin.h
76476 +++ b/kernel/rcutiny_plugin.h
76477 @@ -896,7 +896,7 @@ static int rcu_kthread(void *arg)
76478 have_rcu_kthread_work = morework;
76479 local_irq_restore(flags);
76480 if (work)
76481 - rcu_process_callbacks(NULL);
76482 + rcu_process_callbacks();
76483 schedule_timeout_interruptible(1); /* Leave CPU for others. */
76484 }
76485
76486 diff --git a/kernel/rcutorture.c b/kernel/rcutorture.c
76487 index 31dea01..ad91ffb 100644
76488 --- a/kernel/rcutorture.c
76489 +++ b/kernel/rcutorture.c
76490 @@ -163,12 +163,12 @@ static DEFINE_PER_CPU(long [RCU_TORTURE_PIPE_LEN + 1], rcu_torture_count) =
76491 { 0 };
76492 static DEFINE_PER_CPU(long [RCU_TORTURE_PIPE_LEN + 1], rcu_torture_batch) =
76493 { 0 };
76494 -static atomic_t rcu_torture_wcount[RCU_TORTURE_PIPE_LEN + 1];
76495 -static atomic_t n_rcu_torture_alloc;
76496 -static atomic_t n_rcu_torture_alloc_fail;
76497 -static atomic_t n_rcu_torture_free;
76498 -static atomic_t n_rcu_torture_mberror;
76499 -static atomic_t n_rcu_torture_error;
76500 +static atomic_unchecked_t rcu_torture_wcount[RCU_TORTURE_PIPE_LEN + 1];
76501 +static atomic_unchecked_t n_rcu_torture_alloc;
76502 +static atomic_unchecked_t n_rcu_torture_alloc_fail;
76503 +static atomic_unchecked_t n_rcu_torture_free;
76504 +static atomic_unchecked_t n_rcu_torture_mberror;
76505 +static atomic_unchecked_t n_rcu_torture_error;
76506 static long n_rcu_torture_barrier_error;
76507 static long n_rcu_torture_boost_ktrerror;
76508 static long n_rcu_torture_boost_rterror;
76509 @@ -272,11 +272,11 @@ rcu_torture_alloc(void)
76510
76511 spin_lock_bh(&rcu_torture_lock);
76512 if (list_empty(&rcu_torture_freelist)) {
76513 - atomic_inc(&n_rcu_torture_alloc_fail);
76514 + atomic_inc_unchecked(&n_rcu_torture_alloc_fail);
76515 spin_unlock_bh(&rcu_torture_lock);
76516 return NULL;
76517 }
76518 - atomic_inc(&n_rcu_torture_alloc);
76519 + atomic_inc_unchecked(&n_rcu_torture_alloc);
76520 p = rcu_torture_freelist.next;
76521 list_del_init(p);
76522 spin_unlock_bh(&rcu_torture_lock);
76523 @@ -289,7 +289,7 @@ rcu_torture_alloc(void)
76524 static void
76525 rcu_torture_free(struct rcu_torture *p)
76526 {
76527 - atomic_inc(&n_rcu_torture_free);
76528 + atomic_inc_unchecked(&n_rcu_torture_free);
76529 spin_lock_bh(&rcu_torture_lock);
76530 list_add_tail(&p->rtort_free, &rcu_torture_freelist);
76531 spin_unlock_bh(&rcu_torture_lock);
76532 @@ -409,7 +409,7 @@ rcu_torture_cb(struct rcu_head *p)
76533 i = rp->rtort_pipe_count;
76534 if (i > RCU_TORTURE_PIPE_LEN)
76535 i = RCU_TORTURE_PIPE_LEN;
76536 - atomic_inc(&rcu_torture_wcount[i]);
76537 + atomic_inc_unchecked(&rcu_torture_wcount[i]);
76538 if (++rp->rtort_pipe_count >= RCU_TORTURE_PIPE_LEN) {
76539 rp->rtort_mbtest = 0;
76540 rcu_torture_free(rp);
76541 @@ -457,7 +457,7 @@ static void rcu_sync_torture_deferred_free(struct rcu_torture *p)
76542 i = rp->rtort_pipe_count;
76543 if (i > RCU_TORTURE_PIPE_LEN)
76544 i = RCU_TORTURE_PIPE_LEN;
76545 - atomic_inc(&rcu_torture_wcount[i]);
76546 + atomic_inc_unchecked(&rcu_torture_wcount[i]);
76547 if (++rp->rtort_pipe_count >= RCU_TORTURE_PIPE_LEN) {
76548 rp->rtort_mbtest = 0;
76549 list_del(&rp->rtort_free);
76550 @@ -975,7 +975,7 @@ rcu_torture_writer(void *arg)
76551 i = old_rp->rtort_pipe_count;
76552 if (i > RCU_TORTURE_PIPE_LEN)
76553 i = RCU_TORTURE_PIPE_LEN;
76554 - atomic_inc(&rcu_torture_wcount[i]);
76555 + atomic_inc_unchecked(&rcu_torture_wcount[i]);
76556 old_rp->rtort_pipe_count++;
76557 cur_ops->deferred_free(old_rp);
76558 }
76559 @@ -1060,7 +1060,7 @@ static void rcu_torture_timer(unsigned long unused)
76560 }
76561 do_trace_rcu_torture_read(cur_ops->name, &p->rtort_rcu);
76562 if (p->rtort_mbtest == 0)
76563 - atomic_inc(&n_rcu_torture_mberror);
76564 + atomic_inc_unchecked(&n_rcu_torture_mberror);
76565 spin_lock(&rand_lock);
76566 cur_ops->read_delay(&rand);
76567 n_rcu_torture_timers++;
76568 @@ -1124,7 +1124,7 @@ rcu_torture_reader(void *arg)
76569 }
76570 do_trace_rcu_torture_read(cur_ops->name, &p->rtort_rcu);
76571 if (p->rtort_mbtest == 0)
76572 - atomic_inc(&n_rcu_torture_mberror);
76573 + atomic_inc_unchecked(&n_rcu_torture_mberror);
76574 cur_ops->read_delay(&rand);
76575 preempt_disable();
76576 pipe_count = p->rtort_pipe_count;
76577 @@ -1183,11 +1183,11 @@ rcu_torture_printk(char *page)
76578 rcu_torture_current,
76579 rcu_torture_current_version,
76580 list_empty(&rcu_torture_freelist),
76581 - atomic_read(&n_rcu_torture_alloc),
76582 - atomic_read(&n_rcu_torture_alloc_fail),
76583 - atomic_read(&n_rcu_torture_free));
76584 + atomic_read_unchecked(&n_rcu_torture_alloc),
76585 + atomic_read_unchecked(&n_rcu_torture_alloc_fail),
76586 + atomic_read_unchecked(&n_rcu_torture_free));
76587 cnt += sprintf(&page[cnt], "rtmbe: %d rtbke: %ld rtbre: %ld ",
76588 - atomic_read(&n_rcu_torture_mberror),
76589 + atomic_read_unchecked(&n_rcu_torture_mberror),
76590 n_rcu_torture_boost_ktrerror,
76591 n_rcu_torture_boost_rterror);
76592 cnt += sprintf(&page[cnt], "rtbf: %ld rtb: %ld nt: %ld ",
76593 @@ -1206,14 +1206,14 @@ rcu_torture_printk(char *page)
76594 n_barrier_attempts,
76595 n_rcu_torture_barrier_error);
76596 cnt += sprintf(&page[cnt], "\n%s%s ", torture_type, TORTURE_FLAG);
76597 - if (atomic_read(&n_rcu_torture_mberror) != 0 ||
76598 + if (atomic_read_unchecked(&n_rcu_torture_mberror) != 0 ||
76599 n_rcu_torture_barrier_error != 0 ||
76600 n_rcu_torture_boost_ktrerror != 0 ||
76601 n_rcu_torture_boost_rterror != 0 ||
76602 n_rcu_torture_boost_failure != 0 ||
76603 i > 1) {
76604 cnt += sprintf(&page[cnt], "!!! ");
76605 - atomic_inc(&n_rcu_torture_error);
76606 + atomic_inc_unchecked(&n_rcu_torture_error);
76607 WARN_ON_ONCE(1);
76608 }
76609 cnt += sprintf(&page[cnt], "Reader Pipe: ");
76610 @@ -1227,7 +1227,7 @@ rcu_torture_printk(char *page)
76611 cnt += sprintf(&page[cnt], "Free-Block Circulation: ");
76612 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++) {
76613 cnt += sprintf(&page[cnt], " %d",
76614 - atomic_read(&rcu_torture_wcount[i]));
76615 + atomic_read_unchecked(&rcu_torture_wcount[i]));
76616 }
76617 cnt += sprintf(&page[cnt], "\n");
76618 if (cur_ops->stats)
76619 @@ -1920,7 +1920,7 @@ rcu_torture_cleanup(void)
76620
76621 rcu_torture_stats_print(); /* -After- the stats thread is stopped! */
76622
76623 - if (atomic_read(&n_rcu_torture_error) || n_rcu_torture_barrier_error)
76624 + if (atomic_read_unchecked(&n_rcu_torture_error) || n_rcu_torture_barrier_error)
76625 rcu_torture_print_module_parms(cur_ops, "End of test: FAILURE");
76626 else if (n_online_successes != n_online_attempts ||
76627 n_offline_successes != n_offline_attempts)
76628 @@ -1989,18 +1989,18 @@ rcu_torture_init(void)
76629
76630 rcu_torture_current = NULL;
76631 rcu_torture_current_version = 0;
76632 - atomic_set(&n_rcu_torture_alloc, 0);
76633 - atomic_set(&n_rcu_torture_alloc_fail, 0);
76634 - atomic_set(&n_rcu_torture_free, 0);
76635 - atomic_set(&n_rcu_torture_mberror, 0);
76636 - atomic_set(&n_rcu_torture_error, 0);
76637 + atomic_set_unchecked(&n_rcu_torture_alloc, 0);
76638 + atomic_set_unchecked(&n_rcu_torture_alloc_fail, 0);
76639 + atomic_set_unchecked(&n_rcu_torture_free, 0);
76640 + atomic_set_unchecked(&n_rcu_torture_mberror, 0);
76641 + atomic_set_unchecked(&n_rcu_torture_error, 0);
76642 n_rcu_torture_barrier_error = 0;
76643 n_rcu_torture_boost_ktrerror = 0;
76644 n_rcu_torture_boost_rterror = 0;
76645 n_rcu_torture_boost_failure = 0;
76646 n_rcu_torture_boosts = 0;
76647 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++)
76648 - atomic_set(&rcu_torture_wcount[i], 0);
76649 + atomic_set_unchecked(&rcu_torture_wcount[i], 0);
76650 for_each_possible_cpu(cpu) {
76651 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++) {
76652 per_cpu(rcu_torture_count, cpu)[i] = 0;
76653 diff --git a/kernel/rcutree.c b/kernel/rcutree.c
76654 index e441b77..dd54f17 100644
76655 --- a/kernel/rcutree.c
76656 +++ b/kernel/rcutree.c
76657 @@ -349,9 +349,9 @@ static void rcu_eqs_enter_common(struct rcu_dynticks *rdtp, long long oldval,
76658 rcu_prepare_for_idle(smp_processor_id());
76659 /* CPUs seeing atomic_inc() must see prior RCU read-side crit sects */
76660 smp_mb__before_atomic_inc(); /* See above. */
76661 - atomic_inc(&rdtp->dynticks);
76662 + atomic_inc_unchecked(&rdtp->dynticks);
76663 smp_mb__after_atomic_inc(); /* Force ordering with next sojourn. */
76664 - WARN_ON_ONCE(atomic_read(&rdtp->dynticks) & 0x1);
76665 + WARN_ON_ONCE(atomic_read_unchecked(&rdtp->dynticks) & 0x1);
76666
76667 /*
76668 * It is illegal to enter an extended quiescent state while
76669 @@ -487,10 +487,10 @@ static void rcu_eqs_exit_common(struct rcu_dynticks *rdtp, long long oldval,
76670 int user)
76671 {
76672 smp_mb__before_atomic_inc(); /* Force ordering w/previous sojourn. */
76673 - atomic_inc(&rdtp->dynticks);
76674 + atomic_inc_unchecked(&rdtp->dynticks);
76675 /* CPUs seeing atomic_inc() must see later RCU read-side crit sects */
76676 smp_mb__after_atomic_inc(); /* See above. */
76677 - WARN_ON_ONCE(!(atomic_read(&rdtp->dynticks) & 0x1));
76678 + WARN_ON_ONCE(!(atomic_read_unchecked(&rdtp->dynticks) & 0x1));
76679 rcu_cleanup_after_idle(smp_processor_id());
76680 trace_rcu_dyntick("End", oldval, rdtp->dynticks_nesting);
76681 if (!user && !is_idle_task(current)) {
76682 @@ -629,14 +629,14 @@ void rcu_nmi_enter(void)
76683 struct rcu_dynticks *rdtp = &__get_cpu_var(rcu_dynticks);
76684
76685 if (rdtp->dynticks_nmi_nesting == 0 &&
76686 - (atomic_read(&rdtp->dynticks) & 0x1))
76687 + (atomic_read_unchecked(&rdtp->dynticks) & 0x1))
76688 return;
76689 rdtp->dynticks_nmi_nesting++;
76690 smp_mb__before_atomic_inc(); /* Force delay from prior write. */
76691 - atomic_inc(&rdtp->dynticks);
76692 + atomic_inc_unchecked(&rdtp->dynticks);
76693 /* CPUs seeing atomic_inc() must see later RCU read-side crit sects */
76694 smp_mb__after_atomic_inc(); /* See above. */
76695 - WARN_ON_ONCE(!(atomic_read(&rdtp->dynticks) & 0x1));
76696 + WARN_ON_ONCE(!(atomic_read_unchecked(&rdtp->dynticks) & 0x1));
76697 }
76698
76699 /**
76700 @@ -655,9 +655,9 @@ void rcu_nmi_exit(void)
76701 return;
76702 /* CPUs seeing atomic_inc() must see prior RCU read-side crit sects */
76703 smp_mb__before_atomic_inc(); /* See above. */
76704 - atomic_inc(&rdtp->dynticks);
76705 + atomic_inc_unchecked(&rdtp->dynticks);
76706 smp_mb__after_atomic_inc(); /* Force delay to next write. */
76707 - WARN_ON_ONCE(atomic_read(&rdtp->dynticks) & 0x1);
76708 + WARN_ON_ONCE(atomic_read_unchecked(&rdtp->dynticks) & 0x1);
76709 }
76710
76711 /**
76712 @@ -671,7 +671,7 @@ int rcu_is_cpu_idle(void)
76713 int ret;
76714
76715 preempt_disable();
76716 - ret = (atomic_read(&__get_cpu_var(rcu_dynticks).dynticks) & 0x1) == 0;
76717 + ret = (atomic_read_unchecked(&__get_cpu_var(rcu_dynticks).dynticks) & 0x1) == 0;
76718 preempt_enable();
76719 return ret;
76720 }
76721 @@ -739,7 +739,7 @@ int rcu_is_cpu_rrupt_from_idle(void)
76722 */
76723 static int dyntick_save_progress_counter(struct rcu_data *rdp)
76724 {
76725 - rdp->dynticks_snap = atomic_add_return(0, &rdp->dynticks->dynticks);
76726 + rdp->dynticks_snap = atomic_add_return_unchecked(0, &rdp->dynticks->dynticks);
76727 return (rdp->dynticks_snap & 0x1) == 0;
76728 }
76729
76730 @@ -754,7 +754,7 @@ static int rcu_implicit_dynticks_qs(struct rcu_data *rdp)
76731 unsigned int curr;
76732 unsigned int snap;
76733
76734 - curr = (unsigned int)atomic_add_return(0, &rdp->dynticks->dynticks);
76735 + curr = (unsigned int)atomic_add_return_unchecked(0, &rdp->dynticks->dynticks);
76736 snap = (unsigned int)rdp->dynticks_snap;
76737
76738 /*
76739 @@ -802,10 +802,10 @@ static int jiffies_till_stall_check(void)
76740 * for CONFIG_RCU_CPU_STALL_TIMEOUT.
76741 */
76742 if (till_stall_check < 3) {
76743 - ACCESS_ONCE(rcu_cpu_stall_timeout) = 3;
76744 + ACCESS_ONCE_RW(rcu_cpu_stall_timeout) = 3;
76745 till_stall_check = 3;
76746 } else if (till_stall_check > 300) {
76747 - ACCESS_ONCE(rcu_cpu_stall_timeout) = 300;
76748 + ACCESS_ONCE_RW(rcu_cpu_stall_timeout) = 300;
76749 till_stall_check = 300;
76750 }
76751 return till_stall_check * HZ + RCU_STALL_DELAY_DELTA;
76752 @@ -1592,7 +1592,7 @@ rcu_send_cbs_to_orphanage(int cpu, struct rcu_state *rsp,
76753 rsp->qlen += rdp->qlen;
76754 rdp->n_cbs_orphaned += rdp->qlen;
76755 rdp->qlen_lazy = 0;
76756 - ACCESS_ONCE(rdp->qlen) = 0;
76757 + ACCESS_ONCE_RW(rdp->qlen) = 0;
76758 }
76759
76760 /*
76761 @@ -1838,7 +1838,7 @@ static void rcu_do_batch(struct rcu_state *rsp, struct rcu_data *rdp)
76762 }
76763 smp_mb(); /* List handling before counting for rcu_barrier(). */
76764 rdp->qlen_lazy -= count_lazy;
76765 - ACCESS_ONCE(rdp->qlen) -= count;
76766 + ACCESS_ONCE_RW(rdp->qlen) -= count;
76767 rdp->n_cbs_invoked += count;
76768
76769 /* Reinstate batch limit if we have worked down the excess. */
76770 @@ -2031,7 +2031,7 @@ __rcu_process_callbacks(struct rcu_state *rsp)
76771 /*
76772 * Do RCU core processing for the current CPU.
76773 */
76774 -static void rcu_process_callbacks(struct softirq_action *unused)
76775 +static void rcu_process_callbacks(void)
76776 {
76777 struct rcu_state *rsp;
76778
76779 @@ -2154,7 +2154,7 @@ __call_rcu(struct rcu_head *head, void (*func)(struct rcu_head *rcu),
76780 local_irq_restore(flags);
76781 return;
76782 }
76783 - ACCESS_ONCE(rdp->qlen)++;
76784 + ACCESS_ONCE_RW(rdp->qlen)++;
76785 if (lazy)
76786 rdp->qlen_lazy++;
76787 else
76788 @@ -2363,11 +2363,11 @@ void synchronize_sched_expedited(void)
76789 * counter wrap on a 32-bit system. Quite a few more CPUs would of
76790 * course be required on a 64-bit system.
76791 */
76792 - if (ULONG_CMP_GE((ulong)atomic_long_read(&rsp->expedited_start),
76793 + if (ULONG_CMP_GE((ulong)atomic_long_read_unchecked(&rsp->expedited_start),
76794 (ulong)atomic_long_read(&rsp->expedited_done) +
76795 ULONG_MAX / 8)) {
76796 synchronize_sched();
76797 - atomic_long_inc(&rsp->expedited_wrap);
76798 + atomic_long_inc_unchecked(&rsp->expedited_wrap);
76799 return;
76800 }
76801
76802 @@ -2375,7 +2375,7 @@ void synchronize_sched_expedited(void)
76803 * Take a ticket. Note that atomic_inc_return() implies a
76804 * full memory barrier.
76805 */
76806 - snap = atomic_long_inc_return(&rsp->expedited_start);
76807 + snap = atomic_long_inc_return_unchecked(&rsp->expedited_start);
76808 firstsnap = snap;
76809 get_online_cpus();
76810 WARN_ON_ONCE(cpu_is_offline(raw_smp_processor_id()));
76811 @@ -2388,14 +2388,14 @@ void synchronize_sched_expedited(void)
76812 synchronize_sched_expedited_cpu_stop,
76813 NULL) == -EAGAIN) {
76814 put_online_cpus();
76815 - atomic_long_inc(&rsp->expedited_tryfail);
76816 + atomic_long_inc_unchecked(&rsp->expedited_tryfail);
76817
76818 /* Check to see if someone else did our work for us. */
76819 s = atomic_long_read(&rsp->expedited_done);
76820 if (ULONG_CMP_GE((ulong)s, (ulong)firstsnap)) {
76821 /* ensure test happens before caller kfree */
76822 smp_mb__before_atomic_inc(); /* ^^^ */
76823 - atomic_long_inc(&rsp->expedited_workdone1);
76824 + atomic_long_inc_unchecked(&rsp->expedited_workdone1);
76825 return;
76826 }
76827
76828 @@ -2404,7 +2404,7 @@ void synchronize_sched_expedited(void)
76829 udelay(trycount * num_online_cpus());
76830 } else {
76831 wait_rcu_gp(call_rcu_sched);
76832 - atomic_long_inc(&rsp->expedited_normal);
76833 + atomic_long_inc_unchecked(&rsp->expedited_normal);
76834 return;
76835 }
76836
76837 @@ -2413,7 +2413,7 @@ void synchronize_sched_expedited(void)
76838 if (ULONG_CMP_GE((ulong)s, (ulong)firstsnap)) {
76839 /* ensure test happens before caller kfree */
76840 smp_mb__before_atomic_inc(); /* ^^^ */
76841 - atomic_long_inc(&rsp->expedited_workdone2);
76842 + atomic_long_inc_unchecked(&rsp->expedited_workdone2);
76843 return;
76844 }
76845
76846 @@ -2425,10 +2425,10 @@ void synchronize_sched_expedited(void)
76847 * period works for us.
76848 */
76849 get_online_cpus();
76850 - snap = atomic_long_read(&rsp->expedited_start);
76851 + snap = atomic_long_read_unchecked(&rsp->expedited_start);
76852 smp_mb(); /* ensure read is before try_stop_cpus(). */
76853 }
76854 - atomic_long_inc(&rsp->expedited_stoppedcpus);
76855 + atomic_long_inc_unchecked(&rsp->expedited_stoppedcpus);
76856
76857 /*
76858 * Everyone up to our most recent fetch is covered by our grace
76859 @@ -2437,16 +2437,16 @@ void synchronize_sched_expedited(void)
76860 * than we did already did their update.
76861 */
76862 do {
76863 - atomic_long_inc(&rsp->expedited_done_tries);
76864 + atomic_long_inc_unchecked(&rsp->expedited_done_tries);
76865 s = atomic_long_read(&rsp->expedited_done);
76866 if (ULONG_CMP_GE((ulong)s, (ulong)snap)) {
76867 /* ensure test happens before caller kfree */
76868 smp_mb__before_atomic_inc(); /* ^^^ */
76869 - atomic_long_inc(&rsp->expedited_done_lost);
76870 + atomic_long_inc_unchecked(&rsp->expedited_done_lost);
76871 break;
76872 }
76873 } while (atomic_long_cmpxchg(&rsp->expedited_done, s, snap) != s);
76874 - atomic_long_inc(&rsp->expedited_done_exit);
76875 + atomic_long_inc_unchecked(&rsp->expedited_done_exit);
76876
76877 put_online_cpus();
76878 }
76879 @@ -2620,7 +2620,7 @@ static void _rcu_barrier(struct rcu_state *rsp)
76880 * ACCESS_ONCE() to prevent the compiler from speculating
76881 * the increment to precede the early-exit check.
76882 */
76883 - ACCESS_ONCE(rsp->n_barrier_done)++;
76884 + ACCESS_ONCE_RW(rsp->n_barrier_done)++;
76885 WARN_ON_ONCE((rsp->n_barrier_done & 0x1) != 1);
76886 _rcu_barrier_trace(rsp, "Inc1", -1, rsp->n_barrier_done);
76887 smp_mb(); /* Order ->n_barrier_done increment with below mechanism. */
76888 @@ -2670,7 +2670,7 @@ static void _rcu_barrier(struct rcu_state *rsp)
76889
76890 /* Increment ->n_barrier_done to prevent duplicate work. */
76891 smp_mb(); /* Keep increment after above mechanism. */
76892 - ACCESS_ONCE(rsp->n_barrier_done)++;
76893 + ACCESS_ONCE_RW(rsp->n_barrier_done)++;
76894 WARN_ON_ONCE((rsp->n_barrier_done & 0x1) != 0);
76895 _rcu_barrier_trace(rsp, "Inc2", -1, rsp->n_barrier_done);
76896 smp_mb(); /* Keep increment before caller's subsequent code. */
76897 @@ -2715,10 +2715,10 @@ rcu_boot_init_percpu_data(int cpu, struct rcu_state *rsp)
76898 rdp->grpmask = 1UL << (cpu - rdp->mynode->grplo);
76899 init_callback_list(rdp);
76900 rdp->qlen_lazy = 0;
76901 - ACCESS_ONCE(rdp->qlen) = 0;
76902 + ACCESS_ONCE_RW(rdp->qlen) = 0;
76903 rdp->dynticks = &per_cpu(rcu_dynticks, cpu);
76904 WARN_ON_ONCE(rdp->dynticks->dynticks_nesting != DYNTICK_TASK_EXIT_IDLE);
76905 - WARN_ON_ONCE(atomic_read(&rdp->dynticks->dynticks) != 1);
76906 + WARN_ON_ONCE(atomic_read_unchecked(&rdp->dynticks->dynticks) != 1);
76907 #ifdef CONFIG_RCU_USER_QS
76908 WARN_ON_ONCE(rdp->dynticks->in_user);
76909 #endif
76910 @@ -2754,8 +2754,8 @@ rcu_init_percpu_data(int cpu, struct rcu_state *rsp, int preemptible)
76911 rdp->blimit = blimit;
76912 init_callback_list(rdp); /* Re-enable callbacks on this CPU. */
76913 rdp->dynticks->dynticks_nesting = DYNTICK_TASK_EXIT_IDLE;
76914 - atomic_set(&rdp->dynticks->dynticks,
76915 - (atomic_read(&rdp->dynticks->dynticks) & ~0x1) + 1);
76916 + atomic_set_unchecked(&rdp->dynticks->dynticks,
76917 + (atomic_read_unchecked(&rdp->dynticks->dynticks) & ~0x1) + 1);
76918 rcu_prepare_for_idle_init(cpu);
76919 raw_spin_unlock(&rnp->lock); /* irqs remain disabled. */
76920
76921 diff --git a/kernel/rcutree.h b/kernel/rcutree.h
76922 index 4b69291..704c92e 100644
76923 --- a/kernel/rcutree.h
76924 +++ b/kernel/rcutree.h
76925 @@ -86,7 +86,7 @@ struct rcu_dynticks {
76926 long long dynticks_nesting; /* Track irq/process nesting level. */
76927 /* Process level is worth LLONG_MAX/2. */
76928 int dynticks_nmi_nesting; /* Track NMI nesting level. */
76929 - atomic_t dynticks; /* Even value for idle, else odd. */
76930 + atomic_unchecked_t dynticks;/* Even value for idle, else odd. */
76931 #ifdef CONFIG_RCU_FAST_NO_HZ
76932 int dyntick_drain; /* Prepare-for-idle state variable. */
76933 unsigned long dyntick_holdoff;
76934 @@ -423,17 +423,17 @@ struct rcu_state {
76935 /* _rcu_barrier(). */
76936 /* End of fields guarded by barrier_mutex. */
76937
76938 - atomic_long_t expedited_start; /* Starting ticket. */
76939 - atomic_long_t expedited_done; /* Done ticket. */
76940 - atomic_long_t expedited_wrap; /* # near-wrap incidents. */
76941 - atomic_long_t expedited_tryfail; /* # acquisition failures. */
76942 - atomic_long_t expedited_workdone1; /* # done by others #1. */
76943 - atomic_long_t expedited_workdone2; /* # done by others #2. */
76944 - atomic_long_t expedited_normal; /* # fallbacks to normal. */
76945 - atomic_long_t expedited_stoppedcpus; /* # successful stop_cpus. */
76946 - atomic_long_t expedited_done_tries; /* # tries to update _done. */
76947 - atomic_long_t expedited_done_lost; /* # times beaten to _done. */
76948 - atomic_long_t expedited_done_exit; /* # times exited _done loop. */
76949 + atomic_long_unchecked_t expedited_start; /* Starting ticket. */
76950 + atomic_long_t expedited_done; /* Done ticket. */
76951 + atomic_long_unchecked_t expedited_wrap; /* # near-wrap incidents. */
76952 + atomic_long_unchecked_t expedited_tryfail; /* # acquisition failures. */
76953 + atomic_long_unchecked_t expedited_workdone1; /* # done by others #1. */
76954 + atomic_long_unchecked_t expedited_workdone2; /* # done by others #2. */
76955 + atomic_long_unchecked_t expedited_normal; /* # fallbacks to normal. */
76956 + atomic_long_unchecked_t expedited_stoppedcpus; /* # successful stop_cpus. */
76957 + atomic_long_unchecked_t expedited_done_tries; /* # tries to update _done. */
76958 + atomic_long_unchecked_t expedited_done_lost; /* # times beaten to _done. */
76959 + atomic_long_unchecked_t expedited_done_exit; /* # times exited _done loop. */
76960
76961 unsigned long jiffies_force_qs; /* Time at which to invoke */
76962 /* force_quiescent_state(). */
76963 diff --git a/kernel/rcutree_plugin.h b/kernel/rcutree_plugin.h
76964 index c1cc7e1..f62e436 100644
76965 --- a/kernel/rcutree_plugin.h
76966 +++ b/kernel/rcutree_plugin.h
76967 @@ -892,7 +892,7 @@ void synchronize_rcu_expedited(void)
76968
76969 /* Clean up and exit. */
76970 smp_mb(); /* ensure expedited GP seen before counter increment. */
76971 - ACCESS_ONCE(sync_rcu_preempt_exp_count)++;
76972 + ACCESS_ONCE_RW(sync_rcu_preempt_exp_count)++;
76973 unlock_mb_ret:
76974 mutex_unlock(&sync_rcu_preempt_exp_mutex);
76975 mb_ret:
76976 @@ -1440,7 +1440,7 @@ static void rcu_boost_kthread_setaffinity(struct rcu_node *rnp, int outgoingcpu)
76977 free_cpumask_var(cm);
76978 }
76979
76980 -static struct smp_hotplug_thread rcu_cpu_thread_spec = {
76981 +static struct smp_hotplug_thread rcu_cpu_thread_spec __read_only = {
76982 .store = &rcu_cpu_kthread_task,
76983 .thread_should_run = rcu_cpu_kthread_should_run,
76984 .thread_fn = rcu_cpu_kthread,
76985 @@ -2072,7 +2072,7 @@ static void print_cpu_stall_info(struct rcu_state *rsp, int cpu)
76986 print_cpu_stall_fast_no_hz(fast_no_hz, cpu);
76987 printk(KERN_ERR "\t%d: (%lu %s) idle=%03x/%llx/%d %s\n",
76988 cpu, ticks_value, ticks_title,
76989 - atomic_read(&rdtp->dynticks) & 0xfff,
76990 + atomic_read_unchecked(&rdtp->dynticks) & 0xfff,
76991 rdtp->dynticks_nesting, rdtp->dynticks_nmi_nesting,
76992 fast_no_hz);
76993 }
76994 @@ -2192,7 +2192,7 @@ static void __call_rcu_nocb_enqueue(struct rcu_data *rdp,
76995
76996 /* Enqueue the callback on the nocb list and update counts. */
76997 old_rhpp = xchg(&rdp->nocb_tail, rhtp);
76998 - ACCESS_ONCE(*old_rhpp) = rhp;
76999 + ACCESS_ONCE_RW(*old_rhpp) = rhp;
77000 atomic_long_add(rhcount, &rdp->nocb_q_count);
77001 atomic_long_add(rhcount_lazy, &rdp->nocb_q_count_lazy);
77002
77003 @@ -2384,12 +2384,12 @@ static int rcu_nocb_kthread(void *arg)
77004 * Extract queued callbacks, update counts, and wait
77005 * for a grace period to elapse.
77006 */
77007 - ACCESS_ONCE(rdp->nocb_head) = NULL;
77008 + ACCESS_ONCE_RW(rdp->nocb_head) = NULL;
77009 tail = xchg(&rdp->nocb_tail, &rdp->nocb_head);
77010 c = atomic_long_xchg(&rdp->nocb_q_count, 0);
77011 cl = atomic_long_xchg(&rdp->nocb_q_count_lazy, 0);
77012 - ACCESS_ONCE(rdp->nocb_p_count) += c;
77013 - ACCESS_ONCE(rdp->nocb_p_count_lazy) += cl;
77014 + ACCESS_ONCE_RW(rdp->nocb_p_count) += c;
77015 + ACCESS_ONCE_RW(rdp->nocb_p_count_lazy) += cl;
77016 wait_rcu_gp(rdp->rsp->call_remote);
77017
77018 /* Each pass through the following loop invokes a callback. */
77019 @@ -2411,8 +2411,8 @@ static int rcu_nocb_kthread(void *arg)
77020 list = next;
77021 }
77022 trace_rcu_batch_end(rdp->rsp->name, c, !!list, 0, 0, 1);
77023 - ACCESS_ONCE(rdp->nocb_p_count) -= c;
77024 - ACCESS_ONCE(rdp->nocb_p_count_lazy) -= cl;
77025 + ACCESS_ONCE_RW(rdp->nocb_p_count) -= c;
77026 + ACCESS_ONCE_RW(rdp->nocb_p_count_lazy) -= cl;
77027 rdp->n_nocbs_invoked += c;
77028 }
77029 return 0;
77030 @@ -2438,7 +2438,7 @@ static void __init rcu_spawn_nocb_kthreads(struct rcu_state *rsp)
77031 rdp = per_cpu_ptr(rsp->rda, cpu);
77032 t = kthread_run(rcu_nocb_kthread, rdp, "rcuo%d", cpu);
77033 BUG_ON(IS_ERR(t));
77034 - ACCESS_ONCE(rdp->nocb_kthread) = t;
77035 + ACCESS_ONCE_RW(rdp->nocb_kthread) = t;
77036 }
77037 }
77038
77039 diff --git a/kernel/rcutree_trace.c b/kernel/rcutree_trace.c
77040 index 0d095dc..1985b19 100644
77041 --- a/kernel/rcutree_trace.c
77042 +++ b/kernel/rcutree_trace.c
77043 @@ -123,7 +123,7 @@ static void print_one_rcu_data(struct seq_file *m, struct rcu_data *rdp)
77044 ulong2long(rdp->completed), ulong2long(rdp->gpnum),
77045 rdp->passed_quiesce, rdp->qs_pending);
77046 seq_printf(m, " dt=%d/%llx/%d df=%lu",
77047 - atomic_read(&rdp->dynticks->dynticks),
77048 + atomic_read_unchecked(&rdp->dynticks->dynticks),
77049 rdp->dynticks->dynticks_nesting,
77050 rdp->dynticks->dynticks_nmi_nesting,
77051 rdp->dynticks_fqs);
77052 @@ -184,17 +184,17 @@ static int show_rcuexp(struct seq_file *m, void *v)
77053 struct rcu_state *rsp = (struct rcu_state *)m->private;
77054
77055 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",
77056 - atomic_long_read(&rsp->expedited_start),
77057 + atomic_long_read_unchecked(&rsp->expedited_start),
77058 atomic_long_read(&rsp->expedited_done),
77059 - atomic_long_read(&rsp->expedited_wrap),
77060 - atomic_long_read(&rsp->expedited_tryfail),
77061 - atomic_long_read(&rsp->expedited_workdone1),
77062 - atomic_long_read(&rsp->expedited_workdone2),
77063 - atomic_long_read(&rsp->expedited_normal),
77064 - atomic_long_read(&rsp->expedited_stoppedcpus),
77065 - atomic_long_read(&rsp->expedited_done_tries),
77066 - atomic_long_read(&rsp->expedited_done_lost),
77067 - atomic_long_read(&rsp->expedited_done_exit));
77068 + atomic_long_read_unchecked(&rsp->expedited_wrap),
77069 + atomic_long_read_unchecked(&rsp->expedited_tryfail),
77070 + atomic_long_read_unchecked(&rsp->expedited_workdone1),
77071 + atomic_long_read_unchecked(&rsp->expedited_workdone2),
77072 + atomic_long_read_unchecked(&rsp->expedited_normal),
77073 + atomic_long_read_unchecked(&rsp->expedited_stoppedcpus),
77074 + atomic_long_read_unchecked(&rsp->expedited_done_tries),
77075 + atomic_long_read_unchecked(&rsp->expedited_done_lost),
77076 + atomic_long_read_unchecked(&rsp->expedited_done_exit));
77077 return 0;
77078 }
77079
77080 diff --git a/kernel/resource.c b/kernel/resource.c
77081 index 73f35d4..4684fc4 100644
77082 --- a/kernel/resource.c
77083 +++ b/kernel/resource.c
77084 @@ -143,8 +143,18 @@ static const struct file_operations proc_iomem_operations = {
77085
77086 static int __init ioresources_init(void)
77087 {
77088 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
77089 +#ifdef CONFIG_GRKERNSEC_PROC_USER
77090 + proc_create("ioports", S_IRUSR, NULL, &proc_ioports_operations);
77091 + proc_create("iomem", S_IRUSR, NULL, &proc_iomem_operations);
77092 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
77093 + proc_create("ioports", S_IRUSR | S_IRGRP, NULL, &proc_ioports_operations);
77094 + proc_create("iomem", S_IRUSR | S_IRGRP, NULL, &proc_iomem_operations);
77095 +#endif
77096 +#else
77097 proc_create("ioports", 0, NULL, &proc_ioports_operations);
77098 proc_create("iomem", 0, NULL, &proc_iomem_operations);
77099 +#endif
77100 return 0;
77101 }
77102 __initcall(ioresources_init);
77103 diff --git a/kernel/rtmutex-tester.c b/kernel/rtmutex-tester.c
77104 index 98ec494..4241d6d 100644
77105 --- a/kernel/rtmutex-tester.c
77106 +++ b/kernel/rtmutex-tester.c
77107 @@ -20,7 +20,7 @@
77108 #define MAX_RT_TEST_MUTEXES 8
77109
77110 static spinlock_t rttest_lock;
77111 -static atomic_t rttest_event;
77112 +static atomic_unchecked_t rttest_event;
77113
77114 struct test_thread_data {
77115 int opcode;
77116 @@ -61,7 +61,7 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
77117
77118 case RTTEST_LOCKCONT:
77119 td->mutexes[td->opdata] = 1;
77120 - td->event = atomic_add_return(1, &rttest_event);
77121 + td->event = atomic_add_return_unchecked(1, &rttest_event);
77122 return 0;
77123
77124 case RTTEST_RESET:
77125 @@ -74,7 +74,7 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
77126 return 0;
77127
77128 case RTTEST_RESETEVENT:
77129 - atomic_set(&rttest_event, 0);
77130 + atomic_set_unchecked(&rttest_event, 0);
77131 return 0;
77132
77133 default:
77134 @@ -91,9 +91,9 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
77135 return ret;
77136
77137 td->mutexes[id] = 1;
77138 - td->event = atomic_add_return(1, &rttest_event);
77139 + td->event = atomic_add_return_unchecked(1, &rttest_event);
77140 rt_mutex_lock(&mutexes[id]);
77141 - td->event = atomic_add_return(1, &rttest_event);
77142 + td->event = atomic_add_return_unchecked(1, &rttest_event);
77143 td->mutexes[id] = 4;
77144 return 0;
77145
77146 @@ -104,9 +104,9 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
77147 return ret;
77148
77149 td->mutexes[id] = 1;
77150 - td->event = atomic_add_return(1, &rttest_event);
77151 + td->event = atomic_add_return_unchecked(1, &rttest_event);
77152 ret = rt_mutex_lock_interruptible(&mutexes[id], 0);
77153 - td->event = atomic_add_return(1, &rttest_event);
77154 + td->event = atomic_add_return_unchecked(1, &rttest_event);
77155 td->mutexes[id] = ret ? 0 : 4;
77156 return ret ? -EINTR : 0;
77157
77158 @@ -115,9 +115,9 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
77159 if (id < 0 || id >= MAX_RT_TEST_MUTEXES || td->mutexes[id] != 4)
77160 return ret;
77161
77162 - td->event = atomic_add_return(1, &rttest_event);
77163 + td->event = atomic_add_return_unchecked(1, &rttest_event);
77164 rt_mutex_unlock(&mutexes[id]);
77165 - td->event = atomic_add_return(1, &rttest_event);
77166 + td->event = atomic_add_return_unchecked(1, &rttest_event);
77167 td->mutexes[id] = 0;
77168 return 0;
77169
77170 @@ -164,7 +164,7 @@ void schedule_rt_mutex_test(struct rt_mutex *mutex)
77171 break;
77172
77173 td->mutexes[dat] = 2;
77174 - td->event = atomic_add_return(1, &rttest_event);
77175 + td->event = atomic_add_return_unchecked(1, &rttest_event);
77176 break;
77177
77178 default:
77179 @@ -184,7 +184,7 @@ void schedule_rt_mutex_test(struct rt_mutex *mutex)
77180 return;
77181
77182 td->mutexes[dat] = 3;
77183 - td->event = atomic_add_return(1, &rttest_event);
77184 + td->event = atomic_add_return_unchecked(1, &rttest_event);
77185 break;
77186
77187 case RTTEST_LOCKNOWAIT:
77188 @@ -196,7 +196,7 @@ void schedule_rt_mutex_test(struct rt_mutex *mutex)
77189 return;
77190
77191 td->mutexes[dat] = 1;
77192 - td->event = atomic_add_return(1, &rttest_event);
77193 + td->event = atomic_add_return_unchecked(1, &rttest_event);
77194 return;
77195
77196 default:
77197 diff --git a/kernel/sched/auto_group.c b/kernel/sched/auto_group.c
77198 index 0984a21..939f183 100644
77199 --- a/kernel/sched/auto_group.c
77200 +++ b/kernel/sched/auto_group.c
77201 @@ -11,7 +11,7 @@
77202
77203 unsigned int __read_mostly sysctl_sched_autogroup_enabled = 1;
77204 static struct autogroup autogroup_default;
77205 -static atomic_t autogroup_seq_nr;
77206 +static atomic_unchecked_t autogroup_seq_nr;
77207
77208 void __init autogroup_init(struct task_struct *init_task)
77209 {
77210 @@ -78,7 +78,7 @@ static inline struct autogroup *autogroup_create(void)
77211
77212 kref_init(&ag->kref);
77213 init_rwsem(&ag->lock);
77214 - ag->id = atomic_inc_return(&autogroup_seq_nr);
77215 + ag->id = atomic_inc_return_unchecked(&autogroup_seq_nr);
77216 ag->tg = tg;
77217 #ifdef CONFIG_RT_GROUP_SCHED
77218 /*
77219 diff --git a/kernel/sched/core.c b/kernel/sched/core.c
77220 index 26058d0..e315889 100644
77221 --- a/kernel/sched/core.c
77222 +++ b/kernel/sched/core.c
77223 @@ -3367,7 +3367,7 @@ EXPORT_SYMBOL(wait_for_completion_interruptible);
77224 * The return value is -ERESTARTSYS if interrupted, 0 if timed out,
77225 * positive (at least 1, or number of jiffies left till timeout) if completed.
77226 */
77227 -long __sched
77228 +long __sched __intentional_overflow(-1)
77229 wait_for_completion_interruptible_timeout(struct completion *x,
77230 unsigned long timeout)
77231 {
77232 @@ -3384,7 +3384,7 @@ EXPORT_SYMBOL(wait_for_completion_interruptible_timeout);
77233 *
77234 * The return value is -ERESTARTSYS if interrupted, 0 if completed.
77235 */
77236 -int __sched wait_for_completion_killable(struct completion *x)
77237 +int __sched __intentional_overflow(-1) wait_for_completion_killable(struct completion *x)
77238 {
77239 long t = wait_for_common(x, MAX_SCHEDULE_TIMEOUT, TASK_KILLABLE);
77240 if (t == -ERESTARTSYS)
77241 @@ -3405,7 +3405,7 @@ EXPORT_SYMBOL(wait_for_completion_killable);
77242 * The return value is -ERESTARTSYS if interrupted, 0 if timed out,
77243 * positive (at least 1, or number of jiffies left till timeout) if completed.
77244 */
77245 -long __sched
77246 +long __sched __intentional_overflow(-1)
77247 wait_for_completion_killable_timeout(struct completion *x,
77248 unsigned long timeout)
77249 {
77250 @@ -3631,6 +3631,8 @@ int can_nice(const struct task_struct *p, const int nice)
77251 /* convert nice value [19,-20] to rlimit style value [1,40] */
77252 int nice_rlim = 20 - nice;
77253
77254 + gr_learn_resource(p, RLIMIT_NICE, nice_rlim, 1);
77255 +
77256 return (nice_rlim <= task_rlimit(p, RLIMIT_NICE) ||
77257 capable(CAP_SYS_NICE));
77258 }
77259 @@ -3664,7 +3666,8 @@ SYSCALL_DEFINE1(nice, int, increment)
77260 if (nice > 19)
77261 nice = 19;
77262
77263 - if (increment < 0 && !can_nice(current, nice))
77264 + if (increment < 0 && (!can_nice(current, nice) ||
77265 + gr_handle_chroot_nice()))
77266 return -EPERM;
77267
77268 retval = security_task_setnice(current, nice);
77269 @@ -3818,6 +3821,7 @@ recheck:
77270 unsigned long rlim_rtprio =
77271 task_rlimit(p, RLIMIT_RTPRIO);
77272
77273 + gr_learn_resource(p, RLIMIT_RTPRIO, param->sched_priority, 1);
77274 /* can't set/change the rt policy */
77275 if (policy != p->policy && !rlim_rtprio)
77276 return -EPERM;
77277 @@ -4901,7 +4905,7 @@ static void migrate_tasks(unsigned int dead_cpu)
77278
77279 #if defined(CONFIG_SCHED_DEBUG) && defined(CONFIG_SYSCTL)
77280
77281 -static struct ctl_table sd_ctl_dir[] = {
77282 +static ctl_table_no_const sd_ctl_dir[] __read_only = {
77283 {
77284 .procname = "sched_domain",
77285 .mode = 0555,
77286 @@ -4918,17 +4922,17 @@ static struct ctl_table sd_ctl_root[] = {
77287 {}
77288 };
77289
77290 -static struct ctl_table *sd_alloc_ctl_entry(int n)
77291 +static ctl_table_no_const *sd_alloc_ctl_entry(int n)
77292 {
77293 - struct ctl_table *entry =
77294 + ctl_table_no_const *entry =
77295 kcalloc(n, sizeof(struct ctl_table), GFP_KERNEL);
77296
77297 return entry;
77298 }
77299
77300 -static void sd_free_ctl_entry(struct ctl_table **tablep)
77301 +static void sd_free_ctl_entry(ctl_table_no_const *tablep)
77302 {
77303 - struct ctl_table *entry;
77304 + ctl_table_no_const *entry;
77305
77306 /*
77307 * In the intermediate directories, both the child directory and
77308 @@ -4936,22 +4940,25 @@ static void sd_free_ctl_entry(struct ctl_table **tablep)
77309 * will always be set. In the lowest directory the names are
77310 * static strings and all have proc handlers.
77311 */
77312 - for (entry = *tablep; entry->mode; entry++) {
77313 - if (entry->child)
77314 - sd_free_ctl_entry(&entry->child);
77315 + for (entry = tablep; entry->mode; entry++) {
77316 + if (entry->child) {
77317 + sd_free_ctl_entry(entry->child);
77318 + pax_open_kernel();
77319 + entry->child = NULL;
77320 + pax_close_kernel();
77321 + }
77322 if (entry->proc_handler == NULL)
77323 kfree(entry->procname);
77324 }
77325
77326 - kfree(*tablep);
77327 - *tablep = NULL;
77328 + kfree(tablep);
77329 }
77330
77331 static int min_load_idx = 0;
77332 static int max_load_idx = CPU_LOAD_IDX_MAX;
77333
77334 static void
77335 -set_table_entry(struct ctl_table *entry,
77336 +set_table_entry(ctl_table_no_const *entry,
77337 const char *procname, void *data, int maxlen,
77338 umode_t mode, proc_handler *proc_handler,
77339 bool load_idx)
77340 @@ -4971,7 +4978,7 @@ set_table_entry(struct ctl_table *entry,
77341 static struct ctl_table *
77342 sd_alloc_ctl_domain_table(struct sched_domain *sd)
77343 {
77344 - struct ctl_table *table = sd_alloc_ctl_entry(13);
77345 + ctl_table_no_const *table = sd_alloc_ctl_entry(13);
77346
77347 if (table == NULL)
77348 return NULL;
77349 @@ -5006,9 +5013,9 @@ sd_alloc_ctl_domain_table(struct sched_domain *sd)
77350 return table;
77351 }
77352
77353 -static ctl_table *sd_alloc_ctl_cpu_table(int cpu)
77354 +static ctl_table_no_const *sd_alloc_ctl_cpu_table(int cpu)
77355 {
77356 - struct ctl_table *entry, *table;
77357 + ctl_table_no_const *entry, *table;
77358 struct sched_domain *sd;
77359 int domain_num = 0, i;
77360 char buf[32];
77361 @@ -5035,11 +5042,13 @@ static struct ctl_table_header *sd_sysctl_header;
77362 static void register_sched_domain_sysctl(void)
77363 {
77364 int i, cpu_num = num_possible_cpus();
77365 - struct ctl_table *entry = sd_alloc_ctl_entry(cpu_num + 1);
77366 + ctl_table_no_const *entry = sd_alloc_ctl_entry(cpu_num + 1);
77367 char buf[32];
77368
77369 WARN_ON(sd_ctl_dir[0].child);
77370 + pax_open_kernel();
77371 sd_ctl_dir[0].child = entry;
77372 + pax_close_kernel();
77373
77374 if (entry == NULL)
77375 return;
77376 @@ -5062,8 +5071,12 @@ static void unregister_sched_domain_sysctl(void)
77377 if (sd_sysctl_header)
77378 unregister_sysctl_table(sd_sysctl_header);
77379 sd_sysctl_header = NULL;
77380 - if (sd_ctl_dir[0].child)
77381 - sd_free_ctl_entry(&sd_ctl_dir[0].child);
77382 + if (sd_ctl_dir[0].child) {
77383 + sd_free_ctl_entry(sd_ctl_dir[0].child);
77384 + pax_open_kernel();
77385 + sd_ctl_dir[0].child = NULL;
77386 + pax_close_kernel();
77387 + }
77388 }
77389 #else
77390 static void register_sched_domain_sysctl(void)
77391 @@ -5162,7 +5175,7 @@ migration_call(struct notifier_block *nfb, unsigned long action, void *hcpu)
77392 * happens before everything else. This has to be lower priority than
77393 * the notifier in the perf_event subsystem, though.
77394 */
77395 -static struct notifier_block __cpuinitdata migration_notifier = {
77396 +static struct notifier_block migration_notifier = {
77397 .notifier_call = migration_call,
77398 .priority = CPU_PRI_MIGRATION,
77399 };
77400 diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
77401 index 81fa536..6ccf96a 100644
77402 --- a/kernel/sched/fair.c
77403 +++ b/kernel/sched/fair.c
77404 @@ -830,7 +830,7 @@ void task_numa_fault(int node, int pages, bool migrated)
77405
77406 static void reset_ptenuma_scan(struct task_struct *p)
77407 {
77408 - ACCESS_ONCE(p->mm->numa_scan_seq)++;
77409 + ACCESS_ONCE_RW(p->mm->numa_scan_seq)++;
77410 p->mm->numa_scan_offset = 0;
77411 }
77412
77413 @@ -3254,25 +3254,18 @@ find_idlest_cpu(struct sched_group *group, struct task_struct *p, int this_cpu)
77414 */
77415 static int select_idle_sibling(struct task_struct *p, int target)
77416 {
77417 - int cpu = smp_processor_id();
77418 - int prev_cpu = task_cpu(p);
77419 struct sched_domain *sd;
77420 struct sched_group *sg;
77421 - int i;
77422 + int i = task_cpu(p);
77423
77424 - /*
77425 - * If the task is going to be woken-up on this cpu and if it is
77426 - * already idle, then it is the right target.
77427 - */
77428 - if (target == cpu && idle_cpu(cpu))
77429 - return cpu;
77430 + if (idle_cpu(target))
77431 + return target;
77432
77433 /*
77434 - * If the task is going to be woken-up on the cpu where it previously
77435 - * ran and if it is currently idle, then it the right target.
77436 + * If the prevous cpu is cache affine and idle, don't be stupid.
77437 */
77438 - if (target == prev_cpu && idle_cpu(prev_cpu))
77439 - return prev_cpu;
77440 + if (i != target && cpus_share_cache(i, target) && idle_cpu(i))
77441 + return i;
77442
77443 /*
77444 * Otherwise, iterate the domains and find an elegible idle cpu.
77445 @@ -3286,7 +3279,7 @@ static int select_idle_sibling(struct task_struct *p, int target)
77446 goto next;
77447
77448 for_each_cpu(i, sched_group_cpus(sg)) {
77449 - if (!idle_cpu(i))
77450 + if (i == target || !idle_cpu(i))
77451 goto next;
77452 }
77453
77454 @@ -5663,7 +5656,7 @@ static void nohz_idle_balance(int this_cpu, enum cpu_idle_type idle) { }
77455 * run_rebalance_domains is triggered when needed from the scheduler tick.
77456 * Also triggered for nohz idle balancing (with nohz_balancing_kick set).
77457 */
77458 -static void run_rebalance_domains(struct softirq_action *h)
77459 +static void run_rebalance_domains(void)
77460 {
77461 int this_cpu = smp_processor_id();
77462 struct rq *this_rq = cpu_rq(this_cpu);
77463 diff --git a/kernel/signal.c b/kernel/signal.c
77464 index 7591ccc..8988390 100644
77465 --- a/kernel/signal.c
77466 +++ b/kernel/signal.c
77467 @@ -50,12 +50,12 @@ static struct kmem_cache *sigqueue_cachep;
77468
77469 int print_fatal_signals __read_mostly;
77470
77471 -static void __user *sig_handler(struct task_struct *t, int sig)
77472 +static __sighandler_t sig_handler(struct task_struct *t, int sig)
77473 {
77474 return t->sighand->action[sig - 1].sa.sa_handler;
77475 }
77476
77477 -static int sig_handler_ignored(void __user *handler, int sig)
77478 +static int sig_handler_ignored(__sighandler_t handler, int sig)
77479 {
77480 /* Is it explicitly or implicitly ignored? */
77481 return handler == SIG_IGN ||
77482 @@ -64,7 +64,7 @@ static int sig_handler_ignored(void __user *handler, int sig)
77483
77484 static int sig_task_ignored(struct task_struct *t, int sig, bool force)
77485 {
77486 - void __user *handler;
77487 + __sighandler_t handler;
77488
77489 handler = sig_handler(t, sig);
77490
77491 @@ -368,6 +368,9 @@ __sigqueue_alloc(int sig, struct task_struct *t, gfp_t flags, int override_rlimi
77492 atomic_inc(&user->sigpending);
77493 rcu_read_unlock();
77494
77495 + if (!override_rlimit)
77496 + gr_learn_resource(t, RLIMIT_SIGPENDING, atomic_read(&user->sigpending), 1);
77497 +
77498 if (override_rlimit ||
77499 atomic_read(&user->sigpending) <=
77500 task_rlimit(t, RLIMIT_SIGPENDING)) {
77501 @@ -495,7 +498,7 @@ flush_signal_handlers(struct task_struct *t, int force_default)
77502
77503 int unhandled_signal(struct task_struct *tsk, int sig)
77504 {
77505 - void __user *handler = tsk->sighand->action[sig-1].sa.sa_handler;
77506 + __sighandler_t handler = tsk->sighand->action[sig-1].sa.sa_handler;
77507 if (is_global_init(tsk))
77508 return 1;
77509 if (handler != SIG_IGN && handler != SIG_DFL)
77510 @@ -815,6 +818,13 @@ static int check_kill_permission(int sig, struct siginfo *info,
77511 }
77512 }
77513
77514 + /* allow glibc communication via tgkill to other threads in our
77515 + thread group */
77516 + if ((info == SEND_SIG_NOINFO || info->si_code != SI_TKILL ||
77517 + sig != (SIGRTMIN+1) || task_tgid_vnr(t) != info->si_pid)
77518 + && gr_handle_signal(t, sig))
77519 + return -EPERM;
77520 +
77521 return security_task_kill(t, info, sig, 0);
77522 }
77523
77524 @@ -1197,7 +1207,7 @@ __group_send_sig_info(int sig, struct siginfo *info, struct task_struct *p)
77525 return send_signal(sig, info, p, 1);
77526 }
77527
77528 -static int
77529 +int
77530 specific_send_sig_info(int sig, struct siginfo *info, struct task_struct *t)
77531 {
77532 return send_signal(sig, info, t, 0);
77533 @@ -1234,6 +1244,7 @@ force_sig_info(int sig, struct siginfo *info, struct task_struct *t)
77534 unsigned long int flags;
77535 int ret, blocked, ignored;
77536 struct k_sigaction *action;
77537 + int is_unhandled = 0;
77538
77539 spin_lock_irqsave(&t->sighand->siglock, flags);
77540 action = &t->sighand->action[sig-1];
77541 @@ -1248,9 +1259,18 @@ force_sig_info(int sig, struct siginfo *info, struct task_struct *t)
77542 }
77543 if (action->sa.sa_handler == SIG_DFL)
77544 t->signal->flags &= ~SIGNAL_UNKILLABLE;
77545 + if (action->sa.sa_handler == SIG_IGN || action->sa.sa_handler == SIG_DFL)
77546 + is_unhandled = 1;
77547 ret = specific_send_sig_info(sig, info, t);
77548 spin_unlock_irqrestore(&t->sighand->siglock, flags);
77549
77550 + /* only deal with unhandled signals, java etc trigger SIGSEGV during
77551 + normal operation */
77552 + if (is_unhandled) {
77553 + gr_log_signal(sig, !is_si_special(info) ? info->si_addr : NULL, t);
77554 + gr_handle_crash(t, sig);
77555 + }
77556 +
77557 return ret;
77558 }
77559
77560 @@ -1317,8 +1337,11 @@ int group_send_sig_info(int sig, struct siginfo *info, struct task_struct *p)
77561 ret = check_kill_permission(sig, info, p);
77562 rcu_read_unlock();
77563
77564 - if (!ret && sig)
77565 + if (!ret && sig) {
77566 ret = do_send_sig_info(sig, info, p, true);
77567 + if (!ret)
77568 + gr_log_signal(sig, !is_si_special(info) ? info->si_addr : NULL, p);
77569 + }
77570
77571 return ret;
77572 }
77573 @@ -2855,7 +2878,15 @@ do_send_specific(pid_t tgid, pid_t pid, int sig, struct siginfo *info)
77574 int error = -ESRCH;
77575
77576 rcu_read_lock();
77577 - p = find_task_by_vpid(pid);
77578 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
77579 + /* allow glibc communication via tgkill to other threads in our
77580 + thread group */
77581 + if (grsec_enable_chroot_findtask && info->si_code == SI_TKILL &&
77582 + sig == (SIGRTMIN+1) && tgid == info->si_pid)
77583 + p = find_task_by_vpid_unrestricted(pid);
77584 + else
77585 +#endif
77586 + p = find_task_by_vpid(pid);
77587 if (p && (tgid <= 0 || task_tgid_vnr(p) == tgid)) {
77588 error = check_kill_permission(sig, info, p);
77589 /*
77590 @@ -3138,8 +3169,8 @@ COMPAT_SYSCALL_DEFINE2(sigaltstack,
77591 }
77592 seg = get_fs();
77593 set_fs(KERNEL_DS);
77594 - ret = do_sigaltstack((stack_t __force __user *) (uss_ptr ? &uss : NULL),
77595 - (stack_t __force __user *) &uoss,
77596 + ret = do_sigaltstack((stack_t __force_user *) (uss_ptr ? &uss : NULL),
77597 + (stack_t __force_user *) &uoss,
77598 compat_user_stack_pointer());
77599 set_fs(seg);
77600 if (ret >= 0 && uoss_ptr) {
77601 diff --git a/kernel/smp.c b/kernel/smp.c
77602 index 69f38bd..77bbf12 100644
77603 --- a/kernel/smp.c
77604 +++ b/kernel/smp.c
77605 @@ -77,7 +77,7 @@ hotplug_cfd(struct notifier_block *nfb, unsigned long action, void *hcpu)
77606 return NOTIFY_OK;
77607 }
77608
77609 -static struct notifier_block __cpuinitdata hotplug_cfd_notifier = {
77610 +static struct notifier_block hotplug_cfd_notifier = {
77611 .notifier_call = hotplug_cfd,
77612 };
77613
77614 diff --git a/kernel/smpboot.c b/kernel/smpboot.c
77615 index d6c5fc0..530560c 100644
77616 --- a/kernel/smpboot.c
77617 +++ b/kernel/smpboot.c
77618 @@ -275,7 +275,7 @@ int smpboot_register_percpu_thread(struct smp_hotplug_thread *plug_thread)
77619 }
77620 smpboot_unpark_thread(plug_thread, cpu);
77621 }
77622 - list_add(&plug_thread->list, &hotplug_threads);
77623 + pax_list_add(&plug_thread->list, &hotplug_threads);
77624 out:
77625 mutex_unlock(&smpboot_threads_lock);
77626 return ret;
77627 @@ -292,7 +292,7 @@ void smpboot_unregister_percpu_thread(struct smp_hotplug_thread *plug_thread)
77628 {
77629 get_online_cpus();
77630 mutex_lock(&smpboot_threads_lock);
77631 - list_del(&plug_thread->list);
77632 + pax_list_del(&plug_thread->list);
77633 smpboot_destroy_threads(plug_thread);
77634 mutex_unlock(&smpboot_threads_lock);
77635 put_online_cpus();
77636 diff --git a/kernel/softirq.c b/kernel/softirq.c
77637 index ed567ba..e71dabf 100644
77638 --- a/kernel/softirq.c
77639 +++ b/kernel/softirq.c
77640 @@ -53,11 +53,11 @@ irq_cpustat_t irq_stat[NR_CPUS] ____cacheline_aligned;
77641 EXPORT_SYMBOL(irq_stat);
77642 #endif
77643
77644 -static struct softirq_action softirq_vec[NR_SOFTIRQS] __cacheline_aligned_in_smp;
77645 +static struct softirq_action softirq_vec[NR_SOFTIRQS] __read_only __aligned(PAGE_SIZE);
77646
77647 DEFINE_PER_CPU(struct task_struct *, ksoftirqd);
77648
77649 -char *softirq_to_name[NR_SOFTIRQS] = {
77650 +const char * const softirq_to_name[NR_SOFTIRQS] = {
77651 "HI", "TIMER", "NET_TX", "NET_RX", "BLOCK", "BLOCK_IOPOLL",
77652 "TASKLET", "SCHED", "HRTIMER", "RCU"
77653 };
77654 @@ -244,7 +244,7 @@ restart:
77655 kstat_incr_softirqs_this_cpu(vec_nr);
77656
77657 trace_softirq_entry(vec_nr);
77658 - h->action(h);
77659 + h->action();
77660 trace_softirq_exit(vec_nr);
77661 if (unlikely(prev_count != preempt_count())) {
77662 printk(KERN_ERR "huh, entered softirq %u %s %p"
77663 @@ -391,7 +391,7 @@ void __raise_softirq_irqoff(unsigned int nr)
77664 or_softirq_pending(1UL << nr);
77665 }
77666
77667 -void open_softirq(int nr, void (*action)(struct softirq_action *))
77668 +void __init open_softirq(int nr, void (*action)(void))
77669 {
77670 softirq_vec[nr].action = action;
77671 }
77672 @@ -447,7 +447,7 @@ void __tasklet_hi_schedule_first(struct tasklet_struct *t)
77673
77674 EXPORT_SYMBOL(__tasklet_hi_schedule_first);
77675
77676 -static void tasklet_action(struct softirq_action *a)
77677 +static void tasklet_action(void)
77678 {
77679 struct tasklet_struct *list;
77680
77681 @@ -482,7 +482,7 @@ static void tasklet_action(struct softirq_action *a)
77682 }
77683 }
77684
77685 -static void tasklet_hi_action(struct softirq_action *a)
77686 +static void tasklet_hi_action(void)
77687 {
77688 struct tasklet_struct *list;
77689
77690 @@ -718,7 +718,7 @@ static int __cpuinit remote_softirq_cpu_notify(struct notifier_block *self,
77691 return NOTIFY_OK;
77692 }
77693
77694 -static struct notifier_block __cpuinitdata remote_softirq_cpu_notifier = {
77695 +static struct notifier_block remote_softirq_cpu_notifier = {
77696 .notifier_call = remote_softirq_cpu_notify,
77697 };
77698
77699 @@ -835,11 +835,11 @@ static int __cpuinit cpu_callback(struct notifier_block *nfb,
77700 return NOTIFY_OK;
77701 }
77702
77703 -static struct notifier_block __cpuinitdata cpu_nfb = {
77704 +static struct notifier_block cpu_nfb = {
77705 .notifier_call = cpu_callback
77706 };
77707
77708 -static struct smp_hotplug_thread softirq_threads = {
77709 +static struct smp_hotplug_thread softirq_threads __read_only = {
77710 .store = &ksoftirqd,
77711 .thread_should_run = ksoftirqd_should_run,
77712 .thread_fn = run_ksoftirqd,
77713 diff --git a/kernel/srcu.c b/kernel/srcu.c
77714 index 2b85982..d52ab26 100644
77715 --- a/kernel/srcu.c
77716 +++ b/kernel/srcu.c
77717 @@ -305,9 +305,9 @@ int __srcu_read_lock(struct srcu_struct *sp)
77718 preempt_disable();
77719 idx = rcu_dereference_index_check(sp->completed,
77720 rcu_read_lock_sched_held()) & 0x1;
77721 - ACCESS_ONCE(this_cpu_ptr(sp->per_cpu_ref)->c[idx]) += 1;
77722 + ACCESS_ONCE_RW(this_cpu_ptr(sp->per_cpu_ref)->c[idx]) += 1;
77723 smp_mb(); /* B */ /* Avoid leaking the critical section. */
77724 - ACCESS_ONCE(this_cpu_ptr(sp->per_cpu_ref)->seq[idx]) += 1;
77725 + ACCESS_ONCE_RW(this_cpu_ptr(sp->per_cpu_ref)->seq[idx]) += 1;
77726 preempt_enable();
77727 return idx;
77728 }
77729 @@ -323,7 +323,7 @@ void __srcu_read_unlock(struct srcu_struct *sp, int idx)
77730 {
77731 preempt_disable();
77732 smp_mb(); /* C */ /* Avoid leaking the critical section. */
77733 - ACCESS_ONCE(this_cpu_ptr(sp->per_cpu_ref)->c[idx]) -= 1;
77734 + ACCESS_ONCE_RW(this_cpu_ptr(sp->per_cpu_ref)->c[idx]) -= 1;
77735 preempt_enable();
77736 }
77737 EXPORT_SYMBOL_GPL(__srcu_read_unlock);
77738 diff --git a/kernel/stop_machine.c b/kernel/stop_machine.c
77739 index 2f194e9..2c05ea9 100644
77740 --- a/kernel/stop_machine.c
77741 +++ b/kernel/stop_machine.c
77742 @@ -362,7 +362,7 @@ static int __cpuinit cpu_stop_cpu_callback(struct notifier_block *nfb,
77743 * cpu notifiers. It currently shares the same priority as sched
77744 * migration_notifier.
77745 */
77746 -static struct notifier_block __cpuinitdata cpu_stop_cpu_notifier = {
77747 +static struct notifier_block cpu_stop_cpu_notifier = {
77748 .notifier_call = cpu_stop_cpu_callback,
77749 .priority = 10,
77750 };
77751 diff --git a/kernel/sys.c b/kernel/sys.c
77752 index 265b376..4e42ef5 100644
77753 --- a/kernel/sys.c
77754 +++ b/kernel/sys.c
77755 @@ -157,6 +157,12 @@ static int set_one_prio(struct task_struct *p, int niceval, int error)
77756 error = -EACCES;
77757 goto out;
77758 }
77759 +
77760 + if (gr_handle_chroot_setpriority(p, niceval)) {
77761 + error = -EACCES;
77762 + goto out;
77763 + }
77764 +
77765 no_nice = security_task_setnice(p, niceval);
77766 if (no_nice) {
77767 error = no_nice;
77768 @@ -595,6 +601,9 @@ SYSCALL_DEFINE2(setregid, gid_t, rgid, gid_t, egid)
77769 goto error;
77770 }
77771
77772 + if (gr_check_group_change(new->gid, new->egid, INVALID_GID))
77773 + goto error;
77774 +
77775 if (rgid != (gid_t) -1 ||
77776 (egid != (gid_t) -1 && !gid_eq(kegid, old->gid)))
77777 new->sgid = new->egid;
77778 @@ -630,6 +639,10 @@ SYSCALL_DEFINE1(setgid, gid_t, gid)
77779 old = current_cred();
77780
77781 retval = -EPERM;
77782 +
77783 + if (gr_check_group_change(kgid, kgid, kgid))
77784 + goto error;
77785 +
77786 if (nsown_capable(CAP_SETGID))
77787 new->gid = new->egid = new->sgid = new->fsgid = kgid;
77788 else if (gid_eq(kgid, old->gid) || gid_eq(kgid, old->sgid))
77789 @@ -647,7 +660,7 @@ error:
77790 /*
77791 * change the user struct in a credentials set to match the new UID
77792 */
77793 -static int set_user(struct cred *new)
77794 +int set_user(struct cred *new)
77795 {
77796 struct user_struct *new_user;
77797
77798 @@ -727,6 +740,9 @@ SYSCALL_DEFINE2(setreuid, uid_t, ruid, uid_t, euid)
77799 goto error;
77800 }
77801
77802 + if (gr_check_user_change(new->uid, new->euid, INVALID_UID))
77803 + goto error;
77804 +
77805 if (!uid_eq(new->uid, old->uid)) {
77806 retval = set_user(new);
77807 if (retval < 0)
77808 @@ -777,6 +793,12 @@ SYSCALL_DEFINE1(setuid, uid_t, uid)
77809 old = current_cred();
77810
77811 retval = -EPERM;
77812 +
77813 + if (gr_check_crash_uid(kuid))
77814 + goto error;
77815 + if (gr_check_user_change(kuid, kuid, kuid))
77816 + goto error;
77817 +
77818 if (nsown_capable(CAP_SETUID)) {
77819 new->suid = new->uid = kuid;
77820 if (!uid_eq(kuid, old->uid)) {
77821 @@ -846,6 +868,9 @@ SYSCALL_DEFINE3(setresuid, uid_t, ruid, uid_t, euid, uid_t, suid)
77822 goto error;
77823 }
77824
77825 + if (gr_check_user_change(kruid, keuid, INVALID_UID))
77826 + goto error;
77827 +
77828 if (ruid != (uid_t) -1) {
77829 new->uid = kruid;
77830 if (!uid_eq(kruid, old->uid)) {
77831 @@ -928,6 +953,9 @@ SYSCALL_DEFINE3(setresgid, gid_t, rgid, gid_t, egid, gid_t, sgid)
77832 goto error;
77833 }
77834
77835 + if (gr_check_group_change(krgid, kegid, INVALID_GID))
77836 + goto error;
77837 +
77838 if (rgid != (gid_t) -1)
77839 new->gid = krgid;
77840 if (egid != (gid_t) -1)
77841 @@ -981,6 +1009,9 @@ SYSCALL_DEFINE1(setfsuid, uid_t, uid)
77842 if (!uid_valid(kuid))
77843 return old_fsuid;
77844
77845 + if (gr_check_user_change(INVALID_UID, INVALID_UID, kuid))
77846 + goto error;
77847 +
77848 new = prepare_creds();
77849 if (!new)
77850 return old_fsuid;
77851 @@ -995,6 +1026,7 @@ SYSCALL_DEFINE1(setfsuid, uid_t, uid)
77852 }
77853 }
77854
77855 +error:
77856 abort_creds(new);
77857 return old_fsuid;
77858
77859 @@ -1027,12 +1059,16 @@ SYSCALL_DEFINE1(setfsgid, gid_t, gid)
77860 if (gid_eq(kgid, old->gid) || gid_eq(kgid, old->egid) ||
77861 gid_eq(kgid, old->sgid) || gid_eq(kgid, old->fsgid) ||
77862 nsown_capable(CAP_SETGID)) {
77863 + if (gr_check_group_change(INVALID_GID, INVALID_GID, kgid))
77864 + goto error;
77865 +
77866 if (!gid_eq(kgid, old->fsgid)) {
77867 new->fsgid = kgid;
77868 goto change_okay;
77869 }
77870 }
77871
77872 +error:
77873 abort_creds(new);
77874 return old_fsgid;
77875
77876 @@ -1340,19 +1376,19 @@ SYSCALL_DEFINE1(olduname, struct oldold_utsname __user *, name)
77877 return -EFAULT;
77878
77879 down_read(&uts_sem);
77880 - error = __copy_to_user(&name->sysname, &utsname()->sysname,
77881 + error = __copy_to_user(name->sysname, &utsname()->sysname,
77882 __OLD_UTS_LEN);
77883 error |= __put_user(0, name->sysname + __OLD_UTS_LEN);
77884 - error |= __copy_to_user(&name->nodename, &utsname()->nodename,
77885 + error |= __copy_to_user(name->nodename, &utsname()->nodename,
77886 __OLD_UTS_LEN);
77887 error |= __put_user(0, name->nodename + __OLD_UTS_LEN);
77888 - error |= __copy_to_user(&name->release, &utsname()->release,
77889 + error |= __copy_to_user(name->release, &utsname()->release,
77890 __OLD_UTS_LEN);
77891 error |= __put_user(0, name->release + __OLD_UTS_LEN);
77892 - error |= __copy_to_user(&name->version, &utsname()->version,
77893 + error |= __copy_to_user(name->version, &utsname()->version,
77894 __OLD_UTS_LEN);
77895 error |= __put_user(0, name->version + __OLD_UTS_LEN);
77896 - error |= __copy_to_user(&name->machine, &utsname()->machine,
77897 + error |= __copy_to_user(name->machine, &utsname()->machine,
77898 __OLD_UTS_LEN);
77899 error |= __put_user(0, name->machine + __OLD_UTS_LEN);
77900 up_read(&uts_sem);
77901 @@ -2026,7 +2062,7 @@ SYSCALL_DEFINE5(prctl, int, option, unsigned long, arg2, unsigned long, arg3,
77902 error = get_dumpable(me->mm);
77903 break;
77904 case PR_SET_DUMPABLE:
77905 - if (arg2 < 0 || arg2 > 1) {
77906 + if (arg2 > 1) {
77907 error = -EINVAL;
77908 break;
77909 }
77910 diff --git a/kernel/sysctl.c b/kernel/sysctl.c
77911 index c88878d..e4fa5d1 100644
77912 --- a/kernel/sysctl.c
77913 +++ b/kernel/sysctl.c
77914 @@ -92,7 +92,6 @@
77915
77916
77917 #if defined(CONFIG_SYSCTL)
77918 -
77919 /* External variables not in a header file. */
77920 extern int sysctl_overcommit_memory;
77921 extern int sysctl_overcommit_ratio;
77922 @@ -172,10 +171,8 @@ static int proc_taint(struct ctl_table *table, int write,
77923 void __user *buffer, size_t *lenp, loff_t *ppos);
77924 #endif
77925
77926 -#ifdef CONFIG_PRINTK
77927 static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
77928 void __user *buffer, size_t *lenp, loff_t *ppos);
77929 -#endif
77930
77931 static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write,
77932 void __user *buffer, size_t *lenp, loff_t *ppos);
77933 @@ -206,6 +203,8 @@ static int sysrq_sysctl_handler(ctl_table *table, int write,
77934
77935 #endif
77936
77937 +extern struct ctl_table grsecurity_table[];
77938 +
77939 static struct ctl_table kern_table[];
77940 static struct ctl_table vm_table[];
77941 static struct ctl_table fs_table[];
77942 @@ -220,6 +219,20 @@ extern struct ctl_table epoll_table[];
77943 int sysctl_legacy_va_layout;
77944 #endif
77945
77946 +#ifdef CONFIG_PAX_SOFTMODE
77947 +static ctl_table pax_table[] = {
77948 + {
77949 + .procname = "softmode",
77950 + .data = &pax_softmode,
77951 + .maxlen = sizeof(unsigned int),
77952 + .mode = 0600,
77953 + .proc_handler = &proc_dointvec,
77954 + },
77955 +
77956 + { }
77957 +};
77958 +#endif
77959 +
77960 /* The default sysctl tables: */
77961
77962 static struct ctl_table sysctl_base_table[] = {
77963 @@ -268,6 +281,22 @@ static int max_extfrag_threshold = 1000;
77964 #endif
77965
77966 static struct ctl_table kern_table[] = {
77967 +#if defined(CONFIG_GRKERNSEC_SYSCTL) || defined(CONFIG_GRKERNSEC_ROFS)
77968 + {
77969 + .procname = "grsecurity",
77970 + .mode = 0500,
77971 + .child = grsecurity_table,
77972 + },
77973 +#endif
77974 +
77975 +#ifdef CONFIG_PAX_SOFTMODE
77976 + {
77977 + .procname = "pax",
77978 + .mode = 0500,
77979 + .child = pax_table,
77980 + },
77981 +#endif
77982 +
77983 {
77984 .procname = "sched_child_runs_first",
77985 .data = &sysctl_sched_child_runs_first,
77986 @@ -593,7 +622,7 @@ static struct ctl_table kern_table[] = {
77987 .data = &modprobe_path,
77988 .maxlen = KMOD_PATH_LEN,
77989 .mode = 0644,
77990 - .proc_handler = proc_dostring,
77991 + .proc_handler = proc_dostring_modpriv,
77992 },
77993 {
77994 .procname = "modules_disabled",
77995 @@ -760,16 +789,20 @@ static struct ctl_table kern_table[] = {
77996 .extra1 = &zero,
77997 .extra2 = &one,
77998 },
77999 +#endif
78000 {
78001 .procname = "kptr_restrict",
78002 .data = &kptr_restrict,
78003 .maxlen = sizeof(int),
78004 .mode = 0644,
78005 .proc_handler = proc_dointvec_minmax_sysadmin,
78006 +#ifdef CONFIG_GRKERNSEC_HIDESYM
78007 + .extra1 = &two,
78008 +#else
78009 .extra1 = &zero,
78010 +#endif
78011 .extra2 = &two,
78012 },
78013 -#endif
78014 {
78015 .procname = "ngroups_max",
78016 .data = &ngroups_max,
78017 @@ -1266,6 +1299,13 @@ static struct ctl_table vm_table[] = {
78018 .proc_handler = proc_dointvec_minmax,
78019 .extra1 = &zero,
78020 },
78021 + {
78022 + .procname = "heap_stack_gap",
78023 + .data = &sysctl_heap_stack_gap,
78024 + .maxlen = sizeof(sysctl_heap_stack_gap),
78025 + .mode = 0644,
78026 + .proc_handler = proc_doulongvec_minmax,
78027 + },
78028 #else
78029 {
78030 .procname = "nr_trim_pages",
78031 @@ -1716,6 +1756,16 @@ int proc_dostring(struct ctl_table *table, int write,
78032 buffer, lenp, ppos);
78033 }
78034
78035 +int proc_dostring_modpriv(struct ctl_table *table, int write,
78036 + void __user *buffer, size_t *lenp, loff_t *ppos)
78037 +{
78038 + if (write && !capable(CAP_SYS_MODULE))
78039 + return -EPERM;
78040 +
78041 + return _proc_do_string(table->data, table->maxlen, write,
78042 + buffer, lenp, ppos);
78043 +}
78044 +
78045 static size_t proc_skip_spaces(char **buf)
78046 {
78047 size_t ret;
78048 @@ -1821,6 +1871,8 @@ static int proc_put_long(void __user **buf, size_t *size, unsigned long val,
78049 len = strlen(tmp);
78050 if (len > *size)
78051 len = *size;
78052 + if (len > sizeof(tmp))
78053 + len = sizeof(tmp);
78054 if (copy_to_user(*buf, tmp, len))
78055 return -EFAULT;
78056 *size -= len;
78057 @@ -1985,7 +2037,7 @@ int proc_dointvec(struct ctl_table *table, int write,
78058 static int proc_taint(struct ctl_table *table, int write,
78059 void __user *buffer, size_t *lenp, loff_t *ppos)
78060 {
78061 - struct ctl_table t;
78062 + ctl_table_no_const t;
78063 unsigned long tmptaint = get_taint();
78064 int err;
78065
78066 @@ -2013,7 +2065,6 @@ static int proc_taint(struct ctl_table *table, int write,
78067 return err;
78068 }
78069
78070 -#ifdef CONFIG_PRINTK
78071 static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
78072 void __user *buffer, size_t *lenp, loff_t *ppos)
78073 {
78074 @@ -2022,7 +2073,6 @@ static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
78075
78076 return proc_dointvec_minmax(table, write, buffer, lenp, ppos);
78077 }
78078 -#endif
78079
78080 struct do_proc_dointvec_minmax_conv_param {
78081 int *min;
78082 @@ -2169,8 +2219,11 @@ static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int
78083 *i = val;
78084 } else {
78085 val = convdiv * (*i) / convmul;
78086 - if (!first)
78087 + if (!first) {
78088 err = proc_put_char(&buffer, &left, '\t');
78089 + if (err)
78090 + break;
78091 + }
78092 err = proc_put_long(&buffer, &left, val, false);
78093 if (err)
78094 break;
78095 @@ -2562,6 +2615,12 @@ int proc_dostring(struct ctl_table *table, int write,
78096 return -ENOSYS;
78097 }
78098
78099 +int proc_dostring_modpriv(struct ctl_table *table, int write,
78100 + void __user *buffer, size_t *lenp, loff_t *ppos)
78101 +{
78102 + return -ENOSYS;
78103 +}
78104 +
78105 int proc_dointvec(struct ctl_table *table, int write,
78106 void __user *buffer, size_t *lenp, loff_t *ppos)
78107 {
78108 @@ -2618,5 +2677,6 @@ EXPORT_SYMBOL(proc_dointvec_minmax);
78109 EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
78110 EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
78111 EXPORT_SYMBOL(proc_dostring);
78112 +EXPORT_SYMBOL(proc_dostring_modpriv);
78113 EXPORT_SYMBOL(proc_doulongvec_minmax);
78114 EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);
78115 diff --git a/kernel/sysctl_binary.c b/kernel/sysctl_binary.c
78116 index 0ddf3a0..a199f50 100644
78117 --- a/kernel/sysctl_binary.c
78118 +++ b/kernel/sysctl_binary.c
78119 @@ -989,7 +989,7 @@ static ssize_t bin_intvec(struct file *file,
78120 int i;
78121
78122 set_fs(KERNEL_DS);
78123 - result = vfs_read(file, buffer, BUFSZ - 1, &pos);
78124 + result = vfs_read(file, (char __force_user *)buffer, BUFSZ - 1, &pos);
78125 set_fs(old_fs);
78126 if (result < 0)
78127 goto out_kfree;
78128 @@ -1034,7 +1034,7 @@ static ssize_t bin_intvec(struct file *file,
78129 }
78130
78131 set_fs(KERNEL_DS);
78132 - result = vfs_write(file, buffer, str - buffer, &pos);
78133 + result = vfs_write(file, (const char __force_user *)buffer, str - buffer, &pos);
78134 set_fs(old_fs);
78135 if (result < 0)
78136 goto out_kfree;
78137 @@ -1067,7 +1067,7 @@ static ssize_t bin_ulongvec(struct file *file,
78138 int i;
78139
78140 set_fs(KERNEL_DS);
78141 - result = vfs_read(file, buffer, BUFSZ - 1, &pos);
78142 + result = vfs_read(file, (char __force_user *)buffer, BUFSZ - 1, &pos);
78143 set_fs(old_fs);
78144 if (result < 0)
78145 goto out_kfree;
78146 @@ -1112,7 +1112,7 @@ static ssize_t bin_ulongvec(struct file *file,
78147 }
78148
78149 set_fs(KERNEL_DS);
78150 - result = vfs_write(file, buffer, str - buffer, &pos);
78151 + result = vfs_write(file, (const char __force_user *)buffer, str - buffer, &pos);
78152 set_fs(old_fs);
78153 if (result < 0)
78154 goto out_kfree;
78155 @@ -1138,7 +1138,7 @@ static ssize_t bin_uuid(struct file *file,
78156 int i;
78157
78158 set_fs(KERNEL_DS);
78159 - result = vfs_read(file, buf, sizeof(buf) - 1, &pos);
78160 + result = vfs_read(file, (char __force_user *)buf, sizeof(buf) - 1, &pos);
78161 set_fs(old_fs);
78162 if (result < 0)
78163 goto out;
78164 @@ -1185,7 +1185,7 @@ static ssize_t bin_dn_node_address(struct file *file,
78165 __le16 dnaddr;
78166
78167 set_fs(KERNEL_DS);
78168 - result = vfs_read(file, buf, sizeof(buf) - 1, &pos);
78169 + result = vfs_read(file, (char __force_user *)buf, sizeof(buf) - 1, &pos);
78170 set_fs(old_fs);
78171 if (result < 0)
78172 goto out;
78173 @@ -1234,7 +1234,7 @@ static ssize_t bin_dn_node_address(struct file *file,
78174 le16_to_cpu(dnaddr) & 0x3ff);
78175
78176 set_fs(KERNEL_DS);
78177 - result = vfs_write(file, buf, len, &pos);
78178 + result = vfs_write(file, (const char __force_user *)buf, len, &pos);
78179 set_fs(old_fs);
78180 if (result < 0)
78181 goto out;
78182 diff --git a/kernel/taskstats.c b/kernel/taskstats.c
78183 index 145bb4d..b2aa969 100644
78184 --- a/kernel/taskstats.c
78185 +++ b/kernel/taskstats.c
78186 @@ -28,9 +28,12 @@
78187 #include <linux/fs.h>
78188 #include <linux/file.h>
78189 #include <linux/pid_namespace.h>
78190 +#include <linux/grsecurity.h>
78191 #include <net/genetlink.h>
78192 #include <linux/atomic.h>
78193
78194 +extern int gr_is_taskstats_denied(int pid);
78195 +
78196 /*
78197 * Maximum length of a cpumask that can be specified in
78198 * the TASKSTATS_CMD_ATTR_REGISTER/DEREGISTER_CPUMASK attribute
78199 @@ -570,6 +573,9 @@ err:
78200
78201 static int taskstats_user_cmd(struct sk_buff *skb, struct genl_info *info)
78202 {
78203 + if (gr_is_taskstats_denied(current->pid))
78204 + return -EACCES;
78205 +
78206 if (info->attrs[TASKSTATS_CMD_ATTR_REGISTER_CPUMASK])
78207 return cmd_attr_register_cpumask(info);
78208 else if (info->attrs[TASKSTATS_CMD_ATTR_DEREGISTER_CPUMASK])
78209 diff --git a/kernel/time.c b/kernel/time.c
78210 index d226c6a..2f0d217 100644
78211 --- a/kernel/time.c
78212 +++ b/kernel/time.c
78213 @@ -163,6 +163,11 @@ int do_sys_settimeofday(const struct timespec *tv, const struct timezone *tz)
78214 return error;
78215
78216 if (tz) {
78217 + /* we log in do_settimeofday called below, so don't log twice
78218 + */
78219 + if (!tv)
78220 + gr_log_timechange();
78221 +
78222 sys_tz = *tz;
78223 update_vsyscall_tz();
78224 if (firsttime) {
78225 @@ -493,7 +498,7 @@ EXPORT_SYMBOL(usecs_to_jiffies);
78226 * The >> (NSEC_JIFFIE_SC - SEC_JIFFIE_SC) converts the scaled nsec
78227 * value to a scaled second value.
78228 */
78229 -unsigned long
78230 +unsigned long __intentional_overflow(-1)
78231 timespec_to_jiffies(const struct timespec *value)
78232 {
78233 unsigned long sec = value->tv_sec;
78234 diff --git a/kernel/time/alarmtimer.c b/kernel/time/alarmtimer.c
78235 index f11d83b..d016d91 100644
78236 --- a/kernel/time/alarmtimer.c
78237 +++ b/kernel/time/alarmtimer.c
78238 @@ -750,7 +750,7 @@ static int __init alarmtimer_init(void)
78239 struct platform_device *pdev;
78240 int error = 0;
78241 int i;
78242 - struct k_clock alarm_clock = {
78243 + static struct k_clock alarm_clock = {
78244 .clock_getres = alarm_clock_getres,
78245 .clock_get = alarm_clock_get,
78246 .timer_create = alarm_timer_create,
78247 diff --git a/kernel/time/tick-broadcast.c b/kernel/time/tick-broadcast.c
78248 index f113755..ec24223 100644
78249 --- a/kernel/time/tick-broadcast.c
78250 +++ b/kernel/time/tick-broadcast.c
78251 @@ -115,7 +115,7 @@ int tick_device_uses_broadcast(struct clock_event_device *dev, int cpu)
78252 * then clear the broadcast bit.
78253 */
78254 if (!(dev->features & CLOCK_EVT_FEAT_C3STOP)) {
78255 - int cpu = smp_processor_id();
78256 + cpu = smp_processor_id();
78257
78258 cpumask_clear_cpu(cpu, tick_get_broadcast_mask());
78259 tick_broadcast_clear_oneshot(cpu);
78260 diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
78261 index cbc6acb..3a77191 100644
78262 --- a/kernel/time/timekeeping.c
78263 +++ b/kernel/time/timekeeping.c
78264 @@ -15,6 +15,7 @@
78265 #include <linux/init.h>
78266 #include <linux/mm.h>
78267 #include <linux/sched.h>
78268 +#include <linux/grsecurity.h>
78269 #include <linux/syscore_ops.h>
78270 #include <linux/clocksource.h>
78271 #include <linux/jiffies.h>
78272 @@ -412,6 +413,8 @@ int do_settimeofday(const struct timespec *tv)
78273 if (!timespec_valid_strict(tv))
78274 return -EINVAL;
78275
78276 + gr_log_timechange();
78277 +
78278 write_seqlock_irqsave(&tk->lock, flags);
78279
78280 timekeeping_forward_now(tk);
78281 diff --git a/kernel/time/timer_list.c b/kernel/time/timer_list.c
78282 index af5a7e9..715611a 100644
78283 --- a/kernel/time/timer_list.c
78284 +++ b/kernel/time/timer_list.c
78285 @@ -38,12 +38,16 @@ DECLARE_PER_CPU(struct hrtimer_cpu_base, hrtimer_bases);
78286
78287 static void print_name_offset(struct seq_file *m, void *sym)
78288 {
78289 +#ifdef CONFIG_GRKERNSEC_HIDESYM
78290 + SEQ_printf(m, "<%p>", NULL);
78291 +#else
78292 char symname[KSYM_NAME_LEN];
78293
78294 if (lookup_symbol_name((unsigned long)sym, symname) < 0)
78295 SEQ_printf(m, "<%pK>", sym);
78296 else
78297 SEQ_printf(m, "%s", symname);
78298 +#endif
78299 }
78300
78301 static void
78302 @@ -112,7 +116,11 @@ next_one:
78303 static void
78304 print_base(struct seq_file *m, struct hrtimer_clock_base *base, u64 now)
78305 {
78306 +#ifdef CONFIG_GRKERNSEC_HIDESYM
78307 + SEQ_printf(m, " .base: %p\n", NULL);
78308 +#else
78309 SEQ_printf(m, " .base: %pK\n", base);
78310 +#endif
78311 SEQ_printf(m, " .index: %d\n",
78312 base->index);
78313 SEQ_printf(m, " .resolution: %Lu nsecs\n",
78314 @@ -293,7 +301,11 @@ static int __init init_timer_list_procfs(void)
78315 {
78316 struct proc_dir_entry *pe;
78317
78318 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
78319 + pe = proc_create("timer_list", 0400, NULL, &timer_list_fops);
78320 +#else
78321 pe = proc_create("timer_list", 0444, NULL, &timer_list_fops);
78322 +#endif
78323 if (!pe)
78324 return -ENOMEM;
78325 return 0;
78326 diff --git a/kernel/time/timer_stats.c b/kernel/time/timer_stats.c
78327 index 0b537f2..40d6c20 100644
78328 --- a/kernel/time/timer_stats.c
78329 +++ b/kernel/time/timer_stats.c
78330 @@ -116,7 +116,7 @@ static ktime_t time_start, time_stop;
78331 static unsigned long nr_entries;
78332 static struct entry entries[MAX_ENTRIES];
78333
78334 -static atomic_t overflow_count;
78335 +static atomic_unchecked_t overflow_count;
78336
78337 /*
78338 * The entries are in a hash-table, for fast lookup:
78339 @@ -140,7 +140,7 @@ static void reset_entries(void)
78340 nr_entries = 0;
78341 memset(entries, 0, sizeof(entries));
78342 memset(tstat_hash_table, 0, sizeof(tstat_hash_table));
78343 - atomic_set(&overflow_count, 0);
78344 + atomic_set_unchecked(&overflow_count, 0);
78345 }
78346
78347 static struct entry *alloc_entry(void)
78348 @@ -261,7 +261,7 @@ void timer_stats_update_stats(void *timer, pid_t pid, void *startf,
78349 if (likely(entry))
78350 entry->count++;
78351 else
78352 - atomic_inc(&overflow_count);
78353 + atomic_inc_unchecked(&overflow_count);
78354
78355 out_unlock:
78356 raw_spin_unlock_irqrestore(lock, flags);
78357 @@ -269,12 +269,16 @@ void timer_stats_update_stats(void *timer, pid_t pid, void *startf,
78358
78359 static void print_name_offset(struct seq_file *m, unsigned long addr)
78360 {
78361 +#ifdef CONFIG_GRKERNSEC_HIDESYM
78362 + seq_printf(m, "<%p>", NULL);
78363 +#else
78364 char symname[KSYM_NAME_LEN];
78365
78366 if (lookup_symbol_name(addr, symname) < 0)
78367 - seq_printf(m, "<%p>", (void *)addr);
78368 + seq_printf(m, "<%pK>", (void *)addr);
78369 else
78370 seq_printf(m, "%s", symname);
78371 +#endif
78372 }
78373
78374 static int tstats_show(struct seq_file *m, void *v)
78375 @@ -300,9 +304,9 @@ static int tstats_show(struct seq_file *m, void *v)
78376
78377 seq_puts(m, "Timer Stats Version: v0.2\n");
78378 seq_printf(m, "Sample period: %ld.%03ld s\n", period.tv_sec, ms);
78379 - if (atomic_read(&overflow_count))
78380 + if (atomic_read_unchecked(&overflow_count))
78381 seq_printf(m, "Overflow: %d entries\n",
78382 - atomic_read(&overflow_count));
78383 + atomic_read_unchecked(&overflow_count));
78384
78385 for (i = 0; i < nr_entries; i++) {
78386 entry = entries + i;
78387 @@ -417,7 +421,11 @@ static int __init init_tstats_procfs(void)
78388 {
78389 struct proc_dir_entry *pe;
78390
78391 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
78392 + pe = proc_create("timer_stats", 0600, NULL, &tstats_fops);
78393 +#else
78394 pe = proc_create("timer_stats", 0644, NULL, &tstats_fops);
78395 +#endif
78396 if (!pe)
78397 return -ENOMEM;
78398 return 0;
78399 diff --git a/kernel/timer.c b/kernel/timer.c
78400 index 367d008..5dee98f 100644
78401 --- a/kernel/timer.c
78402 +++ b/kernel/timer.c
78403 @@ -1363,7 +1363,7 @@ void update_process_times(int user_tick)
78404 /*
78405 * This function runs timers and the timer-tq in bottom half context.
78406 */
78407 -static void run_timer_softirq(struct softirq_action *h)
78408 +static void run_timer_softirq(void)
78409 {
78410 struct tvec_base *base = __this_cpu_read(tvec_bases);
78411
78412 @@ -1481,7 +1481,7 @@ static void process_timeout(unsigned long __data)
78413 *
78414 * In all cases the return value is guaranteed to be non-negative.
78415 */
78416 -signed long __sched schedule_timeout(signed long timeout)
78417 +signed long __sched __intentional_overflow(-1) schedule_timeout(signed long timeout)
78418 {
78419 struct timer_list timer;
78420 unsigned long expire;
78421 @@ -1772,7 +1772,7 @@ static int __cpuinit timer_cpu_notify(struct notifier_block *self,
78422 return NOTIFY_OK;
78423 }
78424
78425 -static struct notifier_block __cpuinitdata timers_nb = {
78426 +static struct notifier_block timers_nb = {
78427 .notifier_call = timer_cpu_notify,
78428 };
78429
78430 diff --git a/kernel/trace/blktrace.c b/kernel/trace/blktrace.c
78431 index c0bd030..62a1927 100644
78432 --- a/kernel/trace/blktrace.c
78433 +++ b/kernel/trace/blktrace.c
78434 @@ -317,7 +317,7 @@ static ssize_t blk_dropped_read(struct file *filp, char __user *buffer,
78435 struct blk_trace *bt = filp->private_data;
78436 char buf[16];
78437
78438 - snprintf(buf, sizeof(buf), "%u\n", atomic_read(&bt->dropped));
78439 + snprintf(buf, sizeof(buf), "%u\n", atomic_read_unchecked(&bt->dropped));
78440
78441 return simple_read_from_buffer(buffer, count, ppos, buf, strlen(buf));
78442 }
78443 @@ -375,7 +375,7 @@ static int blk_subbuf_start_callback(struct rchan_buf *buf, void *subbuf,
78444 return 1;
78445
78446 bt = buf->chan->private_data;
78447 - atomic_inc(&bt->dropped);
78448 + atomic_inc_unchecked(&bt->dropped);
78449 return 0;
78450 }
78451
78452 @@ -476,7 +476,7 @@ int do_blk_trace_setup(struct request_queue *q, char *name, dev_t dev,
78453
78454 bt->dir = dir;
78455 bt->dev = dev;
78456 - atomic_set(&bt->dropped, 0);
78457 + atomic_set_unchecked(&bt->dropped, 0);
78458
78459 ret = -EIO;
78460 bt->dropped_file = debugfs_create_file("dropped", 0444, dir, bt,
78461 diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
78462 index 43defd1..76da436 100644
78463 --- a/kernel/trace/ftrace.c
78464 +++ b/kernel/trace/ftrace.c
78465 @@ -1874,12 +1874,17 @@ ftrace_code_disable(struct module *mod, struct dyn_ftrace *rec)
78466 if (unlikely(ftrace_disabled))
78467 return 0;
78468
78469 + ret = ftrace_arch_code_modify_prepare();
78470 + FTRACE_WARN_ON(ret);
78471 + if (ret)
78472 + return 0;
78473 +
78474 ret = ftrace_make_nop(mod, rec, MCOUNT_ADDR);
78475 + FTRACE_WARN_ON(ftrace_arch_code_modify_post_process());
78476 if (ret) {
78477 ftrace_bug(ret, ip);
78478 - return 0;
78479 }
78480 - return 1;
78481 + return ret ? 0 : 1;
78482 }
78483
78484 /*
78485 @@ -2965,7 +2970,7 @@ static void ftrace_free_entry_rcu(struct rcu_head *rhp)
78486
78487 int
78488 register_ftrace_function_probe(char *glob, struct ftrace_probe_ops *ops,
78489 - void *data)
78490 + void *data)
78491 {
78492 struct ftrace_func_probe *entry;
78493 struct ftrace_page *pg;
78494 @@ -3832,8 +3837,10 @@ static int ftrace_process_locs(struct module *mod,
78495 if (!count)
78496 return 0;
78497
78498 + pax_open_kernel();
78499 sort(start, count, sizeof(*start),
78500 ftrace_cmp_ips, ftrace_swap_ips);
78501 + pax_close_kernel();
78502
78503 start_pg = ftrace_allocate_pages(count);
78504 if (!start_pg)
78505 @@ -4559,8 +4566,6 @@ ftrace_enable_sysctl(struct ctl_table *table, int write,
78506 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
78507
78508 static int ftrace_graph_active;
78509 -static struct notifier_block ftrace_suspend_notifier;
78510 -
78511 int ftrace_graph_entry_stub(struct ftrace_graph_ent *trace)
78512 {
78513 return 0;
78514 @@ -4704,6 +4709,10 @@ ftrace_suspend_notifier_call(struct notifier_block *bl, unsigned long state,
78515 return NOTIFY_DONE;
78516 }
78517
78518 +static struct notifier_block ftrace_suspend_notifier = {
78519 + .notifier_call = ftrace_suspend_notifier_call
78520 +};
78521 +
78522 int register_ftrace_graph(trace_func_graph_ret_t retfunc,
78523 trace_func_graph_ent_t entryfunc)
78524 {
78525 @@ -4717,7 +4726,6 @@ int register_ftrace_graph(trace_func_graph_ret_t retfunc,
78526 goto out;
78527 }
78528
78529 - ftrace_suspend_notifier.notifier_call = ftrace_suspend_notifier_call;
78530 register_pm_notifier(&ftrace_suspend_notifier);
78531
78532 ftrace_graph_active++;
78533 diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c
78534 index ce8514f..8233573 100644
78535 --- a/kernel/trace/ring_buffer.c
78536 +++ b/kernel/trace/ring_buffer.c
78537 @@ -346,9 +346,9 @@ struct buffer_data_page {
78538 */
78539 struct buffer_page {
78540 struct list_head list; /* list of buffer pages */
78541 - local_t write; /* index for next write */
78542 + local_unchecked_t write; /* index for next write */
78543 unsigned read; /* index for next read */
78544 - local_t entries; /* entries on this page */
78545 + local_unchecked_t entries; /* entries on this page */
78546 unsigned long real_end; /* real end of data */
78547 struct buffer_data_page *page; /* Actual data page */
78548 };
78549 @@ -461,8 +461,8 @@ struct ring_buffer_per_cpu {
78550 unsigned long last_overrun;
78551 local_t entries_bytes;
78552 local_t entries;
78553 - local_t overrun;
78554 - local_t commit_overrun;
78555 + local_unchecked_t overrun;
78556 + local_unchecked_t commit_overrun;
78557 local_t dropped_events;
78558 local_t committing;
78559 local_t commits;
78560 @@ -861,8 +861,8 @@ static int rb_tail_page_update(struct ring_buffer_per_cpu *cpu_buffer,
78561 *
78562 * We add a counter to the write field to denote this.
78563 */
78564 - old_write = local_add_return(RB_WRITE_INTCNT, &next_page->write);
78565 - old_entries = local_add_return(RB_WRITE_INTCNT, &next_page->entries);
78566 + old_write = local_add_return_unchecked(RB_WRITE_INTCNT, &next_page->write);
78567 + old_entries = local_add_return_unchecked(RB_WRITE_INTCNT, &next_page->entries);
78568
78569 /*
78570 * Just make sure we have seen our old_write and synchronize
78571 @@ -890,8 +890,8 @@ static int rb_tail_page_update(struct ring_buffer_per_cpu *cpu_buffer,
78572 * cmpxchg to only update if an interrupt did not already
78573 * do it for us. If the cmpxchg fails, we don't care.
78574 */
78575 - (void)local_cmpxchg(&next_page->write, old_write, val);
78576 - (void)local_cmpxchg(&next_page->entries, old_entries, eval);
78577 + (void)local_cmpxchg_unchecked(&next_page->write, old_write, val);
78578 + (void)local_cmpxchg_unchecked(&next_page->entries, old_entries, eval);
78579
78580 /*
78581 * No need to worry about races with clearing out the commit.
78582 @@ -1250,12 +1250,12 @@ static void rb_reset_cpu(struct ring_buffer_per_cpu *cpu_buffer);
78583
78584 static inline unsigned long rb_page_entries(struct buffer_page *bpage)
78585 {
78586 - return local_read(&bpage->entries) & RB_WRITE_MASK;
78587 + return local_read_unchecked(&bpage->entries) & RB_WRITE_MASK;
78588 }
78589
78590 static inline unsigned long rb_page_write(struct buffer_page *bpage)
78591 {
78592 - return local_read(&bpage->write) & RB_WRITE_MASK;
78593 + return local_read_unchecked(&bpage->write) & RB_WRITE_MASK;
78594 }
78595
78596 static int
78597 @@ -1350,7 +1350,7 @@ rb_remove_pages(struct ring_buffer_per_cpu *cpu_buffer, unsigned int nr_pages)
78598 * bytes consumed in ring buffer from here.
78599 * Increment overrun to account for the lost events.
78600 */
78601 - local_add(page_entries, &cpu_buffer->overrun);
78602 + local_add_unchecked(page_entries, &cpu_buffer->overrun);
78603 local_sub(BUF_PAGE_SIZE, &cpu_buffer->entries_bytes);
78604 }
78605
78606 @@ -1906,7 +1906,7 @@ rb_handle_head_page(struct ring_buffer_per_cpu *cpu_buffer,
78607 * it is our responsibility to update
78608 * the counters.
78609 */
78610 - local_add(entries, &cpu_buffer->overrun);
78611 + local_add_unchecked(entries, &cpu_buffer->overrun);
78612 local_sub(BUF_PAGE_SIZE, &cpu_buffer->entries_bytes);
78613
78614 /*
78615 @@ -2056,7 +2056,7 @@ rb_reset_tail(struct ring_buffer_per_cpu *cpu_buffer,
78616 if (tail == BUF_PAGE_SIZE)
78617 tail_page->real_end = 0;
78618
78619 - local_sub(length, &tail_page->write);
78620 + local_sub_unchecked(length, &tail_page->write);
78621 return;
78622 }
78623
78624 @@ -2091,7 +2091,7 @@ rb_reset_tail(struct ring_buffer_per_cpu *cpu_buffer,
78625 rb_event_set_padding(event);
78626
78627 /* Set the write back to the previous setting */
78628 - local_sub(length, &tail_page->write);
78629 + local_sub_unchecked(length, &tail_page->write);
78630 return;
78631 }
78632
78633 @@ -2103,7 +2103,7 @@ rb_reset_tail(struct ring_buffer_per_cpu *cpu_buffer,
78634
78635 /* Set write to end of buffer */
78636 length = (tail + length) - BUF_PAGE_SIZE;
78637 - local_sub(length, &tail_page->write);
78638 + local_sub_unchecked(length, &tail_page->write);
78639 }
78640
78641 /*
78642 @@ -2129,7 +2129,7 @@ rb_move_tail(struct ring_buffer_per_cpu *cpu_buffer,
78643 * about it.
78644 */
78645 if (unlikely(next_page == commit_page)) {
78646 - local_inc(&cpu_buffer->commit_overrun);
78647 + local_inc_unchecked(&cpu_buffer->commit_overrun);
78648 goto out_reset;
78649 }
78650
78651 @@ -2185,7 +2185,7 @@ rb_move_tail(struct ring_buffer_per_cpu *cpu_buffer,
78652 cpu_buffer->tail_page) &&
78653 (cpu_buffer->commit_page ==
78654 cpu_buffer->reader_page))) {
78655 - local_inc(&cpu_buffer->commit_overrun);
78656 + local_inc_unchecked(&cpu_buffer->commit_overrun);
78657 goto out_reset;
78658 }
78659 }
78660 @@ -2233,7 +2233,7 @@ __rb_reserve_next(struct ring_buffer_per_cpu *cpu_buffer,
78661 length += RB_LEN_TIME_EXTEND;
78662
78663 tail_page = cpu_buffer->tail_page;
78664 - write = local_add_return(length, &tail_page->write);
78665 + write = local_add_return_unchecked(length, &tail_page->write);
78666
78667 /* set write to only the index of the write */
78668 write &= RB_WRITE_MASK;
78669 @@ -2250,7 +2250,7 @@ __rb_reserve_next(struct ring_buffer_per_cpu *cpu_buffer,
78670 kmemcheck_annotate_bitfield(event, bitfield);
78671 rb_update_event(cpu_buffer, event, length, add_timestamp, delta);
78672
78673 - local_inc(&tail_page->entries);
78674 + local_inc_unchecked(&tail_page->entries);
78675
78676 /*
78677 * If this is the first commit on the page, then update
78678 @@ -2283,7 +2283,7 @@ rb_try_to_discard(struct ring_buffer_per_cpu *cpu_buffer,
78679
78680 if (bpage->page == (void *)addr && rb_page_write(bpage) == old_index) {
78681 unsigned long write_mask =
78682 - local_read(&bpage->write) & ~RB_WRITE_MASK;
78683 + local_read_unchecked(&bpage->write) & ~RB_WRITE_MASK;
78684 unsigned long event_length = rb_event_length(event);
78685 /*
78686 * This is on the tail page. It is possible that
78687 @@ -2293,7 +2293,7 @@ rb_try_to_discard(struct ring_buffer_per_cpu *cpu_buffer,
78688 */
78689 old_index += write_mask;
78690 new_index += write_mask;
78691 - index = local_cmpxchg(&bpage->write, old_index, new_index);
78692 + index = local_cmpxchg_unchecked(&bpage->write, old_index, new_index);
78693 if (index == old_index) {
78694 /* update counters */
78695 local_sub(event_length, &cpu_buffer->entries_bytes);
78696 @@ -2632,7 +2632,7 @@ rb_decrement_entry(struct ring_buffer_per_cpu *cpu_buffer,
78697
78698 /* Do the likely case first */
78699 if (likely(bpage->page == (void *)addr)) {
78700 - local_dec(&bpage->entries);
78701 + local_dec_unchecked(&bpage->entries);
78702 return;
78703 }
78704
78705 @@ -2644,7 +2644,7 @@ rb_decrement_entry(struct ring_buffer_per_cpu *cpu_buffer,
78706 start = bpage;
78707 do {
78708 if (bpage->page == (void *)addr) {
78709 - local_dec(&bpage->entries);
78710 + local_dec_unchecked(&bpage->entries);
78711 return;
78712 }
78713 rb_inc_page(cpu_buffer, &bpage);
78714 @@ -2926,7 +2926,7 @@ static inline unsigned long
78715 rb_num_of_entries(struct ring_buffer_per_cpu *cpu_buffer)
78716 {
78717 return local_read(&cpu_buffer->entries) -
78718 - (local_read(&cpu_buffer->overrun) + cpu_buffer->read);
78719 + (local_read_unchecked(&cpu_buffer->overrun) + cpu_buffer->read);
78720 }
78721
78722 /**
78723 @@ -3015,7 +3015,7 @@ unsigned long ring_buffer_overrun_cpu(struct ring_buffer *buffer, int cpu)
78724 return 0;
78725
78726 cpu_buffer = buffer->buffers[cpu];
78727 - ret = local_read(&cpu_buffer->overrun);
78728 + ret = local_read_unchecked(&cpu_buffer->overrun);
78729
78730 return ret;
78731 }
78732 @@ -3038,7 +3038,7 @@ ring_buffer_commit_overrun_cpu(struct ring_buffer *buffer, int cpu)
78733 return 0;
78734
78735 cpu_buffer = buffer->buffers[cpu];
78736 - ret = local_read(&cpu_buffer->commit_overrun);
78737 + ret = local_read_unchecked(&cpu_buffer->commit_overrun);
78738
78739 return ret;
78740 }
78741 @@ -3105,7 +3105,7 @@ unsigned long ring_buffer_overruns(struct ring_buffer *buffer)
78742 /* if you care about this being correct, lock the buffer */
78743 for_each_buffer_cpu(buffer, cpu) {
78744 cpu_buffer = buffer->buffers[cpu];
78745 - overruns += local_read(&cpu_buffer->overrun);
78746 + overruns += local_read_unchecked(&cpu_buffer->overrun);
78747 }
78748
78749 return overruns;
78750 @@ -3281,8 +3281,8 @@ rb_get_reader_page(struct ring_buffer_per_cpu *cpu_buffer)
78751 /*
78752 * Reset the reader page to size zero.
78753 */
78754 - local_set(&cpu_buffer->reader_page->write, 0);
78755 - local_set(&cpu_buffer->reader_page->entries, 0);
78756 + local_set_unchecked(&cpu_buffer->reader_page->write, 0);
78757 + local_set_unchecked(&cpu_buffer->reader_page->entries, 0);
78758 local_set(&cpu_buffer->reader_page->page->commit, 0);
78759 cpu_buffer->reader_page->real_end = 0;
78760
78761 @@ -3316,7 +3316,7 @@ rb_get_reader_page(struct ring_buffer_per_cpu *cpu_buffer)
78762 * want to compare with the last_overrun.
78763 */
78764 smp_mb();
78765 - overwrite = local_read(&(cpu_buffer->overrun));
78766 + overwrite = local_read_unchecked(&(cpu_buffer->overrun));
78767
78768 /*
78769 * Here's the tricky part.
78770 @@ -3886,8 +3886,8 @@ rb_reset_cpu(struct ring_buffer_per_cpu *cpu_buffer)
78771
78772 cpu_buffer->head_page
78773 = list_entry(cpu_buffer->pages, struct buffer_page, list);
78774 - local_set(&cpu_buffer->head_page->write, 0);
78775 - local_set(&cpu_buffer->head_page->entries, 0);
78776 + local_set_unchecked(&cpu_buffer->head_page->write, 0);
78777 + local_set_unchecked(&cpu_buffer->head_page->entries, 0);
78778 local_set(&cpu_buffer->head_page->page->commit, 0);
78779
78780 cpu_buffer->head_page->read = 0;
78781 @@ -3897,14 +3897,14 @@ rb_reset_cpu(struct ring_buffer_per_cpu *cpu_buffer)
78782
78783 INIT_LIST_HEAD(&cpu_buffer->reader_page->list);
78784 INIT_LIST_HEAD(&cpu_buffer->new_pages);
78785 - local_set(&cpu_buffer->reader_page->write, 0);
78786 - local_set(&cpu_buffer->reader_page->entries, 0);
78787 + local_set_unchecked(&cpu_buffer->reader_page->write, 0);
78788 + local_set_unchecked(&cpu_buffer->reader_page->entries, 0);
78789 local_set(&cpu_buffer->reader_page->page->commit, 0);
78790 cpu_buffer->reader_page->read = 0;
78791
78792 local_set(&cpu_buffer->entries_bytes, 0);
78793 - local_set(&cpu_buffer->overrun, 0);
78794 - local_set(&cpu_buffer->commit_overrun, 0);
78795 + local_set_unchecked(&cpu_buffer->overrun, 0);
78796 + local_set_unchecked(&cpu_buffer->commit_overrun, 0);
78797 local_set(&cpu_buffer->dropped_events, 0);
78798 local_set(&cpu_buffer->entries, 0);
78799 local_set(&cpu_buffer->committing, 0);
78800 @@ -4308,8 +4308,8 @@ int ring_buffer_read_page(struct ring_buffer *buffer,
78801 rb_init_page(bpage);
78802 bpage = reader->page;
78803 reader->page = *data_page;
78804 - local_set(&reader->write, 0);
78805 - local_set(&reader->entries, 0);
78806 + local_set_unchecked(&reader->write, 0);
78807 + local_set_unchecked(&reader->entries, 0);
78808 reader->read = 0;
78809 *data_page = bpage;
78810
78811 diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
78812 index 3c13e46..883d039 100644
78813 --- a/kernel/trace/trace.c
78814 +++ b/kernel/trace/trace.c
78815 @@ -4465,10 +4465,9 @@ static const struct file_operations tracing_dyn_info_fops = {
78816 };
78817 #endif
78818
78819 -static struct dentry *d_tracer;
78820 -
78821 struct dentry *tracing_init_dentry(void)
78822 {
78823 + static struct dentry *d_tracer;
78824 static int once;
78825
78826 if (d_tracer)
78827 @@ -4488,10 +4487,9 @@ struct dentry *tracing_init_dentry(void)
78828 return d_tracer;
78829 }
78830
78831 -static struct dentry *d_percpu;
78832 -
78833 struct dentry *tracing_dentry_percpu(void)
78834 {
78835 + static struct dentry *d_percpu;
78836 static int once;
78837 struct dentry *d_tracer;
78838
78839 diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c
78840 index 880073d..42db7c3 100644
78841 --- a/kernel/trace/trace_events.c
78842 +++ b/kernel/trace/trace_events.c
78843 @@ -1330,10 +1330,6 @@ static LIST_HEAD(ftrace_module_file_list);
78844 struct ftrace_module_file_ops {
78845 struct list_head list;
78846 struct module *mod;
78847 - struct file_operations id;
78848 - struct file_operations enable;
78849 - struct file_operations format;
78850 - struct file_operations filter;
78851 };
78852
78853 static struct ftrace_module_file_ops *
78854 @@ -1354,17 +1350,12 @@ trace_create_file_ops(struct module *mod)
78855
78856 file_ops->mod = mod;
78857
78858 - file_ops->id = ftrace_event_id_fops;
78859 - file_ops->id.owner = mod;
78860 -
78861 - file_ops->enable = ftrace_enable_fops;
78862 - file_ops->enable.owner = mod;
78863 -
78864 - file_ops->filter = ftrace_event_filter_fops;
78865 - file_ops->filter.owner = mod;
78866 -
78867 - file_ops->format = ftrace_event_format_fops;
78868 - file_ops->format.owner = mod;
78869 + pax_open_kernel();
78870 + mod->trace_id.owner = mod;
78871 + mod->trace_enable.owner = mod;
78872 + mod->trace_filter.owner = mod;
78873 + mod->trace_format.owner = mod;
78874 + pax_close_kernel();
78875
78876 list_add(&file_ops->list, &ftrace_module_file_list);
78877
78878 @@ -1388,8 +1379,8 @@ static void trace_module_add_events(struct module *mod)
78879
78880 for_each_event(call, start, end) {
78881 __trace_add_event_call(*call, mod,
78882 - &file_ops->id, &file_ops->enable,
78883 - &file_ops->filter, &file_ops->format);
78884 + &mod->trace_id, &mod->trace_enable,
78885 + &mod->trace_filter, &mod->trace_format);
78886 }
78887 }
78888
78889 diff --git a/kernel/trace/trace_mmiotrace.c b/kernel/trace/trace_mmiotrace.c
78890 index fd3c8aa..5f324a6 100644
78891 --- a/kernel/trace/trace_mmiotrace.c
78892 +++ b/kernel/trace/trace_mmiotrace.c
78893 @@ -24,7 +24,7 @@ struct header_iter {
78894 static struct trace_array *mmio_trace_array;
78895 static bool overrun_detected;
78896 static unsigned long prev_overruns;
78897 -static atomic_t dropped_count;
78898 +static atomic_unchecked_t dropped_count;
78899
78900 static void mmio_reset_data(struct trace_array *tr)
78901 {
78902 @@ -127,7 +127,7 @@ static void mmio_close(struct trace_iterator *iter)
78903
78904 static unsigned long count_overruns(struct trace_iterator *iter)
78905 {
78906 - unsigned long cnt = atomic_xchg(&dropped_count, 0);
78907 + unsigned long cnt = atomic_xchg_unchecked(&dropped_count, 0);
78908 unsigned long over = ring_buffer_overruns(iter->tr->buffer);
78909
78910 if (over > prev_overruns)
78911 @@ -317,7 +317,7 @@ static void __trace_mmiotrace_rw(struct trace_array *tr,
78912 event = trace_buffer_lock_reserve(buffer, TRACE_MMIO_RW,
78913 sizeof(*entry), 0, pc);
78914 if (!event) {
78915 - atomic_inc(&dropped_count);
78916 + atomic_inc_unchecked(&dropped_count);
78917 return;
78918 }
78919 entry = ring_buffer_event_data(event);
78920 @@ -347,7 +347,7 @@ static void __trace_mmiotrace_map(struct trace_array *tr,
78921 event = trace_buffer_lock_reserve(buffer, TRACE_MMIO_MAP,
78922 sizeof(*entry), 0, pc);
78923 if (!event) {
78924 - atomic_inc(&dropped_count);
78925 + atomic_inc_unchecked(&dropped_count);
78926 return;
78927 }
78928 entry = ring_buffer_event_data(event);
78929 diff --git a/kernel/trace/trace_output.c b/kernel/trace/trace_output.c
78930 index 194d796..76edb8f 100644
78931 --- a/kernel/trace/trace_output.c
78932 +++ b/kernel/trace/trace_output.c
78933 @@ -278,7 +278,7 @@ int trace_seq_path(struct trace_seq *s, const struct path *path)
78934
78935 p = d_path(path, s->buffer + s->len, PAGE_SIZE - s->len);
78936 if (!IS_ERR(p)) {
78937 - p = mangle_path(s->buffer + s->len, p, "\n");
78938 + p = mangle_path(s->buffer + s->len, p, "\n\\");
78939 if (p) {
78940 s->len = p - s->buffer;
78941 return 1;
78942 @@ -852,14 +852,16 @@ int register_ftrace_event(struct trace_event *event)
78943 goto out;
78944 }
78945
78946 + pax_open_kernel();
78947 if (event->funcs->trace == NULL)
78948 - event->funcs->trace = trace_nop_print;
78949 + *(void **)&event->funcs->trace = trace_nop_print;
78950 if (event->funcs->raw == NULL)
78951 - event->funcs->raw = trace_nop_print;
78952 + *(void **)&event->funcs->raw = trace_nop_print;
78953 if (event->funcs->hex == NULL)
78954 - event->funcs->hex = trace_nop_print;
78955 + *(void **)&event->funcs->hex = trace_nop_print;
78956 if (event->funcs->binary == NULL)
78957 - event->funcs->binary = trace_nop_print;
78958 + *(void **)&event->funcs->binary = trace_nop_print;
78959 + pax_close_kernel();
78960
78961 key = event->type & (EVENT_HASHSIZE - 1);
78962
78963 diff --git a/kernel/trace/trace_stack.c b/kernel/trace/trace_stack.c
78964 index 42ca822..cdcacc6 100644
78965 --- a/kernel/trace/trace_stack.c
78966 +++ b/kernel/trace/trace_stack.c
78967 @@ -52,7 +52,7 @@ static inline void check_stack(void)
78968 return;
78969
78970 /* we do not handle interrupt stacks yet */
78971 - if (!object_is_on_stack(&this_size))
78972 + if (!object_starts_on_stack(&this_size))
78973 return;
78974
78975 local_irq_save(flags);
78976 diff --git a/kernel/user.c b/kernel/user.c
78977 index 33acb5e..57ebfd4 100644
78978 --- a/kernel/user.c
78979 +++ b/kernel/user.c
78980 @@ -47,9 +47,7 @@ struct user_namespace init_user_ns = {
78981 .count = 4294967295U,
78982 },
78983 },
78984 - .kref = {
78985 - .refcount = ATOMIC_INIT(3),
78986 - },
78987 + .count = ATOMIC_INIT(3),
78988 .owner = GLOBAL_ROOT_UID,
78989 .group = GLOBAL_ROOT_GID,
78990 .proc_inum = PROC_USER_INIT_INO,
78991 diff --git a/kernel/user_namespace.c b/kernel/user_namespace.c
78992 index dbfe36a7..2a3c1df 100644
78993 --- a/kernel/user_namespace.c
78994 +++ b/kernel/user_namespace.c
78995 @@ -79,7 +79,7 @@ int create_user_ns(struct cred *new)
78996 return ret;
78997 }
78998
78999 - kref_init(&ns->kref);
79000 + atomic_set(&ns->count, 1);
79001 /* Leave the new->user_ns reference with the new user namespace. */
79002 ns->parent = parent_ns;
79003 ns->owner = owner;
79004 @@ -105,15 +105,16 @@ int unshare_userns(unsigned long unshare_flags, struct cred **new_cred)
79005 return create_user_ns(cred);
79006 }
79007
79008 -void free_user_ns(struct kref *kref)
79009 +void free_user_ns(struct user_namespace *ns)
79010 {
79011 - struct user_namespace *parent, *ns =
79012 - container_of(kref, struct user_namespace, kref);
79013 + struct user_namespace *parent;
79014
79015 - parent = ns->parent;
79016 - proc_free_inum(ns->proc_inum);
79017 - kmem_cache_free(user_ns_cachep, ns);
79018 - put_user_ns(parent);
79019 + do {
79020 + parent = ns->parent;
79021 + proc_free_inum(ns->proc_inum);
79022 + kmem_cache_free(user_ns_cachep, ns);
79023 + ns = parent;
79024 + } while (atomic_dec_and_test(&parent->count));
79025 }
79026 EXPORT_SYMBOL(free_user_ns);
79027
79028 @@ -804,7 +805,7 @@ static int userns_install(struct nsproxy *nsproxy, void *ns)
79029 if (atomic_read(&current->mm->mm_users) > 1)
79030 return -EINVAL;
79031
79032 - if (current->fs->users != 1)
79033 + if (atomic_read(&current->fs->users) != 1)
79034 return -EINVAL;
79035
79036 if (!ns_capable(user_ns, CAP_SYS_ADMIN))
79037 diff --git a/kernel/utsname_sysctl.c b/kernel/utsname_sysctl.c
79038 index 63da38c..639904e 100644
79039 --- a/kernel/utsname_sysctl.c
79040 +++ b/kernel/utsname_sysctl.c
79041 @@ -46,7 +46,7 @@ static void put_uts(ctl_table *table, int write, void *which)
79042 static int proc_do_uts_string(ctl_table *table, int write,
79043 void __user *buffer, size_t *lenp, loff_t *ppos)
79044 {
79045 - struct ctl_table uts_table;
79046 + ctl_table_no_const uts_table;
79047 int r;
79048 memcpy(&uts_table, table, sizeof(uts_table));
79049 uts_table.data = get_uts(table, write);
79050 diff --git a/kernel/watchdog.c b/kernel/watchdog.c
79051 index 75a2ab3..5961da7 100644
79052 --- a/kernel/watchdog.c
79053 +++ b/kernel/watchdog.c
79054 @@ -527,7 +527,7 @@ int proc_dowatchdog(struct ctl_table *table, int write,
79055 }
79056 #endif /* CONFIG_SYSCTL */
79057
79058 -static struct smp_hotplug_thread watchdog_threads = {
79059 +static struct smp_hotplug_thread watchdog_threads __read_only = {
79060 .store = &softlockup_watchdog,
79061 .thread_should_run = watchdog_should_run,
79062 .thread_fn = watchdog,
79063 diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
79064 index 67604e5..fe94fb1 100644
79065 --- a/lib/Kconfig.debug
79066 +++ b/lib/Kconfig.debug
79067 @@ -550,7 +550,7 @@ config DEBUG_MUTEXES
79068
79069 config DEBUG_LOCK_ALLOC
79070 bool "Lock debugging: detect incorrect freeing of live locks"
79071 - depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
79072 + depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT && !PAX_CONSTIFY_PLUGIN
79073 select DEBUG_SPINLOCK
79074 select DEBUG_MUTEXES
79075 select LOCKDEP
79076 @@ -564,7 +564,7 @@ config DEBUG_LOCK_ALLOC
79077
79078 config PROVE_LOCKING
79079 bool "Lock debugging: prove locking correctness"
79080 - depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
79081 + depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT && !PAX_CONSTIFY_PLUGIN
79082 select LOCKDEP
79083 select DEBUG_SPINLOCK
79084 select DEBUG_MUTEXES
79085 @@ -670,7 +670,7 @@ config LOCKDEP
79086
79087 config LOCK_STAT
79088 bool "Lock usage statistics"
79089 - depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
79090 + depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT && !PAX_CONSTIFY_PLUGIN
79091 select LOCKDEP
79092 select DEBUG_SPINLOCK
79093 select DEBUG_MUTEXES
79094 @@ -1278,6 +1278,7 @@ config LATENCYTOP
79095 depends on DEBUG_KERNEL
79096 depends on STACKTRACE_SUPPORT
79097 depends on PROC_FS
79098 + depends on !GRKERNSEC_HIDESYM
79099 select FRAME_POINTER if !MIPS && !PPC && !S390 && !MICROBLAZE && !ARM_UNWIND
79100 select KALLSYMS
79101 select KALLSYMS_ALL
79102 @@ -1306,7 +1307,7 @@ config INTERVAL_TREE_TEST
79103
79104 config PROVIDE_OHCI1394_DMA_INIT
79105 bool "Remote debugging over FireWire early on boot"
79106 - depends on PCI && X86
79107 + depends on PCI && X86 && !GRKERNSEC
79108 help
79109 If you want to debug problems which hang or crash the kernel early
79110 on boot and the crashing machine has a FireWire port, you can use
79111 @@ -1335,7 +1336,7 @@ config PROVIDE_OHCI1394_DMA_INIT
79112
79113 config FIREWIRE_OHCI_REMOTE_DMA
79114 bool "Remote debugging over FireWire with firewire-ohci"
79115 - depends on FIREWIRE_OHCI
79116 + depends on FIREWIRE_OHCI && !GRKERNSEC
79117 help
79118 This option lets you use the FireWire bus for remote debugging
79119 with help of the firewire-ohci driver. It enables unfiltered
79120 diff --git a/lib/Makefile b/lib/Makefile
79121 index 02ed6c0..bd243da 100644
79122 --- a/lib/Makefile
79123 +++ b/lib/Makefile
79124 @@ -47,7 +47,7 @@ obj-$(CONFIG_GENERIC_HWEIGHT) += hweight.o
79125
79126 obj-$(CONFIG_BTREE) += btree.o
79127 obj-$(CONFIG_DEBUG_PREEMPT) += smp_processor_id.o
79128 -obj-$(CONFIG_DEBUG_LIST) += list_debug.o
79129 +obj-y += list_debug.o
79130 obj-$(CONFIG_DEBUG_OBJECTS) += debugobjects.o
79131
79132 ifneq ($(CONFIG_HAVE_DEC_LOCK),y)
79133 diff --git a/lib/bitmap.c b/lib/bitmap.c
79134 index 06f7e4f..f3cf2b0 100644
79135 --- a/lib/bitmap.c
79136 +++ b/lib/bitmap.c
79137 @@ -422,7 +422,7 @@ int __bitmap_parse(const char *buf, unsigned int buflen,
79138 {
79139 int c, old_c, totaldigits, ndigits, nchunks, nbits;
79140 u32 chunk;
79141 - const char __user __force *ubuf = (const char __user __force *)buf;
79142 + const char __user *ubuf = (const char __force_user *)buf;
79143
79144 bitmap_zero(maskp, nmaskbits);
79145
79146 @@ -507,7 +507,7 @@ int bitmap_parse_user(const char __user *ubuf,
79147 {
79148 if (!access_ok(VERIFY_READ, ubuf, ulen))
79149 return -EFAULT;
79150 - return __bitmap_parse((const char __force *)ubuf,
79151 + return __bitmap_parse((const char __force_kernel *)ubuf,
79152 ulen, 1, maskp, nmaskbits);
79153
79154 }
79155 @@ -598,7 +598,7 @@ static int __bitmap_parselist(const char *buf, unsigned int buflen,
79156 {
79157 unsigned a, b;
79158 int c, old_c, totaldigits;
79159 - const char __user __force *ubuf = (const char __user __force *)buf;
79160 + const char __user *ubuf = (const char __force_user *)buf;
79161 int exp_digit, in_range;
79162
79163 totaldigits = c = 0;
79164 @@ -698,7 +698,7 @@ int bitmap_parselist_user(const char __user *ubuf,
79165 {
79166 if (!access_ok(VERIFY_READ, ubuf, ulen))
79167 return -EFAULT;
79168 - return __bitmap_parselist((const char __force *)ubuf,
79169 + return __bitmap_parselist((const char __force_kernel *)ubuf,
79170 ulen, 1, maskp, nmaskbits);
79171 }
79172 EXPORT_SYMBOL(bitmap_parselist_user);
79173 diff --git a/lib/bug.c b/lib/bug.c
79174 index d0cdf14..4d07bd2 100644
79175 --- a/lib/bug.c
79176 +++ b/lib/bug.c
79177 @@ -134,6 +134,8 @@ enum bug_trap_type report_bug(unsigned long bugaddr, struct pt_regs *regs)
79178 return BUG_TRAP_TYPE_NONE;
79179
79180 bug = find_bug(bugaddr);
79181 + if (!bug)
79182 + return BUG_TRAP_TYPE_NONE;
79183
79184 file = NULL;
79185 line = 0;
79186 diff --git a/lib/debugobjects.c b/lib/debugobjects.c
79187 index d11808c..dc2d6f8 100644
79188 --- a/lib/debugobjects.c
79189 +++ b/lib/debugobjects.c
79190 @@ -287,7 +287,7 @@ static void debug_object_is_on_stack(void *addr, int onstack)
79191 if (limit > 4)
79192 return;
79193
79194 - is_on_stack = object_is_on_stack(addr);
79195 + is_on_stack = object_starts_on_stack(addr);
79196 if (is_on_stack == onstack)
79197 return;
79198
79199 diff --git a/lib/devres.c b/lib/devres.c
79200 index 80b9c76..9e32279 100644
79201 --- a/lib/devres.c
79202 +++ b/lib/devres.c
79203 @@ -80,7 +80,7 @@ EXPORT_SYMBOL(devm_ioremap_nocache);
79204 void devm_iounmap(struct device *dev, void __iomem *addr)
79205 {
79206 WARN_ON(devres_destroy(dev, devm_ioremap_release, devm_ioremap_match,
79207 - (void *)addr));
79208 + (void __force *)addr));
79209 iounmap(addr);
79210 }
79211 EXPORT_SYMBOL(devm_iounmap);
79212 @@ -192,7 +192,7 @@ void devm_ioport_unmap(struct device *dev, void __iomem *addr)
79213 {
79214 ioport_unmap(addr);
79215 WARN_ON(devres_destroy(dev, devm_ioport_map_release,
79216 - devm_ioport_map_match, (void *)addr));
79217 + devm_ioport_map_match, (void __force *)addr));
79218 }
79219 EXPORT_SYMBOL(devm_ioport_unmap);
79220
79221 diff --git a/lib/div64.c b/lib/div64.c
79222 index a163b6c..9618fa5 100644
79223 --- a/lib/div64.c
79224 +++ b/lib/div64.c
79225 @@ -59,7 +59,7 @@ uint32_t __attribute__((weak)) __div64_32(uint64_t *n, uint32_t base)
79226 EXPORT_SYMBOL(__div64_32);
79227
79228 #ifndef div_s64_rem
79229 -s64 div_s64_rem(s64 dividend, s32 divisor, s32 *remainder)
79230 +s64 __intentional_overflow(-1) div_s64_rem(s64 dividend, s32 divisor, s32 *remainder)
79231 {
79232 u64 quotient;
79233
79234 @@ -90,7 +90,7 @@ EXPORT_SYMBOL(div_s64_rem);
79235 * 'http://www.hackersdelight.org/HDcode/newCode/divDouble.c.txt'
79236 */
79237 #ifndef div64_u64
79238 -u64 div64_u64(u64 dividend, u64 divisor)
79239 +u64 __intentional_overflow(-1) div64_u64(u64 dividend, u64 divisor)
79240 {
79241 u32 high = divisor >> 32;
79242 u64 quot;
79243 diff --git a/lib/dma-debug.c b/lib/dma-debug.c
79244 index 5e396ac..58d5de1 100644
79245 --- a/lib/dma-debug.c
79246 +++ b/lib/dma-debug.c
79247 @@ -768,7 +768,7 @@ static int dma_debug_device_change(struct notifier_block *nb, unsigned long acti
79248
79249 void dma_debug_add_bus(struct bus_type *bus)
79250 {
79251 - struct notifier_block *nb;
79252 + notifier_block_no_const *nb;
79253
79254 if (global_disable)
79255 return;
79256 @@ -942,7 +942,7 @@ out:
79257
79258 static void check_for_stack(struct device *dev, void *addr)
79259 {
79260 - if (object_is_on_stack(addr))
79261 + if (object_starts_on_stack(addr))
79262 err_printk(dev, NULL, "DMA-API: device driver maps memory from"
79263 "stack [addr=%p]\n", addr);
79264 }
79265 diff --git a/lib/inflate.c b/lib/inflate.c
79266 index 013a761..c28f3fc 100644
79267 --- a/lib/inflate.c
79268 +++ b/lib/inflate.c
79269 @@ -269,7 +269,7 @@ static void free(void *where)
79270 malloc_ptr = free_mem_ptr;
79271 }
79272 #else
79273 -#define malloc(a) kmalloc(a, GFP_KERNEL)
79274 +#define malloc(a) kmalloc((a), GFP_KERNEL)
79275 #define free(a) kfree(a)
79276 #endif
79277
79278 diff --git a/lib/ioremap.c b/lib/ioremap.c
79279 index 0c9216c..863bd89 100644
79280 --- a/lib/ioremap.c
79281 +++ b/lib/ioremap.c
79282 @@ -38,7 +38,7 @@ static inline int ioremap_pmd_range(pud_t *pud, unsigned long addr,
79283 unsigned long next;
79284
79285 phys_addr -= addr;
79286 - pmd = pmd_alloc(&init_mm, pud, addr);
79287 + pmd = pmd_alloc_kernel(&init_mm, pud, addr);
79288 if (!pmd)
79289 return -ENOMEM;
79290 do {
79291 @@ -56,7 +56,7 @@ static inline int ioremap_pud_range(pgd_t *pgd, unsigned long addr,
79292 unsigned long next;
79293
79294 phys_addr -= addr;
79295 - pud = pud_alloc(&init_mm, pgd, addr);
79296 + pud = pud_alloc_kernel(&init_mm, pgd, addr);
79297 if (!pud)
79298 return -ENOMEM;
79299 do {
79300 diff --git a/lib/is_single_threaded.c b/lib/is_single_threaded.c
79301 index bd2bea9..6b3c95e 100644
79302 --- a/lib/is_single_threaded.c
79303 +++ b/lib/is_single_threaded.c
79304 @@ -22,6 +22,9 @@ bool current_is_single_threaded(void)
79305 struct task_struct *p, *t;
79306 bool ret;
79307
79308 + if (!mm)
79309 + return true;
79310 +
79311 if (atomic_read(&task->signal->live) != 1)
79312 return false;
79313
79314 diff --git a/lib/kobject.c b/lib/kobject.c
79315 index e07ee1f..998489d 100644
79316 --- a/lib/kobject.c
79317 +++ b/lib/kobject.c
79318 @@ -852,9 +852,9 @@ EXPORT_SYMBOL_GPL(kset_create_and_add);
79319
79320
79321 static DEFINE_SPINLOCK(kobj_ns_type_lock);
79322 -static const struct kobj_ns_type_operations *kobj_ns_ops_tbl[KOBJ_NS_TYPES];
79323 +static const struct kobj_ns_type_operations *kobj_ns_ops_tbl[KOBJ_NS_TYPES] __read_only;
79324
79325 -int kobj_ns_type_register(const struct kobj_ns_type_operations *ops)
79326 +int __init kobj_ns_type_register(const struct kobj_ns_type_operations *ops)
79327 {
79328 enum kobj_ns_type type = ops->type;
79329 int error;
79330 diff --git a/lib/list_debug.c b/lib/list_debug.c
79331 index c24c2f7..0475b78 100644
79332 --- a/lib/list_debug.c
79333 +++ b/lib/list_debug.c
79334 @@ -11,7 +11,9 @@
79335 #include <linux/bug.h>
79336 #include <linux/kernel.h>
79337 #include <linux/rculist.h>
79338 +#include <linux/mm.h>
79339
79340 +#ifdef CONFIG_DEBUG_LIST
79341 /*
79342 * Insert a new entry between two known consecutive entries.
79343 *
79344 @@ -19,21 +21,32 @@
79345 * the prev/next entries already!
79346 */
79347
79348 -void __list_add(struct list_head *new,
79349 - struct list_head *prev,
79350 - struct list_head *next)
79351 +static bool __list_add_debug(struct list_head *new,
79352 + struct list_head *prev,
79353 + struct list_head *next)
79354 {
79355 - WARN(next->prev != prev,
79356 + if (WARN(next->prev != prev,
79357 "list_add corruption. next->prev should be "
79358 "prev (%p), but was %p. (next=%p).\n",
79359 - prev, next->prev, next);
79360 - WARN(prev->next != next,
79361 + prev, next->prev, next) ||
79362 + WARN(prev->next != next,
79363 "list_add corruption. prev->next should be "
79364 "next (%p), but was %p. (prev=%p).\n",
79365 - next, prev->next, prev);
79366 - WARN(new == prev || new == next,
79367 + next, prev->next, prev) ||
79368 + WARN(new == prev || new == next,
79369 "list_add double add: new=%p, prev=%p, next=%p.\n",
79370 - new, prev, next);
79371 + new, prev, next))
79372 + return false;
79373 + return true;
79374 +}
79375 +
79376 +void __list_add(struct list_head *new,
79377 + struct list_head *prev,
79378 + struct list_head *next)
79379 +{
79380 + if (!__list_add_debug(new, prev, next))
79381 + return;
79382 +
79383 next->prev = new;
79384 new->next = next;
79385 new->prev = prev;
79386 @@ -41,7 +54,7 @@ void __list_add(struct list_head *new,
79387 }
79388 EXPORT_SYMBOL(__list_add);
79389
79390 -void __list_del_entry(struct list_head *entry)
79391 +static bool __list_del_entry_debug(struct list_head *entry)
79392 {
79393 struct list_head *prev, *next;
79394
79395 @@ -60,9 +73,16 @@ void __list_del_entry(struct list_head *entry)
79396 WARN(next->prev != entry,
79397 "list_del corruption. next->prev should be %p, "
79398 "but was %p\n", entry, next->prev))
79399 + return false;
79400 + return true;
79401 +}
79402 +
79403 +void __list_del_entry(struct list_head *entry)
79404 +{
79405 + if (!__list_del_entry_debug(entry))
79406 return;
79407
79408 - __list_del(prev, next);
79409 + __list_del(entry->prev, entry->next);
79410 }
79411 EXPORT_SYMBOL(__list_del_entry);
79412
79413 @@ -86,15 +106,85 @@ EXPORT_SYMBOL(list_del);
79414 void __list_add_rcu(struct list_head *new,
79415 struct list_head *prev, struct list_head *next)
79416 {
79417 - WARN(next->prev != prev,
79418 - "list_add_rcu corruption. next->prev should be prev (%p), but was %p. (next=%p).\n",
79419 - prev, next->prev, next);
79420 - WARN(prev->next != next,
79421 - "list_add_rcu corruption. prev->next should be next (%p), but was %p. (prev=%p).\n",
79422 - next, prev->next, prev);
79423 + if (!__list_add_debug(new, prev, next))
79424 + return;
79425 +
79426 new->next = next;
79427 new->prev = prev;
79428 rcu_assign_pointer(list_next_rcu(prev), new);
79429 next->prev = new;
79430 }
79431 EXPORT_SYMBOL(__list_add_rcu);
79432 +#endif
79433 +
79434 +void __pax_list_add(struct list_head *new, struct list_head *prev, struct list_head *next)
79435 +{
79436 +#ifdef CONFIG_DEBUG_LIST
79437 + if (!__list_add_debug(new, prev, next))
79438 + return;
79439 +#endif
79440 +
79441 + pax_open_kernel();
79442 + next->prev = new;
79443 + new->next = next;
79444 + new->prev = prev;
79445 + prev->next = new;
79446 + pax_close_kernel();
79447 +}
79448 +EXPORT_SYMBOL(__pax_list_add);
79449 +
79450 +void pax_list_del(struct list_head *entry)
79451 +{
79452 +#ifdef CONFIG_DEBUG_LIST
79453 + if (!__list_del_entry_debug(entry))
79454 + return;
79455 +#endif
79456 +
79457 + pax_open_kernel();
79458 + __list_del(entry->prev, entry->next);
79459 + entry->next = LIST_POISON1;
79460 + entry->prev = LIST_POISON2;
79461 + pax_close_kernel();
79462 +}
79463 +EXPORT_SYMBOL(pax_list_del);
79464 +
79465 +void pax_list_del_init(struct list_head *entry)
79466 +{
79467 + pax_open_kernel();
79468 + __list_del(entry->prev, entry->next);
79469 + INIT_LIST_HEAD(entry);
79470 + pax_close_kernel();
79471 +}
79472 +EXPORT_SYMBOL(pax_list_del_init);
79473 +
79474 +void __pax_list_add_rcu(struct list_head *new,
79475 + struct list_head *prev, struct list_head *next)
79476 +{
79477 +#ifdef CONFIG_DEBUG_LIST
79478 + if (!__list_add_debug(new, prev, next))
79479 + return;
79480 +#endif
79481 +
79482 + pax_open_kernel();
79483 + new->next = next;
79484 + new->prev = prev;
79485 + rcu_assign_pointer(list_next_rcu(prev), new);
79486 + next->prev = new;
79487 + pax_close_kernel();
79488 +}
79489 +EXPORT_SYMBOL(__pax_list_add_rcu);
79490 +
79491 +void pax_list_del_rcu(struct list_head *entry)
79492 +{
79493 +#ifdef CONFIG_DEBUG_LIST
79494 + if (!__list_del_entry_debug(entry))
79495 + return;
79496 +#endif
79497 +
79498 + pax_open_kernel();
79499 + __list_del(entry->prev, entry->next);
79500 + entry->next = LIST_POISON1;
79501 + entry->prev = LIST_POISON2;
79502 + pax_close_kernel();
79503 +}
79504 +EXPORT_SYMBOL(pax_list_del_rcu);
79505 diff --git a/lib/radix-tree.c b/lib/radix-tree.c
79506 index e796429..6e38f9f 100644
79507 --- a/lib/radix-tree.c
79508 +++ b/lib/radix-tree.c
79509 @@ -92,7 +92,7 @@ struct radix_tree_preload {
79510 int nr;
79511 struct radix_tree_node *nodes[RADIX_TREE_PRELOAD_SIZE];
79512 };
79513 -static DEFINE_PER_CPU(struct radix_tree_preload, radix_tree_preloads) = { 0, };
79514 +static DEFINE_PER_CPU(struct radix_tree_preload, radix_tree_preloads);
79515
79516 static inline void *ptr_to_indirect(void *ptr)
79517 {
79518 diff --git a/lib/strncpy_from_user.c b/lib/strncpy_from_user.c
79519 index bb2b201..46abaf9 100644
79520 --- a/lib/strncpy_from_user.c
79521 +++ b/lib/strncpy_from_user.c
79522 @@ -21,7 +21,7 @@
79523 */
79524 static inline long do_strncpy_from_user(char *dst, const char __user *src, long count, unsigned long max)
79525 {
79526 - const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
79527 + static const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
79528 long res = 0;
79529
79530 /*
79531 diff --git a/lib/strnlen_user.c b/lib/strnlen_user.c
79532 index a28df52..3d55877 100644
79533 --- a/lib/strnlen_user.c
79534 +++ b/lib/strnlen_user.c
79535 @@ -26,7 +26,7 @@
79536 */
79537 static inline long do_strnlen_user(const char __user *src, unsigned long count, unsigned long max)
79538 {
79539 - const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
79540 + static const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
79541 long align, res = 0;
79542 unsigned long c;
79543
79544 diff --git a/lib/swiotlb.c b/lib/swiotlb.c
79545 index 196b069..358f342 100644
79546 --- a/lib/swiotlb.c
79547 +++ b/lib/swiotlb.c
79548 @@ -642,7 +642,7 @@ EXPORT_SYMBOL(swiotlb_alloc_coherent);
79549
79550 void
79551 swiotlb_free_coherent(struct device *hwdev, size_t size, void *vaddr,
79552 - dma_addr_t dev_addr)
79553 + dma_addr_t dev_addr, struct dma_attrs *attrs)
79554 {
79555 phys_addr_t paddr = dma_to_phys(hwdev, dev_addr);
79556
79557 diff --git a/lib/vsprintf.c b/lib/vsprintf.c
79558 index fab33a9..3b5fe68 100644
79559 --- a/lib/vsprintf.c
79560 +++ b/lib/vsprintf.c
79561 @@ -16,6 +16,9 @@
79562 * - scnprintf and vscnprintf
79563 */
79564
79565 +#ifdef CONFIG_GRKERNSEC_HIDESYM
79566 +#define __INCLUDED_BY_HIDESYM 1
79567 +#endif
79568 #include <stdarg.h>
79569 #include <linux/module.h> /* for KSYM_SYMBOL_LEN */
79570 #include <linux/types.h>
79571 @@ -541,7 +544,7 @@ char *symbol_string(char *buf, char *end, void *ptr,
79572 char sym[KSYM_SYMBOL_LEN];
79573 if (ext == 'B')
79574 sprint_backtrace(sym, value);
79575 - else if (ext != 'f' && ext != 's')
79576 + else if (ext != 'f' && ext != 's' && ext != 'a')
79577 sprint_symbol(sym, value);
79578 else
79579 sprint_symbol_no_offset(sym, value);
79580 @@ -974,7 +977,11 @@ char *netdev_feature_string(char *buf, char *end, const u8 *addr,
79581 return number(buf, end, *(const netdev_features_t *)addr, spec);
79582 }
79583
79584 +#ifdef CONFIG_GRKERNSEC_HIDESYM
79585 +int kptr_restrict __read_mostly = 2;
79586 +#else
79587 int kptr_restrict __read_mostly;
79588 +#endif
79589
79590 /*
79591 * Show a '%p' thing. A kernel extension is that the '%p' is followed
79592 @@ -988,6 +995,8 @@ int kptr_restrict __read_mostly;
79593 * - 'S' For symbolic direct pointers with offset
79594 * - 's' For symbolic direct pointers without offset
79595 * - 'B' For backtraced symbolic direct pointers with offset
79596 + * - 'A' For symbolic direct pointers with offset approved for use with GRKERNSEC_HIDESYM
79597 + * - 'a' For symbolic direct pointers without offset approved for use with GRKERNSEC_HIDESYM
79598 * - 'R' For decoded struct resource, e.g., [mem 0x0-0x1f 64bit pref]
79599 * - 'r' For raw struct resource, e.g., [mem 0x0-0x1f flags 0x201]
79600 * - 'M' For a 6-byte MAC address, it prints the address in the
79601 @@ -1043,12 +1052,12 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
79602
79603 if (!ptr && *fmt != 'K') {
79604 /*
79605 - * Print (null) with the same width as a pointer so it makes
79606 + * Print (nil) with the same width as a pointer so it makes
79607 * tabular output look nice.
79608 */
79609 if (spec.field_width == -1)
79610 spec.field_width = default_width;
79611 - return string(buf, end, "(null)", spec);
79612 + return string(buf, end, "(nil)", spec);
79613 }
79614
79615 switch (*fmt) {
79616 @@ -1058,6 +1067,13 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
79617 /* Fallthrough */
79618 case 'S':
79619 case 's':
79620 +#ifdef CONFIG_GRKERNSEC_HIDESYM
79621 + break;
79622 +#else
79623 + return symbol_string(buf, end, ptr, spec, *fmt);
79624 +#endif
79625 + case 'A':
79626 + case 'a':
79627 case 'B':
79628 return symbol_string(buf, end, ptr, spec, *fmt);
79629 case 'R':
79630 @@ -1098,6 +1114,8 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
79631 va_end(va);
79632 return buf;
79633 }
79634 + case 'P':
79635 + break;
79636 case 'K':
79637 /*
79638 * %pK cannot be used in IRQ context because its test
79639 @@ -1121,6 +1139,21 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
79640 }
79641 break;
79642 }
79643 +
79644 +#ifdef CONFIG_GRKERNSEC_HIDESYM
79645 + /* 'P' = approved pointers to copy to userland,
79646 + as in the /proc/kallsyms case, as we make it display nothing
79647 + for non-root users, and the real contents for root users
79648 + Also ignore 'K' pointers, since we force their NULLing for non-root users
79649 + above
79650 + */
79651 + if ((unsigned long)ptr > TASK_SIZE && *fmt != 'P' && *fmt != 'K' && is_usercopy_object(buf)) {
79652 + printk(KERN_ALERT "grsec: kernel infoleak detected! Please report this log to spender@grsecurity.net.\n");
79653 + dump_stack();
79654 + ptr = NULL;
79655 + }
79656 +#endif
79657 +
79658 spec.flags |= SMALL;
79659 if (spec.field_width == -1) {
79660 spec.field_width = default_width;
79661 @@ -1842,11 +1875,11 @@ int bstr_printf(char *buf, size_t size, const char *fmt, const u32 *bin_buf)
79662 typeof(type) value; \
79663 if (sizeof(type) == 8) { \
79664 args = PTR_ALIGN(args, sizeof(u32)); \
79665 - *(u32 *)&value = *(u32 *)args; \
79666 - *((u32 *)&value + 1) = *(u32 *)(args + 4); \
79667 + *(u32 *)&value = *(const u32 *)args; \
79668 + *((u32 *)&value + 1) = *(const u32 *)(args + 4); \
79669 } else { \
79670 args = PTR_ALIGN(args, sizeof(type)); \
79671 - value = *(typeof(type) *)args; \
79672 + value = *(const typeof(type) *)args; \
79673 } \
79674 args += sizeof(type); \
79675 value; \
79676 @@ -1909,7 +1942,7 @@ int bstr_printf(char *buf, size_t size, const char *fmt, const u32 *bin_buf)
79677 case FORMAT_TYPE_STR: {
79678 const char *str_arg = args;
79679 args += strlen(str_arg) + 1;
79680 - str = string(str, end, (char *)str_arg, spec);
79681 + str = string(str, end, str_arg, spec);
79682 break;
79683 }
79684
79685 diff --git a/localversion-grsec b/localversion-grsec
79686 new file mode 100644
79687 index 0000000..7cd6065
79688 --- /dev/null
79689 +++ b/localversion-grsec
79690 @@ -0,0 +1 @@
79691 +-grsec
79692 diff --git a/mm/Kconfig b/mm/Kconfig
79693 index 278e3ab..87c384d 100644
79694 --- a/mm/Kconfig
79695 +++ b/mm/Kconfig
79696 @@ -286,10 +286,10 @@ config KSM
79697 root has set /sys/kernel/mm/ksm/run to 1 (if CONFIG_SYSFS is set).
79698
79699 config DEFAULT_MMAP_MIN_ADDR
79700 - int "Low address space to protect from user allocation"
79701 + int "Low address space to protect from user allocation"
79702 depends on MMU
79703 - default 4096
79704 - help
79705 + default 65536
79706 + help
79707 This is the portion of low virtual memory which should be protected
79708 from userspace allocation. Keeping a user from writing to low pages
79709 can help reduce the impact of kernel NULL pointer bugs.
79710 @@ -320,7 +320,7 @@ config MEMORY_FAILURE
79711
79712 config HWPOISON_INJECT
79713 tristate "HWPoison pages injector"
79714 - depends on MEMORY_FAILURE && DEBUG_KERNEL && PROC_FS
79715 + depends on MEMORY_FAILURE && DEBUG_KERNEL && PROC_FS && !GRKERNSEC
79716 select PROC_PAGE_MONITOR
79717
79718 config NOMMU_INITIAL_TRIM_EXCESS
79719 diff --git a/mm/filemap.c b/mm/filemap.c
79720 index 83efee7..3f99381 100644
79721 --- a/mm/filemap.c
79722 +++ b/mm/filemap.c
79723 @@ -1747,7 +1747,7 @@ int generic_file_mmap(struct file * file, struct vm_area_struct * vma)
79724 struct address_space *mapping = file->f_mapping;
79725
79726 if (!mapping->a_ops->readpage)
79727 - return -ENOEXEC;
79728 + return -ENODEV;
79729 file_accessed(file);
79730 vma->vm_ops = &generic_file_vm_ops;
79731 return 0;
79732 @@ -2087,6 +2087,7 @@ inline int generic_write_checks(struct file *file, loff_t *pos, size_t *count, i
79733 *pos = i_size_read(inode);
79734
79735 if (limit != RLIM_INFINITY) {
79736 + gr_learn_resource(current, RLIMIT_FSIZE,*pos, 0);
79737 if (*pos >= limit) {
79738 send_sig(SIGXFSZ, current, 0);
79739 return -EFBIG;
79740 diff --git a/mm/fremap.c b/mm/fremap.c
79741 index a0aaf0e..20325c3 100644
79742 --- a/mm/fremap.c
79743 +++ b/mm/fremap.c
79744 @@ -157,6 +157,11 @@ SYSCALL_DEFINE5(remap_file_pages, unsigned long, start, unsigned long, size,
79745 retry:
79746 vma = find_vma(mm, start);
79747
79748 +#ifdef CONFIG_PAX_SEGMEXEC
79749 + if (vma && (mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_flags & VM_MAYEXEC))
79750 + goto out;
79751 +#endif
79752 +
79753 /*
79754 * Make sure the vma is shared, that it supports prefaulting,
79755 * and that the remapped range is valid and fully within
79756 diff --git a/mm/highmem.c b/mm/highmem.c
79757 index b32b70c..e512eb0 100644
79758 --- a/mm/highmem.c
79759 +++ b/mm/highmem.c
79760 @@ -138,8 +138,9 @@ static void flush_all_zero_pkmaps(void)
79761 * So no dangers, even with speculative execution.
79762 */
79763 page = pte_page(pkmap_page_table[i]);
79764 + pax_open_kernel();
79765 pte_clear(&init_mm, PKMAP_ADDR(i), &pkmap_page_table[i]);
79766 -
79767 + pax_close_kernel();
79768 set_page_address(page, NULL);
79769 need_flush = 1;
79770 }
79771 @@ -198,9 +199,11 @@ start:
79772 }
79773 }
79774 vaddr = PKMAP_ADDR(last_pkmap_nr);
79775 +
79776 + pax_open_kernel();
79777 set_pte_at(&init_mm, vaddr,
79778 &(pkmap_page_table[last_pkmap_nr]), mk_pte(page, kmap_prot));
79779 -
79780 + pax_close_kernel();
79781 pkmap_count[last_pkmap_nr] = 1;
79782 set_page_address(page, (void *)vaddr);
79783
79784 diff --git a/mm/hugetlb.c b/mm/hugetlb.c
79785 index 546db81..34830af 100644
79786 --- a/mm/hugetlb.c
79787 +++ b/mm/hugetlb.c
79788 @@ -2008,15 +2008,17 @@ static int hugetlb_sysctl_handler_common(bool obey_mempolicy,
79789 struct hstate *h = &default_hstate;
79790 unsigned long tmp;
79791 int ret;
79792 + ctl_table_no_const hugetlb_table;
79793
79794 tmp = h->max_huge_pages;
79795
79796 if (write && h->order >= MAX_ORDER)
79797 return -EINVAL;
79798
79799 - table->data = &tmp;
79800 - table->maxlen = sizeof(unsigned long);
79801 - ret = proc_doulongvec_minmax(table, write, buffer, length, ppos);
79802 + hugetlb_table = *table;
79803 + hugetlb_table.data = &tmp;
79804 + hugetlb_table.maxlen = sizeof(unsigned long);
79805 + ret = proc_doulongvec_minmax(&hugetlb_table, write, buffer, length, ppos);
79806 if (ret)
79807 goto out;
79808
79809 @@ -2073,15 +2075,17 @@ int hugetlb_overcommit_handler(struct ctl_table *table, int write,
79810 struct hstate *h = &default_hstate;
79811 unsigned long tmp;
79812 int ret;
79813 + ctl_table_no_const hugetlb_table;
79814
79815 tmp = h->nr_overcommit_huge_pages;
79816
79817 if (write && h->order >= MAX_ORDER)
79818 return -EINVAL;
79819
79820 - table->data = &tmp;
79821 - table->maxlen = sizeof(unsigned long);
79822 - ret = proc_doulongvec_minmax(table, write, buffer, length, ppos);
79823 + hugetlb_table = *table;
79824 + hugetlb_table.data = &tmp;
79825 + hugetlb_table.maxlen = sizeof(unsigned long);
79826 + ret = proc_doulongvec_minmax(&hugetlb_table, write, buffer, length, ppos);
79827 if (ret)
79828 goto out;
79829
79830 @@ -2511,6 +2515,27 @@ static int unmap_ref_private(struct mm_struct *mm, struct vm_area_struct *vma,
79831 return 1;
79832 }
79833
79834 +#ifdef CONFIG_PAX_SEGMEXEC
79835 +static void pax_mirror_huge_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m)
79836 +{
79837 + struct mm_struct *mm = vma->vm_mm;
79838 + struct vm_area_struct *vma_m;
79839 + unsigned long address_m;
79840 + pte_t *ptep_m;
79841 +
79842 + vma_m = pax_find_mirror_vma(vma);
79843 + if (!vma_m)
79844 + return;
79845 +
79846 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
79847 + address_m = address + SEGMEXEC_TASK_SIZE;
79848 + ptep_m = huge_pte_offset(mm, address_m & HPAGE_MASK);
79849 + get_page(page_m);
79850 + hugepage_add_anon_rmap(page_m, vma_m, address_m);
79851 + set_huge_pte_at(mm, address_m, ptep_m, make_huge_pte(vma_m, page_m, 0));
79852 +}
79853 +#endif
79854 +
79855 /*
79856 * Hugetlb_cow() should be called with page lock of the original hugepage held.
79857 * Called with hugetlb_instantiation_mutex held and pte_page locked so we
79858 @@ -2629,6 +2654,11 @@ retry_avoidcopy:
79859 make_huge_pte(vma, new_page, 1));
79860 page_remove_rmap(old_page);
79861 hugepage_add_new_anon_rmap(new_page, vma, address);
79862 +
79863 +#ifdef CONFIG_PAX_SEGMEXEC
79864 + pax_mirror_huge_pte(vma, address, new_page);
79865 +#endif
79866 +
79867 /* Make the old page be freed below */
79868 new_page = old_page;
79869 }
79870 @@ -2788,6 +2818,10 @@ retry:
79871 && (vma->vm_flags & VM_SHARED)));
79872 set_huge_pte_at(mm, address, ptep, new_pte);
79873
79874 +#ifdef CONFIG_PAX_SEGMEXEC
79875 + pax_mirror_huge_pte(vma, address, page);
79876 +#endif
79877 +
79878 if ((flags & FAULT_FLAG_WRITE) && !(vma->vm_flags & VM_SHARED)) {
79879 /* Optimization, do the COW without a second fault */
79880 ret = hugetlb_cow(mm, vma, address, ptep, new_pte, page);
79881 @@ -2817,6 +2851,10 @@ int hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma,
79882 static DEFINE_MUTEX(hugetlb_instantiation_mutex);
79883 struct hstate *h = hstate_vma(vma);
79884
79885 +#ifdef CONFIG_PAX_SEGMEXEC
79886 + struct vm_area_struct *vma_m;
79887 +#endif
79888 +
79889 address &= huge_page_mask(h);
79890
79891 ptep = huge_pte_offset(mm, address);
79892 @@ -2830,6 +2868,26 @@ int hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma,
79893 VM_FAULT_SET_HINDEX(hstate_index(h));
79894 }
79895
79896 +#ifdef CONFIG_PAX_SEGMEXEC
79897 + vma_m = pax_find_mirror_vma(vma);
79898 + if (vma_m) {
79899 + unsigned long address_m;
79900 +
79901 + if (vma->vm_start > vma_m->vm_start) {
79902 + address_m = address;
79903 + address -= SEGMEXEC_TASK_SIZE;
79904 + vma = vma_m;
79905 + h = hstate_vma(vma);
79906 + } else
79907 + address_m = address + SEGMEXEC_TASK_SIZE;
79908 +
79909 + if (!huge_pte_alloc(mm, address_m, huge_page_size(h)))
79910 + return VM_FAULT_OOM;
79911 + address_m &= HPAGE_MASK;
79912 + unmap_hugepage_range(vma, address_m, address_m + HPAGE_SIZE, NULL);
79913 + }
79914 +#endif
79915 +
79916 ptep = huge_pte_alloc(mm, address, huge_page_size(h));
79917 if (!ptep)
79918 return VM_FAULT_OOM;
79919 diff --git a/mm/internal.h b/mm/internal.h
79920 index 9ba2110..eaf0674 100644
79921 --- a/mm/internal.h
79922 +++ b/mm/internal.h
79923 @@ -100,6 +100,7 @@ extern pmd_t *mm_find_pmd(struct mm_struct *mm, unsigned long address);
79924 * in mm/page_alloc.c
79925 */
79926 extern void __free_pages_bootmem(struct page *page, unsigned int order);
79927 +extern void free_compound_page(struct page *page);
79928 extern void prep_compound_page(struct page *page, unsigned long order);
79929 #ifdef CONFIG_MEMORY_FAILURE
79930 extern bool is_free_buddy_page(struct page *page);
79931 diff --git a/mm/kmemleak.c b/mm/kmemleak.c
79932 index 752a705..6c3102e 100644
79933 --- a/mm/kmemleak.c
79934 +++ b/mm/kmemleak.c
79935 @@ -363,7 +363,7 @@ static void print_unreferenced(struct seq_file *seq,
79936
79937 for (i = 0; i < object->trace_len; i++) {
79938 void *ptr = (void *)object->trace[i];
79939 - seq_printf(seq, " [<%p>] %pS\n", ptr, ptr);
79940 + seq_printf(seq, " [<%pP>] %pA\n", ptr, ptr);
79941 }
79942 }
79943
79944 @@ -1853,7 +1853,7 @@ static int __init kmemleak_late_init(void)
79945 return -ENOMEM;
79946 }
79947
79948 - dentry = debugfs_create_file("kmemleak", S_IRUGO, NULL, NULL,
79949 + dentry = debugfs_create_file("kmemleak", S_IRUSR, NULL, NULL,
79950 &kmemleak_fops);
79951 if (!dentry)
79952 pr_warning("Failed to create the debugfs kmemleak file\n");
79953 diff --git a/mm/maccess.c b/mm/maccess.c
79954 index d53adf9..03a24bf 100644
79955 --- a/mm/maccess.c
79956 +++ b/mm/maccess.c
79957 @@ -26,7 +26,7 @@ long __probe_kernel_read(void *dst, const void *src, size_t size)
79958 set_fs(KERNEL_DS);
79959 pagefault_disable();
79960 ret = __copy_from_user_inatomic(dst,
79961 - (__force const void __user *)src, size);
79962 + (const void __force_user *)src, size);
79963 pagefault_enable();
79964 set_fs(old_fs);
79965
79966 @@ -53,7 +53,7 @@ long __probe_kernel_write(void *dst, const void *src, size_t size)
79967
79968 set_fs(KERNEL_DS);
79969 pagefault_disable();
79970 - ret = __copy_to_user_inatomic((__force void __user *)dst, src, size);
79971 + ret = __copy_to_user_inatomic((void __force_user *)dst, src, size);
79972 pagefault_enable();
79973 set_fs(old_fs);
79974
79975 diff --git a/mm/madvise.c b/mm/madvise.c
79976 index 03dfa5c..b032917 100644
79977 --- a/mm/madvise.c
79978 +++ b/mm/madvise.c
79979 @@ -48,6 +48,10 @@ static long madvise_behavior(struct vm_area_struct * vma,
79980 pgoff_t pgoff;
79981 unsigned long new_flags = vma->vm_flags;
79982
79983 +#ifdef CONFIG_PAX_SEGMEXEC
79984 + struct vm_area_struct *vma_m;
79985 +#endif
79986 +
79987 switch (behavior) {
79988 case MADV_NORMAL:
79989 new_flags = new_flags & ~VM_RAND_READ & ~VM_SEQ_READ;
79990 @@ -123,6 +127,13 @@ success:
79991 /*
79992 * vm_flags is protected by the mmap_sem held in write mode.
79993 */
79994 +
79995 +#ifdef CONFIG_PAX_SEGMEXEC
79996 + vma_m = pax_find_mirror_vma(vma);
79997 + if (vma_m)
79998 + vma_m->vm_flags = new_flags & ~(VM_WRITE | VM_MAYWRITE | VM_ACCOUNT);
79999 +#endif
80000 +
80001 vma->vm_flags = new_flags;
80002
80003 out:
80004 @@ -181,6 +192,11 @@ static long madvise_dontneed(struct vm_area_struct * vma,
80005 struct vm_area_struct ** prev,
80006 unsigned long start, unsigned long end)
80007 {
80008 +
80009 +#ifdef CONFIG_PAX_SEGMEXEC
80010 + struct vm_area_struct *vma_m;
80011 +#endif
80012 +
80013 *prev = vma;
80014 if (vma->vm_flags & (VM_LOCKED|VM_HUGETLB|VM_PFNMAP))
80015 return -EINVAL;
80016 @@ -193,6 +209,21 @@ static long madvise_dontneed(struct vm_area_struct * vma,
80017 zap_page_range(vma, start, end - start, &details);
80018 } else
80019 zap_page_range(vma, start, end - start, NULL);
80020 +
80021 +#ifdef CONFIG_PAX_SEGMEXEC
80022 + vma_m = pax_find_mirror_vma(vma);
80023 + if (vma_m) {
80024 + if (unlikely(vma->vm_flags & VM_NONLINEAR)) {
80025 + struct zap_details details = {
80026 + .nonlinear_vma = vma_m,
80027 + .last_index = ULONG_MAX,
80028 + };
80029 + zap_page_range(vma, start + SEGMEXEC_TASK_SIZE, end - start, &details);
80030 + } else
80031 + zap_page_range(vma, start + SEGMEXEC_TASK_SIZE, end - start, NULL);
80032 + }
80033 +#endif
80034 +
80035 return 0;
80036 }
80037
80038 @@ -397,6 +428,16 @@ SYSCALL_DEFINE3(madvise, unsigned long, start, size_t, len_in, int, behavior)
80039 if (end < start)
80040 goto out;
80041
80042 +#ifdef CONFIG_PAX_SEGMEXEC
80043 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC) {
80044 + if (end > SEGMEXEC_TASK_SIZE)
80045 + goto out;
80046 + } else
80047 +#endif
80048 +
80049 + if (end > TASK_SIZE)
80050 + goto out;
80051 +
80052 error = 0;
80053 if (end == start)
80054 goto out;
80055 diff --git a/mm/memory-failure.c b/mm/memory-failure.c
80056 index c6e4dd3..1f41988 100644
80057 --- a/mm/memory-failure.c
80058 +++ b/mm/memory-failure.c
80059 @@ -61,7 +61,7 @@ int sysctl_memory_failure_early_kill __read_mostly = 0;
80060
80061 int sysctl_memory_failure_recovery __read_mostly = 1;
80062
80063 -atomic_long_t mce_bad_pages __read_mostly = ATOMIC_LONG_INIT(0);
80064 +atomic_long_unchecked_t mce_bad_pages __read_mostly = ATOMIC_LONG_INIT(0);
80065
80066 #if defined(CONFIG_HWPOISON_INJECT) || defined(CONFIG_HWPOISON_INJECT_MODULE)
80067
80068 @@ -202,7 +202,7 @@ static int kill_proc(struct task_struct *t, unsigned long addr, int trapno,
80069 pfn, t->comm, t->pid);
80070 si.si_signo = SIGBUS;
80071 si.si_errno = 0;
80072 - si.si_addr = (void *)addr;
80073 + si.si_addr = (void __user *)addr;
80074 #ifdef __ARCH_SI_TRAPNO
80075 si.si_trapno = trapno;
80076 #endif
80077 @@ -760,7 +760,7 @@ static struct page_state {
80078 unsigned long res;
80079 char *msg;
80080 int (*action)(struct page *p, unsigned long pfn);
80081 -} error_states[] = {
80082 +} __do_const error_states[] = {
80083 { reserved, reserved, "reserved kernel", me_kernel },
80084 /*
80085 * free pages are specially detected outside this table:
80086 @@ -1040,7 +1040,7 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
80087 }
80088
80089 nr_pages = 1 << compound_trans_order(hpage);
80090 - atomic_long_add(nr_pages, &mce_bad_pages);
80091 + atomic_long_add_unchecked(nr_pages, &mce_bad_pages);
80092
80093 /*
80094 * We need/can do nothing about count=0 pages.
80095 @@ -1070,7 +1070,7 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
80096 if (!PageHWPoison(hpage)
80097 || (hwpoison_filter(p) && TestClearPageHWPoison(p))
80098 || (p != hpage && TestSetPageHWPoison(hpage))) {
80099 - atomic_long_sub(nr_pages, &mce_bad_pages);
80100 + atomic_long_sub_unchecked(nr_pages, &mce_bad_pages);
80101 return 0;
80102 }
80103 set_page_hwpoison_huge_page(hpage);
80104 @@ -1128,7 +1128,7 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
80105 }
80106 if (hwpoison_filter(p)) {
80107 if (TestClearPageHWPoison(p))
80108 - atomic_long_sub(nr_pages, &mce_bad_pages);
80109 + atomic_long_sub_unchecked(nr_pages, &mce_bad_pages);
80110 unlock_page(hpage);
80111 put_page(hpage);
80112 return 0;
80113 @@ -1323,7 +1323,7 @@ int unpoison_memory(unsigned long pfn)
80114 return 0;
80115 }
80116 if (TestClearPageHWPoison(p))
80117 - atomic_long_sub(nr_pages, &mce_bad_pages);
80118 + atomic_long_sub_unchecked(nr_pages, &mce_bad_pages);
80119 pr_info("MCE: Software-unpoisoned free page %#lx\n", pfn);
80120 return 0;
80121 }
80122 @@ -1337,7 +1337,7 @@ int unpoison_memory(unsigned long pfn)
80123 */
80124 if (TestClearPageHWPoison(page)) {
80125 pr_info("MCE: Software-unpoisoned page %#lx\n", pfn);
80126 - atomic_long_sub(nr_pages, &mce_bad_pages);
80127 + atomic_long_sub_unchecked(nr_pages, &mce_bad_pages);
80128 freeit = 1;
80129 if (PageHuge(page))
80130 clear_page_hwpoison_huge_page(page);
80131 @@ -1442,7 +1442,7 @@ static int soft_offline_huge_page(struct page *page, int flags)
80132 }
80133 done:
80134 if (!PageHWPoison(hpage))
80135 - atomic_long_add(1 << compound_trans_order(hpage),
80136 + atomic_long_add_unchecked(1 << compound_trans_order(hpage),
80137 &mce_bad_pages);
80138 set_page_hwpoison_huge_page(hpage);
80139 dequeue_hwpoisoned_huge_page(hpage);
80140 @@ -1583,7 +1583,7 @@ int soft_offline_page(struct page *page, int flags)
80141 return ret;
80142
80143 done:
80144 - atomic_long_add(1, &mce_bad_pages);
80145 + atomic_long_add_unchecked(1, &mce_bad_pages);
80146 SetPageHWPoison(page);
80147 /* keep elevated page count for bad page */
80148 return ret;
80149 diff --git a/mm/memory.c b/mm/memory.c
80150 index bb1369f..efb96b5 100644
80151 --- a/mm/memory.c
80152 +++ b/mm/memory.c
80153 @@ -433,6 +433,7 @@ static inline void free_pmd_range(struct mmu_gather *tlb, pud_t *pud,
80154 free_pte_range(tlb, pmd, addr);
80155 } while (pmd++, addr = next, addr != end);
80156
80157 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_PER_CPU_PGD)
80158 start &= PUD_MASK;
80159 if (start < floor)
80160 return;
80161 @@ -447,6 +448,8 @@ static inline void free_pmd_range(struct mmu_gather *tlb, pud_t *pud,
80162 pmd = pmd_offset(pud, start);
80163 pud_clear(pud);
80164 pmd_free_tlb(tlb, pmd, start);
80165 +#endif
80166 +
80167 }
80168
80169 static inline void free_pud_range(struct mmu_gather *tlb, pgd_t *pgd,
80170 @@ -466,6 +469,7 @@ static inline void free_pud_range(struct mmu_gather *tlb, pgd_t *pgd,
80171 free_pmd_range(tlb, pud, addr, next, floor, ceiling);
80172 } while (pud++, addr = next, addr != end);
80173
80174 +#if !defined(CONFIG_X86_64) || !defined(CONFIG_PAX_PER_CPU_PGD)
80175 start &= PGDIR_MASK;
80176 if (start < floor)
80177 return;
80178 @@ -480,6 +484,8 @@ static inline void free_pud_range(struct mmu_gather *tlb, pgd_t *pgd,
80179 pud = pud_offset(pgd, start);
80180 pgd_clear(pgd);
80181 pud_free_tlb(tlb, pud, start);
80182 +#endif
80183 +
80184 }
80185
80186 /*
80187 @@ -1618,12 +1624,6 @@ no_page_table:
80188 return page;
80189 }
80190
80191 -static inline int stack_guard_page(struct vm_area_struct *vma, unsigned long addr)
80192 -{
80193 - return stack_guard_page_start(vma, addr) ||
80194 - stack_guard_page_end(vma, addr+PAGE_SIZE);
80195 -}
80196 -
80197 /**
80198 * __get_user_pages() - pin user pages in memory
80199 * @tsk: task_struct of target task
80200 @@ -1709,10 +1709,10 @@ int __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
80201
80202 i = 0;
80203
80204 - do {
80205 + while (nr_pages) {
80206 struct vm_area_struct *vma;
80207
80208 - vma = find_extend_vma(mm, start);
80209 + vma = find_vma(mm, start);
80210 if (!vma && in_gate_area(mm, start)) {
80211 unsigned long pg = start & PAGE_MASK;
80212 pgd_t *pgd;
80213 @@ -1760,7 +1760,7 @@ int __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
80214 goto next_page;
80215 }
80216
80217 - if (!vma ||
80218 + if (!vma || start < vma->vm_start ||
80219 (vma->vm_flags & (VM_IO | VM_PFNMAP)) ||
80220 !(vm_flags & vma->vm_flags))
80221 return i ? : -EFAULT;
80222 @@ -1787,11 +1787,6 @@ int __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
80223 int ret;
80224 unsigned int fault_flags = 0;
80225
80226 - /* For mlock, just skip the stack guard page. */
80227 - if (foll_flags & FOLL_MLOCK) {
80228 - if (stack_guard_page(vma, start))
80229 - goto next_page;
80230 - }
80231 if (foll_flags & FOLL_WRITE)
80232 fault_flags |= FAULT_FLAG_WRITE;
80233 if (nonblocking)
80234 @@ -1865,7 +1860,7 @@ next_page:
80235 start += PAGE_SIZE;
80236 nr_pages--;
80237 } while (nr_pages && start < vma->vm_end);
80238 - } while (nr_pages);
80239 + }
80240 return i;
80241 }
80242 EXPORT_SYMBOL(__get_user_pages);
80243 @@ -2072,6 +2067,10 @@ static int insert_page(struct vm_area_struct *vma, unsigned long addr,
80244 page_add_file_rmap(page);
80245 set_pte_at(mm, addr, pte, mk_pte(page, prot));
80246
80247 +#ifdef CONFIG_PAX_SEGMEXEC
80248 + pax_mirror_file_pte(vma, addr, page, ptl);
80249 +#endif
80250 +
80251 retval = 0;
80252 pte_unmap_unlock(pte, ptl);
80253 return retval;
80254 @@ -2116,9 +2115,21 @@ int vm_insert_page(struct vm_area_struct *vma, unsigned long addr,
80255 if (!page_count(page))
80256 return -EINVAL;
80257 if (!(vma->vm_flags & VM_MIXEDMAP)) {
80258 +
80259 +#ifdef CONFIG_PAX_SEGMEXEC
80260 + struct vm_area_struct *vma_m;
80261 +#endif
80262 +
80263 BUG_ON(down_read_trylock(&vma->vm_mm->mmap_sem));
80264 BUG_ON(vma->vm_flags & VM_PFNMAP);
80265 vma->vm_flags |= VM_MIXEDMAP;
80266 +
80267 +#ifdef CONFIG_PAX_SEGMEXEC
80268 + vma_m = pax_find_mirror_vma(vma);
80269 + if (vma_m)
80270 + vma_m->vm_flags |= VM_MIXEDMAP;
80271 +#endif
80272 +
80273 }
80274 return insert_page(vma, addr, page, vma->vm_page_prot);
80275 }
80276 @@ -2201,6 +2212,7 @@ int vm_insert_mixed(struct vm_area_struct *vma, unsigned long addr,
80277 unsigned long pfn)
80278 {
80279 BUG_ON(!(vma->vm_flags & VM_MIXEDMAP));
80280 + BUG_ON(vma->vm_mirror);
80281
80282 if (addr < vma->vm_start || addr >= vma->vm_end)
80283 return -EFAULT;
80284 @@ -2401,7 +2413,9 @@ static int apply_to_pmd_range(struct mm_struct *mm, pud_t *pud,
80285
80286 BUG_ON(pud_huge(*pud));
80287
80288 - pmd = pmd_alloc(mm, pud, addr);
80289 + pmd = (mm == &init_mm) ?
80290 + pmd_alloc_kernel(mm, pud, addr) :
80291 + pmd_alloc(mm, pud, addr);
80292 if (!pmd)
80293 return -ENOMEM;
80294 do {
80295 @@ -2421,7 +2435,9 @@ static int apply_to_pud_range(struct mm_struct *mm, pgd_t *pgd,
80296 unsigned long next;
80297 int err;
80298
80299 - pud = pud_alloc(mm, pgd, addr);
80300 + pud = (mm == &init_mm) ?
80301 + pud_alloc_kernel(mm, pgd, addr) :
80302 + pud_alloc(mm, pgd, addr);
80303 if (!pud)
80304 return -ENOMEM;
80305 do {
80306 @@ -2509,6 +2525,186 @@ static inline void cow_user_page(struct page *dst, struct page *src, unsigned lo
80307 copy_user_highpage(dst, src, va, vma);
80308 }
80309
80310 +#ifdef CONFIG_PAX_SEGMEXEC
80311 +static void pax_unmap_mirror_pte(struct vm_area_struct *vma, unsigned long address, pmd_t *pmd)
80312 +{
80313 + struct mm_struct *mm = vma->vm_mm;
80314 + spinlock_t *ptl;
80315 + pte_t *pte, entry;
80316 +
80317 + pte = pte_offset_map_lock(mm, pmd, address, &ptl);
80318 + entry = *pte;
80319 + if (!pte_present(entry)) {
80320 + if (!pte_none(entry)) {
80321 + BUG_ON(pte_file(entry));
80322 + free_swap_and_cache(pte_to_swp_entry(entry));
80323 + pte_clear_not_present_full(mm, address, pte, 0);
80324 + }
80325 + } else {
80326 + struct page *page;
80327 +
80328 + flush_cache_page(vma, address, pte_pfn(entry));
80329 + entry = ptep_clear_flush(vma, address, pte);
80330 + BUG_ON(pte_dirty(entry));
80331 + page = vm_normal_page(vma, address, entry);
80332 + if (page) {
80333 + update_hiwater_rss(mm);
80334 + if (PageAnon(page))
80335 + dec_mm_counter_fast(mm, MM_ANONPAGES);
80336 + else
80337 + dec_mm_counter_fast(mm, MM_FILEPAGES);
80338 + page_remove_rmap(page);
80339 + page_cache_release(page);
80340 + }
80341 + }
80342 + pte_unmap_unlock(pte, ptl);
80343 +}
80344 +
80345 +/* PaX: if vma is mirrored, synchronize the mirror's PTE
80346 + *
80347 + * the ptl of the lower mapped page is held on entry and is not released on exit
80348 + * or inside to ensure atomic changes to the PTE states (swapout, mremap, munmap, etc)
80349 + */
80350 +static void pax_mirror_anon_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m, spinlock_t *ptl)
80351 +{
80352 + struct mm_struct *mm = vma->vm_mm;
80353 + unsigned long address_m;
80354 + spinlock_t *ptl_m;
80355 + struct vm_area_struct *vma_m;
80356 + pmd_t *pmd_m;
80357 + pte_t *pte_m, entry_m;
80358 +
80359 + BUG_ON(!page_m || !PageAnon(page_m));
80360 +
80361 + vma_m = pax_find_mirror_vma(vma);
80362 + if (!vma_m)
80363 + return;
80364 +
80365 + BUG_ON(!PageLocked(page_m));
80366 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
80367 + address_m = address + SEGMEXEC_TASK_SIZE;
80368 + pmd_m = pmd_offset(pud_offset(pgd_offset(mm, address_m), address_m), address_m);
80369 + pte_m = pte_offset_map(pmd_m, address_m);
80370 + ptl_m = pte_lockptr(mm, pmd_m);
80371 + if (ptl != ptl_m) {
80372 + spin_lock_nested(ptl_m, SINGLE_DEPTH_NESTING);
80373 + if (!pte_none(*pte_m))
80374 + goto out;
80375 + }
80376 +
80377 + entry_m = pfn_pte(page_to_pfn(page_m), vma_m->vm_page_prot);
80378 + page_cache_get(page_m);
80379 + page_add_anon_rmap(page_m, vma_m, address_m);
80380 + inc_mm_counter_fast(mm, MM_ANONPAGES);
80381 + set_pte_at(mm, address_m, pte_m, entry_m);
80382 + update_mmu_cache(vma_m, address_m, entry_m);
80383 +out:
80384 + if (ptl != ptl_m)
80385 + spin_unlock(ptl_m);
80386 + pte_unmap(pte_m);
80387 + unlock_page(page_m);
80388 +}
80389 +
80390 +void pax_mirror_file_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m, spinlock_t *ptl)
80391 +{
80392 + struct mm_struct *mm = vma->vm_mm;
80393 + unsigned long address_m;
80394 + spinlock_t *ptl_m;
80395 + struct vm_area_struct *vma_m;
80396 + pmd_t *pmd_m;
80397 + pte_t *pte_m, entry_m;
80398 +
80399 + BUG_ON(!page_m || PageAnon(page_m));
80400 +
80401 + vma_m = pax_find_mirror_vma(vma);
80402 + if (!vma_m)
80403 + return;
80404 +
80405 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
80406 + address_m = address + SEGMEXEC_TASK_SIZE;
80407 + pmd_m = pmd_offset(pud_offset(pgd_offset(mm, address_m), address_m), address_m);
80408 + pte_m = pte_offset_map(pmd_m, address_m);
80409 + ptl_m = pte_lockptr(mm, pmd_m);
80410 + if (ptl != ptl_m) {
80411 + spin_lock_nested(ptl_m, SINGLE_DEPTH_NESTING);
80412 + if (!pte_none(*pte_m))
80413 + goto out;
80414 + }
80415 +
80416 + entry_m = pfn_pte(page_to_pfn(page_m), vma_m->vm_page_prot);
80417 + page_cache_get(page_m);
80418 + page_add_file_rmap(page_m);
80419 + inc_mm_counter_fast(mm, MM_FILEPAGES);
80420 + set_pte_at(mm, address_m, pte_m, entry_m);
80421 + update_mmu_cache(vma_m, address_m, entry_m);
80422 +out:
80423 + if (ptl != ptl_m)
80424 + spin_unlock(ptl_m);
80425 + pte_unmap(pte_m);
80426 +}
80427 +
80428 +static void pax_mirror_pfn_pte(struct vm_area_struct *vma, unsigned long address, unsigned long pfn_m, spinlock_t *ptl)
80429 +{
80430 + struct mm_struct *mm = vma->vm_mm;
80431 + unsigned long address_m;
80432 + spinlock_t *ptl_m;
80433 + struct vm_area_struct *vma_m;
80434 + pmd_t *pmd_m;
80435 + pte_t *pte_m, entry_m;
80436 +
80437 + vma_m = pax_find_mirror_vma(vma);
80438 + if (!vma_m)
80439 + return;
80440 +
80441 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
80442 + address_m = address + SEGMEXEC_TASK_SIZE;
80443 + pmd_m = pmd_offset(pud_offset(pgd_offset(mm, address_m), address_m), address_m);
80444 + pte_m = pte_offset_map(pmd_m, address_m);
80445 + ptl_m = pte_lockptr(mm, pmd_m);
80446 + if (ptl != ptl_m) {
80447 + spin_lock_nested(ptl_m, SINGLE_DEPTH_NESTING);
80448 + if (!pte_none(*pte_m))
80449 + goto out;
80450 + }
80451 +
80452 + entry_m = pfn_pte(pfn_m, vma_m->vm_page_prot);
80453 + set_pte_at(mm, address_m, pte_m, entry_m);
80454 +out:
80455 + if (ptl != ptl_m)
80456 + spin_unlock(ptl_m);
80457 + pte_unmap(pte_m);
80458 +}
80459 +
80460 +static void pax_mirror_pte(struct vm_area_struct *vma, unsigned long address, pte_t *pte, pmd_t *pmd, spinlock_t *ptl)
80461 +{
80462 + struct page *page_m;
80463 + pte_t entry;
80464 +
80465 + if (!(vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC))
80466 + goto out;
80467 +
80468 + entry = *pte;
80469 + page_m = vm_normal_page(vma, address, entry);
80470 + if (!page_m)
80471 + pax_mirror_pfn_pte(vma, address, pte_pfn(entry), ptl);
80472 + else if (PageAnon(page_m)) {
80473 + if (pax_find_mirror_vma(vma)) {
80474 + pte_unmap_unlock(pte, ptl);
80475 + lock_page(page_m);
80476 + pte = pte_offset_map_lock(vma->vm_mm, pmd, address, &ptl);
80477 + if (pte_same(entry, *pte))
80478 + pax_mirror_anon_pte(vma, address, page_m, ptl);
80479 + else
80480 + unlock_page(page_m);
80481 + }
80482 + } else
80483 + pax_mirror_file_pte(vma, address, page_m, ptl);
80484 +
80485 +out:
80486 + pte_unmap_unlock(pte, ptl);
80487 +}
80488 +#endif
80489 +
80490 /*
80491 * This routine handles present pages, when users try to write
80492 * to a shared page. It is done by copying the page to a new address
80493 @@ -2725,6 +2921,12 @@ gotten:
80494 */
80495 page_table = pte_offset_map_lock(mm, pmd, address, &ptl);
80496 if (likely(pte_same(*page_table, orig_pte))) {
80497 +
80498 +#ifdef CONFIG_PAX_SEGMEXEC
80499 + if (pax_find_mirror_vma(vma))
80500 + BUG_ON(!trylock_page(new_page));
80501 +#endif
80502 +
80503 if (old_page) {
80504 if (!PageAnon(old_page)) {
80505 dec_mm_counter_fast(mm, MM_FILEPAGES);
80506 @@ -2776,6 +2978,10 @@ gotten:
80507 page_remove_rmap(old_page);
80508 }
80509
80510 +#ifdef CONFIG_PAX_SEGMEXEC
80511 + pax_mirror_anon_pte(vma, address, new_page, ptl);
80512 +#endif
80513 +
80514 /* Free the old page.. */
80515 new_page = old_page;
80516 ret |= VM_FAULT_WRITE;
80517 @@ -3051,6 +3257,11 @@ static int do_swap_page(struct mm_struct *mm, struct vm_area_struct *vma,
80518 swap_free(entry);
80519 if (vm_swap_full() || (vma->vm_flags & VM_LOCKED) || PageMlocked(page))
80520 try_to_free_swap(page);
80521 +
80522 +#ifdef CONFIG_PAX_SEGMEXEC
80523 + if ((flags & FAULT_FLAG_WRITE) || !pax_find_mirror_vma(vma))
80524 +#endif
80525 +
80526 unlock_page(page);
80527 if (swapcache) {
80528 /*
80529 @@ -3074,6 +3285,11 @@ static int do_swap_page(struct mm_struct *mm, struct vm_area_struct *vma,
80530
80531 /* No need to invalidate - it was non-present before */
80532 update_mmu_cache(vma, address, page_table);
80533 +
80534 +#ifdef CONFIG_PAX_SEGMEXEC
80535 + pax_mirror_anon_pte(vma, address, page, ptl);
80536 +#endif
80537 +
80538 unlock:
80539 pte_unmap_unlock(page_table, ptl);
80540 out:
80541 @@ -3093,40 +3309,6 @@ out_release:
80542 }
80543
80544 /*
80545 - * This is like a special single-page "expand_{down|up}wards()",
80546 - * except we must first make sure that 'address{-|+}PAGE_SIZE'
80547 - * doesn't hit another vma.
80548 - */
80549 -static inline int check_stack_guard_page(struct vm_area_struct *vma, unsigned long address)
80550 -{
80551 - address &= PAGE_MASK;
80552 - if ((vma->vm_flags & VM_GROWSDOWN) && address == vma->vm_start) {
80553 - struct vm_area_struct *prev = vma->vm_prev;
80554 -
80555 - /*
80556 - * Is there a mapping abutting this one below?
80557 - *
80558 - * That's only ok if it's the same stack mapping
80559 - * that has gotten split..
80560 - */
80561 - if (prev && prev->vm_end == address)
80562 - return prev->vm_flags & VM_GROWSDOWN ? 0 : -ENOMEM;
80563 -
80564 - expand_downwards(vma, address - PAGE_SIZE);
80565 - }
80566 - if ((vma->vm_flags & VM_GROWSUP) && address + PAGE_SIZE == vma->vm_end) {
80567 - struct vm_area_struct *next = vma->vm_next;
80568 -
80569 - /* As VM_GROWSDOWN but s/below/above/ */
80570 - if (next && next->vm_start == address + PAGE_SIZE)
80571 - return next->vm_flags & VM_GROWSUP ? 0 : -ENOMEM;
80572 -
80573 - expand_upwards(vma, address + PAGE_SIZE);
80574 - }
80575 - return 0;
80576 -}
80577 -
80578 -/*
80579 * We enter with non-exclusive mmap_sem (to exclude vma changes,
80580 * but allow concurrent faults), and pte mapped but not yet locked.
80581 * We return with mmap_sem still held, but pte unmapped and unlocked.
80582 @@ -3135,27 +3317,23 @@ static int do_anonymous_page(struct mm_struct *mm, struct vm_area_struct *vma,
80583 unsigned long address, pte_t *page_table, pmd_t *pmd,
80584 unsigned int flags)
80585 {
80586 - struct page *page;
80587 + struct page *page = NULL;
80588 spinlock_t *ptl;
80589 pte_t entry;
80590
80591 - pte_unmap(page_table);
80592 -
80593 - /* Check if we need to add a guard page to the stack */
80594 - if (check_stack_guard_page(vma, address) < 0)
80595 - return VM_FAULT_SIGBUS;
80596 -
80597 - /* Use the zero-page for reads */
80598 if (!(flags & FAULT_FLAG_WRITE)) {
80599 entry = pte_mkspecial(pfn_pte(my_zero_pfn(address),
80600 vma->vm_page_prot));
80601 - page_table = pte_offset_map_lock(mm, pmd, address, &ptl);
80602 + ptl = pte_lockptr(mm, pmd);
80603 + spin_lock(ptl);
80604 if (!pte_none(*page_table))
80605 goto unlock;
80606 goto setpte;
80607 }
80608
80609 /* Allocate our own private page. */
80610 + pte_unmap(page_table);
80611 +
80612 if (unlikely(anon_vma_prepare(vma)))
80613 goto oom;
80614 page = alloc_zeroed_user_highpage_movable(vma, address);
80615 @@ -3174,6 +3352,11 @@ static int do_anonymous_page(struct mm_struct *mm, struct vm_area_struct *vma,
80616 if (!pte_none(*page_table))
80617 goto release;
80618
80619 +#ifdef CONFIG_PAX_SEGMEXEC
80620 + if (pax_find_mirror_vma(vma))
80621 + BUG_ON(!trylock_page(page));
80622 +#endif
80623 +
80624 inc_mm_counter_fast(mm, MM_ANONPAGES);
80625 page_add_new_anon_rmap(page, vma, address);
80626 setpte:
80627 @@ -3181,6 +3364,12 @@ setpte:
80628
80629 /* No need to invalidate - it was non-present before */
80630 update_mmu_cache(vma, address, page_table);
80631 +
80632 +#ifdef CONFIG_PAX_SEGMEXEC
80633 + if (page)
80634 + pax_mirror_anon_pte(vma, address, page, ptl);
80635 +#endif
80636 +
80637 unlock:
80638 pte_unmap_unlock(page_table, ptl);
80639 return 0;
80640 @@ -3324,6 +3513,12 @@ static int __do_fault(struct mm_struct *mm, struct vm_area_struct *vma,
80641 */
80642 /* Only go through if we didn't race with anybody else... */
80643 if (likely(pte_same(*page_table, orig_pte))) {
80644 +
80645 +#ifdef CONFIG_PAX_SEGMEXEC
80646 + if (anon && pax_find_mirror_vma(vma))
80647 + BUG_ON(!trylock_page(page));
80648 +#endif
80649 +
80650 flush_icache_page(vma, page);
80651 entry = mk_pte(page, vma->vm_page_prot);
80652 if (flags & FAULT_FLAG_WRITE)
80653 @@ -3343,6 +3538,14 @@ static int __do_fault(struct mm_struct *mm, struct vm_area_struct *vma,
80654
80655 /* no need to invalidate: a not-present page won't be cached */
80656 update_mmu_cache(vma, address, page_table);
80657 +
80658 +#ifdef CONFIG_PAX_SEGMEXEC
80659 + if (anon)
80660 + pax_mirror_anon_pte(vma, address, page, ptl);
80661 + else
80662 + pax_mirror_file_pte(vma, address, page, ptl);
80663 +#endif
80664 +
80665 } else {
80666 if (cow_page)
80667 mem_cgroup_uncharge_page(cow_page);
80668 @@ -3664,6 +3867,12 @@ int handle_pte_fault(struct mm_struct *mm,
80669 if (flags & FAULT_FLAG_WRITE)
80670 flush_tlb_fix_spurious_fault(vma, address);
80671 }
80672 +
80673 +#ifdef CONFIG_PAX_SEGMEXEC
80674 + pax_mirror_pte(vma, address, pte, pmd, ptl);
80675 + return 0;
80676 +#endif
80677 +
80678 unlock:
80679 pte_unmap_unlock(pte, ptl);
80680 return 0;
80681 @@ -3680,6 +3889,10 @@ int handle_mm_fault(struct mm_struct *mm, struct vm_area_struct *vma,
80682 pmd_t *pmd;
80683 pte_t *pte;
80684
80685 +#ifdef CONFIG_PAX_SEGMEXEC
80686 + struct vm_area_struct *vma_m;
80687 +#endif
80688 +
80689 __set_current_state(TASK_RUNNING);
80690
80691 count_vm_event(PGFAULT);
80692 @@ -3691,6 +3904,34 @@ int handle_mm_fault(struct mm_struct *mm, struct vm_area_struct *vma,
80693 if (unlikely(is_vm_hugetlb_page(vma)))
80694 return hugetlb_fault(mm, vma, address, flags);
80695
80696 +#ifdef CONFIG_PAX_SEGMEXEC
80697 + vma_m = pax_find_mirror_vma(vma);
80698 + if (vma_m) {
80699 + unsigned long address_m;
80700 + pgd_t *pgd_m;
80701 + pud_t *pud_m;
80702 + pmd_t *pmd_m;
80703 +
80704 + if (vma->vm_start > vma_m->vm_start) {
80705 + address_m = address;
80706 + address -= SEGMEXEC_TASK_SIZE;
80707 + vma = vma_m;
80708 + } else
80709 + address_m = address + SEGMEXEC_TASK_SIZE;
80710 +
80711 + pgd_m = pgd_offset(mm, address_m);
80712 + pud_m = pud_alloc(mm, pgd_m, address_m);
80713 + if (!pud_m)
80714 + return VM_FAULT_OOM;
80715 + pmd_m = pmd_alloc(mm, pud_m, address_m);
80716 + if (!pmd_m)
80717 + return VM_FAULT_OOM;
80718 + if (!pmd_present(*pmd_m) && __pte_alloc(mm, vma_m, pmd_m, address_m))
80719 + return VM_FAULT_OOM;
80720 + pax_unmap_mirror_pte(vma_m, address_m, pmd_m);
80721 + }
80722 +#endif
80723 +
80724 retry:
80725 pgd = pgd_offset(mm, address);
80726 pud = pud_alloc(mm, pgd, address);
80727 @@ -3789,6 +4030,23 @@ int __pud_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long address)
80728 spin_unlock(&mm->page_table_lock);
80729 return 0;
80730 }
80731 +
80732 +int __pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd, unsigned long address)
80733 +{
80734 + pud_t *new = pud_alloc_one(mm, address);
80735 + if (!new)
80736 + return -ENOMEM;
80737 +
80738 + smp_wmb(); /* See comment in __pte_alloc */
80739 +
80740 + spin_lock(&mm->page_table_lock);
80741 + if (pgd_present(*pgd)) /* Another has populated it */
80742 + pud_free(mm, new);
80743 + else
80744 + pgd_populate_kernel(mm, pgd, new);
80745 + spin_unlock(&mm->page_table_lock);
80746 + return 0;
80747 +}
80748 #endif /* __PAGETABLE_PUD_FOLDED */
80749
80750 #ifndef __PAGETABLE_PMD_FOLDED
80751 @@ -3819,6 +4077,30 @@ int __pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address)
80752 spin_unlock(&mm->page_table_lock);
80753 return 0;
80754 }
80755 +
80756 +int __pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud, unsigned long address)
80757 +{
80758 + pmd_t *new = pmd_alloc_one(mm, address);
80759 + if (!new)
80760 + return -ENOMEM;
80761 +
80762 + smp_wmb(); /* See comment in __pte_alloc */
80763 +
80764 + spin_lock(&mm->page_table_lock);
80765 +#ifndef __ARCH_HAS_4LEVEL_HACK
80766 + if (pud_present(*pud)) /* Another has populated it */
80767 + pmd_free(mm, new);
80768 + else
80769 + pud_populate_kernel(mm, pud, new);
80770 +#else
80771 + if (pgd_present(*pud)) /* Another has populated it */
80772 + pmd_free(mm, new);
80773 + else
80774 + pgd_populate_kernel(mm, pud, new);
80775 +#endif /* __ARCH_HAS_4LEVEL_HACK */
80776 + spin_unlock(&mm->page_table_lock);
80777 + return 0;
80778 +}
80779 #endif /* __PAGETABLE_PMD_FOLDED */
80780
80781 int make_pages_present(unsigned long addr, unsigned long end)
80782 @@ -3856,7 +4138,7 @@ static int __init gate_vma_init(void)
80783 gate_vma.vm_start = FIXADDR_USER_START;
80784 gate_vma.vm_end = FIXADDR_USER_END;
80785 gate_vma.vm_flags = VM_READ | VM_MAYREAD | VM_EXEC | VM_MAYEXEC;
80786 - gate_vma.vm_page_prot = __P101;
80787 + gate_vma.vm_page_prot = vm_get_page_prot(gate_vma.vm_flags);
80788
80789 return 0;
80790 }
80791 diff --git a/mm/mempolicy.c b/mm/mempolicy.c
80792 index 3df6d12..a11056a 100644
80793 --- a/mm/mempolicy.c
80794 +++ b/mm/mempolicy.c
80795 @@ -721,6 +721,10 @@ static int mbind_range(struct mm_struct *mm, unsigned long start,
80796 unsigned long vmstart;
80797 unsigned long vmend;
80798
80799 +#ifdef CONFIG_PAX_SEGMEXEC
80800 + struct vm_area_struct *vma_m;
80801 +#endif
80802 +
80803 vma = find_vma(mm, start);
80804 if (!vma || vma->vm_start > start)
80805 return -EFAULT;
80806 @@ -757,9 +761,20 @@ static int mbind_range(struct mm_struct *mm, unsigned long start,
80807 if (err)
80808 goto out;
80809 }
80810 +
80811 err = vma_replace_policy(vma, new_pol);
80812 if (err)
80813 goto out;
80814 +
80815 +#ifdef CONFIG_PAX_SEGMEXEC
80816 + vma_m = pax_find_mirror_vma(vma);
80817 + if (vma_m) {
80818 + err = vma_replace_policy(vma_m, new_pol);
80819 + if (err)
80820 + goto out;
80821 + }
80822 +#endif
80823 +
80824 }
80825
80826 out:
80827 @@ -1216,6 +1231,17 @@ static long do_mbind(unsigned long start, unsigned long len,
80828
80829 if (end < start)
80830 return -EINVAL;
80831 +
80832 +#ifdef CONFIG_PAX_SEGMEXEC
80833 + if (mm->pax_flags & MF_PAX_SEGMEXEC) {
80834 + if (end > SEGMEXEC_TASK_SIZE)
80835 + return -EINVAL;
80836 + } else
80837 +#endif
80838 +
80839 + if (end > TASK_SIZE)
80840 + return -EINVAL;
80841 +
80842 if (end == start)
80843 return 0;
80844
80845 @@ -1445,8 +1471,7 @@ SYSCALL_DEFINE4(migrate_pages, pid_t, pid, unsigned long, maxnode,
80846 */
80847 tcred = __task_cred(task);
80848 if (!uid_eq(cred->euid, tcred->suid) && !uid_eq(cred->euid, tcred->uid) &&
80849 - !uid_eq(cred->uid, tcred->suid) && !uid_eq(cred->uid, tcred->uid) &&
80850 - !capable(CAP_SYS_NICE)) {
80851 + !uid_eq(cred->uid, tcred->suid) && !capable(CAP_SYS_NICE)) {
80852 rcu_read_unlock();
80853 err = -EPERM;
80854 goto out_put;
80855 @@ -1477,6 +1502,15 @@ SYSCALL_DEFINE4(migrate_pages, pid_t, pid, unsigned long, maxnode,
80856 goto out;
80857 }
80858
80859 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
80860 + if (mm != current->mm &&
80861 + (mm->pax_flags & MF_PAX_RANDMMAP || mm->pax_flags & MF_PAX_SEGMEXEC)) {
80862 + mmput(mm);
80863 + err = -EPERM;
80864 + goto out;
80865 + }
80866 +#endif
80867 +
80868 err = do_migrate_pages(mm, old, new,
80869 capable(CAP_SYS_NICE) ? MPOL_MF_MOVE_ALL : MPOL_MF_MOVE);
80870
80871 diff --git a/mm/migrate.c b/mm/migrate.c
80872 index 2fd8b4a..d70358f 100644
80873 --- a/mm/migrate.c
80874 +++ b/mm/migrate.c
80875 @@ -1401,8 +1401,7 @@ SYSCALL_DEFINE6(move_pages, pid_t, pid, unsigned long, nr_pages,
80876 */
80877 tcred = __task_cred(task);
80878 if (!uid_eq(cred->euid, tcred->suid) && !uid_eq(cred->euid, tcred->uid) &&
80879 - !uid_eq(cred->uid, tcred->suid) && !uid_eq(cred->uid, tcred->uid) &&
80880 - !capable(CAP_SYS_NICE)) {
80881 + !uid_eq(cred->uid, tcred->suid) && !capable(CAP_SYS_NICE)) {
80882 rcu_read_unlock();
80883 err = -EPERM;
80884 goto out;
80885 diff --git a/mm/mlock.c b/mm/mlock.c
80886 index c9bd528..da8d069 100644
80887 --- a/mm/mlock.c
80888 +++ b/mm/mlock.c
80889 @@ -13,6 +13,7 @@
80890 #include <linux/pagemap.h>
80891 #include <linux/mempolicy.h>
80892 #include <linux/syscalls.h>
80893 +#include <linux/security.h>
80894 #include <linux/sched.h>
80895 #include <linux/export.h>
80896 #include <linux/rmap.h>
80897 @@ -369,7 +370,7 @@ static int do_mlock(unsigned long start, size_t len, int on)
80898 {
80899 unsigned long nstart, end, tmp;
80900 struct vm_area_struct * vma, * prev;
80901 - int error;
80902 + int error = 0;
80903
80904 VM_BUG_ON(start & ~PAGE_MASK);
80905 VM_BUG_ON(len != PAGE_ALIGN(len));
80906 @@ -378,6 +379,9 @@ static int do_mlock(unsigned long start, size_t len, int on)
80907 return -EINVAL;
80908 if (end == start)
80909 return 0;
80910 + if (end > TASK_SIZE)
80911 + return -EINVAL;
80912 +
80913 vma = find_vma(current->mm, start);
80914 if (!vma || vma->vm_start > start)
80915 return -ENOMEM;
80916 @@ -389,6 +393,11 @@ static int do_mlock(unsigned long start, size_t len, int on)
80917 for (nstart = start ; ; ) {
80918 vm_flags_t newflags;
80919
80920 +#ifdef CONFIG_PAX_SEGMEXEC
80921 + if ((current->mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_start >= SEGMEXEC_TASK_SIZE))
80922 + break;
80923 +#endif
80924 +
80925 /* Here we know that vma->vm_start <= nstart < vma->vm_end. */
80926
80927 newflags = vma->vm_flags | VM_LOCKED;
80928 @@ -494,6 +503,7 @@ SYSCALL_DEFINE2(mlock, unsigned long, start, size_t, len)
80929 lock_limit >>= PAGE_SHIFT;
80930
80931 /* check against resource limits */
80932 + gr_learn_resource(current, RLIMIT_MEMLOCK, (current->mm->locked_vm << PAGE_SHIFT) + len, 1);
80933 if ((locked <= lock_limit) || capable(CAP_IPC_LOCK))
80934 error = do_mlock(start, len, 1);
80935 up_write(&current->mm->mmap_sem);
80936 @@ -528,6 +538,12 @@ static int do_mlockall(int flags)
80937 for (vma = current->mm->mmap; vma ; vma = prev->vm_next) {
80938 vm_flags_t newflags;
80939
80940 +#ifdef CONFIG_PAX_SEGMEXEC
80941 + if ((current->mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_start >= SEGMEXEC_TASK_SIZE))
80942 + break;
80943 +#endif
80944 +
80945 + BUG_ON(vma->vm_end > TASK_SIZE);
80946 newflags = vma->vm_flags | VM_LOCKED;
80947 if (!(flags & MCL_CURRENT))
80948 newflags &= ~VM_LOCKED;
80949 @@ -560,6 +576,7 @@ SYSCALL_DEFINE1(mlockall, int, flags)
80950 lock_limit >>= PAGE_SHIFT;
80951
80952 ret = -ENOMEM;
80953 + gr_learn_resource(current, RLIMIT_MEMLOCK, current->mm->total_vm << PAGE_SHIFT, 1);
80954 if (!(flags & MCL_CURRENT) || (current->mm->total_vm <= lock_limit) ||
80955 capable(CAP_IPC_LOCK))
80956 ret = do_mlockall(flags);
80957 diff --git a/mm/mmap.c b/mm/mmap.c
80958 index 8832b87..4bbb1b2 100644
80959 --- a/mm/mmap.c
80960 +++ b/mm/mmap.c
80961 @@ -32,6 +32,7 @@
80962 #include <linux/khugepaged.h>
80963 #include <linux/uprobes.h>
80964 #include <linux/rbtree_augmented.h>
80965 +#include <linux/random.h>
80966
80967 #include <asm/uaccess.h>
80968 #include <asm/cacheflush.h>
80969 @@ -48,6 +49,16 @@
80970 #define arch_rebalance_pgtables(addr, len) (addr)
80971 #endif
80972
80973 +static inline void verify_mm_writelocked(struct mm_struct *mm)
80974 +{
80975 +#if defined(CONFIG_DEBUG_VM) || defined(CONFIG_PAX)
80976 + if (unlikely(down_read_trylock(&mm->mmap_sem))) {
80977 + up_read(&mm->mmap_sem);
80978 + BUG();
80979 + }
80980 +#endif
80981 +}
80982 +
80983 static void unmap_region(struct mm_struct *mm,
80984 struct vm_area_struct *vma, struct vm_area_struct *prev,
80985 unsigned long start, unsigned long end);
80986 @@ -67,22 +78,32 @@ static void unmap_region(struct mm_struct *mm,
80987 * x: (no) no x: (no) yes x: (no) yes x: (yes) yes
80988 *
80989 */
80990 -pgprot_t protection_map[16] = {
80991 +pgprot_t protection_map[16] __read_only = {
80992 __P000, __P001, __P010, __P011, __P100, __P101, __P110, __P111,
80993 __S000, __S001, __S010, __S011, __S100, __S101, __S110, __S111
80994 };
80995
80996 -pgprot_t vm_get_page_prot(unsigned long vm_flags)
80997 +pgprot_t vm_get_page_prot(vm_flags_t vm_flags)
80998 {
80999 - return __pgprot(pgprot_val(protection_map[vm_flags &
81000 + pgprot_t prot = __pgprot(pgprot_val(protection_map[vm_flags &
81001 (VM_READ|VM_WRITE|VM_EXEC|VM_SHARED)]) |
81002 pgprot_val(arch_vm_get_page_prot(vm_flags)));
81003 +
81004 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
81005 + if (!(__supported_pte_mask & _PAGE_NX) &&
81006 + (vm_flags & (VM_PAGEEXEC | VM_EXEC)) == VM_PAGEEXEC &&
81007 + (vm_flags & (VM_READ | VM_WRITE)))
81008 + prot = __pgprot(pte_val(pte_exprotect(__pte(pgprot_val(prot)))));
81009 +#endif
81010 +
81011 + return prot;
81012 }
81013 EXPORT_SYMBOL(vm_get_page_prot);
81014
81015 int sysctl_overcommit_memory __read_mostly = OVERCOMMIT_GUESS; /* heuristic overcommit */
81016 int sysctl_overcommit_ratio __read_mostly = 50; /* default is 50% */
81017 int sysctl_max_map_count __read_mostly = DEFAULT_MAX_MAP_COUNT;
81018 +unsigned long sysctl_heap_stack_gap __read_mostly = 64*1024;
81019 /*
81020 * Make sure vm_committed_as in one cacheline and not cacheline shared with
81021 * other variables. It can be updated by several CPUs frequently.
81022 @@ -238,6 +259,7 @@ static struct vm_area_struct *remove_vma(struct vm_area_struct *vma)
81023 struct vm_area_struct *next = vma->vm_next;
81024
81025 might_sleep();
81026 + BUG_ON(vma->vm_mirror);
81027 if (vma->vm_ops && vma->vm_ops->close)
81028 vma->vm_ops->close(vma);
81029 if (vma->vm_file)
81030 @@ -281,6 +303,7 @@ SYSCALL_DEFINE1(brk, unsigned long, brk)
81031 * not page aligned -Ram Gupta
81032 */
81033 rlim = rlimit(RLIMIT_DATA);
81034 + gr_learn_resource(current, RLIMIT_DATA, (brk - mm->start_brk) + (mm->end_data - mm->start_data), 1);
81035 if (rlim < RLIM_INFINITY && (brk - mm->start_brk) +
81036 (mm->end_data - mm->start_data) > rlim)
81037 goto out;
81038 @@ -888,6 +911,12 @@ static int
81039 can_vma_merge_before(struct vm_area_struct *vma, unsigned long vm_flags,
81040 struct anon_vma *anon_vma, struct file *file, pgoff_t vm_pgoff)
81041 {
81042 +
81043 +#ifdef CONFIG_PAX_SEGMEXEC
81044 + if ((vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) && vma->vm_start == SEGMEXEC_TASK_SIZE)
81045 + return 0;
81046 +#endif
81047 +
81048 if (is_mergeable_vma(vma, file, vm_flags) &&
81049 is_mergeable_anon_vma(anon_vma, vma->anon_vma, vma)) {
81050 if (vma->vm_pgoff == vm_pgoff)
81051 @@ -907,6 +936,12 @@ static int
81052 can_vma_merge_after(struct vm_area_struct *vma, unsigned long vm_flags,
81053 struct anon_vma *anon_vma, struct file *file, pgoff_t vm_pgoff)
81054 {
81055 +
81056 +#ifdef CONFIG_PAX_SEGMEXEC
81057 + if ((vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) && vma->vm_end == SEGMEXEC_TASK_SIZE)
81058 + return 0;
81059 +#endif
81060 +
81061 if (is_mergeable_vma(vma, file, vm_flags) &&
81062 is_mergeable_anon_vma(anon_vma, vma->anon_vma, vma)) {
81063 pgoff_t vm_pglen;
81064 @@ -949,13 +984,20 @@ can_vma_merge_after(struct vm_area_struct *vma, unsigned long vm_flags,
81065 struct vm_area_struct *vma_merge(struct mm_struct *mm,
81066 struct vm_area_struct *prev, unsigned long addr,
81067 unsigned long end, unsigned long vm_flags,
81068 - struct anon_vma *anon_vma, struct file *file,
81069 + struct anon_vma *anon_vma, struct file *file,
81070 pgoff_t pgoff, struct mempolicy *policy)
81071 {
81072 pgoff_t pglen = (end - addr) >> PAGE_SHIFT;
81073 struct vm_area_struct *area, *next;
81074 int err;
81075
81076 +#ifdef CONFIG_PAX_SEGMEXEC
81077 + unsigned long addr_m = addr + SEGMEXEC_TASK_SIZE, end_m = end + SEGMEXEC_TASK_SIZE;
81078 + struct vm_area_struct *area_m = NULL, *next_m = NULL, *prev_m = NULL;
81079 +
81080 + BUG_ON((mm->pax_flags & MF_PAX_SEGMEXEC) && SEGMEXEC_TASK_SIZE < end);
81081 +#endif
81082 +
81083 /*
81084 * We later require that vma->vm_flags == vm_flags,
81085 * so this tests vma->vm_flags & VM_SPECIAL, too.
81086 @@ -971,6 +1013,15 @@ struct vm_area_struct *vma_merge(struct mm_struct *mm,
81087 if (next && next->vm_end == end) /* cases 6, 7, 8 */
81088 next = next->vm_next;
81089
81090 +#ifdef CONFIG_PAX_SEGMEXEC
81091 + if (prev)
81092 + prev_m = pax_find_mirror_vma(prev);
81093 + if (area)
81094 + area_m = pax_find_mirror_vma(area);
81095 + if (next)
81096 + next_m = pax_find_mirror_vma(next);
81097 +#endif
81098 +
81099 /*
81100 * Can it merge with the predecessor?
81101 */
81102 @@ -990,9 +1041,24 @@ struct vm_area_struct *vma_merge(struct mm_struct *mm,
81103 /* cases 1, 6 */
81104 err = vma_adjust(prev, prev->vm_start,
81105 next->vm_end, prev->vm_pgoff, NULL);
81106 - } else /* cases 2, 5, 7 */
81107 +
81108 +#ifdef CONFIG_PAX_SEGMEXEC
81109 + if (!err && prev_m)
81110 + err = vma_adjust(prev_m, prev_m->vm_start,
81111 + next_m->vm_end, prev_m->vm_pgoff, NULL);
81112 +#endif
81113 +
81114 + } else { /* cases 2, 5, 7 */
81115 err = vma_adjust(prev, prev->vm_start,
81116 end, prev->vm_pgoff, NULL);
81117 +
81118 +#ifdef CONFIG_PAX_SEGMEXEC
81119 + if (!err && prev_m)
81120 + err = vma_adjust(prev_m, prev_m->vm_start,
81121 + end_m, prev_m->vm_pgoff, NULL);
81122 +#endif
81123 +
81124 + }
81125 if (err)
81126 return NULL;
81127 khugepaged_enter_vma_merge(prev);
81128 @@ -1006,12 +1072,27 @@ struct vm_area_struct *vma_merge(struct mm_struct *mm,
81129 mpol_equal(policy, vma_policy(next)) &&
81130 can_vma_merge_before(next, vm_flags,
81131 anon_vma, file, pgoff+pglen)) {
81132 - if (prev && addr < prev->vm_end) /* case 4 */
81133 + if (prev && addr < prev->vm_end) { /* case 4 */
81134 err = vma_adjust(prev, prev->vm_start,
81135 addr, prev->vm_pgoff, NULL);
81136 - else /* cases 3, 8 */
81137 +
81138 +#ifdef CONFIG_PAX_SEGMEXEC
81139 + if (!err && prev_m)
81140 + err = vma_adjust(prev_m, prev_m->vm_start,
81141 + addr_m, prev_m->vm_pgoff, NULL);
81142 +#endif
81143 +
81144 + } else { /* cases 3, 8 */
81145 err = vma_adjust(area, addr, next->vm_end,
81146 next->vm_pgoff - pglen, NULL);
81147 +
81148 +#ifdef CONFIG_PAX_SEGMEXEC
81149 + if (!err && area_m)
81150 + err = vma_adjust(area_m, addr_m, next_m->vm_end,
81151 + next_m->vm_pgoff - pglen, NULL);
81152 +#endif
81153 +
81154 + }
81155 if (err)
81156 return NULL;
81157 khugepaged_enter_vma_merge(area);
81158 @@ -1120,8 +1201,10 @@ none:
81159 void vm_stat_account(struct mm_struct *mm, unsigned long flags,
81160 struct file *file, long pages)
81161 {
81162 - const unsigned long stack_flags
81163 - = VM_STACK_FLAGS & (VM_GROWSUP|VM_GROWSDOWN);
81164 +
81165 +#ifdef CONFIG_PAX_RANDMMAP
81166 + if (!(mm->pax_flags & MF_PAX_RANDMMAP) || (flags & (VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)))
81167 +#endif
81168
81169 mm->total_vm += pages;
81170
81171 @@ -1129,7 +1212,7 @@ void vm_stat_account(struct mm_struct *mm, unsigned long flags,
81172 mm->shared_vm += pages;
81173 if ((flags & (VM_EXEC|VM_WRITE)) == VM_EXEC)
81174 mm->exec_vm += pages;
81175 - } else if (flags & stack_flags)
81176 + } else if (flags & (VM_GROWSUP|VM_GROWSDOWN))
81177 mm->stack_vm += pages;
81178 }
81179 #endif /* CONFIG_PROC_FS */
81180 @@ -1165,7 +1248,7 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
81181 * (the exception is when the underlying filesystem is noexec
81182 * mounted, in which case we dont add PROT_EXEC.)
81183 */
81184 - if ((prot & PROT_READ) && (current->personality & READ_IMPLIES_EXEC))
81185 + if ((prot & (PROT_READ | PROT_WRITE)) && (current->personality & READ_IMPLIES_EXEC))
81186 if (!(file && (file->f_path.mnt->mnt_flags & MNT_NOEXEC)))
81187 prot |= PROT_EXEC;
81188
81189 @@ -1191,7 +1274,7 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
81190 /* Obtain the address to map to. we verify (or select) it and ensure
81191 * that it represents a valid section of the address space.
81192 */
81193 - addr = get_unmapped_area(file, addr, len, pgoff, flags);
81194 + addr = get_unmapped_area(file, addr, len, pgoff, flags | ((prot & PROT_EXEC) ? MAP_EXECUTABLE : 0));
81195 if (addr & ~PAGE_MASK)
81196 return addr;
81197
81198 @@ -1202,6 +1285,36 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
81199 vm_flags = calc_vm_prot_bits(prot) | calc_vm_flag_bits(flags) |
81200 mm->def_flags | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC;
81201
81202 +#ifdef CONFIG_PAX_MPROTECT
81203 + if (mm->pax_flags & MF_PAX_MPROTECT) {
81204 +#ifndef CONFIG_PAX_MPROTECT_COMPAT
81205 + if ((vm_flags & (VM_WRITE | VM_EXEC)) == (VM_WRITE | VM_EXEC)) {
81206 + gr_log_rwxmmap(file);
81207 +
81208 +#ifdef CONFIG_PAX_EMUPLT
81209 + vm_flags &= ~VM_EXEC;
81210 +#else
81211 + return -EPERM;
81212 +#endif
81213 +
81214 + }
81215 +
81216 + if (!(vm_flags & VM_EXEC))
81217 + vm_flags &= ~VM_MAYEXEC;
81218 +#else
81219 + if ((vm_flags & (VM_WRITE | VM_EXEC)) != VM_EXEC)
81220 + vm_flags &= ~(VM_EXEC | VM_MAYEXEC);
81221 +#endif
81222 + else
81223 + vm_flags &= ~VM_MAYWRITE;
81224 + }
81225 +#endif
81226 +
81227 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
81228 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && file)
81229 + vm_flags &= ~VM_PAGEEXEC;
81230 +#endif
81231 +
81232 if (flags & MAP_LOCKED)
81233 if (!can_do_mlock())
81234 return -EPERM;
81235 @@ -1213,6 +1326,7 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
81236 locked += mm->locked_vm;
81237 lock_limit = rlimit(RLIMIT_MEMLOCK);
81238 lock_limit >>= PAGE_SHIFT;
81239 + gr_learn_resource(current, RLIMIT_MEMLOCK, locked << PAGE_SHIFT, 1);
81240 if (locked > lock_limit && !capable(CAP_IPC_LOCK))
81241 return -EAGAIN;
81242 }
81243 @@ -1279,6 +1393,9 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
81244 }
81245 }
81246
81247 + if (!gr_acl_handle_mmap(file, prot))
81248 + return -EACCES;
81249 +
81250 return mmap_region(file, addr, len, flags, vm_flags, pgoff);
81251 }
81252
81253 @@ -1356,7 +1473,7 @@ int vma_wants_writenotify(struct vm_area_struct *vma)
81254 vm_flags_t vm_flags = vma->vm_flags;
81255
81256 /* If it was private or non-writable, the write bit is already clear */
81257 - if ((vm_flags & (VM_WRITE|VM_SHARED)) != ((VM_WRITE|VM_SHARED)))
81258 + if ((vm_flags & (VM_WRITE|VM_SHARED)) != (VM_WRITE|VM_SHARED))
81259 return 0;
81260
81261 /* The backer wishes to know when pages are first written to? */
81262 @@ -1405,16 +1522,30 @@ unsigned long mmap_region(struct file *file, unsigned long addr,
81263 unsigned long charged = 0;
81264 struct inode *inode = file ? file->f_path.dentry->d_inode : NULL;
81265
81266 +#ifdef CONFIG_PAX_SEGMEXEC
81267 + struct vm_area_struct *vma_m = NULL;
81268 +#endif
81269 +
81270 + /*
81271 + * mm->mmap_sem is required to protect against another thread
81272 + * changing the mappings in case we sleep.
81273 + */
81274 + verify_mm_writelocked(mm);
81275 +
81276 /* Clear old maps */
81277 error = -ENOMEM;
81278 -munmap_back:
81279 if (find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent)) {
81280 if (do_munmap(mm, addr, len))
81281 return -ENOMEM;
81282 - goto munmap_back;
81283 + BUG_ON(find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent));
81284 }
81285
81286 /* Check against address space limit. */
81287 +
81288 +#ifdef CONFIG_PAX_RANDMMAP
81289 + if (!(mm->pax_flags & MF_PAX_RANDMMAP) || (vm_flags & (VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)))
81290 +#endif
81291 +
81292 if (!may_expand_vm(mm, len >> PAGE_SHIFT))
81293 return -ENOMEM;
81294
81295 @@ -1460,6 +1591,16 @@ munmap_back:
81296 goto unacct_error;
81297 }
81298
81299 +#ifdef CONFIG_PAX_SEGMEXEC
81300 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (vm_flags & VM_EXEC)) {
81301 + vma_m = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
81302 + if (!vma_m) {
81303 + error = -ENOMEM;
81304 + goto free_vma;
81305 + }
81306 + }
81307 +#endif
81308 +
81309 vma->vm_mm = mm;
81310 vma->vm_start = addr;
81311 vma->vm_end = addr + len;
81312 @@ -1484,6 +1625,13 @@ munmap_back:
81313 if (error)
81314 goto unmap_and_free_vma;
81315
81316 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
81317 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && !(vma->vm_flags & VM_SPECIAL)) {
81318 + vma->vm_flags |= VM_PAGEEXEC;
81319 + vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
81320 + }
81321 +#endif
81322 +
81323 /* Can addr have changed??
81324 *
81325 * Answer: Yes, several device drivers can do it in their
81326 @@ -1522,6 +1670,11 @@ munmap_back:
81327 vma_link(mm, vma, prev, rb_link, rb_parent);
81328 file = vma->vm_file;
81329
81330 +#ifdef CONFIG_PAX_SEGMEXEC
81331 + if (vma_m)
81332 + BUG_ON(pax_mirror_vma(vma_m, vma));
81333 +#endif
81334 +
81335 /* Once vma denies write, undo our temporary denial count */
81336 if (correct_wcount)
81337 atomic_inc(&inode->i_writecount);
81338 @@ -1529,6 +1682,7 @@ out:
81339 perf_event_mmap(vma);
81340
81341 vm_stat_account(mm, vm_flags, file, len >> PAGE_SHIFT);
81342 + track_exec_limit(mm, addr, addr + len, vm_flags);
81343 if (vm_flags & VM_LOCKED) {
81344 if (!mlock_vma_pages_range(vma, addr, addr + len))
81345 mm->locked_vm += (len >> PAGE_SHIFT);
81346 @@ -1550,6 +1704,12 @@ unmap_and_free_vma:
81347 unmap_region(mm, vma, prev, vma->vm_start, vma->vm_end);
81348 charged = 0;
81349 free_vma:
81350 +
81351 +#ifdef CONFIG_PAX_SEGMEXEC
81352 + if (vma_m)
81353 + kmem_cache_free(vm_area_cachep, vma_m);
81354 +#endif
81355 +
81356 kmem_cache_free(vm_area_cachep, vma);
81357 unacct_error:
81358 if (charged)
81359 @@ -1557,6 +1717,62 @@ unacct_error:
81360 return error;
81361 }
81362
81363 +#ifdef CONFIG_GRKERNSEC_RAND_THREADSTACK
81364 +unsigned long gr_rand_threadstack_offset(const struct mm_struct *mm, const struct file *filp, unsigned long flags)
81365 +{
81366 + if ((mm->pax_flags & MF_PAX_RANDMMAP) && !filp && (flags & MAP_STACK))
81367 + return (random32() & 0xFF) << PAGE_SHIFT;
81368 +
81369 + return 0;
81370 +}
81371 +#endif
81372 +
81373 +bool check_heap_stack_gap(const struct vm_area_struct *vma, unsigned long addr, unsigned long len, unsigned long offset)
81374 +{
81375 + if (!vma) {
81376 +#ifdef CONFIG_STACK_GROWSUP
81377 + if (addr > sysctl_heap_stack_gap)
81378 + vma = find_vma(current->mm, addr - sysctl_heap_stack_gap);
81379 + else
81380 + vma = find_vma(current->mm, 0);
81381 + if (vma && (vma->vm_flags & VM_GROWSUP))
81382 + return false;
81383 +#endif
81384 + return true;
81385 + }
81386 +
81387 + if (addr + len > vma->vm_start)
81388 + return false;
81389 +
81390 + if (vma->vm_flags & VM_GROWSDOWN)
81391 + return sysctl_heap_stack_gap <= vma->vm_start - addr - len;
81392 +#ifdef CONFIG_STACK_GROWSUP
81393 + else if (vma->vm_prev && (vma->vm_prev->vm_flags & VM_GROWSUP))
81394 + return addr - vma->vm_prev->vm_end <= sysctl_heap_stack_gap;
81395 +#endif
81396 + else if (offset)
81397 + return offset <= vma->vm_start - addr - len;
81398 +
81399 + return true;
81400 +}
81401 +
81402 +unsigned long skip_heap_stack_gap(const struct vm_area_struct *vma, unsigned long len, unsigned long offset)
81403 +{
81404 + if (vma->vm_start < len)
81405 + return -ENOMEM;
81406 +
81407 + if (!(vma->vm_flags & VM_GROWSDOWN)) {
81408 + if (offset <= vma->vm_start - len)
81409 + return vma->vm_start - len - offset;
81410 + else
81411 + return -ENOMEM;
81412 + }
81413 +
81414 + if (sysctl_heap_stack_gap <= vma->vm_start - len)
81415 + return vma->vm_start - len - sysctl_heap_stack_gap;
81416 + return -ENOMEM;
81417 +}
81418 +
81419 unsigned long unmapped_area(struct vm_unmapped_area_info *info)
81420 {
81421 /*
81422 @@ -1776,6 +1992,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
81423 struct mm_struct *mm = current->mm;
81424 struct vm_area_struct *vma;
81425 struct vm_unmapped_area_info info;
81426 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
81427
81428 if (len > TASK_SIZE)
81429 return -ENOMEM;
81430 @@ -1783,17 +2000,26 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
81431 if (flags & MAP_FIXED)
81432 return addr;
81433
81434 +#ifdef CONFIG_PAX_RANDMMAP
81435 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
81436 +#endif
81437 +
81438 if (addr) {
81439 addr = PAGE_ALIGN(addr);
81440 vma = find_vma(mm, addr);
81441 - if (TASK_SIZE - len >= addr &&
81442 - (!vma || addr + len <= vma->vm_start))
81443 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
81444 return addr;
81445 }
81446
81447 info.flags = 0;
81448 info.length = len;
81449 info.low_limit = TASK_UNMAPPED_BASE;
81450 +
81451 +#ifdef CONFIG_PAX_RANDMMAP
81452 + if (mm->pax_flags & MF_PAX_RANDMMAP)
81453 + info.low_limit += mm->delta_mmap;
81454 +#endif
81455 +
81456 info.high_limit = TASK_SIZE;
81457 info.align_mask = 0;
81458 return vm_unmapped_area(&info);
81459 @@ -1802,10 +2028,16 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
81460
81461 void arch_unmap_area(struct mm_struct *mm, unsigned long addr)
81462 {
81463 +
81464 +#ifdef CONFIG_PAX_SEGMEXEC
81465 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && SEGMEXEC_TASK_SIZE <= addr)
81466 + return;
81467 +#endif
81468 +
81469 /*
81470 * Is this a new hole at the lowest possible address?
81471 */
81472 - if (addr >= TASK_UNMAPPED_BASE && addr < mm->free_area_cache)
81473 + if (addr >= mm->mmap_base && addr < mm->free_area_cache)
81474 mm->free_area_cache = addr;
81475 }
81476
81477 @@ -1823,6 +2055,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
81478 struct mm_struct *mm = current->mm;
81479 unsigned long addr = addr0;
81480 struct vm_unmapped_area_info info;
81481 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
81482
81483 /* requested length too big for entire address space */
81484 if (len > TASK_SIZE)
81485 @@ -1831,12 +2064,15 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
81486 if (flags & MAP_FIXED)
81487 return addr;
81488
81489 +#ifdef CONFIG_PAX_RANDMMAP
81490 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
81491 +#endif
81492 +
81493 /* requesting a specific address */
81494 if (addr) {
81495 addr = PAGE_ALIGN(addr);
81496 vma = find_vma(mm, addr);
81497 - if (TASK_SIZE - len >= addr &&
81498 - (!vma || addr + len <= vma->vm_start))
81499 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
81500 return addr;
81501 }
81502
81503 @@ -1857,6 +2093,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
81504 VM_BUG_ON(addr != -ENOMEM);
81505 info.flags = 0;
81506 info.low_limit = TASK_UNMAPPED_BASE;
81507 +
81508 +#ifdef CONFIG_PAX_RANDMMAP
81509 + if (mm->pax_flags & MF_PAX_RANDMMAP)
81510 + info.low_limit += mm->delta_mmap;
81511 +#endif
81512 +
81513 info.high_limit = TASK_SIZE;
81514 addr = vm_unmapped_area(&info);
81515 }
81516 @@ -1867,6 +2109,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
81517
81518 void arch_unmap_area_topdown(struct mm_struct *mm, unsigned long addr)
81519 {
81520 +
81521 +#ifdef CONFIG_PAX_SEGMEXEC
81522 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && SEGMEXEC_TASK_SIZE <= addr)
81523 + return;
81524 +#endif
81525 +
81526 /*
81527 * Is this a new hole at the highest possible address?
81528 */
81529 @@ -1874,8 +2122,10 @@ void arch_unmap_area_topdown(struct mm_struct *mm, unsigned long addr)
81530 mm->free_area_cache = addr;
81531
81532 /* dont allow allocations above current base */
81533 - if (mm->free_area_cache > mm->mmap_base)
81534 + if (mm->free_area_cache > mm->mmap_base) {
81535 mm->free_area_cache = mm->mmap_base;
81536 + mm->cached_hole_size = ~0UL;
81537 + }
81538 }
81539
81540 unsigned long
81541 @@ -1974,6 +2224,28 @@ find_vma_prev(struct mm_struct *mm, unsigned long addr,
81542 return vma;
81543 }
81544
81545 +#ifdef CONFIG_PAX_SEGMEXEC
81546 +struct vm_area_struct *pax_find_mirror_vma(struct vm_area_struct *vma)
81547 +{
81548 + struct vm_area_struct *vma_m;
81549 +
81550 + BUG_ON(!vma || vma->vm_start >= vma->vm_end);
81551 + if (!(vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) || !(vma->vm_flags & VM_EXEC)) {
81552 + BUG_ON(vma->vm_mirror);
81553 + return NULL;
81554 + }
81555 + BUG_ON(vma->vm_start < SEGMEXEC_TASK_SIZE && SEGMEXEC_TASK_SIZE < vma->vm_end);
81556 + vma_m = vma->vm_mirror;
81557 + BUG_ON(!vma_m || vma_m->vm_mirror != vma);
81558 + BUG_ON(vma->vm_file != vma_m->vm_file);
81559 + BUG_ON(vma->vm_end - vma->vm_start != vma_m->vm_end - vma_m->vm_start);
81560 + BUG_ON(vma->vm_pgoff != vma_m->vm_pgoff);
81561 + BUG_ON(vma->anon_vma != vma_m->anon_vma && vma->anon_vma->root != vma_m->anon_vma->root);
81562 + BUG_ON((vma->vm_flags ^ vma_m->vm_flags) & ~(VM_WRITE | VM_MAYWRITE | VM_ACCOUNT | VM_LOCKED));
81563 + return vma_m;
81564 +}
81565 +#endif
81566 +
81567 /*
81568 * Verify that the stack growth is acceptable and
81569 * update accounting. This is shared with both the
81570 @@ -1990,6 +2262,7 @@ static int acct_stack_growth(struct vm_area_struct *vma, unsigned long size, uns
81571 return -ENOMEM;
81572
81573 /* Stack limit test */
81574 + gr_learn_resource(current, RLIMIT_STACK, size, 1);
81575 if (size > ACCESS_ONCE(rlim[RLIMIT_STACK].rlim_cur))
81576 return -ENOMEM;
81577
81578 @@ -2000,6 +2273,7 @@ static int acct_stack_growth(struct vm_area_struct *vma, unsigned long size, uns
81579 locked = mm->locked_vm + grow;
81580 limit = ACCESS_ONCE(rlim[RLIMIT_MEMLOCK].rlim_cur);
81581 limit >>= PAGE_SHIFT;
81582 + gr_learn_resource(current, RLIMIT_MEMLOCK, locked << PAGE_SHIFT, 1);
81583 if (locked > limit && !capable(CAP_IPC_LOCK))
81584 return -ENOMEM;
81585 }
81586 @@ -2029,37 +2303,48 @@ static int acct_stack_growth(struct vm_area_struct *vma, unsigned long size, uns
81587 * PA-RISC uses this for its stack; IA64 for its Register Backing Store.
81588 * vma is the last one with address > vma->vm_end. Have to extend vma.
81589 */
81590 +#ifndef CONFIG_IA64
81591 +static
81592 +#endif
81593 int expand_upwards(struct vm_area_struct *vma, unsigned long address)
81594 {
81595 int error;
81596 + bool locknext;
81597
81598 if (!(vma->vm_flags & VM_GROWSUP))
81599 return -EFAULT;
81600
81601 + /* Also guard against wrapping around to address 0. */
81602 + if (address < PAGE_ALIGN(address+1))
81603 + address = PAGE_ALIGN(address+1);
81604 + else
81605 + return -ENOMEM;
81606 +
81607 /*
81608 * We must make sure the anon_vma is allocated
81609 * so that the anon_vma locking is not a noop.
81610 */
81611 if (unlikely(anon_vma_prepare(vma)))
81612 return -ENOMEM;
81613 + locknext = vma->vm_next && (vma->vm_next->vm_flags & VM_GROWSDOWN);
81614 + if (locknext && anon_vma_prepare(vma->vm_next))
81615 + return -ENOMEM;
81616 vma_lock_anon_vma(vma);
81617 + if (locknext)
81618 + vma_lock_anon_vma(vma->vm_next);
81619
81620 /*
81621 * vma->vm_start/vm_end cannot change under us because the caller
81622 * is required to hold the mmap_sem in read mode. We need the
81623 - * anon_vma lock to serialize against concurrent expand_stacks.
81624 - * Also guard against wrapping around to address 0.
81625 + * anon_vma locks to serialize against concurrent expand_stacks
81626 + * and expand_upwards.
81627 */
81628 - if (address < PAGE_ALIGN(address+4))
81629 - address = PAGE_ALIGN(address+4);
81630 - else {
81631 - vma_unlock_anon_vma(vma);
81632 - return -ENOMEM;
81633 - }
81634 error = 0;
81635
81636 /* Somebody else might have raced and expanded it already */
81637 - if (address > vma->vm_end) {
81638 + 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)
81639 + error = -ENOMEM;
81640 + else if (address > vma->vm_end && (!locknext || vma->vm_next->vm_start >= address)) {
81641 unsigned long size, grow;
81642
81643 size = address - vma->vm_start;
81644 @@ -2094,6 +2379,8 @@ int expand_upwards(struct vm_area_struct *vma, unsigned long address)
81645 }
81646 }
81647 }
81648 + if (locknext)
81649 + vma_unlock_anon_vma(vma->vm_next);
81650 vma_unlock_anon_vma(vma);
81651 khugepaged_enter_vma_merge(vma);
81652 validate_mm(vma->vm_mm);
81653 @@ -2108,6 +2395,8 @@ int expand_downwards(struct vm_area_struct *vma,
81654 unsigned long address)
81655 {
81656 int error;
81657 + bool lockprev = false;
81658 + struct vm_area_struct *prev;
81659
81660 /*
81661 * We must make sure the anon_vma is allocated
81662 @@ -2121,6 +2410,15 @@ int expand_downwards(struct vm_area_struct *vma,
81663 if (error)
81664 return error;
81665
81666 + prev = vma->vm_prev;
81667 +#if defined(CONFIG_STACK_GROWSUP) || defined(CONFIG_IA64)
81668 + lockprev = prev && (prev->vm_flags & VM_GROWSUP);
81669 +#endif
81670 + if (lockprev && anon_vma_prepare(prev))
81671 + return -ENOMEM;
81672 + if (lockprev)
81673 + vma_lock_anon_vma(prev);
81674 +
81675 vma_lock_anon_vma(vma);
81676
81677 /*
81678 @@ -2130,9 +2428,17 @@ int expand_downwards(struct vm_area_struct *vma,
81679 */
81680
81681 /* Somebody else might have raced and expanded it already */
81682 - if (address < vma->vm_start) {
81683 + if (prev && (prev->vm_flags & (VM_READ | VM_WRITE | VM_EXEC)) && address - prev->vm_end < sysctl_heap_stack_gap)
81684 + error = -ENOMEM;
81685 + else if (address < vma->vm_start && (!lockprev || prev->vm_end <= address)) {
81686 unsigned long size, grow;
81687
81688 +#ifdef CONFIG_PAX_SEGMEXEC
81689 + struct vm_area_struct *vma_m;
81690 +
81691 + vma_m = pax_find_mirror_vma(vma);
81692 +#endif
81693 +
81694 size = vma->vm_end - address;
81695 grow = (vma->vm_start - address) >> PAGE_SHIFT;
81696
81697 @@ -2157,6 +2463,18 @@ int expand_downwards(struct vm_area_struct *vma,
81698 vma->vm_pgoff -= grow;
81699 anon_vma_interval_tree_post_update_vma(vma);
81700 vma_gap_update(vma);
81701 + track_exec_limit(vma->vm_mm, vma->vm_start, vma->vm_end, vma->vm_flags);
81702 +
81703 +#ifdef CONFIG_PAX_SEGMEXEC
81704 + if (vma_m) {
81705 + anon_vma_interval_tree_pre_update_vma(vma_m);
81706 + vma_m->vm_start -= grow << PAGE_SHIFT;
81707 + vma_m->vm_pgoff -= grow;
81708 + anon_vma_interval_tree_post_update_vma(vma_m);
81709 + vma_gap_update(vma_m);
81710 + }
81711 +#endif
81712 +
81713 spin_unlock(&vma->vm_mm->page_table_lock);
81714
81715 perf_event_mmap(vma);
81716 @@ -2263,6 +2581,13 @@ static void remove_vma_list(struct mm_struct *mm, struct vm_area_struct *vma)
81717 do {
81718 long nrpages = vma_pages(vma);
81719
81720 +#ifdef CONFIG_PAX_SEGMEXEC
81721 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_start >= SEGMEXEC_TASK_SIZE)) {
81722 + vma = remove_vma(vma);
81723 + continue;
81724 + }
81725 +#endif
81726 +
81727 if (vma->vm_flags & VM_ACCOUNT)
81728 nr_accounted += nrpages;
81729 vm_stat_account(mm, vma->vm_flags, vma->vm_file, -nrpages);
81730 @@ -2308,6 +2633,16 @@ detach_vmas_to_be_unmapped(struct mm_struct *mm, struct vm_area_struct *vma,
81731 insertion_point = (prev ? &prev->vm_next : &mm->mmap);
81732 vma->vm_prev = NULL;
81733 do {
81734 +
81735 +#ifdef CONFIG_PAX_SEGMEXEC
81736 + if (vma->vm_mirror) {
81737 + BUG_ON(!vma->vm_mirror->vm_mirror || vma->vm_mirror->vm_mirror != vma);
81738 + vma->vm_mirror->vm_mirror = NULL;
81739 + vma->vm_mirror->vm_flags &= ~VM_EXEC;
81740 + vma->vm_mirror = NULL;
81741 + }
81742 +#endif
81743 +
81744 vma_rb_erase(vma, &mm->mm_rb);
81745 mm->map_count--;
81746 tail_vma = vma;
81747 @@ -2339,14 +2674,33 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
81748 struct vm_area_struct *new;
81749 int err = -ENOMEM;
81750
81751 +#ifdef CONFIG_PAX_SEGMEXEC
81752 + struct vm_area_struct *vma_m, *new_m = NULL;
81753 + unsigned long addr_m = addr + SEGMEXEC_TASK_SIZE;
81754 +#endif
81755 +
81756 if (is_vm_hugetlb_page(vma) && (addr &
81757 ~(huge_page_mask(hstate_vma(vma)))))
81758 return -EINVAL;
81759
81760 +#ifdef CONFIG_PAX_SEGMEXEC
81761 + vma_m = pax_find_mirror_vma(vma);
81762 +#endif
81763 +
81764 new = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
81765 if (!new)
81766 goto out_err;
81767
81768 +#ifdef CONFIG_PAX_SEGMEXEC
81769 + if (vma_m) {
81770 + new_m = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
81771 + if (!new_m) {
81772 + kmem_cache_free(vm_area_cachep, new);
81773 + goto out_err;
81774 + }
81775 + }
81776 +#endif
81777 +
81778 /* most fields are the same, copy all, and then fixup */
81779 *new = *vma;
81780
81781 @@ -2359,6 +2713,22 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
81782 new->vm_pgoff += ((addr - vma->vm_start) >> PAGE_SHIFT);
81783 }
81784
81785 +#ifdef CONFIG_PAX_SEGMEXEC
81786 + if (vma_m) {
81787 + *new_m = *vma_m;
81788 + INIT_LIST_HEAD(&new_m->anon_vma_chain);
81789 + new_m->vm_mirror = new;
81790 + new->vm_mirror = new_m;
81791 +
81792 + if (new_below)
81793 + new_m->vm_end = addr_m;
81794 + else {
81795 + new_m->vm_start = addr_m;
81796 + new_m->vm_pgoff += ((addr_m - vma_m->vm_start) >> PAGE_SHIFT);
81797 + }
81798 + }
81799 +#endif
81800 +
81801 pol = mpol_dup(vma_policy(vma));
81802 if (IS_ERR(pol)) {
81803 err = PTR_ERR(pol);
81804 @@ -2381,6 +2751,36 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
81805 else
81806 err = vma_adjust(vma, vma->vm_start, addr, vma->vm_pgoff, new);
81807
81808 +#ifdef CONFIG_PAX_SEGMEXEC
81809 + if (!err && vma_m) {
81810 + if (anon_vma_clone(new_m, vma_m))
81811 + goto out_free_mpol;
81812 +
81813 + mpol_get(pol);
81814 + vma_set_policy(new_m, pol);
81815 +
81816 + if (new_m->vm_file)
81817 + get_file(new_m->vm_file);
81818 +
81819 + if (new_m->vm_ops && new_m->vm_ops->open)
81820 + new_m->vm_ops->open(new_m);
81821 +
81822 + if (new_below)
81823 + err = vma_adjust(vma_m, addr_m, vma_m->vm_end, vma_m->vm_pgoff +
81824 + ((addr_m - new_m->vm_start) >> PAGE_SHIFT), new_m);
81825 + else
81826 + err = vma_adjust(vma_m, vma_m->vm_start, addr_m, vma_m->vm_pgoff, new_m);
81827 +
81828 + if (err) {
81829 + if (new_m->vm_ops && new_m->vm_ops->close)
81830 + new_m->vm_ops->close(new_m);
81831 + if (new_m->vm_file)
81832 + fput(new_m->vm_file);
81833 + mpol_put(pol);
81834 + }
81835 + }
81836 +#endif
81837 +
81838 /* Success. */
81839 if (!err)
81840 return 0;
81841 @@ -2390,10 +2790,18 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
81842 new->vm_ops->close(new);
81843 if (new->vm_file)
81844 fput(new->vm_file);
81845 - unlink_anon_vmas(new);
81846 out_free_mpol:
81847 mpol_put(pol);
81848 out_free_vma:
81849 +
81850 +#ifdef CONFIG_PAX_SEGMEXEC
81851 + if (new_m) {
81852 + unlink_anon_vmas(new_m);
81853 + kmem_cache_free(vm_area_cachep, new_m);
81854 + }
81855 +#endif
81856 +
81857 + unlink_anon_vmas(new);
81858 kmem_cache_free(vm_area_cachep, new);
81859 out_err:
81860 return err;
81861 @@ -2406,6 +2814,15 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
81862 int split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
81863 unsigned long addr, int new_below)
81864 {
81865 +
81866 +#ifdef CONFIG_PAX_SEGMEXEC
81867 + if (mm->pax_flags & MF_PAX_SEGMEXEC) {
81868 + BUG_ON(vma->vm_end > SEGMEXEC_TASK_SIZE);
81869 + if (mm->map_count >= sysctl_max_map_count-1)
81870 + return -ENOMEM;
81871 + } else
81872 +#endif
81873 +
81874 if (mm->map_count >= sysctl_max_map_count)
81875 return -ENOMEM;
81876
81877 @@ -2417,11 +2834,30 @@ int split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
81878 * work. This now handles partial unmappings.
81879 * Jeremy Fitzhardinge <jeremy@goop.org>
81880 */
81881 +#ifdef CONFIG_PAX_SEGMEXEC
81882 int do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
81883 {
81884 + int ret = __do_munmap(mm, start, len);
81885 + if (ret || !(mm->pax_flags & MF_PAX_SEGMEXEC))
81886 + return ret;
81887 +
81888 + return __do_munmap(mm, start + SEGMEXEC_TASK_SIZE, len);
81889 +}
81890 +
81891 +int __do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
81892 +#else
81893 +int do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
81894 +#endif
81895 +{
81896 unsigned long end;
81897 struct vm_area_struct *vma, *prev, *last;
81898
81899 + /*
81900 + * mm->mmap_sem is required to protect against another thread
81901 + * changing the mappings in case we sleep.
81902 + */
81903 + verify_mm_writelocked(mm);
81904 +
81905 if ((start & ~PAGE_MASK) || start > TASK_SIZE || len > TASK_SIZE-start)
81906 return -EINVAL;
81907
81908 @@ -2496,6 +2932,8 @@ int do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
81909 /* Fix up all other VM information */
81910 remove_vma_list(mm, vma);
81911
81912 + track_exec_limit(mm, start, end, 0UL);
81913 +
81914 return 0;
81915 }
81916
81917 @@ -2504,6 +2942,13 @@ int vm_munmap(unsigned long start, size_t len)
81918 int ret;
81919 struct mm_struct *mm = current->mm;
81920
81921 +
81922 +#ifdef CONFIG_PAX_SEGMEXEC
81923 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) &&
81924 + (len > SEGMEXEC_TASK_SIZE || start > SEGMEXEC_TASK_SIZE-len))
81925 + return -EINVAL;
81926 +#endif
81927 +
81928 down_write(&mm->mmap_sem);
81929 ret = do_munmap(mm, start, len);
81930 up_write(&mm->mmap_sem);
81931 @@ -2517,16 +2962,6 @@ SYSCALL_DEFINE2(munmap, unsigned long, addr, size_t, len)
81932 return vm_munmap(addr, len);
81933 }
81934
81935 -static inline void verify_mm_writelocked(struct mm_struct *mm)
81936 -{
81937 -#ifdef CONFIG_DEBUG_VM
81938 - if (unlikely(down_read_trylock(&mm->mmap_sem))) {
81939 - WARN_ON(1);
81940 - up_read(&mm->mmap_sem);
81941 - }
81942 -#endif
81943 -}
81944 -
81945 /*
81946 * this is really a simplified "do_mmap". it only handles
81947 * anonymous maps. eventually we may be able to do some
81948 @@ -2540,6 +2975,7 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
81949 struct rb_node ** rb_link, * rb_parent;
81950 pgoff_t pgoff = addr >> PAGE_SHIFT;
81951 int error;
81952 + unsigned long charged;
81953
81954 len = PAGE_ALIGN(len);
81955 if (!len)
81956 @@ -2547,16 +2983,30 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
81957
81958 flags = VM_DATA_DEFAULT_FLAGS | VM_ACCOUNT | mm->def_flags;
81959
81960 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
81961 + if (mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
81962 + flags &= ~VM_EXEC;
81963 +
81964 +#ifdef CONFIG_PAX_MPROTECT
81965 + if (mm->pax_flags & MF_PAX_MPROTECT)
81966 + flags &= ~VM_MAYEXEC;
81967 +#endif
81968 +
81969 + }
81970 +#endif
81971 +
81972 error = get_unmapped_area(NULL, addr, len, 0, MAP_FIXED);
81973 if (error & ~PAGE_MASK)
81974 return error;
81975
81976 + charged = len >> PAGE_SHIFT;
81977 +
81978 /*
81979 * mlock MCL_FUTURE?
81980 */
81981 if (mm->def_flags & VM_LOCKED) {
81982 unsigned long locked, lock_limit;
81983 - locked = len >> PAGE_SHIFT;
81984 + locked = charged;
81985 locked += mm->locked_vm;
81986 lock_limit = rlimit(RLIMIT_MEMLOCK);
81987 lock_limit >>= PAGE_SHIFT;
81988 @@ -2573,21 +3023,20 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
81989 /*
81990 * Clear old maps. this also does some error checking for us
81991 */
81992 - munmap_back:
81993 if (find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent)) {
81994 if (do_munmap(mm, addr, len))
81995 return -ENOMEM;
81996 - goto munmap_back;
81997 + BUG_ON(find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent));
81998 }
81999
82000 /* Check against address space limits *after* clearing old maps... */
82001 - if (!may_expand_vm(mm, len >> PAGE_SHIFT))
82002 + if (!may_expand_vm(mm, charged))
82003 return -ENOMEM;
82004
82005 if (mm->map_count > sysctl_max_map_count)
82006 return -ENOMEM;
82007
82008 - if (security_vm_enough_memory_mm(mm, len >> PAGE_SHIFT))
82009 + if (security_vm_enough_memory_mm(mm, charged))
82010 return -ENOMEM;
82011
82012 /* Can we just expand an old private anonymous mapping? */
82013 @@ -2601,7 +3050,7 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
82014 */
82015 vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
82016 if (!vma) {
82017 - vm_unacct_memory(len >> PAGE_SHIFT);
82018 + vm_unacct_memory(charged);
82019 return -ENOMEM;
82020 }
82021
82022 @@ -2615,11 +3064,12 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
82023 vma_link(mm, vma, prev, rb_link, rb_parent);
82024 out:
82025 perf_event_mmap(vma);
82026 - mm->total_vm += len >> PAGE_SHIFT;
82027 + mm->total_vm += charged;
82028 if (flags & VM_LOCKED) {
82029 if (!mlock_vma_pages_range(vma, addr, addr + len))
82030 - mm->locked_vm += (len >> PAGE_SHIFT);
82031 + mm->locked_vm += charged;
82032 }
82033 + track_exec_limit(mm, addr, addr + len, flags);
82034 return addr;
82035 }
82036
82037 @@ -2677,6 +3127,7 @@ void exit_mmap(struct mm_struct *mm)
82038 while (vma) {
82039 if (vma->vm_flags & VM_ACCOUNT)
82040 nr_accounted += vma_pages(vma);
82041 + vma->vm_mirror = NULL;
82042 vma = remove_vma(vma);
82043 }
82044 vm_unacct_memory(nr_accounted);
82045 @@ -2693,6 +3144,13 @@ int insert_vm_struct(struct mm_struct *mm, struct vm_area_struct *vma)
82046 struct vm_area_struct *prev;
82047 struct rb_node **rb_link, *rb_parent;
82048
82049 +#ifdef CONFIG_PAX_SEGMEXEC
82050 + struct vm_area_struct *vma_m = NULL;
82051 +#endif
82052 +
82053 + if (security_mmap_addr(vma->vm_start))
82054 + return -EPERM;
82055 +
82056 /*
82057 * The vm_pgoff of a purely anonymous vma should be irrelevant
82058 * until its first write fault, when page's anon_vma and index
82059 @@ -2716,7 +3174,21 @@ int insert_vm_struct(struct mm_struct *mm, struct vm_area_struct *vma)
82060 security_vm_enough_memory_mm(mm, vma_pages(vma)))
82061 return -ENOMEM;
82062
82063 +#ifdef CONFIG_PAX_SEGMEXEC
82064 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_flags & VM_EXEC)) {
82065 + vma_m = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
82066 + if (!vma_m)
82067 + return -ENOMEM;
82068 + }
82069 +#endif
82070 +
82071 vma_link(mm, vma, prev, rb_link, rb_parent);
82072 +
82073 +#ifdef CONFIG_PAX_SEGMEXEC
82074 + if (vma_m)
82075 + BUG_ON(pax_mirror_vma(vma_m, vma));
82076 +#endif
82077 +
82078 return 0;
82079 }
82080
82081 @@ -2736,6 +3208,8 @@ struct vm_area_struct *copy_vma(struct vm_area_struct **vmap,
82082 struct mempolicy *pol;
82083 bool faulted_in_anon_vma = true;
82084
82085 + BUG_ON(vma->vm_mirror);
82086 +
82087 /*
82088 * If anonymous vma has not yet been faulted, update new pgoff
82089 * to match new location, to increase its chance of merging.
82090 @@ -2802,6 +3276,39 @@ struct vm_area_struct *copy_vma(struct vm_area_struct **vmap,
82091 return NULL;
82092 }
82093
82094 +#ifdef CONFIG_PAX_SEGMEXEC
82095 +long pax_mirror_vma(struct vm_area_struct *vma_m, struct vm_area_struct *vma)
82096 +{
82097 + struct vm_area_struct *prev_m;
82098 + struct rb_node **rb_link_m, *rb_parent_m;
82099 + struct mempolicy *pol_m;
82100 +
82101 + BUG_ON(!(vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) || !(vma->vm_flags & VM_EXEC));
82102 + BUG_ON(vma->vm_mirror || vma_m->vm_mirror);
82103 + BUG_ON(!mpol_equal(vma_policy(vma), vma_policy(vma_m)));
82104 + *vma_m = *vma;
82105 + INIT_LIST_HEAD(&vma_m->anon_vma_chain);
82106 + if (anon_vma_clone(vma_m, vma))
82107 + return -ENOMEM;
82108 + pol_m = vma_policy(vma_m);
82109 + mpol_get(pol_m);
82110 + vma_set_policy(vma_m, pol_m);
82111 + vma_m->vm_start += SEGMEXEC_TASK_SIZE;
82112 + vma_m->vm_end += SEGMEXEC_TASK_SIZE;
82113 + vma_m->vm_flags &= ~(VM_WRITE | VM_MAYWRITE | VM_ACCOUNT | VM_LOCKED);
82114 + vma_m->vm_page_prot = vm_get_page_prot(vma_m->vm_flags);
82115 + if (vma_m->vm_file)
82116 + get_file(vma_m->vm_file);
82117 + if (vma_m->vm_ops && vma_m->vm_ops->open)
82118 + vma_m->vm_ops->open(vma_m);
82119 + BUG_ON(find_vma_links(vma->vm_mm, vma_m->vm_start, vma_m->vm_end, &prev_m, &rb_link_m, &rb_parent_m));
82120 + vma_link(vma->vm_mm, vma_m, prev_m, rb_link_m, rb_parent_m);
82121 + vma_m->vm_mirror = vma;
82122 + vma->vm_mirror = vma_m;
82123 + return 0;
82124 +}
82125 +#endif
82126 +
82127 /*
82128 * Return true if the calling process may expand its vm space by the passed
82129 * number of pages
82130 @@ -2813,6 +3320,7 @@ int may_expand_vm(struct mm_struct *mm, unsigned long npages)
82131
82132 lim = rlimit(RLIMIT_AS) >> PAGE_SHIFT;
82133
82134 + gr_learn_resource(current, RLIMIT_AS, (cur + npages) << PAGE_SHIFT, 1);
82135 if (cur + npages > lim)
82136 return 0;
82137 return 1;
82138 @@ -2883,6 +3391,22 @@ int install_special_mapping(struct mm_struct *mm,
82139 vma->vm_start = addr;
82140 vma->vm_end = addr + len;
82141
82142 +#ifdef CONFIG_PAX_MPROTECT
82143 + if (mm->pax_flags & MF_PAX_MPROTECT) {
82144 +#ifndef CONFIG_PAX_MPROTECT_COMPAT
82145 + if ((vm_flags & (VM_WRITE | VM_EXEC)) == (VM_WRITE | VM_EXEC))
82146 + return -EPERM;
82147 + if (!(vm_flags & VM_EXEC))
82148 + vm_flags &= ~VM_MAYEXEC;
82149 +#else
82150 + if ((vm_flags & (VM_WRITE | VM_EXEC)) != VM_EXEC)
82151 + vm_flags &= ~(VM_EXEC | VM_MAYEXEC);
82152 +#endif
82153 + else
82154 + vm_flags &= ~VM_MAYWRITE;
82155 + }
82156 +#endif
82157 +
82158 vma->vm_flags = vm_flags | mm->def_flags | VM_DONTEXPAND;
82159 vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
82160
82161 diff --git a/mm/mprotect.c b/mm/mprotect.c
82162 index 94722a4..9837984 100644
82163 --- a/mm/mprotect.c
82164 +++ b/mm/mprotect.c
82165 @@ -23,10 +23,17 @@
82166 #include <linux/mmu_notifier.h>
82167 #include <linux/migrate.h>
82168 #include <linux/perf_event.h>
82169 +
82170 +#ifdef CONFIG_PAX_MPROTECT
82171 +#include <linux/elf.h>
82172 +#include <linux/binfmts.h>
82173 +#endif
82174 +
82175 #include <asm/uaccess.h>
82176 #include <asm/pgtable.h>
82177 #include <asm/cacheflush.h>
82178 #include <asm/tlbflush.h>
82179 +#include <asm/mmu_context.h>
82180
82181 #ifndef pgprot_modify
82182 static inline pgprot_t pgprot_modify(pgprot_t oldprot, pgprot_t newprot)
82183 @@ -233,6 +240,48 @@ unsigned long change_protection(struct vm_area_struct *vma, unsigned long start,
82184 return pages;
82185 }
82186
82187 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
82188 +/* called while holding the mmap semaphor for writing except stack expansion */
82189 +void track_exec_limit(struct mm_struct *mm, unsigned long start, unsigned long end, unsigned long prot)
82190 +{
82191 + unsigned long oldlimit, newlimit = 0UL;
82192 +
82193 + if (!(mm->pax_flags & MF_PAX_PAGEEXEC) || (__supported_pte_mask & _PAGE_NX))
82194 + return;
82195 +
82196 + spin_lock(&mm->page_table_lock);
82197 + oldlimit = mm->context.user_cs_limit;
82198 + if ((prot & VM_EXEC) && oldlimit < end)
82199 + /* USER_CS limit moved up */
82200 + newlimit = end;
82201 + else if (!(prot & VM_EXEC) && start < oldlimit && oldlimit <= end)
82202 + /* USER_CS limit moved down */
82203 + newlimit = start;
82204 +
82205 + if (newlimit) {
82206 + mm->context.user_cs_limit = newlimit;
82207 +
82208 +#ifdef CONFIG_SMP
82209 + wmb();
82210 + cpus_clear(mm->context.cpu_user_cs_mask);
82211 + cpu_set(smp_processor_id(), mm->context.cpu_user_cs_mask);
82212 +#endif
82213 +
82214 + set_user_cs(mm->context.user_cs_base, mm->context.user_cs_limit, smp_processor_id());
82215 + }
82216 + spin_unlock(&mm->page_table_lock);
82217 + if (newlimit == end) {
82218 + struct vm_area_struct *vma = find_vma(mm, oldlimit);
82219 +
82220 + for (; vma && vma->vm_start < end; vma = vma->vm_next)
82221 + if (is_vm_hugetlb_page(vma))
82222 + hugetlb_change_protection(vma, vma->vm_start, vma->vm_end, vma->vm_page_prot);
82223 + else
82224 + change_protection(vma, vma->vm_start, vma->vm_end, vma->vm_page_prot, vma_wants_writenotify(vma), 0);
82225 + }
82226 +}
82227 +#endif
82228 +
82229 int
82230 mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev,
82231 unsigned long start, unsigned long end, unsigned long newflags)
82232 @@ -245,11 +294,29 @@ mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev,
82233 int error;
82234 int dirty_accountable = 0;
82235
82236 +#ifdef CONFIG_PAX_SEGMEXEC
82237 + struct vm_area_struct *vma_m = NULL;
82238 + unsigned long start_m, end_m;
82239 +
82240 + start_m = start + SEGMEXEC_TASK_SIZE;
82241 + end_m = end + SEGMEXEC_TASK_SIZE;
82242 +#endif
82243 +
82244 if (newflags == oldflags) {
82245 *pprev = vma;
82246 return 0;
82247 }
82248
82249 + if (newflags & (VM_READ | VM_WRITE | VM_EXEC)) {
82250 + struct vm_area_struct *prev = vma->vm_prev, *next = vma->vm_next;
82251 +
82252 + if (next && (next->vm_flags & VM_GROWSDOWN) && sysctl_heap_stack_gap > next->vm_start - end)
82253 + return -ENOMEM;
82254 +
82255 + if (prev && (prev->vm_flags & VM_GROWSUP) && sysctl_heap_stack_gap > start - prev->vm_end)
82256 + return -ENOMEM;
82257 + }
82258 +
82259 /*
82260 * If we make a private mapping writable we increase our commit;
82261 * but (without finer accounting) cannot reduce our commit if we
82262 @@ -266,6 +333,42 @@ mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev,
82263 }
82264 }
82265
82266 +#ifdef CONFIG_PAX_SEGMEXEC
82267 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && ((oldflags ^ newflags) & VM_EXEC)) {
82268 + if (start != vma->vm_start) {
82269 + error = split_vma(mm, vma, start, 1);
82270 + if (error)
82271 + goto fail;
82272 + BUG_ON(!*pprev || (*pprev)->vm_next == vma);
82273 + *pprev = (*pprev)->vm_next;
82274 + }
82275 +
82276 + if (end != vma->vm_end) {
82277 + error = split_vma(mm, vma, end, 0);
82278 + if (error)
82279 + goto fail;
82280 + }
82281 +
82282 + if (pax_find_mirror_vma(vma)) {
82283 + error = __do_munmap(mm, start_m, end_m - start_m);
82284 + if (error)
82285 + goto fail;
82286 + } else {
82287 + vma_m = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
82288 + if (!vma_m) {
82289 + error = -ENOMEM;
82290 + goto fail;
82291 + }
82292 + vma->vm_flags = newflags;
82293 + error = pax_mirror_vma(vma_m, vma);
82294 + if (error) {
82295 + vma->vm_flags = oldflags;
82296 + goto fail;
82297 + }
82298 + }
82299 + }
82300 +#endif
82301 +
82302 /*
82303 * First try to merge with previous and/or next vma.
82304 */
82305 @@ -296,9 +399,21 @@ success:
82306 * vm_flags and vm_page_prot are protected by the mmap_sem
82307 * held in write mode.
82308 */
82309 +
82310 +#ifdef CONFIG_PAX_SEGMEXEC
82311 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (newflags & VM_EXEC) && ((vma->vm_flags ^ newflags) & VM_READ))
82312 + pax_find_mirror_vma(vma)->vm_flags ^= VM_READ;
82313 +#endif
82314 +
82315 vma->vm_flags = newflags;
82316 +
82317 +#ifdef CONFIG_PAX_MPROTECT
82318 + if (mm->binfmt && mm->binfmt->handle_mprotect)
82319 + mm->binfmt->handle_mprotect(vma, newflags);
82320 +#endif
82321 +
82322 vma->vm_page_prot = pgprot_modify(vma->vm_page_prot,
82323 - vm_get_page_prot(newflags));
82324 + vm_get_page_prot(vma->vm_flags));
82325
82326 if (vma_wants_writenotify(vma)) {
82327 vma->vm_page_prot = vm_get_page_prot(newflags & ~VM_SHARED);
82328 @@ -337,6 +452,17 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
82329 end = start + len;
82330 if (end <= start)
82331 return -ENOMEM;
82332 +
82333 +#ifdef CONFIG_PAX_SEGMEXEC
82334 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC) {
82335 + if (end > SEGMEXEC_TASK_SIZE)
82336 + return -EINVAL;
82337 + } else
82338 +#endif
82339 +
82340 + if (end > TASK_SIZE)
82341 + return -EINVAL;
82342 +
82343 if (!arch_validate_prot(prot))
82344 return -EINVAL;
82345
82346 @@ -344,7 +470,7 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
82347 /*
82348 * Does the application expect PROT_READ to imply PROT_EXEC:
82349 */
82350 - if ((prot & PROT_READ) && (current->personality & READ_IMPLIES_EXEC))
82351 + if ((prot & (PROT_READ | PROT_WRITE)) && (current->personality & READ_IMPLIES_EXEC))
82352 prot |= PROT_EXEC;
82353
82354 vm_flags = calc_vm_prot_bits(prot);
82355 @@ -376,6 +502,11 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
82356 if (start > vma->vm_start)
82357 prev = vma;
82358
82359 +#ifdef CONFIG_PAX_MPROTECT
82360 + if (current->mm->binfmt && current->mm->binfmt->handle_mprotect)
82361 + current->mm->binfmt->handle_mprotect(vma, vm_flags);
82362 +#endif
82363 +
82364 for (nstart = start ; ; ) {
82365 unsigned long newflags;
82366
82367 @@ -386,6 +517,14 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
82368
82369 /* newflags >> 4 shift VM_MAY% in place of VM_% */
82370 if ((newflags & ~(newflags >> 4)) & (VM_READ | VM_WRITE | VM_EXEC)) {
82371 + if (prot & (PROT_WRITE | PROT_EXEC))
82372 + gr_log_rwxmprotect(vma->vm_file);
82373 +
82374 + error = -EACCES;
82375 + goto out;
82376 + }
82377 +
82378 + if (!gr_acl_handle_mprotect(vma->vm_file, prot)) {
82379 error = -EACCES;
82380 goto out;
82381 }
82382 @@ -400,6 +539,9 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
82383 error = mprotect_fixup(vma, &prev, nstart, tmp, newflags);
82384 if (error)
82385 goto out;
82386 +
82387 + track_exec_limit(current->mm, nstart, tmp, vm_flags);
82388 +
82389 nstart = tmp;
82390
82391 if (nstart < prev->vm_end)
82392 diff --git a/mm/mremap.c b/mm/mremap.c
82393 index e1031e1..1f2a0a1 100644
82394 --- a/mm/mremap.c
82395 +++ b/mm/mremap.c
82396 @@ -125,6 +125,12 @@ static void move_ptes(struct vm_area_struct *vma, pmd_t *old_pmd,
82397 continue;
82398 pte = ptep_get_and_clear(mm, old_addr, old_pte);
82399 pte = move_pte(pte, new_vma->vm_page_prot, old_addr, new_addr);
82400 +
82401 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
82402 + if (!(__supported_pte_mask & _PAGE_NX) && (new_vma->vm_flags & (VM_PAGEEXEC | VM_EXEC)) == VM_PAGEEXEC)
82403 + pte = pte_exprotect(pte);
82404 +#endif
82405 +
82406 set_pte_at(mm, new_addr, new_pte, pte);
82407 }
82408
82409 @@ -319,6 +325,11 @@ static struct vm_area_struct *vma_to_resize(unsigned long addr,
82410 if (is_vm_hugetlb_page(vma))
82411 goto Einval;
82412
82413 +#ifdef CONFIG_PAX_SEGMEXEC
82414 + if (pax_find_mirror_vma(vma))
82415 + goto Einval;
82416 +#endif
82417 +
82418 /* We can't remap across vm area boundaries */
82419 if (old_len > vma->vm_end - addr)
82420 goto Efault;
82421 @@ -375,20 +386,25 @@ static unsigned long mremap_to(unsigned long addr,
82422 unsigned long ret = -EINVAL;
82423 unsigned long charged = 0;
82424 unsigned long map_flags;
82425 + unsigned long pax_task_size = TASK_SIZE;
82426
82427 if (new_addr & ~PAGE_MASK)
82428 goto out;
82429
82430 - if (new_len > TASK_SIZE || new_addr > TASK_SIZE - new_len)
82431 +#ifdef CONFIG_PAX_SEGMEXEC
82432 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
82433 + pax_task_size = SEGMEXEC_TASK_SIZE;
82434 +#endif
82435 +
82436 + pax_task_size -= PAGE_SIZE;
82437 +
82438 + if (new_len > TASK_SIZE || new_addr > pax_task_size - new_len)
82439 goto out;
82440
82441 /* Check if the location we're moving into overlaps the
82442 * old location at all, and fail if it does.
82443 */
82444 - if ((new_addr <= addr) && (new_addr+new_len) > addr)
82445 - goto out;
82446 -
82447 - if ((addr <= new_addr) && (addr+old_len) > new_addr)
82448 + if (addr + old_len > new_addr && new_addr + new_len > addr)
82449 goto out;
82450
82451 ret = do_munmap(mm, new_addr, new_len);
82452 @@ -456,6 +472,7 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
82453 struct vm_area_struct *vma;
82454 unsigned long ret = -EINVAL;
82455 unsigned long charged = 0;
82456 + unsigned long pax_task_size = TASK_SIZE;
82457
82458 down_write(&current->mm->mmap_sem);
82459
82460 @@ -476,6 +493,17 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
82461 if (!new_len)
82462 goto out;
82463
82464 +#ifdef CONFIG_PAX_SEGMEXEC
82465 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
82466 + pax_task_size = SEGMEXEC_TASK_SIZE;
82467 +#endif
82468 +
82469 + pax_task_size -= PAGE_SIZE;
82470 +
82471 + if (new_len > pax_task_size || addr > pax_task_size-new_len ||
82472 + old_len > pax_task_size || addr > pax_task_size-old_len)
82473 + goto out;
82474 +
82475 if (flags & MREMAP_FIXED) {
82476 if (flags & MREMAP_MAYMOVE)
82477 ret = mremap_to(addr, old_len, new_addr, new_len);
82478 @@ -524,6 +552,7 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
82479 addr + new_len);
82480 }
82481 ret = addr;
82482 + track_exec_limit(vma->vm_mm, vma->vm_start, addr + new_len, vma->vm_flags);
82483 goto out;
82484 }
82485 }
82486 @@ -547,7 +576,12 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
82487 goto out;
82488 }
82489
82490 + map_flags = vma->vm_flags;
82491 ret = move_vma(vma, addr, old_len, new_len, new_addr);
82492 + if (!(ret & ~PAGE_MASK)) {
82493 + track_exec_limit(current->mm, addr, addr + old_len, 0UL);
82494 + track_exec_limit(current->mm, new_addr, new_addr + new_len, map_flags);
82495 + }
82496 }
82497 out:
82498 if (ret & ~PAGE_MASK)
82499 diff --git a/mm/nommu.c b/mm/nommu.c
82500 index 79c3cac..4d357e0 100644
82501 --- a/mm/nommu.c
82502 +++ b/mm/nommu.c
82503 @@ -62,7 +62,6 @@ int sysctl_overcommit_memory = OVERCOMMIT_GUESS; /* heuristic overcommit */
82504 int sysctl_overcommit_ratio = 50; /* default is 50% */
82505 int sysctl_max_map_count = DEFAULT_MAX_MAP_COUNT;
82506 int sysctl_nr_trim_pages = CONFIG_NOMMU_INITIAL_TRIM_EXCESS;
82507 -int heap_stack_gap = 0;
82508
82509 atomic_long_t mmap_pages_allocated;
82510
82511 @@ -839,15 +838,6 @@ struct vm_area_struct *find_vma(struct mm_struct *mm, unsigned long addr)
82512 EXPORT_SYMBOL(find_vma);
82513
82514 /*
82515 - * find a VMA
82516 - * - we don't extend stack VMAs under NOMMU conditions
82517 - */
82518 -struct vm_area_struct *find_extend_vma(struct mm_struct *mm, unsigned long addr)
82519 -{
82520 - return find_vma(mm, addr);
82521 -}
82522 -
82523 -/*
82524 * expand a stack to a given address
82525 * - not supported under NOMMU conditions
82526 */
82527 @@ -1555,6 +1545,7 @@ int split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
82528
82529 /* most fields are the same, copy all, and then fixup */
82530 *new = *vma;
82531 + INIT_LIST_HEAD(&new->anon_vma_chain);
82532 *region = *vma->vm_region;
82533 new->vm_region = region;
82534
82535 diff --git a/mm/page-writeback.c b/mm/page-writeback.c
82536 index 0713bfb..b95bb87 100644
82537 --- a/mm/page-writeback.c
82538 +++ b/mm/page-writeback.c
82539 @@ -655,7 +655,7 @@ unsigned long bdi_dirty_limit(struct backing_dev_info *bdi, unsigned long dirty)
82540 * card's bdi_dirty may rush to many times higher than bdi_setpoint.
82541 * - the bdi dirty thresh drops quickly due to change of JBOD workload
82542 */
82543 -static unsigned long bdi_position_ratio(struct backing_dev_info *bdi,
82544 +static unsigned long __intentional_overflow(-1) bdi_position_ratio(struct backing_dev_info *bdi,
82545 unsigned long thresh,
82546 unsigned long bg_thresh,
82547 unsigned long dirty,
82548 @@ -1630,7 +1630,7 @@ ratelimit_handler(struct notifier_block *self, unsigned long action,
82549 }
82550 }
82551
82552 -static struct notifier_block __cpuinitdata ratelimit_nb = {
82553 +static struct notifier_block ratelimit_nb = {
82554 .notifier_call = ratelimit_handler,
82555 .next = NULL,
82556 };
82557 diff --git a/mm/page_alloc.c b/mm/page_alloc.c
82558 index 6a83cd3..3ab04ef 100644
82559 --- a/mm/page_alloc.c
82560 +++ b/mm/page_alloc.c
82561 @@ -58,6 +58,7 @@
82562 #include <linux/prefetch.h>
82563 #include <linux/migrate.h>
82564 #include <linux/page-debug-flags.h>
82565 +#include <linux/random.h>
82566
82567 #include <asm/tlbflush.h>
82568 #include <asm/div64.h>
82569 @@ -338,7 +339,7 @@ out:
82570 * This usage means that zero-order pages may not be compound.
82571 */
82572
82573 -static void free_compound_page(struct page *page)
82574 +void free_compound_page(struct page *page)
82575 {
82576 __free_pages_ok(page, compound_order(page));
82577 }
82578 @@ -693,6 +694,10 @@ static bool free_pages_prepare(struct page *page, unsigned int order)
82579 int i;
82580 int bad = 0;
82581
82582 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
82583 + unsigned long index = 1UL << order;
82584 +#endif
82585 +
82586 trace_mm_page_free(page, order);
82587 kmemcheck_free_shadow(page, order);
82588
82589 @@ -708,6 +713,12 @@ static bool free_pages_prepare(struct page *page, unsigned int order)
82590 debug_check_no_obj_freed(page_address(page),
82591 PAGE_SIZE << order);
82592 }
82593 +
82594 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
82595 + for (; index; --index)
82596 + sanitize_highpage(page + index - 1);
82597 +#endif
82598 +
82599 arch_free_page(page, order);
82600 kernel_map_pages(page, 1 << order, 0);
82601
82602 @@ -730,6 +741,19 @@ static void __free_pages_ok(struct page *page, unsigned int order)
82603 local_irq_restore(flags);
82604 }
82605
82606 +#ifdef CONFIG_PAX_LATENT_ENTROPY
82607 +bool __meminitdata extra_latent_entropy;
82608 +
82609 +static int __init setup_pax_extra_latent_entropy(char *str)
82610 +{
82611 + extra_latent_entropy = true;
82612 + return 0;
82613 +}
82614 +early_param("pax_extra_latent_entropy", setup_pax_extra_latent_entropy);
82615 +
82616 +volatile u64 latent_entropy;
82617 +#endif
82618 +
82619 /*
82620 * Read access to zone->managed_pages is safe because it's unsigned long,
82621 * but we still need to serialize writers. Currently all callers of
82622 @@ -752,6 +776,19 @@ void __meminit __free_pages_bootmem(struct page *page, unsigned int order)
82623 set_page_count(p, 0);
82624 }
82625
82626 +#ifdef CONFIG_PAX_LATENT_ENTROPY
82627 + if (extra_latent_entropy && !PageHighMem(page) && page_to_pfn(page) < 0x100000) {
82628 + u64 hash = 0;
82629 + size_t index, end = PAGE_SIZE * nr_pages / sizeof hash;
82630 + const u64 *data = lowmem_page_address(page);
82631 +
82632 + for (index = 0; index < end; index++)
82633 + hash ^= hash + data[index];
82634 + latent_entropy ^= hash;
82635 + add_device_randomness((const void *)&latent_entropy, sizeof(latent_entropy));
82636 + }
82637 +#endif
82638 +
82639 page_zone(page)->managed_pages += 1 << order;
82640 set_page_refcounted(page);
82641 __free_pages(page, order);
82642 @@ -861,8 +898,10 @@ static int prep_new_page(struct page *page, int order, gfp_t gfp_flags)
82643 arch_alloc_page(page, order);
82644 kernel_map_pages(page, 1 << order, 1);
82645
82646 +#ifndef CONFIG_PAX_MEMORY_SANITIZE
82647 if (gfp_flags & __GFP_ZERO)
82648 prep_zero_page(page, order, gfp_flags);
82649 +#endif
82650
82651 if (order && (gfp_flags & __GFP_COMP))
82652 prep_compound_page(page, order);
82653 @@ -3752,7 +3791,13 @@ static int pageblock_is_reserved(unsigned long start_pfn, unsigned long end_pfn)
82654 unsigned long pfn;
82655
82656 for (pfn = start_pfn; pfn < end_pfn; pfn++) {
82657 +#ifdef CONFIG_X86_32
82658 + /* boot failures in VMware 8 on 32bit vanilla since
82659 + this change */
82660 + if (!pfn_valid(pfn) || PageReserved(pfn_to_page(pfn)))
82661 +#else
82662 if (!pfn_valid_within(pfn) || PageReserved(pfn_to_page(pfn)))
82663 +#endif
82664 return 1;
82665 }
82666 return 0;
82667 diff --git a/mm/percpu.c b/mm/percpu.c
82668 index 8c8e08f..73a5cda 100644
82669 --- a/mm/percpu.c
82670 +++ b/mm/percpu.c
82671 @@ -122,7 +122,7 @@ static unsigned int pcpu_low_unit_cpu __read_mostly;
82672 static unsigned int pcpu_high_unit_cpu __read_mostly;
82673
82674 /* the address of the first chunk which starts with the kernel static area */
82675 -void *pcpu_base_addr __read_mostly;
82676 +void *pcpu_base_addr __read_only;
82677 EXPORT_SYMBOL_GPL(pcpu_base_addr);
82678
82679 static const int *pcpu_unit_map __read_mostly; /* cpu -> unit */
82680 diff --git a/mm/process_vm_access.c b/mm/process_vm_access.c
82681 index fd26d04..0cea1b0 100644
82682 --- a/mm/process_vm_access.c
82683 +++ b/mm/process_vm_access.c
82684 @@ -13,6 +13,7 @@
82685 #include <linux/uio.h>
82686 #include <linux/sched.h>
82687 #include <linux/highmem.h>
82688 +#include <linux/security.h>
82689 #include <linux/ptrace.h>
82690 #include <linux/slab.h>
82691 #include <linux/syscalls.h>
82692 @@ -258,19 +259,19 @@ static ssize_t process_vm_rw_core(pid_t pid, const struct iovec *lvec,
82693 size_t iov_l_curr_offset = 0;
82694 ssize_t iov_len;
82695
82696 + return -ENOSYS; // PaX: until properly audited
82697 +
82698 /*
82699 * Work out how many pages of struct pages we're going to need
82700 * when eventually calling get_user_pages
82701 */
82702 for (i = 0; i < riovcnt; i++) {
82703 iov_len = rvec[i].iov_len;
82704 - if (iov_len > 0) {
82705 - nr_pages_iov = ((unsigned long)rvec[i].iov_base
82706 - + iov_len)
82707 - / PAGE_SIZE - (unsigned long)rvec[i].iov_base
82708 - / PAGE_SIZE + 1;
82709 - nr_pages = max(nr_pages, nr_pages_iov);
82710 - }
82711 + if (iov_len <= 0)
82712 + continue;
82713 + nr_pages_iov = ((unsigned long)rvec[i].iov_base + iov_len) / PAGE_SIZE -
82714 + (unsigned long)rvec[i].iov_base / PAGE_SIZE + 1;
82715 + nr_pages = max(nr_pages, nr_pages_iov);
82716 }
82717
82718 if (nr_pages == 0)
82719 @@ -298,6 +299,11 @@ static ssize_t process_vm_rw_core(pid_t pid, const struct iovec *lvec,
82720 goto free_proc_pages;
82721 }
82722
82723 + if (gr_handle_ptrace(task, vm_write ? PTRACE_POKETEXT : PTRACE_ATTACH)) {
82724 + rc = -EPERM;
82725 + goto put_task_struct;
82726 + }
82727 +
82728 mm = mm_access(task, PTRACE_MODE_ATTACH);
82729 if (!mm || IS_ERR(mm)) {
82730 rc = IS_ERR(mm) ? PTR_ERR(mm) : -ESRCH;
82731 diff --git a/mm/rmap.c b/mm/rmap.c
82732 index 2c78f8c..9e9c624 100644
82733 --- a/mm/rmap.c
82734 +++ b/mm/rmap.c
82735 @@ -163,6 +163,10 @@ int anon_vma_prepare(struct vm_area_struct *vma)
82736 struct anon_vma *anon_vma = vma->anon_vma;
82737 struct anon_vma_chain *avc;
82738
82739 +#ifdef CONFIG_PAX_SEGMEXEC
82740 + struct anon_vma_chain *avc_m = NULL;
82741 +#endif
82742 +
82743 might_sleep();
82744 if (unlikely(!anon_vma)) {
82745 struct mm_struct *mm = vma->vm_mm;
82746 @@ -172,6 +176,12 @@ int anon_vma_prepare(struct vm_area_struct *vma)
82747 if (!avc)
82748 goto out_enomem;
82749
82750 +#ifdef CONFIG_PAX_SEGMEXEC
82751 + avc_m = anon_vma_chain_alloc(GFP_KERNEL);
82752 + if (!avc_m)
82753 + goto out_enomem_free_avc;
82754 +#endif
82755 +
82756 anon_vma = find_mergeable_anon_vma(vma);
82757 allocated = NULL;
82758 if (!anon_vma) {
82759 @@ -185,6 +195,18 @@ int anon_vma_prepare(struct vm_area_struct *vma)
82760 /* page_table_lock to protect against threads */
82761 spin_lock(&mm->page_table_lock);
82762 if (likely(!vma->anon_vma)) {
82763 +
82764 +#ifdef CONFIG_PAX_SEGMEXEC
82765 + struct vm_area_struct *vma_m = pax_find_mirror_vma(vma);
82766 +
82767 + if (vma_m) {
82768 + BUG_ON(vma_m->anon_vma);
82769 + vma_m->anon_vma = anon_vma;
82770 + anon_vma_chain_link(vma_m, avc_m, anon_vma);
82771 + avc_m = NULL;
82772 + }
82773 +#endif
82774 +
82775 vma->anon_vma = anon_vma;
82776 anon_vma_chain_link(vma, avc, anon_vma);
82777 allocated = NULL;
82778 @@ -195,12 +217,24 @@ int anon_vma_prepare(struct vm_area_struct *vma)
82779
82780 if (unlikely(allocated))
82781 put_anon_vma(allocated);
82782 +
82783 +#ifdef CONFIG_PAX_SEGMEXEC
82784 + if (unlikely(avc_m))
82785 + anon_vma_chain_free(avc_m);
82786 +#endif
82787 +
82788 if (unlikely(avc))
82789 anon_vma_chain_free(avc);
82790 }
82791 return 0;
82792
82793 out_enomem_free_avc:
82794 +
82795 +#ifdef CONFIG_PAX_SEGMEXEC
82796 + if (avc_m)
82797 + anon_vma_chain_free(avc_m);
82798 +#endif
82799 +
82800 anon_vma_chain_free(avc);
82801 out_enomem:
82802 return -ENOMEM;
82803 @@ -236,7 +270,7 @@ static inline void unlock_anon_vma_root(struct anon_vma *root)
82804 * Attach the anon_vmas from src to dst.
82805 * Returns 0 on success, -ENOMEM on failure.
82806 */
82807 -int anon_vma_clone(struct vm_area_struct *dst, struct vm_area_struct *src)
82808 +int anon_vma_clone(struct vm_area_struct *dst, const struct vm_area_struct *src)
82809 {
82810 struct anon_vma_chain *avc, *pavc;
82811 struct anon_vma *root = NULL;
82812 @@ -269,7 +303,7 @@ int anon_vma_clone(struct vm_area_struct *dst, struct vm_area_struct *src)
82813 * the corresponding VMA in the parent process is attached to.
82814 * Returns 0 on success, non-zero on failure.
82815 */
82816 -int anon_vma_fork(struct vm_area_struct *vma, struct vm_area_struct *pvma)
82817 +int anon_vma_fork(struct vm_area_struct *vma, const struct vm_area_struct *pvma)
82818 {
82819 struct anon_vma_chain *avc;
82820 struct anon_vma *anon_vma;
82821 diff --git a/mm/shmem.c b/mm/shmem.c
82822 index efd0b3a..994b702 100644
82823 --- a/mm/shmem.c
82824 +++ b/mm/shmem.c
82825 @@ -31,7 +31,7 @@
82826 #include <linux/export.h>
82827 #include <linux/swap.h>
82828
82829 -static struct vfsmount *shm_mnt;
82830 +struct vfsmount *shm_mnt;
82831
82832 #ifdef CONFIG_SHMEM
82833 /*
82834 @@ -75,7 +75,7 @@ static struct vfsmount *shm_mnt;
82835 #define BOGO_DIRENT_SIZE 20
82836
82837 /* Symlink up to this size is kmalloc'ed instead of using a swappable page */
82838 -#define SHORT_SYMLINK_LEN 128
82839 +#define SHORT_SYMLINK_LEN 64
82840
82841 /*
82842 * shmem_fallocate and shmem_writepage communicate via inode->i_private
82843 @@ -2202,6 +2202,11 @@ static const struct xattr_handler *shmem_xattr_handlers[] = {
82844 static int shmem_xattr_validate(const char *name)
82845 {
82846 struct { const char *prefix; size_t len; } arr[] = {
82847 +
82848 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
82849 + { XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN},
82850 +#endif
82851 +
82852 { XATTR_SECURITY_PREFIX, XATTR_SECURITY_PREFIX_LEN },
82853 { XATTR_TRUSTED_PREFIX, XATTR_TRUSTED_PREFIX_LEN }
82854 };
82855 @@ -2257,6 +2262,15 @@ static int shmem_setxattr(struct dentry *dentry, const char *name,
82856 if (err)
82857 return err;
82858
82859 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
82860 + if (!strncmp(name, XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN)) {
82861 + if (strcmp(name, XATTR_NAME_PAX_FLAGS))
82862 + return -EOPNOTSUPP;
82863 + if (size > 8)
82864 + return -EINVAL;
82865 + }
82866 +#endif
82867 +
82868 return simple_xattr_set(&info->xattrs, name, value, size, flags);
82869 }
82870
82871 @@ -2562,8 +2576,7 @@ int shmem_fill_super(struct super_block *sb, void *data, int silent)
82872 int err = -ENOMEM;
82873
82874 /* Round up to L1_CACHE_BYTES to resist false sharing */
82875 - sbinfo = kzalloc(max((int)sizeof(struct shmem_sb_info),
82876 - L1_CACHE_BYTES), GFP_KERNEL);
82877 + sbinfo = kzalloc(max(sizeof(struct shmem_sb_info), L1_CACHE_BYTES), GFP_KERNEL);
82878 if (!sbinfo)
82879 return -ENOMEM;
82880
82881 diff --git a/mm/slab.c b/mm/slab.c
82882 index e7667a3..b62c169 100644
82883 --- a/mm/slab.c
82884 +++ b/mm/slab.c
82885 @@ -306,7 +306,7 @@ struct kmem_list3 {
82886 * Need this for bootstrapping a per node allocator.
82887 */
82888 #define NUM_INIT_LISTS (3 * MAX_NUMNODES)
82889 -static struct kmem_list3 __initdata initkmem_list3[NUM_INIT_LISTS];
82890 +static struct kmem_list3 initkmem_list3[NUM_INIT_LISTS];
82891 #define CACHE_CACHE 0
82892 #define SIZE_AC MAX_NUMNODES
82893 #define SIZE_L3 (2 * MAX_NUMNODES)
82894 @@ -407,10 +407,10 @@ static void kmem_list3_init(struct kmem_list3 *parent)
82895 if ((x)->max_freeable < i) \
82896 (x)->max_freeable = i; \
82897 } while (0)
82898 -#define STATS_INC_ALLOCHIT(x) atomic_inc(&(x)->allochit)
82899 -#define STATS_INC_ALLOCMISS(x) atomic_inc(&(x)->allocmiss)
82900 -#define STATS_INC_FREEHIT(x) atomic_inc(&(x)->freehit)
82901 -#define STATS_INC_FREEMISS(x) atomic_inc(&(x)->freemiss)
82902 +#define STATS_INC_ALLOCHIT(x) atomic_inc_unchecked(&(x)->allochit)
82903 +#define STATS_INC_ALLOCMISS(x) atomic_inc_unchecked(&(x)->allocmiss)
82904 +#define STATS_INC_FREEHIT(x) atomic_inc_unchecked(&(x)->freehit)
82905 +#define STATS_INC_FREEMISS(x) atomic_inc_unchecked(&(x)->freemiss)
82906 #else
82907 #define STATS_INC_ACTIVE(x) do { } while (0)
82908 #define STATS_DEC_ACTIVE(x) do { } while (0)
82909 @@ -518,7 +518,7 @@ static inline void *index_to_obj(struct kmem_cache *cache, struct slab *slab,
82910 * reciprocal_divide(offset, cache->reciprocal_buffer_size)
82911 */
82912 static inline unsigned int obj_to_index(const struct kmem_cache *cache,
82913 - const struct slab *slab, void *obj)
82914 + const struct slab *slab, const void *obj)
82915 {
82916 u32 offset = (obj - slab->s_mem);
82917 return reciprocal_divide(offset, cache->reciprocal_buffer_size);
82918 @@ -539,12 +539,13 @@ EXPORT_SYMBOL(malloc_sizes);
82919 struct cache_names {
82920 char *name;
82921 char *name_dma;
82922 + char *name_usercopy;
82923 };
82924
82925 static struct cache_names __initdata cache_names[] = {
82926 -#define CACHE(x) { .name = "size-" #x, .name_dma = "size-" #x "(DMA)" },
82927 +#define CACHE(x) { .name = "size-" #x, .name_dma = "size-" #x "(DMA)", .name_usercopy = "size-" #x "(USERCOPY)" },
82928 #include <linux/kmalloc_sizes.h>
82929 - {NULL,}
82930 + {NULL}
82931 #undef CACHE
82932 };
82933
82934 @@ -729,6 +730,12 @@ static inline struct kmem_cache *__find_general_cachep(size_t size,
82935 if (unlikely(gfpflags & GFP_DMA))
82936 return csizep->cs_dmacachep;
82937 #endif
82938 +
82939 +#ifdef CONFIG_PAX_USERCOPY_SLABS
82940 + if (unlikely(gfpflags & GFP_USERCOPY))
82941 + return csizep->cs_usercopycachep;
82942 +#endif
82943 +
82944 return csizep->cs_cachep;
82945 }
82946
82947 @@ -1482,7 +1489,7 @@ static int __cpuinit cpuup_callback(struct notifier_block *nfb,
82948 return notifier_from_errno(err);
82949 }
82950
82951 -static struct notifier_block __cpuinitdata cpucache_notifier = {
82952 +static struct notifier_block cpucache_notifier = {
82953 &cpuup_callback, NULL, 0
82954 };
82955
82956 @@ -1667,12 +1674,12 @@ void __init kmem_cache_init(void)
82957 */
82958
82959 sizes[INDEX_AC].cs_cachep = create_kmalloc_cache(names[INDEX_AC].name,
82960 - sizes[INDEX_AC].cs_size, ARCH_KMALLOC_FLAGS);
82961 + sizes[INDEX_AC].cs_size, ARCH_KMALLOC_FLAGS|SLAB_USERCOPY);
82962
82963 if (INDEX_AC != INDEX_L3)
82964 sizes[INDEX_L3].cs_cachep =
82965 create_kmalloc_cache(names[INDEX_L3].name,
82966 - sizes[INDEX_L3].cs_size, ARCH_KMALLOC_FLAGS);
82967 + sizes[INDEX_L3].cs_size, ARCH_KMALLOC_FLAGS|SLAB_USERCOPY);
82968
82969 slab_early_init = 0;
82970
82971 @@ -1686,13 +1693,20 @@ void __init kmem_cache_init(void)
82972 */
82973 if (!sizes->cs_cachep)
82974 sizes->cs_cachep = create_kmalloc_cache(names->name,
82975 - sizes->cs_size, ARCH_KMALLOC_FLAGS);
82976 + sizes->cs_size, ARCH_KMALLOC_FLAGS|SLAB_USERCOPY);
82977
82978 #ifdef CONFIG_ZONE_DMA
82979 sizes->cs_dmacachep = create_kmalloc_cache(
82980 names->name_dma, sizes->cs_size,
82981 SLAB_CACHE_DMA|ARCH_KMALLOC_FLAGS);
82982 #endif
82983 +
82984 +#ifdef CONFIG_PAX_USERCOPY_SLABS
82985 + sizes->cs_usercopycachep = create_kmalloc_cache(
82986 + names->name_usercopy, sizes->cs_size,
82987 + ARCH_KMALLOC_FLAGS|SLAB_USERCOPY);
82988 +#endif
82989 +
82990 sizes++;
82991 names++;
82992 }
82993 @@ -4365,10 +4379,10 @@ void slabinfo_show_stats(struct seq_file *m, struct kmem_cache *cachep)
82994 }
82995 /* cpu stats */
82996 {
82997 - unsigned long allochit = atomic_read(&cachep->allochit);
82998 - unsigned long allocmiss = atomic_read(&cachep->allocmiss);
82999 - unsigned long freehit = atomic_read(&cachep->freehit);
83000 - unsigned long freemiss = atomic_read(&cachep->freemiss);
83001 + unsigned long allochit = atomic_read_unchecked(&cachep->allochit);
83002 + unsigned long allocmiss = atomic_read_unchecked(&cachep->allocmiss);
83003 + unsigned long freehit = atomic_read_unchecked(&cachep->freehit);
83004 + unsigned long freemiss = atomic_read_unchecked(&cachep->freemiss);
83005
83006 seq_printf(m, " : cpustat %6lu %6lu %6lu %6lu",
83007 allochit, allocmiss, freehit, freemiss);
83008 @@ -4600,13 +4614,71 @@ static const struct file_operations proc_slabstats_operations = {
83009 static int __init slab_proc_init(void)
83010 {
83011 #ifdef CONFIG_DEBUG_SLAB_LEAK
83012 - proc_create("slab_allocators", 0, NULL, &proc_slabstats_operations);
83013 + proc_create("slab_allocators", S_IRUSR, NULL, &proc_slabstats_operations);
83014 #endif
83015 return 0;
83016 }
83017 module_init(slab_proc_init);
83018 #endif
83019
83020 +bool is_usercopy_object(const void *ptr)
83021 +{
83022 + struct page *page;
83023 + struct kmem_cache *cachep;
83024 +
83025 + if (ZERO_OR_NULL_PTR(ptr))
83026 + return false;
83027 +
83028 + if (!slab_is_available())
83029 + return false;
83030 +
83031 + if (!virt_addr_valid(ptr))
83032 + return false;
83033 +
83034 + page = virt_to_head_page(ptr);
83035 +
83036 + if (!PageSlab(page))
83037 + return false;
83038 +
83039 + cachep = page->slab_cache;
83040 + return cachep->flags & SLAB_USERCOPY;
83041 +}
83042 +
83043 +#ifdef CONFIG_PAX_USERCOPY
83044 +const char *check_heap_object(const void *ptr, unsigned long n)
83045 +{
83046 + struct page *page;
83047 + struct kmem_cache *cachep;
83048 + struct slab *slabp;
83049 + unsigned int objnr;
83050 + unsigned long offset;
83051 +
83052 + if (ZERO_OR_NULL_PTR(ptr))
83053 + return "<null>";
83054 +
83055 + if (!virt_addr_valid(ptr))
83056 + return NULL;
83057 +
83058 + page = virt_to_head_page(ptr);
83059 +
83060 + if (!PageSlab(page))
83061 + return NULL;
83062 +
83063 + cachep = page->slab_cache;
83064 + if (!(cachep->flags & SLAB_USERCOPY))
83065 + return cachep->name;
83066 +
83067 + slabp = page->slab_page;
83068 + objnr = obj_to_index(cachep, slabp, ptr);
83069 + BUG_ON(objnr >= cachep->num);
83070 + offset = ptr - index_to_obj(cachep, slabp, objnr) - obj_offset(cachep);
83071 + if (offset <= cachep->object_size && n <= cachep->object_size - offset)
83072 + return NULL;
83073 +
83074 + return cachep->name;
83075 +}
83076 +#endif
83077 +
83078 /**
83079 * ksize - get the actual amount of memory allocated for a given object
83080 * @objp: Pointer to the object
83081 diff --git a/mm/slab.h b/mm/slab.h
83082 index 34a98d6..73633d1 100644
83083 --- a/mm/slab.h
83084 +++ b/mm/slab.h
83085 @@ -58,7 +58,7 @@ __kmem_cache_alias(struct mem_cgroup *memcg, const char *name, size_t size,
83086
83087 /* Legal flag mask for kmem_cache_create(), for various configurations */
83088 #define SLAB_CORE_FLAGS (SLAB_HWCACHE_ALIGN | SLAB_CACHE_DMA | SLAB_PANIC | \
83089 - SLAB_DESTROY_BY_RCU | SLAB_DEBUG_OBJECTS )
83090 + SLAB_DESTROY_BY_RCU | SLAB_DEBUG_OBJECTS | SLAB_USERCOPY)
83091
83092 #if defined(CONFIG_DEBUG_SLAB)
83093 #define SLAB_DEBUG_FLAGS (SLAB_RED_ZONE | SLAB_POISON | SLAB_STORE_USER)
83094 @@ -220,6 +220,9 @@ static inline struct kmem_cache *cache_from_obj(struct kmem_cache *s, void *x)
83095 return s;
83096
83097 page = virt_to_head_page(x);
83098 +
83099 + BUG_ON(!PageSlab(page));
83100 +
83101 cachep = page->slab_cache;
83102 if (slab_equal_or_root(cachep, s))
83103 return cachep;
83104 diff --git a/mm/slab_common.c b/mm/slab_common.c
83105 index 3f3cd97..93b0236 100644
83106 --- a/mm/slab_common.c
83107 +++ b/mm/slab_common.c
83108 @@ -22,7 +22,7 @@
83109
83110 #include "slab.h"
83111
83112 -enum slab_state slab_state;
83113 +enum slab_state slab_state __read_only;
83114 LIST_HEAD(slab_caches);
83115 DEFINE_MUTEX(slab_mutex);
83116 struct kmem_cache *kmem_cache;
83117 @@ -209,7 +209,7 @@ kmem_cache_create_memcg(struct mem_cgroup *memcg, const char *name, size_t size,
83118
83119 err = __kmem_cache_create(s, flags);
83120 if (!err) {
83121 - s->refcount = 1;
83122 + atomic_set(&s->refcount, 1);
83123 list_add(&s->list, &slab_caches);
83124 memcg_cache_list_add(memcg, s);
83125 } else {
83126 @@ -255,8 +255,7 @@ void kmem_cache_destroy(struct kmem_cache *s)
83127
83128 get_online_cpus();
83129 mutex_lock(&slab_mutex);
83130 - s->refcount--;
83131 - if (!s->refcount) {
83132 + if (atomic_dec_and_test(&s->refcount)) {
83133 list_del(&s->list);
83134
83135 if (!__kmem_cache_shutdown(s)) {
83136 @@ -302,7 +301,7 @@ void __init create_boot_cache(struct kmem_cache *s, const char *name, size_t siz
83137 panic("Creation of kmalloc slab %s size=%zd failed. Reason %d\n",
83138 name, size, err);
83139
83140 - s->refcount = -1; /* Exempt from merging for now */
83141 + atomic_set(&s->refcount, -1); /* Exempt from merging for now */
83142 }
83143
83144 struct kmem_cache *__init create_kmalloc_cache(const char *name, size_t size,
83145 @@ -315,7 +314,7 @@ struct kmem_cache *__init create_kmalloc_cache(const char *name, size_t size,
83146
83147 create_boot_cache(s, name, size, flags);
83148 list_add(&s->list, &slab_caches);
83149 - s->refcount = 1;
83150 + atomic_set(&s->refcount, 1);
83151 return s;
83152 }
83153
83154 diff --git a/mm/slob.c b/mm/slob.c
83155 index a99fdf7..f5b6577 100644
83156 --- a/mm/slob.c
83157 +++ b/mm/slob.c
83158 @@ -157,7 +157,7 @@ static void set_slob(slob_t *s, slobidx_t size, slob_t *next)
83159 /*
83160 * Return the size of a slob block.
83161 */
83162 -static slobidx_t slob_units(slob_t *s)
83163 +static slobidx_t slob_units(const slob_t *s)
83164 {
83165 if (s->units > 0)
83166 return s->units;
83167 @@ -167,7 +167,7 @@ static slobidx_t slob_units(slob_t *s)
83168 /*
83169 * Return the next free slob block pointer after this one.
83170 */
83171 -static slob_t *slob_next(slob_t *s)
83172 +static slob_t *slob_next(const slob_t *s)
83173 {
83174 slob_t *base = (slob_t *)((unsigned long)s & PAGE_MASK);
83175 slobidx_t next;
83176 @@ -182,14 +182,14 @@ static slob_t *slob_next(slob_t *s)
83177 /*
83178 * Returns true if s is the last free block in its page.
83179 */
83180 -static int slob_last(slob_t *s)
83181 +static int slob_last(const slob_t *s)
83182 {
83183 return !((unsigned long)slob_next(s) & ~PAGE_MASK);
83184 }
83185
83186 -static void *slob_new_pages(gfp_t gfp, int order, int node)
83187 +static struct page *slob_new_pages(gfp_t gfp, unsigned int order, int node)
83188 {
83189 - void *page;
83190 + struct page *page;
83191
83192 #ifdef CONFIG_NUMA
83193 if (node != NUMA_NO_NODE)
83194 @@ -201,14 +201,18 @@ static void *slob_new_pages(gfp_t gfp, int order, int node)
83195 if (!page)
83196 return NULL;
83197
83198 - return page_address(page);
83199 + __SetPageSlab(page);
83200 + return page;
83201 }
83202
83203 -static void slob_free_pages(void *b, int order)
83204 +static void slob_free_pages(struct page *sp, int order)
83205 {
83206 if (current->reclaim_state)
83207 current->reclaim_state->reclaimed_slab += 1 << order;
83208 - free_pages((unsigned long)b, order);
83209 + __ClearPageSlab(sp);
83210 + reset_page_mapcount(sp);
83211 + sp->private = 0;
83212 + __free_pages(sp, order);
83213 }
83214
83215 /*
83216 @@ -313,15 +317,15 @@ static void *slob_alloc(size_t size, gfp_t gfp, int align, int node)
83217
83218 /* Not enough space: must allocate a new page */
83219 if (!b) {
83220 - b = slob_new_pages(gfp & ~__GFP_ZERO, 0, node);
83221 - if (!b)
83222 + sp = slob_new_pages(gfp & ~__GFP_ZERO, 0, node);
83223 + if (!sp)
83224 return NULL;
83225 - sp = virt_to_page(b);
83226 - __SetPageSlab(sp);
83227 + b = page_address(sp);
83228
83229 spin_lock_irqsave(&slob_lock, flags);
83230 sp->units = SLOB_UNITS(PAGE_SIZE);
83231 sp->freelist = b;
83232 + sp->private = 0;
83233 INIT_LIST_HEAD(&sp->list);
83234 set_slob(b, SLOB_UNITS(PAGE_SIZE), b + SLOB_UNITS(PAGE_SIZE));
83235 set_slob_page_free(sp, slob_list);
83236 @@ -359,9 +363,7 @@ static void slob_free(void *block, int size)
83237 if (slob_page_free(sp))
83238 clear_slob_page_free(sp);
83239 spin_unlock_irqrestore(&slob_lock, flags);
83240 - __ClearPageSlab(sp);
83241 - reset_page_mapcount(sp);
83242 - slob_free_pages(b, 0);
83243 + slob_free_pages(sp, 0);
83244 return;
83245 }
83246
83247 @@ -424,11 +426,10 @@ out:
83248 */
83249
83250 static __always_inline void *
83251 -__do_kmalloc_node(size_t size, gfp_t gfp, int node, unsigned long caller)
83252 +__do_kmalloc_node_align(size_t size, gfp_t gfp, int node, unsigned long caller, int align)
83253 {
83254 - unsigned int *m;
83255 - int align = max_t(size_t, ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
83256 - void *ret;
83257 + slob_t *m;
83258 + void *ret = NULL;
83259
83260 gfp &= gfp_allowed_mask;
83261
83262 @@ -442,23 +443,41 @@ __do_kmalloc_node(size_t size, gfp_t gfp, int node, unsigned long caller)
83263
83264 if (!m)
83265 return NULL;
83266 - *m = size;
83267 + BUILD_BUG_ON(ARCH_KMALLOC_MINALIGN < 2 * SLOB_UNIT);
83268 + BUILD_BUG_ON(ARCH_SLAB_MINALIGN < 2 * SLOB_UNIT);
83269 + m[0].units = size;
83270 + m[1].units = align;
83271 ret = (void *)m + align;
83272
83273 trace_kmalloc_node(caller, ret,
83274 size, size + align, gfp, node);
83275 } else {
83276 unsigned int order = get_order(size);
83277 + struct page *page;
83278
83279 if (likely(order))
83280 gfp |= __GFP_COMP;
83281 - ret = slob_new_pages(gfp, order, node);
83282 + page = slob_new_pages(gfp, order, node);
83283 + if (page) {
83284 + ret = page_address(page);
83285 + page->private = size;
83286 + }
83287
83288 trace_kmalloc_node(caller, ret,
83289 size, PAGE_SIZE << order, gfp, node);
83290 }
83291
83292 - kmemleak_alloc(ret, size, 1, gfp);
83293 + return ret;
83294 +}
83295 +
83296 +static __always_inline void *
83297 +__do_kmalloc_node(size_t size, gfp_t gfp, int node, unsigned long caller)
83298 +{
83299 + int align = max(ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
83300 + void *ret = __do_kmalloc_node_align(size, gfp, node, caller, align);
83301 +
83302 + if (!ZERO_OR_NULL_PTR(ret))
83303 + kmemleak_alloc(ret, size, 1, gfp);
83304 return ret;
83305 }
83306
83307 @@ -494,33 +513,110 @@ void kfree(const void *block)
83308 kmemleak_free(block);
83309
83310 sp = virt_to_page(block);
83311 - if (PageSlab(sp)) {
83312 + VM_BUG_ON(!PageSlab(sp));
83313 + if (!sp->private) {
83314 int align = max_t(size_t, ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
83315 - unsigned int *m = (unsigned int *)(block - align);
83316 - slob_free(m, *m + align);
83317 - } else
83318 + slob_t *m = (slob_t *)(block - align);
83319 + slob_free(m, m[0].units + align);
83320 + } else {
83321 + __ClearPageSlab(sp);
83322 + reset_page_mapcount(sp);
83323 + sp->private = 0;
83324 __free_pages(sp, compound_order(sp));
83325 + }
83326 }
83327 EXPORT_SYMBOL(kfree);
83328
83329 +bool is_usercopy_object(const void *ptr)
83330 +{
83331 + if (!slab_is_available())
83332 + return false;
83333 +
83334 + // PAX: TODO
83335 +
83336 + return false;
83337 +}
83338 +
83339 +#ifdef CONFIG_PAX_USERCOPY
83340 +const char *check_heap_object(const void *ptr, unsigned long n)
83341 +{
83342 + struct page *page;
83343 + const slob_t *free;
83344 + const void *base;
83345 + unsigned long flags;
83346 +
83347 + if (ZERO_OR_NULL_PTR(ptr))
83348 + return "<null>";
83349 +
83350 + if (!virt_addr_valid(ptr))
83351 + return NULL;
83352 +
83353 + page = virt_to_head_page(ptr);
83354 + if (!PageSlab(page))
83355 + return NULL;
83356 +
83357 + if (page->private) {
83358 + base = page;
83359 + if (base <= ptr && n <= page->private - (ptr - base))
83360 + return NULL;
83361 + return "<slob>";
83362 + }
83363 +
83364 + /* some tricky double walking to find the chunk */
83365 + spin_lock_irqsave(&slob_lock, flags);
83366 + base = (void *)((unsigned long)ptr & PAGE_MASK);
83367 + free = page->freelist;
83368 +
83369 + while (!slob_last(free) && (void *)free <= ptr) {
83370 + base = free + slob_units(free);
83371 + free = slob_next(free);
83372 + }
83373 +
83374 + while (base < (void *)free) {
83375 + slobidx_t m = ((slob_t *)base)[0].units, align = ((slob_t *)base)[1].units;
83376 + int size = SLOB_UNIT * SLOB_UNITS(m + align);
83377 + int offset;
83378 +
83379 + if (ptr < base + align)
83380 + break;
83381 +
83382 + offset = ptr - base - align;
83383 + if (offset >= m) {
83384 + base += size;
83385 + continue;
83386 + }
83387 +
83388 + if (n > m - offset)
83389 + break;
83390 +
83391 + spin_unlock_irqrestore(&slob_lock, flags);
83392 + return NULL;
83393 + }
83394 +
83395 + spin_unlock_irqrestore(&slob_lock, flags);
83396 + return "<slob>";
83397 +}
83398 +#endif
83399 +
83400 /* can't use ksize for kmem_cache_alloc memory, only kmalloc */
83401 size_t ksize(const void *block)
83402 {
83403 struct page *sp;
83404 int align;
83405 - unsigned int *m;
83406 + slob_t *m;
83407
83408 BUG_ON(!block);
83409 if (unlikely(block == ZERO_SIZE_PTR))
83410 return 0;
83411
83412 sp = virt_to_page(block);
83413 - if (unlikely(!PageSlab(sp)))
83414 - return PAGE_SIZE << compound_order(sp);
83415 + VM_BUG_ON(!PageSlab(sp));
83416 + if (sp->private)
83417 + return sp->private;
83418
83419 align = max_t(size_t, ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
83420 - m = (unsigned int *)(block - align);
83421 - return SLOB_UNITS(*m) * SLOB_UNIT;
83422 + m = (slob_t *)(block - align);
83423 + return SLOB_UNITS(m[0].units) * SLOB_UNIT;
83424 }
83425 EXPORT_SYMBOL(ksize);
83426
83427 @@ -536,23 +632,33 @@ int __kmem_cache_create(struct kmem_cache *c, unsigned long flags)
83428
83429 void *kmem_cache_alloc_node(struct kmem_cache *c, gfp_t flags, int node)
83430 {
83431 - void *b;
83432 + void *b = NULL;
83433
83434 flags &= gfp_allowed_mask;
83435
83436 lockdep_trace_alloc(flags);
83437
83438 +#ifdef CONFIG_PAX_USERCOPY_SLABS
83439 + b = __do_kmalloc_node_align(c->size, flags, node, _RET_IP_, c->align);
83440 +#else
83441 if (c->size < PAGE_SIZE) {
83442 b = slob_alloc(c->size, flags, c->align, node);
83443 trace_kmem_cache_alloc_node(_RET_IP_, b, c->object_size,
83444 SLOB_UNITS(c->size) * SLOB_UNIT,
83445 flags, node);
83446 } else {
83447 - b = slob_new_pages(flags, get_order(c->size), node);
83448 + struct page *sp;
83449 +
83450 + sp = slob_new_pages(flags, get_order(c->size), node);
83451 + if (sp) {
83452 + b = page_address(sp);
83453 + sp->private = c->size;
83454 + }
83455 trace_kmem_cache_alloc_node(_RET_IP_, b, c->object_size,
83456 PAGE_SIZE << get_order(c->size),
83457 flags, node);
83458 }
83459 +#endif
83460
83461 if (c->ctor)
83462 c->ctor(b);
83463 @@ -564,10 +670,14 @@ EXPORT_SYMBOL(kmem_cache_alloc_node);
83464
83465 static void __kmem_cache_free(void *b, int size)
83466 {
83467 - if (size < PAGE_SIZE)
83468 + struct page *sp;
83469 +
83470 + sp = virt_to_page(b);
83471 + BUG_ON(!PageSlab(sp));
83472 + if (!sp->private)
83473 slob_free(b, size);
83474 else
83475 - slob_free_pages(b, get_order(size));
83476 + slob_free_pages(sp, get_order(size));
83477 }
83478
83479 static void kmem_rcu_free(struct rcu_head *head)
83480 @@ -580,17 +690,31 @@ static void kmem_rcu_free(struct rcu_head *head)
83481
83482 void kmem_cache_free(struct kmem_cache *c, void *b)
83483 {
83484 + int size = c->size;
83485 +
83486 +#ifdef CONFIG_PAX_USERCOPY_SLABS
83487 + if (size + c->align < PAGE_SIZE) {
83488 + size += c->align;
83489 + b -= c->align;
83490 + }
83491 +#endif
83492 +
83493 kmemleak_free_recursive(b, c->flags);
83494 if (unlikely(c->flags & SLAB_DESTROY_BY_RCU)) {
83495 struct slob_rcu *slob_rcu;
83496 - slob_rcu = b + (c->size - sizeof(struct slob_rcu));
83497 - slob_rcu->size = c->size;
83498 + slob_rcu = b + (size - sizeof(struct slob_rcu));
83499 + slob_rcu->size = size;
83500 call_rcu(&slob_rcu->head, kmem_rcu_free);
83501 } else {
83502 - __kmem_cache_free(b, c->size);
83503 + __kmem_cache_free(b, size);
83504 }
83505
83506 +#ifdef CONFIG_PAX_USERCOPY_SLABS
83507 + trace_kfree(_RET_IP_, b);
83508 +#else
83509 trace_kmem_cache_free(_RET_IP_, b);
83510 +#endif
83511 +
83512 }
83513 EXPORT_SYMBOL(kmem_cache_free);
83514
83515 diff --git a/mm/slub.c b/mm/slub.c
83516 index ba2ca53..00b1f4e 100644
83517 --- a/mm/slub.c
83518 +++ b/mm/slub.c
83519 @@ -197,7 +197,7 @@ struct track {
83520
83521 enum track_item { TRACK_ALLOC, TRACK_FREE };
83522
83523 -#ifdef CONFIG_SYSFS
83524 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
83525 static int sysfs_slab_add(struct kmem_cache *);
83526 static int sysfs_slab_alias(struct kmem_cache *, const char *);
83527 static void sysfs_slab_remove(struct kmem_cache *);
83528 @@ -518,7 +518,7 @@ static void print_track(const char *s, struct track *t)
83529 if (!t->addr)
83530 return;
83531
83532 - printk(KERN_ERR "INFO: %s in %pS age=%lu cpu=%u pid=%d\n",
83533 + printk(KERN_ERR "INFO: %s in %pA age=%lu cpu=%u pid=%d\n",
83534 s, (void *)t->addr, jiffies - t->when, t->cpu, t->pid);
83535 #ifdef CONFIG_STACKTRACE
83536 {
83537 @@ -2653,7 +2653,7 @@ static int slub_min_objects;
83538 * Merge control. If this is set then no merging of slab caches will occur.
83539 * (Could be removed. This was introduced to pacify the merge skeptics.)
83540 */
83541 -static int slub_nomerge;
83542 +static int slub_nomerge = 1;
83543
83544 /*
83545 * Calculate the order of allocation given an slab object size.
83546 @@ -3181,6 +3181,10 @@ EXPORT_SYMBOL(kmalloc_caches);
83547 static struct kmem_cache *kmalloc_dma_caches[SLUB_PAGE_SHIFT];
83548 #endif
83549
83550 +#ifdef CONFIG_PAX_USERCOPY_SLABS
83551 +static struct kmem_cache *kmalloc_usercopy_caches[SLUB_PAGE_SHIFT];
83552 +#endif
83553 +
83554 static int __init setup_slub_min_order(char *str)
83555 {
83556 get_option(&str, &slub_min_order);
83557 @@ -3272,6 +3276,13 @@ static struct kmem_cache *get_slab(size_t size, gfp_t flags)
83558 return kmalloc_dma_caches[index];
83559
83560 #endif
83561 +
83562 +#ifdef CONFIG_PAX_USERCOPY_SLABS
83563 + if (flags & SLAB_USERCOPY)
83564 + return kmalloc_usercopy_caches[index];
83565 +
83566 +#endif
83567 +
83568 return kmalloc_caches[index];
83569 }
83570
83571 @@ -3340,6 +3351,59 @@ void *__kmalloc_node(size_t size, gfp_t flags, int node)
83572 EXPORT_SYMBOL(__kmalloc_node);
83573 #endif
83574
83575 +bool is_usercopy_object(const void *ptr)
83576 +{
83577 + struct page *page;
83578 + struct kmem_cache *s;
83579 +
83580 + if (ZERO_OR_NULL_PTR(ptr))
83581 + return false;
83582 +
83583 + if (!slab_is_available())
83584 + return false;
83585 +
83586 + if (!virt_addr_valid(ptr))
83587 + return false;
83588 +
83589 + page = virt_to_head_page(ptr);
83590 +
83591 + if (!PageSlab(page))
83592 + return false;
83593 +
83594 + s = page->slab_cache;
83595 + return s->flags & SLAB_USERCOPY;
83596 +}
83597 +
83598 +#ifdef CONFIG_PAX_USERCOPY
83599 +const char *check_heap_object(const void *ptr, unsigned long n)
83600 +{
83601 + struct page *page;
83602 + struct kmem_cache *s;
83603 + unsigned long offset;
83604 +
83605 + if (ZERO_OR_NULL_PTR(ptr))
83606 + return "<null>";
83607 +
83608 + if (!virt_addr_valid(ptr))
83609 + return NULL;
83610 +
83611 + page = virt_to_head_page(ptr);
83612 +
83613 + if (!PageSlab(page))
83614 + return NULL;
83615 +
83616 + s = page->slab_cache;
83617 + if (!(s->flags & SLAB_USERCOPY))
83618 + return s->name;
83619 +
83620 + offset = (ptr - page_address(page)) % s->size;
83621 + if (offset <= s->object_size && n <= s->object_size - offset)
83622 + return NULL;
83623 +
83624 + return s->name;
83625 +}
83626 +#endif
83627 +
83628 size_t ksize(const void *object)
83629 {
83630 struct page *page;
83631 @@ -3712,17 +3776,17 @@ void __init kmem_cache_init(void)
83632
83633 /* Caches that are not of the two-to-the-power-of size */
83634 if (KMALLOC_MIN_SIZE <= 32) {
83635 - kmalloc_caches[1] = create_kmalloc_cache("kmalloc-96", 96, 0);
83636 + kmalloc_caches[1] = create_kmalloc_cache("kmalloc-96", 96, SLAB_USERCOPY);
83637 caches++;
83638 }
83639
83640 if (KMALLOC_MIN_SIZE <= 64) {
83641 - kmalloc_caches[2] = create_kmalloc_cache("kmalloc-192", 192, 0);
83642 + kmalloc_caches[2] = create_kmalloc_cache("kmalloc-192", 192, SLAB_USERCOPY);
83643 caches++;
83644 }
83645
83646 for (i = KMALLOC_SHIFT_LOW; i < SLUB_PAGE_SHIFT; i++) {
83647 - kmalloc_caches[i] = create_kmalloc_cache("kmalloc", 1 << i, 0);
83648 + kmalloc_caches[i] = create_kmalloc_cache("kmalloc", 1 << i, SLAB_USERCOPY);
83649 caches++;
83650 }
83651
83652 @@ -3764,6 +3828,22 @@ void __init kmem_cache_init(void)
83653 }
83654 }
83655 #endif
83656 +
83657 +#ifdef CONFIG_PAX_USERCOPY_SLABS
83658 + for (i = 0; i < SLUB_PAGE_SHIFT; i++) {
83659 + struct kmem_cache *s = kmalloc_caches[i];
83660 +
83661 + if (s && s->size) {
83662 + char *name = kasprintf(GFP_NOWAIT,
83663 + "usercopy-kmalloc-%d", s->object_size);
83664 +
83665 + BUG_ON(!name);
83666 + kmalloc_usercopy_caches[i] = create_kmalloc_cache(name,
83667 + s->object_size, SLAB_USERCOPY);
83668 + }
83669 + }
83670 +#endif
83671 +
83672 printk(KERN_INFO
83673 "SLUB: Genslabs=%d, HWalign=%d, Order=%d-%d, MinObjects=%d,"
83674 " CPUs=%d, Nodes=%d\n",
83675 @@ -3790,7 +3870,7 @@ static int slab_unmergeable(struct kmem_cache *s)
83676 /*
83677 * We may have set a slab to be unmergeable during bootstrap.
83678 */
83679 - if (s->refcount < 0)
83680 + if (atomic_read(&s->refcount) < 0)
83681 return 1;
83682
83683 return 0;
83684 @@ -3848,7 +3928,7 @@ __kmem_cache_alias(struct mem_cgroup *memcg, const char *name, size_t size,
83685
83686 s = find_mergeable(memcg, size, align, flags, name, ctor);
83687 if (s) {
83688 - s->refcount++;
83689 + atomic_inc(&s->refcount);
83690 /*
83691 * Adjust the object sizes so that we clear
83692 * the complete object on kzalloc.
83693 @@ -3857,7 +3937,7 @@ __kmem_cache_alias(struct mem_cgroup *memcg, const char *name, size_t size,
83694 s->inuse = max_t(int, s->inuse, ALIGN(size, sizeof(void *)));
83695
83696 if (sysfs_slab_alias(s, name)) {
83697 - s->refcount--;
83698 + atomic_dec(&s->refcount);
83699 s = NULL;
83700 }
83701 }
83702 @@ -3919,7 +3999,7 @@ static int __cpuinit slab_cpuup_callback(struct notifier_block *nfb,
83703 return NOTIFY_OK;
83704 }
83705
83706 -static struct notifier_block __cpuinitdata slab_notifier = {
83707 +static struct notifier_block slab_notifier = {
83708 .notifier_call = slab_cpuup_callback
83709 };
83710
83711 @@ -3977,7 +4057,7 @@ void *__kmalloc_node_track_caller(size_t size, gfp_t gfpflags,
83712 }
83713 #endif
83714
83715 -#ifdef CONFIG_SYSFS
83716 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
83717 static int count_inuse(struct page *page)
83718 {
83719 return page->inuse;
83720 @@ -4364,12 +4444,12 @@ static void resiliency_test(void)
83721 validate_slab_cache(kmalloc_caches[9]);
83722 }
83723 #else
83724 -#ifdef CONFIG_SYSFS
83725 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
83726 static void resiliency_test(void) {};
83727 #endif
83728 #endif
83729
83730 -#ifdef CONFIG_SYSFS
83731 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
83732 enum slab_stat_type {
83733 SL_ALL, /* All slabs */
83734 SL_PARTIAL, /* Only partially allocated slabs */
83735 @@ -4613,7 +4693,7 @@ SLAB_ATTR_RO(ctor);
83736
83737 static ssize_t aliases_show(struct kmem_cache *s, char *buf)
83738 {
83739 - return sprintf(buf, "%d\n", s->refcount - 1);
83740 + return sprintf(buf, "%d\n", atomic_read(&s->refcount) - 1);
83741 }
83742 SLAB_ATTR_RO(aliases);
83743
83744 @@ -5266,6 +5346,7 @@ static char *create_unique_id(struct kmem_cache *s)
83745 return name;
83746 }
83747
83748 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
83749 static int sysfs_slab_add(struct kmem_cache *s)
83750 {
83751 int err;
83752 @@ -5323,6 +5404,7 @@ static void sysfs_slab_remove(struct kmem_cache *s)
83753 kobject_del(&s->kobj);
83754 kobject_put(&s->kobj);
83755 }
83756 +#endif
83757
83758 /*
83759 * Need to buffer aliases during bootup until sysfs becomes
83760 @@ -5336,6 +5418,7 @@ struct saved_alias {
83761
83762 static struct saved_alias *alias_list;
83763
83764 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
83765 static int sysfs_slab_alias(struct kmem_cache *s, const char *name)
83766 {
83767 struct saved_alias *al;
83768 @@ -5358,6 +5441,7 @@ static int sysfs_slab_alias(struct kmem_cache *s, const char *name)
83769 alias_list = al;
83770 return 0;
83771 }
83772 +#endif
83773
83774 static int __init slab_sysfs_init(void)
83775 {
83776 diff --git a/mm/sparse-vmemmap.c b/mm/sparse-vmemmap.c
83777 index 1b7e22a..3fcd4f3 100644
83778 --- a/mm/sparse-vmemmap.c
83779 +++ b/mm/sparse-vmemmap.c
83780 @@ -128,7 +128,7 @@ pud_t * __meminit vmemmap_pud_populate(pgd_t *pgd, unsigned long addr, int node)
83781 void *p = vmemmap_alloc_block(PAGE_SIZE, node);
83782 if (!p)
83783 return NULL;
83784 - pud_populate(&init_mm, pud, p);
83785 + pud_populate_kernel(&init_mm, pud, p);
83786 }
83787 return pud;
83788 }
83789 @@ -140,7 +140,7 @@ pgd_t * __meminit vmemmap_pgd_populate(unsigned long addr, int node)
83790 void *p = vmemmap_alloc_block(PAGE_SIZE, node);
83791 if (!p)
83792 return NULL;
83793 - pgd_populate(&init_mm, pgd, p);
83794 + pgd_populate_kernel(&init_mm, pgd, p);
83795 }
83796 return pgd;
83797 }
83798 diff --git a/mm/sparse.c b/mm/sparse.c
83799 index 6b5fb76..db0c190 100644
83800 --- a/mm/sparse.c
83801 +++ b/mm/sparse.c
83802 @@ -782,7 +782,7 @@ static void clear_hwpoisoned_pages(struct page *memmap, int nr_pages)
83803
83804 for (i = 0; i < PAGES_PER_SECTION; i++) {
83805 if (PageHWPoison(&memmap[i])) {
83806 - atomic_long_sub(1, &mce_bad_pages);
83807 + atomic_long_sub_unchecked(1, &mce_bad_pages);
83808 ClearPageHWPoison(&memmap[i]);
83809 }
83810 }
83811 diff --git a/mm/swap.c b/mm/swap.c
83812 index 6310dc2..3662b3f 100644
83813 --- a/mm/swap.c
83814 +++ b/mm/swap.c
83815 @@ -30,6 +30,7 @@
83816 #include <linux/backing-dev.h>
83817 #include <linux/memcontrol.h>
83818 #include <linux/gfp.h>
83819 +#include <linux/hugetlb.h>
83820
83821 #include "internal.h"
83822
83823 @@ -72,6 +73,8 @@ static void __put_compound_page(struct page *page)
83824
83825 __page_cache_release(page);
83826 dtor = get_compound_page_dtor(page);
83827 + if (!PageHuge(page))
83828 + BUG_ON(dtor != free_compound_page);
83829 (*dtor)(page);
83830 }
83831
83832 diff --git a/mm/swapfile.c b/mm/swapfile.c
83833 index e97a0e5..b50e796 100644
83834 --- a/mm/swapfile.c
83835 +++ b/mm/swapfile.c
83836 @@ -64,7 +64,7 @@ static DEFINE_MUTEX(swapon_mutex);
83837
83838 static DECLARE_WAIT_QUEUE_HEAD(proc_poll_wait);
83839 /* Activity counter to indicate that a swapon or swapoff has occurred */
83840 -static atomic_t proc_poll_event = ATOMIC_INIT(0);
83841 +static atomic_unchecked_t proc_poll_event = ATOMIC_INIT(0);
83842
83843 static inline unsigned char swap_count(unsigned char ent)
83844 {
83845 @@ -1608,7 +1608,7 @@ SYSCALL_DEFINE1(swapoff, const char __user *, specialfile)
83846 }
83847 filp_close(swap_file, NULL);
83848 err = 0;
83849 - atomic_inc(&proc_poll_event);
83850 + atomic_inc_unchecked(&proc_poll_event);
83851 wake_up_interruptible(&proc_poll_wait);
83852
83853 out_dput:
83854 @@ -1625,8 +1625,8 @@ static unsigned swaps_poll(struct file *file, poll_table *wait)
83855
83856 poll_wait(file, &proc_poll_wait, wait);
83857
83858 - if (seq->poll_event != atomic_read(&proc_poll_event)) {
83859 - seq->poll_event = atomic_read(&proc_poll_event);
83860 + if (seq->poll_event != atomic_read_unchecked(&proc_poll_event)) {
83861 + seq->poll_event = atomic_read_unchecked(&proc_poll_event);
83862 return POLLIN | POLLRDNORM | POLLERR | POLLPRI;
83863 }
83864
83865 @@ -1724,7 +1724,7 @@ static int swaps_open(struct inode *inode, struct file *file)
83866 return ret;
83867
83868 seq = file->private_data;
83869 - seq->poll_event = atomic_read(&proc_poll_event);
83870 + seq->poll_event = atomic_read_unchecked(&proc_poll_event);
83871 return 0;
83872 }
83873
83874 @@ -2066,7 +2066,7 @@ SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags)
83875 (frontswap_map) ? "FS" : "");
83876
83877 mutex_unlock(&swapon_mutex);
83878 - atomic_inc(&proc_poll_event);
83879 + atomic_inc_unchecked(&proc_poll_event);
83880 wake_up_interruptible(&proc_poll_wait);
83881
83882 if (S_ISREG(inode->i_mode))
83883 diff --git a/mm/util.c b/mm/util.c
83884 index c55e26b..3f913a9 100644
83885 --- a/mm/util.c
83886 +++ b/mm/util.c
83887 @@ -292,6 +292,12 @@ done:
83888 void arch_pick_mmap_layout(struct mm_struct *mm)
83889 {
83890 mm->mmap_base = TASK_UNMAPPED_BASE;
83891 +
83892 +#ifdef CONFIG_PAX_RANDMMAP
83893 + if (mm->pax_flags & MF_PAX_RANDMMAP)
83894 + mm->mmap_base += mm->delta_mmap;
83895 +#endif
83896 +
83897 mm->get_unmapped_area = arch_get_unmapped_area;
83898 mm->unmap_area = arch_unmap_area;
83899 }
83900 diff --git a/mm/vmalloc.c b/mm/vmalloc.c
83901 index 5123a16..f234a48 100644
83902 --- a/mm/vmalloc.c
83903 +++ b/mm/vmalloc.c
83904 @@ -39,8 +39,19 @@ static void vunmap_pte_range(pmd_t *pmd, unsigned long addr, unsigned long end)
83905
83906 pte = pte_offset_kernel(pmd, addr);
83907 do {
83908 - pte_t ptent = ptep_get_and_clear(&init_mm, addr, pte);
83909 - WARN_ON(!pte_none(ptent) && !pte_present(ptent));
83910 +
83911 +#if defined(CONFIG_MODULES) && defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
83912 + if ((unsigned long)MODULES_EXEC_VADDR <= addr && addr < (unsigned long)MODULES_EXEC_END) {
83913 + BUG_ON(!pte_exec(*pte));
83914 + set_pte_at(&init_mm, addr, pte, pfn_pte(__pa(addr) >> PAGE_SHIFT, PAGE_KERNEL_EXEC));
83915 + continue;
83916 + }
83917 +#endif
83918 +
83919 + {
83920 + pte_t ptent = ptep_get_and_clear(&init_mm, addr, pte);
83921 + WARN_ON(!pte_none(ptent) && !pte_present(ptent));
83922 + }
83923 } while (pte++, addr += PAGE_SIZE, addr != end);
83924 }
83925
83926 @@ -100,16 +111,29 @@ static int vmap_pte_range(pmd_t *pmd, unsigned long addr,
83927 pte = pte_alloc_kernel(pmd, addr);
83928 if (!pte)
83929 return -ENOMEM;
83930 +
83931 + pax_open_kernel();
83932 do {
83933 struct page *page = pages[*nr];
83934
83935 - if (WARN_ON(!pte_none(*pte)))
83936 +#if defined(CONFIG_MODULES) && defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
83937 + if (pgprot_val(prot) & _PAGE_NX)
83938 +#endif
83939 +
83940 + if (!pte_none(*pte)) {
83941 + pax_close_kernel();
83942 + WARN_ON(1);
83943 return -EBUSY;
83944 - if (WARN_ON(!page))
83945 + }
83946 + if (!page) {
83947 + pax_close_kernel();
83948 + WARN_ON(1);
83949 return -ENOMEM;
83950 + }
83951 set_pte_at(&init_mm, addr, pte, mk_pte(page, prot));
83952 (*nr)++;
83953 } while (pte++, addr += PAGE_SIZE, addr != end);
83954 + pax_close_kernel();
83955 return 0;
83956 }
83957
83958 @@ -119,7 +143,7 @@ static int vmap_pmd_range(pud_t *pud, unsigned long addr,
83959 pmd_t *pmd;
83960 unsigned long next;
83961
83962 - pmd = pmd_alloc(&init_mm, pud, addr);
83963 + pmd = pmd_alloc_kernel(&init_mm, pud, addr);
83964 if (!pmd)
83965 return -ENOMEM;
83966 do {
83967 @@ -136,7 +160,7 @@ static int vmap_pud_range(pgd_t *pgd, unsigned long addr,
83968 pud_t *pud;
83969 unsigned long next;
83970
83971 - pud = pud_alloc(&init_mm, pgd, addr);
83972 + pud = pud_alloc_kernel(&init_mm, pgd, addr);
83973 if (!pud)
83974 return -ENOMEM;
83975 do {
83976 @@ -191,11 +215,20 @@ int is_vmalloc_or_module_addr(const void *x)
83977 * and fall back on vmalloc() if that fails. Others
83978 * just put it in the vmalloc space.
83979 */
83980 -#if defined(CONFIG_MODULES) && defined(MODULES_VADDR)
83981 +#ifdef CONFIG_MODULES
83982 +#ifdef MODULES_VADDR
83983 unsigned long addr = (unsigned long)x;
83984 if (addr >= MODULES_VADDR && addr < MODULES_END)
83985 return 1;
83986 #endif
83987 +
83988 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
83989 + if (x >= (const void *)MODULES_EXEC_VADDR && x < (const void *)MODULES_EXEC_END)
83990 + return 1;
83991 +#endif
83992 +
83993 +#endif
83994 +
83995 return is_vmalloc_addr(x);
83996 }
83997
83998 @@ -216,8 +249,14 @@ struct page *vmalloc_to_page(const void *vmalloc_addr)
83999
84000 if (!pgd_none(*pgd)) {
84001 pud_t *pud = pud_offset(pgd, addr);
84002 +#ifdef CONFIG_X86
84003 + if (!pud_large(*pud))
84004 +#endif
84005 if (!pud_none(*pud)) {
84006 pmd_t *pmd = pmd_offset(pud, addr);
84007 +#ifdef CONFIG_X86
84008 + if (!pmd_large(*pmd))
84009 +#endif
84010 if (!pmd_none(*pmd)) {
84011 pte_t *ptep, pte;
84012
84013 @@ -329,7 +368,7 @@ static void purge_vmap_area_lazy(void);
84014 * Allocate a region of KVA of the specified size and alignment, within the
84015 * vstart and vend.
84016 */
84017 -static struct vmap_area *alloc_vmap_area(unsigned long size,
84018 +static __size_overflow(1) struct vmap_area *alloc_vmap_area(unsigned long size,
84019 unsigned long align,
84020 unsigned long vstart, unsigned long vend,
84021 int node, gfp_t gfp_mask)
84022 @@ -1328,6 +1367,16 @@ static struct vm_struct *__get_vm_area_node(unsigned long size,
84023 struct vm_struct *area;
84024
84025 BUG_ON(in_interrupt());
84026 +
84027 +#if defined(CONFIG_MODULES) && defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
84028 + if (flags & VM_KERNEXEC) {
84029 + if (start != VMALLOC_START || end != VMALLOC_END)
84030 + return NULL;
84031 + start = (unsigned long)MODULES_EXEC_VADDR;
84032 + end = (unsigned long)MODULES_EXEC_END;
84033 + }
84034 +#endif
84035 +
84036 if (flags & VM_IOREMAP) {
84037 int bit = fls(size);
84038
84039 @@ -1568,6 +1617,11 @@ void *vmap(struct page **pages, unsigned int count,
84040 if (count > totalram_pages)
84041 return NULL;
84042
84043 +#if defined(CONFIG_MODULES) && defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
84044 + if (!(pgprot_val(prot) & _PAGE_NX))
84045 + flags |= VM_KERNEXEC;
84046 +#endif
84047 +
84048 area = get_vm_area_caller((count << PAGE_SHIFT), flags,
84049 __builtin_return_address(0));
84050 if (!area)
84051 @@ -1669,6 +1723,13 @@ void *__vmalloc_node_range(unsigned long size, unsigned long align,
84052 if (!size || (size >> PAGE_SHIFT) > totalram_pages)
84053 goto fail;
84054
84055 +#if defined(CONFIG_MODULES) && defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
84056 + if (!(pgprot_val(prot) & _PAGE_NX))
84057 + area = __get_vm_area_node(size, align, VM_ALLOC | VM_UNLIST | VM_KERNEXEC,
84058 + VMALLOC_START, VMALLOC_END, node, gfp_mask, caller);
84059 + else
84060 +#endif
84061 +
84062 area = __get_vm_area_node(size, align, VM_ALLOC | VM_UNLIST,
84063 start, end, node, gfp_mask, caller);
84064 if (!area)
84065 @@ -1842,10 +1903,9 @@ EXPORT_SYMBOL(vzalloc_node);
84066 * For tight control over page level allocator and protection flags
84067 * use __vmalloc() instead.
84068 */
84069 -
84070 void *vmalloc_exec(unsigned long size)
84071 {
84072 - return __vmalloc_node(size, 1, GFP_KERNEL | __GFP_HIGHMEM, PAGE_KERNEL_EXEC,
84073 + return __vmalloc_node(size, 1, GFP_KERNEL | __GFP_HIGHMEM | __GFP_ZERO, PAGE_KERNEL_EXEC,
84074 -1, __builtin_return_address(0));
84075 }
84076
84077 @@ -2136,6 +2196,8 @@ int remap_vmalloc_range(struct vm_area_struct *vma, void *addr,
84078 unsigned long uaddr = vma->vm_start;
84079 unsigned long usize = vma->vm_end - vma->vm_start;
84080
84081 + BUG_ON(vma->vm_mirror);
84082 +
84083 if ((PAGE_SIZE-1) & (unsigned long)addr)
84084 return -EINVAL;
84085
84086 @@ -2575,7 +2637,11 @@ static int s_show(struct seq_file *m, void *p)
84087 v->addr, v->addr + v->size, v->size);
84088
84089 if (v->caller)
84090 +#ifdef CONFIG_GRKERNSEC_HIDESYM
84091 + seq_printf(m, " %pK", v->caller);
84092 +#else
84093 seq_printf(m, " %pS", v->caller);
84094 +#endif
84095
84096 if (v->nr_pages)
84097 seq_printf(m, " pages=%d", v->nr_pages);
84098 diff --git a/mm/vmstat.c b/mm/vmstat.c
84099 index 9800306..76b4b27 100644
84100 --- a/mm/vmstat.c
84101 +++ b/mm/vmstat.c
84102 @@ -78,7 +78,7 @@ void vm_events_fold_cpu(int cpu)
84103 *
84104 * vm_stat contains the global counters
84105 */
84106 -atomic_long_t vm_stat[NR_VM_ZONE_STAT_ITEMS] __cacheline_aligned_in_smp;
84107 +atomic_long_unchecked_t vm_stat[NR_VM_ZONE_STAT_ITEMS] __cacheline_aligned_in_smp;
84108 EXPORT_SYMBOL(vm_stat);
84109
84110 #ifdef CONFIG_SMP
84111 @@ -454,7 +454,7 @@ void refresh_cpu_vm_stats(int cpu)
84112 v = p->vm_stat_diff[i];
84113 p->vm_stat_diff[i] = 0;
84114 local_irq_restore(flags);
84115 - atomic_long_add(v, &zone->vm_stat[i]);
84116 + atomic_long_add_unchecked(v, &zone->vm_stat[i]);
84117 global_diff[i] += v;
84118 #ifdef CONFIG_NUMA
84119 /* 3 seconds idle till flush */
84120 @@ -492,7 +492,7 @@ void refresh_cpu_vm_stats(int cpu)
84121
84122 for (i = 0; i < NR_VM_ZONE_STAT_ITEMS; i++)
84123 if (global_diff[i])
84124 - atomic_long_add(global_diff[i], &vm_stat[i]);
84125 + atomic_long_add_unchecked(global_diff[i], &vm_stat[i]);
84126 }
84127
84128 void drain_zonestat(struct zone *zone, struct per_cpu_pageset *pset)
84129 @@ -503,8 +503,8 @@ void drain_zonestat(struct zone *zone, struct per_cpu_pageset *pset)
84130 if (pset->vm_stat_diff[i]) {
84131 int v = pset->vm_stat_diff[i];
84132 pset->vm_stat_diff[i] = 0;
84133 - atomic_long_add(v, &zone->vm_stat[i]);
84134 - atomic_long_add(v, &vm_stat[i]);
84135 + atomic_long_add_unchecked(v, &zone->vm_stat[i]);
84136 + atomic_long_add_unchecked(v, &vm_stat[i]);
84137 }
84138 }
84139 #endif
84140 @@ -1223,7 +1223,7 @@ static int __cpuinit vmstat_cpuup_callback(struct notifier_block *nfb,
84141 return NOTIFY_OK;
84142 }
84143
84144 -static struct notifier_block __cpuinitdata vmstat_notifier =
84145 +static struct notifier_block vmstat_notifier =
84146 { &vmstat_cpuup_callback, NULL, 0 };
84147 #endif
84148
84149 @@ -1238,10 +1238,20 @@ static int __init setup_vmstat(void)
84150 start_cpu_timer(cpu);
84151 #endif
84152 #ifdef CONFIG_PROC_FS
84153 - proc_create("buddyinfo", S_IRUGO, NULL, &fragmentation_file_operations);
84154 - proc_create("pagetypeinfo", S_IRUGO, NULL, &pagetypeinfo_file_ops);
84155 - proc_create("vmstat", S_IRUGO, NULL, &proc_vmstat_file_operations);
84156 - proc_create("zoneinfo", S_IRUGO, NULL, &proc_zoneinfo_file_operations);
84157 + {
84158 + mode_t gr_mode = S_IRUGO;
84159 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
84160 + gr_mode = S_IRUSR;
84161 +#endif
84162 + proc_create("buddyinfo", gr_mode, NULL, &fragmentation_file_operations);
84163 + proc_create("pagetypeinfo", gr_mode, NULL, &pagetypeinfo_file_ops);
84164 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
84165 + proc_create("vmstat", gr_mode | S_IRGRP, NULL, &proc_vmstat_file_operations);
84166 +#else
84167 + proc_create("vmstat", gr_mode, NULL, &proc_vmstat_file_operations);
84168 +#endif
84169 + proc_create("zoneinfo", gr_mode, NULL, &proc_zoneinfo_file_operations);
84170 + }
84171 #endif
84172 return 0;
84173 }
84174 diff --git a/net/8021q/vlan.c b/net/8021q/vlan.c
84175 index a292e80..785ee68 100644
84176 --- a/net/8021q/vlan.c
84177 +++ b/net/8021q/vlan.c
84178 @@ -485,7 +485,7 @@ out:
84179 return NOTIFY_DONE;
84180 }
84181
84182 -static struct notifier_block vlan_notifier_block __read_mostly = {
84183 +static struct notifier_block vlan_notifier_block = {
84184 .notifier_call = vlan_device_event,
84185 };
84186
84187 @@ -560,8 +560,7 @@ static int vlan_ioctl_handler(struct net *net, void __user *arg)
84188 err = -EPERM;
84189 if (!ns_capable(net->user_ns, CAP_NET_ADMIN))
84190 break;
84191 - if ((args.u.name_type >= 0) &&
84192 - (args.u.name_type < VLAN_NAME_TYPE_HIGHEST)) {
84193 + if (args.u.name_type < VLAN_NAME_TYPE_HIGHEST) {
84194 struct vlan_net *vn;
84195
84196 vn = net_generic(net, vlan_net_id);
84197 diff --git a/net/9p/mod.c b/net/9p/mod.c
84198 index 6ab36ae..6f1841b 100644
84199 --- a/net/9p/mod.c
84200 +++ b/net/9p/mod.c
84201 @@ -84,7 +84,7 @@ static LIST_HEAD(v9fs_trans_list);
84202 void v9fs_register_trans(struct p9_trans_module *m)
84203 {
84204 spin_lock(&v9fs_trans_lock);
84205 - list_add_tail(&m->list, &v9fs_trans_list);
84206 + pax_list_add_tail((struct list_head *)&m->list, &v9fs_trans_list);
84207 spin_unlock(&v9fs_trans_lock);
84208 }
84209 EXPORT_SYMBOL(v9fs_register_trans);
84210 @@ -97,7 +97,7 @@ EXPORT_SYMBOL(v9fs_register_trans);
84211 void v9fs_unregister_trans(struct p9_trans_module *m)
84212 {
84213 spin_lock(&v9fs_trans_lock);
84214 - list_del_init(&m->list);
84215 + pax_list_del_init((struct list_head *)&m->list);
84216 spin_unlock(&v9fs_trans_lock);
84217 }
84218 EXPORT_SYMBOL(v9fs_unregister_trans);
84219 diff --git a/net/9p/trans_fd.c b/net/9p/trans_fd.c
84220 index 02efb25..41541a9 100644
84221 --- a/net/9p/trans_fd.c
84222 +++ b/net/9p/trans_fd.c
84223 @@ -425,7 +425,7 @@ static int p9_fd_write(struct p9_client *client, void *v, int len)
84224 oldfs = get_fs();
84225 set_fs(get_ds());
84226 /* The cast to a user pointer is valid due to the set_fs() */
84227 - ret = vfs_write(ts->wr, (__force void __user *)v, len, &ts->wr->f_pos);
84228 + ret = vfs_write(ts->wr, (void __force_user *)v, len, &ts->wr->f_pos);
84229 set_fs(oldfs);
84230
84231 if (ret <= 0 && ret != -ERESTARTSYS && ret != -EAGAIN)
84232 diff --git a/net/atm/atm_misc.c b/net/atm/atm_misc.c
84233 index 876fbe8..8bbea9f 100644
84234 --- a/net/atm/atm_misc.c
84235 +++ b/net/atm/atm_misc.c
84236 @@ -17,7 +17,7 @@ int atm_charge(struct atm_vcc *vcc, int truesize)
84237 if (atomic_read(&sk_atm(vcc)->sk_rmem_alloc) <= sk_atm(vcc)->sk_rcvbuf)
84238 return 1;
84239 atm_return(vcc, truesize);
84240 - atomic_inc(&vcc->stats->rx_drop);
84241 + atomic_inc_unchecked(&vcc->stats->rx_drop);
84242 return 0;
84243 }
84244 EXPORT_SYMBOL(atm_charge);
84245 @@ -39,7 +39,7 @@ struct sk_buff *atm_alloc_charge(struct atm_vcc *vcc, int pdu_size,
84246 }
84247 }
84248 atm_return(vcc, guess);
84249 - atomic_inc(&vcc->stats->rx_drop);
84250 + atomic_inc_unchecked(&vcc->stats->rx_drop);
84251 return NULL;
84252 }
84253 EXPORT_SYMBOL(atm_alloc_charge);
84254 @@ -86,7 +86,7 @@ EXPORT_SYMBOL(atm_pcr_goal);
84255
84256 void sonet_copy_stats(struct k_sonet_stats *from, struct sonet_stats *to)
84257 {
84258 -#define __HANDLE_ITEM(i) to->i = atomic_read(&from->i)
84259 +#define __HANDLE_ITEM(i) to->i = atomic_read_unchecked(&from->i)
84260 __SONET_ITEMS
84261 #undef __HANDLE_ITEM
84262 }
84263 @@ -94,7 +94,7 @@ EXPORT_SYMBOL(sonet_copy_stats);
84264
84265 void sonet_subtract_stats(struct k_sonet_stats *from, struct sonet_stats *to)
84266 {
84267 -#define __HANDLE_ITEM(i) atomic_sub(to->i, &from->i)
84268 +#define __HANDLE_ITEM(i) atomic_sub_unchecked(to->i,&from->i)
84269 __SONET_ITEMS
84270 #undef __HANDLE_ITEM
84271 }
84272 diff --git a/net/atm/lec.h b/net/atm/lec.h
84273 index a86aff9..3a0d6f6 100644
84274 --- a/net/atm/lec.h
84275 +++ b/net/atm/lec.h
84276 @@ -48,7 +48,7 @@ struct lane2_ops {
84277 const u8 *tlvs, u32 sizeoftlvs);
84278 void (*associate_indicator) (struct net_device *dev, const u8 *mac_addr,
84279 const u8 *tlvs, u32 sizeoftlvs);
84280 -};
84281 +} __no_const;
84282
84283 /*
84284 * ATM LAN Emulation supports both LLC & Dix Ethernet EtherType
84285 diff --git a/net/atm/proc.c b/net/atm/proc.c
84286 index 0d020de..011c7bb 100644
84287 --- a/net/atm/proc.c
84288 +++ b/net/atm/proc.c
84289 @@ -45,9 +45,9 @@ static void add_stats(struct seq_file *seq, const char *aal,
84290 const struct k_atm_aal_stats *stats)
84291 {
84292 seq_printf(seq, "%s ( %d %d %d %d %d )", aal,
84293 - atomic_read(&stats->tx), atomic_read(&stats->tx_err),
84294 - atomic_read(&stats->rx), atomic_read(&stats->rx_err),
84295 - atomic_read(&stats->rx_drop));
84296 + atomic_read_unchecked(&stats->tx),atomic_read_unchecked(&stats->tx_err),
84297 + atomic_read_unchecked(&stats->rx),atomic_read_unchecked(&stats->rx_err),
84298 + atomic_read_unchecked(&stats->rx_drop));
84299 }
84300
84301 static void atm_dev_info(struct seq_file *seq, const struct atm_dev *dev)
84302 diff --git a/net/atm/resources.c b/net/atm/resources.c
84303 index 0447d5d..3cf4728 100644
84304 --- a/net/atm/resources.c
84305 +++ b/net/atm/resources.c
84306 @@ -160,7 +160,7 @@ EXPORT_SYMBOL(atm_dev_deregister);
84307 static void copy_aal_stats(struct k_atm_aal_stats *from,
84308 struct atm_aal_stats *to)
84309 {
84310 -#define __HANDLE_ITEM(i) to->i = atomic_read(&from->i)
84311 +#define __HANDLE_ITEM(i) to->i = atomic_read_unchecked(&from->i)
84312 __AAL_STAT_ITEMS
84313 #undef __HANDLE_ITEM
84314 }
84315 @@ -168,7 +168,7 @@ static void copy_aal_stats(struct k_atm_aal_stats *from,
84316 static void subtract_aal_stats(struct k_atm_aal_stats *from,
84317 struct atm_aal_stats *to)
84318 {
84319 -#define __HANDLE_ITEM(i) atomic_sub(to->i, &from->i)
84320 +#define __HANDLE_ITEM(i) atomic_sub_unchecked(to->i, &from->i)
84321 __AAL_STAT_ITEMS
84322 #undef __HANDLE_ITEM
84323 }
84324 diff --git a/net/ax25/sysctl_net_ax25.c b/net/ax25/sysctl_net_ax25.c
84325 index d5744b7..506bae3 100644
84326 --- a/net/ax25/sysctl_net_ax25.c
84327 +++ b/net/ax25/sysctl_net_ax25.c
84328 @@ -152,7 +152,7 @@ int ax25_register_dev_sysctl(ax25_dev *ax25_dev)
84329 {
84330 char path[sizeof("net/ax25/") + IFNAMSIZ];
84331 int k;
84332 - struct ctl_table *table;
84333 + ctl_table_no_const *table;
84334
84335 table = kmemdup(ax25_param_table, sizeof(ax25_param_table), GFP_KERNEL);
84336 if (!table)
84337 diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c
84338 index 7d02ebd..4d4cc01 100644
84339 --- a/net/batman-adv/bat_iv_ogm.c
84340 +++ b/net/batman-adv/bat_iv_ogm.c
84341 @@ -63,7 +63,7 @@ static int batadv_iv_ogm_iface_enable(struct batadv_hard_iface *hard_iface)
84342
84343 /* randomize initial seqno to avoid collision */
84344 get_random_bytes(&random_seqno, sizeof(random_seqno));
84345 - atomic_set(&hard_iface->bat_iv.ogm_seqno, random_seqno);
84346 + atomic_set_unchecked(&hard_iface->bat_iv.ogm_seqno, random_seqno);
84347
84348 hard_iface->bat_iv.ogm_buff_len = BATADV_OGM_HLEN;
84349 ogm_buff = kmalloc(hard_iface->bat_iv.ogm_buff_len, GFP_ATOMIC);
84350 @@ -615,9 +615,9 @@ static void batadv_iv_ogm_schedule(struct batadv_hard_iface *hard_iface)
84351 batadv_ogm_packet = (struct batadv_ogm_packet *)(*ogm_buff);
84352
84353 /* change sequence number to network order */
84354 - seqno = (uint32_t)atomic_read(&hard_iface->bat_iv.ogm_seqno);
84355 + seqno = (uint32_t)atomic_read_unchecked(&hard_iface->bat_iv.ogm_seqno);
84356 batadv_ogm_packet->seqno = htonl(seqno);
84357 - atomic_inc(&hard_iface->bat_iv.ogm_seqno);
84358 + atomic_inc_unchecked(&hard_iface->bat_iv.ogm_seqno);
84359
84360 batadv_ogm_packet->ttvn = atomic_read(&bat_priv->tt.vn);
84361 batadv_ogm_packet->tt_crc = htons(bat_priv->tt.local_crc);
84362 @@ -1022,7 +1022,7 @@ static void batadv_iv_ogm_process(const struct ethhdr *ethhdr,
84363 return;
84364
84365 /* could be changed by schedule_own_packet() */
84366 - if_incoming_seqno = atomic_read(&if_incoming->bat_iv.ogm_seqno);
84367 + if_incoming_seqno = atomic_read_unchecked(&if_incoming->bat_iv.ogm_seqno);
84368
84369 if (batadv_ogm_packet->flags & BATADV_DIRECTLINK)
84370 has_directlink_flag = 1;
84371 diff --git a/net/batman-adv/hard-interface.c b/net/batman-adv/hard-interface.c
84372 index f1d37cd..4190879 100644
84373 --- a/net/batman-adv/hard-interface.c
84374 +++ b/net/batman-adv/hard-interface.c
84375 @@ -370,7 +370,7 @@ int batadv_hardif_enable_interface(struct batadv_hard_iface *hard_iface,
84376 hard_iface->batman_adv_ptype.dev = hard_iface->net_dev;
84377 dev_add_pack(&hard_iface->batman_adv_ptype);
84378
84379 - atomic_set(&hard_iface->frag_seqno, 1);
84380 + atomic_set_unchecked(&hard_iface->frag_seqno, 1);
84381 batadv_info(hard_iface->soft_iface, "Adding interface: %s\n",
84382 hard_iface->net_dev->name);
84383
84384 @@ -493,7 +493,7 @@ batadv_hardif_add_interface(struct net_device *net_dev)
84385 /* This can't be called via a bat_priv callback because
84386 * we have no bat_priv yet.
84387 */
84388 - atomic_set(&hard_iface->bat_iv.ogm_seqno, 1);
84389 + atomic_set_unchecked(&hard_iface->bat_iv.ogm_seqno, 1);
84390 hard_iface->bat_iv.ogm_buff = NULL;
84391
84392 return hard_iface;
84393 diff --git a/net/batman-adv/soft-interface.c b/net/batman-adv/soft-interface.c
84394 index 6b548fd..fc32c8d 100644
84395 --- a/net/batman-adv/soft-interface.c
84396 +++ b/net/batman-adv/soft-interface.c
84397 @@ -252,7 +252,7 @@ static int batadv_interface_tx(struct sk_buff *skb,
84398 primary_if->net_dev->dev_addr, ETH_ALEN);
84399
84400 /* set broadcast sequence number */
84401 - seqno = atomic_inc_return(&bat_priv->bcast_seqno);
84402 + seqno = atomic_inc_return_unchecked(&bat_priv->bcast_seqno);
84403 bcast_packet->seqno = htonl(seqno);
84404
84405 batadv_add_bcast_packet_to_list(bat_priv, skb, brd_delay);
84406 @@ -497,7 +497,7 @@ struct net_device *batadv_softif_create(const char *name)
84407 atomic_set(&bat_priv->batman_queue_left, BATADV_BATMAN_QUEUE_LEN);
84408
84409 atomic_set(&bat_priv->mesh_state, BATADV_MESH_INACTIVE);
84410 - atomic_set(&bat_priv->bcast_seqno, 1);
84411 + atomic_set_unchecked(&bat_priv->bcast_seqno, 1);
84412 atomic_set(&bat_priv->tt.vn, 0);
84413 atomic_set(&bat_priv->tt.local_changes, 0);
84414 atomic_set(&bat_priv->tt.ogm_append_cnt, 0);
84415 diff --git a/net/batman-adv/types.h b/net/batman-adv/types.h
84416 index ae9ac9a..11e0fe7 100644
84417 --- a/net/batman-adv/types.h
84418 +++ b/net/batman-adv/types.h
84419 @@ -48,7 +48,7 @@
84420 struct batadv_hard_iface_bat_iv {
84421 unsigned char *ogm_buff;
84422 int ogm_buff_len;
84423 - atomic_t ogm_seqno;
84424 + atomic_unchecked_t ogm_seqno;
84425 };
84426
84427 struct batadv_hard_iface {
84428 @@ -56,7 +56,7 @@ struct batadv_hard_iface {
84429 int16_t if_num;
84430 char if_status;
84431 struct net_device *net_dev;
84432 - atomic_t frag_seqno;
84433 + atomic_unchecked_t frag_seqno;
84434 struct kobject *hardif_obj;
84435 atomic_t refcount;
84436 struct packet_type batman_adv_ptype;
84437 @@ -284,7 +284,7 @@ struct batadv_priv {
84438 atomic_t orig_interval; /* uint */
84439 atomic_t hop_penalty; /* uint */
84440 atomic_t log_level; /* uint */
84441 - atomic_t bcast_seqno;
84442 + atomic_unchecked_t bcast_seqno;
84443 atomic_t bcast_queue_left;
84444 atomic_t batman_queue_left;
84445 char num_ifaces;
84446 diff --git a/net/batman-adv/unicast.c b/net/batman-adv/unicast.c
84447 index 10aff49..ea8e021 100644
84448 --- a/net/batman-adv/unicast.c
84449 +++ b/net/batman-adv/unicast.c
84450 @@ -272,7 +272,7 @@ int batadv_frag_send_skb(struct sk_buff *skb, struct batadv_priv *bat_priv,
84451 frag1->flags = BATADV_UNI_FRAG_HEAD | large_tail;
84452 frag2->flags = large_tail;
84453
84454 - seqno = atomic_add_return(2, &hard_iface->frag_seqno);
84455 + seqno = atomic_add_return_unchecked(2, &hard_iface->frag_seqno);
84456 frag1->seqno = htons(seqno - 1);
84457 frag2->seqno = htons(seqno);
84458
84459 diff --git a/net/bluetooth/hci_sock.c b/net/bluetooth/hci_sock.c
84460 index 07f0739..3c42e34 100644
84461 --- a/net/bluetooth/hci_sock.c
84462 +++ b/net/bluetooth/hci_sock.c
84463 @@ -934,7 +934,7 @@ static int hci_sock_setsockopt(struct socket *sock, int level, int optname,
84464 uf.event_mask[1] = *((u32 *) f->event_mask + 1);
84465 }
84466
84467 - len = min_t(unsigned int, len, sizeof(uf));
84468 + len = min((size_t)len, sizeof(uf));
84469 if (copy_from_user(&uf, optval, len)) {
84470 err = -EFAULT;
84471 break;
84472 diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
84473 index 22e6583..426e2f3 100644
84474 --- a/net/bluetooth/l2cap_core.c
84475 +++ b/net/bluetooth/l2cap_core.c
84476 @@ -3400,8 +3400,10 @@ static int l2cap_parse_conf_rsp(struct l2cap_chan *chan, void *rsp, int len,
84477 break;
84478
84479 case L2CAP_CONF_RFC:
84480 - if (olen == sizeof(rfc))
84481 - memcpy(&rfc, (void *)val, olen);
84482 + if (olen != sizeof(rfc))
84483 + break;
84484 +
84485 + memcpy(&rfc, (void *)val, olen);
84486
84487 if (test_bit(CONF_STATE2_DEVICE, &chan->conf_state) &&
84488 rfc.mode != chan->mode)
84489 diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c
84490 index 1bcfb84..dad9f98 100644
84491 --- a/net/bluetooth/l2cap_sock.c
84492 +++ b/net/bluetooth/l2cap_sock.c
84493 @@ -479,7 +479,8 @@ static int l2cap_sock_setsockopt_old(struct socket *sock, int optname,
84494 struct sock *sk = sock->sk;
84495 struct l2cap_chan *chan = l2cap_pi(sk)->chan;
84496 struct l2cap_options opts;
84497 - int len, err = 0;
84498 + int err = 0;
84499 + size_t len = optlen;
84500 u32 opt;
84501
84502 BT_DBG("sk %p", sk);
84503 @@ -501,7 +502,7 @@ static int l2cap_sock_setsockopt_old(struct socket *sock, int optname,
84504 opts.max_tx = chan->max_tx;
84505 opts.txwin_size = chan->tx_win;
84506
84507 - len = min_t(unsigned int, sizeof(opts), optlen);
84508 + len = min(sizeof(opts), len);
84509 if (copy_from_user((char *) &opts, optval, len)) {
84510 err = -EFAULT;
84511 break;
84512 @@ -581,7 +582,8 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname,
84513 struct bt_security sec;
84514 struct bt_power pwr;
84515 struct l2cap_conn *conn;
84516 - int len, err = 0;
84517 + int err = 0;
84518 + size_t len = optlen;
84519 u32 opt;
84520
84521 BT_DBG("sk %p", sk);
84522 @@ -604,7 +606,7 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname,
84523
84524 sec.level = BT_SECURITY_LOW;
84525
84526 - len = min_t(unsigned int, sizeof(sec), optlen);
84527 + len = min(sizeof(sec), len);
84528 if (copy_from_user((char *) &sec, optval, len)) {
84529 err = -EFAULT;
84530 break;
84531 @@ -701,7 +703,7 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname,
84532
84533 pwr.force_active = BT_POWER_FORCE_ACTIVE_ON;
84534
84535 - len = min_t(unsigned int, sizeof(pwr), optlen);
84536 + len = min(sizeof(pwr), len);
84537 if (copy_from_user((char *) &pwr, optval, len)) {
84538 err = -EFAULT;
84539 break;
84540 diff --git a/net/bluetooth/rfcomm/sock.c b/net/bluetooth/rfcomm/sock.c
84541 index ce3f665..2c7d08f 100644
84542 --- a/net/bluetooth/rfcomm/sock.c
84543 +++ b/net/bluetooth/rfcomm/sock.c
84544 @@ -667,7 +667,7 @@ static int rfcomm_sock_setsockopt(struct socket *sock, int level, int optname, c
84545 struct sock *sk = sock->sk;
84546 struct bt_security sec;
84547 int err = 0;
84548 - size_t len;
84549 + size_t len = optlen;
84550 u32 opt;
84551
84552 BT_DBG("sk %p", sk);
84553 @@ -689,7 +689,7 @@ static int rfcomm_sock_setsockopt(struct socket *sock, int level, int optname, c
84554
84555 sec.level = BT_SECURITY_LOW;
84556
84557 - len = min_t(unsigned int, sizeof(sec), optlen);
84558 + len = min(sizeof(sec), len);
84559 if (copy_from_user((char *) &sec, optval, len)) {
84560 err = -EFAULT;
84561 break;
84562 diff --git a/net/bluetooth/rfcomm/tty.c b/net/bluetooth/rfcomm/tty.c
84563 index bd6fd0f..6492cba 100644
84564 --- a/net/bluetooth/rfcomm/tty.c
84565 +++ b/net/bluetooth/rfcomm/tty.c
84566 @@ -309,7 +309,7 @@ static void rfcomm_dev_del(struct rfcomm_dev *dev)
84567 BUG_ON(test_and_set_bit(RFCOMM_TTY_RELEASED, &dev->flags));
84568
84569 spin_lock_irqsave(&dev->port.lock, flags);
84570 - if (dev->port.count > 0) {
84571 + if (atomic_read(&dev->port.count) > 0) {
84572 spin_unlock_irqrestore(&dev->port.lock, flags);
84573 return;
84574 }
84575 @@ -664,10 +664,10 @@ static int rfcomm_tty_open(struct tty_struct *tty, struct file *filp)
84576 return -ENODEV;
84577
84578 BT_DBG("dev %p dst %pMR channel %d opened %d", dev, &dev->dst,
84579 - dev->channel, dev->port.count);
84580 + dev->channel, atomic_read(&dev->port.count));
84581
84582 spin_lock_irqsave(&dev->port.lock, flags);
84583 - if (++dev->port.count > 1) {
84584 + if (atomic_inc_return(&dev->port.count) > 1) {
84585 spin_unlock_irqrestore(&dev->port.lock, flags);
84586 return 0;
84587 }
84588 @@ -732,10 +732,10 @@ static void rfcomm_tty_close(struct tty_struct *tty, struct file *filp)
84589 return;
84590
84591 BT_DBG("tty %p dev %p dlc %p opened %d", tty, dev, dev->dlc,
84592 - dev->port.count);
84593 + atomic_read(&dev->port.count));
84594
84595 spin_lock_irqsave(&dev->port.lock, flags);
84596 - if (!--dev->port.count) {
84597 + if (!atomic_dec_return(&dev->port.count)) {
84598 spin_unlock_irqrestore(&dev->port.lock, flags);
84599 if (dev->tty_dev->parent)
84600 device_move(dev->tty_dev, NULL, DPM_ORDER_DEV_LAST);
84601 diff --git a/net/bridge/netfilter/ebtables.c b/net/bridge/netfilter/ebtables.c
84602 index 5fe2ff3..121d696 100644
84603 --- a/net/bridge/netfilter/ebtables.c
84604 +++ b/net/bridge/netfilter/ebtables.c
84605 @@ -1523,7 +1523,7 @@ static int do_ebt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
84606 tmp.valid_hooks = t->table->valid_hooks;
84607 }
84608 mutex_unlock(&ebt_mutex);
84609 - if (copy_to_user(user, &tmp, *len) != 0){
84610 + if (*len > sizeof(tmp) || copy_to_user(user, &tmp, *len) != 0){
84611 BUGPRINT("c2u Didn't work\n");
84612 ret = -EFAULT;
84613 break;
84614 @@ -2327,7 +2327,7 @@ static int compat_do_ebt_get_ctl(struct sock *sk, int cmd,
84615 goto out;
84616 tmp.valid_hooks = t->valid_hooks;
84617
84618 - if (copy_to_user(user, &tmp, *len) != 0) {
84619 + if (*len > sizeof(tmp) || copy_to_user(user, &tmp, *len) != 0) {
84620 ret = -EFAULT;
84621 break;
84622 }
84623 @@ -2338,7 +2338,7 @@ static int compat_do_ebt_get_ctl(struct sock *sk, int cmd,
84624 tmp.entries_size = t->table->entries_size;
84625 tmp.valid_hooks = t->table->valid_hooks;
84626
84627 - if (copy_to_user(user, &tmp, *len) != 0) {
84628 + if (*len > sizeof(tmp) || copy_to_user(user, &tmp, *len) != 0) {
84629 ret = -EFAULT;
84630 break;
84631 }
84632 diff --git a/net/caif/cfctrl.c b/net/caif/cfctrl.c
84633 index a376ec1..1fbd6be 100644
84634 --- a/net/caif/cfctrl.c
84635 +++ b/net/caif/cfctrl.c
84636 @@ -10,6 +10,7 @@
84637 #include <linux/spinlock.h>
84638 #include <linux/slab.h>
84639 #include <linux/pkt_sched.h>
84640 +#include <linux/sched.h>
84641 #include <net/caif/caif_layer.h>
84642 #include <net/caif/cfpkt.h>
84643 #include <net/caif/cfctrl.h>
84644 @@ -43,8 +44,8 @@ struct cflayer *cfctrl_create(void)
84645 memset(&dev_info, 0, sizeof(dev_info));
84646 dev_info.id = 0xff;
84647 cfsrvl_init(&this->serv, 0, &dev_info, false);
84648 - atomic_set(&this->req_seq_no, 1);
84649 - atomic_set(&this->rsp_seq_no, 1);
84650 + atomic_set_unchecked(&this->req_seq_no, 1);
84651 + atomic_set_unchecked(&this->rsp_seq_no, 1);
84652 this->serv.layer.receive = cfctrl_recv;
84653 sprintf(this->serv.layer.name, "ctrl");
84654 this->serv.layer.ctrlcmd = cfctrl_ctrlcmd;
84655 @@ -130,8 +131,8 @@ static void cfctrl_insert_req(struct cfctrl *ctrl,
84656 struct cfctrl_request_info *req)
84657 {
84658 spin_lock_bh(&ctrl->info_list_lock);
84659 - atomic_inc(&ctrl->req_seq_no);
84660 - req->sequence_no = atomic_read(&ctrl->req_seq_no);
84661 + atomic_inc_unchecked(&ctrl->req_seq_no);
84662 + req->sequence_no = atomic_read_unchecked(&ctrl->req_seq_no);
84663 list_add_tail(&req->list, &ctrl->list);
84664 spin_unlock_bh(&ctrl->info_list_lock);
84665 }
84666 @@ -149,7 +150,7 @@ static struct cfctrl_request_info *cfctrl_remove_req(struct cfctrl *ctrl,
84667 if (p != first)
84668 pr_warn("Requests are not received in order\n");
84669
84670 - atomic_set(&ctrl->rsp_seq_no,
84671 + atomic_set_unchecked(&ctrl->rsp_seq_no,
84672 p->sequence_no);
84673 list_del(&p->list);
84674 goto out;
84675 diff --git a/net/can/af_can.c b/net/can/af_can.c
84676 index ddac1ee..3ee0a78 100644
84677 --- a/net/can/af_can.c
84678 +++ b/net/can/af_can.c
84679 @@ -872,7 +872,7 @@ static const struct net_proto_family can_family_ops = {
84680 };
84681
84682 /* notifier block for netdevice event */
84683 -static struct notifier_block can_netdev_notifier __read_mostly = {
84684 +static struct notifier_block can_netdev_notifier = {
84685 .notifier_call = can_notifier,
84686 };
84687
84688 diff --git a/net/can/gw.c b/net/can/gw.c
84689 index 574dda78e..3d2b3da 100644
84690 --- a/net/can/gw.c
84691 +++ b/net/can/gw.c
84692 @@ -67,7 +67,6 @@ MODULE_AUTHOR("Oliver Hartkopp <oliver.hartkopp@volkswagen.de>");
84693 MODULE_ALIAS("can-gw");
84694
84695 static HLIST_HEAD(cgw_list);
84696 -static struct notifier_block notifier;
84697
84698 static struct kmem_cache *cgw_cache __read_mostly;
84699
84700 @@ -893,6 +892,10 @@ static int cgw_remove_job(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg)
84701 return err;
84702 }
84703
84704 +static struct notifier_block notifier = {
84705 + .notifier_call = cgw_notifier
84706 +};
84707 +
84708 static __init int cgw_module_init(void)
84709 {
84710 printk(banner);
84711 @@ -904,7 +907,6 @@ static __init int cgw_module_init(void)
84712 return -ENOMEM;
84713
84714 /* set notifier */
84715 - notifier.notifier_call = cgw_notifier;
84716 register_netdevice_notifier(&notifier);
84717
84718 if (__rtnl_register(PF_CAN, RTM_GETROUTE, NULL, cgw_dump_jobs, NULL)) {
84719 diff --git a/net/compat.c b/net/compat.c
84720 index 79ae884..17c5c09 100644
84721 --- a/net/compat.c
84722 +++ b/net/compat.c
84723 @@ -71,9 +71,9 @@ int get_compat_msghdr(struct msghdr *kmsg, struct compat_msghdr __user *umsg)
84724 __get_user(kmsg->msg_controllen, &umsg->msg_controllen) ||
84725 __get_user(kmsg->msg_flags, &umsg->msg_flags))
84726 return -EFAULT;
84727 - kmsg->msg_name = compat_ptr(tmp1);
84728 - kmsg->msg_iov = compat_ptr(tmp2);
84729 - kmsg->msg_control = compat_ptr(tmp3);
84730 + kmsg->msg_name = (void __force_kernel *)compat_ptr(tmp1);
84731 + kmsg->msg_iov = (void __force_kernel *)compat_ptr(tmp2);
84732 + kmsg->msg_control = (void __force_kernel *)compat_ptr(tmp3);
84733 return 0;
84734 }
84735
84736 @@ -85,7 +85,7 @@ int verify_compat_iovec(struct msghdr *kern_msg, struct iovec *kern_iov,
84737
84738 if (kern_msg->msg_namelen) {
84739 if (mode == VERIFY_READ) {
84740 - int err = move_addr_to_kernel(kern_msg->msg_name,
84741 + int err = move_addr_to_kernel((void __force_user *)kern_msg->msg_name,
84742 kern_msg->msg_namelen,
84743 kern_address);
84744 if (err < 0)
84745 @@ -96,7 +96,7 @@ int verify_compat_iovec(struct msghdr *kern_msg, struct iovec *kern_iov,
84746 kern_msg->msg_name = NULL;
84747
84748 tot_len = iov_from_user_compat_to_kern(kern_iov,
84749 - (struct compat_iovec __user *)kern_msg->msg_iov,
84750 + (struct compat_iovec __force_user *)kern_msg->msg_iov,
84751 kern_msg->msg_iovlen);
84752 if (tot_len >= 0)
84753 kern_msg->msg_iov = kern_iov;
84754 @@ -116,20 +116,20 @@ int verify_compat_iovec(struct msghdr *kern_msg, struct iovec *kern_iov,
84755
84756 #define CMSG_COMPAT_FIRSTHDR(msg) \
84757 (((msg)->msg_controllen) >= sizeof(struct compat_cmsghdr) ? \
84758 - (struct compat_cmsghdr __user *)((msg)->msg_control) : \
84759 + (struct compat_cmsghdr __force_user *)((msg)->msg_control) : \
84760 (struct compat_cmsghdr __user *)NULL)
84761
84762 #define CMSG_COMPAT_OK(ucmlen, ucmsg, mhdr) \
84763 ((ucmlen) >= sizeof(struct compat_cmsghdr) && \
84764 (ucmlen) <= (unsigned long) \
84765 ((mhdr)->msg_controllen - \
84766 - ((char *)(ucmsg) - (char *)(mhdr)->msg_control)))
84767 + ((char __force_kernel *)(ucmsg) - (char *)(mhdr)->msg_control)))
84768
84769 static inline struct compat_cmsghdr __user *cmsg_compat_nxthdr(struct msghdr *msg,
84770 struct compat_cmsghdr __user *cmsg, int cmsg_len)
84771 {
84772 char __user *ptr = (char __user *)cmsg + CMSG_COMPAT_ALIGN(cmsg_len);
84773 - if ((unsigned long)(ptr + 1 - (char __user *)msg->msg_control) >
84774 + if ((unsigned long)(ptr + 1 - (char __force_user *)msg->msg_control) >
84775 msg->msg_controllen)
84776 return NULL;
84777 return (struct compat_cmsghdr __user *)ptr;
84778 @@ -219,7 +219,7 @@ Efault:
84779
84780 int put_cmsg_compat(struct msghdr *kmsg, int level, int type, int len, void *data)
84781 {
84782 - struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __user *) kmsg->msg_control;
84783 + struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __force_user *) kmsg->msg_control;
84784 struct compat_cmsghdr cmhdr;
84785 struct compat_timeval ctv;
84786 struct compat_timespec cts[3];
84787 @@ -275,7 +275,7 @@ int put_cmsg_compat(struct msghdr *kmsg, int level, int type, int len, void *dat
84788
84789 void scm_detach_fds_compat(struct msghdr *kmsg, struct scm_cookie *scm)
84790 {
84791 - struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __user *) kmsg->msg_control;
84792 + struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __force_user *) kmsg->msg_control;
84793 int fdmax = (kmsg->msg_controllen - sizeof(struct compat_cmsghdr)) / sizeof(int);
84794 int fdnum = scm->fp->count;
84795 struct file **fp = scm->fp->fp;
84796 @@ -363,7 +363,7 @@ static int do_set_sock_timeout(struct socket *sock, int level,
84797 return -EFAULT;
84798 old_fs = get_fs();
84799 set_fs(KERNEL_DS);
84800 - err = sock_setsockopt(sock, level, optname, (char *)&ktime, sizeof(ktime));
84801 + err = sock_setsockopt(sock, level, optname, (char __force_user *)&ktime, sizeof(ktime));
84802 set_fs(old_fs);
84803
84804 return err;
84805 @@ -424,7 +424,7 @@ static int do_get_sock_timeout(struct socket *sock, int level, int optname,
84806 len = sizeof(ktime);
84807 old_fs = get_fs();
84808 set_fs(KERNEL_DS);
84809 - err = sock_getsockopt(sock, level, optname, (char *) &ktime, &len);
84810 + err = sock_getsockopt(sock, level, optname, (char __force_user *) &ktime, (int __force_user *)&len);
84811 set_fs(old_fs);
84812
84813 if (!err) {
84814 @@ -567,7 +567,7 @@ int compat_mc_setsockopt(struct sock *sock, int level, int optname,
84815 case MCAST_JOIN_GROUP:
84816 case MCAST_LEAVE_GROUP:
84817 {
84818 - struct compat_group_req __user *gr32 = (void *)optval;
84819 + struct compat_group_req __user *gr32 = (void __user *)optval;
84820 struct group_req __user *kgr =
84821 compat_alloc_user_space(sizeof(struct group_req));
84822 u32 interface;
84823 @@ -588,7 +588,7 @@ int compat_mc_setsockopt(struct sock *sock, int level, int optname,
84824 case MCAST_BLOCK_SOURCE:
84825 case MCAST_UNBLOCK_SOURCE:
84826 {
84827 - struct compat_group_source_req __user *gsr32 = (void *)optval;
84828 + struct compat_group_source_req __user *gsr32 = (void __user *)optval;
84829 struct group_source_req __user *kgsr = compat_alloc_user_space(
84830 sizeof(struct group_source_req));
84831 u32 interface;
84832 @@ -609,7 +609,7 @@ int compat_mc_setsockopt(struct sock *sock, int level, int optname,
84833 }
84834 case MCAST_MSFILTER:
84835 {
84836 - struct compat_group_filter __user *gf32 = (void *)optval;
84837 + struct compat_group_filter __user *gf32 = (void __user *)optval;
84838 struct group_filter __user *kgf;
84839 u32 interface, fmode, numsrc;
84840
84841 @@ -647,7 +647,7 @@ int compat_mc_getsockopt(struct sock *sock, int level, int optname,
84842 char __user *optval, int __user *optlen,
84843 int (*getsockopt)(struct sock *, int, int, char __user *, int __user *))
84844 {
84845 - struct compat_group_filter __user *gf32 = (void *)optval;
84846 + struct compat_group_filter __user *gf32 = (void __user *)optval;
84847 struct group_filter __user *kgf;
84848 int __user *koptlen;
84849 u32 interface, fmode, numsrc;
84850 @@ -796,7 +796,7 @@ asmlinkage long compat_sys_socketcall(int call, u32 __user *args)
84851
84852 if (call < SYS_SOCKET || call > SYS_SENDMMSG)
84853 return -EINVAL;
84854 - if (copy_from_user(a, args, nas[call]))
84855 + if (nas[call] > sizeof a || copy_from_user(a, args, nas[call]))
84856 return -EFAULT;
84857 a0 = a[0];
84858 a1 = a[1];
84859 diff --git a/net/core/datagram.c b/net/core/datagram.c
84860 index 368f9c3..f82d4a3 100644
84861 --- a/net/core/datagram.c
84862 +++ b/net/core/datagram.c
84863 @@ -289,7 +289,7 @@ int skb_kill_datagram(struct sock *sk, struct sk_buff *skb, unsigned int flags)
84864 }
84865
84866 kfree_skb(skb);
84867 - atomic_inc(&sk->sk_drops);
84868 + atomic_inc_unchecked(&sk->sk_drops);
84869 sk_mem_reclaim_partial(sk);
84870
84871 return err;
84872 diff --git a/net/core/dev.c b/net/core/dev.c
84873 index 1339f77..6fd27dc 100644
84874 --- a/net/core/dev.c
84875 +++ b/net/core/dev.c
84876 @@ -1250,9 +1250,13 @@ void dev_load(struct net *net, const char *name)
84877 if (no_module && capable(CAP_NET_ADMIN))
84878 no_module = request_module("netdev-%s", name);
84879 if (no_module && capable(CAP_SYS_MODULE)) {
84880 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
84881 + ___request_module(true, "grsec_modharden_netdev", "%s", name);
84882 +#else
84883 if (!request_module("%s", name))
84884 pr_warn("Loading kernel module for a network device with CAP_SYS_MODULE (deprecated). Use CAP_NET_ADMIN and alias netdev-%s instead.\n",
84885 name);
84886 +#endif
84887 }
84888 }
84889 EXPORT_SYMBOL(dev_load);
84890 @@ -1715,7 +1719,7 @@ int dev_forward_skb(struct net_device *dev, struct sk_buff *skb)
84891 {
84892 if (skb_shinfo(skb)->tx_flags & SKBTX_DEV_ZEROCOPY) {
84893 if (skb_copy_ubufs(skb, GFP_ATOMIC)) {
84894 - atomic_long_inc(&dev->rx_dropped);
84895 + atomic_long_inc_unchecked(&dev->rx_dropped);
84896 kfree_skb(skb);
84897 return NET_RX_DROP;
84898 }
84899 @@ -1725,7 +1729,7 @@ int dev_forward_skb(struct net_device *dev, struct sk_buff *skb)
84900 nf_reset(skb);
84901
84902 if (unlikely(!is_skb_forwardable(dev, skb))) {
84903 - atomic_long_inc(&dev->rx_dropped);
84904 + atomic_long_inc_unchecked(&dev->rx_dropped);
84905 kfree_skb(skb);
84906 return NET_RX_DROP;
84907 }
84908 @@ -2180,7 +2184,7 @@ static int illegal_highdma(struct net_device *dev, struct sk_buff *skb)
84909
84910 struct dev_gso_cb {
84911 void (*destructor)(struct sk_buff *skb);
84912 -};
84913 +} __no_const;
84914
84915 #define DEV_GSO_CB(skb) ((struct dev_gso_cb *)(skb)->cb)
84916
84917 @@ -3053,7 +3057,7 @@ enqueue:
84918
84919 local_irq_restore(flags);
84920
84921 - atomic_long_inc(&skb->dev->rx_dropped);
84922 + atomic_long_inc_unchecked(&skb->dev->rx_dropped);
84923 kfree_skb(skb);
84924 return NET_RX_DROP;
84925 }
84926 @@ -3125,7 +3129,7 @@ int netif_rx_ni(struct sk_buff *skb)
84927 }
84928 EXPORT_SYMBOL(netif_rx_ni);
84929
84930 -static void net_tx_action(struct softirq_action *h)
84931 +static void net_tx_action(void)
84932 {
84933 struct softnet_data *sd = &__get_cpu_var(softnet_data);
84934
84935 @@ -3457,7 +3461,7 @@ ncls:
84936 ret = pt_prev->func(skb, skb->dev, pt_prev, orig_dev);
84937 } else {
84938 drop:
84939 - atomic_long_inc(&skb->dev->rx_dropped);
84940 + atomic_long_inc_unchecked(&skb->dev->rx_dropped);
84941 kfree_skb(skb);
84942 /* Jamal, now you will not able to escape explaining
84943 * me how you were going to use this. :-)
84944 @@ -4040,7 +4044,7 @@ void netif_napi_del(struct napi_struct *napi)
84945 }
84946 EXPORT_SYMBOL(netif_napi_del);
84947
84948 -static void net_rx_action(struct softirq_action *h)
84949 +static void net_rx_action(void)
84950 {
84951 struct softnet_data *sd = &__get_cpu_var(softnet_data);
84952 unsigned long time_limit = jiffies + 2;
84953 @@ -4524,8 +4528,13 @@ static int ptype_seq_show(struct seq_file *seq, void *v)
84954 else
84955 seq_printf(seq, "%04x", ntohs(pt->type));
84956
84957 +#ifdef CONFIG_GRKERNSEC_HIDESYM
84958 + seq_printf(seq, " %-8s %p\n",
84959 + pt->dev ? pt->dev->name : "", NULL);
84960 +#else
84961 seq_printf(seq, " %-8s %pF\n",
84962 pt->dev ? pt->dev->name : "", pt->func);
84963 +#endif
84964 }
84965
84966 return 0;
84967 @@ -6097,7 +6106,7 @@ struct rtnl_link_stats64 *dev_get_stats(struct net_device *dev,
84968 } else {
84969 netdev_stats_to_stats64(storage, &dev->stats);
84970 }
84971 - storage->rx_dropped += atomic_long_read(&dev->rx_dropped);
84972 + storage->rx_dropped += atomic_long_read_unchecked(&dev->rx_dropped);
84973 return storage;
84974 }
84975 EXPORT_SYMBOL(dev_get_stats);
84976 diff --git a/net/core/flow.c b/net/core/flow.c
84977 index b0901ee..7d3c2ca 100644
84978 --- a/net/core/flow.c
84979 +++ b/net/core/flow.c
84980 @@ -61,7 +61,7 @@ struct flow_cache {
84981 struct timer_list rnd_timer;
84982 };
84983
84984 -atomic_t flow_cache_genid = ATOMIC_INIT(0);
84985 +atomic_unchecked_t flow_cache_genid = ATOMIC_INIT(0);
84986 EXPORT_SYMBOL(flow_cache_genid);
84987 static struct flow_cache flow_cache_global;
84988 static struct kmem_cache *flow_cachep __read_mostly;
84989 @@ -86,7 +86,7 @@ static void flow_cache_new_hashrnd(unsigned long arg)
84990
84991 static int flow_entry_valid(struct flow_cache_entry *fle)
84992 {
84993 - if (atomic_read(&flow_cache_genid) != fle->genid)
84994 + if (atomic_read_unchecked(&flow_cache_genid) != fle->genid)
84995 return 0;
84996 if (fle->object && !fle->object->ops->check(fle->object))
84997 return 0;
84998 @@ -259,7 +259,7 @@ flow_cache_lookup(struct net *net, const struct flowi *key, u16 family, u8 dir,
84999 hlist_add_head(&fle->u.hlist, &fcp->hash_table[hash]);
85000 fcp->hash_count++;
85001 }
85002 - } else if (likely(fle->genid == atomic_read(&flow_cache_genid))) {
85003 + } else if (likely(fle->genid == atomic_read_unchecked(&flow_cache_genid))) {
85004 flo = fle->object;
85005 if (!flo)
85006 goto ret_object;
85007 @@ -280,7 +280,7 @@ nocache:
85008 }
85009 flo = resolver(net, key, family, dir, flo, ctx);
85010 if (fle) {
85011 - fle->genid = atomic_read(&flow_cache_genid);
85012 + fle->genid = atomic_read_unchecked(&flow_cache_genid);
85013 if (!IS_ERR(flo))
85014 fle->object = flo;
85015 else
85016 diff --git a/net/core/iovec.c b/net/core/iovec.c
85017 index 7e7aeb0..2a998cb 100644
85018 --- a/net/core/iovec.c
85019 +++ b/net/core/iovec.c
85020 @@ -42,7 +42,7 @@ int verify_iovec(struct msghdr *m, struct iovec *iov, struct sockaddr_storage *a
85021 if (m->msg_namelen) {
85022 if (mode == VERIFY_READ) {
85023 void __user *namep;
85024 - namep = (void __user __force *) m->msg_name;
85025 + namep = (void __force_user *) m->msg_name;
85026 err = move_addr_to_kernel(namep, m->msg_namelen,
85027 address);
85028 if (err < 0)
85029 @@ -54,7 +54,7 @@ int verify_iovec(struct msghdr *m, struct iovec *iov, struct sockaddr_storage *a
85030 }
85031
85032 size = m->msg_iovlen * sizeof(struct iovec);
85033 - if (copy_from_user(iov, (void __user __force *) m->msg_iov, size))
85034 + if (copy_from_user(iov, (void __force_user *) m->msg_iov, size))
85035 return -EFAULT;
85036
85037 m->msg_iov = iov;
85038 diff --git a/net/core/neighbour.c b/net/core/neighbour.c
85039 index c815f28..e6403f2 100644
85040 --- a/net/core/neighbour.c
85041 +++ b/net/core/neighbour.c
85042 @@ -2776,7 +2776,7 @@ static int proc_unres_qlen(ctl_table *ctl, int write, void __user *buffer,
85043 size_t *lenp, loff_t *ppos)
85044 {
85045 int size, ret;
85046 - ctl_table tmp = *ctl;
85047 + ctl_table_no_const tmp = *ctl;
85048
85049 tmp.extra1 = &zero;
85050 tmp.extra2 = &unres_qlen_max;
85051 diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c
85052 index 28c5f5a..7edf2e2 100644
85053 --- a/net/core/net-sysfs.c
85054 +++ b/net/core/net-sysfs.c
85055 @@ -1455,7 +1455,7 @@ void netdev_class_remove_file(struct class_attribute *class_attr)
85056 }
85057 EXPORT_SYMBOL(netdev_class_remove_file);
85058
85059 -int netdev_kobject_init(void)
85060 +int __init netdev_kobject_init(void)
85061 {
85062 kobj_ns_type_register(&net_ns_type_operations);
85063 return class_register(&net_class);
85064 diff --git a/net/core/net_namespace.c b/net/core/net_namespace.c
85065 index 8acce01..2e306bb 100644
85066 --- a/net/core/net_namespace.c
85067 +++ b/net/core/net_namespace.c
85068 @@ -442,7 +442,7 @@ static int __register_pernet_operations(struct list_head *list,
85069 int error;
85070 LIST_HEAD(net_exit_list);
85071
85072 - list_add_tail(&ops->list, list);
85073 + pax_list_add_tail((struct list_head *)&ops->list, list);
85074 if (ops->init || (ops->id && ops->size)) {
85075 for_each_net(net) {
85076 error = ops_init(ops, net);
85077 @@ -455,7 +455,7 @@ static int __register_pernet_operations(struct list_head *list,
85078
85079 out_undo:
85080 /* If I have an error cleanup all namespaces I initialized */
85081 - list_del(&ops->list);
85082 + pax_list_del((struct list_head *)&ops->list);
85083 ops_exit_list(ops, &net_exit_list);
85084 ops_free_list(ops, &net_exit_list);
85085 return error;
85086 @@ -466,7 +466,7 @@ static void __unregister_pernet_operations(struct pernet_operations *ops)
85087 struct net *net;
85088 LIST_HEAD(net_exit_list);
85089
85090 - list_del(&ops->list);
85091 + pax_list_del((struct list_head *)&ops->list);
85092 for_each_net(net)
85093 list_add_tail(&net->exit_list, &net_exit_list);
85094 ops_exit_list(ops, &net_exit_list);
85095 @@ -600,7 +600,7 @@ int register_pernet_device(struct pernet_operations *ops)
85096 mutex_lock(&net_mutex);
85097 error = register_pernet_operations(&pernet_list, ops);
85098 if (!error && (first_device == &pernet_list))
85099 - first_device = &ops->list;
85100 + first_device = (struct list_head *)&ops->list;
85101 mutex_unlock(&net_mutex);
85102 return error;
85103 }
85104 diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
85105 index 798f920..e2261f5 100644
85106 --- a/net/core/rtnetlink.c
85107 +++ b/net/core/rtnetlink.c
85108 @@ -58,7 +58,7 @@ struct rtnl_link {
85109 rtnl_doit_func doit;
85110 rtnl_dumpit_func dumpit;
85111 rtnl_calcit_func calcit;
85112 -};
85113 +} __no_const;
85114
85115 static DEFINE_MUTEX(rtnl_mutex);
85116
85117 @@ -299,10 +299,13 @@ int __rtnl_link_register(struct rtnl_link_ops *ops)
85118 if (rtnl_link_ops_get(ops->kind))
85119 return -EEXIST;
85120
85121 - if (!ops->dellink)
85122 - ops->dellink = unregister_netdevice_queue;
85123 + if (!ops->dellink) {
85124 + pax_open_kernel();
85125 + *(void **)&ops->dellink = unregister_netdevice_queue;
85126 + pax_close_kernel();
85127 + }
85128
85129 - list_add_tail(&ops->list, &link_ops);
85130 + pax_list_add_tail((struct list_head *)&ops->list, &link_ops);
85131 return 0;
85132 }
85133 EXPORT_SYMBOL_GPL(__rtnl_link_register);
85134 @@ -349,7 +352,7 @@ void __rtnl_link_unregister(struct rtnl_link_ops *ops)
85135 for_each_net(net) {
85136 __rtnl_kill_links(net, ops);
85137 }
85138 - list_del(&ops->list);
85139 + pax_list_del((struct list_head *)&ops->list);
85140 }
85141 EXPORT_SYMBOL_GPL(__rtnl_link_unregister);
85142
85143 diff --git a/net/core/scm.c b/net/core/scm.c
85144 index 905dcc6..14ee2d6 100644
85145 --- a/net/core/scm.c
85146 +++ b/net/core/scm.c
85147 @@ -224,7 +224,7 @@ EXPORT_SYMBOL(__scm_send);
85148 int put_cmsg(struct msghdr * msg, int level, int type, int len, void *data)
85149 {
85150 struct cmsghdr __user *cm
85151 - = (__force struct cmsghdr __user *)msg->msg_control;
85152 + = (struct cmsghdr __force_user *)msg->msg_control;
85153 struct cmsghdr cmhdr;
85154 int cmlen = CMSG_LEN(len);
85155 int err;
85156 @@ -247,7 +247,7 @@ int put_cmsg(struct msghdr * msg, int level, int type, int len, void *data)
85157 err = -EFAULT;
85158 if (copy_to_user(cm, &cmhdr, sizeof cmhdr))
85159 goto out;
85160 - if (copy_to_user(CMSG_DATA(cm), data, cmlen - sizeof(struct cmsghdr)))
85161 + if (copy_to_user((void __force_user *)CMSG_DATA((void __force_kernel *)cm), data, cmlen - sizeof(struct cmsghdr)))
85162 goto out;
85163 cmlen = CMSG_SPACE(len);
85164 if (msg->msg_controllen < cmlen)
85165 @@ -263,7 +263,7 @@ EXPORT_SYMBOL(put_cmsg);
85166 void scm_detach_fds(struct msghdr *msg, struct scm_cookie *scm)
85167 {
85168 struct cmsghdr __user *cm
85169 - = (__force struct cmsghdr __user*)msg->msg_control;
85170 + = (struct cmsghdr __force_user *)msg->msg_control;
85171
85172 int fdmax = 0;
85173 int fdnum = scm->fp->count;
85174 @@ -283,7 +283,7 @@ void scm_detach_fds(struct msghdr *msg, struct scm_cookie *scm)
85175 if (fdnum < fdmax)
85176 fdmax = fdnum;
85177
85178 - for (i=0, cmfptr=(__force int __user *)CMSG_DATA(cm); i<fdmax;
85179 + for (i=0, cmfptr=(int __force_user *)CMSG_DATA((void __force_kernel *)cm); i<fdmax;
85180 i++, cmfptr++)
85181 {
85182 struct socket *sock;
85183 diff --git a/net/core/sock.c b/net/core/sock.c
85184 index bc131d4..029e378 100644
85185 --- a/net/core/sock.c
85186 +++ b/net/core/sock.c
85187 @@ -388,7 +388,7 @@ int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
85188 struct sk_buff_head *list = &sk->sk_receive_queue;
85189
85190 if (atomic_read(&sk->sk_rmem_alloc) >= sk->sk_rcvbuf) {
85191 - atomic_inc(&sk->sk_drops);
85192 + atomic_inc_unchecked(&sk->sk_drops);
85193 trace_sock_rcvqueue_full(sk, skb);
85194 return -ENOMEM;
85195 }
85196 @@ -398,7 +398,7 @@ int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
85197 return err;
85198
85199 if (!sk_rmem_schedule(sk, skb, skb->truesize)) {
85200 - atomic_inc(&sk->sk_drops);
85201 + atomic_inc_unchecked(&sk->sk_drops);
85202 return -ENOBUFS;
85203 }
85204
85205 @@ -418,7 +418,7 @@ int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
85206 skb_dst_force(skb);
85207
85208 spin_lock_irqsave(&list->lock, flags);
85209 - skb->dropcount = atomic_read(&sk->sk_drops);
85210 + skb->dropcount = atomic_read_unchecked(&sk->sk_drops);
85211 __skb_queue_tail(list, skb);
85212 spin_unlock_irqrestore(&list->lock, flags);
85213
85214 @@ -438,7 +438,7 @@ int sk_receive_skb(struct sock *sk, struct sk_buff *skb, const int nested)
85215 skb->dev = NULL;
85216
85217 if (sk_rcvqueues_full(sk, skb, sk->sk_rcvbuf)) {
85218 - atomic_inc(&sk->sk_drops);
85219 + atomic_inc_unchecked(&sk->sk_drops);
85220 goto discard_and_relse;
85221 }
85222 if (nested)
85223 @@ -456,7 +456,7 @@ int sk_receive_skb(struct sock *sk, struct sk_buff *skb, const int nested)
85224 mutex_release(&sk->sk_lock.dep_map, 1, _RET_IP_);
85225 } else if (sk_add_backlog(sk, skb, sk->sk_rcvbuf)) {
85226 bh_unlock_sock(sk);
85227 - atomic_inc(&sk->sk_drops);
85228 + atomic_inc_unchecked(&sk->sk_drops);
85229 goto discard_and_relse;
85230 }
85231
85232 @@ -930,12 +930,12 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
85233 struct timeval tm;
85234 } v;
85235
85236 - int lv = sizeof(int);
85237 - int len;
85238 + unsigned int lv = sizeof(int);
85239 + unsigned int len;
85240
85241 if (get_user(len, optlen))
85242 return -EFAULT;
85243 - if (len < 0)
85244 + if (len > INT_MAX)
85245 return -EINVAL;
85246
85247 memset(&v, 0, sizeof(v));
85248 @@ -1083,11 +1083,11 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
85249
85250 case SO_PEERNAME:
85251 {
85252 - char address[128];
85253 + char address[_K_SS_MAXSIZE];
85254
85255 if (sock->ops->getname(sock, (struct sockaddr *)address, &lv, 2))
85256 return -ENOTCONN;
85257 - if (lv < len)
85258 + if (lv < len || sizeof address < len)
85259 return -EINVAL;
85260 if (copy_to_user(optval, address, len))
85261 return -EFAULT;
85262 @@ -1146,7 +1146,7 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
85263
85264 if (len > lv)
85265 len = lv;
85266 - if (copy_to_user(optval, &v, len))
85267 + if (len > sizeof(v) || copy_to_user(optval, &v, len))
85268 return -EFAULT;
85269 lenout:
85270 if (put_user(len, optlen))
85271 @@ -2276,7 +2276,7 @@ void sock_init_data(struct socket *sock, struct sock *sk)
85272 */
85273 smp_wmb();
85274 atomic_set(&sk->sk_refcnt, 1);
85275 - atomic_set(&sk->sk_drops, 0);
85276 + atomic_set_unchecked(&sk->sk_drops, 0);
85277 }
85278 EXPORT_SYMBOL(sock_init_data);
85279
85280 diff --git a/net/core/sock_diag.c b/net/core/sock_diag.c
85281 index 750f44f..922399c 100644
85282 --- a/net/core/sock_diag.c
85283 +++ b/net/core/sock_diag.c
85284 @@ -9,26 +9,33 @@
85285 #include <linux/inet_diag.h>
85286 #include <linux/sock_diag.h>
85287
85288 -static const struct sock_diag_handler *sock_diag_handlers[AF_MAX];
85289 +static const struct sock_diag_handler *sock_diag_handlers[AF_MAX] __read_only;
85290 static int (*inet_rcv_compat)(struct sk_buff *skb, struct nlmsghdr *nlh);
85291 static DEFINE_MUTEX(sock_diag_table_mutex);
85292
85293 int sock_diag_check_cookie(void *sk, __u32 *cookie)
85294 {
85295 +#ifndef CONFIG_GRKERNSEC_HIDESYM
85296 if ((cookie[0] != INET_DIAG_NOCOOKIE ||
85297 cookie[1] != INET_DIAG_NOCOOKIE) &&
85298 ((u32)(unsigned long)sk != cookie[0] ||
85299 (u32)((((unsigned long)sk) >> 31) >> 1) != cookie[1]))
85300 return -ESTALE;
85301 else
85302 +#endif
85303 return 0;
85304 }
85305 EXPORT_SYMBOL_GPL(sock_diag_check_cookie);
85306
85307 void sock_diag_save_cookie(void *sk, __u32 *cookie)
85308 {
85309 +#ifdef CONFIG_GRKERNSEC_HIDESYM
85310 + cookie[0] = 0;
85311 + cookie[1] = 0;
85312 +#else
85313 cookie[0] = (u32)(unsigned long)sk;
85314 cookie[1] = (u32)(((unsigned long)sk >> 31) >> 1);
85315 +#endif
85316 }
85317 EXPORT_SYMBOL_GPL(sock_diag_save_cookie);
85318
85319 @@ -75,8 +82,11 @@ int sock_diag_register(const struct sock_diag_handler *hndl)
85320 mutex_lock(&sock_diag_table_mutex);
85321 if (sock_diag_handlers[hndl->family])
85322 err = -EBUSY;
85323 - else
85324 + else {
85325 + pax_open_kernel();
85326 sock_diag_handlers[hndl->family] = hndl;
85327 + pax_close_kernel();
85328 + }
85329 mutex_unlock(&sock_diag_table_mutex);
85330
85331 return err;
85332 @@ -92,26 +102,13 @@ void sock_diag_unregister(const struct sock_diag_handler *hnld)
85333
85334 mutex_lock(&sock_diag_table_mutex);
85335 BUG_ON(sock_diag_handlers[family] != hnld);
85336 + pax_open_kernel();
85337 sock_diag_handlers[family] = NULL;
85338 + pax_close_kernel();
85339 mutex_unlock(&sock_diag_table_mutex);
85340 }
85341 EXPORT_SYMBOL_GPL(sock_diag_unregister);
85342
85343 -static const inline struct sock_diag_handler *sock_diag_lock_handler(int family)
85344 -{
85345 - if (sock_diag_handlers[family] == NULL)
85346 - request_module("net-pf-%d-proto-%d-type-%d", PF_NETLINK,
85347 - NETLINK_SOCK_DIAG, family);
85348 -
85349 - mutex_lock(&sock_diag_table_mutex);
85350 - return sock_diag_handlers[family];
85351 -}
85352 -
85353 -static inline void sock_diag_unlock_handler(const struct sock_diag_handler *h)
85354 -{
85355 - mutex_unlock(&sock_diag_table_mutex);
85356 -}
85357 -
85358 static int __sock_diag_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
85359 {
85360 int err;
85361 @@ -124,12 +121,17 @@ static int __sock_diag_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
85362 if (req->sdiag_family >= AF_MAX)
85363 return -EINVAL;
85364
85365 - hndl = sock_diag_lock_handler(req->sdiag_family);
85366 + if (sock_diag_handlers[req->sdiag_family] == NULL)
85367 + request_module("net-pf-%d-proto-%d-type-%d", PF_NETLINK,
85368 + NETLINK_SOCK_DIAG, req->sdiag_family);
85369 +
85370 + mutex_lock(&sock_diag_table_mutex);
85371 + hndl = sock_diag_handlers[req->sdiag_family];
85372 if (hndl == NULL)
85373 err = -ENOENT;
85374 else
85375 err = hndl->dump(skb, nlh);
85376 - sock_diag_unlock_handler(hndl);
85377 + mutex_unlock(&sock_diag_table_mutex);
85378
85379 return err;
85380 }
85381 diff --git a/net/core/sysctl_net_core.c b/net/core/sysctl_net_core.c
85382 index d1b0804..4aed0a5 100644
85383 --- a/net/core/sysctl_net_core.c
85384 +++ b/net/core/sysctl_net_core.c
85385 @@ -26,7 +26,7 @@ static int rps_sock_flow_sysctl(ctl_table *table, int write,
85386 {
85387 unsigned int orig_size, size;
85388 int ret, i;
85389 - ctl_table tmp = {
85390 + ctl_table_no_const tmp = {
85391 .data = &size,
85392 .maxlen = sizeof(size),
85393 .mode = table->mode
85394 @@ -205,13 +205,12 @@ static struct ctl_table netns_core_table[] = {
85395
85396 static __net_init int sysctl_core_net_init(struct net *net)
85397 {
85398 - struct ctl_table *tbl;
85399 + ctl_table_no_const *tbl = NULL;
85400
85401 net->core.sysctl_somaxconn = SOMAXCONN;
85402
85403 - tbl = netns_core_table;
85404 if (!net_eq(net, &init_net)) {
85405 - tbl = kmemdup(tbl, sizeof(netns_core_table), GFP_KERNEL);
85406 + tbl = kmemdup(netns_core_table, sizeof(netns_core_table), GFP_KERNEL);
85407 if (tbl == NULL)
85408 goto err_dup;
85409
85410 @@ -221,16 +220,16 @@ static __net_init int sysctl_core_net_init(struct net *net)
85411 if (net->user_ns != &init_user_ns) {
85412 tbl[0].procname = NULL;
85413 }
85414 - }
85415 -
85416 - net->core.sysctl_hdr = register_net_sysctl(net, "net/core", tbl);
85417 + net->core.sysctl_hdr = register_net_sysctl(net, "net/core", tbl);
85418 + } else
85419 + net->core.sysctl_hdr = register_net_sysctl(net, "net/core", netns_core_table);
85420 if (net->core.sysctl_hdr == NULL)
85421 goto err_reg;
85422
85423 return 0;
85424
85425 err_reg:
85426 - if (tbl != netns_core_table)
85427 + if (tbl)
85428 kfree(tbl);
85429 err_dup:
85430 return -ENOMEM;
85431 @@ -246,7 +245,7 @@ static __net_exit void sysctl_core_net_exit(struct net *net)
85432 kfree(tbl);
85433 }
85434
85435 -static __net_initdata struct pernet_operations sysctl_core_ops = {
85436 +static __net_initconst struct pernet_operations sysctl_core_ops = {
85437 .init = sysctl_core_net_init,
85438 .exit = sysctl_core_net_exit,
85439 };
85440 diff --git a/net/decnet/af_decnet.c b/net/decnet/af_decnet.c
85441 index 307c322..78a4c6f 100644
85442 --- a/net/decnet/af_decnet.c
85443 +++ b/net/decnet/af_decnet.c
85444 @@ -468,6 +468,7 @@ static struct proto dn_proto = {
85445 .sysctl_rmem = sysctl_decnet_rmem,
85446 .max_header = DN_MAX_NSP_DATA_HEADER + 64,
85447 .obj_size = sizeof(struct dn_sock),
85448 + .slab_flags = SLAB_USERCOPY,
85449 };
85450
85451 static struct sock *dn_alloc_sock(struct net *net, struct socket *sock, gfp_t gfp)
85452 diff --git a/net/decnet/sysctl_net_decnet.c b/net/decnet/sysctl_net_decnet.c
85453 index a55eecc..dd8428c 100644
85454 --- a/net/decnet/sysctl_net_decnet.c
85455 +++ b/net/decnet/sysctl_net_decnet.c
85456 @@ -174,7 +174,7 @@ static int dn_node_address_handler(ctl_table *table, int write,
85457
85458 if (len > *lenp) len = *lenp;
85459
85460 - if (copy_to_user(buffer, addr, len))
85461 + if (len > sizeof addr || copy_to_user(buffer, addr, len))
85462 return -EFAULT;
85463
85464 *lenp = len;
85465 @@ -237,7 +237,7 @@ static int dn_def_dev_handler(ctl_table *table, int write,
85466
85467 if (len > *lenp) len = *lenp;
85468
85469 - if (copy_to_user(buffer, devname, len))
85470 + if (len > sizeof devname || copy_to_user(buffer, devname, len))
85471 return -EFAULT;
85472
85473 *lenp = len;
85474 diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c
85475 index fcf104e..95552d4 100644
85476 --- a/net/ipv4/af_inet.c
85477 +++ b/net/ipv4/af_inet.c
85478 @@ -1717,13 +1717,9 @@ static int __init inet_init(void)
85479
85480 BUILD_BUG_ON(sizeof(struct inet_skb_parm) > sizeof(dummy_skb->cb));
85481
85482 - sysctl_local_reserved_ports = kzalloc(65536 / 8, GFP_KERNEL);
85483 - if (!sysctl_local_reserved_ports)
85484 - goto out;
85485 -
85486 rc = proto_register(&tcp_prot, 1);
85487 if (rc)
85488 - goto out_free_reserved_ports;
85489 + goto out;
85490
85491 rc = proto_register(&udp_prot, 1);
85492 if (rc)
85493 @@ -1832,8 +1828,6 @@ out_unregister_udp_proto:
85494 proto_unregister(&udp_prot);
85495 out_unregister_tcp_proto:
85496 proto_unregister(&tcp_prot);
85497 -out_free_reserved_ports:
85498 - kfree(sysctl_local_reserved_ports);
85499 goto out;
85500 }
85501
85502 diff --git a/net/ipv4/ah4.c b/net/ipv4/ah4.c
85503 index a69b4e4..dbccba5 100644
85504 --- a/net/ipv4/ah4.c
85505 +++ b/net/ipv4/ah4.c
85506 @@ -421,7 +421,7 @@ static void ah4_err(struct sk_buff *skb, u32 info)
85507 return;
85508
85509 if (icmp_hdr(skb)->type == ICMP_DEST_UNREACH) {
85510 - atomic_inc(&flow_cache_genid);
85511 + atomic_inc_unchecked(&flow_cache_genid);
85512 rt_genid_bump(net);
85513
85514 ipv4_update_pmtu(skb, net, info, 0, 0, IPPROTO_AH, 0);
85515 diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c
85516 index a8e4f26..25e5f40 100644
85517 --- a/net/ipv4/devinet.c
85518 +++ b/net/ipv4/devinet.c
85519 @@ -1763,7 +1763,7 @@ static int ipv4_doint_and_flush(ctl_table *ctl, int write,
85520 #define DEVINET_SYSCTL_FLUSHING_ENTRY(attr, name) \
85521 DEVINET_SYSCTL_COMPLEX_ENTRY(attr, name, ipv4_doint_and_flush)
85522
85523 -static struct devinet_sysctl_table {
85524 +static const struct devinet_sysctl_table {
85525 struct ctl_table_header *sysctl_header;
85526 struct ctl_table devinet_vars[__IPV4_DEVCONF_MAX];
85527 } devinet_sysctl = {
85528 @@ -1881,7 +1881,7 @@ static __net_init int devinet_init_net(struct net *net)
85529 int err;
85530 struct ipv4_devconf *all, *dflt;
85531 #ifdef CONFIG_SYSCTL
85532 - struct ctl_table *tbl = ctl_forward_entry;
85533 + ctl_table_no_const *tbl = NULL;
85534 struct ctl_table_header *forw_hdr;
85535 #endif
85536
85537 @@ -1899,7 +1899,7 @@ static __net_init int devinet_init_net(struct net *net)
85538 goto err_alloc_dflt;
85539
85540 #ifdef CONFIG_SYSCTL
85541 - tbl = kmemdup(tbl, sizeof(ctl_forward_entry), GFP_KERNEL);
85542 + tbl = kmemdup(ctl_forward_entry, sizeof(ctl_forward_entry), GFP_KERNEL);
85543 if (tbl == NULL)
85544 goto err_alloc_ctl;
85545
85546 @@ -1919,7 +1919,10 @@ static __net_init int devinet_init_net(struct net *net)
85547 goto err_reg_dflt;
85548
85549 err = -ENOMEM;
85550 - forw_hdr = register_net_sysctl(net, "net/ipv4", tbl);
85551 + if (!net_eq(net, &init_net))
85552 + forw_hdr = register_net_sysctl(net, "net/ipv4", tbl);
85553 + else
85554 + forw_hdr = register_net_sysctl(net, "net/ipv4", ctl_forward_entry);
85555 if (forw_hdr == NULL)
85556 goto err_reg_ctl;
85557 net->ipv4.forw_hdr = forw_hdr;
85558 @@ -1935,8 +1938,7 @@ err_reg_ctl:
85559 err_reg_dflt:
85560 __devinet_sysctl_unregister(all);
85561 err_reg_all:
85562 - if (tbl != ctl_forward_entry)
85563 - kfree(tbl);
85564 + kfree(tbl);
85565 err_alloc_ctl:
85566 #endif
85567 if (dflt != &ipv4_devconf_dflt)
85568 diff --git a/net/ipv4/esp4.c b/net/ipv4/esp4.c
85569 index 3b4f0cd..8cb864c 100644
85570 --- a/net/ipv4/esp4.c
85571 +++ b/net/ipv4/esp4.c
85572 @@ -503,7 +503,7 @@ static void esp4_err(struct sk_buff *skb, u32 info)
85573 return;
85574
85575 if (icmp_hdr(skb)->type == ICMP_DEST_UNREACH) {
85576 - atomic_inc(&flow_cache_genid);
85577 + atomic_inc_unchecked(&flow_cache_genid);
85578 rt_genid_bump(net);
85579
85580 ipv4_update_pmtu(skb, net, info, 0, 0, IPPROTO_ESP, 0);
85581 diff --git a/net/ipv4/fib_frontend.c b/net/ipv4/fib_frontend.c
85582 index 5cd75e2..f57ef39 100644
85583 --- a/net/ipv4/fib_frontend.c
85584 +++ b/net/ipv4/fib_frontend.c
85585 @@ -1020,12 +1020,12 @@ static int fib_inetaddr_event(struct notifier_block *this, unsigned long event,
85586 #ifdef CONFIG_IP_ROUTE_MULTIPATH
85587 fib_sync_up(dev);
85588 #endif
85589 - atomic_inc(&net->ipv4.dev_addr_genid);
85590 + atomic_inc_unchecked(&net->ipv4.dev_addr_genid);
85591 rt_cache_flush(dev_net(dev));
85592 break;
85593 case NETDEV_DOWN:
85594 fib_del_ifaddr(ifa, NULL);
85595 - atomic_inc(&net->ipv4.dev_addr_genid);
85596 + atomic_inc_unchecked(&net->ipv4.dev_addr_genid);
85597 if (ifa->ifa_dev->ifa_list == NULL) {
85598 /* Last address was deleted from this interface.
85599 * Disable IP.
85600 @@ -1061,7 +1061,7 @@ static int fib_netdev_event(struct notifier_block *this, unsigned long event, vo
85601 #ifdef CONFIG_IP_ROUTE_MULTIPATH
85602 fib_sync_up(dev);
85603 #endif
85604 - atomic_inc(&net->ipv4.dev_addr_genid);
85605 + atomic_inc_unchecked(&net->ipv4.dev_addr_genid);
85606 rt_cache_flush(net);
85607 break;
85608 case NETDEV_DOWN:
85609 diff --git a/net/ipv4/fib_semantics.c b/net/ipv4/fib_semantics.c
85610 index 4797a80..2bd54e9 100644
85611 --- a/net/ipv4/fib_semantics.c
85612 +++ b/net/ipv4/fib_semantics.c
85613 @@ -767,7 +767,7 @@ __be32 fib_info_update_nh_saddr(struct net *net, struct fib_nh *nh)
85614 nh->nh_saddr = inet_select_addr(nh->nh_dev,
85615 nh->nh_gw,
85616 nh->nh_parent->fib_scope);
85617 - nh->nh_saddr_genid = atomic_read(&net->ipv4.dev_addr_genid);
85618 + nh->nh_saddr_genid = atomic_read_unchecked(&net->ipv4.dev_addr_genid);
85619
85620 return nh->nh_saddr;
85621 }
85622 diff --git a/net/ipv4/inet_connection_sock.c b/net/ipv4/inet_connection_sock.c
85623 index d0670f0..744ac80 100644
85624 --- a/net/ipv4/inet_connection_sock.c
85625 +++ b/net/ipv4/inet_connection_sock.c
85626 @@ -37,7 +37,7 @@ struct local_ports sysctl_local_ports __read_mostly = {
85627 .range = { 32768, 61000 },
85628 };
85629
85630 -unsigned long *sysctl_local_reserved_ports;
85631 +unsigned long sysctl_local_reserved_ports[65536 / 8 / sizeof(unsigned long)];
85632 EXPORT_SYMBOL(sysctl_local_reserved_ports);
85633
85634 void inet_get_local_port_range(int *low, int *high)
85635 diff --git a/net/ipv4/inet_hashtables.c b/net/ipv4/inet_hashtables.c
85636 index fa3ae81..0dbe6b8 100644
85637 --- a/net/ipv4/inet_hashtables.c
85638 +++ b/net/ipv4/inet_hashtables.c
85639 @@ -18,12 +18,15 @@
85640 #include <linux/sched.h>
85641 #include <linux/slab.h>
85642 #include <linux/wait.h>
85643 +#include <linux/security.h>
85644
85645 #include <net/inet_connection_sock.h>
85646 #include <net/inet_hashtables.h>
85647 #include <net/secure_seq.h>
85648 #include <net/ip.h>
85649
85650 +extern void gr_update_task_in_ip_table(struct task_struct *task, const struct inet_sock *inet);
85651 +
85652 /*
85653 * Allocate and initialize a new local port bind bucket.
85654 * The bindhash mutex for snum's hash chain must be held here.
85655 @@ -540,6 +543,8 @@ ok:
85656 twrefcnt += inet_twsk_bind_unhash(tw, hinfo);
85657 spin_unlock(&head->lock);
85658
85659 + gr_update_task_in_ip_table(current, inet_sk(sk));
85660 +
85661 if (tw) {
85662 inet_twsk_deschedule(tw, death_row);
85663 while (twrefcnt) {
85664 diff --git a/net/ipv4/inetpeer.c b/net/ipv4/inetpeer.c
85665 index 000e3d2..5472da3 100644
85666 --- a/net/ipv4/inetpeer.c
85667 +++ b/net/ipv4/inetpeer.c
85668 @@ -503,8 +503,8 @@ relookup:
85669 if (p) {
85670 p->daddr = *daddr;
85671 atomic_set(&p->refcnt, 1);
85672 - atomic_set(&p->rid, 0);
85673 - atomic_set(&p->ip_id_count,
85674 + atomic_set_unchecked(&p->rid, 0);
85675 + atomic_set_unchecked(&p->ip_id_count,
85676 (daddr->family == AF_INET) ?
85677 secure_ip_id(daddr->addr.a4) :
85678 secure_ipv6_id(daddr->addr.a6));
85679 diff --git a/net/ipv4/ip_fragment.c b/net/ipv4/ip_fragment.c
85680 index eb9d63a..31c5372 100644
85681 --- a/net/ipv4/ip_fragment.c
85682 +++ b/net/ipv4/ip_fragment.c
85683 @@ -322,7 +322,7 @@ static inline int ip_frag_too_far(struct ipq *qp)
85684 return 0;
85685
85686 start = qp->rid;
85687 - end = atomic_inc_return(&peer->rid);
85688 + end = atomic_inc_return_unchecked(&peer->rid);
85689 qp->rid = end;
85690
85691 rc = qp->q.fragments && (end - start) > max;
85692 @@ -789,12 +789,11 @@ static struct ctl_table ip4_frags_ctl_table[] = {
85693
85694 static int __net_init ip4_frags_ns_ctl_register(struct net *net)
85695 {
85696 - struct ctl_table *table;
85697 + ctl_table_no_const *table = NULL;
85698 struct ctl_table_header *hdr;
85699
85700 - table = ip4_frags_ns_ctl_table;
85701 if (!net_eq(net, &init_net)) {
85702 - table = kmemdup(table, sizeof(ip4_frags_ns_ctl_table), GFP_KERNEL);
85703 + table = kmemdup(ip4_frags_ns_ctl_table, sizeof(ip4_frags_ns_ctl_table), GFP_KERNEL);
85704 if (table == NULL)
85705 goto err_alloc;
85706
85707 @@ -805,9 +804,10 @@ static int __net_init ip4_frags_ns_ctl_register(struct net *net)
85708 /* Don't export sysctls to unprivileged users */
85709 if (net->user_ns != &init_user_ns)
85710 table[0].procname = NULL;
85711 - }
85712 + hdr = register_net_sysctl(net, "net/ipv4", table);
85713 + } else
85714 + hdr = register_net_sysctl(net, "net/ipv4", ip4_frags_ns_ctl_table);
85715
85716 - hdr = register_net_sysctl(net, "net/ipv4", table);
85717 if (hdr == NULL)
85718 goto err_reg;
85719
85720 @@ -815,8 +815,7 @@ static int __net_init ip4_frags_ns_ctl_register(struct net *net)
85721 return 0;
85722
85723 err_reg:
85724 - if (!net_eq(net, &init_net))
85725 - kfree(table);
85726 + kfree(table);
85727 err_alloc:
85728 return -ENOMEM;
85729 }
85730 diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c
85731 index e81b1ca..6f3b5b9 100644
85732 --- a/net/ipv4/ip_gre.c
85733 +++ b/net/ipv4/ip_gre.c
85734 @@ -124,7 +124,7 @@ static bool log_ecn_error = true;
85735 module_param(log_ecn_error, bool, 0644);
85736 MODULE_PARM_DESC(log_ecn_error, "Log packets received with corrupted ECN");
85737
85738 -static struct rtnl_link_ops ipgre_link_ops __read_mostly;
85739 +static struct rtnl_link_ops ipgre_link_ops;
85740 static int ipgre_tunnel_init(struct net_device *dev);
85741 static void ipgre_tunnel_setup(struct net_device *dev);
85742 static int ipgre_tunnel_bind_dev(struct net_device *dev);
85743 @@ -1756,7 +1756,7 @@ static const struct nla_policy ipgre_policy[IFLA_GRE_MAX + 1] = {
85744 [IFLA_GRE_PMTUDISC] = { .type = NLA_U8 },
85745 };
85746
85747 -static struct rtnl_link_ops ipgre_link_ops __read_mostly = {
85748 +static struct rtnl_link_ops ipgre_link_ops = {
85749 .kind = "gre",
85750 .maxtype = IFLA_GRE_MAX,
85751 .policy = ipgre_policy,
85752 @@ -1769,7 +1769,7 @@ static struct rtnl_link_ops ipgre_link_ops __read_mostly = {
85753 .fill_info = ipgre_fill_info,
85754 };
85755
85756 -static struct rtnl_link_ops ipgre_tap_ops __read_mostly = {
85757 +static struct rtnl_link_ops ipgre_tap_ops = {
85758 .kind = "gretap",
85759 .maxtype = IFLA_GRE_MAX,
85760 .policy = ipgre_policy,
85761 diff --git a/net/ipv4/ip_sockglue.c b/net/ipv4/ip_sockglue.c
85762 index d9c4f11..02b82db 100644
85763 --- a/net/ipv4/ip_sockglue.c
85764 +++ b/net/ipv4/ip_sockglue.c
85765 @@ -1152,7 +1152,8 @@ static int do_ip_getsockopt(struct sock *sk, int level, int optname,
85766 len = min_t(unsigned int, len, opt->optlen);
85767 if (put_user(len, optlen))
85768 return -EFAULT;
85769 - if (copy_to_user(optval, opt->__data, len))
85770 + if ((len > (sizeof(optbuf) - sizeof(struct ip_options))) ||
85771 + copy_to_user(optval, opt->__data, len))
85772 return -EFAULT;
85773 return 0;
85774 }
85775 @@ -1283,7 +1284,7 @@ static int do_ip_getsockopt(struct sock *sk, int level, int optname,
85776 if (sk->sk_type != SOCK_STREAM)
85777 return -ENOPROTOOPT;
85778
85779 - msg.msg_control = optval;
85780 + msg.msg_control = (void __force_kernel *)optval;
85781 msg.msg_controllen = len;
85782 msg.msg_flags = flags;
85783
85784 diff --git a/net/ipv4/ip_vti.c b/net/ipv4/ip_vti.c
85785 index c3a4233..1412161 100644
85786 --- a/net/ipv4/ip_vti.c
85787 +++ b/net/ipv4/ip_vti.c
85788 @@ -47,7 +47,7 @@
85789 #define HASH_SIZE 16
85790 #define HASH(addr) (((__force u32)addr^((__force u32)addr>>4))&(HASH_SIZE-1))
85791
85792 -static struct rtnl_link_ops vti_link_ops __read_mostly;
85793 +static struct rtnl_link_ops vti_link_ops;
85794
85795 static int vti_net_id __read_mostly;
85796 struct vti_net {
85797 @@ -886,7 +886,7 @@ static const struct nla_policy vti_policy[IFLA_VTI_MAX + 1] = {
85798 [IFLA_VTI_REMOTE] = { .len = FIELD_SIZEOF(struct iphdr, daddr) },
85799 };
85800
85801 -static struct rtnl_link_ops vti_link_ops __read_mostly = {
85802 +static struct rtnl_link_ops vti_link_ops = {
85803 .kind = "vti",
85804 .maxtype = IFLA_VTI_MAX,
85805 .policy = vti_policy,
85806 diff --git a/net/ipv4/ipcomp.c b/net/ipv4/ipcomp.c
85807 index 9a46dae..5f793a0 100644
85808 --- a/net/ipv4/ipcomp.c
85809 +++ b/net/ipv4/ipcomp.c
85810 @@ -48,7 +48,7 @@ static void ipcomp4_err(struct sk_buff *skb, u32 info)
85811 return;
85812
85813 if (icmp_hdr(skb)->type == ICMP_DEST_UNREACH) {
85814 - atomic_inc(&flow_cache_genid);
85815 + atomic_inc_unchecked(&flow_cache_genid);
85816 rt_genid_bump(net);
85817
85818 ipv4_update_pmtu(skb, net, info, 0, 0, IPPROTO_COMP, 0);
85819 diff --git a/net/ipv4/ipconfig.c b/net/ipv4/ipconfig.c
85820 index a2e50ae..e152b7c 100644
85821 --- a/net/ipv4/ipconfig.c
85822 +++ b/net/ipv4/ipconfig.c
85823 @@ -323,7 +323,7 @@ static int __init ic_devinet_ioctl(unsigned int cmd, struct ifreq *arg)
85824
85825 mm_segment_t oldfs = get_fs();
85826 set_fs(get_ds());
85827 - res = devinet_ioctl(&init_net, cmd, (struct ifreq __user *) arg);
85828 + res = devinet_ioctl(&init_net, cmd, (struct ifreq __force_user *) arg);
85829 set_fs(oldfs);
85830 return res;
85831 }
85832 @@ -334,7 +334,7 @@ static int __init ic_dev_ioctl(unsigned int cmd, struct ifreq *arg)
85833
85834 mm_segment_t oldfs = get_fs();
85835 set_fs(get_ds());
85836 - res = dev_ioctl(&init_net, cmd, (struct ifreq __user *) arg);
85837 + res = dev_ioctl(&init_net, cmd, (struct ifreq __force_user *) arg);
85838 set_fs(oldfs);
85839 return res;
85840 }
85841 @@ -345,7 +345,7 @@ static int __init ic_route_ioctl(unsigned int cmd, struct rtentry *arg)
85842
85843 mm_segment_t oldfs = get_fs();
85844 set_fs(get_ds());
85845 - res = ip_rt_ioctl(&init_net, cmd, (void __user *) arg);
85846 + res = ip_rt_ioctl(&init_net, cmd, (void __force_user *) arg);
85847 set_fs(oldfs);
85848 return res;
85849 }
85850 diff --git a/net/ipv4/ipip.c b/net/ipv4/ipip.c
85851 index 191fc24..1b3b804 100644
85852 --- a/net/ipv4/ipip.c
85853 +++ b/net/ipv4/ipip.c
85854 @@ -138,7 +138,7 @@ struct ipip_net {
85855 static int ipip_tunnel_init(struct net_device *dev);
85856 static void ipip_tunnel_setup(struct net_device *dev);
85857 static void ipip_dev_free(struct net_device *dev);
85858 -static struct rtnl_link_ops ipip_link_ops __read_mostly;
85859 +static struct rtnl_link_ops ipip_link_ops;
85860
85861 static struct rtnl_link_stats64 *ipip_get_stats64(struct net_device *dev,
85862 struct rtnl_link_stats64 *tot)
85863 @@ -972,7 +972,7 @@ static const struct nla_policy ipip_policy[IFLA_IPTUN_MAX + 1] = {
85864 [IFLA_IPTUN_PMTUDISC] = { .type = NLA_U8 },
85865 };
85866
85867 -static struct rtnl_link_ops ipip_link_ops __read_mostly = {
85868 +static struct rtnl_link_ops ipip_link_ops = {
85869 .kind = "ipip",
85870 .maxtype = IFLA_IPTUN_MAX,
85871 .policy = ipip_policy,
85872 diff --git a/net/ipv4/netfilter/arp_tables.c b/net/ipv4/netfilter/arp_tables.c
85873 index 3ea4127..849297b 100644
85874 --- a/net/ipv4/netfilter/arp_tables.c
85875 +++ b/net/ipv4/netfilter/arp_tables.c
85876 @@ -879,14 +879,14 @@ static int compat_table_info(const struct xt_table_info *info,
85877 #endif
85878
85879 static int get_info(struct net *net, void __user *user,
85880 - const int *len, int compat)
85881 + int len, int compat)
85882 {
85883 char name[XT_TABLE_MAXNAMELEN];
85884 struct xt_table *t;
85885 int ret;
85886
85887 - if (*len != sizeof(struct arpt_getinfo)) {
85888 - duprintf("length %u != %Zu\n", *len,
85889 + if (len != sizeof(struct arpt_getinfo)) {
85890 + duprintf("length %u != %Zu\n", len,
85891 sizeof(struct arpt_getinfo));
85892 return -EINVAL;
85893 }
85894 @@ -923,7 +923,7 @@ static int get_info(struct net *net, void __user *user,
85895 info.size = private->size;
85896 strcpy(info.name, name);
85897
85898 - if (copy_to_user(user, &info, *len) != 0)
85899 + if (copy_to_user(user, &info, len) != 0)
85900 ret = -EFAULT;
85901 else
85902 ret = 0;
85903 @@ -1682,7 +1682,7 @@ static int compat_do_arpt_get_ctl(struct sock *sk, int cmd, void __user *user,
85904
85905 switch (cmd) {
85906 case ARPT_SO_GET_INFO:
85907 - ret = get_info(sock_net(sk), user, len, 1);
85908 + ret = get_info(sock_net(sk), user, *len, 1);
85909 break;
85910 case ARPT_SO_GET_ENTRIES:
85911 ret = compat_get_entries(sock_net(sk), user, len);
85912 @@ -1727,7 +1727,7 @@ static int do_arpt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len
85913
85914 switch (cmd) {
85915 case ARPT_SO_GET_INFO:
85916 - ret = get_info(sock_net(sk), user, len, 0);
85917 + ret = get_info(sock_net(sk), user, *len, 0);
85918 break;
85919
85920 case ARPT_SO_GET_ENTRIES:
85921 diff --git a/net/ipv4/netfilter/ip_tables.c b/net/ipv4/netfilter/ip_tables.c
85922 index 17c5e06..1b91206 100644
85923 --- a/net/ipv4/netfilter/ip_tables.c
85924 +++ b/net/ipv4/netfilter/ip_tables.c
85925 @@ -1068,14 +1068,14 @@ static int compat_table_info(const struct xt_table_info *info,
85926 #endif
85927
85928 static int get_info(struct net *net, void __user *user,
85929 - const int *len, int compat)
85930 + int len, int compat)
85931 {
85932 char name[XT_TABLE_MAXNAMELEN];
85933 struct xt_table *t;
85934 int ret;
85935
85936 - if (*len != sizeof(struct ipt_getinfo)) {
85937 - duprintf("length %u != %zu\n", *len,
85938 + if (len != sizeof(struct ipt_getinfo)) {
85939 + duprintf("length %u != %zu\n", len,
85940 sizeof(struct ipt_getinfo));
85941 return -EINVAL;
85942 }
85943 @@ -1112,7 +1112,7 @@ static int get_info(struct net *net, void __user *user,
85944 info.size = private->size;
85945 strcpy(info.name, name);
85946
85947 - if (copy_to_user(user, &info, *len) != 0)
85948 + if (copy_to_user(user, &info, len) != 0)
85949 ret = -EFAULT;
85950 else
85951 ret = 0;
85952 @@ -1966,7 +1966,7 @@ compat_do_ipt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
85953
85954 switch (cmd) {
85955 case IPT_SO_GET_INFO:
85956 - ret = get_info(sock_net(sk), user, len, 1);
85957 + ret = get_info(sock_net(sk), user, *len, 1);
85958 break;
85959 case IPT_SO_GET_ENTRIES:
85960 ret = compat_get_entries(sock_net(sk), user, len);
85961 @@ -2013,7 +2013,7 @@ do_ipt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
85962
85963 switch (cmd) {
85964 case IPT_SO_GET_INFO:
85965 - ret = get_info(sock_net(sk), user, len, 0);
85966 + ret = get_info(sock_net(sk), user, *len, 0);
85967 break;
85968
85969 case IPT_SO_GET_ENTRIES:
85970 diff --git a/net/ipv4/ping.c b/net/ipv4/ping.c
85971 index dc454cc..5bb917f 100644
85972 --- a/net/ipv4/ping.c
85973 +++ b/net/ipv4/ping.c
85974 @@ -844,7 +844,7 @@ static void ping_format_sock(struct sock *sp, struct seq_file *f,
85975 from_kuid_munged(seq_user_ns(f), sock_i_uid(sp)),
85976 0, sock_i_ino(sp),
85977 atomic_read(&sp->sk_refcnt), sp,
85978 - atomic_read(&sp->sk_drops), len);
85979 + atomic_read_unchecked(&sp->sk_drops), len);
85980 }
85981
85982 static int ping_seq_show(struct seq_file *seq, void *v)
85983 diff --git a/net/ipv4/raw.c b/net/ipv4/raw.c
85984 index 6f08991..55867ad 100644
85985 --- a/net/ipv4/raw.c
85986 +++ b/net/ipv4/raw.c
85987 @@ -311,7 +311,7 @@ static int raw_rcv_skb(struct sock *sk, struct sk_buff *skb)
85988 int raw_rcv(struct sock *sk, struct sk_buff *skb)
85989 {
85990 if (!xfrm4_policy_check(sk, XFRM_POLICY_IN, skb)) {
85991 - atomic_inc(&sk->sk_drops);
85992 + atomic_inc_unchecked(&sk->sk_drops);
85993 kfree_skb(skb);
85994 return NET_RX_DROP;
85995 }
85996 @@ -747,16 +747,20 @@ static int raw_init(struct sock *sk)
85997
85998 static int raw_seticmpfilter(struct sock *sk, char __user *optval, int optlen)
85999 {
86000 + struct icmp_filter filter;
86001 +
86002 if (optlen > sizeof(struct icmp_filter))
86003 optlen = sizeof(struct icmp_filter);
86004 - if (copy_from_user(&raw_sk(sk)->filter, optval, optlen))
86005 + if (copy_from_user(&filter, optval, optlen))
86006 return -EFAULT;
86007 + raw_sk(sk)->filter = filter;
86008 return 0;
86009 }
86010
86011 static int raw_geticmpfilter(struct sock *sk, char __user *optval, int __user *optlen)
86012 {
86013 int len, ret = -EFAULT;
86014 + struct icmp_filter filter;
86015
86016 if (get_user(len, optlen))
86017 goto out;
86018 @@ -766,8 +770,8 @@ static int raw_geticmpfilter(struct sock *sk, char __user *optval, int __user *o
86019 if (len > sizeof(struct icmp_filter))
86020 len = sizeof(struct icmp_filter);
86021 ret = -EFAULT;
86022 - if (put_user(len, optlen) ||
86023 - copy_to_user(optval, &raw_sk(sk)->filter, len))
86024 + filter = raw_sk(sk)->filter;
86025 + if (put_user(len, optlen) || len > sizeof filter || copy_to_user(optval, &filter, len))
86026 goto out;
86027 ret = 0;
86028 out: return ret;
86029 @@ -998,7 +1002,7 @@ static void raw_sock_seq_show(struct seq_file *seq, struct sock *sp, int i)
86030 0, 0L, 0,
86031 from_kuid_munged(seq_user_ns(seq), sock_i_uid(sp)),
86032 0, sock_i_ino(sp),
86033 - atomic_read(&sp->sk_refcnt), sp, atomic_read(&sp->sk_drops));
86034 + atomic_read(&sp->sk_refcnt), sp, atomic_read_unchecked(&sp->sk_drops));
86035 }
86036
86037 static int raw_seq_show(struct seq_file *seq, void *v)
86038 diff --git a/net/ipv4/route.c b/net/ipv4/route.c
86039 index a0fcc47..32e2c89 100644
86040 --- a/net/ipv4/route.c
86041 +++ b/net/ipv4/route.c
86042 @@ -2552,34 +2552,34 @@ static struct ctl_table ipv4_route_flush_table[] = {
86043 .maxlen = sizeof(int),
86044 .mode = 0200,
86045 .proc_handler = ipv4_sysctl_rtcache_flush,
86046 + .extra1 = &init_net,
86047 },
86048 { },
86049 };
86050
86051 static __net_init int sysctl_route_net_init(struct net *net)
86052 {
86053 - struct ctl_table *tbl;
86054 + ctl_table_no_const *tbl = NULL;
86055
86056 - tbl = ipv4_route_flush_table;
86057 if (!net_eq(net, &init_net)) {
86058 - tbl = kmemdup(tbl, sizeof(ipv4_route_flush_table), GFP_KERNEL);
86059 + tbl = kmemdup(ipv4_route_flush_table, sizeof(ipv4_route_flush_table), GFP_KERNEL);
86060 if (tbl == NULL)
86061 goto err_dup;
86062
86063 /* Don't export sysctls to unprivileged users */
86064 if (net->user_ns != &init_user_ns)
86065 tbl[0].procname = NULL;
86066 - }
86067 - tbl[0].extra1 = net;
86068 + tbl[0].extra1 = net;
86069 + net->ipv4.route_hdr = register_net_sysctl(net, "net/ipv4/route", tbl);
86070 + } else
86071 + net->ipv4.route_hdr = register_net_sysctl(net, "net/ipv4/route", ipv4_route_flush_table);
86072
86073 - net->ipv4.route_hdr = register_net_sysctl(net, "net/ipv4/route", tbl);
86074 if (net->ipv4.route_hdr == NULL)
86075 goto err_reg;
86076 return 0;
86077
86078 err_reg:
86079 - if (tbl != ipv4_route_flush_table)
86080 - kfree(tbl);
86081 + kfree(tbl);
86082 err_dup:
86083 return -ENOMEM;
86084 }
86085 @@ -2602,7 +2602,7 @@ static __net_initdata struct pernet_operations sysctl_route_ops = {
86086
86087 static __net_init int rt_genid_init(struct net *net)
86088 {
86089 - atomic_set(&net->rt_genid, 0);
86090 + atomic_set_unchecked(&net->rt_genid, 0);
86091 get_random_bytes(&net->ipv4.dev_addr_genid,
86092 sizeof(net->ipv4.dev_addr_genid));
86093 return 0;
86094 diff --git a/net/ipv4/sysctl_net_ipv4.c b/net/ipv4/sysctl_net_ipv4.c
86095 index d84400b..62e066e 100644
86096 --- a/net/ipv4/sysctl_net_ipv4.c
86097 +++ b/net/ipv4/sysctl_net_ipv4.c
86098 @@ -54,7 +54,7 @@ static int ipv4_local_port_range(ctl_table *table, int write,
86099 {
86100 int ret;
86101 int range[2];
86102 - ctl_table tmp = {
86103 + ctl_table_no_const tmp = {
86104 .data = &range,
86105 .maxlen = sizeof(range),
86106 .mode = table->mode,
86107 @@ -107,7 +107,7 @@ static int ipv4_ping_group_range(ctl_table *table, int write,
86108 int ret;
86109 gid_t urange[2];
86110 kgid_t low, high;
86111 - ctl_table tmp = {
86112 + ctl_table_no_const tmp = {
86113 .data = &urange,
86114 .maxlen = sizeof(urange),
86115 .mode = table->mode,
86116 @@ -138,7 +138,7 @@ static int proc_tcp_congestion_control(ctl_table *ctl, int write,
86117 void __user *buffer, size_t *lenp, loff_t *ppos)
86118 {
86119 char val[TCP_CA_NAME_MAX];
86120 - ctl_table tbl = {
86121 + ctl_table_no_const tbl = {
86122 .data = val,
86123 .maxlen = TCP_CA_NAME_MAX,
86124 };
86125 @@ -157,7 +157,7 @@ static int proc_tcp_available_congestion_control(ctl_table *ctl,
86126 void __user *buffer, size_t *lenp,
86127 loff_t *ppos)
86128 {
86129 - ctl_table tbl = { .maxlen = TCP_CA_BUF_MAX, };
86130 + ctl_table_no_const tbl = { .maxlen = TCP_CA_BUF_MAX, };
86131 int ret;
86132
86133 tbl.data = kmalloc(tbl.maxlen, GFP_USER);
86134 @@ -174,7 +174,7 @@ static int proc_allowed_congestion_control(ctl_table *ctl,
86135 void __user *buffer, size_t *lenp,
86136 loff_t *ppos)
86137 {
86138 - ctl_table tbl = { .maxlen = TCP_CA_BUF_MAX };
86139 + ctl_table_no_const tbl = { .maxlen = TCP_CA_BUF_MAX };
86140 int ret;
86141
86142 tbl.data = kmalloc(tbl.maxlen, GFP_USER);
86143 @@ -200,15 +200,17 @@ static int ipv4_tcp_mem(ctl_table *ctl, int write,
86144 struct mem_cgroup *memcg;
86145 #endif
86146
86147 - ctl_table tmp = {
86148 + ctl_table_no_const tmp = {
86149 .data = &vec,
86150 .maxlen = sizeof(vec),
86151 .mode = ctl->mode,
86152 };
86153
86154 if (!write) {
86155 - ctl->data = &net->ipv4.sysctl_tcp_mem;
86156 - return proc_doulongvec_minmax(ctl, write, buffer, lenp, ppos);
86157 + ctl_table_no_const tcp_mem = *ctl;
86158 +
86159 + tcp_mem.data = &net->ipv4.sysctl_tcp_mem;
86160 + return proc_doulongvec_minmax(&tcp_mem, write, buffer, lenp, ppos);
86161 }
86162
86163 ret = proc_doulongvec_minmax(&tmp, write, buffer, lenp, ppos);
86164 @@ -235,7 +237,7 @@ static int ipv4_tcp_mem(ctl_table *ctl, int write,
86165 int proc_tcp_fastopen_key(ctl_table *ctl, int write, void __user *buffer,
86166 size_t *lenp, loff_t *ppos)
86167 {
86168 - ctl_table tbl = { .maxlen = (TCP_FASTOPEN_KEY_LENGTH * 2 + 10) };
86169 + ctl_table_no_const tbl = { .maxlen = (TCP_FASTOPEN_KEY_LENGTH * 2 + 10) };
86170 struct tcp_fastopen_context *ctxt;
86171 int ret;
86172 u32 user_key[4]; /* 16 bytes, matching TCP_FASTOPEN_KEY_LENGTH */
86173 @@ -476,7 +478,7 @@ static struct ctl_table ipv4_table[] = {
86174 },
86175 {
86176 .procname = "ip_local_reserved_ports",
86177 - .data = NULL, /* initialized in sysctl_ipv4_init */
86178 + .data = sysctl_local_reserved_ports,
86179 .maxlen = 65536,
86180 .mode = 0644,
86181 .proc_handler = proc_do_large_bitmap,
86182 @@ -860,11 +862,10 @@ static struct ctl_table ipv4_net_table[] = {
86183
86184 static __net_init int ipv4_sysctl_init_net(struct net *net)
86185 {
86186 - struct ctl_table *table;
86187 + ctl_table_no_const *table = NULL;
86188
86189 - table = ipv4_net_table;
86190 if (!net_eq(net, &init_net)) {
86191 - table = kmemdup(table, sizeof(ipv4_net_table), GFP_KERNEL);
86192 + table = kmemdup(ipv4_net_table, sizeof(ipv4_net_table), GFP_KERNEL);
86193 if (table == NULL)
86194 goto err_alloc;
86195
86196 @@ -897,15 +898,17 @@ static __net_init int ipv4_sysctl_init_net(struct net *net)
86197
86198 tcp_init_mem(net);
86199
86200 - net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", table);
86201 + if (!net_eq(net, &init_net))
86202 + net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", table);
86203 + else
86204 + net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", ipv4_net_table);
86205 if (net->ipv4.ipv4_hdr == NULL)
86206 goto err_reg;
86207
86208 return 0;
86209
86210 err_reg:
86211 - if (!net_eq(net, &init_net))
86212 - kfree(table);
86213 + kfree(table);
86214 err_alloc:
86215 return -ENOMEM;
86216 }
86217 @@ -927,16 +930,6 @@ static __net_initdata struct pernet_operations ipv4_sysctl_ops = {
86218 static __init int sysctl_ipv4_init(void)
86219 {
86220 struct ctl_table_header *hdr;
86221 - struct ctl_table *i;
86222 -
86223 - for (i = ipv4_table; i->procname; i++) {
86224 - if (strcmp(i->procname, "ip_local_reserved_ports") == 0) {
86225 - i->data = sysctl_local_reserved_ports;
86226 - break;
86227 - }
86228 - }
86229 - if (!i->procname)
86230 - return -EINVAL;
86231
86232 hdr = register_net_sysctl(&init_net, "net/ipv4", ipv4_table);
86233 if (hdr == NULL)
86234 diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
86235 index 66702d3..31ff8f9 100644
86236 --- a/net/ipv4/tcp_input.c
86237 +++ b/net/ipv4/tcp_input.c
86238 @@ -4733,7 +4733,7 @@ static struct sk_buff *tcp_collapse_one(struct sock *sk, struct sk_buff *skb,
86239 * simplifies code)
86240 */
86241 static void
86242 -tcp_collapse(struct sock *sk, struct sk_buff_head *list,
86243 +__intentional_overflow(5,6) tcp_collapse(struct sock *sk, struct sk_buff_head *list,
86244 struct sk_buff *head, struct sk_buff *tail,
86245 u32 start, u32 end)
86246 {
86247 @@ -5850,6 +5850,7 @@ discard:
86248 tcp_paws_reject(&tp->rx_opt, 0))
86249 goto discard_and_undo;
86250
86251 +#ifndef CONFIG_GRKERNSEC_NO_SIMULT_CONNECT
86252 if (th->syn) {
86253 /* We see SYN without ACK. It is attempt of
86254 * simultaneous connect with crossed SYNs.
86255 @@ -5900,6 +5901,7 @@ discard:
86256 goto discard;
86257 #endif
86258 }
86259 +#endif
86260 /* "fifth, if neither of the SYN or RST bits is set then
86261 * drop the segment and return."
86262 */
86263 @@ -5944,7 +5946,7 @@ int tcp_rcv_state_process(struct sock *sk, struct sk_buff *skb,
86264 goto discard;
86265
86266 if (th->syn) {
86267 - if (th->fin)
86268 + if (th->fin || th->urg || th->psh)
86269 goto discard;
86270 if (icsk->icsk_af_ops->conn_request(sk, skb) < 0)
86271 return 1;
86272 diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
86273 index eadb693..e8f7251 100644
86274 --- a/net/ipv4/tcp_ipv4.c
86275 +++ b/net/ipv4/tcp_ipv4.c
86276 @@ -90,6 +90,10 @@ int sysctl_tcp_low_latency __read_mostly;
86277 EXPORT_SYMBOL(sysctl_tcp_low_latency);
86278
86279
86280 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
86281 +extern int grsec_enable_blackhole;
86282 +#endif
86283 +
86284 #ifdef CONFIG_TCP_MD5SIG
86285 static int tcp_v4_md5_hash_hdr(char *md5_hash, const struct tcp_md5sig_key *key,
86286 __be32 daddr, __be32 saddr, const struct tcphdr *th);
86287 @@ -1895,6 +1899,9 @@ int tcp_v4_do_rcv(struct sock *sk, struct sk_buff *skb)
86288 return 0;
86289
86290 reset:
86291 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
86292 + if (!grsec_enable_blackhole)
86293 +#endif
86294 tcp_v4_send_reset(rsk, skb);
86295 discard:
86296 kfree_skb(skb);
86297 @@ -1994,12 +2001,19 @@ int tcp_v4_rcv(struct sk_buff *skb)
86298 TCP_SKB_CB(skb)->sacked = 0;
86299
86300 sk = __inet_lookup_skb(&tcp_hashinfo, skb, th->source, th->dest);
86301 - if (!sk)
86302 + if (!sk) {
86303 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
86304 + ret = 1;
86305 +#endif
86306 goto no_tcp_socket;
86307 -
86308 + }
86309 process:
86310 - if (sk->sk_state == TCP_TIME_WAIT)
86311 + if (sk->sk_state == TCP_TIME_WAIT) {
86312 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
86313 + ret = 2;
86314 +#endif
86315 goto do_time_wait;
86316 + }
86317
86318 if (unlikely(iph->ttl < inet_sk(sk)->min_ttl)) {
86319 NET_INC_STATS_BH(net, LINUX_MIB_TCPMINTTLDROP);
86320 @@ -2050,6 +2064,10 @@ no_tcp_socket:
86321 bad_packet:
86322 TCP_INC_STATS_BH(net, TCP_MIB_INERRS);
86323 } else {
86324 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
86325 + if (!grsec_enable_blackhole || (ret == 1 &&
86326 + (skb->dev->flags & IFF_LOOPBACK)))
86327 +#endif
86328 tcp_v4_send_reset(NULL, skb);
86329 }
86330
86331 diff --git a/net/ipv4/tcp_minisocks.c b/net/ipv4/tcp_minisocks.c
86332 index f35f2df..ccb5ca6 100644
86333 --- a/net/ipv4/tcp_minisocks.c
86334 +++ b/net/ipv4/tcp_minisocks.c
86335 @@ -27,6 +27,10 @@
86336 #include <net/inet_common.h>
86337 #include <net/xfrm.h>
86338
86339 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
86340 +extern int grsec_enable_blackhole;
86341 +#endif
86342 +
86343 int sysctl_tcp_syncookies __read_mostly = 1;
86344 EXPORT_SYMBOL(sysctl_tcp_syncookies);
86345
86346 @@ -742,7 +746,10 @@ embryonic_reset:
86347 * avoid becoming vulnerable to outside attack aiming at
86348 * resetting legit local connections.
86349 */
86350 - req->rsk_ops->send_reset(sk, skb);
86351 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
86352 + if (!grsec_enable_blackhole)
86353 +#endif
86354 + req->rsk_ops->send_reset(sk, skb);
86355 } else if (fastopen) { /* received a valid RST pkt */
86356 reqsk_fastopen_remove(sk, req, true);
86357 tcp_reset(sk);
86358 diff --git a/net/ipv4/tcp_probe.c b/net/ipv4/tcp_probe.c
86359 index 4526fe6..1a34e43 100644
86360 --- a/net/ipv4/tcp_probe.c
86361 +++ b/net/ipv4/tcp_probe.c
86362 @@ -204,7 +204,7 @@ static ssize_t tcpprobe_read(struct file *file, char __user *buf,
86363 if (cnt + width >= len)
86364 break;
86365
86366 - if (copy_to_user(buf + cnt, tbuf, width))
86367 + if (width > sizeof tbuf || copy_to_user(buf + cnt, tbuf, width))
86368 return -EFAULT;
86369 cnt += width;
86370 }
86371 diff --git a/net/ipv4/tcp_timer.c b/net/ipv4/tcp_timer.c
86372 index b78aac3..e18230b 100644
86373 --- a/net/ipv4/tcp_timer.c
86374 +++ b/net/ipv4/tcp_timer.c
86375 @@ -22,6 +22,10 @@
86376 #include <linux/gfp.h>
86377 #include <net/tcp.h>
86378
86379 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
86380 +extern int grsec_lastack_retries;
86381 +#endif
86382 +
86383 int sysctl_tcp_syn_retries __read_mostly = TCP_SYN_RETRIES;
86384 int sysctl_tcp_synack_retries __read_mostly = TCP_SYNACK_RETRIES;
86385 int sysctl_tcp_keepalive_time __read_mostly = TCP_KEEPALIVE_TIME;
86386 @@ -185,6 +189,13 @@ static int tcp_write_timeout(struct sock *sk)
86387 }
86388 }
86389
86390 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
86391 + if ((sk->sk_state == TCP_LAST_ACK) &&
86392 + (grsec_lastack_retries > 0) &&
86393 + (grsec_lastack_retries < retry_until))
86394 + retry_until = grsec_lastack_retries;
86395 +#endif
86396 +
86397 if (retransmits_timed_out(sk, retry_until,
86398 syn_set ? 0 : icsk->icsk_user_timeout, syn_set)) {
86399 /* Has it gone just too far? */
86400 diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
86401 index 1f4d405..3524677 100644
86402 --- a/net/ipv4/udp.c
86403 +++ b/net/ipv4/udp.c
86404 @@ -87,6 +87,7 @@
86405 #include <linux/types.h>
86406 #include <linux/fcntl.h>
86407 #include <linux/module.h>
86408 +#include <linux/security.h>
86409 #include <linux/socket.h>
86410 #include <linux/sockios.h>
86411 #include <linux/igmp.h>
86412 @@ -111,6 +112,10 @@
86413 #include <trace/events/skb.h>
86414 #include "udp_impl.h"
86415
86416 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
86417 +extern int grsec_enable_blackhole;
86418 +#endif
86419 +
86420 struct udp_table udp_table __read_mostly;
86421 EXPORT_SYMBOL(udp_table);
86422
86423 @@ -569,6 +574,9 @@ found:
86424 return s;
86425 }
86426
86427 +extern int gr_search_udp_recvmsg(struct sock *sk, const struct sk_buff *skb);
86428 +extern int gr_search_udp_sendmsg(struct sock *sk, struct sockaddr_in *addr);
86429 +
86430 /*
86431 * This routine is called by the ICMP module when it gets some
86432 * sort of error condition. If err < 0 then the socket should
86433 @@ -864,9 +872,18 @@ int udp_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
86434 dport = usin->sin_port;
86435 if (dport == 0)
86436 return -EINVAL;
86437 +
86438 + err = gr_search_udp_sendmsg(sk, usin);
86439 + if (err)
86440 + return err;
86441 } else {
86442 if (sk->sk_state != TCP_ESTABLISHED)
86443 return -EDESTADDRREQ;
86444 +
86445 + err = gr_search_udp_sendmsg(sk, NULL);
86446 + if (err)
86447 + return err;
86448 +
86449 daddr = inet->inet_daddr;
86450 dport = inet->inet_dport;
86451 /* Open fast path for connected socket.
86452 @@ -1108,7 +1125,7 @@ static unsigned int first_packet_length(struct sock *sk)
86453 udp_lib_checksum_complete(skb)) {
86454 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS,
86455 IS_UDPLITE(sk));
86456 - atomic_inc(&sk->sk_drops);
86457 + atomic_inc_unchecked(&sk->sk_drops);
86458 __skb_unlink(skb, rcvq);
86459 __skb_queue_tail(&list_kill, skb);
86460 }
86461 @@ -1194,6 +1211,10 @@ try_again:
86462 if (!skb)
86463 goto out;
86464
86465 + err = gr_search_udp_recvmsg(sk, skb);
86466 + if (err)
86467 + goto out_free;
86468 +
86469 ulen = skb->len - sizeof(struct udphdr);
86470 copied = len;
86471 if (copied > ulen)
86472 @@ -1227,7 +1248,7 @@ try_again:
86473 if (unlikely(err)) {
86474 trace_kfree_skb(skb, udp_recvmsg);
86475 if (!peeked) {
86476 - atomic_inc(&sk->sk_drops);
86477 + atomic_inc_unchecked(&sk->sk_drops);
86478 UDP_INC_STATS_USER(sock_net(sk),
86479 UDP_MIB_INERRORS, is_udplite);
86480 }
86481 @@ -1510,7 +1531,7 @@ int udp_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
86482
86483 drop:
86484 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS, is_udplite);
86485 - atomic_inc(&sk->sk_drops);
86486 + atomic_inc_unchecked(&sk->sk_drops);
86487 kfree_skb(skb);
86488 return -1;
86489 }
86490 @@ -1529,7 +1550,7 @@ static void flush_stack(struct sock **stack, unsigned int count,
86491 skb1 = (i == final) ? skb : skb_clone(skb, GFP_ATOMIC);
86492
86493 if (!skb1) {
86494 - atomic_inc(&sk->sk_drops);
86495 + atomic_inc_unchecked(&sk->sk_drops);
86496 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_RCVBUFERRORS,
86497 IS_UDPLITE(sk));
86498 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS,
86499 @@ -1698,6 +1719,9 @@ int __udp4_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
86500 goto csum_error;
86501
86502 UDP_INC_STATS_BH(net, UDP_MIB_NOPORTS, proto == IPPROTO_UDPLITE);
86503 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
86504 + if (!grsec_enable_blackhole || (skb->dev->flags & IFF_LOOPBACK))
86505 +#endif
86506 icmp_send(skb, ICMP_DEST_UNREACH, ICMP_PORT_UNREACH, 0);
86507
86508 /*
86509 @@ -2120,7 +2144,7 @@ static void udp4_format_sock(struct sock *sp, struct seq_file *f,
86510 from_kuid_munged(seq_user_ns(f), sock_i_uid(sp)),
86511 0, sock_i_ino(sp),
86512 atomic_read(&sp->sk_refcnt), sp,
86513 - atomic_read(&sp->sk_drops), len);
86514 + atomic_read_unchecked(&sp->sk_drops), len);
86515 }
86516
86517 int udp4_seq_show(struct seq_file *seq, void *v)
86518 diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
86519 index 1b5d8cb..ffb0833 100644
86520 --- a/net/ipv6/addrconf.c
86521 +++ b/net/ipv6/addrconf.c
86522 @@ -2272,7 +2272,7 @@ int addrconf_set_dstaddr(struct net *net, void __user *arg)
86523 p.iph.ihl = 5;
86524 p.iph.protocol = IPPROTO_IPV6;
86525 p.iph.ttl = 64;
86526 - ifr.ifr_ifru.ifru_data = (__force void __user *)&p;
86527 + ifr.ifr_ifru.ifru_data = (void __force_user *)&p;
86528
86529 if (ops->ndo_do_ioctl) {
86530 mm_segment_t oldfs = get_fs();
86531 @@ -4388,7 +4388,7 @@ int addrconf_sysctl_forward(ctl_table *ctl, int write,
86532 int *valp = ctl->data;
86533 int val = *valp;
86534 loff_t pos = *ppos;
86535 - ctl_table lctl;
86536 + ctl_table_no_const lctl;
86537 int ret;
86538
86539 /*
86540 @@ -4470,7 +4470,7 @@ int addrconf_sysctl_disable(ctl_table *ctl, int write,
86541 int *valp = ctl->data;
86542 int val = *valp;
86543 loff_t pos = *ppos;
86544 - ctl_table lctl;
86545 + ctl_table_no_const lctl;
86546 int ret;
86547
86548 /*
86549 diff --git a/net/ipv6/icmp.c b/net/ipv6/icmp.c
86550 index fff5bdd..15194fb 100644
86551 --- a/net/ipv6/icmp.c
86552 +++ b/net/ipv6/icmp.c
86553 @@ -973,7 +973,7 @@ ctl_table ipv6_icmp_table_template[] = {
86554
86555 struct ctl_table * __net_init ipv6_icmp_sysctl_init(struct net *net)
86556 {
86557 - struct ctl_table *table;
86558 + ctl_table_no_const *table;
86559
86560 table = kmemdup(ipv6_icmp_table_template,
86561 sizeof(ipv6_icmp_table_template),
86562 diff --git a/net/ipv6/ip6_gre.c b/net/ipv6/ip6_gre.c
86563 index 131dd09..f7ed64f 100644
86564 --- a/net/ipv6/ip6_gre.c
86565 +++ b/net/ipv6/ip6_gre.c
86566 @@ -73,7 +73,7 @@ struct ip6gre_net {
86567 struct net_device *fb_tunnel_dev;
86568 };
86569
86570 -static struct rtnl_link_ops ip6gre_link_ops __read_mostly;
86571 +static struct rtnl_link_ops ip6gre_link_ops;
86572 static int ip6gre_tunnel_init(struct net_device *dev);
86573 static void ip6gre_tunnel_setup(struct net_device *dev);
86574 static void ip6gre_tunnel_link(struct ip6gre_net *ign, struct ip6_tnl *t);
86575 @@ -1337,7 +1337,7 @@ static void ip6gre_fb_tunnel_init(struct net_device *dev)
86576 }
86577
86578
86579 -static struct inet6_protocol ip6gre_protocol __read_mostly = {
86580 +static struct inet6_protocol ip6gre_protocol = {
86581 .handler = ip6gre_rcv,
86582 .err_handler = ip6gre_err,
86583 .flags = INET6_PROTO_NOPOLICY|INET6_PROTO_FINAL,
86584 @@ -1671,7 +1671,7 @@ static const struct nla_policy ip6gre_policy[IFLA_GRE_MAX + 1] = {
86585 [IFLA_GRE_FLAGS] = { .type = NLA_U32 },
86586 };
86587
86588 -static struct rtnl_link_ops ip6gre_link_ops __read_mostly = {
86589 +static struct rtnl_link_ops ip6gre_link_ops = {
86590 .kind = "ip6gre",
86591 .maxtype = IFLA_GRE_MAX,
86592 .policy = ip6gre_policy,
86593 @@ -1684,7 +1684,7 @@ static struct rtnl_link_ops ip6gre_link_ops __read_mostly = {
86594 .fill_info = ip6gre_fill_info,
86595 };
86596
86597 -static struct rtnl_link_ops ip6gre_tap_ops __read_mostly = {
86598 +static struct rtnl_link_ops ip6gre_tap_ops = {
86599 .kind = "ip6gretap",
86600 .maxtype = IFLA_GRE_MAX,
86601 .policy = ip6gre_policy,
86602 diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c
86603 index a14f28b..b4b8956 100644
86604 --- a/net/ipv6/ip6_tunnel.c
86605 +++ b/net/ipv6/ip6_tunnel.c
86606 @@ -87,7 +87,7 @@ static u32 HASH(const struct in6_addr *addr1, const struct in6_addr *addr2)
86607
86608 static int ip6_tnl_dev_init(struct net_device *dev);
86609 static void ip6_tnl_dev_setup(struct net_device *dev);
86610 -static struct rtnl_link_ops ip6_link_ops __read_mostly;
86611 +static struct rtnl_link_ops ip6_link_ops;
86612
86613 static int ip6_tnl_net_id __read_mostly;
86614 struct ip6_tnl_net {
86615 @@ -1686,7 +1686,7 @@ static const struct nla_policy ip6_tnl_policy[IFLA_IPTUN_MAX + 1] = {
86616 [IFLA_IPTUN_PROTO] = { .type = NLA_U8 },
86617 };
86618
86619 -static struct rtnl_link_ops ip6_link_ops __read_mostly = {
86620 +static struct rtnl_link_ops ip6_link_ops = {
86621 .kind = "ip6tnl",
86622 .maxtype = IFLA_IPTUN_MAX,
86623 .policy = ip6_tnl_policy,
86624 diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c
86625 index d1e2e8e..51c19ae 100644
86626 --- a/net/ipv6/ipv6_sockglue.c
86627 +++ b/net/ipv6/ipv6_sockglue.c
86628 @@ -991,7 +991,7 @@ static int do_ipv6_getsockopt(struct sock *sk, int level, int optname,
86629 if (sk->sk_type != SOCK_STREAM)
86630 return -ENOPROTOOPT;
86631
86632 - msg.msg_control = optval;
86633 + msg.msg_control = (void __force_kernel *)optval;
86634 msg.msg_controllen = len;
86635 msg.msg_flags = flags;
86636
86637 diff --git a/net/ipv6/netfilter/ip6_tables.c b/net/ipv6/netfilter/ip6_tables.c
86638 index 125a90d..2a11f36 100644
86639 --- a/net/ipv6/netfilter/ip6_tables.c
86640 +++ b/net/ipv6/netfilter/ip6_tables.c
86641 @@ -1076,14 +1076,14 @@ static int compat_table_info(const struct xt_table_info *info,
86642 #endif
86643
86644 static int get_info(struct net *net, void __user *user,
86645 - const int *len, int compat)
86646 + int len, int compat)
86647 {
86648 char name[XT_TABLE_MAXNAMELEN];
86649 struct xt_table *t;
86650 int ret;
86651
86652 - if (*len != sizeof(struct ip6t_getinfo)) {
86653 - duprintf("length %u != %zu\n", *len,
86654 + if (len != sizeof(struct ip6t_getinfo)) {
86655 + duprintf("length %u != %zu\n", len,
86656 sizeof(struct ip6t_getinfo));
86657 return -EINVAL;
86658 }
86659 @@ -1120,7 +1120,7 @@ static int get_info(struct net *net, void __user *user,
86660 info.size = private->size;
86661 strcpy(info.name, name);
86662
86663 - if (copy_to_user(user, &info, *len) != 0)
86664 + if (copy_to_user(user, &info, len) != 0)
86665 ret = -EFAULT;
86666 else
86667 ret = 0;
86668 @@ -1974,7 +1974,7 @@ compat_do_ip6t_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
86669
86670 switch (cmd) {
86671 case IP6T_SO_GET_INFO:
86672 - ret = get_info(sock_net(sk), user, len, 1);
86673 + ret = get_info(sock_net(sk), user, *len, 1);
86674 break;
86675 case IP6T_SO_GET_ENTRIES:
86676 ret = compat_get_entries(sock_net(sk), user, len);
86677 @@ -2021,7 +2021,7 @@ do_ip6t_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
86678
86679 switch (cmd) {
86680 case IP6T_SO_GET_INFO:
86681 - ret = get_info(sock_net(sk), user, len, 0);
86682 + ret = get_info(sock_net(sk), user, *len, 0);
86683 break;
86684
86685 case IP6T_SO_GET_ENTRIES:
86686 diff --git a/net/ipv6/netfilter/nf_conntrack_reasm.c b/net/ipv6/netfilter/nf_conntrack_reasm.c
86687 index 3dacecc..2939087 100644
86688 --- a/net/ipv6/netfilter/nf_conntrack_reasm.c
86689 +++ b/net/ipv6/netfilter/nf_conntrack_reasm.c
86690 @@ -87,12 +87,11 @@ static struct ctl_table nf_ct_frag6_sysctl_table[] = {
86691
86692 static int nf_ct_frag6_sysctl_register(struct net *net)
86693 {
86694 - struct ctl_table *table;
86695 + ctl_table_no_const *table = NULL;
86696 struct ctl_table_header *hdr;
86697
86698 - table = nf_ct_frag6_sysctl_table;
86699 if (!net_eq(net, &init_net)) {
86700 - table = kmemdup(table, sizeof(nf_ct_frag6_sysctl_table),
86701 + table = kmemdup(nf_ct_frag6_sysctl_table, sizeof(nf_ct_frag6_sysctl_table),
86702 GFP_KERNEL);
86703 if (table == NULL)
86704 goto err_alloc;
86705 @@ -100,9 +99,9 @@ static int nf_ct_frag6_sysctl_register(struct net *net)
86706 table[0].data = &net->ipv6.frags.high_thresh;
86707 table[1].data = &net->ipv6.frags.low_thresh;
86708 table[2].data = &net->ipv6.frags.timeout;
86709 - }
86710 -
86711 - hdr = register_net_sysctl(net, "net/netfilter", table);
86712 + hdr = register_net_sysctl(net, "net/netfilter", table);
86713 + } else
86714 + hdr = register_net_sysctl(net, "net/netfilter", nf_ct_frag6_sysctl_table);
86715 if (hdr == NULL)
86716 goto err_reg;
86717
86718 @@ -110,8 +109,7 @@ static int nf_ct_frag6_sysctl_register(struct net *net)
86719 return 0;
86720
86721 err_reg:
86722 - if (!net_eq(net, &init_net))
86723 - kfree(table);
86724 + kfree(table);
86725 err_alloc:
86726 return -ENOMEM;
86727 }
86728 diff --git a/net/ipv6/raw.c b/net/ipv6/raw.c
86729 index 70fa814..d70c28c 100644
86730 --- a/net/ipv6/raw.c
86731 +++ b/net/ipv6/raw.c
86732 @@ -379,7 +379,7 @@ static inline int rawv6_rcv_skb(struct sock *sk, struct sk_buff *skb)
86733 {
86734 if ((raw6_sk(sk)->checksum || rcu_access_pointer(sk->sk_filter)) &&
86735 skb_checksum_complete(skb)) {
86736 - atomic_inc(&sk->sk_drops);
86737 + atomic_inc_unchecked(&sk->sk_drops);
86738 kfree_skb(skb);
86739 return NET_RX_DROP;
86740 }
86741 @@ -407,7 +407,7 @@ int rawv6_rcv(struct sock *sk, struct sk_buff *skb)
86742 struct raw6_sock *rp = raw6_sk(sk);
86743
86744 if (!xfrm6_policy_check(sk, XFRM_POLICY_IN, skb)) {
86745 - atomic_inc(&sk->sk_drops);
86746 + atomic_inc_unchecked(&sk->sk_drops);
86747 kfree_skb(skb);
86748 return NET_RX_DROP;
86749 }
86750 @@ -431,7 +431,7 @@ int rawv6_rcv(struct sock *sk, struct sk_buff *skb)
86751
86752 if (inet->hdrincl) {
86753 if (skb_checksum_complete(skb)) {
86754 - atomic_inc(&sk->sk_drops);
86755 + atomic_inc_unchecked(&sk->sk_drops);
86756 kfree_skb(skb);
86757 return NET_RX_DROP;
86758 }
86759 @@ -604,7 +604,7 @@ out:
86760 return err;
86761 }
86762
86763 -static int rawv6_send_hdrinc(struct sock *sk, void *from, int length,
86764 +static int rawv6_send_hdrinc(struct sock *sk, void *from, unsigned int length,
86765 struct flowi6 *fl6, struct dst_entry **dstp,
86766 unsigned int flags)
86767 {
86768 @@ -916,12 +916,15 @@ do_confirm:
86769 static int rawv6_seticmpfilter(struct sock *sk, int level, int optname,
86770 char __user *optval, int optlen)
86771 {
86772 + struct icmp6_filter filter;
86773 +
86774 switch (optname) {
86775 case ICMPV6_FILTER:
86776 if (optlen > sizeof(struct icmp6_filter))
86777 optlen = sizeof(struct icmp6_filter);
86778 - if (copy_from_user(&raw6_sk(sk)->filter, optval, optlen))
86779 + if (copy_from_user(&filter, optval, optlen))
86780 return -EFAULT;
86781 + raw6_sk(sk)->filter = filter;
86782 return 0;
86783 default:
86784 return -ENOPROTOOPT;
86785 @@ -934,6 +937,7 @@ static int rawv6_geticmpfilter(struct sock *sk, int level, int optname,
86786 char __user *optval, int __user *optlen)
86787 {
86788 int len;
86789 + struct icmp6_filter filter;
86790
86791 switch (optname) {
86792 case ICMPV6_FILTER:
86793 @@ -945,7 +949,8 @@ static int rawv6_geticmpfilter(struct sock *sk, int level, int optname,
86794 len = sizeof(struct icmp6_filter);
86795 if (put_user(len, optlen))
86796 return -EFAULT;
86797 - if (copy_to_user(optval, &raw6_sk(sk)->filter, len))
86798 + filter = raw6_sk(sk)->filter;
86799 + if (len > sizeof filter || copy_to_user(optval, &filter, len))
86800 return -EFAULT;
86801 return 0;
86802 default:
86803 @@ -1253,7 +1258,7 @@ static void raw6_sock_seq_show(struct seq_file *seq, struct sock *sp, int i)
86804 from_kuid_munged(seq_user_ns(seq), sock_i_uid(sp)),
86805 0,
86806 sock_i_ino(sp),
86807 - atomic_read(&sp->sk_refcnt), sp, atomic_read(&sp->sk_drops));
86808 + atomic_read(&sp->sk_refcnt), sp, atomic_read_unchecked(&sp->sk_drops));
86809 }
86810
86811 static int raw6_seq_show(struct seq_file *seq, void *v)
86812 diff --git a/net/ipv6/reassembly.c b/net/ipv6/reassembly.c
86813 index e5253ec..0410257 100644
86814 --- a/net/ipv6/reassembly.c
86815 +++ b/net/ipv6/reassembly.c
86816 @@ -604,12 +604,11 @@ static struct ctl_table ip6_frags_ctl_table[] = {
86817
86818 static int __net_init ip6_frags_ns_sysctl_register(struct net *net)
86819 {
86820 - struct ctl_table *table;
86821 + ctl_table_no_const *table = NULL;
86822 struct ctl_table_header *hdr;
86823
86824 - table = ip6_frags_ns_ctl_table;
86825 if (!net_eq(net, &init_net)) {
86826 - table = kmemdup(table, sizeof(ip6_frags_ns_ctl_table), GFP_KERNEL);
86827 + table = kmemdup(ip6_frags_ns_ctl_table, sizeof(ip6_frags_ns_ctl_table), GFP_KERNEL);
86828 if (table == NULL)
86829 goto err_alloc;
86830
86831 @@ -620,9 +619,10 @@ static int __net_init ip6_frags_ns_sysctl_register(struct net *net)
86832 /* Don't export sysctls to unprivileged users */
86833 if (net->user_ns != &init_user_ns)
86834 table[0].procname = NULL;
86835 - }
86836 + hdr = register_net_sysctl(net, "net/ipv6", table);
86837 + } else
86838 + hdr = register_net_sysctl(net, "net/ipv6", ip6_frags_ns_ctl_table);
86839
86840 - hdr = register_net_sysctl(net, "net/ipv6", table);
86841 if (hdr == NULL)
86842 goto err_reg;
86843
86844 @@ -630,8 +630,7 @@ static int __net_init ip6_frags_ns_sysctl_register(struct net *net)
86845 return 0;
86846
86847 err_reg:
86848 - if (!net_eq(net, &init_net))
86849 - kfree(table);
86850 + kfree(table);
86851 err_alloc:
86852 return -ENOMEM;
86853 }
86854 diff --git a/net/ipv6/route.c b/net/ipv6/route.c
86855 index 5845613..3af8fc7 100644
86856 --- a/net/ipv6/route.c
86857 +++ b/net/ipv6/route.c
86858 @@ -2966,7 +2966,7 @@ ctl_table ipv6_route_table_template[] = {
86859
86860 struct ctl_table * __net_init ipv6_route_sysctl_init(struct net *net)
86861 {
86862 - struct ctl_table *table;
86863 + ctl_table_no_const *table;
86864
86865 table = kmemdup(ipv6_route_table_template,
86866 sizeof(ipv6_route_table_template),
86867 diff --git a/net/ipv6/sit.c b/net/ipv6/sit.c
86868 index cfba99b..20ca511 100644
86869 --- a/net/ipv6/sit.c
86870 +++ b/net/ipv6/sit.c
86871 @@ -72,7 +72,7 @@ MODULE_PARM_DESC(log_ecn_error, "Log packets received with corrupted ECN");
86872 static int ipip6_tunnel_init(struct net_device *dev);
86873 static void ipip6_tunnel_setup(struct net_device *dev);
86874 static void ipip6_dev_free(struct net_device *dev);
86875 -static struct rtnl_link_ops sit_link_ops __read_mostly;
86876 +static struct rtnl_link_ops sit_link_ops;
86877
86878 static int sit_net_id __read_mostly;
86879 struct sit_net {
86880 @@ -1463,7 +1463,7 @@ static const struct nla_policy ipip6_policy[IFLA_IPTUN_MAX + 1] = {
86881 #endif
86882 };
86883
86884 -static struct rtnl_link_ops sit_link_ops __read_mostly = {
86885 +static struct rtnl_link_ops sit_link_ops = {
86886 .kind = "sit",
86887 .maxtype = IFLA_IPTUN_MAX,
86888 .policy = ipip6_policy,
86889 diff --git a/net/ipv6/sysctl_net_ipv6.c b/net/ipv6/sysctl_net_ipv6.c
86890 index e85c48b..b8268d3 100644
86891 --- a/net/ipv6/sysctl_net_ipv6.c
86892 +++ b/net/ipv6/sysctl_net_ipv6.c
86893 @@ -40,7 +40,7 @@ static ctl_table ipv6_rotable[] = {
86894
86895 static int __net_init ipv6_sysctl_net_init(struct net *net)
86896 {
86897 - struct ctl_table *ipv6_table;
86898 + ctl_table_no_const *ipv6_table;
86899 struct ctl_table *ipv6_route_table;
86900 struct ctl_table *ipv6_icmp_table;
86901 int err;
86902 diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
86903 index 4f435371..5de9da7 100644
86904 --- a/net/ipv6/tcp_ipv6.c
86905 +++ b/net/ipv6/tcp_ipv6.c
86906 @@ -103,6 +103,10 @@ static void inet6_sk_rx_dst_set(struct sock *sk, const struct sk_buff *skb)
86907 inet6_sk(sk)->rx_dst_cookie = rt->rt6i_node->fn_sernum;
86908 }
86909
86910 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
86911 +extern int grsec_enable_blackhole;
86912 +#endif
86913 +
86914 static void tcp_v6_hash(struct sock *sk)
86915 {
86916 if (sk->sk_state != TCP_CLOSE) {
86917 @@ -1433,6 +1437,9 @@ static int tcp_v6_do_rcv(struct sock *sk, struct sk_buff *skb)
86918 return 0;
86919
86920 reset:
86921 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
86922 + if (!grsec_enable_blackhole)
86923 +#endif
86924 tcp_v6_send_reset(sk, skb);
86925 discard:
86926 if (opt_skb)
86927 @@ -1514,12 +1521,20 @@ static int tcp_v6_rcv(struct sk_buff *skb)
86928 TCP_SKB_CB(skb)->sacked = 0;
86929
86930 sk = __inet6_lookup_skb(&tcp_hashinfo, skb, th->source, th->dest);
86931 - if (!sk)
86932 + if (!sk) {
86933 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
86934 + ret = 1;
86935 +#endif
86936 goto no_tcp_socket;
86937 + }
86938
86939 process:
86940 - if (sk->sk_state == TCP_TIME_WAIT)
86941 + if (sk->sk_state == TCP_TIME_WAIT) {
86942 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
86943 + ret = 2;
86944 +#endif
86945 goto do_time_wait;
86946 + }
86947
86948 if (hdr->hop_limit < inet6_sk(sk)->min_hopcount) {
86949 NET_INC_STATS_BH(net, LINUX_MIB_TCPMINTTLDROP);
86950 @@ -1568,6 +1583,10 @@ no_tcp_socket:
86951 bad_packet:
86952 TCP_INC_STATS_BH(net, TCP_MIB_INERRS);
86953 } else {
86954 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
86955 + if (!grsec_enable_blackhole || (ret == 1 &&
86956 + (skb->dev->flags & IFF_LOOPBACK)))
86957 +#endif
86958 tcp_v6_send_reset(NULL, skb);
86959 }
86960
86961 diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c
86962 index fb08329..2d6919e 100644
86963 --- a/net/ipv6/udp.c
86964 +++ b/net/ipv6/udp.c
86965 @@ -51,6 +51,10 @@
86966 #include <trace/events/skb.h>
86967 #include "udp_impl.h"
86968
86969 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
86970 +extern int grsec_enable_blackhole;
86971 +#endif
86972 +
86973 int ipv6_rcv_saddr_equal(const struct sock *sk, const struct sock *sk2)
86974 {
86975 const struct in6_addr *sk_rcv_saddr6 = &inet6_sk(sk)->rcv_saddr;
86976 @@ -395,7 +399,7 @@ try_again:
86977 if (unlikely(err)) {
86978 trace_kfree_skb(skb, udpv6_recvmsg);
86979 if (!peeked) {
86980 - atomic_inc(&sk->sk_drops);
86981 + atomic_inc_unchecked(&sk->sk_drops);
86982 if (is_udp4)
86983 UDP_INC_STATS_USER(sock_net(sk),
86984 UDP_MIB_INERRORS,
86985 @@ -633,7 +637,7 @@ int udpv6_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
86986 return rc;
86987 drop:
86988 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS, is_udplite);
86989 - atomic_inc(&sk->sk_drops);
86990 + atomic_inc_unchecked(&sk->sk_drops);
86991 kfree_skb(skb);
86992 return -1;
86993 }
86994 @@ -691,7 +695,7 @@ static void flush_stack(struct sock **stack, unsigned int count,
86995 if (likely(skb1 == NULL))
86996 skb1 = (i == final) ? skb : skb_clone(skb, GFP_ATOMIC);
86997 if (!skb1) {
86998 - atomic_inc(&sk->sk_drops);
86999 + atomic_inc_unchecked(&sk->sk_drops);
87000 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_RCVBUFERRORS,
87001 IS_UDPLITE(sk));
87002 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS,
87003 @@ -862,6 +866,9 @@ int __udp6_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
87004 goto discard;
87005
87006 UDP6_INC_STATS_BH(net, UDP_MIB_NOPORTS, proto == IPPROTO_UDPLITE);
87007 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87008 + if (!grsec_enable_blackhole || (skb->dev->flags & IFF_LOOPBACK))
87009 +#endif
87010 icmpv6_send(skb, ICMPV6_DEST_UNREACH, ICMPV6_PORT_UNREACH, 0);
87011
87012 kfree_skb(skb);
87013 @@ -1379,7 +1386,7 @@ static void udp6_sock_seq_show(struct seq_file *seq, struct sock *sp, int bucket
87014 0,
87015 sock_i_ino(sp),
87016 atomic_read(&sp->sk_refcnt), sp,
87017 - atomic_read(&sp->sk_drops));
87018 + atomic_read_unchecked(&sp->sk_drops));
87019 }
87020
87021 int udp6_seq_show(struct seq_file *seq, void *v)
87022 diff --git a/net/irda/af_irda.c b/net/irda/af_irda.c
87023 index b833677..4d04105 100644
87024 --- a/net/irda/af_irda.c
87025 +++ b/net/irda/af_irda.c
87026 @@ -2584,8 +2584,10 @@ bed:
87027 NULL, NULL, NULL);
87028
87029 /* Check if the we got some results */
87030 - if (!self->cachedaddr)
87031 - return -EAGAIN; /* Didn't find any devices */
87032 + if (!self->cachedaddr) {
87033 + err = -EAGAIN; /* Didn't find any devices */
87034 + goto out;
87035 + }
87036 daddr = self->cachedaddr;
87037 /* Cleanup */
87038 self->cachedaddr = 0;
87039 diff --git a/net/irda/ircomm/ircomm_tty.c b/net/irda/ircomm/ircomm_tty.c
87040 index a68c88c..d55b0c5 100644
87041 --- a/net/irda/ircomm/ircomm_tty.c
87042 +++ b/net/irda/ircomm/ircomm_tty.c
87043 @@ -312,12 +312,12 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
87044 add_wait_queue(&port->open_wait, &wait);
87045
87046 IRDA_DEBUG(2, "%s(%d):block_til_ready before block on %s open_count=%d\n",
87047 - __FILE__, __LINE__, tty->driver->name, port->count);
87048 + __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
87049
87050 spin_lock_irqsave(&port->lock, flags);
87051 if (!tty_hung_up_p(filp)) {
87052 extra_count = 1;
87053 - port->count--;
87054 + atomic_dec(&port->count);
87055 }
87056 spin_unlock_irqrestore(&port->lock, flags);
87057 port->blocked_open++;
87058 @@ -353,7 +353,7 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
87059 }
87060
87061 IRDA_DEBUG(1, "%s(%d):block_til_ready blocking on %s open_count=%d\n",
87062 - __FILE__, __LINE__, tty->driver->name, port->count);
87063 + __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
87064
87065 schedule();
87066 }
87067 @@ -364,13 +364,13 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
87068 if (extra_count) {
87069 /* ++ is not atomic, so this should be protected - Jean II */
87070 spin_lock_irqsave(&port->lock, flags);
87071 - port->count++;
87072 + atomic_inc(&port->count);
87073 spin_unlock_irqrestore(&port->lock, flags);
87074 }
87075 port->blocked_open--;
87076
87077 IRDA_DEBUG(1, "%s(%d):block_til_ready after blocking on %s open_count=%d\n",
87078 - __FILE__, __LINE__, tty->driver->name, port->count);
87079 + __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
87080
87081 if (!retval)
87082 port->flags |= ASYNC_NORMAL_ACTIVE;
87083 @@ -444,12 +444,12 @@ static int ircomm_tty_open(struct tty_struct *tty, struct file *filp)
87084
87085 /* ++ is not atomic, so this should be protected - Jean II */
87086 spin_lock_irqsave(&self->port.lock, flags);
87087 - self->port.count++;
87088 + atomic_inc(&self->port.count);
87089 spin_unlock_irqrestore(&self->port.lock, flags);
87090 tty_port_tty_set(&self->port, tty);
87091
87092 IRDA_DEBUG(1, "%s(), %s%d, count = %d\n", __func__ , tty->driver->name,
87093 - self->line, self->port.count);
87094 + self->line, atomic_read(&self->port.count));
87095
87096 /* Not really used by us, but lets do it anyway */
87097 tty->low_latency = (self->port.flags & ASYNC_LOW_LATENCY) ? 1 : 0;
87098 @@ -986,7 +986,7 @@ static void ircomm_tty_hangup(struct tty_struct *tty)
87099 tty_kref_put(port->tty);
87100 }
87101 port->tty = NULL;
87102 - port->count = 0;
87103 + atomic_set(&port->count, 0);
87104 spin_unlock_irqrestore(&port->lock, flags);
87105
87106 wake_up_interruptible(&port->open_wait);
87107 @@ -1343,7 +1343,7 @@ static void ircomm_tty_line_info(struct ircomm_tty_cb *self, struct seq_file *m)
87108 seq_putc(m, '\n');
87109
87110 seq_printf(m, "Role: %s\n", self->client ? "client" : "server");
87111 - seq_printf(m, "Open count: %d\n", self->port.count);
87112 + seq_printf(m, "Open count: %d\n", atomic_read(&self->port.count));
87113 seq_printf(m, "Max data size: %d\n", self->max_data_size);
87114 seq_printf(m, "Max header size: %d\n", self->max_header_size);
87115
87116 diff --git a/net/irda/iriap.c b/net/irda/iriap.c
87117 index e71e85b..29340a9 100644
87118 --- a/net/irda/iriap.c
87119 +++ b/net/irda/iriap.c
87120 @@ -495,8 +495,11 @@ static void iriap_getvaluebyclass_confirm(struct iriap_cb *self,
87121 /* case CS_ISO_8859_9: */
87122 /* case CS_UNICODE: */
87123 default:
87124 - IRDA_DEBUG(0, "%s(), charset %s, not supported\n",
87125 - __func__, ias_charset_types[charset]);
87126 + IRDA_DEBUG(0, "%s(), charset [%d] %s, not supported\n",
87127 + __func__, charset,
87128 + charset < ARRAY_SIZE(ias_charset_types) ?
87129 + ias_charset_types[charset] :
87130 + "(unknown)");
87131
87132 /* Aborting, close connection! */
87133 iriap_disconnect_request(self);
87134 diff --git a/net/iucv/af_iucv.c b/net/iucv/af_iucv.c
87135 index cd6f7a9..e63fe89 100644
87136 --- a/net/iucv/af_iucv.c
87137 +++ b/net/iucv/af_iucv.c
87138 @@ -782,10 +782,10 @@ static int iucv_sock_autobind(struct sock *sk)
87139
87140 write_lock_bh(&iucv_sk_list.lock);
87141
87142 - sprintf(name, "%08x", atomic_inc_return(&iucv_sk_list.autobind_name));
87143 + sprintf(name, "%08x", atomic_inc_return_unchecked(&iucv_sk_list.autobind_name));
87144 while (__iucv_get_sock_by_name(name)) {
87145 sprintf(name, "%08x",
87146 - atomic_inc_return(&iucv_sk_list.autobind_name));
87147 + atomic_inc_return_unchecked(&iucv_sk_list.autobind_name));
87148 }
87149
87150 write_unlock_bh(&iucv_sk_list.lock);
87151 diff --git a/net/iucv/iucv.c b/net/iucv/iucv.c
87152 index df08250..02021fe 100644
87153 --- a/net/iucv/iucv.c
87154 +++ b/net/iucv/iucv.c
87155 @@ -690,7 +690,7 @@ static int __cpuinit iucv_cpu_notify(struct notifier_block *self,
87156 return NOTIFY_OK;
87157 }
87158
87159 -static struct notifier_block __refdata iucv_cpu_notifier = {
87160 +static struct notifier_block iucv_cpu_notifier = {
87161 .notifier_call = iucv_cpu_notify,
87162 };
87163
87164 diff --git a/net/key/af_key.c b/net/key/af_key.c
87165 index 5b426a6..970032b 100644
87166 --- a/net/key/af_key.c
87167 +++ b/net/key/af_key.c
87168 @@ -3019,10 +3019,10 @@ static int pfkey_send_policy_notify(struct xfrm_policy *xp, int dir, const struc
87169 static u32 get_acqseq(void)
87170 {
87171 u32 res;
87172 - static atomic_t acqseq;
87173 + static atomic_unchecked_t acqseq;
87174
87175 do {
87176 - res = atomic_inc_return(&acqseq);
87177 + res = atomic_inc_return_unchecked(&acqseq);
87178 } while (!res);
87179 return res;
87180 }
87181 diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
87182 index 0479c64..d031db6 100644
87183 --- a/net/mac80211/cfg.c
87184 +++ b/net/mac80211/cfg.c
87185 @@ -790,7 +790,7 @@ static int ieee80211_set_monitor_channel(struct wiphy *wiphy,
87186 ret = ieee80211_vif_use_channel(sdata, chandef,
87187 IEEE80211_CHANCTX_EXCLUSIVE);
87188 }
87189 - } else if (local->open_count == local->monitors) {
87190 + } else if (local_read(&local->open_count) == local->monitors) {
87191 local->_oper_channel = chandef->chan;
87192 local->_oper_channel_type = cfg80211_get_chandef_type(chandef);
87193 ieee80211_hw_config(local, 0);
87194 @@ -2716,7 +2716,7 @@ static void ieee80211_mgmt_frame_register(struct wiphy *wiphy,
87195 else
87196 local->probe_req_reg--;
87197
87198 - if (!local->open_count)
87199 + if (!local_read(&local->open_count))
87200 break;
87201
87202 ieee80211_queue_work(&local->hw, &local->reconfig_filter);
87203 diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h
87204 index 2ed065c..948177f 100644
87205 --- a/net/mac80211/ieee80211_i.h
87206 +++ b/net/mac80211/ieee80211_i.h
87207 @@ -28,6 +28,7 @@
87208 #include <net/ieee80211_radiotap.h>
87209 #include <net/cfg80211.h>
87210 #include <net/mac80211.h>
87211 +#include <asm/local.h>
87212 #include "key.h"
87213 #include "sta_info.h"
87214 #include "debug.h"
87215 @@ -909,7 +910,7 @@ struct ieee80211_local {
87216 /* also used to protect ampdu_ac_queue and amdpu_ac_stop_refcnt */
87217 spinlock_t queue_stop_reason_lock;
87218
87219 - int open_count;
87220 + local_t open_count;
87221 int monitors, cooked_mntrs;
87222 /* number of interfaces with corresponding FIF_ flags */
87223 int fif_fcsfail, fif_plcpfail, fif_control, fif_other_bss, fif_pspoll,
87224 diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c
87225 index 8be854e..ad72a69 100644
87226 --- a/net/mac80211/iface.c
87227 +++ b/net/mac80211/iface.c
87228 @@ -546,7 +546,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
87229 break;
87230 }
87231
87232 - if (local->open_count == 0) {
87233 + if (local_read(&local->open_count) == 0) {
87234 res = drv_start(local);
87235 if (res)
87236 goto err_del_bss;
87237 @@ -591,7 +591,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
87238 break;
87239 }
87240
87241 - if (local->monitors == 0 && local->open_count == 0) {
87242 + if (local->monitors == 0 && local_read(&local->open_count) == 0) {
87243 res = ieee80211_add_virtual_monitor(local);
87244 if (res)
87245 goto err_stop;
87246 @@ -699,7 +699,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
87247 mutex_unlock(&local->mtx);
87248
87249 if (coming_up)
87250 - local->open_count++;
87251 + local_inc(&local->open_count);
87252
87253 if (hw_reconf_flags)
87254 ieee80211_hw_config(local, hw_reconf_flags);
87255 @@ -713,7 +713,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
87256 err_del_interface:
87257 drv_remove_interface(local, sdata);
87258 err_stop:
87259 - if (!local->open_count)
87260 + if (!local_read(&local->open_count))
87261 drv_stop(local);
87262 err_del_bss:
87263 sdata->bss = NULL;
87264 @@ -827,7 +827,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
87265 }
87266
87267 if (going_down)
87268 - local->open_count--;
87269 + local_dec(&local->open_count);
87270
87271 switch (sdata->vif.type) {
87272 case NL80211_IFTYPE_AP_VLAN:
87273 @@ -884,7 +884,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
87274
87275 ieee80211_recalc_ps(local, -1);
87276
87277 - if (local->open_count == 0) {
87278 + if (local_read(&local->open_count) == 0) {
87279 if (local->ops->napi_poll)
87280 napi_disable(&local->napi);
87281 ieee80211_clear_tx_pending(local);
87282 @@ -910,7 +910,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
87283 }
87284 spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags);
87285
87286 - if (local->monitors == local->open_count && local->monitors > 0)
87287 + if (local->monitors == local_read(&local->open_count) && local->monitors > 0)
87288 ieee80211_add_virtual_monitor(local);
87289 }
87290
87291 diff --git a/net/mac80211/main.c b/net/mac80211/main.c
87292 index 1b087ff..bf600e9 100644
87293 --- a/net/mac80211/main.c
87294 +++ b/net/mac80211/main.c
87295 @@ -181,7 +181,7 @@ int ieee80211_hw_config(struct ieee80211_local *local, u32 changed)
87296 changed &= ~(IEEE80211_CONF_CHANGE_CHANNEL |
87297 IEEE80211_CONF_CHANGE_POWER);
87298
87299 - if (changed && local->open_count) {
87300 + if (changed && local_read(&local->open_count)) {
87301 ret = drv_config(local, changed);
87302 /*
87303 * Goal:
87304 diff --git a/net/mac80211/pm.c b/net/mac80211/pm.c
87305 index 79a48f3..5e185c9 100644
87306 --- a/net/mac80211/pm.c
87307 +++ b/net/mac80211/pm.c
87308 @@ -35,7 +35,7 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
87309 struct sta_info *sta;
87310 struct ieee80211_chanctx *ctx;
87311
87312 - if (!local->open_count)
87313 + if (!local_read(&local->open_count))
87314 goto suspend;
87315
87316 ieee80211_scan_cancel(local);
87317 @@ -73,7 +73,7 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
87318 cancel_work_sync(&local->dynamic_ps_enable_work);
87319 del_timer_sync(&local->dynamic_ps_timer);
87320
87321 - local->wowlan = wowlan && local->open_count;
87322 + local->wowlan = wowlan && local_read(&local->open_count);
87323 if (local->wowlan) {
87324 int err = drv_suspend(local, wowlan);
87325 if (err < 0) {
87326 @@ -187,7 +187,7 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
87327 mutex_unlock(&local->chanctx_mtx);
87328
87329 /* stop hardware - this must stop RX */
87330 - if (local->open_count)
87331 + if (local_read(&local->open_count))
87332 ieee80211_stop_device(local);
87333
87334 suspend:
87335 diff --git a/net/mac80211/rate.c b/net/mac80211/rate.c
87336 index dd88381..eef4dd6 100644
87337 --- a/net/mac80211/rate.c
87338 +++ b/net/mac80211/rate.c
87339 @@ -493,7 +493,7 @@ int ieee80211_init_rate_ctrl_alg(struct ieee80211_local *local,
87340
87341 ASSERT_RTNL();
87342
87343 - if (local->open_count)
87344 + if (local_read(&local->open_count))
87345 return -EBUSY;
87346
87347 if (local->hw.flags & IEEE80211_HW_HAS_RATE_CONTROL) {
87348 diff --git a/net/mac80211/rc80211_pid_debugfs.c b/net/mac80211/rc80211_pid_debugfs.c
87349 index c97a065..ff61928 100644
87350 --- a/net/mac80211/rc80211_pid_debugfs.c
87351 +++ b/net/mac80211/rc80211_pid_debugfs.c
87352 @@ -193,7 +193,7 @@ static ssize_t rate_control_pid_events_read(struct file *file, char __user *buf,
87353
87354 spin_unlock_irqrestore(&events->lock, status);
87355
87356 - if (copy_to_user(buf, pb, p))
87357 + if (p > sizeof(pb) || copy_to_user(buf, pb, p))
87358 return -EFAULT;
87359
87360 return p;
87361 diff --git a/net/mac80211/util.c b/net/mac80211/util.c
87362 index f11e8c5..08d0013 100644
87363 --- a/net/mac80211/util.c
87364 +++ b/net/mac80211/util.c
87365 @@ -1380,7 +1380,7 @@ int ieee80211_reconfig(struct ieee80211_local *local)
87366 }
87367 #endif
87368 /* everything else happens only if HW was up & running */
87369 - if (!local->open_count)
87370 + if (!local_read(&local->open_count))
87371 goto wake_up;
87372
87373 /*
87374 diff --git a/net/netfilter/Kconfig b/net/netfilter/Kconfig
87375 index 49e96df..63a51c3 100644
87376 --- a/net/netfilter/Kconfig
87377 +++ b/net/netfilter/Kconfig
87378 @@ -936,6 +936,16 @@ config NETFILTER_XT_MATCH_ESP
87379
87380 To compile it as a module, choose M here. If unsure, say N.
87381
87382 +config NETFILTER_XT_MATCH_GRADM
87383 + tristate '"gradm" match support'
87384 + depends on NETFILTER_XTABLES && NETFILTER_ADVANCED
87385 + depends on GRKERNSEC && !GRKERNSEC_NO_RBAC
87386 + ---help---
87387 + The gradm match allows to match on grsecurity RBAC being enabled.
87388 + It is useful when iptables rules are applied early on bootup to
87389 + prevent connections to the machine (except from a trusted host)
87390 + while the RBAC system is disabled.
87391 +
87392 config NETFILTER_XT_MATCH_HASHLIMIT
87393 tristate '"hashlimit" match support'
87394 depends on (IP6_NF_IPTABLES || IP6_NF_IPTABLES=n)
87395 diff --git a/net/netfilter/Makefile b/net/netfilter/Makefile
87396 index 3259697..54d5393 100644
87397 --- a/net/netfilter/Makefile
87398 +++ b/net/netfilter/Makefile
87399 @@ -109,6 +109,7 @@ obj-$(CONFIG_NETFILTER_XT_MATCH_DEVGROUP) += xt_devgroup.o
87400 obj-$(CONFIG_NETFILTER_XT_MATCH_DSCP) += xt_dscp.o
87401 obj-$(CONFIG_NETFILTER_XT_MATCH_ECN) += xt_ecn.o
87402 obj-$(CONFIG_NETFILTER_XT_MATCH_ESP) += xt_esp.o
87403 +obj-$(CONFIG_NETFILTER_XT_MATCH_GRADM) += xt_gradm.o
87404 obj-$(CONFIG_NETFILTER_XT_MATCH_HASHLIMIT) += xt_hashlimit.o
87405 obj-$(CONFIG_NETFILTER_XT_MATCH_HELPER) += xt_helper.o
87406 obj-$(CONFIG_NETFILTER_XT_MATCH_HL) += xt_hl.o
87407 diff --git a/net/netfilter/ipset/ip_set_core.c b/net/netfilter/ipset/ip_set_core.c
87408 index 6d6d8f2..a676749 100644
87409 --- a/net/netfilter/ipset/ip_set_core.c
87410 +++ b/net/netfilter/ipset/ip_set_core.c
87411 @@ -1800,7 +1800,7 @@ done:
87412 return ret;
87413 }
87414
87415 -static struct nf_sockopt_ops so_set __read_mostly = {
87416 +static struct nf_sockopt_ops so_set = {
87417 .pf = PF_INET,
87418 .get_optmin = SO_IP_SET,
87419 .get_optmax = SO_IP_SET + 1,
87420 diff --git a/net/netfilter/ipvs/ip_vs_conn.c b/net/netfilter/ipvs/ip_vs_conn.c
87421 index 30e764a..c3b6a9d 100644
87422 --- a/net/netfilter/ipvs/ip_vs_conn.c
87423 +++ b/net/netfilter/ipvs/ip_vs_conn.c
87424 @@ -554,7 +554,7 @@ ip_vs_bind_dest(struct ip_vs_conn *cp, struct ip_vs_dest *dest)
87425 /* Increase the refcnt counter of the dest */
87426 atomic_inc(&dest->refcnt);
87427
87428 - conn_flags = atomic_read(&dest->conn_flags);
87429 + conn_flags = atomic_read_unchecked(&dest->conn_flags);
87430 if (cp->protocol != IPPROTO_UDP)
87431 conn_flags &= ~IP_VS_CONN_F_ONE_PACKET;
87432 flags = cp->flags;
87433 @@ -899,7 +899,7 @@ ip_vs_conn_new(const struct ip_vs_conn_param *p,
87434 atomic_set(&cp->refcnt, 1);
87435
87436 atomic_set(&cp->n_control, 0);
87437 - atomic_set(&cp->in_pkts, 0);
87438 + atomic_set_unchecked(&cp->in_pkts, 0);
87439
87440 atomic_inc(&ipvs->conn_count);
87441 if (flags & IP_VS_CONN_F_NO_CPORT)
87442 @@ -1180,7 +1180,7 @@ static inline int todrop_entry(struct ip_vs_conn *cp)
87443
87444 /* Don't drop the entry if its number of incoming packets is not
87445 located in [0, 8] */
87446 - i = atomic_read(&cp->in_pkts);
87447 + i = atomic_read_unchecked(&cp->in_pkts);
87448 if (i > 8 || i < 0) return 0;
87449
87450 if (!todrop_rate[i]) return 0;
87451 diff --git a/net/netfilter/ipvs/ip_vs_core.c b/net/netfilter/ipvs/ip_vs_core.c
87452 index 47edf5a..235b07d 100644
87453 --- a/net/netfilter/ipvs/ip_vs_core.c
87454 +++ b/net/netfilter/ipvs/ip_vs_core.c
87455 @@ -559,7 +559,7 @@ int ip_vs_leave(struct ip_vs_service *svc, struct sk_buff *skb,
87456 ret = cp->packet_xmit(skb, cp, pd->pp, iph);
87457 /* do not touch skb anymore */
87458
87459 - atomic_inc(&cp->in_pkts);
87460 + atomic_inc_unchecked(&cp->in_pkts);
87461 ip_vs_conn_put(cp);
87462 return ret;
87463 }
87464 @@ -1691,7 +1691,7 @@ ip_vs_in(unsigned int hooknum, struct sk_buff *skb, int af)
87465 if (cp->flags & IP_VS_CONN_F_ONE_PACKET)
87466 pkts = sysctl_sync_threshold(ipvs);
87467 else
87468 - pkts = atomic_add_return(1, &cp->in_pkts);
87469 + pkts = atomic_add_return_unchecked(1, &cp->in_pkts);
87470
87471 if (ipvs->sync_state & IP_VS_STATE_MASTER)
87472 ip_vs_sync_conn(net, cp, pkts);
87473 diff --git a/net/netfilter/ipvs/ip_vs_ctl.c b/net/netfilter/ipvs/ip_vs_ctl.c
87474 index ec664cb..7f34a77 100644
87475 --- a/net/netfilter/ipvs/ip_vs_ctl.c
87476 +++ b/net/netfilter/ipvs/ip_vs_ctl.c
87477 @@ -787,7 +787,7 @@ __ip_vs_update_dest(struct ip_vs_service *svc, struct ip_vs_dest *dest,
87478 ip_vs_rs_hash(ipvs, dest);
87479 write_unlock_bh(&ipvs->rs_lock);
87480 }
87481 - atomic_set(&dest->conn_flags, conn_flags);
87482 + atomic_set_unchecked(&dest->conn_flags, conn_flags);
87483
87484 /* bind the service */
87485 if (!dest->svc) {
87486 @@ -1688,7 +1688,7 @@ proc_do_sync_ports(ctl_table *table, int write,
87487 * align with netns init in ip_vs_control_net_init()
87488 */
87489
87490 -static struct ctl_table vs_vars[] = {
87491 +static ctl_table_no_const vs_vars[] __read_only = {
87492 {
87493 .procname = "amemthresh",
87494 .maxlen = sizeof(int),
87495 @@ -2081,7 +2081,7 @@ static int ip_vs_info_seq_show(struct seq_file *seq, void *v)
87496 " %-7s %-6d %-10d %-10d\n",
87497 &dest->addr.in6,
87498 ntohs(dest->port),
87499 - ip_vs_fwd_name(atomic_read(&dest->conn_flags)),
87500 + ip_vs_fwd_name(atomic_read_unchecked(&dest->conn_flags)),
87501 atomic_read(&dest->weight),
87502 atomic_read(&dest->activeconns),
87503 atomic_read(&dest->inactconns));
87504 @@ -2092,7 +2092,7 @@ static int ip_vs_info_seq_show(struct seq_file *seq, void *v)
87505 "%-7s %-6d %-10d %-10d\n",
87506 ntohl(dest->addr.ip),
87507 ntohs(dest->port),
87508 - ip_vs_fwd_name(atomic_read(&dest->conn_flags)),
87509 + ip_vs_fwd_name(atomic_read_unchecked(&dest->conn_flags)),
87510 atomic_read(&dest->weight),
87511 atomic_read(&dest->activeconns),
87512 atomic_read(&dest->inactconns));
87513 @@ -2562,7 +2562,7 @@ __ip_vs_get_dest_entries(struct net *net, const struct ip_vs_get_dests *get,
87514
87515 entry.addr = dest->addr.ip;
87516 entry.port = dest->port;
87517 - entry.conn_flags = atomic_read(&dest->conn_flags);
87518 + entry.conn_flags = atomic_read_unchecked(&dest->conn_flags);
87519 entry.weight = atomic_read(&dest->weight);
87520 entry.u_threshold = dest->u_threshold;
87521 entry.l_threshold = dest->l_threshold;
87522 @@ -3098,7 +3098,7 @@ static int ip_vs_genl_fill_dest(struct sk_buff *skb, struct ip_vs_dest *dest)
87523 if (nla_put(skb, IPVS_DEST_ATTR_ADDR, sizeof(dest->addr), &dest->addr) ||
87524 nla_put_u16(skb, IPVS_DEST_ATTR_PORT, dest->port) ||
87525 nla_put_u32(skb, IPVS_DEST_ATTR_FWD_METHOD,
87526 - (atomic_read(&dest->conn_flags) &
87527 + (atomic_read_unchecked(&dest->conn_flags) &
87528 IP_VS_CONN_F_FWD_MASK)) ||
87529 nla_put_u32(skb, IPVS_DEST_ATTR_WEIGHT,
87530 atomic_read(&dest->weight)) ||
87531 @@ -3688,7 +3688,7 @@ static int __net_init ip_vs_control_net_init_sysctl(struct net *net)
87532 {
87533 int idx;
87534 struct netns_ipvs *ipvs = net_ipvs(net);
87535 - struct ctl_table *tbl;
87536 + ctl_table_no_const *tbl;
87537
87538 atomic_set(&ipvs->dropentry, 0);
87539 spin_lock_init(&ipvs->dropentry_lock);
87540 diff --git a/net/netfilter/ipvs/ip_vs_lblc.c b/net/netfilter/ipvs/ip_vs_lblc.c
87541 index fdd89b9..bd96aa9 100644
87542 --- a/net/netfilter/ipvs/ip_vs_lblc.c
87543 +++ b/net/netfilter/ipvs/ip_vs_lblc.c
87544 @@ -115,7 +115,7 @@ struct ip_vs_lblc_table {
87545 * IPVS LBLC sysctl table
87546 */
87547 #ifdef CONFIG_SYSCTL
87548 -static ctl_table vs_vars_table[] = {
87549 +static ctl_table_no_const vs_vars_table[] __read_only = {
87550 {
87551 .procname = "lblc_expiration",
87552 .data = NULL,
87553 diff --git a/net/netfilter/ipvs/ip_vs_lblcr.c b/net/netfilter/ipvs/ip_vs_lblcr.c
87554 index c03b6a3..8ce3681 100644
87555 --- a/net/netfilter/ipvs/ip_vs_lblcr.c
87556 +++ b/net/netfilter/ipvs/ip_vs_lblcr.c
87557 @@ -288,7 +288,7 @@ struct ip_vs_lblcr_table {
87558 * IPVS LBLCR sysctl table
87559 */
87560
87561 -static ctl_table vs_vars_table[] = {
87562 +static ctl_table_no_const vs_vars_table[] __read_only = {
87563 {
87564 .procname = "lblcr_expiration",
87565 .data = NULL,
87566 diff --git a/net/netfilter/ipvs/ip_vs_sync.c b/net/netfilter/ipvs/ip_vs_sync.c
87567 index 44fd10c..2a163b3 100644
87568 --- a/net/netfilter/ipvs/ip_vs_sync.c
87569 +++ b/net/netfilter/ipvs/ip_vs_sync.c
87570 @@ -596,7 +596,7 @@ static void ip_vs_sync_conn_v0(struct net *net, struct ip_vs_conn *cp,
87571 cp = cp->control;
87572 if (cp) {
87573 if (cp->flags & IP_VS_CONN_F_TEMPLATE)
87574 - pkts = atomic_add_return(1, &cp->in_pkts);
87575 + pkts = atomic_add_return_unchecked(1, &cp->in_pkts);
87576 else
87577 pkts = sysctl_sync_threshold(ipvs);
87578 ip_vs_sync_conn(net, cp->control, pkts);
87579 @@ -758,7 +758,7 @@ control:
87580 if (!cp)
87581 return;
87582 if (cp->flags & IP_VS_CONN_F_TEMPLATE)
87583 - pkts = atomic_add_return(1, &cp->in_pkts);
87584 + pkts = atomic_add_return_unchecked(1, &cp->in_pkts);
87585 else
87586 pkts = sysctl_sync_threshold(ipvs);
87587 goto sloop;
87588 @@ -885,7 +885,7 @@ static void ip_vs_proc_conn(struct net *net, struct ip_vs_conn_param *param,
87589
87590 if (opt)
87591 memcpy(&cp->in_seq, opt, sizeof(*opt));
87592 - atomic_set(&cp->in_pkts, sysctl_sync_threshold(ipvs));
87593 + atomic_set_unchecked(&cp->in_pkts, sysctl_sync_threshold(ipvs));
87594 cp->state = state;
87595 cp->old_state = cp->state;
87596 /*
87597 diff --git a/net/netfilter/ipvs/ip_vs_xmit.c b/net/netfilter/ipvs/ip_vs_xmit.c
87598 index ee6b7a9..f9a89f6 100644
87599 --- a/net/netfilter/ipvs/ip_vs_xmit.c
87600 +++ b/net/netfilter/ipvs/ip_vs_xmit.c
87601 @@ -1210,7 +1210,7 @@ ip_vs_icmp_xmit(struct sk_buff *skb, struct ip_vs_conn *cp,
87602 else
87603 rc = NF_ACCEPT;
87604 /* do not touch skb anymore */
87605 - atomic_inc(&cp->in_pkts);
87606 + atomic_inc_unchecked(&cp->in_pkts);
87607 goto out;
87608 }
87609
87610 @@ -1332,7 +1332,7 @@ ip_vs_icmp_xmit_v6(struct sk_buff *skb, struct ip_vs_conn *cp,
87611 else
87612 rc = NF_ACCEPT;
87613 /* do not touch skb anymore */
87614 - atomic_inc(&cp->in_pkts);
87615 + atomic_inc_unchecked(&cp->in_pkts);
87616 goto out;
87617 }
87618
87619 diff --git a/net/netfilter/nf_conntrack_acct.c b/net/netfilter/nf_conntrack_acct.c
87620 index 7df424e..a527b02 100644
87621 --- a/net/netfilter/nf_conntrack_acct.c
87622 +++ b/net/netfilter/nf_conntrack_acct.c
87623 @@ -60,7 +60,7 @@ static struct nf_ct_ext_type acct_extend __read_mostly = {
87624 #ifdef CONFIG_SYSCTL
87625 static int nf_conntrack_acct_init_sysctl(struct net *net)
87626 {
87627 - struct ctl_table *table;
87628 + ctl_table_no_const *table;
87629
87630 table = kmemdup(acct_sysctl_table, sizeof(acct_sysctl_table),
87631 GFP_KERNEL);
87632 diff --git a/net/netfilter/nf_conntrack_core.c b/net/netfilter/nf_conntrack_core.c
87633 index e4a0c4f..c263f28 100644
87634 --- a/net/netfilter/nf_conntrack_core.c
87635 +++ b/net/netfilter/nf_conntrack_core.c
87636 @@ -1529,6 +1529,10 @@ err_extend:
87637 #define DYING_NULLS_VAL ((1<<30)+1)
87638 #define TEMPLATE_NULLS_VAL ((1<<30)+2)
87639
87640 +#ifdef CONFIG_GRKERNSEC_HIDESYM
87641 +static atomic_unchecked_t conntrack_cache_id = ATOMIC_INIT(0);
87642 +#endif
87643 +
87644 static int nf_conntrack_init_net(struct net *net)
87645 {
87646 int ret;
87647 @@ -1543,7 +1547,11 @@ static int nf_conntrack_init_net(struct net *net)
87648 goto err_stat;
87649 }
87650
87651 +#ifdef CONFIG_GRKERNSEC_HIDESYM
87652 + net->ct.slabname = kasprintf(GFP_KERNEL, "nf_conntrack_%08lx", atomic_inc_return_unchecked(&conntrack_cache_id));
87653 +#else
87654 net->ct.slabname = kasprintf(GFP_KERNEL, "nf_conntrack_%p", net);
87655 +#endif
87656 if (!net->ct.slabname) {
87657 ret = -ENOMEM;
87658 goto err_slabname;
87659 diff --git a/net/netfilter/nf_conntrack_ecache.c b/net/netfilter/nf_conntrack_ecache.c
87660 index faa978f..1afb18f 100644
87661 --- a/net/netfilter/nf_conntrack_ecache.c
87662 +++ b/net/netfilter/nf_conntrack_ecache.c
87663 @@ -186,7 +186,7 @@ static struct nf_ct_ext_type event_extend __read_mostly = {
87664 #ifdef CONFIG_SYSCTL
87665 static int nf_conntrack_event_init_sysctl(struct net *net)
87666 {
87667 - struct ctl_table *table;
87668 + ctl_table_no_const *table;
87669
87670 table = kmemdup(event_sysctl_table, sizeof(event_sysctl_table),
87671 GFP_KERNEL);
87672 diff --git a/net/netfilter/nf_conntrack_helper.c b/net/netfilter/nf_conntrack_helper.c
87673 index 884f2b3..d53b33a 100644
87674 --- a/net/netfilter/nf_conntrack_helper.c
87675 +++ b/net/netfilter/nf_conntrack_helper.c
87676 @@ -55,7 +55,7 @@ static struct ctl_table helper_sysctl_table[] = {
87677
87678 static int nf_conntrack_helper_init_sysctl(struct net *net)
87679 {
87680 - struct ctl_table *table;
87681 + ctl_table_no_const *table;
87682
87683 table = kmemdup(helper_sysctl_table, sizeof(helper_sysctl_table),
87684 GFP_KERNEL);
87685 diff --git a/net/netfilter/nf_conntrack_proto.c b/net/netfilter/nf_conntrack_proto.c
87686 index 51e928d..72a413a 100644
87687 --- a/net/netfilter/nf_conntrack_proto.c
87688 +++ b/net/netfilter/nf_conntrack_proto.c
87689 @@ -51,7 +51,7 @@ nf_ct_register_sysctl(struct net *net,
87690
87691 static void
87692 nf_ct_unregister_sysctl(struct ctl_table_header **header,
87693 - struct ctl_table **table,
87694 + ctl_table_no_const **table,
87695 unsigned int users)
87696 {
87697 if (users > 0)
87698 diff --git a/net/netfilter/nf_conntrack_standalone.c b/net/netfilter/nf_conntrack_standalone.c
87699 index e7185c6..4ad6c9c 100644
87700 --- a/net/netfilter/nf_conntrack_standalone.c
87701 +++ b/net/netfilter/nf_conntrack_standalone.c
87702 @@ -470,7 +470,7 @@ static ctl_table nf_ct_netfilter_table[] = {
87703
87704 static int nf_conntrack_standalone_init_sysctl(struct net *net)
87705 {
87706 - struct ctl_table *table;
87707 + ctl_table_no_const *table;
87708
87709 if (net_eq(net, &init_net)) {
87710 nf_ct_netfilter_header =
87711 diff --git a/net/netfilter/nf_conntrack_timestamp.c b/net/netfilter/nf_conntrack_timestamp.c
87712 index 7ea8026..bc9512d 100644
87713 --- a/net/netfilter/nf_conntrack_timestamp.c
87714 +++ b/net/netfilter/nf_conntrack_timestamp.c
87715 @@ -42,7 +42,7 @@ static struct nf_ct_ext_type tstamp_extend __read_mostly = {
87716 #ifdef CONFIG_SYSCTL
87717 static int nf_conntrack_tstamp_init_sysctl(struct net *net)
87718 {
87719 - struct ctl_table *table;
87720 + ctl_table_no_const *table;
87721
87722 table = kmemdup(tstamp_sysctl_table, sizeof(tstamp_sysctl_table),
87723 GFP_KERNEL);
87724 diff --git a/net/netfilter/nf_log.c b/net/netfilter/nf_log.c
87725 index 9e31269..bc4c1b7 100644
87726 --- a/net/netfilter/nf_log.c
87727 +++ b/net/netfilter/nf_log.c
87728 @@ -215,7 +215,7 @@ static const struct file_operations nflog_file_ops = {
87729
87730 #ifdef CONFIG_SYSCTL
87731 static char nf_log_sysctl_fnames[NFPROTO_NUMPROTO-NFPROTO_UNSPEC][3];
87732 -static struct ctl_table nf_log_sysctl_table[NFPROTO_NUMPROTO+1];
87733 +static ctl_table_no_const nf_log_sysctl_table[NFPROTO_NUMPROTO+1] __read_only;
87734 static struct ctl_table_header *nf_log_dir_header;
87735
87736 static int nf_log_proc_dostring(ctl_table *table, int write,
87737 @@ -246,14 +246,16 @@ static int nf_log_proc_dostring(ctl_table *table, int write,
87738 rcu_assign_pointer(nf_loggers[tindex], logger);
87739 mutex_unlock(&nf_log_mutex);
87740 } else {
87741 + ctl_table_no_const nf_log_table = *table;
87742 +
87743 mutex_lock(&nf_log_mutex);
87744 logger = rcu_dereference_protected(nf_loggers[tindex],
87745 lockdep_is_held(&nf_log_mutex));
87746 if (!logger)
87747 - table->data = "NONE";
87748 + nf_log_table.data = "NONE";
87749 else
87750 - table->data = logger->name;
87751 - r = proc_dostring(table, write, buffer, lenp, ppos);
87752 + nf_log_table.data = logger->name;
87753 + r = proc_dostring(&nf_log_table, write, buffer, lenp, ppos);
87754 mutex_unlock(&nf_log_mutex);
87755 }
87756
87757 diff --git a/net/netfilter/nf_sockopt.c b/net/netfilter/nf_sockopt.c
87758 index f042ae5..30ea486 100644
87759 --- a/net/netfilter/nf_sockopt.c
87760 +++ b/net/netfilter/nf_sockopt.c
87761 @@ -45,7 +45,7 @@ int nf_register_sockopt(struct nf_sockopt_ops *reg)
87762 }
87763 }
87764
87765 - list_add(&reg->list, &nf_sockopts);
87766 + pax_list_add((struct list_head *)&reg->list, &nf_sockopts);
87767 out:
87768 mutex_unlock(&nf_sockopt_mutex);
87769 return ret;
87770 @@ -55,7 +55,7 @@ EXPORT_SYMBOL(nf_register_sockopt);
87771 void nf_unregister_sockopt(struct nf_sockopt_ops *reg)
87772 {
87773 mutex_lock(&nf_sockopt_mutex);
87774 - list_del(&reg->list);
87775 + pax_list_del((struct list_head *)&reg->list);
87776 mutex_unlock(&nf_sockopt_mutex);
87777 }
87778 EXPORT_SYMBOL(nf_unregister_sockopt);
87779 diff --git a/net/netfilter/nfnetlink_log.c b/net/netfilter/nfnetlink_log.c
87780 index 92fd8ec..3f6ea4b 100644
87781 --- a/net/netfilter/nfnetlink_log.c
87782 +++ b/net/netfilter/nfnetlink_log.c
87783 @@ -72,7 +72,7 @@ struct nfulnl_instance {
87784 };
87785
87786 static DEFINE_SPINLOCK(instances_lock);
87787 -static atomic_t global_seq;
87788 +static atomic_unchecked_t global_seq;
87789
87790 #define INSTANCE_BUCKETS 16
87791 static struct hlist_head instance_table[INSTANCE_BUCKETS];
87792 @@ -537,7 +537,7 @@ __build_packet_message(struct nfulnl_instance *inst,
87793 /* global sequence number */
87794 if ((inst->flags & NFULNL_CFG_F_SEQ_GLOBAL) &&
87795 nla_put_be32(inst->skb, NFULA_SEQ_GLOBAL,
87796 - htonl(atomic_inc_return(&global_seq))))
87797 + htonl(atomic_inc_return_unchecked(&global_seq))))
87798 goto nla_put_failure;
87799
87800 if (data_len) {
87801 diff --git a/net/netfilter/xt_gradm.c b/net/netfilter/xt_gradm.c
87802 new file mode 100644
87803 index 0000000..c566332
87804 --- /dev/null
87805 +++ b/net/netfilter/xt_gradm.c
87806 @@ -0,0 +1,51 @@
87807 +/*
87808 + * gradm match for netfilter
87809 + * Copyright © Zbigniew Krzystolik, 2010
87810 + *
87811 + * This program is free software; you can redistribute it and/or modify
87812 + * it under the terms of the GNU General Public License; either version
87813 + * 2 or 3 as published by the Free Software Foundation.
87814 + */
87815 +#include <linux/module.h>
87816 +#include <linux/moduleparam.h>
87817 +#include <linux/skbuff.h>
87818 +#include <linux/netfilter/x_tables.h>
87819 +#include <linux/grsecurity.h>
87820 +#include <linux/netfilter/xt_gradm.h>
87821 +
87822 +static bool
87823 +gradm_mt(const struct sk_buff *skb, struct xt_action_param *par)
87824 +{
87825 + const struct xt_gradm_mtinfo *info = par->matchinfo;
87826 + bool retval = false;
87827 + if (gr_acl_is_enabled())
87828 + retval = true;
87829 + return retval ^ info->invflags;
87830 +}
87831 +
87832 +static struct xt_match gradm_mt_reg __read_mostly = {
87833 + .name = "gradm",
87834 + .revision = 0,
87835 + .family = NFPROTO_UNSPEC,
87836 + .match = gradm_mt,
87837 + .matchsize = XT_ALIGN(sizeof(struct xt_gradm_mtinfo)),
87838 + .me = THIS_MODULE,
87839 +};
87840 +
87841 +static int __init gradm_mt_init(void)
87842 +{
87843 + return xt_register_match(&gradm_mt_reg);
87844 +}
87845 +
87846 +static void __exit gradm_mt_exit(void)
87847 +{
87848 + xt_unregister_match(&gradm_mt_reg);
87849 +}
87850 +
87851 +module_init(gradm_mt_init);
87852 +module_exit(gradm_mt_exit);
87853 +MODULE_AUTHOR("Zbigniew Krzystolik <zbyniu@destrukcja.pl>");
87854 +MODULE_DESCRIPTION("Xtables: Grsecurity RBAC match");
87855 +MODULE_LICENSE("GPL");
87856 +MODULE_ALIAS("ipt_gradm");
87857 +MODULE_ALIAS("ip6t_gradm");
87858 diff --git a/net/netfilter/xt_statistic.c b/net/netfilter/xt_statistic.c
87859 index 4fe4fb4..87a89e5 100644
87860 --- a/net/netfilter/xt_statistic.c
87861 +++ b/net/netfilter/xt_statistic.c
87862 @@ -19,7 +19,7 @@
87863 #include <linux/module.h>
87864
87865 struct xt_statistic_priv {
87866 - atomic_t count;
87867 + atomic_unchecked_t count;
87868 } ____cacheline_aligned_in_smp;
87869
87870 MODULE_LICENSE("GPL");
87871 @@ -42,9 +42,9 @@ statistic_mt(const struct sk_buff *skb, struct xt_action_param *par)
87872 break;
87873 case XT_STATISTIC_MODE_NTH:
87874 do {
87875 - oval = atomic_read(&info->master->count);
87876 + oval = atomic_read_unchecked(&info->master->count);
87877 nval = (oval == info->u.nth.every) ? 0 : oval + 1;
87878 - } while (atomic_cmpxchg(&info->master->count, oval, nval) != oval);
87879 + } while (atomic_cmpxchg_unchecked(&info->master->count, oval, nval) != oval);
87880 if (nval == 0)
87881 ret = !ret;
87882 break;
87883 @@ -64,7 +64,7 @@ static int statistic_mt_check(const struct xt_mtchk_param *par)
87884 info->master = kzalloc(sizeof(*info->master), GFP_KERNEL);
87885 if (info->master == NULL)
87886 return -ENOMEM;
87887 - atomic_set(&info->master->count, info->u.nth.count);
87888 + atomic_set_unchecked(&info->master->count, info->u.nth.count);
87889
87890 return 0;
87891 }
87892 diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
87893 index c0353d5..fcb0270 100644
87894 --- a/net/netlink/af_netlink.c
87895 +++ b/net/netlink/af_netlink.c
87896 @@ -785,7 +785,7 @@ static void netlink_overrun(struct sock *sk)
87897 sk->sk_error_report(sk);
87898 }
87899 }
87900 - atomic_inc(&sk->sk_drops);
87901 + atomic_inc_unchecked(&sk->sk_drops);
87902 }
87903
87904 static struct sock *netlink_getsockbyportid(struct sock *ssk, u32 portid)
87905 @@ -2071,7 +2071,7 @@ static int netlink_seq_show(struct seq_file *seq, void *v)
87906 sk_wmem_alloc_get(s),
87907 nlk->cb,
87908 atomic_read(&s->sk_refcnt),
87909 - atomic_read(&s->sk_drops),
87910 + atomic_read_unchecked(&s->sk_drops),
87911 sock_i_ino(s)
87912 );
87913
87914 diff --git a/net/netlink/genetlink.c b/net/netlink/genetlink.c
87915 index f2aabb6..2e5e66e 100644
87916 --- a/net/netlink/genetlink.c
87917 +++ b/net/netlink/genetlink.c
87918 @@ -295,18 +295,20 @@ int genl_register_ops(struct genl_family *family, struct genl_ops *ops)
87919 goto errout;
87920 }
87921
87922 + pax_open_kernel();
87923 if (ops->dumpit)
87924 - ops->flags |= GENL_CMD_CAP_DUMP;
87925 + *(unsigned int *)&ops->flags |= GENL_CMD_CAP_DUMP;
87926 if (ops->doit)
87927 - ops->flags |= GENL_CMD_CAP_DO;
87928 + *(unsigned int *)&ops->flags |= GENL_CMD_CAP_DO;
87929 if (ops->policy)
87930 - ops->flags |= GENL_CMD_CAP_HASPOL;
87931 + *(unsigned int *)&ops->flags |= GENL_CMD_CAP_HASPOL;
87932 + pax_close_kernel();
87933
87934 genl_lock();
87935 - list_add_tail(&ops->ops_list, &family->ops_list);
87936 + pax_list_add_tail((struct list_head *)&ops->ops_list, &family->ops_list);
87937 genl_unlock();
87938
87939 - genl_ctrl_event(CTRL_CMD_NEWOPS, ops);
87940 + genl_ctrl_event(CTRL_CMD_NEWOPS, (void *)ops);
87941 err = 0;
87942 errout:
87943 return err;
87944 @@ -336,9 +338,9 @@ int genl_unregister_ops(struct genl_family *family, struct genl_ops *ops)
87945 genl_lock();
87946 list_for_each_entry(rc, &family->ops_list, ops_list) {
87947 if (rc == ops) {
87948 - list_del(&ops->ops_list);
87949 + pax_list_del((struct list_head *)&ops->ops_list);
87950 genl_unlock();
87951 - genl_ctrl_event(CTRL_CMD_DELOPS, ops);
87952 + genl_ctrl_event(CTRL_CMD_DELOPS, (void *)ops);
87953 return 0;
87954 }
87955 }
87956 diff --git a/net/netrom/af_netrom.c b/net/netrom/af_netrom.c
87957 index 7261eb8..44e8ac6 100644
87958 --- a/net/netrom/af_netrom.c
87959 +++ b/net/netrom/af_netrom.c
87960 @@ -838,6 +838,7 @@ static int nr_getname(struct socket *sock, struct sockaddr *uaddr,
87961 struct sock *sk = sock->sk;
87962 struct nr_sock *nr = nr_sk(sk);
87963
87964 + memset(sax, 0, sizeof(*sax));
87965 lock_sock(sk);
87966 if (peer != 0) {
87967 if (sk->sk_state != TCP_ESTABLISHED) {
87968 @@ -852,7 +853,6 @@ static int nr_getname(struct socket *sock, struct sockaddr *uaddr,
87969 *uaddr_len = sizeof(struct full_sockaddr_ax25);
87970 } else {
87971 sax->fsa_ax25.sax25_family = AF_NETROM;
87972 - sax->fsa_ax25.sax25_ndigis = 0;
87973 sax->fsa_ax25.sax25_call = nr->source_addr;
87974 *uaddr_len = sizeof(struct sockaddr_ax25);
87975 }
87976 diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
87977 index c111bd0..7788ff7 100644
87978 --- a/net/packet/af_packet.c
87979 +++ b/net/packet/af_packet.c
87980 @@ -1578,7 +1578,7 @@ static int packet_rcv(struct sk_buff *skb, struct net_device *dev,
87981
87982 spin_lock(&sk->sk_receive_queue.lock);
87983 po->stats.tp_packets++;
87984 - skb->dropcount = atomic_read(&sk->sk_drops);
87985 + skb->dropcount = atomic_read_unchecked(&sk->sk_drops);
87986 __skb_queue_tail(&sk->sk_receive_queue, skb);
87987 spin_unlock(&sk->sk_receive_queue.lock);
87988 sk->sk_data_ready(sk, skb->len);
87989 @@ -1587,7 +1587,7 @@ static int packet_rcv(struct sk_buff *skb, struct net_device *dev,
87990 drop_n_acct:
87991 spin_lock(&sk->sk_receive_queue.lock);
87992 po->stats.tp_drops++;
87993 - atomic_inc(&sk->sk_drops);
87994 + atomic_inc_unchecked(&sk->sk_drops);
87995 spin_unlock(&sk->sk_receive_queue.lock);
87996
87997 drop_n_restore:
87998 @@ -2565,6 +2565,7 @@ out:
87999
88000 static int packet_recv_error(struct sock *sk, struct msghdr *msg, int len)
88001 {
88002 + struct sock_extended_err ee;
88003 struct sock_exterr_skb *serr;
88004 struct sk_buff *skb, *skb2;
88005 int copied, err;
88006 @@ -2586,8 +2587,9 @@ static int packet_recv_error(struct sock *sk, struct msghdr *msg, int len)
88007 sock_recv_timestamp(msg, sk, skb);
88008
88009 serr = SKB_EXT_ERR(skb);
88010 + ee = serr->ee;
88011 put_cmsg(msg, SOL_PACKET, PACKET_TX_TIMESTAMP,
88012 - sizeof(serr->ee), &serr->ee);
88013 + sizeof ee, &ee);
88014
88015 msg->msg_flags |= MSG_ERRQUEUE;
88016 err = copied;
88017 @@ -3212,7 +3214,7 @@ static int packet_getsockopt(struct socket *sock, int level, int optname,
88018 case PACKET_HDRLEN:
88019 if (len > sizeof(int))
88020 len = sizeof(int);
88021 - if (copy_from_user(&val, optval, len))
88022 + if (len > sizeof(val) || copy_from_user(&val, optval, len))
88023 return -EFAULT;
88024 switch (val) {
88025 case TPACKET_V1:
88026 @@ -3254,7 +3256,7 @@ static int packet_getsockopt(struct socket *sock, int level, int optname,
88027 len = lv;
88028 if (put_user(len, optlen))
88029 return -EFAULT;
88030 - if (copy_to_user(optval, data, len))
88031 + if (len > sizeof(st) || copy_to_user(optval, data, len))
88032 return -EFAULT;
88033 return 0;
88034 }
88035 diff --git a/net/phonet/af_phonet.c b/net/phonet/af_phonet.c
88036 index 5a940db..f0b9c12 100644
88037 --- a/net/phonet/af_phonet.c
88038 +++ b/net/phonet/af_phonet.c
88039 @@ -41,7 +41,7 @@ static struct phonet_protocol *phonet_proto_get(unsigned int protocol)
88040 {
88041 struct phonet_protocol *pp;
88042
88043 - if (protocol >= PHONET_NPROTO)
88044 + if (protocol < 0 || protocol >= PHONET_NPROTO)
88045 return NULL;
88046
88047 rcu_read_lock();
88048 @@ -469,7 +469,7 @@ int __init_or_module phonet_proto_register(unsigned int protocol,
88049 {
88050 int err = 0;
88051
88052 - if (protocol >= PHONET_NPROTO)
88053 + if (protocol < 0 || protocol >= PHONET_NPROTO)
88054 return -EINVAL;
88055
88056 err = proto_register(pp->prot, 1);
88057 diff --git a/net/phonet/pep.c b/net/phonet/pep.c
88058 index 576f22c..bc7a71b 100644
88059 --- a/net/phonet/pep.c
88060 +++ b/net/phonet/pep.c
88061 @@ -388,7 +388,7 @@ static int pipe_do_rcv(struct sock *sk, struct sk_buff *skb)
88062
88063 case PNS_PEP_CTRL_REQ:
88064 if (skb_queue_len(&pn->ctrlreq_queue) >= PNPIPE_CTRLREQ_MAX) {
88065 - atomic_inc(&sk->sk_drops);
88066 + atomic_inc_unchecked(&sk->sk_drops);
88067 break;
88068 }
88069 __skb_pull(skb, 4);
88070 @@ -409,7 +409,7 @@ static int pipe_do_rcv(struct sock *sk, struct sk_buff *skb)
88071 }
88072
88073 if (pn->rx_credits == 0) {
88074 - atomic_inc(&sk->sk_drops);
88075 + atomic_inc_unchecked(&sk->sk_drops);
88076 err = -ENOBUFS;
88077 break;
88078 }
88079 @@ -580,7 +580,7 @@ static int pipe_handler_do_rcv(struct sock *sk, struct sk_buff *skb)
88080 }
88081
88082 if (pn->rx_credits == 0) {
88083 - atomic_inc(&sk->sk_drops);
88084 + atomic_inc_unchecked(&sk->sk_drops);
88085 err = NET_RX_DROP;
88086 break;
88087 }
88088 diff --git a/net/phonet/socket.c b/net/phonet/socket.c
88089 index b7e9827..c264c85 100644
88090 --- a/net/phonet/socket.c
88091 +++ b/net/phonet/socket.c
88092 @@ -615,7 +615,7 @@ static int pn_sock_seq_show(struct seq_file *seq, void *v)
88093 from_kuid_munged(seq_user_ns(seq), sock_i_uid(sk)),
88094 sock_i_ino(sk),
88095 atomic_read(&sk->sk_refcnt), sk,
88096 - atomic_read(&sk->sk_drops), &len);
88097 + atomic_read_unchecked(&sk->sk_drops), &len);
88098 }
88099 seq_printf(seq, "%*s\n", 127 - len, "");
88100 return 0;
88101 diff --git a/net/phonet/sysctl.c b/net/phonet/sysctl.c
88102 index d6bbbbd..61561e4 100644
88103 --- a/net/phonet/sysctl.c
88104 +++ b/net/phonet/sysctl.c
88105 @@ -67,7 +67,7 @@ static int proc_local_port_range(ctl_table *table, int write,
88106 {
88107 int ret;
88108 int range[2] = {local_port_range[0], local_port_range[1]};
88109 - ctl_table tmp = {
88110 + ctl_table_no_const tmp = {
88111 .data = &range,
88112 .maxlen = sizeof(range),
88113 .mode = table->mode,
88114 diff --git a/net/rds/cong.c b/net/rds/cong.c
88115 index e5b65ac..f3b6fb7 100644
88116 --- a/net/rds/cong.c
88117 +++ b/net/rds/cong.c
88118 @@ -78,7 +78,7 @@
88119 * finds that the saved generation number is smaller than the global generation
88120 * number, it wakes up the process.
88121 */
88122 -static atomic_t rds_cong_generation = ATOMIC_INIT(0);
88123 +static atomic_unchecked_t rds_cong_generation = ATOMIC_INIT(0);
88124
88125 /*
88126 * Congestion monitoring
88127 @@ -233,7 +233,7 @@ void rds_cong_map_updated(struct rds_cong_map *map, uint64_t portmask)
88128 rdsdebug("waking map %p for %pI4\n",
88129 map, &map->m_addr);
88130 rds_stats_inc(s_cong_update_received);
88131 - atomic_inc(&rds_cong_generation);
88132 + atomic_inc_unchecked(&rds_cong_generation);
88133 if (waitqueue_active(&map->m_waitq))
88134 wake_up(&map->m_waitq);
88135 if (waitqueue_active(&rds_poll_waitq))
88136 @@ -259,7 +259,7 @@ EXPORT_SYMBOL_GPL(rds_cong_map_updated);
88137
88138 int rds_cong_updated_since(unsigned long *recent)
88139 {
88140 - unsigned long gen = atomic_read(&rds_cong_generation);
88141 + unsigned long gen = atomic_read_unchecked(&rds_cong_generation);
88142
88143 if (likely(*recent == gen))
88144 return 0;
88145 diff --git a/net/rds/ib.h b/net/rds/ib.h
88146 index 7280ab8..e04f4ea 100644
88147 --- a/net/rds/ib.h
88148 +++ b/net/rds/ib.h
88149 @@ -128,7 +128,7 @@ struct rds_ib_connection {
88150 /* sending acks */
88151 unsigned long i_ack_flags;
88152 #ifdef KERNEL_HAS_ATOMIC64
88153 - atomic64_t i_ack_next; /* next ACK to send */
88154 + atomic64_unchecked_t i_ack_next; /* next ACK to send */
88155 #else
88156 spinlock_t i_ack_lock; /* protect i_ack_next */
88157 u64 i_ack_next; /* next ACK to send */
88158 diff --git a/net/rds/ib_cm.c b/net/rds/ib_cm.c
88159 index 31b74f5..dc1fbfa 100644
88160 --- a/net/rds/ib_cm.c
88161 +++ b/net/rds/ib_cm.c
88162 @@ -717,7 +717,7 @@ void rds_ib_conn_shutdown(struct rds_connection *conn)
88163 /* Clear the ACK state */
88164 clear_bit(IB_ACK_IN_FLIGHT, &ic->i_ack_flags);
88165 #ifdef KERNEL_HAS_ATOMIC64
88166 - atomic64_set(&ic->i_ack_next, 0);
88167 + atomic64_set_unchecked(&ic->i_ack_next, 0);
88168 #else
88169 ic->i_ack_next = 0;
88170 #endif
88171 diff --git a/net/rds/ib_recv.c b/net/rds/ib_recv.c
88172 index 8eb9501..0c386ff 100644
88173 --- a/net/rds/ib_recv.c
88174 +++ b/net/rds/ib_recv.c
88175 @@ -597,7 +597,7 @@ static u64 rds_ib_get_ack(struct rds_ib_connection *ic)
88176 static void rds_ib_set_ack(struct rds_ib_connection *ic, u64 seq,
88177 int ack_required)
88178 {
88179 - atomic64_set(&ic->i_ack_next, seq);
88180 + atomic64_set_unchecked(&ic->i_ack_next, seq);
88181 if (ack_required) {
88182 smp_mb__before_clear_bit();
88183 set_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
88184 @@ -609,7 +609,7 @@ static u64 rds_ib_get_ack(struct rds_ib_connection *ic)
88185 clear_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
88186 smp_mb__after_clear_bit();
88187
88188 - return atomic64_read(&ic->i_ack_next);
88189 + return atomic64_read_unchecked(&ic->i_ack_next);
88190 }
88191 #endif
88192
88193 diff --git a/net/rds/iw.h b/net/rds/iw.h
88194 index 04ce3b1..48119a6 100644
88195 --- a/net/rds/iw.h
88196 +++ b/net/rds/iw.h
88197 @@ -134,7 +134,7 @@ struct rds_iw_connection {
88198 /* sending acks */
88199 unsigned long i_ack_flags;
88200 #ifdef KERNEL_HAS_ATOMIC64
88201 - atomic64_t i_ack_next; /* next ACK to send */
88202 + atomic64_unchecked_t i_ack_next; /* next ACK to send */
88203 #else
88204 spinlock_t i_ack_lock; /* protect i_ack_next */
88205 u64 i_ack_next; /* next ACK to send */
88206 diff --git a/net/rds/iw_cm.c b/net/rds/iw_cm.c
88207 index a91e1db..cf3053f 100644
88208 --- a/net/rds/iw_cm.c
88209 +++ b/net/rds/iw_cm.c
88210 @@ -663,7 +663,7 @@ void rds_iw_conn_shutdown(struct rds_connection *conn)
88211 /* Clear the ACK state */
88212 clear_bit(IB_ACK_IN_FLIGHT, &ic->i_ack_flags);
88213 #ifdef KERNEL_HAS_ATOMIC64
88214 - atomic64_set(&ic->i_ack_next, 0);
88215 + atomic64_set_unchecked(&ic->i_ack_next, 0);
88216 #else
88217 ic->i_ack_next = 0;
88218 #endif
88219 diff --git a/net/rds/iw_recv.c b/net/rds/iw_recv.c
88220 index 4503335..db566b4 100644
88221 --- a/net/rds/iw_recv.c
88222 +++ b/net/rds/iw_recv.c
88223 @@ -427,7 +427,7 @@ static u64 rds_iw_get_ack(struct rds_iw_connection *ic)
88224 static void rds_iw_set_ack(struct rds_iw_connection *ic, u64 seq,
88225 int ack_required)
88226 {
88227 - atomic64_set(&ic->i_ack_next, seq);
88228 + atomic64_set_unchecked(&ic->i_ack_next, seq);
88229 if (ack_required) {
88230 smp_mb__before_clear_bit();
88231 set_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
88232 @@ -439,7 +439,7 @@ static u64 rds_iw_get_ack(struct rds_iw_connection *ic)
88233 clear_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
88234 smp_mb__after_clear_bit();
88235
88236 - return atomic64_read(&ic->i_ack_next);
88237 + return atomic64_read_unchecked(&ic->i_ack_next);
88238 }
88239 #endif
88240
88241 diff --git a/net/rds/rds.h b/net/rds/rds.h
88242 index ec1d731..90a3a8d 100644
88243 --- a/net/rds/rds.h
88244 +++ b/net/rds/rds.h
88245 @@ -449,7 +449,7 @@ struct rds_transport {
88246 void (*sync_mr)(void *trans_private, int direction);
88247 void (*free_mr)(void *trans_private, int invalidate);
88248 void (*flush_mrs)(void);
88249 -};
88250 +} __do_const;
88251
88252 struct rds_sock {
88253 struct sock rs_sk;
88254 diff --git a/net/rds/tcp.c b/net/rds/tcp.c
88255 index edac9ef..16bcb98 100644
88256 --- a/net/rds/tcp.c
88257 +++ b/net/rds/tcp.c
88258 @@ -59,7 +59,7 @@ void rds_tcp_nonagle(struct socket *sock)
88259 int val = 1;
88260
88261 set_fs(KERNEL_DS);
88262 - sock->ops->setsockopt(sock, SOL_TCP, TCP_NODELAY, (char __user *)&val,
88263 + sock->ops->setsockopt(sock, SOL_TCP, TCP_NODELAY, (char __force_user *)&val,
88264 sizeof(val));
88265 set_fs(oldfs);
88266 }
88267 diff --git a/net/rds/tcp_send.c b/net/rds/tcp_send.c
88268 index 81cf5a4..b5826ff 100644
88269 --- a/net/rds/tcp_send.c
88270 +++ b/net/rds/tcp_send.c
88271 @@ -43,7 +43,7 @@ static void rds_tcp_cork(struct socket *sock, int val)
88272
88273 oldfs = get_fs();
88274 set_fs(KERNEL_DS);
88275 - sock->ops->setsockopt(sock, SOL_TCP, TCP_CORK, (char __user *)&val,
88276 + sock->ops->setsockopt(sock, SOL_TCP, TCP_CORK, (char __force_user *)&val,
88277 sizeof(val));
88278 set_fs(oldfs);
88279 }
88280 diff --git a/net/rxrpc/af_rxrpc.c b/net/rxrpc/af_rxrpc.c
88281 index 05996d0..5a1dfe0 100644
88282 --- a/net/rxrpc/af_rxrpc.c
88283 +++ b/net/rxrpc/af_rxrpc.c
88284 @@ -39,7 +39,7 @@ static const struct proto_ops rxrpc_rpc_ops;
88285 __be32 rxrpc_epoch;
88286
88287 /* current debugging ID */
88288 -atomic_t rxrpc_debug_id;
88289 +atomic_unchecked_t rxrpc_debug_id;
88290
88291 /* count of skbs currently in use */
88292 atomic_t rxrpc_n_skbs;
88293 diff --git a/net/rxrpc/ar-ack.c b/net/rxrpc/ar-ack.c
88294 index e4d9cbc..b229649 100644
88295 --- a/net/rxrpc/ar-ack.c
88296 +++ b/net/rxrpc/ar-ack.c
88297 @@ -175,7 +175,7 @@ static void rxrpc_resend(struct rxrpc_call *call)
88298
88299 _enter("{%d,%d,%d,%d},",
88300 call->acks_hard, call->acks_unacked,
88301 - atomic_read(&call->sequence),
88302 + atomic_read_unchecked(&call->sequence),
88303 CIRC_CNT(call->acks_head, call->acks_tail, call->acks_winsz));
88304
88305 stop = 0;
88306 @@ -199,7 +199,7 @@ static void rxrpc_resend(struct rxrpc_call *call)
88307
88308 /* each Tx packet has a new serial number */
88309 sp->hdr.serial =
88310 - htonl(atomic_inc_return(&call->conn->serial));
88311 + htonl(atomic_inc_return_unchecked(&call->conn->serial));
88312
88313 hdr = (struct rxrpc_header *) txb->head;
88314 hdr->serial = sp->hdr.serial;
88315 @@ -403,7 +403,7 @@ static void rxrpc_rotate_tx_window(struct rxrpc_call *call, u32 hard)
88316 */
88317 static void rxrpc_clear_tx_window(struct rxrpc_call *call)
88318 {
88319 - rxrpc_rotate_tx_window(call, atomic_read(&call->sequence));
88320 + rxrpc_rotate_tx_window(call, atomic_read_unchecked(&call->sequence));
88321 }
88322
88323 /*
88324 @@ -629,7 +629,7 @@ process_further:
88325
88326 latest = ntohl(sp->hdr.serial);
88327 hard = ntohl(ack.firstPacket);
88328 - tx = atomic_read(&call->sequence);
88329 + tx = atomic_read_unchecked(&call->sequence);
88330
88331 _proto("Rx ACK %%%u { m=%hu f=#%u p=#%u s=%%%u r=%s n=%u }",
88332 latest,
88333 @@ -1161,7 +1161,7 @@ void rxrpc_process_call(struct work_struct *work)
88334 goto maybe_reschedule;
88335
88336 send_ACK_with_skew:
88337 - ack.maxSkew = htons(atomic_read(&call->conn->hi_serial) -
88338 + ack.maxSkew = htons(atomic_read_unchecked(&call->conn->hi_serial) -
88339 ntohl(ack.serial));
88340 send_ACK:
88341 mtu = call->conn->trans->peer->if_mtu;
88342 @@ -1173,7 +1173,7 @@ send_ACK:
88343 ackinfo.rxMTU = htonl(5692);
88344 ackinfo.jumbo_max = htonl(4);
88345
88346 - hdr.serial = htonl(atomic_inc_return(&call->conn->serial));
88347 + hdr.serial = htonl(atomic_inc_return_unchecked(&call->conn->serial));
88348 _proto("Tx ACK %%%u { m=%hu f=#%u p=#%u s=%%%u r=%s n=%u }",
88349 ntohl(hdr.serial),
88350 ntohs(ack.maxSkew),
88351 @@ -1191,7 +1191,7 @@ send_ACK:
88352 send_message:
88353 _debug("send message");
88354
88355 - hdr.serial = htonl(atomic_inc_return(&call->conn->serial));
88356 + hdr.serial = htonl(atomic_inc_return_unchecked(&call->conn->serial));
88357 _proto("Tx %s %%%u", rxrpc_pkts[hdr.type], ntohl(hdr.serial));
88358 send_message_2:
88359
88360 diff --git a/net/rxrpc/ar-call.c b/net/rxrpc/ar-call.c
88361 index a3bbb36..3341fb9 100644
88362 --- a/net/rxrpc/ar-call.c
88363 +++ b/net/rxrpc/ar-call.c
88364 @@ -83,7 +83,7 @@ static struct rxrpc_call *rxrpc_alloc_call(gfp_t gfp)
88365 spin_lock_init(&call->lock);
88366 rwlock_init(&call->state_lock);
88367 atomic_set(&call->usage, 1);
88368 - call->debug_id = atomic_inc_return(&rxrpc_debug_id);
88369 + call->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
88370 call->state = RXRPC_CALL_CLIENT_SEND_REQUEST;
88371
88372 memset(&call->sock_node, 0xed, sizeof(call->sock_node));
88373 diff --git a/net/rxrpc/ar-connection.c b/net/rxrpc/ar-connection.c
88374 index 4106ca9..a338d7a 100644
88375 --- a/net/rxrpc/ar-connection.c
88376 +++ b/net/rxrpc/ar-connection.c
88377 @@ -206,7 +206,7 @@ static struct rxrpc_connection *rxrpc_alloc_connection(gfp_t gfp)
88378 rwlock_init(&conn->lock);
88379 spin_lock_init(&conn->state_lock);
88380 atomic_set(&conn->usage, 1);
88381 - conn->debug_id = atomic_inc_return(&rxrpc_debug_id);
88382 + conn->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
88383 conn->avail_calls = RXRPC_MAXCALLS;
88384 conn->size_align = 4;
88385 conn->header_size = sizeof(struct rxrpc_header);
88386 diff --git a/net/rxrpc/ar-connevent.c b/net/rxrpc/ar-connevent.c
88387 index e7ed43a..6afa140 100644
88388 --- a/net/rxrpc/ar-connevent.c
88389 +++ b/net/rxrpc/ar-connevent.c
88390 @@ -109,7 +109,7 @@ static int rxrpc_abort_connection(struct rxrpc_connection *conn,
88391
88392 len = iov[0].iov_len + iov[1].iov_len;
88393
88394 - hdr.serial = htonl(atomic_inc_return(&conn->serial));
88395 + hdr.serial = htonl(atomic_inc_return_unchecked(&conn->serial));
88396 _proto("Tx CONN ABORT %%%u { %d }", ntohl(hdr.serial), abort_code);
88397
88398 ret = kernel_sendmsg(conn->trans->local->socket, &msg, iov, 2, len);
88399 diff --git a/net/rxrpc/ar-input.c b/net/rxrpc/ar-input.c
88400 index 529572f..c758ca7 100644
88401 --- a/net/rxrpc/ar-input.c
88402 +++ b/net/rxrpc/ar-input.c
88403 @@ -340,9 +340,9 @@ void rxrpc_fast_process_packet(struct rxrpc_call *call, struct sk_buff *skb)
88404 /* track the latest serial number on this connection for ACK packet
88405 * information */
88406 serial = ntohl(sp->hdr.serial);
88407 - hi_serial = atomic_read(&call->conn->hi_serial);
88408 + hi_serial = atomic_read_unchecked(&call->conn->hi_serial);
88409 while (serial > hi_serial)
88410 - hi_serial = atomic_cmpxchg(&call->conn->hi_serial, hi_serial,
88411 + hi_serial = atomic_cmpxchg_unchecked(&call->conn->hi_serial, hi_serial,
88412 serial);
88413
88414 /* request ACK generation for any ACK or DATA packet that requests
88415 diff --git a/net/rxrpc/ar-internal.h b/net/rxrpc/ar-internal.h
88416 index a693aca..81e7293 100644
88417 --- a/net/rxrpc/ar-internal.h
88418 +++ b/net/rxrpc/ar-internal.h
88419 @@ -272,8 +272,8 @@ struct rxrpc_connection {
88420 int error; /* error code for local abort */
88421 int debug_id; /* debug ID for printks */
88422 unsigned int call_counter; /* call ID counter */
88423 - atomic_t serial; /* packet serial number counter */
88424 - atomic_t hi_serial; /* highest serial number received */
88425 + atomic_unchecked_t serial; /* packet serial number counter */
88426 + atomic_unchecked_t hi_serial; /* highest serial number received */
88427 u8 avail_calls; /* number of calls available */
88428 u8 size_align; /* data size alignment (for security) */
88429 u8 header_size; /* rxrpc + security header size */
88430 @@ -346,7 +346,7 @@ struct rxrpc_call {
88431 spinlock_t lock;
88432 rwlock_t state_lock; /* lock for state transition */
88433 atomic_t usage;
88434 - atomic_t sequence; /* Tx data packet sequence counter */
88435 + atomic_unchecked_t sequence; /* Tx data packet sequence counter */
88436 u32 abort_code; /* local/remote abort code */
88437 enum { /* current state of call */
88438 RXRPC_CALL_CLIENT_SEND_REQUEST, /* - client sending request phase */
88439 @@ -420,7 +420,7 @@ static inline void rxrpc_abort_call(struct rxrpc_call *call, u32 abort_code)
88440 */
88441 extern atomic_t rxrpc_n_skbs;
88442 extern __be32 rxrpc_epoch;
88443 -extern atomic_t rxrpc_debug_id;
88444 +extern atomic_unchecked_t rxrpc_debug_id;
88445 extern struct workqueue_struct *rxrpc_workqueue;
88446
88447 /*
88448 diff --git a/net/rxrpc/ar-local.c b/net/rxrpc/ar-local.c
88449 index 87f7135..74d3703 100644
88450 --- a/net/rxrpc/ar-local.c
88451 +++ b/net/rxrpc/ar-local.c
88452 @@ -45,7 +45,7 @@ struct rxrpc_local *rxrpc_alloc_local(struct sockaddr_rxrpc *srx)
88453 spin_lock_init(&local->lock);
88454 rwlock_init(&local->services_lock);
88455 atomic_set(&local->usage, 1);
88456 - local->debug_id = atomic_inc_return(&rxrpc_debug_id);
88457 + local->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
88458 memcpy(&local->srx, srx, sizeof(*srx));
88459 }
88460
88461 diff --git a/net/rxrpc/ar-output.c b/net/rxrpc/ar-output.c
88462 index e1ac183..b43e10e 100644
88463 --- a/net/rxrpc/ar-output.c
88464 +++ b/net/rxrpc/ar-output.c
88465 @@ -682,9 +682,9 @@ static int rxrpc_send_data(struct kiocb *iocb,
88466 sp->hdr.cid = call->cid;
88467 sp->hdr.callNumber = call->call_id;
88468 sp->hdr.seq =
88469 - htonl(atomic_inc_return(&call->sequence));
88470 + htonl(atomic_inc_return_unchecked(&call->sequence));
88471 sp->hdr.serial =
88472 - htonl(atomic_inc_return(&conn->serial));
88473 + htonl(atomic_inc_return_unchecked(&conn->serial));
88474 sp->hdr.type = RXRPC_PACKET_TYPE_DATA;
88475 sp->hdr.userStatus = 0;
88476 sp->hdr.securityIndex = conn->security_ix;
88477 diff --git a/net/rxrpc/ar-peer.c b/net/rxrpc/ar-peer.c
88478 index bebaa43..2644591 100644
88479 --- a/net/rxrpc/ar-peer.c
88480 +++ b/net/rxrpc/ar-peer.c
88481 @@ -72,7 +72,7 @@ static struct rxrpc_peer *rxrpc_alloc_peer(struct sockaddr_rxrpc *srx,
88482 INIT_LIST_HEAD(&peer->error_targets);
88483 spin_lock_init(&peer->lock);
88484 atomic_set(&peer->usage, 1);
88485 - peer->debug_id = atomic_inc_return(&rxrpc_debug_id);
88486 + peer->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
88487 memcpy(&peer->srx, srx, sizeof(*srx));
88488
88489 rxrpc_assess_MTU_size(peer);
88490 diff --git a/net/rxrpc/ar-proc.c b/net/rxrpc/ar-proc.c
88491 index 38047f7..9f48511 100644
88492 --- a/net/rxrpc/ar-proc.c
88493 +++ b/net/rxrpc/ar-proc.c
88494 @@ -164,8 +164,8 @@ static int rxrpc_connection_seq_show(struct seq_file *seq, void *v)
88495 atomic_read(&conn->usage),
88496 rxrpc_conn_states[conn->state],
88497 key_serial(conn->key),
88498 - atomic_read(&conn->serial),
88499 - atomic_read(&conn->hi_serial));
88500 + atomic_read_unchecked(&conn->serial),
88501 + atomic_read_unchecked(&conn->hi_serial));
88502
88503 return 0;
88504 }
88505 diff --git a/net/rxrpc/ar-transport.c b/net/rxrpc/ar-transport.c
88506 index 92df566..87ec1bf 100644
88507 --- a/net/rxrpc/ar-transport.c
88508 +++ b/net/rxrpc/ar-transport.c
88509 @@ -47,7 +47,7 @@ static struct rxrpc_transport *rxrpc_alloc_transport(struct rxrpc_local *local,
88510 spin_lock_init(&trans->client_lock);
88511 rwlock_init(&trans->conn_lock);
88512 atomic_set(&trans->usage, 1);
88513 - trans->debug_id = atomic_inc_return(&rxrpc_debug_id);
88514 + trans->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
88515
88516 if (peer->srx.transport.family == AF_INET) {
88517 switch (peer->srx.transport_type) {
88518 diff --git a/net/rxrpc/rxkad.c b/net/rxrpc/rxkad.c
88519 index f226709..0e735a8 100644
88520 --- a/net/rxrpc/rxkad.c
88521 +++ b/net/rxrpc/rxkad.c
88522 @@ -610,7 +610,7 @@ static int rxkad_issue_challenge(struct rxrpc_connection *conn)
88523
88524 len = iov[0].iov_len + iov[1].iov_len;
88525
88526 - hdr.serial = htonl(atomic_inc_return(&conn->serial));
88527 + hdr.serial = htonl(atomic_inc_return_unchecked(&conn->serial));
88528 _proto("Tx CHALLENGE %%%u", ntohl(hdr.serial));
88529
88530 ret = kernel_sendmsg(conn->trans->local->socket, &msg, iov, 2, len);
88531 @@ -660,7 +660,7 @@ static int rxkad_send_response(struct rxrpc_connection *conn,
88532
88533 len = iov[0].iov_len + iov[1].iov_len + iov[2].iov_len;
88534
88535 - hdr->serial = htonl(atomic_inc_return(&conn->serial));
88536 + hdr->serial = htonl(atomic_inc_return_unchecked(&conn->serial));
88537 _proto("Tx RESPONSE %%%u", ntohl(hdr->serial));
88538
88539 ret = kernel_sendmsg(conn->trans->local->socket, &msg, iov, 3, len);
88540 diff --git a/net/sctp/ipv6.c b/net/sctp/ipv6.c
88541 index 391a245..296b3d7 100644
88542 --- a/net/sctp/ipv6.c
88543 +++ b/net/sctp/ipv6.c
88544 @@ -981,7 +981,7 @@ static const struct inet6_protocol sctpv6_protocol = {
88545 .flags = INET6_PROTO_NOPOLICY | INET6_PROTO_FINAL,
88546 };
88547
88548 -static struct sctp_af sctp_af_inet6 = {
88549 +static struct sctp_af sctp_af_inet6 __read_only = {
88550 .sa_family = AF_INET6,
88551 .sctp_xmit = sctp_v6_xmit,
88552 .setsockopt = ipv6_setsockopt,
88553 @@ -1013,7 +1013,7 @@ static struct sctp_af sctp_af_inet6 = {
88554 #endif
88555 };
88556
88557 -static struct sctp_pf sctp_pf_inet6 = {
88558 +static struct sctp_pf sctp_pf_inet6 __read_only = {
88559 .event_msgname = sctp_inet6_event_msgname,
88560 .skb_msgname = sctp_inet6_skb_msgname,
88561 .af_supported = sctp_inet6_af_supported,
88562 @@ -1038,7 +1038,7 @@ void sctp_v6_pf_init(void)
88563
88564 void sctp_v6_pf_exit(void)
88565 {
88566 - list_del(&sctp_af_inet6.list);
88567 + pax_list_del(&sctp_af_inet6.list);
88568 }
88569
88570 /* Initialize IPv6 support and register with socket layer. */
88571 diff --git a/net/sctp/proc.c b/net/sctp/proc.c
88572 index 8c19e97..16264b8 100644
88573 --- a/net/sctp/proc.c
88574 +++ b/net/sctp/proc.c
88575 @@ -338,7 +338,8 @@ static int sctp_assocs_seq_show(struct seq_file *seq, void *v)
88576 seq_printf(seq,
88577 "%8pK %8pK %-3d %-3d %-2d %-4d "
88578 "%4d %8d %8d %7d %5lu %-5d %5d ",
88579 - assoc, sk, sctp_sk(sk)->type, sk->sk_state,
88580 + assoc, sk,
88581 + sctp_sk(sk)->type, sk->sk_state,
88582 assoc->state, hash,
88583 assoc->assoc_id,
88584 assoc->sndbuf_used,
88585 diff --git a/net/sctp/protocol.c b/net/sctp/protocol.c
88586 index f898b1c..a2d0fe8 100644
88587 --- a/net/sctp/protocol.c
88588 +++ b/net/sctp/protocol.c
88589 @@ -834,8 +834,10 @@ int sctp_register_af(struct sctp_af *af)
88590 return 0;
88591 }
88592
88593 + pax_open_kernel();
88594 INIT_LIST_HEAD(&af->list);
88595 - list_add_tail(&af->list, &sctp_address_families);
88596 + pax_close_kernel();
88597 + pax_list_add_tail(&af->list, &sctp_address_families);
88598 return 1;
88599 }
88600
88601 @@ -966,7 +968,7 @@ static inline int sctp_v4_xmit(struct sk_buff *skb,
88602
88603 static struct sctp_af sctp_af_inet;
88604
88605 -static struct sctp_pf sctp_pf_inet = {
88606 +static struct sctp_pf sctp_pf_inet __read_only = {
88607 .event_msgname = sctp_inet_event_msgname,
88608 .skb_msgname = sctp_inet_skb_msgname,
88609 .af_supported = sctp_inet_af_supported,
88610 @@ -1037,7 +1039,7 @@ static const struct net_protocol sctp_protocol = {
88611 };
88612
88613 /* IPv4 address related functions. */
88614 -static struct sctp_af sctp_af_inet = {
88615 +static struct sctp_af sctp_af_inet __read_only = {
88616 .sa_family = AF_INET,
88617 .sctp_xmit = sctp_v4_xmit,
88618 .setsockopt = ip_setsockopt,
88619 @@ -1122,7 +1124,7 @@ static void sctp_v4_pf_init(void)
88620
88621 static void sctp_v4_pf_exit(void)
88622 {
88623 - list_del(&sctp_af_inet.list);
88624 + pax_list_del(&sctp_af_inet.list);
88625 }
88626
88627 static int sctp_v4_protosw_init(void)
88628 diff --git a/net/sctp/sm_sideeffect.c b/net/sctp/sm_sideeffect.c
88629 index c957775..6d4593a 100644
88630 --- a/net/sctp/sm_sideeffect.c
88631 +++ b/net/sctp/sm_sideeffect.c
88632 @@ -447,7 +447,7 @@ static void sctp_generate_sack_event(unsigned long data)
88633 sctp_generate_timeout_event(asoc, SCTP_EVENT_TIMEOUT_SACK);
88634 }
88635
88636 -sctp_timer_event_t *sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES] = {
88637 +sctp_timer_event_t * const sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES] = {
88638 NULL,
88639 sctp_generate_t1_cookie_event,
88640 sctp_generate_t1_init_event,
88641 diff --git a/net/sctp/socket.c b/net/sctp/socket.c
88642 index 9ef5c73..d577d71 100644
88643 --- a/net/sctp/socket.c
88644 +++ b/net/sctp/socket.c
88645 @@ -4665,6 +4665,8 @@ static int sctp_getsockopt_peer_addrs(struct sock *sk, int len,
88646 addrlen = sctp_get_af_specific(temp.sa.sa_family)->sockaddr_len;
88647 if (space_left < addrlen)
88648 return -ENOMEM;
88649 + if (addrlen > sizeof(temp) || addrlen < 0)
88650 + return -EFAULT;
88651 if (copy_to_user(to, &temp, addrlen))
88652 return -EFAULT;
88653 to += addrlen;
88654 diff --git a/net/sctp/ssnmap.c b/net/sctp/ssnmap.c
88655 index 442ad4e..825ea94 100644
88656 --- a/net/sctp/ssnmap.c
88657 +++ b/net/sctp/ssnmap.c
88658 @@ -41,8 +41,6 @@
88659 #include <net/sctp/sctp.h>
88660 #include <net/sctp/sm.h>
88661
88662 -#define MAX_KMALLOC_SIZE 131072
88663 -
88664 static struct sctp_ssnmap *sctp_ssnmap_init(struct sctp_ssnmap *map, __u16 in,
88665 __u16 out);
88666
88667 @@ -65,7 +63,7 @@ struct sctp_ssnmap *sctp_ssnmap_new(__u16 in, __u16 out,
88668 int size;
88669
88670 size = sctp_ssnmap_size(in, out);
88671 - if (size <= MAX_KMALLOC_SIZE)
88672 + if (size <= KMALLOC_MAX_SIZE)
88673 retval = kmalloc(size, gfp);
88674 else
88675 retval = (struct sctp_ssnmap *)
88676 @@ -82,7 +80,7 @@ struct sctp_ssnmap *sctp_ssnmap_new(__u16 in, __u16 out,
88677 return retval;
88678
88679 fail_map:
88680 - if (size <= MAX_KMALLOC_SIZE)
88681 + if (size <= KMALLOC_MAX_SIZE)
88682 kfree(retval);
88683 else
88684 free_pages((unsigned long)retval, get_order(size));
88685 @@ -124,7 +122,7 @@ void sctp_ssnmap_free(struct sctp_ssnmap *map)
88686 int size;
88687
88688 size = sctp_ssnmap_size(map->in.len, map->out.len);
88689 - if (size <= MAX_KMALLOC_SIZE)
88690 + if (size <= KMALLOC_MAX_SIZE)
88691 kfree(map);
88692 else
88693 free_pages((unsigned long)map, get_order(size));
88694 diff --git a/net/sctp/sysctl.c b/net/sctp/sysctl.c
88695 index bf3c6e8..376d8d0 100644
88696 --- a/net/sctp/sysctl.c
88697 +++ b/net/sctp/sysctl.c
88698 @@ -307,7 +307,7 @@ static int proc_sctp_do_hmac_alg(ctl_table *ctl,
88699 {
88700 struct net *net = current->nsproxy->net_ns;
88701 char tmp[8];
88702 - ctl_table tbl;
88703 + ctl_table_no_const tbl;
88704 int ret;
88705 int changed = 0;
88706 char *none = "none";
88707 @@ -350,7 +350,7 @@ static int proc_sctp_do_hmac_alg(ctl_table *ctl,
88708
88709 int sctp_sysctl_net_register(struct net *net)
88710 {
88711 - struct ctl_table *table;
88712 + ctl_table_no_const *table;
88713 int i;
88714
88715 table = kmemdup(sctp_net_table, sizeof(sctp_net_table), GFP_KERNEL);
88716 diff --git a/net/socket.c b/net/socket.c
88717 index 2ca51c7..adc6cb6 100644
88718 --- a/net/socket.c
88719 +++ b/net/socket.c
88720 @@ -89,6 +89,7 @@
88721 #include <linux/magic.h>
88722 #include <linux/slab.h>
88723 #include <linux/xattr.h>
88724 +#include <linux/in.h>
88725
88726 #include <asm/uaccess.h>
88727 #include <asm/unistd.h>
88728 @@ -106,6 +107,8 @@
88729 #include <linux/sockios.h>
88730 #include <linux/atalk.h>
88731
88732 +#include <linux/grsock.h>
88733 +
88734 static int sock_no_open(struct inode *irrelevant, struct file *dontcare);
88735 static ssize_t sock_aio_read(struct kiocb *iocb, const struct iovec *iov,
88736 unsigned long nr_segs, loff_t pos);
88737 @@ -322,7 +325,7 @@ static struct dentry *sockfs_mount(struct file_system_type *fs_type,
88738 &sockfs_dentry_operations, SOCKFS_MAGIC);
88739 }
88740
88741 -static struct vfsmount *sock_mnt __read_mostly;
88742 +struct vfsmount *sock_mnt __read_mostly;
88743
88744 static struct file_system_type sock_fs_type = {
88745 .name = "sockfs",
88746 @@ -1270,6 +1273,8 @@ int __sock_create(struct net *net, int family, int type, int protocol,
88747 return -EAFNOSUPPORT;
88748 if (type < 0 || type >= SOCK_MAX)
88749 return -EINVAL;
88750 + if (protocol < 0)
88751 + return -EINVAL;
88752
88753 /* Compatibility.
88754
88755 @@ -1401,6 +1406,16 @@ SYSCALL_DEFINE3(socket, int, family, int, type, int, protocol)
88756 if (SOCK_NONBLOCK != O_NONBLOCK && (flags & SOCK_NONBLOCK))
88757 flags = (flags & ~SOCK_NONBLOCK) | O_NONBLOCK;
88758
88759 + if(!gr_search_socket(family, type, protocol)) {
88760 + retval = -EACCES;
88761 + goto out;
88762 + }
88763 +
88764 + if (gr_handle_sock_all(family, type, protocol)) {
88765 + retval = -EACCES;
88766 + goto out;
88767 + }
88768 +
88769 retval = sock_create(family, type, protocol, &sock);
88770 if (retval < 0)
88771 goto out;
88772 @@ -1528,6 +1543,14 @@ SYSCALL_DEFINE3(bind, int, fd, struct sockaddr __user *, umyaddr, int, addrlen)
88773 if (sock) {
88774 err = move_addr_to_kernel(umyaddr, addrlen, &address);
88775 if (err >= 0) {
88776 + if (gr_handle_sock_server((struct sockaddr *)&address)) {
88777 + err = -EACCES;
88778 + goto error;
88779 + }
88780 + err = gr_search_bind(sock, (struct sockaddr_in *)&address);
88781 + if (err)
88782 + goto error;
88783 +
88784 err = security_socket_bind(sock,
88785 (struct sockaddr *)&address,
88786 addrlen);
88787 @@ -1536,6 +1559,7 @@ SYSCALL_DEFINE3(bind, int, fd, struct sockaddr __user *, umyaddr, int, addrlen)
88788 (struct sockaddr *)
88789 &address, addrlen);
88790 }
88791 +error:
88792 fput_light(sock->file, fput_needed);
88793 }
88794 return err;
88795 @@ -1559,10 +1583,20 @@ SYSCALL_DEFINE2(listen, int, fd, int, backlog)
88796 if ((unsigned int)backlog > somaxconn)
88797 backlog = somaxconn;
88798
88799 + if (gr_handle_sock_server_other(sock->sk)) {
88800 + err = -EPERM;
88801 + goto error;
88802 + }
88803 +
88804 + err = gr_search_listen(sock);
88805 + if (err)
88806 + goto error;
88807 +
88808 err = security_socket_listen(sock, backlog);
88809 if (!err)
88810 err = sock->ops->listen(sock, backlog);
88811
88812 +error:
88813 fput_light(sock->file, fput_needed);
88814 }
88815 return err;
88816 @@ -1606,6 +1640,18 @@ SYSCALL_DEFINE4(accept4, int, fd, struct sockaddr __user *, upeer_sockaddr,
88817 newsock->type = sock->type;
88818 newsock->ops = sock->ops;
88819
88820 + if (gr_handle_sock_server_other(sock->sk)) {
88821 + err = -EPERM;
88822 + sock_release(newsock);
88823 + goto out_put;
88824 + }
88825 +
88826 + err = gr_search_accept(sock);
88827 + if (err) {
88828 + sock_release(newsock);
88829 + goto out_put;
88830 + }
88831 +
88832 /*
88833 * We don't need try_module_get here, as the listening socket (sock)
88834 * has the protocol module (sock->ops->owner) held.
88835 @@ -1651,6 +1697,8 @@ SYSCALL_DEFINE4(accept4, int, fd, struct sockaddr __user *, upeer_sockaddr,
88836 fd_install(newfd, newfile);
88837 err = newfd;
88838
88839 + gr_attach_curr_ip(newsock->sk);
88840 +
88841 out_put:
88842 fput_light(sock->file, fput_needed);
88843 out:
88844 @@ -1683,6 +1731,7 @@ SYSCALL_DEFINE3(connect, int, fd, struct sockaddr __user *, uservaddr,
88845 int, addrlen)
88846 {
88847 struct socket *sock;
88848 + struct sockaddr *sck;
88849 struct sockaddr_storage address;
88850 int err, fput_needed;
88851
88852 @@ -1693,6 +1742,17 @@ SYSCALL_DEFINE3(connect, int, fd, struct sockaddr __user *, uservaddr,
88853 if (err < 0)
88854 goto out_put;
88855
88856 + sck = (struct sockaddr *)&address;
88857 +
88858 + if (gr_handle_sock_client(sck)) {
88859 + err = -EACCES;
88860 + goto out_put;
88861 + }
88862 +
88863 + err = gr_search_connect(sock, (struct sockaddr_in *)sck);
88864 + if (err)
88865 + goto out_put;
88866 +
88867 err =
88868 security_socket_connect(sock, (struct sockaddr *)&address, addrlen);
88869 if (err)
88870 @@ -1774,6 +1834,8 @@ SYSCALL_DEFINE3(getpeername, int, fd, struct sockaddr __user *, usockaddr,
88871 * the protocol.
88872 */
88873
88874 +asmlinkage long sys_sendto(int, void *, size_t, unsigned, struct sockaddr *, int) __intentional_overflow(0);
88875 +
88876 SYSCALL_DEFINE6(sendto, int, fd, void __user *, buff, size_t, len,
88877 unsigned int, flags, struct sockaddr __user *, addr,
88878 int, addr_len)
88879 @@ -2047,7 +2109,7 @@ static int __sys_sendmsg(struct socket *sock, struct msghdr __user *msg,
88880 * checking falls down on this.
88881 */
88882 if (copy_from_user(ctl_buf,
88883 - (void __user __force *)msg_sys->msg_control,
88884 + (void __force_user *)msg_sys->msg_control,
88885 ctl_len))
88886 goto out_freectl;
88887 msg_sys->msg_control = ctl_buf;
88888 @@ -2215,7 +2277,7 @@ static int __sys_recvmsg(struct socket *sock, struct msghdr __user *msg,
88889 * kernel msghdr to use the kernel address space)
88890 */
88891
88892 - uaddr = (__force void __user *)msg_sys->msg_name;
88893 + uaddr = (void __force_user *)msg_sys->msg_name;
88894 uaddr_len = COMPAT_NAMELEN(msg);
88895 if (MSG_CMSG_COMPAT & flags) {
88896 err = verify_compat_iovec(msg_sys, iov, &addr, VERIFY_WRITE);
88897 @@ -2838,7 +2900,7 @@ static int ethtool_ioctl(struct net *net, struct compat_ifreq __user *ifr32)
88898 }
88899
88900 ifr = compat_alloc_user_space(buf_size);
88901 - rxnfc = (void *)ifr + ALIGN(sizeof(struct ifreq), 8);
88902 + rxnfc = (void __user *)ifr + ALIGN(sizeof(struct ifreq), 8);
88903
88904 if (copy_in_user(&ifr->ifr_name, &ifr32->ifr_name, IFNAMSIZ))
88905 return -EFAULT;
88906 @@ -2862,12 +2924,12 @@ static int ethtool_ioctl(struct net *net, struct compat_ifreq __user *ifr32)
88907 offsetof(struct ethtool_rxnfc, fs.ring_cookie));
88908
88909 if (copy_in_user(rxnfc, compat_rxnfc,
88910 - (void *)(&rxnfc->fs.m_ext + 1) -
88911 - (void *)rxnfc) ||
88912 + (void __user *)(&rxnfc->fs.m_ext + 1) -
88913 + (void __user *)rxnfc) ||
88914 copy_in_user(&rxnfc->fs.ring_cookie,
88915 &compat_rxnfc->fs.ring_cookie,
88916 - (void *)(&rxnfc->fs.location + 1) -
88917 - (void *)&rxnfc->fs.ring_cookie) ||
88918 + (void __user *)(&rxnfc->fs.location + 1) -
88919 + (void __user *)&rxnfc->fs.ring_cookie) ||
88920 copy_in_user(&rxnfc->rule_cnt, &compat_rxnfc->rule_cnt,
88921 sizeof(rxnfc->rule_cnt)))
88922 return -EFAULT;
88923 @@ -2879,12 +2941,12 @@ static int ethtool_ioctl(struct net *net, struct compat_ifreq __user *ifr32)
88924
88925 if (convert_out) {
88926 if (copy_in_user(compat_rxnfc, rxnfc,
88927 - (const void *)(&rxnfc->fs.m_ext + 1) -
88928 - (const void *)rxnfc) ||
88929 + (const void __user *)(&rxnfc->fs.m_ext + 1) -
88930 + (const void __user *)rxnfc) ||
88931 copy_in_user(&compat_rxnfc->fs.ring_cookie,
88932 &rxnfc->fs.ring_cookie,
88933 - (const void *)(&rxnfc->fs.location + 1) -
88934 - (const void *)&rxnfc->fs.ring_cookie) ||
88935 + (const void __user *)(&rxnfc->fs.location + 1) -
88936 + (const void __user *)&rxnfc->fs.ring_cookie) ||
88937 copy_in_user(&compat_rxnfc->rule_cnt, &rxnfc->rule_cnt,
88938 sizeof(rxnfc->rule_cnt)))
88939 return -EFAULT;
88940 @@ -2954,7 +3016,7 @@ static int bond_ioctl(struct net *net, unsigned int cmd,
88941 old_fs = get_fs();
88942 set_fs(KERNEL_DS);
88943 err = dev_ioctl(net, cmd,
88944 - (struct ifreq __user __force *) &kifr);
88945 + (struct ifreq __force_user *) &kifr);
88946 set_fs(old_fs);
88947
88948 return err;
88949 @@ -3063,7 +3125,7 @@ static int compat_sioc_ifmap(struct net *net, unsigned int cmd,
88950
88951 old_fs = get_fs();
88952 set_fs(KERNEL_DS);
88953 - err = dev_ioctl(net, cmd, (void __user __force *)&ifr);
88954 + err = dev_ioctl(net, cmd, (void __force_user *)&ifr);
88955 set_fs(old_fs);
88956
88957 if (cmd == SIOCGIFMAP && !err) {
88958 @@ -3168,7 +3230,7 @@ static int routing_ioctl(struct net *net, struct socket *sock,
88959 ret |= __get_user(rtdev, &(ur4->rt_dev));
88960 if (rtdev) {
88961 ret |= copy_from_user(devname, compat_ptr(rtdev), 15);
88962 - r4.rt_dev = (char __user __force *)devname;
88963 + r4.rt_dev = (char __force_user *)devname;
88964 devname[15] = 0;
88965 } else
88966 r4.rt_dev = NULL;
88967 @@ -3394,8 +3456,8 @@ int kernel_getsockopt(struct socket *sock, int level, int optname,
88968 int __user *uoptlen;
88969 int err;
88970
88971 - uoptval = (char __user __force *) optval;
88972 - uoptlen = (int __user __force *) optlen;
88973 + uoptval = (char __force_user *) optval;
88974 + uoptlen = (int __force_user *) optlen;
88975
88976 set_fs(KERNEL_DS);
88977 if (level == SOL_SOCKET)
88978 @@ -3415,7 +3477,7 @@ int kernel_setsockopt(struct socket *sock, int level, int optname,
88979 char __user *uoptval;
88980 int err;
88981
88982 - uoptval = (char __user __force *) optval;
88983 + uoptval = (char __force_user *) optval;
88984
88985 set_fs(KERNEL_DS);
88986 if (level == SOL_SOCKET)
88987 diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c
88988 index 507b5e8..049e64a 100644
88989 --- a/net/sunrpc/clnt.c
88990 +++ b/net/sunrpc/clnt.c
88991 @@ -1272,7 +1272,9 @@ call_start(struct rpc_task *task)
88992 (RPC_IS_ASYNC(task) ? "async" : "sync"));
88993
88994 /* Increment call count */
88995 - task->tk_msg.rpc_proc->p_count++;
88996 + pax_open_kernel();
88997 + (*(unsigned int *)&task->tk_msg.rpc_proc->p_count)++;
88998 + pax_close_kernel();
88999 clnt->cl_stats->rpccnt++;
89000 task->tk_action = call_reserve;
89001 }
89002 diff --git a/net/sunrpc/sched.c b/net/sunrpc/sched.c
89003 index fb20f25..e3ba316 100644
89004 --- a/net/sunrpc/sched.c
89005 +++ b/net/sunrpc/sched.c
89006 @@ -259,9 +259,9 @@ static int rpc_wait_bit_killable(void *word)
89007 #ifdef RPC_DEBUG
89008 static void rpc_task_set_debuginfo(struct rpc_task *task)
89009 {
89010 - static atomic_t rpc_pid;
89011 + static atomic_unchecked_t rpc_pid;
89012
89013 - task->tk_pid = atomic_inc_return(&rpc_pid);
89014 + task->tk_pid = atomic_inc_return_unchecked(&rpc_pid);
89015 }
89016 #else
89017 static inline void rpc_task_set_debuginfo(struct rpc_task *task)
89018 diff --git a/net/sunrpc/svc.c b/net/sunrpc/svc.c
89019 index 2d34b6b..e2d584d 100644
89020 --- a/net/sunrpc/svc.c
89021 +++ b/net/sunrpc/svc.c
89022 @@ -1156,7 +1156,9 @@ svc_process_common(struct svc_rqst *rqstp, struct kvec *argv, struct kvec *resv)
89023 svc_putnl(resv, RPC_SUCCESS);
89024
89025 /* Bump per-procedure stats counter */
89026 - procp->pc_count++;
89027 + pax_open_kernel();
89028 + (*(unsigned int *)&procp->pc_count)++;
89029 + pax_close_kernel();
89030
89031 /* Initialize storage for argp and resp */
89032 memset(rqstp->rq_argp, 0, procp->pc_argsize);
89033 diff --git a/net/sunrpc/xprtrdma/svc_rdma.c b/net/sunrpc/xprtrdma/svc_rdma.c
89034 index 8343737..677025e 100644
89035 --- a/net/sunrpc/xprtrdma/svc_rdma.c
89036 +++ b/net/sunrpc/xprtrdma/svc_rdma.c
89037 @@ -62,15 +62,15 @@ unsigned int svcrdma_max_req_size = RPCRDMA_MAX_REQ_SIZE;
89038 static unsigned int min_max_inline = 4096;
89039 static unsigned int max_max_inline = 65536;
89040
89041 -atomic_t rdma_stat_recv;
89042 -atomic_t rdma_stat_read;
89043 -atomic_t rdma_stat_write;
89044 -atomic_t rdma_stat_sq_starve;
89045 -atomic_t rdma_stat_rq_starve;
89046 -atomic_t rdma_stat_rq_poll;
89047 -atomic_t rdma_stat_rq_prod;
89048 -atomic_t rdma_stat_sq_poll;
89049 -atomic_t rdma_stat_sq_prod;
89050 +atomic_unchecked_t rdma_stat_recv;
89051 +atomic_unchecked_t rdma_stat_read;
89052 +atomic_unchecked_t rdma_stat_write;
89053 +atomic_unchecked_t rdma_stat_sq_starve;
89054 +atomic_unchecked_t rdma_stat_rq_starve;
89055 +atomic_unchecked_t rdma_stat_rq_poll;
89056 +atomic_unchecked_t rdma_stat_rq_prod;
89057 +atomic_unchecked_t rdma_stat_sq_poll;
89058 +atomic_unchecked_t rdma_stat_sq_prod;
89059
89060 /* Temporary NFS request map and context caches */
89061 struct kmem_cache *svc_rdma_map_cachep;
89062 @@ -110,7 +110,7 @@ static int read_reset_stat(ctl_table *table, int write,
89063 len -= *ppos;
89064 if (len > *lenp)
89065 len = *lenp;
89066 - if (len && copy_to_user(buffer, str_buf, len))
89067 + if (len > sizeof str_buf || (len && copy_to_user(buffer, str_buf, len)))
89068 return -EFAULT;
89069 *lenp = len;
89070 *ppos += len;
89071 @@ -151,63 +151,63 @@ static ctl_table svcrdma_parm_table[] = {
89072 {
89073 .procname = "rdma_stat_read",
89074 .data = &rdma_stat_read,
89075 - .maxlen = sizeof(atomic_t),
89076 + .maxlen = sizeof(atomic_unchecked_t),
89077 .mode = 0644,
89078 .proc_handler = read_reset_stat,
89079 },
89080 {
89081 .procname = "rdma_stat_recv",
89082 .data = &rdma_stat_recv,
89083 - .maxlen = sizeof(atomic_t),
89084 + .maxlen = sizeof(atomic_unchecked_t),
89085 .mode = 0644,
89086 .proc_handler = read_reset_stat,
89087 },
89088 {
89089 .procname = "rdma_stat_write",
89090 .data = &rdma_stat_write,
89091 - .maxlen = sizeof(atomic_t),
89092 + .maxlen = sizeof(atomic_unchecked_t),
89093 .mode = 0644,
89094 .proc_handler = read_reset_stat,
89095 },
89096 {
89097 .procname = "rdma_stat_sq_starve",
89098 .data = &rdma_stat_sq_starve,
89099 - .maxlen = sizeof(atomic_t),
89100 + .maxlen = sizeof(atomic_unchecked_t),
89101 .mode = 0644,
89102 .proc_handler = read_reset_stat,
89103 },
89104 {
89105 .procname = "rdma_stat_rq_starve",
89106 .data = &rdma_stat_rq_starve,
89107 - .maxlen = sizeof(atomic_t),
89108 + .maxlen = sizeof(atomic_unchecked_t),
89109 .mode = 0644,
89110 .proc_handler = read_reset_stat,
89111 },
89112 {
89113 .procname = "rdma_stat_rq_poll",
89114 .data = &rdma_stat_rq_poll,
89115 - .maxlen = sizeof(atomic_t),
89116 + .maxlen = sizeof(atomic_unchecked_t),
89117 .mode = 0644,
89118 .proc_handler = read_reset_stat,
89119 },
89120 {
89121 .procname = "rdma_stat_rq_prod",
89122 .data = &rdma_stat_rq_prod,
89123 - .maxlen = sizeof(atomic_t),
89124 + .maxlen = sizeof(atomic_unchecked_t),
89125 .mode = 0644,
89126 .proc_handler = read_reset_stat,
89127 },
89128 {
89129 .procname = "rdma_stat_sq_poll",
89130 .data = &rdma_stat_sq_poll,
89131 - .maxlen = sizeof(atomic_t),
89132 + .maxlen = sizeof(atomic_unchecked_t),
89133 .mode = 0644,
89134 .proc_handler = read_reset_stat,
89135 },
89136 {
89137 .procname = "rdma_stat_sq_prod",
89138 .data = &rdma_stat_sq_prod,
89139 - .maxlen = sizeof(atomic_t),
89140 + .maxlen = sizeof(atomic_unchecked_t),
89141 .mode = 0644,
89142 .proc_handler = read_reset_stat,
89143 },
89144 diff --git a/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c b/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
89145 index 0ce7552..d074459 100644
89146 --- a/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
89147 +++ b/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
89148 @@ -501,7 +501,7 @@ next_sge:
89149 svc_rdma_put_context(ctxt, 0);
89150 goto out;
89151 }
89152 - atomic_inc(&rdma_stat_read);
89153 + atomic_inc_unchecked(&rdma_stat_read);
89154
89155 if (read_wr.num_sge < chl_map->ch[ch_no].count) {
89156 chl_map->ch[ch_no].count -= read_wr.num_sge;
89157 @@ -611,7 +611,7 @@ int svc_rdma_recvfrom(struct svc_rqst *rqstp)
89158 dto_q);
89159 list_del_init(&ctxt->dto_q);
89160 } else {
89161 - atomic_inc(&rdma_stat_rq_starve);
89162 + atomic_inc_unchecked(&rdma_stat_rq_starve);
89163 clear_bit(XPT_DATA, &xprt->xpt_flags);
89164 ctxt = NULL;
89165 }
89166 @@ -631,7 +631,7 @@ int svc_rdma_recvfrom(struct svc_rqst *rqstp)
89167 dprintk("svcrdma: processing ctxt=%p on xprt=%p, rqstp=%p, status=%d\n",
89168 ctxt, rdma_xprt, rqstp, ctxt->wc_status);
89169 BUG_ON(ctxt->wc_status != IB_WC_SUCCESS);
89170 - atomic_inc(&rdma_stat_recv);
89171 + atomic_inc_unchecked(&rdma_stat_recv);
89172
89173 /* Build up the XDR from the receive buffers. */
89174 rdma_build_arg_xdr(rqstp, ctxt, ctxt->byte_len);
89175 diff --git a/net/sunrpc/xprtrdma/svc_rdma_sendto.c b/net/sunrpc/xprtrdma/svc_rdma_sendto.c
89176 index c1d124d..acfc59e 100644
89177 --- a/net/sunrpc/xprtrdma/svc_rdma_sendto.c
89178 +++ b/net/sunrpc/xprtrdma/svc_rdma_sendto.c
89179 @@ -362,7 +362,7 @@ static int send_write(struct svcxprt_rdma *xprt, struct svc_rqst *rqstp,
89180 write_wr.wr.rdma.remote_addr = to;
89181
89182 /* Post It */
89183 - atomic_inc(&rdma_stat_write);
89184 + atomic_inc_unchecked(&rdma_stat_write);
89185 if (svc_rdma_send(xprt, &write_wr))
89186 goto err;
89187 return 0;
89188 diff --git a/net/sunrpc/xprtrdma/svc_rdma_transport.c b/net/sunrpc/xprtrdma/svc_rdma_transport.c
89189 index 62e4f9b..dd3f2d7 100644
89190 --- a/net/sunrpc/xprtrdma/svc_rdma_transport.c
89191 +++ b/net/sunrpc/xprtrdma/svc_rdma_transport.c
89192 @@ -292,7 +292,7 @@ static void rq_cq_reap(struct svcxprt_rdma *xprt)
89193 return;
89194
89195 ib_req_notify_cq(xprt->sc_rq_cq, IB_CQ_NEXT_COMP);
89196 - atomic_inc(&rdma_stat_rq_poll);
89197 + atomic_inc_unchecked(&rdma_stat_rq_poll);
89198
89199 while ((ret = ib_poll_cq(xprt->sc_rq_cq, 1, &wc)) > 0) {
89200 ctxt = (struct svc_rdma_op_ctxt *)(unsigned long)wc.wr_id;
89201 @@ -314,7 +314,7 @@ static void rq_cq_reap(struct svcxprt_rdma *xprt)
89202 }
89203
89204 if (ctxt)
89205 - atomic_inc(&rdma_stat_rq_prod);
89206 + atomic_inc_unchecked(&rdma_stat_rq_prod);
89207
89208 set_bit(XPT_DATA, &xprt->sc_xprt.xpt_flags);
89209 /*
89210 @@ -386,7 +386,7 @@ static void sq_cq_reap(struct svcxprt_rdma *xprt)
89211 return;
89212
89213 ib_req_notify_cq(xprt->sc_sq_cq, IB_CQ_NEXT_COMP);
89214 - atomic_inc(&rdma_stat_sq_poll);
89215 + atomic_inc_unchecked(&rdma_stat_sq_poll);
89216 while ((ret = ib_poll_cq(cq, 1, &wc)) > 0) {
89217 if (wc.status != IB_WC_SUCCESS)
89218 /* Close the transport */
89219 @@ -404,7 +404,7 @@ static void sq_cq_reap(struct svcxprt_rdma *xprt)
89220 }
89221
89222 if (ctxt)
89223 - atomic_inc(&rdma_stat_sq_prod);
89224 + atomic_inc_unchecked(&rdma_stat_sq_prod);
89225 }
89226
89227 static void sq_comp_handler(struct ib_cq *cq, void *cq_context)
89228 @@ -1262,7 +1262,7 @@ int svc_rdma_send(struct svcxprt_rdma *xprt, struct ib_send_wr *wr)
89229 spin_lock_bh(&xprt->sc_lock);
89230 if (xprt->sc_sq_depth < atomic_read(&xprt->sc_sq_count) + wr_count) {
89231 spin_unlock_bh(&xprt->sc_lock);
89232 - atomic_inc(&rdma_stat_sq_starve);
89233 + atomic_inc_unchecked(&rdma_stat_sq_starve);
89234
89235 /* See if we can opportunistically reap SQ WR to make room */
89236 sq_cq_reap(xprt);
89237 diff --git a/net/sysctl_net.c b/net/sysctl_net.c
89238 index 9bc6db0..47ac8c0 100644
89239 --- a/net/sysctl_net.c
89240 +++ b/net/sysctl_net.c
89241 @@ -46,7 +46,7 @@ static int net_ctl_permissions(struct ctl_table_header *head,
89242 kgid_t root_gid = make_kgid(net->user_ns, 0);
89243
89244 /* Allow network administrator to have same access as root. */
89245 - if (ns_capable(net->user_ns, CAP_NET_ADMIN) ||
89246 + if (ns_capable_nolog(net->user_ns, CAP_NET_ADMIN) ||
89247 uid_eq(root_uid, current_uid())) {
89248 int mode = (table->mode >> 6) & 7;
89249 return (mode << 6) | (mode << 3) | mode;
89250 diff --git a/net/tipc/link.c b/net/tipc/link.c
89251 index daa6080..02d357f 100644
89252 --- a/net/tipc/link.c
89253 +++ b/net/tipc/link.c
89254 @@ -1201,7 +1201,7 @@ static int link_send_sections_long(struct tipc_port *sender,
89255 struct tipc_msg fragm_hdr;
89256 struct sk_buff *buf, *buf_chain, *prev;
89257 u32 fragm_crs, fragm_rest, hsz, sect_rest;
89258 - const unchar *sect_crs;
89259 + const unchar __user *sect_crs;
89260 int curr_sect;
89261 u32 fragm_no;
89262
89263 @@ -1242,7 +1242,7 @@ again:
89264
89265 if (!sect_rest) {
89266 sect_rest = msg_sect[++curr_sect].iov_len;
89267 - sect_crs = (const unchar *)msg_sect[curr_sect].iov_base;
89268 + sect_crs = (const unchar __user *)msg_sect[curr_sect].iov_base;
89269 }
89270
89271 if (sect_rest < fragm_rest)
89272 @@ -1261,7 +1261,7 @@ error:
89273 }
89274 } else
89275 skb_copy_to_linear_data_offset(buf, fragm_crs,
89276 - sect_crs, sz);
89277 + (const void __force_kernel *)sect_crs, sz);
89278 sect_crs += sz;
89279 sect_rest -= sz;
89280 fragm_crs += sz;
89281 diff --git a/net/tipc/msg.c b/net/tipc/msg.c
89282 index f2db8a8..9245aa4 100644
89283 --- a/net/tipc/msg.c
89284 +++ b/net/tipc/msg.c
89285 @@ -98,7 +98,7 @@ int tipc_msg_build(struct tipc_msg *hdr, struct iovec const *msg_sect,
89286 msg_sect[cnt].iov_len);
89287 else
89288 skb_copy_to_linear_data_offset(*buf, pos,
89289 - msg_sect[cnt].iov_base,
89290 + (const void __force_kernel *)msg_sect[cnt].iov_base,
89291 msg_sect[cnt].iov_len);
89292 pos += msg_sect[cnt].iov_len;
89293 }
89294 diff --git a/net/tipc/subscr.c b/net/tipc/subscr.c
89295 index 6b42d47..2ac24d5 100644
89296 --- a/net/tipc/subscr.c
89297 +++ b/net/tipc/subscr.c
89298 @@ -96,7 +96,7 @@ static void subscr_send_event(struct tipc_subscription *sub,
89299 {
89300 struct iovec msg_sect;
89301
89302 - msg_sect.iov_base = (void *)&sub->evt;
89303 + msg_sect.iov_base = (void __force_user *)&sub->evt;
89304 msg_sect.iov_len = sizeof(struct tipc_event);
89305
89306 sub->evt.event = htohl(event, sub->swap);
89307 diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
89308 index 5b5c876..6713b81 100644
89309 --- a/net/unix/af_unix.c
89310 +++ b/net/unix/af_unix.c
89311 @@ -786,6 +786,12 @@ static struct sock *unix_find_other(struct net *net,
89312 err = -ECONNREFUSED;
89313 if (!S_ISSOCK(inode->i_mode))
89314 goto put_fail;
89315 +
89316 + if (!gr_acl_handle_unix(path.dentry, path.mnt)) {
89317 + err = -EACCES;
89318 + goto put_fail;
89319 + }
89320 +
89321 u = unix_find_socket_byinode(inode);
89322 if (!u)
89323 goto put_fail;
89324 @@ -806,6 +812,13 @@ static struct sock *unix_find_other(struct net *net,
89325 if (u) {
89326 struct dentry *dentry;
89327 dentry = unix_sk(u)->path.dentry;
89328 +
89329 + if (!gr_handle_chroot_unix(pid_vnr(u->sk_peer_pid))) {
89330 + err = -EPERM;
89331 + sock_put(u);
89332 + goto fail;
89333 + }
89334 +
89335 if (dentry)
89336 touch_atime(&unix_sk(u)->path);
89337 } else
89338 @@ -839,12 +852,18 @@ static int unix_mknod(const char *sun_path, umode_t mode, struct path *res)
89339 */
89340 err = security_path_mknod(&path, dentry, mode, 0);
89341 if (!err) {
89342 + if (!gr_acl_handle_mknod(dentry, path.dentry, path.mnt, mode)) {
89343 + err = -EACCES;
89344 + goto out;
89345 + }
89346 err = vfs_mknod(path.dentry->d_inode, dentry, mode, 0);
89347 if (!err) {
89348 res->mnt = mntget(path.mnt);
89349 res->dentry = dget(dentry);
89350 + gr_handle_create(dentry, path.mnt);
89351 }
89352 }
89353 +out:
89354 done_path_create(&path, dentry);
89355 return err;
89356 }
89357 @@ -2326,9 +2345,13 @@ static int unix_seq_show(struct seq_file *seq, void *v)
89358 seq_puts(seq, "Num RefCount Protocol Flags Type St "
89359 "Inode Path\n");
89360 else {
89361 - struct sock *s = v;
89362 + struct sock *s = v, *peer;
89363 struct unix_sock *u = unix_sk(s);
89364 unix_state_lock(s);
89365 + peer = unix_peer(s);
89366 + unix_state_unlock(s);
89367 +
89368 + unix_state_double_lock(s, peer);
89369
89370 seq_printf(seq, "%pK: %08X %08X %08X %04X %02X %5lu",
89371 s,
89372 @@ -2355,8 +2378,10 @@ static int unix_seq_show(struct seq_file *seq, void *v)
89373 }
89374 for ( ; i < len; i++)
89375 seq_putc(seq, u->addr->name->sun_path[i]);
89376 - }
89377 - unix_state_unlock(s);
89378 + } else if (peer)
89379 + seq_printf(seq, " P%lu", sock_i_ino(peer));
89380 +
89381 + unix_state_double_unlock(s, peer);
89382 seq_putc(seq, '\n');
89383 }
89384
89385 diff --git a/net/unix/sysctl_net_unix.c b/net/unix/sysctl_net_unix.c
89386 index 8800604..0526440 100644
89387 --- a/net/unix/sysctl_net_unix.c
89388 +++ b/net/unix/sysctl_net_unix.c
89389 @@ -28,7 +28,7 @@ static ctl_table unix_table[] = {
89390
89391 int __net_init unix_sysctl_register(struct net *net)
89392 {
89393 - struct ctl_table *table;
89394 + ctl_table_no_const *table;
89395
89396 table = kmemdup(unix_table, sizeof(unix_table), GFP_KERNEL);
89397 if (table == NULL)
89398 diff --git a/net/wireless/wext-core.c b/net/wireless/wext-core.c
89399 index c8717c1..08539f5 100644
89400 --- a/net/wireless/wext-core.c
89401 +++ b/net/wireless/wext-core.c
89402 @@ -748,8 +748,7 @@ static int ioctl_standard_iw_point(struct iw_point *iwp, unsigned int cmd,
89403 */
89404
89405 /* Support for very large requests */
89406 - if ((descr->flags & IW_DESCR_FLAG_NOMAX) &&
89407 - (user_length > descr->max_tokens)) {
89408 + if (user_length > descr->max_tokens) {
89409 /* Allow userspace to GET more than max so
89410 * we can support any size GET requests.
89411 * There is still a limit : -ENOMEM.
89412 @@ -788,22 +787,6 @@ static int ioctl_standard_iw_point(struct iw_point *iwp, unsigned int cmd,
89413 }
89414 }
89415
89416 - if (IW_IS_GET(cmd) && !(descr->flags & IW_DESCR_FLAG_NOMAX)) {
89417 - /*
89418 - * If this is a GET, but not NOMAX, it means that the extra
89419 - * data is not bounded by userspace, but by max_tokens. Thus
89420 - * set the length to max_tokens. This matches the extra data
89421 - * allocation.
89422 - * The driver should fill it with the number of tokens it
89423 - * provided, and it may check iwp->length rather than having
89424 - * knowledge of max_tokens. If the driver doesn't change the
89425 - * iwp->length, this ioctl just copies back max_token tokens
89426 - * filled with zeroes. Hopefully the driver isn't claiming
89427 - * them to be valid data.
89428 - */
89429 - iwp->length = descr->max_tokens;
89430 - }
89431 -
89432 err = handler(dev, info, (union iwreq_data *) iwp, extra);
89433
89434 iwp->length += essid_compat;
89435 diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c
89436 index 07c5857..fde4018 100644
89437 --- a/net/xfrm/xfrm_policy.c
89438 +++ b/net/xfrm/xfrm_policy.c
89439 @@ -317,7 +317,7 @@ static void xfrm_policy_kill(struct xfrm_policy *policy)
89440 {
89441 policy->walk.dead = 1;
89442
89443 - atomic_inc(&policy->genid);
89444 + atomic_inc_unchecked(&policy->genid);
89445
89446 if (del_timer(&policy->timer))
89447 xfrm_pol_put(policy);
89448 @@ -601,7 +601,7 @@ int xfrm_policy_insert(int dir, struct xfrm_policy *policy, int excl)
89449 hlist_add_head(&policy->bydst, chain);
89450 xfrm_pol_hold(policy);
89451 net->xfrm.policy_count[dir]++;
89452 - atomic_inc(&flow_cache_genid);
89453 + atomic_inc_unchecked(&flow_cache_genid);
89454 rt_genid_bump(net);
89455 if (delpol)
89456 __xfrm_policy_unlink(delpol, dir);
89457 @@ -1550,7 +1550,7 @@ free_dst:
89458 goto out;
89459 }
89460
89461 -static int inline
89462 +static inline int
89463 xfrm_dst_alloc_copy(void **target, const void *src, int size)
89464 {
89465 if (!*target) {
89466 @@ -1562,7 +1562,7 @@ xfrm_dst_alloc_copy(void **target, const void *src, int size)
89467 return 0;
89468 }
89469
89470 -static int inline
89471 +static inline int
89472 xfrm_dst_update_parent(struct dst_entry *dst, const struct xfrm_selector *sel)
89473 {
89474 #ifdef CONFIG_XFRM_SUB_POLICY
89475 @@ -1574,7 +1574,7 @@ xfrm_dst_update_parent(struct dst_entry *dst, const struct xfrm_selector *sel)
89476 #endif
89477 }
89478
89479 -static int inline
89480 +static inline int
89481 xfrm_dst_update_origin(struct dst_entry *dst, const struct flowi *fl)
89482 {
89483 #ifdef CONFIG_XFRM_SUB_POLICY
89484 @@ -1668,7 +1668,7 @@ xfrm_resolve_and_create_bundle(struct xfrm_policy **pols, int num_pols,
89485
89486 xdst->num_pols = num_pols;
89487 memcpy(xdst->pols, pols, sizeof(struct xfrm_policy*) * num_pols);
89488 - xdst->policy_genid = atomic_read(&pols[0]->genid);
89489 + xdst->policy_genid = atomic_read_unchecked(&pols[0]->genid);
89490
89491 return xdst;
89492 }
89493 @@ -2369,7 +2369,7 @@ static int xfrm_bundle_ok(struct xfrm_dst *first)
89494 if (xdst->xfrm_genid != dst->xfrm->genid)
89495 return 0;
89496 if (xdst->num_pols > 0 &&
89497 - xdst->policy_genid != atomic_read(&xdst->pols[0]->genid))
89498 + xdst->policy_genid != atomic_read_unchecked(&xdst->pols[0]->genid))
89499 return 0;
89500
89501 mtu = dst_mtu(dst->child);
89502 @@ -2457,8 +2457,11 @@ int xfrm_policy_register_afinfo(struct xfrm_policy_afinfo *afinfo)
89503 dst_ops->link_failure = xfrm_link_failure;
89504 if (likely(dst_ops->neigh_lookup == NULL))
89505 dst_ops->neigh_lookup = xfrm_neigh_lookup;
89506 - if (likely(afinfo->garbage_collect == NULL))
89507 - afinfo->garbage_collect = xfrm_garbage_collect_deferred;
89508 + if (likely(afinfo->garbage_collect == NULL)) {
89509 + pax_open_kernel();
89510 + *(void **)&afinfo->garbage_collect = xfrm_garbage_collect_deferred;
89511 + pax_close_kernel();
89512 + }
89513 rcu_assign_pointer(xfrm_policy_afinfo[afinfo->family], afinfo);
89514 }
89515 spin_unlock(&xfrm_policy_afinfo_lock);
89516 @@ -2512,7 +2515,9 @@ int xfrm_policy_unregister_afinfo(struct xfrm_policy_afinfo *afinfo)
89517 dst_ops->check = NULL;
89518 dst_ops->negative_advice = NULL;
89519 dst_ops->link_failure = NULL;
89520 - afinfo->garbage_collect = NULL;
89521 + pax_open_kernel();
89522 + *(void **)&afinfo->garbage_collect = NULL;
89523 + pax_close_kernel();
89524 }
89525 return err;
89526 }
89527 @@ -2896,7 +2901,7 @@ static int xfrm_policy_migrate(struct xfrm_policy *pol,
89528 sizeof(pol->xfrm_vec[i].saddr));
89529 pol->xfrm_vec[i].encap_family = mp->new_family;
89530 /* flush bundles */
89531 - atomic_inc(&pol->genid);
89532 + atomic_inc_unchecked(&pol->genid);
89533 }
89534 }
89535
89536 diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c
89537 index 3459692..e7cdb1a 100644
89538 --- a/net/xfrm/xfrm_state.c
89539 +++ b/net/xfrm/xfrm_state.c
89540 @@ -194,11 +194,13 @@ int xfrm_register_type(const struct xfrm_type *type, unsigned short family)
89541
89542 if (unlikely(afinfo == NULL))
89543 return -EAFNOSUPPORT;
89544 - typemap = afinfo->type_map;
89545 + typemap = (const struct xfrm_type **)afinfo->type_map;
89546
89547 - if (likely(typemap[type->proto] == NULL))
89548 + if (likely(typemap[type->proto] == NULL)) {
89549 + pax_open_kernel();
89550 typemap[type->proto] = type;
89551 - else
89552 + pax_close_kernel();
89553 + } else
89554 err = -EEXIST;
89555 xfrm_state_unlock_afinfo(afinfo);
89556 return err;
89557 @@ -213,12 +215,15 @@ int xfrm_unregister_type(const struct xfrm_type *type, unsigned short family)
89558
89559 if (unlikely(afinfo == NULL))
89560 return -EAFNOSUPPORT;
89561 - typemap = afinfo->type_map;
89562 + typemap = (const struct xfrm_type **)afinfo->type_map;
89563
89564 if (unlikely(typemap[type->proto] != type))
89565 err = -ENOENT;
89566 - else
89567 + else {
89568 + pax_open_kernel();
89569 typemap[type->proto] = NULL;
89570 + pax_close_kernel();
89571 + }
89572 xfrm_state_unlock_afinfo(afinfo);
89573 return err;
89574 }
89575 @@ -227,7 +232,6 @@ EXPORT_SYMBOL(xfrm_unregister_type);
89576 static const struct xfrm_type *xfrm_get_type(u8 proto, unsigned short family)
89577 {
89578 struct xfrm_state_afinfo *afinfo;
89579 - const struct xfrm_type **typemap;
89580 const struct xfrm_type *type;
89581 int modload_attempted = 0;
89582
89583 @@ -235,9 +239,8 @@ retry:
89584 afinfo = xfrm_state_get_afinfo(family);
89585 if (unlikely(afinfo == NULL))
89586 return NULL;
89587 - typemap = afinfo->type_map;
89588
89589 - type = typemap[proto];
89590 + type = afinfo->type_map[proto];
89591 if (unlikely(type && !try_module_get(type->owner)))
89592 type = NULL;
89593 if (!type && !modload_attempted) {
89594 @@ -270,7 +273,7 @@ int xfrm_register_mode(struct xfrm_mode *mode, int family)
89595 return -EAFNOSUPPORT;
89596
89597 err = -EEXIST;
89598 - modemap = afinfo->mode_map;
89599 + modemap = (struct xfrm_mode **)afinfo->mode_map;
89600 if (modemap[mode->encap])
89601 goto out;
89602
89603 @@ -278,8 +281,10 @@ int xfrm_register_mode(struct xfrm_mode *mode, int family)
89604 if (!try_module_get(afinfo->owner))
89605 goto out;
89606
89607 - mode->afinfo = afinfo;
89608 + pax_open_kernel();
89609 + *(const void **)&mode->afinfo = afinfo;
89610 modemap[mode->encap] = mode;
89611 + pax_close_kernel();
89612 err = 0;
89613
89614 out:
89615 @@ -302,9 +307,11 @@ int xfrm_unregister_mode(struct xfrm_mode *mode, int family)
89616 return -EAFNOSUPPORT;
89617
89618 err = -ENOENT;
89619 - modemap = afinfo->mode_map;
89620 + modemap = (struct xfrm_mode **)afinfo->mode_map;
89621 if (likely(modemap[mode->encap] == mode)) {
89622 + pax_open_kernel();
89623 modemap[mode->encap] = NULL;
89624 + pax_close_kernel();
89625 module_put(mode->afinfo->owner);
89626 err = 0;
89627 }
89628 diff --git a/net/xfrm/xfrm_sysctl.c b/net/xfrm/xfrm_sysctl.c
89629 index 05a6e3d..6716ec9 100644
89630 --- a/net/xfrm/xfrm_sysctl.c
89631 +++ b/net/xfrm/xfrm_sysctl.c
89632 @@ -42,7 +42,7 @@ static struct ctl_table xfrm_table[] = {
89633
89634 int __net_init xfrm_sysctl_init(struct net *net)
89635 {
89636 - struct ctl_table *table;
89637 + ctl_table_no_const *table;
89638
89639 __xfrm_sysctl_init(net);
89640
89641 diff --git a/scripts/Makefile.build b/scripts/Makefile.build
89642 index 0e801c3..5c8ad3b 100644
89643 --- a/scripts/Makefile.build
89644 +++ b/scripts/Makefile.build
89645 @@ -111,7 +111,7 @@ endif
89646 endif
89647
89648 # Do not include host rules unless needed
89649 -ifneq ($(hostprogs-y)$(hostprogs-m),)
89650 +ifneq ($(hostprogs-y)$(hostprogs-m)$(hostlibs-y)$(hostlibs-m)$(hostcxxlibs-y)$(hostcxxlibs-m),)
89651 include scripts/Makefile.host
89652 endif
89653
89654 diff --git a/scripts/Makefile.clean b/scripts/Makefile.clean
89655 index 686cb0d..9d653bf 100644
89656 --- a/scripts/Makefile.clean
89657 +++ b/scripts/Makefile.clean
89658 @@ -43,7 +43,8 @@ subdir-ymn := $(addprefix $(obj)/,$(subdir-ymn))
89659 __clean-files := $(extra-y) $(always) \
89660 $(targets) $(clean-files) \
89661 $(host-progs) \
89662 - $(hostprogs-y) $(hostprogs-m) $(hostprogs-)
89663 + $(hostprogs-y) $(hostprogs-m) $(hostprogs-) \
89664 + $(hostlibs-y) $(hostlibs-m) $(hostlibs-)
89665
89666 __clean-files := $(filter-out $(no-clean-files), $(__clean-files))
89667
89668 diff --git a/scripts/Makefile.host b/scripts/Makefile.host
89669 index 1ac414f..38575f7 100644
89670 --- a/scripts/Makefile.host
89671 +++ b/scripts/Makefile.host
89672 @@ -31,6 +31,8 @@
89673 # Note: Shared libraries consisting of C++ files are not supported
89674
89675 __hostprogs := $(sort $(hostprogs-y) $(hostprogs-m))
89676 +__hostlibs := $(sort $(hostlibs-y) $(hostlibs-m))
89677 +__hostcxxlibs := $(sort $(hostcxxlibs-y) $(hostcxxlibs-m))
89678
89679 # C code
89680 # Executables compiled from a single .c file
89681 @@ -54,11 +56,15 @@ host-cxxobjs := $(sort $(foreach m,$(host-cxxmulti),$($(m)-cxxobjs)))
89682 # Shared libaries (only .c supported)
89683 # Shared libraries (.so) - all .so files referenced in "xxx-objs"
89684 host-cshlib := $(sort $(filter %.so, $(host-cobjs)))
89685 +host-cshlib += $(sort $(filter %.so, $(__hostlibs)))
89686 +host-cxxshlib := $(sort $(filter %.so, $(__hostcxxlibs)))
89687 # Remove .so files from "xxx-objs"
89688 host-cobjs := $(filter-out %.so,$(host-cobjs))
89689 +host-cxxobjs := $(filter-out %.so,$(host-cxxobjs))
89690
89691 -#Object (.o) files used by the shared libaries
89692 +# Object (.o) files used by the shared libaries
89693 host-cshobjs := $(sort $(foreach m,$(host-cshlib),$($(m:.so=-objs))))
89694 +host-cxxshobjs := $(sort $(foreach m,$(host-cxxshlib),$($(m:.so=-objs))))
89695
89696 # output directory for programs/.o files
89697 # hostprogs-y := tools/build may have been specified. Retrieve directory
89698 @@ -82,7 +88,9 @@ host-cobjs := $(addprefix $(obj)/,$(host-cobjs))
89699 host-cxxmulti := $(addprefix $(obj)/,$(host-cxxmulti))
89700 host-cxxobjs := $(addprefix $(obj)/,$(host-cxxobjs))
89701 host-cshlib := $(addprefix $(obj)/,$(host-cshlib))
89702 +host-cxxshlib := $(addprefix $(obj)/,$(host-cxxshlib))
89703 host-cshobjs := $(addprefix $(obj)/,$(host-cshobjs))
89704 +host-cxxshobjs := $(addprefix $(obj)/,$(host-cxxshobjs))
89705 host-objdirs := $(addprefix $(obj)/,$(host-objdirs))
89706
89707 obj-dirs += $(host-objdirs)
89708 @@ -156,6 +164,13 @@ quiet_cmd_host-cshobjs = HOSTCC -fPIC $@
89709 $(host-cshobjs): $(obj)/%.o: $(src)/%.c FORCE
89710 $(call if_changed_dep,host-cshobjs)
89711
89712 +# Compile .c file, create position independent .o file
89713 +# host-cxxshobjs -> .o
89714 +quiet_cmd_host-cxxshobjs = HOSTCXX -fPIC $@
89715 + cmd_host-cxxshobjs = $(HOSTCXX) $(hostcxx_flags) -fPIC -c -o $@ $<
89716 +$(host-cxxshobjs): $(obj)/%.o: $(src)/%.c FORCE
89717 + $(call if_changed_dep,host-cxxshobjs)
89718 +
89719 # Link a shared library, based on position independent .o files
89720 # *.o -> .so shared library (host-cshlib)
89721 quiet_cmd_host-cshlib = HOSTLLD -shared $@
89722 @@ -165,6 +180,15 @@ quiet_cmd_host-cshlib = HOSTLLD -shared $@
89723 $(host-cshlib): $(obj)/%: $(host-cshobjs) FORCE
89724 $(call if_changed,host-cshlib)
89725
89726 +# Link a shared library, based on position independent .o files
89727 +# *.o -> .so shared library (host-cxxshlib)
89728 +quiet_cmd_host-cxxshlib = HOSTLLD -shared $@
89729 + cmd_host-cxxshlib = $(HOSTCXX) $(HOSTLDFLAGS) -shared -o $@ \
89730 + $(addprefix $(obj)/,$($(@F:.so=-objs))) \
89731 + $(HOST_LOADLIBES) $(HOSTLOADLIBES_$(@F))
89732 +$(host-cxxshlib): $(obj)/%: $(host-cxxshobjs) FORCE
89733 + $(call if_changed,host-cxxshlib)
89734 +
89735 targets += $(host-csingle) $(host-cmulti) $(host-cobjs)\
89736 - $(host-cxxmulti) $(host-cxxobjs) $(host-cshlib) $(host-cshobjs)
89737 + $(host-cxxmulti) $(host-cxxobjs) $(host-cshlib) $(host-cshobjs) $(host-cxxshlib) $(host-cxxshobjs)
89738
89739 diff --git a/scripts/basic/fixdep.c b/scripts/basic/fixdep.c
89740 index cb1f50c..cef2a7c 100644
89741 --- a/scripts/basic/fixdep.c
89742 +++ b/scripts/basic/fixdep.c
89743 @@ -161,7 +161,7 @@ static unsigned int strhash(const char *str, unsigned int sz)
89744 /*
89745 * Lookup a value in the configuration string.
89746 */
89747 -static int is_defined_config(const char *name, int len, unsigned int hash)
89748 +static int is_defined_config(const char *name, unsigned int len, unsigned int hash)
89749 {
89750 struct item *aux;
89751
89752 @@ -211,10 +211,10 @@ static void clear_config(void)
89753 /*
89754 * Record the use of a CONFIG_* word.
89755 */
89756 -static void use_config(const char *m, int slen)
89757 +static void use_config(const char *m, unsigned int slen)
89758 {
89759 unsigned int hash = strhash(m, slen);
89760 - int c, i;
89761 + unsigned int c, i;
89762
89763 if (is_defined_config(m, slen, hash))
89764 return;
89765 @@ -235,9 +235,9 @@ static void use_config(const char *m, int slen)
89766
89767 static void parse_config_file(const char *map, size_t len)
89768 {
89769 - const int *end = (const int *) (map + len);
89770 + const unsigned int *end = (const unsigned int *) (map + len);
89771 /* start at +1, so that p can never be < map */
89772 - const int *m = (const int *) map + 1;
89773 + const unsigned int *m = (const unsigned int *) map + 1;
89774 const char *p, *q;
89775
89776 for (; m < end; m++) {
89777 @@ -406,7 +406,7 @@ static void print_deps(void)
89778 static void traps(void)
89779 {
89780 static char test[] __attribute__((aligned(sizeof(int)))) = "CONF";
89781 - int *p = (int *)test;
89782 + unsigned int *p = (unsigned int *)test;
89783
89784 if (*p != INT_CONF) {
89785 fprintf(stderr, "fixdep: sizeof(int) != 4 or wrong endianess? %#x\n",
89786 diff --git a/scripts/gcc-plugin.sh b/scripts/gcc-plugin.sh
89787 new file mode 100644
89788 index 0000000..5e0222d
89789 --- /dev/null
89790 +++ b/scripts/gcc-plugin.sh
89791 @@ -0,0 +1,17 @@
89792 +#!/bin/bash
89793 +plugincc=`$1 -E -shared - -o /dev/null -I\`$3 -print-file-name=plugin\`/include 2>&1 <<EOF
89794 +#include "gcc-plugin.h"
89795 +#include "tree.h"
89796 +#include "tm.h"
89797 +#include "rtl.h"
89798 +#ifdef ENABLE_BUILD_WITH_CXX
89799 +#warning $2
89800 +#else
89801 +#warning $1
89802 +#endif
89803 +EOF`
89804 +if [ $? -eq 0 ]
89805 +then
89806 + [[ "$plugincc" =~ "$1" ]] && echo "$1"
89807 + [[ "$plugincc" =~ "$2" ]] && echo "$2"
89808 +fi
89809 diff --git a/scripts/link-vmlinux.sh b/scripts/link-vmlinux.sh
89810 index b3d907e..a4782ab 100644
89811 --- a/scripts/link-vmlinux.sh
89812 +++ b/scripts/link-vmlinux.sh
89813 @@ -152,7 +152,7 @@ else
89814 fi;
89815
89816 # final build of init/
89817 -${MAKE} -f "${srctree}/scripts/Makefile.build" obj=init
89818 +${MAKE} -f "${srctree}/scripts/Makefile.build" obj=init GCC_PLUGINS_CFLAGS="${GCC_PLUGINS_CFLAGS}" GCC_PLUGINS_AFLAGS="${GCC_PLUGINS_AFLAGS}"
89819
89820 kallsymso=""
89821 kallsyms_vmlinux=""
89822 diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c
89823 index df4fc23..0ea719d 100644
89824 --- a/scripts/mod/file2alias.c
89825 +++ b/scripts/mod/file2alias.c
89826 @@ -128,7 +128,7 @@ static void device_id_check(const char *modname, const char *device_id,
89827 unsigned long size, unsigned long id_size,
89828 void *symval)
89829 {
89830 - int i;
89831 + unsigned int i;
89832
89833 if (size % id_size || size < id_size) {
89834 if (cross_build != 0)
89835 @@ -158,7 +158,7 @@ static void device_id_check(const char *modname, const char *device_id,
89836 /* USB is special because the bcdDevice can be matched against a numeric range */
89837 /* Looks like "usb:vNpNdNdcNdscNdpNicNiscNipNinN" */
89838 static void do_usb_entry(struct usb_device_id *id,
89839 - unsigned int bcdDevice_initial, int bcdDevice_initial_digits,
89840 + unsigned int bcdDevice_initial, unsigned int bcdDevice_initial_digits,
89841 unsigned char range_lo, unsigned char range_hi,
89842 unsigned char max, struct module *mod)
89843 {
89844 @@ -262,7 +262,7 @@ static void do_usb_entry_multi(struct usb_device_id *id, struct module *mod)
89845 {
89846 unsigned int devlo, devhi;
89847 unsigned char chi, clo, max;
89848 - int ndigits;
89849 + unsigned int ndigits;
89850
89851 id->match_flags = TO_NATIVE(id->match_flags);
89852 id->idVendor = TO_NATIVE(id->idVendor);
89853 @@ -507,7 +507,7 @@ static void do_pnp_device_entry(void *symval, unsigned long size,
89854 for (i = 0; i < count; i++) {
89855 const char *id = (char *)devs[i].id;
89856 char acpi_id[sizeof(devs[0].id)];
89857 - int j;
89858 + unsigned int j;
89859
89860 buf_printf(&mod->dev_table_buf,
89861 "MODULE_ALIAS(\"pnp:d%s*\");\n", id);
89862 @@ -537,7 +537,7 @@ static void do_pnp_card_entries(void *symval, unsigned long size,
89863
89864 for (j = 0; j < PNP_MAX_DEVICES; j++) {
89865 const char *id = (char *)card->devs[j].id;
89866 - int i2, j2;
89867 + unsigned int i2, j2;
89868 int dup = 0;
89869
89870 if (!id[0])
89871 @@ -563,7 +563,7 @@ static void do_pnp_card_entries(void *symval, unsigned long size,
89872 /* add an individual alias for every device entry */
89873 if (!dup) {
89874 char acpi_id[sizeof(card->devs[0].id)];
89875 - int k;
89876 + unsigned int k;
89877
89878 buf_printf(&mod->dev_table_buf,
89879 "MODULE_ALIAS(\"pnp:d%s*\");\n", id);
89880 @@ -888,7 +888,7 @@ static void dmi_ascii_filter(char *d, const char *s)
89881 static int do_dmi_entry(const char *filename, struct dmi_system_id *id,
89882 char *alias)
89883 {
89884 - int i, j;
89885 + unsigned int i, j;
89886
89887 sprintf(alias, "dmi*");
89888
89889 diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
89890 index ff36c50..7ab4fa9 100644
89891 --- a/scripts/mod/modpost.c
89892 +++ b/scripts/mod/modpost.c
89893 @@ -929,6 +929,7 @@ enum mismatch {
89894 ANY_INIT_TO_ANY_EXIT,
89895 ANY_EXIT_TO_ANY_INIT,
89896 EXPORT_TO_INIT_EXIT,
89897 + DATA_TO_TEXT
89898 };
89899
89900 struct sectioncheck {
89901 @@ -1043,6 +1044,12 @@ const struct sectioncheck sectioncheck[] = {
89902 .tosec = { INIT_SECTIONS, EXIT_SECTIONS, NULL },
89903 .mismatch = EXPORT_TO_INIT_EXIT,
89904 .symbol_white_list = { DEFAULT_SYMBOL_WHITE_LIST, NULL },
89905 +},
89906 +/* Do not reference code from writable data */
89907 +{
89908 + .fromsec = { DATA_SECTIONS, NULL },
89909 + .tosec = { TEXT_SECTIONS, NULL },
89910 + .mismatch = DATA_TO_TEXT
89911 }
89912 };
89913
89914 @@ -1165,10 +1172,10 @@ static Elf_Sym *find_elf_symbol(struct elf_info *elf, Elf64_Sword addr,
89915 continue;
89916 if (ELF_ST_TYPE(sym->st_info) == STT_SECTION)
89917 continue;
89918 - if (sym->st_value == addr)
89919 - return sym;
89920 /* Find a symbol nearby - addr are maybe negative */
89921 d = sym->st_value - addr;
89922 + if (d == 0)
89923 + return sym;
89924 if (d < 0)
89925 d = addr - sym->st_value;
89926 if (d < distance) {
89927 @@ -1447,6 +1454,14 @@ static void report_sec_mismatch(const char *modname,
89928 tosym, prl_to, prl_to, tosym);
89929 free(prl_to);
89930 break;
89931 + case DATA_TO_TEXT:
89932 +#if 0
89933 + fprintf(stderr,
89934 + "The %s %s:%s references\n"
89935 + "the %s %s:%s%s\n",
89936 + from, fromsec, fromsym, to, tosec, tosym, to_p);
89937 +#endif
89938 + break;
89939 }
89940 fprintf(stderr, "\n");
89941 }
89942 @@ -1681,7 +1696,7 @@ static void section_rel(const char *modname, struct elf_info *elf,
89943 static void check_sec_ref(struct module *mod, const char *modname,
89944 struct elf_info *elf)
89945 {
89946 - int i;
89947 + unsigned int i;
89948 Elf_Shdr *sechdrs = elf->sechdrs;
89949
89950 /* Walk through all sections */
89951 @@ -1779,7 +1794,7 @@ void __attribute__((format(printf, 2, 3))) buf_printf(struct buffer *buf,
89952 va_end(ap);
89953 }
89954
89955 -void buf_write(struct buffer *buf, const char *s, int len)
89956 +void buf_write(struct buffer *buf, const char *s, unsigned int len)
89957 {
89958 if (buf->size - buf->pos < len) {
89959 buf->size += len + SZ;
89960 @@ -1997,7 +2012,7 @@ static void write_if_changed(struct buffer *b, const char *fname)
89961 if (fstat(fileno(file), &st) < 0)
89962 goto close_write;
89963
89964 - if (st.st_size != b->pos)
89965 + if (st.st_size != (off_t)b->pos)
89966 goto close_write;
89967
89968 tmp = NOFAIL(malloc(b->pos));
89969 diff --git a/scripts/mod/modpost.h b/scripts/mod/modpost.h
89970 index 51207e4..f7d603d 100644
89971 --- a/scripts/mod/modpost.h
89972 +++ b/scripts/mod/modpost.h
89973 @@ -92,15 +92,15 @@ void *do_nofail(void *ptr, const char *expr);
89974
89975 struct buffer {
89976 char *p;
89977 - int pos;
89978 - int size;
89979 + unsigned int pos;
89980 + unsigned int size;
89981 };
89982
89983 void __attribute__((format(printf, 2, 3)))
89984 buf_printf(struct buffer *buf, const char *fmt, ...);
89985
89986 void
89987 -buf_write(struct buffer *buf, const char *s, int len);
89988 +buf_write(struct buffer *buf, const char *s, unsigned int len);
89989
89990 struct module {
89991 struct module *next;
89992 diff --git a/scripts/mod/sumversion.c b/scripts/mod/sumversion.c
89993 index 9dfcd6d..099068e 100644
89994 --- a/scripts/mod/sumversion.c
89995 +++ b/scripts/mod/sumversion.c
89996 @@ -470,7 +470,7 @@ static void write_version(const char *filename, const char *sum,
89997 goto out;
89998 }
89999
90000 - if (write(fd, sum, strlen(sum)+1) != strlen(sum)+1) {
90001 + if (write(fd, sum, strlen(sum)+1) != (ssize_t)strlen(sum)+1) {
90002 warn("writing sum in %s failed: %s\n",
90003 filename, strerror(errno));
90004 goto out;
90005 diff --git a/scripts/package/builddeb b/scripts/package/builddeb
90006 index acb8650..b8c5f02 100644
90007 --- a/scripts/package/builddeb
90008 +++ b/scripts/package/builddeb
90009 @@ -246,6 +246,7 @@ fi
90010 (cd $srctree; find . -name Makefile\* -o -name Kconfig\* -o -name \*.pl > "$objtree/debian/hdrsrcfiles")
90011 (cd $srctree; find arch/$SRCARCH/include include scripts -type f >> "$objtree/debian/hdrsrcfiles")
90012 (cd $objtree; find arch/$SRCARCH/include .config Module.symvers include scripts -type f >> "$objtree/debian/hdrobjfiles")
90013 +(cd $objtree; find tools/gcc -name \*.so >> "$objtree/debian/hdrobjfiles")
90014 destdir=$kernel_headers_dir/usr/src/linux-headers-$version
90015 mkdir -p "$destdir"
90016 (cd $srctree; tar -c -f - -T "$objtree/debian/hdrsrcfiles") | (cd $destdir; tar -xf -)
90017 diff --git a/scripts/pnmtologo.c b/scripts/pnmtologo.c
90018 index 68bb4ef..2f419e1 100644
90019 --- a/scripts/pnmtologo.c
90020 +++ b/scripts/pnmtologo.c
90021 @@ -244,14 +244,14 @@ static void write_header(void)
90022 fprintf(out, " * Linux logo %s\n", logoname);
90023 fputs(" */\n\n", out);
90024 fputs("#include <linux/linux_logo.h>\n\n", out);
90025 - fprintf(out, "static unsigned char %s_data[] __initdata = {\n",
90026 + fprintf(out, "static unsigned char %s_data[] = {\n",
90027 logoname);
90028 }
90029
90030 static void write_footer(void)
90031 {
90032 fputs("\n};\n\n", out);
90033 - fprintf(out, "const struct linux_logo %s __initconst = {\n", logoname);
90034 + fprintf(out, "const struct linux_logo %s = {\n", logoname);
90035 fprintf(out, "\t.type\t\t= %s,\n", logo_types[logo_type]);
90036 fprintf(out, "\t.width\t\t= %d,\n", logo_width);
90037 fprintf(out, "\t.height\t\t= %d,\n", logo_height);
90038 @@ -381,7 +381,7 @@ static void write_logo_clut224(void)
90039 fputs("\n};\n\n", out);
90040
90041 /* write logo clut */
90042 - fprintf(out, "static unsigned char %s_clut[] __initdata = {\n",
90043 + fprintf(out, "static unsigned char %s_clut[] = {\n",
90044 logoname);
90045 write_hex_cnt = 0;
90046 for (i = 0; i < logo_clutsize; i++) {
90047 diff --git a/scripts/sortextable.h b/scripts/sortextable.h
90048 index e4fd45b..2eeb5c4 100644
90049 --- a/scripts/sortextable.h
90050 +++ b/scripts/sortextable.h
90051 @@ -106,9 +106,9 @@ do_func(Elf_Ehdr *ehdr, char const *const fname, table_sort_t custom_sort)
90052 const char *secstrtab;
90053 const char *strtab;
90054 char *extab_image;
90055 - int extab_index = 0;
90056 - int i;
90057 - int idx;
90058 + unsigned int extab_index = 0;
90059 + unsigned int i;
90060 + unsigned int idx;
90061
90062 shdr = (Elf_Shdr *)((char *)ehdr + _r(&ehdr->e_shoff));
90063 shstrtab_sec = shdr + r2(&ehdr->e_shstrndx);
90064 diff --git a/security/Kconfig b/security/Kconfig
90065 index e9c6ac7..952353c 100644
90066 --- a/security/Kconfig
90067 +++ b/security/Kconfig
90068 @@ -4,6 +4,925 @@
90069
90070 menu "Security options"
90071
90072 +menu "Grsecurity"
90073 +
90074 + config ARCH_TRACK_EXEC_LIMIT
90075 + bool
90076 +
90077 + config PAX_KERNEXEC_PLUGIN
90078 + bool
90079 +
90080 + config PAX_PER_CPU_PGD
90081 + bool
90082 +
90083 + config TASK_SIZE_MAX_SHIFT
90084 + int
90085 + depends on X86_64
90086 + default 47 if !PAX_PER_CPU_PGD
90087 + default 42 if PAX_PER_CPU_PGD
90088 +
90089 + config PAX_ENABLE_PAE
90090 + bool
90091 + default y if (X86_32 && (MPENTIUM4 || MK8 || MPSC || MCORE2 || MATOM))
90092 +
90093 + config PAX_USERCOPY_SLABS
90094 + bool
90095 +
90096 +config GRKERNSEC
90097 + bool "Grsecurity"
90098 + select CRYPTO
90099 + select CRYPTO_SHA256
90100 + select PROC_FS
90101 + select STOP_MACHINE
90102 + help
90103 + If you say Y here, you will be able to configure many features
90104 + that will enhance the security of your system. It is highly
90105 + recommended that you say Y here and read through the help
90106 + for each option so that you fully understand the features and
90107 + can evaluate their usefulness for your machine.
90108 +
90109 +choice
90110 + prompt "Configuration Method"
90111 + depends on GRKERNSEC
90112 + default GRKERNSEC_CONFIG_CUSTOM
90113 + help
90114 +
90115 +config GRKERNSEC_CONFIG_AUTO
90116 + bool "Automatic"
90117 + help
90118 + If you choose this configuration method, you'll be able to answer a small
90119 + number of simple questions about how you plan to use this kernel.
90120 + The settings of grsecurity and PaX will be automatically configured for
90121 + the highest commonly-used settings within the provided constraints.
90122 +
90123 + If you require additional configuration, custom changes can still be made
90124 + from the "custom configuration" menu.
90125 +
90126 +config GRKERNSEC_CONFIG_CUSTOM
90127 + bool "Custom"
90128 + help
90129 + If you choose this configuration method, you'll be able to configure all
90130 + grsecurity and PaX settings manually. Via this method, no options are
90131 + automatically enabled.
90132 +
90133 +endchoice
90134 +
90135 +choice
90136 + prompt "Usage Type"
90137 + depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO)
90138 + default GRKERNSEC_CONFIG_SERVER
90139 + help
90140 +
90141 +config GRKERNSEC_CONFIG_SERVER
90142 + bool "Server"
90143 + help
90144 + Choose this option if you plan to use this kernel on a server.
90145 +
90146 +config GRKERNSEC_CONFIG_DESKTOP
90147 + bool "Desktop"
90148 + help
90149 + Choose this option if you plan to use this kernel on a desktop.
90150 +
90151 +endchoice
90152 +
90153 +choice
90154 + prompt "Virtualization Type"
90155 + depends on (GRKERNSEC && X86 && GRKERNSEC_CONFIG_AUTO)
90156 + default GRKERNSEC_CONFIG_VIRT_NONE
90157 + help
90158 +
90159 +config GRKERNSEC_CONFIG_VIRT_NONE
90160 + bool "None"
90161 + help
90162 + Choose this option if this kernel will be run on bare metal.
90163 +
90164 +config GRKERNSEC_CONFIG_VIRT_GUEST
90165 + bool "Guest"
90166 + help
90167 + Choose this option if this kernel will be run as a VM guest.
90168 +
90169 +config GRKERNSEC_CONFIG_VIRT_HOST
90170 + bool "Host"
90171 + help
90172 + Choose this option if this kernel will be run as a VM host.
90173 +
90174 +endchoice
90175 +
90176 +choice
90177 + prompt "Virtualization Hardware"
90178 + depends on (GRKERNSEC && X86 && GRKERNSEC_CONFIG_AUTO && (GRKERNSEC_CONFIG_VIRT_GUEST || GRKERNSEC_CONFIG_VIRT_HOST))
90179 + help
90180 +
90181 +config GRKERNSEC_CONFIG_VIRT_EPT
90182 + bool "EPT/RVI Processor Support"
90183 + depends on X86
90184 + help
90185 + Choose this option if your CPU supports the EPT or RVI features of 2nd-gen
90186 + hardware virtualization. This allows for additional kernel hardening protections
90187 + to operate without additional performance impact.
90188 +
90189 + To see if your Intel processor supports EPT, see:
90190 + http://ark.intel.com/Products/VirtualizationTechnology
90191 + (Most Core i3/5/7 support EPT)
90192 +
90193 + To see if your AMD processor supports RVI, see:
90194 + http://support.amd.com/us/kbarticles/Pages/GPU120AMDRVICPUsHyperVWin8.aspx
90195 +
90196 +config GRKERNSEC_CONFIG_VIRT_SOFT
90197 + bool "First-gen/No Hardware Virtualization"
90198 + help
90199 + Choose this option if you use an Atom/Pentium/Core 2 processor that either doesn't
90200 + support hardware virtualization or doesn't support the EPT/RVI extensions.
90201 +
90202 +endchoice
90203 +
90204 +choice
90205 + prompt "Virtualization Software"
90206 + depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO && (GRKERNSEC_CONFIG_VIRT_GUEST || GRKERNSEC_CONFIG_VIRT_HOST))
90207 + help
90208 +
90209 +config GRKERNSEC_CONFIG_VIRT_XEN
90210 + bool "Xen"
90211 + help
90212 + Choose this option if this kernel is running as a Xen guest or host.
90213 +
90214 +config GRKERNSEC_CONFIG_VIRT_VMWARE
90215 + bool "VMWare"
90216 + help
90217 + Choose this option if this kernel is running as a VMWare guest or host.
90218 +
90219 +config GRKERNSEC_CONFIG_VIRT_KVM
90220 + bool "KVM"
90221 + help
90222 + Choose this option if this kernel is running as a KVM guest or host.
90223 +
90224 +config GRKERNSEC_CONFIG_VIRT_VIRTUALBOX
90225 + bool "VirtualBox"
90226 + help
90227 + Choose this option if this kernel is running as a VirtualBox guest or host.
90228 +
90229 +endchoice
90230 +
90231 +choice
90232 + prompt "Required Priorities"
90233 + depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO)
90234 + default GRKERNSEC_CONFIG_PRIORITY_PERF
90235 + help
90236 +
90237 +config GRKERNSEC_CONFIG_PRIORITY_PERF
90238 + bool "Performance"
90239 + help
90240 + Choose this option if performance is of highest priority for this deployment
90241 + of grsecurity. Features like UDEREF on a 64bit kernel, kernel stack clearing,
90242 + and freed memory sanitizing will be disabled.
90243 +
90244 +config GRKERNSEC_CONFIG_PRIORITY_SECURITY
90245 + bool "Security"
90246 + help
90247 + Choose this option if security is of highest priority for this deployment of
90248 + grsecurity. UDEREF, kernel stack clearing, and freed memory sanitizing will
90249 + be enabled for this kernel. In a worst-case scenario, these features can
90250 + introduce a 20% performance hit (UDEREF on x64 contributing half of this hit).
90251 +
90252 +endchoice
90253 +
90254 +menu "Default Special Groups"
90255 +depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO)
90256 +
90257 +config GRKERNSEC_PROC_GID
90258 + int "GID exempted from /proc restrictions"
90259 + default 1001
90260 + help
90261 + Setting this GID determines which group will be exempted from
90262 + grsecurity's /proc restrictions, allowing users of the specified
90263 + group to view network statistics and the existence of other users'
90264 + processes on the system. This GID may also be chosen at boot time
90265 + via "grsec_proc_gid=" on the kernel commandline.
90266 +
90267 +config GRKERNSEC_TPE_UNTRUSTED_GID
90268 + int "GID for TPE-untrusted users"
90269 + depends on GRKERNSEC_CONFIG_SERVER && GRKERNSEC_TPE && !GRKERNSEC_TPE_INVERT
90270 + default 1005
90271 + help
90272 + Setting this GID determines which group untrusted users should
90273 + be added to. These users will be placed under grsecurity's Trusted Path
90274 + Execution mechanism, preventing them from executing their own binaries.
90275 + The users will only be able to execute binaries in directories owned and
90276 + writable only by the root user. If the sysctl option is enabled, a sysctl
90277 + option with name "tpe_gid" is created.
90278 +
90279 +config GRKERNSEC_TPE_TRUSTED_GID
90280 + int "GID for TPE-trusted users"
90281 + depends on GRKERNSEC_CONFIG_SERVER && GRKERNSEC_TPE && GRKERNSEC_TPE_INVERT
90282 + default 1005
90283 + help
90284 + Setting this GID determines what group TPE restrictions will be
90285 + *disabled* for. If the sysctl option is enabled, a sysctl option
90286 + with name "tpe_gid" is created.
90287 +
90288 +config GRKERNSEC_SYMLINKOWN_GID
90289 + int "GID for users with kernel-enforced SymlinksIfOwnerMatch"
90290 + depends on GRKERNSEC_CONFIG_SERVER
90291 + default 1006
90292 + help
90293 + Setting this GID determines what group kernel-enforced
90294 + SymlinksIfOwnerMatch will be enabled for. If the sysctl option
90295 + is enabled, a sysctl option with name "symlinkown_gid" is created.
90296 +
90297 +
90298 +endmenu
90299 +
90300 +menu "Customize Configuration"
90301 +depends on GRKERNSEC
90302 +
90303 +menu "PaX"
90304 +
90305 +config PAX
90306 + bool "Enable various PaX features"
90307 + default y if GRKERNSEC_CONFIG_AUTO
90308 + depends on GRKERNSEC && (ALPHA || ARM || AVR32 || IA64 || MIPS || PARISC || PPC || SPARC || X86)
90309 + help
90310 + This allows you to enable various PaX features. PaX adds
90311 + intrusion prevention mechanisms to the kernel that reduce
90312 + the risks posed by exploitable memory corruption bugs.
90313 +
90314 +menu "PaX Control"
90315 + depends on PAX
90316 +
90317 +config PAX_SOFTMODE
90318 + bool 'Support soft mode'
90319 + help
90320 + Enabling this option will allow you to run PaX in soft mode, that
90321 + is, PaX features will not be enforced by default, only on executables
90322 + marked explicitly. You must also enable PT_PAX_FLAGS or XATTR_PAX_FLAGS
90323 + support as they are the only way to mark executables for soft mode use.
90324 +
90325 + Soft mode can be activated by using the "pax_softmode=1" kernel command
90326 + line option on boot. Furthermore you can control various PaX features
90327 + at runtime via the entries in /proc/sys/kernel/pax.
90328 +
90329 +config PAX_EI_PAX
90330 + bool 'Use legacy ELF header marking'
90331 + default y if GRKERNSEC_CONFIG_AUTO
90332 + help
90333 + Enabling this option will allow you to control PaX features on
90334 + a per executable basis via the 'chpax' utility available at
90335 + http://pax.grsecurity.net/. The control flags will be read from
90336 + an otherwise reserved part of the ELF header. This marking has
90337 + numerous drawbacks (no support for soft-mode, toolchain does not
90338 + know about the non-standard use of the ELF header) therefore it
90339 + has been deprecated in favour of PT_PAX_FLAGS and XATTR_PAX_FLAGS
90340 + support.
90341 +
90342 + Note that if you enable PT_PAX_FLAGS or XATTR_PAX_FLAGS marking
90343 + support as well, they will override the legacy EI_PAX marks.
90344 +
90345 + If you enable none of the marking options then all applications
90346 + will run with PaX enabled on them by default.
90347 +
90348 +config PAX_PT_PAX_FLAGS
90349 + bool 'Use ELF program header marking'
90350 + default y if GRKERNSEC_CONFIG_AUTO
90351 + help
90352 + Enabling this option will allow you to control PaX features on
90353 + a per executable basis via the 'paxctl' utility available at
90354 + http://pax.grsecurity.net/. The control flags will be read from
90355 + a PaX specific ELF program header (PT_PAX_FLAGS). This marking
90356 + has the benefits of supporting both soft mode and being fully
90357 + integrated into the toolchain (the binutils patch is available
90358 + from http://pax.grsecurity.net).
90359 +
90360 + Note that if you enable the legacy EI_PAX marking support as well,
90361 + the EI_PAX marks will be overridden by the PT_PAX_FLAGS marks.
90362 +
90363 + If you enable both PT_PAX_FLAGS and XATTR_PAX_FLAGS support then you
90364 + must make sure that the marks are the same if a binary has both marks.
90365 +
90366 + If you enable none of the marking options then all applications
90367 + will run with PaX enabled on them by default.
90368 +
90369 +config PAX_XATTR_PAX_FLAGS
90370 + bool 'Use filesystem extended attributes marking'
90371 + default y if GRKERNSEC_CONFIG_AUTO
90372 + select CIFS_XATTR if CIFS
90373 + select EXT2_FS_XATTR if EXT2_FS
90374 + select EXT3_FS_XATTR if EXT3_FS
90375 + select EXT4_FS_XATTR if EXT4_FS
90376 + select JFFS2_FS_XATTR if JFFS2_FS
90377 + select REISERFS_FS_XATTR if REISERFS_FS
90378 + select SQUASHFS_XATTR if SQUASHFS
90379 + select TMPFS_XATTR if TMPFS
90380 + select UBIFS_FS_XATTR if UBIFS_FS
90381 + help
90382 + Enabling this option will allow you to control PaX features on
90383 + a per executable basis via the 'setfattr' utility. The control
90384 + flags will be read from the user.pax.flags extended attribute of
90385 + the file. This marking has the benefit of supporting binary-only
90386 + applications that self-check themselves (e.g., skype) and would
90387 + not tolerate chpax/paxctl changes. The main drawback is that
90388 + extended attributes are not supported by some filesystems (e.g.,
90389 + isofs, udf, vfat) so copying files through such filesystems will
90390 + lose the extended attributes and these PaX markings.
90391 +
90392 + Note that if you enable the legacy EI_PAX marking support as well,
90393 + the EI_PAX marks will be overridden by the XATTR_PAX_FLAGS marks.
90394 +
90395 + If you enable both PT_PAX_FLAGS and XATTR_PAX_FLAGS support then you
90396 + must make sure that the marks are the same if a binary has both marks.
90397 +
90398 + If you enable none of the marking options then all applications
90399 + will run with PaX enabled on them by default.
90400 +
90401 +choice
90402 + prompt 'MAC system integration'
90403 + default PAX_HAVE_ACL_FLAGS
90404 + help
90405 + Mandatory Access Control systems have the option of controlling
90406 + PaX flags on a per executable basis, choose the method supported
90407 + by your particular system.
90408 +
90409 + - "none": if your MAC system does not interact with PaX,
90410 + - "direct": if your MAC system defines pax_set_initial_flags() itself,
90411 + - "hook": if your MAC system uses the pax_set_initial_flags_func callback.
90412 +
90413 + NOTE: this option is for developers/integrators only.
90414 +
90415 + config PAX_NO_ACL_FLAGS
90416 + bool 'none'
90417 +
90418 + config PAX_HAVE_ACL_FLAGS
90419 + bool 'direct'
90420 +
90421 + config PAX_HOOK_ACL_FLAGS
90422 + bool 'hook'
90423 +endchoice
90424 +
90425 +endmenu
90426 +
90427 +menu "Non-executable pages"
90428 + depends on PAX
90429 +
90430 +config PAX_NOEXEC
90431 + bool "Enforce non-executable pages"
90432 + default y if GRKERNSEC_CONFIG_AUTO
90433 + depends on ALPHA || (ARM && (CPU_V6 || CPU_V7)) || IA64 || MIPS || PARISC || PPC || S390 || SPARC || X86
90434 + help
90435 + By design some architectures do not allow for protecting memory
90436 + pages against execution or even if they do, Linux does not make
90437 + use of this feature. In practice this means that if a page is
90438 + readable (such as the stack or heap) it is also executable.
90439 +
90440 + There is a well known exploit technique that makes use of this
90441 + fact and a common programming mistake where an attacker can
90442 + introduce code of his choice somewhere in the attacked program's
90443 + memory (typically the stack or the heap) and then execute it.
90444 +
90445 + If the attacked program was running with different (typically
90446 + higher) privileges than that of the attacker, then he can elevate
90447 + his own privilege level (e.g. get a root shell, write to files for
90448 + which he does not have write access to, etc).
90449 +
90450 + Enabling this option will let you choose from various features
90451 + that prevent the injection and execution of 'foreign' code in
90452 + a program.
90453 +
90454 + This will also break programs that rely on the old behaviour and
90455 + expect that dynamically allocated memory via the malloc() family
90456 + of functions is executable (which it is not). Notable examples
90457 + are the XFree86 4.x server, the java runtime and wine.
90458 +
90459 +config PAX_PAGEEXEC
90460 + bool "Paging based non-executable pages"
90461 + default y if GRKERNSEC_CONFIG_AUTO
90462 + 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)
90463 + select S390_SWITCH_AMODE if S390
90464 + select S390_EXEC_PROTECT if S390
90465 + select ARCH_TRACK_EXEC_LIMIT if X86_32
90466 + help
90467 + This implementation is based on the paging feature of the CPU.
90468 + On i386 without hardware non-executable bit support there is a
90469 + variable but usually low performance impact, however on Intel's
90470 + P4 core based CPUs it is very high so you should not enable this
90471 + for kernels meant to be used on such CPUs.
90472 +
90473 + On alpha, avr32, ia64, parisc, sparc, sparc64, x86_64 and i386
90474 + with hardware non-executable bit support there is no performance
90475 + impact, on ppc the impact is negligible.
90476 +
90477 + Note that several architectures require various emulations due to
90478 + badly designed userland ABIs, this will cause a performance impact
90479 + but will disappear as soon as userland is fixed. For example, ppc
90480 + userland MUST have been built with secure-plt by a recent toolchain.
90481 +
90482 +config PAX_SEGMEXEC
90483 + bool "Segmentation based non-executable pages"
90484 + default y if GRKERNSEC_CONFIG_AUTO
90485 + depends on PAX_NOEXEC && X86_32
90486 + help
90487 + This implementation is based on the segmentation feature of the
90488 + CPU and has a very small performance impact, however applications
90489 + will be limited to a 1.5 GB address space instead of the normal
90490 + 3 GB.
90491 +
90492 +config PAX_EMUTRAMP
90493 + bool "Emulate trampolines" if (PAX_PAGEEXEC || PAX_SEGMEXEC) && (PARISC || X86)
90494 + default y if PARISC
90495 + help
90496 + There are some programs and libraries that for one reason or
90497 + another attempt to execute special small code snippets from
90498 + non-executable memory pages. Most notable examples are the
90499 + signal handler return code generated by the kernel itself and
90500 + the GCC trampolines.
90501 +
90502 + If you enabled CONFIG_PAX_PAGEEXEC or CONFIG_PAX_SEGMEXEC then
90503 + such programs will no longer work under your kernel.
90504 +
90505 + As a remedy you can say Y here and use the 'chpax' or 'paxctl'
90506 + utilities to enable trampoline emulation for the affected programs
90507 + yet still have the protection provided by the non-executable pages.
90508 +
90509 + On parisc you MUST enable this option and EMUSIGRT as well, otherwise
90510 + your system will not even boot.
90511 +
90512 + Alternatively you can say N here and use the 'chpax' or 'paxctl'
90513 + utilities to disable CONFIG_PAX_PAGEEXEC and CONFIG_PAX_SEGMEXEC
90514 + for the affected files.
90515 +
90516 + NOTE: enabling this feature *may* open up a loophole in the
90517 + protection provided by non-executable pages that an attacker
90518 + could abuse. Therefore the best solution is to not have any
90519 + files on your system that would require this option. This can
90520 + be achieved by not using libc5 (which relies on the kernel
90521 + signal handler return code) and not using or rewriting programs
90522 + that make use of the nested function implementation of GCC.
90523 + Skilled users can just fix GCC itself so that it implements
90524 + nested function calls in a way that does not interfere with PaX.
90525 +
90526 +config PAX_EMUSIGRT
90527 + bool "Automatically emulate sigreturn trampolines"
90528 + depends on PAX_EMUTRAMP && PARISC
90529 + default y
90530 + help
90531 + Enabling this option will have the kernel automatically detect
90532 + and emulate signal return trampolines executing on the stack
90533 + that would otherwise lead to task termination.
90534 +
90535 + This solution is intended as a temporary one for users with
90536 + legacy versions of libc (libc5, glibc 2.0, uClibc before 0.9.17,
90537 + Modula-3 runtime, etc) or executables linked to such, basically
90538 + everything that does not specify its own SA_RESTORER function in
90539 + normal executable memory like glibc 2.1+ does.
90540 +
90541 + On parisc you MUST enable this option, otherwise your system will
90542 + not even boot.
90543 +
90544 + NOTE: this feature cannot be disabled on a per executable basis
90545 + and since it *does* open up a loophole in the protection provided
90546 + by non-executable pages, the best solution is to not have any
90547 + files on your system that would require this option.
90548 +
90549 +config PAX_MPROTECT
90550 + bool "Restrict mprotect()"
90551 + default y if GRKERNSEC_CONFIG_AUTO
90552 + depends on (PAX_PAGEEXEC || PAX_SEGMEXEC)
90553 + help
90554 + Enabling this option will prevent programs from
90555 + - changing the executable status of memory pages that were
90556 + not originally created as executable,
90557 + - making read-only executable pages writable again,
90558 + - creating executable pages from anonymous memory,
90559 + - making read-only-after-relocations (RELRO) data pages writable again.
90560 +
90561 + You should say Y here to complete the protection provided by
90562 + the enforcement of non-executable pages.
90563 +
90564 + NOTE: you can use the 'chpax' or 'paxctl' utilities to control
90565 + this feature on a per file basis.
90566 +
90567 +config PAX_MPROTECT_COMPAT
90568 + bool "Use legacy/compat protection demoting (read help)"
90569 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_DESKTOP)
90570 + depends on PAX_MPROTECT
90571 + help
90572 + The current implementation of PAX_MPROTECT denies RWX allocations/mprotects
90573 + by sending the proper error code to the application. For some broken
90574 + userland, this can cause problems with Python or other applications. The
90575 + current implementation however allows for applications like clamav to
90576 + detect if JIT compilation/execution is allowed and to fall back gracefully
90577 + to an interpreter-based mode if it does not. While we encourage everyone
90578 + to use the current implementation as-is and push upstream to fix broken
90579 + userland (note that the RWX logging option can assist with this), in some
90580 + environments this may not be possible. Having to disable MPROTECT
90581 + completely on certain binaries reduces the security benefit of PaX,
90582 + so this option is provided for those environments to revert to the old
90583 + behavior.
90584 +
90585 +config PAX_ELFRELOCS
90586 + bool "Allow ELF text relocations (read help)"
90587 + depends on PAX_MPROTECT
90588 + default n
90589 + help
90590 + Non-executable pages and mprotect() restrictions are effective
90591 + in preventing the introduction of new executable code into an
90592 + attacked task's address space. There remain only two venues
90593 + for this kind of attack: if the attacker can execute already
90594 + existing code in the attacked task then he can either have it
90595 + create and mmap() a file containing his code or have it mmap()
90596 + an already existing ELF library that does not have position
90597 + independent code in it and use mprotect() on it to make it
90598 + writable and copy his code there. While protecting against
90599 + the former approach is beyond PaX, the latter can be prevented
90600 + by having only PIC ELF libraries on one's system (which do not
90601 + need to relocate their code). If you are sure this is your case,
90602 + as is the case with all modern Linux distributions, then leave
90603 + this option disabled. You should say 'n' here.
90604 +
90605 +config PAX_ETEXECRELOCS
90606 + bool "Allow ELF ET_EXEC text relocations"
90607 + depends on PAX_MPROTECT && (ALPHA || IA64 || PARISC)
90608 + select PAX_ELFRELOCS
90609 + default y
90610 + help
90611 + On some architectures there are incorrectly created applications
90612 + that require text relocations and would not work without enabling
90613 + this option. If you are an alpha, ia64 or parisc user, you should
90614 + enable this option and disable it once you have made sure that
90615 + none of your applications need it.
90616 +
90617 +config PAX_EMUPLT
90618 + bool "Automatically emulate ELF PLT"
90619 + depends on PAX_MPROTECT && (ALPHA || PARISC || SPARC)
90620 + default y
90621 + help
90622 + Enabling this option will have the kernel automatically detect
90623 + and emulate the Procedure Linkage Table entries in ELF files.
90624 + On some architectures such entries are in writable memory, and
90625 + become non-executable leading to task termination. Therefore
90626 + it is mandatory that you enable this option on alpha, parisc,
90627 + sparc and sparc64, otherwise your system would not even boot.
90628 +
90629 + NOTE: this feature *does* open up a loophole in the protection
90630 + provided by the non-executable pages, therefore the proper
90631 + solution is to modify the toolchain to produce a PLT that does
90632 + not need to be writable.
90633 +
90634 +config PAX_DLRESOLVE
90635 + bool 'Emulate old glibc resolver stub'
90636 + depends on PAX_EMUPLT && SPARC
90637 + default n
90638 + help
90639 + This option is needed if userland has an old glibc (before 2.4)
90640 + that puts a 'save' instruction into the runtime generated resolver
90641 + stub that needs special emulation.
90642 +
90643 +config PAX_KERNEXEC
90644 + bool "Enforce non-executable kernel pages"
90645 + 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))
90646 + depends on ((X86 && (!X86_32 || X86_WP_WORKS_OK)) || (ARM && (CPU_V6 || CPU_V7) && !(ARM_LPAE && MODULES))) && !XEN
90647 + select PAX_PER_CPU_PGD if X86_64 || (X86_32 && X86_PAE)
90648 + select PAX_KERNEXEC_PLUGIN if X86_64
90649 + help
90650 + This is the kernel land equivalent of PAGEEXEC and MPROTECT,
90651 + that is, enabling this option will make it harder to inject
90652 + and execute 'foreign' code in kernel memory itself.
90653 +
90654 +choice
90655 + prompt "Return Address Instrumentation Method"
90656 + default PAX_KERNEXEC_PLUGIN_METHOD_BTS
90657 + depends on PAX_KERNEXEC_PLUGIN
90658 + help
90659 + Select the method used to instrument function pointer dereferences.
90660 + Note that binary modules cannot be instrumented by this approach.
90661 +
90662 + Note that the implementation requires a gcc with plugin support,
90663 + i.e., gcc 4.5 or newer. You may need to install the supporting
90664 + headers explicitly in addition to the normal gcc package.
90665 +
90666 + config PAX_KERNEXEC_PLUGIN_METHOD_BTS
90667 + bool "bts"
90668 + help
90669 + This method is compatible with binary only modules but has
90670 + a higher runtime overhead.
90671 +
90672 + config PAX_KERNEXEC_PLUGIN_METHOD_OR
90673 + bool "or"
90674 + depends on !PARAVIRT
90675 + help
90676 + This method is incompatible with binary only modules but has
90677 + a lower runtime overhead.
90678 +endchoice
90679 +
90680 +config PAX_KERNEXEC_PLUGIN_METHOD
90681 + string
90682 + default "bts" if PAX_KERNEXEC_PLUGIN_METHOD_BTS
90683 + default "or" if PAX_KERNEXEC_PLUGIN_METHOD_OR
90684 + default ""
90685 +
90686 +config PAX_KERNEXEC_MODULE_TEXT
90687 + int "Minimum amount of memory reserved for module code"
90688 + default "4" if (!GRKERNSEC_CONFIG_AUTO || GRKERNSEC_CONFIG_SERVER)
90689 + default "12" if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_DESKTOP)
90690 + depends on PAX_KERNEXEC && X86_32 && MODULES
90691 + help
90692 + Due to implementation details the kernel must reserve a fixed
90693 + amount of memory for module code at compile time that cannot be
90694 + changed at runtime. Here you can specify the minimum amount
90695 + in MB that will be reserved. Due to the same implementation
90696 + details this size will always be rounded up to the next 2/4 MB
90697 + boundary (depends on PAE) so the actually available memory for
90698 + module code will usually be more than this minimum.
90699 +
90700 + The default 4 MB should be enough for most users but if you have
90701 + an excessive number of modules (e.g., most distribution configs
90702 + compile many drivers as modules) or use huge modules such as
90703 + nvidia's kernel driver, you will need to adjust this amount.
90704 + A good rule of thumb is to look at your currently loaded kernel
90705 + modules and add up their sizes.
90706 +
90707 +endmenu
90708 +
90709 +menu "Address Space Layout Randomization"
90710 + depends on PAX
90711 +
90712 +config PAX_ASLR
90713 + bool "Address Space Layout Randomization"
90714 + default y if GRKERNSEC_CONFIG_AUTO
90715 + help
90716 + Many if not most exploit techniques rely on the knowledge of
90717 + certain addresses in the attacked program. The following options
90718 + will allow the kernel to apply a certain amount of randomization
90719 + to specific parts of the program thereby forcing an attacker to
90720 + guess them in most cases. Any failed guess will most likely crash
90721 + the attacked program which allows the kernel to detect such attempts
90722 + and react on them. PaX itself provides no reaction mechanisms,
90723 + instead it is strongly encouraged that you make use of Nergal's
90724 + segvguard (ftp://ftp.pl.openwall.com/misc/segvguard/) or grsecurity's
90725 + (http://www.grsecurity.net/) built-in crash detection features or
90726 + develop one yourself.
90727 +
90728 + By saying Y here you can choose to randomize the following areas:
90729 + - top of the task's kernel stack
90730 + - top of the task's userland stack
90731 + - base address for mmap() requests that do not specify one
90732 + (this includes all libraries)
90733 + - base address of the main executable
90734 +
90735 + It is strongly recommended to say Y here as address space layout
90736 + randomization has negligible impact on performance yet it provides
90737 + a very effective protection.
90738 +
90739 + NOTE: you can use the 'chpax' or 'paxctl' utilities to control
90740 + this feature on a per file basis.
90741 +
90742 +config PAX_RANDKSTACK
90743 + bool "Randomize kernel stack base"
90744 + default y if GRKERNSEC_CONFIG_AUTO
90745 + depends on X86_TSC && X86
90746 + help
90747 + By saying Y here the kernel will randomize every task's kernel
90748 + stack on every system call. This will not only force an attacker
90749 + to guess it but also prevent him from making use of possible
90750 + leaked information about it.
90751 +
90752 + Since the kernel stack is a rather scarce resource, randomization
90753 + may cause unexpected stack overflows, therefore you should very
90754 + carefully test your system. Note that once enabled in the kernel
90755 + configuration, this feature cannot be disabled on a per file basis.
90756 +
90757 +config PAX_RANDUSTACK
90758 + bool "Randomize user stack base"
90759 + default y if GRKERNSEC_CONFIG_AUTO
90760 + depends on PAX_ASLR
90761 + help
90762 + By saying Y here the kernel will randomize every task's userland
90763 + stack. The randomization is done in two steps where the second
90764 + one may apply a big amount of shift to the top of the stack and
90765 + cause problems for programs that want to use lots of memory (more
90766 + than 2.5 GB if SEGMEXEC is not active, or 1.25 GB when it is).
90767 + For this reason the second step can be controlled by 'chpax' or
90768 + 'paxctl' on a per file basis.
90769 +
90770 +config PAX_RANDMMAP
90771 + bool "Randomize mmap() base"
90772 + default y if GRKERNSEC_CONFIG_AUTO
90773 + depends on PAX_ASLR
90774 + help
90775 + By saying Y here the kernel will use a randomized base address for
90776 + mmap() requests that do not specify one themselves. As a result
90777 + all dynamically loaded libraries will appear at random addresses
90778 + and therefore be harder to exploit by a technique where an attacker
90779 + attempts to execute library code for his purposes (e.g. spawn a
90780 + shell from an exploited program that is running at an elevated
90781 + privilege level).
90782 +
90783 + Furthermore, if a program is relinked as a dynamic ELF file, its
90784 + base address will be randomized as well, completing the full
90785 + randomization of the address space layout. Attacking such programs
90786 + becomes a guess game. You can find an example of doing this at
90787 + http://pax.grsecurity.net/et_dyn.tar.gz and practical samples at
90788 + http://www.grsecurity.net/grsec-gcc-specs.tar.gz .
90789 +
90790 + NOTE: you can use the 'chpax' or 'paxctl' utilities to control this
90791 + feature on a per file basis.
90792 +
90793 +endmenu
90794 +
90795 +menu "Miscellaneous hardening features"
90796 +
90797 +config PAX_MEMORY_SANITIZE
90798 + bool "Sanitize all freed memory"
90799 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_PRIORITY_SECURITY)
90800 + depends on !HIBERNATION
90801 + help
90802 + By saying Y here the kernel will erase memory pages as soon as they
90803 + are freed. This in turn reduces the lifetime of data stored in the
90804 + pages, making it less likely that sensitive information such as
90805 + passwords, cryptographic secrets, etc stay in memory for too long.
90806 +
90807 + This is especially useful for programs whose runtime is short, long
90808 + lived processes and the kernel itself benefit from this as long as
90809 + they operate on whole memory pages and ensure timely freeing of pages
90810 + that may hold sensitive information.
90811 +
90812 + The tradeoff is performance impact, on a single CPU system kernel
90813 + compilation sees a 3% slowdown, other systems and workloads may vary
90814 + and you are advised to test this feature on your expected workload
90815 + before deploying it.
90816 +
90817 + Note that this feature does not protect data stored in live pages,
90818 + e.g., process memory swapped to disk may stay there for a long time.
90819 +
90820 +config PAX_MEMORY_STACKLEAK
90821 + bool "Sanitize kernel stack"
90822 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_PRIORITY_SECURITY)
90823 + depends on X86
90824 + help
90825 + By saying Y here the kernel will erase the kernel stack before it
90826 + returns from a system call. This in turn reduces the information
90827 + that a kernel stack leak bug can reveal.
90828 +
90829 + Note that such a bug can still leak information that was put on
90830 + the stack by the current system call (the one eventually triggering
90831 + the bug) but traces of earlier system calls on the kernel stack
90832 + cannot leak anymore.
90833 +
90834 + The tradeoff is performance impact: on a single CPU system kernel
90835 + compilation sees a 1% slowdown, other systems and workloads may vary
90836 + and you are advised to test this feature on your expected workload
90837 + before deploying it.
90838 +
90839 + Note that the full feature requires a gcc with plugin support,
90840 + i.e., gcc 4.5 or newer. You may need to install the supporting
90841 + headers explicitly in addition to the normal gcc package. Using
90842 + older gcc versions means that functions with large enough stack
90843 + frames may leave uninitialized memory behind that may be exposed
90844 + to a later syscall leaking the stack.
90845 +
90846 +config PAX_MEMORY_UDEREF
90847 + bool "Prevent invalid userland pointer dereference"
90848 + default y if GRKERNSEC_CONFIG_AUTO && !(X86_64 && GRKERNSEC_CONFIG_PRIORITY_PERF) && (GRKERNSEC_CONFIG_VIRT_NONE || GRKERNSEC_CONFIG_VIRT_EPT)
90849 + depends on (X86 || (ARM && (CPU_V6 || CPU_V7) && !ARM_LPAE)) && !UML_X86 && !XEN
90850 + select PAX_PER_CPU_PGD if X86_64
90851 + help
90852 + By saying Y here the kernel will be prevented from dereferencing
90853 + userland pointers in contexts where the kernel expects only kernel
90854 + pointers. This is both a useful runtime debugging feature and a
90855 + security measure that prevents exploiting a class of kernel bugs.
90856 +
90857 + The tradeoff is that some virtualization solutions may experience
90858 + a huge slowdown and therefore you should not enable this feature
90859 + for kernels meant to run in such environments. Whether a given VM
90860 + solution is affected or not is best determined by simply trying it
90861 + out, the performance impact will be obvious right on boot as this
90862 + mechanism engages from very early on. A good rule of thumb is that
90863 + VMs running on CPUs without hardware virtualization support (i.e.,
90864 + the majority of IA-32 CPUs) will likely experience the slowdown.
90865 +
90866 +config PAX_REFCOUNT
90867 + bool "Prevent various kernel object reference counter overflows"
90868 + default y if GRKERNSEC_CONFIG_AUTO
90869 + depends on GRKERNSEC && ((ARM && (CPU_32v6 || CPU_32v6K || CPU_32v7)) || SPARC64 || X86)
90870 + help
90871 + By saying Y here the kernel will detect and prevent overflowing
90872 + various (but not all) kinds of object reference counters. Such
90873 + overflows can normally occur due to bugs only and are often, if
90874 + not always, exploitable.
90875 +
90876 + The tradeoff is that data structures protected by an overflowed
90877 + refcount will never be freed and therefore will leak memory. Note
90878 + that this leak also happens even without this protection but in
90879 + that case the overflow can eventually trigger the freeing of the
90880 + data structure while it is still being used elsewhere, resulting
90881 + in the exploitable situation that this feature prevents.
90882 +
90883 + Since this has a negligible performance impact, you should enable
90884 + this feature.
90885 +
90886 +config PAX_CONSTIFY_PLUGIN
90887 + bool "Automatically constify eligible structures"
90888 + default y
90889 + depends on !UML
90890 + help
90891 + By saying Y here the compiler will automatically constify a class
90892 + of types that contain only function pointers. This reduces the
90893 + kernel's attack surface and also produces a better memory layout.
90894 +
90895 + Note that the implementation requires a gcc with plugin support,
90896 + i.e., gcc 4.5 or newer. You may need to install the supporting
90897 + headers explicitly in addition to the normal gcc package.
90898 +
90899 + Note that if some code really has to modify constified variables
90900 + then the source code will have to be patched to allow it. Examples
90901 + can be found in PaX itself (the no_const attribute) and for some
90902 + out-of-tree modules at http://www.grsecurity.net/~paxguy1/ .
90903 +
90904 +config PAX_USERCOPY
90905 + bool "Harden heap object copies between kernel and userland"
90906 + default y if GRKERNSEC_CONFIG_AUTO
90907 + depends on ARM || IA64 || PPC || SPARC || X86
90908 + depends on GRKERNSEC && (SLAB || SLUB || SLOB)
90909 + select PAX_USERCOPY_SLABS
90910 + help
90911 + By saying Y here the kernel will enforce the size of heap objects
90912 + when they are copied in either direction between the kernel and
90913 + userland, even if only a part of the heap object is copied.
90914 +
90915 + Specifically, this checking prevents information leaking from the
90916 + kernel heap during kernel to userland copies (if the kernel heap
90917 + object is otherwise fully initialized) and prevents kernel heap
90918 + overflows during userland to kernel copies.
90919 +
90920 + Note that the current implementation provides the strictest bounds
90921 + checks for the SLUB allocator.
90922 +
90923 + Enabling this option also enables per-slab cache protection against
90924 + data in a given cache being copied into/out of via userland
90925 + accessors. Though the whitelist of regions will be reduced over
90926 + time, it notably protects important data structures like task structs.
90927 +
90928 + If frame pointers are enabled on x86, this option will also restrict
90929 + copies into and out of the kernel stack to local variables within a
90930 + single frame.
90931 +
90932 + Since this has a negligible performance impact, you should enable
90933 + this feature.
90934 +
90935 +
90936 +config PAX_USERCOPY_DEBUG
90937 + bool
90938 + depends on X86 && PAX_USERCOPY
90939 + default n
90940 +
90941 +config PAX_SIZE_OVERFLOW
90942 + bool "Prevent various integer overflows in function size parameters"
90943 + default y if GRKERNSEC_CONFIG_AUTO
90944 + depends on X86
90945 + help
90946 + By saying Y here the kernel recomputes expressions of function
90947 + arguments marked by a size_overflow attribute with double integer
90948 + precision (DImode/TImode for 32/64 bit integer types).
90949 +
90950 + The recomputed argument is checked against TYPE_MAX and an event
90951 + is logged on overflow and the triggering process is killed.
90952 +
90953 + Homepage: http://www.grsecurity.net/~ephox/overflow_plugin/
90954 +
90955 + Note that the implementation requires a gcc with plugin support,
90956 + i.e., gcc 4.5 or newer. You may need to install the supporting
90957 + headers explicitly in addition to the normal gcc package.
90958 +
90959 +config PAX_LATENT_ENTROPY
90960 + bool "Generate some entropy during boot"
90961 + default y if GRKERNSEC_CONFIG_AUTO
90962 + help
90963 + By saying Y here the kernel will instrument early boot code to
90964 + extract some entropy from both original and artificially created
90965 + program state. This will help especially embedded systems where
90966 + there is little 'natural' source of entropy normally. The cost
90967 + is some slowdown of the boot process.
90968 +
90969 + When pax_extra_latent_entropy is passed on the kernel command line,
90970 + entropy will be extracted from up to the first 4GB of RAM while the
90971 + runtime memory allocator is being initialized. This costs even more
90972 + slowdown of the boot process.
90973 +
90974 + Note that the implementation requires a gcc with plugin support,
90975 + i.e., gcc 4.5 or newer. You may need to install the supporting
90976 + headers explicitly in addition to the normal gcc package.
90977 +
90978 + Note that entropy extracted this way is not cryptographically
90979 + secure!
90980 +
90981 +endmenu
90982 +
90983 +endmenu
90984 +
90985 +source grsecurity/Kconfig
90986 +
90987 +endmenu
90988 +
90989 +endmenu
90990 +
90991 source security/keys/Kconfig
90992
90993 config SECURITY_DMESG_RESTRICT
90994 @@ -103,7 +1022,7 @@ config INTEL_TXT
90995 config LSM_MMAP_MIN_ADDR
90996 int "Low address space for LSM to protect from user allocation"
90997 depends on SECURITY && SECURITY_SELINUX
90998 - default 32768 if ARM
90999 + default 32768 if ALPHA || ARM || PARISC || SPARC32
91000 default 65536
91001 help
91002 This is the portion of low virtual memory which should be protected
91003 diff --git a/security/apparmor/lsm.c b/security/apparmor/lsm.c
91004 index 8c2a7f6..b133ac9 100644
91005 --- a/security/apparmor/lsm.c
91006 +++ b/security/apparmor/lsm.c
91007 @@ -614,7 +614,7 @@ static int apparmor_task_setrlimit(struct task_struct *task,
91008 return error;
91009 }
91010
91011 -static struct security_operations apparmor_ops = {
91012 +static struct security_operations apparmor_ops __read_only = {
91013 .name = "apparmor",
91014
91015 .ptrace_access_check = apparmor_ptrace_access_check,
91016 diff --git a/security/commoncap.c b/security/commoncap.c
91017 index 7ee08c7..8d1a9d6 100644
91018 --- a/security/commoncap.c
91019 +++ b/security/commoncap.c
91020 @@ -424,6 +424,32 @@ int get_vfs_caps_from_disk(const struct dentry *dentry, struct cpu_vfs_cap_data
91021 return 0;
91022 }
91023
91024 +/* returns:
91025 + 1 for suid privilege
91026 + 2 for sgid privilege
91027 + 3 for fscap privilege
91028 +*/
91029 +int is_privileged_binary(const struct dentry *dentry)
91030 +{
91031 + struct cpu_vfs_cap_data capdata;
91032 + struct inode *inode = dentry->d_inode;
91033 +
91034 + if (!inode || S_ISDIR(inode->i_mode))
91035 + return 0;
91036 +
91037 + if (inode->i_mode & S_ISUID)
91038 + return 1;
91039 + if ((inode->i_mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))
91040 + return 2;
91041 +
91042 + if (!get_vfs_caps_from_disk(dentry, &capdata)) {
91043 + if (!cap_isclear(capdata.inheritable) || !cap_isclear(capdata.permitted))
91044 + return 3;
91045 + }
91046 +
91047 + return 0;
91048 +}
91049 +
91050 /*
91051 * Attempt to get the on-exec apply capability sets for an executable file from
91052 * its xattrs and, if present, apply them to the proposed credentials being
91053 @@ -592,6 +618,9 @@ int cap_bprm_secureexec(struct linux_binprm *bprm)
91054 const struct cred *cred = current_cred();
91055 kuid_t root_uid = make_kuid(cred->user_ns, 0);
91056
91057 + if (gr_acl_enable_at_secure())
91058 + return 1;
91059 +
91060 if (!uid_eq(cred->uid, root_uid)) {
91061 if (bprm->cap_effective)
91062 return 1;
91063 diff --git a/security/integrity/ima/ima.h b/security/integrity/ima/ima.h
91064 index 079a85d..12e93f8 100644
91065 --- a/security/integrity/ima/ima.h
91066 +++ b/security/integrity/ima/ima.h
91067 @@ -96,8 +96,8 @@ void ima_add_violation(struct inode *inode, const unsigned char *filename,
91068 extern spinlock_t ima_queue_lock;
91069
91070 struct ima_h_table {
91071 - atomic_long_t len; /* number of stored measurements in the list */
91072 - atomic_long_t violations;
91073 + atomic_long_unchecked_t len; /* number of stored measurements in the list */
91074 + atomic_long_unchecked_t violations;
91075 struct hlist_head queue[IMA_MEASURE_HTABLE_SIZE];
91076 };
91077 extern struct ima_h_table ima_htable;
91078 diff --git a/security/integrity/ima/ima_api.c b/security/integrity/ima/ima_api.c
91079 index 0cea3db..2f0ef77 100644
91080 --- a/security/integrity/ima/ima_api.c
91081 +++ b/security/integrity/ima/ima_api.c
91082 @@ -79,7 +79,7 @@ void ima_add_violation(struct inode *inode, const unsigned char *filename,
91083 int result;
91084
91085 /* can overflow, only indicator */
91086 - atomic_long_inc(&ima_htable.violations);
91087 + atomic_long_inc_unchecked(&ima_htable.violations);
91088
91089 entry = kmalloc(sizeof(*entry), GFP_KERNEL);
91090 if (!entry) {
91091 diff --git a/security/integrity/ima/ima_fs.c b/security/integrity/ima/ima_fs.c
91092 index 38477c9..87a60c7 100644
91093 --- a/security/integrity/ima/ima_fs.c
91094 +++ b/security/integrity/ima/ima_fs.c
91095 @@ -28,12 +28,12 @@
91096 static int valid_policy = 1;
91097 #define TMPBUFLEN 12
91098 static ssize_t ima_show_htable_value(char __user *buf, size_t count,
91099 - loff_t *ppos, atomic_long_t *val)
91100 + loff_t *ppos, atomic_long_unchecked_t *val)
91101 {
91102 char tmpbuf[TMPBUFLEN];
91103 ssize_t len;
91104
91105 - len = scnprintf(tmpbuf, TMPBUFLEN, "%li\n", atomic_long_read(val));
91106 + len = scnprintf(tmpbuf, TMPBUFLEN, "%li\n", atomic_long_read_unchecked(val));
91107 return simple_read_from_buffer(buf, count, ppos, tmpbuf, len);
91108 }
91109
91110 diff --git a/security/integrity/ima/ima_queue.c b/security/integrity/ima/ima_queue.c
91111 index 55a6271..ad829c3 100644
91112 --- a/security/integrity/ima/ima_queue.c
91113 +++ b/security/integrity/ima/ima_queue.c
91114 @@ -81,7 +81,7 @@ static int ima_add_digest_entry(struct ima_template_entry *entry)
91115 INIT_LIST_HEAD(&qe->later);
91116 list_add_tail_rcu(&qe->later, &ima_measurements);
91117
91118 - atomic_long_inc(&ima_htable.len);
91119 + atomic_long_inc_unchecked(&ima_htable.len);
91120 key = ima_hash_key(entry->digest);
91121 hlist_add_head_rcu(&qe->hnext, &ima_htable.queue[key]);
91122 return 0;
91123 diff --git a/security/keys/compat.c b/security/keys/compat.c
91124 index d65fa7f..cbfe366 100644
91125 --- a/security/keys/compat.c
91126 +++ b/security/keys/compat.c
91127 @@ -44,7 +44,7 @@ static long compat_keyctl_instantiate_key_iov(
91128 if (ret == 0)
91129 goto no_payload_free;
91130
91131 - ret = keyctl_instantiate_key_common(id, iov, ioc, ret, ringid);
91132 + ret = keyctl_instantiate_key_common(id, (const struct iovec __force_user *)iov, ioc, ret, ringid);
91133 err:
91134 if (iov != iovstack)
91135 kfree(iov);
91136 diff --git a/security/keys/key.c b/security/keys/key.c
91137 index 8fb7c7b..ba3610d 100644
91138 --- a/security/keys/key.c
91139 +++ b/security/keys/key.c
91140 @@ -284,7 +284,7 @@ struct key *key_alloc(struct key_type *type, const char *desc,
91141
91142 atomic_set(&key->usage, 1);
91143 init_rwsem(&key->sem);
91144 - lockdep_set_class(&key->sem, &type->lock_class);
91145 + lockdep_set_class(&key->sem, (struct lock_class_key *)&type->lock_class);
91146 key->type = type;
91147 key->user = user;
91148 key->quotalen = quotalen;
91149 @@ -1032,7 +1032,9 @@ int register_key_type(struct key_type *ktype)
91150 struct key_type *p;
91151 int ret;
91152
91153 - memset(&ktype->lock_class, 0, sizeof(ktype->lock_class));
91154 + pax_open_kernel();
91155 + memset((void *)&ktype->lock_class, 0, sizeof(ktype->lock_class));
91156 + pax_close_kernel();
91157
91158 ret = -EEXIST;
91159 down_write(&key_types_sem);
91160 @@ -1044,7 +1046,7 @@ int register_key_type(struct key_type *ktype)
91161 }
91162
91163 /* store the type */
91164 - list_add(&ktype->link, &key_types_list);
91165 + pax_list_add((struct list_head *)&ktype->link, &key_types_list);
91166
91167 pr_notice("Key type %s registered\n", ktype->name);
91168 ret = 0;
91169 @@ -1066,7 +1068,7 @@ EXPORT_SYMBOL(register_key_type);
91170 void unregister_key_type(struct key_type *ktype)
91171 {
91172 down_write(&key_types_sem);
91173 - list_del_init(&ktype->link);
91174 + pax_list_del_init((struct list_head *)&ktype->link);
91175 downgrade_write(&key_types_sem);
91176 key_gc_keytype(ktype);
91177 pr_notice("Key type %s unregistered\n", ktype->name);
91178 @@ -1084,10 +1086,10 @@ void __init key_init(void)
91179 0, SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
91180
91181 /* add the special key types */
91182 - list_add_tail(&key_type_keyring.link, &key_types_list);
91183 - list_add_tail(&key_type_dead.link, &key_types_list);
91184 - list_add_tail(&key_type_user.link, &key_types_list);
91185 - list_add_tail(&key_type_logon.link, &key_types_list);
91186 + pax_list_add_tail((struct list_head *)&key_type_keyring.link, &key_types_list);
91187 + pax_list_add_tail((struct list_head *)&key_type_dead.link, &key_types_list);
91188 + pax_list_add_tail((struct list_head *)&key_type_user.link, &key_types_list);
91189 + pax_list_add_tail((struct list_head *)&key_type_logon.link, &key_types_list);
91190
91191 /* record the root user tracking */
91192 rb_link_node(&root_key_user.node,
91193 diff --git a/security/keys/keyctl.c b/security/keys/keyctl.c
91194 index 4b5c948..2054dc1 100644
91195 --- a/security/keys/keyctl.c
91196 +++ b/security/keys/keyctl.c
91197 @@ -986,7 +986,7 @@ static int keyctl_change_reqkey_auth(struct key *key)
91198 /*
91199 * Copy the iovec data from userspace
91200 */
91201 -static long copy_from_user_iovec(void *buffer, const struct iovec *iov,
91202 +static long copy_from_user_iovec(void *buffer, const struct iovec __user *iov,
91203 unsigned ioc)
91204 {
91205 for (; ioc > 0; ioc--) {
91206 @@ -1008,7 +1008,7 @@ static long copy_from_user_iovec(void *buffer, const struct iovec *iov,
91207 * If successful, 0 will be returned.
91208 */
91209 long keyctl_instantiate_key_common(key_serial_t id,
91210 - const struct iovec *payload_iov,
91211 + const struct iovec __user *payload_iov,
91212 unsigned ioc,
91213 size_t plen,
91214 key_serial_t ringid)
91215 @@ -1103,7 +1103,7 @@ long keyctl_instantiate_key(key_serial_t id,
91216 [0].iov_len = plen
91217 };
91218
91219 - return keyctl_instantiate_key_common(id, iov, 1, plen, ringid);
91220 + return keyctl_instantiate_key_common(id, (const struct iovec __force_user *)iov, 1, plen, ringid);
91221 }
91222
91223 return keyctl_instantiate_key_common(id, NULL, 0, 0, ringid);
91224 @@ -1136,7 +1136,7 @@ long keyctl_instantiate_key_iov(key_serial_t id,
91225 if (ret == 0)
91226 goto no_payload_free;
91227
91228 - ret = keyctl_instantiate_key_common(id, iov, ioc, ret, ringid);
91229 + ret = keyctl_instantiate_key_common(id, (const struct iovec __force_user *)iov, ioc, ret, ringid);
91230 err:
91231 if (iov != iovstack)
91232 kfree(iov);
91233 diff --git a/security/keys/keyring.c b/security/keys/keyring.c
91234 index 6ece7f2..ecdb55c 100644
91235 --- a/security/keys/keyring.c
91236 +++ b/security/keys/keyring.c
91237 @@ -227,16 +227,16 @@ static long keyring_read(const struct key *keyring,
91238 ret = -EFAULT;
91239
91240 for (loop = 0; loop < klist->nkeys; loop++) {
91241 + key_serial_t serial;
91242 key = rcu_deref_link_locked(klist, loop,
91243 keyring);
91244 + serial = key->serial;
91245
91246 tmp = sizeof(key_serial_t);
91247 if (tmp > buflen)
91248 tmp = buflen;
91249
91250 - if (copy_to_user(buffer,
91251 - &key->serial,
91252 - tmp) != 0)
91253 + if (copy_to_user(buffer, &serial, tmp))
91254 goto error;
91255
91256 buflen -= tmp;
91257 diff --git a/security/min_addr.c b/security/min_addr.c
91258 index f728728..6457a0c 100644
91259 --- a/security/min_addr.c
91260 +++ b/security/min_addr.c
91261 @@ -14,6 +14,7 @@ unsigned long dac_mmap_min_addr = CONFIG_DEFAULT_MMAP_MIN_ADDR;
91262 */
91263 static void update_mmap_min_addr(void)
91264 {
91265 +#ifndef SPARC
91266 #ifdef CONFIG_LSM_MMAP_MIN_ADDR
91267 if (dac_mmap_min_addr > CONFIG_LSM_MMAP_MIN_ADDR)
91268 mmap_min_addr = dac_mmap_min_addr;
91269 @@ -22,6 +23,7 @@ static void update_mmap_min_addr(void)
91270 #else
91271 mmap_min_addr = dac_mmap_min_addr;
91272 #endif
91273 +#endif
91274 }
91275
91276 /*
91277 diff --git a/security/security.c b/security/security.c
91278 index 7b88c6a..1e3ea8f 100644
91279 --- a/security/security.c
91280 +++ b/security/security.c
91281 @@ -20,6 +20,7 @@
91282 #include <linux/ima.h>
91283 #include <linux/evm.h>
91284 #include <linux/fsnotify.h>
91285 +#include <linux/mm.h>
91286 #include <linux/mman.h>
91287 #include <linux/mount.h>
91288 #include <linux/personality.h>
91289 @@ -32,8 +33,8 @@
91290 static __initdata char chosen_lsm[SECURITY_NAME_MAX + 1] =
91291 CONFIG_DEFAULT_SECURITY;
91292
91293 -static struct security_operations *security_ops;
91294 -static struct security_operations default_security_ops = {
91295 +static struct security_operations *security_ops __read_only;
91296 +static struct security_operations default_security_ops __read_only = {
91297 .name = "default",
91298 };
91299
91300 @@ -74,7 +75,9 @@ int __init security_init(void)
91301
91302 void reset_security_ops(void)
91303 {
91304 + pax_open_kernel();
91305 security_ops = &default_security_ops;
91306 + pax_close_kernel();
91307 }
91308
91309 /* Save user chosen LSM */
91310 diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
91311 index ef26e96..642fb78 100644
91312 --- a/security/selinux/hooks.c
91313 +++ b/security/selinux/hooks.c
91314 @@ -95,8 +95,6 @@
91315
91316 #define NUM_SEL_MNT_OPTS 5
91317
91318 -extern struct security_operations *security_ops;
91319 -
91320 /* SECMARK reference count */
91321 static atomic_t selinux_secmark_refcount = ATOMIC_INIT(0);
91322
91323 @@ -5501,7 +5499,7 @@ static int selinux_key_getsecurity(struct key *key, char **_buffer)
91324
91325 #endif
91326
91327 -static struct security_operations selinux_ops = {
91328 +static struct security_operations selinux_ops __read_only = {
91329 .name = "selinux",
91330
91331 .ptrace_access_check = selinux_ptrace_access_check,
91332 diff --git a/security/selinux/include/xfrm.h b/security/selinux/include/xfrm.h
91333 index 65f67cb..3f141ef 100644
91334 --- a/security/selinux/include/xfrm.h
91335 +++ b/security/selinux/include/xfrm.h
91336 @@ -50,7 +50,7 @@ int selinux_xfrm_decode_session(struct sk_buff *skb, u32 *sid, int ckall);
91337
91338 static inline void selinux_xfrm_notify_policyload(void)
91339 {
91340 - atomic_inc(&flow_cache_genid);
91341 + atomic_inc_unchecked(&flow_cache_genid);
91342 rt_genid_bump(&init_net);
91343 }
91344 #else
91345 diff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c
91346 index 38be92c..21f49ee 100644
91347 --- a/security/smack/smack_lsm.c
91348 +++ b/security/smack/smack_lsm.c
91349 @@ -3398,7 +3398,7 @@ static int smack_inode_getsecctx(struct inode *inode, void **ctx, u32 *ctxlen)
91350 return 0;
91351 }
91352
91353 -struct security_operations smack_ops = {
91354 +struct security_operations smack_ops __read_only = {
91355 .name = "smack",
91356
91357 .ptrace_access_check = smack_ptrace_access_check,
91358 diff --git a/security/tomoyo/mount.c b/security/tomoyo/mount.c
91359 index 390c646..f2f8db3 100644
91360 --- a/security/tomoyo/mount.c
91361 +++ b/security/tomoyo/mount.c
91362 @@ -118,6 +118,10 @@ static int tomoyo_mount_acl(struct tomoyo_request_info *r,
91363 type == tomoyo_mounts[TOMOYO_MOUNT_MOVE]) {
91364 need_dev = -1; /* dev_name is a directory */
91365 } else {
91366 + if (!capable(CAP_SYS_ADMIN)) {
91367 + error = -EPERM;
91368 + goto out;
91369 + }
91370 fstype = get_fs_type(type);
91371 if (!fstype) {
91372 error = -ENODEV;
91373 diff --git a/security/tomoyo/tomoyo.c b/security/tomoyo/tomoyo.c
91374 index a2ee362..5754f34 100644
91375 --- a/security/tomoyo/tomoyo.c
91376 +++ b/security/tomoyo/tomoyo.c
91377 @@ -503,7 +503,7 @@ static int tomoyo_socket_sendmsg(struct socket *sock, struct msghdr *msg,
91378 * tomoyo_security_ops is a "struct security_operations" which is used for
91379 * registering TOMOYO.
91380 */
91381 -static struct security_operations tomoyo_security_ops = {
91382 +static struct security_operations tomoyo_security_ops __read_only = {
91383 .name = "tomoyo",
91384 .cred_alloc_blank = tomoyo_cred_alloc_blank,
91385 .cred_prepare = tomoyo_cred_prepare,
91386 diff --git a/security/yama/Kconfig b/security/yama/Kconfig
91387 index 20ef514..4182bed 100644
91388 --- a/security/yama/Kconfig
91389 +++ b/security/yama/Kconfig
91390 @@ -1,6 +1,6 @@
91391 config SECURITY_YAMA
91392 bool "Yama support"
91393 - depends on SECURITY
91394 + depends on SECURITY && !GRKERNSEC
91395 select SECURITYFS
91396 select SECURITY_PATH
91397 default n
91398 diff --git a/security/yama/yama_lsm.c b/security/yama/yama_lsm.c
91399 index 23414b9..b92b314 100644
91400 --- a/security/yama/yama_lsm.c
91401 +++ b/security/yama/yama_lsm.c
91402 @@ -367,7 +367,7 @@ int yama_ptrace_traceme(struct task_struct *parent)
91403 }
91404
91405 #ifndef CONFIG_SECURITY_YAMA_STACKED
91406 -static struct security_operations yama_ops = {
91407 +static struct security_operations yama_ops __read_only = {
91408 .name = "yama",
91409
91410 .ptrace_access_check = yama_ptrace_access_check,
91411 @@ -378,28 +378,24 @@ static struct security_operations yama_ops = {
91412 #endif
91413
91414 #ifdef CONFIG_SYSCTL
91415 +static int zero __read_only;
91416 +static int max_scope __read_only = YAMA_SCOPE_NO_ATTACH;
91417 +
91418 static int yama_dointvec_minmax(struct ctl_table *table, int write,
91419 void __user *buffer, size_t *lenp, loff_t *ppos)
91420 {
91421 - int rc;
91422 + ctl_table_no_const yama_table;
91423
91424 if (write && !capable(CAP_SYS_PTRACE))
91425 return -EPERM;
91426
91427 - rc = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
91428 - if (rc)
91429 - return rc;
91430 -
91431 + yama_table = *table;
91432 /* Lock the max value if it ever gets set. */
91433 - if (write && *(int *)table->data == *(int *)table->extra2)
91434 - table->extra1 = table->extra2;
91435 -
91436 - return rc;
91437 + if (ptrace_scope == max_scope)
91438 + yama_table.extra1 = &max_scope;
91439 + return proc_dointvec_minmax(&yama_table, write, buffer, lenp, ppos);
91440 }
91441
91442 -static int zero;
91443 -static int max_scope = YAMA_SCOPE_NO_ATTACH;
91444 -
91445 struct ctl_path yama_sysctl_path[] = {
91446 { .procname = "kernel", },
91447 { .procname = "yama", },
91448 diff --git a/sound/aoa/codecs/onyx.c b/sound/aoa/codecs/onyx.c
91449 index 4cedc69..e59d8a3 100644
91450 --- a/sound/aoa/codecs/onyx.c
91451 +++ b/sound/aoa/codecs/onyx.c
91452 @@ -54,7 +54,7 @@ struct onyx {
91453 spdif_locked:1,
91454 analog_locked:1,
91455 original_mute:2;
91456 - int open_count;
91457 + local_t open_count;
91458 struct codec_info *codec_info;
91459
91460 /* mutex serializes concurrent access to the device
91461 @@ -753,7 +753,7 @@ static int onyx_open(struct codec_info_item *cii,
91462 struct onyx *onyx = cii->codec_data;
91463
91464 mutex_lock(&onyx->mutex);
91465 - onyx->open_count++;
91466 + local_inc(&onyx->open_count);
91467 mutex_unlock(&onyx->mutex);
91468
91469 return 0;
91470 @@ -765,8 +765,7 @@ static int onyx_close(struct codec_info_item *cii,
91471 struct onyx *onyx = cii->codec_data;
91472
91473 mutex_lock(&onyx->mutex);
91474 - onyx->open_count--;
91475 - if (!onyx->open_count)
91476 + if (local_dec_and_test(&onyx->open_count))
91477 onyx->spdif_locked = onyx->analog_locked = 0;
91478 mutex_unlock(&onyx->mutex);
91479
91480 diff --git a/sound/aoa/codecs/onyx.h b/sound/aoa/codecs/onyx.h
91481 index ffd2025..df062c9 100644
91482 --- a/sound/aoa/codecs/onyx.h
91483 +++ b/sound/aoa/codecs/onyx.h
91484 @@ -11,6 +11,7 @@
91485 #include <linux/i2c.h>
91486 #include <asm/pmac_low_i2c.h>
91487 #include <asm/prom.h>
91488 +#include <asm/local.h>
91489
91490 /* PCM3052 register definitions */
91491
91492 diff --git a/sound/core/oss/pcm_oss.c b/sound/core/oss/pcm_oss.c
91493 index 4c1cc51..16040040 100644
91494 --- a/sound/core/oss/pcm_oss.c
91495 +++ b/sound/core/oss/pcm_oss.c
91496 @@ -1189,10 +1189,10 @@ snd_pcm_sframes_t snd_pcm_oss_write3(struct snd_pcm_substream *substream, const
91497 if (in_kernel) {
91498 mm_segment_t fs;
91499 fs = snd_enter_user();
91500 - ret = snd_pcm_lib_write(substream, (void __force __user *)ptr, frames);
91501 + ret = snd_pcm_lib_write(substream, (void __force_user *)ptr, frames);
91502 snd_leave_user(fs);
91503 } else {
91504 - ret = snd_pcm_lib_write(substream, (void __force __user *)ptr, frames);
91505 + ret = snd_pcm_lib_write(substream, (void __force_user *)ptr, frames);
91506 }
91507 if (ret != -EPIPE && ret != -ESTRPIPE)
91508 break;
91509 @@ -1234,10 +1234,10 @@ snd_pcm_sframes_t snd_pcm_oss_read3(struct snd_pcm_substream *substream, char *p
91510 if (in_kernel) {
91511 mm_segment_t fs;
91512 fs = snd_enter_user();
91513 - ret = snd_pcm_lib_read(substream, (void __force __user *)ptr, frames);
91514 + ret = snd_pcm_lib_read(substream, (void __force_user *)ptr, frames);
91515 snd_leave_user(fs);
91516 } else {
91517 - ret = snd_pcm_lib_read(substream, (void __force __user *)ptr, frames);
91518 + ret = snd_pcm_lib_read(substream, (void __force_user *)ptr, frames);
91519 }
91520 if (ret == -EPIPE) {
91521 if (runtime->status->state == SNDRV_PCM_STATE_DRAINING) {
91522 @@ -1337,7 +1337,7 @@ static ssize_t snd_pcm_oss_write2(struct snd_pcm_substream *substream, const cha
91523 struct snd_pcm_plugin_channel *channels;
91524 size_t oss_frame_bytes = (runtime->oss.plugin_first->src_width * runtime->oss.plugin_first->src_format.channels) / 8;
91525 if (!in_kernel) {
91526 - if (copy_from_user(runtime->oss.buffer, (const char __force __user *)buf, bytes))
91527 + if (copy_from_user(runtime->oss.buffer, (const char __force_user *)buf, bytes))
91528 return -EFAULT;
91529 buf = runtime->oss.buffer;
91530 }
91531 @@ -1407,7 +1407,7 @@ static ssize_t snd_pcm_oss_write1(struct snd_pcm_substream *substream, const cha
91532 }
91533 } else {
91534 tmp = snd_pcm_oss_write2(substream,
91535 - (const char __force *)buf,
91536 + (const char __force_kernel *)buf,
91537 runtime->oss.period_bytes, 0);
91538 if (tmp <= 0)
91539 goto err;
91540 @@ -1433,7 +1433,7 @@ static ssize_t snd_pcm_oss_read2(struct snd_pcm_substream *substream, char *buf,
91541 struct snd_pcm_runtime *runtime = substream->runtime;
91542 snd_pcm_sframes_t frames, frames1;
91543 #ifdef CONFIG_SND_PCM_OSS_PLUGINS
91544 - char __user *final_dst = (char __force __user *)buf;
91545 + char __user *final_dst = (char __force_user *)buf;
91546 if (runtime->oss.plugin_first) {
91547 struct snd_pcm_plugin_channel *channels;
91548 size_t oss_frame_bytes = (runtime->oss.plugin_last->dst_width * runtime->oss.plugin_last->dst_format.channels) / 8;
91549 @@ -1495,7 +1495,7 @@ static ssize_t snd_pcm_oss_read1(struct snd_pcm_substream *substream, char __use
91550 xfer += tmp;
91551 runtime->oss.buffer_used -= tmp;
91552 } else {
91553 - tmp = snd_pcm_oss_read2(substream, (char __force *)buf,
91554 + tmp = snd_pcm_oss_read2(substream, (char __force_kernel *)buf,
91555 runtime->oss.period_bytes, 0);
91556 if (tmp <= 0)
91557 goto err;
91558 @@ -1663,7 +1663,7 @@ static int snd_pcm_oss_sync(struct snd_pcm_oss_file *pcm_oss_file)
91559 size1);
91560 size1 /= runtime->channels; /* frames */
91561 fs = snd_enter_user();
91562 - snd_pcm_lib_write(substream, (void __force __user *)runtime->oss.buffer, size1);
91563 + snd_pcm_lib_write(substream, (void __force_user *)runtime->oss.buffer, size1);
91564 snd_leave_user(fs);
91565 }
91566 } else if (runtime->access == SNDRV_PCM_ACCESS_RW_NONINTERLEAVED) {
91567 diff --git a/sound/core/pcm_compat.c b/sound/core/pcm_compat.c
91568 index af49721..e85058e 100644
91569 --- a/sound/core/pcm_compat.c
91570 +++ b/sound/core/pcm_compat.c
91571 @@ -31,7 +31,7 @@ static int snd_pcm_ioctl_delay_compat(struct snd_pcm_substream *substream,
91572 int err;
91573
91574 fs = snd_enter_user();
91575 - err = snd_pcm_delay(substream, &delay);
91576 + err = snd_pcm_delay(substream, (snd_pcm_sframes_t __force_user *)&delay);
91577 snd_leave_user(fs);
91578 if (err < 0)
91579 return err;
91580 diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c
91581 index 09b4286..8620fac 100644
91582 --- a/sound/core/pcm_native.c
91583 +++ b/sound/core/pcm_native.c
91584 @@ -2806,11 +2806,11 @@ int snd_pcm_kernel_ioctl(struct snd_pcm_substream *substream,
91585 switch (substream->stream) {
91586 case SNDRV_PCM_STREAM_PLAYBACK:
91587 result = snd_pcm_playback_ioctl1(NULL, substream, cmd,
91588 - (void __user *)arg);
91589 + (void __force_user *)arg);
91590 break;
91591 case SNDRV_PCM_STREAM_CAPTURE:
91592 result = snd_pcm_capture_ioctl1(NULL, substream, cmd,
91593 - (void __user *)arg);
91594 + (void __force_user *)arg);
91595 break;
91596 default:
91597 result = -EINVAL;
91598 diff --git a/sound/core/seq/seq_device.c b/sound/core/seq/seq_device.c
91599 index 040c60e..989a19a 100644
91600 --- a/sound/core/seq/seq_device.c
91601 +++ b/sound/core/seq/seq_device.c
91602 @@ -64,7 +64,7 @@ struct ops_list {
91603 int argsize; /* argument size */
91604
91605 /* operators */
91606 - struct snd_seq_dev_ops ops;
91607 + struct snd_seq_dev_ops *ops;
91608
91609 /* registered devices */
91610 struct list_head dev_list; /* list of devices */
91611 @@ -333,7 +333,7 @@ int snd_seq_device_register_driver(char *id, struct snd_seq_dev_ops *entry,
91612
91613 mutex_lock(&ops->reg_mutex);
91614 /* copy driver operators */
91615 - ops->ops = *entry;
91616 + ops->ops = entry;
91617 ops->driver |= DRIVER_LOADED;
91618 ops->argsize = argsize;
91619
91620 @@ -463,7 +463,7 @@ static int init_device(struct snd_seq_device *dev, struct ops_list *ops)
91621 dev->name, ops->id, ops->argsize, dev->argsize);
91622 return -EINVAL;
91623 }
91624 - if (ops->ops.init_device(dev) >= 0) {
91625 + if (ops->ops->init_device(dev) >= 0) {
91626 dev->status = SNDRV_SEQ_DEVICE_REGISTERED;
91627 ops->num_init_devices++;
91628 } else {
91629 @@ -490,7 +490,7 @@ static int free_device(struct snd_seq_device *dev, struct ops_list *ops)
91630 dev->name, ops->id, ops->argsize, dev->argsize);
91631 return -EINVAL;
91632 }
91633 - if ((result = ops->ops.free_device(dev)) >= 0 || result == -ENXIO) {
91634 + if ((result = ops->ops->free_device(dev)) >= 0 || result == -ENXIO) {
91635 dev->status = SNDRV_SEQ_DEVICE_FREE;
91636 dev->driver_data = NULL;
91637 ops->num_init_devices--;
91638 diff --git a/sound/drivers/mts64.c b/sound/drivers/mts64.c
91639 index 4e0dd22..7a1f32c 100644
91640 --- a/sound/drivers/mts64.c
91641 +++ b/sound/drivers/mts64.c
91642 @@ -29,6 +29,7 @@
91643 #include <sound/initval.h>
91644 #include <sound/rawmidi.h>
91645 #include <sound/control.h>
91646 +#include <asm/local.h>
91647
91648 #define CARD_NAME "Miditerminal 4140"
91649 #define DRIVER_NAME "MTS64"
91650 @@ -67,7 +68,7 @@ struct mts64 {
91651 struct pardevice *pardev;
91652 int pardev_claimed;
91653
91654 - int open_count;
91655 + local_t open_count;
91656 int current_midi_output_port;
91657 int current_midi_input_port;
91658 u8 mode[MTS64_NUM_INPUT_PORTS];
91659 @@ -697,7 +698,7 @@ static int snd_mts64_rawmidi_open(struct snd_rawmidi_substream *substream)
91660 {
91661 struct mts64 *mts = substream->rmidi->private_data;
91662
91663 - if (mts->open_count == 0) {
91664 + if (local_read(&mts->open_count) == 0) {
91665 /* We don't need a spinlock here, because this is just called
91666 if the device has not been opened before.
91667 So there aren't any IRQs from the device */
91668 @@ -705,7 +706,7 @@ static int snd_mts64_rawmidi_open(struct snd_rawmidi_substream *substream)
91669
91670 msleep(50);
91671 }
91672 - ++(mts->open_count);
91673 + local_inc(&mts->open_count);
91674
91675 return 0;
91676 }
91677 @@ -715,8 +716,7 @@ static int snd_mts64_rawmidi_close(struct snd_rawmidi_substream *substream)
91678 struct mts64 *mts = substream->rmidi->private_data;
91679 unsigned long flags;
91680
91681 - --(mts->open_count);
91682 - if (mts->open_count == 0) {
91683 + if (local_dec_return(&mts->open_count) == 0) {
91684 /* We need the spinlock_irqsave here because we can still
91685 have IRQs at this point */
91686 spin_lock_irqsave(&mts->lock, flags);
91687 @@ -725,8 +725,8 @@ static int snd_mts64_rawmidi_close(struct snd_rawmidi_substream *substream)
91688
91689 msleep(500);
91690
91691 - } else if (mts->open_count < 0)
91692 - mts->open_count = 0;
91693 + } else if (local_read(&mts->open_count) < 0)
91694 + local_set(&mts->open_count, 0);
91695
91696 return 0;
91697 }
91698 diff --git a/sound/drivers/opl4/opl4_lib.c b/sound/drivers/opl4/opl4_lib.c
91699 index b953fb4..1999c01 100644
91700 --- a/sound/drivers/opl4/opl4_lib.c
91701 +++ b/sound/drivers/opl4/opl4_lib.c
91702 @@ -29,7 +29,7 @@ MODULE_AUTHOR("Clemens Ladisch <clemens@ladisch.de>");
91703 MODULE_DESCRIPTION("OPL4 driver");
91704 MODULE_LICENSE("GPL");
91705
91706 -static void inline snd_opl4_wait(struct snd_opl4 *opl4)
91707 +static inline void snd_opl4_wait(struct snd_opl4 *opl4)
91708 {
91709 int timeout = 10;
91710 while ((inb(opl4->fm_port) & OPL4_STATUS_BUSY) && --timeout > 0)
91711 diff --git a/sound/drivers/portman2x4.c b/sound/drivers/portman2x4.c
91712 index 991018d..8984740 100644
91713 --- a/sound/drivers/portman2x4.c
91714 +++ b/sound/drivers/portman2x4.c
91715 @@ -48,6 +48,7 @@
91716 #include <sound/initval.h>
91717 #include <sound/rawmidi.h>
91718 #include <sound/control.h>
91719 +#include <asm/local.h>
91720
91721 #define CARD_NAME "Portman 2x4"
91722 #define DRIVER_NAME "portman"
91723 @@ -85,7 +86,7 @@ struct portman {
91724 struct pardevice *pardev;
91725 int pardev_claimed;
91726
91727 - int open_count;
91728 + local_t open_count;
91729 int mode[PORTMAN_NUM_INPUT_PORTS];
91730 struct snd_rawmidi_substream *midi_input[PORTMAN_NUM_INPUT_PORTS];
91731 };
91732 diff --git a/sound/firewire/amdtp.c b/sound/firewire/amdtp.c
91733 index ea995af..f1bfa37 100644
91734 --- a/sound/firewire/amdtp.c
91735 +++ b/sound/firewire/amdtp.c
91736 @@ -389,7 +389,7 @@ static void queue_out_packet(struct amdtp_out_stream *s, unsigned int cycle)
91737 ptr = s->pcm_buffer_pointer + data_blocks;
91738 if (ptr >= pcm->runtime->buffer_size)
91739 ptr -= pcm->runtime->buffer_size;
91740 - ACCESS_ONCE(s->pcm_buffer_pointer) = ptr;
91741 + ACCESS_ONCE_RW(s->pcm_buffer_pointer) = ptr;
91742
91743 s->pcm_period_pointer += data_blocks;
91744 if (s->pcm_period_pointer >= pcm->runtime->period_size) {
91745 @@ -557,7 +557,7 @@ EXPORT_SYMBOL(amdtp_out_stream_pcm_pointer);
91746 */
91747 void amdtp_out_stream_update(struct amdtp_out_stream *s)
91748 {
91749 - ACCESS_ONCE(s->source_node_id_field) =
91750 + ACCESS_ONCE_RW(s->source_node_id_field) =
91751 (fw_parent_device(s->unit)->card->node_id & 0x3f) << 24;
91752 }
91753 EXPORT_SYMBOL(amdtp_out_stream_update);
91754 diff --git a/sound/firewire/amdtp.h b/sound/firewire/amdtp.h
91755 index b680c5e..061b7a0 100644
91756 --- a/sound/firewire/amdtp.h
91757 +++ b/sound/firewire/amdtp.h
91758 @@ -139,7 +139,7 @@ static inline bool amdtp_out_streaming_error(struct amdtp_out_stream *s)
91759 static inline void amdtp_out_stream_pcm_trigger(struct amdtp_out_stream *s,
91760 struct snd_pcm_substream *pcm)
91761 {
91762 - ACCESS_ONCE(s->pcm) = pcm;
91763 + ACCESS_ONCE_RW(s->pcm) = pcm;
91764 }
91765
91766 static inline bool cip_sfc_is_base_44100(enum cip_sfc sfc)
91767 diff --git a/sound/firewire/isight.c b/sound/firewire/isight.c
91768 index d428ffe..751ef78 100644
91769 --- a/sound/firewire/isight.c
91770 +++ b/sound/firewire/isight.c
91771 @@ -96,7 +96,7 @@ static void isight_update_pointers(struct isight *isight, unsigned int count)
91772 ptr += count;
91773 if (ptr >= runtime->buffer_size)
91774 ptr -= runtime->buffer_size;
91775 - ACCESS_ONCE(isight->buffer_pointer) = ptr;
91776 + ACCESS_ONCE_RW(isight->buffer_pointer) = ptr;
91777
91778 isight->period_counter += count;
91779 if (isight->period_counter >= runtime->period_size) {
91780 @@ -307,7 +307,7 @@ static int isight_hw_params(struct snd_pcm_substream *substream,
91781 if (err < 0)
91782 return err;
91783
91784 - ACCESS_ONCE(isight->pcm_active) = true;
91785 + ACCESS_ONCE_RW(isight->pcm_active) = true;
91786
91787 return 0;
91788 }
91789 @@ -340,7 +340,7 @@ static int isight_hw_free(struct snd_pcm_substream *substream)
91790 {
91791 struct isight *isight = substream->private_data;
91792
91793 - ACCESS_ONCE(isight->pcm_active) = false;
91794 + ACCESS_ONCE_RW(isight->pcm_active) = false;
91795
91796 mutex_lock(&isight->mutex);
91797 isight_stop_streaming(isight);
91798 @@ -433,10 +433,10 @@ static int isight_trigger(struct snd_pcm_substream *substream, int cmd)
91799
91800 switch (cmd) {
91801 case SNDRV_PCM_TRIGGER_START:
91802 - ACCESS_ONCE(isight->pcm_running) = true;
91803 + ACCESS_ONCE_RW(isight->pcm_running) = true;
91804 break;
91805 case SNDRV_PCM_TRIGGER_STOP:
91806 - ACCESS_ONCE(isight->pcm_running) = false;
91807 + ACCESS_ONCE_RW(isight->pcm_running) = false;
91808 break;
91809 default:
91810 return -EINVAL;
91811 diff --git a/sound/firewire/scs1x.c b/sound/firewire/scs1x.c
91812 index 844a555..985ab83 100644
91813 --- a/sound/firewire/scs1x.c
91814 +++ b/sound/firewire/scs1x.c
91815 @@ -74,7 +74,7 @@ static void scs_output_trigger(struct snd_rawmidi_substream *stream, int up)
91816 {
91817 struct scs *scs = stream->rmidi->private_data;
91818
91819 - ACCESS_ONCE(scs->output) = up ? stream : NULL;
91820 + ACCESS_ONCE_RW(scs->output) = up ? stream : NULL;
91821 if (up) {
91822 scs->output_idle = false;
91823 tasklet_schedule(&scs->tasklet);
91824 @@ -257,7 +257,7 @@ static void scs_input_trigger(struct snd_rawmidi_substream *stream, int up)
91825 {
91826 struct scs *scs = stream->rmidi->private_data;
91827
91828 - ACCESS_ONCE(scs->input) = up ? stream : NULL;
91829 + ACCESS_ONCE_RW(scs->input) = up ? stream : NULL;
91830 }
91831
91832 static void scs_input_escaped_byte(struct snd_rawmidi_substream *stream,
91833 @@ -457,8 +457,8 @@ static int scs_remove(struct device *dev)
91834
91835 snd_card_disconnect(scs->card);
91836
91837 - ACCESS_ONCE(scs->output) = NULL;
91838 - ACCESS_ONCE(scs->input) = NULL;
91839 + ACCESS_ONCE_RW(scs->output) = NULL;
91840 + ACCESS_ONCE_RW(scs->input) = NULL;
91841
91842 wait_event(scs->idle_wait, scs->output_idle);
91843
91844 diff --git a/sound/oss/sb_audio.c b/sound/oss/sb_audio.c
91845 index 048439a..3be9f6f 100644
91846 --- a/sound/oss/sb_audio.c
91847 +++ b/sound/oss/sb_audio.c
91848 @@ -904,7 +904,7 @@ sb16_copy_from_user(int dev,
91849 buf16 = (signed short *)(localbuf + localoffs);
91850 while (c)
91851 {
91852 - locallen = (c >= LBUFCOPYSIZE ? LBUFCOPYSIZE : c);
91853 + locallen = ((unsigned)c >= LBUFCOPYSIZE ? LBUFCOPYSIZE : c);
91854 if (copy_from_user(lbuf8,
91855 userbuf+useroffs + p,
91856 locallen))
91857 diff --git a/sound/oss/swarm_cs4297a.c b/sound/oss/swarm_cs4297a.c
91858 index 7d8803a..559f8d0 100644
91859 --- a/sound/oss/swarm_cs4297a.c
91860 +++ b/sound/oss/swarm_cs4297a.c
91861 @@ -2621,7 +2621,6 @@ static int __init cs4297a_init(void)
91862 {
91863 struct cs4297a_state *s;
91864 u32 pwr, id;
91865 - mm_segment_t fs;
91866 int rval;
91867 #ifndef CONFIG_BCM_CS4297A_CSWARM
91868 u64 cfg;
91869 @@ -2711,22 +2710,23 @@ static int __init cs4297a_init(void)
91870 if (!rval) {
91871 char *sb1250_duart_present;
91872
91873 +#if 0
91874 + mm_segment_t fs;
91875 fs = get_fs();
91876 set_fs(KERNEL_DS);
91877 -#if 0
91878 val = SOUND_MASK_LINE;
91879 mixer_ioctl(s, SOUND_MIXER_WRITE_RECSRC, (unsigned long) &val);
91880 for (i = 0; i < ARRAY_SIZE(initvol); i++) {
91881 val = initvol[i].vol;
91882 mixer_ioctl(s, initvol[i].mixch, (unsigned long) &val);
91883 }
91884 + set_fs(fs);
91885 // cs4297a_write_ac97(s, 0x18, 0x0808);
91886 #else
91887 // cs4297a_write_ac97(s, 0x5e, 0x180);
91888 cs4297a_write_ac97(s, 0x02, 0x0808);
91889 cs4297a_write_ac97(s, 0x18, 0x0808);
91890 #endif
91891 - set_fs(fs);
91892
91893 list_add(&s->list, &cs4297a_devs);
91894
91895 diff --git a/sound/pci/ymfpci/ymfpci.h b/sound/pci/ymfpci/ymfpci.h
91896 index 4631a23..001ae57 100644
91897 --- a/sound/pci/ymfpci/ymfpci.h
91898 +++ b/sound/pci/ymfpci/ymfpci.h
91899 @@ -358,7 +358,7 @@ struct snd_ymfpci {
91900 spinlock_t reg_lock;
91901 spinlock_t voice_lock;
91902 wait_queue_head_t interrupt_sleep;
91903 - atomic_t interrupt_sleep_count;
91904 + atomic_unchecked_t interrupt_sleep_count;
91905 struct snd_info_entry *proc_entry;
91906 const struct firmware *dsp_microcode;
91907 const struct firmware *controller_microcode;
91908 diff --git a/sound/pci/ymfpci/ymfpci_main.c b/sound/pci/ymfpci/ymfpci_main.c
91909 index 22056c5..25d3244 100644
91910 --- a/sound/pci/ymfpci/ymfpci_main.c
91911 +++ b/sound/pci/ymfpci/ymfpci_main.c
91912 @@ -202,8 +202,8 @@ static void snd_ymfpci_hw_stop(struct snd_ymfpci *chip)
91913 if ((snd_ymfpci_readl(chip, YDSXGR_STATUS) & 2) == 0)
91914 break;
91915 }
91916 - if (atomic_read(&chip->interrupt_sleep_count)) {
91917 - atomic_set(&chip->interrupt_sleep_count, 0);
91918 + if (atomic_read_unchecked(&chip->interrupt_sleep_count)) {
91919 + atomic_set_unchecked(&chip->interrupt_sleep_count, 0);
91920 wake_up(&chip->interrupt_sleep);
91921 }
91922 __end:
91923 @@ -787,7 +787,7 @@ static void snd_ymfpci_irq_wait(struct snd_ymfpci *chip)
91924 continue;
91925 init_waitqueue_entry(&wait, current);
91926 add_wait_queue(&chip->interrupt_sleep, &wait);
91927 - atomic_inc(&chip->interrupt_sleep_count);
91928 + atomic_inc_unchecked(&chip->interrupt_sleep_count);
91929 schedule_timeout_uninterruptible(msecs_to_jiffies(50));
91930 remove_wait_queue(&chip->interrupt_sleep, &wait);
91931 }
91932 @@ -825,8 +825,8 @@ static irqreturn_t snd_ymfpci_interrupt(int irq, void *dev_id)
91933 snd_ymfpci_writel(chip, YDSXGR_MODE, mode);
91934 spin_unlock(&chip->reg_lock);
91935
91936 - if (atomic_read(&chip->interrupt_sleep_count)) {
91937 - atomic_set(&chip->interrupt_sleep_count, 0);
91938 + if (atomic_read_unchecked(&chip->interrupt_sleep_count)) {
91939 + atomic_set_unchecked(&chip->interrupt_sleep_count, 0);
91940 wake_up(&chip->interrupt_sleep);
91941 }
91942 }
91943 @@ -2421,7 +2421,7 @@ int snd_ymfpci_create(struct snd_card *card,
91944 spin_lock_init(&chip->reg_lock);
91945 spin_lock_init(&chip->voice_lock);
91946 init_waitqueue_head(&chip->interrupt_sleep);
91947 - atomic_set(&chip->interrupt_sleep_count, 0);
91948 + atomic_set_unchecked(&chip->interrupt_sleep_count, 0);
91949 chip->card = card;
91950 chip->pci = pci;
91951 chip->irq = -1;
91952 diff --git a/tools/gcc/.gitignore b/tools/gcc/.gitignore
91953 new file mode 100644
91954 index 0000000..50f2f2f
91955 --- /dev/null
91956 +++ b/tools/gcc/.gitignore
91957 @@ -0,0 +1 @@
91958 +size_overflow_hash.h
91959 diff --git a/tools/gcc/Makefile b/tools/gcc/Makefile
91960 new file mode 100644
91961 index 0000000..33a1587
91962 --- /dev/null
91963 +++ b/tools/gcc/Makefile
91964 @@ -0,0 +1,43 @@
91965 +#CC := gcc
91966 +#PLUGIN_SOURCE_FILES := pax_plugin.c
91967 +#PLUGIN_OBJECT_FILES := $(patsubst %.c,%.o,$(PLUGIN_SOURCE_FILES))
91968 +GCCPLUGINS_DIR := $(shell $(CC) -print-file-name=plugin)
91969 +#CFLAGS += -I$(GCCPLUGINS_DIR)/include -fPIC -O2 -Wall -W -std=gnu99
91970 +
91971 +ifeq ($(PLUGINCC),$(HOSTCC))
91972 +HOSTLIBS := hostlibs
91973 +HOST_EXTRACFLAGS += -I$(GCCPLUGINS_DIR)/include -std=gnu99 -ggdb
91974 +else
91975 +HOSTLIBS := hostcxxlibs
91976 +HOST_EXTRACXXFLAGS += -I$(GCCPLUGINS_DIR)/include -std=gnu++98 -ggdb -Wno-unused-parameter
91977 +endif
91978 +
91979 +$(HOSTLIBS)-$(CONFIG_PAX_CONSTIFY_PLUGIN) := constify_plugin.so
91980 +$(HOSTLIBS)-$(CONFIG_PAX_MEMORY_STACKLEAK) += stackleak_plugin.so
91981 +$(HOSTLIBS)-$(CONFIG_KALLOCSTAT_PLUGIN) += kallocstat_plugin.so
91982 +$(HOSTLIBS)-$(CONFIG_PAX_KERNEXEC_PLUGIN) += kernexec_plugin.so
91983 +$(HOSTLIBS)-$(CONFIG_CHECKER_PLUGIN) += checker_plugin.so
91984 +$(HOSTLIBS)-y += colorize_plugin.so
91985 +$(HOSTLIBS)-$(CONFIG_PAX_SIZE_OVERFLOW) += size_overflow_plugin.so
91986 +$(HOSTLIBS)-$(CONFIG_PAX_LATENT_ENTROPY) += latent_entropy_plugin.so
91987 +
91988 +always := $($(HOSTLIBS)-y)
91989 +
91990 +constify_plugin-objs := constify_plugin.o
91991 +stackleak_plugin-objs := stackleak_plugin.o
91992 +kallocstat_plugin-objs := kallocstat_plugin.o
91993 +kernexec_plugin-objs := kernexec_plugin.o
91994 +checker_plugin-objs := checker_plugin.o
91995 +colorize_plugin-objs := colorize_plugin.o
91996 +size_overflow_plugin-objs := size_overflow_plugin.o
91997 +latent_entropy_plugin-objs := latent_entropy_plugin.o
91998 +
91999 +$(obj)/size_overflow_plugin.o: $(objtree)/$(obj)/size_overflow_hash.h
92000 +
92001 +quiet_cmd_build_size_overflow_hash = GENHASH $@
92002 + cmd_build_size_overflow_hash = \
92003 + $(CONFIG_SHELL) $(srctree)/$(src)/generate_size_overflow_hash.sh -d $< -o $@
92004 +$(objtree)/$(obj)/size_overflow_hash.h: $(src)/size_overflow_hash.data FORCE
92005 + $(call if_changed,build_size_overflow_hash)
92006 +
92007 +targets += size_overflow_hash.h
92008 diff --git a/tools/gcc/checker_plugin.c b/tools/gcc/checker_plugin.c
92009 new file mode 100644
92010 index 0000000..d41b5af
92011 --- /dev/null
92012 +++ b/tools/gcc/checker_plugin.c
92013 @@ -0,0 +1,171 @@
92014 +/*
92015 + * Copyright 2011 by the PaX Team <pageexec@freemail.hu>
92016 + * Licensed under the GPL v2
92017 + *
92018 + * Note: the choice of the license means that the compilation process is
92019 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
92020 + * but for the kernel it doesn't matter since it doesn't link against
92021 + * any of the gcc libraries
92022 + *
92023 + * gcc plugin to implement various sparse (source code checker) features
92024 + *
92025 + * TODO:
92026 + * - define separate __iomem, __percpu and __rcu address spaces (lots of code to patch)
92027 + *
92028 + * BUGS:
92029 + * - none known
92030 + */
92031 +#include "gcc-plugin.h"
92032 +#include "config.h"
92033 +#include "system.h"
92034 +#include "coretypes.h"
92035 +#include "tree.h"
92036 +#include "tree-pass.h"
92037 +#include "flags.h"
92038 +#include "intl.h"
92039 +#include "toplev.h"
92040 +#include "plugin.h"
92041 +//#include "expr.h" where are you...
92042 +#include "diagnostic.h"
92043 +#include "plugin-version.h"
92044 +#include "tm.h"
92045 +#include "function.h"
92046 +#include "basic-block.h"
92047 +#include "gimple.h"
92048 +#include "rtl.h"
92049 +#include "emit-rtl.h"
92050 +#include "tree-flow.h"
92051 +#include "target.h"
92052 +
92053 +extern void c_register_addr_space (const char *str, addr_space_t as);
92054 +extern enum machine_mode default_addr_space_pointer_mode (addr_space_t);
92055 +extern enum machine_mode default_addr_space_address_mode (addr_space_t);
92056 +extern bool default_addr_space_valid_pointer_mode(enum machine_mode mode, addr_space_t as);
92057 +extern bool default_addr_space_legitimate_address_p(enum machine_mode mode, rtx mem, bool strict, addr_space_t as);
92058 +extern rtx default_addr_space_legitimize_address(rtx x, rtx oldx, enum machine_mode mode, addr_space_t as);
92059 +
92060 +extern void print_gimple_stmt(FILE *, gimple, int, int);
92061 +extern rtx emit_move_insn(rtx x, rtx y);
92062 +
92063 +int plugin_is_GPL_compatible;
92064 +
92065 +static struct plugin_info checker_plugin_info = {
92066 + .version = "201111150100",
92067 +};
92068 +
92069 +#define ADDR_SPACE_KERNEL 0
92070 +#define ADDR_SPACE_FORCE_KERNEL 1
92071 +#define ADDR_SPACE_USER 2
92072 +#define ADDR_SPACE_FORCE_USER 3
92073 +#define ADDR_SPACE_IOMEM 0
92074 +#define ADDR_SPACE_FORCE_IOMEM 0
92075 +#define ADDR_SPACE_PERCPU 0
92076 +#define ADDR_SPACE_FORCE_PERCPU 0
92077 +#define ADDR_SPACE_RCU 0
92078 +#define ADDR_SPACE_FORCE_RCU 0
92079 +
92080 +static enum machine_mode checker_addr_space_pointer_mode(addr_space_t addrspace)
92081 +{
92082 + return default_addr_space_pointer_mode(ADDR_SPACE_GENERIC);
92083 +}
92084 +
92085 +static enum machine_mode checker_addr_space_address_mode(addr_space_t addrspace)
92086 +{
92087 + return default_addr_space_address_mode(ADDR_SPACE_GENERIC);
92088 +}
92089 +
92090 +static bool checker_addr_space_valid_pointer_mode(enum machine_mode mode, addr_space_t as)
92091 +{
92092 + return default_addr_space_valid_pointer_mode(mode, as);
92093 +}
92094 +
92095 +static bool checker_addr_space_legitimate_address_p(enum machine_mode mode, rtx mem, bool strict, addr_space_t as)
92096 +{
92097 + return default_addr_space_legitimate_address_p(mode, mem, strict, ADDR_SPACE_GENERIC);
92098 +}
92099 +
92100 +static rtx checker_addr_space_legitimize_address(rtx x, rtx oldx, enum machine_mode mode, addr_space_t as)
92101 +{
92102 + return default_addr_space_legitimize_address(x, oldx, mode, as);
92103 +}
92104 +
92105 +static bool checker_addr_space_subset_p(addr_space_t subset, addr_space_t superset)
92106 +{
92107 + if (subset == ADDR_SPACE_FORCE_KERNEL && superset == ADDR_SPACE_KERNEL)
92108 + return true;
92109 +
92110 + if (subset == ADDR_SPACE_FORCE_USER && superset == ADDR_SPACE_USER)
92111 + return true;
92112 +
92113 + if (subset == ADDR_SPACE_FORCE_IOMEM && superset == ADDR_SPACE_IOMEM)
92114 + return true;
92115 +
92116 + if (subset == ADDR_SPACE_KERNEL && superset == ADDR_SPACE_FORCE_USER)
92117 + return true;
92118 +
92119 + if (subset == ADDR_SPACE_KERNEL && superset == ADDR_SPACE_FORCE_IOMEM)
92120 + return true;
92121 +
92122 + if (subset == ADDR_SPACE_USER && superset == ADDR_SPACE_FORCE_KERNEL)
92123 + return true;
92124 +
92125 + if (subset == ADDR_SPACE_IOMEM && superset == ADDR_SPACE_FORCE_KERNEL)
92126 + return true;
92127 +
92128 + return subset == superset;
92129 +}
92130 +
92131 +static rtx checker_addr_space_convert(rtx op, tree from_type, tree to_type)
92132 +{
92133 +// addr_space_t from_as = TYPE_ADDR_SPACE(TREE_TYPE(from_type));
92134 +// addr_space_t to_as = TYPE_ADDR_SPACE(TREE_TYPE(to_type));
92135 +
92136 + return op;
92137 +}
92138 +
92139 +static void register_checker_address_spaces(void *event_data, void *data)
92140 +{
92141 + c_register_addr_space("__kernel", ADDR_SPACE_KERNEL);
92142 + c_register_addr_space("__force_kernel", ADDR_SPACE_FORCE_KERNEL);
92143 + c_register_addr_space("__user", ADDR_SPACE_USER);
92144 + c_register_addr_space("__force_user", ADDR_SPACE_FORCE_USER);
92145 +// c_register_addr_space("__iomem", ADDR_SPACE_IOMEM);
92146 +// c_register_addr_space("__force_iomem", ADDR_SPACE_FORCE_IOMEM);
92147 +// c_register_addr_space("__percpu", ADDR_SPACE_PERCPU);
92148 +// c_register_addr_space("__force_percpu", ADDR_SPACE_FORCE_PERCPU);
92149 +// c_register_addr_space("__rcu", ADDR_SPACE_RCU);
92150 +// c_register_addr_space("__force_rcu", ADDR_SPACE_FORCE_RCU);
92151 +
92152 + targetm.addr_space.pointer_mode = checker_addr_space_pointer_mode;
92153 + targetm.addr_space.address_mode = checker_addr_space_address_mode;
92154 + targetm.addr_space.valid_pointer_mode = checker_addr_space_valid_pointer_mode;
92155 + targetm.addr_space.legitimate_address_p = checker_addr_space_legitimate_address_p;
92156 +// targetm.addr_space.legitimize_address = checker_addr_space_legitimize_address;
92157 + targetm.addr_space.subset_p = checker_addr_space_subset_p;
92158 + targetm.addr_space.convert = checker_addr_space_convert;
92159 +}
92160 +
92161 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
92162 +{
92163 + const char * const plugin_name = plugin_info->base_name;
92164 + const int argc = plugin_info->argc;
92165 + const struct plugin_argument * const argv = plugin_info->argv;
92166 + int i;
92167 +
92168 + if (!plugin_default_version_check(version, &gcc_version)) {
92169 + error(G_("incompatible gcc/plugin versions"));
92170 + return 1;
92171 + }
92172 +
92173 + register_callback(plugin_name, PLUGIN_INFO, NULL, &checker_plugin_info);
92174 +
92175 + for (i = 0; i < argc; ++i)
92176 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
92177 +
92178 + if (TARGET_64BIT == 0)
92179 + return 0;
92180 +
92181 + register_callback(plugin_name, PLUGIN_PRAGMAS, register_checker_address_spaces, NULL);
92182 +
92183 + return 0;
92184 +}
92185 diff --git a/tools/gcc/colorize_plugin.c b/tools/gcc/colorize_plugin.c
92186 new file mode 100644
92187 index 0000000..414fe5e
92188 --- /dev/null
92189 +++ b/tools/gcc/colorize_plugin.c
92190 @@ -0,0 +1,151 @@
92191 +/*
92192 + * Copyright 2012-2013 by PaX Team <pageexec@freemail.hu>
92193 + * Licensed under the GPL v2
92194 + *
92195 + * Note: the choice of the license means that the compilation process is
92196 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
92197 + * but for the kernel it doesn't matter since it doesn't link against
92198 + * any of the gcc libraries
92199 + *
92200 + * gcc plugin to colorize diagnostic output
92201 + *
92202 + */
92203 +
92204 +#include "gcc-plugin.h"
92205 +#include "config.h"
92206 +#include "system.h"
92207 +#include "coretypes.h"
92208 +#include "tree.h"
92209 +#include "tree-pass.h"
92210 +#include "flags.h"
92211 +#include "intl.h"
92212 +#include "toplev.h"
92213 +#include "plugin.h"
92214 +#include "diagnostic.h"
92215 +#include "plugin-version.h"
92216 +#include "tm.h"
92217 +
92218 +int plugin_is_GPL_compatible;
92219 +
92220 +static struct plugin_info colorize_plugin_info = {
92221 + .version = "201302112000",
92222 + .help = NULL,
92223 +};
92224 +
92225 +#define GREEN "\033[32m\033[2m"
92226 +#define LIGHTGREEN "\033[32m\033[1m"
92227 +#define YELLOW "\033[33m\033[2m"
92228 +#define LIGHTYELLOW "\033[33m\033[1m"
92229 +#define RED "\033[31m\033[2m"
92230 +#define LIGHTRED "\033[31m\033[1m"
92231 +#define BLUE "\033[34m\033[2m"
92232 +#define LIGHTBLUE "\033[34m\033[1m"
92233 +#define BRIGHT "\033[m\033[1m"
92234 +#define NORMAL "\033[m"
92235 +
92236 +static diagnostic_starter_fn old_starter;
92237 +static diagnostic_finalizer_fn old_finalizer;
92238 +
92239 +static void start_colorize(diagnostic_context *context, diagnostic_info *diagnostic)
92240 +{
92241 + const char *color;
92242 + char *newprefix;
92243 +
92244 + switch (diagnostic->kind) {
92245 + case DK_NOTE:
92246 + color = LIGHTBLUE;
92247 + break;
92248 +
92249 + case DK_PEDWARN:
92250 + case DK_WARNING:
92251 + color = LIGHTYELLOW;
92252 + break;
92253 +
92254 + case DK_ERROR:
92255 + case DK_FATAL:
92256 + case DK_ICE:
92257 + case DK_PERMERROR:
92258 + case DK_SORRY:
92259 + color = LIGHTRED;
92260 + break;
92261 +
92262 + default:
92263 + color = NORMAL;
92264 + }
92265 +
92266 + old_starter(context, diagnostic);
92267 + if (-1 == asprintf(&newprefix, "%s%s" NORMAL, color, context->printer->prefix))
92268 + return;
92269 + pp_destroy_prefix(context->printer);
92270 + pp_set_prefix(context->printer, newprefix);
92271 +}
92272 +
92273 +static void finalize_colorize(diagnostic_context *context, diagnostic_info *diagnostic)
92274 +{
92275 + old_finalizer(context, diagnostic);
92276 +}
92277 +
92278 +static void colorize_arm(void)
92279 +{
92280 + old_starter = diagnostic_starter(global_dc);
92281 + old_finalizer = diagnostic_finalizer(global_dc);
92282 +
92283 + diagnostic_starter(global_dc) = start_colorize;
92284 + diagnostic_finalizer(global_dc) = finalize_colorize;
92285 +}
92286 +
92287 +static unsigned int execute_colorize_rearm(void)
92288 +{
92289 + if (diagnostic_starter(global_dc) == start_colorize)
92290 + return 0;
92291 +
92292 + colorize_arm();
92293 + return 0;
92294 +}
92295 +
92296 +struct simple_ipa_opt_pass pass_ipa_colorize_rearm = {
92297 + .pass = {
92298 + .type = SIMPLE_IPA_PASS,
92299 + .name = "colorize_rearm",
92300 +#if BUILDING_GCC_VERSION >= 4008
92301 + .optinfo_flags = OPTGROUP_NONE,
92302 +#endif
92303 + .gate = NULL,
92304 + .execute = execute_colorize_rearm,
92305 + .sub = NULL,
92306 + .next = NULL,
92307 + .static_pass_number = 0,
92308 + .tv_id = TV_NONE,
92309 + .properties_required = 0,
92310 + .properties_provided = 0,
92311 + .properties_destroyed = 0,
92312 + .todo_flags_start = 0,
92313 + .todo_flags_finish = 0
92314 + }
92315 +};
92316 +
92317 +static void colorize_start_unit(void *gcc_data, void *user_data)
92318 +{
92319 + colorize_arm();
92320 +}
92321 +
92322 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
92323 +{
92324 + const char * const plugin_name = plugin_info->base_name;
92325 + struct register_pass_info colorize_rearm_pass_info = {
92326 + .pass = &pass_ipa_colorize_rearm.pass,
92327 + .reference_pass_name = "*free_lang_data",
92328 + .ref_pass_instance_number = 1,
92329 + .pos_op = PASS_POS_INSERT_AFTER
92330 + };
92331 +
92332 + if (!plugin_default_version_check(version, &gcc_version)) {
92333 + error(G_("incompatible gcc/plugin versions"));
92334 + return 1;
92335 + }
92336 +
92337 + register_callback(plugin_name, PLUGIN_INFO, NULL, &colorize_plugin_info);
92338 + register_callback(plugin_name, PLUGIN_START_UNIT, &colorize_start_unit, NULL);
92339 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &colorize_rearm_pass_info);
92340 + return 0;
92341 +}
92342 diff --git a/tools/gcc/constify_plugin.c b/tools/gcc/constify_plugin.c
92343 new file mode 100644
92344 index 0000000..43e86d6
92345 --- /dev/null
92346 +++ b/tools/gcc/constify_plugin.c
92347 @@ -0,0 +1,512 @@
92348 +/*
92349 + * Copyright 2011 by Emese Revfy <re.emese@gmail.com>
92350 + * Copyright 2011-2013 by PaX Team <pageexec@freemail.hu>
92351 + * Licensed under the GPL v2, or (at your option) v3
92352 + *
92353 + * This gcc plugin constifies all structures which contain only function pointers or are explicitly marked for constification.
92354 + *
92355 + * Homepage:
92356 + * http://www.grsecurity.net/~ephox/const_plugin/
92357 + *
92358 + * Usage:
92359 + * $ gcc -I`gcc -print-file-name=plugin`/include -fPIC -shared -O2 -o constify_plugin.so constify_plugin.c
92360 + * $ gcc -fplugin=constify_plugin.so test.c -O2
92361 + */
92362 +
92363 +#include "gcc-plugin.h"
92364 +#include "config.h"
92365 +#include "system.h"
92366 +#include "coretypes.h"
92367 +#include "tree.h"
92368 +#include "tree-pass.h"
92369 +#include "flags.h"
92370 +#include "intl.h"
92371 +#include "toplev.h"
92372 +#include "plugin.h"
92373 +#include "diagnostic.h"
92374 +#include "plugin-version.h"
92375 +#include "tm.h"
92376 +#include "function.h"
92377 +#include "basic-block.h"
92378 +#include "gimple.h"
92379 +#include "rtl.h"
92380 +#include "emit-rtl.h"
92381 +#include "tree-flow.h"
92382 +#include "target.h"
92383 +
92384 +// should come from c-tree.h if only it were installed for gcc 4.5...
92385 +#define C_TYPE_FIELDS_READONLY(TYPE) TREE_LANG_FLAG_1(TYPE)
92386 +
92387 +// unused type flag in all versions 4.5-4.8
92388 +#define TYPE_CONSTIFY_VISITED(TYPE) TYPE_LANG_FLAG_4(TYPE)
92389 +
92390 +int plugin_is_GPL_compatible;
92391 +
92392 +static struct plugin_info const_plugin_info = {
92393 + .version = "201303070020",
92394 + .help = "no-constify\tturn off constification\n",
92395 +};
92396 +
92397 +typedef struct {
92398 + bool has_fptr_field;
92399 + bool has_writable_field;
92400 + bool has_do_const_field;
92401 + bool has_no_const_field;
92402 +} constify_info;
92403 +
92404 +static const_tree get_field_type(const_tree field)
92405 +{
92406 + return strip_array_types(TREE_TYPE(field));
92407 +}
92408 +
92409 +static bool is_fptr(const_tree field)
92410 +{
92411 + const_tree ptr = get_field_type(field);
92412 +
92413 + if (TREE_CODE(ptr) != POINTER_TYPE)
92414 + return false;
92415 +
92416 + return TREE_CODE(TREE_TYPE(ptr)) == FUNCTION_TYPE;
92417 +}
92418 +
92419 +/*
92420 + * determine whether the given structure type meets the requirements for automatic constification,
92421 + * including the constification attributes on nested structure types
92422 + */
92423 +static void constifiable(const_tree node, constify_info *cinfo)
92424 +{
92425 + const_tree field;
92426 +
92427 + gcc_assert(TREE_CODE(node) == RECORD_TYPE || TREE_CODE(node) == UNION_TYPE);
92428 +
92429 + // e.g., pointer to structure fields while still constructing the structure type
92430 + if (TYPE_FIELDS(node) == NULL_TREE)
92431 + return;
92432 +
92433 + for (field = TYPE_FIELDS(node); field; field = TREE_CHAIN(field)) {
92434 + const_tree type = get_field_type(field);
92435 + enum tree_code code = TREE_CODE(type);
92436 +
92437 + if (node == type)
92438 + continue;
92439 +
92440 + if (is_fptr(field))
92441 + cinfo->has_fptr_field = true;
92442 + else if (!TREE_READONLY(field))
92443 + cinfo->has_writable_field = true;
92444 +
92445 + if (code == RECORD_TYPE || code == UNION_TYPE) {
92446 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
92447 + cinfo->has_do_const_field = true;
92448 + else if (lookup_attribute("no_const", TYPE_ATTRIBUTES(type)))
92449 + cinfo->has_no_const_field = true;
92450 + else
92451 + constifiable(type, cinfo);
92452 + }
92453 + }
92454 +}
92455 +
92456 +static bool constified(const_tree node)
92457 +{
92458 + constify_info cinfo = {
92459 + .has_fptr_field = false,
92460 + .has_writable_field = false,
92461 + .has_do_const_field = false,
92462 + .has_no_const_field = false
92463 + };
92464 +
92465 + gcc_assert(TREE_CODE(node) == RECORD_TYPE || TREE_CODE(node) == UNION_TYPE);
92466 +
92467 + if (lookup_attribute("no_const", TYPE_ATTRIBUTES(node))) {
92468 + gcc_assert(!TYPE_READONLY(node));
92469 + return false;
92470 + }
92471 +
92472 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(node))) {
92473 + gcc_assert(TYPE_READONLY(node));
92474 + return true;
92475 + }
92476 +
92477 + constifiable(node, &cinfo);
92478 + if ((!cinfo.has_fptr_field || cinfo.has_writable_field) && !cinfo.has_do_const_field)
92479 + return false;
92480 +
92481 + return TYPE_READONLY(node);
92482 +}
92483 +
92484 +static void deconstify_tree(tree node);
92485 +
92486 +static void deconstify_type(tree type)
92487 +{
92488 + tree field;
92489 +
92490 + gcc_assert(TREE_CODE(type) == RECORD_TYPE || TREE_CODE(type) == UNION_TYPE);
92491 +
92492 + for (field = TYPE_FIELDS(type); field; field = TREE_CHAIN(field)) {
92493 + const_tree fieldtype = get_field_type(field);
92494 +
92495 + // special case handling of simple ptr-to-same-array-type members
92496 + if (TREE_CODE(TREE_TYPE(field)) == POINTER_TYPE) {
92497 + const_tree ptrtype = TREE_TYPE(TREE_TYPE(field));
92498 +
92499 + if (TREE_CODE(ptrtype) != RECORD_TYPE && TREE_CODE(ptrtype) != UNION_TYPE)
92500 + continue;
92501 + if (TREE_TYPE(TREE_TYPE(field)) == type)
92502 + continue;
92503 + if (TYPE_MAIN_VARIANT(ptrtype) == TYPE_MAIN_VARIANT(type)) {
92504 + TREE_TYPE(field) = copy_node(TREE_TYPE(field));
92505 + TREE_TYPE(TREE_TYPE(field)) = type;
92506 + }
92507 + continue;
92508 + }
92509 + if (TREE_CODE(fieldtype) != RECORD_TYPE && TREE_CODE(fieldtype) != UNION_TYPE)
92510 + continue;
92511 + if (!constified(fieldtype))
92512 + continue;
92513 +
92514 + deconstify_tree(field);
92515 + TREE_READONLY(field) = 0;
92516 + }
92517 + TYPE_READONLY(type) = 0;
92518 + C_TYPE_FIELDS_READONLY(type) = 0;
92519 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
92520 + TYPE_ATTRIBUTES(type) = remove_attribute("do_const", TYPE_ATTRIBUTES(type));
92521 +}
92522 +
92523 +static void deconstify_tree(tree node)
92524 +{
92525 + tree old_type, new_type, field;
92526 +
92527 + old_type = TREE_TYPE(node);
92528 + while (TREE_CODE(old_type) == ARRAY_TYPE && TREE_CODE(TREE_TYPE(old_type)) != ARRAY_TYPE) {
92529 + node = TREE_TYPE(node) = copy_node(old_type);
92530 + old_type = TREE_TYPE(old_type);
92531 + }
92532 +
92533 + gcc_assert(TREE_CODE(old_type) == RECORD_TYPE || TREE_CODE(old_type) == UNION_TYPE);
92534 + gcc_assert(TYPE_READONLY(old_type) && (TYPE_QUALS(old_type) & TYPE_QUAL_CONST));
92535 +
92536 + new_type = build_qualified_type(old_type, TYPE_QUALS(old_type) & ~TYPE_QUAL_CONST);
92537 + TYPE_FIELDS(new_type) = copy_list(TYPE_FIELDS(new_type));
92538 + for (field = TYPE_FIELDS(new_type); field; field = TREE_CHAIN(field))
92539 + DECL_FIELD_CONTEXT(field) = new_type;
92540 +
92541 + deconstify_type(new_type);
92542 +
92543 + TREE_TYPE(node) = new_type;
92544 +}
92545 +
92546 +static tree handle_no_const_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
92547 +{
92548 + tree type;
92549 + constify_info cinfo = {
92550 + .has_fptr_field = false,
92551 + .has_writable_field = false,
92552 + .has_do_const_field = false,
92553 + .has_no_const_field = false
92554 + };
92555 +
92556 + *no_add_attrs = true;
92557 + if (TREE_CODE(*node) == FUNCTION_DECL) {
92558 + error("%qE attribute does not apply to functions", name);
92559 + return NULL_TREE;
92560 + }
92561 +
92562 + if (TREE_CODE(*node) == PARM_DECL) {
92563 + error("%qE attribute does not apply to function parameters", name);
92564 + return NULL_TREE;
92565 + }
92566 +
92567 + if (TREE_CODE(*node) == VAR_DECL) {
92568 + error("%qE attribute does not apply to variables", name);
92569 + return NULL_TREE;
92570 + }
92571 +
92572 + if (TYPE_P(*node)) {
92573 + *no_add_attrs = false;
92574 + type = *node;
92575 + } else {
92576 + gcc_assert(TREE_CODE(*node) == TYPE_DECL);
92577 + type = TREE_TYPE(*node);
92578 + }
92579 +
92580 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE) {
92581 + error("%qE attribute applies to struct and union types only", name);
92582 + return NULL_TREE;
92583 + }
92584 +
92585 + if (lookup_attribute(IDENTIFIER_POINTER(name), TYPE_ATTRIBUTES(type))) {
92586 + error("%qE attribute is already applied to the type", name);
92587 + return NULL_TREE;
92588 + }
92589 +
92590 + if (TYPE_P(*node)) {
92591 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
92592 + error("%qE attribute is incompatible with 'do_const'", name);
92593 + return NULL_TREE;
92594 + }
92595 +
92596 + constifiable(type, &cinfo);
92597 + if ((cinfo.has_fptr_field && !cinfo.has_writable_field) || lookup_attribute("do_const", TYPE_ATTRIBUTES(type))) {
92598 + deconstify_tree(*node);
92599 + TYPE_CONSTIFY_VISITED(TREE_TYPE(*node)) = 1;
92600 + return NULL_TREE;
92601 + }
92602 +
92603 + error("%qE attribute used on type that is not constified", name);
92604 + return NULL_TREE;
92605 +}
92606 +
92607 +static void constify_type(tree type)
92608 +{
92609 + TYPE_READONLY(type) = 1;
92610 + C_TYPE_FIELDS_READONLY(type) = 1;
92611 + TYPE_CONSTIFY_VISITED(type) = 1;
92612 +// TYPE_ATTRIBUTES(type) = tree_cons(get_identifier("do_const"), NULL_TREE, TYPE_ATTRIBUTES(type));
92613 +}
92614 +
92615 +static tree handle_do_const_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
92616 +{
92617 + *no_add_attrs = true;
92618 + if (!TYPE_P(*node)) {
92619 + error("%qE attribute applies to types only", name);
92620 + return NULL_TREE;
92621 + }
92622 +
92623 + if (TREE_CODE(*node) != RECORD_TYPE && TREE_CODE(*node) != UNION_TYPE) {
92624 + error("%qE attribute applies to struct and union types only", name);
92625 + return NULL_TREE;
92626 + }
92627 +
92628 + if (lookup_attribute(IDENTIFIER_POINTER(name), TYPE_ATTRIBUTES(*node))) {
92629 + error("%qE attribute is already applied to the type", name);
92630 + return NULL_TREE;
92631 + }
92632 +
92633 + if (lookup_attribute("no_const", TYPE_ATTRIBUTES(*node))) {
92634 + error("%qE attribute is incompatible with 'no_const'", name);
92635 + return NULL_TREE;
92636 + }
92637 +
92638 + *no_add_attrs = false;
92639 + return NULL_TREE;
92640 +}
92641 +
92642 +static struct attribute_spec no_const_attr = {
92643 + .name = "no_const",
92644 + .min_length = 0,
92645 + .max_length = 0,
92646 + .decl_required = false,
92647 + .type_required = false,
92648 + .function_type_required = false,
92649 + .handler = handle_no_const_attribute,
92650 +#if BUILDING_GCC_VERSION >= 4007
92651 + .affects_type_identity = true
92652 +#endif
92653 +};
92654 +
92655 +static struct attribute_spec do_const_attr = {
92656 + .name = "do_const",
92657 + .min_length = 0,
92658 + .max_length = 0,
92659 + .decl_required = false,
92660 + .type_required = false,
92661 + .function_type_required = false,
92662 + .handler = handle_do_const_attribute,
92663 +#if BUILDING_GCC_VERSION >= 4007
92664 + .affects_type_identity = true
92665 +#endif
92666 +};
92667 +
92668 +static void register_attributes(void *event_data, void *data)
92669 +{
92670 + register_attribute(&no_const_attr);
92671 + register_attribute(&do_const_attr);
92672 +}
92673 +
92674 +static void finish_type(void *event_data, void *data)
92675 +{
92676 + tree type = (tree)event_data;
92677 + constify_info cinfo = {
92678 + .has_fptr_field = false,
92679 + .has_writable_field = false,
92680 + .has_do_const_field = false,
92681 + .has_no_const_field = false
92682 + };
92683 +
92684 + if (type == NULL_TREE || type == error_mark_node)
92685 + return;
92686 +
92687 + if (TYPE_FIELDS(type) == NULL_TREE || TYPE_CONSTIFY_VISITED(type))
92688 + return;
92689 +
92690 + constifiable(type, &cinfo);
92691 +
92692 + if (TYPE_READONLY(type) && C_TYPE_FIELDS_READONLY(type)) {
92693 + if (!lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
92694 + return;
92695 + if (cinfo.has_writable_field)
92696 + return;
92697 + error("'do_const' attribute used on type that is%sconstified", cinfo.has_fptr_field ? " " : " not ");
92698 + return;
92699 + }
92700 +
92701 + if (lookup_attribute("no_const", TYPE_ATTRIBUTES(type))) {
92702 + if ((cinfo.has_fptr_field && !cinfo.has_writable_field) || cinfo.has_do_const_field) {
92703 + deconstify_type(type);
92704 + TYPE_CONSTIFY_VISITED(type) = 1;
92705 + } else
92706 + error("'no_const' attribute used on type that is not constified");
92707 + return;
92708 + }
92709 +
92710 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type))) {
92711 + constify_type(type);
92712 + return;
92713 + }
92714 +
92715 + if (cinfo.has_fptr_field && !cinfo.has_writable_field) {
92716 + constify_type(type);
92717 + return;
92718 + }
92719 +
92720 + deconstify_type(type);
92721 + TYPE_CONSTIFY_VISITED(type) = 1;
92722 +}
92723 +
92724 +static unsigned int check_local_variables(void)
92725 +{
92726 + unsigned int ret = 0;
92727 + tree var;
92728 +
92729 +#if BUILDING_GCC_VERSION == 4005
92730 + tree vars;
92731 +#else
92732 + unsigned int i;
92733 +#endif
92734 +
92735 +#if BUILDING_GCC_VERSION == 4005
92736 + for (vars = cfun->local_decls; vars; vars = TREE_CHAIN(vars)) {
92737 + var = TREE_VALUE(vars);
92738 +#else
92739 + FOR_EACH_LOCAL_DECL(cfun, i, var) {
92740 +#endif
92741 + tree type = TREE_TYPE(var);
92742 +
92743 + gcc_assert(DECL_P(var));
92744 + if (is_global_var(var))
92745 + continue;
92746 +
92747 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE)
92748 + continue;
92749 +
92750 + if (!TYPE_READONLY(type) || !C_TYPE_FIELDS_READONLY(type))
92751 + continue;
92752 +
92753 + if (!TYPE_CONSTIFY_VISITED(type))
92754 + continue;
92755 +
92756 + error_at(DECL_SOURCE_LOCATION(var), "constified variable %qE cannot be local", var);
92757 + ret = 1;
92758 + }
92759 + return ret;
92760 +}
92761 +
92762 +static struct gimple_opt_pass pass_local_variable = {
92763 + {
92764 + .type = GIMPLE_PASS,
92765 + .name = "check_local_variables",
92766 +#if BUILDING_GCC_VERSION >= 4008
92767 + .optinfo_flags = OPTGROUP_NONE,
92768 +#endif
92769 + .gate = NULL,
92770 + .execute = check_local_variables,
92771 + .sub = NULL,
92772 + .next = NULL,
92773 + .static_pass_number = 0,
92774 + .tv_id = TV_NONE,
92775 + .properties_required = 0,
92776 + .properties_provided = 0,
92777 + .properties_destroyed = 0,
92778 + .todo_flags_start = 0,
92779 + .todo_flags_finish = 0
92780 + }
92781 +};
92782 +
92783 +static struct {
92784 + const char *name;
92785 + const char *asm_op;
92786 +} sections[] = {
92787 + {".init.rodata", "\t.section\t.init.rodata,\"a\""},
92788 + {".ref.rodata", "\t.section\t.ref.rodata,\"a\""},
92789 + {".devinit.rodata", "\t.section\t.devinit.rodata,\"a\""},
92790 + {".devexit.rodata", "\t.section\t.devexit.rodata,\"a\""},
92791 + {".cpuinit.rodata", "\t.section\t.cpuinit.rodata,\"a\""},
92792 + {".cpuexit.rodata", "\t.section\t.cpuexit.rodata,\"a\""},
92793 + {".meminit.rodata", "\t.section\t.meminit.rodata,\"a\""},
92794 + {".memexit.rodata", "\t.section\t.memexit.rodata,\"a\""},
92795 + {".data..read_only", "\t.section\t.data..read_only,\"a\""},
92796 +};
92797 +
92798 +static unsigned int (*old_section_type_flags)(tree decl, const char *name, int reloc);
92799 +
92800 +static unsigned int constify_section_type_flags(tree decl, const char *name, int reloc)
92801 +{
92802 + size_t i;
92803 +
92804 + for (i = 0; i < ARRAY_SIZE(sections); i++)
92805 + if (!strcmp(sections[i].name, name))
92806 + return 0;
92807 + return old_section_type_flags(decl, name, reloc);
92808 +}
92809 +
92810 +static void constify_start_unit(void *gcc_data, void *user_data)
92811 +{
92812 +// size_t i;
92813 +
92814 +// for (i = 0; i < ARRAY_SIZE(sections); i++)
92815 +// sections[i].section = get_unnamed_section(0, output_section_asm_op, sections[i].asm_op);
92816 +// sections[i].section = get_section(sections[i].name, 0, NULL);
92817 +
92818 + old_section_type_flags = targetm.section_type_flags;
92819 + targetm.section_type_flags = constify_section_type_flags;
92820 +}
92821 +
92822 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
92823 +{
92824 + const char * const plugin_name = plugin_info->base_name;
92825 + const int argc = plugin_info->argc;
92826 + const struct plugin_argument * const argv = plugin_info->argv;
92827 + int i;
92828 + bool constify = true;
92829 +
92830 + struct register_pass_info local_variable_pass_info = {
92831 + .pass = &pass_local_variable.pass,
92832 + .reference_pass_name = "ssa",
92833 + .ref_pass_instance_number = 1,
92834 + .pos_op = PASS_POS_INSERT_BEFORE
92835 + };
92836 +
92837 + if (!plugin_default_version_check(version, &gcc_version)) {
92838 + error(G_("incompatible gcc/plugin versions"));
92839 + return 1;
92840 + }
92841 +
92842 + for (i = 0; i < argc; ++i) {
92843 + if (!(strcmp(argv[i].key, "no-constify"))) {
92844 + constify = false;
92845 + continue;
92846 + }
92847 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
92848 + }
92849 +
92850 + register_callback(plugin_name, PLUGIN_INFO, NULL, &const_plugin_info);
92851 + if (constify) {
92852 + register_callback(plugin_name, PLUGIN_FINISH_TYPE, finish_type, NULL);
92853 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &local_variable_pass_info);
92854 + register_callback(plugin_name, PLUGIN_START_UNIT, constify_start_unit, NULL);
92855 + }
92856 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
92857 +
92858 + return 0;
92859 +}
92860 diff --git a/tools/gcc/generate_size_overflow_hash.sh b/tools/gcc/generate_size_overflow_hash.sh
92861 new file mode 100644
92862 index 0000000..e518932
92863 --- /dev/null
92864 +++ b/tools/gcc/generate_size_overflow_hash.sh
92865 @@ -0,0 +1,94 @@
92866 +#!/bin/bash
92867 +
92868 +# This script generates the hash table (size_overflow_hash.h) for the size_overflow gcc plugin (size_overflow_plugin.c).
92869 +
92870 +header1="size_overflow_hash.h"
92871 +database="size_overflow_hash.data"
92872 +n=65536
92873 +
92874 +usage() {
92875 +cat <<EOF
92876 +usage: $0 options
92877 +OPTIONS:
92878 + -h|--help help
92879 + -o header file
92880 + -d database file
92881 + -n hash array size
92882 +EOF
92883 + return 0
92884 +}
92885 +
92886 +while true
92887 +do
92888 + case "$1" in
92889 + -h|--help) usage && exit 0;;
92890 + -n) n=$2; shift 2;;
92891 + -o) header1="$2"; shift 2;;
92892 + -d) database="$2"; shift 2;;
92893 + --) shift 1; break ;;
92894 + *) break ;;
92895 + esac
92896 +done
92897 +
92898 +create_defines() {
92899 + for i in `seq 0 31`
92900 + do
92901 + echo -e "#define PARAM"$i" (1U << "$i")" >> "$header1"
92902 + done
92903 + echo >> "$header1"
92904 +}
92905 +
92906 +create_structs() {
92907 + rm -f "$header1"
92908 +
92909 + create_defines
92910 +
92911 + cat "$database" | while read data
92912 + do
92913 + data_array=($data)
92914 + struct_hash_name="${data_array[0]}"
92915 + funcn="${data_array[1]}"
92916 + params="${data_array[2]}"
92917 + next="${data_array[4]}"
92918 +
92919 + echo "const struct size_overflow_hash $struct_hash_name = {" >> "$header1"
92920 +
92921 + echo -e "\t.next\t= $next,\n\t.name\t= \"$funcn\"," >> "$header1"
92922 + echo -en "\t.param\t= " >> "$header1"
92923 + line=
92924 + for param_num in ${params//-/ };
92925 + do
92926 + line="${line}PARAM"$param_num"|"
92927 + done
92928 +
92929 + echo -e "${line%?},\n};\n" >> "$header1"
92930 + done
92931 +}
92932 +
92933 +create_headers() {
92934 + echo "const struct size_overflow_hash * const size_overflow_hash[$n] = {" >> "$header1"
92935 +}
92936 +
92937 +create_array_elements() {
92938 + index=0
92939 + grep -v "nohasharray" $database | sort -n -k 4 | while read data
92940 + do
92941 + data_array=($data)
92942 + i="${data_array[3]}"
92943 + hash="${data_array[0]}"
92944 + while [[ $index -lt $i ]]
92945 + do
92946 + echo -e "\t["$index"]\t= NULL," >> "$header1"
92947 + index=$(($index + 1))
92948 + done
92949 + index=$(($index + 1))
92950 + echo -e "\t["$i"]\t= &"$hash"," >> "$header1"
92951 + done
92952 + echo '};' >> $header1
92953 +}
92954 +
92955 +create_structs
92956 +create_headers
92957 +create_array_elements
92958 +
92959 +exit 0
92960 diff --git a/tools/gcc/kallocstat_plugin.c b/tools/gcc/kallocstat_plugin.c
92961 new file mode 100644
92962 index 0000000..568b360
92963 --- /dev/null
92964 +++ b/tools/gcc/kallocstat_plugin.c
92965 @@ -0,0 +1,170 @@
92966 +/*
92967 + * Copyright 2011-2013 by the PaX Team <pageexec@freemail.hu>
92968 + * Licensed under the GPL v2
92969 + *
92970 + * Note: the choice of the license means that the compilation process is
92971 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
92972 + * but for the kernel it doesn't matter since it doesn't link against
92973 + * any of the gcc libraries
92974 + *
92975 + * gcc plugin to find the distribution of k*alloc sizes
92976 + *
92977 + * TODO:
92978 + *
92979 + * BUGS:
92980 + * - none known
92981 + */
92982 +#include "gcc-plugin.h"
92983 +#include "config.h"
92984 +#include "system.h"
92985 +#include "coretypes.h"
92986 +#include "tree.h"
92987 +#include "tree-pass.h"
92988 +#include "flags.h"
92989 +#include "intl.h"
92990 +#include "toplev.h"
92991 +#include "plugin.h"
92992 +//#include "expr.h" where are you...
92993 +#include "diagnostic.h"
92994 +#include "plugin-version.h"
92995 +#include "tm.h"
92996 +#include "function.h"
92997 +#include "basic-block.h"
92998 +#include "gimple.h"
92999 +#include "rtl.h"
93000 +#include "emit-rtl.h"
93001 +
93002 +extern void print_gimple_stmt(FILE *, gimple, int, int);
93003 +
93004 +int plugin_is_GPL_compatible;
93005 +
93006 +static const char * const kalloc_functions[] = {
93007 + "__kmalloc",
93008 + "kmalloc",
93009 + "kmalloc_large",
93010 + "kmalloc_node",
93011 + "kmalloc_order",
93012 + "kmalloc_order_trace",
93013 + "kmalloc_slab",
93014 + "kzalloc",
93015 + "kzalloc_node",
93016 +};
93017 +
93018 +static struct plugin_info kallocstat_plugin_info = {
93019 + .version = "201302112000",
93020 +};
93021 +
93022 +static unsigned int execute_kallocstat(void);
93023 +
93024 +static struct gimple_opt_pass kallocstat_pass = {
93025 + .pass = {
93026 + .type = GIMPLE_PASS,
93027 + .name = "kallocstat",
93028 +#if BUILDING_GCC_VERSION >= 4008
93029 + .optinfo_flags = OPTGROUP_NONE,
93030 +#endif
93031 + .gate = NULL,
93032 + .execute = execute_kallocstat,
93033 + .sub = NULL,
93034 + .next = NULL,
93035 + .static_pass_number = 0,
93036 + .tv_id = TV_NONE,
93037 + .properties_required = 0,
93038 + .properties_provided = 0,
93039 + .properties_destroyed = 0,
93040 + .todo_flags_start = 0,
93041 + .todo_flags_finish = 0
93042 + }
93043 +};
93044 +
93045 +static bool is_kalloc(const char *fnname)
93046 +{
93047 + size_t i;
93048 +
93049 + for (i = 0; i < ARRAY_SIZE(kalloc_functions); i++)
93050 + if (!strcmp(fnname, kalloc_functions[i]))
93051 + return true;
93052 + return false;
93053 +}
93054 +
93055 +static unsigned int execute_kallocstat(void)
93056 +{
93057 + basic_block bb;
93058 +
93059 + // 1. loop through BBs and GIMPLE statements
93060 + FOR_EACH_BB(bb) {
93061 + gimple_stmt_iterator gsi;
93062 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
93063 + // gimple match:
93064 + tree fndecl, size;
93065 + gimple call_stmt;
93066 + const char *fnname;
93067 +
93068 + // is it a call
93069 + call_stmt = gsi_stmt(gsi);
93070 + if (!is_gimple_call(call_stmt))
93071 + continue;
93072 + fndecl = gimple_call_fndecl(call_stmt);
93073 + if (fndecl == NULL_TREE)
93074 + continue;
93075 + if (TREE_CODE(fndecl) != FUNCTION_DECL)
93076 + continue;
93077 +
93078 + // is it a call to k*alloc
93079 + fnname = IDENTIFIER_POINTER(DECL_NAME(fndecl));
93080 + if (!is_kalloc(fnname))
93081 + continue;
93082 +
93083 + // is the size arg the result of a simple const assignment
93084 + size = gimple_call_arg(call_stmt, 0);
93085 + while (true) {
93086 + gimple def_stmt;
93087 + expanded_location xloc;
93088 + size_t size_val;
93089 +
93090 + if (TREE_CODE(size) != SSA_NAME)
93091 + break;
93092 + def_stmt = SSA_NAME_DEF_STMT(size);
93093 + if (!def_stmt || !is_gimple_assign(def_stmt))
93094 + break;
93095 + if (gimple_num_ops(def_stmt) != 2)
93096 + break;
93097 + size = gimple_assign_rhs1(def_stmt);
93098 + if (!TREE_CONSTANT(size))
93099 + continue;
93100 + xloc = expand_location(gimple_location(def_stmt));
93101 + if (!xloc.file)
93102 + xloc = expand_location(DECL_SOURCE_LOCATION(current_function_decl));
93103 + size_val = TREE_INT_CST_LOW(size);
93104 + fprintf(stderr, "kallocsize: %8zu %8zx %s %s:%u\n", size_val, size_val, fnname, xloc.file, xloc.line);
93105 + break;
93106 + }
93107 +//print_gimple_stmt(stderr, call_stmt, 0, TDF_LINENO);
93108 +//debug_tree(gimple_call_fn(call_stmt));
93109 +//print_node(stderr, "pax", fndecl, 4);
93110 + }
93111 + }
93112 +
93113 + return 0;
93114 +}
93115 +
93116 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
93117 +{
93118 + const char * const plugin_name = plugin_info->base_name;
93119 + struct register_pass_info kallocstat_pass_info = {
93120 + .pass = &kallocstat_pass.pass,
93121 + .reference_pass_name = "ssa",
93122 + .ref_pass_instance_number = 1,
93123 + .pos_op = PASS_POS_INSERT_AFTER
93124 + };
93125 +
93126 + if (!plugin_default_version_check(version, &gcc_version)) {
93127 + error(G_("incompatible gcc/plugin versions"));
93128 + return 1;
93129 + }
93130 +
93131 + register_callback(plugin_name, PLUGIN_INFO, NULL, &kallocstat_plugin_info);
93132 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kallocstat_pass_info);
93133 +
93134 + return 0;
93135 +}
93136 diff --git a/tools/gcc/kernexec_plugin.c b/tools/gcc/kernexec_plugin.c
93137 new file mode 100644
93138 index 0000000..0408e06
93139 --- /dev/null
93140 +++ b/tools/gcc/kernexec_plugin.c
93141 @@ -0,0 +1,465 @@
93142 +/*
93143 + * Copyright 2011-2013 by the PaX Team <pageexec@freemail.hu>
93144 + * Licensed under the GPL v2
93145 + *
93146 + * Note: the choice of the license means that the compilation process is
93147 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
93148 + * but for the kernel it doesn't matter since it doesn't link against
93149 + * any of the gcc libraries
93150 + *
93151 + * gcc plugin to make KERNEXEC/amd64 almost as good as it is on i386
93152 + *
93153 + * TODO:
93154 + *
93155 + * BUGS:
93156 + * - none known
93157 + */
93158 +#include "gcc-plugin.h"
93159 +#include "config.h"
93160 +#include "system.h"
93161 +#include "coretypes.h"
93162 +#include "tree.h"
93163 +#include "tree-pass.h"
93164 +#include "flags.h"
93165 +#include "intl.h"
93166 +#include "toplev.h"
93167 +#include "plugin.h"
93168 +//#include "expr.h" where are you...
93169 +#include "diagnostic.h"
93170 +#include "plugin-version.h"
93171 +#include "tm.h"
93172 +#include "function.h"
93173 +#include "basic-block.h"
93174 +#include "gimple.h"
93175 +#include "rtl.h"
93176 +#include "emit-rtl.h"
93177 +#include "tree-flow.h"
93178 +
93179 +extern void print_gimple_stmt(FILE *, gimple, int, int);
93180 +extern rtx emit_move_insn(rtx x, rtx y);
93181 +
93182 +#if BUILDING_GCC_VERSION <= 4006
93183 +#define ANY_RETURN_P(rtx) (GET_CODE(rtx) == RETURN)
93184 +#endif
93185 +
93186 +#if BUILDING_GCC_VERSION >= 4008
93187 +#define TODO_dump_func 0
93188 +#endif
93189 +
93190 +int plugin_is_GPL_compatible;
93191 +
93192 +static struct plugin_info kernexec_plugin_info = {
93193 + .version = "201302112000",
93194 + .help = "method=[bts|or]\tinstrumentation method\n"
93195 +};
93196 +
93197 +static unsigned int execute_kernexec_reload(void);
93198 +static unsigned int execute_kernexec_fptr(void);
93199 +static unsigned int execute_kernexec_retaddr(void);
93200 +static bool kernexec_cmodel_check(void);
93201 +
93202 +static void (*kernexec_instrument_fptr)(gimple_stmt_iterator *);
93203 +static void (*kernexec_instrument_retaddr)(rtx);
93204 +
93205 +static struct gimple_opt_pass kernexec_reload_pass = {
93206 + .pass = {
93207 + .type = GIMPLE_PASS,
93208 + .name = "kernexec_reload",
93209 +#if BUILDING_GCC_VERSION >= 4008
93210 + .optinfo_flags = OPTGROUP_NONE,
93211 +#endif
93212 + .gate = kernexec_cmodel_check,
93213 + .execute = execute_kernexec_reload,
93214 + .sub = NULL,
93215 + .next = NULL,
93216 + .static_pass_number = 0,
93217 + .tv_id = TV_NONE,
93218 + .properties_required = 0,
93219 + .properties_provided = 0,
93220 + .properties_destroyed = 0,
93221 + .todo_flags_start = 0,
93222 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_remove_unused_locals | TODO_update_ssa_no_phi
93223 + }
93224 +};
93225 +
93226 +static struct gimple_opt_pass kernexec_fptr_pass = {
93227 + .pass = {
93228 + .type = GIMPLE_PASS,
93229 + .name = "kernexec_fptr",
93230 +#if BUILDING_GCC_VERSION >= 4008
93231 + .optinfo_flags = OPTGROUP_NONE,
93232 +#endif
93233 + .gate = kernexec_cmodel_check,
93234 + .execute = execute_kernexec_fptr,
93235 + .sub = NULL,
93236 + .next = NULL,
93237 + .static_pass_number = 0,
93238 + .tv_id = TV_NONE,
93239 + .properties_required = 0,
93240 + .properties_provided = 0,
93241 + .properties_destroyed = 0,
93242 + .todo_flags_start = 0,
93243 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_remove_unused_locals | TODO_update_ssa_no_phi
93244 + }
93245 +};
93246 +
93247 +static struct rtl_opt_pass kernexec_retaddr_pass = {
93248 + .pass = {
93249 + .type = RTL_PASS,
93250 + .name = "kernexec_retaddr",
93251 +#if BUILDING_GCC_VERSION >= 4008
93252 + .optinfo_flags = OPTGROUP_NONE,
93253 +#endif
93254 + .gate = kernexec_cmodel_check,
93255 + .execute = execute_kernexec_retaddr,
93256 + .sub = NULL,
93257 + .next = NULL,
93258 + .static_pass_number = 0,
93259 + .tv_id = TV_NONE,
93260 + .properties_required = 0,
93261 + .properties_provided = 0,
93262 + .properties_destroyed = 0,
93263 + .todo_flags_start = 0,
93264 + .todo_flags_finish = TODO_dump_func | TODO_ggc_collect
93265 + }
93266 +};
93267 +
93268 +static bool kernexec_cmodel_check(void)
93269 +{
93270 + tree section;
93271 +
93272 + if (ix86_cmodel != CM_KERNEL)
93273 + return false;
93274 +
93275 + section = lookup_attribute("section", DECL_ATTRIBUTES(current_function_decl));
93276 + if (!section || !TREE_VALUE(section))
93277 + return true;
93278 +
93279 + section = TREE_VALUE(TREE_VALUE(section));
93280 + if (strncmp(TREE_STRING_POINTER(section), ".vsyscall_", 10))
93281 + return true;
93282 +
93283 + return false;
93284 +}
93285 +
93286 +/*
93287 + * add special KERNEXEC instrumentation: reload %r10 after it has been clobbered
93288 + */
93289 +static void kernexec_reload_fptr_mask(gimple_stmt_iterator *gsi)
93290 +{
93291 + gimple asm_movabs_stmt;
93292 +
93293 + // build asm volatile("movabs $0x8000000000000000, %%r10\n\t" : : : );
93294 + asm_movabs_stmt = gimple_build_asm_vec("movabs $0x8000000000000000, %%r10\n\t", NULL, NULL, NULL, NULL);
93295 + gimple_asm_set_volatile(asm_movabs_stmt, true);
93296 + gsi_insert_after(gsi, asm_movabs_stmt, GSI_CONTINUE_LINKING);
93297 + update_stmt(asm_movabs_stmt);
93298 +}
93299 +
93300 +/*
93301 + * find all asm() stmts that clobber r10 and add a reload of r10
93302 + */
93303 +static unsigned int execute_kernexec_reload(void)
93304 +{
93305 + basic_block bb;
93306 +
93307 + // 1. loop through BBs and GIMPLE statements
93308 + FOR_EACH_BB(bb) {
93309 + gimple_stmt_iterator gsi;
93310 +
93311 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
93312 + // gimple match: __asm__ ("" : : : "r10");
93313 + gimple asm_stmt;
93314 + size_t nclobbers;
93315 +
93316 + // is it an asm ...
93317 + asm_stmt = gsi_stmt(gsi);
93318 + if (gimple_code(asm_stmt) != GIMPLE_ASM)
93319 + continue;
93320 +
93321 + // ... clobbering r10
93322 + nclobbers = gimple_asm_nclobbers(asm_stmt);
93323 + while (nclobbers--) {
93324 + tree op = gimple_asm_clobber_op(asm_stmt, nclobbers);
93325 + if (strcmp(TREE_STRING_POINTER(TREE_VALUE(op)), "r10"))
93326 + continue;
93327 + kernexec_reload_fptr_mask(&gsi);
93328 +//print_gimple_stmt(stderr, asm_stmt, 0, TDF_LINENO);
93329 + break;
93330 + }
93331 + }
93332 + }
93333 +
93334 + return 0;
93335 +}
93336 +
93337 +/*
93338 + * add special KERNEXEC instrumentation: force MSB of fptr to 1, which will produce
93339 + * a non-canonical address from a userland ptr and will just trigger a GPF on dereference
93340 + */
93341 +static void kernexec_instrument_fptr_bts(gimple_stmt_iterator *gsi)
93342 +{
93343 + gimple assign_intptr, assign_new_fptr, call_stmt;
93344 + tree intptr, old_fptr, new_fptr, kernexec_mask;
93345 +
93346 + call_stmt = gsi_stmt(*gsi);
93347 + old_fptr = gimple_call_fn(call_stmt);
93348 +
93349 + // create temporary unsigned long variable used for bitops and cast fptr to it
93350 + intptr = create_tmp_var(long_unsigned_type_node, "kernexec_bts");
93351 +#if BUILDING_GCC_VERSION <= 4007
93352 + add_referenced_var(intptr);
93353 + mark_sym_for_renaming(intptr);
93354 +#endif
93355 + assign_intptr = gimple_build_assign(intptr, fold_convert(long_unsigned_type_node, old_fptr));
93356 + gsi_insert_before(gsi, assign_intptr, GSI_SAME_STMT);
93357 + update_stmt(assign_intptr);
93358 +
93359 + // apply logical or to temporary unsigned long and bitmask
93360 + kernexec_mask = build_int_cstu(long_long_unsigned_type_node, 0x8000000000000000LL);
93361 +// kernexec_mask = build_int_cstu(long_long_unsigned_type_node, 0xffffffff80000000LL);
93362 + assign_intptr = gimple_build_assign(intptr, fold_build2(BIT_IOR_EXPR, long_long_unsigned_type_node, intptr, kernexec_mask));
93363 + gsi_insert_before(gsi, assign_intptr, GSI_SAME_STMT);
93364 + update_stmt(assign_intptr);
93365 +
93366 + // cast temporary unsigned long back to a temporary fptr variable
93367 + new_fptr = create_tmp_var(TREE_TYPE(old_fptr), "kernexec_fptr");
93368 +#if BUILDING_GCC_VERSION <= 4007
93369 + add_referenced_var(new_fptr);
93370 + mark_sym_for_renaming(new_fptr);
93371 +#endif
93372 + assign_new_fptr = gimple_build_assign(new_fptr, fold_convert(TREE_TYPE(old_fptr), intptr));
93373 + gsi_insert_before(gsi, assign_new_fptr, GSI_SAME_STMT);
93374 + update_stmt(assign_new_fptr);
93375 +
93376 + // replace call stmt fn with the new fptr
93377 + gimple_call_set_fn(call_stmt, new_fptr);
93378 + update_stmt(call_stmt);
93379 +}
93380 +
93381 +static void kernexec_instrument_fptr_or(gimple_stmt_iterator *gsi)
93382 +{
93383 + gimple asm_or_stmt, call_stmt;
93384 + tree old_fptr, new_fptr, input, output;
93385 +#if BUILDING_GCC_VERSION <= 4007
93386 + VEC(tree, gc) *inputs = NULL;
93387 + VEC(tree, gc) *outputs = NULL;
93388 +#else
93389 + vec<tree, va_gc> *inputs = NULL;
93390 + vec<tree, va_gc> *outputs = NULL;
93391 +#endif
93392 +
93393 + call_stmt = gsi_stmt(*gsi);
93394 + old_fptr = gimple_call_fn(call_stmt);
93395 +
93396 + // create temporary fptr variable
93397 + new_fptr = create_tmp_var(TREE_TYPE(old_fptr), "kernexec_or");
93398 +#if BUILDING_GCC_VERSION <= 4007
93399 + add_referenced_var(new_fptr);
93400 + mark_sym_for_renaming(new_fptr);
93401 +#endif
93402 +
93403 + // build asm volatile("orq %%r10, %0\n\t" : "=r"(new_fptr) : "0"(old_fptr));
93404 + input = build_tree_list(NULL_TREE, build_string(2, "0"));
93405 + input = chainon(NULL_TREE, build_tree_list(input, old_fptr));
93406 + output = build_tree_list(NULL_TREE, build_string(3, "=r"));
93407 + output = chainon(NULL_TREE, build_tree_list(output, new_fptr));
93408 +#if BUILDING_GCC_VERSION <= 4007
93409 + VEC_safe_push(tree, gc, inputs, input);
93410 + VEC_safe_push(tree, gc, outputs, output);
93411 +#else
93412 + vec_safe_push(inputs, input);
93413 + vec_safe_push(outputs, output);
93414 +#endif
93415 + asm_or_stmt = gimple_build_asm_vec("orq %%r10, %0\n\t", inputs, outputs, NULL, NULL);
93416 + gimple_asm_set_volatile(asm_or_stmt, true);
93417 + gsi_insert_before(gsi, asm_or_stmt, GSI_SAME_STMT);
93418 + update_stmt(asm_or_stmt);
93419 +
93420 + // replace call stmt fn with the new fptr
93421 + gimple_call_set_fn(call_stmt, new_fptr);
93422 + update_stmt(call_stmt);
93423 +}
93424 +
93425 +/*
93426 + * find all C level function pointer dereferences and forcibly set the highest bit of the pointer
93427 + */
93428 +static unsigned int execute_kernexec_fptr(void)
93429 +{
93430 + basic_block bb;
93431 +
93432 + // 1. loop through BBs and GIMPLE statements
93433 + FOR_EACH_BB(bb) {
93434 + gimple_stmt_iterator gsi;
93435 +
93436 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
93437 + // gimple match: h_1 = get_fptr (); D.2709_3 = h_1 (x_2(D));
93438 + tree fn;
93439 + gimple call_stmt;
93440 +
93441 + // is it a call ...
93442 + call_stmt = gsi_stmt(gsi);
93443 + if (!is_gimple_call(call_stmt))
93444 + continue;
93445 + fn = gimple_call_fn(call_stmt);
93446 + if (TREE_CODE(fn) == ADDR_EXPR)
93447 + continue;
93448 + if (TREE_CODE(fn) != SSA_NAME)
93449 + gcc_unreachable();
93450 +
93451 + // ... through a function pointer
93452 + if (SSA_NAME_VAR(fn) != NULL_TREE) {
93453 + fn = SSA_NAME_VAR(fn);
93454 + if (TREE_CODE(fn) != VAR_DECL && TREE_CODE(fn) != PARM_DECL) {
93455 + debug_tree(fn);
93456 + gcc_unreachable();
93457 + }
93458 + }
93459 + fn = TREE_TYPE(fn);
93460 + if (TREE_CODE(fn) != POINTER_TYPE)
93461 + continue;
93462 + fn = TREE_TYPE(fn);
93463 + if (TREE_CODE(fn) != FUNCTION_TYPE)
93464 + continue;
93465 +
93466 + kernexec_instrument_fptr(&gsi);
93467 +
93468 +//debug_tree(gimple_call_fn(call_stmt));
93469 +//print_gimple_stmt(stderr, call_stmt, 0, TDF_LINENO);
93470 + }
93471 + }
93472 +
93473 + return 0;
93474 +}
93475 +
93476 +// add special KERNEXEC instrumentation: btsq $63,(%rsp) just before retn
93477 +static void kernexec_instrument_retaddr_bts(rtx insn)
93478 +{
93479 + rtx btsq;
93480 + rtvec argvec, constraintvec, labelvec;
93481 + int line;
93482 +
93483 + // create asm volatile("btsq $63,(%%rsp)":::)
93484 + argvec = rtvec_alloc(0);
93485 + constraintvec = rtvec_alloc(0);
93486 + labelvec = rtvec_alloc(0);
93487 + line = expand_location(RTL_LOCATION(insn)).line;
93488 + btsq = gen_rtx_ASM_OPERANDS(VOIDmode, "btsq $63,(%%rsp)", empty_string, 0, argvec, constraintvec, labelvec, line);
93489 + MEM_VOLATILE_P(btsq) = 1;
93490 +// RTX_FRAME_RELATED_P(btsq) = 1; // not for ASM_OPERANDS
93491 + emit_insn_before(btsq, insn);
93492 +}
93493 +
93494 +// add special KERNEXEC instrumentation: orq %r10,(%rsp) just before retn
93495 +static void kernexec_instrument_retaddr_or(rtx insn)
93496 +{
93497 + rtx orq;
93498 + rtvec argvec, constraintvec, labelvec;
93499 + int line;
93500 +
93501 + // create asm volatile("orq %%r10,(%%rsp)":::)
93502 + argvec = rtvec_alloc(0);
93503 + constraintvec = rtvec_alloc(0);
93504 + labelvec = rtvec_alloc(0);
93505 + line = expand_location(RTL_LOCATION(insn)).line;
93506 + orq = gen_rtx_ASM_OPERANDS(VOIDmode, "orq %%r10,(%%rsp)", empty_string, 0, argvec, constraintvec, labelvec, line);
93507 + MEM_VOLATILE_P(orq) = 1;
93508 +// RTX_FRAME_RELATED_P(orq) = 1; // not for ASM_OPERANDS
93509 + emit_insn_before(orq, insn);
93510 +}
93511 +
93512 +/*
93513 + * find all asm level function returns and forcibly set the highest bit of the return address
93514 + */
93515 +static unsigned int execute_kernexec_retaddr(void)
93516 +{
93517 + rtx insn;
93518 +
93519 + // 1. find function returns
93520 + for (insn = get_insns(); insn; insn = NEXT_INSN(insn)) {
93521 + // rtl match: (jump_insn 41 40 42 2 (return) fptr.c:42 634 {return_internal} (nil))
93522 + // (jump_insn 12 9 11 2 (parallel [ (return) (unspec [ (0) ] UNSPEC_REP) ]) fptr.c:46 635 {return_internal_long} (nil))
93523 + // (jump_insn 97 96 98 6 (simple_return) fptr.c:50 -1 (nil) -> simple_return)
93524 + rtx body;
93525 +
93526 + // is it a retn
93527 + if (!JUMP_P(insn))
93528 + continue;
93529 + body = PATTERN(insn);
93530 + if (GET_CODE(body) == PARALLEL)
93531 + body = XVECEXP(body, 0, 0);
93532 + if (!ANY_RETURN_P(body))
93533 + continue;
93534 + kernexec_instrument_retaddr(insn);
93535 + }
93536 +
93537 +// print_simple_rtl(stderr, get_insns());
93538 +// print_rtl(stderr, get_insns());
93539 +
93540 + return 0;
93541 +}
93542 +
93543 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
93544 +{
93545 + const char * const plugin_name = plugin_info->base_name;
93546 + const int argc = plugin_info->argc;
93547 + const struct plugin_argument * const argv = plugin_info->argv;
93548 + int i;
93549 + struct register_pass_info kernexec_reload_pass_info = {
93550 + .pass = &kernexec_reload_pass.pass,
93551 + .reference_pass_name = "ssa",
93552 + .ref_pass_instance_number = 1,
93553 + .pos_op = PASS_POS_INSERT_AFTER
93554 + };
93555 + struct register_pass_info kernexec_fptr_pass_info = {
93556 + .pass = &kernexec_fptr_pass.pass,
93557 + .reference_pass_name = "ssa",
93558 + .ref_pass_instance_number = 1,
93559 + .pos_op = PASS_POS_INSERT_AFTER
93560 + };
93561 + struct register_pass_info kernexec_retaddr_pass_info = {
93562 + .pass = &kernexec_retaddr_pass.pass,
93563 + .reference_pass_name = "pro_and_epilogue",
93564 + .ref_pass_instance_number = 1,
93565 + .pos_op = PASS_POS_INSERT_AFTER
93566 + };
93567 +
93568 + if (!plugin_default_version_check(version, &gcc_version)) {
93569 + error(G_("incompatible gcc/plugin versions"));
93570 + return 1;
93571 + }
93572 +
93573 + register_callback(plugin_name, PLUGIN_INFO, NULL, &kernexec_plugin_info);
93574 +
93575 + if (TARGET_64BIT == 0)
93576 + return 0;
93577 +
93578 + for (i = 0; i < argc; ++i) {
93579 + if (!strcmp(argv[i].key, "method")) {
93580 + if (!argv[i].value) {
93581 + error(G_("no value supplied for option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
93582 + continue;
93583 + }
93584 + if (!strcmp(argv[i].value, "bts")) {
93585 + kernexec_instrument_fptr = kernexec_instrument_fptr_bts;
93586 + kernexec_instrument_retaddr = kernexec_instrument_retaddr_bts;
93587 + } else if (!strcmp(argv[i].value, "or")) {
93588 + kernexec_instrument_fptr = kernexec_instrument_fptr_or;
93589 + kernexec_instrument_retaddr = kernexec_instrument_retaddr_or;
93590 + fix_register("r10", 1, 1);
93591 + } else
93592 + error(G_("invalid option argument '-fplugin-arg-%s-%s=%s'"), plugin_name, argv[i].key, argv[i].value);
93593 + continue;
93594 + }
93595 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
93596 + }
93597 + if (!kernexec_instrument_fptr || !kernexec_instrument_retaddr)
93598 + error(G_("no instrumentation method was selected via '-fplugin-arg-%s-method'"), plugin_name);
93599 +
93600 + if (kernexec_instrument_fptr == kernexec_instrument_fptr_or)
93601 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kernexec_reload_pass_info);
93602 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kernexec_fptr_pass_info);
93603 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kernexec_retaddr_pass_info);
93604 +
93605 + return 0;
93606 +}
93607 diff --git a/tools/gcc/latent_entropy_plugin.c b/tools/gcc/latent_entropy_plugin.c
93608 new file mode 100644
93609 index 0000000..b5395ba
93610 --- /dev/null
93611 +++ b/tools/gcc/latent_entropy_plugin.c
93612 @@ -0,0 +1,327 @@
93613 +/*
93614 + * Copyright 2012-2013 by the PaX Team <pageexec@freemail.hu>
93615 + * Licensed under the GPL v2
93616 + *
93617 + * Note: the choice of the license means that the compilation process is
93618 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
93619 + * but for the kernel it doesn't matter since it doesn't link against
93620 + * any of the gcc libraries
93621 + *
93622 + * gcc plugin to help generate a little bit of entropy from program state,
93623 + * used during boot in the kernel
93624 + *
93625 + * TODO:
93626 + * - add ipa pass to identify not explicitly marked candidate functions
93627 + * - mix in more program state (function arguments/return values, loop variables, etc)
93628 + * - more instrumentation control via attribute parameters
93629 + *
93630 + * BUGS:
93631 + * - LTO needs -flto-partition=none for now
93632 + */
93633 +#include "gcc-plugin.h"
93634 +#include "config.h"
93635 +#include "system.h"
93636 +#include "coretypes.h"
93637 +#include "tree.h"
93638 +#include "tree-pass.h"
93639 +#include "flags.h"
93640 +#include "intl.h"
93641 +#include "toplev.h"
93642 +#include "plugin.h"
93643 +//#include "expr.h" where are you...
93644 +#include "diagnostic.h"
93645 +#include "plugin-version.h"
93646 +#include "tm.h"
93647 +#include "function.h"
93648 +#include "basic-block.h"
93649 +#include "gimple.h"
93650 +#include "rtl.h"
93651 +#include "emit-rtl.h"
93652 +#include "tree-flow.h"
93653 +#include "langhooks.h"
93654 +
93655 +#if BUILDING_GCC_VERSION >= 4008
93656 +#define TODO_dump_func 0
93657 +#endif
93658 +
93659 +int plugin_is_GPL_compatible;
93660 +
93661 +static tree latent_entropy_decl;
93662 +
93663 +static struct plugin_info latent_entropy_plugin_info = {
93664 + .version = "201303102320",
93665 + .help = NULL
93666 +};
93667 +
93668 +static unsigned int execute_latent_entropy(void);
93669 +static bool gate_latent_entropy(void);
93670 +
93671 +static struct gimple_opt_pass latent_entropy_pass = {
93672 + .pass = {
93673 + .type = GIMPLE_PASS,
93674 + .name = "latent_entropy",
93675 +#if BUILDING_GCC_VERSION >= 4008
93676 + .optinfo_flags = OPTGROUP_NONE,
93677 +#endif
93678 + .gate = gate_latent_entropy,
93679 + .execute = execute_latent_entropy,
93680 + .sub = NULL,
93681 + .next = NULL,
93682 + .static_pass_number = 0,
93683 + .tv_id = TV_NONE,
93684 + .properties_required = PROP_gimple_leh | PROP_cfg,
93685 + .properties_provided = 0,
93686 + .properties_destroyed = 0,
93687 + .todo_flags_start = 0, //TODO_verify_ssa | TODO_verify_flow | TODO_verify_stmts,
93688 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_update_ssa
93689 + }
93690 +};
93691 +
93692 +static tree handle_latent_entropy_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
93693 +{
93694 + if (TREE_CODE(*node) != FUNCTION_DECL) {
93695 + *no_add_attrs = true;
93696 + error("%qE attribute only applies to functions", name);
93697 + }
93698 + return NULL_TREE;
93699 +}
93700 +
93701 +static struct attribute_spec latent_entropy_attr = {
93702 + .name = "latent_entropy",
93703 + .min_length = 0,
93704 + .max_length = 0,
93705 + .decl_required = true,
93706 + .type_required = false,
93707 + .function_type_required = false,
93708 + .handler = handle_latent_entropy_attribute,
93709 +#if BUILDING_GCC_VERSION >= 4007
93710 + .affects_type_identity = false
93711 +#endif
93712 +};
93713 +
93714 +static void register_attributes(void *event_data, void *data)
93715 +{
93716 + register_attribute(&latent_entropy_attr);
93717 +}
93718 +
93719 +static bool gate_latent_entropy(void)
93720 +{
93721 + tree latent_entropy_attr;
93722 +
93723 + latent_entropy_attr = lookup_attribute("latent_entropy", DECL_ATTRIBUTES(current_function_decl));
93724 + return latent_entropy_attr != NULL_TREE;
93725 +}
93726 +
93727 +static unsigned HOST_WIDE_INT seed;
93728 +static unsigned HOST_WIDE_INT get_random_const(void)
93729 +{
93730 + seed = (seed >> 1U) ^ (-(seed & 1ULL) & 0xD800000000000000ULL);
93731 + return seed;
93732 +}
93733 +
93734 +static enum tree_code get_op(tree *rhs)
93735 +{
93736 + static enum tree_code op;
93737 + unsigned HOST_WIDE_INT random_const;
93738 +
93739 + random_const = get_random_const();
93740 +
93741 + switch (op) {
93742 + case BIT_XOR_EXPR:
93743 + op = PLUS_EXPR;
93744 + break;
93745 +
93746 + case PLUS_EXPR:
93747 + if (rhs) {
93748 + op = LROTATE_EXPR;
93749 + random_const &= HOST_BITS_PER_WIDE_INT - 1;
93750 + break;
93751 + }
93752 +
93753 + case LROTATE_EXPR:
93754 + default:
93755 + op = BIT_XOR_EXPR;
93756 + break;
93757 + }
93758 + if (rhs)
93759 + *rhs = build_int_cstu(unsigned_intDI_type_node, random_const);
93760 + return op;
93761 +}
93762 +
93763 +static void perturb_local_entropy(basic_block bb, tree local_entropy)
93764 +{
93765 + gimple_stmt_iterator gsi;
93766 + gimple assign;
93767 + tree addxorrol, rhs;
93768 + enum tree_code op;
93769 +
93770 + op = get_op(&rhs);
93771 + addxorrol = fold_build2_loc(UNKNOWN_LOCATION, op, unsigned_intDI_type_node, local_entropy, rhs);
93772 + assign = gimple_build_assign(local_entropy, addxorrol);
93773 +#if BUILDING_GCC_VERSION <= 4007
93774 + find_referenced_vars_in(assign);
93775 +#endif
93776 +//debug_bb(bb);
93777 + gsi = gsi_after_labels(bb);
93778 + gsi_insert_before(&gsi, assign, GSI_NEW_STMT);
93779 + update_stmt(assign);
93780 +}
93781 +
93782 +static void perturb_latent_entropy(basic_block bb, tree rhs)
93783 +{
93784 + gimple_stmt_iterator gsi;
93785 + gimple assign;
93786 + tree addxorrol, temp;
93787 +
93788 + // 1. create temporary copy of latent_entropy
93789 + temp = create_tmp_var(unsigned_intDI_type_node, "temp_latent_entropy");
93790 +#if BUILDING_GCC_VERSION <= 4007
93791 + add_referenced_var(temp);
93792 + mark_sym_for_renaming(temp);
93793 +#endif
93794 +
93795 + // 2. read...
93796 + assign = gimple_build_assign(temp, latent_entropy_decl);
93797 +#if BUILDING_GCC_VERSION <= 4007
93798 + find_referenced_vars_in(assign);
93799 +#endif
93800 + gsi = gsi_after_labels(bb);
93801 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
93802 + update_stmt(assign);
93803 +
93804 + // 3. ...modify...
93805 + addxorrol = fold_build2_loc(UNKNOWN_LOCATION, get_op(NULL), unsigned_intDI_type_node, temp, rhs);
93806 + assign = gimple_build_assign(temp, addxorrol);
93807 +#if BUILDING_GCC_VERSION <= 4007
93808 + find_referenced_vars_in(assign);
93809 +#endif
93810 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
93811 + update_stmt(assign);
93812 +
93813 + // 4. ...write latent_entropy
93814 + assign = gimple_build_assign(latent_entropy_decl, temp);
93815 +#if BUILDING_GCC_VERSION <= 4007
93816 + find_referenced_vars_in(assign);
93817 +#endif
93818 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
93819 + update_stmt(assign);
93820 +}
93821 +
93822 +static unsigned int execute_latent_entropy(void)
93823 +{
93824 + basic_block bb;
93825 + gimple assign;
93826 + gimple_stmt_iterator gsi;
93827 + tree local_entropy;
93828 +
93829 + if (!latent_entropy_decl) {
93830 + struct varpool_node *node;
93831 +
93832 +#if BUILDING_GCC_VERSION <= 4007
93833 + for (node = varpool_nodes; node; node = node->next) {
93834 + tree var = node->decl;
93835 +#else
93836 + FOR_EACH_VARIABLE(node) {
93837 + tree var = node->symbol.decl;
93838 +#endif
93839 + if (strcmp(IDENTIFIER_POINTER(DECL_NAME(var)), "latent_entropy"))
93840 + continue;
93841 + latent_entropy_decl = var;
93842 +// debug_tree(var);
93843 + break;
93844 + }
93845 + if (!latent_entropy_decl) {
93846 +// debug_tree(current_function_decl);
93847 + return 0;
93848 + }
93849 + }
93850 +
93851 +//fprintf(stderr, "latent_entropy: %s\n", IDENTIFIER_POINTER(DECL_NAME(current_function_decl)));
93852 +
93853 + // 1. create local entropy variable
93854 + local_entropy = create_tmp_var(unsigned_intDI_type_node, "local_entropy");
93855 +#if BUILDING_GCC_VERSION <= 4007
93856 + add_referenced_var(local_entropy);
93857 + mark_sym_for_renaming(local_entropy);
93858 +#endif
93859 +
93860 + // 2. initialize local entropy variable
93861 + bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
93862 + if (dom_info_available_p(CDI_DOMINATORS))
93863 + set_immediate_dominator(CDI_DOMINATORS, bb, ENTRY_BLOCK_PTR);
93864 + gsi = gsi_start_bb(bb);
93865 +
93866 + assign = gimple_build_assign(local_entropy, build_int_cstu(unsigned_intDI_type_node, get_random_const()));
93867 +// gimple_set_location(assign, loc);
93868 +#if BUILDING_GCC_VERSION <= 4007
93869 + find_referenced_vars_in(assign);
93870 +#endif
93871 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
93872 + update_stmt(assign);
93873 + bb = bb->next_bb;
93874 +
93875 + // 3. instrument each BB with an operation on the local entropy variable
93876 + while (bb != EXIT_BLOCK_PTR) {
93877 + perturb_local_entropy(bb, local_entropy);
93878 + bb = bb->next_bb;
93879 + };
93880 +
93881 + // 4. mix local entropy into the global entropy variable
93882 + perturb_latent_entropy(EXIT_BLOCK_PTR->prev_bb, local_entropy);
93883 + return 0;
93884 +}
93885 +
93886 +static void start_unit_callback(void *gcc_data, void *user_data)
93887 +{
93888 + tree latent_entropy_type;
93889 +
93890 +#if BUILDING_GCC_VERSION >= 4007
93891 + seed = get_random_seed(false);
93892 +#else
93893 + sscanf(get_random_seed(false), "%" HOST_WIDE_INT_PRINT "x", &seed);
93894 + seed *= seed;
93895 +#endif
93896 +
93897 + if (in_lto_p)
93898 + return;
93899 +
93900 + // extern volatile u64 latent_entropy
93901 + gcc_assert(TYPE_PRECISION(long_long_unsigned_type_node) == 64);
93902 + latent_entropy_type = build_qualified_type(long_long_unsigned_type_node, TYPE_QUALS(long_long_unsigned_type_node) | TYPE_QUAL_VOLATILE);
93903 + latent_entropy_decl = build_decl(UNKNOWN_LOCATION, VAR_DECL, get_identifier("latent_entropy"), latent_entropy_type);
93904 +
93905 + TREE_STATIC(latent_entropy_decl) = 1;
93906 + TREE_PUBLIC(latent_entropy_decl) = 1;
93907 + TREE_USED(latent_entropy_decl) = 1;
93908 + TREE_THIS_VOLATILE(latent_entropy_decl) = 1;
93909 + DECL_EXTERNAL(latent_entropy_decl) = 1;
93910 + DECL_ARTIFICIAL(latent_entropy_decl) = 1;
93911 + DECL_INITIAL(latent_entropy_decl) = NULL;
93912 + lang_hooks.decls.pushdecl(latent_entropy_decl);
93913 +// DECL_ASSEMBLER_NAME(latent_entropy_decl);
93914 +// varpool_finalize_decl(latent_entropy_decl);
93915 +// varpool_mark_needed_node(latent_entropy_decl);
93916 +}
93917 +
93918 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
93919 +{
93920 + const char * const plugin_name = plugin_info->base_name;
93921 + struct register_pass_info latent_entropy_pass_info = {
93922 + .pass = &latent_entropy_pass.pass,
93923 + .reference_pass_name = "optimized",
93924 + .ref_pass_instance_number = 1,
93925 + .pos_op = PASS_POS_INSERT_BEFORE
93926 + };
93927 +
93928 + if (!plugin_default_version_check(version, &gcc_version)) {
93929 + error(G_("incompatible gcc/plugin versions"));
93930 + return 1;
93931 + }
93932 +
93933 + register_callback(plugin_name, PLUGIN_INFO, NULL, &latent_entropy_plugin_info);
93934 + register_callback ("start_unit", PLUGIN_START_UNIT, &start_unit_callback, NULL);
93935 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &latent_entropy_pass_info);
93936 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
93937 +
93938 + return 0;
93939 +}
93940 diff --git a/tools/gcc/size_overflow_hash.data b/tools/gcc/size_overflow_hash.data
93941 new file mode 100644
93942 index 0000000..5ac778be
93943 --- /dev/null
93944 +++ b/tools/gcc/size_overflow_hash.data
93945 @@ -0,0 +1,5862 @@
93946 +intel_fake_agp_alloc_by_type_1 intel_fake_agp_alloc_by_type 1 1 NULL
93947 +batadv_orig_node_del_if_4 batadv_orig_node_del_if 2 4 NULL
93948 +storvsc_connect_to_vsp_22 storvsc_connect_to_vsp 2 22 NULL
93949 +compat_sock_setsockopt_23 compat_sock_setsockopt 5 23 NULL
93950 +carl9170_alloc_27 carl9170_alloc 1 27 NULL
93951 +sel_read_policyvers_55 sel_read_policyvers 3 55 NULL nohasharray
93952 +padzero_55 padzero 1 55 &sel_read_policyvers_55
93953 +cfg80211_disconnected_57 cfg80211_disconnected 4 57 NULL
93954 +__skb_to_sgvec_72 __skb_to_sgvec 0 72 NULL
93955 +DepcaSignature_80 DepcaSignature 2 80 NULL nohasharray
93956 +crypto_authenc_setkey_80 crypto_authenc_setkey 3 80 &DepcaSignature_80
93957 +snd_korg1212_copy_to_92 snd_korg1212_copy_to 6 92 NULL
93958 +load_msg_95 load_msg 2 95 NULL
93959 +device_flush_iotlb_115 device_flush_iotlb 2-3 115 NULL
93960 +init_q_132 init_q 4 132 NULL
93961 +memstick_alloc_host_142 memstick_alloc_host 1 142 NULL
93962 +hva_to_gfn_memslot_149 hva_to_gfn_memslot 0-1 149 NULL
93963 +tracing_trace_options_write_153 tracing_trace_options_write 3 153 NULL
93964 +nvme_create_queue_170 nvme_create_queue 3 170 NULL
93965 +xfs_buf_item_get_format_189 xfs_buf_item_get_format 2 189 NULL
93966 +iscsi_session_setup_196 iscsi_session_setup 4-5 196 NULL
93967 +virtblk_add_req_197 virtblk_add_req 2-3 197 NULL
93968 +proc_scsi_write_proc_267 proc_scsi_write_proc 3 267 NULL
93969 +br_port_info_size_268 br_port_info_size 0 268 NULL
93970 +generic_file_direct_write_291 generic_file_direct_write 0 291 NULL
93971 +read_file_war_stats_292 read_file_war_stats 3 292 NULL
93972 +syslog_print_307 syslog_print 2 307 NULL
93973 +platform_device_add_data_310 platform_device_add_data 3 310 NULL
93974 +dn_setsockopt_314 dn_setsockopt 5 314 NULL
93975 +next_node_allowed_318 next_node_allowed 1 318 NULL
93976 +compat_sys_ioctl_333 compat_sys_ioctl 3 333 NULL
93977 +btmrvl_txdnldready_read_413 btmrvl_txdnldready_read 3 413 NULL
93978 +lbs_rdmac_read_418 lbs_rdmac_read 3 418 NULL
93979 +snd_ca0106_ptr_read_467 snd_ca0106_ptr_read 0 467 NULL
93980 +_alloc_get_attr_desc_470 _alloc_get_attr_desc 2 470 NULL
93981 +dccp_manip_pkt_476 dccp_manip_pkt 4 476 NULL
93982 +pidlist_resize_496 pidlist_resize 2 496 NULL
93983 +read_vbt_r0_503 read_vbt_r0 1 503 NULL
93984 +rx_rx_defrag_end_read_505 rx_rx_defrag_end_read 3 505 NULL
93985 +ocfs2_validate_meta_ecc_bhs_527 ocfs2_validate_meta_ecc_bhs 0 527 NULL
93986 +zlib_deflate_workspacesize_537 zlib_deflate_workspacesize 0-1-2 537 NULL
93987 +iwl_dbgfs_wowlan_sram_read_540 iwl_dbgfs_wowlan_sram_read 3 540 NULL
93988 +dle_count_543 dle_count 0 543 NULL
93989 +devres_alloc_551 devres_alloc 2 551 NULL
93990 +snd_aw2_saa7146_get_hw_ptr_playback_558 snd_aw2_saa7146_get_hw_ptr_playback 0 558 NULL
93991 +dev_hard_header_565 dev_hard_header 0 565 NULL nohasharray
93992 +start_isoc_chain_565 start_isoc_chain 2 565 &dev_hard_header_565
93993 +compat_sys_preadv_583 compat_sys_preadv 3 583 NULL
93994 +smk_write_load_self2_591 smk_write_load_self2 3 591 NULL
93995 +ni_gpct_device_construct_610 ni_gpct_device_construct 5 610 NULL
93996 +compat_sys_shmat_620 compat_sys_shmat 3 620 NULL
93997 +isp1760_register_628 isp1760_register 1-2 628 NULL
93998 +drbd_bm_find_next_643 drbd_bm_find_next 2 643 NULL
93999 +unlink_queued_645 unlink_queued 3-4 645 NULL
94000 +dtim_interval_read_654 dtim_interval_read 3 654 NULL
94001 +ceph_copy_user_to_page_vector_656 ceph_copy_user_to_page_vector 4-3 656 NULL
94002 +div_u64_rem_672 div_u64_rem 0 672 NULL
94003 +mem_rx_free_mem_blks_read_675 mem_rx_free_mem_blks_read 3 675 NULL
94004 +rtl8169_try_rx_copy_705 rtl8169_try_rx_copy 3 705 NULL
94005 +persistent_ram_vmap_709 persistent_ram_vmap 1-2 709 NULL
94006 +ipath_resize_cq_712 ipath_resize_cq 2 712 NULL
94007 +sctp_setsockopt_peer_addr_params_734 sctp_setsockopt_peer_addr_params 3 734 NULL
94008 +wm8962_gpio_direction_out_738 wm8962_gpio_direction_out 2 738 NULL
94009 +dvb_video_write_754 dvb_video_write 3 754 NULL
94010 +iwl_read_targ_mem_772 iwl_read_targ_mem 0 772 NULL
94011 +snd_pcm_drain_811 snd_pcm_drain 0 811 NULL
94012 +if_writecmd_815 if_writecmd 2 815 NULL
94013 +aac_change_queue_depth_825 aac_change_queue_depth 2 825 NULL
94014 +read_fifo_826 read_fifo 3 826 NULL
94015 +read_tree_block_841 read_tree_block 3 841 NULL
94016 +um_idi_read_850 um_idi_read 3 850 NULL
94017 +ieee80211_if_fmt_rc_rateidx_mcs_mask_5ghz_856 ieee80211_if_fmt_rc_rateidx_mcs_mask_5ghz 3 856 NULL
94018 +o2net_send_message_vec_879 o2net_send_message_vec 4 879 NULL nohasharray
94019 +iwl_dbgfs_fh_reg_read_879 iwl_dbgfs_fh_reg_read 3 879 &o2net_send_message_vec_879
94020 +snd_pcm_action_single_905 snd_pcm_action_single 0 905 NULL
94021 +btmrvl_hsstate_read_920 btmrvl_hsstate_read 3 920 NULL
94022 +readw_931 readw 0 931 NULL
94023 +carl9170_cmd_buf_950 carl9170_cmd_buf 3 950 NULL
94024 +ieee80211_ie_build_vht_cap_956 ieee80211_ie_build_vht_cap 0 956 NULL nohasharray
94025 +__nodes_weight_956 __nodes_weight 2-0 956 &ieee80211_ie_build_vht_cap_956
94026 +sys_msgrcv_959 sys_msgrcv 3 959 NULL
94027 +hdlcdev_rx_997 hdlcdev_rx 3 997 NULL
94028 +smk_write_cipso2_1021 smk_write_cipso2 3 1021 NULL
94029 +lp872x_select_buck_vout_addr_1045 lp872x_select_buck_vout_addr 0 1045 NULL
94030 +gigaset_initdriver_1060 gigaset_initdriver 2 1060 NULL
94031 +Read_hfc16_1070 Read_hfc16 0 1070 NULL
94032 +mce_request_packet_1073 mce_request_packet 3 1073 NULL
94033 +agp_create_memory_1075 agp_create_memory 1 1075 NULL
94034 +_scsih_adjust_queue_depth_1083 _scsih_adjust_queue_depth 2 1083 NULL
94035 +nfs_pgarray_set_1085 nfs_pgarray_set 2 1085 NULL
94036 +llcp_sock_sendmsg_1092 llcp_sock_sendmsg 4 1092 NULL
94037 +nfs4_init_nonuniform_client_string_1097 nfs4_init_nonuniform_client_string 3 1097 NULL
94038 +store_risefalltime_1109 store_risefalltime 5 1109 NULL
94039 +cfg80211_report_obss_beacon_1133 cfg80211_report_obss_beacon 3 1133 NULL
94040 +vmalloc_32_1135 vmalloc_32 1 1135 NULL
94041 +i2400m_rx_ctl_1157 i2400m_rx_ctl 4 1157 NULL
94042 +ipc_alloc_1192 ipc_alloc 1 1192 NULL
94043 +ib_create_send_mad_1196 ib_create_send_mad 5 1196 NULL
94044 +i2400m_rx_ctl_ack_1199 i2400m_rx_ctl_ack 3 1199 NULL
94045 +dgrp_dpa_read_1204 dgrp_dpa_read 3 1204 NULL
94046 +i2cdev_read_1206 i2cdev_read 3 1206 NULL
94047 +ipw_packet_received_skb_1230 ipw_packet_received_skb 2 1230 NULL
94048 +thin_status_1239 thin_status 5 1239 NULL
94049 +acpi_battery_write_alarm_1240 acpi_battery_write_alarm 3 1240 NULL
94050 +ocfs2_extend_file_1266 ocfs2_extend_file 3 1266 NULL
94051 +qla4xxx_change_queue_depth_1268 qla4xxx_change_queue_depth 2 1268 NULL
94052 +ioctl_private_iw_point_1273 ioctl_private_iw_point 7 1273 NULL
94053 +batadv_tt_prepare_packet_buff_1280 batadv_tt_prepare_packet_buff 4 1280 NULL
94054 +tx_frag_in_process_called_read_1290 tx_frag_in_process_called_read 3 1290 NULL
94055 +compat_put_u64_1319 compat_put_u64 1 1319 NULL
94056 +ffs_1322 ffs 0 1322 NULL
94057 +carl9170_rx_stream_1334 carl9170_rx_stream 3 1334 NULL
94058 +btrfs_submit_compressed_write_1347 btrfs_submit_compressed_write 5 1347 NULL
94059 +gen_pool_best_fit_1348 gen_pool_best_fit 2-3-4 1348 NULL
94060 +io_mapping_create_wc_1354 io_mapping_create_wc 1-2 1354 NULL
94061 +snd_pcm_lib_write1_1358 snd_pcm_lib_write1 0-3 1358 NULL
94062 +ipx_sendmsg_1362 ipx_sendmsg 4 1362 NULL
94063 +fw_stats_raw_read_1369 fw_stats_raw_read 3 1369 NULL
94064 +ocfs2_prepare_inode_for_write_1372 ocfs2_prepare_inode_for_write 3 1372 NULL
94065 +sctp_setsockopt_initmsg_1383 sctp_setsockopt_initmsg 3 1383 NULL
94066 +do_msgsnd_1387 do_msgsnd 4 1387 NULL
94067 +zone_page_state_1393 zone_page_state 0 1393 NULL
94068 +file_read_actor_1401 file_read_actor 4 1401 NULL
94069 +lm3533_als_get_threshold_reg_1404 lm3533_als_get_threshold_reg 0-1 1404 NULL
94070 +stack_max_size_read_1445 stack_max_size_read 3 1445 NULL
94071 +tx_queue_len_read_1463 tx_queue_len_read 3 1463 NULL
94072 +xprt_alloc_1475 xprt_alloc 2 1475 NULL
94073 +sta_num_ps_buf_frames_read_1488 sta_num_ps_buf_frames_read 3 1488 NULL
94074 +posix_acl_permission_1495 posix_acl_permission 0 1495 NULL
94075 +tomoyo_round2_1518 tomoyo_round2 0 1518 NULL
94076 +alloc_perm_bits_1532 alloc_perm_bits 2 1532 NULL
94077 +ieee80211_if_read_dot11MeshHWMPnetDiameterTraversalTime_1589 ieee80211_if_read_dot11MeshHWMPnetDiameterTraversalTime 3 1589 NULL
94078 +fc_frame_alloc_1596 fc_frame_alloc 2 1596 NULL
94079 +packet_buffer_init_1607 packet_buffer_init 2 1607 NULL
94080 +btmrvl_hscmd_read_1614 btmrvl_hscmd_read 3 1614 NULL
94081 +v9fs_fid_xattr_get_1618 v9fs_fid_xattr_get 0 1618 NULL
94082 +btmrvl_hsmode_read_1647 btmrvl_hsmode_read 3 1647 NULL
94083 +ikconfig_read_current_1658 ikconfig_read_current 3 1658 NULL
94084 +netdev_feature_string_1667 netdev_feature_string 0 1667 NULL
94085 +compat_x25_ioctl_1674 compat_x25_ioctl 3 1674 NULL
94086 +rmap_add_1677 rmap_add 3 1677 NULL
94087 +configfs_read_file_1683 configfs_read_file 3 1683 NULL
94088 +coda_psdev_write_1711 coda_psdev_write 3 1711 NULL
94089 +btrfs_dir_data_len_1714 btrfs_dir_data_len 0 1714 NULL
94090 +dma_memcpy_pg_to_iovec_1725 dma_memcpy_pg_to_iovec 6 1725 NULL
94091 +tx_frag_called_read_1748 tx_frag_called_read 3 1748 NULL
94092 +compat_cdrom_generic_command_1756 compat_cdrom_generic_command 4 1756 NULL
94093 +ieee80211_new_mesh_header_1761 ieee80211_new_mesh_header 0 1761 NULL
94094 +ebt_size_mwt_1768 ebt_size_mwt 0 1768 NULL
94095 +cosa_write_1774 cosa_write 3 1774 NULL
94096 +update_macheader_1775 update_macheader 7 1775 NULL
94097 +fcoe_ctlr_device_add_1793 fcoe_ctlr_device_add 3 1793 NULL
94098 +__nodelist_scnprintf_1815 __nodelist_scnprintf 0-2-4 1815 NULL
94099 +rx_defrag_called_read_1897 rx_defrag_called_read 3 1897 NULL
94100 +nfs_parse_server_name_1899 nfs_parse_server_name 2 1899 NULL
94101 +tx_tx_retry_data_read_1926 tx_tx_retry_data_read 3 1926 NULL
94102 +cyttsp_probe_1940 cyttsp_probe 4 1940 NULL
94103 +ieee80211_if_fmt_dot11MeshConfirmTimeout_1945 ieee80211_if_fmt_dot11MeshConfirmTimeout 3 1945 NULL
94104 +read_swap_header_1957 read_swap_header 0 1957 NULL
94105 +ivtv_v4l2_read_1964 ivtv_v4l2_read 3 1964 NULL
94106 +sel_read_avc_hash_stats_1984 sel_read_avc_hash_stats 3 1984 NULL
94107 +__alloc_bootmem_node_1992 __alloc_bootmem_node 2 1992 NULL
94108 +atomic_read_unchecked_1995 atomic_read_unchecked 0 1995 NULL
94109 +batadv_tt_commit_changes_2008 batadv_tt_commit_changes 4 2008 NULL
94110 +sep_prepare_input_dma_table_2009 sep_prepare_input_dma_table 2-3 2009 NULL
94111 +rx_rx_defrag_read_2010 rx_rx_defrag_read 3 2010 NULL
94112 +ocfs2_global_qinit_alloc_2018 ocfs2_global_qinit_alloc 0 2018 NULL
94113 +write_flush_pipefs_2021 write_flush_pipefs 3 2021 NULL
94114 +BcmCopySection_2035 BcmCopySection 5 2035 NULL
94115 +devm_ioremap_nocache_2036 devm_ioremap_nocache 2-3 2036 NULL
94116 +ath6kl_fwlog_mask_read_2050 ath6kl_fwlog_mask_read 3 2050 NULL
94117 +ocfs2_expand_inline_dir_2063 ocfs2_expand_inline_dir 3 2063 NULL
94118 +subbuf_read_actor_2071 subbuf_read_actor 3 2071 NULL
94119 +iwl_dbgfs_current_sleep_command_read_2081 iwl_dbgfs_current_sleep_command_read 3 2081 NULL
94120 +get_unaligned_le32_2092 get_unaligned_le32 0 2092 NULL
94121 +idetape_chrdev_read_2097 idetape_chrdev_read 3 2097 NULL
94122 +audit_expand_2098 audit_expand 2 2098 NULL
94123 +num_pages_spanned_2105 num_pages_spanned 0 2105 NULL
94124 +iwl_dbgfs_log_event_read_2107 iwl_dbgfs_log_event_read 3 2107 NULL
94125 +ecryptfs_encrypt_and_encode_filename_2109 ecryptfs_encrypt_and_encode_filename 6 2109 NULL
94126 +__find_xattr_2117 __find_xattr 6 2117 NULL nohasharray
94127 +enable_read_2117 enable_read 3 2117 &__find_xattr_2117
94128 +pcf50633_write_block_2124 pcf50633_write_block 3-2 2124 NULL
94129 +check_load_and_stores_2143 check_load_and_stores 2 2143 NULL
94130 +mlx4_init_icm_table_2151 mlx4_init_icm_table 5-4 2151 NULL nohasharray
94131 +multipath_status_2151 multipath_status 5 2151 &mlx4_init_icm_table_2151
94132 +iov_iter_count_2152 iov_iter_count 0 2152 NULL
94133 +_ore_get_io_state_2166 _ore_get_io_state 3-4-5 2166 NULL
94134 +ssb_bus_ssbbus_register_2217 ssb_bus_ssbbus_register 2 2217 NULL
94135 +u32_array_read_2219 u32_array_read 3 2219 NULL
94136 +vhci_write_2224 vhci_write 3 2224 NULL
94137 +efx_tsoh_page_count_2225 efx_tsoh_page_count 0 2225 NULL
94138 +lowpan_get_mac_header_length_2231 lowpan_get_mac_header_length 0 2231 NULL
94139 +ieee80211_if_read_dot11MeshHWMPRannInterval_2249 ieee80211_if_read_dot11MeshHWMPRannInterval 3 2249 NULL
94140 +netlbl_secattr_catmap_walk_2255 netlbl_secattr_catmap_walk 0-2 2255 NULL
94141 +sel_write_avc_cache_threshold_2256 sel_write_avc_cache_threshold 3 2256 NULL
94142 +do_update_counters_2259 do_update_counters 4 2259 NULL
94143 +ath6kl_wmi_bssinfo_event_rx_2275 ath6kl_wmi_bssinfo_event_rx 3 2275 NULL
94144 +debug_debug5_read_2291 debug_debug5_read 3 2291 NULL
94145 +kvm_clear_guest_page_2308 kvm_clear_guest_page 4 2308 NULL
94146 +intel_sdvo_set_value_2311 intel_sdvo_set_value 4 2311 NULL
94147 +picolcd_fb_write_2318 picolcd_fb_write 3 2318 NULL
94148 +gart_map_page_2325 gart_map_page 3-4 2325 NULL
94149 +__erst_read_to_erange_2341 __erst_read_to_erange 0 2341 NULL
94150 +zr364xx_read_2354 zr364xx_read 3 2354 NULL
94151 +viafb_iga2_odev_proc_write_2363 viafb_iga2_odev_proc_write 3 2363 NULL
94152 +xfs_buf_map_from_irec_2368 xfs_buf_map_from_irec 5 2368 NULL
94153 +il_dbgfs_sensitivity_read_2370 il_dbgfs_sensitivity_read 3 2370 NULL
94154 +rtl_port_map_2385 rtl_port_map 1-2 2385 NULL
94155 +rxpipe_rx_prep_beacon_drop_read_2403 rxpipe_rx_prep_beacon_drop_read 3 2403 NULL
94156 +isdn_v110_open_2418 isdn_v110_open 3 2418 NULL
94157 +raid1_size_2419 raid1_size 0-2 2419 NULL
94158 +roccat_common2_send_2422 roccat_common2_send 4 2422 NULL
94159 +hfcpci_empty_fifo_2427 hfcpci_empty_fifo 4 2427 NULL
94160 +ioremap_nocache_2439 ioremap_nocache 1-2 2439 NULL
94161 +tty_buffer_find_2443 tty_buffer_find 2 2443 NULL
94162 +nfs4_alloc_slots_2454 nfs4_alloc_slots 1 2454 NULL nohasharray
94163 +ath6kl_usb_bmi_write_2454 ath6kl_usb_bmi_write 3 2454 &nfs4_alloc_slots_2454
94164 +b43legacy_debugfs_read_2473 b43legacy_debugfs_read 3 2473 NULL
94165 +update_pmkid_2481 update_pmkid 4 2481 NULL
94166 +wiphy_new_2482 wiphy_new 2 2482 NULL
94167 +bio_alloc_bioset_2484 bio_alloc_bioset 2 2484 NULL
94168 +squashfs_read_fragment_index_table_2506 squashfs_read_fragment_index_table 4 2506 NULL
94169 +dm_write_2513 dm_write 3 2513 NULL
94170 +v9fs_cached_file_read_2514 v9fs_cached_file_read 3 2514 NULL
94171 +ext4_get_inode_loc_2516 ext4_get_inode_loc 0 2516 NULL
94172 +gspca_dev_probe_2570 gspca_dev_probe 4 2570 NULL
94173 +pcm_sanity_check_2574 pcm_sanity_check 0 2574 NULL
94174 +smk_write_logging_2618 smk_write_logging 3 2618 NULL
94175 +lro_gen_skb_2644 lro_gen_skb 6 2644 NULL
94176 +nfc_llcp_send_ui_frame_2702 nfc_llcp_send_ui_frame 5 2702 NULL
94177 +memcpy_fromiovecend_2707 memcpy_fromiovecend 3-4 2707 NULL
94178 +__xip_file_write_2733 __xip_file_write 4-3 2733 NULL
94179 +hid_report_raw_event_2762 hid_report_raw_event 4 2762 NULL
94180 +mon_bin_ioctl_2771 mon_bin_ioctl 3 2771 NULL
94181 +__next_cpu_2782 __next_cpu 1 2782 NULL
94182 +sel_read_enforce_2828 sel_read_enforce 3 2828 NULL
94183 +vb2_dc_get_userptr_2829 vb2_dc_get_userptr 2-3 2829 NULL nohasharray
94184 +snd_pcm_reset_2829 snd_pcm_reset 0 2829 &vb2_dc_get_userptr_2829
94185 +wait_for_avail_2847 wait_for_avail 0 2847 NULL
94186 +ufs_free_fragments_2857 ufs_free_fragments 2 2857 NULL
94187 +sfq_alloc_2861 sfq_alloc 1 2861 NULL
94188 +move_addr_to_user_2868 move_addr_to_user 2 2868 NULL
94189 +__swab64p_2875 __swab64p 0 2875 NULL
94190 +nla_padlen_2883 nla_padlen 1 2883 NULL
94191 +cmm_write_2896 cmm_write 3 2896 NULL
94192 +rbd_req_sync_read_2915 rbd_req_sync_read 4-5 2915 NULL
94193 +alloc_page_cgroup_2919 alloc_page_cgroup 1 2919 NULL
94194 +xfs_trans_get_buf_map_2927 xfs_trans_get_buf_map 4 2927 NULL
94195 +nes_read_indexed_2946 nes_read_indexed 0 2946 NULL
94196 +tm6000_i2c_recv_regs16_2949 tm6000_i2c_recv_regs16 5 2949 NULL
94197 +ppp_cp_event_2965 ppp_cp_event 6 2965 NULL
94198 +do_strnlen_user_2976 do_strnlen_user 0-2 2976 NULL
94199 +p9_nr_pages_2992 p9_nr_pages 0-2 2992 NULL
94200 +do_dmabuf_dirty_sou_3017 do_dmabuf_dirty_sou 7 3017 NULL
94201 +depth_write_3021 depth_write 3 3021 NULL
94202 +snd_azf3328_codec_inl_3022 snd_azf3328_codec_inl 0 3022 NULL
94203 +xfrm_dst_alloc_copy_3034 xfrm_dst_alloc_copy 3 3034 NULL
94204 +iwl_dbgfs_sleep_level_override_read_3038 iwl_dbgfs_sleep_level_override_read 3 3038 NULL
94205 +nr_free_buffer_pages_3044 nr_free_buffer_pages 0 3044 NULL
94206 +il3945_ucode_rx_stats_read_3048 il3945_ucode_rx_stats_read 3 3048 NULL
94207 +__blk_end_bidi_request_3070 __blk_end_bidi_request 3-4 3070 NULL
94208 +dac960_user_command_proc_write_3071 dac960_user_command_proc_write 3 3071 NULL
94209 +free_coherent_3082 free_coherent 4-2 3082 NULL
94210 +ttusb2_msg_3100 ttusb2_msg 4 3100 NULL
94211 +rb_alloc_3102 rb_alloc 1 3102 NULL
94212 +simple_write_to_buffer_3122 simple_write_to_buffer 5-2 3122 NULL
94213 +print_time_3132 print_time 0 3132 NULL
94214 +fill_write_buffer_3142 fill_write_buffer 3 3142 NULL
94215 +CIFSSMBSetPosixACL_3154 CIFSSMBSetPosixACL 5 3154 NULL
94216 +compat_sys_migrate_pages_3157 compat_sys_migrate_pages 2 3157 NULL
94217 +uv_num_possible_blades_3177 uv_num_possible_blades 0 3177 NULL
94218 +uvc_video_stats_dump_3181 uvc_video_stats_dump 3 3181 NULL
94219 +compat_do_ip6t_set_ctl_3184 compat_do_ip6t_set_ctl 4 3184 NULL
94220 +mempool_create_node_3191 mempool_create_node 1 3191 NULL
94221 +alloc_context_3194 alloc_context 1 3194 NULL
94222 +shmem_pread_slow_3198 shmem_pread_slow 3 3198 NULL
94223 +kimage_crash_alloc_3233 kimage_crash_alloc 3 3233 NULL
94224 +do_read_log_to_user_3236 do_read_log_to_user 4 3236 NULL
94225 +ext3_xattr_find_entry_3237 ext3_xattr_find_entry 0 3237 NULL
94226 +key_key_read_3241 key_key_read 3 3241 NULL
94227 +number_3243 number 0 3243 NULL
94228 +check_vendor_extension_3254 check_vendor_extension 1 3254 NULL
94229 +__ilog2_u64_3284 __ilog2_u64 0 3284 NULL
94230 +arvo_sysfs_write_3311 arvo_sysfs_write 6 3311 NULL
94231 +dbDiscardAG_3322 dbDiscardAG 3 3322 NULL
94232 +compat_sys_setsockopt_3326 compat_sys_setsockopt 5 3326 NULL
94233 +de600_read_byte_3332 de600_read_byte 0 3332 NULL
94234 +aac_rkt_ioremap_3333 aac_rkt_ioremap 2 3333 NULL
94235 +read_from_oldmem_3337 read_from_oldmem 2 3337 NULL
94236 +tty_port_register_device_attr_3341 tty_port_register_device_attr 3 3341 NULL
94237 +il_dbgfs_interrupt_read_3351 il_dbgfs_interrupt_read 3 3351 NULL
94238 +gsm_control_rls_3353 gsm_control_rls 3 3353 NULL
94239 +scnprintf_3360 scnprintf 0-2 3360 NULL nohasharray
94240 +tps65090_clr_bits_3360 tps65090_clr_bits 2 3360 &scnprintf_3360
94241 +mtdchar_writeoob_3393 mtdchar_writeoob 4 3393 NULL
94242 +send_stream_3397 send_stream 4 3397 NULL
94243 +isdn_readbchan_3401 isdn_readbchan 0-5 3401 NULL
94244 +msix_map_region_3411 msix_map_region 3 3411 NULL
94245 +mei_io_cb_alloc_resp_buf_3414 mei_io_cb_alloc_resp_buf 2 3414 NULL
94246 +pci_add_cap_save_buffer_3426 pci_add_cap_save_buffer 3 3426 NULL
94247 +crystalhd_create_dio_pool_3427 crystalhd_create_dio_pool 2 3427 NULL
94248 +pipe_iov_copy_to_user_3447 pipe_iov_copy_to_user 3 3447 NULL
94249 +percpu_modalloc_3448 percpu_modalloc 2-3 3448 NULL
94250 +jffs2_acl_setxattr_3464 jffs2_acl_setxattr 4 3464 NULL nohasharray
94251 +snd_pcm_lib_readv_transfer_3464 snd_pcm_lib_readv_transfer 4-2-5 3464 &jffs2_acl_setxattr_3464
94252 +alloc_skb_fclone_3467 alloc_skb_fclone 1 3467 NULL
94253 +security_context_to_sid_default_3492 security_context_to_sid_default 2 3492 NULL
94254 +xfrm_migrate_msgsize_3496 xfrm_migrate_msgsize 1 3496 NULL
94255 +mem_tx_free_mem_blks_read_3521 mem_tx_free_mem_blks_read 3 3521 NULL nohasharray
94256 +ieee80211_wx_set_gen_ie_rsl_3521 ieee80211_wx_set_gen_ie_rsl 3 3521 &mem_tx_free_mem_blks_read_3521
94257 +btrfs_dir_name_len_3549 btrfs_dir_name_len 0 3549 NULL
94258 +b43legacy_read16_3561 b43legacy_read16 0 3561 NULL
94259 +alloc_smp_resp_3566 alloc_smp_resp 1 3566 NULL
94260 +evtchn_read_3569 evtchn_read 3 3569 NULL
94261 +vc_resize_3585 vc_resize 2-3 3585 NULL
94262 +compat_sys_semtimedop_3606 compat_sys_semtimedop 3 3606 NULL
94263 +sctp_getsockopt_events_3607 sctp_getsockopt_events 2 3607 NULL
94264 +edac_mc_alloc_3611 edac_mc_alloc 4 3611 NULL
94265 +tx_tx_starts_read_3617 tx_tx_starts_read 3 3617 NULL
94266 +aligned_kmalloc_3628 aligned_kmalloc 1 3628 NULL
94267 +x86_swiotlb_alloc_coherent_3649 x86_swiotlb_alloc_coherent 2 3649 NULL nohasharray
94268 +cm_copy_private_data_3649 cm_copy_private_data 2 3649 &x86_swiotlb_alloc_coherent_3649
94269 +ath6kl_disconnect_timeout_read_3650 ath6kl_disconnect_timeout_read 3 3650 NULL
94270 +i915_compat_ioctl_3656 i915_compat_ioctl 2 3656 NULL
94271 +ntfs_attr_make_non_resident_3694 ntfs_attr_make_non_resident 0 3694 NULL
94272 +create_irq_3703 create_irq 0 3703 NULL nohasharray
94273 +btmrvl_psmode_write_3703 btmrvl_psmode_write 3 3703 &create_irq_3703 nohasharray
94274 +snd_m3_assp_read_3703 snd_m3_assp_read 0 3703 &btmrvl_psmode_write_3703
94275 +videobuf_pages_to_sg_3708 videobuf_pages_to_sg 2 3708 NULL
94276 +lm3533_als_get_threshold_3725 lm3533_als_get_threshold 2 3725 NULL
94277 +ci_ll_write_3740 ci_ll_write 4 3740 NULL nohasharray
94278 +ath6kl_mgmt_tx_3740 ath6kl_mgmt_tx 7 3740 &ci_ll_write_3740
94279 +sctp_setsockopt_auth_key_3793 sctp_setsockopt_auth_key 3 3793 NULL
94280 +ncp_file_write_3813 ncp_file_write 3 3813 NULL
94281 +read_file_tx_chainmask_3829 read_file_tx_chainmask 3 3829 NULL
94282 +stringify_nodemap_3842 stringify_nodemap 2 3842 NULL
94283 +ubi_eba_read_leb_3847 ubi_eba_read_leb 0 3847 NULL
94284 +create_one_cdev_3852 create_one_cdev 2 3852 NULL
94285 +smk_read_onlycap_3855 smk_read_onlycap 3 3855 NULL
94286 +get_fd_set_3866 get_fd_set 1 3866 NULL
94287 +garp_attr_create_3883 garp_attr_create 3 3883 NULL
94288 +uea_send_modem_cmd_3888 uea_send_modem_cmd 3 3888 NULL
94289 +efivarfs_file_read_3893 efivarfs_file_read 3 3893 NULL
94290 +nvram_write_3894 nvram_write 3 3894 NULL
94291 +pipeline_pre_proc_swi_read_3898 pipeline_pre_proc_swi_read 3 3898 NULL
94292 +comedi_buf_read_n_available_3899 comedi_buf_read_n_available 0 3899 NULL
94293 +vcs_write_3910 vcs_write 3 3910 NULL
94294 +atalk_compat_ioctl_3991 atalk_compat_ioctl 3 3991 NULL
94295 +do_add_counters_3992 do_add_counters 3 3992 NULL
94296 +userspace_status_4004 userspace_status 4 4004 NULL
94297 +mei_write_4005 mei_write 3 4005 NULL nohasharray
94298 +xfs_check_block_4005 xfs_check_block 4 4005 &mei_write_4005
94299 +snd_hdsp_capture_copy_4011 snd_hdsp_capture_copy 5 4011 NULL
94300 +blk_end_request_4024 blk_end_request 3 4024 NULL
94301 +ext4_xattr_find_entry_4025 ext4_xattr_find_entry 0 4025 NULL
94302 +usbnet_write_cmd_async_4035 usbnet_write_cmd_async 7 4035 NULL
94303 +read_file_queues_4078 read_file_queues 3 4078 NULL
94304 +fbcon_do_set_font_4079 fbcon_do_set_font 2-3 4079 NULL
94305 +da9052_free_irq_4090 da9052_free_irq 2 4090 NULL
94306 +tm6000_read_4151 tm6000_read 3 4151 NULL
94307 +mpt_raid_phys_disk_get_num_paths_4155 mpt_raid_phys_disk_get_num_paths 0 4155 NULL
94308 +msg_bits_4158 msg_bits 0-3-4 4158 NULL
94309 +get_alua_req_4166 get_alua_req 3 4166 NULL
94310 +blk_dropped_read_4168 blk_dropped_read 3 4168 NULL
94311 +read_file_bool_4180 read_file_bool 3 4180 NULL
94312 +f1x_determine_channel_4202 f1x_determine_channel 2 4202 NULL
94313 +_osd_req_list_objects_4204 _osd_req_list_objects 6 4204 NULL
94314 +__snd_gf1_read_addr_4210 __snd_gf1_read_addr 0 4210 NULL
94315 +ext4_new_inode_4247 ext4_new_inode 5 4247 NULL
94316 +xt_compat_add_offset_4289 xt_compat_add_offset 0 4289 NULL
94317 +__usbnet_read_cmd_4299 __usbnet_read_cmd 7 4299 NULL
94318 +dvb_ringbuffer_pkt_read_user_4303 dvb_ringbuffer_pkt_read_user 2-3-5 4303 NULL
94319 +nouveau_fifo_create__4327 nouveau_fifo_create_ 5-6 4327 NULL
94320 +snd_rawmidi_kernel_read_4328 snd_rawmidi_kernel_read 3 4328 NULL
94321 +__copy_from_user_inatomic_4365 __copy_from_user_inatomic 3 4365 NULL
94322 +sys_setdomainname_4373 sys_setdomainname 2 4373 NULL
94323 +irda_sendmsg_4388 irda_sendmsg 4 4388 NULL
94324 +access_process_vm_4412 access_process_vm 0-2-4 4412 NULL nohasharray
94325 +cxacru_cm_get_array_4412 cxacru_cm_get_array 4 4412 &access_process_vm_4412
94326 +libfc_vport_create_4415 libfc_vport_create 2 4415 NULL
94327 +do_pages_stat_4437 do_pages_stat 2 4437 NULL
94328 +at76_set_card_command_4471 at76_set_card_command 4 4471 NULL
94329 +snd_seq_expand_var_event_4481 snd_seq_expand_var_event 0-5 4481 NULL
94330 +sys_semtimedop_4486 sys_semtimedop 3 4486 NULL
94331 +vmbus_establish_gpadl_4495 vmbus_establish_gpadl 3 4495 NULL
94332 +set_link_security_4502 set_link_security 4 4502 NULL
94333 +sys_llistxattr_4532 sys_llistxattr 3 4532 NULL
94334 +da9052_group_write_4534 da9052_group_write 2-3 4534 NULL
94335 +tty_register_device_4544 tty_register_device 2 4544 NULL
94336 +videobuf_vmalloc_to_sg_4548 videobuf_vmalloc_to_sg 2 4548 NULL
94337 +btrfs_file_extent_inline_item_len_4575 btrfs_file_extent_inline_item_len 0 4575 NULL
94338 +xfs_buf_get_maps_4581 xfs_buf_get_maps 2 4581 NULL
94339 +bch_alloc_4593 bch_alloc 1 4593 NULL
94340 +iwl_dbgfs_tx_queue_read_4635 iwl_dbgfs_tx_queue_read 3 4635 NULL
94341 +skb_add_data_nocache_4682 skb_add_data_nocache 4 4682 NULL
94342 +cx18_read_pos_4683 cx18_read_pos 3 4683 NULL
94343 +short_retry_limit_read_4687 short_retry_limit_read 3 4687 NULL
94344 +kone_receive_4690 kone_receive 4 4690 NULL
94345 +round_pipe_size_4701 round_pipe_size 0 4701 NULL
94346 +cxgbi_alloc_big_mem_4707 cxgbi_alloc_big_mem 1 4707 NULL
94347 +btmrvl_gpiogap_read_4718 btmrvl_gpiogap_read 3 4718 NULL
94348 +ati_create_gatt_pages_4722 ati_create_gatt_pages 1 4722 NULL nohasharray
94349 +show_header_4722 show_header 3 4722 &ati_create_gatt_pages_4722
94350 +pwr_rcvd_bcns_cnt_read_4774 pwr_rcvd_bcns_cnt_read 3 4774 NULL
94351 +ncp__vol2io_4804 ncp__vol2io 5 4804 NULL
94352 +repair_io_failure_4815 repair_io_failure 4 4815 NULL
94353 +__iio_allocate_sw_ring_buffer_4843 __iio_allocate_sw_ring_buffer 3 4843 NULL
94354 +gigaset_if_receive_4861 gigaset_if_receive 3 4861 NULL
94355 +key_tx_spec_read_4862 key_tx_spec_read 3 4862 NULL
94356 +ocfs2_defrag_extent_4873 ocfs2_defrag_extent 3 4873 NULL
94357 +hid_register_field_4874 hid_register_field 2-3 4874 NULL
94358 +vga_arb_read_4886 vga_arb_read 3 4886 NULL
94359 +sys_ipc_4889 sys_ipc 3 4889 NULL
94360 +lp872x_write_byte_4914 lp872x_write_byte 2 4914 NULL
94361 +sys_process_vm_writev_4928 sys_process_vm_writev 3-5 4928 NULL
94362 +ntfs_rl_insert_4931 ntfs_rl_insert 2-4 4931 NULL
94363 +ieee80211_if_fmt_ave_beacon_4941 ieee80211_if_fmt_ave_beacon 3 4941 NULL
94364 +da9055_reg_write_4942 da9055_reg_write 2 4942 NULL
94365 +devm_kzalloc_4966 devm_kzalloc 2 4966 NULL
94366 +compat_rawv6_setsockopt_4967 compat_rawv6_setsockopt 5 4967 NULL
94367 +skb_network_header_len_4971 skb_network_header_len 0 4971 NULL
94368 +ieee80211_if_fmt_dot11MeshHWMPconfirmationInterval_4976 ieee80211_if_fmt_dot11MeshHWMPconfirmationInterval 3 4976 NULL
94369 +vmw_surface_define_size_4993 vmw_surface_define_size 0 4993 NULL
94370 +qla82xx_pci_mem_write_direct_5008 qla82xx_pci_mem_write_direct 2 5008 NULL
94371 +lm3533_als_set_target_5010 lm3533_als_set_target 2-3 5010 NULL
94372 +do_mincore_5018 do_mincore 0-1 5018 NULL
94373 +mtd_device_parse_register_5024 mtd_device_parse_register 5 5024 NULL
94374 +ocfs2_check_range_for_holes_5066 ocfs2_check_range_for_holes 2-3 5066 NULL
94375 +snd_mixart_BA1_read_5082 snd_mixart_BA1_read 5 5082 NULL
94376 +snd_emu10k1_ptr20_read_5087 snd_emu10k1_ptr20_read 0 5087 NULL
94377 +get_random_bytes_5091 get_random_bytes 2 5091 NULL nohasharray
94378 +kfifo_copy_from_user_5091 kfifo_copy_from_user 3 5091 &get_random_bytes_5091 nohasharray
94379 +blk_rq_sectors_5091 blk_rq_sectors 0 5091 &kfifo_copy_from_user_5091
94380 +mpol_to_str_5093 mpol_to_str 2 5093 NULL
94381 +sound_write_5102 sound_write 3 5102 NULL
94382 +ufs_add_fragments_5144 ufs_add_fragments 2 5144 NULL
94383 +compat_ptr_5159 compat_ptr 0-1 5159 NULL
94384 +__uwb_addr_print_5161 __uwb_addr_print 2 5161 NULL
94385 +iwl_dbgfs_status_read_5171 iwl_dbgfs_status_read 3 5171 NULL
94386 +acpi_pcc_get_sqty_5176 acpi_pcc_get_sqty 0 5176 NULL
94387 +sfi_map_memory_5183 sfi_map_memory 1-2 5183 NULL
94388 +skb_network_header_5203 skb_network_header 0 5203 NULL
94389 +pipe_set_size_5204 pipe_set_size 2 5204 NULL
94390 +ppp_cp_parse_cr_5214 ppp_cp_parse_cr 4 5214 NULL
94391 +ath6kl_debug_roam_tbl_event_5224 ath6kl_debug_roam_tbl_event 3 5224 NULL
94392 +ssb_ioremap_5228 ssb_ioremap 2 5228 NULL
94393 +isdn_ppp_skb_push_5236 isdn_ppp_skb_push 2 5236 NULL
94394 +do_atmif_sioc_5247 do_atmif_sioc 3 5247 NULL
94395 +pwr_elp_enter_read_5324 pwr_elp_enter_read 3 5324 NULL
94396 +allocate_cnodes_5329 allocate_cnodes 1 5329 NULL
94397 +ps_pspoll_utilization_read_5361 ps_pspoll_utilization_read 3 5361 NULL
94398 +cciss_allocate_sg_chain_blocks_5368 cciss_allocate_sg_chain_blocks 3-2 5368 NULL
94399 +bitmap_fold_5396 bitmap_fold 4 5396 NULL
94400 +nilfs_palloc_entries_per_group_5418 nilfs_palloc_entries_per_group 0 5418 NULL
94401 +sfi_map_table_5462 sfi_map_table 1 5462 NULL
94402 +xfs_efd_init_5463 xfs_efd_init 3 5463 NULL
94403 +xfs_efi_init_5476 xfs_efi_init 2 5476 NULL
94404 +ubi_leb_write_5478 ubi_leb_write 4-5 5478 NULL
94405 +cifs_security_flags_proc_write_5484 cifs_security_flags_proc_write 3 5484 NULL
94406 +tty_write_5494 tty_write 3 5494 NULL
94407 +tomoyo_update_domain_5498 tomoyo_update_domain 2 5498 NULL nohasharray
94408 +ieee80211_if_fmt_last_beacon_5498 ieee80211_if_fmt_last_beacon 3 5498 &tomoyo_update_domain_5498
94409 +__max_nr_grant_frames_5505 __max_nr_grant_frames 0 5505 NULL
94410 +spidev_message_5518 spidev_message 3 5518 NULL
94411 +ieee80211_if_fmt_auto_open_plinks_5534 ieee80211_if_fmt_auto_open_plinks 3 5534 NULL
94412 +brcmu_pkt_buf_get_skb_5556 brcmu_pkt_buf_get_skb 1 5556 NULL
94413 +le_readq_5557 le_readq 0 5557 NULL
94414 +inw_5558 inw 0 5558 NULL
94415 +__first_dma_cap_5560 __first_dma_cap 0 5560 NULL
94416 +fir16_create_5574 fir16_create 3 5574 NULL
94417 +bioset_create_5580 bioset_create 1 5580 NULL
94418 +oz_ep_alloc_5587 oz_ep_alloc 2 5587 NULL
94419 +do_msgrcv_5590 do_msgrcv 4 5590 NULL
94420 +usb_dump_device_descriptor_5599 usb_dump_device_descriptor 0 5599 NULL
94421 +ldm_frag_add_5611 ldm_frag_add 2 5611 NULL
94422 +compat_copy_entries_5617 compat_copy_entries 0 5617 NULL
94423 +ext4_xattr_get_5661 ext4_xattr_get 0 5661 NULL
94424 +posix_clock_register_5662 posix_clock_register 2 5662 NULL
94425 +mthca_map_reg_5664 mthca_map_reg 2-3 5664 NULL
94426 +__videobuf_alloc_vb_5665 __videobuf_alloc_vb 1 5665 NULL
94427 +get_arg_5694 get_arg 3 5694 NULL
94428 +vmw_kms_readback_5727 vmw_kms_readback 6 5727 NULL
94429 +rts51x_transfer_data_partial_5735 rts51x_transfer_data_partial 6 5735 NULL
94430 +ubi_cdev_compat_ioctl_5746 ubi_cdev_compat_ioctl 3 5746 NULL
94431 +sctp_setsockopt_autoclose_5775 sctp_setsockopt_autoclose 3 5775 NULL
94432 +compat_sys_writev_5784 compat_sys_writev 3 5784 NULL
94433 +__vxge_hw_blockpool_malloc_5786 __vxge_hw_blockpool_malloc 2 5786 NULL
94434 +skb_copy_datagram_iovec_5806 skb_copy_datagram_iovec 2-4 5806 NULL
94435 +nv50_disp_pioc_create__5812 nv50_disp_pioc_create_ 5 5812 NULL
94436 +ceph_x_encrypt_buflen_5829 ceph_x_encrypt_buflen 0-1 5829 NULL
94437 +autofs4_root_compat_ioctl_5838 autofs4_root_compat_ioctl 3 5838 NULL
94438 +ceph_msg_new_5846 ceph_msg_new 2 5846 NULL
94439 +ixgb_check_copybreak_5847 ixgb_check_copybreak 3 5847 NULL
94440 +setup_req_5848 setup_req 3 5848 NULL
94441 +rx_filter_max_arp_queue_dep_read_5851 rx_filter_max_arp_queue_dep_read 3 5851 NULL
94442 +compat_sys_move_pages_5861 compat_sys_move_pages 2 5861 NULL nohasharray
94443 +uinput_compat_ioctl_5861 uinput_compat_ioctl 3 5861 &compat_sys_move_pages_5861
94444 +port_show_regs_5904 port_show_regs 3 5904 NULL
94445 +rbd_segment_length_5907 rbd_segment_length 0-3-2 5907 NULL
94446 +uhci_debug_read_5911 uhci_debug_read 3 5911 NULL
94447 +qla82xx_pci_mem_read_2M_5912 qla82xx_pci_mem_read_2M 2 5912 NULL
94448 +ttm_bo_kmap_ttm_5922 ttm_bo_kmap_ttm 3 5922 NULL
94449 +lbs_highsnr_read_5931 lbs_highsnr_read 3 5931 NULL
94450 +ps_poll_ps_poll_timeouts_read_5934 ps_poll_ps_poll_timeouts_read 3 5934 NULL
94451 +edac_device_alloc_ctl_info_5941 edac_device_alloc_ctl_info 1 5941 NULL
94452 +tipc_subseq_alloc_5957 tipc_subseq_alloc 1 5957 NULL
94453 +__apu_get_register_5967 __apu_get_register 0 5967 NULL
94454 +ieee80211_if_fmt_rc_rateidx_mask_5ghz_5971 ieee80211_if_fmt_rc_rateidx_mask_5ghz 3 5971 NULL
94455 +ntfs_rl_append_6037 ntfs_rl_append 2-4 6037 NULL
94456 +da9052_request_irq_6058 da9052_request_irq 2 6058 NULL
94457 +sctp_setsockopt_connectx_6073 sctp_setsockopt_connectx 3 6073 NULL
94458 +rts51x_ms_rw_multi_sector_6076 rts51x_ms_rw_multi_sector 3-4 6076 NULL
94459 +ipmi_addr_length_6110 ipmi_addr_length 0 6110 NULL
94460 +dfs_global_file_write_6112 dfs_global_file_write 3 6112 NULL
94461 +matrix_keypad_build_keymap_6129 matrix_keypad_build_keymap 3 6129 NULL
94462 +nouveau_parent_create__6131 nouveau_parent_create_ 7 6131 NULL
94463 +ivtv_copy_buf_to_user_6159 ivtv_copy_buf_to_user 4 6159 NULL
94464 +vdma_mem_alloc_6171 vdma_mem_alloc 1 6171 NULL
94465 +wl1251_cmd_template_set_6172 wl1251_cmd_template_set 4 6172 NULL
94466 +mxt_show_instance_6207 mxt_show_instance 2-0 6207 NULL
94467 +v4l2_ctrl_new_std_menu_6221 v4l2_ctrl_new_std_menu 4 6221 NULL
94468 +mqueue_read_file_6228 mqueue_read_file 3 6228 NULL
94469 +f_hidg_read_6238 f_hidg_read 3 6238 NULL
94470 +fbcon_prepare_logo_6246 fbcon_prepare_logo 5 6246 NULL
94471 +pcpu_next_pop_6277 pcpu_next_pop 4 6277 NULL
94472 +tx_tx_start_null_frame_read_6281 tx_tx_start_null_frame_read 3 6281 NULL
94473 +snd_hda_override_conn_list_6282 snd_hda_override_conn_list 0 6282 NULL nohasharray
94474 +xenbus_file_write_6282 xenbus_file_write 3 6282 &snd_hda_override_conn_list_6282
94475 +posix_acl_fix_xattr_to_user_6283 posix_acl_fix_xattr_to_user 2 6283 NULL
94476 +nf_nat_ipv6_manip_pkt_6289 nf_nat_ipv6_manip_pkt 2 6289 NULL
94477 +nf_nat_sack_adjust_6297 nf_nat_sack_adjust 2 6297 NULL
94478 +mid_get_vbt_data_r10_6308 mid_get_vbt_data_r10 2 6308 NULL
94479 +_proc_do_string_6376 _proc_do_string 2 6376 NULL
94480 +osd_req_read_sg_kern_6378 osd_req_read_sg_kern 5 6378 NULL
94481 +posix_acl_fix_xattr_userns_6420 posix_acl_fix_xattr_userns 4 6420 NULL
94482 +ipr_change_queue_depth_6431 ipr_change_queue_depth 2 6431 NULL
94483 +__alloc_bootmem_node_nopanic_6432 __alloc_bootmem_node_nopanic 2 6432 NULL
94484 +ext4_compat_ioctl_6471 ext4_compat_ioctl 3 6471 NULL
94485 +ieee80211_if_fmt_dot11MeshMaxRetries_6476 ieee80211_if_fmt_dot11MeshMaxRetries 3 6476 NULL
94486 +cipso_v4_map_lvl_hton_6490 cipso_v4_map_lvl_hton 0 6490 NULL
94487 +dbg_intr_buf_6501 dbg_intr_buf 2 6501 NULL
94488 +mei_read_6507 mei_read 3 6507 NULL
94489 +cpumask_next_and_6516 cpumask_next_and 1 6516 NULL
94490 +read_file_disable_ani_6536 read_file_disable_ani 3 6536 NULL
94491 +rndis_set_oid_6547 rndis_set_oid 4 6547 NULL
94492 +wdm_read_6549 wdm_read 3 6549 NULL
94493 +fb_alloc_cmap_6554 fb_alloc_cmap 2 6554 NULL
94494 +usb_dump_config_descriptor_6572 usb_dump_config_descriptor 0 6572 NULL
94495 +snd_pcm_hw_refine_old_user_6586 snd_pcm_hw_refine_old_user 0 6586 NULL
94496 +usemap_size_6601 usemap_size 0-1 6601 NULL
94497 +snmp_mib_init_6604 snmp_mib_init 2-3 6604 NULL
94498 +ecryptfs_filldir_6622 ecryptfs_filldir 3 6622 NULL
94499 +virtscsi_alloc_tgt_6643 virtscsi_alloc_tgt 2 6643 NULL
94500 +aac_srcv_ioremap_6659 aac_srcv_ioremap 2 6659 NULL
94501 +process_rcvd_data_6679 process_rcvd_data 3 6679 NULL
94502 +ql_process_mac_rx_skb_6689 ql_process_mac_rx_skb 4 6689 NULL
94503 +ieee80211_build_preq_ies_6691 ieee80211_build_preq_ies 0-4 6691 NULL
94504 +btrfs_lookup_csums_range_6696 btrfs_lookup_csums_range 2 6696 NULL
94505 +ps_pspoll_max_apturn_read_6699 ps_pspoll_max_apturn_read 3 6699 NULL
94506 +bnad_debugfs_write_regrd_6706 bnad_debugfs_write_regrd 3 6706 NULL
94507 +mpeg_read_6708 mpeg_read 3 6708 NULL
94508 +video_proc_write_6724 video_proc_write 3 6724 NULL
94509 +posix_acl_xattr_count_6725 posix_acl_xattr_count 0-1 6725 NULL
94510 +rds_rdma_pages_6735 rds_rdma_pages 0 6735 NULL
94511 +sfi_check_table_6772 sfi_check_table 1 6772 NULL
94512 +iwl_dbgfs_channels_read_6784 iwl_dbgfs_channels_read 3 6784 NULL
94513 +ieee80211_if_read_6785 ieee80211_if_read 3 6785 NULL
94514 +hdlcdrv_register_6792 hdlcdrv_register 2 6792 NULL
94515 +tx_tx_done_data_read_6799 tx_tx_done_data_read 3 6799 NULL
94516 +make_8259A_irq_6828 make_8259A_irq 1 6828 NULL
94517 +calc_pages_for_6838 calc_pages_for 0-1-2 6838 NULL
94518 +mon_bin_read_6841 mon_bin_read 3 6841 NULL
94519 +snd_cs4281_BA0_read_6847 snd_cs4281_BA0_read 5 6847 NULL
94520 +ieee80211_if_fmt_path_refresh_time_6888 ieee80211_if_fmt_path_refresh_time 3 6888 NULL nohasharray
94521 +raw_seticmpfilter_6888 raw_seticmpfilter 3 6888 &ieee80211_if_fmt_path_refresh_time_6888
94522 +dlmfs_file_write_6892 dlmfs_file_write 3 6892 NULL
94523 +spi_show_regs_6911 spi_show_regs 3 6911 NULL nohasharray
94524 +proc_sessionid_read_6911 proc_sessionid_read 3 6911 &spi_show_regs_6911 nohasharray
94525 +acm_alloc_minor_6911 acm_alloc_minor 0 6911 &proc_sessionid_read_6911
94526 +__kfifo_dma_in_finish_r_6913 __kfifo_dma_in_finish_r 2-3 6913 NULL
94527 +ieee80211_rx_mgmt_probe_resp_6918 ieee80211_rx_mgmt_probe_resp 3 6918 NULL
94528 +do_msgrcv_6921 do_msgrcv 3 6921 NULL
94529 +cache_do_downcall_6926 cache_do_downcall 3 6926 NULL
94530 +qsfp_cks_6945 qsfp_cks 0-2 6945 NULL
94531 +pch_uart_hal_read_6961 pch_uart_hal_read 0 6961 NULL
94532 +videobuf_dma_init_kernel_6963 videobuf_dma_init_kernel 3 6963 NULL
94533 +rsa_extract_mpi_6973 rsa_extract_mpi 5 6973 NULL
94534 +crypto_authenc_esn_setkey_6985 crypto_authenc_esn_setkey 3 6985 NULL
94535 +request_key_async_6990 request_key_async 4 6990 NULL
94536 +r871x_set_wpa_ie_7000 r871x_set_wpa_ie 3 7000 NULL
94537 +cipso_v4_gentag_enum_7006 cipso_v4_gentag_enum 0 7006 NULL
94538 +tracing_cpumask_read_7010 tracing_cpumask_read 3 7010 NULL
94539 +wimax_msg_7030 wimax_msg 4 7030 NULL
94540 +ipath_get_base_info_7043 ipath_get_base_info 3 7043 NULL
94541 +snd_pcm_oss_bytes_7051 snd_pcm_oss_bytes 2 7051 NULL
94542 +event_enable_read_7074 event_enable_read 3 7074 NULL
94543 +beacon_interval_read_7091 beacon_interval_read 3 7091 NULL
94544 +lp_compat_ioctl_7098 lp_compat_ioctl 3 7098 NULL
94545 +pipeline_enc_rx_stat_fifo_int_read_7107 pipeline_enc_rx_stat_fifo_int_read 3 7107 NULL
94546 +check_header_7108 check_header 0 7108 NULL
94547 +__alloc_objio_seg_7203 __alloc_objio_seg 1 7203 NULL nohasharray
94548 +utf16_strsize_7203 utf16_strsize 0 7203 &__alloc_objio_seg_7203
94549 +sys32_ipc_7238 sys32_ipc 3-5-6-4 7238 NULL
94550 +get_param_h_7247 get_param_h 0 7247 NULL
94551 +vm_mmap_pgoff_7259 vm_mmap_pgoff 0 7259 NULL
94552 +dma_ops_alloc_addresses_7272 dma_ops_alloc_addresses 3-4-5 7272 NULL
94553 +rx_rate_rx_frames_per_rates_read_7282 rx_rate_rx_frames_per_rates_read 3 7282 NULL
94554 +mgmt_control_7349 mgmt_control 3 7349 NULL
94555 +ext3_free_blocks_7362 ext3_free_blocks 3-4 7362 NULL
94556 +ieee80211_if_read_dot11MeshHWMPactivePathTimeout_7368 ieee80211_if_read_dot11MeshHWMPactivePathTimeout 3 7368 NULL
94557 +hweight_long_7388 hweight_long 0-1 7388 NULL
94558 +vhost_scsi_compat_ioctl_7393 vhost_scsi_compat_ioctl 3 7393 NULL
94559 +sl_change_mtu_7396 sl_change_mtu 2 7396 NULL
94560 +readb_7401 readb 0 7401 NULL
94561 +drm_property_create_blob_7414 drm_property_create_blob 2 7414 NULL
94562 +ip_options_get_alloc_7448 ip_options_get_alloc 1 7448 NULL
94563 +ms_rw_multi_sector_7459 ms_rw_multi_sector 3-4 7459 NULL
94564 +__mutex_lock_common_7469 __mutex_lock_common 0 7469 NULL nohasharray
94565 +wm8996_gpio_direction_out_7469 wm8996_gpio_direction_out 2 7469 &__mutex_lock_common_7469
94566 +garp_request_join_7471 garp_request_join 4 7471 NULL
94567 +compat_sys_msgrcv_7482 compat_sys_msgrcv 2 7482 NULL
94568 +snd_pcm_lib_read1_7491 snd_pcm_lib_read1 0-3 7491 NULL
94569 +sdhci_alloc_host_7509 sdhci_alloc_host 2 7509 NULL nohasharray
94570 +ahash_instance_headroom_7509 ahash_instance_headroom 0 7509 &sdhci_alloc_host_7509
94571 +array_zalloc_7519 array_zalloc 1-2 7519 NULL
94572 +setup_usemap_7524 setup_usemap 3 7524 NULL
94573 +goal_in_my_reservation_7553 goal_in_my_reservation 3 7553 NULL
94574 +smk_read_mapped_7562 smk_read_mapped 3 7562 NULL
94575 +ext3_try_to_allocate_7590 ext3_try_to_allocate 5-3 7590 NULL
94576 +groups_alloc_7614 groups_alloc 1 7614 NULL
94577 +sg_virt_7616 sg_virt 0 7616 NULL
94578 +cpumask_first_7648 cpumask_first 0 7648 NULL
94579 +skb_copy_expand_7685 skb_copy_expand 2-3 7685 NULL nohasharray
94580 +acpi_ex_allocate_name_string_7685 acpi_ex_allocate_name_string 2-1 7685 &skb_copy_expand_7685
94581 +acpi_ns_get_pathname_length_7699 acpi_ns_get_pathname_length 0 7699 NULL
94582 +dev_write_7708 dev_write 3 7708 NULL
94583 +tps65090_set_bits_7709 tps65090_set_bits 2 7709 NULL
94584 +brcmf_sdcard_send_buf_7713 brcmf_sdcard_send_buf 6 7713 NULL nohasharray
94585 +dbg_check_cats_7713 dbg_check_cats 0 7713 &brcmf_sdcard_send_buf_7713
94586 +set_bypass_pwup_pfs_7742 set_bypass_pwup_pfs 3 7742 NULL
94587 +vxge_device_register_7752 vxge_device_register 4 7752 NULL
94588 +osdv2_attr_list_elem_size_7763 osdv2_attr_list_elem_size 0-1 7763 NULL
94589 +ubi_io_read_vid_hdr_7766 ubi_io_read_vid_hdr 0 7766 NULL
94590 +alloc_candev_7776 alloc_candev 1-2 7776 NULL
94591 +dfs_global_file_read_7787 dfs_global_file_read 3 7787 NULL
94592 +bnx2_nvram_write_7790 bnx2_nvram_write 4-2 7790 NULL
94593 +diva_os_copy_from_user_7792 diva_os_copy_from_user 4 7792 NULL
94594 +ubifs_leb_read_7828 ubifs_leb_read 0 7828 NULL
94595 +da9052_reg_update_7858 da9052_reg_update 2 7858 NULL
94596 +tps6586x_clr_bits_7889 tps6586x_clr_bits 2 7889 NULL
94597 +dvb_dmxdev_read_sec_7892 dvb_dmxdev_read_sec 4 7892 NULL
94598 +xfs_trans_get_efi_7898 xfs_trans_get_efi 2 7898 NULL
94599 +gfs2_tune_get_i_7903 gfs2_tune_get_i 0 7903 NULL
94600 +ext3_group_extend_7911 ext3_group_extend 3 7911 NULL
94601 +libfc_host_alloc_7917 libfc_host_alloc 2 7917 NULL
94602 +f_hidg_write_7932 f_hidg_write 3 7932 NULL
94603 +io_apic_setup_irq_pin_once_7934 io_apic_setup_irq_pin_once 1 7934 NULL
94604 +smk_write_load_self_7958 smk_write_load_self 3 7958 NULL
94605 +sys_mbind_7990 sys_mbind 5 7990 NULL
94606 +tt3650_ci_msg_locked_8013 tt3650_ci_msg_locked 4 8013 NULL
94607 +vcs_read_8017 vcs_read 3 8017 NULL
94608 +normalize_up_8037 normalize_up 0-1-2 8037 NULL
94609 +vhost_add_used_and_signal_n_8038 vhost_add_used_and_signal_n 4 8038 NULL
94610 +ms_read_multiple_pages_8052 ms_read_multiple_pages 5-4 8052 NULL
94611 +dgrp_mon_read_8065 dgrp_mon_read 3 8065 NULL
94612 +leb_read_lock_8070 leb_read_lock 0 8070 NULL
94613 +alloc_targets_8074 alloc_targets 2 8074 NULL nohasharray
94614 +qla4xxx_post_ping_evt_work_8074 qla4xxx_post_ping_evt_work 4 8074 &alloc_targets_8074
94615 +venus_lookup_8121 venus_lookup 4 8121 NULL
94616 +lm3533_als_set_threshold_8125 lm3533_als_set_threshold 2 8125 NULL
94617 +ieee80211_if_fmt_num_buffered_multicast_8127 ieee80211_if_fmt_num_buffered_multicast 3 8127 NULL
94618 +ext_sd_execute_write_data_8175 ext_sd_execute_write_data 9 8175 NULL
94619 +dma_map_area_8178 dma_map_area 5-2-3 8178 NULL
94620 +__sk_mem_schedule_8185 __sk_mem_schedule 2 8185 NULL
94621 +ieee80211_if_fmt_dot11MeshHoldingTimeout_8187 ieee80211_if_fmt_dot11MeshHoldingTimeout 3 8187 NULL
94622 +recent_mt_proc_write_8206 recent_mt_proc_write 3 8206 NULL
94623 +rt2x00debug_write_bbp_8212 rt2x00debug_write_bbp 3 8212 NULL
94624 +ad7879_spi_multi_read_8218 ad7879_spi_multi_read 3 8218 NULL
94625 +play_iframe_8219 play_iframe 3 8219 NULL
94626 +create_log_8225 create_log 2 8225 NULL nohasharray
94627 +kvm_mmu_page_set_gfn_8225 kvm_mmu_page_set_gfn 2 8225 &create_log_8225
94628 +sctp_ssnmap_size_8228 sctp_ssnmap_size 0-1-2 8228 NULL
94629 +check_xattr_ref_inode_8244 check_xattr_ref_inode 0 8244 NULL
94630 +add_rx_skb_8257 add_rx_skb 3 8257 NULL
94631 +t3_init_l2t_8261 t3_init_l2t 1 8261 NULL
94632 +init_cdev_8274 init_cdev 1 8274 NULL
94633 +rproc_recovery_write_8281 rproc_recovery_write 3 8281 NULL
94634 +qib_decode_7220_err_8315 qib_decode_7220_err 3 8315 NULL
94635 +snd_pcm_update_state_8320 snd_pcm_update_state 0 8320 NULL
94636 +lm3533_led_get_pattern_8321 lm3533_led_get_pattern 0 8321 NULL nohasharray
94637 +construct_key_and_link_8321 construct_key_and_link 4 8321 &lm3533_led_get_pattern_8321
94638 +ipwireless_send_packet_8328 ipwireless_send_packet 4 8328 NULL
94639 +tracing_entries_read_8345 tracing_entries_read 3 8345 NULL
94640 +ieee80211_if_fmt_ht_opmode_8347 ieee80211_if_fmt_ht_opmode 3 8347 NULL
94641 +ping_getfrag_8360 ping_getfrag 4-3 8360 NULL
94642 +uvc_v4l2_compat_ioctl32_8375 uvc_v4l2_compat_ioctl32 3 8375 NULL
94643 +xdi_copy_from_user_8395 xdi_copy_from_user 4 8395 NULL
94644 +zd_rf_scnprint_id_8406 zd_rf_scnprint_id 0-3 8406 NULL
94645 +uvc_v4l2_ioctl_8411 uvc_v4l2_ioctl 2 8411 NULL
94646 +snd_usb_ctl_msg_8436 snd_usb_ctl_msg 8 8436 NULL
94647 +irq_create_mapping_8437 irq_create_mapping 2 8437 NULL
94648 +afs_cell_lookup_8482 afs_cell_lookup 2 8482 NULL
94649 +_irq_to_enable_addr_8485 _irq_to_enable_addr 0-1 8485 NULL
94650 +batadv_tt_len_8502 batadv_tt_len 0-1 8502 NULL
94651 +dev_config_8506 dev_config 3 8506 NULL
94652 +ACL_to_cifs_posix_8509 ACL_to_cifs_posix 3 8509 NULL
94653 +utf16_strnlen_8513 utf16_strnlen 0 8513 NULL
94654 +opticon_process_data_packet_8524 opticon_process_data_packet 3 8524 NULL
94655 +pnp_resource_len_8532 pnp_resource_len 0 8532 NULL
94656 +alloc_pg_vec_8533 alloc_pg_vec 2 8533 NULL
94657 +ocfs2_read_virt_blocks_8538 ocfs2_read_virt_blocks 2-3 8538 NULL
94658 +profile_remove_8556 profile_remove 3 8556 NULL
94659 +cache_slow_downcall_8570 cache_slow_downcall 2 8570 NULL
94660 +mga_ioremap_8571 mga_ioremap 1-2 8571 NULL
94661 +isr_dma0_done_read_8574 isr_dma0_done_read 3 8574 NULL
94662 +tower_write_8580 tower_write 3 8580 NULL
94663 +rtllib_MFIE_rate_len_8606 rtllib_MFIE_rate_len 0 8606 NULL
94664 +shash_setkey_unaligned_8620 shash_setkey_unaligned 3 8620 NULL
94665 +it821x_firmware_command_8628 it821x_firmware_command 3 8628 NULL
94666 +scsi_dma_map_8632 scsi_dma_map 0 8632 NULL
94667 +fuse_send_write_pages_8636 fuse_send_write_pages 0 8636 NULL
94668 +generic_acl_set_8658 generic_acl_set 4 8658 NULL
94669 +dio_bio_alloc_8677 dio_bio_alloc 5 8677 NULL
94670 +lbs_bcnmiss_read_8678 lbs_bcnmiss_read 3 8678 NULL
94671 +tc3589x_gpio_irq_unmap_8680 tc3589x_gpio_irq_unmap 2 8680 NULL
94672 +rproc_trace_read_8686 rproc_trace_read 3 8686 NULL
94673 +skb_frag_size_8695 skb_frag_size 0 8695 NULL
94674 +arcfb_write_8702 arcfb_write 3 8702 NULL
94675 +i_size_read_8703 i_size_read 0 8703 NULL nohasharray
94676 +init_header_8703 init_header 0 8703 &i_size_read_8703
94677 +ctrl_out_8712 ctrl_out 3-5 8712 NULL
94678 +jffs2_acl_count_8729 jffs2_acl_count 0-1 8729 NULL nohasharray
94679 +snapshot_status_8729 snapshot_status 5 8729 &jffs2_acl_count_8729
94680 +f_dupfd_8730 f_dupfd 1 8730 NULL
94681 +tx_tx_exch_expiry_read_8749 tx_tx_exch_expiry_read 3 8749 NULL
94682 +joydev_compat_ioctl_8765 joydev_compat_ioctl 2 8765 NULL
94683 +sys_prctl_8766 sys_prctl 4 8766 NULL
94684 +x32_arch_ptrace_8767 x32_arch_ptrace 3-4 8767 NULL
94685 +paging32_prefetch_gpte_8783 paging32_prefetch_gpte 4 8783 NULL
94686 +ext4_try_to_write_inline_data_8785 ext4_try_to_write_inline_data 3-4 8785 NULL
94687 +__bitmap_weight_8796 __bitmap_weight 0-2 8796 NULL
94688 +cpuset_common_file_read_8800 cpuset_common_file_read 5 8800 NULL
94689 +metronomefb_write_8823 metronomefb_write 3 8823 NULL
94690 +icmpv6_manip_pkt_8833 icmpv6_manip_pkt 4 8833 NULL nohasharray
94691 +get_queue_depth_8833 get_queue_depth 0 8833 &icmpv6_manip_pkt_8833
94692 +dvb_ringbuffer_pkt_next_8834 dvb_ringbuffer_pkt_next 0-2 8834 NULL
94693 +usb_ep_queue_8839 usb_ep_queue 0 8839 NULL
94694 +debug_debug1_read_8856 debug_debug1_read 3 8856 NULL
94695 +wa_nep_queue_8858 wa_nep_queue 2 8858 NULL
94696 +send_pages_8872 send_pages 3 8872 NULL
94697 +compressed_bio_size_8887 compressed_bio_size 0-2 8887 NULL
94698 +tracing_max_lat_read_8890 tracing_max_lat_read 3 8890 NULL
94699 +sdio_max_byte_size_8907 sdio_max_byte_size 0 8907 NULL
94700 +layout_commit_8926 layout_commit 3 8926 NULL
94701 +adjust_priv_size_8935 adjust_priv_size 0-1 8935 NULL
94702 +driver_stats_read_8944 driver_stats_read 3 8944 NULL
94703 +read_file_tgt_stats_8959 read_file_tgt_stats 3 8959 NULL
94704 +seq_bitmap_list_8963 seq_bitmap_list 3 8963 NULL
94705 +usb_allocate_stream_buffers_8964 usb_allocate_stream_buffers 3 8964 NULL
94706 +qib_qsfp_dump_8966 qib_qsfp_dump 0-3 8966 NULL
94707 +venus_mkdir_8967 venus_mkdir 4 8967 NULL
94708 +seq_open_net_8968 seq_open_net 4 8968 NULL nohasharray
94709 +vol_cdev_read_8968 vol_cdev_read 3 8968 &seq_open_net_8968
94710 +bio_integrity_get_tag_8974 bio_integrity_get_tag 3 8974 NULL
94711 +btrfs_alloc_free_block_8986 btrfs_alloc_free_block 3 8986 NULL
94712 +palmas_ldo_write_9012 palmas_ldo_write 2 9012 NULL
94713 +snd_emu10k1_ptr_read_9026 snd_emu10k1_ptr_read 0-2 9026 NULL
94714 +__pskb_copy_9038 __pskb_copy 2 9038 NULL
94715 +nla_put_9042 nla_put 3 9042 NULL
94716 +snd_emu10k1_synth_copy_from_user_9061 snd_emu10k1_synth_copy_from_user 3-5 9061 NULL
94717 +snd_gus_dram_peek_9062 snd_gus_dram_peek 4 9062 NULL
94718 +fib_info_hash_alloc_9075 fib_info_hash_alloc 1 9075 NULL
94719 +string_9080 string 0 9080 NULL
94720 +create_queues_9088 create_queues 2-3 9088 NULL
94721 +ftdi_prepare_write_buffer_9093 ftdi_prepare_write_buffer 3 9093 NULL
94722 +caif_stream_sendmsg_9110 caif_stream_sendmsg 4 9110 NULL nohasharray
94723 +gfn_to_rmap_9110 gfn_to_rmap 2-3 9110 &caif_stream_sendmsg_9110
94724 +pmcraid_change_queue_depth_9116 pmcraid_change_queue_depth 2 9116 NULL
94725 +ext4_list_backups_9138 ext4_list_backups 0 9138 NULL
94726 +dbg_command_buf_9165 dbg_command_buf 2 9165 NULL
94727 +isr_irqs_read_9181 isr_irqs_read 3 9181 NULL
94728 +count_leading_zeros_9183 count_leading_zeros 0 9183 NULL
94729 +alloc_group_attrs_9194 alloc_group_attrs 2 9194 NULL nohasharray
94730 +altera_swap_ir_9194 altera_swap_ir 2 9194 &alloc_group_attrs_9194
94731 +gx1_gx_base_9198 gx1_gx_base 0 9198 NULL
94732 +snd_m3_get_pointer_9206 snd_m3_get_pointer 0 9206 NULL
94733 +tx_tx_prepared_descs_read_9221 tx_tx_prepared_descs_read 3 9221 NULL
94734 +sctp_getsockopt_delayed_ack_9232 sctp_getsockopt_delayed_ack 2 9232 NULL
94735 +ocfs2_clear_ext_refcount_9256 ocfs2_clear_ext_refcount 4 9256 NULL
94736 +tcf_csum_ipv4_icmp_9258 tcf_csum_ipv4_icmp 3 9258 NULL
94737 +sparse_early_usemaps_alloc_node_9269 sparse_early_usemaps_alloc_node 4 9269 NULL
94738 +hdpvr_read_9273 hdpvr_read 3 9273 NULL
94739 +qla82xx_pci_set_window_9303 qla82xx_pci_set_window 0-2 9303 NULL
94740 +iwl_dbgfs_stations_read_9309 iwl_dbgfs_stations_read 3 9309 NULL
94741 +ceph_sync_setxattr_9310 ceph_sync_setxattr 4 9310 NULL
94742 +ieee80211_if_fmt_txpower_9334 ieee80211_if_fmt_txpower 3 9334 NULL
94743 +ocfs2_orphan_for_truncate_9342 ocfs2_orphan_for_truncate 4 9342 NULL
94744 +read_9397 read 3 9397 NULL
94745 +nf_nat_sip_expect_9418 nf_nat_sip_expect 8 9418 NULL
94746 +cfg80211_report_obss_beacon_9422 cfg80211_report_obss_beacon 3 9422 NULL
94747 +bm_realloc_pages_9431 bm_realloc_pages 2 9431 NULL
94748 +ffs_ep0_write_9438 ffs_ep0_write 3 9438 NULL
94749 +kmalloc_array_9444 kmalloc_array 1-2 9444 NULL
94750 +ieee80211_if_fmt_fwded_unicast_9454 ieee80211_if_fmt_fwded_unicast 3 9454 NULL
94751 +mcs_unwrap_mir_9455 mcs_unwrap_mir 3 9455 NULL
94752 +ext3_xattr_set_acl_9467 ext3_xattr_set_acl 4 9467 NULL
94753 +agp_generic_alloc_user_9470 agp_generic_alloc_user 1 9470 NULL
94754 +rbd_coll_end_req_9472 rbd_coll_end_req 3 9472 NULL
94755 +__alloc_preds_9492 __alloc_preds 2 9492 NULL
94756 +lp_write_9511 lp_write 3 9511 NULL
94757 +scsi_tgt_kspace_exec_9522 scsi_tgt_kspace_exec 8 9522 NULL
94758 +lm3533_update_9529 lm3533_update 2 9529 NULL
94759 +read_file_dma_9530 read_file_dma 3 9530 NULL
94760 +ext3_alloc_branch_9534 ext3_alloc_branch 5 9534 NULL
94761 +tps65910_gpio_output_9539 tps65910_gpio_output 2 9539 NULL
94762 +audit_log_n_untrustedstring_9548 audit_log_n_untrustedstring 3 9548 NULL
94763 +readl_9557 readl 0 9557 NULL
94764 +fw_node_create_9559 fw_node_create 2 9559 NULL
94765 +kobj_map_9566 kobj_map 2-3 9566 NULL
94766 +f2fs_read_data_pages_9574 f2fs_read_data_pages 4 9574 NULL
94767 +biovec_create_pools_9575 biovec_create_pools 2 9575 NULL
94768 +ieee80211_tdls_mgmt_9581 ieee80211_tdls_mgmt 8 9581 NULL
94769 +do_sync_9604 do_sync 1 9604 NULL
94770 +snd_emu10k1_fx8010_read_9605 snd_emu10k1_fx8010_read 5-6 9605 NULL
94771 +saa7164_buffer_alloc_user_9627 saa7164_buffer_alloc_user 2 9627 NULL
94772 +compat_sys_keyctl_9639 compat_sys_keyctl 4-2-3 9639 NULL
94773 +ocfs2_xattr_get_rec_9652 ocfs2_xattr_get_rec 0 9652 NULL
94774 +uvc_alloc_buffers_9656 uvc_alloc_buffers 2-3 9656 NULL
94775 +queue_received_packet_9657 queue_received_packet 5 9657 NULL
94776 +snd_opl4_mem_proc_write_9670 snd_opl4_mem_proc_write 5 9670 NULL
94777 +ks8842_read16_9676 ks8842_read16 0 9676 NULL nohasharray
94778 +dns_query_9676 dns_query 3 9676 &ks8842_read16_9676
94779 +qib_7322_handle_hwerrors_9678 qib_7322_handle_hwerrors 3 9678 NULL
94780 +__erst_read_from_storage_9690 __erst_read_from_storage 0 9690 NULL
94781 +is_hole_9694 is_hole 2 9694 NULL nohasharray
94782 +x25_asy_compat_ioctl_9694 x25_asy_compat_ioctl 4 9694 &is_hole_9694
94783 +fnb_9703 fnb 2-3 9703 NULL
94784 +ieee80211_if_read_aid_9705 ieee80211_if_read_aid 3 9705 NULL
94785 +ieee80211_if_fmt_num_mcast_sta_9738 ieee80211_if_fmt_num_mcast_sta 3 9738 NULL
94786 +ddb_input_read_9743 ddb_input_read 3 9743 NULL
94787 +sta_last_ack_signal_read_9751 sta_last_ack_signal_read 3 9751 NULL
94788 +btrfs_super_root_9763 btrfs_super_root 0 9763 NULL
94789 +__alloc_percpu_9764 __alloc_percpu 1-2 9764 NULL
94790 +do_sigpending_9766 do_sigpending 2 9766 NULL
94791 +__blk_queue_init_tags_9778 __blk_queue_init_tags 2 9778 NULL
94792 +snd_mem_proc_write_9786 snd_mem_proc_write 3 9786 NULL
94793 +_regmap_write_9803 _regmap_write 2 9803 NULL
94794 +ttm_bo_fbdev_io_9805 ttm_bo_fbdev_io 4 9805 NULL
94795 +ieee80211_if_read_state_9813 ieee80211_if_read_state 3 9813 NULL
94796 +pnp_mem_start_9817 pnp_mem_start 0 9817 NULL
94797 +kernel_physical_mapping_init_9818 kernel_physical_mapping_init 0-2-1 9818 NULL
94798 +dvb_dvr_set_buffer_size_9840 dvb_dvr_set_buffer_size 2 9840 NULL
94799 +cfg80211_send_deauth_9862 cfg80211_send_deauth 3 9862 NULL
94800 +pmcraid_alloc_sglist_9864 pmcraid_alloc_sglist 1 9864 NULL
94801 +btrfs_free_reserved_extent_9867 btrfs_free_reserved_extent 2 9867 NULL
94802 +f1x_translate_sysaddr_to_cs_9868 f1x_translate_sysaddr_to_cs 2 9868 NULL
94803 +mlx4_bitmap_alloc_range_9876 mlx4_bitmap_alloc_range 2-3 9876 NULL
94804 +wil_read_file_ioblob_9878 wil_read_file_ioblob 3 9878 NULL
94805 +bm_register_write_9893 bm_register_write 3 9893 NULL nohasharray
94806 +snd_midi_event_new_9893 snd_midi_event_new 1 9893 &bm_register_write_9893
94807 +snd_gf1_pcm_playback_copy_9895 snd_gf1_pcm_playback_copy 3-5 9895 NULL
94808 +receive_DataRequest_9904 receive_DataRequest 3 9904 NULL
94809 +nonpaging_page_fault_9908 nonpaging_page_fault 2 9908 NULL
94810 +pstore_ftrace_knob_read_9947 pstore_ftrace_knob_read 3 9947 NULL
94811 +read_file_misc_9948 read_file_misc 3 9948 NULL
94812 +set_rxd_buffer_pointer_9950 set_rxd_buffer_pointer 8 9950 NULL
94813 +ext2_new_blocks_9954 ext2_new_blocks 2 9954 NULL
94814 +csum_partial_copy_fromiovecend_9957 csum_partial_copy_fromiovecend 3-4 9957 NULL
94815 +get_free_serial_index_9969 get_free_serial_index 0 9969 NULL
94816 +btrfs_add_link_9973 btrfs_add_link 5 9973 NULL
94817 +ath6kl_usb_submit_ctrl_out_9978 ath6kl_usb_submit_ctrl_out 6 9978 NULL
94818 +twl6040_clear_bits_9985 twl6040_clear_bits 2 9985 NULL
94819 +aat2870_dump_reg_10019 aat2870_dump_reg 0 10019 NULL
94820 +handle_request_10024 handle_request 9 10024 NULL
94821 +batadv_orig_hash_add_if_10033 batadv_orig_hash_add_if 2 10033 NULL
94822 +ieee80211_probereq_get_10040 ieee80211_probereq_get 4-5 10040 NULL
94823 +rbd_coll_end_req_index_10041 rbd_coll_end_req_index 5 10041 NULL
94824 +ieee80211_set_probe_resp_10077 ieee80211_set_probe_resp 3 10077 NULL
94825 +wm831x_gpio_direction_in_10099 wm831x_gpio_direction_in 2 10099 NULL
94826 +ufs_bitmap_search_10105 ufs_bitmap_search 0-3 10105 NULL
94827 +get_elem_size_10110 get_elem_size 0-2 10110 NULL nohasharray
94828 +dynamic_ps_timeout_read_10110 dynamic_ps_timeout_read 3 10110 &get_elem_size_10110
94829 +gfs2_meta_read_10112 gfs2_meta_read 0 10112 NULL
94830 +offset_to_bit_10134 offset_to_bit 0 10134 NULL
94831 +aes_decrypt_packets_read_10155 aes_decrypt_packets_read 3 10155 NULL
94832 +rx_out_of_mem_read_10157 rx_out_of_mem_read 3 10157 NULL
94833 +hidg_alloc_ep_req_10159 hidg_alloc_ep_req 2 10159 NULL nohasharray
94834 +ol_chunk_entries_10159 ol_chunk_entries 0 10159 &hidg_alloc_ep_req_10159
94835 +stmpe_irq_unmap_10164 stmpe_irq_unmap 2 10164 NULL
94836 +asd_store_update_bios_10165 asd_store_update_bios 4 10165 NULL
94837 +proc_pid_attr_read_10173 proc_pid_attr_read 3 10173 NULL
94838 +jffs2_user_setxattr_10182 jffs2_user_setxattr 4 10182 NULL
94839 +do_ioctl_trans_10194 do_ioctl_trans 3 10194 NULL
94840 +cciss_proc_write_10259 cciss_proc_write 3 10259 NULL
94841 +snd_rme9652_capture_copy_10287 snd_rme9652_capture_copy 5 10287 NULL
94842 +ubi_leb_change_10289 ubi_leb_change 4 10289 NULL
94843 +lm3533_led_delay_set_10291 lm3533_led_delay_set 2 10291 NULL
94844 +read_emulate_10310 read_emulate 2-4 10310 NULL
94845 +ttm_object_device_init_10321 ttm_object_device_init 2 10321 NULL
94846 +ubi_leb_read_10328 ubi_leb_read 0 10328 NULL
94847 +tun_sendmsg_10337 tun_sendmsg 4 10337 NULL
94848 +ufx_alloc_urb_list_10349 ufx_alloc_urb_list 3 10349 NULL
94849 +dbAllocAny_10354 dbAllocAny 0 10354 NULL
94850 +ath6kl_listen_int_read_10355 ath6kl_listen_int_read 3 10355 NULL
94851 +ms_write_multiple_pages_10362 ms_write_multiple_pages 6-5 10362 NULL
94852 +sta_ht_capa_read_10366 sta_ht_capa_read 3 10366 NULL
94853 +ecryptfs_decode_and_decrypt_filename_10379 ecryptfs_decode_and_decrypt_filename 5 10379 NULL
94854 +do_compat_pselect_10398 do_compat_pselect 1 10398 NULL
94855 +fwtty_rx_10434 fwtty_rx 3 10434 NULL
94856 +event_phy_transmit_error_read_10471 event_phy_transmit_error_read 3 10471 NULL
94857 +ca91cx42_alloc_resource_10502 ca91cx42_alloc_resource 2 10502 NULL
94858 +qib_alloc_fast_reg_page_list_10507 qib_alloc_fast_reg_page_list 2 10507 NULL
94859 +sel_write_disable_10511 sel_write_disable 3 10511 NULL
94860 +osd_req_write_sg_kern_10514 osd_req_write_sg_kern 5 10514 NULL
94861 +rds_message_alloc_10517 rds_message_alloc 1 10517 NULL
94862 +snd_pcm_hw_params_user_10520 snd_pcm_hw_params_user 0 10520 NULL
94863 +ocfs2_add_refcounted_extent_10526 ocfs2_add_refcounted_extent 6 10526 NULL
94864 +get_vm_area_caller_10527 get_vm_area_caller 1 10527 NULL
94865 +snd_pcm_lib_read_10536 snd_pcm_lib_read 0-3 10536 NULL
94866 +ext4_write_begin_10576 ext4_write_begin 3-4 10576 NULL
94867 +scrub_remap_extent_10588 scrub_remap_extent 2 10588 NULL
94868 +otp_read_10594 otp_read 2-4-5 10594 NULL
94869 +supply_map_read_file_10608 supply_map_read_file 3 10608 NULL
94870 +mc13783_set_fmt_10616 mc13783_set_fmt 3 10616 NULL
94871 +ima_show_htable_violations_10619 ima_show_htable_violations 3 10619 NULL
94872 +alloc_coherent_10632 alloc_coherent 2 10632 NULL
94873 +nfs_idmap_lookup_id_10660 nfs_idmap_lookup_id 2 10660 NULL
94874 +parport_write_10669 parport_write 0 10669 NULL
94875 +inl_10708 inl 0 10708 NULL nohasharray
94876 +selinux_inode_setxattr_10708 selinux_inode_setxattr 4 10708 &inl_10708
94877 +pvr2_ioread_read_10720 pvr2_ioread_read 3 10720 NULL nohasharray
94878 +shash_async_setkey_10720 shash_async_setkey 3 10720 &pvr2_ioread_read_10720
94879 +spi_sync_10731 spi_sync 0 10731 NULL
94880 +sctp_getsockopt_maxseg_10737 sctp_getsockopt_maxseg 2 10737 NULL nohasharray
94881 +apu_get_register_10737 apu_get_register 0 10737 &sctp_getsockopt_maxseg_10737
94882 +compat_sys_msgsnd_10738 compat_sys_msgsnd 2 10738 NULL
94883 +sys_syslog_10746 sys_syslog 3 10746 NULL
94884 +alloc_one_pg_vec_page_10747 alloc_one_pg_vec_page 1 10747 NULL
94885 +vhost_add_used_n_10760 vhost_add_used_n 3 10760 NULL
94886 +kvm_read_guest_atomic_10765 kvm_read_guest_atomic 4 10765 NULL
94887 +sys_bind_10799 sys_bind 3 10799 NULL
94888 +compat_put_int_10828 compat_put_int 1 10828 NULL
94889 +lbs_sleepparams_read_10840 lbs_sleepparams_read 3 10840 NULL
94890 +ida_get_new_above_10853 ida_get_new_above 2 10853 NULL
94891 +fuse_conn_max_background_read_10855 fuse_conn_max_background_read 3 10855 NULL
94892 +ol_chunk_blocks_10864 ol_chunk_blocks 0 10864 NULL
94893 +batadv_check_unicast_packet_10866 batadv_check_unicast_packet 2 10866 NULL
94894 +snd_pcm_oss_write1_10872 snd_pcm_oss_write1 3 10872 NULL
94895 +mid_get_vbt_data_r0_10876 mid_get_vbt_data_r0 2 10876 NULL
94896 +bl_mark_for_commit_10879 bl_mark_for_commit 2-3 10879 NULL
94897 +get_scq_10897 get_scq 2 10897 NULL
94898 +cgroup_write_string_10900 cgroup_write_string 5 10900 NULL
94899 +tifm_alloc_adapter_10903 tifm_alloc_adapter 1 10903 NULL
94900 +__copy_from_user_10918 __copy_from_user 3 10918 NULL
94901 +da9052_map_irq_10952 da9052_map_irq 2 10952 NULL
94902 +bm_entry_read_10976 bm_entry_read 3 10976 NULL
94903 +i915_min_freq_write_10981 i915_min_freq_write 3 10981 NULL
94904 +sched_autogroup_write_10984 sched_autogroup_write 3 10984 NULL
94905 +__hci_num_ctrl_10985 __hci_num_ctrl 0 10985 NULL
94906 +xfrm_hash_alloc_10997 xfrm_hash_alloc 1 10997 NULL
94907 +rx_filter_accum_arp_pend_requests_read_11003 rx_filter_accum_arp_pend_requests_read 3 11003 NULL
94908 +SetLineNumber_11023 SetLineNumber 0 11023 NULL
94909 +mb_find_next_bit_11037 mb_find_next_bit 2-3-0 11037 NULL
94910 +nouveau_gpio_create__11048 nouveau_gpio_create_ 4 11048 NULL
94911 +tda10048_writeregbulk_11050 tda10048_writeregbulk 4 11050 NULL
94912 +carl9170_handle_mpdu_11056 carl9170_handle_mpdu 3 11056 NULL
94913 +tcp_send_mss_11079 tcp_send_mss 0 11079 NULL
94914 +snd_pcm_delay_11081 snd_pcm_delay 0 11081 NULL
94915 +count_argc_11083 count_argc 0 11083 NULL
94916 +kvm_write_guest_cached_11106 kvm_write_guest_cached 4 11106 NULL
94917 +stmpe_gpio_to_irq_11110 stmpe_gpio_to_irq 2 11110 NULL
94918 +tw_change_queue_depth_11116 tw_change_queue_depth 2 11116 NULL
94919 +page_offset_11120 page_offset 0 11120 NULL
94920 +tracing_buffers_read_11124 tracing_buffers_read 3 11124 NULL
94921 +alloc_alien_cache_11127 alloc_alien_cache 2 11127 NULL
94922 +acpi_os_map_memory_11161 acpi_os_map_memory 1-2 11161 NULL
94923 +ioat2_alloc_ring_11172 ioat2_alloc_ring 2 11172 NULL nohasharray
94924 +snd_gf1_pcm_playback_silence_11172 snd_gf1_pcm_playback_silence 3-4 11172 &ioat2_alloc_ring_11172
94925 +__swab16p_11220 __swab16p 0 11220 NULL
94926 +il_dbgfs_rx_queue_read_11221 il_dbgfs_rx_queue_read 3 11221 NULL
94927 +of_irq_count_11253 of_irq_count 0 11253 NULL
94928 +ubifs_write_node_11258 ubifs_write_node 5-3 11258 NULL
94929 +hugetlbfs_read_11268 hugetlbfs_read 3 11268 NULL
94930 +cru_detect_11272 cru_detect 1 11272 NULL
94931 +ext4_xattr_check_names_11314 ext4_xattr_check_names 0 11314 NULL
94932 +tcp_send_rcvq_11316 tcp_send_rcvq 3 11316 NULL
94933 +construct_key_11329 construct_key 3 11329 NULL nohasharray
94934 +__kfifo_out_peek_11329 __kfifo_out_peek 0-3 11329 &construct_key_11329
94935 +next_segment_11330 next_segment 0-2-1 11330 NULL
94936 +persistent_ram_buffer_map_11332 persistent_ram_buffer_map 1-2 11332 NULL
94937 +ext4_get_inline_size_11349 ext4_get_inline_size 0 11349 NULL
94938 +i915_max_freq_write_11350 i915_max_freq_write 3 11350 NULL
94939 +sel_write_create_11353 sel_write_create 3 11353 NULL
94940 +handle_unit_11355 handle_unit 0-1 11355 NULL
94941 +batadv_skb_head_push_11360 batadv_skb_head_push 2 11360 NULL
94942 +drm_vblank_init_11362 drm_vblank_init 2 11362 NULL
94943 +qib_get_base_info_11369 qib_get_base_info 3 11369 NULL
94944 +dev_irnet_write_11398 dev_irnet_write 3 11398 NULL
94945 +___alloc_bootmem_11410 ___alloc_bootmem 1 11410 NULL
94946 +str_to_user_11411 str_to_user 2 11411 NULL
94947 +mem_fw_gen_free_mem_blks_read_11413 mem_fw_gen_free_mem_blks_read 3 11413 NULL
94948 +ath6kl_wmi_test_rx_11414 ath6kl_wmi_test_rx 3 11414 NULL
94949 +adis16480_show_firmware_revision_11417 adis16480_show_firmware_revision 3 11417 NULL
94950 +trace_options_read_11419 trace_options_read 3 11419 NULL
94951 +xd_read_multiple_pages_11422 xd_read_multiple_pages 5-4 11422 NULL
94952 +prepare_image_11424 prepare_image 0 11424 NULL
94953 +vring_size_11426 vring_size 0-1-2 11426 NULL
94954 +bttv_read_11432 bttv_read 3 11432 NULL
94955 +create_zero_mask_11453 create_zero_mask 0-1 11453 NULL
94956 +swp_offset_11475 swp_offset 0 11475 NULL
94957 +sca3000_read_first_n_hw_rb_11479 sca3000_read_first_n_hw_rb 2 11479 NULL
94958 +xfs_file_buffered_aio_write_11492 xfs_file_buffered_aio_write 4 11492 NULL
94959 +sd_do_mode_sense_11507 sd_do_mode_sense 5 11507 NULL
94960 +kmem_zalloc_11510 kmem_zalloc 1 11510 NULL
94961 +twl_direction_in_11527 twl_direction_in 2 11527 NULL
94962 +setup_IO_APIC_irq_extra_11537 setup_IO_APIC_irq_extra 1 11537 NULL
94963 +skb_cow_data_11565 skb_cow_data 0-2 11565 NULL
94964 +mlx4_init_cmpt_table_11569 mlx4_init_cmpt_table 3 11569 NULL
94965 +oprofilefs_ulong_to_user_11582 oprofilefs_ulong_to_user 3 11582 NULL
94966 +snd_pcm_action_11589 snd_pcm_action 0 11589 NULL
94967 +fw_device_op_ioctl_11595 fw_device_op_ioctl 2 11595 NULL
94968 +sisusb_send_bridge_packet_11649 sisusb_send_bridge_packet 2 11649 NULL
94969 +nla_total_size_11658 nla_total_size 0-1 11658 NULL
94970 +ide_queue_pc_tail_11673 ide_queue_pc_tail 5 11673 NULL
94971 +btrfs_alloc_delayed_item_11678 btrfs_alloc_delayed_item 1 11678 NULL
94972 +da9055_gpio_direction_output_11680 da9055_gpio_direction_output 2 11680 NULL
94973 +dsp_buffer_alloc_11684 dsp_buffer_alloc 2 11684 NULL
94974 +sctp_setsockopt_hmac_ident_11687 sctp_setsockopt_hmac_ident 3 11687 NULL
94975 +split_11691 split 2 11691 NULL
94976 +snd_ctl_elem_user_tlv_11695 snd_ctl_elem_user_tlv 3 11695 NULL
94977 +blk_rq_cur_bytes_11723 blk_rq_cur_bytes 0 11723 NULL
94978 +tcf_csum_ipv6_icmp_11738 tcf_csum_ipv6_icmp 4 11738 NULL
94979 +nfsd4_get_drc_mem_11748 nfsd4_get_drc_mem 0-1-2 11748 NULL
94980 +dm_bio_prison_create_11749 dm_bio_prison_create 1 11749 NULL
94981 +iwl_dbgfs_qos_read_11753 iwl_dbgfs_qos_read 3 11753 NULL
94982 +ps_pspoll_timeouts_read_11776 ps_pspoll_timeouts_read 3 11776 NULL
94983 +ebt_buf_add_11779 ebt_buf_add 0 11779 NULL
94984 +btrfs_key_blockptr_11786 btrfs_key_blockptr 0 11786 NULL
94985 +pcpu_fc_alloc_11818 pcpu_fc_alloc 2 11818 NULL
94986 +zerocopy_sg_from_iovec_11828 zerocopy_sg_from_iovec 3 11828 NULL
94987 +sctp_setsockopt_maxseg_11829 sctp_setsockopt_maxseg 3 11829 NULL
94988 +rts51x_read_status_11830 rts51x_read_status 4 11830 NULL
94989 +unix_stream_connect_11844 unix_stream_connect 3 11844 NULL
94990 +nf_nat_sdp_media_11863 nf_nat_sdp_media 9 11863 NULL
94991 +ecryptfs_copy_filename_11868 ecryptfs_copy_filename 4 11868 NULL
94992 +kmalloc_slab_11917 kmalloc_slab 1 11917 NULL
94993 +fs_devrw_entry_11924 fs_devrw_entry 3 11924 NULL
94994 +bitmap_remap_11929 bitmap_remap 5 11929 NULL
94995 +atomic_sub_return_11939 atomic_sub_return 0-1 11939 NULL
94996 +dccp_feat_clone_sp_val_11942 dccp_feat_clone_sp_val 3 11942 NULL
94997 +kvm_set_msr_common_11953 kvm_set_msr_common 3 11953 NULL
94998 +f1x_swap_interleaved_region_11970 f1x_swap_interleaved_region 0-2 11970 NULL
94999 +atmel_read16_11981 atmel_read16 0 11981 NULL
95000 +read_and_add_raw_conns_11987 read_and_add_raw_conns 0 11987 NULL
95001 +mwifiex_cfg80211_mgmt_tx_12022 mwifiex_cfg80211_mgmt_tx 9 12022 NULL
95002 +ftdi_elan_total_command_size_12045 ftdi_elan_total_command_size 0 12045 NULL
95003 +ieee80211_if_read_user_power_level_12050 ieee80211_if_read_user_power_level 3 12050 NULL
95004 +il4965_ucode_tx_stats_read_12064 il4965_ucode_tx_stats_read 3 12064 NULL
95005 +ptc_proc_write_12076 ptc_proc_write 3 12076 NULL
95006 +ubifs_recover_log_leb_12079 ubifs_recover_log_leb 3 12079 NULL
95007 +da9052_gpio_direction_output_12120 da9052_gpio_direction_output 2 12120 NULL
95008 +alloc_bulk_urbs_generic_12127 alloc_bulk_urbs_generic 5 12127 NULL
95009 +set_powered_12129 set_powered 4 12129 NULL
95010 +nfs_writedata_alloc_12133 nfs_writedata_alloc 2 12133 NULL
95011 +ramoops_init_prz_12134 ramoops_init_prz 5 12134 NULL
95012 +xfs_handle_to_dentry_12135 xfs_handle_to_dentry 3 12135 NULL
95013 +batadv_add_packet_12136 batadv_add_packet 3 12136 NULL
95014 +rawv6_seticmpfilter_12137 rawv6_seticmpfilter 5 12137 NULL
95015 +vmw_fifo_reserve_12141 vmw_fifo_reserve 2 12141 NULL
95016 +get_idx_gc_leb_12148 get_idx_gc_leb 0 12148 NULL
95017 +btmrvl_sdio_host_to_card_12152 btmrvl_sdio_host_to_card 3 12152 NULL
95018 +vmbus_open_12154 vmbus_open 2-3 12154 NULL
95019 +wil_rxdesc_phy_length_12165 wil_rxdesc_phy_length 0 12165 NULL
95020 +dma_memcpy_to_iovec_12173 dma_memcpy_to_iovec 5 12173 NULL
95021 +ddp_make_gl_12179 ddp_make_gl 1 12179 NULL
95022 +compat_do_arpt_set_ctl_12184 compat_do_arpt_set_ctl 4 12184 NULL
95023 +ip_generic_getfrag_12187 ip_generic_getfrag 3-4 12187 NULL
95024 +bl_is_sector_init_12199 bl_is_sector_init 2 12199 NULL
95025 +receive_copy_12216 receive_copy 3 12216 NULL
95026 +snd_pcm_kernel_ioctl_12219 snd_pcm_kernel_ioctl 0 12219 NULL
95027 +aat2870_reg_read_file_12221 aat2870_reg_read_file 3 12221 NULL
95028 +ib_uverbs_unmarshall_recv_12251 ib_uverbs_unmarshall_recv 5 12251 NULL
95029 +ath_descdma_setup_12257 ath_descdma_setup 5 12257 NULL
95030 +shash_compat_setkey_12267 shash_compat_setkey 3 12267 NULL
95031 +add_sctp_bind_addr_12269 add_sctp_bind_addr 3 12269 NULL
95032 +note_last_dentry_12285 note_last_dentry 3 12285 NULL
95033 +il_dbgfs_nvm_read_12288 il_dbgfs_nvm_read 3 12288 NULL nohasharray
95034 +roundup_to_multiple_of_64_12288 roundup_to_multiple_of_64 0-1 12288 &il_dbgfs_nvm_read_12288
95035 +vxge_get_num_vfs_12302 vxge_get_num_vfs 0 12302 NULL
95036 +split_bvec_12312 split_bvec 6 12312 NULL
95037 +tipc_msg_build_12326 tipc_msg_build 4 12326 NULL
95038 +pcbit_writecmd_12332 pcbit_writecmd 2 12332 NULL
95039 +mptctl_ioctl_12355 mptctl_ioctl 2 12355 NULL
95040 +__nf_ct_ext_add_length_12364 __nf_ct_ext_add_length 3 12364 NULL
95041 +receive_packet_12367 receive_packet 2 12367 NULL
95042 +xfs_iext_inline_to_direct_12384 xfs_iext_inline_to_direct 2 12384 NULL
95043 +btrfs_file_extent_ram_bytes_12391 btrfs_file_extent_ram_bytes 0 12391 NULL
95044 +ntfs_get_size_for_mapping_pairs_12413 ntfs_get_size_for_mapping_pairs 0 12413 NULL
95045 +ieee80211_if_read_num_mcast_sta_12419 ieee80211_if_read_num_mcast_sta 3 12419 NULL
95046 +skb_do_copy_data_nocache_12465 skb_do_copy_data_nocache 5 12465 NULL
95047 +qla4_82xx_pci_mem_write_direct_12479 qla4_82xx_pci_mem_write_direct 2 12479 NULL
95048 +x25_sendmsg_12487 x25_sendmsg 4 12487 NULL
95049 +rtllib_auth_challenge_12493 rtllib_auth_challenge 3 12493 NULL
95050 +nfs_readdir_make_qstr_12509 nfs_readdir_make_qstr 3 12509 NULL
95051 +qib_alloc_fast_reg_mr_12526 qib_alloc_fast_reg_mr 2 12526 NULL
95052 +arizona_gpio_direction_out_12564 arizona_gpio_direction_out 2 12564 NULL
95053 +hvc_alloc_12579 hvc_alloc 4 12579 NULL
95054 +snd_pcm_plugin_alloc_12580 snd_pcm_plugin_alloc 2 12580 NULL
95055 +macvtap_compat_ioctl_12587 macvtap_compat_ioctl 3 12587 NULL
95056 +pcpu_extend_area_map_12589 pcpu_extend_area_map 2 12589 NULL
95057 +ipv6_get_l4proto_12600 ipv6_get_l4proto 2 12600 NULL
95058 +vhci_put_user_12604 vhci_put_user 4 12604 NULL
95059 +fc_fcp_frame_alloc_12624 fc_fcp_frame_alloc 2 12624 NULL
95060 +pwr_rcvd_awake_bcns_cnt_read_12632 pwr_rcvd_awake_bcns_cnt_read 3 12632 NULL
95061 +ctrl_cdev_compat_ioctl_12634 ctrl_cdev_compat_ioctl 3 12634 NULL
95062 +pn_sendmsg_12640 pn_sendmsg 4 12640 NULL
95063 +dwc3_link_state_write_12641 dwc3_link_state_write 3 12641 NULL
95064 +ocfs2_read_block_12659 ocfs2_read_block 0 12659 NULL
95065 +sel_read_class_12669 sel_read_class 3 12669 NULL nohasharray
95066 +sparse_mem_maps_populate_node_12669 sparse_mem_maps_populate_node 4 12669 &sel_read_class_12669
95067 +ieee80211_if_read_num_buffered_multicast_12716 ieee80211_if_read_num_buffered_multicast 3 12716 NULL
95068 +ivtv_write_12721 ivtv_write 3 12721 NULL
95069 +key_rx_spec_read_12736 key_rx_spec_read 3 12736 NULL
95070 +__videobuf_alloc_cached_12740 __videobuf_alloc_cached 1 12740 NULL
95071 +ieee80211_if_read_dot11MeshMaxRetries_12756 ieee80211_if_read_dot11MeshMaxRetries 3 12756 NULL
95072 +listxattr_12769 listxattr 3 12769 NULL
95073 +sctp_ssnmap_init_12772 sctp_ssnmap_init 2-3 12772 NULL
95074 +platform_create_bundle_12785 platform_create_bundle 4-6 12785 NULL
95075 +scsi_adjust_queue_depth_12802 scsi_adjust_queue_depth 3 12802 NULL
95076 +xfs_inumbers_fmt_12817 xfs_inumbers_fmt 3 12817 NULL
95077 +readq_12825 readq 0 12825 NULL
95078 +TSS_authhmac_12839 TSS_authhmac 3 12839 NULL
95079 +spidev_sync_12842 spidev_sync 0 12842 NULL nohasharray
95080 +ath6kl_wmi_add_wow_pattern_cmd_12842 ath6kl_wmi_add_wow_pattern_cmd 4 12842 &spidev_sync_12842
95081 +spidev_ioctl_12846 spidev_ioctl 2 12846 NULL
95082 +get_leb_cnt_12892 get_leb_cnt 0-2 12892 NULL
95083 +ocfs2_hamming_encode_block_12904 ocfs2_hamming_encode_block 2 12904 NULL
95084 +get_virtual_node_size_12908 get_virtual_node_size 0 12908 NULL
95085 +rds_pages_in_vec_12922 rds_pages_in_vec 0 12922 NULL
95086 +ci_ll_init_12930 ci_ll_init 3 12930 NULL
95087 +tps65910_reg_update_bits_12934 tps65910_reg_update_bits 2 12934 NULL
95088 +do_inode_permission_12946 do_inode_permission 0 12946 NULL
95089 +bm_status_write_12964 bm_status_write 3 12964 NULL
95090 +_drbd_md_first_sector_12984 _drbd_md_first_sector 0 12984 NULL
95091 +acpi_tb_install_table_12988 acpi_tb_install_table 1 12988 NULL
95092 +TransmitTcb_12989 TransmitTcb 4 12989 NULL
95093 +sk_peek_offset_12991 sk_peek_offset 0 12991 NULL
95094 +subsystem_filter_write_13022 subsystem_filter_write 3 13022 NULL
95095 +generic_segment_checks_13041 generic_segment_checks 0 13041 NULL
95096 +ocfs2_write_begin_13045 ocfs2_write_begin 3-4 13045 NULL
95097 +__dn_setsockopt_13060 __dn_setsockopt 5 13060 NULL
95098 +irq_set_chip_and_handler_13088 irq_set_chip_and_handler 1 13088 NULL
95099 +tps6586x_set_bits_13089 tps6586x_set_bits 2 13089 NULL
95100 +xattr_getsecurity_13090 xattr_getsecurity 0 13090 NULL
95101 +blk_rq_map_sg_13092 blk_rq_map_sg 0 13092 NULL
95102 +mb_find_next_zero_bit_13100 mb_find_next_zero_bit 2-3 13100 NULL
95103 +ubifs_compat_ioctl_13108 ubifs_compat_ioctl 3 13108 NULL
95104 +snd_rme96_playback_copy_13111 snd_rme96_playback_copy 5 13111 NULL
95105 +xen_allocate_irq_dynamic_13116 xen_allocate_irq_dynamic 0 13116 NULL
95106 +bfad_debugfs_read_13119 bfad_debugfs_read 3 13119 NULL
95107 +blk_update_request_13146 blk_update_request 3 13146 NULL
95108 +caif_stream_recvmsg_13173 caif_stream_recvmsg 4 13173 NULL
95109 +pwr_disable_ps_read_13176 pwr_disable_ps_read 3 13176 NULL
95110 +dgrp_net_ioctl_13183 dgrp_net_ioctl 2 13183 NULL
95111 +create_trace_uprobe_13184 create_trace_uprobe 1 13184 NULL
95112 +compat_put_ulong_13186 compat_put_ulong 1 13186 NULL
95113 +comedi_read_13199 comedi_read 3 13199 NULL
95114 +mmc_ext_csd_read_13205 mmc_ext_csd_read 3 13205 NULL
95115 +__nodes_fold_13215 __nodes_fold 4 13215 NULL
95116 +get_unaligned_le64_13219 get_unaligned_le64 0 13219 NULL
95117 +svm_msrpm_offset_13220 svm_msrpm_offset 0-1 13220 NULL
95118 +asix_read_cmd_13245 asix_read_cmd 5 13245 NULL
95119 +fw_download_code_13249 fw_download_code 3 13249 NULL
95120 +init_tid_tabs_13252 init_tid_tabs 2-3-4 13252 NULL
95121 +hostap_80211_get_hdrlen_13255 hostap_80211_get_hdrlen 0 13255 NULL
95122 +bio_integrity_trim_13259 bio_integrity_trim 3 13259 NULL
95123 +carl9170_rx_13272 carl9170_rx 3 13272 NULL
95124 +pmcraid_notify_aen_13274 pmcraid_notify_aen 3 13274 NULL
95125 +il4965_stats_flag_13281 il4965_stats_flag 0-3 13281 NULL
95126 +lpfc_idiag_mbxacc_get_setup_13282 lpfc_idiag_mbxacc_get_setup 0 13282 NULL
95127 +platform_device_add_resources_13289 platform_device_add_resources 3 13289 NULL
95128 +us122l_ctl_msg_13330 us122l_ctl_msg 8 13330 NULL
95129 +kvm_read_nested_guest_page_13337 kvm_read_nested_guest_page 5 13337 NULL
95130 +mthca_alloc_mtt_range_13371 mthca_alloc_mtt_range 2 13371 NULL
95131 +iso_sched_alloc_13377 iso_sched_alloc 1 13377 NULL nohasharray
95132 +wep_key_not_found_read_13377 wep_key_not_found_read 3 13377 &iso_sched_alloc_13377
95133 +carl9170_rx_untie_data_13405 carl9170_rx_untie_data 3 13405 NULL
95134 +sky2_receive_13407 sky2_receive 2 13407 NULL
95135 +netxen_alloc_sds_rings_13417 netxen_alloc_sds_rings 2 13417 NULL
95136 +keyring_read_13438 keyring_read 3 13438 NULL
95137 +sctp_setsockopt_peer_primary_addr_13440 sctp_setsockopt_peer_primary_addr 3 13440 NULL nohasharray
95138 +set_tap_pwup_pfs_13440 set_tap_pwup_pfs 3 13440 &sctp_setsockopt_peer_primary_addr_13440
95139 +ath6kl_cfg80211_connect_event_13443 ath6kl_cfg80211_connect_event 7-8-9 13443 NULL
95140 +mthca_buddy_alloc_13454 mthca_buddy_alloc 2 13454 NULL
95141 +ocfs2_align_bytes_to_blocks_13512 ocfs2_align_bytes_to_blocks 2 13512 NULL
95142 +core_status_13515 core_status 4 13515 NULL
95143 +smk_write_mapped_13519 smk_write_mapped 3 13519 NULL
95144 +bm_init_13529 bm_init 2 13529 NULL
95145 +llcp_sock_recvmsg_13556 llcp_sock_recvmsg 4 13556 NULL
95146 +ieee80211_if_read_ap_power_level_13558 ieee80211_if_read_ap_power_level 3 13558 NULL
95147 +alloc_tio_13564 alloc_tio 3 13564 NULL
95148 +ubifs_get_idx_gc_leb_13566 ubifs_get_idx_gc_leb 0 13566 NULL
95149 +read_file_antenna_13574 read_file_antenna 3 13574 NULL
95150 +pm860x_set_bits_13582 pm860x_set_bits 2 13582 NULL
95151 +cache_write_13589 cache_write 3 13589 NULL
95152 +mpt_lan_receive_post_turbo_13592 mpt_lan_receive_post_turbo 2 13592 NULL
95153 +aac_sa_ioremap_13596 aac_sa_ioremap 2 13596 NULL nohasharray
95154 +irias_new_octseq_value_13596 irias_new_octseq_value 2 13596 &aac_sa_ioremap_13596
95155 +usb_dump_interface_descriptor_13603 usb_dump_interface_descriptor 0 13603 NULL
95156 +swap_cgroup_swapon_13614 swap_cgroup_swapon 2 13614 NULL
95157 +wm8994_bulk_write_13615 wm8994_bulk_write 3-2 13615 NULL
95158 +pmcraid_get_minor_13619 pmcraid_get_minor 0 13619 NULL
95159 +iio_device_add_event_sysfs_13627 iio_device_add_event_sysfs 0 13627 NULL
95160 +packet_snd_13634 packet_snd 3 13634 NULL
95161 +blk_msg_write_13655 blk_msg_write 3 13655 NULL
95162 +cache_downcall_13666 cache_downcall 3 13666 NULL
95163 +fw_iso_buffer_alloc_13704 fw_iso_buffer_alloc 2 13704 NULL
95164 +audit_unpack_string_13748 audit_unpack_string 3 13748 NULL
95165 +ufs_dtog_13750 ufs_dtog 0-2 13750 NULL
95166 +ieee802154_alloc_device_13767 ieee802154_alloc_device 1 13767 NULL
95167 +fb_sys_read_13778 fb_sys_read 3 13778 NULL
95168 +ath6kl_mgmt_powersave_ap_13791 ath6kl_mgmt_powersave_ap 6 13791 NULL
95169 +random_read_13815 random_read 3 13815 NULL
95170 +hsi_register_board_info_13820 hsi_register_board_info 2 13820 NULL
95171 +evdev_ioctl_compat_13851 evdev_ioctl_compat 2-3 13851 NULL
95172 +compat_ip_setsockopt_13870 compat_ip_setsockopt 5 13870 NULL nohasharray
95173 +alloc_trace_uprobe_13870 alloc_trace_uprobe 3 13870 &compat_ip_setsockopt_13870
95174 +snd_pcm_aio_read_13900 snd_pcm_aio_read 3 13900 NULL
95175 +ext3_xattr_block_get_13936 ext3_xattr_block_get 0 13936 NULL
95176 +ieee80211_if_read_dot11MeshForwarding_13940 ieee80211_if_read_dot11MeshForwarding 3 13940 NULL nohasharray
95177 +ocfs2_xa_value_truncate_13940 ocfs2_xa_value_truncate 2 13940 &ieee80211_if_read_dot11MeshForwarding_13940
95178 +iwl_dbgfs_protection_mode_read_13943 iwl_dbgfs_protection_mode_read 3 13943 NULL
95179 +compat_chaninfo_13945 compat_chaninfo 2 13945 NULL
95180 +ieee80211_if_read_min_discovery_timeout_13946 ieee80211_if_read_min_discovery_timeout 3 13946 NULL
95181 +lpfc_idiag_queacc_read_13950 lpfc_idiag_queacc_read 3 13950 NULL
95182 +snd_pcm_plug_slave_size_13967 snd_pcm_plug_slave_size 0-2 13967 NULL
95183 +com90xx_found_13974 com90xx_found 3 13974 NULL
95184 +qcam_read_13977 qcam_read 3 13977 NULL
95185 +dsp_read_13980 dsp_read 2 13980 NULL
95186 +bm_block_bits_13981 bm_block_bits 0 13981 NULL nohasharray
95187 +dvb_demux_read_13981 dvb_demux_read 3 13981 &bm_block_bits_13981
95188 +ieee80211_bss_info_update_13991 ieee80211_bss_info_update 4 13991 NULL
95189 +btrfs_get_blocks_direct_14016 btrfs_get_blocks_direct 2 14016 NULL
95190 +_rtl92s_firmware_downloadcode_14021 _rtl92s_firmware_downloadcode 3 14021 NULL
95191 +dvb_usercopy_14036 dvb_usercopy 2 14036 NULL
95192 +read_def_modal_eeprom_14041 read_def_modal_eeprom 3 14041 NULL
95193 +ieee80211_if_fmt_aid_14055 ieee80211_if_fmt_aid 3 14055 NULL
95194 +sta_agg_status_read_14058 sta_agg_status_read 3 14058 NULL
95195 +do_proc_readlink_14096 do_proc_readlink 3 14096 NULL
95196 +compat_sys_pselect6_14105 compat_sys_pselect6 1 14105 NULL
95197 +nlmsg_len_14115 nlmsg_len 0 14115 NULL
95198 +vfio_fops_compat_ioctl_14130 vfio_fops_compat_ioctl 3 14130 NULL
95199 +ntfs_rl_replace_14136 ntfs_rl_replace 2-4 14136 NULL
95200 +em_canid_change_14150 em_canid_change 3 14150 NULL
95201 +gsm_dlci_data_14155 gsm_dlci_data 3 14155 NULL
95202 +print_input_mask_14168 print_input_mask 3-0 14168 NULL
95203 +ocfs2_xattr_value_truncate_14183 ocfs2_xattr_value_truncate 3 14183 NULL
95204 +alloc_async_14208 alloc_async 1 14208 NULL
95205 +sys_kexec_load_14222 sys_kexec_load 2 14222 NULL
95206 +pool_status_14230 pool_status 5 14230 NULL
95207 +ieee80211_if_write_uapsd_max_sp_len_14233 ieee80211_if_write_uapsd_max_sp_len 3 14233 NULL
95208 +inode_to_path_14235 inode_to_path 2 14235 NULL
95209 +dma_declare_coherent_memory_14244 dma_declare_coherent_memory 4-2 14244 NULL
95210 +snd_soc_hw_bulk_write_raw_14245 snd_soc_hw_bulk_write_raw 4-2 14245 NULL
95211 +reiserfs_compat_ioctl_14265 reiserfs_compat_ioctl 3 14265 NULL
95212 +ath6kl_connect_event_14267 ath6kl_connect_event 7-8-9 14267 NULL
95213 +add_numbered_child_14273 add_numbered_child 5 14273 NULL
95214 +OS_mem_token_alloc_14276 OS_mem_token_alloc 1 14276 NULL
95215 +snd_seq_oss_readq_new_14283 snd_seq_oss_readq_new 2 14283 NULL
95216 +rr_status_14293 rr_status 5 14293 NULL
95217 +lp8788_write_byte_14299 lp8788_write_byte 2 14299 NULL
95218 +read_default_ldt_14302 read_default_ldt 2 14302 NULL
95219 +oo_objects_14319 oo_objects 0 14319 NULL
95220 +p9_client_zc_rpc_14345 p9_client_zc_rpc 7 14345 NULL
95221 +snd_pcm_lib_readv_14363 snd_pcm_lib_readv 0-3 14363 NULL
95222 +acpi_get_override_irq_14381 acpi_get_override_irq 1 14381 NULL
95223 +ath6kl_regdump_read_14393 ath6kl_regdump_read 3 14393 NULL
95224 +smk_write_onlycap_14400 smk_write_onlycap 3 14400 NULL
95225 +mtd_concat_create_14416 mtd_concat_create 2 14416 NULL
95226 +get_kcore_size_14425 get_kcore_size 0 14425 NULL
95227 +check_lpt_crc_14442 check_lpt_crc 0 14442 NULL
95228 +block_size_14443 block_size 0 14443 NULL
95229 +ci13xxx_add_device_14456 ci13xxx_add_device 3 14456 NULL
95230 +snd_emu10k1_proc_spdif_status_14457 snd_emu10k1_proc_spdif_status 4-5 14457 NULL
95231 +udplite_getfrag_14479 udplite_getfrag 3-4 14479 NULL
95232 +ieee80211_if_read_dot11MeshGateAnnouncementProtocol_14486 ieee80211_if_read_dot11MeshGateAnnouncementProtocol 3 14486 NULL
95233 +stripe_status_14506 stripe_status 5 14506 NULL
95234 +ocfs2_debug_read_14507 ocfs2_debug_read 3 14507 NULL
95235 +ep0_write_14536 ep0_write 3 14536 NULL nohasharray
95236 +dataflash_read_user_otp_14536 dataflash_read_user_otp 2-3 14536 &ep0_write_14536
95237 +picolcd_debug_eeprom_read_14549 picolcd_debug_eeprom_read 3 14549 NULL
95238 +drm_vmalloc_dma_14550 drm_vmalloc_dma 1 14550 NULL
95239 +usb_dump_desc_14553 usb_dump_desc 0 14553 NULL
95240 +idmap_pipe_downcall_14591 idmap_pipe_downcall 3 14591 NULL
95241 +ocfs2_trim_group_14641 ocfs2_trim_group 4-3 14641 NULL
95242 +dbJoin_14644 dbJoin 0 14644 NULL
95243 +profile_replace_14652 profile_replace 3 14652 NULL
95244 +pipeline_enc_tx_stat_fifo_int_read_14680 pipeline_enc_tx_stat_fifo_int_read 3 14680 NULL
95245 +ieee80211_if_fmt_rc_rateidx_mask_2ghz_14683 ieee80211_if_fmt_rc_rateidx_mask_2ghz 3 14683 NULL
95246 +tsi148_master_set_14685 tsi148_master_set 4 14685 NULL
95247 +u_audio_playback_14709 u_audio_playback 3 14709 NULL
95248 +vfd_write_14717 vfd_write 3 14717 NULL
95249 +__blk_end_request_14729 __blk_end_request 3 14729 NULL
95250 +raid1_resize_14740 raid1_resize 2 14740 NULL
95251 +btrfs_inode_extref_name_len_14752 btrfs_inode_extref_name_len 0 14752 NULL
95252 +rx_rx_cmplt_read_14753 rx_rx_cmplt_read 3 14753 NULL
95253 +qla82xx_pci_mem_write_2M_14765 qla82xx_pci_mem_write_2M 2 14765 NULL
95254 +regmap_range_read_file_14775 regmap_range_read_file 3 14775 NULL
95255 +lm3533_als_get_hysteresis_14776 lm3533_als_get_hysteresis 2 14776 NULL
95256 +sta_dev_read_14782 sta_dev_read 3 14782 NULL
95257 +ext4_kvmalloc_14796 ext4_kvmalloc 1 14796 NULL
95258 +snd_als300_gcr_read_14801 snd_als300_gcr_read 0 14801 NULL nohasharray
95259 +hpet_readl_14801 hpet_readl 0 14801 &snd_als300_gcr_read_14801
95260 +bcma_scan_read32_14802 bcma_scan_read32 0 14802 NULL
95261 +do_tune_cpucache_14828 do_tune_cpucache 2 14828 NULL
95262 +__mutex_fastpath_lock_retval_14844 __mutex_fastpath_lock_retval 0 14844 NULL
95263 +lcd_write_14857 lcd_write 3 14857 NULL nohasharray
95264 +__krealloc_14857 __krealloc 2 14857 &lcd_write_14857
95265 +get_user_cpu_mask_14861 get_user_cpu_mask 2 14861 NULL
95266 +sriov_enable_migration_14889 sriov_enable_migration 2 14889 NULL
95267 +acpi_os_allocate_14892 acpi_os_allocate 1 14892 NULL
95268 +unifi_read_14899 unifi_read 3 14899 NULL
95269 +krealloc_14908 krealloc 2 14908 NULL
95270 +regmap_irq_get_virq_14910 regmap_irq_get_virq 2 14910 NULL
95271 +__arch_hweight64_14923 __arch_hweight64 0 14923 NULL
95272 +ocfs2_expand_nonsparse_inode_14936 ocfs2_expand_nonsparse_inode 3-4 14936 NULL
95273 +queue_cnt_14951 queue_cnt 0 14951 NULL
95274 +videobuf_read_stream_14956 videobuf_read_stream 3 14956 NULL
95275 +mce_flush_rx_buffer_14976 mce_flush_rx_buffer 2 14976 NULL
95276 +setkey_14987 setkey 3 14987 NULL nohasharray
95277 +gpio_twl4030_write_14987 gpio_twl4030_write 1 14987 &setkey_14987
95278 +vmap_15025 vmap 2 15025 NULL
95279 +blk_integrity_tuple_size_15027 blk_integrity_tuple_size 0 15027 NULL
95280 +irq_get_next_irq_15053 irq_get_next_irq 1 15053 NULL
95281 +cld_pipe_downcall_15058 cld_pipe_downcall 3 15058 NULL
95282 +ieee80211_if_read_uapsd_max_sp_len_15067 ieee80211_if_read_uapsd_max_sp_len 3 15067 NULL
95283 +nfs4_write_cached_acl_15070 nfs4_write_cached_acl 4 15070 NULL
95284 +ntfs_copy_from_user_15072 ntfs_copy_from_user 3-5 15072 NULL
95285 +__alloc_extent_buffer_15093 __alloc_extent_buffer 3 15093 NULL
95286 +hex_dump_to_buffer_15121 hex_dump_to_buffer 6 15121 NULL
95287 +start_port_15124 start_port 0 15124 NULL
95288 +memchr_15126 memchr 0 15126 NULL
95289 +ipwireless_ppp_mru_15153 ipwireless_ppp_mru 0 15153 NULL
95290 +self_check_not_bad_15175 self_check_not_bad 0 15175 NULL
95291 +iscsi_create_endpoint_15193 iscsi_create_endpoint 1 15193 NULL
95292 +reserve_resources_15194 reserve_resources 3 15194 NULL
95293 +bfad_debugfs_write_regrd_15218 bfad_debugfs_write_regrd 3 15218 NULL
95294 +variax_alloc_sysex_buffer_15237 variax_alloc_sysex_buffer 3 15237 NULL
95295 +il_dbgfs_rx_stats_read_15243 il_dbgfs_rx_stats_read 3 15243 NULL
95296 +compat_raw_ioctl_15290 compat_raw_ioctl 3 15290 NULL
95297 +sys_connect_15291 sys_connect 3 15291 NULL nohasharray
95298 +xlate_dev_mem_ptr_15291 xlate_dev_mem_ptr 1 15291 &sys_connect_15291
95299 +arch_enable_uv_irq_15294 arch_enable_uv_irq 2 15294 NULL
95300 +acpi_ev_create_gpe_block_15297 acpi_ev_create_gpe_block 5 15297 NULL
95301 +tpm_tis_init_15304 tpm_tis_init 2-3 15304 NULL
95302 +fcoe_ctlr_send_keep_alive_15308 fcoe_ctlr_send_keep_alive 3 15308 NULL
95303 +__ocfs2_remove_xattr_range_15330 __ocfs2_remove_xattr_range 4-5-3 15330 NULL
95304 +kovaplus_sysfs_read_15337 kovaplus_sysfs_read 6 15337 NULL
95305 +ioread16_15342 ioread16 0 15342 NULL
95306 +alloc_ring_15345 alloc_ring 2-4 15345 NULL
95307 +acpi_ut_create_string_object_15360 acpi_ut_create_string_object 1 15360 NULL
95308 +compat_sys_process_vm_readv_15374 compat_sys_process_vm_readv 3-5 15374 NULL
95309 +fq_codel_zalloc_15378 fq_codel_zalloc 1 15378 NULL
95310 +domain_flush_pages_15379 domain_flush_pages 2-3 15379 NULL
95311 +alloc_fddidev_15382 alloc_fddidev 1 15382 NULL
95312 +btrfs_level_size_15392 btrfs_level_size 0 15392 NULL
95313 +pipeline_csum_to_rx_xfer_swi_read_15403 pipeline_csum_to_rx_xfer_swi_read 3 15403 NULL
95314 +get_modalias_15406 get_modalias 2 15406 NULL
95315 +__videobuf_copy_to_user_15423 __videobuf_copy_to_user 4 15423 NULL
95316 +tcp_mtu_to_mss_15438 tcp_mtu_to_mss 0-2 15438 NULL
95317 +hpsa_change_queue_depth_15449 hpsa_change_queue_depth 2 15449 NULL
95318 +memweight_15450 memweight 2 15450 NULL
95319 +vmalloc_15464 vmalloc 1 15464 NULL
95320 +insert_old_idx_znode_15500 insert_old_idx_znode 0 15500 NULL
95321 +zd_chip_is_zd1211b_15518 zd_chip_is_zd1211b 0 15518 NULL
95322 +da9052_bat_irq_15533 da9052_bat_irq 1 15533 NULL
95323 +p9_check_zc_errors_15534 p9_check_zc_errors 4 15534 NULL
95324 +ql_process_mac_rx_page_15543 ql_process_mac_rx_page 4 15543 NULL
95325 +ieee80211_amsdu_to_8023s_15561 ieee80211_amsdu_to_8023s 5 15561 NULL
95326 +snd_pcm_channel_info_15572 snd_pcm_channel_info 0 15572 NULL
95327 +persistent_status_15574 persistent_status 4 15574 NULL
95328 +bnx2fc_process_unsol_compl_15576 bnx2fc_process_unsol_compl 2 15576 NULL
95329 +vme_user_write_15587 vme_user_write 3 15587 NULL
95330 +ocfs2_truncate_rec_15595 ocfs2_truncate_rec 7 15595 NULL
95331 +sx150x_install_irq_chip_15609 sx150x_install_irq_chip 3 15609 NULL
95332 +iommu_device_max_index_15620 iommu_device_max_index 0-3-2-1 15620 NULL nohasharray
95333 +compat_fillonedir_15620 compat_fillonedir 3 15620 &iommu_device_max_index_15620
95334 +set_dis_tap_pfs_15621 set_dis_tap_pfs 3 15621 NULL
95335 +proc_loginuid_read_15631 proc_loginuid_read 3 15631 NULL
95336 +tomoyo_scan_bprm_15642 tomoyo_scan_bprm 2-4 15642 NULL nohasharray
95337 +sk_memory_allocated_add_15642 sk_memory_allocated_add 2 15642 &tomoyo_scan_bprm_15642 nohasharray
95338 +pipeline_hs_tx_stat_fifo_int_read_15642 pipeline_hs_tx_stat_fifo_int_read 3 15642 &sk_memory_allocated_add_15642
95339 +fs_path_add_15648 fs_path_add 3 15648 NULL
95340 +xsd_read_15653 xsd_read 3 15653 NULL
95341 +compat_sys_fcntl_15654 compat_sys_fcntl 3 15654 NULL
95342 +unix_bind_15668 unix_bind 3 15668 NULL
95343 +dm_read_15674 dm_read 3 15674 NULL
95344 +pstore_mkfile_15675 pstore_mkfile 6 15675 NULL
95345 +uf_sme_queue_message_15697 uf_sme_queue_message 3 15697 NULL
95346 +ocfs2_split_tree_15716 ocfs2_split_tree 5 15716 NULL
95347 +HiSax_readstatus_15752 HiSax_readstatus 2 15752 NULL
95348 +bitmap_search_next_usable_block_15762 bitmap_search_next_usable_block 3-1 15762 NULL
95349 +do_test_15766 do_test 1 15766 NULL
95350 +set_std_nic_pfs_15792 set_std_nic_pfs 3 15792 NULL
95351 +smk_read_direct_15803 smk_read_direct 3 15803 NULL
95352 +snd_pcm_ioctl_compat_15804 snd_pcm_ioctl_compat 3 15804 NULL
95353 +gx1_read_conf_reg_15817 gx1_read_conf_reg 0 15817 NULL nohasharray
95354 +nameseq_list_15817 nameseq_list 3 15817 &gx1_read_conf_reg_15817 nohasharray
95355 +gnttab_expand_15817 gnttab_expand 1 15817 &nameseq_list_15817
95356 +afs_proc_rootcell_write_15822 afs_proc_rootcell_write 3 15822 NULL
95357 +brcmf_sdbrcm_died_dump_15841 brcmf_sdbrcm_died_dump 3 15841 NULL
95358 +table_size_15851 table_size 0-1-2 15851 NULL
95359 +ubi_io_write_15870 ubi_io_write 5-4 15870 NULL nohasharray
95360 +media_entity_init_15870 media_entity_init 2-4 15870 &ubi_io_write_15870
95361 +__mptctl_ioctl_15875 __mptctl_ioctl 2 15875 NULL
95362 +ERR_PTR_15881 ERR_PTR 0 15881 NULL
95363 +nfs_map_group_to_gid_15892 nfs_map_group_to_gid 3 15892 NULL
95364 +native_read_msr_15905 native_read_msr 0 15905 NULL
95365 +wm5100_gpio_direction_in_15934 wm5100_gpio_direction_in 2 15934 NULL
95366 +parse_audio_stream_data_15937 parse_audio_stream_data 3 15937 NULL
95367 +power_read_15939 power_read 3 15939 NULL
95368 +lpfc_idiag_drbacc_read_15948 lpfc_idiag_drbacc_read 3 15948 NULL
95369 +snd_pcm_lib_read_transfer_15952 snd_pcm_lib_read_transfer 4-2-5 15952 NULL
95370 +remap_pci_mem_15966 remap_pci_mem 1-2 15966 NULL
95371 +set_spte_15977 set_spte 7-6 15977 NULL
95372 +frame_alloc_15981 frame_alloc 4 15981 NULL
95373 +alloc_vm_area_15989 alloc_vm_area 1 15989 NULL
95374 +hdpvr_register_videodev_16010 hdpvr_register_videodev 3 16010 NULL
95375 +viafb_vt1636_proc_write_16018 viafb_vt1636_proc_write 3 16018 NULL
95376 +got_frame_16028 got_frame 2 16028 NULL
95377 +isr_tx_exch_complete_read_16103 isr_tx_exch_complete_read 3 16103 NULL
95378 +dma_tx_requested_read_16110 dma_tx_requested_read 3 16110 NULL nohasharray
95379 +isr_hw_pm_mode_changes_read_16110 isr_hw_pm_mode_changes_read 3 16110 &dma_tx_requested_read_16110
95380 +irq_set_chip_and_handler_name_16111 irq_set_chip_and_handler_name 1 16111 NULL
95381 +snd_dma_pointer_16126 snd_dma_pointer 0-2 16126 NULL
95382 +compat_sys_select_16131 compat_sys_select 1 16131 NULL
95383 +fsm_init_16134 fsm_init 2 16134 NULL
95384 +hysdn_rx_netpkt_16136 hysdn_rx_netpkt 3 16136 NULL
95385 +ext4_xattr_block_get_16148 ext4_xattr_block_get 0 16148 NULL
95386 +bnx2i_get_cid_num_16166 bnx2i_get_cid_num 0 16166 NULL
95387 +mapping_level_16188 mapping_level 2 16188 NULL
95388 +cipso_v4_map_cat_rng_hton_16203 cipso_v4_map_cat_rng_hton 0 16203 NULL
95389 +create_table_16213 create_table 2 16213 NULL
95390 +atomic_read_file_16227 atomic_read_file 3 16227 NULL
95391 +BcmGetSectionValStartOffset_16235 BcmGetSectionValStartOffset 0 16235 NULL
95392 +btrfs_dev_extent_chunk_offset_16247 btrfs_dev_extent_chunk_offset 0 16247 NULL
95393 +mark_written_sectors_16262 mark_written_sectors 2 16262 NULL
95394 +reiserfs_acl_count_16265 reiserfs_acl_count 0-1 16265 NULL
95395 +set_disc_pfs_16270 set_disc_pfs 3 16270 NULL
95396 +ocfs2_xattr_bucket_value_truncate_16279 ocfs2_xattr_bucket_value_truncate 4 16279 NULL
95397 +drbd_setsockopt_16280 drbd_setsockopt 5 16280 NULL nohasharray
95398 +nand_bch_init_16280 nand_bch_init 3-2 16280 &drbd_setsockopt_16280
95399 +account_16283 account 0-2-4 16283 NULL
95400 +stk_allocate_buffers_16291 stk_allocate_buffers 2 16291 NULL
95401 +rbd_segment_offset_16293 rbd_segment_offset 0-2 16293 NULL
95402 +rsc_mgr_init_16299 rsc_mgr_init 3 16299 NULL
95403 +vmw_cursor_update_image_16332 vmw_cursor_update_image 3-4 16332 NULL
95404 +tps80031_update_16360 tps80031_update 3 16360 NULL
95405 +total_ps_buffered_read_16365 total_ps_buffered_read 3 16365 NULL
95406 +rbd_add_16366 rbd_add 3 16366 NULL
95407 +iscsi_tcp_conn_setup_16376 iscsi_tcp_conn_setup 2 16376 NULL
95408 +nl80211_send_unprot_deauth_16378 nl80211_send_unprot_deauth 4 16378 NULL
95409 +diva_os_malloc_16406 diva_os_malloc 2 16406 NULL
95410 +ieee80211_if_read_tsf_16420 ieee80211_if_read_tsf 3 16420 NULL
95411 +rxrpc_server_keyring_16431 rxrpc_server_keyring 3 16431 NULL
95412 +netlink_change_ngroups_16457 netlink_change_ngroups 2 16457 NULL
95413 +tracing_readme_read_16493 tracing_readme_read 3 16493 NULL
95414 +snd_interval_max_16529 snd_interval_max 0 16529 NULL
95415 +raid10_resize_16537 raid10_resize 2 16537 NULL
95416 +tcp_manip_pkt_16563 tcp_manip_pkt 4 16563 NULL
95417 +lpfc_debugfs_read_16566 lpfc_debugfs_read 3 16566 NULL
95418 +agp_allocate_memory_wrap_16576 agp_allocate_memory_wrap 1 16576 NULL
95419 +btrfs_get_token_32_16651 btrfs_get_token_32 0 16651 NULL
95420 +mfd_add_devices_16668 mfd_add_devices 4 16668 NULL
95421 +da9052_reg_write_16685 da9052_reg_write 2 16685 NULL
95422 +em28xx_v4l2_read_16701 em28xx_v4l2_read 3 16701 NULL
95423 +arcmsr_adjust_disk_queue_depth_16756 arcmsr_adjust_disk_queue_depth 2 16756 NULL
95424 +compat_blkdev_driver_ioctl_16769 compat_blkdev_driver_ioctl 4 16769 NULL
95425 +blk_rq_map_user_iov_16772 blk_rq_map_user_iov 5 16772 NULL
95426 +i2o_parm_issue_16790 i2o_parm_issue 0 16790 NULL
95427 +get_server_iovec_16804 get_server_iovec 2 16804 NULL
95428 +tipc_send2name_16809 tipc_send2name 6 16809 NULL
95429 +dm_vcalloc_16814 dm_vcalloc 1-2 16814 NULL
95430 +drm_malloc_ab_16831 drm_malloc_ab 1-2 16831 NULL
95431 +scsi_mode_sense_16835 scsi_mode_sense 5 16835 NULL
95432 +hfsplus_min_io_size_16859 hfsplus_min_io_size 0 16859 NULL
95433 +alloc_idx_lebs_16872 alloc_idx_lebs 2 16872 NULL
95434 +carl9170_debugfs_ampdu_state_read_16873 carl9170_debugfs_ampdu_state_read 3 16873 NULL
95435 +st_write_16874 st_write 3 16874 NULL
95436 +__kfifo_peek_n_16877 __kfifo_peek_n 0 16877 NULL
95437 +wm8350_set_bits_16911 wm8350_set_bits 2 16911 NULL
95438 +psb_unlocked_ioctl_16926 psb_unlocked_ioctl 2 16926 NULL nohasharray
95439 +snd_gf1_mem_proc_dump_16926 snd_gf1_mem_proc_dump 5 16926 &psb_unlocked_ioctl_16926
95440 +random32_16937 random32 0 16937 NULL
95441 +_sp2d_alloc_16944 _sp2d_alloc 1-2-3 16944 NULL
95442 +squashfs_read_table_16945 squashfs_read_table 3 16945 NULL
95443 +cfg80211_send_unprot_disassoc_16951 cfg80211_send_unprot_disassoc 3 16951 NULL
95444 +keyctl_instantiate_key_iov_16969 keyctl_instantiate_key_iov 3 16969 NULL
95445 +ceph_read_dir_17005 ceph_read_dir 3 17005 NULL
95446 +copy_counters_to_user_17027 copy_counters_to_user 5 17027 NULL
95447 +jffs2_trusted_setxattr_17048 jffs2_trusted_setxattr 4 17048 NULL
95448 +__arch_hweight32_17060 __arch_hweight32 0 17060 NULL
95449 +dvb_dvr_read_17073 dvb_dvr_read 3 17073 NULL
95450 +simple_transaction_read_17076 simple_transaction_read 3 17076 NULL
95451 +__kmalloc_reserve_17080 __kmalloc_reserve 1 17080 NULL
95452 +carl9170_debugfs_mem_usage_read_17084 carl9170_debugfs_mem_usage_read 3 17084 NULL
95453 +mac_address_string_17091 mac_address_string 0 17091 NULL
95454 +entry_length_17093 entry_length 0 17093 NULL
95455 +sys_preadv_17100 sys_preadv 3 17100 NULL
95456 +pvr2_hdw_state_report_17121 pvr2_hdw_state_report 3 17121 NULL
95457 +mwifiex_get_common_rates_17131 mwifiex_get_common_rates 3 17131 NULL
95458 +nouveau_instobj_create__17144 nouveau_instobj_create_ 4 17144 NULL
95459 +sep_read_17161 sep_read 3 17161 NULL
95460 +befs_nls2utf_17163 befs_nls2utf 3 17163 NULL
95461 +tx_tx_start_templates_read_17164 tx_tx_start_templates_read 3 17164 NULL
95462 +UniStrnlen_17169 UniStrnlen 0 17169 NULL
95463 +access_remote_vm_17189 access_remote_vm 0-2-4 17189 NULL
95464 +driver_state_read_17194 driver_state_read 3 17194 NULL nohasharray
95465 +iscsit_find_cmd_from_itt_or_dump_17194 iscsit_find_cmd_from_itt_or_dump 3 17194 &driver_state_read_17194
95466 +dn_recvmsg_17213 dn_recvmsg 4 17213 NULL
95467 +ms_rw_17220 ms_rw 3-4 17220 NULL
95468 +__be16_to_cpup_17261 __be16_to_cpup 0 17261 NULL
95469 +error_error_frame_cts_nul_flid_read_17262 error_error_frame_cts_nul_flid_read 3 17262 NULL
95470 +alloc_ep_17269 alloc_ep 1 17269 NULL
95471 +pg_read_17276 pg_read 3 17276 NULL
95472 +raw_recvmsg_17277 raw_recvmsg 4 17277 NULL
95473 +hmac_sha256_17278 hmac_sha256 2 17278 NULL
95474 +neigh_hash_grow_17283 neigh_hash_grow 2 17283 NULL
95475 +minstrel_stats_read_17290 minstrel_stats_read 3 17290 NULL
95476 +ieee80211_if_fmt_dot11MeshForwarding_17301 ieee80211_if_fmt_dot11MeshForwarding 3 17301 NULL
95477 +skb_pad_17302 skb_pad 2 17302 NULL
95478 +mb_cache_create_17307 mb_cache_create 2 17307 NULL
95479 +gnttab_map_frames_v2_17314 gnttab_map_frames_v2 2 17314 NULL
95480 +ata_host_alloc_pinfo_17325 ata_host_alloc_pinfo 3 17325 NULL
95481 +ieee80211_if_read_dot11MeshHWMPperrMinInterval_17346 ieee80211_if_read_dot11MeshHWMPperrMinInterval 3 17346 NULL
95482 +ath6kl_wmi_send_mgmt_cmd_17347 ath6kl_wmi_send_mgmt_cmd 7 17347 NULL
95483 +lpfc_debugfs_dif_err_write_17424 lpfc_debugfs_dif_err_write 3 17424 NULL
95484 +sta_connected_time_read_17435 sta_connected_time_read 3 17435 NULL
95485 +nla_get_u32_17455 nla_get_u32 0 17455 NULL
95486 +__ref_totlen_17461 __ref_totlen 0 17461 NULL
95487 +compat_cmd_17465 compat_cmd 2 17465 NULL
95488 +probe_bios_17467 probe_bios 1 17467 NULL
95489 +probe_kernel_write_17481 probe_kernel_write 3 17481 NULL
95490 +__alloc_session_17485 __alloc_session 2-1 17485 NULL
95491 +TSS_rawhmac_17486 TSS_rawhmac 3 17486 NULL
95492 +bitmap_pos_to_ord_17503 bitmap_pos_to_ord 3 17503 NULL
95493 +arizona_apply_fll_17538 arizona_apply_fll 2 17538 NULL
95494 +xlog_do_log_recovery_17550 xlog_do_log_recovery 3 17550 NULL
95495 +__copy_to_user_17551 __copy_to_user 0-3 17551 NULL
95496 +copy_from_user_17559 copy_from_user 3 17559 NULL
95497 +snd_pcm_action_lock_irq_17569 snd_pcm_action_lock_irq 0 17569 NULL
95498 +acpi_ut_create_package_object_17594 acpi_ut_create_package_object 1 17594 NULL
95499 +neigh_hash_alloc_17595 neigh_hash_alloc 1 17595 NULL
95500 +rts51x_write_mem_17598 rts51x_write_mem 4 17598 NULL
95501 +iwl_dump_nic_event_log_17601 iwl_dump_nic_event_log 0 17601 NULL
95502 +wm8994_gpio_to_irq_17604 wm8994_gpio_to_irq 2 17604 NULL
95503 +osst_execute_17607 osst_execute 7-6 17607 NULL
95504 +ocfs2_mark_extent_written_17615 ocfs2_mark_extent_written 6 17615 NULL
95505 +ieee80211_if_read_dot11MeshHWMPactivePathToRootTimeout_17618 ieee80211_if_read_dot11MeshHWMPactivePathToRootTimeout 3 17618 NULL
95506 +twl4030_set_gpio_direction_17645 twl4030_set_gpio_direction 1 17645 NULL
95507 +packet_setsockopt_17662 packet_setsockopt 5 17662 NULL nohasharray
95508 +ubi_io_read_data_17662 ubi_io_read_data 0 17662 &packet_setsockopt_17662
95509 +pwr_enable_ps_read_17686 pwr_enable_ps_read 3 17686 NULL
95510 +__einj_error_trigger_17707 __einj_error_trigger 1 17707 NULL nohasharray
95511 +venus_rename_17707 venus_rename 5-4 17707 &__einj_error_trigger_17707
95512 +exofs_read_lookup_dev_table_17733 exofs_read_lookup_dev_table 3 17733 NULL
95513 +sctpprobe_read_17741 sctpprobe_read 3 17741 NULL
95514 +mark_unsafe_pages_17759 mark_unsafe_pages 0 17759 NULL
95515 +brcmf_usb_attach_17766 brcmf_usb_attach 2-3 17766 NULL
95516 +ubifs_leb_change_17789 ubifs_leb_change 4 17789 NULL
95517 +get_unaligned_be64_17794 get_unaligned_be64 0 17794 NULL
95518 +_snd_pcm_lib_alloc_vmalloc_buffer_17820 _snd_pcm_lib_alloc_vmalloc_buffer 2 17820 NULL
95519 +gnet_stats_copy_app_17821 gnet_stats_copy_app 3 17821 NULL
95520 +cipso_v4_gentag_rbm_17836 cipso_v4_gentag_rbm 0 17836 NULL
95521 +count_leafs_17842 count_leafs 0 17842 NULL
95522 +sisusb_send_bulk_msg_17864 sisusb_send_bulk_msg 3 17864 NULL
95523 +alloc_sja1000dev_17868 alloc_sja1000dev 1 17868 NULL
95524 +ray_cs_essid_proc_write_17875 ray_cs_essid_proc_write 3 17875 NULL
95525 +orinoco_set_key_17878 orinoco_set_key 5-7 17878 NULL
95526 +init_per_cpu_17880 init_per_cpu 1 17880 NULL
95527 +ieee80211_if_fmt_dot11MeshMaxPeerLinks_17883 ieee80211_if_fmt_dot11MeshMaxPeerLinks 3 17883 NULL
95528 +compat_sys_pwritev_17886 compat_sys_pwritev 3 17886 NULL
95529 +ieee80211_if_fmt_dot11MeshHWMPRootMode_17890 ieee80211_if_fmt_dot11MeshHWMPRootMode 3 17890 NULL
95530 +ocfs2_clusters_to_blocks_17896 ocfs2_clusters_to_blocks 0-2 17896 NULL
95531 +wm8400_set_bits_17898 wm8400_set_bits 2 17898 NULL
95532 +recover_head_17904 recover_head 3 17904 NULL
95533 +dccp_feat_register_sp_17914 dccp_feat_register_sp 5 17914 NULL
95534 +xfs_buf_associate_memory_17915 xfs_buf_associate_memory 3 17915 NULL
95535 +srp_iu_pool_alloc_17920 srp_iu_pool_alloc 2 17920 NULL
95536 +scsi_bufflen_17933 scsi_bufflen 0 17933 NULL
95537 +ufs_free_blocks_17963 ufs_free_blocks 2-3 17963 NULL
95538 +calc_nr_buckets_17976 calc_nr_buckets 0 17976 NULL
95539 +smk_write_cipso_17989 smk_write_cipso 3 17989 NULL
95540 +gnttab_max_grant_frames_17993 gnttab_max_grant_frames 0 17993 NULL
95541 +ext4_num_overhead_clusters_18001 ext4_num_overhead_clusters 2 18001 NULL
95542 +pvr2_v4l2_read_18006 pvr2_v4l2_read 3 18006 NULL
95543 +prandom32_18007 prandom32 0 18007 NULL
95544 +alloc_rx_desc_ring_18016 alloc_rx_desc_ring 2 18016 NULL
95545 +fill_read_18019 fill_read 0 18019 NULL
95546 +o2hb_highest_node_18034 o2hb_highest_node 2 18034 NULL
95547 +cryptd_alloc_instance_18048 cryptd_alloc_instance 2-3 18048 NULL
95548 +find_next_inuse_18051 find_next_inuse 2-3 18051 NULL
95549 +ddebug_proc_write_18055 ddebug_proc_write 3 18055 NULL
95550 +lua_sysfs_read_18062 lua_sysfs_read 6 18062 NULL
95551 +hex_byte_pack_18064 hex_byte_pack 0 18064 NULL
95552 +packet_came_18072 packet_came 3 18072 NULL
95553 +kvm_read_guest_page_18074 kvm_read_guest_page 5 18074 NULL
95554 +get_vm_area_18080 get_vm_area 1 18080 NULL
95555 +mpi_alloc_18094 mpi_alloc 1 18094 NULL
95556 +tps65910_gpio_input_18110 tps65910_gpio_input 2 18110 NULL
95557 +dfs_file_read_18116 dfs_file_read 3 18116 NULL
95558 +svc_getnl_18120 svc_getnl 0 18120 NULL
95559 +paging32_gpte_to_gfn_lvl_18131 paging32_gpte_to_gfn_lvl 0-1-2 18131 NULL
95560 +vmw_surface_dma_size_18132 vmw_surface_dma_size 0 18132 NULL
95561 +tps65910_gpio_set_18135 tps65910_gpio_set 2 18135 NULL
95562 +selinux_inode_setsecurity_18148 selinux_inode_setsecurity 4 18148 NULL
95563 +is_idx_node_in_use_18165 is_idx_node_in_use 0 18165 NULL
95564 +_has_tag_18169 _has_tag 2 18169 NULL
95565 +pccard_store_cis_18176 pccard_store_cis 6 18176 NULL
95566 +snd_pcm_hw_refine_user_18204 snd_pcm_hw_refine_user 0 18204 NULL
95567 +orinoco_add_extscan_result_18207 orinoco_add_extscan_result 3 18207 NULL
95568 +gsm_control_message_18209 gsm_control_message 4 18209 NULL
95569 +do_ipv6_setsockopt_18215 do_ipv6_setsockopt 5 18215 NULL
95570 +gnttab_alloc_grant_references_18240 gnttab_alloc_grant_references 1 18240 NULL
95571 +snd_ctl_ioctl_compat_18250 snd_ctl_ioctl_compat 3 18250 NULL
95572 +qdisc_class_hash_alloc_18262 qdisc_class_hash_alloc 1 18262 NULL
95573 +gfs2_alloc_sort_buffer_18275 gfs2_alloc_sort_buffer 1 18275 NULL
95574 +alloc_ring_18278 alloc_ring 2-4 18278 NULL
95575 +find_dirty_idx_leb_18280 find_dirty_idx_leb 0 18280 NULL
95576 +nouveau_subdev_create__18281 nouveau_subdev_create_ 7 18281 NULL nohasharray
95577 +bio_phys_segments_18281 bio_phys_segments 0 18281 &nouveau_subdev_create__18281
95578 +ext4_readpages_18283 ext4_readpages 4 18283 NULL
95579 +mmc_send_bus_test_18285 mmc_send_bus_test 4 18285 NULL
95580 +um_idi_write_18293 um_idi_write 3 18293 NULL
95581 +ip6ip6_err_18308 ip6ip6_err 5 18308 NULL
95582 +vga_r_18310 vga_r 0 18310 NULL
95583 +ecryptfs_send_message_18322 ecryptfs_send_message 2 18322 NULL
95584 +bio_integrity_advance_18324 bio_integrity_advance 2 18324 NULL
95585 +wm8994_gpio_direction_out_18337 wm8994_gpio_direction_out 2 18337 NULL
95586 +pwr_power_save_off_read_18355 pwr_power_save_off_read 3 18355 NULL
95587 +xlbd_reserve_minors_18365 xlbd_reserve_minors 1-2 18365 NULL
95588 +ep_io_18367 ep_io 0 18367 NULL
95589 +lp872x_update_bits_18368 lp872x_update_bits 2 18368 NULL
95590 +irq_find_mapping_18388 irq_find_mapping 0-2 18388 NULL
95591 +__video_register_device_18399 __video_register_device 3 18399 NULL
95592 +reada_tree_block_flagged_18402 reada_tree_block_flagged 3 18402 NULL nohasharray
95593 +adis16136_show_serial_18402 adis16136_show_serial 3 18402 &reada_tree_block_flagged_18402
95594 +crystalhd_user_data_18407 crystalhd_user_data 3 18407 NULL
95595 +usbnet_write_cmd_nopm_18426 usbnet_write_cmd_nopm 7 18426 NULL
95596 +batadv_orig_node_add_if_18433 batadv_orig_node_add_if 2 18433 NULL
95597 +snd_hda_get_connections_18437 snd_hda_get_connections 0 18437 NULL
95598 +fuse_perform_write_18457 fuse_perform_write 4 18457 NULL
95599 +regset_tls_set_18459 regset_tls_set 4 18459 NULL
95600 +dma_alloc_from_contiguous_18466 dma_alloc_from_contiguous 3-2 18466 NULL
95601 +pci_vpd_lrdt_size_18479 pci_vpd_lrdt_size 0 18479 NULL
95602 +udpv6_setsockopt_18487 udpv6_setsockopt 5 18487 NULL
95603 +snd_gus_dram_poke_18525 snd_gus_dram_poke 4 18525 NULL
95604 +nouveau_fifo_channel_create__18530 nouveau_fifo_channel_create_ 5-6-9 18530 NULL
95605 +seq_copy_in_user_18543 seq_copy_in_user 3 18543 NULL
95606 +acpi_register_gsi_ioapic_18550 acpi_register_gsi_ioapic 2 18550 NULL
95607 +sas_change_queue_depth_18555 sas_change_queue_depth 2 18555 NULL
95608 +smk_write_rules_list_18565 smk_write_rules_list 3 18565 NULL
95609 +debug_output_18575 debug_output 3 18575 NULL
95610 +check_lpt_type_18577 check_lpt_type 0 18577 NULL
95611 +__netdev_alloc_skb_18595 __netdev_alloc_skb 2 18595 NULL
95612 +filemap_fdatawait_range_18600 filemap_fdatawait_range 0 18600 NULL nohasharray
95613 +slabinfo_write_18600 slabinfo_write 3 18600 &filemap_fdatawait_range_18600
95614 +iowarrior_write_18604 iowarrior_write 3 18604 NULL
95615 +batadv_arp_get_type_18609 batadv_arp_get_type 3 18609 NULL
95616 +from_buffer_18625 from_buffer 3 18625 NULL
95617 +f1x_map_sysaddr_to_csrow_18628 f1x_map_sysaddr_to_csrow 2 18628 NULL
95618 +snd_pcm_oss_write3_18657 snd_pcm_oss_write3 0-3 18657 NULL
95619 +ieee80211_if_fmt_rssi_threshold_18664 ieee80211_if_fmt_rssi_threshold 3 18664 NULL
95620 +unmap_page_18665 unmap_page 2-3 18665 NULL
95621 +edge_tty_recv_18667 edge_tty_recv 4 18667 NULL nohasharray
95622 +xfs_iext_insert_18667 xfs_iext_insert 3 18667 &edge_tty_recv_18667
95623 +replay_log_leb_18704 replay_log_leb 3 18704 NULL
95624 +iwl_dbgfs_rx_handlers_read_18708 iwl_dbgfs_rx_handlers_read 3 18708 NULL
95625 +ceph_alloc_page_vector_18710 ceph_alloc_page_vector 1 18710 NULL
95626 +ocfs2_trim_extent_18711 ocfs2_trim_extent 4-3 18711 NULL
95627 +blk_rq_bytes_18715 blk_rq_bytes 0 18715 NULL
95628 +snd_als4k_gcr_read_addr_18741 snd_als4k_gcr_read_addr 0 18741 NULL
95629 +o2hb_debug_create_18744 o2hb_debug_create 4 18744 NULL
95630 +__erst_read_to_erange_from_nvram_18748 __erst_read_to_erange_from_nvram 0 18748 NULL
95631 +wep_packets_read_18751 wep_packets_read 3 18751 NULL
95632 +md_compat_ioctl_18764 md_compat_ioctl 4 18764 NULL
95633 +read_file_dump_nfcal_18766 read_file_dump_nfcal 3 18766 NULL
95634 +ffs_epfile_read_18775 ffs_epfile_read 3 18775 NULL
95635 +alloc_fcdev_18780 alloc_fcdev 1 18780 NULL
95636 +fat_compat_dir_ioctl_18800 fat_compat_dir_ioctl 3 18800 NULL
95637 +ieee80211_auth_challenge_18810 ieee80211_auth_challenge 3 18810 NULL
95638 +setup_ioapic_irq_18813 setup_ioapic_irq 1 18813 NULL
95639 +sys_modify_ldt_18824 sys_modify_ldt 3 18824 NULL
95640 +mtf_test_write_18844 mtf_test_write 3 18844 NULL
95641 +drm_ht_create_18853 drm_ht_create 2 18853 NULL
95642 +sctp_setsockopt_events_18862 sctp_setsockopt_events 3 18862 NULL
95643 +ieee80211_if_read_element_ttl_18869 ieee80211_if_read_element_ttl 3 18869 NULL
95644 +xlog_find_verify_log_record_18870 xlog_find_verify_log_record 2 18870 NULL
95645 +width_to_agaw_18883 width_to_agaw 0-1 18883 NULL
95646 +ceph_setxattr_18913 ceph_setxattr 4 18913 NULL
95647 +mangle_packet_18920 mangle_packet 7-9 18920 NULL
95648 +snapshot_write_next_18937 snapshot_write_next 0 18937 NULL
95649 +__nla_reserve_18974 __nla_reserve 3 18974 NULL
95650 +alc_auto_create_extra_outs_18975 alc_auto_create_extra_outs 2 18975 NULL
95651 +find_dirtiest_idx_leb_19001 find_dirtiest_idx_leb 0 19001 NULL
95652 +layout_in_gaps_19006 layout_in_gaps 2 19006 NULL
95653 +huge_page_size_19008 huge_page_size 0 19008 NULL
95654 +usbdev_compat_ioctl_19026 usbdev_compat_ioctl 3 19026 NULL
95655 +prepare_highmem_image_19028 prepare_highmem_image 0 19028 NULL
95656 +revalidate_19043 revalidate 2 19043 NULL
95657 +drm_fb_helper_init_19044 drm_fb_helper_init 3-4 19044 NULL
95658 +create_gpadl_header_19064 create_gpadl_header 2 19064 NULL
95659 +ieee80211_key_alloc_19065 ieee80211_key_alloc 3 19065 NULL
95660 +copy_and_check_19089 copy_and_check 3 19089 NULL
95661 +sys_process_vm_readv_19090 sys_process_vm_readv 3-5 19090 NULL nohasharray
95662 +brcmf_usbdev_qinit_19090 brcmf_usbdev_qinit 2 19090 &sys_process_vm_readv_19090
95663 +sta_last_seq_ctrl_read_19106 sta_last_seq_ctrl_read 3 19106 NULL
95664 +cifs_readv_from_socket_19109 cifs_readv_from_socket 3 19109 NULL
95665 +skb_gro_offset_19123 skb_gro_offset 0 19123 NULL
95666 +ext4_inode_table_19125 ext4_inode_table 0 19125 NULL
95667 +snd_als4k_iobase_readl_19136 snd_als4k_iobase_readl 0 19136 NULL
95668 +alloc_irdadev_19140 alloc_irdadev 1 19140 NULL
95669 +sleep_auth_read_19159 sleep_auth_read 3 19159 NULL
95670 +smk_write_access2_19170 smk_write_access2 3 19170 NULL
95671 +iwl_dbgfs_reply_tx_error_read_19205 iwl_dbgfs_reply_tx_error_read 3 19205 NULL
95672 +vmw_unlocked_ioctl_19212 vmw_unlocked_ioctl 2 19212 NULL
95673 +__copy_to_user_inatomic_19214 __copy_to_user_inatomic 3 19214 NULL
95674 +dev_counters_read_19216 dev_counters_read 3 19216 NULL
95675 +wbcir_tx_19219 wbcir_tx 3 19219 NULL
95676 +gsi_to_irq_19220 gsi_to_irq 0-1 19220 NULL
95677 +snd_mask_max_19224 snd_mask_max 0 19224 NULL
95678 +snd_pcm_capture_rewind_19229 snd_pcm_capture_rewind 0-2 19229 NULL
95679 +bio_alloc_mddev_19238 bio_alloc_mddev 2 19238 NULL
95680 +sys_fcntl_19267 sys_fcntl 3 19267 NULL
95681 +il_dbgfs_rxon_filter_flags_read_19281 il_dbgfs_rxon_filter_flags_read 3 19281 NULL
95682 +io_mapping_map_wc_19284 io_mapping_map_wc 2 19284 NULL
95683 +qc_capture_19298 qc_capture 3 19298 NULL
95684 +ocfs2_prepare_inode_for_refcount_19303 ocfs2_prepare_inode_for_refcount 3-4 19303 NULL
95685 +event_tx_stuck_read_19305 event_tx_stuck_read 3 19305 NULL
95686 +debug_read_19322 debug_read 3 19322 NULL
95687 +cfg80211_inform_bss_19332 cfg80211_inform_bss 8 19332 NULL
95688 +read_zero_19366 read_zero 3 19366 NULL
95689 +interpret_user_input_19393 interpret_user_input 2 19393 NULL
95690 +get_unaligned_be16_19400 get_unaligned_be16 0 19400 NULL
95691 +get_n_events_by_type_19401 get_n_events_by_type 0 19401 NULL
95692 +dvbdmx_write_19423 dvbdmx_write 3 19423 NULL
95693 +__phys_addr_19434 __phys_addr 0 19434 NULL
95694 +xfrm_alg_auth_len_19454 xfrm_alg_auth_len 0 19454 NULL
95695 +hpet_compat_ioctl_19455 hpet_compat_ioctl 3 19455 NULL
95696 +gnet_stats_copy_19458 gnet_stats_copy 4 19458 NULL
95697 +sky2_read16_19475 sky2_read16 0 19475 NULL
95698 +efivar_create_sysfs_entry_19485 efivar_create_sysfs_entry 2 19485 NULL
95699 +ext4_add_new_descs_19509 ext4_add_new_descs 3 19509 NULL
95700 +skb_realloc_headroom_19516 skb_realloc_headroom 2 19516 NULL
95701 +dev_alloc_skb_19517 dev_alloc_skb 1 19517 NULL
95702 +nfc_llcp_build_tlv_19536 nfc_llcp_build_tlv 3 19536 NULL
95703 +gfn_to_index_19558 gfn_to_index 0-1-3-2 19558 NULL
95704 +ocfs2_control_message_19564 ocfs2_control_message 3 19564 NULL
95705 +ieee80211_if_read_tkip_mic_test_19565 ieee80211_if_read_tkip_mic_test 3 19565 NULL nohasharray
95706 +wlcore_hw_get_rx_packet_len_19565 wlcore_hw_get_rx_packet_len 0 19565 &ieee80211_if_read_tkip_mic_test_19565
95707 +nfsd_read_19568 nfsd_read 5 19568 NULL
95708 +cgroup_read_s64_19570 cgroup_read_s64 5 19570 NULL
95709 +bm_status_read_19583 bm_status_read 3 19583 NULL
95710 +batadv_tt_update_orig_19586 batadv_tt_update_orig 4 19586 NULL
95711 +load_xattr_datum_19594 load_xattr_datum 0 19594 NULL
95712 +usbvision_rvmalloc_19655 usbvision_rvmalloc 1 19655 NULL
95713 +LoadBitmap_19658 LoadBitmap 2 19658 NULL
95714 +usbnet_write_cmd_19679 usbnet_write_cmd 7 19679 NULL
95715 +read_reg_19723 read_reg 0 19723 NULL
95716 +wm8350_block_write_19727 wm8350_block_write 3-2 19727 NULL
95717 +memcpy_toiovecend_19736 memcpy_toiovecend 4-3 19736 NULL
95718 +snd_es1968_get_dma_ptr_19747 snd_es1968_get_dma_ptr 0 19747 NULL
95719 +p9_client_read_19750 p9_client_read 5 19750 NULL
95720 +pnpbios_proc_write_19758 pnpbios_proc_write 3 19758 NULL
95721 +ocfs2_readpages_19759 ocfs2_readpages 4 19759 NULL
95722 +jffs2_acl_from_medium_19762 jffs2_acl_from_medium 2 19762 NULL
95723 +__set_print_fmt_19776 __set_print_fmt 0 19776 NULL
95724 +saa7146_vmalloc_build_pgtable_19780 saa7146_vmalloc_build_pgtable 2 19780 NULL
95725 +irda_setsockopt_19824 irda_setsockopt 5 19824 NULL
95726 +pcpu_next_unpop_19831 pcpu_next_unpop 4 19831 NULL
95727 +vip_read_19832 vip_read 3 19832 NULL nohasharray
95728 +vfs_getxattr_19832 vfs_getxattr 0 19832 &vip_read_19832
95729 +security_context_to_sid_19839 security_context_to_sid 2 19839 NULL
95730 +crypt_alloc_buffer_19846 crypt_alloc_buffer 2 19846 NULL
95731 +cfg80211_mlme_register_mgmt_19852 cfg80211_mlme_register_mgmt 5 19852 NULL
95732 +__nla_put_19857 __nla_put 3 19857 NULL
95733 +ip6gre_err_19869 ip6gre_err 5 19869 NULL
95734 +aes_decrypt_interrupt_read_19910 aes_decrypt_interrupt_read 3 19910 NULL
95735 +ps_upsd_max_apturn_read_19918 ps_upsd_max_apturn_read 3 19918 NULL
95736 +cgroup_task_count_19930 cgroup_task_count 0 19930 NULL
95737 +iwl_dbgfs_rx_queue_read_19943 iwl_dbgfs_rx_queue_read 3 19943 NULL
95738 +attach_hdlc_protocol_19986 attach_hdlc_protocol 3 19986 NULL
95739 +diva_um_idi_read_20003 diva_um_idi_read 0 20003 NULL
95740 +split_scan_timeout_read_20029 split_scan_timeout_read 3 20029 NULL
95741 +__be32_to_cpup_20056 __be32_to_cpup 0 20056 NULL
95742 +alloc_ieee80211_20063 alloc_ieee80211 1 20063 NULL
95743 +rawv6_sendmsg_20080 rawv6_sendmsg 4 20080 NULL
95744 +fuse_conn_limit_read_20084 fuse_conn_limit_read 3 20084 NULL
95745 +team_options_register_20091 team_options_register 3 20091 NULL
95746 +qla2x00_adjust_sdev_qdepth_up_20097 qla2x00_adjust_sdev_qdepth_up 2 20097 NULL
95747 +hptiop_adjust_disk_queue_depth_20122 hptiop_adjust_disk_queue_depth 2 20122 NULL
95748 +tomoyo_commit_ok_20167 tomoyo_commit_ok 2 20167 NULL
95749 +read_flush_pipefs_20171 read_flush_pipefs 3 20171 NULL
95750 +wep_addr_key_count_read_20174 wep_addr_key_count_read 3 20174 NULL
95751 +create_trace_probe_20175 create_trace_probe 1 20175 NULL
95752 +udf_bitmap_new_block_20214 udf_bitmap_new_block 4 20214 NULL
95753 +pvr2_ctrl_value_to_sym_20229 pvr2_ctrl_value_to_sym 5 20229 NULL
95754 +rose_sendmsg_20249 rose_sendmsg 4 20249 NULL
95755 +tm6000_i2c_send_regs_20250 tm6000_i2c_send_regs 5 20250 NULL
95756 +pcpu_alloc_20255 pcpu_alloc 1-2 20255 NULL
95757 +resource_size_20256 resource_size 0 20256 NULL
95758 +_rtl92s_get_h2c_cmdlen_20312 _rtl92s_get_h2c_cmdlen 0 20312 NULL
95759 +tx_tx_burst_programmed_read_20320 tx_tx_burst_programmed_read 3 20320 NULL
95760 +snd_cs4281_BA1_read_20323 snd_cs4281_BA1_read 5 20323 NULL
95761 +gfs2_glock_nq_m_20347 gfs2_glock_nq_m 1 20347 NULL
95762 +qla82xx_pci_mem_read_direct_20368 qla82xx_pci_mem_read_direct 2 20368 NULL
95763 +snd_pcm_stop_20376 snd_pcm_stop 0 20376 NULL
95764 +smk_set_cipso_20379 smk_set_cipso 3 20379 NULL
95765 +u64_to_uptr_20384 u64_to_uptr 1 20384 NULL
95766 +snd_nm256_readl_20394 snd_nm256_readl 0 20394 NULL
95767 +__kfifo_from_user_20399 __kfifo_from_user 3 20399 NULL
95768 +pm860x_write_reg_cache_20448 pm860x_write_reg_cache 2 20448 NULL
95769 +nfs3_setxattr_20458 nfs3_setxattr 4 20458 NULL
95770 +ip_vs_icmp_xmit_v6_20464 ip_vs_icmp_xmit_v6 4 20464 NULL
95771 +compat_ipv6_setsockopt_20468 compat_ipv6_setsockopt 5 20468 NULL
95772 +read_buf_20469 read_buf 2 20469 NULL
95773 +btrfs_get_32_20476 btrfs_get_32 0 20476 NULL
95774 +fast_user_write_20494 fast_user_write 5 20494 NULL
95775 +ocfs2_db_frozen_trigger_20503 ocfs2_db_frozen_trigger 4 20503 NULL nohasharray
95776 +hidraw_report_event_20503 hidraw_report_event 3 20503 &ocfs2_db_frozen_trigger_20503
95777 +pcpu_alloc_area_20511 pcpu_alloc_area 0-3 20511 NULL
95778 +pcpu_depopulate_chunk_20517 pcpu_depopulate_chunk 2-3 20517 NULL
95779 +xfs_iext_realloc_direct_20521 xfs_iext_realloc_direct 2 20521 NULL
95780 +drbd_bm_resize_20522 drbd_bm_resize 2 20522 NULL
95781 +amd_create_gatt_pages_20537 amd_create_gatt_pages 1 20537 NULL
95782 +scsi_report_opcode_20551 scsi_report_opcode 3 20551 NULL
95783 +venus_create_20555 venus_create 4 20555 NULL
95784 +btrfs_super_log_root_20565 btrfs_super_log_root 0 20565 NULL
95785 +crypto_ahash_reqsize_20569 crypto_ahash_reqsize 0 20569 NULL
95786 +rc5t583_set_bits_20573 rc5t583_set_bits 2 20573 NULL
95787 +i915_max_freq_read_20581 i915_max_freq_read 3 20581 NULL
95788 +batadv_tt_append_diff_20588 batadv_tt_append_diff 4 20588 NULL
95789 +lirc_write_20604 lirc_write 3 20604 NULL
95790 +qib_qsfp_write_20614 qib_qsfp_write 0-4-2 20614 NULL
95791 +snd_pcm_oss_prepare_20641 snd_pcm_oss_prepare 0 20641 NULL
95792 +kfifo_copy_to_user_20646 kfifo_copy_to_user 3 20646 NULL
95793 +cpulist_scnprintf_20648 cpulist_scnprintf 0-2 20648 NULL
95794 +oz_add_farewell_20652 oz_add_farewell 5 20652 NULL
95795 +ceph_osdc_new_request_20654 ceph_osdc_new_request 15-4 20654 NULL
95796 +oz_cdev_read_20659 oz_cdev_read 3 20659 NULL
95797 +sec_reg_write_20667 sec_reg_write 2 20667 NULL
95798 +tps65910_reg_clear_bits_20672 tps65910_reg_clear_bits 2 20672 NULL
95799 +snd_hdsp_playback_copy_20676 snd_hdsp_playback_copy 5 20676 NULL
95800 +dvb_dmxdev_buffer_read_20682 dvb_dmxdev_buffer_read 0-4 20682 NULL
95801 +cpumask_size_20683 cpumask_size 0 20683 NULL
95802 +btrfs_node_blockptr_20685 btrfs_node_blockptr 0 20685 NULL
95803 +read_file_tgt_int_stats_20697 read_file_tgt_int_stats 3 20697 NULL
95804 +__maestro_read_20700 __maestro_read 0 20700 NULL
95805 +cipso_v4_gentag_rng_20703 cipso_v4_gentag_rng 0 20703 NULL
95806 +pcpu_page_first_chunk_20712 pcpu_page_first_chunk 1 20712 NULL
95807 +ocfs2_read_xattr_bucket_20722 ocfs2_read_xattr_bucket 0 20722 NULL
95808 +security_context_to_sid_force_20724 security_context_to_sid_force 2 20724 NULL
95809 +vring_add_indirect_20737 vring_add_indirect 3-4 20737 NULL
95810 +io_apic_set_pci_routing_20740 io_apic_set_pci_routing 2 20740 NULL
95811 +vol_cdev_direct_write_20751 vol_cdev_direct_write 3 20751 NULL
95812 +ocfs2_align_bytes_to_clusters_20754 ocfs2_align_bytes_to_clusters 2 20754 NULL
95813 +ubi_io_read_20767 ubi_io_read 0 20767 NULL
95814 +fb_alloc_cmap_gfp_20792 fb_alloc_cmap_gfp 2 20792 NULL
95815 +iommu_range_alloc_20794 iommu_range_alloc 3 20794 NULL
95816 +iwl_dbgfs_rxon_flags_read_20795 iwl_dbgfs_rxon_flags_read 3 20795 NULL
95817 +sys_sendto_20809 sys_sendto 6 20809 NULL
95818 +strndup_user_20819 strndup_user 2 20819 NULL
95819 +wl1271_format_buffer_20834 wl1271_format_buffer 2 20834 NULL
95820 +uvc_alloc_entity_20836 uvc_alloc_entity 4-3 20836 NULL
95821 +snd_pcm_capture_avail_20867 snd_pcm_capture_avail 0 20867 NULL
95822 +ocfs2_bmap_20874 ocfs2_bmap 2 20874 NULL
95823 +sisusb_send_packet_20891 sisusb_send_packet 2 20891 NULL
95824 +key_icverrors_read_20895 key_icverrors_read 3 20895 NULL
95825 +vfio_msi_enable_20906 vfio_msi_enable 2 20906 NULL
95826 +compat_sys_readv_20911 compat_sys_readv 3 20911 NULL
95827 +htable_bits_20933 htable_bits 0 20933 NULL
95828 +altera_set_ir_post_20948 altera_set_ir_post 2 20948 NULL
95829 +rx_rx_phy_hdr_read_20950 rx_rx_phy_hdr_read 3 20950 NULL
95830 +snd_rme9652_playback_copy_20970 snd_rme9652_playback_copy 5 20970 NULL
95831 +brcmf_tx_frame_20978 brcmf_tx_frame 3 20978 NULL
95832 +alg_setsockopt_20985 alg_setsockopt 5 20985 NULL
95833 +ocfs2_free_clusters_21001 ocfs2_free_clusters 4 21001 NULL
95834 +btrfs_inode_ref_name_len_21024 btrfs_inode_ref_name_len 0 21024 NULL
95835 +rx_defrag_tkip_called_read_21031 rx_defrag_tkip_called_read 3 21031 NULL
95836 +lbs_threshold_read_21046 lbs_threshold_read 5 21046 NULL
95837 +proc_fault_inject_write_21058 proc_fault_inject_write 3 21058 NULL
95838 +event_calibration_read_21083 event_calibration_read 3 21083 NULL
95839 +compat_sock_ioctl_trans_21092 compat_sock_ioctl_trans 4 21092 NULL
95840 +__cfg80211_send_disassoc_21096 __cfg80211_send_disassoc 3 21096 NULL
95841 +ext2_valid_block_bitmap_21101 ext2_valid_block_bitmap 3 21101 NULL
95842 +ath6kl_send_go_probe_resp_21113 ath6kl_send_go_probe_resp 3 21113 NULL
95843 +i2400m_rx_trace_21127 i2400m_rx_trace 3 21127 NULL
95844 +tps6586x_irq_init_21144 tps6586x_irq_init 3 21144 NULL
95845 +ocfs2_block_check_validate_21149 ocfs2_block_check_validate 2 21149 NULL
95846 +ath6kl_mgmt_tx_21153 ath6kl_mgmt_tx 9 21153 NULL
95847 +setup_msi_irq_21169 setup_msi_irq 3 21169 NULL
95848 +cx18_v4l2_read_21196 cx18_v4l2_read 3 21196 NULL
95849 +ipc_rcu_alloc_21208 ipc_rcu_alloc 1 21208 NULL
95850 +_ocfs2_free_clusters_21220 _ocfs2_free_clusters 4 21220 NULL
95851 +get_numpages_21227 get_numpages 0-1-2 21227 NULL
95852 +input_ff_create_21240 input_ff_create 2 21240 NULL
95853 +cfg80211_notify_new_peer_candidate_21242 cfg80211_notify_new_peer_candidate 4 21242 NULL
95854 +ocfs2_blocks_for_bytes_21268 ocfs2_blocks_for_bytes 0-2 21268 NULL
95855 +ip_vs_icmp_xmit_21269 ip_vs_icmp_xmit 4 21269 NULL
95856 +rc5t583_clear_bits_21300 rc5t583_clear_bits 2 21300 NULL
95857 +vmw_gmr2_bind_21305 vmw_gmr2_bind 3 21305 NULL
95858 +do_msg_fill_21307 do_msg_fill 3 21307 NULL
95859 +add_res_range_21310 add_res_range 4 21310 NULL
95860 +get_zeroed_page_21322 get_zeroed_page 0 21322 NULL
95861 +ftrace_profile_read_21327 ftrace_profile_read 3 21327 NULL
95862 +gfs2_ea_get_copy_21353 gfs2_ea_get_copy 0 21353 NULL
95863 +max77693_irq_domain_map_21357 max77693_irq_domain_map 2 21357 NULL
95864 +alloc_orinocodev_21371 alloc_orinocodev 1 21371 NULL
95865 +video_ioctl2_21380 video_ioctl2 2 21380 NULL
95866 +diva_get_driver_dbg_mask_21399 diva_get_driver_dbg_mask 0 21399 NULL
95867 +snd_m3_inw_21406 snd_m3_inw 0 21406 NULL
95868 +snapshot_read_next_21426 snapshot_read_next 0 21426 NULL
95869 +tcp_bound_to_half_wnd_21429 tcp_bound_to_half_wnd 0-2 21429 NULL
95870 +tracing_saved_cmdlines_read_21434 tracing_saved_cmdlines_read 3 21434 NULL
95871 +aggr_size_tx_agg_vs_rate_read_21438 aggr_size_tx_agg_vs_rate_read 3 21438 NULL
95872 +btrfs_iref_to_path_21445 btrfs_iref_to_path 7 21445 NULL
95873 +__ertm_hdr_size_21450 __ertm_hdr_size 0 21450 NULL
95874 +concat_writev_21451 concat_writev 3 21451 NULL
95875 +extend_netdev_table_21453 extend_netdev_table 2 21453 NULL
95876 +read_file_xmit_21487 read_file_xmit 3 21487 NULL
95877 +mmc_alloc_sg_21504 mmc_alloc_sg 1 21504 NULL
95878 +btrfs_file_aio_write_21520 btrfs_file_aio_write 4 21520 NULL
95879 +il_dbgfs_stations_read_21532 il_dbgfs_stations_read 3 21532 NULL
95880 +cipso_v4_map_cat_enum_hton_21540 cipso_v4_map_cat_enum_hton 0 21540 NULL
95881 +rxrpc_send_data_21553 rxrpc_send_data 5 21553 NULL
95882 +rx_rx_beacon_early_term_read_21559 rx_rx_beacon_early_term_read 3 21559 NULL
95883 +xfs_buf_read_uncached_21585 xfs_buf_read_uncached 3 21585 NULL
95884 +ocfs2_acl_from_xattr_21604 ocfs2_acl_from_xattr 2 21604 NULL
95885 +xlog_do_recovery_pass_21618 xlog_do_recovery_pass 3 21618 NULL
95886 +__jfs_getxattr_21631 __jfs_getxattr 0 21631 NULL
95887 +rbd_req_sync_op_21632 rbd_req_sync_op 7-8 21632 NULL
95888 +validate_nnode_21638 validate_nnode 0 21638 NULL
95889 +__irq_alloc_descs_21639 __irq_alloc_descs 2-1-3 21639 NULL
95890 +carl9170_rx_copy_data_21656 carl9170_rx_copy_data 2 21656 NULL
95891 +hpet_setup_msi_irq_21662 hpet_setup_msi_irq 1 21662 NULL
95892 +atalk_sendmsg_21677 atalk_sendmsg 4 21677 NULL
95893 +ocfs2_xattr_get_nolock_21678 ocfs2_xattr_get_nolock 0 21678 NULL
95894 +regmap_register_patch_21681 regmap_register_patch 3 21681 NULL
95895 +rtllib_alloc_txb_21687 rtllib_alloc_txb 1-2 21687 NULL
95896 +evdev_ioctl_handler_21705 evdev_ioctl_handler 2 21705 NULL
95897 +reiserfs_allocate_list_bitmaps_21732 reiserfs_allocate_list_bitmaps 3 21732 NULL
95898 +__nf_nat_mangle_tcp_packet_21744 __nf_nat_mangle_tcp_packet 8-6 21744 NULL
95899 +mthca_alloc_init_21754 mthca_alloc_init 2 21754 NULL
95900 +gen_pool_add_21776 gen_pool_add 3 21776 NULL
95901 +xfs_da_grow_inode_int_21785 xfs_da_grow_inode_int 3 21785 NULL
95902 +__ioremap_caller_21800 __ioremap_caller 1-2 21800 NULL
95903 +dvb_generic_ioctl_21810 dvb_generic_ioctl 2 21810 NULL
95904 +wm8994_request_irq_21822 wm8994_request_irq 2 21822 NULL
95905 +oom_adj_read_21847 oom_adj_read 3 21847 NULL
95906 +acpi_tb_check_xsdt_21862 acpi_tb_check_xsdt 1 21862 NULL
95907 +lpfc_idiag_extacc_avail_get_21865 lpfc_idiag_extacc_avail_get 0-3 21865 NULL
95908 +brcms_debugfs_hardware_read_21867 brcms_debugfs_hardware_read 3 21867 NULL
95909 +sisusbcon_bmove_21873 sisusbcon_bmove 6-5-7 21873 NULL nohasharray
95910 +tcp_cookie_size_check_21873 tcp_cookie_size_check 0-1 21873 &sisusbcon_bmove_21873
95911 +__alloc_reserved_percpu_21895 __alloc_reserved_percpu 1-2 21895 NULL
95912 +rio_destid_first_21900 rio_destid_first 0 21900 NULL
95913 +dbAllocCtl_21911 dbAllocCtl 0 21911 NULL
95914 +qsfp_1_read_21915 qsfp_1_read 3 21915 NULL
95915 +rbd_req_read_21952 rbd_req_read 4-5 21952 NULL
95916 +security_mmap_addr_21970 security_mmap_addr 0 21970 NULL
95917 +alloc_ldt_21972 alloc_ldt 2 21972 NULL
95918 +rxpipe_descr_host_int_trig_rx_data_read_22001 rxpipe_descr_host_int_trig_rx_data_read 3 22001 NULL nohasharray
95919 +compat_rw_copy_check_uvector_22001 compat_rw_copy_check_uvector 0-3 22001 &rxpipe_descr_host_int_trig_rx_data_read_22001
95920 +btrfs_get_16_22023 btrfs_get_16 0 22023 NULL
95921 +ti_recv_22027 ti_recv 4 22027 NULL
95922 +pcf50633_irq_unmask_22034 pcf50633_irq_unmask 2 22034 NULL
95923 +zd_usb_read_fw_22049 zd_usb_read_fw 4 22049 NULL
95924 +ieee80211_if_fmt_dropped_frames_ttl_22054 ieee80211_if_fmt_dropped_frames_ttl 3 22054 NULL
95925 +btrfs_reloc_clone_csums_22077 btrfs_reloc_clone_csums 2 22077 NULL
95926 +mem_rw_22085 mem_rw 3 22085 NULL
95927 +snd_pcm_xrun_22088 snd_pcm_xrun 0 22088 NULL
95928 +lowpan_fragment_xmit_22095 lowpan_fragment_xmit 3-4 22095 NULL
95929 +sys_remap_file_pages_22124 sys_remap_file_pages 1 22124 NULL
95930 +__bitmap_size_22138 __bitmap_size 0 22138 NULL
95931 +compat_insn_22142 compat_insn 2 22142 NULL
95932 +pn533_dep_link_up_22154 pn533_dep_link_up 5 22154 NULL
95933 +do_tcp_sendpages_22155 do_tcp_sendpages 4 22155 NULL
95934 +__kfifo_alloc_22173 __kfifo_alloc 2-3 22173 NULL
95935 +fls_22210 fls 0 22210 NULL
95936 +bio_chain_clone_22227 bio_chain_clone 4 22227 NULL
95937 +mem_write_22232 mem_write 3 22232 NULL
95938 +p9_virtio_zc_request_22240 p9_virtio_zc_request 6-5 22240 NULL
95939 +atomic64_xchg_22246 atomic64_xchg 0 22246 NULL
95940 +compat_process_vm_rw_22254 compat_process_vm_rw 3-5 22254 NULL
95941 +__btrfs_direct_write_22273 __btrfs_direct_write 4 22273 NULL
95942 +queue_max_sectors_22280 queue_max_sectors 0 22280 NULL
95943 +pci_vpd_srdt_size_22300 pci_vpd_srdt_size 0 22300 NULL nohasharray
95944 +__tun_chr_ioctl_22300 __tun_chr_ioctl 4 22300 &pci_vpd_srdt_size_22300
95945 +mesh_table_alloc_22305 mesh_table_alloc 1 22305 NULL
95946 +get_segment_base_22324 get_segment_base 0 22324 NULL
95947 +radix_tree_find_next_bit_22334 radix_tree_find_next_bit 2-3 22334 NULL
95948 +atomic_read_22342 atomic_read 0 22342 NULL
95949 +mlx4_db_alloc_22358 mlx4_db_alloc 3 22358 NULL
95950 +irq_reserve_irq_22360 irq_reserve_irq 1 22360 NULL
95951 +snd_pcm_alsa_frames_22363 snd_pcm_alsa_frames 2 22363 NULL
95952 +wlcore_alloc_hw_22365 wlcore_alloc_hw 1 22365 NULL nohasharray
95953 +tps6586x_gpio_to_irq_22365 tps6586x_gpio_to_irq 2 22365 &wlcore_alloc_hw_22365
95954 +evdev_ioctl_22371 evdev_ioctl 2 22371 NULL
95955 +alloc_large_system_hash_22391 alloc_large_system_hash 2 22391 NULL
95956 +btmrvl_psmode_read_22395 btmrvl_psmode_read 3 22395 NULL
95957 +zoran_write_22404 zoran_write 3 22404 NULL
95958 +queue_reply_22416 queue_reply 3 22416 NULL
95959 +__set_enter_print_fmt_22431 __set_enter_print_fmt 0 22431 NULL
95960 +queue_max_segments_22441 queue_max_segments 0 22441 NULL
95961 +handle_received_packet_22457 handle_received_packet 3 22457 NULL
95962 +mem_cgroup_read_22461 mem_cgroup_read 5 22461 NULL
95963 +cache_write_procfs_22491 cache_write_procfs 3 22491 NULL
95964 +mp_find_ioapic_pin_22499 mp_find_ioapic_pin 0-2 22499 NULL
95965 +mutex_lock_interruptible_22505 mutex_lock_interruptible 0 22505 NULL
95966 +ip4_addr_string_22511 ip4_addr_string 0 22511 NULL
95967 +pskb_may_pull_22546 pskb_may_pull 2 22546 NULL
95968 +ocfs2_read_extent_block_22550 ocfs2_read_extent_block 0 22550 NULL
95969 +atomic_long_read_unchecked_22551 atomic_long_read_unchecked 0 22551 NULL
95970 +agp_alloc_page_array_22554 agp_alloc_page_array 1 22554 NULL
95971 +dbFindCtl_22587 dbFindCtl 0 22587 NULL
95972 +snapshot_read_22601 snapshot_read 3 22601 NULL
95973 +sctp_setsockopt_connectx_old_22631 sctp_setsockopt_connectx_old 3 22631 NULL
95974 +ide_core_cp_entry_22636 ide_core_cp_entry 3 22636 NULL
95975 +wl1271_rx_filter_get_fields_size_22638 wl1271_rx_filter_get_fields_size 0 22638 NULL
95976 +pwr_wake_on_timer_exp_read_22640 pwr_wake_on_timer_exp_read 3 22640 NULL
95977 +iwl_dbgfs_calib_disabled_read_22649 iwl_dbgfs_calib_disabled_read 3 22649 NULL
95978 +ubifs_leb_write_22679 ubifs_leb_write 4-5 22679 NULL
95979 +fill_gap_22681 fill_gap 0 22681 NULL
95980 +ocfs2_get_block_22687 ocfs2_get_block 2 22687 NULL
95981 +compat_fd_ioctl_22694 compat_fd_ioctl 4 22694 NULL
95982 +alloc_libipw_22708 alloc_libipw 1 22708 NULL
95983 +brcmf_sdbrcm_read_control_22721 brcmf_sdbrcm_read_control 3 22721 NULL
95984 +cx18_copy_buf_to_user_22735 cx18_copy_buf_to_user 4 22735 NULL
95985 +ceph_decode_32_22738 ceph_decode_32 0 22738 NULL
95986 +iio_debugfs_write_reg_22742 iio_debugfs_write_reg 3 22742 NULL
95987 +print_frame_22769 print_frame 0 22769 NULL
95988 +ftrace_arch_read_dyn_info_22773 ftrace_arch_read_dyn_info 0 22773 NULL
95989 +retu_write_22800 retu_write 2 22800 NULL
95990 +compat_blkdev_ioctl_22841 compat_blkdev_ioctl 3 22841 NULL
95991 +can_nocow_odirect_22854 can_nocow_odirect 3 22854 NULL nohasharray
95992 +read_file_rcstat_22854 read_file_rcstat 3 22854 &can_nocow_odirect_22854
95993 +do_atm_iobuf_22857 do_atm_iobuf 3 22857 NULL
95994 +nfs4_realloc_slot_table_22859 nfs4_realloc_slot_table 2 22859 NULL
95995 +create_attr_set_22861 create_attr_set 1 22861 NULL
95996 +vmw_execbuf_process_22885 vmw_execbuf_process 5 22885 NULL
95997 +usblp_new_writeurb_22894 usblp_new_writeurb 2 22894 NULL
95998 +mdc800_device_read_22896 mdc800_device_read 3 22896 NULL
95999 +pcpu_mem_zalloc_22948 pcpu_mem_zalloc 1 22948 NULL
96000 +alloc_sglist_22960 alloc_sglist 1-2-3 22960 NULL
96001 +caif_seqpkt_sendmsg_22961 caif_seqpkt_sendmsg 4 22961 NULL
96002 +vme_get_size_22964 vme_get_size 0 22964 NULL
96003 +tx_frag_key_not_found_read_22971 tx_frag_key_not_found_read 3 22971 NULL
96004 +usb_get_langid_22983 usb_get_langid 0 22983 NULL
96005 +remote_settings_file_write_22987 remote_settings_file_write 3 22987 NULL
96006 +viafb_dvp0_proc_write_23023 viafb_dvp0_proc_write 3 23023 NULL
96007 +cifs_local_to_utf16_bytes_23025 cifs_local_to_utf16_bytes 0 23025 NULL
96008 +st_status_23032 st_status 5 23032 NULL
96009 +nv50_disp_chan_create__23056 nv50_disp_chan_create_ 5 23056 NULL
96010 +reiserfs_add_entry_23062 reiserfs_add_entry 4 23062 NULL
96011 +vm_map_ram_23078 vm_map_ram 2 23078 NULL nohasharray
96012 +raw_sendmsg_23078 raw_sendmsg 4 23078 &vm_map_ram_23078
96013 +qla4_82xx_pci_mem_read_2M_23081 qla4_82xx_pci_mem_read_2M 2 23081 NULL
96014 +isr_tx_procs_read_23084 isr_tx_procs_read 3 23084 NULL
96015 +lnw_gpio_irq_map_23087 lnw_gpio_irq_map 2 23087 NULL
96016 +rt2x00debug_write_eeprom_23091 rt2x00debug_write_eeprom 3 23091 NULL
96017 +fls_long_23096 fls_long 0 23096 NULL
96018 +ntfs_ucstonls_23097 ntfs_ucstonls 3-5 23097 NULL
96019 +pipe_iov_copy_from_user_23102 pipe_iov_copy_from_user 3 23102 NULL
96020 +mwl8k_cmd_set_beacon_23110 mwl8k_cmd_set_beacon 4 23110 NULL
96021 +nl80211_send_rx_auth_23111 nl80211_send_rx_auth 4 23111 NULL
96022 +__clear_user_23118 __clear_user 0 23118 NULL
96023 +dm_write_async_23120 dm_write_async 3 23120 NULL
96024 +drm_mode_create_tv_properties_23122 drm_mode_create_tv_properties 2 23122 NULL
96025 +ca91cx42_master_set_23146 ca91cx42_master_set 4 23146 NULL
96026 +wm831x_set_bits_23158 wm831x_set_bits 2 23158 NULL
96027 +read_file_ani_23161 read_file_ani 3 23161 NULL
96028 +ioremap_23172 ioremap 1-2 23172 NULL
96029 +usblp_write_23178 usblp_write 3 23178 NULL
96030 +msnd_fifo_alloc_23179 msnd_fifo_alloc 2 23179 NULL
96031 +gss_pipe_downcall_23182 gss_pipe_downcall 3 23182 NULL
96032 +ieee80211_get_mesh_hdrlen_23183 ieee80211_get_mesh_hdrlen 0 23183 NULL
96033 +fix_unclean_leb_23188 fix_unclean_leb 3 23188 NULL
96034 +mpi_alloc_limb_space_23190 mpi_alloc_limb_space 1 23190 NULL
96035 +__next_dma_cap_23195 __next_dma_cap 1 23195 NULL
96036 +convert_ip_to_linear_23198 convert_ip_to_linear 0 23198 NULL
96037 +pm80x_free_irq_23210 pm80x_free_irq 2 23210 NULL nohasharray
96038 +compat_rawv6_ioctl_23210 compat_rawv6_ioctl 3 23210 &pm80x_free_irq_23210
96039 +tty_buffer_request_room_23228 tty_buffer_request_room 2 23228 NULL
96040 +xlog_get_bp_23229 xlog_get_bp 2 23229 NULL
96041 +rxrpc_client_sendmsg_23236 rxrpc_client_sendmsg 5 23236 NULL
96042 +__gfn_to_rmap_23240 __gfn_to_rmap 1-2 23240 NULL
96043 +uwb_dev_addr_print_23282 uwb_dev_addr_print 2 23282 NULL
96044 +ipv6_skip_exthdr_23283 ipv6_skip_exthdr 0-2 23283 NULL
96045 +doc_probe_23285 doc_probe 1 23285 NULL
96046 +diva_get_trace_filter_23286 diva_get_trace_filter 0 23286 NULL
96047 +i2cdev_write_23310 i2cdev_write 3 23310 NULL
96048 +mc13xxx_get_num_regulators_dt_23344 mc13xxx_get_num_regulators_dt 0 23344 NULL
96049 +page_readlink_23346 page_readlink 3 23346 NULL
96050 +get_dst_timing_23358 get_dst_timing 0 23358 NULL
96051 +iscsi_change_queue_depth_23416 iscsi_change_queue_depth 2 23416 NULL
96052 +vga_mm_r_23419 vga_mm_r 0 23419 NULL
96053 +vzalloc_node_23424 vzalloc_node 1 23424 NULL
96054 +__cxio_init_resource_fifo_23447 __cxio_init_resource_fifo 3 23447 NULL nohasharray
96055 +ocfs2_zero_tail_23447 ocfs2_zero_tail 3 23447 &__cxio_init_resource_fifo_23447
96056 +hidraw_send_report_23449 hidraw_send_report 3 23449 NULL
96057 +linear_conf_23485 linear_conf 2 23485 NULL nohasharray
96058 +divasa_remap_pci_bar_23485 divasa_remap_pci_bar 3-4 23485 &linear_conf_23485
96059 +event_filter_read_23494 event_filter_read 3 23494 NULL
96060 +ima_show_measurements_count_23536 ima_show_measurements_count 3 23536 NULL
96061 +xen_allocate_irq_gsi_23546 xen_allocate_irq_gsi 1-0 23546 NULL
96062 +tcp_current_mss_23552 tcp_current_mss 0 23552 NULL
96063 +dbg_leb_change_23555 dbg_leb_change 4 23555 NULL
96064 +venus_symlink_23570 venus_symlink 4-6 23570 NULL
96065 +iwl_dbgfs_interrupt_read_23574 iwl_dbgfs_interrupt_read 3 23574 NULL
96066 +snd_interval_min_23590 snd_interval_min 0 23590 NULL
96067 +_alloc_cdb_cont_23609 _alloc_cdb_cont 2 23609 NULL
96068 +islpci_mgt_transaction_23610 islpci_mgt_transaction 5 23610 NULL
96069 +__i2400mu_send_barker_23652 __i2400mu_send_barker 3 23652 NULL
96070 +ext3_compat_ioctl_23659 ext3_compat_ioctl 3 23659 NULL
96071 +sInW_23663 sInW 0 23663 NULL
96072 +proc_ioctl_compat_23682 proc_ioctl_compat 2 23682 NULL
96073 +nftl_partscan_23688 nftl_partscan 0 23688 NULL
96074 +cx18_read_23699 cx18_read 3 23699 NULL
96075 +mp_config_acpi_gsi_23728 mp_config_acpi_gsi 2 23728 NULL
96076 +pack_sg_list_p_23739 pack_sg_list_p 0-2 23739 NULL
96077 +rx_rx_dropped_frame_read_23748 rx_rx_dropped_frame_read 3 23748 NULL
96078 +__kfifo_max_r_23768 __kfifo_max_r 0-2-1 23768 NULL
96079 +security_inode_getxattr_23781 security_inode_getxattr 0 23781 NULL
96080 +diva_alloc_dma_map_23798 diva_alloc_dma_map 2 23798 NULL
96081 +rx_path_reset_read_23801 rx_path_reset_read 3 23801 NULL
96082 +__earlyonly_bootmem_alloc_23824 __earlyonly_bootmem_alloc 2 23824 NULL
96083 +xfs_dir2_leaf_getdents_23841 xfs_dir2_leaf_getdents 3 23841 NULL
96084 +iwl_dbgfs_nvm_read_23845 iwl_dbgfs_nvm_read 3 23845 NULL
96085 +p54_init_common_23850 p54_init_common 1 23850 NULL
96086 +gart_alloc_coherent_23852 gart_alloc_coherent 2 23852 NULL
96087 +bin_to_hex_dup_23853 bin_to_hex_dup 2 23853 NULL
96088 +ocfs2_xattr_get_clusters_23857 ocfs2_xattr_get_clusters 0 23857 NULL
96089 +ieee80211_if_read_dot11MeshMaxPeerLinks_23878 ieee80211_if_read_dot11MeshMaxPeerLinks 3 23878 NULL
96090 +ieee80211_if_read_channel_type_23884 ieee80211_if_read_channel_type 3 23884 NULL
96091 +nes_alloc_resource_23891 nes_alloc_resource 3 23891 NULL
96092 +tipc_snprintf_23893 tipc_snprintf 2 23893 NULL
96093 +add_new_gdb_meta_bg_23911 add_new_gdb_meta_bg 3 23911 NULL nohasharray
96094 +ieee80211_if_read_hw_queues_23911 ieee80211_if_read_hw_queues 3 23911 &add_new_gdb_meta_bg_23911
96095 +f2fs_getxattr_23917 f2fs_getxattr 0 23917 NULL
96096 +ipath_reg_phys_mr_23918 ipath_reg_phys_mr 3 23918 NULL nohasharray
96097 +mpihelp_mul_karatsuba_case_23918 mpihelp_mul_karatsuba_case 5-3 23918 &ipath_reg_phys_mr_23918
96098 +kvm_read_guest_23928 kvm_read_guest 4-2 23928 NULL
96099 +__alloc_skb_23940 __alloc_skb 1 23940 NULL
96100 +uvc_endpoint_max_bpi_23944 uvc_endpoint_max_bpi 0 23944 NULL
96101 +cifs_setxattr_23957 cifs_setxattr 4 23957 NULL
96102 +zd_usb_iowrite16v_async_23984 zd_usb_iowrite16v_async 3 23984 NULL
96103 +cxgb_alloc_mem_24007 cxgb_alloc_mem 1 24007 NULL
96104 +dgrp_send_24028 dgrp_send 0-2 24028 NULL
96105 +ocfs2_mark_extent_refcounted_24035 ocfs2_mark_extent_refcounted 6 24035 NULL
96106 +afs_cell_alloc_24052 afs_cell_alloc 2 24052 NULL
96107 +blkcipher_copy_iv_24075 blkcipher_copy_iv 3 24075 NULL
96108 +vb2_fop_read_24080 vb2_fop_read 3 24080 NULL
96109 +pipeline_post_proc_swi_read_24108 pipeline_post_proc_swi_read 3 24108 NULL
96110 +request_key_auth_read_24109 request_key_auth_read 3 24109 NULL
96111 +ieee80211_send_auth_24121 ieee80211_send_auth 5 24121 NULL
96112 +mpu401_read_24126 mpu401_read 3 24126 NULL
96113 +irnet_ctrl_write_24139 irnet_ctrl_write 3 24139 NULL
96114 +trim_bitmaps_24158 trim_bitmaps 3 24158 NULL
96115 +adu_read_24177 adu_read 3 24177 NULL
96116 +safe_prepare_write_buffer_24187 safe_prepare_write_buffer 3 24187 NULL
96117 +ieee80211_if_read_dot11MeshHWMPpreqMinInterval_24208 ieee80211_if_read_dot11MeshHWMPpreqMinInterval 3 24208 NULL
96118 +efx_vf_size_24213 efx_vf_size 0 24213 NULL
96119 +tcpprobe_sprint_24222 tcpprobe_sprint 0-2 24222 NULL
96120 +pcpu_embed_first_chunk_24224 pcpu_embed_first_chunk 1-2-3 24224 NULL nohasharray
96121 +mei_amthif_read_24224 mei_amthif_read 4 24224 &pcpu_embed_first_chunk_24224
96122 +pci_num_vf_24235 pci_num_vf 0 24235 NULL
96123 +sel_read_bool_24236 sel_read_bool 3 24236 NULL
96124 +compat_sys_preadv64_24283 compat_sys_preadv64 3 24283 NULL
96125 +msg_size_24288 msg_size 0 24288 NULL
96126 +ext2_free_blocks_24292 ext2_free_blocks 2-3 24292 NULL
96127 +map_page_24298 map_page 3-4 24298 NULL
96128 +btmrvl_pscmd_read_24308 btmrvl_pscmd_read 3 24308 NULL
96129 +ath6kl_add_bss_if_needed_24317 ath6kl_add_bss_if_needed 6 24317 NULL
96130 +ocfs2_direct_IO_get_blocks_24333 ocfs2_direct_IO_get_blocks 2 24333 NULL
96131 +kzalloc_node_24352 kzalloc_node 1 24352 NULL
96132 +qla2x00_handle_queue_full_24365 qla2x00_handle_queue_full 2 24365 NULL
96133 +cfi_read_pri_24366 cfi_read_pri 3 24366 NULL
96134 +btrfs_item_size_nr_24367 btrfs_item_size_nr 0 24367 NULL
96135 +igetword_24373 igetword 0 24373 NULL
96136 +pvr2_v4l2_ioctl_24398 pvr2_v4l2_ioctl 2 24398 NULL nohasharray
96137 +getxattr_24398 getxattr 4 24398 &pvr2_v4l2_ioctl_24398
96138 +blk_update_bidi_request_24415 blk_update_bidi_request 3-4 24415 NULL
96139 +b43_debugfs_read_24425 b43_debugfs_read 3 24425 NULL
96140 +ieee80211_rx_mgmt_beacon_24430 ieee80211_rx_mgmt_beacon 3 24430 NULL
96141 +ixgbe_alloc_q_vector_24439 ixgbe_alloc_q_vector 4-6 24439 NULL
96142 +smk_user_access_24440 smk_user_access 3 24440 NULL
96143 +page_address_24444 page_address 0 24444 NULL
96144 +evdev_do_ioctl_24459 evdev_do_ioctl 2 24459 NULL
96145 +ocfs2_write_cluster_by_desc_24466 ocfs2_write_cluster_by_desc 5-6 24466 NULL
96146 +pd_video_read_24510 pd_video_read 3 24510 NULL
96147 +request_key_with_auxdata_24515 request_key_with_auxdata 4 24515 NULL
96148 +xfs_buf_get_map_24522 xfs_buf_get_map 3 24522 NULL
96149 +named_prepare_buf_24532 named_prepare_buf 2 24532 NULL
96150 +do_mpage_readpage_24536 do_mpage_readpage 3 24536 NULL
96151 +write_cache_pages_24562 write_cache_pages 0 24562 NULL
96152 +tsi148_alloc_resource_24563 tsi148_alloc_resource 2 24563 NULL
96153 +udf_compute_nr_groups_24594 udf_compute_nr_groups 0 24594 NULL
96154 +palmas_smps_write_24600 palmas_smps_write 2 24600 NULL nohasharray
96155 +count_preds_24600 count_preds 0 24600 &palmas_smps_write_24600
96156 +sensor_hub_get_physical_device_count_24605 sensor_hub_get_physical_device_count 0 24605 NULL
96157 +context_alloc_24645 context_alloc 3 24645 NULL
96158 +blk_rq_err_bytes_24650 blk_rq_err_bytes 0 24650 NULL
96159 +unifi_net_data_malloc_24716 unifi_net_data_malloc 3 24716 NULL
96160 +simple_attr_read_24738 simple_attr_read 3 24738 NULL
96161 +qla2x00_change_queue_depth_24742 qla2x00_change_queue_depth 2 24742 NULL
96162 +ath_rxbuf_alloc_24745 ath_rxbuf_alloc 2 24745 NULL
96163 +get_dma_residue_24749 get_dma_residue 0 24749 NULL
96164 +kgdb_hex2mem_24755 kgdb_hex2mem 3 24755 NULL
96165 +nfsd4_sanitize_slot_size_24756 nfsd4_sanitize_slot_size 0-1 24756 NULL
96166 +i915_cache_sharing_read_24775 i915_cache_sharing_read 3 24775 NULL
96167 +ocfs2_read_blocks_24777 ocfs2_read_blocks 0 24777 NULL
96168 +skb_make_writable_24783 skb_make_writable 2 24783 NULL
96169 +datablob_hmac_verify_24786 datablob_hmac_verify 4 24786 NULL
96170 +cache_read_24790 cache_read 3 24790 NULL
96171 +unpack_str_24798 unpack_str 0 24798 NULL
96172 +__next_cpu_nr_24805 __next_cpu_nr 1 24805 NULL
96173 +comedi_buf_alloc_24822 comedi_buf_alloc 3 24822 NULL
96174 +snd_als4k_gcr_read_24840 snd_als4k_gcr_read 0 24840 NULL
96175 +snd_pcm_lib_buffer_bytes_24865 snd_pcm_lib_buffer_bytes 0 24865 NULL
96176 +pnp_alloc_24869 pnp_alloc 1 24869 NULL nohasharray
96177 +l2cap_create_basic_pdu_24869 l2cap_create_basic_pdu 3 24869 &pnp_alloc_24869
96178 +bnx2fc_cmd_mgr_alloc_24873 bnx2fc_cmd_mgr_alloc 3-2 24873 NULL
96179 +queues_read_24877 queues_read 3 24877 NULL
96180 +codec_list_read_file_24910 codec_list_read_file 3 24910 NULL
96181 +v4l2_ctrl_new_24927 v4l2_ctrl_new 7 24927 NULL
96182 +next_token_24929 next_token 0 24929 NULL
96183 +uf_create_device_nodes_24948 uf_create_device_nodes 2 24948 NULL
96184 +ocfs2_fiemap_24949 ocfs2_fiemap 3-4 24949 NULL
96185 +packet_sendmsg_24954 packet_sendmsg 4 24954 NULL
96186 +sys_rt_sigpending_24961 sys_rt_sigpending 2 24961 NULL
96187 +ensure_wear_leveling_24971 ensure_wear_leveling 0 24971 NULL
96188 +twl_i2c_write_u8_24976 twl_i2c_write_u8 3 24976 NULL
96189 +nf_nat_sdp_port_24977 nf_nat_sdp_port 7 24977 NULL
96190 +llc_ui_sendmsg_24987 llc_ui_sendmsg 4 24987 NULL
96191 +key_conf_hw_key_idx_read_25003 key_conf_hw_key_idx_read 3 25003 NULL
96192 +il_dbgfs_channels_read_25005 il_dbgfs_channels_read 3 25005 NULL
96193 +ni_660x_num_counters_25031 ni_660x_num_counters 0 25031 NULL
96194 +nfs_dns_resolve_name_25036 nfs_dns_resolve_name 3 25036 NULL
96195 +gs_buf_alloc_25067 gs_buf_alloc 2 25067 NULL
96196 +gfs2_iter_unstuffed_25099 gfs2_iter_unstuffed 0 25099 NULL
96197 +cxio_hal_init_rhdl_resource_25104 cxio_hal_init_rhdl_resource 1 25104 NULL
96198 +snd_rawmidi_kernel_write_25106 snd_rawmidi_kernel_write 3 25106 NULL
96199 +fs32_to_cpu_25143 fs32_to_cpu 0 25143 NULL
96200 +sys_fgetxattr_25166 sys_fgetxattr 4 25166 NULL
96201 +ipath_init_qp_table_25167 ipath_init_qp_table 2 25167 NULL
96202 +mmu_set_spte_25177 mmu_set_spte 8-9 25177 NULL
96203 +sctp_getsockopt_local_addrs_25178 sctp_getsockopt_local_addrs 2 25178 NULL
96204 +ks8851_rdreg32_25187 ks8851_rdreg32 0 25187 NULL
96205 +ocfs2_block_check_compute_25223 ocfs2_block_check_compute 2 25223 NULL
96206 +mon_stat_read_25238 mon_stat_read 3 25238 NULL
96207 +tcf_csum_ipv6_udp_25241 tcf_csum_ipv6_udp 4 25241 NULL
96208 +nilfs_palloc_find_available_slot_25245 nilfs_palloc_find_available_slot 3-5 25245 NULL
96209 +snd_pcm_start_25273 snd_pcm_start 0 25273 NULL
96210 +crypto_alloc_instance2_25277 crypto_alloc_instance2 3 25277 NULL
96211 +vfs_writev_25278 vfs_writev 3 25278 NULL
96212 +l2tp_session_create_25286 l2tp_session_create 1 25286 NULL
96213 +snd_seq_ioctl_compat_25307 snd_seq_ioctl_compat 3 25307 NULL
96214 +help_25316 help 5 25316 NULL nohasharray
96215 +ath9k_debugfs_read_buf_25316 ath9k_debugfs_read_buf 3 25316 &help_25316
96216 +i915_gem_execbuffer_relocate_slow_25355 i915_gem_execbuffer_relocate_slow 7 25355 NULL
96217 +rio_destid_next_25368 rio_destid_next 2 25368 NULL nohasharray
96218 +unix_mkname_25368 unix_mkname 0-2 25368 &rio_destid_next_25368
96219 +sel_read_mls_25369 sel_read_mls 3 25369 NULL
96220 +tc3589x_gpio_to_irq_25371 tc3589x_gpio_to_irq 2 25371 NULL
96221 +ebt_buf_add_pad_25413 ebt_buf_add_pad 0 25413 NULL
96222 +dai_list_read_file_25421 dai_list_read_file 3 25421 NULL
96223 +ath6kl_wmi_beginscan_cmd_25462 ath6kl_wmi_beginscan_cmd 8 25462 NULL
96224 +generic_file_buffered_write_25464 generic_file_buffered_write 4 25464 NULL
96225 +crypto_hash_digestsize_25469 crypto_hash_digestsize 0 25469 NULL
96226 +ocfs2_hamming_encode_25501 ocfs2_hamming_encode 3 25501 NULL
96227 +ivtv_buf_copy_from_user_25502 ivtv_buf_copy_from_user 4 25502 NULL
96228 +snd_pcm_plugin_build_25505 snd_pcm_plugin_build 5 25505 NULL
96229 +sb_permission_25523 sb_permission 0 25523 NULL
96230 +ext3_get_inode_loc_25542 ext3_get_inode_loc 0 25542 NULL
96231 +ieee80211_if_read_path_refresh_time_25545 ieee80211_if_read_path_refresh_time 3 25545 NULL
96232 +wimax_addr_scnprint_25548 wimax_addr_scnprint 2 25548 NULL
96233 +ht_print_chan_25556 ht_print_chan 0 25556 NULL
96234 +skb_tailroom_25567 skb_tailroom 0 25567 NULL
96235 +__devres_alloc_25598 __devres_alloc 2 25598 NULL
96236 +copy_user_generic_25611 copy_user_generic 0 25611 NULL
96237 +proc_coredump_filter_write_25625 proc_coredump_filter_write 3 25625 NULL
96238 +__get_user_pages_25628 __get_user_pages 0 25628 NULL nohasharray
96239 +befs_utf2nls_25628 befs_utf2nls 3 25628 &__get_user_pages_25628
96240 +__direct_map_25647 __direct_map 5-6 25647 NULL
96241 +ext2_try_to_allocate_25667 ext2_try_to_allocate 4-2 25667 NULL
96242 +aircable_prepare_write_buffer_25669 aircable_prepare_write_buffer 3 25669 NULL
96243 +sta_inactive_ms_read_25690 sta_inactive_ms_read 3 25690 NULL
96244 +ebitmap_start_positive_25703 ebitmap_start_positive 0 25703 NULL
96245 +rx_filter_mc_filter_read_25712 rx_filter_mc_filter_read 3 25712 NULL
96246 +ibmasm_new_command_25714 ibmasm_new_command 2 25714 NULL
96247 +sel_write_context_25726 sel_write_context 3 25726 NULL nohasharray
96248 +__alloc_bootmem_low_node_25726 __alloc_bootmem_low_node 2 25726 &sel_write_context_25726
96249 +mcs_unwrap_fir_25733 mcs_unwrap_fir 3 25733 NULL
96250 +ext2_find_near_25734 ext2_find_near 0 25734 NULL
96251 +cxgbi_device_portmap_create_25747 cxgbi_device_portmap_create 3 25747 NULL
96252 +event_rx_pool_read_25792 event_rx_pool_read 3 25792 NULL
96253 +sg_read_25799 sg_read 3 25799 NULL
96254 +sys32_rt_sigpending_25814 sys32_rt_sigpending 2 25814 NULL
96255 +system_enable_read_25815 system_enable_read 3 25815 NULL
96256 +realloc_buffer_25816 realloc_buffer 2 25816 NULL
96257 +pwr_missing_bcns_read_25824 pwr_missing_bcns_read 3 25824 NULL
96258 +parport_read_25855 parport_read 0 25855 NULL
96259 +xfs_dir2_sf_hdr_size_25858 xfs_dir2_sf_hdr_size 0 25858 NULL
96260 +uf_ap_process_data_pdu_25860 uf_ap_process_data_pdu 7 25860 NULL
96261 +ath6kl_regread_read_25884 ath6kl_regread_read 3 25884 NULL
96262 +run_delalloc_nocow_25896 run_delalloc_nocow 3 25896 NULL
96263 +sisusbcon_scroll_area_25899 sisusbcon_scroll_area 4-3 25899 NULL
96264 +lpfc_change_queue_depth_25905 lpfc_change_queue_depth 2 25905 NULL
96265 +do_jffs2_setxattr_25910 do_jffs2_setxattr 5 25910 NULL
96266 +utf16_strlen_25913 utf16_strlen 0 25913 NULL
96267 +rcname_read_25919 rcname_read 3 25919 NULL
96268 +snd_es1938_capture_copy_25930 snd_es1938_capture_copy 5 25930 NULL
96269 +key_flags_read_25931 key_flags_read 3 25931 NULL
96270 +copy_play_buf_25932 copy_play_buf 3 25932 NULL
96271 +tps80031_clr_bits_25942 tps80031_clr_bits 3 25942 NULL
96272 +flush_25957 flush 2 25957 NULL
96273 +video_register_device_25971 video_register_device 3 25971 NULL
96274 +udp_setsockopt_25985 udp_setsockopt 5 25985 NULL
96275 +ebt_compat_entry_padsize_26001 ebt_compat_entry_padsize 0 26001 NULL
96276 +lpfc_sli_probe_sriov_nr_virtfn_26004 lpfc_sli_probe_sriov_nr_virtfn 2 26004 NULL
96277 +mirror_status_26010 mirror_status 5 26010 NULL
96278 +irq_create_strict_mappings_26025 irq_create_strict_mappings 2-4 26025 NULL
96279 +xfs_xattr_acl_set_26028 xfs_xattr_acl_set 4 26028 NULL
96280 +skb_mac_header_26034 skb_mac_header 0 26034 NULL
96281 +mptscsih_change_queue_depth_26036 mptscsih_change_queue_depth 2 26036 NULL
96282 +selinux_inode_post_setxattr_26037 selinux_inode_post_setxattr 4 26037 NULL
96283 +tun_do_read_26047 tun_do_read 5 26047 NULL
96284 +keyctl_update_key_26061 keyctl_update_key 3 26061 NULL
96285 +rx_rx_wa_density_dropped_frame_read_26095 rx_rx_wa_density_dropped_frame_read 3 26095 NULL
96286 +cpumask_next_26096 cpumask_next 1 26096 NULL
96287 +skb_cow_26138 skb_cow 2 26138 NULL
96288 +usb_dump_device_strings_26146 usb_dump_device_strings 0 26146 NULL
96289 +__fswab64_26155 __fswab64 0 26155 NULL
96290 +copy_oldmem_page_26164 copy_oldmem_page 3-1 26164 NULL
96291 +ath6kl_roam_table_read_26166 ath6kl_roam_table_read 3 26166 NULL nohasharray
96292 +gfs2_xattr_acl_get_26166 gfs2_xattr_acl_get 0 26166 &ath6kl_roam_table_read_26166
96293 +mid_get_vbt_data_r1_26170 mid_get_vbt_data_r1 2 26170 NULL
96294 +disk_devt_26180 disk_devt 0 26180 NULL
96295 +get_registers_26187 get_registers 3 26187 NULL
96296 +cgroup_setxattr_26188 cgroup_setxattr 4 26188 NULL
96297 +ieee80211_if_fmt_dot11MeshTTL_26198 ieee80211_if_fmt_dot11MeshTTL 3 26198 NULL
96298 +xfs_idata_realloc_26199 xfs_idata_realloc 2 26199 NULL
96299 +mce_write_26201 mce_write 3 26201 NULL
96300 +_scsih_change_queue_depth_26230 _scsih_change_queue_depth 2 26230 NULL
96301 +cxio_num_stags_26233 cxio_num_stags 0 26233 NULL
96302 +bio_split_26235 bio_split 2 26235 NULL
96303 +crypto_ctxsize_26278 crypto_ctxsize 0 26278 NULL
96304 +wacom_set_device_mode_26280 wacom_set_device_mode 3 26280 NULL
96305 +ext2_find_goal_26306 ext2_find_goal 0 26306 NULL
96306 +snd_pcm_plug_client_channels_buf_26309 snd_pcm_plug_client_channels_buf 0-3 26309 NULL nohasharray
96307 +pax_get_random_long_26309 pax_get_random_long 0 26309 &snd_pcm_plug_client_channels_buf_26309
96308 +pwr_wake_on_host_read_26321 pwr_wake_on_host_read 3 26321 NULL
96309 +ocfs2_duplicate_clusters_by_page_26357 ocfs2_duplicate_clusters_by_page 5 26357 NULL
96310 +cifs_readdata_alloc_26360 cifs_readdata_alloc 1 26360 NULL
96311 +dup_to_netobj_26363 dup_to_netobj 3 26363 NULL
96312 +invalidate_inode_pages2_range_26403 invalidate_inode_pages2_range 0 26403 NULL
96313 +virtio_has_feature_26467 virtio_has_feature 0 26467 NULL
96314 +ib_alloc_device_26483 ib_alloc_device 1 26483 NULL
96315 +ulong_write_file_26485 ulong_write_file 3 26485 NULL
96316 +dvb_ca_en50221_io_ioctl_26490 dvb_ca_en50221_io_ioctl 2 26490 NULL
96317 +read_vmcore_26501 read_vmcore 3 26501 NULL
96318 +vfio_pci_set_msi_trigger_26507 vfio_pci_set_msi_trigger 3-4 26507 NULL
96319 +iwl_dbgfs_rf_reset_read_26512 iwl_dbgfs_rf_reset_read 3 26512 NULL
96320 +rds_message_inc_copy_to_user_26540 rds_message_inc_copy_to_user 3 26540 NULL
96321 +__vhost_add_used_n_26554 __vhost_add_used_n 3 26554 NULL
96322 +ip6_addr_string_26568 ip6_addr_string 0 26568 NULL
96323 +rts51x_read_mem_26577 rts51x_read_mem 4 26577 NULL nohasharray
96324 +batadv_receive_server_sync_packet_26577 batadv_receive_server_sync_packet 3 26577 &rts51x_read_mem_26577
96325 +cirrusfb_get_memsize_26597 cirrusfb_get_memsize 0 26597 NULL
96326 +__unmap_single_26604 __unmap_single 2-3 26604 NULL
96327 +iommu_alloc_26621 iommu_alloc 4 26621 NULL
96328 +pwr_fix_tsf_ps_read_26627 pwr_fix_tsf_ps_read 3 26627 NULL
96329 +mmap_region_26649 mmap_region 0-2 26649 NULL
96330 +irq_alloc_generic_chip_26650 irq_alloc_generic_chip 2 26650 NULL nohasharray
96331 +inb_p_26650 inb_p 0 26650 &irq_alloc_generic_chip_26650
96332 +cipso_v4_map_cat_rbm_hton_26680 cipso_v4_map_cat_rbm_hton 0 26680 NULL
96333 +__alloc_pred_stack_26687 __alloc_pred_stack 2 26687 NULL
96334 +rtllib_authentication_req_26713 rtllib_authentication_req 3 26713 NULL
96335 +aty_ld_le32_26720 aty_ld_le32 0 26720 NULL
96336 +nouveau_namedb_create__26732 nouveau_namedb_create_ 7 26732 NULL
96337 +pipeline_tcp_rx_stat_fifo_int_read_26745 pipeline_tcp_rx_stat_fifo_int_read 3 26745 NULL
96338 +srp_ring_alloc_26760 srp_ring_alloc 2 26760 NULL
96339 +snd_hda_get_raw_connections_26762 snd_hda_get_raw_connections 0 26762 NULL
96340 +ntfs_are_rl_mergeable_26777 ntfs_are_rl_mergeable 0 26777 NULL
96341 +qlcnic_alloc_sds_rings_26795 qlcnic_alloc_sds_rings 2 26795 NULL
96342 +cipso_v4_genopt_26812 cipso_v4_genopt 0 26812 NULL
96343 +smk_write_load_26829 smk_write_load 3 26829 NULL
96344 +slgt_compat_ioctl_26834 slgt_compat_ioctl 3 26834 NULL
96345 +__nodes_onto_26838 __nodes_onto 4 26838 NULL
96346 +scnprint_id_26842 scnprint_id 3 26842 NULL
96347 +ecryptfs_miscdev_write_26847 ecryptfs_miscdev_write 3 26847 NULL
96348 +netxen_nic_hw_read_wx_128M_26858 netxen_nic_hw_read_wx_128M 2 26858 NULL
96349 +svc_print_xprts_26881 svc_print_xprts 0 26881 NULL
96350 +ext2_compat_ioctl_26883 ext2_compat_ioctl 3 26883 NULL
96351 +slhc_uncompress_26905 slhc_uncompress 0-3 26905 NULL
96352 +wm8994_reg_write_26919 wm8994_reg_write 2 26919 NULL
96353 +x25_asy_change_mtu_26928 x25_asy_change_mtu 2 26928 NULL
96354 +compat_mtw_from_user_26932 compat_mtw_from_user 0 26932 NULL
96355 +scsi_tgt_copy_sense_26933 scsi_tgt_copy_sense 3 26933 NULL
96356 +pwr_ps_enter_read_26935 pwr_ps_enter_read 3 26935 NULL nohasharray
96357 +sctp_setsockopt_adaptation_layer_26935 sctp_setsockopt_adaptation_layer 3 26935 &pwr_ps_enter_read_26935
96358 +carl9170_handle_mpdu_26940 carl9170_handle_mpdu 3 26940 NULL nohasharray
96359 +create_bm_block_list_26940 create_bm_block_list 0 26940 &carl9170_handle_mpdu_26940
96360 +hecubafb_write_26942 hecubafb_write 3 26942 NULL
96361 +extract_entropy_user_26952 extract_entropy_user 3 26952 NULL nohasharray
96362 +do_trimming_26952 do_trimming 3 26952 &extract_entropy_user_26952
96363 +pcf857x_irq_domain_map_26998 pcf857x_irq_domain_map 2 26998 NULL
96364 +rbd_do_op_27025 rbd_do_op 7-8 27025 NULL
96365 +ufs_alloc_fragments_27059 ufs_alloc_fragments 3-0-2 27059 NULL
96366 +__videobuf_alloc_vb_27062 __videobuf_alloc_vb 1 27062 NULL
96367 +snd_pcm_lib_period_bytes_27071 snd_pcm_lib_period_bytes 0 27071 NULL
96368 +paravirt_read_msr_27077 paravirt_read_msr 0 27077 NULL
96369 +alloc_fdmem_27083 alloc_fdmem 1 27083 NULL
96370 +find_first_bit_27088 find_first_bit 0-2 27088 NULL
96371 +btmrvl_hscmd_write_27089 btmrvl_hscmd_write 3 27089 NULL
96372 +__devcgroup_inode_permission_27108 __devcgroup_inode_permission 0 27108 NULL
96373 +get_kernel_page_27133 get_kernel_page 0 27133 NULL
96374 +drbd_get_capacity_27141 drbd_get_capacity 0 27141 NULL
96375 +pms_capture_27142 pms_capture 4 27142 NULL
96376 +btmrvl_hscfgcmd_write_27143 btmrvl_hscfgcmd_write 3 27143 NULL
96377 +snd_compr_calc_avail_27165 snd_compr_calc_avail 0 27165 NULL
96378 +mc13xxx_irq_handle_27166 mc13xxx_irq_handle 3 27166 NULL
96379 +i2400m_net_rx_27170 i2400m_net_rx 5 27170 NULL
96380 +ieee80211_if_read_rc_rateidx_mask_5ghz_27183 ieee80211_if_read_rc_rateidx_mask_5ghz 3 27183 NULL
96381 +get_unaligned_be32_27184 get_unaligned_be32 0 27184 NULL
96382 +mmc_blk_compat_ioctl_27194 mmc_blk_compat_ioctl 4 27194 NULL
96383 +dbAllocAG_27228 dbAllocAG 0 27228 NULL
96384 +rxrpc_request_key_27235 rxrpc_request_key 3 27235 NULL
96385 +cfpkt_add_trail_27260 cfpkt_add_trail 3 27260 NULL
96386 +__dma_map_cont_27289 __dma_map_cont 5 27289 NULL
96387 +hpi_read_reg_27302 hpi_read_reg 0 27302 NULL
96388 +copy_from_buf_27308 copy_from_buf 4-2 27308 NULL
96389 +ath6kl_wmi_test_cmd_27312 ath6kl_wmi_test_cmd 3 27312 NULL
96390 +rbd_req_sync_exec_27320 rbd_req_sync_exec 8 27320 NULL
96391 +ocfs2_blocks_to_clusters_27327 ocfs2_blocks_to_clusters 0-2 27327 NULL
96392 +snd_pcm_oss_write2_27332 snd_pcm_oss_write2 3-0 27332 NULL
96393 +afs_cell_create_27346 afs_cell_create 2 27346 NULL
96394 +pcbit_stat_27364 pcbit_stat 2 27364 NULL
96395 +init_memory_mapping_27395 init_memory_mapping 0 27395 NULL
96396 +phys_pte_init_27411 phys_pte_init 0-3-2 27411 NULL
96397 +ib_dma_map_sg_27413 ib_dma_map_sg 0 27413 NULL
96398 +acpi_os_get_root_pointer_27416 acpi_os_get_root_pointer 0 27416 NULL nohasharray
96399 +ieee80211_if_read_smps_27416 ieee80211_if_read_smps 3 27416 &acpi_os_get_root_pointer_27416
96400 +pack_sg_list_27425 pack_sg_list 0-2 27425 NULL
96401 +tps65910_reg_set_bits_27468 tps65910_reg_set_bits 2 27468 NULL
96402 +rtsx_write_cfg_seq_27485 rtsx_write_cfg_seq 5-3 27485 NULL
96403 +v4l2_ctrl_new_std_menu_items_27487 v4l2_ctrl_new_std_menu_items 4 27487 NULL
96404 +set_tpl_pfs_27490 set_tpl_pfs 3 27490 NULL
96405 +hcd_buffer_alloc_27495 hcd_buffer_alloc 2 27495 NULL
96406 +qib_create_cq_27497 qib_create_cq 2 27497 NULL
96407 +ip_set_get_h32_27498 ip_set_get_h32 0 27498 NULL
96408 +btrfs_get_64_27499 btrfs_get_64 0 27499 NULL
96409 +__usbnet_write_cmd_27500 __usbnet_write_cmd 7 27500 NULL
96410 +garmin_read_process_27509 garmin_read_process 3 27509 NULL
96411 +ib_copy_to_udata_27525 ib_copy_to_udata 3 27525 NULL
96412 +snd_sonicvibes_getdmaa_27552 snd_sonicvibes_getdmaa 0 27552 NULL
96413 +libipw_alloc_txb_27579 libipw_alloc_txb 1-2-3 27579 NULL
96414 +read_flush_procfs_27642 read_flush_procfs 3 27642 NULL nohasharray
96415 +nl80211_send_connect_result_27642 nl80211_send_connect_result 5-7 27642 &read_flush_procfs_27642 nohasharray
96416 +ocfs2_xattr_ibody_get_27642 ocfs2_xattr_ibody_get 0 27642 &nl80211_send_connect_result_27642
96417 +add_new_gdb_27643 add_new_gdb 3 27643 NULL
96418 +qnx6_readpages_27657 qnx6_readpages 4 27657 NULL
96419 +cdrom_read_cdda_old_27664 cdrom_read_cdda_old 4 27664 NULL
96420 +set_bypass_pwoff_pfs_27669 set_bypass_pwoff_pfs 3 27669 NULL
96421 +qword_get_27670 qword_get 0 27670 NULL
96422 +ocfs2_extend_dir_27695 ocfs2_extend_dir 4 27695 NULL
96423 +__tty_buffer_request_room_27700 __tty_buffer_request_room 2 27700 NULL
96424 +fs_path_add_from_extent_buffer_27702 fs_path_add_from_extent_buffer 4 27702 NULL
96425 +evm_write_key_27715 evm_write_key 3 27715 NULL
96426 +ieee80211_if_fmt_dot11MeshGateAnnouncementProtocol_27722 ieee80211_if_fmt_dot11MeshGateAnnouncementProtocol 3 27722 NULL
96427 +reg_w_buf_27724 reg_w_buf 3 27724 NULL
96428 +xfs_dir2_block_sfsize_27727 xfs_dir2_block_sfsize 0 27727 NULL
96429 +a4t_cs_init_27734 a4t_cs_init 3 27734 NULL
96430 +kcalloc_27770 kcalloc 1-2 27770 NULL
96431 +twl4030_set_gpio_dataout_27792 twl4030_set_gpio_dataout 1 27792 NULL
96432 +DivaSTraceGetMemotyRequirement_27797 DivaSTraceGetMemotyRequirement 0-1 27797 NULL
96433 +ttm_object_file_init_27804 ttm_object_file_init 2 27804 NULL
96434 +mpihelp_mul_27805 mpihelp_mul 5-3 27805 NULL
96435 +fwtty_buffer_rx_27821 fwtty_buffer_rx 3 27821 NULL
96436 +init_header_complete_27833 init_header_complete 0 27833 NULL nohasharray
96437 +sys_listxattr_27833 sys_listxattr 3 27833 &init_header_complete_27833
96438 +read_profile_27859 read_profile 3 27859 NULL
96439 +sky2_pci_read16_27863 sky2_pci_read16 0 27863 NULL
96440 +ieee80211_if_read_dot11MeshHWMProotInterval_27873 ieee80211_if_read_dot11MeshHWMProotInterval 3 27873 NULL
96441 +unix_seqpacket_sendmsg_27893 unix_seqpacket_sendmsg 4 27893 NULL
96442 +gluebi_write_27905 gluebi_write 3 27905 NULL
96443 +mc13783_set_sysclk_27914 mc13783_set_sysclk 5 27914 NULL
96444 +bm_find_next_27929 bm_find_next 2 27929 NULL
96445 +tracing_clock_write_27961 tracing_clock_write 3 27961 NULL
96446 +tipc_media_addr_printf_27971 tipc_media_addr_printf 2 27971 NULL
96447 +mic_rx_pkts_read_27972 mic_rx_pkts_read 3 27972 NULL
96448 +f2fs_bio_alloc_27983 f2fs_bio_alloc 2 27983 NULL
96449 +edt_ft5x06_debugfs_raw_data_read_28002 edt_ft5x06_debugfs_raw_data_read 3 28002 NULL
96450 +snd_rawmidi_write_28008 snd_rawmidi_write 3 28008 NULL
96451 +serial8250_port_size_28019 serial8250_port_size 0 28019 NULL
96452 +sctp_setsockopt_maxburst_28041 sctp_setsockopt_maxburst 3 28041 NULL
96453 +rts51x_xd_rw_28046 rts51x_xd_rw 3-4 28046 NULL
96454 +cx231xx_init_vbi_isoc_28053 cx231xx_init_vbi_isoc 3-2 28053 NULL
96455 +lpfc_idiag_mbxacc_read_28061 lpfc_idiag_mbxacc_read 3 28061 NULL
96456 +tx_frag_bad_mblk_num_read_28064 tx_frag_bad_mblk_num_read 3 28064 NULL
96457 +ext4_read_block_bitmap_nowait_28078 ext4_read_block_bitmap_nowait 2 28078 NULL
96458 +GetRecvByte_28082 GetRecvByte 0 28082 NULL
96459 +platform_get_irq_28088 platform_get_irq 0 28088 NULL
96460 +gdth_init_isa_28091 gdth_init_isa 1 28091 NULL
96461 +mmc_test_alloc_mem_28102 mmc_test_alloc_mem 3-2 28102 NULL
96462 +rx_defrag_need_defrag_read_28117 rx_defrag_need_defrag_read 3 28117 NULL
96463 +vgacon_adjust_height_28124 vgacon_adjust_height 2 28124 NULL
96464 +video_read_28148 video_read 3 28148 NULL
96465 +snd_midi_channel_alloc_set_28153 snd_midi_channel_alloc_set 1 28153 NULL
96466 +stats_dot11FCSErrorCount_read_28154 stats_dot11FCSErrorCount_read 3 28154 NULL
96467 +vread_28173 vread 0 28173 NULL
96468 +macvtap_get_user_28185 macvtap_get_user 4 28185 NULL
96469 +d_path_28198 d_path 0 28198 NULL
96470 +nouveau_mxm_create__28200 nouveau_mxm_create_ 4 28200 NULL
96471 +line6_alloc_sysex_buffer_28225 line6_alloc_sysex_buffer 4 28225 NULL nohasharray
96472 +set_dis_disc_pfs_28225 set_dis_disc_pfs 3 28225 &line6_alloc_sysex_buffer_28225
96473 +amd_nb_num_28228 amd_nb_num 0 28228 NULL
96474 +ext4_validate_block_bitmap_28243 ext4_validate_block_bitmap 3 28243 NULL
96475 +usemap_size_28281 usemap_size 0 28281 NULL
96476 +dma_map_sg_attrs_28289 dma_map_sg_attrs 0 28289 NULL
96477 +acpi_register_gsi_xen_28305 acpi_register_gsi_xen 2 28305 NULL nohasharray
96478 +nouveau_compat_ioctl_28305 nouveau_compat_ioctl 2 28305 &acpi_register_gsi_xen_28305
96479 +snd_pcm_oss_read_28317 snd_pcm_oss_read 3 28317 NULL
96480 +bm_entry_write_28338 bm_entry_write 3 28338 NULL
96481 +snapshot_write_28351 snapshot_write 3 28351 NULL
96482 +__next_wq_cpu_28352 __next_wq_cpu 1 28352 NULL
96483 +sys_writev_28384 sys_writev 3 28384 NULL
96484 +dlmfs_file_read_28385 dlmfs_file_read 3 28385 NULL
96485 +tx_frag_cache_miss_read_28394 tx_frag_cache_miss_read 3 28394 NULL
96486 +set_bypass_pfs_28395 set_bypass_pfs 3 28395 NULL
96487 +subdev_ioctl_28417 subdev_ioctl 2 28417 NULL
96488 +mpage_readpages_28436 mpage_readpages 3 28436 NULL
96489 +snd_emu10k1_efx_read_28452 snd_emu10k1_efx_read 2 28452 NULL
96490 +key_mic_failures_read_28457 key_mic_failures_read 3 28457 NULL
96491 +alloc_irq_cpu_rmap_28459 alloc_irq_cpu_rmap 1 28459 NULL
96492 +vmw_du_crtc_cursor_set_28479 vmw_du_crtc_cursor_set 4-5 28479 NULL
96493 +ocfs2_backup_super_blkno_28484 ocfs2_backup_super_blkno 0-2 28484 NULL
96494 +max_response_pages_28492 max_response_pages 0 28492 NULL
96495 +ps_poll_upsd_utilization_read_28519 ps_poll_upsd_utilization_read 3 28519 NULL
96496 +__next_node_28521 __next_node 1 28521 NULL
96497 +i2400m_tx_stats_read_28527 i2400m_tx_stats_read 3 28527 NULL
96498 +early_init_dt_alloc_memory_arch_28528 early_init_dt_alloc_memory_arch 1 28528 NULL
96499 +sel_read_policycap_28544 sel_read_policycap 3 28544 NULL
96500 +run_delalloc_range_28545 run_delalloc_range 3 28545 NULL nohasharray
96501 +mptctl_getiocinfo_28545 mptctl_getiocinfo 2 28545 &run_delalloc_range_28545
96502 +b43legacy_debugfs_write_28556 b43legacy_debugfs_write 3 28556 NULL
96503 +i2o_msg_post_wait_mem_28558 i2o_msg_post_wait_mem 0 28558 NULL
96504 +phys_pud_init_28574 phys_pud_init 0-3-2 28574 NULL
96505 +cfg80211_send_rx_auth_28580 cfg80211_send_rx_auth 3 28580 NULL
96506 +oxygen_read32_28582 oxygen_read32 0 28582 NULL
96507 +ocfs2_read_dir_block_28587 ocfs2_read_dir_block 2 28587 NULL
96508 +wm8350_clear_bits_28596 wm8350_clear_bits 2 28596 NULL
96509 +extract_entropy_28604 extract_entropy 3-5 28604 NULL
96510 +kfifo_unused_28612 kfifo_unused 0 28612 NULL
96511 +mp_override_legacy_irq_28618 mp_override_legacy_irq 4 28618 NULL
96512 +snd_nm256_capture_copy_28622 snd_nm256_capture_copy 5-3 28622 NULL
96513 +_set_range_28627 _set_range 3 28627 NULL
96514 +v4l2_compat_ioctl32_28630 v4l2_compat_ioctl32 3 28630 NULL
96515 +setup_usemap_28636 setup_usemap 3-4 28636 NULL
96516 +blk_queue_resize_tags_28670 blk_queue_resize_tags 2 28670 NULL
96517 +__dev_alloc_skb_28681 __dev_alloc_skb 1 28681 NULL
96518 +nl80211_send_new_peer_candidate_28692 nl80211_send_new_peer_candidate 5 28692 NULL nohasharray
96519 +kvm_mmu_get_page_28692 kvm_mmu_get_page 2 28692 &nl80211_send_new_peer_candidate_28692
96520 +drm_plane_init_28731 drm_plane_init 6 28731 NULL
96521 +spi_execute_28736 spi_execute 5 28736 NULL
96522 +snd_pcm_aio_write_28738 snd_pcm_aio_write 3 28738 NULL nohasharray
96523 +phantom_compat_ioctl_28738 phantom_compat_ioctl 3 28738 &snd_pcm_aio_write_28738
96524 +read_file_btcoex_28743 read_file_btcoex 3 28743 NULL
96525 +cxio_init_resource_fifo_28764 cxio_init_resource_fifo 3 28764 NULL
96526 +ath6kl_get_num_reg_28780 ath6kl_get_num_reg 0 28780 NULL
96527 +dvb_net_sec_callback_28786 dvb_net_sec_callback 2 28786 NULL
96528 +sel_write_member_28800 sel_write_member 3 28800 NULL
96529 +cgroup_file_read_28804 cgroup_file_read 3 28804 NULL
96530 +btrfs_ref_to_path_28809 btrfs_ref_to_path 0-8-3 28809 NULL
96531 +memory_bm_create_28814 memory_bm_create 0 28814 NULL
96532 +iwl_dbgfs_rxon_filter_flags_read_28832 iwl_dbgfs_rxon_filter_flags_read 3 28832 NULL
96533 +vp_request_msix_vectors_28849 vp_request_msix_vectors 2 28849 NULL
96534 +ipv6_renew_options_28867 ipv6_renew_options 5 28867 NULL
96535 +packet_sendmsg_spkt_28885 packet_sendmsg_spkt 4 28885 NULL
96536 +tps6586x_update_28898 tps6586x_update 2 28898 NULL
96537 +da9055_group_write_28904 da9055_group_write 2-3 28904 NULL
96538 +ps_upsd_timeouts_read_28924 ps_upsd_timeouts_read 3 28924 NULL
96539 +ocfs2_frozen_trigger_28929 ocfs2_frozen_trigger 4 28929 NULL
96540 +push_rx_28939 push_rx 3 28939 NULL
96541 +btrfs_trim_block_group_28963 btrfs_trim_block_group 3 28963 NULL
96542 +alloc_sched_domains_28972 alloc_sched_domains 1 28972 NULL
96543 +ext4_mb_add_groupinfo_28988 ext4_mb_add_groupinfo 2 28988 NULL
96544 +bin_uuid_28999 bin_uuid 3 28999 NULL
96545 +xz_dec_init_29029 xz_dec_init 2 29029 NULL
96546 +sys_fcntl64_29031 sys_fcntl64 3 29031 NULL
96547 +ieee80211_if_read_ht_opmode_29044 ieee80211_if_read_ht_opmode 3 29044 NULL
96548 +rxrpc_sendmsg_29049 rxrpc_sendmsg 4 29049 NULL
96549 +iso_packets_buffer_init_29061 iso_packets_buffer_init 3-4 29061 NULL
96550 +lpfc_idiag_extacc_drivr_get_29067 lpfc_idiag_extacc_drivr_get 0-3 29067 NULL
96551 +ieee80211_probereq_get_29069 ieee80211_probereq_get 4-6 29069 NULL
96552 +sctp_getsockopt_assoc_stats_29074 sctp_getsockopt_assoc_stats 2 29074 NULL
96553 +mark_extents_written_29082 mark_extents_written 2 29082 NULL
96554 +isdn_ppp_write_29109 isdn_ppp_write 4 29109 NULL
96555 +snprintf_29125 snprintf 0 29125 NULL
96556 +iov_shorten_29130 iov_shorten 0 29130 NULL
96557 +pm860x_reg_write_29141 pm860x_reg_write 2 29141 NULL
96558 +proc_scsi_write_29142 proc_scsi_write 3 29142 NULL
96559 +reshape_ring_29147 reshape_ring 2 29147 NULL
96560 +drm_property_create_enum_29201 drm_property_create_enum 5 29201 NULL
96561 +wusb_prf_256_29203 wusb_prf_256 7 29203 NULL nohasharray
96562 +alloc_group_attrs_29203 alloc_group_attrs 3 29203 &wusb_prf_256_29203
96563 +comedi_alloc_subdevices_29207 comedi_alloc_subdevices 2 29207 NULL
96564 +do_shrinker_shrink_29208 do_shrinker_shrink 0 29208 NULL
96565 +rds_iw_inc_copy_to_user_29214 rds_iw_inc_copy_to_user 3 29214 NULL
96566 +iwl_dbgfs_temperature_read_29224 iwl_dbgfs_temperature_read 3 29224 NULL
96567 +devm_ioremap_29235 devm_ioremap 2-3 29235 NULL
96568 +irq_domain_add_linear_29236 irq_domain_add_linear 2 29236 NULL
96569 +recover_peb_29238 recover_peb 6-7 29238 NULL
96570 +security_context_to_sid_core_29248 security_context_to_sid_core 2 29248 NULL
96571 +prism2_set_genericelement_29277 prism2_set_genericelement 3 29277 NULL
96572 +bitmap_ord_to_pos_29279 bitmap_ord_to_pos 3 29279 NULL
96573 +sn9c102_read_29305 sn9c102_read 3 29305 NULL
96574 +fd_do_writev_29329 fd_do_writev 3 29329 NULL
96575 +lo_compat_ioctl_29336 lo_compat_ioctl 4 29336 NULL
96576 +tun_put_user_29337 tun_put_user 5 29337 NULL
96577 +__alloc_ei_netdev_29338 __alloc_ei_netdev 1 29338 NULL
96578 +alloc_and_copy_ftrace_hash_29368 alloc_and_copy_ftrace_hash 1 29368 NULL
96579 +mwifiex_cfg80211_mgmt_tx_29387 mwifiex_cfg80211_mgmt_tx 7 29387 NULL
96580 +pca953x_irq_setup_29407 pca953x_irq_setup 3 29407 NULL
96581 +mempool_create_29437 mempool_create 1 29437 NULL
96582 +crypto_ahash_alignmask_29445 crypto_ahash_alignmask 0 29445 NULL
96583 +apei_exec_ctx_get_output_29457 apei_exec_ctx_get_output 0 29457 NULL
96584 +validate_scan_freqs_29462 validate_scan_freqs 0 29462 NULL
96585 +do_register_entry_29478 do_register_entry 4 29478 NULL
96586 +simple_strtoul_29480 simple_strtoul 0 29480 NULL
96587 +btmrvl_pscmd_write_29504 btmrvl_pscmd_write 3 29504 NULL
96588 +btrfs_file_extent_disk_bytenr_29505 btrfs_file_extent_disk_bytenr 0 29505 NULL
96589 +atk_debugfs_ggrp_read_29522 atk_debugfs_ggrp_read 3 29522 NULL
96590 +ftrace_write_29551 ftrace_write 3 29551 NULL
96591 +idetape_queue_rw_tail_29562 idetape_queue_rw_tail 3 29562 NULL
96592 +leaf_dealloc_29566 leaf_dealloc 3 29566 NULL nohasharray
96593 +alloc_empty_pages_29566 alloc_empty_pages 2 29566 &leaf_dealloc_29566
96594 +lbs_lowsnr_read_29571 lbs_lowsnr_read 3 29571 NULL
96595 +pvr2_hdw_report_unlocked_29589 pvr2_hdw_report_unlocked 4 29589 NULL
96596 +wm8903_gpio_set_29597 wm8903_gpio_set 2 29597 NULL
96597 +slots_per_page_29601 slots_per_page 0 29601 NULL
96598 +qla4_82xx_pci_set_window_29605 qla4_82xx_pci_set_window 0-2 29605 NULL
96599 +nla_get_u16_29624 nla_get_u16 0 29624 NULL
96600 +tx_frag_cache_hit_read_29639 tx_frag_cache_hit_read 3 29639 NULL
96601 +lowmem_page_address_29649 lowmem_page_address 0 29649 NULL
96602 +sctp_make_abort_user_29654 sctp_make_abort_user 3 29654 NULL
96603 +br_send_bpdu_29669 br_send_bpdu 3 29669 NULL
96604 +sisusb_write_mem_bulk_29678 sisusb_write_mem_bulk 4 29678 NULL
96605 +sd_alloc_ctl_entry_29708 sd_alloc_ctl_entry 1 29708 NULL nohasharray
96606 +posix_acl_from_xattr_29708 posix_acl_from_xattr 3 29708 &sd_alloc_ctl_entry_29708
96607 +probes_write_29711 probes_write 3 29711 NULL
96608 +emi62_writememory_29731 emi62_writememory 4 29731 NULL
96609 +read_cis_cache_29735 read_cis_cache 4 29735 NULL
96610 +da9055_gpio_direction_input_29742 da9055_gpio_direction_input 2 29742 NULL
96611 +cxio_hal_init_resource_29771 cxio_hal_init_resource 2-6-7 29771 NULL nohasharray
96612 +ip_vs_conn_fill_param_sync_29771 ip_vs_conn_fill_param_sync 6 29771 &cxio_hal_init_resource_29771
96613 +dbAlloc_29794 dbAlloc 0 29794 NULL
96614 +ext4_trim_all_free_29806 ext4_trim_all_free 4-3-2 29806 NULL
96615 +arizona_gpio_set_29823 arizona_gpio_set 2 29823 NULL
96616 +tcp_sendpage_29829 tcp_sendpage 4 29829 NULL
96617 +scan_bitmap_block_29840 scan_bitmap_block 4 29840 NULL
96618 +__probe_kernel_write_29842 __probe_kernel_write 3 29842 NULL
96619 +kvm_read_hva_atomic_29848 kvm_read_hva_atomic 3 29848 NULL
96620 +ipv6_setsockopt_29871 ipv6_setsockopt 5 29871 NULL
96621 +scsi_end_request_29876 scsi_end_request 3 29876 NULL
96622 +crypto_aead_alignmask_29885 crypto_aead_alignmask 0 29885 NULL
96623 +nfc_targets_found_29886 nfc_targets_found 3 29886 NULL
96624 +tps6586x_write_29894 tps6586x_write 2 29894 NULL
96625 +check586_29914 check586 2 29914 NULL
96626 +ext4_xattr_set_acl_29930 ext4_xattr_set_acl 4 29930 NULL
96627 +__btrfs_getxattr_29947 __btrfs_getxattr 0 29947 NULL
96628 +irias_add_octseq_attrib_29983 irias_add_octseq_attrib 4 29983 NULL nohasharray
96629 +diva_os_get_context_size_29983 diva_os_get_context_size 0 29983 &irias_add_octseq_attrib_29983
96630 +arch_setup_dmar_msi_29992 arch_setup_dmar_msi 1 29992 NULL
96631 +utf32_to_utf8_30028 utf32_to_utf8 0 30028 NULL
96632 +alloc_netdev_mqs_30030 alloc_netdev_mqs 1 30030 NULL
96633 +scsi_vpd_inquiry_30040 scsi_vpd_inquiry 4 30040 NULL
96634 +drp_wmove_30043 drp_wmove 4 30043 NULL
96635 +cxgbi_ddp_reserve_30091 cxgbi_ddp_reserve 4 30091 NULL
96636 +snd_midi_channel_init_set_30092 snd_midi_channel_init_set 1 30092 NULL
96637 +tg3_run_loopback_30093 tg3_run_loopback 2 30093 NULL
96638 +rx_filter_data_filter_read_30098 rx_filter_data_filter_read 3 30098 NULL
96639 +skb_pagelen_30113 skb_pagelen 0 30113 NULL
96640 +spi_async_locked_30117 spi_async_locked 0 30117 NULL
96641 +calgary_unmap_page_30130 calgary_unmap_page 2-3 30130 NULL
96642 +_osd_req_sizeof_alist_header_30134 _osd_req_sizeof_alist_header 0 30134 NULL
96643 +u_memcpya_30139 u_memcpya 2-3 30139 NULL
96644 +cx25821_video_ioctl_30188 cx25821_video_ioctl 2 30188 NULL
96645 +mempool_create_page_pool_30189 mempool_create_page_pool 1 30189 NULL
96646 +drm_property_create_bitmask_30195 drm_property_create_bitmask 5 30195 NULL
96647 +snd_pcm_playback_forward_30201 snd_pcm_playback_forward 0-2 30201 NULL
96648 +usblp_ioctl_30203 usblp_ioctl 2 30203 NULL
96649 +nfs_idmap_request_key_30208 nfs_idmap_request_key 3 30208 NULL
96650 +read_4k_modal_eeprom_30212 read_4k_modal_eeprom 3 30212 NULL
96651 +snd_ac97_pcm_assign_30218 snd_ac97_pcm_assign 2 30218 NULL
96652 +isr_pci_pm_read_30271 isr_pci_pm_read 3 30271 NULL
96653 +compat_readv_30273 compat_readv 3 30273 NULL
96654 +lapic_register_intr_30279 lapic_register_intr 1 30279 NULL
96655 +__be64_to_cpup_30283 __be64_to_cpup 0 30283 NULL
96656 +skcipher_sendmsg_30290 skcipher_sendmsg 4 30290 NULL
96657 +pipeline_sec_frag_swi_read_30294 pipeline_sec_frag_swi_read 3 30294 NULL
96658 +tcp_sendmsg_30296 tcp_sendmsg 4 30296 NULL
96659 +ext4_acl_from_disk_30320 ext4_acl_from_disk 2 30320 NULL
96660 +generic_ptrace_pokedata_30338 generic_ptrace_pokedata 2 30338 NULL
96661 +resource_from_user_30341 resource_from_user 3 30341 NULL
96662 +__vmalloc_node_flags_30352 __vmalloc_node_flags 1 30352 NULL
96663 +sys_get_mempolicy_30379 sys_get_mempolicy 3 30379 NULL
96664 +mangle_sdp_packet_30381 mangle_sdp_packet 10 30381 NULL
96665 +c4iw_init_resource_30393 c4iw_init_resource 2-3 30393 NULL
96666 +get_kernel_pages_30397 get_kernel_pages 0 30397 NULL
96667 +_drbd_bm_find_next_zero_30415 _drbd_bm_find_next_zero 2 30415 NULL
96668 +vb2_fop_write_30420 vb2_fop_write 3 30420 NULL
96669 +tx_tx_template_prepared_read_30424 tx_tx_template_prepared_read 3 30424 NULL
96670 +enable_write_30456 enable_write 3 30456 NULL
96671 +tx_tx_template_programmed_read_30461 tx_tx_template_programmed_read 3 30461 NULL
96672 +urandom_read_30462 urandom_read 3 30462 NULL
96673 +zoran_ioctl_30465 zoran_ioctl 2 30465 NULL
96674 +write_head_30481 write_head 4 30481 NULL
96675 +adu_write_30487 adu_write 3 30487 NULL
96676 +dwc3_testmode_write_30516 dwc3_testmode_write 3 30516 NULL
96677 +debug_debug2_read_30526 debug_debug2_read 3 30526 NULL
96678 +batadv_dat_snoop_incoming_arp_request_30548 batadv_dat_snoop_incoming_arp_request 3 30548 NULL
96679 +disk_expand_part_tbl_30561 disk_expand_part_tbl 2 30561 NULL
96680 +set_le_30581 set_le 4 30581 NULL
96681 +blk_init_tags_30592 blk_init_tags 1 30592 NULL
96682 +i2c_hid_get_report_length_30598 i2c_hid_get_report_length 0 30598 NULL
96683 +sgl_map_user_pages_30610 sgl_map_user_pages 2 30610 NULL
96684 +macvtap_sendmsg_30629 macvtap_sendmsg 4 30629 NULL
96685 +compat_raw_setsockopt_30634 compat_raw_setsockopt 5 30634 NULL
96686 +nfsd_nrpools_30651 nfsd_nrpools 0 30651 NULL
96687 +agp_remap_30665 agp_remap 2 30665 NULL
96688 +jffs2_flash_read_30667 jffs2_flash_read 0 30667 NULL
96689 +dccp_setsockopt_ccid_30701 dccp_setsockopt_ccid 4 30701 NULL
96690 +lbs_debugfs_read_30721 lbs_debugfs_read 3 30721 NULL
96691 +snd_nm256_playback_silence_30727 snd_nm256_playback_silence 4-3 30727 NULL
96692 +max77693_update_reg_30747 max77693_update_reg 2 30747 NULL
96693 +tcf_csum_ipv4_udp_30777 tcf_csum_ipv4_udp 4 30777 NULL
96694 +wm8350_read_auxadc_30780 wm8350_read_auxadc 2 30780 NULL
96695 +smk_read_doi_30813 smk_read_doi 3 30813 NULL
96696 +get_kobj_path_length_30831 get_kobj_path_length 0 30831 NULL
96697 +create_subvol_30836 create_subvol 4 30836 NULL
96698 +sctp_setsockopt_auth_chunk_30843 sctp_setsockopt_auth_chunk 3 30843 NULL
96699 +cfg80211_rx_mgmt_30844 cfg80211_rx_mgmt 5 30844 NULL nohasharray
96700 +twl6040_set_bits_30844 twl6040_set_bits 2 30844 &cfg80211_rx_mgmt_30844
96701 +hda_hwdep_ioctl_compat_30847 hda_hwdep_ioctl_compat 4 30847 NULL
96702 +ieee80211_if_fmt_dropped_frames_no_route_30884 ieee80211_if_fmt_dropped_frames_no_route 3 30884 NULL
96703 +f1x_match_to_this_node_30888 f1x_match_to_this_node 3 30888 NULL
96704 +regmap_update_bits_check_30894 regmap_update_bits_check 2 30894 NULL
96705 +iommu_map_mmio_space_30919 iommu_map_mmio_space 1 30919 NULL
96706 +sctp_setsockopt_rtoinfo_30941 sctp_setsockopt_rtoinfo 3 30941 NULL
96707 +tty_insert_flip_string_flags_30969 tty_insert_flip_string_flags 4 30969 NULL
96708 +huge_page_mask_30981 huge_page_mask 0 30981 NULL
96709 +i2400mu_rx_size_grow_30989 i2400mu_rx_size_grow 0 30989 NULL
96710 +lbs_host_sleep_read_31013 lbs_host_sleep_read 3 31013 NULL
96711 +phys_pmd_init_31024 phys_pmd_init 0-3-2 31024 NULL
96712 +compat_sys_mq_timedsend_31060 compat_sys_mq_timedsend 3 31060 NULL
96713 +lbs_failcount_read_31063 lbs_failcount_read 3 31063 NULL
96714 +find_next_bit_le_31064 find_next_bit_le 0-2-3 31064 NULL
96715 +sys_mincore_31079 sys_mincore 1 31079 NULL
96716 +ttm_bo_ioremap_31082 ttm_bo_ioremap 2-3 31082 NULL
96717 +sctp_setsockopt_context_31091 sctp_setsockopt_context 3 31091 NULL
96718 +compat_sys_get_mempolicy_31109 compat_sys_get_mempolicy 3 31109 NULL
96719 +depth_read_31112 depth_read 3 31112 NULL
96720 +ssb_read16_31139 ssb_read16 0 31139 NULL
96721 +kimage_normal_alloc_31140 kimage_normal_alloc 3 31140 NULL
96722 +size_inside_page_31141 size_inside_page 0 31141 NULL
96723 +w9966_v4l_read_31148 w9966_v4l_read 3 31148 NULL
96724 +ch_do_scsi_31171 ch_do_scsi 4 31171 NULL
96725 +acpi_ex_system_memory_space_handler_31192 acpi_ex_system_memory_space_handler 2 31192 NULL
96726 +r592_read_fifo_pio_31198 r592_read_fifo_pio 3 31198 NULL
96727 +mtdchar_readoob_31200 mtdchar_readoob 4 31200 NULL
96728 +__btrfs_free_reserved_extent_31207 __btrfs_free_reserved_extent 2 31207 NULL
96729 +cpumask_weight_31215 cpumask_weight 0 31215 NULL
96730 +__read_reg_31216 __read_reg 0 31216 NULL
96731 +atm_get_addr_31221 atm_get_addr 3 31221 NULL
96732 +cyy_readb_31240 cyy_readb 0 31240 NULL
96733 +_create_sg_bios_31244 _create_sg_bios 4 31244 NULL
96734 +ieee80211_if_read_last_beacon_31257 ieee80211_if_read_last_beacon 3 31257 NULL
96735 +ceph_copy_page_vector_to_user_31270 ceph_copy_page_vector_to_user 3-4 31270 NULL
96736 +sctp_tsnmap_find_gap_ack_31272 sctp_tsnmap_find_gap_ack 3-2 31272 NULL
96737 +uvc_simplify_fraction_31303 uvc_simplify_fraction 3 31303 NULL
96738 +sisusbcon_scroll_31315 sisusbcon_scroll 5-2-3 31315 NULL
96739 +futex_uaddr_31316 futex_uaddr 2 31316 NULL
96740 +command_file_write_31318 command_file_write 3 31318 NULL
96741 +__cpu_to_node_31345 __cpu_to_node 0 31345 NULL
96742 +xprt_rdma_allocate_31372 xprt_rdma_allocate 2 31372 NULL
96743 +vb2_vmalloc_get_userptr_31374 vb2_vmalloc_get_userptr 3 31374 NULL
96744 +trace_parser_get_init_31379 trace_parser_get_init 2 31379 NULL
96745 +inb_31388 inb 0 31388 NULL
96746 +key_ifindex_read_31411 key_ifindex_read 3 31411 NULL
96747 +mcs7830_set_reg_31413 mcs7830_set_reg 3 31413 NULL
96748 +TSS_checkhmac1_31429 TSS_checkhmac1 5 31429 NULL
96749 +snd_aw2_saa7146_get_hw_ptr_capture_31431 snd_aw2_saa7146_get_hw_ptr_capture 0 31431 NULL
96750 +acpi_sci_ioapic_setup_31445 acpi_sci_ioapic_setup 4 31445 NULL
96751 +opera1_xilinx_rw_31453 opera1_xilinx_rw 5 31453 NULL
96752 +_regmap_update_bits_31456 _regmap_update_bits 2 31456 NULL
96753 +input_get_new_minor_31464 input_get_new_minor 1 31464 NULL
96754 +do_fcntl_31468 do_fcntl 3 31468 NULL
96755 +xfs_btree_get_numrecs_31477 xfs_btree_get_numrecs 0 31477 NULL
96756 +alg_setkey_31485 alg_setkey 3 31485 NULL
96757 +rds_message_map_pages_31487 rds_message_map_pages 2 31487 NULL
96758 +qsfp_2_read_31491 qsfp_2_read 3 31491 NULL
96759 +__alloc_bootmem_31498 __alloc_bootmem 1 31498 NULL
96760 +hidraw_write_31536 hidraw_write 3 31536 NULL
96761 +mtd_div_by_eb_31543 mtd_div_by_eb 0-1 31543 NULL
96762 +usbvision_read_31555 usbvision_read 3 31555 NULL
96763 +normalize_31566 normalize 0-1-2 31566 NULL
96764 +tx_frag_tkip_called_read_31575 tx_frag_tkip_called_read 3 31575 NULL
96765 +get_max_inline_xattr_value_size_31578 get_max_inline_xattr_value_size 0 31578 NULL
96766 +osst_write_31581 osst_write 3 31581 NULL
96767 +snd_compr_get_avail_31584 snd_compr_get_avail 0 31584 NULL
96768 +iwl_dbgfs_ucode_tx_stats_read_31611 iwl_dbgfs_ucode_tx_stats_read 3 31611 NULL
96769 +mtd_get_user_prot_info_31616 mtd_get_user_prot_info 0 31616 NULL
96770 +arvo_sysfs_read_31617 arvo_sysfs_read 6 31617 NULL
96771 +videobuf_read_one_31637 videobuf_read_one 3 31637 NULL
96772 +pod_alloc_sysex_buffer_31651 pod_alloc_sysex_buffer 3 31651 NULL
96773 +xfer_secondary_pool_31661 xfer_secondary_pool 2 31661 NULL
96774 +__lgread_31668 __lgread 4 31668 NULL
96775 +symbol_string_31670 symbol_string 0 31670 NULL
96776 +_usb_writeN_sync_31682 _usb_writeN_sync 4 31682 NULL
96777 +forced_ps_read_31685 forced_ps_read 3 31685 NULL
96778 +reiserfs_in_journal_31689 reiserfs_in_journal 3 31689 NULL
96779 +audit_log_n_string_31705 audit_log_n_string 3 31705 NULL
96780 +ath6kl_wmi_send_probe_response_cmd_31728 ath6kl_wmi_send_probe_response_cmd 6 31728 NULL
96781 +utf16s_to_utf8s_31735 utf16s_to_utf8s 0 31735 NULL
96782 +shmem_pwrite_slow_31741 shmem_pwrite_slow 3 31741 NULL
96783 +NCR_700_change_queue_depth_31742 NCR_700_change_queue_depth 2 31742 NULL nohasharray
96784 +input_abs_get_max_31742 input_abs_get_max 0 31742 &NCR_700_change_queue_depth_31742
96785 +bcm_char_read_31750 bcm_char_read 3 31750 NULL
96786 +lm3533_led_get_pattern_reg_31752 lm3533_led_get_pattern_reg 0-2 31752 NULL
96787 +snd_seq_device_new_31753 snd_seq_device_new 4 31753 NULL
96788 +usblp_cache_device_id_string_31790 usblp_cache_device_id_string 0 31790 NULL
96789 +get_count_order_31800 get_count_order 0 31800 NULL
96790 +ecryptfs_send_message_locked_31801 ecryptfs_send_message_locked 2 31801 NULL
96791 +isr_rx_procs_read_31804 isr_rx_procs_read 3 31804 NULL
96792 +strnlen_user_31815 strnlen_user 0-2 31815 NULL
96793 +sta_last_signal_read_31818 sta_last_signal_read 3 31818 NULL
96794 +drm_mode_crtc_set_gamma_size_31881 drm_mode_crtc_set_gamma_size 2 31881 NULL
96795 +ddb_output_write_31902 ddb_output_write 3 31902 NULL
96796 +xattr_permission_31907 xattr_permission 0 31907 NULL
96797 +new_dir_31919 new_dir 3 31919 NULL
96798 +kmem_alloc_31920 kmem_alloc 1 31920 NULL
96799 +guestwidth_to_adjustwidth_31937 guestwidth_to_adjustwidth 0-1 31937 NULL
96800 +iov_iter_copy_from_user_31942 iov_iter_copy_from_user 4 31942 NULL
96801 +vb2_write_31948 vb2_write 3 31948 NULL
96802 +pvr2_ctrl_get_valname_31951 pvr2_ctrl_get_valname 4 31951 NULL
96803 +regcache_rbtree_sync_31964 regcache_rbtree_sync 2 31964 NULL
96804 +copy_from_user_toio_31966 copy_from_user_toio 3 31966 NULL
96805 +mtd_add_partition_31971 mtd_add_partition 3 31971 NULL
96806 +find_next_zero_bit_31990 find_next_zero_bit 0-2-3 31990 NULL
96807 +tps6586x_irq_map_32002 tps6586x_irq_map 2 32002 NULL
96808 +calc_hmac_32010 calc_hmac 3 32010 NULL
96809 +aead_len_32021 aead_len 0 32021 NULL
96810 +ocfs2_remove_extent_32032 ocfs2_remove_extent 4-3 32032 NULL
96811 +posix_acl_set_32037 posix_acl_set 4 32037 NULL
96812 +vmw_cursor_update_dmabuf_32045 vmw_cursor_update_dmabuf 3-4 32045 NULL
96813 +sys_sched_setaffinity_32046 sys_sched_setaffinity 2 32046 NULL
96814 +proc_scsi_devinfo_write_32064 proc_scsi_devinfo_write 3 32064 NULL
96815 +cfg80211_send_unprot_deauth_32080 cfg80211_send_unprot_deauth 3 32080 NULL
96816 +bio_alloc_32095 bio_alloc 2 32095 NULL
96817 +alloc_pwms_32100 alloc_pwms 1-2 32100 NULL
96818 +ath6kl_fwlog_read_32101 ath6kl_fwlog_read 3 32101 NULL
96819 +disk_status_32120 disk_status 4 32120 NULL
96820 +rc5t583_write_32124 rc5t583_write 2 32124 NULL
96821 +venus_link_32165 venus_link 5 32165 NULL
96822 +drbd_new_dev_size_32171 drbd_new_dev_size 0 32171 NULL
96823 +do_writepages_32173 do_writepages 0 32173 NULL nohasharray
96824 +ntfs_rl_realloc_nofail_32173 ntfs_rl_realloc_nofail 3 32173 &do_writepages_32173
96825 +load_header_32183 load_header 0 32183 NULL
96826 +ubi_wl_scrub_peb_32196 ubi_wl_scrub_peb 0 32196 NULL
96827 +wusb_ccm_mac_32199 wusb_ccm_mac 7 32199 NULL
96828 +riva_get_cmap_len_32218 riva_get_cmap_len 0 32218 NULL
96829 +lm3533_write_32236 lm3533_write 2 32236 NULL
96830 +lbs_lowrssi_read_32242 lbs_lowrssi_read 3 32242 NULL
96831 +ocfs2_xattr_find_entry_32260 ocfs2_xattr_find_entry 0 32260 NULL
96832 +fb_compat_ioctl_32265 fb_compat_ioctl 3 32265 NULL
96833 +vmalloc_user_32308 vmalloc_user 1 32308 NULL
96834 +hex_string_32310 hex_string 0 32310 NULL
96835 +flakey_status_32315 flakey_status 5 32315 NULL
96836 +nouveau_bar_create__32332 nouveau_bar_create_ 4 32332 NULL
96837 +nl80211_send_mlme_event_32337 nl80211_send_mlme_event 4 32337 NULL
96838 +t4_alloc_mem_32342 t4_alloc_mem 1 32342 NULL
96839 +dispatch_ioctl_32357 dispatch_ioctl 2 32357 NULL
96840 +f1x_translate_sysaddr_to_cs_32359 f1x_translate_sysaddr_to_cs 2 32359 NULL
96841 +sel_read_initcon_32362 sel_read_initcon 3 32362 NULL
96842 +_drbd_bm_find_next_32372 _drbd_bm_find_next 2 32372 NULL
96843 +variax_set_raw2_32374 variax_set_raw2 4 32374 NULL
96844 +usbtmc_read_32377 usbtmc_read 3 32377 NULL
96845 +qla4_82xx_pci_mem_write_2M_32398 qla4_82xx_pci_mem_write_2M 2 32398 NULL
96846 +xfs_iext_add_indirect_multi_32400 xfs_iext_add_indirect_multi 3 32400 NULL
96847 +log_text_32428 log_text 0 32428 NULL
96848 +regmap_irq_map_32429 regmap_irq_map 2 32429 NULL
96849 +hid_input_report_32458 hid_input_report 4 32458 NULL
96850 +snd_pcm_sync_ptr_32461 snd_pcm_sync_ptr 0 32461 NULL
96851 +ieee80211_fill_mesh_addresses_32465 ieee80211_fill_mesh_addresses 0 32465 NULL
96852 +ide_driver_proc_write_32493 ide_driver_proc_write 3 32493 NULL
96853 +ctrl_std_val_to_sym_32516 ctrl_std_val_to_sym 5 32516 NULL
96854 +disconnect_32521 disconnect 4 32521 NULL
96855 +qsfp_read_32522 qsfp_read 0-4-2 32522 NULL
96856 +ilo_read_32531 ilo_read 3 32531 NULL
96857 +ieee80211_if_read_estab_plinks_32533 ieee80211_if_read_estab_plinks 3 32533 NULL nohasharray
96858 +crypt_status_32533 crypt_status 5 32533 &ieee80211_if_read_estab_plinks_32533
96859 +format_devstat_counter_32550 format_devstat_counter 3 32550 NULL
96860 +__first_node_32558 __first_node 0 32558 NULL
96861 +aes_encrypt_fail_read_32562 aes_encrypt_fail_read 3 32562 NULL
96862 +pnp_mem_len_32584 pnp_mem_len 0 32584 NULL
96863 +mem_swapout_entry_32586 mem_swapout_entry 3 32586 NULL
96864 +pipeline_tcp_tx_stat_fifo_int_read_32589 pipeline_tcp_tx_stat_fifo_int_read 3 32589 NULL
96865 +read_file_beacon_32595 read_file_beacon 3 32595 NULL
96866 +ieee80211_if_read_dropped_frames_congestion_32603 ieee80211_if_read_dropped_frames_congestion 3 32603 NULL
96867 +sys_set_mempolicy_32608 sys_set_mempolicy 3 32608 NULL
96868 +cfg80211_roamed_32632 cfg80211_roamed 5-7 32632 NULL
96869 +ieee80211_hdrlen_32637 ieee80211_hdrlen 0 32637 NULL
96870 +ite_decode_bytes_32642 ite_decode_bytes 3 32642 NULL
96871 +kvmalloc_32646 kvmalloc 1 32646 NULL
96872 +ib_sg_dma_len_32649 ib_sg_dma_len 0 32649 NULL
96873 +generic_readlink_32654 generic_readlink 3 32654 NULL
96874 +move_addr_to_kernel_32673 move_addr_to_kernel 2 32673 NULL
96875 +tps80031_set_bits_32686 tps80031_set_bits 3 32686 NULL
96876 +jfs_readpages_32702 jfs_readpages 4 32702 NULL
96877 +snd_hwdep_ioctl_compat_32736 snd_hwdep_ioctl_compat 3 32736 NULL
96878 +megasas_change_queue_depth_32747 megasas_change_queue_depth 2 32747 NULL
96879 +stats_read_ul_32751 stats_read_ul 3 32751 NULL
96880 +tty_compat_ioctl_32761 tty_compat_ioctl 3 32761 NULL
96881 +sctp_tsnmap_grow_32784 sctp_tsnmap_grow 2 32784 NULL
96882 +firmwareUpload_32794 firmwareUpload 3 32794 NULL
96883 +rproc_name_read_32805 rproc_name_read 3 32805 NULL
96884 +vga_rseq_32848 vga_rseq 0 32848 NULL
96885 +new_tape_buffer_32866 new_tape_buffer 2 32866 NULL
96886 +io_apic_setup_irq_pin_32868 io_apic_setup_irq_pin 1 32868 NULL
96887 +ath6kl_usb_submit_ctrl_in_32880 ath6kl_usb_submit_ctrl_in 6 32880 NULL nohasharray
96888 +cifs_writedata_alloc_32880 cifs_writedata_alloc 1 32880 &ath6kl_usb_submit_ctrl_in_32880
96889 +ath6kl_usb_post_recv_transfers_32892 ath6kl_usb_post_recv_transfers 2 32892 NULL
96890 +il_dbgfs_tx_stats_read_32913 il_dbgfs_tx_stats_read 3 32913 NULL
96891 +zlib_inflate_workspacesize_32927 zlib_inflate_workspacesize 0 32927 NULL
96892 +rmap_recycle_32938 rmap_recycle 3 32938 NULL
96893 +irq_reserve_irqs_32946 irq_reserve_irqs 1-2 32946 NULL
96894 +ext4_valid_block_bitmap_32958 ext4_valid_block_bitmap 3 32958 NULL
96895 +arch_ptrace_32981 arch_ptrace 3 32981 NULL
96896 +compat_filldir_32999 compat_filldir 3 32999 NULL
96897 +ext3_alloc_blocks_33007 ext3_alloc_blocks 3 33007 NULL
96898 +snd_pcm_prepare_33036 snd_pcm_prepare 0 33036 NULL
96899 +pipeline_dec_packet_in_fifo_full_read_33052 pipeline_dec_packet_in_fifo_full_read 3 33052 NULL
96900 +ebt_compat_match_offset_33053 ebt_compat_match_offset 0-2 33053 NULL
96901 +bitmap_resize_33054 bitmap_resize 2 33054 NULL
96902 +stats_dot11RTSSuccessCount_read_33065 stats_dot11RTSSuccessCount_read 3 33065 NULL
96903 +sel_read_checkreqprot_33068 sel_read_checkreqprot 3 33068 NULL
96904 +acl_permission_check_33083 acl_permission_check 0 33083 NULL
96905 +ieee80211_fragment_33112 ieee80211_fragment 4 33112 NULL
96906 +write_node_33121 write_node 4 33121 NULL
96907 +calc_patch_size_33124 calc_patch_size 0 33124 NULL
96908 +fb_sys_write_33130 fb_sys_write 3 33130 NULL
96909 +debug_debug6_read_33168 debug_debug6_read 3 33168 NULL
96910 +dataflash_read_fact_otp_33204 dataflash_read_fact_otp 2-3 33204 NULL
96911 +pp_read_33210 pp_read 3 33210 NULL
96912 +xfs_file_aio_write_33234 xfs_file_aio_write 4 33234 NULL
96913 +snd_pcm_plug_client_size_33267 snd_pcm_plug_client_size 0-2 33267 NULL
96914 +sched_find_first_bit_33270 sched_find_first_bit 0 33270 NULL
96915 +cachefiles_cook_key_33274 cachefiles_cook_key 2 33274 NULL
96916 +mei_compat_ioctl_33275 mei_compat_ioctl 3 33275 NULL
96917 +pcf50633_irq_mask_33280 pcf50633_irq_mask 2 33280 NULL
96918 +mcs7830_get_reg_33308 mcs7830_get_reg 3 33308 NULL
96919 +ath6kl_usb_ctrl_msg_exchange_33327 ath6kl_usb_ctrl_msg_exchange 4 33327 NULL
96920 +gsm_mux_rx_netchar_33336 gsm_mux_rx_netchar 3 33336 NULL
96921 +joydev_ioctl_33343 joydev_ioctl 2 33343 NULL
96922 +create_xattr_datum_33356 create_xattr_datum 5 33356 NULL nohasharray
96923 +irq_pkt_threshold_read_33356 irq_pkt_threshold_read 3 33356 &create_xattr_datum_33356
96924 +read_file_regidx_33370 read_file_regidx 3 33370 NULL
96925 +ceph_osdc_writepages_33375 ceph_osdc_writepages 5 33375 NULL
96926 +ocfs2_quota_read_33382 ocfs2_quota_read 5 33382 NULL
96927 +ieee80211_if_read_dropped_frames_no_route_33383 ieee80211_if_read_dropped_frames_no_route 3 33383 NULL
96928 +scsi_varlen_cdb_length_33385 scsi_varlen_cdb_length 0 33385 NULL
96929 +ocfs2_allocate_unwritten_extents_33394 ocfs2_allocate_unwritten_extents 2-3 33394 NULL
96930 +ext4_meta_bg_first_block_no_33408 ext4_meta_bg_first_block_no 2 33408 NULL nohasharray
96931 +snd_pcm_capture_ioctl1_33408 snd_pcm_capture_ioctl1 0 33408 &ext4_meta_bg_first_block_no_33408
96932 +ufs_getfrag_block_33409 ufs_getfrag_block 2 33409 NULL
96933 +ubh_scanc_33436 ubh_scanc 0-4-3 33436 NULL
96934 +ovs_vport_alloc_33475 ovs_vport_alloc 1 33475 NULL
96935 +create_entry_33479 create_entry 2 33479 NULL
96936 +ip_setsockopt_33487 ip_setsockopt 5 33487 NULL nohasharray
96937 +elf_map_33487 elf_map 0-2 33487 &ip_setsockopt_33487
96938 +netxen_nic_hw_write_wx_128M_33488 netxen_nic_hw_write_wx_128M 2 33488 NULL
96939 +ol_dqblk_chunk_off_33489 ol_dqblk_chunk_off 2 33489 NULL
96940 +res_counter_read_33499 res_counter_read 4 33499 NULL
96941 +fb_read_33506 fb_read 3 33506 NULL
96942 +musb_test_mode_write_33518 musb_test_mode_write 3 33518 NULL
96943 +ahash_setkey_unaligned_33521 ahash_setkey_unaligned 3 33521 NULL
96944 +nes_alloc_fast_reg_page_list_33523 nes_alloc_fast_reg_page_list 2 33523 NULL
96945 +aggr_size_rx_size_read_33526 aggr_size_rx_size_read 3 33526 NULL
96946 +acpi_gsi_to_irq_33533 acpi_gsi_to_irq 1 33533 NULL
96947 +tomoyo_read_self_33539 tomoyo_read_self 3 33539 NULL
96948 +dup_array_33551 dup_array 3 33551 NULL
96949 +solo_enc_read_33553 solo_enc_read 3 33553 NULL
96950 +count_subheaders_33591 count_subheaders 0 33591 NULL
96951 +scsi_execute_33596 scsi_execute 5 33596 NULL
96952 +comedi_buf_write_n_allocated_33604 comedi_buf_write_n_allocated 0 33604 NULL
96953 +xt_compat_target_offset_33608 xt_compat_target_offset 0 33608 NULL nohasharray
96954 +ip6_find_1stfragopt_33608 ip6_find_1stfragopt 0 33608 &xt_compat_target_offset_33608
96955 +il_dbgfs_qos_read_33615 il_dbgfs_qos_read 3 33615 NULL
96956 +irq_blk_threshold_read_33666 irq_blk_threshold_read 3 33666 NULL
96957 +inw_p_33668 inw_p 0 33668 NULL
96958 +arp_hdr_len_33671 arp_hdr_len 0 33671 NULL
96959 +i2c_hid_alloc_buffers_33673 i2c_hid_alloc_buffers 2 33673 NULL
96960 +ath6kl_wmi_startscan_cmd_33674 ath6kl_wmi_startscan_cmd 8 33674 NULL
96961 +rbd_alloc_coll_33678 rbd_alloc_coll 1 33678 NULL
96962 +nv50_disp_dmac_create__33696 nv50_disp_dmac_create_ 6 33696 NULL
96963 +compat_insnlist_33706 compat_insnlist 2 33706 NULL
96964 +sys_keyctl_33708 sys_keyctl 4 33708 NULL nohasharray
96965 +netlink_sendmsg_33708 netlink_sendmsg 4 33708 &sys_keyctl_33708
96966 +tipc_link_stats_33716 tipc_link_stats 3 33716 NULL
96967 +pvr2_stream_buffer_count_33719 pvr2_stream_buffer_count 2 33719 NULL
96968 +ocfs2_extent_map_get_blocks_33720 ocfs2_extent_map_get_blocks 2 33720 NULL
96969 +__mutex_lock_interruptible_slowpath_33735 __mutex_lock_interruptible_slowpath 0 33735 NULL
96970 +Read_hfc_33755 Read_hfc 0 33755 NULL
96971 +vifs_state_read_33762 vifs_state_read 3 33762 NULL
96972 +hashtab_create_33769 hashtab_create 3 33769 NULL
96973 +midibuf_message_length_33770 midibuf_message_length 0 33770 NULL
96974 +if_sdio_read_rx_len_33800 if_sdio_read_rx_len 0 33800 NULL
96975 +find_next_offset_33804 find_next_offset 3 33804 NULL
96976 +sky2_rx_pad_33819 sky2_rx_pad 0 33819 NULL
96977 +sep_create_msgarea_context_33829 sep_create_msgarea_context 4 33829 NULL
96978 +scrub_setup_recheck_block_33831 scrub_setup_recheck_block 5-4 33831 NULL
96979 +udplite_manip_pkt_33832 udplite_manip_pkt 4 33832 NULL
96980 +snd_pcm_action_nonatomic_33844 snd_pcm_action_nonatomic 0 33844 NULL
96981 +usb_dump_endpoint_descriptor_33849 usb_dump_endpoint_descriptor 0 33849 NULL
96982 +calgary_alloc_coherent_33851 calgary_alloc_coherent 2 33851 NULL
96983 +oz_cdev_write_33852 oz_cdev_write 3 33852 NULL
96984 +cap_mmap_addr_33853 cap_mmap_addr 0 33853 NULL
96985 +config_proc_write_33878 config_proc_write 3 33878 NULL
96986 +get_user_pages_33908 get_user_pages 0 33908 NULL
96987 +queue_logical_block_size_33918 queue_logical_block_size 0 33918 NULL
96988 +sel_read_avc_cache_threshold_33942 sel_read_avc_cache_threshold 3 33942 NULL
96989 +lpfc_idiag_ctlacc_read_33943 lpfc_idiag_ctlacc_read 3 33943 NULL
96990 +read_file_tgt_rx_stats_33944 read_file_tgt_rx_stats 3 33944 NULL
96991 +vga_switcheroo_debugfs_write_33984 vga_switcheroo_debugfs_write 3 33984 NULL
96992 +__ntfs_malloc_34022 __ntfs_malloc 1 34022 NULL
96993 +ppp_write_34034 ppp_write 3 34034 NULL
96994 +tty_insert_flip_string_34042 tty_insert_flip_string 3 34042 NULL
96995 +__domain_flush_pages_34045 __domain_flush_pages 2-3 34045 NULL
96996 +acpi_dev_get_irqresource_34064 acpi_dev_get_irqresource 2 34064 NULL
96997 +memcg_update_all_caches_34068 memcg_update_all_caches 1 34068 NULL
96998 +read_file_ant_diversity_34071 read_file_ant_diversity 3 34071 NULL
96999 +show_risefalltime_34084 show_risefalltime 4 34084 NULL
97000 +compat_hdio_ioctl_34088 compat_hdio_ioctl 4 34088 NULL
97001 +pipeline_pipeline_fifo_full_read_34095 pipeline_pipeline_fifo_full_read 3 34095 NULL
97002 +islpci_mgt_transmit_34133 islpci_mgt_transmit 5 34133 NULL
97003 +ttm_dma_page_pool_free_34135 ttm_dma_page_pool_free 2 34135 NULL
97004 +cdc_mbim_process_dgram_34136 cdc_mbim_process_dgram 3 34136 NULL
97005 +ixgbe_dbg_netdev_ops_write_34141 ixgbe_dbg_netdev_ops_write 3 34141 NULL
97006 +shmem_pread_fast_34147 shmem_pread_fast 3 34147 NULL
97007 +skb_to_sgvec_34171 skb_to_sgvec 0 34171 NULL
97008 +ext4_da_write_begin_34215 ext4_da_write_begin 3-4 34215 NULL
97009 +bl_pipe_downcall_34264 bl_pipe_downcall 3 34264 NULL
97010 +pcf857x_to_irq_34273 pcf857x_to_irq 2 34273 NULL
97011 +zone_spanned_pages_in_node_34299 zone_spanned_pages_in_node 0 34299 NULL
97012 +iov_iter_single_seg_count_34326 iov_iter_single_seg_count 0 34326 NULL nohasharray
97013 +pcpu_need_to_extend_34326 pcpu_need_to_extend 0 34326 &iov_iter_single_seg_count_34326
97014 +crypto_ablkcipher_ivsize_34363 crypto_ablkcipher_ivsize 0 34363 NULL
97015 +rngapi_reset_34366 rngapi_reset 3 34366 NULL nohasharray
97016 +p54_alloc_skb_34366 p54_alloc_skb 3 34366 &rngapi_reset_34366
97017 +reiserfs_resize_34377 reiserfs_resize 2 34377 NULL
97018 +ea_read_34378 ea_read 0 34378 NULL
97019 +av7110_vbi_write_34384 av7110_vbi_write 3 34384 NULL
97020 +usbvision_v4l2_read_34386 usbvision_v4l2_read 3 34386 NULL
97021 +read_rbu_image_type_34387 read_rbu_image_type 6 34387 NULL
97022 +iwl_calib_set_34400 iwl_calib_set 3 34400 NULL nohasharray
97023 +ivtv_read_pos_34400 ivtv_read_pos 3 34400 &iwl_calib_set_34400
97024 +nl80211_send_disassoc_34424 nl80211_send_disassoc 4 34424 NULL
97025 +usbtest_alloc_urb_34446 usbtest_alloc_urb 3-5 34446 NULL
97026 +mwifiex_regrdwr_read_34472 mwifiex_regrdwr_read 3 34472 NULL
97027 +line6_dumpreq_init_34473 line6_dumpreq_init 3 34473 NULL
97028 +skcipher_sndbuf_34476 skcipher_sndbuf 0 34476 NULL
97029 +i2o_parm_field_get_34477 i2o_parm_field_get 5 34477 NULL
97030 +security_inode_permission_34488 security_inode_permission 0 34488 NULL
97031 +alloc_buf_34532 alloc_buf 1 34532 NULL
97032 +tracing_stats_read_34537 tracing_stats_read 3 34537 NULL
97033 +hugetlbfs_read_actor_34547 hugetlbfs_read_actor 0-2-5-4 34547 NULL
97034 +dbBackSplit_34561 dbBackSplit 0 34561 NULL
97035 +alloc_ieee80211_rsl_34564 alloc_ieee80211_rsl 1 34564 NULL
97036 +velocity_rx_copy_34583 velocity_rx_copy 2 34583 NULL
97037 +init_send_hfcd_34586 init_send_hfcd 1 34586 NULL
97038 +inet6_ifla6_size_34591 inet6_ifla6_size 0 34591 NULL
97039 +ceph_msgpool_init_34599 ceph_msgpool_init 4 34599 NULL
97040 +__jffs2_ref_totlen_34609 __jffs2_ref_totlen 0 34609 NULL
97041 +__cfg80211_disconnected_34622 __cfg80211_disconnected 3 34622 NULL
97042 +cnic_alloc_dma_34641 cnic_alloc_dma 3 34641 NULL
97043 +nf_nat_mangle_udp_packet_34661 nf_nat_mangle_udp_packet 8-6 34661 NULL
97044 +isr_fiqs_read_34687 isr_fiqs_read 3 34687 NULL
97045 +port_print_34704 port_print 3 34704 NULL
97046 +alloc_irq_and_cfg_at_34706 alloc_irq_and_cfg_at 1 34706 NULL
97047 +ieee80211_if_read_num_sta_ps_34722 ieee80211_if_read_num_sta_ps 3 34722 NULL
97048 +platform_list_read_file_34734 platform_list_read_file 3 34734 NULL
97049 +reg_w_ixbuf_34736 reg_w_ixbuf 4 34736 NULL
97050 +qib_cdev_init_34778 qib_cdev_init 1 34778 NULL
97051 +ssd1307fb_write_array_34779 ssd1307fb_write_array 4 34779 NULL
97052 +__copy_in_user_34790 __copy_in_user 3 34790 NULL
97053 +drbd_get_max_capacity_34804 drbd_get_max_capacity 0 34804 NULL
97054 +b43_debugfs_write_34838 b43_debugfs_write 3 34838 NULL
97055 +nl_portid_hash_zalloc_34843 nl_portid_hash_zalloc 1 34843 NULL
97056 +acpi_system_write_wakeup_device_34853 acpi_system_write_wakeup_device 3 34853 NULL
97057 +usb_serial_generic_prepare_write_buffer_34857 usb_serial_generic_prepare_write_buffer 3 34857 NULL
97058 +ieee80211_if_read_txpower_34871 ieee80211_if_read_txpower 3 34871 NULL
97059 +lm3533_ctrlbank_get_reg_34886 lm3533_ctrlbank_get_reg 0-2 34886 NULL
97060 +msg_print_text_34889 msg_print_text 0 34889 NULL
97061 +ieee80211_if_write_34894 ieee80211_if_write 3 34894 NULL
97062 +compat_put_uint_34905 compat_put_uint 1 34905 NULL
97063 +__inode_permission_34925 __inode_permission 0 34925 NULL nohasharray
97064 +btrfs_super_chunk_root_34925 btrfs_super_chunk_root 0 34925 &__inode_permission_34925
97065 +skb_gro_header_slow_34958 skb_gro_header_slow 2 34958 NULL
97066 +Realloc_34961 Realloc 2 34961 NULL
97067 +rx_rx_hdr_overflow_read_35002 rx_rx_hdr_overflow_read 3 35002 NULL
97068 +l2cap_skbuff_fromiovec_35003 l2cap_skbuff_fromiovec 4-3 35003 NULL
97069 +sisusb_copy_memory_35016 sisusb_copy_memory 4 35016 NULL
97070 +coda_psdev_read_35029 coda_psdev_read 3 35029 NULL
97071 +btmrvl_gpiogap_write_35053 btmrvl_gpiogap_write 3 35053 NULL
97072 +pwr_connection_out_of_sync_read_35061 pwr_connection_out_of_sync_read 3 35061 NULL
97073 +store_ifalias_35088 store_ifalias 4 35088 NULL
97074 +__kfifo_uint_must_check_helper_35097 __kfifo_uint_must_check_helper 0-1 35097 NULL
97075 +capi_write_35104 capi_write 3 35104 NULL nohasharray
97076 +tx_tx_done_template_read_35104 tx_tx_done_template_read 3 35104 &capi_write_35104
97077 +ide_settings_proc_write_35110 ide_settings_proc_write 3 35110 NULL
97078 +pointer_35138 pointer 0 35138 NULL
97079 +gntdev_alloc_map_35145 gntdev_alloc_map 2 35145 NULL
97080 +iscsi_conn_setup_35159 iscsi_conn_setup 2 35159 NULL
97081 +ieee80211_if_read_bssid_35161 ieee80211_if_read_bssid 3 35161 NULL
97082 +unix_stream_recvmsg_35210 unix_stream_recvmsg 4 35210 NULL
97083 +_osd_req_alist_elem_size_35216 _osd_req_alist_elem_size 0-2 35216 NULL
97084 +striped_read_35218 striped_read 0-2-8-3 35218 NULL nohasharray
97085 +security_key_getsecurity_35218 security_key_getsecurity 0 35218 &striped_read_35218
97086 +video_register_device_no_warn_35226 video_register_device_no_warn 3 35226 NULL nohasharray
97087 +rx_rx_cmplt_task_read_35226 rx_rx_cmplt_task_read 3 35226 &video_register_device_no_warn_35226
97088 +set_fd_set_35249 set_fd_set 1 35249 NULL
97089 +ioapic_setup_resources_35255 ioapic_setup_resources 1 35255 NULL
97090 +dma_show_regs_35266 dma_show_regs 3 35266 NULL
97091 +irda_recvmsg_stream_35280 irda_recvmsg_stream 4 35280 NULL
97092 +i2o_block_end_request_35282 i2o_block_end_request 3 35282 NULL
97093 +isr_rx_rdys_read_35283 isr_rx_rdys_read 3 35283 NULL
97094 +brcmf_sdio_forensic_read_35311 brcmf_sdio_forensic_read 3 35311 NULL nohasharray
97095 +__btrfs_buffered_write_35311 __btrfs_buffered_write 3 35311 &brcmf_sdio_forensic_read_35311
97096 +tracing_read_pipe_35312 tracing_read_pipe 3 35312 NULL
97097 +sys_setsockopt_35320 sys_setsockopt 5 35320 NULL
97098 +new_bind_ctl_35324 new_bind_ctl 2 35324 NULL
97099 +irq_domain_disassociate_many_35325 irq_domain_disassociate_many 2-3 35325 NULL
97100 +fallback_on_nodma_alloc_35332 fallback_on_nodma_alloc 2 35332 NULL
97101 +pskb_network_may_pull_35336 pskb_network_may_pull 2 35336 NULL
97102 +ieee80211_if_fmt_ap_power_level_35347 ieee80211_if_fmt_ap_power_level 3 35347 NULL
97103 +nouveau_devinit_create__35348 nouveau_devinit_create_ 4 35348 NULL
97104 +hpi_alloc_control_cache_35351 hpi_alloc_control_cache 1 35351 NULL
97105 +compat_filldir64_35354 compat_filldir64 3 35354 NULL
97106 +rawv6_send_hdrinc_35425 rawv6_send_hdrinc 3 35425 NULL
97107 +__set_test_and_free_35436 __set_test_and_free 2 35436 NULL
97108 +buffer_to_user_35439 buffer_to_user 3 35439 NULL
97109 +rdev_get_id_35454 rdev_get_id 0 35454 NULL
97110 +i915_wedged_read_35474 i915_wedged_read 3 35474 NULL
97111 +do_atm_ioctl_35519 do_atm_ioctl 3 35519 NULL
97112 +async_setkey_35521 async_setkey 3 35521 NULL
97113 +__filemap_fdatawrite_range_35528 __filemap_fdatawrite_range 0 35528 NULL
97114 +iwl_dbgfs_bt_traffic_read_35534 iwl_dbgfs_bt_traffic_read 3 35534 NULL
97115 +rxpipe_tx_xfr_host_int_trig_rx_data_read_35538 rxpipe_tx_xfr_host_int_trig_rx_data_read 3 35538 NULL
97116 +ibnl_put_attr_35541 ibnl_put_attr 3 35541 NULL
97117 +ieee80211_if_write_smps_35550 ieee80211_if_write_smps 3 35550 NULL
97118 +ext2_acl_from_disk_35580 ext2_acl_from_disk 2 35580 NULL
97119 +ReadZReg_35604 ReadZReg 0 35604 NULL
97120 +kernel_readv_35617 kernel_readv 3 35617 NULL
97121 +reiserfs_readpages_35629 reiserfs_readpages 4 35629 NULL
97122 +scrub_stripe_35637 scrub_stripe 4-3 35637 NULL
97123 +spi_register_board_info_35651 spi_register_board_info 2 35651 NULL
97124 +store_debug_level_35652 store_debug_level 3 35652 NULL
97125 +regmap_update_bits_35668 regmap_update_bits 2 35668 NULL
97126 +rdmaltWithLock_35669 rdmaltWithLock 0 35669 NULL
97127 +compat_sys_kexec_load_35674 compat_sys_kexec_load 2 35674 NULL
97128 +dm_table_create_35687 dm_table_create 3 35687 NULL
97129 +rds_page_copy_user_35691 rds_page_copy_user 4 35691 NULL
97130 +pci_enable_sriov_35745 pci_enable_sriov 2 35745 NULL
97131 +iwl_dbgfs_disable_ht40_read_35761 iwl_dbgfs_disable_ht40_read 3 35761 NULL
97132 +udf_alloc_i_data_35786 udf_alloc_i_data 2 35786 NULL
97133 +read_file_stations_35795 read_file_stations 3 35795 NULL
97134 +pvr2_hdw_cpufw_get_35824 pvr2_hdw_cpufw_get 0-4-2 35824 NULL
97135 +tx_tx_cmplt_read_35854 tx_tx_cmplt_read 3 35854 NULL
97136 +mthca_buf_alloc_35861 mthca_buf_alloc 2 35861 NULL
97137 +fls64_35862 fls64 0 35862 NULL
97138 +kvm_dirty_bitmap_bytes_35886 kvm_dirty_bitmap_bytes 0 35886 NULL
97139 +ieee80211_if_fmt_dot11MeshRetryTimeout_35890 ieee80211_if_fmt_dot11MeshRetryTimeout 3 35890 NULL
97140 +uwb_rc_cmd_done_35892 uwb_rc_cmd_done 4 35892 NULL
97141 +kernel_setsockopt_35913 kernel_setsockopt 5 35913 NULL
97142 +vol_cdev_compat_ioctl_35923 vol_cdev_compat_ioctl 3 35923 NULL
97143 +sctp_tsnmap_mark_35929 sctp_tsnmap_mark 2 35929 NULL
97144 +rx_defrag_init_called_read_35935 rx_defrag_init_called_read 3 35935 NULL
97145 +put_cmsg_compat_35937 put_cmsg_compat 4 35937 NULL
97146 +wm8350_reg_write_35967 wm8350_reg_write 2 35967 NULL
97147 +ext_rts51x_sd_execute_write_data_35971 ext_rts51x_sd_execute_write_data 9 35971 NULL
97148 +ceph_buffer_new_35974 ceph_buffer_new 1 35974 NULL
97149 +acl_alloc_35979 acl_alloc 1 35979 NULL
97150 +generic_file_aio_read_35987 generic_file_aio_read 0 35987 NULL
97151 +koneplus_sysfs_write_35993 koneplus_sysfs_write 6 35993 NULL
97152 +il3945_ucode_tx_stats_read_36016 il3945_ucode_tx_stats_read 3 36016 NULL
97153 +ubi_eba_write_leb_36029 ubi_eba_write_leb 5-6 36029 NULL
97154 +sys_init_module_36047 sys_init_module 2 36047 NULL
97155 +account_shadowed_36048 account_shadowed 2 36048 NULL
97156 +gpio_power_read_36059 gpio_power_read 3 36059 NULL
97157 +snd_pcm_playback_hw_avail_36061 snd_pcm_playback_hw_avail 0 36061 NULL
97158 +write_emulate_36065 write_emulate 2-4 36065 NULL
97159 +radeon_vm_num_pdes_36070 radeon_vm_num_pdes 0 36070 NULL
97160 +ieee80211_if_fmt_peer_36071 ieee80211_if_fmt_peer 3 36071 NULL
97161 +ext3_new_blocks_36073 ext3_new_blocks 3 36073 NULL
97162 +ieee80211_if_write_tsf_36077 ieee80211_if_write_tsf 3 36077 NULL
97163 +snd_pcm_plug_read_transfer_36080 snd_pcm_plug_read_transfer 0-3 36080 NULL
97164 +vga_arb_write_36112 vga_arb_write 3 36112 NULL
97165 +simple_xattr_alloc_36118 simple_xattr_alloc 2 36118 NULL
97166 +compat_ptrace_request_36131 compat_ptrace_request 3-4 36131 NULL
97167 +vmalloc_exec_36132 vmalloc_exec 1 36132 NULL
97168 +ext3_readpages_36144 ext3_readpages 4 36144 NULL
97169 +iwl_trans_txq_alloc_36147 iwl_trans_txq_alloc 3 36147 NULL
97170 +alloc_vm_area_36149 alloc_vm_area 1 36149 NULL
97171 +twl_set_36154 twl_set 2 36154 NULL
97172 +b1_alloc_card_36155 b1_alloc_card 1 36155 NULL
97173 +btrfs_file_extent_inline_len_36158 btrfs_file_extent_inline_len 0 36158 NULL
97174 +snd_korg1212_copy_from_36169 snd_korg1212_copy_from 6 36169 NULL
97175 +ubifs_read_nnode_36221 ubifs_read_nnode 0 36221 NULL
97176 +nfqnl_mangle_36226 nfqnl_mangle 4-2 36226 NULL
97177 +atomic_stats_read_36228 atomic_stats_read 3 36228 NULL
97178 +viafb_iga1_odev_proc_write_36241 viafb_iga1_odev_proc_write 3 36241 NULL
97179 +rproc_recovery_read_36245 rproc_recovery_read 3 36245 NULL
97180 +scrub_stripe_36248 scrub_stripe 5-4 36248 NULL
97181 +compat_sys_mbind_36256 compat_sys_mbind 5 36256 NULL
97182 +usb_buffer_alloc_36276 usb_buffer_alloc 2 36276 NULL
97183 +codec_reg_read_file_36280 codec_reg_read_file 3 36280 NULL
97184 +crypto_shash_digestsize_36284 crypto_shash_digestsize 0 36284 NULL
97185 +readahead_tree_block_36285 readahead_tree_block 3 36285 NULL
97186 +nouveau_cli_create_36293 nouveau_cli_create 3 36293 NULL
97187 +lpfc_debugfs_dif_err_read_36303 lpfc_debugfs_dif_err_read 3 36303 NULL
97188 +ad7879_spi_xfer_36311 ad7879_spi_xfer 3 36311 NULL
97189 +fat_compat_ioctl_filldir_36328 fat_compat_ioctl_filldir 3 36328 NULL
97190 +lc_create_36332 lc_create 4 36332 NULL
97191 +jbd2_journal_init_revoke_table_36336 jbd2_journal_init_revoke_table 1 36336 NULL
97192 +v9fs_file_readn_36353 v9fs_file_readn 4 36353 NULL nohasharray
97193 +xz_dec_lzma2_create_36353 xz_dec_lzma2_create 2 36353 &v9fs_file_readn_36353
97194 +to_sector_36361 to_sector 0-1 36361 NULL
97195 +tunables_read_36385 tunables_read 3 36385 NULL
97196 +afs_alloc_flat_call_36399 afs_alloc_flat_call 2-3 36399 NULL
97197 +sctp_tsnmap_init_36446 sctp_tsnmap_init 2 36446 NULL
97198 +alloc_etherdev_mqs_36450 alloc_etherdev_mqs 1 36450 NULL
97199 +b43_nphy_load_samples_36481 b43_nphy_load_samples 3 36481 NULL
97200 +tx_tx_checksum_result_read_36490 tx_tx_checksum_result_read 3 36490 NULL
97201 +__hwahc_op_set_ptk_36510 __hwahc_op_set_ptk 5 36510 NULL
97202 +mcam_v4l_read_36513 mcam_v4l_read 3 36513 NULL
97203 +get_param_l_36518 get_param_l 0 36518 NULL
97204 +ieee80211_if_read_fwded_frames_36520 ieee80211_if_read_fwded_frames 3 36520 NULL
97205 +lguest_setup_irq_36531 lguest_setup_irq 1 36531 NULL
97206 +crypto_aead_authsize_36537 crypto_aead_authsize 0 36537 NULL
97207 +ssd1307fb_write_data_array_36538 ssd1307fb_write_data_array 3 36538 NULL
97208 +cpu_type_read_36540 cpu_type_read 3 36540 NULL
97209 +get_entry_len_36549 get_entry_len 0 36549 NULL
97210 +__kfifo_to_user_36555 __kfifo_to_user 3 36555 NULL nohasharray
97211 +macvtap_do_read_36555 macvtap_do_read 4 36555 &__kfifo_to_user_36555
97212 +btrfs_get_token_64_36572 btrfs_get_token_64 0 36572 NULL
97213 +ssb_bus_scan_36578 ssb_bus_scan 2 36578 NULL
97214 +__erst_read_36579 __erst_read 0 36579 NULL
97215 +put_cmsg_36589 put_cmsg 4 36589 NULL
97216 +pcnet32_realloc_rx_ring_36598 pcnet32_realloc_rx_ring 3 36598 NULL
97217 +fat_ioctl_filldir_36621 fat_ioctl_filldir 3 36621 NULL
97218 +vxge_config_vpaths_36636 vxge_config_vpaths 0 36636 NULL
97219 +format_decode_36638 format_decode 0 36638 NULL
97220 +ced_ioctl_36647 ced_ioctl 2 36647 NULL
97221 +lpfc_idiag_extacc_alloc_get_36648 lpfc_idiag_extacc_alloc_get 0-3 36648 NULL
97222 +osd_req_list_collection_objects_36664 osd_req_list_collection_objects 5 36664 NULL
97223 +iscsi_host_alloc_36671 iscsi_host_alloc 2 36671 NULL
97224 +ptr_to_compat_36680 ptr_to_compat 0 36680 NULL
97225 +ext4_mb_discard_group_preallocations_36685 ext4_mb_discard_group_preallocations 2 36685 NULL
97226 +snd_soc_update_bits_36714 snd_soc_update_bits 2 36714 NULL
97227 +extract_icmp6_fields_36732 extract_icmp6_fields 2 36732 NULL
97228 +snd_rawmidi_kernel_read1_36740 snd_rawmidi_kernel_read1 4 36740 NULL
97229 +cxgbi_device_register_36746 cxgbi_device_register 1-2 36746 NULL
97230 +ps_poll_upsd_timeouts_read_36755 ps_poll_upsd_timeouts_read 3 36755 NULL
97231 +snd_soc_update_bits_locked_36766 snd_soc_update_bits_locked 2 36766 NULL
97232 +ip4ip6_err_36772 ip4ip6_err 5 36772 NULL
97233 +ptp_filter_init_36780 ptp_filter_init 2 36780 NULL
97234 +proc_fault_inject_read_36802 proc_fault_inject_read 3 36802 NULL
97235 +hiddev_ioctl_36816 hiddev_ioctl 2 36816 NULL
97236 +int_hardware_entry_36833 int_hardware_entry 3 36833 NULL
97237 +pcf50633_reg_write_36841 pcf50633_reg_write 2 36841 NULL nohasharray
97238 +fc_change_queue_depth_36841 fc_change_queue_depth 2 36841 &pcf50633_reg_write_36841
97239 +keyctl_describe_key_36853 keyctl_describe_key 3 36853 NULL
97240 +cm_write_36858 cm_write 3 36858 NULL
97241 +tx_tx_data_programmed_read_36871 tx_tx_data_programmed_read 3 36871 NULL
97242 +svc_setsockopt_36876 svc_setsockopt 5 36876 NULL
97243 +ib_ucm_alloc_data_36885 ib_ucm_alloc_data 3 36885 NULL
97244 +selinux_inode_notifysecctx_36896 selinux_inode_notifysecctx 3 36896 NULL
97245 +lm3533_als_get_target_36905 lm3533_als_get_target 2-3 36905 NULL
97246 +OS_kmalloc_36909 OS_kmalloc 1 36909 NULL
97247 +crypto_blkcipher_ivsize_36944 crypto_blkcipher_ivsize 0 36944 NULL
97248 +div_u64_36951 div_u64 0 36951 NULL
97249 +write_leb_36957 write_leb 5 36957 NULL
97250 +ntfs_external_attr_find_36963 ntfs_external_attr_find 0 36963 NULL
97251 +sparse_early_mem_maps_alloc_node_36971 sparse_early_mem_maps_alloc_node 4 36971 NULL
97252 +mc13xxx_reg_rmw_36997 mc13xxx_reg_rmw 2 36997 NULL
97253 +drbd_new_dev_size_36998 drbd_new_dev_size 0-3 36998 NULL
97254 +auok190xfb_write_37001 auok190xfb_write 3 37001 NULL
97255 +setxattr_37006 setxattr 4 37006 NULL
97256 +ieee80211_if_read_drop_unencrypted_37053 ieee80211_if_read_drop_unencrypted 3 37053 NULL
97257 +parse_command_37079 parse_command 2 37079 NULL
97258 +wm8994_gpio_set_37082 wm8994_gpio_set 2 37082 NULL
97259 +pipeline_cs_rx_packet_in_read_37089 pipeline_cs_rx_packet_in_read 3 37089 NULL
97260 +tun_get_user_37094 tun_get_user 5 37094 NULL
97261 +has_wrprotected_page_37123 has_wrprotected_page 2-3 37123 NULL
97262 +msg_word_37164 msg_word 0 37164 NULL
97263 +can_set_xattr_37182 can_set_xattr 4 37182 NULL
97264 +crypto_shash_descsize_37212 crypto_shash_descsize 0 37212 NULL
97265 +regmap_access_read_file_37223 regmap_access_read_file 3 37223 NULL
97266 +__do_replace_37227 __do_replace 5 37227 NULL
97267 +rx_filter_dup_filter_read_37238 rx_filter_dup_filter_read 3 37238 NULL
97268 +prot_queue_del_37258 prot_queue_del 0 37258 NULL
97269 +ath6kl_wmi_set_ie_cmd_37260 ath6kl_wmi_set_ie_cmd 6 37260 NULL
97270 +exofs_max_io_pages_37263 exofs_max_io_pages 0-2 37263 NULL
97271 +c101_run_37279 c101_run 2 37279 NULL
97272 +srp_target_alloc_37288 srp_target_alloc 3 37288 NULL
97273 +jffs2_write_dirent_37311 jffs2_write_dirent 5 37311 NULL
97274 +send_msg_37323 send_msg 4 37323 NULL
97275 +brcmf_sdbrcm_membytes_37324 brcmf_sdbrcm_membytes 3-5 37324 NULL
97276 +l2cap_create_connless_pdu_37327 l2cap_create_connless_pdu 3 37327 NULL
97277 +scsi_mode_select_37330 scsi_mode_select 6 37330 NULL
97278 +rxrpc_server_sendmsg_37331 rxrpc_server_sendmsg 4 37331 NULL
97279 +security_inode_getsecurity_37354 security_inode_getsecurity 0 37354 NULL
97280 +iommu_num_pages_37391 iommu_num_pages 0-1-3-2 37391 NULL
97281 +sys_getxattr_37418 sys_getxattr 4 37418 NULL
97282 +hci_sock_sendmsg_37420 hci_sock_sendmsg 4 37420 NULL
97283 +acpi_os_allocate_zeroed_37422 acpi_os_allocate_zeroed 1 37422 NULL nohasharray
97284 +find_next_bit_37422 find_next_bit 0-2-3 37422 &acpi_os_allocate_zeroed_37422
97285 +tty_insert_flip_string_fixed_flag_37428 tty_insert_flip_string_fixed_flag 4 37428 NULL
97286 +iwl_print_last_event_logs_37433 iwl_print_last_event_logs 0-7-9 37433 NULL
97287 +tcp_established_options_37450 tcp_established_options 0 37450 NULL
97288 +brcmf_sdio_dump_console_37455 brcmf_sdio_dump_console 4 37455 NULL
97289 +ufs_data_ptr_to_cpu_37475 ufs_data_ptr_to_cpu 0 37475 NULL
97290 +get_est_timing_37484 get_est_timing 0 37484 NULL
97291 +xfs_trans_read_buf_map_37487 xfs_trans_read_buf_map 5 37487 NULL
97292 +kmem_realloc_37489 kmem_realloc 2 37489 NULL
97293 +kvm_vcpu_compat_ioctl_37500 kvm_vcpu_compat_ioctl 3 37500 NULL
97294 +vmalloc_32_user_37519 vmalloc_32_user 1 37519 NULL
97295 +fault_inject_read_37534 fault_inject_read 3 37534 NULL
97296 +hdr_size_37536 hdr_size 0 37536 NULL
97297 +sep_create_dcb_dmatables_context_37551 sep_create_dcb_dmatables_context 6 37551 NULL nohasharray
97298 +nf_nat_mangle_tcp_packet_37551 nf_nat_mangle_tcp_packet 6-8 37551 &sep_create_dcb_dmatables_context_37551
97299 +xhci_alloc_streams_37586 xhci_alloc_streams 5 37586 NULL
97300 +mlx4_get_mgm_entry_size_37607 mlx4_get_mgm_entry_size 0 37607 NULL
97301 +kvm_read_guest_page_mmu_37611 kvm_read_guest_page_mmu 6 37611 NULL
97302 +alloc_fd_37637 alloc_fd 1 37637 NULL
97303 +bio_copy_user_iov_37660 bio_copy_user_iov 4 37660 NULL
97304 +rfcomm_sock_sendmsg_37661 rfcomm_sock_sendmsg 4 37661 NULL nohasharray
97305 +vmw_framebuffer_dmabuf_dirty_37661 vmw_framebuffer_dmabuf_dirty 6 37661 &rfcomm_sock_sendmsg_37661
97306 +lnw_gpio_to_irq_37665 lnw_gpio_to_irq 2 37665 NULL
97307 +ieee80211_if_read_rc_rateidx_mcs_mask_2ghz_37675 ieee80211_if_read_rc_rateidx_mcs_mask_2ghz 3 37675 NULL
97308 +regmap_map_read_file_37685 regmap_map_read_file 3 37685 NULL
97309 +nametbl_header_37698 nametbl_header 2 37698 NULL
97310 +__le32_to_cpup_37702 __le32_to_cpup 0 37702 NULL
97311 +soc_widget_update_bits_locked_37715 soc_widget_update_bits_locked 2 37715 NULL
97312 +read_enabled_file_bool_37744 read_enabled_file_bool 3 37744 NULL
97313 +ocfs2_duplicate_clusters_by_jbd_37749 ocfs2_duplicate_clusters_by_jbd 6-4-5 37749 NULL
97314 +ocfs2_control_cfu_37750 ocfs2_control_cfu 2 37750 NULL
97315 +ipath_cdev_init_37752 ipath_cdev_init 1 37752 NULL
97316 +dccp_setsockopt_cscov_37766 dccp_setsockopt_cscov 2 37766 NULL
97317 +il4965_rs_sta_dbgfs_rate_scale_data_read_37792 il4965_rs_sta_dbgfs_rate_scale_data_read 3 37792 NULL
97318 +smk_read_logging_37804 smk_read_logging 3 37804 NULL
97319 +deny_write_access_37813 deny_write_access 0 37813 NULL
97320 +rx_decrypt_key_not_found_read_37820 rx_decrypt_key_not_found_read 3 37820 NULL
97321 +bitmap_find_next_zero_area_37827 bitmap_find_next_zero_area 2-3-5-4 37827 NULL
97322 +o2hb_debug_read_37851 o2hb_debug_read 3 37851 NULL
97323 +xfs_dir2_block_to_sf_37868 xfs_dir2_block_to_sf 3 37868 NULL
97324 +sys_setxattr_37880 sys_setxattr 4 37880 NULL
97325 +lm3533_als_get_target_reg_37881 lm3533_als_get_target_reg 0-1-2 37881 NULL
97326 +dvb_net_sec_37884 dvb_net_sec 3 37884 NULL
97327 +max77686_irq_domain_map_37897 max77686_irq_domain_map 2 37897 NULL
97328 +tipc_link_send_sections_fast_37920 tipc_link_send_sections_fast 4 37920 NULL
97329 +pkt_alloc_packet_data_37928 pkt_alloc_packet_data 1 37928 NULL
97330 +read_rbu_packet_size_37939 read_rbu_packet_size 6 37939 NULL
97331 +fifo_alloc_37961 fifo_alloc 1 37961 NULL
97332 +ext3_free_blocks_sb_37967 ext3_free_blocks_sb 3-4 37967 NULL
97333 +rds_rdma_extra_size_37990 rds_rdma_extra_size 0 37990 NULL
97334 +persistent_ram_old_size_37997 persistent_ram_old_size 0 37997 NULL
97335 +vfs_readv_38011 vfs_readv 3 38011 NULL
97336 +aggr_recv_addba_req_evt_38037 aggr_recv_addba_req_evt 4 38037 NULL
97337 +klsi_105_prepare_write_buffer_38044 klsi_105_prepare_write_buffer 3 38044 NULL nohasharray
97338 +il_dbgfs_chain_noise_read_38044 il_dbgfs_chain_noise_read 3 38044 &klsi_105_prepare_write_buffer_38044
97339 +_xfs_buf_alloc_38058 _xfs_buf_alloc 3 38058 NULL
97340 +nsm_create_handle_38060 nsm_create_handle 4 38060 NULL
97341 +alloc_ltalkdev_38071 alloc_ltalkdev 1 38071 NULL
97342 +xfs_buf_readahead_map_38081 xfs_buf_readahead_map 3 38081 NULL
97343 +uwb_mac_addr_print_38085 uwb_mac_addr_print 2 38085 NULL
97344 +request_key_auth_new_38092 request_key_auth_new 3 38092 NULL
97345 +proc_self_readlink_38094 proc_self_readlink 3 38094 NULL
97346 +ep0_read_38095 ep0_read 3 38095 NULL
97347 +sk_wmem_schedule_38096 sk_wmem_schedule 2 38096 NULL
97348 +snd_pcm_oss_write_38108 snd_pcm_oss_write 3 38108 NULL
97349 +vmw_kms_present_38130 vmw_kms_present 9 38130 NULL
97350 +__ntfs_copy_from_user_iovec_inatomic_38153 __ntfs_copy_from_user_iovec_inatomic 3-4 38153 NULL
97351 +kvm_clear_guest_38164 kvm_clear_guest 3-2 38164 NULL
97352 +cdev_add_38176 cdev_add 2-3 38176 NULL
97353 +brcmf_sdcard_recv_buf_38179 brcmf_sdcard_recv_buf 6 38179 NULL
97354 +rt2x00debug_write_rf_38195 rt2x00debug_write_rf 3 38195 NULL
97355 +get_ucode_user_38202 get_ucode_user 3 38202 NULL
97356 +ext3_new_block_38208 ext3_new_block 3 38208 NULL
97357 +stmpe_gpio_irq_map_38222 stmpe_gpio_irq_map 3 38222 NULL
97358 +osd_req_list_partition_collections_38223 osd_req_list_partition_collections 5 38223 NULL
97359 +vhost_net_compat_ioctl_38237 vhost_net_compat_ioctl 3 38237 NULL
97360 +_ipw_read_reg32_38245 _ipw_read_reg32 0 38245 NULL
97361 +snd_pcm_playback_rewind_38249 snd_pcm_playback_rewind 0-2 38249 NULL
97362 +ieee80211_if_read_auto_open_plinks_38268 ieee80211_if_read_auto_open_plinks 3 38268 NULL nohasharray
97363 +mthca_alloc_icm_table_38268 mthca_alloc_icm_table 4-3 38268 &ieee80211_if_read_auto_open_plinks_38268
97364 +verity_status_38273 verity_status 5 38273 NULL
97365 +xfs_bmdr_to_bmbt_38275 xfs_bmdr_to_bmbt 5 38275 NULL nohasharray
97366 +xfs_bmbt_to_bmdr_38275 xfs_bmbt_to_bmdr 3 38275 &xfs_bmdr_to_bmbt_38275
97367 +zd_mac_rx_38296 zd_mac_rx 3 38296 NULL
97368 +ieee80211_send_probe_req_38307 ieee80211_send_probe_req 6-4 38307 NULL
97369 +isr_rx_headers_read_38325 isr_rx_headers_read 3 38325 NULL
97370 +ida_simple_get_38326 ida_simple_get 2 38326 NULL
97371 +__snd_gf1_look8_38333 __snd_gf1_look8 0 38333 NULL
97372 +pyra_sysfs_write_38370 pyra_sysfs_write 6 38370 NULL
97373 +dn_sendmsg_38390 dn_sendmsg 4 38390 NULL
97374 +get_valid_node_allowed_38412 get_valid_node_allowed 1-0 38412 NULL
97375 +ocfs2_which_cluster_group_38413 ocfs2_which_cluster_group 2 38413 NULL
97376 +ht_destroy_irq_38418 ht_destroy_irq 1 38418 NULL
97377 +ieee80211_if_read_dtim_count_38419 ieee80211_if_read_dtim_count 3 38419 NULL
97378 +asix_write_cmd_async_38420 asix_write_cmd_async 5 38420 NULL
97379 +pcnet32_realloc_tx_ring_38428 pcnet32_realloc_tx_ring 3 38428 NULL
97380 +pmcraid_copy_sglist_38431 pmcraid_copy_sglist 3 38431 NULL
97381 +kvm_write_guest_38454 kvm_write_guest 4-2 38454 NULL
97382 +i915_min_freq_read_38470 i915_min_freq_read 3 38470 NULL
97383 +blk_end_bidi_request_38482 blk_end_bidi_request 3-4 38482 NULL
97384 +cpu_to_mem_38501 cpu_to_mem 0 38501 NULL
97385 +dev_names_read_38509 dev_names_read 3 38509 NULL
97386 +iscsi_create_iface_38510 iscsi_create_iface 5 38510 NULL
97387 +event_rx_mismatch_read_38518 event_rx_mismatch_read 3 38518 NULL
97388 +set_queue_count_38519 set_queue_count 0 38519 NULL
97389 +ubifs_idx_node_sz_38546 ubifs_idx_node_sz 0-2 38546 NULL
97390 +btrfs_discard_extent_38547 btrfs_discard_extent 2 38547 NULL
97391 +cpu_to_node_38561 cpu_to_node 0 38561 NULL
97392 +irda_sendmsg_dgram_38563 irda_sendmsg_dgram 4 38563 NULL
97393 +il4965_rs_sta_dbgfs_scale_table_read_38564 il4965_rs_sta_dbgfs_scale_table_read 3 38564 NULL
97394 +_ipw_read32_38565 _ipw_read32 0 38565 NULL
97395 +snd_nm256_playback_copy_38567 snd_nm256_playback_copy 5-3 38567 NULL
97396 +copy_ctl_value_to_user_38587 copy_ctl_value_to_user 4 38587 NULL
97397 +cosa_net_setup_rx_38594 cosa_net_setup_rx 2 38594 NULL
97398 +compat_sys_ptrace_38595 compat_sys_ptrace 3-4 38595 NULL
97399 +delay_status_38606 delay_status 5 38606 NULL
97400 +icn_writecmd_38629 icn_writecmd 2 38629 NULL
97401 +ext2_readpages_38640 ext2_readpages 4 38640 NULL
97402 +cma_create_area_38642 cma_create_area 2 38642 NULL
97403 +audit_init_entry_38644 audit_init_entry 1 38644 NULL
97404 +mmc_send_cxd_data_38655 mmc_send_cxd_data 5 38655 NULL
97405 +nouveau_instmem_create__38664 nouveau_instmem_create_ 4 38664 NULL
97406 +cfg80211_send_disassoc_38678 cfg80211_send_disassoc 3 38678 NULL
97407 +iscsit_dump_data_payload_38683 iscsit_dump_data_payload 2 38683 NULL
97408 +ext4_wait_block_bitmap_38695 ext4_wait_block_bitmap 2 38695 NULL
97409 +find_next_usable_block_38716 find_next_usable_block 1-3 38716 NULL
97410 +alloc_trace_probe_38720 alloc_trace_probe 6 38720 NULL
97411 +udf_readpages_38761 udf_readpages 4 38761 NULL
97412 +iwl_dbgfs_thermal_throttling_read_38779 iwl_dbgfs_thermal_throttling_read 3 38779 NULL
97413 +snd_gus_dram_write_38784 snd_gus_dram_write 4 38784 NULL
97414 +err_decode_38804 err_decode 2 38804 NULL
97415 +ipv6_renew_option_38813 ipv6_renew_option 3 38813 NULL
97416 +sys_select_38827 sys_select 1 38827 NULL
97417 +b43_txhdr_size_38832 b43_txhdr_size 0 38832 NULL
97418 +direct_entry_38836 direct_entry 3 38836 NULL
97419 +compat_udp_setsockopt_38840 compat_udp_setsockopt 5 38840 NULL
97420 +interfaces_38859 interfaces 2 38859 NULL
97421 +pci_msix_table_size_38867 pci_msix_table_size 0 38867 NULL
97422 +sizeof_gpio_leds_priv_38882 sizeof_gpio_leds_priv 0-1 38882 NULL
97423 +dbgfs_state_38894 dbgfs_state 3 38894 NULL
97424 +f2fs_xattr_set_acl_38895 f2fs_xattr_set_acl 4 38895 NULL
97425 +__fswab16_38898 __fswab16 0 38898 NULL
97426 +process_bulk_data_command_38906 process_bulk_data_command 4 38906 NULL
97427 +ext3_trim_all_free_38929 ext3_trim_all_free 3-4-2 38929 NULL
97428 +sbp_count_se_tpg_luns_38943 sbp_count_se_tpg_luns 0 38943 NULL
97429 +__ath6kl_wmi_send_mgmt_cmd_38971 __ath6kl_wmi_send_mgmt_cmd 7 38971 NULL
97430 +usb_maxpacket_38977 usb_maxpacket 0 38977 NULL
97431 +OSDSetBlock_38986 OSDSetBlock 4-2 38986 NULL
97432 +udf_new_block_38999 udf_new_block 4 38999 NULL
97433 +get_nodes_39012 get_nodes 3 39012 NULL
97434 +twl6030_interrupt_unmask_39013 twl6030_interrupt_unmask 2 39013 NULL
97435 +acpi_install_gpe_block_39031 acpi_install_gpe_block 4 39031 NULL
97436 +_zd_iowrite32v_async_locked_39034 _zd_iowrite32v_async_locked 3 39034 NULL
97437 +line6_midibuf_read_39067 line6_midibuf_read 0-3 39067 NULL
97438 +ext4_init_block_bitmap_39071 ext4_init_block_bitmap 3 39071 NULL
97439 +tun_get_user_39099 tun_get_user 4 39099 NULL
97440 +tomoyo_truncate_39105 tomoyo_truncate 0 39105 NULL
97441 +__kfifo_to_user_r_39123 __kfifo_to_user_r 3 39123 NULL
97442 +ea_foreach_39133 ea_foreach 0 39133 NULL
97443 +generic_permission_39150 generic_permission 0 39150 NULL
97444 +alloc_ring_39151 alloc_ring 2-4 39151 NULL
97445 +proc_coredump_filter_read_39153 proc_coredump_filter_read 3 39153 NULL
97446 +create_bounce_buffer_39155 create_bounce_buffer 3 39155 NULL
97447 +ext3_xattr_check_names_39174 ext3_xattr_check_names 0 39174 NULL
97448 +init_list_set_39188 init_list_set 2-3 39188 NULL
97449 +ubi_more_update_data_39189 ubi_more_update_data 4 39189 NULL
97450 +qcam_read_bytes_39205 qcam_read_bytes 0 39205 NULL
97451 +qla4_82xx_pci_mem_read_direct_39208 qla4_82xx_pci_mem_read_direct 2 39208 NULL
97452 +vfio_group_fops_compat_ioctl_39219 vfio_group_fops_compat_ioctl 3 39219 NULL
97453 +ivtv_v4l2_write_39226 ivtv_v4l2_write 3 39226 NULL
97454 +batadv_tt_response_fill_table_39236 batadv_tt_response_fill_table 1 39236 NULL
97455 +posix_acl_to_xattr_39237 posix_acl_to_xattr 0 39237 NULL
97456 +drm_order_39244 drm_order 0 39244 NULL
97457 +snd_pcm_capture_forward_39248 snd_pcm_capture_forward 0-2 39248 NULL
97458 +r128_compat_ioctl_39250 r128_compat_ioctl 2 39250 NULL nohasharray
97459 +pwr_cont_miss_bcns_spread_read_39250 pwr_cont_miss_bcns_spread_read 3 39250 &r128_compat_ioctl_39250
97460 +__skb_cow_39254 __skb_cow 2 39254 NULL
97461 +ath6kl_wmi_set_appie_cmd_39266 ath6kl_wmi_set_appie_cmd 5 39266 NULL
97462 +rx_filter_protection_filter_read_39282 rx_filter_protection_filter_read 3 39282 NULL
97463 +__vmalloc_node_39308 __vmalloc_node 1 39308 NULL
97464 +__cfg80211_connect_result_39326 __cfg80211_connect_result 4-6 39326 NULL
97465 +wimax_msg_alloc_39343 wimax_msg_alloc 4 39343 NULL
97466 +__cfg80211_send_deauth_39344 __cfg80211_send_deauth 3 39344 NULL
97467 +__copy_from_user_nocache_39351 __copy_from_user_nocache 3 39351 NULL
97468 +ide_complete_rq_39354 ide_complete_rq 3 39354 NULL
97469 +do_write_log_from_user_39362 do_write_log_from_user 3 39362 NULL
97470 +vortex_wtdma_getlinearpos_39371 vortex_wtdma_getlinearpos 0 39371 NULL
97471 +regmap_name_read_file_39379 regmap_name_read_file 3 39379 NULL
97472 +ps_poll_ps_poll_utilization_read_39383 ps_poll_ps_poll_utilization_read 3 39383 NULL
97473 +__send_to_port_39386 __send_to_port 3 39386 NULL
97474 +user_power_read_39414 user_power_read 3 39414 NULL
97475 +alloc_agpphysmem_i8xx_39427 alloc_agpphysmem_i8xx 1 39427 NULL
97476 +sys_semop_39457 sys_semop 3 39457 NULL
97477 +setkey_unaligned_39474 setkey_unaligned 3 39474 NULL
97478 +ieee80211_if_fmt_dot11MeshHWMPmaxPREQretries_39499 ieee80211_if_fmt_dot11MeshHWMPmaxPREQretries 3 39499 NULL
97479 +atomic64_read_unchecked_39505 atomic64_read_unchecked 0 39505 NULL
97480 +int_proc_write_39542 int_proc_write 3 39542 NULL
97481 +pp_write_39554 pp_write 3 39554 NULL
97482 +ol_dqblk_block_39558 ol_dqblk_block 0-3-2 39558 NULL
97483 +datablob_format_39571 datablob_format 2 39571 NULL nohasharray
97484 +ieee80211_if_read_fwded_mcast_39571 ieee80211_if_read_fwded_mcast 3 39571 &datablob_format_39571
97485 +handle_response_icmp_39574 handle_response_icmp 7 39574 NULL
97486 +adau1373_set_pll_39593 adau1373_set_pll 2 39593 NULL
97487 +mtdchar_compat_ioctl_39602 mtdchar_compat_ioctl 3 39602 NULL
97488 +n_tty_compat_ioctl_helper_39605 n_tty_compat_ioctl_helper 4 39605 NULL
97489 +ext_depth_39607 ext_depth 0 39607 NULL
97490 +nfs_idmap_get_key_39616 nfs_idmap_get_key 2 39616 NULL
97491 +sdio_readb_39618 sdio_readb 0 39618 NULL
97492 +dm_exception_table_init_39645 dm_exception_table_init 2 39645 NULL nohasharray
97493 +set_dev_class_39645 set_dev_class 4 39645 &dm_exception_table_init_39645
97494 +snd_rme32_capture_copy_39653 snd_rme32_capture_copy 5 39653 NULL
97495 +tcp_try_rmem_schedule_39657 tcp_try_rmem_schedule 3 39657 NULL nohasharray
97496 +prism2_info_hostscanresults_39657 prism2_info_hostscanresults 3 39657 &tcp_try_rmem_schedule_39657
97497 +kvm_read_guest_cached_39666 kvm_read_guest_cached 4 39666 NULL
97498 +v4l_stk_read_39672 v4l_stk_read 3 39672 NULL
97499 +hsc_msg_len_get_39673 hsc_msg_len_get 0 39673 NULL
97500 +do_surface_dirty_sou_39678 do_surface_dirty_sou 7 39678 NULL
97501 +ftrace_pid_write_39710 ftrace_pid_write 3 39710 NULL
97502 +tcf_csum_ipv4_tcp_39713 tcf_csum_ipv4_tcp 4 39713 NULL
97503 +ocfs2_pages_per_cluster_39790 ocfs2_pages_per_cluster 0 39790 NULL
97504 +security_inode_listsecurity_39812 security_inode_listsecurity 0 39812 NULL
97505 +snd_pcm_oss_writev3_39818 snd_pcm_oss_writev3 3 39818 NULL
97506 +sys_migrate_pages_39825 sys_migrate_pages 2 39825 NULL
97507 +get_priv_size_39828 get_priv_size 0-1 39828 NULL
97508 +pkt_add_39897 pkt_add 3 39897 NULL
97509 +read_file_modal_eeprom_39909 read_file_modal_eeprom 3 39909 NULL
97510 +gen_pool_add_virt_39913 gen_pool_add_virt 4 39913 NULL
97511 +dw210x_op_rw_39915 dw210x_op_rw 6 39915 NULL
97512 +aes_encrypt_interrupt_read_39919 aes_encrypt_interrupt_read 3 39919 NULL
97513 +exofs_read_kern_39921 exofs_read_kern 6 39921 NULL nohasharray
97514 +oom_score_adj_read_39921 oom_score_adj_read 3 39921 &exofs_read_kern_39921
97515 +__spi_async_39932 __spi_async 0 39932 NULL
97516 +__get_order_39935 __get_order 0 39935 NULL
97517 +error_error_frame_read_39947 error_error_frame_read 3 39947 NULL nohasharray
97518 +fwnet_pd_new_39947 fwnet_pd_new 4 39947 &error_error_frame_read_39947
97519 +tty_prepare_flip_string_39955 tty_prepare_flip_string 3 39955 NULL
97520 +dma_push_rx_39973 dma_push_rx 2 39973 NULL
97521 +broadsheetfb_write_39976 broadsheetfb_write 3 39976 NULL
97522 +mthca_array_init_39987 mthca_array_init 2 39987 NULL
97523 +xen_hvm_config_40018 xen_hvm_config 2 40018 NULL
97524 +nf_nat_icmpv6_reply_translation_40023 nf_nat_icmpv6_reply_translation 5 40023 NULL nohasharray
97525 +ivtvfb_write_40023 ivtvfb_write 3 40023 &nf_nat_icmpv6_reply_translation_40023
97526 +ea_foreach_i_40028 ea_foreach_i 0 40028 NULL
97527 +datablob_hmac_append_40038 datablob_hmac_append 3 40038 NULL
97528 +regmap_add_irq_chip_40042 regmap_add_irq_chip 4 40042 NULL
97529 +add_tty_40055 add_tty 1 40055 NULL nohasharray
97530 +l2cap_create_iframe_pdu_40055 l2cap_create_iframe_pdu 3 40055 &add_tty_40055
97531 +atomic_xchg_40070 atomic_xchg 0 40070 NULL
97532 +snd_pcm_sw_params_user_40095 snd_pcm_sw_params_user 0 40095 NULL
97533 +gen_pool_first_fit_40110 gen_pool_first_fit 2-3-4 40110 NULL
97534 +rbd_do_op_40128 rbd_do_op 4-5 40128 NULL
97535 +sctp_setsockopt_delayed_ack_40129 sctp_setsockopt_delayed_ack 3 40129 NULL
97536 +rx_rx_frame_checksum_read_40140 rx_rx_frame_checksum_read 3 40140 NULL
97537 +iwch_alloc_fastreg_pbl_40153 iwch_alloc_fastreg_pbl 2 40153 NULL
97538 +pt_write_40159 pt_write 3 40159 NULL
97539 +scsi_sg_count_40182 scsi_sg_count 0 40182 NULL
97540 +ipr_alloc_ucode_buffer_40199 ipr_alloc_ucode_buffer 1 40199 NULL nohasharray
97541 +devnode_find_40199 devnode_find 3-2 40199 &ipr_alloc_ucode_buffer_40199
97542 +allocate_probes_40204 allocate_probes 1 40204 NULL
97543 +acpi_system_write_alarm_40205 acpi_system_write_alarm 3 40205 NULL
97544 +compat_put_long_40214 compat_put_long 1 40214 NULL
97545 +au0828_v4l2_read_40220 au0828_v4l2_read 3 40220 NULL
97546 +xfs_buf_read_map_40226 xfs_buf_read_map 3 40226 NULL
97547 +osst_read_40237 osst_read 3 40237 NULL
97548 +lpage_info_slot_40243 lpage_info_slot 1-3 40243 NULL
97549 +ocfs2_zero_extend_get_range_40248 ocfs2_zero_extend_get_range 4 40248 NULL
97550 +of_get_child_count_40254 of_get_child_count 0 40254 NULL
97551 +rs_sta_dbgfs_scale_table_read_40262 rs_sta_dbgfs_scale_table_read 3 40262 NULL
97552 +usbnet_read_cmd_40275 usbnet_read_cmd 7 40275 NULL
97553 +rx_xfr_hint_trig_read_40283 rx_xfr_hint_trig_read 3 40283 NULL
97554 +ubi_io_write_data_40305 ubi_io_write_data 4-5 40305 NULL
97555 +batadv_tt_changes_fill_buff_40323 batadv_tt_changes_fill_buff 4 40323 NULL
97556 +ib_get_mad_data_offset_40336 ib_get_mad_data_offset 0 40336 NULL
97557 +mmio_read_40348 mmio_read 4 40348 NULL
97558 +usb_dump_interface_40353 usb_dump_interface 0 40353 NULL
97559 +ocfs2_release_clusters_40355 ocfs2_release_clusters 4 40355 NULL
97560 +event_rx_mem_empty_read_40363 event_rx_mem_empty_read 3 40363 NULL
97561 +ocfs2_check_range_for_refcount_40365 ocfs2_check_range_for_refcount 2-3 40365 NULL
97562 +fwnet_incoming_packet_40380 fwnet_incoming_packet 3 40380 NULL
97563 +brcmf_sdbrcm_get_image_40397 brcmf_sdbrcm_get_image 0-2 40397 NULL
97564 +atmel_rmem16_40450 atmel_rmem16 0 40450 NULL
97565 +tomoyo_update_policy_40458 tomoyo_update_policy 2 40458 NULL
97566 +zd_usb_scnprint_id_40459 zd_usb_scnprint_id 0-3 40459 NULL
97567 +batadv_hash_new_40491 batadv_hash_new 1 40491 NULL
97568 +devcgroup_inode_permission_40492 devcgroup_inode_permission 0 40492 NULL
97569 +tty_write_room_40495 tty_write_room 0 40495 NULL
97570 +persistent_ram_new_40501 persistent_ram_new 1-2 40501 NULL
97571 +sg_phys_40507 sg_phys 0 40507 NULL
97572 +TSS_checkhmac2_40520 TSS_checkhmac2 5-7 40520 NULL
97573 +ixgbe_dbg_reg_ops_read_40540 ixgbe_dbg_reg_ops_read 3 40540 NULL
97574 +ima_write_policy_40548 ima_write_policy 3 40548 NULL
97575 +esp_alloc_tmp_40558 esp_alloc_tmp 3-2 40558 NULL
97576 +ufs_inode_getfrag_40560 ufs_inode_getfrag 2-4 40560 NULL
97577 +arch_setup_hpet_msi_40584 arch_setup_hpet_msi 1 40584 NULL
97578 +skge_rx_get_40598 skge_rx_get 3 40598 NULL
97579 +get_priv_descr_and_size_40612 get_priv_descr_and_size 0 40612 NULL
97580 +bl_mark_sectors_init_40613 bl_mark_sectors_init 2-3 40613 NULL
97581 +cpuset_sprintf_cpulist_40627 cpuset_sprintf_cpulist 0 40627 NULL
97582 +twl4030_kpwrite_u8_40665 twl4030_kpwrite_u8 3 40665 NULL
97583 +__cfg80211_roamed_40668 __cfg80211_roamed 4-6 40668 NULL
97584 +pipeline_rx_complete_stat_fifo_int_read_40671 pipeline_rx_complete_stat_fifo_int_read 3 40671 NULL
97585 +fops_read_40672 fops_read 3 40672 NULL
97586 +tps80031_write_40678 tps80031_write 3 40678 NULL
97587 +nfc_hci_set_param_40697 nfc_hci_set_param 5 40697 NULL
97588 +__seq_open_private_40715 __seq_open_private 3 40715 NULL
97589 +xfs_iext_remove_direct_40744 xfs_iext_remove_direct 3 40744 NULL nohasharray
97590 +find_next_zero_bit_le_40744 find_next_zero_bit_le 0-2-3 40744 &xfs_iext_remove_direct_40744
97591 +tps65910_irq_map_40748 tps65910_irq_map 2 40748 NULL
97592 +security_inode_listxattr_40752 security_inode_listxattr 0 40752 NULL
97593 +fat_generic_compat_ioctl_40755 fat_generic_compat_ioctl 3 40755 NULL
97594 +card_send_command_40757 card_send_command 3 40757 NULL
97595 +ad1889_readl_40765 ad1889_readl 0 40765 NULL
97596 +pg_write_40766 pg_write 3 40766 NULL
97597 +show_list_40775 show_list 3 40775 NULL
97598 +kfifo_out_copy_r_40784 kfifo_out_copy_r 0-3 40784 NULL
97599 +bitmap_weight_40791 bitmap_weight 0-2 40791 NULL
97600 +pyra_sysfs_read_40795 pyra_sysfs_read 6 40795 NULL
97601 +netdev_alloc_skb_ip_align_40811 netdev_alloc_skb_ip_align 2 40811 NULL
97602 +nl80211_send_roamed_40825 nl80211_send_roamed 5-7 40825 NULL
97603 +__mlx4_qp_reserve_range_40847 __mlx4_qp_reserve_range 2-3 40847 NULL
97604 +ocfs2_zero_partial_clusters_40856 ocfs2_zero_partial_clusters 2-3 40856 NULL
97605 +v9fs_file_read_40858 v9fs_file_read 3 40858 NULL
97606 +read_file_queue_40895 read_file_queue 3 40895 NULL
97607 +waiters_read_40902 waiters_read 3 40902 NULL
97608 +isdn_add_channels_40905 isdn_add_channels 3 40905 NULL
97609 +gfs2_ea_find_40913 gfs2_ea_find 0 40913 NULL
97610 +vol_cdev_write_40915 vol_cdev_write 3 40915 NULL
97611 +snd_vx_create_40948 snd_vx_create 4 40948 NULL
97612 +skb_end_offset_40949 skb_end_offset 0 40949 NULL
97613 +wm8994_free_irq_40951 wm8994_free_irq 2 40951 NULL
97614 +rds_sendmsg_40976 rds_sendmsg 4 40976 NULL
97615 +insert_old_idx_40987 insert_old_idx 0 40987 NULL
97616 +il_dbgfs_fh_reg_read_40993 il_dbgfs_fh_reg_read 3 40993 NULL
97617 +mac80211_format_buffer_41010 mac80211_format_buffer 2 41010 NULL
97618 +mtd_block_isbad_41015 mtd_block_isbad 0 41015 NULL
97619 +_req_append_segment_41031 _req_append_segment 2 41031 NULL
97620 +mISDN_sock_sendmsg_41035 mISDN_sock_sendmsg 4 41035 NULL
97621 +ocfs2_xattr_index_block_find_41040 ocfs2_xattr_index_block_find 0 41040 NULL
97622 +vfs_listxattr_41062 vfs_listxattr 0 41062 NULL
97623 +cfg80211_inform_bss_frame_41078 cfg80211_inform_bss_frame 4 41078 NULL
97624 +roccat_read_41093 roccat_read 3 41093 NULL nohasharray
97625 +nvme_map_user_pages_41093 nvme_map_user_pages 3-4 41093 &roccat_read_41093
97626 +dma_attach_41094 dma_attach 5-6 41094 NULL
97627 +provide_user_output_41105 provide_user_output 3 41105 NULL
97628 +f_audio_buffer_alloc_41110 f_audio_buffer_alloc 1 41110 NULL
97629 +v4l2_ctrl_new_int_menu_41151 v4l2_ctrl_new_int_menu 4 41151 NULL
97630 +tx_frag_mpdu_alloc_failed_read_41167 tx_frag_mpdu_alloc_failed_read 3 41167 NULL
97631 +dvb_ca_write_41171 dvb_ca_write 3 41171 NULL
97632 +ol_quota_chunk_block_41177 ol_quota_chunk_block 0-2 41177 NULL
97633 +netif_get_num_default_rss_queues_41187 netif_get_num_default_rss_queues 0 41187 NULL
97634 +compat_sys_process_vm_writev_41194 compat_sys_process_vm_writev 3-5 41194 NULL
97635 +dfs_file_write_41196 dfs_file_write 3 41196 NULL
97636 +xfs_readdir_41200 xfs_readdir 3 41200 NULL
97637 +ocfs2_read_quota_block_41207 ocfs2_read_quota_block 2 41207 NULL
97638 +nfs_page_array_len_41219 nfs_page_array_len 0-2-1 41219 NULL
97639 +hiddev_compat_ioctl_41255 hiddev_compat_ioctl 2-3 41255 NULL
97640 +erst_read_41260 erst_read 0 41260 NULL
97641 +__fprog_create_41263 __fprog_create 2 41263 NULL
97642 +alloc_context_41283 alloc_context 1 41283 NULL
97643 +arch_gnttab_map_shared_41306 arch_gnttab_map_shared 3 41306 NULL
97644 +twl_change_queue_depth_41342 twl_change_queue_depth 2 41342 NULL
97645 +cnic_init_id_tbl_41354 cnic_init_id_tbl 2 41354 NULL
97646 +jbd2_alloc_41359 jbd2_alloc 1 41359 NULL
97647 +kmp_init_41373 kmp_init 2 41373 NULL
97648 +isr_commands_read_41398 isr_commands_read 3 41398 NULL
97649 +sys_flistxattr_41407 sys_flistxattr 3 41407 NULL
97650 +rx_defrag_decrypt_failed_read_41411 rx_defrag_decrypt_failed_read 3 41411 NULL
97651 +xfs_iext_add_41422 xfs_iext_add 3 41422 NULL
97652 +isdn_ppp_fill_rq_41428 isdn_ppp_fill_rq 2 41428 NULL
97653 +lbs_rdrf_read_41431 lbs_rdrf_read 3 41431 NULL
97654 +ext4_trim_extent_41436 ext4_trim_extent 4 41436 NULL
97655 +iio_device_alloc_41440 iio_device_alloc 1 41440 NULL
97656 +ntfs_file_buffered_write_41442 ntfs_file_buffered_write 4-6 41442 NULL
97657 +pcpu_build_alloc_info_41443 pcpu_build_alloc_info 1-2-3 41443 NULL
97658 +layout_leb_in_gaps_41470 layout_leb_in_gaps 0 41470 NULL
97659 +snd_pcm_status_41472 snd_pcm_status 0 41472 NULL
97660 +rt2x00debug_write_rfcsr_41473 rt2x00debug_write_rfcsr 3 41473 NULL
97661 +wep_interrupt_read_41492 wep_interrupt_read 3 41492 NULL
97662 +hpfs_translate_name_41497 hpfs_translate_name 3 41497 NULL
97663 +xfrm_hash_new_size_41505 xfrm_hash_new_size 0-1 41505 NULL
97664 +ldisc_receive_41516 ldisc_receive 4 41516 NULL
97665 +tx_tx_frame_checksum_read_41553 tx_tx_frame_checksum_read 3 41553 NULL
97666 +ath6kl_endpoint_stats_read_41554 ath6kl_endpoint_stats_read 3 41554 NULL
97667 +gserial_setup_41558 gserial_setup 2 41558 NULL
97668 +nr_status_frames_41559 nr_status_frames 0-1 41559 NULL
97669 +batadv_receive_client_update_packet_41578 batadv_receive_client_update_packet 3 41578 NULL
97670 +rng_dev_read_41581 rng_dev_read 3 41581 NULL
97671 +read_file_rx_chainmask_41605 read_file_rx_chainmask 3 41605 NULL
97672 +vga_io_r_41609 vga_io_r 0 41609 NULL
97673 +usb_endpoint_maxp_41613 usb_endpoint_maxp 0 41613 NULL
97674 +a2mp_send_41615 a2mp_send 4 41615 NULL
97675 +mempool_create_kmalloc_pool_41650 mempool_create_kmalloc_pool 1 41650 NULL
97676 +rx_rx_pre_complt_read_41653 rx_rx_pre_complt_read 3 41653 NULL
97677 +get_std_timing_41654 get_std_timing 0 41654 NULL
97678 +squashfs_cache_init_41656 squashfs_cache_init 2 41656 NULL
97679 +ieee80211_if_fmt_bssid_41677 ieee80211_if_fmt_bssid 3 41677 NULL
97680 +params_period_bytes_41683 params_period_bytes 0 41683 NULL
97681 +aac_src_ioremap_41688 aac_src_ioremap 2 41688 NULL
97682 +bdx_tx_db_init_41719 bdx_tx_db_init 2 41719 NULL
97683 +sys_pwritev_41722 sys_pwritev 3 41722 NULL
97684 +get_bios_ebda_41730 get_bios_ebda 0 41730 NULL
97685 +fillonedir_41746 fillonedir 3 41746 NULL
97686 +ocfs2_dx_dir_rebalance_41793 ocfs2_dx_dir_rebalance 7 41793 NULL
97687 +hsi_alloc_controller_41802 hsi_alloc_controller 1 41802 NULL
97688 +da9052_enable_irq_41814 da9052_enable_irq 2 41814 NULL
97689 +sco_send_frame_41815 sco_send_frame 3 41815 NULL
97690 +ixgbe_dbg_netdev_ops_read_41839 ixgbe_dbg_netdev_ops_read 3 41839 NULL
97691 +do_ip_setsockopt_41852 do_ip_setsockopt 5 41852 NULL
97692 +irq_data_to_status_reg_41854 irq_data_to_status_reg 0 41854 NULL
97693 +keyctl_instantiate_key_41855 keyctl_instantiate_key 3 41855 NULL
97694 +ieee80211_rx_radiotap_space_41870 ieee80211_rx_radiotap_space 0 41870 NULL
97695 +get_fdb_entries_41916 get_fdb_entries 3 41916 NULL
97696 +ceph_get_direct_page_vector_41917 ceph_get_direct_page_vector 2 41917 NULL
97697 +find_ge_pid_41918 find_ge_pid 1 41918 NULL
97698 +build_inv_iotlb_pages_41922 build_inv_iotlb_pages 4-5 41922 NULL
97699 +nfsd_getxattr_41934 nfsd_getxattr 0 41934 NULL
97700 +ext4_da_write_inline_data_begin_41935 ext4_da_write_inline_data_begin 3-4 41935 NULL
97701 +ocfs2_xattr_bucket_get_name_value_41949 ocfs2_xattr_bucket_get_name_value 0 41949 NULL
97702 +portnames_read_41958 portnames_read 3 41958 NULL
97703 +ubi_self_check_all_ff_41959 ubi_self_check_all_ff 4 41959 NULL
97704 +dst_mtu_41969 dst_mtu 0 41969 NULL
97705 +cx24116_writeregN_41975 cx24116_writeregN 4 41975 NULL
97706 +ubi_io_is_bad_41983 ubi_io_is_bad 0 41983 NULL
97707 +lguest_map_42008 lguest_map 1-2 42008 NULL
97708 +pool_allocate_42012 pool_allocate 3 42012 NULL
97709 +spidev_sync_read_42014 spidev_sync_read 0 42014 NULL
97710 +acpi_ut_create_buffer_object_42030 acpi_ut_create_buffer_object 1 42030 NULL
97711 +__hwahc_op_set_gtk_42038 __hwahc_op_set_gtk 4 42038 NULL
97712 +irda_sendmsg_ultra_42047 irda_sendmsg_ultra 4 42047 NULL
97713 +dma_generic_alloc_coherent_42048 dma_generic_alloc_coherent 2 42048 NULL nohasharray
97714 +jffs2_do_link_42048 jffs2_do_link 6 42048 &dma_generic_alloc_coherent_42048
97715 +ps_poll_upsd_max_ap_turn_read_42050 ps_poll_upsd_max_ap_turn_read 3 42050 NULL
97716 +InterfaceTransmitPacket_42058 InterfaceTransmitPacket 3 42058 NULL
97717 +scsi_execute_req_42088 scsi_execute_req 5 42088 NULL
97718 +sk_chk_filter_42095 sk_chk_filter 2 42095 NULL
97719 +submit_inquiry_42108 submit_inquiry 3 42108 NULL
97720 +sysfs_read_file_42113 sysfs_read_file 3 42113 NULL
97721 +Read_hfc16_stable_42131 Read_hfc16_stable 0 42131 NULL
97722 +v9fs_alloc_rdir_buf_42150 v9fs_alloc_rdir_buf 2 42150 NULL
97723 +mmc_align_data_size_42161 mmc_align_data_size 0-2 42161 NULL
97724 +read_file_base_eeprom_42168 read_file_base_eeprom 3 42168 NULL
97725 +oprofilefs_str_to_user_42182 oprofilefs_str_to_user 3 42182 NULL
97726 +get_znodes_to_commit_42201 get_znodes_to_commit 0 42201 NULL
97727 +btmrvl_hsmode_write_42252 btmrvl_hsmode_write 3 42252 NULL
97728 +rx_defrag_need_decrypt_read_42253 rx_defrag_need_decrypt_read 3 42253 NULL
97729 +netxen_nic_map_indirect_address_128M_42257 netxen_nic_map_indirect_address_128M 2 42257 NULL
97730 +savu_sysfs_write_42273 savu_sysfs_write 6 42273 NULL
97731 +snd_pcm_hw_param_value_max_42280 snd_pcm_hw_param_value_max 0 42280 NULL
97732 +sel_read_perm_42302 sel_read_perm 3 42302 NULL
97733 +sctp_setsockopt_del_key_42304 sctp_setsockopt_del_key 3 42304 NULL nohasharray
97734 +ulong_read_file_42304 ulong_read_file 3 42304 &sctp_setsockopt_del_key_42304
97735 +xfs_vm_readpages_42308 xfs_vm_readpages 4 42308 NULL
97736 +hysdn_conf_read_42324 hysdn_conf_read 3 42324 NULL
97737 +tcp_sync_mss_42330 tcp_sync_mss 2-0 42330 NULL
97738 +snd_pcm_plug_alloc_42339 snd_pcm_plug_alloc 2 42339 NULL
97739 +ide_raw_taskfile_42355 ide_raw_taskfile 4 42355 NULL
97740 +il_dbgfs_disable_ht40_read_42386 il_dbgfs_disable_ht40_read 3 42386 NULL
97741 +msnd_fifo_read_42406 msnd_fifo_read 0-3 42406 NULL
97742 +krng_get_random_42420 krng_get_random 3 42420 NULL
97743 +gsm_data_alloc_42437 gsm_data_alloc 3 42437 NULL
97744 +key_conf_keyidx_read_42443 key_conf_keyidx_read 3 42443 NULL
97745 +snd_pcm_action_group_42452 snd_pcm_action_group 0 42452 NULL
97746 +tcm_loop_change_queue_depth_42454 tcm_loop_change_queue_depth 2 42454 NULL
97747 +tc3589x_gpio_irq_get_virq_42457 tc3589x_gpio_irq_get_virq 2 42457 NULL
97748 +ext3_valid_block_bitmap_42459 ext3_valid_block_bitmap 3 42459 NULL
97749 +__simple_xattr_set_42474 __simple_xattr_set 4 42474 NULL
97750 +follow_hugetlb_page_42486 follow_hugetlb_page 0-7 42486 NULL
97751 +omfs_readpages_42490 omfs_readpages 4 42490 NULL
97752 +brcmf_sdbrcm_bus_txctl_42492 brcmf_sdbrcm_bus_txctl 3 42492 NULL
97753 +kvm_write_wall_clock_42520 kvm_write_wall_clock 2 42520 NULL
97754 +smk_write_netlbladdr_42525 smk_write_netlbladdr 3 42525 NULL
97755 +snd_emux_create_port_42533 snd_emux_create_port 3 42533 NULL
97756 +dbAllocNear_42546 dbAllocNear 0 42546 NULL
97757 +i915_ring_stop_read_42549 i915_ring_stop_read 3 42549 NULL nohasharray
97758 +ath6kl_wmi_proc_events_vif_42549 ath6kl_wmi_proc_events_vif 5 42549 &i915_ring_stop_read_42549
97759 +iwl_print_event_log_42566 iwl_print_event_log 0-5-7 42566 NULL
97760 +xfrm_new_hash_mask_42579 xfrm_new_hash_mask 0-1 42579 NULL
97761 +oom_score_adj_write_42594 oom_score_adj_write 3 42594 NULL
97762 +map_state_42602 map_state 1 42602 NULL nohasharray
97763 +__pskb_pull_42602 __pskb_pull 2 42602 &map_state_42602
97764 +sys_move_pages_42626 sys_move_pages 2 42626 NULL
97765 +ieee80211_if_fmt_dot11MeshHWMPactivePathTimeout_42635 ieee80211_if_fmt_dot11MeshHWMPactivePathTimeout 3 42635 NULL
97766 +scsi_activate_tcq_42640 scsi_activate_tcq 2 42640 NULL
97767 +br_mdb_rehash_42643 br_mdb_rehash 2 42643 NULL
97768 +_regmap_raw_write_42652 _regmap_raw_write 4-2 42652 NULL
97769 +l2tp_xmit_skb_42672 l2tp_xmit_skb 3 42672 NULL
97770 +request_key_and_link_42693 request_key_and_link 4 42693 NULL
97771 +vb2_read_42703 vb2_read 3 42703 NULL
97772 +sierra_net_send_cmd_42708 sierra_net_send_cmd 3 42708 NULL
97773 +__ocfs2_decrease_refcount_42717 __ocfs2_decrease_refcount 4 42717 NULL
97774 +dvb_demux_ioctl_42733 dvb_demux_ioctl 2 42733 NULL
97775 +set_aoe_iflist_42737 set_aoe_iflist 2 42737 NULL
97776 +ax25_setsockopt_42740 ax25_setsockopt 5 42740 NULL
97777 +xen_bind_pirq_gsi_to_irq_42750 xen_bind_pirq_gsi_to_irq 1 42750 NULL
97778 +snd_midi_event_decode_42780 snd_midi_event_decode 0 42780 NULL
97779 +cryptd_hash_setkey_42781 cryptd_hash_setkey 3 42781 NULL
97780 +koneplus_sysfs_read_42792 koneplus_sysfs_read 6 42792 NULL
97781 +ntfs_attr_extend_allocation_42796 ntfs_attr_extend_allocation 0-2 42796 NULL
97782 +fw_device_op_compat_ioctl_42804 fw_device_op_compat_ioctl 2-3 42804 NULL
97783 +drm_ioctl_42813 drm_ioctl 2 42813 NULL
97784 +iwl_dbgfs_ucode_bt_stats_read_42820 iwl_dbgfs_ucode_bt_stats_read 3 42820 NULL
97785 +set_arg_42824 set_arg 3 42824 NULL
97786 +ocfs2_desc_bitmap_to_cluster_off_42831 ocfs2_desc_bitmap_to_cluster_off 2 42831 NULL
97787 +xfs_buf_read_uncached_42844 xfs_buf_read_uncached 3 42844 NULL
97788 +prandom_u32_42853 prandom_u32 0 42853 NULL
97789 +of_property_count_strings_42863 of_property_count_strings 0 42863 NULL
97790 +ocfs2_clusters_for_bytes_42872 ocfs2_clusters_for_bytes 0-2 42872 NULL
97791 +pskb_expand_head_42881 pskb_expand_head 2-3 42881 NULL
97792 +vt_compat_ioctl_42887 vt_compat_ioctl 3 42887 NULL
97793 +tipc_port_recv_sections_42890 tipc_port_recv_sections 4 42890 NULL
97794 +xpc_kmalloc_cacheline_aligned_42895 xpc_kmalloc_cacheline_aligned 1 42895 NULL
97795 +SendTxCommandPacket_42901 SendTxCommandPacket 3 42901 NULL
97796 +hd_end_request_42904 hd_end_request 2 42904 NULL
97797 +sta_last_rx_rate_read_42909 sta_last_rx_rate_read 3 42909 NULL
97798 +sctp_getsockopt_maxburst_42941 sctp_getsockopt_maxburst 2 42941 NULL
97799 +get_unmapped_area_42944 get_unmapped_area 0 42944 NULL
97800 +sys_sethostname_42962 sys_sethostname 2 42962 NULL
97801 +read_file_node_stat_42964 read_file_node_stat 3 42964 NULL
97802 +compat_udpv6_setsockopt_42981 compat_udpv6_setsockopt 5 42981 NULL
97803 +snd_timer_user_ioctl_compat_42985 snd_timer_user_ioctl_compat 3 42985 NULL
97804 +nfs_idmap_get_desc_42990 nfs_idmap_get_desc 4-2 42990 NULL
97805 +mlx4_qp_reserve_range_43000 mlx4_qp_reserve_range 2-3 43000 NULL
97806 +isr_rx_mem_overflow_read_43025 isr_rx_mem_overflow_read 3 43025 NULL
97807 +wep_default_key_count_read_43035 wep_default_key_count_read 3 43035 NULL
97808 +nouveau_gpuobj_create__43072 nouveau_gpuobj_create_ 9 43072 NULL
97809 +cpuset_sprintf_memlist_43088 cpuset_sprintf_memlist 0 43088 NULL
97810 +ieee80211_if_fmt_drop_unencrypted_43107 ieee80211_if_fmt_drop_unencrypted 3 43107 NULL
97811 +read_file_dfs_43145 read_file_dfs 3 43145 NULL
97812 +uuid_string_43154 uuid_string 0 43154 NULL
97813 +usb_string_sub_43164 usb_string_sub 0 43164 NULL
97814 +il_dbgfs_power_save_status_read_43165 il_dbgfs_power_save_status_read 3 43165 NULL
97815 +ath6kl_set_assoc_req_ies_43185 ath6kl_set_assoc_req_ies 3 43185 NULL
97816 +process_measurement_43190 process_measurement 0 43190 NULL
97817 +ext4_xattr_ibody_get_43200 ext4_xattr_ibody_get 0 43200 NULL
97818 +uio_write_43202 uio_write 3 43202 NULL
97819 +iso_callback_43208 iso_callback 3 43208 NULL
97820 +f2fs_acl_from_disk_43210 f2fs_acl_from_disk 2 43210 NULL
97821 +atomic_long_add_return_43217 atomic_long_add_return 1 43217 NULL
97822 +comedi_compat_ioctl_43218 comedi_compat_ioctl 3 43218 NULL
97823 +vmemmap_alloc_block_43245 vmemmap_alloc_block 1 43245 NULL
97824 +fixup_leb_43256 fixup_leb 3 43256 NULL
97825 +ide_end_rq_43269 ide_end_rq 4 43269 NULL
97826 +evtchn_write_43278 evtchn_write 3 43278 NULL
97827 +filemap_write_and_wait_range_43279 filemap_write_and_wait_range 0 43279 NULL
97828 +mpage_alloc_43299 mpage_alloc 3 43299 NULL
97829 +get_nr_irqs_gsi_43315 get_nr_irqs_gsi 0 43315 NULL
97830 +__ext4_get_inode_loc_43332 __ext4_get_inode_loc 0 43332 NULL
97831 +gart_free_coherent_43362 gart_free_coherent 4-2 43362 NULL
97832 +xenfb_write_43412 xenfb_write 3 43412 NULL
97833 +__alloc_bootmem_low_43423 __alloc_bootmem_low 1 43423 NULL nohasharray
97834 +gdm_wimax_netif_rx_43423 gdm_wimax_netif_rx 3 43423 &__alloc_bootmem_low_43423
97835 +usb_alloc_urb_43436 usb_alloc_urb 1 43436 NULL
97836 +ath6kl_wmi_roam_tbl_event_rx_43440 ath6kl_wmi_roam_tbl_event_rx 3 43440 NULL
97837 +usb_string_43443 usb_string 0 43443 NULL nohasharray
97838 +usemap_size_43443 usemap_size 0-2-1 43443 &usb_string_43443
97839 +alloc_new_reservation_43480 alloc_new_reservation 4 43480 NULL
97840 +tx_tx_data_prepared_read_43497 tx_tx_data_prepared_read 3 43497 NULL
97841 +ieee80211_if_fmt_dot11MeshHWMPnetDiameterTraversalTime_43505 ieee80211_if_fmt_dot11MeshHWMPnetDiameterTraversalTime 3 43505 NULL
97842 +do_readlink_43518 do_readlink 2 43518 NULL
97843 +dvb_ca_en50221_io_write_43533 dvb_ca_en50221_io_write 3 43533 NULL
97844 +cachefiles_daemon_write_43535 cachefiles_daemon_write 3 43535 NULL
97845 +tx_frag_failed_read_43540 tx_frag_failed_read 3 43540 NULL nohasharray
97846 +ufs_alloccg_block_43540 ufs_alloccg_block 3-0 43540 &tx_frag_failed_read_43540
97847 +ath_rx_init_43564 ath_rx_init 2 43564 NULL
97848 +_fc_frame_alloc_43568 _fc_frame_alloc 1 43568 NULL
97849 +rpc_malloc_43573 rpc_malloc 2 43573 NULL
97850 +lpfc_idiag_drbacc_read_reg_43606 lpfc_idiag_drbacc_read_reg 0-3 43606 NULL
97851 +proc_read_43614 proc_read 3 43614 NULL
97852 +bio_integrity_tag_43658 bio_integrity_tag 3 43658 NULL
97853 +tps65217_set_bits_43659 tps65217_set_bits 2 43659 NULL nohasharray
97854 +ext4_acl_count_43659 ext4_acl_count 0-1 43659 &tps65217_set_bits_43659
97855 +dmam_declare_coherent_memory_43679 dmam_declare_coherent_memory 4-2 43679 NULL
97856 +calgary_map_page_43686 calgary_map_page 3-4 43686 NULL
97857 +max77693_bulk_write_43698 max77693_bulk_write 2-3 43698 NULL
97858 +drbd_md_first_sector_43729 drbd_md_first_sector 0 43729 NULL
97859 +snd_rme32_playback_copy_43732 snd_rme32_playback_copy 5 43732 NULL
97860 +ocfs2_replace_clusters_43733 ocfs2_replace_clusters 5 43733 NULL
97861 +osdv1_attr_list_elem_size_43747 osdv1_attr_list_elem_size 0-1 43747 NULL
97862 +__bm_find_next_43748 __bm_find_next 2 43748 NULL
97863 +gigaset_initcs_43753 gigaset_initcs 2 43753 NULL
97864 +sctp_setsockopt_active_key_43755 sctp_setsockopt_active_key 3 43755 NULL
97865 +ocfs2_xattr_get_value_outside_43787 ocfs2_xattr_get_value_outside 0 43787 NULL nohasharray
97866 +byte_pos_43787 byte_pos 0-2 43787 &ocfs2_xattr_get_value_outside_43787
97867 +btrfs_copy_from_user_43806 btrfs_copy_from_user 3-1 43806 NULL
97868 +ext4_read_block_bitmap_43814 ext4_read_block_bitmap 2 43814 NULL
97869 +ieee80211_if_fmt_element_ttl_43825 ieee80211_if_fmt_element_ttl 3 43825 NULL
97870 +ieee80211_alloc_hw_43829 ieee80211_alloc_hw 1 43829 NULL
97871 +p54_download_eeprom_43842 p54_download_eeprom 4 43842 NULL
97872 +read_flush_43851 read_flush 3 43851 NULL
97873 +ocfs2_block_group_find_clear_bits_43874 ocfs2_block_group_find_clear_bits 4 43874 NULL
97874 +pm860x_bulk_write_43875 pm860x_bulk_write 3-2 43875 NULL
97875 +ec_dbgfs_cmd_write_43895 ec_dbgfs_cmd_write 3 43895 NULL
97876 +prism2_sta_send_mgmt_43916 prism2_sta_send_mgmt 5 43916 NULL
97877 +SendString_43928 SendString 3 43928 NULL
97878 +xen_register_gsi_43946 xen_register_gsi 1-2 43946 NULL
97879 +stats_dot11RTSFailureCount_read_43948 stats_dot11RTSFailureCount_read 3 43948 NULL
97880 +__get_required_blob_size_43980 __get_required_blob_size 0-2-3 43980 NULL
97881 +nla_reserve_43984 nla_reserve 3 43984 NULL
97882 +scsi_command_size_43992 scsi_command_size 0 43992 NULL nohasharray
97883 +bcm_recvmsg_43992 bcm_recvmsg 4 43992 &scsi_command_size_43992
97884 +emit_flags_44006 emit_flags 4-3 44006 NULL
97885 +write_flush_procfs_44011 write_flush_procfs 3 44011 NULL
97886 +xlog_recover_add_to_cont_trans_44102 xlog_recover_add_to_cont_trans 4 44102 NULL
97887 +tracing_set_trace_read_44122 tracing_set_trace_read 3 44122 NULL
97888 +vmw_gmr_bind_44130 vmw_gmr_bind 3 44130 NULL
97889 +scsi_get_resid_44147 scsi_get_resid 0 44147 NULL
97890 +ubifs_find_dirty_idx_leb_44169 ubifs_find_dirty_idx_leb 0 44169 NULL
97891 +ocfs2_xattr_bucket_find_44174 ocfs2_xattr_bucket_find 0 44174 NULL
97892 +handle_eviocgbit_44193 handle_eviocgbit 3 44193 NULL
97893 +IO_APIC_get_PCI_irq_vector_44198 IO_APIC_get_PCI_irq_vector 0 44198 NULL
97894 +__set_free_44211 __set_free 2 44211 NULL
97895 +claim_ptd_buffers_44213 claim_ptd_buffers 3 44213 NULL
97896 +srp_alloc_iu_44227 srp_alloc_iu 2 44227 NULL
97897 +ioapic_register_intr_44238 ioapic_register_intr 1 44238 NULL
97898 +scsi_track_queue_full_44239 scsi_track_queue_full 2 44239 NULL
97899 +tc3589x_gpio_irq_map_44245 tc3589x_gpio_irq_map 2 44245 NULL
97900 +enlarge_skb_44248 enlarge_skb 2 44248 NULL nohasharray
97901 +xfs_buf_readahead_map_44248 xfs_buf_readahead_map 3 44248 &enlarge_skb_44248
97902 +ufs_clusteracct_44293 ufs_clusteracct 3 44293 NULL
97903 +ocfs2_zero_range_for_truncate_44294 ocfs2_zero_range_for_truncate 3 44294 NULL
97904 +ath6kl_keepalive_read_44303 ath6kl_keepalive_read 3 44303 NULL
97905 +bitmap_scnprintf_44318 bitmap_scnprintf 0-2 44318 NULL
97906 +dispatch_proc_write_44320 dispatch_proc_write 3 44320 NULL
97907 +ubi_eba_write_leb_st_44343 ubi_eba_write_leb_st 5 44343 NULL
97908 +nfs_fscache_get_super_cookie_44355 nfs_fscache_get_super_cookie 3 44355 NULL nohasharray
97909 +blk_queue_init_tags_44355 blk_queue_init_tags 2 44355 &nfs_fscache_get_super_cookie_44355
97910 +rts_threshold_read_44384 rts_threshold_read 3 44384 NULL
97911 +aoedev_flush_44398 aoedev_flush 2 44398 NULL
97912 +drm_buffer_alloc_44405 drm_buffer_alloc 2 44405 NULL
97913 +osst_do_scsi_44410 osst_do_scsi 4 44410 NULL
97914 +ieee80211_if_read_rc_rateidx_mcs_mask_5ghz_44423 ieee80211_if_read_rc_rateidx_mcs_mask_5ghz 3 44423 NULL
97915 +prandom_u32_state_44445 prandom_u32_state 0 44445 NULL
97916 +btrfs_chunk_item_size_44478 btrfs_chunk_item_size 0-1 44478 NULL
97917 +sdio_align_size_44489 sdio_align_size 0-2 44489 NULL
97918 +ieee80211_if_read_dropped_frames_ttl_44500 ieee80211_if_read_dropped_frames_ttl 3 44500 NULL
97919 +security_getprocattr_44505 security_getprocattr 0 44505 NULL nohasharray
97920 +iwl_dbgfs_sram_read_44505 iwl_dbgfs_sram_read 3 44505 &security_getprocattr_44505
97921 +spidev_write_44510 spidev_write 3 44510 NULL
97922 +sys_msgsnd_44537 sys_msgsnd 3 44537 NULL nohasharray
97923 +comm_write_44537 comm_write 3 44537 &sys_msgsnd_44537
97924 +snd_pcm_drop_44542 snd_pcm_drop 0 44542 NULL
97925 +dbg_chk_pnode_44555 dbg_chk_pnode 0 44555 NULL
97926 +snd_pcm_alloc_vmalloc_buffer_44595 snd_pcm_alloc_vmalloc_buffer 2 44595 NULL
97927 +slip_compat_ioctl_44599 slip_compat_ioctl 4 44599 NULL
97928 +wm5100_gpio_set_44602 wm5100_gpio_set 2 44602 NULL
97929 +brcmf_sdbrcm_glom_len_44618 brcmf_sdbrcm_glom_len 0 44618 NULL
97930 +cfpkt_add_body_44630 cfpkt_add_body 3 44630 NULL
97931 +ext2_new_block_44645 ext2_new_block 2 44645 NULL
97932 +alloc_ctrl_packet_44667 alloc_ctrl_packet 1 44667 NULL
97933 +mpi_resize_44674 mpi_resize 2 44674 NULL
97934 +ts_read_44687 ts_read 3 44687 NULL
97935 +_zd_iowrite32v_locked_44725 _zd_iowrite32v_locked 3 44725 NULL
97936 +clusterip_proc_write_44729 clusterip_proc_write 3 44729 NULL
97937 +fib_count_nexthops_44730 fib_count_nexthops 0 44730 NULL
97938 +key_tx_rx_count_read_44742 key_tx_rx_count_read 3 44742 NULL
97939 +WIL_GET_BITS_44747 WIL_GET_BITS 0-1-2-3 44747 NULL
97940 +tnode_new_44757 tnode_new 3 44757 NULL nohasharray
97941 +pty_write_44757 pty_write 3 44757 &tnode_new_44757
97942 +__videobuf_copy_stream_44769 __videobuf_copy_stream 4 44769 NULL
97943 +handsfree_ramp_44777 handsfree_ramp 2 44777 NULL
97944 +sctp_setsockopt_44788 sctp_setsockopt 5 44788 NULL
97945 +rx_dropped_read_44799 rx_dropped_read 3 44799 NULL
97946 +qla4xxx_alloc_work_44813 qla4xxx_alloc_work 2 44813 NULL
97947 +rmap_write_protect_44833 rmap_write_protect 2 44833 NULL
97948 +sisusb_write_44834 sisusb_write 3 44834 NULL
97949 +nl80211_send_unprot_disassoc_44846 nl80211_send_unprot_disassoc 4 44846 NULL
97950 +kvm_read_hva_44847 kvm_read_hva 3 44847 NULL
97951 +skb_availroom_44883 skb_availroom 0 44883 NULL
97952 +nf_bridge_encap_header_len_44890 nf_bridge_encap_header_len 0 44890 NULL
97953 +do_tty_write_44896 do_tty_write 5 44896 NULL
97954 +tx_queue_status_read_44978 tx_queue_status_read 3 44978 NULL
97955 +nf_nat_seq_adjust_44989 nf_nat_seq_adjust 4 44989 NULL
97956 +max77693_write_reg_45004 max77693_write_reg 2 45004 NULL
97957 +ftdi_process_packet_45005 ftdi_process_packet 5 45005 NULL
97958 +bytepos_delta_45017 bytepos_delta 0 45017 NULL
97959 +read_block_bitmap_45021 read_block_bitmap 2 45021 NULL nohasharray
97960 +ptrace_writedata_45021 ptrace_writedata 4-3 45021 &read_block_bitmap_45021
97961 +vhci_get_user_45039 vhci_get_user 3 45039 NULL
97962 +sel_write_user_45060 sel_write_user 3 45060 NULL
97963 +do_video_ioctl_45069 do_video_ioctl 3 45069 NULL nohasharray
97964 +snd_mixart_BA0_read_45069 snd_mixart_BA0_read 5 45069 &do_video_ioctl_45069
97965 +kvm_mmu_page_get_gfn_45110 kvm_mmu_page_get_gfn 0-2 45110 NULL
97966 +pwr_missing_bcns_cnt_read_45113 pwr_missing_bcns_cnt_read 3 45113 NULL
97967 +usbdev_read_45114 usbdev_read 3 45114 NULL
97968 +send_to_tty_45141 send_to_tty 3 45141 NULL
97969 +stmpe_irq_map_45146 stmpe_irq_map 2 45146 NULL
97970 +crypto_aead_blocksize_45148 crypto_aead_blocksize 0 45148 NULL
97971 +gen_bitmask_string_45149 gen_bitmask_string 6 45149 NULL
97972 +ocfs2_remove_inode_range_45156 ocfs2_remove_inode_range 3-4 45156 NULL nohasharray
97973 +device_write_45156 device_write 3 45156 &ocfs2_remove_inode_range_45156
97974 +ocfs2_dq_frozen_trigger_45159 ocfs2_dq_frozen_trigger 4 45159 NULL
97975 +tomoyo_write_self_45161 tomoyo_write_self 3 45161 NULL
97976 +sta_agg_status_write_45164 sta_agg_status_write 3 45164 NULL
97977 +snd_sb_csp_load_user_45190 snd_sb_csp_load_user 3 45190 NULL
97978 +num_clusters_in_group_45194 num_clusters_in_group 2 45194 NULL
97979 +add_child_45201 add_child 4 45201 NULL
97980 +iso_alloc_urb_45206 iso_alloc_urb 4-5 45206 NULL
97981 +spi_alloc_master_45223 spi_alloc_master 2 45223 NULL
97982 +ieee80211_if_read_peer_45233 ieee80211_if_read_peer 3 45233 NULL
97983 +input_mt_init_slots_45279 input_mt_init_slots 2 45279 NULL
97984 +vcc_compat_ioctl_45291 vcc_compat_ioctl 3 45291 NULL
97985 +snd_pcm_oss_sync1_45298 snd_pcm_oss_sync1 2 45298 NULL
97986 +copy_vm86_regs_from_user_45340 copy_vm86_regs_from_user 3 45340 NULL
97987 +lane2_associate_req_45398 lane2_associate_req 4 45398 NULL
97988 +keymap_store_45406 keymap_store 4 45406 NULL
97989 +ieee80211_if_fmt_dot11MeshHWMProotInterval_45421 ieee80211_if_fmt_dot11MeshHWMProotInterval 3 45421 NULL
97990 +tty_buffer_alloc_45437 tty_buffer_alloc 2 45437 NULL
97991 +do_mmap_pgoff_45441 do_mmap_pgoff 0 45441 NULL
97992 +intel_render_ring_init_dri_45446 intel_render_ring_init_dri 2-3 45446 NULL
97993 +__node_remap_45458 __node_remap 4 45458 NULL
97994 +rds_ib_set_wr_signal_state_45463 rds_ib_set_wr_signal_state 0 45463 NULL
97995 +udp_manip_pkt_45467 udp_manip_pkt 4 45467 NULL
97996 +tracing_read_dyn_info_45468 tracing_read_dyn_info 3 45468 NULL
97997 +snd_pcm_hwsync_45479 snd_pcm_hwsync 0 45479 NULL
97998 +arizona_init_fll_45503 arizona_init_fll 4-5 45503 NULL
97999 +rds_message_copy_from_user_45510 rds_message_copy_from_user 3 45510 NULL
98000 +clone_bio_45516 clone_bio 6 45516 NULL
98001 +sys_lgetxattr_45531 sys_lgetxattr 4 45531 NULL
98002 +cgroup_read_u64_45532 cgroup_read_u64 5 45532 NULL
98003 +copy_macs_45534 copy_macs 4 45534 NULL
98004 +nla_attr_size_45545 nla_attr_size 0-1 45545 NULL
98005 +v9fs_direct_read_45546 v9fs_direct_read 3 45546 NULL
98006 +cx18_copy_mdl_to_user_45549 cx18_copy_mdl_to_user 4 45549 NULL
98007 +atomic_long_sub_return_45551 atomic_long_sub_return 1 45551 NULL
98008 +ext3_group_first_block_no_45555 ext3_group_first_block_no 0-2 45555 NULL
98009 +stats_dot11ACKFailureCount_read_45558 stats_dot11ACKFailureCount_read 3 45558 NULL
98010 +posix_acl_xattr_size_45561 posix_acl_xattr_size 0-1 45561 NULL
98011 +venus_rmdir_45564 venus_rmdir 4 45564 NULL
98012 +ipath_create_cq_45586 ipath_create_cq 2 45586 NULL
98013 +rdma_set_ib_paths_45592 rdma_set_ib_paths 3 45592 NULL
98014 +hidraw_get_report_45609 hidraw_get_report 3 45609 NULL
98015 +audit_log_n_hex_45617 audit_log_n_hex 3 45617 NULL
98016 +da9052_gpio_set_45643 da9052_gpio_set 2 45643 NULL
98017 +ebitmap_next_positive_45651 ebitmap_next_positive 3 45651 NULL
98018 +dma_map_cont_45668 dma_map_cont 5 45668 NULL
98019 +compat_mpctl_ioctl_45671 compat_mpctl_ioctl 2 45671 NULL
98020 +dgram_sendmsg_45679 dgram_sendmsg 4 45679 NULL
98021 +smk_write_ambient_45691 smk_write_ambient 3 45691 NULL
98022 +dm_compat_ctl_ioctl_45692 dm_compat_ctl_ioctl 3 45692 NULL
98023 +unix_dgram_sendmsg_45699 unix_dgram_sendmsg 4 45699 NULL nohasharray
98024 +bscnl_emit_45699 bscnl_emit 2-5-0 45699 &unix_dgram_sendmsg_45699
98025 +dvb_ca_en50221_init_45718 dvb_ca_en50221_init 4 45718 NULL
98026 +snd_cs46xx_io_read_45734 snd_cs46xx_io_read 5 45734 NULL
98027 +rw_copy_check_uvector_45748 rw_copy_check_uvector 3 45748 NULL nohasharray
98028 +v4l2_ctrl_new_std_45748 v4l2_ctrl_new_std 5 45748 &rw_copy_check_uvector_45748
98029 +lkdtm_debugfs_read_45752 lkdtm_debugfs_read 3 45752 NULL
98030 +nilfs_compat_ioctl_45769 nilfs_compat_ioctl 3 45769 NULL
98031 +alloc_ts_config_45775 alloc_ts_config 1 45775 NULL
98032 +raw_setsockopt_45800 raw_setsockopt 5 45800 NULL
98033 +lbs_rdbbp_read_45805 lbs_rdbbp_read 3 45805 NULL
98034 +pcpu_alloc_alloc_info_45813 pcpu_alloc_alloc_info 1-2 45813 NULL
98035 +fm_v4l2_init_video_device_45821 fm_v4l2_init_video_device 2 45821 NULL
98036 +memcg_update_cache_size_45828 memcg_update_cache_size 2 45828 NULL
98037 +amthi_read_45831 amthi_read 4 45831 NULL
98038 +x509_process_extension_45854 x509_process_extension 5 45854 NULL
98039 +isdn_write_45863 isdn_write 3 45863 NULL
98040 +rbd_get_num_segments_45864 rbd_get_num_segments 0-2-3 45864 NULL
98041 +unpack_orig_pfns_45867 unpack_orig_pfns 0 45867 NULL
98042 +get_rdac_req_45882 get_rdac_req 3 45882 NULL
98043 +ocfs2_xattr_block_find_45891 ocfs2_xattr_block_find 0 45891 NULL
98044 +dbgfs_frame_45917 dbgfs_frame 3 45917 NULL
98045 +nf_nat_ftp_fmt_cmd_45926 nf_nat_ftp_fmt_cmd 0 45926 NULL
98046 +alloc_mr_45935 alloc_mr 1 45935 NULL
98047 +rb_simple_read_45972 rb_simple_read 3 45972 NULL
98048 +ezusb_writememory_45976 ezusb_writememory 4 45976 NULL
98049 +ioat2_dca_count_dca_slots_45984 ioat2_dca_count_dca_slots 0 45984 NULL
98050 +sierra_setup_urb_46029 sierra_setup_urb 5 46029 NULL
98051 +get_free_entries_46030 get_free_entries 1 46030 NULL
98052 +__access_remote_vm_46031 __access_remote_vm 0-5-3 46031 NULL
98053 +snd_emu10k1x_ptr_read_46049 snd_emu10k1x_ptr_read 0 46049 NULL
98054 +acpi_register_gsi_xen_hvm_46052 acpi_register_gsi_xen_hvm 2 46052 NULL
98055 +line6_midibuf_bytes_used_46059 line6_midibuf_bytes_used 0 46059 NULL
98056 +__ocfs2_move_extent_46060 __ocfs2_move_extent 5-6 46060 NULL nohasharray
98057 +dma_tx_errors_read_46060 dma_tx_errors_read 3 46060 &__ocfs2_move_extent_46060
98058 +slhc_toss_46066 slhc_toss 0 46066 NULL
98059 +sel_commit_bools_write_46077 sel_commit_bools_write 3 46077 NULL
98060 +vfio_config_do_rw_46091 vfio_config_do_rw 3 46091 NULL
98061 +ata_host_alloc_46094 ata_host_alloc 2 46094 NULL
98062 +arizona_set_irq_wake_46101 arizona_set_irq_wake 2 46101 NULL
98063 +pkt_ctl_compat_ioctl_46110 pkt_ctl_compat_ioctl 3 46110 NULL
98064 +il3945_ucode_general_stats_read_46111 il3945_ucode_general_stats_read 3 46111 NULL nohasharray
98065 +memcg_update_array_size_46111 memcg_update_array_size 1 46111 &il3945_ucode_general_stats_read_46111
98066 +mlx4_ib_alloc_fast_reg_page_list_46119 mlx4_ib_alloc_fast_reg_page_list 2 46119 NULL
98067 +__netlink_change_ngroups_46156 __netlink_change_ngroups 2 46156 NULL
98068 +qlcnic_alloc_msix_entries_46160 qlcnic_alloc_msix_entries 2 46160 NULL
98069 +twl_direction_out_46182 twl_direction_out 2 46182 NULL
98070 +vxge_os_dma_malloc_46184 vxge_os_dma_malloc 2 46184 NULL
98071 +i2400m_op_msg_from_user_46213 i2400m_op_msg_from_user 4 46213 NULL
98072 +tm6000_i2c_recv_regs_46215 tm6000_i2c_recv_regs 5 46215 NULL
98073 +dsp_write_46218 dsp_write 2 46218 NULL
98074 +mpi_read_raw_data_46248 mpi_read_raw_data 2 46248 NULL
98075 +__le64_to_cpup_46257 __le64_to_cpup 0 46257 NULL
98076 +nf_nat_ftp_46265 nf_nat_ftp 6 46265 NULL
98077 +ReadReg_46277 ReadReg 0 46277 NULL
98078 +batadv_iv_ogm_queue_add_46319 batadv_iv_ogm_queue_add 3 46319 NULL
98079 +__hwahc_dev_set_key_46328 __hwahc_dev_set_key 5 46328 NULL
98080 +twl6040_write_46351 twl6040_write 2 46351 NULL
98081 +iwl_dbgfs_chain_noise_read_46355 iwl_dbgfs_chain_noise_read 3 46355 NULL
98082 +smk_write_direct_46363 smk_write_direct 3 46363 NULL
98083 +__iommu_calculate_agaw_46366 __iommu_calculate_agaw 2 46366 NULL
98084 +ubi_dump_flash_46381 ubi_dump_flash 4 46381 NULL
98085 +fuse_file_aio_write_46399 fuse_file_aio_write 4 46399 NULL
98086 +crypto_ablkcipher_reqsize_46411 crypto_ablkcipher_reqsize 0 46411 NULL
98087 +cp210x_set_config_46447 cp210x_set_config 4 46447 NULL
98088 +filldir64_46469 filldir64 3 46469 NULL
98089 +fill_in_write_vector_46498 fill_in_write_vector 0 46498 NULL
98090 +pin_code_reply_46510 pin_code_reply 4 46510 NULL
98091 +mthca_alloc_cq_buf_46512 mthca_alloc_cq_buf 3 46512 NULL
98092 +kmsg_read_46514 kmsg_read 3 46514 NULL
98093 +bdx_rxdb_create_46525 bdx_rxdb_create 1 46525 NULL
98094 +nl80211_send_rx_assoc_46538 nl80211_send_rx_assoc 4 46538 NULL
98095 +pm860x_irq_domain_map_46553 pm860x_irq_domain_map 2 46553 NULL
98096 +mv_get_hc_count_46554 mv_get_hc_count 0 46554 NULL
98097 +link_send_sections_long_46556 link_send_sections_long 4 46556 NULL
98098 +irq_domain_associate_46564 irq_domain_associate 2 46564 NULL
98099 +dn_current_mss_46574 dn_current_mss 0 46574 NULL
98100 +serverworks_create_gatt_pages_46582 serverworks_create_gatt_pages 1 46582 NULL
98101 +snd_compr_write_data_46592 snd_compr_write_data 3 46592 NULL
98102 +il3945_stats_flag_46606 il3945_stats_flag 0-3 46606 NULL
98103 +vscnprintf_46617 vscnprintf 0-2 46617 NULL
98104 +__kfifo_out_r_46623 __kfifo_out_r 0-3 46623 NULL
98105 +request_key_async_with_auxdata_46624 request_key_async_with_auxdata 4 46624 NULL
98106 +aircable_process_packet_46639 aircable_process_packet 5 46639 NULL
98107 +av7110_ipack_init_46655 av7110_ipack_init 2 46655 NULL
98108 +alloc_data_packet_46698 alloc_data_packet 1 46698 NULL
98109 +__ilog2_u32_46706 __ilog2_u32 0 46706 NULL
98110 +erst_dbg_write_46715 erst_dbg_write 3 46715 NULL
98111 +wl1271_rx_filter_alloc_field_46721 wl1271_rx_filter_alloc_field 5 46721 NULL
98112 +prepare_copy_46725 prepare_copy 2 46725 NULL
98113 +irq_domain_add_simple_46734 irq_domain_add_simple 2-3 46734 NULL
98114 +ext4_count_free_46754 ext4_count_free 2 46754 NULL
98115 +hest_ghes_dev_register_46766 hest_ghes_dev_register 1 46766 NULL
98116 +int_hw_irq_en_46776 int_hw_irq_en 3 46776 NULL
98117 +regcache_lzo_sync_46777 regcache_lzo_sync 2 46777 NULL
98118 +scrub_chunk_46789 scrub_chunk 4 46789 NULL
98119 +_sys_packet_req_46793 _sys_packet_req 4 46793 NULL
98120 +_xfs_buf_get_pages_46811 _xfs_buf_get_pages 2 46811 NULL
98121 +xfs_iroot_realloc_46826 xfs_iroot_realloc 2 46826 NULL
98122 +shmem_pwrite_fast_46842 shmem_pwrite_fast 3 46842 NULL
98123 +ieee80211_rx_radiotap_len_46846 ieee80211_rx_radiotap_len 0 46846 NULL
98124 +spi_async_46857 spi_async 0 46857 NULL
98125 +ieee80211_mgmt_tx_46860 ieee80211_mgmt_tx 9 46860 NULL
98126 +vsnprintf_46863 vsnprintf 0 46863 NULL
98127 +nvme_alloc_queue_46865 nvme_alloc_queue 3 46865 NULL
98128 +sip_sprintf_addr_46872 sip_sprintf_addr 0 46872 NULL
98129 +rvmalloc_46873 rvmalloc 1 46873 NULL
98130 +hpi_read_word_nolock_46881 hpi_read_word_nolock 0 46881 NULL
98131 +stmpe_gpio_irq_unmap_46884 stmpe_gpio_irq_unmap 2 46884 NULL
98132 +em28xx_alloc_isoc_46892 em28xx_alloc_isoc 4 46892 NULL
98133 +ixgbe_dbg_reg_ops_write_46895 ixgbe_dbg_reg_ops_write 3 46895 NULL
98134 +sk_mem_pages_46896 sk_mem_pages 0-1 46896 NULL
98135 +ol_dqblk_off_46904 ol_dqblk_off 3-2 46904 NULL
98136 +fb_write_46924 fb_write 3 46924 NULL
98137 +raid_status_46930 raid_status 5 46930 NULL
98138 +btmrvl_curpsmode_read_46939 btmrvl_curpsmode_read 3 46939 NULL
98139 +__sctp_setsockopt_connectx_46949 __sctp_setsockopt_connectx 3 46949 NULL
98140 +qla4xxx_post_aen_work_46953 qla4xxx_post_aen_work 3 46953 NULL
98141 +crypto_tfm_alg_alignmask_46971 crypto_tfm_alg_alignmask 0 46971 NULL
98142 +mgmt_pending_add_46976 mgmt_pending_add 5 46976 NULL
98143 +gfs2_xattr_system_set_46996 gfs2_xattr_system_set 4 46996 NULL nohasharray
98144 +sel_write_bool_46996 sel_write_bool 3 46996 &gfs2_xattr_system_set_46996
98145 +ttm_bo_io_47000 ttm_bo_io 5 47000 NULL
98146 +blk_rq_map_kern_47004 blk_rq_map_kern 4 47004 NULL
98147 +__map_single_47020 __map_single 3-4-7 47020 NULL
98148 +cx231xx_init_bulk_47024 cx231xx_init_bulk 3-2 47024 NULL
98149 +set_dis_bypass_pfs_47038 set_dis_bypass_pfs 3 47038 NULL
98150 +wm8994_set_bits_47052 wm8994_set_bits 2 47052 NULL
98151 +fs_path_len_47060 fs_path_len 0 47060 NULL
98152 +ufs_new_fragments_47070 ufs_new_fragments 3-5-4 47070 NULL
98153 +pipeline_dec_packet_in_read_47076 pipeline_dec_packet_in_read 3 47076 NULL
98154 +scsi_deactivate_tcq_47086 scsi_deactivate_tcq 2 47086 NULL
98155 +mousedev_read_47123 mousedev_read 3 47123 NULL
98156 +ses_recv_diag_47143 ses_recv_diag 4 47143 NULL nohasharray
98157 +acpi_ut_initialize_buffer_47143 acpi_ut_initialize_buffer 2 47143 &ses_recv_diag_47143
98158 +cxio_init_resource_fifo_random_47151 cxio_init_resource_fifo_random 3 47151 NULL
98159 +persistent_ram_iomap_47156 persistent_ram_iomap 1-2 47156 NULL
98160 +mxms_headerlen_47161 mxms_headerlen 0 47161 NULL
98161 +rs_sta_dbgfs_rate_scale_data_read_47165 rs_sta_dbgfs_rate_scale_data_read 3 47165 NULL
98162 +rts51x_ms_rw_47171 rts51x_ms_rw 3-4 47171 NULL
98163 +svc_pool_map_alloc_arrays_47181 svc_pool_map_alloc_arrays 2 47181 NULL
98164 +can_set_system_xattr_47182 can_set_system_xattr 4 47182 NULL
98165 +ioremap_cache_47189 ioremap_cache 1-2 47189 NULL
98166 +wm8903_gpio_direction_in_47213 wm8903_gpio_direction_in 2 47213 NULL
98167 +l2headersize_47238 l2headersize 0 47238 NULL
98168 +options_write_47243 options_write 3 47243 NULL
98169 +portcntrs_1_read_47253 portcntrs_1_read 3 47253 NULL
98170 +da9052_disable_irq_nosync_47260 da9052_disable_irq_nosync 2 47260 NULL
98171 +ablkcipher_next_slow_47274 ablkcipher_next_slow 4-3 47274 NULL
98172 +tty_audit_log_47280 tty_audit_log 8 47280 NULL
98173 +gfs2_readpages_47285 gfs2_readpages 4 47285 NULL
98174 +vsnprintf_47291 vsnprintf 0 47291 NULL
98175 +tx_internal_desc_overflow_read_47300 tx_internal_desc_overflow_read 3 47300 NULL
98176 +ieee80211_if_read_dot11MeshHoldingTimeout_47356 ieee80211_if_read_dot11MeshHoldingTimeout 3 47356 NULL
98177 +avc_get_hash_stats_47359 avc_get_hash_stats 0 47359 NULL
98178 +find_first_zero_bit_le_47369 find_first_zero_bit_le 2 47369 NULL
98179 +__bio_map_kern_47379 __bio_map_kern 3 47379 NULL
98180 +trace_options_core_read_47390 trace_options_core_read 3 47390 NULL
98181 +nametbl_list_47391 nametbl_list 2 47391 NULL
98182 +dgrp_net_write_47392 dgrp_net_write 3 47392 NULL
98183 +pfkey_sendmsg_47394 pfkey_sendmsg 4 47394 NULL
98184 +ocfs2_resv_end_47408 ocfs2_resv_end 0 47408 NULL
98185 +crypto_ablkcipher_alignmask_47410 crypto_ablkcipher_alignmask 0 47410 NULL
98186 +vzalloc_47421 vzalloc 1 47421 NULL
98187 +posix_acl_from_disk_47445 posix_acl_from_disk 2 47445 NULL
98188 +newpart_47485 newpart 6 47485 NULL
98189 +core_sys_select_47494 core_sys_select 1 47494 NULL
98190 +alloc_arraycache_47505 alloc_arraycache 2 47505 NULL
98191 +unlink_simple_47506 unlink_simple 3 47506 NULL
98192 +ufs_inode_getblock_47512 ufs_inode_getblock 4 47512 NULL
98193 +snd_pcm_resume_47530 snd_pcm_resume 0 47530 NULL
98194 +vscnprintf_47533 vscnprintf 0-2 47533 NULL nohasharray
98195 +process_vm_rw_47533 process_vm_rw 3-5 47533 &vscnprintf_47533
98196 +oz_events_read_47535 oz_events_read 3 47535 NULL
98197 +ieee80211_if_fmt_min_discovery_timeout_47539 ieee80211_if_fmt_min_discovery_timeout 3 47539 NULL
98198 +cycx_setup_47562 cycx_setup 4 47562 NULL
98199 +read_ldt_47570 read_ldt 2 47570 NULL
98200 +pci_iomap_47575 pci_iomap 3 47575 NULL
98201 +rpipe_get_idx_47579 rpipe_get_idx 2 47579 NULL
98202 +ext4_kvzalloc_47605 ext4_kvzalloc 1 47605 NULL
98203 +wm831x_gpio_direction_out_47607 wm831x_gpio_direction_out 2 47607 NULL
98204 +sctp_ssnmap_new_47608 sctp_ssnmap_new 1-2 47608 NULL
98205 +uea_request_47613 uea_request 4 47613 NULL
98206 +cache_read_pipefs_47615 cache_read_pipefs 3 47615 NULL
98207 +tps65217_clear_bits_47619 tps65217_clear_bits 2 47619 NULL
98208 +twl4030_clear_set_47624 twl4030_clear_set 4 47624 NULL
98209 +irq_set_chip_47638 irq_set_chip 1 47638 NULL
98210 +__build_packet_message_47643 __build_packet_message 3-9 47643 NULL
98211 +irq_linear_revmap_47682 irq_linear_revmap 0 47682 NULL
98212 +snd_pcm_info_47699 snd_pcm_info 0 47699 NULL
98213 +bits_to_user_47733 bits_to_user 2-3 47733 NULL
98214 +carl9170_debugfs_read_47738 carl9170_debugfs_read 3 47738 NULL
98215 +ir_prepare_write_buffer_47747 ir_prepare_write_buffer 3 47747 NULL
98216 +mvumi_alloc_mem_resource_47750 mvumi_alloc_mem_resource 3 47750 NULL
98217 +ext3_find_near_47752 ext3_find_near 0 47752 NULL
98218 +alloc_sched_domains_47756 alloc_sched_domains 1 47756 NULL
98219 +irq_domain_legacy_revmap_47765 irq_domain_legacy_revmap 0-2 47765 NULL
98220 +i915_wedged_write_47771 i915_wedged_write 3 47771 NULL
98221 +uwb_ie_dump_hex_47774 uwb_ie_dump_hex 4 47774 NULL
98222 +error_error_numll_frame_cts_start_read_47781 error_error_numll_frame_cts_start_read 3 47781 NULL
98223 +posix_acl_fix_xattr_from_user_47793 posix_acl_fix_xattr_from_user 2 47793 NULL
98224 +stmmac_set_bfsize_47834 stmmac_set_bfsize 0 47834 NULL
98225 +__pcf50633_irq_mask_set_47847 __pcf50633_irq_mask_set 2 47847 NULL
98226 +ubifs_unpack_nnode_47866 ubifs_unpack_nnode 0 47866 NULL
98227 +vhci_read_47878 vhci_read 3 47878 NULL
98228 +keyctl_instantiate_key_common_47889 keyctl_instantiate_key_common 4 47889 NULL
98229 +osd_req_read_sg_47905 osd_req_read_sg 5 47905 NULL
98230 +timeout_read_47915 timeout_read 3 47915 NULL
98231 +comedi_write_47926 comedi_write 3 47926 NULL
98232 +lp8788_irq_map_47964 lp8788_irq_map 2 47964 NULL
98233 +iwl_dbgfs_ucode_tracing_read_47983 iwl_dbgfs_ucode_tracing_read 3 47983 NULL nohasharray
98234 +mempool_resize_47983 mempool_resize 2 47983 &iwl_dbgfs_ucode_tracing_read_47983
98235 +pnpacpi_parse_allocated_irqresource_47986 pnpacpi_parse_allocated_irqresource 2 47986 NULL
98236 +dbg_port_buf_47990 dbg_port_buf 2 47990 NULL
98237 +ib_umad_write_47993 ib_umad_write 3 47993 NULL
98238 +ffs_epfile_write_48014 ffs_epfile_write 3 48014 NULL
98239 +bio_integrity_set_tag_48035 bio_integrity_set_tag 3 48035 NULL
98240 +pppoe_sendmsg_48039 pppoe_sendmsg 4 48039 NULL
98241 +wpan_phy_alloc_48056 wpan_phy_alloc 1 48056 NULL
98242 +posix_acl_alloc_48063 posix_acl_alloc 1 48063 NULL
98243 +mmc_alloc_host_48097 mmc_alloc_host 1 48097 NULL
98244 +skb_copy_datagram_const_iovec_48102 skb_copy_datagram_const_iovec 4-2-5 48102 NULL
98245 +radio_isa_common_probe_48107 radio_isa_common_probe 3 48107 NULL
98246 +vmw_framebuffer_surface_dirty_48132 vmw_framebuffer_surface_dirty 6 48132 NULL
98247 +rtsx_read_cfg_seq_48139 rtsx_read_cfg_seq 5-3 48139 NULL
98248 +set_discoverable_48141 set_discoverable 4 48141 NULL
98249 +dn_fib_count_nhs_48145 dn_fib_count_nhs 0 48145 NULL
98250 +bitmap_onto_48152 bitmap_onto 4 48152 NULL
98251 +isr_dma1_done_read_48159 isr_dma1_done_read 3 48159 NULL
98252 +c4iw_id_table_alloc_48163 c4iw_id_table_alloc 3 48163 NULL
98253 +ocfs2_find_next_zero_bit_unaligned_48170 ocfs2_find_next_zero_bit_unaligned 2-3 48170 NULL
98254 +alloc_cc770dev_48186 alloc_cc770dev 1 48186 NULL
98255 +init_ipath_48187 init_ipath 1 48187 NULL nohasharray
98256 +ieee80211_send_auth_48187 ieee80211_send_auth 6 48187 &init_ipath_48187
98257 +snd_seq_dump_var_event_48209 snd_seq_dump_var_event 0 48209 NULL
98258 +is_block_in_journal_48223 is_block_in_journal 3 48223 NULL
98259 +uv_blade_nr_possible_cpus_48226 uv_blade_nr_possible_cpus 0 48226 NULL
98260 +nilfs_readpages_48229 nilfs_readpages 4 48229 NULL
98261 +read_file_recv_48232 read_file_recv 3 48232 NULL
98262 +unaccount_shadowed_48233 unaccount_shadowed 2 48233 NULL nohasharray
98263 +blk_rq_pos_48233 blk_rq_pos 0 48233 &unaccount_shadowed_48233
98264 +nfsctl_transaction_read_48250 nfsctl_transaction_read 3 48250 NULL
98265 +cache_write_pipefs_48270 cache_write_pipefs 3 48270 NULL
98266 +send_set_info_48288 send_set_info 7 48288 NULL
98267 +set_disc_pwup_pfs_48300 set_disc_pwup_pfs 3 48300 NULL
98268 +lpfc_idiag_extacc_read_48301 lpfc_idiag_extacc_read 3 48301 NULL
98269 +timblogiw_read_48305 timblogiw_read 3 48305 NULL
98270 +hash_setkey_48310 hash_setkey 3 48310 NULL
98271 +__alloc_fd_48356 __alloc_fd 2 48356 NULL
98272 +skb_add_data_48363 skb_add_data 3 48363 NULL
98273 +tx_frag_init_called_read_48377 tx_frag_init_called_read 3 48377 NULL
98274 +lbs_debugfs_write_48413 lbs_debugfs_write 3 48413 NULL
98275 +snd_power_wait_48422 snd_power_wait 0 48422 NULL
98276 +pwr_tx_without_ps_read_48423 pwr_tx_without_ps_read 3 48423 NULL
98277 +nfs4_alloc_pages_48426 nfs4_alloc_pages 1 48426 NULL
98278 +tun_recvmsg_48463 tun_recvmsg 4 48463 NULL
98279 +r8712_usbctrl_vendorreq_48489 r8712_usbctrl_vendorreq 6 48489 NULL
98280 +send_control_msg_48498 send_control_msg 6 48498 NULL
98281 +mlx4_en_create_tx_ring_48501 mlx4_en_create_tx_ring 4 48501 NULL
98282 +count_masked_bytes_48507 count_masked_bytes 0-1 48507 NULL
98283 +diva_os_copy_to_user_48508 diva_os_copy_to_user 4 48508 NULL
98284 +brcmf_sdio_trap_info_48510 brcmf_sdio_trap_info 4 48510 NULL
98285 +phantom_get_free_48514 phantom_get_free 0 48514 NULL
98286 +wiimote_hid_send_48528 wiimote_hid_send 3 48528 NULL
98287 +ext3_splice_branch_48531 ext3_splice_branch 6 48531 NULL
98288 +named_distribute_48544 named_distribute 4 48544 NULL
98289 +raid10_size_48571 raid10_size 0-2-3 48571 NULL
98290 +ext_sd_execute_read_data_48589 ext_sd_execute_read_data 9 48589 NULL
98291 +ufs_dtogd_48616 ufs_dtogd 0-2 48616 NULL
98292 +do_ip_vs_set_ctl_48641 do_ip_vs_set_ctl 4 48641 NULL
98293 +mtd_read_48655 mtd_read 0 48655 NULL
98294 +lc_create_48662 lc_create 3 48662 NULL
98295 +aes_encrypt_packets_read_48666 aes_encrypt_packets_read 3 48666 NULL
98296 +sm501_create_subdev_48668 sm501_create_subdev 3-4 48668 NULL nohasharray
98297 +sys_setgroups_48668 sys_setgroups 1 48668 &sm501_create_subdev_48668
98298 +altera_drscan_48698 altera_drscan 2 48698 NULL
98299 +kvm_set_irq_routing_48704 kvm_set_irq_routing 3 48704 NULL
98300 +ath6kl_usb_bmi_read_48745 ath6kl_usb_bmi_read 3 48745 NULL
98301 +ath6kl_regwrite_read_48747 ath6kl_regwrite_read 3 48747 NULL
98302 +l2cap_segment_sdu_48772 l2cap_segment_sdu 4 48772 NULL
98303 +lua_sysfs_write_48797 lua_sysfs_write 6 48797 NULL
98304 +il3945_sta_dbgfs_stats_table_read_48802 il3945_sta_dbgfs_stats_table_read 3 48802 NULL
98305 +twa_change_queue_depth_48808 twa_change_queue_depth 2 48808 NULL
98306 +atomic_counters_read_48827 atomic_counters_read 3 48827 NULL
98307 +azx_get_position_48841 azx_get_position 0 48841 NULL
98308 +vc_do_resize_48842 vc_do_resize 3-4 48842 NULL
98309 +viafb_dvp1_proc_write_48864 viafb_dvp1_proc_write 3 48864 NULL
98310 +__ffs_ep0_read_events_48868 __ffs_ep0_read_events 3 48868 NULL
98311 +sys_setgroups16_48882 sys_setgroups16 1 48882 NULL
98312 +get_num_ops_48886 get_num_ops 0 48886 NULL
98313 +ext2_alloc_branch_48889 ext2_alloc_branch 4 48889 NULL
98314 +crypto_cipher_ctxsize_48890 crypto_cipher_ctxsize 0 48890 NULL
98315 +xdi_copy_to_user_48900 xdi_copy_to_user 4 48900 NULL
98316 +msg_hdr_sz_48908 msg_hdr_sz 0 48908 NULL
98317 +gdth_isa_probe_one_48925 gdth_isa_probe_one 1 48925 NULL nohasharray
98318 +snd_pcm_update_hw_ptr_48925 snd_pcm_update_hw_ptr 0 48925 &gdth_isa_probe_one_48925
98319 +sep_crypto_dma_48937 sep_crypto_dma 0 48937 NULL
98320 +event_heart_beat_read_48961 event_heart_beat_read 3 48961 NULL
98321 +nand_ecc_test_run_48966 nand_ecc_test_run 1 48966 NULL
98322 +batadv_orig_hash_del_if_48972 batadv_orig_hash_del_if 2 48972 NULL
98323 +_alloc_set_attr_list_48991 _alloc_set_attr_list 4 48991 NULL
98324 +rds_rm_size_48996 rds_rm_size 0-2 48996 NULL
98325 +sel_write_enforce_48998 sel_write_enforce 3 48998 NULL
98326 +xd_rw_49020 xd_rw 3-4 49020 NULL
98327 +transient_status_49027 transient_status 4 49027 NULL
98328 +ubi_read_49061 ubi_read 0 49061 NULL
98329 +tps65910_reg_write_49066 tps65910_reg_write 2 49066 NULL
98330 +calc_layout_49074 calc_layout 4 49074 NULL
98331 +vmx_set_msr_49090 vmx_set_msr 3 49090 NULL
98332 +scsi_register_49094 scsi_register 2 49094 NULL
98333 +compat_do_readv_writev_49102 compat_do_readv_writev 4 49102 NULL
98334 +xfrm_replay_state_esn_len_49119 xfrm_replay_state_esn_len 0 49119 NULL
98335 +pt_read_49136 pt_read 3 49136 NULL
98336 +tipc_multicast_49144 tipc_multicast 5 49144 NULL
98337 +atyfb_setup_generic_49151 atyfb_setup_generic 3 49151 NULL
98338 +ipwireless_tty_received_49154 ipwireless_tty_received 3 49154 NULL
98339 +f2fs_acl_count_49155 f2fs_acl_count 0-1 49155 NULL
98340 +ipw_queue_tx_init_49161 ipw_queue_tx_init 3 49161 NULL
98341 +ext4_free_clusters_after_init_49174 ext4_free_clusters_after_init 2 49174 NULL
98342 +dvb_dvr_ioctl_49182 dvb_dvr_ioctl 2 49182 NULL
98343 +iwl_dbgfs_ucode_general_stats_read_49199 iwl_dbgfs_ucode_general_stats_read 3 49199 NULL
98344 +il4965_rs_sta_dbgfs_stats_table_read_49206 il4965_rs_sta_dbgfs_stats_table_read 3 49206 NULL
98345 +do_jffs2_getxattr_49210 do_jffs2_getxattr 0 49210 NULL
98346 +pcf50633_gpio_invert_set_49256 pcf50633_gpio_invert_set 2 49256 NULL
98347 +hugetlb_cgroup_read_49259 hugetlb_cgroup_read 5 49259 NULL
98348 +ieee80211_if_read_rssi_threshold_49260 ieee80211_if_read_rssi_threshold 3 49260 NULL
98349 +osd_req_add_get_attr_list_49278 osd_req_add_get_attr_list 3 49278 NULL
98350 +rx_filter_beacon_filter_read_49279 rx_filter_beacon_filter_read 3 49279 NULL
98351 +uio_read_49300 uio_read 3 49300 NULL
98352 +ocfs2_resmap_find_free_bits_49301 ocfs2_resmap_find_free_bits 3 49301 NULL
98353 +fwtty_port_handler_49327 fwtty_port_handler 9 49327 NULL
98354 +srpt_alloc_ioctx_ring_49330 srpt_alloc_ioctx_ring 2-3-4 49330 NULL
98355 +cfpkt_setlen_49343 cfpkt_setlen 2 49343 NULL
98356 +joydev_ioctl_common_49359 joydev_ioctl_common 2 49359 NULL
98357 +ocfs2_remove_btree_range_49370 ocfs2_remove_btree_range 4-5-3 49370 NULL
98358 +px_raw_event_49371 px_raw_event 4 49371 NULL
98359 +iscsi_alloc_session_49390 iscsi_alloc_session 3 49390 NULL
98360 +applesmc_create_nodes_49392 applesmc_create_nodes 2 49392 NULL
98361 +rx_streaming_always_read_49401 rx_streaming_always_read 3 49401 NULL
98362 +tnode_alloc_49407 tnode_alloc 1 49407 NULL
98363 +samples_to_bytes_49426 samples_to_bytes 0-2 49426 NULL
98364 +md_domain_init_49432 md_domain_init 2 49432 NULL
98365 +compat_do_msg_fill_49440 compat_do_msg_fill 3 49440 NULL
98366 +agp_3_5_isochronous_node_enable_49465 agp_3_5_isochronous_node_enable 3 49465 NULL
98367 +xfs_iformat_local_49472 xfs_iformat_local 4 49472 NULL
98368 +savu_sysfs_read_49473 savu_sysfs_read 6 49473 NULL
98369 +ieee80211_ie_split_49474 ieee80211_ie_split 0-5 49474 NULL
98370 +isr_decrypt_done_read_49490 isr_decrypt_done_read 3 49490 NULL
98371 +emulator_write_phys_49520 emulator_write_phys 2-4 49520 NULL
98372 +acpi_os_ioremap_49523 acpi_os_ioremap 1-2 49523 NULL
98373 +wm831x_dcdc_set_mode_int_49546 wm831x_dcdc_set_mode_int 2 49546 NULL
98374 +smk_write_access_49561 smk_write_access 3 49561 NULL
98375 +ntfs_malloc_nofs_49572 ntfs_malloc_nofs 1 49572 NULL
98376 +alloc_chunk_49575 alloc_chunk 1 49575 NULL
98377 +sctp_setsockopt_default_send_param_49578 sctp_setsockopt_default_send_param 3 49578 NULL
98378 +isr_wakeups_read_49607 isr_wakeups_read 3 49607 NULL
98379 +heap_init_49617 heap_init 2 49617 NULL
98380 +smk_write_doi_49621 smk_write_doi 3 49621 NULL
98381 +btrfsic_cmp_log_and_dev_bytenr_49628 btrfsic_cmp_log_and_dev_bytenr 2 49628 NULL
98382 +svm_set_msr_49643 svm_set_msr 3 49643 NULL
98383 +aa_simple_write_to_buffer_49683 aa_simple_write_to_buffer 3-4 49683 NULL
98384 +sys_gethostname_49698 sys_gethostname 2 49698 NULL
98385 +cx2341x_ctrl_new_menu_49700 cx2341x_ctrl_new_menu 3 49700 NULL
98386 +sep_create_dcb_dmatables_context_kernel_49728 sep_create_dcb_dmatables_context_kernel 6 49728 NULL
98387 +sys_fsetxattr_49736 sys_fsetxattr 4 49736 NULL
98388 +check_frame_49741 check_frame 0 49741 NULL
98389 +zd_usb_iowrite16v_49744 zd_usb_iowrite16v 3 49744 NULL
98390 +btrfs_chunk_num_stripes_49751 btrfs_chunk_num_stripes 0 49751 NULL
98391 +key_conf_keylen_read_49758 key_conf_keylen_read 3 49758 NULL
98392 +fuse_conn_waiting_read_49762 fuse_conn_waiting_read 3 49762 NULL
98393 +isku_sysfs_write_49767 isku_sysfs_write 6 49767 NULL
98394 +ceph_osdc_readpages_49789 ceph_osdc_readpages 10-4 49789 NULL
98395 +nfs4_acl_new_49806 nfs4_acl_new 1 49806 NULL
98396 +arch_gnttab_map_status_49812 arch_gnttab_map_status 3 49812 NULL
98397 +ntfs_copy_from_user_iovec_49829 ntfs_copy_from_user_iovec 3-6-0 49829 NULL
98398 +add_uuid_49831 add_uuid 4 49831 NULL
98399 +ath6kl_fwlog_block_read_49836 ath6kl_fwlog_block_read 3 49836 NULL
98400 +__btrfs_map_block_49839 __btrfs_map_block 3 49839 NULL
98401 +twl4030_write_49846 twl4030_write 2 49846 NULL
98402 +scsi_dispatch_cmd_entry_49848 scsi_dispatch_cmd_entry 3 49848 NULL
98403 +timeradd_entry_49850 timeradd_entry 3 49850 NULL
98404 +sctp_setsockopt_bindx_49870 sctp_setsockopt_bindx 3 49870 NULL
98405 +ceph_get_caps_49890 ceph_get_caps 0 49890 NULL
98406 +__cow_file_range_49901 __cow_file_range 5 49901 NULL
98407 +__copy_from_user_inatomic_nocache_49921 __copy_from_user_inatomic_nocache 3 49921 NULL
98408 +batadv_tt_realloc_packet_buff_49960 batadv_tt_realloc_packet_buff 4 49960 NULL
98409 +b43legacy_pio_read_49978 b43legacy_pio_read 0 49978 NULL
98410 +ieee80211_if_fmt_dtim_count_49987 ieee80211_if_fmt_dtim_count 3 49987 NULL
98411 +sta2x11_swiotlb_alloc_coherent_49994 sta2x11_swiotlb_alloc_coherent 2 49994 NULL
98412 +l2cap_chan_send_49995 l2cap_chan_send 3 49995 NULL
98413 +__module_alloc_50004 __module_alloc 1 50004 NULL
98414 +dn_mss_from_pmtu_50011 dn_mss_from_pmtu 0-2 50011 NULL
98415 +ptrace_readdata_50020 ptrace_readdata 2-4 50020 NULL
98416 +isdn_read_50021 isdn_read 3 50021 NULL
98417 +rbd_req_write_50041 rbd_req_write 4-5 50041 NULL
98418 +alloc_ebda_hpc_50046 alloc_ebda_hpc 1-2 50046 NULL
98419 +vmw_surface_destroy_size_50072 vmw_surface_destroy_size 0 50072 NULL
98420 +arch_setup_ht_irq_50073 arch_setup_ht_irq 1 50073 NULL
98421 +dev_set_alias_50084 dev_set_alias 3 50084 NULL
98422 +pcpu_get_vm_areas_50085 pcpu_get_vm_areas 3 50085 NULL
98423 +sock_setsockopt_50088 sock_setsockopt 5 50088 NULL
98424 +altera_swap_dr_50090 altera_swap_dr 2 50090 NULL
98425 +read_file_slot_50111 read_file_slot 3 50111 NULL
98426 +copy_items_50140 copy_items 6 50140 NULL
98427 +tx_frag_need_fragmentation_read_50153 tx_frag_need_fragmentation_read 3 50153 NULL
98428 +set_cmd_header_50155 set_cmd_header 0 50155 NULL
98429 +reiserfs_bmap_count_50160 reiserfs_bmap_count 0 50160 NULL
98430 +aac_nark_ioremap_50163 aac_nark_ioremap 2 50163 NULL nohasharray
98431 +kmalloc_node_50163 kmalloc_node 1 50163 &aac_nark_ioremap_50163
98432 +rx_filter_ibss_filter_read_50167 rx_filter_ibss_filter_read 3 50167 NULL
98433 +odev_update_50169 odev_update 2 50169 NULL
98434 +ieee80211_if_fmt_dot11MeshHWMPRannInterval_50172 ieee80211_if_fmt_dot11MeshHWMPRannInterval 3 50172 NULL nohasharray
98435 +ubi_resize_volume_50172 ubi_resize_volume 2 50172 &ieee80211_if_fmt_dot11MeshHWMPRannInterval_50172
98436 +ib_send_cm_drep_50186 ib_send_cm_drep 3 50186 NULL
98437 +cfg80211_roamed_bss_50198 cfg80211_roamed_bss 4-6 50198 NULL
98438 +rx_rx_timeout_wa_read_50204 rx_rx_timeout_wa_read 3 50204 NULL
98439 +ieee80211_skb_resize_50211 ieee80211_skb_resize 3 50211 NULL
98440 +mon_bin_compat_ioctl_50234 mon_bin_compat_ioctl 3 50234 NULL
98441 +sg_kmalloc_50240 sg_kmalloc 1 50240 NULL
98442 +afs_extract_data_50261 afs_extract_data 5 50261 NULL
98443 +rxrpc_setsockopt_50286 rxrpc_setsockopt 5 50286 NULL
98444 +soc_codec_reg_show_50302 soc_codec_reg_show 0 50302 NULL
98445 +soc_camera_read_50319 soc_camera_read 3 50319 NULL
98446 +do_launder_page_50329 do_launder_page 0 50329 NULL
98447 +nouveau_engine_create__50331 nouveau_engine_create_ 7 50331 NULL
98448 +lpfc_idiag_pcicfg_read_50334 lpfc_idiag_pcicfg_read 3 50334 NULL
98449 +ocfs2_block_to_cluster_group_50337 ocfs2_block_to_cluster_group 2 50337 NULL nohasharray
98450 +snd_pcm_lib_writev_50337 snd_pcm_lib_writev 0-3 50337 &ocfs2_block_to_cluster_group_50337
98451 +roccat_common2_send_with_status_50343 roccat_common2_send_with_status 4 50343 NULL
98452 +tpm_read_50344 tpm_read 3 50344 NULL
98453 +kvm_arch_create_memslot_50354 kvm_arch_create_memslot 2 50354 NULL
98454 +isdn_ppp_read_50356 isdn_ppp_read 4 50356 NULL
98455 +unpack_u16_chunk_50357 unpack_u16_chunk 0 50357 NULL
98456 +xfrm_send_migrate_50365 xfrm_send_migrate 5 50365 NULL
98457 +roccat_common2_receive_50369 roccat_common2_receive 4 50369 NULL
98458 +sl_alloc_bufs_50380 sl_alloc_bufs 2 50380 NULL
98459 +l2tp_ip_sendmsg_50411 l2tp_ip_sendmsg 4 50411 NULL
98460 +iscsi_create_conn_50425 iscsi_create_conn 2 50425 NULL
98461 +btrfs_error_discard_extent_50444 btrfs_error_discard_extent 2 50444 NULL
98462 +pgctrl_write_50453 pgctrl_write 3 50453 NULL
98463 +tps65217_update_bits_50472 tps65217_update_bits 2 50472 NULL
98464 +cdrom_read_cdda_50478 cdrom_read_cdda 4 50478 NULL
98465 +mei_io_cb_alloc_req_buf_50493 mei_io_cb_alloc_req_buf 2 50493 NULL
98466 +pwr_rcvd_awake_beacons_read_50505 pwr_rcvd_awake_beacons_read 3 50505 NULL
98467 +fwnet_receive_packet_50537 fwnet_receive_packet 9 50537 NULL
98468 +ath6kl_set_ap_probe_resp_ies_50539 ath6kl_set_ap_probe_resp_ies 3 50539 NULL
98469 +pcf50633_reg_set_bit_mask_50544 pcf50633_reg_set_bit_mask 2 50544 NULL
98470 +hme_read_desc32_50574 hme_read_desc32 0 50574 NULL
98471 +fat_readpages_50582 fat_readpages 4 50582 NULL
98472 +iwl_dbgfs_missed_beacon_read_50584 iwl_dbgfs_missed_beacon_read 3 50584 NULL
98473 +build_inv_iommu_pages_50589 build_inv_iommu_pages 2-3 50589 NULL
98474 +rx_rx_checksum_result_read_50617 rx_rx_checksum_result_read 3 50617 NULL
98475 +__ffs_50625 __ffs 0 50625 NULL
98476 +simple_transaction_get_50633 simple_transaction_get 3 50633 NULL
98477 +ath6kl_tm_rx_event_50664 ath6kl_tm_rx_event 3 50664 NULL nohasharray
98478 +sys_readv_50664 sys_readv 3 50664 &ath6kl_tm_rx_event_50664
98479 +bnad_debugfs_read_50665 bnad_debugfs_read 3 50665 NULL
98480 +ext2_try_to_allocate_with_rsv_50669 ext2_try_to_allocate_with_rsv 4-2 50669 NULL
98481 +btmrvl_psstate_read_50683 btmrvl_psstate_read 3 50683 NULL
98482 +xfs_growfs_get_hdr_buf_50697 xfs_growfs_get_hdr_buf 3 50697 NULL
98483 +blk_check_plugged_50736 blk_check_plugged 3 50736 NULL
98484 +__ext3_get_inode_loc_50744 __ext3_get_inode_loc 0 50744 NULL
98485 +skb_padto_50759 skb_padto 2 50759 NULL
98486 +ocfs2_xattr_block_get_50773 ocfs2_xattr_block_get 0 50773 NULL
98487 +tm6000_read_write_usb_50774 tm6000_read_write_usb 7 50774 NULL
98488 +bio_alloc_map_data_50782 bio_alloc_map_data 1-2 50782 NULL
98489 +tpm_write_50798 tpm_write 3 50798 NULL
98490 +tun_do_read_50800 tun_do_read 4 50800 NULL
98491 +write_flush_50803 write_flush 3 50803 NULL
98492 +dvb_play_50814 dvb_play 3 50814 NULL
98493 +dpcm_show_state_50827 dpcm_show_state 0 50827 NULL
98494 +acpi_ev_install_gpe_block_50829 acpi_ev_install_gpe_block 2 50829 NULL
98495 +pstore_mkfile_50830 pstore_mkfile 5 50830 NULL
98496 +dma_attach_50831 dma_attach 6-7 50831 NULL
98497 +SetArea_50835 SetArea 4 50835 NULL nohasharray
98498 +create_mem_extents_50835 create_mem_extents 0 50835 &SetArea_50835
98499 +self_check_write_50856 self_check_write 5 50856 NULL
98500 +carl9170_debugfs_write_50857 carl9170_debugfs_write 3 50857 NULL
98501 +netlbl_secattr_catmap_walk_rng_50894 netlbl_secattr_catmap_walk_rng 0-2 50894 NULL
98502 +osd_req_write_sg_50908 osd_req_write_sg 5 50908 NULL
98503 +xfs_iext_remove_50909 xfs_iext_remove 3 50909 NULL
98504 +blk_rq_cur_sectors_50910 blk_rq_cur_sectors 0 50910 NULL
98505 +hash_recvmsg_50924 hash_recvmsg 4 50924 NULL
98506 +chd_dec_fetch_cdata_50926 chd_dec_fetch_cdata 3 50926 NULL
98507 +sock_bindtodevice_50942 sock_bindtodevice 3 50942 NULL
98508 +ocfs2_add_refcount_flag_50952 ocfs2_add_refcount_flag 6 50952 NULL
98509 +iwl_statistics_flag_50981 iwl_statistics_flag 0-3 50981 NULL
98510 +timeout_write_50991 timeout_write 3 50991 NULL
98511 +wm831x_irq_map_50995 wm831x_irq_map 2 50995 NULL nohasharray
98512 +wm8903_gpio_direction_out_50995 wm8903_gpio_direction_out 2 50995 &wm831x_irq_map_50995
98513 +proc_write_51003 proc_write 3 51003 NULL
98514 +lbs_dev_info_51023 lbs_dev_info 3 51023 NULL
98515 +ntfs_attr_find_51028 ntfs_attr_find 0 51028 NULL nohasharray
98516 +fuse_conn_congestion_threshold_read_51028 fuse_conn_congestion_threshold_read 3 51028 &ntfs_attr_find_51028
98517 +BcmGetSectionValEndOffset_51039 BcmGetSectionValEndOffset 0 51039 NULL
98518 +dump_midi_51040 dump_midi 3 51040 NULL
98519 +srpt_alloc_ioctx_51042 srpt_alloc_ioctx 2-3 51042 NULL
98520 +do_arpt_set_ctl_51053 do_arpt_set_ctl 4 51053 NULL
98521 +wusb_prf_64_51065 wusb_prf_64 7 51065 NULL
98522 +jbd2_journal_init_revoke_51088 jbd2_journal_init_revoke 2 51088 NULL
98523 +__ocfs2_find_path_51096 __ocfs2_find_path 0 51096 NULL
98524 +dgrp_net_read_51113 dgrp_net_read 3 51113 NULL
98525 +lm3533_als_get_current_51120 lm3533_als_get_current 2 51120 NULL
98526 +nfs_map_name_to_uid_51132 nfs_map_name_to_uid 3 51132 NULL
98527 +alloc_rtllib_51136 alloc_rtllib 1 51136 NULL
98528 +simple_xattr_set_51140 simple_xattr_set 4 51140 NULL
98529 +xfs_trans_get_efd_51148 xfs_trans_get_efd 3 51148 NULL
98530 +compat_sys_pwritev64_51151 compat_sys_pwritev64 3 51151 NULL
98531 +snd_pcm_unlink_51210 snd_pcm_unlink 0 51210 NULL
98532 +blk_bio_map_sg_51213 blk_bio_map_sg 0 51213 NULL
98533 +nf_ct_ext_create_51232 nf_ct_ext_create 3 51232 NULL
98534 +snd_pcm_write_51235 snd_pcm_write 3 51235 NULL
98535 +tipc_send_51238 tipc_send 4 51238 NULL
98536 +drm_property_create_51239 drm_property_create 4 51239 NULL
98537 +st_read_51251 st_read 3 51251 NULL
98538 +compat_dccp_setsockopt_51263 compat_dccp_setsockopt 5 51263 NULL
98539 +dvb_audio_write_51275 dvb_audio_write 3 51275 NULL
98540 +ipwireless_network_packet_received_51277 ipwireless_network_packet_received 4 51277 NULL
98541 +zone_reclaimable_pages_51283 zone_reclaimable_pages 0 51283 NULL
98542 +pvr2_std_id_to_str_51288 pvr2_std_id_to_str 2 51288 NULL
98543 +fd_do_readv_51297 fd_do_readv 3 51297 NULL
98544 +bnad_debugfs_read_regrd_51308 bnad_debugfs_read_regrd 3 51308 NULL
98545 +alloc_hippi_dev_51320 alloc_hippi_dev 1 51320 NULL
98546 +ext2_xattr_get_51327 ext2_xattr_get 0 51327 NULL
98547 +alloc_smp_req_51337 alloc_smp_req 1 51337 NULL nohasharray
98548 +compat_arch_ptrace_51337 compat_arch_ptrace 3-4 51337 &alloc_smp_req_51337
98549 +ipw_get_event_log_len_51341 ipw_get_event_log_len 0 51341 NULL
98550 +ieee80211_if_fmt_estab_plinks_51370 ieee80211_if_fmt_estab_plinks 3 51370 NULL
98551 +radeon_kms_compat_ioctl_51371 radeon_kms_compat_ioctl 2 51371 NULL
98552 +ieee80211_wx_set_gen_ie_51399 ieee80211_wx_set_gen_ie 3 51399 NULL
98553 +ceph_sync_read_51410 ceph_sync_read 3 51410 NULL
98554 +blk_register_region_51424 blk_register_region 1-2 51424 NULL
98555 +mwifiex_rdeeprom_read_51429 mwifiex_rdeeprom_read 3 51429 NULL
98556 +ieee80211_if_read_dot11MeshHWMPRootMode_51441 ieee80211_if_read_dot11MeshHWMPRootMode 3 51441 NULL
98557 +print_devstats_dot11ACKFailureCount_51443 print_devstats_dot11ACKFailureCount 3 51443 NULL
98558 +____alloc_ei_netdev_51475 ____alloc_ei_netdev 1 51475 NULL
98559 +xfs_buf_get_uncached_51477 xfs_buf_get_uncached 2 51477 NULL
98560 +ieee80211_if_write_uapsd_queues_51526 ieee80211_if_write_uapsd_queues 3 51526 NULL
98561 +__alloc_eip_netdev_51549 __alloc_eip_netdev 1 51549 NULL
98562 +icmp_manip_pkt_51560 icmp_manip_pkt 4 51560 NULL
98563 +ixgb_get_eeprom_len_51586 ixgb_get_eeprom_len 0 51586 NULL
98564 +aac_convert_sgraw2_51598 aac_convert_sgraw2 4 51598 NULL
98565 +raw_ioctl_51607 raw_ioctl 3 51607 NULL
98566 +table_size_to_number_of_entries_51613 table_size_to_number_of_entries 0-1 51613 NULL
98567 +dns_resolve_server_name_to_ip_51632 dns_resolve_server_name_to_ip 0 51632 NULL
98568 +sctp_auth_create_key_51641 sctp_auth_create_key 1 51641 NULL
98569 +iscsi_create_session_51647 iscsi_create_session 3 51647 NULL
98570 +get_new_cssid_51665 get_new_cssid 2 51665 NULL
98571 +ps_upsd_utilization_read_51669 ps_upsd_utilization_read 3 51669 NULL
98572 +sctp_setsockopt_associnfo_51684 sctp_setsockopt_associnfo 3 51684 NULL
98573 +sfi_sysfs_install_table_51688 sfi_sysfs_install_table 1 51688 NULL
98574 +sel_write_access_51704 sel_write_access 3 51704 NULL
98575 +tty_cdev_add_51714 tty_cdev_add 2-4 51714 NULL
98576 +drm_compat_ioctl_51717 drm_compat_ioctl 2 51717 NULL
98577 +sg_read_oxfer_51724 sg_read_oxfer 3 51724 NULL
98578 +msg_set_51725 msg_set 3 51725 NULL
98579 +dbg_check_lpt_nodes_51727 dbg_check_lpt_nodes 0 51727 NULL
98580 +hid_parse_report_51737 hid_parse_report 3 51737 NULL
98581 +get_user_pages_fast_51751 get_user_pages_fast 0 51751 NULL
98582 +ifx_spi_insert_flip_string_51752 ifx_spi_insert_flip_string 3 51752 NULL
98583 +if_write_51756 if_write 3 51756 NULL
98584 +ioremap_prot_51764 ioremap_prot 1-2 51764 NULL
98585 +iio_buffer_add_channel_sysfs_51766 iio_buffer_add_channel_sysfs 0 51766 NULL
98586 +__fswab32_51781 __fswab32 0 51781 NULL
98587 +qib_alloc_devdata_51819 qib_alloc_devdata 2 51819 NULL
98588 +buffer_from_user_51826 buffer_from_user 3 51826 NULL
98589 +wm2000_write_51834 wm2000_write 2 51834 NULL
98590 +ioread32_51847 ioread32 0 51847 NULL nohasharray
98591 +read_file_tgt_tx_stats_51847 read_file_tgt_tx_stats 3 51847 &ioread32_51847
98592 +do_readv_writev_51849 do_readv_writev 4 51849 NULL
98593 +pointer_size_read_51863 pointer_size_read 3 51863 NULL
98594 +mlx4_alloc_db_from_pgdir_51865 mlx4_alloc_db_from_pgdir 3 51865 NULL
98595 +get_indirect_ea_51869 get_indirect_ea 4 51869 NULL
98596 +user_read_51881 user_read 3 51881 NULL
98597 +dbAdjCtl_51888 dbAdjCtl 0 51888 NULL
98598 +virt_to_phys_51896 virt_to_phys 0 51896 NULL
98599 +iio_read_first_n_sw_rb_51911 iio_read_first_n_sw_rb 2 51911 NULL
98600 +wmi_set_ie_51919 wmi_set_ie 3 51919 NULL
98601 +dbg_status_buf_51930 dbg_status_buf 2 51930 NULL
98602 +__tcp_mtu_to_mss_51938 __tcp_mtu_to_mss 0-2 51938 NULL
98603 +xfrm_alg_len_51940 xfrm_alg_len 0 51940 NULL
98604 +irq_dispose_mapping_51941 irq_dispose_mapping 1 51941 NULL
98605 +scsi_get_vpd_page_51951 scsi_get_vpd_page 4 51951 NULL
98606 +arizona_free_irq_51969 arizona_free_irq 2 51969 NULL nohasharray
98607 +snd_mask_min_51969 snd_mask_min 0 51969 &arizona_free_irq_51969
98608 +ath6kl_sdio_alloc_prep_scat_req_51986 ath6kl_sdio_alloc_prep_scat_req 2 51986 NULL
98609 +dwc3_mode_write_51997 dwc3_mode_write 3 51997 NULL
98610 +skb_copy_datagram_from_iovec_52014 skb_copy_datagram_from_iovec 4-2-5 52014 NULL
98611 +rdmalt_52022 rdmalt 0 52022 NULL
98612 +vxge_rx_alloc_52024 vxge_rx_alloc 3 52024 NULL
98613 +override_release_52032 override_release 2 52032 NULL
98614 +end_port_52042 end_port 0 52042 NULL
98615 +dma_rx_errors_read_52045 dma_rx_errors_read 3 52045 NULL
98616 +msnd_fifo_write_52052 msnd_fifo_write 0-3 52052 NULL
98617 +dvb_ringbuffer_avail_52057 dvb_ringbuffer_avail 0 52057 NULL
98618 +isofs_readpages_52067 isofs_readpages 4 52067 NULL
98619 +nsm_get_handle_52089 nsm_get_handle 4 52089 NULL
98620 +o2net_debug_read_52105 o2net_debug_read 3 52105 NULL
98621 +retry_count_read_52129 retry_count_read 3 52129 NULL
98622 +snd_pcm_channel_info_user_52135 snd_pcm_channel_info_user 0 52135 NULL
98623 +hysdn_conf_write_52145 hysdn_conf_write 3 52145 NULL nohasharray
98624 +ext2_alloc_blocks_52145 ext2_alloc_blocks 2 52145 &hysdn_conf_write_52145
98625 +htable_size_52148 htable_size 0-1 52148 NULL
98626 +__le16_to_cpup_52155 __le16_to_cpup 0 52155 NULL nohasharray
98627 +smk_write_load2_52155 smk_write_load2 3 52155 &__le16_to_cpup_52155
98628 +ieee80211_if_read_dot11MeshRetryTimeout_52168 ieee80211_if_read_dot11MeshRetryTimeout 3 52168 NULL
98629 +mga_compat_ioctl_52170 mga_compat_ioctl 2 52170 NULL
98630 +print_prefix_52176 print_prefix 0 52176 NULL
98631 +proc_pid_readlink_52186 proc_pid_readlink 3 52186 NULL
98632 +do_dmabuf_dirty_ldu_52241 do_dmabuf_dirty_ldu 6 52241 NULL
98633 +pm80x_request_irq_52250 pm80x_request_irq 2 52250 NULL
98634 +mdiobus_alloc_size_52259 mdiobus_alloc_size 1 52259 NULL
98635 +shrink_slab_52261 shrink_slab 2-3 52261 NULL
98636 +sisusbcon_do_font_op_52271 sisusbcon_do_font_op 9 52271 NULL
98637 +mpol_to_str_52293 mpol_to_str 2 52293 NULL
98638 +ath6kl_wmi_get_new_buf_52304 ath6kl_wmi_get_new_buf 1 52304 NULL
98639 +read_file_reset_52310 read_file_reset 3 52310 NULL
98640 +ssd1307fb_write_52315 ssd1307fb_write 3 52315 NULL
98641 +request_asymmetric_key_52317 request_asymmetric_key 2-4 52317 NULL
98642 +hwflags_read_52318 hwflags_read 3 52318 NULL
98643 +snd_pcm_hw_free_52327 snd_pcm_hw_free 0 52327 NULL
98644 +ntfs_rl_split_52328 ntfs_rl_split 2-4 52328 NULL
98645 +test_unaligned_bulk_52333 test_unaligned_bulk 3 52333 NULL
98646 +bytes_to_frames_52362 bytes_to_frames 0-2 52362 NULL
98647 +copy_entries_to_user_52367 copy_entries_to_user 1 52367 NULL
98648 +iwl_dump_fh_52371 iwl_dump_fh 0 52371 NULL
98649 +isdn_writebuf_stub_52383 isdn_writebuf_stub 4 52383 NULL
98650 +jfs_setxattr_52389 jfs_setxattr 4 52389 NULL
98651 +aer_inject_write_52399 aer_inject_write 3 52399 NULL
98652 +pcf50633_reg_clear_bits_52407 pcf50633_reg_clear_bits 2 52407 NULL
98653 +aac_rx_ioremap_52410 aac_rx_ioremap 2 52410 NULL
98654 +cgroup_file_write_52417 cgroup_file_write 3 52417 NULL
98655 +line6_midibuf_init_52425 line6_midibuf_init 2 52425 NULL
98656 +ieee80211_if_fmt_num_sta_ps_52438 ieee80211_if_fmt_num_sta_ps 3 52438 NULL
98657 +nl80211_send_mgmt_tx_status_52445 nl80211_send_mgmt_tx_status 5 52445 NULL
98658 +ieee80211_alloc_txb_52477 ieee80211_alloc_txb 1-2 52477 NULL
98659 +ocfs2_extend_no_holes_52483 ocfs2_extend_no_holes 3-4 52483 NULL
98660 +fd_do_rw_52495 fd_do_rw 3 52495 NULL nohasharray
98661 +skb_cow_head_52495 skb_cow_head 2 52495 &fd_do_rw_52495
98662 +int_tasklet_entry_52500 int_tasklet_entry 3 52500 NULL
98663 +pm_qos_power_write_52513 pm_qos_power_write 3 52513 NULL
98664 +dccpprobe_read_52549 dccpprobe_read 3 52549 NULL
98665 +ocfs2_make_right_split_rec_52562 ocfs2_make_right_split_rec 3 52562 NULL
98666 +emit_code_52583 emit_code 0-3 52583 NULL
98667 +snd_pcm_sw_params_52594 snd_pcm_sw_params 0 52594 NULL
98668 +brcmf_sdio_assert_info_52653 brcmf_sdio_assert_info 4 52653 NULL
98669 +ntfs_get_nr_significant_bytes_52688 ntfs_get_nr_significant_bytes 0 52688 NULL
98670 +nvd0_disp_pioc_create__52693 nvd0_disp_pioc_create_ 5 52693 NULL
98671 +nouveau_client_create__52715 nouveau_client_create_ 5 52715 NULL
98672 +cx25840_ir_rx_read_52724 cx25840_ir_rx_read 3 52724 NULL
98673 +blkcipher_next_slow_52733 blkcipher_next_slow 3-4 52733 NULL
98674 +relay_alloc_page_array_52735 relay_alloc_page_array 1 52735 NULL
98675 +carl9170_debugfs_vif_dump_read_52755 carl9170_debugfs_vif_dump_read 3 52755 NULL
98676 +alloc_extent_buffer_52824 alloc_extent_buffer 3 52824 NULL
98677 +pwr_rcvd_beacons_read_52836 pwr_rcvd_beacons_read 3 52836 NULL
98678 +ext2_xattr_set_acl_52857 ext2_xattr_set_acl 4 52857 NULL
98679 +mon_bin_get_event_52863 mon_bin_get_event 4 52863 NULL
98680 +twlreg_write_52880 twlreg_write 3 52880 NULL
98681 +pvr2_ctrl_value_to_sym_internal_52881 pvr2_ctrl_value_to_sym_internal 5 52881 NULL
98682 +cache_read_procfs_52882 cache_read_procfs 3 52882 NULL
98683 +kvm_kvzalloc_52894 kvm_kvzalloc 1 52894 NULL
98684 +arizona_request_irq_52908 arizona_request_irq 2 52908 NULL
98685 +__kfifo_out_peek_r_52919 __kfifo_out_peek_r 3 52919 NULL
98686 +iblock_get_bio_52936 iblock_get_bio 3 52936 NULL nohasharray
98687 +__iio_device_attr_init_52936 __iio_device_attr_init 0 52936 &iblock_get_bio_52936
98688 +__nodes_remap_52951 __nodes_remap 5 52951 NULL
98689 +send_packet_52960 send_packet 4 52960 NULL
98690 +ieee80211_if_fmt_fwded_mcast_52961 ieee80211_if_fmt_fwded_mcast 3 52961 NULL
98691 +compat_sock_ioctl_52964 compat_sock_ioctl 3 52964 NULL
98692 +tx_tx_exch_read_52986 tx_tx_exch_read 3 52986 NULL
98693 +num_node_state_52989 num_node_state 0 52989 NULL
98694 +batadv_check_management_packet_52993 batadv_check_management_packet 3 52993 NULL
98695 +efivarfs_file_write_53000 efivarfs_file_write 3 53000 NULL
98696 +btrfs_free_and_pin_reserved_extent_53016 btrfs_free_and_pin_reserved_extent 2 53016 NULL
98697 +tx_tx_exch_pending_read_53018 tx_tx_exch_pending_read 3 53018 NULL
98698 +ext4_meta_bg_first_group_53031 ext4_meta_bg_first_group 0-2 53031 NULL
98699 +bio_cur_bytes_53037 bio_cur_bytes 0 53037 NULL
98700 +regcache_lzo_block_count_53056 regcache_lzo_block_count 0 53056 NULL
98701 +cfi_read_query_53066 cfi_read_query 0 53066 NULL
98702 +mwifiex_debug_read_53074 mwifiex_debug_read 3 53074 NULL
98703 +qib_resize_cq_53090 qib_resize_cq 2 53090 NULL
98704 +line6_dumpreq_initbuf_53123 line6_dumpreq_initbuf 3 53123 NULL
98705 +brcmf_usb_dl_cmd_53130 brcmf_usb_dl_cmd 4 53130 NULL
98706 +ps_poll_ps_poll_max_ap_turn_read_53140 ps_poll_ps_poll_max_ap_turn_read 3 53140 NULL
98707 +clear_capture_buf_53192 clear_capture_buf 2 53192 NULL
98708 +mtdoops_erase_block_53206 mtdoops_erase_block 2 53206 NULL
98709 +tx_tx_start_data_read_53219 tx_tx_start_data_read 3 53219 NULL
98710 +xfs_trans_read_buf_map_53258 xfs_trans_read_buf_map 5 53258 NULL
98711 +wil_write_file_ssid_53266 wil_write_file_ssid 3 53266 NULL
98712 +btrfs_file_extent_num_bytes_53269 btrfs_file_extent_num_bytes 0 53269 NULL
98713 +lirc_buffer_init_53282 lirc_buffer_init 3-2 53282 NULL
98714 +batadv_interface_rx_53325 batadv_interface_rx 4 53325 NULL
98715 +gsm_control_reply_53333 gsm_control_reply 4 53333 NULL
98716 +vm_mmap_53339 vm_mmap 0 53339 NULL
98717 +sock_setbindtodevice_53369 sock_setbindtodevice 3 53369 NULL
98718 +get_random_bytes_arch_53370 get_random_bytes_arch 2 53370 NULL
98719 +iwl_pcie_txq_alloc_53413 iwl_pcie_txq_alloc 3 53413 NULL
98720 +wm8996_gpio_set_53421 wm8996_gpio_set 2 53421 NULL
98721 +isr_cmd_cmplt_read_53439 isr_cmd_cmplt_read 3 53439 NULL
98722 +mwifiex_info_read_53447 mwifiex_info_read 3 53447 NULL
98723 +apei_exec_run_optional_53452 apei_exec_run_optional 0 53452 NULL
98724 +acpi_tb_parse_root_table_53455 acpi_tb_parse_root_table 1 53455 NULL
98725 +n2_run_53459 n2_run 3 53459 NULL
98726 +paging64_prefetch_gpte_53468 paging64_prefetch_gpte 4 53468 NULL
98727 +wm831x_write_53469 wm831x_write 2 53469 NULL
98728 +rds_tcp_data_recv_53476 rds_tcp_data_recv 3 53476 NULL
98729 +iowarrior_read_53483 iowarrior_read 3 53483 NULL
98730 +osd_req_write_kern_53486 osd_req_write_kern 5 53486 NULL
98731 +do_verify_xattr_datum_53499 do_verify_xattr_datum 0 53499 NULL
98732 +snd_pcm_format_physical_width_53505 snd_pcm_format_physical_width 0 53505 NULL
98733 +dbAllocNext_53506 dbAllocNext 0 53506 NULL
98734 +ocfs2_xattr_set_acl_53508 ocfs2_xattr_set_acl 4 53508 NULL
98735 +check_acl_53512 check_acl 0 53512 NULL
98736 +set_registers_53582 set_registers 3 53582 NULL
98737 +cifs_utf16_bytes_53593 cifs_utf16_bytes 0 53593 NULL
98738 +__readw_53594 __readw 0 53594 NULL
98739 +___alloc_bootmem_nopanic_53626 ___alloc_bootmem_nopanic 1 53626 NULL
98740 +xd_write_multiple_pages_53633 xd_write_multiple_pages 6-5 53633 NULL
98741 +ccid_getsockopt_builtin_ccids_53634 ccid_getsockopt_builtin_ccids 2 53634 NULL
98742 +nr_sendmsg_53656 nr_sendmsg 4 53656 NULL
98743 +_preload_range_53676 _preload_range 2-3 53676 NULL
98744 +fuse_fill_write_pages_53682 fuse_fill_write_pages 4 53682 NULL
98745 +v4l2_event_subscribe_53687 v4l2_event_subscribe 3 53687 NULL
98746 +bdev_logical_block_size_53690 bdev_logical_block_size 0 53690 NULL nohasharray
98747 +igb_alloc_q_vector_53690 igb_alloc_q_vector 4-6 53690 &bdev_logical_block_size_53690
98748 +find_overflow_devnum_53711 find_overflow_devnum 0 53711 NULL
98749 +bio_integrity_split_53714 bio_integrity_split 3 53714 NULL
98750 +__ocfs2_resv_find_window_53721 __ocfs2_resv_find_window 3 53721 NULL
98751 +wdm_write_53735 wdm_write 3 53735 NULL
98752 +ext3_try_to_allocate_with_rsv_53737 ext3_try_to_allocate_with_rsv 5-3 53737 NULL
98753 +da9052_disable_irq_53745 da9052_disable_irq 2 53745 NULL
98754 +lpfc_idiag_queacc_read_qe_53755 lpfc_idiag_queacc_read_qe 0-2 53755 NULL nohasharray
98755 +amdtp_out_stream_get_max_payload_53755 amdtp_out_stream_get_max_payload 0 53755 &lpfc_idiag_queacc_read_qe_53755
98756 +ext2_acl_count_53773 ext2_acl_count 0-1 53773 NULL
98757 +__kfifo_dma_in_prepare_r_53792 __kfifo_dma_in_prepare_r 4-5 53792 NULL
98758 +__tty_alloc_driver_53799 __tty_alloc_driver 1 53799 NULL
98759 +regmap_raw_write_53803 regmap_raw_write 4-2 53803 NULL
98760 +lpfc_idiag_ctlacc_read_reg_53809 lpfc_idiag_ctlacc_read_reg 0-3 53809 NULL
98761 +nls_nullsize_53815 nls_nullsize 0 53815 NULL
98762 +cpumask_next_zero_53835 cpumask_next_zero 1 53835 NULL
98763 +pms_read_53873 pms_read 3 53873 NULL
98764 +ieee80211_if_fmt_dropped_frames_congestion_53883 ieee80211_if_fmt_dropped_frames_congestion 3 53883 NULL
98765 +ocfs2_rm_xattr_cluster_53900 ocfs2_rm_xattr_cluster 5-4-3 53900 NULL
98766 +proc_file_read_53905 proc_file_read 3 53905 NULL
98767 +azx_via_get_position_53916 azx_via_get_position 0 53916 NULL
98768 +ocfs2_make_clusters_writable_53938 ocfs2_make_clusters_writable 4 53938 NULL
98769 +mthca_setup_cmd_doorbells_53954 mthca_setup_cmd_doorbells 2 53954 NULL
98770 +mlx4_num_eq_uar_53965 mlx4_num_eq_uar 0 53965 NULL
98771 +idetape_chrdev_write_53976 idetape_chrdev_write 3 53976 NULL
98772 +__ocfs2_xattr_set_value_outside_53981 __ocfs2_xattr_set_value_outside 5 53981 NULL
98773 +ieee80211_if_fmt_dot11MeshHWMPperrMinInterval_53998 ieee80211_if_fmt_dot11MeshHWMPperrMinInterval 3 53998 NULL
98774 +snd_pcm_lib_write_transfer_54018 snd_pcm_lib_write_transfer 4-2-5 54018 NULL
98775 +cmpk_message_handle_tx_54024 cmpk_message_handle_tx 4 54024 NULL
98776 +ipxrtr_route_packet_54036 ipxrtr_route_packet 4 54036 NULL
98777 +pipeline_dec_packet_out_read_54052 pipeline_dec_packet_out_read 3 54052 NULL
98778 +nl80211_send_disconnected_54056 nl80211_send_disconnected 5 54056 NULL
98779 +rproc_state_read_54057 rproc_state_read 3 54057 NULL
98780 +_malloc_54077 _malloc 1 54077 NULL
98781 +bitmap_bitremap_54096 bitmap_bitremap 4 54096 NULL
98782 +altera_set_ir_pre_54103 altera_set_ir_pre 2 54103 NULL
98783 +create_xattr_54106 create_xattr 5 54106 NULL
98784 +strn_len_54122 strn_len 0 54122 NULL
98785 +isku_receive_54130 isku_receive 4 54130 NULL
98786 +isr_host_acknowledges_read_54136 isr_host_acknowledges_read 3 54136 NULL
98787 +i2400m_zrealloc_2x_54166 i2400m_zrealloc_2x 3 54166 NULL nohasharray
98788 +memcpy_toiovec_54166 memcpy_toiovec 3 54166 &i2400m_zrealloc_2x_54166
98789 +nouveau_falcon_create__54169 nouveau_falcon_create_ 8 54169 NULL
98790 +acpi_os_read_memory_54186 acpi_os_read_memory 1-3 54186 NULL
98791 +__register_chrdev_54223 __register_chrdev 2-3 54223 NULL
98792 +_format_mac_addr_54229 _format_mac_addr 2-0 54229 NULL
98793 +pi_read_regr_54231 pi_read_regr 0 54231 NULL
98794 +reada_add_block_54247 reada_add_block 2 54247 NULL
98795 +xfs_dir2_sf_addname_hard_54254 xfs_dir2_sf_addname_hard 3 54254 NULL
98796 +ceph_msgpool_get_54258 ceph_msgpool_get 2 54258 NULL
98797 +wusb_prf_54261 wusb_prf 7 54261 NULL nohasharray
98798 +audio_write_54261 audio_write 4 54261 &wusb_prf_54261
98799 +mwifiex_getlog_read_54269 mwifiex_getlog_read 3 54269 NULL
98800 +ubi_calc_data_len_54279 ubi_calc_data_len 0-3 54279 NULL
98801 +altera_set_dr_post_54291 altera_set_dr_post 2 54291 NULL
98802 +dlm_alloc_pagevec_54296 dlm_alloc_pagevec 1 54296 NULL
98803 +sprintf_54306 sprintf 0 54306 NULL
98804 +irq_domain_associate_many_54307 irq_domain_associate_many 2 54307 NULL
98805 +br_fdb_fillbuf_54339 br_fdb_fillbuf 0 54339 NULL
98806 +__alloc_dev_table_54343 __alloc_dev_table 2 54343 NULL
98807 +_osd_realloc_seg_54352 _osd_realloc_seg 3 54352 NULL nohasharray
98808 +__get_free_pages_54352 __get_free_pages 0 54352 &_osd_realloc_seg_54352
98809 +tcf_hash_create_54360 tcf_hash_create 4 54360 NULL
98810 +read_file_credit_dist_stats_54367 read_file_credit_dist_stats 3 54367 NULL
98811 +vfs_readlink_54368 vfs_readlink 3 54368 NULL
98812 +do_dccp_setsockopt_54377 do_dccp_setsockopt 5 54377 NULL nohasharray
98813 +intel_sdvo_write_cmd_54377 intel_sdvo_write_cmd 4 54377 &do_dccp_setsockopt_54377
98814 +ah_alloc_tmp_54378 ah_alloc_tmp 3-2 54378 NULL
98815 +gart_unmap_page_54379 gart_unmap_page 2-3 54379 NULL
98816 +snd_pcm_oss_read2_54387 snd_pcm_oss_read2 0-3 54387 NULL
98817 +i386_mmap_check_54388 i386_mmap_check 0 54388 NULL
98818 +__do_krealloc_54389 __do_krealloc 2 54389 NULL
98819 +iwl_dbgfs_power_save_status_read_54392 iwl_dbgfs_power_save_status_read 3 54392 NULL
98820 +simple_strtoull_54493 simple_strtoull 0 54493 NULL
98821 +btrfs_ordered_sum_size_54509 btrfs_ordered_sum_size 0-2 54509 NULL
98822 +cgroup_write_X64_54514 cgroup_write_X64 5 54514 NULL
98823 +rfc4106_set_key_54519 rfc4106_set_key 3 54519 NULL
98824 +viacam_read_54526 viacam_read 3 54526 NULL
98825 +unix_dgram_connect_54535 unix_dgram_connect 3 54535 NULL
98826 +setsockopt_54539 setsockopt 5 54539 NULL
98827 +mwifiex_usb_submit_rx_urb_54558 mwifiex_usb_submit_rx_urb 2 54558 NULL
98828 +nfsd_vfs_write_54577 nfsd_vfs_write 6 54577 NULL
98829 +fw_iso_buffer_init_54582 fw_iso_buffer_init 3 54582 NULL
98830 +nvme_npages_54601 nvme_npages 0-1 54601 NULL
98831 +fwSendNullPacket_54618 fwSendNullPacket 2 54618 NULL
98832 +irq_of_parse_and_map_54646 irq_of_parse_and_map 0 54646 NULL
98833 +irq_timeout_read_54653 irq_timeout_read 3 54653 NULL
98834 +dns_resolver_read_54658 dns_resolver_read 3 54658 NULL
98835 +twl6030_interrupt_mask_54659 twl6030_interrupt_mask 2 54659 NULL
98836 +bio_kmalloc_54672 bio_kmalloc 2 54672 NULL
98837 +vring_new_virtqueue_54673 vring_new_virtqueue 2 54673 NULL
98838 +evm_read_key_54674 evm_read_key 3 54674 NULL
98839 +resource_string_54699 resource_string 0 54699 NULL
98840 +platform_get_irq_byname_54700 platform_get_irq_byname 0 54700 NULL
98841 +rfkill_fop_read_54711 rfkill_fop_read 3 54711 NULL
98842 +_add_sg_continuation_descriptor_54721 _add_sg_continuation_descriptor 3 54721 NULL
98843 +ocfs2_control_write_54737 ocfs2_control_write 3 54737 NULL
98844 +kzalloc_54740 kzalloc 1 54740 NULL
98845 +wep_iv_read_54744 wep_iv_read 3 54744 NULL
98846 +iio_event_chrdev_read_54757 iio_event_chrdev_read 3 54757 NULL
98847 +batadv_iv_ogm_aggregate_new_54761 batadv_iv_ogm_aggregate_new 2 54761 NULL
98848 +adis16480_show_firmware_date_54762 adis16480_show_firmware_date 3 54762 NULL
98849 +flexcop_device_kmalloc_54793 flexcop_device_kmalloc 1 54793 NULL
98850 +domain_init_54797 domain_init 2 54797 NULL
98851 +ext3_find_goal_54801 ext3_find_goal 0 54801 NULL
98852 +nfsd_write_54809 nfsd_write 6 54809 NULL
98853 +aes_decrypt_fail_read_54815 aes_decrypt_fail_read 3 54815 NULL nohasharray
98854 +crypto_tfm_ctx_alignment_54815 crypto_tfm_ctx_alignment 0 54815 &aes_decrypt_fail_read_54815
98855 +generic_perform_write_54832 generic_perform_write 3 54832 NULL
98856 +write_rio_54837 write_rio 3 54837 NULL
98857 +nouveau_engctx_create__54839 nouveau_engctx_create_ 8 54839 NULL nohasharray
98858 +ext3_acl_from_disk_54839 ext3_acl_from_disk 2 54839 &nouveau_engctx_create__54839
98859 +ufx_ops_write_54848 ufx_ops_write 3 54848 NULL
98860 +printer_read_54851 printer_read 3 54851 NULL
98861 +alloc_ep_req_54860 alloc_ep_req 2 54860 NULL
98862 +broadsheet_spiflash_rewrite_sector_54864 broadsheet_spiflash_rewrite_sector 2 54864 NULL
98863 +prism_build_supp_rates_54865 prism_build_supp_rates 0 54865 NULL
98864 +tcf_csum_ipv6_tcp_54877 tcf_csum_ipv6_tcp 4 54877 NULL
98865 +lm3533_led_get_lv_reg_54900 lm3533_led_get_lv_reg 0-2 54900 NULL
98866 +iscsi_pool_init_54913 iscsi_pool_init 2-4 54913 NULL
98867 +btrfs_stack_chunk_num_stripes_54923 btrfs_stack_chunk_num_stripes 0 54923 NULL
98868 +mxms_structlen_54939 mxms_structlen 0 54939 NULL
98869 +add_port_54941 add_port 2 54941 NULL
98870 +virtblk_add_buf_wait_54943 virtblk_add_buf_wait 3-4 54943 NULL
98871 +wl12xx_cmd_build_probe_req_54946 wl12xx_cmd_build_probe_req 6-8 54946 NULL
98872 +ath9k_dump_btcoex_54949 ath9k_dump_btcoex 0 54949 NULL
98873 +c4_add_card_54968 c4_add_card 3 54968 NULL
98874 +iwl_pcie_dump_fh_54975 iwl_pcie_dump_fh 0 54975 NULL
98875 +__proc_file_read_54978 __proc_file_read 3 54978 NULL
98876 +ext3_xattr_get_54989 ext3_xattr_get 0 54989 NULL
98877 +rds_ib_inc_copy_to_user_55007 rds_ib_inc_copy_to_user 3 55007 NULL
98878 +cx231xx_v4l2_read_55014 cx231xx_v4l2_read 3 55014 NULL
98879 +error_error_null_Frame_tx_start_read_55024 error_error_null_Frame_tx_start_read 3 55024 NULL
98880 +__netdev_alloc_skb_ip_align_55067 __netdev_alloc_skb_ip_align 2 55067 NULL
98881 +apei_exec_run_55075 apei_exec_run 0 55075 NULL
98882 +bitmap_storage_alloc_55077 bitmap_storage_alloc 2 55077 NULL
98883 +snd_pcm_capture_hw_avail_55086 snd_pcm_capture_hw_avail 0 55086 NULL
98884 +rxpipe_beacon_buffer_thres_host_int_trig_rx_data_read_55106 rxpipe_beacon_buffer_thres_host_int_trig_rx_data_read 3 55106 NULL
98885 +corrupt_data_55120 corrupt_data 0 55120 NULL
98886 +crypto_ahash_setkey_55134 crypto_ahash_setkey 3 55134 NULL
98887 +ocfs2_prepare_refcount_change_for_del_55137 ocfs2_prepare_refcount_change_for_del 3 55137 NULL nohasharray
98888 +filldir_55137 filldir 3 55137 &ocfs2_prepare_refcount_change_for_del_55137
98889 +ocfs2_truncate_file_55148 ocfs2_truncate_file 3 55148 NULL
98890 +ieee80211_if_read_uapsd_queues_55150 ieee80211_if_read_uapsd_queues 3 55150 NULL
98891 +mtd_get_fact_prot_info_55186 mtd_get_fact_prot_info 0 55186 NULL
98892 +sel_write_relabel_55195 sel_write_relabel 3 55195 NULL
98893 +sched_feat_write_55202 sched_feat_write 3 55202 NULL
98894 +ht40allow_map_read_55209 ht40allow_map_read 3 55209 NULL nohasharray
98895 +pcf50633_gpio_set_55209 pcf50633_gpio_set 2 55209 &ht40allow_map_read_55209
98896 +ssd1307fb_write_cmd_array_55211 ssd1307fb_write_cmd_array 3 55211 NULL nohasharray
98897 +__kfifo_dma_out_prepare_r_55211 __kfifo_dma_out_prepare_r 4-5 55211 &ssd1307fb_write_cmd_array_55211
98898 +do_raw_setsockopt_55215 do_raw_setsockopt 5 55215 NULL
98899 +dbAllocDmap_55227 dbAllocDmap 0 55227 NULL
98900 +tipc_port_reject_sections_55229 tipc_port_reject_sections 5 55229 NULL
98901 +register_unifi_sdio_55239 register_unifi_sdio 2 55239 NULL
98902 +memcpy_fromiovec_55247 memcpy_fromiovec 3 55247 NULL
98903 +ptrace_request_55288 ptrace_request 3 55288 NULL
98904 +rx_streaming_interval_read_55291 rx_streaming_interval_read 3 55291 NULL
98905 +rbd_create_rw_ops_55297 rbd_create_rw_ops 1 55297 NULL
98906 +gsm_control_modem_55303 gsm_control_modem 3 55303 NULL
98907 +__get_vm_area_node_55305 __get_vm_area_node 1 55305 NULL
98908 +vme_user_read_55338 vme_user_read 3 55338 NULL
98909 +sctp_datamsg_from_user_55342 sctp_datamsg_from_user 4 55342 NULL nohasharray
98910 +__wa_xfer_setup_sizes_55342 __wa_xfer_setup_sizes 0 55342 &sctp_datamsg_from_user_55342
98911 +acpi_system_read_event_55362 acpi_system_read_event 3 55362 NULL
98912 +__send_to_port_55383 __send_to_port 3 55383 NULL
98913 +nf_nat_ipv4_manip_pkt_55387 nf_nat_ipv4_manip_pkt 2 55387 NULL
98914 +iwl_dbgfs_plcp_delta_read_55407 iwl_dbgfs_plcp_delta_read 3 55407 NULL
98915 +alloc_skb_55439 alloc_skb 1 55439 NULL
98916 +__vxge_hw_channel_allocate_55462 __vxge_hw_channel_allocate 3 55462 NULL
98917 +isdnhdlc_decode_55466 isdnhdlc_decode 0 55466 NULL
98918 +cx23888_ir_rx_read_55473 cx23888_ir_rx_read 3 55473 NULL
98919 +batadv_unicast_push_and_fill_skb_55474 batadv_unicast_push_and_fill_skb 2 55474 NULL
98920 +snd_pcm_lib_write_55483 snd_pcm_lib_write 0-3 55483 NULL
98921 +i2o_pool_alloc_55485 i2o_pool_alloc 4 55485 NULL
98922 +wm5100_gpio_direction_out_55497 wm5100_gpio_direction_out 2 55497 NULL
98923 +ocfs2_rec_clusters_55501 ocfs2_rec_clusters 0 55501 NULL
98924 +ext4_flex_bg_size_55502 ext4_flex_bg_size 0 55502 NULL
98925 +cfpkt_pad_trail_55511 cfpkt_pad_trail 2 55511 NULL nohasharray
98926 +tx_tx_done_int_template_read_55511 tx_tx_done_int_template_read 3 55511 &cfpkt_pad_trail_55511
98927 +ea_get_55522 ea_get 0 55522 NULL
98928 +buffer_size_55534 buffer_size 0 55534 NULL
98929 +set_msr_interception_55538 set_msr_interception 2 55538 NULL
98930 +tty_port_register_device_55543 tty_port_register_device 3 55543 NULL
98931 +add_partition_55588 add_partition 2 55588 NULL
98932 +macvtap_put_user_55609 macvtap_put_user 4 55609 NULL
98933 +selinux_setprocattr_55611 selinux_setprocattr 4 55611 NULL
98934 +reiserfs_xattr_get_55628 reiserfs_xattr_get 0 55628 NULL nohasharray
98935 +pktgen_if_write_55628 pktgen_if_write 3 55628 &reiserfs_xattr_get_55628
98936 +dvb_dmxdev_set_buffer_size_55643 dvb_dmxdev_set_buffer_size 2 55643 NULL
98937 +mlx4_buddy_alloc_55647 mlx4_buddy_alloc 2 55647 NULL
98938 +xfs_bmbt_maxrecs_55649 xfs_bmbt_maxrecs 0-2 55649 NULL
98939 +ib_umad_compat_ioctl_55650 ib_umad_compat_ioctl 3 55650 NULL
98940 +cfg80211_send_rx_assoc_55651 cfg80211_send_rx_assoc 4 55651 NULL
98941 +read_oldmem_55658 read_oldmem 3 55658 NULL
98942 +lpfc_idiag_queinfo_read_55662 lpfc_idiag_queinfo_read 3 55662 NULL
98943 +il_dbgfs_tx_queue_read_55668 il_dbgfs_tx_queue_read 3 55668 NULL
98944 +get_info_55681 get_info 3 55681 NULL
98945 +arizona_gpio_direction_in_55690 arizona_gpio_direction_in 2 55690 NULL
98946 +wil_vring_alloc_skb_55703 wil_vring_alloc_skb 4 55703 NULL
98947 +__videobuf_alloc_uncached_55711 __videobuf_alloc_uncached 1 55711 NULL
98948 +pm8001_store_update_fw_55716 pm8001_store_update_fw 4 55716 NULL
98949 +mtdswap_init_55719 mtdswap_init 2 55719 NULL
98950 +__iio_allocate_kfifo_55738 __iio_allocate_kfifo 3-2 55738 NULL
98951 +set_local_name_55757 set_local_name 4 55757 NULL
98952 +btrfs_init_new_buffer_55761 btrfs_init_new_buffer 4 55761 NULL
98953 +strlen_55778 strlen 0 55778 NULL nohasharray
98954 +is_idx_node_in_tnc_55778 is_idx_node_in_tnc 0 55778 &strlen_55778
98955 +req_bio_endio_55786 req_bio_endio 3 55786 NULL nohasharray
98956 +conf_read_55786 conf_read 3 55786 &req_bio_endio_55786
98957 +uwb_rc_neh_grok_event_55799 uwb_rc_neh_grok_event 3 55799 NULL
98958 +btrfs_find_create_tree_block_55812 btrfs_find_create_tree_block 3 55812 NULL
98959 +sb16_copy_from_user_55836 sb16_copy_from_user 10-6-7 55836 NULL
98960 +ip_hdrlen_55849 ip_hdrlen 0 55849 NULL
98961 +hcd_alloc_coherent_55862 hcd_alloc_coherent 5 55862 NULL
98962 +shmem_setxattr_55867 shmem_setxattr 4 55867 NULL
98963 +hsc_write_55875 hsc_write 3 55875 NULL
98964 +pm_qos_power_read_55891 pm_qos_power_read 3 55891 NULL
98965 +snd_pcm_hw_param_value_min_55917 snd_pcm_hw_param_value_min 0 55917 NULL
98966 +sel_read_policy_55947 sel_read_policy 3 55947 NULL
98967 +handle_response_55951 handle_response 5 55951 NULL
98968 +simple_read_from_buffer_55957 simple_read_from_buffer 2-5 55957 NULL
98969 +tx_tx_imm_resp_read_55964 tx_tx_imm_resp_read 3 55964 NULL
98970 +ssb_bus_pcmciabus_register_56020 ssb_bus_pcmciabus_register 3 56020 NULL
98971 +nvme_alloc_iod_56027 nvme_alloc_iod 1-2 56027 NULL
98972 +dccp_sendmsg_56058 dccp_sendmsg 4 56058 NULL
98973 +pscsi_get_bio_56103 pscsi_get_bio 1 56103 NULL
98974 +usb_alloc_stream_buffers_56123 usb_alloc_stream_buffers 3 56123 NULL
98975 +kmem_zalloc_large_56128 kmem_zalloc_large 1 56128 NULL
98976 +sel_read_handle_status_56139 sel_read_handle_status 3 56139 NULL
98977 +map_addr_56144 map_addr 7 56144 NULL
98978 +rawv6_setsockopt_56165 rawv6_setsockopt 5 56165 NULL
98979 +create_irq_nr_56180 create_irq_nr 1 56180 NULL
98980 +ath9k_dump_legacy_btcoex_56194 ath9k_dump_legacy_btcoex 0 56194 NULL
98981 +skb_headroom_56200 skb_headroom 0 56200 NULL
98982 +usb_dump_iad_descriptor_56204 usb_dump_iad_descriptor 0 56204 NULL
98983 +ncp_read_bounce_size_56221 ncp_read_bounce_size 0-1 56221 NULL
98984 +ocfs2_find_xe_in_bucket_56224 ocfs2_find_xe_in_bucket 0 56224 NULL
98985 +cp210x_get_config_56229 cp210x_get_config 4 56229 NULL
98986 +do_ipt_set_ctl_56238 do_ipt_set_ctl 4 56238 NULL
98987 +scrub_setup_recheck_block_56245 scrub_setup_recheck_block 4-3 56245 NULL
98988 +fd_copyin_56247 fd_copyin 3 56247 NULL
98989 +sk_rmem_schedule_56255 sk_rmem_schedule 3 56255 NULL
98990 +il4965_ucode_general_stats_read_56277 il4965_ucode_general_stats_read 3 56277 NULL
98991 +ieee80211_if_fmt_user_power_level_56283 ieee80211_if_fmt_user_power_level 3 56283 NULL
98992 +RESIZE_IF_NEEDED_56286 RESIZE_IF_NEEDED 2 56286 NULL
98993 +dvb_aplay_56296 dvb_aplay 3 56296 NULL
98994 +btmrvl_hscfgcmd_read_56303 btmrvl_hscfgcmd_read 3 56303 NULL
98995 +compat_cdrom_read_audio_56304 compat_cdrom_read_audio 4 56304 NULL
98996 +pipeline_pre_to_defrag_swi_read_56321 pipeline_pre_to_defrag_swi_read 3 56321 NULL
98997 +journal_init_revoke_table_56331 journal_init_revoke_table 1 56331 NULL
98998 +snd_rawmidi_read_56337 snd_rawmidi_read 3 56337 NULL
98999 +sixpack_compat_ioctl_56346 sixpack_compat_ioctl 4 56346 NULL
99000 +vxge_os_dma_malloc_async_56348 vxge_os_dma_malloc_async 3 56348 NULL
99001 +tps80031_ext_power_req_config_56353 tps80031_ext_power_req_config 3-4-5 56353 NULL
99002 +iov_iter_copy_from_user_atomic_56368 iov_iter_copy_from_user_atomic 4 56368 NULL
99003 +dev_read_56369 dev_read 3 56369 NULL
99004 +alloc_dummy_extent_buffer_56374 alloc_dummy_extent_buffer 2 56374 NULL
99005 +snd_pcm_common_ioctl1_56382 snd_pcm_common_ioctl1 0 56382 NULL
99006 +ocfs2_control_read_56405 ocfs2_control_read 3 56405 NULL
99007 +__get_vm_area_caller_56416 __get_vm_area_caller 1 56416 NULL nohasharray
99008 +acpi_os_write_memory_56416 acpi_os_write_memory 1-3 56416 &__get_vm_area_caller_56416
99009 +store_msg_56417 store_msg 3 56417 NULL
99010 +pppol2tp_sendmsg_56420 pppol2tp_sendmsg 4 56420 NULL
99011 +ec_dbgfs_cmd_read_56431 ec_dbgfs_cmd_read 3 56431 NULL
99012 +fl_create_56435 fl_create 5 56435 NULL
99013 +gnttab_map_56439 gnttab_map 2 56439 NULL
99014 +cx231xx_init_isoc_56453 cx231xx_init_isoc 3-2 56453 NULL
99015 +set_connectable_56458 set_connectable 4 56458 NULL
99016 +osd_req_list_partition_objects_56464 osd_req_list_partition_objects 5 56464 NULL
99017 +calc_linear_pos_56472 calc_linear_pos 0-3 56472 NULL
99018 +crypto_shash_alignmask_56486 crypto_shash_alignmask 0 56486 NULL
99019 +cfg80211_connect_result_56515 cfg80211_connect_result 4-6 56515 NULL
99020 +ip_options_get_56538 ip_options_get 4 56538 NULL
99021 +ocfs2_change_extent_flag_56549 ocfs2_change_extent_flag 5 56549 NULL
99022 +alloc_apertures_56561 alloc_apertures 1 56561 NULL
99023 +rs_sta_dbgfs_stats_table_read_56573 rs_sta_dbgfs_stats_table_read 3 56573 NULL
99024 +portcntrs_2_read_56586 portcntrs_2_read 3 56586 NULL
99025 +event_filter_write_56609 event_filter_write 3 56609 NULL
99026 +gather_array_56641 gather_array 3 56641 NULL
99027 +uvc_debugfs_stats_read_56651 uvc_debugfs_stats_read 3 56651 NULL
99028 +snd_gus_dram_read_56686 snd_gus_dram_read 4 56686 NULL nohasharray
99029 +da9055_gpio_to_irq_56686 da9055_gpio_to_irq 2 56686 &snd_gus_dram_read_56686
99030 +dvb_ringbuffer_read_user_56702 dvb_ringbuffer_read_user 3 56702 NULL
99031 +sta_flags_read_56710 sta_flags_read 3 56710 NULL
99032 +ipv6_getsockopt_sticky_56711 ipv6_getsockopt_sticky 5 56711 NULL
99033 +__wa_xfer_setup_segs_56725 __wa_xfer_setup_segs 2 56725 NULL
99034 +pcpu_populate_chunk_56741 pcpu_populate_chunk 2-3 56741 NULL
99035 +drm_agp_bind_pages_56748 drm_agp_bind_pages 3 56748 NULL
99036 +btrfsic_map_block_56751 btrfsic_map_block 2 56751 NULL
99037 +alloc_iommu_56778 alloc_iommu 2-3 56778 NULL
99038 +__carl9170_rx_56784 __carl9170_rx 3 56784 NULL
99039 +do_syslog_56807 do_syslog 3 56807 NULL
99040 +mtdchar_write_56831 mtdchar_write 3 56831 NULL nohasharray
99041 +ntfs_rl_realloc_56831 ntfs_rl_realloc 3 56831 &mtdchar_write_56831
99042 +snd_rawmidi_kernel_write1_56847 snd_rawmidi_kernel_write1 4 56847 NULL
99043 +ext3_xattr_ibody_get_56880 ext3_xattr_ibody_get 0 56880 NULL
99044 +pvr2_debugifc_print_status_56890 pvr2_debugifc_print_status 3 56890 NULL
99045 +debug_debug3_read_56894 debug_debug3_read 3 56894 NULL
99046 +batadv_tt_update_changes_56895 batadv_tt_update_changes 3 56895 NULL
99047 +strcspn_56913 strcspn 0 56913 NULL
99048 +__kfifo_out_56927 __kfifo_out 0-3 56927 NULL
99049 +check_header_56930 check_header 2 56930 NULL
99050 +journal_init_revoke_56933 journal_init_revoke 2 56933 NULL
99051 +diva_get_driver_info_56967 diva_get_driver_info 0 56967 NULL
99052 +nouveau_device_create__56984 nouveau_device_create_ 6 56984 NULL
99053 +vlsi_alloc_ring_57003 vlsi_alloc_ring 3-4 57003 NULL
99054 +btrfs_super_csum_size_57004 btrfs_super_csum_size 0 57004 NULL
99055 +skb_network_offset_57043 skb_network_offset 0 57043 NULL nohasharray
99056 +ieee80211_if_fmt_state_57043 ieee80211_if_fmt_state 3 57043 &skb_network_offset_57043
99057 +bytes_to_samples_57049 bytes_to_samples 0-2 57049 NULL
99058 +xfs_buf_read_map_57053 xfs_buf_read_map 3 57053 NULL
99059 +autofs_dev_ioctl_compat_57059 autofs_dev_ioctl_compat 3 57059 NULL
99060 +cx2341x_ctrl_new_std_57061 cx2341x_ctrl_new_std 4 57061 NULL
99061 +sca3000_read_data_57064 sca3000_read_data 4 57064 NULL
99062 +pcmcia_replace_cis_57066 pcmcia_replace_cis 3 57066 NULL
99063 +sis190_try_rx_copy_57069 sis190_try_rx_copy 3 57069 NULL
99064 +tracing_set_trace_write_57096 tracing_set_trace_write 3 57096 NULL
99065 +snd_pcm_hw_params_old_user_57108 snd_pcm_hw_params_old_user 0 57108 NULL
99066 +crypto_compress_ctxsize_57109 crypto_compress_ctxsize 0 57109 NULL
99067 +sysfs_write_file_57116 sysfs_write_file 3 57116 NULL
99068 +cipso_v4_gentag_loc_57119 cipso_v4_gentag_loc 0 57119 NULL
99069 +nl80211_send_deauth_57136 nl80211_send_deauth 4 57136 NULL nohasharray
99070 +rds_ib_sub_signaled_57136 rds_ib_sub_signaled 2 57136 &nl80211_send_deauth_57136 nohasharray
99071 +ima_show_htable_value_57136 ima_show_htable_value 2 57136 &rds_ib_sub_signaled_57136
99072 +snd_sonicvibes_getdmac_57140 snd_sonicvibes_getdmac 0 57140 NULL
99073 +udl_prime_create_57159 udl_prime_create 2 57159 NULL
99074 +stk_prepare_sio_buffers_57168 stk_prepare_sio_buffers 2 57168 NULL
99075 +rx_hw_stuck_read_57179 rx_hw_stuck_read 3 57179 NULL
99076 +tt3650_ci_msg_57219 tt3650_ci_msg 4 57219 NULL
99077 +dma_fifo_alloc_57236 dma_fifo_alloc 5-3-2 57236 NULL
99078 +ieee80211_if_fmt_tsf_57249 ieee80211_if_fmt_tsf 3 57249 NULL
99079 +oprofilefs_ulong_from_user_57251 oprofilefs_ulong_from_user 3 57251 NULL
99080 +alloc_flex_gd_57259 alloc_flex_gd 1 57259 NULL
99081 +security_mmap_file_57268 security_mmap_file 0 57268 NULL
99082 +pstore_file_read_57288 pstore_file_read 3 57288 NULL
99083 +snd_pcm_read_57289 snd_pcm_read 3 57289 NULL
99084 +ath6kl_buf_alloc_57304 ath6kl_buf_alloc 1 57304 NULL
99085 +fw_file_size_57307 fw_file_size 0 57307 NULL
99086 +ftdi_elan_write_57309 ftdi_elan_write 3 57309 NULL
99087 +__mxt_write_reg_57326 __mxt_write_reg 3 57326 NULL
99088 +ocfs2_xattr_shrink_size_57328 ocfs2_xattr_shrink_size 3 57328 NULL
99089 +check_mirror_57342 check_mirror 1-2 57342 NULL nohasharray
99090 +usblp_read_57342 usblp_read 3 57342 &check_mirror_57342
99091 +print_devstats_dot11RTSFailureCount_57347 print_devstats_dot11RTSFailureCount 3 57347 NULL
99092 +tipc_bclink_stats_57372 tipc_bclink_stats 2 57372 NULL
99093 +max8997_irq_domain_map_57375 max8997_irq_domain_map 2 57375 NULL
99094 +tty_register_device_attr_57381 tty_register_device_attr 2 57381 NULL
99095 +read_file_blob_57406 read_file_blob 3 57406 NULL
99096 +enclosure_register_57412 enclosure_register 3 57412 NULL
99097 +gre_manip_pkt_57416 gre_manip_pkt 4 57416 NULL
99098 +wm831x_gpio_set_debounce_57428 wm831x_gpio_set_debounce 2 57428 NULL
99099 +compat_keyctl_instantiate_key_iov_57431 compat_keyctl_instantiate_key_iov 3 57431 NULL nohasharray
99100 +alloc_ftrace_hash_57431 alloc_ftrace_hash 1 57431 &compat_keyctl_instantiate_key_iov_57431
99101 +copy_to_user_fromio_57432 copy_to_user_fromio 3 57432 NULL
99102 +sys_pselect6_57449 sys_pselect6 1 57449 NULL
99103 +ReadReg_57453 ReadReg 0 57453 NULL
99104 +__roundup_pow_of_two_57461 __roundup_pow_of_two 0 57461 NULL
99105 +crypto_tfm_alg_blocksize_57463 crypto_tfm_alg_blocksize 0 57463 NULL nohasharray
99106 +send_midi_async_57463 send_midi_async 3 57463 &crypto_tfm_alg_blocksize_57463
99107 +sisusb_clear_vram_57466 sisusb_clear_vram 3-2 57466 NULL
99108 +ieee80211_if_read_flags_57470 ieee80211_if_read_flags 3 57470 NULL nohasharray
99109 +sep_lock_user_pages_57470 sep_lock_user_pages 2-3 57470 &ieee80211_if_read_flags_57470
99110 +ocfs2_write_cluster_57483 ocfs2_write_cluster 8-2-9 57483 NULL
99111 +bnad_debugfs_write_regwr_57500 bnad_debugfs_write_regwr 3 57500 NULL
99112 +skb_headlen_57501 skb_headlen 0 57501 NULL
99113 +ks8842_read32_57505 ks8842_read32 0 57505 NULL nohasharray
99114 +ckhdid_printf_57505 ckhdid_printf 2 57505 &ks8842_read32_57505
99115 +init_tag_map_57515 init_tag_map 3 57515 NULL
99116 +wil_read_file_ssid_57517 wil_read_file_ssid 3 57517 NULL nohasharray
99117 +il_dbgfs_force_reset_read_57517 il_dbgfs_force_reset_read 3 57517 &wil_read_file_ssid_57517
99118 +inode_permission_57531 inode_permission 0 57531 NULL
99119 +acpi_dev_get_resources_57534 acpi_dev_get_resources 0 57534 NULL nohasharray
99120 +DoC_Probe_57534 DoC_Probe 1 57534 &acpi_dev_get_resources_57534
99121 +ext4_group_first_block_no_57559 ext4_group_first_block_no 0-2 57559 NULL
99122 +snd_pcm_playback_ioctl1_57569 snd_pcm_playback_ioctl1 0 57569 NULL
99123 +lp8788_update_bits_57600 lp8788_update_bits 2 57600 NULL
99124 +wm831x_gpio_to_irq_57614 wm831x_gpio_to_irq 2 57614 NULL
99125 +sk_stream_alloc_skb_57622 sk_stream_alloc_skb 2 57622 NULL
99126 +tps65217_reg_write_57623 tps65217_reg_write 2 57623 NULL nohasharray
99127 +tx_tx_retry_template_read_57623 tx_tx_retry_template_read 3 57623 &tps65217_reg_write_57623
99128 +osdmap_set_max_osd_57630 osdmap_set_max_osd 2 57630 NULL nohasharray
99129 +sisusbcon_putcs_57630 sisusbcon_putcs 3 57630 &osdmap_set_max_osd_57630
99130 +mem_read_57631 mem_read 3 57631 NULL
99131 +tc3589x_irq_map_57639 tc3589x_irq_map 2 57639 NULL
99132 +sys_mq_timedsend_57661 sys_mq_timedsend 3 57661 NULL
99133 +r3964_write_57662 r3964_write 4 57662 NULL
99134 +proc_ns_readlink_57664 proc_ns_readlink 3 57664 NULL
99135 +__lgwrite_57669 __lgwrite 4 57669 NULL
99136 +ieee80211_MFIE_rate_len_57692 ieee80211_MFIE_rate_len 0 57692 NULL
99137 +f1x_match_to_this_node_57695 f1x_match_to_this_node 3 57695 NULL
99138 +check_prefree_segments_57702 check_prefree_segments 2 57702 NULL
99139 +i2400m_rx_stats_read_57706 i2400m_rx_stats_read 3 57706 NULL
99140 +ieee80211_if_read_dot11MeshHWMPconfirmationInterval_57722 ieee80211_if_read_dot11MeshHWMPconfirmationInterval 3 57722 NULL
99141 +compat_sys_set_mempolicy_57742 compat_sys_set_mempolicy 3 57742 NULL
99142 +ieee80211_if_fmt_dot11MeshHWMPpreqMinInterval_57762 ieee80211_if_fmt_dot11MeshHWMPpreqMinInterval 3 57762 NULL
99143 +ld2_57794 ld2 0 57794 NULL
99144 +ivtv_read_57796 ivtv_read 3 57796 NULL
99145 +generic_ptrace_peekdata_57806 generic_ptrace_peekdata 2 57806 NULL
99146 +usb_dump_config_57817 usb_dump_config 0 57817 NULL
99147 +bfad_debugfs_read_regrd_57830 bfad_debugfs_read_regrd 3 57830 NULL
99148 +copy_to_user_57835 copy_to_user 3 57835 NULL
99149 +flash_read_57843 flash_read 3 57843 NULL
99150 +xt_alloc_table_info_57903 xt_alloc_table_info 1 57903 NULL
99151 +ad5380_info_to_reg_57905 ad5380_info_to_reg 0 57905 NULL
99152 +emi26_writememory_57908 emi26_writememory 4 57908 NULL
99153 +iio_read_first_n_kfifo_57910 iio_read_first_n_kfifo 2 57910 NULL
99154 +memcg_caches_array_size_57918 memcg_caches_array_size 0-1 57918 NULL
99155 +twl_i2c_write_57923 twl_i2c_write 4-3 57923 NULL
99156 +__snd_gf1_look16_57925 __snd_gf1_look16 0 57925 NULL
99157 +sel_read_handle_unknown_57933 sel_read_handle_unknown 3 57933 NULL
99158 +key_algorithm_read_57946 key_algorithm_read 3 57946 NULL
99159 +ip_set_alloc_57953 ip_set_alloc 1 57953 NULL nohasharray
99160 +ioat3_dca_count_dca_slots_57953 ioat3_dca_count_dca_slots 0 57953 &ip_set_alloc_57953
99161 +i915_cache_sharing_write_57961 i915_cache_sharing_write 3 57961 NULL
99162 +hfc_empty_fifo_57972 hfc_empty_fifo 2 57972 NULL
99163 +rx_reset_counter_read_58001 rx_reset_counter_read 3 58001 NULL
99164 +regcache_rbtree_insert_to_block_58009 regcache_rbtree_insert_to_block 5 58009 NULL
99165 +iwl_dbgfs_ucode_rx_stats_read_58023 iwl_dbgfs_ucode_rx_stats_read 3 58023 NULL
99166 +io_playback_transfer_58030 io_playback_transfer 4 58030 NULL
99167 +mc13783_write_58033 mc13783_write 2 58033 NULL
99168 +mce_async_out_58056 mce_async_out 3 58056 NULL
99169 +ocfs2_find_leaf_58065 ocfs2_find_leaf 0 58065 NULL
99170 +dt3155_alloc_coherent_58073 dt3155_alloc_coherent 2 58073 NULL
99171 +cm4040_write_58079 cm4040_write 3 58079 NULL
99172 +udi_log_event_58105 udi_log_event 3 58105 NULL
99173 +savemem_58129 savemem 3 58129 NULL
99174 +ipv6_flowlabel_opt_58135 ipv6_flowlabel_opt 3 58135 NULL nohasharray
99175 +slhc_init_58135 slhc_init 1-2 58135 &ipv6_flowlabel_opt_58135
99176 +garmin_write_bulk_58191 garmin_write_bulk 3 58191 NULL
99177 +asix_write_cmd_58192 asix_write_cmd 5 58192 NULL
99178 +ieee80211_if_fmt_flags_58205 ieee80211_if_fmt_flags 3 58205 NULL
99179 +btrfs_mksubvol_58240 btrfs_mksubvol 3 58240 NULL
99180 +btrfsic_create_link_to_next_block_58246 btrfsic_create_link_to_next_block 4 58246 NULL
99181 +read_file_debug_58256 read_file_debug 3 58256 NULL
99182 +cfg80211_mgmt_tx_status_58266 cfg80211_mgmt_tx_status 4 58266 NULL
99183 +profile_load_58267 profile_load 3 58267 NULL
99184 +acpi_ds_build_internal_package_obj_58271 acpi_ds_build_internal_package_obj 3 58271 NULL
99185 +r100_mm_rreg_58276 r100_mm_rreg 0 58276 NULL
99186 +iscsi_decode_text_input_58292 iscsi_decode_text_input 4 58292 NULL
99187 +ieee80211_if_read_dot11MeshTTL_58307 ieee80211_if_read_dot11MeshTTL 3 58307 NULL
99188 +tx_tx_start_int_templates_read_58324 tx_tx_start_int_templates_read 3 58324 NULL
99189 +pcim_iomap_58334 pcim_iomap 3 58334 NULL
99190 +diva_init_dma_map_58336 diva_init_dma_map 3 58336 NULL
99191 +ieee80211_send_probe_req_58337 ieee80211_send_probe_req 4-6 58337 NULL
99192 +next_pidmap_58347 next_pidmap 2 58347 NULL
99193 +vmalloc_to_sg_58354 vmalloc_to_sg 2 58354 NULL
99194 +brcmf_debugfs_sdio_counter_read_58369 brcmf_debugfs_sdio_counter_read 3 58369 NULL
99195 +il_dbgfs_status_read_58388 il_dbgfs_status_read 3 58388 NULL
99196 +kvm_mmu_write_protect_pt_masked_58406 kvm_mmu_write_protect_pt_masked 3 58406 NULL
99197 +i2400m_pld_size_58415 i2400m_pld_size 0 58415 NULL
99198 +__mlx4_alloc_mtt_range_58418 __mlx4_alloc_mtt_range 2 58418 NULL
99199 +__iio_add_chan_devattr_58451 __iio_add_chan_devattr 0 58451 NULL
99200 +capabilities_read_58457 capabilities_read 3 58457 NULL
99201 +batadv_iv_ogm_aggr_packet_58462 batadv_iv_ogm_aggr_packet 3 58462 NULL
99202 +lpfc_idiag_baracc_read_58466 lpfc_idiag_baracc_read 3 58466 NULL nohasharray
99203 +compat_do_ipt_set_ctl_58466 compat_do_ipt_set_ctl 4 58466 &lpfc_idiag_baracc_read_58466
99204 +snd_gf1_read_addr_58483 snd_gf1_read_addr 0 58483 NULL
99205 +snd_rme96_capture_copy_58484 snd_rme96_capture_copy 5 58484 NULL
99206 +batadv_bla_is_backbone_gw_58488 batadv_bla_is_backbone_gw 3 58488 NULL
99207 +wm831x_reg_write_58489 wm831x_reg_write 2 58489 NULL
99208 +rndis_add_response_58544 rndis_add_response 2 58544 NULL
99209 +wep_decrypt_fail_read_58567 wep_decrypt_fail_read 3 58567 NULL
99210 +sip_sprintf_addr_port_58574 sip_sprintf_addr_port 0 58574 NULL
99211 +scnprint_mac_oui_58578 scnprint_mac_oui 3-0 58578 NULL
99212 +ea_read_inline_58589 ea_read_inline 0 58589 NULL
99213 +xip_file_read_58592 xip_file_read 3 58592 NULL
99214 +gdth_search_isa_58595 gdth_search_isa 1 58595 NULL
99215 +ebt_buf_count_58607 ebt_buf_count 0 58607 NULL
99216 +skb_copy_to_page_nocache_58624 skb_copy_to_page_nocache 6 58624 NULL
99217 +module_alloc_update_bounds_rx_58634 module_alloc_update_bounds_rx 1 58634 NULL nohasharray
99218 +efi_ioremap_58634 efi_ioremap 1-2 58634 &module_alloc_update_bounds_rx_58634
99219 +tx_tx_start_fw_gen_read_58648 tx_tx_start_fw_gen_read 3 58648 NULL
99220 +ocfs2_block_to_cluster_start_58653 ocfs2_block_to_cluster_start 2 58653 NULL
99221 +find_zero_58685 find_zero 0-1 58685 NULL nohasharray
99222 +mcs7830_set_reg_async_58685 mcs7830_set_reg_async 3 58685 &find_zero_58685
99223 +uwb_bce_print_IEs_58686 uwb_bce_print_IEs 4 58686 NULL
99224 +tps6586x_writes_58689 tps6586x_writes 3-2 58689 NULL
99225 +vmalloc_node_58700 vmalloc_node 1 58700 NULL
99226 +acpi_map_58725 acpi_map 1-2 58725 NULL
99227 +da9052_gpio_to_irq_58729 da9052_gpio_to_irq 2 58729 NULL
99228 +csum_exist_in_range_58730 csum_exist_in_range 2 58730 NULL
99229 +frames_to_bytes_58741 frames_to_bytes 0-2 58741 NULL
99230 +ieee80211_if_write_tkip_mic_test_58748 ieee80211_if_write_tkip_mic_test 3 58748 NULL
99231 +agp_allocate_memory_58761 agp_allocate_memory 2 58761 NULL
99232 +__do_config_autodelink_58763 __do_config_autodelink 3 58763 NULL
99233 +regmap_calc_reg_len_58795 regmap_calc_reg_len 0 58795 NULL
99234 +raw_send_hdrinc_58803 raw_send_hdrinc 4 58803 NULL
99235 +isku_sysfs_read_58806 isku_sysfs_read 6 58806 NULL
99236 +ep_read_58813 ep_read 3 58813 NULL
99237 +command_write_58841 command_write 3 58841 NULL
99238 +ocfs2_truncate_log_append_58850 ocfs2_truncate_log_append 3 58850 NULL
99239 +ath6kl_wmi_send_action_cmd_58860 ath6kl_wmi_send_action_cmd 7 58860 NULL
99240 +hw_write_58881 hw_write 2 58881 NULL
99241 +gs_alloc_req_58883 gs_alloc_req 2 58883 NULL
99242 +cs553x_init_one_58886 cs553x_init_one 3 58886 NULL
99243 +raw_ctl_compat_ioctl_58905 raw_ctl_compat_ioctl 3 58905 NULL
99244 +print_devstats_dot11FCSErrorCount_58919 print_devstats_dot11FCSErrorCount 3 58919 NULL
99245 +tun_chr_compat_ioctl_58921 tun_chr_compat_ioctl 3 58921 NULL
99246 +pipeline_cs_rx_packet_out_read_58926 pipeline_cs_rx_packet_out_read 3 58926 NULL
99247 +st5481_isoc_flatten_58952 st5481_isoc_flatten 0 58952 NULL
99248 +ieee80211_if_fmt_dot11MeshHWMPactivePathToRootTimeout_58965 ieee80211_if_fmt_dot11MeshHWMPactivePathToRootTimeout 3 58965 NULL
99249 +crypto_aead_ivsize_58970 crypto_aead_ivsize 0 58970 NULL
99250 +handle_rx_packet_58993 handle_rx_packet 3 58993 NULL
99251 +edac_align_ptr_59003 edac_align_ptr 0 59003 NULL
99252 +ep_write_59008 ep_write 3 59008 NULL
99253 +i915_ring_stop_write_59010 i915_ring_stop_write 3 59010 NULL
99254 +init_pci_cap_msi_perm_59033 init_pci_cap_msi_perm 2 59033 NULL
99255 +selinux_transaction_write_59038 selinux_transaction_write 3 59038 NULL
99256 +crypto_aead_reqsize_59039 crypto_aead_reqsize 0 59039 NULL
99257 +regmap_bulk_write_59049 regmap_bulk_write 4-2 59049 NULL
99258 +da9052_gpio_direction_input_59062 da9052_gpio_direction_input 2 59062 NULL
99259 +vfio_device_fops_compat_ioctl_59111 vfio_device_fops_compat_ioctl 3 59111 NULL
99260 +mmc_sd_num_wr_blocks_59112 mmc_sd_num_wr_blocks 0 59112 NULL
99261 +scsi_io_completion_59122 scsi_io_completion 2 59122 NULL
99262 +nfc_llcp_send_i_frame_59130 nfc_llcp_send_i_frame 3 59130 NULL
99263 +__iio_add_event_config_attrs_59136 __iio_add_event_config_attrs 0 59136 NULL
99264 +print_devstats_dot11RTSSuccessCount_59145 print_devstats_dot11RTSSuccessCount 3 59145 NULL nohasharray
99265 +framebuffer_alloc_59145 framebuffer_alloc 1 59145 &print_devstats_dot11RTSSuccessCount_59145
99266 +radeon_compat_ioctl_59150 radeon_compat_ioctl 2 59150 NULL
99267 +pvr2_hdw_report_clients_59152 pvr2_hdw_report_clients 3 59152 NULL
99268 +setup_window_59178 setup_window 4-2-5-7 59178 NULL
99269 +ocfs2_move_extent_59187 ocfs2_move_extent 3 59187 NULL
99270 +xfs_iext_realloc_indirect_59211 xfs_iext_realloc_indirect 2 59211 NULL
99271 +fast_rx_path_59214 fast_rx_path 3 59214 NULL
99272 +inftl_partscan_59216 inftl_partscan 0 59216 NULL
99273 +skb_transport_header_59223 skb_transport_header 0 59223 NULL
99274 +dt3155_read_59226 dt3155_read 3 59226 NULL
99275 +paging64_gpte_to_gfn_lvl_59229 paging64_gpte_to_gfn_lvl 0-1-2 59229 NULL
99276 +rbd_do_request_59239 rbd_do_request 6-7 59239 NULL
99277 +tty_prepare_flip_string_flags_59240 tty_prepare_flip_string_flags 4 59240 NULL
99278 +solo_v4l2_read_59247 solo_v4l2_read 3 59247 NULL
99279 +nla_len_59258 nla_len 0 59258 NULL
99280 +da9055_reg_update_59280 da9055_reg_update 2 59280 NULL
99281 +btrfs_insert_dir_item_59304 btrfs_insert_dir_item 4 59304 NULL
99282 +fd_copyout_59323 fd_copyout 3 59323 NULL
99283 +read_9287_modal_eeprom_59327 read_9287_modal_eeprom 3 59327 NULL
99284 +rx_defrag_in_process_called_read_59338 rx_defrag_in_process_called_read 3 59338 NULL
99285 +xfs_attrmulti_attr_set_59346 xfs_attrmulti_attr_set 4 59346 NULL
99286 +xfs_dir2_sf_entsize_59366 xfs_dir2_sf_entsize 0-2 59366 NULL
99287 +pvr2_debugifc_print_info_59380 pvr2_debugifc_print_info 3 59380 NULL
99288 +fc_frame_alloc_fill_59394 fc_frame_alloc_fill 2 59394 NULL
99289 +vxge_hw_ring_rxds_per_block_get_59425 vxge_hw_ring_rxds_per_block_get 0 59425 NULL
99290 +snd_pcm_tstamp_59431 snd_pcm_tstamp 0 59431 NULL
99291 +squashfs_read_data_59440 squashfs_read_data 6 59440 NULL
99292 +fs_path_ensure_buf_59445 fs_path_ensure_buf 2 59445 NULL
99293 +descriptor_loc_59446 descriptor_loc 3 59446 NULL
99294 +do_compat_semctl_59449 do_compat_semctl 4 59449 NULL
99295 +virtqueue_add_buf_59470 virtqueue_add_buf 3-4 59470 NULL
99296 +ib_copy_from_udata_59502 ib_copy_from_udata 3 59502 NULL
99297 +nfsd_nrpools_59503 nfsd_nrpools 0 59503 NULL
99298 +rds_pin_pages_59507 rds_pin_pages 0 59507 NULL
99299 +mpi_get_nbits_59551 mpi_get_nbits 0 59551 NULL
99300 +tunables_write_59563 tunables_write 3 59563 NULL
99301 +memdup_user_59590 memdup_user 2 59590 NULL
99302 +tps6586x_irq_get_virq_59601 tps6586x_irq_get_virq 2 59601 NULL
99303 +mem_fwlog_free_mem_blks_read_59616 mem_fwlog_free_mem_blks_read 3 59616 NULL
99304 +mtrr_write_59622 mtrr_write 3 59622 NULL
99305 +ip_vs_icmp_xmit_59624 ip_vs_icmp_xmit 4 59624 NULL
99306 +find_first_zero_bit_59636 find_first_zero_bit 0-2 59636 NULL
99307 +ubifs_setxattr_59650 ubifs_setxattr 4 59650 NULL nohasharray
99308 +hidraw_read_59650 hidraw_read 3 59650 &ubifs_setxattr_59650
99309 +v9fs_xattr_set_acl_59651 v9fs_xattr_set_acl 4 59651 NULL
99310 +__devcgroup_check_permission_59665 __devcgroup_check_permission 0 59665 NULL
99311 +alloc_dca_provider_59670 alloc_dca_provider 2 59670 NULL
99312 +wm8400_write_59675 wm8400_write 2 59675 NULL
99313 +sriov_enable_59689 sriov_enable 2 59689 NULL
99314 +mic_calc_failure_read_59700 mic_calc_failure_read 3 59700 NULL
99315 +snd_pcm_info_user_59711 snd_pcm_info_user 0 59711 NULL
99316 +prism2_info_scanresults_59729 prism2_info_scanresults 3 59729 NULL
99317 +wm8996_gpio_direction_in_59739 wm8996_gpio_direction_in 2 59739 NULL
99318 +ieee80211_if_read_fwded_unicast_59740 ieee80211_if_read_fwded_unicast 3 59740 NULL
99319 +qib_decode_7220_sdma_errs_59745 qib_decode_7220_sdma_errs 4 59745 NULL
99320 +strnlen_59746 strnlen 0 59746 NULL
99321 +sctp_manip_pkt_59749 sctp_manip_pkt 4 59749 NULL
99322 +ext3_acl_count_59754 ext3_acl_count 0-1 59754 NULL
99323 +long_retry_limit_read_59766 long_retry_limit_read 3 59766 NULL
99324 +sec_reg_update_59771 sec_reg_update 2 59771 NULL
99325 +venus_remove_59781 venus_remove 4 59781 NULL
99326 +xlog_do_recover_59789 xlog_do_recover 3 59789 NULL
99327 +ipw_write_59807 ipw_write 3 59807 NULL
99328 +rtllib_wx_set_gen_ie_59808 rtllib_wx_set_gen_ie 3 59808 NULL
99329 +scsi_init_shared_tag_map_59812 scsi_init_shared_tag_map 2 59812 NULL
99330 +ieee80211_if_read_dot11MeshHWMPmaxPREQretries_59829 ieee80211_if_read_dot11MeshHWMPmaxPREQretries 3 59829 NULL
99331 +gspca_dev_probe2_59833 gspca_dev_probe2 4 59833 NULL
99332 +fs64_to_cpu_59845 fs64_to_cpu 0 59845 NULL
99333 +tun_put_user_59849 tun_put_user 4 59849 NULL
99334 +pvr2_ioread_set_sync_key_59882 pvr2_ioread_set_sync_key 3 59882 NULL
99335 +shmem_zero_setup_59885 shmem_zero_setup 0 59885 NULL
99336 +ffs_prepare_buffer_59892 ffs_prepare_buffer 2 59892 NULL
99337 +il_dbgfs_rxon_flags_read_59950 il_dbgfs_rxon_flags_read 3 59950 NULL nohasharray
99338 +dapm_widget_power_read_file_59950 dapm_widget_power_read_file 3 59950 &il_dbgfs_rxon_flags_read_59950
99339 +il_dbgfs_missed_beacon_read_59956 il_dbgfs_missed_beacon_read 3 59956 NULL nohasharray
99340 +compat_ipmi_ioctl_59956 compat_ipmi_ioctl 3 59956 &il_dbgfs_missed_beacon_read_59956
99341 +fb_getput_cmap_59971 fb_getput_cmap 3 59971 NULL
99342 +__arch_hweight16_59975 __arch_hweight16 0 59975 NULL
99343 +osd_req_read_kern_59990 osd_req_read_kern 5 59990 NULL
99344 +ghash_async_setkey_60001 ghash_async_setkey 3 60001 NULL
99345 +rawsock_sendmsg_60010 rawsock_sendmsg 4 60010 NULL
99346 +mthca_init_cq_60011 mthca_init_cq 2 60011 NULL
99347 +register_device_60015 register_device 2-3 60015 NULL
99348 +osd_req_list_dev_partitions_60027 osd_req_list_dev_partitions 4 60027 NULL
99349 +xlog_bread_offset_60030 xlog_bread_offset 3 60030 NULL
99350 +sys_sched_getaffinity_60033 sys_sched_getaffinity 2 60033 NULL
99351 +ceph_calc_raw_layout_60035 ceph_calc_raw_layout 4 60035 NULL
99352 +bio_integrity_hw_sectors_60039 bio_integrity_hw_sectors 0-2 60039 NULL
99353 +do_ip6t_set_ctl_60040 do_ip6t_set_ctl 4 60040 NULL
99354 +vcs_size_60050 vcs_size 0 60050 NULL nohasharray
99355 +pin_2_irq_60050 pin_2_irq 0-3 60050 &vcs_size_60050
99356 +load_module_60056 load_module 2 60056 NULL nohasharray
99357 +gru_alloc_gts_60056 gru_alloc_gts 3-2 60056 &load_module_60056
99358 +compat_writev_60063 compat_writev 3 60063 NULL
99359 +ieee80211_build_probe_req_60064 ieee80211_build_probe_req 8-6 60064 NULL
99360 +c4iw_num_stags_60073 c4iw_num_stags 0 60073 NULL
99361 +mp_register_gsi_60079 mp_register_gsi 2 60079 NULL
99362 +rxrpc_kernel_send_data_60083 rxrpc_kernel_send_data 3 60083 NULL
99363 +ieee80211_if_fmt_fwded_frames_60103 ieee80211_if_fmt_fwded_frames 3 60103 NULL
99364 +ttm_bo_kmap_60118 ttm_bo_kmap 3-2 60118 NULL
99365 +jmb38x_ms_count_slots_60164 jmb38x_ms_count_slots 0 60164 NULL
99366 +init_state_60165 init_state 2 60165 NULL
99367 +sg_build_sgat_60179 sg_build_sgat 3 60179 NULL nohasharray
99368 +jffs2_alloc_full_dirent_60179 jffs2_alloc_full_dirent 1 60179 &sg_build_sgat_60179
99369 +rx_rx_tkip_replays_read_60193 rx_rx_tkip_replays_read 3 60193 NULL
99370 +svc_compat_ioctl_60194 svc_compat_ioctl 3 60194 NULL
99371 +ib_send_cm_mra_60202 ib_send_cm_mra 4 60202 NULL nohasharray
99372 +qib_reg_phys_mr_60202 qib_reg_phys_mr 3 60202 &ib_send_cm_mra_60202
99373 +set_tap_pfs_60203 set_tap_pfs 3 60203 NULL
99374 +ieee80211_mgmt_tx_60209 ieee80211_mgmt_tx 7 60209 NULL
99375 +btrfs_get_token_16_60220 btrfs_get_token_16 0 60220 NULL
99376 +arizona_map_irq_60230 arizona_map_irq 2 60230 NULL
99377 +lp8788_select_buck_vout_addr_60241 lp8788_select_buck_vout_addr 0 60241 NULL
99378 +wm831x_irq_60254 wm831x_irq 2 60254 NULL
99379 +compat_sys_fcntl64_60256 compat_sys_fcntl64 3 60256 NULL
99380 +printer_write_60276 printer_write 3 60276 NULL
99381 +__pskb_pull_tail_60287 __pskb_pull_tail 2 60287 NULL
99382 +do_xip_mapping_read_60297 do_xip_mapping_read 5 60297 NULL
99383 +getDataLength_60301 getDataLength 0 60301 NULL
99384 +ceph_parse_server_name_60318 ceph_parse_server_name 2 60318 NULL
99385 +__kfifo_from_user_r_60345 __kfifo_from_user_r 3-5 60345 NULL
99386 +dccp_setsockopt_60367 dccp_setsockopt 5 60367 NULL
99387 +ubi_eba_atomic_leb_change_60379 ubi_eba_atomic_leb_change 5 60379 NULL
99388 +mthca_alloc_resize_buf_60394 mthca_alloc_resize_buf 3 60394 NULL
99389 +ocfs2_zero_extend_60396 ocfs2_zero_extend 3 60396 NULL
99390 +driver_names_read_60399 driver_names_read 3 60399 NULL
99391 +simple_alloc_urb_60420 simple_alloc_urb 3 60420 NULL
99392 +excessive_retries_read_60425 excessive_retries_read 3 60425 NULL
99393 +tstats_write_60432 tstats_write 3 60432 NULL nohasharray
99394 +kmalloc_60432 kmalloc 1 60432 &tstats_write_60432
99395 +tipc_buf_acquire_60437 tipc_buf_acquire 1 60437 NULL
99396 +rx_data_60442 rx_data 4 60442 NULL
99397 +tcf_csum_ipv4_igmp_60446 tcf_csum_ipv4_igmp 3 60446 NULL
99398 +crypto_shash_setkey_60483 crypto_shash_setkey 3 60483 NULL
99399 +ath_tx_init_60515 ath_tx_init 2 60515 NULL
99400 +hysdn_sched_rx_60533 hysdn_sched_rx 3 60533 NULL
99401 +v9fs_fid_readn_60544 v9fs_fid_readn 4 60544 NULL
99402 +nonpaging_map_60551 nonpaging_map 4 60551 NULL
99403 +skb_transport_offset_60619 skb_transport_offset 0 60619 NULL
99404 +wl1273_fm_fops_write_60621 wl1273_fm_fops_write 3 60621 NULL
99405 +usb_control_msg_60624 usb_control_msg 0 60624 NULL
99406 +acl_alloc_stack_init_60630 acl_alloc_stack_init 1 60630 NULL
99407 +ubifs_recover_leb_60639 ubifs_recover_leb 3 60639 NULL
99408 +fb_get_fscreeninfo_60640 fb_get_fscreeninfo 3 60640 NULL
99409 +if_sdio_host_to_card_60666 if_sdio_host_to_card 4 60666 NULL
99410 +ieee80211_if_read_dot11MeshConfirmTimeout_60670 ieee80211_if_read_dot11MeshConfirmTimeout 3 60670 NULL
99411 +read_vbt_r10_60679 read_vbt_r10 1 60679 NULL
99412 +init_data_container_60709 init_data_container 1 60709 NULL
99413 +snd_ice1712_ds_read_60754 snd_ice1712_ds_read 0 60754 NULL
99414 +sel_write_checkreqprot_60774 sel_write_checkreqprot 3 60774 NULL
99415 +opticon_write_60775 opticon_write 4 60775 NULL
99416 +acl_alloc_num_60778 acl_alloc_num 1-2 60778 NULL
99417 +snd_pcm_oss_readv3_60792 snd_pcm_oss_readv3 3 60792 NULL
99418 +pwr_tx_with_ps_read_60851 pwr_tx_with_ps_read 3 60851 NULL
99419 +alloc_buf_60864 alloc_buf 3-2 60864 NULL
99420 +alloc_irq_from_60868 alloc_irq_from 1 60868 NULL
99421 +generic_writepages_60871 generic_writepages 0 60871 NULL
99422 +ubifs_read_one_lp_60882 ubifs_read_one_lp 0 60882 NULL
99423 +ext4_update_inline_data_60888 ext4_update_inline_data 3 60888 NULL
99424 +wm8962_gpio_set_60894 wm8962_gpio_set 2 60894 NULL
99425 +iio_debugfs_read_reg_60908 iio_debugfs_read_reg 3 60908 NULL
99426 +mgt_set_varlen_60916 mgt_set_varlen 4 60916 NULL
99427 +scrub_chunk_60926 scrub_chunk 5 60926 NULL
99428 +pti_char_write_60960 pti_char_write 3 60960 NULL
99429 +mwifiex_alloc_sdio_mpa_buffers_60961 mwifiex_alloc_sdio_mpa_buffers 2-3 60961 NULL
99430 +__a2mp_build_60987 __a2mp_build 3 60987 NULL
99431 +hsc_msg_alloc_60990 hsc_msg_alloc 1 60990 NULL
99432 +ath6kl_lrssi_roam_read_61022 ath6kl_lrssi_roam_read 3 61022 NULL
99433 +symtab_init_61050 symtab_init 2 61050 NULL
99434 +fuse_send_write_61053 fuse_send_write 0 61053 NULL
99435 +snd_pcm_pause_61054 snd_pcm_pause 0 61054 NULL
99436 +bitmap_scnlistprintf_61062 bitmap_scnlistprintf 0-4-2 61062 NULL
99437 +ahash_align_buffer_size_61070 ahash_align_buffer_size 0-1-2 61070 NULL
99438 +snd_pcm_update_hw_ptr0_61084 snd_pcm_update_hw_ptr0 0 61084 NULL
99439 +get_derived_key_61100 get_derived_key 4 61100 NULL
99440 +alloc_chrdev_region_61112 alloc_chrdev_region 0 61112 NULL
99441 +p80211_headerlen_61119 p80211_headerlen 0 61119 NULL nohasharray
99442 +__probe_kernel_read_61119 __probe_kernel_read 3 61119 &p80211_headerlen_61119
99443 +vmemmap_alloc_block_buf_61126 vmemmap_alloc_block_buf 1 61126 NULL
99444 +afs_proc_cells_write_61139 afs_proc_cells_write 3 61139 NULL
99445 +__vmalloc_61168 __vmalloc 1 61168 NULL
99446 +event_oom_late_read_61175 event_oom_late_read 3 61175 NULL nohasharray
99447 +pair_device_61175 pair_device 4 61175 &event_oom_late_read_61175
99448 +sys_lsetxattr_61177 sys_lsetxattr 4 61177 NULL
99449 +arch_hibernation_header_save_61212 arch_hibernation_header_save 0 61212 NULL
99450 +smk_read_ambient_61220 smk_read_ambient 3 61220 NULL
99451 +btrfs_bio_alloc_61270 btrfs_bio_alloc 3 61270 NULL
99452 +vortex_adbdma_getlinearpos_61283 vortex_adbdma_getlinearpos 0 61283 NULL
99453 +sys_add_key_61288 sys_add_key 4 61288 NULL
99454 +ext4_issue_discard_61305 ext4_issue_discard 2 61305 NULL
99455 +xfrm_user_sec_ctx_size_61320 xfrm_user_sec_ctx_size 0 61320 NULL
99456 +st5481_setup_isocpipes_61340 st5481_setup_isocpipes 6-4 61340 NULL
99457 +rx_rx_wa_ba_not_expected_read_61341 rx_rx_wa_ba_not_expected_read 3 61341 NULL
99458 +f1x_map_sysaddr_to_csrow_61344 f1x_map_sysaddr_to_csrow 2 61344 NULL
99459 +debug_debug4_read_61367 debug_debug4_read 3 61367 NULL
99460 +sys_ptrace_61369 sys_ptrace 3 61369 NULL
99461 +change_xattr_61390 change_xattr 5 61390 NULL
99462 +size_entry_mwt_61400 size_entry_mwt 0 61400 NULL
99463 +irq_create_of_mapping_61428 irq_create_of_mapping 0 61428 NULL
99464 +dma_ops_area_alloc_61440 dma_ops_area_alloc 3-4-5 61440 NULL
99465 +tc3589x_irq_unmap_61447 tc3589x_irq_unmap 2 61447 NULL
99466 +unix_stream_sendmsg_61455 unix_stream_sendmsg 4 61455 NULL
99467 +snd_pcm_lib_writev_transfer_61483 snd_pcm_lib_writev_transfer 4-2-5 61483 NULL
99468 +btrfs_item_size_61485 btrfs_item_size 0 61485 NULL
99469 +mc13xxx_reg_write_61490 mc13xxx_reg_write 2 61490 NULL
99470 +erst_errno_61526 erst_errno 0 61526 NULL
99471 +ntfs_attr_lookup_61539 ntfs_attr_lookup 0 61539 NULL
99472 +o2hb_pop_count_61553 o2hb_pop_count 2 61553 NULL
99473 +dvb_net_ioctl_61559 dvb_net_ioctl 2 61559 NULL
99474 +ieee80211_if_read_rc_rateidx_mask_2ghz_61570 ieee80211_if_read_rc_rateidx_mask_2ghz 3 61570 NULL
99475 +seq_open_private_61589 seq_open_private 3 61589 NULL
99476 +__get_vm_area_61599 __get_vm_area 1 61599 NULL
99477 +nfs4_init_uniform_client_string_61601 nfs4_init_uniform_client_string 3 61601 NULL
99478 +ncp_compat_ioctl_61608 ncp_compat_ioctl 3 61608 NULL
99479 +configfs_write_file_61621 configfs_write_file 3 61621 NULL
99480 +ieee80211_if_fmt_hw_queues_61629 ieee80211_if_fmt_hw_queues 3 61629 NULL
99481 +ieee80211_rx_bss_info_61630 ieee80211_rx_bss_info 3 61630 NULL
99482 +i2o_parm_table_get_61635 i2o_parm_table_get 6 61635 NULL
99483 +snd_pcm_oss_read3_61643 snd_pcm_oss_read3 0-3 61643 NULL
99484 +resize_stripes_61650 resize_stripes 2 61650 NULL
99485 +ttm_page_pool_free_61661 ttm_page_pool_free 2 61661 NULL
99486 +insert_one_name_61668 insert_one_name 7 61668 NULL
99487 +snd_pcm_playback_avail_61671 snd_pcm_playback_avail 0 61671 NULL
99488 +lock_loop_61681 lock_loop 1 61681 NULL
99489 +__do_tune_cpucache_61684 __do_tune_cpucache 2 61684 NULL
99490 +filter_read_61692 filter_read 3 61692 NULL
99491 +iov_length_61716 iov_length 0 61716 NULL
99492 +fragmentation_threshold_read_61718 fragmentation_threshold_read 3 61718 NULL
99493 +read_file_interrupt_61742 read_file_interrupt 3 61742 NULL nohasharray
99494 +read_file_regval_61742 read_file_regval 3 61742 &read_file_interrupt_61742
99495 +gfs2_meta_wait_61773 gfs2_meta_wait 0 61773 NULL
99496 +batadv_dat_snoop_incoming_arp_reply_61801 batadv_dat_snoop_incoming_arp_reply 3 61801 NULL
99497 +tps80031_irq_init_61830 tps80031_irq_init 3 61830 NULL
99498 +bfad_debugfs_write_regwr_61841 bfad_debugfs_write_regwr 3 61841 NULL
99499 +fs_path_prepare_for_add_61854 fs_path_prepare_for_add 2 61854 NULL
99500 +evdev_compute_buffer_size_61863 evdev_compute_buffer_size 0 61863 NULL
99501 +get_fw_name_61874 get_fw_name 3 61874 NULL
99502 +twl4030_sih_setup_61878 twl4030_sih_setup 3 61878 NULL
99503 +ieee80211_rtl_auth_challenge_61897 ieee80211_rtl_auth_challenge 3 61897 NULL
99504 +ax25_addr_size_61899 ax25_addr_size 0 61899 NULL nohasharray
99505 +cxgb4_pktgl_to_skb_61899 cxgb4_pktgl_to_skb 2 61899 &ax25_addr_size_61899
99506 +clear_refs_write_61904 clear_refs_write 3 61904 NULL
99507 +rx_filter_arp_filter_read_61914 rx_filter_arp_filter_read 3 61914 NULL
99508 +au0828_init_isoc_61917 au0828_init_isoc 3-2 61917 NULL
99509 +sctp_sendmsg_61919 sctp_sendmsg 4 61919 NULL
99510 +send_bulk_static_data_61932 send_bulk_static_data 3 61932 NULL
99511 +il4965_ucode_rx_stats_read_61948 il4965_ucode_rx_stats_read 3 61948 NULL
99512 +squashfs_read_id_index_table_61961 squashfs_read_id_index_table 4 61961 NULL
99513 +mlx4_alloc_mtt_range_61966 mlx4_alloc_mtt_range 2 61966 NULL
99514 +ocfs2_quota_write_61972 ocfs2_quota_write 5-4 61972 NULL
99515 +cow_file_range_61979 cow_file_range 3 61979 NULL
99516 +virtnet_send_command_61993 virtnet_send_command 5-6 61993 NULL
99517 +xt_compat_match_offset_62011 xt_compat_match_offset 0 62011 NULL
99518 +jffs2_do_unlink_62020 jffs2_do_unlink 4 62020 NULL
99519 +pmcraid_build_passthrough_ioadls_62034 pmcraid_build_passthrough_ioadls 2 62034 NULL
99520 +ppp_tx_cp_62044 ppp_tx_cp 5 62044 NULL
99521 +sctp_user_addto_chunk_62047 sctp_user_addto_chunk 2-3 62047 NULL
99522 +do_pselect_62061 do_pselect 1 62061 NULL
99523 +pcpu_alloc_bootmem_62074 pcpu_alloc_bootmem 2 62074 NULL
99524 +__next_gcwq_cpu_62078 __next_gcwq_cpu 1 62078 NULL
99525 +get_domain_for_dev_62099 get_domain_for_dev 2 62099 NULL
99526 +jffs2_security_setxattr_62107 jffs2_security_setxattr 4 62107 NULL
99527 +llc_ui_header_len_62131 llc_ui_header_len 0 62131 NULL
99528 +qib_diag_write_62133 qib_diag_write 3 62133 NULL
99529 +ql_status_62135 ql_status 5 62135 NULL
99530 +video_usercopy_62151 video_usercopy 2 62151 NULL
99531 +prism54_wpa_bss_ie_get_62173 prism54_wpa_bss_ie_get 0 62173 NULL
99532 +_irq_to_addr_62183 _irq_to_addr 0-1 62183 NULL
99533 +alloc_upcall_62186 alloc_upcall 2 62186 NULL
99534 +btrfs_xattr_acl_set_62203 btrfs_xattr_acl_set 4 62203 NULL
99535 +sock_kmalloc_62205 sock_kmalloc 2 62205 NULL
99536 +nfsd_read_file_62241 nfsd_read_file 6 62241 NULL
99537 +allocate_partition_62245 allocate_partition 4 62245 NULL
99538 +il_dbgfs_sram_read_62296 il_dbgfs_sram_read 3 62296 NULL
99539 +sparse_early_usemaps_alloc_pgdat_section_62304 sparse_early_usemaps_alloc_pgdat_section 2 62304 NULL
99540 +subsystem_filter_read_62310 subsystem_filter_read 3 62310 NULL
99541 +udf_sb_alloc_partition_maps_62313 udf_sb_alloc_partition_maps 2 62313 NULL
99542 +Wb35Reg_BurstWrite_62327 Wb35Reg_BurstWrite 4 62327 NULL
99543 +subseq_list_62332 subseq_list 3-0 62332 NULL
99544 +flash_write_62354 flash_write 3 62354 NULL
99545 +set_wd_exp_mode_pfs_62372 set_wd_exp_mode_pfs 3 62372 NULL
99546 +rx_rx_timeout_read_62389 rx_rx_timeout_read 3 62389 NULL
99547 +altera_irscan_62396 altera_irscan 2 62396 NULL
99548 +set_ssp_62411 set_ssp 4 62411 NULL
99549 +tscadc_writel_62426 tscadc_writel 2 62426 NULL
99550 +netdev_alloc_skb_62437 netdev_alloc_skb 2 62437 NULL
99551 +e1000_check_copybreak_62448 e1000_check_copybreak 3 62448 NULL
99552 +ip_vs_icmp_xmit_v6_62477 ip_vs_icmp_xmit_v6 4 62477 NULL
99553 +ceph_dns_resolve_name_62488 ceph_dns_resolve_name 2 62488 NULL
99554 +mlx4_en_create_rx_ring_62498 mlx4_en_create_rx_ring 3 62498 NULL
99555 +ext_rts51x_sd_execute_read_data_62501 ext_rts51x_sd_execute_read_data 9 62501 NULL
99556 +pep_sendmsg_62524 pep_sendmsg 4 62524 NULL
99557 +test_iso_queue_62534 test_iso_queue 5 62534 NULL
99558 +debugfs_read_62535 debugfs_read 3 62535 NULL
99559 +sco_sock_sendmsg_62542 sco_sock_sendmsg 4 62542 NULL
99560 +qib_refresh_qsfp_cache_62547 qib_refresh_qsfp_cache 0 62547 NULL
99561 +xfrm_user_policy_62573 xfrm_user_policy 4 62573 NULL
99562 +get_subdir_62581 get_subdir 3 62581 NULL
99563 +prism2_send_mgmt_62605 prism2_send_mgmt 4 62605 NULL nohasharray
99564 +nfsd_vfs_read_62605 nfsd_vfs_read 6 62605 &prism2_send_mgmt_62605
99565 +get_desc_base_62617 get_desc_base 0 62617 NULL
99566 +iommu_area_alloc_62619 iommu_area_alloc 2-3-4-7 62619 NULL
99567 +ems_pcmcia_add_card_62627 ems_pcmcia_add_card 2 62627 NULL
99568 +compat_rangeinfo_62630 compat_rangeinfo 2 62630 NULL
99569 +lpfc_sli4_queue_alloc_62646 lpfc_sli4_queue_alloc 3 62646 NULL
99570 +wm8994_gpio_direction_in_62649 wm8994_gpio_direction_in 2 62649 NULL
99571 +ima_file_mmap_62663 ima_file_mmap 0 62663 NULL
99572 +write_62671 write 3 62671 NULL
99573 +printer_req_alloc_62687 printer_req_alloc 2 62687 NULL
99574 +qla4_83xx_rd_reg_62693 qla4_83xx_rd_reg 0 62693 NULL
99575 +ioremap_wc_62695 ioremap_wc 1-2 62695 NULL
99576 +bioset_integrity_create_62708 bioset_integrity_create 2 62708 NULL
99577 +rdm_62719 rdm 0 62719 NULL
99578 +key_replays_read_62746 key_replays_read 3 62746 NULL
99579 +init_chip_wc_pat_62768 init_chip_wc_pat 2 62768 NULL
99580 +ax25_sendmsg_62770 ax25_sendmsg 4 62770 NULL
99581 +page_key_alloc_62771 page_key_alloc 0 62771 NULL
99582 +tracing_total_entries_read_62817 tracing_total_entries_read 3 62817 NULL
99583 +__rounddown_pow_of_two_62836 __rounddown_pow_of_two 0 62836 NULL
99584 +bio_get_nr_vecs_62838 bio_get_nr_vecs 0 62838 NULL
99585 +xlog_recover_add_to_trans_62839 xlog_recover_add_to_trans 4 62839 NULL
99586 +rx_fcs_err_read_62844 rx_fcs_err_read 3 62844 NULL
99587 +hpi_read_word_62862 hpi_read_word 0 62862 NULL
99588 +em28xx_init_isoc_62883 em28xx_init_isoc 4 62883 NULL nohasharray
99589 +aoechr_write_62883 aoechr_write 3 62883 &em28xx_init_isoc_62883
99590 +resize_info_buffer_62889 resize_info_buffer 2 62889 NULL
99591 +if_spi_host_to_card_62890 if_spi_host_to_card 4 62890 NULL
99592 +mempool_create_slab_pool_62907 mempool_create_slab_pool 1 62907 NULL
99593 +getdqbuf_62908 getdqbuf 1 62908 NULL
99594 +agp_create_user_memory_62955 agp_create_user_memory 1 62955 NULL
99595 +PTR_ERR_63033 PTR_ERR 0 63033 NULL nohasharray
99596 +__vb2_perform_fileio_63033 __vb2_perform_fileio 3 63033 &PTR_ERR_63033
99597 +pipeline_defrag_to_csum_swi_read_63037 pipeline_defrag_to_csum_swi_read 3 63037 NULL
99598 +scsi_host_alloc_63041 scsi_host_alloc 2 63041 NULL
99599 +unlink1_63059 unlink1 3 63059 NULL
99600 +xen_set_nslabs_63066 xen_set_nslabs 0 63066 NULL
99601 +ocfs2_decrease_refcount_63078 ocfs2_decrease_refcount 3 63078 NULL
99602 +sep_prepare_input_output_dma_table_in_dcb_63087 sep_prepare_input_output_dma_table_in_dcb 4-5-2-3 63087 NULL
99603 +iwl_dbgfs_sensitivity_read_63116 iwl_dbgfs_sensitivity_read 3 63116 NULL
99604 +ib_send_cm_rtu_63138 ib_send_cm_rtu 3 63138 NULL
99605 +snd_pcm_status_user_63140 snd_pcm_status_user 0 63140 NULL
99606 +ubifs_change_one_lp_63157 ubifs_change_one_lp 0 63157 NULL
99607 +smk_write_revoke_subj_63173 smk_write_revoke_subj 3 63173 NULL
99608 +vme_master_read_63221 vme_master_read 0 63221 NULL
99609 +module_alloc_update_bounds_rw_63233 module_alloc_update_bounds_rw 1 63233 NULL
99610 +ptp_read_63251 ptp_read 4 63251 NULL
99611 +ntfs_attr_can_be_non_resident_63267 ntfs_attr_can_be_non_resident 0 63267 NULL
99612 +raid5_resize_63306 raid5_resize 2 63306 NULL
99613 +proc_info_read_63344 proc_info_read 3 63344 NULL
99614 +ps_upsd_max_sptime_read_63362 ps_upsd_max_sptime_read 3 63362 NULL
99615 +idmouse_read_63374 idmouse_read 3 63374 NULL
99616 +edac_pci_alloc_ctl_info_63388 edac_pci_alloc_ctl_info 1 63388 NULL nohasharray
99617 +usbnet_read_cmd_nopm_63388 usbnet_read_cmd_nopm 7 63388 &edac_pci_alloc_ctl_info_63388
99618 +rxpipe_missed_beacon_host_int_trig_rx_data_read_63405 rxpipe_missed_beacon_host_int_trig_rx_data_read 3 63405 NULL
99619 +l2cap_sock_sendmsg_63427 l2cap_sock_sendmsg 4 63427 NULL
99620 +sep_prepare_input_output_dma_table_63429 sep_prepare_input_output_dma_table 2-4-3 63429 NULL
99621 +kone_send_63435 kone_send 4 63435 NULL
99622 +nfsd_symlink_63442 nfsd_symlink 6 63442 NULL
99623 +snd_info_entry_write_63474 snd_info_entry_write 3 63474 NULL
99624 +reada_find_extent_63486 reada_find_extent 2 63486 NULL
99625 +read_kcore_63488 read_kcore 3 63488 NULL
99626 +snd_pcm_plug_write_transfer_63503 snd_pcm_plug_write_transfer 0-3 63503 NULL
99627 +ubi_more_leb_change_data_63534 ubi_more_leb_change_data 4 63534 NULL
99628 +if_sdio_read_scratch_63540 if_sdio_read_scratch 0 63540 NULL
99629 +append_to_buffer_63550 append_to_buffer 3 63550 NULL
99630 +dbg_leb_write_63555 dbg_leb_write 4-5 63555 NULL nohasharray
99631 +kvm_write_guest_page_63555 kvm_write_guest_page 5 63555 &dbg_leb_write_63555
99632 +ubifs_lpt_scan_nolock_63572 ubifs_lpt_scan_nolock 0 63572 NULL
99633 +ocfs2_calc_trunc_pos_63576 ocfs2_calc_trunc_pos 4 63576 NULL
99634 +rproc_alloc_63577 rproc_alloc 5 63577 NULL
99635 +ext3_clear_blocks_63597 ext3_clear_blocks 4-5 63597 NULL
99636 +ntfs_malloc_nofs_nofail_63631 ntfs_malloc_nofs_nofail 1 63631 NULL
99637 +symbol_build_supp_rates_63634 symbol_build_supp_rates 0 63634 NULL
99638 +_ubh_find_next_zero_bit__63640 _ubh_find_next_zero_bit_ 4-5-3 63640 NULL
99639 +proc_loginuid_write_63648 proc_loginuid_write 3 63648 NULL
99640 +ValidateDSDParamsChecksum_63654 ValidateDSDParamsChecksum 3 63654 NULL
99641 +hidraw_ioctl_63658 hidraw_ioctl 2 63658 NULL
99642 +vbi_read_63673 vbi_read 3 63673 NULL nohasharray
99643 +xen_register_pirq_63673 xen_register_pirq 1-2 63673 &vbi_read_63673
99644 +alloc_tty_driver_63681 alloc_tty_driver 1 63681 NULL
99645 +mkiss_compat_ioctl_63686 mkiss_compat_ioctl 4 63686 NULL
99646 +arizona_irq_map_63709 arizona_irq_map 2 63709 NULL
99647 +nouveau_object_create__63715 nouveau_object_create_ 5 63715 NULL
99648 +btrfs_insert_delayed_dir_index_63720 btrfs_insert_delayed_dir_index 4 63720 NULL
99649 +selinux_secctx_to_secid_63744 selinux_secctx_to_secid 2 63744 NULL
99650 +snd_pcm_oss_read1_63771 snd_pcm_oss_read1 3 63771 NULL
99651 +snd_pcm_link_63772 snd_pcm_link 0 63772 NULL
99652 +snd_opl4_mem_proc_read_63774 snd_opl4_mem_proc_read 5 63774 NULL
99653 +spidev_compat_ioctl_63778 spidev_compat_ioctl 2-3 63778 NULL
99654 +snapshot_compat_ioctl_63792 snapshot_compat_ioctl 3 63792 NULL
99655 +kovaplus_sysfs_write_63795 kovaplus_sysfs_write 6 63795 NULL
99656 +mwifiex_11n_create_rx_reorder_tbl_63806 mwifiex_11n_create_rx_reorder_tbl 4 63806 NULL
99657 +copy_nodes_to_user_63807 copy_nodes_to_user 2 63807 NULL
99658 +sel_write_load_63830 sel_write_load 3 63830 NULL
99659 +proc_pid_attr_write_63845 proc_pid_attr_write 3 63845 NULL
99660 +ieee80211_if_fmt_channel_type_63855 ieee80211_if_fmt_channel_type 3 63855 NULL
99661 +init_map_ipmac_63896 init_map_ipmac 4-3 63896 NULL
99662 +divas_write_63901 divas_write 3 63901 NULL
99663 +xhci_alloc_stream_info_63902 xhci_alloc_stream_info 3 63902 NULL
99664 +uvc_alloc_urb_buffers_63922 uvc_alloc_urb_buffers 0-3-2 63922 NULL
99665 +snd_compr_write_63923 snd_compr_write 3 63923 NULL
99666 +acpi_ev_get_gpe_xrupt_block_63924 acpi_ev_get_gpe_xrupt_block 1 63924 NULL
99667 +tipc_send2port_63935 tipc_send2port 5 63935 NULL
99668 +afs_send_simple_reply_63940 afs_send_simple_reply 3 63940 NULL
99669 +__team_options_register_63941 __team_options_register 3 63941 NULL
99670 +macvtap_recvmsg_63949 macvtap_recvmsg 4 63949 NULL
99671 +ieee80211_if_fmt_rc_rateidx_mcs_mask_2ghz_63968 ieee80211_if_fmt_rc_rateidx_mcs_mask_2ghz 3 63968 NULL
99672 +ieee80211_authentication_req_63973 ieee80211_authentication_req 3 63973 NULL
99673 +diva_xdi_write_63975 diva_xdi_write 4 63975 NULL
99674 +read_file_frameerrors_64001 read_file_frameerrors 3 64001 NULL
99675 +kmemdup_64015 kmemdup 2 64015 NULL
99676 +tcf_csum_skb_nextlayer_64025 tcf_csum_skb_nextlayer 3 64025 NULL
99677 +dbAllocDmapLev_64030 dbAllocDmapLev 0 64030 NULL
99678 +resize_async_buffer_64031 resize_async_buffer 4 64031 NULL
99679 +sep_lli_table_secure_dma_64042 sep_lli_table_secure_dma 2-3 64042 NULL
99680 +get_u8_64076 get_u8 0 64076 NULL
99681 +sl_realloc_bufs_64086 sl_realloc_bufs 2 64086 NULL
99682 +lbs_highrssi_read_64089 lbs_highrssi_read 3 64089 NULL
99683 +do_load_xattr_datum_64118 do_load_xattr_datum 0 64118 NULL
99684 +ol_quota_entries_per_block_64122 ol_quota_entries_per_block 0 64122 NULL
99685 +ext4_prepare_inline_data_64124 ext4_prepare_inline_data 3 64124 NULL
99686 +init_bch_64130 init_bch 1-2 64130 NULL
99687 +uea_idma_write_64139 uea_idma_write 3 64139 NULL
99688 +ablkcipher_copy_iv_64140 ablkcipher_copy_iv 3 64140 NULL
99689 +dlfb_ops_write_64150 dlfb_ops_write 3 64150 NULL
99690 +cpumask_scnprintf_64170 cpumask_scnprintf 2 64170 NULL
99691 +read_pulse_64227 read_pulse 0-3 64227 NULL
99692 +header_len_64232 header_len 0 64232 NULL
99693 +redrat3_transmit_ir_64244 redrat3_transmit_ir 3 64244 NULL
99694 +io_capture_transfer_64276 io_capture_transfer 4 64276 NULL
99695 +btrfs_file_extent_offset_64278 btrfs_file_extent_offset 0 64278 NULL
99696 +sta_current_tx_rate_read_64286 sta_current_tx_rate_read 3 64286 NULL
99697 +event_id_read_64288 event_id_read 3 64288 NULL nohasharray
99698 +xfs_dir_cilookup_result_64288 xfs_dir_cilookup_result 3 64288 &event_id_read_64288
99699 +ocfs2_block_check_validate_bhs_64302 ocfs2_block_check_validate_bhs 0 64302 NULL
99700 +error_error_bar_retry_read_64305 error_error_bar_retry_read 3 64305 NULL
99701 +ffz_64324 ffz 0 64324 NULL
99702 +sisusbcon_clear_64329 sisusbcon_clear 4-3-5 64329 NULL
99703 +ts_write_64336 ts_write 3 64336 NULL
99704 +usbtmc_write_64340 usbtmc_write 3 64340 NULL
99705 +do_write_orph_node_64343 do_write_orph_node 2 64343 NULL
99706 +ft1000_read_reg_64352 ft1000_read_reg 0 64352 NULL
99707 +wlc_phy_loadsampletable_nphy_64367 wlc_phy_loadsampletable_nphy 3 64367 NULL
99708 +ilo_write_64378 ilo_write 3 64378 NULL
99709 +btrfs_map_block_64379 btrfs_map_block 3 64379 NULL
99710 +nilfs_alloc_seg_bio_64383 nilfs_alloc_seg_bio 3 64383 NULL
99711 +ir_lirc_transmit_ir_64403 ir_lirc_transmit_ir 3 64403 NULL
99712 +pidlist_allocate_64404 pidlist_allocate 1 64404 NULL
99713 +rx_hdr_overflow_read_64407 rx_hdr_overflow_read 3 64407 NULL
99714 +snd_card_create_64418 snd_card_create 4 64418 NULL nohasharray
99715 +keyctl_get_security_64418 keyctl_get_security 3 64418 &snd_card_create_64418
99716 +nl80211_send_mgmt_64419 nl80211_send_mgmt 7 64419 NULL
99717 +oom_adj_write_64428 oom_adj_write 3 64428 NULL
99718 +ext4_trim_extent_64431 ext4_trim_extent 4 64431 NULL
99719 +ieee80211_ie_build_ht_cap_64443 ieee80211_ie_build_ht_cap 0 64443 NULL
99720 +cap_capable_64462 cap_capable 0 64462 NULL
99721 +ip_vs_create_timeout_table_64478 ip_vs_create_timeout_table 2 64478 NULL
99722 +p54_parse_rssical_64493 p54_parse_rssical 3 64493 NULL
99723 +msg_data_sz_64503 msg_data_sz 0 64503 NULL
99724 +remove_uuid_64505 remove_uuid 4 64505 NULL
99725 +crypto_blkcipher_alignmask_64520 crypto_blkcipher_alignmask 0 64520 NULL
99726 +opera1_usb_i2c_msgxfer_64521 opera1_usb_i2c_msgxfer 4 64521 NULL
99727 +ses_send_diag_64527 ses_send_diag 4 64527 NULL
99728 +prctl_set_mm_64538 prctl_set_mm 3 64538 NULL
99729 +__spi_sync_64561 __spi_sync 0 64561 NULL
99730 +__apei_exec_run_64563 __apei_exec_run 0 64563 NULL
99731 +fanotify_write_64623 fanotify_write 3 64623 NULL
99732 +regmap_read_debugfs_64658 regmap_read_debugfs 5 64658 NULL
99733 +ocfs2_read_xattr_block_64661 ocfs2_read_xattr_block 0 64661 NULL nohasharray
99734 +tlbflush_read_file_64661 tlbflush_read_file 3 64661 &ocfs2_read_xattr_block_64661
99735 +efx_tsoh_get_buffer_64664 efx_tsoh_get_buffer 3 64664 NULL
99736 +rx_rx_out_of_mpdu_nodes_read_64668 rx_rx_out_of_mpdu_nodes_read 3 64668 NULL
99737 +nr_free_zone_pages_64680 nr_free_zone_pages 0 64680 NULL
99738 +sec_bulk_write_64691 sec_bulk_write 2-3 64691 NULL
99739 +__feat_register_sp_64712 __feat_register_sp 6 64712 NULL
99740 +snd_pcm_oss_capture_position_fixup_64713 snd_pcm_oss_capture_position_fixup 0 64713 NULL
99741 +dapm_bias_read_file_64715 dapm_bias_read_file 3 64715 NULL
99742 +atomic_add_return_64720 atomic_add_return 0-1 64720 NULL
99743 +i2400m_msg_to_dev_64722 i2400m_msg_to_dev 3 64722 NULL
99744 +squashfs_read_inode_lookup_table_64739 squashfs_read_inode_lookup_table 4 64739 NULL
99745 +bio_map_kern_64751 bio_map_kern 3 64751 NULL
99746 +rt2x00debug_write_csr_64753 rt2x00debug_write_csr 3 64753 NULL
99747 +isr_low_rssi_read_64789 isr_low_rssi_read 3 64789 NULL
99748 +twl6040_reg_write_64790 twl6040_reg_write 2 64790 NULL
99749 +nfsctl_transaction_write_64800 nfsctl_transaction_write 3 64800 NULL
99750 +megaraid_change_queue_depth_64815 megaraid_change_queue_depth 2 64815 NULL
99751 +ecryptfs_send_miscdev_64816 ecryptfs_send_miscdev 2 64816 NULL
99752 +do_kimage_alloc_64827 do_kimage_alloc 3 64827 NULL
99753 +altera_set_dr_pre_64862 altera_set_dr_pre 2 64862 NULL
99754 +ffs_epfile_io_64886 ffs_epfile_io 3 64886 NULL
99755 +ieee80211_if_read_ave_beacon_64924 ieee80211_if_read_ave_beacon 3 64924 NULL
99756 +ubifs_wbuf_write_nolock_64946 ubifs_wbuf_write_nolock 3 64946 NULL
99757 +snd_rawmidi_ioctl_compat_64954 snd_rawmidi_ioctl_compat 3 64954 NULL
99758 +ip_options_get_from_user_64958 ip_options_get_from_user 4 64958 NULL
99759 +acpi_os_install_interrupt_handler_64968 acpi_os_install_interrupt_handler 1 64968 NULL
99760 +traceprobe_probes_write_64969 traceprobe_probes_write 3 64969 NULL
99761 +suspend_dtim_interval_read_64971 suspend_dtim_interval_read 3 64971 NULL
99762 +ext2_group_first_block_no_64972 ext2_group_first_block_no 0-2 64972 NULL
99763 +pskb_pull_65005 pskb_pull 2 65005 NULL
99764 +unifi_write_65012 unifi_write 3 65012 NULL
99765 +crypto_ahash_digestsize_65014 crypto_ahash_digestsize 0 65014 NULL
99766 +nfs_readdata_alloc_65015 nfs_readdata_alloc 2 65015 NULL
99767 +insert_dent_65034 insert_dent 7 65034 NULL
99768 +compat_put_ushort_65040 compat_put_ushort 1 65040 NULL
99769 +brcmf_sdcard_rwdata_65041 brcmf_sdcard_rwdata 5 65041 NULL
99770 +compat_cmdtest_65064 compat_cmdtest 2 65064 NULL
99771 +make_idx_node_65068 make_idx_node 0 65068 NULL
99772 +count_run_65072 count_run 0-2-4 65072 NULL nohasharray
99773 +bnx2fc_process_l2_frame_compl_65072 bnx2fc_process_l2_frame_compl 3 65072 &count_run_65072
99774 +__alloc_bootmem_node_high_65076 __alloc_bootmem_node_high 2 65076 NULL
99775 +ocfs2_truncate_cluster_pages_65086 ocfs2_truncate_cluster_pages 2 65086 NULL
99776 +ath9k_dump_mci_btcoex_65090 ath9k_dump_mci_btcoex 0 65090 NULL
99777 +ssb_bus_register_65183 ssb_bus_register 3 65183 NULL
99778 +rx_rx_done_read_65217 rx_rx_done_read 3 65217 NULL
99779 +print_endpoint_stat_65232 print_endpoint_stat 0-4-3 65232 NULL
99780 +whci_n_caps_65247 whci_n_caps 0 65247 NULL
99781 +kmem_zalloc_greedy_65268 kmem_zalloc_greedy 3-2 65268 NULL
99782 +kmalloc_parameter_65279 kmalloc_parameter 1 65279 NULL
99783 +compat_core_sys_select_65285 compat_core_sys_select 1 65285 NULL
99784 +get_unaligned_le16_65293 get_unaligned_le16 0 65293 NULL
99785 +mpi_set_buffer_65294 mpi_set_buffer 3 65294 NULL
99786 +redirected_tty_write_65297 redirected_tty_write 3 65297 NULL
99787 +get_var_len_65304 get_var_len 0 65304 NULL
99788 +unpack_array_65318 unpack_array 0 65318 NULL
99789 +pci_vpd_find_tag_65325 pci_vpd_find_tag 0-2 65325 NULL
99790 +dccp_setsockopt_service_65336 dccp_setsockopt_service 4 65336 NULL
99791 +dma_rx_requested_read_65354 dma_rx_requested_read 3 65354 NULL
99792 +batadv_tt_save_orig_buffer_65361 batadv_tt_save_orig_buffer 4 65361 NULL
99793 +alloc_cpu_rmap_65363 alloc_cpu_rmap 1 65363 NULL
99794 +strchr_65372 strchr 0 65372 NULL
99795 +__alloc_bootmem_nopanic_65397 __alloc_bootmem_nopanic 1 65397 NULL
99796 +trace_seq_to_user_65398 trace_seq_to_user 3 65398 NULL
99797 +mtd_get_device_size_65400 mtd_get_device_size 0 65400 NULL
99798 +iio_device_add_channel_sysfs_65406 iio_device_add_channel_sysfs 0 65406 NULL
99799 +ocfs2_write_begin_nolock_65410 ocfs2_write_begin_nolock 3-4 65410 NULL
99800 +drm_calloc_large_65421 drm_calloc_large 1-2 65421 NULL
99801 +xpc_kzalloc_cacheline_aligned_65433 xpc_kzalloc_cacheline_aligned 1 65433 NULL
99802 +pn533_init_target_frame_65438 pn533_init_target_frame 3 65438 NULL
99803 +usb_alloc_coherent_65444 usb_alloc_coherent 2 65444 NULL
99804 +regmap_write_65478 regmap_write 2 65478 NULL
99805 +ath_rx_edma_init_65483 ath_rx_edma_init 2 65483 NULL
99806 +dpcm_state_read_file_65489 dpcm_state_read_file 3 65489 NULL
99807 +alloc_dr_65495 alloc_dr 2 65495 NULL
99808 diff --git a/tools/gcc/size_overflow_plugin.c b/tools/gcc/size_overflow_plugin.c
99809 new file mode 100644
99810 index 0000000..63c46e5
99811 --- /dev/null
99812 +++ b/tools/gcc/size_overflow_plugin.c
99813 @@ -0,0 +1,2050 @@
99814 +/*
99815 + * Copyright 2011, 2012 by Emese Revfy <re.emese@gmail.com>
99816 + * Licensed under the GPL v2, or (at your option) v3
99817 + *
99818 + * Homepage:
99819 + * http://www.grsecurity.net/~ephox/overflow_plugin/
99820 + *
99821 + * This plugin recomputes expressions of function arguments marked by a size_overflow attribute
99822 + * with double integer precision (DImode/TImode for 32/64 bit integer types).
99823 + * The recomputed argument is checked against TYPE_MAX and an event is logged on overflow and the triggering process is killed.
99824 + *
99825 + * Usage:
99826 + * $ 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
99827 + * $ gcc -fplugin=size_overflow_plugin.so test.c -O2
99828 + */
99829 +
99830 +#include "gcc-plugin.h"
99831 +#include "config.h"
99832 +#include "system.h"
99833 +#include "coretypes.h"
99834 +#include "tree.h"
99835 +#include "tree-pass.h"
99836 +#include "intl.h"
99837 +#include "plugin-version.h"
99838 +#include "tm.h"
99839 +#include "toplev.h"
99840 +#include "function.h"
99841 +#include "tree-flow.h"
99842 +#include "plugin.h"
99843 +#include "gimple.h"
99844 +#include "diagnostic.h"
99845 +#include "cfgloop.h"
99846 +
99847 +#if BUILDING_GCC_VERSION >= 4008
99848 +#define TODO_dump_func 0
99849 +#endif
99850 +
99851 +struct size_overflow_hash {
99852 + const struct size_overflow_hash * const next;
99853 + const char * const name;
99854 + const unsigned int param;
99855 +};
99856 +
99857 +#include "size_overflow_hash.h"
99858 +
99859 +enum mark {
99860 + MARK_NO, MARK_YES, MARK_NOT_INTENTIONAL, MARK_TURN_OFF
99861 +};
99862 +
99863 +enum err_code_conditions {
99864 + CAST_ONLY, FROM_CONST
99865 +};
99866 +
99867 +static unsigned int call_count = 0;
99868 +
99869 +#define __unused __attribute__((__unused__))
99870 +#define NAME(node) IDENTIFIER_POINTER(DECL_NAME(node))
99871 +#define NAME_LEN(node) IDENTIFIER_LENGTH(DECL_NAME(node))
99872 +#define BEFORE_STMT true
99873 +#define AFTER_STMT false
99874 +#define CREATE_NEW_VAR NULL_TREE
99875 +#define CODES_LIMIT 32
99876 +#define MAX_PARAM 31
99877 +#define MY_STMT GF_PLF_1
99878 +#define NO_CAST_CHECK GF_PLF_2
99879 +#define FROM_ARG true
99880 +#define FROM_RET false
99881 +
99882 +#if BUILDING_GCC_VERSION == 4005
99883 +#define DECL_CHAIN(NODE) (TREE_CHAIN(DECL_MINIMAL_CHECK(NODE)))
99884 +#endif
99885 +
99886 +int plugin_is_GPL_compatible;
99887 +void debug_gimple_stmt(gimple gs);
99888 +
99889 +static tree expand(struct pointer_set_t *visited, tree lhs);
99890 +static enum mark pre_expand(struct pointer_set_t *visited, bool *search_err_code, const_tree lhs);
99891 +static tree report_size_overflow_decl;
99892 +static const_tree const_char_ptr_type_node;
99893 +static unsigned int handle_function(void);
99894 +static void check_size_overflow(gimple stmt, tree size_overflow_type, tree cast_rhs, tree rhs, bool before);
99895 +static tree get_size_overflow_type(gimple stmt, const_tree node);
99896 +static tree dup_assign(struct pointer_set_t *visited, gimple oldstmt, const_tree node, tree rhs1, tree rhs2, tree __unused rhs3);
99897 +static void print_missing_msg(tree func, unsigned int argnum);
99898 +
99899 +static struct plugin_info size_overflow_plugin_info = {
99900 + .version = "20130316beta",
99901 + .help = "no-size-overflow\tturn off size overflow checking\n",
99902 +};
99903 +
99904 +static tree handle_size_overflow_attribute(tree *node, tree __unused name, tree args, int __unused flags, bool *no_add_attrs)
99905 +{
99906 + unsigned int arg_count;
99907 + enum tree_code code = TREE_CODE(*node);
99908 +
99909 + switch (code) {
99910 + case FUNCTION_DECL:
99911 + arg_count = type_num_arguments(TREE_TYPE(*node));
99912 + break;
99913 + case FUNCTION_TYPE:
99914 + case METHOD_TYPE:
99915 + arg_count = type_num_arguments(*node);
99916 + break;
99917 + default:
99918 + *no_add_attrs = true;
99919 + error("%s: %qE attribute only applies to functions", __func__, name);
99920 + return NULL_TREE;
99921 + }
99922 +
99923 + for (; args; args = TREE_CHAIN(args)) {
99924 + tree position = TREE_VALUE(args);
99925 + if (TREE_CODE(position) != INTEGER_CST || TREE_INT_CST_LOW(position) > arg_count ) {
99926 + error("%s: parameter %u is outside range.", __func__, (unsigned int)TREE_INT_CST_LOW(position));
99927 + *no_add_attrs = true;
99928 + }
99929 + }
99930 + return NULL_TREE;
99931 +}
99932 +
99933 +static const char* get_asm_name(tree node)
99934 +{
99935 + return IDENTIFIER_POINTER(DECL_ASSEMBLER_NAME(node));
99936 +}
99937 +
99938 +static tree handle_intentional_overflow_attribute(tree *node, tree __unused name, tree args, int __unused flags, bool *no_add_attrs)
99939 +{
99940 + unsigned int arg_count, arg_num;
99941 + enum tree_code code = TREE_CODE(*node);
99942 +
99943 + switch (code) {
99944 + case FUNCTION_DECL:
99945 + arg_count = type_num_arguments(TREE_TYPE(*node));
99946 + break;
99947 + case FUNCTION_TYPE:
99948 + case METHOD_TYPE:
99949 + arg_count = type_num_arguments(*node);
99950 + break;
99951 + case FIELD_DECL:
99952 + arg_num = TREE_INT_CST_LOW(TREE_VALUE(args));
99953 + if (arg_num != 0) {
99954 + *no_add_attrs = true;
99955 + error("%s: %qE attribute parameter can only be 0 in structure fields", __func__, name);
99956 + }
99957 + return NULL_TREE;
99958 + default:
99959 + *no_add_attrs = true;
99960 + error("%qE attribute only applies to functions", name);
99961 + return NULL_TREE;
99962 + }
99963 +
99964 + if (TREE_INT_CST_HIGH(TREE_VALUE(args)) != 0)
99965 + return NULL_TREE;
99966 +
99967 + for (; args; args = TREE_CHAIN(args)) {
99968 + tree position = TREE_VALUE(args);
99969 + if (TREE_CODE(position) != INTEGER_CST || TREE_INT_CST_LOW(position) > arg_count ) {
99970 + error("%s: parameter %u is outside range.", __func__, (unsigned int)TREE_INT_CST_LOW(position));
99971 + *no_add_attrs = true;
99972 + }
99973 + }
99974 + return NULL_TREE;
99975 +}
99976 +
99977 +static struct attribute_spec size_overflow_attr = {
99978 + .name = "size_overflow",
99979 + .min_length = 1,
99980 + .max_length = -1,
99981 + .decl_required = true,
99982 + .type_required = false,
99983 + .function_type_required = false,
99984 + .handler = handle_size_overflow_attribute,
99985 +#if BUILDING_GCC_VERSION >= 4007
99986 + .affects_type_identity = false
99987 +#endif
99988 +};
99989 +
99990 +static struct attribute_spec intentional_overflow_attr = {
99991 + .name = "intentional_overflow",
99992 + .min_length = 1,
99993 + .max_length = -1,
99994 + .decl_required = true,
99995 + .type_required = false,
99996 + .function_type_required = false,
99997 + .handler = handle_intentional_overflow_attribute,
99998 +#if BUILDING_GCC_VERSION >= 4007
99999 + .affects_type_identity = false
100000 +#endif
100001 +};
100002 +
100003 +static void register_attributes(void __unused *event_data, void __unused *data)
100004 +{
100005 + register_attribute(&size_overflow_attr);
100006 + register_attribute(&intentional_overflow_attr);
100007 +}
100008 +
100009 +// http://www.team5150.com/~andrew/noncryptohashzoo2~/CrapWow.html
100010 +static unsigned int CrapWow(const char *key, unsigned int len, unsigned int seed)
100011 +{
100012 +#define cwfold( a, b, lo, hi ) { p = (unsigned int)(a) * (unsigned long long)(b); lo ^= (unsigned int)p; hi ^= (unsigned int)(p >> 32); }
100013 +#define cwmixa( in ) { cwfold( in, m, k, h ); }
100014 +#define cwmixb( in ) { cwfold( in, n, h, k ); }
100015 +
100016 + unsigned int m = 0x57559429;
100017 + unsigned int n = 0x5052acdb;
100018 + const unsigned int *key4 = (const unsigned int *)key;
100019 + unsigned int h = len;
100020 + unsigned int k = len + seed + n;
100021 + unsigned long long p;
100022 +
100023 + while (len >= 8) {
100024 + cwmixb(key4[0]) cwmixa(key4[1]) key4 += 2;
100025 + len -= 8;
100026 + }
100027 + if (len >= 4) {
100028 + cwmixb(key4[0]) key4 += 1;
100029 + len -= 4;
100030 + }
100031 + if (len)
100032 + cwmixa(key4[0] & ((1 << (len * 8)) - 1 ));
100033 + cwmixb(h ^ (k + n));
100034 + return k ^ h;
100035 +
100036 +#undef cwfold
100037 +#undef cwmixa
100038 +#undef cwmixb
100039 +}
100040 +
100041 +static inline unsigned int get_hash_num(const char *fndecl, const char *tree_codes, unsigned int len, unsigned int seed)
100042 +{
100043 + unsigned int fn = CrapWow(fndecl, strlen(fndecl), seed) & 0xffff;
100044 + unsigned int codes = CrapWow(tree_codes, len, seed) & 0xffff;
100045 + return fn ^ codes;
100046 +}
100047 +
100048 +static inline tree get_original_function_decl(tree fndecl)
100049 +{
100050 + if (DECL_ABSTRACT_ORIGIN(fndecl))
100051 + return DECL_ABSTRACT_ORIGIN(fndecl);
100052 + return fndecl;
100053 +}
100054 +
100055 +static inline gimple get_def_stmt(const_tree node)
100056 +{
100057 + gcc_assert(node != NULL_TREE);
100058 + if (TREE_CODE(node) != SSA_NAME)
100059 + return NULL;
100060 + return SSA_NAME_DEF_STMT(node);
100061 +}
100062 +
100063 +static unsigned char get_tree_code(const_tree type)
100064 +{
100065 + switch (TREE_CODE(type)) {
100066 + case ARRAY_TYPE:
100067 + return 0;
100068 + case BOOLEAN_TYPE:
100069 + return 1;
100070 + case ENUMERAL_TYPE:
100071 + return 2;
100072 + case FUNCTION_TYPE:
100073 + return 3;
100074 + case INTEGER_TYPE:
100075 + return 4;
100076 + case POINTER_TYPE:
100077 + return 5;
100078 + case RECORD_TYPE:
100079 + return 6;
100080 + case UNION_TYPE:
100081 + return 7;
100082 + case VOID_TYPE:
100083 + return 8;
100084 + case REAL_TYPE:
100085 + return 9;
100086 + case VECTOR_TYPE:
100087 + return 10;
100088 + case REFERENCE_TYPE:
100089 + return 11;
100090 + case OFFSET_TYPE:
100091 + return 12;
100092 + case COMPLEX_TYPE:
100093 + return 13;
100094 + default:
100095 + debug_tree((tree)type);
100096 + gcc_unreachable();
100097 + }
100098 +}
100099 +
100100 +static size_t add_type_codes(const_tree type, unsigned char *tree_codes, size_t len)
100101 +{
100102 + gcc_assert(type != NULL_TREE);
100103 +
100104 + while (type && len < CODES_LIMIT) {
100105 + tree_codes[len] = get_tree_code(type);
100106 + len++;
100107 + type = TREE_TYPE(type);
100108 + }
100109 + return len;
100110 +}
100111 +
100112 +static unsigned int get_function_decl(const_tree fndecl, unsigned char *tree_codes)
100113 +{
100114 + const_tree arg, result, arg_field, type = TREE_TYPE(fndecl);
100115 + enum tree_code code = TREE_CODE(type);
100116 + size_t len = 0;
100117 +
100118 + gcc_assert(code == FUNCTION_TYPE || code == METHOD_TYPE);
100119 +
100120 + arg = TYPE_ARG_TYPES(type);
100121 + // skip builtins __builtin_constant_p
100122 + if (!arg && DECL_BUILT_IN(fndecl))
100123 + return 0;
100124 +
100125 + if (TREE_CODE_CLASS(code) == tcc_type)
100126 + result = type;
100127 + else
100128 + result = DECL_RESULT(fndecl);
100129 +
100130 + gcc_assert(result != NULL_TREE);
100131 + len = add_type_codes(TREE_TYPE(result), tree_codes, len);
100132 +
100133 + if (arg == NULL_TREE) {
100134 + gcc_assert(CODE_CONTAINS_STRUCT(TREE_CODE(fndecl), TS_DECL_NON_COMMON));
100135 + arg_field = DECL_ARGUMENT_FLD(fndecl);
100136 + if (arg_field == NULL_TREE)
100137 + return 0;
100138 + arg = TREE_TYPE(arg_field);
100139 + len = add_type_codes(arg, tree_codes, len);
100140 + gcc_assert(len != 0);
100141 + return len;
100142 + }
100143 +
100144 + gcc_assert(arg != NULL_TREE && TREE_CODE(arg) == TREE_LIST);
100145 + while (arg && len < CODES_LIMIT) {
100146 + len = add_type_codes(TREE_VALUE(arg), tree_codes, len);
100147 + arg = TREE_CHAIN(arg);
100148 + }
100149 +
100150 + gcc_assert(len != 0);
100151 + return len;
100152 +}
100153 +
100154 +static const struct size_overflow_hash *get_function_hash(tree fndecl)
100155 +{
100156 + unsigned int hash;
100157 + const struct size_overflow_hash *entry;
100158 + unsigned char tree_codes[CODES_LIMIT];
100159 + size_t len;
100160 + const char *func_name;
100161 +
100162 + fndecl = get_original_function_decl(fndecl);
100163 + len = get_function_decl(fndecl, tree_codes);
100164 + if (len == 0)
100165 + return NULL;
100166 +
100167 + func_name = get_asm_name(fndecl);
100168 + hash = get_hash_num(func_name, (const char*) tree_codes, len, 0);
100169 +
100170 + entry = size_overflow_hash[hash];
100171 + while (entry) {
100172 + if (!strcmp(entry->name, func_name))
100173 + return entry;
100174 + entry = entry->next;
100175 + }
100176 +
100177 + return NULL;
100178 +}
100179 +
100180 +static bool is_bool(const_tree node)
100181 +{
100182 + const_tree type;
100183 +
100184 + if (node == NULL_TREE)
100185 + return false;
100186 +
100187 + type = TREE_TYPE(node);
100188 + if (!INTEGRAL_TYPE_P(type))
100189 + return false;
100190 + if (TREE_CODE(type) == BOOLEAN_TYPE)
100191 + return true;
100192 + if (TYPE_PRECISION(type) == 1)
100193 + return true;
100194 + return false;
100195 +}
100196 +
100197 +static bool skip_types(const_tree var)
100198 +{
100199 + tree type;
100200 +
100201 + if (is_gimple_constant(var))
100202 + return true;
100203 +
100204 + switch (TREE_CODE(var)) {
100205 + case ADDR_EXPR:
100206 +#if BUILDING_GCC_VERSION >= 4006
100207 + case MEM_REF:
100208 +#endif
100209 + case ARRAY_REF:
100210 + case BIT_FIELD_REF:
100211 + case INDIRECT_REF:
100212 + case TARGET_MEM_REF:
100213 + return true;
100214 + case PARM_DECL:
100215 + case VAR_DECL:
100216 + case COMPONENT_REF:
100217 + return false;
100218 + default:
100219 + break;
100220 + }
100221 +
100222 + gcc_assert(TREE_CODE(var) == SSA_NAME);
100223 +
100224 + type = TREE_TYPE(var);
100225 + switch (TREE_CODE(type)) {
100226 + case INTEGER_TYPE:
100227 + case ENUMERAL_TYPE:
100228 + return false;
100229 + case BOOLEAN_TYPE:
100230 + return is_bool(var);
100231 + default:
100232 + break;
100233 + }
100234 +
100235 + gcc_assert(TREE_CODE(type) == POINTER_TYPE);
100236 +
100237 + type = TREE_TYPE(type);
100238 + gcc_assert(type != NULL_TREE);
100239 + switch (TREE_CODE(type)) {
100240 + case RECORD_TYPE:
100241 + case POINTER_TYPE:
100242 + case ARRAY_TYPE:
100243 + return true;
100244 + case VOID_TYPE:
100245 + case INTEGER_TYPE:
100246 + case UNION_TYPE:
100247 + return false;
100248 + default:
100249 + break;
100250 + }
100251 +
100252 + debug_tree((tree)var);
100253 + gcc_unreachable();
100254 +}
100255 +
100256 +static unsigned int find_arg_number(const_tree arg, tree func)
100257 +{
100258 + tree var;
100259 + unsigned int argnum = 1;
100260 +
100261 + if (TREE_CODE(arg) == SSA_NAME)
100262 + arg = SSA_NAME_VAR(arg);
100263 +
100264 + for (var = DECL_ARGUMENTS(func); var; var = TREE_CHAIN(var), argnum++) {
100265 + if (!operand_equal_p(arg, var, 0) && strcmp(NAME(var), NAME(arg)))
100266 + continue;
100267 + if (!skip_types(var))
100268 + return argnum;
100269 + }
100270 +
100271 + return 0;
100272 +}
100273 +
100274 +static tree create_new_var(tree type)
100275 +{
100276 + tree new_var = create_tmp_var(type, "cicus");
100277 +
100278 +#if BUILDING_GCC_VERSION <= 4007
100279 + add_referenced_var(new_var);
100280 + mark_sym_for_renaming(new_var);
100281 +#endif
100282 + return new_var;
100283 +}
100284 +
100285 +static gimple create_binary_assign(enum tree_code code, gimple stmt, tree rhs1, tree rhs2)
100286 +{
100287 + gimple assign;
100288 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
100289 + tree type = TREE_TYPE(rhs1);
100290 + tree lhs = create_new_var(type);
100291 +
100292 + gcc_assert(types_compatible_p(type, TREE_TYPE(rhs2)));
100293 + assign = gimple_build_assign_with_ops(code, lhs, rhs1, rhs2);
100294 + gimple_set_lhs(assign, make_ssa_name(lhs, assign));
100295 +
100296 + gsi_insert_before(&gsi, assign, GSI_NEW_STMT);
100297 + update_stmt(assign);
100298 + gimple_set_plf(assign, MY_STMT, true);
100299 + return assign;
100300 +}
100301 +
100302 +static tree cast_a_tree(tree type, tree var)
100303 +{
100304 + gcc_assert(type != NULL_TREE);
100305 + gcc_assert(var != NULL_TREE);
100306 + gcc_assert(fold_convertible_p(type, var));
100307 +
100308 + return fold_convert(type, var);
100309 +}
100310 +
100311 +static tree get_lhs(const_gimple stmt)
100312 +{
100313 + switch (gimple_code(stmt)) {
100314 + case GIMPLE_ASSIGN:
100315 + return gimple_get_lhs(stmt);
100316 + case GIMPLE_PHI:
100317 + return gimple_phi_result(stmt);
100318 + case GIMPLE_CALL:
100319 + return gimple_call_lhs(stmt);
100320 + default:
100321 + return NULL_TREE;
100322 + }
100323 +}
100324 +
100325 +static bool skip_cast(tree dst_type, const_tree rhs, bool force)
100326 +{
100327 + const_gimple def_stmt = get_def_stmt(rhs);
100328 +
100329 + if (force)
100330 + return false;
100331 +
100332 + if (is_gimple_constant(rhs))
100333 + return false;
100334 +
100335 + if (!def_stmt || gimple_code(def_stmt) == GIMPLE_NOP)
100336 + return false;
100337 +
100338 + if (!types_compatible_p(dst_type, TREE_TYPE(rhs)))
100339 + return false;
100340 +
100341 + // DI type can be on 32 bit (from create_assign) but overflow type stays DI
100342 + if (LONG_TYPE_SIZE == GET_MODE_BITSIZE(SImode))
100343 + return false;
100344 +
100345 + return true;
100346 +}
100347 +
100348 +static gimple build_cast_stmt(tree dst_type, tree rhs, tree lhs, gimple_stmt_iterator *gsi, bool before, bool force)
100349 +{
100350 + gimple assign, def_stmt;
100351 +
100352 + gcc_assert(dst_type != NULL_TREE && rhs != NULL_TREE);
100353 + if (gsi_end_p(*gsi) && before == AFTER_STMT)
100354 + gcc_unreachable();
100355 +
100356 + def_stmt = get_def_stmt(rhs);
100357 + if (skip_cast(dst_type, rhs, force) && gimple_plf(def_stmt, MY_STMT))
100358 + return def_stmt;
100359 +
100360 + if (lhs == CREATE_NEW_VAR)
100361 + lhs = create_new_var(dst_type);
100362 +
100363 + assign = gimple_build_assign(lhs, cast_a_tree(dst_type, rhs));
100364 +
100365 + if (!gsi_end_p(*gsi)) {
100366 + location_t loc = gimple_location(gsi_stmt(*gsi));
100367 + gimple_set_location(assign, loc);
100368 + }
100369 +
100370 + gimple_set_lhs(assign, make_ssa_name(lhs, assign));
100371 +
100372 + if (before)
100373 + gsi_insert_before(gsi, assign, GSI_NEW_STMT);
100374 + else
100375 + gsi_insert_after(gsi, assign, GSI_NEW_STMT);
100376 + update_stmt(assign);
100377 + gimple_set_plf(assign, MY_STMT, true);
100378 +
100379 + return assign;
100380 +}
100381 +
100382 +static tree cast_to_new_size_overflow_type(gimple stmt, tree rhs, tree size_overflow_type, bool before)
100383 +{
100384 + gimple_stmt_iterator gsi;
100385 + tree lhs;
100386 + const_gimple new_stmt;
100387 +
100388 + if (rhs == NULL_TREE)
100389 + return NULL_TREE;
100390 +
100391 + gsi = gsi_for_stmt(stmt);
100392 + new_stmt = build_cast_stmt(size_overflow_type, rhs, CREATE_NEW_VAR, &gsi, before, false);
100393 +
100394 + lhs = get_lhs(new_stmt);
100395 + gcc_assert(lhs != NULL_TREE);
100396 + return lhs;
100397 +}
100398 +
100399 +static tree cast_to_TI_type(gimple stmt, tree node)
100400 +{
100401 + gimple_stmt_iterator gsi;
100402 + gimple cast_stmt;
100403 + tree type = TREE_TYPE(node);
100404 +
100405 + if (types_compatible_p(type, intTI_type_node))
100406 + return node;
100407 +
100408 + gsi = gsi_for_stmt(stmt);
100409 + cast_stmt = build_cast_stmt(intTI_type_node, node, CREATE_NEW_VAR, &gsi, BEFORE_STMT, false);
100410 + return gimple_get_lhs(cast_stmt);
100411 +}
100412 +
100413 +static void check_function_hash(const_gimple stmt)
100414 +{
100415 + tree func;
100416 + const struct size_overflow_hash *hash;
100417 +
100418 + if (gimple_code(stmt) != GIMPLE_CALL)
100419 + return;
100420 +
100421 + func = gimple_call_fndecl(stmt);
100422 + //fs/xattr.c D.34222_15 = D.34219_14 (dentry_3(D), name_7(D), 0B, 0);
100423 + if (func == NULL_TREE)
100424 + return;
100425 +
100426 + hash = get_function_hash(func);
100427 + if (!hash)
100428 + print_missing_msg(func, 0);
100429 +}
100430 +
100431 +static tree create_assign(struct pointer_set_t *visited, gimple oldstmt, tree rhs1, bool before)
100432 +{
100433 + tree lhs, new_lhs;
100434 + gimple_stmt_iterator gsi;
100435 +
100436 + if (rhs1 == NULL_TREE) {
100437 + debug_gimple_stmt(oldstmt);
100438 + error("%s: rhs1 is NULL_TREE", __func__);
100439 + gcc_unreachable();
100440 + }
100441 +
100442 + switch (gimple_code(oldstmt)) {
100443 + case GIMPLE_ASM:
100444 + lhs = rhs1;
100445 + break;
100446 + case GIMPLE_CALL:
100447 + lhs = gimple_call_lhs(oldstmt);
100448 + break;
100449 + case GIMPLE_ASSIGN:
100450 + lhs = gimple_get_lhs(oldstmt);
100451 + break;
100452 + default:
100453 + debug_gimple_stmt(oldstmt);
100454 + gcc_unreachable();
100455 + }
100456 +
100457 + gsi = gsi_for_stmt(oldstmt);
100458 + pointer_set_insert(visited, oldstmt);
100459 + if (lookup_stmt_eh_lp(oldstmt) != 0) {
100460 + basic_block next_bb, cur_bb;
100461 + const_edge e;
100462 +
100463 + gcc_assert(before == false);
100464 + gcc_assert(stmt_can_throw_internal(oldstmt));
100465 + gcc_assert(gimple_code(oldstmt) == GIMPLE_CALL);
100466 + gcc_assert(!gsi_end_p(gsi));
100467 +
100468 + cur_bb = gimple_bb(oldstmt);
100469 + next_bb = cur_bb->next_bb;
100470 + e = find_edge(cur_bb, next_bb);
100471 + gcc_assert(e != NULL);
100472 + gcc_assert(e->flags & EDGE_FALLTHRU);
100473 +
100474 + gsi = gsi_after_labels(next_bb);
100475 + gcc_assert(!gsi_end_p(gsi));
100476 +
100477 + before = true;
100478 + oldstmt = gsi_stmt(gsi);
100479 + }
100480 +
100481 + new_lhs = cast_to_new_size_overflow_type(oldstmt, rhs1, get_size_overflow_type(oldstmt, lhs), before);
100482 + return new_lhs;
100483 +}
100484 +
100485 +static tree dup_assign(struct pointer_set_t *visited, gimple oldstmt, const_tree node, tree rhs1, tree rhs2, tree __unused rhs3)
100486 +{
100487 + gimple stmt;
100488 + gimple_stmt_iterator gsi;
100489 + tree size_overflow_type, new_var, lhs = gimple_get_lhs(oldstmt);
100490 +
100491 + if (gimple_plf(oldstmt, MY_STMT))
100492 + return lhs;
100493 +
100494 + if (gimple_num_ops(oldstmt) != 4 && rhs1 == NULL_TREE) {
100495 + rhs1 = gimple_assign_rhs1(oldstmt);
100496 + rhs1 = create_assign(visited, oldstmt, rhs1, BEFORE_STMT);
100497 + }
100498 + if (gimple_num_ops(oldstmt) == 3 && rhs2 == NULL_TREE) {
100499 + rhs2 = gimple_assign_rhs2(oldstmt);
100500 + rhs2 = create_assign(visited, oldstmt, rhs2, BEFORE_STMT);
100501 + }
100502 +
100503 + stmt = gimple_copy(oldstmt);
100504 + gimple_set_location(stmt, gimple_location(oldstmt));
100505 + gimple_set_plf(stmt, MY_STMT, true);
100506 +
100507 + if (gimple_assign_rhs_code(oldstmt) == WIDEN_MULT_EXPR)
100508 + gimple_assign_set_rhs_code(stmt, MULT_EXPR);
100509 +
100510 + size_overflow_type = get_size_overflow_type(oldstmt, node);
100511 +
100512 + new_var = create_new_var(size_overflow_type);
100513 + new_var = make_ssa_name(new_var, stmt);
100514 + gimple_set_lhs(stmt, new_var);
100515 +
100516 + if (rhs1 != NULL_TREE)
100517 + gimple_assign_set_rhs1(stmt, rhs1);
100518 +
100519 + if (rhs2 != NULL_TREE)
100520 + gimple_assign_set_rhs2(stmt, rhs2);
100521 +#if BUILDING_GCC_VERSION >= 4007
100522 + if (rhs3 != NULL_TREE)
100523 + gimple_assign_set_rhs3(stmt, rhs3);
100524 +#endif
100525 + gimple_set_vuse(stmt, gimple_vuse(oldstmt));
100526 + gimple_set_vdef(stmt, gimple_vdef(oldstmt));
100527 +
100528 + gsi = gsi_for_stmt(oldstmt);
100529 + gsi_insert_after(&gsi, stmt, GSI_SAME_STMT);
100530 + update_stmt(stmt);
100531 + pointer_set_insert(visited, oldstmt);
100532 + return gimple_get_lhs(stmt);
100533 +}
100534 +
100535 +static tree cast_parm_decl(tree phi_ssa_name, tree arg, tree size_overflow_type)
100536 +{
100537 + basic_block first_bb;
100538 + gimple assign;
100539 + gimple_stmt_iterator gsi;
100540 +
100541 + first_bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
100542 + gcc_assert(dom_info_available_p(CDI_DOMINATORS));
100543 + set_immediate_dominator(CDI_DOMINATORS, first_bb, ENTRY_BLOCK_PTR);
100544 +
100545 + gsi = gsi_start_bb(first_bb);
100546 + assign = build_cast_stmt(size_overflow_type, arg, phi_ssa_name, &gsi, BEFORE_STMT, false);
100547 + return gimple_get_lhs(assign);
100548 +}
100549 +
100550 +static tree use_phi_ssa_name(tree phi_ssa_name, tree new_arg)
100551 +{
100552 + gimple_stmt_iterator gsi;
100553 + const_gimple assign;
100554 + gimple def_stmt = get_def_stmt(new_arg);
100555 +
100556 + if (gimple_code(def_stmt) == GIMPLE_PHI) {
100557 + gsi = gsi_after_labels(gimple_bb(def_stmt));
100558 + assign = build_cast_stmt(TREE_TYPE(new_arg), new_arg, phi_ssa_name, &gsi, BEFORE_STMT, true);
100559 + } else {
100560 + gsi = gsi_for_stmt(def_stmt);
100561 + assign = build_cast_stmt(TREE_TYPE(new_arg), new_arg, phi_ssa_name, &gsi, AFTER_STMT, true);
100562 + }
100563 +
100564 + return gimple_get_lhs(assign);
100565 +}
100566 +
100567 +static tree cast_visited_phi_arg(tree phi_ssa_name, tree arg, tree size_overflow_type)
100568 +{
100569 + basic_block bb;
100570 + gimple_stmt_iterator gsi;
100571 + const_gimple assign, def_stmt;
100572 +
100573 + def_stmt = get_def_stmt(arg);
100574 + bb = gimple_bb(def_stmt);
100575 + gcc_assert(bb->index != 0);
100576 + gsi = gsi_after_labels(bb);
100577 +
100578 + assign = build_cast_stmt(size_overflow_type, arg, phi_ssa_name, &gsi, BEFORE_STMT, false);
100579 + return gimple_get_lhs(assign);
100580 +}
100581 +
100582 +static tree create_new_phi_arg(tree phi_ssa_name, tree new_arg, tree arg, gimple oldstmt)
100583 +{
100584 + tree size_overflow_type;
100585 + const_gimple def_stmt = get_def_stmt(arg);
100586 +
100587 + if (phi_ssa_name != NULL_TREE)
100588 + phi_ssa_name = SSA_NAME_VAR(phi_ssa_name);
100589 +
100590 + size_overflow_type = get_size_overflow_type(oldstmt, arg);
100591 +
100592 + if (new_arg != NULL_TREE) {
100593 + gcc_assert(types_compatible_p(TREE_TYPE(new_arg), size_overflow_type));
100594 + return use_phi_ssa_name(phi_ssa_name, new_arg);
100595 + }
100596 +
100597 + switch(gimple_code(def_stmt)) {
100598 + case GIMPLE_PHI:
100599 + return cast_visited_phi_arg(phi_ssa_name, arg, size_overflow_type);
100600 + case GIMPLE_NOP:
100601 + return cast_parm_decl(phi_ssa_name, arg, size_overflow_type);
100602 + default:
100603 + debug_gimple_stmt((gimple)def_stmt);
100604 + gcc_unreachable();
100605 + }
100606 +}
100607 +
100608 +static gimple overflow_create_phi_node(gimple oldstmt, tree result)
100609 +{
100610 + basic_block bb;
100611 + gimple phi;
100612 + gimple_seq seq;
100613 + gimple_stmt_iterator gsi = gsi_for_stmt(oldstmt);
100614 +
100615 + bb = gsi_bb(gsi);
100616 +
100617 + phi = create_phi_node(result, bb);
100618 + gimple_phi_set_result(phi, make_ssa_name(result, phi));
100619 + seq = phi_nodes(bb);
100620 + gsi = gsi_last(seq);
100621 + gsi_remove(&gsi, false);
100622 +
100623 + gsi = gsi_for_stmt(oldstmt);
100624 + gsi_insert_after(&gsi, phi, GSI_NEW_STMT);
100625 + gimple_set_bb(phi, bb);
100626 + gimple_set_plf(phi, MY_STMT, true);
100627 + return phi;
100628 +}
100629 +
100630 +static tree handle_phi(struct pointer_set_t *visited, tree orig_result)
100631 +{
100632 + gimple new_phi = NULL;
100633 + gimple oldstmt = get_def_stmt(orig_result);
100634 + tree phi_ssa_name = NULL_TREE;
100635 + unsigned int i;
100636 +
100637 + pointer_set_insert(visited, oldstmt);
100638 + for (i = 0; i < gimple_phi_num_args(oldstmt); i++) {
100639 + tree arg, new_arg;
100640 +
100641 + arg = gimple_phi_arg_def(oldstmt, i);
100642 +
100643 + new_arg = expand(visited, arg);
100644 + new_arg = create_new_phi_arg(phi_ssa_name, new_arg, arg, oldstmt);
100645 + if (i == 0) {
100646 + phi_ssa_name = new_arg;
100647 + new_phi = overflow_create_phi_node(oldstmt, SSA_NAME_VAR(phi_ssa_name));
100648 + }
100649 +
100650 + gcc_assert(new_phi != NULL);
100651 + add_phi_arg(new_phi, new_arg, gimple_phi_arg_edge(oldstmt, i), gimple_location(oldstmt));
100652 + }
100653 +
100654 + gcc_assert(new_phi != NULL);
100655 + update_stmt(new_phi);
100656 + return gimple_phi_result(new_phi);
100657 +}
100658 +
100659 +static tree change_assign_rhs(gimple stmt, const_tree orig_rhs, tree new_rhs)
100660 +{
100661 + const_gimple assign;
100662 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
100663 + tree origtype = TREE_TYPE(orig_rhs);
100664 +
100665 + gcc_assert(gimple_code(stmt) == GIMPLE_ASSIGN);
100666 +
100667 + assign = build_cast_stmt(origtype, new_rhs, CREATE_NEW_VAR, &gsi, BEFORE_STMT, false);
100668 + return gimple_get_lhs(assign);
100669 +}
100670 +
100671 +static bool is_a_cast_and_const_overflow(const_tree no_const_rhs)
100672 +{
100673 + const_tree rhs1, lhs, rhs1_type, lhs_type;
100674 + enum machine_mode lhs_mode, rhs_mode;
100675 + gimple def_stmt = get_def_stmt(no_const_rhs);
100676 +
100677 + if (!gimple_assign_cast_p(def_stmt))
100678 + return false;
100679 +
100680 + rhs1 = gimple_assign_rhs1(def_stmt);
100681 + lhs = gimple_get_lhs(def_stmt);
100682 + rhs1_type = TREE_TYPE(rhs1);
100683 + lhs_type = TREE_TYPE(lhs);
100684 + rhs_mode = TYPE_MODE(rhs1_type);
100685 + lhs_mode = TYPE_MODE(lhs_type);
100686 + if (TYPE_UNSIGNED(lhs_type) == TYPE_UNSIGNED(rhs1_type) || lhs_mode != rhs_mode)
100687 + return false;
100688 +
100689 + return true;
100690 +}
100691 +
100692 +static tree create_cast_assign(struct pointer_set_t *visited, gimple stmt)
100693 +{
100694 + tree rhs1 = gimple_assign_rhs1(stmt);
100695 + tree lhs = gimple_get_lhs(stmt);
100696 + const_tree rhs1_type = TREE_TYPE(rhs1);
100697 + const_tree lhs_type = TREE_TYPE(lhs);
100698 +
100699 + if (TYPE_UNSIGNED(rhs1_type) == TYPE_UNSIGNED(lhs_type))
100700 + return create_assign(visited, stmt, lhs, AFTER_STMT);
100701 +
100702 + return create_assign(visited, stmt, rhs1, AFTER_STMT);
100703 +}
100704 +
100705 +static bool skip_lhs_cast_check(const_gimple stmt)
100706 +{
100707 + const_tree rhs = gimple_assign_rhs1(stmt);
100708 + const_gimple def_stmt = get_def_stmt(rhs);
100709 +
100710 + // 3.8.2 kernel/futex_compat.c compat_exit_robust_list(): get_user() 64 ulong -> int (compat_long_t), int max
100711 + if (gimple_code(def_stmt) == GIMPLE_ASM)
100712 + return true;
100713 +
100714 + return false;
100715 +}
100716 +
100717 +static tree create_cast_overflow_check(struct pointer_set_t *visited, tree new_rhs1, gimple stmt)
100718 +{
100719 + bool cast_lhs, cast_rhs;
100720 + tree lhs = gimple_get_lhs(stmt);
100721 + tree rhs = gimple_assign_rhs1(stmt);
100722 + const_tree lhs_type = TREE_TYPE(lhs);
100723 + const_tree rhs_type = TREE_TYPE(rhs);
100724 + enum machine_mode lhs_mode = TYPE_MODE(lhs_type);
100725 + enum machine_mode rhs_mode = TYPE_MODE(rhs_type);
100726 + unsigned int lhs_size = GET_MODE_BITSIZE(lhs_mode);
100727 + unsigned int rhs_size = GET_MODE_BITSIZE(rhs_mode);
100728 +
100729 + static bool check_lhs[3][4] = {
100730 + // ss su us uu
100731 + { false, true, true, false }, // lhs > rhs
100732 + { false, false, false, false }, // lhs = rhs
100733 + { true, true, true, true }, // lhs < rhs
100734 + };
100735 +
100736 + static bool check_rhs[3][4] = {
100737 + // ss su us uu
100738 + { true, false, true, true }, // lhs > rhs
100739 + { true, false, true, true }, // lhs = rhs
100740 + { true, false, true, true }, // lhs < rhs
100741 + };
100742 +
100743 + // skip lhs check on signed SI -> HI cast or signed SI -> QI cast !!!!
100744 + if (rhs_mode == SImode && !TYPE_UNSIGNED(rhs_type) && (lhs_mode == HImode || lhs_mode == QImode))
100745 + return create_assign(visited, stmt, lhs, AFTER_STMT);
100746 +
100747 + if (lhs_size > rhs_size) {
100748 + cast_lhs = check_lhs[0][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
100749 + cast_rhs = check_rhs[0][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
100750 + } else if (lhs_size == rhs_size) {
100751 + cast_lhs = check_lhs[1][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
100752 + cast_rhs = check_rhs[1][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
100753 + } else {
100754 + cast_lhs = check_lhs[2][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
100755 + cast_rhs = check_rhs[2][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
100756 + }
100757 +
100758 + if (!cast_lhs && !cast_rhs)
100759 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
100760 +
100761 + if (cast_lhs && !skip_lhs_cast_check(stmt))
100762 + check_size_overflow(stmt, TREE_TYPE(new_rhs1), new_rhs1, lhs, BEFORE_STMT);
100763 +
100764 + if (cast_rhs)
100765 + check_size_overflow(stmt, TREE_TYPE(new_rhs1), new_rhs1, rhs, BEFORE_STMT);
100766 +
100767 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
100768 +}
100769 +
100770 +static tree handle_unary_rhs(struct pointer_set_t *visited, gimple stmt)
100771 +{
100772 + tree rhs1, new_rhs1, lhs = gimple_get_lhs(stmt);
100773 +
100774 + if (gimple_plf(stmt, MY_STMT))
100775 + return lhs;
100776 +
100777 + rhs1 = gimple_assign_rhs1(stmt);
100778 + if (TREE_CODE(TREE_TYPE(rhs1)) == POINTER_TYPE)
100779 + return create_assign(visited, stmt, lhs, AFTER_STMT);
100780 +
100781 + new_rhs1 = expand(visited, rhs1);
100782 +
100783 + if (new_rhs1 == NULL_TREE)
100784 + return create_cast_assign(visited, stmt);
100785 +
100786 + if (gimple_plf(stmt, NO_CAST_CHECK))
100787 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
100788 +
100789 + if (gimple_assign_rhs_code(stmt) == BIT_NOT_EXPR) {
100790 + tree size_overflow_type = get_size_overflow_type(stmt, rhs1);
100791 +
100792 + new_rhs1 = cast_to_new_size_overflow_type(stmt, new_rhs1, size_overflow_type, BEFORE_STMT);
100793 + check_size_overflow(stmt, size_overflow_type, new_rhs1, rhs1, BEFORE_STMT);
100794 + return create_assign(visited, stmt, lhs, AFTER_STMT);
100795 + }
100796 +
100797 + if (!gimple_assign_cast_p(stmt))
100798 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
100799 +
100800 + return create_cast_overflow_check(visited, new_rhs1, stmt);
100801 +}
100802 +
100803 +static tree handle_unary_ops(struct pointer_set_t *visited, gimple stmt)
100804 +{
100805 + tree rhs1, lhs = gimple_get_lhs(stmt);
100806 + gimple def_stmt = get_def_stmt(lhs);
100807 +
100808 + gcc_assert(gimple_code(def_stmt) != GIMPLE_NOP);
100809 + rhs1 = gimple_assign_rhs1(def_stmt);
100810 +
100811 + if (is_gimple_constant(rhs1))
100812 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
100813 +
100814 + switch (TREE_CODE(rhs1)) {
100815 + case SSA_NAME:
100816 + return handle_unary_rhs(visited, def_stmt);
100817 + case ARRAY_REF:
100818 + case BIT_FIELD_REF:
100819 + case ADDR_EXPR:
100820 + case COMPONENT_REF:
100821 + case INDIRECT_REF:
100822 +#if BUILDING_GCC_VERSION >= 4006
100823 + case MEM_REF:
100824 +#endif
100825 + case TARGET_MEM_REF:
100826 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
100827 + case PARM_DECL:
100828 + case VAR_DECL:
100829 + return create_assign(visited, stmt, lhs, AFTER_STMT);
100830 +
100831 + default:
100832 + debug_gimple_stmt(def_stmt);
100833 + debug_tree(rhs1);
100834 + gcc_unreachable();
100835 + }
100836 +}
100837 +
100838 +static void insert_cond(basic_block cond_bb, tree arg, enum tree_code cond_code, tree type_value)
100839 +{
100840 + gimple cond_stmt;
100841 + gimple_stmt_iterator gsi = gsi_last_bb(cond_bb);
100842 +
100843 + cond_stmt = gimple_build_cond(cond_code, arg, type_value, NULL_TREE, NULL_TREE);
100844 + gsi_insert_after(&gsi, cond_stmt, GSI_CONTINUE_LINKING);
100845 + update_stmt(cond_stmt);
100846 +}
100847 +
100848 +static tree create_string_param(tree string)
100849 +{
100850 + tree i_type, a_type;
100851 + const int length = TREE_STRING_LENGTH(string);
100852 +
100853 + gcc_assert(length > 0);
100854 +
100855 + i_type = build_index_type(build_int_cst(NULL_TREE, length - 1));
100856 + a_type = build_array_type(char_type_node, i_type);
100857 +
100858 + TREE_TYPE(string) = a_type;
100859 + TREE_CONSTANT(string) = 1;
100860 + TREE_READONLY(string) = 1;
100861 +
100862 + return build1(ADDR_EXPR, ptr_type_node, string);
100863 +}
100864 +
100865 +static void insert_cond_result(basic_block bb_true, const_gimple stmt, const_tree arg, bool min)
100866 +{
100867 + gimple func_stmt;
100868 + const_gimple def_stmt;
100869 + const_tree loc_line;
100870 + tree loc_file, ssa_name, current_func;
100871 + expanded_location xloc;
100872 + char *ssa_name_buf;
100873 + int len;
100874 + gimple_stmt_iterator gsi = gsi_start_bb(bb_true);
100875 +
100876 + def_stmt = get_def_stmt(arg);
100877 + xloc = expand_location(gimple_location(def_stmt));
100878 +
100879 + if (!gimple_has_location(def_stmt)) {
100880 + xloc = expand_location(gimple_location(stmt));
100881 + if (!gimple_has_location(stmt))
100882 + xloc = expand_location(DECL_SOURCE_LOCATION(current_function_decl));
100883 + }
100884 +
100885 + loc_line = build_int_cstu(unsigned_type_node, xloc.line);
100886 +
100887 + loc_file = build_string(strlen(xloc.file) + 1, xloc.file);
100888 + loc_file = create_string_param(loc_file);
100889 +
100890 + current_func = build_string(NAME_LEN(current_function_decl) + 1, NAME(current_function_decl));
100891 + current_func = create_string_param(current_func);
100892 +
100893 + gcc_assert(DECL_NAME(SSA_NAME_VAR(arg)) != NULL);
100894 + call_count++;
100895 + 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);
100896 + gcc_assert(len > 0);
100897 + ssa_name = build_string(len + 1, ssa_name_buf);
100898 + free(ssa_name_buf);
100899 + ssa_name = create_string_param(ssa_name);
100900 +
100901 + // void report_size_overflow(const char *file, unsigned int line, const char *func, const char *ssa_name)
100902 + func_stmt = gimple_build_call(report_size_overflow_decl, 4, loc_file, loc_line, current_func, ssa_name);
100903 +
100904 + gsi_insert_after(&gsi, func_stmt, GSI_CONTINUE_LINKING);
100905 +}
100906 +
100907 +static void __unused print_the_code_insertions(const_gimple stmt)
100908 +{
100909 + location_t loc = gimple_location(stmt);
100910 +
100911 + inform(loc, "Integer size_overflow check applied here.");
100912 +}
100913 +
100914 +static void insert_check_size_overflow(gimple stmt, enum tree_code cond_code, tree arg, tree type_value, bool before, bool min)
100915 +{
100916 + basic_block cond_bb, join_bb, bb_true;
100917 + edge e;
100918 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
100919 +
100920 + cond_bb = gimple_bb(stmt);
100921 + if (before)
100922 + gsi_prev(&gsi);
100923 + if (gsi_end_p(gsi))
100924 + e = split_block_after_labels(cond_bb);
100925 + else
100926 + e = split_block(cond_bb, gsi_stmt(gsi));
100927 + cond_bb = e->src;
100928 + join_bb = e->dest;
100929 + e->flags = EDGE_FALSE_VALUE;
100930 + e->probability = REG_BR_PROB_BASE;
100931 +
100932 + bb_true = create_empty_bb(cond_bb);
100933 + make_edge(cond_bb, bb_true, EDGE_TRUE_VALUE);
100934 + make_edge(cond_bb, join_bb, EDGE_FALSE_VALUE);
100935 + make_edge(bb_true, join_bb, EDGE_FALLTHRU);
100936 +
100937 + gcc_assert(dom_info_available_p(CDI_DOMINATORS));
100938 + set_immediate_dominator(CDI_DOMINATORS, bb_true, cond_bb);
100939 + set_immediate_dominator(CDI_DOMINATORS, join_bb, cond_bb);
100940 +
100941 + if (current_loops != NULL) {
100942 + gcc_assert(cond_bb->loop_father == join_bb->loop_father);
100943 + add_bb_to_loop(bb_true, cond_bb->loop_father);
100944 + }
100945 +
100946 + insert_cond(cond_bb, arg, cond_code, type_value);
100947 + insert_cond_result(bb_true, stmt, arg, min);
100948 +
100949 +// print_the_code_insertions(stmt);
100950 +}
100951 +
100952 +static void check_size_overflow(gimple stmt, tree size_overflow_type, tree cast_rhs, tree rhs, bool before)
100953 +{
100954 + const_tree rhs_type = TREE_TYPE(rhs);
100955 + tree cast_rhs_type, type_max_type, type_min_type, type_max, type_min;
100956 +
100957 + gcc_assert(rhs_type != NULL_TREE);
100958 + if (TREE_CODE(rhs_type) == POINTER_TYPE)
100959 + return;
100960 +
100961 + gcc_assert(TREE_CODE(rhs_type) == INTEGER_TYPE || TREE_CODE(rhs_type) == ENUMERAL_TYPE);
100962 +
100963 + type_max = cast_a_tree(size_overflow_type, TYPE_MAX_VALUE(rhs_type));
100964 + // typemax (-1) < typemin (0)
100965 + if (TREE_OVERFLOW(type_max))
100966 + return;
100967 +
100968 + type_min = cast_a_tree(size_overflow_type, TYPE_MIN_VALUE(rhs_type));
100969 +
100970 + cast_rhs_type = TREE_TYPE(cast_rhs);
100971 + type_max_type = TREE_TYPE(type_max);
100972 + type_min_type = TREE_TYPE(type_min);
100973 + gcc_assert(types_compatible_p(cast_rhs_type, type_max_type));
100974 + gcc_assert(types_compatible_p(type_max_type, type_min_type));
100975 +
100976 + insert_check_size_overflow(stmt, GT_EXPR, cast_rhs, type_max, before, false);
100977 + insert_check_size_overflow(stmt, LT_EXPR, cast_rhs, type_min, before, true);
100978 +}
100979 +
100980 +static bool is_a_constant_overflow(const_gimple stmt, const_tree rhs)
100981 +{
100982 + if (gimple_assign_rhs_code(stmt) == MIN_EXPR)
100983 + return false;
100984 + if (!is_gimple_constant(rhs))
100985 + return false;
100986 + return true;
100987 +}
100988 +
100989 +static tree get_def_stmt_rhs(const_tree var)
100990 +{
100991 + tree rhs1, def_stmt_rhs1;
100992 + gimple rhs1_def_stmt, def_stmt_rhs1_def_stmt, def_stmt;
100993 +
100994 + def_stmt = get_def_stmt(var);
100995 + gcc_assert(gimple_code(def_stmt) != GIMPLE_NOP && gimple_plf(def_stmt, MY_STMT) && gimple_assign_cast_p(def_stmt));
100996 +
100997 + rhs1 = gimple_assign_rhs1(def_stmt);
100998 + rhs1_def_stmt = get_def_stmt(rhs1);
100999 + if (!gimple_assign_cast_p(rhs1_def_stmt))
101000 + return rhs1;
101001 +
101002 + def_stmt_rhs1 = gimple_assign_rhs1(rhs1_def_stmt);
101003 + def_stmt_rhs1_def_stmt = get_def_stmt(def_stmt_rhs1);
101004 +
101005 + switch (gimple_code(def_stmt_rhs1_def_stmt)) {
101006 + case GIMPLE_CALL:
101007 + case GIMPLE_NOP:
101008 + case GIMPLE_ASM:
101009 + case GIMPLE_PHI:
101010 + return def_stmt_rhs1;
101011 + case GIMPLE_ASSIGN:
101012 + return rhs1;
101013 + default:
101014 + debug_gimple_stmt(def_stmt_rhs1_def_stmt);
101015 + gcc_unreachable();
101016 + }
101017 +}
101018 +
101019 +static tree handle_intentional_overflow(struct pointer_set_t *visited, bool check_overflow, gimple stmt, tree change_rhs, tree new_rhs2)
101020 +{
101021 + tree new_rhs, orig_rhs;
101022 + void (*gimple_assign_set_rhs)(gimple, tree);
101023 + tree rhs1 = gimple_assign_rhs1(stmt);
101024 + tree rhs2 = gimple_assign_rhs2(stmt);
101025 + tree lhs = gimple_get_lhs(stmt);
101026 +
101027 + if (!check_overflow)
101028 + return create_assign(visited, stmt, lhs, AFTER_STMT);
101029 +
101030 + if (change_rhs == NULL_TREE)
101031 + return create_assign(visited, stmt, lhs, AFTER_STMT);
101032 +
101033 + if (new_rhs2 == NULL_TREE) {
101034 + orig_rhs = rhs1;
101035 + gimple_assign_set_rhs = &gimple_assign_set_rhs1;
101036 + } else {
101037 + orig_rhs = rhs2;
101038 + gimple_assign_set_rhs = &gimple_assign_set_rhs2;
101039 + }
101040 +
101041 + check_size_overflow(stmt, TREE_TYPE(change_rhs), change_rhs, orig_rhs, BEFORE_STMT);
101042 +
101043 + new_rhs = change_assign_rhs(stmt, orig_rhs, change_rhs);
101044 + gimple_assign_set_rhs(stmt, new_rhs);
101045 + update_stmt(stmt);
101046 +
101047 + return create_assign(visited, stmt, lhs, AFTER_STMT);
101048 +}
101049 +
101050 +static bool is_subtraction_special(const_gimple stmt)
101051 +{
101052 + gimple rhs1_def_stmt, rhs2_def_stmt;
101053 + const_tree rhs1_def_stmt_rhs1, rhs2_def_stmt_rhs1, rhs1_def_stmt_lhs, rhs2_def_stmt_lhs;
101054 + enum machine_mode rhs1_def_stmt_rhs1_mode, rhs2_def_stmt_rhs1_mode, rhs1_def_stmt_lhs_mode, rhs2_def_stmt_lhs_mode;
101055 + const_tree rhs1 = gimple_assign_rhs1(stmt);
101056 + const_tree rhs2 = gimple_assign_rhs2(stmt);
101057 +
101058 + if (is_gimple_constant(rhs1) || is_gimple_constant(rhs2))
101059 + return false;
101060 +
101061 + gcc_assert(TREE_CODE(rhs1) == SSA_NAME && TREE_CODE(rhs2) == SSA_NAME);
101062 +
101063 + if (gimple_assign_rhs_code(stmt) != MINUS_EXPR)
101064 + return false;
101065 +
101066 + rhs1_def_stmt = get_def_stmt(rhs1);
101067 + rhs2_def_stmt = get_def_stmt(rhs2);
101068 + if (!gimple_assign_cast_p(rhs1_def_stmt) || !gimple_assign_cast_p(rhs2_def_stmt))
101069 + return false;
101070 +
101071 + rhs1_def_stmt_rhs1 = gimple_assign_rhs1(rhs1_def_stmt);
101072 + rhs2_def_stmt_rhs1 = gimple_assign_rhs1(rhs2_def_stmt);
101073 + rhs1_def_stmt_lhs = gimple_get_lhs(rhs1_def_stmt);
101074 + rhs2_def_stmt_lhs = gimple_get_lhs(rhs2_def_stmt);
101075 + rhs1_def_stmt_rhs1_mode = TYPE_MODE(TREE_TYPE(rhs1_def_stmt_rhs1));
101076 + rhs2_def_stmt_rhs1_mode = TYPE_MODE(TREE_TYPE(rhs2_def_stmt_rhs1));
101077 + rhs1_def_stmt_lhs_mode = TYPE_MODE(TREE_TYPE(rhs1_def_stmt_lhs));
101078 + rhs2_def_stmt_lhs_mode = TYPE_MODE(TREE_TYPE(rhs2_def_stmt_lhs));
101079 + if (GET_MODE_BITSIZE(rhs1_def_stmt_rhs1_mode) <= GET_MODE_BITSIZE(rhs1_def_stmt_lhs_mode))
101080 + return false;
101081 + if (GET_MODE_BITSIZE(rhs2_def_stmt_rhs1_mode) <= GET_MODE_BITSIZE(rhs2_def_stmt_lhs_mode))
101082 + return false;
101083 +
101084 + gimple_set_plf(rhs1_def_stmt, NO_CAST_CHECK, true);
101085 + gimple_set_plf(rhs2_def_stmt, NO_CAST_CHECK, true);
101086 + return true;
101087 +}
101088 +
101089 +static tree handle_integer_truncation(struct pointer_set_t *visited, const_tree lhs)
101090 +{
101091 + tree new_rhs1, new_rhs2;
101092 + tree new_rhs1_def_stmt_rhs1, new_rhs2_def_stmt_rhs1, new_lhs;
101093 + gimple assign, stmt = get_def_stmt(lhs);
101094 + tree rhs1 = gimple_assign_rhs1(stmt);
101095 + tree rhs2 = gimple_assign_rhs2(stmt);
101096 +
101097 + if (!is_subtraction_special(stmt))
101098 + return NULL_TREE;
101099 +
101100 + new_rhs1 = expand(visited, rhs1);
101101 + new_rhs2 = expand(visited, rhs2);
101102 +
101103 + new_rhs1_def_stmt_rhs1 = get_def_stmt_rhs(new_rhs1);
101104 + new_rhs2_def_stmt_rhs1 = get_def_stmt_rhs(new_rhs2);
101105 +
101106 + if (!types_compatible_p(TREE_TYPE(new_rhs1_def_stmt_rhs1), TREE_TYPE(new_rhs2_def_stmt_rhs1))) {
101107 + new_rhs1_def_stmt_rhs1 = cast_to_TI_type(stmt, new_rhs1_def_stmt_rhs1);
101108 + new_rhs2_def_stmt_rhs1 = cast_to_TI_type(stmt, new_rhs2_def_stmt_rhs1);
101109 + }
101110 +
101111 + assign = create_binary_assign(MINUS_EXPR, stmt, new_rhs1_def_stmt_rhs1, new_rhs2_def_stmt_rhs1);
101112 + new_lhs = gimple_get_lhs(assign);
101113 + check_size_overflow(assign, TREE_TYPE(new_lhs), new_lhs, rhs1, AFTER_STMT);
101114 +
101115 + return dup_assign(visited, stmt, lhs, new_rhs1, new_rhs2, NULL_TREE);
101116 +}
101117 +
101118 +static bool is_a_neg_overflow(const_gimple stmt, const_tree rhs)
101119 +{
101120 + const_gimple def_stmt;
101121 +
101122 + if (TREE_CODE(rhs) != SSA_NAME)
101123 + return false;
101124 +
101125 + if (gimple_assign_rhs_code(stmt) != PLUS_EXPR)
101126 + return false;
101127 +
101128 + def_stmt = get_def_stmt(rhs);
101129 + if (gimple_code(def_stmt) != GIMPLE_ASSIGN || gimple_assign_rhs_code(def_stmt) != BIT_NOT_EXPR)
101130 + return false;
101131 +
101132 + return true;
101133 +}
101134 +
101135 +static tree handle_binary_ops(struct pointer_set_t *visited, tree lhs)
101136 +{
101137 + tree rhs1, rhs2, new_lhs;
101138 + gimple def_stmt = get_def_stmt(lhs);
101139 + tree new_rhs1 = NULL_TREE;
101140 + tree new_rhs2 = NULL_TREE;
101141 +
101142 + rhs1 = gimple_assign_rhs1(def_stmt);
101143 + rhs2 = gimple_assign_rhs2(def_stmt);
101144 +
101145 + /* no DImode/TImode division in the 32/64 bit kernel */
101146 + switch (gimple_assign_rhs_code(def_stmt)) {
101147 + case RDIV_EXPR:
101148 + case TRUNC_DIV_EXPR:
101149 + case CEIL_DIV_EXPR:
101150 + case FLOOR_DIV_EXPR:
101151 + case ROUND_DIV_EXPR:
101152 + case TRUNC_MOD_EXPR:
101153 + case CEIL_MOD_EXPR:
101154 + case FLOOR_MOD_EXPR:
101155 + case ROUND_MOD_EXPR:
101156 + case EXACT_DIV_EXPR:
101157 + case POINTER_PLUS_EXPR:
101158 + case BIT_AND_EXPR:
101159 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
101160 + default:
101161 + break;
101162 + }
101163 +
101164 + new_lhs = handle_integer_truncation(visited, lhs);
101165 + if (new_lhs != NULL_TREE)
101166 + return new_lhs;
101167 +
101168 + if (TREE_CODE(rhs1) == SSA_NAME)
101169 + new_rhs1 = expand(visited, rhs1);
101170 + if (TREE_CODE(rhs2) == SSA_NAME)
101171 + new_rhs2 = expand(visited, rhs2);
101172 +
101173 + if (is_a_neg_overflow(def_stmt, rhs2))
101174 + return handle_intentional_overflow(visited, true, def_stmt, new_rhs1, NULL_TREE);
101175 + if (is_a_neg_overflow(def_stmt, rhs1))
101176 + return handle_intentional_overflow(visited, true, def_stmt, new_rhs2, new_rhs2);
101177 +
101178 +
101179 + if (is_a_constant_overflow(def_stmt, rhs2))
101180 + return handle_intentional_overflow(visited, !is_a_cast_and_const_overflow(rhs1), def_stmt, new_rhs1, NULL_TREE);
101181 + if (is_a_constant_overflow(def_stmt, rhs1))
101182 + return handle_intentional_overflow(visited, !is_a_cast_and_const_overflow(rhs2), def_stmt, new_rhs2, new_rhs2);
101183 +
101184 + return dup_assign(visited, def_stmt, lhs, new_rhs1, new_rhs2, NULL_TREE);
101185 +}
101186 +
101187 +#if BUILDING_GCC_VERSION >= 4007
101188 +static tree get_new_rhs(struct pointer_set_t *visited, tree size_overflow_type, tree rhs)
101189 +{
101190 + if (is_gimple_constant(rhs))
101191 + return cast_a_tree(size_overflow_type, rhs);
101192 + if (TREE_CODE(rhs) != SSA_NAME)
101193 + return NULL_TREE;
101194 + return expand(visited, rhs);
101195 +}
101196 +
101197 +static tree handle_ternary_ops(struct pointer_set_t *visited, tree lhs)
101198 +{
101199 + tree rhs1, rhs2, rhs3, new_rhs1, new_rhs2, new_rhs3, size_overflow_type;
101200 + gimple def_stmt = get_def_stmt(lhs);
101201 +
101202 + size_overflow_type = get_size_overflow_type(def_stmt, lhs);
101203 +
101204 + rhs1 = gimple_assign_rhs1(def_stmt);
101205 + rhs2 = gimple_assign_rhs2(def_stmt);
101206 + rhs3 = gimple_assign_rhs3(def_stmt);
101207 + new_rhs1 = get_new_rhs(visited, size_overflow_type, rhs1);
101208 + new_rhs2 = get_new_rhs(visited, size_overflow_type, rhs2);
101209 + new_rhs3 = get_new_rhs(visited, size_overflow_type, rhs3);
101210 +
101211 + return dup_assign(visited, def_stmt, lhs, new_rhs1, new_rhs2, new_rhs3);
101212 +}
101213 +#endif
101214 +
101215 +static tree get_size_overflow_type(gimple stmt, const_tree node)
101216 +{
101217 + const_tree type;
101218 + tree new_type;
101219 +
101220 + gcc_assert(node != NULL_TREE);
101221 +
101222 + type = TREE_TYPE(node);
101223 +
101224 + if (gimple_plf(stmt, MY_STMT))
101225 + return TREE_TYPE(node);
101226 +
101227 + switch (TYPE_MODE(type)) {
101228 + case QImode:
101229 + new_type = intHI_type_node;
101230 + break;
101231 + case HImode:
101232 + new_type = intSI_type_node;
101233 + break;
101234 + case SImode:
101235 + new_type = intDI_type_node;
101236 + break;
101237 + case DImode:
101238 + if (LONG_TYPE_SIZE == GET_MODE_BITSIZE(SImode))
101239 + new_type = intDI_type_node;
101240 + else
101241 + new_type = intTI_type_node;
101242 + break;
101243 + default:
101244 + debug_tree((tree)node);
101245 + error("%s: unsupported gcc configuration.", __func__);
101246 + gcc_unreachable();
101247 + }
101248 +
101249 + if (TYPE_QUALS(type) != 0)
101250 + return build_qualified_type(new_type, TYPE_QUALS(type));
101251 + return new_type;
101252 +}
101253 +
101254 +static tree expand_visited(gimple def_stmt)
101255 +{
101256 + const_gimple next_stmt;
101257 + gimple_stmt_iterator gsi;
101258 + enum gimple_code code = gimple_code(def_stmt);
101259 +
101260 + if (code == GIMPLE_ASM)
101261 + return NULL_TREE;
101262 +
101263 + gsi = gsi_for_stmt(def_stmt);
101264 + gsi_next(&gsi);
101265 +
101266 + if (gimple_code(def_stmt) == GIMPLE_PHI && gsi_end_p(gsi))
101267 + return NULL_TREE;
101268 + gcc_assert(!gsi_end_p(gsi));
101269 + next_stmt = gsi_stmt(gsi);
101270 +
101271 + if (gimple_code(def_stmt) == GIMPLE_PHI && !gimple_plf((gimple)next_stmt, MY_STMT))
101272 + return NULL_TREE;
101273 + gcc_assert(gimple_plf((gimple)next_stmt, MY_STMT));
101274 +
101275 + return get_lhs(next_stmt);
101276 +}
101277 +
101278 +static tree expand(struct pointer_set_t *visited, tree lhs)
101279 +{
101280 + gimple def_stmt;
101281 +
101282 + if (skip_types(lhs))
101283 + return NULL_TREE;
101284 +
101285 + def_stmt = get_def_stmt(lhs);
101286 +
101287 + if (!def_stmt || gimple_code(def_stmt) == GIMPLE_NOP)
101288 + return NULL_TREE;
101289 +
101290 + if (gimple_plf(def_stmt, MY_STMT))
101291 + return lhs;
101292 +
101293 + if (pointer_set_contains(visited, def_stmt))
101294 + return expand_visited(def_stmt);
101295 +
101296 + switch (gimple_code(def_stmt)) {
101297 + case GIMPLE_PHI:
101298 + return handle_phi(visited, lhs);
101299 + case GIMPLE_CALL:
101300 + case GIMPLE_ASM:
101301 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
101302 + case GIMPLE_ASSIGN:
101303 + switch (gimple_num_ops(def_stmt)) {
101304 + case 2:
101305 + return handle_unary_ops(visited, def_stmt);
101306 + case 3:
101307 + return handle_binary_ops(visited, lhs);
101308 +#if BUILDING_GCC_VERSION >= 4007
101309 + case 4:
101310 + return handle_ternary_ops(visited, lhs);
101311 +#endif
101312 + }
101313 + default:
101314 + debug_gimple_stmt(def_stmt);
101315 + error("%s: unknown gimple code", __func__);
101316 + gcc_unreachable();
101317 + }
101318 +}
101319 +
101320 +static tree get_new_tree(gimple stmt, const_tree orig_node, tree new_node)
101321 +{
101322 + const_gimple assign;
101323 + tree orig_type = TREE_TYPE(orig_node);
101324 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
101325 +
101326 + assign = build_cast_stmt(orig_type, new_node, CREATE_NEW_VAR, &gsi, BEFORE_STMT, false);
101327 + return gimple_get_lhs(assign);
101328 +}
101329 +
101330 +static void change_function_arg(gimple stmt, const_tree orig_arg, unsigned int argnum, tree new_arg)
101331 +{
101332 + gimple_call_set_arg(stmt, argnum, get_new_tree(stmt, orig_arg, new_arg));
101333 + update_stmt(stmt);
101334 +}
101335 +
101336 +static void change_function_return(gimple stmt, const_tree orig_ret, tree new_ret)
101337 +{
101338 + gimple_return_set_retval(stmt, get_new_tree(stmt, orig_ret, new_ret));
101339 + update_stmt(stmt);
101340 +}
101341 +
101342 +static bool get_function_arg(unsigned int* argnum, const_tree fndecl)
101343 +{
101344 + tree arg;
101345 + const_tree origarg;
101346 +
101347 + if (!DECL_ABSTRACT_ORIGIN(fndecl))
101348 + return true;
101349 +
101350 + origarg = DECL_ARGUMENTS(DECL_ABSTRACT_ORIGIN(fndecl));
101351 + while (origarg && *argnum) {
101352 + (*argnum)--;
101353 + origarg = TREE_CHAIN(origarg);
101354 + }
101355 +
101356 + gcc_assert(*argnum == 0);
101357 +
101358 + gcc_assert(origarg != NULL_TREE);
101359 + *argnum = 0;
101360 + for (arg = DECL_ARGUMENTS(fndecl); arg; arg = TREE_CHAIN(arg), (*argnum)++)
101361 + if (operand_equal_p(origarg, arg, 0) || !strcmp(NAME(origarg), NAME(arg)))
101362 + return true;
101363 + return false;
101364 +}
101365 +
101366 +static enum mark walk_phi(struct pointer_set_t *visited, bool *search_err_code, const_tree result)
101367 +{
101368 + gimple phi = get_def_stmt(result);
101369 + unsigned int i, n = gimple_phi_num_args(phi);
101370 +
101371 + if (!phi)
101372 + return MARK_NO;
101373 +
101374 + pointer_set_insert(visited, phi);
101375 + for (i = 0; i < n; i++) {
101376 + enum mark marked;
101377 + const_tree arg = gimple_phi_arg_def(phi, i);
101378 + marked = pre_expand(visited, search_err_code, arg);
101379 + if (marked != MARK_NO)
101380 + return marked;
101381 + }
101382 + return MARK_NO;
101383 +}
101384 +
101385 +static enum mark walk_unary_ops(struct pointer_set_t *visited, bool *search_err_code, const_tree lhs)
101386 +{
101387 + gimple def_stmt = get_def_stmt(lhs);
101388 + const_tree rhs;
101389 +
101390 + if (!def_stmt)
101391 + return MARK_NO;
101392 +
101393 + rhs = gimple_assign_rhs1(def_stmt);
101394 +
101395 + def_stmt = get_def_stmt(rhs);
101396 + if (is_gimple_constant(rhs))
101397 + search_err_code[FROM_CONST] = true;
101398 +
101399 + return pre_expand(visited, search_err_code, rhs);
101400 +}
101401 +
101402 +static enum mark walk_binary_ops(struct pointer_set_t *visited, bool *search_err_code, const_tree lhs)
101403 +{
101404 + gimple def_stmt = get_def_stmt(lhs);
101405 + const_tree rhs1, rhs2;
101406 + enum mark marked;
101407 +
101408 + if (!def_stmt)
101409 + return MARK_NO;
101410 +
101411 + search_err_code[CAST_ONLY] = false;
101412 +
101413 + rhs1 = gimple_assign_rhs1(def_stmt);
101414 + rhs2 = gimple_assign_rhs2(def_stmt);
101415 + marked = pre_expand(visited, search_err_code, rhs1);
101416 + if (marked != MARK_NO)
101417 + return marked;
101418 + return pre_expand(visited, search_err_code, rhs2);
101419 +}
101420 +
101421 +static const_tree search_field_decl(const_tree comp_ref)
101422 +{
101423 + const_tree field = NULL_TREE;
101424 + unsigned int i, len = TREE_OPERAND_LENGTH(comp_ref);
101425 +
101426 + for (i = 0; i < len; i++) {
101427 + field = TREE_OPERAND(comp_ref, i);
101428 + if (TREE_CODE(field) == FIELD_DECL)
101429 + break;
101430 + }
101431 + gcc_assert(TREE_CODE(field) == FIELD_DECL);
101432 + return field;
101433 +}
101434 +
101435 +static enum mark mark_status(const_tree fndecl, unsigned int argnum)
101436 +{
101437 + const_tree attr, p;
101438 +
101439 + // 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);
101440 + if (fndecl == NULL_TREE)
101441 + return MARK_NO;
101442 +
101443 + attr = lookup_attribute("intentional_overflow", DECL_ATTRIBUTES(fndecl));
101444 + if (!attr || !TREE_VALUE(attr))
101445 + return MARK_NO;
101446 +
101447 + p = TREE_VALUE(attr);
101448 + if (TREE_INT_CST_HIGH(TREE_VALUE(p)) == -1)
101449 + return MARK_TURN_OFF;
101450 + if (!TREE_INT_CST_LOW(TREE_VALUE(p)))
101451 + return MARK_NOT_INTENTIONAL;
101452 + if (argnum == 0) {
101453 + gcc_assert(current_function_decl == fndecl);
101454 + return MARK_NO;
101455 + }
101456 +
101457 + do {
101458 + if (argnum == TREE_INT_CST_LOW(TREE_VALUE(p)))
101459 + return MARK_YES;
101460 + p = TREE_CHAIN(p);
101461 + } while (p);
101462 +
101463 + return MARK_NO;
101464 +}
101465 +
101466 +static void print_missing_msg(tree func, unsigned int argnum)
101467 +{
101468 + unsigned int new_hash;
101469 + size_t len;
101470 + unsigned char tree_codes[CODES_LIMIT];
101471 + location_t loc;
101472 + const char *curfunc;
101473 +
101474 + func = get_original_function_decl(func);
101475 + loc = DECL_SOURCE_LOCATION(func);
101476 + curfunc = get_asm_name(func);
101477 +
101478 + len = get_function_decl(func, tree_codes);
101479 + new_hash = get_hash_num(curfunc, (const char *) tree_codes, len, 0);
101480 + inform(loc, "Function %s is missing from the size_overflow hash table +%s+%u+%u+", curfunc, curfunc, argnum, new_hash);
101481 +}
101482 +
101483 +static unsigned int search_missing_attribute(const_tree arg)
101484 +{
101485 + unsigned int argnum;
101486 + const struct size_overflow_hash *hash;
101487 + const_tree type = TREE_TYPE(arg);
101488 + tree func = get_original_function_decl(current_function_decl);
101489 +
101490 + gcc_assert(TREE_CODE(arg) != COMPONENT_REF);
101491 +
101492 + if (TREE_CODE(type) == POINTER_TYPE)
101493 + return 0;
101494 +
101495 + argnum = find_arg_number(arg, func);
101496 + if (argnum == 0)
101497 + return 0;
101498 +
101499 + if (lookup_attribute("size_overflow", DECL_ATTRIBUTES(func)))
101500 + return argnum;
101501 +
101502 + hash = get_function_hash(func);
101503 + if (!hash || !(hash->param & (1U << argnum))) {
101504 + print_missing_msg(func, argnum);
101505 + return 0;
101506 + }
101507 + return argnum;
101508 +}
101509 +
101510 +static enum mark is_already_marked(const_tree lhs)
101511 +{
101512 + unsigned int argnum;
101513 + const_tree fndecl;
101514 +
101515 + argnum = search_missing_attribute(lhs);
101516 + fndecl = get_original_function_decl(current_function_decl);
101517 + if (argnum && mark_status(fndecl, argnum) == MARK_YES)
101518 + return MARK_YES;
101519 + return MARK_NO;
101520 +}
101521 +
101522 +static enum mark pre_expand(struct pointer_set_t *visited, bool *search_err_code, const_tree lhs)
101523 +{
101524 + const_gimple def_stmt;
101525 +
101526 + if (skip_types(lhs))
101527 + return MARK_NO;
101528 +
101529 + if (TREE_CODE(lhs) == PARM_DECL)
101530 + return is_already_marked(lhs);
101531 +
101532 + if (TREE_CODE(lhs) == COMPONENT_REF) {
101533 + const_tree field, attr;
101534 +
101535 + field = search_field_decl(lhs);
101536 + attr = lookup_attribute("intentional_overflow", DECL_ATTRIBUTES(field));
101537 + if (!attr || !TREE_VALUE(attr))
101538 + return MARK_NO;
101539 + return MARK_YES;
101540 + }
101541 +
101542 + def_stmt = get_def_stmt(lhs);
101543 +
101544 + if (!def_stmt)
101545 + return MARK_NO;
101546 +
101547 + if (pointer_set_contains(visited, def_stmt))
101548 + return MARK_NO;
101549 +
101550 + switch (gimple_code(def_stmt)) {
101551 + case GIMPLE_NOP:
101552 + if (TREE_CODE(SSA_NAME_VAR(lhs)) == PARM_DECL)
101553 + return is_already_marked(lhs);
101554 + return MARK_NO;
101555 + case GIMPLE_PHI:
101556 + return walk_phi(visited, search_err_code, lhs);
101557 + case GIMPLE_CALL:
101558 + if (mark_status((gimple_call_fndecl(def_stmt)), 0) == MARK_TURN_OFF)
101559 + return MARK_TURN_OFF;
101560 + check_function_hash(def_stmt);
101561 + return MARK_NO;
101562 + case GIMPLE_ASM:
101563 + search_err_code[CAST_ONLY] = false;
101564 + return MARK_NO;
101565 + case GIMPLE_ASSIGN:
101566 + switch (gimple_num_ops(def_stmt)) {
101567 + case 2:
101568 + return walk_unary_ops(visited, search_err_code, lhs);
101569 + case 3:
101570 + return walk_binary_ops(visited, search_err_code, lhs);
101571 + }
101572 + default:
101573 + debug_gimple_stmt((gimple)def_stmt);
101574 + error("%s: unknown gimple code", __func__);
101575 + gcc_unreachable();
101576 + }
101577 +}
101578 +
101579 +// e.g., 3.8.2, 64, arch/x86/ia32/ia32_signal.c copy_siginfo_from_user32(): compat_ptr() u32 max
101580 +static bool skip_asm(const_tree arg)
101581 +{
101582 + gimple def_stmt = get_def_stmt(arg);
101583 +
101584 + if (!def_stmt || !gimple_assign_cast_p(def_stmt))
101585 + return false;
101586 +
101587 + def_stmt = get_def_stmt(gimple_assign_rhs1(def_stmt));
101588 + return def_stmt && gimple_code(def_stmt) == GIMPLE_ASM;
101589 +}
101590 +
101591 +/*
101592 +0</MARK_YES: no dup, search attributes (so, int)
101593 +0/MARK_NOT_INTENTIONAL: no dup, search attribute (int)
101594 +-1/MARK_TURN_OFF: no dup, no search, current_function_decl -> no dup
101595 +*/
101596 +
101597 +static bool search_attributes(tree fndecl, const_tree arg, unsigned int argnum, bool where)
101598 +{
101599 + struct pointer_set_t *visited;
101600 + enum mark is_marked, is_found;
101601 + location_t loc;
101602 + bool search_err_code[2] = {true, false};
101603 +
101604 + is_marked = mark_status(current_function_decl, 0);
101605 + if (is_marked == MARK_TURN_OFF)
101606 + return true;
101607 +
101608 + is_marked = mark_status(fndecl, argnum + 1);
101609 + if (is_marked == MARK_TURN_OFF || is_marked == MARK_NOT_INTENTIONAL)
101610 + return true;
101611 +
101612 + visited = pointer_set_create();
101613 + is_found = pre_expand(visited, search_err_code, arg);
101614 + pointer_set_destroy(visited);
101615 +
101616 + if (where == FROM_RET && search_err_code[CAST_ONLY] && search_err_code[FROM_CONST])
101617 + return true;
101618 +
101619 + if (where == FROM_ARG && skip_asm(arg))
101620 + return true;
101621 +
101622 + if (is_found == MARK_TURN_OFF)
101623 + return true;
101624 +
101625 + if ((is_found == MARK_YES && is_marked == MARK_YES))
101626 + return true;
101627 +
101628 + if (is_found == MARK_YES) {
101629 + loc = DECL_SOURCE_LOCATION(fndecl);
101630 + inform(loc, "The intentional_overflow attribute is missing from +%s+%u+", get_asm_name(fndecl), argnum + 1);
101631 + return true;
101632 + }
101633 + return false;
101634 +}
101635 +
101636 +static void handle_function_arg(gimple stmt, tree fndecl, unsigned int argnum)
101637 +{
101638 + struct pointer_set_t *visited;
101639 + tree arg, new_arg;
101640 + bool match;
101641 +
101642 + if (argnum == 0)
101643 + return;
101644 +
101645 + argnum--;
101646 +
101647 + match = get_function_arg(&argnum, fndecl);
101648 + if (!match)
101649 + return;
101650 + gcc_assert(gimple_call_num_args(stmt) > argnum);
101651 + arg = gimple_call_arg(stmt, argnum);
101652 + if (arg == NULL_TREE)
101653 + return;
101654 +
101655 + if (skip_types(arg))
101656 + return;
101657 +
101658 + if (search_attributes(fndecl, arg, argnum, FROM_ARG))
101659 + return;
101660 +
101661 + visited = pointer_set_create();
101662 + new_arg = expand(visited, arg);
101663 + pointer_set_destroy(visited);
101664 +
101665 + if (new_arg == NULL_TREE)
101666 + return;
101667 +
101668 + change_function_arg(stmt, arg, argnum, new_arg);
101669 + check_size_overflow(stmt, TREE_TYPE(new_arg), new_arg, arg, BEFORE_STMT);
101670 +}
101671 +
101672 +static void handle_function_by_attribute(gimple stmt, const_tree attr, tree fndecl)
101673 +{
101674 + tree p = TREE_VALUE(attr);
101675 + do {
101676 + handle_function_arg(stmt, fndecl, TREE_INT_CST_LOW(TREE_VALUE(p)));
101677 + p = TREE_CHAIN(p);
101678 + } while (p);
101679 +}
101680 +
101681 +static void handle_function_by_hash(gimple stmt, tree fndecl)
101682 +{
101683 + unsigned int num;
101684 + const struct size_overflow_hash *hash;
101685 +
101686 + hash = get_function_hash(fndecl);
101687 + if (!hash)
101688 + return;
101689 +
101690 + for (num = 0; num <= MAX_PARAM; num++)
101691 + if (hash->param & (1U << num))
101692 + handle_function_arg(stmt, fndecl, num);
101693 +}
101694 +
101695 +static bool check_return_value(void)
101696 +{
101697 + const struct size_overflow_hash *hash;
101698 +
101699 + hash = get_function_hash(current_function_decl);
101700 + if (!hash || !(hash->param & 1U << 0))
101701 + return false;
101702 +
101703 + return true;
101704 +}
101705 +
101706 +static void handle_return_value(gimple ret_stmt)
101707 +{
101708 + struct pointer_set_t *visited;
101709 + tree ret, new_ret;
101710 +
101711 + if (gimple_code(ret_stmt) != GIMPLE_RETURN)
101712 + return;
101713 +
101714 + ret = gimple_return_retval(ret_stmt);
101715 +
101716 + if (skip_types(ret))
101717 + return;
101718 +
101719 + if (search_attributes(current_function_decl, ret, 0, FROM_RET))
101720 + return;
101721 +
101722 + visited = pointer_set_create();
101723 + new_ret = expand(visited, ret);
101724 + pointer_set_destroy(visited);
101725 +
101726 + change_function_return(ret_stmt, ret, new_ret);
101727 + check_size_overflow(ret_stmt, TREE_TYPE(new_ret), new_ret, ret, BEFORE_STMT);
101728 +}
101729 +
101730 +static void set_plf_false(void)
101731 +{
101732 + basic_block bb;
101733 +
101734 + FOR_ALL_BB(bb) {
101735 + gimple_stmt_iterator si;
101736 +
101737 + for (si = gsi_start_bb(bb); !gsi_end_p(si); gsi_next(&si))
101738 + gimple_set_plf(gsi_stmt(si), MY_STMT, false);
101739 + for (si = gsi_start_phis(bb); !gsi_end_p(si); gsi_next(&si))
101740 + gimple_set_plf(gsi_stmt(si), MY_STMT, false);
101741 + }
101742 +}
101743 +
101744 +static unsigned int handle_function(void)
101745 +{
101746 + basic_block next, bb = ENTRY_BLOCK_PTR->next_bb;
101747 + bool check_ret;
101748 +
101749 + set_plf_false();
101750 +
101751 + check_ret = check_return_value();
101752 +
101753 + do {
101754 + gimple_stmt_iterator gsi;
101755 + next = bb->next_bb;
101756 +
101757 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
101758 + tree fndecl, attr;
101759 + gimple stmt = gsi_stmt(gsi);
101760 +
101761 + if (check_ret)
101762 + handle_return_value(stmt);
101763 +
101764 + if (!(is_gimple_call(stmt)))
101765 + continue;
101766 + fndecl = gimple_call_fndecl(stmt);
101767 + if (fndecl == NULL_TREE)
101768 + continue;
101769 + if (gimple_call_num_args(stmt) == 0)
101770 + continue;
101771 + attr = lookup_attribute("size_overflow", DECL_ATTRIBUTES(fndecl));
101772 + if (!attr || !TREE_VALUE(attr))
101773 + handle_function_by_hash(stmt, fndecl);
101774 + else
101775 + handle_function_by_attribute(stmt, attr, fndecl);
101776 + gsi = gsi_for_stmt(stmt);
101777 + next = gimple_bb(stmt)->next_bb;
101778 + }
101779 + bb = next;
101780 + } while (bb);
101781 + return 0;
101782 +}
101783 +
101784 +static struct gimple_opt_pass size_overflow_pass = {
101785 + .pass = {
101786 + .type = GIMPLE_PASS,
101787 + .name = "size_overflow",
101788 +#if BUILDING_GCC_VERSION >= 4008
101789 + .optinfo_flags = OPTGROUP_NONE,
101790 +#endif
101791 + .gate = NULL,
101792 + .execute = handle_function,
101793 + .sub = NULL,
101794 + .next = NULL,
101795 + .static_pass_number = 0,
101796 + .tv_id = TV_NONE,
101797 + .properties_required = PROP_cfg,
101798 + .properties_provided = 0,
101799 + .properties_destroyed = 0,
101800 + .todo_flags_start = 0,
101801 + .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
101802 + }
101803 +};
101804 +
101805 +static void start_unit_callback(void __unused *gcc_data, void __unused *user_data)
101806 +{
101807 + tree fntype;
101808 +
101809 + const_char_ptr_type_node = build_pointer_type(build_type_variant(char_type_node, 1, 0));
101810 +
101811 + // void report_size_overflow(const char *loc_file, unsigned int loc_line, const char *current_func, const char *ssa_var)
101812 + fntype = build_function_type_list(void_type_node,
101813 + const_char_ptr_type_node,
101814 + unsigned_type_node,
101815 + const_char_ptr_type_node,
101816 + const_char_ptr_type_node,
101817 + NULL_TREE);
101818 + report_size_overflow_decl = build_fn_decl("report_size_overflow", fntype);
101819 +
101820 + DECL_ASSEMBLER_NAME(report_size_overflow_decl);
101821 + TREE_PUBLIC(report_size_overflow_decl) = 1;
101822 + DECL_EXTERNAL(report_size_overflow_decl) = 1;
101823 + DECL_ARTIFICIAL(report_size_overflow_decl) = 1;
101824 + TREE_THIS_VOLATILE(report_size_overflow_decl) = 1;
101825 +}
101826 +
101827 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
101828 +{
101829 + int i;
101830 + const char * const plugin_name = plugin_info->base_name;
101831 + const int argc = plugin_info->argc;
101832 + const struct plugin_argument * const argv = plugin_info->argv;
101833 + bool enable = true;
101834 +
101835 + struct register_pass_info size_overflow_pass_info = {
101836 + .pass = &size_overflow_pass.pass,
101837 + .reference_pass_name = "ssa",
101838 + .ref_pass_instance_number = 1,
101839 + .pos_op = PASS_POS_INSERT_AFTER
101840 + };
101841 +
101842 + if (!plugin_default_version_check(version, &gcc_version)) {
101843 + error(G_("incompatible gcc/plugin versions"));
101844 + return 1;
101845 + }
101846 +
101847 + for (i = 0; i < argc; ++i) {
101848 + if (!strcmp(argv[i].key, "no-size-overflow")) {
101849 + enable = false;
101850 + continue;
101851 + }
101852 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
101853 + }
101854 +
101855 + register_callback(plugin_name, PLUGIN_INFO, NULL, &size_overflow_plugin_info);
101856 + if (enable) {
101857 + register_callback("start_unit", PLUGIN_START_UNIT, &start_unit_callback, NULL);
101858 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &size_overflow_pass_info);
101859 + }
101860 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
101861 +
101862 + return 0;
101863 +}
101864 diff --git a/tools/gcc/stackleak_plugin.c b/tools/gcc/stackleak_plugin.c
101865 new file mode 100644
101866 index 0000000..ac2901e
101867 --- /dev/null
101868 +++ b/tools/gcc/stackleak_plugin.c
101869 @@ -0,0 +1,327 @@
101870 +/*
101871 + * Copyright 2011-2013 by the PaX Team <pageexec@freemail.hu>
101872 + * Licensed under the GPL v2
101873 + *
101874 + * Note: the choice of the license means that the compilation process is
101875 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
101876 + * but for the kernel it doesn't matter since it doesn't link against
101877 + * any of the gcc libraries
101878 + *
101879 + * gcc plugin to help implement various PaX features
101880 + *
101881 + * - track lowest stack pointer
101882 + *
101883 + * TODO:
101884 + * - initialize all local variables
101885 + *
101886 + * BUGS:
101887 + * - none known
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 "flags.h"
101896 +#include "intl.h"
101897 +#include "toplev.h"
101898 +#include "plugin.h"
101899 +//#include "expr.h" where are you...
101900 +#include "diagnostic.h"
101901 +#include "plugin-version.h"
101902 +#include "tm.h"
101903 +#include "function.h"
101904 +#include "basic-block.h"
101905 +#include "gimple.h"
101906 +#include "rtl.h"
101907 +#include "emit-rtl.h"
101908 +
101909 +#if BUILDING_GCC_VERSION >= 4008
101910 +#define TODO_dump_func 0
101911 +#endif
101912 +
101913 +extern void print_gimple_stmt(FILE *, gimple, int, int);
101914 +
101915 +int plugin_is_GPL_compatible;
101916 +
101917 +static int track_frame_size = -1;
101918 +static const char track_function[] = "pax_track_stack";
101919 +static const char check_function[] = "pax_check_alloca";
101920 +static bool init_locals;
101921 +
101922 +static struct plugin_info stackleak_plugin_info = {
101923 + .version = "201302112000",
101924 + .help = "track-lowest-sp=nn\ttrack sp in functions whose frame size is at least nn bytes\n"
101925 +// "initialize-locals\t\tforcibly initialize all stack frames\n"
101926 +};
101927 +
101928 +static bool gate_stackleak_track_stack(void);
101929 +static unsigned int execute_stackleak_tree_instrument(void);
101930 +static unsigned int execute_stackleak_final(void);
101931 +
101932 +static struct gimple_opt_pass stackleak_tree_instrument_pass = {
101933 + .pass = {
101934 + .type = GIMPLE_PASS,
101935 + .name = "stackleak_tree_instrument",
101936 +#if BUILDING_GCC_VERSION >= 4008
101937 + .optinfo_flags = OPTGROUP_NONE,
101938 +#endif
101939 + .gate = gate_stackleak_track_stack,
101940 + .execute = execute_stackleak_tree_instrument,
101941 + .sub = NULL,
101942 + .next = NULL,
101943 + .static_pass_number = 0,
101944 + .tv_id = TV_NONE,
101945 + .properties_required = PROP_gimple_leh | PROP_cfg,
101946 + .properties_provided = 0,
101947 + .properties_destroyed = 0,
101948 + .todo_flags_start = 0, //TODO_verify_ssa | TODO_verify_flow | TODO_verify_stmts,
101949 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_update_ssa
101950 + }
101951 +};
101952 +
101953 +static struct rtl_opt_pass stackleak_final_rtl_opt_pass = {
101954 + .pass = {
101955 + .type = RTL_PASS,
101956 + .name = "stackleak_final",
101957 +#if BUILDING_GCC_VERSION >= 4008
101958 + .optinfo_flags = OPTGROUP_NONE,
101959 +#endif
101960 + .gate = gate_stackleak_track_stack,
101961 + .execute = execute_stackleak_final,
101962 + .sub = NULL,
101963 + .next = NULL,
101964 + .static_pass_number = 0,
101965 + .tv_id = TV_NONE,
101966 + .properties_required = 0,
101967 + .properties_provided = 0,
101968 + .properties_destroyed = 0,
101969 + .todo_flags_start = 0,
101970 + .todo_flags_finish = TODO_dump_func
101971 + }
101972 +};
101973 +
101974 +static bool gate_stackleak_track_stack(void)
101975 +{
101976 + return track_frame_size >= 0;
101977 +}
101978 +
101979 +static void stackleak_check_alloca(gimple_stmt_iterator *gsi)
101980 +{
101981 + gimple check_alloca;
101982 + tree fntype, fndecl, alloca_size;
101983 +
101984 + fntype = build_function_type_list(void_type_node, long_unsigned_type_node, NULL_TREE);
101985 + fndecl = build_fn_decl(check_function, fntype);
101986 + DECL_ASSEMBLER_NAME(fndecl); // for LTO
101987 +
101988 + // insert call to void pax_check_alloca(unsigned long size)
101989 + alloca_size = gimple_call_arg(gsi_stmt(*gsi), 0);
101990 + check_alloca = gimple_build_call(fndecl, 1, alloca_size);
101991 + gsi_insert_before(gsi, check_alloca, GSI_SAME_STMT);
101992 +}
101993 +
101994 +static void stackleak_add_instrumentation(gimple_stmt_iterator *gsi)
101995 +{
101996 + gimple track_stack;
101997 + tree fntype, fndecl;
101998 +
101999 + fntype = build_function_type_list(void_type_node, NULL_TREE);
102000 + fndecl = build_fn_decl(track_function, fntype);
102001 + DECL_ASSEMBLER_NAME(fndecl); // for LTO
102002 +
102003 + // insert call to void pax_track_stack(void)
102004 + track_stack = gimple_build_call(fndecl, 0);
102005 + gsi_insert_after(gsi, track_stack, GSI_CONTINUE_LINKING);
102006 +}
102007 +
102008 +#if BUILDING_GCC_VERSION == 4005
102009 +static bool gimple_call_builtin_p(gimple stmt, enum built_in_function code)
102010 +{
102011 + tree fndecl;
102012 +
102013 + if (!is_gimple_call(stmt))
102014 + return false;
102015 + fndecl = gimple_call_fndecl(stmt);
102016 + if (!fndecl)
102017 + return false;
102018 + if (DECL_BUILT_IN_CLASS(fndecl) != BUILT_IN_NORMAL)
102019 + return false;
102020 +// print_node(stderr, "pax", fndecl, 4);
102021 + return DECL_FUNCTION_CODE(fndecl) == code;
102022 +}
102023 +#endif
102024 +
102025 +static bool is_alloca(gimple stmt)
102026 +{
102027 + if (gimple_call_builtin_p(stmt, BUILT_IN_ALLOCA))
102028 + return true;
102029 +
102030 +#if BUILDING_GCC_VERSION >= 4007
102031 + if (gimple_call_builtin_p(stmt, BUILT_IN_ALLOCA_WITH_ALIGN))
102032 + return true;
102033 +#endif
102034 +
102035 + return false;
102036 +}
102037 +
102038 +static unsigned int execute_stackleak_tree_instrument(void)
102039 +{
102040 + basic_block bb, entry_bb;
102041 + bool prologue_instrumented = false, is_leaf = true;
102042 +
102043 + entry_bb = ENTRY_BLOCK_PTR_FOR_FUNCTION(cfun)->next_bb;
102044 +
102045 + // 1. loop through BBs and GIMPLE statements
102046 + FOR_EACH_BB(bb) {
102047 + gimple_stmt_iterator gsi;
102048 +
102049 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
102050 + gimple stmt;
102051 +
102052 + stmt = gsi_stmt(gsi);
102053 +
102054 + if (is_gimple_call(stmt))
102055 + is_leaf = false;
102056 +
102057 + // gimple match: align 8 built-in BUILT_IN_NORMAL:BUILT_IN_ALLOCA attributes <tree_list 0xb7576450>
102058 + if (!is_alloca(stmt))
102059 + continue;
102060 +
102061 + // 2. insert stack overflow check before each __builtin_alloca call
102062 + stackleak_check_alloca(&gsi);
102063 +
102064 + // 3. insert track call after each __builtin_alloca call
102065 + stackleak_add_instrumentation(&gsi);
102066 + if (bb == entry_bb)
102067 + prologue_instrumented = true;
102068 + }
102069 + }
102070 +
102071 + // special cases for some bad linux code: taking the address of static inline functions will materialize them
102072 + // but we mustn't instrument some of them as the resulting stack alignment required by the function call ABI
102073 + // will break other assumptions regarding the expected (but not otherwise enforced) register clobbering ABI.
102074 + // case in point: native_save_fl on amd64 when optimized for size clobbers rdx if it were instrumented here.
102075 + if (is_leaf && !TREE_PUBLIC(current_function_decl) && DECL_DECLARED_INLINE_P(current_function_decl))
102076 + return 0;
102077 + if (is_leaf && !strncmp(IDENTIFIER_POINTER(DECL_NAME(current_function_decl)), "_paravirt_", 10))
102078 + return 0;
102079 +
102080 + // 4. insert track call at the beginning
102081 + if (!prologue_instrumented) {
102082 + gimple_stmt_iterator gsi;
102083 +
102084 + bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
102085 + if (dom_info_available_p(CDI_DOMINATORS))
102086 + set_immediate_dominator(CDI_DOMINATORS, bb, ENTRY_BLOCK_PTR);
102087 + gsi = gsi_start_bb(bb);
102088 + stackleak_add_instrumentation(&gsi);
102089 + }
102090 +
102091 + return 0;
102092 +}
102093 +
102094 +static unsigned int execute_stackleak_final(void)
102095 +{
102096 + rtx insn, next;
102097 +
102098 + if (cfun->calls_alloca)
102099 + return 0;
102100 +
102101 + // keep calls only if function frame is big enough
102102 + if (get_frame_size() >= track_frame_size)
102103 + return 0;
102104 +
102105 + // 1. find pax_track_stack calls
102106 + for (insn = get_insns(); insn; insn = next) {
102107 + // 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))
102108 + rtx body;
102109 +
102110 + next = NEXT_INSN(insn);
102111 + if (!CALL_P(insn))
102112 + continue;
102113 + body = PATTERN(insn);
102114 + if (GET_CODE(body) != CALL)
102115 + continue;
102116 + body = XEXP(body, 0);
102117 + if (GET_CODE(body) != MEM)
102118 + continue;
102119 + body = XEXP(body, 0);
102120 + if (GET_CODE(body) != SYMBOL_REF)
102121 + continue;
102122 + if (strcmp(XSTR(body, 0), track_function))
102123 + continue;
102124 +// warning(0, "track_frame_size: %d %ld %d", cfun->calls_alloca, get_frame_size(), track_frame_size);
102125 + // 2. delete call
102126 + delete_insn_and_edges(insn);
102127 +#if BUILDING_GCC_VERSION >= 4007
102128 + if (GET_CODE(next) == NOTE && NOTE_KIND(next) == NOTE_INSN_CALL_ARG_LOCATION) {
102129 + insn = next;
102130 + next = NEXT_INSN(insn);
102131 + delete_insn_and_edges(insn);
102132 + }
102133 +#endif
102134 + }
102135 +
102136 +// print_simple_rtl(stderr, get_insns());
102137 +// print_rtl(stderr, get_insns());
102138 +// warning(0, "track_frame_size: %d %ld %d", cfun->calls_alloca, get_frame_size(), track_frame_size);
102139 +
102140 + return 0;
102141 +}
102142 +
102143 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
102144 +{
102145 + const char * const plugin_name = plugin_info->base_name;
102146 + const int argc = plugin_info->argc;
102147 + const struct plugin_argument * const argv = plugin_info->argv;
102148 + int i;
102149 + struct register_pass_info stackleak_tree_instrument_pass_info = {
102150 + .pass = &stackleak_tree_instrument_pass.pass,
102151 +// .reference_pass_name = "tree_profile",
102152 + .reference_pass_name = "optimized",
102153 + .ref_pass_instance_number = 1,
102154 + .pos_op = PASS_POS_INSERT_BEFORE
102155 + };
102156 + struct register_pass_info stackleak_final_pass_info = {
102157 + .pass = &stackleak_final_rtl_opt_pass.pass,
102158 + .reference_pass_name = "final",
102159 + .ref_pass_instance_number = 1,
102160 + .pos_op = PASS_POS_INSERT_BEFORE
102161 + };
102162 +
102163 + if (!plugin_default_version_check(version, &gcc_version)) {
102164 + error(G_("incompatible gcc/plugin versions"));
102165 + return 1;
102166 + }
102167 +
102168 + register_callback(plugin_name, PLUGIN_INFO, NULL, &stackleak_plugin_info);
102169 +
102170 + for (i = 0; i < argc; ++i) {
102171 + if (!strcmp(argv[i].key, "track-lowest-sp")) {
102172 + if (!argv[i].value) {
102173 + error(G_("no value supplied for option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
102174 + continue;
102175 + }
102176 + track_frame_size = atoi(argv[i].value);
102177 + if (argv[i].value[0] < '0' || argv[i].value[0] > '9' || track_frame_size < 0)
102178 + error(G_("invalid option argument '-fplugin-arg-%s-%s=%s'"), plugin_name, argv[i].key, argv[i].value);
102179 + continue;
102180 + }
102181 + if (!strcmp(argv[i].key, "initialize-locals")) {
102182 + if (argv[i].value) {
102183 + error(G_("invalid option argument '-fplugin-arg-%s-%s=%s'"), plugin_name, argv[i].key, argv[i].value);
102184 + continue;
102185 + }
102186 + init_locals = true;
102187 + continue;
102188 + }
102189 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
102190 + }
102191 +
102192 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &stackleak_tree_instrument_pass_info);
102193 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &stackleak_final_pass_info);
102194 +
102195 + return 0;
102196 +}
102197 diff --git a/tools/perf/util/include/asm/alternative-asm.h b/tools/perf/util/include/asm/alternative-asm.h
102198 index 6789d78..4afd019e 100644
102199 --- a/tools/perf/util/include/asm/alternative-asm.h
102200 +++ b/tools/perf/util/include/asm/alternative-asm.h
102201 @@ -5,4 +5,7 @@
102202
102203 #define altinstruction_entry #
102204
102205 + .macro pax_force_retaddr rip=0, reload=0
102206 + .endm
102207 +
102208 #endif
102209 diff --git a/virt/kvm/ioapic.c b/virt/kvm/ioapic.c
102210 index cfb7e4d..52058f0 100644
102211 --- a/virt/kvm/ioapic.c
102212 +++ b/virt/kvm/ioapic.c
102213 @@ -73,9 +73,12 @@ static unsigned long ioapic_read_indirect(struct kvm_ioapic *ioapic,
102214 u32 redir_index = (ioapic->ioregsel - 0x10) >> 1;
102215 u64 redir_content;
102216
102217 - ASSERT(redir_index < IOAPIC_NUM_PINS);
102218 + if (redir_index < IOAPIC_NUM_PINS)
102219 + redir_content =
102220 + ioapic->redirtbl[redir_index].bits;
102221 + else
102222 + redir_content = ~0ULL;
102223
102224 - redir_content = ioapic->redirtbl[redir_index].bits;
102225 result = (ioapic->ioregsel & 0x1) ?
102226 (redir_content >> 32) & 0xffffffff :
102227 redir_content & 0xffffffff;
102228 diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
102229 index 1cd693a..f4a7b20 100644
102230 --- a/virt/kvm/kvm_main.c
102231 +++ b/virt/kvm/kvm_main.c
102232 @@ -75,12 +75,17 @@ LIST_HEAD(vm_list);
102233
102234 static cpumask_var_t cpus_hardware_enabled;
102235 static int kvm_usage_count = 0;
102236 -static atomic_t hardware_enable_failed;
102237 +static atomic_unchecked_t hardware_enable_failed;
102238
102239 struct kmem_cache *kvm_vcpu_cache;
102240 EXPORT_SYMBOL_GPL(kvm_vcpu_cache);
102241
102242 -static __read_mostly struct preempt_ops kvm_preempt_ops;
102243 +static void kvm_sched_in(struct preempt_notifier *pn, int cpu);
102244 +static void kvm_sched_out(struct preempt_notifier *pn, struct task_struct *next);
102245 +static struct preempt_ops kvm_preempt_ops = {
102246 + .sched_in = kvm_sched_in,
102247 + .sched_out = kvm_sched_out,
102248 +};
102249
102250 struct dentry *kvm_debugfs_dir;
102251
102252 @@ -731,7 +736,7 @@ int __kvm_set_memory_region(struct kvm *kvm,
102253 /* We can read the guest memory with __xxx_user() later on. */
102254 if (user_alloc &&
102255 ((mem->userspace_addr & (PAGE_SIZE - 1)) ||
102256 - !access_ok(VERIFY_WRITE,
102257 + !__access_ok(VERIFY_WRITE,
102258 (void __user *)(unsigned long)mem->userspace_addr,
102259 mem->memory_size)))
102260 goto out;
102261 @@ -1783,7 +1788,7 @@ static int kvm_vcpu_release(struct inode *inode, struct file *filp)
102262 return 0;
102263 }
102264
102265 -static struct file_operations kvm_vcpu_fops = {
102266 +static file_operations_no_const kvm_vcpu_fops __read_only = {
102267 .release = kvm_vcpu_release,
102268 .unlocked_ioctl = kvm_vcpu_ioctl,
102269 #ifdef CONFIG_COMPAT
102270 @@ -2304,7 +2309,7 @@ static int kvm_vm_mmap(struct file *file, struct vm_area_struct *vma)
102271 return 0;
102272 }
102273
102274 -static struct file_operations kvm_vm_fops = {
102275 +static file_operations_no_const kvm_vm_fops __read_only = {
102276 .release = kvm_vm_release,
102277 .unlocked_ioctl = kvm_vm_ioctl,
102278 #ifdef CONFIG_COMPAT
102279 @@ -2402,7 +2407,7 @@ out:
102280 return r;
102281 }
102282
102283 -static struct file_operations kvm_chardev_ops = {
102284 +static file_operations_no_const kvm_chardev_ops __read_only = {
102285 .unlocked_ioctl = kvm_dev_ioctl,
102286 .compat_ioctl = kvm_dev_ioctl,
102287 .llseek = noop_llseek,
102288 @@ -2428,7 +2433,7 @@ static void hardware_enable_nolock(void *junk)
102289
102290 if (r) {
102291 cpumask_clear_cpu(cpu, cpus_hardware_enabled);
102292 - atomic_inc(&hardware_enable_failed);
102293 + atomic_inc_unchecked(&hardware_enable_failed);
102294 printk(KERN_INFO "kvm: enabling virtualization on "
102295 "CPU%d failed\n", cpu);
102296 }
102297 @@ -2482,10 +2487,10 @@ static int hardware_enable_all(void)
102298
102299 kvm_usage_count++;
102300 if (kvm_usage_count == 1) {
102301 - atomic_set(&hardware_enable_failed, 0);
102302 + atomic_set_unchecked(&hardware_enable_failed, 0);
102303 on_each_cpu(hardware_enable_nolock, NULL, 1);
102304
102305 - if (atomic_read(&hardware_enable_failed)) {
102306 + if (atomic_read_unchecked(&hardware_enable_failed)) {
102307 hardware_disable_all_nolock();
102308 r = -EBUSY;
102309 }
102310 @@ -2843,7 +2848,7 @@ static void kvm_sched_out(struct preempt_notifier *pn,
102311 kvm_arch_vcpu_put(vcpu);
102312 }
102313
102314 -int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
102315 +int kvm_init(const void *opaque, unsigned vcpu_size, unsigned vcpu_align,
102316 struct module *module)
102317 {
102318 int r;
102319 @@ -2879,7 +2884,7 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
102320 if (!vcpu_align)
102321 vcpu_align = __alignof__(struct kvm_vcpu);
102322 kvm_vcpu_cache = kmem_cache_create("kvm_vcpu", vcpu_size, vcpu_align,
102323 - 0, NULL);
102324 + SLAB_USERCOPY, NULL);
102325 if (!kvm_vcpu_cache) {
102326 r = -ENOMEM;
102327 goto out_free_3;
102328 @@ -2889,9 +2894,11 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
102329 if (r)
102330 goto out_free;
102331
102332 + pax_open_kernel();
102333 kvm_chardev_ops.owner = module;
102334 kvm_vm_fops.owner = module;
102335 kvm_vcpu_fops.owner = module;
102336 + pax_close_kernel();
102337
102338 r = misc_register(&kvm_dev);
102339 if (r) {
102340 @@ -2901,9 +2908,6 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
102341
102342 register_syscore_ops(&kvm_syscore_ops);
102343
102344 - kvm_preempt_ops.sched_in = kvm_sched_in;
102345 - kvm_preempt_ops.sched_out = kvm_sched_out;
102346 -
102347 r = kvm_init_debug();
102348 if (r) {
102349 printk(KERN_ERR "kvm: create debugfs files failed\n");