]> git.ipfire.org Git - thirdparty/grsecurity-scrape.git/blob - test/grsecurity-2.9.1-3.8.3-201303191846.patch
Auto commit, 1 new patch{es}.
[thirdparty/grsecurity-scrape.git] / test / grsecurity-2.9.1-3.8.3-201303191846.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 8c49fc9b..3576922 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..e16ab04 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,58 @@ 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 +<<<<<<< HEAD
3731 + if (!user_mode(regs) && (is_domain_fault(ifsr) || is_xn_fault(ifsr))) {
3732 + if (current->signal->curr_ip)
3733 + 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),
3734 + from_kuid(&init_user_ns, current_uid()), from_kuid(&init_user_ns, current_euid()),
3735 + addr >= TASK_SIZE ? "non-executable kernel" : "userland", addr);
3736 + else
3737 + printk(KERN_ERR "PAX: %s:%d, uid/euid: %u/%u, attempted to execute %s memory at %08lx\n", current->comm, task_pid_nr(current),
3738 + from_kuid(&init_user_ns, current_uid()), from_kuid(&init_user_ns, current_euid()),
3739 + addr >= TASK_SIZE ? "non-executable kernel" : "userland", addr);
3740 +=======
3741 + else if (is_domain_fault(ifsr) || is_xn_fault(ifsr)) {
3742 + printk(KERN_ERR "PAX: %s:%d, uid/euid: %u/%u, attempted to execute %s memory at %08lx\n",
3743 + current->comm, task_pid_nr(current),
3744 + from_kuid_munged(&init_user_ns, current_uid()),
3745 + from_kuid_munged(&init_user_ns, current_euid()),
3746 + addr >= TASK_SIZE ? "non-executable kernel" : "userland", addr);
3747 +>>>>>>> c57d8557f5f2d77c2c7fa1f58316819a5e1f9293
3748 + goto die;
3749 + }
3750 +#endif
3751 +
3752 +#ifdef CONFIG_PAX_REFCOUNT
3753 + if (fsr_fs(ifsr) == FAULT_CODE_DEBUG) {
3754 + unsigned int bkpt;
3755 +
3756 + if (!probe_kernel_address((unsigned int *)addr, bkpt) && bkpt == 0xe12f1073) {
3757 + current->thread.error_code = ifsr;
3758 + current->thread.trap_no = 0;
3759 + pax_report_refcount_overflow(regs);
3760 + fixup_exception(regs);
3761 + return;
3762 + }
3763 + }
3764 +#endif
3765 +
3766 if (!inf->fn(addr, ifsr | FSR_LNX_PF, regs))
3767 return;
3768
3769 +die:
3770 printk(KERN_ALERT "Unhandled prefetch abort: %s (0x%03x) at 0x%08lx\n",
3771 inf->name, ifsr, addr);
3772
3773 diff --git a/arch/arm/mm/fault.h b/arch/arm/mm/fault.h
3774 index cf08bdf..772656c 100644
3775 --- a/arch/arm/mm/fault.h
3776 +++ b/arch/arm/mm/fault.h
3777 @@ -3,6 +3,7 @@
3778
3779 /*
3780 * Fault status register encodings. We steal bit 31 for our own purposes.
3781 + * Set when the FSR value is from an instruction fault.
3782 */
3783 #define FSR_LNX_PF (1 << 31)
3784 #define FSR_WRITE (1 << 11)
3785 @@ -22,6 +23,17 @@ static inline int fsr_fs(unsigned int fsr)
3786 }
3787 #endif
3788
3789 +/* valid for LPAE and !LPAE */
3790 +static inline int is_xn_fault(unsigned int fsr)
3791 +{
3792 + return ((fsr_fs(fsr) & 0x3c) == 0xc);
3793 +}
3794 +
3795 +static inline int is_domain_fault(unsigned int fsr)
3796 +{
3797 + return ((fsr_fs(fsr) & 0xD) == 0x9);
3798 +}
3799 +
3800 void do_bad_area(unsigned long addr, unsigned int fsr, struct pt_regs *regs);
3801 unsigned long search_exception_table(unsigned long addr);
3802
3803 diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c
3804 index ad722f1..763fdd3 100644
3805 --- a/arch/arm/mm/init.c
3806 +++ b/arch/arm/mm/init.c
3807 @@ -30,6 +30,8 @@
3808 #include <asm/setup.h>
3809 #include <asm/tlb.h>
3810 #include <asm/fixmap.h>
3811 +#include <asm/system_info.h>
3812 +#include <asm/cp15.h>
3813
3814 #include <asm/mach/arch.h>
3815 #include <asm/mach/map.h>
3816 @@ -736,7 +738,46 @@ void free_initmem(void)
3817 {
3818 #ifdef CONFIG_HAVE_TCM
3819 extern char __tcm_start, __tcm_end;
3820 +#endif
3821
3822 +#ifdef CONFIG_PAX_KERNEXEC
3823 + unsigned long addr;
3824 + pgd_t *pgd;
3825 + pud_t *pud;
3826 + pmd_t *pmd;
3827 + int cpu_arch = cpu_architecture();
3828 + unsigned int cr = get_cr();
3829 +
3830 + if (cpu_arch >= CPU_ARCH_ARMv6 && (cr & CR_XP)) {
3831 + /* make pages tables, etc before .text NX */
3832 + for (addr = PAGE_OFFSET; addr < (unsigned long)_stext; addr += SECTION_SIZE) {
3833 + pgd = pgd_offset_k(addr);
3834 + pud = pud_offset(pgd, addr);
3835 + pmd = pmd_offset(pud, addr);
3836 + __section_update(pmd, addr, PMD_SECT_XN);
3837 + }
3838 + /* make init NX */
3839 + for (addr = (unsigned long)__init_begin; addr < (unsigned long)_sdata; addr += SECTION_SIZE) {
3840 + pgd = pgd_offset_k(addr);
3841 + pud = pud_offset(pgd, addr);
3842 + pmd = pmd_offset(pud, addr);
3843 + __section_update(pmd, addr, PMD_SECT_XN);
3844 + }
3845 + /* make kernel code/rodata RX */
3846 + for (addr = (unsigned long)_stext; addr < (unsigned long)__init_begin; addr += SECTION_SIZE) {
3847 + pgd = pgd_offset_k(addr);
3848 + pud = pud_offset(pgd, addr);
3849 + pmd = pmd_offset(pud, addr);
3850 +#ifdef CONFIG_ARM_LPAE
3851 + __section_update(pmd, addr, PMD_SECT_RDONLY);
3852 +#else
3853 + __section_update(pmd, addr, PMD_SECT_APX|PMD_SECT_AP_WRITE);
3854 +#endif
3855 + }
3856 + }
3857 +#endif
3858 +
3859 +#ifdef CONFIG_HAVE_TCM
3860 poison_init_mem(&__tcm_start, &__tcm_end - &__tcm_start);
3861 totalram_pages += free_area(__phys_to_pfn(__pa(&__tcm_start)),
3862 __phys_to_pfn(__pa(&__tcm_end)),
3863 diff --git a/arch/arm/mm/ioremap.c b/arch/arm/mm/ioremap.c
3864 index 88fd86c..7a224ce 100644
3865 --- a/arch/arm/mm/ioremap.c
3866 +++ b/arch/arm/mm/ioremap.c
3867 @@ -335,9 +335,9 @@ __arm_ioremap_exec(unsigned long phys_addr, size_t size, bool cached)
3868 unsigned int mtype;
3869
3870 if (cached)
3871 - mtype = MT_MEMORY;
3872 + mtype = MT_MEMORY_RX;
3873 else
3874 - mtype = MT_MEMORY_NONCACHED;
3875 + mtype = MT_MEMORY_NONCACHED_RX;
3876
3877 return __arm_ioremap_caller(phys_addr, size, mtype,
3878 __builtin_return_address(0));
3879 diff --git a/arch/arm/mm/mmap.c b/arch/arm/mm/mmap.c
3880 index 10062ce..aa96dd7 100644
3881 --- a/arch/arm/mm/mmap.c
3882 +++ b/arch/arm/mm/mmap.c
3883 @@ -59,6 +59,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
3884 struct vm_area_struct *vma;
3885 int do_align = 0;
3886 int aliasing = cache_is_vipt_aliasing();
3887 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
3888 struct vm_unmapped_area_info info;
3889
3890 /*
3891 @@ -81,6 +82,10 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
3892 if (len > TASK_SIZE)
3893 return -ENOMEM;
3894
3895 +#ifdef CONFIG_PAX_RANDMMAP
3896 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
3897 +#endif
3898 +
3899 if (addr) {
3900 if (do_align)
3901 addr = COLOUR_ALIGN(addr, pgoff);
3902 @@ -88,8 +93,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
3903 addr = PAGE_ALIGN(addr);
3904
3905 vma = find_vma(mm, addr);
3906 - if (TASK_SIZE - len >= addr &&
3907 - (!vma || addr + len <= vma->vm_start))
3908 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
3909 return addr;
3910 }
3911
3912 @@ -112,6 +116,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
3913 unsigned long addr = addr0;
3914 int do_align = 0;
3915 int aliasing = cache_is_vipt_aliasing();
3916 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
3917 struct vm_unmapped_area_info info;
3918
3919 /*
3920 @@ -132,6 +137,10 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
3921 return addr;
3922 }
3923
3924 +#ifdef CONFIG_PAX_RANDMMAP
3925 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
3926 +#endif
3927 +
3928 /* requesting a specific address */
3929 if (addr) {
3930 if (do_align)
3931 @@ -139,8 +148,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
3932 else
3933 addr = PAGE_ALIGN(addr);
3934 vma = find_vma(mm, addr);
3935 - if (TASK_SIZE - len >= addr &&
3936 - (!vma || addr + len <= vma->vm_start))
3937 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
3938 return addr;
3939 }
3940
3941 @@ -162,6 +170,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
3942 VM_BUG_ON(addr != -ENOMEM);
3943 info.flags = 0;
3944 info.low_limit = mm->mmap_base;
3945 +
3946 +#ifdef CONFIG_PAX_RANDMMAP
3947 + if (mm->pax_flags & MF_PAX_RANDMMAP)
3948 + info.low_limit += mm->delta_mmap;
3949 +#endif
3950 +
3951 info.high_limit = TASK_SIZE;
3952 addr = vm_unmapped_area(&info);
3953 }
3954 @@ -173,6 +187,10 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
3955 {
3956 unsigned long random_factor = 0UL;
3957
3958 +#ifdef CONFIG_PAX_RANDMMAP
3959 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
3960 +#endif
3961 +
3962 /* 8 bits of randomness in 20 address space bits */
3963 if ((current->flags & PF_RANDOMIZE) &&
3964 !(current->personality & ADDR_NO_RANDOMIZE))
3965 @@ -180,10 +198,22 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
3966
3967 if (mmap_is_legacy()) {
3968 mm->mmap_base = TASK_UNMAPPED_BASE + random_factor;
3969 +
3970 +#ifdef CONFIG_PAX_RANDMMAP
3971 + if (mm->pax_flags & MF_PAX_RANDMMAP)
3972 + mm->mmap_base += mm->delta_mmap;
3973 +#endif
3974 +
3975 mm->get_unmapped_area = arch_get_unmapped_area;
3976 mm->unmap_area = arch_unmap_area;
3977 } else {
3978 mm->mmap_base = mmap_base(random_factor);
3979 +
3980 +#ifdef CONFIG_PAX_RANDMMAP
3981 + if (mm->pax_flags & MF_PAX_RANDMMAP)
3982 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
3983 +#endif
3984 +
3985 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
3986 mm->unmap_area = arch_unmap_area_topdown;
3987 }
3988 diff --git a/arch/arm/mm/mmu.c b/arch/arm/mm/mmu.c
3989 index ce328c7..35b88dc 100644
3990 --- a/arch/arm/mm/mmu.c
3991 +++ b/arch/arm/mm/mmu.c
3992 @@ -35,6 +35,23 @@
3993
3994 #include "mm.h"
3995
3996 +
3997 +#if defined(CONFIG_CPU_USE_DOMAINS) || defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
3998 +void modify_domain(unsigned int dom, unsigned int type)
3999 +{
4000 + struct thread_info *thread = current_thread_info();
4001 + unsigned int domain = thread->cpu_domain;
4002 + /*
4003 + * DOMAIN_MANAGER might be defined to some other value,
4004 + * use the arch-defined constant
4005 + */
4006 + domain &= ~domain_val(dom, 3);
4007 + thread->cpu_domain = domain | domain_val(dom, type);
4008 + set_domain(thread->cpu_domain);
4009 +}
4010 +EXPORT_SYMBOL(modify_domain);
4011 +#endif
4012 +
4013 /*
4014 * empty_zero_page is a special page that is used for
4015 * zero-initialized data and COW.
4016 @@ -195,10 +212,18 @@ void adjust_cr(unsigned long mask, unsigned long set)
4017 }
4018 #endif
4019
4020 -#define PROT_PTE_DEVICE L_PTE_PRESENT|L_PTE_YOUNG|L_PTE_DIRTY|L_PTE_XN
4021 +#define PROT_PTE_DEVICE L_PTE_PRESENT|L_PTE_YOUNG|L_PTE_DIRTY
4022 #define PROT_SECT_DEVICE PMD_TYPE_SECT|PMD_SECT_AP_WRITE
4023
4024 -static struct mem_type mem_types[] = {
4025 +#ifdef CONFIG_PAX_KERNEXEC
4026 +#define L_PTE_KERNEXEC L_PTE_RDONLY
4027 +#define PMD_SECT_KERNEXEC PMD_SECT_RDONLY
4028 +#else
4029 +#define L_PTE_KERNEXEC L_PTE_DIRTY
4030 +#define PMD_SECT_KERNEXEC PMD_SECT_AP_WRITE
4031 +#endif
4032 +
4033 +static struct mem_type mem_types[] __read_only = {
4034 [MT_DEVICE] = { /* Strongly ordered / ARMv6 shared device */
4035 .prot_pte = PROT_PTE_DEVICE | L_PTE_MT_DEV_SHARED |
4036 L_PTE_SHARED,
4037 @@ -227,16 +252,16 @@ static struct mem_type mem_types[] = {
4038 [MT_UNCACHED] = {
4039 .prot_pte = PROT_PTE_DEVICE,
4040 .prot_l1 = PMD_TYPE_TABLE,
4041 - .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN,
4042 + .prot_sect = PROT_SECT_DEVICE,
4043 .domain = DOMAIN_IO,
4044 },
4045 [MT_CACHECLEAN] = {
4046 - .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN,
4047 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_RDONLY,
4048 .domain = DOMAIN_KERNEL,
4049 },
4050 #ifndef CONFIG_ARM_LPAE
4051 [MT_MINICLEAN] = {
4052 - .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN | PMD_SECT_MINICACHE,
4053 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_MINICACHE | PMD_SECT_RDONLY,
4054 .domain = DOMAIN_KERNEL,
4055 },
4056 #endif
4057 @@ -244,36 +269,54 @@ static struct mem_type mem_types[] = {
4058 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4059 L_PTE_RDONLY,
4060 .prot_l1 = PMD_TYPE_TABLE,
4061 - .domain = DOMAIN_USER,
4062 + .domain = DOMAIN_VECTORS,
4063 },
4064 [MT_HIGH_VECTORS] = {
4065 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4066 - L_PTE_USER | L_PTE_RDONLY,
4067 + L_PTE_RDONLY,
4068 .prot_l1 = PMD_TYPE_TABLE,
4069 - .domain = DOMAIN_USER,
4070 + .domain = DOMAIN_VECTORS,
4071 },
4072 - [MT_MEMORY] = {
4073 + [MT_MEMORY_RWX] = {
4074 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY,
4075 .prot_l1 = PMD_TYPE_TABLE,
4076 .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE,
4077 .domain = DOMAIN_KERNEL,
4078 },
4079 + [MT_MEMORY_RW] = {
4080 + .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY,
4081 + .prot_l1 = PMD_TYPE_TABLE,
4082 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE,
4083 + .domain = DOMAIN_KERNEL,
4084 + },
4085 + [MT_MEMORY_RX] = {
4086 + .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_KERNEXEC,
4087 + .prot_l1 = PMD_TYPE_TABLE,
4088 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_KERNEXEC,
4089 + .domain = DOMAIN_KERNEL,
4090 + },
4091 [MT_ROM] = {
4092 - .prot_sect = PMD_TYPE_SECT,
4093 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_RDONLY,
4094 .domain = DOMAIN_KERNEL,
4095 },
4096 - [MT_MEMORY_NONCACHED] = {
4097 + [MT_MEMORY_NONCACHED_RW] = {
4098 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4099 L_PTE_MT_BUFFERABLE,
4100 .prot_l1 = PMD_TYPE_TABLE,
4101 .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE,
4102 .domain = DOMAIN_KERNEL,
4103 },
4104 + [MT_MEMORY_NONCACHED_RX] = {
4105 + .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_KERNEXEC |
4106 + L_PTE_MT_BUFFERABLE,
4107 + .prot_l1 = PMD_TYPE_TABLE,
4108 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_KERNEXEC,
4109 + .domain = DOMAIN_KERNEL,
4110 + },
4111 [MT_MEMORY_DTCM] = {
4112 - .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4113 - L_PTE_XN,
4114 + .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY,
4115 .prot_l1 = PMD_TYPE_TABLE,
4116 - .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN,
4117 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_RDONLY,
4118 .domain = DOMAIN_KERNEL,
4119 },
4120 [MT_MEMORY_ITCM] = {
4121 @@ -283,10 +326,10 @@ static struct mem_type mem_types[] = {
4122 },
4123 [MT_MEMORY_SO] = {
4124 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4125 - L_PTE_MT_UNCACHED | L_PTE_XN,
4126 + L_PTE_MT_UNCACHED,
4127 .prot_l1 = PMD_TYPE_TABLE,
4128 .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE | PMD_SECT_S |
4129 - PMD_SECT_UNCACHED | PMD_SECT_XN,
4130 + PMD_SECT_UNCACHED,
4131 .domain = DOMAIN_KERNEL,
4132 },
4133 [MT_MEMORY_DMA_READY] = {
4134 @@ -371,9 +414,35 @@ static void __init build_mem_type_table(void)
4135 * to prevent speculative instruction fetches.
4136 */
4137 mem_types[MT_DEVICE].prot_sect |= PMD_SECT_XN;
4138 + mem_types[MT_DEVICE].prot_pte |= L_PTE_XN;
4139 mem_types[MT_DEVICE_NONSHARED].prot_sect |= PMD_SECT_XN;
4140 + mem_types[MT_DEVICE_NONSHARED].prot_pte |= L_PTE_XN;
4141 mem_types[MT_DEVICE_CACHED].prot_sect |= PMD_SECT_XN;
4142 + mem_types[MT_DEVICE_CACHED].prot_pte |= L_PTE_XN;
4143 mem_types[MT_DEVICE_WC].prot_sect |= PMD_SECT_XN;
4144 + mem_types[MT_DEVICE_WC].prot_pte |= L_PTE_XN;
4145 +
4146 + /* Mark other regions on ARMv6+ as execute-never */
4147 +
4148 +#ifdef CONFIG_PAX_KERNEXEC
4149 + mem_types[MT_UNCACHED].prot_sect |= PMD_SECT_XN;
4150 + mem_types[MT_UNCACHED].prot_pte |= L_PTE_XN;
4151 + mem_types[MT_CACHECLEAN].prot_sect |= PMD_SECT_XN;
4152 + mem_types[MT_CACHECLEAN].prot_pte |= L_PTE_XN;
4153 +#ifndef CONFIG_ARM_LPAE
4154 + mem_types[MT_MINICLEAN].prot_sect |= PMD_SECT_XN;
4155 + mem_types[MT_MINICLEAN].prot_pte |= L_PTE_XN;
4156 +#endif
4157 + mem_types[MT_MEMORY_RW].prot_sect |= PMD_SECT_XN;
4158 + mem_types[MT_MEMORY_RW].prot_pte |= L_PTE_XN;
4159 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |= PMD_SECT_XN;
4160 + mem_types[MT_MEMORY_NONCACHED_RW].prot_pte |= PMD_SECT_XN;
4161 + mem_types[MT_MEMORY_DTCM].prot_sect |= PMD_SECT_XN;
4162 + mem_types[MT_MEMORY_DTCM].prot_pte |= L_PTE_XN;
4163 +#endif
4164 +
4165 + mem_types[MT_MEMORY_SO].prot_sect |= PMD_SECT_XN;
4166 + mem_types[MT_MEMORY_SO].prot_pte |= L_PTE_XN;
4167 }
4168 if (cpu_arch >= CPU_ARCH_ARMv7 && (cr & CR_TRE)) {
4169 /*
4170 @@ -432,6 +501,9 @@ static void __init build_mem_type_table(void)
4171 * from SVC mode and no access from userspace.
4172 */
4173 mem_types[MT_ROM].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4174 +#ifdef CONFIG_PAX_KERNEXEC
4175 + mem_types[MT_MEMORY_RX].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4176 +#endif
4177 mem_types[MT_MINICLEAN].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4178 mem_types[MT_CACHECLEAN].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4179 #endif
4180 @@ -448,11 +520,17 @@ static void __init build_mem_type_table(void)
4181 mem_types[MT_DEVICE_WC].prot_pte |= L_PTE_SHARED;
4182 mem_types[MT_DEVICE_CACHED].prot_sect |= PMD_SECT_S;
4183 mem_types[MT_DEVICE_CACHED].prot_pte |= L_PTE_SHARED;
4184 - mem_types[MT_MEMORY].prot_sect |= PMD_SECT_S;
4185 - mem_types[MT_MEMORY].prot_pte |= L_PTE_SHARED;
4186 + mem_types[MT_MEMORY_RWX].prot_sect |= PMD_SECT_S;
4187 + mem_types[MT_MEMORY_RWX].prot_pte |= L_PTE_SHARED;
4188 + mem_types[MT_MEMORY_RW].prot_sect |= PMD_SECT_S;
4189 + mem_types[MT_MEMORY_RW].prot_pte |= L_PTE_SHARED;
4190 + mem_types[MT_MEMORY_RX].prot_sect |= PMD_SECT_S;
4191 + mem_types[MT_MEMORY_RX].prot_pte |= L_PTE_SHARED;
4192 mem_types[MT_MEMORY_DMA_READY].prot_pte |= L_PTE_SHARED;
4193 - mem_types[MT_MEMORY_NONCACHED].prot_sect |= PMD_SECT_S;
4194 - mem_types[MT_MEMORY_NONCACHED].prot_pte |= L_PTE_SHARED;
4195 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |= PMD_SECT_S;
4196 + mem_types[MT_MEMORY_NONCACHED_RW].prot_pte |= L_PTE_SHARED;
4197 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |= PMD_SECT_S;
4198 + mem_types[MT_MEMORY_NONCACHED_RX].prot_pte |= L_PTE_SHARED;
4199 }
4200 }
4201
4202 @@ -463,15 +541,20 @@ static void __init build_mem_type_table(void)
4203 if (cpu_arch >= CPU_ARCH_ARMv6) {
4204 if (cpu_arch >= CPU_ARCH_ARMv7 && (cr & CR_TRE)) {
4205 /* Non-cacheable Normal is XCB = 001 */
4206 - mem_types[MT_MEMORY_NONCACHED].prot_sect |=
4207 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |=
4208 + PMD_SECT_BUFFERED;
4209 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |=
4210 PMD_SECT_BUFFERED;
4211 } else {
4212 /* For both ARMv6 and non-TEX-remapping ARMv7 */
4213 - mem_types[MT_MEMORY_NONCACHED].prot_sect |=
4214 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |=
4215 + PMD_SECT_TEX(1);
4216 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |=
4217 PMD_SECT_TEX(1);
4218 }
4219 } else {
4220 - mem_types[MT_MEMORY_NONCACHED].prot_sect |= PMD_SECT_BUFFERABLE;
4221 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |= PMD_SECT_BUFFERABLE;
4222 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |= PMD_SECT_BUFFERABLE;
4223 }
4224
4225 #ifdef CONFIG_ARM_LPAE
4226 @@ -487,6 +570,8 @@ static void __init build_mem_type_table(void)
4227 vecs_pgprot |= PTE_EXT_AF;
4228 #endif
4229
4230 + user_pgprot |= __supported_pte_mask;
4231 +
4232 for (i = 0; i < 16; i++) {
4233 pteval_t v = pgprot_val(protection_map[i]);
4234 protection_map[i] = __pgprot(v | user_pgprot);
4235 @@ -501,10 +586,15 @@ static void __init build_mem_type_table(void)
4236
4237 mem_types[MT_LOW_VECTORS].prot_l1 |= ecc_mask;
4238 mem_types[MT_HIGH_VECTORS].prot_l1 |= ecc_mask;
4239 - mem_types[MT_MEMORY].prot_sect |= ecc_mask | cp->pmd;
4240 - mem_types[MT_MEMORY].prot_pte |= kern_pgprot;
4241 + mem_types[MT_MEMORY_RWX].prot_sect |= ecc_mask | cp->pmd;
4242 + mem_types[MT_MEMORY_RWX].prot_pte |= kern_pgprot;
4243 + mem_types[MT_MEMORY_RW].prot_sect |= ecc_mask | cp->pmd;
4244 + mem_types[MT_MEMORY_RW].prot_pte |= kern_pgprot;
4245 + mem_types[MT_MEMORY_RX].prot_sect |= ecc_mask | cp->pmd;
4246 + mem_types[MT_MEMORY_RX].prot_pte |= kern_pgprot;
4247 mem_types[MT_MEMORY_DMA_READY].prot_pte |= kern_pgprot;
4248 - mem_types[MT_MEMORY_NONCACHED].prot_sect |= ecc_mask;
4249 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |= ecc_mask;
4250 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |= ecc_mask;
4251 mem_types[MT_ROM].prot_sect |= cp->pmd;
4252
4253 switch (cp->pmd) {
4254 @@ -1105,18 +1195,15 @@ void __init arm_mm_memblock_reserve(void)
4255 * called function. This means you can't use any function or debugging
4256 * method which may touch any device, otherwise the kernel _will_ crash.
4257 */
4258 +
4259 +static char vectors[PAGE_SIZE] __read_only __aligned(PAGE_SIZE);
4260 +
4261 static void __init devicemaps_init(struct machine_desc *mdesc)
4262 {
4263 struct map_desc map;
4264 unsigned long addr;
4265 - void *vectors;
4266
4267 - /*
4268 - * Allocate the vector page early.
4269 - */
4270 - vectors = early_alloc(PAGE_SIZE);
4271 -
4272 - early_trap_init(vectors);
4273 + early_trap_init(&vectors);
4274
4275 for (addr = VMALLOC_START; addr; addr += PMD_SIZE)
4276 pmd_clear(pmd_off_k(addr));
4277 @@ -1156,7 +1243,7 @@ static void __init devicemaps_init(struct machine_desc *mdesc)
4278 * location (0xffff0000). If we aren't using high-vectors, also
4279 * create a mapping at the low-vectors virtual address.
4280 */
4281 - map.pfn = __phys_to_pfn(virt_to_phys(vectors));
4282 + map.pfn = __phys_to_pfn(virt_to_phys(&vectors));
4283 map.virtual = 0xffff0000;
4284 map.length = PAGE_SIZE;
4285 map.type = MT_HIGH_VECTORS;
4286 @@ -1214,8 +1301,39 @@ static void __init map_lowmem(void)
4287 map.pfn = __phys_to_pfn(start);
4288 map.virtual = __phys_to_virt(start);
4289 map.length = end - start;
4290 - map.type = MT_MEMORY;
4291
4292 +#ifdef CONFIG_PAX_KERNEXEC
4293 + if (map.virtual <= (unsigned long)_stext && ((unsigned long)_end < (map.virtual + map.length))) {
4294 + struct map_desc kernel;
4295 + struct map_desc initmap;
4296 +
4297 + /* when freeing initmem we will make this RW */
4298 + initmap.pfn = __phys_to_pfn(__pa(__init_begin));
4299 + initmap.virtual = (unsigned long)__init_begin;
4300 + initmap.length = _sdata - __init_begin;
4301 + initmap.type = MT_MEMORY_RWX;
4302 + create_mapping(&initmap);
4303 +
4304 + /* when freeing initmem we will make this RX */
4305 + kernel.pfn = __phys_to_pfn(__pa(_stext));
4306 + kernel.virtual = (unsigned long)_stext;
4307 + kernel.length = __init_begin - _stext;
4308 + kernel.type = MT_MEMORY_RWX;
4309 + create_mapping(&kernel);
4310 +
4311 + if (map.virtual < (unsigned long)_stext) {
4312 + map.length = (unsigned long)_stext - map.virtual;
4313 + map.type = MT_MEMORY_RWX;
4314 + create_mapping(&map);
4315 + }
4316 +
4317 + map.pfn = __phys_to_pfn(__pa(_sdata));
4318 + map.virtual = (unsigned long)_sdata;
4319 + map.length = end - __pa(_sdata);
4320 + }
4321 +#endif
4322 +
4323 + map.type = MT_MEMORY_RW;
4324 create_mapping(&map);
4325 }
4326 }
4327 diff --git a/arch/arm/mm/proc-v7-2level.S b/arch/arm/mm/proc-v7-2level.S
4328 index 6d98c13..3cfb174 100644
4329 --- a/arch/arm/mm/proc-v7-2level.S
4330 +++ b/arch/arm/mm/proc-v7-2level.S
4331 @@ -99,6 +99,9 @@ ENTRY(cpu_v7_set_pte_ext)
4332 tst r1, #L_PTE_XN
4333 orrne r3, r3, #PTE_EXT_XN
4334
4335 + tst r1, #L_PTE_PXN
4336 + orrne r3, r3, #PTE_EXT_PXN
4337 +
4338 tst r1, #L_PTE_YOUNG
4339 tstne r1, #L_PTE_VALID
4340 #ifndef CONFIG_CPU_USE_DOMAINS
4341 diff --git a/arch/arm/plat-omap/sram.c b/arch/arm/plat-omap/sram.c
4342 index a5bc92d..0bb4730 100644
4343 --- a/arch/arm/plat-omap/sram.c
4344 +++ b/arch/arm/plat-omap/sram.c
4345 @@ -93,6 +93,8 @@ void __init omap_map_sram(unsigned long start, unsigned long size,
4346 * Looks like we need to preserve some bootloader code at the
4347 * beginning of SRAM for jumping to flash for reboot to work...
4348 */
4349 + pax_open_kernel();
4350 memset_io(omap_sram_base + omap_sram_skip, 0,
4351 omap_sram_size - omap_sram_skip);
4352 + pax_close_kernel();
4353 }
4354 diff --git a/arch/arm/plat-samsung/include/plat/dma-ops.h b/arch/arm/plat-samsung/include/plat/dma-ops.h
4355 index f5144cd..71f6d1f 100644
4356 --- a/arch/arm/plat-samsung/include/plat/dma-ops.h
4357 +++ b/arch/arm/plat-samsung/include/plat/dma-ops.h
4358 @@ -47,7 +47,7 @@ struct samsung_dma_ops {
4359 int (*started)(unsigned ch);
4360 int (*flush)(unsigned ch);
4361 int (*stop)(unsigned ch);
4362 -};
4363 +} __no_const;
4364
4365 extern void *samsung_dmadev_get_ops(void);
4366 extern void *s3c_dma_get_ops(void);
4367 diff --git a/arch/arm64/kernel/debug-monitors.c b/arch/arm64/kernel/debug-monitors.c
4368 index 0c3ba9f..95722b3 100644
4369 --- a/arch/arm64/kernel/debug-monitors.c
4370 +++ b/arch/arm64/kernel/debug-monitors.c
4371 @@ -151,7 +151,7 @@ static int __cpuinit os_lock_notify(struct notifier_block *self,
4372 return NOTIFY_OK;
4373 }
4374
4375 -static struct notifier_block __cpuinitdata os_lock_nb = {
4376 +static struct notifier_block os_lock_nb = {
4377 .notifier_call = os_lock_notify,
4378 };
4379
4380 diff --git a/arch/arm64/kernel/hw_breakpoint.c b/arch/arm64/kernel/hw_breakpoint.c
4381 index 5ab825c..96aaec8 100644
4382 --- a/arch/arm64/kernel/hw_breakpoint.c
4383 +++ b/arch/arm64/kernel/hw_breakpoint.c
4384 @@ -831,7 +831,7 @@ static int __cpuinit hw_breakpoint_reset_notify(struct notifier_block *self,
4385 return NOTIFY_OK;
4386 }
4387
4388 -static struct notifier_block __cpuinitdata hw_breakpoint_reset_nb = {
4389 +static struct notifier_block hw_breakpoint_reset_nb = {
4390 .notifier_call = hw_breakpoint_reset_notify,
4391 };
4392
4393 diff --git a/arch/avr32/include/asm/cache.h b/arch/avr32/include/asm/cache.h
4394 index c3a58a1..78fbf54 100644
4395 --- a/arch/avr32/include/asm/cache.h
4396 +++ b/arch/avr32/include/asm/cache.h
4397 @@ -1,8 +1,10 @@
4398 #ifndef __ASM_AVR32_CACHE_H
4399 #define __ASM_AVR32_CACHE_H
4400
4401 +#include <linux/const.h>
4402 +
4403 #define L1_CACHE_SHIFT 5
4404 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4405 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4406
4407 /*
4408 * Memory returned by kmalloc() may be used for DMA, so we must make
4409 diff --git a/arch/avr32/include/asm/elf.h b/arch/avr32/include/asm/elf.h
4410 index e2c3287..6c4f98c 100644
4411 --- a/arch/avr32/include/asm/elf.h
4412 +++ b/arch/avr32/include/asm/elf.h
4413 @@ -84,8 +84,14 @@ typedef struct user_fpu_struct elf_fpregset_t;
4414 the loader. We need to make sure that it is out of the way of the program
4415 that it will "exec", and that there is sufficient room for the brk. */
4416
4417 -#define ELF_ET_DYN_BASE (2 * TASK_SIZE / 3)
4418 +#define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
4419
4420 +#ifdef CONFIG_PAX_ASLR
4421 +#define PAX_ELF_ET_DYN_BASE 0x00001000UL
4422 +
4423 +#define PAX_DELTA_MMAP_LEN 15
4424 +#define PAX_DELTA_STACK_LEN 15
4425 +#endif
4426
4427 /* This yields a mask that user programs can use to figure out what
4428 instruction set this CPU supports. This could be done in user space,
4429 diff --git a/arch/avr32/include/asm/kmap_types.h b/arch/avr32/include/asm/kmap_types.h
4430 index 479330b..53717a8 100644
4431 --- a/arch/avr32/include/asm/kmap_types.h
4432 +++ b/arch/avr32/include/asm/kmap_types.h
4433 @@ -2,9 +2,9 @@
4434 #define __ASM_AVR32_KMAP_TYPES_H
4435
4436 #ifdef CONFIG_DEBUG_HIGHMEM
4437 -# define KM_TYPE_NR 29
4438 +# define KM_TYPE_NR 30
4439 #else
4440 -# define KM_TYPE_NR 14
4441 +# define KM_TYPE_NR 15
4442 #endif
4443
4444 #endif /* __ASM_AVR32_KMAP_TYPES_H */
4445 diff --git a/arch/avr32/mm/fault.c b/arch/avr32/mm/fault.c
4446 index b2f2d2d..d1c85cb 100644
4447 --- a/arch/avr32/mm/fault.c
4448 +++ b/arch/avr32/mm/fault.c
4449 @@ -41,6 +41,23 @@ static inline int notify_page_fault(struct pt_regs *regs, int trap)
4450
4451 int exception_trace = 1;
4452
4453 +#ifdef CONFIG_PAX_PAGEEXEC
4454 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
4455 +{
4456 + unsigned long i;
4457 +
4458 + printk(KERN_ERR "PAX: bytes at PC: ");
4459 + for (i = 0; i < 20; i++) {
4460 + unsigned char c;
4461 + if (get_user(c, (unsigned char *)pc+i))
4462 + printk(KERN_CONT "???????? ");
4463 + else
4464 + printk(KERN_CONT "%02x ", c);
4465 + }
4466 + printk("\n");
4467 +}
4468 +#endif
4469 +
4470 /*
4471 * This routine handles page faults. It determines the address and the
4472 * problem, and then passes it off to one of the appropriate routines.
4473 @@ -174,6 +191,16 @@ bad_area:
4474 up_read(&mm->mmap_sem);
4475
4476 if (user_mode(regs)) {
4477 +
4478 +#ifdef CONFIG_PAX_PAGEEXEC
4479 + if (mm->pax_flags & MF_PAX_PAGEEXEC) {
4480 + if (ecr == ECR_PROTECTION_X || ecr == ECR_TLB_MISS_X) {
4481 + pax_report_fault(regs, (void *)regs->pc, (void *)regs->sp);
4482 + do_group_exit(SIGKILL);
4483 + }
4484 + }
4485 +#endif
4486 +
4487 if (exception_trace && printk_ratelimit())
4488 printk("%s%s[%d]: segfault at %08lx pc %08lx "
4489 "sp %08lx ecr %lu\n",
4490 diff --git a/arch/blackfin/include/asm/cache.h b/arch/blackfin/include/asm/cache.h
4491 index 568885a..f8008df 100644
4492 --- a/arch/blackfin/include/asm/cache.h
4493 +++ b/arch/blackfin/include/asm/cache.h
4494 @@ -7,6 +7,7 @@
4495 #ifndef __ARCH_BLACKFIN_CACHE_H
4496 #define __ARCH_BLACKFIN_CACHE_H
4497
4498 +#include <linux/const.h>
4499 #include <linux/linkage.h> /* for asmlinkage */
4500
4501 /*
4502 @@ -14,7 +15,7 @@
4503 * Blackfin loads 32 bytes for cache
4504 */
4505 #define L1_CACHE_SHIFT 5
4506 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4507 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4508 #define SMP_CACHE_BYTES L1_CACHE_BYTES
4509
4510 #define ARCH_DMA_MINALIGN L1_CACHE_BYTES
4511 diff --git a/arch/cris/include/arch-v10/arch/cache.h b/arch/cris/include/arch-v10/arch/cache.h
4512 index aea2718..3639a60 100644
4513 --- a/arch/cris/include/arch-v10/arch/cache.h
4514 +++ b/arch/cris/include/arch-v10/arch/cache.h
4515 @@ -1,8 +1,9 @@
4516 #ifndef _ASM_ARCH_CACHE_H
4517 #define _ASM_ARCH_CACHE_H
4518
4519 +#include <linux/const.h>
4520 /* Etrax 100LX have 32-byte cache-lines. */
4521 -#define L1_CACHE_BYTES 32
4522 #define L1_CACHE_SHIFT 5
4523 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4524
4525 #endif /* _ASM_ARCH_CACHE_H */
4526 diff --git a/arch/cris/include/arch-v32/arch/cache.h b/arch/cris/include/arch-v32/arch/cache.h
4527 index 7caf25d..ee65ac5 100644
4528 --- a/arch/cris/include/arch-v32/arch/cache.h
4529 +++ b/arch/cris/include/arch-v32/arch/cache.h
4530 @@ -1,11 +1,12 @@
4531 #ifndef _ASM_CRIS_ARCH_CACHE_H
4532 #define _ASM_CRIS_ARCH_CACHE_H
4533
4534 +#include <linux/const.h>
4535 #include <arch/hwregs/dma.h>
4536
4537 /* A cache-line is 32 bytes. */
4538 -#define L1_CACHE_BYTES 32
4539 #define L1_CACHE_SHIFT 5
4540 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4541
4542 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
4543
4544 diff --git a/arch/frv/include/asm/atomic.h b/arch/frv/include/asm/atomic.h
4545 index b86329d..6709906 100644
4546 --- a/arch/frv/include/asm/atomic.h
4547 +++ b/arch/frv/include/asm/atomic.h
4548 @@ -186,6 +186,16 @@ static inline void atomic64_dec(atomic64_t *v)
4549 #define atomic64_cmpxchg(v, old, new) (__cmpxchg_64(old, new, &(v)->counter))
4550 #define atomic64_xchg(v, new) (__xchg_64(new, &(v)->counter))
4551
4552 +#define atomic64_read_unchecked(v) atomic64_read(v)
4553 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
4554 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
4555 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
4556 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
4557 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
4558 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
4559 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
4560 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
4561 +
4562 static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
4563 {
4564 int c, old;
4565 diff --git a/arch/frv/include/asm/cache.h b/arch/frv/include/asm/cache.h
4566 index 2797163..c2a401d 100644
4567 --- a/arch/frv/include/asm/cache.h
4568 +++ b/arch/frv/include/asm/cache.h
4569 @@ -12,10 +12,11 @@
4570 #ifndef __ASM_CACHE_H
4571 #define __ASM_CACHE_H
4572
4573 +#include <linux/const.h>
4574
4575 /* bytes per L1 cache line */
4576 #define L1_CACHE_SHIFT (CONFIG_FRV_L1_CACHE_SHIFT)
4577 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4578 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4579
4580 #define __cacheline_aligned __attribute__((aligned(L1_CACHE_BYTES)))
4581 #define ____cacheline_aligned __attribute__((aligned(L1_CACHE_BYTES)))
4582 diff --git a/arch/frv/include/asm/kmap_types.h b/arch/frv/include/asm/kmap_types.h
4583 index 43901f2..0d8b865 100644
4584 --- a/arch/frv/include/asm/kmap_types.h
4585 +++ b/arch/frv/include/asm/kmap_types.h
4586 @@ -2,6 +2,6 @@
4587 #ifndef _ASM_KMAP_TYPES_H
4588 #define _ASM_KMAP_TYPES_H
4589
4590 -#define KM_TYPE_NR 17
4591 +#define KM_TYPE_NR 18
4592
4593 #endif
4594 diff --git a/arch/frv/mm/elf-fdpic.c b/arch/frv/mm/elf-fdpic.c
4595 index 385fd30..3aaf4fe 100644
4596 --- a/arch/frv/mm/elf-fdpic.c
4597 +++ b/arch/frv/mm/elf-fdpic.c
4598 @@ -61,6 +61,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
4599 {
4600 struct vm_area_struct *vma;
4601 unsigned long limit;
4602 + unsigned long offset = gr_rand_threadstack_offset(current->mm, filp, flags);
4603
4604 if (len > TASK_SIZE)
4605 return -ENOMEM;
4606 @@ -73,8 +74,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
4607 if (addr) {
4608 addr = PAGE_ALIGN(addr);
4609 vma = find_vma(current->mm, addr);
4610 - if (TASK_SIZE - len >= addr &&
4611 - (!vma || addr + len <= vma->vm_start))
4612 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
4613 goto success;
4614 }
4615
4616 @@ -89,7 +89,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 @@ -104,7 +104,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
4626 for (; vma; vma = vma->vm_next) {
4627 if (addr > limit)
4628 break;
4629 - if (addr + len <= vma->vm_start)
4630 + if (check_heap_stack_gap(vma, addr, len, offset))
4631 goto success;
4632 addr = vma->vm_end;
4633 }
4634 diff --git a/arch/hexagon/include/asm/cache.h b/arch/hexagon/include/asm/cache.h
4635 index f4ca594..adc72fd6 100644
4636 --- a/arch/hexagon/include/asm/cache.h
4637 +++ b/arch/hexagon/include/asm/cache.h
4638 @@ -21,9 +21,11 @@
4639 #ifndef __ASM_CACHE_H
4640 #define __ASM_CACHE_H
4641
4642 +#include <linux/const.h>
4643 +
4644 /* Bytes per L1 cache line */
4645 -#define L1_CACHE_SHIFT (5)
4646 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4647 +#define L1_CACHE_SHIFT 5
4648 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4649
4650 #define __cacheline_aligned __aligned(L1_CACHE_BYTES)
4651 #define ____cacheline_aligned __aligned(L1_CACHE_BYTES)
4652 diff --git a/arch/ia64/include/asm/atomic.h b/arch/ia64/include/asm/atomic.h
4653 index 6e6fe18..a6ae668 100644
4654 --- a/arch/ia64/include/asm/atomic.h
4655 +++ b/arch/ia64/include/asm/atomic.h
4656 @@ -208,6 +208,16 @@ atomic64_add_negative (__s64 i, atomic64_t *v)
4657 #define atomic64_inc(v) atomic64_add(1, (v))
4658 #define atomic64_dec(v) atomic64_sub(1, (v))
4659
4660 +#define atomic64_read_unchecked(v) atomic64_read(v)
4661 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
4662 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
4663 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
4664 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
4665 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
4666 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
4667 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
4668 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
4669 +
4670 /* Atomic operations are already serializing */
4671 #define smp_mb__before_atomic_dec() barrier()
4672 #define smp_mb__after_atomic_dec() barrier()
4673 diff --git a/arch/ia64/include/asm/cache.h b/arch/ia64/include/asm/cache.h
4674 index 988254a..e1ee885 100644
4675 --- a/arch/ia64/include/asm/cache.h
4676 +++ b/arch/ia64/include/asm/cache.h
4677 @@ -1,6 +1,7 @@
4678 #ifndef _ASM_IA64_CACHE_H
4679 #define _ASM_IA64_CACHE_H
4680
4681 +#include <linux/const.h>
4682
4683 /*
4684 * Copyright (C) 1998-2000 Hewlett-Packard Co
4685 @@ -9,7 +10,7 @@
4686
4687 /* Bytes per L1 (data) cache line. */
4688 #define L1_CACHE_SHIFT CONFIG_IA64_L1_CACHE_SHIFT
4689 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4690 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4691
4692 #ifdef CONFIG_SMP
4693 # define SMP_CACHE_SHIFT L1_CACHE_SHIFT
4694 diff --git a/arch/ia64/include/asm/elf.h b/arch/ia64/include/asm/elf.h
4695 index b5298eb..67c6e62 100644
4696 --- a/arch/ia64/include/asm/elf.h
4697 +++ b/arch/ia64/include/asm/elf.h
4698 @@ -42,6 +42,13 @@
4699 */
4700 #define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE + 0x800000000UL)
4701
4702 +#ifdef CONFIG_PAX_ASLR
4703 +#define PAX_ELF_ET_DYN_BASE (current->personality == PER_LINUX32 ? 0x08048000UL : 0x4000000000000000UL)
4704 +
4705 +#define PAX_DELTA_MMAP_LEN (current->personality == PER_LINUX32 ? 16 : 3*PAGE_SHIFT - 13)
4706 +#define PAX_DELTA_STACK_LEN (current->personality == PER_LINUX32 ? 16 : 3*PAGE_SHIFT - 13)
4707 +#endif
4708 +
4709 #define PT_IA_64_UNWIND 0x70000001
4710
4711 /* IA-64 relocations: */
4712 diff --git a/arch/ia64/include/asm/pgalloc.h b/arch/ia64/include/asm/pgalloc.h
4713 index 96a8d92..617a1cf 100644
4714 --- a/arch/ia64/include/asm/pgalloc.h
4715 +++ b/arch/ia64/include/asm/pgalloc.h
4716 @@ -39,6 +39,12 @@ pgd_populate(struct mm_struct *mm, pgd_t * pgd_entry, pud_t * pud)
4717 pgd_val(*pgd_entry) = __pa(pud);
4718 }
4719
4720 +static inline void
4721 +pgd_populate_kernel(struct mm_struct *mm, pgd_t * pgd_entry, pud_t * pud)
4722 +{
4723 + pgd_populate(mm, pgd_entry, pud);
4724 +}
4725 +
4726 static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr)
4727 {
4728 return quicklist_alloc(0, GFP_KERNEL, NULL);
4729 @@ -57,6 +63,12 @@ pud_populate(struct mm_struct *mm, pud_t * pud_entry, pmd_t * pmd)
4730 pud_val(*pud_entry) = __pa(pmd);
4731 }
4732
4733 +static inline void
4734 +pud_populate_kernel(struct mm_struct *mm, pud_t * pud_entry, pmd_t * pmd)
4735 +{
4736 + pud_populate(mm, pud_entry, pmd);
4737 +}
4738 +
4739 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long addr)
4740 {
4741 return quicklist_alloc(0, GFP_KERNEL, NULL);
4742 diff --git a/arch/ia64/include/asm/pgtable.h b/arch/ia64/include/asm/pgtable.h
4743 index 815810c..d60bd4c 100644
4744 --- a/arch/ia64/include/asm/pgtable.h
4745 +++ b/arch/ia64/include/asm/pgtable.h
4746 @@ -12,7 +12,7 @@
4747 * David Mosberger-Tang <davidm@hpl.hp.com>
4748 */
4749
4750 -
4751 +#include <linux/const.h>
4752 #include <asm/mman.h>
4753 #include <asm/page.h>
4754 #include <asm/processor.h>
4755 @@ -142,6 +142,17 @@
4756 #define PAGE_READONLY __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
4757 #define PAGE_COPY __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
4758 #define PAGE_COPY_EXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_RX)
4759 +
4760 +#ifdef CONFIG_PAX_PAGEEXEC
4761 +# define PAGE_SHARED_NOEXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_RW)
4762 +# define PAGE_READONLY_NOEXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
4763 +# define PAGE_COPY_NOEXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
4764 +#else
4765 +# define PAGE_SHARED_NOEXEC PAGE_SHARED
4766 +# define PAGE_READONLY_NOEXEC PAGE_READONLY
4767 +# define PAGE_COPY_NOEXEC PAGE_COPY
4768 +#endif
4769 +
4770 #define PAGE_GATE __pgprot(__ACCESS_BITS | _PAGE_PL_0 | _PAGE_AR_X_RX)
4771 #define PAGE_KERNEL __pgprot(__DIRTY_BITS | _PAGE_PL_0 | _PAGE_AR_RWX)
4772 #define PAGE_KERNELRX __pgprot(__ACCESS_BITS | _PAGE_PL_0 | _PAGE_AR_RX)
4773 diff --git a/arch/ia64/include/asm/spinlock.h b/arch/ia64/include/asm/spinlock.h
4774 index 54ff557..70c88b7 100644
4775 --- a/arch/ia64/include/asm/spinlock.h
4776 +++ b/arch/ia64/include/asm/spinlock.h
4777 @@ -71,7 +71,7 @@ static __always_inline void __ticket_spin_unlock(arch_spinlock_t *lock)
4778 unsigned short *p = (unsigned short *)&lock->lock + 1, tmp;
4779
4780 asm volatile ("ld2.bias %0=[%1]" : "=r"(tmp) : "r"(p));
4781 - ACCESS_ONCE(*p) = (tmp + 2) & ~1;
4782 + ACCESS_ONCE_RW(*p) = (tmp + 2) & ~1;
4783 }
4784
4785 static __always_inline void __ticket_spin_unlock_wait(arch_spinlock_t *lock)
4786 diff --git a/arch/ia64/include/asm/uaccess.h b/arch/ia64/include/asm/uaccess.h
4787 index 449c8c0..50cdf87 100644
4788 --- a/arch/ia64/include/asm/uaccess.h
4789 +++ b/arch/ia64/include/asm/uaccess.h
4790 @@ -42,6 +42,8 @@
4791 #include <asm/pgtable.h>
4792 #include <asm/io.h>
4793
4794 +extern void check_object_size(const void *ptr, unsigned long n, bool to);
4795 +
4796 /*
4797 * For historical reasons, the following macros are grossly misnamed:
4798 */
4799 @@ -240,12 +242,24 @@ extern unsigned long __must_check __copy_user (void __user *to, const void __use
4800 static inline unsigned long
4801 __copy_to_user (void __user *to, const void *from, unsigned long count)
4802 {
4803 + if (count > INT_MAX)
4804 + return count;
4805 +
4806 + if (!__builtin_constant_p(count))
4807 + check_object_size(from, count, true);
4808 +
4809 return __copy_user(to, (__force void __user *) from, count);
4810 }
4811
4812 static inline unsigned long
4813 __copy_from_user (void *to, const void __user *from, unsigned long count)
4814 {
4815 + if (count > INT_MAX)
4816 + return count;
4817 +
4818 + if (!__builtin_constant_p(count))
4819 + check_object_size(to, count, false);
4820 +
4821 return __copy_user((__force void __user *) to, from, count);
4822 }
4823
4824 @@ -255,10 +269,13 @@ __copy_from_user (void *to, const void __user *from, unsigned long count)
4825 ({ \
4826 void __user *__cu_to = (to); \
4827 const void *__cu_from = (from); \
4828 - long __cu_len = (n); \
4829 + unsigned long __cu_len = (n); \
4830 \
4831 - if (__access_ok(__cu_to, __cu_len, get_fs())) \
4832 + if (__cu_len <= INT_MAX && __access_ok(__cu_to, __cu_len, get_fs())) { \
4833 + if (!__builtin_constant_p(n)) \
4834 + check_object_size(__cu_from, __cu_len, true); \
4835 __cu_len = __copy_user(__cu_to, (__force void __user *) __cu_from, __cu_len); \
4836 + } \
4837 __cu_len; \
4838 })
4839
4840 @@ -266,11 +283,14 @@ __copy_from_user (void *to, const void __user *from, unsigned long count)
4841 ({ \
4842 void *__cu_to = (to); \
4843 const void __user *__cu_from = (from); \
4844 - long __cu_len = (n); \
4845 + unsigned long __cu_len = (n); \
4846 \
4847 __chk_user_ptr(__cu_from); \
4848 - if (__access_ok(__cu_from, __cu_len, get_fs())) \
4849 + if (__cu_len <= INT_MAX && __access_ok(__cu_from, __cu_len, get_fs())) { \
4850 + if (!__builtin_constant_p(n)) \
4851 + check_object_size(__cu_to, __cu_len, false); \
4852 __cu_len = __copy_user((__force void __user *) __cu_to, __cu_from, __cu_len); \
4853 + } \
4854 __cu_len; \
4855 })
4856
4857 diff --git a/arch/ia64/kernel/err_inject.c b/arch/ia64/kernel/err_inject.c
4858 index 2d67317..07d8bfa 100644
4859 --- a/arch/ia64/kernel/err_inject.c
4860 +++ b/arch/ia64/kernel/err_inject.c
4861 @@ -256,7 +256,7 @@ static int __cpuinit err_inject_cpu_callback(struct notifier_block *nfb,
4862 return NOTIFY_OK;
4863 }
4864
4865 -static struct notifier_block __cpuinitdata err_inject_cpu_notifier =
4866 +static struct notifier_block err_inject_cpu_notifier =
4867 {
4868 .notifier_call = err_inject_cpu_callback,
4869 };
4870 diff --git a/arch/ia64/kernel/mca.c b/arch/ia64/kernel/mca.c
4871 index 65bf9cd..794f06b 100644
4872 --- a/arch/ia64/kernel/mca.c
4873 +++ b/arch/ia64/kernel/mca.c
4874 @@ -1922,7 +1922,7 @@ static int __cpuinit mca_cpu_callback(struct notifier_block *nfb,
4875 return NOTIFY_OK;
4876 }
4877
4878 -static struct notifier_block mca_cpu_notifier __cpuinitdata = {
4879 +static struct notifier_block mca_cpu_notifier = {
4880 .notifier_call = mca_cpu_callback
4881 };
4882
4883 diff --git a/arch/ia64/kernel/module.c b/arch/ia64/kernel/module.c
4884 index 24603be..948052d 100644
4885 --- a/arch/ia64/kernel/module.c
4886 +++ b/arch/ia64/kernel/module.c
4887 @@ -307,8 +307,7 @@ plt_target (struct plt_entry *plt)
4888 void
4889 module_free (struct module *mod, void *module_region)
4890 {
4891 - if (mod && mod->arch.init_unw_table &&
4892 - module_region == mod->module_init) {
4893 + if (mod && mod->arch.init_unw_table && module_region == mod->module_init_rx) {
4894 unw_remove_unwind_table(mod->arch.init_unw_table);
4895 mod->arch.init_unw_table = NULL;
4896 }
4897 @@ -494,15 +493,39 @@ module_frob_arch_sections (Elf_Ehdr *ehdr, Elf_Shdr *sechdrs, char *secstrings,
4898 }
4899
4900 static inline int
4901 +in_init_rx (const struct module *mod, uint64_t addr)
4902 +{
4903 + return addr - (uint64_t) mod->module_init_rx < mod->init_size_rx;
4904 +}
4905 +
4906 +static inline int
4907 +in_init_rw (const struct module *mod, uint64_t addr)
4908 +{
4909 + return addr - (uint64_t) mod->module_init_rw < mod->init_size_rw;
4910 +}
4911 +
4912 +static inline int
4913 in_init (const struct module *mod, uint64_t addr)
4914 {
4915 - return addr - (uint64_t) mod->module_init < mod->init_size;
4916 + return in_init_rx(mod, addr) || in_init_rw(mod, addr);
4917 +}
4918 +
4919 +static inline int
4920 +in_core_rx (const struct module *mod, uint64_t addr)
4921 +{
4922 + return addr - (uint64_t) mod->module_core_rx < mod->core_size_rx;
4923 +}
4924 +
4925 +static inline int
4926 +in_core_rw (const struct module *mod, uint64_t addr)
4927 +{
4928 + return addr - (uint64_t) mod->module_core_rw < mod->core_size_rw;
4929 }
4930
4931 static inline int
4932 in_core (const struct module *mod, uint64_t addr)
4933 {
4934 - return addr - (uint64_t) mod->module_core < mod->core_size;
4935 + return in_core_rx(mod, addr) || in_core_rw(mod, addr);
4936 }
4937
4938 static inline int
4939 @@ -685,7 +708,14 @@ do_reloc (struct module *mod, uint8_t r_type, Elf64_Sym *sym, uint64_t addend,
4940 break;
4941
4942 case RV_BDREL:
4943 - val -= (uint64_t) (in_init(mod, val) ? mod->module_init : mod->module_core);
4944 + if (in_init_rx(mod, val))
4945 + val -= (uint64_t) mod->module_init_rx;
4946 + else if (in_init_rw(mod, val))
4947 + val -= (uint64_t) mod->module_init_rw;
4948 + else if (in_core_rx(mod, val))
4949 + val -= (uint64_t) mod->module_core_rx;
4950 + else if (in_core_rw(mod, val))
4951 + val -= (uint64_t) mod->module_core_rw;
4952 break;
4953
4954 case RV_LTV:
4955 @@ -820,15 +850,15 @@ apply_relocate_add (Elf64_Shdr *sechdrs, const char *strtab, unsigned int symind
4956 * addresses have been selected...
4957 */
4958 uint64_t gp;
4959 - if (mod->core_size > MAX_LTOFF)
4960 + if (mod->core_size_rx + mod->core_size_rw > MAX_LTOFF)
4961 /*
4962 * This takes advantage of fact that SHF_ARCH_SMALL gets allocated
4963 * at the end of the module.
4964 */
4965 - gp = mod->core_size - MAX_LTOFF / 2;
4966 + gp = mod->core_size_rx + mod->core_size_rw - MAX_LTOFF / 2;
4967 else
4968 - gp = mod->core_size / 2;
4969 - gp = (uint64_t) mod->module_core + ((gp + 7) & -8);
4970 + gp = (mod->core_size_rx + mod->core_size_rw) / 2;
4971 + gp = (uint64_t) mod->module_core_rx + ((gp + 7) & -8);
4972 mod->arch.gp = gp;
4973 DEBUGP("%s: placing gp at 0x%lx\n", __func__, gp);
4974 }
4975 diff --git a/arch/ia64/kernel/palinfo.c b/arch/ia64/kernel/palinfo.c
4976 index 77597e5..6f28f3f 100644
4977 --- a/arch/ia64/kernel/palinfo.c
4978 +++ b/arch/ia64/kernel/palinfo.c
4979 @@ -1045,7 +1045,7 @@ static int __cpuinit palinfo_cpu_callback(struct notifier_block *nfb,
4980 return NOTIFY_OK;
4981 }
4982
4983 -static struct notifier_block __refdata palinfo_cpu_notifier =
4984 +static struct notifier_block palinfo_cpu_notifier =
4985 {
4986 .notifier_call = palinfo_cpu_callback,
4987 .priority = 0,
4988 diff --git a/arch/ia64/kernel/salinfo.c b/arch/ia64/kernel/salinfo.c
4989 index 79802e5..1a89ec5 100644
4990 --- a/arch/ia64/kernel/salinfo.c
4991 +++ b/arch/ia64/kernel/salinfo.c
4992 @@ -616,7 +616,7 @@ salinfo_cpu_callback(struct notifier_block *nb, unsigned long action, void *hcpu
4993 return NOTIFY_OK;
4994 }
4995
4996 -static struct notifier_block salinfo_cpu_notifier __cpuinitdata =
4997 +static struct notifier_block salinfo_cpu_notifier =
4998 {
4999 .notifier_call = salinfo_cpu_callback,
5000 .priority = 0,
5001 diff --git a/arch/ia64/kernel/sys_ia64.c b/arch/ia64/kernel/sys_ia64.c
5002 index d9439ef..d0cac6b 100644
5003 --- a/arch/ia64/kernel/sys_ia64.c
5004 +++ b/arch/ia64/kernel/sys_ia64.c
5005 @@ -28,6 +28,7 @@ arch_get_unmapped_area (struct file *filp, unsigned long addr, unsigned long len
5006 unsigned long start_addr, align_mask = PAGE_SIZE - 1;
5007 struct mm_struct *mm = current->mm;
5008 struct vm_area_struct *vma;
5009 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
5010
5011 if (len > RGN_MAP_LIMIT)
5012 return -ENOMEM;
5013 @@ -43,6 +44,13 @@ arch_get_unmapped_area (struct file *filp, unsigned long addr, unsigned long len
5014 if (REGION_NUMBER(addr) == RGN_HPAGE)
5015 addr = 0;
5016 #endif
5017 +
5018 +#ifdef CONFIG_PAX_RANDMMAP
5019 + if (mm->pax_flags & MF_PAX_RANDMMAP)
5020 + addr = mm->free_area_cache;
5021 + else
5022 +#endif
5023 +
5024 if (!addr)
5025 addr = mm->free_area_cache;
5026
5027 @@ -61,14 +69,14 @@ arch_get_unmapped_area (struct file *filp, unsigned long addr, unsigned long len
5028 for (vma = find_vma(mm, addr); ; vma = vma->vm_next) {
5029 /* At this point: (!vma || addr < vma->vm_end). */
5030 if (TASK_SIZE - len < addr || RGN_MAP_LIMIT - len < REGION_OFFSET(addr)) {
5031 - if (start_addr != TASK_UNMAPPED_BASE) {
5032 + if (start_addr != mm->mmap_base) {
5033 /* Start a new search --- just in case we missed some holes. */
5034 - addr = TASK_UNMAPPED_BASE;
5035 + addr = mm->mmap_base;
5036 goto full_search;
5037 }
5038 return -ENOMEM;
5039 }
5040 - if (!vma || addr + len <= vma->vm_start) {
5041 + if (check_heap_stack_gap(vma, addr, len, offset)) {
5042 /* Remember the address where we stopped this search: */
5043 mm->free_area_cache = addr + len;
5044 return addr;
5045 diff --git a/arch/ia64/kernel/topology.c b/arch/ia64/kernel/topology.c
5046 index dc00b2c..cce53c2 100644
5047 --- a/arch/ia64/kernel/topology.c
5048 +++ b/arch/ia64/kernel/topology.c
5049 @@ -445,7 +445,7 @@ static int __cpuinit cache_cpu_callback(struct notifier_block *nfb,
5050 return NOTIFY_OK;
5051 }
5052
5053 -static struct notifier_block __cpuinitdata cache_cpu_notifier =
5054 +static struct notifier_block cache_cpu_notifier =
5055 {
5056 .notifier_call = cache_cpu_callback
5057 };
5058 diff --git a/arch/ia64/kernel/vmlinux.lds.S b/arch/ia64/kernel/vmlinux.lds.S
5059 index 0ccb28f..8992469 100644
5060 --- a/arch/ia64/kernel/vmlinux.lds.S
5061 +++ b/arch/ia64/kernel/vmlinux.lds.S
5062 @@ -198,7 +198,7 @@ SECTIONS {
5063 /* Per-cpu data: */
5064 . = ALIGN(PERCPU_PAGE_SIZE);
5065 PERCPU_VADDR(SMP_CACHE_BYTES, PERCPU_ADDR, :percpu)
5066 - __phys_per_cpu_start = __per_cpu_load;
5067 + __phys_per_cpu_start = per_cpu_load;
5068 /*
5069 * ensure percpu data fits
5070 * into percpu page size
5071 diff --git a/arch/ia64/mm/fault.c b/arch/ia64/mm/fault.c
5072 index 6cf0341..d352594 100644
5073 --- a/arch/ia64/mm/fault.c
5074 +++ b/arch/ia64/mm/fault.c
5075 @@ -72,6 +72,23 @@ mapped_kernel_page_is_present (unsigned long address)
5076 return pte_present(pte);
5077 }
5078
5079 +#ifdef CONFIG_PAX_PAGEEXEC
5080 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
5081 +{
5082 + unsigned long i;
5083 +
5084 + printk(KERN_ERR "PAX: bytes at PC: ");
5085 + for (i = 0; i < 8; i++) {
5086 + unsigned int c;
5087 + if (get_user(c, (unsigned int *)pc+i))
5088 + printk(KERN_CONT "???????? ");
5089 + else
5090 + printk(KERN_CONT "%08x ", c);
5091 + }
5092 + printk("\n");
5093 +}
5094 +#endif
5095 +
5096 # define VM_READ_BIT 0
5097 # define VM_WRITE_BIT 1
5098 # define VM_EXEC_BIT 2
5099 @@ -149,8 +166,21 @@ retry:
5100 if (((isr >> IA64_ISR_R_BIT) & 1UL) && (!(vma->vm_flags & (VM_READ | VM_WRITE))))
5101 goto bad_area;
5102
5103 - if ((vma->vm_flags & mask) != mask)
5104 + if ((vma->vm_flags & mask) != mask) {
5105 +
5106 +#ifdef CONFIG_PAX_PAGEEXEC
5107 + if (!(vma->vm_flags & VM_EXEC) && (mask & VM_EXEC)) {
5108 + if (!(mm->pax_flags & MF_PAX_PAGEEXEC) || address != regs->cr_iip)
5109 + goto bad_area;
5110 +
5111 + up_read(&mm->mmap_sem);
5112 + pax_report_fault(regs, (void *)regs->cr_iip, (void *)regs->r12);
5113 + do_group_exit(SIGKILL);
5114 + }
5115 +#endif
5116 +
5117 goto bad_area;
5118 + }
5119
5120 /*
5121 * If for any reason at all we couldn't handle the fault, make
5122 diff --git a/arch/ia64/mm/hugetlbpage.c b/arch/ia64/mm/hugetlbpage.c
5123 index 5ca674b..127c3cb 100644
5124 --- a/arch/ia64/mm/hugetlbpage.c
5125 +++ b/arch/ia64/mm/hugetlbpage.c
5126 @@ -149,6 +149,7 @@ unsigned long hugetlb_get_unmapped_area(struct file *file, unsigned long addr, u
5127 unsigned long pgoff, unsigned long flags)
5128 {
5129 struct vm_area_struct *vmm;
5130 + unsigned long offset = gr_rand_threadstack_offset(current->mm, file, flags);
5131
5132 if (len > RGN_MAP_LIMIT)
5133 return -ENOMEM;
5134 @@ -171,7 +172,7 @@ unsigned long hugetlb_get_unmapped_area(struct file *file, unsigned long addr, u
5135 /* At this point: (!vmm || addr < vmm->vm_end). */
5136 if (REGION_OFFSET(addr) + len > RGN_MAP_LIMIT)
5137 return -ENOMEM;
5138 - if (!vmm || (addr + len) <= vmm->vm_start)
5139 + if (check_heap_stack_gap(vmm, addr, len, offset))
5140 return addr;
5141 addr = ALIGN(vmm->vm_end, HPAGE_SIZE);
5142 }
5143 diff --git a/arch/ia64/mm/init.c b/arch/ia64/mm/init.c
5144 index b755ea9..b9a969e 100644
5145 --- a/arch/ia64/mm/init.c
5146 +++ b/arch/ia64/mm/init.c
5147 @@ -120,6 +120,19 @@ ia64_init_addr_space (void)
5148 vma->vm_start = current->thread.rbs_bot & PAGE_MASK;
5149 vma->vm_end = vma->vm_start + PAGE_SIZE;
5150 vma->vm_flags = VM_DATA_DEFAULT_FLAGS|VM_GROWSUP|VM_ACCOUNT;
5151 +
5152 +#ifdef CONFIG_PAX_PAGEEXEC
5153 + if (current->mm->pax_flags & MF_PAX_PAGEEXEC) {
5154 + vma->vm_flags &= ~VM_EXEC;
5155 +
5156 +#ifdef CONFIG_PAX_MPROTECT
5157 + if (current->mm->pax_flags & MF_PAX_MPROTECT)
5158 + vma->vm_flags &= ~VM_MAYEXEC;
5159 +#endif
5160 +
5161 + }
5162 +#endif
5163 +
5164 vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
5165 down_write(&current->mm->mmap_sem);
5166 if (insert_vm_struct(current->mm, vma)) {
5167 diff --git a/arch/m32r/include/asm/cache.h b/arch/m32r/include/asm/cache.h
5168 index 40b3ee9..8c2c112 100644
5169 --- a/arch/m32r/include/asm/cache.h
5170 +++ b/arch/m32r/include/asm/cache.h
5171 @@ -1,8 +1,10 @@
5172 #ifndef _ASM_M32R_CACHE_H
5173 #define _ASM_M32R_CACHE_H
5174
5175 +#include <linux/const.h>
5176 +
5177 /* L1 cache line size */
5178 #define L1_CACHE_SHIFT 4
5179 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
5180 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5181
5182 #endif /* _ASM_M32R_CACHE_H */
5183 diff --git a/arch/m32r/lib/usercopy.c b/arch/m32r/lib/usercopy.c
5184 index 82abd15..d95ae5d 100644
5185 --- a/arch/m32r/lib/usercopy.c
5186 +++ b/arch/m32r/lib/usercopy.c
5187 @@ -14,6 +14,9 @@
5188 unsigned long
5189 __generic_copy_to_user(void __user *to, const void *from, unsigned long n)
5190 {
5191 + if ((long)n < 0)
5192 + return n;
5193 +
5194 prefetch(from);
5195 if (access_ok(VERIFY_WRITE, to, n))
5196 __copy_user(to,from,n);
5197 @@ -23,6 +26,9 @@ __generic_copy_to_user(void __user *to, const void *from, unsigned long n)
5198 unsigned long
5199 __generic_copy_from_user(void *to, const void __user *from, unsigned long n)
5200 {
5201 + if ((long)n < 0)
5202 + return n;
5203 +
5204 prefetchw(to);
5205 if (access_ok(VERIFY_READ, from, n))
5206 __copy_user_zeroing(to,from,n);
5207 diff --git a/arch/m68k/include/asm/cache.h b/arch/m68k/include/asm/cache.h
5208 index 0395c51..5f26031 100644
5209 --- a/arch/m68k/include/asm/cache.h
5210 +++ b/arch/m68k/include/asm/cache.h
5211 @@ -4,9 +4,11 @@
5212 #ifndef __ARCH_M68K_CACHE_H
5213 #define __ARCH_M68K_CACHE_H
5214
5215 +#include <linux/const.h>
5216 +
5217 /* bytes per L1 cache line */
5218 #define L1_CACHE_SHIFT 4
5219 -#define L1_CACHE_BYTES (1<< L1_CACHE_SHIFT)
5220 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5221
5222 #define ARCH_DMA_MINALIGN L1_CACHE_BYTES
5223
5224 diff --git a/arch/microblaze/include/asm/cache.h b/arch/microblaze/include/asm/cache.h
5225 index 4efe96a..60e8699 100644
5226 --- a/arch/microblaze/include/asm/cache.h
5227 +++ b/arch/microblaze/include/asm/cache.h
5228 @@ -13,11 +13,12 @@
5229 #ifndef _ASM_MICROBLAZE_CACHE_H
5230 #define _ASM_MICROBLAZE_CACHE_H
5231
5232 +#include <linux/const.h>
5233 #include <asm/registers.h>
5234
5235 #define L1_CACHE_SHIFT 5
5236 /* word-granular cache in microblaze */
5237 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
5238 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5239
5240 #define SMP_CACHE_BYTES L1_CACHE_BYTES
5241
5242 diff --git a/arch/mips/include/asm/atomic.h b/arch/mips/include/asm/atomic.h
5243 index 01cc6ba..bcb7a5d 100644
5244 --- a/arch/mips/include/asm/atomic.h
5245 +++ b/arch/mips/include/asm/atomic.h
5246 @@ -21,6 +21,10 @@
5247 #include <asm/cmpxchg.h>
5248 #include <asm/war.h>
5249
5250 +#ifdef CONFIG_GENERIC_ATOMIC64
5251 +#include <asm-generic/atomic64.h>
5252 +#endif
5253 +
5254 #define ATOMIC_INIT(i) { (i) }
5255
5256 /*
5257 @@ -759,6 +763,16 @@ static __inline__ int atomic64_add_unless(atomic64_t *v, long a, long u)
5258 */
5259 #define atomic64_add_negative(i, v) (atomic64_add_return(i, (v)) < 0)
5260
5261 +#define atomic64_read_unchecked(v) atomic64_read(v)
5262 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
5263 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
5264 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
5265 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
5266 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
5267 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
5268 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
5269 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
5270 +
5271 #endif /* CONFIG_64BIT */
5272
5273 /*
5274 diff --git a/arch/mips/include/asm/cache.h b/arch/mips/include/asm/cache.h
5275 index b4db69f..8f3b093 100644
5276 --- a/arch/mips/include/asm/cache.h
5277 +++ b/arch/mips/include/asm/cache.h
5278 @@ -9,10 +9,11 @@
5279 #ifndef _ASM_CACHE_H
5280 #define _ASM_CACHE_H
5281
5282 +#include <linux/const.h>
5283 #include <kmalloc.h>
5284
5285 #define L1_CACHE_SHIFT CONFIG_MIPS_L1_CACHE_SHIFT
5286 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
5287 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5288
5289 #define SMP_CACHE_SHIFT L1_CACHE_SHIFT
5290 #define SMP_CACHE_BYTES L1_CACHE_BYTES
5291 diff --git a/arch/mips/include/asm/elf.h b/arch/mips/include/asm/elf.h
5292 index 455c0ac..ad65fbe 100644
5293 --- a/arch/mips/include/asm/elf.h
5294 +++ b/arch/mips/include/asm/elf.h
5295 @@ -372,13 +372,16 @@ extern const char *__elf_platform;
5296 #define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
5297 #endif
5298
5299 +#ifdef CONFIG_PAX_ASLR
5300 +#define PAX_ELF_ET_DYN_BASE (TASK_IS_32BIT_ADDR ? 0x00400000UL : 0x00400000UL)
5301 +
5302 +#define PAX_DELTA_MMAP_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
5303 +#define PAX_DELTA_STACK_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
5304 +#endif
5305 +
5306 #define ARCH_HAS_SETUP_ADDITIONAL_PAGES 1
5307 struct linux_binprm;
5308 extern int arch_setup_additional_pages(struct linux_binprm *bprm,
5309 int uses_interp);
5310
5311 -struct mm_struct;
5312 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
5313 -#define arch_randomize_brk arch_randomize_brk
5314 -
5315 #endif /* _ASM_ELF_H */
5316 diff --git a/arch/mips/include/asm/exec.h b/arch/mips/include/asm/exec.h
5317 index c1f6afa..38cc6e9 100644
5318 --- a/arch/mips/include/asm/exec.h
5319 +++ b/arch/mips/include/asm/exec.h
5320 @@ -12,6 +12,6 @@
5321 #ifndef _ASM_EXEC_H
5322 #define _ASM_EXEC_H
5323
5324 -extern unsigned long arch_align_stack(unsigned long sp);
5325 +#define arch_align_stack(x) ((x) & ~0xfUL)
5326
5327 #endif /* _ASM_EXEC_H */
5328 diff --git a/arch/mips/include/asm/page.h b/arch/mips/include/asm/page.h
5329 index dbaec94..6a14935 100644
5330 --- a/arch/mips/include/asm/page.h
5331 +++ b/arch/mips/include/asm/page.h
5332 @@ -96,7 +96,7 @@ extern void copy_user_highpage(struct page *to, struct page *from,
5333 #ifdef CONFIG_CPU_MIPS32
5334 typedef struct { unsigned long pte_low, pte_high; } pte_t;
5335 #define pte_val(x) ((x).pte_low | ((unsigned long long)(x).pte_high << 32))
5336 - #define __pte(x) ({ pte_t __pte = {(x), ((unsigned long long)(x)) >> 32}; __pte; })
5337 + #define __pte(x) ({ pte_t __pte = {(x), (x) >> 32}; __pte; })
5338 #else
5339 typedef struct { unsigned long long pte; } pte_t;
5340 #define pte_val(x) ((x).pte)
5341 diff --git a/arch/mips/include/asm/pgalloc.h b/arch/mips/include/asm/pgalloc.h
5342 index 881d18b..cea38bc 100644
5343 --- a/arch/mips/include/asm/pgalloc.h
5344 +++ b/arch/mips/include/asm/pgalloc.h
5345 @@ -37,6 +37,11 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
5346 {
5347 set_pud(pud, __pud((unsigned long)pmd));
5348 }
5349 +
5350 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
5351 +{
5352 + pud_populate(mm, pud, pmd);
5353 +}
5354 #endif
5355
5356 /*
5357 diff --git a/arch/mips/include/asm/thread_info.h b/arch/mips/include/asm/thread_info.h
5358 index b2050b9..d71bb1b 100644
5359 --- a/arch/mips/include/asm/thread_info.h
5360 +++ b/arch/mips/include/asm/thread_info.h
5361 @@ -111,6 +111,8 @@ register struct thread_info *__current_thread_info __asm__("$28");
5362 #define TIF_32BIT_ADDR 23 /* 32-bit address space (o32/n32) */
5363 #define TIF_FPUBOUND 24 /* thread bound to FPU-full CPU set */
5364 #define TIF_LOAD_WATCH 25 /* If set, load watch registers */
5365 +/* li takes a 32bit immediate */
5366 +#define TIF_GRSEC_SETXID 29 /* update credentials on syscall entry/exit */
5367 #define TIF_SYSCALL_TRACE 31 /* syscall trace active */
5368
5369 #define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
5370 @@ -126,15 +128,18 @@ register struct thread_info *__current_thread_info __asm__("$28");
5371 #define _TIF_32BIT_ADDR (1<<TIF_32BIT_ADDR)
5372 #define _TIF_FPUBOUND (1<<TIF_FPUBOUND)
5373 #define _TIF_LOAD_WATCH (1<<TIF_LOAD_WATCH)
5374 +#define _TIF_GRSEC_SETXID (1<<TIF_GRSEC_SETXID)
5375 +
5376 +#define _TIF_SYSCALL_WORK (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | _TIF_GRSEC_SETXID)
5377
5378 /* work to do in syscall_trace_leave() */
5379 -#define _TIF_WORK_SYSCALL_EXIT (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT)
5380 +#define _TIF_WORK_SYSCALL_EXIT (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | _TIF_GRSEC_SETXID)
5381
5382 /* work to do on interrupt/exception return */
5383 #define _TIF_WORK_MASK \
5384 (_TIF_SIGPENDING | _TIF_NEED_RESCHED | _TIF_NOTIFY_RESUME)
5385 /* work to do on any return to u-space */
5386 -#define _TIF_ALLWORK_MASK (_TIF_WORK_MASK | _TIF_WORK_SYSCALL_EXIT)
5387 +#define _TIF_ALLWORK_MASK (_TIF_WORK_MASK | _TIF_WORK_SYSCALL_EXIT | _TIF_GRSEC_SETXID)
5388
5389 #endif /* __KERNEL__ */
5390
5391 diff --git a/arch/mips/kernel/binfmt_elfn32.c b/arch/mips/kernel/binfmt_elfn32.c
5392 index 9fdd8bc..4bd7f1a 100644
5393 --- a/arch/mips/kernel/binfmt_elfn32.c
5394 +++ b/arch/mips/kernel/binfmt_elfn32.c
5395 @@ -50,6 +50,13 @@ typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
5396 #undef ELF_ET_DYN_BASE
5397 #define ELF_ET_DYN_BASE (TASK32_SIZE / 3 * 2)
5398
5399 +#ifdef CONFIG_PAX_ASLR
5400 +#define PAX_ELF_ET_DYN_BASE (TASK_IS_32BIT_ADDR ? 0x00400000UL : 0x00400000UL)
5401 +
5402 +#define PAX_DELTA_MMAP_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
5403 +#define PAX_DELTA_STACK_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
5404 +#endif
5405 +
5406 #include <asm/processor.h>
5407 #include <linux/module.h>
5408 #include <linux/elfcore.h>
5409 diff --git a/arch/mips/kernel/binfmt_elfo32.c b/arch/mips/kernel/binfmt_elfo32.c
5410 index ff44823..97f8906 100644
5411 --- a/arch/mips/kernel/binfmt_elfo32.c
5412 +++ b/arch/mips/kernel/binfmt_elfo32.c
5413 @@ -52,6 +52,13 @@ typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
5414 #undef ELF_ET_DYN_BASE
5415 #define ELF_ET_DYN_BASE (TASK32_SIZE / 3 * 2)
5416
5417 +#ifdef CONFIG_PAX_ASLR
5418 +#define PAX_ELF_ET_DYN_BASE (TASK_IS_32BIT_ADDR ? 0x00400000UL : 0x00400000UL)
5419 +
5420 +#define PAX_DELTA_MMAP_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
5421 +#define PAX_DELTA_STACK_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
5422 +#endif
5423 +
5424 #include <asm/processor.h>
5425
5426 /*
5427 diff --git a/arch/mips/kernel/process.c b/arch/mips/kernel/process.c
5428 index a11c6f9..be5e164 100644
5429 --- a/arch/mips/kernel/process.c
5430 +++ b/arch/mips/kernel/process.c
5431 @@ -460,15 +460,3 @@ unsigned long get_wchan(struct task_struct *task)
5432 out:
5433 return pc;
5434 }
5435 -
5436 -/*
5437 - * Don't forget that the stack pointer must be aligned on a 8 bytes
5438 - * boundary for 32-bits ABI and 16 bytes for 64-bits ABI.
5439 - */
5440 -unsigned long arch_align_stack(unsigned long sp)
5441 -{
5442 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
5443 - sp -= get_random_int() & ~PAGE_MASK;
5444 -
5445 - return sp & ALMASK;
5446 -}
5447 diff --git a/arch/mips/kernel/ptrace.c b/arch/mips/kernel/ptrace.c
5448 index 4812c6d..2069554 100644
5449 --- a/arch/mips/kernel/ptrace.c
5450 +++ b/arch/mips/kernel/ptrace.c
5451 @@ -528,6 +528,10 @@ static inline int audit_arch(void)
5452 return arch;
5453 }
5454
5455 +#ifdef CONFIG_GRKERNSEC_SETXID
5456 +extern void gr_delayed_cred_worker(void);
5457 +#endif
5458 +
5459 /*
5460 * Notification of system call entry/exit
5461 * - triggered by current->work.syscall_trace
5462 @@ -537,6 +541,11 @@ asmlinkage void syscall_trace_enter(struct pt_regs *regs)
5463 /* do the secure computing check first */
5464 secure_computing_strict(regs->regs[2]);
5465
5466 +#ifdef CONFIG_GRKERNSEC_SETXID
5467 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
5468 + gr_delayed_cred_worker();
5469 +#endif
5470 +
5471 if (!(current->ptrace & PT_PTRACED))
5472 goto out;
5473
5474 diff --git a/arch/mips/kernel/scall32-o32.S b/arch/mips/kernel/scall32-o32.S
5475 index d20a4bc..7096ae5 100644
5476 --- a/arch/mips/kernel/scall32-o32.S
5477 +++ b/arch/mips/kernel/scall32-o32.S
5478 @@ -52,7 +52,7 @@ NESTED(handle_sys, PT_SIZE, sp)
5479
5480 stack_done:
5481 lw t0, TI_FLAGS($28) # syscall tracing enabled?
5482 - li t1, _TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT
5483 + li t1, _TIF_SYSCALL_WORK
5484 and t0, t1
5485 bnez t0, syscall_trace_entry # -> yes
5486
5487 diff --git a/arch/mips/kernel/scall64-64.S b/arch/mips/kernel/scall64-64.S
5488 index b64f642..0fe6eab 100644
5489 --- a/arch/mips/kernel/scall64-64.S
5490 +++ b/arch/mips/kernel/scall64-64.S
5491 @@ -54,7 +54,7 @@ NESTED(handle_sys64, PT_SIZE, sp)
5492
5493 sd a3, PT_R26(sp) # save a3 for syscall restarting
5494
5495 - li t1, _TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT
5496 + li t1, _TIF_SYSCALL_WORK
5497 LONG_L t0, TI_FLAGS($28) # syscall tracing enabled?
5498 and t0, t1, t0
5499 bnez t0, syscall_trace_entry
5500 diff --git a/arch/mips/kernel/scall64-n32.S b/arch/mips/kernel/scall64-n32.S
5501 index c29ac19..c592d05 100644
5502 --- a/arch/mips/kernel/scall64-n32.S
5503 +++ b/arch/mips/kernel/scall64-n32.S
5504 @@ -47,7 +47,7 @@ NESTED(handle_sysn32, PT_SIZE, sp)
5505
5506 sd a3, PT_R26(sp) # save a3 for syscall restarting
5507
5508 - li t1, _TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT
5509 + li t1, _TIF_SYSCALL_WORK
5510 LONG_L t0, TI_FLAGS($28) # syscall tracing enabled?
5511 and t0, t1, t0
5512 bnez t0, n32_syscall_trace_entry
5513 diff --git a/arch/mips/kernel/scall64-o32.S b/arch/mips/kernel/scall64-o32.S
5514 index cf3e75e..72e93fe 100644
5515 --- a/arch/mips/kernel/scall64-o32.S
5516 +++ b/arch/mips/kernel/scall64-o32.S
5517 @@ -81,7 +81,7 @@ NESTED(handle_sys, PT_SIZE, sp)
5518 PTR 4b, bad_stack
5519 .previous
5520
5521 - li t1, _TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT
5522 + li t1, _TIF_SYSCALL_WORK
5523 LONG_L t0, TI_FLAGS($28) # syscall tracing enabled?
5524 and t0, t1, t0
5525 bnez t0, trace_a_syscall
5526 diff --git a/arch/mips/mm/fault.c b/arch/mips/mm/fault.c
5527 index ddcec1e..c7f983e 100644
5528 --- a/arch/mips/mm/fault.c
5529 +++ b/arch/mips/mm/fault.c
5530 @@ -27,6 +27,23 @@
5531 #include <asm/highmem.h> /* For VMALLOC_END */
5532 #include <linux/kdebug.h>
5533
5534 +#ifdef CONFIG_PAX_PAGEEXEC
5535 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
5536 +{
5537 + unsigned long i;
5538 +
5539 + printk(KERN_ERR "PAX: bytes at PC: ");
5540 + for (i = 0; i < 5; i++) {
5541 + unsigned int c;
5542 + if (get_user(c, (unsigned int *)pc+i))
5543 + printk(KERN_CONT "???????? ");
5544 + else
5545 + printk(KERN_CONT "%08x ", c);
5546 + }
5547 + printk("\n");
5548 +}
5549 +#endif
5550 +
5551 /*
5552 * This routine handles page faults. It determines the address,
5553 * and the problem, and then passes it off to one of the appropriate
5554 diff --git a/arch/mips/mm/mmap.c b/arch/mips/mm/mmap.c
5555 index 7e5fe27..479a219 100644
5556 --- a/arch/mips/mm/mmap.c
5557 +++ b/arch/mips/mm/mmap.c
5558 @@ -59,6 +59,7 @@ static unsigned long arch_get_unmapped_area_common(struct file *filp,
5559 struct vm_area_struct *vma;
5560 unsigned long addr = addr0;
5561 int do_color_align;
5562 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
5563 struct vm_unmapped_area_info info;
5564
5565 if (unlikely(len > TASK_SIZE))
5566 @@ -84,6 +85,11 @@ static unsigned long arch_get_unmapped_area_common(struct file *filp,
5567 do_color_align = 1;
5568
5569 /* requesting a specific address */
5570 +
5571 +#ifdef CONFIG_PAX_RANDMMAP
5572 + if (!(current->mm->pax_flags & MF_PAX_RANDMMAP))
5573 +#endif
5574 +
5575 if (addr) {
5576 if (do_color_align)
5577 addr = COLOUR_ALIGN(addr, pgoff);
5578 @@ -91,8 +97,7 @@ static unsigned long arch_get_unmapped_area_common(struct file *filp,
5579 addr = PAGE_ALIGN(addr);
5580
5581 vma = find_vma(mm, addr);
5582 - if (TASK_SIZE - len >= addr &&
5583 - (!vma || addr + len <= vma->vm_start))
5584 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vmm, addr, len, offset))
5585 return addr;
5586 }
5587
5588 @@ -146,6 +151,10 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
5589 {
5590 unsigned long random_factor = 0UL;
5591
5592 +#ifdef CONFIG_PAX_RANDMMAP
5593 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
5594 +#endif
5595 +
5596 if (current->flags & PF_RANDOMIZE) {
5597 random_factor = get_random_int();
5598 random_factor = random_factor << PAGE_SHIFT;
5599 @@ -157,42 +166,27 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
5600
5601 if (mmap_is_legacy()) {
5602 mm->mmap_base = TASK_UNMAPPED_BASE + random_factor;
5603 +
5604 +#ifdef CONFIG_PAX_RANDMMAP
5605 + if (mm->pax_flags & MF_PAX_RANDMMAP)
5606 + mm->mmap_base += mm->delta_mmap;
5607 +#endif
5608 +
5609 mm->get_unmapped_area = arch_get_unmapped_area;
5610 mm->unmap_area = arch_unmap_area;
5611 } else {
5612 mm->mmap_base = mmap_base(random_factor);
5613 +
5614 +#ifdef CONFIG_PAX_RANDMMAP
5615 + if (mm->pax_flags & MF_PAX_RANDMMAP)
5616 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
5617 +#endif
5618 +
5619 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
5620 mm->unmap_area = arch_unmap_area_topdown;
5621 }
5622 }
5623
5624 -static inline unsigned long brk_rnd(void)
5625 -{
5626 - unsigned long rnd = get_random_int();
5627 -
5628 - rnd = rnd << PAGE_SHIFT;
5629 - /* 8MB for 32bit, 256MB for 64bit */
5630 - if (TASK_IS_32BIT_ADDR)
5631 - rnd = rnd & 0x7ffffful;
5632 - else
5633 - rnd = rnd & 0xffffffful;
5634 -
5635 - return rnd;
5636 -}
5637 -
5638 -unsigned long arch_randomize_brk(struct mm_struct *mm)
5639 -{
5640 - unsigned long base = mm->brk;
5641 - unsigned long ret;
5642 -
5643 - ret = PAGE_ALIGN(base + brk_rnd());
5644 -
5645 - if (ret < mm->brk)
5646 - return mm->brk;
5647 -
5648 - return ret;
5649 -}
5650 -
5651 int __virt_addr_valid(const volatile void *kaddr)
5652 {
5653 return pfn_valid(PFN_DOWN(virt_to_phys(kaddr)));
5654 diff --git a/arch/mn10300/proc-mn103e010/include/proc/cache.h b/arch/mn10300/proc-mn103e010/include/proc/cache.h
5655 index 967d144..db12197 100644
5656 --- a/arch/mn10300/proc-mn103e010/include/proc/cache.h
5657 +++ b/arch/mn10300/proc-mn103e010/include/proc/cache.h
5658 @@ -11,12 +11,14 @@
5659 #ifndef _ASM_PROC_CACHE_H
5660 #define _ASM_PROC_CACHE_H
5661
5662 +#include <linux/const.h>
5663 +
5664 /* L1 cache */
5665
5666 #define L1_CACHE_NWAYS 4 /* number of ways in caches */
5667 #define L1_CACHE_NENTRIES 256 /* number of entries in each way */
5668 -#define L1_CACHE_BYTES 16 /* bytes per entry */
5669 #define L1_CACHE_SHIFT 4 /* shift for bytes per entry */
5670 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT) /* bytes per entry */
5671 #define L1_CACHE_WAYDISP 0x1000 /* displacement of one way from the next */
5672
5673 #define L1_CACHE_TAG_VALID 0x00000001 /* cache tag valid bit */
5674 diff --git a/arch/mn10300/proc-mn2ws0050/include/proc/cache.h b/arch/mn10300/proc-mn2ws0050/include/proc/cache.h
5675 index bcb5df2..84fabd2 100644
5676 --- a/arch/mn10300/proc-mn2ws0050/include/proc/cache.h
5677 +++ b/arch/mn10300/proc-mn2ws0050/include/proc/cache.h
5678 @@ -16,13 +16,15 @@
5679 #ifndef _ASM_PROC_CACHE_H
5680 #define _ASM_PROC_CACHE_H
5681
5682 +#include <linux/const.h>
5683 +
5684 /*
5685 * L1 cache
5686 */
5687 #define L1_CACHE_NWAYS 4 /* number of ways in caches */
5688 #define L1_CACHE_NENTRIES 128 /* number of entries in each way */
5689 -#define L1_CACHE_BYTES 32 /* bytes per entry */
5690 #define L1_CACHE_SHIFT 5 /* shift for bytes per entry */
5691 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT) /* bytes per entry */
5692 #define L1_CACHE_WAYDISP 0x1000 /* distance from one way to the next */
5693
5694 #define L1_CACHE_TAG_VALID 0x00000001 /* cache tag valid bit */
5695 diff --git a/arch/openrisc/include/asm/cache.h b/arch/openrisc/include/asm/cache.h
5696 index 4ce7a01..449202a 100644
5697 --- a/arch/openrisc/include/asm/cache.h
5698 +++ b/arch/openrisc/include/asm/cache.h
5699 @@ -19,11 +19,13 @@
5700 #ifndef __ASM_OPENRISC_CACHE_H
5701 #define __ASM_OPENRISC_CACHE_H
5702
5703 +#include <linux/const.h>
5704 +
5705 /* FIXME: How can we replace these with values from the CPU...
5706 * they shouldn't be hard-coded!
5707 */
5708
5709 -#define L1_CACHE_BYTES 16
5710 #define L1_CACHE_SHIFT 4
5711 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5712
5713 #endif /* __ASM_OPENRISC_CACHE_H */
5714 diff --git a/arch/parisc/include/asm/atomic.h b/arch/parisc/include/asm/atomic.h
5715 index af9cf30..2aae9b2 100644
5716 --- a/arch/parisc/include/asm/atomic.h
5717 +++ b/arch/parisc/include/asm/atomic.h
5718 @@ -229,6 +229,16 @@ static __inline__ int atomic64_add_unless(atomic64_t *v, long a, long u)
5719
5720 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
5721
5722 +#define atomic64_read_unchecked(v) atomic64_read(v)
5723 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
5724 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
5725 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
5726 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
5727 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
5728 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
5729 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
5730 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
5731 +
5732 #endif /* !CONFIG_64BIT */
5733
5734
5735 diff --git a/arch/parisc/include/asm/cache.h b/arch/parisc/include/asm/cache.h
5736 index 47f11c7..3420df2 100644
5737 --- a/arch/parisc/include/asm/cache.h
5738 +++ b/arch/parisc/include/asm/cache.h
5739 @@ -5,6 +5,7 @@
5740 #ifndef __ARCH_PARISC_CACHE_H
5741 #define __ARCH_PARISC_CACHE_H
5742
5743 +#include <linux/const.h>
5744
5745 /*
5746 * PA 2.0 processors have 64-byte cachelines; PA 1.1 processors have
5747 @@ -15,13 +16,13 @@
5748 * just ruin performance.
5749 */
5750 #ifdef CONFIG_PA20
5751 -#define L1_CACHE_BYTES 64
5752 #define L1_CACHE_SHIFT 6
5753 #else
5754 -#define L1_CACHE_BYTES 32
5755 #define L1_CACHE_SHIFT 5
5756 #endif
5757
5758 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5759 +
5760 #ifndef __ASSEMBLY__
5761
5762 #define SMP_CACHE_BYTES L1_CACHE_BYTES
5763 diff --git a/arch/parisc/include/asm/elf.h b/arch/parisc/include/asm/elf.h
5764 index 19f6cb1..6c78cf2 100644
5765 --- a/arch/parisc/include/asm/elf.h
5766 +++ b/arch/parisc/include/asm/elf.h
5767 @@ -342,6 +342,13 @@ struct pt_regs; /* forward declaration... */
5768
5769 #define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE + 0x01000000)
5770
5771 +#ifdef CONFIG_PAX_ASLR
5772 +#define PAX_ELF_ET_DYN_BASE 0x10000UL
5773 +
5774 +#define PAX_DELTA_MMAP_LEN 16
5775 +#define PAX_DELTA_STACK_LEN 16
5776 +#endif
5777 +
5778 /* This yields a mask that user programs can use to figure out what
5779 instruction set this CPU supports. This could be done in user space,
5780 but it's not easy, and we've already done it here. */
5781 diff --git a/arch/parisc/include/asm/pgalloc.h b/arch/parisc/include/asm/pgalloc.h
5782 index fc987a1..6e068ef 100644
5783 --- a/arch/parisc/include/asm/pgalloc.h
5784 +++ b/arch/parisc/include/asm/pgalloc.h
5785 @@ -61,6 +61,11 @@ static inline void pgd_populate(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmd)
5786 (__u32)(__pa((unsigned long)pmd) >> PxD_VALUE_SHIFT));
5787 }
5788
5789 +static inline void pgd_populate_kernel(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmd)
5790 +{
5791 + pgd_populate(mm, pgd, pmd);
5792 +}
5793 +
5794 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long address)
5795 {
5796 pmd_t *pmd = (pmd_t *)__get_free_pages(GFP_KERNEL|__GFP_REPEAT,
5797 @@ -93,6 +98,7 @@ static inline void pmd_free(struct mm_struct *mm, pmd_t *pmd)
5798 #define pmd_alloc_one(mm, addr) ({ BUG(); ((pmd_t *)2); })
5799 #define pmd_free(mm, x) do { } while (0)
5800 #define pgd_populate(mm, pmd, pte) BUG()
5801 +#define pgd_populate_kernel(mm, pmd, pte) BUG()
5802
5803 #endif
5804
5805 diff --git a/arch/parisc/include/asm/pgtable.h b/arch/parisc/include/asm/pgtable.h
5806 index 7df49fa..38b62bf 100644
5807 --- a/arch/parisc/include/asm/pgtable.h
5808 +++ b/arch/parisc/include/asm/pgtable.h
5809 @@ -218,6 +218,17 @@ extern void purge_tlb_entries(struct mm_struct *, unsigned long);
5810 #define PAGE_EXECREAD __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_EXEC |_PAGE_ACCESSED)
5811 #define PAGE_COPY PAGE_EXECREAD
5812 #define PAGE_RWX __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_WRITE | _PAGE_EXEC |_PAGE_ACCESSED)
5813 +
5814 +#ifdef CONFIG_PAX_PAGEEXEC
5815 +# define PAGE_SHARED_NOEXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_WRITE | _PAGE_ACCESSED)
5816 +# define PAGE_COPY_NOEXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_ACCESSED)
5817 +# define PAGE_READONLY_NOEXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_ACCESSED)
5818 +#else
5819 +# define PAGE_SHARED_NOEXEC PAGE_SHARED
5820 +# define PAGE_COPY_NOEXEC PAGE_COPY
5821 +# define PAGE_READONLY_NOEXEC PAGE_READONLY
5822 +#endif
5823 +
5824 #define PAGE_KERNEL __pgprot(_PAGE_KERNEL)
5825 #define PAGE_KERNEL_EXEC __pgprot(_PAGE_KERNEL_EXEC)
5826 #define PAGE_KERNEL_RWX __pgprot(_PAGE_KERNEL_RWX)
5827 diff --git a/arch/parisc/include/asm/uaccess.h b/arch/parisc/include/asm/uaccess.h
5828 index 4ba2c93..f5e3974 100644
5829 --- a/arch/parisc/include/asm/uaccess.h
5830 +++ b/arch/parisc/include/asm/uaccess.h
5831 @@ -251,10 +251,10 @@ static inline unsigned long __must_check copy_from_user(void *to,
5832 const void __user *from,
5833 unsigned long n)
5834 {
5835 - int sz = __compiletime_object_size(to);
5836 + size_t sz = __compiletime_object_size(to);
5837 int ret = -EFAULT;
5838
5839 - if (likely(sz == -1 || !__builtin_constant_p(n) || sz >= n))
5840 + if (likely(sz == (size_t)-1 || !__builtin_constant_p(n) || sz >= n))
5841 ret = __copy_from_user(to, from, n);
5842 else
5843 copy_from_user_overflow();
5844 diff --git a/arch/parisc/kernel/module.c b/arch/parisc/kernel/module.c
5845 index 2a625fb..9908930 100644
5846 --- a/arch/parisc/kernel/module.c
5847 +++ b/arch/parisc/kernel/module.c
5848 @@ -98,16 +98,38 @@
5849
5850 /* three functions to determine where in the module core
5851 * or init pieces the location is */
5852 +static inline int in_init_rx(struct module *me, void *loc)
5853 +{
5854 + return (loc >= me->module_init_rx &&
5855 + loc < (me->module_init_rx + me->init_size_rx));
5856 +}
5857 +
5858 +static inline int in_init_rw(struct module *me, void *loc)
5859 +{
5860 + return (loc >= me->module_init_rw &&
5861 + loc < (me->module_init_rw + me->init_size_rw));
5862 +}
5863 +
5864 static inline int in_init(struct module *me, void *loc)
5865 {
5866 - return (loc >= me->module_init &&
5867 - loc <= (me->module_init + me->init_size));
5868 + return in_init_rx(me, loc) || in_init_rw(me, loc);
5869 +}
5870 +
5871 +static inline int in_core_rx(struct module *me, void *loc)
5872 +{
5873 + return (loc >= me->module_core_rx &&
5874 + loc < (me->module_core_rx + me->core_size_rx));
5875 +}
5876 +
5877 +static inline int in_core_rw(struct module *me, void *loc)
5878 +{
5879 + return (loc >= me->module_core_rw &&
5880 + loc < (me->module_core_rw + me->core_size_rw));
5881 }
5882
5883 static inline int in_core(struct module *me, void *loc)
5884 {
5885 - return (loc >= me->module_core &&
5886 - loc <= (me->module_core + me->core_size));
5887 + return in_core_rx(me, loc) || in_core_rw(me, loc);
5888 }
5889
5890 static inline int in_local(struct module *me, void *loc)
5891 @@ -371,13 +393,13 @@ int module_frob_arch_sections(CONST Elf_Ehdr *hdr,
5892 }
5893
5894 /* align things a bit */
5895 - me->core_size = ALIGN(me->core_size, 16);
5896 - me->arch.got_offset = me->core_size;
5897 - me->core_size += gots * sizeof(struct got_entry);
5898 + me->core_size_rw = ALIGN(me->core_size_rw, 16);
5899 + me->arch.got_offset = me->core_size_rw;
5900 + me->core_size_rw += gots * sizeof(struct got_entry);
5901
5902 - me->core_size = ALIGN(me->core_size, 16);
5903 - me->arch.fdesc_offset = me->core_size;
5904 - me->core_size += fdescs * sizeof(Elf_Fdesc);
5905 + me->core_size_rw = ALIGN(me->core_size_rw, 16);
5906 + me->arch.fdesc_offset = me->core_size_rw;
5907 + me->core_size_rw += fdescs * sizeof(Elf_Fdesc);
5908
5909 me->arch.got_max = gots;
5910 me->arch.fdesc_max = fdescs;
5911 @@ -395,7 +417,7 @@ static Elf64_Word get_got(struct module *me, unsigned long value, long addend)
5912
5913 BUG_ON(value == 0);
5914
5915 - got = me->module_core + me->arch.got_offset;
5916 + got = me->module_core_rw + me->arch.got_offset;
5917 for (i = 0; got[i].addr; i++)
5918 if (got[i].addr == value)
5919 goto out;
5920 @@ -413,7 +435,7 @@ static Elf64_Word get_got(struct module *me, unsigned long value, long addend)
5921 #ifdef CONFIG_64BIT
5922 static Elf_Addr get_fdesc(struct module *me, unsigned long value)
5923 {
5924 - Elf_Fdesc *fdesc = me->module_core + me->arch.fdesc_offset;
5925 + Elf_Fdesc *fdesc = me->module_core_rw + me->arch.fdesc_offset;
5926
5927 if (!value) {
5928 printk(KERN_ERR "%s: zero OPD requested!\n", me->name);
5929 @@ -431,7 +453,7 @@ static Elf_Addr get_fdesc(struct module *me, unsigned long value)
5930
5931 /* Create new one */
5932 fdesc->addr = value;
5933 - fdesc->gp = (Elf_Addr)me->module_core + me->arch.got_offset;
5934 + fdesc->gp = (Elf_Addr)me->module_core_rw + me->arch.got_offset;
5935 return (Elf_Addr)fdesc;
5936 }
5937 #endif /* CONFIG_64BIT */
5938 @@ -843,7 +865,7 @@ register_unwind_table(struct module *me,
5939
5940 table = (unsigned char *)sechdrs[me->arch.unwind_section].sh_addr;
5941 end = table + sechdrs[me->arch.unwind_section].sh_size;
5942 - gp = (Elf_Addr)me->module_core + me->arch.got_offset;
5943 + gp = (Elf_Addr)me->module_core_rw + me->arch.got_offset;
5944
5945 DEBUGP("register_unwind_table(), sect = %d at 0x%p - 0x%p (gp=0x%lx)\n",
5946 me->arch.unwind_section, table, end, gp);
5947 diff --git a/arch/parisc/kernel/sys_parisc.c b/arch/parisc/kernel/sys_parisc.c
5948 index f76c108..92bad82 100644
5949 --- a/arch/parisc/kernel/sys_parisc.c
5950 +++ b/arch/parisc/kernel/sys_parisc.c
5951 @@ -33,9 +33,11 @@
5952 #include <linux/utsname.h>
5953 #include <linux/personality.h>
5954
5955 -static unsigned long get_unshared_area(unsigned long addr, unsigned long len)
5956 +static unsigned long get_unshared_area(struct file *filp, unsigned long addr, unsigned long len,
5957 + unsigned long flags)
5958 {
5959 struct vm_area_struct *vma;
5960 + unsigned long offset = gr_rand_threadstack_offset(current->mm, filp, flags);
5961
5962 addr = PAGE_ALIGN(addr);
5963
5964 @@ -43,7 +45,7 @@ static unsigned long get_unshared_area(unsigned long addr, unsigned long len)
5965 /* At this point: (!vma || addr < vma->vm_end). */
5966 if (TASK_SIZE - len < addr)
5967 return -ENOMEM;
5968 - if (!vma || addr + len <= vma->vm_start)
5969 + if (check_heap_stack_gap(vma, addr, len, offset))
5970 return addr;
5971 addr = vma->vm_end;
5972 }
5973 @@ -67,11 +69,12 @@ static int get_offset(struct address_space *mapping)
5974 return offset & 0x3FF000;
5975 }
5976
5977 -static unsigned long get_shared_area(struct address_space *mapping,
5978 - unsigned long addr, unsigned long len, unsigned long pgoff)
5979 +static unsigned long get_shared_area(struct file *filp, struct address_space *mapping,
5980 + unsigned long addr, unsigned long len, unsigned long pgoff, unsigned long flags)
5981 {
5982 struct vm_area_struct *vma;
5983 int offset = mapping ? get_offset(mapping) : 0;
5984 + unsigned long rand_offset = gr_rand_threadstack_offset(current->mm, filp, flags);
5985
5986 offset = (offset + (pgoff << PAGE_SHIFT)) & 0x3FF000;
5987
5988 @@ -81,7 +84,7 @@ static unsigned long get_shared_area(struct address_space *mapping,
5989 /* At this point: (!vma || addr < vma->vm_end). */
5990 if (TASK_SIZE - len < addr)
5991 return -ENOMEM;
5992 - if (!vma || addr + len <= vma->vm_start)
5993 + if (check_heap_stack_gap(vma, addr, len, rand_offset))
5994 return addr;
5995 addr = DCACHE_ALIGN(vma->vm_end - offset) + offset;
5996 if (addr < vma->vm_end) /* handle wraparound */
5997 @@ -100,14 +103,14 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
5998 if (flags & MAP_FIXED)
5999 return addr;
6000 if (!addr)
6001 - addr = TASK_UNMAPPED_BASE;
6002 + addr = current->mm->mmap_base;
6003
6004 if (filp) {
6005 - addr = get_shared_area(filp->f_mapping, addr, len, pgoff);
6006 + addr = get_shared_area(filp, filp->f_mapping, addr, len, pgoff, flags);
6007 } else if(flags & MAP_SHARED) {
6008 - addr = get_shared_area(NULL, addr, len, pgoff);
6009 + addr = get_shared_area(filp, NULL, addr, len, pgoff, flags);
6010 } else {
6011 - addr = get_unshared_area(addr, len);
6012 + addr = get_unshared_area(filp, addr, len, flags);
6013 }
6014 return addr;
6015 }
6016 diff --git a/arch/parisc/kernel/traps.c b/arch/parisc/kernel/traps.c
6017 index 45ba99f..8e22c33 100644
6018 --- a/arch/parisc/kernel/traps.c
6019 +++ b/arch/parisc/kernel/traps.c
6020 @@ -732,9 +732,7 @@ void notrace handle_interruption(int code, struct pt_regs *regs)
6021
6022 down_read(&current->mm->mmap_sem);
6023 vma = find_vma(current->mm,regs->iaoq[0]);
6024 - if (vma && (regs->iaoq[0] >= vma->vm_start)
6025 - && (vma->vm_flags & VM_EXEC)) {
6026 -
6027 + if (vma && (regs->iaoq[0] >= vma->vm_start)) {
6028 fault_address = regs->iaoq[0];
6029 fault_space = regs->iasq[0];
6030
6031 diff --git a/arch/parisc/mm/fault.c b/arch/parisc/mm/fault.c
6032 index 18162ce..94de376 100644
6033 --- a/arch/parisc/mm/fault.c
6034 +++ b/arch/parisc/mm/fault.c
6035 @@ -15,6 +15,7 @@
6036 #include <linux/sched.h>
6037 #include <linux/interrupt.h>
6038 #include <linux/module.h>
6039 +#include <linux/unistd.h>
6040
6041 #include <asm/uaccess.h>
6042 #include <asm/traps.h>
6043 @@ -52,7 +53,7 @@ DEFINE_PER_CPU(struct exception_data, exception_data);
6044 static unsigned long
6045 parisc_acctyp(unsigned long code, unsigned int inst)
6046 {
6047 - if (code == 6 || code == 16)
6048 + if (code == 6 || code == 7 || code == 16)
6049 return VM_EXEC;
6050
6051 switch (inst & 0xf0000000) {
6052 @@ -138,6 +139,116 @@ parisc_acctyp(unsigned long code, unsigned int inst)
6053 }
6054 #endif
6055
6056 +#ifdef CONFIG_PAX_PAGEEXEC
6057 +/*
6058 + * PaX: decide what to do with offenders (instruction_pointer(regs) = fault address)
6059 + *
6060 + * returns 1 when task should be killed
6061 + * 2 when rt_sigreturn trampoline was detected
6062 + * 3 when unpatched PLT trampoline was detected
6063 + */
6064 +static int pax_handle_fetch_fault(struct pt_regs *regs)
6065 +{
6066 +
6067 +#ifdef CONFIG_PAX_EMUPLT
6068 + int err;
6069 +
6070 + do { /* PaX: unpatched PLT emulation */
6071 + unsigned int bl, depwi;
6072 +
6073 + err = get_user(bl, (unsigned int *)instruction_pointer(regs));
6074 + err |= get_user(depwi, (unsigned int *)(instruction_pointer(regs)+4));
6075 +
6076 + if (err)
6077 + break;
6078 +
6079 + if (bl == 0xEA9F1FDDU && depwi == 0xD6801C1EU) {
6080 + unsigned int ldw, bv, ldw2, addr = instruction_pointer(regs)-12;
6081 +
6082 + err = get_user(ldw, (unsigned int *)addr);
6083 + err |= get_user(bv, (unsigned int *)(addr+4));
6084 + err |= get_user(ldw2, (unsigned int *)(addr+8));
6085 +
6086 + if (err)
6087 + break;
6088 +
6089 + if (ldw == 0x0E801096U &&
6090 + bv == 0xEAC0C000U &&
6091 + ldw2 == 0x0E881095U)
6092 + {
6093 + unsigned int resolver, map;
6094 +
6095 + err = get_user(resolver, (unsigned int *)(instruction_pointer(regs)+8));
6096 + err |= get_user(map, (unsigned int *)(instruction_pointer(regs)+12));
6097 + if (err)
6098 + break;
6099 +
6100 + regs->gr[20] = instruction_pointer(regs)+8;
6101 + regs->gr[21] = map;
6102 + regs->gr[22] = resolver;
6103 + regs->iaoq[0] = resolver | 3UL;
6104 + regs->iaoq[1] = regs->iaoq[0] + 4;
6105 + return 3;
6106 + }
6107 + }
6108 + } while (0);
6109 +#endif
6110 +
6111 +#ifdef CONFIG_PAX_EMUTRAMP
6112 +
6113 +#ifndef CONFIG_PAX_EMUSIGRT
6114 + if (!(current->mm->pax_flags & MF_PAX_EMUTRAMP))
6115 + return 1;
6116 +#endif
6117 +
6118 + do { /* PaX: rt_sigreturn emulation */
6119 + unsigned int ldi1, ldi2, bel, nop;
6120 +
6121 + err = get_user(ldi1, (unsigned int *)instruction_pointer(regs));
6122 + err |= get_user(ldi2, (unsigned int *)(instruction_pointer(regs)+4));
6123 + err |= get_user(bel, (unsigned int *)(instruction_pointer(regs)+8));
6124 + err |= get_user(nop, (unsigned int *)(instruction_pointer(regs)+12));
6125 +
6126 + if (err)
6127 + break;
6128 +
6129 + if ((ldi1 == 0x34190000U || ldi1 == 0x34190002U) &&
6130 + ldi2 == 0x3414015AU &&
6131 + bel == 0xE4008200U &&
6132 + nop == 0x08000240U)
6133 + {
6134 + regs->gr[25] = (ldi1 & 2) >> 1;
6135 + regs->gr[20] = __NR_rt_sigreturn;
6136 + regs->gr[31] = regs->iaoq[1] + 16;
6137 + regs->sr[0] = regs->iasq[1];
6138 + regs->iaoq[0] = 0x100UL;
6139 + regs->iaoq[1] = regs->iaoq[0] + 4;
6140 + regs->iasq[0] = regs->sr[2];
6141 + regs->iasq[1] = regs->sr[2];
6142 + return 2;
6143 + }
6144 + } while (0);
6145 +#endif
6146 +
6147 + return 1;
6148 +}
6149 +
6150 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
6151 +{
6152 + unsigned long i;
6153 +
6154 + printk(KERN_ERR "PAX: bytes at PC: ");
6155 + for (i = 0; i < 5; i++) {
6156 + unsigned int c;
6157 + if (get_user(c, (unsigned int *)pc+i))
6158 + printk(KERN_CONT "???????? ");
6159 + else
6160 + printk(KERN_CONT "%08x ", c);
6161 + }
6162 + printk("\n");
6163 +}
6164 +#endif
6165 +
6166 int fixup_exception(struct pt_regs *regs)
6167 {
6168 const struct exception_table_entry *fix;
6169 @@ -192,8 +303,33 @@ good_area:
6170
6171 acc_type = parisc_acctyp(code,regs->iir);
6172
6173 - if ((vma->vm_flags & acc_type) != acc_type)
6174 + if ((vma->vm_flags & acc_type) != acc_type) {
6175 +
6176 +#ifdef CONFIG_PAX_PAGEEXEC
6177 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && (acc_type & VM_EXEC) &&
6178 + (address & ~3UL) == instruction_pointer(regs))
6179 + {
6180 + up_read(&mm->mmap_sem);
6181 + switch (pax_handle_fetch_fault(regs)) {
6182 +
6183 +#ifdef CONFIG_PAX_EMUPLT
6184 + case 3:
6185 + return;
6186 +#endif
6187 +
6188 +#ifdef CONFIG_PAX_EMUTRAMP
6189 + case 2:
6190 + return;
6191 +#endif
6192 +
6193 + }
6194 + pax_report_fault(regs, (void *)instruction_pointer(regs), (void *)regs->gr[30]);
6195 + do_group_exit(SIGKILL);
6196 + }
6197 +#endif
6198 +
6199 goto bad_area;
6200 + }
6201
6202 /*
6203 * If for any reason at all we couldn't handle the fault, make
6204 diff --git a/arch/powerpc/include/asm/atomic.h b/arch/powerpc/include/asm/atomic.h
6205 index e3b1d41..8e81edf 100644
6206 --- a/arch/powerpc/include/asm/atomic.h
6207 +++ b/arch/powerpc/include/asm/atomic.h
6208 @@ -523,6 +523,16 @@ static __inline__ long atomic64_inc_not_zero(atomic64_t *v)
6209 return t1;
6210 }
6211
6212 +#define atomic64_read_unchecked(v) atomic64_read(v)
6213 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
6214 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
6215 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
6216 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
6217 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
6218 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
6219 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
6220 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
6221 +
6222 #endif /* __powerpc64__ */
6223
6224 #endif /* __KERNEL__ */
6225 diff --git a/arch/powerpc/include/asm/cache.h b/arch/powerpc/include/asm/cache.h
6226 index 9e495c9..b6878e5 100644
6227 --- a/arch/powerpc/include/asm/cache.h
6228 +++ b/arch/powerpc/include/asm/cache.h
6229 @@ -3,6 +3,7 @@
6230
6231 #ifdef __KERNEL__
6232
6233 +#include <linux/const.h>
6234
6235 /* bytes per L1 cache line */
6236 #if defined(CONFIG_8xx) || defined(CONFIG_403GCX)
6237 @@ -22,7 +23,7 @@
6238 #define L1_CACHE_SHIFT 7
6239 #endif
6240
6241 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
6242 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
6243
6244 #define SMP_CACHE_BYTES L1_CACHE_BYTES
6245
6246 diff --git a/arch/powerpc/include/asm/elf.h b/arch/powerpc/include/asm/elf.h
6247 index 6abf0a1..459d0f1 100644
6248 --- a/arch/powerpc/include/asm/elf.h
6249 +++ b/arch/powerpc/include/asm/elf.h
6250 @@ -28,8 +28,19 @@
6251 the loader. We need to make sure that it is out of the way of the program
6252 that it will "exec", and that there is sufficient room for the brk. */
6253
6254 -extern unsigned long randomize_et_dyn(unsigned long base);
6255 -#define ELF_ET_DYN_BASE (randomize_et_dyn(0x20000000))
6256 +#define ELF_ET_DYN_BASE (0x20000000)
6257 +
6258 +#ifdef CONFIG_PAX_ASLR
6259 +#define PAX_ELF_ET_DYN_BASE (0x10000000UL)
6260 +
6261 +#ifdef __powerpc64__
6262 +#define PAX_DELTA_MMAP_LEN (is_32bit_task() ? 16 : 28)
6263 +#define PAX_DELTA_STACK_LEN (is_32bit_task() ? 16 : 28)
6264 +#else
6265 +#define PAX_DELTA_MMAP_LEN 15
6266 +#define PAX_DELTA_STACK_LEN 15
6267 +#endif
6268 +#endif
6269
6270 /*
6271 * Our registers are always unsigned longs, whether we're a 32 bit
6272 @@ -124,10 +135,6 @@ extern int arch_setup_additional_pages(struct linux_binprm *bprm,
6273 (0x7ff >> (PAGE_SHIFT - 12)) : \
6274 (0x3ffff >> (PAGE_SHIFT - 12)))
6275
6276 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
6277 -#define arch_randomize_brk arch_randomize_brk
6278 -
6279 -
6280 #ifdef CONFIG_SPU_BASE
6281 /* Notes used in ET_CORE. Note name is "SPU/<fd>/<filename>". */
6282 #define NT_SPU 1
6283 diff --git a/arch/powerpc/include/asm/exec.h b/arch/powerpc/include/asm/exec.h
6284 index 8196e9c..d83a9f3 100644
6285 --- a/arch/powerpc/include/asm/exec.h
6286 +++ b/arch/powerpc/include/asm/exec.h
6287 @@ -4,6 +4,6 @@
6288 #ifndef _ASM_POWERPC_EXEC_H
6289 #define _ASM_POWERPC_EXEC_H
6290
6291 -extern unsigned long arch_align_stack(unsigned long sp);
6292 +#define arch_align_stack(x) ((x) & ~0xfUL)
6293
6294 #endif /* _ASM_POWERPC_EXEC_H */
6295 diff --git a/arch/powerpc/include/asm/kmap_types.h b/arch/powerpc/include/asm/kmap_types.h
6296 index 5acabbd..7ea14fa 100644
6297 --- a/arch/powerpc/include/asm/kmap_types.h
6298 +++ b/arch/powerpc/include/asm/kmap_types.h
6299 @@ -10,7 +10,7 @@
6300 * 2 of the License, or (at your option) any later version.
6301 */
6302
6303 -#define KM_TYPE_NR 16
6304 +#define KM_TYPE_NR 17
6305
6306 #endif /* __KERNEL__ */
6307 #endif /* _ASM_POWERPC_KMAP_TYPES_H */
6308 diff --git a/arch/powerpc/include/asm/mman.h b/arch/powerpc/include/asm/mman.h
6309 index 8565c25..2865190 100644
6310 --- a/arch/powerpc/include/asm/mman.h
6311 +++ b/arch/powerpc/include/asm/mman.h
6312 @@ -24,7 +24,7 @@ static inline unsigned long arch_calc_vm_prot_bits(unsigned long prot)
6313 }
6314 #define arch_calc_vm_prot_bits(prot) arch_calc_vm_prot_bits(prot)
6315
6316 -static inline pgprot_t arch_vm_get_page_prot(unsigned long vm_flags)
6317 +static inline pgprot_t arch_vm_get_page_prot(vm_flags_t vm_flags)
6318 {
6319 return (vm_flags & VM_SAO) ? __pgprot(_PAGE_SAO) : __pgprot(0);
6320 }
6321 diff --git a/arch/powerpc/include/asm/page.h b/arch/powerpc/include/asm/page.h
6322 index f072e97..b436dee 100644
6323 --- a/arch/powerpc/include/asm/page.h
6324 +++ b/arch/powerpc/include/asm/page.h
6325 @@ -220,8 +220,9 @@ extern long long virt_phys_offset;
6326 * and needs to be executable. This means the whole heap ends
6327 * up being executable.
6328 */
6329 -#define VM_DATA_DEFAULT_FLAGS32 (VM_READ | VM_WRITE | VM_EXEC | \
6330 - VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
6331 +#define VM_DATA_DEFAULT_FLAGS32 \
6332 + (((current->personality & READ_IMPLIES_EXEC) ? VM_EXEC : 0) | \
6333 + VM_READ | VM_WRITE | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
6334
6335 #define VM_DATA_DEFAULT_FLAGS64 (VM_READ | VM_WRITE | \
6336 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
6337 @@ -249,6 +250,9 @@ extern long long virt_phys_offset;
6338 #define is_kernel_addr(x) ((x) >= PAGE_OFFSET)
6339 #endif
6340
6341 +#define ktla_ktva(addr) (addr)
6342 +#define ktva_ktla(addr) (addr)
6343 +
6344 /*
6345 * Use the top bit of the higher-level page table entries to indicate whether
6346 * the entries we point to contain hugepages. This works because we know that
6347 diff --git a/arch/powerpc/include/asm/page_64.h b/arch/powerpc/include/asm/page_64.h
6348 index cd915d6..c10cee8 100644
6349 --- a/arch/powerpc/include/asm/page_64.h
6350 +++ b/arch/powerpc/include/asm/page_64.h
6351 @@ -154,15 +154,18 @@ do { \
6352 * stack by default, so in the absence of a PT_GNU_STACK program header
6353 * we turn execute permission off.
6354 */
6355 -#define VM_STACK_DEFAULT_FLAGS32 (VM_READ | VM_WRITE | VM_EXEC | \
6356 - VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
6357 +#define VM_STACK_DEFAULT_FLAGS32 \
6358 + (((current->personality & READ_IMPLIES_EXEC) ? VM_EXEC : 0) | \
6359 + VM_READ | VM_WRITE | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
6360
6361 #define VM_STACK_DEFAULT_FLAGS64 (VM_READ | VM_WRITE | \
6362 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
6363
6364 +#ifndef CONFIG_PAX_PAGEEXEC
6365 #define VM_STACK_DEFAULT_FLAGS \
6366 (is_32bit_task() ? \
6367 VM_STACK_DEFAULT_FLAGS32 : VM_STACK_DEFAULT_FLAGS64)
6368 +#endif
6369
6370 #include <asm-generic/getorder.h>
6371
6372 diff --git a/arch/powerpc/include/asm/pgalloc-64.h b/arch/powerpc/include/asm/pgalloc-64.h
6373 index 292725c..f87ae14 100644
6374 --- a/arch/powerpc/include/asm/pgalloc-64.h
6375 +++ b/arch/powerpc/include/asm/pgalloc-64.h
6376 @@ -50,6 +50,7 @@ static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd)
6377 #ifndef CONFIG_PPC_64K_PAGES
6378
6379 #define pgd_populate(MM, PGD, PUD) pgd_set(PGD, PUD)
6380 +#define pgd_populate_kernel(MM, PGD, PUD) pgd_populate((MM), (PGD), (PUD))
6381
6382 static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr)
6383 {
6384 @@ -67,6 +68,11 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
6385 pud_set(pud, (unsigned long)pmd);
6386 }
6387
6388 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
6389 +{
6390 + pud_populate(mm, pud, pmd);
6391 +}
6392 +
6393 #define pmd_populate(mm, pmd, pte_page) \
6394 pmd_populate_kernel(mm, pmd, page_address(pte_page))
6395 #define pmd_populate_kernel(mm, pmd, pte) pmd_set(pmd, (unsigned long)(pte))
6396 @@ -76,6 +82,7 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
6397 #else /* CONFIG_PPC_64K_PAGES */
6398
6399 #define pud_populate(mm, pud, pmd) pud_set(pud, (unsigned long)pmd)
6400 +#define pud_populate_kernel(mm, pud, pmd) pud_populate((mm), (pud), (pmd))
6401
6402 static inline void pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmd,
6403 pte_t *pte)
6404 diff --git a/arch/powerpc/include/asm/pgtable.h b/arch/powerpc/include/asm/pgtable.h
6405 index a9cbd3b..3b67efa 100644
6406 --- a/arch/powerpc/include/asm/pgtable.h
6407 +++ b/arch/powerpc/include/asm/pgtable.h
6408 @@ -2,6 +2,7 @@
6409 #define _ASM_POWERPC_PGTABLE_H
6410 #ifdef __KERNEL__
6411
6412 +#include <linux/const.h>
6413 #ifndef __ASSEMBLY__
6414 #include <asm/processor.h> /* For TASK_SIZE */
6415 #include <asm/mmu.h>
6416 diff --git a/arch/powerpc/include/asm/pte-hash32.h b/arch/powerpc/include/asm/pte-hash32.h
6417 index 4aad413..85d86bf 100644
6418 --- a/arch/powerpc/include/asm/pte-hash32.h
6419 +++ b/arch/powerpc/include/asm/pte-hash32.h
6420 @@ -21,6 +21,7 @@
6421 #define _PAGE_FILE 0x004 /* when !present: nonlinear file mapping */
6422 #define _PAGE_USER 0x004 /* usermode access allowed */
6423 #define _PAGE_GUARDED 0x008 /* G: prohibit speculative access */
6424 +#define _PAGE_EXEC _PAGE_GUARDED
6425 #define _PAGE_COHERENT 0x010 /* M: enforce memory coherence (SMP systems) */
6426 #define _PAGE_NO_CACHE 0x020 /* I: cache inhibit */
6427 #define _PAGE_WRITETHRU 0x040 /* W: cache write-through */
6428 diff --git a/arch/powerpc/include/asm/reg.h b/arch/powerpc/include/asm/reg.h
6429 index 3d5c9dc..62f8414 100644
6430 --- a/arch/powerpc/include/asm/reg.h
6431 +++ b/arch/powerpc/include/asm/reg.h
6432 @@ -215,6 +215,7 @@
6433 #define SPRN_DBCR 0x136 /* e300 Data Breakpoint Control Reg */
6434 #define SPRN_DSISR 0x012 /* Data Storage Interrupt Status Register */
6435 #define DSISR_NOHPTE 0x40000000 /* no translation found */
6436 +#define DSISR_GUARDED 0x10000000 /* fetch from guarded storage */
6437 #define DSISR_PROTFAULT 0x08000000 /* protection fault */
6438 #define DSISR_ISSTORE 0x02000000 /* access was a store */
6439 #define DSISR_DABRMATCH 0x00400000 /* hit data breakpoint */
6440 diff --git a/arch/powerpc/include/asm/thread_info.h b/arch/powerpc/include/asm/thread_info.h
6441 index 406b7b9..af63426 100644
6442 --- a/arch/powerpc/include/asm/thread_info.h
6443 +++ b/arch/powerpc/include/asm/thread_info.h
6444 @@ -97,7 +97,6 @@ static inline struct thread_info *current_thread_info(void)
6445 #define TIF_PERFMON_CTXSW 6 /* perfmon needs ctxsw calls */
6446 #define TIF_SYSCALL_AUDIT 7 /* syscall auditing active */
6447 #define TIF_SINGLESTEP 8 /* singlestepping active */
6448 -#define TIF_MEMDIE 9 /* is terminating due to OOM killer */
6449 #define TIF_SECCOMP 10 /* secure computing */
6450 #define TIF_RESTOREALL 11 /* Restore all regs (implies NOERROR) */
6451 #define TIF_NOERROR 12 /* Force successful syscall return */
6452 @@ -106,6 +105,9 @@ static inline struct thread_info *current_thread_info(void)
6453 #define TIF_SYSCALL_TRACEPOINT 15 /* syscall tracepoint instrumentation */
6454 #define TIF_EMULATE_STACK_STORE 16 /* Is an instruction emulation
6455 for stack store? */
6456 +#define TIF_MEMDIE 17 /* is terminating due to OOM killer */
6457 +/* mask must be expressable within 16 bits to satisfy 'andi' instruction reqs */
6458 +#define TIF_GRSEC_SETXID 9 /* update credentials on syscall entry/exit */
6459
6460 /* as above, but as bit values */
6461 #define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
6462 @@ -124,8 +126,10 @@ static inline struct thread_info *current_thread_info(void)
6463 #define _TIF_UPROBE (1<<TIF_UPROBE)
6464 #define _TIF_SYSCALL_TRACEPOINT (1<<TIF_SYSCALL_TRACEPOINT)
6465 #define _TIF_EMULATE_STACK_STORE (1<<TIF_EMULATE_STACK_STORE)
6466 +#define _TIF_GRSEC_SETXID (1<<TIF_GRSEC_SETXID)
6467 #define _TIF_SYSCALL_T_OR_A (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | \
6468 - _TIF_SECCOMP | _TIF_SYSCALL_TRACEPOINT)
6469 + _TIF_SECCOMP | _TIF_SYSCALL_TRACEPOINT | \
6470 + _TIF_GRSEC_SETXID)
6471
6472 #define _TIF_USER_WORK_MASK (_TIF_SIGPENDING | _TIF_NEED_RESCHED | \
6473 _TIF_NOTIFY_RESUME | _TIF_UPROBE)
6474 diff --git a/arch/powerpc/include/asm/uaccess.h b/arch/powerpc/include/asm/uaccess.h
6475 index 4db4959..335e00c 100644
6476 --- a/arch/powerpc/include/asm/uaccess.h
6477 +++ b/arch/powerpc/include/asm/uaccess.h
6478 @@ -13,6 +13,8 @@
6479 #define VERIFY_READ 0
6480 #define VERIFY_WRITE 1
6481
6482 +extern void check_object_size(const void *ptr, unsigned long n, bool to);
6483 +
6484 /*
6485 * The fs value determines whether argument validity checking should be
6486 * performed or not. If get_fs() == USER_DS, checking is performed, with
6487 @@ -318,52 +320,6 @@ do { \
6488 extern unsigned long __copy_tofrom_user(void __user *to,
6489 const void __user *from, unsigned long size);
6490
6491 -#ifndef __powerpc64__
6492 -
6493 -static inline unsigned long copy_from_user(void *to,
6494 - const void __user *from, unsigned long n)
6495 -{
6496 - unsigned long over;
6497 -
6498 - if (access_ok(VERIFY_READ, from, n))
6499 - return __copy_tofrom_user((__force void __user *)to, from, n);
6500 - if ((unsigned long)from < TASK_SIZE) {
6501 - over = (unsigned long)from + n - TASK_SIZE;
6502 - return __copy_tofrom_user((__force void __user *)to, from,
6503 - n - over) + over;
6504 - }
6505 - return n;
6506 -}
6507 -
6508 -static inline unsigned long copy_to_user(void __user *to,
6509 - const void *from, unsigned long n)
6510 -{
6511 - unsigned long over;
6512 -
6513 - if (access_ok(VERIFY_WRITE, to, n))
6514 - return __copy_tofrom_user(to, (__force void __user *)from, n);
6515 - if ((unsigned long)to < TASK_SIZE) {
6516 - over = (unsigned long)to + n - TASK_SIZE;
6517 - return __copy_tofrom_user(to, (__force void __user *)from,
6518 - n - over) + over;
6519 - }
6520 - return n;
6521 -}
6522 -
6523 -#else /* __powerpc64__ */
6524 -
6525 -#define __copy_in_user(to, from, size) \
6526 - __copy_tofrom_user((to), (from), (size))
6527 -
6528 -extern unsigned long copy_from_user(void *to, const void __user *from,
6529 - unsigned long n);
6530 -extern unsigned long copy_to_user(void __user *to, const void *from,
6531 - unsigned long n);
6532 -extern unsigned long copy_in_user(void __user *to, const void __user *from,
6533 - unsigned long n);
6534 -
6535 -#endif /* __powerpc64__ */
6536 -
6537 static inline unsigned long __copy_from_user_inatomic(void *to,
6538 const void __user *from, unsigned long n)
6539 {
6540 @@ -387,6 +343,10 @@ static inline unsigned long __copy_from_user_inatomic(void *to,
6541 if (ret == 0)
6542 return 0;
6543 }
6544 +
6545 + if (!__builtin_constant_p(n))
6546 + check_object_size(to, n, false);
6547 +
6548 return __copy_tofrom_user((__force void __user *)to, from, n);
6549 }
6550
6551 @@ -413,6 +373,10 @@ static inline unsigned long __copy_to_user_inatomic(void __user *to,
6552 if (ret == 0)
6553 return 0;
6554 }
6555 +
6556 + if (!__builtin_constant_p(n))
6557 + check_object_size(from, n, true);
6558 +
6559 return __copy_tofrom_user(to, (__force const void __user *)from, n);
6560 }
6561
6562 @@ -430,6 +394,92 @@ static inline unsigned long __copy_to_user(void __user *to,
6563 return __copy_to_user_inatomic(to, from, size);
6564 }
6565
6566 +#ifndef __powerpc64__
6567 +
6568 +static inline unsigned long __must_check copy_from_user(void *to,
6569 + const void __user *from, unsigned long n)
6570 +{
6571 + unsigned long over;
6572 +
6573 + if ((long)n < 0)
6574 + return n;
6575 +
6576 + if (access_ok(VERIFY_READ, from, n)) {
6577 + if (!__builtin_constant_p(n))
6578 + check_object_size(to, n, false);
6579 + return __copy_tofrom_user((__force void __user *)to, from, n);
6580 + }
6581 + if ((unsigned long)from < TASK_SIZE) {
6582 + over = (unsigned long)from + n - TASK_SIZE;
6583 + if (!__builtin_constant_p(n - over))
6584 + check_object_size(to, n - over, false);
6585 + return __copy_tofrom_user((__force void __user *)to, from,
6586 + n - over) + over;
6587 + }
6588 + return n;
6589 +}
6590 +
6591 +static inline unsigned long __must_check copy_to_user(void __user *to,
6592 + const void *from, unsigned long n)
6593 +{
6594 + unsigned long over;
6595 +
6596 + if ((long)n < 0)
6597 + return n;
6598 +
6599 + if (access_ok(VERIFY_WRITE, to, n)) {
6600 + if (!__builtin_constant_p(n))
6601 + check_object_size(from, n, true);
6602 + return __copy_tofrom_user(to, (__force void __user *)from, n);
6603 + }
6604 + if ((unsigned long)to < TASK_SIZE) {
6605 + over = (unsigned long)to + n - TASK_SIZE;
6606 + if (!__builtin_constant_p(n))
6607 + check_object_size(from, n - over, true);
6608 + return __copy_tofrom_user(to, (__force void __user *)from,
6609 + n - over) + over;
6610 + }
6611 + return n;
6612 +}
6613 +
6614 +#else /* __powerpc64__ */
6615 +
6616 +#define __copy_in_user(to, from, size) \
6617 + __copy_tofrom_user((to), (from), (size))
6618 +
6619 +static inline unsigned long __must_check copy_from_user(void *to, const void __user *from, unsigned long n)
6620 +{
6621 + if ((long)n < 0 || n > INT_MAX)
6622 + return n;
6623 +
6624 + if (!__builtin_constant_p(n))
6625 + check_object_size(to, n, false);
6626 +
6627 + if (likely(access_ok(VERIFY_READ, from, n)))
6628 + n = __copy_from_user(to, from, n);
6629 + else
6630 + memset(to, 0, n);
6631 + return n;
6632 +}
6633 +
6634 +static inline unsigned long __must_check copy_to_user(void __user *to, const void *from, unsigned long n)
6635 +{
6636 + if ((long)n < 0 || n > INT_MAX)
6637 + return n;
6638 +
6639 + if (likely(access_ok(VERIFY_WRITE, to, n))) {
6640 + if (!__builtin_constant_p(n))
6641 + check_object_size(from, n, true);
6642 + n = __copy_to_user(to, from, n);
6643 + }
6644 + return n;
6645 +}
6646 +
6647 +extern unsigned long copy_in_user(void __user *to, const void __user *from,
6648 + unsigned long n);
6649 +
6650 +#endif /* __powerpc64__ */
6651 +
6652 extern unsigned long __clear_user(void __user *addr, unsigned long size);
6653
6654 static inline unsigned long clear_user(void __user *addr, unsigned long size)
6655 diff --git a/arch/powerpc/kernel/exceptions-64e.S b/arch/powerpc/kernel/exceptions-64e.S
6656 index 4684e33..acc4d19e 100644
6657 --- a/arch/powerpc/kernel/exceptions-64e.S
6658 +++ b/arch/powerpc/kernel/exceptions-64e.S
6659 @@ -715,6 +715,7 @@ storage_fault_common:
6660 std r14,_DAR(r1)
6661 std r15,_DSISR(r1)
6662 addi r3,r1,STACK_FRAME_OVERHEAD
6663 + bl .save_nvgprs
6664 mr r4,r14
6665 mr r5,r15
6666 ld r14,PACA_EXGEN+EX_R14(r13)
6667 @@ -723,8 +724,7 @@ storage_fault_common:
6668 cmpdi r3,0
6669 bne- 1f
6670 b .ret_from_except_lite
6671 -1: bl .save_nvgprs
6672 - mr r5,r3
6673 +1: mr r5,r3
6674 addi r3,r1,STACK_FRAME_OVERHEAD
6675 ld r4,_DAR(r1)
6676 bl .bad_page_fault
6677 diff --git a/arch/powerpc/kernel/exceptions-64s.S b/arch/powerpc/kernel/exceptions-64s.S
6678 index 4665e82..080ea99 100644
6679 --- a/arch/powerpc/kernel/exceptions-64s.S
6680 +++ b/arch/powerpc/kernel/exceptions-64s.S
6681 @@ -1206,10 +1206,10 @@ handle_page_fault:
6682 11: ld r4,_DAR(r1)
6683 ld r5,_DSISR(r1)
6684 addi r3,r1,STACK_FRAME_OVERHEAD
6685 + bl .save_nvgprs
6686 bl .do_page_fault
6687 cmpdi r3,0
6688 beq+ 12f
6689 - bl .save_nvgprs
6690 mr r5,r3
6691 addi r3,r1,STACK_FRAME_OVERHEAD
6692 lwz r4,_DAR(r1)
6693 diff --git a/arch/powerpc/kernel/module_32.c b/arch/powerpc/kernel/module_32.c
6694 index 2e3200c..72095ce 100644
6695 --- a/arch/powerpc/kernel/module_32.c
6696 +++ b/arch/powerpc/kernel/module_32.c
6697 @@ -162,7 +162,7 @@ int module_frob_arch_sections(Elf32_Ehdr *hdr,
6698 me->arch.core_plt_section = i;
6699 }
6700 if (!me->arch.core_plt_section || !me->arch.init_plt_section) {
6701 - printk("Module doesn't contain .plt or .init.plt sections.\n");
6702 + printk("Module %s doesn't contain .plt or .init.plt sections.\n", me->name);
6703 return -ENOEXEC;
6704 }
6705
6706 @@ -192,11 +192,16 @@ static uint32_t do_plt_call(void *location,
6707
6708 DEBUGP("Doing plt for call to 0x%x at 0x%x\n", val, (unsigned int)location);
6709 /* Init, or core PLT? */
6710 - if (location >= mod->module_core
6711 - && location < mod->module_core + mod->core_size)
6712 + if ((location >= mod->module_core_rx && location < mod->module_core_rx + mod->core_size_rx) ||
6713 + (location >= mod->module_core_rw && location < mod->module_core_rw + mod->core_size_rw))
6714 entry = (void *)sechdrs[mod->arch.core_plt_section].sh_addr;
6715 - else
6716 + else if ((location >= mod->module_init_rx && location < mod->module_init_rx + mod->init_size_rx) ||
6717 + (location >= mod->module_init_rw && location < mod->module_init_rw + mod->init_size_rw))
6718 entry = (void *)sechdrs[mod->arch.init_plt_section].sh_addr;
6719 + else {
6720 + printk(KERN_ERR "%s: invalid R_PPC_REL24 entry found\n", mod->name);
6721 + return ~0UL;
6722 + }
6723
6724 /* Find this entry, or if that fails, the next avail. entry */
6725 while (entry->jump[0]) {
6726 diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c
6727 index 8143067..21ae55b 100644
6728 --- a/arch/powerpc/kernel/process.c
6729 +++ b/arch/powerpc/kernel/process.c
6730 @@ -680,8 +680,8 @@ void show_regs(struct pt_regs * regs)
6731 * Lookup NIP late so we have the best change of getting the
6732 * above info out without failing
6733 */
6734 - printk("NIP ["REG"] %pS\n", regs->nip, (void *)regs->nip);
6735 - printk("LR ["REG"] %pS\n", regs->link, (void *)regs->link);
6736 + printk("NIP ["REG"] %pA\n", regs->nip, (void *)regs->nip);
6737 + printk("LR ["REG"] %pA\n", regs->link, (void *)regs->link);
6738 #endif
6739 show_stack(current, (unsigned long *) regs->gpr[1]);
6740 if (!user_mode(regs))
6741 @@ -1129,10 +1129,10 @@ void show_stack(struct task_struct *tsk, unsigned long *stack)
6742 newsp = stack[0];
6743 ip = stack[STACK_FRAME_LR_SAVE];
6744 if (!firstframe || ip != lr) {
6745 - printk("["REG"] ["REG"] %pS", sp, ip, (void *)ip);
6746 + printk("["REG"] ["REG"] %pA", sp, ip, (void *)ip);
6747 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
6748 if ((ip == rth || ip == mrth) && curr_frame >= 0) {
6749 - printk(" (%pS)",
6750 + printk(" (%pA)",
6751 (void *)current->ret_stack[curr_frame].ret);
6752 curr_frame--;
6753 }
6754 @@ -1152,7 +1152,7 @@ void show_stack(struct task_struct *tsk, unsigned long *stack)
6755 struct pt_regs *regs = (struct pt_regs *)
6756 (sp + STACK_FRAME_OVERHEAD);
6757 lr = regs->link;
6758 - printk("--- Exception: %lx at %pS\n LR = %pS\n",
6759 + printk("--- Exception: %lx at %pA\n LR = %pA\n",
6760 regs->trap, (void *)regs->nip, (void *)lr);
6761 firstframe = 1;
6762 }
6763 @@ -1194,58 +1194,3 @@ void __ppc64_runlatch_off(void)
6764 mtspr(SPRN_CTRLT, ctrl);
6765 }
6766 #endif /* CONFIG_PPC64 */
6767 -
6768 -unsigned long arch_align_stack(unsigned long sp)
6769 -{
6770 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
6771 - sp -= get_random_int() & ~PAGE_MASK;
6772 - return sp & ~0xf;
6773 -}
6774 -
6775 -static inline unsigned long brk_rnd(void)
6776 -{
6777 - unsigned long rnd = 0;
6778 -
6779 - /* 8MB for 32bit, 1GB for 64bit */
6780 - if (is_32bit_task())
6781 - rnd = (long)(get_random_int() % (1<<(23-PAGE_SHIFT)));
6782 - else
6783 - rnd = (long)(get_random_int() % (1<<(30-PAGE_SHIFT)));
6784 -
6785 - return rnd << PAGE_SHIFT;
6786 -}
6787 -
6788 -unsigned long arch_randomize_brk(struct mm_struct *mm)
6789 -{
6790 - unsigned long base = mm->brk;
6791 - unsigned long ret;
6792 -
6793 -#ifdef CONFIG_PPC_STD_MMU_64
6794 - /*
6795 - * If we are using 1TB segments and we are allowed to randomise
6796 - * the heap, we can put it above 1TB so it is backed by a 1TB
6797 - * segment. Otherwise the heap will be in the bottom 1TB
6798 - * which always uses 256MB segments and this may result in a
6799 - * performance penalty.
6800 - */
6801 - if (!is_32bit_task() && (mmu_highuser_ssize == MMU_SEGSIZE_1T))
6802 - base = max_t(unsigned long, mm->brk, 1UL << SID_SHIFT_1T);
6803 -#endif
6804 -
6805 - ret = PAGE_ALIGN(base + brk_rnd());
6806 -
6807 - if (ret < mm->brk)
6808 - return mm->brk;
6809 -
6810 - return ret;
6811 -}
6812 -
6813 -unsigned long randomize_et_dyn(unsigned long base)
6814 -{
6815 - unsigned long ret = PAGE_ALIGN(base + brk_rnd());
6816 -
6817 - if (ret < base)
6818 - return base;
6819 -
6820 - return ret;
6821 -}
6822 diff --git a/arch/powerpc/kernel/ptrace.c b/arch/powerpc/kernel/ptrace.c
6823 index c497000..8fde506 100644
6824 --- a/arch/powerpc/kernel/ptrace.c
6825 +++ b/arch/powerpc/kernel/ptrace.c
6826 @@ -1737,6 +1737,10 @@ long arch_ptrace(struct task_struct *child, long request,
6827 return ret;
6828 }
6829
6830 +#ifdef CONFIG_GRKERNSEC_SETXID
6831 +extern void gr_delayed_cred_worker(void);
6832 +#endif
6833 +
6834 /*
6835 * We must return the syscall number to actually look up in the table.
6836 * This can be -1L to skip running any syscall at all.
6837 @@ -1747,6 +1751,11 @@ long do_syscall_trace_enter(struct pt_regs *regs)
6838
6839 secure_computing_strict(regs->gpr[0]);
6840
6841 +#ifdef CONFIG_GRKERNSEC_SETXID
6842 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
6843 + gr_delayed_cred_worker();
6844 +#endif
6845 +
6846 if (test_thread_flag(TIF_SYSCALL_TRACE) &&
6847 tracehook_report_syscall_entry(regs))
6848 /*
6849 @@ -1781,6 +1790,11 @@ void do_syscall_trace_leave(struct pt_regs *regs)
6850 {
6851 int step;
6852
6853 +#ifdef CONFIG_GRKERNSEC_SETXID
6854 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
6855 + gr_delayed_cred_worker();
6856 +#endif
6857 +
6858 audit_syscall_exit(regs);
6859
6860 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
6861 diff --git a/arch/powerpc/kernel/signal_32.c b/arch/powerpc/kernel/signal_32.c
6862 index 804e323..79181c1 100644
6863 --- a/arch/powerpc/kernel/signal_32.c
6864 +++ b/arch/powerpc/kernel/signal_32.c
6865 @@ -851,7 +851,7 @@ int handle_rt_signal32(unsigned long sig, struct k_sigaction *ka,
6866 /* Save user registers on the stack */
6867 frame = &rt_sf->uc.uc_mcontext;
6868 addr = frame;
6869 - if (vdso32_rt_sigtramp && current->mm->context.vdso_base) {
6870 + if (vdso32_rt_sigtramp && current->mm->context.vdso_base != ~0UL) {
6871 if (save_user_regs(regs, frame, 0, 1))
6872 goto badframe;
6873 regs->link = current->mm->context.vdso_base + vdso32_rt_sigtramp;
6874 diff --git a/arch/powerpc/kernel/signal_64.c b/arch/powerpc/kernel/signal_64.c
6875 index 1ca045d..139c3f7 100644
6876 --- a/arch/powerpc/kernel/signal_64.c
6877 +++ b/arch/powerpc/kernel/signal_64.c
6878 @@ -430,7 +430,7 @@ int handle_rt_signal64(int signr, struct k_sigaction *ka, siginfo_t *info,
6879 current->thread.fpscr.val = 0;
6880
6881 /* Set up to return from userspace. */
6882 - if (vdso64_rt_sigtramp && current->mm->context.vdso_base) {
6883 + if (vdso64_rt_sigtramp && current->mm->context.vdso_base != ~0UL) {
6884 regs->link = current->mm->context.vdso_base + vdso64_rt_sigtramp;
6885 } else {
6886 err |= setup_trampoline(__NR_rt_sigreturn, &frame->tramp[0]);
6887 diff --git a/arch/powerpc/kernel/sysfs.c b/arch/powerpc/kernel/sysfs.c
6888 index 3ce1f86..c30e629 100644
6889 --- a/arch/powerpc/kernel/sysfs.c
6890 +++ b/arch/powerpc/kernel/sysfs.c
6891 @@ -522,7 +522,7 @@ static int __cpuinit sysfs_cpu_notify(struct notifier_block *self,
6892 return NOTIFY_OK;
6893 }
6894
6895 -static struct notifier_block __cpuinitdata sysfs_cpu_nb = {
6896 +static struct notifier_block sysfs_cpu_nb = {
6897 .notifier_call = sysfs_cpu_notify,
6898 };
6899
6900 diff --git a/arch/powerpc/kernel/traps.c b/arch/powerpc/kernel/traps.c
6901 index 3251840..3f7c77a 100644
6902 --- a/arch/powerpc/kernel/traps.c
6903 +++ b/arch/powerpc/kernel/traps.c
6904 @@ -133,6 +133,8 @@ static unsigned __kprobes long oops_begin(struct pt_regs *regs)
6905 return flags;
6906 }
6907
6908 +extern void gr_handle_kernel_exploit(void);
6909 +
6910 static void __kprobes oops_end(unsigned long flags, struct pt_regs *regs,
6911 int signr)
6912 {
6913 @@ -182,6 +184,9 @@ static void __kprobes oops_end(unsigned long flags, struct pt_regs *regs,
6914 panic("Fatal exception in interrupt");
6915 if (panic_on_oops)
6916 panic("Fatal exception");
6917 +
6918 + gr_handle_kernel_exploit();
6919 +
6920 do_exit(signr);
6921 }
6922
6923 diff --git a/arch/powerpc/kernel/vdso.c b/arch/powerpc/kernel/vdso.c
6924 index 1b2076f..835e4be 100644
6925 --- a/arch/powerpc/kernel/vdso.c
6926 +++ b/arch/powerpc/kernel/vdso.c
6927 @@ -34,6 +34,7 @@
6928 #include <asm/firmware.h>
6929 #include <asm/vdso.h>
6930 #include <asm/vdso_datapage.h>
6931 +#include <asm/mman.h>
6932
6933 #include "setup.h"
6934
6935 @@ -218,7 +219,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
6936 vdso_base = VDSO32_MBASE;
6937 #endif
6938
6939 - current->mm->context.vdso_base = 0;
6940 + current->mm->context.vdso_base = ~0UL;
6941
6942 /* vDSO has a problem and was disabled, just don't "enable" it for the
6943 * process
6944 @@ -238,7 +239,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
6945 vdso_base = get_unmapped_area(NULL, vdso_base,
6946 (vdso_pages << PAGE_SHIFT) +
6947 ((VDSO_ALIGNMENT - 1) & PAGE_MASK),
6948 - 0, 0);
6949 + 0, MAP_PRIVATE | MAP_EXECUTABLE);
6950 if (IS_ERR_VALUE(vdso_base)) {
6951 rc = vdso_base;
6952 goto fail_mmapsem;
6953 diff --git a/arch/powerpc/lib/usercopy_64.c b/arch/powerpc/lib/usercopy_64.c
6954 index 5eea6f3..5d10396 100644
6955 --- a/arch/powerpc/lib/usercopy_64.c
6956 +++ b/arch/powerpc/lib/usercopy_64.c
6957 @@ -9,22 +9,6 @@
6958 #include <linux/module.h>
6959 #include <asm/uaccess.h>
6960
6961 -unsigned long copy_from_user(void *to, const void __user *from, unsigned long n)
6962 -{
6963 - if (likely(access_ok(VERIFY_READ, from, n)))
6964 - n = __copy_from_user(to, from, n);
6965 - else
6966 - memset(to, 0, n);
6967 - return n;
6968 -}
6969 -
6970 -unsigned long copy_to_user(void __user *to, const void *from, unsigned long n)
6971 -{
6972 - if (likely(access_ok(VERIFY_WRITE, to, n)))
6973 - n = __copy_to_user(to, from, n);
6974 - return n;
6975 -}
6976 -
6977 unsigned long copy_in_user(void __user *to, const void __user *from,
6978 unsigned long n)
6979 {
6980 @@ -35,7 +19,5 @@ unsigned long copy_in_user(void __user *to, const void __user *from,
6981 return n;
6982 }
6983
6984 -EXPORT_SYMBOL(copy_from_user);
6985 -EXPORT_SYMBOL(copy_to_user);
6986 EXPORT_SYMBOL(copy_in_user);
6987
6988 diff --git a/arch/powerpc/mm/fault.c b/arch/powerpc/mm/fault.c
6989 index 3a8489a..6a63b3b 100644
6990 --- a/arch/powerpc/mm/fault.c
6991 +++ b/arch/powerpc/mm/fault.c
6992 @@ -32,6 +32,10 @@
6993 #include <linux/perf_event.h>
6994 #include <linux/magic.h>
6995 #include <linux/ratelimit.h>
6996 +#include <linux/slab.h>
6997 +#include <linux/pagemap.h>
6998 +#include <linux/compiler.h>
6999 +#include <linux/unistd.h>
7000
7001 #include <asm/firmware.h>
7002 #include <asm/page.h>
7003 @@ -68,6 +72,33 @@ static inline int notify_page_fault(struct pt_regs *regs)
7004 }
7005 #endif
7006
7007 +#ifdef CONFIG_PAX_PAGEEXEC
7008 +/*
7009 + * PaX: decide what to do with offenders (regs->nip = fault address)
7010 + *
7011 + * returns 1 when task should be killed
7012 + */
7013 +static int pax_handle_fetch_fault(struct pt_regs *regs)
7014 +{
7015 + return 1;
7016 +}
7017 +
7018 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
7019 +{
7020 + unsigned long i;
7021 +
7022 + printk(KERN_ERR "PAX: bytes at PC: ");
7023 + for (i = 0; i < 5; i++) {
7024 + unsigned int c;
7025 + if (get_user(c, (unsigned int __user *)pc+i))
7026 + printk(KERN_CONT "???????? ");
7027 + else
7028 + printk(KERN_CONT "%08x ", c);
7029 + }
7030 + printk("\n");
7031 +}
7032 +#endif
7033 +
7034 /*
7035 * Check whether the instruction at regs->nip is a store using
7036 * an update addressing form which will update r1.
7037 @@ -213,7 +244,7 @@ int __kprobes do_page_fault(struct pt_regs *regs, unsigned long address,
7038 * indicate errors in DSISR but can validly be set in SRR1.
7039 */
7040 if (trap == 0x400)
7041 - error_code &= 0x48200000;
7042 + error_code &= 0x58200000;
7043 else
7044 is_write = error_code & DSISR_ISSTORE;
7045 #else
7046 @@ -364,7 +395,7 @@ good_area:
7047 * "undefined". Of those that can be set, this is the only
7048 * one which seems bad.
7049 */
7050 - if (error_code & 0x10000000)
7051 + if (error_code & DSISR_GUARDED)
7052 /* Guarded storage error. */
7053 goto bad_area;
7054 #endif /* CONFIG_8xx */
7055 @@ -379,7 +410,7 @@ good_area:
7056 * processors use the same I/D cache coherency mechanism
7057 * as embedded.
7058 */
7059 - if (error_code & DSISR_PROTFAULT)
7060 + if (error_code & (DSISR_PROTFAULT | DSISR_GUARDED))
7061 goto bad_area;
7062 #endif /* CONFIG_PPC_STD_MMU */
7063
7064 @@ -462,6 +493,23 @@ bad_area:
7065 bad_area_nosemaphore:
7066 /* User mode accesses cause a SIGSEGV */
7067 if (user_mode(regs)) {
7068 +
7069 +#ifdef CONFIG_PAX_PAGEEXEC
7070 + if (mm->pax_flags & MF_PAX_PAGEEXEC) {
7071 +#ifdef CONFIG_PPC_STD_MMU
7072 + if (is_exec && (error_code & (DSISR_PROTFAULT | DSISR_GUARDED))) {
7073 +#else
7074 + if (is_exec && regs->nip == address) {
7075 +#endif
7076 + switch (pax_handle_fetch_fault(regs)) {
7077 + }
7078 +
7079 + pax_report_fault(regs, (void *)regs->nip, (void *)regs->gpr[PT_R1]);
7080 + do_group_exit(SIGKILL);
7081 + }
7082 + }
7083 +#endif
7084 +
7085 _exception(SIGSEGV, regs, code, address);
7086 return 0;
7087 }
7088 diff --git a/arch/powerpc/mm/mmap_64.c b/arch/powerpc/mm/mmap_64.c
7089 index 67a42ed..cd463e0 100644
7090 --- a/arch/powerpc/mm/mmap_64.c
7091 +++ b/arch/powerpc/mm/mmap_64.c
7092 @@ -57,6 +57,10 @@ static unsigned long mmap_rnd(void)
7093 {
7094 unsigned long rnd = 0;
7095
7096 +#ifdef CONFIG_PAX_RANDMMAP
7097 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
7098 +#endif
7099 +
7100 if (current->flags & PF_RANDOMIZE) {
7101 /* 8MB for 32bit, 1GB for 64bit */
7102 if (is_32bit_task())
7103 @@ -91,10 +95,22 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
7104 */
7105 if (mmap_is_legacy()) {
7106 mm->mmap_base = TASK_UNMAPPED_BASE;
7107 +
7108 +#ifdef CONFIG_PAX_RANDMMAP
7109 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7110 + mm->mmap_base += mm->delta_mmap;
7111 +#endif
7112 +
7113 mm->get_unmapped_area = arch_get_unmapped_area;
7114 mm->unmap_area = arch_unmap_area;
7115 } else {
7116 mm->mmap_base = mmap_base();
7117 +
7118 +#ifdef CONFIG_PAX_RANDMMAP
7119 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7120 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
7121 +#endif
7122 +
7123 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
7124 mm->unmap_area = arch_unmap_area_topdown;
7125 }
7126 diff --git a/arch/powerpc/mm/mmu_context_nohash.c b/arch/powerpc/mm/mmu_context_nohash.c
7127 index e779642..e5bb889 100644
7128 --- a/arch/powerpc/mm/mmu_context_nohash.c
7129 +++ b/arch/powerpc/mm/mmu_context_nohash.c
7130 @@ -363,7 +363,7 @@ static int __cpuinit mmu_context_cpu_notify(struct notifier_block *self,
7131 return NOTIFY_OK;
7132 }
7133
7134 -static struct notifier_block __cpuinitdata mmu_context_cpu_nb = {
7135 +static struct notifier_block mmu_context_cpu_nb = {
7136 .notifier_call = mmu_context_cpu_notify,
7137 };
7138
7139 diff --git a/arch/powerpc/mm/numa.c b/arch/powerpc/mm/numa.c
7140 index bba87ca..c346a33 100644
7141 --- a/arch/powerpc/mm/numa.c
7142 +++ b/arch/powerpc/mm/numa.c
7143 @@ -932,7 +932,7 @@ static void __init *careful_zallocation(int nid, unsigned long size,
7144 return ret;
7145 }
7146
7147 -static struct notifier_block __cpuinitdata ppc64_numa_nb = {
7148 +static struct notifier_block ppc64_numa_nb = {
7149 .notifier_call = cpu_numa_callback,
7150 .priority = 1 /* Must run before sched domains notifier. */
7151 };
7152 diff --git a/arch/powerpc/mm/slice.c b/arch/powerpc/mm/slice.c
7153 index cf9dada..241529f 100644
7154 --- a/arch/powerpc/mm/slice.c
7155 +++ b/arch/powerpc/mm/slice.c
7156 @@ -103,7 +103,7 @@ static int slice_area_is_free(struct mm_struct *mm, unsigned long addr,
7157 if ((mm->task_size - len) < addr)
7158 return 0;
7159 vma = find_vma(mm, addr);
7160 - return (!vma || (addr + len) <= vma->vm_start);
7161 + return check_heap_stack_gap(vma, addr, len, 0);
7162 }
7163
7164 static int slice_low_has_vma(struct mm_struct *mm, unsigned long slice)
7165 @@ -272,7 +272,7 @@ full_search:
7166 addr = _ALIGN_UP(addr + 1, 1ul << SLICE_HIGH_SHIFT);
7167 continue;
7168 }
7169 - if (!vma || addr + len <= vma->vm_start) {
7170 + if (check_heap_stack_gap(vma, addr, len, 0)) {
7171 /*
7172 * Remember the place where we stopped the search:
7173 */
7174 @@ -329,10 +329,14 @@ static unsigned long slice_find_area_topdown(struct mm_struct *mm,
7175 }
7176 }
7177
7178 - addr = mm->mmap_base;
7179 - while (addr > len) {
7180 + if (mm->mmap_base < len)
7181 + addr = -ENOMEM;
7182 + else
7183 + addr = mm->mmap_base - len;
7184 +
7185 + while (!IS_ERR_VALUE(addr)) {
7186 /* Go down by chunk size */
7187 - addr = _ALIGN_DOWN(addr - len, 1ul << pshift);
7188 + addr = _ALIGN_DOWN(addr, 1ul << pshift);
7189
7190 /* Check for hit with different page size */
7191 mask = slice_range_to_mask(addr, len);
7192 @@ -352,7 +356,7 @@ static unsigned long slice_find_area_topdown(struct mm_struct *mm,
7193 * return with success:
7194 */
7195 vma = find_vma(mm, addr);
7196 - if (!vma || (addr + len) <= vma->vm_start) {
7197 + if (check_heap_stack_gap(vma, addr, len, 0)) {
7198 /* remember the address as a hint for next time */
7199 if (use_cache)
7200 mm->free_area_cache = addr;
7201 @@ -364,7 +368,7 @@ static unsigned long slice_find_area_topdown(struct mm_struct *mm,
7202 mm->cached_hole_size = vma->vm_start - addr;
7203
7204 /* try just below the current vma->vm_start */
7205 - addr = vma->vm_start;
7206 + addr = skip_heap_stack_gap(vma, len, 0);
7207 }
7208
7209 /*
7210 @@ -442,6 +446,11 @@ unsigned long slice_get_unmapped_area(unsigned long addr, unsigned long len,
7211 if (fixed && addr > (mm->task_size - len))
7212 return -EINVAL;
7213
7214 +#ifdef CONFIG_PAX_RANDMMAP
7215 + if (!fixed && (mm->pax_flags & MF_PAX_RANDMMAP))
7216 + addr = 0;
7217 +#endif
7218 +
7219 /* If hint, make sure it matches our alignment restrictions */
7220 if (!fixed && addr) {
7221 addr = _ALIGN_UP(addr, 1ul << pshift);
7222 diff --git a/arch/powerpc/platforms/powermac/smp.c b/arch/powerpc/platforms/powermac/smp.c
7223 index bdb738a..49c9f95 100644
7224 --- a/arch/powerpc/platforms/powermac/smp.c
7225 +++ b/arch/powerpc/platforms/powermac/smp.c
7226 @@ -885,7 +885,7 @@ static int smp_core99_cpu_notify(struct notifier_block *self,
7227 return NOTIFY_OK;
7228 }
7229
7230 -static struct notifier_block __cpuinitdata smp_core99_cpu_nb = {
7231 +static struct notifier_block smp_core99_cpu_nb = {
7232 .notifier_call = smp_core99_cpu_notify,
7233 };
7234 #endif /* CONFIG_HOTPLUG_CPU */
7235 diff --git a/arch/s390/include/asm/atomic.h b/arch/s390/include/asm/atomic.h
7236 index c797832..ce575c8 100644
7237 --- a/arch/s390/include/asm/atomic.h
7238 +++ b/arch/s390/include/asm/atomic.h
7239 @@ -326,6 +326,16 @@ static inline long long atomic64_dec_if_positive(atomic64_t *v)
7240 #define atomic64_dec_and_test(_v) (atomic64_sub_return(1, _v) == 0)
7241 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
7242
7243 +#define atomic64_read_unchecked(v) atomic64_read(v)
7244 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
7245 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
7246 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
7247 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
7248 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
7249 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
7250 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
7251 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
7252 +
7253 #define smp_mb__before_atomic_dec() smp_mb()
7254 #define smp_mb__after_atomic_dec() smp_mb()
7255 #define smp_mb__before_atomic_inc() smp_mb()
7256 diff --git a/arch/s390/include/asm/cache.h b/arch/s390/include/asm/cache.h
7257 index 4d7ccac..d03d0ad 100644
7258 --- a/arch/s390/include/asm/cache.h
7259 +++ b/arch/s390/include/asm/cache.h
7260 @@ -9,8 +9,10 @@
7261 #ifndef __ARCH_S390_CACHE_H
7262 #define __ARCH_S390_CACHE_H
7263
7264 -#define L1_CACHE_BYTES 256
7265 +#include <linux/const.h>
7266 +
7267 #define L1_CACHE_SHIFT 8
7268 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
7269 #define NET_SKB_PAD 32
7270
7271 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
7272 diff --git a/arch/s390/include/asm/elf.h b/arch/s390/include/asm/elf.h
7273 index 178ff96..8c93bd1 100644
7274 --- a/arch/s390/include/asm/elf.h
7275 +++ b/arch/s390/include/asm/elf.h
7276 @@ -160,8 +160,14 @@ extern unsigned int vdso_enabled;
7277 the loader. We need to make sure that it is out of the way of the program
7278 that it will "exec", and that there is sufficient room for the brk. */
7279
7280 -extern unsigned long randomize_et_dyn(unsigned long base);
7281 -#define ELF_ET_DYN_BASE (randomize_et_dyn(STACK_TOP / 3 * 2))
7282 +#define ELF_ET_DYN_BASE (STACK_TOP / 3 * 2)
7283 +
7284 +#ifdef CONFIG_PAX_ASLR
7285 +#define PAX_ELF_ET_DYN_BASE (test_thread_flag(TIF_31BIT) ? 0x10000UL : 0x80000000UL)
7286 +
7287 +#define PAX_DELTA_MMAP_LEN (test_thread_flag(TIF_31BIT) ? 15 : 26)
7288 +#define PAX_DELTA_STACK_LEN (test_thread_flag(TIF_31BIT) ? 15 : 26)
7289 +#endif
7290
7291 /* This yields a mask that user programs can use to figure out what
7292 instruction set this CPU supports. */
7293 @@ -210,9 +216,6 @@ struct linux_binprm;
7294 #define ARCH_HAS_SETUP_ADDITIONAL_PAGES 1
7295 int arch_setup_additional_pages(struct linux_binprm *, int);
7296
7297 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
7298 -#define arch_randomize_brk arch_randomize_brk
7299 -
7300 void *fill_cpu_elf_notes(void *ptr, struct save_area *sa);
7301
7302 #endif
7303 diff --git a/arch/s390/include/asm/exec.h b/arch/s390/include/asm/exec.h
7304 index c4a93d6..4d2a9b4 100644
7305 --- a/arch/s390/include/asm/exec.h
7306 +++ b/arch/s390/include/asm/exec.h
7307 @@ -7,6 +7,6 @@
7308 #ifndef __ASM_EXEC_H
7309 #define __ASM_EXEC_H
7310
7311 -extern unsigned long arch_align_stack(unsigned long sp);
7312 +#define arch_align_stack(x) ((x) & ~0xfUL)
7313
7314 #endif /* __ASM_EXEC_H */
7315 diff --git a/arch/s390/include/asm/uaccess.h b/arch/s390/include/asm/uaccess.h
7316 index 34268df..ea97318 100644
7317 --- a/arch/s390/include/asm/uaccess.h
7318 +++ b/arch/s390/include/asm/uaccess.h
7319 @@ -252,6 +252,10 @@ static inline unsigned long __must_check
7320 copy_to_user(void __user *to, const void *from, unsigned long n)
7321 {
7322 might_fault();
7323 +
7324 + if ((long)n < 0)
7325 + return n;
7326 +
7327 if (access_ok(VERIFY_WRITE, to, n))
7328 n = __copy_to_user(to, from, n);
7329 return n;
7330 @@ -277,6 +281,9 @@ copy_to_user(void __user *to, const void *from, unsigned long n)
7331 static inline unsigned long __must_check
7332 __copy_from_user(void *to, const void __user *from, unsigned long n)
7333 {
7334 + if ((long)n < 0)
7335 + return n;
7336 +
7337 if (__builtin_constant_p(n) && (n <= 256))
7338 return uaccess.copy_from_user_small(n, from, to);
7339 else
7340 @@ -308,10 +315,14 @@ __compiletime_warning("copy_from_user() buffer size is not provably correct")
7341 static inline unsigned long __must_check
7342 copy_from_user(void *to, const void __user *from, unsigned long n)
7343 {
7344 - unsigned int sz = __compiletime_object_size(to);
7345 + size_t sz = __compiletime_object_size(to);
7346
7347 might_fault();
7348 - if (unlikely(sz != -1 && sz < n)) {
7349 +
7350 + if ((long)n < 0)
7351 + return n;
7352 +
7353 + if (unlikely(sz != (size_t)-1 && sz < n)) {
7354 copy_from_user_overflow();
7355 return n;
7356 }
7357 diff --git a/arch/s390/kernel/module.c b/arch/s390/kernel/module.c
7358 index 4610dea..cf0af21 100644
7359 --- a/arch/s390/kernel/module.c
7360 +++ b/arch/s390/kernel/module.c
7361 @@ -171,11 +171,11 @@ module_frob_arch_sections(Elf_Ehdr *hdr, Elf_Shdr *sechdrs,
7362
7363 /* Increase core size by size of got & plt and set start
7364 offsets for got and plt. */
7365 - me->core_size = ALIGN(me->core_size, 4);
7366 - me->arch.got_offset = me->core_size;
7367 - me->core_size += me->arch.got_size;
7368 - me->arch.plt_offset = me->core_size;
7369 - me->core_size += me->arch.plt_size;
7370 + me->core_size_rw = ALIGN(me->core_size_rw, 4);
7371 + me->arch.got_offset = me->core_size_rw;
7372 + me->core_size_rw += me->arch.got_size;
7373 + me->arch.plt_offset = me->core_size_rx;
7374 + me->core_size_rx += me->arch.plt_size;
7375 return 0;
7376 }
7377
7378 @@ -252,7 +252,7 @@ apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
7379 if (info->got_initialized == 0) {
7380 Elf_Addr *gotent;
7381
7382 - gotent = me->module_core + me->arch.got_offset +
7383 + gotent = me->module_core_rw + me->arch.got_offset +
7384 info->got_offset;
7385 *gotent = val;
7386 info->got_initialized = 1;
7387 @@ -276,7 +276,7 @@ apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
7388 else if (r_type == R_390_GOTENT ||
7389 r_type == R_390_GOTPLTENT)
7390 *(unsigned int *) loc =
7391 - (val + (Elf_Addr) me->module_core - loc) >> 1;
7392 + (val + (Elf_Addr) me->module_core_rw - loc) >> 1;
7393 else if (r_type == R_390_GOT64 ||
7394 r_type == R_390_GOTPLT64)
7395 *(unsigned long *) loc = val;
7396 @@ -290,7 +290,7 @@ apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
7397 case R_390_PLTOFF64: /* 16 bit offset from GOT to PLT. */
7398 if (info->plt_initialized == 0) {
7399 unsigned int *ip;
7400 - ip = me->module_core + me->arch.plt_offset +
7401 + ip = me->module_core_rx + me->arch.plt_offset +
7402 info->plt_offset;
7403 #ifndef CONFIG_64BIT
7404 ip[0] = 0x0d105810; /* basr 1,0; l 1,6(1); br 1 */
7405 @@ -315,7 +315,7 @@ apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
7406 val - loc + 0xffffUL < 0x1ffffeUL) ||
7407 (r_type == R_390_PLT32DBL &&
7408 val - loc + 0xffffffffULL < 0x1fffffffeULL)))
7409 - val = (Elf_Addr) me->module_core +
7410 + val = (Elf_Addr) me->module_core_rx +
7411 me->arch.plt_offset +
7412 info->plt_offset;
7413 val += rela->r_addend - loc;
7414 @@ -337,7 +337,7 @@ apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
7415 case R_390_GOTOFF32: /* 32 bit offset to GOT. */
7416 case R_390_GOTOFF64: /* 64 bit offset to GOT. */
7417 val = val + rela->r_addend -
7418 - ((Elf_Addr) me->module_core + me->arch.got_offset);
7419 + ((Elf_Addr) me->module_core_rw + me->arch.got_offset);
7420 if (r_type == R_390_GOTOFF16)
7421 *(unsigned short *) loc = val;
7422 else if (r_type == R_390_GOTOFF32)
7423 @@ -347,7 +347,7 @@ apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
7424 break;
7425 case R_390_GOTPC: /* 32 bit PC relative offset to GOT. */
7426 case R_390_GOTPCDBL: /* 32 bit PC rel. off. to GOT shifted by 1. */
7427 - val = (Elf_Addr) me->module_core + me->arch.got_offset +
7428 + val = (Elf_Addr) me->module_core_rw + me->arch.got_offset +
7429 rela->r_addend - loc;
7430 if (r_type == R_390_GOTPC)
7431 *(unsigned int *) loc = val;
7432 diff --git a/arch/s390/kernel/process.c b/arch/s390/kernel/process.c
7433 index 536d645..4a5bd9e 100644
7434 --- a/arch/s390/kernel/process.c
7435 +++ b/arch/s390/kernel/process.c
7436 @@ -250,39 +250,3 @@ unsigned long get_wchan(struct task_struct *p)
7437 }
7438 return 0;
7439 }
7440 -
7441 -unsigned long arch_align_stack(unsigned long sp)
7442 -{
7443 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
7444 - sp -= get_random_int() & ~PAGE_MASK;
7445 - return sp & ~0xf;
7446 -}
7447 -
7448 -static inline unsigned long brk_rnd(void)
7449 -{
7450 - /* 8MB for 32bit, 1GB for 64bit */
7451 - if (is_32bit_task())
7452 - return (get_random_int() & 0x7ffUL) << PAGE_SHIFT;
7453 - else
7454 - return (get_random_int() & 0x3ffffUL) << PAGE_SHIFT;
7455 -}
7456 -
7457 -unsigned long arch_randomize_brk(struct mm_struct *mm)
7458 -{
7459 - unsigned long ret = PAGE_ALIGN(mm->brk + brk_rnd());
7460 -
7461 - if (ret < mm->brk)
7462 - return mm->brk;
7463 - return ret;
7464 -}
7465 -
7466 -unsigned long randomize_et_dyn(unsigned long base)
7467 -{
7468 - unsigned long ret = PAGE_ALIGN(base + brk_rnd());
7469 -
7470 - if (!(current->flags & PF_RANDOMIZE))
7471 - return base;
7472 - if (ret < base)
7473 - return base;
7474 - return ret;
7475 -}
7476 diff --git a/arch/s390/mm/mmap.c b/arch/s390/mm/mmap.c
7477 index c59a5ef..3fae59c 100644
7478 --- a/arch/s390/mm/mmap.c
7479 +++ b/arch/s390/mm/mmap.c
7480 @@ -90,10 +90,22 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
7481 */
7482 if (mmap_is_legacy()) {
7483 mm->mmap_base = TASK_UNMAPPED_BASE;
7484 +
7485 +#ifdef CONFIG_PAX_RANDMMAP
7486 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7487 + mm->mmap_base += mm->delta_mmap;
7488 +#endif
7489 +
7490 mm->get_unmapped_area = arch_get_unmapped_area;
7491 mm->unmap_area = arch_unmap_area;
7492 } else {
7493 mm->mmap_base = mmap_base();
7494 +
7495 +#ifdef CONFIG_PAX_RANDMMAP
7496 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7497 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
7498 +#endif
7499 +
7500 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
7501 mm->unmap_area = arch_unmap_area_topdown;
7502 }
7503 @@ -172,10 +184,22 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
7504 */
7505 if (mmap_is_legacy()) {
7506 mm->mmap_base = TASK_UNMAPPED_BASE;
7507 +
7508 +#ifdef CONFIG_PAX_RANDMMAP
7509 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7510 + mm->mmap_base += mm->delta_mmap;
7511 +#endif
7512 +
7513 mm->get_unmapped_area = s390_get_unmapped_area;
7514 mm->unmap_area = arch_unmap_area;
7515 } else {
7516 mm->mmap_base = mmap_base();
7517 +
7518 +#ifdef CONFIG_PAX_RANDMMAP
7519 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7520 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
7521 +#endif
7522 +
7523 mm->get_unmapped_area = s390_get_unmapped_area_topdown;
7524 mm->unmap_area = arch_unmap_area_topdown;
7525 }
7526 diff --git a/arch/score/include/asm/cache.h b/arch/score/include/asm/cache.h
7527 index ae3d59f..f65f075 100644
7528 --- a/arch/score/include/asm/cache.h
7529 +++ b/arch/score/include/asm/cache.h
7530 @@ -1,7 +1,9 @@
7531 #ifndef _ASM_SCORE_CACHE_H
7532 #define _ASM_SCORE_CACHE_H
7533
7534 +#include <linux/const.h>
7535 +
7536 #define L1_CACHE_SHIFT 4
7537 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
7538 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
7539
7540 #endif /* _ASM_SCORE_CACHE_H */
7541 diff --git a/arch/score/include/asm/exec.h b/arch/score/include/asm/exec.h
7542 index f9f3cd5..58ff438 100644
7543 --- a/arch/score/include/asm/exec.h
7544 +++ b/arch/score/include/asm/exec.h
7545 @@ -1,6 +1,6 @@
7546 #ifndef _ASM_SCORE_EXEC_H
7547 #define _ASM_SCORE_EXEC_H
7548
7549 -extern unsigned long arch_align_stack(unsigned long sp);
7550 +#define arch_align_stack(x) (x)
7551
7552 #endif /* _ASM_SCORE_EXEC_H */
7553 diff --git a/arch/score/kernel/process.c b/arch/score/kernel/process.c
7554 index 7956846..5f37677 100644
7555 --- a/arch/score/kernel/process.c
7556 +++ b/arch/score/kernel/process.c
7557 @@ -134,8 +134,3 @@ unsigned long get_wchan(struct task_struct *task)
7558
7559 return task_pt_regs(task)->cp0_epc;
7560 }
7561 -
7562 -unsigned long arch_align_stack(unsigned long sp)
7563 -{
7564 - return sp;
7565 -}
7566 diff --git a/arch/sh/include/asm/cache.h b/arch/sh/include/asm/cache.h
7567 index ef9e555..331bd29 100644
7568 --- a/arch/sh/include/asm/cache.h
7569 +++ b/arch/sh/include/asm/cache.h
7570 @@ -9,10 +9,11 @@
7571 #define __ASM_SH_CACHE_H
7572 #ifdef __KERNEL__
7573
7574 +#include <linux/const.h>
7575 #include <linux/init.h>
7576 #include <cpu/cache.h>
7577
7578 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
7579 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
7580
7581 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
7582
7583 diff --git a/arch/sh/kernel/cpu/sh4a/smp-shx3.c b/arch/sh/kernel/cpu/sh4a/smp-shx3.c
7584 index 03f2b55..b027032 100644
7585 --- a/arch/sh/kernel/cpu/sh4a/smp-shx3.c
7586 +++ b/arch/sh/kernel/cpu/sh4a/smp-shx3.c
7587 @@ -143,7 +143,7 @@ shx3_cpu_callback(struct notifier_block *nfb, unsigned long action, void *hcpu)
7588 return NOTIFY_OK;
7589 }
7590
7591 -static struct notifier_block __cpuinitdata shx3_cpu_notifier = {
7592 +static struct notifier_block shx3_cpu_notifier = {
7593 .notifier_call = shx3_cpu_callback,
7594 };
7595
7596 diff --git a/arch/sh/mm/mmap.c b/arch/sh/mm/mmap.c
7597 index 6777177..cb5e44f 100644
7598 --- a/arch/sh/mm/mmap.c
7599 +++ b/arch/sh/mm/mmap.c
7600 @@ -36,6 +36,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
7601 struct mm_struct *mm = current->mm;
7602 struct vm_area_struct *vma;
7603 int do_colour_align;
7604 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
7605 struct vm_unmapped_area_info info;
7606
7607 if (flags & MAP_FIXED) {
7608 @@ -55,6 +56,10 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
7609 if (filp || (flags & MAP_SHARED))
7610 do_colour_align = 1;
7611
7612 +#ifdef CONFIG_PAX_RANDMMAP
7613 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
7614 +#endif
7615 +
7616 if (addr) {
7617 if (do_colour_align)
7618 addr = COLOUR_ALIGN(addr, pgoff);
7619 @@ -62,14 +67,13 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
7620 addr = PAGE_ALIGN(addr);
7621
7622 vma = find_vma(mm, addr);
7623 - if (TASK_SIZE - len >= addr &&
7624 - (!vma || addr + len <= vma->vm_start))
7625 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
7626 return addr;
7627 }
7628
7629 info.flags = 0;
7630 info.length = len;
7631 - info.low_limit = TASK_UNMAPPED_BASE;
7632 + info.low_limit = mm->mmap_base;
7633 info.high_limit = TASK_SIZE;
7634 info.align_mask = do_colour_align ? (PAGE_MASK & shm_align_mask) : 0;
7635 info.align_offset = pgoff << PAGE_SHIFT;
7636 @@ -85,6 +89,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
7637 struct mm_struct *mm = current->mm;
7638 unsigned long addr = addr0;
7639 int do_colour_align;
7640 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
7641 struct vm_unmapped_area_info info;
7642
7643 if (flags & MAP_FIXED) {
7644 @@ -104,6 +109,10 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
7645 if (filp || (flags & MAP_SHARED))
7646 do_colour_align = 1;
7647
7648 +#ifdef CONFIG_PAX_RANDMMAP
7649 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
7650 +#endif
7651 +
7652 /* requesting a specific address */
7653 if (addr) {
7654 if (do_colour_align)
7655 @@ -112,8 +121,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
7656 addr = PAGE_ALIGN(addr);
7657
7658 vma = find_vma(mm, addr);
7659 - if (TASK_SIZE - len >= addr &&
7660 - (!vma || addr + len <= vma->vm_start))
7661 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
7662 return addr;
7663 }
7664
7665 @@ -135,6 +143,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
7666 VM_BUG_ON(addr != -ENOMEM);
7667 info.flags = 0;
7668 info.low_limit = TASK_UNMAPPED_BASE;
7669 +
7670 +#ifdef CONFIG_PAX_RANDMMAP
7671 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7672 + info.low_limit += mm->delta_mmap;
7673 +#endif
7674 +
7675 info.high_limit = TASK_SIZE;
7676 addr = vm_unmapped_area(&info);
7677 }
7678 diff --git a/arch/sparc/include/asm/atomic_64.h b/arch/sparc/include/asm/atomic_64.h
7679 index be56a24..443328f 100644
7680 --- a/arch/sparc/include/asm/atomic_64.h
7681 +++ b/arch/sparc/include/asm/atomic_64.h
7682 @@ -14,18 +14,40 @@
7683 #define ATOMIC64_INIT(i) { (i) }
7684
7685 #define atomic_read(v) (*(volatile int *)&(v)->counter)
7686 +static inline int atomic_read_unchecked(const atomic_unchecked_t *v)
7687 +{
7688 + return v->counter;
7689 +}
7690 #define atomic64_read(v) (*(volatile long *)&(v)->counter)
7691 +static inline long atomic64_read_unchecked(const atomic64_unchecked_t *v)
7692 +{
7693 + return v->counter;
7694 +}
7695
7696 #define atomic_set(v, i) (((v)->counter) = i)
7697 +static inline void atomic_set_unchecked(atomic_unchecked_t *v, int i)
7698 +{
7699 + v->counter = i;
7700 +}
7701 #define atomic64_set(v, i) (((v)->counter) = i)
7702 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, long i)
7703 +{
7704 + v->counter = i;
7705 +}
7706
7707 extern void atomic_add(int, atomic_t *);
7708 +extern void atomic_add_unchecked(int, atomic_unchecked_t *);
7709 extern void atomic64_add(long, atomic64_t *);
7710 +extern void atomic64_add_unchecked(long, atomic64_unchecked_t *);
7711 extern void atomic_sub(int, atomic_t *);
7712 +extern void atomic_sub_unchecked(int, atomic_unchecked_t *);
7713 extern void atomic64_sub(long, atomic64_t *);
7714 +extern void atomic64_sub_unchecked(long, atomic64_unchecked_t *);
7715
7716 extern int atomic_add_ret(int, atomic_t *);
7717 +extern int atomic_add_ret_unchecked(int, atomic_unchecked_t *);
7718 extern long atomic64_add_ret(long, atomic64_t *);
7719 +extern long atomic64_add_ret_unchecked(long, atomic64_unchecked_t *);
7720 extern int atomic_sub_ret(int, atomic_t *);
7721 extern long atomic64_sub_ret(long, atomic64_t *);
7722
7723 @@ -33,13 +55,29 @@ extern long atomic64_sub_ret(long, atomic64_t *);
7724 #define atomic64_dec_return(v) atomic64_sub_ret(1, v)
7725
7726 #define atomic_inc_return(v) atomic_add_ret(1, v)
7727 +static inline int atomic_inc_return_unchecked(atomic_unchecked_t *v)
7728 +{
7729 + return atomic_add_ret_unchecked(1, v);
7730 +}
7731 #define atomic64_inc_return(v) atomic64_add_ret(1, v)
7732 +static inline long atomic64_inc_return_unchecked(atomic64_unchecked_t *v)
7733 +{
7734 + return atomic64_add_ret_unchecked(1, v);
7735 +}
7736
7737 #define atomic_sub_return(i, v) atomic_sub_ret(i, v)
7738 #define atomic64_sub_return(i, v) atomic64_sub_ret(i, v)
7739
7740 #define atomic_add_return(i, v) atomic_add_ret(i, v)
7741 +static inline int atomic_add_return_unchecked(int i, atomic_unchecked_t *v)
7742 +{
7743 + return atomic_add_ret_unchecked(i, v);
7744 +}
7745 #define atomic64_add_return(i, v) atomic64_add_ret(i, v)
7746 +static inline long atomic64_add_return_unchecked(long i, atomic64_unchecked_t *v)
7747 +{
7748 + return atomic64_add_ret_unchecked(i, v);
7749 +}
7750
7751 /*
7752 * atomic_inc_and_test - increment and test
7753 @@ -50,6 +88,10 @@ extern long atomic64_sub_ret(long, atomic64_t *);
7754 * other cases.
7755 */
7756 #define atomic_inc_and_test(v) (atomic_inc_return(v) == 0)
7757 +static inline int atomic_inc_and_test_unchecked(atomic_unchecked_t *v)
7758 +{
7759 + return atomic_inc_return_unchecked(v) == 0;
7760 +}
7761 #define atomic64_inc_and_test(v) (atomic64_inc_return(v) == 0)
7762
7763 #define atomic_sub_and_test(i, v) (atomic_sub_ret(i, v) == 0)
7764 @@ -59,25 +101,60 @@ extern long atomic64_sub_ret(long, atomic64_t *);
7765 #define atomic64_dec_and_test(v) (atomic64_sub_ret(1, v) == 0)
7766
7767 #define atomic_inc(v) atomic_add(1, v)
7768 +static inline void atomic_inc_unchecked(atomic_unchecked_t *v)
7769 +{
7770 + atomic_add_unchecked(1, v);
7771 +}
7772 #define atomic64_inc(v) atomic64_add(1, v)
7773 +static inline void atomic64_inc_unchecked(atomic64_unchecked_t *v)
7774 +{
7775 + atomic64_add_unchecked(1, v);
7776 +}
7777
7778 #define atomic_dec(v) atomic_sub(1, v)
7779 +static inline void atomic_dec_unchecked(atomic_unchecked_t *v)
7780 +{
7781 + atomic_sub_unchecked(1, v);
7782 +}
7783 #define atomic64_dec(v) atomic64_sub(1, v)
7784 +static inline void atomic64_dec_unchecked(atomic64_unchecked_t *v)
7785 +{
7786 + atomic64_sub_unchecked(1, v);
7787 +}
7788
7789 #define atomic_add_negative(i, v) (atomic_add_ret(i, v) < 0)
7790 #define atomic64_add_negative(i, v) (atomic64_add_ret(i, v) < 0)
7791
7792 #define atomic_cmpxchg(v, o, n) (cmpxchg(&((v)->counter), (o), (n)))
7793 +static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *v, int old, int new)
7794 +{
7795 + return cmpxchg(&v->counter, old, new);
7796 +}
7797 #define atomic_xchg(v, new) (xchg(&((v)->counter), new))
7798 +static inline int atomic_xchg_unchecked(atomic_unchecked_t *v, int new)
7799 +{
7800 + return xchg(&v->counter, new);
7801 +}
7802
7803 static inline int __atomic_add_unless(atomic_t *v, int a, int u)
7804 {
7805 - int c, old;
7806 + int c, old, new;
7807 c = atomic_read(v);
7808 for (;;) {
7809 - if (unlikely(c == (u)))
7810 + if (unlikely(c == u))
7811 break;
7812 - old = atomic_cmpxchg((v), c, c + (a));
7813 +
7814 + asm volatile("addcc %2, %0, %0\n"
7815 +
7816 +#ifdef CONFIG_PAX_REFCOUNT
7817 + "tvs %%icc, 6\n"
7818 +#endif
7819 +
7820 + : "=r" (new)
7821 + : "0" (c), "ir" (a)
7822 + : "cc");
7823 +
7824 + old = atomic_cmpxchg(v, c, new);
7825 if (likely(old == c))
7826 break;
7827 c = old;
7828 @@ -88,20 +165,35 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
7829 #define atomic64_cmpxchg(v, o, n) \
7830 ((__typeof__((v)->counter))cmpxchg(&((v)->counter), (o), (n)))
7831 #define atomic64_xchg(v, new) (xchg(&((v)->counter), new))
7832 +static inline long atomic64_xchg_unchecked(atomic64_unchecked_t *v, long new)
7833 +{
7834 + return xchg(&v->counter, new);
7835 +}
7836
7837 static inline long atomic64_add_unless(atomic64_t *v, long a, long u)
7838 {
7839 - long c, old;
7840 + long c, old, new;
7841 c = atomic64_read(v);
7842 for (;;) {
7843 - if (unlikely(c == (u)))
7844 + if (unlikely(c == u))
7845 break;
7846 - old = atomic64_cmpxchg((v), c, c + (a));
7847 +
7848 + asm volatile("addcc %2, %0, %0\n"
7849 +
7850 +#ifdef CONFIG_PAX_REFCOUNT
7851 + "tvs %%xcc, 6\n"
7852 +#endif
7853 +
7854 + : "=r" (new)
7855 + : "0" (c), "ir" (a)
7856 + : "cc");
7857 +
7858 + old = atomic64_cmpxchg(v, c, new);
7859 if (likely(old == c))
7860 break;
7861 c = old;
7862 }
7863 - return c != (u);
7864 + return c != u;
7865 }
7866
7867 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
7868 diff --git a/arch/sparc/include/asm/cache.h b/arch/sparc/include/asm/cache.h
7869 index 5bb6991..5c2132e 100644
7870 --- a/arch/sparc/include/asm/cache.h
7871 +++ b/arch/sparc/include/asm/cache.h
7872 @@ -7,10 +7,12 @@
7873 #ifndef _SPARC_CACHE_H
7874 #define _SPARC_CACHE_H
7875
7876 +#include <linux/const.h>
7877 +
7878 #define ARCH_SLAB_MINALIGN __alignof__(unsigned long long)
7879
7880 #define L1_CACHE_SHIFT 5
7881 -#define L1_CACHE_BYTES 32
7882 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
7883
7884 #ifdef CONFIG_SPARC32
7885 #define SMP_CACHE_BYTES_SHIFT 5
7886 diff --git a/arch/sparc/include/asm/elf_32.h b/arch/sparc/include/asm/elf_32.h
7887 index ac74a2c..a9e58af 100644
7888 --- a/arch/sparc/include/asm/elf_32.h
7889 +++ b/arch/sparc/include/asm/elf_32.h
7890 @@ -114,6 +114,13 @@ typedef struct {
7891
7892 #define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE)
7893
7894 +#ifdef CONFIG_PAX_ASLR
7895 +#define PAX_ELF_ET_DYN_BASE 0x10000UL
7896 +
7897 +#define PAX_DELTA_MMAP_LEN 16
7898 +#define PAX_DELTA_STACK_LEN 16
7899 +#endif
7900 +
7901 /* This yields a mask that user programs can use to figure out what
7902 instruction set this cpu supports. This can NOT be done in userspace
7903 on Sparc. */
7904 diff --git a/arch/sparc/include/asm/elf_64.h b/arch/sparc/include/asm/elf_64.h
7905 index 370ca1e..d4f4a98 100644
7906 --- a/arch/sparc/include/asm/elf_64.h
7907 +++ b/arch/sparc/include/asm/elf_64.h
7908 @@ -189,6 +189,13 @@ typedef struct {
7909 #define ELF_ET_DYN_BASE 0x0000010000000000UL
7910 #define COMPAT_ELF_ET_DYN_BASE 0x0000000070000000UL
7911
7912 +#ifdef CONFIG_PAX_ASLR
7913 +#define PAX_ELF_ET_DYN_BASE (test_thread_flag(TIF_32BIT) ? 0x10000UL : 0x100000UL)
7914 +
7915 +#define PAX_DELTA_MMAP_LEN (test_thread_flag(TIF_32BIT) ? 14 : 28)
7916 +#define PAX_DELTA_STACK_LEN (test_thread_flag(TIF_32BIT) ? 15 : 29)
7917 +#endif
7918 +
7919 extern unsigned long sparc64_elf_hwcap;
7920 #define ELF_HWCAP sparc64_elf_hwcap
7921
7922 diff --git a/arch/sparc/include/asm/pgalloc_32.h b/arch/sparc/include/asm/pgalloc_32.h
7923 index 9b1c36d..209298b 100644
7924 --- a/arch/sparc/include/asm/pgalloc_32.h
7925 +++ b/arch/sparc/include/asm/pgalloc_32.h
7926 @@ -33,6 +33,7 @@ static inline void pgd_set(pgd_t * pgdp, pmd_t * pmdp)
7927 }
7928
7929 #define pgd_populate(MM, PGD, PMD) pgd_set(PGD, PMD)
7930 +#define pgd_populate_kernel(MM, PGD, PMD) pgd_populate((MM), (PGD), (PMD))
7931
7932 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm,
7933 unsigned long address)
7934 diff --git a/arch/sparc/include/asm/pgalloc_64.h b/arch/sparc/include/asm/pgalloc_64.h
7935 index bcfe063..b333142 100644
7936 --- a/arch/sparc/include/asm/pgalloc_64.h
7937 +++ b/arch/sparc/include/asm/pgalloc_64.h
7938 @@ -26,6 +26,7 @@ static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd)
7939 }
7940
7941 #define pud_populate(MM, PUD, PMD) pud_set(PUD, PMD)
7942 +#define pud_populate_kernel(MM, PUD, PMD) pud_populate((MM), (PUD), (PMD))
7943
7944 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long addr)
7945 {
7946 diff --git a/arch/sparc/include/asm/pgtable_32.h b/arch/sparc/include/asm/pgtable_32.h
7947 index 6fc1348..390c50a 100644
7948 --- a/arch/sparc/include/asm/pgtable_32.h
7949 +++ b/arch/sparc/include/asm/pgtable_32.h
7950 @@ -50,6 +50,9 @@ extern unsigned long calc_highpages(void);
7951 #define PAGE_SHARED SRMMU_PAGE_SHARED
7952 #define PAGE_COPY SRMMU_PAGE_COPY
7953 #define PAGE_READONLY SRMMU_PAGE_RDONLY
7954 +#define PAGE_SHARED_NOEXEC SRMMU_PAGE_SHARED_NOEXEC
7955 +#define PAGE_COPY_NOEXEC SRMMU_PAGE_COPY_NOEXEC
7956 +#define PAGE_READONLY_NOEXEC SRMMU_PAGE_RDONLY_NOEXEC
7957 #define PAGE_KERNEL SRMMU_PAGE_KERNEL
7958
7959 /* Top-level page directory - dummy used by init-mm.
7960 @@ -62,18 +65,18 @@ extern unsigned long ptr_in_current_pgd;
7961
7962 /* xwr */
7963 #define __P000 PAGE_NONE
7964 -#define __P001 PAGE_READONLY
7965 -#define __P010 PAGE_COPY
7966 -#define __P011 PAGE_COPY
7967 +#define __P001 PAGE_READONLY_NOEXEC
7968 +#define __P010 PAGE_COPY_NOEXEC
7969 +#define __P011 PAGE_COPY_NOEXEC
7970 #define __P100 PAGE_READONLY
7971 #define __P101 PAGE_READONLY
7972 #define __P110 PAGE_COPY
7973 #define __P111 PAGE_COPY
7974
7975 #define __S000 PAGE_NONE
7976 -#define __S001 PAGE_READONLY
7977 -#define __S010 PAGE_SHARED
7978 -#define __S011 PAGE_SHARED
7979 +#define __S001 PAGE_READONLY_NOEXEC
7980 +#define __S010 PAGE_SHARED_NOEXEC
7981 +#define __S011 PAGE_SHARED_NOEXEC
7982 #define __S100 PAGE_READONLY
7983 #define __S101 PAGE_READONLY
7984 #define __S110 PAGE_SHARED
7985 diff --git a/arch/sparc/include/asm/pgtsrmmu.h b/arch/sparc/include/asm/pgtsrmmu.h
7986 index 79da178..c2eede8 100644
7987 --- a/arch/sparc/include/asm/pgtsrmmu.h
7988 +++ b/arch/sparc/include/asm/pgtsrmmu.h
7989 @@ -115,6 +115,11 @@
7990 SRMMU_EXEC | SRMMU_REF)
7991 #define SRMMU_PAGE_RDONLY __pgprot(SRMMU_VALID | SRMMU_CACHE | \
7992 SRMMU_EXEC | SRMMU_REF)
7993 +
7994 +#define SRMMU_PAGE_SHARED_NOEXEC __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_WRITE | SRMMU_REF)
7995 +#define SRMMU_PAGE_COPY_NOEXEC __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_REF)
7996 +#define SRMMU_PAGE_RDONLY_NOEXEC __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_REF)
7997 +
7998 #define SRMMU_PAGE_KERNEL __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_PRIV | \
7999 SRMMU_DIRTY | SRMMU_REF)
8000
8001 diff --git a/arch/sparc/include/asm/spinlock_64.h b/arch/sparc/include/asm/spinlock_64.h
8002 index 9689176..63c18ea 100644
8003 --- a/arch/sparc/include/asm/spinlock_64.h
8004 +++ b/arch/sparc/include/asm/spinlock_64.h
8005 @@ -92,14 +92,19 @@ static inline void arch_spin_lock_flags(arch_spinlock_t *lock, unsigned long fla
8006
8007 /* Multi-reader locks, these are much saner than the 32-bit Sparc ones... */
8008
8009 -static void inline arch_read_lock(arch_rwlock_t *lock)
8010 +static inline void arch_read_lock(arch_rwlock_t *lock)
8011 {
8012 unsigned long tmp1, tmp2;
8013
8014 __asm__ __volatile__ (
8015 "1: ldsw [%2], %0\n"
8016 " brlz,pn %0, 2f\n"
8017 -"4: add %0, 1, %1\n"
8018 +"4: addcc %0, 1, %1\n"
8019 +
8020 +#ifdef CONFIG_PAX_REFCOUNT
8021 +" tvs %%icc, 6\n"
8022 +#endif
8023 +
8024 " cas [%2], %0, %1\n"
8025 " cmp %0, %1\n"
8026 " bne,pn %%icc, 1b\n"
8027 @@ -112,10 +117,10 @@ static void inline arch_read_lock(arch_rwlock_t *lock)
8028 " .previous"
8029 : "=&r" (tmp1), "=&r" (tmp2)
8030 : "r" (lock)
8031 - : "memory");
8032 + : "memory", "cc");
8033 }
8034
8035 -static int inline arch_read_trylock(arch_rwlock_t *lock)
8036 +static inline int arch_read_trylock(arch_rwlock_t *lock)
8037 {
8038 int tmp1, tmp2;
8039
8040 @@ -123,7 +128,12 @@ static int inline arch_read_trylock(arch_rwlock_t *lock)
8041 "1: ldsw [%2], %0\n"
8042 " brlz,a,pn %0, 2f\n"
8043 " mov 0, %0\n"
8044 -" add %0, 1, %1\n"
8045 +" addcc %0, 1, %1\n"
8046 +
8047 +#ifdef CONFIG_PAX_REFCOUNT
8048 +" tvs %%icc, 6\n"
8049 +#endif
8050 +
8051 " cas [%2], %0, %1\n"
8052 " cmp %0, %1\n"
8053 " bne,pn %%icc, 1b\n"
8054 @@ -136,13 +146,18 @@ static int inline arch_read_trylock(arch_rwlock_t *lock)
8055 return tmp1;
8056 }
8057
8058 -static void inline arch_read_unlock(arch_rwlock_t *lock)
8059 +static inline void arch_read_unlock(arch_rwlock_t *lock)
8060 {
8061 unsigned long tmp1, tmp2;
8062
8063 __asm__ __volatile__(
8064 "1: lduw [%2], %0\n"
8065 -" sub %0, 1, %1\n"
8066 +" subcc %0, 1, %1\n"
8067 +
8068 +#ifdef CONFIG_PAX_REFCOUNT
8069 +" tvs %%icc, 6\n"
8070 +#endif
8071 +
8072 " cas [%2], %0, %1\n"
8073 " cmp %0, %1\n"
8074 " bne,pn %%xcc, 1b\n"
8075 @@ -152,7 +167,7 @@ static void inline arch_read_unlock(arch_rwlock_t *lock)
8076 : "memory");
8077 }
8078
8079 -static void inline arch_write_lock(arch_rwlock_t *lock)
8080 +static inline void arch_write_lock(arch_rwlock_t *lock)
8081 {
8082 unsigned long mask, tmp1, tmp2;
8083
8084 @@ -177,7 +192,7 @@ static void inline arch_write_lock(arch_rwlock_t *lock)
8085 : "memory");
8086 }
8087
8088 -static void inline arch_write_unlock(arch_rwlock_t *lock)
8089 +static inline void arch_write_unlock(arch_rwlock_t *lock)
8090 {
8091 __asm__ __volatile__(
8092 " stw %%g0, [%0]"
8093 @@ -186,7 +201,7 @@ static void inline arch_write_unlock(arch_rwlock_t *lock)
8094 : "memory");
8095 }
8096
8097 -static int inline arch_write_trylock(arch_rwlock_t *lock)
8098 +static inline int arch_write_trylock(arch_rwlock_t *lock)
8099 {
8100 unsigned long mask, tmp1, tmp2, result;
8101
8102 diff --git a/arch/sparc/include/asm/thread_info_32.h b/arch/sparc/include/asm/thread_info_32.h
8103 index 25849ae..924c54b 100644
8104 --- a/arch/sparc/include/asm/thread_info_32.h
8105 +++ b/arch/sparc/include/asm/thread_info_32.h
8106 @@ -49,6 +49,8 @@ struct thread_info {
8107 unsigned long w_saved;
8108
8109 struct restart_block restart_block;
8110 +
8111 + unsigned long lowest_stack;
8112 };
8113
8114 /*
8115 diff --git a/arch/sparc/include/asm/thread_info_64.h b/arch/sparc/include/asm/thread_info_64.h
8116 index 269bd92..e46a9b8 100644
8117 --- a/arch/sparc/include/asm/thread_info_64.h
8118 +++ b/arch/sparc/include/asm/thread_info_64.h
8119 @@ -63,6 +63,8 @@ struct thread_info {
8120 struct pt_regs *kern_una_regs;
8121 unsigned int kern_una_insn;
8122
8123 + unsigned long lowest_stack;
8124 +
8125 unsigned long fpregs[0] __attribute__ ((aligned(64)));
8126 };
8127
8128 @@ -192,10 +194,11 @@ register struct thread_info *current_thread_info_reg asm("g6");
8129 #define TIF_UNALIGNED 5 /* allowed to do unaligned accesses */
8130 /* flag bit 6 is available */
8131 #define TIF_32BIT 7 /* 32-bit binary */
8132 -/* flag bit 8 is available */
8133 +#define TIF_GRSEC_SETXID 8 /* update credentials on syscall entry/exit */
8134 #define TIF_SECCOMP 9 /* secure computing */
8135 #define TIF_SYSCALL_AUDIT 10 /* syscall auditing active */
8136 #define TIF_SYSCALL_TRACEPOINT 11 /* syscall tracepoint instrumentation */
8137 +
8138 /* NOTE: Thread flags >= 12 should be ones we have no interest
8139 * in using in assembly, else we can't use the mask as
8140 * an immediate value in instructions such as andcc.
8141 @@ -214,12 +217,18 @@ register struct thread_info *current_thread_info_reg asm("g6");
8142 #define _TIF_SYSCALL_AUDIT (1<<TIF_SYSCALL_AUDIT)
8143 #define _TIF_SYSCALL_TRACEPOINT (1<<TIF_SYSCALL_TRACEPOINT)
8144 #define _TIF_POLLING_NRFLAG (1<<TIF_POLLING_NRFLAG)
8145 +#define _TIF_GRSEC_SETXID (1<<TIF_GRSEC_SETXID)
8146
8147 #define _TIF_USER_WORK_MASK ((0xff << TI_FLAG_WSAVED_SHIFT) | \
8148 _TIF_DO_NOTIFY_RESUME_MASK | \
8149 _TIF_NEED_RESCHED)
8150 #define _TIF_DO_NOTIFY_RESUME_MASK (_TIF_NOTIFY_RESUME | _TIF_SIGPENDING)
8151
8152 +#define _TIF_WORK_SYSCALL \
8153 + (_TIF_SYSCALL_TRACE | _TIF_SECCOMP | _TIF_SYSCALL_AUDIT | \
8154 + _TIF_SYSCALL_TRACEPOINT | _TIF_GRSEC_SETXID)
8155 +
8156 +
8157 /*
8158 * Thread-synchronous status.
8159 *
8160 diff --git a/arch/sparc/include/asm/uaccess.h b/arch/sparc/include/asm/uaccess.h
8161 index 0167d26..9acd8ed 100644
8162 --- a/arch/sparc/include/asm/uaccess.h
8163 +++ b/arch/sparc/include/asm/uaccess.h
8164 @@ -1,5 +1,13 @@
8165 #ifndef ___ASM_SPARC_UACCESS_H
8166 #define ___ASM_SPARC_UACCESS_H
8167 +
8168 +#ifdef __KERNEL__
8169 +#ifndef __ASSEMBLY__
8170 +#include <linux/types.h>
8171 +extern void check_object_size(const void *ptr, unsigned long n, bool to);
8172 +#endif
8173 +#endif
8174 +
8175 #if defined(__sparc__) && defined(__arch64__)
8176 #include <asm/uaccess_64.h>
8177 #else
8178 diff --git a/arch/sparc/include/asm/uaccess_32.h b/arch/sparc/include/asm/uaccess_32.h
8179 index 53a28dd..50c38c3 100644
8180 --- a/arch/sparc/include/asm/uaccess_32.h
8181 +++ b/arch/sparc/include/asm/uaccess_32.h
8182 @@ -250,27 +250,46 @@ extern unsigned long __copy_user(void __user *to, const void __user *from, unsig
8183
8184 static inline unsigned long copy_to_user(void __user *to, const void *from, unsigned long n)
8185 {
8186 - if (n && __access_ok((unsigned long) to, n))
8187 + if ((long)n < 0)
8188 + return n;
8189 +
8190 + if (n && __access_ok((unsigned long) to, n)) {
8191 + if (!__builtin_constant_p(n))
8192 + check_object_size(from, n, true);
8193 return __copy_user(to, (__force void __user *) from, n);
8194 - else
8195 + } else
8196 return n;
8197 }
8198
8199 static inline unsigned long __copy_to_user(void __user *to, const void *from, unsigned long n)
8200 {
8201 + if ((long)n < 0)
8202 + return n;
8203 +
8204 + if (!__builtin_constant_p(n))
8205 + check_object_size(from, n, true);
8206 +
8207 return __copy_user(to, (__force void __user *) from, n);
8208 }
8209
8210 static inline unsigned long copy_from_user(void *to, const void __user *from, unsigned long n)
8211 {
8212 - if (n && __access_ok((unsigned long) from, n))
8213 + if ((long)n < 0)
8214 + return n;
8215 +
8216 + if (n && __access_ok((unsigned long) from, n)) {
8217 + if (!__builtin_constant_p(n))
8218 + check_object_size(to, n, false);
8219 return __copy_user((__force void __user *) to, from, n);
8220 - else
8221 + } else
8222 return n;
8223 }
8224
8225 static inline unsigned long __copy_from_user(void *to, const void __user *from, unsigned long n)
8226 {
8227 + if ((long)n < 0)
8228 + return n;
8229 +
8230 return __copy_user((__force void __user *) to, from, n);
8231 }
8232
8233 diff --git a/arch/sparc/include/asm/uaccess_64.h b/arch/sparc/include/asm/uaccess_64.h
8234 index e562d3c..191f176 100644
8235 --- a/arch/sparc/include/asm/uaccess_64.h
8236 +++ b/arch/sparc/include/asm/uaccess_64.h
8237 @@ -10,6 +10,7 @@
8238 #include <linux/compiler.h>
8239 #include <linux/string.h>
8240 #include <linux/thread_info.h>
8241 +#include <linux/kernel.h>
8242 #include <asm/asi.h>
8243 #include <asm/spitfire.h>
8244 #include <asm-generic/uaccess-unaligned.h>
8245 @@ -214,8 +215,15 @@ extern unsigned long copy_from_user_fixup(void *to, const void __user *from,
8246 static inline unsigned long __must_check
8247 copy_from_user(void *to, const void __user *from, unsigned long size)
8248 {
8249 - unsigned long ret = ___copy_from_user(to, from, size);
8250 + unsigned long ret;
8251
8252 + if ((long)size < 0 || size > INT_MAX)
8253 + return size;
8254 +
8255 + if (!__builtin_constant_p(size))
8256 + check_object_size(to, size, false);
8257 +
8258 + ret = ___copy_from_user(to, from, size);
8259 if (unlikely(ret))
8260 ret = copy_from_user_fixup(to, from, size);
8261
8262 @@ -231,8 +239,15 @@ extern unsigned long copy_to_user_fixup(void __user *to, const void *from,
8263 static inline unsigned long __must_check
8264 copy_to_user(void __user *to, const void *from, unsigned long size)
8265 {
8266 - unsigned long ret = ___copy_to_user(to, from, size);
8267 + unsigned long ret;
8268
8269 + if ((long)size < 0 || size > INT_MAX)
8270 + return size;
8271 +
8272 + if (!__builtin_constant_p(size))
8273 + check_object_size(from, size, true);
8274 +
8275 + ret = ___copy_to_user(to, from, size);
8276 if (unlikely(ret))
8277 ret = copy_to_user_fixup(to, from, size);
8278 return ret;
8279 diff --git a/arch/sparc/kernel/Makefile b/arch/sparc/kernel/Makefile
8280 index 6cf591b..b49e65a 100644
8281 --- a/arch/sparc/kernel/Makefile
8282 +++ b/arch/sparc/kernel/Makefile
8283 @@ -3,7 +3,7 @@
8284 #
8285
8286 asflags-y := -ansi
8287 -ccflags-y := -Werror
8288 +#ccflags-y := -Werror
8289
8290 extra-y := head_$(BITS).o
8291
8292 diff --git a/arch/sparc/kernel/process_32.c b/arch/sparc/kernel/process_32.c
8293 index be8e862..5b50b12 100644
8294 --- a/arch/sparc/kernel/process_32.c
8295 +++ b/arch/sparc/kernel/process_32.c
8296 @@ -126,14 +126,14 @@ void show_regs(struct pt_regs *r)
8297
8298 printk("PSR: %08lx PC: %08lx NPC: %08lx Y: %08lx %s\n",
8299 r->psr, r->pc, r->npc, r->y, print_tainted());
8300 - printk("PC: <%pS>\n", (void *) r->pc);
8301 + printk("PC: <%pA>\n", (void *) r->pc);
8302 printk("%%G: %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
8303 r->u_regs[0], r->u_regs[1], r->u_regs[2], r->u_regs[3],
8304 r->u_regs[4], r->u_regs[5], r->u_regs[6], r->u_regs[7]);
8305 printk("%%O: %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
8306 r->u_regs[8], r->u_regs[9], r->u_regs[10], r->u_regs[11],
8307 r->u_regs[12], r->u_regs[13], r->u_regs[14], r->u_regs[15]);
8308 - printk("RPC: <%pS>\n", (void *) r->u_regs[15]);
8309 + printk("RPC: <%pA>\n", (void *) r->u_regs[15]);
8310
8311 printk("%%L: %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
8312 rw->locals[0], rw->locals[1], rw->locals[2], rw->locals[3],
8313 @@ -168,7 +168,7 @@ void show_stack(struct task_struct *tsk, unsigned long *_ksp)
8314 rw = (struct reg_window32 *) fp;
8315 pc = rw->ins[7];
8316 printk("[%08lx : ", pc);
8317 - printk("%pS ] ", (void *) pc);
8318 + printk("%pA ] ", (void *) pc);
8319 fp = rw->ins[6];
8320 } while (++count < 16);
8321 printk("\n");
8322 diff --git a/arch/sparc/kernel/process_64.c b/arch/sparc/kernel/process_64.c
8323 index cdb80b2..5ca141d 100644
8324 --- a/arch/sparc/kernel/process_64.c
8325 +++ b/arch/sparc/kernel/process_64.c
8326 @@ -181,14 +181,14 @@ static void show_regwindow(struct pt_regs *regs)
8327 printk("i4: %016lx i5: %016lx i6: %016lx i7: %016lx\n",
8328 rwk->ins[4], rwk->ins[5], rwk->ins[6], rwk->ins[7]);
8329 if (regs->tstate & TSTATE_PRIV)
8330 - printk("I7: <%pS>\n", (void *) rwk->ins[7]);
8331 + printk("I7: <%pA>\n", (void *) rwk->ins[7]);
8332 }
8333
8334 void show_regs(struct pt_regs *regs)
8335 {
8336 printk("TSTATE: %016lx TPC: %016lx TNPC: %016lx Y: %08x %s\n", regs->tstate,
8337 regs->tpc, regs->tnpc, regs->y, print_tainted());
8338 - printk("TPC: <%pS>\n", (void *) regs->tpc);
8339 + printk("TPC: <%pA>\n", (void *) regs->tpc);
8340 printk("g0: %016lx g1: %016lx g2: %016lx g3: %016lx\n",
8341 regs->u_regs[0], regs->u_regs[1], regs->u_regs[2],
8342 regs->u_regs[3]);
8343 @@ -201,7 +201,7 @@ void show_regs(struct pt_regs *regs)
8344 printk("o4: %016lx o5: %016lx sp: %016lx ret_pc: %016lx\n",
8345 regs->u_regs[12], regs->u_regs[13], regs->u_regs[14],
8346 regs->u_regs[15]);
8347 - printk("RPC: <%pS>\n", (void *) regs->u_regs[15]);
8348 + printk("RPC: <%pA>\n", (void *) regs->u_regs[15]);
8349 show_regwindow(regs);
8350 show_stack(current, (unsigned long *) regs->u_regs[UREG_FP]);
8351 }
8352 @@ -290,7 +290,7 @@ void arch_trigger_all_cpu_backtrace(void)
8353 ((tp && tp->task) ? tp->task->pid : -1));
8354
8355 if (gp->tstate & TSTATE_PRIV) {
8356 - printk(" TPC[%pS] O7[%pS] I7[%pS] RPC[%pS]\n",
8357 + printk(" TPC[%pA] O7[%pA] I7[%pA] RPC[%pA]\n",
8358 (void *) gp->tpc,
8359 (void *) gp->o7,
8360 (void *) gp->i7,
8361 diff --git a/arch/sparc/kernel/ptrace_64.c b/arch/sparc/kernel/ptrace_64.c
8362 index 7ff45e4..a58f271 100644
8363 --- a/arch/sparc/kernel/ptrace_64.c
8364 +++ b/arch/sparc/kernel/ptrace_64.c
8365 @@ -1057,6 +1057,10 @@ long arch_ptrace(struct task_struct *child, long request,
8366 return ret;
8367 }
8368
8369 +#ifdef CONFIG_GRKERNSEC_SETXID
8370 +extern void gr_delayed_cred_worker(void);
8371 +#endif
8372 +
8373 asmlinkage int syscall_trace_enter(struct pt_regs *regs)
8374 {
8375 int ret = 0;
8376 @@ -1064,6 +1068,11 @@ asmlinkage int syscall_trace_enter(struct pt_regs *regs)
8377 /* do the secure computing check first */
8378 secure_computing_strict(regs->u_regs[UREG_G1]);
8379
8380 +#ifdef CONFIG_GRKERNSEC_SETXID
8381 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
8382 + gr_delayed_cred_worker();
8383 +#endif
8384 +
8385 if (test_thread_flag(TIF_SYSCALL_TRACE))
8386 ret = tracehook_report_syscall_entry(regs);
8387
8388 @@ -1084,6 +1093,11 @@ asmlinkage int syscall_trace_enter(struct pt_regs *regs)
8389
8390 asmlinkage void syscall_trace_leave(struct pt_regs *regs)
8391 {
8392 +#ifdef CONFIG_GRKERNSEC_SETXID
8393 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
8394 + gr_delayed_cred_worker();
8395 +#endif
8396 +
8397 audit_syscall_exit(regs);
8398
8399 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
8400 diff --git a/arch/sparc/kernel/sys_sparc_32.c b/arch/sparc/kernel/sys_sparc_32.c
8401 index 2da0bdc..79128d2 100644
8402 --- a/arch/sparc/kernel/sys_sparc_32.c
8403 +++ b/arch/sparc/kernel/sys_sparc_32.c
8404 @@ -52,7 +52,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
8405 if (len > TASK_SIZE - PAGE_SIZE)
8406 return -ENOMEM;
8407 if (!addr)
8408 - addr = TASK_UNMAPPED_BASE;
8409 + addr = current->mm->mmap_base;
8410
8411 info.flags = 0;
8412 info.length = len;
8413 diff --git a/arch/sparc/kernel/sys_sparc_64.c b/arch/sparc/kernel/sys_sparc_64.c
8414 index 708bc29..f0129cb 100644
8415 --- a/arch/sparc/kernel/sys_sparc_64.c
8416 +++ b/arch/sparc/kernel/sys_sparc_64.c
8417 @@ -90,13 +90,14 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
8418 struct vm_area_struct * vma;
8419 unsigned long task_size = TASK_SIZE;
8420 int do_color_align;
8421 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
8422 struct vm_unmapped_area_info info;
8423
8424 if (flags & MAP_FIXED) {
8425 /* We do not accept a shared mapping if it would violate
8426 * cache aliasing constraints.
8427 */
8428 - if ((flags & MAP_SHARED) &&
8429 + if ((filp || (flags & MAP_SHARED)) &&
8430 ((addr - (pgoff << PAGE_SHIFT)) & (SHMLBA - 1)))
8431 return -EINVAL;
8432 return addr;
8433 @@ -111,6 +112,10 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
8434 if (filp || (flags & MAP_SHARED))
8435 do_color_align = 1;
8436
8437 +#ifdef CONFIG_PAX_RANDMMAP
8438 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
8439 +#endif
8440 +
8441 if (addr) {
8442 if (do_color_align)
8443 addr = COLOR_ALIGN(addr, pgoff);
8444 @@ -118,14 +123,13 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
8445 addr = PAGE_ALIGN(addr);
8446
8447 vma = find_vma(mm, addr);
8448 - if (task_size - len >= addr &&
8449 - (!vma || addr + len <= vma->vm_start))
8450 + if (task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
8451 return addr;
8452 }
8453
8454 info.flags = 0;
8455 info.length = len;
8456 - info.low_limit = TASK_UNMAPPED_BASE;
8457 + info.low_limit = mm->mmap_base;
8458 info.high_limit = min(task_size, VA_EXCLUDE_START);
8459 info.align_mask = do_color_align ? (PAGE_MASK & (SHMLBA - 1)) : 0;
8460 info.align_offset = pgoff << PAGE_SHIFT;
8461 @@ -134,6 +138,12 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
8462 if ((addr & ~PAGE_MASK) && task_size > VA_EXCLUDE_END) {
8463 VM_BUG_ON(addr != -ENOMEM);
8464 info.low_limit = VA_EXCLUDE_END;
8465 +
8466 +#ifdef CONFIG_PAX_RANDMMAP
8467 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8468 + info.low_limit += mm->delta_mmap;
8469 +#endif
8470 +
8471 info.high_limit = task_size;
8472 addr = vm_unmapped_area(&info);
8473 }
8474 @@ -151,6 +161,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8475 unsigned long task_size = STACK_TOP32;
8476 unsigned long addr = addr0;
8477 int do_color_align;
8478 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
8479 struct vm_unmapped_area_info info;
8480
8481 /* This should only ever run for 32-bit processes. */
8482 @@ -160,7 +171,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8483 /* We do not accept a shared mapping if it would violate
8484 * cache aliasing constraints.
8485 */
8486 - if ((flags & MAP_SHARED) &&
8487 + if ((filp || (flags & MAP_SHARED)) &&
8488 ((addr - (pgoff << PAGE_SHIFT)) & (SHMLBA - 1)))
8489 return -EINVAL;
8490 return addr;
8491 @@ -173,6 +184,10 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8492 if (filp || (flags & MAP_SHARED))
8493 do_color_align = 1;
8494
8495 +#ifdef CONFIG_PAX_RANDMMAP
8496 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
8497 +#endif
8498 +
8499 /* requesting a specific address */
8500 if (addr) {
8501 if (do_color_align)
8502 @@ -181,8 +196,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8503 addr = PAGE_ALIGN(addr);
8504
8505 vma = find_vma(mm, addr);
8506 - if (task_size - len >= addr &&
8507 - (!vma || addr + len <= vma->vm_start))
8508 + if (task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
8509 return addr;
8510 }
8511
8512 @@ -204,6 +218,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8513 VM_BUG_ON(addr != -ENOMEM);
8514 info.flags = 0;
8515 info.low_limit = TASK_UNMAPPED_BASE;
8516 +
8517 +#ifdef CONFIG_PAX_RANDMMAP
8518 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8519 + info.low_limit += mm->delta_mmap;
8520 +#endif
8521 +
8522 info.high_limit = STACK_TOP32;
8523 addr = vm_unmapped_area(&info);
8524 }
8525 @@ -264,6 +284,10 @@ static unsigned long mmap_rnd(void)
8526 {
8527 unsigned long rnd = 0UL;
8528
8529 +#ifdef CONFIG_PAX_RANDMMAP
8530 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
8531 +#endif
8532 +
8533 if (current->flags & PF_RANDOMIZE) {
8534 unsigned long val = get_random_int();
8535 if (test_thread_flag(TIF_32BIT))
8536 @@ -289,6 +313,12 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
8537 gap == RLIM_INFINITY ||
8538 sysctl_legacy_va_layout) {
8539 mm->mmap_base = TASK_UNMAPPED_BASE + random_factor;
8540 +
8541 +#ifdef CONFIG_PAX_RANDMMAP
8542 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8543 + mm->mmap_base += mm->delta_mmap;
8544 +#endif
8545 +
8546 mm->get_unmapped_area = arch_get_unmapped_area;
8547 mm->unmap_area = arch_unmap_area;
8548 } else {
8549 @@ -301,6 +331,12 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
8550 gap = (task_size / 6 * 5);
8551
8552 mm->mmap_base = PAGE_ALIGN(task_size - gap - random_factor);
8553 +
8554 +#ifdef CONFIG_PAX_RANDMMAP
8555 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8556 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
8557 +#endif
8558 +
8559 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
8560 mm->unmap_area = arch_unmap_area_topdown;
8561 }
8562 diff --git a/arch/sparc/kernel/syscalls.S b/arch/sparc/kernel/syscalls.S
8563 index e0fed77..604a7e5 100644
8564 --- a/arch/sparc/kernel/syscalls.S
8565 +++ b/arch/sparc/kernel/syscalls.S
8566 @@ -58,7 +58,7 @@ sys32_rt_sigreturn:
8567 #endif
8568 .align 32
8569 1: ldx [%g6 + TI_FLAGS], %l5
8570 - andcc %l5, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
8571 + andcc %l5, _TIF_WORK_SYSCALL, %g0
8572 be,pt %icc, rtrap
8573 nop
8574 call syscall_trace_leave
8575 @@ -190,7 +190,7 @@ linux_sparc_syscall32:
8576
8577 srl %i5, 0, %o5 ! IEU1
8578 srl %i2, 0, %o2 ! 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_trace32 ! CTI
8582 mov %i0, %l5 ! IEU1
8583 call %l7 ! CTI Group brk forced
8584 @@ -213,7 +213,7 @@ linux_sparc_syscall:
8585
8586 mov %i3, %o3 ! IEU1
8587 mov %i4, %o4 ! IEU0 Group
8588 - andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
8589 + andcc %l0, _TIF_WORK_SYSCALL, %g0
8590 bne,pn %icc, linux_syscall_trace ! CTI Group
8591 mov %i0, %l5 ! IEU0
8592 2: call %l7 ! CTI Group brk forced
8593 @@ -229,7 +229,7 @@ ret_sys_call:
8594
8595 cmp %o0, -ERESTART_RESTARTBLOCK
8596 bgeu,pn %xcc, 1f
8597 - andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
8598 + andcc %l0, _TIF_WORK_SYSCALL, %g0
8599 ldx [%sp + PTREGS_OFF + PT_V9_TNPC], %l1 ! pc = npc
8600
8601 2:
8602 diff --git a/arch/sparc/kernel/sysfs.c b/arch/sparc/kernel/sysfs.c
8603 index 654e8aa..45f431b 100644
8604 --- a/arch/sparc/kernel/sysfs.c
8605 +++ b/arch/sparc/kernel/sysfs.c
8606 @@ -266,7 +266,7 @@ static int __cpuinit sysfs_cpu_notify(struct notifier_block *self,
8607 return NOTIFY_OK;
8608 }
8609
8610 -static struct notifier_block __cpuinitdata sysfs_cpu_nb = {
8611 +static struct notifier_block sysfs_cpu_nb = {
8612 .notifier_call = sysfs_cpu_notify,
8613 };
8614
8615 diff --git a/arch/sparc/kernel/traps_32.c b/arch/sparc/kernel/traps_32.c
8616 index a5785ea..405c5f7 100644
8617 --- a/arch/sparc/kernel/traps_32.c
8618 +++ b/arch/sparc/kernel/traps_32.c
8619 @@ -44,6 +44,8 @@ static void instruction_dump(unsigned long *pc)
8620 #define __SAVE __asm__ __volatile__("save %sp, -0x40, %sp\n\t")
8621 #define __RESTORE __asm__ __volatile__("restore %g0, %g0, %g0\n\t")
8622
8623 +extern void gr_handle_kernel_exploit(void);
8624 +
8625 void die_if_kernel(char *str, struct pt_regs *regs)
8626 {
8627 static int die_counter;
8628 @@ -76,15 +78,17 @@ void die_if_kernel(char *str, struct pt_regs *regs)
8629 count++ < 30 &&
8630 (((unsigned long) rw) >= PAGE_OFFSET) &&
8631 !(((unsigned long) rw) & 0x7)) {
8632 - printk("Caller[%08lx]: %pS\n", rw->ins[7],
8633 + printk("Caller[%08lx]: %pA\n", rw->ins[7],
8634 (void *) rw->ins[7]);
8635 rw = (struct reg_window32 *)rw->ins[6];
8636 }
8637 }
8638 printk("Instruction DUMP:");
8639 instruction_dump ((unsigned long *) regs->pc);
8640 - if(regs->psr & PSR_PS)
8641 + if(regs->psr & PSR_PS) {
8642 + gr_handle_kernel_exploit();
8643 do_exit(SIGKILL);
8644 + }
8645 do_exit(SIGSEGV);
8646 }
8647
8648 diff --git a/arch/sparc/kernel/traps_64.c b/arch/sparc/kernel/traps_64.c
8649 index e7ecf15..6520e65 100644
8650 --- a/arch/sparc/kernel/traps_64.c
8651 +++ b/arch/sparc/kernel/traps_64.c
8652 @@ -76,7 +76,7 @@ static void dump_tl1_traplog(struct tl1_traplog *p)
8653 i + 1,
8654 p->trapstack[i].tstate, p->trapstack[i].tpc,
8655 p->trapstack[i].tnpc, p->trapstack[i].tt);
8656 - printk("TRAPLOG: TPC<%pS>\n", (void *) p->trapstack[i].tpc);
8657 + printk("TRAPLOG: TPC<%pA>\n", (void *) p->trapstack[i].tpc);
8658 }
8659 }
8660
8661 @@ -96,6 +96,12 @@ void bad_trap(struct pt_regs *regs, long lvl)
8662
8663 lvl -= 0x100;
8664 if (regs->tstate & TSTATE_PRIV) {
8665 +
8666 +#ifdef CONFIG_PAX_REFCOUNT
8667 + if (lvl == 6)
8668 + pax_report_refcount_overflow(regs);
8669 +#endif
8670 +
8671 sprintf(buffer, "Kernel bad sw trap %lx", lvl);
8672 die_if_kernel(buffer, regs);
8673 }
8674 @@ -114,11 +120,16 @@ void bad_trap(struct pt_regs *regs, long lvl)
8675 void bad_trap_tl1(struct pt_regs *regs, long lvl)
8676 {
8677 char buffer[32];
8678 -
8679 +
8680 if (notify_die(DIE_TRAP_TL1, "bad trap tl1", regs,
8681 0, lvl, SIGTRAP) == NOTIFY_STOP)
8682 return;
8683
8684 +#ifdef CONFIG_PAX_REFCOUNT
8685 + if (lvl == 6)
8686 + pax_report_refcount_overflow(regs);
8687 +#endif
8688 +
8689 dump_tl1_traplog((struct tl1_traplog *)(regs + 1));
8690
8691 sprintf (buffer, "Bad trap %lx at tl>0", lvl);
8692 @@ -1142,7 +1153,7 @@ static void cheetah_log_errors(struct pt_regs *regs, struct cheetah_err_info *in
8693 regs->tpc, regs->tnpc, regs->u_regs[UREG_I7], regs->tstate);
8694 printk("%s" "ERROR(%d): ",
8695 (recoverable ? KERN_WARNING : KERN_CRIT), smp_processor_id());
8696 - printk("TPC<%pS>\n", (void *) regs->tpc);
8697 + printk("TPC<%pA>\n", (void *) regs->tpc);
8698 printk("%s" "ERROR(%d): M_SYND(%lx), E_SYND(%lx)%s%s\n",
8699 (recoverable ? KERN_WARNING : KERN_CRIT), smp_processor_id(),
8700 (afsr & CHAFSR_M_SYNDROME) >> CHAFSR_M_SYNDROME_SHIFT,
8701 @@ -1749,7 +1760,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_EMERG "TPC<%pS>\n", (void *) regs->tpc);
8706 + printk(KERN_EMERG "TPC<%pA>\n", (void *) regs->tpc);
8707 panic("Irrecoverable Cheetah+ parity error.");
8708 }
8709
8710 @@ -1757,7 +1768,7 @@ void cheetah_plus_parity_error(int type, struct pt_regs *regs)
8711 smp_processor_id(),
8712 (type & 0x1) ? 'I' : 'D',
8713 regs->tpc);
8714 - printk(KERN_WARNING "TPC<%pS>\n", (void *) regs->tpc);
8715 + printk(KERN_WARNING "TPC<%pA>\n", (void *) regs->tpc);
8716 }
8717
8718 struct sun4v_error_entry {
8719 @@ -2104,9 +2115,9 @@ void sun4v_itlb_error_report(struct pt_regs *regs, int tl)
8720
8721 printk(KERN_EMERG "SUN4V-ITLB: Error at TPC[%lx], tl %d\n",
8722 regs->tpc, tl);
8723 - printk(KERN_EMERG "SUN4V-ITLB: TPC<%pS>\n", (void *) regs->tpc);
8724 + printk(KERN_EMERG "SUN4V-ITLB: TPC<%pA>\n", (void *) regs->tpc);
8725 printk(KERN_EMERG "SUN4V-ITLB: O7[%lx]\n", regs->u_regs[UREG_I7]);
8726 - printk(KERN_EMERG "SUN4V-ITLB: O7<%pS>\n",
8727 + printk(KERN_EMERG "SUN4V-ITLB: O7<%pA>\n",
8728 (void *) regs->u_regs[UREG_I7]);
8729 printk(KERN_EMERG "SUN4V-ITLB: vaddr[%lx] ctx[%lx] "
8730 "pte[%lx] error[%lx]\n",
8731 @@ -2128,9 +2139,9 @@ void sun4v_dtlb_error_report(struct pt_regs *regs, int tl)
8732
8733 printk(KERN_EMERG "SUN4V-DTLB: Error at TPC[%lx], tl %d\n",
8734 regs->tpc, tl);
8735 - printk(KERN_EMERG "SUN4V-DTLB: TPC<%pS>\n", (void *) regs->tpc);
8736 + printk(KERN_EMERG "SUN4V-DTLB: TPC<%pA>\n", (void *) regs->tpc);
8737 printk(KERN_EMERG "SUN4V-DTLB: O7[%lx]\n", regs->u_regs[UREG_I7]);
8738 - printk(KERN_EMERG "SUN4V-DTLB: O7<%pS>\n",
8739 + printk(KERN_EMERG "SUN4V-DTLB: O7<%pA>\n",
8740 (void *) regs->u_regs[UREG_I7]);
8741 printk(KERN_EMERG "SUN4V-DTLB: vaddr[%lx] ctx[%lx] "
8742 "pte[%lx] error[%lx]\n",
8743 @@ -2336,13 +2347,13 @@ void show_stack(struct task_struct *tsk, unsigned long *_ksp)
8744 fp = (unsigned long)sf->fp + STACK_BIAS;
8745 }
8746
8747 - printk(" [%016lx] %pS\n", pc, (void *) pc);
8748 + printk(" [%016lx] %pA\n", pc, (void *) pc);
8749 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
8750 if ((pc + 8UL) == (unsigned long) &return_to_handler) {
8751 int index = tsk->curr_ret_stack;
8752 if (tsk->ret_stack && index >= graph) {
8753 pc = tsk->ret_stack[index - graph].ret;
8754 - printk(" [%016lx] %pS\n", pc, (void *) pc);
8755 + printk(" [%016lx] %pA\n", pc, (void *) pc);
8756 graph++;
8757 }
8758 }
8759 @@ -2367,6 +2378,8 @@ static inline struct reg_window *kernel_stack_up(struct reg_window *rw)
8760 return (struct reg_window *) (fp + STACK_BIAS);
8761 }
8762
8763 +extern void gr_handle_kernel_exploit(void);
8764 +
8765 void die_if_kernel(char *str, struct pt_regs *regs)
8766 {
8767 static int die_counter;
8768 @@ -2395,7 +2408,7 @@ void die_if_kernel(char *str, struct pt_regs *regs)
8769 while (rw &&
8770 count++ < 30 &&
8771 kstack_valid(tp, (unsigned long) rw)) {
8772 - printk("Caller[%016lx]: %pS\n", rw->ins[7],
8773 + printk("Caller[%016lx]: %pA\n", rw->ins[7],
8774 (void *) rw->ins[7]);
8775
8776 rw = kernel_stack_up(rw);
8777 @@ -2408,8 +2421,10 @@ void die_if_kernel(char *str, struct pt_regs *regs)
8778 }
8779 user_instruction_dump ((unsigned int __user *) regs->tpc);
8780 }
8781 - if (regs->tstate & TSTATE_PRIV)
8782 + if (regs->tstate & TSTATE_PRIV) {
8783 + gr_handle_kernel_exploit();
8784 do_exit(SIGKILL);
8785 + }
8786 do_exit(SIGSEGV);
8787 }
8788 EXPORT_SYMBOL(die_if_kernel);
8789 diff --git a/arch/sparc/kernel/unaligned_64.c b/arch/sparc/kernel/unaligned_64.c
8790 index 8201c25e..072a2a7 100644
8791 --- a/arch/sparc/kernel/unaligned_64.c
8792 +++ b/arch/sparc/kernel/unaligned_64.c
8793 @@ -286,7 +286,7 @@ static void log_unaligned(struct pt_regs *regs)
8794 static DEFINE_RATELIMIT_STATE(ratelimit, 5 * HZ, 5);
8795
8796 if (__ratelimit(&ratelimit)) {
8797 - printk("Kernel unaligned access at TPC[%lx] %pS\n",
8798 + printk("Kernel unaligned access at TPC[%lx] %pA\n",
8799 regs->tpc, (void *) regs->tpc);
8800 }
8801 }
8802 diff --git a/arch/sparc/lib/Makefile b/arch/sparc/lib/Makefile
8803 index 8410065f2..4fd4ca22 100644
8804 --- a/arch/sparc/lib/Makefile
8805 +++ b/arch/sparc/lib/Makefile
8806 @@ -2,7 +2,7 @@
8807 #
8808
8809 asflags-y := -ansi -DST_DIV0=0x02
8810 -ccflags-y := -Werror
8811 +#ccflags-y := -Werror
8812
8813 lib-$(CONFIG_SPARC32) += ashrdi3.o
8814 lib-$(CONFIG_SPARC32) += memcpy.o memset.o
8815 diff --git a/arch/sparc/lib/atomic_64.S b/arch/sparc/lib/atomic_64.S
8816 index 85c233d..68500e0 100644
8817 --- a/arch/sparc/lib/atomic_64.S
8818 +++ b/arch/sparc/lib/atomic_64.S
8819 @@ -17,7 +17,12 @@
8820 ENTRY(atomic_add) /* %o0 = increment, %o1 = atomic_ptr */
8821 BACKOFF_SETUP(%o2)
8822 1: lduw [%o1], %g1
8823 - add %g1, %o0, %g7
8824 + addcc %g1, %o0, %g7
8825 +
8826 +#ifdef CONFIG_PAX_REFCOUNT
8827 + tvs %icc, 6
8828 +#endif
8829 +
8830 cas [%o1], %g1, %g7
8831 cmp %g1, %g7
8832 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
8833 @@ -27,10 +32,28 @@ ENTRY(atomic_add) /* %o0 = increment, %o1 = atomic_ptr */
8834 2: BACKOFF_SPIN(%o2, %o3, 1b)
8835 ENDPROC(atomic_add)
8836
8837 +ENTRY(atomic_add_unchecked) /* %o0 = increment, %o1 = atomic_ptr */
8838 + BACKOFF_SETUP(%o2)
8839 +1: lduw [%o1], %g1
8840 + add %g1, %o0, %g7
8841 + cas [%o1], %g1, %g7
8842 + cmp %g1, %g7
8843 + bne,pn %icc, 2f
8844 + nop
8845 + retl
8846 + nop
8847 +2: BACKOFF_SPIN(%o2, %o3, 1b)
8848 +ENDPROC(atomic_add_unchecked)
8849 +
8850 ENTRY(atomic_sub) /* %o0 = decrement, %o1 = atomic_ptr */
8851 BACKOFF_SETUP(%o2)
8852 1: lduw [%o1], %g1
8853 - sub %g1, %o0, %g7
8854 + subcc %g1, %o0, %g7
8855 +
8856 +#ifdef CONFIG_PAX_REFCOUNT
8857 + tvs %icc, 6
8858 +#endif
8859 +
8860 cas [%o1], %g1, %g7
8861 cmp %g1, %g7
8862 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
8863 @@ -40,10 +63,28 @@ ENTRY(atomic_sub) /* %o0 = decrement, %o1 = atomic_ptr */
8864 2: BACKOFF_SPIN(%o2, %o3, 1b)
8865 ENDPROC(atomic_sub)
8866
8867 +ENTRY(atomic_sub_unchecked) /* %o0 = decrement, %o1 = atomic_ptr */
8868 + BACKOFF_SETUP(%o2)
8869 +1: lduw [%o1], %g1
8870 + sub %g1, %o0, %g7
8871 + cas [%o1], %g1, %g7
8872 + cmp %g1, %g7
8873 + bne,pn %icc, 2f
8874 + nop
8875 + retl
8876 + nop
8877 +2: BACKOFF_SPIN(%o2, %o3, 1b)
8878 +ENDPROC(atomic_sub_unchecked)
8879 +
8880 ENTRY(atomic_add_ret) /* %o0 = increment, %o1 = atomic_ptr */
8881 BACKOFF_SETUP(%o2)
8882 1: lduw [%o1], %g1
8883 - add %g1, %o0, %g7
8884 + addcc %g1, %o0, %g7
8885 +
8886 +#ifdef CONFIG_PAX_REFCOUNT
8887 + tvs %icc, 6
8888 +#endif
8889 +
8890 cas [%o1], %g1, %g7
8891 cmp %g1, %g7
8892 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
8893 @@ -53,10 +94,29 @@ ENTRY(atomic_add_ret) /* %o0 = increment, %o1 = atomic_ptr */
8894 2: BACKOFF_SPIN(%o2, %o3, 1b)
8895 ENDPROC(atomic_add_ret)
8896
8897 +ENTRY(atomic_add_ret_unchecked) /* %o0 = increment, %o1 = atomic_ptr */
8898 + BACKOFF_SETUP(%o2)
8899 +1: lduw [%o1], %g1
8900 + addcc %g1, %o0, %g7
8901 + cas [%o1], %g1, %g7
8902 + cmp %g1, %g7
8903 + bne,pn %icc, 2f
8904 + add %g7, %o0, %g7
8905 + sra %g7, 0, %o0
8906 + retl
8907 + nop
8908 +2: BACKOFF_SPIN(%o2, %o3, 1b)
8909 +ENDPROC(atomic_add_ret_unchecked)
8910 +
8911 ENTRY(atomic_sub_ret) /* %o0 = decrement, %o1 = atomic_ptr */
8912 BACKOFF_SETUP(%o2)
8913 1: lduw [%o1], %g1
8914 - sub %g1, %o0, %g7
8915 + subcc %g1, %o0, %g7
8916 +
8917 +#ifdef CONFIG_PAX_REFCOUNT
8918 + tvs %icc, 6
8919 +#endif
8920 +
8921 cas [%o1], %g1, %g7
8922 cmp %g1, %g7
8923 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
8924 @@ -69,7 +129,12 @@ ENDPROC(atomic_sub_ret)
8925 ENTRY(atomic64_add) /* %o0 = increment, %o1 = atomic_ptr */
8926 BACKOFF_SETUP(%o2)
8927 1: ldx [%o1], %g1
8928 - add %g1, %o0, %g7
8929 + addcc %g1, %o0, %g7
8930 +
8931 +#ifdef CONFIG_PAX_REFCOUNT
8932 + tvs %xcc, 6
8933 +#endif
8934 +
8935 casx [%o1], %g1, %g7
8936 cmp %g1, %g7
8937 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
8938 @@ -79,10 +144,28 @@ ENTRY(atomic64_add) /* %o0 = increment, %o1 = atomic_ptr */
8939 2: BACKOFF_SPIN(%o2, %o3, 1b)
8940 ENDPROC(atomic64_add)
8941
8942 +ENTRY(atomic64_add_unchecked) /* %o0 = increment, %o1 = atomic_ptr */
8943 + BACKOFF_SETUP(%o2)
8944 +1: ldx [%o1], %g1
8945 + addcc %g1, %o0, %g7
8946 + casx [%o1], %g1, %g7
8947 + cmp %g1, %g7
8948 + bne,pn %xcc, 2f
8949 + nop
8950 + retl
8951 + nop
8952 +2: BACKOFF_SPIN(%o2, %o3, 1b)
8953 +ENDPROC(atomic64_add_unchecked)
8954 +
8955 ENTRY(atomic64_sub) /* %o0 = decrement, %o1 = atomic_ptr */
8956 BACKOFF_SETUP(%o2)
8957 1: ldx [%o1], %g1
8958 - sub %g1, %o0, %g7
8959 + subcc %g1, %o0, %g7
8960 +
8961 +#ifdef CONFIG_PAX_REFCOUNT
8962 + tvs %xcc, 6
8963 +#endif
8964 +
8965 casx [%o1], %g1, %g7
8966 cmp %g1, %g7
8967 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
8968 @@ -92,10 +175,28 @@ ENTRY(atomic64_sub) /* %o0 = decrement, %o1 = atomic_ptr */
8969 2: BACKOFF_SPIN(%o2, %o3, 1b)
8970 ENDPROC(atomic64_sub)
8971
8972 +ENTRY(atomic64_sub_unchecked) /* %o0 = decrement, %o1 = atomic_ptr */
8973 + BACKOFF_SETUP(%o2)
8974 +1: ldx [%o1], %g1
8975 + subcc %g1, %o0, %g7
8976 + casx [%o1], %g1, %g7
8977 + cmp %g1, %g7
8978 + bne,pn %xcc, 2f
8979 + nop
8980 + retl
8981 + nop
8982 +2: BACKOFF_SPIN(%o2, %o3, 1b)
8983 +ENDPROC(atomic64_sub_unchecked)
8984 +
8985 ENTRY(atomic64_add_ret) /* %o0 = increment, %o1 = atomic_ptr */
8986 BACKOFF_SETUP(%o2)
8987 1: ldx [%o1], %g1
8988 - add %g1, %o0, %g7
8989 + addcc %g1, %o0, %g7
8990 +
8991 +#ifdef CONFIG_PAX_REFCOUNT
8992 + tvs %xcc, 6
8993 +#endif
8994 +
8995 casx [%o1], %g1, %g7
8996 cmp %g1, %g7
8997 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
8998 @@ -105,10 +206,29 @@ ENTRY(atomic64_add_ret) /* %o0 = increment, %o1 = atomic_ptr */
8999 2: BACKOFF_SPIN(%o2, %o3, 1b)
9000 ENDPROC(atomic64_add_ret)
9001
9002 +ENTRY(atomic64_add_ret_unchecked) /* %o0 = increment, %o1 = atomic_ptr */
9003 + BACKOFF_SETUP(%o2)
9004 +1: ldx [%o1], %g1
9005 + addcc %g1, %o0, %g7
9006 + casx [%o1], %g1, %g7
9007 + cmp %g1, %g7
9008 + bne,pn %xcc, 2f
9009 + add %g7, %o0, %g7
9010 + mov %g7, %o0
9011 + retl
9012 + nop
9013 +2: BACKOFF_SPIN(%o2, %o3, 1b)
9014 +ENDPROC(atomic64_add_ret_unchecked)
9015 +
9016 ENTRY(atomic64_sub_ret) /* %o0 = decrement, %o1 = atomic_ptr */
9017 BACKOFF_SETUP(%o2)
9018 1: ldx [%o1], %g1
9019 - sub %g1, %o0, %g7
9020 + subcc %g1, %o0, %g7
9021 +
9022 +#ifdef CONFIG_PAX_REFCOUNT
9023 + tvs %xcc, 6
9024 +#endif
9025 +
9026 casx [%o1], %g1, %g7
9027 cmp %g1, %g7
9028 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
9029 diff --git a/arch/sparc/lib/ksyms.c b/arch/sparc/lib/ksyms.c
9030 index 0c4e35e..745d3e4 100644
9031 --- a/arch/sparc/lib/ksyms.c
9032 +++ b/arch/sparc/lib/ksyms.c
9033 @@ -109,12 +109,18 @@ EXPORT_SYMBOL(__downgrade_write);
9034
9035 /* Atomic counter implementation. */
9036 EXPORT_SYMBOL(atomic_add);
9037 +EXPORT_SYMBOL(atomic_add_unchecked);
9038 EXPORT_SYMBOL(atomic_add_ret);
9039 +EXPORT_SYMBOL(atomic_add_ret_unchecked);
9040 EXPORT_SYMBOL(atomic_sub);
9041 +EXPORT_SYMBOL(atomic_sub_unchecked);
9042 EXPORT_SYMBOL(atomic_sub_ret);
9043 EXPORT_SYMBOL(atomic64_add);
9044 +EXPORT_SYMBOL(atomic64_add_unchecked);
9045 EXPORT_SYMBOL(atomic64_add_ret);
9046 +EXPORT_SYMBOL(atomic64_add_ret_unchecked);
9047 EXPORT_SYMBOL(atomic64_sub);
9048 +EXPORT_SYMBOL(atomic64_sub_unchecked);
9049 EXPORT_SYMBOL(atomic64_sub_ret);
9050 EXPORT_SYMBOL(atomic64_dec_if_positive);
9051
9052 diff --git a/arch/sparc/mm/Makefile b/arch/sparc/mm/Makefile
9053 index 30c3ecc..736f015 100644
9054 --- a/arch/sparc/mm/Makefile
9055 +++ b/arch/sparc/mm/Makefile
9056 @@ -2,7 +2,7 @@
9057 #
9058
9059 asflags-y := -ansi
9060 -ccflags-y := -Werror
9061 +#ccflags-y := -Werror
9062
9063 obj-$(CONFIG_SPARC64) += ultra.o tlb.o tsb.o gup.o
9064 obj-y += fault_$(BITS).o
9065 diff --git a/arch/sparc/mm/fault_32.c b/arch/sparc/mm/fault_32.c
9066 index e98bfda..ea8d221 100644
9067 --- a/arch/sparc/mm/fault_32.c
9068 +++ b/arch/sparc/mm/fault_32.c
9069 @@ -21,6 +21,9 @@
9070 #include <linux/perf_event.h>
9071 #include <linux/interrupt.h>
9072 #include <linux/kdebug.h>
9073 +#include <linux/slab.h>
9074 +#include <linux/pagemap.h>
9075 +#include <linux/compiler.h>
9076
9077 #include <asm/page.h>
9078 #include <asm/pgtable.h>
9079 @@ -159,6 +162,277 @@ static unsigned long compute_si_addr(struct pt_regs *regs, int text_fault)
9080 return safe_compute_effective_address(regs, insn);
9081 }
9082
9083 +#ifdef CONFIG_PAX_PAGEEXEC
9084 +#ifdef CONFIG_PAX_DLRESOLVE
9085 +static void pax_emuplt_close(struct vm_area_struct *vma)
9086 +{
9087 + vma->vm_mm->call_dl_resolve = 0UL;
9088 +}
9089 +
9090 +static int pax_emuplt_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
9091 +{
9092 + unsigned int *kaddr;
9093 +
9094 + vmf->page = alloc_page(GFP_HIGHUSER);
9095 + if (!vmf->page)
9096 + return VM_FAULT_OOM;
9097 +
9098 + kaddr = kmap(vmf->page);
9099 + memset(kaddr, 0, PAGE_SIZE);
9100 + kaddr[0] = 0x9DE3BFA8U; /* save */
9101 + flush_dcache_page(vmf->page);
9102 + kunmap(vmf->page);
9103 + return VM_FAULT_MAJOR;
9104 +}
9105 +
9106 +static const struct vm_operations_struct pax_vm_ops = {
9107 + .close = pax_emuplt_close,
9108 + .fault = pax_emuplt_fault
9109 +};
9110 +
9111 +static int pax_insert_vma(struct vm_area_struct *vma, unsigned long addr)
9112 +{
9113 + int ret;
9114 +
9115 + INIT_LIST_HEAD(&vma->anon_vma_chain);
9116 + vma->vm_mm = current->mm;
9117 + vma->vm_start = addr;
9118 + vma->vm_end = addr + PAGE_SIZE;
9119 + vma->vm_flags = VM_READ | VM_EXEC | VM_MAYREAD | VM_MAYEXEC;
9120 + vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
9121 + vma->vm_ops = &pax_vm_ops;
9122 +
9123 + ret = insert_vm_struct(current->mm, vma);
9124 + if (ret)
9125 + return ret;
9126 +
9127 + ++current->mm->total_vm;
9128 + return 0;
9129 +}
9130 +#endif
9131 +
9132 +/*
9133 + * PaX: decide what to do with offenders (regs->pc = fault address)
9134 + *
9135 + * returns 1 when task should be killed
9136 + * 2 when patched PLT trampoline was detected
9137 + * 3 when unpatched PLT trampoline was detected
9138 + */
9139 +static int pax_handle_fetch_fault(struct pt_regs *regs)
9140 +{
9141 +
9142 +#ifdef CONFIG_PAX_EMUPLT
9143 + int err;
9144 +
9145 + do { /* PaX: patched PLT emulation #1 */
9146 + unsigned int sethi1, sethi2, jmpl;
9147 +
9148 + err = get_user(sethi1, (unsigned int *)regs->pc);
9149 + err |= get_user(sethi2, (unsigned int *)(regs->pc+4));
9150 + err |= get_user(jmpl, (unsigned int *)(regs->pc+8));
9151 +
9152 + if (err)
9153 + break;
9154 +
9155 + if ((sethi1 & 0xFFC00000U) == 0x03000000U &&
9156 + (sethi2 & 0xFFC00000U) == 0x03000000U &&
9157 + (jmpl & 0xFFFFE000U) == 0x81C06000U)
9158 + {
9159 + unsigned int addr;
9160 +
9161 + regs->u_regs[UREG_G1] = (sethi2 & 0x003FFFFFU) << 10;
9162 + addr = regs->u_regs[UREG_G1];
9163 + addr += (((jmpl | 0xFFFFE000U) ^ 0x00001000U) + 0x00001000U);
9164 + regs->pc = addr;
9165 + regs->npc = addr+4;
9166 + return 2;
9167 + }
9168 + } while (0);
9169 +
9170 + do { /* PaX: patched PLT emulation #2 */
9171 + unsigned int ba;
9172 +
9173 + err = get_user(ba, (unsigned int *)regs->pc);
9174 +
9175 + if (err)
9176 + break;
9177 +
9178 + if ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30480000U) {
9179 + unsigned int addr;
9180 +
9181 + if ((ba & 0xFFC00000U) == 0x30800000U)
9182 + addr = regs->pc + ((((ba | 0xFFC00000U) ^ 0x00200000U) + 0x00200000U) << 2);
9183 + else
9184 + addr = regs->pc + ((((ba | 0xFFF80000U) ^ 0x00040000U) + 0x00040000U) << 2);
9185 + regs->pc = addr;
9186 + regs->npc = addr+4;
9187 + return 2;
9188 + }
9189 + } while (0);
9190 +
9191 + do { /* PaX: patched PLT emulation #3 */
9192 + unsigned int sethi, bajmpl, nop;
9193 +
9194 + err = get_user(sethi, (unsigned int *)regs->pc);
9195 + err |= get_user(bajmpl, (unsigned int *)(regs->pc+4));
9196 + err |= get_user(nop, (unsigned int *)(regs->pc+8));
9197 +
9198 + if (err)
9199 + break;
9200 +
9201 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
9202 + ((bajmpl & 0xFFFFE000U) == 0x81C06000U || (bajmpl & 0xFFF80000U) == 0x30480000U) &&
9203 + nop == 0x01000000U)
9204 + {
9205 + unsigned int addr;
9206 +
9207 + addr = (sethi & 0x003FFFFFU) << 10;
9208 + regs->u_regs[UREG_G1] = addr;
9209 + if ((bajmpl & 0xFFFFE000U) == 0x81C06000U)
9210 + addr += (((bajmpl | 0xFFFFE000U) ^ 0x00001000U) + 0x00001000U);
9211 + else
9212 + addr = regs->pc + ((((bajmpl | 0xFFF80000U) ^ 0x00040000U) + 0x00040000U) << 2);
9213 + regs->pc = addr;
9214 + regs->npc = addr+4;
9215 + return 2;
9216 + }
9217 + } while (0);
9218 +
9219 + do { /* PaX: unpatched PLT emulation step 1 */
9220 + unsigned int sethi, ba, nop;
9221 +
9222 + err = get_user(sethi, (unsigned int *)regs->pc);
9223 + err |= get_user(ba, (unsigned int *)(regs->pc+4));
9224 + err |= get_user(nop, (unsigned int *)(regs->pc+8));
9225 +
9226 + if (err)
9227 + break;
9228 +
9229 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
9230 + ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30680000U) &&
9231 + nop == 0x01000000U)
9232 + {
9233 + unsigned int addr, save, call;
9234 +
9235 + if ((ba & 0xFFC00000U) == 0x30800000U)
9236 + addr = regs->pc + 4 + ((((ba | 0xFFC00000U) ^ 0x00200000U) + 0x00200000U) << 2);
9237 + else
9238 + addr = regs->pc + 4 + ((((ba | 0xFFF80000U) ^ 0x00040000U) + 0x00040000U) << 2);
9239 +
9240 + err = get_user(save, (unsigned int *)addr);
9241 + err |= get_user(call, (unsigned int *)(addr+4));
9242 + err |= get_user(nop, (unsigned int *)(addr+8));
9243 + if (err)
9244 + break;
9245 +
9246 +#ifdef CONFIG_PAX_DLRESOLVE
9247 + if (save == 0x9DE3BFA8U &&
9248 + (call & 0xC0000000U) == 0x40000000U &&
9249 + nop == 0x01000000U)
9250 + {
9251 + struct vm_area_struct *vma;
9252 + unsigned long call_dl_resolve;
9253 +
9254 + down_read(&current->mm->mmap_sem);
9255 + call_dl_resolve = current->mm->call_dl_resolve;
9256 + up_read(&current->mm->mmap_sem);
9257 + if (likely(call_dl_resolve))
9258 + goto emulate;
9259 +
9260 + vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
9261 +
9262 + down_write(&current->mm->mmap_sem);
9263 + if (current->mm->call_dl_resolve) {
9264 + call_dl_resolve = current->mm->call_dl_resolve;
9265 + up_write(&current->mm->mmap_sem);
9266 + if (vma)
9267 + kmem_cache_free(vm_area_cachep, vma);
9268 + goto emulate;
9269 + }
9270 +
9271 + call_dl_resolve = get_unmapped_area(NULL, 0UL, PAGE_SIZE, 0UL, MAP_PRIVATE);
9272 + if (!vma || (call_dl_resolve & ~PAGE_MASK)) {
9273 + up_write(&current->mm->mmap_sem);
9274 + if (vma)
9275 + kmem_cache_free(vm_area_cachep, vma);
9276 + return 1;
9277 + }
9278 +
9279 + if (pax_insert_vma(vma, call_dl_resolve)) {
9280 + up_write(&current->mm->mmap_sem);
9281 + kmem_cache_free(vm_area_cachep, vma);
9282 + return 1;
9283 + }
9284 +
9285 + current->mm->call_dl_resolve = call_dl_resolve;
9286 + up_write(&current->mm->mmap_sem);
9287 +
9288 +emulate:
9289 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
9290 + regs->pc = call_dl_resolve;
9291 + regs->npc = addr+4;
9292 + return 3;
9293 + }
9294 +#endif
9295 +
9296 + /* PaX: glibc 2.4+ generates sethi/jmpl instead of save/call */
9297 + if ((save & 0xFFC00000U) == 0x05000000U &&
9298 + (call & 0xFFFFE000U) == 0x85C0A000U &&
9299 + nop == 0x01000000U)
9300 + {
9301 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
9302 + regs->u_regs[UREG_G2] = addr + 4;
9303 + addr = (save & 0x003FFFFFU) << 10;
9304 + addr += (((call | 0xFFFFE000U) ^ 0x00001000U) + 0x00001000U);
9305 + regs->pc = addr;
9306 + regs->npc = addr+4;
9307 + return 3;
9308 + }
9309 + }
9310 + } while (0);
9311 +
9312 + do { /* PaX: unpatched PLT emulation step 2 */
9313 + unsigned int save, call, nop;
9314 +
9315 + err = get_user(save, (unsigned int *)(regs->pc-4));
9316 + err |= get_user(call, (unsigned int *)regs->pc);
9317 + err |= get_user(nop, (unsigned int *)(regs->pc+4));
9318 + if (err)
9319 + break;
9320 +
9321 + if (save == 0x9DE3BFA8U &&
9322 + (call & 0xC0000000U) == 0x40000000U &&
9323 + nop == 0x01000000U)
9324 + {
9325 + unsigned int dl_resolve = regs->pc + ((((call | 0xC0000000U) ^ 0x20000000U) + 0x20000000U) << 2);
9326 +
9327 + regs->u_regs[UREG_RETPC] = regs->pc;
9328 + regs->pc = dl_resolve;
9329 + regs->npc = dl_resolve+4;
9330 + return 3;
9331 + }
9332 + } while (0);
9333 +#endif
9334 +
9335 + return 1;
9336 +}
9337 +
9338 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
9339 +{
9340 + unsigned long i;
9341 +
9342 + printk(KERN_ERR "PAX: bytes at PC: ");
9343 + for (i = 0; i < 8; i++) {
9344 + unsigned int c;
9345 + if (get_user(c, (unsigned int *)pc+i))
9346 + printk(KERN_CONT "???????? ");
9347 + else
9348 + printk(KERN_CONT "%08x ", c);
9349 + }
9350 + printk("\n");
9351 +}
9352 +#endif
9353 +
9354 static noinline void do_fault_siginfo(int code, int sig, struct pt_regs *regs,
9355 int text_fault)
9356 {
9357 @@ -230,6 +504,24 @@ good_area:
9358 if (!(vma->vm_flags & VM_WRITE))
9359 goto bad_area;
9360 } else {
9361 +
9362 +#ifdef CONFIG_PAX_PAGEEXEC
9363 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && text_fault && !(vma->vm_flags & VM_EXEC)) {
9364 + up_read(&mm->mmap_sem);
9365 + switch (pax_handle_fetch_fault(regs)) {
9366 +
9367 +#ifdef CONFIG_PAX_EMUPLT
9368 + case 2:
9369 + case 3:
9370 + return;
9371 +#endif
9372 +
9373 + }
9374 + pax_report_fault(regs, (void *)regs->pc, (void *)regs->u_regs[UREG_FP]);
9375 + do_group_exit(SIGKILL);
9376 + }
9377 +#endif
9378 +
9379 /* Allow reads even for write-only mappings */
9380 if (!(vma->vm_flags & (VM_READ | VM_EXEC)))
9381 goto bad_area;
9382 diff --git a/arch/sparc/mm/fault_64.c b/arch/sparc/mm/fault_64.c
9383 index 5062ff3..e0b75f3 100644
9384 --- a/arch/sparc/mm/fault_64.c
9385 +++ b/arch/sparc/mm/fault_64.c
9386 @@ -21,6 +21,9 @@
9387 #include <linux/kprobes.h>
9388 #include <linux/kdebug.h>
9389 #include <linux/percpu.h>
9390 +#include <linux/slab.h>
9391 +#include <linux/pagemap.h>
9392 +#include <linux/compiler.h>
9393
9394 #include <asm/page.h>
9395 #include <asm/pgtable.h>
9396 @@ -74,7 +77,7 @@ static void __kprobes bad_kernel_pc(struct pt_regs *regs, unsigned long vaddr)
9397 printk(KERN_CRIT "OOPS: Bogus kernel PC [%016lx] in fault handler\n",
9398 regs->tpc);
9399 printk(KERN_CRIT "OOPS: RPC [%016lx]\n", regs->u_regs[15]);
9400 - printk("OOPS: RPC <%pS>\n", (void *) regs->u_regs[15]);
9401 + printk("OOPS: RPC <%pA>\n", (void *) regs->u_regs[15]);
9402 printk(KERN_CRIT "OOPS: Fault was to vaddr[%lx]\n", vaddr);
9403 dump_stack();
9404 unhandled_fault(regs->tpc, current, regs);
9405 @@ -270,6 +273,466 @@ static void noinline __kprobes bogus_32bit_fault_address(struct pt_regs *regs,
9406 show_regs(regs);
9407 }
9408
9409 +#ifdef CONFIG_PAX_PAGEEXEC
9410 +#ifdef CONFIG_PAX_DLRESOLVE
9411 +static void pax_emuplt_close(struct vm_area_struct *vma)
9412 +{
9413 + vma->vm_mm->call_dl_resolve = 0UL;
9414 +}
9415 +
9416 +static int pax_emuplt_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
9417 +{
9418 + unsigned int *kaddr;
9419 +
9420 + vmf->page = alloc_page(GFP_HIGHUSER);
9421 + if (!vmf->page)
9422 + return VM_FAULT_OOM;
9423 +
9424 + kaddr = kmap(vmf->page);
9425 + memset(kaddr, 0, PAGE_SIZE);
9426 + kaddr[0] = 0x9DE3BFA8U; /* save */
9427 + flush_dcache_page(vmf->page);
9428 + kunmap(vmf->page);
9429 + return VM_FAULT_MAJOR;
9430 +}
9431 +
9432 +static const struct vm_operations_struct pax_vm_ops = {
9433 + .close = pax_emuplt_close,
9434 + .fault = pax_emuplt_fault
9435 +};
9436 +
9437 +static int pax_insert_vma(struct vm_area_struct *vma, unsigned long addr)
9438 +{
9439 + int ret;
9440 +
9441 + INIT_LIST_HEAD(&vma->anon_vma_chain);
9442 + vma->vm_mm = current->mm;
9443 + vma->vm_start = addr;
9444 + vma->vm_end = addr + PAGE_SIZE;
9445 + vma->vm_flags = VM_READ | VM_EXEC | VM_MAYREAD | VM_MAYEXEC;
9446 + vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
9447 + vma->vm_ops = &pax_vm_ops;
9448 +
9449 + ret = insert_vm_struct(current->mm, vma);
9450 + if (ret)
9451 + return ret;
9452 +
9453 + ++current->mm->total_vm;
9454 + return 0;
9455 +}
9456 +#endif
9457 +
9458 +/*
9459 + * PaX: decide what to do with offenders (regs->tpc = fault address)
9460 + *
9461 + * returns 1 when task should be killed
9462 + * 2 when patched PLT trampoline was detected
9463 + * 3 when unpatched PLT trampoline was detected
9464 + */
9465 +static int pax_handle_fetch_fault(struct pt_regs *regs)
9466 +{
9467 +
9468 +#ifdef CONFIG_PAX_EMUPLT
9469 + int err;
9470 +
9471 + do { /* PaX: patched PLT emulation #1 */
9472 + unsigned int sethi1, sethi2, jmpl;
9473 +
9474 + err = get_user(sethi1, (unsigned int *)regs->tpc);
9475 + err |= get_user(sethi2, (unsigned int *)(regs->tpc+4));
9476 + err |= get_user(jmpl, (unsigned int *)(regs->tpc+8));
9477 +
9478 + if (err)
9479 + break;
9480 +
9481 + if ((sethi1 & 0xFFC00000U) == 0x03000000U &&
9482 + (sethi2 & 0xFFC00000U) == 0x03000000U &&
9483 + (jmpl & 0xFFFFE000U) == 0x81C06000U)
9484 + {
9485 + unsigned long addr;
9486 +
9487 + regs->u_regs[UREG_G1] = (sethi2 & 0x003FFFFFU) << 10;
9488 + addr = regs->u_regs[UREG_G1];
9489 + addr += (((jmpl | 0xFFFFFFFFFFFFE000UL) ^ 0x00001000UL) + 0x00001000UL);
9490 +
9491 + if (test_thread_flag(TIF_32BIT))
9492 + addr &= 0xFFFFFFFFUL;
9493 +
9494 + regs->tpc = addr;
9495 + regs->tnpc = addr+4;
9496 + return 2;
9497 + }
9498 + } while (0);
9499 +
9500 + do { /* PaX: patched PLT emulation #2 */
9501 + unsigned int ba;
9502 +
9503 + err = get_user(ba, (unsigned int *)regs->tpc);
9504 +
9505 + if (err)
9506 + break;
9507 +
9508 + if ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30480000U) {
9509 + unsigned long addr;
9510 +
9511 + if ((ba & 0xFFC00000U) == 0x30800000U)
9512 + addr = regs->tpc + ((((ba | 0xFFFFFFFFFFC00000UL) ^ 0x00200000UL) + 0x00200000UL) << 2);
9513 + else
9514 + addr = regs->tpc + ((((ba | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
9515 +
9516 + if (test_thread_flag(TIF_32BIT))
9517 + addr &= 0xFFFFFFFFUL;
9518 +
9519 + regs->tpc = addr;
9520 + regs->tnpc = addr+4;
9521 + return 2;
9522 + }
9523 + } while (0);
9524 +
9525 + do { /* PaX: patched PLT emulation #3 */
9526 + unsigned int sethi, bajmpl, nop;
9527 +
9528 + err = get_user(sethi, (unsigned int *)regs->tpc);
9529 + err |= get_user(bajmpl, (unsigned int *)(regs->tpc+4));
9530 + err |= get_user(nop, (unsigned int *)(regs->tpc+8));
9531 +
9532 + if (err)
9533 + break;
9534 +
9535 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
9536 + ((bajmpl & 0xFFFFE000U) == 0x81C06000U || (bajmpl & 0xFFF80000U) == 0x30480000U) &&
9537 + nop == 0x01000000U)
9538 + {
9539 + unsigned long addr;
9540 +
9541 + addr = (sethi & 0x003FFFFFU) << 10;
9542 + regs->u_regs[UREG_G1] = addr;
9543 + if ((bajmpl & 0xFFFFE000U) == 0x81C06000U)
9544 + addr += (((bajmpl | 0xFFFFFFFFFFFFE000UL) ^ 0x00001000UL) + 0x00001000UL);
9545 + else
9546 + addr = regs->tpc + ((((bajmpl | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
9547 +
9548 + if (test_thread_flag(TIF_32BIT))
9549 + addr &= 0xFFFFFFFFUL;
9550 +
9551 + regs->tpc = addr;
9552 + regs->tnpc = addr+4;
9553 + return 2;
9554 + }
9555 + } while (0);
9556 +
9557 + do { /* PaX: patched PLT emulation #4 */
9558 + unsigned int sethi, mov1, call, mov2;
9559 +
9560 + err = get_user(sethi, (unsigned int *)regs->tpc);
9561 + err |= get_user(mov1, (unsigned int *)(regs->tpc+4));
9562 + err |= get_user(call, (unsigned int *)(regs->tpc+8));
9563 + err |= get_user(mov2, (unsigned int *)(regs->tpc+12));
9564 +
9565 + if (err)
9566 + break;
9567 +
9568 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
9569 + mov1 == 0x8210000FU &&
9570 + (call & 0xC0000000U) == 0x40000000U &&
9571 + mov2 == 0x9E100001U)
9572 + {
9573 + unsigned long addr;
9574 +
9575 + regs->u_regs[UREG_G1] = regs->u_regs[UREG_RETPC];
9576 + addr = regs->tpc + 4 + ((((call | 0xFFFFFFFFC0000000UL) ^ 0x20000000UL) + 0x20000000UL) << 2);
9577 +
9578 + if (test_thread_flag(TIF_32BIT))
9579 + addr &= 0xFFFFFFFFUL;
9580 +
9581 + regs->tpc = addr;
9582 + regs->tnpc = addr+4;
9583 + return 2;
9584 + }
9585 + } while (0);
9586 +
9587 + do { /* PaX: patched PLT emulation #5 */
9588 + unsigned int sethi, sethi1, sethi2, or1, or2, sllx, jmpl, nop;
9589 +
9590 + err = get_user(sethi, (unsigned int *)regs->tpc);
9591 + err |= get_user(sethi1, (unsigned int *)(regs->tpc+4));
9592 + err |= get_user(sethi2, (unsigned int *)(regs->tpc+8));
9593 + err |= get_user(or1, (unsigned int *)(regs->tpc+12));
9594 + err |= get_user(or2, (unsigned int *)(regs->tpc+16));
9595 + err |= get_user(sllx, (unsigned int *)(regs->tpc+20));
9596 + err |= get_user(jmpl, (unsigned int *)(regs->tpc+24));
9597 + err |= get_user(nop, (unsigned int *)(regs->tpc+28));
9598 +
9599 + if (err)
9600 + break;
9601 +
9602 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
9603 + (sethi1 & 0xFFC00000U) == 0x03000000U &&
9604 + (sethi2 & 0xFFC00000U) == 0x0B000000U &&
9605 + (or1 & 0xFFFFE000U) == 0x82106000U &&
9606 + (or2 & 0xFFFFE000U) == 0x8A116000U &&
9607 + sllx == 0x83287020U &&
9608 + jmpl == 0x81C04005U &&
9609 + nop == 0x01000000U)
9610 + {
9611 + unsigned long addr;
9612 +
9613 + regs->u_regs[UREG_G1] = ((sethi1 & 0x003FFFFFU) << 10) | (or1 & 0x000003FFU);
9614 + regs->u_regs[UREG_G1] <<= 32;
9615 + regs->u_regs[UREG_G5] = ((sethi2 & 0x003FFFFFU) << 10) | (or2 & 0x000003FFU);
9616 + addr = regs->u_regs[UREG_G1] + regs->u_regs[UREG_G5];
9617 + regs->tpc = addr;
9618 + regs->tnpc = addr+4;
9619 + return 2;
9620 + }
9621 + } while (0);
9622 +
9623 + do { /* PaX: patched PLT emulation #6 */
9624 + unsigned int sethi, sethi1, sethi2, sllx, or, jmpl, nop;
9625 +
9626 + err = get_user(sethi, (unsigned int *)regs->tpc);
9627 + err |= get_user(sethi1, (unsigned int *)(regs->tpc+4));
9628 + err |= get_user(sethi2, (unsigned int *)(regs->tpc+8));
9629 + err |= get_user(sllx, (unsigned int *)(regs->tpc+12));
9630 + err |= get_user(or, (unsigned int *)(regs->tpc+16));
9631 + err |= get_user(jmpl, (unsigned int *)(regs->tpc+20));
9632 + err |= get_user(nop, (unsigned int *)(regs->tpc+24));
9633 +
9634 + if (err)
9635 + break;
9636 +
9637 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
9638 + (sethi1 & 0xFFC00000U) == 0x03000000U &&
9639 + (sethi2 & 0xFFC00000U) == 0x0B000000U &&
9640 + sllx == 0x83287020U &&
9641 + (or & 0xFFFFE000U) == 0x8A116000U &&
9642 + jmpl == 0x81C04005U &&
9643 + nop == 0x01000000U)
9644 + {
9645 + unsigned long addr;
9646 +
9647 + regs->u_regs[UREG_G1] = (sethi1 & 0x003FFFFFU) << 10;
9648 + regs->u_regs[UREG_G1] <<= 32;
9649 + regs->u_regs[UREG_G5] = ((sethi2 & 0x003FFFFFU) << 10) | (or & 0x3FFU);
9650 + addr = regs->u_regs[UREG_G1] + regs->u_regs[UREG_G5];
9651 + regs->tpc = addr;
9652 + regs->tnpc = addr+4;
9653 + return 2;
9654 + }
9655 + } while (0);
9656 +
9657 + do { /* PaX: unpatched PLT emulation step 1 */
9658 + unsigned int sethi, ba, nop;
9659 +
9660 + err = get_user(sethi, (unsigned int *)regs->tpc);
9661 + err |= get_user(ba, (unsigned int *)(regs->tpc+4));
9662 + err |= get_user(nop, (unsigned int *)(regs->tpc+8));
9663 +
9664 + if (err)
9665 + break;
9666 +
9667 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
9668 + ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30680000U) &&
9669 + nop == 0x01000000U)
9670 + {
9671 + unsigned long addr;
9672 + unsigned int save, call;
9673 + unsigned int sethi1, sethi2, or1, or2, sllx, add, jmpl;
9674 +
9675 + if ((ba & 0xFFC00000U) == 0x30800000U)
9676 + addr = regs->tpc + 4 + ((((ba | 0xFFFFFFFFFFC00000UL) ^ 0x00200000UL) + 0x00200000UL) << 2);
9677 + else
9678 + addr = regs->tpc + 4 + ((((ba | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
9679 +
9680 + if (test_thread_flag(TIF_32BIT))
9681 + addr &= 0xFFFFFFFFUL;
9682 +
9683 + err = get_user(save, (unsigned int *)addr);
9684 + err |= get_user(call, (unsigned int *)(addr+4));
9685 + err |= get_user(nop, (unsigned int *)(addr+8));
9686 + if (err)
9687 + break;
9688 +
9689 +#ifdef CONFIG_PAX_DLRESOLVE
9690 + if (save == 0x9DE3BFA8U &&
9691 + (call & 0xC0000000U) == 0x40000000U &&
9692 + nop == 0x01000000U)
9693 + {
9694 + struct vm_area_struct *vma;
9695 + unsigned long call_dl_resolve;
9696 +
9697 + down_read(&current->mm->mmap_sem);
9698 + call_dl_resolve = current->mm->call_dl_resolve;
9699 + up_read(&current->mm->mmap_sem);
9700 + if (likely(call_dl_resolve))
9701 + goto emulate;
9702 +
9703 + vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
9704 +
9705 + down_write(&current->mm->mmap_sem);
9706 + if (current->mm->call_dl_resolve) {
9707 + call_dl_resolve = current->mm->call_dl_resolve;
9708 + up_write(&current->mm->mmap_sem);
9709 + if (vma)
9710 + kmem_cache_free(vm_area_cachep, vma);
9711 + goto emulate;
9712 + }
9713 +
9714 + call_dl_resolve = get_unmapped_area(NULL, 0UL, PAGE_SIZE, 0UL, MAP_PRIVATE);
9715 + if (!vma || (call_dl_resolve & ~PAGE_MASK)) {
9716 + up_write(&current->mm->mmap_sem);
9717 + if (vma)
9718 + kmem_cache_free(vm_area_cachep, vma);
9719 + return 1;
9720 + }
9721 +
9722 + if (pax_insert_vma(vma, call_dl_resolve)) {
9723 + up_write(&current->mm->mmap_sem);
9724 + kmem_cache_free(vm_area_cachep, vma);
9725 + return 1;
9726 + }
9727 +
9728 + current->mm->call_dl_resolve = call_dl_resolve;
9729 + up_write(&current->mm->mmap_sem);
9730 +
9731 +emulate:
9732 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
9733 + regs->tpc = call_dl_resolve;
9734 + regs->tnpc = addr+4;
9735 + return 3;
9736 + }
9737 +#endif
9738 +
9739 + /* PaX: glibc 2.4+ generates sethi/jmpl instead of save/call */
9740 + if ((save & 0xFFC00000U) == 0x05000000U &&
9741 + (call & 0xFFFFE000U) == 0x85C0A000U &&
9742 + nop == 0x01000000U)
9743 + {
9744 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
9745 + regs->u_regs[UREG_G2] = addr + 4;
9746 + addr = (save & 0x003FFFFFU) << 10;
9747 + addr += (((call | 0xFFFFFFFFFFFFE000UL) ^ 0x00001000UL) + 0x00001000UL);
9748 +
9749 + if (test_thread_flag(TIF_32BIT))
9750 + addr &= 0xFFFFFFFFUL;
9751 +
9752 + regs->tpc = addr;
9753 + regs->tnpc = addr+4;
9754 + return 3;
9755 + }
9756 +
9757 + /* PaX: 64-bit PLT stub */
9758 + err = get_user(sethi1, (unsigned int *)addr);
9759 + err |= get_user(sethi2, (unsigned int *)(addr+4));
9760 + err |= get_user(or1, (unsigned int *)(addr+8));
9761 + err |= get_user(or2, (unsigned int *)(addr+12));
9762 + err |= get_user(sllx, (unsigned int *)(addr+16));
9763 + err |= get_user(add, (unsigned int *)(addr+20));
9764 + err |= get_user(jmpl, (unsigned int *)(addr+24));
9765 + err |= get_user(nop, (unsigned int *)(addr+28));
9766 + if (err)
9767 + break;
9768 +
9769 + if ((sethi1 & 0xFFC00000U) == 0x09000000U &&
9770 + (sethi2 & 0xFFC00000U) == 0x0B000000U &&
9771 + (or1 & 0xFFFFE000U) == 0x88112000U &&
9772 + (or2 & 0xFFFFE000U) == 0x8A116000U &&
9773 + sllx == 0x89293020U &&
9774 + add == 0x8A010005U &&
9775 + jmpl == 0x89C14000U &&
9776 + nop == 0x01000000U)
9777 + {
9778 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
9779 + regs->u_regs[UREG_G4] = ((sethi1 & 0x003FFFFFU) << 10) | (or1 & 0x000003FFU);
9780 + regs->u_regs[UREG_G4] <<= 32;
9781 + regs->u_regs[UREG_G5] = ((sethi2 & 0x003FFFFFU) << 10) | (or2 & 0x000003FFU);
9782 + regs->u_regs[UREG_G5] += regs->u_regs[UREG_G4];
9783 + regs->u_regs[UREG_G4] = addr + 24;
9784 + addr = regs->u_regs[UREG_G5];
9785 + regs->tpc = addr;
9786 + regs->tnpc = addr+4;
9787 + return 3;
9788 + }
9789 + }
9790 + } while (0);
9791 +
9792 +#ifdef CONFIG_PAX_DLRESOLVE
9793 + do { /* PaX: unpatched PLT emulation step 2 */
9794 + unsigned int save, call, nop;
9795 +
9796 + err = get_user(save, (unsigned int *)(regs->tpc-4));
9797 + err |= get_user(call, (unsigned int *)regs->tpc);
9798 + err |= get_user(nop, (unsigned int *)(regs->tpc+4));
9799 + if (err)
9800 + break;
9801 +
9802 + if (save == 0x9DE3BFA8U &&
9803 + (call & 0xC0000000U) == 0x40000000U &&
9804 + nop == 0x01000000U)
9805 + {
9806 + unsigned long dl_resolve = regs->tpc + ((((call | 0xFFFFFFFFC0000000UL) ^ 0x20000000UL) + 0x20000000UL) << 2);
9807 +
9808 + if (test_thread_flag(TIF_32BIT))
9809 + dl_resolve &= 0xFFFFFFFFUL;
9810 +
9811 + regs->u_regs[UREG_RETPC] = regs->tpc;
9812 + regs->tpc = dl_resolve;
9813 + regs->tnpc = dl_resolve+4;
9814 + return 3;
9815 + }
9816 + } while (0);
9817 +#endif
9818 +
9819 + do { /* PaX: patched PLT emulation #7, must be AFTER the unpatched PLT emulation */
9820 + unsigned int sethi, ba, nop;
9821 +
9822 + err = get_user(sethi, (unsigned int *)regs->tpc);
9823 + err |= get_user(ba, (unsigned int *)(regs->tpc+4));
9824 + err |= get_user(nop, (unsigned int *)(regs->tpc+8));
9825 +
9826 + if (err)
9827 + break;
9828 +
9829 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
9830 + (ba & 0xFFF00000U) == 0x30600000U &&
9831 + nop == 0x01000000U)
9832 + {
9833 + unsigned long addr;
9834 +
9835 + addr = (sethi & 0x003FFFFFU) << 10;
9836 + regs->u_regs[UREG_G1] = addr;
9837 + addr = regs->tpc + ((((ba | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
9838 +
9839 + if (test_thread_flag(TIF_32BIT))
9840 + addr &= 0xFFFFFFFFUL;
9841 +
9842 + regs->tpc = addr;
9843 + regs->tnpc = addr+4;
9844 + return 2;
9845 + }
9846 + } while (0);
9847 +
9848 +#endif
9849 +
9850 + return 1;
9851 +}
9852 +
9853 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
9854 +{
9855 + unsigned long i;
9856 +
9857 + printk(KERN_ERR "PAX: bytes at PC: ");
9858 + for (i = 0; i < 8; i++) {
9859 + unsigned int c;
9860 + if (get_user(c, (unsigned int *)pc+i))
9861 + printk(KERN_CONT "???????? ");
9862 + else
9863 + printk(KERN_CONT "%08x ", c);
9864 + }
9865 + printk("\n");
9866 +}
9867 +#endif
9868 +
9869 asmlinkage void __kprobes do_sparc64_fault(struct pt_regs *regs)
9870 {
9871 struct mm_struct *mm = current->mm;
9872 @@ -341,6 +804,29 @@ retry:
9873 if (!vma)
9874 goto bad_area;
9875
9876 +#ifdef CONFIG_PAX_PAGEEXEC
9877 + /* PaX: detect ITLB misses on non-exec pages */
9878 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && vma->vm_start <= address &&
9879 + !(vma->vm_flags & VM_EXEC) && (fault_code & FAULT_CODE_ITLB))
9880 + {
9881 + if (address != regs->tpc)
9882 + goto good_area;
9883 +
9884 + up_read(&mm->mmap_sem);
9885 + switch (pax_handle_fetch_fault(regs)) {
9886 +
9887 +#ifdef CONFIG_PAX_EMUPLT
9888 + case 2:
9889 + case 3:
9890 + return;
9891 +#endif
9892 +
9893 + }
9894 + pax_report_fault(regs, (void *)regs->tpc, (void *)(regs->u_regs[UREG_FP] + STACK_BIAS));
9895 + do_group_exit(SIGKILL);
9896 + }
9897 +#endif
9898 +
9899 /* Pure DTLB misses do not tell us whether the fault causing
9900 * load/store/atomic was a write or not, it only says that there
9901 * was no match. So in such a case we (carefully) read the
9902 diff --git a/arch/sparc/mm/hugetlbpage.c b/arch/sparc/mm/hugetlbpage.c
9903 index d2b5944..bd813f2 100644
9904 --- a/arch/sparc/mm/hugetlbpage.c
9905 +++ b/arch/sparc/mm/hugetlbpage.c
9906 @@ -38,7 +38,7 @@ static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *filp,
9907
9908 info.flags = 0;
9909 info.length = len;
9910 - info.low_limit = TASK_UNMAPPED_BASE;
9911 + info.low_limit = mm->mmap_base;
9912 info.high_limit = min(task_size, VA_EXCLUDE_START);
9913 info.align_mask = PAGE_MASK & ~HPAGE_MASK;
9914 info.align_offset = 0;
9915 @@ -47,6 +47,12 @@ static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *filp,
9916 if ((addr & ~PAGE_MASK) && task_size > VA_EXCLUDE_END) {
9917 VM_BUG_ON(addr != -ENOMEM);
9918 info.low_limit = VA_EXCLUDE_END;
9919 +
9920 +#ifdef CONFIG_PAX_RANDMMAP
9921 + if (mm->pax_flags & MF_PAX_RANDMMAP)
9922 + info.low_limit += mm->delta_mmap;
9923 +#endif
9924 +
9925 info.high_limit = task_size;
9926 addr = vm_unmapped_area(&info);
9927 }
9928 @@ -85,6 +91,12 @@ hugetlb_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
9929 VM_BUG_ON(addr != -ENOMEM);
9930 info.flags = 0;
9931 info.low_limit = TASK_UNMAPPED_BASE;
9932 +
9933 +#ifdef CONFIG_PAX_RANDMMAP
9934 + if (mm->pax_flags & MF_PAX_RANDMMAP)
9935 + info.low_limit += mm->delta_mmap;
9936 +#endif
9937 +
9938 info.high_limit = STACK_TOP32;
9939 addr = vm_unmapped_area(&info);
9940 }
9941 @@ -99,6 +111,7 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
9942 struct mm_struct *mm = current->mm;
9943 struct vm_area_struct *vma;
9944 unsigned long task_size = TASK_SIZE;
9945 + unsigned long offset = gr_rand_threadstack_offset(mm, file, flags);
9946
9947 if (test_thread_flag(TIF_32BIT))
9948 task_size = STACK_TOP32;
9949 @@ -114,11 +127,14 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
9950 return addr;
9951 }
9952
9953 +#ifdef CONFIG_PAX_RANDMMAP
9954 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
9955 +#endif
9956 +
9957 if (addr) {
9958 addr = ALIGN(addr, HPAGE_SIZE);
9959 vma = find_vma(mm, addr);
9960 - if (task_size - len >= addr &&
9961 - (!vma || addr + len <= vma->vm_start))
9962 + if (task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
9963 return addr;
9964 }
9965 if (mm->get_unmapped_area == arch_get_unmapped_area)
9966 diff --git a/arch/tile/include/asm/atomic_64.h b/arch/tile/include/asm/atomic_64.h
9967 index f4500c6..889656c 100644
9968 --- a/arch/tile/include/asm/atomic_64.h
9969 +++ b/arch/tile/include/asm/atomic_64.h
9970 @@ -143,6 +143,16 @@ static inline long atomic64_add_unless(atomic64_t *v, long a, long u)
9971
9972 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
9973
9974 +#define atomic64_read_unchecked(v) atomic64_read(v)
9975 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
9976 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
9977 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
9978 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
9979 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
9980 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
9981 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
9982 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
9983 +
9984 /* Atomic dec and inc don't implement barrier, so provide them if needed. */
9985 #define smp_mb__before_atomic_dec() smp_mb()
9986 #define smp_mb__after_atomic_dec() smp_mb()
9987 diff --git a/arch/tile/include/asm/cache.h b/arch/tile/include/asm/cache.h
9988 index a9a5299..0fce79e 100644
9989 --- a/arch/tile/include/asm/cache.h
9990 +++ b/arch/tile/include/asm/cache.h
9991 @@ -15,11 +15,12 @@
9992 #ifndef _ASM_TILE_CACHE_H
9993 #define _ASM_TILE_CACHE_H
9994
9995 +#include <linux/const.h>
9996 #include <arch/chip.h>
9997
9998 /* bytes per L1 data cache line */
9999 #define L1_CACHE_SHIFT CHIP_L1D_LOG_LINE_SIZE()
10000 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
10001 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
10002
10003 /* bytes per L2 cache line */
10004 #define L2_CACHE_SHIFT CHIP_L2_LOG_LINE_SIZE()
10005 diff --git a/arch/tile/include/asm/uaccess.h b/arch/tile/include/asm/uaccess.h
10006 index 9ab078a..d6635c2 100644
10007 --- a/arch/tile/include/asm/uaccess.h
10008 +++ b/arch/tile/include/asm/uaccess.h
10009 @@ -403,9 +403,9 @@ static inline unsigned long __must_check copy_from_user(void *to,
10010 const void __user *from,
10011 unsigned long n)
10012 {
10013 - int sz = __compiletime_object_size(to);
10014 + size_t sz = __compiletime_object_size(to);
10015
10016 - if (likely(sz == -1 || sz >= n))
10017 + if (likely(sz == (size_t)-1 || sz >= n))
10018 n = _copy_from_user(to, from, n);
10019 else
10020 copy_from_user_overflow();
10021 diff --git a/arch/um/Makefile b/arch/um/Makefile
10022 index 133f7de..1d6f2f1 100644
10023 --- a/arch/um/Makefile
10024 +++ b/arch/um/Makefile
10025 @@ -62,6 +62,10 @@ USER_CFLAGS = $(patsubst $(KERNEL_DEFINES),,$(patsubst -D__KERNEL__,,\
10026 $(patsubst -I%,,$(KBUILD_CFLAGS)))) $(ARCH_INCLUDE) $(MODE_INCLUDE) \
10027 $(filter -I%,$(CFLAGS)) -D_FILE_OFFSET_BITS=64 -idirafter include
10028
10029 +ifdef CONSTIFY_PLUGIN
10030 +USER_CFLAGS += -fplugin-arg-constify_plugin-no-constify
10031 +endif
10032 +
10033 #This will adjust *FLAGS accordingly to the platform.
10034 include $(srctree)/$(ARCH_DIR)/Makefile-os-$(OS)
10035
10036 diff --git a/arch/um/include/asm/cache.h b/arch/um/include/asm/cache.h
10037 index 19e1bdd..3665b77 100644
10038 --- a/arch/um/include/asm/cache.h
10039 +++ b/arch/um/include/asm/cache.h
10040 @@ -1,6 +1,7 @@
10041 #ifndef __UM_CACHE_H
10042 #define __UM_CACHE_H
10043
10044 +#include <linux/const.h>
10045
10046 #if defined(CONFIG_UML_X86) && !defined(CONFIG_64BIT)
10047 # define L1_CACHE_SHIFT (CONFIG_X86_L1_CACHE_SHIFT)
10048 @@ -12,6 +13,6 @@
10049 # define L1_CACHE_SHIFT 5
10050 #endif
10051
10052 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
10053 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
10054
10055 #endif
10056 diff --git a/arch/um/include/asm/kmap_types.h b/arch/um/include/asm/kmap_types.h
10057 index 2e0a6b1..a64d0f5 100644
10058 --- a/arch/um/include/asm/kmap_types.h
10059 +++ b/arch/um/include/asm/kmap_types.h
10060 @@ -8,6 +8,6 @@
10061
10062 /* No more #include "asm/arch/kmap_types.h" ! */
10063
10064 -#define KM_TYPE_NR 14
10065 +#define KM_TYPE_NR 15
10066
10067 #endif
10068 diff --git a/arch/um/include/asm/page.h b/arch/um/include/asm/page.h
10069 index 5ff53d9..5850cdf 100644
10070 --- a/arch/um/include/asm/page.h
10071 +++ b/arch/um/include/asm/page.h
10072 @@ -14,6 +14,9 @@
10073 #define PAGE_SIZE (_AC(1, UL) << PAGE_SHIFT)
10074 #define PAGE_MASK (~(PAGE_SIZE-1))
10075
10076 +#define ktla_ktva(addr) (addr)
10077 +#define ktva_ktla(addr) (addr)
10078 +
10079 #ifndef __ASSEMBLY__
10080
10081 struct page;
10082 diff --git a/arch/um/include/asm/pgtable-3level.h b/arch/um/include/asm/pgtable-3level.h
10083 index 0032f92..cd151e0 100644
10084 --- a/arch/um/include/asm/pgtable-3level.h
10085 +++ b/arch/um/include/asm/pgtable-3level.h
10086 @@ -58,6 +58,7 @@
10087 #define pud_present(x) (pud_val(x) & _PAGE_PRESENT)
10088 #define pud_populate(mm, pud, pmd) \
10089 set_pud(pud, __pud(_PAGE_TABLE + __pa(pmd)))
10090 +#define pud_populate_kernel(mm, pud, pmd) pud_populate((mm), (pud), (pmd))
10091
10092 #ifdef CONFIG_64BIT
10093 #define set_pud(pudptr, pudval) set_64bit((u64 *) (pudptr), pud_val(pudval))
10094 diff --git a/arch/um/kernel/process.c b/arch/um/kernel/process.c
10095 index b462b13..e7a19aa 100644
10096 --- a/arch/um/kernel/process.c
10097 +++ b/arch/um/kernel/process.c
10098 @@ -386,22 +386,6 @@ int singlestepping(void * t)
10099 return 2;
10100 }
10101
10102 -/*
10103 - * Only x86 and x86_64 have an arch_align_stack().
10104 - * All other arches have "#define arch_align_stack(x) (x)"
10105 - * in their asm/system.h
10106 - * As this is included in UML from asm-um/system-generic.h,
10107 - * we can use it to behave as the subarch does.
10108 - */
10109 -#ifndef arch_align_stack
10110 -unsigned long arch_align_stack(unsigned long sp)
10111 -{
10112 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
10113 - sp -= get_random_int() % 8192;
10114 - return sp & ~0xf;
10115 -}
10116 -#endif
10117 -
10118 unsigned long get_wchan(struct task_struct *p)
10119 {
10120 unsigned long stack_page, sp, ip;
10121 diff --git a/arch/unicore32/include/asm/cache.h b/arch/unicore32/include/asm/cache.h
10122 index ad8f795..2c7eec6 100644
10123 --- a/arch/unicore32/include/asm/cache.h
10124 +++ b/arch/unicore32/include/asm/cache.h
10125 @@ -12,8 +12,10 @@
10126 #ifndef __UNICORE_CACHE_H__
10127 #define __UNICORE_CACHE_H__
10128
10129 -#define L1_CACHE_SHIFT (5)
10130 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
10131 +#include <linux/const.h>
10132 +
10133 +#define L1_CACHE_SHIFT 5
10134 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
10135
10136 /*
10137 * Memory returned by kmalloc() may be used for DMA, so we must make
10138 diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
10139 index 0694d09..b58b3aa 100644
10140 --- a/arch/x86/Kconfig
10141 +++ b/arch/x86/Kconfig
10142 @@ -238,7 +238,7 @@ config X86_HT
10143
10144 config X86_32_LAZY_GS
10145 def_bool y
10146 - depends on X86_32 && !CC_STACKPROTECTOR
10147 + depends on X86_32 && !CC_STACKPROTECTOR && !PAX_MEMORY_UDEREF
10148
10149 config ARCH_HWEIGHT_CFLAGS
10150 string
10151 @@ -1031,6 +1031,7 @@ config MICROCODE_OLD_INTERFACE
10152
10153 config X86_MSR
10154 tristate "/dev/cpu/*/msr - Model-specific register support"
10155 + depends on !GRKERNSEC_KMEM
10156 ---help---
10157 This device gives privileged processes access to the x86
10158 Model-Specific Registers (MSRs). It is a character device with
10159 @@ -1054,7 +1055,7 @@ choice
10160
10161 config NOHIGHMEM
10162 bool "off"
10163 - depends on !X86_NUMAQ
10164 + depends on !X86_NUMAQ && !(PAX_PAGEEXEC && PAX_ENABLE_PAE)
10165 ---help---
10166 Linux can use up to 64 Gigabytes of physical memory on x86 systems.
10167 However, the address space of 32-bit x86 processors is only 4
10168 @@ -1091,7 +1092,7 @@ config NOHIGHMEM
10169
10170 config HIGHMEM4G
10171 bool "4GB"
10172 - depends on !X86_NUMAQ
10173 + depends on !X86_NUMAQ && !(PAX_PAGEEXEC && PAX_ENABLE_PAE)
10174 ---help---
10175 Select this if you have a 32-bit processor and between 1 and 4
10176 gigabytes of physical RAM.
10177 @@ -1145,7 +1146,7 @@ config PAGE_OFFSET
10178 hex
10179 default 0xB0000000 if VMSPLIT_3G_OPT
10180 default 0x80000000 if VMSPLIT_2G
10181 - default 0x78000000 if VMSPLIT_2G_OPT
10182 + default 0x70000000 if VMSPLIT_2G_OPT
10183 default 0x40000000 if VMSPLIT_1G
10184 default 0xC0000000
10185 depends on X86_32
10186 @@ -1542,6 +1543,7 @@ config SECCOMP
10187
10188 config CC_STACKPROTECTOR
10189 bool "Enable -fstack-protector buffer overflow detection"
10190 + depends on X86_64 || !PAX_MEMORY_UDEREF
10191 ---help---
10192 This option turns on the -fstack-protector GCC feature. This
10193 feature puts, at the beginning of functions, a canary value on
10194 @@ -1599,6 +1601,7 @@ config KEXEC_JUMP
10195 config PHYSICAL_START
10196 hex "Physical address where the kernel is loaded" if (EXPERT || CRASH_DUMP)
10197 default "0x1000000"
10198 + range 0x400000 0x40000000
10199 ---help---
10200 This gives the physical address where the kernel is loaded.
10201
10202 @@ -1662,6 +1665,7 @@ config X86_NEED_RELOCS
10203 config PHYSICAL_ALIGN
10204 hex "Alignment value to which kernel should be aligned" if X86_32
10205 default "0x1000000"
10206 + range 0x400000 0x1000000 if PAX_KERNEXEC
10207 range 0x2000 0x1000000
10208 ---help---
10209 This value puts the alignment restrictions on physical address
10210 @@ -1737,9 +1741,10 @@ config DEBUG_HOTPLUG_CPU0
10211 If unsure, say N.
10212
10213 config COMPAT_VDSO
10214 - def_bool y
10215 + def_bool n
10216 prompt "Compat VDSO support"
10217 depends on X86_32 || IA32_EMULATION
10218 + depends on !PAX_PAGEEXEC && !PAX_SEGMEXEC && !PAX_KERNEXEC && !PAX_MEMORY_UDEREF
10219 ---help---
10220 Map the 32-bit VDSO to the predictable old-style address too.
10221
10222 diff --git a/arch/x86/Kconfig.cpu b/arch/x86/Kconfig.cpu
10223 index c026cca..14657ae 100644
10224 --- a/arch/x86/Kconfig.cpu
10225 +++ b/arch/x86/Kconfig.cpu
10226 @@ -319,7 +319,7 @@ config X86_PPRO_FENCE
10227
10228 config X86_F00F_BUG
10229 def_bool y
10230 - depends on M586MMX || M586TSC || M586 || M486
10231 + depends on (M586MMX || M586TSC || M586 || M486) && !PAX_KERNEXEC
10232
10233 config X86_INVD_BUG
10234 def_bool y
10235 @@ -327,7 +327,7 @@ config X86_INVD_BUG
10236
10237 config X86_ALIGNMENT_16
10238 def_bool y
10239 - depends on MWINCHIP3D || MWINCHIPC6 || MCYRIXIII || MELAN || MK6 || M586MMX || M586TSC || M586 || M486 || MVIAC3_2 || MGEODEGX1
10240 + depends on MWINCHIP3D || MWINCHIPC6 || MCYRIXIII || X86_ELAN || MK8 || MK7 || MK6 || MCORE2 || MPENTIUM4 || MPENTIUMIII || MPENTIUMII || M686 || M586MMX || M586TSC || M586 || M486 || MVIAC3_2 || MGEODEGX1
10241
10242 config X86_INTEL_USERCOPY
10243 def_bool y
10244 @@ -373,7 +373,7 @@ config X86_CMPXCHG64
10245 # generates cmov.
10246 config X86_CMOV
10247 def_bool y
10248 - depends on (MK8 || MK7 || MCORE2 || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || MVIAC3_2 || MVIAC7 || MCRUSOE || MEFFICEON || X86_64 || MATOM || MGEODE_LX)
10249 + depends on (MK8 || MK7 || MCORE2 || MPSC || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || MVIAC3_2 || MVIAC7 || MCRUSOE || MEFFICEON || X86_64 || MATOM || MGEODE_LX)
10250
10251 config X86_MINIMUM_CPU_FAMILY
10252 int
10253 diff --git a/arch/x86/Kconfig.debug b/arch/x86/Kconfig.debug
10254 index b322f12..652d0d9 100644
10255 --- a/arch/x86/Kconfig.debug
10256 +++ b/arch/x86/Kconfig.debug
10257 @@ -84,7 +84,7 @@ config X86_PTDUMP
10258 config DEBUG_RODATA
10259 bool "Write protect kernel read-only data structures"
10260 default y
10261 - depends on DEBUG_KERNEL
10262 + depends on DEBUG_KERNEL && BROKEN
10263 ---help---
10264 Mark the kernel read-only data as write-protected in the pagetables,
10265 in order to catch accidental (and incorrect) writes to such const
10266 @@ -102,7 +102,7 @@ config DEBUG_RODATA_TEST
10267
10268 config DEBUG_SET_MODULE_RONX
10269 bool "Set loadable kernel module data as NX and text as RO"
10270 - depends on MODULES
10271 + depends on MODULES && BROKEN
10272 ---help---
10273 This option helps catch unintended modifications to loadable
10274 kernel module's text and read-only data. It also prevents execution
10275 @@ -294,7 +294,7 @@ config OPTIMIZE_INLINING
10276
10277 config DEBUG_STRICT_USER_COPY_CHECKS
10278 bool "Strict copy size checks"
10279 - depends on DEBUG_KERNEL && !TRACE_BRANCH_PROFILING
10280 + depends on DEBUG_KERNEL && !TRACE_BRANCH_PROFILING && !PAX_SIZE_OVERFLOW
10281 ---help---
10282 Enabling this option turns a certain set of sanity checks for user
10283 copy operations into compile time failures.
10284 diff --git a/arch/x86/Makefile b/arch/x86/Makefile
10285 index e71fc42..7829607 100644
10286 --- a/arch/x86/Makefile
10287 +++ b/arch/x86/Makefile
10288 @@ -50,6 +50,7 @@ else
10289 UTS_MACHINE := x86_64
10290 CHECKFLAGS += -D__x86_64__ -m64
10291
10292 + biarch := $(call cc-option,-m64)
10293 KBUILD_AFLAGS += -m64
10294 KBUILD_CFLAGS += -m64
10295
10296 @@ -230,3 +231,12 @@ define archhelp
10297 echo ' FDARGS="..." arguments for the booted kernel'
10298 echo ' FDINITRD=file initrd for the booted kernel'
10299 endef
10300 +
10301 +define OLD_LD
10302 +
10303 +*** ${VERSION}.${PATCHLEVEL} PaX kernels no longer build correctly with old versions of binutils.
10304 +*** Please upgrade your binutils to 2.18 or newer
10305 +endef
10306 +
10307 +archprepare:
10308 + $(if $(LDFLAGS_BUILD_ID),,$(error $(OLD_LD)))
10309 diff --git a/arch/x86/boot/Makefile b/arch/x86/boot/Makefile
10310 index 379814b..add62ce 100644
10311 --- a/arch/x86/boot/Makefile
10312 +++ b/arch/x86/boot/Makefile
10313 @@ -65,6 +65,9 @@ KBUILD_CFLAGS := $(USERINCLUDE) -g -Os -D_SETUP -D__KERNEL__ \
10314 $(call cc-option, -fno-stack-protector) \
10315 $(call cc-option, -mpreferred-stack-boundary=2)
10316 KBUILD_CFLAGS += $(call cc-option, -m32)
10317 +ifdef CONSTIFY_PLUGIN
10318 +KBUILD_CFLAGS += -fplugin-arg-constify_plugin-no-constify
10319 +endif
10320 KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
10321 GCOV_PROFILE := n
10322
10323 diff --git a/arch/x86/boot/bitops.h b/arch/x86/boot/bitops.h
10324 index 878e4b9..20537ab 100644
10325 --- a/arch/x86/boot/bitops.h
10326 +++ b/arch/x86/boot/bitops.h
10327 @@ -26,7 +26,7 @@ static inline int variable_test_bit(int nr, const void *addr)
10328 u8 v;
10329 const u32 *p = (const u32 *)addr;
10330
10331 - asm("btl %2,%1; setc %0" : "=qm" (v) : "m" (*p), "Ir" (nr));
10332 + asm volatile("btl %2,%1; setc %0" : "=qm" (v) : "m" (*p), "Ir" (nr));
10333 return v;
10334 }
10335
10336 @@ -37,7 +37,7 @@ static inline int variable_test_bit(int nr, const void *addr)
10337
10338 static inline void set_bit(int nr, void *addr)
10339 {
10340 - asm("btsl %1,%0" : "+m" (*(u32 *)addr) : "Ir" (nr));
10341 + asm volatile("btsl %1,%0" : "+m" (*(u32 *)addr) : "Ir" (nr));
10342 }
10343
10344 #endif /* BOOT_BITOPS_H */
10345 diff --git a/arch/x86/boot/boot.h b/arch/x86/boot/boot.h
10346 index 18997e5..83d9c67 100644
10347 --- a/arch/x86/boot/boot.h
10348 +++ b/arch/x86/boot/boot.h
10349 @@ -85,7 +85,7 @@ static inline void io_delay(void)
10350 static inline u16 ds(void)
10351 {
10352 u16 seg;
10353 - asm("movw %%ds,%0" : "=rm" (seg));
10354 + asm volatile("movw %%ds,%0" : "=rm" (seg));
10355 return seg;
10356 }
10357
10358 @@ -181,7 +181,7 @@ static inline void wrgs32(u32 v, addr_t addr)
10359 static inline int memcmp(const void *s1, const void *s2, size_t len)
10360 {
10361 u8 diff;
10362 - asm("repe; cmpsb; setnz %0"
10363 + asm volatile("repe; cmpsb; setnz %0"
10364 : "=qm" (diff), "+D" (s1), "+S" (s2), "+c" (len));
10365 return diff;
10366 }
10367 diff --git a/arch/x86/boot/compressed/Makefile b/arch/x86/boot/compressed/Makefile
10368 index 8a84501..b2d165f 100644
10369 --- a/arch/x86/boot/compressed/Makefile
10370 +++ b/arch/x86/boot/compressed/Makefile
10371 @@ -14,6 +14,9 @@ cflags-$(CONFIG_X86_64) := -mcmodel=small
10372 KBUILD_CFLAGS += $(cflags-y)
10373 KBUILD_CFLAGS += $(call cc-option,-ffreestanding)
10374 KBUILD_CFLAGS += $(call cc-option,-fno-stack-protector)
10375 +ifdef CONSTIFY_PLUGIN
10376 +KBUILD_CFLAGS += -fplugin-arg-constify_plugin-no-constify
10377 +endif
10378
10379 KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
10380 GCOV_PROFILE := n
10381 diff --git a/arch/x86/boot/compressed/eboot.c b/arch/x86/boot/compressed/eboot.c
10382 index c205035..5853587 100644
10383 --- a/arch/x86/boot/compressed/eboot.c
10384 +++ b/arch/x86/boot/compressed/eboot.c
10385 @@ -150,7 +150,6 @@ again:
10386 *addr = max_addr;
10387 }
10388
10389 -free_pool:
10390 efi_call_phys1(sys_table->boottime->free_pool, map);
10391
10392 fail:
10393 @@ -214,7 +213,6 @@ static efi_status_t low_alloc(unsigned long size, unsigned long align,
10394 if (i == map_size / desc_size)
10395 status = EFI_NOT_FOUND;
10396
10397 -free_pool:
10398 efi_call_phys1(sys_table->boottime->free_pool, map);
10399 fail:
10400 return status;
10401 diff --git a/arch/x86/boot/compressed/head_32.S b/arch/x86/boot/compressed/head_32.S
10402 index 1e3184f..0d11e2e 100644
10403 --- a/arch/x86/boot/compressed/head_32.S
10404 +++ b/arch/x86/boot/compressed/head_32.S
10405 @@ -118,7 +118,7 @@ preferred_addr:
10406 notl %eax
10407 andl %eax, %ebx
10408 #else
10409 - movl $LOAD_PHYSICAL_ADDR, %ebx
10410 + movl $____LOAD_PHYSICAL_ADDR, %ebx
10411 #endif
10412
10413 /* Target address to relocate to for decompression */
10414 @@ -204,7 +204,7 @@ relocated:
10415 * and where it was actually loaded.
10416 */
10417 movl %ebp, %ebx
10418 - subl $LOAD_PHYSICAL_ADDR, %ebx
10419 + subl $____LOAD_PHYSICAL_ADDR, %ebx
10420 jz 2f /* Nothing to be done if loaded at compiled addr. */
10421 /*
10422 * Process relocations.
10423 @@ -212,8 +212,7 @@ relocated:
10424
10425 1: subl $4, %edi
10426 movl (%edi), %ecx
10427 - testl %ecx, %ecx
10428 - jz 2f
10429 + jecxz 2f
10430 addl %ebx, -__PAGE_OFFSET(%ebx, %ecx)
10431 jmp 1b
10432 2:
10433 diff --git a/arch/x86/boot/compressed/head_64.S b/arch/x86/boot/compressed/head_64.S
10434 index f5d1aaa..cce11dc 100644
10435 --- a/arch/x86/boot/compressed/head_64.S
10436 +++ b/arch/x86/boot/compressed/head_64.S
10437 @@ -91,7 +91,7 @@ ENTRY(startup_32)
10438 notl %eax
10439 andl %eax, %ebx
10440 #else
10441 - movl $LOAD_PHYSICAL_ADDR, %ebx
10442 + movl $____LOAD_PHYSICAL_ADDR, %ebx
10443 #endif
10444
10445 /* Target address to relocate to for decompression */
10446 @@ -273,7 +273,7 @@ preferred_addr:
10447 notq %rax
10448 andq %rax, %rbp
10449 #else
10450 - movq $LOAD_PHYSICAL_ADDR, %rbp
10451 + movq $____LOAD_PHYSICAL_ADDR, %rbp
10452 #endif
10453
10454 /* Target address to relocate to for decompression */
10455 diff --git a/arch/x86/boot/compressed/misc.c b/arch/x86/boot/compressed/misc.c
10456 index 88f7ff6..ed695dd 100644
10457 --- a/arch/x86/boot/compressed/misc.c
10458 +++ b/arch/x86/boot/compressed/misc.c
10459 @@ -303,7 +303,7 @@ static void parse_elf(void *output)
10460 case PT_LOAD:
10461 #ifdef CONFIG_RELOCATABLE
10462 dest = output;
10463 - dest += (phdr->p_paddr - LOAD_PHYSICAL_ADDR);
10464 + dest += (phdr->p_paddr - ____LOAD_PHYSICAL_ADDR);
10465 #else
10466 dest = (void *)(phdr->p_paddr);
10467 #endif
10468 @@ -352,7 +352,7 @@ asmlinkage void decompress_kernel(void *rmode, memptr heap,
10469 error("Destination address too large");
10470 #endif
10471 #ifndef CONFIG_RELOCATABLE
10472 - if ((unsigned long)output != LOAD_PHYSICAL_ADDR)
10473 + if ((unsigned long)output != ____LOAD_PHYSICAL_ADDR)
10474 error("Wrong destination address");
10475 #endif
10476
10477 diff --git a/arch/x86/boot/cpucheck.c b/arch/x86/boot/cpucheck.c
10478 index 4d3ff03..e4972ff 100644
10479 --- a/arch/x86/boot/cpucheck.c
10480 +++ b/arch/x86/boot/cpucheck.c
10481 @@ -74,7 +74,7 @@ static int has_fpu(void)
10482 u16 fcw = -1, fsw = -1;
10483 u32 cr0;
10484
10485 - asm("movl %%cr0,%0" : "=r" (cr0));
10486 + asm volatile("movl %%cr0,%0" : "=r" (cr0));
10487 if (cr0 & (X86_CR0_EM|X86_CR0_TS)) {
10488 cr0 &= ~(X86_CR0_EM|X86_CR0_TS);
10489 asm volatile("movl %0,%%cr0" : : "r" (cr0));
10490 @@ -90,7 +90,7 @@ static int has_eflag(u32 mask)
10491 {
10492 u32 f0, f1;
10493
10494 - asm("pushfl ; "
10495 + asm volatile("pushfl ; "
10496 "pushfl ; "
10497 "popl %0 ; "
10498 "movl %0,%1 ; "
10499 @@ -115,7 +115,7 @@ static void get_flags(void)
10500 set_bit(X86_FEATURE_FPU, cpu.flags);
10501
10502 if (has_eflag(X86_EFLAGS_ID)) {
10503 - asm("cpuid"
10504 + asm volatile("cpuid"
10505 : "=a" (max_intel_level),
10506 "=b" (cpu_vendor[0]),
10507 "=d" (cpu_vendor[1]),
10508 @@ -124,7 +124,7 @@ static void get_flags(void)
10509
10510 if (max_intel_level >= 0x00000001 &&
10511 max_intel_level <= 0x0000ffff) {
10512 - asm("cpuid"
10513 + asm volatile("cpuid"
10514 : "=a" (tfms),
10515 "=c" (cpu.flags[4]),
10516 "=d" (cpu.flags[0])
10517 @@ -136,7 +136,7 @@ static void get_flags(void)
10518 cpu.model += ((tfms >> 16) & 0xf) << 4;
10519 }
10520
10521 - asm("cpuid"
10522 + asm volatile("cpuid"
10523 : "=a" (max_amd_level)
10524 : "a" (0x80000000)
10525 : "ebx", "ecx", "edx");
10526 @@ -144,7 +144,7 @@ static void get_flags(void)
10527 if (max_amd_level >= 0x80000001 &&
10528 max_amd_level <= 0x8000ffff) {
10529 u32 eax = 0x80000001;
10530 - asm("cpuid"
10531 + asm volatile("cpuid"
10532 : "+a" (eax),
10533 "=c" (cpu.flags[6]),
10534 "=d" (cpu.flags[1])
10535 @@ -203,9 +203,9 @@ int check_cpu(int *cpu_level_ptr, int *req_level_ptr, u32 **err_flags_ptr)
10536 u32 ecx = MSR_K7_HWCR;
10537 u32 eax, edx;
10538
10539 - asm("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
10540 + asm volatile("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
10541 eax &= ~(1 << 15);
10542 - asm("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
10543 + asm volatile("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
10544
10545 get_flags(); /* Make sure it really did something */
10546 err = check_flags();
10547 @@ -218,9 +218,9 @@ int check_cpu(int *cpu_level_ptr, int *req_level_ptr, u32 **err_flags_ptr)
10548 u32 ecx = MSR_VIA_FCR;
10549 u32 eax, edx;
10550
10551 - asm("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
10552 + asm volatile("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
10553 eax |= (1<<1)|(1<<7);
10554 - asm("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
10555 + asm volatile("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
10556
10557 set_bit(X86_FEATURE_CX8, cpu.flags);
10558 err = check_flags();
10559 @@ -231,12 +231,12 @@ int check_cpu(int *cpu_level_ptr, int *req_level_ptr, u32 **err_flags_ptr)
10560 u32 eax, edx;
10561 u32 level = 1;
10562
10563 - asm("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
10564 - asm("wrmsr" : : "a" (~0), "d" (edx), "c" (ecx));
10565 - asm("cpuid"
10566 + asm volatile("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
10567 + asm volatile("wrmsr" : : "a" (~0), "d" (edx), "c" (ecx));
10568 + asm volatile("cpuid"
10569 : "+a" (level), "=d" (cpu.flags[0])
10570 : : "ecx", "ebx");
10571 - asm("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
10572 + asm volatile("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
10573
10574 err = check_flags();
10575 }
10576 diff --git a/arch/x86/boot/header.S b/arch/x86/boot/header.S
10577 index 944ce59..87ee37a 100644
10578 --- a/arch/x86/boot/header.S
10579 +++ b/arch/x86/boot/header.S
10580 @@ -401,10 +401,14 @@ setup_data: .quad 0 # 64-bit physical pointer to
10581 # single linked list of
10582 # struct setup_data
10583
10584 -pref_address: .quad LOAD_PHYSICAL_ADDR # preferred load addr
10585 +pref_address: .quad ____LOAD_PHYSICAL_ADDR # preferred load addr
10586
10587 #define ZO_INIT_SIZE (ZO__end - ZO_startup_32 + ZO_z_extract_offset)
10588 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
10589 +#define VO_INIT_SIZE (VO__end - VO__text - __PAGE_OFFSET - ____LOAD_PHYSICAL_ADDR)
10590 +#else
10591 #define VO_INIT_SIZE (VO__end - VO__text)
10592 +#endif
10593 #if ZO_INIT_SIZE > VO_INIT_SIZE
10594 #define INIT_SIZE ZO_INIT_SIZE
10595 #else
10596 diff --git a/arch/x86/boot/memory.c b/arch/x86/boot/memory.c
10597 index db75d07..8e6d0af 100644
10598 --- a/arch/x86/boot/memory.c
10599 +++ b/arch/x86/boot/memory.c
10600 @@ -19,7 +19,7 @@
10601
10602 static int detect_memory_e820(void)
10603 {
10604 - int count = 0;
10605 + unsigned int count = 0;
10606 struct biosregs ireg, oreg;
10607 struct e820entry *desc = boot_params.e820_map;
10608 static struct e820entry buf; /* static so it is zeroed */
10609 diff --git a/arch/x86/boot/video-vesa.c b/arch/x86/boot/video-vesa.c
10610 index 11e8c6e..fdbb1ed 100644
10611 --- a/arch/x86/boot/video-vesa.c
10612 +++ b/arch/x86/boot/video-vesa.c
10613 @@ -200,6 +200,7 @@ static void vesa_store_pm_info(void)
10614
10615 boot_params.screen_info.vesapm_seg = oreg.es;
10616 boot_params.screen_info.vesapm_off = oreg.di;
10617 + boot_params.screen_info.vesapm_size = oreg.cx;
10618 }
10619
10620 /*
10621 diff --git a/arch/x86/boot/video.c b/arch/x86/boot/video.c
10622 index 43eda28..5ab5fdb 100644
10623 --- a/arch/x86/boot/video.c
10624 +++ b/arch/x86/boot/video.c
10625 @@ -96,7 +96,7 @@ static void store_mode_params(void)
10626 static unsigned int get_entry(void)
10627 {
10628 char entry_buf[4];
10629 - int i, len = 0;
10630 + unsigned int i, len = 0;
10631 int key;
10632 unsigned int v;
10633
10634 diff --git a/arch/x86/crypto/aes-x86_64-asm_64.S b/arch/x86/crypto/aes-x86_64-asm_64.S
10635 index 5b577d5..3c1fed4 100644
10636 --- a/arch/x86/crypto/aes-x86_64-asm_64.S
10637 +++ b/arch/x86/crypto/aes-x86_64-asm_64.S
10638 @@ -8,6 +8,8 @@
10639 * including this sentence is retained in full.
10640 */
10641
10642 +#include <asm/alternative-asm.h>
10643 +
10644 .extern crypto_ft_tab
10645 .extern crypto_it_tab
10646 .extern crypto_fl_tab
10647 @@ -71,6 +73,8 @@ FUNC: movq r1,r2; \
10648 je B192; \
10649 leaq 32(r9),r9;
10650
10651 +#define ret pax_force_retaddr 0, 1; ret
10652 +
10653 #define epilogue(r1,r2,r3,r4,r5,r6,r7,r8,r9) \
10654 movq r1,r2; \
10655 movq r3,r4; \
10656 diff --git a/arch/x86/crypto/aesni-intel_asm.S b/arch/x86/crypto/aesni-intel_asm.S
10657 index 3470624..201259d 100644
10658 --- a/arch/x86/crypto/aesni-intel_asm.S
10659 +++ b/arch/x86/crypto/aesni-intel_asm.S
10660 @@ -31,6 +31,7 @@
10661
10662 #include <linux/linkage.h>
10663 #include <asm/inst.h>
10664 +#include <asm/alternative-asm.h>
10665
10666 #ifdef __x86_64__
10667 .data
10668 @@ -1436,7 +1437,9 @@ _return_T_done_decrypt:
10669 pop %r14
10670 pop %r13
10671 pop %r12
10672 + pax_force_retaddr 0, 1
10673 ret
10674 +ENDPROC(aesni_gcm_dec)
10675
10676
10677 /*****************************************************************************
10678 @@ -1699,7 +1702,9 @@ _return_T_done_encrypt:
10679 pop %r14
10680 pop %r13
10681 pop %r12
10682 + pax_force_retaddr 0, 1
10683 ret
10684 +ENDPROC(aesni_gcm_enc)
10685
10686 #endif
10687
10688 @@ -1714,6 +1719,7 @@ _key_expansion_256a:
10689 pxor %xmm1, %xmm0
10690 movaps %xmm0, (TKEYP)
10691 add $0x10, TKEYP
10692 + pax_force_retaddr_bts
10693 ret
10694
10695 .align 4
10696 @@ -1738,6 +1744,7 @@ _key_expansion_192a:
10697 shufps $0b01001110, %xmm2, %xmm1
10698 movaps %xmm1, 0x10(TKEYP)
10699 add $0x20, TKEYP
10700 + pax_force_retaddr_bts
10701 ret
10702
10703 .align 4
10704 @@ -1757,6 +1764,7 @@ _key_expansion_192b:
10705
10706 movaps %xmm0, (TKEYP)
10707 add $0x10, TKEYP
10708 + pax_force_retaddr_bts
10709 ret
10710
10711 .align 4
10712 @@ -1769,6 +1777,7 @@ _key_expansion_256b:
10713 pxor %xmm1, %xmm2
10714 movaps %xmm2, (TKEYP)
10715 add $0x10, TKEYP
10716 + pax_force_retaddr_bts
10717 ret
10718
10719 /*
10720 @@ -1881,7 +1890,9 @@ ENTRY(aesni_set_key)
10721 #ifndef __x86_64__
10722 popl KEYP
10723 #endif
10724 + pax_force_retaddr 0, 1
10725 ret
10726 +ENDPROC(aesni_set_key)
10727
10728 /*
10729 * void aesni_enc(struct crypto_aes_ctx *ctx, u8 *dst, const u8 *src)
10730 @@ -1902,7 +1913,9 @@ ENTRY(aesni_enc)
10731 popl KLEN
10732 popl KEYP
10733 #endif
10734 + pax_force_retaddr 0, 1
10735 ret
10736 +ENDPROC(aesni_enc)
10737
10738 /*
10739 * _aesni_enc1: internal ABI
10740 @@ -1959,6 +1972,7 @@ _aesni_enc1:
10741 AESENC KEY STATE
10742 movaps 0x70(TKEYP), KEY
10743 AESENCLAST KEY STATE
10744 + pax_force_retaddr_bts
10745 ret
10746
10747 /*
10748 @@ -2067,6 +2081,7 @@ _aesni_enc4:
10749 AESENCLAST KEY STATE2
10750 AESENCLAST KEY STATE3
10751 AESENCLAST KEY STATE4
10752 + pax_force_retaddr_bts
10753 ret
10754
10755 /*
10756 @@ -2089,7 +2104,9 @@ ENTRY(aesni_dec)
10757 popl KLEN
10758 popl KEYP
10759 #endif
10760 + pax_force_retaddr 0, 1
10761 ret
10762 +ENDPROC(aesni_dec)
10763
10764 /*
10765 * _aesni_dec1: internal ABI
10766 @@ -2146,6 +2163,7 @@ _aesni_dec1:
10767 AESDEC KEY STATE
10768 movaps 0x70(TKEYP), KEY
10769 AESDECLAST KEY STATE
10770 + pax_force_retaddr_bts
10771 ret
10772
10773 /*
10774 @@ -2254,6 +2272,7 @@ _aesni_dec4:
10775 AESDECLAST KEY STATE2
10776 AESDECLAST KEY STATE3
10777 AESDECLAST KEY STATE4
10778 + pax_force_retaddr_bts
10779 ret
10780
10781 /*
10782 @@ -2311,7 +2330,9 @@ ENTRY(aesni_ecb_enc)
10783 popl KEYP
10784 popl LEN
10785 #endif
10786 + pax_force_retaddr 0, 1
10787 ret
10788 +ENDPROC(aesni_ecb_enc)
10789
10790 /*
10791 * void aesni_ecb_dec(struct crypto_aes_ctx *ctx, const u8 *dst, u8 *src,
10792 @@ -2369,7 +2390,9 @@ ENTRY(aesni_ecb_dec)
10793 popl KEYP
10794 popl LEN
10795 #endif
10796 + pax_force_retaddr 0, 1
10797 ret
10798 +ENDPROC(aesni_ecb_dec)
10799
10800 /*
10801 * void aesni_cbc_enc(struct crypto_aes_ctx *ctx, const u8 *dst, u8 *src,
10802 @@ -2410,7 +2433,9 @@ ENTRY(aesni_cbc_enc)
10803 popl LEN
10804 popl IVP
10805 #endif
10806 + pax_force_retaddr 0, 1
10807 ret
10808 +ENDPROC(aesni_cbc_enc)
10809
10810 /*
10811 * void aesni_cbc_dec(struct crypto_aes_ctx *ctx, const u8 *dst, u8 *src,
10812 @@ -2500,7 +2525,9 @@ ENTRY(aesni_cbc_dec)
10813 popl LEN
10814 popl IVP
10815 #endif
10816 + pax_force_retaddr 0, 1
10817 ret
10818 +ENDPROC(aesni_cbc_dec)
10819
10820 #ifdef __x86_64__
10821 .align 16
10822 @@ -2526,6 +2553,7 @@ _aesni_inc_init:
10823 mov $1, TCTR_LOW
10824 MOVQ_R64_XMM TCTR_LOW INC
10825 MOVQ_R64_XMM CTR TCTR_LOW
10826 + pax_force_retaddr_bts
10827 ret
10828
10829 /*
10830 @@ -2554,6 +2582,7 @@ _aesni_inc:
10831 .Linc_low:
10832 movaps CTR, IV
10833 PSHUFB_XMM BSWAP_MASK IV
10834 + pax_force_retaddr_bts
10835 ret
10836
10837 /*
10838 @@ -2614,5 +2643,7 @@ ENTRY(aesni_ctr_enc)
10839 .Lctr_enc_ret:
10840 movups IV, (IVP)
10841 .Lctr_enc_just_ret:
10842 + pax_force_retaddr 0, 1
10843 ret
10844 +ENDPROC(aesni_ctr_enc)
10845 #endif
10846 diff --git a/arch/x86/crypto/blowfish-x86_64-asm_64.S b/arch/x86/crypto/blowfish-x86_64-asm_64.S
10847 index 391d245..67f35c2 100644
10848 --- a/arch/x86/crypto/blowfish-x86_64-asm_64.S
10849 +++ b/arch/x86/crypto/blowfish-x86_64-asm_64.S
10850 @@ -20,6 +20,8 @@
10851 *
10852 */
10853
10854 +#include <asm/alternative-asm.h>
10855 +
10856 .file "blowfish-x86_64-asm.S"
10857 .text
10858
10859 @@ -151,9 +153,11 @@ __blowfish_enc_blk:
10860 jnz __enc_xor;
10861
10862 write_block();
10863 + pax_force_retaddr 0, 1
10864 ret;
10865 __enc_xor:
10866 xor_block();
10867 + pax_force_retaddr 0, 1
10868 ret;
10869
10870 .align 8
10871 @@ -188,6 +192,7 @@ blowfish_dec_blk:
10872
10873 movq %r11, %rbp;
10874
10875 + pax_force_retaddr 0, 1
10876 ret;
10877
10878 /**********************************************************************
10879 @@ -342,6 +347,7 @@ __blowfish_enc_blk_4way:
10880
10881 popq %rbx;
10882 popq %rbp;
10883 + pax_force_retaddr 0, 1
10884 ret;
10885
10886 __enc_xor4:
10887 @@ -349,6 +355,7 @@ __enc_xor4:
10888
10889 popq %rbx;
10890 popq %rbp;
10891 + pax_force_retaddr 0, 1
10892 ret;
10893
10894 .align 8
10895 @@ -386,5 +393,6 @@ blowfish_dec_blk_4way:
10896 popq %rbx;
10897 popq %rbp;
10898
10899 + pax_force_retaddr 0, 1
10900 ret;
10901
10902 diff --git a/arch/x86/crypto/camellia-x86_64-asm_64.S b/arch/x86/crypto/camellia-x86_64-asm_64.S
10903 index 0b33743..7a56206 100644
10904 --- a/arch/x86/crypto/camellia-x86_64-asm_64.S
10905 +++ b/arch/x86/crypto/camellia-x86_64-asm_64.S
10906 @@ -20,6 +20,8 @@
10907 *
10908 */
10909
10910 +#include <asm/alternative-asm.h>
10911 +
10912 .file "camellia-x86_64-asm_64.S"
10913 .text
10914
10915 @@ -229,12 +231,14 @@ __enc_done:
10916 enc_outunpack(mov, RT1);
10917
10918 movq RRBP, %rbp;
10919 + pax_force_retaddr 0, 1
10920 ret;
10921
10922 __enc_xor:
10923 enc_outunpack(xor, RT1);
10924
10925 movq RRBP, %rbp;
10926 + pax_force_retaddr 0, 1
10927 ret;
10928
10929 .global camellia_dec_blk;
10930 @@ -275,6 +279,7 @@ __dec_rounds16:
10931 dec_outunpack();
10932
10933 movq RRBP, %rbp;
10934 + pax_force_retaddr 0, 1
10935 ret;
10936
10937 /**********************************************************************
10938 @@ -468,6 +473,7 @@ __enc2_done:
10939
10940 movq RRBP, %rbp;
10941 popq %rbx;
10942 + pax_force_retaddr 0, 1
10943 ret;
10944
10945 __enc2_xor:
10946 @@ -475,6 +481,7 @@ __enc2_xor:
10947
10948 movq RRBP, %rbp;
10949 popq %rbx;
10950 + pax_force_retaddr 0, 1
10951 ret;
10952
10953 .global camellia_dec_blk_2way;
10954 @@ -517,4 +524,5 @@ __dec2_rounds16:
10955
10956 movq RRBP, %rbp;
10957 movq RXOR, %rbx;
10958 + pax_force_retaddr 0, 1
10959 ret;
10960 diff --git a/arch/x86/crypto/cast5-avx-x86_64-asm_64.S b/arch/x86/crypto/cast5-avx-x86_64-asm_64.S
10961 index 15b00ac..2071784 100644
10962 --- a/arch/x86/crypto/cast5-avx-x86_64-asm_64.S
10963 +++ b/arch/x86/crypto/cast5-avx-x86_64-asm_64.S
10964 @@ -23,6 +23,8 @@
10965 *
10966 */
10967
10968 +#include <asm/alternative-asm.h>
10969 +
10970 .file "cast5-avx-x86_64-asm_64.S"
10971
10972 .extern cast_s1
10973 @@ -281,6 +283,7 @@ __skip_enc:
10974 outunpack_blocks(RR3, RL3, RTMP, RX, RKM);
10975 outunpack_blocks(RR4, RL4, RTMP, RX, RKM);
10976
10977 + pax_force_retaddr 0, 1
10978 ret;
10979
10980 .align 16
10981 @@ -353,6 +356,7 @@ __dec_tail:
10982 outunpack_blocks(RR3, RL3, RTMP, RX, RKM);
10983 outunpack_blocks(RR4, RL4, RTMP, RX, RKM);
10984
10985 + pax_force_retaddr 0, 1
10986 ret;
10987
10988 __skip_dec:
10989 @@ -392,6 +396,7 @@ cast5_ecb_enc_16way:
10990 vmovdqu RR4, (6*4*4)(%r11);
10991 vmovdqu RL4, (7*4*4)(%r11);
10992
10993 + pax_force_retaddr
10994 ret;
10995
10996 .align 16
10997 @@ -427,6 +432,7 @@ cast5_ecb_dec_16way:
10998 vmovdqu RR4, (6*4*4)(%r11);
10999 vmovdqu RL4, (7*4*4)(%r11);
11000
11001 + pax_force_retaddr
11002 ret;
11003
11004 .align 16
11005 @@ -479,6 +485,7 @@ cast5_cbc_dec_16way:
11006
11007 popq %r12;
11008
11009 + pax_force_retaddr
11010 ret;
11011
11012 .align 16
11013 @@ -555,4 +562,5 @@ cast5_ctr_16way:
11014
11015 popq %r12;
11016
11017 + pax_force_retaddr
11018 ret;
11019 diff --git a/arch/x86/crypto/cast6-avx-x86_64-asm_64.S b/arch/x86/crypto/cast6-avx-x86_64-asm_64.S
11020 index 2569d0d..637c289 100644
11021 --- a/arch/x86/crypto/cast6-avx-x86_64-asm_64.S
11022 +++ b/arch/x86/crypto/cast6-avx-x86_64-asm_64.S
11023 @@ -23,6 +23,8 @@
11024 *
11025 */
11026
11027 +#include <asm/alternative-asm.h>
11028 +
11029 #include "glue_helper-asm-avx.S"
11030
11031 .file "cast6-avx-x86_64-asm_64.S"
11032 @@ -294,6 +296,7 @@ __cast6_enc_blk8:
11033 outunpack_blocks(RA1, RB1, RC1, RD1, RTMP, RX, RKRF, RKM);
11034 outunpack_blocks(RA2, RB2, RC2, RD2, RTMP, RX, RKRF, RKM);
11035
11036 + pax_force_retaddr 0, 1
11037 ret;
11038
11039 .align 8
11040 @@ -340,6 +343,7 @@ __cast6_dec_blk8:
11041 outunpack_blocks(RA1, RB1, RC1, RD1, RTMP, RX, RKRF, RKM);
11042 outunpack_blocks(RA2, RB2, RC2, RD2, RTMP, RX, RKRF, RKM);
11043
11044 + pax_force_retaddr 0, 1
11045 ret;
11046
11047 .align 8
11048 @@ -361,6 +365,7 @@ cast6_ecb_enc_8way:
11049
11050 store_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
11051
11052 + pax_force_retaddr
11053 ret;
11054
11055 .align 8
11056 @@ -382,6 +387,7 @@ cast6_ecb_dec_8way:
11057
11058 store_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
11059
11060 + pax_force_retaddr
11061 ret;
11062
11063 .align 8
11064 @@ -408,6 +414,7 @@ cast6_cbc_dec_8way:
11065
11066 popq %r12;
11067
11068 + pax_force_retaddr
11069 ret;
11070
11071 .align 8
11072 @@ -436,4 +443,5 @@ cast6_ctr_8way:
11073
11074 popq %r12;
11075
11076 + pax_force_retaddr
11077 ret;
11078 diff --git a/arch/x86/crypto/salsa20-x86_64-asm_64.S b/arch/x86/crypto/salsa20-x86_64-asm_64.S
11079 index 6214a9b..1f4fc9a 100644
11080 --- a/arch/x86/crypto/salsa20-x86_64-asm_64.S
11081 +++ b/arch/x86/crypto/salsa20-x86_64-asm_64.S
11082 @@ -1,3 +1,5 @@
11083 +#include <asm/alternative-asm.h>
11084 +
11085 # enter ECRYPT_encrypt_bytes
11086 .text
11087 .p2align 5
11088 @@ -790,6 +792,7 @@ ECRYPT_encrypt_bytes:
11089 add %r11,%rsp
11090 mov %rdi,%rax
11091 mov %rsi,%rdx
11092 + pax_force_retaddr 0, 1
11093 ret
11094 # bytesatleast65:
11095 ._bytesatleast65:
11096 @@ -891,6 +894,7 @@ ECRYPT_keysetup:
11097 add %r11,%rsp
11098 mov %rdi,%rax
11099 mov %rsi,%rdx
11100 + pax_force_retaddr
11101 ret
11102 # enter ECRYPT_ivsetup
11103 .text
11104 @@ -917,4 +921,5 @@ ECRYPT_ivsetup:
11105 add %r11,%rsp
11106 mov %rdi,%rax
11107 mov %rsi,%rdx
11108 + pax_force_retaddr
11109 ret
11110 diff --git a/arch/x86/crypto/serpent-avx-x86_64-asm_64.S b/arch/x86/crypto/serpent-avx-x86_64-asm_64.S
11111 index 02b0e9f..cf4cf5c 100644
11112 --- a/arch/x86/crypto/serpent-avx-x86_64-asm_64.S
11113 +++ b/arch/x86/crypto/serpent-avx-x86_64-asm_64.S
11114 @@ -24,6 +24,8 @@
11115 *
11116 */
11117
11118 +#include <asm/alternative-asm.h>
11119 +
11120 #include "glue_helper-asm-avx.S"
11121
11122 .file "serpent-avx-x86_64-asm_64.S"
11123 @@ -618,6 +620,7 @@ __serpent_enc_blk8_avx:
11124 write_blocks(RA1, RB1, RC1, RD1, RK0, RK1, RK2);
11125 write_blocks(RA2, RB2, RC2, RD2, RK0, RK1, RK2);
11126
11127 + pax_force_retaddr
11128 ret;
11129
11130 .align 8
11131 @@ -673,6 +676,7 @@ __serpent_dec_blk8_avx:
11132 write_blocks(RC1, RD1, RB1, RE1, RK0, RK1, RK2);
11133 write_blocks(RC2, RD2, RB2, RE2, RK0, RK1, RK2);
11134
11135 + pax_force_retaddr
11136 ret;
11137
11138 .align 8
11139 @@ -692,6 +696,7 @@ serpent_ecb_enc_8way_avx:
11140
11141 store_8way(%rsi, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
11142
11143 + pax_force_retaddr
11144 ret;
11145
11146 .align 8
11147 @@ -711,6 +716,7 @@ serpent_ecb_dec_8way_avx:
11148
11149 store_8way(%rsi, RC1, RD1, RB1, RE1, RC2, RD2, RB2, RE2);
11150
11151 + pax_force_retaddr
11152 ret;
11153
11154 .align 8
11155 @@ -730,6 +736,7 @@ serpent_cbc_dec_8way_avx:
11156
11157 store_cbc_8way(%rdx, %rsi, RC1, RD1, RB1, RE1, RC2, RD2, RB2, RE2);
11158
11159 + pax_force_retaddr
11160 ret;
11161
11162 .align 8
11163 @@ -751,4 +758,5 @@ serpent_ctr_8way_avx:
11164
11165 store_ctr_8way(%rdx, %rsi, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
11166
11167 + pax_force_retaddr
11168 ret;
11169 diff --git a/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S b/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S
11170 index 3ee1ff0..cbc568b 100644
11171 --- a/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S
11172 +++ b/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S
11173 @@ -24,6 +24,8 @@
11174 *
11175 */
11176
11177 +#include <asm/alternative-asm.h>
11178 +
11179 .file "serpent-sse2-x86_64-asm_64.S"
11180 .text
11181
11182 @@ -692,12 +694,14 @@ __serpent_enc_blk_8way:
11183 write_blocks(%rsi, RA1, RB1, RC1, RD1, RK0, RK1, RK2);
11184 write_blocks(%rax, RA2, RB2, RC2, RD2, RK0, RK1, RK2);
11185
11186 + pax_force_retaddr
11187 ret;
11188
11189 __enc_xor8:
11190 xor_blocks(%rsi, RA1, RB1, RC1, RD1, RK0, RK1, RK2);
11191 xor_blocks(%rax, RA2, RB2, RC2, RD2, RK0, RK1, RK2);
11192
11193 + pax_force_retaddr
11194 ret;
11195
11196 .align 8
11197 @@ -755,4 +759,5 @@ serpent_dec_blk_8way:
11198 write_blocks(%rsi, RC1, RD1, RB1, RE1, RK0, RK1, RK2);
11199 write_blocks(%rax, RC2, RD2, RB2, RE2, RK0, RK1, RK2);
11200
11201 + pax_force_retaddr
11202 ret;
11203 diff --git a/arch/x86/crypto/sha1_ssse3_asm.S b/arch/x86/crypto/sha1_ssse3_asm.S
11204 index 49d6987..df66bd4 100644
11205 --- a/arch/x86/crypto/sha1_ssse3_asm.S
11206 +++ b/arch/x86/crypto/sha1_ssse3_asm.S
11207 @@ -28,6 +28,8 @@
11208 * (at your option) any later version.
11209 */
11210
11211 +#include <asm/alternative-asm.h>
11212 +
11213 #define CTX %rdi // arg1
11214 #define BUF %rsi // arg2
11215 #define CNT %rdx // arg3
11216 @@ -104,6 +106,7 @@
11217 pop %r12
11218 pop %rbp
11219 pop %rbx
11220 + pax_force_retaddr 0, 1
11221 ret
11222
11223 .size \name, .-\name
11224 diff --git a/arch/x86/crypto/twofish-avx-x86_64-asm_64.S b/arch/x86/crypto/twofish-avx-x86_64-asm_64.S
11225 index ebac16b..8092eb9 100644
11226 --- a/arch/x86/crypto/twofish-avx-x86_64-asm_64.S
11227 +++ b/arch/x86/crypto/twofish-avx-x86_64-asm_64.S
11228 @@ -23,6 +23,8 @@
11229 *
11230 */
11231
11232 +#include <asm/alternative-asm.h>
11233 +
11234 #include "glue_helper-asm-avx.S"
11235
11236 .file "twofish-avx-x86_64-asm_64.S"
11237 @@ -283,6 +285,7 @@ __twofish_enc_blk8:
11238 outunpack_blocks(RC1, RD1, RA1, RB1, RK1, RX0, RY0, RK2);
11239 outunpack_blocks(RC2, RD2, RA2, RB2, RK1, RX0, RY0, RK2);
11240
11241 + pax_force_retaddr 0, 1
11242 ret;
11243
11244 .align 8
11245 @@ -324,6 +327,7 @@ __twofish_dec_blk8:
11246 outunpack_blocks(RA1, RB1, RC1, RD1, RK1, RX0, RY0, RK2);
11247 outunpack_blocks(RA2, RB2, RC2, RD2, RK1, RX0, RY0, RK2);
11248
11249 + pax_force_retaddr 0, 1
11250 ret;
11251
11252 .align 8
11253 @@ -345,6 +349,7 @@ twofish_ecb_enc_8way:
11254
11255 store_8way(%r11, RC1, RD1, RA1, RB1, RC2, RD2, RA2, RB2);
11256
11257 + pax_force_retaddr 0, 1
11258 ret;
11259
11260 .align 8
11261 @@ -366,6 +371,7 @@ twofish_ecb_dec_8way:
11262
11263 store_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
11264
11265 + pax_force_retaddr 0, 1
11266 ret;
11267
11268 .align 8
11269 @@ -392,6 +398,7 @@ twofish_cbc_dec_8way:
11270
11271 popq %r12;
11272
11273 + pax_force_retaddr 0, 1
11274 ret;
11275
11276 .align 8
11277 @@ -420,4 +427,5 @@ twofish_ctr_8way:
11278
11279 popq %r12;
11280
11281 + pax_force_retaddr 0, 1
11282 ret;
11283 diff --git a/arch/x86/crypto/twofish-x86_64-asm_64-3way.S b/arch/x86/crypto/twofish-x86_64-asm_64-3way.S
11284 index 5b012a2..36d5364 100644
11285 --- a/arch/x86/crypto/twofish-x86_64-asm_64-3way.S
11286 +++ b/arch/x86/crypto/twofish-x86_64-asm_64-3way.S
11287 @@ -20,6 +20,8 @@
11288 *
11289 */
11290
11291 +#include <asm/alternative-asm.h>
11292 +
11293 .file "twofish-x86_64-asm-3way.S"
11294 .text
11295
11296 @@ -260,6 +262,7 @@ __twofish_enc_blk_3way:
11297 popq %r13;
11298 popq %r14;
11299 popq %r15;
11300 + pax_force_retaddr 0, 1
11301 ret;
11302
11303 __enc_xor3:
11304 @@ -271,6 +274,7 @@ __enc_xor3:
11305 popq %r13;
11306 popq %r14;
11307 popq %r15;
11308 + pax_force_retaddr 0, 1
11309 ret;
11310
11311 .global twofish_dec_blk_3way
11312 @@ -312,5 +316,6 @@ twofish_dec_blk_3way:
11313 popq %r13;
11314 popq %r14;
11315 popq %r15;
11316 + pax_force_retaddr 0, 1
11317 ret;
11318
11319 diff --git a/arch/x86/crypto/twofish-x86_64-asm_64.S b/arch/x86/crypto/twofish-x86_64-asm_64.S
11320 index 7bcf3fc..f53832f 100644
11321 --- a/arch/x86/crypto/twofish-x86_64-asm_64.S
11322 +++ b/arch/x86/crypto/twofish-x86_64-asm_64.S
11323 @@ -21,6 +21,7 @@
11324 .text
11325
11326 #include <asm/asm-offsets.h>
11327 +#include <asm/alternative-asm.h>
11328
11329 #define a_offset 0
11330 #define b_offset 4
11331 @@ -268,6 +269,7 @@ twofish_enc_blk:
11332
11333 popq R1
11334 movq $1,%rax
11335 + pax_force_retaddr 0, 1
11336 ret
11337
11338 twofish_dec_blk:
11339 @@ -319,4 +321,5 @@ twofish_dec_blk:
11340
11341 popq R1
11342 movq $1,%rax
11343 + pax_force_retaddr 0, 1
11344 ret
11345 diff --git a/arch/x86/ia32/ia32_aout.c b/arch/x86/ia32/ia32_aout.c
11346 index a703af1..f5b9c36 100644
11347 --- a/arch/x86/ia32/ia32_aout.c
11348 +++ b/arch/x86/ia32/ia32_aout.c
11349 @@ -159,6 +159,8 @@ static int aout_core_dump(long signr, struct pt_regs *regs, struct file *file,
11350 unsigned long dump_start, dump_size;
11351 struct user32 dump;
11352
11353 + memset(&dump, 0, sizeof(dump));
11354 +
11355 fs = get_fs();
11356 set_fs(KERNEL_DS);
11357 has_dumped = 1;
11358 diff --git a/arch/x86/ia32/ia32_signal.c b/arch/x86/ia32/ia32_signal.c
11359 index a1daf4a..f8c4537 100644
11360 --- a/arch/x86/ia32/ia32_signal.c
11361 +++ b/arch/x86/ia32/ia32_signal.c
11362 @@ -348,7 +348,7 @@ static void __user *get_sigframe(struct k_sigaction *ka, struct pt_regs *regs,
11363 sp -= frame_size;
11364 /* Align the stack pointer according to the i386 ABI,
11365 * i.e. so that on function entry ((sp + 4) & 15) == 0. */
11366 - sp = ((sp + 4) & -16ul) - 4;
11367 + sp = ((sp - 12) & -16ul) - 4;
11368 return (void __user *) sp;
11369 }
11370
11371 @@ -406,7 +406,7 @@ int ia32_setup_frame(int sig, struct k_sigaction *ka,
11372 * These are actually not used anymore, but left because some
11373 * gdb versions depend on them as a marker.
11374 */
11375 - put_user_ex(*((u64 *)&code), (u64 __user *)frame->retcode);
11376 + put_user_ex(*((const u64 *)&code), (u64 __user *)frame->retcode);
11377 } put_user_catch(err);
11378
11379 if (err)
11380 @@ -448,7 +448,7 @@ int ia32_setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
11381 0xb8,
11382 __NR_ia32_rt_sigreturn,
11383 0x80cd,
11384 - 0,
11385 + 0
11386 };
11387
11388 frame = get_sigframe(ka, regs, sizeof(*frame), &fpstate);
11389 @@ -471,16 +471,18 @@ int ia32_setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
11390
11391 if (ka->sa.sa_flags & SA_RESTORER)
11392 restorer = ka->sa.sa_restorer;
11393 + else if (current->mm->context.vdso)
11394 + /* Return stub is in 32bit vsyscall page */
11395 + restorer = VDSO32_SYMBOL(current->mm->context.vdso, rt_sigreturn);
11396 else
11397 - restorer = VDSO32_SYMBOL(current->mm->context.vdso,
11398 - rt_sigreturn);
11399 + restorer = &frame->retcode;
11400 put_user_ex(ptr_to_compat(restorer), &frame->pretcode);
11401
11402 /*
11403 * Not actually used anymore, but left because some gdb
11404 * versions need it.
11405 */
11406 - put_user_ex(*((u64 *)&code), (u64 __user *)frame->retcode);
11407 + put_user_ex(*((const u64 *)&code), (u64 __user *)frame->retcode);
11408 } put_user_catch(err);
11409
11410 err |= copy_siginfo_to_user32(&frame->info, info);
11411 diff --git a/arch/x86/ia32/ia32entry.S b/arch/x86/ia32/ia32entry.S
11412 index 142c4ce..19b683f 100644
11413 --- a/arch/x86/ia32/ia32entry.S
11414 +++ b/arch/x86/ia32/ia32entry.S
11415 @@ -15,8 +15,10 @@
11416 #include <asm/irqflags.h>
11417 #include <asm/asm.h>
11418 #include <asm/smap.h>
11419 +#include <asm/pgtable.h>
11420 #include <linux/linkage.h>
11421 #include <linux/err.h>
11422 +#include <asm/alternative-asm.h>
11423
11424 /* Avoid __ASSEMBLER__'ifying <linux/audit.h> just for this. */
11425 #include <linux/elf-em.h>
11426 @@ -96,6 +98,32 @@ ENTRY(native_irq_enable_sysexit)
11427 ENDPROC(native_irq_enable_sysexit)
11428 #endif
11429
11430 + .macro pax_enter_kernel_user
11431 + pax_set_fptr_mask
11432 +#ifdef CONFIG_PAX_MEMORY_UDEREF
11433 + call pax_enter_kernel_user
11434 +#endif
11435 + .endm
11436 +
11437 + .macro pax_exit_kernel_user
11438 +#ifdef CONFIG_PAX_MEMORY_UDEREF
11439 + call pax_exit_kernel_user
11440 +#endif
11441 +#ifdef CONFIG_PAX_RANDKSTACK
11442 + pushq %rax
11443 + pushq %r11
11444 + call pax_randomize_kstack
11445 + popq %r11
11446 + popq %rax
11447 +#endif
11448 + .endm
11449 +
11450 +.macro pax_erase_kstack
11451 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
11452 + call pax_erase_kstack
11453 +#endif
11454 +.endm
11455 +
11456 /*
11457 * 32bit SYSENTER instruction entry.
11458 *
11459 @@ -122,12 +150,6 @@ ENTRY(ia32_sysenter_target)
11460 CFI_REGISTER rsp,rbp
11461 SWAPGS_UNSAFE_STACK
11462 movq PER_CPU_VAR(kernel_stack), %rsp
11463 - addq $(KERNEL_STACK_OFFSET),%rsp
11464 - /*
11465 - * No need to follow this irqs on/off section: the syscall
11466 - * disabled irqs, here we enable it straight after entry:
11467 - */
11468 - ENABLE_INTERRUPTS(CLBR_NONE)
11469 movl %ebp,%ebp /* zero extension */
11470 pushq_cfi $__USER32_DS
11471 /*CFI_REL_OFFSET ss,0*/
11472 @@ -135,24 +157,44 @@ ENTRY(ia32_sysenter_target)
11473 CFI_REL_OFFSET rsp,0
11474 pushfq_cfi
11475 /*CFI_REL_OFFSET rflags,0*/
11476 - movl TI_sysenter_return+THREAD_INFO(%rsp,3*8-KERNEL_STACK_OFFSET),%r10d
11477 - CFI_REGISTER rip,r10
11478 + orl $X86_EFLAGS_IF,(%rsp)
11479 + GET_THREAD_INFO(%r11)
11480 + movl TI_sysenter_return(%r11), %r11d
11481 + CFI_REGISTER rip,r11
11482 pushq_cfi $__USER32_CS
11483 /*CFI_REL_OFFSET cs,0*/
11484 movl %eax, %eax
11485 - pushq_cfi %r10
11486 + pushq_cfi %r11
11487 CFI_REL_OFFSET rip,0
11488 pushq_cfi %rax
11489 cld
11490 SAVE_ARGS 0,1,0
11491 + pax_enter_kernel_user
11492 +
11493 +#ifdef CONFIG_PAX_RANDKSTACK
11494 + pax_erase_kstack
11495 +#endif
11496 +
11497 + /*
11498 + * No need to follow this irqs on/off section: the syscall
11499 + * disabled irqs, here we enable it straight after entry:
11500 + */
11501 + ENABLE_INTERRUPTS(CLBR_NONE)
11502 /* no need to do an access_ok check here because rbp has been
11503 32bit zero extended */
11504 +
11505 +#ifdef CONFIG_PAX_MEMORY_UDEREF
11506 + mov $PAX_USER_SHADOW_BASE,%r11
11507 + add %r11,%rbp
11508 +#endif
11509 +
11510 ASM_STAC
11511 1: movl (%rbp),%ebp
11512 _ASM_EXTABLE(1b,ia32_badarg)
11513 ASM_CLAC
11514 - orl $TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11515 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11516 + GET_THREAD_INFO(%r11)
11517 + orl $TS_COMPAT,TI_status(%r11)
11518 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%r11)
11519 CFI_REMEMBER_STATE
11520 jnz sysenter_tracesys
11521 cmpq $(IA32_NR_syscalls-1),%rax
11522 @@ -162,12 +204,15 @@ sysenter_do_call:
11523 sysenter_dispatch:
11524 call *ia32_sys_call_table(,%rax,8)
11525 movq %rax,RAX-ARGOFFSET(%rsp)
11526 + GET_THREAD_INFO(%r11)
11527 DISABLE_INTERRUPTS(CLBR_NONE)
11528 TRACE_IRQS_OFF
11529 - testl $_TIF_ALLWORK_MASK,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11530 + testl $_TIF_ALLWORK_MASK,TI_flags(%r11)
11531 jnz sysexit_audit
11532 sysexit_from_sys_call:
11533 - andl $~TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11534 + pax_exit_kernel_user
11535 + pax_erase_kstack
11536 + andl $~TS_COMPAT,TI_status(%r11)
11537 /* clear IF, that popfq doesn't enable interrupts early */
11538 andl $~0x200,EFLAGS-R11(%rsp)
11539 movl RIP-R11(%rsp),%edx /* User %eip */
11540 @@ -193,6 +238,9 @@ sysexit_from_sys_call:
11541 movl %eax,%esi /* 2nd arg: syscall number */
11542 movl $AUDIT_ARCH_I386,%edi /* 1st arg: audit arch */
11543 call __audit_syscall_entry
11544 +
11545 + pax_erase_kstack
11546 +
11547 movl RAX-ARGOFFSET(%rsp),%eax /* reload syscall number */
11548 cmpq $(IA32_NR_syscalls-1),%rax
11549 ja ia32_badsys
11550 @@ -204,7 +252,7 @@ sysexit_from_sys_call:
11551 .endm
11552
11553 .macro auditsys_exit exit
11554 - testl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11555 + testl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT),TI_flags(%r11)
11556 jnz ia32_ret_from_sys_call
11557 TRACE_IRQS_ON
11558 ENABLE_INTERRUPTS(CLBR_NONE)
11559 @@ -215,11 +263,12 @@ sysexit_from_sys_call:
11560 1: setbe %al /* 1 if error, 0 if not */
11561 movzbl %al,%edi /* zero-extend that into %edi */
11562 call __audit_syscall_exit
11563 + GET_THREAD_INFO(%r11)
11564 movq RAX-ARGOFFSET(%rsp),%rax /* reload syscall return value */
11565 movl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT),%edi
11566 DISABLE_INTERRUPTS(CLBR_NONE)
11567 TRACE_IRQS_OFF
11568 - testl %edi,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11569 + testl %edi,TI_flags(%r11)
11570 jz \exit
11571 CLEAR_RREGS -ARGOFFSET
11572 jmp int_with_check
11573 @@ -237,7 +286,7 @@ sysexit_audit:
11574
11575 sysenter_tracesys:
11576 #ifdef CONFIG_AUDITSYSCALL
11577 - testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11578 + testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags(%r11)
11579 jz sysenter_auditsys
11580 #endif
11581 SAVE_REST
11582 @@ -249,6 +298,9 @@ sysenter_tracesys:
11583 RESTORE_REST
11584 cmpq $(IA32_NR_syscalls-1),%rax
11585 ja int_ret_from_sys_call /* sysenter_tracesys has set RAX(%rsp) */
11586 +
11587 + pax_erase_kstack
11588 +
11589 jmp sysenter_do_call
11590 CFI_ENDPROC
11591 ENDPROC(ia32_sysenter_target)
11592 @@ -276,19 +328,25 @@ ENDPROC(ia32_sysenter_target)
11593 ENTRY(ia32_cstar_target)
11594 CFI_STARTPROC32 simple
11595 CFI_SIGNAL_FRAME
11596 - CFI_DEF_CFA rsp,KERNEL_STACK_OFFSET
11597 + CFI_DEF_CFA rsp,0
11598 CFI_REGISTER rip,rcx
11599 /*CFI_REGISTER rflags,r11*/
11600 SWAPGS_UNSAFE_STACK
11601 movl %esp,%r8d
11602 CFI_REGISTER rsp,r8
11603 movq PER_CPU_VAR(kernel_stack),%rsp
11604 + SAVE_ARGS 8*6,0,0
11605 + pax_enter_kernel_user
11606 +
11607 +#ifdef CONFIG_PAX_RANDKSTACK
11608 + pax_erase_kstack
11609 +#endif
11610 +
11611 /*
11612 * No need to follow this irqs on/off section: the syscall
11613 * disabled irqs and here we enable it straight after entry:
11614 */
11615 ENABLE_INTERRUPTS(CLBR_NONE)
11616 - SAVE_ARGS 8,0,0
11617 movl %eax,%eax /* zero extension */
11618 movq %rax,ORIG_RAX-ARGOFFSET(%rsp)
11619 movq %rcx,RIP-ARGOFFSET(%rsp)
11620 @@ -304,12 +362,19 @@ ENTRY(ia32_cstar_target)
11621 /* no need to do an access_ok check here because r8 has been
11622 32bit zero extended */
11623 /* hardware stack frame is complete now */
11624 +
11625 +#ifdef CONFIG_PAX_MEMORY_UDEREF
11626 + mov $PAX_USER_SHADOW_BASE,%r11
11627 + add %r11,%r8
11628 +#endif
11629 +
11630 ASM_STAC
11631 1: movl (%r8),%r9d
11632 _ASM_EXTABLE(1b,ia32_badarg)
11633 ASM_CLAC
11634 - orl $TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11635 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11636 + GET_THREAD_INFO(%r11)
11637 + orl $TS_COMPAT,TI_status(%r11)
11638 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%r11)
11639 CFI_REMEMBER_STATE
11640 jnz cstar_tracesys
11641 cmpq $IA32_NR_syscalls-1,%rax
11642 @@ -319,12 +384,15 @@ cstar_do_call:
11643 cstar_dispatch:
11644 call *ia32_sys_call_table(,%rax,8)
11645 movq %rax,RAX-ARGOFFSET(%rsp)
11646 + GET_THREAD_INFO(%r11)
11647 DISABLE_INTERRUPTS(CLBR_NONE)
11648 TRACE_IRQS_OFF
11649 - testl $_TIF_ALLWORK_MASK,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11650 + testl $_TIF_ALLWORK_MASK,TI_flags(%r11)
11651 jnz sysretl_audit
11652 sysretl_from_sys_call:
11653 - andl $~TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11654 + pax_exit_kernel_user
11655 + pax_erase_kstack
11656 + andl $~TS_COMPAT,TI_status(%r11)
11657 RESTORE_ARGS 0,-ARG_SKIP,0,0,0
11658 movl RIP-ARGOFFSET(%rsp),%ecx
11659 CFI_REGISTER rip,rcx
11660 @@ -352,7 +420,7 @@ sysretl_audit:
11661
11662 cstar_tracesys:
11663 #ifdef CONFIG_AUDITSYSCALL
11664 - testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11665 + testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags(%r11)
11666 jz cstar_auditsys
11667 #endif
11668 xchgl %r9d,%ebp
11669 @@ -366,6 +434,9 @@ cstar_tracesys:
11670 xchgl %ebp,%r9d
11671 cmpq $(IA32_NR_syscalls-1),%rax
11672 ja int_ret_from_sys_call /* cstar_tracesys has set RAX(%rsp) */
11673 +
11674 + pax_erase_kstack
11675 +
11676 jmp cstar_do_call
11677 END(ia32_cstar_target)
11678
11679 @@ -407,19 +478,26 @@ ENTRY(ia32_syscall)
11680 CFI_REL_OFFSET rip,RIP-RIP
11681 PARAVIRT_ADJUST_EXCEPTION_FRAME
11682 SWAPGS
11683 - /*
11684 - * No need to follow this irqs on/off section: the syscall
11685 - * disabled irqs and here we enable it straight after entry:
11686 - */
11687 - ENABLE_INTERRUPTS(CLBR_NONE)
11688 movl %eax,%eax
11689 pushq_cfi %rax
11690 cld
11691 /* note the registers are not zero extended to the sf.
11692 this could be a problem. */
11693 SAVE_ARGS 0,1,0
11694 - orl $TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11695 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11696 + pax_enter_kernel_user
11697 +
11698 +#ifdef CONFIG_PAX_RANDKSTACK
11699 + pax_erase_kstack
11700 +#endif
11701 +
11702 + /*
11703 + * No need to follow this irqs on/off section: the syscall
11704 + * disabled irqs and here we enable it straight after entry:
11705 + */
11706 + ENABLE_INTERRUPTS(CLBR_NONE)
11707 + GET_THREAD_INFO(%r11)
11708 + orl $TS_COMPAT,TI_status(%r11)
11709 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%r11)
11710 jnz ia32_tracesys
11711 cmpq $(IA32_NR_syscalls-1),%rax
11712 ja ia32_badsys
11713 @@ -442,6 +520,9 @@ ia32_tracesys:
11714 RESTORE_REST
11715 cmpq $(IA32_NR_syscalls-1),%rax
11716 ja int_ret_from_sys_call /* ia32_tracesys has set RAX(%rsp) */
11717 +
11718 + pax_erase_kstack
11719 +
11720 jmp ia32_do_call
11721 END(ia32_syscall)
11722
11723 diff --git a/arch/x86/ia32/sys_ia32.c b/arch/x86/ia32/sys_ia32.c
11724 index d0b689b..34be51d 100644
11725 --- a/arch/x86/ia32/sys_ia32.c
11726 +++ b/arch/x86/ia32/sys_ia32.c
11727 @@ -69,8 +69,8 @@ asmlinkage long sys32_ftruncate64(unsigned int fd, unsigned long offset_low,
11728 */
11729 static int cp_stat64(struct stat64 __user *ubuf, struct kstat *stat)
11730 {
11731 - typeof(ubuf->st_uid) uid = 0;
11732 - typeof(ubuf->st_gid) gid = 0;
11733 + typeof(((struct stat64 *)0)->st_uid) uid = 0;
11734 + typeof(((struct stat64 *)0)->st_gid) gid = 0;
11735 SET_UID(uid, from_kuid_munged(current_user_ns(), stat->uid));
11736 SET_GID(gid, from_kgid_munged(current_user_ns(), stat->gid));
11737 if (!access_ok(VERIFY_WRITE, ubuf, sizeof(struct stat64)) ||
11738 @@ -303,7 +303,7 @@ asmlinkage long sys32_sched_rr_get_interval(compat_pid_t pid,
11739 mm_segment_t old_fs = get_fs();
11740
11741 set_fs(KERNEL_DS);
11742 - ret = sys_sched_rr_get_interval(pid, (struct timespec __user *)&t);
11743 + ret = sys_sched_rr_get_interval(pid, (struct timespec __force_user *)&t);
11744 set_fs(old_fs);
11745 if (put_compat_timespec(&t, interval))
11746 return -EFAULT;
11747 @@ -319,7 +319,7 @@ asmlinkage long sys32_rt_sigpending(compat_sigset_t __user *set,
11748 mm_segment_t old_fs = get_fs();
11749
11750 set_fs(KERNEL_DS);
11751 - ret = sys_rt_sigpending((sigset_t __user *)&s, sigsetsize);
11752 + ret = sys_rt_sigpending((sigset_t __force_user *)&s, sigsetsize);
11753 set_fs(old_fs);
11754 if (!ret) {
11755 switch (_NSIG_WORDS) {
11756 @@ -344,7 +344,7 @@ asmlinkage long sys32_rt_sigqueueinfo(int pid, int sig,
11757 if (copy_siginfo_from_user32(&info, uinfo))
11758 return -EFAULT;
11759 set_fs(KERNEL_DS);
11760 - ret = sys_rt_sigqueueinfo(pid, sig, (siginfo_t __user *)&info);
11761 + ret = sys_rt_sigqueueinfo(pid, sig, (siginfo_t __force_user *)&info);
11762 set_fs(old_fs);
11763 return ret;
11764 }
11765 @@ -376,7 +376,7 @@ asmlinkage long sys32_sendfile(int out_fd, int in_fd,
11766 return -EFAULT;
11767
11768 set_fs(KERNEL_DS);
11769 - ret = sys_sendfile(out_fd, in_fd, offset ? (off_t __user *)&of : NULL,
11770 + ret = sys_sendfile(out_fd, in_fd, offset ? (off_t __force_user *)&of : NULL,
11771 count);
11772 set_fs(old_fs);
11773
11774 diff --git a/arch/x86/include/asm/alternative-asm.h b/arch/x86/include/asm/alternative-asm.h
11775 index 372231c..a5aa1a1 100644
11776 --- a/arch/x86/include/asm/alternative-asm.h
11777 +++ b/arch/x86/include/asm/alternative-asm.h
11778 @@ -18,6 +18,45 @@
11779 .endm
11780 #endif
11781
11782 +#ifdef KERNEXEC_PLUGIN
11783 + .macro pax_force_retaddr_bts rip=0
11784 + btsq $63,\rip(%rsp)
11785 + .endm
11786 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_BTS
11787 + .macro pax_force_retaddr rip=0, reload=0
11788 + btsq $63,\rip(%rsp)
11789 + .endm
11790 + .macro pax_force_fptr ptr
11791 + btsq $63,\ptr
11792 + .endm
11793 + .macro pax_set_fptr_mask
11794 + .endm
11795 +#endif
11796 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR
11797 + .macro pax_force_retaddr rip=0, reload=0
11798 + .if \reload
11799 + pax_set_fptr_mask
11800 + .endif
11801 + orq %r10,\rip(%rsp)
11802 + .endm
11803 + .macro pax_force_fptr ptr
11804 + orq %r10,\ptr
11805 + .endm
11806 + .macro pax_set_fptr_mask
11807 + movabs $0x8000000000000000,%r10
11808 + .endm
11809 +#endif
11810 +#else
11811 + .macro pax_force_retaddr rip=0, reload=0
11812 + .endm
11813 + .macro pax_force_fptr ptr
11814 + .endm
11815 + .macro pax_force_retaddr_bts rip=0
11816 + .endm
11817 + .macro pax_set_fptr_mask
11818 + .endm
11819 +#endif
11820 +
11821 .macro altinstruction_entry orig alt feature orig_len alt_len
11822 .long \orig - .
11823 .long \alt - .
11824 diff --git a/arch/x86/include/asm/alternative.h b/arch/x86/include/asm/alternative.h
11825 index 58ed6d9..f1cbe58 100644
11826 --- a/arch/x86/include/asm/alternative.h
11827 +++ b/arch/x86/include/asm/alternative.h
11828 @@ -105,7 +105,7 @@ static inline int alternatives_text_reserved(void *start, void *end)
11829 ".pushsection .discard,\"aw\",@progbits\n" \
11830 DISCARD_ENTRY(1) \
11831 ".popsection\n" \
11832 - ".pushsection .altinstr_replacement, \"ax\"\n" \
11833 + ".pushsection .altinstr_replacement, \"a\"\n" \
11834 ALTINSTR_REPLACEMENT(newinstr, feature, 1) \
11835 ".popsection"
11836
11837 @@ -119,7 +119,7 @@ static inline int alternatives_text_reserved(void *start, void *end)
11838 DISCARD_ENTRY(1) \
11839 DISCARD_ENTRY(2) \
11840 ".popsection\n" \
11841 - ".pushsection .altinstr_replacement, \"ax\"\n" \
11842 + ".pushsection .altinstr_replacement, \"a\"\n" \
11843 ALTINSTR_REPLACEMENT(newinstr1, feature1, 1) \
11844 ALTINSTR_REPLACEMENT(newinstr2, feature2, 2) \
11845 ".popsection"
11846 diff --git a/arch/x86/include/asm/apic.h b/arch/x86/include/asm/apic.h
11847 index 3388034..050f0b9 100644
11848 --- a/arch/x86/include/asm/apic.h
11849 +++ b/arch/x86/include/asm/apic.h
11850 @@ -44,7 +44,7 @@ static inline void generic_apic_probe(void)
11851
11852 #ifdef CONFIG_X86_LOCAL_APIC
11853
11854 -extern unsigned int apic_verbosity;
11855 +extern int apic_verbosity;
11856 extern int local_apic_timer_c2_ok;
11857
11858 extern int disable_apic;
11859 diff --git a/arch/x86/include/asm/apm.h b/arch/x86/include/asm/apm.h
11860 index 20370c6..a2eb9b0 100644
11861 --- a/arch/x86/include/asm/apm.h
11862 +++ b/arch/x86/include/asm/apm.h
11863 @@ -34,7 +34,7 @@ static inline void apm_bios_call_asm(u32 func, u32 ebx_in, u32 ecx_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 %%al\n\t"
11870 "popl %%ebp\n\t"
11871 "popl %%edi\n\t"
11872 @@ -58,7 +58,7 @@ static inline u8 apm_bios_call_simple_asm(u32 func, u32 ebx_in,
11873 __asm__ __volatile__(APM_DO_ZERO_SEGS
11874 "pushl %%edi\n\t"
11875 "pushl %%ebp\n\t"
11876 - "lcall *%%cs:apm_bios_entry\n\t"
11877 + "lcall *%%ss:apm_bios_entry\n\t"
11878 "setc %%bl\n\t"
11879 "popl %%ebp\n\t"
11880 "popl %%edi\n\t"
11881 diff --git a/arch/x86/include/asm/atomic.h b/arch/x86/include/asm/atomic.h
11882 index 722aa3b..3a0bb27 100644
11883 --- a/arch/x86/include/asm/atomic.h
11884 +++ b/arch/x86/include/asm/atomic.h
11885 @@ -22,7 +22,18 @@
11886 */
11887 static inline int atomic_read(const atomic_t *v)
11888 {
11889 - return (*(volatile int *)&(v)->counter);
11890 + return (*(volatile const int *)&(v)->counter);
11891 +}
11892 +
11893 +/**
11894 + * atomic_read_unchecked - read atomic variable
11895 + * @v: pointer of type atomic_unchecked_t
11896 + *
11897 + * Atomically reads the value of @v.
11898 + */
11899 +static inline int atomic_read_unchecked(const atomic_unchecked_t *v)
11900 +{
11901 + return (*(volatile const int *)&(v)->counter);
11902 }
11903
11904 /**
11905 @@ -38,6 +49,18 @@ static inline void atomic_set(atomic_t *v, int i)
11906 }
11907
11908 /**
11909 + * atomic_set_unchecked - set atomic variable
11910 + * @v: pointer of type atomic_unchecked_t
11911 + * @i: required value
11912 + *
11913 + * Atomically sets the value of @v to @i.
11914 + */
11915 +static inline void atomic_set_unchecked(atomic_unchecked_t *v, int i)
11916 +{
11917 + v->counter = i;
11918 +}
11919 +
11920 +/**
11921 * atomic_add - add integer to atomic variable
11922 * @i: integer value to add
11923 * @v: pointer of type atomic_t
11924 @@ -46,7 +69,29 @@ static inline void atomic_set(atomic_t *v, int i)
11925 */
11926 static inline void atomic_add(int i, atomic_t *v)
11927 {
11928 - asm volatile(LOCK_PREFIX "addl %1,%0"
11929 + asm volatile(LOCK_PREFIX "addl %1,%0\n"
11930 +
11931 +#ifdef CONFIG_PAX_REFCOUNT
11932 + "jno 0f\n"
11933 + LOCK_PREFIX "subl %1,%0\n"
11934 + "int $4\n0:\n"
11935 + _ASM_EXTABLE(0b, 0b)
11936 +#endif
11937 +
11938 + : "+m" (v->counter)
11939 + : "ir" (i));
11940 +}
11941 +
11942 +/**
11943 + * atomic_add_unchecked - add integer to atomic variable
11944 + * @i: integer value to add
11945 + * @v: pointer of type atomic_unchecked_t
11946 + *
11947 + * Atomically adds @i to @v.
11948 + */
11949 +static inline void atomic_add_unchecked(int i, atomic_unchecked_t *v)
11950 +{
11951 + asm volatile(LOCK_PREFIX "addl %1,%0\n"
11952 : "+m" (v->counter)
11953 : "ir" (i));
11954 }
11955 @@ -60,7 +105,29 @@ static inline void atomic_add(int i, atomic_t *v)
11956 */
11957 static inline void atomic_sub(int i, atomic_t *v)
11958 {
11959 - asm volatile(LOCK_PREFIX "subl %1,%0"
11960 + asm volatile(LOCK_PREFIX "subl %1,%0\n"
11961 +
11962 +#ifdef CONFIG_PAX_REFCOUNT
11963 + "jno 0f\n"
11964 + LOCK_PREFIX "addl %1,%0\n"
11965 + "int $4\n0:\n"
11966 + _ASM_EXTABLE(0b, 0b)
11967 +#endif
11968 +
11969 + : "+m" (v->counter)
11970 + : "ir" (i));
11971 +}
11972 +
11973 +/**
11974 + * atomic_sub_unchecked - subtract integer from atomic variable
11975 + * @i: integer value to subtract
11976 + * @v: pointer of type atomic_unchecked_t
11977 + *
11978 + * Atomically subtracts @i from @v.
11979 + */
11980 +static inline void atomic_sub_unchecked(int i, atomic_unchecked_t *v)
11981 +{
11982 + asm volatile(LOCK_PREFIX "subl %1,%0\n"
11983 : "+m" (v->counter)
11984 : "ir" (i));
11985 }
11986 @@ -78,7 +145,16 @@ static inline int atomic_sub_and_test(int i, atomic_t *v)
11987 {
11988 unsigned char c;
11989
11990 - asm volatile(LOCK_PREFIX "subl %2,%0; sete %1"
11991 + asm volatile(LOCK_PREFIX "subl %2,%0\n"
11992 +
11993 +#ifdef CONFIG_PAX_REFCOUNT
11994 + "jno 0f\n"
11995 + LOCK_PREFIX "addl %2,%0\n"
11996 + "int $4\n0:\n"
11997 + _ASM_EXTABLE(0b, 0b)
11998 +#endif
11999 +
12000 + "sete %1\n"
12001 : "+m" (v->counter), "=qm" (c)
12002 : "ir" (i) : "memory");
12003 return c;
12004 @@ -92,7 +168,27 @@ static inline int atomic_sub_and_test(int i, atomic_t *v)
12005 */
12006 static inline void atomic_inc(atomic_t *v)
12007 {
12008 - asm volatile(LOCK_PREFIX "incl %0"
12009 + asm volatile(LOCK_PREFIX "incl %0\n"
12010 +
12011 +#ifdef CONFIG_PAX_REFCOUNT
12012 + "jno 0f\n"
12013 + LOCK_PREFIX "decl %0\n"
12014 + "int $4\n0:\n"
12015 + _ASM_EXTABLE(0b, 0b)
12016 +#endif
12017 +
12018 + : "+m" (v->counter));
12019 +}
12020 +
12021 +/**
12022 + * atomic_inc_unchecked - increment atomic variable
12023 + * @v: pointer of type atomic_unchecked_t
12024 + *
12025 + * Atomically increments @v by 1.
12026 + */
12027 +static inline void atomic_inc_unchecked(atomic_unchecked_t *v)
12028 +{
12029 + asm volatile(LOCK_PREFIX "incl %0\n"
12030 : "+m" (v->counter));
12031 }
12032
12033 @@ -104,7 +200,27 @@ static inline void atomic_inc(atomic_t *v)
12034 */
12035 static inline void atomic_dec(atomic_t *v)
12036 {
12037 - asm volatile(LOCK_PREFIX "decl %0"
12038 + asm volatile(LOCK_PREFIX "decl %0\n"
12039 +
12040 +#ifdef CONFIG_PAX_REFCOUNT
12041 + "jno 0f\n"
12042 + LOCK_PREFIX "incl %0\n"
12043 + "int $4\n0:\n"
12044 + _ASM_EXTABLE(0b, 0b)
12045 +#endif
12046 +
12047 + : "+m" (v->counter));
12048 +}
12049 +
12050 +/**
12051 + * atomic_dec_unchecked - decrement atomic variable
12052 + * @v: pointer of type atomic_unchecked_t
12053 + *
12054 + * Atomically decrements @v by 1.
12055 + */
12056 +static inline void atomic_dec_unchecked(atomic_unchecked_t *v)
12057 +{
12058 + asm volatile(LOCK_PREFIX "decl %0\n"
12059 : "+m" (v->counter));
12060 }
12061
12062 @@ -120,7 +236,16 @@ static inline int atomic_dec_and_test(atomic_t *v)
12063 {
12064 unsigned char c;
12065
12066 - asm volatile(LOCK_PREFIX "decl %0; sete %1"
12067 + asm volatile(LOCK_PREFIX "decl %0\n"
12068 +
12069 +#ifdef CONFIG_PAX_REFCOUNT
12070 + "jno 0f\n"
12071 + LOCK_PREFIX "incl %0\n"
12072 + "int $4\n0:\n"
12073 + _ASM_EXTABLE(0b, 0b)
12074 +#endif
12075 +
12076 + "sete %1\n"
12077 : "+m" (v->counter), "=qm" (c)
12078 : : "memory");
12079 return c != 0;
12080 @@ -138,7 +263,35 @@ static inline int atomic_inc_and_test(atomic_t *v)
12081 {
12082 unsigned char c;
12083
12084 - asm volatile(LOCK_PREFIX "incl %0; sete %1"
12085 + asm volatile(LOCK_PREFIX "incl %0\n"
12086 +
12087 +#ifdef CONFIG_PAX_REFCOUNT
12088 + "jno 0f\n"
12089 + LOCK_PREFIX "decl %0\n"
12090 + "int $4\n0:\n"
12091 + _ASM_EXTABLE(0b, 0b)
12092 +#endif
12093 +
12094 + "sete %1\n"
12095 + : "+m" (v->counter), "=qm" (c)
12096 + : : "memory");
12097 + return c != 0;
12098 +}
12099 +
12100 +/**
12101 + * atomic_inc_and_test_unchecked - increment and test
12102 + * @v: pointer of type atomic_unchecked_t
12103 + *
12104 + * Atomically increments @v by 1
12105 + * and returns true if the result is zero, or false for all
12106 + * other cases.
12107 + */
12108 +static inline int atomic_inc_and_test_unchecked(atomic_unchecked_t *v)
12109 +{
12110 + unsigned char c;
12111 +
12112 + asm volatile(LOCK_PREFIX "incl %0\n"
12113 + "sete %1\n"
12114 : "+m" (v->counter), "=qm" (c)
12115 : : "memory");
12116 return c != 0;
12117 @@ -157,7 +310,16 @@ static inline int atomic_add_negative(int i, atomic_t *v)
12118 {
12119 unsigned char c;
12120
12121 - asm volatile(LOCK_PREFIX "addl %2,%0; sets %1"
12122 + asm volatile(LOCK_PREFIX "addl %2,%0\n"
12123 +
12124 +#ifdef CONFIG_PAX_REFCOUNT
12125 + "jno 0f\n"
12126 + LOCK_PREFIX "subl %2,%0\n"
12127 + "int $4\n0:\n"
12128 + _ASM_EXTABLE(0b, 0b)
12129 +#endif
12130 +
12131 + "sets %1\n"
12132 : "+m" (v->counter), "=qm" (c)
12133 : "ir" (i) : "memory");
12134 return c;
12135 @@ -172,6 +334,18 @@ static inline int atomic_add_negative(int i, atomic_t *v)
12136 */
12137 static inline int atomic_add_return(int i, atomic_t *v)
12138 {
12139 + return i + xadd_check_overflow(&v->counter, i);
12140 +}
12141 +
12142 +/**
12143 + * atomic_add_return_unchecked - add integer and return
12144 + * @i: integer value to add
12145 + * @v: pointer of type atomic_unchecked_t
12146 + *
12147 + * Atomically adds @i to @v and returns @i + @v
12148 + */
12149 +static inline int atomic_add_return_unchecked(int i, atomic_unchecked_t *v)
12150 +{
12151 return i + xadd(&v->counter, i);
12152 }
12153
12154 @@ -188,6 +362,10 @@ static inline int atomic_sub_return(int i, atomic_t *v)
12155 }
12156
12157 #define atomic_inc_return(v) (atomic_add_return(1, v))
12158 +static inline int atomic_inc_return_unchecked(atomic_unchecked_t *v)
12159 +{
12160 + return atomic_add_return_unchecked(1, v);
12161 +}
12162 #define atomic_dec_return(v) (atomic_sub_return(1, v))
12163
12164 static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
12165 @@ -195,11 +373,21 @@ static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
12166 return cmpxchg(&v->counter, old, new);
12167 }
12168
12169 +static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *v, int old, int new)
12170 +{
12171 + return cmpxchg(&v->counter, old, new);
12172 +}
12173 +
12174 static inline int atomic_xchg(atomic_t *v, int new)
12175 {
12176 return xchg(&v->counter, new);
12177 }
12178
12179 +static inline int atomic_xchg_unchecked(atomic_unchecked_t *v, int new)
12180 +{
12181 + return xchg(&v->counter, new);
12182 +}
12183 +
12184 /**
12185 * __atomic_add_unless - add unless the number is already a given value
12186 * @v: pointer of type atomic_t
12187 @@ -211,12 +399,25 @@ static inline int atomic_xchg(atomic_t *v, int new)
12188 */
12189 static inline int __atomic_add_unless(atomic_t *v, int a, int u)
12190 {
12191 - int c, old;
12192 + int c, old, new;
12193 c = atomic_read(v);
12194 for (;;) {
12195 - if (unlikely(c == (u)))
12196 + if (unlikely(c == u))
12197 break;
12198 - old = atomic_cmpxchg((v), c, c + (a));
12199 +
12200 + asm volatile("addl %2,%0\n"
12201 +
12202 +#ifdef CONFIG_PAX_REFCOUNT
12203 + "jno 0f\n"
12204 + "subl %2,%0\n"
12205 + "int $4\n0:\n"
12206 + _ASM_EXTABLE(0b, 0b)
12207 +#endif
12208 +
12209 + : "=r" (new)
12210 + : "0" (c), "ir" (a));
12211 +
12212 + old = atomic_cmpxchg(v, c, new);
12213 if (likely(old == c))
12214 break;
12215 c = old;
12216 @@ -225,6 +426,49 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
12217 }
12218
12219 /**
12220 + * atomic_inc_not_zero_hint - increment if not null
12221 + * @v: pointer of type atomic_t
12222 + * @hint: probable value of the atomic before the increment
12223 + *
12224 + * This version of atomic_inc_not_zero() gives a hint of probable
12225 + * value of the atomic. This helps processor to not read the memory
12226 + * before doing the atomic read/modify/write cycle, lowering
12227 + * number of bus transactions on some arches.
12228 + *
12229 + * Returns: 0 if increment was not done, 1 otherwise.
12230 + */
12231 +#define atomic_inc_not_zero_hint atomic_inc_not_zero_hint
12232 +static inline int atomic_inc_not_zero_hint(atomic_t *v, int hint)
12233 +{
12234 + int val, c = hint, new;
12235 +
12236 + /* sanity test, should be removed by compiler if hint is a constant */
12237 + if (!hint)
12238 + return __atomic_add_unless(v, 1, 0);
12239 +
12240 + do {
12241 + asm volatile("incl %0\n"
12242 +
12243 +#ifdef CONFIG_PAX_REFCOUNT
12244 + "jno 0f\n"
12245 + "decl %0\n"
12246 + "int $4\n0:\n"
12247 + _ASM_EXTABLE(0b, 0b)
12248 +#endif
12249 +
12250 + : "=r" (new)
12251 + : "0" (c));
12252 +
12253 + val = atomic_cmpxchg(v, c, new);
12254 + if (val == c)
12255 + return 1;
12256 + c = val;
12257 + } while (c);
12258 +
12259 + return 0;
12260 +}
12261 +
12262 +/**
12263 * atomic_inc_short - increment of a short integer
12264 * @v: pointer to type int
12265 *
12266 @@ -253,14 +497,37 @@ static inline void atomic_or_long(unsigned long *v1, unsigned long v2)
12267 #endif
12268
12269 /* These are x86-specific, used by some header files */
12270 -#define atomic_clear_mask(mask, addr) \
12271 - asm volatile(LOCK_PREFIX "andl %0,%1" \
12272 - : : "r" (~(mask)), "m" (*(addr)) : "memory")
12273 +static inline void atomic_clear_mask(unsigned int mask, atomic_t *v)
12274 +{
12275 + asm volatile(LOCK_PREFIX "andl %1,%0"
12276 + : "+m" (v->counter)
12277 + : "r" (~(mask))
12278 + : "memory");
12279 +}
12280
12281 -#define atomic_set_mask(mask, addr) \
12282 - asm volatile(LOCK_PREFIX "orl %0,%1" \
12283 - : : "r" ((unsigned)(mask)), "m" (*(addr)) \
12284 - : "memory")
12285 +static inline void atomic_clear_mask_unchecked(unsigned int mask, atomic_unchecked_t *v)
12286 +{
12287 + asm volatile(LOCK_PREFIX "andl %1,%0"
12288 + : "+m" (v->counter)
12289 + : "r" (~(mask))
12290 + : "memory");
12291 +}
12292 +
12293 +static inline void atomic_set_mask(unsigned int mask, atomic_t *v)
12294 +{
12295 + asm volatile(LOCK_PREFIX "orl %1,%0"
12296 + : "+m" (v->counter)
12297 + : "r" (mask)
12298 + : "memory");
12299 +}
12300 +
12301 +static inline void atomic_set_mask_unchecked(unsigned int mask, atomic_unchecked_t *v)
12302 +{
12303 + asm volatile(LOCK_PREFIX "orl %1,%0"
12304 + : "+m" (v->counter)
12305 + : "r" (mask)
12306 + : "memory");
12307 +}
12308
12309 /* Atomic operations are already serializing on x86 */
12310 #define smp_mb__before_atomic_dec() barrier()
12311 diff --git a/arch/x86/include/asm/atomic64_32.h b/arch/x86/include/asm/atomic64_32.h
12312 index b154de7..aadebd8 100644
12313 --- a/arch/x86/include/asm/atomic64_32.h
12314 +++ b/arch/x86/include/asm/atomic64_32.h
12315 @@ -12,6 +12,14 @@ typedef struct {
12316 u64 __aligned(8) counter;
12317 } atomic64_t;
12318
12319 +#ifdef CONFIG_PAX_REFCOUNT
12320 +typedef struct {
12321 + u64 __aligned(8) counter;
12322 +} atomic64_unchecked_t;
12323 +#else
12324 +typedef atomic64_t atomic64_unchecked_t;
12325 +#endif
12326 +
12327 #define ATOMIC64_INIT(val) { (val) }
12328
12329 #define __ATOMIC64_DECL(sym) void atomic64_##sym(atomic64_t *, ...)
12330 @@ -37,21 +45,31 @@ typedef struct {
12331 ATOMIC64_DECL_ONE(sym##_386)
12332
12333 ATOMIC64_DECL_ONE(add_386);
12334 +ATOMIC64_DECL_ONE(add_unchecked_386);
12335 ATOMIC64_DECL_ONE(sub_386);
12336 +ATOMIC64_DECL_ONE(sub_unchecked_386);
12337 ATOMIC64_DECL_ONE(inc_386);
12338 +ATOMIC64_DECL_ONE(inc_unchecked_386);
12339 ATOMIC64_DECL_ONE(dec_386);
12340 +ATOMIC64_DECL_ONE(dec_unchecked_386);
12341 #endif
12342
12343 #define alternative_atomic64(f, out, in...) \
12344 __alternative_atomic64(f, f, ASM_OUTPUT2(out), ## in)
12345
12346 ATOMIC64_DECL(read);
12347 +ATOMIC64_DECL(read_unchecked);
12348 ATOMIC64_DECL(set);
12349 +ATOMIC64_DECL(set_unchecked);
12350 ATOMIC64_DECL(xchg);
12351 ATOMIC64_DECL(add_return);
12352 +ATOMIC64_DECL(add_return_unchecked);
12353 ATOMIC64_DECL(sub_return);
12354 +ATOMIC64_DECL(sub_return_unchecked);
12355 ATOMIC64_DECL(inc_return);
12356 +ATOMIC64_DECL(inc_return_unchecked);
12357 ATOMIC64_DECL(dec_return);
12358 +ATOMIC64_DECL(dec_return_unchecked);
12359 ATOMIC64_DECL(dec_if_positive);
12360 ATOMIC64_DECL(inc_not_zero);
12361 ATOMIC64_DECL(add_unless);
12362 @@ -77,6 +95,21 @@ static inline long long atomic64_cmpxchg(atomic64_t *v, long long o, long long n
12363 }
12364
12365 /**
12366 + * atomic64_cmpxchg_unchecked - cmpxchg atomic64 variable
12367 + * @p: pointer to type atomic64_unchecked_t
12368 + * @o: expected value
12369 + * @n: new value
12370 + *
12371 + * Atomically sets @v to @n if it was equal to @o and returns
12372 + * the old value.
12373 + */
12374 +
12375 +static inline long long atomic64_cmpxchg_unchecked(atomic64_unchecked_t *v, long long o, long long n)
12376 +{
12377 + return cmpxchg64(&v->counter, o, n);
12378 +}
12379 +
12380 +/**
12381 * atomic64_xchg - xchg atomic64 variable
12382 * @v: pointer to type atomic64_t
12383 * @n: value to assign
12384 @@ -112,6 +145,22 @@ static inline void atomic64_set(atomic64_t *v, long long i)
12385 }
12386
12387 /**
12388 + * atomic64_set_unchecked - set atomic64 variable
12389 + * @v: pointer to type atomic64_unchecked_t
12390 + * @n: value to assign
12391 + *
12392 + * Atomically sets the value of @v to @n.
12393 + */
12394 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, long long i)
12395 +{
12396 + unsigned high = (unsigned)(i >> 32);
12397 + unsigned low = (unsigned)i;
12398 + alternative_atomic64(set, /* no output */,
12399 + "S" (v), "b" (low), "c" (high)
12400 + : "eax", "edx", "memory");
12401 +}
12402 +
12403 +/**
12404 * atomic64_read - read atomic64 variable
12405 * @v: pointer to type atomic64_t
12406 *
12407 @@ -125,6 +174,19 @@ static inline long long atomic64_read(const atomic64_t *v)
12408 }
12409
12410 /**
12411 + * atomic64_read_unchecked - read atomic64 variable
12412 + * @v: pointer to type atomic64_unchecked_t
12413 + *
12414 + * Atomically reads the value of @v and returns it.
12415 + */
12416 +static inline long long atomic64_read_unchecked(atomic64_unchecked_t *v)
12417 +{
12418 + long long r;
12419 + alternative_atomic64(read, "=&A" (r), "c" (v) : "memory");
12420 + return r;
12421 + }
12422 +
12423 +/**
12424 * atomic64_add_return - add and return
12425 * @i: integer value to add
12426 * @v: pointer to type atomic64_t
12427 @@ -139,6 +201,21 @@ static inline long long atomic64_add_return(long long i, atomic64_t *v)
12428 return i;
12429 }
12430
12431 +/**
12432 + * atomic64_add_return_unchecked - add and return
12433 + * @i: integer value to add
12434 + * @v: pointer to type atomic64_unchecked_t
12435 + *
12436 + * Atomically adds @i to @v and returns @i + *@v
12437 + */
12438 +static inline long long atomic64_add_return_unchecked(long long i, atomic64_unchecked_t *v)
12439 +{
12440 + alternative_atomic64(add_return_unchecked,
12441 + ASM_OUTPUT2("+A" (i), "+c" (v)),
12442 + ASM_NO_INPUT_CLOBBER("memory"));
12443 + return i;
12444 +}
12445 +
12446 /*
12447 * Other variants with different arithmetic operators:
12448 */
12449 @@ -158,6 +235,14 @@ static inline long long atomic64_inc_return(atomic64_t *v)
12450 return a;
12451 }
12452
12453 +static inline long long atomic64_inc_return_unchecked(atomic64_unchecked_t *v)
12454 +{
12455 + long long a;
12456 + alternative_atomic64(inc_return_unchecked, "=&A" (a),
12457 + "S" (v) : "memory", "ecx");
12458 + return a;
12459 +}
12460 +
12461 static inline long long atomic64_dec_return(atomic64_t *v)
12462 {
12463 long long a;
12464 @@ -182,6 +267,21 @@ static inline long long atomic64_add(long long i, atomic64_t *v)
12465 }
12466
12467 /**
12468 + * atomic64_add_unchecked - add integer to atomic64 variable
12469 + * @i: integer value to add
12470 + * @v: pointer to type atomic64_unchecked_t
12471 + *
12472 + * Atomically adds @i to @v.
12473 + */
12474 +static inline long long atomic64_add_unchecked(long long i, atomic64_unchecked_t *v)
12475 +{
12476 + __alternative_atomic64(add_unchecked, add_return_unchecked,
12477 + ASM_OUTPUT2("+A" (i), "+c" (v)),
12478 + ASM_NO_INPUT_CLOBBER("memory"));
12479 + return i;
12480 +}
12481 +
12482 +/**
12483 * atomic64_sub - subtract the atomic64 variable
12484 * @i: integer value to subtract
12485 * @v: pointer to type atomic64_t
12486 diff --git a/arch/x86/include/asm/atomic64_64.h b/arch/x86/include/asm/atomic64_64.h
12487 index 0e1cbfc..5623683 100644
12488 --- a/arch/x86/include/asm/atomic64_64.h
12489 +++ b/arch/x86/include/asm/atomic64_64.h
12490 @@ -18,7 +18,19 @@
12491 */
12492 static inline long atomic64_read(const atomic64_t *v)
12493 {
12494 - return (*(volatile long *)&(v)->counter);
12495 + return (*(volatile const long *)&(v)->counter);
12496 +}
12497 +
12498 +/**
12499 + * atomic64_read_unchecked - read atomic64 variable
12500 + * @v: pointer of type atomic64_unchecked_t
12501 + *
12502 + * Atomically reads the value of @v.
12503 + * Doesn't imply a read memory barrier.
12504 + */
12505 +static inline long atomic64_read_unchecked(const atomic64_unchecked_t *v)
12506 +{
12507 + return (*(volatile const long *)&(v)->counter);
12508 }
12509
12510 /**
12511 @@ -34,6 +46,18 @@ static inline void atomic64_set(atomic64_t *v, long i)
12512 }
12513
12514 /**
12515 + * atomic64_set_unchecked - set atomic64 variable
12516 + * @v: pointer to type atomic64_unchecked_t
12517 + * @i: required value
12518 + *
12519 + * Atomically sets the value of @v to @i.
12520 + */
12521 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, long i)
12522 +{
12523 + v->counter = i;
12524 +}
12525 +
12526 +/**
12527 * atomic64_add - add integer to atomic64 variable
12528 * @i: integer value to add
12529 * @v: pointer to type atomic64_t
12530 @@ -42,6 +66,28 @@ static inline void atomic64_set(atomic64_t *v, long i)
12531 */
12532 static inline void atomic64_add(long i, atomic64_t *v)
12533 {
12534 + asm volatile(LOCK_PREFIX "addq %1,%0\n"
12535 +
12536 +#ifdef CONFIG_PAX_REFCOUNT
12537 + "jno 0f\n"
12538 + LOCK_PREFIX "subq %1,%0\n"
12539 + "int $4\n0:\n"
12540 + _ASM_EXTABLE(0b, 0b)
12541 +#endif
12542 +
12543 + : "=m" (v->counter)
12544 + : "er" (i), "m" (v->counter));
12545 +}
12546 +
12547 +/**
12548 + * atomic64_add_unchecked - add integer to atomic64 variable
12549 + * @i: integer value to add
12550 + * @v: pointer to type atomic64_unchecked_t
12551 + *
12552 + * Atomically adds @i to @v.
12553 + */
12554 +static inline void atomic64_add_unchecked(long i, atomic64_unchecked_t *v)
12555 +{
12556 asm volatile(LOCK_PREFIX "addq %1,%0"
12557 : "=m" (v->counter)
12558 : "er" (i), "m" (v->counter));
12559 @@ -56,7 +102,29 @@ static inline void atomic64_add(long i, atomic64_t *v)
12560 */
12561 static inline void atomic64_sub(long i, atomic64_t *v)
12562 {
12563 - asm volatile(LOCK_PREFIX "subq %1,%0"
12564 + asm volatile(LOCK_PREFIX "subq %1,%0\n"
12565 +
12566 +#ifdef CONFIG_PAX_REFCOUNT
12567 + "jno 0f\n"
12568 + LOCK_PREFIX "addq %1,%0\n"
12569 + "int $4\n0:\n"
12570 + _ASM_EXTABLE(0b, 0b)
12571 +#endif
12572 +
12573 + : "=m" (v->counter)
12574 + : "er" (i), "m" (v->counter));
12575 +}
12576 +
12577 +/**
12578 + * atomic64_sub_unchecked - subtract the atomic64 variable
12579 + * @i: integer value to subtract
12580 + * @v: pointer to type atomic64_unchecked_t
12581 + *
12582 + * Atomically subtracts @i from @v.
12583 + */
12584 +static inline void atomic64_sub_unchecked(long i, atomic64_unchecked_t *v)
12585 +{
12586 + asm volatile(LOCK_PREFIX "subq %1,%0\n"
12587 : "=m" (v->counter)
12588 : "er" (i), "m" (v->counter));
12589 }
12590 @@ -74,7 +142,16 @@ static inline int atomic64_sub_and_test(long i, atomic64_t *v)
12591 {
12592 unsigned char c;
12593
12594 - asm volatile(LOCK_PREFIX "subq %2,%0; sete %1"
12595 + asm volatile(LOCK_PREFIX "subq %2,%0\n"
12596 +
12597 +#ifdef CONFIG_PAX_REFCOUNT
12598 + "jno 0f\n"
12599 + LOCK_PREFIX "addq %2,%0\n"
12600 + "int $4\n0:\n"
12601 + _ASM_EXTABLE(0b, 0b)
12602 +#endif
12603 +
12604 + "sete %1\n"
12605 : "=m" (v->counter), "=qm" (c)
12606 : "er" (i), "m" (v->counter) : "memory");
12607 return c;
12608 @@ -88,6 +165,27 @@ static inline int atomic64_sub_and_test(long i, atomic64_t *v)
12609 */
12610 static inline void atomic64_inc(atomic64_t *v)
12611 {
12612 + asm volatile(LOCK_PREFIX "incq %0\n"
12613 +
12614 +#ifdef CONFIG_PAX_REFCOUNT
12615 + "jno 0f\n"
12616 + LOCK_PREFIX "decq %0\n"
12617 + "int $4\n0:\n"
12618 + _ASM_EXTABLE(0b, 0b)
12619 +#endif
12620 +
12621 + : "=m" (v->counter)
12622 + : "m" (v->counter));
12623 +}
12624 +
12625 +/**
12626 + * atomic64_inc_unchecked - increment atomic64 variable
12627 + * @v: pointer to type atomic64_unchecked_t
12628 + *
12629 + * Atomically increments @v by 1.
12630 + */
12631 +static inline void atomic64_inc_unchecked(atomic64_unchecked_t *v)
12632 +{
12633 asm volatile(LOCK_PREFIX "incq %0"
12634 : "=m" (v->counter)
12635 : "m" (v->counter));
12636 @@ -101,7 +199,28 @@ static inline void atomic64_inc(atomic64_t *v)
12637 */
12638 static inline void atomic64_dec(atomic64_t *v)
12639 {
12640 - asm volatile(LOCK_PREFIX "decq %0"
12641 + asm volatile(LOCK_PREFIX "decq %0\n"
12642 +
12643 +#ifdef CONFIG_PAX_REFCOUNT
12644 + "jno 0f\n"
12645 + LOCK_PREFIX "incq %0\n"
12646 + "int $4\n0:\n"
12647 + _ASM_EXTABLE(0b, 0b)
12648 +#endif
12649 +
12650 + : "=m" (v->counter)
12651 + : "m" (v->counter));
12652 +}
12653 +
12654 +/**
12655 + * atomic64_dec_unchecked - decrement atomic64 variable
12656 + * @v: pointer to type atomic64_t
12657 + *
12658 + * Atomically decrements @v by 1.
12659 + */
12660 +static inline void atomic64_dec_unchecked(atomic64_unchecked_t *v)
12661 +{
12662 + asm volatile(LOCK_PREFIX "decq %0\n"
12663 : "=m" (v->counter)
12664 : "m" (v->counter));
12665 }
12666 @@ -118,7 +237,16 @@ static inline int atomic64_dec_and_test(atomic64_t *v)
12667 {
12668 unsigned char c;
12669
12670 - asm volatile(LOCK_PREFIX "decq %0; sete %1"
12671 + asm volatile(LOCK_PREFIX "decq %0\n"
12672 +
12673 +#ifdef CONFIG_PAX_REFCOUNT
12674 + "jno 0f\n"
12675 + LOCK_PREFIX "incq %0\n"
12676 + "int $4\n0:\n"
12677 + _ASM_EXTABLE(0b, 0b)
12678 +#endif
12679 +
12680 + "sete %1\n"
12681 : "=m" (v->counter), "=qm" (c)
12682 : "m" (v->counter) : "memory");
12683 return c != 0;
12684 @@ -136,7 +264,16 @@ static inline int atomic64_inc_and_test(atomic64_t *v)
12685 {
12686 unsigned char c;
12687
12688 - asm volatile(LOCK_PREFIX "incq %0; sete %1"
12689 + asm volatile(LOCK_PREFIX "incq %0\n"
12690 +
12691 +#ifdef CONFIG_PAX_REFCOUNT
12692 + "jno 0f\n"
12693 + LOCK_PREFIX "decq %0\n"
12694 + "int $4\n0:\n"
12695 + _ASM_EXTABLE(0b, 0b)
12696 +#endif
12697 +
12698 + "sete %1\n"
12699 : "=m" (v->counter), "=qm" (c)
12700 : "m" (v->counter) : "memory");
12701 return c != 0;
12702 @@ -155,7 +292,16 @@ static inline int atomic64_add_negative(long i, atomic64_t *v)
12703 {
12704 unsigned char c;
12705
12706 - asm volatile(LOCK_PREFIX "addq %2,%0; sets %1"
12707 + asm volatile(LOCK_PREFIX "addq %2,%0\n"
12708 +
12709 +#ifdef CONFIG_PAX_REFCOUNT
12710 + "jno 0f\n"
12711 + LOCK_PREFIX "subq %2,%0\n"
12712 + "int $4\n0:\n"
12713 + _ASM_EXTABLE(0b, 0b)
12714 +#endif
12715 +
12716 + "sets %1\n"
12717 : "=m" (v->counter), "=qm" (c)
12718 : "er" (i), "m" (v->counter) : "memory");
12719 return c;
12720 @@ -170,6 +316,18 @@ static inline int atomic64_add_negative(long i, atomic64_t *v)
12721 */
12722 static inline long atomic64_add_return(long i, atomic64_t *v)
12723 {
12724 + return i + xadd_check_overflow(&v->counter, i);
12725 +}
12726 +
12727 +/**
12728 + * atomic64_add_return_unchecked - add and return
12729 + * @i: integer value to add
12730 + * @v: pointer to type atomic64_unchecked_t
12731 + *
12732 + * Atomically adds @i to @v and returns @i + @v
12733 + */
12734 +static inline long atomic64_add_return_unchecked(long i, atomic64_unchecked_t *v)
12735 +{
12736 return i + xadd(&v->counter, i);
12737 }
12738
12739 @@ -179,6 +337,10 @@ static inline long atomic64_sub_return(long i, atomic64_t *v)
12740 }
12741
12742 #define atomic64_inc_return(v) (atomic64_add_return(1, (v)))
12743 +static inline long atomic64_inc_return_unchecked(atomic64_unchecked_t *v)
12744 +{
12745 + return atomic64_add_return_unchecked(1, v);
12746 +}
12747 #define atomic64_dec_return(v) (atomic64_sub_return(1, (v)))
12748
12749 static inline long atomic64_cmpxchg(atomic64_t *v, long old, long new)
12750 @@ -186,6 +348,11 @@ static inline long atomic64_cmpxchg(atomic64_t *v, long old, long new)
12751 return cmpxchg(&v->counter, old, new);
12752 }
12753
12754 +static inline long atomic64_cmpxchg_unchecked(atomic64_unchecked_t *v, long old, long new)
12755 +{
12756 + return cmpxchg(&v->counter, old, new);
12757 +}
12758 +
12759 static inline long atomic64_xchg(atomic64_t *v, long new)
12760 {
12761 return xchg(&v->counter, new);
12762 @@ -202,17 +369,30 @@ static inline long atomic64_xchg(atomic64_t *v, long new)
12763 */
12764 static inline int atomic64_add_unless(atomic64_t *v, long a, long u)
12765 {
12766 - long c, old;
12767 + long c, old, new;
12768 c = atomic64_read(v);
12769 for (;;) {
12770 - if (unlikely(c == (u)))
12771 + if (unlikely(c == u))
12772 break;
12773 - old = atomic64_cmpxchg((v), c, c + (a));
12774 +
12775 + asm volatile("add %2,%0\n"
12776 +
12777 +#ifdef CONFIG_PAX_REFCOUNT
12778 + "jno 0f\n"
12779 + "sub %2,%0\n"
12780 + "int $4\n0:\n"
12781 + _ASM_EXTABLE(0b, 0b)
12782 +#endif
12783 +
12784 + : "=r" (new)
12785 + : "0" (c), "ir" (a));
12786 +
12787 + old = atomic64_cmpxchg(v, c, new);
12788 if (likely(old == c))
12789 break;
12790 c = old;
12791 }
12792 - return c != (u);
12793 + return c != u;
12794 }
12795
12796 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
12797 diff --git a/arch/x86/include/asm/bitops.h b/arch/x86/include/asm/bitops.h
12798 index 6dfd019..28e188d 100644
12799 --- a/arch/x86/include/asm/bitops.h
12800 +++ b/arch/x86/include/asm/bitops.h
12801 @@ -40,7 +40,7 @@
12802 * a mask operation on a byte.
12803 */
12804 #define IS_IMMEDIATE(nr) (__builtin_constant_p(nr))
12805 -#define CONST_MASK_ADDR(nr, addr) BITOP_ADDR((void *)(addr) + ((nr)>>3))
12806 +#define CONST_MASK_ADDR(nr, addr) BITOP_ADDR((volatile void *)(addr) + ((nr)>>3))
12807 #define CONST_MASK(nr) (1 << ((nr) & 7))
12808
12809 /**
12810 @@ -486,7 +486,7 @@ static inline int fls(int x)
12811 * at position 64.
12812 */
12813 #ifdef CONFIG_X86_64
12814 -static __always_inline int fls64(__u64 x)
12815 +static __always_inline long fls64(__u64 x)
12816 {
12817 int bitpos = -1;
12818 /*
12819 diff --git a/arch/x86/include/asm/boot.h b/arch/x86/include/asm/boot.h
12820 index 4fa687a..60f2d39 100644
12821 --- a/arch/x86/include/asm/boot.h
12822 +++ b/arch/x86/include/asm/boot.h
12823 @@ -6,10 +6,15 @@
12824 #include <uapi/asm/boot.h>
12825
12826 /* Physical address where kernel should be loaded. */
12827 -#define LOAD_PHYSICAL_ADDR ((CONFIG_PHYSICAL_START \
12828 +#define ____LOAD_PHYSICAL_ADDR ((CONFIG_PHYSICAL_START \
12829 + (CONFIG_PHYSICAL_ALIGN - 1)) \
12830 & ~(CONFIG_PHYSICAL_ALIGN - 1))
12831
12832 +#ifndef __ASSEMBLY__
12833 +extern unsigned char __LOAD_PHYSICAL_ADDR[];
12834 +#define LOAD_PHYSICAL_ADDR ((unsigned long)__LOAD_PHYSICAL_ADDR)
12835 +#endif
12836 +
12837 /* Minimum kernel alignment, as a power of two */
12838 #ifdef CONFIG_X86_64
12839 #define MIN_KERNEL_ALIGN_LG2 PMD_SHIFT
12840 diff --git a/arch/x86/include/asm/cache.h b/arch/x86/include/asm/cache.h
12841 index 48f99f1..d78ebf9 100644
12842 --- a/arch/x86/include/asm/cache.h
12843 +++ b/arch/x86/include/asm/cache.h
12844 @@ -5,12 +5,13 @@
12845
12846 /* L1 cache line size */
12847 #define L1_CACHE_SHIFT (CONFIG_X86_L1_CACHE_SHIFT)
12848 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
12849 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
12850
12851 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
12852 +#define __read_only __attribute__((__section__(".data..read_only")))
12853
12854 #define INTERNODE_CACHE_SHIFT CONFIG_X86_INTERNODE_CACHE_SHIFT
12855 -#define INTERNODE_CACHE_BYTES (1 << INTERNODE_CACHE_SHIFT)
12856 +#define INTERNODE_CACHE_BYTES (_AC(1,UL) << INTERNODE_CACHE_SHIFT)
12857
12858 #ifdef CONFIG_X86_VSMP
12859 #ifdef CONFIG_SMP
12860 diff --git a/arch/x86/include/asm/cacheflush.h b/arch/x86/include/asm/cacheflush.h
12861 index 9863ee3..4a1f8e1 100644
12862 --- a/arch/x86/include/asm/cacheflush.h
12863 +++ b/arch/x86/include/asm/cacheflush.h
12864 @@ -27,7 +27,7 @@ static inline unsigned long get_page_memtype(struct page *pg)
12865 unsigned long pg_flags = pg->flags & _PGMT_MASK;
12866
12867 if (pg_flags == _PGMT_DEFAULT)
12868 - return -1;
12869 + return ~0UL;
12870 else if (pg_flags == _PGMT_WC)
12871 return _PAGE_CACHE_WC;
12872 else if (pg_flags == _PGMT_UC_MINUS)
12873 diff --git a/arch/x86/include/asm/checksum_32.h b/arch/x86/include/asm/checksum_32.h
12874 index 46fc474..b02b0f9 100644
12875 --- a/arch/x86/include/asm/checksum_32.h
12876 +++ b/arch/x86/include/asm/checksum_32.h
12877 @@ -31,6 +31,14 @@ asmlinkage __wsum csum_partial_copy_generic(const void *src, void *dst,
12878 int len, __wsum sum,
12879 int *src_err_ptr, int *dst_err_ptr);
12880
12881 +asmlinkage __wsum csum_partial_copy_generic_to_user(const void *src, void *dst,
12882 + int len, __wsum sum,
12883 + int *src_err_ptr, int *dst_err_ptr);
12884 +
12885 +asmlinkage __wsum csum_partial_copy_generic_from_user(const void *src, void *dst,
12886 + int len, __wsum sum,
12887 + int *src_err_ptr, int *dst_err_ptr);
12888 +
12889 /*
12890 * Note: when you get a NULL pointer exception here this means someone
12891 * passed in an incorrect kernel address to one of these functions.
12892 @@ -50,7 +58,7 @@ static inline __wsum csum_partial_copy_from_user(const void __user *src,
12893 int *err_ptr)
12894 {
12895 might_sleep();
12896 - return csum_partial_copy_generic((__force void *)src, dst,
12897 + return csum_partial_copy_generic_from_user((__force void *)src, dst,
12898 len, sum, err_ptr, NULL);
12899 }
12900
12901 @@ -178,7 +186,7 @@ static inline __wsum csum_and_copy_to_user(const void *src,
12902 {
12903 might_sleep();
12904 if (access_ok(VERIFY_WRITE, dst, len))
12905 - return csum_partial_copy_generic(src, (__force void *)dst,
12906 + return csum_partial_copy_generic_to_user(src, (__force void *)dst,
12907 len, sum, NULL, err_ptr);
12908
12909 if (len)
12910 diff --git a/arch/x86/include/asm/cmpxchg.h b/arch/x86/include/asm/cmpxchg.h
12911 index 8d871ea..c1a0dc9 100644
12912 --- a/arch/x86/include/asm/cmpxchg.h
12913 +++ b/arch/x86/include/asm/cmpxchg.h
12914 @@ -14,8 +14,12 @@ extern void __cmpxchg_wrong_size(void)
12915 __compiletime_error("Bad argument size for cmpxchg");
12916 extern void __xadd_wrong_size(void)
12917 __compiletime_error("Bad argument size for xadd");
12918 +extern void __xadd_check_overflow_wrong_size(void)
12919 + __compiletime_error("Bad argument size for xadd_check_overflow");
12920 extern void __add_wrong_size(void)
12921 __compiletime_error("Bad argument size for add");
12922 +extern void __add_check_overflow_wrong_size(void)
12923 + __compiletime_error("Bad argument size for add_check_overflow");
12924
12925 /*
12926 * Constants for operation sizes. On 32-bit, the 64-bit size it set to
12927 @@ -67,6 +71,34 @@ extern void __add_wrong_size(void)
12928 __ret; \
12929 })
12930
12931 +#define __xchg_op_check_overflow(ptr, arg, op, lock) \
12932 + ({ \
12933 + __typeof__ (*(ptr)) __ret = (arg); \
12934 + switch (sizeof(*(ptr))) { \
12935 + case __X86_CASE_L: \
12936 + asm volatile (lock #op "l %0, %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 + case __X86_CASE_Q: \
12945 + asm volatile (lock #op "q %q0, %1\n" \
12946 + "jno 0f\n" \
12947 + "mov %0,%1\n" \
12948 + "int $4\n0:\n" \
12949 + _ASM_EXTABLE(0b, 0b) \
12950 + : "+r" (__ret), "+m" (*(ptr)) \
12951 + : : "memory", "cc"); \
12952 + break; \
12953 + default: \
12954 + __ ## op ## _check_overflow_wrong_size(); \
12955 + } \
12956 + __ret; \
12957 + })
12958 +
12959 /*
12960 * Note: no "lock" prefix even on SMP: xchg always implies lock anyway.
12961 * Since this is generally used to protect other memory information, we
12962 @@ -167,6 +199,9 @@ extern void __add_wrong_size(void)
12963 #define xadd_sync(ptr, inc) __xadd((ptr), (inc), "lock; ")
12964 #define xadd_local(ptr, inc) __xadd((ptr), (inc), "")
12965
12966 +#define __xadd_check_overflow(ptr, inc, lock) __xchg_op_check_overflow((ptr), (inc), xadd, lock)
12967 +#define xadd_check_overflow(ptr, inc) __xadd_check_overflow((ptr), (inc), LOCK_PREFIX)
12968 +
12969 #define __add(ptr, inc, lock) \
12970 ({ \
12971 __typeof__ (*(ptr)) __ret = (inc); \
12972 diff --git a/arch/x86/include/asm/cpufeature.h b/arch/x86/include/asm/cpufeature.h
12973 index 2d9075e..b75a844 100644
12974 --- a/arch/x86/include/asm/cpufeature.h
12975 +++ b/arch/x86/include/asm/cpufeature.h
12976 @@ -206,7 +206,7 @@
12977 #define X86_FEATURE_BMI1 (9*32+ 3) /* 1st group bit manipulation extensions */
12978 #define X86_FEATURE_HLE (9*32+ 4) /* Hardware Lock Elision */
12979 #define X86_FEATURE_AVX2 (9*32+ 5) /* AVX2 instructions */
12980 -#define X86_FEATURE_SMEP (9*32+ 7) /* Supervisor Mode Execution Protection */
12981 +#define X86_FEATURE_SMEP (9*32+ 7) /* Supervisor Mode Execution Prevention */
12982 #define X86_FEATURE_BMI2 (9*32+ 8) /* 2nd group bit manipulation extensions */
12983 #define X86_FEATURE_ERMS (9*32+ 9) /* Enhanced REP MOVSB/STOSB */
12984 #define X86_FEATURE_INVPCID (9*32+10) /* Invalidate Processor Context ID */
12985 @@ -375,7 +375,7 @@ static __always_inline __pure bool __static_cpu_has(u16 bit)
12986 ".section .discard,\"aw\",@progbits\n"
12987 " .byte 0xff + (4f-3f) - (2b-1b)\n" /* size check */
12988 ".previous\n"
12989 - ".section .altinstr_replacement,\"ax\"\n"
12990 + ".section .altinstr_replacement,\"a\"\n"
12991 "3: movb $1,%0\n"
12992 "4:\n"
12993 ".previous\n"
12994 diff --git a/arch/x86/include/asm/desc.h b/arch/x86/include/asm/desc.h
12995 index 8bf1c06..b6ae785 100644
12996 --- a/arch/x86/include/asm/desc.h
12997 +++ b/arch/x86/include/asm/desc.h
12998 @@ -4,6 +4,7 @@
12999 #include <asm/desc_defs.h>
13000 #include <asm/ldt.h>
13001 #include <asm/mmu.h>
13002 +#include <asm/pgtable.h>
13003
13004 #include <linux/smp.h>
13005 #include <linux/percpu.h>
13006 @@ -17,6 +18,7 @@ static inline void fill_ldt(struct desc_struct *desc, const struct user_desc *in
13007
13008 desc->type = (info->read_exec_only ^ 1) << 1;
13009 desc->type |= info->contents << 2;
13010 + desc->type |= info->seg_not_present ^ 1;
13011
13012 desc->s = 1;
13013 desc->dpl = 0x3;
13014 @@ -35,19 +37,14 @@ static inline void fill_ldt(struct desc_struct *desc, const struct user_desc *in
13015 }
13016
13017 extern struct desc_ptr idt_descr;
13018 -extern gate_desc idt_table[];
13019 extern struct desc_ptr nmi_idt_descr;
13020 -extern gate_desc nmi_idt_table[];
13021 -
13022 -struct gdt_page {
13023 - struct desc_struct gdt[GDT_ENTRIES];
13024 -} __attribute__((aligned(PAGE_SIZE)));
13025 -
13026 -DECLARE_PER_CPU_PAGE_ALIGNED(struct gdt_page, gdt_page);
13027 +extern gate_desc idt_table[256];
13028 +extern gate_desc nmi_idt_table[256];
13029
13030 +extern struct desc_struct cpu_gdt_table[NR_CPUS][PAGE_SIZE / sizeof(struct desc_struct)];
13031 static inline struct desc_struct *get_cpu_gdt_table(unsigned int cpu)
13032 {
13033 - return per_cpu(gdt_page, cpu).gdt;
13034 + return cpu_gdt_table[cpu];
13035 }
13036
13037 #ifdef CONFIG_X86_64
13038 @@ -72,8 +69,14 @@ static inline void pack_gate(gate_desc *gate, unsigned char type,
13039 unsigned long base, unsigned dpl, unsigned flags,
13040 unsigned short seg)
13041 {
13042 - gate->a = (seg << 16) | (base & 0xffff);
13043 - gate->b = (base & 0xffff0000) | (((0x80 | type | (dpl << 5)) & 0xff) << 8);
13044 + gate->gate.offset_low = base;
13045 + gate->gate.seg = seg;
13046 + gate->gate.reserved = 0;
13047 + gate->gate.type = type;
13048 + gate->gate.s = 0;
13049 + gate->gate.dpl = dpl;
13050 + gate->gate.p = 1;
13051 + gate->gate.offset_high = base >> 16;
13052 }
13053
13054 #endif
13055 @@ -118,12 +121,16 @@ static inline void paravirt_free_ldt(struct desc_struct *ldt, unsigned entries)
13056
13057 static inline void native_write_idt_entry(gate_desc *idt, int entry, const gate_desc *gate)
13058 {
13059 + pax_open_kernel();
13060 memcpy(&idt[entry], gate, sizeof(*gate));
13061 + pax_close_kernel();
13062 }
13063
13064 static inline void native_write_ldt_entry(struct desc_struct *ldt, int entry, const void *desc)
13065 {
13066 + pax_open_kernel();
13067 memcpy(&ldt[entry], desc, 8);
13068 + pax_close_kernel();
13069 }
13070
13071 static inline void
13072 @@ -137,7 +144,9 @@ native_write_gdt_entry(struct desc_struct *gdt, int entry, const void *desc, int
13073 default: size = sizeof(*gdt); break;
13074 }
13075
13076 + pax_open_kernel();
13077 memcpy(&gdt[entry], desc, size);
13078 + pax_close_kernel();
13079 }
13080
13081 static inline void pack_descriptor(struct desc_struct *desc, unsigned long base,
13082 @@ -210,7 +219,9 @@ static inline void native_set_ldt(const void *addr, unsigned int entries)
13083
13084 static inline void native_load_tr_desc(void)
13085 {
13086 + pax_open_kernel();
13087 asm volatile("ltr %w0"::"q" (GDT_ENTRY_TSS*8));
13088 + pax_close_kernel();
13089 }
13090
13091 static inline void native_load_gdt(const struct desc_ptr *dtr)
13092 @@ -247,8 +258,10 @@ static inline void native_load_tls(struct thread_struct *t, unsigned int cpu)
13093 struct desc_struct *gdt = get_cpu_gdt_table(cpu);
13094 unsigned int i;
13095
13096 + pax_open_kernel();
13097 for (i = 0; i < GDT_ENTRY_TLS_ENTRIES; i++)
13098 gdt[GDT_ENTRY_TLS_MIN + i] = t->tls_array[i];
13099 + pax_close_kernel();
13100 }
13101
13102 #define _LDT_empty(info) \
13103 @@ -287,7 +300,7 @@ static inline void load_LDT(mm_context_t *pc)
13104 preempt_enable();
13105 }
13106
13107 -static inline unsigned long get_desc_base(const struct desc_struct *desc)
13108 +static inline unsigned long __intentional_overflow(-1) get_desc_base(const struct desc_struct *desc)
13109 {
13110 return (unsigned)(desc->base0 | ((desc->base1) << 16) | ((desc->base2) << 24));
13111 }
13112 @@ -311,7 +324,7 @@ static inline void set_desc_limit(struct desc_struct *desc, unsigned long limit)
13113 }
13114
13115 #ifdef CONFIG_X86_64
13116 -static inline void set_nmi_gate(int gate, void *addr)
13117 +static inline void set_nmi_gate(int gate, const void *addr)
13118 {
13119 gate_desc s;
13120
13121 @@ -320,7 +333,7 @@ static inline void set_nmi_gate(int gate, void *addr)
13122 }
13123 #endif
13124
13125 -static inline void _set_gate(int gate, unsigned type, void *addr,
13126 +static inline void _set_gate(int gate, unsigned type, const void *addr,
13127 unsigned dpl, unsigned ist, unsigned seg)
13128 {
13129 gate_desc s;
13130 @@ -339,7 +352,7 @@ static inline void _set_gate(int gate, unsigned type, void *addr,
13131 * Pentium F0 0F bugfix can have resulted in the mapped
13132 * IDT being write-protected.
13133 */
13134 -static inline void set_intr_gate(unsigned int n, void *addr)
13135 +static inline void set_intr_gate(unsigned int n, const void *addr)
13136 {
13137 BUG_ON((unsigned)n > 0xFF);
13138 _set_gate(n, GATE_INTERRUPT, addr, 0, 0, __KERNEL_CS);
13139 @@ -369,19 +382,19 @@ static inline void alloc_intr_gate(unsigned int n, void *addr)
13140 /*
13141 * This routine sets up an interrupt gate at directory privilege level 3.
13142 */
13143 -static inline void set_system_intr_gate(unsigned int n, void *addr)
13144 +static inline void set_system_intr_gate(unsigned int n, const void *addr)
13145 {
13146 BUG_ON((unsigned)n > 0xFF);
13147 _set_gate(n, GATE_INTERRUPT, addr, 0x3, 0, __KERNEL_CS);
13148 }
13149
13150 -static inline void set_system_trap_gate(unsigned int n, void *addr)
13151 +static inline void set_system_trap_gate(unsigned int n, const void *addr)
13152 {
13153 BUG_ON((unsigned)n > 0xFF);
13154 _set_gate(n, GATE_TRAP, addr, 0x3, 0, __KERNEL_CS);
13155 }
13156
13157 -static inline void set_trap_gate(unsigned int n, void *addr)
13158 +static inline void set_trap_gate(unsigned int n, const void *addr)
13159 {
13160 BUG_ON((unsigned)n > 0xFF);
13161 _set_gate(n, GATE_TRAP, addr, 0, 0, __KERNEL_CS);
13162 @@ -390,19 +403,31 @@ static inline void set_trap_gate(unsigned int n, void *addr)
13163 static inline void set_task_gate(unsigned int n, unsigned int gdt_entry)
13164 {
13165 BUG_ON((unsigned)n > 0xFF);
13166 - _set_gate(n, GATE_TASK, (void *)0, 0, 0, (gdt_entry<<3));
13167 + _set_gate(n, GATE_TASK, (const void *)0, 0, 0, (gdt_entry<<3));
13168 }
13169
13170 -static inline void set_intr_gate_ist(int n, void *addr, unsigned ist)
13171 +static inline void set_intr_gate_ist(int n, const void *addr, unsigned ist)
13172 {
13173 BUG_ON((unsigned)n > 0xFF);
13174 _set_gate(n, GATE_INTERRUPT, addr, 0, ist, __KERNEL_CS);
13175 }
13176
13177 -static inline void set_system_intr_gate_ist(int n, void *addr, unsigned ist)
13178 +static inline void set_system_intr_gate_ist(int n, const void *addr, unsigned ist)
13179 {
13180 BUG_ON((unsigned)n > 0xFF);
13181 _set_gate(n, GATE_INTERRUPT, addr, 0x3, ist, __KERNEL_CS);
13182 }
13183
13184 +#ifdef CONFIG_X86_32
13185 +static inline void set_user_cs(unsigned long base, unsigned long limit, int cpu)
13186 +{
13187 + struct desc_struct d;
13188 +
13189 + if (likely(limit))
13190 + limit = (limit - 1UL) >> PAGE_SHIFT;
13191 + pack_descriptor(&d, base, limit, 0xFB, 0xC);
13192 + write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_DEFAULT_USER_CS, &d, DESCTYPE_S);
13193 +}
13194 +#endif
13195 +
13196 #endif /* _ASM_X86_DESC_H */
13197 diff --git a/arch/x86/include/asm/desc_defs.h b/arch/x86/include/asm/desc_defs.h
13198 index 278441f..b95a174 100644
13199 --- a/arch/x86/include/asm/desc_defs.h
13200 +++ b/arch/x86/include/asm/desc_defs.h
13201 @@ -31,6 +31,12 @@ struct desc_struct {
13202 unsigned base1: 8, type: 4, s: 1, dpl: 2, p: 1;
13203 unsigned limit: 4, avl: 1, l: 1, d: 1, g: 1, base2: 8;
13204 };
13205 + struct {
13206 + u16 offset_low;
13207 + u16 seg;
13208 + unsigned reserved: 8, type: 4, s: 1, dpl: 2, p: 1;
13209 + unsigned offset_high: 16;
13210 + } gate;
13211 };
13212 } __attribute__((packed));
13213
13214 diff --git a/arch/x86/include/asm/div64.h b/arch/x86/include/asm/div64.h
13215 index ced283a..ffe04cc 100644
13216 --- a/arch/x86/include/asm/div64.h
13217 +++ b/arch/x86/include/asm/div64.h
13218 @@ -39,7 +39,7 @@
13219 __mod; \
13220 })
13221
13222 -static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
13223 +static inline u64 __intentional_overflow(-1) div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
13224 {
13225 union {
13226 u64 v64;
13227 diff --git a/arch/x86/include/asm/elf.h b/arch/x86/include/asm/elf.h
13228 index 9c999c1..3860cb8 100644
13229 --- a/arch/x86/include/asm/elf.h
13230 +++ b/arch/x86/include/asm/elf.h
13231 @@ -243,7 +243,25 @@ extern int force_personality32;
13232 the loader. We need to make sure that it is out of the way of the program
13233 that it will "exec", and that there is sufficient room for the brk. */
13234
13235 +#ifdef CONFIG_PAX_SEGMEXEC
13236 +#define ELF_ET_DYN_BASE ((current->mm->pax_flags & MF_PAX_SEGMEXEC) ? SEGMEXEC_TASK_SIZE/3*2 : TASK_SIZE/3*2)
13237 +#else
13238 #define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
13239 +#endif
13240 +
13241 +#ifdef CONFIG_PAX_ASLR
13242 +#ifdef CONFIG_X86_32
13243 +#define PAX_ELF_ET_DYN_BASE 0x10000000UL
13244 +
13245 +#define PAX_DELTA_MMAP_LEN (current->mm->pax_flags & MF_PAX_SEGMEXEC ? 15 : 16)
13246 +#define PAX_DELTA_STACK_LEN (current->mm->pax_flags & MF_PAX_SEGMEXEC ? 15 : 16)
13247 +#else
13248 +#define PAX_ELF_ET_DYN_BASE 0x400000UL
13249 +
13250 +#define PAX_DELTA_MMAP_LEN ((test_thread_flag(TIF_ADDR32)) ? 16 : TASK_SIZE_MAX_SHIFT - PAGE_SHIFT - 3)
13251 +#define PAX_DELTA_STACK_LEN ((test_thread_flag(TIF_ADDR32)) ? 16 : TASK_SIZE_MAX_SHIFT - PAGE_SHIFT - 3)
13252 +#endif
13253 +#endif
13254
13255 /* This yields a mask that user programs can use to figure out what
13256 instruction set this CPU supports. This could be done in user space,
13257 @@ -296,16 +314,12 @@ do { \
13258
13259 #define ARCH_DLINFO \
13260 do { \
13261 - if (vdso_enabled) \
13262 - NEW_AUX_ENT(AT_SYSINFO_EHDR, \
13263 - (unsigned long)current->mm->context.vdso); \
13264 + NEW_AUX_ENT(AT_SYSINFO_EHDR, current->mm->context.vdso); \
13265 } while (0)
13266
13267 #define ARCH_DLINFO_X32 \
13268 do { \
13269 - if (vdso_enabled) \
13270 - NEW_AUX_ENT(AT_SYSINFO_EHDR, \
13271 - (unsigned long)current->mm->context.vdso); \
13272 + NEW_AUX_ENT(AT_SYSINFO_EHDR, current->mm->context.vdso); \
13273 } while (0)
13274
13275 #define AT_SYSINFO 32
13276 @@ -320,7 +334,7 @@ else \
13277
13278 #endif /* !CONFIG_X86_32 */
13279
13280 -#define VDSO_CURRENT_BASE ((unsigned long)current->mm->context.vdso)
13281 +#define VDSO_CURRENT_BASE (current->mm->context.vdso)
13282
13283 #define VDSO_ENTRY \
13284 ((unsigned long)VDSO32_SYMBOL(VDSO_CURRENT_BASE, vsyscall))
13285 @@ -336,9 +350,6 @@ extern int x32_setup_additional_pages(struct linux_binprm *bprm,
13286 extern int syscall32_setup_pages(struct linux_binprm *, int exstack);
13287 #define compat_arch_setup_additional_pages syscall32_setup_pages
13288
13289 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
13290 -#define arch_randomize_brk arch_randomize_brk
13291 -
13292 /*
13293 * True on X86_32 or when emulating IA32 on X86_64
13294 */
13295 diff --git a/arch/x86/include/asm/emergency-restart.h b/arch/x86/include/asm/emergency-restart.h
13296 index 75ce3f4..882e801 100644
13297 --- a/arch/x86/include/asm/emergency-restart.h
13298 +++ b/arch/x86/include/asm/emergency-restart.h
13299 @@ -13,6 +13,6 @@ enum reboot_type {
13300
13301 extern enum reboot_type reboot_type;
13302
13303 -extern void machine_emergency_restart(void);
13304 +extern void machine_emergency_restart(void) __noreturn;
13305
13306 #endif /* _ASM_X86_EMERGENCY_RESTART_H */
13307 diff --git a/arch/x86/include/asm/fpu-internal.h b/arch/x86/include/asm/fpu-internal.h
13308 index 41ab26e..a88c9e6 100644
13309 --- a/arch/x86/include/asm/fpu-internal.h
13310 +++ b/arch/x86/include/asm/fpu-internal.h
13311 @@ -126,7 +126,9 @@ static inline void sanitize_i387_state(struct task_struct *tsk)
13312 ({ \
13313 int err; \
13314 asm volatile(ASM_STAC "\n" \
13315 - "1:" #insn "\n\t" \
13316 + "1:" \
13317 + __copyuser_seg \
13318 + #insn "\n\t" \
13319 "2: " ASM_CLAC "\n" \
13320 ".section .fixup,\"ax\"\n" \
13321 "3: movl $-1,%[err]\n" \
13322 @@ -299,7 +301,7 @@ static inline int restore_fpu_checking(struct task_struct *tsk)
13323 "emms\n\t" /* clear stack tags */
13324 "fildl %P[addr]", /* set F?P to defined value */
13325 X86_FEATURE_FXSAVE_LEAK,
13326 - [addr] "m" (tsk->thread.fpu.has_fpu));
13327 + [addr] "m" (init_tss[raw_smp_processor_id()].x86_tss.sp0));
13328
13329 return fpu_restore_checking(&tsk->thread.fpu);
13330 }
13331 diff --git a/arch/x86/include/asm/futex.h b/arch/x86/include/asm/futex.h
13332 index be27ba1..8f13ff9 100644
13333 --- a/arch/x86/include/asm/futex.h
13334 +++ b/arch/x86/include/asm/futex.h
13335 @@ -12,6 +12,7 @@
13336 #include <asm/smap.h>
13337
13338 #define __futex_atomic_op1(insn, ret, oldval, uaddr, oparg) \
13339 + typecheck(u32 __user *, uaddr); \
13340 asm volatile("\t" ASM_STAC "\n" \
13341 "1:\t" insn "\n" \
13342 "2:\t" ASM_CLAC "\n" \
13343 @@ -20,15 +21,16 @@
13344 "\tjmp\t2b\n" \
13345 "\t.previous\n" \
13346 _ASM_EXTABLE(1b, 3b) \
13347 - : "=r" (oldval), "=r" (ret), "+m" (*uaddr) \
13348 + : "=r" (oldval), "=r" (ret), "+m" (*(u32 __user *)____m(uaddr)) \
13349 : "i" (-EFAULT), "0" (oparg), "1" (0))
13350
13351 #define __futex_atomic_op2(insn, ret, oldval, uaddr, oparg) \
13352 + typecheck(u32 __user *, uaddr); \
13353 asm volatile("\t" ASM_STAC "\n" \
13354 "1:\tmovl %2, %0\n" \
13355 "\tmovl\t%0, %3\n" \
13356 "\t" insn "\n" \
13357 - "2:\t" LOCK_PREFIX "cmpxchgl %3, %2\n" \
13358 + "2:\t" LOCK_PREFIX __copyuser_seg"cmpxchgl %3, %2\n" \
13359 "\tjnz\t1b\n" \
13360 "3:\t" ASM_CLAC "\n" \
13361 "\t.section .fixup,\"ax\"\n" \
13362 @@ -38,7 +40,7 @@
13363 _ASM_EXTABLE(1b, 4b) \
13364 _ASM_EXTABLE(2b, 4b) \
13365 : "=&a" (oldval), "=&r" (ret), \
13366 - "+m" (*uaddr), "=&r" (tem) \
13367 + "+m" (*(u32 __user *)____m(uaddr)), "=&r" (tem) \
13368 : "r" (oparg), "i" (-EFAULT), "1" (0))
13369
13370 static inline int futex_atomic_op_inuser(int encoded_op, u32 __user *uaddr)
13371 @@ -59,10 +61,10 @@ static inline int futex_atomic_op_inuser(int encoded_op, u32 __user *uaddr)
13372
13373 switch (op) {
13374 case FUTEX_OP_SET:
13375 - __futex_atomic_op1("xchgl %0, %2", ret, oldval, uaddr, oparg);
13376 + __futex_atomic_op1(__copyuser_seg"xchgl %0, %2", ret, oldval, uaddr, oparg);
13377 break;
13378 case FUTEX_OP_ADD:
13379 - __futex_atomic_op1(LOCK_PREFIX "xaddl %0, %2", ret, oldval,
13380 + __futex_atomic_op1(LOCK_PREFIX __copyuser_seg"xaddl %0, %2", ret, oldval,
13381 uaddr, oparg);
13382 break;
13383 case FUTEX_OP_OR:
13384 @@ -116,14 +118,14 @@ static inline int futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
13385 return -EFAULT;
13386
13387 asm volatile("\t" ASM_STAC "\n"
13388 - "1:\t" LOCK_PREFIX "cmpxchgl %4, %2\n"
13389 + "1:\t" LOCK_PREFIX __copyuser_seg"cmpxchgl %4, %2\n"
13390 "2:\t" ASM_CLAC "\n"
13391 "\t.section .fixup, \"ax\"\n"
13392 "3:\tmov %3, %0\n"
13393 "\tjmp 2b\n"
13394 "\t.previous\n"
13395 _ASM_EXTABLE(1b, 3b)
13396 - : "+r" (ret), "=a" (oldval), "+m" (*uaddr)
13397 + : "+r" (ret), "=a" (oldval), "+m" (*(u32 __user *)____m(uaddr))
13398 : "i" (-EFAULT), "r" (newval), "1" (oldval)
13399 : "memory"
13400 );
13401 diff --git a/arch/x86/include/asm/hw_irq.h b/arch/x86/include/asm/hw_irq.h
13402 index eb92a6e..b98b2f4 100644
13403 --- a/arch/x86/include/asm/hw_irq.h
13404 +++ b/arch/x86/include/asm/hw_irq.h
13405 @@ -136,8 +136,8 @@ extern void setup_ioapic_dest(void);
13406 extern void enable_IO_APIC(void);
13407
13408 /* Statistics */
13409 -extern atomic_t irq_err_count;
13410 -extern atomic_t irq_mis_count;
13411 +extern atomic_unchecked_t irq_err_count;
13412 +extern atomic_unchecked_t irq_mis_count;
13413
13414 /* EISA */
13415 extern void eisa_set_level_irq(unsigned int irq);
13416 diff --git a/arch/x86/include/asm/i8259.h b/arch/x86/include/asm/i8259.h
13417 index a203659..9889f1c 100644
13418 --- a/arch/x86/include/asm/i8259.h
13419 +++ b/arch/x86/include/asm/i8259.h
13420 @@ -62,7 +62,7 @@ struct legacy_pic {
13421 void (*init)(int auto_eoi);
13422 int (*irq_pending)(unsigned int irq);
13423 void (*make_irq)(unsigned int irq);
13424 -};
13425 +} __do_const;
13426
13427 extern struct legacy_pic *legacy_pic;
13428 extern struct legacy_pic null_legacy_pic;
13429 diff --git a/arch/x86/include/asm/io.h b/arch/x86/include/asm/io.h
13430 index d8e8eef..1765f78 100644
13431 --- a/arch/x86/include/asm/io.h
13432 +++ b/arch/x86/include/asm/io.h
13433 @@ -51,12 +51,12 @@ static inline void name(type val, volatile void __iomem *addr) \
13434 "m" (*(volatile type __force *)addr) barrier); }
13435
13436 build_mmio_read(readb, "b", unsigned char, "=q", :"memory")
13437 -build_mmio_read(readw, "w", unsigned short, "=r", :"memory")
13438 -build_mmio_read(readl, "l", unsigned int, "=r", :"memory")
13439 +build_mmio_read(__intentional_overflow(-1) readw, "w", unsigned short, "=r", :"memory")
13440 +build_mmio_read(__intentional_overflow(-1) readl, "l", unsigned int, "=r", :"memory")
13441
13442 build_mmio_read(__readb, "b", unsigned char, "=q", )
13443 -build_mmio_read(__readw, "w", unsigned short, "=r", )
13444 -build_mmio_read(__readl, "l", unsigned int, "=r", )
13445 +build_mmio_read(__intentional_overflow(-1) __readw, "w", unsigned short, "=r", )
13446 +build_mmio_read(__intentional_overflow(-1) __readl, "l", unsigned int, "=r", )
13447
13448 build_mmio_write(writeb, "b", unsigned char, "q", :"memory")
13449 build_mmio_write(writew, "w", unsigned short, "r", :"memory")
13450 @@ -184,7 +184,7 @@ static inline void __iomem *ioremap(resource_size_t offset, unsigned long size)
13451 return ioremap_nocache(offset, size);
13452 }
13453
13454 -extern void iounmap(volatile void __iomem *addr);
13455 +extern void iounmap(const volatile void __iomem *addr);
13456
13457 extern void set_iounmap_nonlazy(void);
13458
13459 @@ -194,6 +194,17 @@ extern void set_iounmap_nonlazy(void);
13460
13461 #include <linux/vmalloc.h>
13462
13463 +#define ARCH_HAS_VALID_PHYS_ADDR_RANGE
13464 +static inline int valid_phys_addr_range(unsigned long addr, size_t count)
13465 +{
13466 + return ((addr + count + PAGE_SIZE - 1) >> PAGE_SHIFT) < (1ULL << (boot_cpu_data.x86_phys_bits - PAGE_SHIFT)) ? 1 : 0;
13467 +}
13468 +
13469 +static inline int valid_mmap_phys_addr_range(unsigned long pfn, size_t count)
13470 +{
13471 + return (pfn + (count >> PAGE_SHIFT)) < (1ULL << (boot_cpu_data.x86_phys_bits - PAGE_SHIFT)) ? 1 : 0;
13472 +}
13473 +
13474 /*
13475 * Convert a virtual cached pointer to an uncached pointer
13476 */
13477 diff --git a/arch/x86/include/asm/irqflags.h b/arch/x86/include/asm/irqflags.h
13478 index bba3cf8..06bc8da 100644
13479 --- a/arch/x86/include/asm/irqflags.h
13480 +++ b/arch/x86/include/asm/irqflags.h
13481 @@ -141,6 +141,11 @@ static inline notrace unsigned long arch_local_irq_save(void)
13482 sti; \
13483 sysexit
13484
13485 +#define GET_CR0_INTO_RDI mov %cr0, %rdi
13486 +#define SET_RDI_INTO_CR0 mov %rdi, %cr0
13487 +#define GET_CR3_INTO_RDI mov %cr3, %rdi
13488 +#define SET_RDI_INTO_CR3 mov %rdi, %cr3
13489 +
13490 #else
13491 #define INTERRUPT_RETURN iret
13492 #define ENABLE_INTERRUPTS_SYSEXIT sti; sysexit
13493 diff --git a/arch/x86/include/asm/kprobes.h b/arch/x86/include/asm/kprobes.h
13494 index d3ddd17..c9fb0cc 100644
13495 --- a/arch/x86/include/asm/kprobes.h
13496 +++ b/arch/x86/include/asm/kprobes.h
13497 @@ -38,13 +38,8 @@ typedef u8 kprobe_opcode_t;
13498 #define RELATIVEJUMP_SIZE 5
13499 #define RELATIVECALL_OPCODE 0xe8
13500 #define RELATIVE_ADDR_SIZE 4
13501 -#define MAX_STACK_SIZE 64
13502 -#define MIN_STACK_SIZE(ADDR) \
13503 - (((MAX_STACK_SIZE) < (((unsigned long)current_thread_info()) + \
13504 - THREAD_SIZE - (unsigned long)(ADDR))) \
13505 - ? (MAX_STACK_SIZE) \
13506 - : (((unsigned long)current_thread_info()) + \
13507 - THREAD_SIZE - (unsigned long)(ADDR)))
13508 +#define MAX_STACK_SIZE 64UL
13509 +#define MIN_STACK_SIZE(ADDR) min(MAX_STACK_SIZE, current->thread.sp0 - (unsigned long)(ADDR))
13510
13511 #define flush_insn_slot(p) do { } while (0)
13512
13513 diff --git a/arch/x86/include/asm/local.h b/arch/x86/include/asm/local.h
13514 index 2d89e39..baee879 100644
13515 --- a/arch/x86/include/asm/local.h
13516 +++ b/arch/x86/include/asm/local.h
13517 @@ -10,33 +10,97 @@ typedef struct {
13518 atomic_long_t a;
13519 } local_t;
13520
13521 +typedef struct {
13522 + atomic_long_unchecked_t a;
13523 +} local_unchecked_t;
13524 +
13525 #define LOCAL_INIT(i) { ATOMIC_LONG_INIT(i) }
13526
13527 #define local_read(l) atomic_long_read(&(l)->a)
13528 +#define local_read_unchecked(l) atomic_long_read_unchecked(&(l)->a)
13529 #define local_set(l, i) atomic_long_set(&(l)->a, (i))
13530 +#define local_set_unchecked(l, i) atomic_long_set_unchecked(&(l)->a, (i))
13531
13532 static inline void local_inc(local_t *l)
13533 {
13534 - asm volatile(_ASM_INC "%0"
13535 + asm volatile(_ASM_INC "%0\n"
13536 +
13537 +#ifdef CONFIG_PAX_REFCOUNT
13538 + "jno 0f\n"
13539 + _ASM_DEC "%0\n"
13540 + "int $4\n0:\n"
13541 + _ASM_EXTABLE(0b, 0b)
13542 +#endif
13543 +
13544 + : "+m" (l->a.counter));
13545 +}
13546 +
13547 +static inline void local_inc_unchecked(local_unchecked_t *l)
13548 +{
13549 + asm volatile(_ASM_INC "%0\n"
13550 : "+m" (l->a.counter));
13551 }
13552
13553 static inline void local_dec(local_t *l)
13554 {
13555 - asm volatile(_ASM_DEC "%0"
13556 + asm volatile(_ASM_DEC "%0\n"
13557 +
13558 +#ifdef CONFIG_PAX_REFCOUNT
13559 + "jno 0f\n"
13560 + _ASM_INC "%0\n"
13561 + "int $4\n0:\n"
13562 + _ASM_EXTABLE(0b, 0b)
13563 +#endif
13564 +
13565 + : "+m" (l->a.counter));
13566 +}
13567 +
13568 +static inline void local_dec_unchecked(local_unchecked_t *l)
13569 +{
13570 + asm volatile(_ASM_DEC "%0\n"
13571 : "+m" (l->a.counter));
13572 }
13573
13574 static inline void local_add(long i, local_t *l)
13575 {
13576 - asm volatile(_ASM_ADD "%1,%0"
13577 + asm volatile(_ASM_ADD "%1,%0\n"
13578 +
13579 +#ifdef CONFIG_PAX_REFCOUNT
13580 + "jno 0f\n"
13581 + _ASM_SUB "%1,%0\n"
13582 + "int $4\n0:\n"
13583 + _ASM_EXTABLE(0b, 0b)
13584 +#endif
13585 +
13586 + : "+m" (l->a.counter)
13587 + : "ir" (i));
13588 +}
13589 +
13590 +static inline void local_add_unchecked(long i, local_unchecked_t *l)
13591 +{
13592 + asm volatile(_ASM_ADD "%1,%0\n"
13593 : "+m" (l->a.counter)
13594 : "ir" (i));
13595 }
13596
13597 static inline void local_sub(long i, local_t *l)
13598 {
13599 - asm volatile(_ASM_SUB "%1,%0"
13600 + asm volatile(_ASM_SUB "%1,%0\n"
13601 +
13602 +#ifdef CONFIG_PAX_REFCOUNT
13603 + "jno 0f\n"
13604 + _ASM_ADD "%1,%0\n"
13605 + "int $4\n0:\n"
13606 + _ASM_EXTABLE(0b, 0b)
13607 +#endif
13608 +
13609 + : "+m" (l->a.counter)
13610 + : "ir" (i));
13611 +}
13612 +
13613 +static inline void local_sub_unchecked(long i, local_unchecked_t *l)
13614 +{
13615 + asm volatile(_ASM_SUB "%1,%0\n"
13616 : "+m" (l->a.counter)
13617 : "ir" (i));
13618 }
13619 @@ -54,7 +118,16 @@ static inline int local_sub_and_test(long i, local_t *l)
13620 {
13621 unsigned char c;
13622
13623 - asm volatile(_ASM_SUB "%2,%0; sete %1"
13624 + asm volatile(_ASM_SUB "%2,%0\n"
13625 +
13626 +#ifdef CONFIG_PAX_REFCOUNT
13627 + "jno 0f\n"
13628 + _ASM_ADD "%2,%0\n"
13629 + "int $4\n0:\n"
13630 + _ASM_EXTABLE(0b, 0b)
13631 +#endif
13632 +
13633 + "sete %1\n"
13634 : "+m" (l->a.counter), "=qm" (c)
13635 : "ir" (i) : "memory");
13636 return c;
13637 @@ -72,7 +145,16 @@ static inline int local_dec_and_test(local_t *l)
13638 {
13639 unsigned char c;
13640
13641 - asm volatile(_ASM_DEC "%0; sete %1"
13642 + asm volatile(_ASM_DEC "%0\n"
13643 +
13644 +#ifdef CONFIG_PAX_REFCOUNT
13645 + "jno 0f\n"
13646 + _ASM_INC "%0\n"
13647 + "int $4\n0:\n"
13648 + _ASM_EXTABLE(0b, 0b)
13649 +#endif
13650 +
13651 + "sete %1\n"
13652 : "+m" (l->a.counter), "=qm" (c)
13653 : : "memory");
13654 return c != 0;
13655 @@ -90,7 +172,16 @@ static inline int local_inc_and_test(local_t *l)
13656 {
13657 unsigned char c;
13658
13659 - asm volatile(_ASM_INC "%0; sete %1"
13660 + asm volatile(_ASM_INC "%0\n"
13661 +
13662 +#ifdef CONFIG_PAX_REFCOUNT
13663 + "jno 0f\n"
13664 + _ASM_DEC "%0\n"
13665 + "int $4\n0:\n"
13666 + _ASM_EXTABLE(0b, 0b)
13667 +#endif
13668 +
13669 + "sete %1\n"
13670 : "+m" (l->a.counter), "=qm" (c)
13671 : : "memory");
13672 return c != 0;
13673 @@ -109,7 +200,16 @@ static inline int local_add_negative(long i, local_t *l)
13674 {
13675 unsigned char c;
13676
13677 - asm volatile(_ASM_ADD "%2,%0; sets %1"
13678 + asm volatile(_ASM_ADD "%2,%0\n"
13679 +
13680 +#ifdef CONFIG_PAX_REFCOUNT
13681 + "jno 0f\n"
13682 + _ASM_SUB "%2,%0\n"
13683 + "int $4\n0:\n"
13684 + _ASM_EXTABLE(0b, 0b)
13685 +#endif
13686 +
13687 + "sets %1\n"
13688 : "+m" (l->a.counter), "=qm" (c)
13689 : "ir" (i) : "memory");
13690 return c;
13691 @@ -125,6 +225,30 @@ static inline int local_add_negative(long i, local_t *l)
13692 static inline long local_add_return(long i, local_t *l)
13693 {
13694 long __i = i;
13695 + asm volatile(_ASM_XADD "%0, %1\n"
13696 +
13697 +#ifdef CONFIG_PAX_REFCOUNT
13698 + "jno 0f\n"
13699 + _ASM_MOV "%0,%1\n"
13700 + "int $4\n0:\n"
13701 + _ASM_EXTABLE(0b, 0b)
13702 +#endif
13703 +
13704 + : "+r" (i), "+m" (l->a.counter)
13705 + : : "memory");
13706 + return i + __i;
13707 +}
13708 +
13709 +/**
13710 + * local_add_return_unchecked - add and return
13711 + * @i: integer value to add
13712 + * @l: pointer to type local_unchecked_t
13713 + *
13714 + * Atomically adds @i to @l and returns @i + @l
13715 + */
13716 +static inline long local_add_return_unchecked(long i, local_unchecked_t *l)
13717 +{
13718 + long __i = i;
13719 asm volatile(_ASM_XADD "%0, %1;"
13720 : "+r" (i), "+m" (l->a.counter)
13721 : : "memory");
13722 @@ -141,6 +265,8 @@ static inline long local_sub_return(long i, local_t *l)
13723
13724 #define local_cmpxchg(l, o, n) \
13725 (cmpxchg_local(&((l)->a.counter), (o), (n)))
13726 +#define local_cmpxchg_unchecked(l, o, n) \
13727 + (cmpxchg_local(&((l)->a.counter), (o), (n)))
13728 /* Always has a lock prefix */
13729 #define local_xchg(l, n) (xchg(&((l)->a.counter), (n)))
13730
13731 diff --git a/arch/x86/include/asm/mman.h b/arch/x86/include/asm/mman.h
13732 new file mode 100644
13733 index 0000000..2bfd3ba
13734 --- /dev/null
13735 +++ b/arch/x86/include/asm/mman.h
13736 @@ -0,0 +1,15 @@
13737 +#ifndef _X86_MMAN_H
13738 +#define _X86_MMAN_H
13739 +
13740 +#include <uapi/asm/mman.h>
13741 +
13742 +#ifdef __KERNEL__
13743 +#ifndef __ASSEMBLY__
13744 +#ifdef CONFIG_X86_32
13745 +#define arch_mmap_check i386_mmap_check
13746 +int i386_mmap_check(unsigned long addr, unsigned long len, unsigned long flags);
13747 +#endif
13748 +#endif
13749 +#endif
13750 +
13751 +#endif /* X86_MMAN_H */
13752 diff --git a/arch/x86/include/asm/mmu.h b/arch/x86/include/asm/mmu.h
13753 index 5f55e69..e20bfb1 100644
13754 --- a/arch/x86/include/asm/mmu.h
13755 +++ b/arch/x86/include/asm/mmu.h
13756 @@ -9,7 +9,7 @@
13757 * we put the segment information here.
13758 */
13759 typedef struct {
13760 - void *ldt;
13761 + struct desc_struct *ldt;
13762 int size;
13763
13764 #ifdef CONFIG_X86_64
13765 @@ -18,7 +18,19 @@ typedef struct {
13766 #endif
13767
13768 struct mutex lock;
13769 - void *vdso;
13770 + unsigned long vdso;
13771 +
13772 +#ifdef CONFIG_X86_32
13773 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
13774 + unsigned long user_cs_base;
13775 + unsigned long user_cs_limit;
13776 +
13777 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_SMP)
13778 + cpumask_t cpu_user_cs_mask;
13779 +#endif
13780 +
13781 +#endif
13782 +#endif
13783 } mm_context_t;
13784
13785 #ifdef CONFIG_SMP
13786 diff --git a/arch/x86/include/asm/mmu_context.h b/arch/x86/include/asm/mmu_context.h
13787 index cdbf367..adb37ac 100644
13788 --- a/arch/x86/include/asm/mmu_context.h
13789 +++ b/arch/x86/include/asm/mmu_context.h
13790 @@ -24,6 +24,18 @@ void destroy_context(struct mm_struct *mm);
13791
13792 static inline void enter_lazy_tlb(struct mm_struct *mm, struct task_struct *tsk)
13793 {
13794 +
13795 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
13796 + unsigned int i;
13797 + pgd_t *pgd;
13798 +
13799 + pax_open_kernel();
13800 + pgd = get_cpu_pgd(smp_processor_id());
13801 + for (i = USER_PGD_PTRS; i < 2 * USER_PGD_PTRS; ++i)
13802 + set_pgd_batched(pgd+i, native_make_pgd(0));
13803 + pax_close_kernel();
13804 +#endif
13805 +
13806 #ifdef CONFIG_SMP
13807 if (this_cpu_read(cpu_tlbstate.state) == TLBSTATE_OK)
13808 this_cpu_write(cpu_tlbstate.state, TLBSTATE_LAZY);
13809 @@ -34,16 +46,30 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
13810 struct task_struct *tsk)
13811 {
13812 unsigned cpu = smp_processor_id();
13813 +#if defined(CONFIG_X86_32) && defined(CONFIG_SMP) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
13814 + int tlbstate = TLBSTATE_OK;
13815 +#endif
13816
13817 if (likely(prev != next)) {
13818 #ifdef CONFIG_SMP
13819 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
13820 + tlbstate = this_cpu_read(cpu_tlbstate.state);
13821 +#endif
13822 this_cpu_write(cpu_tlbstate.state, TLBSTATE_OK);
13823 this_cpu_write(cpu_tlbstate.active_mm, next);
13824 #endif
13825 cpumask_set_cpu(cpu, mm_cpumask(next));
13826
13827 /* Re-load page tables */
13828 +#ifdef CONFIG_PAX_PER_CPU_PGD
13829 + pax_open_kernel();
13830 + __clone_user_pgds(get_cpu_pgd(cpu), next->pgd);
13831 + __shadow_user_pgds(get_cpu_pgd(cpu) + USER_PGD_PTRS, next->pgd);
13832 + pax_close_kernel();
13833 + load_cr3(get_cpu_pgd(cpu));
13834 +#else
13835 load_cr3(next->pgd);
13836 +#endif
13837
13838 /* stop flush ipis for the previous mm */
13839 cpumask_clear_cpu(cpu, mm_cpumask(prev));
13840 @@ -53,9 +79,38 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
13841 */
13842 if (unlikely(prev->context.ldt != next->context.ldt))
13843 load_LDT_nolock(&next->context);
13844 - }
13845 +
13846 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_SMP)
13847 + if (!(__supported_pte_mask & _PAGE_NX)) {
13848 + smp_mb__before_clear_bit();
13849 + cpu_clear(cpu, prev->context.cpu_user_cs_mask);
13850 + smp_mb__after_clear_bit();
13851 + cpu_set(cpu, next->context.cpu_user_cs_mask);
13852 + }
13853 +#endif
13854 +
13855 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
13856 + if (unlikely(prev->context.user_cs_base != next->context.user_cs_base ||
13857 + prev->context.user_cs_limit != next->context.user_cs_limit))
13858 + set_user_cs(next->context.user_cs_base, next->context.user_cs_limit, cpu);
13859 #ifdef CONFIG_SMP
13860 + else if (unlikely(tlbstate != TLBSTATE_OK))
13861 + set_user_cs(next->context.user_cs_base, next->context.user_cs_limit, cpu);
13862 +#endif
13863 +#endif
13864 +
13865 + }
13866 else {
13867 +
13868 +#ifdef CONFIG_PAX_PER_CPU_PGD
13869 + pax_open_kernel();
13870 + __clone_user_pgds(get_cpu_pgd(cpu), next->pgd);
13871 + __shadow_user_pgds(get_cpu_pgd(cpu) + USER_PGD_PTRS, next->pgd);
13872 + pax_close_kernel();
13873 + load_cr3(get_cpu_pgd(cpu));
13874 +#endif
13875 +
13876 +#ifdef CONFIG_SMP
13877 this_cpu_write(cpu_tlbstate.state, TLBSTATE_OK);
13878 BUG_ON(this_cpu_read(cpu_tlbstate.active_mm) != next);
13879
13880 @@ -64,11 +119,28 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
13881 * tlb flush IPI delivery. We must reload CR3
13882 * to make sure to use no freed page tables.
13883 */
13884 +
13885 +#ifndef CONFIG_PAX_PER_CPU_PGD
13886 load_cr3(next->pgd);
13887 +#endif
13888 +
13889 load_LDT_nolock(&next->context);
13890 +
13891 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
13892 + if (!(__supported_pte_mask & _PAGE_NX))
13893 + cpu_set(cpu, next->context.cpu_user_cs_mask);
13894 +#endif
13895 +
13896 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
13897 +#ifdef CONFIG_PAX_PAGEEXEC
13898 + if (!((next->pax_flags & MF_PAX_PAGEEXEC) && (__supported_pte_mask & _PAGE_NX)))
13899 +#endif
13900 + set_user_cs(next->context.user_cs_base, next->context.user_cs_limit, cpu);
13901 +#endif
13902 +
13903 }
13904 +#endif
13905 }
13906 -#endif
13907 }
13908
13909 #define activate_mm(prev, next) \
13910 diff --git a/arch/x86/include/asm/module.h b/arch/x86/include/asm/module.h
13911 index e3b7819..b257c64 100644
13912 --- a/arch/x86/include/asm/module.h
13913 +++ b/arch/x86/include/asm/module.h
13914 @@ -5,6 +5,7 @@
13915
13916 #ifdef CONFIG_X86_64
13917 /* X86_64 does not define MODULE_PROC_FAMILY */
13918 +#define MODULE_PROC_FAMILY ""
13919 #elif defined CONFIG_M486
13920 #define MODULE_PROC_FAMILY "486 "
13921 #elif defined CONFIG_M586
13922 @@ -57,8 +58,20 @@
13923 #error unknown processor family
13924 #endif
13925
13926 -#ifdef CONFIG_X86_32
13927 -# define MODULE_ARCH_VERMAGIC MODULE_PROC_FAMILY
13928 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_BTS
13929 +#define MODULE_PAX_KERNEXEC "KERNEXEC_BTS "
13930 +#elif defined(CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR)
13931 +#define MODULE_PAX_KERNEXEC "KERNEXEC_OR "
13932 +#else
13933 +#define MODULE_PAX_KERNEXEC ""
13934 #endif
13935
13936 +#ifdef CONFIG_PAX_MEMORY_UDEREF
13937 +#define MODULE_PAX_UDEREF "UDEREF "
13938 +#else
13939 +#define MODULE_PAX_UDEREF ""
13940 +#endif
13941 +
13942 +#define MODULE_ARCH_VERMAGIC MODULE_PROC_FAMILY MODULE_PAX_KERNEXEC MODULE_PAX_UDEREF
13943 +
13944 #endif /* _ASM_X86_MODULE_H */
13945 diff --git a/arch/x86/include/asm/nmi.h b/arch/x86/include/asm/nmi.h
13946 index c0fa356..07a498a 100644
13947 --- a/arch/x86/include/asm/nmi.h
13948 +++ b/arch/x86/include/asm/nmi.h
13949 @@ -42,11 +42,11 @@ struct nmiaction {
13950 nmi_handler_t handler;
13951 unsigned long flags;
13952 const char *name;
13953 -};
13954 +} __do_const;
13955
13956 #define register_nmi_handler(t, fn, fg, n, init...) \
13957 ({ \
13958 - static struct nmiaction init fn##_na = { \
13959 + static const struct nmiaction init fn##_na = { \
13960 .handler = (fn), \
13961 .name = (n), \
13962 .flags = (fg), \
13963 @@ -54,7 +54,7 @@ struct nmiaction {
13964 __register_nmi_handler((t), &fn##_na); \
13965 })
13966
13967 -int __register_nmi_handler(unsigned int, struct nmiaction *);
13968 +int __register_nmi_handler(unsigned int, const struct nmiaction *);
13969
13970 void unregister_nmi_handler(unsigned int, const char *);
13971
13972 diff --git a/arch/x86/include/asm/page_64_types.h b/arch/x86/include/asm/page_64_types.h
13973 index 320f7bb..e89f8f8 100644
13974 --- a/arch/x86/include/asm/page_64_types.h
13975 +++ b/arch/x86/include/asm/page_64_types.h
13976 @@ -56,7 +56,7 @@ void copy_page(void *to, void *from);
13977
13978 /* duplicated to the one in bootmem.h */
13979 extern unsigned long max_pfn;
13980 -extern unsigned long phys_base;
13981 +extern const unsigned long phys_base;
13982
13983 extern unsigned long __phys_addr(unsigned long);
13984 #define __phys_reloc_hide(x) (x)
13985 diff --git a/arch/x86/include/asm/paravirt.h b/arch/x86/include/asm/paravirt.h
13986 index 5edd174..c395822 100644
13987 --- a/arch/x86/include/asm/paravirt.h
13988 +++ b/arch/x86/include/asm/paravirt.h
13989 @@ -564,7 +564,7 @@ static inline pmd_t __pmd(pmdval_t val)
13990 return (pmd_t) { ret };
13991 }
13992
13993 -static inline pmdval_t pmd_val(pmd_t pmd)
13994 +static inline __intentional_overflow(-1) pmdval_t pmd_val(pmd_t pmd)
13995 {
13996 pmdval_t ret;
13997
13998 @@ -630,6 +630,18 @@ static inline void set_pgd(pgd_t *pgdp, pgd_t pgd)
13999 val);
14000 }
14001
14002 +static inline void set_pgd_batched(pgd_t *pgdp, pgd_t pgd)
14003 +{
14004 + pgdval_t val = native_pgd_val(pgd);
14005 +
14006 + if (sizeof(pgdval_t) > sizeof(long))
14007 + PVOP_VCALL3(pv_mmu_ops.set_pgd_batched, pgdp,
14008 + val, (u64)val >> 32);
14009 + else
14010 + PVOP_VCALL2(pv_mmu_ops.set_pgd_batched, pgdp,
14011 + val);
14012 +}
14013 +
14014 static inline void pgd_clear(pgd_t *pgdp)
14015 {
14016 set_pgd(pgdp, __pgd(0));
14017 @@ -711,6 +723,21 @@ static inline void __set_fixmap(unsigned /* enum fixed_addresses */ idx,
14018 pv_mmu_ops.set_fixmap(idx, phys, flags);
14019 }
14020
14021 +#ifdef CONFIG_PAX_KERNEXEC
14022 +static inline unsigned long pax_open_kernel(void)
14023 +{
14024 + return PVOP_CALL0(unsigned long, pv_mmu_ops.pax_open_kernel);
14025 +}
14026 +
14027 +static inline unsigned long pax_close_kernel(void)
14028 +{
14029 + return PVOP_CALL0(unsigned long, pv_mmu_ops.pax_close_kernel);
14030 +}
14031 +#else
14032 +static inline unsigned long pax_open_kernel(void) { return 0; }
14033 +static inline unsigned long pax_close_kernel(void) { return 0; }
14034 +#endif
14035 +
14036 #if defined(CONFIG_SMP) && defined(CONFIG_PARAVIRT_SPINLOCKS)
14037
14038 static inline int arch_spin_is_locked(struct arch_spinlock *lock)
14039 @@ -927,7 +954,7 @@ extern void default_banner(void);
14040
14041 #define PARA_PATCH(struct, off) ((PARAVIRT_PATCH_##struct + (off)) / 4)
14042 #define PARA_SITE(ptype, clobbers, ops) _PVSITE(ptype, clobbers, ops, .long, 4)
14043 -#define PARA_INDIRECT(addr) *%cs:addr
14044 +#define PARA_INDIRECT(addr) *%ss:addr
14045 #endif
14046
14047 #define INTERRUPT_RETURN \
14048 @@ -1002,6 +1029,21 @@ extern void default_banner(void);
14049 PARA_SITE(PARA_PATCH(pv_cpu_ops, PV_CPU_irq_enable_sysexit), \
14050 CLBR_NONE, \
14051 jmp PARA_INDIRECT(pv_cpu_ops+PV_CPU_irq_enable_sysexit))
14052 +
14053 +#define GET_CR0_INTO_RDI \
14054 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_read_cr0); \
14055 + mov %rax,%rdi
14056 +
14057 +#define SET_RDI_INTO_CR0 \
14058 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_write_cr0)
14059 +
14060 +#define GET_CR3_INTO_RDI \
14061 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_read_cr3); \
14062 + mov %rax,%rdi
14063 +
14064 +#define SET_RDI_INTO_CR3 \
14065 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_write_cr3)
14066 +
14067 #endif /* CONFIG_X86_32 */
14068
14069 #endif /* __ASSEMBLY__ */
14070 diff --git a/arch/x86/include/asm/paravirt_types.h b/arch/x86/include/asm/paravirt_types.h
14071 index 142236e..5446ffbc 100644
14072 --- a/arch/x86/include/asm/paravirt_types.h
14073 +++ b/arch/x86/include/asm/paravirt_types.h
14074 @@ -84,7 +84,7 @@ struct pv_init_ops {
14075 */
14076 unsigned (*patch)(u8 type, u16 clobber, void *insnbuf,
14077 unsigned long addr, unsigned len);
14078 -};
14079 +} __no_const;
14080
14081
14082 struct pv_lazy_ops {
14083 @@ -97,7 +97,7 @@ struct pv_time_ops {
14084 unsigned long long (*sched_clock)(void);
14085 unsigned long long (*steal_clock)(int cpu);
14086 unsigned long (*get_tsc_khz)(void);
14087 -};
14088 +} __no_const;
14089
14090 struct pv_cpu_ops {
14091 /* hooks for various privileged instructions */
14092 @@ -191,7 +191,7 @@ struct pv_cpu_ops {
14093
14094 void (*start_context_switch)(struct task_struct *prev);
14095 void (*end_context_switch)(struct task_struct *next);
14096 -};
14097 +} __no_const;
14098
14099 struct pv_irq_ops {
14100 /*
14101 @@ -222,7 +222,7 @@ struct pv_apic_ops {
14102 unsigned long start_eip,
14103 unsigned long start_esp);
14104 #endif
14105 -};
14106 +} __no_const;
14107
14108 struct pv_mmu_ops {
14109 unsigned long (*read_cr2)(void);
14110 @@ -312,6 +312,7 @@ struct pv_mmu_ops {
14111 struct paravirt_callee_save make_pud;
14112
14113 void (*set_pgd)(pgd_t *pudp, pgd_t pgdval);
14114 + void (*set_pgd_batched)(pgd_t *pudp, pgd_t pgdval);
14115 #endif /* PAGETABLE_LEVELS == 4 */
14116 #endif /* PAGETABLE_LEVELS >= 3 */
14117
14118 @@ -323,6 +324,12 @@ struct pv_mmu_ops {
14119 an mfn. We can tell which is which from the index. */
14120 void (*set_fixmap)(unsigned /* enum fixed_addresses */ idx,
14121 phys_addr_t phys, pgprot_t flags);
14122 +
14123 +#ifdef CONFIG_PAX_KERNEXEC
14124 + unsigned long (*pax_open_kernel)(void);
14125 + unsigned long (*pax_close_kernel)(void);
14126 +#endif
14127 +
14128 };
14129
14130 struct arch_spinlock;
14131 @@ -333,7 +340,7 @@ struct pv_lock_ops {
14132 void (*spin_lock_flags)(struct arch_spinlock *lock, unsigned long flags);
14133 int (*spin_trylock)(struct arch_spinlock *lock);
14134 void (*spin_unlock)(struct arch_spinlock *lock);
14135 -};
14136 +} __no_const;
14137
14138 /* This contains all the paravirt structures: we get a convenient
14139 * number for each function using the offset which we use to indicate
14140 diff --git a/arch/x86/include/asm/pgalloc.h b/arch/x86/include/asm/pgalloc.h
14141 index b4389a4..7024269 100644
14142 --- a/arch/x86/include/asm/pgalloc.h
14143 +++ b/arch/x86/include/asm/pgalloc.h
14144 @@ -63,6 +63,13 @@ static inline void pmd_populate_kernel(struct mm_struct *mm,
14145 pmd_t *pmd, pte_t *pte)
14146 {
14147 paravirt_alloc_pte(mm, __pa(pte) >> PAGE_SHIFT);
14148 + set_pmd(pmd, __pmd(__pa(pte) | _KERNPG_TABLE));
14149 +}
14150 +
14151 +static inline void pmd_populate_user(struct mm_struct *mm,
14152 + pmd_t *pmd, pte_t *pte)
14153 +{
14154 + paravirt_alloc_pte(mm, __pa(pte) >> PAGE_SHIFT);
14155 set_pmd(pmd, __pmd(__pa(pte) | _PAGE_TABLE));
14156 }
14157
14158 @@ -99,12 +106,22 @@ static inline void __pmd_free_tlb(struct mmu_gather *tlb, pmd_t *pmd,
14159
14160 #ifdef CONFIG_X86_PAE
14161 extern void pud_populate(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd);
14162 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd)
14163 +{
14164 + pud_populate(mm, pudp, pmd);
14165 +}
14166 #else /* !CONFIG_X86_PAE */
14167 static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
14168 {
14169 paravirt_alloc_pmd(mm, __pa(pmd) >> PAGE_SHIFT);
14170 set_pud(pud, __pud(_PAGE_TABLE | __pa(pmd)));
14171 }
14172 +
14173 +static inline void pud_populate_kernel(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(_KERNPG_TABLE | __pa(pmd)));
14177 +}
14178 #endif /* CONFIG_X86_PAE */
14179
14180 #if PAGETABLE_LEVELS > 3
14181 @@ -114,6 +131,12 @@ static inline void pgd_populate(struct mm_struct *mm, pgd_t *pgd, pud_t *pud)
14182 set_pgd(pgd, __pgd(_PAGE_TABLE | __pa(pud)));
14183 }
14184
14185 +static inline void pgd_populate_kernel(struct mm_struct *mm, pgd_t *pgd, pud_t *pud)
14186 +{
14187 + paravirt_alloc_pud(mm, __pa(pud) >> PAGE_SHIFT);
14188 + set_pgd(pgd, __pgd(_KERNPG_TABLE | __pa(pud)));
14189 +}
14190 +
14191 static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr)
14192 {
14193 return (pud_t *)get_zeroed_page(GFP_KERNEL|__GFP_REPEAT);
14194 diff --git a/arch/x86/include/asm/pgtable-2level.h b/arch/x86/include/asm/pgtable-2level.h
14195 index f2b489c..4f7e2e5 100644
14196 --- a/arch/x86/include/asm/pgtable-2level.h
14197 +++ b/arch/x86/include/asm/pgtable-2level.h
14198 @@ -18,7 +18,9 @@ static inline void native_set_pte(pte_t *ptep , pte_t pte)
14199
14200 static inline void native_set_pmd(pmd_t *pmdp, pmd_t pmd)
14201 {
14202 + pax_open_kernel();
14203 *pmdp = pmd;
14204 + pax_close_kernel();
14205 }
14206
14207 static inline void native_set_pte_atomic(pte_t *ptep, pte_t pte)
14208 diff --git a/arch/x86/include/asm/pgtable-3level.h b/arch/x86/include/asm/pgtable-3level.h
14209 index 4cc9f2b..5fd9226 100644
14210 --- a/arch/x86/include/asm/pgtable-3level.h
14211 +++ b/arch/x86/include/asm/pgtable-3level.h
14212 @@ -92,12 +92,16 @@ static inline void native_set_pte_atomic(pte_t *ptep, pte_t pte)
14213
14214 static inline void native_set_pmd(pmd_t *pmdp, pmd_t pmd)
14215 {
14216 + pax_open_kernel();
14217 set_64bit((unsigned long long *)(pmdp), native_pmd_val(pmd));
14218 + pax_close_kernel();
14219 }
14220
14221 static inline void native_set_pud(pud_t *pudp, pud_t pud)
14222 {
14223 + pax_open_kernel();
14224 set_64bit((unsigned long long *)(pudp), native_pud_val(pud));
14225 + pax_close_kernel();
14226 }
14227
14228 /*
14229 diff --git a/arch/x86/include/asm/pgtable.h b/arch/x86/include/asm/pgtable.h
14230 index 1c1a955..50f828c 100644
14231 --- a/arch/x86/include/asm/pgtable.h
14232 +++ b/arch/x86/include/asm/pgtable.h
14233 @@ -44,6 +44,7 @@ extern struct mm_struct *pgd_page_get_mm(struct page *page);
14234
14235 #ifndef __PAGETABLE_PUD_FOLDED
14236 #define set_pgd(pgdp, pgd) native_set_pgd(pgdp, pgd)
14237 +#define set_pgd_batched(pgdp, pgd) native_set_pgd_batched(pgdp, pgd)
14238 #define pgd_clear(pgd) native_pgd_clear(pgd)
14239 #endif
14240
14241 @@ -81,12 +82,51 @@ extern struct mm_struct *pgd_page_get_mm(struct page *page);
14242
14243 #define arch_end_context_switch(prev) do {} while(0)
14244
14245 +#define pax_open_kernel() native_pax_open_kernel()
14246 +#define pax_close_kernel() native_pax_close_kernel()
14247 #endif /* CONFIG_PARAVIRT */
14248
14249 +#define __HAVE_ARCH_PAX_OPEN_KERNEL
14250 +#define __HAVE_ARCH_PAX_CLOSE_KERNEL
14251 +
14252 +#ifdef CONFIG_PAX_KERNEXEC
14253 +static inline unsigned long native_pax_open_kernel(void)
14254 +{
14255 + unsigned long cr0;
14256 +
14257 + preempt_disable();
14258 + barrier();
14259 + cr0 = read_cr0() ^ X86_CR0_WP;
14260 + BUG_ON(cr0 & X86_CR0_WP);
14261 + write_cr0(cr0);
14262 + return cr0 ^ X86_CR0_WP;
14263 +}
14264 +
14265 +static inline unsigned long native_pax_close_kernel(void)
14266 +{
14267 + unsigned long cr0;
14268 +
14269 + cr0 = read_cr0() ^ X86_CR0_WP;
14270 + BUG_ON(!(cr0 & X86_CR0_WP));
14271 + write_cr0(cr0);
14272 + barrier();
14273 + preempt_enable_no_resched();
14274 + return cr0 ^ X86_CR0_WP;
14275 +}
14276 +#else
14277 +static inline unsigned long native_pax_open_kernel(void) { return 0; }
14278 +static inline unsigned long native_pax_close_kernel(void) { return 0; }
14279 +#endif
14280 +
14281 /*
14282 * The following only work if pte_present() is true.
14283 * Undefined behaviour if not..
14284 */
14285 +static inline int pte_user(pte_t pte)
14286 +{
14287 + return pte_val(pte) & _PAGE_USER;
14288 +}
14289 +
14290 static inline int pte_dirty(pte_t pte)
14291 {
14292 return pte_flags(pte) & _PAGE_DIRTY;
14293 @@ -200,9 +240,29 @@ static inline pte_t pte_wrprotect(pte_t pte)
14294 return pte_clear_flags(pte, _PAGE_RW);
14295 }
14296
14297 +static inline pte_t pte_mkread(pte_t pte)
14298 +{
14299 + return __pte(pte_val(pte) | _PAGE_USER);
14300 +}
14301 +
14302 static inline pte_t pte_mkexec(pte_t pte)
14303 {
14304 - return pte_clear_flags(pte, _PAGE_NX);
14305 +#ifdef CONFIG_X86_PAE
14306 + if (__supported_pte_mask & _PAGE_NX)
14307 + return pte_clear_flags(pte, _PAGE_NX);
14308 + else
14309 +#endif
14310 + return pte_set_flags(pte, _PAGE_USER);
14311 +}
14312 +
14313 +static inline pte_t pte_exprotect(pte_t pte)
14314 +{
14315 +#ifdef CONFIG_X86_PAE
14316 + if (__supported_pte_mask & _PAGE_NX)
14317 + return pte_set_flags(pte, _PAGE_NX);
14318 + else
14319 +#endif
14320 + return pte_clear_flags(pte, _PAGE_USER);
14321 }
14322
14323 static inline pte_t pte_mkdirty(pte_t pte)
14324 @@ -394,6 +454,15 @@ pte_t *populate_extra_pte(unsigned long vaddr);
14325 #endif
14326
14327 #ifndef __ASSEMBLY__
14328 +
14329 +#ifdef CONFIG_PAX_PER_CPU_PGD
14330 +extern pgd_t cpu_pgd[NR_CPUS][PTRS_PER_PGD];
14331 +static inline pgd_t *get_cpu_pgd(unsigned int cpu)
14332 +{
14333 + return cpu_pgd[cpu];
14334 +}
14335 +#endif
14336 +
14337 #include <linux/mm_types.h>
14338
14339 static inline int pte_none(pte_t pte)
14340 @@ -583,7 +652,7 @@ static inline pud_t *pud_offset(pgd_t *pgd, unsigned long address)
14341
14342 static inline int pgd_bad(pgd_t pgd)
14343 {
14344 - return (pgd_flags(pgd) & ~_PAGE_USER) != _KERNPG_TABLE;
14345 + return (pgd_flags(pgd) & ~(_PAGE_USER | _PAGE_NX)) != _KERNPG_TABLE;
14346 }
14347
14348 static inline int pgd_none(pgd_t pgd)
14349 @@ -606,7 +675,12 @@ static inline int pgd_none(pgd_t pgd)
14350 * pgd_offset() returns a (pgd_t *)
14351 * pgd_index() is used get the offset into the pgd page's array of pgd_t's;
14352 */
14353 -#define pgd_offset(mm, address) ((mm)->pgd + pgd_index((address)))
14354 +#define pgd_offset(mm, address) ((mm)->pgd + pgd_index(address))
14355 +
14356 +#ifdef CONFIG_PAX_PER_CPU_PGD
14357 +#define pgd_offset_cpu(cpu, address) (get_cpu_pgd(cpu) + pgd_index(address))
14358 +#endif
14359 +
14360 /*
14361 * a shortcut which implies the use of the kernel's pgd, instead
14362 * of a process's
14363 @@ -617,6 +691,20 @@ static inline int pgd_none(pgd_t pgd)
14364 #define KERNEL_PGD_BOUNDARY pgd_index(PAGE_OFFSET)
14365 #define KERNEL_PGD_PTRS (PTRS_PER_PGD - KERNEL_PGD_BOUNDARY)
14366
14367 +#ifdef CONFIG_X86_32
14368 +#define USER_PGD_PTRS KERNEL_PGD_BOUNDARY
14369 +#else
14370 +#define TASK_SIZE_MAX_SHIFT CONFIG_TASK_SIZE_MAX_SHIFT
14371 +#define USER_PGD_PTRS (_AC(1,UL) << (TASK_SIZE_MAX_SHIFT - PGDIR_SHIFT))
14372 +
14373 +#ifdef CONFIG_PAX_MEMORY_UDEREF
14374 +#define PAX_USER_SHADOW_BASE (_AC(1,UL) << TASK_SIZE_MAX_SHIFT)
14375 +#else
14376 +#define PAX_USER_SHADOW_BASE (_AC(0,UL))
14377 +#endif
14378 +
14379 +#endif
14380 +
14381 #ifndef __ASSEMBLY__
14382
14383 extern int direct_gbpages;
14384 @@ -781,11 +869,23 @@ static inline void pmdp_set_wrprotect(struct mm_struct *mm,
14385 * dst and src can be on the same page, but the range must not overlap,
14386 * and must not cross a page boundary.
14387 */
14388 -static inline void clone_pgd_range(pgd_t *dst, pgd_t *src, int count)
14389 +static inline void clone_pgd_range(pgd_t *dst, const pgd_t *src, int count)
14390 {
14391 - memcpy(dst, src, count * sizeof(pgd_t));
14392 + pax_open_kernel();
14393 + while (count--)
14394 + *dst++ = *src++;
14395 + pax_close_kernel();
14396 }
14397
14398 +#ifdef CONFIG_PAX_PER_CPU_PGD
14399 +extern void __clone_user_pgds(pgd_t *dst, const pgd_t *src);
14400 +#endif
14401 +
14402 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
14403 +extern void __shadow_user_pgds(pgd_t *dst, const pgd_t *src);
14404 +#else
14405 +static inline void __shadow_user_pgds(pgd_t *dst, const pgd_t *src) {}
14406 +#endif
14407
14408 #include <asm-generic/pgtable.h>
14409 #endif /* __ASSEMBLY__ */
14410 diff --git a/arch/x86/include/asm/pgtable_32.h b/arch/x86/include/asm/pgtable_32.h
14411 index 8faa215..a8a17ea 100644
14412 --- a/arch/x86/include/asm/pgtable_32.h
14413 +++ b/arch/x86/include/asm/pgtable_32.h
14414 @@ -25,9 +25,6 @@
14415 struct mm_struct;
14416 struct vm_area_struct;
14417
14418 -extern pgd_t swapper_pg_dir[1024];
14419 -extern pgd_t initial_page_table[1024];
14420 -
14421 static inline void pgtable_cache_init(void) { }
14422 static inline void check_pgt_cache(void) { }
14423 void paging_init(void);
14424 @@ -48,6 +45,12 @@ extern void set_pmd_pfn(unsigned long, unsigned long, pgprot_t);
14425 # include <asm/pgtable-2level.h>
14426 #endif
14427
14428 +extern pgd_t swapper_pg_dir[PTRS_PER_PGD];
14429 +extern pgd_t initial_page_table[PTRS_PER_PGD];
14430 +#ifdef CONFIG_X86_PAE
14431 +extern pmd_t swapper_pm_dir[PTRS_PER_PGD][PTRS_PER_PMD];
14432 +#endif
14433 +
14434 #if defined(CONFIG_HIGHPTE)
14435 #define pte_offset_map(dir, address) \
14436 ((pte_t *)kmap_atomic(pmd_page(*(dir))) + \
14437 @@ -62,7 +65,9 @@ extern void set_pmd_pfn(unsigned long, unsigned long, pgprot_t);
14438 /* Clear a kernel PTE and flush it from the TLB */
14439 #define kpte_clear_flush(ptep, vaddr) \
14440 do { \
14441 + pax_open_kernel(); \
14442 pte_clear(&init_mm, (vaddr), (ptep)); \
14443 + pax_close_kernel(); \
14444 __flush_tlb_one((vaddr)); \
14445 } while (0)
14446
14447 @@ -75,6 +80,9 @@ do { \
14448
14449 #endif /* !__ASSEMBLY__ */
14450
14451 +#define HAVE_ARCH_UNMAPPED_AREA
14452 +#define HAVE_ARCH_UNMAPPED_AREA_TOPDOWN
14453 +
14454 /*
14455 * kern_addr_valid() is (1) for FLATMEM and (0) for
14456 * SPARSEMEM and DISCONTIGMEM
14457 diff --git a/arch/x86/include/asm/pgtable_32_types.h b/arch/x86/include/asm/pgtable_32_types.h
14458 index ed5903b..c7fe163 100644
14459 --- a/arch/x86/include/asm/pgtable_32_types.h
14460 +++ b/arch/x86/include/asm/pgtable_32_types.h
14461 @@ -8,7 +8,7 @@
14462 */
14463 #ifdef CONFIG_X86_PAE
14464 # include <asm/pgtable-3level_types.h>
14465 -# define PMD_SIZE (1UL << PMD_SHIFT)
14466 +# define PMD_SIZE (_AC(1, UL) << PMD_SHIFT)
14467 # define PMD_MASK (~(PMD_SIZE - 1))
14468 #else
14469 # include <asm/pgtable-2level_types.h>
14470 @@ -46,6 +46,19 @@ extern bool __vmalloc_start_set; /* set once high_memory is set */
14471 # define VMALLOC_END (FIXADDR_START - 2 * PAGE_SIZE)
14472 #endif
14473
14474 +#ifdef CONFIG_PAX_KERNEXEC
14475 +#ifndef __ASSEMBLY__
14476 +extern unsigned char MODULES_EXEC_VADDR[];
14477 +extern unsigned char MODULES_EXEC_END[];
14478 +#endif
14479 +#include <asm/boot.h>
14480 +#define ktla_ktva(addr) (addr + LOAD_PHYSICAL_ADDR + PAGE_OFFSET)
14481 +#define ktva_ktla(addr) (addr - LOAD_PHYSICAL_ADDR - PAGE_OFFSET)
14482 +#else
14483 +#define ktla_ktva(addr) (addr)
14484 +#define ktva_ktla(addr) (addr)
14485 +#endif
14486 +
14487 #define MODULES_VADDR VMALLOC_START
14488 #define MODULES_END VMALLOC_END
14489 #define MODULES_LEN (MODULES_VADDR - MODULES_END)
14490 diff --git a/arch/x86/include/asm/pgtable_64.h b/arch/x86/include/asm/pgtable_64.h
14491 index 47356f9..deb94a2 100644
14492 --- a/arch/x86/include/asm/pgtable_64.h
14493 +++ b/arch/x86/include/asm/pgtable_64.h
14494 @@ -16,10 +16,14 @@
14495
14496 extern pud_t level3_kernel_pgt[512];
14497 extern pud_t level3_ident_pgt[512];
14498 +extern pud_t level3_vmalloc_start_pgt[512];
14499 +extern pud_t level3_vmalloc_end_pgt[512];
14500 +extern pud_t level3_vmemmap_pgt[512];
14501 +extern pud_t level2_vmemmap_pgt[512];
14502 extern pmd_t level2_kernel_pgt[512];
14503 extern pmd_t level2_fixmap_pgt[512];
14504 -extern pmd_t level2_ident_pgt[512];
14505 -extern pgd_t init_level4_pgt[];
14506 +extern pmd_t level2_ident_pgt[512*2];
14507 +extern pgd_t init_level4_pgt[512];
14508
14509 #define swapper_pg_dir init_level4_pgt
14510
14511 @@ -61,7 +65,9 @@ static inline void native_set_pte_atomic(pte_t *ptep, pte_t pte)
14512
14513 static inline void native_set_pmd(pmd_t *pmdp, pmd_t pmd)
14514 {
14515 + pax_open_kernel();
14516 *pmdp = pmd;
14517 + pax_close_kernel();
14518 }
14519
14520 static inline void native_pmd_clear(pmd_t *pmd)
14521 @@ -97,7 +103,9 @@ static inline pmd_t native_pmdp_get_and_clear(pmd_t *xp)
14522
14523 static inline void native_set_pud(pud_t *pudp, pud_t pud)
14524 {
14525 + pax_open_kernel();
14526 *pudp = pud;
14527 + pax_close_kernel();
14528 }
14529
14530 static inline void native_pud_clear(pud_t *pud)
14531 @@ -107,6 +115,13 @@ static inline void native_pud_clear(pud_t *pud)
14532
14533 static inline void native_set_pgd(pgd_t *pgdp, pgd_t pgd)
14534 {
14535 + pax_open_kernel();
14536 + *pgdp = pgd;
14537 + pax_close_kernel();
14538 +}
14539 +
14540 +static inline void native_set_pgd_batched(pgd_t *pgdp, pgd_t pgd)
14541 +{
14542 *pgdp = pgd;
14543 }
14544
14545 diff --git a/arch/x86/include/asm/pgtable_64_types.h b/arch/x86/include/asm/pgtable_64_types.h
14546 index 766ea16..5b96cb3 100644
14547 --- a/arch/x86/include/asm/pgtable_64_types.h
14548 +++ b/arch/x86/include/asm/pgtable_64_types.h
14549 @@ -59,5 +59,10 @@ typedef struct { pteval_t pte; } pte_t;
14550 #define MODULES_VADDR _AC(0xffffffffa0000000, UL)
14551 #define MODULES_END _AC(0xffffffffff000000, UL)
14552 #define MODULES_LEN (MODULES_END - MODULES_VADDR)
14553 +#define MODULES_EXEC_VADDR MODULES_VADDR
14554 +#define MODULES_EXEC_END MODULES_END
14555 +
14556 +#define ktla_ktva(addr) (addr)
14557 +#define ktva_ktla(addr) (addr)
14558
14559 #endif /* _ASM_X86_PGTABLE_64_DEFS_H */
14560 diff --git a/arch/x86/include/asm/pgtable_types.h b/arch/x86/include/asm/pgtable_types.h
14561 index 3c32db8..1ddccf5 100644
14562 --- a/arch/x86/include/asm/pgtable_types.h
14563 +++ b/arch/x86/include/asm/pgtable_types.h
14564 @@ -16,13 +16,12 @@
14565 #define _PAGE_BIT_PSE 7 /* 4 MB (or 2MB) page */
14566 #define _PAGE_BIT_PAT 7 /* on 4KB pages */
14567 #define _PAGE_BIT_GLOBAL 8 /* Global TLB entry PPro+ */
14568 -#define _PAGE_BIT_UNUSED1 9 /* available for programmer */
14569 +#define _PAGE_BIT_SPECIAL 9 /* special mappings, no associated struct page */
14570 #define _PAGE_BIT_IOMAP 10 /* flag used to indicate IO mapping */
14571 #define _PAGE_BIT_HIDDEN 11 /* hidden by kmemcheck */
14572 #define _PAGE_BIT_PAT_LARGE 12 /* On 2MB or 1GB pages */
14573 -#define _PAGE_BIT_SPECIAL _PAGE_BIT_UNUSED1
14574 -#define _PAGE_BIT_CPA_TEST _PAGE_BIT_UNUSED1
14575 -#define _PAGE_BIT_SPLITTING _PAGE_BIT_UNUSED1 /* only valid on a PSE pmd */
14576 +#define _PAGE_BIT_CPA_TEST _PAGE_BIT_SPECIAL
14577 +#define _PAGE_BIT_SPLITTING _PAGE_BIT_SPECIAL /* only valid on a PSE pmd */
14578 #define _PAGE_BIT_NX 63 /* No execute: only valid after cpuid check */
14579
14580 /* If _PAGE_BIT_PRESENT is clear, we use these: */
14581 @@ -40,7 +39,6 @@
14582 #define _PAGE_DIRTY (_AT(pteval_t, 1) << _PAGE_BIT_DIRTY)
14583 #define _PAGE_PSE (_AT(pteval_t, 1) << _PAGE_BIT_PSE)
14584 #define _PAGE_GLOBAL (_AT(pteval_t, 1) << _PAGE_BIT_GLOBAL)
14585 -#define _PAGE_UNUSED1 (_AT(pteval_t, 1) << _PAGE_BIT_UNUSED1)
14586 #define _PAGE_IOMAP (_AT(pteval_t, 1) << _PAGE_BIT_IOMAP)
14587 #define _PAGE_PAT (_AT(pteval_t, 1) << _PAGE_BIT_PAT)
14588 #define _PAGE_PAT_LARGE (_AT(pteval_t, 1) << _PAGE_BIT_PAT_LARGE)
14589 @@ -57,8 +55,10 @@
14590
14591 #if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
14592 #define _PAGE_NX (_AT(pteval_t, 1) << _PAGE_BIT_NX)
14593 -#else
14594 +#elif defined(CONFIG_KMEMCHECK)
14595 #define _PAGE_NX (_AT(pteval_t, 0))
14596 +#else
14597 +#define _PAGE_NX (_AT(pteval_t, 1) << _PAGE_BIT_HIDDEN)
14598 #endif
14599
14600 #define _PAGE_FILE (_AT(pteval_t, 1) << _PAGE_BIT_FILE)
14601 @@ -116,6 +116,9 @@
14602 #define PAGE_READONLY_EXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | \
14603 _PAGE_ACCESSED)
14604
14605 +#define PAGE_READONLY_NOEXEC PAGE_READONLY
14606 +#define PAGE_SHARED_NOEXEC PAGE_SHARED
14607 +
14608 #define __PAGE_KERNEL_EXEC \
14609 (_PAGE_PRESENT | _PAGE_RW | _PAGE_DIRTY | _PAGE_ACCESSED | _PAGE_GLOBAL)
14610 #define __PAGE_KERNEL (__PAGE_KERNEL_EXEC | _PAGE_NX)
14611 @@ -126,7 +129,7 @@
14612 #define __PAGE_KERNEL_WC (__PAGE_KERNEL | _PAGE_CACHE_WC)
14613 #define __PAGE_KERNEL_NOCACHE (__PAGE_KERNEL | _PAGE_PCD | _PAGE_PWT)
14614 #define __PAGE_KERNEL_UC_MINUS (__PAGE_KERNEL | _PAGE_PCD)
14615 -#define __PAGE_KERNEL_VSYSCALL (__PAGE_KERNEL_RX | _PAGE_USER)
14616 +#define __PAGE_KERNEL_VSYSCALL (__PAGE_KERNEL_RO | _PAGE_USER)
14617 #define __PAGE_KERNEL_VVAR (__PAGE_KERNEL_RO | _PAGE_USER)
14618 #define __PAGE_KERNEL_VVAR_NOCACHE (__PAGE_KERNEL_VVAR | _PAGE_PCD | _PAGE_PWT)
14619 #define __PAGE_KERNEL_LARGE (__PAGE_KERNEL | _PAGE_PSE)
14620 @@ -188,8 +191,8 @@
14621 * bits are combined, this will alow user to access the high address mapped
14622 * VDSO in the presence of CONFIG_COMPAT_VDSO
14623 */
14624 -#define PTE_IDENT_ATTR 0x003 /* PRESENT+RW */
14625 -#define PDE_IDENT_ATTR 0x067 /* PRESENT+RW+USER+DIRTY+ACCESSED */
14626 +#define PTE_IDENT_ATTR 0x063 /* PRESENT+RW+DIRTY+ACCESSED */
14627 +#define PDE_IDENT_ATTR 0x063 /* PRESENT+RW+DIRTY+ACCESSED */
14628 #define PGD_IDENT_ATTR 0x001 /* PRESENT (no other attributes) */
14629 #endif
14630
14631 @@ -227,7 +230,17 @@ static inline pgdval_t pgd_flags(pgd_t pgd)
14632 {
14633 return native_pgd_val(pgd) & PTE_FLAGS_MASK;
14634 }
14635 +#endif
14636
14637 +#if PAGETABLE_LEVELS == 3
14638 +#include <asm-generic/pgtable-nopud.h>
14639 +#endif
14640 +
14641 +#if PAGETABLE_LEVELS == 2
14642 +#include <asm-generic/pgtable-nopmd.h>
14643 +#endif
14644 +
14645 +#ifndef __ASSEMBLY__
14646 #if PAGETABLE_LEVELS > 3
14647 typedef struct { pudval_t pud; } pud_t;
14648
14649 @@ -241,8 +254,6 @@ static inline pudval_t native_pud_val(pud_t pud)
14650 return pud.pud;
14651 }
14652 #else
14653 -#include <asm-generic/pgtable-nopud.h>
14654 -
14655 static inline pudval_t native_pud_val(pud_t pud)
14656 {
14657 return native_pgd_val(pud.pgd);
14658 @@ -262,8 +273,6 @@ static inline pmdval_t native_pmd_val(pmd_t pmd)
14659 return pmd.pmd;
14660 }
14661 #else
14662 -#include <asm-generic/pgtable-nopmd.h>
14663 -
14664 static inline pmdval_t native_pmd_val(pmd_t pmd)
14665 {
14666 return native_pgd_val(pmd.pud.pgd);
14667 @@ -303,7 +312,6 @@ typedef struct page *pgtable_t;
14668
14669 extern pteval_t __supported_pte_mask;
14670 extern void set_nx(void);
14671 -extern int nx_enabled;
14672
14673 #define pgprot_writecombine pgprot_writecombine
14674 extern pgprot_t pgprot_writecombine(pgprot_t prot);
14675 diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h
14676 index 888184b..a07ac89 100644
14677 --- a/arch/x86/include/asm/processor.h
14678 +++ b/arch/x86/include/asm/processor.h
14679 @@ -287,7 +287,7 @@ struct tss_struct {
14680
14681 } ____cacheline_aligned;
14682
14683 -DECLARE_PER_CPU_SHARED_ALIGNED(struct tss_struct, init_tss);
14684 +extern struct tss_struct init_tss[NR_CPUS];
14685
14686 /*
14687 * Save the original ist values for checking stack pointers during debugging
14688 @@ -827,11 +827,18 @@ static inline void spin_lock_prefetch(const void *x)
14689 */
14690 #define TASK_SIZE PAGE_OFFSET
14691 #define TASK_SIZE_MAX TASK_SIZE
14692 +
14693 +#ifdef CONFIG_PAX_SEGMEXEC
14694 +#define SEGMEXEC_TASK_SIZE (TASK_SIZE / 2)
14695 +#define STACK_TOP ((current->mm->pax_flags & MF_PAX_SEGMEXEC)?SEGMEXEC_TASK_SIZE:TASK_SIZE)
14696 +#else
14697 #define STACK_TOP TASK_SIZE
14698 -#define STACK_TOP_MAX STACK_TOP
14699 +#endif
14700 +
14701 +#define STACK_TOP_MAX TASK_SIZE
14702
14703 #define INIT_THREAD { \
14704 - .sp0 = sizeof(init_stack) + (long)&init_stack, \
14705 + .sp0 = sizeof(init_stack) + (long)&init_stack - 8, \
14706 .vm86_info = NULL, \
14707 .sysenter_cs = __KERNEL_CS, \
14708 .io_bitmap_ptr = NULL, \
14709 @@ -845,7 +852,7 @@ static inline void spin_lock_prefetch(const void *x)
14710 */
14711 #define INIT_TSS { \
14712 .x86_tss = { \
14713 - .sp0 = sizeof(init_stack) + (long)&init_stack, \
14714 + .sp0 = sizeof(init_stack) + (long)&init_stack - 8, \
14715 .ss0 = __KERNEL_DS, \
14716 .ss1 = __KERNEL_CS, \
14717 .io_bitmap_base = INVALID_IO_BITMAP_OFFSET, \
14718 @@ -856,11 +863,7 @@ static inline void spin_lock_prefetch(const void *x)
14719 extern unsigned long thread_saved_pc(struct task_struct *tsk);
14720
14721 #define THREAD_SIZE_LONGS (THREAD_SIZE/sizeof(unsigned long))
14722 -#define KSTK_TOP(info) \
14723 -({ \
14724 - unsigned long *__ptr = (unsigned long *)(info); \
14725 - (unsigned long)(&__ptr[THREAD_SIZE_LONGS]); \
14726 -})
14727 +#define KSTK_TOP(info) ((container_of(info, struct task_struct, tinfo))->thread.sp0)
14728
14729 /*
14730 * The below -8 is to reserve 8 bytes on top of the ring0 stack.
14731 @@ -875,7 +878,7 @@ extern unsigned long thread_saved_pc(struct task_struct *tsk);
14732 #define task_pt_regs(task) \
14733 ({ \
14734 struct pt_regs *__regs__; \
14735 - __regs__ = (struct pt_regs *)(KSTK_TOP(task_stack_page(task))-8); \
14736 + __regs__ = (struct pt_regs *)((task)->thread.sp0); \
14737 __regs__ - 1; \
14738 })
14739
14740 @@ -885,13 +888,13 @@ extern unsigned long thread_saved_pc(struct task_struct *tsk);
14741 /*
14742 * User space process size. 47bits minus one guard page.
14743 */
14744 -#define TASK_SIZE_MAX ((1UL << 47) - PAGE_SIZE)
14745 +#define TASK_SIZE_MAX ((1UL << TASK_SIZE_MAX_SHIFT) - PAGE_SIZE)
14746
14747 /* This decides where the kernel will search for a free chunk of vm
14748 * space during mmap's.
14749 */
14750 #define IA32_PAGE_OFFSET ((current->personality & ADDR_LIMIT_3GB) ? \
14751 - 0xc0000000 : 0xFFFFe000)
14752 + 0xc0000000 : 0xFFFFf000)
14753
14754 #define TASK_SIZE (test_thread_flag(TIF_ADDR32) ? \
14755 IA32_PAGE_OFFSET : TASK_SIZE_MAX)
14756 @@ -902,11 +905,11 @@ extern unsigned long thread_saved_pc(struct task_struct *tsk);
14757 #define STACK_TOP_MAX TASK_SIZE_MAX
14758
14759 #define INIT_THREAD { \
14760 - .sp0 = (unsigned long)&init_stack + sizeof(init_stack) \
14761 + .sp0 = (unsigned long)&init_stack + sizeof(init_stack) - 16 \
14762 }
14763
14764 #define INIT_TSS { \
14765 - .x86_tss.sp0 = (unsigned long)&init_stack + sizeof(init_stack) \
14766 + .x86_tss.sp0 = (unsigned long)&init_stack + sizeof(init_stack) - 16 \
14767 }
14768
14769 /*
14770 @@ -934,6 +937,10 @@ extern void start_thread(struct pt_regs *regs, unsigned long new_ip,
14771 */
14772 #define TASK_UNMAPPED_BASE (PAGE_ALIGN(TASK_SIZE / 3))
14773
14774 +#ifdef CONFIG_PAX_SEGMEXEC
14775 +#define SEGMEXEC_TASK_UNMAPPED_BASE (PAGE_ALIGN(SEGMEXEC_TASK_SIZE / 3))
14776 +#endif
14777 +
14778 #define KSTK_EIP(task) (task_pt_regs(task)->ip)
14779
14780 /* Get/set a process' ability to use the timestamp counter instruction */
14781 @@ -994,12 +1001,12 @@ extern bool cpu_has_amd_erratum(const int *);
14782 #define cpu_has_amd_erratum(x) (false)
14783 #endif /* CONFIG_CPU_SUP_AMD */
14784
14785 -extern unsigned long arch_align_stack(unsigned long sp);
14786 +#define arch_align_stack(x) ((x) & ~0xfUL)
14787 extern void free_init_pages(char *what, unsigned long begin, unsigned long end);
14788
14789 void default_idle(void);
14790 bool set_pm_idle_to_default(void);
14791
14792 -void stop_this_cpu(void *dummy);
14793 +void stop_this_cpu(void *dummy) __noreturn;
14794
14795 #endif /* _ASM_X86_PROCESSOR_H */
14796 diff --git a/arch/x86/include/asm/ptrace.h b/arch/x86/include/asm/ptrace.h
14797 index 942a086..6c26446 100644
14798 --- a/arch/x86/include/asm/ptrace.h
14799 +++ b/arch/x86/include/asm/ptrace.h
14800 @@ -85,28 +85,29 @@ static inline unsigned long regs_return_value(struct pt_regs *regs)
14801 }
14802
14803 /*
14804 - * user_mode_vm(regs) determines whether a register set came from user mode.
14805 + * user_mode(regs) determines whether a register set came from user mode.
14806 * This is true if V8086 mode was enabled OR if the register set was from
14807 * protected mode with RPL-3 CS value. This tricky test checks that with
14808 * one comparison. Many places in the kernel can bypass this full check
14809 - * if they have already ruled out V8086 mode, so user_mode(regs) can be used.
14810 + * if they have already ruled out V8086 mode, so user_mode_novm(regs) can
14811 + * be used.
14812 */
14813 -static inline int user_mode(struct pt_regs *regs)
14814 +static inline int user_mode_novm(struct pt_regs *regs)
14815 {
14816 #ifdef CONFIG_X86_32
14817 return (regs->cs & SEGMENT_RPL_MASK) == USER_RPL;
14818 #else
14819 - return !!(regs->cs & 3);
14820 + return !!(regs->cs & SEGMENT_RPL_MASK);
14821 #endif
14822 }
14823
14824 -static inline int user_mode_vm(struct pt_regs *regs)
14825 +static inline int user_mode(struct pt_regs *regs)
14826 {
14827 #ifdef CONFIG_X86_32
14828 return ((regs->cs & SEGMENT_RPL_MASK) | (regs->flags & X86_VM_MASK)) >=
14829 USER_RPL;
14830 #else
14831 - return user_mode(regs);
14832 + return user_mode_novm(regs);
14833 #endif
14834 }
14835
14836 @@ -122,15 +123,16 @@ static inline int v8086_mode(struct pt_regs *regs)
14837 #ifdef CONFIG_X86_64
14838 static inline bool user_64bit_mode(struct pt_regs *regs)
14839 {
14840 + unsigned long cs = regs->cs & 0xffff;
14841 #ifndef CONFIG_PARAVIRT
14842 /*
14843 * On non-paravirt systems, this is the only long mode CPL 3
14844 * selector. We do not allow long mode selectors in the LDT.
14845 */
14846 - return regs->cs == __USER_CS;
14847 + return cs == __USER_CS;
14848 #else
14849 /* Headers are too twisted for this to go in paravirt.h. */
14850 - return regs->cs == __USER_CS || regs->cs == pv_info.extra_user_64bit_cs;
14851 + return cs == __USER_CS || cs == pv_info.extra_user_64bit_cs;
14852 #endif
14853 }
14854
14855 @@ -181,9 +183,11 @@ static inline unsigned long regs_get_register(struct pt_regs *regs,
14856 * Traps from the kernel do not save sp and ss.
14857 * Use the helper function to retrieve sp.
14858 */
14859 - if (offset == offsetof(struct pt_regs, sp) &&
14860 - regs->cs == __KERNEL_CS)
14861 - return kernel_stack_pointer(regs);
14862 + if (offset == offsetof(struct pt_regs, sp)) {
14863 + unsigned long cs = regs->cs & 0xffff;
14864 + if (cs == __KERNEL_CS || cs == __KERNEXEC_KERNEL_CS)
14865 + return kernel_stack_pointer(regs);
14866 + }
14867 #endif
14868 return *(unsigned long *)((unsigned long)regs + offset);
14869 }
14870 diff --git a/arch/x86/include/asm/realmode.h b/arch/x86/include/asm/realmode.h
14871 index fe1ec5b..dc5c3fe 100644
14872 --- a/arch/x86/include/asm/realmode.h
14873 +++ b/arch/x86/include/asm/realmode.h
14874 @@ -22,16 +22,14 @@ struct real_mode_header {
14875 #endif
14876 /* APM/BIOS reboot */
14877 u32 machine_real_restart_asm;
14878 -#ifdef CONFIG_X86_64
14879 u32 machine_real_restart_seg;
14880 -#endif
14881 };
14882
14883 /* This must match data at trampoline_32/64.S */
14884 struct trampoline_header {
14885 #ifdef CONFIG_X86_32
14886 u32 start;
14887 - u16 gdt_pad;
14888 + u16 boot_cs;
14889 u16 gdt_limit;
14890 u32 gdt_base;
14891 #else
14892 diff --git a/arch/x86/include/asm/reboot.h b/arch/x86/include/asm/reboot.h
14893 index a82c4f1..ac45053 100644
14894 --- a/arch/x86/include/asm/reboot.h
14895 +++ b/arch/x86/include/asm/reboot.h
14896 @@ -6,13 +6,13 @@
14897 struct pt_regs;
14898
14899 struct machine_ops {
14900 - void (*restart)(char *cmd);
14901 - void (*halt)(void);
14902 - void (*power_off)(void);
14903 + void (* __noreturn restart)(char *cmd);
14904 + void (* __noreturn halt)(void);
14905 + void (* __noreturn power_off)(void);
14906 void (*shutdown)(void);
14907 void (*crash_shutdown)(struct pt_regs *);
14908 - void (*emergency_restart)(void);
14909 -};
14910 + void (* __noreturn emergency_restart)(void);
14911 +} __no_const;
14912
14913 extern struct machine_ops machine_ops;
14914
14915 diff --git a/arch/x86/include/asm/rwsem.h b/arch/x86/include/asm/rwsem.h
14916 index 2dbe4a7..ce1db00 100644
14917 --- a/arch/x86/include/asm/rwsem.h
14918 +++ b/arch/x86/include/asm/rwsem.h
14919 @@ -64,6 +64,14 @@ static inline void __down_read(struct rw_semaphore *sem)
14920 {
14921 asm volatile("# beginning down_read\n\t"
14922 LOCK_PREFIX _ASM_INC "(%1)\n\t"
14923 +
14924 +#ifdef CONFIG_PAX_REFCOUNT
14925 + "jno 0f\n"
14926 + LOCK_PREFIX _ASM_DEC "(%1)\n"
14927 + "int $4\n0:\n"
14928 + _ASM_EXTABLE(0b, 0b)
14929 +#endif
14930 +
14931 /* adds 0x00000001 */
14932 " jns 1f\n"
14933 " call call_rwsem_down_read_failed\n"
14934 @@ -85,6 +93,14 @@ static inline int __down_read_trylock(struct rw_semaphore *sem)
14935 "1:\n\t"
14936 " mov %1,%2\n\t"
14937 " add %3,%2\n\t"
14938 +
14939 +#ifdef CONFIG_PAX_REFCOUNT
14940 + "jno 0f\n"
14941 + "sub %3,%2\n"
14942 + "int $4\n0:\n"
14943 + _ASM_EXTABLE(0b, 0b)
14944 +#endif
14945 +
14946 " jle 2f\n\t"
14947 LOCK_PREFIX " cmpxchg %2,%0\n\t"
14948 " jnz 1b\n\t"
14949 @@ -104,6 +120,14 @@ static inline void __down_write_nested(struct rw_semaphore *sem, int subclass)
14950 long tmp;
14951 asm volatile("# beginning down_write\n\t"
14952 LOCK_PREFIX " xadd %1,(%2)\n\t"
14953 +
14954 +#ifdef CONFIG_PAX_REFCOUNT
14955 + "jno 0f\n"
14956 + "mov %1,(%2)\n"
14957 + "int $4\n0:\n"
14958 + _ASM_EXTABLE(0b, 0b)
14959 +#endif
14960 +
14961 /* adds 0xffff0001, returns the old value */
14962 " test %1,%1\n\t"
14963 /* was the count 0 before? */
14964 @@ -141,6 +165,14 @@ static inline void __up_read(struct rw_semaphore *sem)
14965 long tmp;
14966 asm volatile("# beginning __up_read\n\t"
14967 LOCK_PREFIX " xadd %1,(%2)\n\t"
14968 +
14969 +#ifdef CONFIG_PAX_REFCOUNT
14970 + "jno 0f\n"
14971 + "mov %1,(%2)\n"
14972 + "int $4\n0:\n"
14973 + _ASM_EXTABLE(0b, 0b)
14974 +#endif
14975 +
14976 /* subtracts 1, returns the old value */
14977 " jns 1f\n\t"
14978 " call call_rwsem_wake\n" /* expects old value in %edx */
14979 @@ -159,6 +191,14 @@ static inline void __up_write(struct rw_semaphore *sem)
14980 long tmp;
14981 asm volatile("# beginning __up_write\n\t"
14982 LOCK_PREFIX " xadd %1,(%2)\n\t"
14983 +
14984 +#ifdef CONFIG_PAX_REFCOUNT
14985 + "jno 0f\n"
14986 + "mov %1,(%2)\n"
14987 + "int $4\n0:\n"
14988 + _ASM_EXTABLE(0b, 0b)
14989 +#endif
14990 +
14991 /* subtracts 0xffff0001, returns the old value */
14992 " jns 1f\n\t"
14993 " call call_rwsem_wake\n" /* expects old value in %edx */
14994 @@ -176,6 +216,14 @@ static inline void __downgrade_write(struct rw_semaphore *sem)
14995 {
14996 asm volatile("# beginning __downgrade_write\n\t"
14997 LOCK_PREFIX _ASM_ADD "%2,(%1)\n\t"
14998 +
14999 +#ifdef CONFIG_PAX_REFCOUNT
15000 + "jno 0f\n"
15001 + LOCK_PREFIX _ASM_SUB "%2,(%1)\n"
15002 + "int $4\n0:\n"
15003 + _ASM_EXTABLE(0b, 0b)
15004 +#endif
15005 +
15006 /*
15007 * transitions 0xZZZZ0001 -> 0xYYYY0001 (i386)
15008 * 0xZZZZZZZZ00000001 -> 0xYYYYYYYY00000001 (x86_64)
15009 @@ -194,7 +242,15 @@ static inline void __downgrade_write(struct rw_semaphore *sem)
15010 */
15011 static inline void rwsem_atomic_add(long delta, struct rw_semaphore *sem)
15012 {
15013 - asm volatile(LOCK_PREFIX _ASM_ADD "%1,%0"
15014 + asm volatile(LOCK_PREFIX _ASM_ADD "%1,%0\n"
15015 +
15016 +#ifdef CONFIG_PAX_REFCOUNT
15017 + "jno 0f\n"
15018 + LOCK_PREFIX _ASM_SUB "%1,%0\n"
15019 + "int $4\n0:\n"
15020 + _ASM_EXTABLE(0b, 0b)
15021 +#endif
15022 +
15023 : "+m" (sem->count)
15024 : "er" (delta));
15025 }
15026 @@ -204,7 +260,7 @@ static inline void rwsem_atomic_add(long delta, struct rw_semaphore *sem)
15027 */
15028 static inline long rwsem_atomic_update(long delta, struct rw_semaphore *sem)
15029 {
15030 - return delta + xadd(&sem->count, delta);
15031 + return delta + xadd_check_overflow(&sem->count, delta);
15032 }
15033
15034 #endif /* __KERNEL__ */
15035 diff --git a/arch/x86/include/asm/segment.h b/arch/x86/include/asm/segment.h
15036 index c48a950..c6d7468 100644
15037 --- a/arch/x86/include/asm/segment.h
15038 +++ b/arch/x86/include/asm/segment.h
15039 @@ -64,10 +64,15 @@
15040 * 26 - ESPFIX small SS
15041 * 27 - per-cpu [ offset to per-cpu data area ]
15042 * 28 - stack_canary-20 [ for stack protector ]
15043 - * 29 - unused
15044 - * 30 - unused
15045 + * 29 - PCI BIOS CS
15046 + * 30 - PCI BIOS DS
15047 * 31 - TSS for double fault handler
15048 */
15049 +#define GDT_ENTRY_KERNEXEC_EFI_CS (1)
15050 +#define GDT_ENTRY_KERNEXEC_EFI_DS (2)
15051 +#define __KERNEXEC_EFI_CS (GDT_ENTRY_KERNEXEC_EFI_CS*8)
15052 +#define __KERNEXEC_EFI_DS (GDT_ENTRY_KERNEXEC_EFI_DS*8)
15053 +
15054 #define GDT_ENTRY_TLS_MIN 6
15055 #define GDT_ENTRY_TLS_MAX (GDT_ENTRY_TLS_MIN + GDT_ENTRY_TLS_ENTRIES - 1)
15056
15057 @@ -79,6 +84,8 @@
15058
15059 #define GDT_ENTRY_KERNEL_CS (GDT_ENTRY_KERNEL_BASE+0)
15060
15061 +#define GDT_ENTRY_KERNEXEC_KERNEL_CS (4)
15062 +
15063 #define GDT_ENTRY_KERNEL_DS (GDT_ENTRY_KERNEL_BASE+1)
15064
15065 #define GDT_ENTRY_TSS (GDT_ENTRY_KERNEL_BASE+4)
15066 @@ -104,6 +111,12 @@
15067 #define __KERNEL_STACK_CANARY 0
15068 #endif
15069
15070 +#define GDT_ENTRY_PCIBIOS_CS (GDT_ENTRY_KERNEL_BASE+17)
15071 +#define __PCIBIOS_CS (GDT_ENTRY_PCIBIOS_CS * 8)
15072 +
15073 +#define GDT_ENTRY_PCIBIOS_DS (GDT_ENTRY_KERNEL_BASE+18)
15074 +#define __PCIBIOS_DS (GDT_ENTRY_PCIBIOS_DS * 8)
15075 +
15076 #define GDT_ENTRY_DOUBLEFAULT_TSS 31
15077
15078 /*
15079 @@ -141,7 +154,7 @@
15080 */
15081
15082 /* Matches PNP_CS32 and PNP_CS16 (they must be consecutive) */
15083 -#define SEGMENT_IS_PNP_CODE(x) (((x) & 0xf4) == GDT_ENTRY_PNPBIOS_BASE * 8)
15084 +#define SEGMENT_IS_PNP_CODE(x) (((x) & 0xFFFCU) == PNP_CS32 || ((x) & 0xFFFCU) == PNP_CS16)
15085
15086
15087 #else
15088 @@ -165,6 +178,8 @@
15089 #define __USER32_CS (GDT_ENTRY_DEFAULT_USER32_CS*8+3)
15090 #define __USER32_DS __USER_DS
15091
15092 +#define GDT_ENTRY_KERNEXEC_KERNEL_CS 7
15093 +
15094 #define GDT_ENTRY_TSS 8 /* needs two entries */
15095 #define GDT_ENTRY_LDT 10 /* needs two entries */
15096 #define GDT_ENTRY_TLS_MIN 12
15097 @@ -185,6 +200,7 @@
15098 #endif
15099
15100 #define __KERNEL_CS (GDT_ENTRY_KERNEL_CS*8)
15101 +#define __KERNEXEC_KERNEL_CS (GDT_ENTRY_KERNEXEC_KERNEL_CS*8)
15102 #define __KERNEL_DS (GDT_ENTRY_KERNEL_DS*8)
15103 #define __USER_DS (GDT_ENTRY_DEFAULT_USER_DS*8+3)
15104 #define __USER_CS (GDT_ENTRY_DEFAULT_USER_CS*8+3)
15105 @@ -265,7 +281,7 @@ static inline unsigned long get_limit(unsigned long segment)
15106 {
15107 unsigned long __limit;
15108 asm("lsll %1,%0" : "=r" (__limit) : "r" (segment));
15109 - return __limit + 1;
15110 + return __limit;
15111 }
15112
15113 #endif /* !__ASSEMBLY__ */
15114 diff --git a/arch/x86/include/asm/smp.h b/arch/x86/include/asm/smp.h
15115 index b073aae..39f9bdd 100644
15116 --- a/arch/x86/include/asm/smp.h
15117 +++ b/arch/x86/include/asm/smp.h
15118 @@ -36,7 +36,7 @@ DECLARE_PER_CPU_READ_MOSTLY(cpumask_var_t, cpu_core_map);
15119 /* cpus sharing the last level cache: */
15120 DECLARE_PER_CPU_READ_MOSTLY(cpumask_var_t, cpu_llc_shared_map);
15121 DECLARE_PER_CPU_READ_MOSTLY(u16, cpu_llc_id);
15122 -DECLARE_PER_CPU_READ_MOSTLY(int, cpu_number);
15123 +DECLARE_PER_CPU_READ_MOSTLY(unsigned int, cpu_number);
15124
15125 static inline struct cpumask *cpu_sibling_mask(int cpu)
15126 {
15127 @@ -79,7 +79,7 @@ struct smp_ops {
15128
15129 void (*send_call_func_ipi)(const struct cpumask *mask);
15130 void (*send_call_func_single_ipi)(int cpu);
15131 -};
15132 +} __no_const;
15133
15134 /* Globals due to paravirt */
15135 extern void set_cpu_sibling_map(int cpu);
15136 @@ -191,14 +191,8 @@ extern unsigned disabled_cpus __cpuinitdata;
15137 extern int safe_smp_processor_id(void);
15138
15139 #elif defined(CONFIG_X86_64_SMP)
15140 -#define raw_smp_processor_id() (this_cpu_read(cpu_number))
15141 -
15142 -#define stack_smp_processor_id() \
15143 -({ \
15144 - struct thread_info *ti; \
15145 - __asm__("andq %%rsp,%0; ":"=r" (ti) : "0" (CURRENT_MASK)); \
15146 - ti->cpu; \
15147 -})
15148 +#define raw_smp_processor_id() (this_cpu_read(cpu_number))
15149 +#define stack_smp_processor_id() raw_smp_processor_id()
15150 #define safe_smp_processor_id() smp_processor_id()
15151
15152 #endif
15153 diff --git a/arch/x86/include/asm/spinlock.h b/arch/x86/include/asm/spinlock.h
15154 index 33692ea..350a534 100644
15155 --- a/arch/x86/include/asm/spinlock.h
15156 +++ b/arch/x86/include/asm/spinlock.h
15157 @@ -172,6 +172,14 @@ static inline int arch_write_can_lock(arch_rwlock_t *lock)
15158 static inline void arch_read_lock(arch_rwlock_t *rw)
15159 {
15160 asm volatile(LOCK_PREFIX READ_LOCK_SIZE(dec) " (%0)\n\t"
15161 +
15162 +#ifdef CONFIG_PAX_REFCOUNT
15163 + "jno 0f\n"
15164 + LOCK_PREFIX READ_LOCK_SIZE(inc) " (%0)\n"
15165 + "int $4\n0:\n"
15166 + _ASM_EXTABLE(0b, 0b)
15167 +#endif
15168 +
15169 "jns 1f\n"
15170 "call __read_lock_failed\n\t"
15171 "1:\n"
15172 @@ -181,6 +189,14 @@ static inline void arch_read_lock(arch_rwlock_t *rw)
15173 static inline void arch_write_lock(arch_rwlock_t *rw)
15174 {
15175 asm volatile(LOCK_PREFIX WRITE_LOCK_SUB(%1) "(%0)\n\t"
15176 +
15177 +#ifdef CONFIG_PAX_REFCOUNT
15178 + "jno 0f\n"
15179 + LOCK_PREFIX WRITE_LOCK_ADD(%1) "(%0)\n"
15180 + "int $4\n0:\n"
15181 + _ASM_EXTABLE(0b, 0b)
15182 +#endif
15183 +
15184 "jz 1f\n"
15185 "call __write_lock_failed\n\t"
15186 "1:\n"
15187 @@ -210,13 +226,29 @@ static inline int arch_write_trylock(arch_rwlock_t *lock)
15188
15189 static inline void arch_read_unlock(arch_rwlock_t *rw)
15190 {
15191 - asm volatile(LOCK_PREFIX READ_LOCK_SIZE(inc) " %0"
15192 + asm volatile(LOCK_PREFIX READ_LOCK_SIZE(inc) " %0\n"
15193 +
15194 +#ifdef CONFIG_PAX_REFCOUNT
15195 + "jno 0f\n"
15196 + LOCK_PREFIX READ_LOCK_SIZE(dec) " %0\n"
15197 + "int $4\n0:\n"
15198 + _ASM_EXTABLE(0b, 0b)
15199 +#endif
15200 +
15201 :"+m" (rw->lock) : : "memory");
15202 }
15203
15204 static inline void arch_write_unlock(arch_rwlock_t *rw)
15205 {
15206 - asm volatile(LOCK_PREFIX WRITE_LOCK_ADD(%1) "%0"
15207 + asm volatile(LOCK_PREFIX WRITE_LOCK_ADD(%1) "%0\n"
15208 +
15209 +#ifdef CONFIG_PAX_REFCOUNT
15210 + "jno 0f\n"
15211 + LOCK_PREFIX WRITE_LOCK_SUB(%1) "%0\n"
15212 + "int $4\n0:\n"
15213 + _ASM_EXTABLE(0b, 0b)
15214 +#endif
15215 +
15216 : "+m" (rw->write) : "i" (RW_LOCK_BIAS) : "memory");
15217 }
15218
15219 diff --git a/arch/x86/include/asm/stackprotector.h b/arch/x86/include/asm/stackprotector.h
15220 index 6a99859..03cb807 100644
15221 --- a/arch/x86/include/asm/stackprotector.h
15222 +++ b/arch/x86/include/asm/stackprotector.h
15223 @@ -47,7 +47,7 @@
15224 * head_32 for boot CPU and setup_per_cpu_areas() for others.
15225 */
15226 #define GDT_STACK_CANARY_INIT \
15227 - [GDT_ENTRY_STACK_CANARY] = GDT_ENTRY_INIT(0x4090, 0, 0x18),
15228 + [GDT_ENTRY_STACK_CANARY] = GDT_ENTRY_INIT(0x4090, 0, 0x17),
15229
15230 /*
15231 * Initialize the stackprotector canary value.
15232 @@ -112,7 +112,7 @@ static inline void setup_stack_canary_segment(int cpu)
15233
15234 static inline void load_stack_canary_segment(void)
15235 {
15236 -#ifdef CONFIG_X86_32
15237 +#if defined(CONFIG_X86_32) && !defined(CONFIG_PAX_MEMORY_UDEREF)
15238 asm volatile ("mov %0, %%gs" : : "r" (0));
15239 #endif
15240 }
15241 diff --git a/arch/x86/include/asm/stacktrace.h b/arch/x86/include/asm/stacktrace.h
15242 index 70bbe39..4ae2bd4 100644
15243 --- a/arch/x86/include/asm/stacktrace.h
15244 +++ b/arch/x86/include/asm/stacktrace.h
15245 @@ -11,28 +11,20 @@
15246
15247 extern int kstack_depth_to_print;
15248
15249 -struct thread_info;
15250 +struct task_struct;
15251 struct stacktrace_ops;
15252
15253 -typedef unsigned long (*walk_stack_t)(struct thread_info *tinfo,
15254 - unsigned long *stack,
15255 - unsigned long bp,
15256 - const struct stacktrace_ops *ops,
15257 - void *data,
15258 - unsigned long *end,
15259 - int *graph);
15260 +typedef unsigned long walk_stack_t(struct task_struct *task,
15261 + void *stack_start,
15262 + unsigned long *stack,
15263 + unsigned long bp,
15264 + const struct stacktrace_ops *ops,
15265 + void *data,
15266 + unsigned long *end,
15267 + int *graph);
15268
15269 -extern unsigned long
15270 -print_context_stack(struct thread_info *tinfo,
15271 - unsigned long *stack, unsigned long bp,
15272 - const struct stacktrace_ops *ops, void *data,
15273 - unsigned long *end, int *graph);
15274 -
15275 -extern unsigned long
15276 -print_context_stack_bp(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 +extern walk_stack_t print_context_stack;
15281 +extern walk_stack_t print_context_stack_bp;
15282
15283 /* Generic stack tracer with callbacks */
15284
15285 @@ -40,7 +32,7 @@ struct stacktrace_ops {
15286 void (*address)(void *data, unsigned long address, int reliable);
15287 /* On negative return stop dumping */
15288 int (*stack)(void *data, char *name);
15289 - walk_stack_t walk_stack;
15290 + walk_stack_t *walk_stack;
15291 };
15292
15293 void dump_trace(struct task_struct *tsk, struct pt_regs *regs,
15294 diff --git a/arch/x86/include/asm/switch_to.h b/arch/x86/include/asm/switch_to.h
15295 index 4ec45b3..a4f0a8a 100644
15296 --- a/arch/x86/include/asm/switch_to.h
15297 +++ b/arch/x86/include/asm/switch_to.h
15298 @@ -108,7 +108,7 @@ do { \
15299 "call __switch_to\n\t" \
15300 "movq "__percpu_arg([current_task])",%%rsi\n\t" \
15301 __switch_canary \
15302 - "movq %P[thread_info](%%rsi),%%r8\n\t" \
15303 + "movq "__percpu_arg([thread_info])",%%r8\n\t" \
15304 "movq %%rax,%%rdi\n\t" \
15305 "testl %[_tif_fork],%P[ti_flags](%%r8)\n\t" \
15306 "jnz ret_from_fork\n\t" \
15307 @@ -119,7 +119,7 @@ do { \
15308 [threadrsp] "i" (offsetof(struct task_struct, thread.sp)), \
15309 [ti_flags] "i" (offsetof(struct thread_info, flags)), \
15310 [_tif_fork] "i" (_TIF_FORK), \
15311 - [thread_info] "i" (offsetof(struct task_struct, stack)), \
15312 + [thread_info] "m" (current_tinfo), \
15313 [current_task] "m" (current_task) \
15314 __switch_canary_iparam \
15315 : "memory", "cc" __EXTRA_CLOBBER)
15316 diff --git a/arch/x86/include/asm/thread_info.h b/arch/x86/include/asm/thread_info.h
15317 index 2d946e6..e453ec4 100644
15318 --- a/arch/x86/include/asm/thread_info.h
15319 +++ b/arch/x86/include/asm/thread_info.h
15320 @@ -10,6 +10,7 @@
15321 #include <linux/compiler.h>
15322 #include <asm/page.h>
15323 #include <asm/types.h>
15324 +#include <asm/percpu.h>
15325
15326 /*
15327 * low level task data that entry.S needs immediate access to
15328 @@ -24,7 +25,6 @@ struct exec_domain;
15329 #include <linux/atomic.h>
15330
15331 struct thread_info {
15332 - struct task_struct *task; /* main task structure */
15333 struct exec_domain *exec_domain; /* execution domain */
15334 __u32 flags; /* low level flags */
15335 __u32 status; /* thread synchronous flags */
15336 @@ -34,19 +34,13 @@ struct thread_info {
15337 mm_segment_t addr_limit;
15338 struct restart_block restart_block;
15339 void __user *sysenter_return;
15340 -#ifdef CONFIG_X86_32
15341 - unsigned long previous_esp; /* ESP of the previous stack in
15342 - case of nested (IRQ) stacks
15343 - */
15344 - __u8 supervisor_stack[0];
15345 -#endif
15346 + unsigned long lowest_stack;
15347 unsigned int sig_on_uaccess_error:1;
15348 unsigned int uaccess_err:1; /* uaccess failed */
15349 };
15350
15351 -#define INIT_THREAD_INFO(tsk) \
15352 +#define INIT_THREAD_INFO \
15353 { \
15354 - .task = &tsk, \
15355 .exec_domain = &default_exec_domain, \
15356 .flags = 0, \
15357 .cpu = 0, \
15358 @@ -57,7 +51,7 @@ struct thread_info {
15359 }, \
15360 }
15361
15362 -#define init_thread_info (init_thread_union.thread_info)
15363 +#define init_thread_info (init_thread_union.stack)
15364 #define init_stack (init_thread_union.stack)
15365
15366 #else /* !__ASSEMBLY__ */
15367 @@ -98,6 +92,7 @@ struct thread_info {
15368 #define TIF_SYSCALL_TRACEPOINT 28 /* syscall tracepoint instrumentation */
15369 #define TIF_ADDR32 29 /* 32-bit address space on 64 bits */
15370 #define TIF_X32 30 /* 32-bit native x86-64 binary */
15371 +#define TIF_GRSEC_SETXID 31 /* update credentials on syscall entry/exit */
15372
15373 #define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE)
15374 #define _TIF_NOTIFY_RESUME (1 << TIF_NOTIFY_RESUME)
15375 @@ -122,17 +117,18 @@ struct thread_info {
15376 #define _TIF_SYSCALL_TRACEPOINT (1 << TIF_SYSCALL_TRACEPOINT)
15377 #define _TIF_ADDR32 (1 << TIF_ADDR32)
15378 #define _TIF_X32 (1 << TIF_X32)
15379 +#define _TIF_GRSEC_SETXID (1 << TIF_GRSEC_SETXID)
15380
15381 /* work to do in syscall_trace_enter() */
15382 #define _TIF_WORK_SYSCALL_ENTRY \
15383 (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_EMU | _TIF_SYSCALL_AUDIT | \
15384 _TIF_SECCOMP | _TIF_SINGLESTEP | _TIF_SYSCALL_TRACEPOINT | \
15385 - _TIF_NOHZ)
15386 + _TIF_NOHZ | _TIF_GRSEC_SETXID)
15387
15388 /* work to do in syscall_trace_leave() */
15389 #define _TIF_WORK_SYSCALL_EXIT \
15390 (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | _TIF_SINGLESTEP | \
15391 - _TIF_SYSCALL_TRACEPOINT | _TIF_NOHZ)
15392 + _TIF_SYSCALL_TRACEPOINT | _TIF_NOHZ | _TIF_GRSEC_SETXID)
15393
15394 /* work to do on interrupt/exception return */
15395 #define _TIF_WORK_MASK \
15396 @@ -143,7 +139,7 @@ struct thread_info {
15397 /* work to do on any return to user space */
15398 #define _TIF_ALLWORK_MASK \
15399 ((0x0000FFFF & ~_TIF_SECCOMP) | _TIF_SYSCALL_TRACEPOINT | \
15400 - _TIF_NOHZ)
15401 + _TIF_NOHZ | _TIF_GRSEC_SETXID)
15402
15403 /* Only used for 64 bit */
15404 #define _TIF_DO_NOTIFY_MASK \
15405 @@ -159,45 +155,40 @@ struct thread_info {
15406
15407 #define PREEMPT_ACTIVE 0x10000000
15408
15409 -#ifdef CONFIG_X86_32
15410 -
15411 -#define STACK_WARN (THREAD_SIZE/8)
15412 -/*
15413 - * macros/functions for gaining access to the thread information structure
15414 - *
15415 - * preempt_count needs to be 1 initially, until the scheduler is functional.
15416 - */
15417 -#ifndef __ASSEMBLY__
15418 -
15419 -
15420 -/* how to get the current stack pointer from C */
15421 -register unsigned long current_stack_pointer asm("esp") __used;
15422 -
15423 -/* how to get the thread information struct from C */
15424 -static inline struct thread_info *current_thread_info(void)
15425 -{
15426 - return (struct thread_info *)
15427 - (current_stack_pointer & ~(THREAD_SIZE - 1));
15428 -}
15429 -
15430 -#else /* !__ASSEMBLY__ */
15431 -
15432 +#ifdef __ASSEMBLY__
15433 /* how to get the thread information struct from ASM */
15434 #define GET_THREAD_INFO(reg) \
15435 - movl $-THREAD_SIZE, reg; \
15436 - andl %esp, reg
15437 + mov PER_CPU_VAR(current_tinfo), reg
15438
15439 /* use this one if reg already contains %esp */
15440 -#define GET_THREAD_INFO_WITH_ESP(reg) \
15441 - andl $-THREAD_SIZE, reg
15442 +#define GET_THREAD_INFO_WITH_ESP(reg) GET_THREAD_INFO(reg)
15443 +#else
15444 +/* how to get the thread information struct from C */
15445 +DECLARE_PER_CPU(struct thread_info *, current_tinfo);
15446 +
15447 +static __always_inline struct thread_info *current_thread_info(void)
15448 +{
15449 + return this_cpu_read_stable(current_tinfo);
15450 +}
15451 +#endif
15452 +
15453 +#ifdef CONFIG_X86_32
15454 +
15455 +#define STACK_WARN (THREAD_SIZE/8)
15456 +/*
15457 + * macros/functions for gaining access to the thread information structure
15458 + *
15459 + * preempt_count needs to be 1 initially, until the scheduler is functional.
15460 + */
15461 +#ifndef __ASSEMBLY__
15462 +
15463 +/* how to get the current stack pointer from C */
15464 +register unsigned long current_stack_pointer asm("esp") __used;
15465
15466 #endif
15467
15468 #else /* X86_32 */
15469
15470 -#include <asm/percpu.h>
15471 -#define KERNEL_STACK_OFFSET (5*8)
15472 -
15473 /*
15474 * macros/functions for gaining access to the thread information structure
15475 * preempt_count needs to be 1 initially, until the scheduler is functional.
15476 @@ -205,27 +196,8 @@ static inline struct thread_info *current_thread_info(void)
15477 #ifndef __ASSEMBLY__
15478 DECLARE_PER_CPU(unsigned long, kernel_stack);
15479
15480 -static inline struct thread_info *current_thread_info(void)
15481 -{
15482 - struct thread_info *ti;
15483 - ti = (void *)(this_cpu_read_stable(kernel_stack) +
15484 - KERNEL_STACK_OFFSET - THREAD_SIZE);
15485 - return ti;
15486 -}
15487 -
15488 -#else /* !__ASSEMBLY__ */
15489 -
15490 -/* how to get the thread information struct from ASM */
15491 -#define GET_THREAD_INFO(reg) \
15492 - movq PER_CPU_VAR(kernel_stack),reg ; \
15493 - subq $(THREAD_SIZE-KERNEL_STACK_OFFSET),reg
15494 -
15495 -/*
15496 - * Same if PER_CPU_VAR(kernel_stack) is, perhaps with some offset, already in
15497 - * a certain register (to be used in assembler memory operands).
15498 - */
15499 -#define THREAD_INFO(reg, off) KERNEL_STACK_OFFSET+(off)-THREAD_SIZE(reg)
15500 -
15501 +/* how to get the current stack pointer from C */
15502 +register unsigned long current_stack_pointer asm("rsp") __used;
15503 #endif
15504
15505 #endif /* !X86_32 */
15506 @@ -286,5 +258,12 @@ static inline bool is_ia32_task(void)
15507 extern void arch_task_cache_init(void);
15508 extern int arch_dup_task_struct(struct task_struct *dst, struct task_struct *src);
15509 extern void arch_release_task_struct(struct task_struct *tsk);
15510 +
15511 +#define __HAVE_THREAD_FUNCTIONS
15512 +#define task_thread_info(task) (&(task)->tinfo)
15513 +#define task_stack_page(task) ((task)->stack)
15514 +#define setup_thread_stack(p, org) do {} while (0)
15515 +#define end_of_stack(p) ((unsigned long *)task_stack_page(p) + 1)
15516 +
15517 #endif
15518 #endif /* _ASM_X86_THREAD_INFO_H */
15519 diff --git a/arch/x86/include/asm/uaccess.h b/arch/x86/include/asm/uaccess.h
15520 index 1709801..0a60f2f 100644
15521 --- a/arch/x86/include/asm/uaccess.h
15522 +++ b/arch/x86/include/asm/uaccess.h
15523 @@ -7,6 +7,7 @@
15524 #include <linux/compiler.h>
15525 #include <linux/thread_info.h>
15526 #include <linux/string.h>
15527 +#include <linux/sched.h>
15528 #include <asm/asm.h>
15529 #include <asm/page.h>
15530 #include <asm/smap.h>
15531 @@ -29,7 +30,12 @@
15532
15533 #define get_ds() (KERNEL_DS)
15534 #define get_fs() (current_thread_info()->addr_limit)
15535 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
15536 +void __set_fs(mm_segment_t x);
15537 +void set_fs(mm_segment_t x);
15538 +#else
15539 #define set_fs(x) (current_thread_info()->addr_limit = (x))
15540 +#endif
15541
15542 #define segment_eq(a, b) ((a).seg == (b).seg)
15543
15544 @@ -77,8 +83,33 @@
15545 * checks that the pointer is in the user space range - after calling
15546 * this function, memory access functions may still return -EFAULT.
15547 */
15548 -#define access_ok(type, addr, size) \
15549 - (likely(__range_not_ok(addr, size, user_addr_max()) == 0))
15550 +#define __access_ok(type, addr, size) (likely(__range_not_ok(addr, size, user_addr_max()) == 0))
15551 +#define access_ok(type, addr, size) \
15552 +({ \
15553 + long __size = size; \
15554 + unsigned long __addr = (unsigned long)addr; \
15555 + unsigned long __addr_ao = __addr & PAGE_MASK; \
15556 + unsigned long __end_ao = __addr + __size - 1; \
15557 + bool __ret_ao = __range_not_ok(__addr, __size, user_addr_max()) == 0;\
15558 + if (__ret_ao && unlikely((__end_ao ^ __addr_ao) & PAGE_MASK)) { \
15559 + while(__addr_ao <= __end_ao) { \
15560 + char __c_ao; \
15561 + __addr_ao += PAGE_SIZE; \
15562 + if (__size > PAGE_SIZE) \
15563 + cond_resched(); \
15564 + if (__get_user(__c_ao, (char __user *)__addr)) \
15565 + break; \
15566 + if (type != VERIFY_WRITE) { \
15567 + __addr = __addr_ao; \
15568 + continue; \
15569 + } \
15570 + if (__put_user(__c_ao, (char __user *)__addr)) \
15571 + break; \
15572 + __addr = __addr_ao; \
15573 + } \
15574 + } \
15575 + __ret_ao; \
15576 +})
15577
15578 /*
15579 * The exception table consists of pairs of addresses relative to the
15580 @@ -189,13 +220,21 @@ extern int __get_user_bad(void);
15581 asm volatile("call __put_user_" #size : "=a" (__ret_pu) \
15582 : "0" ((typeof(*(ptr)))(x)), "c" (ptr) : "ebx")
15583
15584 -
15585 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
15586 +#define __copyuser_seg "gs;"
15587 +#define __COPYUSER_SET_ES "pushl %%gs; popl %%es\n"
15588 +#define __COPYUSER_RESTORE_ES "pushl %%ss; popl %%es\n"
15589 +#else
15590 +#define __copyuser_seg
15591 +#define __COPYUSER_SET_ES
15592 +#define __COPYUSER_RESTORE_ES
15593 +#endif
15594
15595 #ifdef CONFIG_X86_32
15596 #define __put_user_asm_u64(x, addr, err, errret) \
15597 asm volatile(ASM_STAC "\n" \
15598 - "1: movl %%eax,0(%2)\n" \
15599 - "2: movl %%edx,4(%2)\n" \
15600 + "1: "__copyuser_seg"movl %%eax,0(%2)\n" \
15601 + "2: "__copyuser_seg"movl %%edx,4(%2)\n" \
15602 "3: " ASM_CLAC "\n" \
15603 ".section .fixup,\"ax\"\n" \
15604 "4: movl %3,%0\n" \
15605 @@ -208,8 +247,8 @@ extern int __get_user_bad(void);
15606
15607 #define __put_user_asm_ex_u64(x, addr) \
15608 asm volatile(ASM_STAC "\n" \
15609 - "1: movl %%eax,0(%1)\n" \
15610 - "2: movl %%edx,4(%1)\n" \
15611 + "1: "__copyuser_seg"movl %%eax,0(%1)\n" \
15612 + "2: "__copyuser_seg"movl %%edx,4(%1)\n" \
15613 "3: " ASM_CLAC "\n" \
15614 _ASM_EXTABLE_EX(1b, 2b) \
15615 _ASM_EXTABLE_EX(2b, 3b) \
15616 @@ -259,7 +298,7 @@ extern void __put_user_8(void);
15617 __typeof__(*(ptr)) __pu_val; \
15618 __chk_user_ptr(ptr); \
15619 might_fault(); \
15620 - __pu_val = x; \
15621 + __pu_val = (x); \
15622 switch (sizeof(*(ptr))) { \
15623 case 1: \
15624 __put_user_x(1, __pu_val, ptr, __ret_pu); \
15625 @@ -358,7 +397,7 @@ do { \
15626
15627 #define __get_user_asm(x, addr, err, itype, rtype, ltype, errret) \
15628 asm volatile(ASM_STAC "\n" \
15629 - "1: mov"itype" %2,%"rtype"1\n" \
15630 + "1: "__copyuser_seg"mov"itype" %2,%"rtype"1\n"\
15631 "2: " ASM_CLAC "\n" \
15632 ".section .fixup,\"ax\"\n" \
15633 "3: mov %3,%0\n" \
15634 @@ -366,7 +405,7 @@ do { \
15635 " jmp 2b\n" \
15636 ".previous\n" \
15637 _ASM_EXTABLE(1b, 3b) \
15638 - : "=r" (err), ltype(x) \
15639 + : "=r" (err), ltype (x) \
15640 : "m" (__m(addr)), "i" (errret), "0" (err))
15641
15642 #define __get_user_size_ex(x, ptr, size) \
15643 @@ -391,7 +430,7 @@ do { \
15644 } while (0)
15645
15646 #define __get_user_asm_ex(x, addr, itype, rtype, ltype) \
15647 - asm volatile("1: mov"itype" %1,%"rtype"0\n" \
15648 + asm volatile("1: "__copyuser_seg"mov"itype" %1,%"rtype"0\n"\
15649 "2:\n" \
15650 _ASM_EXTABLE_EX(1b, 2b) \
15651 : ltype(x) : "m" (__m(addr)))
15652 @@ -408,13 +447,24 @@ do { \
15653 int __gu_err; \
15654 unsigned long __gu_val; \
15655 __get_user_size(__gu_val, (ptr), (size), __gu_err, -EFAULT); \
15656 - (x) = (__force __typeof__(*(ptr)))__gu_val; \
15657 + (x) = (__typeof__(*(ptr)))__gu_val; \
15658 __gu_err; \
15659 })
15660
15661 /* FIXME: this hack is definitely wrong -AK */
15662 struct __large_struct { unsigned long buf[100]; };
15663 -#define __m(x) (*(struct __large_struct __user *)(x))
15664 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
15665 +#define ____m(x) \
15666 +({ \
15667 + unsigned long ____x = (unsigned long)(x); \
15668 + if (____x < PAX_USER_SHADOW_BASE) \
15669 + ____x += PAX_USER_SHADOW_BASE; \
15670 + (void __user *)____x; \
15671 +})
15672 +#else
15673 +#define ____m(x) (x)
15674 +#endif
15675 +#define __m(x) (*(struct __large_struct __user *)____m(x))
15676
15677 /*
15678 * Tell gcc we read from memory instead of writing: this is because
15679 @@ -423,7 +473,7 @@ struct __large_struct { unsigned long buf[100]; };
15680 */
15681 #define __put_user_asm(x, addr, err, itype, rtype, ltype, errret) \
15682 asm volatile(ASM_STAC "\n" \
15683 - "1: mov"itype" %"rtype"1,%2\n" \
15684 + "1: "__copyuser_seg"mov"itype" %"rtype"1,%2\n"\
15685 "2: " ASM_CLAC "\n" \
15686 ".section .fixup,\"ax\"\n" \
15687 "3: mov %3,%0\n" \
15688 @@ -431,10 +481,10 @@ struct __large_struct { unsigned long buf[100]; };
15689 ".previous\n" \
15690 _ASM_EXTABLE(1b, 3b) \
15691 : "=r"(err) \
15692 - : ltype(x), "m" (__m(addr)), "i" (errret), "0" (err))
15693 + : ltype (x), "m" (__m(addr)), "i" (errret), "0" (err))
15694
15695 #define __put_user_asm_ex(x, addr, itype, rtype, ltype) \
15696 - asm volatile("1: mov"itype" %"rtype"0,%1\n" \
15697 + asm volatile("1: "__copyuser_seg"mov"itype" %"rtype"0,%1\n"\
15698 "2:\n" \
15699 _ASM_EXTABLE_EX(1b, 2b) \
15700 : : ltype(x), "m" (__m(addr)))
15701 @@ -473,8 +523,12 @@ struct __large_struct { unsigned long buf[100]; };
15702 * On error, the variable @x is set to zero.
15703 */
15704
15705 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
15706 +#define __get_user(x, ptr) get_user((x), (ptr))
15707 +#else
15708 #define __get_user(x, ptr) \
15709 __get_user_nocheck((x), (ptr), sizeof(*(ptr)))
15710 +#endif
15711
15712 /**
15713 * __put_user: - Write a simple value into user space, with less checking.
15714 @@ -496,8 +550,12 @@ struct __large_struct { unsigned long buf[100]; };
15715 * Returns zero on success, or -EFAULT on error.
15716 */
15717
15718 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
15719 +#define __put_user(x, ptr) put_user((x), (ptr))
15720 +#else
15721 #define __put_user(x, ptr) \
15722 __put_user_nocheck((__typeof__(*(ptr)))(x), (ptr), sizeof(*(ptr)))
15723 +#endif
15724
15725 #define __get_user_unaligned __get_user
15726 #define __put_user_unaligned __put_user
15727 @@ -515,7 +573,7 @@ struct __large_struct { unsigned long buf[100]; };
15728 #define get_user_ex(x, ptr) do { \
15729 unsigned long __gue_val; \
15730 __get_user_size_ex((__gue_val), (ptr), (sizeof(*(ptr)))); \
15731 - (x) = (__force __typeof__(*(ptr)))__gue_val; \
15732 + (x) = (__typeof__(*(ptr)))__gue_val; \
15733 } while (0)
15734
15735 #define put_user_try uaccess_try
15736 @@ -532,8 +590,8 @@ strncpy_from_user(char *dst, const char __user *src, long count);
15737 extern __must_check long strlen_user(const char __user *str);
15738 extern __must_check long strnlen_user(const char __user *str, long n);
15739
15740 -unsigned long __must_check clear_user(void __user *mem, unsigned long len);
15741 -unsigned long __must_check __clear_user(void __user *mem, unsigned long len);
15742 +unsigned long __must_check clear_user(void __user *mem, unsigned long len) __size_overflow(2);
15743 +unsigned long __must_check __clear_user(void __user *mem, unsigned long len) __size_overflow(2);
15744
15745 /*
15746 * movsl can be slow when source and dest are not both 8-byte aligned
15747 diff --git a/arch/x86/include/asm/uaccess_32.h b/arch/x86/include/asm/uaccess_32.h
15748 index 7f760a9..04b1c65 100644
15749 --- a/arch/x86/include/asm/uaccess_32.h
15750 +++ b/arch/x86/include/asm/uaccess_32.h
15751 @@ -11,15 +11,15 @@
15752 #include <asm/page.h>
15753
15754 unsigned long __must_check __copy_to_user_ll
15755 - (void __user *to, const void *from, unsigned long n);
15756 + (void __user *to, const void *from, unsigned long n) __size_overflow(3);
15757 unsigned long __must_check __copy_from_user_ll
15758 - (void *to, const void __user *from, unsigned long n);
15759 + (void *to, const void __user *from, unsigned long n) __size_overflow(3);
15760 unsigned long __must_check __copy_from_user_ll_nozero
15761 - (void *to, const void __user *from, unsigned long n);
15762 + (void *to, const void __user *from, unsigned long n) __size_overflow(3);
15763 unsigned long __must_check __copy_from_user_ll_nocache
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_nocache_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
15770 /**
15771 * __copy_to_user_inatomic: - Copy a block of data into user space, with less checking.
15772 @@ -43,6 +43,11 @@ unsigned long __must_check __copy_from_user_ll_nocache_nozero
15773 static __always_inline unsigned long __must_check
15774 __copy_to_user_inatomic(void __user *to, const void *from, unsigned long n)
15775 {
15776 + if ((long)n < 0)
15777 + return n;
15778 +
15779 + check_object_size(from, n, true);
15780 +
15781 if (__builtin_constant_p(n)) {
15782 unsigned long ret;
15783
15784 @@ -82,12 +87,16 @@ static __always_inline unsigned long __must_check
15785 __copy_to_user(void __user *to, const void *from, unsigned long n)
15786 {
15787 might_fault();
15788 +
15789 return __copy_to_user_inatomic(to, from, n);
15790 }
15791
15792 static __always_inline unsigned long
15793 __copy_from_user_inatomic(void *to, const void __user *from, unsigned long n)
15794 {
15795 + if ((long)n < 0)
15796 + return n;
15797 +
15798 /* Avoid zeroing the tail if the copy fails..
15799 * If 'n' is constant and 1, 2, or 4, we do still zero on a failure,
15800 * but as the zeroing behaviour is only significant when n is not
15801 @@ -137,6 +146,12 @@ static __always_inline unsigned long
15802 __copy_from_user(void *to, const void __user *from, unsigned long n)
15803 {
15804 might_fault();
15805 +
15806 + if ((long)n < 0)
15807 + return n;
15808 +
15809 + check_object_size(to, n, false);
15810 +
15811 if (__builtin_constant_p(n)) {
15812 unsigned long ret;
15813
15814 @@ -159,6 +174,10 @@ static __always_inline unsigned long __copy_from_user_nocache(void *to,
15815 const void __user *from, unsigned long n)
15816 {
15817 might_fault();
15818 +
15819 + if ((long)n < 0)
15820 + return n;
15821 +
15822 if (__builtin_constant_p(n)) {
15823 unsigned long ret;
15824
15825 @@ -181,15 +200,19 @@ static __always_inline unsigned long
15826 __copy_from_user_inatomic_nocache(void *to, const void __user *from,
15827 unsigned long n)
15828 {
15829 - return __copy_from_user_ll_nocache_nozero(to, from, n);
15830 + if ((long)n < 0)
15831 + return n;
15832 +
15833 + return __copy_from_user_ll_nocache_nozero(to, from, n);
15834 }
15835
15836 -unsigned long __must_check copy_to_user(void __user *to,
15837 - const void *from, unsigned long n);
15838 -unsigned long __must_check _copy_from_user(void *to,
15839 - const void __user *from,
15840 - unsigned long n);
15841 -
15842 +extern void copy_to_user_overflow(void)
15843 +#ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
15844 + __compiletime_error("copy_to_user() buffer size is not provably correct")
15845 +#else
15846 + __compiletime_warning("copy_to_user() buffer size is not provably correct")
15847 +#endif
15848 +;
15849
15850 extern void copy_from_user_overflow(void)
15851 #ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
15852 @@ -199,17 +222,60 @@ extern void copy_from_user_overflow(void)
15853 #endif
15854 ;
15855
15856 -static inline unsigned long __must_check copy_from_user(void *to,
15857 - const void __user *from,
15858 - unsigned long n)
15859 +/**
15860 + * copy_to_user: - Copy a block of data into user space.
15861 + * @to: Destination address, in user space.
15862 + * @from: Source address, in kernel space.
15863 + * @n: Number of bytes to copy.
15864 + *
15865 + * Context: User context only. This function may sleep.
15866 + *
15867 + * Copy data from kernel space to user space.
15868 + *
15869 + * Returns number of bytes that could not be copied.
15870 + * On success, this will be zero.
15871 + */
15872 +static inline unsigned long __must_check
15873 +copy_to_user(void __user *to, const void *from, unsigned long n)
15874 {
15875 - int sz = __compiletime_object_size(to);
15876 + size_t sz = __compiletime_object_size(from);
15877
15878 - if (likely(sz == -1 || sz >= n))
15879 - n = _copy_from_user(to, from, n);
15880 - else
15881 + if (unlikely(sz != (size_t)-1 && sz < n))
15882 + copy_to_user_overflow();
15883 + else if (access_ok(VERIFY_WRITE, to, n))
15884 + n = __copy_to_user(to, from, n);
15885 + return n;
15886 +}
15887 +
15888 +/**
15889 + * copy_from_user: - Copy a block of data from user space.
15890 + * @to: Destination address, in kernel space.
15891 + * @from: Source address, in user space.
15892 + * @n: Number of bytes to copy.
15893 + *
15894 + * Context: User context only. This function may sleep.
15895 + *
15896 + * Copy data from user space to kernel space.
15897 + *
15898 + * Returns number of bytes that could not be copied.
15899 + * On success, this will be zero.
15900 + *
15901 + * If some data could not be copied, this function will pad the copied
15902 + * data to the requested size using zero bytes.
15903 + */
15904 +static inline unsigned long __must_check
15905 +copy_from_user(void *to, const void __user *from, unsigned long n)
15906 +{
15907 + size_t sz = __compiletime_object_size(to);
15908 +
15909 + check_object_size(to, n, false);
15910 +
15911 + if (unlikely(sz != (size_t)-1 && sz < n))
15912 copy_from_user_overflow();
15913 -
15914 + else if (access_ok(VERIFY_READ, from, n))
15915 + n = __copy_from_user(to, from, n);
15916 + else if ((long)n > 0)
15917 + memset(to, 0, n);
15918 return n;
15919 }
15920
15921 diff --git a/arch/x86/include/asm/uaccess_64.h b/arch/x86/include/asm/uaccess_64.h
15922 index 142810c..747941a 100644
15923 --- a/arch/x86/include/asm/uaccess_64.h
15924 +++ b/arch/x86/include/asm/uaccess_64.h
15925 @@ -10,6 +10,9 @@
15926 #include <asm/alternative.h>
15927 #include <asm/cpufeature.h>
15928 #include <asm/page.h>
15929 +#include <asm/pgtable.h>
15930 +
15931 +#define set_fs(x) (current_thread_info()->addr_limit = (x))
15932
15933 /*
15934 * Copy To/From Userspace
15935 @@ -17,13 +20,13 @@
15936
15937 /* Handles exceptions in both to and from, but doesn't do access_ok */
15938 __must_check unsigned long
15939 -copy_user_enhanced_fast_string(void *to, const void *from, unsigned len);
15940 +copy_user_enhanced_fast_string(void *to, const void *from, unsigned len) __size_overflow(3);
15941 __must_check unsigned long
15942 -copy_user_generic_string(void *to, const void *from, unsigned len);
15943 +copy_user_generic_string(void *to, const void *from, unsigned len) __size_overflow(3);
15944 __must_check unsigned long
15945 -copy_user_generic_unrolled(void *to, const void *from, unsigned len);
15946 +copy_user_generic_unrolled(void *to, const void *from, unsigned len) __size_overflow(3);
15947
15948 -static __always_inline __must_check unsigned long
15949 +static __always_inline __must_check __size_overflow(3) unsigned long
15950 copy_user_generic(void *to, const void *from, unsigned len)
15951 {
15952 unsigned ret;
15953 @@ -41,142 +44,204 @@ copy_user_generic(void *to, const void *from, unsigned len)
15954 ASM_OUTPUT2("=a" (ret), "=D" (to), "=S" (from),
15955 "=d" (len)),
15956 "1" (to), "2" (from), "3" (len)
15957 - : "memory", "rcx", "r8", "r9", "r10", "r11");
15958 + : "memory", "rcx", "r8", "r9", "r11");
15959 return ret;
15960 }
15961
15962 +static __always_inline __must_check unsigned long
15963 +__copy_to_user(void __user *to, const void *from, unsigned long len) __size_overflow(3);
15964 +static __always_inline __must_check unsigned long
15965 +__copy_from_user(void *to, const void __user *from, unsigned long len) __size_overflow(3);
15966 __must_check unsigned long
15967 -_copy_to_user(void __user *to, const void *from, unsigned len);
15968 -__must_check unsigned long
15969 -_copy_from_user(void *to, const void __user *from, unsigned len);
15970 -__must_check unsigned long
15971 -copy_in_user(void __user *to, const void __user *from, unsigned len);
15972 +copy_in_user(void __user *to, const void __user *from, unsigned long len) __size_overflow(3);
15973 +
15974 +extern void copy_to_user_overflow(void)
15975 +#ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
15976 + __compiletime_error("copy_to_user() buffer size is not provably correct")
15977 +#else
15978 + __compiletime_warning("copy_to_user() buffer size is not provably correct")
15979 +#endif
15980 +;
15981 +
15982 +extern void copy_from_user_overflow(void)
15983 +#ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
15984 + __compiletime_error("copy_from_user() buffer size is not provably correct")
15985 +#else
15986 + __compiletime_warning("copy_from_user() buffer size is not provably correct")
15987 +#endif
15988 +;
15989
15990 static inline unsigned long __must_check copy_from_user(void *to,
15991 const void __user *from,
15992 unsigned long n)
15993 {
15994 - int sz = __compiletime_object_size(to);
15995 -
15996 might_fault();
15997 - if (likely(sz == -1 || sz >= n))
15998 - n = _copy_from_user(to, from, n);
15999 -#ifdef CONFIG_DEBUG_VM
16000 - else
16001 - WARN(1, "Buffer overflow detected!\n");
16002 -#endif
16003 +
16004 + check_object_size(to, n, false);
16005 +
16006 + if (access_ok(VERIFY_READ, from, n))
16007 + n = __copy_from_user(to, from, n);
16008 + else if (n < INT_MAX)
16009 + memset(to, 0, n);
16010 return n;
16011 }
16012
16013 static __always_inline __must_check
16014 -int copy_to_user(void __user *dst, const void *src, unsigned size)
16015 +int copy_to_user(void __user *dst, const void *src, unsigned long size)
16016 {
16017 might_fault();
16018
16019 - return _copy_to_user(dst, src, size);
16020 + if (access_ok(VERIFY_WRITE, dst, size))
16021 + size = __copy_to_user(dst, src, size);
16022 + return size;
16023 }
16024
16025 static __always_inline __must_check
16026 -int __copy_from_user(void *dst, const void __user *src, unsigned size)
16027 +unsigned long __copy_from_user(void *dst, const void __user *src, unsigned long size)
16028 {
16029 - int ret = 0;
16030 + size_t sz = __compiletime_object_size(dst);
16031 + unsigned ret = 0;
16032
16033 might_fault();
16034 +
16035 + if (size > INT_MAX)
16036 + return size;
16037 +
16038 + check_object_size(dst, size, false);
16039 +
16040 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16041 + if (!__access_ok(VERIFY_READ, src, size))
16042 + return size;
16043 +#endif
16044 +
16045 + if (unlikely(sz != (size_t)-1 && sz < size)) {
16046 + copy_from_user_overflow();
16047 + return size;
16048 + }
16049 +
16050 if (!__builtin_constant_p(size))
16051 - return copy_user_generic(dst, (__force void *)src, size);
16052 + return copy_user_generic(dst, (__force_kernel const void *)____m(src), size);
16053 switch (size) {
16054 - case 1:__get_user_asm(*(u8 *)dst, (u8 __user *)src,
16055 + case 1:__get_user_asm(*(u8 *)dst, (const u8 __user *)src,
16056 ret, "b", "b", "=q", 1);
16057 return ret;
16058 - case 2:__get_user_asm(*(u16 *)dst, (u16 __user *)src,
16059 + case 2:__get_user_asm(*(u16 *)dst, (const u16 __user *)src,
16060 ret, "w", "w", "=r", 2);
16061 return ret;
16062 - case 4:__get_user_asm(*(u32 *)dst, (u32 __user *)src,
16063 + case 4:__get_user_asm(*(u32 *)dst, (const u32 __user *)src,
16064 ret, "l", "k", "=r", 4);
16065 return ret;
16066 - case 8:__get_user_asm(*(u64 *)dst, (u64 __user *)src,
16067 + case 8:__get_user_asm(*(u64 *)dst, (const u64 __user *)src,
16068 ret, "q", "", "=r", 8);
16069 return ret;
16070 case 10:
16071 - __get_user_asm(*(u64 *)dst, (u64 __user *)src,
16072 + __get_user_asm(*(u64 *)dst, (const u64 __user *)src,
16073 ret, "q", "", "=r", 10);
16074 if (unlikely(ret))
16075 return ret;
16076 __get_user_asm(*(u16 *)(8 + (char *)dst),
16077 - (u16 __user *)(8 + (char __user *)src),
16078 + (const u16 __user *)(8 + (const char __user *)src),
16079 ret, "w", "w", "=r", 2);
16080 return ret;
16081 case 16:
16082 - __get_user_asm(*(u64 *)dst, (u64 __user *)src,
16083 + __get_user_asm(*(u64 *)dst, (const u64 __user *)src,
16084 ret, "q", "", "=r", 16);
16085 if (unlikely(ret))
16086 return ret;
16087 __get_user_asm(*(u64 *)(8 + (char *)dst),
16088 - (u64 __user *)(8 + (char __user *)src),
16089 + (const u64 __user *)(8 + (const char __user *)src),
16090 ret, "q", "", "=r", 8);
16091 return ret;
16092 default:
16093 - return copy_user_generic(dst, (__force void *)src, size);
16094 + return copy_user_generic(dst, (__force_kernel const void *)____m(src), size);
16095 }
16096 }
16097
16098 static __always_inline __must_check
16099 -int __copy_to_user(void __user *dst, const void *src, unsigned size)
16100 +unsigned long __copy_to_user(void __user *dst, const void *src, unsigned long size)
16101 {
16102 - int ret = 0;
16103 + size_t sz = __compiletime_object_size(src);
16104 + unsigned ret = 0;
16105
16106 might_fault();
16107 +
16108 + if (size > INT_MAX)
16109 + return size;
16110 +
16111 + check_object_size(src, size, true);
16112 +
16113 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16114 + if (!__access_ok(VERIFY_WRITE, dst, size))
16115 + return size;
16116 +#endif
16117 +
16118 + if (unlikely(sz != (size_t)-1 && sz < size)) {
16119 + copy_to_user_overflow();
16120 + return size;
16121 + }
16122 +
16123 if (!__builtin_constant_p(size))
16124 - return copy_user_generic((__force void *)dst, src, size);
16125 + return copy_user_generic((__force_kernel void *)____m(dst), src, size);
16126 switch (size) {
16127 - case 1:__put_user_asm(*(u8 *)src, (u8 __user *)dst,
16128 + case 1:__put_user_asm(*(const u8 *)src, (u8 __user *)dst,
16129 ret, "b", "b", "iq", 1);
16130 return ret;
16131 - case 2:__put_user_asm(*(u16 *)src, (u16 __user *)dst,
16132 + case 2:__put_user_asm(*(const u16 *)src, (u16 __user *)dst,
16133 ret, "w", "w", "ir", 2);
16134 return ret;
16135 - case 4:__put_user_asm(*(u32 *)src, (u32 __user *)dst,
16136 + case 4:__put_user_asm(*(const u32 *)src, (u32 __user *)dst,
16137 ret, "l", "k", "ir", 4);
16138 return ret;
16139 - case 8:__put_user_asm(*(u64 *)src, (u64 __user *)dst,
16140 + case 8:__put_user_asm(*(const u64 *)src, (u64 __user *)dst,
16141 ret, "q", "", "er", 8);
16142 return ret;
16143 case 10:
16144 - __put_user_asm(*(u64 *)src, (u64 __user *)dst,
16145 + __put_user_asm(*(const u64 *)src, (u64 __user *)dst,
16146 ret, "q", "", "er", 10);
16147 if (unlikely(ret))
16148 return ret;
16149 asm("":::"memory");
16150 - __put_user_asm(4[(u16 *)src], 4 + (u16 __user *)dst,
16151 + __put_user_asm(4[(const u16 *)src], 4 + (u16 __user *)dst,
16152 ret, "w", "w", "ir", 2);
16153 return ret;
16154 case 16:
16155 - __put_user_asm(*(u64 *)src, (u64 __user *)dst,
16156 + __put_user_asm(*(const u64 *)src, (u64 __user *)dst,
16157 ret, "q", "", "er", 16);
16158 if (unlikely(ret))
16159 return ret;
16160 asm("":::"memory");
16161 - __put_user_asm(1[(u64 *)src], 1 + (u64 __user *)dst,
16162 + __put_user_asm(1[(const u64 *)src], 1 + (u64 __user *)dst,
16163 ret, "q", "", "er", 8);
16164 return ret;
16165 default:
16166 - return copy_user_generic((__force void *)dst, src, size);
16167 + return copy_user_generic((__force_kernel void *)____m(dst), src, size);
16168 }
16169 }
16170
16171 static __always_inline __must_check
16172 -int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
16173 +unsigned long __copy_in_user(void __user *dst, const void __user *src, unsigned long size)
16174 {
16175 - int ret = 0;
16176 + unsigned ret = 0;
16177
16178 might_fault();
16179 +
16180 + if (size > INT_MAX)
16181 + return size;
16182 +
16183 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16184 + if (!__access_ok(VERIFY_READ, src, size))
16185 + return size;
16186 + if (!__access_ok(VERIFY_WRITE, dst, size))
16187 + return size;
16188 +#endif
16189 +
16190 if (!__builtin_constant_p(size))
16191 - return copy_user_generic((__force void *)dst,
16192 - (__force void *)src, size);
16193 + return copy_user_generic((__force_kernel void *)____m(dst),
16194 + (__force_kernel const void *)____m(src), size);
16195 switch (size) {
16196 case 1: {
16197 u8 tmp;
16198 - __get_user_asm(tmp, (u8 __user *)src,
16199 + __get_user_asm(tmp, (const u8 __user *)src,
16200 ret, "b", "b", "=q", 1);
16201 if (likely(!ret))
16202 __put_user_asm(tmp, (u8 __user *)dst,
16203 @@ -185,7 +250,7 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
16204 }
16205 case 2: {
16206 u16 tmp;
16207 - __get_user_asm(tmp, (u16 __user *)src,
16208 + __get_user_asm(tmp, (const u16 __user *)src,
16209 ret, "w", "w", "=r", 2);
16210 if (likely(!ret))
16211 __put_user_asm(tmp, (u16 __user *)dst,
16212 @@ -195,7 +260,7 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
16213
16214 case 4: {
16215 u32 tmp;
16216 - __get_user_asm(tmp, (u32 __user *)src,
16217 + __get_user_asm(tmp, (const u32 __user *)src,
16218 ret, "l", "k", "=r", 4);
16219 if (likely(!ret))
16220 __put_user_asm(tmp, (u32 __user *)dst,
16221 @@ -204,7 +269,7 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
16222 }
16223 case 8: {
16224 u64 tmp;
16225 - __get_user_asm(tmp, (u64 __user *)src,
16226 + __get_user_asm(tmp, (const u64 __user *)src,
16227 ret, "q", "", "=r", 8);
16228 if (likely(!ret))
16229 __put_user_asm(tmp, (u64 __user *)dst,
16230 @@ -212,41 +277,72 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
16231 return ret;
16232 }
16233 default:
16234 - return copy_user_generic((__force void *)dst,
16235 - (__force void *)src, size);
16236 + return copy_user_generic((__force_kernel void *)____m(dst),
16237 + (__force_kernel const void *)____m(src), size);
16238 }
16239 }
16240
16241 static __must_check __always_inline int
16242 -__copy_from_user_inatomic(void *dst, const void __user *src, unsigned size)
16243 +__copy_from_user_inatomic(void *dst, const void __user *src, unsigned long size)
16244 {
16245 - return copy_user_generic(dst, (__force const void *)src, size);
16246 + if (size > INT_MAX)
16247 + return size;
16248 +
16249 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16250 + if (!__access_ok(VERIFY_READ, src, size))
16251 + return size;
16252 +#endif
16253 +
16254 + return copy_user_generic(dst, (__force_kernel const void *)____m(src), size);
16255 }
16256
16257 -static __must_check __always_inline int
16258 -__copy_to_user_inatomic(void __user *dst, const void *src, unsigned size)
16259 +static __must_check __always_inline unsigned long
16260 +__copy_to_user_inatomic(void __user *dst, const void *src, unsigned long size)
16261 {
16262 - return copy_user_generic((__force void *)dst, src, size);
16263 + if (size > INT_MAX)
16264 + return size;
16265 +
16266 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16267 + if (!__access_ok(VERIFY_WRITE, dst, size))
16268 + return size;
16269 +#endif
16270 +
16271 + return copy_user_generic((__force_kernel void *)____m(dst), src, size);
16272 }
16273
16274 -extern long __copy_user_nocache(void *dst, const void __user *src,
16275 - unsigned size, int zerorest);
16276 +extern unsigned long __copy_user_nocache(void *dst, const void __user *src,
16277 + unsigned long size, int zerorest) __size_overflow(3);
16278
16279 -static inline int
16280 -__copy_from_user_nocache(void *dst, const void __user *src, unsigned size)
16281 +static inline unsigned long __copy_from_user_nocache(void *dst, const void __user *src, unsigned long size)
16282 {
16283 might_sleep();
16284 +
16285 + if (size > INT_MAX)
16286 + return size;
16287 +
16288 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16289 + if (!__access_ok(VERIFY_READ, src, size))
16290 + return size;
16291 +#endif
16292 +
16293 return __copy_user_nocache(dst, src, size, 1);
16294 }
16295
16296 -static inline int
16297 -__copy_from_user_inatomic_nocache(void *dst, const void __user *src,
16298 - unsigned size)
16299 +static inline unsigned long __copy_from_user_inatomic_nocache(void *dst, const void __user *src,
16300 + unsigned long size)
16301 {
16302 + if (size > INT_MAX)
16303 + return size;
16304 +
16305 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16306 + if (!__access_ok(VERIFY_READ, src, size))
16307 + return size;
16308 +#endif
16309 +
16310 return __copy_user_nocache(dst, src, size, 0);
16311 }
16312
16313 -unsigned long
16314 -copy_user_handle_tail(char *to, char *from, unsigned len, unsigned zerorest);
16315 +extern unsigned long
16316 +copy_user_handle_tail(char __user *to, char __user *from, unsigned long len, unsigned zerorest) __size_overflow(3);
16317
16318 #endif /* _ASM_X86_UACCESS_64_H */
16319 diff --git a/arch/x86/include/asm/word-at-a-time.h b/arch/x86/include/asm/word-at-a-time.h
16320 index 5b238981..77fdd78 100644
16321 --- a/arch/x86/include/asm/word-at-a-time.h
16322 +++ b/arch/x86/include/asm/word-at-a-time.h
16323 @@ -11,7 +11,7 @@
16324 * and shift, for example.
16325 */
16326 struct word_at_a_time {
16327 - const unsigned long one_bits, high_bits;
16328 + unsigned long one_bits, high_bits;
16329 };
16330
16331 #define WORD_AT_A_TIME_CONSTANTS { REPEAT_BYTE(0x01), REPEAT_BYTE(0x80) }
16332 diff --git a/arch/x86/include/asm/x86_init.h b/arch/x86/include/asm/x86_init.h
16333 index 5769349..a3d3e2a 100644
16334 --- a/arch/x86/include/asm/x86_init.h
16335 +++ b/arch/x86/include/asm/x86_init.h
16336 @@ -141,7 +141,7 @@ struct x86_init_ops {
16337 struct x86_init_timers timers;
16338 struct x86_init_iommu iommu;
16339 struct x86_init_pci pci;
16340 -};
16341 +} __no_const;
16342
16343 /**
16344 * struct x86_cpuinit_ops - platform specific cpu hotplug setups
16345 @@ -152,7 +152,7 @@ struct x86_cpuinit_ops {
16346 void (*setup_percpu_clockev)(void);
16347 void (*early_percpu_clock_init)(void);
16348 void (*fixup_cpu_id)(struct cpuinfo_x86 *c, int node);
16349 -};
16350 +} __no_const;
16351
16352 /**
16353 * struct x86_platform_ops - platform specific runtime functions
16354 @@ -178,7 +178,7 @@ struct x86_platform_ops {
16355 void (*save_sched_clock_state)(void);
16356 void (*restore_sched_clock_state)(void);
16357 void (*apic_post_init)(void);
16358 -};
16359 +} __no_const;
16360
16361 struct pci_dev;
16362
16363 @@ -187,14 +187,14 @@ struct x86_msi_ops {
16364 void (*teardown_msi_irq)(unsigned int irq);
16365 void (*teardown_msi_irqs)(struct pci_dev *dev);
16366 void (*restore_msi_irqs)(struct pci_dev *dev, int irq);
16367 -};
16368 +} __no_const;
16369
16370 struct x86_io_apic_ops {
16371 void (*init) (void);
16372 unsigned int (*read) (unsigned int apic, unsigned int reg);
16373 void (*write) (unsigned int apic, unsigned int reg, unsigned int value);
16374 void (*modify)(unsigned int apic, unsigned int reg, unsigned int value);
16375 -};
16376 +} __no_const;
16377
16378 extern struct x86_init_ops x86_init;
16379 extern struct x86_cpuinit_ops x86_cpuinit;
16380 diff --git a/arch/x86/include/asm/xsave.h b/arch/x86/include/asm/xsave.h
16381 index 0415cda..b43d877 100644
16382 --- a/arch/x86/include/asm/xsave.h
16383 +++ b/arch/x86/include/asm/xsave.h
16384 @@ -71,7 +71,9 @@ static inline int xsave_user(struct xsave_struct __user *buf)
16385 return -EFAULT;
16386
16387 __asm__ __volatile__(ASM_STAC "\n"
16388 - "1: .byte " REX_PREFIX "0x0f,0xae,0x27\n"
16389 + "1:"
16390 + __copyuser_seg
16391 + ".byte " REX_PREFIX "0x0f,0xae,0x27\n"
16392 "2: " ASM_CLAC "\n"
16393 ".section .fixup,\"ax\"\n"
16394 "3: movl $-1,%[err]\n"
16395 @@ -87,12 +89,14 @@ static inline int xsave_user(struct xsave_struct __user *buf)
16396 static inline int xrestore_user(struct xsave_struct __user *buf, u64 mask)
16397 {
16398 int err;
16399 - struct xsave_struct *xstate = ((__force struct xsave_struct *)buf);
16400 + struct xsave_struct *xstate = ((__force_kernel struct xsave_struct *)buf);
16401 u32 lmask = mask;
16402 u32 hmask = mask >> 32;
16403
16404 __asm__ __volatile__(ASM_STAC "\n"
16405 - "1: .byte " REX_PREFIX "0x0f,0xae,0x2f\n"
16406 + "1:"
16407 + __copyuser_seg
16408 + ".byte " REX_PREFIX "0x0f,0xae,0x2f\n"
16409 "2: " ASM_CLAC "\n"
16410 ".section .fixup,\"ax\"\n"
16411 "3: movl $-1,%[err]\n"
16412 diff --git a/arch/x86/include/uapi/asm/e820.h b/arch/x86/include/uapi/asm/e820.h
16413 index bbae024..e1528f9 100644
16414 --- a/arch/x86/include/uapi/asm/e820.h
16415 +++ b/arch/x86/include/uapi/asm/e820.h
16416 @@ -63,7 +63,7 @@ struct e820map {
16417 #define ISA_START_ADDRESS 0xa0000
16418 #define ISA_END_ADDRESS 0x100000
16419
16420 -#define BIOS_BEGIN 0x000a0000
16421 +#define BIOS_BEGIN 0x000c0000
16422 #define BIOS_END 0x00100000
16423
16424 #define BIOS_ROM_BASE 0xffe00000
16425 diff --git a/arch/x86/kernel/Makefile b/arch/x86/kernel/Makefile
16426 index 34e923a..0c6bb6e 100644
16427 --- a/arch/x86/kernel/Makefile
16428 +++ b/arch/x86/kernel/Makefile
16429 @@ -22,7 +22,7 @@ obj-y += time.o ioport.o ldt.o dumpstack.o nmi.o
16430 obj-y += setup.o x86_init.o i8259.o irqinit.o jump_label.o
16431 obj-$(CONFIG_IRQ_WORK) += irq_work.o
16432 obj-y += probe_roms.o
16433 -obj-$(CONFIG_X86_32) += i386_ksyms_32.o
16434 +obj-$(CONFIG_X86_32) += sys_i386_32.o i386_ksyms_32.o
16435 obj-$(CONFIG_X86_64) += sys_x86_64.o x8664_ksyms_64.o
16436 obj-y += syscall_$(BITS).o
16437 obj-$(CONFIG_X86_64) += vsyscall_64.o
16438 diff --git a/arch/x86/kernel/acpi/boot.c b/arch/x86/kernel/acpi/boot.c
16439 index bacf4b0..4ede72e 100644
16440 --- a/arch/x86/kernel/acpi/boot.c
16441 +++ b/arch/x86/kernel/acpi/boot.c
16442 @@ -1358,7 +1358,7 @@ static int __init dmi_ignore_irq0_timer_override(const struct dmi_system_id *d)
16443 * If your system is blacklisted here, but you find that acpi=force
16444 * works for you, please contact linux-acpi@vger.kernel.org
16445 */
16446 -static struct dmi_system_id __initdata acpi_dmi_table[] = {
16447 +static const struct dmi_system_id __initconst acpi_dmi_table[] = {
16448 /*
16449 * Boxes that need ACPI disabled
16450 */
16451 @@ -1433,7 +1433,7 @@ static struct dmi_system_id __initdata acpi_dmi_table[] = {
16452 };
16453
16454 /* second table for DMI checks that should run after early-quirks */
16455 -static struct dmi_system_id __initdata acpi_dmi_table_late[] = {
16456 +static const struct dmi_system_id __initconst acpi_dmi_table_late[] = {
16457 /*
16458 * HP laptops which use a DSDT reporting as HP/SB400/10000,
16459 * which includes some code which overrides all temperature
16460 diff --git a/arch/x86/kernel/acpi/sleep.c b/arch/x86/kernel/acpi/sleep.c
16461 index d5e0d71..6533e08 100644
16462 --- a/arch/x86/kernel/acpi/sleep.c
16463 +++ b/arch/x86/kernel/acpi/sleep.c
16464 @@ -74,8 +74,12 @@ int acpi_suspend_lowlevel(void)
16465 #else /* CONFIG_64BIT */
16466 #ifdef CONFIG_SMP
16467 stack_start = (unsigned long)temp_stack + sizeof(temp_stack);
16468 +
16469 + pax_open_kernel();
16470 early_gdt_descr.address =
16471 (unsigned long)get_cpu_gdt_table(smp_processor_id());
16472 + pax_close_kernel();
16473 +
16474 initial_gs = per_cpu_offset(smp_processor_id());
16475 #endif
16476 initial_code = (unsigned long)wakeup_long64;
16477 diff --git a/arch/x86/kernel/acpi/wakeup_32.S b/arch/x86/kernel/acpi/wakeup_32.S
16478 index 13ab720..95d5442 100644
16479 --- a/arch/x86/kernel/acpi/wakeup_32.S
16480 +++ b/arch/x86/kernel/acpi/wakeup_32.S
16481 @@ -30,13 +30,11 @@ wakeup_pmode_return:
16482 # and restore the stack ... but you need gdt for this to work
16483 movl saved_context_esp, %esp
16484
16485 - movl %cs:saved_magic, %eax
16486 - cmpl $0x12345678, %eax
16487 + cmpl $0x12345678, saved_magic
16488 jne bogus_magic
16489
16490 # jump to place where we left off
16491 - movl saved_eip, %eax
16492 - jmp *%eax
16493 + jmp *(saved_eip)
16494
16495 bogus_magic:
16496 jmp bogus_magic
16497 diff --git a/arch/x86/kernel/alternative.c b/arch/x86/kernel/alternative.c
16498 index ef5ccca..bd83949 100644
16499 --- a/arch/x86/kernel/alternative.c
16500 +++ b/arch/x86/kernel/alternative.c
16501 @@ -268,6 +268,13 @@ void __init_or_module apply_alternatives(struct alt_instr *start,
16502 */
16503 for (a = start; a < end; a++) {
16504 instr = (u8 *)&a->instr_offset + a->instr_offset;
16505 +
16506 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
16507 + instr += ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
16508 + if (instr < (u8 *)_text || (u8 *)_einittext <= instr)
16509 + instr -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
16510 +#endif
16511 +
16512 replacement = (u8 *)&a->repl_offset + a->repl_offset;
16513 BUG_ON(a->replacementlen > a->instrlen);
16514 BUG_ON(a->instrlen > sizeof(insnbuf));
16515 @@ -299,10 +306,16 @@ static void alternatives_smp_lock(const s32 *start, const s32 *end,
16516 for (poff = start; poff < end; poff++) {
16517 u8 *ptr = (u8 *)poff + *poff;
16518
16519 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
16520 + ptr += ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
16521 + if (ptr < (u8 *)_text || (u8 *)_einittext <= ptr)
16522 + ptr -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
16523 +#endif
16524 +
16525 if (!*poff || ptr < text || ptr >= text_end)
16526 continue;
16527 /* turn DS segment override prefix into lock prefix */
16528 - if (*ptr == 0x3e)
16529 + if (*ktla_ktva(ptr) == 0x3e)
16530 text_poke(ptr, ((unsigned char []){0xf0}), 1);
16531 }
16532 mutex_unlock(&text_mutex);
16533 @@ -317,10 +330,16 @@ static void alternatives_smp_unlock(const s32 *start, const s32 *end,
16534 for (poff = start; poff < end; poff++) {
16535 u8 *ptr = (u8 *)poff + *poff;
16536
16537 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
16538 + ptr += ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
16539 + if (ptr < (u8 *)_text || (u8 *)_einittext <= ptr)
16540 + ptr -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
16541 +#endif
16542 +
16543 if (!*poff || ptr < text || ptr >= text_end)
16544 continue;
16545 /* turn lock prefix into DS segment override prefix */
16546 - if (*ptr == 0xf0)
16547 + if (*ktla_ktva(ptr) == 0xf0)
16548 text_poke(ptr, ((unsigned char []){0x3E}), 1);
16549 }
16550 mutex_unlock(&text_mutex);
16551 @@ -468,7 +487,7 @@ void __init_or_module apply_paravirt(struct paravirt_patch_site *start,
16552
16553 BUG_ON(p->len > MAX_PATCH_LEN);
16554 /* prep the buffer with the original instructions */
16555 - memcpy(insnbuf, p->instr, p->len);
16556 + memcpy(insnbuf, ktla_ktva(p->instr), p->len);
16557 used = pv_init_ops.patch(p->instrtype, p->clobbers, insnbuf,
16558 (unsigned long)p->instr, p->len);
16559
16560 @@ -515,7 +534,7 @@ void __init alternative_instructions(void)
16561 if (!uniproc_patched || num_possible_cpus() == 1)
16562 free_init_pages("SMP alternatives",
16563 (unsigned long)__smp_locks,
16564 - (unsigned long)__smp_locks_end);
16565 + PAGE_ALIGN((unsigned long)__smp_locks_end));
16566 #endif
16567
16568 apply_paravirt(__parainstructions, __parainstructions_end);
16569 @@ -535,13 +554,17 @@ void __init alternative_instructions(void)
16570 * instructions. And on the local CPU you need to be protected again NMI or MCE
16571 * handlers seeing an inconsistent instruction while you patch.
16572 */
16573 -void *__init_or_module text_poke_early(void *addr, const void *opcode,
16574 +void *__kprobes text_poke_early(void *addr, const void *opcode,
16575 size_t len)
16576 {
16577 unsigned long flags;
16578 local_irq_save(flags);
16579 - memcpy(addr, opcode, len);
16580 +
16581 + pax_open_kernel();
16582 + memcpy(ktla_ktva(addr), opcode, len);
16583 sync_core();
16584 + pax_close_kernel();
16585 +
16586 local_irq_restore(flags);
16587 /* Could also do a CLFLUSH here to speed up CPU recovery; but
16588 that causes hangs on some VIA CPUs. */
16589 @@ -563,36 +586,22 @@ void *__init_or_module text_poke_early(void *addr, const void *opcode,
16590 */
16591 void *__kprobes text_poke(void *addr, const void *opcode, size_t len)
16592 {
16593 - unsigned long flags;
16594 - char *vaddr;
16595 + unsigned char *vaddr = ktla_ktva(addr);
16596 struct page *pages[2];
16597 - int i;
16598 + size_t i;
16599
16600 if (!core_kernel_text((unsigned long)addr)) {
16601 - pages[0] = vmalloc_to_page(addr);
16602 - pages[1] = vmalloc_to_page(addr + PAGE_SIZE);
16603 + pages[0] = vmalloc_to_page(vaddr);
16604 + pages[1] = vmalloc_to_page(vaddr + PAGE_SIZE);
16605 } else {
16606 - pages[0] = virt_to_page(addr);
16607 + pages[0] = virt_to_page(vaddr);
16608 WARN_ON(!PageReserved(pages[0]));
16609 - pages[1] = virt_to_page(addr + PAGE_SIZE);
16610 + pages[1] = virt_to_page(vaddr + PAGE_SIZE);
16611 }
16612 BUG_ON(!pages[0]);
16613 - local_irq_save(flags);
16614 - set_fixmap(FIX_TEXT_POKE0, page_to_phys(pages[0]));
16615 - if (pages[1])
16616 - set_fixmap(FIX_TEXT_POKE1, page_to_phys(pages[1]));
16617 - vaddr = (char *)fix_to_virt(FIX_TEXT_POKE0);
16618 - memcpy(&vaddr[(unsigned long)addr & ~PAGE_MASK], opcode, len);
16619 - clear_fixmap(FIX_TEXT_POKE0);
16620 - if (pages[1])
16621 - clear_fixmap(FIX_TEXT_POKE1);
16622 - local_flush_tlb();
16623 - sync_core();
16624 - /* Could also do a CLFLUSH here to speed up CPU recovery; but
16625 - that causes hangs on some VIA CPUs. */
16626 + text_poke_early(addr, opcode, len);
16627 for (i = 0; i < len; i++)
16628 - BUG_ON(((char *)addr)[i] != ((char *)opcode)[i]);
16629 - local_irq_restore(flags);
16630 + BUG_ON((vaddr)[i] != ((const unsigned char *)opcode)[i]);
16631 return addr;
16632 }
16633
16634 diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c
16635 index cbf5121..812b537 100644
16636 --- a/arch/x86/kernel/apic/apic.c
16637 +++ b/arch/x86/kernel/apic/apic.c
16638 @@ -189,7 +189,7 @@ int first_system_vector = 0xfe;
16639 /*
16640 * Debug level, exported for io_apic.c
16641 */
16642 -unsigned int apic_verbosity;
16643 +int apic_verbosity;
16644
16645 int pic_mode;
16646
16647 @@ -1956,7 +1956,7 @@ void smp_error_interrupt(struct pt_regs *regs)
16648 apic_write(APIC_ESR, 0);
16649 v1 = apic_read(APIC_ESR);
16650 ack_APIC_irq();
16651 - atomic_inc(&irq_err_count);
16652 + atomic_inc_unchecked(&irq_err_count);
16653
16654 apic_printk(APIC_DEBUG, KERN_DEBUG "APIC error on CPU%d: %02x(%02x)",
16655 smp_processor_id(), v0 , v1);
16656 diff --git a/arch/x86/kernel/apic/apic_flat_64.c b/arch/x86/kernel/apic/apic_flat_64.c
16657 index 00c77cf..2dc6a2d 100644
16658 --- a/arch/x86/kernel/apic/apic_flat_64.c
16659 +++ b/arch/x86/kernel/apic/apic_flat_64.c
16660 @@ -157,7 +157,7 @@ static int flat_probe(void)
16661 return 1;
16662 }
16663
16664 -static struct apic apic_flat = {
16665 +static struct apic apic_flat __read_only = {
16666 .name = "flat",
16667 .probe = flat_probe,
16668 .acpi_madt_oem_check = flat_acpi_madt_oem_check,
16669 @@ -271,7 +271,7 @@ static int physflat_probe(void)
16670 return 0;
16671 }
16672
16673 -static struct apic apic_physflat = {
16674 +static struct apic apic_physflat __read_only = {
16675
16676 .name = "physical flat",
16677 .probe = physflat_probe,
16678 diff --git a/arch/x86/kernel/apic/apic_noop.c b/arch/x86/kernel/apic/apic_noop.c
16679 index e145f28..2752888 100644
16680 --- a/arch/x86/kernel/apic/apic_noop.c
16681 +++ b/arch/x86/kernel/apic/apic_noop.c
16682 @@ -119,7 +119,7 @@ static void noop_apic_write(u32 reg, u32 v)
16683 WARN_ON_ONCE(cpu_has_apic && !disable_apic);
16684 }
16685
16686 -struct apic apic_noop = {
16687 +struct apic apic_noop __read_only = {
16688 .name = "noop",
16689 .probe = noop_probe,
16690 .acpi_madt_oem_check = NULL,
16691 diff --git a/arch/x86/kernel/apic/bigsmp_32.c b/arch/x86/kernel/apic/bigsmp_32.c
16692 index d50e364..543bee3 100644
16693 --- a/arch/x86/kernel/apic/bigsmp_32.c
16694 +++ b/arch/x86/kernel/apic/bigsmp_32.c
16695 @@ -152,7 +152,7 @@ static int probe_bigsmp(void)
16696 return dmi_bigsmp;
16697 }
16698
16699 -static struct apic apic_bigsmp = {
16700 +static struct apic apic_bigsmp __read_only = {
16701
16702 .name = "bigsmp",
16703 .probe = probe_bigsmp,
16704 diff --git a/arch/x86/kernel/apic/es7000_32.c b/arch/x86/kernel/apic/es7000_32.c
16705 index 0874799..a7a7892 100644
16706 --- a/arch/x86/kernel/apic/es7000_32.c
16707 +++ b/arch/x86/kernel/apic/es7000_32.c
16708 @@ -608,8 +608,7 @@ static int es7000_mps_oem_check_cluster(struct mpc_table *mpc, char *oem,
16709 return ret && es7000_apic_is_cluster();
16710 }
16711
16712 -/* We've been warned by a false positive warning.Use __refdata to keep calm. */
16713 -static struct apic __refdata apic_es7000_cluster = {
16714 +static struct apic apic_es7000_cluster __read_only = {
16715
16716 .name = "es7000",
16717 .probe = probe_es7000,
16718 @@ -675,7 +674,7 @@ static struct apic __refdata apic_es7000_cluster = {
16719 .x86_32_early_logical_apicid = es7000_early_logical_apicid,
16720 };
16721
16722 -static struct apic __refdata apic_es7000 = {
16723 +static struct apic apic_es7000 __read_only = {
16724
16725 .name = "es7000",
16726 .probe = probe_es7000,
16727 diff --git a/arch/x86/kernel/apic/io_apic.c b/arch/x86/kernel/apic/io_apic.c
16728 index b739d39..aebc14c 100644
16729 --- a/arch/x86/kernel/apic/io_apic.c
16730 +++ b/arch/x86/kernel/apic/io_apic.c
16731 @@ -1084,7 +1084,7 @@ int IO_APIC_get_PCI_irq_vector(int bus, int slot, int pin,
16732 }
16733 EXPORT_SYMBOL(IO_APIC_get_PCI_irq_vector);
16734
16735 -void lock_vector_lock(void)
16736 +void lock_vector_lock(void) __acquires(vector_lock)
16737 {
16738 /* Used to the online set of cpus does not change
16739 * during assign_irq_vector.
16740 @@ -1092,7 +1092,7 @@ void lock_vector_lock(void)
16741 raw_spin_lock(&vector_lock);
16742 }
16743
16744 -void unlock_vector_lock(void)
16745 +void unlock_vector_lock(void) __releases(vector_lock)
16746 {
16747 raw_spin_unlock(&vector_lock);
16748 }
16749 @@ -2399,7 +2399,7 @@ static void ack_apic_edge(struct irq_data *data)
16750 ack_APIC_irq();
16751 }
16752
16753 -atomic_t irq_mis_count;
16754 +atomic_unchecked_t irq_mis_count;
16755
16756 #ifdef CONFIG_GENERIC_PENDING_IRQ
16757 static bool io_apic_level_ack_pending(struct irq_cfg *cfg)
16758 @@ -2540,7 +2540,7 @@ static void ack_apic_level(struct irq_data *data)
16759 * at the cpu.
16760 */
16761 if (!(v & (1 << (i & 0x1f)))) {
16762 - atomic_inc(&irq_mis_count);
16763 + atomic_inc_unchecked(&irq_mis_count);
16764
16765 eoi_ioapic_irq(irq, cfg);
16766 }
16767 @@ -2567,11 +2567,13 @@ static void ir_print_prefix(struct irq_data *data, struct seq_file *p)
16768
16769 static void irq_remap_modify_chip_defaults(struct irq_chip *chip)
16770 {
16771 - chip->irq_print_chip = ir_print_prefix;
16772 - chip->irq_ack = ir_ack_apic_edge;
16773 - chip->irq_eoi = ir_ack_apic_level;
16774 + pax_open_kernel();
16775 + *(void **)&chip->irq_print_chip = ir_print_prefix;
16776 + *(void **)&chip->irq_ack = ir_ack_apic_edge;
16777 + *(void **)&chip->irq_eoi = ir_ack_apic_level;
16778
16779 - chip->irq_set_affinity = set_remapped_irq_affinity;
16780 + *(void **)&chip->irq_set_affinity = set_remapped_irq_affinity;
16781 + pax_close_kernel();
16782 }
16783 #endif /* CONFIG_IRQ_REMAP */
16784
16785 diff --git a/arch/x86/kernel/apic/numaq_32.c b/arch/x86/kernel/apic/numaq_32.c
16786 index d661ee9..791fd33 100644
16787 --- a/arch/x86/kernel/apic/numaq_32.c
16788 +++ b/arch/x86/kernel/apic/numaq_32.c
16789 @@ -455,8 +455,7 @@ static void numaq_setup_portio_remap(void)
16790 (u_long) xquad_portio, (u_long) num_quads*XQUAD_PORTIO_QUAD);
16791 }
16792
16793 -/* Use __refdata to keep false positive warning calm. */
16794 -static struct apic __refdata apic_numaq = {
16795 +static struct apic apic_numaq __read_only = {
16796
16797 .name = "NUMAQ",
16798 .probe = probe_numaq,
16799 diff --git a/arch/x86/kernel/apic/probe_32.c b/arch/x86/kernel/apic/probe_32.c
16800 index eb35ef9..f184a21 100644
16801 --- a/arch/x86/kernel/apic/probe_32.c
16802 +++ b/arch/x86/kernel/apic/probe_32.c
16803 @@ -72,7 +72,7 @@ static int probe_default(void)
16804 return 1;
16805 }
16806
16807 -static struct apic apic_default = {
16808 +static struct apic apic_default __read_only = {
16809
16810 .name = "default",
16811 .probe = probe_default,
16812 diff --git a/arch/x86/kernel/apic/summit_32.c b/arch/x86/kernel/apic/summit_32.c
16813 index 77c95c0..434f8a4 100644
16814 --- a/arch/x86/kernel/apic/summit_32.c
16815 +++ b/arch/x86/kernel/apic/summit_32.c
16816 @@ -486,7 +486,7 @@ void setup_summit(void)
16817 }
16818 #endif
16819
16820 -static struct apic apic_summit = {
16821 +static struct apic apic_summit __read_only = {
16822
16823 .name = "summit",
16824 .probe = probe_summit,
16825 diff --git a/arch/x86/kernel/apic/x2apic_cluster.c b/arch/x86/kernel/apic/x2apic_cluster.c
16826 index c88baa4..757aee1 100644
16827 --- a/arch/x86/kernel/apic/x2apic_cluster.c
16828 +++ b/arch/x86/kernel/apic/x2apic_cluster.c
16829 @@ -183,7 +183,7 @@ update_clusterinfo(struct notifier_block *nfb, unsigned long action, void *hcpu)
16830 return notifier_from_errno(err);
16831 }
16832
16833 -static struct notifier_block __refdata x2apic_cpu_notifier = {
16834 +static struct notifier_block x2apic_cpu_notifier = {
16835 .notifier_call = update_clusterinfo,
16836 };
16837
16838 @@ -235,7 +235,7 @@ static void cluster_vector_allocation_domain(int cpu, struct cpumask *retmask,
16839 cpumask_and(retmask, mask, per_cpu(cpus_in_cluster, cpu));
16840 }
16841
16842 -static struct apic apic_x2apic_cluster = {
16843 +static struct apic apic_x2apic_cluster __read_only = {
16844
16845 .name = "cluster x2apic",
16846 .probe = x2apic_cluster_probe,
16847 diff --git a/arch/x86/kernel/apic/x2apic_phys.c b/arch/x86/kernel/apic/x2apic_phys.c
16848 index 562a76d..a003c0f 100644
16849 --- a/arch/x86/kernel/apic/x2apic_phys.c
16850 +++ b/arch/x86/kernel/apic/x2apic_phys.c
16851 @@ -89,7 +89,7 @@ static int x2apic_phys_probe(void)
16852 return apic == &apic_x2apic_phys;
16853 }
16854
16855 -static struct apic apic_x2apic_phys = {
16856 +static struct apic apic_x2apic_phys __read_only = {
16857
16858 .name = "physical x2apic",
16859 .probe = x2apic_phys_probe,
16860 diff --git a/arch/x86/kernel/apic/x2apic_uv_x.c b/arch/x86/kernel/apic/x2apic_uv_x.c
16861 index 8cfade9..b9d04fc 100644
16862 --- a/arch/x86/kernel/apic/x2apic_uv_x.c
16863 +++ b/arch/x86/kernel/apic/x2apic_uv_x.c
16864 @@ -333,7 +333,7 @@ static int uv_probe(void)
16865 return apic == &apic_x2apic_uv_x;
16866 }
16867
16868 -static struct apic __refdata apic_x2apic_uv_x = {
16869 +static struct apic apic_x2apic_uv_x __read_only = {
16870
16871 .name = "UV large system",
16872 .probe = uv_probe,
16873 diff --git a/arch/x86/kernel/apm_32.c b/arch/x86/kernel/apm_32.c
16874 index d65464e..1035d31 100644
16875 --- a/arch/x86/kernel/apm_32.c
16876 +++ b/arch/x86/kernel/apm_32.c
16877 @@ -412,7 +412,7 @@ static DEFINE_MUTEX(apm_mutex);
16878 * This is for buggy BIOS's that refer to (real mode) segment 0x40
16879 * even though they are called in protected mode.
16880 */
16881 -static struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4092,
16882 +static const struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4093,
16883 (unsigned long)__va(0x400UL), PAGE_SIZE - 0x400 - 1);
16884
16885 static const char driver_version[] = "1.16ac"; /* no spaces */
16886 @@ -590,7 +590,10 @@ static long __apm_bios_call(void *_call)
16887 BUG_ON(cpu != 0);
16888 gdt = get_cpu_gdt_table(cpu);
16889 save_desc_40 = gdt[0x40 / 8];
16890 +
16891 + pax_open_kernel();
16892 gdt[0x40 / 8] = bad_bios_desc;
16893 + pax_close_kernel();
16894
16895 apm_irq_save(flags);
16896 APM_DO_SAVE_SEGS;
16897 @@ -599,7 +602,11 @@ static long __apm_bios_call(void *_call)
16898 &call->esi);
16899 APM_DO_RESTORE_SEGS;
16900 apm_irq_restore(flags);
16901 +
16902 + pax_open_kernel();
16903 gdt[0x40 / 8] = save_desc_40;
16904 + pax_close_kernel();
16905 +
16906 put_cpu();
16907
16908 return call->eax & 0xff;
16909 @@ -666,7 +673,10 @@ static long __apm_bios_call_simple(void *_call)
16910 BUG_ON(cpu != 0);
16911 gdt = get_cpu_gdt_table(cpu);
16912 save_desc_40 = gdt[0x40 / 8];
16913 +
16914 + pax_open_kernel();
16915 gdt[0x40 / 8] = bad_bios_desc;
16916 + pax_close_kernel();
16917
16918 apm_irq_save(flags);
16919 APM_DO_SAVE_SEGS;
16920 @@ -674,7 +684,11 @@ static long __apm_bios_call_simple(void *_call)
16921 &call->eax);
16922 APM_DO_RESTORE_SEGS;
16923 apm_irq_restore(flags);
16924 +
16925 + pax_open_kernel();
16926 gdt[0x40 / 8] = save_desc_40;
16927 + pax_close_kernel();
16928 +
16929 put_cpu();
16930 return error;
16931 }
16932 @@ -2345,12 +2359,15 @@ static int __init apm_init(void)
16933 * code to that CPU.
16934 */
16935 gdt = get_cpu_gdt_table(0);
16936 +
16937 + pax_open_kernel();
16938 set_desc_base(&gdt[APM_CS >> 3],
16939 (unsigned long)__va((unsigned long)apm_info.bios.cseg << 4));
16940 set_desc_base(&gdt[APM_CS_16 >> 3],
16941 (unsigned long)__va((unsigned long)apm_info.bios.cseg_16 << 4));
16942 set_desc_base(&gdt[APM_DS >> 3],
16943 (unsigned long)__va((unsigned long)apm_info.bios.dseg << 4));
16944 + pax_close_kernel();
16945
16946 proc_create("apm", 0, NULL, &apm_file_ops);
16947
16948 diff --git a/arch/x86/kernel/asm-offsets.c b/arch/x86/kernel/asm-offsets.c
16949 index 2861082..6d4718e 100644
16950 --- a/arch/x86/kernel/asm-offsets.c
16951 +++ b/arch/x86/kernel/asm-offsets.c
16952 @@ -33,6 +33,8 @@ void common(void) {
16953 OFFSET(TI_status, thread_info, status);
16954 OFFSET(TI_addr_limit, thread_info, addr_limit);
16955 OFFSET(TI_preempt_count, thread_info, preempt_count);
16956 + OFFSET(TI_lowest_stack, thread_info, lowest_stack);
16957 + DEFINE(TI_task_thread_sp0, offsetof(struct task_struct, thread.sp0) - offsetof(struct task_struct, tinfo));
16958
16959 BLANK();
16960 OFFSET(crypto_tfm_ctx_offset, crypto_tfm, __crt_ctx);
16961 @@ -53,8 +55,26 @@ void common(void) {
16962 OFFSET(PV_CPU_irq_enable_sysexit, pv_cpu_ops, irq_enable_sysexit);
16963 OFFSET(PV_CPU_read_cr0, pv_cpu_ops, read_cr0);
16964 OFFSET(PV_MMU_read_cr2, pv_mmu_ops, read_cr2);
16965 +
16966 +#ifdef CONFIG_PAX_KERNEXEC
16967 + OFFSET(PV_CPU_write_cr0, pv_cpu_ops, write_cr0);
16968 #endif
16969
16970 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16971 + OFFSET(PV_MMU_read_cr3, pv_mmu_ops, read_cr3);
16972 + OFFSET(PV_MMU_write_cr3, pv_mmu_ops, write_cr3);
16973 +#ifdef CONFIG_X86_64
16974 + OFFSET(PV_MMU_set_pgd_batched, pv_mmu_ops, set_pgd_batched);
16975 +#endif
16976 +#endif
16977 +
16978 +#endif
16979 +
16980 + BLANK();
16981 + DEFINE(PAGE_SIZE_asm, PAGE_SIZE);
16982 + DEFINE(PAGE_SHIFT_asm, PAGE_SHIFT);
16983 + DEFINE(THREAD_SIZE_asm, THREAD_SIZE);
16984 +
16985 #ifdef CONFIG_XEN
16986 BLANK();
16987 OFFSET(XEN_vcpu_info_mask, vcpu_info, evtchn_upcall_mask);
16988 diff --git a/arch/x86/kernel/asm-offsets_64.c b/arch/x86/kernel/asm-offsets_64.c
16989 index 1b4754f..fbb4227 100644
16990 --- a/arch/x86/kernel/asm-offsets_64.c
16991 +++ b/arch/x86/kernel/asm-offsets_64.c
16992 @@ -76,6 +76,7 @@ int main(void)
16993 BLANK();
16994 #undef ENTRY
16995
16996 + DEFINE(TSS_size, sizeof(struct tss_struct));
16997 OFFSET(TSS_ist, tss_struct, x86_tss.ist);
16998 BLANK();
16999
17000 diff --git a/arch/x86/kernel/cpu/Makefile b/arch/x86/kernel/cpu/Makefile
17001 index a0e067d..9c7db16 100644
17002 --- a/arch/x86/kernel/cpu/Makefile
17003 +++ b/arch/x86/kernel/cpu/Makefile
17004 @@ -8,10 +8,6 @@ CFLAGS_REMOVE_common.o = -pg
17005 CFLAGS_REMOVE_perf_event.o = -pg
17006 endif
17007
17008 -# Make sure load_percpu_segment has no stackprotector
17009 -nostackp := $(call cc-option, -fno-stack-protector)
17010 -CFLAGS_common.o := $(nostackp)
17011 -
17012 obj-y := intel_cacheinfo.o scattered.o topology.o
17013 obj-y += proc.o capflags.o powerflags.o common.o
17014 obj-y += vmware.o hypervisor.o mshyperv.o
17015 diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c
17016 index 15239ff..e23e04e 100644
17017 --- a/arch/x86/kernel/cpu/amd.c
17018 +++ b/arch/x86/kernel/cpu/amd.c
17019 @@ -733,7 +733,7 @@ static unsigned int __cpuinit amd_size_cache(struct cpuinfo_x86 *c,
17020 unsigned int size)
17021 {
17022 /* AMD errata T13 (order #21922) */
17023 - if ((c->x86 == 6)) {
17024 + if (c->x86 == 6) {
17025 /* Duron Rev A0 */
17026 if (c->x86_model == 3 && c->x86_mask == 0)
17027 size = 64;
17028 diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
17029 index 9c3ab43..51e6366 100644
17030 --- a/arch/x86/kernel/cpu/common.c
17031 +++ b/arch/x86/kernel/cpu/common.c
17032 @@ -86,60 +86,6 @@ static const struct cpu_dev __cpuinitconst default_cpu = {
17033
17034 static const struct cpu_dev *this_cpu __cpuinitdata = &default_cpu;
17035
17036 -DEFINE_PER_CPU_PAGE_ALIGNED(struct gdt_page, gdt_page) = { .gdt = {
17037 -#ifdef CONFIG_X86_64
17038 - /*
17039 - * We need valid kernel segments for data and code in long mode too
17040 - * IRET will check the segment types kkeil 2000/10/28
17041 - * Also sysret mandates a special GDT layout
17042 - *
17043 - * TLS descriptors are currently at a different place compared to i386.
17044 - * Hopefully nobody expects them at a fixed place (Wine?)
17045 - */
17046 - [GDT_ENTRY_KERNEL32_CS] = GDT_ENTRY_INIT(0xc09b, 0, 0xfffff),
17047 - [GDT_ENTRY_KERNEL_CS] = GDT_ENTRY_INIT(0xa09b, 0, 0xfffff),
17048 - [GDT_ENTRY_KERNEL_DS] = GDT_ENTRY_INIT(0xc093, 0, 0xfffff),
17049 - [GDT_ENTRY_DEFAULT_USER32_CS] = GDT_ENTRY_INIT(0xc0fb, 0, 0xfffff),
17050 - [GDT_ENTRY_DEFAULT_USER_DS] = GDT_ENTRY_INIT(0xc0f3, 0, 0xfffff),
17051 - [GDT_ENTRY_DEFAULT_USER_CS] = GDT_ENTRY_INIT(0xa0fb, 0, 0xfffff),
17052 -#else
17053 - [GDT_ENTRY_KERNEL_CS] = GDT_ENTRY_INIT(0xc09a, 0, 0xfffff),
17054 - [GDT_ENTRY_KERNEL_DS] = GDT_ENTRY_INIT(0xc092, 0, 0xfffff),
17055 - [GDT_ENTRY_DEFAULT_USER_CS] = GDT_ENTRY_INIT(0xc0fa, 0, 0xfffff),
17056 - [GDT_ENTRY_DEFAULT_USER_DS] = GDT_ENTRY_INIT(0xc0f2, 0, 0xfffff),
17057 - /*
17058 - * Segments used for calling PnP BIOS have byte granularity.
17059 - * They code segments and data segments have fixed 64k limits,
17060 - * the transfer segment sizes are set at run time.
17061 - */
17062 - /* 32-bit code */
17063 - [GDT_ENTRY_PNPBIOS_CS32] = GDT_ENTRY_INIT(0x409a, 0, 0xffff),
17064 - /* 16-bit code */
17065 - [GDT_ENTRY_PNPBIOS_CS16] = GDT_ENTRY_INIT(0x009a, 0, 0xffff),
17066 - /* 16-bit data */
17067 - [GDT_ENTRY_PNPBIOS_DS] = GDT_ENTRY_INIT(0x0092, 0, 0xffff),
17068 - /* 16-bit data */
17069 - [GDT_ENTRY_PNPBIOS_TS1] = GDT_ENTRY_INIT(0x0092, 0, 0),
17070 - /* 16-bit data */
17071 - [GDT_ENTRY_PNPBIOS_TS2] = GDT_ENTRY_INIT(0x0092, 0, 0),
17072 - /*
17073 - * The APM segments have byte granularity and their bases
17074 - * are set at run time. All have 64k limits.
17075 - */
17076 - /* 32-bit code */
17077 - [GDT_ENTRY_APMBIOS_BASE] = GDT_ENTRY_INIT(0x409a, 0, 0xffff),
17078 - /* 16-bit code */
17079 - [GDT_ENTRY_APMBIOS_BASE+1] = GDT_ENTRY_INIT(0x009a, 0, 0xffff),
17080 - /* data */
17081 - [GDT_ENTRY_APMBIOS_BASE+2] = GDT_ENTRY_INIT(0x4092, 0, 0xffff),
17082 -
17083 - [GDT_ENTRY_ESPFIX_SS] = GDT_ENTRY_INIT(0xc092, 0, 0xfffff),
17084 - [GDT_ENTRY_PERCPU] = GDT_ENTRY_INIT(0xc092, 0, 0xfffff),
17085 - GDT_STACK_CANARY_INIT
17086 -#endif
17087 -} };
17088 -EXPORT_PER_CPU_SYMBOL_GPL(gdt_page);
17089 -
17090 static int __init x86_xsave_setup(char *s)
17091 {
17092 setup_clear_cpu_cap(X86_FEATURE_XSAVE);
17093 @@ -389,7 +335,7 @@ void switch_to_new_gdt(int cpu)
17094 {
17095 struct desc_ptr gdt_descr;
17096
17097 - gdt_descr.address = (long)get_cpu_gdt_table(cpu);
17098 + gdt_descr.address = (unsigned long)get_cpu_gdt_table(cpu);
17099 gdt_descr.size = GDT_SIZE - 1;
17100 load_gdt(&gdt_descr);
17101 /* Reload the per-cpu base */
17102 @@ -885,6 +831,10 @@ static void __cpuinit identify_cpu(struct cpuinfo_x86 *c)
17103 /* Filter out anything that depends on CPUID levels we don't have */
17104 filter_cpuid_features(c, true);
17105
17106 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_SEGMEXEC) || defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF))
17107 + setup_clear_cpu_cap(X86_FEATURE_SEP);
17108 +#endif
17109 +
17110 /* If the model name is still unset, do table lookup. */
17111 if (!c->x86_model_id[0]) {
17112 const char *p;
17113 @@ -1068,10 +1018,12 @@ static __init int setup_disablecpuid(char *arg)
17114 }
17115 __setup("clearcpuid=", setup_disablecpuid);
17116
17117 +DEFINE_PER_CPU(struct thread_info *, current_tinfo) = &init_task.tinfo;
17118 +EXPORT_PER_CPU_SYMBOL(current_tinfo);
17119 +
17120 #ifdef CONFIG_X86_64
17121 struct desc_ptr idt_descr = { NR_VECTORS * 16 - 1, (unsigned long) idt_table };
17122 -struct desc_ptr nmi_idt_descr = { NR_VECTORS * 16 - 1,
17123 - (unsigned long) nmi_idt_table };
17124 +struct desc_ptr nmi_idt_descr = { NR_VECTORS * 16 - 1, (unsigned long) nmi_idt_table };
17125
17126 DEFINE_PER_CPU_FIRST(union irq_stack_union,
17127 irq_stack_union) __aligned(PAGE_SIZE);
17128 @@ -1085,7 +1037,7 @@ DEFINE_PER_CPU(struct task_struct *, current_task) ____cacheline_aligned =
17129 EXPORT_PER_CPU_SYMBOL(current_task);
17130
17131 DEFINE_PER_CPU(unsigned long, kernel_stack) =
17132 - (unsigned long)&init_thread_union - KERNEL_STACK_OFFSET + THREAD_SIZE;
17133 + (unsigned long)&init_thread_union - 16 + THREAD_SIZE;
17134 EXPORT_PER_CPU_SYMBOL(kernel_stack);
17135
17136 DEFINE_PER_CPU(char *, irq_stack_ptr) =
17137 @@ -1224,7 +1176,7 @@ void __cpuinit cpu_init(void)
17138 int i;
17139
17140 cpu = stack_smp_processor_id();
17141 - t = &per_cpu(init_tss, cpu);
17142 + t = init_tss + cpu;
17143 oist = &per_cpu(orig_ist, cpu);
17144
17145 #ifdef CONFIG_NUMA
17146 @@ -1250,7 +1202,7 @@ void __cpuinit cpu_init(void)
17147 switch_to_new_gdt(cpu);
17148 loadsegment(fs, 0);
17149
17150 - load_idt((const struct desc_ptr *)&idt_descr);
17151 + load_idt(&idt_descr);
17152
17153 memset(me->thread.tls_array, 0, GDT_ENTRY_TLS_ENTRIES * 8);
17154 syscall_init();
17155 @@ -1259,7 +1211,6 @@ void __cpuinit cpu_init(void)
17156 wrmsrl(MSR_KERNEL_GS_BASE, 0);
17157 barrier();
17158
17159 - x86_configure_nx();
17160 enable_x2apic();
17161
17162 /*
17163 @@ -1311,7 +1262,7 @@ void __cpuinit cpu_init(void)
17164 {
17165 int cpu = smp_processor_id();
17166 struct task_struct *curr = current;
17167 - struct tss_struct *t = &per_cpu(init_tss, cpu);
17168 + struct tss_struct *t = init_tss + cpu;
17169 struct thread_struct *thread = &curr->thread;
17170
17171 if (cpumask_test_and_set_cpu(cpu, cpu_initialized_mask)) {
17172 diff --git a/arch/x86/kernel/cpu/intel.c b/arch/x86/kernel/cpu/intel.c
17173 index fcaabd0..7b55a26 100644
17174 --- a/arch/x86/kernel/cpu/intel.c
17175 +++ b/arch/x86/kernel/cpu/intel.c
17176 @@ -174,7 +174,7 @@ static void __cpuinit trap_init_f00f_bug(void)
17177 * Update the IDT descriptor and reload the IDT so that
17178 * it uses the read-only mapped virtual address.
17179 */
17180 - idt_descr.address = fix_to_virt(FIX_F00F_IDT);
17181 + idt_descr.address = (struct desc_struct *)fix_to_virt(FIX_F00F_IDT);
17182 load_idt(&idt_descr);
17183 }
17184 #endif
17185 diff --git a/arch/x86/kernel/cpu/intel_cacheinfo.c b/arch/x86/kernel/cpu/intel_cacheinfo.c
17186 index 84c1309..39b7224 100644
17187 --- a/arch/x86/kernel/cpu/intel_cacheinfo.c
17188 +++ b/arch/x86/kernel/cpu/intel_cacheinfo.c
17189 @@ -1017,6 +1017,22 @@ static struct attribute *default_attrs[] = {
17190 };
17191
17192 #ifdef CONFIG_AMD_NB
17193 +static struct attribute *default_attrs_amd_nb[] = {
17194 + &type.attr,
17195 + &level.attr,
17196 + &coherency_line_size.attr,
17197 + &physical_line_partition.attr,
17198 + &ways_of_associativity.attr,
17199 + &number_of_sets.attr,
17200 + &size.attr,
17201 + &shared_cpu_map.attr,
17202 + &shared_cpu_list.attr,
17203 + NULL,
17204 + NULL,
17205 + NULL,
17206 + NULL
17207 +};
17208 +
17209 static struct attribute ** __cpuinit amd_l3_attrs(void)
17210 {
17211 static struct attribute **attrs;
17212 @@ -1027,18 +1043,7 @@ static struct attribute ** __cpuinit amd_l3_attrs(void)
17213
17214 n = ARRAY_SIZE(default_attrs);
17215
17216 - if (amd_nb_has_feature(AMD_NB_L3_INDEX_DISABLE))
17217 - n += 2;
17218 -
17219 - if (amd_nb_has_feature(AMD_NB_L3_PARTITIONING))
17220 - n += 1;
17221 -
17222 - attrs = kzalloc(n * sizeof (struct attribute *), GFP_KERNEL);
17223 - if (attrs == NULL)
17224 - return attrs = default_attrs;
17225 -
17226 - for (n = 0; default_attrs[n]; n++)
17227 - attrs[n] = default_attrs[n];
17228 + attrs = default_attrs_amd_nb;
17229
17230 if (amd_nb_has_feature(AMD_NB_L3_INDEX_DISABLE)) {
17231 attrs[n++] = &cache_disable_0.attr;
17232 @@ -1089,6 +1094,13 @@ static struct kobj_type ktype_cache = {
17233 .default_attrs = default_attrs,
17234 };
17235
17236 +#ifdef CONFIG_AMD_NB
17237 +static struct kobj_type ktype_cache_amd_nb = {
17238 + .sysfs_ops = &sysfs_ops,
17239 + .default_attrs = default_attrs_amd_nb,
17240 +};
17241 +#endif
17242 +
17243 static struct kobj_type ktype_percpu_entry = {
17244 .sysfs_ops = &sysfs_ops,
17245 };
17246 @@ -1154,20 +1166,26 @@ static int __cpuinit cache_add_dev(struct device *dev)
17247 return retval;
17248 }
17249
17250 +#ifdef CONFIG_AMD_NB
17251 + amd_l3_attrs();
17252 +#endif
17253 +
17254 for (i = 0; i < num_cache_leaves; i++) {
17255 + struct kobj_type *ktype;
17256 +
17257 this_object = INDEX_KOBJECT_PTR(cpu, i);
17258 this_object->cpu = cpu;
17259 this_object->index = i;
17260
17261 this_leaf = CPUID4_INFO_IDX(cpu, i);
17262
17263 - ktype_cache.default_attrs = default_attrs;
17264 + ktype = &ktype_cache;
17265 #ifdef CONFIG_AMD_NB
17266 if (this_leaf->base.nb)
17267 - ktype_cache.default_attrs = amd_l3_attrs();
17268 + ktype = &ktype_cache_amd_nb;
17269 #endif
17270 retval = kobject_init_and_add(&(this_object->kobj),
17271 - &ktype_cache,
17272 + ktype,
17273 per_cpu(ici_cache_kobject, cpu),
17274 "index%1lu", i);
17275 if (unlikely(retval)) {
17276 @@ -1222,7 +1240,7 @@ static int __cpuinit cacheinfo_cpu_callback(struct notifier_block *nfb,
17277 return NOTIFY_OK;
17278 }
17279
17280 -static struct notifier_block __cpuinitdata cacheinfo_cpu_notifier = {
17281 +static struct notifier_block cacheinfo_cpu_notifier = {
17282 .notifier_call = cacheinfo_cpu_callback,
17283 };
17284
17285 diff --git a/arch/x86/kernel/cpu/mcheck/mce.c b/arch/x86/kernel/cpu/mcheck/mce.c
17286 index 80dbda8..be16652 100644
17287 --- a/arch/x86/kernel/cpu/mcheck/mce.c
17288 +++ b/arch/x86/kernel/cpu/mcheck/mce.c
17289 @@ -45,6 +45,7 @@
17290 #include <asm/processor.h>
17291 #include <asm/mce.h>
17292 #include <asm/msr.h>
17293 +#include <asm/local.h>
17294
17295 #include "mce-internal.h"
17296
17297 @@ -246,7 +247,7 @@ static void print_mce(struct mce *m)
17298 !(m->mcgstatus & MCG_STATUS_EIPV) ? " !INEXACT!" : "",
17299 m->cs, m->ip);
17300
17301 - if (m->cs == __KERNEL_CS)
17302 + if (m->cs == __KERNEL_CS || m->cs == __KERNEXEC_KERNEL_CS)
17303 print_symbol("{%s}", m->ip);
17304 pr_cont("\n");
17305 }
17306 @@ -279,10 +280,10 @@ static void print_mce(struct mce *m)
17307
17308 #define PANIC_TIMEOUT 5 /* 5 seconds */
17309
17310 -static atomic_t mce_paniced;
17311 +static atomic_unchecked_t mce_paniced;
17312
17313 static int fake_panic;
17314 -static atomic_t mce_fake_paniced;
17315 +static atomic_unchecked_t mce_fake_paniced;
17316
17317 /* Panic in progress. Enable interrupts and wait for final IPI */
17318 static void wait_for_panic(void)
17319 @@ -306,7 +307,7 @@ static void mce_panic(char *msg, struct mce *final, char *exp)
17320 /*
17321 * Make sure only one CPU runs in machine check panic
17322 */
17323 - if (atomic_inc_return(&mce_paniced) > 1)
17324 + if (atomic_inc_return_unchecked(&mce_paniced) > 1)
17325 wait_for_panic();
17326 barrier();
17327
17328 @@ -314,7 +315,7 @@ static void mce_panic(char *msg, struct mce *final, char *exp)
17329 console_verbose();
17330 } else {
17331 /* Don't log too much for fake panic */
17332 - if (atomic_inc_return(&mce_fake_paniced) > 1)
17333 + if (atomic_inc_return_unchecked(&mce_fake_paniced) > 1)
17334 return;
17335 }
17336 /* First print corrected ones that are still unlogged */
17337 @@ -686,7 +687,7 @@ static int mce_timed_out(u64 *t)
17338 * might have been modified by someone else.
17339 */
17340 rmb();
17341 - if (atomic_read(&mce_paniced))
17342 + if (atomic_read_unchecked(&mce_paniced))
17343 wait_for_panic();
17344 if (!mca_cfg.monarch_timeout)
17345 goto out;
17346 @@ -1662,7 +1663,7 @@ static void unexpected_machine_check(struct pt_regs *regs, long error_code)
17347 }
17348
17349 /* Call the installed machine check handler for this CPU setup. */
17350 -void (*machine_check_vector)(struct pt_regs *, long error_code) =
17351 +void (*machine_check_vector)(struct pt_regs *, long error_code) __read_only =
17352 unexpected_machine_check;
17353
17354 /*
17355 @@ -1685,7 +1686,9 @@ void __cpuinit mcheck_cpu_init(struct cpuinfo_x86 *c)
17356 return;
17357 }
17358
17359 + pax_open_kernel();
17360 machine_check_vector = do_machine_check;
17361 + pax_close_kernel();
17362
17363 __mcheck_cpu_init_generic();
17364 __mcheck_cpu_init_vendor(c);
17365 @@ -1699,7 +1702,7 @@ void __cpuinit mcheck_cpu_init(struct cpuinfo_x86 *c)
17366 */
17367
17368 static DEFINE_SPINLOCK(mce_chrdev_state_lock);
17369 -static int mce_chrdev_open_count; /* #times opened */
17370 +static local_t mce_chrdev_open_count; /* #times opened */
17371 static int mce_chrdev_open_exclu; /* already open exclusive? */
17372
17373 static int mce_chrdev_open(struct inode *inode, struct file *file)
17374 @@ -1707,7 +1710,7 @@ static int mce_chrdev_open(struct inode *inode, struct file *file)
17375 spin_lock(&mce_chrdev_state_lock);
17376
17377 if (mce_chrdev_open_exclu ||
17378 - (mce_chrdev_open_count && (file->f_flags & O_EXCL))) {
17379 + (local_read(&mce_chrdev_open_count) && (file->f_flags & O_EXCL))) {
17380 spin_unlock(&mce_chrdev_state_lock);
17381
17382 return -EBUSY;
17383 @@ -1715,7 +1718,7 @@ static int mce_chrdev_open(struct inode *inode, struct file *file)
17384
17385 if (file->f_flags & O_EXCL)
17386 mce_chrdev_open_exclu = 1;
17387 - mce_chrdev_open_count++;
17388 + local_inc(&mce_chrdev_open_count);
17389
17390 spin_unlock(&mce_chrdev_state_lock);
17391
17392 @@ -1726,7 +1729,7 @@ static int mce_chrdev_release(struct inode *inode, struct file *file)
17393 {
17394 spin_lock(&mce_chrdev_state_lock);
17395
17396 - mce_chrdev_open_count--;
17397 + local_dec(&mce_chrdev_open_count);
17398 mce_chrdev_open_exclu = 0;
17399
17400 spin_unlock(&mce_chrdev_state_lock);
17401 @@ -2372,7 +2375,7 @@ mce_cpu_callback(struct notifier_block *nfb, unsigned long action, void *hcpu)
17402 return NOTIFY_OK;
17403 }
17404
17405 -static struct notifier_block mce_cpu_notifier __cpuinitdata = {
17406 +static struct notifier_block mce_cpu_notifier = {
17407 .notifier_call = mce_cpu_callback,
17408 };
17409
17410 @@ -2382,7 +2385,7 @@ static __init void mce_init_banks(void)
17411
17412 for (i = 0; i < mca_cfg.banks; i++) {
17413 struct mce_bank *b = &mce_banks[i];
17414 - struct device_attribute *a = &b->attr;
17415 + device_attribute_no_const *a = &b->attr;
17416
17417 sysfs_attr_init(&a->attr);
17418 a->attr.name = b->attrname;
17419 @@ -2450,7 +2453,7 @@ struct dentry *mce_get_debugfs_dir(void)
17420 static void mce_reset(void)
17421 {
17422 cpu_missing = 0;
17423 - atomic_set(&mce_fake_paniced, 0);
17424 + atomic_set_unchecked(&mce_fake_paniced, 0);
17425 atomic_set(&mce_executing, 0);
17426 atomic_set(&mce_callin, 0);
17427 atomic_set(&global_nwo, 0);
17428 diff --git a/arch/x86/kernel/cpu/mcheck/p5.c b/arch/x86/kernel/cpu/mcheck/p5.c
17429 index 2d5454c..51987eb 100644
17430 --- a/arch/x86/kernel/cpu/mcheck/p5.c
17431 +++ b/arch/x86/kernel/cpu/mcheck/p5.c
17432 @@ -11,6 +11,7 @@
17433 #include <asm/processor.h>
17434 #include <asm/mce.h>
17435 #include <asm/msr.h>
17436 +#include <asm/pgtable.h>
17437
17438 /* By default disabled */
17439 int mce_p5_enabled __read_mostly;
17440 @@ -49,7 +50,9 @@ void intel_p5_mcheck_init(struct cpuinfo_x86 *c)
17441 if (!cpu_has(c, X86_FEATURE_MCE))
17442 return;
17443
17444 + pax_open_kernel();
17445 machine_check_vector = pentium_machine_check;
17446 + pax_close_kernel();
17447 /* Make sure the vector pointer is visible before we enable MCEs: */
17448 wmb();
17449
17450 diff --git a/arch/x86/kernel/cpu/mcheck/therm_throt.c b/arch/x86/kernel/cpu/mcheck/therm_throt.c
17451 index 47a1870..8c019a7 100644
17452 --- a/arch/x86/kernel/cpu/mcheck/therm_throt.c
17453 +++ b/arch/x86/kernel/cpu/mcheck/therm_throt.c
17454 @@ -288,7 +288,7 @@ thermal_throttle_cpu_callback(struct notifier_block *nfb,
17455 return notifier_from_errno(err);
17456 }
17457
17458 -static struct notifier_block thermal_throttle_cpu_notifier __cpuinitdata =
17459 +static struct notifier_block thermal_throttle_cpu_notifier =
17460 {
17461 .notifier_call = thermal_throttle_cpu_callback,
17462 };
17463 diff --git a/arch/x86/kernel/cpu/mcheck/winchip.c b/arch/x86/kernel/cpu/mcheck/winchip.c
17464 index 2d7998f..17c9de1 100644
17465 --- a/arch/x86/kernel/cpu/mcheck/winchip.c
17466 +++ b/arch/x86/kernel/cpu/mcheck/winchip.c
17467 @@ -10,6 +10,7 @@
17468 #include <asm/processor.h>
17469 #include <asm/mce.h>
17470 #include <asm/msr.h>
17471 +#include <asm/pgtable.h>
17472
17473 /* Machine check handler for WinChip C6: */
17474 static void winchip_machine_check(struct pt_regs *regs, long error_code)
17475 @@ -23,7 +24,9 @@ void winchip_mcheck_init(struct cpuinfo_x86 *c)
17476 {
17477 u32 lo, hi;
17478
17479 + pax_open_kernel();
17480 machine_check_vector = winchip_machine_check;
17481 + pax_close_kernel();
17482 /* Make sure the vector pointer is visible before we enable MCEs: */
17483 wmb();
17484
17485 diff --git a/arch/x86/kernel/cpu/mtrr/main.c b/arch/x86/kernel/cpu/mtrr/main.c
17486 index 726bf96..81f0526 100644
17487 --- a/arch/x86/kernel/cpu/mtrr/main.c
17488 +++ b/arch/x86/kernel/cpu/mtrr/main.c
17489 @@ -62,7 +62,7 @@ static DEFINE_MUTEX(mtrr_mutex);
17490 u64 size_or_mask, size_and_mask;
17491 static bool mtrr_aps_delayed_init;
17492
17493 -static const struct mtrr_ops *mtrr_ops[X86_VENDOR_NUM];
17494 +static const struct mtrr_ops *mtrr_ops[X86_VENDOR_NUM] __read_only;
17495
17496 const struct mtrr_ops *mtrr_if;
17497
17498 diff --git a/arch/x86/kernel/cpu/mtrr/mtrr.h b/arch/x86/kernel/cpu/mtrr/mtrr.h
17499 index df5e41f..816c719 100644
17500 --- a/arch/x86/kernel/cpu/mtrr/mtrr.h
17501 +++ b/arch/x86/kernel/cpu/mtrr/mtrr.h
17502 @@ -25,7 +25,7 @@ struct mtrr_ops {
17503 int (*validate_add_page)(unsigned long base, unsigned long size,
17504 unsigned int type);
17505 int (*have_wrcomb)(void);
17506 -};
17507 +} __do_const;
17508
17509 extern int generic_get_free_region(unsigned long base, unsigned long size,
17510 int replace_reg);
17511 diff --git a/arch/x86/kernel/cpu/perf_event.c b/arch/x86/kernel/cpu/perf_event.c
17512 index 6774c17..72c1b22 100644
17513 --- a/arch/x86/kernel/cpu/perf_event.c
17514 +++ b/arch/x86/kernel/cpu/perf_event.c
17515 @@ -1305,7 +1305,7 @@ static void __init pmu_check_apic(void)
17516 pr_info("no hardware sampling interrupt available.\n");
17517 }
17518
17519 -static struct attribute_group x86_pmu_format_group = {
17520 +static attribute_group_no_const x86_pmu_format_group = {
17521 .name = "format",
17522 .attrs = NULL,
17523 };
17524 @@ -1313,7 +1313,7 @@ static struct attribute_group x86_pmu_format_group = {
17525 struct perf_pmu_events_attr {
17526 struct device_attribute attr;
17527 u64 id;
17528 -};
17529 +} __do_const;
17530
17531 /*
17532 * Remove all undefined events (x86_pmu.event_map(id) == 0)
17533 @@ -1381,7 +1381,7 @@ static struct attribute *events_attr[] = {
17534 NULL,
17535 };
17536
17537 -static struct attribute_group x86_pmu_events_group = {
17538 +static attribute_group_no_const x86_pmu_events_group = {
17539 .name = "events",
17540 .attrs = events_attr,
17541 };
17542 @@ -1880,7 +1880,7 @@ static unsigned long get_segment_base(unsigned int segment)
17543 if (idx > GDT_ENTRIES)
17544 return 0;
17545
17546 - desc = __this_cpu_ptr(&gdt_page.gdt[0]);
17547 + desc = get_cpu_gdt_table(smp_processor_id());
17548 }
17549
17550 return get_desc_base(desc + idx);
17551 @@ -1970,7 +1970,7 @@ perf_callchain_user(struct perf_callchain_entry *entry, struct pt_regs *regs)
17552 break;
17553
17554 perf_callchain_store(entry, frame.return_address);
17555 - fp = frame.next_frame;
17556 + fp = (const void __force_user *)frame.next_frame;
17557 }
17558 }
17559
17560 diff --git a/arch/x86/kernel/cpu/perf_event_intel.c b/arch/x86/kernel/cpu/perf_event_intel.c
17561 index 4914e94..60b06e3 100644
17562 --- a/arch/x86/kernel/cpu/perf_event_intel.c
17563 +++ b/arch/x86/kernel/cpu/perf_event_intel.c
17564 @@ -1958,10 +1958,10 @@ __init int intel_pmu_init(void)
17565 * v2 and above have a perf capabilities MSR
17566 */
17567 if (version > 1) {
17568 - u64 capabilities;
17569 + u64 capabilities = x86_pmu.intel_cap.capabilities;
17570
17571 - rdmsrl(MSR_IA32_PERF_CAPABILITIES, capabilities);
17572 - x86_pmu.intel_cap.capabilities = capabilities;
17573 + if (rdmsrl_safe(MSR_IA32_PERF_CAPABILITIES, &x86_pmu.intel_cap.capabilities))
17574 + x86_pmu.intel_cap.capabilities = capabilities;
17575 }
17576
17577 intel_ds_init();
17578 diff --git a/arch/x86/kernel/cpu/perf_event_intel_uncore.c b/arch/x86/kernel/cpu/perf_event_intel_uncore.c
17579 index b43200d..d235b3e 100644
17580 --- a/arch/x86/kernel/cpu/perf_event_intel_uncore.c
17581 +++ b/arch/x86/kernel/cpu/perf_event_intel_uncore.c
17582 @@ -2428,7 +2428,7 @@ static void __init uncore_types_exit(struct intel_uncore_type **types)
17583 static int __init uncore_type_init(struct intel_uncore_type *type)
17584 {
17585 struct intel_uncore_pmu *pmus;
17586 - struct attribute_group *events_group;
17587 + attribute_group_no_const *attr_group;
17588 struct attribute **attrs;
17589 int i, j;
17590
17591 @@ -2455,19 +2455,19 @@ static int __init uncore_type_init(struct intel_uncore_type *type)
17592 while (type->event_descs[i].attr.attr.name)
17593 i++;
17594
17595 - events_group = kzalloc(sizeof(struct attribute *) * (i + 1) +
17596 - sizeof(*events_group), GFP_KERNEL);
17597 - if (!events_group)
17598 + attr_group = kzalloc(sizeof(struct attribute *) * (i + 1) +
17599 + sizeof(*attr_group), GFP_KERNEL);
17600 + if (!attr_group)
17601 goto fail;
17602
17603 - attrs = (struct attribute **)(events_group + 1);
17604 - events_group->name = "events";
17605 - events_group->attrs = attrs;
17606 + attrs = (struct attribute **)(attr_group + 1);
17607 + attr_group->name = "events";
17608 + attr_group->attrs = attrs;
17609
17610 for (j = 0; j < i; j++)
17611 attrs[j] = &type->event_descs[j].attr.attr;
17612
17613 - type->events_group = events_group;
17614 + type->events_group = attr_group;
17615 }
17616
17617 type->pmu_group = &uncore_pmu_attr_group;
17618 @@ -2826,7 +2826,7 @@ static int
17619 return NOTIFY_OK;
17620 }
17621
17622 -static struct notifier_block uncore_cpu_nb __cpuinitdata = {
17623 +static struct notifier_block uncore_cpu_nb = {
17624 .notifier_call = uncore_cpu_notifier,
17625 /*
17626 * to migrate uncore events, our notifier should be executed
17627 diff --git a/arch/x86/kernel/cpu/perf_event_intel_uncore.h b/arch/x86/kernel/cpu/perf_event_intel_uncore.h
17628 index e68a455..975a932 100644
17629 --- a/arch/x86/kernel/cpu/perf_event_intel_uncore.h
17630 +++ b/arch/x86/kernel/cpu/perf_event_intel_uncore.h
17631 @@ -428,7 +428,7 @@ struct intel_uncore_box {
17632 struct uncore_event_desc {
17633 struct kobj_attribute attr;
17634 const char *config;
17635 -};
17636 +} __do_const;
17637
17638 #define INTEL_UNCORE_EVENT_DESC(_name, _config) \
17639 { \
17640 diff --git a/arch/x86/kernel/cpuid.c b/arch/x86/kernel/cpuid.c
17641 index 60c7891..9e911d3 100644
17642 --- a/arch/x86/kernel/cpuid.c
17643 +++ b/arch/x86/kernel/cpuid.c
17644 @@ -171,7 +171,7 @@ static int __cpuinit cpuid_class_cpu_callback(struct notifier_block *nfb,
17645 return notifier_from_errno(err);
17646 }
17647
17648 -static struct notifier_block __refdata cpuid_class_cpu_notifier =
17649 +static struct notifier_block cpuid_class_cpu_notifier =
17650 {
17651 .notifier_call = cpuid_class_cpu_callback,
17652 };
17653 diff --git a/arch/x86/kernel/crash.c b/arch/x86/kernel/crash.c
17654 index 74467fe..18793d5 100644
17655 --- a/arch/x86/kernel/crash.c
17656 +++ b/arch/x86/kernel/crash.c
17657 @@ -58,10 +58,8 @@ static void kdump_nmi_callback(int cpu, struct pt_regs *regs)
17658 {
17659 #ifdef CONFIG_X86_32
17660 struct pt_regs fixed_regs;
17661 -#endif
17662
17663 -#ifdef CONFIG_X86_32
17664 - if (!user_mode_vm(regs)) {
17665 + if (!user_mode(regs)) {
17666 crash_fixup_ss_esp(&fixed_regs, regs);
17667 regs = &fixed_regs;
17668 }
17669 diff --git a/arch/x86/kernel/doublefault_32.c b/arch/x86/kernel/doublefault_32.c
17670 index 37250fe..bf2ec74 100644
17671 --- a/arch/x86/kernel/doublefault_32.c
17672 +++ b/arch/x86/kernel/doublefault_32.c
17673 @@ -11,7 +11,7 @@
17674
17675 #define DOUBLEFAULT_STACKSIZE (1024)
17676 static unsigned long doublefault_stack[DOUBLEFAULT_STACKSIZE];
17677 -#define STACK_START (unsigned long)(doublefault_stack+DOUBLEFAULT_STACKSIZE)
17678 +#define STACK_START (unsigned long)(doublefault_stack+DOUBLEFAULT_STACKSIZE-2)
17679
17680 #define ptr_ok(x) ((x) > PAGE_OFFSET && (x) < PAGE_OFFSET + MAXMEM)
17681
17682 @@ -21,7 +21,7 @@ static void doublefault_fn(void)
17683 unsigned long gdt, tss;
17684
17685 store_gdt(&gdt_desc);
17686 - gdt = gdt_desc.address;
17687 + gdt = (unsigned long)gdt_desc.address;
17688
17689 printk(KERN_EMERG "PANIC: double fault, gdt at %08lx [%d bytes]\n", gdt, gdt_desc.size);
17690
17691 @@ -58,10 +58,10 @@ struct tss_struct doublefault_tss __cacheline_aligned = {
17692 /* 0x2 bit is always set */
17693 .flags = X86_EFLAGS_SF | 0x2,
17694 .sp = STACK_START,
17695 - .es = __USER_DS,
17696 + .es = __KERNEL_DS,
17697 .cs = __KERNEL_CS,
17698 .ss = __KERNEL_DS,
17699 - .ds = __USER_DS,
17700 + .ds = __KERNEL_DS,
17701 .fs = __KERNEL_PERCPU,
17702
17703 .__cr3 = __pa_nodebug(swapper_pg_dir),
17704 diff --git a/arch/x86/kernel/dumpstack.c b/arch/x86/kernel/dumpstack.c
17705 index ae42418b..787c16b 100644
17706 --- a/arch/x86/kernel/dumpstack.c
17707 +++ b/arch/x86/kernel/dumpstack.c
17708 @@ -2,6 +2,9 @@
17709 * Copyright (C) 1991, 1992 Linus Torvalds
17710 * Copyright (C) 2000, 2001, 2002 Andi Kleen, SuSE Labs
17711 */
17712 +#ifdef CONFIG_GRKERNSEC_HIDESYM
17713 +#define __INCLUDED_BY_HIDESYM 1
17714 +#endif
17715 #include <linux/kallsyms.h>
17716 #include <linux/kprobes.h>
17717 #include <linux/uaccess.h>
17718 @@ -35,16 +38,14 @@ void printk_address(unsigned long address, int reliable)
17719 static void
17720 print_ftrace_graph_addr(unsigned long addr, void *data,
17721 const struct stacktrace_ops *ops,
17722 - struct thread_info *tinfo, int *graph)
17723 + struct task_struct *task, int *graph)
17724 {
17725 - struct task_struct *task;
17726 unsigned long ret_addr;
17727 int index;
17728
17729 if (addr != (unsigned long)return_to_handler)
17730 return;
17731
17732 - task = tinfo->task;
17733 index = task->curr_ret_stack;
17734
17735 if (!task->ret_stack || index < *graph)
17736 @@ -61,7 +62,7 @@ print_ftrace_graph_addr(unsigned long addr, void *data,
17737 static inline void
17738 print_ftrace_graph_addr(unsigned long addr, void *data,
17739 const struct stacktrace_ops *ops,
17740 - struct thread_info *tinfo, int *graph)
17741 + struct task_struct *task, int *graph)
17742 { }
17743 #endif
17744
17745 @@ -72,10 +73,8 @@ print_ftrace_graph_addr(unsigned long addr, void *data,
17746 * severe exception (double fault, nmi, stack fault, debug, mce) hardware stack
17747 */
17748
17749 -static inline int valid_stack_ptr(struct thread_info *tinfo,
17750 - void *p, unsigned int size, void *end)
17751 +static inline int valid_stack_ptr(void *t, void *p, unsigned int size, void *end)
17752 {
17753 - void *t = tinfo;
17754 if (end) {
17755 if (p < end && p >= (end-THREAD_SIZE))
17756 return 1;
17757 @@ -86,14 +85,14 @@ static inline int valid_stack_ptr(struct thread_info *tinfo,
17758 }
17759
17760 unsigned long
17761 -print_context_stack(struct thread_info *tinfo,
17762 +print_context_stack(struct task_struct *task, void *stack_start,
17763 unsigned long *stack, unsigned long bp,
17764 const struct stacktrace_ops *ops, void *data,
17765 unsigned long *end, int *graph)
17766 {
17767 struct stack_frame *frame = (struct stack_frame *)bp;
17768
17769 - while (valid_stack_ptr(tinfo, stack, sizeof(*stack), end)) {
17770 + while (valid_stack_ptr(stack_start, stack, sizeof(*stack), end)) {
17771 unsigned long addr;
17772
17773 addr = *stack;
17774 @@ -105,7 +104,7 @@ print_context_stack(struct thread_info *tinfo,
17775 } else {
17776 ops->address(data, addr, 0);
17777 }
17778 - print_ftrace_graph_addr(addr, data, ops, tinfo, graph);
17779 + print_ftrace_graph_addr(addr, data, ops, task, graph);
17780 }
17781 stack++;
17782 }
17783 @@ -114,7 +113,7 @@ print_context_stack(struct thread_info *tinfo,
17784 EXPORT_SYMBOL_GPL(print_context_stack);
17785
17786 unsigned long
17787 -print_context_stack_bp(struct thread_info *tinfo,
17788 +print_context_stack_bp(struct task_struct *task, void *stack_start,
17789 unsigned long *stack, unsigned long bp,
17790 const struct stacktrace_ops *ops, void *data,
17791 unsigned long *end, int *graph)
17792 @@ -122,7 +121,7 @@ print_context_stack_bp(struct thread_info *tinfo,
17793 struct stack_frame *frame = (struct stack_frame *)bp;
17794 unsigned long *ret_addr = &frame->return_address;
17795
17796 - while (valid_stack_ptr(tinfo, ret_addr, sizeof(*ret_addr), end)) {
17797 + while (valid_stack_ptr(stack_start, ret_addr, sizeof(*ret_addr), end)) {
17798 unsigned long addr = *ret_addr;
17799
17800 if (!__kernel_text_address(addr))
17801 @@ -131,7 +130,7 @@ print_context_stack_bp(struct thread_info *tinfo,
17802 ops->address(data, addr, 1);
17803 frame = frame->next_frame;
17804 ret_addr = &frame->return_address;
17805 - print_ftrace_graph_addr(addr, data, ops, tinfo, graph);
17806 + print_ftrace_graph_addr(addr, data, ops, task, graph);
17807 }
17808
17809 return (unsigned long)frame;
17810 @@ -189,7 +188,7 @@ void dump_stack(void)
17811
17812 bp = stack_frame(current, NULL);
17813 printk("Pid: %d, comm: %.20s %s %s %.*s\n",
17814 - current->pid, current->comm, print_tainted(),
17815 + task_pid_nr(current), current->comm, print_tainted(),
17816 init_utsname()->release,
17817 (int)strcspn(init_utsname()->version, " "),
17818 init_utsname()->version);
17819 @@ -225,6 +224,8 @@ unsigned __kprobes long oops_begin(void)
17820 }
17821 EXPORT_SYMBOL_GPL(oops_begin);
17822
17823 +extern void gr_handle_kernel_exploit(void);
17824 +
17825 void __kprobes oops_end(unsigned long flags, struct pt_regs *regs, int signr)
17826 {
17827 if (regs && kexec_should_crash(current))
17828 @@ -246,7 +247,10 @@ void __kprobes oops_end(unsigned long flags, struct pt_regs *regs, int signr)
17829 panic("Fatal exception in interrupt");
17830 if (panic_on_oops)
17831 panic("Fatal exception");
17832 - do_exit(signr);
17833 +
17834 + gr_handle_kernel_exploit();
17835 +
17836 + do_group_exit(signr);
17837 }
17838
17839 int __kprobes __die(const char *str, struct pt_regs *regs, long err)
17840 @@ -274,7 +278,7 @@ int __kprobes __die(const char *str, struct pt_regs *regs, long err)
17841 print_modules();
17842 show_regs(regs);
17843 #ifdef CONFIG_X86_32
17844 - if (user_mode_vm(regs)) {
17845 + if (user_mode(regs)) {
17846 sp = regs->sp;
17847 ss = regs->ss & 0xffff;
17848 } else {
17849 @@ -302,7 +306,7 @@ void die(const char *str, struct pt_regs *regs, long err)
17850 unsigned long flags = oops_begin();
17851 int sig = SIGSEGV;
17852
17853 - if (!user_mode_vm(regs))
17854 + if (!user_mode(regs))
17855 report_bug(regs->ip, regs);
17856
17857 if (__die(str, regs, err))
17858 diff --git a/arch/x86/kernel/dumpstack_32.c b/arch/x86/kernel/dumpstack_32.c
17859 index 1038a41..db2c12b 100644
17860 --- a/arch/x86/kernel/dumpstack_32.c
17861 +++ b/arch/x86/kernel/dumpstack_32.c
17862 @@ -38,15 +38,13 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
17863 bp = stack_frame(task, regs);
17864
17865 for (;;) {
17866 - struct thread_info *context;
17867 + void *stack_start = (void *)((unsigned long)stack & ~(THREAD_SIZE-1));
17868
17869 - context = (struct thread_info *)
17870 - ((unsigned long)stack & (~(THREAD_SIZE - 1)));
17871 - bp = ops->walk_stack(context, stack, bp, ops, data, NULL, &graph);
17872 + bp = ops->walk_stack(task, stack_start, stack, bp, ops, data, NULL, &graph);
17873
17874 - stack = (unsigned long *)context->previous_esp;
17875 - if (!stack)
17876 + if (stack_start == task_stack_page(task))
17877 break;
17878 + stack = *(unsigned long **)stack_start;
17879 if (ops->stack(data, "IRQ") < 0)
17880 break;
17881 touch_nmi_watchdog();
17882 @@ -86,7 +84,7 @@ void show_regs(struct pt_regs *regs)
17883 {
17884 int i;
17885
17886 - __show_regs(regs, !user_mode_vm(regs));
17887 + __show_regs(regs, !user_mode(regs));
17888
17889 pr_emerg("Process %.*s (pid: %d, ti=%p task=%p task.ti=%p)\n",
17890 TASK_COMM_LEN, current->comm, task_pid_nr(current),
17891 @@ -95,21 +93,22 @@ void show_regs(struct pt_regs *regs)
17892 * When in-kernel, we also print out the stack and code at the
17893 * time of the fault..
17894 */
17895 - if (!user_mode_vm(regs)) {
17896 + if (!user_mode(regs)) {
17897 unsigned int code_prologue = code_bytes * 43 / 64;
17898 unsigned int code_len = code_bytes;
17899 unsigned char c;
17900 u8 *ip;
17901 + unsigned long cs_base = get_desc_base(&get_cpu_gdt_table(0)[(0xffff & regs->cs) >> 3]);
17902
17903 pr_emerg("Stack:\n");
17904 show_stack_log_lvl(NULL, regs, &regs->sp, 0, KERN_EMERG);
17905
17906 pr_emerg("Code:");
17907
17908 - ip = (u8 *)regs->ip - code_prologue;
17909 + ip = (u8 *)regs->ip - code_prologue + cs_base;
17910 if (ip < (u8 *)PAGE_OFFSET || probe_kernel_address(ip, c)) {
17911 /* try starting at IP */
17912 - ip = (u8 *)regs->ip;
17913 + ip = (u8 *)regs->ip + cs_base;
17914 code_len = code_len - code_prologue + 1;
17915 }
17916 for (i = 0; i < code_len; i++, ip++) {
17917 @@ -118,7 +117,7 @@ void show_regs(struct pt_regs *regs)
17918 pr_cont(" Bad EIP value.");
17919 break;
17920 }
17921 - if (ip == (u8 *)regs->ip)
17922 + if (ip == (u8 *)regs->ip + cs_base)
17923 pr_cont(" <%02x>", c);
17924 else
17925 pr_cont(" %02x", c);
17926 @@ -131,6 +130,7 @@ int is_valid_bugaddr(unsigned long ip)
17927 {
17928 unsigned short ud2;
17929
17930 + ip = ktla_ktva(ip);
17931 if (ip < PAGE_OFFSET)
17932 return 0;
17933 if (probe_kernel_address((unsigned short *)ip, ud2))
17934 @@ -138,3 +138,15 @@ int is_valid_bugaddr(unsigned long ip)
17935
17936 return ud2 == 0x0b0f;
17937 }
17938 +
17939 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
17940 +void pax_check_alloca(unsigned long size)
17941 +{
17942 + unsigned long sp = (unsigned long)&sp, stack_left;
17943 +
17944 + /* all kernel stacks are of the same size */
17945 + stack_left = sp & (THREAD_SIZE - 1);
17946 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
17947 +}
17948 +EXPORT_SYMBOL(pax_check_alloca);
17949 +#endif
17950 diff --git a/arch/x86/kernel/dumpstack_64.c b/arch/x86/kernel/dumpstack_64.c
17951 index b653675..51cc8c0 100644
17952 --- a/arch/x86/kernel/dumpstack_64.c
17953 +++ b/arch/x86/kernel/dumpstack_64.c
17954 @@ -119,9 +119,9 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
17955 unsigned long *irq_stack_end =
17956 (unsigned long *)per_cpu(irq_stack_ptr, cpu);
17957 unsigned used = 0;
17958 - struct thread_info *tinfo;
17959 int graph = 0;
17960 unsigned long dummy;
17961 + void *stack_start;
17962
17963 if (!task)
17964 task = current;
17965 @@ -142,10 +142,10 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
17966 * current stack address. If the stacks consist of nested
17967 * exceptions
17968 */
17969 - tinfo = task_thread_info(task);
17970 for (;;) {
17971 char *id;
17972 unsigned long *estack_end;
17973 +
17974 estack_end = in_exception_stack(cpu, (unsigned long)stack,
17975 &used, &id);
17976
17977 @@ -153,7 +153,7 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
17978 if (ops->stack(data, id) < 0)
17979 break;
17980
17981 - bp = ops->walk_stack(tinfo, stack, bp, ops,
17982 + bp = ops->walk_stack(task, estack_end - EXCEPTION_STKSZ, stack, bp, ops,
17983 data, estack_end, &graph);
17984 ops->stack(data, "<EOE>");
17985 /*
17986 @@ -161,6 +161,8 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
17987 * second-to-last pointer (index -2 to end) in the
17988 * exception stack:
17989 */
17990 + if ((u16)estack_end[-1] != __KERNEL_DS)
17991 + goto out;
17992 stack = (unsigned long *) estack_end[-2];
17993 continue;
17994 }
17995 @@ -172,7 +174,7 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
17996 if (in_irq_stack(stack, irq_stack, irq_stack_end)) {
17997 if (ops->stack(data, "IRQ") < 0)
17998 break;
17999 - bp = ops->walk_stack(tinfo, stack, bp,
18000 + bp = ops->walk_stack(task, irq_stack, stack, bp,
18001 ops, data, irq_stack_end, &graph);
18002 /*
18003 * We link to the next stack (which would be
18004 @@ -191,7 +193,9 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
18005 /*
18006 * This handles the process stack:
18007 */
18008 - bp = ops->walk_stack(tinfo, stack, bp, ops, data, NULL, &graph);
18009 + stack_start = (void *)((unsigned long)stack & ~(THREAD_SIZE-1));
18010 + bp = ops->walk_stack(task, stack_start, stack, bp, ops, data, NULL, &graph);
18011 +out:
18012 put_cpu();
18013 }
18014 EXPORT_SYMBOL(dump_trace);
18015 @@ -249,7 +253,7 @@ void show_regs(struct pt_regs *regs)
18016 {
18017 int i;
18018 unsigned long sp;
18019 - const int cpu = smp_processor_id();
18020 + const int cpu = raw_smp_processor_id();
18021 struct task_struct *cur = current;
18022
18023 sp = regs->sp;
18024 @@ -304,3 +308,50 @@ int is_valid_bugaddr(unsigned long ip)
18025
18026 return ud2 == 0x0b0f;
18027 }
18028 +
18029 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
18030 +void pax_check_alloca(unsigned long size)
18031 +{
18032 + unsigned long sp = (unsigned long)&sp, stack_start, stack_end;
18033 + unsigned cpu, used;
18034 + char *id;
18035 +
18036 + /* check the process stack first */
18037 + stack_start = (unsigned long)task_stack_page(current);
18038 + stack_end = stack_start + THREAD_SIZE;
18039 + if (likely(stack_start <= sp && sp < stack_end)) {
18040 + unsigned long stack_left = sp & (THREAD_SIZE - 1);
18041 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
18042 + return;
18043 + }
18044 +
18045 + cpu = get_cpu();
18046 +
18047 + /* check the irq stacks */
18048 + stack_end = (unsigned long)per_cpu(irq_stack_ptr, cpu);
18049 + stack_start = stack_end - IRQ_STACK_SIZE;
18050 + if (stack_start <= sp && sp < stack_end) {
18051 + unsigned long stack_left = sp & (IRQ_STACK_SIZE - 1);
18052 + put_cpu();
18053 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
18054 + return;
18055 + }
18056 +
18057 + /* check the exception stacks */
18058 + used = 0;
18059 + stack_end = (unsigned long)in_exception_stack(cpu, sp, &used, &id);
18060 + stack_start = stack_end - EXCEPTION_STKSZ;
18061 + if (stack_end && stack_start <= sp && sp < stack_end) {
18062 + unsigned long stack_left = sp & (EXCEPTION_STKSZ - 1);
18063 + put_cpu();
18064 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
18065 + return;
18066 + }
18067 +
18068 + put_cpu();
18069 +
18070 + /* unknown stack */
18071 + BUG();
18072 +}
18073 +EXPORT_SYMBOL(pax_check_alloca);
18074 +#endif
18075 diff --git a/arch/x86/kernel/early_printk.c b/arch/x86/kernel/early_printk.c
18076 index 9b9f18b..9fcaa04 100644
18077 --- a/arch/x86/kernel/early_printk.c
18078 +++ b/arch/x86/kernel/early_printk.c
18079 @@ -7,6 +7,7 @@
18080 #include <linux/pci_regs.h>
18081 #include <linux/pci_ids.h>
18082 #include <linux/errno.h>
18083 +#include <linux/sched.h>
18084 #include <asm/io.h>
18085 #include <asm/processor.h>
18086 #include <asm/fcntl.h>
18087 diff --git a/arch/x86/kernel/entry_32.S b/arch/x86/kernel/entry_32.S
18088 index 6ed91d9..6cc365b 100644
18089 --- a/arch/x86/kernel/entry_32.S
18090 +++ b/arch/x86/kernel/entry_32.S
18091 @@ -177,13 +177,153 @@
18092 /*CFI_REL_OFFSET gs, PT_GS*/
18093 .endm
18094 .macro SET_KERNEL_GS reg
18095 +
18096 +#ifdef CONFIG_CC_STACKPROTECTOR
18097 movl $(__KERNEL_STACK_CANARY), \reg
18098 +#elif defined(CONFIG_PAX_MEMORY_UDEREF)
18099 + movl $(__USER_DS), \reg
18100 +#else
18101 + xorl \reg, \reg
18102 +#endif
18103 +
18104 movl \reg, %gs
18105 .endm
18106
18107 #endif /* CONFIG_X86_32_LAZY_GS */
18108
18109 -.macro SAVE_ALL
18110 +.macro pax_enter_kernel
18111 +#ifdef CONFIG_PAX_KERNEXEC
18112 + call pax_enter_kernel
18113 +#endif
18114 +.endm
18115 +
18116 +.macro pax_exit_kernel
18117 +#ifdef CONFIG_PAX_KERNEXEC
18118 + call pax_exit_kernel
18119 +#endif
18120 +.endm
18121 +
18122 +#ifdef CONFIG_PAX_KERNEXEC
18123 +ENTRY(pax_enter_kernel)
18124 +#ifdef CONFIG_PARAVIRT
18125 + pushl %eax
18126 + pushl %ecx
18127 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_read_cr0)
18128 + mov %eax, %esi
18129 +#else
18130 + mov %cr0, %esi
18131 +#endif
18132 + bts $16, %esi
18133 + jnc 1f
18134 + mov %cs, %esi
18135 + cmp $__KERNEL_CS, %esi
18136 + jz 3f
18137 + ljmp $__KERNEL_CS, $3f
18138 +1: ljmp $__KERNEXEC_KERNEL_CS, $2f
18139 +2:
18140 +#ifdef CONFIG_PARAVIRT
18141 + mov %esi, %eax
18142 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_write_cr0)
18143 +#else
18144 + mov %esi, %cr0
18145 +#endif
18146 +3:
18147 +#ifdef CONFIG_PARAVIRT
18148 + popl %ecx
18149 + popl %eax
18150 +#endif
18151 + ret
18152 +ENDPROC(pax_enter_kernel)
18153 +
18154 +ENTRY(pax_exit_kernel)
18155 +#ifdef CONFIG_PARAVIRT
18156 + pushl %eax
18157 + pushl %ecx
18158 +#endif
18159 + mov %cs, %esi
18160 + cmp $__KERNEXEC_KERNEL_CS, %esi
18161 + jnz 2f
18162 +#ifdef CONFIG_PARAVIRT
18163 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_read_cr0);
18164 + mov %eax, %esi
18165 +#else
18166 + mov %cr0, %esi
18167 +#endif
18168 + btr $16, %esi
18169 + ljmp $__KERNEL_CS, $1f
18170 +1:
18171 +#ifdef CONFIG_PARAVIRT
18172 + mov %esi, %eax
18173 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_write_cr0);
18174 +#else
18175 + mov %esi, %cr0
18176 +#endif
18177 +2:
18178 +#ifdef CONFIG_PARAVIRT
18179 + popl %ecx
18180 + popl %eax
18181 +#endif
18182 + ret
18183 +ENDPROC(pax_exit_kernel)
18184 +#endif
18185 +
18186 +.macro pax_erase_kstack
18187 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
18188 + call pax_erase_kstack
18189 +#endif
18190 +.endm
18191 +
18192 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
18193 +/*
18194 + * ebp: thread_info
18195 + */
18196 +ENTRY(pax_erase_kstack)
18197 + pushl %edi
18198 + pushl %ecx
18199 + pushl %eax
18200 +
18201 + mov TI_lowest_stack(%ebp), %edi
18202 + mov $-0xBEEF, %eax
18203 + std
18204 +
18205 +1: mov %edi, %ecx
18206 + and $THREAD_SIZE_asm - 1, %ecx
18207 + shr $2, %ecx
18208 + repne scasl
18209 + jecxz 2f
18210 +
18211 + cmp $2*16, %ecx
18212 + jc 2f
18213 +
18214 + mov $2*16, %ecx
18215 + repe scasl
18216 + jecxz 2f
18217 + jne 1b
18218 +
18219 +2: cld
18220 + mov %esp, %ecx
18221 + sub %edi, %ecx
18222 +
18223 + cmp $THREAD_SIZE_asm, %ecx
18224 + jb 3f
18225 + ud2
18226 +3:
18227 +
18228 + shr $2, %ecx
18229 + rep stosl
18230 +
18231 + mov TI_task_thread_sp0(%ebp), %edi
18232 + sub $128, %edi
18233 + mov %edi, TI_lowest_stack(%ebp)
18234 +
18235 + popl %eax
18236 + popl %ecx
18237 + popl %edi
18238 + ret
18239 +ENDPROC(pax_erase_kstack)
18240 +#endif
18241 +
18242 +.macro __SAVE_ALL _DS
18243 cld
18244 PUSH_GS
18245 pushl_cfi %fs
18246 @@ -206,7 +346,7 @@
18247 CFI_REL_OFFSET ecx, 0
18248 pushl_cfi %ebx
18249 CFI_REL_OFFSET ebx, 0
18250 - movl $(__USER_DS), %edx
18251 + movl $\_DS, %edx
18252 movl %edx, %ds
18253 movl %edx, %es
18254 movl $(__KERNEL_PERCPU), %edx
18255 @@ -214,6 +354,15 @@
18256 SET_KERNEL_GS %edx
18257 .endm
18258
18259 +.macro SAVE_ALL
18260 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
18261 + __SAVE_ALL __KERNEL_DS
18262 + pax_enter_kernel
18263 +#else
18264 + __SAVE_ALL __USER_DS
18265 +#endif
18266 +.endm
18267 +
18268 .macro RESTORE_INT_REGS
18269 popl_cfi %ebx
18270 CFI_RESTORE ebx
18271 @@ -297,7 +446,7 @@ ENTRY(ret_from_fork)
18272 popfl_cfi
18273 jmp syscall_exit
18274 CFI_ENDPROC
18275 -END(ret_from_fork)
18276 +ENDPROC(ret_from_fork)
18277
18278 ENTRY(ret_from_kernel_thread)
18279 CFI_STARTPROC
18280 @@ -344,7 +493,15 @@ ret_from_intr:
18281 andl $SEGMENT_RPL_MASK, %eax
18282 #endif
18283 cmpl $USER_RPL, %eax
18284 +
18285 +#ifdef CONFIG_PAX_KERNEXEC
18286 + jae resume_userspace
18287 +
18288 + pax_exit_kernel
18289 + jmp resume_kernel
18290 +#else
18291 jb resume_kernel # not returning to v8086 or userspace
18292 +#endif
18293
18294 ENTRY(resume_userspace)
18295 LOCKDEP_SYS_EXIT
18296 @@ -356,8 +513,8 @@ ENTRY(resume_userspace)
18297 andl $_TIF_WORK_MASK, %ecx # is there any work to be done on
18298 # int/exception return?
18299 jne work_pending
18300 - jmp restore_all
18301 -END(ret_from_exception)
18302 + jmp restore_all_pax
18303 +ENDPROC(ret_from_exception)
18304
18305 #ifdef CONFIG_PREEMPT
18306 ENTRY(resume_kernel)
18307 @@ -372,7 +529,7 @@ need_resched:
18308 jz restore_all
18309 call preempt_schedule_irq
18310 jmp need_resched
18311 -END(resume_kernel)
18312 +ENDPROC(resume_kernel)
18313 #endif
18314 CFI_ENDPROC
18315 /*
18316 @@ -406,30 +563,45 @@ sysenter_past_esp:
18317 /*CFI_REL_OFFSET cs, 0*/
18318 /*
18319 * Push current_thread_info()->sysenter_return to the stack.
18320 - * A tiny bit of offset fixup is necessary - 4*4 means the 4 words
18321 - * pushed above; +8 corresponds to copy_thread's esp0 setting.
18322 */
18323 - pushl_cfi ((TI_sysenter_return)-THREAD_SIZE+8+4*4)(%esp)
18324 + pushl_cfi $0
18325 CFI_REL_OFFSET eip, 0
18326
18327 pushl_cfi %eax
18328 SAVE_ALL
18329 + GET_THREAD_INFO(%ebp)
18330 + movl TI_sysenter_return(%ebp),%ebp
18331 + movl %ebp,PT_EIP(%esp)
18332 ENABLE_INTERRUPTS(CLBR_NONE)
18333
18334 /*
18335 * Load the potential sixth argument from user stack.
18336 * Careful about security.
18337 */
18338 + movl PT_OLDESP(%esp),%ebp
18339 +
18340 +#ifdef CONFIG_PAX_MEMORY_UDEREF
18341 + mov PT_OLDSS(%esp),%ds
18342 +1: movl %ds:(%ebp),%ebp
18343 + push %ss
18344 + pop %ds
18345 +#else
18346 cmpl $__PAGE_OFFSET-3,%ebp
18347 jae syscall_fault
18348 ASM_STAC
18349 1: movl (%ebp),%ebp
18350 ASM_CLAC
18351 +#endif
18352 +
18353 movl %ebp,PT_EBP(%esp)
18354 _ASM_EXTABLE(1b,syscall_fault)
18355
18356 GET_THREAD_INFO(%ebp)
18357
18358 +#ifdef CONFIG_PAX_RANDKSTACK
18359 + pax_erase_kstack
18360 +#endif
18361 +
18362 testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%ebp)
18363 jnz sysenter_audit
18364 sysenter_do_call:
18365 @@ -444,12 +616,24 @@ sysenter_do_call:
18366 testl $_TIF_ALLWORK_MASK, %ecx
18367 jne sysexit_audit
18368 sysenter_exit:
18369 +
18370 +#ifdef CONFIG_PAX_RANDKSTACK
18371 + pushl_cfi %eax
18372 + movl %esp, %eax
18373 + call pax_randomize_kstack
18374 + popl_cfi %eax
18375 +#endif
18376 +
18377 + pax_erase_kstack
18378 +
18379 /* if something modifies registers it must also disable sysexit */
18380 movl PT_EIP(%esp), %edx
18381 movl PT_OLDESP(%esp), %ecx
18382 xorl %ebp,%ebp
18383 TRACE_IRQS_ON
18384 1: mov PT_FS(%esp), %fs
18385 +2: mov PT_DS(%esp), %ds
18386 +3: mov PT_ES(%esp), %es
18387 PTGS_TO_GS
18388 ENABLE_INTERRUPTS_SYSEXIT
18389
18390 @@ -466,6 +650,9 @@ sysenter_audit:
18391 movl %eax,%edx /* 2nd arg: syscall number */
18392 movl $AUDIT_ARCH_I386,%eax /* 1st arg: audit arch */
18393 call __audit_syscall_entry
18394 +
18395 + pax_erase_kstack
18396 +
18397 pushl_cfi %ebx
18398 movl PT_EAX(%esp),%eax /* reload syscall number */
18399 jmp sysenter_do_call
18400 @@ -491,10 +678,16 @@ sysexit_audit:
18401
18402 CFI_ENDPROC
18403 .pushsection .fixup,"ax"
18404 -2: movl $0,PT_FS(%esp)
18405 +4: movl $0,PT_FS(%esp)
18406 + jmp 1b
18407 +5: movl $0,PT_DS(%esp)
18408 + jmp 1b
18409 +6: movl $0,PT_ES(%esp)
18410 jmp 1b
18411 .popsection
18412 - _ASM_EXTABLE(1b,2b)
18413 + _ASM_EXTABLE(1b,4b)
18414 + _ASM_EXTABLE(2b,5b)
18415 + _ASM_EXTABLE(3b,6b)
18416 PTGS_TO_GS_EX
18417 ENDPROC(ia32_sysenter_target)
18418
18419 @@ -509,6 +702,11 @@ ENTRY(system_call)
18420 pushl_cfi %eax # save orig_eax
18421 SAVE_ALL
18422 GET_THREAD_INFO(%ebp)
18423 +
18424 +#ifdef CONFIG_PAX_RANDKSTACK
18425 + pax_erase_kstack
18426 +#endif
18427 +
18428 # system call tracing in operation / emulation
18429 testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%ebp)
18430 jnz syscall_trace_entry
18431 @@ -527,6 +725,15 @@ syscall_exit:
18432 testl $_TIF_ALLWORK_MASK, %ecx # current->work
18433 jne syscall_exit_work
18434
18435 +restore_all_pax:
18436 +
18437 +#ifdef CONFIG_PAX_RANDKSTACK
18438 + movl %esp, %eax
18439 + call pax_randomize_kstack
18440 +#endif
18441 +
18442 + pax_erase_kstack
18443 +
18444 restore_all:
18445 TRACE_IRQS_IRET
18446 restore_all_notrace:
18447 @@ -583,14 +790,34 @@ ldt_ss:
18448 * compensating for the offset by changing to the ESPFIX segment with
18449 * a base address that matches for the difference.
18450 */
18451 -#define GDT_ESPFIX_SS PER_CPU_VAR(gdt_page) + (GDT_ENTRY_ESPFIX_SS * 8)
18452 +#define GDT_ESPFIX_SS (GDT_ENTRY_ESPFIX_SS * 8)(%ebx)
18453 mov %esp, %edx /* load kernel esp */
18454 mov PT_OLDESP(%esp), %eax /* load userspace esp */
18455 mov %dx, %ax /* eax: new kernel esp */
18456 sub %eax, %edx /* offset (low word is 0) */
18457 +#ifdef CONFIG_SMP
18458 + movl PER_CPU_VAR(cpu_number), %ebx
18459 + shll $PAGE_SHIFT_asm, %ebx
18460 + addl $cpu_gdt_table, %ebx
18461 +#else
18462 + movl $cpu_gdt_table, %ebx
18463 +#endif
18464 shr $16, %edx
18465 - mov %dl, GDT_ESPFIX_SS + 4 /* bits 16..23 */
18466 - mov %dh, GDT_ESPFIX_SS + 7 /* bits 24..31 */
18467 +
18468 +#ifdef CONFIG_PAX_KERNEXEC
18469 + mov %cr0, %esi
18470 + btr $16, %esi
18471 + mov %esi, %cr0
18472 +#endif
18473 +
18474 + mov %dl, 4 + GDT_ESPFIX_SS /* bits 16..23 */
18475 + mov %dh, 7 + GDT_ESPFIX_SS /* bits 24..31 */
18476 +
18477 +#ifdef CONFIG_PAX_KERNEXEC
18478 + bts $16, %esi
18479 + mov %esi, %cr0
18480 +#endif
18481 +
18482 pushl_cfi $__ESPFIX_SS
18483 pushl_cfi %eax /* new kernel esp */
18484 /* Disable interrupts, but do not irqtrace this section: we
18485 @@ -619,20 +846,18 @@ work_resched:
18486 movl TI_flags(%ebp), %ecx
18487 andl $_TIF_WORK_MASK, %ecx # is there any work to be done other
18488 # than syscall tracing?
18489 - jz restore_all
18490 + jz restore_all_pax
18491 testb $_TIF_NEED_RESCHED, %cl
18492 jnz work_resched
18493
18494 work_notifysig: # deal with pending signals and
18495 # notify-resume requests
18496 + movl %esp, %eax
18497 #ifdef CONFIG_VM86
18498 testl $X86_EFLAGS_VM, PT_EFLAGS(%esp)
18499 - movl %esp, %eax
18500 jne work_notifysig_v86 # returning to kernel-space or
18501 # vm86-space
18502 1:
18503 -#else
18504 - movl %esp, %eax
18505 #endif
18506 TRACE_IRQS_ON
18507 ENABLE_INTERRUPTS(CLBR_NONE)
18508 @@ -653,7 +878,7 @@ work_notifysig_v86:
18509 movl %eax, %esp
18510 jmp 1b
18511 #endif
18512 -END(work_pending)
18513 +ENDPROC(work_pending)
18514
18515 # perform syscall exit tracing
18516 ALIGN
18517 @@ -661,11 +886,14 @@ syscall_trace_entry:
18518 movl $-ENOSYS,PT_EAX(%esp)
18519 movl %esp, %eax
18520 call syscall_trace_enter
18521 +
18522 + pax_erase_kstack
18523 +
18524 /* What it returned is what we'll actually use. */
18525 cmpl $(NR_syscalls), %eax
18526 jnae syscall_call
18527 jmp syscall_exit
18528 -END(syscall_trace_entry)
18529 +ENDPROC(syscall_trace_entry)
18530
18531 # perform syscall exit tracing
18532 ALIGN
18533 @@ -678,21 +906,25 @@ syscall_exit_work:
18534 movl %esp, %eax
18535 call syscall_trace_leave
18536 jmp resume_userspace
18537 -END(syscall_exit_work)
18538 +ENDPROC(syscall_exit_work)
18539 CFI_ENDPROC
18540
18541 RING0_INT_FRAME # can't unwind into user space anyway
18542 syscall_fault:
18543 +#ifdef CONFIG_PAX_MEMORY_UDEREF
18544 + push %ss
18545 + pop %ds
18546 +#endif
18547 ASM_CLAC
18548 GET_THREAD_INFO(%ebp)
18549 movl $-EFAULT,PT_EAX(%esp)
18550 jmp resume_userspace
18551 -END(syscall_fault)
18552 +ENDPROC(syscall_fault)
18553
18554 syscall_badsys:
18555 movl $-ENOSYS,PT_EAX(%esp)
18556 jmp resume_userspace
18557 -END(syscall_badsys)
18558 +ENDPROC(syscall_badsys)
18559 CFI_ENDPROC
18560 /*
18561 * End of kprobes section
18562 @@ -753,8 +985,15 @@ PTREGSCALL1(vm86old)
18563 * normal stack and adjusts ESP with the matching offset.
18564 */
18565 /* fixup the stack */
18566 - mov GDT_ESPFIX_SS + 4, %al /* bits 16..23 */
18567 - mov GDT_ESPFIX_SS + 7, %ah /* bits 24..31 */
18568 +#ifdef CONFIG_SMP
18569 + movl PER_CPU_VAR(cpu_number), %ebx
18570 + shll $PAGE_SHIFT_asm, %ebx
18571 + addl $cpu_gdt_table, %ebx
18572 +#else
18573 + movl $cpu_gdt_table, %ebx
18574 +#endif
18575 + mov 4 + GDT_ESPFIX_SS, %al /* bits 16..23 */
18576 + mov 7 + GDT_ESPFIX_SS, %ah /* bits 24..31 */
18577 shl $16, %eax
18578 addl %esp, %eax /* the adjusted stack pointer */
18579 pushl_cfi $__KERNEL_DS
18580 @@ -807,7 +1046,7 @@ vector=vector+1
18581 .endr
18582 2: jmp common_interrupt
18583 .endr
18584 -END(irq_entries_start)
18585 +ENDPROC(irq_entries_start)
18586
18587 .previous
18588 END(interrupt)
18589 @@ -858,7 +1097,7 @@ ENTRY(coprocessor_error)
18590 pushl_cfi $do_coprocessor_error
18591 jmp error_code
18592 CFI_ENDPROC
18593 -END(coprocessor_error)
18594 +ENDPROC(coprocessor_error)
18595
18596 ENTRY(simd_coprocessor_error)
18597 RING0_INT_FRAME
18598 @@ -880,7 +1119,7 @@ ENTRY(simd_coprocessor_error)
18599 #endif
18600 jmp error_code
18601 CFI_ENDPROC
18602 -END(simd_coprocessor_error)
18603 +ENDPROC(simd_coprocessor_error)
18604
18605 ENTRY(device_not_available)
18606 RING0_INT_FRAME
18607 @@ -889,18 +1128,18 @@ ENTRY(device_not_available)
18608 pushl_cfi $do_device_not_available
18609 jmp error_code
18610 CFI_ENDPROC
18611 -END(device_not_available)
18612 +ENDPROC(device_not_available)
18613
18614 #ifdef CONFIG_PARAVIRT
18615 ENTRY(native_iret)
18616 iret
18617 _ASM_EXTABLE(native_iret, iret_exc)
18618 -END(native_iret)
18619 +ENDPROC(native_iret)
18620
18621 ENTRY(native_irq_enable_sysexit)
18622 sti
18623 sysexit
18624 -END(native_irq_enable_sysexit)
18625 +ENDPROC(native_irq_enable_sysexit)
18626 #endif
18627
18628 ENTRY(overflow)
18629 @@ -910,7 +1149,7 @@ ENTRY(overflow)
18630 pushl_cfi $do_overflow
18631 jmp error_code
18632 CFI_ENDPROC
18633 -END(overflow)
18634 +ENDPROC(overflow)
18635
18636 ENTRY(bounds)
18637 RING0_INT_FRAME
18638 @@ -919,7 +1158,7 @@ ENTRY(bounds)
18639 pushl_cfi $do_bounds
18640 jmp error_code
18641 CFI_ENDPROC
18642 -END(bounds)
18643 +ENDPROC(bounds)
18644
18645 ENTRY(invalid_op)
18646 RING0_INT_FRAME
18647 @@ -928,7 +1167,7 @@ ENTRY(invalid_op)
18648 pushl_cfi $do_invalid_op
18649 jmp error_code
18650 CFI_ENDPROC
18651 -END(invalid_op)
18652 +ENDPROC(invalid_op)
18653
18654 ENTRY(coprocessor_segment_overrun)
18655 RING0_INT_FRAME
18656 @@ -937,7 +1176,7 @@ ENTRY(coprocessor_segment_overrun)
18657 pushl_cfi $do_coprocessor_segment_overrun
18658 jmp error_code
18659 CFI_ENDPROC
18660 -END(coprocessor_segment_overrun)
18661 +ENDPROC(coprocessor_segment_overrun)
18662
18663 ENTRY(invalid_TSS)
18664 RING0_EC_FRAME
18665 @@ -945,7 +1184,7 @@ ENTRY(invalid_TSS)
18666 pushl_cfi $do_invalid_TSS
18667 jmp error_code
18668 CFI_ENDPROC
18669 -END(invalid_TSS)
18670 +ENDPROC(invalid_TSS)
18671
18672 ENTRY(segment_not_present)
18673 RING0_EC_FRAME
18674 @@ -953,7 +1192,7 @@ ENTRY(segment_not_present)
18675 pushl_cfi $do_segment_not_present
18676 jmp error_code
18677 CFI_ENDPROC
18678 -END(segment_not_present)
18679 +ENDPROC(segment_not_present)
18680
18681 ENTRY(stack_segment)
18682 RING0_EC_FRAME
18683 @@ -961,7 +1200,7 @@ ENTRY(stack_segment)
18684 pushl_cfi $do_stack_segment
18685 jmp error_code
18686 CFI_ENDPROC
18687 -END(stack_segment)
18688 +ENDPROC(stack_segment)
18689
18690 ENTRY(alignment_check)
18691 RING0_EC_FRAME
18692 @@ -969,7 +1208,7 @@ ENTRY(alignment_check)
18693 pushl_cfi $do_alignment_check
18694 jmp error_code
18695 CFI_ENDPROC
18696 -END(alignment_check)
18697 +ENDPROC(alignment_check)
18698
18699 ENTRY(divide_error)
18700 RING0_INT_FRAME
18701 @@ -978,7 +1217,7 @@ ENTRY(divide_error)
18702 pushl_cfi $do_divide_error
18703 jmp error_code
18704 CFI_ENDPROC
18705 -END(divide_error)
18706 +ENDPROC(divide_error)
18707
18708 #ifdef CONFIG_X86_MCE
18709 ENTRY(machine_check)
18710 @@ -988,7 +1227,7 @@ ENTRY(machine_check)
18711 pushl_cfi machine_check_vector
18712 jmp error_code
18713 CFI_ENDPROC
18714 -END(machine_check)
18715 +ENDPROC(machine_check)
18716 #endif
18717
18718 ENTRY(spurious_interrupt_bug)
18719 @@ -998,7 +1237,7 @@ ENTRY(spurious_interrupt_bug)
18720 pushl_cfi $do_spurious_interrupt_bug
18721 jmp error_code
18722 CFI_ENDPROC
18723 -END(spurious_interrupt_bug)
18724 +ENDPROC(spurious_interrupt_bug)
18725 /*
18726 * End of kprobes section
18727 */
18728 @@ -1101,7 +1340,7 @@ BUILD_INTERRUPT3(xen_hvm_callback_vector, XEN_HVM_EVTCHN_CALLBACK,
18729
18730 ENTRY(mcount)
18731 ret
18732 -END(mcount)
18733 +ENDPROC(mcount)
18734
18735 ENTRY(ftrace_caller)
18736 cmpl $0, function_trace_stop
18737 @@ -1134,7 +1373,7 @@ ftrace_graph_call:
18738 .globl ftrace_stub
18739 ftrace_stub:
18740 ret
18741 -END(ftrace_caller)
18742 +ENDPROC(ftrace_caller)
18743
18744 ENTRY(ftrace_regs_caller)
18745 pushf /* push flags before compare (in cs location) */
18746 @@ -1235,7 +1474,7 @@ trace:
18747 popl %ecx
18748 popl %eax
18749 jmp ftrace_stub
18750 -END(mcount)
18751 +ENDPROC(mcount)
18752 #endif /* CONFIG_DYNAMIC_FTRACE */
18753 #endif /* CONFIG_FUNCTION_TRACER */
18754
18755 @@ -1253,7 +1492,7 @@ ENTRY(ftrace_graph_caller)
18756 popl %ecx
18757 popl %eax
18758 ret
18759 -END(ftrace_graph_caller)
18760 +ENDPROC(ftrace_graph_caller)
18761
18762 .globl return_to_handler
18763 return_to_handler:
18764 @@ -1309,15 +1548,18 @@ error_code:
18765 movl $-1, PT_ORIG_EAX(%esp) # no syscall to restart
18766 REG_TO_PTGS %ecx
18767 SET_KERNEL_GS %ecx
18768 - movl $(__USER_DS), %ecx
18769 + movl $(__KERNEL_DS), %ecx
18770 movl %ecx, %ds
18771 movl %ecx, %es
18772 +
18773 + pax_enter_kernel
18774 +
18775 TRACE_IRQS_OFF
18776 movl %esp,%eax # pt_regs pointer
18777 call *%edi
18778 jmp ret_from_exception
18779 CFI_ENDPROC
18780 -END(page_fault)
18781 +ENDPROC(page_fault)
18782
18783 /*
18784 * Debug traps and NMI can happen at the one SYSENTER instruction
18785 @@ -1360,7 +1602,7 @@ debug_stack_correct:
18786 call do_debug
18787 jmp ret_from_exception
18788 CFI_ENDPROC
18789 -END(debug)
18790 +ENDPROC(debug)
18791
18792 /*
18793 * NMI is doubly nasty. It can happen _while_ we're handling
18794 @@ -1398,6 +1640,9 @@ nmi_stack_correct:
18795 xorl %edx,%edx # zero error code
18796 movl %esp,%eax # pt_regs pointer
18797 call do_nmi
18798 +
18799 + pax_exit_kernel
18800 +
18801 jmp restore_all_notrace
18802 CFI_ENDPROC
18803
18804 @@ -1434,12 +1679,15 @@ nmi_espfix_stack:
18805 FIXUP_ESPFIX_STACK # %eax == %esp
18806 xorl %edx,%edx # zero error code
18807 call do_nmi
18808 +
18809 + pax_exit_kernel
18810 +
18811 RESTORE_REGS
18812 lss 12+4(%esp), %esp # back to espfix stack
18813 CFI_ADJUST_CFA_OFFSET -24
18814 jmp irq_return
18815 CFI_ENDPROC
18816 -END(nmi)
18817 +ENDPROC(nmi)
18818
18819 ENTRY(int3)
18820 RING0_INT_FRAME
18821 @@ -1452,14 +1700,14 @@ ENTRY(int3)
18822 call do_int3
18823 jmp ret_from_exception
18824 CFI_ENDPROC
18825 -END(int3)
18826 +ENDPROC(int3)
18827
18828 ENTRY(general_protection)
18829 RING0_EC_FRAME
18830 pushl_cfi $do_general_protection
18831 jmp error_code
18832 CFI_ENDPROC
18833 -END(general_protection)
18834 +ENDPROC(general_protection)
18835
18836 #ifdef CONFIG_KVM_GUEST
18837 ENTRY(async_page_fault)
18838 @@ -1468,7 +1716,7 @@ ENTRY(async_page_fault)
18839 pushl_cfi $do_async_page_fault
18840 jmp error_code
18841 CFI_ENDPROC
18842 -END(async_page_fault)
18843 +ENDPROC(async_page_fault)
18844 #endif
18845
18846 /*
18847 diff --git a/arch/x86/kernel/entry_64.S b/arch/x86/kernel/entry_64.S
18848 index cb3c591..bc63707 100644
18849 --- a/arch/x86/kernel/entry_64.S
18850 +++ b/arch/x86/kernel/entry_64.S
18851 @@ -59,6 +59,8 @@
18852 #include <asm/context_tracking.h>
18853 #include <asm/smap.h>
18854 #include <linux/err.h>
18855 +#include <asm/pgtable.h>
18856 +#include <asm/alternative-asm.h>
18857
18858 /* Avoid __ASSEMBLER__'ifying <linux/audit.h> just for this. */
18859 #include <linux/elf-em.h>
18860 @@ -80,8 +82,9 @@
18861 #ifdef CONFIG_DYNAMIC_FTRACE
18862
18863 ENTRY(function_hook)
18864 + pax_force_retaddr
18865 retq
18866 -END(function_hook)
18867 +ENDPROC(function_hook)
18868
18869 /* skip is set if stack has been adjusted */
18870 .macro ftrace_caller_setup skip=0
18871 @@ -122,8 +125,9 @@ GLOBAL(ftrace_graph_call)
18872 #endif
18873
18874 GLOBAL(ftrace_stub)
18875 + pax_force_retaddr
18876 retq
18877 -END(ftrace_caller)
18878 +ENDPROC(ftrace_caller)
18879
18880 ENTRY(ftrace_regs_caller)
18881 /* Save the current flags before compare (in SS location)*/
18882 @@ -191,7 +195,7 @@ ftrace_restore_flags:
18883 popfq
18884 jmp ftrace_stub
18885
18886 -END(ftrace_regs_caller)
18887 +ENDPROC(ftrace_regs_caller)
18888
18889
18890 #else /* ! CONFIG_DYNAMIC_FTRACE */
18891 @@ -212,6 +216,7 @@ ENTRY(function_hook)
18892 #endif
18893
18894 GLOBAL(ftrace_stub)
18895 + pax_force_retaddr
18896 retq
18897
18898 trace:
18899 @@ -225,12 +230,13 @@ trace:
18900 #endif
18901 subq $MCOUNT_INSN_SIZE, %rdi
18902
18903 + pax_force_fptr ftrace_trace_function
18904 call *ftrace_trace_function
18905
18906 MCOUNT_RESTORE_FRAME
18907
18908 jmp ftrace_stub
18909 -END(function_hook)
18910 +ENDPROC(function_hook)
18911 #endif /* CONFIG_DYNAMIC_FTRACE */
18912 #endif /* CONFIG_FUNCTION_TRACER */
18913
18914 @@ -252,8 +258,9 @@ ENTRY(ftrace_graph_caller)
18915
18916 MCOUNT_RESTORE_FRAME
18917
18918 + pax_force_retaddr
18919 retq
18920 -END(ftrace_graph_caller)
18921 +ENDPROC(ftrace_graph_caller)
18922
18923 GLOBAL(return_to_handler)
18924 subq $24, %rsp
18925 @@ -269,7 +276,9 @@ GLOBAL(return_to_handler)
18926 movq 8(%rsp), %rdx
18927 movq (%rsp), %rax
18928 addq $24, %rsp
18929 + pax_force_fptr %rdi
18930 jmp *%rdi
18931 +ENDPROC(return_to_handler)
18932 #endif
18933
18934
18935 @@ -284,6 +293,273 @@ ENTRY(native_usergs_sysret64)
18936 ENDPROC(native_usergs_sysret64)
18937 #endif /* CONFIG_PARAVIRT */
18938
18939 + .macro ljmpq sel, off
18940 +#if defined(CONFIG_MPSC) || defined(CONFIG_MCORE2) || defined (CONFIG_MATOM)
18941 + .byte 0x48; ljmp *1234f(%rip)
18942 + .pushsection .rodata
18943 + .align 16
18944 + 1234: .quad \off; .word \sel
18945 + .popsection
18946 +#else
18947 + pushq $\sel
18948 + pushq $\off
18949 + lretq
18950 +#endif
18951 + .endm
18952 +
18953 + .macro pax_enter_kernel
18954 + pax_set_fptr_mask
18955 +#ifdef CONFIG_PAX_KERNEXEC
18956 + call pax_enter_kernel
18957 +#endif
18958 + .endm
18959 +
18960 + .macro pax_exit_kernel
18961 +#ifdef CONFIG_PAX_KERNEXEC
18962 + call pax_exit_kernel
18963 +#endif
18964 + .endm
18965 +
18966 +#ifdef CONFIG_PAX_KERNEXEC
18967 +ENTRY(pax_enter_kernel)
18968 + pushq %rdi
18969 +
18970 +#ifdef CONFIG_PARAVIRT
18971 + PV_SAVE_REGS(CLBR_RDI)
18972 +#endif
18973 +
18974 + GET_CR0_INTO_RDI
18975 + bts $16,%rdi
18976 + jnc 3f
18977 + mov %cs,%edi
18978 + cmp $__KERNEL_CS,%edi
18979 + jnz 2f
18980 +1:
18981 +
18982 +#ifdef CONFIG_PARAVIRT
18983 + PV_RESTORE_REGS(CLBR_RDI)
18984 +#endif
18985 +
18986 + popq %rdi
18987 + pax_force_retaddr
18988 + retq
18989 +
18990 +2: ljmpq __KERNEL_CS,1f
18991 +3: ljmpq __KERNEXEC_KERNEL_CS,4f
18992 +4: SET_RDI_INTO_CR0
18993 + jmp 1b
18994 +ENDPROC(pax_enter_kernel)
18995 +
18996 +ENTRY(pax_exit_kernel)
18997 + pushq %rdi
18998 +
18999 +#ifdef CONFIG_PARAVIRT
19000 + PV_SAVE_REGS(CLBR_RDI)
19001 +#endif
19002 +
19003 + mov %cs,%rdi
19004 + cmp $__KERNEXEC_KERNEL_CS,%edi
19005 + jz 2f
19006 +1:
19007 +
19008 +#ifdef CONFIG_PARAVIRT
19009 + PV_RESTORE_REGS(CLBR_RDI);
19010 +#endif
19011 +
19012 + popq %rdi
19013 + pax_force_retaddr
19014 + retq
19015 +
19016 +2: GET_CR0_INTO_RDI
19017 + btr $16,%rdi
19018 + ljmpq __KERNEL_CS,3f
19019 +3: SET_RDI_INTO_CR0
19020 + jmp 1b
19021 +ENDPROC(pax_exit_kernel)
19022 +#endif
19023 +
19024 + .macro pax_enter_kernel_user
19025 + pax_set_fptr_mask
19026 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19027 + call pax_enter_kernel_user
19028 +#endif
19029 + .endm
19030 +
19031 + .macro pax_exit_kernel_user
19032 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19033 + call pax_exit_kernel_user
19034 +#endif
19035 +#ifdef CONFIG_PAX_RANDKSTACK
19036 + pushq %rax
19037 + call pax_randomize_kstack
19038 + popq %rax
19039 +#endif
19040 + .endm
19041 +
19042 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19043 +ENTRY(pax_enter_kernel_user)
19044 + pushq %rdi
19045 + pushq %rbx
19046 +
19047 +#ifdef CONFIG_PARAVIRT
19048 + PV_SAVE_REGS(CLBR_RDI)
19049 +#endif
19050 +
19051 + GET_CR3_INTO_RDI
19052 + mov %rdi,%rbx
19053 + add $__START_KERNEL_map,%rbx
19054 + sub phys_base(%rip),%rbx
19055 +
19056 +#ifdef CONFIG_PARAVIRT
19057 + pushq %rdi
19058 + cmpl $0, pv_info+PARAVIRT_enabled
19059 + jz 1f
19060 + i = 0
19061 + .rept USER_PGD_PTRS
19062 + mov i*8(%rbx),%rsi
19063 + mov $0,%sil
19064 + lea i*8(%rbx),%rdi
19065 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_set_pgd_batched)
19066 + i = i + 1
19067 + .endr
19068 + jmp 2f
19069 +1:
19070 +#endif
19071 +
19072 + i = 0
19073 + .rept USER_PGD_PTRS
19074 + movb $0,i*8(%rbx)
19075 + i = i + 1
19076 + .endr
19077 +
19078 +#ifdef CONFIG_PARAVIRT
19079 +2: popq %rdi
19080 +#endif
19081 + SET_RDI_INTO_CR3
19082 +
19083 +#ifdef CONFIG_PAX_KERNEXEC
19084 + GET_CR0_INTO_RDI
19085 + bts $16,%rdi
19086 + SET_RDI_INTO_CR0
19087 +#endif
19088 +
19089 +#ifdef CONFIG_PARAVIRT
19090 + PV_RESTORE_REGS(CLBR_RDI)
19091 +#endif
19092 +
19093 + popq %rbx
19094 + popq %rdi
19095 + pax_force_retaddr
19096 + retq
19097 +ENDPROC(pax_enter_kernel_user)
19098 +
19099 +ENTRY(pax_exit_kernel_user)
19100 + push %rdi
19101 +
19102 +#ifdef CONFIG_PARAVIRT
19103 + pushq %rbx
19104 + PV_SAVE_REGS(CLBR_RDI)
19105 +#endif
19106 +
19107 +#ifdef CONFIG_PAX_KERNEXEC
19108 + GET_CR0_INTO_RDI
19109 + btr $16,%rdi
19110 + SET_RDI_INTO_CR0
19111 +#endif
19112 +
19113 + GET_CR3_INTO_RDI
19114 + add $__START_KERNEL_map,%rdi
19115 + sub phys_base(%rip),%rdi
19116 +
19117 +#ifdef CONFIG_PARAVIRT
19118 + cmpl $0, pv_info+PARAVIRT_enabled
19119 + jz 1f
19120 + mov %rdi,%rbx
19121 + i = 0
19122 + .rept USER_PGD_PTRS
19123 + mov i*8(%rbx),%rsi
19124 + mov $0x67,%sil
19125 + lea i*8(%rbx),%rdi
19126 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_set_pgd_batched)
19127 + i = i + 1
19128 + .endr
19129 + jmp 2f
19130 +1:
19131 +#endif
19132 +
19133 + i = 0
19134 + .rept USER_PGD_PTRS
19135 + movb $0x67,i*8(%rdi)
19136 + i = i + 1
19137 + .endr
19138 +
19139 +#ifdef CONFIG_PARAVIRT
19140 +2: PV_RESTORE_REGS(CLBR_RDI)
19141 + popq %rbx
19142 +#endif
19143 +
19144 + popq %rdi
19145 + pax_force_retaddr
19146 + retq
19147 +ENDPROC(pax_exit_kernel_user)
19148 +#endif
19149 +
19150 +.macro pax_erase_kstack
19151 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
19152 + call pax_erase_kstack
19153 +#endif
19154 +.endm
19155 +
19156 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
19157 +ENTRY(pax_erase_kstack)
19158 + pushq %rdi
19159 + pushq %rcx
19160 + pushq %rax
19161 + pushq %r11
19162 +
19163 + GET_THREAD_INFO(%r11)
19164 + mov TI_lowest_stack(%r11), %rdi
19165 + mov $-0xBEEF, %rax
19166 + std
19167 +
19168 +1: mov %edi, %ecx
19169 + and $THREAD_SIZE_asm - 1, %ecx
19170 + shr $3, %ecx
19171 + repne scasq
19172 + jecxz 2f
19173 +
19174 + cmp $2*8, %ecx
19175 + jc 2f
19176 +
19177 + mov $2*8, %ecx
19178 + repe scasq
19179 + jecxz 2f
19180 + jne 1b
19181 +
19182 +2: cld
19183 + mov %esp, %ecx
19184 + sub %edi, %ecx
19185 +
19186 + cmp $THREAD_SIZE_asm, %rcx
19187 + jb 3f
19188 + ud2
19189 +3:
19190 +
19191 + shr $3, %ecx
19192 + rep stosq
19193 +
19194 + mov TI_task_thread_sp0(%r11), %rdi
19195 + sub $256, %rdi
19196 + mov %rdi, TI_lowest_stack(%r11)
19197 +
19198 + popq %r11
19199 + popq %rax
19200 + popq %rcx
19201 + popq %rdi
19202 + pax_force_retaddr
19203 + ret
19204 +ENDPROC(pax_erase_kstack)
19205 +#endif
19206
19207 .macro TRACE_IRQS_IRETQ offset=ARGOFFSET
19208 #ifdef CONFIG_TRACE_IRQFLAGS
19209 @@ -375,8 +651,8 @@ ENDPROC(native_usergs_sysret64)
19210 .endm
19211
19212 .macro UNFAKE_STACK_FRAME
19213 - addq $8*6, %rsp
19214 - CFI_ADJUST_CFA_OFFSET -(6*8)
19215 + addq $8*6 + ARG_SKIP, %rsp
19216 + CFI_ADJUST_CFA_OFFSET -(6*8 + ARG_SKIP)
19217 .endm
19218
19219 /*
19220 @@ -463,7 +739,7 @@ ENDPROC(native_usergs_sysret64)
19221 movq %rsp, %rsi
19222
19223 leaq -RBP(%rsp),%rdi /* arg1 for handler */
19224 - testl $3, CS-RBP(%rsi)
19225 + testb $3, CS-RBP(%rsi)
19226 je 1f
19227 SWAPGS
19228 /*
19229 @@ -498,9 +774,10 @@ ENTRY(save_rest)
19230 movq_cfi r15, R15+16
19231 movq %r11, 8(%rsp) /* return address */
19232 FIXUP_TOP_OF_STACK %r11, 16
19233 + pax_force_retaddr
19234 ret
19235 CFI_ENDPROC
19236 -END(save_rest)
19237 +ENDPROC(save_rest)
19238
19239 /* save complete stack frame */
19240 .pushsection .kprobes.text, "ax"
19241 @@ -529,9 +806,10 @@ ENTRY(save_paranoid)
19242 js 1f /* negative -> in kernel */
19243 SWAPGS
19244 xorl %ebx,%ebx
19245 -1: ret
19246 +1: pax_force_retaddr_bts
19247 + ret
19248 CFI_ENDPROC
19249 -END(save_paranoid)
19250 +ENDPROC(save_paranoid)
19251 .popsection
19252
19253 /*
19254 @@ -553,7 +831,7 @@ ENTRY(ret_from_fork)
19255
19256 RESTORE_REST
19257
19258 - testl $3, CS-ARGOFFSET(%rsp) # from kernel_thread?
19259 + testb $3, CS-ARGOFFSET(%rsp) # from kernel_thread?
19260 jz 1f
19261
19262 testl $_TIF_IA32, TI_flags(%rcx) # 32-bit compat task needs IRET
19263 @@ -571,7 +849,7 @@ ENTRY(ret_from_fork)
19264 RESTORE_REST
19265 jmp int_ret_from_sys_call
19266 CFI_ENDPROC
19267 -END(ret_from_fork)
19268 +ENDPROC(ret_from_fork)
19269
19270 /*
19271 * System call entry. Up to 6 arguments in registers are supported.
19272 @@ -608,7 +886,7 @@ END(ret_from_fork)
19273 ENTRY(system_call)
19274 CFI_STARTPROC simple
19275 CFI_SIGNAL_FRAME
19276 - CFI_DEF_CFA rsp,KERNEL_STACK_OFFSET
19277 + CFI_DEF_CFA rsp,0
19278 CFI_REGISTER rip,rcx
19279 /*CFI_REGISTER rflags,r11*/
19280 SWAPGS_UNSAFE_STACK
19281 @@ -621,16 +899,23 @@ GLOBAL(system_call_after_swapgs)
19282
19283 movq %rsp,PER_CPU_VAR(old_rsp)
19284 movq PER_CPU_VAR(kernel_stack),%rsp
19285 + SAVE_ARGS 8*6,0
19286 + pax_enter_kernel_user
19287 +
19288 +#ifdef CONFIG_PAX_RANDKSTACK
19289 + pax_erase_kstack
19290 +#endif
19291 +
19292 /*
19293 * No need to follow this irqs off/on section - it's straight
19294 * and short:
19295 */
19296 ENABLE_INTERRUPTS(CLBR_NONE)
19297 - SAVE_ARGS 8,0
19298 movq %rax,ORIG_RAX-ARGOFFSET(%rsp)
19299 movq %rcx,RIP-ARGOFFSET(%rsp)
19300 CFI_REL_OFFSET rip,RIP-ARGOFFSET
19301 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
19302 + GET_THREAD_INFO(%rcx)
19303 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%rcx)
19304 jnz tracesys
19305 system_call_fastpath:
19306 #if __SYSCALL_MASK == ~0
19307 @@ -640,7 +925,7 @@ system_call_fastpath:
19308 cmpl $__NR_syscall_max,%eax
19309 #endif
19310 ja badsys
19311 - movq %r10,%rcx
19312 + movq R10-ARGOFFSET(%rsp),%rcx
19313 call *sys_call_table(,%rax,8) # XXX: rip relative
19314 movq %rax,RAX-ARGOFFSET(%rsp)
19315 /*
19316 @@ -654,10 +939,13 @@ sysret_check:
19317 LOCKDEP_SYS_EXIT
19318 DISABLE_INTERRUPTS(CLBR_NONE)
19319 TRACE_IRQS_OFF
19320 - movl TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET),%edx
19321 + GET_THREAD_INFO(%rcx)
19322 + movl TI_flags(%rcx),%edx
19323 andl %edi,%edx
19324 jnz sysret_careful
19325 CFI_REMEMBER_STATE
19326 + pax_exit_kernel_user
19327 + pax_erase_kstack
19328 /*
19329 * sysretq will re-enable interrupts:
19330 */
19331 @@ -709,14 +997,18 @@ badsys:
19332 * jump back to the normal fast path.
19333 */
19334 auditsys:
19335 - movq %r10,%r9 /* 6th arg: 4th syscall arg */
19336 + movq R10-ARGOFFSET(%rsp),%r9 /* 6th arg: 4th syscall arg */
19337 movq %rdx,%r8 /* 5th arg: 3rd syscall arg */
19338 movq %rsi,%rcx /* 4th arg: 2nd syscall arg */
19339 movq %rdi,%rdx /* 3rd arg: 1st syscall arg */
19340 movq %rax,%rsi /* 2nd arg: syscall number */
19341 movl $AUDIT_ARCH_X86_64,%edi /* 1st arg: audit arch */
19342 call __audit_syscall_entry
19343 +
19344 + pax_erase_kstack
19345 +
19346 LOAD_ARGS 0 /* reload call-clobbered registers */
19347 + pax_set_fptr_mask
19348 jmp system_call_fastpath
19349
19350 /*
19351 @@ -737,7 +1029,7 @@ sysret_audit:
19352 /* Do syscall tracing */
19353 tracesys:
19354 #ifdef CONFIG_AUDITSYSCALL
19355 - testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
19356 + testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags(%rcx)
19357 jz auditsys
19358 #endif
19359 SAVE_REST
19360 @@ -745,12 +1037,16 @@ tracesys:
19361 FIXUP_TOP_OF_STACK %rdi
19362 movq %rsp,%rdi
19363 call syscall_trace_enter
19364 +
19365 + pax_erase_kstack
19366 +
19367 /*
19368 * Reload arg registers from stack in case ptrace changed them.
19369 * We don't reload %rax because syscall_trace_enter() returned
19370 * the value it wants us to use in the table lookup.
19371 */
19372 LOAD_ARGS ARGOFFSET, 1
19373 + pax_set_fptr_mask
19374 RESTORE_REST
19375 #if __SYSCALL_MASK == ~0
19376 cmpq $__NR_syscall_max,%rax
19377 @@ -759,7 +1055,7 @@ tracesys:
19378 cmpl $__NR_syscall_max,%eax
19379 #endif
19380 ja int_ret_from_sys_call /* RAX(%rsp) set to -ENOSYS above */
19381 - movq %r10,%rcx /* fixup for C */
19382 + movq R10-ARGOFFSET(%rsp),%rcx /* fixup for C */
19383 call *sys_call_table(,%rax,8)
19384 movq %rax,RAX-ARGOFFSET(%rsp)
19385 /* Use IRET because user could have changed frame */
19386 @@ -780,7 +1076,9 @@ GLOBAL(int_with_check)
19387 andl %edi,%edx
19388 jnz int_careful
19389 andl $~TS_COMPAT,TI_status(%rcx)
19390 - jmp retint_swapgs
19391 + pax_exit_kernel_user
19392 + pax_erase_kstack
19393 + jmp retint_swapgs_pax
19394
19395 /* Either reschedule or signal or syscall exit tracking needed. */
19396 /* First do a reschedule test. */
19397 @@ -826,7 +1124,7 @@ int_restore_rest:
19398 TRACE_IRQS_OFF
19399 jmp int_with_check
19400 CFI_ENDPROC
19401 -END(system_call)
19402 +ENDPROC(system_call)
19403
19404 /*
19405 * Certain special system calls that need to save a complete full stack frame.
19406 @@ -842,7 +1140,7 @@ ENTRY(\label)
19407 call \func
19408 jmp ptregscall_common
19409 CFI_ENDPROC
19410 -END(\label)
19411 +ENDPROC(\label)
19412 .endm
19413
19414 .macro FORK_LIKE func
19415 @@ -856,9 +1154,10 @@ ENTRY(stub_\func)
19416 DEFAULT_FRAME 0 8 /* offset 8: return address */
19417 call sys_\func
19418 RESTORE_TOP_OF_STACK %r11, 8
19419 + pax_force_retaddr
19420 ret $REST_SKIP /* pop extended registers */
19421 CFI_ENDPROC
19422 -END(stub_\func)
19423 +ENDPROC(stub_\func)
19424 .endm
19425
19426 FORK_LIKE clone
19427 @@ -875,9 +1174,10 @@ ENTRY(ptregscall_common)
19428 movq_cfi_restore R12+8, r12
19429 movq_cfi_restore RBP+8, rbp
19430 movq_cfi_restore RBX+8, rbx
19431 + pax_force_retaddr
19432 ret $REST_SKIP /* pop extended registers */
19433 CFI_ENDPROC
19434 -END(ptregscall_common)
19435 +ENDPROC(ptregscall_common)
19436
19437 ENTRY(stub_execve)
19438 CFI_STARTPROC
19439 @@ -891,7 +1191,7 @@ ENTRY(stub_execve)
19440 RESTORE_REST
19441 jmp int_ret_from_sys_call
19442 CFI_ENDPROC
19443 -END(stub_execve)
19444 +ENDPROC(stub_execve)
19445
19446 /*
19447 * sigreturn is special because it needs to restore all registers on return.
19448 @@ -909,7 +1209,7 @@ ENTRY(stub_rt_sigreturn)
19449 RESTORE_REST
19450 jmp int_ret_from_sys_call
19451 CFI_ENDPROC
19452 -END(stub_rt_sigreturn)
19453 +ENDPROC(stub_rt_sigreturn)
19454
19455 #ifdef CONFIG_X86_X32_ABI
19456 ENTRY(stub_x32_rt_sigreturn)
19457 @@ -975,7 +1275,7 @@ vector=vector+1
19458 2: jmp common_interrupt
19459 .endr
19460 CFI_ENDPROC
19461 -END(irq_entries_start)
19462 +ENDPROC(irq_entries_start)
19463
19464 .previous
19465 END(interrupt)
19466 @@ -995,6 +1295,16 @@ END(interrupt)
19467 subq $ORIG_RAX-RBP, %rsp
19468 CFI_ADJUST_CFA_OFFSET ORIG_RAX-RBP
19469 SAVE_ARGS_IRQ
19470 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19471 + testb $3, CS(%rdi)
19472 + jnz 1f
19473 + pax_enter_kernel
19474 + jmp 2f
19475 +1: pax_enter_kernel_user
19476 +2:
19477 +#else
19478 + pax_enter_kernel
19479 +#endif
19480 call \func
19481 .endm
19482
19483 @@ -1027,7 +1337,7 @@ ret_from_intr:
19484
19485 exit_intr:
19486 GET_THREAD_INFO(%rcx)
19487 - testl $3,CS-ARGOFFSET(%rsp)
19488 + testb $3,CS-ARGOFFSET(%rsp)
19489 je retint_kernel
19490
19491 /* Interrupt came from user space */
19492 @@ -1049,12 +1359,16 @@ retint_swapgs: /* return to user-space */
19493 * The iretq could re-enable interrupts:
19494 */
19495 DISABLE_INTERRUPTS(CLBR_ANY)
19496 + pax_exit_kernel_user
19497 +retint_swapgs_pax:
19498 TRACE_IRQS_IRETQ
19499 SWAPGS
19500 jmp restore_args
19501
19502 retint_restore_args: /* return to kernel space */
19503 DISABLE_INTERRUPTS(CLBR_ANY)
19504 + pax_exit_kernel
19505 + pax_force_retaddr (RIP-ARGOFFSET)
19506 /*
19507 * The iretq could re-enable interrupts:
19508 */
19509 @@ -1137,7 +1451,7 @@ ENTRY(retint_kernel)
19510 #endif
19511
19512 CFI_ENDPROC
19513 -END(common_interrupt)
19514 +ENDPROC(common_interrupt)
19515 /*
19516 * End of kprobes section
19517 */
19518 @@ -1155,7 +1469,7 @@ ENTRY(\sym)
19519 interrupt \do_sym
19520 jmp ret_from_intr
19521 CFI_ENDPROC
19522 -END(\sym)
19523 +ENDPROC(\sym)
19524 .endm
19525
19526 #ifdef CONFIG_SMP
19527 @@ -1211,12 +1525,22 @@ ENTRY(\sym)
19528 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
19529 call error_entry
19530 DEFAULT_FRAME 0
19531 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19532 + testb $3, CS(%rsp)
19533 + jnz 1f
19534 + pax_enter_kernel
19535 + jmp 2f
19536 +1: pax_enter_kernel_user
19537 +2:
19538 +#else
19539 + pax_enter_kernel
19540 +#endif
19541 movq %rsp,%rdi /* pt_regs pointer */
19542 xorl %esi,%esi /* no error code */
19543 call \do_sym
19544 jmp error_exit /* %ebx: no swapgs flag */
19545 CFI_ENDPROC
19546 -END(\sym)
19547 +ENDPROC(\sym)
19548 .endm
19549
19550 .macro paranoidzeroentry sym do_sym
19551 @@ -1229,15 +1553,25 @@ ENTRY(\sym)
19552 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
19553 call save_paranoid
19554 TRACE_IRQS_OFF
19555 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19556 + testb $3, CS(%rsp)
19557 + jnz 1f
19558 + pax_enter_kernel
19559 + jmp 2f
19560 +1: pax_enter_kernel_user
19561 +2:
19562 +#else
19563 + pax_enter_kernel
19564 +#endif
19565 movq %rsp,%rdi /* pt_regs pointer */
19566 xorl %esi,%esi /* no error code */
19567 call \do_sym
19568 jmp paranoid_exit /* %ebx: no swapgs flag */
19569 CFI_ENDPROC
19570 -END(\sym)
19571 +ENDPROC(\sym)
19572 .endm
19573
19574 -#define INIT_TSS_IST(x) PER_CPU_VAR(init_tss) + (TSS_ist + ((x) - 1) * 8)
19575 +#define INIT_TSS_IST(x) (TSS_ist + ((x) - 1) * 8)(%r12)
19576 .macro paranoidzeroentry_ist sym do_sym ist
19577 ENTRY(\sym)
19578 INTR_FRAME
19579 @@ -1248,14 +1582,30 @@ ENTRY(\sym)
19580 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
19581 call save_paranoid
19582 TRACE_IRQS_OFF_DEBUG
19583 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19584 + testb $3, CS(%rsp)
19585 + jnz 1f
19586 + pax_enter_kernel
19587 + jmp 2f
19588 +1: pax_enter_kernel_user
19589 +2:
19590 +#else
19591 + pax_enter_kernel
19592 +#endif
19593 movq %rsp,%rdi /* pt_regs pointer */
19594 xorl %esi,%esi /* no error code */
19595 +#ifdef CONFIG_SMP
19596 + imul $TSS_size, PER_CPU_VAR(cpu_number), %r12d
19597 + lea init_tss(%r12), %r12
19598 +#else
19599 + lea init_tss(%rip), %r12
19600 +#endif
19601 subq $EXCEPTION_STKSZ, INIT_TSS_IST(\ist)
19602 call \do_sym
19603 addq $EXCEPTION_STKSZ, INIT_TSS_IST(\ist)
19604 jmp paranoid_exit /* %ebx: no swapgs flag */
19605 CFI_ENDPROC
19606 -END(\sym)
19607 +ENDPROC(\sym)
19608 .endm
19609
19610 .macro errorentry sym do_sym
19611 @@ -1267,13 +1617,23 @@ ENTRY(\sym)
19612 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
19613 call error_entry
19614 DEFAULT_FRAME 0
19615 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19616 + testb $3, CS(%rsp)
19617 + jnz 1f
19618 + pax_enter_kernel
19619 + jmp 2f
19620 +1: pax_enter_kernel_user
19621 +2:
19622 +#else
19623 + pax_enter_kernel
19624 +#endif
19625 movq %rsp,%rdi /* pt_regs pointer */
19626 movq ORIG_RAX(%rsp),%rsi /* get error code */
19627 movq $-1,ORIG_RAX(%rsp) /* no syscall to restart */
19628 call \do_sym
19629 jmp error_exit /* %ebx: no swapgs flag */
19630 CFI_ENDPROC
19631 -END(\sym)
19632 +ENDPROC(\sym)
19633 .endm
19634
19635 /* error code is on the stack already */
19636 @@ -1287,13 +1647,23 @@ ENTRY(\sym)
19637 call save_paranoid
19638 DEFAULT_FRAME 0
19639 TRACE_IRQS_OFF
19640 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19641 + testb $3, CS(%rsp)
19642 + jnz 1f
19643 + pax_enter_kernel
19644 + jmp 2f
19645 +1: pax_enter_kernel_user
19646 +2:
19647 +#else
19648 + pax_enter_kernel
19649 +#endif
19650 movq %rsp,%rdi /* pt_regs pointer */
19651 movq ORIG_RAX(%rsp),%rsi /* get error code */
19652 movq $-1,ORIG_RAX(%rsp) /* no syscall to restart */
19653 call \do_sym
19654 jmp paranoid_exit /* %ebx: no swapgs flag */
19655 CFI_ENDPROC
19656 -END(\sym)
19657 +ENDPROC(\sym)
19658 .endm
19659
19660 zeroentry divide_error do_divide_error
19661 @@ -1323,9 +1693,10 @@ gs_change:
19662 2: mfence /* workaround */
19663 SWAPGS
19664 popfq_cfi
19665 + pax_force_retaddr
19666 ret
19667 CFI_ENDPROC
19668 -END(native_load_gs_index)
19669 +ENDPROC(native_load_gs_index)
19670
19671 _ASM_EXTABLE(gs_change,bad_gs)
19672 .section .fixup,"ax"
19673 @@ -1353,9 +1724,10 @@ ENTRY(call_softirq)
19674 CFI_DEF_CFA_REGISTER rsp
19675 CFI_ADJUST_CFA_OFFSET -8
19676 decl PER_CPU_VAR(irq_count)
19677 + pax_force_retaddr
19678 ret
19679 CFI_ENDPROC
19680 -END(call_softirq)
19681 +ENDPROC(call_softirq)
19682
19683 #ifdef CONFIG_XEN
19684 zeroentry xen_hypervisor_callback xen_do_hypervisor_callback
19685 @@ -1393,7 +1765,7 @@ ENTRY(xen_do_hypervisor_callback) # do_hypervisor_callback(struct *pt_regs)
19686 decl PER_CPU_VAR(irq_count)
19687 jmp error_exit
19688 CFI_ENDPROC
19689 -END(xen_do_hypervisor_callback)
19690 +ENDPROC(xen_do_hypervisor_callback)
19691
19692 /*
19693 * Hypervisor uses this for application faults while it executes.
19694 @@ -1452,7 +1824,7 @@ ENTRY(xen_failsafe_callback)
19695 SAVE_ALL
19696 jmp error_exit
19697 CFI_ENDPROC
19698 -END(xen_failsafe_callback)
19699 +ENDPROC(xen_failsafe_callback)
19700
19701 apicinterrupt XEN_HVM_EVTCHN_CALLBACK \
19702 xen_hvm_callback_vector xen_evtchn_do_upcall
19703 @@ -1501,16 +1873,31 @@ ENTRY(paranoid_exit)
19704 TRACE_IRQS_OFF_DEBUG
19705 testl %ebx,%ebx /* swapgs needed? */
19706 jnz paranoid_restore
19707 - testl $3,CS(%rsp)
19708 + testb $3,CS(%rsp)
19709 jnz paranoid_userspace
19710 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19711 + pax_exit_kernel
19712 + TRACE_IRQS_IRETQ 0
19713 + SWAPGS_UNSAFE_STACK
19714 + RESTORE_ALL 8
19715 + pax_force_retaddr_bts
19716 + jmp irq_return
19717 +#endif
19718 paranoid_swapgs:
19719 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19720 + pax_exit_kernel_user
19721 +#else
19722 + pax_exit_kernel
19723 +#endif
19724 TRACE_IRQS_IRETQ 0
19725 SWAPGS_UNSAFE_STACK
19726 RESTORE_ALL 8
19727 jmp irq_return
19728 paranoid_restore:
19729 + pax_exit_kernel
19730 TRACE_IRQS_IRETQ_DEBUG 0
19731 RESTORE_ALL 8
19732 + pax_force_retaddr_bts
19733 jmp irq_return
19734 paranoid_userspace:
19735 GET_THREAD_INFO(%rcx)
19736 @@ -1539,7 +1926,7 @@ paranoid_schedule:
19737 TRACE_IRQS_OFF
19738 jmp paranoid_userspace
19739 CFI_ENDPROC
19740 -END(paranoid_exit)
19741 +ENDPROC(paranoid_exit)
19742
19743 /*
19744 * Exception entry point. This expects an error code/orig_rax on the stack.
19745 @@ -1566,12 +1953,13 @@ ENTRY(error_entry)
19746 movq_cfi r14, R14+8
19747 movq_cfi r15, R15+8
19748 xorl %ebx,%ebx
19749 - testl $3,CS+8(%rsp)
19750 + testb $3,CS+8(%rsp)
19751 je error_kernelspace
19752 error_swapgs:
19753 SWAPGS
19754 error_sti:
19755 TRACE_IRQS_OFF
19756 + pax_force_retaddr_bts
19757 ret
19758
19759 /*
19760 @@ -1598,7 +1986,7 @@ bstep_iret:
19761 movq %rcx,RIP+8(%rsp)
19762 jmp error_swapgs
19763 CFI_ENDPROC
19764 -END(error_entry)
19765 +ENDPROC(error_entry)
19766
19767
19768 /* ebx: no swapgs flag (1: don't need swapgs, 0: need it) */
19769 @@ -1618,7 +2006,7 @@ ENTRY(error_exit)
19770 jnz retint_careful
19771 jmp retint_swapgs
19772 CFI_ENDPROC
19773 -END(error_exit)
19774 +ENDPROC(error_exit)
19775
19776 /*
19777 * Test if a given stack is an NMI stack or not.
19778 @@ -1676,9 +2064,11 @@ ENTRY(nmi)
19779 * If %cs was not the kernel segment, then the NMI triggered in user
19780 * space, which means it is definitely not nested.
19781 */
19782 + cmpl $__KERNEXEC_KERNEL_CS, 16(%rsp)
19783 + je 1f
19784 cmpl $__KERNEL_CS, 16(%rsp)
19785 jne first_nmi
19786 -
19787 +1:
19788 /*
19789 * Check the special variable on the stack to see if NMIs are
19790 * executing.
19791 @@ -1847,6 +2237,17 @@ end_repeat_nmi:
19792 */
19793 movq %cr2, %r12
19794
19795 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19796 + testb $3, CS(%rsp)
19797 + jnz 1f
19798 + pax_enter_kernel
19799 + jmp 2f
19800 +1: pax_enter_kernel_user
19801 +2:
19802 +#else
19803 + pax_enter_kernel
19804 +#endif
19805 +
19806 /* paranoidentry do_nmi, 0; without TRACE_IRQS_OFF */
19807 movq %rsp,%rdi
19808 movq $-1,%rsi
19809 @@ -1862,23 +2263,34 @@ end_repeat_nmi:
19810 testl %ebx,%ebx /* swapgs needed? */
19811 jnz nmi_restore
19812 nmi_swapgs:
19813 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19814 + pax_exit_kernel_user
19815 +#else
19816 + pax_exit_kernel
19817 +#endif
19818 SWAPGS_UNSAFE_STACK
19819 + RESTORE_ALL 6*8
19820 + /* Clear the NMI executing stack variable */
19821 + movq $0, 5*8(%rsp)
19822 + jmp irq_return
19823 nmi_restore:
19824 + pax_exit_kernel
19825 /* Pop the extra iret frame at once */
19826 RESTORE_ALL 6*8
19827 + pax_force_retaddr_bts
19828
19829 /* Clear the NMI executing stack variable */
19830 movq $0, 5*8(%rsp)
19831 jmp irq_return
19832 CFI_ENDPROC
19833 -END(nmi)
19834 +ENDPROC(nmi)
19835
19836 ENTRY(ignore_sysret)
19837 CFI_STARTPROC
19838 mov $-ENOSYS,%eax
19839 sysret
19840 CFI_ENDPROC
19841 -END(ignore_sysret)
19842 +ENDPROC(ignore_sysret)
19843
19844 /*
19845 * End of kprobes section
19846 diff --git a/arch/x86/kernel/ftrace.c b/arch/x86/kernel/ftrace.c
19847 index 1d41402..af9a46a 100644
19848 --- a/arch/x86/kernel/ftrace.c
19849 +++ b/arch/x86/kernel/ftrace.c
19850 @@ -105,6 +105,8 @@ ftrace_modify_code_direct(unsigned long ip, unsigned const char *old_code,
19851 {
19852 unsigned char replaced[MCOUNT_INSN_SIZE];
19853
19854 + ip = ktla_ktva(ip);
19855 +
19856 /*
19857 * Note: Due to modules and __init, code can
19858 * disappear and change, we need to protect against faulting
19859 @@ -227,7 +229,7 @@ int ftrace_update_ftrace_func(ftrace_func_t func)
19860 unsigned char old[MCOUNT_INSN_SIZE], *new;
19861 int ret;
19862
19863 - memcpy(old, &ftrace_call, MCOUNT_INSN_SIZE);
19864 + memcpy(old, (void *)ktla_ktva((unsigned long)ftrace_call), MCOUNT_INSN_SIZE);
19865 new = ftrace_call_replace(ip, (unsigned long)func);
19866
19867 /* See comment above by declaration of modifying_ftrace_code */
19868 @@ -238,7 +240,7 @@ int ftrace_update_ftrace_func(ftrace_func_t func)
19869 /* Also update the regs callback function */
19870 if (!ret) {
19871 ip = (unsigned long)(&ftrace_regs_call);
19872 - memcpy(old, &ftrace_regs_call, MCOUNT_INSN_SIZE);
19873 + memcpy(old, ktla_ktva((void *)&ftrace_regs_call), MCOUNT_INSN_SIZE);
19874 new = ftrace_call_replace(ip, (unsigned long)func);
19875 ret = ftrace_modify_code(ip, old, new);
19876 }
19877 @@ -279,7 +281,7 @@ static int ftrace_write(unsigned long ip, const char *val, int size)
19878 * kernel identity mapping to modify code.
19879 */
19880 if (within(ip, (unsigned long)_text, (unsigned long)_etext))
19881 - ip = (unsigned long)__va(__pa(ip));
19882 + ip = (unsigned long)__va(__pa(ktla_ktva(ip)));
19883
19884 return probe_kernel_write((void *)ip, val, size);
19885 }
19886 @@ -289,7 +291,7 @@ static int add_break(unsigned long ip, const char *old)
19887 unsigned char replaced[MCOUNT_INSN_SIZE];
19888 unsigned char brk = BREAKPOINT_INSTRUCTION;
19889
19890 - if (probe_kernel_read(replaced, (void *)ip, MCOUNT_INSN_SIZE))
19891 + if (probe_kernel_read(replaced, (void *)ktla_ktva(ip), MCOUNT_INSN_SIZE))
19892 return -EFAULT;
19893
19894 /* Make sure it is what we expect it to be */
19895 @@ -637,7 +639,7 @@ ftrace_modify_code(unsigned long ip, unsigned const char *old_code,
19896 return ret;
19897
19898 fail_update:
19899 - probe_kernel_write((void *)ip, &old_code[0], 1);
19900 + probe_kernel_write((void *)ktla_ktva(ip), &old_code[0], 1);
19901 goto out;
19902 }
19903
19904 @@ -670,6 +672,8 @@ static int ftrace_mod_jmp(unsigned long ip,
19905 {
19906 unsigned char code[MCOUNT_INSN_SIZE];
19907
19908 + ip = ktla_ktva(ip);
19909 +
19910 if (probe_kernel_read(code, (void *)ip, MCOUNT_INSN_SIZE))
19911 return -EFAULT;
19912
19913 diff --git a/arch/x86/kernel/head32.c b/arch/x86/kernel/head32.c
19914 index c18f59d..9c0c9f6 100644
19915 --- a/arch/x86/kernel/head32.c
19916 +++ b/arch/x86/kernel/head32.c
19917 @@ -18,6 +18,7 @@
19918 #include <asm/io_apic.h>
19919 #include <asm/bios_ebda.h>
19920 #include <asm/tlbflush.h>
19921 +#include <asm/boot.h>
19922
19923 static void __init i386_default_early_setup(void)
19924 {
19925 @@ -30,8 +31,7 @@ static void __init i386_default_early_setup(void)
19926
19927 void __init i386_start_kernel(void)
19928 {
19929 - memblock_reserve(__pa_symbol(&_text),
19930 - __pa_symbol(&__bss_stop) - __pa_symbol(&_text));
19931 + memblock_reserve(LOAD_PHYSICAL_ADDR, __pa_symbol(&__bss_stop) - LOAD_PHYSICAL_ADDR);
19932
19933 #ifdef CONFIG_BLK_DEV_INITRD
19934 /* Reserve INITRD */
19935 diff --git a/arch/x86/kernel/head_32.S b/arch/x86/kernel/head_32.S
19936 index c8932c7..d56b622 100644
19937 --- a/arch/x86/kernel/head_32.S
19938 +++ b/arch/x86/kernel/head_32.S
19939 @@ -26,6 +26,12 @@
19940 /* Physical address */
19941 #define pa(X) ((X) - __PAGE_OFFSET)
19942
19943 +#ifdef CONFIG_PAX_KERNEXEC
19944 +#define ta(X) (X)
19945 +#else
19946 +#define ta(X) ((X) - __PAGE_OFFSET)
19947 +#endif
19948 +
19949 /*
19950 * References to members of the new_cpu_data structure.
19951 */
19952 @@ -55,11 +61,7 @@
19953 * and small than max_low_pfn, otherwise will waste some page table entries
19954 */
19955
19956 -#if PTRS_PER_PMD > 1
19957 -#define PAGE_TABLE_SIZE(pages) (((pages) / PTRS_PER_PMD) + PTRS_PER_PGD)
19958 -#else
19959 -#define PAGE_TABLE_SIZE(pages) ((pages) / PTRS_PER_PGD)
19960 -#endif
19961 +#define PAGE_TABLE_SIZE(pages) ((pages) / PTRS_PER_PTE)
19962
19963 /* Number of possible pages in the lowmem region */
19964 LOWMEM_PAGES = (((1<<32) - __PAGE_OFFSET) >> PAGE_SHIFT)
19965 @@ -78,6 +80,12 @@ INIT_MAP_SIZE = PAGE_TABLE_SIZE(KERNEL_PAGES) * PAGE_SIZE
19966 RESERVE_BRK(pagetables, INIT_MAP_SIZE)
19967
19968 /*
19969 + * Real beginning of normal "text" segment
19970 + */
19971 +ENTRY(stext)
19972 +ENTRY(_stext)
19973 +
19974 +/*
19975 * 32-bit kernel entrypoint; only used by the boot CPU. On entry,
19976 * %esi points to the real-mode code as a 32-bit pointer.
19977 * CS and DS must be 4 GB flat segments, but we don't depend on
19978 @@ -85,6 +93,13 @@ RESERVE_BRK(pagetables, INIT_MAP_SIZE)
19979 * can.
19980 */
19981 __HEAD
19982 +
19983 +#ifdef CONFIG_PAX_KERNEXEC
19984 + jmp startup_32
19985 +/* PaX: fill first page in .text with int3 to catch NULL derefs in kernel mode */
19986 +.fill PAGE_SIZE-5,1,0xcc
19987 +#endif
19988 +
19989 ENTRY(startup_32)
19990 movl pa(stack_start),%ecx
19991
19992 @@ -106,6 +121,59 @@ ENTRY(startup_32)
19993 2:
19994 leal -__PAGE_OFFSET(%ecx),%esp
19995
19996 +#ifdef CONFIG_SMP
19997 + movl $pa(cpu_gdt_table),%edi
19998 + movl $__per_cpu_load,%eax
19999 + movw %ax,GDT_ENTRY_PERCPU * 8 + 2(%edi)
20000 + rorl $16,%eax
20001 + movb %al,GDT_ENTRY_PERCPU * 8 + 4(%edi)
20002 + movb %ah,GDT_ENTRY_PERCPU * 8 + 7(%edi)
20003 + movl $__per_cpu_end - 1,%eax
20004 + subl $__per_cpu_start,%eax
20005 + movw %ax,GDT_ENTRY_PERCPU * 8 + 0(%edi)
20006 +#endif
20007 +
20008 +#ifdef CONFIG_PAX_MEMORY_UDEREF
20009 + movl $NR_CPUS,%ecx
20010 + movl $pa(cpu_gdt_table),%edi
20011 +1:
20012 + movl $((((__PAGE_OFFSET-1) & 0xf0000000) >> 12) | 0x00c09700),GDT_ENTRY_KERNEL_DS * 8 + 4(%edi)
20013 + movl $((((__PAGE_OFFSET-1) & 0xf0000000) >> 12) | 0x00c0fb00),GDT_ENTRY_DEFAULT_USER_CS * 8 + 4(%edi)
20014 + movl $((((__PAGE_OFFSET-1) & 0xf0000000) >> 12) | 0x00c0f300),GDT_ENTRY_DEFAULT_USER_DS * 8 + 4(%edi)
20015 + addl $PAGE_SIZE_asm,%edi
20016 + loop 1b
20017 +#endif
20018 +
20019 +#ifdef CONFIG_PAX_KERNEXEC
20020 + movl $pa(boot_gdt),%edi
20021 + movl $__LOAD_PHYSICAL_ADDR,%eax
20022 + movw %ax,GDT_ENTRY_BOOT_CS * 8 + 2(%edi)
20023 + rorl $16,%eax
20024 + movb %al,GDT_ENTRY_BOOT_CS * 8 + 4(%edi)
20025 + movb %ah,GDT_ENTRY_BOOT_CS * 8 + 7(%edi)
20026 + rorl $16,%eax
20027 +
20028 + ljmp $(__BOOT_CS),$1f
20029 +1:
20030 +
20031 + movl $NR_CPUS,%ecx
20032 + movl $pa(cpu_gdt_table),%edi
20033 + addl $__PAGE_OFFSET,%eax
20034 +1:
20035 + movb $0xc0,GDT_ENTRY_KERNEL_CS * 8 + 6(%edi)
20036 + movb $0xc0,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 6(%edi)
20037 + movw %ax,GDT_ENTRY_KERNEL_CS * 8 + 2(%edi)
20038 + movw %ax,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 2(%edi)
20039 + rorl $16,%eax
20040 + movb %al,GDT_ENTRY_KERNEL_CS * 8 + 4(%edi)
20041 + movb %al,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 4(%edi)
20042 + movb %ah,GDT_ENTRY_KERNEL_CS * 8 + 7(%edi)
20043 + movb %ah,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 7(%edi)
20044 + rorl $16,%eax
20045 + addl $PAGE_SIZE_asm,%edi
20046 + loop 1b
20047 +#endif
20048 +
20049 /*
20050 * Clear BSS first so that there are no surprises...
20051 */
20052 @@ -196,8 +264,11 @@ ENTRY(startup_32)
20053 movl %eax, pa(max_pfn_mapped)
20054
20055 /* Do early initialization of the fixmap area */
20056 - movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,%eax
20057 - movl %eax,pa(initial_pg_pmd+0x1000*KPMDS-8)
20058 +#ifdef CONFIG_COMPAT_VDSO
20059 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR+_PAGE_USER,pa(initial_pg_pmd+0x1000*KPMDS-8)
20060 +#else
20061 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,pa(initial_pg_pmd+0x1000*KPMDS-8)
20062 +#endif
20063 #else /* Not PAE */
20064
20065 page_pde_offset = (__PAGE_OFFSET >> 20);
20066 @@ -227,8 +298,11 @@ page_pde_offset = (__PAGE_OFFSET >> 20);
20067 movl %eax, pa(max_pfn_mapped)
20068
20069 /* Do early initialization of the fixmap area */
20070 - movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,%eax
20071 - movl %eax,pa(initial_page_table+0xffc)
20072 +#ifdef CONFIG_COMPAT_VDSO
20073 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR+_PAGE_USER,pa(initial_page_table+0xffc)
20074 +#else
20075 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,pa(initial_page_table+0xffc)
20076 +#endif
20077 #endif
20078
20079 #ifdef CONFIG_PARAVIRT
20080 @@ -242,9 +316,7 @@ page_pde_offset = (__PAGE_OFFSET >> 20);
20081 cmpl $num_subarch_entries, %eax
20082 jae bad_subarch
20083
20084 - movl pa(subarch_entries)(,%eax,4), %eax
20085 - subl $__PAGE_OFFSET, %eax
20086 - jmp *%eax
20087 + jmp *pa(subarch_entries)(,%eax,4)
20088
20089 bad_subarch:
20090 WEAK(lguest_entry)
20091 @@ -256,10 +328,10 @@ WEAK(xen_entry)
20092 __INITDATA
20093
20094 subarch_entries:
20095 - .long default_entry /* normal x86/PC */
20096 - .long lguest_entry /* lguest hypervisor */
20097 - .long xen_entry /* Xen hypervisor */
20098 - .long default_entry /* Moorestown MID */
20099 + .long ta(default_entry) /* normal x86/PC */
20100 + .long ta(lguest_entry) /* lguest hypervisor */
20101 + .long ta(xen_entry) /* Xen hypervisor */
20102 + .long ta(default_entry) /* Moorestown MID */
20103 num_subarch_entries = (. - subarch_entries) / 4
20104 .previous
20105 #else
20106 @@ -335,6 +407,7 @@ default_entry:
20107 movl pa(mmu_cr4_features),%eax
20108 movl %eax,%cr4
20109
20110 +#ifdef CONFIG_X86_PAE
20111 testb $X86_CR4_PAE, %al # check if PAE is enabled
20112 jz 6f
20113
20114 @@ -363,6 +436,9 @@ default_entry:
20115 /* Make changes effective */
20116 wrmsr
20117
20118 + btsl $_PAGE_BIT_NX-32,pa(__supported_pte_mask+4)
20119 +#endif
20120 +
20121 6:
20122
20123 /*
20124 @@ -460,14 +536,20 @@ is386: movl $2,%ecx # set MP
20125 1: movl $(__KERNEL_DS),%eax # reload all the segment registers
20126 movl %eax,%ss # after changing gdt.
20127
20128 - movl $(__USER_DS),%eax # DS/ES contains default USER segment
20129 +# movl $(__KERNEL_DS),%eax # DS/ES contains default KERNEL segment
20130 movl %eax,%ds
20131 movl %eax,%es
20132
20133 movl $(__KERNEL_PERCPU), %eax
20134 movl %eax,%fs # set this cpu's percpu
20135
20136 +#ifdef CONFIG_CC_STACKPROTECTOR
20137 movl $(__KERNEL_STACK_CANARY),%eax
20138 +#elif defined(CONFIG_PAX_MEMORY_UDEREF)
20139 + movl $(__USER_DS),%eax
20140 +#else
20141 + xorl %eax,%eax
20142 +#endif
20143 movl %eax,%gs
20144
20145 xorl %eax,%eax # Clear LDT
20146 @@ -544,8 +626,11 @@ setup_once:
20147 * relocation. Manually set base address in stack canary
20148 * segment descriptor.
20149 */
20150 - movl $gdt_page,%eax
20151 + movl $cpu_gdt_table,%eax
20152 movl $stack_canary,%ecx
20153 +#ifdef CONFIG_SMP
20154 + addl $__per_cpu_load,%ecx
20155 +#endif
20156 movw %cx, 8 * GDT_ENTRY_STACK_CANARY + 2(%eax)
20157 shrl $16, %ecx
20158 movb %cl, 8 * GDT_ENTRY_STACK_CANARY + 4(%eax)
20159 @@ -576,7 +661,7 @@ ENDPROC(early_idt_handlers)
20160 /* This is global to keep gas from relaxing the jumps */
20161 ENTRY(early_idt_handler)
20162 cld
20163 - cmpl $2,%ss:early_recursion_flag
20164 + cmpl $1,%ss:early_recursion_flag
20165 je hlt_loop
20166 incl %ss:early_recursion_flag
20167
20168 @@ -614,8 +699,8 @@ ENTRY(early_idt_handler)
20169 pushl (20+6*4)(%esp) /* trapno */
20170 pushl $fault_msg
20171 call printk
20172 -#endif
20173 call dump_stack
20174 +#endif
20175 hlt_loop:
20176 hlt
20177 jmp hlt_loop
20178 @@ -634,8 +719,11 @@ ENDPROC(early_idt_handler)
20179 /* This is the default interrupt "handler" :-) */
20180 ALIGN
20181 ignore_int:
20182 - cld
20183 #ifdef CONFIG_PRINTK
20184 + cmpl $2,%ss:early_recursion_flag
20185 + je hlt_loop
20186 + incl %ss:early_recursion_flag
20187 + cld
20188 pushl %eax
20189 pushl %ecx
20190 pushl %edx
20191 @@ -644,9 +732,6 @@ ignore_int:
20192 movl $(__KERNEL_DS),%eax
20193 movl %eax,%ds
20194 movl %eax,%es
20195 - cmpl $2,early_recursion_flag
20196 - je hlt_loop
20197 - incl early_recursion_flag
20198 pushl 16(%esp)
20199 pushl 24(%esp)
20200 pushl 32(%esp)
20201 @@ -680,29 +765,43 @@ ENTRY(setup_once_ref)
20202 /*
20203 * BSS section
20204 */
20205 -__PAGE_ALIGNED_BSS
20206 - .align PAGE_SIZE
20207 #ifdef CONFIG_X86_PAE
20208 +.section .initial_pg_pmd,"a",@progbits
20209 initial_pg_pmd:
20210 .fill 1024*KPMDS,4,0
20211 #else
20212 +.section .initial_page_table,"a",@progbits
20213 ENTRY(initial_page_table)
20214 .fill 1024,4,0
20215 #endif
20216 +.section .initial_pg_fixmap,"a",@progbits
20217 initial_pg_fixmap:
20218 .fill 1024,4,0
20219 +.section .empty_zero_page,"a",@progbits
20220 ENTRY(empty_zero_page)
20221 .fill 4096,1,0
20222 +.section .swapper_pg_dir,"a",@progbits
20223 ENTRY(swapper_pg_dir)
20224 +#ifdef CONFIG_X86_PAE
20225 + .fill 4,8,0
20226 +#else
20227 .fill 1024,4,0
20228 +#endif
20229 +
20230 +/*
20231 + * The IDT has to be page-aligned to simplify the Pentium
20232 + * F0 0F bug workaround.. We have a special link segment
20233 + * for this.
20234 + */
20235 +.section .idt,"a",@progbits
20236 +ENTRY(idt_table)
20237 + .fill 256,8,0
20238
20239 /*
20240 * This starts the data section.
20241 */
20242 #ifdef CONFIG_X86_PAE
20243 -__PAGE_ALIGNED_DATA
20244 - /* Page-aligned for the benefit of paravirt? */
20245 - .align PAGE_SIZE
20246 +.section .initial_page_table,"a",@progbits
20247 ENTRY(initial_page_table)
20248 .long pa(initial_pg_pmd+PGD_IDENT_ATTR),0 /* low identity map */
20249 # if KPMDS == 3
20250 @@ -721,12 +820,20 @@ ENTRY(initial_page_table)
20251 # error "Kernel PMDs should be 1, 2 or 3"
20252 # endif
20253 .align PAGE_SIZE /* needs to be page-sized too */
20254 +
20255 +#ifdef CONFIG_PAX_PER_CPU_PGD
20256 +ENTRY(cpu_pgd)
20257 + .rept NR_CPUS
20258 + .fill 4,8,0
20259 + .endr
20260 +#endif
20261 +
20262 #endif
20263
20264 .data
20265 .balign 4
20266 ENTRY(stack_start)
20267 - .long init_thread_union+THREAD_SIZE
20268 + .long init_thread_union+THREAD_SIZE-8
20269
20270 __INITRODATA
20271 int_msg:
20272 @@ -754,7 +861,7 @@ fault_msg:
20273 * segment size, and 32-bit linear address value:
20274 */
20275
20276 - .data
20277 +.section .rodata,"a",@progbits
20278 .globl boot_gdt_descr
20279 .globl idt_descr
20280
20281 @@ -763,7 +870,7 @@ fault_msg:
20282 .word 0 # 32 bit align gdt_desc.address
20283 boot_gdt_descr:
20284 .word __BOOT_DS+7
20285 - .long boot_gdt - __PAGE_OFFSET
20286 + .long pa(boot_gdt)
20287
20288 .word 0 # 32-bit align idt_desc.address
20289 idt_descr:
20290 @@ -774,7 +881,7 @@ idt_descr:
20291 .word 0 # 32 bit align gdt_desc.address
20292 ENTRY(early_gdt_descr)
20293 .word GDT_ENTRIES*8-1
20294 - .long gdt_page /* Overwritten for secondary CPUs */
20295 + .long cpu_gdt_table /* Overwritten for secondary CPUs */
20296
20297 /*
20298 * The boot_gdt must mirror the equivalent in setup.S and is
20299 @@ -783,5 +890,65 @@ ENTRY(early_gdt_descr)
20300 .align L1_CACHE_BYTES
20301 ENTRY(boot_gdt)
20302 .fill GDT_ENTRY_BOOT_CS,8,0
20303 - .quad 0x00cf9a000000ffff /* kernel 4GB code at 0x00000000 */
20304 - .quad 0x00cf92000000ffff /* kernel 4GB data at 0x00000000 */
20305 + .quad 0x00cf9b000000ffff /* kernel 4GB code at 0x00000000 */
20306 + .quad 0x00cf93000000ffff /* kernel 4GB data at 0x00000000 */
20307 +
20308 + .align PAGE_SIZE_asm
20309 +ENTRY(cpu_gdt_table)
20310 + .rept NR_CPUS
20311 + .quad 0x0000000000000000 /* NULL descriptor */
20312 + .quad 0x0000000000000000 /* 0x0b reserved */
20313 + .quad 0x0000000000000000 /* 0x13 reserved */
20314 + .quad 0x0000000000000000 /* 0x1b reserved */
20315 +
20316 +#ifdef CONFIG_PAX_KERNEXEC
20317 + .quad 0x00cf9b000000ffff /* 0x20 alternate kernel 4GB code at 0x00000000 */
20318 +#else
20319 + .quad 0x0000000000000000 /* 0x20 unused */
20320 +#endif
20321 +
20322 + .quad 0x0000000000000000 /* 0x28 unused */
20323 + .quad 0x0000000000000000 /* 0x33 TLS entry 1 */
20324 + .quad 0x0000000000000000 /* 0x3b TLS entry 2 */
20325 + .quad 0x0000000000000000 /* 0x43 TLS entry 3 */
20326 + .quad 0x0000000000000000 /* 0x4b reserved */
20327 + .quad 0x0000000000000000 /* 0x53 reserved */
20328 + .quad 0x0000000000000000 /* 0x5b reserved */
20329 +
20330 + .quad 0x00cf9b000000ffff /* 0x60 kernel 4GB code at 0x00000000 */
20331 + .quad 0x00cf93000000ffff /* 0x68 kernel 4GB data at 0x00000000 */
20332 + .quad 0x00cffb000000ffff /* 0x73 user 4GB code at 0x00000000 */
20333 + .quad 0x00cff3000000ffff /* 0x7b user 4GB data at 0x00000000 */
20334 +
20335 + .quad 0x0000000000000000 /* 0x80 TSS descriptor */
20336 + .quad 0x0000000000000000 /* 0x88 LDT descriptor */
20337 +
20338 + /*
20339 + * Segments used for calling PnP BIOS have byte granularity.
20340 + * The code segments and data segments have fixed 64k limits,
20341 + * the transfer segment sizes are set at run time.
20342 + */
20343 + .quad 0x00409b000000ffff /* 0x90 32-bit code */
20344 + .quad 0x00009b000000ffff /* 0x98 16-bit code */
20345 + .quad 0x000093000000ffff /* 0xa0 16-bit data */
20346 + .quad 0x0000930000000000 /* 0xa8 16-bit data */
20347 + .quad 0x0000930000000000 /* 0xb0 16-bit data */
20348 +
20349 + /*
20350 + * The APM segments have byte granularity and their bases
20351 + * are set at run time. All have 64k limits.
20352 + */
20353 + .quad 0x00409b000000ffff /* 0xb8 APM CS code */
20354 + .quad 0x00009b000000ffff /* 0xc0 APM CS 16 code (16 bit) */
20355 + .quad 0x004093000000ffff /* 0xc8 APM DS data */
20356 +
20357 + .quad 0x00c0930000000000 /* 0xd0 - ESPFIX SS */
20358 + .quad 0x0040930000000000 /* 0xd8 - PERCPU */
20359 + .quad 0x0040910000000017 /* 0xe0 - STACK_CANARY */
20360 + .quad 0x0000000000000000 /* 0xe8 - PCIBIOS_CS */
20361 + .quad 0x0000000000000000 /* 0xf0 - PCIBIOS_DS */
20362 + .quad 0x0000000000000000 /* 0xf8 - GDT entry 31: double-fault TSS */
20363 +
20364 + /* Be sure this is zeroed to avoid false validations in Xen */
20365 + .fill PAGE_SIZE_asm - GDT_SIZE,1,0
20366 + .endr
20367 diff --git a/arch/x86/kernel/head_64.S b/arch/x86/kernel/head_64.S
20368 index 980053c..74d3b44 100644
20369 --- a/arch/x86/kernel/head_64.S
20370 +++ b/arch/x86/kernel/head_64.S
20371 @@ -20,6 +20,8 @@
20372 #include <asm/processor-flags.h>
20373 #include <asm/percpu.h>
20374 #include <asm/nops.h>
20375 +#include <asm/cpufeature.h>
20376 +#include <asm/alternative-asm.h>
20377
20378 #ifdef CONFIG_PARAVIRT
20379 #include <asm/asm-offsets.h>
20380 @@ -41,6 +43,12 @@ L4_PAGE_OFFSET = pgd_index(__PAGE_OFFSET)
20381 L3_PAGE_OFFSET = pud_index(__PAGE_OFFSET)
20382 L4_START_KERNEL = pgd_index(__START_KERNEL_map)
20383 L3_START_KERNEL = pud_index(__START_KERNEL_map)
20384 +L4_VMALLOC_START = pgd_index(VMALLOC_START)
20385 +L3_VMALLOC_START = pud_index(VMALLOC_START)
20386 +L4_VMALLOC_END = pgd_index(VMALLOC_END)
20387 +L3_VMALLOC_END = pud_index(VMALLOC_END)
20388 +L4_VMEMMAP_START = pgd_index(VMEMMAP_START)
20389 +L3_VMEMMAP_START = pud_index(VMEMMAP_START)
20390
20391 .text
20392 __HEAD
20393 @@ -88,35 +96,23 @@ startup_64:
20394 */
20395 addq %rbp, init_level4_pgt + 0(%rip)
20396 addq %rbp, init_level4_pgt + (L4_PAGE_OFFSET*8)(%rip)
20397 + addq %rbp, init_level4_pgt + (L4_VMALLOC_START*8)(%rip)
20398 + addq %rbp, init_level4_pgt + (L4_VMALLOC_END*8)(%rip)
20399 + addq %rbp, init_level4_pgt + (L4_VMEMMAP_START*8)(%rip)
20400 addq %rbp, init_level4_pgt + (L4_START_KERNEL*8)(%rip)
20401
20402 addq %rbp, level3_ident_pgt + 0(%rip)
20403 +#ifndef CONFIG_XEN
20404 + addq %rbp, level3_ident_pgt + 8(%rip)
20405 +#endif
20406
20407 - addq %rbp, level3_kernel_pgt + (510*8)(%rip)
20408 - addq %rbp, level3_kernel_pgt + (511*8)(%rip)
20409 + addq %rbp, level3_vmemmap_pgt + (L3_VMEMMAP_START*8)(%rip)
20410 +
20411 + addq %rbp, level3_kernel_pgt + (L3_START_KERNEL*8)(%rip)
20412 + addq %rbp, level3_kernel_pgt + (L3_START_KERNEL*8+8)(%rip)
20413
20414 addq %rbp, level2_fixmap_pgt + (506*8)(%rip)
20415 -
20416 - /* Add an Identity mapping if I am above 1G */
20417 - leaq _text(%rip), %rdi
20418 - andq $PMD_PAGE_MASK, %rdi
20419 -
20420 - movq %rdi, %rax
20421 - shrq $PUD_SHIFT, %rax
20422 - andq $(PTRS_PER_PUD - 1), %rax
20423 - jz ident_complete
20424 -
20425 - leaq (level2_spare_pgt - __START_KERNEL_map + _KERNPG_TABLE)(%rbp), %rdx
20426 - leaq level3_ident_pgt(%rip), %rbx
20427 - movq %rdx, 0(%rbx, %rax, 8)
20428 -
20429 - movq %rdi, %rax
20430 - shrq $PMD_SHIFT, %rax
20431 - andq $(PTRS_PER_PMD - 1), %rax
20432 - leaq __PAGE_KERNEL_IDENT_LARGE_EXEC(%rdi), %rdx
20433 - leaq level2_spare_pgt(%rip), %rbx
20434 - movq %rdx, 0(%rbx, %rax, 8)
20435 -ident_complete:
20436 + addq %rbp, level2_fixmap_pgt + (507*8)(%rip)
20437
20438 /*
20439 * Fixup the kernel text+data virtual addresses. Note that
20440 @@ -159,8 +155,8 @@ ENTRY(secondary_startup_64)
20441 * after the boot processor executes this code.
20442 */
20443
20444 - /* Enable PAE mode and PGE */
20445 - movl $(X86_CR4_PAE | X86_CR4_PGE), %eax
20446 + /* Enable PAE mode and PSE/PGE */
20447 + movl $(X86_CR4_PSE | X86_CR4_PAE | X86_CR4_PGE), %eax
20448 movq %rax, %cr4
20449
20450 /* Setup early boot stage 4 level pagetables. */
20451 @@ -182,9 +178,17 @@ ENTRY(secondary_startup_64)
20452 movl $MSR_EFER, %ecx
20453 rdmsr
20454 btsl $_EFER_SCE, %eax /* Enable System Call */
20455 - btl $20,%edi /* No Execute supported? */
20456 + btl $(X86_FEATURE_NX & 31),%edi /* No Execute supported? */
20457 jnc 1f
20458 btsl $_EFER_NX, %eax
20459 + leaq init_level4_pgt(%rip), %rdi
20460 +#ifndef CONFIG_EFI
20461 + btsq $_PAGE_BIT_NX, 8*L4_PAGE_OFFSET(%rdi)
20462 +#endif
20463 + btsq $_PAGE_BIT_NX, 8*L4_VMALLOC_START(%rdi)
20464 + btsq $_PAGE_BIT_NX, 8*L4_VMALLOC_END(%rdi)
20465 + btsq $_PAGE_BIT_NX, 8*L4_VMEMMAP_START(%rdi)
20466 + btsq $_PAGE_BIT_NX, __supported_pte_mask(%rip)
20467 1: wrmsr /* Make changes effective */
20468
20469 /* Setup cr0 */
20470 @@ -246,6 +250,7 @@ ENTRY(secondary_startup_64)
20471 * jump. In addition we need to ensure %cs is set so we make this
20472 * a far return.
20473 */
20474 + pax_set_fptr_mask
20475 movq initial_code(%rip),%rax
20476 pushq $0 # fake return address to stop unwinder
20477 pushq $__KERNEL_CS # set correct cs
20478 @@ -284,7 +289,7 @@ ENDPROC(start_cpu0)
20479 bad_address:
20480 jmp bad_address
20481
20482 - .section ".init.text","ax"
20483 + __INIT
20484 .globl early_idt_handlers
20485 early_idt_handlers:
20486 # 104(%rsp) %rflags
20487 @@ -343,7 +348,7 @@ ENTRY(early_idt_handler)
20488 call dump_stack
20489 #ifdef CONFIG_KALLSYMS
20490 leaq early_idt_ripmsg(%rip),%rdi
20491 - movq 40(%rsp),%rsi # %rip again
20492 + movq 88(%rsp),%rsi # %rip again
20493 call __print_symbol
20494 #endif
20495 #endif /* EARLY_PRINTK */
20496 @@ -363,11 +368,15 @@ ENTRY(early_idt_handler)
20497 addq $16,%rsp # drop vector number and error code
20498 decl early_recursion_flag(%rip)
20499 INTERRUPT_RETURN
20500 + .previous
20501
20502 + __INITDATA
20503 .balign 4
20504 early_recursion_flag:
20505 .long 0
20506 + .previous
20507
20508 + .section .rodata,"a",@progbits
20509 #ifdef CONFIG_EARLY_PRINTK
20510 early_idt_msg:
20511 .asciz "PANIC: early exception %02lx rip %lx:%lx error %lx cr2 %lx\n"
20512 @@ -376,6 +385,7 @@ early_idt_ripmsg:
20513 #endif /* CONFIG_EARLY_PRINTK */
20514 .previous
20515
20516 + .section .rodata,"a",@progbits
20517 #define NEXT_PAGE(name) \
20518 .balign PAGE_SIZE; \
20519 ENTRY(name)
20520 @@ -388,7 +398,6 @@ ENTRY(name)
20521 i = i + 1 ; \
20522 .endr
20523
20524 - .data
20525 /*
20526 * This default setting generates an ident mapping at address 0x100000
20527 * and a mapping for the kernel that precisely maps virtual address
20528 @@ -399,13 +408,41 @@ NEXT_PAGE(init_level4_pgt)
20529 .quad level3_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE
20530 .org init_level4_pgt + L4_PAGE_OFFSET*8, 0
20531 .quad level3_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE
20532 + .org init_level4_pgt + L4_VMALLOC_START*8, 0
20533 + .quad level3_vmalloc_start_pgt - __START_KERNEL_map + _KERNPG_TABLE
20534 + .org init_level4_pgt + L4_VMALLOC_END*8, 0
20535 + .quad level3_vmalloc_end_pgt - __START_KERNEL_map + _KERNPG_TABLE
20536 + .org init_level4_pgt + L4_VMEMMAP_START*8, 0
20537 + .quad level3_vmemmap_pgt - __START_KERNEL_map + _KERNPG_TABLE
20538 .org init_level4_pgt + L4_START_KERNEL*8, 0
20539 /* (2^48-(2*1024*1024*1024))/(2^39) = 511 */
20540 .quad level3_kernel_pgt - __START_KERNEL_map + _PAGE_TABLE
20541
20542 +#ifdef CONFIG_PAX_PER_CPU_PGD
20543 +NEXT_PAGE(cpu_pgd)
20544 + .rept NR_CPUS
20545 + .fill 512,8,0
20546 + .endr
20547 +#endif
20548 +
20549 NEXT_PAGE(level3_ident_pgt)
20550 .quad level2_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE
20551 +#ifdef CONFIG_XEN
20552 .fill 511,8,0
20553 +#else
20554 + .quad level2_ident_pgt + PAGE_SIZE - __START_KERNEL_map + _KERNPG_TABLE
20555 + .fill 510,8,0
20556 +#endif
20557 +
20558 +NEXT_PAGE(level3_vmalloc_start_pgt)
20559 + .fill 512,8,0
20560 +
20561 +NEXT_PAGE(level3_vmalloc_end_pgt)
20562 + .fill 512,8,0
20563 +
20564 +NEXT_PAGE(level3_vmemmap_pgt)
20565 + .fill L3_VMEMMAP_START,8,0
20566 + .quad level2_vmemmap_pgt - __START_KERNEL_map + _KERNPG_TABLE
20567
20568 NEXT_PAGE(level3_kernel_pgt)
20569 .fill L3_START_KERNEL,8,0
20570 @@ -413,20 +450,23 @@ NEXT_PAGE(level3_kernel_pgt)
20571 .quad level2_kernel_pgt - __START_KERNEL_map + _KERNPG_TABLE
20572 .quad level2_fixmap_pgt - __START_KERNEL_map + _PAGE_TABLE
20573
20574 +NEXT_PAGE(level2_vmemmap_pgt)
20575 + .fill 512,8,0
20576 +
20577 NEXT_PAGE(level2_fixmap_pgt)
20578 - .fill 506,8,0
20579 - .quad level1_fixmap_pgt - __START_KERNEL_map + _PAGE_TABLE
20580 - /* 8MB reserved for vsyscalls + a 2MB hole = 4 + 1 entries */
20581 - .fill 5,8,0
20582 + .fill 507,8,0
20583 + .quad level1_vsyscall_pgt - __START_KERNEL_map + _PAGE_TABLE
20584 + /* 6MB reserved for vsyscalls + a 2MB hole = 3 + 1 entries */
20585 + .fill 4,8,0
20586
20587 -NEXT_PAGE(level1_fixmap_pgt)
20588 +NEXT_PAGE(level1_vsyscall_pgt)
20589 .fill 512,8,0
20590
20591 -NEXT_PAGE(level2_ident_pgt)
20592 - /* Since I easily can, map the first 1G.
20593 + /* Since I easily can, map the first 2G.
20594 * Don't set NX because code runs from these pages.
20595 */
20596 - PMDS(0, __PAGE_KERNEL_IDENT_LARGE_EXEC, PTRS_PER_PMD)
20597 +NEXT_PAGE(level2_ident_pgt)
20598 + PMDS(0, __PAGE_KERNEL_IDENT_LARGE_EXEC, 2*PTRS_PER_PMD)
20599
20600 NEXT_PAGE(level2_kernel_pgt)
20601 /*
20602 @@ -439,37 +479,59 @@ NEXT_PAGE(level2_kernel_pgt)
20603 * If you want to increase this then increase MODULES_VADDR
20604 * too.)
20605 */
20606 - PMDS(0, __PAGE_KERNEL_LARGE_EXEC,
20607 - KERNEL_IMAGE_SIZE/PMD_SIZE)
20608 -
20609 -NEXT_PAGE(level2_spare_pgt)
20610 - .fill 512, 8, 0
20611 + PMDS(0, __PAGE_KERNEL_LARGE_EXEC, KERNEL_IMAGE_SIZE/PMD_SIZE)
20612
20613 #undef PMDS
20614 #undef NEXT_PAGE
20615
20616 - .data
20617 + .align PAGE_SIZE
20618 +ENTRY(cpu_gdt_table)
20619 + .rept NR_CPUS
20620 + .quad 0x0000000000000000 /* NULL descriptor */
20621 + .quad 0x00cf9b000000ffff /* __KERNEL32_CS */
20622 + .quad 0x00af9b000000ffff /* __KERNEL_CS */
20623 + .quad 0x00cf93000000ffff /* __KERNEL_DS */
20624 + .quad 0x00cffb000000ffff /* __USER32_CS */
20625 + .quad 0x00cff3000000ffff /* __USER_DS, __USER32_DS */
20626 + .quad 0x00affb000000ffff /* __USER_CS */
20627 +
20628 +#ifdef CONFIG_PAX_KERNEXEC
20629 + .quad 0x00af9b000000ffff /* __KERNEXEC_KERNEL_CS */
20630 +#else
20631 + .quad 0x0 /* unused */
20632 +#endif
20633 +
20634 + .quad 0,0 /* TSS */
20635 + .quad 0,0 /* LDT */
20636 + .quad 0,0,0 /* three TLS descriptors */
20637 + .quad 0x0000f40000000000 /* node/CPU stored in limit */
20638 + /* asm/segment.h:GDT_ENTRIES must match this */
20639 +
20640 + /* zero the remaining page */
20641 + .fill PAGE_SIZE / 8 - GDT_ENTRIES,8,0
20642 + .endr
20643 +
20644 .align 16
20645 .globl early_gdt_descr
20646 early_gdt_descr:
20647 .word GDT_ENTRIES*8-1
20648 early_gdt_descr_base:
20649 - .quad INIT_PER_CPU_VAR(gdt_page)
20650 + .quad cpu_gdt_table
20651
20652 ENTRY(phys_base)
20653 /* This must match the first entry in level2_kernel_pgt */
20654 .quad 0x0000000000000000
20655
20656 #include "../../x86/xen/xen-head.S"
20657 -
20658 - .section .bss, "aw", @nobits
20659 +
20660 + .section .rodata,"a",@progbits
20661 .align L1_CACHE_BYTES
20662 ENTRY(idt_table)
20663 - .skip IDT_ENTRIES * 16
20664 + .fill 512,8,0
20665
20666 .align L1_CACHE_BYTES
20667 ENTRY(nmi_idt_table)
20668 - .skip IDT_ENTRIES * 16
20669 + .fill 512,8,0
20670
20671 __PAGE_ALIGNED_BSS
20672 .align PAGE_SIZE
20673 diff --git a/arch/x86/kernel/i386_ksyms_32.c b/arch/x86/kernel/i386_ksyms_32.c
20674 index 9c3bd4a..e1d9b35 100644
20675 --- a/arch/x86/kernel/i386_ksyms_32.c
20676 +++ b/arch/x86/kernel/i386_ksyms_32.c
20677 @@ -20,8 +20,12 @@ extern void cmpxchg8b_emu(void);
20678 EXPORT_SYMBOL(cmpxchg8b_emu);
20679 #endif
20680
20681 +EXPORT_SYMBOL_GPL(cpu_gdt_table);
20682 +
20683 /* Networking helper routines. */
20684 EXPORT_SYMBOL(csum_partial_copy_generic);
20685 +EXPORT_SYMBOL(csum_partial_copy_generic_to_user);
20686 +EXPORT_SYMBOL(csum_partial_copy_generic_from_user);
20687
20688 EXPORT_SYMBOL(__get_user_1);
20689 EXPORT_SYMBOL(__get_user_2);
20690 @@ -36,3 +40,7 @@ EXPORT_SYMBOL(strstr);
20691
20692 EXPORT_SYMBOL(csum_partial);
20693 EXPORT_SYMBOL(empty_zero_page);
20694 +
20695 +#ifdef CONFIG_PAX_KERNEXEC
20696 +EXPORT_SYMBOL(__LOAD_PHYSICAL_ADDR);
20697 +#endif
20698 diff --git a/arch/x86/kernel/i387.c b/arch/x86/kernel/i387.c
20699 index 245a71d..89d9ce4 100644
20700 --- a/arch/x86/kernel/i387.c
20701 +++ b/arch/x86/kernel/i387.c
20702 @@ -55,7 +55,7 @@ static inline bool interrupted_kernel_fpu_idle(void)
20703 static inline bool interrupted_user_mode(void)
20704 {
20705 struct pt_regs *regs = get_irq_regs();
20706 - return regs && user_mode_vm(regs);
20707 + return regs && user_mode(regs);
20708 }
20709
20710 /*
20711 diff --git a/arch/x86/kernel/i8259.c b/arch/x86/kernel/i8259.c
20712 index 9a5c460..b332a4b 100644
20713 --- a/arch/x86/kernel/i8259.c
20714 +++ b/arch/x86/kernel/i8259.c
20715 @@ -209,7 +209,7 @@ spurious_8259A_irq:
20716 "spurious 8259A interrupt: IRQ%d.\n", irq);
20717 spurious_irq_mask |= irqmask;
20718 }
20719 - atomic_inc(&irq_err_count);
20720 + atomic_inc_unchecked(&irq_err_count);
20721 /*
20722 * Theoretically we do not have to handle this IRQ,
20723 * but in Linux this does not cause problems and is
20724 @@ -333,14 +333,16 @@ static void init_8259A(int auto_eoi)
20725 /* (slave's support for AEOI in flat mode is to be investigated) */
20726 outb_pic(SLAVE_ICW4_DEFAULT, PIC_SLAVE_IMR);
20727
20728 + pax_open_kernel();
20729 if (auto_eoi)
20730 /*
20731 * In AEOI mode we just have to mask the interrupt
20732 * when acking.
20733 */
20734 - i8259A_chip.irq_mask_ack = disable_8259A_irq;
20735 + *(void **)&i8259A_chip.irq_mask_ack = disable_8259A_irq;
20736 else
20737 - i8259A_chip.irq_mask_ack = mask_and_ack_8259A;
20738 + *(void **)&i8259A_chip.irq_mask_ack = mask_and_ack_8259A;
20739 + pax_close_kernel();
20740
20741 udelay(100); /* wait for 8259A to initialize */
20742
20743 diff --git a/arch/x86/kernel/io_delay.c b/arch/x86/kernel/io_delay.c
20744 index a979b5b..1d6db75 100644
20745 --- a/arch/x86/kernel/io_delay.c
20746 +++ b/arch/x86/kernel/io_delay.c
20747 @@ -58,7 +58,7 @@ static int __init dmi_io_delay_0xed_port(const struct dmi_system_id *id)
20748 * Quirk table for systems that misbehave (lock up, etc.) if port
20749 * 0x80 is used:
20750 */
20751 -static struct dmi_system_id __initdata io_delay_0xed_port_dmi_table[] = {
20752 +static const struct dmi_system_id __initconst io_delay_0xed_port_dmi_table[] = {
20753 {
20754 .callback = dmi_io_delay_0xed_port,
20755 .ident = "Compaq Presario V6000",
20756 diff --git a/arch/x86/kernel/ioport.c b/arch/x86/kernel/ioport.c
20757 index 8c96897..be66bfa 100644
20758 --- a/arch/x86/kernel/ioport.c
20759 +++ b/arch/x86/kernel/ioport.c
20760 @@ -6,6 +6,7 @@
20761 #include <linux/sched.h>
20762 #include <linux/kernel.h>
20763 #include <linux/capability.h>
20764 +#include <linux/security.h>
20765 #include <linux/errno.h>
20766 #include <linux/types.h>
20767 #include <linux/ioport.h>
20768 @@ -28,6 +29,12 @@ asmlinkage long sys_ioperm(unsigned long from, unsigned long num, int turn_on)
20769
20770 if ((from + num <= from) || (from + num > IO_BITMAP_BITS))
20771 return -EINVAL;
20772 +#ifdef CONFIG_GRKERNSEC_IO
20773 + if (turn_on && grsec_disable_privio) {
20774 + gr_handle_ioperm();
20775 + return -EPERM;
20776 + }
20777 +#endif
20778 if (turn_on && !capable(CAP_SYS_RAWIO))
20779 return -EPERM;
20780
20781 @@ -54,7 +61,7 @@ asmlinkage long sys_ioperm(unsigned long from, unsigned long num, int turn_on)
20782 * because the ->io_bitmap_max value must match the bitmap
20783 * contents:
20784 */
20785 - tss = &per_cpu(init_tss, get_cpu());
20786 + tss = init_tss + get_cpu();
20787
20788 if (turn_on)
20789 bitmap_clear(t->io_bitmap_ptr, from, num);
20790 @@ -102,6 +109,12 @@ long sys_iopl(unsigned int level, struct pt_regs *regs)
20791 return -EINVAL;
20792 /* Trying to gain more privileges? */
20793 if (level > old) {
20794 +#ifdef CONFIG_GRKERNSEC_IO
20795 + if (grsec_disable_privio) {
20796 + gr_handle_iopl();
20797 + return -EPERM;
20798 + }
20799 +#endif
20800 if (!capable(CAP_SYS_RAWIO))
20801 return -EPERM;
20802 }
20803 diff --git a/arch/x86/kernel/irq.c b/arch/x86/kernel/irq.c
20804 index e4595f1..ee3bfb8 100644
20805 --- a/arch/x86/kernel/irq.c
20806 +++ b/arch/x86/kernel/irq.c
20807 @@ -18,7 +18,7 @@
20808 #include <asm/mce.h>
20809 #include <asm/hw_irq.h>
20810
20811 -atomic_t irq_err_count;
20812 +atomic_unchecked_t irq_err_count;
20813
20814 /* Function pointer for generic interrupt vector handling */
20815 void (*x86_platform_ipi_callback)(void) = NULL;
20816 @@ -122,9 +122,9 @@ int arch_show_interrupts(struct seq_file *p, int prec)
20817 seq_printf(p, "%10u ", per_cpu(mce_poll_count, j));
20818 seq_printf(p, " Machine check polls\n");
20819 #endif
20820 - seq_printf(p, "%*s: %10u\n", prec, "ERR", atomic_read(&irq_err_count));
20821 + seq_printf(p, "%*s: %10u\n", prec, "ERR", atomic_read_unchecked(&irq_err_count));
20822 #if defined(CONFIG_X86_IO_APIC)
20823 - seq_printf(p, "%*s: %10u\n", prec, "MIS", atomic_read(&irq_mis_count));
20824 + seq_printf(p, "%*s: %10u\n", prec, "MIS", atomic_read_unchecked(&irq_mis_count));
20825 #endif
20826 return 0;
20827 }
20828 @@ -164,10 +164,10 @@ u64 arch_irq_stat_cpu(unsigned int cpu)
20829
20830 u64 arch_irq_stat(void)
20831 {
20832 - u64 sum = atomic_read(&irq_err_count);
20833 + u64 sum = atomic_read_unchecked(&irq_err_count);
20834
20835 #ifdef CONFIG_X86_IO_APIC
20836 - sum += atomic_read(&irq_mis_count);
20837 + sum += atomic_read_unchecked(&irq_mis_count);
20838 #endif
20839 return sum;
20840 }
20841 diff --git a/arch/x86/kernel/irq_32.c b/arch/x86/kernel/irq_32.c
20842 index 344faf8..355f60d 100644
20843 --- a/arch/x86/kernel/irq_32.c
20844 +++ b/arch/x86/kernel/irq_32.c
20845 @@ -39,7 +39,7 @@ static int check_stack_overflow(void)
20846 __asm__ __volatile__("andl %%esp,%0" :
20847 "=r" (sp) : "0" (THREAD_SIZE - 1));
20848
20849 - return sp < (sizeof(struct thread_info) + STACK_WARN);
20850 + return sp < STACK_WARN;
20851 }
20852
20853 static void print_stack_overflow(void)
20854 @@ -59,8 +59,8 @@ static inline void print_stack_overflow(void) { }
20855 * per-CPU IRQ handling contexts (thread information and stack)
20856 */
20857 union irq_ctx {
20858 - struct thread_info tinfo;
20859 - u32 stack[THREAD_SIZE/sizeof(u32)];
20860 + unsigned long previous_esp;
20861 + u32 stack[THREAD_SIZE/sizeof(u32)];
20862 } __attribute__((aligned(THREAD_SIZE)));
20863
20864 static DEFINE_PER_CPU(union irq_ctx *, hardirq_ctx);
20865 @@ -80,10 +80,9 @@ static void call_on_stack(void *func, void *stack)
20866 static inline int
20867 execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
20868 {
20869 - union irq_ctx *curctx, *irqctx;
20870 + union irq_ctx *irqctx;
20871 u32 *isp, arg1, arg2;
20872
20873 - curctx = (union irq_ctx *) current_thread_info();
20874 irqctx = __this_cpu_read(hardirq_ctx);
20875
20876 /*
20877 @@ -92,16 +91,16 @@ execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
20878 * handler) we can't do that and just have to keep using the
20879 * current stack (which is the irq stack already after all)
20880 */
20881 - if (unlikely(curctx == irqctx))
20882 + if (unlikely((void *)current_stack_pointer - (void *)irqctx < THREAD_SIZE))
20883 return 0;
20884
20885 /* build the stack frame on the IRQ stack */
20886 - isp = (u32 *) ((char *)irqctx + sizeof(*irqctx));
20887 - irqctx->tinfo.task = curctx->tinfo.task;
20888 - irqctx->tinfo.previous_esp = current_stack_pointer;
20889 + isp = (u32 *) ((char *)irqctx + sizeof(*irqctx) - 8);
20890 + irqctx->previous_esp = current_stack_pointer;
20891
20892 - /* Copy the preempt_count so that the [soft]irq checks work. */
20893 - irqctx->tinfo.preempt_count = curctx->tinfo.preempt_count;
20894 +#ifdef CONFIG_PAX_MEMORY_UDEREF
20895 + __set_fs(MAKE_MM_SEG(0));
20896 +#endif
20897
20898 if (unlikely(overflow))
20899 call_on_stack(print_stack_overflow, isp);
20900 @@ -113,6 +112,11 @@ execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
20901 : "0" (irq), "1" (desc), "2" (isp),
20902 "D" (desc->handle_irq)
20903 : "memory", "cc", "ecx");
20904 +
20905 +#ifdef CONFIG_PAX_MEMORY_UDEREF
20906 + __set_fs(current_thread_info()->addr_limit);
20907 +#endif
20908 +
20909 return 1;
20910 }
20911
20912 @@ -121,29 +125,14 @@ execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
20913 */
20914 void __cpuinit irq_ctx_init(int cpu)
20915 {
20916 - union irq_ctx *irqctx;
20917 -
20918 if (per_cpu(hardirq_ctx, cpu))
20919 return;
20920
20921 - irqctx = page_address(alloc_pages_node(cpu_to_node(cpu),
20922 - THREADINFO_GFP,
20923 - THREAD_SIZE_ORDER));
20924 - memset(&irqctx->tinfo, 0, sizeof(struct thread_info));
20925 - irqctx->tinfo.cpu = cpu;
20926 - irqctx->tinfo.preempt_count = HARDIRQ_OFFSET;
20927 - irqctx->tinfo.addr_limit = MAKE_MM_SEG(0);
20928 -
20929 - per_cpu(hardirq_ctx, cpu) = irqctx;
20930 -
20931 - irqctx = page_address(alloc_pages_node(cpu_to_node(cpu),
20932 - THREADINFO_GFP,
20933 - THREAD_SIZE_ORDER));
20934 - memset(&irqctx->tinfo, 0, sizeof(struct thread_info));
20935 - irqctx->tinfo.cpu = cpu;
20936 - irqctx->tinfo.addr_limit = MAKE_MM_SEG(0);
20937 -
20938 - per_cpu(softirq_ctx, cpu) = irqctx;
20939 + per_cpu(hardirq_ctx, cpu) = page_address(alloc_pages_node(cpu_to_node(cpu), THREADINFO_GFP, THREAD_SIZE_ORDER));
20940 + per_cpu(softirq_ctx, cpu) = page_address(alloc_pages_node(cpu_to_node(cpu), THREADINFO_GFP, THREAD_SIZE_ORDER));
20941 +
20942 + printk(KERN_DEBUG "CPU %u irqstacks, hard=%p soft=%p\n",
20943 + cpu, per_cpu(hardirq_ctx, cpu), per_cpu(softirq_ctx, cpu));
20944
20945 printk(KERN_DEBUG "CPU %u irqstacks, hard=%p soft=%p\n",
20946 cpu, per_cpu(hardirq_ctx, cpu), per_cpu(softirq_ctx, cpu));
20947 @@ -152,7 +141,6 @@ void __cpuinit irq_ctx_init(int cpu)
20948 asmlinkage void do_softirq(void)
20949 {
20950 unsigned long flags;
20951 - struct thread_info *curctx;
20952 union irq_ctx *irqctx;
20953 u32 *isp;
20954
20955 @@ -162,15 +150,22 @@ asmlinkage void do_softirq(void)
20956 local_irq_save(flags);
20957
20958 if (local_softirq_pending()) {
20959 - curctx = current_thread_info();
20960 irqctx = __this_cpu_read(softirq_ctx);
20961 - irqctx->tinfo.task = curctx->task;
20962 - irqctx->tinfo.previous_esp = current_stack_pointer;
20963 + irqctx->previous_esp = current_stack_pointer;
20964
20965 /* build the stack frame on the softirq stack */
20966 - isp = (u32 *) ((char *)irqctx + sizeof(*irqctx));
20967 + isp = (u32 *) ((char *)irqctx + sizeof(*irqctx) - 8);
20968 +
20969 +#ifdef CONFIG_PAX_MEMORY_UDEREF
20970 + __set_fs(MAKE_MM_SEG(0));
20971 +#endif
20972
20973 call_on_stack(__do_softirq, isp);
20974 +
20975 +#ifdef CONFIG_PAX_MEMORY_UDEREF
20976 + __set_fs(current_thread_info()->addr_limit);
20977 +#endif
20978 +
20979 /*
20980 * Shouldn't happen, we returned above if in_interrupt():
20981 */
20982 @@ -191,7 +186,7 @@ bool handle_irq(unsigned irq, struct pt_regs *regs)
20983 if (unlikely(!desc))
20984 return false;
20985
20986 - if (user_mode_vm(regs) || !execute_on_irq_stack(overflow, desc, irq)) {
20987 + if (user_mode(regs) || !execute_on_irq_stack(overflow, desc, irq)) {
20988 if (unlikely(overflow))
20989 print_stack_overflow();
20990 desc->handle_irq(irq, desc);
20991 diff --git a/arch/x86/kernel/irq_64.c b/arch/x86/kernel/irq_64.c
20992 index d04d3ec..ea4b374 100644
20993 --- a/arch/x86/kernel/irq_64.c
20994 +++ b/arch/x86/kernel/irq_64.c
20995 @@ -44,7 +44,7 @@ static inline void stack_overflow_check(struct pt_regs *regs)
20996 u64 estack_top, estack_bottom;
20997 u64 curbase = (u64)task_stack_page(current);
20998
20999 - if (user_mode_vm(regs))
21000 + if (user_mode(regs))
21001 return;
21002
21003 if (regs->sp >= curbase + sizeof(struct thread_info) +
21004 diff --git a/arch/x86/kernel/kdebugfs.c b/arch/x86/kernel/kdebugfs.c
21005 index dc1404b..bbc43e7 100644
21006 --- a/arch/x86/kernel/kdebugfs.c
21007 +++ b/arch/x86/kernel/kdebugfs.c
21008 @@ -27,7 +27,7 @@ struct setup_data_node {
21009 u32 len;
21010 };
21011
21012 -static ssize_t setup_data_read(struct file *file, char __user *user_buf,
21013 +static ssize_t __size_overflow(3) setup_data_read(struct file *file, char __user *user_buf,
21014 size_t count, loff_t *ppos)
21015 {
21016 struct setup_data_node *node = file->private_data;
21017 diff --git a/arch/x86/kernel/kgdb.c b/arch/x86/kernel/kgdb.c
21018 index 836f832..a8bda67 100644
21019 --- a/arch/x86/kernel/kgdb.c
21020 +++ b/arch/x86/kernel/kgdb.c
21021 @@ -127,11 +127,11 @@ char *dbg_get_reg(int regno, void *mem, struct pt_regs *regs)
21022 #ifdef CONFIG_X86_32
21023 switch (regno) {
21024 case GDB_SS:
21025 - if (!user_mode_vm(regs))
21026 + if (!user_mode(regs))
21027 *(unsigned long *)mem = __KERNEL_DS;
21028 break;
21029 case GDB_SP:
21030 - if (!user_mode_vm(regs))
21031 + if (!user_mode(regs))
21032 *(unsigned long *)mem = kernel_stack_pointer(regs);
21033 break;
21034 case GDB_GS:
21035 @@ -229,7 +229,10 @@ static void kgdb_correct_hw_break(void)
21036 bp->attr.bp_addr = breakinfo[breakno].addr;
21037 bp->attr.bp_len = breakinfo[breakno].len;
21038 bp->attr.bp_type = breakinfo[breakno].type;
21039 - info->address = breakinfo[breakno].addr;
21040 + if (breakinfo[breakno].type == X86_BREAKPOINT_EXECUTE)
21041 + info->address = ktla_ktva(breakinfo[breakno].addr);
21042 + else
21043 + info->address = breakinfo[breakno].addr;
21044 info->len = breakinfo[breakno].len;
21045 info->type = breakinfo[breakno].type;
21046 val = arch_install_hw_breakpoint(bp);
21047 @@ -476,12 +479,12 @@ int kgdb_arch_handle_exception(int e_vector, int signo, int err_code,
21048 case 'k':
21049 /* clear the trace bit */
21050 linux_regs->flags &= ~X86_EFLAGS_TF;
21051 - atomic_set(&kgdb_cpu_doing_single_step, -1);
21052 + atomic_set_unchecked(&kgdb_cpu_doing_single_step, -1);
21053
21054 /* set the trace bit if we're stepping */
21055 if (remcomInBuffer[0] == 's') {
21056 linux_regs->flags |= X86_EFLAGS_TF;
21057 - atomic_set(&kgdb_cpu_doing_single_step,
21058 + atomic_set_unchecked(&kgdb_cpu_doing_single_step,
21059 raw_smp_processor_id());
21060 }
21061
21062 @@ -546,7 +549,7 @@ static int __kgdb_notify(struct die_args *args, unsigned long cmd)
21063
21064 switch (cmd) {
21065 case DIE_DEBUG:
21066 - if (atomic_read(&kgdb_cpu_doing_single_step) != -1) {
21067 + if (atomic_read_unchecked(&kgdb_cpu_doing_single_step) != -1) {
21068 if (user_mode(regs))
21069 return single_step_cont(regs, args);
21070 break;
21071 @@ -751,11 +754,11 @@ int kgdb_arch_set_breakpoint(struct kgdb_bkpt *bpt)
21072 #endif /* CONFIG_DEBUG_RODATA */
21073
21074 bpt->type = BP_BREAKPOINT;
21075 - err = probe_kernel_read(bpt->saved_instr, (char *)bpt->bpt_addr,
21076 + err = probe_kernel_read(bpt->saved_instr, ktla_ktva((char *)bpt->bpt_addr),
21077 BREAK_INSTR_SIZE);
21078 if (err)
21079 return err;
21080 - err = probe_kernel_write((char *)bpt->bpt_addr,
21081 + err = probe_kernel_write(ktla_ktva((char *)bpt->bpt_addr),
21082 arch_kgdb_ops.gdb_bpt_instr, BREAK_INSTR_SIZE);
21083 #ifdef CONFIG_DEBUG_RODATA
21084 if (!err)
21085 @@ -768,7 +771,7 @@ int kgdb_arch_set_breakpoint(struct kgdb_bkpt *bpt)
21086 return -EBUSY;
21087 text_poke((void *)bpt->bpt_addr, arch_kgdb_ops.gdb_bpt_instr,
21088 BREAK_INSTR_SIZE);
21089 - err = probe_kernel_read(opc, (char *)bpt->bpt_addr, BREAK_INSTR_SIZE);
21090 + err = probe_kernel_read(opc, ktla_ktva((char *)bpt->bpt_addr), BREAK_INSTR_SIZE);
21091 if (err)
21092 return err;
21093 if (memcmp(opc, arch_kgdb_ops.gdb_bpt_instr, BREAK_INSTR_SIZE))
21094 @@ -793,13 +796,13 @@ int kgdb_arch_remove_breakpoint(struct kgdb_bkpt *bpt)
21095 if (mutex_is_locked(&text_mutex))
21096 goto knl_write;
21097 text_poke((void *)bpt->bpt_addr, bpt->saved_instr, BREAK_INSTR_SIZE);
21098 - err = probe_kernel_read(opc, (char *)bpt->bpt_addr, BREAK_INSTR_SIZE);
21099 + err = probe_kernel_read(opc, ktla_ktva((char *)bpt->bpt_addr), BREAK_INSTR_SIZE);
21100 if (err || memcmp(opc, bpt->saved_instr, BREAK_INSTR_SIZE))
21101 goto knl_write;
21102 return err;
21103 knl_write:
21104 #endif /* CONFIG_DEBUG_RODATA */
21105 - return probe_kernel_write((char *)bpt->bpt_addr,
21106 + return probe_kernel_write(ktla_ktva((char *)bpt->bpt_addr),
21107 (char *)bpt->saved_instr, BREAK_INSTR_SIZE);
21108 }
21109
21110 diff --git a/arch/x86/kernel/kprobes-opt.c b/arch/x86/kernel/kprobes-opt.c
21111 index c5e410e..ed5a7f0 100644
21112 --- a/arch/x86/kernel/kprobes-opt.c
21113 +++ b/arch/x86/kernel/kprobes-opt.c
21114 @@ -338,7 +338,7 @@ int __kprobes arch_prepare_optimized_kprobe(struct optimized_kprobe *op)
21115 * Verify if the address gap is in 2GB range, because this uses
21116 * a relative jump.
21117 */
21118 - rel = (long)op->optinsn.insn - (long)op->kp.addr + RELATIVEJUMP_SIZE;
21119 + rel = (long)op->optinsn.insn - ktla_ktva((long)op->kp.addr) + RELATIVEJUMP_SIZE;
21120 if (abs(rel) > 0x7fffffff)
21121 return -ERANGE;
21122
21123 @@ -353,16 +353,16 @@ int __kprobes arch_prepare_optimized_kprobe(struct optimized_kprobe *op)
21124 op->optinsn.size = ret;
21125
21126 /* Copy arch-dep-instance from template */
21127 - memcpy(buf, &optprobe_template_entry, TMPL_END_IDX);
21128 + memcpy(buf, ktla_ktva(&optprobe_template_entry), TMPL_END_IDX);
21129
21130 /* Set probe information */
21131 synthesize_set_arg1(buf + TMPL_MOVE_IDX, (unsigned long)op);
21132
21133 /* Set probe function call */
21134 - synthesize_relcall(buf + TMPL_CALL_IDX, optimized_callback);
21135 + synthesize_relcall(ktva_ktla(buf) + TMPL_CALL_IDX, optimized_callback);
21136
21137 /* Set returning jmp instruction at the tail of out-of-line buffer */
21138 - synthesize_reljump(buf + TMPL_END_IDX + op->optinsn.size,
21139 + synthesize_reljump(ktva_ktla(buf) + TMPL_END_IDX + op->optinsn.size,
21140 (u8 *)op->kp.addr + op->optinsn.size);
21141
21142 flush_icache_range((unsigned long) buf,
21143 @@ -385,7 +385,7 @@ static void __kprobes setup_optimize_kprobe(struct text_poke_param *tprm,
21144 ((long)op->kp.addr + RELATIVEJUMP_SIZE));
21145
21146 /* Backup instructions which will be replaced by jump address */
21147 - memcpy(op->optinsn.copied_insn, op->kp.addr + INT3_SIZE,
21148 + memcpy(op->optinsn.copied_insn, ktla_ktva(op->kp.addr) + INT3_SIZE,
21149 RELATIVE_ADDR_SIZE);
21150
21151 insn_buf[0] = RELATIVEJUMP_OPCODE;
21152 @@ -483,7 +483,7 @@ setup_detour_execution(struct kprobe *p, struct pt_regs *regs, int reenter)
21153 /* This kprobe is really able to run optimized path. */
21154 op = container_of(p, struct optimized_kprobe, kp);
21155 /* Detour through copied instructions */
21156 - regs->ip = (unsigned long)op->optinsn.insn + TMPL_END_IDX;
21157 + regs->ip = ktva_ktla((unsigned long)op->optinsn.insn) + TMPL_END_IDX;
21158 if (!reenter)
21159 reset_current_kprobe();
21160 preempt_enable_no_resched();
21161 diff --git a/arch/x86/kernel/kprobes.c b/arch/x86/kernel/kprobes.c
21162 index 57916c0..9e0b9d0 100644
21163 --- a/arch/x86/kernel/kprobes.c
21164 +++ b/arch/x86/kernel/kprobes.c
21165 @@ -119,9 +119,12 @@ static void __kprobes __synthesize_relative_insn(void *from, void *to, u8 op)
21166 s32 raddr;
21167 } __attribute__((packed)) *insn;
21168
21169 - insn = (struct __arch_relative_insn *)from;
21170 + insn = (struct __arch_relative_insn *)ktla_ktva(from);
21171 +
21172 + pax_open_kernel();
21173 insn->raddr = (s32)((long)(to) - ((long)(from) + 5));
21174 insn->op = op;
21175 + pax_close_kernel();
21176 }
21177
21178 /* Insert a jump instruction at address 'from', which jumps to address 'to'.*/
21179 @@ -164,7 +167,7 @@ int __kprobes can_boost(kprobe_opcode_t *opcodes)
21180 kprobe_opcode_t opcode;
21181 kprobe_opcode_t *orig_opcodes = opcodes;
21182
21183 - if (search_exception_tables((unsigned long)opcodes))
21184 + if (search_exception_tables(ktva_ktla((unsigned long)opcodes)))
21185 return 0; /* Page fault may occur on this address. */
21186
21187 retry:
21188 @@ -238,9 +241,9 @@ __recover_probed_insn(kprobe_opcode_t *buf, unsigned long addr)
21189 * for the first byte, we can recover the original instruction
21190 * from it and kp->opcode.
21191 */
21192 - memcpy(buf, kp->addr, MAX_INSN_SIZE * sizeof(kprobe_opcode_t));
21193 + memcpy(buf, ktla_ktva(kp->addr), MAX_INSN_SIZE * sizeof(kprobe_opcode_t));
21194 buf[0] = kp->opcode;
21195 - return (unsigned long)buf;
21196 + return ktva_ktla((unsigned long)buf);
21197 }
21198
21199 /*
21200 @@ -332,7 +335,9 @@ int __kprobes __copy_instruction(u8 *dest, u8 *src)
21201 /* Another subsystem puts a breakpoint, failed to recover */
21202 if (insn.opcode.bytes[0] == BREAKPOINT_INSTRUCTION)
21203 return 0;
21204 + pax_open_kernel();
21205 memcpy(dest, insn.kaddr, insn.length);
21206 + pax_close_kernel();
21207
21208 #ifdef CONFIG_X86_64
21209 if (insn_rip_relative(&insn)) {
21210 @@ -355,7 +360,9 @@ int __kprobes __copy_instruction(u8 *dest, u8 *src)
21211 newdisp = (u8 *) src + (s64) insn.displacement.value - (u8 *) dest;
21212 BUG_ON((s64) (s32) newdisp != newdisp); /* Sanity check. */
21213 disp = (u8 *) dest + insn_offset_displacement(&insn);
21214 + pax_open_kernel();
21215 *(s32 *) disp = (s32) newdisp;
21216 + pax_close_kernel();
21217 }
21218 #endif
21219 return insn.length;
21220 @@ -485,7 +492,7 @@ setup_singlestep(struct kprobe *p, struct pt_regs *regs, struct kprobe_ctlblk *k
21221 * nor set current_kprobe, because it doesn't use single
21222 * stepping.
21223 */
21224 - regs->ip = (unsigned long)p->ainsn.insn;
21225 + regs->ip = ktva_ktla((unsigned long)p->ainsn.insn);
21226 preempt_enable_no_resched();
21227 return;
21228 }
21229 @@ -502,9 +509,9 @@ setup_singlestep(struct kprobe *p, struct pt_regs *regs, struct kprobe_ctlblk *k
21230 regs->flags &= ~X86_EFLAGS_IF;
21231 /* single step inline if the instruction is an int3 */
21232 if (p->opcode == BREAKPOINT_INSTRUCTION)
21233 - regs->ip = (unsigned long)p->addr;
21234 + regs->ip = ktla_ktva((unsigned long)p->addr);
21235 else
21236 - regs->ip = (unsigned long)p->ainsn.insn;
21237 + regs->ip = ktva_ktla((unsigned long)p->ainsn.insn);
21238 }
21239
21240 /*
21241 @@ -600,7 +607,7 @@ static int __kprobes kprobe_handler(struct pt_regs *regs)
21242 setup_singlestep(p, regs, kcb, 0);
21243 return 1;
21244 }
21245 - } else if (*addr != BREAKPOINT_INSTRUCTION) {
21246 + } else if (*(kprobe_opcode_t *)ktla_ktva((unsigned long)addr) != BREAKPOINT_INSTRUCTION) {
21247 /*
21248 * The breakpoint instruction was removed right
21249 * after we hit it. Another cpu has removed
21250 @@ -651,6 +658,9 @@ static void __used __kprobes kretprobe_trampoline_holder(void)
21251 " movq %rax, 152(%rsp)\n"
21252 RESTORE_REGS_STRING
21253 " popfq\n"
21254 +#ifdef KERNEXEC_PLUGIN
21255 + " btsq $63,(%rsp)\n"
21256 +#endif
21257 #else
21258 " pushf\n"
21259 SAVE_REGS_STRING
21260 @@ -788,7 +798,7 @@ static void __kprobes
21261 resume_execution(struct kprobe *p, struct pt_regs *regs, struct kprobe_ctlblk *kcb)
21262 {
21263 unsigned long *tos = stack_addr(regs);
21264 - unsigned long copy_ip = (unsigned long)p->ainsn.insn;
21265 + unsigned long copy_ip = ktva_ktla((unsigned long)p->ainsn.insn);
21266 unsigned long orig_ip = (unsigned long)p->addr;
21267 kprobe_opcode_t *insn = p->ainsn.insn;
21268
21269 @@ -970,7 +980,7 @@ kprobe_exceptions_notify(struct notifier_block *self, unsigned long val, void *d
21270 struct die_args *args = data;
21271 int ret = NOTIFY_DONE;
21272
21273 - if (args->regs && user_mode_vm(args->regs))
21274 + if (args->regs && user_mode(args->regs))
21275 return ret;
21276
21277 switch (val) {
21278 diff --git a/arch/x86/kernel/kvm.c b/arch/x86/kernel/kvm.c
21279 index 9c2bd8b..bb1131c 100644
21280 --- a/arch/x86/kernel/kvm.c
21281 +++ b/arch/x86/kernel/kvm.c
21282 @@ -452,7 +452,7 @@ static int __cpuinit kvm_cpu_notify(struct notifier_block *self,
21283 return NOTIFY_OK;
21284 }
21285
21286 -static struct notifier_block __cpuinitdata kvm_cpu_notifier = {
21287 +static struct notifier_block kvm_cpu_notifier = {
21288 .notifier_call = kvm_cpu_notify,
21289 };
21290 #endif
21291 diff --git a/arch/x86/kernel/ldt.c b/arch/x86/kernel/ldt.c
21292 index ebc9873..1b9724b 100644
21293 --- a/arch/x86/kernel/ldt.c
21294 +++ b/arch/x86/kernel/ldt.c
21295 @@ -66,13 +66,13 @@ static int alloc_ldt(mm_context_t *pc, int mincount, int reload)
21296 if (reload) {
21297 #ifdef CONFIG_SMP
21298 preempt_disable();
21299 - load_LDT(pc);
21300 + load_LDT_nolock(pc);
21301 if (!cpumask_equal(mm_cpumask(current->mm),
21302 cpumask_of(smp_processor_id())))
21303 smp_call_function(flush_ldt, current->mm, 1);
21304 preempt_enable();
21305 #else
21306 - load_LDT(pc);
21307 + load_LDT_nolock(pc);
21308 #endif
21309 }
21310 if (oldsize) {
21311 @@ -94,7 +94,7 @@ static inline int copy_ldt(mm_context_t *new, mm_context_t *old)
21312 return err;
21313
21314 for (i = 0; i < old->size; i++)
21315 - write_ldt_entry(new->ldt, i, old->ldt + i * LDT_ENTRY_SIZE);
21316 + write_ldt_entry(new->ldt, i, old->ldt + i);
21317 return 0;
21318 }
21319
21320 @@ -115,6 +115,24 @@ int init_new_context(struct task_struct *tsk, struct mm_struct *mm)
21321 retval = copy_ldt(&mm->context, &old_mm->context);
21322 mutex_unlock(&old_mm->context.lock);
21323 }
21324 +
21325 + if (tsk == current) {
21326 + mm->context.vdso = 0;
21327 +
21328 +#ifdef CONFIG_X86_32
21329 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
21330 + mm->context.user_cs_base = 0UL;
21331 + mm->context.user_cs_limit = ~0UL;
21332 +
21333 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_SMP)
21334 + cpus_clear(mm->context.cpu_user_cs_mask);
21335 +#endif
21336 +
21337 +#endif
21338 +#endif
21339 +
21340 + }
21341 +
21342 return retval;
21343 }
21344
21345 @@ -229,6 +247,13 @@ static int write_ldt(void __user *ptr, unsigned long bytecount, int oldmode)
21346 }
21347 }
21348
21349 +#ifdef CONFIG_PAX_SEGMEXEC
21350 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (ldt_info.contents & MODIFY_LDT_CONTENTS_CODE)) {
21351 + error = -EINVAL;
21352 + goto out_unlock;
21353 + }
21354 +#endif
21355 +
21356 fill_ldt(&ldt, &ldt_info);
21357 if (oldmode)
21358 ldt.avl = 0;
21359 diff --git a/arch/x86/kernel/machine_kexec_32.c b/arch/x86/kernel/machine_kexec_32.c
21360 index 5b19e4d..6476a76 100644
21361 --- a/arch/x86/kernel/machine_kexec_32.c
21362 +++ b/arch/x86/kernel/machine_kexec_32.c
21363 @@ -26,7 +26,7 @@
21364 #include <asm/cacheflush.h>
21365 #include <asm/debugreg.h>
21366
21367 -static void set_idt(void *newidt, __u16 limit)
21368 +static void set_idt(struct desc_struct *newidt, __u16 limit)
21369 {
21370 struct desc_ptr curidt;
21371
21372 @@ -38,7 +38,7 @@ static void set_idt(void *newidt, __u16 limit)
21373 }
21374
21375
21376 -static void set_gdt(void *newgdt, __u16 limit)
21377 +static void set_gdt(struct desc_struct *newgdt, __u16 limit)
21378 {
21379 struct desc_ptr curgdt;
21380
21381 @@ -216,7 +216,7 @@ void machine_kexec(struct kimage *image)
21382 }
21383
21384 control_page = page_address(image->control_code_page);
21385 - memcpy(control_page, relocate_kernel, KEXEC_CONTROL_CODE_MAX_SIZE);
21386 + memcpy(control_page, (void *)ktla_ktva((unsigned long)relocate_kernel), KEXEC_CONTROL_CODE_MAX_SIZE);
21387
21388 relocate_kernel_ptr = control_page;
21389 page_list[PA_CONTROL_PAGE] = __pa(control_page);
21390 diff --git a/arch/x86/kernel/microcode_core.c b/arch/x86/kernel/microcode_core.c
21391 index 3a04b22..1d2eb09 100644
21392 --- a/arch/x86/kernel/microcode_core.c
21393 +++ b/arch/x86/kernel/microcode_core.c
21394 @@ -512,7 +512,7 @@ mc_cpu_callback(struct notifier_block *nb, unsigned long action, void *hcpu)
21395 return NOTIFY_OK;
21396 }
21397
21398 -static struct notifier_block __refdata mc_cpu_notifier = {
21399 +static struct notifier_block mc_cpu_notifier = {
21400 .notifier_call = mc_cpu_callback,
21401 };
21402
21403 diff --git a/arch/x86/kernel/microcode_intel.c b/arch/x86/kernel/microcode_intel.c
21404 index 3544aed..01ddc1c 100644
21405 --- a/arch/x86/kernel/microcode_intel.c
21406 +++ b/arch/x86/kernel/microcode_intel.c
21407 @@ -431,13 +431,13 @@ static enum ucode_state request_microcode_fw(int cpu, struct device *device,
21408
21409 static int get_ucode_user(void *to, const void *from, size_t n)
21410 {
21411 - return copy_from_user(to, from, n);
21412 + return copy_from_user(to, (const void __force_user *)from, n);
21413 }
21414
21415 static enum ucode_state
21416 request_microcode_user(int cpu, const void __user *buf, size_t size)
21417 {
21418 - return generic_load_microcode(cpu, (void *)buf, size, &get_ucode_user);
21419 + return generic_load_microcode(cpu, (__force_kernel void *)buf, size, &get_ucode_user);
21420 }
21421
21422 static void microcode_fini_cpu(int cpu)
21423 diff --git a/arch/x86/kernel/module.c b/arch/x86/kernel/module.c
21424 index 216a4d7..228255a 100644
21425 --- a/arch/x86/kernel/module.c
21426 +++ b/arch/x86/kernel/module.c
21427 @@ -43,15 +43,60 @@ do { \
21428 } while (0)
21429 #endif
21430
21431 -void *module_alloc(unsigned long size)
21432 +static inline void *__module_alloc(unsigned long size, pgprot_t prot)
21433 {
21434 - if (PAGE_ALIGN(size) > MODULES_LEN)
21435 + if (!size || PAGE_ALIGN(size) > MODULES_LEN)
21436 return NULL;
21437 return __vmalloc_node_range(size, 1, MODULES_VADDR, MODULES_END,
21438 - GFP_KERNEL | __GFP_HIGHMEM, PAGE_KERNEL_EXEC,
21439 + GFP_KERNEL | __GFP_HIGHMEM | __GFP_ZERO, prot,
21440 -1, __builtin_return_address(0));
21441 }
21442
21443 +void *module_alloc(unsigned long size)
21444 +{
21445 +
21446 +#ifdef CONFIG_PAX_KERNEXEC
21447 + return __module_alloc(size, PAGE_KERNEL);
21448 +#else
21449 + return __module_alloc(size, PAGE_KERNEL_EXEC);
21450 +#endif
21451 +
21452 +}
21453 +
21454 +#ifdef CONFIG_PAX_KERNEXEC
21455 +#ifdef CONFIG_X86_32
21456 +void *module_alloc_exec(unsigned long size)
21457 +{
21458 + struct vm_struct *area;
21459 +
21460 + if (size == 0)
21461 + return NULL;
21462 +
21463 + area = __get_vm_area(size, VM_ALLOC, (unsigned long)&MODULES_EXEC_VADDR, (unsigned long)&MODULES_EXEC_END);
21464 + return area ? area->addr : NULL;
21465 +}
21466 +EXPORT_SYMBOL(module_alloc_exec);
21467 +
21468 +void module_free_exec(struct module *mod, void *module_region)
21469 +{
21470 + vunmap(module_region);
21471 +}
21472 +EXPORT_SYMBOL(module_free_exec);
21473 +#else
21474 +void module_free_exec(struct module *mod, void *module_region)
21475 +{
21476 + module_free(mod, module_region);
21477 +}
21478 +EXPORT_SYMBOL(module_free_exec);
21479 +
21480 +void *module_alloc_exec(unsigned long size)
21481 +{
21482 + return __module_alloc(size, PAGE_KERNEL_RX);
21483 +}
21484 +EXPORT_SYMBOL(module_alloc_exec);
21485 +#endif
21486 +#endif
21487 +
21488 #ifdef CONFIG_X86_32
21489 int apply_relocate(Elf32_Shdr *sechdrs,
21490 const char *strtab,
21491 @@ -62,14 +107,16 @@ int apply_relocate(Elf32_Shdr *sechdrs,
21492 unsigned int i;
21493 Elf32_Rel *rel = (void *)sechdrs[relsec].sh_addr;
21494 Elf32_Sym *sym;
21495 - uint32_t *location;
21496 + uint32_t *plocation, location;
21497
21498 DEBUGP("Applying relocate section %u to %u\n",
21499 relsec, sechdrs[relsec].sh_info);
21500 for (i = 0; i < sechdrs[relsec].sh_size / sizeof(*rel); i++) {
21501 /* This is where to make the change */
21502 - location = (void *)sechdrs[sechdrs[relsec].sh_info].sh_addr
21503 - + rel[i].r_offset;
21504 + plocation = (void *)sechdrs[sechdrs[relsec].sh_info].sh_addr + rel[i].r_offset;
21505 + location = (uint32_t)plocation;
21506 + if (sechdrs[sechdrs[relsec].sh_info].sh_flags & SHF_EXECINSTR)
21507 + plocation = ktla_ktva((void *)plocation);
21508 /* This is the symbol it is referring to. Note that all
21509 undefined symbols have been resolved. */
21510 sym = (Elf32_Sym *)sechdrs[symindex].sh_addr
21511 @@ -78,11 +125,15 @@ int apply_relocate(Elf32_Shdr *sechdrs,
21512 switch (ELF32_R_TYPE(rel[i].r_info)) {
21513 case R_386_32:
21514 /* We add the value into the location given */
21515 - *location += sym->st_value;
21516 + pax_open_kernel();
21517 + *plocation += sym->st_value;
21518 + pax_close_kernel();
21519 break;
21520 case R_386_PC32:
21521 /* Add the value, subtract its position */
21522 - *location += sym->st_value - (uint32_t)location;
21523 + pax_open_kernel();
21524 + *plocation += sym->st_value - location;
21525 + pax_close_kernel();
21526 break;
21527 default:
21528 pr_err("%s: Unknown relocation: %u\n",
21529 @@ -127,21 +178,30 @@ int apply_relocate_add(Elf64_Shdr *sechdrs,
21530 case R_X86_64_NONE:
21531 break;
21532 case R_X86_64_64:
21533 + pax_open_kernel();
21534 *(u64 *)loc = val;
21535 + pax_close_kernel();
21536 break;
21537 case R_X86_64_32:
21538 + pax_open_kernel();
21539 *(u32 *)loc = val;
21540 + pax_close_kernel();
21541 if (val != *(u32 *)loc)
21542 goto overflow;
21543 break;
21544 case R_X86_64_32S:
21545 + pax_open_kernel();
21546 *(s32 *)loc = val;
21547 + pax_close_kernel();
21548 if ((s64)val != *(s32 *)loc)
21549 goto overflow;
21550 break;
21551 case R_X86_64_PC32:
21552 val -= (u64)loc;
21553 + pax_open_kernel();
21554 *(u32 *)loc = val;
21555 + pax_close_kernel();
21556 +
21557 #if 0
21558 if ((s64)val != *(s32 *)loc)
21559 goto overflow;
21560 diff --git a/arch/x86/kernel/msr.c b/arch/x86/kernel/msr.c
21561 index 4929502..686c291 100644
21562 --- a/arch/x86/kernel/msr.c
21563 +++ b/arch/x86/kernel/msr.c
21564 @@ -234,7 +234,7 @@ static int __cpuinit msr_class_cpu_callback(struct notifier_block *nfb,
21565 return notifier_from_errno(err);
21566 }
21567
21568 -static struct notifier_block __refdata msr_class_cpu_notifier = {
21569 +static struct notifier_block msr_class_cpu_notifier = {
21570 .notifier_call = msr_class_cpu_callback,
21571 };
21572
21573 diff --git a/arch/x86/kernel/nmi.c b/arch/x86/kernel/nmi.c
21574 index f84f5c5..f404e81 100644
21575 --- a/arch/x86/kernel/nmi.c
21576 +++ b/arch/x86/kernel/nmi.c
21577 @@ -105,7 +105,7 @@ static int __kprobes nmi_handle(unsigned int type, struct pt_regs *regs, bool b2
21578 return handled;
21579 }
21580
21581 -int __register_nmi_handler(unsigned int type, struct nmiaction *action)
21582 +int __register_nmi_handler(unsigned int type, const struct nmiaction *action)
21583 {
21584 struct nmi_desc *desc = nmi_to_desc(type);
21585 unsigned long flags;
21586 @@ -129,9 +129,9 @@ int __register_nmi_handler(unsigned int type, struct nmiaction *action)
21587 * event confuses some handlers (kdump uses this flag)
21588 */
21589 if (action->flags & NMI_FLAG_FIRST)
21590 - list_add_rcu(&action->list, &desc->head);
21591 + pax_list_add_rcu((struct list_head *)&action->list, &desc->head);
21592 else
21593 - list_add_tail_rcu(&action->list, &desc->head);
21594 + pax_list_add_tail_rcu((struct list_head *)&action->list, &desc->head);
21595
21596 spin_unlock_irqrestore(&desc->lock, flags);
21597 return 0;
21598 @@ -154,7 +154,7 @@ void unregister_nmi_handler(unsigned int type, const char *name)
21599 if (!strcmp(n->name, name)) {
21600 WARN(in_nmi(),
21601 "Trying to free NMI (%s) from NMI context!\n", n->name);
21602 - list_del_rcu(&n->list);
21603 + pax_list_del_rcu((struct list_head *)&n->list);
21604 break;
21605 }
21606 }
21607 @@ -479,6 +479,17 @@ static inline void nmi_nesting_postprocess(void)
21608 dotraplinkage notrace __kprobes void
21609 do_nmi(struct pt_regs *regs, long error_code)
21610 {
21611 +
21612 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
21613 + if (!user_mode(regs)) {
21614 + unsigned long cs = regs->cs & 0xFFFF;
21615 + unsigned long ip = ktva_ktla(regs->ip);
21616 +
21617 + if ((cs == __KERNEL_CS || cs == __KERNEXEC_KERNEL_CS) && ip <= (unsigned long)_etext)
21618 + regs->ip = ip;
21619 + }
21620 +#endif
21621 +
21622 nmi_nesting_preprocess(regs);
21623
21624 nmi_enter();
21625 diff --git a/arch/x86/kernel/nmi_selftest.c b/arch/x86/kernel/nmi_selftest.c
21626 index 6d9582e..f746287 100644
21627 --- a/arch/x86/kernel/nmi_selftest.c
21628 +++ b/arch/x86/kernel/nmi_selftest.c
21629 @@ -43,7 +43,7 @@ static void __init init_nmi_testsuite(void)
21630 {
21631 /* trap all the unknown NMIs we may generate */
21632 register_nmi_handler(NMI_UNKNOWN, nmi_unk_cb, 0, "nmi_selftest_unk",
21633 - __initdata);
21634 + __initconst);
21635 }
21636
21637 static void __init cleanup_nmi_testsuite(void)
21638 @@ -66,7 +66,7 @@ static void __init test_nmi_ipi(struct cpumask *mask)
21639 unsigned long timeout;
21640
21641 if (register_nmi_handler(NMI_LOCAL, test_nmi_ipi_callback,
21642 - NMI_FLAG_FIRST, "nmi_selftest", __initdata)) {
21643 + NMI_FLAG_FIRST, "nmi_selftest", __initconst)) {
21644 nmi_fail = FAILURE;
21645 return;
21646 }
21647 diff --git a/arch/x86/kernel/paravirt-spinlocks.c b/arch/x86/kernel/paravirt-spinlocks.c
21648 index 676b8c7..870ba04 100644
21649 --- a/arch/x86/kernel/paravirt-spinlocks.c
21650 +++ b/arch/x86/kernel/paravirt-spinlocks.c
21651 @@ -13,7 +13,7 @@ default_spin_lock_flags(arch_spinlock_t *lock, unsigned long flags)
21652 arch_spin_lock(lock);
21653 }
21654
21655 -struct pv_lock_ops pv_lock_ops = {
21656 +struct pv_lock_ops pv_lock_ops __read_only = {
21657 #ifdef CONFIG_SMP
21658 .spin_is_locked = __ticket_spin_is_locked,
21659 .spin_is_contended = __ticket_spin_is_contended,
21660 diff --git a/arch/x86/kernel/paravirt.c b/arch/x86/kernel/paravirt.c
21661 index 17fff18..5cfa0f4 100644
21662 --- a/arch/x86/kernel/paravirt.c
21663 +++ b/arch/x86/kernel/paravirt.c
21664 @@ -55,6 +55,9 @@ u64 _paravirt_ident_64(u64 x)
21665 {
21666 return x;
21667 }
21668 +#if defined(CONFIG_X86_32) && defined(CONFIG_X86_PAE)
21669 +PV_CALLEE_SAVE_REGS_THUNK(_paravirt_ident_64);
21670 +#endif
21671
21672 void __init default_banner(void)
21673 {
21674 @@ -147,15 +150,19 @@ unsigned paravirt_patch_default(u8 type, u16 clobbers, void *insnbuf,
21675 if (opfunc == NULL)
21676 /* If there's no function, patch it with a ud2a (BUG) */
21677 ret = paravirt_patch_insns(insnbuf, len, ud2a, ud2a+sizeof(ud2a));
21678 - else if (opfunc == _paravirt_nop)
21679 + else if (opfunc == (void *)_paravirt_nop)
21680 /* If the operation is a nop, then nop the callsite */
21681 ret = paravirt_patch_nop();
21682
21683 /* identity functions just return their single argument */
21684 - else if (opfunc == _paravirt_ident_32)
21685 + else if (opfunc == (void *)_paravirt_ident_32)
21686 ret = paravirt_patch_ident_32(insnbuf, len);
21687 - else if (opfunc == _paravirt_ident_64)
21688 + else if (opfunc == (void *)_paravirt_ident_64)
21689 ret = paravirt_patch_ident_64(insnbuf, len);
21690 +#if defined(CONFIG_X86_32) && defined(CONFIG_X86_PAE)
21691 + else if (opfunc == (void *)__raw_callee_save__paravirt_ident_64)
21692 + ret = paravirt_patch_ident_64(insnbuf, len);
21693 +#endif
21694
21695 else if (type == PARAVIRT_PATCH(pv_cpu_ops.iret) ||
21696 type == PARAVIRT_PATCH(pv_cpu_ops.irq_enable_sysexit) ||
21697 @@ -180,7 +187,7 @@ unsigned paravirt_patch_insns(void *insnbuf, unsigned len,
21698 if (insn_len > len || start == NULL)
21699 insn_len = len;
21700 else
21701 - memcpy(insnbuf, start, insn_len);
21702 + memcpy(insnbuf, ktla_ktva(start), insn_len);
21703
21704 return insn_len;
21705 }
21706 @@ -304,7 +311,7 @@ void arch_flush_lazy_mmu_mode(void)
21707 preempt_enable();
21708 }
21709
21710 -struct pv_info pv_info = {
21711 +struct pv_info pv_info __read_only = {
21712 .name = "bare hardware",
21713 .paravirt_enabled = 0,
21714 .kernel_rpl = 0,
21715 @@ -315,16 +322,16 @@ struct pv_info pv_info = {
21716 #endif
21717 };
21718
21719 -struct pv_init_ops pv_init_ops = {
21720 +struct pv_init_ops pv_init_ops __read_only = {
21721 .patch = native_patch,
21722 };
21723
21724 -struct pv_time_ops pv_time_ops = {
21725 +struct pv_time_ops pv_time_ops __read_only = {
21726 .sched_clock = native_sched_clock,
21727 .steal_clock = native_steal_clock,
21728 };
21729
21730 -struct pv_irq_ops pv_irq_ops = {
21731 +struct pv_irq_ops pv_irq_ops __read_only = {
21732 .save_fl = __PV_IS_CALLEE_SAVE(native_save_fl),
21733 .restore_fl = __PV_IS_CALLEE_SAVE(native_restore_fl),
21734 .irq_disable = __PV_IS_CALLEE_SAVE(native_irq_disable),
21735 @@ -336,7 +343,7 @@ struct pv_irq_ops pv_irq_ops = {
21736 #endif
21737 };
21738
21739 -struct pv_cpu_ops pv_cpu_ops = {
21740 +struct pv_cpu_ops pv_cpu_ops __read_only = {
21741 .cpuid = native_cpuid,
21742 .get_debugreg = native_get_debugreg,
21743 .set_debugreg = native_set_debugreg,
21744 @@ -395,21 +402,26 @@ struct pv_cpu_ops pv_cpu_ops = {
21745 .end_context_switch = paravirt_nop,
21746 };
21747
21748 -struct pv_apic_ops pv_apic_ops = {
21749 +struct pv_apic_ops pv_apic_ops __read_only= {
21750 #ifdef CONFIG_X86_LOCAL_APIC
21751 .startup_ipi_hook = paravirt_nop,
21752 #endif
21753 };
21754
21755 -#if defined(CONFIG_X86_32) && !defined(CONFIG_X86_PAE)
21756 +#ifdef CONFIG_X86_32
21757 +#ifdef CONFIG_X86_PAE
21758 +/* 64-bit pagetable entries */
21759 +#define PTE_IDENT PV_CALLEE_SAVE(_paravirt_ident_64)
21760 +#else
21761 /* 32-bit pagetable entries */
21762 #define PTE_IDENT __PV_IS_CALLEE_SAVE(_paravirt_ident_32)
21763 +#endif
21764 #else
21765 /* 64-bit pagetable entries */
21766 #define PTE_IDENT __PV_IS_CALLEE_SAVE(_paravirt_ident_64)
21767 #endif
21768
21769 -struct pv_mmu_ops pv_mmu_ops = {
21770 +struct pv_mmu_ops pv_mmu_ops __read_only = {
21771
21772 .read_cr2 = native_read_cr2,
21773 .write_cr2 = native_write_cr2,
21774 @@ -459,6 +471,7 @@ struct pv_mmu_ops pv_mmu_ops = {
21775 .make_pud = PTE_IDENT,
21776
21777 .set_pgd = native_set_pgd,
21778 + .set_pgd_batched = native_set_pgd_batched,
21779 #endif
21780 #endif /* PAGETABLE_LEVELS >= 3 */
21781
21782 @@ -478,6 +491,12 @@ struct pv_mmu_ops pv_mmu_ops = {
21783 },
21784
21785 .set_fixmap = native_set_fixmap,
21786 +
21787 +#ifdef CONFIG_PAX_KERNEXEC
21788 + .pax_open_kernel = native_pax_open_kernel,
21789 + .pax_close_kernel = native_pax_close_kernel,
21790 +#endif
21791 +
21792 };
21793
21794 EXPORT_SYMBOL_GPL(pv_time_ops);
21795 diff --git a/arch/x86/kernel/pci-iommu_table.c b/arch/x86/kernel/pci-iommu_table.c
21796 index 35ccf75..7a15747 100644
21797 --- a/arch/x86/kernel/pci-iommu_table.c
21798 +++ b/arch/x86/kernel/pci-iommu_table.c
21799 @@ -2,7 +2,7 @@
21800 #include <asm/iommu_table.h>
21801 #include <linux/string.h>
21802 #include <linux/kallsyms.h>
21803 -
21804 +#include <linux/sched.h>
21805
21806 #define DEBUG 1
21807
21808 diff --git a/arch/x86/kernel/pci-swiotlb.c b/arch/x86/kernel/pci-swiotlb.c
21809 index 6c483ba..d10ce2f 100644
21810 --- a/arch/x86/kernel/pci-swiotlb.c
21811 +++ b/arch/x86/kernel/pci-swiotlb.c
21812 @@ -32,7 +32,7 @@ static void x86_swiotlb_free_coherent(struct device *dev, size_t size,
21813 void *vaddr, dma_addr_t dma_addr,
21814 struct dma_attrs *attrs)
21815 {
21816 - swiotlb_free_coherent(dev, size, vaddr, dma_addr);
21817 + swiotlb_free_coherent(dev, size, vaddr, dma_addr, attrs);
21818 }
21819
21820 static struct dma_map_ops swiotlb_dma_ops = {
21821 diff --git a/arch/x86/kernel/process.c b/arch/x86/kernel/process.c
21822 index 2ed787f..f70c9f6 100644
21823 --- a/arch/x86/kernel/process.c
21824 +++ b/arch/x86/kernel/process.c
21825 @@ -36,7 +36,8 @@
21826 * section. Since TSS's are completely CPU-local, we want them
21827 * on exact cacheline boundaries, to eliminate cacheline ping-pong.
21828 */
21829 -DEFINE_PER_CPU_SHARED_ALIGNED(struct tss_struct, init_tss) = INIT_TSS;
21830 +struct tss_struct init_tss[NR_CPUS] ____cacheline_internodealigned_in_smp = { [0 ... NR_CPUS-1] = INIT_TSS };
21831 +EXPORT_SYMBOL(init_tss);
21832
21833 #ifdef CONFIG_X86_64
21834 static DEFINE_PER_CPU(unsigned char, is_idle);
21835 @@ -92,7 +93,7 @@ void arch_task_cache_init(void)
21836 task_xstate_cachep =
21837 kmem_cache_create("task_xstate", xstate_size,
21838 __alignof__(union thread_xstate),
21839 - SLAB_PANIC | SLAB_NOTRACK, NULL);
21840 + SLAB_PANIC | SLAB_NOTRACK | SLAB_USERCOPY, NULL);
21841 }
21842
21843 /*
21844 @@ -105,7 +106,7 @@ void exit_thread(void)
21845 unsigned long *bp = t->io_bitmap_ptr;
21846
21847 if (bp) {
21848 - struct tss_struct *tss = &per_cpu(init_tss, get_cpu());
21849 + struct tss_struct *tss = init_tss + get_cpu();
21850
21851 t->io_bitmap_ptr = NULL;
21852 clear_thread_flag(TIF_IO_BITMAP);
21853 @@ -136,7 +137,7 @@ void show_regs_common(void)
21854 board = dmi_get_system_info(DMI_BOARD_NAME);
21855
21856 printk(KERN_DEFAULT "Pid: %d, comm: %.20s %s %s %.*s %s %s%s%s\n",
21857 - current->pid, current->comm, print_tainted(),
21858 + task_pid_nr(current), current->comm, print_tainted(),
21859 init_utsname()->release,
21860 (int)strcspn(init_utsname()->version, " "),
21861 init_utsname()->version,
21862 @@ -149,6 +150,9 @@ void flush_thread(void)
21863 {
21864 struct task_struct *tsk = current;
21865
21866 +#if defined(CONFIG_X86_32) && !defined(CONFIG_CC_STACKPROTECTOR) && !defined(CONFIG_PAX_MEMORY_UDEREF)
21867 + loadsegment(gs, 0);
21868 +#endif
21869 flush_ptrace_hw_breakpoint(tsk);
21870 memset(tsk->thread.tls_array, 0, sizeof(tsk->thread.tls_array));
21871 drop_init_fpu(tsk);
21872 @@ -301,7 +305,7 @@ static void __exit_idle(void)
21873 void exit_idle(void)
21874 {
21875 /* idle loop has pid 0 */
21876 - if (current->pid)
21877 + if (task_pid_nr(current))
21878 return;
21879 __exit_idle();
21880 }
21881 @@ -404,7 +408,7 @@ bool set_pm_idle_to_default(void)
21882
21883 return ret;
21884 }
21885 -void stop_this_cpu(void *dummy)
21886 +__noreturn void stop_this_cpu(void *dummy)
21887 {
21888 local_irq_disable();
21889 /*
21890 @@ -632,16 +636,37 @@ static int __init idle_setup(char *str)
21891 }
21892 early_param("idle", idle_setup);
21893
21894 -unsigned long arch_align_stack(unsigned long sp)
21895 +#ifdef CONFIG_PAX_RANDKSTACK
21896 +void pax_randomize_kstack(struct pt_regs *regs)
21897 {
21898 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
21899 - sp -= get_random_int() % 8192;
21900 - return sp & ~0xf;
21901 -}
21902 + struct thread_struct *thread = &current->thread;
21903 + unsigned long time;
21904
21905 -unsigned long arch_randomize_brk(struct mm_struct *mm)
21906 -{
21907 - unsigned long range_end = mm->brk + 0x02000000;
21908 - return randomize_range(mm->brk, range_end, 0) ? : mm->brk;
21909 -}
21910 + if (!randomize_va_space)
21911 + return;
21912 +
21913 + if (v8086_mode(regs))
21914 + return;
21915
21916 + rdtscl(time);
21917 +
21918 + /* P4 seems to return a 0 LSB, ignore it */
21919 +#ifdef CONFIG_MPENTIUM4
21920 + time &= 0x3EUL;
21921 + time <<= 2;
21922 +#elif defined(CONFIG_X86_64)
21923 + time &= 0xFUL;
21924 + time <<= 4;
21925 +#else
21926 + time &= 0x1FUL;
21927 + time <<= 3;
21928 +#endif
21929 +
21930 + thread->sp0 ^= time;
21931 + load_sp0(init_tss + smp_processor_id(), thread);
21932 +
21933 +#ifdef CONFIG_X86_64
21934 + this_cpu_write(kernel_stack, thread->sp0);
21935 +#endif
21936 +}
21937 +#endif
21938 diff --git a/arch/x86/kernel/process_32.c b/arch/x86/kernel/process_32.c
21939 index b5a8905..d9cacac 100644
21940 --- a/arch/x86/kernel/process_32.c
21941 +++ b/arch/x86/kernel/process_32.c
21942 @@ -65,6 +65,7 @@ asmlinkage void ret_from_kernel_thread(void) __asm__("ret_from_kernel_thread");
21943 unsigned long thread_saved_pc(struct task_struct *tsk)
21944 {
21945 return ((unsigned long *)tsk->thread.sp)[3];
21946 +//XXX return tsk->thread.eip;
21947 }
21948
21949 void __show_regs(struct pt_regs *regs, int all)
21950 @@ -74,21 +75,20 @@ void __show_regs(struct pt_regs *regs, int all)
21951 unsigned long sp;
21952 unsigned short ss, gs;
21953
21954 - if (user_mode_vm(regs)) {
21955 + if (user_mode(regs)) {
21956 sp = regs->sp;
21957 ss = regs->ss & 0xffff;
21958 - gs = get_user_gs(regs);
21959 } else {
21960 sp = kernel_stack_pointer(regs);
21961 savesegment(ss, ss);
21962 - savesegment(gs, gs);
21963 }
21964 + gs = get_user_gs(regs);
21965
21966 show_regs_common();
21967
21968 printk(KERN_DEFAULT "EIP: %04x:[<%08lx>] EFLAGS: %08lx CPU: %d\n",
21969 (u16)regs->cs, regs->ip, regs->flags,
21970 - smp_processor_id());
21971 + raw_smp_processor_id());
21972 print_symbol("EIP is at %s\n", regs->ip);
21973
21974 printk(KERN_DEFAULT "EAX: %08lx EBX: %08lx ECX: %08lx EDX: %08lx\n",
21975 @@ -130,20 +130,21 @@ void release_thread(struct task_struct *dead_task)
21976 int copy_thread(unsigned long clone_flags, unsigned long sp,
21977 unsigned long arg, struct task_struct *p)
21978 {
21979 - struct pt_regs *childregs = task_pt_regs(p);
21980 + struct pt_regs *childregs = task_stack_page(p) + THREAD_SIZE - sizeof(struct pt_regs) - 8;
21981 struct task_struct *tsk;
21982 int err;
21983
21984 p->thread.sp = (unsigned long) childregs;
21985 p->thread.sp0 = (unsigned long) (childregs+1);
21986 + p->tinfo.lowest_stack = (unsigned long)task_stack_page(p);
21987
21988 if (unlikely(p->flags & PF_KTHREAD)) {
21989 /* kernel thread */
21990 memset(childregs, 0, sizeof(struct pt_regs));
21991 p->thread.ip = (unsigned long) ret_from_kernel_thread;
21992 - task_user_gs(p) = __KERNEL_STACK_CANARY;
21993 - childregs->ds = __USER_DS;
21994 - childregs->es = __USER_DS;
21995 + savesegment(gs, childregs->gs);
21996 + childregs->ds = __KERNEL_DS;
21997 + childregs->es = __KERNEL_DS;
21998 childregs->fs = __KERNEL_PERCPU;
21999 childregs->bx = sp; /* function */
22000 childregs->bp = arg;
22001 @@ -250,7 +251,7 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
22002 struct thread_struct *prev = &prev_p->thread,
22003 *next = &next_p->thread;
22004 int cpu = smp_processor_id();
22005 - struct tss_struct *tss = &per_cpu(init_tss, cpu);
22006 + struct tss_struct *tss = init_tss + cpu;
22007 fpu_switch_t fpu;
22008
22009 /* never put a printk in __switch_to... printk() calls wake_up*() indirectly */
22010 @@ -274,6 +275,10 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
22011 */
22012 lazy_save_gs(prev->gs);
22013
22014 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22015 + __set_fs(task_thread_info(next_p)->addr_limit);
22016 +#endif
22017 +
22018 /*
22019 * Load the per-thread Thread-Local Storage descriptor.
22020 */
22021 @@ -304,6 +309,9 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
22022 */
22023 arch_end_context_switch(next_p);
22024
22025 + this_cpu_write(current_task, next_p);
22026 + this_cpu_write(current_tinfo, &next_p->tinfo);
22027 +
22028 /*
22029 * Restore %gs if needed (which is common)
22030 */
22031 @@ -312,8 +320,6 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
22032
22033 switch_fpu_finish(next_p, fpu);
22034
22035 - this_cpu_write(current_task, next_p);
22036 -
22037 return prev_p;
22038 }
22039
22040 @@ -343,4 +349,3 @@ unsigned long get_wchan(struct task_struct *p)
22041 } while (count++ < 16);
22042 return 0;
22043 }
22044 -
22045 diff --git a/arch/x86/kernel/process_64.c b/arch/x86/kernel/process_64.c
22046 index 6e68a61..955a9a5 100644
22047 --- a/arch/x86/kernel/process_64.c
22048 +++ b/arch/x86/kernel/process_64.c
22049 @@ -152,10 +152,11 @@ int copy_thread(unsigned long clone_flags, unsigned long sp,
22050 struct pt_regs *childregs;
22051 struct task_struct *me = current;
22052
22053 - p->thread.sp0 = (unsigned long)task_stack_page(p) + THREAD_SIZE;
22054 + p->thread.sp0 = (unsigned long)task_stack_page(p) + THREAD_SIZE - 16;
22055 childregs = task_pt_regs(p);
22056 p->thread.sp = (unsigned long) childregs;
22057 p->thread.usersp = me->thread.usersp;
22058 + p->tinfo.lowest_stack = (unsigned long)task_stack_page(p);
22059 set_tsk_thread_flag(p, TIF_FORK);
22060 p->fpu_counter = 0;
22061 p->thread.io_bitmap_ptr = NULL;
22062 @@ -274,7 +275,7 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
22063 struct thread_struct *prev = &prev_p->thread;
22064 struct thread_struct *next = &next_p->thread;
22065 int cpu = smp_processor_id();
22066 - struct tss_struct *tss = &per_cpu(init_tss, cpu);
22067 + struct tss_struct *tss = init_tss + cpu;
22068 unsigned fsindex, gsindex;
22069 fpu_switch_t fpu;
22070
22071 @@ -356,10 +357,9 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
22072 prev->usersp = this_cpu_read(old_rsp);
22073 this_cpu_write(old_rsp, next->usersp);
22074 this_cpu_write(current_task, next_p);
22075 + this_cpu_write(current_tinfo, &next_p->tinfo);
22076
22077 - this_cpu_write(kernel_stack,
22078 - (unsigned long)task_stack_page(next_p) +
22079 - THREAD_SIZE - KERNEL_STACK_OFFSET);
22080 + this_cpu_write(kernel_stack, next->sp0);
22081
22082 /*
22083 * Now maybe reload the debug registers and handle I/O bitmaps
22084 @@ -428,12 +428,11 @@ unsigned long get_wchan(struct task_struct *p)
22085 if (!p || p == current || p->state == TASK_RUNNING)
22086 return 0;
22087 stack = (unsigned long)task_stack_page(p);
22088 - if (p->thread.sp < stack || p->thread.sp >= stack+THREAD_SIZE)
22089 + if (p->thread.sp < stack || p->thread.sp > stack+THREAD_SIZE-16-sizeof(u64))
22090 return 0;
22091 fp = *(u64 *)(p->thread.sp);
22092 do {
22093 - if (fp < (unsigned long)stack ||
22094 - fp >= (unsigned long)stack+THREAD_SIZE)
22095 + if (fp < stack || fp > stack+THREAD_SIZE-16-sizeof(u64))
22096 return 0;
22097 ip = *(u64 *)(fp+8);
22098 if (!in_sched_functions(ip))
22099 diff --git a/arch/x86/kernel/ptrace.c b/arch/x86/kernel/ptrace.c
22100 index b629bbe..0fa615a 100644
22101 --- a/arch/x86/kernel/ptrace.c
22102 +++ b/arch/x86/kernel/ptrace.c
22103 @@ -184,14 +184,13 @@ unsigned long kernel_stack_pointer(struct pt_regs *regs)
22104 {
22105 unsigned long context = (unsigned long)regs & ~(THREAD_SIZE - 1);
22106 unsigned long sp = (unsigned long)&regs->sp;
22107 - struct thread_info *tinfo;
22108
22109 - if (context == (sp & ~(THREAD_SIZE - 1)))
22110 + if (context == ((sp + 8) & ~(THREAD_SIZE - 1)))
22111 return sp;
22112
22113 - tinfo = (struct thread_info *)context;
22114 - if (tinfo->previous_esp)
22115 - return tinfo->previous_esp;
22116 + sp = *(unsigned long *)context;
22117 + if (sp)
22118 + return sp;
22119
22120 return (unsigned long)regs;
22121 }
22122 @@ -588,7 +587,7 @@ static void ptrace_triggered(struct perf_event *bp,
22123 static unsigned long ptrace_get_dr7(struct perf_event *bp[])
22124 {
22125 int i;
22126 - int dr7 = 0;
22127 + unsigned long dr7 = 0;
22128 struct arch_hw_breakpoint *info;
22129
22130 for (i = 0; i < HBP_NUM; i++) {
22131 @@ -856,7 +855,7 @@ long arch_ptrace(struct task_struct *child, long request,
22132 unsigned long addr, unsigned long data)
22133 {
22134 int ret;
22135 - unsigned long __user *datap = (unsigned long __user *)data;
22136 + unsigned long __user *datap = (__force unsigned long __user *)data;
22137
22138 switch (request) {
22139 /* read the word at location addr in the USER area. */
22140 @@ -941,14 +940,14 @@ long arch_ptrace(struct task_struct *child, long request,
22141 if ((int) addr < 0)
22142 return -EIO;
22143 ret = do_get_thread_area(child, addr,
22144 - (struct user_desc __user *)data);
22145 + (__force struct user_desc __user *) data);
22146 break;
22147
22148 case PTRACE_SET_THREAD_AREA:
22149 if ((int) addr < 0)
22150 return -EIO;
22151 ret = do_set_thread_area(child, addr,
22152 - (struct user_desc __user *)data, 0);
22153 + (__force struct user_desc __user *) data, 0);
22154 break;
22155 #endif
22156
22157 @@ -1326,7 +1325,7 @@ long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
22158
22159 #ifdef CONFIG_X86_64
22160
22161 -static struct user_regset x86_64_regsets[] __read_mostly = {
22162 +static user_regset_no_const x86_64_regsets[] __read_only = {
22163 [REGSET_GENERAL] = {
22164 .core_note_type = NT_PRSTATUS,
22165 .n = sizeof(struct user_regs_struct) / sizeof(long),
22166 @@ -1367,7 +1366,7 @@ static const struct user_regset_view user_x86_64_view = {
22167 #endif /* CONFIG_X86_64 */
22168
22169 #if defined CONFIG_X86_32 || defined CONFIG_IA32_EMULATION
22170 -static struct user_regset x86_32_regsets[] __read_mostly = {
22171 +static user_regset_no_const x86_32_regsets[] __read_only = {
22172 [REGSET_GENERAL] = {
22173 .core_note_type = NT_PRSTATUS,
22174 .n = sizeof(struct user_regs_struct32) / sizeof(u32),
22175 @@ -1420,7 +1419,7 @@ static const struct user_regset_view user_x86_32_view = {
22176 */
22177 u64 xstate_fx_sw_bytes[USER_XSTATE_FX_SW_WORDS];
22178
22179 -void update_regset_xstate_info(unsigned int size, u64 xstate_mask)
22180 +void __init update_regset_xstate_info(unsigned int size, u64 xstate_mask)
22181 {
22182 #ifdef CONFIG_X86_64
22183 x86_64_regsets[REGSET_XSTATE].n = size / sizeof(u64);
22184 @@ -1455,7 +1454,7 @@ static void fill_sigtrap_info(struct task_struct *tsk,
22185 memset(info, 0, sizeof(*info));
22186 info->si_signo = SIGTRAP;
22187 info->si_code = si_code;
22188 - info->si_addr = user_mode_vm(regs) ? (void __user *)regs->ip : NULL;
22189 + info->si_addr = user_mode(regs) ? (__force void __user *)regs->ip : NULL;
22190 }
22191
22192 void user_single_step_siginfo(struct task_struct *tsk,
22193 @@ -1484,6 +1483,10 @@ void send_sigtrap(struct task_struct *tsk, struct pt_regs *regs,
22194 # define IS_IA32 0
22195 #endif
22196
22197 +#ifdef CONFIG_GRKERNSEC_SETXID
22198 +extern void gr_delayed_cred_worker(void);
22199 +#endif
22200 +
22201 /*
22202 * We must return the syscall number to actually look up in the table.
22203 * This can be -1L to skip running any syscall at all.
22204 @@ -1494,6 +1497,11 @@ long syscall_trace_enter(struct pt_regs *regs)
22205
22206 user_exit();
22207
22208 +#ifdef CONFIG_GRKERNSEC_SETXID
22209 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
22210 + gr_delayed_cred_worker();
22211 +#endif
22212 +
22213 /*
22214 * If we stepped into a sysenter/syscall insn, it trapped in
22215 * kernel mode; do_debug() cleared TF and set TIF_SINGLESTEP.
22216 @@ -1549,6 +1557,11 @@ void syscall_trace_leave(struct pt_regs *regs)
22217 */
22218 user_exit();
22219
22220 +#ifdef CONFIG_GRKERNSEC_SETXID
22221 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
22222 + gr_delayed_cred_worker();
22223 +#endif
22224 +
22225 audit_syscall_exit(regs);
22226
22227 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
22228 diff --git a/arch/x86/kernel/pvclock.c b/arch/x86/kernel/pvclock.c
22229 index 2cb9470..ff1fd80 100644
22230 --- a/arch/x86/kernel/pvclock.c
22231 +++ b/arch/x86/kernel/pvclock.c
22232 @@ -43,11 +43,11 @@ unsigned long pvclock_tsc_khz(struct pvclock_vcpu_time_info *src)
22233 return pv_tsc_khz;
22234 }
22235
22236 -static atomic64_t last_value = ATOMIC64_INIT(0);
22237 +static atomic64_unchecked_t last_value = ATOMIC64_INIT(0);
22238
22239 void pvclock_resume(void)
22240 {
22241 - atomic64_set(&last_value, 0);
22242 + atomic64_set_unchecked(&last_value, 0);
22243 }
22244
22245 u8 pvclock_read_flags(struct pvclock_vcpu_time_info *src)
22246 @@ -92,11 +92,11 @@ cycle_t pvclock_clocksource_read(struct pvclock_vcpu_time_info *src)
22247 * updating at the same time, and one of them could be slightly behind,
22248 * making the assumption that last_value always go forward fail to hold.
22249 */
22250 - last = atomic64_read(&last_value);
22251 + last = atomic64_read_unchecked(&last_value);
22252 do {
22253 if (ret < last)
22254 return last;
22255 - last = atomic64_cmpxchg(&last_value, last, ret);
22256 + last = atomic64_cmpxchg_unchecked(&last_value, last, ret);
22257 } while (unlikely(last != ret));
22258
22259 return ret;
22260 diff --git a/arch/x86/kernel/reboot.c b/arch/x86/kernel/reboot.c
22261 index 76fa1e9..abf09ea 100644
22262 --- a/arch/x86/kernel/reboot.c
22263 +++ b/arch/x86/kernel/reboot.c
22264 @@ -36,7 +36,7 @@ void (*pm_power_off)(void);
22265 EXPORT_SYMBOL(pm_power_off);
22266
22267 static const struct desc_ptr no_idt = {};
22268 -static int reboot_mode;
22269 +static unsigned short reboot_mode;
22270 enum reboot_type reboot_type = BOOT_ACPI;
22271 int reboot_force;
22272
22273 @@ -157,6 +157,11 @@ static int __init set_bios_reboot(const struct dmi_system_id *d)
22274
22275 void __noreturn machine_real_restart(unsigned int type)
22276 {
22277 +
22278 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF))
22279 + struct desc_struct *gdt;
22280 +#endif
22281 +
22282 local_irq_disable();
22283
22284 /*
22285 @@ -184,7 +189,29 @@ void __noreturn machine_real_restart(unsigned int type)
22286
22287 /* Jump to the identity-mapped low memory code */
22288 #ifdef CONFIG_X86_32
22289 - asm volatile("jmpl *%0" : :
22290 +
22291 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
22292 + gdt = get_cpu_gdt_table(smp_processor_id());
22293 + pax_open_kernel();
22294 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22295 + gdt[GDT_ENTRY_KERNEL_DS].type = 3;
22296 + gdt[GDT_ENTRY_KERNEL_DS].limit = 0xf;
22297 + loadsegment(ds, __KERNEL_DS);
22298 + loadsegment(es, __KERNEL_DS);
22299 + loadsegment(ss, __KERNEL_DS);
22300 +#endif
22301 +#ifdef CONFIG_PAX_KERNEXEC
22302 + gdt[GDT_ENTRY_KERNEL_CS].base0 = 0;
22303 + gdt[GDT_ENTRY_KERNEL_CS].base1 = 0;
22304 + gdt[GDT_ENTRY_KERNEL_CS].base2 = 0;
22305 + gdt[GDT_ENTRY_KERNEL_CS].limit0 = 0xffff;
22306 + gdt[GDT_ENTRY_KERNEL_CS].limit = 0xf;
22307 + gdt[GDT_ENTRY_KERNEL_CS].g = 1;
22308 +#endif
22309 + pax_close_kernel();
22310 +#endif
22311 +
22312 + asm volatile("ljmpl *%0" : :
22313 "rm" (real_mode_header->machine_real_restart_asm),
22314 "a" (type));
22315 #else
22316 @@ -531,7 +558,7 @@ void __attribute__((weak)) mach_reboot_fixups(void)
22317 * try to force a triple fault and then cycle between hitting the keyboard
22318 * controller and doing that
22319 */
22320 -static void native_machine_emergency_restart(void)
22321 +static void __noreturn native_machine_emergency_restart(void)
22322 {
22323 int i;
22324 int attempt = 0;
22325 @@ -654,13 +681,13 @@ void native_machine_shutdown(void)
22326 #endif
22327 }
22328
22329 -static void __machine_emergency_restart(int emergency)
22330 +static void __noreturn __machine_emergency_restart(int emergency)
22331 {
22332 reboot_emergency = emergency;
22333 machine_ops.emergency_restart();
22334 }
22335
22336 -static void native_machine_restart(char *__unused)
22337 +static void __noreturn native_machine_restart(char *__unused)
22338 {
22339 pr_notice("machine restart\n");
22340
22341 @@ -669,7 +696,7 @@ static void native_machine_restart(char *__unused)
22342 __machine_emergency_restart(0);
22343 }
22344
22345 -static void native_machine_halt(void)
22346 +static void __noreturn native_machine_halt(void)
22347 {
22348 /* Stop other cpus and apics */
22349 machine_shutdown();
22350 @@ -679,7 +706,7 @@ static void native_machine_halt(void)
22351 stop_this_cpu(NULL);
22352 }
22353
22354 -static void native_machine_power_off(void)
22355 +static void __noreturn native_machine_power_off(void)
22356 {
22357 if (pm_power_off) {
22358 if (!reboot_force)
22359 @@ -688,9 +715,10 @@ static void native_machine_power_off(void)
22360 }
22361 /* A fallback in case there is no PM info available */
22362 tboot_shutdown(TB_SHUTDOWN_HALT);
22363 + unreachable();
22364 }
22365
22366 -struct machine_ops machine_ops = {
22367 +struct machine_ops machine_ops __read_only = {
22368 .power_off = native_machine_power_off,
22369 .shutdown = native_machine_shutdown,
22370 .emergency_restart = native_machine_emergency_restart,
22371 diff --git a/arch/x86/kernel/relocate_kernel_64.S b/arch/x86/kernel/relocate_kernel_64.S
22372 index 7a6f3b3..bed145d7 100644
22373 --- a/arch/x86/kernel/relocate_kernel_64.S
22374 +++ b/arch/x86/kernel/relocate_kernel_64.S
22375 @@ -11,6 +11,7 @@
22376 #include <asm/kexec.h>
22377 #include <asm/processor-flags.h>
22378 #include <asm/pgtable_types.h>
22379 +#include <asm/alternative-asm.h>
22380
22381 /*
22382 * Must be relocatable PIC code callable as a C function
22383 @@ -160,13 +161,14 @@ identity_mapped:
22384 xorq %rbp, %rbp
22385 xorq %r8, %r8
22386 xorq %r9, %r9
22387 - xorq %r10, %r9
22388 + xorq %r10, %r10
22389 xorq %r11, %r11
22390 xorq %r12, %r12
22391 xorq %r13, %r13
22392 xorq %r14, %r14
22393 xorq %r15, %r15
22394
22395 + pax_force_retaddr 0, 1
22396 ret
22397
22398 1:
22399 diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
22400 index 8b24289..d37b58b 100644
22401 --- a/arch/x86/kernel/setup.c
22402 +++ b/arch/x86/kernel/setup.c
22403 @@ -437,7 +437,7 @@ static void __init parse_setup_data(void)
22404
22405 switch (data->type) {
22406 case SETUP_E820_EXT:
22407 - parse_e820_ext(data);
22408 + parse_e820_ext((struct setup_data __force_kernel *)data);
22409 break;
22410 case SETUP_DTB:
22411 add_dtb(pa_data);
22412 @@ -706,7 +706,7 @@ static void __init trim_bios_range(void)
22413 * area (640->1Mb) as ram even though it is not.
22414 * take them out.
22415 */
22416 - e820_remove_range(BIOS_BEGIN, BIOS_END - BIOS_BEGIN, E820_RAM, 1);
22417 + e820_remove_range(ISA_START_ADDRESS, ISA_END_ADDRESS - ISA_START_ADDRESS, E820_RAM, 1);
22418
22419 sanitize_e820_map(e820.map, ARRAY_SIZE(e820.map), &e820.nr_map);
22420 }
22421 @@ -830,14 +830,14 @@ void __init setup_arch(char **cmdline_p)
22422
22423 if (!boot_params.hdr.root_flags)
22424 root_mountflags &= ~MS_RDONLY;
22425 - init_mm.start_code = (unsigned long) _text;
22426 - init_mm.end_code = (unsigned long) _etext;
22427 + init_mm.start_code = ktla_ktva((unsigned long) _text);
22428 + init_mm.end_code = ktla_ktva((unsigned long) _etext);
22429 init_mm.end_data = (unsigned long) _edata;
22430 init_mm.brk = _brk_end;
22431
22432 - code_resource.start = virt_to_phys(_text);
22433 - code_resource.end = virt_to_phys(_etext)-1;
22434 - data_resource.start = virt_to_phys(_etext);
22435 + code_resource.start = virt_to_phys(ktla_ktva(_text));
22436 + code_resource.end = virt_to_phys(ktla_ktva(_etext))-1;
22437 + data_resource.start = virt_to_phys(_sdata);
22438 data_resource.end = virt_to_phys(_edata)-1;
22439 bss_resource.start = virt_to_phys(&__bss_start);
22440 bss_resource.end = virt_to_phys(&__bss_stop)-1;
22441 diff --git a/arch/x86/kernel/setup_percpu.c b/arch/x86/kernel/setup_percpu.c
22442 index 5cdff03..80fa283 100644
22443 --- a/arch/x86/kernel/setup_percpu.c
22444 +++ b/arch/x86/kernel/setup_percpu.c
22445 @@ -21,19 +21,17 @@
22446 #include <asm/cpu.h>
22447 #include <asm/stackprotector.h>
22448
22449 -DEFINE_PER_CPU_READ_MOSTLY(int, cpu_number);
22450 +#ifdef CONFIG_SMP
22451 +DEFINE_PER_CPU_READ_MOSTLY(unsigned int, cpu_number);
22452 EXPORT_PER_CPU_SYMBOL(cpu_number);
22453 +#endif
22454
22455 -#ifdef CONFIG_X86_64
22456 #define BOOT_PERCPU_OFFSET ((unsigned long)__per_cpu_load)
22457 -#else
22458 -#define BOOT_PERCPU_OFFSET 0
22459 -#endif
22460
22461 DEFINE_PER_CPU(unsigned long, this_cpu_off) = BOOT_PERCPU_OFFSET;
22462 EXPORT_PER_CPU_SYMBOL(this_cpu_off);
22463
22464 -unsigned long __per_cpu_offset[NR_CPUS] __read_mostly = {
22465 +unsigned long __per_cpu_offset[NR_CPUS] __read_only = {
22466 [0 ... NR_CPUS-1] = BOOT_PERCPU_OFFSET,
22467 };
22468 EXPORT_SYMBOL(__per_cpu_offset);
22469 @@ -66,7 +64,7 @@ static bool __init pcpu_need_numa(void)
22470 {
22471 #ifdef CONFIG_NEED_MULTIPLE_NODES
22472 pg_data_t *last = NULL;
22473 - unsigned int cpu;
22474 + int cpu;
22475
22476 for_each_possible_cpu(cpu) {
22477 int node = early_cpu_to_node(cpu);
22478 @@ -155,10 +153,10 @@ static inline void setup_percpu_segment(int cpu)
22479 {
22480 #ifdef CONFIG_X86_32
22481 struct desc_struct gdt;
22482 + unsigned long base = per_cpu_offset(cpu);
22483
22484 - pack_descriptor(&gdt, per_cpu_offset(cpu), 0xFFFFF,
22485 - 0x2 | DESCTYPE_S, 0x8);
22486 - gdt.s = 1;
22487 + pack_descriptor(&gdt, base, (VMALLOC_END - base - 1) >> PAGE_SHIFT,
22488 + 0x83 | DESCTYPE_S, 0xC);
22489 write_gdt_entry(get_cpu_gdt_table(cpu),
22490 GDT_ENTRY_PERCPU, &gdt, DESCTYPE_S);
22491 #endif
22492 @@ -219,6 +217,11 @@ void __init setup_per_cpu_areas(void)
22493 /* alrighty, percpu areas up and running */
22494 delta = (unsigned long)pcpu_base_addr - (unsigned long)__per_cpu_start;
22495 for_each_possible_cpu(cpu) {
22496 +#ifdef CONFIG_CC_STACKPROTECTOR
22497 +#ifdef CONFIG_X86_32
22498 + unsigned long canary = per_cpu(stack_canary.canary, cpu);
22499 +#endif
22500 +#endif
22501 per_cpu_offset(cpu) = delta + pcpu_unit_offsets[cpu];
22502 per_cpu(this_cpu_off, cpu) = per_cpu_offset(cpu);
22503 per_cpu(cpu_number, cpu) = cpu;
22504 @@ -259,6 +262,12 @@ void __init setup_per_cpu_areas(void)
22505 */
22506 set_cpu_numa_node(cpu, early_cpu_to_node(cpu));
22507 #endif
22508 +#ifdef CONFIG_CC_STACKPROTECTOR
22509 +#ifdef CONFIG_X86_32
22510 + if (!cpu)
22511 + per_cpu(stack_canary.canary, cpu) = canary;
22512 +#endif
22513 +#endif
22514 /*
22515 * Up to this point, the boot CPU has been using .init.data
22516 * area. Reload any changed state for the boot CPU.
22517 diff --git a/arch/x86/kernel/signal.c b/arch/x86/kernel/signal.c
22518 index d6bf1f3..3ffce5a 100644
22519 --- a/arch/x86/kernel/signal.c
22520 +++ b/arch/x86/kernel/signal.c
22521 @@ -196,7 +196,7 @@ static unsigned long align_sigframe(unsigned long sp)
22522 * Align the stack pointer according to the i386 ABI,
22523 * i.e. so that on function entry ((sp + 4) & 15) == 0.
22524 */
22525 - sp = ((sp + 4) & -16ul) - 4;
22526 + sp = ((sp - 12) & -16ul) - 4;
22527 #else /* !CONFIG_X86_32 */
22528 sp = round_down(sp, 16) - 8;
22529 #endif
22530 @@ -304,9 +304,9 @@ __setup_frame(int sig, struct k_sigaction *ka, sigset_t *set,
22531 }
22532
22533 if (current->mm->context.vdso)
22534 - restorer = VDSO32_SYMBOL(current->mm->context.vdso, sigreturn);
22535 + restorer = (__force void __user *)VDSO32_SYMBOL(current->mm->context.vdso, sigreturn);
22536 else
22537 - restorer = &frame->retcode;
22538 + restorer = (void __user *)&frame->retcode;
22539 if (ka->sa.sa_flags & SA_RESTORER)
22540 restorer = ka->sa.sa_restorer;
22541
22542 @@ -320,7 +320,7 @@ __setup_frame(int sig, struct k_sigaction *ka, sigset_t *set,
22543 * reasons and because gdb uses it as a signature to notice
22544 * signal handler stack frames.
22545 */
22546 - err |= __put_user(*((u64 *)&retcode), (u64 *)frame->retcode);
22547 + err |= __put_user(*((u64 *)&retcode), (u64 __user *)frame->retcode);
22548
22549 if (err)
22550 return -EFAULT;
22551 @@ -367,7 +367,10 @@ static int __setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
22552 err |= __save_altstack(&frame->uc.uc_stack, regs->sp);
22553
22554 /* Set up to return from userspace. */
22555 - restorer = VDSO32_SYMBOL(current->mm->context.vdso, rt_sigreturn);
22556 + if (current->mm->context.vdso)
22557 + restorer = (__force void __user *)VDSO32_SYMBOL(current->mm->context.vdso, rt_sigreturn);
22558 + else
22559 + restorer = (void __user *)&frame->retcode;
22560 if (ka->sa.sa_flags & SA_RESTORER)
22561 restorer = ka->sa.sa_restorer;
22562 put_user_ex(restorer, &frame->pretcode);
22563 @@ -379,7 +382,7 @@ static int __setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
22564 * reasons and because gdb uses it as a signature to notice
22565 * signal handler stack frames.
22566 */
22567 - put_user_ex(*((u64 *)&rt_retcode), (u64 *)frame->retcode);
22568 + put_user_ex(*((u64 *)&rt_retcode), (u64 __user *)frame->retcode);
22569 } put_user_catch(err);
22570
22571 err |= copy_siginfo_to_user(&frame->info, info);
22572 diff --git a/arch/x86/kernel/smp.c b/arch/x86/kernel/smp.c
22573 index 48d2b7d..90d328a 100644
22574 --- a/arch/x86/kernel/smp.c
22575 +++ b/arch/x86/kernel/smp.c
22576 @@ -285,7 +285,7 @@ static int __init nonmi_ipi_setup(char *str)
22577
22578 __setup("nonmi_ipi", nonmi_ipi_setup);
22579
22580 -struct smp_ops smp_ops = {
22581 +struct smp_ops smp_ops __read_only = {
22582 .smp_prepare_boot_cpu = native_smp_prepare_boot_cpu,
22583 .smp_prepare_cpus = native_smp_prepare_cpus,
22584 .smp_cpus_done = native_smp_cpus_done,
22585 diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
22586 index ed0fe38..87fc692 100644
22587 --- a/arch/x86/kernel/smpboot.c
22588 +++ b/arch/x86/kernel/smpboot.c
22589 @@ -748,6 +748,7 @@ static int __cpuinit do_boot_cpu(int apicid, int cpu, struct task_struct *idle)
22590 idle->thread.sp = (unsigned long) (((struct pt_regs *)
22591 (THREAD_SIZE + task_stack_page(idle))) - 1);
22592 per_cpu(current_task, cpu) = idle;
22593 + per_cpu(current_tinfo, cpu) = &idle->tinfo;
22594
22595 #ifdef CONFIG_X86_32
22596 /* Stack for startup_32 can be just as for start_secondary onwards */
22597 @@ -755,11 +756,13 @@ static int __cpuinit do_boot_cpu(int apicid, int cpu, struct task_struct *idle)
22598 #else
22599 clear_tsk_thread_flag(idle, TIF_FORK);
22600 initial_gs = per_cpu_offset(cpu);
22601 - per_cpu(kernel_stack, cpu) =
22602 - (unsigned long)task_stack_page(idle) -
22603 - KERNEL_STACK_OFFSET + THREAD_SIZE;
22604 + per_cpu(kernel_stack, cpu) = (unsigned long)task_stack_page(idle) - 16 + THREAD_SIZE;
22605 #endif
22606 +
22607 + pax_open_kernel();
22608 early_gdt_descr.address = (unsigned long)get_cpu_gdt_table(cpu);
22609 + pax_close_kernel();
22610 +
22611 initial_code = (unsigned long)start_secondary;
22612 stack_start = idle->thread.sp;
22613
22614 @@ -908,6 +911,15 @@ int __cpuinit native_cpu_up(unsigned int cpu, struct task_struct *tidle)
22615 /* the FPU context is blank, nobody can own it */
22616 __cpu_disable_lazy_restore(cpu);
22617
22618 +#ifdef CONFIG_PAX_PER_CPU_PGD
22619 + clone_pgd_range(get_cpu_pgd(cpu) + KERNEL_PGD_BOUNDARY,
22620 + swapper_pg_dir + KERNEL_PGD_BOUNDARY,
22621 + KERNEL_PGD_PTRS);
22622 +#endif
22623 +
22624 + /* the FPU context is blank, nobody can own it */
22625 + __cpu_disable_lazy_restore(cpu);
22626 +
22627 err = do_boot_cpu(apicid, cpu, tidle);
22628 if (err) {
22629 pr_debug("do_boot_cpu failed %d\n", err);
22630 diff --git a/arch/x86/kernel/step.c b/arch/x86/kernel/step.c
22631 index 9b4d51d..5d28b58 100644
22632 --- a/arch/x86/kernel/step.c
22633 +++ b/arch/x86/kernel/step.c
22634 @@ -27,10 +27,10 @@ unsigned long convert_ip_to_linear(struct task_struct *child, struct pt_regs *re
22635 struct desc_struct *desc;
22636 unsigned long base;
22637
22638 - seg &= ~7UL;
22639 + seg >>= 3;
22640
22641 mutex_lock(&child->mm->context.lock);
22642 - if (unlikely((seg >> 3) >= child->mm->context.size))
22643 + if (unlikely(seg >= child->mm->context.size))
22644 addr = -1L; /* bogus selector, access would fault */
22645 else {
22646 desc = child->mm->context.ldt + seg;
22647 @@ -42,7 +42,8 @@ unsigned long convert_ip_to_linear(struct task_struct *child, struct pt_regs *re
22648 addr += base;
22649 }
22650 mutex_unlock(&child->mm->context.lock);
22651 - }
22652 + } else if (seg == __KERNEL_CS || seg == __KERNEXEC_KERNEL_CS)
22653 + addr = ktla_ktva(addr);
22654
22655 return addr;
22656 }
22657 @@ -53,6 +54,9 @@ static int is_setting_trap_flag(struct task_struct *child, struct pt_regs *regs)
22658 unsigned char opcode[15];
22659 unsigned long addr = convert_ip_to_linear(child, regs);
22660
22661 + if (addr == -EINVAL)
22662 + return 0;
22663 +
22664 copied = access_process_vm(child, addr, opcode, sizeof(opcode), 0);
22665 for (i = 0; i < copied; i++) {
22666 switch (opcode[i]) {
22667 diff --git a/arch/x86/kernel/sys_i386_32.c b/arch/x86/kernel/sys_i386_32.c
22668 new file mode 100644
22669 index 0000000..207bec6
22670 --- /dev/null
22671 +++ b/arch/x86/kernel/sys_i386_32.c
22672 @@ -0,0 +1,250 @@
22673 +/*
22674 + * This file contains various random system calls that
22675 + * have a non-standard calling sequence on the Linux/i386
22676 + * platform.
22677 + */
22678 +
22679 +#include <linux/errno.h>
22680 +#include <linux/sched.h>
22681 +#include <linux/mm.h>
22682 +#include <linux/fs.h>
22683 +#include <linux/smp.h>
22684 +#include <linux/sem.h>
22685 +#include <linux/msg.h>
22686 +#include <linux/shm.h>
22687 +#include <linux/stat.h>
22688 +#include <linux/syscalls.h>
22689 +#include <linux/mman.h>
22690 +#include <linux/file.h>
22691 +#include <linux/utsname.h>
22692 +#include <linux/ipc.h>
22693 +
22694 +#include <linux/uaccess.h>
22695 +#include <linux/unistd.h>
22696 +
22697 +#include <asm/syscalls.h>
22698 +
22699 +int i386_mmap_check(unsigned long addr, unsigned long len, unsigned long flags)
22700 +{
22701 + unsigned long pax_task_size = TASK_SIZE;
22702 +
22703 +#ifdef CONFIG_PAX_SEGMEXEC
22704 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC)
22705 + pax_task_size = SEGMEXEC_TASK_SIZE;
22706 +#endif
22707 +
22708 + if (flags & MAP_FIXED)
22709 + if (len > pax_task_size || addr > pax_task_size - len)
22710 + return -EINVAL;
22711 +
22712 + return 0;
22713 +}
22714 +
22715 +unsigned long
22716 +arch_get_unmapped_area(struct file *filp, unsigned long addr,
22717 + unsigned long len, unsigned long pgoff, unsigned long flags)
22718 +{
22719 + struct mm_struct *mm = current->mm;
22720 + struct vm_area_struct *vma;
22721 + unsigned long start_addr, pax_task_size = TASK_SIZE;
22722 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
22723 +
22724 +#ifdef CONFIG_PAX_SEGMEXEC
22725 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
22726 + pax_task_size = SEGMEXEC_TASK_SIZE;
22727 +#endif
22728 +
22729 + pax_task_size -= PAGE_SIZE;
22730 +
22731 + if (len > pax_task_size)
22732 + return -ENOMEM;
22733 +
22734 + if (flags & MAP_FIXED)
22735 + return addr;
22736 +
22737 +#ifdef CONFIG_PAX_RANDMMAP
22738 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
22739 +#endif
22740 +
22741 + if (addr) {
22742 + addr = PAGE_ALIGN(addr);
22743 + if (pax_task_size - len >= addr) {
22744 + vma = find_vma(mm, addr);
22745 + if (check_heap_stack_gap(vma, addr, len, offset))
22746 + return addr;
22747 + }
22748 + }
22749 + if (len > mm->cached_hole_size) {
22750 + start_addr = addr = mm->free_area_cache;
22751 + } else {
22752 + start_addr = addr = mm->mmap_base;
22753 + mm->cached_hole_size = 0;
22754 + }
22755 +
22756 +#ifdef CONFIG_PAX_PAGEEXEC
22757 + if (!(__supported_pte_mask & _PAGE_NX) && (mm->pax_flags & MF_PAX_PAGEEXEC) && (flags & MAP_EXECUTABLE) && start_addr >= mm->mmap_base) {
22758 + start_addr = 0x00110000UL;
22759 +
22760 +#ifdef CONFIG_PAX_RANDMMAP
22761 + if (mm->pax_flags & MF_PAX_RANDMMAP)
22762 + start_addr += mm->delta_mmap & 0x03FFF000UL;
22763 +#endif
22764 +
22765 + if (mm->start_brk <= start_addr && start_addr < mm->mmap_base)
22766 + start_addr = addr = mm->mmap_base;
22767 + else
22768 + addr = start_addr;
22769 + }
22770 +#endif
22771 +
22772 +full_search:
22773 + for (vma = find_vma(mm, addr); ; vma = vma->vm_next) {
22774 + /* At this point: (!vma || addr < vma->vm_end). */
22775 + if (pax_task_size - len < addr) {
22776 + /*
22777 + * Start a new search - just in case we missed
22778 + * some holes.
22779 + */
22780 + if (start_addr != mm->mmap_base) {
22781 + start_addr = addr = mm->mmap_base;
22782 + mm->cached_hole_size = 0;
22783 + goto full_search;
22784 + }
22785 + return -ENOMEM;
22786 + }
22787 + if (check_heap_stack_gap(vma, addr, len, offset))
22788 + break;
22789 + if (addr + mm->cached_hole_size < vma->vm_start)
22790 + mm->cached_hole_size = vma->vm_start - addr;
22791 + addr = vma->vm_end;
22792 + if (mm->start_brk <= addr && addr < mm->mmap_base) {
22793 + start_addr = addr = mm->mmap_base;
22794 + mm->cached_hole_size = 0;
22795 + goto full_search;
22796 + }
22797 + }
22798 +
22799 + /*
22800 + * Remember the place where we stopped the search:
22801 + */
22802 + mm->free_area_cache = addr + len;
22803 + return addr;
22804 +}
22805 +
22806 +unsigned long
22807 +arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
22808 + const unsigned long len, const unsigned long pgoff,
22809 + const unsigned long flags)
22810 +{
22811 + struct vm_area_struct *vma;
22812 + struct mm_struct *mm = current->mm;
22813 + unsigned long base = mm->mmap_base, addr = addr0, pax_task_size = TASK_SIZE;
22814 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
22815 +
22816 +#ifdef CONFIG_PAX_SEGMEXEC
22817 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
22818 + pax_task_size = SEGMEXEC_TASK_SIZE;
22819 +#endif
22820 +
22821 + pax_task_size -= PAGE_SIZE;
22822 +
22823 + /* requested length too big for entire address space */
22824 + if (len > pax_task_size)
22825 + return -ENOMEM;
22826 +
22827 + if (flags & MAP_FIXED)
22828 + return addr;
22829 +
22830 +#ifdef CONFIG_PAX_PAGEEXEC
22831 + if (!(__supported_pte_mask & _PAGE_NX) && (mm->pax_flags & MF_PAX_PAGEEXEC) && (flags & MAP_EXECUTABLE))
22832 + goto bottomup;
22833 +#endif
22834 +
22835 +#ifdef CONFIG_PAX_RANDMMAP
22836 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
22837 +#endif
22838 +
22839 + /* requesting a specific address */
22840 + if (addr) {
22841 + addr = PAGE_ALIGN(addr);
22842 + if (pax_task_size - len >= addr) {
22843 + vma = find_vma(mm, addr);
22844 + if (check_heap_stack_gap(vma, addr, len, offset))
22845 + return addr;
22846 + }
22847 + }
22848 +
22849 + /* check if free_area_cache is useful for us */
22850 + if (len <= mm->cached_hole_size) {
22851 + mm->cached_hole_size = 0;
22852 + mm->free_area_cache = mm->mmap_base;
22853 + }
22854 +
22855 + /* either no address requested or can't fit in requested address hole */
22856 + addr = mm->free_area_cache;
22857 +
22858 + /* make sure it can fit in the remaining address space */
22859 + if (addr > len) {
22860 + vma = find_vma(mm, addr-len);
22861 + if (check_heap_stack_gap(vma, addr - len, len, offset))
22862 + /* remember the address as a hint for next time */
22863 + return (mm->free_area_cache = addr-len);
22864 + }
22865 +
22866 + if (mm->mmap_base < len)
22867 + goto bottomup;
22868 +
22869 + addr = mm->mmap_base-len;
22870 +
22871 + do {
22872 + /*
22873 + * Lookup failure means no vma is above this address,
22874 + * else if new region fits below vma->vm_start,
22875 + * return with success:
22876 + */
22877 + vma = find_vma(mm, addr);
22878 + if (check_heap_stack_gap(vma, addr, len, offset))
22879 + /* remember the address as a hint for next time */
22880 + return (mm->free_area_cache = addr);
22881 +
22882 + /* remember the largest hole we saw so far */
22883 + if (addr + mm->cached_hole_size < vma->vm_start)
22884 + mm->cached_hole_size = vma->vm_start - addr;
22885 +
22886 + /* try just below the current vma->vm_start */
22887 + addr = skip_heap_stack_gap(vma, len, offset);
22888 + } while (!IS_ERR_VALUE(addr));
22889 +
22890 +bottomup:
22891 + /*
22892 + * A failed mmap() very likely causes application failure,
22893 + * so fall back to the bottom-up function here. This scenario
22894 + * can happen with large stack limits and large mmap()
22895 + * allocations.
22896 + */
22897 +
22898 +#ifdef CONFIG_PAX_SEGMEXEC
22899 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
22900 + mm->mmap_base = SEGMEXEC_TASK_UNMAPPED_BASE;
22901 + else
22902 +#endif
22903 +
22904 + mm->mmap_base = TASK_UNMAPPED_BASE;
22905 +
22906 +#ifdef CONFIG_PAX_RANDMMAP
22907 + if (mm->pax_flags & MF_PAX_RANDMMAP)
22908 + mm->mmap_base += mm->delta_mmap;
22909 +#endif
22910 +
22911 + mm->free_area_cache = mm->mmap_base;
22912 + mm->cached_hole_size = ~0UL;
22913 + addr = arch_get_unmapped_area(filp, addr0, len, pgoff, flags);
22914 + /*
22915 + * Restore the topdown base:
22916 + */
22917 + mm->mmap_base = base;
22918 + mm->free_area_cache = base;
22919 + mm->cached_hole_size = ~0UL;
22920 +
22921 + return addr;
22922 +}
22923 diff --git a/arch/x86/kernel/sys_x86_64.c b/arch/x86/kernel/sys_x86_64.c
22924 index 97ef74b..57a1882 100644
22925 --- a/arch/x86/kernel/sys_x86_64.c
22926 +++ b/arch/x86/kernel/sys_x86_64.c
22927 @@ -81,8 +81,8 @@ out:
22928 return error;
22929 }
22930
22931 -static void find_start_end(unsigned long flags, unsigned long *begin,
22932 - unsigned long *end)
22933 +static void find_start_end(struct mm_struct *mm, unsigned long flags,
22934 + unsigned long *begin, unsigned long *end)
22935 {
22936 if (!test_thread_flag(TIF_ADDR32) && (flags & MAP_32BIT)) {
22937 unsigned long new_begin;
22938 @@ -101,7 +101,7 @@ static void find_start_end(unsigned long flags, unsigned long *begin,
22939 *begin = new_begin;
22940 }
22941 } else {
22942 - *begin = TASK_UNMAPPED_BASE;
22943 + *begin = mm->mmap_base;
22944 *end = TASK_SIZE;
22945 }
22946 }
22947 @@ -114,20 +114,24 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
22948 struct vm_area_struct *vma;
22949 struct vm_unmapped_area_info info;
22950 unsigned long begin, end;
22951 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
22952
22953 if (flags & MAP_FIXED)
22954 return addr;
22955
22956 - find_start_end(flags, &begin, &end);
22957 + find_start_end(mm, flags, &begin, &end);
22958
22959 if (len > end)
22960 return -ENOMEM;
22961
22962 +#ifdef CONFIG_PAX_RANDMMAP
22963 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
22964 +#endif
22965 +
22966 if (addr) {
22967 addr = PAGE_ALIGN(addr);
22968 vma = find_vma(mm, addr);
22969 - if (end - len >= addr &&
22970 - (!vma || addr + len <= vma->vm_start))
22971 + if (end - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
22972 return addr;
22973 }
22974
22975 @@ -161,6 +165,10 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
22976 if (!test_thread_flag(TIF_ADDR32) && (flags & MAP_32BIT))
22977 goto bottomup;
22978
22979 +#ifdef CONFIG_PAX_RANDMMAP
22980 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
22981 +#endif
22982 +
22983 /* requesting a specific address */
22984 if (addr) {
22985 addr = PAGE_ALIGN(addr);
22986 diff --git a/arch/x86/kernel/tboot.c b/arch/x86/kernel/tboot.c
22987 index f84fe00..f41d9f1 100644
22988 --- a/arch/x86/kernel/tboot.c
22989 +++ b/arch/x86/kernel/tboot.c
22990 @@ -220,7 +220,7 @@ static int tboot_setup_sleep(void)
22991
22992 void tboot_shutdown(u32 shutdown_type)
22993 {
22994 - void (*shutdown)(void);
22995 + void (* __noreturn shutdown)(void);
22996
22997 if (!tboot_enabled())
22998 return;
22999 @@ -242,7 +242,7 @@ void tboot_shutdown(u32 shutdown_type)
23000
23001 switch_to_tboot_pt();
23002
23003 - shutdown = (void(*)(void))(unsigned long)tboot->shutdown_entry;
23004 + shutdown = (void *)tboot->shutdown_entry;
23005 shutdown();
23006
23007 /* should not reach here */
23008 @@ -300,7 +300,7 @@ static int tboot_sleep(u8 sleep_state, u32 pm1a_control, u32 pm1b_control)
23009 return 0;
23010 }
23011
23012 -static atomic_t ap_wfs_count;
23013 +static atomic_unchecked_t ap_wfs_count;
23014
23015 static int tboot_wait_for_aps(int num_aps)
23016 {
23017 @@ -324,16 +324,16 @@ static int __cpuinit tboot_cpu_callback(struct notifier_block *nfb,
23018 {
23019 switch (action) {
23020 case CPU_DYING:
23021 - atomic_inc(&ap_wfs_count);
23022 + atomic_inc_unchecked(&ap_wfs_count);
23023 if (num_online_cpus() == 1)
23024 - if (tboot_wait_for_aps(atomic_read(&ap_wfs_count)))
23025 + if (tboot_wait_for_aps(atomic_read_unchecked(&ap_wfs_count)))
23026 return NOTIFY_BAD;
23027 break;
23028 }
23029 return NOTIFY_OK;
23030 }
23031
23032 -static struct notifier_block tboot_cpu_notifier __cpuinitdata =
23033 +static struct notifier_block tboot_cpu_notifier =
23034 {
23035 .notifier_call = tboot_cpu_callback,
23036 };
23037 @@ -345,7 +345,7 @@ static __init int tboot_late_init(void)
23038
23039 tboot_create_trampoline();
23040
23041 - atomic_set(&ap_wfs_count, 0);
23042 + atomic_set_unchecked(&ap_wfs_count, 0);
23043 register_hotcpu_notifier(&tboot_cpu_notifier);
23044
23045 acpi_os_set_prepare_sleep(&tboot_sleep);
23046 diff --git a/arch/x86/kernel/time.c b/arch/x86/kernel/time.c
23047 index 24d3c91..d06b473 100644
23048 --- a/arch/x86/kernel/time.c
23049 +++ b/arch/x86/kernel/time.c
23050 @@ -30,9 +30,9 @@ unsigned long profile_pc(struct pt_regs *regs)
23051 {
23052 unsigned long pc = instruction_pointer(regs);
23053
23054 - if (!user_mode_vm(regs) && in_lock_functions(pc)) {
23055 + if (!user_mode(regs) && in_lock_functions(pc)) {
23056 #ifdef CONFIG_FRAME_POINTER
23057 - return *(unsigned long *)(regs->bp + sizeof(long));
23058 + return ktla_ktva(*(unsigned long *)(regs->bp + sizeof(long)));
23059 #else
23060 unsigned long *sp =
23061 (unsigned long *)kernel_stack_pointer(regs);
23062 @@ -41,11 +41,17 @@ unsigned long profile_pc(struct pt_regs *regs)
23063 * or above a saved flags. Eflags has bits 22-31 zero,
23064 * kernel addresses don't.
23065 */
23066 +
23067 +#ifdef CONFIG_PAX_KERNEXEC
23068 + return ktla_ktva(sp[0]);
23069 +#else
23070 if (sp[0] >> 22)
23071 return sp[0];
23072 if (sp[1] >> 22)
23073 return sp[1];
23074 #endif
23075 +
23076 +#endif
23077 }
23078 return pc;
23079 }
23080 diff --git a/arch/x86/kernel/tls.c b/arch/x86/kernel/tls.c
23081 index 9d9d2f9..cad418a 100644
23082 --- a/arch/x86/kernel/tls.c
23083 +++ b/arch/x86/kernel/tls.c
23084 @@ -84,6 +84,11 @@ int do_set_thread_area(struct task_struct *p, int idx,
23085 if (idx < GDT_ENTRY_TLS_MIN || idx > GDT_ENTRY_TLS_MAX)
23086 return -EINVAL;
23087
23088 +#ifdef CONFIG_PAX_SEGMEXEC
23089 + if ((p->mm->pax_flags & MF_PAX_SEGMEXEC) && (info.contents & MODIFY_LDT_CONTENTS_CODE))
23090 + return -EINVAL;
23091 +#endif
23092 +
23093 set_tls_desc(p, idx, &info, 1);
23094
23095 return 0;
23096 @@ -204,7 +209,7 @@ int regset_tls_set(struct task_struct *target, const struct user_regset *regset,
23097
23098 if (kbuf)
23099 info = kbuf;
23100 - else if (__copy_from_user(infobuf, ubuf, count))
23101 + else if (count > sizeof infobuf || __copy_from_user(infobuf, ubuf, count))
23102 return -EFAULT;
23103 else
23104 info = infobuf;
23105 diff --git a/arch/x86/kernel/traps.c b/arch/x86/kernel/traps.c
23106 index ecffca1..95c4d13 100644
23107 --- a/arch/x86/kernel/traps.c
23108 +++ b/arch/x86/kernel/traps.c
23109 @@ -68,12 +68,6 @@
23110 #include <asm/setup.h>
23111
23112 asmlinkage int system_call(void);
23113 -
23114 -/*
23115 - * The IDT has to be page-aligned to simplify the Pentium
23116 - * F0 0F bug workaround.
23117 - */
23118 -gate_desc idt_table[NR_VECTORS] __page_aligned_data = { { { { 0, 0 } } }, };
23119 #endif
23120
23121 DECLARE_BITMAP(used_vectors, NR_VECTORS);
23122 @@ -106,11 +100,11 @@ static inline void preempt_conditional_cli(struct pt_regs *regs)
23123 }
23124
23125 static int __kprobes
23126 -do_trap_no_signal(struct task_struct *tsk, int trapnr, char *str,
23127 +do_trap_no_signal(struct task_struct *tsk, int trapnr, const char *str,
23128 struct pt_regs *regs, long error_code)
23129 {
23130 #ifdef CONFIG_X86_32
23131 - if (regs->flags & X86_VM_MASK) {
23132 + if (v8086_mode(regs)) {
23133 /*
23134 * Traps 0, 1, 3, 4, and 5 should be forwarded to vm86.
23135 * On nmi (interrupt 2), do_trap should not be called.
23136 @@ -123,12 +117,24 @@ do_trap_no_signal(struct task_struct *tsk, int trapnr, char *str,
23137 return -1;
23138 }
23139 #endif
23140 - if (!user_mode(regs)) {
23141 + if (!user_mode_novm(regs)) {
23142 if (!fixup_exception(regs)) {
23143 tsk->thread.error_code = error_code;
23144 tsk->thread.trap_nr = trapnr;
23145 +
23146 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
23147 + if (trapnr == 12 && ((regs->cs & 0xFFFF) == __KERNEL_CS || (regs->cs & 0xFFFF) == __KERNEXEC_KERNEL_CS))
23148 + str = "PAX: suspicious stack segment fault";
23149 +#endif
23150 +
23151 die(str, regs, error_code);
23152 }
23153 +
23154 +#ifdef CONFIG_PAX_REFCOUNT
23155 + if (trapnr == 4)
23156 + pax_report_refcount_overflow(regs);
23157 +#endif
23158 +
23159 return 0;
23160 }
23161
23162 @@ -136,7 +142,7 @@ do_trap_no_signal(struct task_struct *tsk, int trapnr, char *str,
23163 }
23164
23165 static void __kprobes
23166 -do_trap(int trapnr, int signr, char *str, struct pt_regs *regs,
23167 +do_trap(int trapnr, int signr, const char *str, struct pt_regs *regs,
23168 long error_code, siginfo_t *info)
23169 {
23170 struct task_struct *tsk = current;
23171 @@ -160,7 +166,7 @@ do_trap(int trapnr, int signr, char *str, struct pt_regs *regs,
23172 if (show_unhandled_signals && unhandled_signal(tsk, signr) &&
23173 printk_ratelimit()) {
23174 pr_info("%s[%d] trap %s ip:%lx sp:%lx error:%lx",
23175 - tsk->comm, tsk->pid, str,
23176 + tsk->comm, task_pid_nr(tsk), str,
23177 regs->ip, regs->sp, error_code);
23178 print_vma_addr(" in ", regs->ip);
23179 pr_cont("\n");
23180 @@ -266,7 +272,7 @@ do_general_protection(struct pt_regs *regs, long error_code)
23181 conditional_sti(regs);
23182
23183 #ifdef CONFIG_X86_32
23184 - if (regs->flags & X86_VM_MASK) {
23185 + if (v8086_mode(regs)) {
23186 local_irq_enable();
23187 handle_vm86_fault((struct kernel_vm86_regs *) regs, error_code);
23188 goto exit;
23189 @@ -274,18 +280,42 @@ do_general_protection(struct pt_regs *regs, long error_code)
23190 #endif
23191
23192 tsk = current;
23193 - if (!user_mode(regs)) {
23194 + if (!user_mode_novm(regs)) {
23195 if (fixup_exception(regs))
23196 goto exit;
23197
23198 tsk->thread.error_code = error_code;
23199 tsk->thread.trap_nr = X86_TRAP_GP;
23200 if (notify_die(DIE_GPF, "general protection fault", regs, error_code,
23201 - X86_TRAP_GP, SIGSEGV) != NOTIFY_STOP)
23202 + X86_TRAP_GP, SIGSEGV) != NOTIFY_STOP) {
23203 +
23204 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
23205 + if ((regs->cs & 0xFFFF) == __KERNEL_CS || (regs->cs & 0xFFFF) == __KERNEXEC_KERNEL_CS)
23206 + die("PAX: suspicious general protection fault", regs, error_code);
23207 + else
23208 +#endif
23209 +
23210 die("general protection fault", regs, error_code);
23211 + }
23212 goto exit;
23213 }
23214
23215 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
23216 + if (!(__supported_pte_mask & _PAGE_NX) && tsk->mm && (tsk->mm->pax_flags & MF_PAX_PAGEEXEC)) {
23217 + struct mm_struct *mm = tsk->mm;
23218 + unsigned long limit;
23219 +
23220 + down_write(&mm->mmap_sem);
23221 + limit = mm->context.user_cs_limit;
23222 + if (limit < TASK_SIZE) {
23223 + track_exec_limit(mm, limit, TASK_SIZE, VM_EXEC);
23224 + up_write(&mm->mmap_sem);
23225 + return;
23226 + }
23227 + up_write(&mm->mmap_sem);
23228 + }
23229 +#endif
23230 +
23231 tsk->thread.error_code = error_code;
23232 tsk->thread.trap_nr = X86_TRAP_GP;
23233
23234 @@ -440,7 +470,7 @@ dotraplinkage void __kprobes do_debug(struct pt_regs *regs, long error_code)
23235 /* It's safe to allow irq's after DR6 has been saved */
23236 preempt_conditional_sti(regs);
23237
23238 - if (regs->flags & X86_VM_MASK) {
23239 + if (v8086_mode(regs)) {
23240 handle_vm86_trap((struct kernel_vm86_regs *) regs, error_code,
23241 X86_TRAP_DB);
23242 preempt_conditional_cli(regs);
23243 @@ -455,7 +485,7 @@ dotraplinkage void __kprobes do_debug(struct pt_regs *regs, long error_code)
23244 * We already checked v86 mode above, so we can check for kernel mode
23245 * by just checking the CPL of CS.
23246 */
23247 - if ((dr6 & DR_STEP) && !user_mode(regs)) {
23248 + if ((dr6 & DR_STEP) && !user_mode_novm(regs)) {
23249 tsk->thread.debugreg6 &= ~DR_STEP;
23250 set_tsk_thread_flag(tsk, TIF_SINGLESTEP);
23251 regs->flags &= ~X86_EFLAGS_TF;
23252 @@ -487,7 +517,7 @@ void math_error(struct pt_regs *regs, int error_code, int trapnr)
23253 return;
23254 conditional_sti(regs);
23255
23256 - if (!user_mode_vm(regs))
23257 + if (!user_mode(regs))
23258 {
23259 if (!fixup_exception(regs)) {
23260 task->thread.error_code = error_code;
23261 diff --git a/arch/x86/kernel/uprobes.c b/arch/x86/kernel/uprobes.c
23262 index c71025b..b117501 100644
23263 --- a/arch/x86/kernel/uprobes.c
23264 +++ b/arch/x86/kernel/uprobes.c
23265 @@ -629,7 +629,7 @@ int arch_uprobe_exception_notify(struct notifier_block *self, unsigned long val,
23266 int ret = NOTIFY_DONE;
23267
23268 /* We are only interested in userspace traps */
23269 - if (regs && !user_mode_vm(regs))
23270 + if (regs && !user_mode(regs))
23271 return NOTIFY_DONE;
23272
23273 switch (val) {
23274 diff --git a/arch/x86/kernel/verify_cpu.S b/arch/x86/kernel/verify_cpu.S
23275 index b9242ba..50c5edd 100644
23276 --- a/arch/x86/kernel/verify_cpu.S
23277 +++ b/arch/x86/kernel/verify_cpu.S
23278 @@ -20,6 +20,7 @@
23279 * arch/x86/boot/compressed/head_64.S: Boot cpu verification
23280 * arch/x86/kernel/trampoline_64.S: secondary processor verification
23281 * arch/x86/kernel/head_32.S: processor startup
23282 + * arch/x86/kernel/acpi/realmode/wakeup.S: 32bit processor resume
23283 *
23284 * verify_cpu, returns the status of longmode and SSE in register %eax.
23285 * 0: Success 1: Failure
23286 diff --git a/arch/x86/kernel/vm86_32.c b/arch/x86/kernel/vm86_32.c
23287 index 1dfe69c..a3df6f6 100644
23288 --- a/arch/x86/kernel/vm86_32.c
23289 +++ b/arch/x86/kernel/vm86_32.c
23290 @@ -43,6 +43,7 @@
23291 #include <linux/ptrace.h>
23292 #include <linux/audit.h>
23293 #include <linux/stddef.h>
23294 +#include <linux/grsecurity.h>
23295
23296 #include <asm/uaccess.h>
23297 #include <asm/io.h>
23298 @@ -150,7 +151,7 @@ struct pt_regs *save_v86_state(struct kernel_vm86_regs *regs)
23299 do_exit(SIGSEGV);
23300 }
23301
23302 - tss = &per_cpu(init_tss, get_cpu());
23303 + tss = init_tss + get_cpu();
23304 current->thread.sp0 = current->thread.saved_sp0;
23305 current->thread.sysenter_cs = __KERNEL_CS;
23306 load_sp0(tss, &current->thread);
23307 @@ -212,6 +213,13 @@ int sys_vm86old(struct vm86_struct __user *v86, struct pt_regs *regs)
23308 struct task_struct *tsk;
23309 int tmp, ret = -EPERM;
23310
23311 +#ifdef CONFIG_GRKERNSEC_VM86
23312 + if (!capable(CAP_SYS_RAWIO)) {
23313 + gr_handle_vm86();
23314 + goto out;
23315 + }
23316 +#endif
23317 +
23318 tsk = current;
23319 if (tsk->thread.saved_sp0)
23320 goto out;
23321 @@ -242,6 +250,14 @@ int sys_vm86(unsigned long cmd, unsigned long arg, struct pt_regs *regs)
23322 int tmp, ret;
23323 struct vm86plus_struct __user *v86;
23324
23325 +#ifdef CONFIG_GRKERNSEC_VM86
23326 + if (!capable(CAP_SYS_RAWIO)) {
23327 + gr_handle_vm86();
23328 + ret = -EPERM;
23329 + goto out;
23330 + }
23331 +#endif
23332 +
23333 tsk = current;
23334 switch (cmd) {
23335 case VM86_REQUEST_IRQ:
23336 @@ -328,7 +344,7 @@ static void do_sys_vm86(struct kernel_vm86_struct *info, struct task_struct *tsk
23337 tsk->thread.saved_fs = info->regs32->fs;
23338 tsk->thread.saved_gs = get_user_gs(info->regs32);
23339
23340 - tss = &per_cpu(init_tss, get_cpu());
23341 + tss = init_tss + get_cpu();
23342 tsk->thread.sp0 = (unsigned long) &info->VM86_TSS_ESP0;
23343 if (cpu_has_sep)
23344 tsk->thread.sysenter_cs = 0;
23345 @@ -535,7 +551,7 @@ static void do_int(struct kernel_vm86_regs *regs, int i,
23346 goto cannot_handle;
23347 if (i == 0x21 && is_revectored(AH(regs), &KVM86->int21_revectored))
23348 goto cannot_handle;
23349 - intr_ptr = (unsigned long __user *) (i << 2);
23350 + intr_ptr = (__force unsigned long __user *) (i << 2);
23351 if (get_user(segoffs, intr_ptr))
23352 goto cannot_handle;
23353 if ((segoffs >> 16) == BIOSSEG)
23354 diff --git a/arch/x86/kernel/vmlinux.lds.S b/arch/x86/kernel/vmlinux.lds.S
23355 index 22a1530..8fbaaad 100644
23356 --- a/arch/x86/kernel/vmlinux.lds.S
23357 +++ b/arch/x86/kernel/vmlinux.lds.S
23358 @@ -26,6 +26,13 @@
23359 #include <asm/page_types.h>
23360 #include <asm/cache.h>
23361 #include <asm/boot.h>
23362 +#include <asm/segment.h>
23363 +
23364 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
23365 +#define __KERNEL_TEXT_OFFSET (LOAD_OFFSET + ____LOAD_PHYSICAL_ADDR)
23366 +#else
23367 +#define __KERNEL_TEXT_OFFSET 0
23368 +#endif
23369
23370 #undef i386 /* in case the preprocessor is a 32bit one */
23371
23372 @@ -69,30 +76,43 @@ jiffies_64 = jiffies;
23373
23374 PHDRS {
23375 text PT_LOAD FLAGS(5); /* R_E */
23376 +#ifdef CONFIG_X86_32
23377 + module PT_LOAD FLAGS(5); /* R_E */
23378 +#endif
23379 +#ifdef CONFIG_XEN
23380 + rodata PT_LOAD FLAGS(5); /* R_E */
23381 +#else
23382 + rodata PT_LOAD FLAGS(4); /* R__ */
23383 +#endif
23384 data PT_LOAD FLAGS(6); /* RW_ */
23385 -#ifdef CONFIG_X86_64
23386 + init.begin PT_LOAD FLAGS(6); /* RW_ */
23387 #ifdef CONFIG_SMP
23388 percpu PT_LOAD FLAGS(6); /* RW_ */
23389 #endif
23390 + text.init PT_LOAD FLAGS(5); /* R_E */
23391 + text.exit PT_LOAD FLAGS(5); /* R_E */
23392 init PT_LOAD FLAGS(7); /* RWE */
23393 -#endif
23394 note PT_NOTE FLAGS(0); /* ___ */
23395 }
23396
23397 SECTIONS
23398 {
23399 #ifdef CONFIG_X86_32
23400 - . = LOAD_OFFSET + LOAD_PHYSICAL_ADDR;
23401 - phys_startup_32 = startup_32 - LOAD_OFFSET;
23402 + . = LOAD_OFFSET + ____LOAD_PHYSICAL_ADDR;
23403 #else
23404 - . = __START_KERNEL;
23405 - phys_startup_64 = startup_64 - LOAD_OFFSET;
23406 + . = __START_KERNEL;
23407 #endif
23408
23409 /* Text and read-only data */
23410 - .text : AT(ADDR(.text) - LOAD_OFFSET) {
23411 - _text = .;
23412 + .text (. - __KERNEL_TEXT_OFFSET): AT(ADDR(.text) - LOAD_OFFSET + __KERNEL_TEXT_OFFSET) {
23413 /* bootstrapping code */
23414 +#ifdef CONFIG_X86_32
23415 + phys_startup_32 = startup_32 - LOAD_OFFSET + __KERNEL_TEXT_OFFSET;
23416 +#else
23417 + phys_startup_64 = startup_64 - LOAD_OFFSET + __KERNEL_TEXT_OFFSET;
23418 +#endif
23419 + __LOAD_PHYSICAL_ADDR = . - LOAD_OFFSET + __KERNEL_TEXT_OFFSET;
23420 + _text = .;
23421 HEAD_TEXT
23422 #ifdef CONFIG_X86_32
23423 . = ALIGN(PAGE_SIZE);
23424 @@ -108,13 +128,48 @@ SECTIONS
23425 IRQENTRY_TEXT
23426 *(.fixup)
23427 *(.gnu.warning)
23428 - /* End of text section */
23429 - _etext = .;
23430 } :text = 0x9090
23431
23432 - NOTES :text :note
23433 + . += __KERNEL_TEXT_OFFSET;
23434
23435 - EXCEPTION_TABLE(16) :text = 0x9090
23436 +#ifdef CONFIG_X86_32
23437 + . = ALIGN(PAGE_SIZE);
23438 + .module.text : AT(ADDR(.module.text) - LOAD_OFFSET) {
23439 +
23440 +#if defined(CONFIG_PAX_KERNEXEC) && defined(CONFIG_MODULES)
23441 + MODULES_EXEC_VADDR = .;
23442 + BYTE(0)
23443 + . += (CONFIG_PAX_KERNEXEC_MODULE_TEXT * 1024 * 1024);
23444 + . = ALIGN(HPAGE_SIZE) - 1;
23445 + MODULES_EXEC_END = .;
23446 +#endif
23447 +
23448 + } :module
23449 +#endif
23450 +
23451 + .text.end : AT(ADDR(.text.end) - LOAD_OFFSET) {
23452 + /* End of text section */
23453 + BYTE(0)
23454 + _etext = . - __KERNEL_TEXT_OFFSET;
23455 + }
23456 +
23457 +#ifdef CONFIG_X86_32
23458 + . = ALIGN(PAGE_SIZE);
23459 + .rodata.page_aligned : AT(ADDR(.rodata.page_aligned) - LOAD_OFFSET) {
23460 + *(.idt)
23461 + . = ALIGN(PAGE_SIZE);
23462 + *(.empty_zero_page)
23463 + *(.initial_pg_fixmap)
23464 + *(.initial_pg_pmd)
23465 + *(.initial_page_table)
23466 + *(.swapper_pg_dir)
23467 + } :rodata
23468 +#endif
23469 +
23470 + . = ALIGN(PAGE_SIZE);
23471 + NOTES :rodata :note
23472 +
23473 + EXCEPTION_TABLE(16) :rodata
23474
23475 #if defined(CONFIG_DEBUG_RODATA)
23476 /* .text should occupy whole number of pages */
23477 @@ -126,16 +181,20 @@ SECTIONS
23478
23479 /* Data */
23480 .data : AT(ADDR(.data) - LOAD_OFFSET) {
23481 +
23482 +#ifdef CONFIG_PAX_KERNEXEC
23483 + . = ALIGN(HPAGE_SIZE);
23484 +#else
23485 + . = ALIGN(PAGE_SIZE);
23486 +#endif
23487 +
23488 /* Start of data section */
23489 _sdata = .;
23490
23491 /* init_task */
23492 INIT_TASK_DATA(THREAD_SIZE)
23493
23494 -#ifdef CONFIG_X86_32
23495 - /* 32 bit has nosave before _edata */
23496 NOSAVE_DATA
23497 -#endif
23498
23499 PAGE_ALIGNED_DATA(PAGE_SIZE)
23500
23501 @@ -176,12 +235,19 @@ SECTIONS
23502 #endif /* CONFIG_X86_64 */
23503
23504 /* Init code and data - will be freed after init */
23505 - . = ALIGN(PAGE_SIZE);
23506 .init.begin : AT(ADDR(.init.begin) - LOAD_OFFSET) {
23507 + BYTE(0)
23508 +
23509 +#ifdef CONFIG_PAX_KERNEXEC
23510 + . = ALIGN(HPAGE_SIZE);
23511 +#else
23512 + . = ALIGN(PAGE_SIZE);
23513 +#endif
23514 +
23515 __init_begin = .; /* paired with __init_end */
23516 - }
23517 + } :init.begin
23518
23519 -#if defined(CONFIG_X86_64) && defined(CONFIG_SMP)
23520 +#ifdef CONFIG_SMP
23521 /*
23522 * percpu offsets are zero-based on SMP. PERCPU_VADDR() changes the
23523 * output PHDR, so the next output section - .init.text - should
23524 @@ -190,12 +256,27 @@ SECTIONS
23525 PERCPU_VADDR(INTERNODE_CACHE_BYTES, 0, :percpu)
23526 #endif
23527
23528 - INIT_TEXT_SECTION(PAGE_SIZE)
23529 -#ifdef CONFIG_X86_64
23530 - :init
23531 -#endif
23532 + . = ALIGN(PAGE_SIZE);
23533 + init_begin = .;
23534 + .init.text (. - __KERNEL_TEXT_OFFSET): AT(init_begin - LOAD_OFFSET) {
23535 + VMLINUX_SYMBOL(_sinittext) = .;
23536 + INIT_TEXT
23537 + VMLINUX_SYMBOL(_einittext) = .;
23538 + . = ALIGN(PAGE_SIZE);
23539 + } :text.init
23540
23541 - INIT_DATA_SECTION(16)
23542 + /*
23543 + * .exit.text is discard at runtime, not link time, to deal with
23544 + * references from .altinstructions and .eh_frame
23545 + */
23546 + .exit.text : AT(ADDR(.exit.text) - LOAD_OFFSET + __KERNEL_TEXT_OFFSET) {
23547 + EXIT_TEXT
23548 + . = ALIGN(16);
23549 + } :text.exit
23550 + . = init_begin + SIZEOF(.init.text) + SIZEOF(.exit.text);
23551 +
23552 + . = ALIGN(PAGE_SIZE);
23553 + INIT_DATA_SECTION(16) :init
23554
23555 .x86_cpu_dev.init : AT(ADDR(.x86_cpu_dev.init) - LOAD_OFFSET) {
23556 __x86_cpu_dev_start = .;
23557 @@ -257,19 +338,12 @@ SECTIONS
23558 }
23559
23560 . = ALIGN(8);
23561 - /*
23562 - * .exit.text is discard at runtime, not link time, to deal with
23563 - * references from .altinstructions and .eh_frame
23564 - */
23565 - .exit.text : AT(ADDR(.exit.text) - LOAD_OFFSET) {
23566 - EXIT_TEXT
23567 - }
23568
23569 .exit.data : AT(ADDR(.exit.data) - LOAD_OFFSET) {
23570 EXIT_DATA
23571 }
23572
23573 -#if !defined(CONFIG_X86_64) || !defined(CONFIG_SMP)
23574 +#ifndef CONFIG_SMP
23575 PERCPU_SECTION(INTERNODE_CACHE_BYTES)
23576 #endif
23577
23578 @@ -288,16 +362,10 @@ SECTIONS
23579 .smp_locks : AT(ADDR(.smp_locks) - LOAD_OFFSET) {
23580 __smp_locks = .;
23581 *(.smp_locks)
23582 - . = ALIGN(PAGE_SIZE);
23583 __smp_locks_end = .;
23584 + . = ALIGN(PAGE_SIZE);
23585 }
23586
23587 -#ifdef CONFIG_X86_64
23588 - .data_nosave : AT(ADDR(.data_nosave) - LOAD_OFFSET) {
23589 - NOSAVE_DATA
23590 - }
23591 -#endif
23592 -
23593 /* BSS */
23594 . = ALIGN(PAGE_SIZE);
23595 .bss : AT(ADDR(.bss) - LOAD_OFFSET) {
23596 @@ -313,6 +381,7 @@ SECTIONS
23597 __brk_base = .;
23598 . += 64 * 1024; /* 64k alignment slop space */
23599 *(.brk_reservation) /* areas brk users have reserved */
23600 + . = ALIGN(HPAGE_SIZE);
23601 __brk_limit = .;
23602 }
23603
23604 @@ -339,13 +408,12 @@ SECTIONS
23605 * for the boot processor.
23606 */
23607 #define INIT_PER_CPU(x) init_per_cpu__##x = x + __per_cpu_load
23608 -INIT_PER_CPU(gdt_page);
23609 INIT_PER_CPU(irq_stack_union);
23610
23611 /*
23612 * Build-time check on the image size:
23613 */
23614 -. = ASSERT((_end - _text <= KERNEL_IMAGE_SIZE),
23615 +. = ASSERT((_end - _text - __KERNEL_TEXT_OFFSET <= KERNEL_IMAGE_SIZE),
23616 "kernel image bigger than KERNEL_IMAGE_SIZE");
23617
23618 #ifdef CONFIG_SMP
23619 diff --git a/arch/x86/kernel/vsyscall_64.c b/arch/x86/kernel/vsyscall_64.c
23620 index 9a907a6..f83f921 100644
23621 --- a/arch/x86/kernel/vsyscall_64.c
23622 +++ b/arch/x86/kernel/vsyscall_64.c
23623 @@ -56,15 +56,13 @@
23624 DEFINE_VVAR(int, vgetcpu_mode);
23625 DEFINE_VVAR(struct vsyscall_gtod_data, vsyscall_gtod_data);
23626
23627 -static enum { EMULATE, NATIVE, NONE } vsyscall_mode = EMULATE;
23628 +static enum { EMULATE, NONE } vsyscall_mode = EMULATE;
23629
23630 static int __init vsyscall_setup(char *str)
23631 {
23632 if (str) {
23633 if (!strcmp("emulate", str))
23634 vsyscall_mode = EMULATE;
23635 - else if (!strcmp("native", str))
23636 - vsyscall_mode = NATIVE;
23637 else if (!strcmp("none", str))
23638 vsyscall_mode = NONE;
23639 else
23640 @@ -323,8 +321,7 @@ do_ret:
23641 return true;
23642
23643 sigsegv:
23644 - force_sig(SIGSEGV, current);
23645 - return true;
23646 + do_group_exit(SIGKILL);
23647 }
23648
23649 /*
23650 @@ -377,10 +374,7 @@ void __init map_vsyscall(void)
23651 extern char __vvar_page;
23652 unsigned long physaddr_vvar_page = __pa_symbol(&__vvar_page);
23653
23654 - __set_fixmap(VSYSCALL_FIRST_PAGE, physaddr_vsyscall,
23655 - vsyscall_mode == NATIVE
23656 - ? PAGE_KERNEL_VSYSCALL
23657 - : PAGE_KERNEL_VVAR);
23658 + __set_fixmap(VSYSCALL_FIRST_PAGE, physaddr_vsyscall, PAGE_KERNEL_VVAR);
23659 BUILD_BUG_ON((unsigned long)__fix_to_virt(VSYSCALL_FIRST_PAGE) !=
23660 (unsigned long)VSYSCALL_START);
23661
23662 diff --git a/arch/x86/kernel/x8664_ksyms_64.c b/arch/x86/kernel/x8664_ksyms_64.c
23663 index 1330dd1..d220b99 100644
23664 --- a/arch/x86/kernel/x8664_ksyms_64.c
23665 +++ b/arch/x86/kernel/x8664_ksyms_64.c
23666 @@ -34,8 +34,6 @@ EXPORT_SYMBOL(copy_user_generic_string);
23667 EXPORT_SYMBOL(copy_user_generic_unrolled);
23668 EXPORT_SYMBOL(copy_user_enhanced_fast_string);
23669 EXPORT_SYMBOL(__copy_user_nocache);
23670 -EXPORT_SYMBOL(_copy_from_user);
23671 -EXPORT_SYMBOL(_copy_to_user);
23672
23673 EXPORT_SYMBOL(copy_page);
23674 EXPORT_SYMBOL(clear_page);
23675 diff --git a/arch/x86/kernel/x86_init.c b/arch/x86/kernel/x86_init.c
23676 index 7a3d075..6cb373d 100644
23677 --- a/arch/x86/kernel/x86_init.c
23678 +++ b/arch/x86/kernel/x86_init.c
23679 @@ -88,7 +88,7 @@ struct x86_init_ops x86_init __initdata = {
23680 },
23681 };
23682
23683 -struct x86_cpuinit_ops x86_cpuinit __cpuinitdata = {
23684 +struct x86_cpuinit_ops x86_cpuinit __cpuinitconst = {
23685 .early_percpu_clock_init = x86_init_noop,
23686 .setup_percpu_clockev = setup_secondary_APIC_clock,
23687 };
23688 @@ -96,7 +96,7 @@ struct x86_cpuinit_ops x86_cpuinit __cpuinitdata = {
23689 static void default_nmi_init(void) { };
23690 static int default_i8042_detect(void) { return 1; };
23691
23692 -struct x86_platform_ops x86_platform = {
23693 +struct x86_platform_ops x86_platform __read_only = {
23694 .calibrate_tsc = native_calibrate_tsc,
23695 .get_wallclock = mach_get_cmos_time,
23696 .set_wallclock = mach_set_rtc_mmss,
23697 @@ -110,14 +110,14 @@ struct x86_platform_ops x86_platform = {
23698 };
23699
23700 EXPORT_SYMBOL_GPL(x86_platform);
23701 -struct x86_msi_ops x86_msi = {
23702 +struct x86_msi_ops x86_msi __read_only = {
23703 .setup_msi_irqs = native_setup_msi_irqs,
23704 .teardown_msi_irq = native_teardown_msi_irq,
23705 .teardown_msi_irqs = default_teardown_msi_irqs,
23706 .restore_msi_irqs = default_restore_msi_irqs,
23707 };
23708
23709 -struct x86_io_apic_ops x86_io_apic_ops = {
23710 +struct x86_io_apic_ops x86_io_apic_ops __read_only = {
23711 .init = native_io_apic_init_mappings,
23712 .read = native_io_apic_read,
23713 .write = native_io_apic_write,
23714 diff --git a/arch/x86/kernel/xsave.c b/arch/x86/kernel/xsave.c
23715 index ada87a3..afea76d 100644
23716 --- a/arch/x86/kernel/xsave.c
23717 +++ b/arch/x86/kernel/xsave.c
23718 @@ -199,6 +199,7 @@ static inline int save_user_xstate(struct xsave_struct __user *buf)
23719 {
23720 int err;
23721
23722 + buf = (struct xsave_struct __user *)____m(buf);
23723 if (use_xsave())
23724 err = xsave_user(buf);
23725 else if (use_fxsr())
23726 @@ -311,6 +312,7 @@ sanitize_restored_xstate(struct task_struct *tsk,
23727 */
23728 static inline int restore_user_xstate(void __user *buf, u64 xbv, int fx_only)
23729 {
23730 + buf = (void __user *)____m(buf);
23731 if (use_xsave()) {
23732 if ((unsigned long)buf % 64 || fx_only) {
23733 u64 init_bv = pcntxt_mask & ~XSTATE_FPSSE;
23734 diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c
23735 index a20ecb5..d0e2194 100644
23736 --- a/arch/x86/kvm/cpuid.c
23737 +++ b/arch/x86/kvm/cpuid.c
23738 @@ -124,15 +124,20 @@ int kvm_vcpu_ioctl_set_cpuid2(struct kvm_vcpu *vcpu,
23739 struct kvm_cpuid2 *cpuid,
23740 struct kvm_cpuid_entry2 __user *entries)
23741 {
23742 - int r;
23743 + int r, i;
23744
23745 r = -E2BIG;
23746 if (cpuid->nent > KVM_MAX_CPUID_ENTRIES)
23747 goto out;
23748 r = -EFAULT;
23749 - if (copy_from_user(&vcpu->arch.cpuid_entries, entries,
23750 - cpuid->nent * sizeof(struct kvm_cpuid_entry2)))
23751 + if (!access_ok(VERIFY_READ, entries, cpuid->nent * sizeof(struct kvm_cpuid_entry2)))
23752 goto out;
23753 + for (i = 0; i < cpuid->nent; ++i) {
23754 + struct kvm_cpuid_entry2 cpuid_entry;
23755 + if (__copy_from_user(&cpuid_entry, entries + i, sizeof(cpuid_entry)))
23756 + goto out;
23757 + vcpu->arch.cpuid_entries[i] = cpuid_entry;
23758 + }
23759 vcpu->arch.cpuid_nent = cpuid->nent;
23760 kvm_apic_set_version(vcpu);
23761 kvm_x86_ops->cpuid_update(vcpu);
23762 @@ -147,15 +152,19 @@ int kvm_vcpu_ioctl_get_cpuid2(struct kvm_vcpu *vcpu,
23763 struct kvm_cpuid2 *cpuid,
23764 struct kvm_cpuid_entry2 __user *entries)
23765 {
23766 - int r;
23767 + int r, i;
23768
23769 r = -E2BIG;
23770 if (cpuid->nent < vcpu->arch.cpuid_nent)
23771 goto out;
23772 r = -EFAULT;
23773 - if (copy_to_user(entries, &vcpu->arch.cpuid_entries,
23774 - vcpu->arch.cpuid_nent * sizeof(struct kvm_cpuid_entry2)))
23775 + if (!access_ok(VERIFY_WRITE, entries, vcpu->arch.cpuid_nent * sizeof(struct kvm_cpuid_entry2)))
23776 goto out;
23777 + for (i = 0; i < vcpu->arch.cpuid_nent; ++i) {
23778 + struct kvm_cpuid_entry2 cpuid_entry = vcpu->arch.cpuid_entries[i];
23779 + if (__copy_to_user(entries + i, &cpuid_entry, sizeof(cpuid_entry)))
23780 + goto out;
23781 + }
23782 return 0;
23783
23784 out:
23785 diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
23786 index a27e763..54bfe43 100644
23787 --- a/arch/x86/kvm/emulate.c
23788 +++ b/arch/x86/kvm/emulate.c
23789 @@ -292,6 +292,7 @@ static void invalidate_registers(struct x86_emulate_ctxt *ctxt)
23790
23791 #define ____emulate_2op(ctxt, _op, _x, _y, _suffix, _dsttype) \
23792 do { \
23793 + unsigned long _tmp; \
23794 __asm__ __volatile__ ( \
23795 _PRE_EFLAGS("0", "4", "2") \
23796 _op _suffix " %"_x"3,%1; " \
23797 @@ -306,8 +307,6 @@ static void invalidate_registers(struct x86_emulate_ctxt *ctxt)
23798 /* Raw emulation: instruction has two explicit operands. */
23799 #define __emulate_2op_nobyte(ctxt,_op,_wx,_wy,_lx,_ly,_qx,_qy) \
23800 do { \
23801 - unsigned long _tmp; \
23802 - \
23803 switch ((ctxt)->dst.bytes) { \
23804 case 2: \
23805 ____emulate_2op(ctxt,_op,_wx,_wy,"w",u16); \
23806 @@ -323,7 +322,6 @@ static void invalidate_registers(struct x86_emulate_ctxt *ctxt)
23807
23808 #define __emulate_2op(ctxt,_op,_bx,_by,_wx,_wy,_lx,_ly,_qx,_qy) \
23809 do { \
23810 - unsigned long _tmp; \
23811 switch ((ctxt)->dst.bytes) { \
23812 case 1: \
23813 ____emulate_2op(ctxt,_op,_bx,_by,"b",u8); \
23814 diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
23815 index 9392f52..0e56d77 100644
23816 --- a/arch/x86/kvm/lapic.c
23817 +++ b/arch/x86/kvm/lapic.c
23818 @@ -55,7 +55,7 @@
23819 #define APIC_BUS_CYCLE_NS 1
23820
23821 /* #define apic_debug(fmt,arg...) printk(KERN_WARNING fmt,##arg) */
23822 -#define apic_debug(fmt, arg...)
23823 +#define apic_debug(fmt, arg...) do {} while (0)
23824
23825 #define APIC_LVT_NUM 6
23826 /* 14 is the version for Xeon and Pentium 8.4.8*/
23827 diff --git a/arch/x86/kvm/paging_tmpl.h b/arch/x86/kvm/paging_tmpl.h
23828 index 891eb6d..e027900 100644
23829 --- a/arch/x86/kvm/paging_tmpl.h
23830 +++ b/arch/x86/kvm/paging_tmpl.h
23831 @@ -208,7 +208,7 @@ retry_walk:
23832 if (unlikely(kvm_is_error_hva(host_addr)))
23833 goto error;
23834
23835 - ptep_user = (pt_element_t __user *)((void *)host_addr + offset);
23836 + ptep_user = (pt_element_t __force_user *)((void *)host_addr + offset);
23837 if (unlikely(__copy_from_user(&pte, ptep_user, sizeof(pte))))
23838 goto error;
23839 walker->ptep_user[walker->level - 1] = ptep_user;
23840 diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
23841 index d29d3cd..ec9d522 100644
23842 --- a/arch/x86/kvm/svm.c
23843 +++ b/arch/x86/kvm/svm.c
23844 @@ -3507,7 +3507,11 @@ static void reload_tss(struct kvm_vcpu *vcpu)
23845 int cpu = raw_smp_processor_id();
23846
23847 struct svm_cpu_data *sd = per_cpu(svm_data, cpu);
23848 +
23849 + pax_open_kernel();
23850 sd->tss_desc->type = 9; /* available 32/64-bit TSS */
23851 + pax_close_kernel();
23852 +
23853 load_TR_desc();
23854 }
23855
23856 @@ -3881,6 +3885,10 @@ static void svm_vcpu_run(struct kvm_vcpu *vcpu)
23857 #endif
23858 #endif
23859
23860 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
23861 + __set_fs(current_thread_info()->addr_limit);
23862 +#endif
23863 +
23864 reload_tss(vcpu);
23865
23866 local_irq_disable();
23867 diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
23868 index 9120ae1..238abc0 100644
23869 --- a/arch/x86/kvm/vmx.c
23870 +++ b/arch/x86/kvm/vmx.c
23871 @@ -1370,7 +1370,11 @@ static void reload_tss(void)
23872 struct desc_struct *descs;
23873
23874 descs = (void *)gdt->address;
23875 +
23876 + pax_open_kernel();
23877 descs[GDT_ENTRY_TSS].type = 9; /* available TSS */
23878 + pax_close_kernel();
23879 +
23880 load_TR_desc();
23881 }
23882
23883 @@ -1594,6 +1598,10 @@ static void vmx_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
23884 vmcs_writel(HOST_TR_BASE, kvm_read_tr_base()); /* 22.2.4 */
23885 vmcs_writel(HOST_GDTR_BASE, gdt->address); /* 22.2.4 */
23886
23887 +#ifdef CONFIG_PAX_PER_CPU_PGD
23888 + vmcs_writel(HOST_CR3, read_cr3()); /* 22.2.3 FIXME: shadow tables */
23889 +#endif
23890 +
23891 rdmsrl(MSR_IA32_SYSENTER_ESP, sysenter_esp);
23892 vmcs_writel(HOST_IA32_SYSENTER_ESP, sysenter_esp); /* 22.2.3 */
23893 vmx->loaded_vmcs->cpu = cpu;
23894 @@ -2738,8 +2746,11 @@ static __init int hardware_setup(void)
23895 if (!cpu_has_vmx_flexpriority())
23896 flexpriority_enabled = 0;
23897
23898 - if (!cpu_has_vmx_tpr_shadow())
23899 - kvm_x86_ops->update_cr8_intercept = NULL;
23900 + if (!cpu_has_vmx_tpr_shadow()) {
23901 + pax_open_kernel();
23902 + *(void **)&kvm_x86_ops->update_cr8_intercept = NULL;
23903 + pax_close_kernel();
23904 + }
23905
23906 if (enable_ept && !cpu_has_vmx_ept_2m_page())
23907 kvm_disable_largepages();
23908 @@ -3782,7 +3793,10 @@ static void vmx_set_constant_host_state(void)
23909
23910 vmcs_writel(HOST_CR0, read_cr0() & ~X86_CR0_TS); /* 22.2.3 */
23911 vmcs_writel(HOST_CR4, read_cr4()); /* 22.2.3, 22.2.5 */
23912 +
23913 +#ifndef CONFIG_PAX_PER_CPU_PGD
23914 vmcs_writel(HOST_CR3, read_cr3()); /* 22.2.3 FIXME: shadow tables */
23915 +#endif
23916
23917 vmcs_write16(HOST_CS_SELECTOR, __KERNEL_CS); /* 22.2.4 */
23918 #ifdef CONFIG_X86_64
23919 @@ -3803,7 +3817,7 @@ static void vmx_set_constant_host_state(void)
23920 native_store_idt(&dt);
23921 vmcs_writel(HOST_IDTR_BASE, dt.address); /* 22.2.4 */
23922
23923 - vmcs_writel(HOST_RIP, vmx_return); /* 22.2.5 */
23924 + vmcs_writel(HOST_RIP, ktla_ktva(vmx_return)); /* 22.2.5 */
23925
23926 rdmsr(MSR_IA32_SYSENTER_CS, low32, high32);
23927 vmcs_write32(HOST_IA32_SYSENTER_CS, low32);
23928 @@ -6355,6 +6369,12 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
23929 "jmp 2f \n\t"
23930 "1: " __ex(ASM_VMX_VMRESUME) "\n\t"
23931 "2: "
23932 +
23933 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
23934 + "ljmp %[cs],$3f\n\t"
23935 + "3: "
23936 +#endif
23937 +
23938 /* Save guest registers, load host registers, keep flags */
23939 "mov %0, %c[wordsize](%%" _ASM_SP ") \n\t"
23940 "pop %0 \n\t"
23941 @@ -6407,6 +6427,11 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
23942 #endif
23943 [cr2]"i"(offsetof(struct vcpu_vmx, vcpu.arch.cr2)),
23944 [wordsize]"i"(sizeof(ulong))
23945 +
23946 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
23947 + ,[cs]"i"(__KERNEL_CS)
23948 +#endif
23949 +
23950 : "cc", "memory"
23951 #ifdef CONFIG_X86_64
23952 , "rax", "rbx", "rdi", "rsi"
23953 @@ -6420,7 +6445,7 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
23954 if (debugctlmsr)
23955 update_debugctlmsr(debugctlmsr);
23956
23957 -#ifndef CONFIG_X86_64
23958 +#ifdef CONFIG_X86_32
23959 /*
23960 * The sysexit path does not restore ds/es, so we must set them to
23961 * a reasonable value ourselves.
23962 @@ -6429,8 +6454,18 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
23963 * may be executed in interrupt context, which saves and restore segments
23964 * around it, nullifying its effect.
23965 */
23966 - loadsegment(ds, __USER_DS);
23967 - loadsegment(es, __USER_DS);
23968 + loadsegment(ds, __KERNEL_DS);
23969 + loadsegment(es, __KERNEL_DS);
23970 + loadsegment(ss, __KERNEL_DS);
23971 +
23972 +#ifdef CONFIG_PAX_KERNEXEC
23973 + loadsegment(fs, __KERNEL_PERCPU);
23974 +#endif
23975 +
23976 +#ifdef CONFIG_PAX_MEMORY_UDEREF
23977 + __set_fs(current_thread_info()->addr_limit);
23978 +#endif
23979 +
23980 #endif
23981
23982 vcpu->arch.regs_avail = ~((1 << VCPU_REGS_RIP) | (1 << VCPU_REGS_RSP)
23983 diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
23984 index c243b81..9eb193f 100644
23985 --- a/arch/x86/kvm/x86.c
23986 +++ b/arch/x86/kvm/x86.c
23987 @@ -1692,8 +1692,8 @@ static int xen_hvm_config(struct kvm_vcpu *vcpu, u64 data)
23988 {
23989 struct kvm *kvm = vcpu->kvm;
23990 int lm = is_long_mode(vcpu);
23991 - u8 *blob_addr = lm ? (u8 *)(long)kvm->arch.xen_hvm_config.blob_addr_64
23992 - : (u8 *)(long)kvm->arch.xen_hvm_config.blob_addr_32;
23993 + u8 __user *blob_addr = lm ? (u8 __user *)(long)kvm->arch.xen_hvm_config.blob_addr_64
23994 + : (u8 __user *)(long)kvm->arch.xen_hvm_config.blob_addr_32;
23995 u8 blob_size = lm ? kvm->arch.xen_hvm_config.blob_size_64
23996 : kvm->arch.xen_hvm_config.blob_size_32;
23997 u32 page_num = data & ~PAGE_MASK;
23998 @@ -2571,6 +2571,8 @@ long kvm_arch_dev_ioctl(struct file *filp,
23999 if (n < msr_list.nmsrs)
24000 goto out;
24001 r = -EFAULT;
24002 + if (num_msrs_to_save > ARRAY_SIZE(msrs_to_save))
24003 + goto out;
24004 if (copy_to_user(user_msr_list->indices, &msrs_to_save,
24005 num_msrs_to_save * sizeof(u32)))
24006 goto out;
24007 @@ -2700,7 +2702,7 @@ static int kvm_vcpu_ioctl_set_lapic(struct kvm_vcpu *vcpu,
24008 static int kvm_vcpu_ioctl_interrupt(struct kvm_vcpu *vcpu,
24009 struct kvm_interrupt *irq)
24010 {
24011 - if (irq->irq < 0 || irq->irq >= KVM_NR_INTERRUPTS)
24012 + if (irq->irq >= KVM_NR_INTERRUPTS)
24013 return -EINVAL;
24014 if (irqchip_in_kernel(vcpu->kvm))
24015 return -ENXIO;
24016 @@ -5213,7 +5215,7 @@ static struct notifier_block pvclock_gtod_notifier = {
24017 };
24018 #endif
24019
24020 -int kvm_arch_init(void *opaque)
24021 +int kvm_arch_init(const void *opaque)
24022 {
24023 int r;
24024 struct kvm_x86_ops *ops = (struct kvm_x86_ops *)opaque;
24025 diff --git a/arch/x86/lguest/boot.c b/arch/x86/lguest/boot.c
24026 index df4176c..23ce092 100644
24027 --- a/arch/x86/lguest/boot.c
24028 +++ b/arch/x86/lguest/boot.c
24029 @@ -1200,9 +1200,10 @@ static __init int early_put_chars(u32 vtermno, const char *buf, int count)
24030 * Rebooting also tells the Host we're finished, but the RESTART flag tells the
24031 * Launcher to reboot us.
24032 */
24033 -static void lguest_restart(char *reason)
24034 +static __noreturn void lguest_restart(char *reason)
24035 {
24036 hcall(LHCALL_SHUTDOWN, __pa(reason), LGUEST_SHUTDOWN_RESTART, 0, 0);
24037 + BUG();
24038 }
24039
24040 /*G:050
24041 diff --git a/arch/x86/lib/atomic64_386_32.S b/arch/x86/lib/atomic64_386_32.S
24042 index 00933d5..3a64af9 100644
24043 --- a/arch/x86/lib/atomic64_386_32.S
24044 +++ b/arch/x86/lib/atomic64_386_32.S
24045 @@ -48,6 +48,10 @@ BEGIN(read)
24046 movl (v), %eax
24047 movl 4(v), %edx
24048 RET_ENDP
24049 +BEGIN(read_unchecked)
24050 + movl (v), %eax
24051 + movl 4(v), %edx
24052 +RET_ENDP
24053 #undef v
24054
24055 #define v %esi
24056 @@ -55,6 +59,10 @@ BEGIN(set)
24057 movl %ebx, (v)
24058 movl %ecx, 4(v)
24059 RET_ENDP
24060 +BEGIN(set_unchecked)
24061 + movl %ebx, (v)
24062 + movl %ecx, 4(v)
24063 +RET_ENDP
24064 #undef v
24065
24066 #define v %esi
24067 @@ -70,6 +78,20 @@ RET_ENDP
24068 BEGIN(add)
24069 addl %eax, (v)
24070 adcl %edx, 4(v)
24071 +
24072 +#ifdef CONFIG_PAX_REFCOUNT
24073 + jno 0f
24074 + subl %eax, (v)
24075 + sbbl %edx, 4(v)
24076 + int $4
24077 +0:
24078 + _ASM_EXTABLE(0b, 0b)
24079 +#endif
24080 +
24081 +RET_ENDP
24082 +BEGIN(add_unchecked)
24083 + addl %eax, (v)
24084 + adcl %edx, 4(v)
24085 RET_ENDP
24086 #undef v
24087
24088 @@ -77,6 +99,24 @@ RET_ENDP
24089 BEGIN(add_return)
24090 addl (v), %eax
24091 adcl 4(v), %edx
24092 +
24093 +#ifdef CONFIG_PAX_REFCOUNT
24094 + into
24095 +1234:
24096 + _ASM_EXTABLE(1234b, 2f)
24097 +#endif
24098 +
24099 + movl %eax, (v)
24100 + movl %edx, 4(v)
24101 +
24102 +#ifdef CONFIG_PAX_REFCOUNT
24103 +2:
24104 +#endif
24105 +
24106 +RET_ENDP
24107 +BEGIN(add_return_unchecked)
24108 + addl (v), %eax
24109 + adcl 4(v), %edx
24110 movl %eax, (v)
24111 movl %edx, 4(v)
24112 RET_ENDP
24113 @@ -86,6 +126,20 @@ RET_ENDP
24114 BEGIN(sub)
24115 subl %eax, (v)
24116 sbbl %edx, 4(v)
24117 +
24118 +#ifdef CONFIG_PAX_REFCOUNT
24119 + jno 0f
24120 + addl %eax, (v)
24121 + adcl %edx, 4(v)
24122 + int $4
24123 +0:
24124 + _ASM_EXTABLE(0b, 0b)
24125 +#endif
24126 +
24127 +RET_ENDP
24128 +BEGIN(sub_unchecked)
24129 + subl %eax, (v)
24130 + sbbl %edx, 4(v)
24131 RET_ENDP
24132 #undef v
24133
24134 @@ -96,6 +150,27 @@ BEGIN(sub_return)
24135 sbbl $0, %edx
24136 addl (v), %eax
24137 adcl 4(v), %edx
24138 +
24139 +#ifdef CONFIG_PAX_REFCOUNT
24140 + into
24141 +1234:
24142 + _ASM_EXTABLE(1234b, 2f)
24143 +#endif
24144 +
24145 + movl %eax, (v)
24146 + movl %edx, 4(v)
24147 +
24148 +#ifdef CONFIG_PAX_REFCOUNT
24149 +2:
24150 +#endif
24151 +
24152 +RET_ENDP
24153 +BEGIN(sub_return_unchecked)
24154 + negl %edx
24155 + negl %eax
24156 + sbbl $0, %edx
24157 + addl (v), %eax
24158 + adcl 4(v), %edx
24159 movl %eax, (v)
24160 movl %edx, 4(v)
24161 RET_ENDP
24162 @@ -105,6 +180,20 @@ RET_ENDP
24163 BEGIN(inc)
24164 addl $1, (v)
24165 adcl $0, 4(v)
24166 +
24167 +#ifdef CONFIG_PAX_REFCOUNT
24168 + jno 0f
24169 + subl $1, (v)
24170 + sbbl $0, 4(v)
24171 + int $4
24172 +0:
24173 + _ASM_EXTABLE(0b, 0b)
24174 +#endif
24175 +
24176 +RET_ENDP
24177 +BEGIN(inc_unchecked)
24178 + addl $1, (v)
24179 + adcl $0, 4(v)
24180 RET_ENDP
24181 #undef v
24182
24183 @@ -114,6 +203,26 @@ BEGIN(inc_return)
24184 movl 4(v), %edx
24185 addl $1, %eax
24186 adcl $0, %edx
24187 +
24188 +#ifdef CONFIG_PAX_REFCOUNT
24189 + into
24190 +1234:
24191 + _ASM_EXTABLE(1234b, 2f)
24192 +#endif
24193 +
24194 + movl %eax, (v)
24195 + movl %edx, 4(v)
24196 +
24197 +#ifdef CONFIG_PAX_REFCOUNT
24198 +2:
24199 +#endif
24200 +
24201 +RET_ENDP
24202 +BEGIN(inc_return_unchecked)
24203 + movl (v), %eax
24204 + movl 4(v), %edx
24205 + addl $1, %eax
24206 + adcl $0, %edx
24207 movl %eax, (v)
24208 movl %edx, 4(v)
24209 RET_ENDP
24210 @@ -123,6 +232,20 @@ RET_ENDP
24211 BEGIN(dec)
24212 subl $1, (v)
24213 sbbl $0, 4(v)
24214 +
24215 +#ifdef CONFIG_PAX_REFCOUNT
24216 + jno 0f
24217 + addl $1, (v)
24218 + adcl $0, 4(v)
24219 + int $4
24220 +0:
24221 + _ASM_EXTABLE(0b, 0b)
24222 +#endif
24223 +
24224 +RET_ENDP
24225 +BEGIN(dec_unchecked)
24226 + subl $1, (v)
24227 + sbbl $0, 4(v)
24228 RET_ENDP
24229 #undef v
24230
24231 @@ -132,6 +255,26 @@ BEGIN(dec_return)
24232 movl 4(v), %edx
24233 subl $1, %eax
24234 sbbl $0, %edx
24235 +
24236 +#ifdef CONFIG_PAX_REFCOUNT
24237 + into
24238 +1234:
24239 + _ASM_EXTABLE(1234b, 2f)
24240 +#endif
24241 +
24242 + movl %eax, (v)
24243 + movl %edx, 4(v)
24244 +
24245 +#ifdef CONFIG_PAX_REFCOUNT
24246 +2:
24247 +#endif
24248 +
24249 +RET_ENDP
24250 +BEGIN(dec_return_unchecked)
24251 + movl (v), %eax
24252 + movl 4(v), %edx
24253 + subl $1, %eax
24254 + sbbl $0, %edx
24255 movl %eax, (v)
24256 movl %edx, 4(v)
24257 RET_ENDP
24258 @@ -143,6 +286,13 @@ BEGIN(add_unless)
24259 adcl %edx, %edi
24260 addl (v), %eax
24261 adcl 4(v), %edx
24262 +
24263 +#ifdef CONFIG_PAX_REFCOUNT
24264 + into
24265 +1234:
24266 + _ASM_EXTABLE(1234b, 2f)
24267 +#endif
24268 +
24269 cmpl %eax, %ecx
24270 je 3f
24271 1:
24272 @@ -168,6 +318,13 @@ BEGIN(inc_not_zero)
24273 1:
24274 addl $1, %eax
24275 adcl $0, %edx
24276 +
24277 +#ifdef CONFIG_PAX_REFCOUNT
24278 + into
24279 +1234:
24280 + _ASM_EXTABLE(1234b, 2f)
24281 +#endif
24282 +
24283 movl %eax, (v)
24284 movl %edx, 4(v)
24285 movl $1, %eax
24286 @@ -186,6 +343,13 @@ BEGIN(dec_if_positive)
24287 movl 4(v), %edx
24288 subl $1, %eax
24289 sbbl $0, %edx
24290 +
24291 +#ifdef CONFIG_PAX_REFCOUNT
24292 + into
24293 +1234:
24294 + _ASM_EXTABLE(1234b, 1f)
24295 +#endif
24296 +
24297 js 1f
24298 movl %eax, (v)
24299 movl %edx, 4(v)
24300 diff --git a/arch/x86/lib/atomic64_cx8_32.S b/arch/x86/lib/atomic64_cx8_32.S
24301 index f5cc9eb..51fa319 100644
24302 --- a/arch/x86/lib/atomic64_cx8_32.S
24303 +++ b/arch/x86/lib/atomic64_cx8_32.S
24304 @@ -35,10 +35,20 @@ ENTRY(atomic64_read_cx8)
24305 CFI_STARTPROC
24306
24307 read64 %ecx
24308 + pax_force_retaddr
24309 ret
24310 CFI_ENDPROC
24311 ENDPROC(atomic64_read_cx8)
24312
24313 +ENTRY(atomic64_read_unchecked_cx8)
24314 + CFI_STARTPROC
24315 +
24316 + read64 %ecx
24317 + pax_force_retaddr
24318 + ret
24319 + CFI_ENDPROC
24320 +ENDPROC(atomic64_read_unchecked_cx8)
24321 +
24322 ENTRY(atomic64_set_cx8)
24323 CFI_STARTPROC
24324
24325 @@ -48,10 +58,25 @@ ENTRY(atomic64_set_cx8)
24326 cmpxchg8b (%esi)
24327 jne 1b
24328
24329 + pax_force_retaddr
24330 ret
24331 CFI_ENDPROC
24332 ENDPROC(atomic64_set_cx8)
24333
24334 +ENTRY(atomic64_set_unchecked_cx8)
24335 + CFI_STARTPROC
24336 +
24337 +1:
24338 +/* we don't need LOCK_PREFIX since aligned 64-bit writes
24339 + * are atomic on 586 and newer */
24340 + cmpxchg8b (%esi)
24341 + jne 1b
24342 +
24343 + pax_force_retaddr
24344 + ret
24345 + CFI_ENDPROC
24346 +ENDPROC(atomic64_set_unchecked_cx8)
24347 +
24348 ENTRY(atomic64_xchg_cx8)
24349 CFI_STARTPROC
24350
24351 @@ -60,12 +85,13 @@ ENTRY(atomic64_xchg_cx8)
24352 cmpxchg8b (%esi)
24353 jne 1b
24354
24355 + pax_force_retaddr
24356 ret
24357 CFI_ENDPROC
24358 ENDPROC(atomic64_xchg_cx8)
24359
24360 -.macro addsub_return func ins insc
24361 -ENTRY(atomic64_\func\()_return_cx8)
24362 +.macro addsub_return func ins insc unchecked=""
24363 +ENTRY(atomic64_\func\()_return\unchecked\()_cx8)
24364 CFI_STARTPROC
24365 SAVE ebp
24366 SAVE ebx
24367 @@ -82,27 +108,44 @@ ENTRY(atomic64_\func\()_return_cx8)
24368 movl %edx, %ecx
24369 \ins\()l %esi, %ebx
24370 \insc\()l %edi, %ecx
24371 +
24372 +.ifb \unchecked
24373 +#ifdef CONFIG_PAX_REFCOUNT
24374 + into
24375 +2:
24376 + _ASM_EXTABLE(2b, 3f)
24377 +#endif
24378 +.endif
24379 +
24380 LOCK_PREFIX
24381 cmpxchg8b (%ebp)
24382 jne 1b
24383 -
24384 -10:
24385 movl %ebx, %eax
24386 movl %ecx, %edx
24387 +
24388 +.ifb \unchecked
24389 +#ifdef CONFIG_PAX_REFCOUNT
24390 +3:
24391 +#endif
24392 +.endif
24393 +
24394 RESTORE edi
24395 RESTORE esi
24396 RESTORE ebx
24397 RESTORE ebp
24398 + pax_force_retaddr
24399 ret
24400 CFI_ENDPROC
24401 -ENDPROC(atomic64_\func\()_return_cx8)
24402 +ENDPROC(atomic64_\func\()_return\unchecked\()_cx8)
24403 .endm
24404
24405 addsub_return add add adc
24406 addsub_return sub sub sbb
24407 +addsub_return add add adc _unchecked
24408 +addsub_return sub sub sbb _unchecked
24409
24410 -.macro incdec_return func ins insc
24411 -ENTRY(atomic64_\func\()_return_cx8)
24412 +.macro incdec_return func ins insc unchecked=""
24413 +ENTRY(atomic64_\func\()_return\unchecked\()_cx8)
24414 CFI_STARTPROC
24415 SAVE ebx
24416
24417 @@ -112,21 +155,39 @@ ENTRY(atomic64_\func\()_return_cx8)
24418 movl %edx, %ecx
24419 \ins\()l $1, %ebx
24420 \insc\()l $0, %ecx
24421 +
24422 +.ifb \unchecked
24423 +#ifdef CONFIG_PAX_REFCOUNT
24424 + into
24425 +2:
24426 + _ASM_EXTABLE(2b, 3f)
24427 +#endif
24428 +.endif
24429 +
24430 LOCK_PREFIX
24431 cmpxchg8b (%esi)
24432 jne 1b
24433
24434 -10:
24435 movl %ebx, %eax
24436 movl %ecx, %edx
24437 +
24438 +.ifb \unchecked
24439 +#ifdef CONFIG_PAX_REFCOUNT
24440 +3:
24441 +#endif
24442 +.endif
24443 +
24444 RESTORE ebx
24445 + pax_force_retaddr
24446 ret
24447 CFI_ENDPROC
24448 -ENDPROC(atomic64_\func\()_return_cx8)
24449 +ENDPROC(atomic64_\func\()_return\unchecked\()_cx8)
24450 .endm
24451
24452 incdec_return inc add adc
24453 incdec_return dec sub sbb
24454 +incdec_return inc add adc _unchecked
24455 +incdec_return dec sub sbb _unchecked
24456
24457 ENTRY(atomic64_dec_if_positive_cx8)
24458 CFI_STARTPROC
24459 @@ -138,6 +199,13 @@ ENTRY(atomic64_dec_if_positive_cx8)
24460 movl %edx, %ecx
24461 subl $1, %ebx
24462 sbb $0, %ecx
24463 +
24464 +#ifdef CONFIG_PAX_REFCOUNT
24465 + into
24466 +1234:
24467 + _ASM_EXTABLE(1234b, 2f)
24468 +#endif
24469 +
24470 js 2f
24471 LOCK_PREFIX
24472 cmpxchg8b (%esi)
24473 @@ -147,6 +215,7 @@ ENTRY(atomic64_dec_if_positive_cx8)
24474 movl %ebx, %eax
24475 movl %ecx, %edx
24476 RESTORE ebx
24477 + pax_force_retaddr
24478 ret
24479 CFI_ENDPROC
24480 ENDPROC(atomic64_dec_if_positive_cx8)
24481 @@ -171,6 +240,13 @@ ENTRY(atomic64_add_unless_cx8)
24482 movl %edx, %ecx
24483 addl %ebp, %ebx
24484 adcl %edi, %ecx
24485 +
24486 +#ifdef CONFIG_PAX_REFCOUNT
24487 + into
24488 +1234:
24489 + _ASM_EXTABLE(1234b, 3f)
24490 +#endif
24491 +
24492 LOCK_PREFIX
24493 cmpxchg8b (%esi)
24494 jne 1b
24495 @@ -181,6 +257,7 @@ ENTRY(atomic64_add_unless_cx8)
24496 CFI_ADJUST_CFA_OFFSET -8
24497 RESTORE ebx
24498 RESTORE ebp
24499 + pax_force_retaddr
24500 ret
24501 4:
24502 cmpl %edx, 4(%esp)
24503 @@ -203,6 +280,13 @@ ENTRY(atomic64_inc_not_zero_cx8)
24504 xorl %ecx, %ecx
24505 addl $1, %ebx
24506 adcl %edx, %ecx
24507 +
24508 +#ifdef CONFIG_PAX_REFCOUNT
24509 + into
24510 +1234:
24511 + _ASM_EXTABLE(1234b, 3f)
24512 +#endif
24513 +
24514 LOCK_PREFIX
24515 cmpxchg8b (%esi)
24516 jne 1b
24517 @@ -210,6 +294,7 @@ ENTRY(atomic64_inc_not_zero_cx8)
24518 movl $1, %eax
24519 3:
24520 RESTORE ebx
24521 + pax_force_retaddr
24522 ret
24523 CFI_ENDPROC
24524 ENDPROC(atomic64_inc_not_zero_cx8)
24525 diff --git a/arch/x86/lib/checksum_32.S b/arch/x86/lib/checksum_32.S
24526 index 2af5df3..62b1a5a 100644
24527 --- a/arch/x86/lib/checksum_32.S
24528 +++ b/arch/x86/lib/checksum_32.S
24529 @@ -29,7 +29,8 @@
24530 #include <asm/dwarf2.h>
24531 #include <asm/errno.h>
24532 #include <asm/asm.h>
24533 -
24534 +#include <asm/segment.h>
24535 +
24536 /*
24537 * computes a partial checksum, e.g. for TCP/UDP fragments
24538 */
24539 @@ -293,9 +294,24 @@ unsigned int csum_partial_copy_generic (const char *src, char *dst,
24540
24541 #define ARGBASE 16
24542 #define FP 12
24543 -
24544 -ENTRY(csum_partial_copy_generic)
24545 +
24546 +ENTRY(csum_partial_copy_generic_to_user)
24547 CFI_STARTPROC
24548 +
24549 +#ifdef CONFIG_PAX_MEMORY_UDEREF
24550 + pushl_cfi %gs
24551 + popl_cfi %es
24552 + jmp csum_partial_copy_generic
24553 +#endif
24554 +
24555 +ENTRY(csum_partial_copy_generic_from_user)
24556 +
24557 +#ifdef CONFIG_PAX_MEMORY_UDEREF
24558 + pushl_cfi %gs
24559 + popl_cfi %ds
24560 +#endif
24561 +
24562 +ENTRY(csum_partial_copy_generic)
24563 subl $4,%esp
24564 CFI_ADJUST_CFA_OFFSET 4
24565 pushl_cfi %edi
24566 @@ -317,7 +333,7 @@ ENTRY(csum_partial_copy_generic)
24567 jmp 4f
24568 SRC(1: movw (%esi), %bx )
24569 addl $2, %esi
24570 -DST( movw %bx, (%edi) )
24571 +DST( movw %bx, %es:(%edi) )
24572 addl $2, %edi
24573 addw %bx, %ax
24574 adcl $0, %eax
24575 @@ -329,30 +345,30 @@ DST( movw %bx, (%edi) )
24576 SRC(1: movl (%esi), %ebx )
24577 SRC( movl 4(%esi), %edx )
24578 adcl %ebx, %eax
24579 -DST( movl %ebx, (%edi) )
24580 +DST( movl %ebx, %es:(%edi) )
24581 adcl %edx, %eax
24582 -DST( movl %edx, 4(%edi) )
24583 +DST( movl %edx, %es:4(%edi) )
24584
24585 SRC( movl 8(%esi), %ebx )
24586 SRC( movl 12(%esi), %edx )
24587 adcl %ebx, %eax
24588 -DST( movl %ebx, 8(%edi) )
24589 +DST( movl %ebx, %es:8(%edi) )
24590 adcl %edx, %eax
24591 -DST( movl %edx, 12(%edi) )
24592 +DST( movl %edx, %es:12(%edi) )
24593
24594 SRC( movl 16(%esi), %ebx )
24595 SRC( movl 20(%esi), %edx )
24596 adcl %ebx, %eax
24597 -DST( movl %ebx, 16(%edi) )
24598 +DST( movl %ebx, %es:16(%edi) )
24599 adcl %edx, %eax
24600 -DST( movl %edx, 20(%edi) )
24601 +DST( movl %edx, %es:20(%edi) )
24602
24603 SRC( movl 24(%esi), %ebx )
24604 SRC( movl 28(%esi), %edx )
24605 adcl %ebx, %eax
24606 -DST( movl %ebx, 24(%edi) )
24607 +DST( movl %ebx, %es:24(%edi) )
24608 adcl %edx, %eax
24609 -DST( movl %edx, 28(%edi) )
24610 +DST( movl %edx, %es:28(%edi) )
24611
24612 lea 32(%esi), %esi
24613 lea 32(%edi), %edi
24614 @@ -366,7 +382,7 @@ DST( movl %edx, 28(%edi) )
24615 shrl $2, %edx # This clears CF
24616 SRC(3: movl (%esi), %ebx )
24617 adcl %ebx, %eax
24618 -DST( movl %ebx, (%edi) )
24619 +DST( movl %ebx, %es:(%edi) )
24620 lea 4(%esi), %esi
24621 lea 4(%edi), %edi
24622 dec %edx
24623 @@ -378,12 +394,12 @@ DST( movl %ebx, (%edi) )
24624 jb 5f
24625 SRC( movw (%esi), %cx )
24626 leal 2(%esi), %esi
24627 -DST( movw %cx, (%edi) )
24628 +DST( movw %cx, %es:(%edi) )
24629 leal 2(%edi), %edi
24630 je 6f
24631 shll $16,%ecx
24632 SRC(5: movb (%esi), %cl )
24633 -DST( movb %cl, (%edi) )
24634 +DST( movb %cl, %es:(%edi) )
24635 6: addl %ecx, %eax
24636 adcl $0, %eax
24637 7:
24638 @@ -394,7 +410,7 @@ DST( movb %cl, (%edi) )
24639
24640 6001:
24641 movl ARGBASE+20(%esp), %ebx # src_err_ptr
24642 - movl $-EFAULT, (%ebx)
24643 + movl $-EFAULT, %ss:(%ebx)
24644
24645 # zero the complete destination - computing the rest
24646 # is too much work
24647 @@ -407,11 +423,15 @@ DST( movb %cl, (%edi) )
24648
24649 6002:
24650 movl ARGBASE+24(%esp), %ebx # dst_err_ptr
24651 - movl $-EFAULT,(%ebx)
24652 + movl $-EFAULT,%ss:(%ebx)
24653 jmp 5000b
24654
24655 .previous
24656
24657 + pushl_cfi %ss
24658 + popl_cfi %ds
24659 + pushl_cfi %ss
24660 + popl_cfi %es
24661 popl_cfi %ebx
24662 CFI_RESTORE ebx
24663 popl_cfi %esi
24664 @@ -421,26 +441,43 @@ DST( movb %cl, (%edi) )
24665 popl_cfi %ecx # equivalent to addl $4,%esp
24666 ret
24667 CFI_ENDPROC
24668 -ENDPROC(csum_partial_copy_generic)
24669 +ENDPROC(csum_partial_copy_generic_to_user)
24670
24671 #else
24672
24673 /* Version for PentiumII/PPro */
24674
24675 #define ROUND1(x) \
24676 + nop; nop; nop; \
24677 SRC(movl x(%esi), %ebx ) ; \
24678 addl %ebx, %eax ; \
24679 - DST(movl %ebx, x(%edi) ) ;
24680 + DST(movl %ebx, %es:x(%edi)) ;
24681
24682 #define ROUND(x) \
24683 + nop; nop; nop; \
24684 SRC(movl x(%esi), %ebx ) ; \
24685 adcl %ebx, %eax ; \
24686 - DST(movl %ebx, x(%edi) ) ;
24687 + DST(movl %ebx, %es:x(%edi)) ;
24688
24689 #define ARGBASE 12
24690 -
24691 -ENTRY(csum_partial_copy_generic)
24692 +
24693 +ENTRY(csum_partial_copy_generic_to_user)
24694 CFI_STARTPROC
24695 +
24696 +#ifdef CONFIG_PAX_MEMORY_UDEREF
24697 + pushl_cfi %gs
24698 + popl_cfi %es
24699 + jmp csum_partial_copy_generic
24700 +#endif
24701 +
24702 +ENTRY(csum_partial_copy_generic_from_user)
24703 +
24704 +#ifdef CONFIG_PAX_MEMORY_UDEREF
24705 + pushl_cfi %gs
24706 + popl_cfi %ds
24707 +#endif
24708 +
24709 +ENTRY(csum_partial_copy_generic)
24710 pushl_cfi %ebx
24711 CFI_REL_OFFSET ebx, 0
24712 pushl_cfi %edi
24713 @@ -461,7 +498,7 @@ ENTRY(csum_partial_copy_generic)
24714 subl %ebx, %edi
24715 lea -1(%esi),%edx
24716 andl $-32,%edx
24717 - lea 3f(%ebx,%ebx), %ebx
24718 + lea 3f(%ebx,%ebx,2), %ebx
24719 testl %esi, %esi
24720 jmp *%ebx
24721 1: addl $64,%esi
24722 @@ -482,19 +519,19 @@ ENTRY(csum_partial_copy_generic)
24723 jb 5f
24724 SRC( movw (%esi), %dx )
24725 leal 2(%esi), %esi
24726 -DST( movw %dx, (%edi) )
24727 +DST( movw %dx, %es:(%edi) )
24728 leal 2(%edi), %edi
24729 je 6f
24730 shll $16,%edx
24731 5:
24732 SRC( movb (%esi), %dl )
24733 -DST( movb %dl, (%edi) )
24734 +DST( movb %dl, %es:(%edi) )
24735 6: addl %edx, %eax
24736 adcl $0, %eax
24737 7:
24738 .section .fixup, "ax"
24739 6001: movl ARGBASE+20(%esp), %ebx # src_err_ptr
24740 - movl $-EFAULT, (%ebx)
24741 + movl $-EFAULT, %ss:(%ebx)
24742 # zero the complete destination (computing the rest is too much work)
24743 movl ARGBASE+8(%esp),%edi # dst
24744 movl ARGBASE+12(%esp),%ecx # len
24745 @@ -502,10 +539,17 @@ DST( movb %dl, (%edi) )
24746 rep; stosb
24747 jmp 7b
24748 6002: movl ARGBASE+24(%esp), %ebx # dst_err_ptr
24749 - movl $-EFAULT, (%ebx)
24750 + movl $-EFAULT, %ss:(%ebx)
24751 jmp 7b
24752 .previous
24753
24754 +#ifdef CONFIG_PAX_MEMORY_UDEREF
24755 + pushl_cfi %ss
24756 + popl_cfi %ds
24757 + pushl_cfi %ss
24758 + popl_cfi %es
24759 +#endif
24760 +
24761 popl_cfi %esi
24762 CFI_RESTORE esi
24763 popl_cfi %edi
24764 @@ -514,7 +558,7 @@ DST( movb %dl, (%edi) )
24765 CFI_RESTORE ebx
24766 ret
24767 CFI_ENDPROC
24768 -ENDPROC(csum_partial_copy_generic)
24769 +ENDPROC(csum_partial_copy_generic_to_user)
24770
24771 #undef ROUND
24772 #undef ROUND1
24773 diff --git a/arch/x86/lib/clear_page_64.S b/arch/x86/lib/clear_page_64.S
24774 index f2145cf..cea889d 100644
24775 --- a/arch/x86/lib/clear_page_64.S
24776 +++ b/arch/x86/lib/clear_page_64.S
24777 @@ -11,6 +11,7 @@ ENTRY(clear_page_c)
24778 movl $4096/8,%ecx
24779 xorl %eax,%eax
24780 rep stosq
24781 + pax_force_retaddr
24782 ret
24783 CFI_ENDPROC
24784 ENDPROC(clear_page_c)
24785 @@ -20,6 +21,7 @@ ENTRY(clear_page_c_e)
24786 movl $4096,%ecx
24787 xorl %eax,%eax
24788 rep stosb
24789 + pax_force_retaddr
24790 ret
24791 CFI_ENDPROC
24792 ENDPROC(clear_page_c_e)
24793 @@ -43,6 +45,7 @@ ENTRY(clear_page)
24794 leaq 64(%rdi),%rdi
24795 jnz .Lloop
24796 nop
24797 + pax_force_retaddr
24798 ret
24799 CFI_ENDPROC
24800 .Lclear_page_end:
24801 @@ -58,7 +61,7 @@ ENDPROC(clear_page)
24802
24803 #include <asm/cpufeature.h>
24804
24805 - .section .altinstr_replacement,"ax"
24806 + .section .altinstr_replacement,"a"
24807 1: .byte 0xeb /* jmp <disp8> */
24808 .byte (clear_page_c - clear_page) - (2f - 1b) /* offset */
24809 2: .byte 0xeb /* jmp <disp8> */
24810 diff --git a/arch/x86/lib/cmpxchg16b_emu.S b/arch/x86/lib/cmpxchg16b_emu.S
24811 index 1e572c5..2a162cd 100644
24812 --- a/arch/x86/lib/cmpxchg16b_emu.S
24813 +++ b/arch/x86/lib/cmpxchg16b_emu.S
24814 @@ -53,11 +53,13 @@ this_cpu_cmpxchg16b_emu:
24815
24816 popf
24817 mov $1, %al
24818 + pax_force_retaddr
24819 ret
24820
24821 not_same:
24822 popf
24823 xor %al,%al
24824 + pax_force_retaddr
24825 ret
24826
24827 CFI_ENDPROC
24828 diff --git a/arch/x86/lib/copy_page_64.S b/arch/x86/lib/copy_page_64.S
24829 index 176cca6..1166c50 100644
24830 --- a/arch/x86/lib/copy_page_64.S
24831 +++ b/arch/x86/lib/copy_page_64.S
24832 @@ -9,6 +9,7 @@ copy_page_rep:
24833 CFI_STARTPROC
24834 movl $4096/8, %ecx
24835 rep movsq
24836 + pax_force_retaddr
24837 ret
24838 CFI_ENDPROC
24839 ENDPROC(copy_page_rep)
24840 @@ -20,12 +21,14 @@ ENDPROC(copy_page_rep)
24841
24842 ENTRY(copy_page)
24843 CFI_STARTPROC
24844 - subq $2*8, %rsp
24845 - CFI_ADJUST_CFA_OFFSET 2*8
24846 + subq $3*8, %rsp
24847 + CFI_ADJUST_CFA_OFFSET 3*8
24848 movq %rbx, (%rsp)
24849 CFI_REL_OFFSET rbx, 0
24850 movq %r12, 1*8(%rsp)
24851 CFI_REL_OFFSET r12, 1*8
24852 + movq %r13, 2*8(%rsp)
24853 + CFI_REL_OFFSET r13, 2*8
24854
24855 movl $(4096/64)-5, %ecx
24856 .p2align 4
24857 @@ -36,7 +39,7 @@ ENTRY(copy_page)
24858 movq 0x8*2(%rsi), %rdx
24859 movq 0x8*3(%rsi), %r8
24860 movq 0x8*4(%rsi), %r9
24861 - movq 0x8*5(%rsi), %r10
24862 + movq 0x8*5(%rsi), %r13
24863 movq 0x8*6(%rsi), %r11
24864 movq 0x8*7(%rsi), %r12
24865
24866 @@ -47,7 +50,7 @@ ENTRY(copy_page)
24867 movq %rdx, 0x8*2(%rdi)
24868 movq %r8, 0x8*3(%rdi)
24869 movq %r9, 0x8*4(%rdi)
24870 - movq %r10, 0x8*5(%rdi)
24871 + movq %r13, 0x8*5(%rdi)
24872 movq %r11, 0x8*6(%rdi)
24873 movq %r12, 0x8*7(%rdi)
24874
24875 @@ -66,7 +69,7 @@ ENTRY(copy_page)
24876 movq 0x8*2(%rsi), %rdx
24877 movq 0x8*3(%rsi), %r8
24878 movq 0x8*4(%rsi), %r9
24879 - movq 0x8*5(%rsi), %r10
24880 + movq 0x8*5(%rsi), %r13
24881 movq 0x8*6(%rsi), %r11
24882 movq 0x8*7(%rsi), %r12
24883
24884 @@ -75,7 +78,7 @@ ENTRY(copy_page)
24885 movq %rdx, 0x8*2(%rdi)
24886 movq %r8, 0x8*3(%rdi)
24887 movq %r9, 0x8*4(%rdi)
24888 - movq %r10, 0x8*5(%rdi)
24889 + movq %r13, 0x8*5(%rdi)
24890 movq %r11, 0x8*6(%rdi)
24891 movq %r12, 0x8*7(%rdi)
24892
24893 @@ -87,8 +90,11 @@ ENTRY(copy_page)
24894 CFI_RESTORE rbx
24895 movq 1*8(%rsp), %r12
24896 CFI_RESTORE r12
24897 - addq $2*8, %rsp
24898 - CFI_ADJUST_CFA_OFFSET -2*8
24899 + movq 2*8(%rsp), %r13
24900 + CFI_RESTORE r13
24901 + addq $3*8, %rsp
24902 + CFI_ADJUST_CFA_OFFSET -3*8
24903 + pax_force_retaddr
24904 ret
24905 .Lcopy_page_end:
24906 CFI_ENDPROC
24907 @@ -99,7 +105,7 @@ ENDPROC(copy_page)
24908
24909 #include <asm/cpufeature.h>
24910
24911 - .section .altinstr_replacement,"ax"
24912 + .section .altinstr_replacement,"a"
24913 1: .byte 0xeb /* jmp <disp8> */
24914 .byte (copy_page_rep - copy_page) - (2f - 1b) /* offset */
24915 2:
24916 diff --git a/arch/x86/lib/copy_user_64.S b/arch/x86/lib/copy_user_64.S
24917 index a30ca15..d25fab6 100644
24918 --- a/arch/x86/lib/copy_user_64.S
24919 +++ b/arch/x86/lib/copy_user_64.S
24920 @@ -18,6 +18,7 @@
24921 #include <asm/alternative-asm.h>
24922 #include <asm/asm.h>
24923 #include <asm/smap.h>
24924 +#include <asm/pgtable.h>
24925
24926 /*
24927 * By placing feature2 after feature1 in altinstructions section, we logically
24928 @@ -31,7 +32,7 @@
24929 .byte 0xe9 /* 32bit jump */
24930 .long \orig-1f /* by default jump to orig */
24931 1:
24932 - .section .altinstr_replacement,"ax"
24933 + .section .altinstr_replacement,"a"
24934 2: .byte 0xe9 /* near jump with 32bit immediate */
24935 .long \alt1-1b /* offset */ /* or alternatively to alt1 */
24936 3: .byte 0xe9 /* near jump with 32bit immediate */
24937 @@ -70,47 +71,20 @@
24938 #endif
24939 .endm
24940
24941 -/* Standard copy_to_user with segment limit checking */
24942 -ENTRY(_copy_to_user)
24943 - CFI_STARTPROC
24944 - GET_THREAD_INFO(%rax)
24945 - movq %rdi,%rcx
24946 - addq %rdx,%rcx
24947 - jc bad_to_user
24948 - cmpq TI_addr_limit(%rax),%rcx
24949 - ja bad_to_user
24950 - ALTERNATIVE_JUMP X86_FEATURE_REP_GOOD,X86_FEATURE_ERMS, \
24951 - copy_user_generic_unrolled,copy_user_generic_string, \
24952 - copy_user_enhanced_fast_string
24953 - CFI_ENDPROC
24954 -ENDPROC(_copy_to_user)
24955 -
24956 -/* Standard copy_from_user with segment limit checking */
24957 -ENTRY(_copy_from_user)
24958 - CFI_STARTPROC
24959 - GET_THREAD_INFO(%rax)
24960 - movq %rsi,%rcx
24961 - addq %rdx,%rcx
24962 - jc bad_from_user
24963 - cmpq TI_addr_limit(%rax),%rcx
24964 - ja bad_from_user
24965 - ALTERNATIVE_JUMP X86_FEATURE_REP_GOOD,X86_FEATURE_ERMS, \
24966 - copy_user_generic_unrolled,copy_user_generic_string, \
24967 - copy_user_enhanced_fast_string
24968 - CFI_ENDPROC
24969 -ENDPROC(_copy_from_user)
24970 -
24971 .section .fixup,"ax"
24972 /* must zero dest */
24973 ENTRY(bad_from_user)
24974 bad_from_user:
24975 CFI_STARTPROC
24976 + testl %edx,%edx
24977 + js bad_to_user
24978 movl %edx,%ecx
24979 xorl %eax,%eax
24980 rep
24981 stosb
24982 bad_to_user:
24983 movl %edx,%eax
24984 + pax_force_retaddr
24985 ret
24986 CFI_ENDPROC
24987 ENDPROC(bad_from_user)
24988 @@ -141,19 +115,19 @@ ENTRY(copy_user_generic_unrolled)
24989 jz 17f
24990 1: movq (%rsi),%r8
24991 2: movq 1*8(%rsi),%r9
24992 -3: movq 2*8(%rsi),%r10
24993 +3: movq 2*8(%rsi),%rax
24994 4: movq 3*8(%rsi),%r11
24995 5: movq %r8,(%rdi)
24996 6: movq %r9,1*8(%rdi)
24997 -7: movq %r10,2*8(%rdi)
24998 +7: movq %rax,2*8(%rdi)
24999 8: movq %r11,3*8(%rdi)
25000 9: movq 4*8(%rsi),%r8
25001 10: movq 5*8(%rsi),%r9
25002 -11: movq 6*8(%rsi),%r10
25003 +11: movq 6*8(%rsi),%rax
25004 12: movq 7*8(%rsi),%r11
25005 13: movq %r8,4*8(%rdi)
25006 14: movq %r9,5*8(%rdi)
25007 -15: movq %r10,6*8(%rdi)
25008 +15: movq %rax,6*8(%rdi)
25009 16: movq %r11,7*8(%rdi)
25010 leaq 64(%rsi),%rsi
25011 leaq 64(%rdi),%rdi
25012 @@ -180,6 +154,7 @@ ENTRY(copy_user_generic_unrolled)
25013 jnz 21b
25014 23: xor %eax,%eax
25015 ASM_CLAC
25016 + pax_force_retaddr
25017 ret
25018
25019 .section .fixup,"ax"
25020 @@ -251,6 +226,7 @@ ENTRY(copy_user_generic_string)
25021 movsb
25022 4: xorl %eax,%eax
25023 ASM_CLAC
25024 + pax_force_retaddr
25025 ret
25026
25027 .section .fixup,"ax"
25028 @@ -286,6 +262,7 @@ ENTRY(copy_user_enhanced_fast_string)
25029 movsb
25030 2: xorl %eax,%eax
25031 ASM_CLAC
25032 + pax_force_retaddr
25033 ret
25034
25035 .section .fixup,"ax"
25036 diff --git a/arch/x86/lib/copy_user_nocache_64.S b/arch/x86/lib/copy_user_nocache_64.S
25037 index 6a4f43c..f5f9e26 100644
25038 --- a/arch/x86/lib/copy_user_nocache_64.S
25039 +++ b/arch/x86/lib/copy_user_nocache_64.S
25040 @@ -8,6 +8,7 @@
25041
25042 #include <linux/linkage.h>
25043 #include <asm/dwarf2.h>
25044 +#include <asm/alternative-asm.h>
25045
25046 #define FIX_ALIGNMENT 1
25047
25048 @@ -16,6 +17,7 @@
25049 #include <asm/thread_info.h>
25050 #include <asm/asm.h>
25051 #include <asm/smap.h>
25052 +#include <asm/pgtable.h>
25053
25054 .macro ALIGN_DESTINATION
25055 #ifdef FIX_ALIGNMENT
25056 @@ -49,6 +51,15 @@
25057 */
25058 ENTRY(__copy_user_nocache)
25059 CFI_STARTPROC
25060 +
25061 +#ifdef CONFIG_PAX_MEMORY_UDEREF
25062 + mov $PAX_USER_SHADOW_BASE,%rcx
25063 + cmp %rcx,%rsi
25064 + jae 1f
25065 + add %rcx,%rsi
25066 +1:
25067 +#endif
25068 +
25069 ASM_STAC
25070 cmpl $8,%edx
25071 jb 20f /* less then 8 bytes, go to byte copy loop */
25072 @@ -59,19 +70,19 @@ ENTRY(__copy_user_nocache)
25073 jz 17f
25074 1: movq (%rsi),%r8
25075 2: movq 1*8(%rsi),%r9
25076 -3: movq 2*8(%rsi),%r10
25077 +3: movq 2*8(%rsi),%rax
25078 4: movq 3*8(%rsi),%r11
25079 5: movnti %r8,(%rdi)
25080 6: movnti %r9,1*8(%rdi)
25081 -7: movnti %r10,2*8(%rdi)
25082 +7: movnti %rax,2*8(%rdi)
25083 8: movnti %r11,3*8(%rdi)
25084 9: movq 4*8(%rsi),%r8
25085 10: movq 5*8(%rsi),%r9
25086 -11: movq 6*8(%rsi),%r10
25087 +11: movq 6*8(%rsi),%rax
25088 12: movq 7*8(%rsi),%r11
25089 13: movnti %r8,4*8(%rdi)
25090 14: movnti %r9,5*8(%rdi)
25091 -15: movnti %r10,6*8(%rdi)
25092 +15: movnti %rax,6*8(%rdi)
25093 16: movnti %r11,7*8(%rdi)
25094 leaq 64(%rsi),%rsi
25095 leaq 64(%rdi),%rdi
25096 @@ -99,6 +110,7 @@ ENTRY(__copy_user_nocache)
25097 23: xorl %eax,%eax
25098 ASM_CLAC
25099 sfence
25100 + pax_force_retaddr
25101 ret
25102
25103 .section .fixup,"ax"
25104 diff --git a/arch/x86/lib/csum-copy_64.S b/arch/x86/lib/csum-copy_64.S
25105 index 2419d5f..953ee51 100644
25106 --- a/arch/x86/lib/csum-copy_64.S
25107 +++ b/arch/x86/lib/csum-copy_64.S
25108 @@ -9,6 +9,7 @@
25109 #include <asm/dwarf2.h>
25110 #include <asm/errno.h>
25111 #include <asm/asm.h>
25112 +#include <asm/alternative-asm.h>
25113
25114 /*
25115 * Checksum copy with exception handling.
25116 @@ -220,6 +221,7 @@ ENTRY(csum_partial_copy_generic)
25117 CFI_RESTORE rbp
25118 addq $7*8, %rsp
25119 CFI_ADJUST_CFA_OFFSET -7*8
25120 + pax_force_retaddr 0, 1
25121 ret
25122 CFI_RESTORE_STATE
25123
25124 diff --git a/arch/x86/lib/csum-wrappers_64.c b/arch/x86/lib/csum-wrappers_64.c
25125 index 25b7ae8..169fafc 100644
25126 --- a/arch/x86/lib/csum-wrappers_64.c
25127 +++ b/arch/x86/lib/csum-wrappers_64.c
25128 @@ -52,7 +52,7 @@ csum_partial_copy_from_user(const void __user *src, void *dst,
25129 len -= 2;
25130 }
25131 }
25132 - isum = csum_partial_copy_generic((__force const void *)src,
25133 + isum = csum_partial_copy_generic((const void __force_kernel *)____m(src),
25134 dst, len, isum, errp, NULL);
25135 if (unlikely(*errp))
25136 goto out_err;
25137 @@ -105,7 +105,7 @@ csum_partial_copy_to_user(const void *src, void __user *dst,
25138 }
25139
25140 *errp = 0;
25141 - return csum_partial_copy_generic(src, (void __force *)dst,
25142 + return csum_partial_copy_generic(src, (void __force_kernel *)____m(dst),
25143 len, isum, NULL, errp);
25144 }
25145 EXPORT_SYMBOL(csum_partial_copy_to_user);
25146 diff --git a/arch/x86/lib/getuser.S b/arch/x86/lib/getuser.S
25147 index 156b9c8..b144132 100644
25148 --- a/arch/x86/lib/getuser.S
25149 +++ b/arch/x86/lib/getuser.S
25150 @@ -34,17 +34,40 @@
25151 #include <asm/thread_info.h>
25152 #include <asm/asm.h>
25153 #include <asm/smap.h>
25154 +#include <asm/segment.h>
25155 +#include <asm/pgtable.h>
25156 +#include <asm/alternative-asm.h>
25157 +
25158 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
25159 +#define __copyuser_seg gs;
25160 +#else
25161 +#define __copyuser_seg
25162 +#endif
25163
25164 .text
25165 ENTRY(__get_user_1)
25166 CFI_STARTPROC
25167 +
25168 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
25169 GET_THREAD_INFO(%_ASM_DX)
25170 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
25171 jae bad_get_user
25172 ASM_STAC
25173 -1: movzb (%_ASM_AX),%edx
25174 +
25175 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
25176 + mov $PAX_USER_SHADOW_BASE,%_ASM_DX
25177 + cmp %_ASM_DX,%_ASM_AX
25178 + jae 1234f
25179 + add %_ASM_DX,%_ASM_AX
25180 +1234:
25181 +#endif
25182 +
25183 +#endif
25184 +
25185 +1: __copyuser_seg movzb (%_ASM_AX),%edx
25186 xor %eax,%eax
25187 ASM_CLAC
25188 + pax_force_retaddr
25189 ret
25190 CFI_ENDPROC
25191 ENDPROC(__get_user_1)
25192 @@ -52,14 +75,28 @@ ENDPROC(__get_user_1)
25193 ENTRY(__get_user_2)
25194 CFI_STARTPROC
25195 add $1,%_ASM_AX
25196 +
25197 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
25198 jc bad_get_user
25199 GET_THREAD_INFO(%_ASM_DX)
25200 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
25201 jae bad_get_user
25202 ASM_STAC
25203 -2: movzwl -1(%_ASM_AX),%edx
25204 +
25205 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
25206 + mov $PAX_USER_SHADOW_BASE,%_ASM_DX
25207 + cmp %_ASM_DX,%_ASM_AX
25208 + jae 1234f
25209 + add %_ASM_DX,%_ASM_AX
25210 +1234:
25211 +#endif
25212 +
25213 +#endif
25214 +
25215 +2: __copyuser_seg movzwl -1(%_ASM_AX),%edx
25216 xor %eax,%eax
25217 ASM_CLAC
25218 + pax_force_retaddr
25219 ret
25220 CFI_ENDPROC
25221 ENDPROC(__get_user_2)
25222 @@ -67,14 +104,28 @@ ENDPROC(__get_user_2)
25223 ENTRY(__get_user_4)
25224 CFI_STARTPROC
25225 add $3,%_ASM_AX
25226 +
25227 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
25228 jc bad_get_user
25229 GET_THREAD_INFO(%_ASM_DX)
25230 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
25231 jae bad_get_user
25232 ASM_STAC
25233 -3: mov -3(%_ASM_AX),%edx
25234 +
25235 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
25236 + mov $PAX_USER_SHADOW_BASE,%_ASM_DX
25237 + cmp %_ASM_DX,%_ASM_AX
25238 + jae 1234f
25239 + add %_ASM_DX,%_ASM_AX
25240 +1234:
25241 +#endif
25242 +
25243 +#endif
25244 +
25245 +3: __copyuser_seg mov -3(%_ASM_AX),%edx
25246 xor %eax,%eax
25247 ASM_CLAC
25248 + pax_force_retaddr
25249 ret
25250 CFI_ENDPROC
25251 ENDPROC(__get_user_4)
25252 @@ -87,10 +138,20 @@ ENTRY(__get_user_8)
25253 GET_THREAD_INFO(%_ASM_DX)
25254 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
25255 jae bad_get_user
25256 +
25257 +#ifdef CONFIG_PAX_MEMORY_UDEREF
25258 + mov $PAX_USER_SHADOW_BASE,%_ASM_DX
25259 + cmp %_ASM_DX,%_ASM_AX
25260 + jae 1234f
25261 + add %_ASM_DX,%_ASM_AX
25262 +1234:
25263 +#endif
25264 +
25265 ASM_STAC
25266 4: movq -7(%_ASM_AX),%_ASM_DX
25267 xor %eax,%eax
25268 ASM_CLAC
25269 + pax_force_retaddr
25270 ret
25271 CFI_ENDPROC
25272 ENDPROC(__get_user_8)
25273 @@ -101,6 +162,7 @@ bad_get_user:
25274 xor %edx,%edx
25275 mov $(-EFAULT),%_ASM_AX
25276 ASM_CLAC
25277 + pax_force_retaddr
25278 ret
25279 CFI_ENDPROC
25280 END(bad_get_user)
25281 diff --git a/arch/x86/lib/insn.c b/arch/x86/lib/insn.c
25282 index 54fcffe..7be149e 100644
25283 --- a/arch/x86/lib/insn.c
25284 +++ b/arch/x86/lib/insn.c
25285 @@ -20,8 +20,10 @@
25286
25287 #ifdef __KERNEL__
25288 #include <linux/string.h>
25289 +#include <asm/pgtable_types.h>
25290 #else
25291 #include <string.h>
25292 +#define ktla_ktva(addr) addr
25293 #endif
25294 #include <asm/inat.h>
25295 #include <asm/insn.h>
25296 @@ -53,8 +55,8 @@
25297 void insn_init(struct insn *insn, const void *kaddr, int x86_64)
25298 {
25299 memset(insn, 0, sizeof(*insn));
25300 - insn->kaddr = kaddr;
25301 - insn->next_byte = kaddr;
25302 + insn->kaddr = ktla_ktva(kaddr);
25303 + insn->next_byte = ktla_ktva(kaddr);
25304 insn->x86_64 = x86_64 ? 1 : 0;
25305 insn->opnd_bytes = 4;
25306 if (x86_64)
25307 diff --git a/arch/x86/lib/iomap_copy_64.S b/arch/x86/lib/iomap_copy_64.S
25308 index 05a95e7..326f2fa 100644
25309 --- a/arch/x86/lib/iomap_copy_64.S
25310 +++ b/arch/x86/lib/iomap_copy_64.S
25311 @@ -17,6 +17,7 @@
25312
25313 #include <linux/linkage.h>
25314 #include <asm/dwarf2.h>
25315 +#include <asm/alternative-asm.h>
25316
25317 /*
25318 * override generic version in lib/iomap_copy.c
25319 @@ -25,6 +26,7 @@ ENTRY(__iowrite32_copy)
25320 CFI_STARTPROC
25321 movl %edx,%ecx
25322 rep movsd
25323 + pax_force_retaddr
25324 ret
25325 CFI_ENDPROC
25326 ENDPROC(__iowrite32_copy)
25327 diff --git a/arch/x86/lib/memcpy_64.S b/arch/x86/lib/memcpy_64.S
25328 index 1c273be..da9cc0e 100644
25329 --- a/arch/x86/lib/memcpy_64.S
25330 +++ b/arch/x86/lib/memcpy_64.S
25331 @@ -33,6 +33,7 @@
25332 rep movsq
25333 movl %edx, %ecx
25334 rep movsb
25335 + pax_force_retaddr
25336 ret
25337 .Lmemcpy_e:
25338 .previous
25339 @@ -49,6 +50,7 @@
25340 movq %rdi, %rax
25341 movq %rdx, %rcx
25342 rep movsb
25343 + pax_force_retaddr
25344 ret
25345 .Lmemcpy_e_e:
25346 .previous
25347 @@ -76,13 +78,13 @@ ENTRY(memcpy)
25348 */
25349 movq 0*8(%rsi), %r8
25350 movq 1*8(%rsi), %r9
25351 - movq 2*8(%rsi), %r10
25352 + movq 2*8(%rsi), %rcx
25353 movq 3*8(%rsi), %r11
25354 leaq 4*8(%rsi), %rsi
25355
25356 movq %r8, 0*8(%rdi)
25357 movq %r9, 1*8(%rdi)
25358 - movq %r10, 2*8(%rdi)
25359 + movq %rcx, 2*8(%rdi)
25360 movq %r11, 3*8(%rdi)
25361 leaq 4*8(%rdi), %rdi
25362 jae .Lcopy_forward_loop
25363 @@ -105,12 +107,12 @@ ENTRY(memcpy)
25364 subq $0x20, %rdx
25365 movq -1*8(%rsi), %r8
25366 movq -2*8(%rsi), %r9
25367 - movq -3*8(%rsi), %r10
25368 + movq -3*8(%rsi), %rcx
25369 movq -4*8(%rsi), %r11
25370 leaq -4*8(%rsi), %rsi
25371 movq %r8, -1*8(%rdi)
25372 movq %r9, -2*8(%rdi)
25373 - movq %r10, -3*8(%rdi)
25374 + movq %rcx, -3*8(%rdi)
25375 movq %r11, -4*8(%rdi)
25376 leaq -4*8(%rdi), %rdi
25377 jae .Lcopy_backward_loop
25378 @@ -130,12 +132,13 @@ ENTRY(memcpy)
25379 */
25380 movq 0*8(%rsi), %r8
25381 movq 1*8(%rsi), %r9
25382 - movq -2*8(%rsi, %rdx), %r10
25383 + movq -2*8(%rsi, %rdx), %rcx
25384 movq -1*8(%rsi, %rdx), %r11
25385 movq %r8, 0*8(%rdi)
25386 movq %r9, 1*8(%rdi)
25387 - movq %r10, -2*8(%rdi, %rdx)
25388 + movq %rcx, -2*8(%rdi, %rdx)
25389 movq %r11, -1*8(%rdi, %rdx)
25390 + pax_force_retaddr
25391 retq
25392 .p2align 4
25393 .Lless_16bytes:
25394 @@ -148,6 +151,7 @@ ENTRY(memcpy)
25395 movq -1*8(%rsi, %rdx), %r9
25396 movq %r8, 0*8(%rdi)
25397 movq %r9, -1*8(%rdi, %rdx)
25398 + pax_force_retaddr
25399 retq
25400 .p2align 4
25401 .Lless_8bytes:
25402 @@ -161,6 +165,7 @@ ENTRY(memcpy)
25403 movl -4(%rsi, %rdx), %r8d
25404 movl %ecx, (%rdi)
25405 movl %r8d, -4(%rdi, %rdx)
25406 + pax_force_retaddr
25407 retq
25408 .p2align 4
25409 .Lless_3bytes:
25410 @@ -179,6 +184,7 @@ ENTRY(memcpy)
25411 movb %cl, (%rdi)
25412
25413 .Lend:
25414 + pax_force_retaddr
25415 retq
25416 CFI_ENDPROC
25417 ENDPROC(memcpy)
25418 diff --git a/arch/x86/lib/memmove_64.S b/arch/x86/lib/memmove_64.S
25419 index ee16461..c39c199 100644
25420 --- a/arch/x86/lib/memmove_64.S
25421 +++ b/arch/x86/lib/memmove_64.S
25422 @@ -61,13 +61,13 @@ ENTRY(memmove)
25423 5:
25424 sub $0x20, %rdx
25425 movq 0*8(%rsi), %r11
25426 - movq 1*8(%rsi), %r10
25427 + movq 1*8(%rsi), %rcx
25428 movq 2*8(%rsi), %r9
25429 movq 3*8(%rsi), %r8
25430 leaq 4*8(%rsi), %rsi
25431
25432 movq %r11, 0*8(%rdi)
25433 - movq %r10, 1*8(%rdi)
25434 + movq %rcx, 1*8(%rdi)
25435 movq %r9, 2*8(%rdi)
25436 movq %r8, 3*8(%rdi)
25437 leaq 4*8(%rdi), %rdi
25438 @@ -81,10 +81,10 @@ ENTRY(memmove)
25439 4:
25440 movq %rdx, %rcx
25441 movq -8(%rsi, %rdx), %r11
25442 - lea -8(%rdi, %rdx), %r10
25443 + lea -8(%rdi, %rdx), %r9
25444 shrq $3, %rcx
25445 rep movsq
25446 - movq %r11, (%r10)
25447 + movq %r11, (%r9)
25448 jmp 13f
25449 .Lmemmove_end_forward:
25450
25451 @@ -95,14 +95,14 @@ ENTRY(memmove)
25452 7:
25453 movq %rdx, %rcx
25454 movq (%rsi), %r11
25455 - movq %rdi, %r10
25456 + movq %rdi, %r9
25457 leaq -8(%rsi, %rdx), %rsi
25458 leaq -8(%rdi, %rdx), %rdi
25459 shrq $3, %rcx
25460 std
25461 rep movsq
25462 cld
25463 - movq %r11, (%r10)
25464 + movq %r11, (%r9)
25465 jmp 13f
25466
25467 /*
25468 @@ -127,13 +127,13 @@ ENTRY(memmove)
25469 8:
25470 subq $0x20, %rdx
25471 movq -1*8(%rsi), %r11
25472 - movq -2*8(%rsi), %r10
25473 + movq -2*8(%rsi), %rcx
25474 movq -3*8(%rsi), %r9
25475 movq -4*8(%rsi), %r8
25476 leaq -4*8(%rsi), %rsi
25477
25478 movq %r11, -1*8(%rdi)
25479 - movq %r10, -2*8(%rdi)
25480 + movq %rcx, -2*8(%rdi)
25481 movq %r9, -3*8(%rdi)
25482 movq %r8, -4*8(%rdi)
25483 leaq -4*8(%rdi), %rdi
25484 @@ -151,11 +151,11 @@ ENTRY(memmove)
25485 * Move data from 16 bytes to 31 bytes.
25486 */
25487 movq 0*8(%rsi), %r11
25488 - movq 1*8(%rsi), %r10
25489 + movq 1*8(%rsi), %rcx
25490 movq -2*8(%rsi, %rdx), %r9
25491 movq -1*8(%rsi, %rdx), %r8
25492 movq %r11, 0*8(%rdi)
25493 - movq %r10, 1*8(%rdi)
25494 + movq %rcx, 1*8(%rdi)
25495 movq %r9, -2*8(%rdi, %rdx)
25496 movq %r8, -1*8(%rdi, %rdx)
25497 jmp 13f
25498 @@ -167,9 +167,9 @@ ENTRY(memmove)
25499 * Move data from 8 bytes to 15 bytes.
25500 */
25501 movq 0*8(%rsi), %r11
25502 - movq -1*8(%rsi, %rdx), %r10
25503 + movq -1*8(%rsi, %rdx), %r9
25504 movq %r11, 0*8(%rdi)
25505 - movq %r10, -1*8(%rdi, %rdx)
25506 + movq %r9, -1*8(%rdi, %rdx)
25507 jmp 13f
25508 10:
25509 cmpq $4, %rdx
25510 @@ -178,9 +178,9 @@ ENTRY(memmove)
25511 * Move data from 4 bytes to 7 bytes.
25512 */
25513 movl (%rsi), %r11d
25514 - movl -4(%rsi, %rdx), %r10d
25515 + movl -4(%rsi, %rdx), %r9d
25516 movl %r11d, (%rdi)
25517 - movl %r10d, -4(%rdi, %rdx)
25518 + movl %r9d, -4(%rdi, %rdx)
25519 jmp 13f
25520 11:
25521 cmp $2, %rdx
25522 @@ -189,9 +189,9 @@ ENTRY(memmove)
25523 * Move data from 2 bytes to 3 bytes.
25524 */
25525 movw (%rsi), %r11w
25526 - movw -2(%rsi, %rdx), %r10w
25527 + movw -2(%rsi, %rdx), %r9w
25528 movw %r11w, (%rdi)
25529 - movw %r10w, -2(%rdi, %rdx)
25530 + movw %r9w, -2(%rdi, %rdx)
25531 jmp 13f
25532 12:
25533 cmp $1, %rdx
25534 @@ -202,6 +202,7 @@ ENTRY(memmove)
25535 movb (%rsi), %r11b
25536 movb %r11b, (%rdi)
25537 13:
25538 + pax_force_retaddr
25539 retq
25540 CFI_ENDPROC
25541
25542 @@ -210,6 +211,7 @@ ENTRY(memmove)
25543 /* Forward moving data. */
25544 movq %rdx, %rcx
25545 rep movsb
25546 + pax_force_retaddr
25547 retq
25548 .Lmemmove_end_forward_efs:
25549 .previous
25550 diff --git a/arch/x86/lib/memset_64.S b/arch/x86/lib/memset_64.S
25551 index 2dcb380..963660a 100644
25552 --- a/arch/x86/lib/memset_64.S
25553 +++ b/arch/x86/lib/memset_64.S
25554 @@ -30,6 +30,7 @@
25555 movl %edx,%ecx
25556 rep stosb
25557 movq %r9,%rax
25558 + pax_force_retaddr
25559 ret
25560 .Lmemset_e:
25561 .previous
25562 @@ -52,6 +53,7 @@
25563 movq %rdx,%rcx
25564 rep stosb
25565 movq %r9,%rax
25566 + pax_force_retaddr
25567 ret
25568 .Lmemset_e_e:
25569 .previous
25570 @@ -59,7 +61,7 @@
25571 ENTRY(memset)
25572 ENTRY(__memset)
25573 CFI_STARTPROC
25574 - movq %rdi,%r10
25575 + movq %rdi,%r11
25576
25577 /* expand byte value */
25578 movzbl %sil,%ecx
25579 @@ -117,7 +119,8 @@ ENTRY(__memset)
25580 jnz .Lloop_1
25581
25582 .Lende:
25583 - movq %r10,%rax
25584 + movq %r11,%rax
25585 + pax_force_retaddr
25586 ret
25587
25588 CFI_RESTORE_STATE
25589 diff --git a/arch/x86/lib/mmx_32.c b/arch/x86/lib/mmx_32.c
25590 index c9f2d9b..e7fd2c0 100644
25591 --- a/arch/x86/lib/mmx_32.c
25592 +++ b/arch/x86/lib/mmx_32.c
25593 @@ -29,6 +29,7 @@ void *_mmx_memcpy(void *to, const void *from, size_t len)
25594 {
25595 void *p;
25596 int i;
25597 + unsigned long cr0;
25598
25599 if (unlikely(in_interrupt()))
25600 return __memcpy(to, from, len);
25601 @@ -39,44 +40,72 @@ void *_mmx_memcpy(void *to, const void *from, size_t len)
25602 kernel_fpu_begin();
25603
25604 __asm__ __volatile__ (
25605 - "1: prefetch (%0)\n" /* This set is 28 bytes */
25606 - " prefetch 64(%0)\n"
25607 - " prefetch 128(%0)\n"
25608 - " prefetch 192(%0)\n"
25609 - " prefetch 256(%0)\n"
25610 + "1: prefetch (%1)\n" /* This set is 28 bytes */
25611 + " prefetch 64(%1)\n"
25612 + " prefetch 128(%1)\n"
25613 + " prefetch 192(%1)\n"
25614 + " prefetch 256(%1)\n"
25615 "2: \n"
25616 ".section .fixup, \"ax\"\n"
25617 - "3: movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
25618 + "3: \n"
25619 +
25620 +#ifdef CONFIG_PAX_KERNEXEC
25621 + " movl %%cr0, %0\n"
25622 + " movl %0, %%eax\n"
25623 + " andl $0xFFFEFFFF, %%eax\n"
25624 + " movl %%eax, %%cr0\n"
25625 +#endif
25626 +
25627 + " movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
25628 +
25629 +#ifdef CONFIG_PAX_KERNEXEC
25630 + " movl %0, %%cr0\n"
25631 +#endif
25632 +
25633 " jmp 2b\n"
25634 ".previous\n"
25635 _ASM_EXTABLE(1b, 3b)
25636 - : : "r" (from));
25637 + : "=&r" (cr0) : "r" (from) : "ax");
25638
25639 for ( ; i > 5; i--) {
25640 __asm__ __volatile__ (
25641 - "1: prefetch 320(%0)\n"
25642 - "2: movq (%0), %%mm0\n"
25643 - " movq 8(%0), %%mm1\n"
25644 - " movq 16(%0), %%mm2\n"
25645 - " movq 24(%0), %%mm3\n"
25646 - " movq %%mm0, (%1)\n"
25647 - " movq %%mm1, 8(%1)\n"
25648 - " movq %%mm2, 16(%1)\n"
25649 - " movq %%mm3, 24(%1)\n"
25650 - " movq 32(%0), %%mm0\n"
25651 - " movq 40(%0), %%mm1\n"
25652 - " movq 48(%0), %%mm2\n"
25653 - " movq 56(%0), %%mm3\n"
25654 - " movq %%mm0, 32(%1)\n"
25655 - " movq %%mm1, 40(%1)\n"
25656 - " movq %%mm2, 48(%1)\n"
25657 - " movq %%mm3, 56(%1)\n"
25658 + "1: prefetch 320(%1)\n"
25659 + "2: movq (%1), %%mm0\n"
25660 + " movq 8(%1), %%mm1\n"
25661 + " movq 16(%1), %%mm2\n"
25662 + " movq 24(%1), %%mm3\n"
25663 + " movq %%mm0, (%2)\n"
25664 + " movq %%mm1, 8(%2)\n"
25665 + " movq %%mm2, 16(%2)\n"
25666 + " movq %%mm3, 24(%2)\n"
25667 + " movq 32(%1), %%mm0\n"
25668 + " movq 40(%1), %%mm1\n"
25669 + " movq 48(%1), %%mm2\n"
25670 + " movq 56(%1), %%mm3\n"
25671 + " movq %%mm0, 32(%2)\n"
25672 + " movq %%mm1, 40(%2)\n"
25673 + " movq %%mm2, 48(%2)\n"
25674 + " movq %%mm3, 56(%2)\n"
25675 ".section .fixup, \"ax\"\n"
25676 - "3: movw $0x05EB, 1b\n" /* jmp on 5 bytes */
25677 + "3:\n"
25678 +
25679 +#ifdef CONFIG_PAX_KERNEXEC
25680 + " movl %%cr0, %0\n"
25681 + " movl %0, %%eax\n"
25682 + " andl $0xFFFEFFFF, %%eax\n"
25683 + " movl %%eax, %%cr0\n"
25684 +#endif
25685 +
25686 + " movw $0x05EB, 1b\n" /* jmp on 5 bytes */
25687 +
25688 +#ifdef CONFIG_PAX_KERNEXEC
25689 + " movl %0, %%cr0\n"
25690 +#endif
25691 +
25692 " jmp 2b\n"
25693 ".previous\n"
25694 _ASM_EXTABLE(1b, 3b)
25695 - : : "r" (from), "r" (to) : "memory");
25696 + : "=&r" (cr0) : "r" (from), "r" (to) : "memory", "ax");
25697
25698 from += 64;
25699 to += 64;
25700 @@ -158,6 +187,7 @@ static void fast_clear_page(void *page)
25701 static void fast_copy_page(void *to, void *from)
25702 {
25703 int i;
25704 + unsigned long cr0;
25705
25706 kernel_fpu_begin();
25707
25708 @@ -166,42 +196,70 @@ static void fast_copy_page(void *to, void *from)
25709 * but that is for later. -AV
25710 */
25711 __asm__ __volatile__(
25712 - "1: prefetch (%0)\n"
25713 - " prefetch 64(%0)\n"
25714 - " prefetch 128(%0)\n"
25715 - " prefetch 192(%0)\n"
25716 - " prefetch 256(%0)\n"
25717 + "1: prefetch (%1)\n"
25718 + " prefetch 64(%1)\n"
25719 + " prefetch 128(%1)\n"
25720 + " prefetch 192(%1)\n"
25721 + " prefetch 256(%1)\n"
25722 "2: \n"
25723 ".section .fixup, \"ax\"\n"
25724 - "3: movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
25725 + "3: \n"
25726 +
25727 +#ifdef CONFIG_PAX_KERNEXEC
25728 + " movl %%cr0, %0\n"
25729 + " movl %0, %%eax\n"
25730 + " andl $0xFFFEFFFF, %%eax\n"
25731 + " movl %%eax, %%cr0\n"
25732 +#endif
25733 +
25734 + " movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
25735 +
25736 +#ifdef CONFIG_PAX_KERNEXEC
25737 + " movl %0, %%cr0\n"
25738 +#endif
25739 +
25740 " jmp 2b\n"
25741 ".previous\n"
25742 - _ASM_EXTABLE(1b, 3b) : : "r" (from));
25743 + _ASM_EXTABLE(1b, 3b) : "=&r" (cr0) : "r" (from) : "ax");
25744
25745 for (i = 0; i < (4096-320)/64; i++) {
25746 __asm__ __volatile__ (
25747 - "1: prefetch 320(%0)\n"
25748 - "2: movq (%0), %%mm0\n"
25749 - " movntq %%mm0, (%1)\n"
25750 - " movq 8(%0), %%mm1\n"
25751 - " movntq %%mm1, 8(%1)\n"
25752 - " movq 16(%0), %%mm2\n"
25753 - " movntq %%mm2, 16(%1)\n"
25754 - " movq 24(%0), %%mm3\n"
25755 - " movntq %%mm3, 24(%1)\n"
25756 - " movq 32(%0), %%mm4\n"
25757 - " movntq %%mm4, 32(%1)\n"
25758 - " movq 40(%0), %%mm5\n"
25759 - " movntq %%mm5, 40(%1)\n"
25760 - " movq 48(%0), %%mm6\n"
25761 - " movntq %%mm6, 48(%1)\n"
25762 - " movq 56(%0), %%mm7\n"
25763 - " movntq %%mm7, 56(%1)\n"
25764 + "1: prefetch 320(%1)\n"
25765 + "2: movq (%1), %%mm0\n"
25766 + " movntq %%mm0, (%2)\n"
25767 + " movq 8(%1), %%mm1\n"
25768 + " movntq %%mm1, 8(%2)\n"
25769 + " movq 16(%1), %%mm2\n"
25770 + " movntq %%mm2, 16(%2)\n"
25771 + " movq 24(%1), %%mm3\n"
25772 + " movntq %%mm3, 24(%2)\n"
25773 + " movq 32(%1), %%mm4\n"
25774 + " movntq %%mm4, 32(%2)\n"
25775 + " movq 40(%1), %%mm5\n"
25776 + " movntq %%mm5, 40(%2)\n"
25777 + " movq 48(%1), %%mm6\n"
25778 + " movntq %%mm6, 48(%2)\n"
25779 + " movq 56(%1), %%mm7\n"
25780 + " movntq %%mm7, 56(%2)\n"
25781 ".section .fixup, \"ax\"\n"
25782 - "3: movw $0x05EB, 1b\n" /* jmp on 5 bytes */
25783 + "3:\n"
25784 +
25785 +#ifdef CONFIG_PAX_KERNEXEC
25786 + " movl %%cr0, %0\n"
25787 + " movl %0, %%eax\n"
25788 + " andl $0xFFFEFFFF, %%eax\n"
25789 + " movl %%eax, %%cr0\n"
25790 +#endif
25791 +
25792 + " movw $0x05EB, 1b\n" /* jmp on 5 bytes */
25793 +
25794 +#ifdef CONFIG_PAX_KERNEXEC
25795 + " movl %0, %%cr0\n"
25796 +#endif
25797 +
25798 " jmp 2b\n"
25799 ".previous\n"
25800 - _ASM_EXTABLE(1b, 3b) : : "r" (from), "r" (to) : "memory");
25801 + _ASM_EXTABLE(1b, 3b) : "=&r" (cr0) : "r" (from), "r" (to) : "memory", "ax");
25802
25803 from += 64;
25804 to += 64;
25805 @@ -280,47 +338,76 @@ static void fast_clear_page(void *page)
25806 static void fast_copy_page(void *to, void *from)
25807 {
25808 int i;
25809 + unsigned long cr0;
25810
25811 kernel_fpu_begin();
25812
25813 __asm__ __volatile__ (
25814 - "1: prefetch (%0)\n"
25815 - " prefetch 64(%0)\n"
25816 - " prefetch 128(%0)\n"
25817 - " prefetch 192(%0)\n"
25818 - " prefetch 256(%0)\n"
25819 + "1: prefetch (%1)\n"
25820 + " prefetch 64(%1)\n"
25821 + " prefetch 128(%1)\n"
25822 + " prefetch 192(%1)\n"
25823 + " prefetch 256(%1)\n"
25824 "2: \n"
25825 ".section .fixup, \"ax\"\n"
25826 - "3: movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
25827 + "3: \n"
25828 +
25829 +#ifdef CONFIG_PAX_KERNEXEC
25830 + " movl %%cr0, %0\n"
25831 + " movl %0, %%eax\n"
25832 + " andl $0xFFFEFFFF, %%eax\n"
25833 + " movl %%eax, %%cr0\n"
25834 +#endif
25835 +
25836 + " movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
25837 +
25838 +#ifdef CONFIG_PAX_KERNEXEC
25839 + " movl %0, %%cr0\n"
25840 +#endif
25841 +
25842 " jmp 2b\n"
25843 ".previous\n"
25844 - _ASM_EXTABLE(1b, 3b) : : "r" (from));
25845 + _ASM_EXTABLE(1b, 3b) : "=&r" (cr0) : "r" (from) : "ax");
25846
25847 for (i = 0; i < 4096/64; i++) {
25848 __asm__ __volatile__ (
25849 - "1: prefetch 320(%0)\n"
25850 - "2: movq (%0), %%mm0\n"
25851 - " movq 8(%0), %%mm1\n"
25852 - " movq 16(%0), %%mm2\n"
25853 - " movq 24(%0), %%mm3\n"
25854 - " movq %%mm0, (%1)\n"
25855 - " movq %%mm1, 8(%1)\n"
25856 - " movq %%mm2, 16(%1)\n"
25857 - " movq %%mm3, 24(%1)\n"
25858 - " movq 32(%0), %%mm0\n"
25859 - " movq 40(%0), %%mm1\n"
25860 - " movq 48(%0), %%mm2\n"
25861 - " movq 56(%0), %%mm3\n"
25862 - " movq %%mm0, 32(%1)\n"
25863 - " movq %%mm1, 40(%1)\n"
25864 - " movq %%mm2, 48(%1)\n"
25865 - " movq %%mm3, 56(%1)\n"
25866 + "1: prefetch 320(%1)\n"
25867 + "2: movq (%1), %%mm0\n"
25868 + " movq 8(%1), %%mm1\n"
25869 + " movq 16(%1), %%mm2\n"
25870 + " movq 24(%1), %%mm3\n"
25871 + " movq %%mm0, (%2)\n"
25872 + " movq %%mm1, 8(%2)\n"
25873 + " movq %%mm2, 16(%2)\n"
25874 + " movq %%mm3, 24(%2)\n"
25875 + " movq 32(%1), %%mm0\n"
25876 + " movq 40(%1), %%mm1\n"
25877 + " movq 48(%1), %%mm2\n"
25878 + " movq 56(%1), %%mm3\n"
25879 + " movq %%mm0, 32(%2)\n"
25880 + " movq %%mm1, 40(%2)\n"
25881 + " movq %%mm2, 48(%2)\n"
25882 + " movq %%mm3, 56(%2)\n"
25883 ".section .fixup, \"ax\"\n"
25884 - "3: movw $0x05EB, 1b\n" /* jmp on 5 bytes */
25885 + "3:\n"
25886 +
25887 +#ifdef CONFIG_PAX_KERNEXEC
25888 + " movl %%cr0, %0\n"
25889 + " movl %0, %%eax\n"
25890 + " andl $0xFFFEFFFF, %%eax\n"
25891 + " movl %%eax, %%cr0\n"
25892 +#endif
25893 +
25894 + " movw $0x05EB, 1b\n" /* jmp on 5 bytes */
25895 +
25896 +#ifdef CONFIG_PAX_KERNEXEC
25897 + " movl %0, %%cr0\n"
25898 +#endif
25899 +
25900 " jmp 2b\n"
25901 ".previous\n"
25902 _ASM_EXTABLE(1b, 3b)
25903 - : : "r" (from), "r" (to) : "memory");
25904 + : "=&r" (cr0) : "r" (from), "r" (to) : "memory", "ax");
25905
25906 from += 64;
25907 to += 64;
25908 diff --git a/arch/x86/lib/msr-reg.S b/arch/x86/lib/msr-reg.S
25909 index f6d13ee..aca5f0b 100644
25910 --- a/arch/x86/lib/msr-reg.S
25911 +++ b/arch/x86/lib/msr-reg.S
25912 @@ -3,6 +3,7 @@
25913 #include <asm/dwarf2.h>
25914 #include <asm/asm.h>
25915 #include <asm/msr.h>
25916 +#include <asm/alternative-asm.h>
25917
25918 #ifdef CONFIG_X86_64
25919 /*
25920 @@ -16,7 +17,7 @@ ENTRY(\op\()_safe_regs)
25921 CFI_STARTPROC
25922 pushq_cfi %rbx
25923 pushq_cfi %rbp
25924 - movq %rdi, %r10 /* Save pointer */
25925 + movq %rdi, %r9 /* Save pointer */
25926 xorl %r11d, %r11d /* Return value */
25927 movl (%rdi), %eax
25928 movl 4(%rdi), %ecx
25929 @@ -27,16 +28,17 @@ ENTRY(\op\()_safe_regs)
25930 movl 28(%rdi), %edi
25931 CFI_REMEMBER_STATE
25932 1: \op
25933 -2: movl %eax, (%r10)
25934 +2: movl %eax, (%r9)
25935 movl %r11d, %eax /* Return value */
25936 - movl %ecx, 4(%r10)
25937 - movl %edx, 8(%r10)
25938 - movl %ebx, 12(%r10)
25939 - movl %ebp, 20(%r10)
25940 - movl %esi, 24(%r10)
25941 - movl %edi, 28(%r10)
25942 + movl %ecx, 4(%r9)
25943 + movl %edx, 8(%r9)
25944 + movl %ebx, 12(%r9)
25945 + movl %ebp, 20(%r9)
25946 + movl %esi, 24(%r9)
25947 + movl %edi, 28(%r9)
25948 popq_cfi %rbp
25949 popq_cfi %rbx
25950 + pax_force_retaddr
25951 ret
25952 3:
25953 CFI_RESTORE_STATE
25954 diff --git a/arch/x86/lib/putuser.S b/arch/x86/lib/putuser.S
25955 index fc6ba17..04471c5 100644
25956 --- a/arch/x86/lib/putuser.S
25957 +++ b/arch/x86/lib/putuser.S
25958 @@ -16,7 +16,9 @@
25959 #include <asm/errno.h>
25960 #include <asm/asm.h>
25961 #include <asm/smap.h>
25962 -
25963 +#include <asm/segment.h>
25964 +#include <asm/pgtable.h>
25965 +#include <asm/alternative-asm.h>
25966
25967 /*
25968 * __put_user_X
25969 @@ -30,57 +32,125 @@
25970 * as they get called from within inline assembly.
25971 */
25972
25973 -#define ENTER CFI_STARTPROC ; \
25974 - GET_THREAD_INFO(%_ASM_BX)
25975 -#define EXIT ASM_CLAC ; \
25976 - ret ; \
25977 +#define ENTER CFI_STARTPROC
25978 +#define EXIT ASM_CLAC ; \
25979 + pax_force_retaddr ; \
25980 + ret ; \
25981 CFI_ENDPROC
25982
25983 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
25984 +#define _DEST %_ASM_CX,%_ASM_BX
25985 +#else
25986 +#define _DEST %_ASM_CX
25987 +#endif
25988 +
25989 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
25990 +#define __copyuser_seg gs;
25991 +#else
25992 +#define __copyuser_seg
25993 +#endif
25994 +
25995 .text
25996 ENTRY(__put_user_1)
25997 ENTER
25998 +
25999 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
26000 + GET_THREAD_INFO(%_ASM_BX)
26001 cmp TI_addr_limit(%_ASM_BX),%_ASM_CX
26002 jae bad_put_user
26003 ASM_STAC
26004 -1: movb %al,(%_ASM_CX)
26005 +
26006 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
26007 + mov $PAX_USER_SHADOW_BASE,%_ASM_BX
26008 + cmp %_ASM_BX,%_ASM_CX
26009 + jb 1234f
26010 + xor %ebx,%ebx
26011 +1234:
26012 +#endif
26013 +
26014 +#endif
26015 +
26016 +1: __copyuser_seg movb %al,(_DEST)
26017 xor %eax,%eax
26018 EXIT
26019 ENDPROC(__put_user_1)
26020
26021 ENTRY(__put_user_2)
26022 ENTER
26023 +
26024 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
26025 + GET_THREAD_INFO(%_ASM_BX)
26026 mov TI_addr_limit(%_ASM_BX),%_ASM_BX
26027 sub $1,%_ASM_BX
26028 cmp %_ASM_BX,%_ASM_CX
26029 jae bad_put_user
26030 ASM_STAC
26031 -2: movw %ax,(%_ASM_CX)
26032 +
26033 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
26034 + mov $PAX_USER_SHADOW_BASE,%_ASM_BX
26035 + cmp %_ASM_BX,%_ASM_CX
26036 + jb 1234f
26037 + xor %ebx,%ebx
26038 +1234:
26039 +#endif
26040 +
26041 +#endif
26042 +
26043 +2: __copyuser_seg movw %ax,(_DEST)
26044 xor %eax,%eax
26045 EXIT
26046 ENDPROC(__put_user_2)
26047
26048 ENTRY(__put_user_4)
26049 ENTER
26050 +
26051 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
26052 + GET_THREAD_INFO(%_ASM_BX)
26053 mov TI_addr_limit(%_ASM_BX),%_ASM_BX
26054 sub $3,%_ASM_BX
26055 cmp %_ASM_BX,%_ASM_CX
26056 jae bad_put_user
26057 ASM_STAC
26058 -3: movl %eax,(%_ASM_CX)
26059 +
26060 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
26061 + mov $PAX_USER_SHADOW_BASE,%_ASM_BX
26062 + cmp %_ASM_BX,%_ASM_CX
26063 + jb 1234f
26064 + xor %ebx,%ebx
26065 +1234:
26066 +#endif
26067 +
26068 +#endif
26069 +
26070 +3: __copyuser_seg movl %eax,(_DEST)
26071 xor %eax,%eax
26072 EXIT
26073 ENDPROC(__put_user_4)
26074
26075 ENTRY(__put_user_8)
26076 ENTER
26077 +
26078 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
26079 + GET_THREAD_INFO(%_ASM_BX)
26080 mov TI_addr_limit(%_ASM_BX),%_ASM_BX
26081 sub $7,%_ASM_BX
26082 cmp %_ASM_BX,%_ASM_CX
26083 jae bad_put_user
26084 ASM_STAC
26085 -4: mov %_ASM_AX,(%_ASM_CX)
26086 +
26087 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
26088 + mov $PAX_USER_SHADOW_BASE,%_ASM_BX
26089 + cmp %_ASM_BX,%_ASM_CX
26090 + jb 1234f
26091 + xor %ebx,%ebx
26092 +1234:
26093 +#endif
26094 +
26095 +#endif
26096 +
26097 +4: __copyuser_seg mov %_ASM_AX,(_DEST)
26098 #ifdef CONFIG_X86_32
26099 -5: movl %edx,4(%_ASM_CX)
26100 +5: __copyuser_seg movl %edx,4(_DEST)
26101 #endif
26102 xor %eax,%eax
26103 EXIT
26104 diff --git a/arch/x86/lib/rwlock.S b/arch/x86/lib/rwlock.S
26105 index 1cad221..de671ee 100644
26106 --- a/arch/x86/lib/rwlock.S
26107 +++ b/arch/x86/lib/rwlock.S
26108 @@ -16,13 +16,34 @@ ENTRY(__write_lock_failed)
26109 FRAME
26110 0: LOCK_PREFIX
26111 WRITE_LOCK_ADD($RW_LOCK_BIAS) (%__lock_ptr)
26112 +
26113 +#ifdef CONFIG_PAX_REFCOUNT
26114 + jno 1234f
26115 + LOCK_PREFIX
26116 + WRITE_LOCK_SUB($RW_LOCK_BIAS) (%__lock_ptr)
26117 + int $4
26118 +1234:
26119 + _ASM_EXTABLE(1234b, 1234b)
26120 +#endif
26121 +
26122 1: rep; nop
26123 cmpl $WRITE_LOCK_CMP, (%__lock_ptr)
26124 jne 1b
26125 LOCK_PREFIX
26126 WRITE_LOCK_SUB($RW_LOCK_BIAS) (%__lock_ptr)
26127 +
26128 +#ifdef CONFIG_PAX_REFCOUNT
26129 + jno 1234f
26130 + LOCK_PREFIX
26131 + WRITE_LOCK_ADD($RW_LOCK_BIAS) (%__lock_ptr)
26132 + int $4
26133 +1234:
26134 + _ASM_EXTABLE(1234b, 1234b)
26135 +#endif
26136 +
26137 jnz 0b
26138 ENDFRAME
26139 + pax_force_retaddr
26140 ret
26141 CFI_ENDPROC
26142 END(__write_lock_failed)
26143 @@ -32,13 +53,34 @@ ENTRY(__read_lock_failed)
26144 FRAME
26145 0: LOCK_PREFIX
26146 READ_LOCK_SIZE(inc) (%__lock_ptr)
26147 +
26148 +#ifdef CONFIG_PAX_REFCOUNT
26149 + jno 1234f
26150 + LOCK_PREFIX
26151 + READ_LOCK_SIZE(dec) (%__lock_ptr)
26152 + int $4
26153 +1234:
26154 + _ASM_EXTABLE(1234b, 1234b)
26155 +#endif
26156 +
26157 1: rep; nop
26158 READ_LOCK_SIZE(cmp) $1, (%__lock_ptr)
26159 js 1b
26160 LOCK_PREFIX
26161 READ_LOCK_SIZE(dec) (%__lock_ptr)
26162 +
26163 +#ifdef CONFIG_PAX_REFCOUNT
26164 + jno 1234f
26165 + LOCK_PREFIX
26166 + READ_LOCK_SIZE(inc) (%__lock_ptr)
26167 + int $4
26168 +1234:
26169 + _ASM_EXTABLE(1234b, 1234b)
26170 +#endif
26171 +
26172 js 0b
26173 ENDFRAME
26174 + pax_force_retaddr
26175 ret
26176 CFI_ENDPROC
26177 END(__read_lock_failed)
26178 diff --git a/arch/x86/lib/rwsem.S b/arch/x86/lib/rwsem.S
26179 index 5dff5f0..cadebf4 100644
26180 --- a/arch/x86/lib/rwsem.S
26181 +++ b/arch/x86/lib/rwsem.S
26182 @@ -94,6 +94,7 @@ ENTRY(call_rwsem_down_read_failed)
26183 __ASM_SIZE(pop,_cfi) %__ASM_REG(dx)
26184 CFI_RESTORE __ASM_REG(dx)
26185 restore_common_regs
26186 + pax_force_retaddr
26187 ret
26188 CFI_ENDPROC
26189 ENDPROC(call_rwsem_down_read_failed)
26190 @@ -104,6 +105,7 @@ ENTRY(call_rwsem_down_write_failed)
26191 movq %rax,%rdi
26192 call rwsem_down_write_failed
26193 restore_common_regs
26194 + pax_force_retaddr
26195 ret
26196 CFI_ENDPROC
26197 ENDPROC(call_rwsem_down_write_failed)
26198 @@ -117,7 +119,8 @@ ENTRY(call_rwsem_wake)
26199 movq %rax,%rdi
26200 call rwsem_wake
26201 restore_common_regs
26202 -1: ret
26203 +1: pax_force_retaddr
26204 + ret
26205 CFI_ENDPROC
26206 ENDPROC(call_rwsem_wake)
26207
26208 @@ -131,6 +134,7 @@ ENTRY(call_rwsem_downgrade_wake)
26209 __ASM_SIZE(pop,_cfi) %__ASM_REG(dx)
26210 CFI_RESTORE __ASM_REG(dx)
26211 restore_common_regs
26212 + pax_force_retaddr
26213 ret
26214 CFI_ENDPROC
26215 ENDPROC(call_rwsem_downgrade_wake)
26216 diff --git a/arch/x86/lib/thunk_64.S b/arch/x86/lib/thunk_64.S
26217 index a63efd6..ccecad8 100644
26218 --- a/arch/x86/lib/thunk_64.S
26219 +++ b/arch/x86/lib/thunk_64.S
26220 @@ -8,6 +8,7 @@
26221 #include <linux/linkage.h>
26222 #include <asm/dwarf2.h>
26223 #include <asm/calling.h>
26224 +#include <asm/alternative-asm.h>
26225
26226 /* rdi: arg1 ... normal C conventions. rax is saved/restored. */
26227 .macro THUNK name, func, put_ret_addr_in_rdi=0
26228 @@ -41,5 +42,6 @@
26229 SAVE_ARGS
26230 restore:
26231 RESTORE_ARGS
26232 + pax_force_retaddr
26233 ret
26234 CFI_ENDPROC
26235 diff --git a/arch/x86/lib/usercopy_32.c b/arch/x86/lib/usercopy_32.c
26236 index f0312d7..9c39d63 100644
26237 --- a/arch/x86/lib/usercopy_32.c
26238 +++ b/arch/x86/lib/usercopy_32.c
26239 @@ -42,11 +42,13 @@ do { \
26240 int __d0; \
26241 might_fault(); \
26242 __asm__ __volatile__( \
26243 + __COPYUSER_SET_ES \
26244 ASM_STAC "\n" \
26245 "0: rep; stosl\n" \
26246 " movl %2,%0\n" \
26247 "1: rep; stosb\n" \
26248 "2: " ASM_CLAC "\n" \
26249 + __COPYUSER_RESTORE_ES \
26250 ".section .fixup,\"ax\"\n" \
26251 "3: lea 0(%2,%0,4),%0\n" \
26252 " jmp 2b\n" \
26253 @@ -98,7 +100,7 @@ EXPORT_SYMBOL(__clear_user);
26254
26255 #ifdef CONFIG_X86_INTEL_USERCOPY
26256 static unsigned long
26257 -__copy_user_intel(void __user *to, const void *from, unsigned long size)
26258 +__generic_copy_to_user_intel(void __user *to, const void *from, unsigned long size)
26259 {
26260 int d0, d1;
26261 __asm__ __volatile__(
26262 @@ -110,36 +112,36 @@ __copy_user_intel(void __user *to, const void *from, unsigned long size)
26263 " .align 2,0x90\n"
26264 "3: movl 0(%4), %%eax\n"
26265 "4: movl 4(%4), %%edx\n"
26266 - "5: movl %%eax, 0(%3)\n"
26267 - "6: movl %%edx, 4(%3)\n"
26268 + "5: "__copyuser_seg" movl %%eax, 0(%3)\n"
26269 + "6: "__copyuser_seg" movl %%edx, 4(%3)\n"
26270 "7: movl 8(%4), %%eax\n"
26271 "8: movl 12(%4),%%edx\n"
26272 - "9: movl %%eax, 8(%3)\n"
26273 - "10: movl %%edx, 12(%3)\n"
26274 + "9: "__copyuser_seg" movl %%eax, 8(%3)\n"
26275 + "10: "__copyuser_seg" movl %%edx, 12(%3)\n"
26276 "11: movl 16(%4), %%eax\n"
26277 "12: movl 20(%4), %%edx\n"
26278 - "13: movl %%eax, 16(%3)\n"
26279 - "14: movl %%edx, 20(%3)\n"
26280 + "13: "__copyuser_seg" movl %%eax, 16(%3)\n"
26281 + "14: "__copyuser_seg" movl %%edx, 20(%3)\n"
26282 "15: movl 24(%4), %%eax\n"
26283 "16: movl 28(%4), %%edx\n"
26284 - "17: movl %%eax, 24(%3)\n"
26285 - "18: movl %%edx, 28(%3)\n"
26286 + "17: "__copyuser_seg" movl %%eax, 24(%3)\n"
26287 + "18: "__copyuser_seg" movl %%edx, 28(%3)\n"
26288 "19: movl 32(%4), %%eax\n"
26289 "20: movl 36(%4), %%edx\n"
26290 - "21: movl %%eax, 32(%3)\n"
26291 - "22: movl %%edx, 36(%3)\n"
26292 + "21: "__copyuser_seg" movl %%eax, 32(%3)\n"
26293 + "22: "__copyuser_seg" movl %%edx, 36(%3)\n"
26294 "23: movl 40(%4), %%eax\n"
26295 "24: movl 44(%4), %%edx\n"
26296 - "25: movl %%eax, 40(%3)\n"
26297 - "26: movl %%edx, 44(%3)\n"
26298 + "25: "__copyuser_seg" movl %%eax, 40(%3)\n"
26299 + "26: "__copyuser_seg" movl %%edx, 44(%3)\n"
26300 "27: movl 48(%4), %%eax\n"
26301 "28: movl 52(%4), %%edx\n"
26302 - "29: movl %%eax, 48(%3)\n"
26303 - "30: movl %%edx, 52(%3)\n"
26304 + "29: "__copyuser_seg" movl %%eax, 48(%3)\n"
26305 + "30: "__copyuser_seg" movl %%edx, 52(%3)\n"
26306 "31: movl 56(%4), %%eax\n"
26307 "32: movl 60(%4), %%edx\n"
26308 - "33: movl %%eax, 56(%3)\n"
26309 - "34: movl %%edx, 60(%3)\n"
26310 + "33: "__copyuser_seg" movl %%eax, 56(%3)\n"
26311 + "34: "__copyuser_seg" movl %%edx, 60(%3)\n"
26312 " addl $-64, %0\n"
26313 " addl $64, %4\n"
26314 " addl $64, %3\n"
26315 @@ -149,10 +151,12 @@ __copy_user_intel(void __user *to, const void *from, unsigned long size)
26316 " shrl $2, %0\n"
26317 " andl $3, %%eax\n"
26318 " cld\n"
26319 + __COPYUSER_SET_ES
26320 "99: rep; movsl\n"
26321 "36: movl %%eax, %0\n"
26322 "37: rep; movsb\n"
26323 "100:\n"
26324 + __COPYUSER_RESTORE_ES
26325 ".section .fixup,\"ax\"\n"
26326 "101: lea 0(%%eax,%0,4),%0\n"
26327 " jmp 100b\n"
26328 @@ -202,46 +206,150 @@ __copy_user_intel(void __user *to, const void *from, unsigned long size)
26329 }
26330
26331 static unsigned long
26332 +__generic_copy_from_user_intel(void *to, const void __user *from, unsigned long size)
26333 +{
26334 + int d0, d1;
26335 + __asm__ __volatile__(
26336 + " .align 2,0x90\n"
26337 + "1: "__copyuser_seg" movl 32(%4), %%eax\n"
26338 + " cmpl $67, %0\n"
26339 + " jbe 3f\n"
26340 + "2: "__copyuser_seg" movl 64(%4), %%eax\n"
26341 + " .align 2,0x90\n"
26342 + "3: "__copyuser_seg" movl 0(%4), %%eax\n"
26343 + "4: "__copyuser_seg" movl 4(%4), %%edx\n"
26344 + "5: movl %%eax, 0(%3)\n"
26345 + "6: movl %%edx, 4(%3)\n"
26346 + "7: "__copyuser_seg" movl 8(%4), %%eax\n"
26347 + "8: "__copyuser_seg" movl 12(%4),%%edx\n"
26348 + "9: movl %%eax, 8(%3)\n"
26349 + "10: movl %%edx, 12(%3)\n"
26350 + "11: "__copyuser_seg" movl 16(%4), %%eax\n"
26351 + "12: "__copyuser_seg" movl 20(%4), %%edx\n"
26352 + "13: movl %%eax, 16(%3)\n"
26353 + "14: movl %%edx, 20(%3)\n"
26354 + "15: "__copyuser_seg" movl 24(%4), %%eax\n"
26355 + "16: "__copyuser_seg" movl 28(%4), %%edx\n"
26356 + "17: movl %%eax, 24(%3)\n"
26357 + "18: movl %%edx, 28(%3)\n"
26358 + "19: "__copyuser_seg" movl 32(%4), %%eax\n"
26359 + "20: "__copyuser_seg" movl 36(%4), %%edx\n"
26360 + "21: movl %%eax, 32(%3)\n"
26361 + "22: movl %%edx, 36(%3)\n"
26362 + "23: "__copyuser_seg" movl 40(%4), %%eax\n"
26363 + "24: "__copyuser_seg" movl 44(%4), %%edx\n"
26364 + "25: movl %%eax, 40(%3)\n"
26365 + "26: movl %%edx, 44(%3)\n"
26366 + "27: "__copyuser_seg" movl 48(%4), %%eax\n"
26367 + "28: "__copyuser_seg" movl 52(%4), %%edx\n"
26368 + "29: movl %%eax, 48(%3)\n"
26369 + "30: movl %%edx, 52(%3)\n"
26370 + "31: "__copyuser_seg" movl 56(%4), %%eax\n"
26371 + "32: "__copyuser_seg" movl 60(%4), %%edx\n"
26372 + "33: movl %%eax, 56(%3)\n"
26373 + "34: movl %%edx, 60(%3)\n"
26374 + " addl $-64, %0\n"
26375 + " addl $64, %4\n"
26376 + " addl $64, %3\n"
26377 + " cmpl $63, %0\n"
26378 + " ja 1b\n"
26379 + "35: movl %0, %%eax\n"
26380 + " shrl $2, %0\n"
26381 + " andl $3, %%eax\n"
26382 + " cld\n"
26383 + "99: rep; "__copyuser_seg" movsl\n"
26384 + "36: movl %%eax, %0\n"
26385 + "37: rep; "__copyuser_seg" movsb\n"
26386 + "100:\n"
26387 + ".section .fixup,\"ax\"\n"
26388 + "101: lea 0(%%eax,%0,4),%0\n"
26389 + " jmp 100b\n"
26390 + ".previous\n"
26391 + _ASM_EXTABLE(1b,100b)
26392 + _ASM_EXTABLE(2b,100b)
26393 + _ASM_EXTABLE(3b,100b)
26394 + _ASM_EXTABLE(4b,100b)
26395 + _ASM_EXTABLE(5b,100b)
26396 + _ASM_EXTABLE(6b,100b)
26397 + _ASM_EXTABLE(7b,100b)
26398 + _ASM_EXTABLE(8b,100b)
26399 + _ASM_EXTABLE(9b,100b)
26400 + _ASM_EXTABLE(10b,100b)
26401 + _ASM_EXTABLE(11b,100b)
26402 + _ASM_EXTABLE(12b,100b)
26403 + _ASM_EXTABLE(13b,100b)
26404 + _ASM_EXTABLE(14b,100b)
26405 + _ASM_EXTABLE(15b,100b)
26406 + _ASM_EXTABLE(16b,100b)
26407 + _ASM_EXTABLE(17b,100b)
26408 + _ASM_EXTABLE(18b,100b)
26409 + _ASM_EXTABLE(19b,100b)
26410 + _ASM_EXTABLE(20b,100b)
26411 + _ASM_EXTABLE(21b,100b)
26412 + _ASM_EXTABLE(22b,100b)
26413 + _ASM_EXTABLE(23b,100b)
26414 + _ASM_EXTABLE(24b,100b)
26415 + _ASM_EXTABLE(25b,100b)
26416 + _ASM_EXTABLE(26b,100b)
26417 + _ASM_EXTABLE(27b,100b)
26418 + _ASM_EXTABLE(28b,100b)
26419 + _ASM_EXTABLE(29b,100b)
26420 + _ASM_EXTABLE(30b,100b)
26421 + _ASM_EXTABLE(31b,100b)
26422 + _ASM_EXTABLE(32b,100b)
26423 + _ASM_EXTABLE(33b,100b)
26424 + _ASM_EXTABLE(34b,100b)
26425 + _ASM_EXTABLE(35b,100b)
26426 + _ASM_EXTABLE(36b,100b)
26427 + _ASM_EXTABLE(37b,100b)
26428 + _ASM_EXTABLE(99b,101b)
26429 + : "=&c"(size), "=&D" (d0), "=&S" (d1)
26430 + : "1"(to), "2"(from), "0"(size)
26431 + : "eax", "edx", "memory");
26432 + return size;
26433 +}
26434 +
26435 +static unsigned long __size_overflow(3)
26436 __copy_user_zeroing_intel(void *to, const void __user *from, unsigned long size)
26437 {
26438 int d0, d1;
26439 __asm__ __volatile__(
26440 " .align 2,0x90\n"
26441 - "0: movl 32(%4), %%eax\n"
26442 + "0: "__copyuser_seg" movl 32(%4), %%eax\n"
26443 " cmpl $67, %0\n"
26444 " jbe 2f\n"
26445 - "1: movl 64(%4), %%eax\n"
26446 + "1: "__copyuser_seg" movl 64(%4), %%eax\n"
26447 " .align 2,0x90\n"
26448 - "2: movl 0(%4), %%eax\n"
26449 - "21: movl 4(%4), %%edx\n"
26450 + "2: "__copyuser_seg" movl 0(%4), %%eax\n"
26451 + "21: "__copyuser_seg" movl 4(%4), %%edx\n"
26452 " movl %%eax, 0(%3)\n"
26453 " movl %%edx, 4(%3)\n"
26454 - "3: movl 8(%4), %%eax\n"
26455 - "31: movl 12(%4),%%edx\n"
26456 + "3: "__copyuser_seg" movl 8(%4), %%eax\n"
26457 + "31: "__copyuser_seg" movl 12(%4),%%edx\n"
26458 " movl %%eax, 8(%3)\n"
26459 " movl %%edx, 12(%3)\n"
26460 - "4: movl 16(%4), %%eax\n"
26461 - "41: movl 20(%4), %%edx\n"
26462 + "4: "__copyuser_seg" movl 16(%4), %%eax\n"
26463 + "41: "__copyuser_seg" movl 20(%4), %%edx\n"
26464 " movl %%eax, 16(%3)\n"
26465 " movl %%edx, 20(%3)\n"
26466 - "10: movl 24(%4), %%eax\n"
26467 - "51: movl 28(%4), %%edx\n"
26468 + "10: "__copyuser_seg" movl 24(%4), %%eax\n"
26469 + "51: "__copyuser_seg" movl 28(%4), %%edx\n"
26470 " movl %%eax, 24(%3)\n"
26471 " movl %%edx, 28(%3)\n"
26472 - "11: movl 32(%4), %%eax\n"
26473 - "61: movl 36(%4), %%edx\n"
26474 + "11: "__copyuser_seg" movl 32(%4), %%eax\n"
26475 + "61: "__copyuser_seg" movl 36(%4), %%edx\n"
26476 " movl %%eax, 32(%3)\n"
26477 " movl %%edx, 36(%3)\n"
26478 - "12: movl 40(%4), %%eax\n"
26479 - "71: movl 44(%4), %%edx\n"
26480 + "12: "__copyuser_seg" movl 40(%4), %%eax\n"
26481 + "71: "__copyuser_seg" movl 44(%4), %%edx\n"
26482 " movl %%eax, 40(%3)\n"
26483 " movl %%edx, 44(%3)\n"
26484 - "13: movl 48(%4), %%eax\n"
26485 - "81: movl 52(%4), %%edx\n"
26486 + "13: "__copyuser_seg" movl 48(%4), %%eax\n"
26487 + "81: "__copyuser_seg" movl 52(%4), %%edx\n"
26488 " movl %%eax, 48(%3)\n"
26489 " movl %%edx, 52(%3)\n"
26490 - "14: movl 56(%4), %%eax\n"
26491 - "91: movl 60(%4), %%edx\n"
26492 + "14: "__copyuser_seg" movl 56(%4), %%eax\n"
26493 + "91: "__copyuser_seg" movl 60(%4), %%edx\n"
26494 " movl %%eax, 56(%3)\n"
26495 " movl %%edx, 60(%3)\n"
26496 " addl $-64, %0\n"
26497 @@ -253,9 +361,9 @@ __copy_user_zeroing_intel(void *to, const void __user *from, unsigned long size)
26498 " shrl $2, %0\n"
26499 " andl $3, %%eax\n"
26500 " cld\n"
26501 - "6: rep; movsl\n"
26502 + "6: rep; "__copyuser_seg" movsl\n"
26503 " movl %%eax,%0\n"
26504 - "7: rep; movsb\n"
26505 + "7: rep; "__copyuser_seg" movsb\n"
26506 "8:\n"
26507 ".section .fixup,\"ax\"\n"
26508 "9: lea 0(%%eax,%0,4),%0\n"
26509 @@ -298,48 +406,48 @@ __copy_user_zeroing_intel(void *to, const void __user *from, unsigned long size)
26510 * hyoshiok@miraclelinux.com
26511 */
26512
26513 -static unsigned long __copy_user_zeroing_intel_nocache(void *to,
26514 +static unsigned long __size_overflow(3) __copy_user_zeroing_intel_nocache(void *to,
26515 const void __user *from, unsigned long size)
26516 {
26517 int d0, d1;
26518
26519 __asm__ __volatile__(
26520 " .align 2,0x90\n"
26521 - "0: movl 32(%4), %%eax\n"
26522 + "0: "__copyuser_seg" movl 32(%4), %%eax\n"
26523 " cmpl $67, %0\n"
26524 " jbe 2f\n"
26525 - "1: movl 64(%4), %%eax\n"
26526 + "1: "__copyuser_seg" movl 64(%4), %%eax\n"
26527 " .align 2,0x90\n"
26528 - "2: movl 0(%4), %%eax\n"
26529 - "21: movl 4(%4), %%edx\n"
26530 + "2: "__copyuser_seg" movl 0(%4), %%eax\n"
26531 + "21: "__copyuser_seg" movl 4(%4), %%edx\n"
26532 " movnti %%eax, 0(%3)\n"
26533 " movnti %%edx, 4(%3)\n"
26534 - "3: movl 8(%4), %%eax\n"
26535 - "31: movl 12(%4),%%edx\n"
26536 + "3: "__copyuser_seg" movl 8(%4), %%eax\n"
26537 + "31: "__copyuser_seg" movl 12(%4),%%edx\n"
26538 " movnti %%eax, 8(%3)\n"
26539 " movnti %%edx, 12(%3)\n"
26540 - "4: movl 16(%4), %%eax\n"
26541 - "41: movl 20(%4), %%edx\n"
26542 + "4: "__copyuser_seg" movl 16(%4), %%eax\n"
26543 + "41: "__copyuser_seg" movl 20(%4), %%edx\n"
26544 " movnti %%eax, 16(%3)\n"
26545 " movnti %%edx, 20(%3)\n"
26546 - "10: movl 24(%4), %%eax\n"
26547 - "51: movl 28(%4), %%edx\n"
26548 + "10: "__copyuser_seg" movl 24(%4), %%eax\n"
26549 + "51: "__copyuser_seg" movl 28(%4), %%edx\n"
26550 " movnti %%eax, 24(%3)\n"
26551 " movnti %%edx, 28(%3)\n"
26552 - "11: movl 32(%4), %%eax\n"
26553 - "61: movl 36(%4), %%edx\n"
26554 + "11: "__copyuser_seg" movl 32(%4), %%eax\n"
26555 + "61: "__copyuser_seg" movl 36(%4), %%edx\n"
26556 " movnti %%eax, 32(%3)\n"
26557 " movnti %%edx, 36(%3)\n"
26558 - "12: movl 40(%4), %%eax\n"
26559 - "71: movl 44(%4), %%edx\n"
26560 + "12: "__copyuser_seg" movl 40(%4), %%eax\n"
26561 + "71: "__copyuser_seg" movl 44(%4), %%edx\n"
26562 " movnti %%eax, 40(%3)\n"
26563 " movnti %%edx, 44(%3)\n"
26564 - "13: movl 48(%4), %%eax\n"
26565 - "81: movl 52(%4), %%edx\n"
26566 + "13: "__copyuser_seg" movl 48(%4), %%eax\n"
26567 + "81: "__copyuser_seg" movl 52(%4), %%edx\n"
26568 " movnti %%eax, 48(%3)\n"
26569 " movnti %%edx, 52(%3)\n"
26570 - "14: movl 56(%4), %%eax\n"
26571 - "91: movl 60(%4), %%edx\n"
26572 + "14: "__copyuser_seg" movl 56(%4), %%eax\n"
26573 + "91: "__copyuser_seg" movl 60(%4), %%edx\n"
26574 " movnti %%eax, 56(%3)\n"
26575 " movnti %%edx, 60(%3)\n"
26576 " addl $-64, %0\n"
26577 @@ -352,9 +460,9 @@ static unsigned long __copy_user_zeroing_intel_nocache(void *to,
26578 " shrl $2, %0\n"
26579 " andl $3, %%eax\n"
26580 " cld\n"
26581 - "6: rep; movsl\n"
26582 + "6: rep; "__copyuser_seg" movsl\n"
26583 " movl %%eax,%0\n"
26584 - "7: rep; movsb\n"
26585 + "7: rep; "__copyuser_seg" movsb\n"
26586 "8:\n"
26587 ".section .fixup,\"ax\"\n"
26588 "9: lea 0(%%eax,%0,4),%0\n"
26589 @@ -392,48 +500,48 @@ static unsigned long __copy_user_zeroing_intel_nocache(void *to,
26590 return size;
26591 }
26592
26593 -static unsigned long __copy_user_intel_nocache(void *to,
26594 +static unsigned long __size_overflow(3) __copy_user_intel_nocache(void *to,
26595 const void __user *from, unsigned long size)
26596 {
26597 int d0, d1;
26598
26599 __asm__ __volatile__(
26600 " .align 2,0x90\n"
26601 - "0: movl 32(%4), %%eax\n"
26602 + "0: "__copyuser_seg" movl 32(%4), %%eax\n"
26603 " cmpl $67, %0\n"
26604 " jbe 2f\n"
26605 - "1: movl 64(%4), %%eax\n"
26606 + "1: "__copyuser_seg" movl 64(%4), %%eax\n"
26607 " .align 2,0x90\n"
26608 - "2: movl 0(%4), %%eax\n"
26609 - "21: movl 4(%4), %%edx\n"
26610 + "2: "__copyuser_seg" movl 0(%4), %%eax\n"
26611 + "21: "__copyuser_seg" movl 4(%4), %%edx\n"
26612 " movnti %%eax, 0(%3)\n"
26613 " movnti %%edx, 4(%3)\n"
26614 - "3: movl 8(%4), %%eax\n"
26615 - "31: movl 12(%4),%%edx\n"
26616 + "3: "__copyuser_seg" movl 8(%4), %%eax\n"
26617 + "31: "__copyuser_seg" movl 12(%4),%%edx\n"
26618 " movnti %%eax, 8(%3)\n"
26619 " movnti %%edx, 12(%3)\n"
26620 - "4: movl 16(%4), %%eax\n"
26621 - "41: movl 20(%4), %%edx\n"
26622 + "4: "__copyuser_seg" movl 16(%4), %%eax\n"
26623 + "41: "__copyuser_seg" movl 20(%4), %%edx\n"
26624 " movnti %%eax, 16(%3)\n"
26625 " movnti %%edx, 20(%3)\n"
26626 - "10: movl 24(%4), %%eax\n"
26627 - "51: movl 28(%4), %%edx\n"
26628 + "10: "__copyuser_seg" movl 24(%4), %%eax\n"
26629 + "51: "__copyuser_seg" movl 28(%4), %%edx\n"
26630 " movnti %%eax, 24(%3)\n"
26631 " movnti %%edx, 28(%3)\n"
26632 - "11: movl 32(%4), %%eax\n"
26633 - "61: movl 36(%4), %%edx\n"
26634 + "11: "__copyuser_seg" movl 32(%4), %%eax\n"
26635 + "61: "__copyuser_seg" movl 36(%4), %%edx\n"
26636 " movnti %%eax, 32(%3)\n"
26637 " movnti %%edx, 36(%3)\n"
26638 - "12: movl 40(%4), %%eax\n"
26639 - "71: movl 44(%4), %%edx\n"
26640 + "12: "__copyuser_seg" movl 40(%4), %%eax\n"
26641 + "71: "__copyuser_seg" movl 44(%4), %%edx\n"
26642 " movnti %%eax, 40(%3)\n"
26643 " movnti %%edx, 44(%3)\n"
26644 - "13: movl 48(%4), %%eax\n"
26645 - "81: movl 52(%4), %%edx\n"
26646 + "13: "__copyuser_seg" movl 48(%4), %%eax\n"
26647 + "81: "__copyuser_seg" movl 52(%4), %%edx\n"
26648 " movnti %%eax, 48(%3)\n"
26649 " movnti %%edx, 52(%3)\n"
26650 - "14: movl 56(%4), %%eax\n"
26651 - "91: movl 60(%4), %%edx\n"
26652 + "14: "__copyuser_seg" movl 56(%4), %%eax\n"
26653 + "91: "__copyuser_seg" movl 60(%4), %%edx\n"
26654 " movnti %%eax, 56(%3)\n"
26655 " movnti %%edx, 60(%3)\n"
26656 " addl $-64, %0\n"
26657 @@ -446,9 +554,9 @@ static unsigned long __copy_user_intel_nocache(void *to,
26658 " shrl $2, %0\n"
26659 " andl $3, %%eax\n"
26660 " cld\n"
26661 - "6: rep; movsl\n"
26662 + "6: rep; "__copyuser_seg" movsl\n"
26663 " movl %%eax,%0\n"
26664 - "7: rep; movsb\n"
26665 + "7: rep; "__copyuser_seg" movsb\n"
26666 "8:\n"
26667 ".section .fixup,\"ax\"\n"
26668 "9: lea 0(%%eax,%0,4),%0\n"
26669 @@ -488,32 +596,36 @@ static unsigned long __copy_user_intel_nocache(void *to,
26670 */
26671 unsigned long __copy_user_zeroing_intel(void *to, const void __user *from,
26672 unsigned long size);
26673 -unsigned long __copy_user_intel(void __user *to, const void *from,
26674 +unsigned long __generic_copy_to_user_intel(void __user *to, const void *from,
26675 + unsigned long size);
26676 +unsigned long __generic_copy_from_user_intel(void *to, const void __user *from,
26677 unsigned long size);
26678 unsigned long __copy_user_zeroing_intel_nocache(void *to,
26679 const void __user *from, unsigned long size);
26680 #endif /* CONFIG_X86_INTEL_USERCOPY */
26681
26682 /* Generic arbitrary sized copy. */
26683 -#define __copy_user(to, from, size) \
26684 +#define __copy_user(to, from, size, prefix, set, restore) \
26685 do { \
26686 int __d0, __d1, __d2; \
26687 __asm__ __volatile__( \
26688 + set \
26689 " cmp $7,%0\n" \
26690 " jbe 1f\n" \
26691 " movl %1,%0\n" \
26692 " negl %0\n" \
26693 " andl $7,%0\n" \
26694 " subl %0,%3\n" \
26695 - "4: rep; movsb\n" \
26696 + "4: rep; "prefix"movsb\n" \
26697 " movl %3,%0\n" \
26698 " shrl $2,%0\n" \
26699 " andl $3,%3\n" \
26700 " .align 2,0x90\n" \
26701 - "0: rep; movsl\n" \
26702 + "0: rep; "prefix"movsl\n" \
26703 " movl %3,%0\n" \
26704 - "1: rep; movsb\n" \
26705 + "1: rep; "prefix"movsb\n" \
26706 "2:\n" \
26707 + restore \
26708 ".section .fixup,\"ax\"\n" \
26709 "5: addl %3,%0\n" \
26710 " jmp 2b\n" \
26711 @@ -538,14 +650,14 @@ do { \
26712 " negl %0\n" \
26713 " andl $7,%0\n" \
26714 " subl %0,%3\n" \
26715 - "4: rep; movsb\n" \
26716 + "4: rep; "__copyuser_seg"movsb\n" \
26717 " movl %3,%0\n" \
26718 " shrl $2,%0\n" \
26719 " andl $3,%3\n" \
26720 " .align 2,0x90\n" \
26721 - "0: rep; movsl\n" \
26722 + "0: rep; "__copyuser_seg"movsl\n" \
26723 " movl %3,%0\n" \
26724 - "1: rep; movsb\n" \
26725 + "1: rep; "__copyuser_seg"movsb\n" \
26726 "2:\n" \
26727 ".section .fixup,\"ax\"\n" \
26728 "5: addl %3,%0\n" \
26729 @@ -572,9 +684,9 @@ unsigned long __copy_to_user_ll(void __user *to, const void *from,
26730 {
26731 stac();
26732 if (movsl_is_ok(to, from, n))
26733 - __copy_user(to, from, n);
26734 + __copy_user(to, from, n, "", __COPYUSER_SET_ES, __COPYUSER_RESTORE_ES);
26735 else
26736 - n = __copy_user_intel(to, from, n);
26737 + n = __generic_copy_to_user_intel(to, from, n);
26738 clac();
26739 return n;
26740 }
26741 @@ -598,10 +710,9 @@ unsigned long __copy_from_user_ll_nozero(void *to, const void __user *from,
26742 {
26743 stac();
26744 if (movsl_is_ok(to, from, n))
26745 - __copy_user(to, from, n);
26746 + __copy_user(to, from, n, __copyuser_seg, "", "");
26747 else
26748 - n = __copy_user_intel((void __user *)to,
26749 - (const void *)from, n);
26750 + n = __generic_copy_from_user_intel(to, from, n);
26751 clac();
26752 return n;
26753 }
26754 @@ -632,66 +743,51 @@ unsigned long __copy_from_user_ll_nocache_nozero(void *to, const void __user *fr
26755 if (n > 64 && cpu_has_xmm2)
26756 n = __copy_user_intel_nocache(to, from, n);
26757 else
26758 - __copy_user(to, from, n);
26759 + __copy_user(to, from, n, __copyuser_seg, "", "");
26760 #else
26761 - __copy_user(to, from, n);
26762 + __copy_user(to, from, n, __copyuser_seg, "", "");
26763 #endif
26764 clac();
26765 return n;
26766 }
26767 EXPORT_SYMBOL(__copy_from_user_ll_nocache_nozero);
26768
26769 -/**
26770 - * copy_to_user: - Copy a block of data into user space.
26771 - * @to: Destination address, in user space.
26772 - * @from: Source address, in kernel space.
26773 - * @n: Number of bytes to copy.
26774 - *
26775 - * Context: User context only. This function may sleep.
26776 - *
26777 - * Copy data from kernel space to user space.
26778 - *
26779 - * Returns number of bytes that could not be copied.
26780 - * On success, this will be zero.
26781 - */
26782 -unsigned long
26783 -copy_to_user(void __user *to, const void *from, unsigned long n)
26784 -{
26785 - if (access_ok(VERIFY_WRITE, to, n))
26786 - n = __copy_to_user(to, from, n);
26787 - return n;
26788 -}
26789 -EXPORT_SYMBOL(copy_to_user);
26790 -
26791 -/**
26792 - * copy_from_user: - Copy a block of data from user space.
26793 - * @to: Destination address, in kernel space.
26794 - * @from: Source address, in user space.
26795 - * @n: Number of bytes to copy.
26796 - *
26797 - * Context: User context only. This function may sleep.
26798 - *
26799 - * Copy data from user space to kernel space.
26800 - *
26801 - * Returns number of bytes that could not be copied.
26802 - * On success, this will be zero.
26803 - *
26804 - * If some data could not be copied, this function will pad the copied
26805 - * data to the requested size using zero bytes.
26806 - */
26807 -unsigned long
26808 -_copy_from_user(void *to, const void __user *from, unsigned long n)
26809 -{
26810 - if (access_ok(VERIFY_READ, from, n))
26811 - n = __copy_from_user(to, from, n);
26812 - else
26813 - memset(to, 0, n);
26814 - return n;
26815 -}
26816 -EXPORT_SYMBOL(_copy_from_user);
26817 -
26818 void copy_from_user_overflow(void)
26819 {
26820 WARN(1, "Buffer overflow detected!\n");
26821 }
26822 EXPORT_SYMBOL(copy_from_user_overflow);
26823 +
26824 +void copy_to_user_overflow(void)
26825 +{
26826 + WARN(1, "Buffer overflow detected!\n");
26827 +}
26828 +EXPORT_SYMBOL(copy_to_user_overflow);
26829 +
26830 +#ifdef CONFIG_PAX_MEMORY_UDEREF
26831 +void __set_fs(mm_segment_t x)
26832 +{
26833 + switch (x.seg) {
26834 + case 0:
26835 + loadsegment(gs, 0);
26836 + break;
26837 + case TASK_SIZE_MAX:
26838 + loadsegment(gs, __USER_DS);
26839 + break;
26840 + case -1UL:
26841 + loadsegment(gs, __KERNEL_DS);
26842 + break;
26843 + default:
26844 + BUG();
26845 + }
26846 + return;
26847 +}
26848 +EXPORT_SYMBOL(__set_fs);
26849 +
26850 +void set_fs(mm_segment_t x)
26851 +{
26852 + current_thread_info()->addr_limit = x;
26853 + __set_fs(x);
26854 +}
26855 +EXPORT_SYMBOL(set_fs);
26856 +#endif
26857 diff --git a/arch/x86/lib/usercopy_64.c b/arch/x86/lib/usercopy_64.c
26858 index 05928aa..b33dea1 100644
26859 --- a/arch/x86/lib/usercopy_64.c
26860 +++ b/arch/x86/lib/usercopy_64.c
26861 @@ -39,7 +39,7 @@ unsigned long __clear_user(void __user *addr, unsigned long size)
26862 _ASM_EXTABLE(0b,3b)
26863 _ASM_EXTABLE(1b,2b)
26864 : [size8] "=&c"(size), [dst] "=&D" (__d0)
26865 - : [size1] "r"(size & 7), "[size8]" (size / 8), "[dst]"(addr),
26866 + : [size1] "r"(size & 7), "[size8]" (size / 8), "[dst]"(____m(addr)),
26867 [zero] "r" (0UL), [eight] "r" (8UL));
26868 clac();
26869 return size;
26870 @@ -54,12 +54,11 @@ unsigned long clear_user(void __user *to, unsigned long n)
26871 }
26872 EXPORT_SYMBOL(clear_user);
26873
26874 -unsigned long copy_in_user(void __user *to, const void __user *from, unsigned len)
26875 +unsigned long copy_in_user(void __user *to, const void __user *from, unsigned long len)
26876 {
26877 - if (access_ok(VERIFY_WRITE, to, len) && access_ok(VERIFY_READ, from, len)) {
26878 - return copy_user_generic((__force void *)to, (__force void *)from, len);
26879 - }
26880 - return len;
26881 + if (access_ok(VERIFY_WRITE, to, len) && access_ok(VERIFY_READ, from, len))
26882 + return copy_user_generic((void __force_kernel *)____m(to), (void __force_kernel *)____m(from), len);
26883 + return len;
26884 }
26885 EXPORT_SYMBOL(copy_in_user);
26886
26887 @@ -69,7 +68,7 @@ EXPORT_SYMBOL(copy_in_user);
26888 * it is not necessary to optimize tail handling.
26889 */
26890 unsigned long
26891 -copy_user_handle_tail(char *to, char *from, unsigned len, unsigned zerorest)
26892 +copy_user_handle_tail(char __user *to, char __user *from, unsigned long len, unsigned zerorest)
26893 {
26894 char c;
26895 unsigned zero_len;
26896 @@ -87,3 +86,15 @@ copy_user_handle_tail(char *to, char *from, unsigned len, unsigned zerorest)
26897 clac();
26898 return len;
26899 }
26900 +
26901 +void copy_from_user_overflow(void)
26902 +{
26903 + WARN(1, "Buffer overflow detected!\n");
26904 +}
26905 +EXPORT_SYMBOL(copy_from_user_overflow);
26906 +
26907 +void copy_to_user_overflow(void)
26908 +{
26909 + WARN(1, "Buffer overflow detected!\n");
26910 +}
26911 +EXPORT_SYMBOL(copy_to_user_overflow);
26912 diff --git a/arch/x86/mm/extable.c b/arch/x86/mm/extable.c
26913 index 903ec1e..c4166b2 100644
26914 --- a/arch/x86/mm/extable.c
26915 +++ b/arch/x86/mm/extable.c
26916 @@ -6,12 +6,24 @@
26917 static inline unsigned long
26918 ex_insn_addr(const struct exception_table_entry *x)
26919 {
26920 - return (unsigned long)&x->insn + x->insn;
26921 + unsigned long reloc = 0;
26922 +
26923 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
26924 + reloc = ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
26925 +#endif
26926 +
26927 + return (unsigned long)&x->insn + x->insn + reloc;
26928 }
26929 static inline unsigned long
26930 ex_fixup_addr(const struct exception_table_entry *x)
26931 {
26932 - return (unsigned long)&x->fixup + x->fixup;
26933 + unsigned long reloc = 0;
26934 +
26935 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
26936 + reloc = ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
26937 +#endif
26938 +
26939 + return (unsigned long)&x->fixup + x->fixup + reloc;
26940 }
26941
26942 int fixup_exception(struct pt_regs *regs)
26943 @@ -20,7 +32,7 @@ int fixup_exception(struct pt_regs *regs)
26944 unsigned long new_ip;
26945
26946 #ifdef CONFIG_PNPBIOS
26947 - if (unlikely(SEGMENT_IS_PNP_CODE(regs->cs))) {
26948 + if (unlikely(!v8086_mode(regs) && SEGMENT_IS_PNP_CODE(regs->cs))) {
26949 extern u32 pnp_bios_fault_eip, pnp_bios_fault_esp;
26950 extern u32 pnp_bios_is_utter_crap;
26951 pnp_bios_is_utter_crap = 1;
26952 @@ -145,6 +157,13 @@ void sort_extable(struct exception_table_entry *start,
26953 i += 4;
26954 p->fixup -= i;
26955 i += 4;
26956 +
26957 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
26958 + BUILD_BUG_ON(!IS_ENABLED(CONFIG_BUILDTIME_EXTABLE_SORT));
26959 + p->insn -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
26960 + p->fixup -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
26961 +#endif
26962 +
26963 }
26964 }
26965
26966 diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c
26967 index fb674fd..1be28b9 100644
26968 --- a/arch/x86/mm/fault.c
26969 +++ b/arch/x86/mm/fault.c
26970 @@ -13,12 +13,19 @@
26971 #include <linux/perf_event.h> /* perf_sw_event */
26972 #include <linux/hugetlb.h> /* hstate_index_to_shift */
26973 #include <linux/prefetch.h> /* prefetchw */
26974 +#include <linux/unistd.h>
26975 +#include <linux/compiler.h>
26976
26977 #include <asm/traps.h> /* dotraplinkage, ... */
26978 #include <asm/pgalloc.h> /* pgd_*(), ... */
26979 #include <asm/kmemcheck.h> /* kmemcheck_*(), ... */
26980 #include <asm/fixmap.h> /* VSYSCALL_START */
26981 #include <asm/context_tracking.h> /* exception_enter(), ... */
26982 +#include <asm/tlbflush.h>
26983 +
26984 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
26985 +#include <asm/stacktrace.h>
26986 +#endif
26987
26988 /*
26989 * Page fault error code bits:
26990 @@ -56,7 +63,7 @@ static inline int __kprobes notify_page_fault(struct pt_regs *regs)
26991 int ret = 0;
26992
26993 /* kprobe_running() needs smp_processor_id() */
26994 - if (kprobes_built_in() && !user_mode_vm(regs)) {
26995 + if (kprobes_built_in() && !user_mode(regs)) {
26996 preempt_disable();
26997 if (kprobe_running() && kprobe_fault_handler(regs, 14))
26998 ret = 1;
26999 @@ -117,7 +124,10 @@ check_prefetch_opcode(struct pt_regs *regs, unsigned char *instr,
27000 return !instr_lo || (instr_lo>>1) == 1;
27001 case 0x00:
27002 /* Prefetch instruction is 0x0F0D or 0x0F18 */
27003 - if (probe_kernel_address(instr, opcode))
27004 + if (user_mode(regs)) {
27005 + if (__copy_from_user_inatomic(&opcode, (unsigned char __force_user *)(instr), 1))
27006 + return 0;
27007 + } else if (probe_kernel_address(instr, opcode))
27008 return 0;
27009
27010 *prefetch = (instr_lo == 0xF) &&
27011 @@ -151,7 +161,10 @@ is_prefetch(struct pt_regs *regs, unsigned long error_code, unsigned long addr)
27012 while (instr < max_instr) {
27013 unsigned char opcode;
27014
27015 - if (probe_kernel_address(instr, opcode))
27016 + if (user_mode(regs)) {
27017 + if (__copy_from_user_inatomic(&opcode, (unsigned char __force_user *)(instr), 1))
27018 + break;
27019 + } else if (probe_kernel_address(instr, opcode))
27020 break;
27021
27022 instr++;
27023 @@ -182,6 +195,34 @@ force_sig_info_fault(int si_signo, int si_code, unsigned long address,
27024 force_sig_info(si_signo, &info, tsk);
27025 }
27026
27027 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
27028 +static bool pax_is_fetch_fault(struct pt_regs *regs, unsigned long error_code, unsigned long address);
27029 +#endif
27030 +
27031 +#ifdef CONFIG_PAX_EMUTRAMP
27032 +static int pax_handle_fetch_fault(struct pt_regs *regs);
27033 +#endif
27034 +
27035 +#ifdef CONFIG_PAX_PAGEEXEC
27036 +static inline pmd_t * pax_get_pmd(struct mm_struct *mm, unsigned long address)
27037 +{
27038 + pgd_t *pgd;
27039 + pud_t *pud;
27040 + pmd_t *pmd;
27041 +
27042 + pgd = pgd_offset(mm, address);
27043 + if (!pgd_present(*pgd))
27044 + return NULL;
27045 + pud = pud_offset(pgd, address);
27046 + if (!pud_present(*pud))
27047 + return NULL;
27048 + pmd = pmd_offset(pud, address);
27049 + if (!pmd_present(*pmd))
27050 + return NULL;
27051 + return pmd;
27052 +}
27053 +#endif
27054 +
27055 DEFINE_SPINLOCK(pgd_lock);
27056 LIST_HEAD(pgd_list);
27057
27058 @@ -232,10 +273,22 @@ void vmalloc_sync_all(void)
27059 for (address = VMALLOC_START & PMD_MASK;
27060 address >= TASK_SIZE && address < FIXADDR_TOP;
27061 address += PMD_SIZE) {
27062 +
27063 +#ifdef CONFIG_PAX_PER_CPU_PGD
27064 + unsigned long cpu;
27065 +#else
27066 struct page *page;
27067 +#endif
27068
27069 spin_lock(&pgd_lock);
27070 +
27071 +#ifdef CONFIG_PAX_PER_CPU_PGD
27072 + for (cpu = 0; cpu < nr_cpu_ids; ++cpu) {
27073 + pgd_t *pgd = get_cpu_pgd(cpu);
27074 + pmd_t *ret;
27075 +#else
27076 list_for_each_entry(page, &pgd_list, lru) {
27077 + pgd_t *pgd = page_address(page);
27078 spinlock_t *pgt_lock;
27079 pmd_t *ret;
27080
27081 @@ -243,8 +296,13 @@ void vmalloc_sync_all(void)
27082 pgt_lock = &pgd_page_get_mm(page)->page_table_lock;
27083
27084 spin_lock(pgt_lock);
27085 - ret = vmalloc_sync_one(page_address(page), address);
27086 +#endif
27087 +
27088 + ret = vmalloc_sync_one(pgd, address);
27089 +
27090 +#ifndef CONFIG_PAX_PER_CPU_PGD
27091 spin_unlock(pgt_lock);
27092 +#endif
27093
27094 if (!ret)
27095 break;
27096 @@ -278,6 +336,11 @@ static noinline __kprobes int vmalloc_fault(unsigned long address)
27097 * an interrupt in the middle of a task switch..
27098 */
27099 pgd_paddr = read_cr3();
27100 +
27101 +#ifdef CONFIG_PAX_PER_CPU_PGD
27102 + BUG_ON(__pa(get_cpu_pgd(smp_processor_id())) != (pgd_paddr & PHYSICAL_PAGE_MASK));
27103 +#endif
27104 +
27105 pmd_k = vmalloc_sync_one(__va(pgd_paddr), address);
27106 if (!pmd_k)
27107 return -1;
27108 @@ -373,7 +436,14 @@ static noinline __kprobes int vmalloc_fault(unsigned long address)
27109 * happen within a race in page table update. In the later
27110 * case just flush:
27111 */
27112 +
27113 +#ifdef CONFIG_PAX_PER_CPU_PGD
27114 + BUG_ON(__pa(get_cpu_pgd(smp_processor_id())) != (read_cr3() & PHYSICAL_PAGE_MASK));
27115 + pgd = pgd_offset_cpu(smp_processor_id(), address);
27116 +#else
27117 pgd = pgd_offset(current->active_mm, address);
27118 +#endif
27119 +
27120 pgd_ref = pgd_offset_k(address);
27121 if (pgd_none(*pgd_ref))
27122 return -1;
27123 @@ -541,7 +611,7 @@ static int is_errata93(struct pt_regs *regs, unsigned long address)
27124 static int is_errata100(struct pt_regs *regs, unsigned long address)
27125 {
27126 #ifdef CONFIG_X86_64
27127 - if ((regs->cs == __USER32_CS || (regs->cs & (1<<2))) && (address >> 32))
27128 + if ((regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT)) && (address >> 32))
27129 return 1;
27130 #endif
27131 return 0;
27132 @@ -568,7 +638,7 @@ static int is_f00f_bug(struct pt_regs *regs, unsigned long address)
27133 }
27134
27135 static const char nx_warning[] = KERN_CRIT
27136 -"kernel tried to execute NX-protected page - exploit attempt? (uid: %d)\n";
27137 +"kernel tried to execute NX-protected page - exploit attempt? (uid: %d, task: %s, pid: %d)\n";
27138
27139 static void
27140 show_fault_oops(struct pt_regs *regs, unsigned long error_code,
27141 @@ -577,15 +647,27 @@ show_fault_oops(struct pt_regs *regs, unsigned long error_code,
27142 if (!oops_may_print())
27143 return;
27144
27145 - if (error_code & PF_INSTR) {
27146 + if ((__supported_pte_mask & _PAGE_NX) && (error_code & PF_INSTR)) {
27147 unsigned int level;
27148
27149 pte_t *pte = lookup_address(address, &level);
27150
27151 if (pte && pte_present(*pte) && !pte_exec(*pte))
27152 - printk(nx_warning, from_kuid(&init_user_ns, current_uid()));
27153 + printk(nx_warning, from_kuid_munged(&init_user_ns, current_uid()), current->comm, task_pid_nr(current));
27154 }
27155
27156 +#ifdef CONFIG_PAX_KERNEXEC
27157 + if (init_mm.start_code <= address && address < init_mm.end_code) {
27158 + if (current->signal->curr_ip)
27159 + printk(KERN_ERR "PAX: From %pI4: %s:%d, uid/euid: %u/%u, attempted to modify kernel code\n",
27160 + &current->signal->curr_ip, current->comm, task_pid_nr(current),
27161 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
27162 + else
27163 + printk(KERN_ERR "PAX: %s:%d, uid/euid: %u/%u, attempted to modify kernel code\n", current->comm, task_pid_nr(current),
27164 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
27165 + }
27166 +#endif
27167 +
27168 printk(KERN_ALERT "BUG: unable to handle kernel ");
27169 if (address < PAGE_SIZE)
27170 printk(KERN_CONT "NULL pointer dereference");
27171 @@ -748,6 +830,22 @@ __bad_area_nosemaphore(struct pt_regs *regs, unsigned long error_code,
27172 return;
27173 }
27174 #endif
27175 +
27176 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
27177 + if (pax_is_fetch_fault(regs, error_code, address)) {
27178 +
27179 +#ifdef CONFIG_PAX_EMUTRAMP
27180 + switch (pax_handle_fetch_fault(regs)) {
27181 + case 2:
27182 + return;
27183 + }
27184 +#endif
27185 +
27186 + pax_report_fault(regs, (void *)regs->ip, (void *)regs->sp);
27187 + do_group_exit(SIGKILL);
27188 + }
27189 +#endif
27190 +
27191 /* Kernel addresses are always protection faults: */
27192 if (address >= TASK_SIZE)
27193 error_code |= PF_PROT;
27194 @@ -833,7 +931,7 @@ do_sigbus(struct pt_regs *regs, unsigned long error_code, unsigned long address,
27195 if (fault & (VM_FAULT_HWPOISON|VM_FAULT_HWPOISON_LARGE)) {
27196 printk(KERN_ERR
27197 "MCE: Killing %s:%d due to hardware memory corruption fault at %lx\n",
27198 - tsk->comm, tsk->pid, address);
27199 + tsk->comm, task_pid_nr(tsk), address);
27200 code = BUS_MCEERR_AR;
27201 }
27202 #endif
27203 @@ -896,6 +994,99 @@ static int spurious_fault_check(unsigned long error_code, pte_t *pte)
27204 return 1;
27205 }
27206
27207 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
27208 +static int pax_handle_pageexec_fault(struct pt_regs *regs, struct mm_struct *mm, unsigned long address, unsigned long error_code)
27209 +{
27210 + pte_t *pte;
27211 + pmd_t *pmd;
27212 + spinlock_t *ptl;
27213 + unsigned char pte_mask;
27214 +
27215 + if ((__supported_pte_mask & _PAGE_NX) || (error_code & (PF_PROT|PF_USER)) != (PF_PROT|PF_USER) || v8086_mode(regs) ||
27216 + !(mm->pax_flags & MF_PAX_PAGEEXEC))
27217 + return 0;
27218 +
27219 + /* PaX: it's our fault, let's handle it if we can */
27220 +
27221 + /* PaX: take a look at read faults before acquiring any locks */
27222 + if (unlikely(!(error_code & PF_WRITE) && (regs->ip == address))) {
27223 + /* instruction fetch attempt from a protected page in user mode */
27224 + up_read(&mm->mmap_sem);
27225 +
27226 +#ifdef CONFIG_PAX_EMUTRAMP
27227 + switch (pax_handle_fetch_fault(regs)) {
27228 + case 2:
27229 + return 1;
27230 + }
27231 +#endif
27232 +
27233 + pax_report_fault(regs, (void *)regs->ip, (void *)regs->sp);
27234 + do_group_exit(SIGKILL);
27235 + }
27236 +
27237 + pmd = pax_get_pmd(mm, address);
27238 + if (unlikely(!pmd))
27239 + return 0;
27240 +
27241 + pte = pte_offset_map_lock(mm, pmd, address, &ptl);
27242 + if (unlikely(!(pte_val(*pte) & _PAGE_PRESENT) || pte_user(*pte))) {
27243 + pte_unmap_unlock(pte, ptl);
27244 + return 0;
27245 + }
27246 +
27247 + if (unlikely((error_code & PF_WRITE) && !pte_write(*pte))) {
27248 + /* write attempt to a protected page in user mode */
27249 + pte_unmap_unlock(pte, ptl);
27250 + return 0;
27251 + }
27252 +
27253 +#ifdef CONFIG_SMP
27254 + if (likely(address > get_limit(regs->cs) && cpu_isset(smp_processor_id(), mm->context.cpu_user_cs_mask)))
27255 +#else
27256 + if (likely(address > get_limit(regs->cs)))
27257 +#endif
27258 + {
27259 + set_pte(pte, pte_mkread(*pte));
27260 + __flush_tlb_one(address);
27261 + pte_unmap_unlock(pte, ptl);
27262 + up_read(&mm->mmap_sem);
27263 + return 1;
27264 + }
27265 +
27266 + pte_mask = _PAGE_ACCESSED | _PAGE_USER | ((error_code & PF_WRITE) << (_PAGE_BIT_DIRTY-1));
27267 +
27268 + /*
27269 + * PaX: fill DTLB with user rights and retry
27270 + */
27271 + __asm__ __volatile__ (
27272 + "orb %2,(%1)\n"
27273 +#if defined(CONFIG_M586) || defined(CONFIG_M586TSC)
27274 +/*
27275 + * PaX: let this uncommented 'invlpg' remind us on the behaviour of Intel's
27276 + * (and AMD's) TLBs. namely, they do not cache PTEs that would raise *any*
27277 + * page fault when examined during a TLB load attempt. this is true not only
27278 + * for PTEs holding a non-present entry but also present entries that will
27279 + * raise a page fault (such as those set up by PaX, or the copy-on-write
27280 + * mechanism). in effect it means that we do *not* need to flush the TLBs
27281 + * for our target pages since their PTEs are simply not in the TLBs at all.
27282 +
27283 + * the best thing in omitting it is that we gain around 15-20% speed in the
27284 + * fast path of the page fault handler and can get rid of tracing since we
27285 + * can no longer flush unintended entries.
27286 + */
27287 + "invlpg (%0)\n"
27288 +#endif
27289 + __copyuser_seg"testb $0,(%0)\n"
27290 + "xorb %3,(%1)\n"
27291 + :
27292 + : "r" (address), "r" (pte), "q" (pte_mask), "i" (_PAGE_USER)
27293 + : "memory", "cc");
27294 + pte_unmap_unlock(pte, ptl);
27295 + up_read(&mm->mmap_sem);
27296 + return 1;
27297 +}
27298 +#endif
27299 +
27300 /*
27301 * Handle a spurious fault caused by a stale TLB entry.
27302 *
27303 @@ -968,6 +1159,9 @@ int show_unhandled_signals = 1;
27304 static inline int
27305 access_error(unsigned long error_code, struct vm_area_struct *vma)
27306 {
27307 + if ((__supported_pte_mask & _PAGE_NX) && (error_code & PF_INSTR) && !(vma->vm_flags & VM_EXEC))
27308 + return 1;
27309 +
27310 if (error_code & PF_WRITE) {
27311 /* write, present and write, not present: */
27312 if (unlikely(!(vma->vm_flags & VM_WRITE)))
27313 @@ -996,7 +1190,7 @@ static inline bool smap_violation(int error_code, struct pt_regs *regs)
27314 if (error_code & PF_USER)
27315 return false;
27316
27317 - if (!user_mode_vm(regs) && (regs->flags & X86_EFLAGS_AC))
27318 + if (!user_mode(regs) && (regs->flags & X86_EFLAGS_AC))
27319 return false;
27320
27321 return true;
27322 @@ -1012,18 +1206,33 @@ __do_page_fault(struct pt_regs *regs, unsigned long error_code)
27323 {
27324 struct vm_area_struct *vma;
27325 struct task_struct *tsk;
27326 - unsigned long address;
27327 struct mm_struct *mm;
27328 int fault;
27329 int write = error_code & PF_WRITE;
27330 unsigned int flags = FAULT_FLAG_ALLOW_RETRY | FAULT_FLAG_KILLABLE |
27331 (write ? FAULT_FLAG_WRITE : 0);
27332
27333 - tsk = current;
27334 - mm = tsk->mm;
27335 -
27336 /* Get the faulting address: */
27337 - address = read_cr2();
27338 + unsigned long address = read_cr2();
27339 +
27340 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
27341 + if (!user_mode(regs) && address < 2 * PAX_USER_SHADOW_BASE) {
27342 + if (!search_exception_tables(regs->ip)) {
27343 + printk(KERN_ERR "PAX: please report this to pageexec@freemail.hu\n");
27344 + bad_area_nosemaphore(regs, error_code, address);
27345 + return;
27346 + }
27347 + if (address < PAX_USER_SHADOW_BASE) {
27348 + printk(KERN_ERR "PAX: please report this to pageexec@freemail.hu\n");
27349 + printk(KERN_ERR "PAX: faulting IP: %pS\n", (void *)regs->ip);
27350 + show_trace_log_lvl(NULL, NULL, (void *)regs->sp, regs->bp, KERN_ERR);
27351 + } else
27352 + address -= PAX_USER_SHADOW_BASE;
27353 + }
27354 +#endif
27355 +
27356 + tsk = current;
27357 + mm = tsk->mm;
27358
27359 /*
27360 * Detect and handle instructions that would cause a page fault for
27361 @@ -1084,7 +1293,7 @@ __do_page_fault(struct pt_regs *regs, unsigned long error_code)
27362 * User-mode registers count as a user access even for any
27363 * potential system fault or CPU buglet:
27364 */
27365 - if (user_mode_vm(regs)) {
27366 + if (user_mode(regs)) {
27367 local_irq_enable();
27368 error_code |= PF_USER;
27369 } else {
27370 @@ -1146,6 +1355,11 @@ retry:
27371 might_sleep();
27372 }
27373
27374 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
27375 + if (pax_handle_pageexec_fault(regs, mm, address, error_code))
27376 + return;
27377 +#endif
27378 +
27379 vma = find_vma(mm, address);
27380 if (unlikely(!vma)) {
27381 bad_area(regs, error_code, address);
27382 @@ -1157,18 +1371,24 @@ retry:
27383 bad_area(regs, error_code, address);
27384 return;
27385 }
27386 - if (error_code & PF_USER) {
27387 - /*
27388 - * Accessing the stack below %sp is always a bug.
27389 - * The large cushion allows instructions like enter
27390 - * and pusha to work. ("enter $65535, $31" pushes
27391 - * 32 pointers and then decrements %sp by 65535.)
27392 - */
27393 - if (unlikely(address + 65536 + 32 * sizeof(unsigned long) < regs->sp)) {
27394 - bad_area(regs, error_code, address);
27395 - return;
27396 - }
27397 + /*
27398 + * Accessing the stack below %sp is always a bug.
27399 + * The large cushion allows instructions like enter
27400 + * and pusha to work. ("enter $65535, $31" pushes
27401 + * 32 pointers and then decrements %sp by 65535.)
27402 + */
27403 + if (unlikely(address + 65536 + 32 * sizeof(unsigned long) < task_pt_regs(tsk)->sp)) {
27404 + bad_area(regs, error_code, address);
27405 + return;
27406 }
27407 +
27408 +#ifdef CONFIG_PAX_SEGMEXEC
27409 + if (unlikely((mm->pax_flags & MF_PAX_SEGMEXEC) && vma->vm_end - SEGMEXEC_TASK_SIZE - 1 < address - SEGMEXEC_TASK_SIZE - 1)) {
27410 + bad_area(regs, error_code, address);
27411 + return;
27412 + }
27413 +#endif
27414 +
27415 if (unlikely(expand_stack(vma, address))) {
27416 bad_area(regs, error_code, address);
27417 return;
27418 @@ -1232,3 +1452,292 @@ do_page_fault(struct pt_regs *regs, unsigned long error_code)
27419 __do_page_fault(regs, error_code);
27420 exception_exit(regs);
27421 }
27422 +
27423 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
27424 +static bool pax_is_fetch_fault(struct pt_regs *regs, unsigned long error_code, unsigned long address)
27425 +{
27426 + struct mm_struct *mm = current->mm;
27427 + unsigned long ip = regs->ip;
27428 +
27429 + if (v8086_mode(regs))
27430 + ip = ((regs->cs & 0xffff) << 4) + (ip & 0xffff);
27431 +
27432 +#ifdef CONFIG_PAX_PAGEEXEC
27433 + if (mm->pax_flags & MF_PAX_PAGEEXEC) {
27434 + if ((__supported_pte_mask & _PAGE_NX) && (error_code & PF_INSTR))
27435 + return true;
27436 + if (!(error_code & (PF_PROT | PF_WRITE)) && ip == address)
27437 + return true;
27438 + return false;
27439 + }
27440 +#endif
27441 +
27442 +#ifdef CONFIG_PAX_SEGMEXEC
27443 + if (mm->pax_flags & MF_PAX_SEGMEXEC) {
27444 + if (!(error_code & (PF_PROT | PF_WRITE)) && (ip + SEGMEXEC_TASK_SIZE == address))
27445 + return true;
27446 + return false;
27447 + }
27448 +#endif
27449 +
27450 + return false;
27451 +}
27452 +#endif
27453 +
27454 +#ifdef CONFIG_PAX_EMUTRAMP
27455 +static int pax_handle_fetch_fault_32(struct pt_regs *regs)
27456 +{
27457 + int err;
27458 +
27459 + do { /* PaX: libffi trampoline emulation */
27460 + unsigned char mov, jmp;
27461 + unsigned int addr1, addr2;
27462 +
27463 +#ifdef CONFIG_X86_64
27464 + if ((regs->ip + 9) >> 32)
27465 + break;
27466 +#endif
27467 +
27468 + err = get_user(mov, (unsigned char __user *)regs->ip);
27469 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 1));
27470 + err |= get_user(jmp, (unsigned char __user *)(regs->ip + 5));
27471 + err |= get_user(addr2, (unsigned int __user *)(regs->ip + 6));
27472 +
27473 + if (err)
27474 + break;
27475 +
27476 + if (mov == 0xB8 && jmp == 0xE9) {
27477 + regs->ax = addr1;
27478 + regs->ip = (unsigned int)(regs->ip + addr2 + 10);
27479 + return 2;
27480 + }
27481 + } while (0);
27482 +
27483 + do { /* PaX: gcc trampoline emulation #1 */
27484 + unsigned char mov1, mov2;
27485 + unsigned short jmp;
27486 + unsigned int addr1, addr2;
27487 +
27488 +#ifdef CONFIG_X86_64
27489 + if ((regs->ip + 11) >> 32)
27490 + break;
27491 +#endif
27492 +
27493 + err = get_user(mov1, (unsigned char __user *)regs->ip);
27494 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 1));
27495 + err |= get_user(mov2, (unsigned char __user *)(regs->ip + 5));
27496 + err |= get_user(addr2, (unsigned int __user *)(regs->ip + 6));
27497 + err |= get_user(jmp, (unsigned short __user *)(regs->ip + 10));
27498 +
27499 + if (err)
27500 + break;
27501 +
27502 + if (mov1 == 0xB9 && mov2 == 0xB8 && jmp == 0xE0FF) {
27503 + regs->cx = addr1;
27504 + regs->ax = addr2;
27505 + regs->ip = addr2;
27506 + return 2;
27507 + }
27508 + } while (0);
27509 +
27510 + do { /* PaX: gcc trampoline emulation #2 */
27511 + unsigned char mov, jmp;
27512 + unsigned int addr1, addr2;
27513 +
27514 +#ifdef CONFIG_X86_64
27515 + if ((regs->ip + 9) >> 32)
27516 + break;
27517 +#endif
27518 +
27519 + err = get_user(mov, (unsigned char __user *)regs->ip);
27520 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 1));
27521 + err |= get_user(jmp, (unsigned char __user *)(regs->ip + 5));
27522 + err |= get_user(addr2, (unsigned int __user *)(regs->ip + 6));
27523 +
27524 + if (err)
27525 + break;
27526 +
27527 + if (mov == 0xB9 && jmp == 0xE9) {
27528 + regs->cx = addr1;
27529 + regs->ip = (unsigned int)(regs->ip + addr2 + 10);
27530 + return 2;
27531 + }
27532 + } while (0);
27533 +
27534 + return 1; /* PaX in action */
27535 +}
27536 +
27537 +#ifdef CONFIG_X86_64
27538 +static int pax_handle_fetch_fault_64(struct pt_regs *regs)
27539 +{
27540 + int err;
27541 +
27542 + do { /* PaX: libffi trampoline emulation */
27543 + unsigned short mov1, mov2, jmp1;
27544 + unsigned char stcclc, jmp2;
27545 + unsigned long addr1, addr2;
27546 +
27547 + err = get_user(mov1, (unsigned short __user *)regs->ip);
27548 + err |= get_user(addr1, (unsigned long __user *)(regs->ip + 2));
27549 + err |= get_user(mov2, (unsigned short __user *)(regs->ip + 10));
27550 + err |= get_user(addr2, (unsigned long __user *)(regs->ip + 12));
27551 + err |= get_user(stcclc, (unsigned char __user *)(regs->ip + 20));
27552 + err |= get_user(jmp1, (unsigned short __user *)(regs->ip + 21));
27553 + err |= get_user(jmp2, (unsigned char __user *)(regs->ip + 23));
27554 +
27555 + if (err)
27556 + break;
27557 +
27558 + if (mov1 == 0xBB49 && mov2 == 0xBA49 && (stcclc == 0xF8 || stcclc == 0xF9) && jmp1 == 0xFF49 && jmp2 == 0xE3) {
27559 + regs->r11 = addr1;
27560 + regs->r10 = addr2;
27561 + if (stcclc == 0xF8)
27562 + regs->flags &= ~X86_EFLAGS_CF;
27563 + else
27564 + regs->flags |= X86_EFLAGS_CF;
27565 + regs->ip = addr1;
27566 + return 2;
27567 + }
27568 + } while (0);
27569 +
27570 + do { /* PaX: gcc trampoline emulation #1 */
27571 + unsigned short mov1, mov2, jmp1;
27572 + unsigned char jmp2;
27573 + unsigned int addr1;
27574 + unsigned long addr2;
27575 +
27576 + err = get_user(mov1, (unsigned short __user *)regs->ip);
27577 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 2));
27578 + err |= get_user(mov2, (unsigned short __user *)(regs->ip + 6));
27579 + err |= get_user(addr2, (unsigned long __user *)(regs->ip + 8));
27580 + err |= get_user(jmp1, (unsigned short __user *)(regs->ip + 16));
27581 + err |= get_user(jmp2, (unsigned char __user *)(regs->ip + 18));
27582 +
27583 + if (err)
27584 + break;
27585 +
27586 + if (mov1 == 0xBB41 && mov2 == 0xBA49 && jmp1 == 0xFF49 && jmp2 == 0xE3) {
27587 + regs->r11 = addr1;
27588 + regs->r10 = addr2;
27589 + regs->ip = addr1;
27590 + return 2;
27591 + }
27592 + } while (0);
27593 +
27594 + do { /* PaX: gcc trampoline emulation #2 */
27595 + unsigned short mov1, mov2, jmp1;
27596 + unsigned char jmp2;
27597 + unsigned long addr1, addr2;
27598 +
27599 + err = get_user(mov1, (unsigned short __user *)regs->ip);
27600 + err |= get_user(addr1, (unsigned long __user *)(regs->ip + 2));
27601 + err |= get_user(mov2, (unsigned short __user *)(regs->ip + 10));
27602 + err |= get_user(addr2, (unsigned long __user *)(regs->ip + 12));
27603 + err |= get_user(jmp1, (unsigned short __user *)(regs->ip + 20));
27604 + err |= get_user(jmp2, (unsigned char __user *)(regs->ip + 22));
27605 +
27606 + if (err)
27607 + break;
27608 +
27609 + if (mov1 == 0xBB49 && mov2 == 0xBA49 && jmp1 == 0xFF49 && jmp2 == 0xE3) {
27610 + regs->r11 = addr1;
27611 + regs->r10 = addr2;
27612 + regs->ip = addr1;
27613 + return 2;
27614 + }
27615 + } while (0);
27616 +
27617 + return 1; /* PaX in action */
27618 +}
27619 +#endif
27620 +
27621 +/*
27622 + * PaX: decide what to do with offenders (regs->ip = fault address)
27623 + *
27624 + * returns 1 when task should be killed
27625 + * 2 when gcc trampoline was detected
27626 + */
27627 +static int pax_handle_fetch_fault(struct pt_regs *regs)
27628 +{
27629 + if (v8086_mode(regs))
27630 + return 1;
27631 +
27632 + if (!(current->mm->pax_flags & MF_PAX_EMUTRAMP))
27633 + return 1;
27634 +
27635 +#ifdef CONFIG_X86_32
27636 + return pax_handle_fetch_fault_32(regs);
27637 +#else
27638 + if (regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT))
27639 + return pax_handle_fetch_fault_32(regs);
27640 + else
27641 + return pax_handle_fetch_fault_64(regs);
27642 +#endif
27643 +}
27644 +#endif
27645 +
27646 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
27647 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
27648 +{
27649 + long i;
27650 +
27651 + printk(KERN_ERR "PAX: bytes at PC: ");
27652 + for (i = 0; i < 20; i++) {
27653 + unsigned char c;
27654 + if (get_user(c, (unsigned char __force_user *)pc+i))
27655 + printk(KERN_CONT "?? ");
27656 + else
27657 + printk(KERN_CONT "%02x ", c);
27658 + }
27659 + printk("\n");
27660 +
27661 + printk(KERN_ERR "PAX: bytes at SP-%lu: ", (unsigned long)sizeof(long));
27662 + for (i = -1; i < 80 / (long)sizeof(long); i++) {
27663 + unsigned long c;
27664 + if (get_user(c, (unsigned long __force_user *)sp+i)) {
27665 +#ifdef CONFIG_X86_32
27666 + printk(KERN_CONT "???????? ");
27667 +#else
27668 + if ((regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT)))
27669 + printk(KERN_CONT "???????? ???????? ");
27670 + else
27671 + printk(KERN_CONT "???????????????? ");
27672 +#endif
27673 + } else {
27674 +#ifdef CONFIG_X86_64
27675 + if ((regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT))) {
27676 + printk(KERN_CONT "%08x ", (unsigned int)c);
27677 + printk(KERN_CONT "%08x ", (unsigned int)(c >> 32));
27678 + } else
27679 +#endif
27680 + printk(KERN_CONT "%0*lx ", 2 * (int)sizeof(long), c);
27681 + }
27682 + }
27683 + printk("\n");
27684 +}
27685 +#endif
27686 +
27687 +/**
27688 + * probe_kernel_write(): safely attempt to write to a location
27689 + * @dst: address to write to
27690 + * @src: pointer to the data that shall be written
27691 + * @size: size of the data chunk
27692 + *
27693 + * Safely write to address @dst from the buffer at @src. If a kernel fault
27694 + * happens, handle that and return -EFAULT.
27695 + */
27696 +long notrace probe_kernel_write(void *dst, const void *src, size_t size)
27697 +{
27698 + long ret;
27699 + mm_segment_t old_fs = get_fs();
27700 +
27701 + set_fs(KERNEL_DS);
27702 + pagefault_disable();
27703 + pax_open_kernel();
27704 + ret = __copy_to_user_inatomic((void __force_user *)dst, src, size);
27705 + pax_close_kernel();
27706 + pagefault_enable();
27707 + set_fs(old_fs);
27708 +
27709 + return ret ? -EFAULT : 0;
27710 +}
27711 diff --git a/arch/x86/mm/gup.c b/arch/x86/mm/gup.c
27712 index dd74e46..7d26398 100644
27713 --- a/arch/x86/mm/gup.c
27714 +++ b/arch/x86/mm/gup.c
27715 @@ -255,7 +255,7 @@ int __get_user_pages_fast(unsigned long start, int nr_pages, int write,
27716 addr = start;
27717 len = (unsigned long) nr_pages << PAGE_SHIFT;
27718 end = start + len;
27719 - if (unlikely(!access_ok(write ? VERIFY_WRITE : VERIFY_READ,
27720 + if (unlikely(!__access_ok(write ? VERIFY_WRITE : VERIFY_READ,
27721 (void __user *)start, len)))
27722 return 0;
27723
27724 diff --git a/arch/x86/mm/highmem_32.c b/arch/x86/mm/highmem_32.c
27725 index 6f31ee5..8ee4164 100644
27726 --- a/arch/x86/mm/highmem_32.c
27727 +++ b/arch/x86/mm/highmem_32.c
27728 @@ -44,7 +44,11 @@ void *kmap_atomic_prot(struct page *page, pgprot_t prot)
27729 idx = type + KM_TYPE_NR*smp_processor_id();
27730 vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx);
27731 BUG_ON(!pte_none(*(kmap_pte-idx)));
27732 +
27733 + pax_open_kernel();
27734 set_pte(kmap_pte-idx, mk_pte(page, prot));
27735 + pax_close_kernel();
27736 +
27737 arch_flush_lazy_mmu_mode();
27738
27739 return (void *)vaddr;
27740 diff --git a/arch/x86/mm/hugetlbpage.c b/arch/x86/mm/hugetlbpage.c
27741 index ae1aa71..56316db 100644
27742 --- a/arch/x86/mm/hugetlbpage.c
27743 +++ b/arch/x86/mm/hugetlbpage.c
27744 @@ -279,6 +279,12 @@ static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *file,
27745 info.flags = 0;
27746 info.length = len;
27747 info.low_limit = TASK_UNMAPPED_BASE;
27748 +
27749 +#ifdef CONFIG_PAX_RANDMMAP
27750 + if (current->mm->pax_flags & MF_PAX_RANDMMAP)
27751 + info.low_limit += current->mm->delta_mmap;
27752 +#endif
27753 +
27754 info.high_limit = TASK_SIZE;
27755 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
27756 info.align_offset = 0;
27757 @@ -311,6 +317,12 @@ static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
27758 VM_BUG_ON(addr != -ENOMEM);
27759 info.flags = 0;
27760 info.low_limit = TASK_UNMAPPED_BASE;
27761 +
27762 +#ifdef CONFIG_PAX_RANDMMAP
27763 + if (current->mm->pax_flags & MF_PAX_RANDMMAP)
27764 + info.low_limit += current->mm->delta_mmap;
27765 +#endif
27766 +
27767 info.high_limit = TASK_SIZE;
27768 addr = vm_unmapped_area(&info);
27769 }
27770 @@ -325,10 +337,20 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
27771 struct hstate *h = hstate_file(file);
27772 struct mm_struct *mm = current->mm;
27773 struct vm_area_struct *vma;
27774 + unsigned long pax_task_size = TASK_SIZE;
27775 + unsigned long offset = gr_rand_threadstack_offset(mm, file, flags);
27776
27777 if (len & ~huge_page_mask(h))
27778 return -EINVAL;
27779 - if (len > TASK_SIZE)
27780 +
27781 +#ifdef CONFIG_PAX_SEGMEXEC
27782 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
27783 + pax_task_size = SEGMEXEC_TASK_SIZE;
27784 +#endif
27785 +
27786 + pax_task_size -= PAGE_SIZE;
27787 +
27788 + if (len > pax_task_size)
27789 return -ENOMEM;
27790
27791 if (flags & MAP_FIXED) {
27792 @@ -337,11 +359,14 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
27793 return addr;
27794 }
27795
27796 +#ifdef CONFIG_PAX_RANDMMAP
27797 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
27798 +#endif
27799 +
27800 if (addr) {
27801 addr = ALIGN(addr, huge_page_size(h));
27802 vma = find_vma(mm, addr);
27803 - if (TASK_SIZE - len >= addr &&
27804 - (!vma || addr + len <= vma->vm_start))
27805 + if (pax_task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
27806 return addr;
27807 }
27808 if (mm->get_unmapped_area == arch_get_unmapped_area)
27809 diff --git a/arch/x86/mm/init.c b/arch/x86/mm/init.c
27810 index d7aea41..0fc945b 100644
27811 --- a/arch/x86/mm/init.c
27812 +++ b/arch/x86/mm/init.c
27813 @@ -4,6 +4,7 @@
27814 #include <linux/swap.h>
27815 #include <linux/memblock.h>
27816 #include <linux/bootmem.h> /* for max_low_pfn */
27817 +#include <linux/tboot.h>
27818
27819 #include <asm/cacheflush.h>
27820 #include <asm/e820.h>
27821 @@ -16,6 +17,8 @@
27822 #include <asm/tlb.h>
27823 #include <asm/proto.h>
27824 #include <asm/dma.h> /* for MAX_DMA_PFN */
27825 +#include <asm/desc.h>
27826 +#include <asm/bios_ebda.h>
27827
27828 unsigned long __initdata pgt_buf_start;
27829 unsigned long __meminitdata pgt_buf_end;
27830 @@ -44,7 +47,7 @@ static void __init find_early_table_space(struct map_range *mr, int nr_range)
27831 {
27832 int i;
27833 unsigned long puds = 0, pmds = 0, ptes = 0, tables;
27834 - unsigned long start = 0, good_end;
27835 + unsigned long start = 0x100000, good_end;
27836 phys_addr_t base;
27837
27838 for (i = 0; i < nr_range; i++) {
27839 @@ -321,10 +324,40 @@ unsigned long __init_refok init_memory_mapping(unsigned long start,
27840 * Access has to be given to non-kernel-ram areas as well, these contain the PCI
27841 * mmio resources as well as potential bios/acpi data regions.
27842 */
27843 +
27844 +#ifdef CONFIG_GRKERNSEC_KMEM
27845 +static unsigned int ebda_start __read_only;
27846 +static unsigned int ebda_end __read_only;
27847 +#endif
27848 +
27849 int devmem_is_allowed(unsigned long pagenr)
27850 {
27851 - if (pagenr < 256)
27852 +#ifdef CONFIG_GRKERNSEC_KMEM
27853 + /* allow BDA */
27854 + if (!pagenr)
27855 return 1;
27856 + /* allow EBDA */
27857 + if (pagenr >= ebda_start && pagenr < ebda_end)
27858 + return 1;
27859 + /* if tboot is in use, allow access to its hardcoded serial log range */
27860 + if (tboot_enabled() && ((0x60000 >> PAGE_SHIFT) <= pagenr) && (pagenr < (0x68000 >> PAGE_SHIFT)))
27861 + return 1;
27862 +#else
27863 + if (!pagenr)
27864 + return 1;
27865 +#ifdef CONFIG_VM86
27866 + if (pagenr < (ISA_START_ADDRESS >> PAGE_SHIFT))
27867 + return 1;
27868 +#endif
27869 +#endif
27870 +
27871 + if ((ISA_START_ADDRESS >> PAGE_SHIFT) <= pagenr && pagenr < (ISA_END_ADDRESS >> PAGE_SHIFT))
27872 + return 1;
27873 +#ifdef CONFIG_GRKERNSEC_KMEM
27874 + /* throw out everything else below 1MB */
27875 + if (pagenr <= 256)
27876 + return 0;
27877 +#endif
27878 if (iomem_is_exclusive(pagenr << PAGE_SHIFT))
27879 return 0;
27880 if (!page_is_ram(pagenr))
27881 @@ -381,8 +414,117 @@ void free_init_pages(char *what, unsigned long begin, unsigned long end)
27882 #endif
27883 }
27884
27885 +#ifdef CONFIG_GRKERNSEC_KMEM
27886 +static inline void gr_init_ebda(void)
27887 +{
27888 + unsigned int ebda_addr;
27889 + unsigned int ebda_size = 0;
27890 +
27891 + ebda_addr = get_bios_ebda();
27892 + if (ebda_addr) {
27893 + ebda_size = *(unsigned char *)phys_to_virt(ebda_addr);
27894 + ebda_size <<= 10;
27895 + }
27896 + if (ebda_addr && ebda_size) {
27897 + ebda_start = ebda_addr >> PAGE_SHIFT;
27898 + ebda_end = min((unsigned int)PAGE_ALIGN(ebda_addr + ebda_size), (unsigned int)0xa0000) >> PAGE_SHIFT;
27899 + } else {
27900 + ebda_start = 0x9f000 >> PAGE_SHIFT;
27901 + ebda_end = 0xa0000 >> PAGE_SHIFT;
27902 + }
27903 +}
27904 +#else
27905 +static inline void gr_init_ebda(void) { }
27906 +#endif
27907 +
27908 void free_initmem(void)
27909 {
27910 +#ifdef CONFIG_PAX_KERNEXEC
27911 +#ifdef CONFIG_X86_32
27912 + /* PaX: limit KERNEL_CS to actual size */
27913 + unsigned long addr, limit;
27914 + struct desc_struct d;
27915 + int cpu;
27916 +#else
27917 + pgd_t *pgd;
27918 + pud_t *pud;
27919 + pmd_t *pmd;
27920 + unsigned long addr, end;
27921 +#endif
27922 +#endif
27923 +
27924 + gr_init_ebda();
27925 +
27926 +#ifdef CONFIG_PAX_KERNEXEC
27927 +#ifdef CONFIG_X86_32
27928 + limit = paravirt_enabled() ? ktva_ktla(0xffffffff) : (unsigned long)&_etext;
27929 + limit = (limit - 1UL) >> PAGE_SHIFT;
27930 +
27931 + memset(__LOAD_PHYSICAL_ADDR + PAGE_OFFSET, POISON_FREE_INITMEM, PAGE_SIZE);
27932 + for (cpu = 0; cpu < nr_cpu_ids; cpu++) {
27933 + pack_descriptor(&d, get_desc_base(&get_cpu_gdt_table(cpu)[GDT_ENTRY_KERNEL_CS]), limit, 0x9B, 0xC);
27934 + write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_KERNEL_CS, &d, DESCTYPE_S);
27935 + write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_KERNEXEC_KERNEL_CS, &d, DESCTYPE_S);
27936 + }
27937 +
27938 + /* PaX: make KERNEL_CS read-only */
27939 + addr = PFN_ALIGN(ktla_ktva((unsigned long)&_text));
27940 + if (!paravirt_enabled())
27941 + set_memory_ro(addr, (PFN_ALIGN(_sdata) - addr) >> PAGE_SHIFT);
27942 +/*
27943 + for (addr = ktla_ktva((unsigned long)&_text); addr < (unsigned long)&_sdata; addr += PMD_SIZE) {
27944 + pgd = pgd_offset_k(addr);
27945 + pud = pud_offset(pgd, addr);
27946 + pmd = pmd_offset(pud, addr);
27947 + set_pmd(pmd, __pmd(pmd_val(*pmd) & ~_PAGE_RW));
27948 + }
27949 +*/
27950 +#ifdef CONFIG_X86_PAE
27951 + set_memory_nx(PFN_ALIGN(__init_begin), (PFN_ALIGN(__init_end) - PFN_ALIGN(__init_begin)) >> PAGE_SHIFT);
27952 +/*
27953 + for (addr = (unsigned long)&__init_begin; addr < (unsigned long)&__init_end; addr += PMD_SIZE) {
27954 + pgd = pgd_offset_k(addr);
27955 + pud = pud_offset(pgd, addr);
27956 + pmd = pmd_offset(pud, addr);
27957 + set_pmd(pmd, __pmd(pmd_val(*pmd) | (_PAGE_NX & __supported_pte_mask)));
27958 + }
27959 +*/
27960 +#endif
27961 +
27962 +#ifdef CONFIG_MODULES
27963 + set_memory_4k((unsigned long)MODULES_EXEC_VADDR, (MODULES_EXEC_END - MODULES_EXEC_VADDR) >> PAGE_SHIFT);
27964 +#endif
27965 +
27966 +#else
27967 + /* PaX: make kernel code/rodata read-only, rest non-executable */
27968 + for (addr = __START_KERNEL_map; addr < __START_KERNEL_map + KERNEL_IMAGE_SIZE; addr += PMD_SIZE) {
27969 + pgd = pgd_offset_k(addr);
27970 + pud = pud_offset(pgd, addr);
27971 + pmd = pmd_offset(pud, addr);
27972 + if (!pmd_present(*pmd))
27973 + continue;
27974 + if ((unsigned long)_text <= addr && addr < (unsigned long)_sdata)
27975 + set_pmd(pmd, __pmd(pmd_val(*pmd) & ~_PAGE_RW));
27976 + else
27977 + set_pmd(pmd, __pmd(pmd_val(*pmd) | (_PAGE_NX & __supported_pte_mask)));
27978 + }
27979 +
27980 + addr = (unsigned long)__va(__pa(__START_KERNEL_map));
27981 + end = addr + KERNEL_IMAGE_SIZE;
27982 + for (; addr < end; addr += PMD_SIZE) {
27983 + pgd = pgd_offset_k(addr);
27984 + pud = pud_offset(pgd, addr);
27985 + pmd = pmd_offset(pud, addr);
27986 + if (!pmd_present(*pmd))
27987 + continue;
27988 + if ((unsigned long)__va(__pa(_text)) <= addr && addr < (unsigned long)__va(__pa(_sdata)))
27989 + set_pmd(pmd, __pmd(pmd_val(*pmd) & ~_PAGE_RW));
27990 + }
27991 +#endif
27992 +
27993 + flush_tlb_all();
27994 +#endif
27995 +
27996 free_init_pages("unused kernel memory",
27997 (unsigned long)(&__init_begin),
27998 (unsigned long)(&__init_end));
27999 diff --git a/arch/x86/mm/init_32.c b/arch/x86/mm/init_32.c
28000 index 745d66b..56bf568 100644
28001 --- a/arch/x86/mm/init_32.c
28002 +++ b/arch/x86/mm/init_32.c
28003 @@ -73,36 +73,6 @@ static __init void *alloc_low_page(void)
28004 }
28005
28006 /*
28007 - * Creates a middle page table and puts a pointer to it in the
28008 - * given global directory entry. This only returns the gd entry
28009 - * in non-PAE compilation mode, since the middle layer is folded.
28010 - */
28011 -static pmd_t * __init one_md_table_init(pgd_t *pgd)
28012 -{
28013 - pud_t *pud;
28014 - pmd_t *pmd_table;
28015 -
28016 -#ifdef CONFIG_X86_PAE
28017 - if (!(pgd_val(*pgd) & _PAGE_PRESENT)) {
28018 - if (after_bootmem)
28019 - pmd_table = (pmd_t *)alloc_bootmem_pages(PAGE_SIZE);
28020 - else
28021 - pmd_table = (pmd_t *)alloc_low_page();
28022 - paravirt_alloc_pmd(&init_mm, __pa(pmd_table) >> PAGE_SHIFT);
28023 - set_pgd(pgd, __pgd(__pa(pmd_table) | _PAGE_PRESENT));
28024 - pud = pud_offset(pgd, 0);
28025 - BUG_ON(pmd_table != pmd_offset(pud, 0));
28026 -
28027 - return pmd_table;
28028 - }
28029 -#endif
28030 - pud = pud_offset(pgd, 0);
28031 - pmd_table = pmd_offset(pud, 0);
28032 -
28033 - return pmd_table;
28034 -}
28035 -
28036 -/*
28037 * Create a page table and place a pointer to it in a middle page
28038 * directory entry:
28039 */
28040 @@ -122,13 +92,28 @@ static pte_t * __init one_page_table_init(pmd_t *pmd)
28041 page_table = (pte_t *)alloc_low_page();
28042
28043 paravirt_alloc_pte(&init_mm, __pa(page_table) >> PAGE_SHIFT);
28044 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
28045 + set_pmd(pmd, __pmd(__pa(page_table) | _KERNPG_TABLE));
28046 +#else
28047 set_pmd(pmd, __pmd(__pa(page_table) | _PAGE_TABLE));
28048 +#endif
28049 BUG_ON(page_table != pte_offset_kernel(pmd, 0));
28050 }
28051
28052 return pte_offset_kernel(pmd, 0);
28053 }
28054
28055 +static pmd_t * __init one_md_table_init(pgd_t *pgd)
28056 +{
28057 + pud_t *pud;
28058 + pmd_t *pmd_table;
28059 +
28060 + pud = pud_offset(pgd, 0);
28061 + pmd_table = pmd_offset(pud, 0);
28062 +
28063 + return pmd_table;
28064 +}
28065 +
28066 pmd_t * __init populate_extra_pmd(unsigned long vaddr)
28067 {
28068 int pgd_idx = pgd_index(vaddr);
28069 @@ -202,6 +187,7 @@ page_table_range_init(unsigned long start, unsigned long end, pgd_t *pgd_base)
28070 int pgd_idx, pmd_idx;
28071 unsigned long vaddr;
28072 pgd_t *pgd;
28073 + pud_t *pud;
28074 pmd_t *pmd;
28075 pte_t *pte = NULL;
28076
28077 @@ -211,8 +197,13 @@ page_table_range_init(unsigned long start, unsigned long end, pgd_t *pgd_base)
28078 pgd = pgd_base + pgd_idx;
28079
28080 for ( ; (pgd_idx < PTRS_PER_PGD) && (vaddr != end); pgd++, pgd_idx++) {
28081 - pmd = one_md_table_init(pgd);
28082 - pmd = pmd + pmd_index(vaddr);
28083 + pud = pud_offset(pgd, vaddr);
28084 + pmd = pmd_offset(pud, vaddr);
28085 +
28086 +#ifdef CONFIG_X86_PAE
28087 + paravirt_alloc_pmd(&init_mm, __pa(pmd) >> PAGE_SHIFT);
28088 +#endif
28089 +
28090 for (; (pmd_idx < PTRS_PER_PMD) && (vaddr != end);
28091 pmd++, pmd_idx++) {
28092 pte = page_table_kmap_check(one_page_table_init(pmd),
28093 @@ -224,11 +215,20 @@ page_table_range_init(unsigned long start, unsigned long end, pgd_t *pgd_base)
28094 }
28095 }
28096
28097 -static inline int is_kernel_text(unsigned long addr)
28098 +static inline int is_kernel_text(unsigned long start, unsigned long end)
28099 {
28100 - if (addr >= (unsigned long)_text && addr <= (unsigned long)__init_end)
28101 - return 1;
28102 - return 0;
28103 + if ((start > ktla_ktva((unsigned long)_etext) ||
28104 + end <= ktla_ktva((unsigned long)_stext)) &&
28105 + (start > ktla_ktva((unsigned long)_einittext) ||
28106 + end <= ktla_ktva((unsigned long)_sinittext)) &&
28107 +
28108 +#ifdef CONFIG_ACPI_SLEEP
28109 + (start > (unsigned long)__va(acpi_wakeup_address) + 0x4000 || end <= (unsigned long)__va(acpi_wakeup_address)) &&
28110 +#endif
28111 +
28112 + (start > (unsigned long)__va(0xfffff) || end <= (unsigned long)__va(0xc0000)))
28113 + return 0;
28114 + return 1;
28115 }
28116
28117 /*
28118 @@ -245,9 +245,10 @@ kernel_physical_mapping_init(unsigned long start,
28119 unsigned long last_map_addr = end;
28120 unsigned long start_pfn, end_pfn;
28121 pgd_t *pgd_base = swapper_pg_dir;
28122 - int pgd_idx, pmd_idx, pte_ofs;
28123 + unsigned int pgd_idx, pmd_idx, pte_ofs;
28124 unsigned long pfn;
28125 pgd_t *pgd;
28126 + pud_t *pud;
28127 pmd_t *pmd;
28128 pte_t *pte;
28129 unsigned pages_2m, pages_4k;
28130 @@ -280,8 +281,13 @@ repeat:
28131 pfn = start_pfn;
28132 pgd_idx = pgd_index((pfn<<PAGE_SHIFT) + PAGE_OFFSET);
28133 pgd = pgd_base + pgd_idx;
28134 - for (; pgd_idx < PTRS_PER_PGD; pgd++, pgd_idx++) {
28135 - pmd = one_md_table_init(pgd);
28136 + for (; pgd_idx < PTRS_PER_PGD && pfn < max_low_pfn; pgd++, pgd_idx++) {
28137 + pud = pud_offset(pgd, 0);
28138 + pmd = pmd_offset(pud, 0);
28139 +
28140 +#ifdef CONFIG_X86_PAE
28141 + paravirt_alloc_pmd(&init_mm, __pa(pmd) >> PAGE_SHIFT);
28142 +#endif
28143
28144 if (pfn >= end_pfn)
28145 continue;
28146 @@ -293,14 +299,13 @@ repeat:
28147 #endif
28148 for (; pmd_idx < PTRS_PER_PMD && pfn < end_pfn;
28149 pmd++, pmd_idx++) {
28150 - unsigned int addr = pfn * PAGE_SIZE + PAGE_OFFSET;
28151 + unsigned long address = pfn * PAGE_SIZE + PAGE_OFFSET;
28152
28153 /*
28154 * Map with big pages if possible, otherwise
28155 * create normal page tables:
28156 */
28157 if (use_pse) {
28158 - unsigned int addr2;
28159 pgprot_t prot = PAGE_KERNEL_LARGE;
28160 /*
28161 * first pass will use the same initial
28162 @@ -310,11 +315,7 @@ repeat:
28163 __pgprot(PTE_IDENT_ATTR |
28164 _PAGE_PSE);
28165
28166 - addr2 = (pfn + PTRS_PER_PTE-1) * PAGE_SIZE +
28167 - PAGE_OFFSET + PAGE_SIZE-1;
28168 -
28169 - if (is_kernel_text(addr) ||
28170 - is_kernel_text(addr2))
28171 + if (is_kernel_text(address, address + PMD_SIZE))
28172 prot = PAGE_KERNEL_LARGE_EXEC;
28173
28174 pages_2m++;
28175 @@ -331,7 +332,7 @@ repeat:
28176 pte_ofs = pte_index((pfn<<PAGE_SHIFT) + PAGE_OFFSET);
28177 pte += pte_ofs;
28178 for (; pte_ofs < PTRS_PER_PTE && pfn < end_pfn;
28179 - pte++, pfn++, pte_ofs++, addr += PAGE_SIZE) {
28180 + pte++, pfn++, pte_ofs++, address += PAGE_SIZE) {
28181 pgprot_t prot = PAGE_KERNEL;
28182 /*
28183 * first pass will use the same initial
28184 @@ -339,7 +340,7 @@ repeat:
28185 */
28186 pgprot_t init_prot = __pgprot(PTE_IDENT_ATTR);
28187
28188 - if (is_kernel_text(addr))
28189 + if (is_kernel_text(address, address + PAGE_SIZE))
28190 prot = PAGE_KERNEL_EXEC;
28191
28192 pages_4k++;
28193 @@ -465,7 +466,7 @@ void __init native_pagetable_init(void)
28194
28195 pud = pud_offset(pgd, va);
28196 pmd = pmd_offset(pud, va);
28197 - if (!pmd_present(*pmd))
28198 + if (!pmd_present(*pmd) || pmd_huge(*pmd))
28199 break;
28200
28201 pte = pte_offset_kernel(pmd, va);
28202 @@ -514,12 +515,10 @@ void __init early_ioremap_page_table_range_init(void)
28203
28204 static void __init pagetable_init(void)
28205 {
28206 - pgd_t *pgd_base = swapper_pg_dir;
28207 -
28208 - permanent_kmaps_init(pgd_base);
28209 + permanent_kmaps_init(swapper_pg_dir);
28210 }
28211
28212 -pteval_t __supported_pte_mask __read_mostly = ~(_PAGE_NX | _PAGE_GLOBAL | _PAGE_IOMAP);
28213 +pteval_t __supported_pte_mask __read_only = ~(_PAGE_NX | _PAGE_GLOBAL | _PAGE_IOMAP);
28214 EXPORT_SYMBOL_GPL(__supported_pte_mask);
28215
28216 /* user-defined highmem size */
28217 @@ -728,6 +727,12 @@ void __init mem_init(void)
28218
28219 pci_iommu_alloc();
28220
28221 +#ifdef CONFIG_PAX_PER_CPU_PGD
28222 + clone_pgd_range(get_cpu_pgd(0) + KERNEL_PGD_BOUNDARY,
28223 + swapper_pg_dir + KERNEL_PGD_BOUNDARY,
28224 + KERNEL_PGD_PTRS);
28225 +#endif
28226 +
28227 #ifdef CONFIG_FLATMEM
28228 BUG_ON(!mem_map);
28229 #endif
28230 @@ -754,7 +759,7 @@ void __init mem_init(void)
28231 reservedpages++;
28232
28233 codesize = (unsigned long) &_etext - (unsigned long) &_text;
28234 - datasize = (unsigned long) &_edata - (unsigned long) &_etext;
28235 + datasize = (unsigned long) &_edata - (unsigned long) &_sdata;
28236 initsize = (unsigned long) &__init_end - (unsigned long) &__init_begin;
28237
28238 printk(KERN_INFO "Memory: %luk/%luk available (%dk kernel code, "
28239 @@ -795,10 +800,10 @@ void __init mem_init(void)
28240 ((unsigned long)&__init_end -
28241 (unsigned long)&__init_begin) >> 10,
28242
28243 - (unsigned long)&_etext, (unsigned long)&_edata,
28244 - ((unsigned long)&_edata - (unsigned long)&_etext) >> 10,
28245 + (unsigned long)&_sdata, (unsigned long)&_edata,
28246 + ((unsigned long)&_edata - (unsigned long)&_sdata) >> 10,
28247
28248 - (unsigned long)&_text, (unsigned long)&_etext,
28249 + ktla_ktva((unsigned long)&_text), ktla_ktva((unsigned long)&_etext),
28250 ((unsigned long)&_etext - (unsigned long)&_text) >> 10);
28251
28252 /*
28253 @@ -876,6 +881,7 @@ void set_kernel_text_rw(void)
28254 if (!kernel_set_to_readonly)
28255 return;
28256
28257 + start = ktla_ktva(start);
28258 pr_debug("Set kernel text: %lx - %lx for read write\n",
28259 start, start+size);
28260
28261 @@ -890,6 +896,7 @@ void set_kernel_text_ro(void)
28262 if (!kernel_set_to_readonly)
28263 return;
28264
28265 + start = ktla_ktva(start);
28266 pr_debug("Set kernel text: %lx - %lx for read only\n",
28267 start, start+size);
28268
28269 @@ -918,6 +925,7 @@ void mark_rodata_ro(void)
28270 unsigned long start = PFN_ALIGN(_text);
28271 unsigned long size = PFN_ALIGN(_etext) - start;
28272
28273 + start = ktla_ktva(start);
28274 set_pages_ro(virt_to_page(start), size >> PAGE_SHIFT);
28275 printk(KERN_INFO "Write protecting the kernel text: %luk\n",
28276 size >> 10);
28277 diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
28278 index 75c9a6a..498d677 100644
28279 --- a/arch/x86/mm/init_64.c
28280 +++ b/arch/x86/mm/init_64.c
28281 @@ -74,7 +74,7 @@ early_param("gbpages", parse_direct_gbpages_on);
28282 * around without checking the pgd every time.
28283 */
28284
28285 -pteval_t __supported_pte_mask __read_mostly = ~_PAGE_IOMAP;
28286 +pteval_t __supported_pte_mask __read_only = ~(_PAGE_NX | _PAGE_IOMAP);
28287 EXPORT_SYMBOL_GPL(__supported_pte_mask);
28288
28289 int force_personality32;
28290 @@ -107,12 +107,22 @@ void sync_global_pgds(unsigned long start, unsigned long end)
28291
28292 for (address = start; address <= end; address += PGDIR_SIZE) {
28293 const pgd_t *pgd_ref = pgd_offset_k(address);
28294 +
28295 +#ifdef CONFIG_PAX_PER_CPU_PGD
28296 + unsigned long cpu;
28297 +#else
28298 struct page *page;
28299 +#endif
28300
28301 if (pgd_none(*pgd_ref))
28302 continue;
28303
28304 spin_lock(&pgd_lock);
28305 +
28306 +#ifdef CONFIG_PAX_PER_CPU_PGD
28307 + for (cpu = 0; cpu < nr_cpu_ids; ++cpu) {
28308 + pgd_t *pgd = pgd_offset_cpu(cpu, address);
28309 +#else
28310 list_for_each_entry(page, &pgd_list, lru) {
28311 pgd_t *pgd;
28312 spinlock_t *pgt_lock;
28313 @@ -121,6 +131,7 @@ void sync_global_pgds(unsigned long start, unsigned long end)
28314 /* the pgt_lock only for Xen */
28315 pgt_lock = &pgd_page_get_mm(page)->page_table_lock;
28316 spin_lock(pgt_lock);
28317 +#endif
28318
28319 if (pgd_none(*pgd))
28320 set_pgd(pgd, *pgd_ref);
28321 @@ -128,7 +139,10 @@ void sync_global_pgds(unsigned long start, unsigned long end)
28322 BUG_ON(pgd_page_vaddr(*pgd)
28323 != pgd_page_vaddr(*pgd_ref));
28324
28325 +#ifndef CONFIG_PAX_PER_CPU_PGD
28326 spin_unlock(pgt_lock);
28327 +#endif
28328 +
28329 }
28330 spin_unlock(&pgd_lock);
28331 }
28332 @@ -161,7 +175,7 @@ static pud_t *fill_pud(pgd_t *pgd, unsigned long vaddr)
28333 {
28334 if (pgd_none(*pgd)) {
28335 pud_t *pud = (pud_t *)spp_getpage();
28336 - pgd_populate(&init_mm, pgd, pud);
28337 + pgd_populate_kernel(&init_mm, pgd, pud);
28338 if (pud != pud_offset(pgd, 0))
28339 printk(KERN_ERR "PAGETABLE BUG #00! %p <-> %p\n",
28340 pud, pud_offset(pgd, 0));
28341 @@ -173,7 +187,7 @@ static pmd_t *fill_pmd(pud_t *pud, unsigned long vaddr)
28342 {
28343 if (pud_none(*pud)) {
28344 pmd_t *pmd = (pmd_t *) spp_getpage();
28345 - pud_populate(&init_mm, pud, pmd);
28346 + pud_populate_kernel(&init_mm, pud, pmd);
28347 if (pmd != pmd_offset(pud, 0))
28348 printk(KERN_ERR "PAGETABLE BUG #01! %p <-> %p\n",
28349 pmd, pmd_offset(pud, 0));
28350 @@ -202,7 +216,9 @@ void set_pte_vaddr_pud(pud_t *pud_page, unsigned long vaddr, pte_t new_pte)
28351 pmd = fill_pmd(pud, vaddr);
28352 pte = fill_pte(pmd, vaddr);
28353
28354 + pax_open_kernel();
28355 set_pte(pte, new_pte);
28356 + pax_close_kernel();
28357
28358 /*
28359 * It's enough to flush this one mapping.
28360 @@ -261,14 +277,12 @@ static void __init __init_extra_mapping(unsigned long phys, unsigned long size,
28361 pgd = pgd_offset_k((unsigned long)__va(phys));
28362 if (pgd_none(*pgd)) {
28363 pud = (pud_t *) spp_getpage();
28364 - set_pgd(pgd, __pgd(__pa(pud) | _KERNPG_TABLE |
28365 - _PAGE_USER));
28366 + set_pgd(pgd, __pgd(__pa(pud) | _PAGE_TABLE));
28367 }
28368 pud = pud_offset(pgd, (unsigned long)__va(phys));
28369 if (pud_none(*pud)) {
28370 pmd = (pmd_t *) spp_getpage();
28371 - set_pud(pud, __pud(__pa(pmd) | _KERNPG_TABLE |
28372 - _PAGE_USER));
28373 + set_pud(pud, __pud(__pa(pmd) | _PAGE_TABLE));
28374 }
28375 pmd = pmd_offset(pud, phys);
28376 BUG_ON(!pmd_none(*pmd));
28377 @@ -329,7 +343,7 @@ static __ref void *alloc_low_page(unsigned long *phys)
28378 if (pfn >= pgt_buf_top)
28379 panic("alloc_low_page: ran out of memory");
28380
28381 - adr = early_memremap(pfn * PAGE_SIZE, PAGE_SIZE);
28382 + adr = (void __force_kernel *)early_memremap(pfn * PAGE_SIZE, PAGE_SIZE);
28383 clear_page(adr);
28384 *phys = pfn * PAGE_SIZE;
28385 return adr;
28386 @@ -345,7 +359,7 @@ static __ref void *map_low_page(void *virt)
28387
28388 phys = __pa(virt);
28389 left = phys & (PAGE_SIZE - 1);
28390 - adr = early_memremap(phys & PAGE_MASK, PAGE_SIZE);
28391 + adr = (void __force_kernel *)early_memremap(phys & PAGE_MASK, PAGE_SIZE);
28392 adr = (void *)(((unsigned long)adr) | left);
28393
28394 return adr;
28395 @@ -553,7 +567,7 @@ phys_pud_init(pud_t *pud_page, unsigned long addr, unsigned long end,
28396 unmap_low_page(pmd);
28397
28398 spin_lock(&init_mm.page_table_lock);
28399 - pud_populate(&init_mm, pud, __va(pmd_phys));
28400 + pud_populate_kernel(&init_mm, pud, __va(pmd_phys));
28401 spin_unlock(&init_mm.page_table_lock);
28402 }
28403 __flush_tlb_all();
28404 @@ -599,7 +613,7 @@ kernel_physical_mapping_init(unsigned long start,
28405 unmap_low_page(pud);
28406
28407 spin_lock(&init_mm.page_table_lock);
28408 - pgd_populate(&init_mm, pgd, __va(pud_phys));
28409 + pgd_populate_kernel(&init_mm, pgd, __va(pud_phys));
28410 spin_unlock(&init_mm.page_table_lock);
28411 pgd_changed = true;
28412 }
28413 @@ -693,6 +707,12 @@ void __init mem_init(void)
28414
28415 pci_iommu_alloc();
28416
28417 +#ifdef CONFIG_PAX_PER_CPU_PGD
28418 + clone_pgd_range(get_cpu_pgd(0) + KERNEL_PGD_BOUNDARY,
28419 + swapper_pg_dir + KERNEL_PGD_BOUNDARY,
28420 + KERNEL_PGD_PTRS);
28421 +#endif
28422 +
28423 /* clear_bss() already clear the empty_zero_page */
28424
28425 reservedpages = 0;
28426 @@ -856,8 +876,8 @@ int kern_addr_valid(unsigned long addr)
28427 static struct vm_area_struct gate_vma = {
28428 .vm_start = VSYSCALL_START,
28429 .vm_end = VSYSCALL_START + (VSYSCALL_MAPPED_PAGES * PAGE_SIZE),
28430 - .vm_page_prot = PAGE_READONLY_EXEC,
28431 - .vm_flags = VM_READ | VM_EXEC
28432 + .vm_page_prot = PAGE_READONLY,
28433 + .vm_flags = VM_READ
28434 };
28435
28436 struct vm_area_struct *get_gate_vma(struct mm_struct *mm)
28437 @@ -891,7 +911,7 @@ int in_gate_area_no_mm(unsigned long addr)
28438
28439 const char *arch_vma_name(struct vm_area_struct *vma)
28440 {
28441 - if (vma->vm_mm && vma->vm_start == (long)vma->vm_mm->context.vdso)
28442 + if (vma->vm_mm && vma->vm_start == vma->vm_mm->context.vdso)
28443 return "[vdso]";
28444 if (vma == &gate_vma)
28445 return "[vsyscall]";
28446 diff --git a/arch/x86/mm/iomap_32.c b/arch/x86/mm/iomap_32.c
28447 index 7b179b4..6bd1777 100644
28448 --- a/arch/x86/mm/iomap_32.c
28449 +++ b/arch/x86/mm/iomap_32.c
28450 @@ -64,7 +64,11 @@ void *kmap_atomic_prot_pfn(unsigned long pfn, pgprot_t prot)
28451 type = kmap_atomic_idx_push();
28452 idx = type + KM_TYPE_NR * smp_processor_id();
28453 vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx);
28454 +
28455 + pax_open_kernel();
28456 set_pte(kmap_pte - idx, pfn_pte(pfn, prot));
28457 + pax_close_kernel();
28458 +
28459 arch_flush_lazy_mmu_mode();
28460
28461 return (void *)vaddr;
28462 diff --git a/arch/x86/mm/ioremap.c b/arch/x86/mm/ioremap.c
28463 index 78fe3f1..2f9433c 100644
28464 --- a/arch/x86/mm/ioremap.c
28465 +++ b/arch/x86/mm/ioremap.c
28466 @@ -97,7 +97,7 @@ static void __iomem *__ioremap_caller(resource_size_t phys_addr,
28467 for (pfn = phys_addr >> PAGE_SHIFT; pfn <= last_pfn; pfn++) {
28468 int is_ram = page_is_ram(pfn);
28469
28470 - if (is_ram && pfn_valid(pfn) && !PageReserved(pfn_to_page(pfn)))
28471 + if (is_ram && pfn_valid(pfn) && (pfn >= 0x100 || !PageReserved(pfn_to_page(pfn))))
28472 return NULL;
28473 WARN_ON_ONCE(is_ram);
28474 }
28475 @@ -256,7 +256,7 @@ EXPORT_SYMBOL(ioremap_prot);
28476 *
28477 * Caller must ensure there is only one unmapping for the same pointer.
28478 */
28479 -void iounmap(volatile void __iomem *addr)
28480 +void iounmap(const volatile void __iomem *addr)
28481 {
28482 struct vm_struct *p, *o;
28483
28484 @@ -315,6 +315,9 @@ void *xlate_dev_mem_ptr(unsigned long phys)
28485
28486 /* If page is RAM, we can use __va. Otherwise ioremap and unmap. */
28487 if (page_is_ram(start >> PAGE_SHIFT))
28488 +#ifdef CONFIG_HIGHMEM
28489 + if ((start >> PAGE_SHIFT) < max_low_pfn)
28490 +#endif
28491 return __va(phys);
28492
28493 addr = (void __force *)ioremap_cache(start, PAGE_SIZE);
28494 @@ -344,7 +347,7 @@ static int __init early_ioremap_debug_setup(char *str)
28495 early_param("early_ioremap_debug", early_ioremap_debug_setup);
28496
28497 static __initdata int after_paging_init;
28498 -static pte_t bm_pte[PAGE_SIZE/sizeof(pte_t)] __page_aligned_bss;
28499 +static pte_t bm_pte[PAGE_SIZE/sizeof(pte_t)] __read_only __aligned(PAGE_SIZE);
28500
28501 static inline pmd_t * __init early_ioremap_pmd(unsigned long addr)
28502 {
28503 @@ -381,8 +384,7 @@ void __init early_ioremap_init(void)
28504 slot_virt[i] = __fix_to_virt(FIX_BTMAP_BEGIN - NR_FIX_BTMAPS*i);
28505
28506 pmd = early_ioremap_pmd(fix_to_virt(FIX_BTMAP_BEGIN));
28507 - memset(bm_pte, 0, sizeof(bm_pte));
28508 - pmd_populate_kernel(&init_mm, pmd, bm_pte);
28509 + pmd_populate_user(&init_mm, pmd, bm_pte);
28510
28511 /*
28512 * The boot-ioremap range spans multiple pmds, for which
28513 diff --git a/arch/x86/mm/kmemcheck/kmemcheck.c b/arch/x86/mm/kmemcheck/kmemcheck.c
28514 index d87dd6d..bf3fa66 100644
28515 --- a/arch/x86/mm/kmemcheck/kmemcheck.c
28516 +++ b/arch/x86/mm/kmemcheck/kmemcheck.c
28517 @@ -622,9 +622,9 @@ bool kmemcheck_fault(struct pt_regs *regs, unsigned long address,
28518 * memory (e.g. tracked pages)? For now, we need this to avoid
28519 * invoking kmemcheck for PnP BIOS calls.
28520 */
28521 - if (regs->flags & X86_VM_MASK)
28522 + if (v8086_mode(regs))
28523 return false;
28524 - if (regs->cs != __KERNEL_CS)
28525 + if (regs->cs != __KERNEL_CS && regs->cs != __KERNEXEC_KERNEL_CS)
28526 return false;
28527
28528 pte = kmemcheck_pte_lookup(address);
28529 diff --git a/arch/x86/mm/mmap.c b/arch/x86/mm/mmap.c
28530 index 845df68..1d8d29f 100644
28531 --- a/arch/x86/mm/mmap.c
28532 +++ b/arch/x86/mm/mmap.c
28533 @@ -52,7 +52,7 @@ static unsigned int stack_maxrandom_size(void)
28534 * Leave an at least ~128 MB hole with possible stack randomization.
28535 */
28536 #define MIN_GAP (128*1024*1024UL + stack_maxrandom_size())
28537 -#define MAX_GAP (TASK_SIZE/6*5)
28538 +#define MAX_GAP (pax_task_size/6*5)
28539
28540 static int mmap_is_legacy(void)
28541 {
28542 @@ -82,27 +82,40 @@ static unsigned long mmap_rnd(void)
28543 return rnd << PAGE_SHIFT;
28544 }
28545
28546 -static unsigned long mmap_base(void)
28547 +static unsigned long mmap_base(struct mm_struct *mm)
28548 {
28549 unsigned long gap = rlimit(RLIMIT_STACK);
28550 + unsigned long pax_task_size = TASK_SIZE;
28551 +
28552 +#ifdef CONFIG_PAX_SEGMEXEC
28553 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
28554 + pax_task_size = SEGMEXEC_TASK_SIZE;
28555 +#endif
28556
28557 if (gap < MIN_GAP)
28558 gap = MIN_GAP;
28559 else if (gap > MAX_GAP)
28560 gap = MAX_GAP;
28561
28562 - return PAGE_ALIGN(TASK_SIZE - gap - mmap_rnd());
28563 + return PAGE_ALIGN(pax_task_size - gap - mmap_rnd());
28564 }
28565
28566 /*
28567 * Bottom-up (legacy) layout on X86_32 did not support randomization, X86_64
28568 * does, but not when emulating X86_32
28569 */
28570 -static unsigned long mmap_legacy_base(void)
28571 +static unsigned long mmap_legacy_base(struct mm_struct *mm)
28572 {
28573 - if (mmap_is_ia32())
28574 + if (mmap_is_ia32()) {
28575 +
28576 +#ifdef CONFIG_PAX_SEGMEXEC
28577 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
28578 + return SEGMEXEC_TASK_UNMAPPED_BASE;
28579 + else
28580 +#endif
28581 +
28582 return TASK_UNMAPPED_BASE;
28583 - else
28584 + } else
28585 return TASK_UNMAPPED_BASE + mmap_rnd();
28586 }
28587
28588 @@ -113,11 +126,23 @@ static unsigned long mmap_legacy_base(void)
28589 void arch_pick_mmap_layout(struct mm_struct *mm)
28590 {
28591 if (mmap_is_legacy()) {
28592 - mm->mmap_base = mmap_legacy_base();
28593 + mm->mmap_base = mmap_legacy_base(mm);
28594 +
28595 +#ifdef CONFIG_PAX_RANDMMAP
28596 + if (mm->pax_flags & MF_PAX_RANDMMAP)
28597 + mm->mmap_base += mm->delta_mmap;
28598 +#endif
28599 +
28600 mm->get_unmapped_area = arch_get_unmapped_area;
28601 mm->unmap_area = arch_unmap_area;
28602 } else {
28603 - mm->mmap_base = mmap_base();
28604 + mm->mmap_base = mmap_base(mm);
28605 +
28606 +#ifdef CONFIG_PAX_RANDMMAP
28607 + if (mm->pax_flags & MF_PAX_RANDMMAP)
28608 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
28609 +#endif
28610 +
28611 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
28612 mm->unmap_area = arch_unmap_area_topdown;
28613 }
28614 diff --git a/arch/x86/mm/mmio-mod.c b/arch/x86/mm/mmio-mod.c
28615 index dc0b727..f612039 100644
28616 --- a/arch/x86/mm/mmio-mod.c
28617 +++ b/arch/x86/mm/mmio-mod.c
28618 @@ -194,7 +194,7 @@ static void pre(struct kmmio_probe *p, struct pt_regs *regs,
28619 break;
28620 default:
28621 {
28622 - unsigned char *ip = (unsigned char *)instptr;
28623 + unsigned char *ip = (unsigned char *)ktla_ktva(instptr);
28624 my_trace->opcode = MMIO_UNKNOWN_OP;
28625 my_trace->width = 0;
28626 my_trace->value = (*ip) << 16 | *(ip + 1) << 8 |
28627 @@ -234,7 +234,7 @@ static void post(struct kmmio_probe *p, unsigned long condition,
28628 static void ioremap_trace_core(resource_size_t offset, unsigned long size,
28629 void __iomem *addr)
28630 {
28631 - static atomic_t next_id;
28632 + static atomic_unchecked_t next_id;
28633 struct remap_trace *trace = kmalloc(sizeof(*trace), GFP_KERNEL);
28634 /* These are page-unaligned. */
28635 struct mmiotrace_map map = {
28636 @@ -258,7 +258,7 @@ static void ioremap_trace_core(resource_size_t offset, unsigned long size,
28637 .private = trace
28638 },
28639 .phys = offset,
28640 - .id = atomic_inc_return(&next_id)
28641 + .id = atomic_inc_return_unchecked(&next_id)
28642 };
28643 map.map_id = trace->id;
28644
28645 @@ -290,7 +290,7 @@ void mmiotrace_ioremap(resource_size_t offset, unsigned long size,
28646 ioremap_trace_core(offset, size, addr);
28647 }
28648
28649 -static void iounmap_trace_core(volatile void __iomem *addr)
28650 +static void iounmap_trace_core(const volatile void __iomem *addr)
28651 {
28652 struct mmiotrace_map map = {
28653 .phys = 0,
28654 @@ -328,7 +328,7 @@ not_enabled:
28655 }
28656 }
28657
28658 -void mmiotrace_iounmap(volatile void __iomem *addr)
28659 +void mmiotrace_iounmap(const volatile void __iomem *addr)
28660 {
28661 might_sleep();
28662 if (is_enabled()) /* recheck and proper locking in *_core() */
28663 diff --git a/arch/x86/mm/numa.c b/arch/x86/mm/numa.c
28664 index 8504f36..5fc68f2 100644
28665 --- a/arch/x86/mm/numa.c
28666 +++ b/arch/x86/mm/numa.c
28667 @@ -478,7 +478,7 @@ static bool __init numa_meminfo_cover_memory(const struct numa_meminfo *mi)
28668 return true;
28669 }
28670
28671 -static int __init numa_register_memblks(struct numa_meminfo *mi)
28672 +static int __init __intentional_overflow(-1) numa_register_memblks(struct numa_meminfo *mi)
28673 {
28674 unsigned long uninitialized_var(pfn_align);
28675 int i, nid;
28676 diff --git a/arch/x86/mm/pageattr-test.c b/arch/x86/mm/pageattr-test.c
28677 index b008656..773eac2 100644
28678 --- a/arch/x86/mm/pageattr-test.c
28679 +++ b/arch/x86/mm/pageattr-test.c
28680 @@ -36,7 +36,7 @@ enum {
28681
28682 static int pte_testbit(pte_t pte)
28683 {
28684 - return pte_flags(pte) & _PAGE_UNUSED1;
28685 + return pte_flags(pte) & _PAGE_CPA_TEST;
28686 }
28687
28688 struct split_state {
28689 diff --git a/arch/x86/mm/pageattr.c b/arch/x86/mm/pageattr.c
28690 index a718e0d..77419bc 100644
28691 --- a/arch/x86/mm/pageattr.c
28692 +++ b/arch/x86/mm/pageattr.c
28693 @@ -261,7 +261,7 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
28694 */
28695 #ifdef CONFIG_PCI_BIOS
28696 if (pcibios_enabled && within(pfn, BIOS_BEGIN >> PAGE_SHIFT, BIOS_END >> PAGE_SHIFT))
28697 - pgprot_val(forbidden) |= _PAGE_NX;
28698 + pgprot_val(forbidden) |= _PAGE_NX & __supported_pte_mask;
28699 #endif
28700
28701 /*
28702 @@ -269,9 +269,10 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
28703 * Does not cover __inittext since that is gone later on. On
28704 * 64bit we do not enforce !NX on the low mapping
28705 */
28706 - if (within(address, (unsigned long)_text, (unsigned long)_etext))
28707 - pgprot_val(forbidden) |= _PAGE_NX;
28708 + if (within(address, ktla_ktva((unsigned long)_text), ktla_ktva((unsigned long)_etext)))
28709 + pgprot_val(forbidden) |= _PAGE_NX & __supported_pte_mask;
28710
28711 +#ifdef CONFIG_DEBUG_RODATA
28712 /*
28713 * The .rodata section needs to be read-only. Using the pfn
28714 * catches all aliases.
28715 @@ -279,6 +280,7 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
28716 if (within(pfn, __pa((unsigned long)__start_rodata) >> PAGE_SHIFT,
28717 __pa((unsigned long)__end_rodata) >> PAGE_SHIFT))
28718 pgprot_val(forbidden) |= _PAGE_RW;
28719 +#endif
28720
28721 #if defined(CONFIG_X86_64) && defined(CONFIG_DEBUG_RODATA)
28722 /*
28723 @@ -317,6 +319,13 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
28724 }
28725 #endif
28726
28727 +#ifdef CONFIG_PAX_KERNEXEC
28728 + if (within(pfn, __pa(ktla_ktva((unsigned long)&_text)), __pa((unsigned long)&_sdata))) {
28729 + pgprot_val(forbidden) |= _PAGE_RW;
28730 + pgprot_val(forbidden) |= _PAGE_NX & __supported_pte_mask;
28731 + }
28732 +#endif
28733 +
28734 prot = __pgprot(pgprot_val(prot) & ~pgprot_val(forbidden));
28735
28736 return prot;
28737 @@ -369,23 +378,37 @@ EXPORT_SYMBOL_GPL(lookup_address);
28738 static void __set_pmd_pte(pte_t *kpte, unsigned long address, pte_t pte)
28739 {
28740 /* change init_mm */
28741 + pax_open_kernel();
28742 set_pte_atomic(kpte, pte);
28743 +
28744 #ifdef CONFIG_X86_32
28745 if (!SHARED_KERNEL_PMD) {
28746 +
28747 +#ifdef CONFIG_PAX_PER_CPU_PGD
28748 + unsigned long cpu;
28749 +#else
28750 struct page *page;
28751 +#endif
28752
28753 +#ifdef CONFIG_PAX_PER_CPU_PGD
28754 + for (cpu = 0; cpu < nr_cpu_ids; ++cpu) {
28755 + pgd_t *pgd = get_cpu_pgd(cpu);
28756 +#else
28757 list_for_each_entry(page, &pgd_list, lru) {
28758 - pgd_t *pgd;
28759 + pgd_t *pgd = (pgd_t *)page_address(page);
28760 +#endif
28761 +
28762 pud_t *pud;
28763 pmd_t *pmd;
28764
28765 - pgd = (pgd_t *)page_address(page) + pgd_index(address);
28766 + pgd += pgd_index(address);
28767 pud = pud_offset(pgd, address);
28768 pmd = pmd_offset(pud, address);
28769 set_pte_atomic((pte_t *)pmd, pte);
28770 }
28771 }
28772 #endif
28773 + pax_close_kernel();
28774 }
28775
28776 static int
28777 diff --git a/arch/x86/mm/pat.c b/arch/x86/mm/pat.c
28778 index 0eb572e..92f5c1e 100644
28779 --- a/arch/x86/mm/pat.c
28780 +++ b/arch/x86/mm/pat.c
28781 @@ -376,7 +376,7 @@ int free_memtype(u64 start, u64 end)
28782
28783 if (!entry) {
28784 printk(KERN_INFO "%s:%d freeing invalid memtype [mem %#010Lx-%#010Lx]\n",
28785 - current->comm, current->pid, start, end - 1);
28786 + current->comm, task_pid_nr(current), start, end - 1);
28787 return -EINVAL;
28788 }
28789
28790 @@ -506,8 +506,8 @@ static inline int range_is_allowed(unsigned long pfn, unsigned long size)
28791
28792 while (cursor < to) {
28793 if (!devmem_is_allowed(pfn)) {
28794 - printk(KERN_INFO "Program %s tried to access /dev/mem between [mem %#010Lx-%#010Lx]\n",
28795 - current->comm, from, to - 1);
28796 + printk(KERN_INFO "Program %s tried to access /dev/mem between [mem %#010Lx-%#010Lx] (%#010Lx)\n",
28797 + current->comm, from, to - 1, cursor);
28798 return 0;
28799 }
28800 cursor += PAGE_SIZE;
28801 @@ -570,7 +570,7 @@ int kernel_map_sync_memtype(u64 base, unsigned long size, unsigned long flags)
28802 if (ioremap_change_attr((unsigned long)__va(base), id_sz, flags) < 0) {
28803 printk(KERN_INFO "%s:%d ioremap_change_attr failed %s "
28804 "for [mem %#010Lx-%#010Lx]\n",
28805 - current->comm, current->pid,
28806 + current->comm, task_pid_nr(current),
28807 cattr_name(flags),
28808 base, (unsigned long long)(base + size-1));
28809 return -EINVAL;
28810 @@ -605,7 +605,7 @@ static int reserve_pfn_range(u64 paddr, unsigned long size, pgprot_t *vma_prot,
28811 flags = lookup_memtype(paddr);
28812 if (want_flags != flags) {
28813 printk(KERN_WARNING "%s:%d map pfn RAM range req %s for [mem %#010Lx-%#010Lx], got %s\n",
28814 - current->comm, current->pid,
28815 + current->comm, task_pid_nr(current),
28816 cattr_name(want_flags),
28817 (unsigned long long)paddr,
28818 (unsigned long long)(paddr + size - 1),
28819 @@ -627,7 +627,7 @@ static int reserve_pfn_range(u64 paddr, unsigned long size, pgprot_t *vma_prot,
28820 free_memtype(paddr, paddr + size);
28821 printk(KERN_ERR "%s:%d map pfn expected mapping type %s"
28822 " for [mem %#010Lx-%#010Lx], got %s\n",
28823 - current->comm, current->pid,
28824 + current->comm, task_pid_nr(current),
28825 cattr_name(want_flags),
28826 (unsigned long long)paddr,
28827 (unsigned long long)(paddr + size - 1),
28828 diff --git a/arch/x86/mm/pf_in.c b/arch/x86/mm/pf_in.c
28829 index 9f0614d..92ae64a 100644
28830 --- a/arch/x86/mm/pf_in.c
28831 +++ b/arch/x86/mm/pf_in.c
28832 @@ -148,7 +148,7 @@ enum reason_type get_ins_type(unsigned long ins_addr)
28833 int i;
28834 enum reason_type rv = OTHERS;
28835
28836 - p = (unsigned char *)ins_addr;
28837 + p = (unsigned char *)ktla_ktva(ins_addr);
28838 p += skip_prefix(p, &prf);
28839 p += get_opcode(p, &opcode);
28840
28841 @@ -168,7 +168,7 @@ static unsigned int get_ins_reg_width(unsigned long ins_addr)
28842 struct prefix_bits prf;
28843 int i;
28844
28845 - p = (unsigned char *)ins_addr;
28846 + p = (unsigned char *)ktla_ktva(ins_addr);
28847 p += skip_prefix(p, &prf);
28848 p += get_opcode(p, &opcode);
28849
28850 @@ -191,7 +191,7 @@ unsigned int get_ins_mem_width(unsigned long ins_addr)
28851 struct prefix_bits prf;
28852 int i;
28853
28854 - p = (unsigned char *)ins_addr;
28855 + p = (unsigned char *)ktla_ktva(ins_addr);
28856 p += skip_prefix(p, &prf);
28857 p += get_opcode(p, &opcode);
28858
28859 @@ -415,7 +415,7 @@ unsigned long get_ins_reg_val(unsigned long ins_addr, struct pt_regs *regs)
28860 struct prefix_bits prf;
28861 int i;
28862
28863 - p = (unsigned char *)ins_addr;
28864 + p = (unsigned char *)ktla_ktva(ins_addr);
28865 p += skip_prefix(p, &prf);
28866 p += get_opcode(p, &opcode);
28867 for (i = 0; i < ARRAY_SIZE(reg_rop); i++)
28868 @@ -470,7 +470,7 @@ unsigned long get_ins_imm_val(unsigned long ins_addr)
28869 struct prefix_bits prf;
28870 int i;
28871
28872 - p = (unsigned char *)ins_addr;
28873 + p = (unsigned char *)ktla_ktva(ins_addr);
28874 p += skip_prefix(p, &prf);
28875 p += get_opcode(p, &opcode);
28876 for (i = 0; i < ARRAY_SIZE(imm_wop); i++)
28877 diff --git a/arch/x86/mm/pgtable.c b/arch/x86/mm/pgtable.c
28878 index e27fbf8..8b56dc9 100644
28879 --- a/arch/x86/mm/pgtable.c
28880 +++ b/arch/x86/mm/pgtable.c
28881 @@ -84,10 +84,64 @@ static inline void pgd_list_del(pgd_t *pgd)
28882 list_del(&page->lru);
28883 }
28884
28885 -#define UNSHARED_PTRS_PER_PGD \
28886 - (SHARED_KERNEL_PMD ? KERNEL_PGD_BOUNDARY : PTRS_PER_PGD)
28887 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
28888 +pgdval_t clone_pgd_mask __read_only = ~_PAGE_PRESENT;
28889
28890 +void __shadow_user_pgds(pgd_t *dst, const pgd_t *src)
28891 +{
28892 + unsigned int count = USER_PGD_PTRS;
28893
28894 + while (count--)
28895 + *dst++ = __pgd((pgd_val(*src++) | (_PAGE_NX & __supported_pte_mask)) & ~_PAGE_USER);
28896 +}
28897 +#endif
28898 +
28899 +#ifdef CONFIG_PAX_PER_CPU_PGD
28900 +void __clone_user_pgds(pgd_t *dst, const pgd_t *src)
28901 +{
28902 + unsigned int count = USER_PGD_PTRS;
28903 +
28904 + while (count--) {
28905 + pgd_t pgd;
28906 +
28907 +#ifdef CONFIG_X86_64
28908 + pgd = __pgd(pgd_val(*src++) | _PAGE_USER);
28909 +#else
28910 + pgd = *src++;
28911 +#endif
28912 +
28913 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
28914 + pgd = __pgd(pgd_val(pgd) & clone_pgd_mask);
28915 +#endif
28916 +
28917 + *dst++ = pgd;
28918 + }
28919 +
28920 +}
28921 +#endif
28922 +
28923 +#ifdef CONFIG_X86_64
28924 +#define pxd_t pud_t
28925 +#define pyd_t pgd_t
28926 +#define paravirt_release_pxd(pfn) paravirt_release_pud(pfn)
28927 +#define pxd_free(mm, pud) pud_free((mm), (pud))
28928 +#define pyd_populate(mm, pgd, pud) pgd_populate((mm), (pgd), (pud))
28929 +#define pyd_offset(mm, address) pgd_offset((mm), (address))
28930 +#define PYD_SIZE PGDIR_SIZE
28931 +#else
28932 +#define pxd_t pmd_t
28933 +#define pyd_t pud_t
28934 +#define paravirt_release_pxd(pfn) paravirt_release_pmd(pfn)
28935 +#define pxd_free(mm, pud) pmd_free((mm), (pud))
28936 +#define pyd_populate(mm, pgd, pud) pud_populate((mm), (pgd), (pud))
28937 +#define pyd_offset(mm, address) pud_offset((mm), (address))
28938 +#define PYD_SIZE PUD_SIZE
28939 +#endif
28940 +
28941 +#ifdef CONFIG_PAX_PER_CPU_PGD
28942 +static inline void pgd_ctor(struct mm_struct *mm, pgd_t *pgd) {}
28943 +static inline void pgd_dtor(pgd_t *pgd) {}
28944 +#else
28945 static void pgd_set_mm(pgd_t *pgd, struct mm_struct *mm)
28946 {
28947 BUILD_BUG_ON(sizeof(virt_to_page(pgd)->index) < sizeof(mm));
28948 @@ -128,6 +182,7 @@ static void pgd_dtor(pgd_t *pgd)
28949 pgd_list_del(pgd);
28950 spin_unlock(&pgd_lock);
28951 }
28952 +#endif
28953
28954 /*
28955 * List of all pgd's needed for non-PAE so it can invalidate entries
28956 @@ -140,7 +195,7 @@ static void pgd_dtor(pgd_t *pgd)
28957 * -- nyc
28958 */
28959
28960 -#ifdef CONFIG_X86_PAE
28961 +#if defined(CONFIG_X86_32) && defined(CONFIG_X86_PAE)
28962 /*
28963 * In PAE mode, we need to do a cr3 reload (=tlb flush) when
28964 * updating the top-level pagetable entries to guarantee the
28965 @@ -152,7 +207,7 @@ static void pgd_dtor(pgd_t *pgd)
28966 * not shared between pagetables (!SHARED_KERNEL_PMDS), we allocate
28967 * and initialize the kernel pmds here.
28968 */
28969 -#define PREALLOCATED_PMDS UNSHARED_PTRS_PER_PGD
28970 +#define PREALLOCATED_PXDS (SHARED_KERNEL_PMD ? KERNEL_PGD_BOUNDARY : PTRS_PER_PGD)
28971
28972 void pud_populate(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd)
28973 {
28974 @@ -170,36 +225,38 @@ void pud_populate(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd)
28975 */
28976 flush_tlb_mm(mm);
28977 }
28978 +#elif defined(CONFIG_X86_64) && defined(CONFIG_PAX_PER_CPU_PGD)
28979 +#define PREALLOCATED_PXDS USER_PGD_PTRS
28980 #else /* !CONFIG_X86_PAE */
28981
28982 /* No need to prepopulate any pagetable entries in non-PAE modes. */
28983 -#define PREALLOCATED_PMDS 0
28984 +#define PREALLOCATED_PXDS 0
28985
28986 #endif /* CONFIG_X86_PAE */
28987
28988 -static void free_pmds(pmd_t *pmds[])
28989 +static void free_pxds(pxd_t *pxds[])
28990 {
28991 int i;
28992
28993 - for(i = 0; i < PREALLOCATED_PMDS; i++)
28994 - if (pmds[i])
28995 - free_page((unsigned long)pmds[i]);
28996 + for(i = 0; i < PREALLOCATED_PXDS; i++)
28997 + if (pxds[i])
28998 + free_page((unsigned long)pxds[i]);
28999 }
29000
29001 -static int preallocate_pmds(pmd_t *pmds[])
29002 +static int preallocate_pxds(pxd_t *pxds[])
29003 {
29004 int i;
29005 bool failed = false;
29006
29007 - for(i = 0; i < PREALLOCATED_PMDS; i++) {
29008 - pmd_t *pmd = (pmd_t *)__get_free_page(PGALLOC_GFP);
29009 - if (pmd == NULL)
29010 + for(i = 0; i < PREALLOCATED_PXDS; i++) {
29011 + pxd_t *pxd = (pxd_t *)__get_free_page(PGALLOC_GFP);
29012 + if (pxd == NULL)
29013 failed = true;
29014 - pmds[i] = pmd;
29015 + pxds[i] = pxd;
29016 }
29017
29018 if (failed) {
29019 - free_pmds(pmds);
29020 + free_pxds(pxds);
29021 return -ENOMEM;
29022 }
29023
29024 @@ -212,51 +269,55 @@ static int preallocate_pmds(pmd_t *pmds[])
29025 * preallocate which never got a corresponding vma will need to be
29026 * freed manually.
29027 */
29028 -static void pgd_mop_up_pmds(struct mm_struct *mm, pgd_t *pgdp)
29029 +static void pgd_mop_up_pxds(struct mm_struct *mm, pgd_t *pgdp)
29030 {
29031 int i;
29032
29033 - for(i = 0; i < PREALLOCATED_PMDS; i++) {
29034 + for(i = 0; i < PREALLOCATED_PXDS; i++) {
29035 pgd_t pgd = pgdp[i];
29036
29037 if (pgd_val(pgd) != 0) {
29038 - pmd_t *pmd = (pmd_t *)pgd_page_vaddr(pgd);
29039 + pxd_t *pxd = (pxd_t *)pgd_page_vaddr(pgd);
29040
29041 - pgdp[i] = native_make_pgd(0);
29042 + set_pgd(pgdp + i, native_make_pgd(0));
29043
29044 - paravirt_release_pmd(pgd_val(pgd) >> PAGE_SHIFT);
29045 - pmd_free(mm, pmd);
29046 + paravirt_release_pxd(pgd_val(pgd) >> PAGE_SHIFT);
29047 + pxd_free(mm, pxd);
29048 }
29049 }
29050 }
29051
29052 -static void pgd_prepopulate_pmd(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmds[])
29053 +static void pgd_prepopulate_pxd(struct mm_struct *mm, pgd_t *pgd, pxd_t *pxds[])
29054 {
29055 - pud_t *pud;
29056 + pyd_t *pyd;
29057 unsigned long addr;
29058 int i;
29059
29060 - if (PREALLOCATED_PMDS == 0) /* Work around gcc-3.4.x bug */
29061 + if (PREALLOCATED_PXDS == 0) /* Work around gcc-3.4.x bug */
29062 return;
29063
29064 - pud = pud_offset(pgd, 0);
29065 +#ifdef CONFIG_X86_64
29066 + pyd = pyd_offset(mm, 0L);
29067 +#else
29068 + pyd = pyd_offset(pgd, 0L);
29069 +#endif
29070
29071 - for (addr = i = 0; i < PREALLOCATED_PMDS;
29072 - i++, pud++, addr += PUD_SIZE) {
29073 - pmd_t *pmd = pmds[i];
29074 + for (addr = i = 0; i < PREALLOCATED_PXDS;
29075 + i++, pyd++, addr += PYD_SIZE) {
29076 + pxd_t *pxd = pxds[i];
29077
29078 if (i >= KERNEL_PGD_BOUNDARY)
29079 - memcpy(pmd, (pmd_t *)pgd_page_vaddr(swapper_pg_dir[i]),
29080 - sizeof(pmd_t) * PTRS_PER_PMD);
29081 + memcpy(pxd, (pxd_t *)pgd_page_vaddr(swapper_pg_dir[i]),
29082 + sizeof(pxd_t) * PTRS_PER_PMD);
29083
29084 - pud_populate(mm, pud, pmd);
29085 + pyd_populate(mm, pyd, pxd);
29086 }
29087 }
29088
29089 pgd_t *pgd_alloc(struct mm_struct *mm)
29090 {
29091 pgd_t *pgd;
29092 - pmd_t *pmds[PREALLOCATED_PMDS];
29093 + pxd_t *pxds[PREALLOCATED_PXDS];
29094
29095 pgd = (pgd_t *)__get_free_page(PGALLOC_GFP);
29096
29097 @@ -265,11 +326,11 @@ pgd_t *pgd_alloc(struct mm_struct *mm)
29098
29099 mm->pgd = pgd;
29100
29101 - if (preallocate_pmds(pmds) != 0)
29102 + if (preallocate_pxds(pxds) != 0)
29103 goto out_free_pgd;
29104
29105 if (paravirt_pgd_alloc(mm) != 0)
29106 - goto out_free_pmds;
29107 + goto out_free_pxds;
29108
29109 /*
29110 * Make sure that pre-populating the pmds is atomic with
29111 @@ -279,14 +340,14 @@ pgd_t *pgd_alloc(struct mm_struct *mm)
29112 spin_lock(&pgd_lock);
29113
29114 pgd_ctor(mm, pgd);
29115 - pgd_prepopulate_pmd(mm, pgd, pmds);
29116 + pgd_prepopulate_pxd(mm, pgd, pxds);
29117
29118 spin_unlock(&pgd_lock);
29119
29120 return pgd;
29121
29122 -out_free_pmds:
29123 - free_pmds(pmds);
29124 +out_free_pxds:
29125 + free_pxds(pxds);
29126 out_free_pgd:
29127 free_page((unsigned long)pgd);
29128 out:
29129 @@ -295,7 +356,7 @@ out:
29130
29131 void pgd_free(struct mm_struct *mm, pgd_t *pgd)
29132 {
29133 - pgd_mop_up_pmds(mm, pgd);
29134 + pgd_mop_up_pxds(mm, pgd);
29135 pgd_dtor(pgd);
29136 paravirt_pgd_free(mm, pgd);
29137 free_page((unsigned long)pgd);
29138 diff --git a/arch/x86/mm/pgtable_32.c b/arch/x86/mm/pgtable_32.c
29139 index a69bcb8..19068ab 100644
29140 --- a/arch/x86/mm/pgtable_32.c
29141 +++ b/arch/x86/mm/pgtable_32.c
29142 @@ -47,10 +47,13 @@ void set_pte_vaddr(unsigned long vaddr, pte_t pteval)
29143 return;
29144 }
29145 pte = pte_offset_kernel(pmd, vaddr);
29146 +
29147 + pax_open_kernel();
29148 if (pte_val(pteval))
29149 set_pte_at(&init_mm, vaddr, pte, pteval);
29150 else
29151 pte_clear(&init_mm, vaddr, pte);
29152 + pax_close_kernel();
29153
29154 /*
29155 * It's enough to flush this one mapping.
29156 diff --git a/arch/x86/mm/physaddr.c b/arch/x86/mm/physaddr.c
29157 index d2e2735..5c6586f 100644
29158 --- a/arch/x86/mm/physaddr.c
29159 +++ b/arch/x86/mm/physaddr.c
29160 @@ -8,7 +8,7 @@
29161
29162 #ifdef CONFIG_X86_64
29163
29164 -unsigned long __phys_addr(unsigned long x)
29165 +unsigned long __intentional_overflow(-1) __phys_addr(unsigned long x)
29166 {
29167 if (x >= __START_KERNEL_map) {
29168 x -= __START_KERNEL_map;
29169 @@ -45,7 +45,7 @@ EXPORT_SYMBOL(__virt_addr_valid);
29170 #else
29171
29172 #ifdef CONFIG_DEBUG_VIRTUAL
29173 -unsigned long __phys_addr(unsigned long x)
29174 +unsigned long __intentional_overflow(-1) __phys_addr(unsigned long x)
29175 {
29176 /* VMALLOC_* aren't constants */
29177 VIRTUAL_BUG_ON(x < PAGE_OFFSET);
29178 diff --git a/arch/x86/mm/setup_nx.c b/arch/x86/mm/setup_nx.c
29179 index 410531d..0f16030 100644
29180 --- a/arch/x86/mm/setup_nx.c
29181 +++ b/arch/x86/mm/setup_nx.c
29182 @@ -5,8 +5,10 @@
29183 #include <asm/pgtable.h>
29184 #include <asm/proto.h>
29185
29186 +#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
29187 static int disable_nx __cpuinitdata;
29188
29189 +#ifndef CONFIG_PAX_PAGEEXEC
29190 /*
29191 * noexec = on|off
29192 *
29193 @@ -28,12 +30,17 @@ static int __init noexec_setup(char *str)
29194 return 0;
29195 }
29196 early_param("noexec", noexec_setup);
29197 +#endif
29198 +
29199 +#endif
29200
29201 void __cpuinit x86_configure_nx(void)
29202 {
29203 +#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
29204 if (cpu_has_nx && !disable_nx)
29205 __supported_pte_mask |= _PAGE_NX;
29206 else
29207 +#endif
29208 __supported_pte_mask &= ~_PAGE_NX;
29209 }
29210
29211 diff --git a/arch/x86/mm/tlb.c b/arch/x86/mm/tlb.c
29212 index 13a6b29..c2fff23 100644
29213 --- a/arch/x86/mm/tlb.c
29214 +++ b/arch/x86/mm/tlb.c
29215 @@ -48,7 +48,11 @@ void leave_mm(int cpu)
29216 BUG();
29217 if (cpumask_test_cpu(cpu, mm_cpumask(active_mm))) {
29218 cpumask_clear_cpu(cpu, mm_cpumask(active_mm));
29219 +
29220 +#ifndef CONFIG_PAX_PER_CPU_PGD
29221 load_cr3(swapper_pg_dir);
29222 +#endif
29223 +
29224 }
29225 }
29226 EXPORT_SYMBOL_GPL(leave_mm);
29227 diff --git a/arch/x86/net/bpf_jit.S b/arch/x86/net/bpf_jit.S
29228 index 877b9a1..a8ecf42 100644
29229 --- a/arch/x86/net/bpf_jit.S
29230 +++ b/arch/x86/net/bpf_jit.S
29231 @@ -9,6 +9,7 @@
29232 */
29233 #include <linux/linkage.h>
29234 #include <asm/dwarf2.h>
29235 +#include <asm/alternative-asm.h>
29236
29237 /*
29238 * Calling convention :
29239 @@ -35,6 +36,7 @@ sk_load_word_positive_offset:
29240 jle bpf_slow_path_word
29241 mov (SKBDATA,%rsi),%eax
29242 bswap %eax /* ntohl() */
29243 + pax_force_retaddr
29244 ret
29245
29246 sk_load_half:
29247 @@ -52,6 +54,7 @@ sk_load_half_positive_offset:
29248 jle bpf_slow_path_half
29249 movzwl (SKBDATA,%rsi),%eax
29250 rol $8,%ax # ntohs()
29251 + pax_force_retaddr
29252 ret
29253
29254 sk_load_byte:
29255 @@ -66,6 +69,7 @@ sk_load_byte_positive_offset:
29256 cmp %esi,%r9d /* if (offset >= hlen) goto bpf_slow_path_byte */
29257 jle bpf_slow_path_byte
29258 movzbl (SKBDATA,%rsi),%eax
29259 + pax_force_retaddr
29260 ret
29261
29262 /**
29263 @@ -87,6 +91,7 @@ sk_load_byte_msh_positive_offset:
29264 movzbl (SKBDATA,%rsi),%ebx
29265 and $15,%bl
29266 shl $2,%bl
29267 + pax_force_retaddr
29268 ret
29269
29270 /* rsi contains offset and can be scratched */
29271 @@ -109,6 +114,7 @@ bpf_slow_path_word:
29272 js bpf_error
29273 mov -12(%rbp),%eax
29274 bswap %eax
29275 + pax_force_retaddr
29276 ret
29277
29278 bpf_slow_path_half:
29279 @@ -117,12 +123,14 @@ bpf_slow_path_half:
29280 mov -12(%rbp),%ax
29281 rol $8,%ax
29282 movzwl %ax,%eax
29283 + pax_force_retaddr
29284 ret
29285
29286 bpf_slow_path_byte:
29287 bpf_slow_path_common(1)
29288 js bpf_error
29289 movzbl -12(%rbp),%eax
29290 + pax_force_retaddr
29291 ret
29292
29293 bpf_slow_path_byte_msh:
29294 @@ -133,6 +141,7 @@ bpf_slow_path_byte_msh:
29295 and $15,%al
29296 shl $2,%al
29297 xchg %eax,%ebx
29298 + pax_force_retaddr
29299 ret
29300
29301 #define sk_negative_common(SIZE) \
29302 @@ -157,6 +166,7 @@ sk_load_word_negative_offset:
29303 sk_negative_common(4)
29304 mov (%rax), %eax
29305 bswap %eax
29306 + pax_force_retaddr
29307 ret
29308
29309 bpf_slow_path_half_neg:
29310 @@ -168,6 +178,7 @@ sk_load_half_negative_offset:
29311 mov (%rax),%ax
29312 rol $8,%ax
29313 movzwl %ax,%eax
29314 + pax_force_retaddr
29315 ret
29316
29317 bpf_slow_path_byte_neg:
29318 @@ -177,6 +188,7 @@ sk_load_byte_negative_offset:
29319 .globl sk_load_byte_negative_offset
29320 sk_negative_common(1)
29321 movzbl (%rax), %eax
29322 + pax_force_retaddr
29323 ret
29324
29325 bpf_slow_path_byte_msh_neg:
29326 @@ -190,6 +202,7 @@ sk_load_byte_msh_negative_offset:
29327 and $15,%al
29328 shl $2,%al
29329 xchg %eax,%ebx
29330 + pax_force_retaddr
29331 ret
29332
29333 bpf_error:
29334 @@ -197,4 +210,5 @@ bpf_error:
29335 xor %eax,%eax
29336 mov -8(%rbp),%rbx
29337 leaveq
29338 + pax_force_retaddr
29339 ret
29340 diff --git a/arch/x86/net/bpf_jit_comp.c b/arch/x86/net/bpf_jit_comp.c
29341 index d11a470..3f9adff3 100644
29342 --- a/arch/x86/net/bpf_jit_comp.c
29343 +++ b/arch/x86/net/bpf_jit_comp.c
29344 @@ -12,6 +12,7 @@
29345 #include <linux/netdevice.h>
29346 #include <linux/filter.h>
29347 #include <linux/if_vlan.h>
29348 +#include <linux/random.h>
29349
29350 /*
29351 * Conventions :
29352 @@ -49,13 +50,87 @@ static inline u8 *emit_code(u8 *ptr, u32 bytes, unsigned int len)
29353 return ptr + len;
29354 }
29355
29356 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
29357 +#define MAX_INSTR_CODE_SIZE 96
29358 +#else
29359 +#define MAX_INSTR_CODE_SIZE 64
29360 +#endif
29361 +
29362 #define EMIT(bytes, len) do { prog = emit_code(prog, bytes, len); } while (0)
29363
29364 #define EMIT1(b1) EMIT(b1, 1)
29365 #define EMIT2(b1, b2) EMIT((b1) + ((b2) << 8), 2)
29366 #define EMIT3(b1, b2, b3) EMIT((b1) + ((b2) << 8) + ((b3) << 16), 3)
29367 #define EMIT4(b1, b2, b3, b4) EMIT((b1) + ((b2) << 8) + ((b3) << 16) + ((b4) << 24), 4)
29368 +
29369 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
29370 +/* original constant will appear in ecx */
29371 +#define DILUTE_CONST_SEQUENCE(_off, _key) \
29372 +do { \
29373 + /* mov ecx, randkey */ \
29374 + EMIT1(0xb9); \
29375 + EMIT(_key, 4); \
29376 + /* xor ecx, randkey ^ off */ \
29377 + EMIT2(0x81, 0xf1); \
29378 + EMIT((_key) ^ (_off), 4); \
29379 +} while (0)
29380 +
29381 +#define EMIT1_off32(b1, _off) \
29382 +do { \
29383 + switch (b1) { \
29384 + case 0x05: /* add eax, imm32 */ \
29385 + case 0x2d: /* sub eax, imm32 */ \
29386 + case 0x25: /* and eax, imm32 */ \
29387 + case 0x0d: /* or eax, imm32 */ \
29388 + case 0xb8: /* mov eax, imm32 */ \
29389 + case 0x3d: /* cmp eax, imm32 */ \
29390 + case 0xa9: /* test eax, imm32 */ \
29391 + DILUTE_CONST_SEQUENCE(_off, randkey); \
29392 + EMIT2((b1) - 4, 0xc8); /* convert imm instruction to eax, ecx */\
29393 + break; \
29394 + case 0xbb: /* mov ebx, imm32 */ \
29395 + DILUTE_CONST_SEQUENCE(_off, randkey); \
29396 + /* mov ebx, ecx */ \
29397 + EMIT2(0x89, 0xcb); \
29398 + break; \
29399 + case 0xbe: /* mov esi, imm32 */ \
29400 + DILUTE_CONST_SEQUENCE(_off, randkey); \
29401 + /* mov esi, ecx */ \
29402 + EMIT2(0x89, 0xce); \
29403 + break; \
29404 + case 0xe9: /* jmp rel imm32 */ \
29405 + EMIT1(b1); \
29406 + EMIT(_off, 4); \
29407 + /* prevent fall-through, we're not called if off = 0 */ \
29408 + EMIT(0xcccccccc, 4); \
29409 + EMIT(0xcccccccc, 4); \
29410 + break; \
29411 + default: \
29412 + EMIT1(b1); \
29413 + EMIT(_off, 4); \
29414 + } \
29415 +} while (0)
29416 +
29417 +#define EMIT2_off32(b1, b2, _off) \
29418 +do { \
29419 + if ((b1) == 0x8d && (b2) == 0xb3) { /* lea esi, [rbx+imm32] */ \
29420 + EMIT2(0x8d, 0xb3); /* lea esi, [rbx+randkey] */ \
29421 + EMIT(randkey, 4); \
29422 + EMIT2(0x8d, 0xb6); /* lea esi, [esi+off-randkey] */ \
29423 + EMIT((_off) - randkey, 4); \
29424 + } else if ((b1) == 0x69 && (b2) == 0xc0) { /* imul eax, imm32 */\
29425 + DILUTE_CONST_SEQUENCE(_off, randkey); \
29426 + /* imul eax, ecx */ \
29427 + EMIT3(0x0f, 0xaf, 0xc1); \
29428 + } else { \
29429 + EMIT2(b1, b2); \
29430 + EMIT(_off, 4); \
29431 + } \
29432 +} while (0)
29433 +#else
29434 #define EMIT1_off32(b1, off) do { EMIT1(b1); EMIT(off, 4);} while (0)
29435 +#define EMIT2_off32(b1, b2, off) do { EMIT2(b1, b2); EMIT(off, 4);} while (0)
29436 +#endif
29437
29438 #define CLEAR_A() EMIT2(0x31, 0xc0) /* xor %eax,%eax */
29439 #define CLEAR_X() EMIT2(0x31, 0xdb) /* xor %ebx,%ebx */
29440 @@ -90,6 +165,24 @@ do { \
29441 #define X86_JBE 0x76
29442 #define X86_JA 0x77
29443
29444 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
29445 +#define APPEND_FLOW_VERIFY() \
29446 +do { \
29447 + /* mov ecx, randkey */ \
29448 + EMIT1(0xb9); \
29449 + EMIT(randkey, 4); \
29450 + /* cmp ecx, randkey */ \
29451 + EMIT2(0x81, 0xf9); \
29452 + EMIT(randkey, 4); \
29453 + /* jz after 8 int 3s */ \
29454 + EMIT2(0x74, 0x08); \
29455 + EMIT(0xcccccccc, 4); \
29456 + EMIT(0xcccccccc, 4); \
29457 +} while (0)
29458 +#else
29459 +#define APPEND_FLOW_VERIFY() do { } while (0)
29460 +#endif
29461 +
29462 #define EMIT_COND_JMP(op, offset) \
29463 do { \
29464 if (is_near(offset)) \
29465 @@ -97,6 +190,7 @@ do { \
29466 else { \
29467 EMIT2(0x0f, op + 0x10); \
29468 EMIT(offset, 4); /* jxx .+off32 */ \
29469 + APPEND_FLOW_VERIFY(); \
29470 } \
29471 } while (0)
29472
29473 @@ -121,12 +215,17 @@ static inline void bpf_flush_icache(void *start, void *end)
29474 set_fs(old_fs);
29475 }
29476
29477 +struct bpf_jit_work {
29478 + struct work_struct work;
29479 + void *image;
29480 +};
29481 +
29482 #define CHOOSE_LOAD_FUNC(K, func) \
29483 ((int)K < 0 ? ((int)K >= SKF_LL_OFF ? func##_negative_offset : func) : func##_positive_offset)
29484
29485 void bpf_jit_compile(struct sk_filter *fp)
29486 {
29487 - u8 temp[64];
29488 + u8 temp[MAX_INSTR_CODE_SIZE];
29489 u8 *prog;
29490 unsigned int proglen, oldproglen = 0;
29491 int ilen, i;
29492 @@ -139,6 +238,9 @@ void bpf_jit_compile(struct sk_filter *fp)
29493 unsigned int *addrs;
29494 const struct sock_filter *filter = fp->insns;
29495 int flen = fp->len;
29496 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
29497 + unsigned int randkey;
29498 +#endif
29499
29500 if (!bpf_jit_enable)
29501 return;
29502 @@ -147,11 +249,19 @@ void bpf_jit_compile(struct sk_filter *fp)
29503 if (addrs == NULL)
29504 return;
29505
29506 + fp->work = kmalloc(sizeof(*fp->work), GFP_KERNEL);
29507 + if (!fp->work)
29508 + goto out;
29509 +
29510 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
29511 + randkey = get_random_int();
29512 +#endif
29513 +
29514 /* Before first pass, make a rough estimation of addrs[]
29515 - * each bpf instruction is translated to less than 64 bytes
29516 + * each bpf instruction is translated to less than MAX_INSTR_CODE_SIZE bytes
29517 */
29518 for (proglen = 0, i = 0; i < flen; i++) {
29519 - proglen += 64;
29520 + proglen += MAX_INSTR_CODE_SIZE;
29521 addrs[i] = proglen;
29522 }
29523 cleanup_addr = proglen; /* epilogue address */
29524 @@ -261,10 +371,8 @@ void bpf_jit_compile(struct sk_filter *fp)
29525 case BPF_S_ALU_MUL_K: /* A *= K */
29526 if (is_imm8(K))
29527 EMIT3(0x6b, 0xc0, K); /* imul imm8,%eax,%eax */
29528 - else {
29529 - EMIT2(0x69, 0xc0); /* imul imm32,%eax */
29530 - EMIT(K, 4);
29531 - }
29532 + else
29533 + EMIT2_off32(0x69, 0xc0, K); /* imul imm32,%eax */
29534 break;
29535 case BPF_S_ALU_DIV_X: /* A /= X; */
29536 seen |= SEEN_XREG;
29537 @@ -304,13 +412,23 @@ void bpf_jit_compile(struct sk_filter *fp)
29538 break;
29539 case BPF_S_ALU_MOD_K: /* A %= K; */
29540 EMIT2(0x31, 0xd2); /* xor %edx,%edx */
29541 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
29542 + DILUTE_CONST_SEQUENCE(K, randkey);
29543 +#else
29544 EMIT1(0xb9);EMIT(K, 4); /* mov imm32,%ecx */
29545 +#endif
29546 EMIT2(0xf7, 0xf1); /* div %ecx */
29547 EMIT2(0x89, 0xd0); /* mov %edx,%eax */
29548 break;
29549 case BPF_S_ALU_DIV_K: /* A = reciprocal_divide(A, K); */
29550 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
29551 + DILUTE_CONST_SEQUENCE(K, randkey);
29552 + // imul rax, rcx
29553 + EMIT4(0x48, 0x0f, 0xaf, 0xc1);
29554 +#else
29555 EMIT3(0x48, 0x69, 0xc0); /* imul imm32,%rax,%rax */
29556 EMIT(K, 4);
29557 +#endif
29558 EMIT4(0x48, 0xc1, 0xe8, 0x20); /* shr $0x20,%rax */
29559 break;
29560 case BPF_S_ALU_AND_X:
29561 @@ -564,8 +682,7 @@ common_load_ind: seen |= SEEN_DATAREF | SEEN_XREG;
29562 if (is_imm8(K)) {
29563 EMIT3(0x8d, 0x73, K); /* lea imm8(%rbx), %esi */
29564 } else {
29565 - EMIT2(0x8d, 0xb3); /* lea imm32(%rbx),%esi */
29566 - EMIT(K, 4);
29567 + EMIT2_off32(0x8d, 0xb3, K); /* lea imm32(%rbx),%esi */
29568 }
29569 } else {
29570 EMIT2(0x89,0xde); /* mov %ebx,%esi */
29571 @@ -648,17 +765,18 @@ cond_branch: f_offset = addrs[i + filter[i].jf] - addrs[i];
29572 break;
29573 default:
29574 /* hmm, too complex filter, give up with jit compiler */
29575 - goto out;
29576 + goto error;
29577 }
29578 ilen = prog - temp;
29579 if (image) {
29580 if (unlikely(proglen + ilen > oldproglen)) {
29581 pr_err("bpb_jit_compile fatal error\n");
29582 - kfree(addrs);
29583 - module_free(NULL, image);
29584 - return;
29585 + module_free_exec(NULL, image);
29586 + goto error;
29587 }
29588 + pax_open_kernel();
29589 memcpy(image + proglen, temp, ilen);
29590 + pax_close_kernel();
29591 }
29592 proglen += ilen;
29593 addrs[i] = proglen;
29594 @@ -679,11 +797,9 @@ cond_branch: f_offset = addrs[i + filter[i].jf] - addrs[i];
29595 break;
29596 }
29597 if (proglen == oldproglen) {
29598 - image = module_alloc(max_t(unsigned int,
29599 - proglen,
29600 - sizeof(struct work_struct)));
29601 + image = module_alloc_exec(proglen);
29602 if (!image)
29603 - goto out;
29604 + goto error;
29605 }
29606 oldproglen = proglen;
29607 }
29608 @@ -699,7 +815,10 @@ cond_branch: f_offset = addrs[i + filter[i].jf] - addrs[i];
29609 bpf_flush_icache(image, image + proglen);
29610
29611 fp->bpf_func = (void *)image;
29612 - }
29613 + } else
29614 +error:
29615 + kfree(fp->work);
29616 +
29617 out:
29618 kfree(addrs);
29619 return;
29620 @@ -707,18 +826,20 @@ out:
29621
29622 static void jit_free_defer(struct work_struct *arg)
29623 {
29624 - module_free(NULL, arg);
29625 + module_free_exec(NULL, ((struct bpf_jit_work *)arg)->image);
29626 + kfree(arg);
29627 }
29628
29629 /* run from softirq, we must use a work_struct to call
29630 - * module_free() from process context
29631 + * module_free_exec() from process context
29632 */
29633 void bpf_jit_free(struct sk_filter *fp)
29634 {
29635 if (fp->bpf_func != sk_run_filter) {
29636 - struct work_struct *work = (struct work_struct *)fp->bpf_func;
29637 + struct work_struct *work = &fp->work->work;
29638
29639 INIT_WORK(work, jit_free_defer);
29640 + fp->work->image = fp->bpf_func;
29641 schedule_work(work);
29642 }
29643 }
29644 diff --git a/arch/x86/oprofile/backtrace.c b/arch/x86/oprofile/backtrace.c
29645 index d6aa6e8..266395a 100644
29646 --- a/arch/x86/oprofile/backtrace.c
29647 +++ b/arch/x86/oprofile/backtrace.c
29648 @@ -46,11 +46,11 @@ dump_user_backtrace_32(struct stack_frame_ia32 *head)
29649 struct stack_frame_ia32 *fp;
29650 unsigned long bytes;
29651
29652 - bytes = copy_from_user_nmi(bufhead, head, sizeof(bufhead));
29653 + bytes = copy_from_user_nmi(bufhead, (const char __force_user *)head, sizeof(bufhead));
29654 if (bytes != sizeof(bufhead))
29655 return NULL;
29656
29657 - fp = (struct stack_frame_ia32 *) compat_ptr(bufhead[0].next_frame);
29658 + fp = (struct stack_frame_ia32 __force_kernel *) compat_ptr(bufhead[0].next_frame);
29659
29660 oprofile_add_trace(bufhead[0].return_address);
29661
29662 @@ -92,7 +92,7 @@ static struct stack_frame *dump_user_backtrace(struct stack_frame *head)
29663 struct stack_frame bufhead[2];
29664 unsigned long bytes;
29665
29666 - bytes = copy_from_user_nmi(bufhead, head, sizeof(bufhead));
29667 + bytes = copy_from_user_nmi(bufhead, (const char __force_user *)head, sizeof(bufhead));
29668 if (bytes != sizeof(bufhead))
29669 return NULL;
29670
29671 @@ -111,7 +111,7 @@ x86_backtrace(struct pt_regs * const regs, unsigned int depth)
29672 {
29673 struct stack_frame *head = (struct stack_frame *)frame_pointer(regs);
29674
29675 - if (!user_mode_vm(regs)) {
29676 + if (!user_mode(regs)) {
29677 unsigned long stack = kernel_stack_pointer(regs);
29678 if (depth)
29679 dump_trace(NULL, regs, (unsigned long *)stack, 0,
29680 diff --git a/arch/x86/oprofile/nmi_int.c b/arch/x86/oprofile/nmi_int.c
29681 index 48768df..ba9143c 100644
29682 --- a/arch/x86/oprofile/nmi_int.c
29683 +++ b/arch/x86/oprofile/nmi_int.c
29684 @@ -23,6 +23,7 @@
29685 #include <asm/nmi.h>
29686 #include <asm/msr.h>
29687 #include <asm/apic.h>
29688 +#include <asm/pgtable.h>
29689
29690 #include "op_counter.h"
29691 #include "op_x86_model.h"
29692 @@ -774,8 +775,11 @@ int __init op_nmi_init(struct oprofile_operations *ops)
29693 if (ret)
29694 return ret;
29695
29696 - if (!model->num_virt_counters)
29697 - model->num_virt_counters = model->num_counters;
29698 + if (!model->num_virt_counters) {
29699 + pax_open_kernel();
29700 + *(unsigned int *)&model->num_virt_counters = model->num_counters;
29701 + pax_close_kernel();
29702 + }
29703
29704 mux_init(ops);
29705
29706 diff --git a/arch/x86/oprofile/op_model_amd.c b/arch/x86/oprofile/op_model_amd.c
29707 index b2b9443..be58856 100644
29708 --- a/arch/x86/oprofile/op_model_amd.c
29709 +++ b/arch/x86/oprofile/op_model_amd.c
29710 @@ -519,9 +519,11 @@ static int op_amd_init(struct oprofile_operations *ops)
29711 num_counters = AMD64_NUM_COUNTERS;
29712 }
29713
29714 - op_amd_spec.num_counters = num_counters;
29715 - op_amd_spec.num_controls = num_counters;
29716 - op_amd_spec.num_virt_counters = max(num_counters, NUM_VIRT_COUNTERS);
29717 + pax_open_kernel();
29718 + *(unsigned int *)&op_amd_spec.num_counters = num_counters;
29719 + *(unsigned int *)&op_amd_spec.num_controls = num_counters;
29720 + *(unsigned int *)&op_amd_spec.num_virt_counters = max(num_counters, NUM_VIRT_COUNTERS);
29721 + pax_close_kernel();
29722
29723 return 0;
29724 }
29725 diff --git a/arch/x86/oprofile/op_model_ppro.c b/arch/x86/oprofile/op_model_ppro.c
29726 index d90528e..0127e2b 100644
29727 --- a/arch/x86/oprofile/op_model_ppro.c
29728 +++ b/arch/x86/oprofile/op_model_ppro.c
29729 @@ -19,6 +19,7 @@
29730 #include <asm/msr.h>
29731 #include <asm/apic.h>
29732 #include <asm/nmi.h>
29733 +#include <asm/pgtable.h>
29734
29735 #include "op_x86_model.h"
29736 #include "op_counter.h"
29737 @@ -221,8 +222,10 @@ static void arch_perfmon_setup_counters(void)
29738
29739 num_counters = min((int)eax.split.num_counters, OP_MAX_COUNTER);
29740
29741 - op_arch_perfmon_spec.num_counters = num_counters;
29742 - op_arch_perfmon_spec.num_controls = num_counters;
29743 + pax_open_kernel();
29744 + *(unsigned int *)&op_arch_perfmon_spec.num_counters = num_counters;
29745 + *(unsigned int *)&op_arch_perfmon_spec.num_controls = num_counters;
29746 + pax_close_kernel();
29747 }
29748
29749 static int arch_perfmon_init(struct oprofile_operations *ignore)
29750 diff --git a/arch/x86/oprofile/op_x86_model.h b/arch/x86/oprofile/op_x86_model.h
29751 index 71e8a67..6a313bb 100644
29752 --- a/arch/x86/oprofile/op_x86_model.h
29753 +++ b/arch/x86/oprofile/op_x86_model.h
29754 @@ -52,7 +52,7 @@ struct op_x86_model_spec {
29755 void (*switch_ctrl)(struct op_x86_model_spec const *model,
29756 struct op_msrs const * const msrs);
29757 #endif
29758 -};
29759 +} __do_const;
29760
29761 struct op_counter_config;
29762
29763 diff --git a/arch/x86/pci/amd_bus.c b/arch/x86/pci/amd_bus.c
29764 index e9e6ed5..e47ae67 100644
29765 --- a/arch/x86/pci/amd_bus.c
29766 +++ b/arch/x86/pci/amd_bus.c
29767 @@ -337,7 +337,7 @@ static int __cpuinit amd_cpu_notify(struct notifier_block *self,
29768 return NOTIFY_OK;
29769 }
29770
29771 -static struct notifier_block __cpuinitdata amd_cpu_notifier = {
29772 +static struct notifier_block amd_cpu_notifier = {
29773 .notifier_call = amd_cpu_notify,
29774 };
29775
29776 diff --git a/arch/x86/pci/irq.c b/arch/x86/pci/irq.c
29777 index 372e9b8..e775a6c 100644
29778 --- a/arch/x86/pci/irq.c
29779 +++ b/arch/x86/pci/irq.c
29780 @@ -50,7 +50,7 @@ struct irq_router {
29781 struct irq_router_handler {
29782 u16 vendor;
29783 int (*probe)(struct irq_router *r, struct pci_dev *router, u16 device);
29784 -};
29785 +} __do_const;
29786
29787 int (*pcibios_enable_irq)(struct pci_dev *dev) = pirq_enable_irq;
29788 void (*pcibios_disable_irq)(struct pci_dev *dev) = NULL;
29789 @@ -794,7 +794,7 @@ static __init int pico_router_probe(struct irq_router *r, struct pci_dev *router
29790 return 0;
29791 }
29792
29793 -static __initdata struct irq_router_handler pirq_routers[] = {
29794 +static __initconst const struct irq_router_handler pirq_routers[] = {
29795 { PCI_VENDOR_ID_INTEL, intel_router_probe },
29796 { PCI_VENDOR_ID_AL, ali_router_probe },
29797 { PCI_VENDOR_ID_ITE, ite_router_probe },
29798 @@ -821,7 +821,7 @@ static struct pci_dev *pirq_router_dev;
29799 static void __init pirq_find_router(struct irq_router *r)
29800 {
29801 struct irq_routing_table *rt = pirq_table;
29802 - struct irq_router_handler *h;
29803 + const struct irq_router_handler *h;
29804
29805 #ifdef CONFIG_PCI_BIOS
29806 if (!rt->signature) {
29807 @@ -1094,7 +1094,7 @@ static int __init fix_acer_tm360_irqrouting(const struct dmi_system_id *d)
29808 return 0;
29809 }
29810
29811 -static struct dmi_system_id __initdata pciirq_dmi_table[] = {
29812 +static const struct dmi_system_id __initconst pciirq_dmi_table[] = {
29813 {
29814 .callback = fix_broken_hp_bios_irq9,
29815 .ident = "HP Pavilion N5400 Series Laptop",
29816 diff --git a/arch/x86/pci/mrst.c b/arch/x86/pci/mrst.c
29817 index 6eb18c4..20d83de 100644
29818 --- a/arch/x86/pci/mrst.c
29819 +++ b/arch/x86/pci/mrst.c
29820 @@ -238,7 +238,9 @@ int __init pci_mrst_init(void)
29821 printk(KERN_INFO "Intel MID platform detected, using MID PCI ops\n");
29822 pci_mmcfg_late_init();
29823 pcibios_enable_irq = mrst_pci_irq_enable;
29824 - pci_root_ops = pci_mrst_ops;
29825 + pax_open_kernel();
29826 + memcpy((void *)&pci_root_ops, &pci_mrst_ops, sizeof(pci_mrst_ops));
29827 + pax_close_kernel();
29828 pci_soc_mode = 1;
29829 /* Continue with standard init */
29830 return 1;
29831 diff --git a/arch/x86/pci/pcbios.c b/arch/x86/pci/pcbios.c
29832 index c77b24a..c979855 100644
29833 --- a/arch/x86/pci/pcbios.c
29834 +++ b/arch/x86/pci/pcbios.c
29835 @@ -79,7 +79,7 @@ union bios32 {
29836 static struct {
29837 unsigned long address;
29838 unsigned short segment;
29839 -} bios32_indirect = { 0, __KERNEL_CS };
29840 +} bios32_indirect __read_only = { 0, __PCIBIOS_CS };
29841
29842 /*
29843 * Returns the entry point for the given service, NULL on error
29844 @@ -92,37 +92,80 @@ static unsigned long bios32_service(unsigned long service)
29845 unsigned long length; /* %ecx */
29846 unsigned long entry; /* %edx */
29847 unsigned long flags;
29848 + struct desc_struct d, *gdt;
29849
29850 local_irq_save(flags);
29851 - __asm__("lcall *(%%edi); cld"
29852 +
29853 + gdt = get_cpu_gdt_table(smp_processor_id());
29854 +
29855 + pack_descriptor(&d, 0UL, 0xFFFFFUL, 0x9B, 0xC);
29856 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_CS, &d, DESCTYPE_S);
29857 + pack_descriptor(&d, 0UL, 0xFFFFFUL, 0x93, 0xC);
29858 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_DS, &d, DESCTYPE_S);
29859 +
29860 + __asm__("movw %w7, %%ds; lcall *(%%edi); push %%ss; pop %%ds; cld"
29861 : "=a" (return_code),
29862 "=b" (address),
29863 "=c" (length),
29864 "=d" (entry)
29865 : "0" (service),
29866 "1" (0),
29867 - "D" (&bios32_indirect));
29868 + "D" (&bios32_indirect),
29869 + "r"(__PCIBIOS_DS)
29870 + : "memory");
29871 +
29872 + pax_open_kernel();
29873 + gdt[GDT_ENTRY_PCIBIOS_CS].a = 0;
29874 + gdt[GDT_ENTRY_PCIBIOS_CS].b = 0;
29875 + gdt[GDT_ENTRY_PCIBIOS_DS].a = 0;
29876 + gdt[GDT_ENTRY_PCIBIOS_DS].b = 0;
29877 + pax_close_kernel();
29878 +
29879 local_irq_restore(flags);
29880
29881 switch (return_code) {
29882 - case 0:
29883 - return address + entry;
29884 - case 0x80: /* Not present */
29885 - printk(KERN_WARNING "bios32_service(0x%lx): not present\n", service);
29886 - return 0;
29887 - default: /* Shouldn't happen */
29888 - printk(KERN_WARNING "bios32_service(0x%lx): returned 0x%x -- BIOS bug!\n",
29889 - service, return_code);
29890 + case 0: {
29891 + int cpu;
29892 + unsigned char flags;
29893 +
29894 + printk(KERN_INFO "bios32_service: base:%08lx length:%08lx entry:%08lx\n", address, length, entry);
29895 + if (address >= 0xFFFF0 || length > 0x100000 - address || length <= entry) {
29896 + printk(KERN_WARNING "bios32_service: not valid\n");
29897 return 0;
29898 + }
29899 + address = address + PAGE_OFFSET;
29900 + length += 16UL; /* some BIOSs underreport this... */
29901 + flags = 4;
29902 + if (length >= 64*1024*1024) {
29903 + length >>= PAGE_SHIFT;
29904 + flags |= 8;
29905 + }
29906 +
29907 + for (cpu = 0; cpu < nr_cpu_ids; cpu++) {
29908 + gdt = get_cpu_gdt_table(cpu);
29909 + pack_descriptor(&d, address, length, 0x9b, flags);
29910 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_CS, &d, DESCTYPE_S);
29911 + pack_descriptor(&d, address, length, 0x93, flags);
29912 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_DS, &d, DESCTYPE_S);
29913 + }
29914 + return entry;
29915 + }
29916 + case 0x80: /* Not present */
29917 + printk(KERN_WARNING "bios32_service(0x%lx): not present\n", service);
29918 + return 0;
29919 + default: /* Shouldn't happen */
29920 + printk(KERN_WARNING "bios32_service(0x%lx): returned 0x%x -- BIOS bug!\n",
29921 + service, return_code);
29922 + return 0;
29923 }
29924 }
29925
29926 static struct {
29927 unsigned long address;
29928 unsigned short segment;
29929 -} pci_indirect = { 0, __KERNEL_CS };
29930 +} pci_indirect __read_only = { 0, __PCIBIOS_CS };
29931
29932 -static int pci_bios_present;
29933 +static int pci_bios_present __read_only;
29934
29935 static int check_pcibios(void)
29936 {
29937 @@ -131,11 +174,13 @@ static int check_pcibios(void)
29938 unsigned long flags, pcibios_entry;
29939
29940 if ((pcibios_entry = bios32_service(PCI_SERVICE))) {
29941 - pci_indirect.address = pcibios_entry + PAGE_OFFSET;
29942 + pci_indirect.address = pcibios_entry;
29943
29944 local_irq_save(flags);
29945 - __asm__(
29946 - "lcall *(%%edi); cld\n\t"
29947 + __asm__("movw %w6, %%ds\n\t"
29948 + "lcall *%%ss:(%%edi); cld\n\t"
29949 + "push %%ss\n\t"
29950 + "pop %%ds\n\t"
29951 "jc 1f\n\t"
29952 "xor %%ah, %%ah\n"
29953 "1:"
29954 @@ -144,7 +189,8 @@ static int check_pcibios(void)
29955 "=b" (ebx),
29956 "=c" (ecx)
29957 : "1" (PCIBIOS_PCI_BIOS_PRESENT),
29958 - "D" (&pci_indirect)
29959 + "D" (&pci_indirect),
29960 + "r" (__PCIBIOS_DS)
29961 : "memory");
29962 local_irq_restore(flags);
29963
29964 @@ -189,7 +235,10 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
29965
29966 switch (len) {
29967 case 1:
29968 - __asm__("lcall *(%%esi); cld\n\t"
29969 + __asm__("movw %w6, %%ds\n\t"
29970 + "lcall *%%ss:(%%esi); cld\n\t"
29971 + "push %%ss\n\t"
29972 + "pop %%ds\n\t"
29973 "jc 1f\n\t"
29974 "xor %%ah, %%ah\n"
29975 "1:"
29976 @@ -198,7 +247,8 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
29977 : "1" (PCIBIOS_READ_CONFIG_BYTE),
29978 "b" (bx),
29979 "D" ((long)reg),
29980 - "S" (&pci_indirect));
29981 + "S" (&pci_indirect),
29982 + "r" (__PCIBIOS_DS));
29983 /*
29984 * Zero-extend the result beyond 8 bits, do not trust the
29985 * BIOS having done it:
29986 @@ -206,7 +256,10 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
29987 *value &= 0xff;
29988 break;
29989 case 2:
29990 - __asm__("lcall *(%%esi); cld\n\t"
29991 + __asm__("movw %w6, %%ds\n\t"
29992 + "lcall *%%ss:(%%esi); cld\n\t"
29993 + "push %%ss\n\t"
29994 + "pop %%ds\n\t"
29995 "jc 1f\n\t"
29996 "xor %%ah, %%ah\n"
29997 "1:"
29998 @@ -215,7 +268,8 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
29999 : "1" (PCIBIOS_READ_CONFIG_WORD),
30000 "b" (bx),
30001 "D" ((long)reg),
30002 - "S" (&pci_indirect));
30003 + "S" (&pci_indirect),
30004 + "r" (__PCIBIOS_DS));
30005 /*
30006 * Zero-extend the result beyond 16 bits, do not trust the
30007 * BIOS having done it:
30008 @@ -223,7 +277,10 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
30009 *value &= 0xffff;
30010 break;
30011 case 4:
30012 - __asm__("lcall *(%%esi); cld\n\t"
30013 + __asm__("movw %w6, %%ds\n\t"
30014 + "lcall *%%ss:(%%esi); cld\n\t"
30015 + "push %%ss\n\t"
30016 + "pop %%ds\n\t"
30017 "jc 1f\n\t"
30018 "xor %%ah, %%ah\n"
30019 "1:"
30020 @@ -232,7 +289,8 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
30021 : "1" (PCIBIOS_READ_CONFIG_DWORD),
30022 "b" (bx),
30023 "D" ((long)reg),
30024 - "S" (&pci_indirect));
30025 + "S" (&pci_indirect),
30026 + "r" (__PCIBIOS_DS));
30027 break;
30028 }
30029
30030 @@ -256,7 +314,10 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
30031
30032 switch (len) {
30033 case 1:
30034 - __asm__("lcall *(%%esi); cld\n\t"
30035 + __asm__("movw %w6, %%ds\n\t"
30036 + "lcall *%%ss:(%%esi); cld\n\t"
30037 + "push %%ss\n\t"
30038 + "pop %%ds\n\t"
30039 "jc 1f\n\t"
30040 "xor %%ah, %%ah\n"
30041 "1:"
30042 @@ -265,10 +326,14 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
30043 "c" (value),
30044 "b" (bx),
30045 "D" ((long)reg),
30046 - "S" (&pci_indirect));
30047 + "S" (&pci_indirect),
30048 + "r" (__PCIBIOS_DS));
30049 break;
30050 case 2:
30051 - __asm__("lcall *(%%esi); cld\n\t"
30052 + __asm__("movw %w6, %%ds\n\t"
30053 + "lcall *%%ss:(%%esi); cld\n\t"
30054 + "push %%ss\n\t"
30055 + "pop %%ds\n\t"
30056 "jc 1f\n\t"
30057 "xor %%ah, %%ah\n"
30058 "1:"
30059 @@ -277,10 +342,14 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
30060 "c" (value),
30061 "b" (bx),
30062 "D" ((long)reg),
30063 - "S" (&pci_indirect));
30064 + "S" (&pci_indirect),
30065 + "r" (__PCIBIOS_DS));
30066 break;
30067 case 4:
30068 - __asm__("lcall *(%%esi); cld\n\t"
30069 + __asm__("movw %w6, %%ds\n\t"
30070 + "lcall *%%ss:(%%esi); cld\n\t"
30071 + "push %%ss\n\t"
30072 + "pop %%ds\n\t"
30073 "jc 1f\n\t"
30074 "xor %%ah, %%ah\n"
30075 "1:"
30076 @@ -289,7 +358,8 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
30077 "c" (value),
30078 "b" (bx),
30079 "D" ((long)reg),
30080 - "S" (&pci_indirect));
30081 + "S" (&pci_indirect),
30082 + "r" (__PCIBIOS_DS));
30083 break;
30084 }
30085
30086 @@ -394,10 +464,13 @@ struct irq_routing_table * pcibios_get_irq_routing_table(void)
30087
30088 DBG("PCI: Fetching IRQ routing table... ");
30089 __asm__("push %%es\n\t"
30090 + "movw %w8, %%ds\n\t"
30091 "push %%ds\n\t"
30092 "pop %%es\n\t"
30093 - "lcall *(%%esi); cld\n\t"
30094 + "lcall *%%ss:(%%esi); cld\n\t"
30095 "pop %%es\n\t"
30096 + "push %%ss\n\t"
30097 + "pop %%ds\n"
30098 "jc 1f\n\t"
30099 "xor %%ah, %%ah\n"
30100 "1:"
30101 @@ -408,7 +481,8 @@ struct irq_routing_table * pcibios_get_irq_routing_table(void)
30102 "1" (0),
30103 "D" ((long) &opt),
30104 "S" (&pci_indirect),
30105 - "m" (opt)
30106 + "m" (opt),
30107 + "r" (__PCIBIOS_DS)
30108 : "memory");
30109 DBG("OK ret=%d, size=%d, map=%x\n", ret, opt.size, map);
30110 if (ret & 0xff00)
30111 @@ -432,7 +506,10 @@ int pcibios_set_irq_routing(struct pci_dev *dev, int pin, int irq)
30112 {
30113 int ret;
30114
30115 - __asm__("lcall *(%%esi); cld\n\t"
30116 + __asm__("movw %w5, %%ds\n\t"
30117 + "lcall *%%ss:(%%esi); cld\n\t"
30118 + "push %%ss\n\t"
30119 + "pop %%ds\n"
30120 "jc 1f\n\t"
30121 "xor %%ah, %%ah\n"
30122 "1:"
30123 @@ -440,7 +517,8 @@ int pcibios_set_irq_routing(struct pci_dev *dev, int pin, int irq)
30124 : "0" (PCIBIOS_SET_PCI_HW_INT),
30125 "b" ((dev->bus->number << 8) | dev->devfn),
30126 "c" ((irq << 8) | (pin + 10)),
30127 - "S" (&pci_indirect));
30128 + "S" (&pci_indirect),
30129 + "r" (__PCIBIOS_DS));
30130 return !(ret & 0xff00);
30131 }
30132 EXPORT_SYMBOL(pcibios_set_irq_routing);
30133 diff --git a/arch/x86/platform/efi/efi_32.c b/arch/x86/platform/efi/efi_32.c
30134 index 40e4469..1ab536e 100644
30135 --- a/arch/x86/platform/efi/efi_32.c
30136 +++ b/arch/x86/platform/efi/efi_32.c
30137 @@ -44,11 +44,22 @@ void efi_call_phys_prelog(void)
30138 {
30139 struct desc_ptr gdt_descr;
30140
30141 +#ifdef CONFIG_PAX_KERNEXEC
30142 + struct desc_struct d;
30143 +#endif
30144 +
30145 local_irq_save(efi_rt_eflags);
30146
30147 load_cr3(initial_page_table);
30148 __flush_tlb_all();
30149
30150 +#ifdef CONFIG_PAX_KERNEXEC
30151 + pack_descriptor(&d, 0, 0xFFFFF, 0x9B, 0xC);
30152 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_CS, &d, DESCTYPE_S);
30153 + pack_descriptor(&d, 0, 0xFFFFF, 0x93, 0xC);
30154 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_DS, &d, DESCTYPE_S);
30155 +#endif
30156 +
30157 gdt_descr.address = __pa(get_cpu_gdt_table(0));
30158 gdt_descr.size = GDT_SIZE - 1;
30159 load_gdt(&gdt_descr);
30160 @@ -58,6 +69,14 @@ void efi_call_phys_epilog(void)
30161 {
30162 struct desc_ptr gdt_descr;
30163
30164 +#ifdef CONFIG_PAX_KERNEXEC
30165 + struct desc_struct d;
30166 +
30167 + memset(&d, 0, sizeof d);
30168 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_CS, &d, DESCTYPE_S);
30169 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_DS, &d, DESCTYPE_S);
30170 +#endif
30171 +
30172 gdt_descr.address = (unsigned long)get_cpu_gdt_table(0);
30173 gdt_descr.size = GDT_SIZE - 1;
30174 load_gdt(&gdt_descr);
30175 diff --git a/arch/x86/platform/efi/efi_stub_32.S b/arch/x86/platform/efi/efi_stub_32.S
30176 index fbe66e6..eae5e38 100644
30177 --- a/arch/x86/platform/efi/efi_stub_32.S
30178 +++ b/arch/x86/platform/efi/efi_stub_32.S
30179 @@ -6,7 +6,9 @@
30180 */
30181
30182 #include <linux/linkage.h>
30183 +#include <linux/init.h>
30184 #include <asm/page_types.h>
30185 +#include <asm/segment.h>
30186
30187 /*
30188 * efi_call_phys(void *, ...) is a function with variable parameters.
30189 @@ -20,7 +22,7 @@
30190 * service functions will comply with gcc calling convention, too.
30191 */
30192
30193 -.text
30194 +__INIT
30195 ENTRY(efi_call_phys)
30196 /*
30197 * 0. The function can only be called in Linux kernel. So CS has been
30198 @@ -36,10 +38,24 @@ ENTRY(efi_call_phys)
30199 * The mapping of lower virtual memory has been created in prelog and
30200 * epilog.
30201 */
30202 - movl $1f, %edx
30203 - subl $__PAGE_OFFSET, %edx
30204 - jmp *%edx
30205 +#ifdef CONFIG_PAX_KERNEXEC
30206 + movl $(__KERNEXEC_EFI_DS), %edx
30207 + mov %edx, %ds
30208 + mov %edx, %es
30209 + mov %edx, %ss
30210 + addl $2f,(1f)
30211 + ljmp *(1f)
30212 +
30213 +__INITDATA
30214 +1: .long __LOAD_PHYSICAL_ADDR, __KERNEXEC_EFI_CS
30215 +.previous
30216 +
30217 +2:
30218 + subl $2b,(1b)
30219 +#else
30220 + jmp 1f-__PAGE_OFFSET
30221 1:
30222 +#endif
30223
30224 /*
30225 * 2. Now on the top of stack is the return
30226 @@ -47,14 +63,8 @@ ENTRY(efi_call_phys)
30227 * parameter 2, ..., param n. To make things easy, we save the return
30228 * address of efi_call_phys in a global variable.
30229 */
30230 - popl %edx
30231 - movl %edx, saved_return_addr
30232 - /* get the function pointer into ECX*/
30233 - popl %ecx
30234 - movl %ecx, efi_rt_function_ptr
30235 - movl $2f, %edx
30236 - subl $__PAGE_OFFSET, %edx
30237 - pushl %edx
30238 + popl (saved_return_addr)
30239 + popl (efi_rt_function_ptr)
30240
30241 /*
30242 * 3. Clear PG bit in %CR0.
30243 @@ -73,9 +83,8 @@ ENTRY(efi_call_phys)
30244 /*
30245 * 5. Call the physical function.
30246 */
30247 - jmp *%ecx
30248 + call *(efi_rt_function_ptr-__PAGE_OFFSET)
30249
30250 -2:
30251 /*
30252 * 6. After EFI runtime service returns, control will return to
30253 * following instruction. We'd better readjust stack pointer first.
30254 @@ -88,35 +97,36 @@ ENTRY(efi_call_phys)
30255 movl %cr0, %edx
30256 orl $0x80000000, %edx
30257 movl %edx, %cr0
30258 - jmp 1f
30259 -1:
30260 +
30261 /*
30262 * 8. Now restore the virtual mode from flat mode by
30263 * adding EIP with PAGE_OFFSET.
30264 */
30265 - movl $1f, %edx
30266 - jmp *%edx
30267 +#ifdef CONFIG_PAX_KERNEXEC
30268 + movl $(__KERNEL_DS), %edx
30269 + mov %edx, %ds
30270 + mov %edx, %es
30271 + mov %edx, %ss
30272 + ljmp $(__KERNEL_CS),$1f
30273 +#else
30274 + jmp 1f+__PAGE_OFFSET
30275 +#endif
30276 1:
30277
30278 /*
30279 * 9. Balance the stack. And because EAX contain the return value,
30280 * we'd better not clobber it.
30281 */
30282 - leal efi_rt_function_ptr, %edx
30283 - movl (%edx), %ecx
30284 - pushl %ecx
30285 + pushl (efi_rt_function_ptr)
30286
30287 /*
30288 - * 10. Push the saved return address onto the stack and return.
30289 + * 10. Return to the saved return address.
30290 */
30291 - leal saved_return_addr, %edx
30292 - movl (%edx), %ecx
30293 - pushl %ecx
30294 - ret
30295 + jmpl *(saved_return_addr)
30296 ENDPROC(efi_call_phys)
30297 .previous
30298
30299 -.data
30300 +__INITDATA
30301 saved_return_addr:
30302 .long 0
30303 efi_rt_function_ptr:
30304 diff --git a/arch/x86/platform/efi/efi_stub_64.S b/arch/x86/platform/efi/efi_stub_64.S
30305 index 4c07cca..2c8427d 100644
30306 --- a/arch/x86/platform/efi/efi_stub_64.S
30307 +++ b/arch/x86/platform/efi/efi_stub_64.S
30308 @@ -7,6 +7,7 @@
30309 */
30310
30311 #include <linux/linkage.h>
30312 +#include <asm/alternative-asm.h>
30313
30314 #define SAVE_XMM \
30315 mov %rsp, %rax; \
30316 @@ -40,6 +41,7 @@ ENTRY(efi_call0)
30317 call *%rdi
30318 addq $32, %rsp
30319 RESTORE_XMM
30320 + pax_force_retaddr 0, 1
30321 ret
30322 ENDPROC(efi_call0)
30323
30324 @@ -50,6 +52,7 @@ ENTRY(efi_call1)
30325 call *%rdi
30326 addq $32, %rsp
30327 RESTORE_XMM
30328 + pax_force_retaddr 0, 1
30329 ret
30330 ENDPROC(efi_call1)
30331
30332 @@ -60,6 +63,7 @@ ENTRY(efi_call2)
30333 call *%rdi
30334 addq $32, %rsp
30335 RESTORE_XMM
30336 + pax_force_retaddr 0, 1
30337 ret
30338 ENDPROC(efi_call2)
30339
30340 @@ -71,6 +75,7 @@ ENTRY(efi_call3)
30341 call *%rdi
30342 addq $32, %rsp
30343 RESTORE_XMM
30344 + pax_force_retaddr 0, 1
30345 ret
30346 ENDPROC(efi_call3)
30347
30348 @@ -83,6 +88,7 @@ ENTRY(efi_call4)
30349 call *%rdi
30350 addq $32, %rsp
30351 RESTORE_XMM
30352 + pax_force_retaddr 0, 1
30353 ret
30354 ENDPROC(efi_call4)
30355
30356 @@ -96,6 +102,7 @@ ENTRY(efi_call5)
30357 call *%rdi
30358 addq $48, %rsp
30359 RESTORE_XMM
30360 + pax_force_retaddr 0, 1
30361 ret
30362 ENDPROC(efi_call5)
30363
30364 @@ -112,5 +119,6 @@ ENTRY(efi_call6)
30365 call *%rdi
30366 addq $48, %rsp
30367 RESTORE_XMM
30368 + pax_force_retaddr 0, 1
30369 ret
30370 ENDPROC(efi_call6)
30371 diff --git a/arch/x86/platform/mrst/mrst.c b/arch/x86/platform/mrst/mrst.c
30372 index e31bcd8..f12dc46 100644
30373 --- a/arch/x86/platform/mrst/mrst.c
30374 +++ b/arch/x86/platform/mrst/mrst.c
30375 @@ -78,13 +78,15 @@ struct sfi_rtc_table_entry sfi_mrtc_array[SFI_MRTC_MAX];
30376 EXPORT_SYMBOL_GPL(sfi_mrtc_array);
30377 int sfi_mrtc_num;
30378
30379 -static void mrst_power_off(void)
30380 +static __noreturn void mrst_power_off(void)
30381 {
30382 + BUG();
30383 }
30384
30385 -static void mrst_reboot(void)
30386 +static __noreturn void mrst_reboot(void)
30387 {
30388 intel_scu_ipc_simple_command(IPCMSG_COLD_BOOT, 0);
30389 + BUG();
30390 }
30391
30392 /* parse all the mtimer info to a static mtimer array */
30393 diff --git a/arch/x86/platform/olpc/olpc_dt.c b/arch/x86/platform/olpc/olpc_dt.c
30394 index d6ee929..3637cb5 100644
30395 --- a/arch/x86/platform/olpc/olpc_dt.c
30396 +++ b/arch/x86/platform/olpc/olpc_dt.c
30397 @@ -156,7 +156,7 @@ void * __init prom_early_alloc(unsigned long size)
30398 return res;
30399 }
30400
30401 -static struct of_pdt_ops prom_olpc_ops __initdata = {
30402 +static struct of_pdt_ops prom_olpc_ops __initconst = {
30403 .nextprop = olpc_dt_nextprop,
30404 .getproplen = olpc_dt_getproplen,
30405 .getproperty = olpc_dt_getproperty,
30406 diff --git a/arch/x86/power/cpu.c b/arch/x86/power/cpu.c
30407 index 120cee1..b2db75a 100644
30408 --- a/arch/x86/power/cpu.c
30409 +++ b/arch/x86/power/cpu.c
30410 @@ -133,7 +133,7 @@ static void do_fpu_end(void)
30411 static void fix_processor_context(void)
30412 {
30413 int cpu = smp_processor_id();
30414 - struct tss_struct *t = &per_cpu(init_tss, cpu);
30415 + struct tss_struct *t = init_tss + cpu;
30416
30417 set_tss_desc(cpu, t); /*
30418 * This just modifies memory; should not be
30419 @@ -143,8 +143,6 @@ static void fix_processor_context(void)
30420 */
30421
30422 #ifdef CONFIG_X86_64
30423 - get_cpu_gdt_table(cpu)[GDT_ENTRY_TSS].type = 9;
30424 -
30425 syscall_init(); /* This sets MSR_*STAR and related */
30426 #endif
30427 load_TR_desc(); /* This does ltr */
30428 diff --git a/arch/x86/realmode/init.c b/arch/x86/realmode/init.c
30429 index cbca565..bae7133 100644
30430 --- a/arch/x86/realmode/init.c
30431 +++ b/arch/x86/realmode/init.c
30432 @@ -62,7 +62,13 @@ void __init setup_real_mode(void)
30433 __va(real_mode_header->trampoline_header);
30434
30435 #ifdef CONFIG_X86_32
30436 - trampoline_header->start = __pa(startup_32_smp);
30437 + trampoline_header->start = __pa(ktla_ktva(startup_32_smp));
30438 +
30439 +#ifdef CONFIG_PAX_KERNEXEC
30440 + trampoline_header->start -= LOAD_PHYSICAL_ADDR;
30441 +#endif
30442 +
30443 + trampoline_header->boot_cs = __BOOT_CS;
30444 trampoline_header->gdt_limit = __BOOT_DS + 7;
30445 trampoline_header->gdt_base = __pa(boot_gdt);
30446 #else
30447 diff --git a/arch/x86/realmode/rm/Makefile b/arch/x86/realmode/rm/Makefile
30448 index 8869287..d577672 100644
30449 --- a/arch/x86/realmode/rm/Makefile
30450 +++ b/arch/x86/realmode/rm/Makefile
30451 @@ -78,5 +78,8 @@ KBUILD_CFLAGS := $(LINUXINCLUDE) -m32 -g -Os -D_SETUP -D__KERNEL__ -D_WAKEUP \
30452 $(call cc-option, -fno-unit-at-a-time)) \
30453 $(call cc-option, -fno-stack-protector) \
30454 $(call cc-option, -mpreferred-stack-boundary=2)
30455 +ifdef CONSTIFY_PLUGIN
30456 +KBUILD_CFLAGS += -fplugin-arg-constify_plugin-no-constify
30457 +endif
30458 KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
30459 GCOV_PROFILE := n
30460 diff --git a/arch/x86/realmode/rm/header.S b/arch/x86/realmode/rm/header.S
30461 index a28221d..93c40f1 100644
30462 --- a/arch/x86/realmode/rm/header.S
30463 +++ b/arch/x86/realmode/rm/header.S
30464 @@ -30,7 +30,9 @@ GLOBAL(real_mode_header)
30465 #endif
30466 /* APM/BIOS reboot */
30467 .long pa_machine_real_restart_asm
30468 -#ifdef CONFIG_X86_64
30469 +#ifdef CONFIG_X86_32
30470 + .long __KERNEL_CS
30471 +#else
30472 .long __KERNEL32_CS
30473 #endif
30474 END(real_mode_header)
30475 diff --git a/arch/x86/realmode/rm/trampoline_32.S b/arch/x86/realmode/rm/trampoline_32.S
30476 index c1b2791..f9e31c7 100644
30477 --- a/arch/x86/realmode/rm/trampoline_32.S
30478 +++ b/arch/x86/realmode/rm/trampoline_32.S
30479 @@ -25,6 +25,12 @@
30480 #include <asm/page_types.h>
30481 #include "realmode.h"
30482
30483 +#ifdef CONFIG_PAX_KERNEXEC
30484 +#define ta(X) (X)
30485 +#else
30486 +#define ta(X) (pa_ ## X)
30487 +#endif
30488 +
30489 .text
30490 .code16
30491
30492 @@ -39,8 +45,6 @@ ENTRY(trampoline_start)
30493
30494 cli # We should be safe anyway
30495
30496 - movl tr_start, %eax # where we need to go
30497 -
30498 movl $0xA5A5A5A5, trampoline_status
30499 # write marker for master knows we're running
30500
30501 @@ -56,7 +60,7 @@ ENTRY(trampoline_start)
30502 movw $1, %dx # protected mode (PE) bit
30503 lmsw %dx # into protected mode
30504
30505 - ljmpl $__BOOT_CS, $pa_startup_32
30506 + ljmpl *(trampoline_header)
30507
30508 .section ".text32","ax"
30509 .code32
30510 @@ -67,7 +71,7 @@ ENTRY(startup_32) # note: also used from wakeup_asm.S
30511 .balign 8
30512 GLOBAL(trampoline_header)
30513 tr_start: .space 4
30514 - tr_gdt_pad: .space 2
30515 + tr_boot_cs: .space 2
30516 tr_gdt: .space 6
30517 END(trampoline_header)
30518
30519 diff --git a/arch/x86/realmode/rm/trampoline_64.S b/arch/x86/realmode/rm/trampoline_64.S
30520 index bb360dc..3e5945f 100644
30521 --- a/arch/x86/realmode/rm/trampoline_64.S
30522 +++ b/arch/x86/realmode/rm/trampoline_64.S
30523 @@ -107,7 +107,7 @@ ENTRY(startup_32)
30524 wrmsr
30525
30526 # Enable paging and in turn activate Long Mode
30527 - movl $(X86_CR0_PG | X86_CR0_WP | X86_CR0_PE), %eax
30528 + movl $(X86_CR0_PG | X86_CR0_PE), %eax
30529 movl %eax, %cr0
30530
30531 /*
30532 diff --git a/arch/x86/tools/relocs.c b/arch/x86/tools/relocs.c
30533 index 79d67bd..c7e1b90 100644
30534 --- a/arch/x86/tools/relocs.c
30535 +++ b/arch/x86/tools/relocs.c
30536 @@ -12,10 +12,13 @@
30537 #include <regex.h>
30538 #include <tools/le_byteshift.h>
30539
30540 +#include "../../../include/generated/autoconf.h"
30541 +
30542 static void die(char *fmt, ...);
30543
30544 #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
30545 static Elf32_Ehdr ehdr;
30546 +static Elf32_Phdr *phdr;
30547 static unsigned long reloc_count, reloc_idx;
30548 static unsigned long *relocs;
30549 static unsigned long reloc16_count, reloc16_idx;
30550 @@ -330,9 +333,39 @@ static void read_ehdr(FILE *fp)
30551 }
30552 }
30553
30554 +static void read_phdrs(FILE *fp)
30555 +{
30556 + unsigned int i;
30557 +
30558 + phdr = calloc(ehdr.e_phnum, sizeof(Elf32_Phdr));
30559 + if (!phdr) {
30560 + die("Unable to allocate %d program headers\n",
30561 + ehdr.e_phnum);
30562 + }
30563 + if (fseek(fp, ehdr.e_phoff, SEEK_SET) < 0) {
30564 + die("Seek to %d failed: %s\n",
30565 + ehdr.e_phoff, strerror(errno));
30566 + }
30567 + if (fread(phdr, sizeof(*phdr), ehdr.e_phnum, fp) != ehdr.e_phnum) {
30568 + die("Cannot read ELF program headers: %s\n",
30569 + strerror(errno));
30570 + }
30571 + for(i = 0; i < ehdr.e_phnum; i++) {
30572 + phdr[i].p_type = elf32_to_cpu(phdr[i].p_type);
30573 + phdr[i].p_offset = elf32_to_cpu(phdr[i].p_offset);
30574 + phdr[i].p_vaddr = elf32_to_cpu(phdr[i].p_vaddr);
30575 + phdr[i].p_paddr = elf32_to_cpu(phdr[i].p_paddr);
30576 + phdr[i].p_filesz = elf32_to_cpu(phdr[i].p_filesz);
30577 + phdr[i].p_memsz = elf32_to_cpu(phdr[i].p_memsz);
30578 + phdr[i].p_flags = elf32_to_cpu(phdr[i].p_flags);
30579 + phdr[i].p_align = elf32_to_cpu(phdr[i].p_align);
30580 + }
30581 +
30582 +}
30583 +
30584 static void read_shdrs(FILE *fp)
30585 {
30586 - int i;
30587 + unsigned int i;
30588 Elf32_Shdr shdr;
30589
30590 secs = calloc(ehdr.e_shnum, sizeof(struct section));
30591 @@ -367,7 +400,7 @@ static void read_shdrs(FILE *fp)
30592
30593 static void read_strtabs(FILE *fp)
30594 {
30595 - int i;
30596 + unsigned int i;
30597 for (i = 0; i < ehdr.e_shnum; i++) {
30598 struct section *sec = &secs[i];
30599 if (sec->shdr.sh_type != SHT_STRTAB) {
30600 @@ -392,7 +425,7 @@ static void read_strtabs(FILE *fp)
30601
30602 static void read_symtabs(FILE *fp)
30603 {
30604 - int i,j;
30605 + unsigned int i,j;
30606 for (i = 0; i < ehdr.e_shnum; i++) {
30607 struct section *sec = &secs[i];
30608 if (sec->shdr.sh_type != SHT_SYMTAB) {
30609 @@ -423,9 +456,11 @@ static void read_symtabs(FILE *fp)
30610 }
30611
30612
30613 -static void read_relocs(FILE *fp)
30614 +static void read_relocs(FILE *fp, int use_real_mode)
30615 {
30616 - int i,j;
30617 + unsigned int i,j;
30618 + uint32_t base;
30619 +
30620 for (i = 0; i < ehdr.e_shnum; i++) {
30621 struct section *sec = &secs[i];
30622 if (sec->shdr.sh_type != SHT_REL) {
30623 @@ -445,9 +480,22 @@ static void read_relocs(FILE *fp)
30624 die("Cannot read symbol table: %s\n",
30625 strerror(errno));
30626 }
30627 + base = 0;
30628 +
30629 +#ifdef CONFIG_X86_32
30630 + for (j = 0; !use_real_mode && j < ehdr.e_phnum; j++) {
30631 + if (phdr[j].p_type != PT_LOAD )
30632 + continue;
30633 + 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)
30634 + continue;
30635 + base = CONFIG_PAGE_OFFSET + phdr[j].p_paddr - phdr[j].p_vaddr;
30636 + break;
30637 + }
30638 +#endif
30639 +
30640 for (j = 0; j < sec->shdr.sh_size/sizeof(Elf32_Rel); j++) {
30641 Elf32_Rel *rel = &sec->reltab[j];
30642 - rel->r_offset = elf32_to_cpu(rel->r_offset);
30643 + rel->r_offset = elf32_to_cpu(rel->r_offset) + base;
30644 rel->r_info = elf32_to_cpu(rel->r_info);
30645 }
30646 }
30647 @@ -456,13 +504,13 @@ static void read_relocs(FILE *fp)
30648
30649 static void print_absolute_symbols(void)
30650 {
30651 - int i;
30652 + unsigned int i;
30653 printf("Absolute symbols\n");
30654 printf(" Num: Value Size Type Bind Visibility Name\n");
30655 for (i = 0; i < ehdr.e_shnum; i++) {
30656 struct section *sec = &secs[i];
30657 char *sym_strtab;
30658 - int j;
30659 + unsigned int j;
30660
30661 if (sec->shdr.sh_type != SHT_SYMTAB) {
30662 continue;
30663 @@ -489,14 +537,14 @@ static void print_absolute_symbols(void)
30664
30665 static void print_absolute_relocs(void)
30666 {
30667 - int i, printed = 0;
30668 + unsigned int i, printed = 0;
30669
30670 for (i = 0; i < ehdr.e_shnum; i++) {
30671 struct section *sec = &secs[i];
30672 struct section *sec_applies, *sec_symtab;
30673 char *sym_strtab;
30674 Elf32_Sym *sh_symtab;
30675 - int j;
30676 + unsigned int j;
30677 if (sec->shdr.sh_type != SHT_REL) {
30678 continue;
30679 }
30680 @@ -558,13 +606,13 @@ static void print_absolute_relocs(void)
30681 static void walk_relocs(void (*visit)(Elf32_Rel *rel, Elf32_Sym *sym),
30682 int use_real_mode)
30683 {
30684 - int i;
30685 + unsigned int i;
30686 /* Walk through the relocations */
30687 for (i = 0; i < ehdr.e_shnum; i++) {
30688 char *sym_strtab;
30689 Elf32_Sym *sh_symtab;
30690 struct section *sec_applies, *sec_symtab;
30691 - int j;
30692 + unsigned int j;
30693 struct section *sec = &secs[i];
30694
30695 if (sec->shdr.sh_type != SHT_REL) {
30696 @@ -588,6 +636,24 @@ static void walk_relocs(void (*visit)(Elf32_Rel *rel, Elf32_Sym *sym),
30697 sym = &sh_symtab[ELF32_R_SYM(rel->r_info)];
30698 r_type = ELF32_R_TYPE(rel->r_info);
30699
30700 + if (!use_real_mode) {
30701 + /* Don't relocate actual per-cpu variables, they are absolute indices, not addresses */
30702 + if (!strcmp(sec_name(sym->st_shndx), ".data..percpu") && strcmp(sym_name(sym_strtab, sym), "__per_cpu_load"))
30703 + continue;
30704 +
30705 +#if defined(CONFIG_PAX_KERNEXEC) && defined(CONFIG_X86_32)
30706 + /* Don't relocate actual code, they are relocated implicitly by the base address of KERNEL_CS */
30707 + if (!strcmp(sec_name(sym->st_shndx), ".text.end") && !strcmp(sym_name(sym_strtab, sym), "_etext"))
30708 + continue;
30709 + if (!strcmp(sec_name(sym->st_shndx), ".init.text"))
30710 + continue;
30711 + if (!strcmp(sec_name(sym->st_shndx), ".exit.text"))
30712 + continue;
30713 + if (!strcmp(sec_name(sym->st_shndx), ".text") && strcmp(sym_name(sym_strtab, sym), "__LOAD_PHYSICAL_ADDR"))
30714 + continue;
30715 +#endif
30716 + }
30717 +
30718 shn_abs = sym->st_shndx == SHN_ABS;
30719
30720 switch (r_type) {
30721 @@ -681,7 +747,7 @@ static int write32(unsigned int v, FILE *f)
30722
30723 static void emit_relocs(int as_text, int use_real_mode)
30724 {
30725 - int i;
30726 + unsigned int i;
30727 /* Count how many relocations I have and allocate space for them. */
30728 reloc_count = 0;
30729 walk_relocs(count_reloc, use_real_mode);
30730 @@ -808,10 +874,11 @@ int main(int argc, char **argv)
30731 fname, strerror(errno));
30732 }
30733 read_ehdr(fp);
30734 + read_phdrs(fp);
30735 read_shdrs(fp);
30736 read_strtabs(fp);
30737 read_symtabs(fp);
30738 - read_relocs(fp);
30739 + read_relocs(fp, use_real_mode);
30740 if (show_absolute_syms) {
30741 print_absolute_symbols();
30742 goto out;
30743 diff --git a/arch/x86/vdso/Makefile b/arch/x86/vdso/Makefile
30744 index fd14be1..e3c79c0 100644
30745 --- a/arch/x86/vdso/Makefile
30746 +++ b/arch/x86/vdso/Makefile
30747 @@ -181,7 +181,7 @@ quiet_cmd_vdso = VDSO $@
30748 -Wl,-T,$(filter %.lds,$^) $(filter %.o,$^) && \
30749 sh $(srctree)/$(src)/checkundef.sh '$(NM)' '$@'
30750
30751 -VDSO_LDFLAGS = -fPIC -shared $(call cc-ldoption, -Wl$(comma)--hash-style=sysv)
30752 +VDSO_LDFLAGS = -fPIC -shared -Wl,--no-undefined $(call cc-ldoption, -Wl$(comma)--hash-style=sysv)
30753 GCOV_PROFILE := n
30754
30755 #
30756 diff --git a/arch/x86/vdso/vdso32-setup.c b/arch/x86/vdso/vdso32-setup.c
30757 index 0faad64..39ef157 100644
30758 --- a/arch/x86/vdso/vdso32-setup.c
30759 +++ b/arch/x86/vdso/vdso32-setup.c
30760 @@ -25,6 +25,7 @@
30761 #include <asm/tlbflush.h>
30762 #include <asm/vdso.h>
30763 #include <asm/proto.h>
30764 +#include <asm/mman.h>
30765
30766 enum {
30767 VDSO_DISABLED = 0,
30768 @@ -226,7 +227,7 @@ static inline void map_compat_vdso(int map)
30769 void enable_sep_cpu(void)
30770 {
30771 int cpu = get_cpu();
30772 - struct tss_struct *tss = &per_cpu(init_tss, cpu);
30773 + struct tss_struct *tss = init_tss + cpu;
30774
30775 if (!boot_cpu_has(X86_FEATURE_SEP)) {
30776 put_cpu();
30777 @@ -249,7 +250,7 @@ static int __init gate_vma_init(void)
30778 gate_vma.vm_start = FIXADDR_USER_START;
30779 gate_vma.vm_end = FIXADDR_USER_END;
30780 gate_vma.vm_flags = VM_READ | VM_MAYREAD | VM_EXEC | VM_MAYEXEC;
30781 - gate_vma.vm_page_prot = __P101;
30782 + gate_vma.vm_page_prot = vm_get_page_prot(gate_vma.vm_flags);
30783
30784 return 0;
30785 }
30786 @@ -330,14 +331,14 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
30787 if (compat)
30788 addr = VDSO_HIGH_BASE;
30789 else {
30790 - addr = get_unmapped_area(NULL, 0, PAGE_SIZE, 0, 0);
30791 + addr = get_unmapped_area(NULL, 0, PAGE_SIZE, 0, MAP_EXECUTABLE);
30792 if (IS_ERR_VALUE(addr)) {
30793 ret = addr;
30794 goto up_fail;
30795 }
30796 }
30797
30798 - current->mm->context.vdso = (void *)addr;
30799 + current->mm->context.vdso = addr;
30800
30801 if (compat_uses_vma || !compat) {
30802 /*
30803 @@ -353,11 +354,11 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
30804 }
30805
30806 current_thread_info()->sysenter_return =
30807 - VDSO32_SYMBOL(addr, SYSENTER_RETURN);
30808 + (__force void __user *)VDSO32_SYMBOL(addr, SYSENTER_RETURN);
30809
30810 up_fail:
30811 if (ret)
30812 - current->mm->context.vdso = NULL;
30813 + current->mm->context.vdso = 0;
30814
30815 up_write(&mm->mmap_sem);
30816
30817 @@ -404,8 +405,14 @@ __initcall(ia32_binfmt_init);
30818
30819 const char *arch_vma_name(struct vm_area_struct *vma)
30820 {
30821 - if (vma->vm_mm && vma->vm_start == (long)vma->vm_mm->context.vdso)
30822 + if (vma->vm_mm && vma->vm_start == vma->vm_mm->context.vdso)
30823 return "[vdso]";
30824 +
30825 +#ifdef CONFIG_PAX_SEGMEXEC
30826 + if (vma->vm_mm && vma->vm_mirror && vma->vm_mirror->vm_start == vma->vm_mm->context.vdso)
30827 + return "[vdso]";
30828 +#endif
30829 +
30830 return NULL;
30831 }
30832
30833 @@ -415,7 +422,7 @@ struct vm_area_struct *get_gate_vma(struct mm_struct *mm)
30834 * Check to see if the corresponding task was created in compat vdso
30835 * mode.
30836 */
30837 - if (mm && mm->context.vdso == (void *)VDSO_HIGH_BASE)
30838 + if (mm && mm->context.vdso == VDSO_HIGH_BASE)
30839 return &gate_vma;
30840 return NULL;
30841 }
30842 diff --git a/arch/x86/vdso/vma.c b/arch/x86/vdso/vma.c
30843 index 431e875..cbb23f3 100644
30844 --- a/arch/x86/vdso/vma.c
30845 +++ b/arch/x86/vdso/vma.c
30846 @@ -16,8 +16,6 @@
30847 #include <asm/vdso.h>
30848 #include <asm/page.h>
30849
30850 -unsigned int __read_mostly vdso_enabled = 1;
30851 -
30852 extern char vdso_start[], vdso_end[];
30853 extern unsigned short vdso_sync_cpuid;
30854
30855 @@ -141,7 +139,6 @@ static unsigned long vdso_addr(unsigned long start, unsigned len)
30856 * unaligned here as a result of stack start randomization.
30857 */
30858 addr = PAGE_ALIGN(addr);
30859 - addr = align_vdso_addr(addr);
30860
30861 return addr;
30862 }
30863 @@ -154,30 +151,31 @@ static int setup_additional_pages(struct linux_binprm *bprm,
30864 unsigned size)
30865 {
30866 struct mm_struct *mm = current->mm;
30867 - unsigned long addr;
30868 + unsigned long addr = 0;
30869 int ret;
30870
30871 - if (!vdso_enabled)
30872 - return 0;
30873 -
30874 down_write(&mm->mmap_sem);
30875 +
30876 +#ifdef CONFIG_PAX_RANDMMAP
30877 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
30878 +#endif
30879 +
30880 addr = vdso_addr(mm->start_stack, size);
30881 + addr = align_vdso_addr(addr);
30882 addr = get_unmapped_area(NULL, addr, size, 0, 0);
30883 if (IS_ERR_VALUE(addr)) {
30884 ret = addr;
30885 goto up_fail;
30886 }
30887
30888 - current->mm->context.vdso = (void *)addr;
30889 + mm->context.vdso = addr;
30890
30891 ret = install_special_mapping(mm, addr, size,
30892 VM_READ|VM_EXEC|
30893 VM_MAYREAD|VM_MAYWRITE|VM_MAYEXEC,
30894 pages);
30895 - if (ret) {
30896 - current->mm->context.vdso = NULL;
30897 - goto up_fail;
30898 - }
30899 + if (ret)
30900 + mm->context.vdso = 0;
30901
30902 up_fail:
30903 up_write(&mm->mmap_sem);
30904 @@ -197,10 +195,3 @@ int x32_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
30905 vdsox32_size);
30906 }
30907 #endif
30908 -
30909 -static __init int vdso_setup(char *s)
30910 -{
30911 - vdso_enabled = simple_strtoul(s, NULL, 0);
30912 - return 0;
30913 -}
30914 -__setup("vdso=", vdso_setup);
30915 diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c
30916 index 2262003..f229ced 100644
30917 --- a/arch/x86/xen/enlighten.c
30918 +++ b/arch/x86/xen/enlighten.c
30919 @@ -100,8 +100,6 @@ EXPORT_SYMBOL_GPL(xen_start_info);
30920
30921 struct shared_info xen_dummy_shared_info;
30922
30923 -void *xen_initial_gdt;
30924 -
30925 RESERVE_BRK(shared_info_page_brk, PAGE_SIZE);
30926 __read_mostly int xen_have_vector_callback;
30927 EXPORT_SYMBOL_GPL(xen_have_vector_callback);
30928 @@ -496,8 +494,7 @@ static void xen_load_gdt(const struct desc_ptr *dtr)
30929 {
30930 unsigned long va = dtr->address;
30931 unsigned int size = dtr->size + 1;
30932 - unsigned pages = (size + PAGE_SIZE - 1) / PAGE_SIZE;
30933 - unsigned long frames[pages];
30934 + unsigned long frames[65536 / PAGE_SIZE];
30935 int f;
30936
30937 /*
30938 @@ -545,8 +542,7 @@ static void __init xen_load_gdt_boot(const struct desc_ptr *dtr)
30939 {
30940 unsigned long va = dtr->address;
30941 unsigned int size = dtr->size + 1;
30942 - unsigned pages = (size + PAGE_SIZE - 1) / PAGE_SIZE;
30943 - unsigned long frames[pages];
30944 + unsigned long frames[65536 / PAGE_SIZE];
30945 int f;
30946
30947 /*
30948 @@ -939,7 +935,7 @@ static u32 xen_safe_apic_wait_icr_idle(void)
30949 return 0;
30950 }
30951
30952 -static void set_xen_basic_apic_ops(void)
30953 +static void __init set_xen_basic_apic_ops(void)
30954 {
30955 apic->read = xen_apic_read;
30956 apic->write = xen_apic_write;
30957 @@ -1245,30 +1241,30 @@ static const struct pv_apic_ops xen_apic_ops __initconst = {
30958 #endif
30959 };
30960
30961 -static void xen_reboot(int reason)
30962 +static __noreturn void xen_reboot(int reason)
30963 {
30964 struct sched_shutdown r = { .reason = reason };
30965
30966 - if (HYPERVISOR_sched_op(SCHEDOP_shutdown, &r))
30967 - BUG();
30968 + HYPERVISOR_sched_op(SCHEDOP_shutdown, &r);
30969 + BUG();
30970 }
30971
30972 -static void xen_restart(char *msg)
30973 +static __noreturn void xen_restart(char *msg)
30974 {
30975 xen_reboot(SHUTDOWN_reboot);
30976 }
30977
30978 -static void xen_emergency_restart(void)
30979 +static __noreturn void xen_emergency_restart(void)
30980 {
30981 xen_reboot(SHUTDOWN_reboot);
30982 }
30983
30984 -static void xen_machine_halt(void)
30985 +static __noreturn void xen_machine_halt(void)
30986 {
30987 xen_reboot(SHUTDOWN_poweroff);
30988 }
30989
30990 -static void xen_machine_power_off(void)
30991 +static __noreturn void xen_machine_power_off(void)
30992 {
30993 if (pm_power_off)
30994 pm_power_off();
30995 @@ -1370,7 +1366,17 @@ asmlinkage void __init xen_start_kernel(void)
30996 __userpte_alloc_gfp &= ~__GFP_HIGHMEM;
30997
30998 /* Work out if we support NX */
30999 - x86_configure_nx();
31000 +#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
31001 + if ((cpuid_eax(0x80000000) & 0xffff0000) == 0x80000000 &&
31002 + (cpuid_edx(0x80000001) & (1U << (X86_FEATURE_NX & 31)))) {
31003 + unsigned l, h;
31004 +
31005 + __supported_pte_mask |= _PAGE_NX;
31006 + rdmsr(MSR_EFER, l, h);
31007 + l |= EFER_NX;
31008 + wrmsr(MSR_EFER, l, h);
31009 + }
31010 +#endif
31011
31012 xen_setup_features();
31013
31014 @@ -1399,14 +1405,7 @@ asmlinkage void __init xen_start_kernel(void)
31015 pv_mmu_ops.ptep_modify_prot_commit = xen_ptep_modify_prot_commit;
31016 }
31017
31018 - machine_ops = xen_machine_ops;
31019 -
31020 - /*
31021 - * The only reliable way to retain the initial address of the
31022 - * percpu gdt_page is to remember it here, so we can go and
31023 - * mark it RW later, when the initial percpu area is freed.
31024 - */
31025 - xen_initial_gdt = &per_cpu(gdt_page, 0);
31026 + memcpy((void *)&machine_ops, &xen_machine_ops, sizeof machine_ops);
31027
31028 xen_smp_init();
31029
31030 @@ -1598,7 +1597,7 @@ static int __cpuinit xen_hvm_cpu_notify(struct notifier_block *self,
31031 return NOTIFY_OK;
31032 }
31033
31034 -static struct notifier_block xen_hvm_cpu_notifier __cpuinitdata = {
31035 +static struct notifier_block xen_hvm_cpu_notifier = {
31036 .notifier_call = xen_hvm_cpu_notify,
31037 };
31038
31039 diff --git a/arch/x86/xen/mmu.c b/arch/x86/xen/mmu.c
31040 index 01de35c..0bda07b 100644
31041 --- a/arch/x86/xen/mmu.c
31042 +++ b/arch/x86/xen/mmu.c
31043 @@ -1881,6 +1881,9 @@ void __init xen_setup_kernel_pagetable(pgd_t *pgd, unsigned long max_pfn)
31044 /* L3_k[510] -> level2_kernel_pgt
31045 * L3_i[511] -> level2_fixmap_pgt */
31046 convert_pfn_mfn(level3_kernel_pgt);
31047 + convert_pfn_mfn(level3_vmalloc_start_pgt);
31048 + convert_pfn_mfn(level3_vmalloc_end_pgt);
31049 + convert_pfn_mfn(level3_vmemmap_pgt);
31050
31051 /* We get [511][511] and have Xen's version of level2_kernel_pgt */
31052 l3 = m2v(pgd[pgd_index(__START_KERNEL_map)].pgd);
31053 @@ -1910,8 +1913,12 @@ void __init xen_setup_kernel_pagetable(pgd_t *pgd, unsigned long max_pfn)
31054 set_page_prot(init_level4_pgt, PAGE_KERNEL_RO);
31055 set_page_prot(level3_ident_pgt, PAGE_KERNEL_RO);
31056 set_page_prot(level3_kernel_pgt, PAGE_KERNEL_RO);
31057 + set_page_prot(level3_vmalloc_start_pgt, PAGE_KERNEL_RO);
31058 + set_page_prot(level3_vmalloc_end_pgt, PAGE_KERNEL_RO);
31059 + set_page_prot(level3_vmemmap_pgt, PAGE_KERNEL_RO);
31060 set_page_prot(level3_user_vsyscall, PAGE_KERNEL_RO);
31061 set_page_prot(level2_ident_pgt, PAGE_KERNEL_RO);
31062 + set_page_prot(level2_vmemmap_pgt, PAGE_KERNEL_RO);
31063 set_page_prot(level2_kernel_pgt, PAGE_KERNEL_RO);
31064 set_page_prot(level2_fixmap_pgt, PAGE_KERNEL_RO);
31065
31066 @@ -2097,6 +2104,7 @@ static void __init xen_post_allocator_init(void)
31067 pv_mmu_ops.set_pud = xen_set_pud;
31068 #if PAGETABLE_LEVELS == 4
31069 pv_mmu_ops.set_pgd = xen_set_pgd;
31070 + pv_mmu_ops.set_pgd_batched = xen_set_pgd;
31071 #endif
31072
31073 /* This will work as long as patching hasn't happened yet
31074 @@ -2178,6 +2186,7 @@ static const struct pv_mmu_ops xen_mmu_ops __initconst = {
31075 .pud_val = PV_CALLEE_SAVE(xen_pud_val),
31076 .make_pud = PV_CALLEE_SAVE(xen_make_pud),
31077 .set_pgd = xen_set_pgd_hyper,
31078 + .set_pgd_batched = xen_set_pgd_hyper,
31079
31080 .alloc_pud = xen_alloc_pmd_init,
31081 .release_pud = xen_release_pmd_init,
31082 diff --git a/arch/x86/xen/smp.c b/arch/x86/xen/smp.c
31083 index 34bc4ce..c34aa24 100644
31084 --- a/arch/x86/xen/smp.c
31085 +++ b/arch/x86/xen/smp.c
31086 @@ -229,11 +229,6 @@ static void __init xen_smp_prepare_boot_cpu(void)
31087 {
31088 BUG_ON(smp_processor_id() != 0);
31089 native_smp_prepare_boot_cpu();
31090 -
31091 - /* We've switched to the "real" per-cpu gdt, so make sure the
31092 - old memory can be recycled */
31093 - make_lowmem_page_readwrite(xen_initial_gdt);
31094 -
31095 xen_filter_cpu_maps();
31096 xen_setup_vcpu_info_placement();
31097 }
31098 @@ -300,12 +295,12 @@ cpu_initialize_context(unsigned int cpu, struct task_struct *idle)
31099 gdt = get_cpu_gdt_table(cpu);
31100
31101 ctxt->flags = VGCF_IN_KERNEL;
31102 - ctxt->user_regs.ds = __USER_DS;
31103 - ctxt->user_regs.es = __USER_DS;
31104 + ctxt->user_regs.ds = __KERNEL_DS;
31105 + ctxt->user_regs.es = __KERNEL_DS;
31106 ctxt->user_regs.ss = __KERNEL_DS;
31107 #ifdef CONFIG_X86_32
31108 ctxt->user_regs.fs = __KERNEL_PERCPU;
31109 - ctxt->user_regs.gs = __KERNEL_STACK_CANARY;
31110 + savesegment(gs, ctxt->user_regs.gs);
31111 #else
31112 ctxt->gs_base_kernel = per_cpu_offset(cpu);
31113 #endif
31114 @@ -355,13 +350,12 @@ static int __cpuinit xen_cpu_up(unsigned int cpu, struct task_struct *idle)
31115 int rc;
31116
31117 per_cpu(current_task, cpu) = idle;
31118 + per_cpu(current_tinfo, cpu) = &idle->tinfo;
31119 #ifdef CONFIG_X86_32
31120 irq_ctx_init(cpu);
31121 #else
31122 clear_tsk_thread_flag(idle, TIF_FORK);
31123 - per_cpu(kernel_stack, cpu) =
31124 - (unsigned long)task_stack_page(idle) -
31125 - KERNEL_STACK_OFFSET + THREAD_SIZE;
31126 + per_cpu(kernel_stack, cpu) = (unsigned long)task_stack_page(idle) - 16 + THREAD_SIZE;
31127 #endif
31128 xen_setup_runstate_info(cpu);
31129 xen_setup_timer(cpu);
31130 @@ -630,7 +624,7 @@ static const struct smp_ops xen_smp_ops __initconst = {
31131
31132 void __init xen_smp_init(void)
31133 {
31134 - smp_ops = xen_smp_ops;
31135 + memcpy((void *)&smp_ops, &xen_smp_ops, sizeof smp_ops);
31136 xen_fill_possible_map();
31137 xen_init_spinlocks();
31138 }
31139 diff --git a/arch/x86/xen/xen-asm_32.S b/arch/x86/xen/xen-asm_32.S
31140 index 33ca6e4..0ded929 100644
31141 --- a/arch/x86/xen/xen-asm_32.S
31142 +++ b/arch/x86/xen/xen-asm_32.S
31143 @@ -84,14 +84,14 @@ ENTRY(xen_iret)
31144 ESP_OFFSET=4 # bytes pushed onto stack
31145
31146 /*
31147 - * Store vcpu_info pointer for easy access. Do it this way to
31148 - * avoid having to reload %fs
31149 + * Store vcpu_info pointer for easy access.
31150 */
31151 #ifdef CONFIG_SMP
31152 - GET_THREAD_INFO(%eax)
31153 - movl %ss:TI_cpu(%eax), %eax
31154 - movl %ss:__per_cpu_offset(,%eax,4), %eax
31155 - mov %ss:xen_vcpu(%eax), %eax
31156 + push %fs
31157 + mov $(__KERNEL_PERCPU), %eax
31158 + mov %eax, %fs
31159 + mov PER_CPU_VAR(xen_vcpu), %eax
31160 + pop %fs
31161 #else
31162 movl %ss:xen_vcpu, %eax
31163 #endif
31164 diff --git a/arch/x86/xen/xen-head.S b/arch/x86/xen/xen-head.S
31165 index 7faed58..ba4427c 100644
31166 --- a/arch/x86/xen/xen-head.S
31167 +++ b/arch/x86/xen/xen-head.S
31168 @@ -19,6 +19,17 @@ ENTRY(startup_xen)
31169 #ifdef CONFIG_X86_32
31170 mov %esi,xen_start_info
31171 mov $init_thread_union+THREAD_SIZE,%esp
31172 +#ifdef CONFIG_SMP
31173 + movl $cpu_gdt_table,%edi
31174 + movl $__per_cpu_load,%eax
31175 + movw %ax,__KERNEL_PERCPU + 2(%edi)
31176 + rorl $16,%eax
31177 + movb %al,__KERNEL_PERCPU + 4(%edi)
31178 + movb %ah,__KERNEL_PERCPU + 7(%edi)
31179 + movl $__per_cpu_end - 1,%eax
31180 + subl $__per_cpu_start,%eax
31181 + movw %ax,__KERNEL_PERCPU + 0(%edi)
31182 +#endif
31183 #else
31184 mov %rsi,xen_start_info
31185 mov $init_thread_union+THREAD_SIZE,%rsp
31186 diff --git a/arch/x86/xen/xen-ops.h b/arch/x86/xen/xen-ops.h
31187 index a95b417..b6dbd0b 100644
31188 --- a/arch/x86/xen/xen-ops.h
31189 +++ b/arch/x86/xen/xen-ops.h
31190 @@ -10,8 +10,6 @@
31191 extern const char xen_hypervisor_callback[];
31192 extern const char xen_failsafe_callback[];
31193
31194 -extern void *xen_initial_gdt;
31195 -
31196 struct trap_info;
31197 void xen_copy_trap_info(struct trap_info *traps);
31198
31199 diff --git a/arch/xtensa/variants/dc232b/include/variant/core.h b/arch/xtensa/variants/dc232b/include/variant/core.h
31200 index 525bd3d..ef888b1 100644
31201 --- a/arch/xtensa/variants/dc232b/include/variant/core.h
31202 +++ b/arch/xtensa/variants/dc232b/include/variant/core.h
31203 @@ -119,9 +119,9 @@
31204 ----------------------------------------------------------------------*/
31205
31206 #define XCHAL_ICACHE_LINESIZE 32 /* I-cache line size in bytes */
31207 -#define XCHAL_DCACHE_LINESIZE 32 /* D-cache line size in bytes */
31208 #define XCHAL_ICACHE_LINEWIDTH 5 /* log2(I line size in bytes) */
31209 #define XCHAL_DCACHE_LINEWIDTH 5 /* log2(D line size in bytes) */
31210 +#define XCHAL_DCACHE_LINESIZE (_AC(1,UL) << XCHAL_DCACHE_LINEWIDTH) /* D-cache line size in bytes */
31211
31212 #define XCHAL_ICACHE_SIZE 16384 /* I-cache size in bytes or 0 */
31213 #define XCHAL_DCACHE_SIZE 16384 /* D-cache size in bytes or 0 */
31214 diff --git a/arch/xtensa/variants/fsf/include/variant/core.h b/arch/xtensa/variants/fsf/include/variant/core.h
31215 index 2f33760..835e50a 100644
31216 --- a/arch/xtensa/variants/fsf/include/variant/core.h
31217 +++ b/arch/xtensa/variants/fsf/include/variant/core.h
31218 @@ -11,6 +11,7 @@
31219 #ifndef _XTENSA_CORE_H
31220 #define _XTENSA_CORE_H
31221
31222 +#include <linux/const.h>
31223
31224 /****************************************************************************
31225 Parameters Useful for Any Code, USER or PRIVILEGED
31226 @@ -112,9 +113,9 @@
31227 ----------------------------------------------------------------------*/
31228
31229 #define XCHAL_ICACHE_LINESIZE 16 /* I-cache line size in bytes */
31230 -#define XCHAL_DCACHE_LINESIZE 16 /* D-cache line size in bytes */
31231 #define XCHAL_ICACHE_LINEWIDTH 4 /* log2(I line size in bytes) */
31232 #define XCHAL_DCACHE_LINEWIDTH 4 /* log2(D line size in bytes) */
31233 +#define XCHAL_DCACHE_LINESIZE (_AC(1,UL) << XCHAL_DCACHE_LINEWIDTH) /* D-cache line size in bytes */
31234
31235 #define XCHAL_ICACHE_SIZE 8192 /* I-cache size in bytes or 0 */
31236 #define XCHAL_DCACHE_SIZE 8192 /* D-cache size in bytes or 0 */
31237 diff --git a/arch/xtensa/variants/s6000/include/variant/core.h b/arch/xtensa/variants/s6000/include/variant/core.h
31238 index af00795..2bb8105 100644
31239 --- a/arch/xtensa/variants/s6000/include/variant/core.h
31240 +++ b/arch/xtensa/variants/s6000/include/variant/core.h
31241 @@ -11,6 +11,7 @@
31242 #ifndef _XTENSA_CORE_CONFIGURATION_H
31243 #define _XTENSA_CORE_CONFIGURATION_H
31244
31245 +#include <linux/const.h>
31246
31247 /****************************************************************************
31248 Parameters Useful for Any Code, USER or PRIVILEGED
31249 @@ -118,9 +119,9 @@
31250 ----------------------------------------------------------------------*/
31251
31252 #define XCHAL_ICACHE_LINESIZE 16 /* I-cache line size in bytes */
31253 -#define XCHAL_DCACHE_LINESIZE 16 /* D-cache line size in bytes */
31254 #define XCHAL_ICACHE_LINEWIDTH 4 /* log2(I line size in bytes) */
31255 #define XCHAL_DCACHE_LINEWIDTH 4 /* log2(D line size in bytes) */
31256 +#define XCHAL_DCACHE_LINESIZE (_AC(1,UL) << XCHAL_DCACHE_LINEWIDTH) /* D-cache line size in bytes */
31257
31258 #define XCHAL_ICACHE_SIZE 32768 /* I-cache size in bytes or 0 */
31259 #define XCHAL_DCACHE_SIZE 32768 /* D-cache size in bytes or 0 */
31260 diff --git a/block/blk-iopoll.c b/block/blk-iopoll.c
31261 index 58916af..eb9dbcf6 100644
31262 --- a/block/blk-iopoll.c
31263 +++ b/block/blk-iopoll.c
31264 @@ -77,7 +77,7 @@ void blk_iopoll_complete(struct blk_iopoll *iopoll)
31265 }
31266 EXPORT_SYMBOL(blk_iopoll_complete);
31267
31268 -static void blk_iopoll_softirq(struct softirq_action *h)
31269 +static void blk_iopoll_softirq(void)
31270 {
31271 struct list_head *list = &__get_cpu_var(blk_cpu_iopoll);
31272 int rearm = 0, budget = blk_iopoll_budget;
31273 @@ -209,7 +209,7 @@ static int __cpuinit blk_iopoll_cpu_notify(struct notifier_block *self,
31274 return NOTIFY_OK;
31275 }
31276
31277 -static struct notifier_block __cpuinitdata blk_iopoll_cpu_notifier = {
31278 +static struct notifier_block blk_iopoll_cpu_notifier = {
31279 .notifier_call = blk_iopoll_cpu_notify,
31280 };
31281
31282 diff --git a/block/blk-map.c b/block/blk-map.c
31283 index 623e1cd..ca1e109 100644
31284 --- a/block/blk-map.c
31285 +++ b/block/blk-map.c
31286 @@ -302,7 +302,7 @@ int blk_rq_map_kern(struct request_queue *q, struct request *rq, void *kbuf,
31287 if (!len || !kbuf)
31288 return -EINVAL;
31289
31290 - do_copy = !blk_rq_aligned(q, addr, len) || object_is_on_stack(kbuf);
31291 + do_copy = !blk_rq_aligned(q, addr, len) || object_starts_on_stack(kbuf);
31292 if (do_copy)
31293 bio = bio_copy_kern(q, kbuf, len, gfp_mask, reading);
31294 else
31295 diff --git a/block/blk-softirq.c b/block/blk-softirq.c
31296 index 467c8de..f3628c5 100644
31297 --- a/block/blk-softirq.c
31298 +++ b/block/blk-softirq.c
31299 @@ -18,7 +18,7 @@ static DEFINE_PER_CPU(struct list_head, blk_cpu_done);
31300 * Softirq action handler - move entries to local list and loop over them
31301 * while passing them to the queue registered handler.
31302 */
31303 -static void blk_done_softirq(struct softirq_action *h)
31304 +static void blk_done_softirq(void)
31305 {
31306 struct list_head *cpu_list, local_list;
31307
31308 @@ -98,7 +98,7 @@ static int __cpuinit blk_cpu_notify(struct notifier_block *self,
31309 return NOTIFY_OK;
31310 }
31311
31312 -static struct notifier_block __cpuinitdata blk_cpu_notifier = {
31313 +static struct notifier_block blk_cpu_notifier = {
31314 .notifier_call = blk_cpu_notify,
31315 };
31316
31317 diff --git a/block/bsg.c b/block/bsg.c
31318 index ff64ae3..593560c 100644
31319 --- a/block/bsg.c
31320 +++ b/block/bsg.c
31321 @@ -176,16 +176,24 @@ static int blk_fill_sgv4_hdr_rq(struct request_queue *q, struct request *rq,
31322 struct sg_io_v4 *hdr, struct bsg_device *bd,
31323 fmode_t has_write_perm)
31324 {
31325 + unsigned char tmpcmd[sizeof(rq->__cmd)];
31326 + unsigned char *cmdptr;
31327 +
31328 if (hdr->request_len > BLK_MAX_CDB) {
31329 rq->cmd = kzalloc(hdr->request_len, GFP_KERNEL);
31330 if (!rq->cmd)
31331 return -ENOMEM;
31332 - }
31333 + cmdptr = rq->cmd;
31334 + } else
31335 + cmdptr = tmpcmd;
31336
31337 - if (copy_from_user(rq->cmd, (void __user *)(unsigned long)hdr->request,
31338 + if (copy_from_user(cmdptr, (void __user *)(unsigned long)hdr->request,
31339 hdr->request_len))
31340 return -EFAULT;
31341
31342 + if (cmdptr != rq->cmd)
31343 + memcpy(rq->cmd, cmdptr, hdr->request_len);
31344 +
31345 if (hdr->subprotocol == BSG_SUB_PROTOCOL_SCSI_CMD) {
31346 if (blk_verify_command(rq->cmd, has_write_perm))
31347 return -EPERM;
31348 diff --git a/block/compat_ioctl.c b/block/compat_ioctl.c
31349 index 7c668c8..db3521c 100644
31350 --- a/block/compat_ioctl.c
31351 +++ b/block/compat_ioctl.c
31352 @@ -340,7 +340,7 @@ static int compat_fd_ioctl(struct block_device *bdev, fmode_t mode,
31353 err |= __get_user(f->spec1, &uf->spec1);
31354 err |= __get_user(f->fmt_gap, &uf->fmt_gap);
31355 err |= __get_user(name, &uf->name);
31356 - f->name = compat_ptr(name);
31357 + f->name = (void __force_kernel *)compat_ptr(name);
31358 if (err) {
31359 err = -EFAULT;
31360 goto out;
31361 diff --git a/block/partitions/efi.c b/block/partitions/efi.c
31362 index b62fb88..bdab4c4 100644
31363 --- a/block/partitions/efi.c
31364 +++ b/block/partitions/efi.c
31365 @@ -234,14 +234,14 @@ static gpt_entry *alloc_read_gpt_entries(struct parsed_partitions *state,
31366 if (!gpt)
31367 return NULL;
31368
31369 + if (!le32_to_cpu(gpt->num_partition_entries))
31370 + return NULL;
31371 + pte = kcalloc(le32_to_cpu(gpt->num_partition_entries), le32_to_cpu(gpt->sizeof_partition_entry), GFP_KERNEL);
31372 + if (!pte)
31373 + return NULL;
31374 +
31375 count = le32_to_cpu(gpt->num_partition_entries) *
31376 le32_to_cpu(gpt->sizeof_partition_entry);
31377 - if (!count)
31378 - return NULL;
31379 - pte = kzalloc(count, GFP_KERNEL);
31380 - if (!pte)
31381 - return NULL;
31382 -
31383 if (read_lba(state, le64_to_cpu(gpt->partition_entry_lba),
31384 (u8 *) pte,
31385 count) < count) {
31386 diff --git a/block/scsi_ioctl.c b/block/scsi_ioctl.c
31387 index 9a87daa..fb17486 100644
31388 --- a/block/scsi_ioctl.c
31389 +++ b/block/scsi_ioctl.c
31390 @@ -223,8 +223,20 @@ EXPORT_SYMBOL(blk_verify_command);
31391 static int blk_fill_sghdr_rq(struct request_queue *q, struct request *rq,
31392 struct sg_io_hdr *hdr, fmode_t mode)
31393 {
31394 - if (copy_from_user(rq->cmd, hdr->cmdp, hdr->cmd_len))
31395 + unsigned char tmpcmd[sizeof(rq->__cmd)];
31396 + unsigned char *cmdptr;
31397 +
31398 + if (rq->cmd != rq->__cmd)
31399 + cmdptr = rq->cmd;
31400 + else
31401 + cmdptr = tmpcmd;
31402 +
31403 + if (copy_from_user(cmdptr, hdr->cmdp, hdr->cmd_len))
31404 return -EFAULT;
31405 +
31406 + if (cmdptr != rq->cmd)
31407 + memcpy(rq->cmd, cmdptr, hdr->cmd_len);
31408 +
31409 if (blk_verify_command(rq->cmd, mode & FMODE_WRITE))
31410 return -EPERM;
31411
31412 @@ -433,6 +445,8 @@ int sg_scsi_ioctl(struct request_queue *q, struct gendisk *disk, fmode_t mode,
31413 int err;
31414 unsigned int in_len, out_len, bytes, opcode, cmdlen;
31415 char *buffer = NULL, sense[SCSI_SENSE_BUFFERSIZE];
31416 + unsigned char tmpcmd[sizeof(rq->__cmd)];
31417 + unsigned char *cmdptr;
31418
31419 if (!sic)
31420 return -EINVAL;
31421 @@ -466,9 +480,18 @@ int sg_scsi_ioctl(struct request_queue *q, struct gendisk *disk, fmode_t mode,
31422 */
31423 err = -EFAULT;
31424 rq->cmd_len = cmdlen;
31425 - if (copy_from_user(rq->cmd, sic->data, cmdlen))
31426 +
31427 + if (rq->cmd != rq->__cmd)
31428 + cmdptr = rq->cmd;
31429 + else
31430 + cmdptr = tmpcmd;
31431 +
31432 + if (copy_from_user(cmdptr, sic->data, cmdlen))
31433 goto error;
31434
31435 + if (rq->cmd != cmdptr)
31436 + memcpy(rq->cmd, cmdptr, cmdlen);
31437 +
31438 if (in_len && copy_from_user(buffer, sic->data + cmdlen, in_len))
31439 goto error;
31440
31441 diff --git a/crypto/cryptd.c b/crypto/cryptd.c
31442 index 7bdd61b..afec999 100644
31443 --- a/crypto/cryptd.c
31444 +++ b/crypto/cryptd.c
31445 @@ -63,7 +63,7 @@ struct cryptd_blkcipher_ctx {
31446
31447 struct cryptd_blkcipher_request_ctx {
31448 crypto_completion_t complete;
31449 -};
31450 +} __no_const;
31451
31452 struct cryptd_hash_ctx {
31453 struct crypto_shash *child;
31454 @@ -80,7 +80,7 @@ struct cryptd_aead_ctx {
31455
31456 struct cryptd_aead_request_ctx {
31457 crypto_completion_t complete;
31458 -};
31459 +} __no_const;
31460
31461 static void cryptd_queue_worker(struct work_struct *work);
31462
31463 diff --git a/crypto/crypto_user.c b/crypto/crypto_user.c
31464 index f6d9baf..dfd511f 100644
31465 --- a/crypto/crypto_user.c
31466 +++ b/crypto/crypto_user.c
31467 @@ -30,6 +30,8 @@
31468
31469 #include "internal.h"
31470
31471 +#define null_terminated(x) (strnlen(x, sizeof(x)) < sizeof(x))
31472 +
31473 static DEFINE_MUTEX(crypto_cfg_mutex);
31474
31475 /* The crypto netlink socket */
31476 @@ -196,7 +198,10 @@ static int crypto_report(struct sk_buff *in_skb, struct nlmsghdr *in_nlh,
31477 struct crypto_dump_info info;
31478 int err;
31479
31480 - if (!p->cru_driver_name)
31481 + if (!null_terminated(p->cru_name) || !null_terminated(p->cru_driver_name))
31482 + return -EINVAL;
31483 +
31484 + if (!p->cru_driver_name[0])
31485 return -EINVAL;
31486
31487 alg = crypto_alg_match(p, 1);
31488 @@ -260,6 +265,9 @@ static int crypto_update_alg(struct sk_buff *skb, struct nlmsghdr *nlh,
31489 struct nlattr *priority = attrs[CRYPTOCFGA_PRIORITY_VAL];
31490 LIST_HEAD(list);
31491
31492 + if (!null_terminated(p->cru_name) || !null_terminated(p->cru_driver_name))
31493 + return -EINVAL;
31494 +
31495 if (priority && !strlen(p->cru_driver_name))
31496 return -EINVAL;
31497
31498 @@ -287,6 +295,9 @@ static int crypto_del_alg(struct sk_buff *skb, struct nlmsghdr *nlh,
31499 struct crypto_alg *alg;
31500 struct crypto_user_alg *p = nlmsg_data(nlh);
31501
31502 + if (!null_terminated(p->cru_name) || !null_terminated(p->cru_driver_name))
31503 + return -EINVAL;
31504 +
31505 alg = crypto_alg_match(p, 1);
31506 if (!alg)
31507 return -ENOENT;
31508 @@ -368,6 +379,9 @@ static int crypto_add_alg(struct sk_buff *skb, struct nlmsghdr *nlh,
31509 struct crypto_user_alg *p = nlmsg_data(nlh);
31510 struct nlattr *priority = attrs[CRYPTOCFGA_PRIORITY_VAL];
31511
31512 + if (!null_terminated(p->cru_name) || !null_terminated(p->cru_driver_name))
31513 + return -EINVAL;
31514 +
31515 if (strlen(p->cru_driver_name))
31516 exact = 1;
31517
31518 diff --git a/drivers/acpi/apei/apei-internal.h b/drivers/acpi/apei/apei-internal.h
31519 index f220d64..d359ad6 100644
31520 --- a/drivers/acpi/apei/apei-internal.h
31521 +++ b/drivers/acpi/apei/apei-internal.h
31522 @@ -20,7 +20,7 @@ typedef int (*apei_exec_ins_func_t)(struct apei_exec_context *ctx,
31523 struct apei_exec_ins_type {
31524 u32 flags;
31525 apei_exec_ins_func_t run;
31526 -};
31527 +} __do_const;
31528
31529 struct apei_exec_context {
31530 u32 ip;
31531 diff --git a/drivers/acpi/apei/cper.c b/drivers/acpi/apei/cper.c
31532 index e6defd8..c26a225 100644
31533 --- a/drivers/acpi/apei/cper.c
31534 +++ b/drivers/acpi/apei/cper.c
31535 @@ -38,12 +38,12 @@
31536 */
31537 u64 cper_next_record_id(void)
31538 {
31539 - static atomic64_t seq;
31540 + static atomic64_unchecked_t seq;
31541
31542 - if (!atomic64_read(&seq))
31543 - atomic64_set(&seq, ((u64)get_seconds()) << 32);
31544 + if (!atomic64_read_unchecked(&seq))
31545 + atomic64_set_unchecked(&seq, ((u64)get_seconds()) << 32);
31546
31547 - return atomic64_inc_return(&seq);
31548 + return atomic64_inc_return_unchecked(&seq);
31549 }
31550 EXPORT_SYMBOL_GPL(cper_next_record_id);
31551
31552 diff --git a/drivers/acpi/bgrt.c b/drivers/acpi/bgrt.c
31553 index be60399..778b33e8 100644
31554 --- a/drivers/acpi/bgrt.c
31555 +++ b/drivers/acpi/bgrt.c
31556 @@ -87,8 +87,10 @@ static int __init bgrt_init(void)
31557 return -ENODEV;
31558
31559 sysfs_bin_attr_init(&image_attr);
31560 - image_attr.private = bgrt_image;
31561 - image_attr.size = bgrt_image_size;
31562 + pax_open_kernel();
31563 + *(void **)&image_attr.private = bgrt_image;
31564 + *(size_t *)&image_attr.size = bgrt_image_size;
31565 + pax_close_kernel();
31566
31567 bgrt_kobj = kobject_create_and_add("bgrt", acpi_kobj);
31568 if (!bgrt_kobj)
31569 diff --git a/drivers/acpi/blacklist.c b/drivers/acpi/blacklist.c
31570 index cb96296..b81293b 100644
31571 --- a/drivers/acpi/blacklist.c
31572 +++ b/drivers/acpi/blacklist.c
31573 @@ -52,7 +52,7 @@ struct acpi_blacklist_item {
31574 u32 is_critical_error;
31575 };
31576
31577 -static struct dmi_system_id acpi_osi_dmi_table[] __initdata;
31578 +static const struct dmi_system_id acpi_osi_dmi_table[] __initconst;
31579
31580 /*
31581 * POLICY: If *anything* doesn't work, put it on the blacklist.
31582 @@ -193,7 +193,7 @@ static int __init dmi_disable_osi_win7(const struct dmi_system_id *d)
31583 return 0;
31584 }
31585
31586 -static struct dmi_system_id acpi_osi_dmi_table[] __initdata = {
31587 +static const struct dmi_system_id acpi_osi_dmi_table[] __initconst = {
31588 {
31589 .callback = dmi_disable_osi_vista,
31590 .ident = "Fujitsu Siemens",
31591 diff --git a/drivers/acpi/ec_sys.c b/drivers/acpi/ec_sys.c
31592 index 7586544..636a2f0 100644
31593 --- a/drivers/acpi/ec_sys.c
31594 +++ b/drivers/acpi/ec_sys.c
31595 @@ -12,6 +12,7 @@
31596 #include <linux/acpi.h>
31597 #include <linux/debugfs.h>
31598 #include <linux/module.h>
31599 +#include <linux/uaccess.h>
31600 #include "internal.h"
31601
31602 MODULE_AUTHOR("Thomas Renninger <trenn@suse.de>");
31603 @@ -34,7 +35,7 @@ static ssize_t acpi_ec_read_io(struct file *f, char __user *buf,
31604 * struct acpi_ec *ec = ((struct seq_file *)f->private_data)->private;
31605 */
31606 unsigned int size = EC_SPACE_SIZE;
31607 - u8 *data = (u8 *) buf;
31608 + u8 data;
31609 loff_t init_off = *off;
31610 int err = 0;
31611
31612 @@ -47,9 +48,11 @@ static ssize_t acpi_ec_read_io(struct file *f, char __user *buf,
31613 size = count;
31614
31615 while (size) {
31616 - err = ec_read(*off, &data[*off - init_off]);
31617 + err = ec_read(*off, &data);
31618 if (err)
31619 return err;
31620 + if (put_user(data, &buf[*off - init_off]))
31621 + return -EFAULT;
31622 *off += 1;
31623 size--;
31624 }
31625 @@ -65,7 +68,6 @@ static ssize_t acpi_ec_write_io(struct file *f, const char __user *buf,
31626
31627 unsigned int size = count;
31628 loff_t init_off = *off;
31629 - u8 *data = (u8 *) buf;
31630 int err = 0;
31631
31632 if (*off >= EC_SPACE_SIZE)
31633 @@ -76,7 +78,9 @@ static ssize_t acpi_ec_write_io(struct file *f, const char __user *buf,
31634 }
31635
31636 while (size) {
31637 - u8 byte_write = data[*off - init_off];
31638 + u8 byte_write;
31639 + if (get_user(byte_write, &buf[*off - init_off]))
31640 + return -EFAULT;
31641 err = ec_write(*off, byte_write);
31642 if (err)
31643 return err;
31644 diff --git a/drivers/acpi/processor_driver.c b/drivers/acpi/processor_driver.c
31645 index e83311b..142b5cc 100644
31646 --- a/drivers/acpi/processor_driver.c
31647 +++ b/drivers/acpi/processor_driver.c
31648 @@ -558,7 +558,7 @@ static int __cpuinit acpi_processor_add(struct acpi_device *device)
31649 return 0;
31650 #endif
31651
31652 - BUG_ON((pr->id >= nr_cpu_ids) || (pr->id < 0));
31653 + BUG_ON(pr->id >= nr_cpu_ids);
31654
31655 /*
31656 * Buggy BIOS check
31657 diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c
31658 index ed9a1cc..f4a354c 100644
31659 --- a/drivers/acpi/processor_idle.c
31660 +++ b/drivers/acpi/processor_idle.c
31661 @@ -1005,7 +1005,7 @@ static int acpi_processor_setup_cpuidle_states(struct acpi_processor *pr)
31662 {
31663 int i, count = CPUIDLE_DRIVER_STATE_START;
31664 struct acpi_processor_cx *cx;
31665 - struct cpuidle_state *state;
31666 + cpuidle_state_no_const *state;
31667 struct cpuidle_driver *drv = &acpi_idle_driver;
31668
31669 if (!pr->flags.power_setup_done)
31670 diff --git a/drivers/acpi/sysfs.c b/drivers/acpi/sysfs.c
31671 index ea61ca9..3fdd70d 100644
31672 --- a/drivers/acpi/sysfs.c
31673 +++ b/drivers/acpi/sysfs.c
31674 @@ -420,11 +420,11 @@ static u32 num_counters;
31675 static struct attribute **all_attrs;
31676 static u32 acpi_gpe_count;
31677
31678 -static struct attribute_group interrupt_stats_attr_group = {
31679 +static attribute_group_no_const interrupt_stats_attr_group = {
31680 .name = "interrupts",
31681 };
31682
31683 -static struct kobj_attribute *counter_attrs;
31684 +static kobj_attribute_no_const *counter_attrs;
31685
31686 static void delete_gpe_attr_array(void)
31687 {
31688 diff --git a/drivers/ata/libahci.c b/drivers/ata/libahci.c
31689 index 6cd7805..07facb3 100644
31690 --- a/drivers/ata/libahci.c
31691 +++ b/drivers/ata/libahci.c
31692 @@ -1230,7 +1230,7 @@ int ahci_kick_engine(struct ata_port *ap)
31693 }
31694 EXPORT_SYMBOL_GPL(ahci_kick_engine);
31695
31696 -static int ahci_exec_polled_cmd(struct ata_port *ap, int pmp,
31697 +static int __intentional_overflow(-1) ahci_exec_polled_cmd(struct ata_port *ap, int pmp,
31698 struct ata_taskfile *tf, int is_cmd, u16 flags,
31699 unsigned long timeout_msec)
31700 {
31701 diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
31702 index 46cd3f4..0871ad0 100644
31703 --- a/drivers/ata/libata-core.c
31704 +++ b/drivers/ata/libata-core.c
31705 @@ -4780,7 +4780,7 @@ void ata_qc_free(struct ata_queued_cmd *qc)
31706 struct ata_port *ap;
31707 unsigned int tag;
31708
31709 - WARN_ON_ONCE(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
31710 + BUG_ON(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
31711 ap = qc->ap;
31712
31713 qc->flags = 0;
31714 @@ -4796,7 +4796,7 @@ void __ata_qc_complete(struct ata_queued_cmd *qc)
31715 struct ata_port *ap;
31716 struct ata_link *link;
31717
31718 - WARN_ON_ONCE(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
31719 + BUG_ON(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
31720 WARN_ON_ONCE(!(qc->flags & ATA_QCFLAG_ACTIVE));
31721 ap = qc->ap;
31722 link = qc->dev->link;
31723 @@ -5892,6 +5892,7 @@ static void ata_finalize_port_ops(struct ata_port_operations *ops)
31724 return;
31725
31726 spin_lock(&lock);
31727 + pax_open_kernel();
31728
31729 for (cur = ops->inherits; cur; cur = cur->inherits) {
31730 void **inherit = (void **)cur;
31731 @@ -5905,8 +5906,9 @@ static void ata_finalize_port_ops(struct ata_port_operations *ops)
31732 if (IS_ERR(*pp))
31733 *pp = NULL;
31734
31735 - ops->inherits = NULL;
31736 + *(struct ata_port_operations **)&ops->inherits = NULL;
31737
31738 + pax_close_kernel();
31739 spin_unlock(&lock);
31740 }
31741
31742 diff --git a/drivers/ata/pata_arasan_cf.c b/drivers/ata/pata_arasan_cf.c
31743 index 405022d..fb70e53 100644
31744 --- a/drivers/ata/pata_arasan_cf.c
31745 +++ b/drivers/ata/pata_arasan_cf.c
31746 @@ -864,7 +864,9 @@ static int arasan_cf_probe(struct platform_device *pdev)
31747 /* Handle platform specific quirks */
31748 if (pdata->quirk) {
31749 if (pdata->quirk & CF_BROKEN_PIO) {
31750 - ap->ops->set_piomode = NULL;
31751 + pax_open_kernel();
31752 + *(void **)&ap->ops->set_piomode = NULL;
31753 + pax_close_kernel();
31754 ap->pio_mask = 0;
31755 }
31756 if (pdata->quirk & CF_BROKEN_MWDMA)
31757 diff --git a/drivers/atm/adummy.c b/drivers/atm/adummy.c
31758 index f9b983a..887b9d8 100644
31759 --- a/drivers/atm/adummy.c
31760 +++ b/drivers/atm/adummy.c
31761 @@ -114,7 +114,7 @@ adummy_send(struct atm_vcc *vcc, struct sk_buff *skb)
31762 vcc->pop(vcc, skb);
31763 else
31764 dev_kfree_skb_any(skb);
31765 - atomic_inc(&vcc->stats->tx);
31766 + atomic_inc_unchecked(&vcc->stats->tx);
31767
31768 return 0;
31769 }
31770 diff --git a/drivers/atm/ambassador.c b/drivers/atm/ambassador.c
31771 index 77a7480..05cde58 100644
31772 --- a/drivers/atm/ambassador.c
31773 +++ b/drivers/atm/ambassador.c
31774 @@ -454,7 +454,7 @@ static void tx_complete (amb_dev * dev, tx_out * tx) {
31775 PRINTD (DBG_FLOW|DBG_TX, "tx_complete %p %p", dev, tx);
31776
31777 // VC layer stats
31778 - atomic_inc(&ATM_SKB(skb)->vcc->stats->tx);
31779 + atomic_inc_unchecked(&ATM_SKB(skb)->vcc->stats->tx);
31780
31781 // free the descriptor
31782 kfree (tx_descr);
31783 @@ -495,7 +495,7 @@ static void rx_complete (amb_dev * dev, rx_out * rx) {
31784 dump_skb ("<<<", vc, skb);
31785
31786 // VC layer stats
31787 - atomic_inc(&atm_vcc->stats->rx);
31788 + atomic_inc_unchecked(&atm_vcc->stats->rx);
31789 __net_timestamp(skb);
31790 // end of our responsibility
31791 atm_vcc->push (atm_vcc, skb);
31792 @@ -510,7 +510,7 @@ static void rx_complete (amb_dev * dev, rx_out * rx) {
31793 } else {
31794 PRINTK (KERN_INFO, "dropped over-size frame");
31795 // should we count this?
31796 - atomic_inc(&atm_vcc->stats->rx_drop);
31797 + atomic_inc_unchecked(&atm_vcc->stats->rx_drop);
31798 }
31799
31800 } else {
31801 @@ -1338,7 +1338,7 @@ static int amb_send (struct atm_vcc * atm_vcc, struct sk_buff * skb) {
31802 }
31803
31804 if (check_area (skb->data, skb->len)) {
31805 - atomic_inc(&atm_vcc->stats->tx_err);
31806 + atomic_inc_unchecked(&atm_vcc->stats->tx_err);
31807 return -ENOMEM; // ?
31808 }
31809
31810 diff --git a/drivers/atm/atmtcp.c b/drivers/atm/atmtcp.c
31811 index b22d71c..d6e1049 100644
31812 --- a/drivers/atm/atmtcp.c
31813 +++ b/drivers/atm/atmtcp.c
31814 @@ -207,7 +207,7 @@ static int atmtcp_v_send(struct atm_vcc *vcc,struct sk_buff *skb)
31815 if (vcc->pop) vcc->pop(vcc,skb);
31816 else dev_kfree_skb(skb);
31817 if (dev_data) return 0;
31818 - atomic_inc(&vcc->stats->tx_err);
31819 + atomic_inc_unchecked(&vcc->stats->tx_err);
31820 return -ENOLINK;
31821 }
31822 size = skb->len+sizeof(struct atmtcp_hdr);
31823 @@ -215,7 +215,7 @@ static int atmtcp_v_send(struct atm_vcc *vcc,struct sk_buff *skb)
31824 if (!new_skb) {
31825 if (vcc->pop) vcc->pop(vcc,skb);
31826 else dev_kfree_skb(skb);
31827 - atomic_inc(&vcc->stats->tx_err);
31828 + atomic_inc_unchecked(&vcc->stats->tx_err);
31829 return -ENOBUFS;
31830 }
31831 hdr = (void *) skb_put(new_skb,sizeof(struct atmtcp_hdr));
31832 @@ -226,8 +226,8 @@ static int atmtcp_v_send(struct atm_vcc *vcc,struct sk_buff *skb)
31833 if (vcc->pop) vcc->pop(vcc,skb);
31834 else dev_kfree_skb(skb);
31835 out_vcc->push(out_vcc,new_skb);
31836 - atomic_inc(&vcc->stats->tx);
31837 - atomic_inc(&out_vcc->stats->rx);
31838 + atomic_inc_unchecked(&vcc->stats->tx);
31839 + atomic_inc_unchecked(&out_vcc->stats->rx);
31840 return 0;
31841 }
31842
31843 @@ -301,7 +301,7 @@ static int atmtcp_c_send(struct atm_vcc *vcc,struct sk_buff *skb)
31844 out_vcc = find_vcc(dev, ntohs(hdr->vpi), ntohs(hdr->vci));
31845 read_unlock(&vcc_sklist_lock);
31846 if (!out_vcc) {
31847 - atomic_inc(&vcc->stats->tx_err);
31848 + atomic_inc_unchecked(&vcc->stats->tx_err);
31849 goto done;
31850 }
31851 skb_pull(skb,sizeof(struct atmtcp_hdr));
31852 @@ -313,8 +313,8 @@ static int atmtcp_c_send(struct atm_vcc *vcc,struct sk_buff *skb)
31853 __net_timestamp(new_skb);
31854 skb_copy_from_linear_data(skb, skb_put(new_skb, skb->len), skb->len);
31855 out_vcc->push(out_vcc,new_skb);
31856 - atomic_inc(&vcc->stats->tx);
31857 - atomic_inc(&out_vcc->stats->rx);
31858 + atomic_inc_unchecked(&vcc->stats->tx);
31859 + atomic_inc_unchecked(&out_vcc->stats->rx);
31860 done:
31861 if (vcc->pop) vcc->pop(vcc,skb);
31862 else dev_kfree_skb(skb);
31863 diff --git a/drivers/atm/eni.c b/drivers/atm/eni.c
31864 index c1eb6fa..4c71be9 100644
31865 --- a/drivers/atm/eni.c
31866 +++ b/drivers/atm/eni.c
31867 @@ -522,7 +522,7 @@ static int rx_aal0(struct atm_vcc *vcc)
31868 DPRINTK(DEV_LABEL "(itf %d): trashing empty cell\n",
31869 vcc->dev->number);
31870 length = 0;
31871 - atomic_inc(&vcc->stats->rx_err);
31872 + atomic_inc_unchecked(&vcc->stats->rx_err);
31873 }
31874 else {
31875 length = ATM_CELL_SIZE-1; /* no HEC */
31876 @@ -577,7 +577,7 @@ static int rx_aal5(struct atm_vcc *vcc)
31877 size);
31878 }
31879 eff = length = 0;
31880 - atomic_inc(&vcc->stats->rx_err);
31881 + atomic_inc_unchecked(&vcc->stats->rx_err);
31882 }
31883 else {
31884 size = (descr & MID_RED_COUNT)*(ATM_CELL_PAYLOAD >> 2);
31885 @@ -594,7 +594,7 @@ static int rx_aal5(struct atm_vcc *vcc)
31886 "(VCI=%d,length=%ld,size=%ld (descr 0x%lx))\n",
31887 vcc->dev->number,vcc->vci,length,size << 2,descr);
31888 length = eff = 0;
31889 - atomic_inc(&vcc->stats->rx_err);
31890 + atomic_inc_unchecked(&vcc->stats->rx_err);
31891 }
31892 }
31893 skb = eff ? atm_alloc_charge(vcc,eff << 2,GFP_ATOMIC) : NULL;
31894 @@ -767,7 +767,7 @@ rx_dequeued++;
31895 vcc->push(vcc,skb);
31896 pushed++;
31897 }
31898 - atomic_inc(&vcc->stats->rx);
31899 + atomic_inc_unchecked(&vcc->stats->rx);
31900 }
31901 wake_up(&eni_dev->rx_wait);
31902 }
31903 @@ -1227,7 +1227,7 @@ static void dequeue_tx(struct atm_dev *dev)
31904 PCI_DMA_TODEVICE);
31905 if (vcc->pop) vcc->pop(vcc,skb);
31906 else dev_kfree_skb_irq(skb);
31907 - atomic_inc(&vcc->stats->tx);
31908 + atomic_inc_unchecked(&vcc->stats->tx);
31909 wake_up(&eni_dev->tx_wait);
31910 dma_complete++;
31911 }
31912 diff --git a/drivers/atm/firestream.c b/drivers/atm/firestream.c
31913 index b41c948..a002b17 100644
31914 --- a/drivers/atm/firestream.c
31915 +++ b/drivers/atm/firestream.c
31916 @@ -749,7 +749,7 @@ static void process_txdone_queue (struct fs_dev *dev, struct queue *q)
31917 }
31918 }
31919
31920 - atomic_inc(&ATM_SKB(skb)->vcc->stats->tx);
31921 + atomic_inc_unchecked(&ATM_SKB(skb)->vcc->stats->tx);
31922
31923 fs_dprintk (FS_DEBUG_TXMEM, "i");
31924 fs_dprintk (FS_DEBUG_ALLOC, "Free t-skb: %p\n", skb);
31925 @@ -816,7 +816,7 @@ static void process_incoming (struct fs_dev *dev, struct queue *q)
31926 #endif
31927 skb_put (skb, qe->p1 & 0xffff);
31928 ATM_SKB(skb)->vcc = atm_vcc;
31929 - atomic_inc(&atm_vcc->stats->rx);
31930 + atomic_inc_unchecked(&atm_vcc->stats->rx);
31931 __net_timestamp(skb);
31932 fs_dprintk (FS_DEBUG_ALLOC, "Free rec-skb: %p (pushed)\n", skb);
31933 atm_vcc->push (atm_vcc, skb);
31934 @@ -837,12 +837,12 @@ static void process_incoming (struct fs_dev *dev, struct queue *q)
31935 kfree (pe);
31936 }
31937 if (atm_vcc)
31938 - atomic_inc(&atm_vcc->stats->rx_drop);
31939 + atomic_inc_unchecked(&atm_vcc->stats->rx_drop);
31940 break;
31941 case 0x1f: /* Reassembly abort: no buffers. */
31942 /* Silently increment error counter. */
31943 if (atm_vcc)
31944 - atomic_inc(&atm_vcc->stats->rx_drop);
31945 + atomic_inc_unchecked(&atm_vcc->stats->rx_drop);
31946 break;
31947 default: /* Hmm. Haven't written the code to handle the others yet... -- REW */
31948 printk (KERN_WARNING "Don't know what to do with RX status %x: %s.\n",
31949 diff --git a/drivers/atm/fore200e.c b/drivers/atm/fore200e.c
31950 index 204814e..cede831 100644
31951 --- a/drivers/atm/fore200e.c
31952 +++ b/drivers/atm/fore200e.c
31953 @@ -931,9 +931,9 @@ fore200e_tx_irq(struct fore200e* fore200e)
31954 #endif
31955 /* check error condition */
31956 if (*entry->status & STATUS_ERROR)
31957 - atomic_inc(&vcc->stats->tx_err);
31958 + atomic_inc_unchecked(&vcc->stats->tx_err);
31959 else
31960 - atomic_inc(&vcc->stats->tx);
31961 + atomic_inc_unchecked(&vcc->stats->tx);
31962 }
31963 }
31964
31965 @@ -1082,7 +1082,7 @@ fore200e_push_rpd(struct fore200e* fore200e, struct atm_vcc* vcc, struct rpd* rp
31966 if (skb == NULL) {
31967 DPRINTK(2, "unable to alloc new skb, rx PDU length = %d\n", pdu_len);
31968
31969 - atomic_inc(&vcc->stats->rx_drop);
31970 + atomic_inc_unchecked(&vcc->stats->rx_drop);
31971 return -ENOMEM;
31972 }
31973
31974 @@ -1125,14 +1125,14 @@ fore200e_push_rpd(struct fore200e* fore200e, struct atm_vcc* vcc, struct rpd* rp
31975
31976 dev_kfree_skb_any(skb);
31977
31978 - atomic_inc(&vcc->stats->rx_drop);
31979 + atomic_inc_unchecked(&vcc->stats->rx_drop);
31980 return -ENOMEM;
31981 }
31982
31983 ASSERT(atomic_read(&sk_atm(vcc)->sk_wmem_alloc) >= 0);
31984
31985 vcc->push(vcc, skb);
31986 - atomic_inc(&vcc->stats->rx);
31987 + atomic_inc_unchecked(&vcc->stats->rx);
31988
31989 ASSERT(atomic_read(&sk_atm(vcc)->sk_wmem_alloc) >= 0);
31990
31991 @@ -1210,7 +1210,7 @@ fore200e_rx_irq(struct fore200e* fore200e)
31992 DPRINTK(2, "damaged PDU on %d.%d.%d\n",
31993 fore200e->atm_dev->number,
31994 entry->rpd->atm_header.vpi, entry->rpd->atm_header.vci);
31995 - atomic_inc(&vcc->stats->rx_err);
31996 + atomic_inc_unchecked(&vcc->stats->rx_err);
31997 }
31998 }
31999
32000 @@ -1655,7 +1655,7 @@ fore200e_send(struct atm_vcc *vcc, struct sk_buff *skb)
32001 goto retry_here;
32002 }
32003
32004 - atomic_inc(&vcc->stats->tx_err);
32005 + atomic_inc_unchecked(&vcc->stats->tx_err);
32006
32007 fore200e->tx_sat++;
32008 DPRINTK(2, "tx queue of device %s is saturated, PDU dropped - heartbeat is %08x\n",
32009 diff --git a/drivers/atm/he.c b/drivers/atm/he.c
32010 index 72b6960..cf9167a 100644
32011 --- a/drivers/atm/he.c
32012 +++ b/drivers/atm/he.c
32013 @@ -1699,7 +1699,7 @@ he_service_rbrq(struct he_dev *he_dev, int group)
32014
32015 if (RBRQ_HBUF_ERR(he_dev->rbrq_head)) {
32016 hprintk("HBUF_ERR! (cid 0x%x)\n", cid);
32017 - atomic_inc(&vcc->stats->rx_drop);
32018 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32019 goto return_host_buffers;
32020 }
32021
32022 @@ -1726,7 +1726,7 @@ he_service_rbrq(struct he_dev *he_dev, int group)
32023 RBRQ_LEN_ERR(he_dev->rbrq_head)
32024 ? "LEN_ERR" : "",
32025 vcc->vpi, vcc->vci);
32026 - atomic_inc(&vcc->stats->rx_err);
32027 + atomic_inc_unchecked(&vcc->stats->rx_err);
32028 goto return_host_buffers;
32029 }
32030
32031 @@ -1778,7 +1778,7 @@ he_service_rbrq(struct he_dev *he_dev, int group)
32032 vcc->push(vcc, skb);
32033 spin_lock(&he_dev->global_lock);
32034
32035 - atomic_inc(&vcc->stats->rx);
32036 + atomic_inc_unchecked(&vcc->stats->rx);
32037
32038 return_host_buffers:
32039 ++pdus_assembled;
32040 @@ -2104,7 +2104,7 @@ __enqueue_tpd(struct he_dev *he_dev, struct he_tpd *tpd, unsigned cid)
32041 tpd->vcc->pop(tpd->vcc, tpd->skb);
32042 else
32043 dev_kfree_skb_any(tpd->skb);
32044 - atomic_inc(&tpd->vcc->stats->tx_err);
32045 + atomic_inc_unchecked(&tpd->vcc->stats->tx_err);
32046 }
32047 pci_pool_free(he_dev->tpd_pool, tpd, TPD_ADDR(tpd->status));
32048 return;
32049 @@ -2516,7 +2516,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
32050 vcc->pop(vcc, skb);
32051 else
32052 dev_kfree_skb_any(skb);
32053 - atomic_inc(&vcc->stats->tx_err);
32054 + atomic_inc_unchecked(&vcc->stats->tx_err);
32055 return -EINVAL;
32056 }
32057
32058 @@ -2527,7 +2527,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
32059 vcc->pop(vcc, skb);
32060 else
32061 dev_kfree_skb_any(skb);
32062 - atomic_inc(&vcc->stats->tx_err);
32063 + atomic_inc_unchecked(&vcc->stats->tx_err);
32064 return -EINVAL;
32065 }
32066 #endif
32067 @@ -2539,7 +2539,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
32068 vcc->pop(vcc, skb);
32069 else
32070 dev_kfree_skb_any(skb);
32071 - atomic_inc(&vcc->stats->tx_err);
32072 + atomic_inc_unchecked(&vcc->stats->tx_err);
32073 spin_unlock_irqrestore(&he_dev->global_lock, flags);
32074 return -ENOMEM;
32075 }
32076 @@ -2581,7 +2581,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
32077 vcc->pop(vcc, skb);
32078 else
32079 dev_kfree_skb_any(skb);
32080 - atomic_inc(&vcc->stats->tx_err);
32081 + atomic_inc_unchecked(&vcc->stats->tx_err);
32082 spin_unlock_irqrestore(&he_dev->global_lock, flags);
32083 return -ENOMEM;
32084 }
32085 @@ -2612,7 +2612,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
32086 __enqueue_tpd(he_dev, tpd, cid);
32087 spin_unlock_irqrestore(&he_dev->global_lock, flags);
32088
32089 - atomic_inc(&vcc->stats->tx);
32090 + atomic_inc_unchecked(&vcc->stats->tx);
32091
32092 return 0;
32093 }
32094 diff --git a/drivers/atm/horizon.c b/drivers/atm/horizon.c
32095 index 1dc0519..1aadaf7 100644
32096 --- a/drivers/atm/horizon.c
32097 +++ b/drivers/atm/horizon.c
32098 @@ -1034,7 +1034,7 @@ static void rx_schedule (hrz_dev * dev, int irq) {
32099 {
32100 struct atm_vcc * vcc = ATM_SKB(skb)->vcc;
32101 // VC layer stats
32102 - atomic_inc(&vcc->stats->rx);
32103 + atomic_inc_unchecked(&vcc->stats->rx);
32104 __net_timestamp(skb);
32105 // end of our responsibility
32106 vcc->push (vcc, skb);
32107 @@ -1186,7 +1186,7 @@ static void tx_schedule (hrz_dev * const dev, int irq) {
32108 dev->tx_iovec = NULL;
32109
32110 // VC layer stats
32111 - atomic_inc(&ATM_SKB(skb)->vcc->stats->tx);
32112 + atomic_inc_unchecked(&ATM_SKB(skb)->vcc->stats->tx);
32113
32114 // free the skb
32115 hrz_kfree_skb (skb);
32116 diff --git a/drivers/atm/idt77252.c b/drivers/atm/idt77252.c
32117 index 272f009..a18ba55 100644
32118 --- a/drivers/atm/idt77252.c
32119 +++ b/drivers/atm/idt77252.c
32120 @@ -812,7 +812,7 @@ drain_scq(struct idt77252_dev *card, struct vc_map *vc)
32121 else
32122 dev_kfree_skb(skb);
32123
32124 - atomic_inc(&vcc->stats->tx);
32125 + atomic_inc_unchecked(&vcc->stats->tx);
32126 }
32127
32128 atomic_dec(&scq->used);
32129 @@ -1075,13 +1075,13 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
32130 if ((sb = dev_alloc_skb(64)) == NULL) {
32131 printk("%s: Can't allocate buffers for aal0.\n",
32132 card->name);
32133 - atomic_add(i, &vcc->stats->rx_drop);
32134 + atomic_add_unchecked(i, &vcc->stats->rx_drop);
32135 break;
32136 }
32137 if (!atm_charge(vcc, sb->truesize)) {
32138 RXPRINTK("%s: atm_charge() dropped aal0 packets.\n",
32139 card->name);
32140 - atomic_add(i - 1, &vcc->stats->rx_drop);
32141 + atomic_add_unchecked(i - 1, &vcc->stats->rx_drop);
32142 dev_kfree_skb(sb);
32143 break;
32144 }
32145 @@ -1098,7 +1098,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
32146 ATM_SKB(sb)->vcc = vcc;
32147 __net_timestamp(sb);
32148 vcc->push(vcc, sb);
32149 - atomic_inc(&vcc->stats->rx);
32150 + atomic_inc_unchecked(&vcc->stats->rx);
32151
32152 cell += ATM_CELL_PAYLOAD;
32153 }
32154 @@ -1135,13 +1135,13 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
32155 "(CDC: %08x)\n",
32156 card->name, len, rpp->len, readl(SAR_REG_CDC));
32157 recycle_rx_pool_skb(card, rpp);
32158 - atomic_inc(&vcc->stats->rx_err);
32159 + atomic_inc_unchecked(&vcc->stats->rx_err);
32160 return;
32161 }
32162 if (stat & SAR_RSQE_CRC) {
32163 RXPRINTK("%s: AAL5 CRC error.\n", card->name);
32164 recycle_rx_pool_skb(card, rpp);
32165 - atomic_inc(&vcc->stats->rx_err);
32166 + atomic_inc_unchecked(&vcc->stats->rx_err);
32167 return;
32168 }
32169 if (skb_queue_len(&rpp->queue) > 1) {
32170 @@ -1152,7 +1152,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
32171 RXPRINTK("%s: Can't alloc RX skb.\n",
32172 card->name);
32173 recycle_rx_pool_skb(card, rpp);
32174 - atomic_inc(&vcc->stats->rx_err);
32175 + atomic_inc_unchecked(&vcc->stats->rx_err);
32176 return;
32177 }
32178 if (!atm_charge(vcc, skb->truesize)) {
32179 @@ -1171,7 +1171,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
32180 __net_timestamp(skb);
32181
32182 vcc->push(vcc, skb);
32183 - atomic_inc(&vcc->stats->rx);
32184 + atomic_inc_unchecked(&vcc->stats->rx);
32185
32186 return;
32187 }
32188 @@ -1193,7 +1193,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
32189 __net_timestamp(skb);
32190
32191 vcc->push(vcc, skb);
32192 - atomic_inc(&vcc->stats->rx);
32193 + atomic_inc_unchecked(&vcc->stats->rx);
32194
32195 if (skb->truesize > SAR_FB_SIZE_3)
32196 add_rx_skb(card, 3, SAR_FB_SIZE_3, 1);
32197 @@ -1304,14 +1304,14 @@ idt77252_rx_raw(struct idt77252_dev *card)
32198 if (vcc->qos.aal != ATM_AAL0) {
32199 RPRINTK("%s: raw cell for non AAL0 vc %u.%u\n",
32200 card->name, vpi, vci);
32201 - atomic_inc(&vcc->stats->rx_drop);
32202 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32203 goto drop;
32204 }
32205
32206 if ((sb = dev_alloc_skb(64)) == NULL) {
32207 printk("%s: Can't allocate buffers for AAL0.\n",
32208 card->name);
32209 - atomic_inc(&vcc->stats->rx_err);
32210 + atomic_inc_unchecked(&vcc->stats->rx_err);
32211 goto drop;
32212 }
32213
32214 @@ -1330,7 +1330,7 @@ idt77252_rx_raw(struct idt77252_dev *card)
32215 ATM_SKB(sb)->vcc = vcc;
32216 __net_timestamp(sb);
32217 vcc->push(vcc, sb);
32218 - atomic_inc(&vcc->stats->rx);
32219 + atomic_inc_unchecked(&vcc->stats->rx);
32220
32221 drop:
32222 skb_pull(queue, 64);
32223 @@ -1955,13 +1955,13 @@ idt77252_send_skb(struct atm_vcc *vcc, struct sk_buff *skb, int oam)
32224
32225 if (vc == NULL) {
32226 printk("%s: NULL connection in send().\n", card->name);
32227 - atomic_inc(&vcc->stats->tx_err);
32228 + atomic_inc_unchecked(&vcc->stats->tx_err);
32229 dev_kfree_skb(skb);
32230 return -EINVAL;
32231 }
32232 if (!test_bit(VCF_TX, &vc->flags)) {
32233 printk("%s: Trying to transmit on a non-tx VC.\n", card->name);
32234 - atomic_inc(&vcc->stats->tx_err);
32235 + atomic_inc_unchecked(&vcc->stats->tx_err);
32236 dev_kfree_skb(skb);
32237 return -EINVAL;
32238 }
32239 @@ -1973,14 +1973,14 @@ idt77252_send_skb(struct atm_vcc *vcc, struct sk_buff *skb, int oam)
32240 break;
32241 default:
32242 printk("%s: Unsupported AAL: %d\n", card->name, vcc->qos.aal);
32243 - atomic_inc(&vcc->stats->tx_err);
32244 + atomic_inc_unchecked(&vcc->stats->tx_err);
32245 dev_kfree_skb(skb);
32246 return -EINVAL;
32247 }
32248
32249 if (skb_shinfo(skb)->nr_frags != 0) {
32250 printk("%s: No scatter-gather yet.\n", card->name);
32251 - atomic_inc(&vcc->stats->tx_err);
32252 + atomic_inc_unchecked(&vcc->stats->tx_err);
32253 dev_kfree_skb(skb);
32254 return -EINVAL;
32255 }
32256 @@ -1988,7 +1988,7 @@ idt77252_send_skb(struct atm_vcc *vcc, struct sk_buff *skb, int oam)
32257
32258 err = queue_skb(card, vc, skb, oam);
32259 if (err) {
32260 - atomic_inc(&vcc->stats->tx_err);
32261 + atomic_inc_unchecked(&vcc->stats->tx_err);
32262 dev_kfree_skb(skb);
32263 return err;
32264 }
32265 @@ -2011,7 +2011,7 @@ idt77252_send_oam(struct atm_vcc *vcc, void *cell, int flags)
32266 skb = dev_alloc_skb(64);
32267 if (!skb) {
32268 printk("%s: Out of memory in send_oam().\n", card->name);
32269 - atomic_inc(&vcc->stats->tx_err);
32270 + atomic_inc_unchecked(&vcc->stats->tx_err);
32271 return -ENOMEM;
32272 }
32273 atomic_add(skb->truesize, &sk_atm(vcc)->sk_wmem_alloc);
32274 diff --git a/drivers/atm/iphase.c b/drivers/atm/iphase.c
32275 index 4217f29..88f547a 100644
32276 --- a/drivers/atm/iphase.c
32277 +++ b/drivers/atm/iphase.c
32278 @@ -1145,7 +1145,7 @@ static int rx_pkt(struct atm_dev *dev)
32279 status = (u_short) (buf_desc_ptr->desc_mode);
32280 if (status & (RX_CER | RX_PTE | RX_OFL))
32281 {
32282 - atomic_inc(&vcc->stats->rx_err);
32283 + atomic_inc_unchecked(&vcc->stats->rx_err);
32284 IF_ERR(printk("IA: bad packet, dropping it");)
32285 if (status & RX_CER) {
32286 IF_ERR(printk(" cause: packet CRC error\n");)
32287 @@ -1168,7 +1168,7 @@ static int rx_pkt(struct atm_dev *dev)
32288 len = dma_addr - buf_addr;
32289 if (len > iadev->rx_buf_sz) {
32290 printk("Over %d bytes sdu received, dropped!!!\n", iadev->rx_buf_sz);
32291 - atomic_inc(&vcc->stats->rx_err);
32292 + atomic_inc_unchecked(&vcc->stats->rx_err);
32293 goto out_free_desc;
32294 }
32295
32296 @@ -1318,7 +1318,7 @@ static void rx_dle_intr(struct atm_dev *dev)
32297 ia_vcc = INPH_IA_VCC(vcc);
32298 if (ia_vcc == NULL)
32299 {
32300 - atomic_inc(&vcc->stats->rx_err);
32301 + atomic_inc_unchecked(&vcc->stats->rx_err);
32302 atm_return(vcc, skb->truesize);
32303 dev_kfree_skb_any(skb);
32304 goto INCR_DLE;
32305 @@ -1330,7 +1330,7 @@ static void rx_dle_intr(struct atm_dev *dev)
32306 if ((length > iadev->rx_buf_sz) || (length >
32307 (skb->len - sizeof(struct cpcs_trailer))))
32308 {
32309 - atomic_inc(&vcc->stats->rx_err);
32310 + atomic_inc_unchecked(&vcc->stats->rx_err);
32311 IF_ERR(printk("rx_dle_intr: Bad AAL5 trailer %d (skb len %d)",
32312 length, skb->len);)
32313 atm_return(vcc, skb->truesize);
32314 @@ -1346,7 +1346,7 @@ static void rx_dle_intr(struct atm_dev *dev)
32315
32316 IF_RX(printk("rx_dle_intr: skb push");)
32317 vcc->push(vcc,skb);
32318 - atomic_inc(&vcc->stats->rx);
32319 + atomic_inc_unchecked(&vcc->stats->rx);
32320 iadev->rx_pkt_cnt++;
32321 }
32322 INCR_DLE:
32323 @@ -2826,15 +2826,15 @@ static int ia_ioctl(struct atm_dev *dev, unsigned int cmd, void __user *arg)
32324 {
32325 struct k_sonet_stats *stats;
32326 stats = &PRIV(_ia_dev[board])->sonet_stats;
32327 - printk("section_bip: %d\n", atomic_read(&stats->section_bip));
32328 - printk("line_bip : %d\n", atomic_read(&stats->line_bip));
32329 - printk("path_bip : %d\n", atomic_read(&stats->path_bip));
32330 - printk("line_febe : %d\n", atomic_read(&stats->line_febe));
32331 - printk("path_febe : %d\n", atomic_read(&stats->path_febe));
32332 - printk("corr_hcs : %d\n", atomic_read(&stats->corr_hcs));
32333 - printk("uncorr_hcs : %d\n", atomic_read(&stats->uncorr_hcs));
32334 - printk("tx_cells : %d\n", atomic_read(&stats->tx_cells));
32335 - printk("rx_cells : %d\n", atomic_read(&stats->rx_cells));
32336 + printk("section_bip: %d\n", atomic_read_unchecked(&stats->section_bip));
32337 + printk("line_bip : %d\n", atomic_read_unchecked(&stats->line_bip));
32338 + printk("path_bip : %d\n", atomic_read_unchecked(&stats->path_bip));
32339 + printk("line_febe : %d\n", atomic_read_unchecked(&stats->line_febe));
32340 + printk("path_febe : %d\n", atomic_read_unchecked(&stats->path_febe));
32341 + printk("corr_hcs : %d\n", atomic_read_unchecked(&stats->corr_hcs));
32342 + printk("uncorr_hcs : %d\n", atomic_read_unchecked(&stats->uncorr_hcs));
32343 + printk("tx_cells : %d\n", atomic_read_unchecked(&stats->tx_cells));
32344 + printk("rx_cells : %d\n", atomic_read_unchecked(&stats->rx_cells));
32345 }
32346 ia_cmds.status = 0;
32347 break;
32348 @@ -2939,7 +2939,7 @@ static int ia_pkt_tx (struct atm_vcc *vcc, struct sk_buff *skb) {
32349 if ((desc == 0) || (desc > iadev->num_tx_desc))
32350 {
32351 IF_ERR(printk(DEV_LABEL "invalid desc for send: %d\n", desc);)
32352 - atomic_inc(&vcc->stats->tx);
32353 + atomic_inc_unchecked(&vcc->stats->tx);
32354 if (vcc->pop)
32355 vcc->pop(vcc, skb);
32356 else
32357 @@ -3044,14 +3044,14 @@ static int ia_pkt_tx (struct atm_vcc *vcc, struct sk_buff *skb) {
32358 ATM_DESC(skb) = vcc->vci;
32359 skb_queue_tail(&iadev->tx_dma_q, skb);
32360
32361 - atomic_inc(&vcc->stats->tx);
32362 + atomic_inc_unchecked(&vcc->stats->tx);
32363 iadev->tx_pkt_cnt++;
32364 /* Increment transaction counter */
32365 writel(2, iadev->dma+IPHASE5575_TX_COUNTER);
32366
32367 #if 0
32368 /* add flow control logic */
32369 - if (atomic_read(&vcc->stats->tx) % 20 == 0) {
32370 + if (atomic_read_unchecked(&vcc->stats->tx) % 20 == 0) {
32371 if (iavcc->vc_desc_cnt > 10) {
32372 vcc->tx_quota = vcc->tx_quota * 3 / 4;
32373 printk("Tx1: vcc->tx_quota = %d \n", (u32)vcc->tx_quota );
32374 diff --git a/drivers/atm/lanai.c b/drivers/atm/lanai.c
32375 index fa7d701..1e404c7 100644
32376 --- a/drivers/atm/lanai.c
32377 +++ b/drivers/atm/lanai.c
32378 @@ -1303,7 +1303,7 @@ static void lanai_send_one_aal5(struct lanai_dev *lanai,
32379 vcc_tx_add_aal5_trailer(lvcc, skb->len, 0, 0);
32380 lanai_endtx(lanai, lvcc);
32381 lanai_free_skb(lvcc->tx.atmvcc, skb);
32382 - atomic_inc(&lvcc->tx.atmvcc->stats->tx);
32383 + atomic_inc_unchecked(&lvcc->tx.atmvcc->stats->tx);
32384 }
32385
32386 /* Try to fill the buffer - don't call unless there is backlog */
32387 @@ -1426,7 +1426,7 @@ static void vcc_rx_aal5(struct lanai_vcc *lvcc, int endptr)
32388 ATM_SKB(skb)->vcc = lvcc->rx.atmvcc;
32389 __net_timestamp(skb);
32390 lvcc->rx.atmvcc->push(lvcc->rx.atmvcc, skb);
32391 - atomic_inc(&lvcc->rx.atmvcc->stats->rx);
32392 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx);
32393 out:
32394 lvcc->rx.buf.ptr = end;
32395 cardvcc_write(lvcc, endptr, vcc_rxreadptr);
32396 @@ -1667,7 +1667,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
32397 DPRINTK("(itf %d) got RX service entry 0x%X for non-AAL5 "
32398 "vcc %d\n", lanai->number, (unsigned int) s, vci);
32399 lanai->stats.service_rxnotaal5++;
32400 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
32401 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
32402 return 0;
32403 }
32404 if (likely(!(s & (SERVICE_TRASH | SERVICE_STREAM | SERVICE_CRCERR)))) {
32405 @@ -1679,7 +1679,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
32406 int bytes;
32407 read_unlock(&vcc_sklist_lock);
32408 DPRINTK("got trashed rx pdu on vci %d\n", vci);
32409 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
32410 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
32411 lvcc->stats.x.aal5.service_trash++;
32412 bytes = (SERVICE_GET_END(s) * 16) -
32413 (((unsigned long) lvcc->rx.buf.ptr) -
32414 @@ -1691,7 +1691,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
32415 }
32416 if (s & SERVICE_STREAM) {
32417 read_unlock(&vcc_sklist_lock);
32418 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
32419 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
32420 lvcc->stats.x.aal5.service_stream++;
32421 printk(KERN_ERR DEV_LABEL "(itf %d): Got AAL5 stream "
32422 "PDU on VCI %d!\n", lanai->number, vci);
32423 @@ -1699,7 +1699,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
32424 return 0;
32425 }
32426 DPRINTK("got rx crc error on vci %d\n", vci);
32427 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
32428 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
32429 lvcc->stats.x.aal5.service_rxcrc++;
32430 lvcc->rx.buf.ptr = &lvcc->rx.buf.start[SERVICE_GET_END(s) * 4];
32431 cardvcc_write(lvcc, SERVICE_GET_END(s), vcc_rxreadptr);
32432 diff --git a/drivers/atm/nicstar.c b/drivers/atm/nicstar.c
32433 index ed1d2b7..8cffc1f 100644
32434 --- a/drivers/atm/nicstar.c
32435 +++ b/drivers/atm/nicstar.c
32436 @@ -1654,7 +1654,7 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
32437 if ((vc = (vc_map *) vcc->dev_data) == NULL) {
32438 printk("nicstar%d: vcc->dev_data == NULL on ns_send().\n",
32439 card->index);
32440 - atomic_inc(&vcc->stats->tx_err);
32441 + atomic_inc_unchecked(&vcc->stats->tx_err);
32442 dev_kfree_skb_any(skb);
32443 return -EINVAL;
32444 }
32445 @@ -1662,7 +1662,7 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
32446 if (!vc->tx) {
32447 printk("nicstar%d: Trying to transmit on a non-tx VC.\n",
32448 card->index);
32449 - atomic_inc(&vcc->stats->tx_err);
32450 + atomic_inc_unchecked(&vcc->stats->tx_err);
32451 dev_kfree_skb_any(skb);
32452 return -EINVAL;
32453 }
32454 @@ -1670,14 +1670,14 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
32455 if (vcc->qos.aal != ATM_AAL5 && vcc->qos.aal != ATM_AAL0) {
32456 printk("nicstar%d: Only AAL0 and AAL5 are supported.\n",
32457 card->index);
32458 - atomic_inc(&vcc->stats->tx_err);
32459 + atomic_inc_unchecked(&vcc->stats->tx_err);
32460 dev_kfree_skb_any(skb);
32461 return -EINVAL;
32462 }
32463
32464 if (skb_shinfo(skb)->nr_frags != 0) {
32465 printk("nicstar%d: No scatter-gather yet.\n", card->index);
32466 - atomic_inc(&vcc->stats->tx_err);
32467 + atomic_inc_unchecked(&vcc->stats->tx_err);
32468 dev_kfree_skb_any(skb);
32469 return -EINVAL;
32470 }
32471 @@ -1725,11 +1725,11 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
32472 }
32473
32474 if (push_scqe(card, vc, scq, &scqe, skb) != 0) {
32475 - atomic_inc(&vcc->stats->tx_err);
32476 + atomic_inc_unchecked(&vcc->stats->tx_err);
32477 dev_kfree_skb_any(skb);
32478 return -EIO;
32479 }
32480 - atomic_inc(&vcc->stats->tx);
32481 + atomic_inc_unchecked(&vcc->stats->tx);
32482
32483 return 0;
32484 }
32485 @@ -2046,14 +2046,14 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32486 printk
32487 ("nicstar%d: Can't allocate buffers for aal0.\n",
32488 card->index);
32489 - atomic_add(i, &vcc->stats->rx_drop);
32490 + atomic_add_unchecked(i, &vcc->stats->rx_drop);
32491 break;
32492 }
32493 if (!atm_charge(vcc, sb->truesize)) {
32494 RXPRINTK
32495 ("nicstar%d: atm_charge() dropped aal0 packets.\n",
32496 card->index);
32497 - atomic_add(i - 1, &vcc->stats->rx_drop); /* already increased by 1 */
32498 + atomic_add_unchecked(i - 1, &vcc->stats->rx_drop); /* already increased by 1 */
32499 dev_kfree_skb_any(sb);
32500 break;
32501 }
32502 @@ -2068,7 +2068,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32503 ATM_SKB(sb)->vcc = vcc;
32504 __net_timestamp(sb);
32505 vcc->push(vcc, sb);
32506 - atomic_inc(&vcc->stats->rx);
32507 + atomic_inc_unchecked(&vcc->stats->rx);
32508 cell += ATM_CELL_PAYLOAD;
32509 }
32510
32511 @@ -2085,7 +2085,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32512 if (iovb == NULL) {
32513 printk("nicstar%d: Out of iovec buffers.\n",
32514 card->index);
32515 - atomic_inc(&vcc->stats->rx_drop);
32516 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32517 recycle_rx_buf(card, skb);
32518 return;
32519 }
32520 @@ -2109,7 +2109,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32521 small or large buffer itself. */
32522 } else if (NS_PRV_IOVCNT(iovb) >= NS_MAX_IOVECS) {
32523 printk("nicstar%d: received too big AAL5 SDU.\n", card->index);
32524 - atomic_inc(&vcc->stats->rx_err);
32525 + atomic_inc_unchecked(&vcc->stats->rx_err);
32526 recycle_iovec_rx_bufs(card, (struct iovec *)iovb->data,
32527 NS_MAX_IOVECS);
32528 NS_PRV_IOVCNT(iovb) = 0;
32529 @@ -2129,7 +2129,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32530 ("nicstar%d: Expected a small buffer, and this is not one.\n",
32531 card->index);
32532 which_list(card, skb);
32533 - atomic_inc(&vcc->stats->rx_err);
32534 + atomic_inc_unchecked(&vcc->stats->rx_err);
32535 recycle_rx_buf(card, skb);
32536 vc->rx_iov = NULL;
32537 recycle_iov_buf(card, iovb);
32538 @@ -2142,7 +2142,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32539 ("nicstar%d: Expected a large buffer, and this is not one.\n",
32540 card->index);
32541 which_list(card, skb);
32542 - atomic_inc(&vcc->stats->rx_err);
32543 + atomic_inc_unchecked(&vcc->stats->rx_err);
32544 recycle_iovec_rx_bufs(card, (struct iovec *)iovb->data,
32545 NS_PRV_IOVCNT(iovb));
32546 vc->rx_iov = NULL;
32547 @@ -2165,7 +2165,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32548 printk(" - PDU size mismatch.\n");
32549 else
32550 printk(".\n");
32551 - atomic_inc(&vcc->stats->rx_err);
32552 + atomic_inc_unchecked(&vcc->stats->rx_err);
32553 recycle_iovec_rx_bufs(card, (struct iovec *)iovb->data,
32554 NS_PRV_IOVCNT(iovb));
32555 vc->rx_iov = NULL;
32556 @@ -2179,7 +2179,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32557 /* skb points to a small buffer */
32558 if (!atm_charge(vcc, skb->truesize)) {
32559 push_rxbufs(card, skb);
32560 - atomic_inc(&vcc->stats->rx_drop);
32561 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32562 } else {
32563 skb_put(skb, len);
32564 dequeue_sm_buf(card, skb);
32565 @@ -2189,7 +2189,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32566 ATM_SKB(skb)->vcc = vcc;
32567 __net_timestamp(skb);
32568 vcc->push(vcc, skb);
32569 - atomic_inc(&vcc->stats->rx);
32570 + atomic_inc_unchecked(&vcc->stats->rx);
32571 }
32572 } else if (NS_PRV_IOVCNT(iovb) == 2) { /* One small plus one large buffer */
32573 struct sk_buff *sb;
32574 @@ -2200,7 +2200,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32575 if (len <= NS_SMBUFSIZE) {
32576 if (!atm_charge(vcc, sb->truesize)) {
32577 push_rxbufs(card, sb);
32578 - atomic_inc(&vcc->stats->rx_drop);
32579 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32580 } else {
32581 skb_put(sb, len);
32582 dequeue_sm_buf(card, sb);
32583 @@ -2210,7 +2210,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32584 ATM_SKB(sb)->vcc = vcc;
32585 __net_timestamp(sb);
32586 vcc->push(vcc, sb);
32587 - atomic_inc(&vcc->stats->rx);
32588 + atomic_inc_unchecked(&vcc->stats->rx);
32589 }
32590
32591 push_rxbufs(card, skb);
32592 @@ -2219,7 +2219,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32593
32594 if (!atm_charge(vcc, skb->truesize)) {
32595 push_rxbufs(card, skb);
32596 - atomic_inc(&vcc->stats->rx_drop);
32597 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32598 } else {
32599 dequeue_lg_buf(card, skb);
32600 #ifdef NS_USE_DESTRUCTORS
32601 @@ -2232,7 +2232,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32602 ATM_SKB(skb)->vcc = vcc;
32603 __net_timestamp(skb);
32604 vcc->push(vcc, skb);
32605 - atomic_inc(&vcc->stats->rx);
32606 + atomic_inc_unchecked(&vcc->stats->rx);
32607 }
32608
32609 push_rxbufs(card, sb);
32610 @@ -2253,7 +2253,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32611 printk
32612 ("nicstar%d: Out of huge buffers.\n",
32613 card->index);
32614 - atomic_inc(&vcc->stats->rx_drop);
32615 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32616 recycle_iovec_rx_bufs(card,
32617 (struct iovec *)
32618 iovb->data,
32619 @@ -2304,7 +2304,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32620 card->hbpool.count++;
32621 } else
32622 dev_kfree_skb_any(hb);
32623 - atomic_inc(&vcc->stats->rx_drop);
32624 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32625 } else {
32626 /* Copy the small buffer to the huge buffer */
32627 sb = (struct sk_buff *)iov->iov_base;
32628 @@ -2341,7 +2341,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32629 #endif /* NS_USE_DESTRUCTORS */
32630 __net_timestamp(hb);
32631 vcc->push(vcc, hb);
32632 - atomic_inc(&vcc->stats->rx);
32633 + atomic_inc_unchecked(&vcc->stats->rx);
32634 }
32635 }
32636
32637 diff --git a/drivers/atm/solos-pci.c b/drivers/atm/solos-pci.c
32638 index 0474a89..06ea4a1 100644
32639 --- a/drivers/atm/solos-pci.c
32640 +++ b/drivers/atm/solos-pci.c
32641 @@ -838,7 +838,7 @@ void solos_bh(unsigned long card_arg)
32642 }
32643 atm_charge(vcc, skb->truesize);
32644 vcc->push(vcc, skb);
32645 - atomic_inc(&vcc->stats->rx);
32646 + atomic_inc_unchecked(&vcc->stats->rx);
32647 break;
32648
32649 case PKT_STATUS:
32650 @@ -1117,7 +1117,7 @@ static uint32_t fpga_tx(struct solos_card *card)
32651 vcc = SKB_CB(oldskb)->vcc;
32652
32653 if (vcc) {
32654 - atomic_inc(&vcc->stats->tx);
32655 + atomic_inc_unchecked(&vcc->stats->tx);
32656 solos_pop(vcc, oldskb);
32657 } else {
32658 dev_kfree_skb_irq(oldskb);
32659 diff --git a/drivers/atm/suni.c b/drivers/atm/suni.c
32660 index 0215934..ce9f5b1 100644
32661 --- a/drivers/atm/suni.c
32662 +++ b/drivers/atm/suni.c
32663 @@ -49,8 +49,8 @@ static DEFINE_SPINLOCK(sunis_lock);
32664
32665
32666 #define ADD_LIMITED(s,v) \
32667 - atomic_add((v),&stats->s); \
32668 - if (atomic_read(&stats->s) < 0) atomic_set(&stats->s,INT_MAX);
32669 + atomic_add_unchecked((v),&stats->s); \
32670 + if (atomic_read_unchecked(&stats->s) < 0) atomic_set_unchecked(&stats->s,INT_MAX);
32671
32672
32673 static void suni_hz(unsigned long from_timer)
32674 diff --git a/drivers/atm/uPD98402.c b/drivers/atm/uPD98402.c
32675 index 5120a96..e2572bd 100644
32676 --- a/drivers/atm/uPD98402.c
32677 +++ b/drivers/atm/uPD98402.c
32678 @@ -42,7 +42,7 @@ static int fetch_stats(struct atm_dev *dev,struct sonet_stats __user *arg,int ze
32679 struct sonet_stats tmp;
32680 int error = 0;
32681
32682 - atomic_add(GET(HECCT),&PRIV(dev)->sonet_stats.uncorr_hcs);
32683 + atomic_add_unchecked(GET(HECCT),&PRIV(dev)->sonet_stats.uncorr_hcs);
32684 sonet_copy_stats(&PRIV(dev)->sonet_stats,&tmp);
32685 if (arg) error = copy_to_user(arg,&tmp,sizeof(tmp));
32686 if (zero && !error) {
32687 @@ -161,9 +161,9 @@ static int uPD98402_ioctl(struct atm_dev *dev,unsigned int cmd,void __user *arg)
32688
32689
32690 #define ADD_LIMITED(s,v) \
32691 - { atomic_add(GET(v),&PRIV(dev)->sonet_stats.s); \
32692 - if (atomic_read(&PRIV(dev)->sonet_stats.s) < 0) \
32693 - atomic_set(&PRIV(dev)->sonet_stats.s,INT_MAX); }
32694 + { atomic_add_unchecked(GET(v),&PRIV(dev)->sonet_stats.s); \
32695 + if (atomic_read_unchecked(&PRIV(dev)->sonet_stats.s) < 0) \
32696 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.s,INT_MAX); }
32697
32698
32699 static void stat_event(struct atm_dev *dev)
32700 @@ -194,7 +194,7 @@ static void uPD98402_int(struct atm_dev *dev)
32701 if (reason & uPD98402_INT_PFM) stat_event(dev);
32702 if (reason & uPD98402_INT_PCO) {
32703 (void) GET(PCOCR); /* clear interrupt cause */
32704 - atomic_add(GET(HECCT),
32705 + atomic_add_unchecked(GET(HECCT),
32706 &PRIV(dev)->sonet_stats.uncorr_hcs);
32707 }
32708 if ((reason & uPD98402_INT_RFO) &&
32709 @@ -222,9 +222,9 @@ static int uPD98402_start(struct atm_dev *dev)
32710 PUT(~(uPD98402_INT_PFM | uPD98402_INT_ALM | uPD98402_INT_RFO |
32711 uPD98402_INT_LOS),PIMR); /* enable them */
32712 (void) fetch_stats(dev,NULL,1); /* clear kernel counters */
32713 - atomic_set(&PRIV(dev)->sonet_stats.corr_hcs,-1);
32714 - atomic_set(&PRIV(dev)->sonet_stats.tx_cells,-1);
32715 - atomic_set(&PRIV(dev)->sonet_stats.rx_cells,-1);
32716 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.corr_hcs,-1);
32717 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.tx_cells,-1);
32718 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.rx_cells,-1);
32719 return 0;
32720 }
32721
32722 diff --git a/drivers/atm/zatm.c b/drivers/atm/zatm.c
32723 index 969c3c2..9b72956 100644
32724 --- a/drivers/atm/zatm.c
32725 +++ b/drivers/atm/zatm.c
32726 @@ -459,7 +459,7 @@ printk("dummy: 0x%08lx, 0x%08lx\n",dummy[0],dummy[1]);
32727 }
32728 if (!size) {
32729 dev_kfree_skb_irq(skb);
32730 - if (vcc) atomic_inc(&vcc->stats->rx_err);
32731 + if (vcc) atomic_inc_unchecked(&vcc->stats->rx_err);
32732 continue;
32733 }
32734 if (!atm_charge(vcc,skb->truesize)) {
32735 @@ -469,7 +469,7 @@ printk("dummy: 0x%08lx, 0x%08lx\n",dummy[0],dummy[1]);
32736 skb->len = size;
32737 ATM_SKB(skb)->vcc = vcc;
32738 vcc->push(vcc,skb);
32739 - atomic_inc(&vcc->stats->rx);
32740 + atomic_inc_unchecked(&vcc->stats->rx);
32741 }
32742 zout(pos & 0xffff,MTA(mbx));
32743 #if 0 /* probably a stupid idea */
32744 @@ -733,7 +733,7 @@ if (*ZATM_PRV_DSC(skb) != (uPD98401_TXPD_V | uPD98401_TXPD_DP |
32745 skb_queue_head(&zatm_vcc->backlog,skb);
32746 break;
32747 }
32748 - atomic_inc(&vcc->stats->tx);
32749 + atomic_inc_unchecked(&vcc->stats->tx);
32750 wake_up(&zatm_vcc->tx_wait);
32751 }
32752
32753 diff --git a/drivers/base/bus.c b/drivers/base/bus.c
32754 index 6856303..0602d70 100644
32755 --- a/drivers/base/bus.c
32756 +++ b/drivers/base/bus.c
32757 @@ -1163,7 +1163,7 @@ int subsys_interface_register(struct subsys_interface *sif)
32758 return -EINVAL;
32759
32760 mutex_lock(&subsys->p->mutex);
32761 - list_add_tail(&sif->node, &subsys->p->interfaces);
32762 + pax_list_add_tail((struct list_head *)&sif->node, &subsys->p->interfaces);
32763 if (sif->add_dev) {
32764 subsys_dev_iter_init(&iter, subsys, NULL, NULL);
32765 while ((dev = subsys_dev_iter_next(&iter)))
32766 @@ -1188,7 +1188,7 @@ void subsys_interface_unregister(struct subsys_interface *sif)
32767 subsys = sif->subsys;
32768
32769 mutex_lock(&subsys->p->mutex);
32770 - list_del_init(&sif->node);
32771 + pax_list_del_init((struct list_head *)&sif->node);
32772 if (sif->remove_dev) {
32773 subsys_dev_iter_init(&iter, subsys, NULL, NULL);
32774 while ((dev = subsys_dev_iter_next(&iter)))
32775 diff --git a/drivers/base/devtmpfs.c b/drivers/base/devtmpfs.c
32776 index 17cf7ca..7e553e1 100644
32777 --- a/drivers/base/devtmpfs.c
32778 +++ b/drivers/base/devtmpfs.c
32779 @@ -347,7 +347,7 @@ int devtmpfs_mount(const char *mntdir)
32780 if (!thread)
32781 return 0;
32782
32783 - err = sys_mount("devtmpfs", (char *)mntdir, "devtmpfs", MS_SILENT, NULL);
32784 + err = sys_mount((char __force_user *)"devtmpfs", (char __force_user *)mntdir, (char __force_user *)"devtmpfs", MS_SILENT, NULL);
32785 if (err)
32786 printk(KERN_INFO "devtmpfs: error mounting %i\n", err);
32787 else
32788 diff --git a/drivers/base/node.c b/drivers/base/node.c
32789 index fac124a..66bd4ab 100644
32790 --- a/drivers/base/node.c
32791 +++ b/drivers/base/node.c
32792 @@ -625,7 +625,7 @@ static ssize_t print_nodes_state(enum node_states state, char *buf)
32793 struct node_attr {
32794 struct device_attribute attr;
32795 enum node_states state;
32796 -};
32797 +} __do_const;
32798
32799 static ssize_t show_node_state(struct device *dev,
32800 struct device_attribute *attr, char *buf)
32801 diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c
32802 index acc3a8d..981c236 100644
32803 --- a/drivers/base/power/domain.c
32804 +++ b/drivers/base/power/domain.c
32805 @@ -1851,7 +1851,7 @@ int pm_genpd_attach_cpuidle(struct generic_pm_domain *genpd, int state)
32806 {
32807 struct cpuidle_driver *cpuidle_drv;
32808 struct gpd_cpu_data *cpu_data;
32809 - struct cpuidle_state *idle_state;
32810 + cpuidle_state_no_const *idle_state;
32811 int ret = 0;
32812
32813 if (IS_ERR_OR_NULL(genpd) || state < 0)
32814 @@ -1919,7 +1919,7 @@ int pm_genpd_name_attach_cpuidle(const char *name, int state)
32815 int pm_genpd_detach_cpuidle(struct generic_pm_domain *genpd)
32816 {
32817 struct gpd_cpu_data *cpu_data;
32818 - struct cpuidle_state *idle_state;
32819 + cpuidle_state_no_const *idle_state;
32820 int ret = 0;
32821
32822 if (IS_ERR_OR_NULL(genpd))
32823 diff --git a/drivers/base/power/wakeup.c b/drivers/base/power/wakeup.c
32824 index e6ee5e8..98ad7fc 100644
32825 --- a/drivers/base/power/wakeup.c
32826 +++ b/drivers/base/power/wakeup.c
32827 @@ -29,14 +29,14 @@ bool events_check_enabled __read_mostly;
32828 * They need to be modified together atomically, so it's better to use one
32829 * atomic variable to hold them both.
32830 */
32831 -static atomic_t combined_event_count = ATOMIC_INIT(0);
32832 +static atomic_unchecked_t combined_event_count = ATOMIC_INIT(0);
32833
32834 #define IN_PROGRESS_BITS (sizeof(int) * 4)
32835 #define MAX_IN_PROGRESS ((1 << IN_PROGRESS_BITS) - 1)
32836
32837 static void split_counters(unsigned int *cnt, unsigned int *inpr)
32838 {
32839 - unsigned int comb = atomic_read(&combined_event_count);
32840 + unsigned int comb = atomic_read_unchecked(&combined_event_count);
32841
32842 *cnt = (comb >> IN_PROGRESS_BITS);
32843 *inpr = comb & MAX_IN_PROGRESS;
32844 @@ -389,7 +389,7 @@ static void wakeup_source_activate(struct wakeup_source *ws)
32845 ws->start_prevent_time = ws->last_time;
32846
32847 /* Increment the counter of events in progress. */
32848 - cec = atomic_inc_return(&combined_event_count);
32849 + cec = atomic_inc_return_unchecked(&combined_event_count);
32850
32851 trace_wakeup_source_activate(ws->name, cec);
32852 }
32853 @@ -515,7 +515,7 @@ static void wakeup_source_deactivate(struct wakeup_source *ws)
32854 * Increment the counter of registered wakeup events and decrement the
32855 * couter of wakeup events in progress simultaneously.
32856 */
32857 - cec = atomic_add_return(MAX_IN_PROGRESS, &combined_event_count);
32858 + cec = atomic_add_return_unchecked(MAX_IN_PROGRESS, &combined_event_count);
32859 trace_wakeup_source_deactivate(ws->name, cec);
32860
32861 split_counters(&cnt, &inpr);
32862 diff --git a/drivers/base/syscore.c b/drivers/base/syscore.c
32863 index e8d11b6..7b1b36f 100644
32864 --- a/drivers/base/syscore.c
32865 +++ b/drivers/base/syscore.c
32866 @@ -21,7 +21,7 @@ static DEFINE_MUTEX(syscore_ops_lock);
32867 void register_syscore_ops(struct syscore_ops *ops)
32868 {
32869 mutex_lock(&syscore_ops_lock);
32870 - list_add_tail(&ops->node, &syscore_ops_list);
32871 + pax_list_add_tail((struct list_head *)&ops->node, &syscore_ops_list);
32872 mutex_unlock(&syscore_ops_lock);
32873 }
32874 EXPORT_SYMBOL_GPL(register_syscore_ops);
32875 @@ -33,7 +33,7 @@ EXPORT_SYMBOL_GPL(register_syscore_ops);
32876 void unregister_syscore_ops(struct syscore_ops *ops)
32877 {
32878 mutex_lock(&syscore_ops_lock);
32879 - list_del(&ops->node);
32880 + pax_list_del((struct list_head *)&ops->node);
32881 mutex_unlock(&syscore_ops_lock);
32882 }
32883 EXPORT_SYMBOL_GPL(unregister_syscore_ops);
32884 diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c
32885 index ade58bc..867143d 100644
32886 --- a/drivers/block/cciss.c
32887 +++ b/drivers/block/cciss.c
32888 @@ -1196,6 +1196,8 @@ static int cciss_ioctl32_passthru(struct block_device *bdev, fmode_t mode,
32889 int err;
32890 u32 cp;
32891
32892 + memset(&arg64, 0, sizeof(arg64));
32893 +
32894 err = 0;
32895 err |=
32896 copy_from_user(&arg64.LUN_info, &arg32->LUN_info,
32897 @@ -3005,7 +3007,7 @@ static void start_io(ctlr_info_t *h)
32898 while (!list_empty(&h->reqQ)) {
32899 c = list_entry(h->reqQ.next, CommandList_struct, list);
32900 /* can't do anything if fifo is full */
32901 - if ((h->access.fifo_full(h))) {
32902 + if ((h->access->fifo_full(h))) {
32903 dev_warn(&h->pdev->dev, "fifo full\n");
32904 break;
32905 }
32906 @@ -3015,7 +3017,7 @@ static void start_io(ctlr_info_t *h)
32907 h->Qdepth--;
32908
32909 /* Tell the controller execute command */
32910 - h->access.submit_command(h, c);
32911 + h->access->submit_command(h, c);
32912
32913 /* Put job onto the completed Q */
32914 addQ(&h->cmpQ, c);
32915 @@ -3441,17 +3443,17 @@ startio:
32916
32917 static inline unsigned long get_next_completion(ctlr_info_t *h)
32918 {
32919 - return h->access.command_completed(h);
32920 + return h->access->command_completed(h);
32921 }
32922
32923 static inline int interrupt_pending(ctlr_info_t *h)
32924 {
32925 - return h->access.intr_pending(h);
32926 + return h->access->intr_pending(h);
32927 }
32928
32929 static inline long interrupt_not_for_us(ctlr_info_t *h)
32930 {
32931 - return ((h->access.intr_pending(h) == 0) ||
32932 + return ((h->access->intr_pending(h) == 0) ||
32933 (h->interrupts_enabled == 0));
32934 }
32935
32936 @@ -3484,7 +3486,7 @@ static inline u32 next_command(ctlr_info_t *h)
32937 u32 a;
32938
32939 if (unlikely(!(h->transMethod & CFGTBL_Trans_Performant)))
32940 - return h->access.command_completed(h);
32941 + return h->access->command_completed(h);
32942
32943 if ((*(h->reply_pool_head) & 1) == (h->reply_pool_wraparound)) {
32944 a = *(h->reply_pool_head); /* Next cmd in ring buffer */
32945 @@ -4041,7 +4043,7 @@ static void cciss_put_controller_into_performant_mode(ctlr_info_t *h)
32946 trans_support & CFGTBL_Trans_use_short_tags);
32947
32948 /* Change the access methods to the performant access methods */
32949 - h->access = SA5_performant_access;
32950 + h->access = &SA5_performant_access;
32951 h->transMethod = CFGTBL_Trans_Performant;
32952
32953 return;
32954 @@ -4310,7 +4312,7 @@ static int cciss_pci_init(ctlr_info_t *h)
32955 if (prod_index < 0)
32956 return -ENODEV;
32957 h->product_name = products[prod_index].product_name;
32958 - h->access = *(products[prod_index].access);
32959 + h->access = products[prod_index].access;
32960
32961 if (cciss_board_disabled(h)) {
32962 dev_warn(&h->pdev->dev, "controller appears to be disabled\n");
32963 @@ -5032,7 +5034,7 @@ reinit_after_soft_reset:
32964 }
32965
32966 /* make sure the board interrupts are off */
32967 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
32968 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
32969 rc = cciss_request_irq(h, do_cciss_msix_intr, do_cciss_intx);
32970 if (rc)
32971 goto clean2;
32972 @@ -5082,7 +5084,7 @@ reinit_after_soft_reset:
32973 * fake ones to scoop up any residual completions.
32974 */
32975 spin_lock_irqsave(&h->lock, flags);
32976 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
32977 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
32978 spin_unlock_irqrestore(&h->lock, flags);
32979 free_irq(h->intr[h->intr_mode], h);
32980 rc = cciss_request_irq(h, cciss_msix_discard_completions,
32981 @@ -5102,9 +5104,9 @@ reinit_after_soft_reset:
32982 dev_info(&h->pdev->dev, "Board READY.\n");
32983 dev_info(&h->pdev->dev,
32984 "Waiting for stale completions to drain.\n");
32985 - h->access.set_intr_mask(h, CCISS_INTR_ON);
32986 + h->access->set_intr_mask(h, CCISS_INTR_ON);
32987 msleep(10000);
32988 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
32989 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
32990
32991 rc = controller_reset_failed(h->cfgtable);
32992 if (rc)
32993 @@ -5127,7 +5129,7 @@ reinit_after_soft_reset:
32994 cciss_scsi_setup(h);
32995
32996 /* Turn the interrupts on so we can service requests */
32997 - h->access.set_intr_mask(h, CCISS_INTR_ON);
32998 + h->access->set_intr_mask(h, CCISS_INTR_ON);
32999
33000 /* Get the firmware version */
33001 inq_buff = kzalloc(sizeof(InquiryData_struct), GFP_KERNEL);
33002 @@ -5199,7 +5201,7 @@ static void cciss_shutdown(struct pci_dev *pdev)
33003 kfree(flush_buf);
33004 if (return_code != IO_OK)
33005 dev_warn(&h->pdev->dev, "Error flushing cache\n");
33006 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
33007 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
33008 free_irq(h->intr[h->intr_mode], h);
33009 }
33010
33011 diff --git a/drivers/block/cciss.h b/drivers/block/cciss.h
33012 index 7fda30e..eb5dfe0 100644
33013 --- a/drivers/block/cciss.h
33014 +++ b/drivers/block/cciss.h
33015 @@ -101,7 +101,7 @@ struct ctlr_info
33016 /* information about each logical volume */
33017 drive_info_struct *drv[CISS_MAX_LUN];
33018
33019 - struct access_method access;
33020 + struct access_method *access;
33021
33022 /* queue and queue Info */
33023 struct list_head reqQ;
33024 diff --git a/drivers/block/cpqarray.c b/drivers/block/cpqarray.c
33025 index 3f08713..56a586a 100644
33026 --- a/drivers/block/cpqarray.c
33027 +++ b/drivers/block/cpqarray.c
33028 @@ -404,7 +404,7 @@ static int cpqarray_register_ctlr(int i, struct pci_dev *pdev)
33029 if (register_blkdev(COMPAQ_SMART2_MAJOR+i, hba[i]->devname)) {
33030 goto Enomem4;
33031 }
33032 - hba[i]->access.set_intr_mask(hba[i], 0);
33033 + hba[i]->access->set_intr_mask(hba[i], 0);
33034 if (request_irq(hba[i]->intr, do_ida_intr,
33035 IRQF_DISABLED|IRQF_SHARED, hba[i]->devname, hba[i]))
33036 {
33037 @@ -459,7 +459,7 @@ static int cpqarray_register_ctlr(int i, struct pci_dev *pdev)
33038 add_timer(&hba[i]->timer);
33039
33040 /* Enable IRQ now that spinlock and rate limit timer are set up */
33041 - hba[i]->access.set_intr_mask(hba[i], FIFO_NOT_EMPTY);
33042 + hba[i]->access->set_intr_mask(hba[i], FIFO_NOT_EMPTY);
33043
33044 for(j=0; j<NWD; j++) {
33045 struct gendisk *disk = ida_gendisk[i][j];
33046 @@ -694,7 +694,7 @@ DBGINFO(
33047 for(i=0; i<NR_PRODUCTS; i++) {
33048 if (board_id == products[i].board_id) {
33049 c->product_name = products[i].product_name;
33050 - c->access = *(products[i].access);
33051 + c->access = products[i].access;
33052 break;
33053 }
33054 }
33055 @@ -792,7 +792,7 @@ static int cpqarray_eisa_detect(void)
33056 hba[ctlr]->intr = intr;
33057 sprintf(hba[ctlr]->devname, "ida%d", nr_ctlr);
33058 hba[ctlr]->product_name = products[j].product_name;
33059 - hba[ctlr]->access = *(products[j].access);
33060 + hba[ctlr]->access = products[j].access;
33061 hba[ctlr]->ctlr = ctlr;
33062 hba[ctlr]->board_id = board_id;
33063 hba[ctlr]->pci_dev = NULL; /* not PCI */
33064 @@ -980,7 +980,7 @@ static void start_io(ctlr_info_t *h)
33065
33066 while((c = h->reqQ) != NULL) {
33067 /* Can't do anything if we're busy */
33068 - if (h->access.fifo_full(h) == 0)
33069 + if (h->access->fifo_full(h) == 0)
33070 return;
33071
33072 /* Get the first entry from the request Q */
33073 @@ -988,7 +988,7 @@ static void start_io(ctlr_info_t *h)
33074 h->Qdepth--;
33075
33076 /* Tell the controller to do our bidding */
33077 - h->access.submit_command(h, c);
33078 + h->access->submit_command(h, c);
33079
33080 /* Get onto the completion Q */
33081 addQ(&h->cmpQ, c);
33082 @@ -1050,7 +1050,7 @@ static irqreturn_t do_ida_intr(int irq, void *dev_id)
33083 unsigned long flags;
33084 __u32 a,a1;
33085
33086 - istat = h->access.intr_pending(h);
33087 + istat = h->access->intr_pending(h);
33088 /* Is this interrupt for us? */
33089 if (istat == 0)
33090 return IRQ_NONE;
33091 @@ -1061,7 +1061,7 @@ static irqreturn_t do_ida_intr(int irq, void *dev_id)
33092 */
33093 spin_lock_irqsave(IDA_LOCK(h->ctlr), flags);
33094 if (istat & FIFO_NOT_EMPTY) {
33095 - while((a = h->access.command_completed(h))) {
33096 + while((a = h->access->command_completed(h))) {
33097 a1 = a; a &= ~3;
33098 if ((c = h->cmpQ) == NULL)
33099 {
33100 @@ -1449,11 +1449,11 @@ static int sendcmd(
33101 /*
33102 * Disable interrupt
33103 */
33104 - info_p->access.set_intr_mask(info_p, 0);
33105 + info_p->access->set_intr_mask(info_p, 0);
33106 /* Make sure there is room in the command FIFO */
33107 /* Actually it should be completely empty at this time. */
33108 for (i = 200000; i > 0; i--) {
33109 - temp = info_p->access.fifo_full(info_p);
33110 + temp = info_p->access->fifo_full(info_p);
33111 if (temp != 0) {
33112 break;
33113 }
33114 @@ -1466,7 +1466,7 @@ DBG(
33115 /*
33116 * Send the cmd
33117 */
33118 - info_p->access.submit_command(info_p, c);
33119 + info_p->access->submit_command(info_p, c);
33120 complete = pollcomplete(ctlr);
33121
33122 pci_unmap_single(info_p->pci_dev, (dma_addr_t) c->req.sg[0].addr,
33123 @@ -1549,9 +1549,9 @@ static int revalidate_allvol(ctlr_info_t *host)
33124 * we check the new geometry. Then turn interrupts back on when
33125 * we're done.
33126 */
33127 - host->access.set_intr_mask(host, 0);
33128 + host->access->set_intr_mask(host, 0);
33129 getgeometry(ctlr);
33130 - host->access.set_intr_mask(host, FIFO_NOT_EMPTY);
33131 + host->access->set_intr_mask(host, FIFO_NOT_EMPTY);
33132
33133 for(i=0; i<NWD; i++) {
33134 struct gendisk *disk = ida_gendisk[ctlr][i];
33135 @@ -1591,7 +1591,7 @@ static int pollcomplete(int ctlr)
33136 /* Wait (up to 2 seconds) for a command to complete */
33137
33138 for (i = 200000; i > 0; i--) {
33139 - done = hba[ctlr]->access.command_completed(hba[ctlr]);
33140 + done = hba[ctlr]->access->command_completed(hba[ctlr]);
33141 if (done == 0) {
33142 udelay(10); /* a short fixed delay */
33143 } else
33144 diff --git a/drivers/block/cpqarray.h b/drivers/block/cpqarray.h
33145 index be73e9d..7fbf140 100644
33146 --- a/drivers/block/cpqarray.h
33147 +++ b/drivers/block/cpqarray.h
33148 @@ -99,7 +99,7 @@ struct ctlr_info {
33149 drv_info_t drv[NWD];
33150 struct proc_dir_entry *proc;
33151
33152 - struct access_method access;
33153 + struct access_method *access;
33154
33155 cmdlist_t *reqQ;
33156 cmdlist_t *cmpQ;
33157 diff --git a/drivers/block/drbd/drbd_int.h b/drivers/block/drbd/drbd_int.h
33158 index 6b51afa..17e1191 100644
33159 --- a/drivers/block/drbd/drbd_int.h
33160 +++ b/drivers/block/drbd/drbd_int.h
33161 @@ -582,7 +582,7 @@ struct drbd_epoch {
33162 struct drbd_tconn *tconn;
33163 struct list_head list;
33164 unsigned int barrier_nr;
33165 - atomic_t epoch_size; /* increased on every request added. */
33166 + atomic_unchecked_t epoch_size; /* increased on every request added. */
33167 atomic_t active; /* increased on every req. added, and dec on every finished. */
33168 unsigned long flags;
33169 };
33170 @@ -1011,7 +1011,7 @@ struct drbd_conf {
33171 int al_tr_cycle;
33172 int al_tr_pos; /* position of the next transaction in the journal */
33173 wait_queue_head_t seq_wait;
33174 - atomic_t packet_seq;
33175 + atomic_unchecked_t packet_seq;
33176 unsigned int peer_seq;
33177 spinlock_t peer_seq_lock;
33178 unsigned int minor;
33179 @@ -1527,7 +1527,7 @@ static inline int drbd_setsockopt(struct socket *sock, int level, int optname,
33180 char __user *uoptval;
33181 int err;
33182
33183 - uoptval = (char __user __force *)optval;
33184 + uoptval = (char __force_user *)optval;
33185
33186 set_fs(KERNEL_DS);
33187 if (level == SOL_SOCKET)
33188 diff --git a/drivers/block/drbd/drbd_main.c b/drivers/block/drbd/drbd_main.c
33189 index 8c13eeb..217adee 100644
33190 --- a/drivers/block/drbd/drbd_main.c
33191 +++ b/drivers/block/drbd/drbd_main.c
33192 @@ -1317,7 +1317,7 @@ static int _drbd_send_ack(struct drbd_conf *mdev, enum drbd_packet cmd,
33193 p->sector = sector;
33194 p->block_id = block_id;
33195 p->blksize = blksize;
33196 - p->seq_num = cpu_to_be32(atomic_inc_return(&mdev->packet_seq));
33197 + p->seq_num = cpu_to_be32(atomic_inc_return_unchecked(&mdev->packet_seq));
33198 return drbd_send_command(mdev, sock, cmd, sizeof(*p), NULL, 0);
33199 }
33200
33201 @@ -1619,7 +1619,7 @@ int drbd_send_dblock(struct drbd_conf *mdev, struct drbd_request *req)
33202 return -EIO;
33203 p->sector = cpu_to_be64(req->i.sector);
33204 p->block_id = (unsigned long)req;
33205 - p->seq_num = cpu_to_be32(atomic_inc_return(&mdev->packet_seq));
33206 + p->seq_num = cpu_to_be32(atomic_inc_return_unchecked(&mdev->packet_seq));
33207 dp_flags = bio_flags_to_wire(mdev, req->master_bio->bi_rw);
33208 if (mdev->state.conn >= C_SYNC_SOURCE &&
33209 mdev->state.conn <= C_PAUSED_SYNC_T)
33210 @@ -2574,8 +2574,8 @@ void conn_destroy(struct kref *kref)
33211 {
33212 struct drbd_tconn *tconn = container_of(kref, struct drbd_tconn, kref);
33213
33214 - if (atomic_read(&tconn->current_epoch->epoch_size) != 0)
33215 - conn_err(tconn, "epoch_size:%d\n", atomic_read(&tconn->current_epoch->epoch_size));
33216 + if (atomic_read_unchecked(&tconn->current_epoch->epoch_size) != 0)
33217 + conn_err(tconn, "epoch_size:%d\n", atomic_read_unchecked(&tconn->current_epoch->epoch_size));
33218 kfree(tconn->current_epoch);
33219
33220 idr_destroy(&tconn->volumes);
33221 diff --git a/drivers/block/drbd/drbd_receiver.c b/drivers/block/drbd/drbd_receiver.c
33222 index a9eccfc..f5efe87 100644
33223 --- a/drivers/block/drbd/drbd_receiver.c
33224 +++ b/drivers/block/drbd/drbd_receiver.c
33225 @@ -833,7 +833,7 @@ int drbd_connected(struct drbd_conf *mdev)
33226 {
33227 int err;
33228
33229 - atomic_set(&mdev->packet_seq, 0);
33230 + atomic_set_unchecked(&mdev->packet_seq, 0);
33231 mdev->peer_seq = 0;
33232
33233 mdev->state_mutex = mdev->tconn->agreed_pro_version < 100 ?
33234 @@ -1191,7 +1191,7 @@ static enum finish_epoch drbd_may_finish_epoch(struct drbd_tconn *tconn,
33235 do {
33236 next_epoch = NULL;
33237
33238 - epoch_size = atomic_read(&epoch->epoch_size);
33239 + epoch_size = atomic_read_unchecked(&epoch->epoch_size);
33240
33241 switch (ev & ~EV_CLEANUP) {
33242 case EV_PUT:
33243 @@ -1231,7 +1231,7 @@ static enum finish_epoch drbd_may_finish_epoch(struct drbd_tconn *tconn,
33244 rv = FE_DESTROYED;
33245 } else {
33246 epoch->flags = 0;
33247 - atomic_set(&epoch->epoch_size, 0);
33248 + atomic_set_unchecked(&epoch->epoch_size, 0);
33249 /* atomic_set(&epoch->active, 0); is already zero */
33250 if (rv == FE_STILL_LIVE)
33251 rv = FE_RECYCLED;
33252 @@ -1449,7 +1449,7 @@ static int receive_Barrier(struct drbd_tconn *tconn, struct packet_info *pi)
33253 conn_wait_active_ee_empty(tconn);
33254 drbd_flush(tconn);
33255
33256 - if (atomic_read(&tconn->current_epoch->epoch_size)) {
33257 + if (atomic_read_unchecked(&tconn->current_epoch->epoch_size)) {
33258 epoch = kmalloc(sizeof(struct drbd_epoch), GFP_NOIO);
33259 if (epoch)
33260 break;
33261 @@ -1462,11 +1462,11 @@ static int receive_Barrier(struct drbd_tconn *tconn, struct packet_info *pi)
33262 }
33263
33264 epoch->flags = 0;
33265 - atomic_set(&epoch->epoch_size, 0);
33266 + atomic_set_unchecked(&epoch->epoch_size, 0);
33267 atomic_set(&epoch->active, 0);
33268
33269 spin_lock(&tconn->epoch_lock);
33270 - if (atomic_read(&tconn->current_epoch->epoch_size)) {
33271 + if (atomic_read_unchecked(&tconn->current_epoch->epoch_size)) {
33272 list_add(&epoch->list, &tconn->current_epoch->list);
33273 tconn->current_epoch = epoch;
33274 tconn->epochs++;
33275 @@ -2170,7 +2170,7 @@ static int receive_Data(struct drbd_tconn *tconn, struct packet_info *pi)
33276
33277 err = wait_for_and_update_peer_seq(mdev, peer_seq);
33278 drbd_send_ack_dp(mdev, P_NEG_ACK, p, pi->size);
33279 - atomic_inc(&tconn->current_epoch->epoch_size);
33280 + atomic_inc_unchecked(&tconn->current_epoch->epoch_size);
33281 err2 = drbd_drain_block(mdev, pi->size);
33282 if (!err)
33283 err = err2;
33284 @@ -2204,7 +2204,7 @@ static int receive_Data(struct drbd_tconn *tconn, struct packet_info *pi)
33285
33286 spin_lock(&tconn->epoch_lock);
33287 peer_req->epoch = tconn->current_epoch;
33288 - atomic_inc(&peer_req->epoch->epoch_size);
33289 + atomic_inc_unchecked(&peer_req->epoch->epoch_size);
33290 atomic_inc(&peer_req->epoch->active);
33291 spin_unlock(&tconn->epoch_lock);
33292
33293 @@ -4346,7 +4346,7 @@ struct data_cmd {
33294 int expect_payload;
33295 size_t pkt_size;
33296 int (*fn)(struct drbd_tconn *, struct packet_info *);
33297 -};
33298 +} __do_const;
33299
33300 static struct data_cmd drbd_cmd_handler[] = {
33301 [P_DATA] = { 1, sizeof(struct p_data), receive_Data },
33302 @@ -4466,7 +4466,7 @@ static void conn_disconnect(struct drbd_tconn *tconn)
33303 if (!list_empty(&tconn->current_epoch->list))
33304 conn_err(tconn, "ASSERTION FAILED: tconn->current_epoch->list not empty\n");
33305 /* ok, no more ee's on the fly, it is safe to reset the epoch_size */
33306 - atomic_set(&tconn->current_epoch->epoch_size, 0);
33307 + atomic_set_unchecked(&tconn->current_epoch->epoch_size, 0);
33308 tconn->send.seen_any_write_yet = false;
33309
33310 conn_info(tconn, "Connection closed\n");
33311 @@ -5222,7 +5222,7 @@ static int tconn_finish_peer_reqs(struct drbd_tconn *tconn)
33312 struct asender_cmd {
33313 size_t pkt_size;
33314 int (*fn)(struct drbd_tconn *tconn, struct packet_info *);
33315 -};
33316 +} __do_const;
33317
33318 static struct asender_cmd asender_tbl[] = {
33319 [P_PING] = { 0, got_Ping },
33320 diff --git a/drivers/block/loop.c b/drivers/block/loop.c
33321 index ae12512..37fa397 100644
33322 --- a/drivers/block/loop.c
33323 +++ b/drivers/block/loop.c
33324 @@ -226,7 +226,7 @@ static int __do_lo_send_write(struct file *file,
33325 mm_segment_t old_fs = get_fs();
33326
33327 set_fs(get_ds());
33328 - bw = file->f_op->write(file, buf, len, &pos);
33329 + bw = file->f_op->write(file, (const char __force_user *)buf, len, &pos);
33330 set_fs(old_fs);
33331 if (likely(bw == len))
33332 return 0;
33333 diff --git a/drivers/cdrom/cdrom.c b/drivers/cdrom/cdrom.c
33334 index d620b44..587561e 100644
33335 --- a/drivers/cdrom/cdrom.c
33336 +++ b/drivers/cdrom/cdrom.c
33337 @@ -416,7 +416,6 @@ int register_cdrom(struct cdrom_device_info *cdi)
33338 ENSURE(reset, CDC_RESET);
33339 ENSURE(generic_packet, CDC_GENERIC_PACKET);
33340 cdi->mc_flags = 0;
33341 - cdo->n_minors = 0;
33342 cdi->options = CDO_USE_FFLAGS;
33343
33344 if (autoclose==1 && CDROM_CAN(CDC_CLOSE_TRAY))
33345 @@ -436,8 +435,11 @@ int register_cdrom(struct cdrom_device_info *cdi)
33346 else
33347 cdi->cdda_method = CDDA_OLD;
33348
33349 - if (!cdo->generic_packet)
33350 - cdo->generic_packet = cdrom_dummy_generic_packet;
33351 + if (!cdo->generic_packet) {
33352 + pax_open_kernel();
33353 + *(void **)&cdo->generic_packet = cdrom_dummy_generic_packet;
33354 + pax_close_kernel();
33355 + }
33356
33357 cdinfo(CD_REG_UNREG, "drive \"/dev/%s\" registered\n", cdi->name);
33358 mutex_lock(&cdrom_mutex);
33359 @@ -458,7 +460,6 @@ void unregister_cdrom(struct cdrom_device_info *cdi)
33360 if (cdi->exit)
33361 cdi->exit(cdi);
33362
33363 - cdi->ops->n_minors--;
33364 cdinfo(CD_REG_UNREG, "drive \"/dev/%s\" unregistered\n", cdi->name);
33365 }
33366
33367 diff --git a/drivers/cdrom/gdrom.c b/drivers/cdrom/gdrom.c
33368 index d59cdcb..11afddf 100644
33369 --- a/drivers/cdrom/gdrom.c
33370 +++ b/drivers/cdrom/gdrom.c
33371 @@ -491,7 +491,6 @@ static struct cdrom_device_ops gdrom_ops = {
33372 .audio_ioctl = gdrom_audio_ioctl,
33373 .capability = CDC_MULTI_SESSION | CDC_MEDIA_CHANGED |
33374 CDC_RESET | CDC_DRIVE_STATUS | CDC_CD_R,
33375 - .n_minors = 1,
33376 };
33377
33378 static int gdrom_bdops_open(struct block_device *bdev, fmode_t mode)
33379 diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig
33380 index 72bedad..8181ce1 100644
33381 --- a/drivers/char/Kconfig
33382 +++ b/drivers/char/Kconfig
33383 @@ -8,7 +8,8 @@ source "drivers/tty/Kconfig"
33384
33385 config DEVKMEM
33386 bool "/dev/kmem virtual device support"
33387 - default y
33388 + default n
33389 + depends on !GRKERNSEC_KMEM
33390 help
33391 Say Y here if you want to support the /dev/kmem device. The
33392 /dev/kmem device is rarely used, but can be used for certain
33393 @@ -581,6 +582,7 @@ config DEVPORT
33394 bool
33395 depends on !M68K
33396 depends on ISA || PCI
33397 + depends on !GRKERNSEC_KMEM
33398 default y
33399
33400 source "drivers/s390/char/Kconfig"
33401 diff --git a/drivers/char/agp/frontend.c b/drivers/char/agp/frontend.c
33402 index 2e04433..22afc64 100644
33403 --- a/drivers/char/agp/frontend.c
33404 +++ b/drivers/char/agp/frontend.c
33405 @@ -817,7 +817,7 @@ static int agpioc_reserve_wrap(struct agp_file_private *priv, void __user *arg)
33406 if (copy_from_user(&reserve, arg, sizeof(struct agp_region)))
33407 return -EFAULT;
33408
33409 - if ((unsigned) reserve.seg_count >= ~0U/sizeof(struct agp_segment))
33410 + if ((unsigned) reserve.seg_count >= ~0U/sizeof(struct agp_segment_priv))
33411 return -EFAULT;
33412
33413 client = agp_find_client_by_pid(reserve.pid);
33414 diff --git a/drivers/char/genrtc.c b/drivers/char/genrtc.c
33415 index 21cb980..f15107c 100644
33416 --- a/drivers/char/genrtc.c
33417 +++ b/drivers/char/genrtc.c
33418 @@ -272,6 +272,7 @@ static int gen_rtc_ioctl(struct file *file,
33419 switch (cmd) {
33420
33421 case RTC_PLL_GET:
33422 + memset(&pll, 0, sizeof(pll));
33423 if (get_rtc_pll(&pll))
33424 return -EINVAL;
33425 else
33426 diff --git a/drivers/char/hpet.c b/drivers/char/hpet.c
33427 index fe6d4be..89f32100 100644
33428 --- a/drivers/char/hpet.c
33429 +++ b/drivers/char/hpet.c
33430 @@ -571,7 +571,7 @@ static inline unsigned long hpet_time_div(struct hpets *hpets,
33431 }
33432
33433 static int
33434 -hpet_ioctl_common(struct hpet_dev *devp, int cmd, unsigned long arg,
33435 +hpet_ioctl_common(struct hpet_dev *devp, unsigned int cmd, unsigned long arg,
33436 struct hpet_info *info)
33437 {
33438 struct hpet_timer __iomem *timer;
33439 diff --git a/drivers/char/ipmi/ipmi_msghandler.c b/drivers/char/ipmi/ipmi_msghandler.c
33440 index 053201b0..8335cce 100644
33441 --- a/drivers/char/ipmi/ipmi_msghandler.c
33442 +++ b/drivers/char/ipmi/ipmi_msghandler.c
33443 @@ -420,7 +420,7 @@ struct ipmi_smi {
33444 struct proc_dir_entry *proc_dir;
33445 char proc_dir_name[10];
33446
33447 - atomic_t stats[IPMI_NUM_STATS];
33448 + atomic_unchecked_t stats[IPMI_NUM_STATS];
33449
33450 /*
33451 * run_to_completion duplicate of smb_info, smi_info
33452 @@ -453,9 +453,9 @@ static DEFINE_MUTEX(smi_watchers_mutex);
33453
33454
33455 #define ipmi_inc_stat(intf, stat) \
33456 - atomic_inc(&(intf)->stats[IPMI_STAT_ ## stat])
33457 + atomic_inc_unchecked(&(intf)->stats[IPMI_STAT_ ## stat])
33458 #define ipmi_get_stat(intf, stat) \
33459 - ((unsigned int) atomic_read(&(intf)->stats[IPMI_STAT_ ## stat]))
33460 + ((unsigned int) atomic_read_unchecked(&(intf)->stats[IPMI_STAT_ ## stat]))
33461
33462 static int is_lan_addr(struct ipmi_addr *addr)
33463 {
33464 @@ -2884,7 +2884,7 @@ int ipmi_register_smi(struct ipmi_smi_handlers *handlers,
33465 INIT_LIST_HEAD(&intf->cmd_rcvrs);
33466 init_waitqueue_head(&intf->waitq);
33467 for (i = 0; i < IPMI_NUM_STATS; i++)
33468 - atomic_set(&intf->stats[i], 0);
33469 + atomic_set_unchecked(&intf->stats[i], 0);
33470
33471 intf->proc_dir = NULL;
33472
33473 diff --git a/drivers/char/ipmi/ipmi_si_intf.c b/drivers/char/ipmi/ipmi_si_intf.c
33474 index 1c7fdcd..4899100 100644
33475 --- a/drivers/char/ipmi/ipmi_si_intf.c
33476 +++ b/drivers/char/ipmi/ipmi_si_intf.c
33477 @@ -275,7 +275,7 @@ struct smi_info {
33478 unsigned char slave_addr;
33479
33480 /* Counters and things for the proc filesystem. */
33481 - atomic_t stats[SI_NUM_STATS];
33482 + atomic_unchecked_t stats[SI_NUM_STATS];
33483
33484 struct task_struct *thread;
33485
33486 @@ -284,9 +284,9 @@ struct smi_info {
33487 };
33488
33489 #define smi_inc_stat(smi, stat) \
33490 - atomic_inc(&(smi)->stats[SI_STAT_ ## stat])
33491 + atomic_inc_unchecked(&(smi)->stats[SI_STAT_ ## stat])
33492 #define smi_get_stat(smi, stat) \
33493 - ((unsigned int) atomic_read(&(smi)->stats[SI_STAT_ ## stat]))
33494 + ((unsigned int) atomic_read_unchecked(&(smi)->stats[SI_STAT_ ## stat]))
33495
33496 #define SI_MAX_PARMS 4
33497
33498 @@ -3225,7 +3225,7 @@ static int try_smi_init(struct smi_info *new_smi)
33499 atomic_set(&new_smi->req_events, 0);
33500 new_smi->run_to_completion = 0;
33501 for (i = 0; i < SI_NUM_STATS; i++)
33502 - atomic_set(&new_smi->stats[i], 0);
33503 + atomic_set_unchecked(&new_smi->stats[i], 0);
33504
33505 new_smi->interrupt_disabled = 1;
33506 atomic_set(&new_smi->stop_operation, 0);
33507 diff --git a/drivers/char/mem.c b/drivers/char/mem.c
33508 index c6fa3bc..4ca3e42 100644
33509 --- a/drivers/char/mem.c
33510 +++ b/drivers/char/mem.c
33511 @@ -18,6 +18,7 @@
33512 #include <linux/raw.h>
33513 #include <linux/tty.h>
33514 #include <linux/capability.h>
33515 +#include <linux/security.h>
33516 #include <linux/ptrace.h>
33517 #include <linux/device.h>
33518 #include <linux/highmem.h>
33519 @@ -37,6 +38,10 @@
33520
33521 #define DEVPORT_MINOR 4
33522
33523 +#if defined(CONFIG_GRKERNSEC) && !defined(CONFIG_GRKERNSEC_NO_RBAC)
33524 +extern const struct file_operations grsec_fops;
33525 +#endif
33526 +
33527 static inline unsigned long size_inside_page(unsigned long start,
33528 unsigned long size)
33529 {
33530 @@ -68,9 +73,13 @@ static inline int range_is_allowed(unsigned long pfn, unsigned long size)
33531
33532 while (cursor < to) {
33533 if (!devmem_is_allowed(pfn)) {
33534 +#ifdef CONFIG_GRKERNSEC_KMEM
33535 + gr_handle_mem_readwrite(from, to);
33536 +#else
33537 printk(KERN_INFO
33538 "Program %s tried to access /dev/mem between %Lx->%Lx.\n",
33539 current->comm, from, to);
33540 +#endif
33541 return 0;
33542 }
33543 cursor += PAGE_SIZE;
33544 @@ -78,6 +87,11 @@ static inline int range_is_allowed(unsigned long pfn, unsigned long size)
33545 }
33546 return 1;
33547 }
33548 +#elif defined(CONFIG_GRKERNSEC_KMEM)
33549 +static inline int range_is_allowed(unsigned long pfn, unsigned long size)
33550 +{
33551 + return 0;
33552 +}
33553 #else
33554 static inline int range_is_allowed(unsigned long pfn, unsigned long size)
33555 {
33556 @@ -120,6 +134,7 @@ static ssize_t read_mem(struct file *file, char __user *buf,
33557
33558 while (count > 0) {
33559 unsigned long remaining;
33560 + char *temp;
33561
33562 sz = size_inside_page(p, count);
33563
33564 @@ -135,7 +150,23 @@ static ssize_t read_mem(struct file *file, char __user *buf,
33565 if (!ptr)
33566 return -EFAULT;
33567
33568 - remaining = copy_to_user(buf, ptr, sz);
33569 +#ifdef CONFIG_PAX_USERCOPY
33570 + temp = kmalloc(sz, GFP_KERNEL|GFP_USERCOPY);
33571 + if (!temp) {
33572 + unxlate_dev_mem_ptr(p, ptr);
33573 + return -ENOMEM;
33574 + }
33575 + memcpy(temp, ptr, sz);
33576 +#else
33577 + temp = ptr;
33578 +#endif
33579 +
33580 + remaining = copy_to_user(buf, temp, sz);
33581 +
33582 +#ifdef CONFIG_PAX_USERCOPY
33583 + kfree(temp);
33584 +#endif
33585 +
33586 unxlate_dev_mem_ptr(p, ptr);
33587 if (remaining)
33588 return -EFAULT;
33589 @@ -398,9 +429,8 @@ static ssize_t read_kmem(struct file *file, char __user *buf,
33590 size_t count, loff_t *ppos)
33591 {
33592 unsigned long p = *ppos;
33593 - ssize_t low_count, read, sz;
33594 + ssize_t low_count, read, sz, err = 0;
33595 char * kbuf; /* k-addr because vread() takes vmlist_lock rwlock */
33596 - int err = 0;
33597
33598 read = 0;
33599 if (p < (unsigned long) high_memory) {
33600 @@ -422,6 +452,8 @@ static ssize_t read_kmem(struct file *file, char __user *buf,
33601 }
33602 #endif
33603 while (low_count > 0) {
33604 + char *temp;
33605 +
33606 sz = size_inside_page(p, low_count);
33607
33608 /*
33609 @@ -431,7 +463,22 @@ static ssize_t read_kmem(struct file *file, char __user *buf,
33610 */
33611 kbuf = xlate_dev_kmem_ptr((char *)p);
33612
33613 - if (copy_to_user(buf, kbuf, sz))
33614 +#ifdef CONFIG_PAX_USERCOPY
33615 + temp = kmalloc(sz, GFP_KERNEL|GFP_USERCOPY);
33616 + if (!temp)
33617 + return -ENOMEM;
33618 + memcpy(temp, kbuf, sz);
33619 +#else
33620 + temp = kbuf;
33621 +#endif
33622 +
33623 + err = copy_to_user(buf, temp, sz);
33624 +
33625 +#ifdef CONFIG_PAX_USERCOPY
33626 + kfree(temp);
33627 +#endif
33628 +
33629 + if (err)
33630 return -EFAULT;
33631 buf += sz;
33632 p += sz;
33633 @@ -833,6 +880,9 @@ static const struct memdev {
33634 #ifdef CONFIG_CRASH_DUMP
33635 [12] = { "oldmem", 0, &oldmem_fops, NULL },
33636 #endif
33637 +#if defined(CONFIG_GRKERNSEC) && !defined(CONFIG_GRKERNSEC_NO_RBAC)
33638 + [13] = { "grsec",S_IRUSR | S_IWUGO, &grsec_fops, NULL },
33639 +#endif
33640 };
33641
33642 static int memory_open(struct inode *inode, struct file *filp)
33643 diff --git a/drivers/char/nvram.c b/drivers/char/nvram.c
33644 index 9df78e2..01ba9ae 100644
33645 --- a/drivers/char/nvram.c
33646 +++ b/drivers/char/nvram.c
33647 @@ -247,7 +247,7 @@ static ssize_t nvram_read(struct file *file, char __user *buf,
33648
33649 spin_unlock_irq(&rtc_lock);
33650
33651 - if (copy_to_user(buf, contents, tmp - contents))
33652 + if (tmp - contents > sizeof(contents) || copy_to_user(buf, contents, tmp - contents))
33653 return -EFAULT;
33654
33655 *ppos = i;
33656 diff --git a/drivers/char/pcmcia/synclink_cs.c b/drivers/char/pcmcia/synclink_cs.c
33657 index b66eaa0..2619d1b 100644
33658 --- a/drivers/char/pcmcia/synclink_cs.c
33659 +++ b/drivers/char/pcmcia/synclink_cs.c
33660 @@ -2348,9 +2348,9 @@ static void mgslpc_close(struct tty_struct *tty, struct file * filp)
33661
33662 if (debug_level >= DEBUG_LEVEL_INFO)
33663 printk("%s(%d):mgslpc_close(%s) entry, count=%d\n",
33664 - __FILE__,__LINE__, info->device_name, port->count);
33665 + __FILE__,__LINE__, info->device_name, atomic_read(&port->count));
33666
33667 - WARN_ON(!port->count);
33668 + WARN_ON(!atomic_read(&port->count));
33669
33670 if (tty_port_close_start(port, tty, filp) == 0)
33671 goto cleanup;
33672 @@ -2368,7 +2368,7 @@ static void mgslpc_close(struct tty_struct *tty, struct file * filp)
33673 cleanup:
33674 if (debug_level >= DEBUG_LEVEL_INFO)
33675 printk("%s(%d):mgslpc_close(%s) exit, count=%d\n", __FILE__,__LINE__,
33676 - tty->driver->name, port->count);
33677 + tty->driver->name, atomic_read(&port->count));
33678 }
33679
33680 /* Wait until the transmitter is empty.
33681 @@ -2510,7 +2510,7 @@ static int mgslpc_open(struct tty_struct *tty, struct file * filp)
33682
33683 if (debug_level >= DEBUG_LEVEL_INFO)
33684 printk("%s(%d):mgslpc_open(%s), old ref count = %d\n",
33685 - __FILE__,__LINE__,tty->driver->name, port->count);
33686 + __FILE__,__LINE__,tty->driver->name, atomic_read(&port->count));
33687
33688 /* If port is closing, signal caller to try again */
33689 if (tty_hung_up_p(filp) || port->flags & ASYNC_CLOSING){
33690 @@ -2530,11 +2530,11 @@ static int mgslpc_open(struct tty_struct *tty, struct file * filp)
33691 goto cleanup;
33692 }
33693 spin_lock(&port->lock);
33694 - port->count++;
33695 + atomic_inc(&port->count);
33696 spin_unlock(&port->lock);
33697 spin_unlock_irqrestore(&info->netlock, flags);
33698
33699 - if (port->count == 1) {
33700 + if (atomic_read(&port->count) == 1) {
33701 /* 1st open on this device, init hardware */
33702 retval = startup(info, tty);
33703 if (retval < 0)
33704 @@ -3889,7 +3889,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
33705 unsigned short new_crctype;
33706
33707 /* return error if TTY interface open */
33708 - if (info->port.count)
33709 + if (atomic_read(&info->port.count))
33710 return -EBUSY;
33711
33712 switch (encoding)
33713 @@ -3992,7 +3992,7 @@ static int hdlcdev_open(struct net_device *dev)
33714
33715 /* arbitrate between network and tty opens */
33716 spin_lock_irqsave(&info->netlock, flags);
33717 - if (info->port.count != 0 || info->netcount != 0) {
33718 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
33719 printk(KERN_WARNING "%s: hdlc_open returning busy\n", dev->name);
33720 spin_unlock_irqrestore(&info->netlock, flags);
33721 return -EBUSY;
33722 @@ -4081,7 +4081,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
33723 printk("%s:hdlcdev_ioctl(%s)\n",__FILE__,dev->name);
33724
33725 /* return error if TTY interface open */
33726 - if (info->port.count)
33727 + if (atomic_read(&info->port.count))
33728 return -EBUSY;
33729
33730 if (cmd != SIOCWANDEV)
33731 diff --git a/drivers/char/random.c b/drivers/char/random.c
33732 index 57d4b15..253207b 100644
33733 --- a/drivers/char/random.c
33734 +++ b/drivers/char/random.c
33735 @@ -272,8 +272,13 @@
33736 /*
33737 * Configuration information
33738 */
33739 +#ifdef CONFIG_GRKERNSEC_RANDNET
33740 +#define INPUT_POOL_WORDS 512
33741 +#define OUTPUT_POOL_WORDS 128
33742 +#else
33743 #define INPUT_POOL_WORDS 128
33744 #define OUTPUT_POOL_WORDS 32
33745 +#endif
33746 #define SEC_XFER_SIZE 512
33747 #define EXTRACT_SIZE 10
33748
33749 @@ -313,10 +318,17 @@ static struct poolinfo {
33750 int poolwords;
33751 int tap1, tap2, tap3, tap4, tap5;
33752 } poolinfo_table[] = {
33753 +#ifdef CONFIG_GRKERNSEC_RANDNET
33754 + /* x^512 + x^411 + x^308 + x^208 +x^104 + x + 1 -- 225 */
33755 + { 512, 411, 308, 208, 104, 1 },
33756 + /* x^128 + x^103 + x^76 + x^51 + x^25 + x + 1 -- 105 */
33757 + { 128, 103, 76, 51, 25, 1 },
33758 +#else
33759 /* x^128 + x^103 + x^76 + x^51 +x^25 + x + 1 -- 105 */
33760 { 128, 103, 76, 51, 25, 1 },
33761 /* x^32 + x^26 + x^20 + x^14 + x^7 + x + 1 -- 15 */
33762 { 32, 26, 20, 14, 7, 1 },
33763 +#endif
33764 #if 0
33765 /* x^2048 + x^1638 + x^1231 + x^819 + x^411 + x + 1 -- 115 */
33766 { 2048, 1638, 1231, 819, 411, 1 },
33767 @@ -524,8 +536,8 @@ static void _mix_pool_bytes(struct entropy_store *r, const void *in,
33768 input_rotate += i ? 7 : 14;
33769 }
33770
33771 - ACCESS_ONCE(r->input_rotate) = input_rotate;
33772 - ACCESS_ONCE(r->add_ptr) = i;
33773 + ACCESS_ONCE_RW(r->input_rotate) = input_rotate;
33774 + ACCESS_ONCE_RW(r->add_ptr) = i;
33775 smp_wmb();
33776
33777 if (out)
33778 @@ -1024,7 +1036,7 @@ static ssize_t extract_entropy_user(struct entropy_store *r, void __user *buf,
33779
33780 extract_buf(r, tmp);
33781 i = min_t(int, nbytes, EXTRACT_SIZE);
33782 - if (copy_to_user(buf, tmp, i)) {
33783 + if (i > sizeof(tmp) || copy_to_user(buf, tmp, i)) {
33784 ret = -EFAULT;
33785 break;
33786 }
33787 @@ -1360,7 +1372,7 @@ EXPORT_SYMBOL(generate_random_uuid);
33788 #include <linux/sysctl.h>
33789
33790 static int min_read_thresh = 8, min_write_thresh;
33791 -static int max_read_thresh = INPUT_POOL_WORDS * 32;
33792 +static int max_read_thresh = OUTPUT_POOL_WORDS * 32;
33793 static int max_write_thresh = INPUT_POOL_WORDS * 32;
33794 static char sysctl_bootid[16];
33795
33796 @@ -1376,7 +1388,7 @@ static char sysctl_bootid[16];
33797 static int proc_do_uuid(ctl_table *table, int write,
33798 void __user *buffer, size_t *lenp, loff_t *ppos)
33799 {
33800 - ctl_table fake_table;
33801 + ctl_table_no_const fake_table;
33802 unsigned char buf[64], tmp_uuid[16], *uuid;
33803
33804 uuid = table->data;
33805 diff --git a/drivers/char/sonypi.c b/drivers/char/sonypi.c
33806 index d780295..b29f3a8 100644
33807 --- a/drivers/char/sonypi.c
33808 +++ b/drivers/char/sonypi.c
33809 @@ -54,6 +54,7 @@
33810
33811 #include <asm/uaccess.h>
33812 #include <asm/io.h>
33813 +#include <asm/local.h>
33814
33815 #include <linux/sonypi.h>
33816
33817 @@ -490,7 +491,7 @@ static struct sonypi_device {
33818 spinlock_t fifo_lock;
33819 wait_queue_head_t fifo_proc_list;
33820 struct fasync_struct *fifo_async;
33821 - int open_count;
33822 + local_t open_count;
33823 int model;
33824 struct input_dev *input_jog_dev;
33825 struct input_dev *input_key_dev;
33826 @@ -897,7 +898,7 @@ static int sonypi_misc_fasync(int fd, struct file *filp, int on)
33827 static int sonypi_misc_release(struct inode *inode, struct file *file)
33828 {
33829 mutex_lock(&sonypi_device.lock);
33830 - sonypi_device.open_count--;
33831 + local_dec(&sonypi_device.open_count);
33832 mutex_unlock(&sonypi_device.lock);
33833 return 0;
33834 }
33835 @@ -906,9 +907,9 @@ static int sonypi_misc_open(struct inode *inode, struct file *file)
33836 {
33837 mutex_lock(&sonypi_device.lock);
33838 /* Flush input queue on first open */
33839 - if (!sonypi_device.open_count)
33840 + if (!local_read(&sonypi_device.open_count))
33841 kfifo_reset(&sonypi_device.fifo);
33842 - sonypi_device.open_count++;
33843 + local_inc(&sonypi_device.open_count);
33844 mutex_unlock(&sonypi_device.lock);
33845
33846 return 0;
33847 diff --git a/drivers/char/tpm/tpm.c b/drivers/char/tpm/tpm.c
33848 index 93211df..c7805f7 100644
33849 --- a/drivers/char/tpm/tpm.c
33850 +++ b/drivers/char/tpm/tpm.c
33851 @@ -410,7 +410,7 @@ static ssize_t tpm_transmit(struct tpm_chip *chip, const char *buf,
33852 chip->vendor.req_complete_val)
33853 goto out_recv;
33854
33855 - if ((status == chip->vendor.req_canceled)) {
33856 + if (status == chip->vendor.req_canceled) {
33857 dev_err(chip->dev, "Operation Canceled\n");
33858 rc = -ECANCELED;
33859 goto out;
33860 diff --git a/drivers/char/tpm/tpm_acpi.c b/drivers/char/tpm/tpm_acpi.c
33861 index 56051d0..11cf3b7 100644
33862 --- a/drivers/char/tpm/tpm_acpi.c
33863 +++ b/drivers/char/tpm/tpm_acpi.c
33864 @@ -98,11 +98,12 @@ int read_log(struct tpm_bios_log *log)
33865 virt = acpi_os_map_memory(start, len);
33866 if (!virt) {
33867 kfree(log->bios_event_log);
33868 + log->bios_event_log = NULL;
33869 printk("%s: ERROR - Unable to map memory\n", __func__);
33870 return -EIO;
33871 }
33872
33873 - memcpy_fromio(log->bios_event_log, virt, len);
33874 + memcpy_fromio(log->bios_event_log, (const char __force_kernel *)virt, len);
33875
33876 acpi_os_unmap_memory(virt, len);
33877 return 0;
33878 diff --git a/drivers/char/tpm/tpm_eventlog.c b/drivers/char/tpm/tpm_eventlog.c
33879 index 84ddc55..1d32f1e 100644
33880 --- a/drivers/char/tpm/tpm_eventlog.c
33881 +++ b/drivers/char/tpm/tpm_eventlog.c
33882 @@ -95,7 +95,7 @@ static void *tpm_bios_measurements_start(struct seq_file *m, loff_t *pos)
33883 event = addr;
33884
33885 if ((event->event_type == 0 && event->event_size == 0) ||
33886 - ((addr + sizeof(struct tcpa_event) + event->event_size) >= limit))
33887 + (event->event_size >= limit - addr - sizeof(struct tcpa_event)))
33888 return NULL;
33889
33890 return addr;
33891 @@ -120,7 +120,7 @@ static void *tpm_bios_measurements_next(struct seq_file *m, void *v,
33892 return NULL;
33893
33894 if ((event->event_type == 0 && event->event_size == 0) ||
33895 - ((v + sizeof(struct tcpa_event) + event->event_size) >= limit))
33896 + (event->event_size >= limit - v - sizeof(struct tcpa_event)))
33897 return NULL;
33898
33899 (*pos)++;
33900 @@ -213,7 +213,8 @@ static int tpm_binary_bios_measurements_show(struct seq_file *m, void *v)
33901 int i;
33902
33903 for (i = 0; i < sizeof(struct tcpa_event) + event->event_size; i++)
33904 - seq_putc(m, data[i]);
33905 + if (!seq_putc(m, data[i]))
33906 + return -EFAULT;
33907
33908 return 0;
33909 }
33910 diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c
33911 index ee4dbea..69c817b 100644
33912 --- a/drivers/char/virtio_console.c
33913 +++ b/drivers/char/virtio_console.c
33914 @@ -681,7 +681,7 @@ static ssize_t fill_readbuf(struct port *port, char *out_buf, size_t out_count,
33915 if (to_user) {
33916 ssize_t ret;
33917
33918 - ret = copy_to_user(out_buf, buf->buf + buf->offset, out_count);
33919 + ret = copy_to_user((char __force_user *)out_buf, buf->buf + buf->offset, out_count);
33920 if (ret)
33921 return -EFAULT;
33922 } else {
33923 @@ -780,7 +780,7 @@ static ssize_t port_fops_read(struct file *filp, char __user *ubuf,
33924 if (!port_has_data(port) && !port->host_connected)
33925 return 0;
33926
33927 - return fill_readbuf(port, ubuf, count, true);
33928 + return fill_readbuf(port, (char __force_kernel *)ubuf, count, true);
33929 }
33930
33931 static int wait_port_writable(struct port *port, bool nonblock)
33932 diff --git a/drivers/clocksource/arm_generic.c b/drivers/clocksource/arm_generic.c
33933 index 8ae1a61..9c00613 100644
33934 --- a/drivers/clocksource/arm_generic.c
33935 +++ b/drivers/clocksource/arm_generic.c
33936 @@ -181,7 +181,7 @@ static int __cpuinit arch_timer_cpu_notify(struct notifier_block *self,
33937 return NOTIFY_OK;
33938 }
33939
33940 -static struct notifier_block __cpuinitdata arch_timer_cpu_nb = {
33941 +static struct notifier_block arch_timer_cpu_nb = {
33942 .notifier_call = arch_timer_cpu_notify,
33943 };
33944
33945 diff --git a/drivers/cpufreq/acpi-cpufreq.c b/drivers/cpufreq/acpi-cpufreq.c
33946 index 7b0d49d..134fac9 100644
33947 --- a/drivers/cpufreq/acpi-cpufreq.c
33948 +++ b/drivers/cpufreq/acpi-cpufreq.c
33949 @@ -172,7 +172,7 @@ static ssize_t show_global_boost(struct kobject *kobj,
33950 return sprintf(buf, "%u\n", boost_enabled);
33951 }
33952
33953 -static struct global_attr global_boost = __ATTR(boost, 0644,
33954 +static global_attr_no_const global_boost = __ATTR(boost, 0644,
33955 show_global_boost,
33956 store_global_boost);
33957
33958 @@ -712,8 +712,11 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
33959 data->acpi_data = per_cpu_ptr(acpi_perf_data, cpu);
33960 per_cpu(acfreq_data, cpu) = data;
33961
33962 - if (cpu_has(c, X86_FEATURE_CONSTANT_TSC))
33963 - acpi_cpufreq_driver.flags |= CPUFREQ_CONST_LOOPS;
33964 + if (cpu_has(c, X86_FEATURE_CONSTANT_TSC)) {
33965 + pax_open_kernel();
33966 + *(u8 *)&acpi_cpufreq_driver.flags |= CPUFREQ_CONST_LOOPS;
33967 + pax_close_kernel();
33968 + }
33969
33970 result = acpi_processor_register_performance(data->acpi_data, cpu);
33971 if (result)
33972 @@ -835,7 +838,9 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
33973 policy->cur = acpi_cpufreq_guess_freq(data, policy->cpu);
33974 break;
33975 case ACPI_ADR_SPACE_FIXED_HARDWARE:
33976 - acpi_cpufreq_driver.get = get_cur_freq_on_cpu;
33977 + pax_open_kernel();
33978 + *(void **)&acpi_cpufreq_driver.get = get_cur_freq_on_cpu;
33979 + pax_close_kernel();
33980 policy->cur = get_cur_freq_on_cpu(cpu);
33981 break;
33982 default:
33983 @@ -846,8 +851,11 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
33984 acpi_processor_notify_smm(THIS_MODULE);
33985
33986 /* Check for APERF/MPERF support in hardware */
33987 - if (boot_cpu_has(X86_FEATURE_APERFMPERF))
33988 - acpi_cpufreq_driver.getavg = cpufreq_get_measured_perf;
33989 + if (boot_cpu_has(X86_FEATURE_APERFMPERF)) {
33990 + pax_open_kernel();
33991 + *(void **)&acpi_cpufreq_driver.getavg = cpufreq_get_measured_perf;
33992 + pax_close_kernel();
33993 + }
33994
33995 pr_debug("CPU%u - ACPI performance management activated.\n", cpu);
33996 for (i = 0; i < perf->state_count; i++)
33997 diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
33998 index 1f93dbd..305cef1 100644
33999 --- a/drivers/cpufreq/cpufreq.c
34000 +++ b/drivers/cpufreq/cpufreq.c
34001 @@ -1843,7 +1843,7 @@ static int __cpuinit cpufreq_cpu_callback(struct notifier_block *nfb,
34002 return NOTIFY_OK;
34003 }
34004
34005 -static struct notifier_block __refdata cpufreq_cpu_notifier = {
34006 +static struct notifier_block cpufreq_cpu_notifier = {
34007 .notifier_call = cpufreq_cpu_callback,
34008 };
34009
34010 @@ -1875,8 +1875,11 @@ int cpufreq_register_driver(struct cpufreq_driver *driver_data)
34011
34012 pr_debug("trying to register driver %s\n", driver_data->name);
34013
34014 - if (driver_data->setpolicy)
34015 - driver_data->flags |= CPUFREQ_CONST_LOOPS;
34016 + if (driver_data->setpolicy) {
34017 + pax_open_kernel();
34018 + *(u8 *)&driver_data->flags |= CPUFREQ_CONST_LOOPS;
34019 + pax_close_kernel();
34020 + }
34021
34022 spin_lock_irqsave(&cpufreq_driver_lock, flags);
34023 if (cpufreq_driver) {
34024 diff --git a/drivers/cpufreq/cpufreq_governor.c b/drivers/cpufreq/cpufreq_governor.c
34025 index 6c5f1d3..c7e2f35e 100644
34026 --- a/drivers/cpufreq/cpufreq_governor.c
34027 +++ b/drivers/cpufreq/cpufreq_governor.c
34028 @@ -243,7 +243,7 @@ int cpufreq_governor_dbs(struct dbs_data *dbs_data,
34029 * governor, thus we are bound to jiffes/HZ
34030 */
34031 if (dbs_data->governor == GOV_CONSERVATIVE) {
34032 - struct cs_ops *ops = dbs_data->gov_ops;
34033 + const struct cs_ops *ops = dbs_data->gov_ops;
34034
34035 cpufreq_register_notifier(ops->notifier_block,
34036 CPUFREQ_TRANSITION_NOTIFIER);
34037 @@ -251,7 +251,7 @@ int cpufreq_governor_dbs(struct dbs_data *dbs_data,
34038 dbs_data->min_sampling_rate = MIN_SAMPLING_RATE_RATIO *
34039 jiffies_to_usecs(10);
34040 } else {
34041 - struct od_ops *ops = dbs_data->gov_ops;
34042 + const struct od_ops *ops = dbs_data->gov_ops;
34043
34044 od_tuners->io_is_busy = ops->io_busy();
34045 }
34046 @@ -268,7 +268,7 @@ second_time:
34047 cs_dbs_info->enable = 1;
34048 cs_dbs_info->requested_freq = policy->cur;
34049 } else {
34050 - struct od_ops *ops = dbs_data->gov_ops;
34051 + const struct od_ops *ops = dbs_data->gov_ops;
34052 od_dbs_info->rate_mult = 1;
34053 od_dbs_info->sample_type = OD_NORMAL_SAMPLE;
34054 ops->powersave_bias_init_cpu(cpu);
34055 @@ -289,7 +289,7 @@ second_time:
34056 mutex_destroy(&cpu_cdbs->timer_mutex);
34057 dbs_data->enable--;
34058 if (!dbs_data->enable) {
34059 - struct cs_ops *ops = dbs_data->gov_ops;
34060 + const struct cs_ops *ops = dbs_data->gov_ops;
34061
34062 sysfs_remove_group(cpufreq_global_kobject,
34063 dbs_data->attr_group);
34064 diff --git a/drivers/cpufreq/cpufreq_governor.h b/drivers/cpufreq/cpufreq_governor.h
34065 index f661654..6c8e638 100644
34066 --- a/drivers/cpufreq/cpufreq_governor.h
34067 +++ b/drivers/cpufreq/cpufreq_governor.h
34068 @@ -142,7 +142,7 @@ struct dbs_data {
34069 void (*gov_check_cpu)(int cpu, unsigned int load);
34070
34071 /* Governor specific ops, see below */
34072 - void *gov_ops;
34073 + const void *gov_ops;
34074 };
34075
34076 /* Governor specific ops, will be passed to dbs_data->gov_ops */
34077 diff --git a/drivers/cpufreq/cpufreq_stats.c b/drivers/cpufreq/cpufreq_stats.c
34078 index 9d7732b..0b1a793 100644
34079 --- a/drivers/cpufreq/cpufreq_stats.c
34080 +++ b/drivers/cpufreq/cpufreq_stats.c
34081 @@ -340,7 +340,7 @@ static int __cpuinit cpufreq_stat_cpu_callback(struct notifier_block *nfb,
34082 }
34083
34084 /* priority=1 so this will get called before cpufreq_remove_dev */
34085 -static struct notifier_block cpufreq_stat_cpu_notifier __refdata = {
34086 +static struct notifier_block cpufreq_stat_cpu_notifier = {
34087 .notifier_call = cpufreq_stat_cpu_callback,
34088 .priority = 1,
34089 };
34090 diff --git a/drivers/cpufreq/p4-clockmod.c b/drivers/cpufreq/p4-clockmod.c
34091 index 827629c9..0bc6a03 100644
34092 --- a/drivers/cpufreq/p4-clockmod.c
34093 +++ b/drivers/cpufreq/p4-clockmod.c
34094 @@ -167,10 +167,14 @@ static unsigned int cpufreq_p4_get_frequency(struct cpuinfo_x86 *c)
34095 case 0x0F: /* Core Duo */
34096 case 0x16: /* Celeron Core */
34097 case 0x1C: /* Atom */
34098 - p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
34099 + pax_open_kernel();
34100 + *(u8 *)&p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
34101 + pax_close_kernel();
34102 return speedstep_get_frequency(SPEEDSTEP_CPU_PCORE);
34103 case 0x0D: /* Pentium M (Dothan) */
34104 - p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
34105 + pax_open_kernel();
34106 + *(u8 *)&p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
34107 + pax_close_kernel();
34108 /* fall through */
34109 case 0x09: /* Pentium M (Banias) */
34110 return speedstep_get_frequency(SPEEDSTEP_CPU_PM);
34111 @@ -182,7 +186,9 @@ static unsigned int cpufreq_p4_get_frequency(struct cpuinfo_x86 *c)
34112
34113 /* on P-4s, the TSC runs with constant frequency independent whether
34114 * throttling is active or not. */
34115 - p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
34116 + pax_open_kernel();
34117 + *(u8 *)&p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
34118 + pax_close_kernel();
34119
34120 if (speedstep_detect_processor() == SPEEDSTEP_CPU_P4M) {
34121 printk(KERN_WARNING PFX "Warning: Pentium 4-M detected. "
34122 diff --git a/drivers/cpufreq/speedstep-centrino.c b/drivers/cpufreq/speedstep-centrino.c
34123 index 3a953d5..f5993f6 100644
34124 --- a/drivers/cpufreq/speedstep-centrino.c
34125 +++ b/drivers/cpufreq/speedstep-centrino.c
34126 @@ -353,8 +353,11 @@ static int centrino_cpu_init(struct cpufreq_policy *policy)
34127 !cpu_has(cpu, X86_FEATURE_EST))
34128 return -ENODEV;
34129
34130 - if (cpu_has(cpu, X86_FEATURE_CONSTANT_TSC))
34131 - centrino_driver.flags |= CPUFREQ_CONST_LOOPS;
34132 + if (cpu_has(cpu, X86_FEATURE_CONSTANT_TSC)) {
34133 + pax_open_kernel();
34134 + *(u8 *)&centrino_driver.flags |= CPUFREQ_CONST_LOOPS;
34135 + pax_close_kernel();
34136 + }
34137
34138 if (policy->cpu != 0)
34139 return -ENODEV;
34140 diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c
34141 index e1f6860..f8de20b 100644
34142 --- a/drivers/cpuidle/cpuidle.c
34143 +++ b/drivers/cpuidle/cpuidle.c
34144 @@ -279,7 +279,7 @@ static int poll_idle(struct cpuidle_device *dev,
34145
34146 static void poll_idle_init(struct cpuidle_driver *drv)
34147 {
34148 - struct cpuidle_state *state = &drv->states[0];
34149 + cpuidle_state_no_const *state = &drv->states[0];
34150
34151 snprintf(state->name, CPUIDLE_NAME_LEN, "POLL");
34152 snprintf(state->desc, CPUIDLE_DESC_LEN, "CPUIDLE CORE POLL IDLE");
34153 diff --git a/drivers/cpuidle/governor.c b/drivers/cpuidle/governor.c
34154 index ea2f8e7..70ac501 100644
34155 --- a/drivers/cpuidle/governor.c
34156 +++ b/drivers/cpuidle/governor.c
34157 @@ -87,7 +87,7 @@ int cpuidle_register_governor(struct cpuidle_governor *gov)
34158 mutex_lock(&cpuidle_lock);
34159 if (__cpuidle_find_governor(gov->name) == NULL) {
34160 ret = 0;
34161 - list_add_tail(&gov->governor_list, &cpuidle_governors);
34162 + pax_list_add_tail((struct list_head *)&gov->governor_list, &cpuidle_governors);
34163 if (!cpuidle_curr_governor ||
34164 cpuidle_curr_governor->rating < gov->rating)
34165 cpuidle_switch_governor(gov);
34166 @@ -135,7 +135,7 @@ void cpuidle_unregister_governor(struct cpuidle_governor *gov)
34167 new_gov = cpuidle_replace_governor(gov->rating);
34168 cpuidle_switch_governor(new_gov);
34169 }
34170 - list_del(&gov->governor_list);
34171 + pax_list_del((struct list_head *)&gov->governor_list);
34172 mutex_unlock(&cpuidle_lock);
34173 }
34174
34175 diff --git a/drivers/cpuidle/sysfs.c b/drivers/cpuidle/sysfs.c
34176 index 428754a..8bdf9cc 100644
34177 --- a/drivers/cpuidle/sysfs.c
34178 +++ b/drivers/cpuidle/sysfs.c
34179 @@ -131,7 +131,7 @@ static struct attribute *cpuidle_switch_attrs[] = {
34180 NULL
34181 };
34182
34183 -static struct attribute_group cpuidle_attr_group = {
34184 +static attribute_group_no_const cpuidle_attr_group = {
34185 .attrs = cpuidle_default_attrs,
34186 .name = "cpuidle",
34187 };
34188 diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
34189 index 3b36797..289c16a 100644
34190 --- a/drivers/devfreq/devfreq.c
34191 +++ b/drivers/devfreq/devfreq.c
34192 @@ -588,7 +588,7 @@ int devfreq_add_governor(struct devfreq_governor *governor)
34193 goto err_out;
34194 }
34195
34196 - list_add(&governor->node, &devfreq_governor_list);
34197 + pax_list_add((struct list_head *)&governor->node, &devfreq_governor_list);
34198
34199 list_for_each_entry(devfreq, &devfreq_list, node) {
34200 int ret = 0;
34201 @@ -676,7 +676,7 @@ int devfreq_remove_governor(struct devfreq_governor *governor)
34202 }
34203 }
34204
34205 - list_del(&governor->node);
34206 + pax_list_del((struct list_head *)&governor->node);
34207 err_out:
34208 mutex_unlock(&devfreq_list_lock);
34209
34210 diff --git a/drivers/dma/sh/shdma.c b/drivers/dma/sh/shdma.c
34211 index b70709b..1d8d02a 100644
34212 --- a/drivers/dma/sh/shdma.c
34213 +++ b/drivers/dma/sh/shdma.c
34214 @@ -476,7 +476,7 @@ static int sh_dmae_nmi_handler(struct notifier_block *self,
34215 return ret;
34216 }
34217
34218 -static struct notifier_block sh_dmae_nmi_notifier __read_mostly = {
34219 +static struct notifier_block sh_dmae_nmi_notifier = {
34220 .notifier_call = sh_dmae_nmi_handler,
34221
34222 /* Run before NMI debug handler and KGDB */
34223 diff --git a/drivers/edac/edac_mc_sysfs.c b/drivers/edac/edac_mc_sysfs.c
34224 index 0ca1ca7..6e6f454 100644
34225 --- a/drivers/edac/edac_mc_sysfs.c
34226 +++ b/drivers/edac/edac_mc_sysfs.c
34227 @@ -148,7 +148,7 @@ static const char *edac_caps[] = {
34228 struct dev_ch_attribute {
34229 struct device_attribute attr;
34230 int channel;
34231 -};
34232 +} __do_const;
34233
34234 #define DEVICE_CHANNEL(_name, _mode, _show, _store, _var) \
34235 struct dev_ch_attribute dev_attr_legacy_##_name = \
34236 diff --git a/drivers/edac/edac_pci_sysfs.c b/drivers/edac/edac_pci_sysfs.c
34237 index 0056c4d..23b54d9 100644
34238 --- a/drivers/edac/edac_pci_sysfs.c
34239 +++ b/drivers/edac/edac_pci_sysfs.c
34240 @@ -26,8 +26,8 @@ static int edac_pci_log_pe = 1; /* log PCI parity errors */
34241 static int edac_pci_log_npe = 1; /* log PCI non-parity error errors */
34242 static int edac_pci_poll_msec = 1000; /* one second workq period */
34243
34244 -static atomic_t pci_parity_count = ATOMIC_INIT(0);
34245 -static atomic_t pci_nonparity_count = ATOMIC_INIT(0);
34246 +static atomic_unchecked_t pci_parity_count = ATOMIC_INIT(0);
34247 +static atomic_unchecked_t pci_nonparity_count = ATOMIC_INIT(0);
34248
34249 static struct kobject *edac_pci_top_main_kobj;
34250 static atomic_t edac_pci_sysfs_refcount = ATOMIC_INIT(0);
34251 @@ -235,7 +235,7 @@ struct edac_pci_dev_attribute {
34252 void *value;
34253 ssize_t(*show) (void *, char *);
34254 ssize_t(*store) (void *, const char *, size_t);
34255 -};
34256 +} __do_const;
34257
34258 /* Set of show/store abstract level functions for PCI Parity object */
34259 static ssize_t edac_pci_dev_show(struct kobject *kobj, struct attribute *attr,
34260 @@ -579,7 +579,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
34261 edac_printk(KERN_CRIT, EDAC_PCI,
34262 "Signaled System Error on %s\n",
34263 pci_name(dev));
34264 - atomic_inc(&pci_nonparity_count);
34265 + atomic_inc_unchecked(&pci_nonparity_count);
34266 }
34267
34268 if (status & (PCI_STATUS_PARITY)) {
34269 @@ -587,7 +587,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
34270 "Master Data Parity Error on %s\n",
34271 pci_name(dev));
34272
34273 - atomic_inc(&pci_parity_count);
34274 + atomic_inc_unchecked(&pci_parity_count);
34275 }
34276
34277 if (status & (PCI_STATUS_DETECTED_PARITY)) {
34278 @@ -595,7 +595,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
34279 "Detected Parity Error on %s\n",
34280 pci_name(dev));
34281
34282 - atomic_inc(&pci_parity_count);
34283 + atomic_inc_unchecked(&pci_parity_count);
34284 }
34285 }
34286
34287 @@ -618,7 +618,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
34288 edac_printk(KERN_CRIT, EDAC_PCI, "Bridge "
34289 "Signaled System Error on %s\n",
34290 pci_name(dev));
34291 - atomic_inc(&pci_nonparity_count);
34292 + atomic_inc_unchecked(&pci_nonparity_count);
34293 }
34294
34295 if (status & (PCI_STATUS_PARITY)) {
34296 @@ -626,7 +626,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
34297 "Master Data Parity Error on "
34298 "%s\n", pci_name(dev));
34299
34300 - atomic_inc(&pci_parity_count);
34301 + atomic_inc_unchecked(&pci_parity_count);
34302 }
34303
34304 if (status & (PCI_STATUS_DETECTED_PARITY)) {
34305 @@ -634,7 +634,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
34306 "Detected Parity Error on %s\n",
34307 pci_name(dev));
34308
34309 - atomic_inc(&pci_parity_count);
34310 + atomic_inc_unchecked(&pci_parity_count);
34311 }
34312 }
34313 }
34314 @@ -672,7 +672,7 @@ void edac_pci_do_parity_check(void)
34315 if (!check_pci_errors)
34316 return;
34317
34318 - before_count = atomic_read(&pci_parity_count);
34319 + before_count = atomic_read_unchecked(&pci_parity_count);
34320
34321 /* scan all PCI devices looking for a Parity Error on devices and
34322 * bridges.
34323 @@ -684,7 +684,7 @@ void edac_pci_do_parity_check(void)
34324 /* Only if operator has selected panic on PCI Error */
34325 if (edac_pci_get_panic_on_pe()) {
34326 /* If the count is different 'after' from 'before' */
34327 - if (before_count != atomic_read(&pci_parity_count))
34328 + if (before_count != atomic_read_unchecked(&pci_parity_count))
34329 panic("EDAC: PCI Parity Error");
34330 }
34331 }
34332 diff --git a/drivers/edac/mce_amd.h b/drivers/edac/mce_amd.h
34333 index 6796799..99e8377 100644
34334 --- a/drivers/edac/mce_amd.h
34335 +++ b/drivers/edac/mce_amd.h
34336 @@ -78,7 +78,7 @@ extern const char * const ii_msgs[];
34337 struct amd_decoder_ops {
34338 bool (*mc0_mce)(u16, u8);
34339 bool (*mc1_mce)(u16, u8);
34340 -};
34341 +} __no_const;
34342
34343 void amd_report_gart_errors(bool);
34344 void amd_register_ecc_decoder(void (*f)(int, struct mce *));
34345 diff --git a/drivers/firewire/core-card.c b/drivers/firewire/core-card.c
34346 index 57ea7f4..789e3c3 100644
34347 --- a/drivers/firewire/core-card.c
34348 +++ b/drivers/firewire/core-card.c
34349 @@ -680,7 +680,7 @@ EXPORT_SYMBOL_GPL(fw_card_release);
34350
34351 void fw_core_remove_card(struct fw_card *card)
34352 {
34353 - struct fw_card_driver dummy_driver = dummy_driver_template;
34354 + fw_card_driver_no_const dummy_driver = dummy_driver_template;
34355
34356 card->driver->update_phy_reg(card, 4,
34357 PHY_LINK_ACTIVE | PHY_CONTENDER, 0);
34358 diff --git a/drivers/firewire/core-cdev.c b/drivers/firewire/core-cdev.c
34359 index f8d2287..5aaf4db 100644
34360 --- a/drivers/firewire/core-cdev.c
34361 +++ b/drivers/firewire/core-cdev.c
34362 @@ -1365,8 +1365,7 @@ static int init_iso_resource(struct client *client,
34363 int ret;
34364
34365 if ((request->channels == 0 && request->bandwidth == 0) ||
34366 - request->bandwidth > BANDWIDTH_AVAILABLE_INITIAL ||
34367 - request->bandwidth < 0)
34368 + request->bandwidth > BANDWIDTH_AVAILABLE_INITIAL)
34369 return -EINVAL;
34370
34371 r = kmalloc(sizeof(*r), GFP_KERNEL);
34372 diff --git a/drivers/firewire/core-device.c b/drivers/firewire/core-device.c
34373 index af3e8aa..eb2f227 100644
34374 --- a/drivers/firewire/core-device.c
34375 +++ b/drivers/firewire/core-device.c
34376 @@ -232,7 +232,7 @@ EXPORT_SYMBOL(fw_device_enable_phys_dma);
34377 struct config_rom_attribute {
34378 struct device_attribute attr;
34379 u32 key;
34380 -};
34381 +} __do_const;
34382
34383 static ssize_t show_immediate(struct device *dev,
34384 struct device_attribute *dattr, char *buf)
34385 diff --git a/drivers/firewire/core-transaction.c b/drivers/firewire/core-transaction.c
34386 index 28a94c7..58da63a 100644
34387 --- a/drivers/firewire/core-transaction.c
34388 +++ b/drivers/firewire/core-transaction.c
34389 @@ -38,6 +38,7 @@
34390 #include <linux/timer.h>
34391 #include <linux/types.h>
34392 #include <linux/workqueue.h>
34393 +#include <linux/sched.h>
34394
34395 #include <asm/byteorder.h>
34396
34397 diff --git a/drivers/firewire/core.h b/drivers/firewire/core.h
34398 index 515a42c..5ecf3ba 100644
34399 --- a/drivers/firewire/core.h
34400 +++ b/drivers/firewire/core.h
34401 @@ -111,6 +111,7 @@ struct fw_card_driver {
34402
34403 int (*stop_iso)(struct fw_iso_context *ctx);
34404 };
34405 +typedef struct fw_card_driver __no_const fw_card_driver_no_const;
34406
34407 void fw_card_initialize(struct fw_card *card,
34408 const struct fw_card_driver *driver, struct device *device);
34409 diff --git a/drivers/firmware/dmi-id.c b/drivers/firmware/dmi-id.c
34410 index 94a58a0..f5eba42 100644
34411 --- a/drivers/firmware/dmi-id.c
34412 +++ b/drivers/firmware/dmi-id.c
34413 @@ -16,7 +16,7 @@
34414 struct dmi_device_attribute{
34415 struct device_attribute dev_attr;
34416 int field;
34417 -};
34418 +} __do_const;
34419 #define to_dmi_dev_attr(_dev_attr) \
34420 container_of(_dev_attr, struct dmi_device_attribute, dev_attr)
34421
34422 diff --git a/drivers/firmware/dmi_scan.c b/drivers/firmware/dmi_scan.c
34423 index 4cd392d..4b629e1 100644
34424 --- a/drivers/firmware/dmi_scan.c
34425 +++ b/drivers/firmware/dmi_scan.c
34426 @@ -490,11 +490,6 @@ void __init dmi_scan_machine(void)
34427 }
34428 }
34429 else {
34430 - /*
34431 - * no iounmap() for that ioremap(); it would be a no-op, but
34432 - * it's so early in setup that sucker gets confused into doing
34433 - * what it shouldn't if we actually call it.
34434 - */
34435 p = dmi_ioremap(0xF0000, 0x10000);
34436 if (p == NULL)
34437 goto error;
34438 @@ -769,7 +764,7 @@ int dmi_walk(void (*decode)(const struct dmi_header *, void *),
34439 if (buf == NULL)
34440 return -1;
34441
34442 - dmi_table(buf, dmi_len, dmi_num, decode, private_data);
34443 + dmi_table((char __force_kernel *)buf, dmi_len, dmi_num, decode, private_data);
34444
34445 iounmap(buf);
34446 return 0;
34447 diff --git a/drivers/firmware/efivars.c b/drivers/firmware/efivars.c
34448 index 2a2e145..73745e79 100644
34449 --- a/drivers/firmware/efivars.c
34450 +++ b/drivers/firmware/efivars.c
34451 @@ -133,7 +133,7 @@ struct efivar_attribute {
34452 };
34453
34454 static struct efivars __efivars;
34455 -static struct efivar_operations ops;
34456 +static efivar_operations_no_const ops __read_only;
34457
34458 #define PSTORE_EFI_ATTRIBUTES \
34459 (EFI_VARIABLE_NON_VOLATILE | \
34460 @@ -1798,7 +1798,7 @@ efivar_create_sysfs_entry(struct efivars *efivars,
34461 static int
34462 create_efivars_bin_attributes(struct efivars *efivars)
34463 {
34464 - struct bin_attribute *attr;
34465 + bin_attribute_no_const *attr;
34466 int error;
34467
34468 /* new_var */
34469 diff --git a/drivers/firmware/google/memconsole.c b/drivers/firmware/google/memconsole.c
34470 index 2a90ba6..07f3733 100644
34471 --- a/drivers/firmware/google/memconsole.c
34472 +++ b/drivers/firmware/google/memconsole.c
34473 @@ -147,7 +147,9 @@ static int __init memconsole_init(void)
34474 if (!found_memconsole())
34475 return -ENODEV;
34476
34477 - memconsole_bin_attr.size = memconsole_length;
34478 + pax_open_kernel();
34479 + *(size_t *)&memconsole_bin_attr.size = memconsole_length;
34480 + pax_close_kernel();
34481
34482 ret = sysfs_create_bin_file(firmware_kobj, &memconsole_bin_attr);
34483
34484 diff --git a/drivers/gpio/gpio-ich.c b/drivers/gpio/gpio-ich.c
34485 index 6f2306d..af9476a 100644
34486 --- a/drivers/gpio/gpio-ich.c
34487 +++ b/drivers/gpio/gpio-ich.c
34488 @@ -69,7 +69,7 @@ struct ichx_desc {
34489 /* Some chipsets have quirks, let these use their own request/get */
34490 int (*request)(struct gpio_chip *chip, unsigned offset);
34491 int (*get)(struct gpio_chip *chip, unsigned offset);
34492 -};
34493 +} __do_const;
34494
34495 static struct {
34496 spinlock_t lock;
34497 diff --git a/drivers/gpio/gpio-vr41xx.c b/drivers/gpio/gpio-vr41xx.c
34498 index 9902732..64b62dd 100644
34499 --- a/drivers/gpio/gpio-vr41xx.c
34500 +++ b/drivers/gpio/gpio-vr41xx.c
34501 @@ -204,7 +204,7 @@ static int giu_get_irq(unsigned int irq)
34502 printk(KERN_ERR "spurious GIU interrupt: %04x(%04x),%04x(%04x)\n",
34503 maskl, pendl, maskh, pendh);
34504
34505 - atomic_inc(&irq_err_count);
34506 + atomic_inc_unchecked(&irq_err_count);
34507
34508 return -EINVAL;
34509 }
34510 diff --git a/drivers/gpu/drm/drm_crtc_helper.c b/drivers/gpu/drm/drm_crtc_helper.c
34511 index 7b2d378..cc947ea 100644
34512 --- a/drivers/gpu/drm/drm_crtc_helper.c
34513 +++ b/drivers/gpu/drm/drm_crtc_helper.c
34514 @@ -319,7 +319,7 @@ static bool drm_encoder_crtc_ok(struct drm_encoder *encoder,
34515 struct drm_crtc *tmp;
34516 int crtc_mask = 1;
34517
34518 - WARN(!crtc, "checking null crtc?\n");
34519 + BUG_ON(!crtc);
34520
34521 dev = crtc->dev;
34522
34523 diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
34524 index be174ca..7f38143 100644
34525 --- a/drivers/gpu/drm/drm_drv.c
34526 +++ b/drivers/gpu/drm/drm_drv.c
34527 @@ -307,7 +307,7 @@ module_exit(drm_core_exit);
34528 /**
34529 * Copy and IOCTL return string to user space
34530 */
34531 -static int drm_copy_field(char *buf, size_t *buf_len, const char *value)
34532 +static int drm_copy_field(char __user *buf, size_t *buf_len, const char *value)
34533 {
34534 int len;
34535
34536 @@ -377,7 +377,7 @@ long drm_ioctl(struct file *filp,
34537 struct drm_file *file_priv = filp->private_data;
34538 struct drm_device *dev;
34539 struct drm_ioctl_desc *ioctl;
34540 - drm_ioctl_t *func;
34541 + drm_ioctl_no_const_t func;
34542 unsigned int nr = DRM_IOCTL_NR(cmd);
34543 int retcode = -EINVAL;
34544 char stack_kdata[128];
34545 @@ -390,7 +390,7 @@ long drm_ioctl(struct file *filp,
34546 return -ENODEV;
34547
34548 atomic_inc(&dev->ioctl_count);
34549 - atomic_inc(&dev->counts[_DRM_STAT_IOCTLS]);
34550 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_IOCTLS]);
34551 ++file_priv->ioctl_count;
34552
34553 DRM_DEBUG("pid=%d, cmd=0x%02x, nr=0x%02x, dev 0x%lx, auth=%d\n",
34554 diff --git a/drivers/gpu/drm/drm_fops.c b/drivers/gpu/drm/drm_fops.c
34555 index 133b413..fd68225 100644
34556 --- a/drivers/gpu/drm/drm_fops.c
34557 +++ b/drivers/gpu/drm/drm_fops.c
34558 @@ -71,7 +71,7 @@ static int drm_setup(struct drm_device * dev)
34559 }
34560
34561 for (i = 0; i < ARRAY_SIZE(dev->counts); i++)
34562 - atomic_set(&dev->counts[i], 0);
34563 + atomic_set_unchecked(&dev->counts[i], 0);
34564
34565 dev->sigdata.lock = NULL;
34566
34567 @@ -134,7 +134,7 @@ int drm_open(struct inode *inode, struct file *filp)
34568 if (drm_device_is_unplugged(dev))
34569 return -ENODEV;
34570
34571 - if (!dev->open_count++)
34572 + if (local_inc_return(&dev->open_count) == 1)
34573 need_setup = 1;
34574 mutex_lock(&dev->struct_mutex);
34575 old_mapping = dev->dev_mapping;
34576 @@ -149,7 +149,7 @@ int drm_open(struct inode *inode, struct file *filp)
34577 retcode = drm_open_helper(inode, filp, dev);
34578 if (retcode)
34579 goto err_undo;
34580 - atomic_inc(&dev->counts[_DRM_STAT_OPENS]);
34581 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_OPENS]);
34582 if (need_setup) {
34583 retcode = drm_setup(dev);
34584 if (retcode)
34585 @@ -164,7 +164,7 @@ err_undo:
34586 iput(container_of(dev->dev_mapping, struct inode, i_data));
34587 dev->dev_mapping = old_mapping;
34588 mutex_unlock(&dev->struct_mutex);
34589 - dev->open_count--;
34590 + local_dec(&dev->open_count);
34591 return retcode;
34592 }
34593 EXPORT_SYMBOL(drm_open);
34594 @@ -438,7 +438,7 @@ int drm_release(struct inode *inode, struct file *filp)
34595
34596 mutex_lock(&drm_global_mutex);
34597
34598 - DRM_DEBUG("open_count = %d\n", dev->open_count);
34599 + DRM_DEBUG("open_count = %ld\n", local_read(&dev->open_count));
34600
34601 if (dev->driver->preclose)
34602 dev->driver->preclose(dev, file_priv);
34603 @@ -447,10 +447,10 @@ int drm_release(struct inode *inode, struct file *filp)
34604 * Begin inline drm_release
34605 */
34606
34607 - DRM_DEBUG("pid = %d, device = 0x%lx, open_count = %d\n",
34608 + DRM_DEBUG("pid = %d, device = 0x%lx, open_count = %ld\n",
34609 task_pid_nr(current),
34610 (long)old_encode_dev(file_priv->minor->device),
34611 - dev->open_count);
34612 + local_read(&dev->open_count));
34613
34614 /* Release any auth tokens that might point to this file_priv,
34615 (do that under the drm_global_mutex) */
34616 @@ -547,8 +547,8 @@ int drm_release(struct inode *inode, struct file *filp)
34617 * End inline drm_release
34618 */
34619
34620 - atomic_inc(&dev->counts[_DRM_STAT_CLOSES]);
34621 - if (!--dev->open_count) {
34622 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_CLOSES]);
34623 + if (local_dec_and_test(&dev->open_count)) {
34624 if (atomic_read(&dev->ioctl_count)) {
34625 DRM_ERROR("Device busy: %d\n",
34626 atomic_read(&dev->ioctl_count));
34627 diff --git a/drivers/gpu/drm/drm_global.c b/drivers/gpu/drm/drm_global.c
34628 index f731116..629842c 100644
34629 --- a/drivers/gpu/drm/drm_global.c
34630 +++ b/drivers/gpu/drm/drm_global.c
34631 @@ -36,7 +36,7 @@
34632 struct drm_global_item {
34633 struct mutex mutex;
34634 void *object;
34635 - int refcount;
34636 + atomic_t refcount;
34637 };
34638
34639 static struct drm_global_item glob[DRM_GLOBAL_NUM];
34640 @@ -49,7 +49,7 @@ void drm_global_init(void)
34641 struct drm_global_item *item = &glob[i];
34642 mutex_init(&item->mutex);
34643 item->object = NULL;
34644 - item->refcount = 0;
34645 + atomic_set(&item->refcount, 0);
34646 }
34647 }
34648
34649 @@ -59,7 +59,7 @@ void drm_global_release(void)
34650 for (i = 0; i < DRM_GLOBAL_NUM; ++i) {
34651 struct drm_global_item *item = &glob[i];
34652 BUG_ON(item->object != NULL);
34653 - BUG_ON(item->refcount != 0);
34654 + BUG_ON(atomic_read(&item->refcount) != 0);
34655 }
34656 }
34657
34658 @@ -70,7 +70,7 @@ int drm_global_item_ref(struct drm_global_reference *ref)
34659 void *object;
34660
34661 mutex_lock(&item->mutex);
34662 - if (item->refcount == 0) {
34663 + if (atomic_read(&item->refcount) == 0) {
34664 item->object = kzalloc(ref->size, GFP_KERNEL);
34665 if (unlikely(item->object == NULL)) {
34666 ret = -ENOMEM;
34667 @@ -83,7 +83,7 @@ int drm_global_item_ref(struct drm_global_reference *ref)
34668 goto out_err;
34669
34670 }
34671 - ++item->refcount;
34672 + atomic_inc(&item->refcount);
34673 ref->object = item->object;
34674 object = item->object;
34675 mutex_unlock(&item->mutex);
34676 @@ -100,9 +100,9 @@ void drm_global_item_unref(struct drm_global_reference *ref)
34677 struct drm_global_item *item = &glob[ref->global_type];
34678
34679 mutex_lock(&item->mutex);
34680 - BUG_ON(item->refcount == 0);
34681 + BUG_ON(atomic_read(&item->refcount) == 0);
34682 BUG_ON(ref->object != item->object);
34683 - if (--item->refcount == 0) {
34684 + if (atomic_dec_and_test(&item->refcount)) {
34685 ref->release(ref);
34686 item->object = NULL;
34687 }
34688 diff --git a/drivers/gpu/drm/drm_info.c b/drivers/gpu/drm/drm_info.c
34689 index d4b20ce..77a8d41 100644
34690 --- a/drivers/gpu/drm/drm_info.c
34691 +++ b/drivers/gpu/drm/drm_info.c
34692 @@ -75,10 +75,14 @@ int drm_vm_info(struct seq_file *m, void *data)
34693 struct drm_local_map *map;
34694 struct drm_map_list *r_list;
34695
34696 - /* Hardcoded from _DRM_FRAME_BUFFER,
34697 - _DRM_REGISTERS, _DRM_SHM, _DRM_AGP, and
34698 - _DRM_SCATTER_GATHER and _DRM_CONSISTENT */
34699 - const char *types[] = { "FB", "REG", "SHM", "AGP", "SG", "PCI" };
34700 + static const char * const types[] = {
34701 + [_DRM_FRAME_BUFFER] = "FB",
34702 + [_DRM_REGISTERS] = "REG",
34703 + [_DRM_SHM] = "SHM",
34704 + [_DRM_AGP] = "AGP",
34705 + [_DRM_SCATTER_GATHER] = "SG",
34706 + [_DRM_CONSISTENT] = "PCI",
34707 + [_DRM_GEM] = "GEM" };
34708 const char *type;
34709 int i;
34710
34711 @@ -89,7 +93,7 @@ int drm_vm_info(struct seq_file *m, void *data)
34712 map = r_list->map;
34713 if (!map)
34714 continue;
34715 - if (map->type < 0 || map->type > 5)
34716 + if (map->type >= ARRAY_SIZE(types))
34717 type = "??";
34718 else
34719 type = types[map->type];
34720 @@ -253,7 +257,11 @@ int drm_vma_info(struct seq_file *m, void *data)
34721 vma->vm_flags & VM_MAYSHARE ? 's' : 'p',
34722 vma->vm_flags & VM_LOCKED ? 'l' : '-',
34723 vma->vm_flags & VM_IO ? 'i' : '-',
34724 +#ifdef CONFIG_GRKERNSEC_HIDESYM
34725 + 0);
34726 +#else
34727 vma->vm_pgoff);
34728 +#endif
34729
34730 #if defined(__i386__)
34731 pgprot = pgprot_val(vma->vm_page_prot);
34732 diff --git a/drivers/gpu/drm/drm_ioc32.c b/drivers/gpu/drm/drm_ioc32.c
34733 index 2f4c434..dd12cd2 100644
34734 --- a/drivers/gpu/drm/drm_ioc32.c
34735 +++ b/drivers/gpu/drm/drm_ioc32.c
34736 @@ -457,7 +457,7 @@ static int compat_drm_infobufs(struct file *file, unsigned int cmd,
34737 request = compat_alloc_user_space(nbytes);
34738 if (!access_ok(VERIFY_WRITE, request, nbytes))
34739 return -EFAULT;
34740 - list = (struct drm_buf_desc *) (request + 1);
34741 + list = (struct drm_buf_desc __user *) (request + 1);
34742
34743 if (__put_user(count, &request->count)
34744 || __put_user(list, &request->list))
34745 @@ -518,7 +518,7 @@ static int compat_drm_mapbufs(struct file *file, unsigned int cmd,
34746 request = compat_alloc_user_space(nbytes);
34747 if (!access_ok(VERIFY_WRITE, request, nbytes))
34748 return -EFAULT;
34749 - list = (struct drm_buf_pub *) (request + 1);
34750 + list = (struct drm_buf_pub __user *) (request + 1);
34751
34752 if (__put_user(count, &request->count)
34753 || __put_user(list, &request->list))
34754 @@ -1016,7 +1016,7 @@ static int compat_drm_wait_vblank(struct file *file, unsigned int cmd,
34755 return 0;
34756 }
34757
34758 -drm_ioctl_compat_t *drm_compat_ioctls[] = {
34759 +drm_ioctl_compat_t drm_compat_ioctls[] = {
34760 [DRM_IOCTL_NR(DRM_IOCTL_VERSION32)] = compat_drm_version,
34761 [DRM_IOCTL_NR(DRM_IOCTL_GET_UNIQUE32)] = compat_drm_getunique,
34762 [DRM_IOCTL_NR(DRM_IOCTL_GET_MAP32)] = compat_drm_getmap,
34763 @@ -1062,7 +1062,6 @@ drm_ioctl_compat_t *drm_compat_ioctls[] = {
34764 long drm_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
34765 {
34766 unsigned int nr = DRM_IOCTL_NR(cmd);
34767 - drm_ioctl_compat_t *fn;
34768 int ret;
34769
34770 /* Assume that ioctls without an explicit compat routine will just
34771 @@ -1072,10 +1071,8 @@ long drm_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
34772 if (nr >= ARRAY_SIZE(drm_compat_ioctls))
34773 return drm_ioctl(filp, cmd, arg);
34774
34775 - fn = drm_compat_ioctls[nr];
34776 -
34777 - if (fn != NULL)
34778 - ret = (*fn) (filp, cmd, arg);
34779 + if (drm_compat_ioctls[nr] != NULL)
34780 + ret = (*drm_compat_ioctls[nr]) (filp, cmd, arg);
34781 else
34782 ret = drm_ioctl(filp, cmd, arg);
34783
34784 diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c
34785 index e77bd8b..1571b85 100644
34786 --- a/drivers/gpu/drm/drm_ioctl.c
34787 +++ b/drivers/gpu/drm/drm_ioctl.c
34788 @@ -252,7 +252,7 @@ int drm_getstats(struct drm_device *dev, void *data,
34789 stats->data[i].value =
34790 (file_priv->master->lock.hw_lock ? file_priv->master->lock.hw_lock->lock : 0);
34791 else
34792 - stats->data[i].value = atomic_read(&dev->counts[i]);
34793 + stats->data[i].value = atomic_read_unchecked(&dev->counts[i]);
34794 stats->data[i].type = dev->types[i];
34795 }
34796
34797 diff --git a/drivers/gpu/drm/drm_lock.c b/drivers/gpu/drm/drm_lock.c
34798 index d752c96..fe08455 100644
34799 --- a/drivers/gpu/drm/drm_lock.c
34800 +++ b/drivers/gpu/drm/drm_lock.c
34801 @@ -86,7 +86,7 @@ int drm_lock(struct drm_device *dev, void *data, struct drm_file *file_priv)
34802 if (drm_lock_take(&master->lock, lock->context)) {
34803 master->lock.file_priv = file_priv;
34804 master->lock.lock_time = jiffies;
34805 - atomic_inc(&dev->counts[_DRM_STAT_LOCKS]);
34806 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_LOCKS]);
34807 break; /* Got lock */
34808 }
34809
34810 @@ -157,7 +157,7 @@ int drm_unlock(struct drm_device *dev, void *data, struct drm_file *file_priv)
34811 return -EINVAL;
34812 }
34813
34814 - atomic_inc(&dev->counts[_DRM_STAT_UNLOCKS]);
34815 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_UNLOCKS]);
34816
34817 if (drm_lock_free(&master->lock, lock->context)) {
34818 /* FIXME: Should really bail out here. */
34819 diff --git a/drivers/gpu/drm/drm_stub.c b/drivers/gpu/drm/drm_stub.c
34820 index 200e104..59facda 100644
34821 --- a/drivers/gpu/drm/drm_stub.c
34822 +++ b/drivers/gpu/drm/drm_stub.c
34823 @@ -516,7 +516,7 @@ void drm_unplug_dev(struct drm_device *dev)
34824
34825 drm_device_set_unplugged(dev);
34826
34827 - if (dev->open_count == 0) {
34828 + if (local_read(&dev->open_count) == 0) {
34829 drm_put_dev(dev);
34830 }
34831 mutex_unlock(&drm_global_mutex);
34832 diff --git a/drivers/gpu/drm/i810/i810_dma.c b/drivers/gpu/drm/i810/i810_dma.c
34833 index 004ecdf..db1f6e0 100644
34834 --- a/drivers/gpu/drm/i810/i810_dma.c
34835 +++ b/drivers/gpu/drm/i810/i810_dma.c
34836 @@ -945,8 +945,8 @@ static int i810_dma_vertex(struct drm_device *dev, void *data,
34837 dma->buflist[vertex->idx],
34838 vertex->discard, vertex->used);
34839
34840 - atomic_add(vertex->used, &dev->counts[_DRM_STAT_SECONDARY]);
34841 - atomic_inc(&dev->counts[_DRM_STAT_DMA]);
34842 + atomic_add_unchecked(vertex->used, &dev->counts[_DRM_STAT_SECONDARY]);
34843 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_DMA]);
34844 sarea_priv->last_enqueue = dev_priv->counter - 1;
34845 sarea_priv->last_dispatch = (int)hw_status[5];
34846
34847 @@ -1106,8 +1106,8 @@ static int i810_dma_mc(struct drm_device *dev, void *data,
34848 i810_dma_dispatch_mc(dev, dma->buflist[mc->idx], mc->used,
34849 mc->last_render);
34850
34851 - atomic_add(mc->used, &dev->counts[_DRM_STAT_SECONDARY]);
34852 - atomic_inc(&dev->counts[_DRM_STAT_DMA]);
34853 + atomic_add_unchecked(mc->used, &dev->counts[_DRM_STAT_SECONDARY]);
34854 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_DMA]);
34855 sarea_priv->last_enqueue = dev_priv->counter - 1;
34856 sarea_priv->last_dispatch = (int)hw_status[5];
34857
34858 diff --git a/drivers/gpu/drm/i810/i810_drv.h b/drivers/gpu/drm/i810/i810_drv.h
34859 index 6e0acad..93c8289 100644
34860 --- a/drivers/gpu/drm/i810/i810_drv.h
34861 +++ b/drivers/gpu/drm/i810/i810_drv.h
34862 @@ -108,8 +108,8 @@ typedef struct drm_i810_private {
34863 int page_flipping;
34864
34865 wait_queue_head_t irq_queue;
34866 - atomic_t irq_received;
34867 - atomic_t irq_emitted;
34868 + atomic_unchecked_t irq_received;
34869 + atomic_unchecked_t irq_emitted;
34870
34871 int front_offset;
34872 } drm_i810_private_t;
34873 diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c
34874 index 8a7c48b..72effc2 100644
34875 --- a/drivers/gpu/drm/i915/i915_debugfs.c
34876 +++ b/drivers/gpu/drm/i915/i915_debugfs.c
34877 @@ -496,7 +496,7 @@ static int i915_interrupt_info(struct seq_file *m, void *data)
34878 I915_READ(GTIMR));
34879 }
34880 seq_printf(m, "Interrupts received: %d\n",
34881 - atomic_read(&dev_priv->irq_received));
34882 + atomic_read_unchecked(&dev_priv->irq_received));
34883 for_each_ring(ring, dev_priv, i) {
34884 if (IS_GEN6(dev) || IS_GEN7(dev)) {
34885 seq_printf(m,
34886 diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c
34887 index 5206f24..7af0a0a 100644
34888 --- a/drivers/gpu/drm/i915/i915_dma.c
34889 +++ b/drivers/gpu/drm/i915/i915_dma.c
34890 @@ -1253,7 +1253,7 @@ static bool i915_switcheroo_can_switch(struct pci_dev *pdev)
34891 bool can_switch;
34892
34893 spin_lock(&dev->count_lock);
34894 - can_switch = (dev->open_count == 0);
34895 + can_switch = (local_read(&dev->open_count) == 0);
34896 spin_unlock(&dev->count_lock);
34897 return can_switch;
34898 }
34899 diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
34900 index 66ad64f..a865871 100644
34901 --- a/drivers/gpu/drm/i915/i915_drv.h
34902 +++ b/drivers/gpu/drm/i915/i915_drv.h
34903 @@ -656,7 +656,7 @@ typedef struct drm_i915_private {
34904 drm_dma_handle_t *status_page_dmah;
34905 struct resource mch_res;
34906
34907 - atomic_t irq_received;
34908 + atomic_unchecked_t irq_received;
34909
34910 /* protects the irq masks */
34911 spinlock_t irq_lock;
34912 @@ -1103,7 +1103,7 @@ struct drm_i915_gem_object {
34913 * will be page flipped away on the next vblank. When it
34914 * reaches 0, dev_priv->pending_flip_queue will be woken up.
34915 */
34916 - atomic_t pending_flip;
34917 + atomic_unchecked_t pending_flip;
34918 };
34919 #define to_gem_object(obj) (&((struct drm_i915_gem_object *)(obj))->base)
34920
34921 @@ -1634,7 +1634,7 @@ extern struct i2c_adapter *intel_gmbus_get_adapter(
34922 struct drm_i915_private *dev_priv, unsigned port);
34923 extern void intel_gmbus_set_speed(struct i2c_adapter *adapter, int speed);
34924 extern void intel_gmbus_force_bit(struct i2c_adapter *adapter, bool force_bit);
34925 -extern inline bool intel_gmbus_is_forced_bit(struct i2c_adapter *adapter)
34926 +static inline bool intel_gmbus_is_forced_bit(struct i2c_adapter *adapter)
34927 {
34928 return container_of(adapter, struct intel_gmbus, adapter)->force_bit;
34929 }
34930 diff --git a/drivers/gpu/drm/i915/i915_gem_execbuffer.c b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
34931 index 26d08bb..a6203ff 100644
34932 --- a/drivers/gpu/drm/i915/i915_gem_execbuffer.c
34933 +++ b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
34934 @@ -672,7 +672,7 @@ i915_gem_execbuffer_move_to_gpu(struct intel_ring_buffer *ring,
34935 i915_gem_clflush_object(obj);
34936
34937 if (obj->base.pending_write_domain)
34938 - flips |= atomic_read(&obj->pending_flip);
34939 + flips |= atomic_read_unchecked(&obj->pending_flip);
34940
34941 flush_domains |= obj->base.write_domain;
34942 }
34943 @@ -703,9 +703,9 @@ i915_gem_check_execbuffer(struct drm_i915_gem_execbuffer2 *exec)
34944
34945 static int
34946 validate_exec_list(struct drm_i915_gem_exec_object2 *exec,
34947 - int count)
34948 + unsigned int count)
34949 {
34950 - int i;
34951 + unsigned int i;
34952
34953 for (i = 0; i < count; i++) {
34954 char __user *ptr = (char __user *)(uintptr_t)exec[i].relocs_ptr;
34955 @@ -1197,7 +1197,7 @@ i915_gem_execbuffer2(struct drm_device *dev, void *data,
34956 return -ENOMEM;
34957 }
34958 ret = copy_from_user(exec2_list,
34959 - (struct drm_i915_relocation_entry __user *)
34960 + (struct drm_i915_gem_exec_object2 __user *)
34961 (uintptr_t) args->buffers_ptr,
34962 sizeof(*exec2_list) * args->buffer_count);
34963 if (ret != 0) {
34964 diff --git a/drivers/gpu/drm/i915/i915_ioc32.c b/drivers/gpu/drm/i915/i915_ioc32.c
34965 index 3c59584..500f2e9 100644
34966 --- a/drivers/gpu/drm/i915/i915_ioc32.c
34967 +++ b/drivers/gpu/drm/i915/i915_ioc32.c
34968 @@ -181,7 +181,7 @@ static int compat_i915_alloc(struct file *file, unsigned int cmd,
34969 (unsigned long)request);
34970 }
34971
34972 -static drm_ioctl_compat_t *i915_compat_ioctls[] = {
34973 +static drm_ioctl_compat_t i915_compat_ioctls[] = {
34974 [DRM_I915_BATCHBUFFER] = compat_i915_batchbuffer,
34975 [DRM_I915_CMDBUFFER] = compat_i915_cmdbuffer,
34976 [DRM_I915_GETPARAM] = compat_i915_getparam,
34977 @@ -202,18 +202,15 @@ static drm_ioctl_compat_t *i915_compat_ioctls[] = {
34978 long i915_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
34979 {
34980 unsigned int nr = DRM_IOCTL_NR(cmd);
34981 - drm_ioctl_compat_t *fn = NULL;
34982 int ret;
34983
34984 if (nr < DRM_COMMAND_BASE)
34985 return drm_compat_ioctl(filp, cmd, arg);
34986
34987 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(i915_compat_ioctls))
34988 - fn = i915_compat_ioctls[nr - DRM_COMMAND_BASE];
34989 -
34990 - if (fn != NULL)
34991 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(i915_compat_ioctls)) {
34992 + drm_ioctl_compat_t fn = i915_compat_ioctls[nr - DRM_COMMAND_BASE];
34993 ret = (*fn) (filp, cmd, arg);
34994 - else
34995 + } else
34996 ret = drm_ioctl(filp, cmd, arg);
34997
34998 return ret;
34999 diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c
35000 index 3c00403..5a5c6c9 100644
35001 --- a/drivers/gpu/drm/i915/i915_irq.c
35002 +++ b/drivers/gpu/drm/i915/i915_irq.c
35003 @@ -539,7 +539,7 @@ static irqreturn_t valleyview_irq_handler(int irq, void *arg)
35004 u32 pipe_stats[I915_MAX_PIPES];
35005 bool blc_event;
35006
35007 - atomic_inc(&dev_priv->irq_received);
35008 + atomic_inc_unchecked(&dev_priv->irq_received);
35009
35010 while (true) {
35011 iir = I915_READ(VLV_IIR);
35012 @@ -692,7 +692,7 @@ static irqreturn_t ivybridge_irq_handler(int irq, void *arg)
35013 irqreturn_t ret = IRQ_NONE;
35014 int i;
35015
35016 - atomic_inc(&dev_priv->irq_received);
35017 + atomic_inc_unchecked(&dev_priv->irq_received);
35018
35019 /* disable master interrupt before clearing iir */
35020 de_ier = I915_READ(DEIER);
35021 @@ -764,7 +764,7 @@ static irqreturn_t ironlake_irq_handler(int irq, void *arg)
35022 int ret = IRQ_NONE;
35023 u32 de_iir, gt_iir, de_ier, pch_iir, pm_iir;
35024
35025 - atomic_inc(&dev_priv->irq_received);
35026 + atomic_inc_unchecked(&dev_priv->irq_received);
35027
35028 /* disable master interrupt before clearing iir */
35029 de_ier = I915_READ(DEIER);
35030 @@ -1791,7 +1791,7 @@ static void ironlake_irq_preinstall(struct drm_device *dev)
35031 {
35032 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
35033
35034 - atomic_set(&dev_priv->irq_received, 0);
35035 + atomic_set_unchecked(&dev_priv->irq_received, 0);
35036
35037 I915_WRITE(HWSTAM, 0xeffe);
35038
35039 @@ -1817,7 +1817,7 @@ static void valleyview_irq_preinstall(struct drm_device *dev)
35040 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
35041 int pipe;
35042
35043 - atomic_set(&dev_priv->irq_received, 0);
35044 + atomic_set_unchecked(&dev_priv->irq_received, 0);
35045
35046 /* VLV magic */
35047 I915_WRITE(VLV_IMR, 0);
35048 @@ -2112,7 +2112,7 @@ static void i8xx_irq_preinstall(struct drm_device * dev)
35049 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
35050 int pipe;
35051
35052 - atomic_set(&dev_priv->irq_received, 0);
35053 + atomic_set_unchecked(&dev_priv->irq_received, 0);
35054
35055 for_each_pipe(pipe)
35056 I915_WRITE(PIPESTAT(pipe), 0);
35057 @@ -2163,7 +2163,7 @@ static irqreturn_t i8xx_irq_handler(int irq, void *arg)
35058 I915_DISPLAY_PLANE_A_FLIP_PENDING_INTERRUPT |
35059 I915_DISPLAY_PLANE_B_FLIP_PENDING_INTERRUPT;
35060
35061 - atomic_inc(&dev_priv->irq_received);
35062 + atomic_inc_unchecked(&dev_priv->irq_received);
35063
35064 iir = I915_READ16(IIR);
35065 if (iir == 0)
35066 @@ -2248,7 +2248,7 @@ static void i915_irq_preinstall(struct drm_device * dev)
35067 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
35068 int pipe;
35069
35070 - atomic_set(&dev_priv->irq_received, 0);
35071 + atomic_set_unchecked(&dev_priv->irq_received, 0);
35072
35073 if (I915_HAS_HOTPLUG(dev)) {
35074 I915_WRITE(PORT_HOTPLUG_EN, 0);
35075 @@ -2343,7 +2343,7 @@ static irqreturn_t i915_irq_handler(int irq, void *arg)
35076 };
35077 int pipe, ret = IRQ_NONE;
35078
35079 - atomic_inc(&dev_priv->irq_received);
35080 + atomic_inc_unchecked(&dev_priv->irq_received);
35081
35082 iir = I915_READ(IIR);
35083 do {
35084 @@ -2469,7 +2469,7 @@ static void i965_irq_preinstall(struct drm_device * dev)
35085 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
35086 int pipe;
35087
35088 - atomic_set(&dev_priv->irq_received, 0);
35089 + atomic_set_unchecked(&dev_priv->irq_received, 0);
35090
35091 I915_WRITE(PORT_HOTPLUG_EN, 0);
35092 I915_WRITE(PORT_HOTPLUG_STAT, I915_READ(PORT_HOTPLUG_STAT));
35093 @@ -2576,7 +2576,7 @@ static irqreturn_t i965_irq_handler(int irq, void *arg)
35094 int irq_received;
35095 int ret = IRQ_NONE, pipe;
35096
35097 - atomic_inc(&dev_priv->irq_received);
35098 + atomic_inc_unchecked(&dev_priv->irq_received);
35099
35100 iir = I915_READ(IIR);
35101
35102 diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
35103 index 80aa1fc..85cfce3 100644
35104 --- a/drivers/gpu/drm/i915/intel_display.c
35105 +++ b/drivers/gpu/drm/i915/intel_display.c
35106 @@ -2255,7 +2255,7 @@ intel_finish_fb(struct drm_framebuffer *old_fb)
35107
35108 wait_event(dev_priv->pending_flip_queue,
35109 atomic_read(&dev_priv->mm.wedged) ||
35110 - atomic_read(&obj->pending_flip) == 0);
35111 + atomic_read_unchecked(&obj->pending_flip) == 0);
35112
35113 /* Big Hammer, we also need to ensure that any pending
35114 * MI_WAIT_FOR_EVENT inside a user batch buffer on the
35115 @@ -7122,8 +7122,7 @@ static void do_intel_finish_page_flip(struct drm_device *dev,
35116
35117 obj = work->old_fb_obj;
35118
35119 - atomic_clear_mask(1 << intel_crtc->plane,
35120 - &obj->pending_flip.counter);
35121 + atomic_clear_mask_unchecked(1 << intel_crtc->plane, &obj->pending_flip);
35122 wake_up(&dev_priv->pending_flip_queue);
35123
35124 queue_work(dev_priv->wq, &work->work);
35125 @@ -7490,7 +7489,7 @@ static int intel_crtc_page_flip(struct drm_crtc *crtc,
35126 /* Block clients from rendering to the new back buffer until
35127 * the flip occurs and the object is no longer visible.
35128 */
35129 - atomic_add(1 << intel_crtc->plane, &work->old_fb_obj->pending_flip);
35130 + atomic_add_unchecked(1 << intel_crtc->plane, &work->old_fb_obj->pending_flip);
35131 atomic_inc(&intel_crtc->unpin_work_count);
35132
35133 ret = dev_priv->display.queue_flip(dev, crtc, fb, obj);
35134 @@ -7507,7 +7506,7 @@ static int intel_crtc_page_flip(struct drm_crtc *crtc,
35135
35136 cleanup_pending:
35137 atomic_dec(&intel_crtc->unpin_work_count);
35138 - atomic_sub(1 << intel_crtc->plane, &work->old_fb_obj->pending_flip);
35139 + atomic_sub_unchecked(1 << intel_crtc->plane, &work->old_fb_obj->pending_flip);
35140 drm_gem_object_unreference(&work->old_fb_obj->base);
35141 drm_gem_object_unreference(&obj->base);
35142 mutex_unlock(&dev->struct_mutex);
35143 @@ -8849,13 +8848,13 @@ struct intel_quirk {
35144 int subsystem_vendor;
35145 int subsystem_device;
35146 void (*hook)(struct drm_device *dev);
35147 -};
35148 +} __do_const;
35149
35150 /* For systems that don't have a meaningful PCI subdevice/subvendor ID */
35151 struct intel_dmi_quirk {
35152 void (*hook)(struct drm_device *dev);
35153 const struct dmi_system_id (*dmi_id_list)[];
35154 -};
35155 +} __do_const;
35156
35157 static int intel_dmi_reverse_brightness(const struct dmi_system_id *id)
35158 {
35159 @@ -8863,18 +8862,20 @@ static int intel_dmi_reverse_brightness(const struct dmi_system_id *id)
35160 return 1;
35161 }
35162
35163 +static const struct dmi_system_id intel_dmi_quirks_table[] = {
35164 + {
35165 + .callback = intel_dmi_reverse_brightness,
35166 + .ident = "NCR Corporation",
35167 + .matches = {DMI_MATCH(DMI_SYS_VENDOR, "NCR Corporation"),
35168 + DMI_MATCH(DMI_PRODUCT_NAME, ""),
35169 + },
35170 + },
35171 + { } /* terminating entry */
35172 +};
35173 +
35174 static const struct intel_dmi_quirk intel_dmi_quirks[] = {
35175 {
35176 - .dmi_id_list = &(const struct dmi_system_id[]) {
35177 - {
35178 - .callback = intel_dmi_reverse_brightness,
35179 - .ident = "NCR Corporation",
35180 - .matches = {DMI_MATCH(DMI_SYS_VENDOR, "NCR Corporation"),
35181 - DMI_MATCH(DMI_PRODUCT_NAME, ""),
35182 - },
35183 - },
35184 - { } /* terminating entry */
35185 - },
35186 + .dmi_id_list = &intel_dmi_quirks_table,
35187 .hook = quirk_invert_brightness,
35188 },
35189 };
35190 diff --git a/drivers/gpu/drm/mga/mga_drv.h b/drivers/gpu/drm/mga/mga_drv.h
35191 index 54558a0..2d97005 100644
35192 --- a/drivers/gpu/drm/mga/mga_drv.h
35193 +++ b/drivers/gpu/drm/mga/mga_drv.h
35194 @@ -120,9 +120,9 @@ typedef struct drm_mga_private {
35195 u32 clear_cmd;
35196 u32 maccess;
35197
35198 - atomic_t vbl_received; /**< Number of vblanks received. */
35199 + atomic_unchecked_t vbl_received; /**< Number of vblanks received. */
35200 wait_queue_head_t fence_queue;
35201 - atomic_t last_fence_retired;
35202 + atomic_unchecked_t last_fence_retired;
35203 u32 next_fence_to_post;
35204
35205 unsigned int fb_cpp;
35206 diff --git a/drivers/gpu/drm/mga/mga_ioc32.c b/drivers/gpu/drm/mga/mga_ioc32.c
35207 index 709e90d..89a1c0d 100644
35208 --- a/drivers/gpu/drm/mga/mga_ioc32.c
35209 +++ b/drivers/gpu/drm/mga/mga_ioc32.c
35210 @@ -189,7 +189,7 @@ static int compat_mga_dma_bootstrap(struct file *file, unsigned int cmd,
35211 return 0;
35212 }
35213
35214 -drm_ioctl_compat_t *mga_compat_ioctls[] = {
35215 +drm_ioctl_compat_t mga_compat_ioctls[] = {
35216 [DRM_MGA_INIT] = compat_mga_init,
35217 [DRM_MGA_GETPARAM] = compat_mga_getparam,
35218 [DRM_MGA_DMA_BOOTSTRAP] = compat_mga_dma_bootstrap,
35219 @@ -207,18 +207,15 @@ drm_ioctl_compat_t *mga_compat_ioctls[] = {
35220 long mga_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
35221 {
35222 unsigned int nr = DRM_IOCTL_NR(cmd);
35223 - drm_ioctl_compat_t *fn = NULL;
35224 int ret;
35225
35226 if (nr < DRM_COMMAND_BASE)
35227 return drm_compat_ioctl(filp, cmd, arg);
35228
35229 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(mga_compat_ioctls))
35230 - fn = mga_compat_ioctls[nr - DRM_COMMAND_BASE];
35231 -
35232 - if (fn != NULL)
35233 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(mga_compat_ioctls)) {
35234 + drm_ioctl_compat_t fn = mga_compat_ioctls[nr - DRM_COMMAND_BASE];
35235 ret = (*fn) (filp, cmd, arg);
35236 - else
35237 + } else
35238 ret = drm_ioctl(filp, cmd, arg);
35239
35240 return ret;
35241 diff --git a/drivers/gpu/drm/mga/mga_irq.c b/drivers/gpu/drm/mga/mga_irq.c
35242 index 598c281..60d590e 100644
35243 --- a/drivers/gpu/drm/mga/mga_irq.c
35244 +++ b/drivers/gpu/drm/mga/mga_irq.c
35245 @@ -43,7 +43,7 @@ u32 mga_get_vblank_counter(struct drm_device *dev, int crtc)
35246 if (crtc != 0)
35247 return 0;
35248
35249 - return atomic_read(&dev_priv->vbl_received);
35250 + return atomic_read_unchecked(&dev_priv->vbl_received);
35251 }
35252
35253
35254 @@ -59,7 +59,7 @@ irqreturn_t mga_driver_irq_handler(DRM_IRQ_ARGS)
35255 /* VBLANK interrupt */
35256 if (status & MGA_VLINEPEN) {
35257 MGA_WRITE(MGA_ICLEAR, MGA_VLINEICLR);
35258 - atomic_inc(&dev_priv->vbl_received);
35259 + atomic_inc_unchecked(&dev_priv->vbl_received);
35260 drm_handle_vblank(dev, 0);
35261 handled = 1;
35262 }
35263 @@ -78,7 +78,7 @@ irqreturn_t mga_driver_irq_handler(DRM_IRQ_ARGS)
35264 if ((prim_start & ~0x03) != (prim_end & ~0x03))
35265 MGA_WRITE(MGA_PRIMEND, prim_end);
35266
35267 - atomic_inc(&dev_priv->last_fence_retired);
35268 + atomic_inc_unchecked(&dev_priv->last_fence_retired);
35269 DRM_WAKEUP(&dev_priv->fence_queue);
35270 handled = 1;
35271 }
35272 @@ -129,7 +129,7 @@ int mga_driver_fence_wait(struct drm_device *dev, unsigned int *sequence)
35273 * using fences.
35274 */
35275 DRM_WAIT_ON(ret, dev_priv->fence_queue, 3 * DRM_HZ,
35276 - (((cur_fence = atomic_read(&dev_priv->last_fence_retired))
35277 + (((cur_fence = atomic_read_unchecked(&dev_priv->last_fence_retired))
35278 - *sequence) <= (1 << 23)));
35279
35280 *sequence = cur_fence;
35281 diff --git a/drivers/gpu/drm/nouveau/nouveau_bios.c b/drivers/gpu/drm/nouveau/nouveau_bios.c
35282 index 865eddf..62c4cc3 100644
35283 --- a/drivers/gpu/drm/nouveau/nouveau_bios.c
35284 +++ b/drivers/gpu/drm/nouveau/nouveau_bios.c
35285 @@ -1015,7 +1015,7 @@ static int parse_bit_tmds_tbl_entry(struct drm_device *dev, struct nvbios *bios,
35286 struct bit_table {
35287 const char id;
35288 int (* const parse_fn)(struct drm_device *, struct nvbios *, struct bit_entry *);
35289 -};
35290 +} __no_const;
35291
35292 #define BIT_TABLE(id, funcid) ((struct bit_table){ id, parse_bit_##funcid##_tbl_entry })
35293
35294 diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.h b/drivers/gpu/drm/nouveau/nouveau_drm.h
35295 index aa89eb9..d45d38b 100644
35296 --- a/drivers/gpu/drm/nouveau/nouveau_drm.h
35297 +++ b/drivers/gpu/drm/nouveau/nouveau_drm.h
35298 @@ -80,7 +80,7 @@ struct nouveau_drm {
35299 struct drm_global_reference mem_global_ref;
35300 struct ttm_bo_global_ref bo_global_ref;
35301 struct ttm_bo_device bdev;
35302 - atomic_t validate_sequence;
35303 + atomic_unchecked_t validate_sequence;
35304 int (*move)(struct nouveau_channel *,
35305 struct ttm_buffer_object *,
35306 struct ttm_mem_reg *, struct ttm_mem_reg *);
35307 diff --git a/drivers/gpu/drm/nouveau/nouveau_fence.h b/drivers/gpu/drm/nouveau/nouveau_fence.h
35308 index cdb83ac..27f0a16 100644
35309 --- a/drivers/gpu/drm/nouveau/nouveau_fence.h
35310 +++ b/drivers/gpu/drm/nouveau/nouveau_fence.h
35311 @@ -43,7 +43,7 @@ struct nouveau_fence_priv {
35312 int (*sync)(struct nouveau_fence *, struct nouveau_channel *,
35313 struct nouveau_channel *);
35314 u32 (*read)(struct nouveau_channel *);
35315 -};
35316 +} __no_const;
35317
35318 #define nouveau_fence(drm) ((struct nouveau_fence_priv *)(drm)->fence)
35319
35320 diff --git a/drivers/gpu/drm/nouveau/nouveau_gem.c b/drivers/gpu/drm/nouveau/nouveau_gem.c
35321 index 8bf695c..9fbc90a 100644
35322 --- a/drivers/gpu/drm/nouveau/nouveau_gem.c
35323 +++ b/drivers/gpu/drm/nouveau/nouveau_gem.c
35324 @@ -321,7 +321,7 @@ validate_init(struct nouveau_channel *chan, struct drm_file *file_priv,
35325 int trycnt = 0;
35326 int ret, i;
35327
35328 - sequence = atomic_add_return(1, &drm->ttm.validate_sequence);
35329 + sequence = atomic_add_return_unchecked(1, &drm->ttm.validate_sequence);
35330 retry:
35331 if (++trycnt > 100000) {
35332 NV_ERROR(drm, "%s failed and gave up.\n", __func__);
35333 diff --git a/drivers/gpu/drm/nouveau/nouveau_ioc32.c b/drivers/gpu/drm/nouveau/nouveau_ioc32.c
35334 index 08214bc..9208577 100644
35335 --- a/drivers/gpu/drm/nouveau/nouveau_ioc32.c
35336 +++ b/drivers/gpu/drm/nouveau/nouveau_ioc32.c
35337 @@ -50,7 +50,7 @@ long nouveau_compat_ioctl(struct file *filp, unsigned int cmd,
35338 unsigned long arg)
35339 {
35340 unsigned int nr = DRM_IOCTL_NR(cmd);
35341 - drm_ioctl_compat_t *fn = NULL;
35342 + drm_ioctl_compat_t fn = NULL;
35343 int ret;
35344
35345 if (nr < DRM_COMMAND_BASE)
35346 diff --git a/drivers/gpu/drm/nouveau/nouveau_vga.c b/drivers/gpu/drm/nouveau/nouveau_vga.c
35347 index 25d3495..d81aaf6 100644
35348 --- a/drivers/gpu/drm/nouveau/nouveau_vga.c
35349 +++ b/drivers/gpu/drm/nouveau/nouveau_vga.c
35350 @@ -62,7 +62,7 @@ nouveau_switcheroo_can_switch(struct pci_dev *pdev)
35351 bool can_switch;
35352
35353 spin_lock(&dev->count_lock);
35354 - can_switch = (dev->open_count == 0);
35355 + can_switch = (local_read(&dev->open_count) == 0);
35356 spin_unlock(&dev->count_lock);
35357 return can_switch;
35358 }
35359 diff --git a/drivers/gpu/drm/r128/r128_cce.c b/drivers/gpu/drm/r128/r128_cce.c
35360 index d4660cf..70dbe65 100644
35361 --- a/drivers/gpu/drm/r128/r128_cce.c
35362 +++ b/drivers/gpu/drm/r128/r128_cce.c
35363 @@ -377,7 +377,7 @@ static int r128_do_init_cce(struct drm_device *dev, drm_r128_init_t *init)
35364
35365 /* GH: Simple idle check.
35366 */
35367 - atomic_set(&dev_priv->idle_count, 0);
35368 + atomic_set_unchecked(&dev_priv->idle_count, 0);
35369
35370 /* We don't support anything other than bus-mastering ring mode,
35371 * but the ring can be in either AGP or PCI space for the ring
35372 diff --git a/drivers/gpu/drm/r128/r128_drv.h b/drivers/gpu/drm/r128/r128_drv.h
35373 index 930c71b..499aded 100644
35374 --- a/drivers/gpu/drm/r128/r128_drv.h
35375 +++ b/drivers/gpu/drm/r128/r128_drv.h
35376 @@ -90,14 +90,14 @@ typedef struct drm_r128_private {
35377 int is_pci;
35378 unsigned long cce_buffers_offset;
35379
35380 - atomic_t idle_count;
35381 + atomic_unchecked_t idle_count;
35382
35383 int page_flipping;
35384 int current_page;
35385 u32 crtc_offset;
35386 u32 crtc_offset_cntl;
35387
35388 - atomic_t vbl_received;
35389 + atomic_unchecked_t vbl_received;
35390
35391 u32 color_fmt;
35392 unsigned int front_offset;
35393 diff --git a/drivers/gpu/drm/r128/r128_ioc32.c b/drivers/gpu/drm/r128/r128_ioc32.c
35394 index a954c54..9cc595c 100644
35395 --- a/drivers/gpu/drm/r128/r128_ioc32.c
35396 +++ b/drivers/gpu/drm/r128/r128_ioc32.c
35397 @@ -177,7 +177,7 @@ static int compat_r128_getparam(struct file *file, unsigned int cmd,
35398 return drm_ioctl(file, DRM_IOCTL_R128_GETPARAM, (unsigned long)getparam);
35399 }
35400
35401 -drm_ioctl_compat_t *r128_compat_ioctls[] = {
35402 +drm_ioctl_compat_t r128_compat_ioctls[] = {
35403 [DRM_R128_INIT] = compat_r128_init,
35404 [DRM_R128_DEPTH] = compat_r128_depth,
35405 [DRM_R128_STIPPLE] = compat_r128_stipple,
35406 @@ -196,18 +196,15 @@ drm_ioctl_compat_t *r128_compat_ioctls[] = {
35407 long r128_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
35408 {
35409 unsigned int nr = DRM_IOCTL_NR(cmd);
35410 - drm_ioctl_compat_t *fn = NULL;
35411 int ret;
35412
35413 if (nr < DRM_COMMAND_BASE)
35414 return drm_compat_ioctl(filp, cmd, arg);
35415
35416 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(r128_compat_ioctls))
35417 - fn = r128_compat_ioctls[nr - DRM_COMMAND_BASE];
35418 -
35419 - if (fn != NULL)
35420 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(r128_compat_ioctls)) {
35421 + drm_ioctl_compat_t fn = r128_compat_ioctls[nr - DRM_COMMAND_BASE];
35422 ret = (*fn) (filp, cmd, arg);
35423 - else
35424 + } else
35425 ret = drm_ioctl(filp, cmd, arg);
35426
35427 return ret;
35428 diff --git a/drivers/gpu/drm/r128/r128_irq.c b/drivers/gpu/drm/r128/r128_irq.c
35429 index 2ea4f09..d391371 100644
35430 --- a/drivers/gpu/drm/r128/r128_irq.c
35431 +++ b/drivers/gpu/drm/r128/r128_irq.c
35432 @@ -41,7 +41,7 @@ u32 r128_get_vblank_counter(struct drm_device *dev, int crtc)
35433 if (crtc != 0)
35434 return 0;
35435
35436 - return atomic_read(&dev_priv->vbl_received);
35437 + return atomic_read_unchecked(&dev_priv->vbl_received);
35438 }
35439
35440 irqreturn_t r128_driver_irq_handler(DRM_IRQ_ARGS)
35441 @@ -55,7 +55,7 @@ irqreturn_t r128_driver_irq_handler(DRM_IRQ_ARGS)
35442 /* VBLANK interrupt */
35443 if (status & R128_CRTC_VBLANK_INT) {
35444 R128_WRITE(R128_GEN_INT_STATUS, R128_CRTC_VBLANK_INT_AK);
35445 - atomic_inc(&dev_priv->vbl_received);
35446 + atomic_inc_unchecked(&dev_priv->vbl_received);
35447 drm_handle_vblank(dev, 0);
35448 return IRQ_HANDLED;
35449 }
35450 diff --git a/drivers/gpu/drm/r128/r128_state.c b/drivers/gpu/drm/r128/r128_state.c
35451 index 19bb7e6..de7e2a2 100644
35452 --- a/drivers/gpu/drm/r128/r128_state.c
35453 +++ b/drivers/gpu/drm/r128/r128_state.c
35454 @@ -320,10 +320,10 @@ static void r128_clear_box(drm_r128_private_t *dev_priv,
35455
35456 static void r128_cce_performance_boxes(drm_r128_private_t *dev_priv)
35457 {
35458 - if (atomic_read(&dev_priv->idle_count) == 0)
35459 + if (atomic_read_unchecked(&dev_priv->idle_count) == 0)
35460 r128_clear_box(dev_priv, 64, 4, 8, 8, 0, 255, 0);
35461 else
35462 - atomic_set(&dev_priv->idle_count, 0);
35463 + atomic_set_unchecked(&dev_priv->idle_count, 0);
35464 }
35465
35466 #endif
35467 diff --git a/drivers/gpu/drm/radeon/mkregtable.c b/drivers/gpu/drm/radeon/mkregtable.c
35468 index 5a82b6b..9e69c73 100644
35469 --- a/drivers/gpu/drm/radeon/mkregtable.c
35470 +++ b/drivers/gpu/drm/radeon/mkregtable.c
35471 @@ -637,14 +637,14 @@ static int parser_auth(struct table *t, const char *filename)
35472 regex_t mask_rex;
35473 regmatch_t match[4];
35474 char buf[1024];
35475 - size_t end;
35476 + long end;
35477 int len;
35478 int done = 0;
35479 int r;
35480 unsigned o;
35481 struct offset *offset;
35482 char last_reg_s[10];
35483 - int last_reg;
35484 + unsigned long last_reg;
35485
35486 if (regcomp
35487 (&mask_rex, "(0x[0-9a-fA-F]*) *([_a-zA-Z0-9]*)", REG_EXTENDED)) {
35488 diff --git a/drivers/gpu/drm/radeon/radeon_device.c b/drivers/gpu/drm/radeon/radeon_device.c
35489 index 0d6562b..a154330 100644
35490 --- a/drivers/gpu/drm/radeon/radeon_device.c
35491 +++ b/drivers/gpu/drm/radeon/radeon_device.c
35492 @@ -969,7 +969,7 @@ static bool radeon_switcheroo_can_switch(struct pci_dev *pdev)
35493 bool can_switch;
35494
35495 spin_lock(&dev->count_lock);
35496 - can_switch = (dev->open_count == 0);
35497 + can_switch = (local_read(&dev->open_count) == 0);
35498 spin_unlock(&dev->count_lock);
35499 return can_switch;
35500 }
35501 diff --git a/drivers/gpu/drm/radeon/radeon_drv.h b/drivers/gpu/drm/radeon/radeon_drv.h
35502 index e7fdf16..f4f6490 100644
35503 --- a/drivers/gpu/drm/radeon/radeon_drv.h
35504 +++ b/drivers/gpu/drm/radeon/radeon_drv.h
35505 @@ -255,7 +255,7 @@ typedef struct drm_radeon_private {
35506
35507 /* SW interrupt */
35508 wait_queue_head_t swi_queue;
35509 - atomic_t swi_emitted;
35510 + atomic_unchecked_t swi_emitted;
35511 int vblank_crtc;
35512 uint32_t irq_enable_reg;
35513 uint32_t r500_disp_irq_reg;
35514 diff --git a/drivers/gpu/drm/radeon/radeon_ioc32.c b/drivers/gpu/drm/radeon/radeon_ioc32.c
35515 index c180df8..5fd8186 100644
35516 --- a/drivers/gpu/drm/radeon/radeon_ioc32.c
35517 +++ b/drivers/gpu/drm/radeon/radeon_ioc32.c
35518 @@ -358,7 +358,7 @@ static int compat_radeon_cp_setparam(struct file *file, unsigned int cmd,
35519 request = compat_alloc_user_space(sizeof(*request));
35520 if (!access_ok(VERIFY_WRITE, request, sizeof(*request))
35521 || __put_user(req32.param, &request->param)
35522 - || __put_user((void __user *)(unsigned long)req32.value,
35523 + || __put_user((unsigned long)req32.value,
35524 &request->value))
35525 return -EFAULT;
35526
35527 @@ -368,7 +368,7 @@ static int compat_radeon_cp_setparam(struct file *file, unsigned int cmd,
35528 #define compat_radeon_cp_setparam NULL
35529 #endif /* X86_64 || IA64 */
35530
35531 -static drm_ioctl_compat_t *radeon_compat_ioctls[] = {
35532 +static drm_ioctl_compat_t radeon_compat_ioctls[] = {
35533 [DRM_RADEON_CP_INIT] = compat_radeon_cp_init,
35534 [DRM_RADEON_CLEAR] = compat_radeon_cp_clear,
35535 [DRM_RADEON_STIPPLE] = compat_radeon_cp_stipple,
35536 @@ -393,18 +393,15 @@ static drm_ioctl_compat_t *radeon_compat_ioctls[] = {
35537 long radeon_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
35538 {
35539 unsigned int nr = DRM_IOCTL_NR(cmd);
35540 - drm_ioctl_compat_t *fn = NULL;
35541 int ret;
35542
35543 if (nr < DRM_COMMAND_BASE)
35544 return drm_compat_ioctl(filp, cmd, arg);
35545
35546 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(radeon_compat_ioctls))
35547 - fn = radeon_compat_ioctls[nr - DRM_COMMAND_BASE];
35548 -
35549 - if (fn != NULL)
35550 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(radeon_compat_ioctls)) {
35551 + drm_ioctl_compat_t fn = radeon_compat_ioctls[nr - DRM_COMMAND_BASE];
35552 ret = (*fn) (filp, cmd, arg);
35553 - else
35554 + } else
35555 ret = drm_ioctl(filp, cmd, arg);
35556
35557 return ret;
35558 diff --git a/drivers/gpu/drm/radeon/radeon_irq.c b/drivers/gpu/drm/radeon/radeon_irq.c
35559 index e771033..a0bc6b3 100644
35560 --- a/drivers/gpu/drm/radeon/radeon_irq.c
35561 +++ b/drivers/gpu/drm/radeon/radeon_irq.c
35562 @@ -224,8 +224,8 @@ static int radeon_emit_irq(struct drm_device * dev)
35563 unsigned int ret;
35564 RING_LOCALS;
35565
35566 - atomic_inc(&dev_priv->swi_emitted);
35567 - ret = atomic_read(&dev_priv->swi_emitted);
35568 + atomic_inc_unchecked(&dev_priv->swi_emitted);
35569 + ret = atomic_read_unchecked(&dev_priv->swi_emitted);
35570
35571 BEGIN_RING(4);
35572 OUT_RING_REG(RADEON_LAST_SWI_REG, ret);
35573 @@ -351,7 +351,7 @@ int radeon_driver_irq_postinstall(struct drm_device *dev)
35574 drm_radeon_private_t *dev_priv =
35575 (drm_radeon_private_t *) dev->dev_private;
35576
35577 - atomic_set(&dev_priv->swi_emitted, 0);
35578 + atomic_set_unchecked(&dev_priv->swi_emitted, 0);
35579 DRM_INIT_WAITQUEUE(&dev_priv->swi_queue);
35580
35581 dev->max_vblank_count = 0x001fffff;
35582 diff --git a/drivers/gpu/drm/radeon/radeon_state.c b/drivers/gpu/drm/radeon/radeon_state.c
35583 index 8e9057b..af6dacb 100644
35584 --- a/drivers/gpu/drm/radeon/radeon_state.c
35585 +++ b/drivers/gpu/drm/radeon/radeon_state.c
35586 @@ -2166,7 +2166,7 @@ static int radeon_cp_clear(struct drm_device *dev, void *data, struct drm_file *
35587 if (sarea_priv->nbox > RADEON_NR_SAREA_CLIPRECTS)
35588 sarea_priv->nbox = RADEON_NR_SAREA_CLIPRECTS;
35589
35590 - if (DRM_COPY_FROM_USER(&depth_boxes, clear->depth_boxes,
35591 + if (sarea_priv->nbox > RADEON_NR_SAREA_CLIPRECTS || DRM_COPY_FROM_USER(&depth_boxes, clear->depth_boxes,
35592 sarea_priv->nbox * sizeof(depth_boxes[0])))
35593 return -EFAULT;
35594
35595 @@ -3029,7 +3029,7 @@ static int radeon_cp_getparam(struct drm_device *dev, void *data, struct drm_fil
35596 {
35597 drm_radeon_private_t *dev_priv = dev->dev_private;
35598 drm_radeon_getparam_t *param = data;
35599 - int value;
35600 + int value = 0;
35601
35602 DRM_DEBUG("pid=%d\n", DRM_CURRENTPID);
35603
35604 diff --git a/drivers/gpu/drm/radeon/radeon_ttm.c b/drivers/gpu/drm/radeon/radeon_ttm.c
35605 index 93f760e..8088227 100644
35606 --- a/drivers/gpu/drm/radeon/radeon_ttm.c
35607 +++ b/drivers/gpu/drm/radeon/radeon_ttm.c
35608 @@ -782,7 +782,7 @@ void radeon_ttm_set_active_vram_size(struct radeon_device *rdev, u64 size)
35609 man->size = size >> PAGE_SHIFT;
35610 }
35611
35612 -static struct vm_operations_struct radeon_ttm_vm_ops;
35613 +static vm_operations_struct_no_const radeon_ttm_vm_ops __read_only;
35614 static const struct vm_operations_struct *ttm_vm_ops = NULL;
35615
35616 static int radeon_ttm_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
35617 @@ -823,8 +823,10 @@ int radeon_mmap(struct file *filp, struct vm_area_struct *vma)
35618 }
35619 if (unlikely(ttm_vm_ops == NULL)) {
35620 ttm_vm_ops = vma->vm_ops;
35621 + pax_open_kernel();
35622 radeon_ttm_vm_ops = *ttm_vm_ops;
35623 radeon_ttm_vm_ops.fault = &radeon_ttm_fault;
35624 + pax_close_kernel();
35625 }
35626 vma->vm_ops = &radeon_ttm_vm_ops;
35627 return 0;
35628 @@ -862,28 +864,33 @@ static int radeon_ttm_debugfs_init(struct radeon_device *rdev)
35629 sprintf(radeon_mem_types_names[i], "radeon_vram_mm");
35630 else
35631 sprintf(radeon_mem_types_names[i], "radeon_gtt_mm");
35632 - radeon_mem_types_list[i].name = radeon_mem_types_names[i];
35633 - radeon_mem_types_list[i].show = &radeon_mm_dump_table;
35634 - radeon_mem_types_list[i].driver_features = 0;
35635 + pax_open_kernel();
35636 + *(const char **)&radeon_mem_types_list[i].name = radeon_mem_types_names[i];
35637 + *(void **)&radeon_mem_types_list[i].show = &radeon_mm_dump_table;
35638 + *(u32 *)&radeon_mem_types_list[i].driver_features = 0;
35639 if (i == 0)
35640 - radeon_mem_types_list[i].data = rdev->mman.bdev.man[TTM_PL_VRAM].priv;
35641 + *(void **)&radeon_mem_types_list[i].data = rdev->mman.bdev.man[TTM_PL_VRAM].priv;
35642 else
35643 - radeon_mem_types_list[i].data = rdev->mman.bdev.man[TTM_PL_TT].priv;
35644 -
35645 + *(void **)&radeon_mem_types_list[i].data = rdev->mman.bdev.man[TTM_PL_TT].priv;
35646 + pax_close_kernel();
35647 }
35648 /* Add ttm page pool to debugfs */
35649 sprintf(radeon_mem_types_names[i], "ttm_page_pool");
35650 - radeon_mem_types_list[i].name = radeon_mem_types_names[i];
35651 - radeon_mem_types_list[i].show = &ttm_page_alloc_debugfs;
35652 - radeon_mem_types_list[i].driver_features = 0;
35653 - radeon_mem_types_list[i++].data = NULL;
35654 + pax_open_kernel();
35655 + *(const char **)&radeon_mem_types_list[i].name = radeon_mem_types_names[i];
35656 + *(void **)&radeon_mem_types_list[i].show = &ttm_page_alloc_debugfs;
35657 + *(u32 *)&radeon_mem_types_list[i].driver_features = 0;
35658 + *(void **)&radeon_mem_types_list[i++].data = NULL;
35659 + pax_close_kernel();
35660 #ifdef CONFIG_SWIOTLB
35661 if (swiotlb_nr_tbl()) {
35662 sprintf(radeon_mem_types_names[i], "ttm_dma_page_pool");
35663 - radeon_mem_types_list[i].name = radeon_mem_types_names[i];
35664 - radeon_mem_types_list[i].show = &ttm_dma_page_alloc_debugfs;
35665 - radeon_mem_types_list[i].driver_features = 0;
35666 - radeon_mem_types_list[i++].data = NULL;
35667 + pax_open_kernel();
35668 + *(const char **)&radeon_mem_types_list[i].name = radeon_mem_types_names[i];
35669 + *(void **)&radeon_mem_types_list[i].show = &ttm_dma_page_alloc_debugfs;
35670 + *(u32 *)&radeon_mem_types_list[i].driver_features = 0;
35671 + *(void **)&radeon_mem_types_list[i++].data = NULL;
35672 + pax_close_kernel();
35673 }
35674 #endif
35675 return radeon_debugfs_add_files(rdev, radeon_mem_types_list, i);
35676 diff --git a/drivers/gpu/drm/radeon/rs690.c b/drivers/gpu/drm/radeon/rs690.c
35677 index 5706d2a..17aedaa 100644
35678 --- a/drivers/gpu/drm/radeon/rs690.c
35679 +++ b/drivers/gpu/drm/radeon/rs690.c
35680 @@ -304,9 +304,11 @@ static void rs690_crtc_bandwidth_compute(struct radeon_device *rdev,
35681 if (rdev->pm.max_bandwidth.full > rdev->pm.sideport_bandwidth.full &&
35682 rdev->pm.sideport_bandwidth.full)
35683 rdev->pm.max_bandwidth = rdev->pm.sideport_bandwidth;
35684 - read_delay_latency.full = dfixed_const(370 * 800 * 1000);
35685 + read_delay_latency.full = dfixed_const(800 * 1000);
35686 read_delay_latency.full = dfixed_div(read_delay_latency,
35687 rdev->pm.igp_sideport_mclk);
35688 + a.full = dfixed_const(370);
35689 + read_delay_latency.full = dfixed_mul(read_delay_latency, a);
35690 } else {
35691 if (rdev->pm.max_bandwidth.full > rdev->pm.k8_bandwidth.full &&
35692 rdev->pm.k8_bandwidth.full)
35693 diff --git a/drivers/gpu/drm/ttm/ttm_page_alloc.c b/drivers/gpu/drm/ttm/ttm_page_alloc.c
35694 index bd2a3b4..122d9ad 100644
35695 --- a/drivers/gpu/drm/ttm/ttm_page_alloc.c
35696 +++ b/drivers/gpu/drm/ttm/ttm_page_alloc.c
35697 @@ -394,9 +394,9 @@ static int ttm_pool_get_num_unused_pages(void)
35698 static int ttm_pool_mm_shrink(struct shrinker *shrink,
35699 struct shrink_control *sc)
35700 {
35701 - static atomic_t start_pool = ATOMIC_INIT(0);
35702 + static atomic_unchecked_t start_pool = ATOMIC_INIT(0);
35703 unsigned i;
35704 - unsigned pool_offset = atomic_add_return(1, &start_pool);
35705 + unsigned pool_offset = atomic_add_return_unchecked(1, &start_pool);
35706 struct ttm_page_pool *pool;
35707 int shrink_pages = sc->nr_to_scan;
35708
35709 diff --git a/drivers/gpu/drm/udl/udl_fb.c b/drivers/gpu/drm/udl/udl_fb.c
35710 index 1eb060c..188b1fc 100644
35711 --- a/drivers/gpu/drm/udl/udl_fb.c
35712 +++ b/drivers/gpu/drm/udl/udl_fb.c
35713 @@ -367,7 +367,6 @@ static int udl_fb_release(struct fb_info *info, int user)
35714 fb_deferred_io_cleanup(info);
35715 kfree(info->fbdefio);
35716 info->fbdefio = NULL;
35717 - info->fbops->fb_mmap = udl_fb_mmap;
35718 }
35719
35720 pr_warn("released /dev/fb%d user=%d count=%d\n",
35721 diff --git a/drivers/gpu/drm/via/via_drv.h b/drivers/gpu/drm/via/via_drv.h
35722 index 893a650..6190d3b 100644
35723 --- a/drivers/gpu/drm/via/via_drv.h
35724 +++ b/drivers/gpu/drm/via/via_drv.h
35725 @@ -51,7 +51,7 @@ typedef struct drm_via_ring_buffer {
35726 typedef uint32_t maskarray_t[5];
35727
35728 typedef struct drm_via_irq {
35729 - atomic_t irq_received;
35730 + atomic_unchecked_t irq_received;
35731 uint32_t pending_mask;
35732 uint32_t enable_mask;
35733 wait_queue_head_t irq_queue;
35734 @@ -75,7 +75,7 @@ typedef struct drm_via_private {
35735 struct timeval last_vblank;
35736 int last_vblank_valid;
35737 unsigned usec_per_vblank;
35738 - atomic_t vbl_received;
35739 + atomic_unchecked_t vbl_received;
35740 drm_via_state_t hc_state;
35741 char pci_buf[VIA_PCI_BUF_SIZE];
35742 const uint32_t *fire_offsets[VIA_FIRE_BUF_SIZE];
35743 diff --git a/drivers/gpu/drm/via/via_irq.c b/drivers/gpu/drm/via/via_irq.c
35744 index ac98964..5dbf512 100644
35745 --- a/drivers/gpu/drm/via/via_irq.c
35746 +++ b/drivers/gpu/drm/via/via_irq.c
35747 @@ -101,7 +101,7 @@ u32 via_get_vblank_counter(struct drm_device *dev, int crtc)
35748 if (crtc != 0)
35749 return 0;
35750
35751 - return atomic_read(&dev_priv->vbl_received);
35752 + return atomic_read_unchecked(&dev_priv->vbl_received);
35753 }
35754
35755 irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
35756 @@ -116,8 +116,8 @@ irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
35757
35758 status = VIA_READ(VIA_REG_INTERRUPT);
35759 if (status & VIA_IRQ_VBLANK_PENDING) {
35760 - atomic_inc(&dev_priv->vbl_received);
35761 - if (!(atomic_read(&dev_priv->vbl_received) & 0x0F)) {
35762 + atomic_inc_unchecked(&dev_priv->vbl_received);
35763 + if (!(atomic_read_unchecked(&dev_priv->vbl_received) & 0x0F)) {
35764 do_gettimeofday(&cur_vblank);
35765 if (dev_priv->last_vblank_valid) {
35766 dev_priv->usec_per_vblank =
35767 @@ -127,7 +127,7 @@ irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
35768 dev_priv->last_vblank = cur_vblank;
35769 dev_priv->last_vblank_valid = 1;
35770 }
35771 - if (!(atomic_read(&dev_priv->vbl_received) & 0xFF)) {
35772 + if (!(atomic_read_unchecked(&dev_priv->vbl_received) & 0xFF)) {
35773 DRM_DEBUG("US per vblank is: %u\n",
35774 dev_priv->usec_per_vblank);
35775 }
35776 @@ -137,7 +137,7 @@ irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
35777
35778 for (i = 0; i < dev_priv->num_irqs; ++i) {
35779 if (status & cur_irq->pending_mask) {
35780 - atomic_inc(&cur_irq->irq_received);
35781 + atomic_inc_unchecked(&cur_irq->irq_received);
35782 DRM_WAKEUP(&cur_irq->irq_queue);
35783 handled = 1;
35784 if (dev_priv->irq_map[drm_via_irq_dma0_td] == i)
35785 @@ -242,11 +242,11 @@ via_driver_irq_wait(struct drm_device *dev, unsigned int irq, int force_sequence
35786 DRM_WAIT_ON(ret, cur_irq->irq_queue, 3 * DRM_HZ,
35787 ((VIA_READ(masks[irq][2]) & masks[irq][3]) ==
35788 masks[irq][4]));
35789 - cur_irq_sequence = atomic_read(&cur_irq->irq_received);
35790 + cur_irq_sequence = atomic_read_unchecked(&cur_irq->irq_received);
35791 } else {
35792 DRM_WAIT_ON(ret, cur_irq->irq_queue, 3 * DRM_HZ,
35793 (((cur_irq_sequence =
35794 - atomic_read(&cur_irq->irq_received)) -
35795 + atomic_read_unchecked(&cur_irq->irq_received)) -
35796 *sequence) <= (1 << 23)));
35797 }
35798 *sequence = cur_irq_sequence;
35799 @@ -284,7 +284,7 @@ void via_driver_irq_preinstall(struct drm_device *dev)
35800 }
35801
35802 for (i = 0; i < dev_priv->num_irqs; ++i) {
35803 - atomic_set(&cur_irq->irq_received, 0);
35804 + atomic_set_unchecked(&cur_irq->irq_received, 0);
35805 cur_irq->enable_mask = dev_priv->irq_masks[i][0];
35806 cur_irq->pending_mask = dev_priv->irq_masks[i][1];
35807 DRM_INIT_WAITQUEUE(&cur_irq->irq_queue);
35808 @@ -366,7 +366,7 @@ int via_wait_irq(struct drm_device *dev, void *data, struct drm_file *file_priv)
35809 switch (irqwait->request.type & ~VIA_IRQ_FLAGS_MASK) {
35810 case VIA_IRQ_RELATIVE:
35811 irqwait->request.sequence +=
35812 - atomic_read(&cur_irq->irq_received);
35813 + atomic_read_unchecked(&cur_irq->irq_received);
35814 irqwait->request.type &= ~_DRM_VBLANK_RELATIVE;
35815 case VIA_IRQ_ABSOLUTE:
35816 break;
35817 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
35818 index 13aeda7..4a952d1 100644
35819 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
35820 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
35821 @@ -290,7 +290,7 @@ struct vmw_private {
35822 * Fencing and IRQs.
35823 */
35824
35825 - atomic_t marker_seq;
35826 + atomic_unchecked_t marker_seq;
35827 wait_queue_head_t fence_queue;
35828 wait_queue_head_t fifo_queue;
35829 int fence_queue_waiters; /* Protected by hw_mutex */
35830 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c b/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
35831 index 3eb1486..0a47ee9 100644
35832 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
35833 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
35834 @@ -137,7 +137,7 @@ int vmw_fifo_init(struct vmw_private *dev_priv, struct vmw_fifo_state *fifo)
35835 (unsigned int) min,
35836 (unsigned int) fifo->capabilities);
35837
35838 - atomic_set(&dev_priv->marker_seq, dev_priv->last_read_seqno);
35839 + atomic_set_unchecked(&dev_priv->marker_seq, dev_priv->last_read_seqno);
35840 iowrite32(dev_priv->last_read_seqno, fifo_mem + SVGA_FIFO_FENCE);
35841 vmw_marker_queue_init(&fifo->marker_queue);
35842 return vmw_fifo_send_fence(dev_priv, &dummy);
35843 @@ -355,7 +355,7 @@ void *vmw_fifo_reserve(struct vmw_private *dev_priv, uint32_t bytes)
35844 if (reserveable)
35845 iowrite32(bytes, fifo_mem +
35846 SVGA_FIFO_RESERVED);
35847 - return fifo_mem + (next_cmd >> 2);
35848 + return (__le32 __force_kernel *)fifo_mem + (next_cmd >> 2);
35849 } else {
35850 need_bounce = true;
35851 }
35852 @@ -475,7 +475,7 @@ int vmw_fifo_send_fence(struct vmw_private *dev_priv, uint32_t *seqno)
35853
35854 fm = vmw_fifo_reserve(dev_priv, bytes);
35855 if (unlikely(fm == NULL)) {
35856 - *seqno = atomic_read(&dev_priv->marker_seq);
35857 + *seqno = atomic_read_unchecked(&dev_priv->marker_seq);
35858 ret = -ENOMEM;
35859 (void)vmw_fallback_wait(dev_priv, false, true, *seqno,
35860 false, 3*HZ);
35861 @@ -483,7 +483,7 @@ int vmw_fifo_send_fence(struct vmw_private *dev_priv, uint32_t *seqno)
35862 }
35863
35864 do {
35865 - *seqno = atomic_add_return(1, &dev_priv->marker_seq);
35866 + *seqno = atomic_add_return_unchecked(1, &dev_priv->marker_seq);
35867 } while (*seqno == 0);
35868
35869 if (!(fifo_state->capabilities & SVGA_FIFO_CAP_FENCE)) {
35870 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c b/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c
35871 index 4640adb..e1384ed 100644
35872 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c
35873 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c
35874 @@ -107,7 +107,7 @@ bool vmw_seqno_passed(struct vmw_private *dev_priv,
35875 * emitted. Then the fence is stale and signaled.
35876 */
35877
35878 - ret = ((atomic_read(&dev_priv->marker_seq) - seqno)
35879 + ret = ((atomic_read_unchecked(&dev_priv->marker_seq) - seqno)
35880 > VMW_FENCE_WRAP);
35881
35882 return ret;
35883 @@ -138,7 +138,7 @@ int vmw_fallback_wait(struct vmw_private *dev_priv,
35884
35885 if (fifo_idle)
35886 down_read(&fifo_state->rwsem);
35887 - signal_seq = atomic_read(&dev_priv->marker_seq);
35888 + signal_seq = atomic_read_unchecked(&dev_priv->marker_seq);
35889 ret = 0;
35890
35891 for (;;) {
35892 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c b/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c
35893 index 8a8725c..afed796 100644
35894 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c
35895 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c
35896 @@ -151,7 +151,7 @@ int vmw_wait_lag(struct vmw_private *dev_priv,
35897 while (!vmw_lag_lt(queue, us)) {
35898 spin_lock(&queue->lock);
35899 if (list_empty(&queue->head))
35900 - seqno = atomic_read(&dev_priv->marker_seq);
35901 + seqno = atomic_read_unchecked(&dev_priv->marker_seq);
35902 else {
35903 marker = list_first_entry(&queue->head,
35904 struct vmw_marker, head);
35905 diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
35906 index ceb3040..6160c5c 100644
35907 --- a/drivers/hid/hid-core.c
35908 +++ b/drivers/hid/hid-core.c
35909 @@ -2242,7 +2242,7 @@ EXPORT_SYMBOL_GPL(hid_ignore);
35910
35911 int hid_add_device(struct hid_device *hdev)
35912 {
35913 - static atomic_t id = ATOMIC_INIT(0);
35914 + static atomic_unchecked_t id = ATOMIC_INIT(0);
35915 int ret;
35916
35917 if (WARN_ON(hdev->status & HID_STAT_ADDED))
35918 @@ -2276,7 +2276,7 @@ int hid_add_device(struct hid_device *hdev)
35919 /* XXX hack, any other cleaner solution after the driver core
35920 * is converted to allow more than 20 bytes as the device name? */
35921 dev_set_name(&hdev->dev, "%04X:%04X:%04X.%04X", hdev->bus,
35922 - hdev->vendor, hdev->product, atomic_inc_return(&id));
35923 + hdev->vendor, hdev->product, atomic_inc_return_unchecked(&id));
35924
35925 hid_debug_register(hdev, dev_name(&hdev->dev));
35926 ret = device_add(&hdev->dev);
35927 diff --git a/drivers/hid/hid-wiimote-debug.c b/drivers/hid/hid-wiimote-debug.c
35928 index eec3291..8ed706b 100644
35929 --- a/drivers/hid/hid-wiimote-debug.c
35930 +++ b/drivers/hid/hid-wiimote-debug.c
35931 @@ -66,7 +66,7 @@ static ssize_t wiidebug_eeprom_read(struct file *f, char __user *u, size_t s,
35932 else if (size == 0)
35933 return -EIO;
35934
35935 - if (copy_to_user(u, buf, size))
35936 + if (size > sizeof(buf) || copy_to_user(u, buf, size))
35937 return -EFAULT;
35938
35939 *off += size;
35940 diff --git a/drivers/hv/channel.c b/drivers/hv/channel.c
35941 index 773a2f2..7ce08bc 100644
35942 --- a/drivers/hv/channel.c
35943 +++ b/drivers/hv/channel.c
35944 @@ -394,8 +394,8 @@ int vmbus_establish_gpadl(struct vmbus_channel *channel, void *kbuffer,
35945 int ret = 0;
35946 int t;
35947
35948 - next_gpadl_handle = atomic_read(&vmbus_connection.next_gpadl_handle);
35949 - atomic_inc(&vmbus_connection.next_gpadl_handle);
35950 + next_gpadl_handle = atomic_read_unchecked(&vmbus_connection.next_gpadl_handle);
35951 + atomic_inc_unchecked(&vmbus_connection.next_gpadl_handle);
35952
35953 ret = create_gpadl_header(kbuffer, size, &msginfo, &msgcount);
35954 if (ret)
35955 diff --git a/drivers/hv/hv.c b/drivers/hv/hv.c
35956 index 3648f8f..30ef30d 100644
35957 --- a/drivers/hv/hv.c
35958 +++ b/drivers/hv/hv.c
35959 @@ -111,7 +111,7 @@ static u64 do_hypercall(u64 control, void *input, void *output)
35960 u64 output_address = (output) ? virt_to_phys(output) : 0;
35961 u32 output_address_hi = output_address >> 32;
35962 u32 output_address_lo = output_address & 0xFFFFFFFF;
35963 - void *hypercall_page = hv_context.hypercall_page;
35964 + void *hypercall_page = ktva_ktla(hv_context.hypercall_page);
35965
35966 __asm__ __volatile__ ("call *%8" : "=d"(hv_status_hi),
35967 "=a"(hv_status_lo) : "d" (control_hi),
35968 diff --git a/drivers/hv/hyperv_vmbus.h b/drivers/hv/hyperv_vmbus.h
35969 index d8d1fad..b91caf7 100644
35970 --- a/drivers/hv/hyperv_vmbus.h
35971 +++ b/drivers/hv/hyperv_vmbus.h
35972 @@ -594,7 +594,7 @@ enum vmbus_connect_state {
35973 struct vmbus_connection {
35974 enum vmbus_connect_state conn_state;
35975
35976 - atomic_t next_gpadl_handle;
35977 + atomic_unchecked_t next_gpadl_handle;
35978
35979 /*
35980 * Represents channel interrupts. Each bit position represents a
35981 diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
35982 index 8e1a9ec..4687821 100644
35983 --- a/drivers/hv/vmbus_drv.c
35984 +++ b/drivers/hv/vmbus_drv.c
35985 @@ -629,10 +629,10 @@ int vmbus_device_register(struct hv_device *child_device_obj)
35986 {
35987 int ret = 0;
35988
35989 - static atomic_t device_num = ATOMIC_INIT(0);
35990 + static atomic_unchecked_t device_num = ATOMIC_INIT(0);
35991
35992 dev_set_name(&child_device_obj->device, "vmbus_0_%d",
35993 - atomic_inc_return(&device_num));
35994 + atomic_inc_return_unchecked(&device_num));
35995
35996 child_device_obj->device.bus = &hv_bus;
35997 child_device_obj->device.parent = &hv_acpi_dev->dev;
35998 diff --git a/drivers/hwmon/acpi_power_meter.c b/drivers/hwmon/acpi_power_meter.c
35999 index 1672e2a..4a6297c 100644
36000 --- a/drivers/hwmon/acpi_power_meter.c
36001 +++ b/drivers/hwmon/acpi_power_meter.c
36002 @@ -117,7 +117,7 @@ struct sensor_template {
36003 struct device_attribute *devattr,
36004 const char *buf, size_t count);
36005 int index;
36006 -};
36007 +} __do_const;
36008
36009 /* Averaging interval */
36010 static int update_avg_interval(struct acpi_power_meter_resource *resource)
36011 @@ -629,7 +629,7 @@ static int register_attrs(struct acpi_power_meter_resource *resource,
36012 struct sensor_template *attrs)
36013 {
36014 struct device *dev = &resource->acpi_dev->dev;
36015 - struct sensor_device_attribute *sensors =
36016 + sensor_device_attribute_no_const *sensors =
36017 &resource->sensors[resource->num_sensors];
36018 int res = 0;
36019
36020 diff --git a/drivers/hwmon/applesmc.c b/drivers/hwmon/applesmc.c
36021 index b41baff..4953e4d 100644
36022 --- a/drivers/hwmon/applesmc.c
36023 +++ b/drivers/hwmon/applesmc.c
36024 @@ -1084,7 +1084,7 @@ static int applesmc_create_nodes(struct applesmc_node_group *groups, int num)
36025 {
36026 struct applesmc_node_group *grp;
36027 struct applesmc_dev_attr *node;
36028 - struct attribute *attr;
36029 + attribute_no_const *attr;
36030 int ret, i;
36031
36032 for (grp = groups; grp->format; grp++) {
36033 diff --git a/drivers/hwmon/asus_atk0110.c b/drivers/hwmon/asus_atk0110.c
36034 index 56dbcfb..9874bf1 100644
36035 --- a/drivers/hwmon/asus_atk0110.c
36036 +++ b/drivers/hwmon/asus_atk0110.c
36037 @@ -152,10 +152,10 @@ MODULE_DEVICE_TABLE(acpi, atk_ids);
36038 struct atk_sensor_data {
36039 struct list_head list;
36040 struct atk_data *data;
36041 - struct device_attribute label_attr;
36042 - struct device_attribute input_attr;
36043 - struct device_attribute limit1_attr;
36044 - struct device_attribute limit2_attr;
36045 + device_attribute_no_const label_attr;
36046 + device_attribute_no_const input_attr;
36047 + device_attribute_no_const limit1_attr;
36048 + device_attribute_no_const limit2_attr;
36049 char label_attr_name[ATTR_NAME_SIZE];
36050 char input_attr_name[ATTR_NAME_SIZE];
36051 char limit1_attr_name[ATTR_NAME_SIZE];
36052 @@ -275,7 +275,7 @@ static ssize_t atk_name_show(struct device *dev,
36053 static struct device_attribute atk_name_attr =
36054 __ATTR(name, 0444, atk_name_show, NULL);
36055
36056 -static void atk_init_attribute(struct device_attribute *attr, char *name,
36057 +static void atk_init_attribute(device_attribute_no_const *attr, char *name,
36058 sysfs_show_func show)
36059 {
36060 sysfs_attr_init(&attr->attr);
36061 diff --git a/drivers/hwmon/coretemp.c b/drivers/hwmon/coretemp.c
36062 index d64923d..72591e8 100644
36063 --- a/drivers/hwmon/coretemp.c
36064 +++ b/drivers/hwmon/coretemp.c
36065 @@ -790,7 +790,7 @@ static int __cpuinit coretemp_cpu_callback(struct notifier_block *nfb,
36066 return NOTIFY_OK;
36067 }
36068
36069 -static struct notifier_block coretemp_cpu_notifier __refdata = {
36070 +static struct notifier_block coretemp_cpu_notifier = {
36071 .notifier_call = coretemp_cpu_callback,
36072 };
36073
36074 diff --git a/drivers/hwmon/ibmaem.c b/drivers/hwmon/ibmaem.c
36075 index a14f634..2916ee2 100644
36076 --- a/drivers/hwmon/ibmaem.c
36077 +++ b/drivers/hwmon/ibmaem.c
36078 @@ -925,7 +925,7 @@ static int aem_register_sensors(struct aem_data *data,
36079 struct aem_rw_sensor_template *rw)
36080 {
36081 struct device *dev = &data->pdev->dev;
36082 - struct sensor_device_attribute *sensors = data->sensors;
36083 + sensor_device_attribute_no_const *sensors = data->sensors;
36084 int err;
36085
36086 /* Set up read-only sensors */
36087 diff --git a/drivers/hwmon/pmbus/pmbus_core.c b/drivers/hwmon/pmbus/pmbus_core.c
36088 index 7d19b1b..8fdaaac 100644
36089 --- a/drivers/hwmon/pmbus/pmbus_core.c
36090 +++ b/drivers/hwmon/pmbus/pmbus_core.c
36091 @@ -811,7 +811,7 @@ static ssize_t pmbus_show_label(struct device *dev,
36092
36093 #define PMBUS_ADD_ATTR(data, _name, _idx, _mode, _type, _show, _set) \
36094 do { \
36095 - struct sensor_device_attribute *a \
36096 + sensor_device_attribute_no_const *a \
36097 = &data->_type##s[data->num_##_type##s].attribute; \
36098 BUG_ON(data->num_attributes >= data->max_attributes); \
36099 sysfs_attr_init(&a->dev_attr.attr); \
36100 diff --git a/drivers/hwmon/sht15.c b/drivers/hwmon/sht15.c
36101 index 8047fed..1e956f0 100644
36102 --- a/drivers/hwmon/sht15.c
36103 +++ b/drivers/hwmon/sht15.c
36104 @@ -169,7 +169,7 @@ struct sht15_data {
36105 int supply_uV;
36106 bool supply_uV_valid;
36107 struct work_struct update_supply_work;
36108 - atomic_t interrupt_handled;
36109 + atomic_unchecked_t interrupt_handled;
36110 };
36111
36112 /**
36113 @@ -512,13 +512,13 @@ static int sht15_measurement(struct sht15_data *data,
36114 return ret;
36115
36116 gpio_direction_input(data->pdata->gpio_data);
36117 - atomic_set(&data->interrupt_handled, 0);
36118 + atomic_set_unchecked(&data->interrupt_handled, 0);
36119
36120 enable_irq(gpio_to_irq(data->pdata->gpio_data));
36121 if (gpio_get_value(data->pdata->gpio_data) == 0) {
36122 disable_irq_nosync(gpio_to_irq(data->pdata->gpio_data));
36123 /* Only relevant if the interrupt hasn't occurred. */
36124 - if (!atomic_read(&data->interrupt_handled))
36125 + if (!atomic_read_unchecked(&data->interrupt_handled))
36126 schedule_work(&data->read_work);
36127 }
36128 ret = wait_event_timeout(data->wait_queue,
36129 @@ -785,7 +785,7 @@ static irqreturn_t sht15_interrupt_fired(int irq, void *d)
36130
36131 /* First disable the interrupt */
36132 disable_irq_nosync(irq);
36133 - atomic_inc(&data->interrupt_handled);
36134 + atomic_inc_unchecked(&data->interrupt_handled);
36135 /* Then schedule a reading work struct */
36136 if (data->state != SHT15_READING_NOTHING)
36137 schedule_work(&data->read_work);
36138 @@ -807,11 +807,11 @@ static void sht15_bh_read_data(struct work_struct *work_s)
36139 * If not, then start the interrupt again - care here as could
36140 * have gone low in meantime so verify it hasn't!
36141 */
36142 - atomic_set(&data->interrupt_handled, 0);
36143 + atomic_set_unchecked(&data->interrupt_handled, 0);
36144 enable_irq(gpio_to_irq(data->pdata->gpio_data));
36145 /* If still not occurred or another handler was scheduled */
36146 if (gpio_get_value(data->pdata->gpio_data)
36147 - || atomic_read(&data->interrupt_handled))
36148 + || atomic_read_unchecked(&data->interrupt_handled))
36149 return;
36150 }
36151
36152 diff --git a/drivers/hwmon/via-cputemp.c b/drivers/hwmon/via-cputemp.c
36153 index 76f157b..9c0db1b 100644
36154 --- a/drivers/hwmon/via-cputemp.c
36155 +++ b/drivers/hwmon/via-cputemp.c
36156 @@ -296,7 +296,7 @@ static int __cpuinit via_cputemp_cpu_callback(struct notifier_block *nfb,
36157 return NOTIFY_OK;
36158 }
36159
36160 -static struct notifier_block via_cputemp_cpu_notifier __refdata = {
36161 +static struct notifier_block via_cputemp_cpu_notifier = {
36162 .notifier_call = via_cputemp_cpu_callback,
36163 };
36164
36165 diff --git a/drivers/i2c/busses/i2c-amd756-s4882.c b/drivers/i2c/busses/i2c-amd756-s4882.c
36166 index 378fcb5..5e91fa8 100644
36167 --- a/drivers/i2c/busses/i2c-amd756-s4882.c
36168 +++ b/drivers/i2c/busses/i2c-amd756-s4882.c
36169 @@ -43,7 +43,7 @@
36170 extern struct i2c_adapter amd756_smbus;
36171
36172 static struct i2c_adapter *s4882_adapter;
36173 -static struct i2c_algorithm *s4882_algo;
36174 +static i2c_algorithm_no_const *s4882_algo;
36175
36176 /* Wrapper access functions for multiplexed SMBus */
36177 static DEFINE_MUTEX(amd756_lock);
36178 diff --git a/drivers/i2c/busses/i2c-nforce2-s4985.c b/drivers/i2c/busses/i2c-nforce2-s4985.c
36179 index 29015eb..af2d8e9 100644
36180 --- a/drivers/i2c/busses/i2c-nforce2-s4985.c
36181 +++ b/drivers/i2c/busses/i2c-nforce2-s4985.c
36182 @@ -41,7 +41,7 @@
36183 extern struct i2c_adapter *nforce2_smbus;
36184
36185 static struct i2c_adapter *s4985_adapter;
36186 -static struct i2c_algorithm *s4985_algo;
36187 +static i2c_algorithm_no_const *s4985_algo;
36188
36189 /* Wrapper access functions for multiplexed SMBus */
36190 static DEFINE_MUTEX(nforce2_lock);
36191 diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c
36192 index 8126824..55a2798 100644
36193 --- a/drivers/ide/ide-cd.c
36194 +++ b/drivers/ide/ide-cd.c
36195 @@ -768,7 +768,7 @@ static void cdrom_do_block_pc(ide_drive_t *drive, struct request *rq)
36196 alignment = queue_dma_alignment(q) | q->dma_pad_mask;
36197 if ((unsigned long)buf & alignment
36198 || blk_rq_bytes(rq) & q->dma_pad_mask
36199 - || object_is_on_stack(buf))
36200 + || object_starts_on_stack(buf))
36201 drive->dma = 0;
36202 }
36203 }
36204 diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c
36205 index 8848f16..f8e6dd8 100644
36206 --- a/drivers/iio/industrialio-core.c
36207 +++ b/drivers/iio/industrialio-core.c
36208 @@ -506,7 +506,7 @@ static ssize_t iio_write_channel_info(struct device *dev,
36209 }
36210
36211 static
36212 -int __iio_device_attr_init(struct device_attribute *dev_attr,
36213 +int __iio_device_attr_init(device_attribute_no_const *dev_attr,
36214 const char *postfix,
36215 struct iio_chan_spec const *chan,
36216 ssize_t (*readfunc)(struct device *dev,
36217 diff --git a/drivers/infiniband/core/cm.c b/drivers/infiniband/core/cm.c
36218 index 394fea2..c833880 100644
36219 --- a/drivers/infiniband/core/cm.c
36220 +++ b/drivers/infiniband/core/cm.c
36221 @@ -114,7 +114,7 @@ static char const counter_group_names[CM_COUNTER_GROUPS]
36222
36223 struct cm_counter_group {
36224 struct kobject obj;
36225 - atomic_long_t counter[CM_ATTR_COUNT];
36226 + atomic_long_unchecked_t counter[CM_ATTR_COUNT];
36227 };
36228
36229 struct cm_counter_attribute {
36230 @@ -1394,7 +1394,7 @@ static void cm_dup_req_handler(struct cm_work *work,
36231 struct ib_mad_send_buf *msg = NULL;
36232 int ret;
36233
36234 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36235 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36236 counter[CM_REQ_COUNTER]);
36237
36238 /* Quick state check to discard duplicate REQs. */
36239 @@ -1778,7 +1778,7 @@ static void cm_dup_rep_handler(struct cm_work *work)
36240 if (!cm_id_priv)
36241 return;
36242
36243 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36244 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36245 counter[CM_REP_COUNTER]);
36246 ret = cm_alloc_response_msg(work->port, work->mad_recv_wc, &msg);
36247 if (ret)
36248 @@ -1945,7 +1945,7 @@ static int cm_rtu_handler(struct cm_work *work)
36249 if (cm_id_priv->id.state != IB_CM_REP_SENT &&
36250 cm_id_priv->id.state != IB_CM_MRA_REP_RCVD) {
36251 spin_unlock_irq(&cm_id_priv->lock);
36252 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36253 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36254 counter[CM_RTU_COUNTER]);
36255 goto out;
36256 }
36257 @@ -2128,7 +2128,7 @@ static int cm_dreq_handler(struct cm_work *work)
36258 cm_id_priv = cm_acquire_id(dreq_msg->remote_comm_id,
36259 dreq_msg->local_comm_id);
36260 if (!cm_id_priv) {
36261 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36262 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36263 counter[CM_DREQ_COUNTER]);
36264 cm_issue_drep(work->port, work->mad_recv_wc);
36265 return -EINVAL;
36266 @@ -2153,7 +2153,7 @@ static int cm_dreq_handler(struct cm_work *work)
36267 case IB_CM_MRA_REP_RCVD:
36268 break;
36269 case IB_CM_TIMEWAIT:
36270 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36271 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36272 counter[CM_DREQ_COUNTER]);
36273 if (cm_alloc_response_msg(work->port, work->mad_recv_wc, &msg))
36274 goto unlock;
36275 @@ -2167,7 +2167,7 @@ static int cm_dreq_handler(struct cm_work *work)
36276 cm_free_msg(msg);
36277 goto deref;
36278 case IB_CM_DREQ_RCVD:
36279 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36280 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36281 counter[CM_DREQ_COUNTER]);
36282 goto unlock;
36283 default:
36284 @@ -2534,7 +2534,7 @@ static int cm_mra_handler(struct cm_work *work)
36285 ib_modify_mad(cm_id_priv->av.port->mad_agent,
36286 cm_id_priv->msg, timeout)) {
36287 if (cm_id_priv->id.lap_state == IB_CM_MRA_LAP_RCVD)
36288 - atomic_long_inc(&work->port->
36289 + atomic_long_inc_unchecked(&work->port->
36290 counter_group[CM_RECV_DUPLICATES].
36291 counter[CM_MRA_COUNTER]);
36292 goto out;
36293 @@ -2543,7 +2543,7 @@ static int cm_mra_handler(struct cm_work *work)
36294 break;
36295 case IB_CM_MRA_REQ_RCVD:
36296 case IB_CM_MRA_REP_RCVD:
36297 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36298 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36299 counter[CM_MRA_COUNTER]);
36300 /* fall through */
36301 default:
36302 @@ -2705,7 +2705,7 @@ static int cm_lap_handler(struct cm_work *work)
36303 case IB_CM_LAP_IDLE:
36304 break;
36305 case IB_CM_MRA_LAP_SENT:
36306 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36307 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36308 counter[CM_LAP_COUNTER]);
36309 if (cm_alloc_response_msg(work->port, work->mad_recv_wc, &msg))
36310 goto unlock;
36311 @@ -2721,7 +2721,7 @@ static int cm_lap_handler(struct cm_work *work)
36312 cm_free_msg(msg);
36313 goto deref;
36314 case IB_CM_LAP_RCVD:
36315 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36316 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36317 counter[CM_LAP_COUNTER]);
36318 goto unlock;
36319 default:
36320 @@ -3005,7 +3005,7 @@ static int cm_sidr_req_handler(struct cm_work *work)
36321 cur_cm_id_priv = cm_insert_remote_sidr(cm_id_priv);
36322 if (cur_cm_id_priv) {
36323 spin_unlock_irq(&cm.lock);
36324 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36325 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36326 counter[CM_SIDR_REQ_COUNTER]);
36327 goto out; /* Duplicate message. */
36328 }
36329 @@ -3217,10 +3217,10 @@ static void cm_send_handler(struct ib_mad_agent *mad_agent,
36330 if (!msg->context[0] && (attr_index != CM_REJ_COUNTER))
36331 msg->retries = 1;
36332
36333 - atomic_long_add(1 + msg->retries,
36334 + atomic_long_add_unchecked(1 + msg->retries,
36335 &port->counter_group[CM_XMIT].counter[attr_index]);
36336 if (msg->retries)
36337 - atomic_long_add(msg->retries,
36338 + atomic_long_add_unchecked(msg->retries,
36339 &port->counter_group[CM_XMIT_RETRIES].
36340 counter[attr_index]);
36341
36342 @@ -3430,7 +3430,7 @@ static void cm_recv_handler(struct ib_mad_agent *mad_agent,
36343 }
36344
36345 attr_id = be16_to_cpu(mad_recv_wc->recv_buf.mad->mad_hdr.attr_id);
36346 - atomic_long_inc(&port->counter_group[CM_RECV].
36347 + atomic_long_inc_unchecked(&port->counter_group[CM_RECV].
36348 counter[attr_id - CM_ATTR_ID_OFFSET]);
36349
36350 work = kmalloc(sizeof *work + sizeof(struct ib_sa_path_rec) * paths,
36351 @@ -3635,7 +3635,7 @@ static ssize_t cm_show_counter(struct kobject *obj, struct attribute *attr,
36352 cm_attr = container_of(attr, struct cm_counter_attribute, attr);
36353
36354 return sprintf(buf, "%ld\n",
36355 - atomic_long_read(&group->counter[cm_attr->index]));
36356 + atomic_long_read_unchecked(&group->counter[cm_attr->index]));
36357 }
36358
36359 static const struct sysfs_ops cm_counter_ops = {
36360 diff --git a/drivers/infiniband/core/fmr_pool.c b/drivers/infiniband/core/fmr_pool.c
36361 index 176c8f9..2627b62 100644
36362 --- a/drivers/infiniband/core/fmr_pool.c
36363 +++ b/drivers/infiniband/core/fmr_pool.c
36364 @@ -98,8 +98,8 @@ struct ib_fmr_pool {
36365
36366 struct task_struct *thread;
36367
36368 - atomic_t req_ser;
36369 - atomic_t flush_ser;
36370 + atomic_unchecked_t req_ser;
36371 + atomic_unchecked_t flush_ser;
36372
36373 wait_queue_head_t force_wait;
36374 };
36375 @@ -180,10 +180,10 @@ static int ib_fmr_cleanup_thread(void *pool_ptr)
36376 struct ib_fmr_pool *pool = pool_ptr;
36377
36378 do {
36379 - if (atomic_read(&pool->flush_ser) - atomic_read(&pool->req_ser) < 0) {
36380 + if (atomic_read_unchecked(&pool->flush_ser) - atomic_read_unchecked(&pool->req_ser) < 0) {
36381 ib_fmr_batch_release(pool);
36382
36383 - atomic_inc(&pool->flush_ser);
36384 + atomic_inc_unchecked(&pool->flush_ser);
36385 wake_up_interruptible(&pool->force_wait);
36386
36387 if (pool->flush_function)
36388 @@ -191,7 +191,7 @@ static int ib_fmr_cleanup_thread(void *pool_ptr)
36389 }
36390
36391 set_current_state(TASK_INTERRUPTIBLE);
36392 - if (atomic_read(&pool->flush_ser) - atomic_read(&pool->req_ser) >= 0 &&
36393 + if (atomic_read_unchecked(&pool->flush_ser) - atomic_read_unchecked(&pool->req_ser) >= 0 &&
36394 !kthread_should_stop())
36395 schedule();
36396 __set_current_state(TASK_RUNNING);
36397 @@ -283,8 +283,8 @@ struct ib_fmr_pool *ib_create_fmr_pool(struct ib_pd *pd,
36398 pool->dirty_watermark = params->dirty_watermark;
36399 pool->dirty_len = 0;
36400 spin_lock_init(&pool->pool_lock);
36401 - atomic_set(&pool->req_ser, 0);
36402 - atomic_set(&pool->flush_ser, 0);
36403 + atomic_set_unchecked(&pool->req_ser, 0);
36404 + atomic_set_unchecked(&pool->flush_ser, 0);
36405 init_waitqueue_head(&pool->force_wait);
36406
36407 pool->thread = kthread_run(ib_fmr_cleanup_thread,
36408 @@ -412,11 +412,11 @@ int ib_flush_fmr_pool(struct ib_fmr_pool *pool)
36409 }
36410 spin_unlock_irq(&pool->pool_lock);
36411
36412 - serial = atomic_inc_return(&pool->req_ser);
36413 + serial = atomic_inc_return_unchecked(&pool->req_ser);
36414 wake_up_process(pool->thread);
36415
36416 if (wait_event_interruptible(pool->force_wait,
36417 - atomic_read(&pool->flush_ser) - serial >= 0))
36418 + atomic_read_unchecked(&pool->flush_ser) - serial >= 0))
36419 return -EINTR;
36420
36421 return 0;
36422 @@ -526,7 +526,7 @@ int ib_fmr_pool_unmap(struct ib_pool_fmr *fmr)
36423 } else {
36424 list_add_tail(&fmr->list, &pool->dirty_list);
36425 if (++pool->dirty_len >= pool->dirty_watermark) {
36426 - atomic_inc(&pool->req_ser);
36427 + atomic_inc_unchecked(&pool->req_ser);
36428 wake_up_process(pool->thread);
36429 }
36430 }
36431 diff --git a/drivers/infiniband/hw/cxgb4/mem.c b/drivers/infiniband/hw/cxgb4/mem.c
36432 index afd8179..598063f 100644
36433 --- a/drivers/infiniband/hw/cxgb4/mem.c
36434 +++ b/drivers/infiniband/hw/cxgb4/mem.c
36435 @@ -122,7 +122,7 @@ static int write_tpt_entry(struct c4iw_rdev *rdev, u32 reset_tpt_entry,
36436 int err;
36437 struct fw_ri_tpte tpt;
36438 u32 stag_idx;
36439 - static atomic_t key;
36440 + static atomic_unchecked_t key;
36441
36442 if (c4iw_fatal_error(rdev))
36443 return -EIO;
36444 @@ -139,7 +139,7 @@ static int write_tpt_entry(struct c4iw_rdev *rdev, u32 reset_tpt_entry,
36445 if (rdev->stats.stag.cur > rdev->stats.stag.max)
36446 rdev->stats.stag.max = rdev->stats.stag.cur;
36447 mutex_unlock(&rdev->stats.lock);
36448 - *stag = (stag_idx << 8) | (atomic_inc_return(&key) & 0xff);
36449 + *stag = (stag_idx << 8) | (atomic_inc_return_unchecked(&key) & 0xff);
36450 }
36451 PDBG("%s stag_state 0x%0x type 0x%0x pdid 0x%0x, stag_idx 0x%x\n",
36452 __func__, stag_state, type, pdid, stag_idx);
36453 diff --git a/drivers/infiniband/hw/ipath/ipath_rc.c b/drivers/infiniband/hw/ipath/ipath_rc.c
36454 index 79b3dbc..96e5fcc 100644
36455 --- a/drivers/infiniband/hw/ipath/ipath_rc.c
36456 +++ b/drivers/infiniband/hw/ipath/ipath_rc.c
36457 @@ -1868,7 +1868,7 @@ void ipath_rc_rcv(struct ipath_ibdev *dev, struct ipath_ib_header *hdr,
36458 struct ib_atomic_eth *ateth;
36459 struct ipath_ack_entry *e;
36460 u64 vaddr;
36461 - atomic64_t *maddr;
36462 + atomic64_unchecked_t *maddr;
36463 u64 sdata;
36464 u32 rkey;
36465 u8 next;
36466 @@ -1903,11 +1903,11 @@ void ipath_rc_rcv(struct ipath_ibdev *dev, struct ipath_ib_header *hdr,
36467 IB_ACCESS_REMOTE_ATOMIC)))
36468 goto nack_acc_unlck;
36469 /* Perform atomic OP and save result. */
36470 - maddr = (atomic64_t *) qp->r_sge.sge.vaddr;
36471 + maddr = (atomic64_unchecked_t *) qp->r_sge.sge.vaddr;
36472 sdata = be64_to_cpu(ateth->swap_data);
36473 e = &qp->s_ack_queue[qp->r_head_ack_queue];
36474 e->atomic_data = (opcode == OP(FETCH_ADD)) ?
36475 - (u64) atomic64_add_return(sdata, maddr) - sdata :
36476 + (u64) atomic64_add_return_unchecked(sdata, maddr) - sdata :
36477 (u64) cmpxchg((u64 *) qp->r_sge.sge.vaddr,
36478 be64_to_cpu(ateth->compare_data),
36479 sdata);
36480 diff --git a/drivers/infiniband/hw/ipath/ipath_ruc.c b/drivers/infiniband/hw/ipath/ipath_ruc.c
36481 index 1f95bba..9530f87 100644
36482 --- a/drivers/infiniband/hw/ipath/ipath_ruc.c
36483 +++ b/drivers/infiniband/hw/ipath/ipath_ruc.c
36484 @@ -266,7 +266,7 @@ static void ipath_ruc_loopback(struct ipath_qp *sqp)
36485 unsigned long flags;
36486 struct ib_wc wc;
36487 u64 sdata;
36488 - atomic64_t *maddr;
36489 + atomic64_unchecked_t *maddr;
36490 enum ib_wc_status send_status;
36491
36492 /*
36493 @@ -382,11 +382,11 @@ again:
36494 IB_ACCESS_REMOTE_ATOMIC)))
36495 goto acc_err;
36496 /* Perform atomic OP and save result. */
36497 - maddr = (atomic64_t *) qp->r_sge.sge.vaddr;
36498 + maddr = (atomic64_unchecked_t *) qp->r_sge.sge.vaddr;
36499 sdata = wqe->wr.wr.atomic.compare_add;
36500 *(u64 *) sqp->s_sge.sge.vaddr =
36501 (wqe->wr.opcode == IB_WR_ATOMIC_FETCH_AND_ADD) ?
36502 - (u64) atomic64_add_return(sdata, maddr) - sdata :
36503 + (u64) atomic64_add_return_unchecked(sdata, maddr) - sdata :
36504 (u64) cmpxchg((u64 *) qp->r_sge.sge.vaddr,
36505 sdata, wqe->wr.wr.atomic.swap);
36506 goto send_comp;
36507 diff --git a/drivers/infiniband/hw/mthca/mthca_cmd.c b/drivers/infiniband/hw/mthca/mthca_cmd.c
36508 index 9d3e5c1..d9afe4a 100644
36509 --- a/drivers/infiniband/hw/mthca/mthca_cmd.c
36510 +++ b/drivers/infiniband/hw/mthca/mthca_cmd.c
36511 @@ -772,7 +772,7 @@ static void mthca_setup_cmd_doorbells(struct mthca_dev *dev, u64 base)
36512 mthca_dbg(dev, "Mapped doorbell page for posting FW commands\n");
36513 }
36514
36515 -int mthca_QUERY_FW(struct mthca_dev *dev)
36516 +int __intentional_overflow(-1) mthca_QUERY_FW(struct mthca_dev *dev)
36517 {
36518 struct mthca_mailbox *mailbox;
36519 u32 *outbox;
36520 diff --git a/drivers/infiniband/hw/mthca/mthca_mr.c b/drivers/infiniband/hw/mthca/mthca_mr.c
36521 index ed9a989..e0c5871 100644
36522 --- a/drivers/infiniband/hw/mthca/mthca_mr.c
36523 +++ b/drivers/infiniband/hw/mthca/mthca_mr.c
36524 @@ -426,7 +426,7 @@ static inline u32 adjust_key(struct mthca_dev *dev, u32 key)
36525 return key;
36526 }
36527
36528 -int mthca_mr_alloc(struct mthca_dev *dev, u32 pd, int buffer_size_shift,
36529 +int __intentional_overflow(-1) mthca_mr_alloc(struct mthca_dev *dev, u32 pd, int buffer_size_shift,
36530 u64 iova, u64 total_size, u32 access, struct mthca_mr *mr)
36531 {
36532 struct mthca_mailbox *mailbox;
36533 diff --git a/drivers/infiniband/hw/nes/nes.c b/drivers/infiniband/hw/nes/nes.c
36534 index 5b152a3..c1f3e83 100644
36535 --- a/drivers/infiniband/hw/nes/nes.c
36536 +++ b/drivers/infiniband/hw/nes/nes.c
36537 @@ -98,7 +98,7 @@ MODULE_PARM_DESC(limit_maxrdreqsz, "Limit max read request size to 256 Bytes");
36538 LIST_HEAD(nes_adapter_list);
36539 static LIST_HEAD(nes_dev_list);
36540
36541 -atomic_t qps_destroyed;
36542 +atomic_unchecked_t qps_destroyed;
36543
36544 static unsigned int ee_flsh_adapter;
36545 static unsigned int sysfs_nonidx_addr;
36546 @@ -267,7 +267,7 @@ static void nes_cqp_rem_ref_callback(struct nes_device *nesdev, struct nes_cqp_r
36547 struct nes_qp *nesqp = cqp_request->cqp_callback_pointer;
36548 struct nes_adapter *nesadapter = nesdev->nesadapter;
36549
36550 - atomic_inc(&qps_destroyed);
36551 + atomic_inc_unchecked(&qps_destroyed);
36552
36553 /* Free the control structures */
36554
36555 diff --git a/drivers/infiniband/hw/nes/nes.h b/drivers/infiniband/hw/nes/nes.h
36556 index 33cc589..3bd6538 100644
36557 --- a/drivers/infiniband/hw/nes/nes.h
36558 +++ b/drivers/infiniband/hw/nes/nes.h
36559 @@ -177,17 +177,17 @@ extern unsigned int nes_debug_level;
36560 extern unsigned int wqm_quanta;
36561 extern struct list_head nes_adapter_list;
36562
36563 -extern atomic_t cm_connects;
36564 -extern atomic_t cm_accepts;
36565 -extern atomic_t cm_disconnects;
36566 -extern atomic_t cm_closes;
36567 -extern atomic_t cm_connecteds;
36568 -extern atomic_t cm_connect_reqs;
36569 -extern atomic_t cm_rejects;
36570 -extern atomic_t mod_qp_timouts;
36571 -extern atomic_t qps_created;
36572 -extern atomic_t qps_destroyed;
36573 -extern atomic_t sw_qps_destroyed;
36574 +extern atomic_unchecked_t cm_connects;
36575 +extern atomic_unchecked_t cm_accepts;
36576 +extern atomic_unchecked_t cm_disconnects;
36577 +extern atomic_unchecked_t cm_closes;
36578 +extern atomic_unchecked_t cm_connecteds;
36579 +extern atomic_unchecked_t cm_connect_reqs;
36580 +extern atomic_unchecked_t cm_rejects;
36581 +extern atomic_unchecked_t mod_qp_timouts;
36582 +extern atomic_unchecked_t qps_created;
36583 +extern atomic_unchecked_t qps_destroyed;
36584 +extern atomic_unchecked_t sw_qps_destroyed;
36585 extern u32 mh_detected;
36586 extern u32 mh_pauses_sent;
36587 extern u32 cm_packets_sent;
36588 @@ -196,16 +196,16 @@ extern u32 cm_packets_created;
36589 extern u32 cm_packets_received;
36590 extern u32 cm_packets_dropped;
36591 extern u32 cm_packets_retrans;
36592 -extern atomic_t cm_listens_created;
36593 -extern atomic_t cm_listens_destroyed;
36594 +extern atomic_unchecked_t cm_listens_created;
36595 +extern atomic_unchecked_t cm_listens_destroyed;
36596 extern u32 cm_backlog_drops;
36597 -extern atomic_t cm_loopbacks;
36598 -extern atomic_t cm_nodes_created;
36599 -extern atomic_t cm_nodes_destroyed;
36600 -extern atomic_t cm_accel_dropped_pkts;
36601 -extern atomic_t cm_resets_recvd;
36602 -extern atomic_t pau_qps_created;
36603 -extern atomic_t pau_qps_destroyed;
36604 +extern atomic_unchecked_t cm_loopbacks;
36605 +extern atomic_unchecked_t cm_nodes_created;
36606 +extern atomic_unchecked_t cm_nodes_destroyed;
36607 +extern atomic_unchecked_t cm_accel_dropped_pkts;
36608 +extern atomic_unchecked_t cm_resets_recvd;
36609 +extern atomic_unchecked_t pau_qps_created;
36610 +extern atomic_unchecked_t pau_qps_destroyed;
36611
36612 extern u32 int_mod_timer_init;
36613 extern u32 int_mod_cq_depth_256;
36614 diff --git a/drivers/infiniband/hw/nes/nes_cm.c b/drivers/infiniband/hw/nes/nes_cm.c
36615 index 22ea67e..dcbe3bc 100644
36616 --- a/drivers/infiniband/hw/nes/nes_cm.c
36617 +++ b/drivers/infiniband/hw/nes/nes_cm.c
36618 @@ -68,14 +68,14 @@ u32 cm_packets_dropped;
36619 u32 cm_packets_retrans;
36620 u32 cm_packets_created;
36621 u32 cm_packets_received;
36622 -atomic_t cm_listens_created;
36623 -atomic_t cm_listens_destroyed;
36624 +atomic_unchecked_t cm_listens_created;
36625 +atomic_unchecked_t cm_listens_destroyed;
36626 u32 cm_backlog_drops;
36627 -atomic_t cm_loopbacks;
36628 -atomic_t cm_nodes_created;
36629 -atomic_t cm_nodes_destroyed;
36630 -atomic_t cm_accel_dropped_pkts;
36631 -atomic_t cm_resets_recvd;
36632 +atomic_unchecked_t cm_loopbacks;
36633 +atomic_unchecked_t cm_nodes_created;
36634 +atomic_unchecked_t cm_nodes_destroyed;
36635 +atomic_unchecked_t cm_accel_dropped_pkts;
36636 +atomic_unchecked_t cm_resets_recvd;
36637
36638 static inline int mini_cm_accelerated(struct nes_cm_core *, struct nes_cm_node *);
36639 static struct nes_cm_listener *mini_cm_listen(struct nes_cm_core *, struct nes_vnic *, struct nes_cm_info *);
36640 @@ -148,13 +148,13 @@ static struct nes_cm_ops nes_cm_api = {
36641
36642 static struct nes_cm_core *g_cm_core;
36643
36644 -atomic_t cm_connects;
36645 -atomic_t cm_accepts;
36646 -atomic_t cm_disconnects;
36647 -atomic_t cm_closes;
36648 -atomic_t cm_connecteds;
36649 -atomic_t cm_connect_reqs;
36650 -atomic_t cm_rejects;
36651 +atomic_unchecked_t cm_connects;
36652 +atomic_unchecked_t cm_accepts;
36653 +atomic_unchecked_t cm_disconnects;
36654 +atomic_unchecked_t cm_closes;
36655 +atomic_unchecked_t cm_connecteds;
36656 +atomic_unchecked_t cm_connect_reqs;
36657 +atomic_unchecked_t cm_rejects;
36658
36659 int nes_add_ref_cm_node(struct nes_cm_node *cm_node)
36660 {
36661 @@ -1272,7 +1272,7 @@ static int mini_cm_dec_refcnt_listen(struct nes_cm_core *cm_core,
36662 kfree(listener);
36663 listener = NULL;
36664 ret = 0;
36665 - atomic_inc(&cm_listens_destroyed);
36666 + atomic_inc_unchecked(&cm_listens_destroyed);
36667 } else {
36668 spin_unlock_irqrestore(&cm_core->listen_list_lock, flags);
36669 }
36670 @@ -1466,7 +1466,7 @@ static struct nes_cm_node *make_cm_node(struct nes_cm_core *cm_core,
36671 cm_node->rem_mac);
36672
36673 add_hte_node(cm_core, cm_node);
36674 - atomic_inc(&cm_nodes_created);
36675 + atomic_inc_unchecked(&cm_nodes_created);
36676
36677 return cm_node;
36678 }
36679 @@ -1524,7 +1524,7 @@ static int rem_ref_cm_node(struct nes_cm_core *cm_core,
36680 }
36681
36682 atomic_dec(&cm_core->node_cnt);
36683 - atomic_inc(&cm_nodes_destroyed);
36684 + atomic_inc_unchecked(&cm_nodes_destroyed);
36685 nesqp = cm_node->nesqp;
36686 if (nesqp) {
36687 nesqp->cm_node = NULL;
36688 @@ -1588,7 +1588,7 @@ static int process_options(struct nes_cm_node *cm_node, u8 *optionsloc,
36689
36690 static void drop_packet(struct sk_buff *skb)
36691 {
36692 - atomic_inc(&cm_accel_dropped_pkts);
36693 + atomic_inc_unchecked(&cm_accel_dropped_pkts);
36694 dev_kfree_skb_any(skb);
36695 }
36696
36697 @@ -1651,7 +1651,7 @@ static void handle_rst_pkt(struct nes_cm_node *cm_node, struct sk_buff *skb,
36698 {
36699
36700 int reset = 0; /* whether to send reset in case of err.. */
36701 - atomic_inc(&cm_resets_recvd);
36702 + atomic_inc_unchecked(&cm_resets_recvd);
36703 nes_debug(NES_DBG_CM, "Received Reset, cm_node = %p, state = %u."
36704 " refcnt=%d\n", cm_node, cm_node->state,
36705 atomic_read(&cm_node->ref_count));
36706 @@ -2292,7 +2292,7 @@ static struct nes_cm_node *mini_cm_connect(struct nes_cm_core *cm_core,
36707 rem_ref_cm_node(cm_node->cm_core, cm_node);
36708 return NULL;
36709 }
36710 - atomic_inc(&cm_loopbacks);
36711 + atomic_inc_unchecked(&cm_loopbacks);
36712 loopbackremotenode->loopbackpartner = cm_node;
36713 loopbackremotenode->tcp_cntxt.rcv_wscale =
36714 NES_CM_DEFAULT_RCV_WND_SCALE;
36715 @@ -2567,7 +2567,7 @@ static int mini_cm_recv_pkt(struct nes_cm_core *cm_core,
36716 nes_queue_mgt_skbs(skb, nesvnic, cm_node->nesqp);
36717 else {
36718 rem_ref_cm_node(cm_core, cm_node);
36719 - atomic_inc(&cm_accel_dropped_pkts);
36720 + atomic_inc_unchecked(&cm_accel_dropped_pkts);
36721 dev_kfree_skb_any(skb);
36722 }
36723 break;
36724 @@ -2875,7 +2875,7 @@ static int nes_cm_disconn_true(struct nes_qp *nesqp)
36725
36726 if ((cm_id) && (cm_id->event_handler)) {
36727 if (issue_disconn) {
36728 - atomic_inc(&cm_disconnects);
36729 + atomic_inc_unchecked(&cm_disconnects);
36730 cm_event.event = IW_CM_EVENT_DISCONNECT;
36731 cm_event.status = disconn_status;
36732 cm_event.local_addr = cm_id->local_addr;
36733 @@ -2897,7 +2897,7 @@ static int nes_cm_disconn_true(struct nes_qp *nesqp)
36734 }
36735
36736 if (issue_close) {
36737 - atomic_inc(&cm_closes);
36738 + atomic_inc_unchecked(&cm_closes);
36739 nes_disconnect(nesqp, 1);
36740
36741 cm_id->provider_data = nesqp;
36742 @@ -3033,7 +3033,7 @@ int nes_accept(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
36743
36744 nes_debug(NES_DBG_CM, "QP%u, cm_node=%p, jiffies = %lu listener = %p\n",
36745 nesqp->hwqp.qp_id, cm_node, jiffies, cm_node->listener);
36746 - atomic_inc(&cm_accepts);
36747 + atomic_inc_unchecked(&cm_accepts);
36748
36749 nes_debug(NES_DBG_CM, "netdev refcnt = %u.\n",
36750 netdev_refcnt_read(nesvnic->netdev));
36751 @@ -3228,7 +3228,7 @@ int nes_reject(struct iw_cm_id *cm_id, const void *pdata, u8 pdata_len)
36752 struct nes_cm_core *cm_core;
36753 u8 *start_buff;
36754
36755 - atomic_inc(&cm_rejects);
36756 + atomic_inc_unchecked(&cm_rejects);
36757 cm_node = (struct nes_cm_node *)cm_id->provider_data;
36758 loopback = cm_node->loopbackpartner;
36759 cm_core = cm_node->cm_core;
36760 @@ -3288,7 +3288,7 @@ int nes_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
36761 ntohl(cm_id->local_addr.sin_addr.s_addr),
36762 ntohs(cm_id->local_addr.sin_port));
36763
36764 - atomic_inc(&cm_connects);
36765 + atomic_inc_unchecked(&cm_connects);
36766 nesqp->active_conn = 1;
36767
36768 /* cache the cm_id in the qp */
36769 @@ -3398,7 +3398,7 @@ int nes_create_listen(struct iw_cm_id *cm_id, int backlog)
36770 g_cm_core->api->stop_listener(g_cm_core, (void *)cm_node);
36771 return err;
36772 }
36773 - atomic_inc(&cm_listens_created);
36774 + atomic_inc_unchecked(&cm_listens_created);
36775 }
36776
36777 cm_id->add_ref(cm_id);
36778 @@ -3499,7 +3499,7 @@ static void cm_event_connected(struct nes_cm_event *event)
36779
36780 if (nesqp->destroyed)
36781 return;
36782 - atomic_inc(&cm_connecteds);
36783 + atomic_inc_unchecked(&cm_connecteds);
36784 nes_debug(NES_DBG_CM, "QP%u attempting to connect to 0x%08X:0x%04X on"
36785 " local port 0x%04X. jiffies = %lu.\n",
36786 nesqp->hwqp.qp_id,
36787 @@ -3679,7 +3679,7 @@ static void cm_event_reset(struct nes_cm_event *event)
36788
36789 cm_id->add_ref(cm_id);
36790 ret = cm_id->event_handler(cm_id, &cm_event);
36791 - atomic_inc(&cm_closes);
36792 + atomic_inc_unchecked(&cm_closes);
36793 cm_event.event = IW_CM_EVENT_CLOSE;
36794 cm_event.status = 0;
36795 cm_event.provider_data = cm_id->provider_data;
36796 @@ -3715,7 +3715,7 @@ static void cm_event_mpa_req(struct nes_cm_event *event)
36797 return;
36798 cm_id = cm_node->cm_id;
36799
36800 - atomic_inc(&cm_connect_reqs);
36801 + atomic_inc_unchecked(&cm_connect_reqs);
36802 nes_debug(NES_DBG_CM, "cm_node = %p - cm_id = %p, jiffies = %lu\n",
36803 cm_node, cm_id, jiffies);
36804
36805 @@ -3755,7 +3755,7 @@ static void cm_event_mpa_reject(struct nes_cm_event *event)
36806 return;
36807 cm_id = cm_node->cm_id;
36808
36809 - atomic_inc(&cm_connect_reqs);
36810 + atomic_inc_unchecked(&cm_connect_reqs);
36811 nes_debug(NES_DBG_CM, "cm_node = %p - cm_id = %p, jiffies = %lu\n",
36812 cm_node, cm_id, jiffies);
36813
36814 diff --git a/drivers/infiniband/hw/nes/nes_mgt.c b/drivers/infiniband/hw/nes/nes_mgt.c
36815 index 4166452..fc952c3 100644
36816 --- a/drivers/infiniband/hw/nes/nes_mgt.c
36817 +++ b/drivers/infiniband/hw/nes/nes_mgt.c
36818 @@ -40,8 +40,8 @@
36819 #include "nes.h"
36820 #include "nes_mgt.h"
36821
36822 -atomic_t pau_qps_created;
36823 -atomic_t pau_qps_destroyed;
36824 +atomic_unchecked_t pau_qps_created;
36825 +atomic_unchecked_t pau_qps_destroyed;
36826
36827 static void nes_replenish_mgt_rq(struct nes_vnic_mgt *mgtvnic)
36828 {
36829 @@ -621,7 +621,7 @@ void nes_destroy_pau_qp(struct nes_device *nesdev, struct nes_qp *nesqp)
36830 {
36831 struct sk_buff *skb;
36832 unsigned long flags;
36833 - atomic_inc(&pau_qps_destroyed);
36834 + atomic_inc_unchecked(&pau_qps_destroyed);
36835
36836 /* Free packets that have not yet been forwarded */
36837 /* Lock is acquired by skb_dequeue when removing the skb */
36838 @@ -810,7 +810,7 @@ static void nes_mgt_ce_handler(struct nes_device *nesdev, struct nes_hw_nic_cq *
36839 cq->cq_vbase[head].cqe_words[NES_NIC_CQE_HASH_RCVNXT]);
36840 skb_queue_head_init(&nesqp->pau_list);
36841 spin_lock_init(&nesqp->pau_lock);
36842 - atomic_inc(&pau_qps_created);
36843 + atomic_inc_unchecked(&pau_qps_created);
36844 nes_change_quad_hash(nesdev, mgtvnic->nesvnic, nesqp);
36845 }
36846
36847 diff --git a/drivers/infiniband/hw/nes/nes_nic.c b/drivers/infiniband/hw/nes/nes_nic.c
36848 index 9542e16..a008c40 100644
36849 --- a/drivers/infiniband/hw/nes/nes_nic.c
36850 +++ b/drivers/infiniband/hw/nes/nes_nic.c
36851 @@ -1273,39 +1273,39 @@ static void nes_netdev_get_ethtool_stats(struct net_device *netdev,
36852 target_stat_values[++index] = mh_detected;
36853 target_stat_values[++index] = mh_pauses_sent;
36854 target_stat_values[++index] = nesvnic->endnode_ipv4_tcp_retransmits;
36855 - target_stat_values[++index] = atomic_read(&cm_connects);
36856 - target_stat_values[++index] = atomic_read(&cm_accepts);
36857 - target_stat_values[++index] = atomic_read(&cm_disconnects);
36858 - target_stat_values[++index] = atomic_read(&cm_connecteds);
36859 - target_stat_values[++index] = atomic_read(&cm_connect_reqs);
36860 - target_stat_values[++index] = atomic_read(&cm_rejects);
36861 - target_stat_values[++index] = atomic_read(&mod_qp_timouts);
36862 - target_stat_values[++index] = atomic_read(&qps_created);
36863 - target_stat_values[++index] = atomic_read(&sw_qps_destroyed);
36864 - target_stat_values[++index] = atomic_read(&qps_destroyed);
36865 - target_stat_values[++index] = atomic_read(&cm_closes);
36866 + target_stat_values[++index] = atomic_read_unchecked(&cm_connects);
36867 + target_stat_values[++index] = atomic_read_unchecked(&cm_accepts);
36868 + target_stat_values[++index] = atomic_read_unchecked(&cm_disconnects);
36869 + target_stat_values[++index] = atomic_read_unchecked(&cm_connecteds);
36870 + target_stat_values[++index] = atomic_read_unchecked(&cm_connect_reqs);
36871 + target_stat_values[++index] = atomic_read_unchecked(&cm_rejects);
36872 + target_stat_values[++index] = atomic_read_unchecked(&mod_qp_timouts);
36873 + target_stat_values[++index] = atomic_read_unchecked(&qps_created);
36874 + target_stat_values[++index] = atomic_read_unchecked(&sw_qps_destroyed);
36875 + target_stat_values[++index] = atomic_read_unchecked(&qps_destroyed);
36876 + target_stat_values[++index] = atomic_read_unchecked(&cm_closes);
36877 target_stat_values[++index] = cm_packets_sent;
36878 target_stat_values[++index] = cm_packets_bounced;
36879 target_stat_values[++index] = cm_packets_created;
36880 target_stat_values[++index] = cm_packets_received;
36881 target_stat_values[++index] = cm_packets_dropped;
36882 target_stat_values[++index] = cm_packets_retrans;
36883 - target_stat_values[++index] = atomic_read(&cm_listens_created);
36884 - target_stat_values[++index] = atomic_read(&cm_listens_destroyed);
36885 + target_stat_values[++index] = atomic_read_unchecked(&cm_listens_created);
36886 + target_stat_values[++index] = atomic_read_unchecked(&cm_listens_destroyed);
36887 target_stat_values[++index] = cm_backlog_drops;
36888 - target_stat_values[++index] = atomic_read(&cm_loopbacks);
36889 - target_stat_values[++index] = atomic_read(&cm_nodes_created);
36890 - target_stat_values[++index] = atomic_read(&cm_nodes_destroyed);
36891 - target_stat_values[++index] = atomic_read(&cm_accel_dropped_pkts);
36892 - target_stat_values[++index] = atomic_read(&cm_resets_recvd);
36893 + target_stat_values[++index] = atomic_read_unchecked(&cm_loopbacks);
36894 + target_stat_values[++index] = atomic_read_unchecked(&cm_nodes_created);
36895 + target_stat_values[++index] = atomic_read_unchecked(&cm_nodes_destroyed);
36896 + target_stat_values[++index] = atomic_read_unchecked(&cm_accel_dropped_pkts);
36897 + target_stat_values[++index] = atomic_read_unchecked(&cm_resets_recvd);
36898 target_stat_values[++index] = nesadapter->free_4kpbl;
36899 target_stat_values[++index] = nesadapter->free_256pbl;
36900 target_stat_values[++index] = int_mod_timer_init;
36901 target_stat_values[++index] = nesvnic->lro_mgr.stats.aggregated;
36902 target_stat_values[++index] = nesvnic->lro_mgr.stats.flushed;
36903 target_stat_values[++index] = nesvnic->lro_mgr.stats.no_desc;
36904 - target_stat_values[++index] = atomic_read(&pau_qps_created);
36905 - target_stat_values[++index] = atomic_read(&pau_qps_destroyed);
36906 + target_stat_values[++index] = atomic_read_unchecked(&pau_qps_created);
36907 + target_stat_values[++index] = atomic_read_unchecked(&pau_qps_destroyed);
36908 }
36909
36910 /**
36911 diff --git a/drivers/infiniband/hw/nes/nes_verbs.c b/drivers/infiniband/hw/nes/nes_verbs.c
36912 index 07e4fba..685f041 100644
36913 --- a/drivers/infiniband/hw/nes/nes_verbs.c
36914 +++ b/drivers/infiniband/hw/nes/nes_verbs.c
36915 @@ -46,9 +46,9 @@
36916
36917 #include <rdma/ib_umem.h>
36918
36919 -atomic_t mod_qp_timouts;
36920 -atomic_t qps_created;
36921 -atomic_t sw_qps_destroyed;
36922 +atomic_unchecked_t mod_qp_timouts;
36923 +atomic_unchecked_t qps_created;
36924 +atomic_unchecked_t sw_qps_destroyed;
36925
36926 static void nes_unregister_ofa_device(struct nes_ib_device *nesibdev);
36927
36928 @@ -1131,7 +1131,7 @@ static struct ib_qp *nes_create_qp(struct ib_pd *ibpd,
36929 if (init_attr->create_flags)
36930 return ERR_PTR(-EINVAL);
36931
36932 - atomic_inc(&qps_created);
36933 + atomic_inc_unchecked(&qps_created);
36934 switch (init_attr->qp_type) {
36935 case IB_QPT_RC:
36936 if (nes_drv_opt & NES_DRV_OPT_NO_INLINE_DATA) {
36937 @@ -1462,7 +1462,7 @@ static int nes_destroy_qp(struct ib_qp *ibqp)
36938 struct iw_cm_event cm_event;
36939 int ret = 0;
36940
36941 - atomic_inc(&sw_qps_destroyed);
36942 + atomic_inc_unchecked(&sw_qps_destroyed);
36943 nesqp->destroyed = 1;
36944
36945 /* Blow away the connection if it exists. */
36946 diff --git a/drivers/infiniband/hw/qib/qib.h b/drivers/infiniband/hw/qib/qib.h
36947 index 4d11575..3e890e5 100644
36948 --- a/drivers/infiniband/hw/qib/qib.h
36949 +++ b/drivers/infiniband/hw/qib/qib.h
36950 @@ -51,6 +51,7 @@
36951 #include <linux/completion.h>
36952 #include <linux/kref.h>
36953 #include <linux/sched.h>
36954 +#include <linux/slab.h>
36955
36956 #include "qib_common.h"
36957 #include "qib_verbs.h"
36958 diff --git a/drivers/input/gameport/gameport.c b/drivers/input/gameport/gameport.c
36959 index da739d9..da1c7f4 100644
36960 --- a/drivers/input/gameport/gameport.c
36961 +++ b/drivers/input/gameport/gameport.c
36962 @@ -487,14 +487,14 @@ EXPORT_SYMBOL(gameport_set_phys);
36963 */
36964 static void gameport_init_port(struct gameport *gameport)
36965 {
36966 - static atomic_t gameport_no = ATOMIC_INIT(0);
36967 + static atomic_unchecked_t gameport_no = ATOMIC_INIT(0);
36968
36969 __module_get(THIS_MODULE);
36970
36971 mutex_init(&gameport->drv_mutex);
36972 device_initialize(&gameport->dev);
36973 dev_set_name(&gameport->dev, "gameport%lu",
36974 - (unsigned long)atomic_inc_return(&gameport_no) - 1);
36975 + (unsigned long)atomic_inc_return_unchecked(&gameport_no) - 1);
36976 gameport->dev.bus = &gameport_bus;
36977 gameport->dev.release = gameport_release_port;
36978 if (gameport->parent)
36979 diff --git a/drivers/input/input.c b/drivers/input/input.c
36980 index c044699..174d71a 100644
36981 --- a/drivers/input/input.c
36982 +++ b/drivers/input/input.c
36983 @@ -2019,7 +2019,7 @@ static void devm_input_device_unregister(struct device *dev, void *res)
36984 */
36985 int input_register_device(struct input_dev *dev)
36986 {
36987 - static atomic_t input_no = ATOMIC_INIT(0);
36988 + static atomic_unchecked_t input_no = ATOMIC_INIT(0);
36989 struct input_devres *devres = NULL;
36990 struct input_handler *handler;
36991 unsigned int packet_size;
36992 @@ -2074,7 +2074,7 @@ int input_register_device(struct input_dev *dev)
36993 dev->setkeycode = input_default_setkeycode;
36994
36995 dev_set_name(&dev->dev, "input%ld",
36996 - (unsigned long) atomic_inc_return(&input_no) - 1);
36997 + (unsigned long) atomic_inc_return_unchecked(&input_no) - 1);
36998
36999 error = device_add(&dev->dev);
37000 if (error)
37001 diff --git a/drivers/input/joystick/sidewinder.c b/drivers/input/joystick/sidewinder.c
37002 index 04c69af..5f92d00 100644
37003 --- a/drivers/input/joystick/sidewinder.c
37004 +++ b/drivers/input/joystick/sidewinder.c
37005 @@ -30,6 +30,7 @@
37006 #include <linux/kernel.h>
37007 #include <linux/module.h>
37008 #include <linux/slab.h>
37009 +#include <linux/sched.h>
37010 #include <linux/init.h>
37011 #include <linux/input.h>
37012 #include <linux/gameport.h>
37013 diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
37014 index d6cbfe9..6225402 100644
37015 --- a/drivers/input/joystick/xpad.c
37016 +++ b/drivers/input/joystick/xpad.c
37017 @@ -735,7 +735,7 @@ static void xpad_led_set(struct led_classdev *led_cdev,
37018
37019 static int xpad_led_probe(struct usb_xpad *xpad)
37020 {
37021 - static atomic_t led_seq = ATOMIC_INIT(0);
37022 + static atomic_unchecked_t led_seq = ATOMIC_INIT(0);
37023 long led_no;
37024 struct xpad_led *led;
37025 struct led_classdev *led_cdev;
37026 @@ -748,7 +748,7 @@ static int xpad_led_probe(struct usb_xpad *xpad)
37027 if (!led)
37028 return -ENOMEM;
37029
37030 - led_no = (long)atomic_inc_return(&led_seq) - 1;
37031 + led_no = (long)atomic_inc_return_unchecked(&led_seq) - 1;
37032
37033 snprintf(led->name, sizeof(led->name), "xpad%ld", led_no);
37034 led->xpad = xpad;
37035 diff --git a/drivers/input/mouse/psmouse.h b/drivers/input/mouse/psmouse.h
37036 index fe1df23..5b710f3 100644
37037 --- a/drivers/input/mouse/psmouse.h
37038 +++ b/drivers/input/mouse/psmouse.h
37039 @@ -115,7 +115,7 @@ struct psmouse_attribute {
37040 ssize_t (*set)(struct psmouse *psmouse, void *data,
37041 const char *buf, size_t count);
37042 bool protect;
37043 -};
37044 +} __do_const;
37045 #define to_psmouse_attr(a) container_of((a), struct psmouse_attribute, dattr)
37046
37047 ssize_t psmouse_attr_show_helper(struct device *dev, struct device_attribute *attr,
37048 diff --git a/drivers/input/mousedev.c b/drivers/input/mousedev.c
37049 index 4c842c3..590b0bf 100644
37050 --- a/drivers/input/mousedev.c
37051 +++ b/drivers/input/mousedev.c
37052 @@ -738,7 +738,7 @@ static ssize_t mousedev_read(struct file *file, char __user *buffer,
37053
37054 spin_unlock_irq(&client->packet_lock);
37055
37056 - if (copy_to_user(buffer, data, count))
37057 + if (count > sizeof(data) || copy_to_user(buffer, data, count))
37058 return -EFAULT;
37059
37060 return count;
37061 diff --git a/drivers/input/serio/serio.c b/drivers/input/serio/serio.c
37062 index 25fc597..558bf3b 100644
37063 --- a/drivers/input/serio/serio.c
37064 +++ b/drivers/input/serio/serio.c
37065 @@ -496,7 +496,7 @@ static void serio_release_port(struct device *dev)
37066 */
37067 static void serio_init_port(struct serio *serio)
37068 {
37069 - static atomic_t serio_no = ATOMIC_INIT(0);
37070 + static atomic_unchecked_t serio_no = ATOMIC_INIT(0);
37071
37072 __module_get(THIS_MODULE);
37073
37074 @@ -507,7 +507,7 @@ static void serio_init_port(struct serio *serio)
37075 mutex_init(&serio->drv_mutex);
37076 device_initialize(&serio->dev);
37077 dev_set_name(&serio->dev, "serio%ld",
37078 - (long)atomic_inc_return(&serio_no) - 1);
37079 + (long)atomic_inc_return_unchecked(&serio_no) - 1);
37080 serio->dev.bus = &serio_bus;
37081 serio->dev.release = serio_release_port;
37082 serio->dev.groups = serio_device_attr_groups;
37083 diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
37084 index ddbdaca..be18a78 100644
37085 --- a/drivers/iommu/iommu.c
37086 +++ b/drivers/iommu/iommu.c
37087 @@ -554,7 +554,7 @@ static struct notifier_block iommu_bus_nb = {
37088 static void iommu_bus_init(struct bus_type *bus, struct iommu_ops *ops)
37089 {
37090 bus_register_notifier(bus, &iommu_bus_nb);
37091 - bus_for_each_dev(bus, NULL, ops, add_iommu_group);
37092 + bus_for_each_dev(bus, NULL, (void *)ops, add_iommu_group);
37093 }
37094
37095 /**
37096 diff --git a/drivers/isdn/capi/capi.c b/drivers/isdn/capi/capi.c
37097 index 89562a8..218999b 100644
37098 --- a/drivers/isdn/capi/capi.c
37099 +++ b/drivers/isdn/capi/capi.c
37100 @@ -81,8 +81,8 @@ struct capiminor {
37101
37102 struct capi20_appl *ap;
37103 u32 ncci;
37104 - atomic_t datahandle;
37105 - atomic_t msgid;
37106 + atomic_unchecked_t datahandle;
37107 + atomic_unchecked_t msgid;
37108
37109 struct tty_port port;
37110 int ttyinstop;
37111 @@ -391,7 +391,7 @@ gen_data_b3_resp_for(struct capiminor *mp, struct sk_buff *skb)
37112 capimsg_setu16(s, 2, mp->ap->applid);
37113 capimsg_setu8 (s, 4, CAPI_DATA_B3);
37114 capimsg_setu8 (s, 5, CAPI_RESP);
37115 - capimsg_setu16(s, 6, atomic_inc_return(&mp->msgid));
37116 + capimsg_setu16(s, 6, atomic_inc_return_unchecked(&mp->msgid));
37117 capimsg_setu32(s, 8, mp->ncci);
37118 capimsg_setu16(s, 12, datahandle);
37119 }
37120 @@ -512,14 +512,14 @@ static void handle_minor_send(struct capiminor *mp)
37121 mp->outbytes -= len;
37122 spin_unlock_bh(&mp->outlock);
37123
37124 - datahandle = atomic_inc_return(&mp->datahandle);
37125 + datahandle = atomic_inc_return_unchecked(&mp->datahandle);
37126 skb_push(skb, CAPI_DATA_B3_REQ_LEN);
37127 memset(skb->data, 0, CAPI_DATA_B3_REQ_LEN);
37128 capimsg_setu16(skb->data, 0, CAPI_DATA_B3_REQ_LEN);
37129 capimsg_setu16(skb->data, 2, mp->ap->applid);
37130 capimsg_setu8 (skb->data, 4, CAPI_DATA_B3);
37131 capimsg_setu8 (skb->data, 5, CAPI_REQ);
37132 - capimsg_setu16(skb->data, 6, atomic_inc_return(&mp->msgid));
37133 + capimsg_setu16(skb->data, 6, atomic_inc_return_unchecked(&mp->msgid));
37134 capimsg_setu32(skb->data, 8, mp->ncci); /* NCCI */
37135 capimsg_setu32(skb->data, 12, (u32)(long)skb->data);/* Data32 */
37136 capimsg_setu16(skb->data, 16, len); /* Data length */
37137 diff --git a/drivers/isdn/gigaset/interface.c b/drivers/isdn/gigaset/interface.c
37138 index 67abf3f..076b3a6 100644
37139 --- a/drivers/isdn/gigaset/interface.c
37140 +++ b/drivers/isdn/gigaset/interface.c
37141 @@ -160,9 +160,9 @@ static int if_open(struct tty_struct *tty, struct file *filp)
37142 }
37143 tty->driver_data = cs;
37144
37145 - ++cs->port.count;
37146 + atomic_inc(&cs->port.count);
37147
37148 - if (cs->port.count == 1) {
37149 + if (atomic_read(&cs->port.count) == 1) {
37150 tty_port_tty_set(&cs->port, tty);
37151 tty->low_latency = 1;
37152 }
37153 @@ -186,9 +186,9 @@ static void if_close(struct tty_struct *tty, struct file *filp)
37154
37155 if (!cs->connected)
37156 gig_dbg(DEBUG_IF, "not connected"); /* nothing to do */
37157 - else if (!cs->port.count)
37158 + else if (!atomic_read(&cs->port.count))
37159 dev_warn(cs->dev, "%s: device not opened\n", __func__);
37160 - else if (!--cs->port.count)
37161 + else if (!atomic_dec_return(&cs->port.count))
37162 tty_port_tty_set(&cs->port, NULL);
37163
37164 mutex_unlock(&cs->mutex);
37165 diff --git a/drivers/isdn/hardware/avm/b1.c b/drivers/isdn/hardware/avm/b1.c
37166 index 821f7ac..28d4030 100644
37167 --- a/drivers/isdn/hardware/avm/b1.c
37168 +++ b/drivers/isdn/hardware/avm/b1.c
37169 @@ -176,7 +176,7 @@ int b1_load_t4file(avmcard *card, capiloaddatapart *t4file)
37170 }
37171 if (left) {
37172 if (t4file->user) {
37173 - if (copy_from_user(buf, dp, left))
37174 + if (left > sizeof buf || copy_from_user(buf, dp, left))
37175 return -EFAULT;
37176 } else {
37177 memcpy(buf, dp, left);
37178 @@ -224,7 +224,7 @@ int b1_load_config(avmcard *card, capiloaddatapart *config)
37179 }
37180 if (left) {
37181 if (config->user) {
37182 - if (copy_from_user(buf, dp, left))
37183 + if (left > sizeof buf || copy_from_user(buf, dp, left))
37184 return -EFAULT;
37185 } else {
37186 memcpy(buf, dp, left);
37187 diff --git a/drivers/isdn/i4l/isdn_tty.c b/drivers/isdn/i4l/isdn_tty.c
37188 index e09dc8a..15e2efb 100644
37189 --- a/drivers/isdn/i4l/isdn_tty.c
37190 +++ b/drivers/isdn/i4l/isdn_tty.c
37191 @@ -1513,9 +1513,9 @@ isdn_tty_open(struct tty_struct *tty, struct file *filp)
37192
37193 #ifdef ISDN_DEBUG_MODEM_OPEN
37194 printk(KERN_DEBUG "isdn_tty_open %s, count = %d\n", tty->name,
37195 - port->count);
37196 + atomic_read(&port->count));
37197 #endif
37198 - port->count++;
37199 + atomic_inc(&port->count);
37200 port->tty = tty;
37201 /*
37202 * Start up serial port
37203 @@ -1559,7 +1559,7 @@ isdn_tty_close(struct tty_struct *tty, struct file *filp)
37204 #endif
37205 return;
37206 }
37207 - if ((tty->count == 1) && (port->count != 1)) {
37208 + if ((tty->count == 1) && (atomic_read(&port->count) != 1)) {
37209 /*
37210 * Uh, oh. tty->count is 1, which means that the tty
37211 * structure will be freed. Info->count should always
37212 @@ -1568,15 +1568,15 @@ isdn_tty_close(struct tty_struct *tty, struct file *filp)
37213 * serial port won't be shutdown.
37214 */
37215 printk(KERN_ERR "isdn_tty_close: bad port count; tty->count is 1, "
37216 - "info->count is %d\n", port->count);
37217 - port->count = 1;
37218 + "info->count is %d\n", atomic_read(&port->count));
37219 + atomic_set(&port->count, 1);
37220 }
37221 - if (--port->count < 0) {
37222 + if (atomic_dec_return(&port->count) < 0) {
37223 printk(KERN_ERR "isdn_tty_close: bad port count for ttyi%d: %d\n",
37224 - info->line, port->count);
37225 - port->count = 0;
37226 + info->line, atomic_read(&port->count));
37227 + atomic_set(&port->count, 0);
37228 }
37229 - if (port->count) {
37230 + if (atomic_read(&port->count)) {
37231 #ifdef ISDN_DEBUG_MODEM_OPEN
37232 printk(KERN_DEBUG "isdn_tty_close after info->count != 0\n");
37233 #endif
37234 @@ -1630,7 +1630,7 @@ isdn_tty_hangup(struct tty_struct *tty)
37235 if (isdn_tty_paranoia_check(info, tty->name, "isdn_tty_hangup"))
37236 return;
37237 isdn_tty_shutdown(info);
37238 - port->count = 0;
37239 + atomic_set(&port->count, 0);
37240 port->flags &= ~ASYNC_NORMAL_ACTIVE;
37241 port->tty = NULL;
37242 wake_up_interruptible(&port->open_wait);
37243 @@ -1975,7 +1975,7 @@ isdn_tty_find_icall(int di, int ch, setup_parm *setup)
37244 for (i = 0; i < ISDN_MAX_CHANNELS; i++) {
37245 modem_info *info = &dev->mdm.info[i];
37246
37247 - if (info->port.count == 0)
37248 + if (atomic_read(&info->port.count) == 0)
37249 continue;
37250 if ((info->emu.mdmreg[REG_SI1] & si2bit[si1]) && /* SI1 is matching */
37251 (info->emu.mdmreg[REG_SI2] == si2)) { /* SI2 is matching */
37252 diff --git a/drivers/isdn/icn/icn.c b/drivers/isdn/icn/icn.c
37253 index e74df7c..03a03ba 100644
37254 --- a/drivers/isdn/icn/icn.c
37255 +++ b/drivers/isdn/icn/icn.c
37256 @@ -1045,7 +1045,7 @@ icn_writecmd(const u_char *buf, int len, int user, icn_card *card)
37257 if (count > len)
37258 count = len;
37259 if (user) {
37260 - if (copy_from_user(msg, buf, count))
37261 + if (count > sizeof msg || copy_from_user(msg, buf, count))
37262 return -EFAULT;
37263 } else
37264 memcpy(msg, buf, count);
37265 diff --git a/drivers/leds/leds-clevo-mail.c b/drivers/leds/leds-clevo-mail.c
37266 index 6a8405d..0bd1c7e 100644
37267 --- a/drivers/leds/leds-clevo-mail.c
37268 +++ b/drivers/leds/leds-clevo-mail.c
37269 @@ -40,7 +40,7 @@ static int __init clevo_mail_led_dmi_callback(const struct dmi_system_id *id)
37270 * detected as working, but in reality it is not) as low as
37271 * possible.
37272 */
37273 -static struct dmi_system_id __initdata clevo_mail_led_dmi_table[] = {
37274 +static const struct dmi_system_id __initconst clevo_mail_led_dmi_table[] = {
37275 {
37276 .callback = clevo_mail_led_dmi_callback,
37277 .ident = "Clevo D410J",
37278 diff --git a/drivers/leds/leds-ss4200.c b/drivers/leds/leds-ss4200.c
37279 index ec9b287..65c9bf4 100644
37280 --- a/drivers/leds/leds-ss4200.c
37281 +++ b/drivers/leds/leds-ss4200.c
37282 @@ -92,7 +92,7 @@ MODULE_PARM_DESC(nodetect, "Skip DMI-based hardware detection");
37283 * detected as working, but in reality it is not) as low as
37284 * possible.
37285 */
37286 -static struct dmi_system_id __initdata nas_led_whitelist[] = {
37287 +static const struct dmi_system_id __initconst nas_led_whitelist[] = {
37288 {
37289 .callback = ss4200_led_dmi_callback,
37290 .ident = "Intel SS4200-E",
37291 diff --git a/drivers/lguest/core.c b/drivers/lguest/core.c
37292 index a5ebc00..982886f 100644
37293 --- a/drivers/lguest/core.c
37294 +++ b/drivers/lguest/core.c
37295 @@ -92,9 +92,17 @@ static __init int map_switcher(void)
37296 * it's worked so far. The end address needs +1 because __get_vm_area
37297 * allocates an extra guard page, so we need space for that.
37298 */
37299 +
37300 +#if defined(CONFIG_MODULES) && defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
37301 + switcher_vma = __get_vm_area(TOTAL_SWITCHER_PAGES * PAGE_SIZE,
37302 + VM_ALLOC | VM_KERNEXEC, SWITCHER_ADDR, SWITCHER_ADDR
37303 + + (TOTAL_SWITCHER_PAGES+1) * PAGE_SIZE);
37304 +#else
37305 switcher_vma = __get_vm_area(TOTAL_SWITCHER_PAGES * PAGE_SIZE,
37306 VM_ALLOC, SWITCHER_ADDR, SWITCHER_ADDR
37307 + (TOTAL_SWITCHER_PAGES+1) * PAGE_SIZE);
37308 +#endif
37309 +
37310 if (!switcher_vma) {
37311 err = -ENOMEM;
37312 printk("lguest: could not map switcher pages high\n");
37313 @@ -119,7 +127,7 @@ static __init int map_switcher(void)
37314 * Now the Switcher is mapped at the right address, we can't fail!
37315 * Copy in the compiled-in Switcher code (from x86/switcher_32.S).
37316 */
37317 - memcpy(switcher_vma->addr, start_switcher_text,
37318 + memcpy(switcher_vma->addr, ktla_ktva(start_switcher_text),
37319 end_switcher_text - start_switcher_text);
37320
37321 printk(KERN_INFO "lguest: mapped switcher at %p\n",
37322 diff --git a/drivers/lguest/page_tables.c b/drivers/lguest/page_tables.c
37323 index 3b62be16..e33134a 100644
37324 --- a/drivers/lguest/page_tables.c
37325 +++ b/drivers/lguest/page_tables.c
37326 @@ -532,7 +532,7 @@ void pin_page(struct lg_cpu *cpu, unsigned long vaddr)
37327 /*:*/
37328
37329 #ifdef CONFIG_X86_PAE
37330 -static void release_pmd(pmd_t *spmd)
37331 +static void __intentional_overflow(-1) release_pmd(pmd_t *spmd)
37332 {
37333 /* If the entry's not present, there's nothing to release. */
37334 if (pmd_flags(*spmd) & _PAGE_PRESENT) {
37335 diff --git a/drivers/lguest/x86/core.c b/drivers/lguest/x86/core.c
37336 index 4af12e1..0e89afe 100644
37337 --- a/drivers/lguest/x86/core.c
37338 +++ b/drivers/lguest/x86/core.c
37339 @@ -59,7 +59,7 @@ static struct {
37340 /* Offset from where switcher.S was compiled to where we've copied it */
37341 static unsigned long switcher_offset(void)
37342 {
37343 - return SWITCHER_ADDR - (unsigned long)start_switcher_text;
37344 + return SWITCHER_ADDR - (unsigned long)ktla_ktva(start_switcher_text);
37345 }
37346
37347 /* This cpu's struct lguest_pages. */
37348 @@ -100,7 +100,13 @@ static void copy_in_guest_info(struct lg_cpu *cpu, struct lguest_pages *pages)
37349 * These copies are pretty cheap, so we do them unconditionally: */
37350 /* Save the current Host top-level page directory.
37351 */
37352 +
37353 +#ifdef CONFIG_PAX_PER_CPU_PGD
37354 + pages->state.host_cr3 = read_cr3();
37355 +#else
37356 pages->state.host_cr3 = __pa(current->mm->pgd);
37357 +#endif
37358 +
37359 /*
37360 * Set up the Guest's page tables to see this CPU's pages (and no
37361 * other CPU's pages).
37362 @@ -476,7 +482,7 @@ void __init lguest_arch_host_init(void)
37363 * compiled-in switcher code and the high-mapped copy we just made.
37364 */
37365 for (i = 0; i < IDT_ENTRIES; i++)
37366 - default_idt_entries[i] += switcher_offset();
37367 + default_idt_entries[i] = ktla_ktva(default_idt_entries[i]) + switcher_offset();
37368
37369 /*
37370 * Set up the Switcher's per-cpu areas.
37371 @@ -559,7 +565,7 @@ void __init lguest_arch_host_init(void)
37372 * it will be undisturbed when we switch. To change %cs and jump we
37373 * need this structure to feed to Intel's "lcall" instruction.
37374 */
37375 - lguest_entry.offset = (long)switch_to_guest + switcher_offset();
37376 + lguest_entry.offset = (long)ktla_ktva(switch_to_guest) + switcher_offset();
37377 lguest_entry.segment = LGUEST_CS;
37378
37379 /*
37380 diff --git a/drivers/lguest/x86/switcher_32.S b/drivers/lguest/x86/switcher_32.S
37381 index 40634b0..4f5855e 100644
37382 --- a/drivers/lguest/x86/switcher_32.S
37383 +++ b/drivers/lguest/x86/switcher_32.S
37384 @@ -87,6 +87,7 @@
37385 #include <asm/page.h>
37386 #include <asm/segment.h>
37387 #include <asm/lguest.h>
37388 +#include <asm/processor-flags.h>
37389
37390 // We mark the start of the code to copy
37391 // It's placed in .text tho it's never run here
37392 @@ -149,6 +150,13 @@ ENTRY(switch_to_guest)
37393 // Changes type when we load it: damn Intel!
37394 // For after we switch over our page tables
37395 // That entry will be read-only: we'd crash.
37396 +
37397 +#ifdef CONFIG_PAX_KERNEXEC
37398 + mov %cr0, %edx
37399 + xor $X86_CR0_WP, %edx
37400 + mov %edx, %cr0
37401 +#endif
37402 +
37403 movl $(GDT_ENTRY_TSS*8), %edx
37404 ltr %dx
37405
37406 @@ -157,9 +165,15 @@ ENTRY(switch_to_guest)
37407 // Let's clear it again for our return.
37408 // The GDT descriptor of the Host
37409 // Points to the table after two "size" bytes
37410 - movl (LGUEST_PAGES_host_gdt_desc+2)(%eax), %edx
37411 + movl (LGUEST_PAGES_host_gdt_desc+2)(%eax), %eax
37412 // Clear "used" from type field (byte 5, bit 2)
37413 - andb $0xFD, (GDT_ENTRY_TSS*8 + 5)(%edx)
37414 + andb $0xFD, (GDT_ENTRY_TSS*8 + 5)(%eax)
37415 +
37416 +#ifdef CONFIG_PAX_KERNEXEC
37417 + mov %cr0, %eax
37418 + xor $X86_CR0_WP, %eax
37419 + mov %eax, %cr0
37420 +#endif
37421
37422 // Once our page table's switched, the Guest is live!
37423 // The Host fades as we run this final step.
37424 @@ -295,13 +309,12 @@ deliver_to_host:
37425 // I consulted gcc, and it gave
37426 // These instructions, which I gladly credit:
37427 leal (%edx,%ebx,8), %eax
37428 - movzwl (%eax),%edx
37429 - movl 4(%eax), %eax
37430 - xorw %ax, %ax
37431 - orl %eax, %edx
37432 + movl 4(%eax), %edx
37433 + movw (%eax), %dx
37434 // Now the address of the handler's in %edx
37435 // We call it now: its "iret" drops us home.
37436 - jmp *%edx
37437 + ljmp $__KERNEL_CS, $1f
37438 +1: jmp *%edx
37439
37440 // Every interrupt can come to us here
37441 // But we must truly tell each apart.
37442 diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c
37443 index 7155945..4bcc562 100644
37444 --- a/drivers/md/bitmap.c
37445 +++ b/drivers/md/bitmap.c
37446 @@ -1779,7 +1779,7 @@ void bitmap_status(struct seq_file *seq, struct bitmap *bitmap)
37447 chunk_kb ? "KB" : "B");
37448 if (bitmap->storage.file) {
37449 seq_printf(seq, ", file: ");
37450 - seq_path(seq, &bitmap->storage.file->f_path, " \t\n");
37451 + seq_path(seq, &bitmap->storage.file->f_path, " \t\n\\");
37452 }
37453
37454 seq_printf(seq, "\n");
37455 diff --git a/drivers/md/dm-ioctl.c b/drivers/md/dm-ioctl.c
37456 index eee353d..74504c4 100644
37457 --- a/drivers/md/dm-ioctl.c
37458 +++ b/drivers/md/dm-ioctl.c
37459 @@ -1632,7 +1632,7 @@ static int validate_params(uint cmd, struct dm_ioctl *param)
37460 cmd == DM_LIST_VERSIONS_CMD)
37461 return 0;
37462
37463 - if ((cmd == DM_DEV_CREATE_CMD)) {
37464 + if (cmd == DM_DEV_CREATE_CMD) {
37465 if (!*param->name) {
37466 DMWARN("name not supplied when creating device");
37467 return -EINVAL;
37468 diff --git a/drivers/md/dm-raid1.c b/drivers/md/dm-raid1.c
37469 index 7f24190..0e18099 100644
37470 --- a/drivers/md/dm-raid1.c
37471 +++ b/drivers/md/dm-raid1.c
37472 @@ -40,7 +40,7 @@ enum dm_raid1_error {
37473
37474 struct mirror {
37475 struct mirror_set *ms;
37476 - atomic_t error_count;
37477 + atomic_unchecked_t error_count;
37478 unsigned long error_type;
37479 struct dm_dev *dev;
37480 sector_t offset;
37481 @@ -183,7 +183,7 @@ static struct mirror *get_valid_mirror(struct mirror_set *ms)
37482 struct mirror *m;
37483
37484 for (m = ms->mirror; m < ms->mirror + ms->nr_mirrors; m++)
37485 - if (!atomic_read(&m->error_count))
37486 + if (!atomic_read_unchecked(&m->error_count))
37487 return m;
37488
37489 return NULL;
37490 @@ -215,7 +215,7 @@ static void fail_mirror(struct mirror *m, enum dm_raid1_error error_type)
37491 * simple way to tell if a device has encountered
37492 * errors.
37493 */
37494 - atomic_inc(&m->error_count);
37495 + atomic_inc_unchecked(&m->error_count);
37496
37497 if (test_and_set_bit(error_type, &m->error_type))
37498 return;
37499 @@ -406,7 +406,7 @@ static struct mirror *choose_mirror(struct mirror_set *ms, sector_t sector)
37500 struct mirror *m = get_default_mirror(ms);
37501
37502 do {
37503 - if (likely(!atomic_read(&m->error_count)))
37504 + if (likely(!atomic_read_unchecked(&m->error_count)))
37505 return m;
37506
37507 if (m-- == ms->mirror)
37508 @@ -420,7 +420,7 @@ static int default_ok(struct mirror *m)
37509 {
37510 struct mirror *default_mirror = get_default_mirror(m->ms);
37511
37512 - return !atomic_read(&default_mirror->error_count);
37513 + return !atomic_read_unchecked(&default_mirror->error_count);
37514 }
37515
37516 static int mirror_available(struct mirror_set *ms, struct bio *bio)
37517 @@ -557,7 +557,7 @@ static void do_reads(struct mirror_set *ms, struct bio_list *reads)
37518 */
37519 if (likely(region_in_sync(ms, region, 1)))
37520 m = choose_mirror(ms, bio->bi_sector);
37521 - else if (m && atomic_read(&m->error_count))
37522 + else if (m && atomic_read_unchecked(&m->error_count))
37523 m = NULL;
37524
37525 if (likely(m))
37526 @@ -924,7 +924,7 @@ static int get_mirror(struct mirror_set *ms, struct dm_target *ti,
37527 }
37528
37529 ms->mirror[mirror].ms = ms;
37530 - atomic_set(&(ms->mirror[mirror].error_count), 0);
37531 + atomic_set_unchecked(&(ms->mirror[mirror].error_count), 0);
37532 ms->mirror[mirror].error_type = 0;
37533 ms->mirror[mirror].offset = offset;
37534
37535 @@ -1337,7 +1337,7 @@ static void mirror_resume(struct dm_target *ti)
37536 */
37537 static char device_status_char(struct mirror *m)
37538 {
37539 - if (!atomic_read(&(m->error_count)))
37540 + if (!atomic_read_unchecked(&(m->error_count)))
37541 return 'A';
37542
37543 return (test_bit(DM_RAID1_FLUSH_ERROR, &(m->error_type))) ? 'F' :
37544 diff --git a/drivers/md/dm-stripe.c b/drivers/md/dm-stripe.c
37545 index aaecefa..23b3026 100644
37546 --- a/drivers/md/dm-stripe.c
37547 +++ b/drivers/md/dm-stripe.c
37548 @@ -20,7 +20,7 @@ struct stripe {
37549 struct dm_dev *dev;
37550 sector_t physical_start;
37551
37552 - atomic_t error_count;
37553 + atomic_unchecked_t error_count;
37554 };
37555
37556 struct stripe_c {
37557 @@ -184,7 +184,7 @@ static int stripe_ctr(struct dm_target *ti, unsigned int argc, char **argv)
37558 kfree(sc);
37559 return r;
37560 }
37561 - atomic_set(&(sc->stripe[i].error_count), 0);
37562 + atomic_set_unchecked(&(sc->stripe[i].error_count), 0);
37563 }
37564
37565 ti->private = sc;
37566 @@ -325,7 +325,7 @@ static void stripe_status(struct dm_target *ti, status_type_t type,
37567 DMEMIT("%d ", sc->stripes);
37568 for (i = 0; i < sc->stripes; i++) {
37569 DMEMIT("%s ", sc->stripe[i].dev->name);
37570 - buffer[i] = atomic_read(&(sc->stripe[i].error_count)) ?
37571 + buffer[i] = atomic_read_unchecked(&(sc->stripe[i].error_count)) ?
37572 'D' : 'A';
37573 }
37574 buffer[i] = '\0';
37575 @@ -370,8 +370,8 @@ static int stripe_end_io(struct dm_target *ti, struct bio *bio, int error)
37576 */
37577 for (i = 0; i < sc->stripes; i++)
37578 if (!strcmp(sc->stripe[i].dev->name, major_minor)) {
37579 - atomic_inc(&(sc->stripe[i].error_count));
37580 - if (atomic_read(&(sc->stripe[i].error_count)) <
37581 + atomic_inc_unchecked(&(sc->stripe[i].error_count));
37582 + if (atomic_read_unchecked(&(sc->stripe[i].error_count)) <
37583 DM_IO_ERROR_THRESHOLD)
37584 schedule_work(&sc->trigger_event);
37585 }
37586 diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c
37587 index daf25d0..d74f49f 100644
37588 --- a/drivers/md/dm-table.c
37589 +++ b/drivers/md/dm-table.c
37590 @@ -390,7 +390,7 @@ static int device_area_is_invalid(struct dm_target *ti, struct dm_dev *dev,
37591 if (!dev_size)
37592 return 0;
37593
37594 - if ((start >= dev_size) || (start + len > dev_size)) {
37595 + if ((start >= dev_size) || (len > dev_size - start)) {
37596 DMWARN("%s: %s too small for target: "
37597 "start=%llu, len=%llu, dev_size=%llu",
37598 dm_device_name(ti->table->md), bdevname(bdev, b),
37599 diff --git a/drivers/md/dm-thin-metadata.c b/drivers/md/dm-thin-metadata.c
37600 index 4d6e853..a234157 100644
37601 --- a/drivers/md/dm-thin-metadata.c
37602 +++ b/drivers/md/dm-thin-metadata.c
37603 @@ -397,7 +397,7 @@ static void __setup_btree_details(struct dm_pool_metadata *pmd)
37604 {
37605 pmd->info.tm = pmd->tm;
37606 pmd->info.levels = 2;
37607 - pmd->info.value_type.context = pmd->data_sm;
37608 + pmd->info.value_type.context = (dm_space_map_no_const *)pmd->data_sm;
37609 pmd->info.value_type.size = sizeof(__le64);
37610 pmd->info.value_type.inc = data_block_inc;
37611 pmd->info.value_type.dec = data_block_dec;
37612 @@ -416,7 +416,7 @@ static void __setup_btree_details(struct dm_pool_metadata *pmd)
37613
37614 pmd->bl_info.tm = pmd->tm;
37615 pmd->bl_info.levels = 1;
37616 - pmd->bl_info.value_type.context = pmd->data_sm;
37617 + pmd->bl_info.value_type.context = (dm_space_map_no_const *)pmd->data_sm;
37618 pmd->bl_info.value_type.size = sizeof(__le64);
37619 pmd->bl_info.value_type.inc = data_block_inc;
37620 pmd->bl_info.value_type.dec = data_block_dec;
37621 diff --git a/drivers/md/dm.c b/drivers/md/dm.c
37622 index 0d8f086..f5a91d5 100644
37623 --- a/drivers/md/dm.c
37624 +++ b/drivers/md/dm.c
37625 @@ -170,9 +170,9 @@ struct mapped_device {
37626 /*
37627 * Event handling.
37628 */
37629 - atomic_t event_nr;
37630 + atomic_unchecked_t event_nr;
37631 wait_queue_head_t eventq;
37632 - atomic_t uevent_seq;
37633 + atomic_unchecked_t uevent_seq;
37634 struct list_head uevent_list;
37635 spinlock_t uevent_lock; /* Protect access to uevent_list */
37636
37637 @@ -1872,8 +1872,8 @@ static struct mapped_device *alloc_dev(int minor)
37638 rwlock_init(&md->map_lock);
37639 atomic_set(&md->holders, 1);
37640 atomic_set(&md->open_count, 0);
37641 - atomic_set(&md->event_nr, 0);
37642 - atomic_set(&md->uevent_seq, 0);
37643 + atomic_set_unchecked(&md->event_nr, 0);
37644 + atomic_set_unchecked(&md->uevent_seq, 0);
37645 INIT_LIST_HEAD(&md->uevent_list);
37646 spin_lock_init(&md->uevent_lock);
37647
37648 @@ -2026,7 +2026,7 @@ static void event_callback(void *context)
37649
37650 dm_send_uevents(&uevents, &disk_to_dev(md->disk)->kobj);
37651
37652 - atomic_inc(&md->event_nr);
37653 + atomic_inc_unchecked(&md->event_nr);
37654 wake_up(&md->eventq);
37655 }
37656
37657 @@ -2683,18 +2683,18 @@ int dm_kobject_uevent(struct mapped_device *md, enum kobject_action action,
37658
37659 uint32_t dm_next_uevent_seq(struct mapped_device *md)
37660 {
37661 - return atomic_add_return(1, &md->uevent_seq);
37662 + return atomic_add_return_unchecked(1, &md->uevent_seq);
37663 }
37664
37665 uint32_t dm_get_event_nr(struct mapped_device *md)
37666 {
37667 - return atomic_read(&md->event_nr);
37668 + return atomic_read_unchecked(&md->event_nr);
37669 }
37670
37671 int dm_wait_event(struct mapped_device *md, int event_nr)
37672 {
37673 return wait_event_interruptible(md->eventq,
37674 - (event_nr != atomic_read(&md->event_nr)));
37675 + (event_nr != atomic_read_unchecked(&md->event_nr)));
37676 }
37677
37678 void dm_uevent_add(struct mapped_device *md, struct list_head *elist)
37679 diff --git a/drivers/md/md.c b/drivers/md/md.c
37680 index f363135..9b38815 100644
37681 --- a/drivers/md/md.c
37682 +++ b/drivers/md/md.c
37683 @@ -240,10 +240,10 @@ EXPORT_SYMBOL_GPL(md_trim_bio);
37684 * start build, activate spare
37685 */
37686 static DECLARE_WAIT_QUEUE_HEAD(md_event_waiters);
37687 -static atomic_t md_event_count;
37688 +static atomic_unchecked_t md_event_count;
37689 void md_new_event(struct mddev *mddev)
37690 {
37691 - atomic_inc(&md_event_count);
37692 + atomic_inc_unchecked(&md_event_count);
37693 wake_up(&md_event_waiters);
37694 }
37695 EXPORT_SYMBOL_GPL(md_new_event);
37696 @@ -253,7 +253,7 @@ EXPORT_SYMBOL_GPL(md_new_event);
37697 */
37698 static void md_new_event_inintr(struct mddev *mddev)
37699 {
37700 - atomic_inc(&md_event_count);
37701 + atomic_inc_unchecked(&md_event_count);
37702 wake_up(&md_event_waiters);
37703 }
37704
37705 @@ -1507,7 +1507,7 @@ static int super_1_load(struct md_rdev *rdev, struct md_rdev *refdev, int minor_
37706 if ((le32_to_cpu(sb->feature_map) & MD_FEATURE_RESHAPE_ACTIVE) &&
37707 (le32_to_cpu(sb->feature_map) & MD_FEATURE_NEW_OFFSET))
37708 rdev->new_data_offset += (s32)le32_to_cpu(sb->new_offset);
37709 - atomic_set(&rdev->corrected_errors, le32_to_cpu(sb->cnt_corrected_read));
37710 + atomic_set_unchecked(&rdev->corrected_errors, le32_to_cpu(sb->cnt_corrected_read));
37711
37712 rdev->sb_size = le32_to_cpu(sb->max_dev) * 2 + 256;
37713 bmask = queue_logical_block_size(rdev->bdev->bd_disk->queue)-1;
37714 @@ -1751,7 +1751,7 @@ static void super_1_sync(struct mddev *mddev, struct md_rdev *rdev)
37715 else
37716 sb->resync_offset = cpu_to_le64(0);
37717
37718 - sb->cnt_corrected_read = cpu_to_le32(atomic_read(&rdev->corrected_errors));
37719 + sb->cnt_corrected_read = cpu_to_le32(atomic_read_unchecked(&rdev->corrected_errors));
37720
37721 sb->raid_disks = cpu_to_le32(mddev->raid_disks);
37722 sb->size = cpu_to_le64(mddev->dev_sectors);
37723 @@ -2751,7 +2751,7 @@ __ATTR(state, S_IRUGO|S_IWUSR, state_show, state_store);
37724 static ssize_t
37725 errors_show(struct md_rdev *rdev, char *page)
37726 {
37727 - return sprintf(page, "%d\n", atomic_read(&rdev->corrected_errors));
37728 + return sprintf(page, "%d\n", atomic_read_unchecked(&rdev->corrected_errors));
37729 }
37730
37731 static ssize_t
37732 @@ -2760,7 +2760,7 @@ errors_store(struct md_rdev *rdev, const char *buf, size_t len)
37733 char *e;
37734 unsigned long n = simple_strtoul(buf, &e, 10);
37735 if (*buf && (*e == 0 || *e == '\n')) {
37736 - atomic_set(&rdev->corrected_errors, n);
37737 + atomic_set_unchecked(&rdev->corrected_errors, n);
37738 return len;
37739 }
37740 return -EINVAL;
37741 @@ -3210,8 +3210,8 @@ int md_rdev_init(struct md_rdev *rdev)
37742 rdev->sb_loaded = 0;
37743 rdev->bb_page = NULL;
37744 atomic_set(&rdev->nr_pending, 0);
37745 - atomic_set(&rdev->read_errors, 0);
37746 - atomic_set(&rdev->corrected_errors, 0);
37747 + atomic_set_unchecked(&rdev->read_errors, 0);
37748 + atomic_set_unchecked(&rdev->corrected_errors, 0);
37749
37750 INIT_LIST_HEAD(&rdev->same_set);
37751 init_waitqueue_head(&rdev->blocked_wait);
37752 @@ -6987,7 +6987,7 @@ static int md_seq_show(struct seq_file *seq, void *v)
37753
37754 spin_unlock(&pers_lock);
37755 seq_printf(seq, "\n");
37756 - seq->poll_event = atomic_read(&md_event_count);
37757 + seq->poll_event = atomic_read_unchecked(&md_event_count);
37758 return 0;
37759 }
37760 if (v == (void*)2) {
37761 @@ -7090,7 +7090,7 @@ static int md_seq_open(struct inode *inode, struct file *file)
37762 return error;
37763
37764 seq = file->private_data;
37765 - seq->poll_event = atomic_read(&md_event_count);
37766 + seq->poll_event = atomic_read_unchecked(&md_event_count);
37767 return error;
37768 }
37769
37770 @@ -7104,7 +7104,7 @@ static unsigned int mdstat_poll(struct file *filp, poll_table *wait)
37771 /* always allow read */
37772 mask = POLLIN | POLLRDNORM;
37773
37774 - if (seq->poll_event != atomic_read(&md_event_count))
37775 + if (seq->poll_event != atomic_read_unchecked(&md_event_count))
37776 mask |= POLLERR | POLLPRI;
37777 return mask;
37778 }
37779 @@ -7148,7 +7148,7 @@ static int is_mddev_idle(struct mddev *mddev, int init)
37780 struct gendisk *disk = rdev->bdev->bd_contains->bd_disk;
37781 curr_events = (int)part_stat_read(&disk->part0, sectors[0]) +
37782 (int)part_stat_read(&disk->part0, sectors[1]) -
37783 - atomic_read(&disk->sync_io);
37784 + atomic_read_unchecked(&disk->sync_io);
37785 /* sync IO will cause sync_io to increase before the disk_stats
37786 * as sync_io is counted when a request starts, and
37787 * disk_stats is counted when it completes.
37788 diff --git a/drivers/md/md.h b/drivers/md/md.h
37789 index eca59c3..7c42285 100644
37790 --- a/drivers/md/md.h
37791 +++ b/drivers/md/md.h
37792 @@ -94,13 +94,13 @@ struct md_rdev {
37793 * only maintained for arrays that
37794 * support hot removal
37795 */
37796 - atomic_t read_errors; /* number of consecutive read errors that
37797 + atomic_unchecked_t read_errors; /* number of consecutive read errors that
37798 * we have tried to ignore.
37799 */
37800 struct timespec last_read_error; /* monotonic time since our
37801 * last read error
37802 */
37803 - atomic_t corrected_errors; /* number of corrected read errors,
37804 + atomic_unchecked_t corrected_errors; /* number of corrected read errors,
37805 * for reporting to userspace and storing
37806 * in superblock.
37807 */
37808 @@ -434,7 +434,7 @@ static inline void rdev_dec_pending(struct md_rdev *rdev, struct mddev *mddev)
37809
37810 static inline void md_sync_acct(struct block_device *bdev, unsigned long nr_sectors)
37811 {
37812 - atomic_add(nr_sectors, &bdev->bd_contains->bd_disk->sync_io);
37813 + atomic_add_unchecked(nr_sectors, &bdev->bd_contains->bd_disk->sync_io);
37814 }
37815
37816 struct md_personality
37817 diff --git a/drivers/md/persistent-data/dm-space-map.h b/drivers/md/persistent-data/dm-space-map.h
37818 index 1cbfc6b..56e1dbb 100644
37819 --- a/drivers/md/persistent-data/dm-space-map.h
37820 +++ b/drivers/md/persistent-data/dm-space-map.h
37821 @@ -60,6 +60,7 @@ struct dm_space_map {
37822 int (*root_size)(struct dm_space_map *sm, size_t *result);
37823 int (*copy_root)(struct dm_space_map *sm, void *copy_to_here_le, size_t len);
37824 };
37825 +typedef struct dm_space_map __no_const dm_space_map_no_const;
37826
37827 /*----------------------------------------------------------------*/
37828
37829 diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
37830 index 75b1f89..00ba344 100644
37831 --- a/drivers/md/raid1.c
37832 +++ b/drivers/md/raid1.c
37833 @@ -1819,7 +1819,7 @@ static int fix_sync_read_error(struct r1bio *r1_bio)
37834 if (r1_sync_page_io(rdev, sect, s,
37835 bio->bi_io_vec[idx].bv_page,
37836 READ) != 0)
37837 - atomic_add(s, &rdev->corrected_errors);
37838 + atomic_add_unchecked(s, &rdev->corrected_errors);
37839 }
37840 sectors -= s;
37841 sect += s;
37842 @@ -2041,7 +2041,7 @@ static void fix_read_error(struct r1conf *conf, int read_disk,
37843 test_bit(In_sync, &rdev->flags)) {
37844 if (r1_sync_page_io(rdev, sect, s,
37845 conf->tmppage, READ)) {
37846 - atomic_add(s, &rdev->corrected_errors);
37847 + atomic_add_unchecked(s, &rdev->corrected_errors);
37848 printk(KERN_INFO
37849 "md/raid1:%s: read error corrected "
37850 "(%d sectors at %llu on %s)\n",
37851 diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
37852 index 8d925dc..11d674f 100644
37853 --- a/drivers/md/raid10.c
37854 +++ b/drivers/md/raid10.c
37855 @@ -1878,7 +1878,7 @@ static void end_sync_read(struct bio *bio, int error)
37856 /* The write handler will notice the lack of
37857 * R10BIO_Uptodate and record any errors etc
37858 */
37859 - atomic_add(r10_bio->sectors,
37860 + atomic_add_unchecked(r10_bio->sectors,
37861 &conf->mirrors[d].rdev->corrected_errors);
37862
37863 /* for reconstruct, we always reschedule after a read.
37864 @@ -2227,7 +2227,7 @@ static void check_decay_read_errors(struct mddev *mddev, struct md_rdev *rdev)
37865 {
37866 struct timespec cur_time_mon;
37867 unsigned long hours_since_last;
37868 - unsigned int read_errors = atomic_read(&rdev->read_errors);
37869 + unsigned int read_errors = atomic_read_unchecked(&rdev->read_errors);
37870
37871 ktime_get_ts(&cur_time_mon);
37872
37873 @@ -2249,9 +2249,9 @@ static void check_decay_read_errors(struct mddev *mddev, struct md_rdev *rdev)
37874 * overflowing the shift of read_errors by hours_since_last.
37875 */
37876 if (hours_since_last >= 8 * sizeof(read_errors))
37877 - atomic_set(&rdev->read_errors, 0);
37878 + atomic_set_unchecked(&rdev->read_errors, 0);
37879 else
37880 - atomic_set(&rdev->read_errors, read_errors >> hours_since_last);
37881 + atomic_set_unchecked(&rdev->read_errors, read_errors >> hours_since_last);
37882 }
37883
37884 static int r10_sync_page_io(struct md_rdev *rdev, sector_t sector,
37885 @@ -2305,8 +2305,8 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
37886 return;
37887
37888 check_decay_read_errors(mddev, rdev);
37889 - atomic_inc(&rdev->read_errors);
37890 - if (atomic_read(&rdev->read_errors) > max_read_errors) {
37891 + atomic_inc_unchecked(&rdev->read_errors);
37892 + if (atomic_read_unchecked(&rdev->read_errors) > max_read_errors) {
37893 char b[BDEVNAME_SIZE];
37894 bdevname(rdev->bdev, b);
37895
37896 @@ -2314,7 +2314,7 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
37897 "md/raid10:%s: %s: Raid device exceeded "
37898 "read_error threshold [cur %d:max %d]\n",
37899 mdname(mddev), b,
37900 - atomic_read(&rdev->read_errors), max_read_errors);
37901 + atomic_read_unchecked(&rdev->read_errors), max_read_errors);
37902 printk(KERN_NOTICE
37903 "md/raid10:%s: %s: Failing raid device\n",
37904 mdname(mddev), b);
37905 @@ -2469,7 +2469,7 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
37906 sect +
37907 choose_data_offset(r10_bio, rdev)),
37908 bdevname(rdev->bdev, b));
37909 - atomic_add(s, &rdev->corrected_errors);
37910 + atomic_add_unchecked(s, &rdev->corrected_errors);
37911 }
37912
37913 rdev_dec_pending(rdev, mddev);
37914 diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
37915 index 19d77a0..56051b92 100644
37916 --- a/drivers/md/raid5.c
37917 +++ b/drivers/md/raid5.c
37918 @@ -1797,21 +1797,21 @@ static void raid5_end_read_request(struct bio * bi, int error)
37919 mdname(conf->mddev), STRIPE_SECTORS,
37920 (unsigned long long)s,
37921 bdevname(rdev->bdev, b));
37922 - atomic_add(STRIPE_SECTORS, &rdev->corrected_errors);
37923 + atomic_add_unchecked(STRIPE_SECTORS, &rdev->corrected_errors);
37924 clear_bit(R5_ReadError, &sh->dev[i].flags);
37925 clear_bit(R5_ReWrite, &sh->dev[i].flags);
37926 } else if (test_bit(R5_ReadNoMerge, &sh->dev[i].flags))
37927 clear_bit(R5_ReadNoMerge, &sh->dev[i].flags);
37928
37929 - if (atomic_read(&rdev->read_errors))
37930 - atomic_set(&rdev->read_errors, 0);
37931 + if (atomic_read_unchecked(&rdev->read_errors))
37932 + atomic_set_unchecked(&rdev->read_errors, 0);
37933 } else {
37934 const char *bdn = bdevname(rdev->bdev, b);
37935 int retry = 0;
37936 int set_bad = 0;
37937
37938 clear_bit(R5_UPTODATE, &sh->dev[i].flags);
37939 - atomic_inc(&rdev->read_errors);
37940 + atomic_inc_unchecked(&rdev->read_errors);
37941 if (test_bit(R5_ReadRepl, &sh->dev[i].flags))
37942 printk_ratelimited(
37943 KERN_WARNING
37944 @@ -1839,7 +1839,7 @@ static void raid5_end_read_request(struct bio * bi, int error)
37945 mdname(conf->mddev),
37946 (unsigned long long)s,
37947 bdn);
37948 - } else if (atomic_read(&rdev->read_errors)
37949 + } else if (atomic_read_unchecked(&rdev->read_errors)
37950 > conf->max_nr_stripes)
37951 printk(KERN_WARNING
37952 "md/raid:%s: Too many read errors, failing device %s.\n",
37953 diff --git a/drivers/media/dvb-core/dvbdev.c b/drivers/media/dvb-core/dvbdev.c
37954 index d33101a..6b13069 100644
37955 --- a/drivers/media/dvb-core/dvbdev.c
37956 +++ b/drivers/media/dvb-core/dvbdev.c
37957 @@ -192,7 +192,7 @@ int dvb_register_device(struct dvb_adapter *adap, struct dvb_device **pdvbdev,
37958 const struct dvb_device *template, void *priv, int type)
37959 {
37960 struct dvb_device *dvbdev;
37961 - struct file_operations *dvbdevfops;
37962 + file_operations_no_const *dvbdevfops;
37963 struct device *clsdev;
37964 int minor;
37965 int id;
37966 diff --git a/drivers/media/dvb-frontends/dib3000.h b/drivers/media/dvb-frontends/dib3000.h
37967 index 404f63a..4796533 100644
37968 --- a/drivers/media/dvb-frontends/dib3000.h
37969 +++ b/drivers/media/dvb-frontends/dib3000.h
37970 @@ -39,7 +39,7 @@ struct dib_fe_xfer_ops
37971 int (*fifo_ctrl)(struct dvb_frontend *fe, int onoff);
37972 int (*pid_ctrl)(struct dvb_frontend *fe, int index, int pid, int onoff);
37973 int (*tuner_pass_ctrl)(struct dvb_frontend *fe, int onoff, u8 pll_ctrl);
37974 -};
37975 +} __no_const;
37976
37977 #if defined(CONFIG_DVB_DIB3000MB) || (defined(CONFIG_DVB_DIB3000MB_MODULE) && defined(MODULE))
37978 extern struct dvb_frontend* dib3000mb_attach(const struct dib3000_config* config,
37979 diff --git a/drivers/media/platform/omap/omap_vout.c b/drivers/media/platform/omap/omap_vout.c
37980 index 8e9a668..78d6310 100644
37981 --- a/drivers/media/platform/omap/omap_vout.c
37982 +++ b/drivers/media/platform/omap/omap_vout.c
37983 @@ -63,7 +63,6 @@ enum omap_vout_channels {
37984 OMAP_VIDEO2,
37985 };
37986
37987 -static struct videobuf_queue_ops video_vbq_ops;
37988 /* Variables configurable through module params*/
37989 static u32 video1_numbuffers = 3;
37990 static u32 video2_numbuffers = 3;
37991 @@ -1012,6 +1011,12 @@ static int omap_vout_open(struct file *file)
37992 {
37993 struct videobuf_queue *q;
37994 struct omap_vout_device *vout = NULL;
37995 + static struct videobuf_queue_ops video_vbq_ops = {
37996 + .buf_setup = omap_vout_buffer_setup,
37997 + .buf_prepare = omap_vout_buffer_prepare,
37998 + .buf_release = omap_vout_buffer_release,
37999 + .buf_queue = omap_vout_buffer_queue,
38000 + };
38001
38002 vout = video_drvdata(file);
38003 v4l2_dbg(1, debug, &vout->vid_dev->v4l2_dev, "Entering %s\n", __func__);
38004 @@ -1029,10 +1034,6 @@ static int omap_vout_open(struct file *file)
38005 vout->type = V4L2_BUF_TYPE_VIDEO_OUTPUT;
38006
38007 q = &vout->vbq;
38008 - video_vbq_ops.buf_setup = omap_vout_buffer_setup;
38009 - video_vbq_ops.buf_prepare = omap_vout_buffer_prepare;
38010 - video_vbq_ops.buf_release = omap_vout_buffer_release;
38011 - video_vbq_ops.buf_queue = omap_vout_buffer_queue;
38012 spin_lock_init(&vout->vbq_lock);
38013
38014 videobuf_queue_dma_contig_init(q, &video_vbq_ops, q->dev,
38015 diff --git a/drivers/media/platform/s5p-tv/mixer.h b/drivers/media/platform/s5p-tv/mixer.h
38016 index b671e20..34088b7 100644
38017 --- a/drivers/media/platform/s5p-tv/mixer.h
38018 +++ b/drivers/media/platform/s5p-tv/mixer.h
38019 @@ -155,7 +155,7 @@ struct mxr_layer {
38020 /** layer index (unique identifier) */
38021 int idx;
38022 /** callbacks for layer methods */
38023 - struct mxr_layer_ops ops;
38024 + struct mxr_layer_ops *ops;
38025 /** format array */
38026 const struct mxr_format **fmt_array;
38027 /** size of format array */
38028 diff --git a/drivers/media/platform/s5p-tv/mixer_grp_layer.c b/drivers/media/platform/s5p-tv/mixer_grp_layer.c
38029 index b93a21f..2535195 100644
38030 --- a/drivers/media/platform/s5p-tv/mixer_grp_layer.c
38031 +++ b/drivers/media/platform/s5p-tv/mixer_grp_layer.c
38032 @@ -235,7 +235,7 @@ struct mxr_layer *mxr_graph_layer_create(struct mxr_device *mdev, int idx)
38033 {
38034 struct mxr_layer *layer;
38035 int ret;
38036 - struct mxr_layer_ops ops = {
38037 + static struct mxr_layer_ops ops = {
38038 .release = mxr_graph_layer_release,
38039 .buffer_set = mxr_graph_buffer_set,
38040 .stream_set = mxr_graph_stream_set,
38041 diff --git a/drivers/media/platform/s5p-tv/mixer_reg.c b/drivers/media/platform/s5p-tv/mixer_reg.c
38042 index 3b1670a..595c939 100644
38043 --- a/drivers/media/platform/s5p-tv/mixer_reg.c
38044 +++ b/drivers/media/platform/s5p-tv/mixer_reg.c
38045 @@ -276,7 +276,7 @@ static void mxr_irq_layer_handle(struct mxr_layer *layer)
38046 layer->update_buf = next;
38047 }
38048
38049 - layer->ops.buffer_set(layer, layer->update_buf);
38050 + layer->ops->buffer_set(layer, layer->update_buf);
38051
38052 if (done && done != layer->shadow_buf)
38053 vb2_buffer_done(&done->vb, VB2_BUF_STATE_DONE);
38054 diff --git a/drivers/media/platform/s5p-tv/mixer_video.c b/drivers/media/platform/s5p-tv/mixer_video.c
38055 index 1f3b743..e839271 100644
38056 --- a/drivers/media/platform/s5p-tv/mixer_video.c
38057 +++ b/drivers/media/platform/s5p-tv/mixer_video.c
38058 @@ -208,7 +208,7 @@ static void mxr_layer_default_geo(struct mxr_layer *layer)
38059 layer->geo.src.height = layer->geo.src.full_height;
38060
38061 mxr_geometry_dump(mdev, &layer->geo);
38062 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
38063 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
38064 mxr_geometry_dump(mdev, &layer->geo);
38065 }
38066
38067 @@ -226,7 +226,7 @@ static void mxr_layer_update_output(struct mxr_layer *layer)
38068 layer->geo.dst.full_width = mbus_fmt.width;
38069 layer->geo.dst.full_height = mbus_fmt.height;
38070 layer->geo.dst.field = mbus_fmt.field;
38071 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
38072 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
38073
38074 mxr_geometry_dump(mdev, &layer->geo);
38075 }
38076 @@ -332,7 +332,7 @@ static int mxr_s_fmt(struct file *file, void *priv,
38077 /* set source size to highest accepted value */
38078 geo->src.full_width = max(geo->dst.full_width, pix->width);
38079 geo->src.full_height = max(geo->dst.full_height, pix->height);
38080 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
38081 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
38082 mxr_geometry_dump(mdev, &layer->geo);
38083 /* set cropping to total visible screen */
38084 geo->src.width = pix->width;
38085 @@ -340,12 +340,12 @@ static int mxr_s_fmt(struct file *file, void *priv,
38086 geo->src.x_offset = 0;
38087 geo->src.y_offset = 0;
38088 /* assure consistency of geometry */
38089 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_CROP, MXR_NO_OFFSET);
38090 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_CROP, MXR_NO_OFFSET);
38091 mxr_geometry_dump(mdev, &layer->geo);
38092 /* set full size to lowest possible value */
38093 geo->src.full_width = 0;
38094 geo->src.full_height = 0;
38095 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
38096 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
38097 mxr_geometry_dump(mdev, &layer->geo);
38098
38099 /* returning results */
38100 @@ -472,7 +472,7 @@ static int mxr_s_selection(struct file *file, void *fh,
38101 target->width = s->r.width;
38102 target->height = s->r.height;
38103
38104 - layer->ops.fix_geometry(layer, stage, s->flags);
38105 + layer->ops->fix_geometry(layer, stage, s->flags);
38106
38107 /* retrieve update selection rectangle */
38108 res.left = target->x_offset;
38109 @@ -937,13 +937,13 @@ static int start_streaming(struct vb2_queue *vq, unsigned int count)
38110 mxr_output_get(mdev);
38111
38112 mxr_layer_update_output(layer);
38113 - layer->ops.format_set(layer);
38114 + layer->ops->format_set(layer);
38115 /* enabling layer in hardware */
38116 spin_lock_irqsave(&layer->enq_slock, flags);
38117 layer->state = MXR_LAYER_STREAMING;
38118 spin_unlock_irqrestore(&layer->enq_slock, flags);
38119
38120 - layer->ops.stream_set(layer, MXR_ENABLE);
38121 + layer->ops->stream_set(layer, MXR_ENABLE);
38122 mxr_streamer_get(mdev);
38123
38124 return 0;
38125 @@ -1013,7 +1013,7 @@ static int stop_streaming(struct vb2_queue *vq)
38126 spin_unlock_irqrestore(&layer->enq_slock, flags);
38127
38128 /* disabling layer in hardware */
38129 - layer->ops.stream_set(layer, MXR_DISABLE);
38130 + layer->ops->stream_set(layer, MXR_DISABLE);
38131 /* remove one streamer */
38132 mxr_streamer_put(mdev);
38133 /* allow changes in output configuration */
38134 @@ -1052,8 +1052,8 @@ void mxr_base_layer_unregister(struct mxr_layer *layer)
38135
38136 void mxr_layer_release(struct mxr_layer *layer)
38137 {
38138 - if (layer->ops.release)
38139 - layer->ops.release(layer);
38140 + if (layer->ops->release)
38141 + layer->ops->release(layer);
38142 }
38143
38144 void mxr_base_layer_release(struct mxr_layer *layer)
38145 @@ -1079,7 +1079,7 @@ struct mxr_layer *mxr_base_layer_create(struct mxr_device *mdev,
38146
38147 layer->mdev = mdev;
38148 layer->idx = idx;
38149 - layer->ops = *ops;
38150 + layer->ops = ops;
38151
38152 spin_lock_init(&layer->enq_slock);
38153 INIT_LIST_HEAD(&layer->enq_list);
38154 diff --git a/drivers/media/platform/s5p-tv/mixer_vp_layer.c b/drivers/media/platform/s5p-tv/mixer_vp_layer.c
38155 index 3d13a63..da31bf1 100644
38156 --- a/drivers/media/platform/s5p-tv/mixer_vp_layer.c
38157 +++ b/drivers/media/platform/s5p-tv/mixer_vp_layer.c
38158 @@ -206,7 +206,7 @@ struct mxr_layer *mxr_vp_layer_create(struct mxr_device *mdev, int idx)
38159 {
38160 struct mxr_layer *layer;
38161 int ret;
38162 - struct mxr_layer_ops ops = {
38163 + static struct mxr_layer_ops ops = {
38164 .release = mxr_vp_layer_release,
38165 .buffer_set = mxr_vp_buffer_set,
38166 .stream_set = mxr_vp_stream_set,
38167 diff --git a/drivers/media/radio/radio-cadet.c b/drivers/media/radio/radio-cadet.c
38168 index 643d80a..56bb96b 100644
38169 --- a/drivers/media/radio/radio-cadet.c
38170 +++ b/drivers/media/radio/radio-cadet.c
38171 @@ -302,6 +302,8 @@ static ssize_t cadet_read(struct file *file, char __user *data, size_t count, lo
38172 unsigned char readbuf[RDS_BUFFER];
38173 int i = 0;
38174
38175 + if (count > RDS_BUFFER)
38176 + return -EFAULT;
38177 mutex_lock(&dev->lock);
38178 if (dev->rdsstat == 0)
38179 cadet_start_rds(dev);
38180 @@ -317,7 +319,7 @@ static ssize_t cadet_read(struct file *file, char __user *data, size_t count, lo
38181 while (i < count && dev->rdsin != dev->rdsout)
38182 readbuf[i++] = dev->rdsbuf[dev->rdsout++];
38183
38184 - if (i && copy_to_user(data, readbuf, i))
38185 + if (i > sizeof(readbuf) || copy_to_user(data, readbuf, i))
38186 i = -EFAULT;
38187 unlock:
38188 mutex_unlock(&dev->lock);
38189 diff --git a/drivers/media/usb/dvb-usb/cxusb.c b/drivers/media/usb/dvb-usb/cxusb.c
38190 index 3940bb0..fb3952a 100644
38191 --- a/drivers/media/usb/dvb-usb/cxusb.c
38192 +++ b/drivers/media/usb/dvb-usb/cxusb.c
38193 @@ -1068,7 +1068,7 @@ static struct dib0070_config dib7070p_dib0070_config = {
38194
38195 struct dib0700_adapter_state {
38196 int (*set_param_save) (struct dvb_frontend *);
38197 -};
38198 +} __no_const;
38199
38200 static int dib7070_set_param_override(struct dvb_frontend *fe)
38201 {
38202 diff --git a/drivers/media/usb/dvb-usb/dw2102.c b/drivers/media/usb/dvb-usb/dw2102.c
38203 index 9382895..ac8093c 100644
38204 --- a/drivers/media/usb/dvb-usb/dw2102.c
38205 +++ b/drivers/media/usb/dvb-usb/dw2102.c
38206 @@ -95,7 +95,7 @@ struct su3000_state {
38207
38208 struct s6x0_state {
38209 int (*old_set_voltage)(struct dvb_frontend *f, fe_sec_voltage_t v);
38210 -};
38211 +} __no_const;
38212
38213 /* debug */
38214 static int dvb_usb_dw2102_debug;
38215 diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c
38216 index aa6e7c7..4cd8061 100644
38217 --- a/drivers/media/v4l2-core/v4l2-ioctl.c
38218 +++ b/drivers/media/v4l2-core/v4l2-ioctl.c
38219 @@ -1923,7 +1923,8 @@ struct v4l2_ioctl_info {
38220 struct file *file, void *fh, void *p);
38221 } u;
38222 void (*debug)(const void *arg, bool write_only);
38223 -};
38224 +} __do_const;
38225 +typedef struct v4l2_ioctl_info __no_const v4l2_ioctl_info_no_const;
38226
38227 /* This control needs a priority check */
38228 #define INFO_FL_PRIO (1 << 0)
38229 @@ -2108,7 +2109,7 @@ static long __video_do_ioctl(struct file *file,
38230 struct video_device *vfd = video_devdata(file);
38231 const struct v4l2_ioctl_ops *ops = vfd->ioctl_ops;
38232 bool write_only = false;
38233 - struct v4l2_ioctl_info default_info;
38234 + v4l2_ioctl_info_no_const default_info;
38235 const struct v4l2_ioctl_info *info;
38236 void *fh = file->private_data;
38237 struct v4l2_fh *vfh = NULL;
38238 diff --git a/drivers/memstick/host/r592.c b/drivers/memstick/host/r592.c
38239 index 29b2172..a7c5b31 100644
38240 --- a/drivers/memstick/host/r592.c
38241 +++ b/drivers/memstick/host/r592.c
38242 @@ -454,7 +454,7 @@ static int r592_transfer_fifo_pio(struct r592_device *dev)
38243 /* Executes one TPC (data is read/written from small or large fifo) */
38244 static void r592_execute_tpc(struct r592_device *dev)
38245 {
38246 - bool is_write = dev->req->tpc >= MS_TPC_SET_RW_REG_ADRS;
38247 + bool is_write;
38248 int len, error;
38249 u32 status, reg;
38250
38251 @@ -463,6 +463,7 @@ static void r592_execute_tpc(struct r592_device *dev)
38252 return;
38253 }
38254
38255 + is_write = dev->req->tpc >= MS_TPC_SET_RW_REG_ADRS;
38256 len = dev->req->long_data ?
38257 dev->req->sg.length : dev->req->data_len;
38258
38259 diff --git a/drivers/message/fusion/mptbase.c b/drivers/message/fusion/mptbase.c
38260 index fb69baa..3aeea2e 100644
38261 --- a/drivers/message/fusion/mptbase.c
38262 +++ b/drivers/message/fusion/mptbase.c
38263 @@ -6755,8 +6755,13 @@ static int mpt_iocinfo_proc_show(struct seq_file *m, void *v)
38264 seq_printf(m, " MaxChainDepth = 0x%02x frames\n", ioc->facts.MaxChainDepth);
38265 seq_printf(m, " MinBlockSize = 0x%02x bytes\n", 4*ioc->facts.BlockSize);
38266
38267 +#ifdef CONFIG_GRKERNSEC_HIDESYM
38268 + seq_printf(m, " RequestFrames @ 0x%p (Dma @ 0x%p)\n", NULL, NULL);
38269 +#else
38270 seq_printf(m, " RequestFrames @ 0x%p (Dma @ 0x%p)\n",
38271 (void *)ioc->req_frames, (void *)(ulong)ioc->req_frames_dma);
38272 +#endif
38273 +
38274 /*
38275 * Rounding UP to nearest 4-kB boundary here...
38276 */
38277 @@ -6769,7 +6774,11 @@ static int mpt_iocinfo_proc_show(struct seq_file *m, void *v)
38278 ioc->facts.GlobalCredits);
38279
38280 seq_printf(m, " Frames @ 0x%p (Dma @ 0x%p)\n",
38281 +#ifdef CONFIG_GRKERNSEC_HIDESYM
38282 + NULL, NULL);
38283 +#else
38284 (void *)ioc->alloc, (void *)(ulong)ioc->alloc_dma);
38285 +#endif
38286 sz = (ioc->reply_sz * ioc->reply_depth) + 128;
38287 seq_printf(m, " {CurRepSz=%d} x {CurRepDepth=%d} = %d bytes ^= 0x%x\n",
38288 ioc->reply_sz, ioc->reply_depth, ioc->reply_sz*ioc->reply_depth, sz);
38289 diff --git a/drivers/message/fusion/mptsas.c b/drivers/message/fusion/mptsas.c
38290 index fa43c39..daeb158 100644
38291 --- a/drivers/message/fusion/mptsas.c
38292 +++ b/drivers/message/fusion/mptsas.c
38293 @@ -446,6 +446,23 @@ mptsas_is_end_device(struct mptsas_devinfo * attached)
38294 return 0;
38295 }
38296
38297 +static inline void
38298 +mptsas_set_rphy(MPT_ADAPTER *ioc, struct mptsas_phyinfo *phy_info, struct sas_rphy *rphy)
38299 +{
38300 + if (phy_info->port_details) {
38301 + phy_info->port_details->rphy = rphy;
38302 + dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "sas_rphy_add: rphy=%p\n",
38303 + ioc->name, rphy));
38304 + }
38305 +
38306 + if (rphy) {
38307 + dsaswideprintk(ioc, dev_printk(KERN_DEBUG,
38308 + &rphy->dev, MYIOC_s_FMT "add:", ioc->name));
38309 + dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "rphy=%p release=%p\n",
38310 + ioc->name, rphy, rphy->dev.release));
38311 + }
38312 +}
38313 +
38314 /* no mutex */
38315 static void
38316 mptsas_port_delete(MPT_ADAPTER *ioc, struct mptsas_portinfo_details * port_details)
38317 @@ -484,23 +501,6 @@ mptsas_get_rphy(struct mptsas_phyinfo *phy_info)
38318 return NULL;
38319 }
38320
38321 -static inline void
38322 -mptsas_set_rphy(MPT_ADAPTER *ioc, struct mptsas_phyinfo *phy_info, struct sas_rphy *rphy)
38323 -{
38324 - if (phy_info->port_details) {
38325 - phy_info->port_details->rphy = rphy;
38326 - dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "sas_rphy_add: rphy=%p\n",
38327 - ioc->name, rphy));
38328 - }
38329 -
38330 - if (rphy) {
38331 - dsaswideprintk(ioc, dev_printk(KERN_DEBUG,
38332 - &rphy->dev, MYIOC_s_FMT "add:", ioc->name));
38333 - dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "rphy=%p release=%p\n",
38334 - ioc->name, rphy, rphy->dev.release));
38335 - }
38336 -}
38337 -
38338 static inline struct sas_port *
38339 mptsas_get_port(struct mptsas_phyinfo *phy_info)
38340 {
38341 diff --git a/drivers/message/fusion/mptscsih.c b/drivers/message/fusion/mptscsih.c
38342 index 164afa7..b6b2e74 100644
38343 --- a/drivers/message/fusion/mptscsih.c
38344 +++ b/drivers/message/fusion/mptscsih.c
38345 @@ -1271,15 +1271,16 @@ mptscsih_info(struct Scsi_Host *SChost)
38346
38347 h = shost_priv(SChost);
38348
38349 - if (h) {
38350 - if (h->info_kbuf == NULL)
38351 - if ((h->info_kbuf = kmalloc(0x1000 /* 4Kb */, GFP_KERNEL)) == NULL)
38352 - return h->info_kbuf;
38353 - h->info_kbuf[0] = '\0';
38354 + if (!h)
38355 + return NULL;
38356
38357 - mpt_print_ioc_summary(h->ioc, h->info_kbuf, &size, 0, 0);
38358 - h->info_kbuf[size-1] = '\0';
38359 - }
38360 + if (h->info_kbuf == NULL)
38361 + if ((h->info_kbuf = kmalloc(0x1000 /* 4Kb */, GFP_KERNEL)) == NULL)
38362 + return h->info_kbuf;
38363 + h->info_kbuf[0] = '\0';
38364 +
38365 + mpt_print_ioc_summary(h->ioc, h->info_kbuf, &size, 0, 0);
38366 + h->info_kbuf[size-1] = '\0';
38367
38368 return h->info_kbuf;
38369 }
38370 diff --git a/drivers/message/i2o/i2o_proc.c b/drivers/message/i2o/i2o_proc.c
38371 index 8001aa6..b137580 100644
38372 --- a/drivers/message/i2o/i2o_proc.c
38373 +++ b/drivers/message/i2o/i2o_proc.c
38374 @@ -255,12 +255,6 @@ static char *scsi_devices[] = {
38375 "Array Controller Device"
38376 };
38377
38378 -static char *chtostr(char *tmp, u8 *chars, int n)
38379 -{
38380 - tmp[0] = 0;
38381 - return strncat(tmp, (char *)chars, n);
38382 -}
38383 -
38384 static int i2o_report_query_status(struct seq_file *seq, int block_status,
38385 char *group)
38386 {
38387 @@ -790,7 +784,6 @@ static int i2o_seq_show_ddm_table(struct seq_file *seq, void *v)
38388 } *result;
38389
38390 i2o_exec_execute_ddm_table ddm_table;
38391 - char tmp[28 + 1];
38392
38393 result = kmalloc(sizeof(*result), GFP_KERNEL);
38394 if (!result)
38395 @@ -825,8 +818,7 @@ static int i2o_seq_show_ddm_table(struct seq_file *seq, void *v)
38396
38397 seq_printf(seq, "%-#7x", ddm_table.i2o_vendor_id);
38398 seq_printf(seq, "%-#8x", ddm_table.module_id);
38399 - seq_printf(seq, "%-29s",
38400 - chtostr(tmp, ddm_table.module_name_version, 28));
38401 + seq_printf(seq, "%-.28s", ddm_table.module_name_version);
38402 seq_printf(seq, "%9d ", ddm_table.data_size);
38403 seq_printf(seq, "%8d", ddm_table.code_size);
38404
38405 @@ -893,7 +885,6 @@ static int i2o_seq_show_drivers_stored(struct seq_file *seq, void *v)
38406
38407 i2o_driver_result_table *result;
38408 i2o_driver_store_table *dst;
38409 - char tmp[28 + 1];
38410
38411 result = kmalloc(sizeof(i2o_driver_result_table), GFP_KERNEL);
38412 if (result == NULL)
38413 @@ -928,9 +919,8 @@ static int i2o_seq_show_drivers_stored(struct seq_file *seq, void *v)
38414
38415 seq_printf(seq, "%-#7x", dst->i2o_vendor_id);
38416 seq_printf(seq, "%-#8x", dst->module_id);
38417 - seq_printf(seq, "%-29s",
38418 - chtostr(tmp, dst->module_name_version, 28));
38419 - seq_printf(seq, "%-9s", chtostr(tmp, dst->date, 8));
38420 + seq_printf(seq, "%-.28s", dst->module_name_version);
38421 + seq_printf(seq, "%-.8s", dst->date);
38422 seq_printf(seq, "%8d ", dst->module_size);
38423 seq_printf(seq, "%8d ", dst->mpb_size);
38424 seq_printf(seq, "0x%04x", dst->module_flags);
38425 @@ -1250,7 +1240,6 @@ static int i2o_seq_show_dev_identity(struct seq_file *seq, void *v)
38426 // == (allow) 512d bytes (max)
38427 static u16 *work16 = (u16 *) work32;
38428 int token;
38429 - char tmp[16 + 1];
38430
38431 token = i2o_parm_field_get(d, 0xF100, -1, &work32, sizeof(work32));
38432
38433 @@ -1262,14 +1251,10 @@ static int i2o_seq_show_dev_identity(struct seq_file *seq, void *v)
38434 seq_printf(seq, "Device Class : %s\n", i2o_get_class_name(work16[0]));
38435 seq_printf(seq, "Owner TID : %0#5x\n", work16[2]);
38436 seq_printf(seq, "Parent TID : %0#5x\n", work16[3]);
38437 - seq_printf(seq, "Vendor info : %s\n",
38438 - chtostr(tmp, (u8 *) (work32 + 2), 16));
38439 - seq_printf(seq, "Product info : %s\n",
38440 - chtostr(tmp, (u8 *) (work32 + 6), 16));
38441 - seq_printf(seq, "Description : %s\n",
38442 - chtostr(tmp, (u8 *) (work32 + 10), 16));
38443 - seq_printf(seq, "Product rev. : %s\n",
38444 - chtostr(tmp, (u8 *) (work32 + 14), 8));
38445 + seq_printf(seq, "Vendor info : %.16s\n", (u8 *) (work32 + 2));
38446 + seq_printf(seq, "Product info : %.16s\n", (u8 *) (work32 + 6));
38447 + seq_printf(seq, "Description : %.16s\n", (u8 *) (work32 + 10));
38448 + seq_printf(seq, "Product rev. : %.8s\n", (u8 *) (work32 + 14));
38449
38450 seq_printf(seq, "Serial number : ");
38451 print_serial_number(seq, (u8 *) (work32 + 16),
38452 @@ -1306,8 +1291,6 @@ static int i2o_seq_show_ddm_identity(struct seq_file *seq, void *v)
38453 u8 pad[256]; // allow up to 256 byte (max) serial number
38454 } result;
38455
38456 - char tmp[24 + 1];
38457 -
38458 token = i2o_parm_field_get(d, 0xF101, -1, &result, sizeof(result));
38459
38460 if (token < 0) {
38461 @@ -1316,10 +1299,8 @@ static int i2o_seq_show_ddm_identity(struct seq_file *seq, void *v)
38462 }
38463
38464 seq_printf(seq, "Registering DDM TID : 0x%03x\n", result.ddm_tid);
38465 - seq_printf(seq, "Module name : %s\n",
38466 - chtostr(tmp, result.module_name, 24));
38467 - seq_printf(seq, "Module revision : %s\n",
38468 - chtostr(tmp, result.module_rev, 8));
38469 + seq_printf(seq, "Module name : %.24s\n", result.module_name);
38470 + seq_printf(seq, "Module revision : %.8s\n", result.module_rev);
38471
38472 seq_printf(seq, "Serial number : ");
38473 print_serial_number(seq, result.serial_number, sizeof(result) - 36);
38474 @@ -1343,8 +1324,6 @@ static int i2o_seq_show_uinfo(struct seq_file *seq, void *v)
38475 u8 instance_number[4];
38476 } result;
38477
38478 - char tmp[64 + 1];
38479 -
38480 token = i2o_parm_field_get(d, 0xF102, -1, &result, sizeof(result));
38481
38482 if (token < 0) {
38483 @@ -1352,14 +1331,10 @@ static int i2o_seq_show_uinfo(struct seq_file *seq, void *v)
38484 return 0;
38485 }
38486
38487 - seq_printf(seq, "Device name : %s\n",
38488 - chtostr(tmp, result.device_name, 64));
38489 - seq_printf(seq, "Service name : %s\n",
38490 - chtostr(tmp, result.service_name, 64));
38491 - seq_printf(seq, "Physical name : %s\n",
38492 - chtostr(tmp, result.physical_location, 64));
38493 - seq_printf(seq, "Instance number : %s\n",
38494 - chtostr(tmp, result.instance_number, 4));
38495 + seq_printf(seq, "Device name : %.64s\n", result.device_name);
38496 + seq_printf(seq, "Service name : %.64s\n", result.service_name);
38497 + seq_printf(seq, "Physical name : %.64s\n", result.physical_location);
38498 + seq_printf(seq, "Instance number : %.4s\n", result.instance_number);
38499
38500 return 0;
38501 }
38502 diff --git a/drivers/message/i2o/iop.c b/drivers/message/i2o/iop.c
38503 index a8c08f3..155fe3d 100644
38504 --- a/drivers/message/i2o/iop.c
38505 +++ b/drivers/message/i2o/iop.c
38506 @@ -111,10 +111,10 @@ u32 i2o_cntxt_list_add(struct i2o_controller * c, void *ptr)
38507
38508 spin_lock_irqsave(&c->context_list_lock, flags);
38509
38510 - if (unlikely(atomic_inc_and_test(&c->context_list_counter)))
38511 - atomic_inc(&c->context_list_counter);
38512 + if (unlikely(atomic_inc_and_test_unchecked(&c->context_list_counter)))
38513 + atomic_inc_unchecked(&c->context_list_counter);
38514
38515 - entry->context = atomic_read(&c->context_list_counter);
38516 + entry->context = atomic_read_unchecked(&c->context_list_counter);
38517
38518 list_add(&entry->list, &c->context_list);
38519
38520 @@ -1077,7 +1077,7 @@ struct i2o_controller *i2o_iop_alloc(void)
38521
38522 #if BITS_PER_LONG == 64
38523 spin_lock_init(&c->context_list_lock);
38524 - atomic_set(&c->context_list_counter, 0);
38525 + atomic_set_unchecked(&c->context_list_counter, 0);
38526 INIT_LIST_HEAD(&c->context_list);
38527 #endif
38528
38529 diff --git a/drivers/mfd/janz-cmodio.c b/drivers/mfd/janz-cmodio.c
38530 index 45ece11..8efa218 100644
38531 --- a/drivers/mfd/janz-cmodio.c
38532 +++ b/drivers/mfd/janz-cmodio.c
38533 @@ -13,6 +13,7 @@
38534
38535 #include <linux/kernel.h>
38536 #include <linux/module.h>
38537 +#include <linux/slab.h>
38538 #include <linux/init.h>
38539 #include <linux/pci.h>
38540 #include <linux/interrupt.h>
38541 diff --git a/drivers/mfd/twl4030-irq.c b/drivers/mfd/twl4030-irq.c
38542 index a5f9888..1c0ed56 100644
38543 --- a/drivers/mfd/twl4030-irq.c
38544 +++ b/drivers/mfd/twl4030-irq.c
38545 @@ -35,6 +35,7 @@
38546 #include <linux/of.h>
38547 #include <linux/irqdomain.h>
38548 #include <linux/i2c/twl.h>
38549 +#include <asm/pgtable.h>
38550
38551 #include "twl-core.h"
38552
38553 @@ -728,10 +729,12 @@ int twl4030_init_irq(struct device *dev, int irq_num)
38554 * Install an irq handler for each of the SIH modules;
38555 * clone dummy irq_chip since PIH can't *do* anything
38556 */
38557 - twl4030_irq_chip = dummy_irq_chip;
38558 - twl4030_irq_chip.name = "twl4030";
38559 + pax_open_kernel();
38560 + memcpy((void *)&twl4030_irq_chip, &dummy_irq_chip, sizeof twl4030_irq_chip);
38561 + *(const char **)&twl4030_irq_chip.name = "twl4030";
38562
38563 - twl4030_sih_irq_chip.irq_ack = dummy_irq_chip.irq_ack;
38564 + *(void **)&twl4030_sih_irq_chip.irq_ack = dummy_irq_chip.irq_ack;
38565 + pax_close_kernel();
38566
38567 for (i = irq_base; i < irq_end; i++) {
38568 irq_set_chip_and_handler(i, &twl4030_irq_chip,
38569 diff --git a/drivers/mfd/twl6030-irq.c b/drivers/mfd/twl6030-irq.c
38570 index 277a8db..0e0b754 100644
38571 --- a/drivers/mfd/twl6030-irq.c
38572 +++ b/drivers/mfd/twl6030-irq.c
38573 @@ -387,10 +387,12 @@ int twl6030_init_irq(struct device *dev, int irq_num)
38574 * install an irq handler for each of the modules;
38575 * clone dummy irq_chip since PIH can't *do* anything
38576 */
38577 - twl6030_irq_chip = dummy_irq_chip;
38578 - twl6030_irq_chip.name = "twl6030";
38579 - twl6030_irq_chip.irq_set_type = NULL;
38580 - twl6030_irq_chip.irq_set_wake = twl6030_irq_set_wake;
38581 + pax_open_kernel();
38582 + memcpy((void *)&twl6030_irq_chip, &dummy_irq_chip, sizeof twl6030_irq_chip);
38583 + *(const char **)&twl6030_irq_chip.name = "twl6030";
38584 + *(void **)&twl6030_irq_chip.irq_set_type = NULL;
38585 + *(void **)&twl6030_irq_chip.irq_set_wake = twl6030_irq_set_wake;
38586 + pax_close_kernel();
38587
38588 for (i = irq_base; i < irq_end; i++) {
38589 irq_set_chip_and_handler(i, &twl6030_irq_chip,
38590 diff --git a/drivers/misc/c2port/core.c b/drivers/misc/c2port/core.c
38591 index f428d86..274c368 100644
38592 --- a/drivers/misc/c2port/core.c
38593 +++ b/drivers/misc/c2port/core.c
38594 @@ -924,7 +924,9 @@ struct c2port_device *c2port_device_register(char *name,
38595 mutex_init(&c2dev->mutex);
38596
38597 /* Create binary file */
38598 - c2port_bin_attrs.size = ops->blocks_num * ops->block_size;
38599 + pax_open_kernel();
38600 + *(size_t *)&c2port_bin_attrs.size = ops->blocks_num * ops->block_size;
38601 + pax_close_kernel();
38602 ret = device_create_bin_file(c2dev->dev, &c2port_bin_attrs);
38603 if (unlikely(ret))
38604 goto error_device_create_bin_file;
38605 diff --git a/drivers/misc/kgdbts.c b/drivers/misc/kgdbts.c
38606 index 3aa9a96..59cf685 100644
38607 --- a/drivers/misc/kgdbts.c
38608 +++ b/drivers/misc/kgdbts.c
38609 @@ -832,7 +832,7 @@ static void run_plant_and_detach_test(int is_early)
38610 char before[BREAK_INSTR_SIZE];
38611 char after[BREAK_INSTR_SIZE];
38612
38613 - probe_kernel_read(before, (char *)kgdbts_break_test,
38614 + probe_kernel_read(before, ktla_ktva((char *)kgdbts_break_test),
38615 BREAK_INSTR_SIZE);
38616 init_simple_test();
38617 ts.tst = plant_and_detach_test;
38618 @@ -840,7 +840,7 @@ static void run_plant_and_detach_test(int is_early)
38619 /* Activate test with initial breakpoint */
38620 if (!is_early)
38621 kgdb_breakpoint();
38622 - probe_kernel_read(after, (char *)kgdbts_break_test,
38623 + probe_kernel_read(after, ktla_ktva((char *)kgdbts_break_test),
38624 BREAK_INSTR_SIZE);
38625 if (memcmp(before, after, BREAK_INSTR_SIZE)) {
38626 printk(KERN_CRIT "kgdbts: ERROR kgdb corrupted memory\n");
38627 diff --git a/drivers/misc/lis3lv02d/lis3lv02d.c b/drivers/misc/lis3lv02d/lis3lv02d.c
38628 index 4a87e5c..76bdf5c 100644
38629 --- a/drivers/misc/lis3lv02d/lis3lv02d.c
38630 +++ b/drivers/misc/lis3lv02d/lis3lv02d.c
38631 @@ -498,7 +498,7 @@ static irqreturn_t lis302dl_interrupt(int irq, void *data)
38632 * the lid is closed. This leads to interrupts as soon as a little move
38633 * is done.
38634 */
38635 - atomic_inc(&lis3->count);
38636 + atomic_inc_unchecked(&lis3->count);
38637
38638 wake_up_interruptible(&lis3->misc_wait);
38639 kill_fasync(&lis3->async_queue, SIGIO, POLL_IN);
38640 @@ -584,7 +584,7 @@ static int lis3lv02d_misc_open(struct inode *inode, struct file *file)
38641 if (lis3->pm_dev)
38642 pm_runtime_get_sync(lis3->pm_dev);
38643
38644 - atomic_set(&lis3->count, 0);
38645 + atomic_set_unchecked(&lis3->count, 0);
38646 return 0;
38647 }
38648
38649 @@ -617,7 +617,7 @@ static ssize_t lis3lv02d_misc_read(struct file *file, char __user *buf,
38650 add_wait_queue(&lis3->misc_wait, &wait);
38651 while (true) {
38652 set_current_state(TASK_INTERRUPTIBLE);
38653 - data = atomic_xchg(&lis3->count, 0);
38654 + data = atomic_xchg_unchecked(&lis3->count, 0);
38655 if (data)
38656 break;
38657
38658 @@ -658,7 +658,7 @@ static unsigned int lis3lv02d_misc_poll(struct file *file, poll_table *wait)
38659 struct lis3lv02d, miscdev);
38660
38661 poll_wait(file, &lis3->misc_wait, wait);
38662 - if (atomic_read(&lis3->count))
38663 + if (atomic_read_unchecked(&lis3->count))
38664 return POLLIN | POLLRDNORM;
38665 return 0;
38666 }
38667 diff --git a/drivers/misc/lis3lv02d/lis3lv02d.h b/drivers/misc/lis3lv02d/lis3lv02d.h
38668 index c439c82..1f20f57 100644
38669 --- a/drivers/misc/lis3lv02d/lis3lv02d.h
38670 +++ b/drivers/misc/lis3lv02d/lis3lv02d.h
38671 @@ -297,7 +297,7 @@ struct lis3lv02d {
38672 struct input_polled_dev *idev; /* input device */
38673 struct platform_device *pdev; /* platform device */
38674 struct regulator_bulk_data regulators[2];
38675 - atomic_t count; /* interrupt count after last read */
38676 + atomic_unchecked_t count; /* interrupt count after last read */
38677 union axis_conversion ac; /* hw -> logical axis */
38678 int mapped_btns[3];
38679
38680 diff --git a/drivers/misc/sgi-gru/gruhandles.c b/drivers/misc/sgi-gru/gruhandles.c
38681 index 2f30bad..c4c13d0 100644
38682 --- a/drivers/misc/sgi-gru/gruhandles.c
38683 +++ b/drivers/misc/sgi-gru/gruhandles.c
38684 @@ -44,8 +44,8 @@ static void update_mcs_stats(enum mcs_op op, unsigned long clks)
38685 unsigned long nsec;
38686
38687 nsec = CLKS2NSEC(clks);
38688 - atomic_long_inc(&mcs_op_statistics[op].count);
38689 - atomic_long_add(nsec, &mcs_op_statistics[op].total);
38690 + atomic_long_inc_unchecked(&mcs_op_statistics[op].count);
38691 + atomic_long_add_unchecked(nsec, &mcs_op_statistics[op].total);
38692 if (mcs_op_statistics[op].max < nsec)
38693 mcs_op_statistics[op].max = nsec;
38694 }
38695 diff --git a/drivers/misc/sgi-gru/gruprocfs.c b/drivers/misc/sgi-gru/gruprocfs.c
38696 index 950dbe9..eeef0f8 100644
38697 --- a/drivers/misc/sgi-gru/gruprocfs.c
38698 +++ b/drivers/misc/sgi-gru/gruprocfs.c
38699 @@ -32,9 +32,9 @@
38700
38701 #define printstat(s, f) printstat_val(s, &gru_stats.f, #f)
38702
38703 -static void printstat_val(struct seq_file *s, atomic_long_t *v, char *id)
38704 +static void printstat_val(struct seq_file *s, atomic_long_unchecked_t *v, char *id)
38705 {
38706 - unsigned long val = atomic_long_read(v);
38707 + unsigned long val = atomic_long_read_unchecked(v);
38708
38709 seq_printf(s, "%16lu %s\n", val, id);
38710 }
38711 @@ -134,8 +134,8 @@ static int mcs_statistics_show(struct seq_file *s, void *p)
38712
38713 seq_printf(s, "%-20s%12s%12s%12s\n", "#id", "count", "aver-clks", "max-clks");
38714 for (op = 0; op < mcsop_last; op++) {
38715 - count = atomic_long_read(&mcs_op_statistics[op].count);
38716 - total = atomic_long_read(&mcs_op_statistics[op].total);
38717 + count = atomic_long_read_unchecked(&mcs_op_statistics[op].count);
38718 + total = atomic_long_read_unchecked(&mcs_op_statistics[op].total);
38719 max = mcs_op_statistics[op].max;
38720 seq_printf(s, "%-20s%12ld%12ld%12ld\n", id[op], count,
38721 count ? total / count : 0, max);
38722 diff --git a/drivers/misc/sgi-gru/grutables.h b/drivers/misc/sgi-gru/grutables.h
38723 index 5c3ce24..4915ccb 100644
38724 --- a/drivers/misc/sgi-gru/grutables.h
38725 +++ b/drivers/misc/sgi-gru/grutables.h
38726 @@ -167,82 +167,82 @@ extern unsigned int gru_max_gids;
38727 * GRU statistics.
38728 */
38729 struct gru_stats_s {
38730 - atomic_long_t vdata_alloc;
38731 - atomic_long_t vdata_free;
38732 - atomic_long_t gts_alloc;
38733 - atomic_long_t gts_free;
38734 - atomic_long_t gms_alloc;
38735 - atomic_long_t gms_free;
38736 - atomic_long_t gts_double_allocate;
38737 - atomic_long_t assign_context;
38738 - atomic_long_t assign_context_failed;
38739 - atomic_long_t free_context;
38740 - atomic_long_t load_user_context;
38741 - atomic_long_t load_kernel_context;
38742 - atomic_long_t lock_kernel_context;
38743 - atomic_long_t unlock_kernel_context;
38744 - atomic_long_t steal_user_context;
38745 - atomic_long_t steal_kernel_context;
38746 - atomic_long_t steal_context_failed;
38747 - atomic_long_t nopfn;
38748 - atomic_long_t asid_new;
38749 - atomic_long_t asid_next;
38750 - atomic_long_t asid_wrap;
38751 - atomic_long_t asid_reuse;
38752 - atomic_long_t intr;
38753 - atomic_long_t intr_cbr;
38754 - atomic_long_t intr_tfh;
38755 - atomic_long_t intr_spurious;
38756 - atomic_long_t intr_mm_lock_failed;
38757 - atomic_long_t call_os;
38758 - atomic_long_t call_os_wait_queue;
38759 - atomic_long_t user_flush_tlb;
38760 - atomic_long_t user_unload_context;
38761 - atomic_long_t user_exception;
38762 - atomic_long_t set_context_option;
38763 - atomic_long_t check_context_retarget_intr;
38764 - atomic_long_t check_context_unload;
38765 - atomic_long_t tlb_dropin;
38766 - atomic_long_t tlb_preload_page;
38767 - atomic_long_t tlb_dropin_fail_no_asid;
38768 - atomic_long_t tlb_dropin_fail_upm;
38769 - atomic_long_t tlb_dropin_fail_invalid;
38770 - atomic_long_t tlb_dropin_fail_range_active;
38771 - atomic_long_t tlb_dropin_fail_idle;
38772 - atomic_long_t tlb_dropin_fail_fmm;
38773 - atomic_long_t tlb_dropin_fail_no_exception;
38774 - atomic_long_t tfh_stale_on_fault;
38775 - atomic_long_t mmu_invalidate_range;
38776 - atomic_long_t mmu_invalidate_page;
38777 - atomic_long_t flush_tlb;
38778 - atomic_long_t flush_tlb_gru;
38779 - atomic_long_t flush_tlb_gru_tgh;
38780 - atomic_long_t flush_tlb_gru_zero_asid;
38781 + atomic_long_unchecked_t vdata_alloc;
38782 + atomic_long_unchecked_t vdata_free;
38783 + atomic_long_unchecked_t gts_alloc;
38784 + atomic_long_unchecked_t gts_free;
38785 + atomic_long_unchecked_t gms_alloc;
38786 + atomic_long_unchecked_t gms_free;
38787 + atomic_long_unchecked_t gts_double_allocate;
38788 + atomic_long_unchecked_t assign_context;
38789 + atomic_long_unchecked_t assign_context_failed;
38790 + atomic_long_unchecked_t free_context;
38791 + atomic_long_unchecked_t load_user_context;
38792 + atomic_long_unchecked_t load_kernel_context;
38793 + atomic_long_unchecked_t lock_kernel_context;
38794 + atomic_long_unchecked_t unlock_kernel_context;
38795 + atomic_long_unchecked_t steal_user_context;
38796 + atomic_long_unchecked_t steal_kernel_context;
38797 + atomic_long_unchecked_t steal_context_failed;
38798 + atomic_long_unchecked_t nopfn;
38799 + atomic_long_unchecked_t asid_new;
38800 + atomic_long_unchecked_t asid_next;
38801 + atomic_long_unchecked_t asid_wrap;
38802 + atomic_long_unchecked_t asid_reuse;
38803 + atomic_long_unchecked_t intr;
38804 + atomic_long_unchecked_t intr_cbr;
38805 + atomic_long_unchecked_t intr_tfh;
38806 + atomic_long_unchecked_t intr_spurious;
38807 + atomic_long_unchecked_t intr_mm_lock_failed;
38808 + atomic_long_unchecked_t call_os;
38809 + atomic_long_unchecked_t call_os_wait_queue;
38810 + atomic_long_unchecked_t user_flush_tlb;
38811 + atomic_long_unchecked_t user_unload_context;
38812 + atomic_long_unchecked_t user_exception;
38813 + atomic_long_unchecked_t set_context_option;
38814 + atomic_long_unchecked_t check_context_retarget_intr;
38815 + atomic_long_unchecked_t check_context_unload;
38816 + atomic_long_unchecked_t tlb_dropin;
38817 + atomic_long_unchecked_t tlb_preload_page;
38818 + atomic_long_unchecked_t tlb_dropin_fail_no_asid;
38819 + atomic_long_unchecked_t tlb_dropin_fail_upm;
38820 + atomic_long_unchecked_t tlb_dropin_fail_invalid;
38821 + atomic_long_unchecked_t tlb_dropin_fail_range_active;
38822 + atomic_long_unchecked_t tlb_dropin_fail_idle;
38823 + atomic_long_unchecked_t tlb_dropin_fail_fmm;
38824 + atomic_long_unchecked_t tlb_dropin_fail_no_exception;
38825 + atomic_long_unchecked_t tfh_stale_on_fault;
38826 + atomic_long_unchecked_t mmu_invalidate_range;
38827 + atomic_long_unchecked_t mmu_invalidate_page;
38828 + atomic_long_unchecked_t flush_tlb;
38829 + atomic_long_unchecked_t flush_tlb_gru;
38830 + atomic_long_unchecked_t flush_tlb_gru_tgh;
38831 + atomic_long_unchecked_t flush_tlb_gru_zero_asid;
38832
38833 - atomic_long_t copy_gpa;
38834 - atomic_long_t read_gpa;
38835 + atomic_long_unchecked_t copy_gpa;
38836 + atomic_long_unchecked_t read_gpa;
38837
38838 - atomic_long_t mesq_receive;
38839 - atomic_long_t mesq_receive_none;
38840 - atomic_long_t mesq_send;
38841 - atomic_long_t mesq_send_failed;
38842 - atomic_long_t mesq_noop;
38843 - atomic_long_t mesq_send_unexpected_error;
38844 - atomic_long_t mesq_send_lb_overflow;
38845 - atomic_long_t mesq_send_qlimit_reached;
38846 - atomic_long_t mesq_send_amo_nacked;
38847 - atomic_long_t mesq_send_put_nacked;
38848 - atomic_long_t mesq_page_overflow;
38849 - atomic_long_t mesq_qf_locked;
38850 - atomic_long_t mesq_qf_noop_not_full;
38851 - atomic_long_t mesq_qf_switch_head_failed;
38852 - atomic_long_t mesq_qf_unexpected_error;
38853 - atomic_long_t mesq_noop_unexpected_error;
38854 - atomic_long_t mesq_noop_lb_overflow;
38855 - atomic_long_t mesq_noop_qlimit_reached;
38856 - atomic_long_t mesq_noop_amo_nacked;
38857 - atomic_long_t mesq_noop_put_nacked;
38858 - atomic_long_t mesq_noop_page_overflow;
38859 + atomic_long_unchecked_t mesq_receive;
38860 + atomic_long_unchecked_t mesq_receive_none;
38861 + atomic_long_unchecked_t mesq_send;
38862 + atomic_long_unchecked_t mesq_send_failed;
38863 + atomic_long_unchecked_t mesq_noop;
38864 + atomic_long_unchecked_t mesq_send_unexpected_error;
38865 + atomic_long_unchecked_t mesq_send_lb_overflow;
38866 + atomic_long_unchecked_t mesq_send_qlimit_reached;
38867 + atomic_long_unchecked_t mesq_send_amo_nacked;
38868 + atomic_long_unchecked_t mesq_send_put_nacked;
38869 + atomic_long_unchecked_t mesq_page_overflow;
38870 + atomic_long_unchecked_t mesq_qf_locked;
38871 + atomic_long_unchecked_t mesq_qf_noop_not_full;
38872 + atomic_long_unchecked_t mesq_qf_switch_head_failed;
38873 + atomic_long_unchecked_t mesq_qf_unexpected_error;
38874 + atomic_long_unchecked_t mesq_noop_unexpected_error;
38875 + atomic_long_unchecked_t mesq_noop_lb_overflow;
38876 + atomic_long_unchecked_t mesq_noop_qlimit_reached;
38877 + atomic_long_unchecked_t mesq_noop_amo_nacked;
38878 + atomic_long_unchecked_t mesq_noop_put_nacked;
38879 + atomic_long_unchecked_t mesq_noop_page_overflow;
38880
38881 };
38882
38883 @@ -251,8 +251,8 @@ enum mcs_op {cchop_allocate, cchop_start, cchop_interrupt, cchop_interrupt_sync,
38884 tghop_invalidate, mcsop_last};
38885
38886 struct mcs_op_statistic {
38887 - atomic_long_t count;
38888 - atomic_long_t total;
38889 + atomic_long_unchecked_t count;
38890 + atomic_long_unchecked_t total;
38891 unsigned long max;
38892 };
38893
38894 @@ -275,7 +275,7 @@ extern struct mcs_op_statistic mcs_op_statistics[mcsop_last];
38895
38896 #define STAT(id) do { \
38897 if (gru_options & OPT_STATS) \
38898 - atomic_long_inc(&gru_stats.id); \
38899 + atomic_long_inc_unchecked(&gru_stats.id); \
38900 } while (0)
38901
38902 #ifdef CONFIG_SGI_GRU_DEBUG
38903 diff --git a/drivers/misc/sgi-xp/xp.h b/drivers/misc/sgi-xp/xp.h
38904 index c862cd4..0d176fe 100644
38905 --- a/drivers/misc/sgi-xp/xp.h
38906 +++ b/drivers/misc/sgi-xp/xp.h
38907 @@ -288,7 +288,7 @@ struct xpc_interface {
38908 xpc_notify_func, void *);
38909 void (*received) (short, int, void *);
38910 enum xp_retval (*partid_to_nasids) (short, void *);
38911 -};
38912 +} __no_const;
38913
38914 extern struct xpc_interface xpc_interface;
38915
38916 diff --git a/drivers/misc/sgi-xp/xpc.h b/drivers/misc/sgi-xp/xpc.h
38917 index b94d5f7..7f494c5 100644
38918 --- a/drivers/misc/sgi-xp/xpc.h
38919 +++ b/drivers/misc/sgi-xp/xpc.h
38920 @@ -835,6 +835,7 @@ struct xpc_arch_operations {
38921 void (*received_payload) (struct xpc_channel *, void *);
38922 void (*notify_senders_of_disconnect) (struct xpc_channel *);
38923 };
38924 +typedef struct xpc_arch_operations __no_const xpc_arch_operations_no_const;
38925
38926 /* struct xpc_partition act_state values (for XPC HB) */
38927
38928 @@ -876,7 +877,7 @@ extern struct xpc_registration xpc_registrations[];
38929 /* found in xpc_main.c */
38930 extern struct device *xpc_part;
38931 extern struct device *xpc_chan;
38932 -extern struct xpc_arch_operations xpc_arch_ops;
38933 +extern xpc_arch_operations_no_const xpc_arch_ops;
38934 extern int xpc_disengage_timelimit;
38935 extern int xpc_disengage_timedout;
38936 extern int xpc_activate_IRQ_rcvd;
38937 diff --git a/drivers/misc/sgi-xp/xpc_main.c b/drivers/misc/sgi-xp/xpc_main.c
38938 index d971817..33bdca5 100644
38939 --- a/drivers/misc/sgi-xp/xpc_main.c
38940 +++ b/drivers/misc/sgi-xp/xpc_main.c
38941 @@ -166,7 +166,7 @@ static struct notifier_block xpc_die_notifier = {
38942 .notifier_call = xpc_system_die,
38943 };
38944
38945 -struct xpc_arch_operations xpc_arch_ops;
38946 +xpc_arch_operations_no_const xpc_arch_ops;
38947
38948 /*
38949 * Timer function to enforce the timelimit on the partition disengage.
38950 @@ -1210,7 +1210,7 @@ xpc_system_die(struct notifier_block *nb, unsigned long event, void *_die_args)
38951
38952 if (((die_args->trapnr == X86_TRAP_MF) ||
38953 (die_args->trapnr == X86_TRAP_XF)) &&
38954 - !user_mode_vm(die_args->regs))
38955 + !user_mode(die_args->regs))
38956 xpc_die_deactivate();
38957
38958 break;
38959 diff --git a/drivers/mmc/core/mmc_ops.c b/drivers/mmc/core/mmc_ops.c
38960 index 6d8f701..35b6369 100644
38961 --- a/drivers/mmc/core/mmc_ops.c
38962 +++ b/drivers/mmc/core/mmc_ops.c
38963 @@ -247,7 +247,7 @@ mmc_send_cxd_data(struct mmc_card *card, struct mmc_host *host,
38964 void *data_buf;
38965 int is_on_stack;
38966
38967 - is_on_stack = object_is_on_stack(buf);
38968 + is_on_stack = object_starts_on_stack(buf);
38969 if (is_on_stack) {
38970 /*
38971 * dma onto stack is unsafe/nonportable, but callers to this
38972 diff --git a/drivers/mmc/host/dw_mmc.h b/drivers/mmc/host/dw_mmc.h
38973 index 53b8fd9..615b462 100644
38974 --- a/drivers/mmc/host/dw_mmc.h
38975 +++ b/drivers/mmc/host/dw_mmc.h
38976 @@ -205,5 +205,5 @@ struct dw_mci_drv_data {
38977 int (*parse_dt)(struct dw_mci *host);
38978 int (*setup_bus)(struct dw_mci *host,
38979 struct device_node *slot_np, u8 bus_width);
38980 -};
38981 +} __do_const;
38982 #endif /* _DW_MMC_H_ */
38983 diff --git a/drivers/mmc/host/sdhci-s3c.c b/drivers/mmc/host/sdhci-s3c.c
38984 index 82a8de1..3c56ccb 100644
38985 --- a/drivers/mmc/host/sdhci-s3c.c
38986 +++ b/drivers/mmc/host/sdhci-s3c.c
38987 @@ -721,9 +721,11 @@ static int sdhci_s3c_probe(struct platform_device *pdev)
38988 * we can use overriding functions instead of default.
38989 */
38990 if (host->quirks & SDHCI_QUIRK_NONSTANDARD_CLOCK) {
38991 - sdhci_s3c_ops.set_clock = sdhci_cmu_set_clock;
38992 - sdhci_s3c_ops.get_min_clock = sdhci_cmu_get_min_clock;
38993 - sdhci_s3c_ops.get_max_clock = sdhci_cmu_get_max_clock;
38994 + pax_open_kernel();
38995 + *(void **)&sdhci_s3c_ops.set_clock = sdhci_cmu_set_clock;
38996 + *(void **)&sdhci_s3c_ops.get_min_clock = sdhci_cmu_get_min_clock;
38997 + *(void **)&sdhci_s3c_ops.get_max_clock = sdhci_cmu_get_max_clock;
38998 + pax_close_kernel();
38999 }
39000
39001 /* It supports additional host capabilities if needed */
39002 diff --git a/drivers/mtd/devices/doc2000.c b/drivers/mtd/devices/doc2000.c
39003 index a4eb8b5..8c0628f 100644
39004 --- a/drivers/mtd/devices/doc2000.c
39005 +++ b/drivers/mtd/devices/doc2000.c
39006 @@ -753,7 +753,7 @@ static int doc_write(struct mtd_info *mtd, loff_t to, size_t len,
39007
39008 /* The ECC will not be calculated correctly if less than 512 is written */
39009 /* DBB-
39010 - if (len != 0x200 && eccbuf)
39011 + if (len != 0x200)
39012 printk(KERN_WARNING
39013 "ECC needs a full sector write (adr: %lx size %lx)\n",
39014 (long) to, (long) len);
39015 diff --git a/drivers/mtd/nand/denali.c b/drivers/mtd/nand/denali.c
39016 index 0c8bb6b..6f35deb 100644
39017 --- a/drivers/mtd/nand/denali.c
39018 +++ b/drivers/mtd/nand/denali.c
39019 @@ -24,6 +24,7 @@
39020 #include <linux/slab.h>
39021 #include <linux/mtd/mtd.h>
39022 #include <linux/module.h>
39023 +#include <linux/slab.h>
39024
39025 #include "denali.h"
39026
39027 diff --git a/drivers/mtd/nftlmount.c b/drivers/mtd/nftlmount.c
39028 index 51b9d6a..52af9a7 100644
39029 --- a/drivers/mtd/nftlmount.c
39030 +++ b/drivers/mtd/nftlmount.c
39031 @@ -24,6 +24,7 @@
39032 #include <asm/errno.h>
39033 #include <linux/delay.h>
39034 #include <linux/slab.h>
39035 +#include <linux/sched.h>
39036 #include <linux/mtd/mtd.h>
39037 #include <linux/mtd/nand.h>
39038 #include <linux/mtd/nftl.h>
39039 diff --git a/drivers/mtd/sm_ftl.c b/drivers/mtd/sm_ftl.c
39040 index 8dd6ba5..419cc1d 100644
39041 --- a/drivers/mtd/sm_ftl.c
39042 +++ b/drivers/mtd/sm_ftl.c
39043 @@ -56,7 +56,7 @@ ssize_t sm_attr_show(struct device *dev, struct device_attribute *attr,
39044 #define SM_CIS_VENDOR_OFFSET 0x59
39045 struct attribute_group *sm_create_sysfs_attributes(struct sm_ftl *ftl)
39046 {
39047 - struct attribute_group *attr_group;
39048 + attribute_group_no_const *attr_group;
39049 struct attribute **attributes;
39050 struct sm_sysfs_attribute *vendor_attribute;
39051
39052 diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
39053 index b7d45f3..b5c89d9 100644
39054 --- a/drivers/net/bonding/bond_main.c
39055 +++ b/drivers/net/bonding/bond_main.c
39056 @@ -4861,7 +4861,7 @@ static unsigned int bond_get_num_tx_queues(void)
39057 return tx_queues;
39058 }
39059
39060 -static struct rtnl_link_ops bond_link_ops __read_mostly = {
39061 +static struct rtnl_link_ops bond_link_ops = {
39062 .kind = "bond",
39063 .priv_size = sizeof(struct bonding),
39064 .setup = bond_setup,
39065 diff --git a/drivers/net/ethernet/8390/ax88796.c b/drivers/net/ethernet/8390/ax88796.c
39066 index 70dba5d..11a0919 100644
39067 --- a/drivers/net/ethernet/8390/ax88796.c
39068 +++ b/drivers/net/ethernet/8390/ax88796.c
39069 @@ -872,9 +872,11 @@ static int ax_probe(struct platform_device *pdev)
39070 if (ax->plat->reg_offsets)
39071 ei_local->reg_offset = ax->plat->reg_offsets;
39072 else {
39073 + resource_size_t _mem_size = mem_size;
39074 + do_div(_mem_size, 0x18);
39075 ei_local->reg_offset = ax->reg_offsets;
39076 for (ret = 0; ret < 0x18; ret++)
39077 - ax->reg_offsets[ret] = (mem_size / 0x18) * ret;
39078 + ax->reg_offsets[ret] = _mem_size * ret;
39079 }
39080
39081 if (!request_mem_region(mem->start, mem_size, pdev->name)) {
39082 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
39083 index 0991534..8098e92 100644
39084 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
39085 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
39086 @@ -1094,7 +1094,7 @@ static inline u8 bnx2x_get_path_func_num(struct bnx2x *bp)
39087 static inline void bnx2x_init_bp_objs(struct bnx2x *bp)
39088 {
39089 /* RX_MODE controlling object */
39090 - bnx2x_init_rx_mode_obj(bp, &bp->rx_mode_obj);
39091 + bnx2x_init_rx_mode_obj(bp);
39092
39093 /* multicast configuration controlling object */
39094 bnx2x_init_mcast_obj(bp, &bp->mcast_obj, bp->fp->cl_id, bp->fp->cid,
39095 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
39096 index 09b625e..15b16fe 100644
39097 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
39098 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
39099 @@ -2375,15 +2375,14 @@ int bnx2x_config_rx_mode(struct bnx2x *bp,
39100 return rc;
39101 }
39102
39103 -void bnx2x_init_rx_mode_obj(struct bnx2x *bp,
39104 - struct bnx2x_rx_mode_obj *o)
39105 +void bnx2x_init_rx_mode_obj(struct bnx2x *bp)
39106 {
39107 if (CHIP_IS_E1x(bp)) {
39108 - o->wait_comp = bnx2x_empty_rx_mode_wait;
39109 - o->config_rx_mode = bnx2x_set_rx_mode_e1x;
39110 + bp->rx_mode_obj.wait_comp = bnx2x_empty_rx_mode_wait;
39111 + bp->rx_mode_obj.config_rx_mode = bnx2x_set_rx_mode_e1x;
39112 } else {
39113 - o->wait_comp = bnx2x_wait_rx_mode_comp_e2;
39114 - o->config_rx_mode = bnx2x_set_rx_mode_e2;
39115 + bp->rx_mode_obj.wait_comp = bnx2x_wait_rx_mode_comp_e2;
39116 + bp->rx_mode_obj.config_rx_mode = bnx2x_set_rx_mode_e2;
39117 }
39118 }
39119
39120 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
39121 index adbd91b..58ec94a 100644
39122 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
39123 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
39124 @@ -1293,8 +1293,7 @@ int bnx2x_vlan_mac_move(struct bnx2x *bp,
39125
39126 /********************* RX MODE ****************/
39127
39128 -void bnx2x_init_rx_mode_obj(struct bnx2x *bp,
39129 - struct bnx2x_rx_mode_obj *o);
39130 +void bnx2x_init_rx_mode_obj(struct bnx2x *bp);
39131
39132 /**
39133 * bnx2x_config_rx_mode - Send and RX_MODE ramrod according to the provided parameters.
39134 diff --git a/drivers/net/ethernet/broadcom/tg3.h b/drivers/net/ethernet/broadcom/tg3.h
39135 index d330e81..ce1fb9a 100644
39136 --- a/drivers/net/ethernet/broadcom/tg3.h
39137 +++ b/drivers/net/ethernet/broadcom/tg3.h
39138 @@ -146,6 +146,7 @@
39139 #define CHIPREV_ID_5750_A0 0x4000
39140 #define CHIPREV_ID_5750_A1 0x4001
39141 #define CHIPREV_ID_5750_A3 0x4003
39142 +#define CHIPREV_ID_5750_C1 0x4201
39143 #define CHIPREV_ID_5750_C2 0x4202
39144 #define CHIPREV_ID_5752_A0_HW 0x5000
39145 #define CHIPREV_ID_5752_A0 0x6000
39146 diff --git a/drivers/net/ethernet/chelsio/cxgb3/l2t.h b/drivers/net/ethernet/chelsio/cxgb3/l2t.h
39147 index 8cffcdf..aadf043 100644
39148 --- a/drivers/net/ethernet/chelsio/cxgb3/l2t.h
39149 +++ b/drivers/net/ethernet/chelsio/cxgb3/l2t.h
39150 @@ -87,7 +87,7 @@ typedef void (*arp_failure_handler_func)(struct t3cdev * dev,
39151 */
39152 struct l2t_skb_cb {
39153 arp_failure_handler_func arp_failure_handler;
39154 -};
39155 +} __no_const;
39156
39157 #define L2T_SKB_CB(skb) ((struct l2t_skb_cb *)(skb)->cb)
39158
39159 diff --git a/drivers/net/ethernet/dec/tulip/de4x5.c b/drivers/net/ethernet/dec/tulip/de4x5.c
39160 index 4c83003..2a2a5b9 100644
39161 --- a/drivers/net/ethernet/dec/tulip/de4x5.c
39162 +++ b/drivers/net/ethernet/dec/tulip/de4x5.c
39163 @@ -5388,7 +5388,7 @@ de4x5_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
39164 for (i=0; i<ETH_ALEN; i++) {
39165 tmp.addr[i] = dev->dev_addr[i];
39166 }
39167 - if (copy_to_user(ioc->data, tmp.addr, ioc->len)) return -EFAULT;
39168 + if (ioc->len > sizeof tmp.addr || copy_to_user(ioc->data, tmp.addr, ioc->len)) return -EFAULT;
39169 break;
39170
39171 case DE4X5_SET_HWADDR: /* Set the hardware address */
39172 @@ -5428,7 +5428,7 @@ de4x5_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
39173 spin_lock_irqsave(&lp->lock, flags);
39174 memcpy(&statbuf, &lp->pktStats, ioc->len);
39175 spin_unlock_irqrestore(&lp->lock, flags);
39176 - if (copy_to_user(ioc->data, &statbuf, ioc->len))
39177 + if (ioc->len > sizeof statbuf || copy_to_user(ioc->data, &statbuf, ioc->len))
39178 return -EFAULT;
39179 break;
39180 }
39181 diff --git a/drivers/net/ethernet/emulex/benet/be_main.c b/drivers/net/ethernet/emulex/benet/be_main.c
39182 index 4d6f3c5..6169e60 100644
39183 --- a/drivers/net/ethernet/emulex/benet/be_main.c
39184 +++ b/drivers/net/ethernet/emulex/benet/be_main.c
39185 @@ -455,7 +455,7 @@ static void accumulate_16bit_val(u32 *acc, u16 val)
39186
39187 if (wrapped)
39188 newacc += 65536;
39189 - ACCESS_ONCE(*acc) = newacc;
39190 + ACCESS_ONCE_RW(*acc) = newacc;
39191 }
39192
39193 void be_parse_stats(struct be_adapter *adapter)
39194 diff --git a/drivers/net/ethernet/faraday/ftgmac100.c b/drivers/net/ethernet/faraday/ftgmac100.c
39195 index 74d749e..eefb1bd 100644
39196 --- a/drivers/net/ethernet/faraday/ftgmac100.c
39197 +++ b/drivers/net/ethernet/faraday/ftgmac100.c
39198 @@ -31,6 +31,8 @@
39199 #include <linux/netdevice.h>
39200 #include <linux/phy.h>
39201 #include <linux/platform_device.h>
39202 +#include <linux/interrupt.h>
39203 +#include <linux/irqreturn.h>
39204 #include <net/ip.h>
39205
39206 #include "ftgmac100.h"
39207 diff --git a/drivers/net/ethernet/faraday/ftmac100.c b/drivers/net/ethernet/faraday/ftmac100.c
39208 index b901a01..1ff32ee 100644
39209 --- a/drivers/net/ethernet/faraday/ftmac100.c
39210 +++ b/drivers/net/ethernet/faraday/ftmac100.c
39211 @@ -31,6 +31,8 @@
39212 #include <linux/module.h>
39213 #include <linux/netdevice.h>
39214 #include <linux/platform_device.h>
39215 +#include <linux/interrupt.h>
39216 +#include <linux/irqreturn.h>
39217
39218 #include "ftmac100.h"
39219
39220 diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
39221 index bb9256a..56d8752 100644
39222 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
39223 +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
39224 @@ -806,7 +806,7 @@ void ixgbe_ptp_start_cyclecounter(struct ixgbe_adapter *adapter)
39225 }
39226
39227 /* update the base incval used to calculate frequency adjustment */
39228 - ACCESS_ONCE(adapter->base_incval) = incval;
39229 + ACCESS_ONCE_RW(adapter->base_incval) = incval;
39230 smp_mb();
39231
39232 /* need lock to prevent incorrect read while modifying cyclecounter */
39233 diff --git a/drivers/net/ethernet/neterion/vxge/vxge-config.c b/drivers/net/ethernet/neterion/vxge/vxge-config.c
39234 index fbe5363..266b4e3 100644
39235 --- a/drivers/net/ethernet/neterion/vxge/vxge-config.c
39236 +++ b/drivers/net/ethernet/neterion/vxge/vxge-config.c
39237 @@ -3461,7 +3461,10 @@ __vxge_hw_fifo_create(struct __vxge_hw_vpath_handle *vp,
39238 struct __vxge_hw_fifo *fifo;
39239 struct vxge_hw_fifo_config *config;
39240 u32 txdl_size, txdl_per_memblock;
39241 - struct vxge_hw_mempool_cbs fifo_mp_callback;
39242 + static struct vxge_hw_mempool_cbs fifo_mp_callback = {
39243 + .item_func_alloc = __vxge_hw_fifo_mempool_item_alloc,
39244 + };
39245 +
39246 struct __vxge_hw_virtualpath *vpath;
39247
39248 if ((vp == NULL) || (attr == NULL)) {
39249 @@ -3544,8 +3547,6 @@ __vxge_hw_fifo_create(struct __vxge_hw_vpath_handle *vp,
39250 goto exit;
39251 }
39252
39253 - fifo_mp_callback.item_func_alloc = __vxge_hw_fifo_mempool_item_alloc;
39254 -
39255 fifo->mempool =
39256 __vxge_hw_mempool_create(vpath->hldev,
39257 fifo->config->memblock_size,
39258 diff --git a/drivers/net/ethernet/realtek/r8169.c b/drivers/net/ethernet/realtek/r8169.c
39259 index 998974f..ecd26db 100644
39260 --- a/drivers/net/ethernet/realtek/r8169.c
39261 +++ b/drivers/net/ethernet/realtek/r8169.c
39262 @@ -741,22 +741,22 @@ struct rtl8169_private {
39263 struct mdio_ops {
39264 void (*write)(struct rtl8169_private *, int, int);
39265 int (*read)(struct rtl8169_private *, int);
39266 - } mdio_ops;
39267 + } __no_const mdio_ops;
39268
39269 struct pll_power_ops {
39270 void (*down)(struct rtl8169_private *);
39271 void (*up)(struct rtl8169_private *);
39272 - } pll_power_ops;
39273 + } __no_const pll_power_ops;
39274
39275 struct jumbo_ops {
39276 void (*enable)(struct rtl8169_private *);
39277 void (*disable)(struct rtl8169_private *);
39278 - } jumbo_ops;
39279 + } __no_const jumbo_ops;
39280
39281 struct csi_ops {
39282 void (*write)(struct rtl8169_private *, int, int);
39283 u32 (*read)(struct rtl8169_private *, int);
39284 - } csi_ops;
39285 + } __no_const csi_ops;
39286
39287 int (*set_speed)(struct net_device *, u8 aneg, u16 sp, u8 dpx, u32 adv);
39288 int (*get_settings)(struct net_device *, struct ethtool_cmd *);
39289 diff --git a/drivers/net/ethernet/sfc/ptp.c b/drivers/net/ethernet/sfc/ptp.c
39290 index 0767043f..08c2553 100644
39291 --- a/drivers/net/ethernet/sfc/ptp.c
39292 +++ b/drivers/net/ethernet/sfc/ptp.c
39293 @@ -553,7 +553,7 @@ static int efx_ptp_synchronize(struct efx_nic *efx, unsigned int num_readings)
39294 (u32)((u64)ptp->start.dma_addr >> 32));
39295
39296 /* Clear flag that signals MC ready */
39297 - ACCESS_ONCE(*start) = 0;
39298 + ACCESS_ONCE_RW(*start) = 0;
39299 efx_mcdi_rpc_start(efx, MC_CMD_PTP, synch_buf,
39300 MC_CMD_PTP_IN_SYNCHRONIZE_LEN);
39301
39302 diff --git a/drivers/net/ethernet/stmicro/stmmac/mmc_core.c b/drivers/net/ethernet/stmicro/stmmac/mmc_core.c
39303 index 0c74a70..3bc6f68 100644
39304 --- a/drivers/net/ethernet/stmicro/stmmac/mmc_core.c
39305 +++ b/drivers/net/ethernet/stmicro/stmmac/mmc_core.c
39306 @@ -140,8 +140,8 @@ void dwmac_mmc_ctrl(void __iomem *ioaddr, unsigned int mode)
39307
39308 writel(value, ioaddr + MMC_CNTRL);
39309
39310 - pr_debug("stmmac: MMC ctrl register (offset 0x%x): 0x%08x\n",
39311 - MMC_CNTRL, value);
39312 +// pr_debug("stmmac: MMC ctrl register (offset 0x%x): 0x%08x\n",
39313 +// MMC_CNTRL, value);
39314 }
39315
39316 /* To mask all all interrupts.*/
39317 diff --git a/drivers/net/hyperv/hyperv_net.h b/drivers/net/hyperv/hyperv_net.h
39318 index e6fe0d8..2b7d752 100644
39319 --- a/drivers/net/hyperv/hyperv_net.h
39320 +++ b/drivers/net/hyperv/hyperv_net.h
39321 @@ -101,7 +101,7 @@ struct rndis_device {
39322
39323 enum rndis_device_state state;
39324 bool link_state;
39325 - atomic_t new_req_id;
39326 + atomic_unchecked_t new_req_id;
39327
39328 spinlock_t request_lock;
39329 struct list_head req_list;
39330 diff --git a/drivers/net/hyperv/rndis_filter.c b/drivers/net/hyperv/rndis_filter.c
39331 index 2b657d4..9903bc0 100644
39332 --- a/drivers/net/hyperv/rndis_filter.c
39333 +++ b/drivers/net/hyperv/rndis_filter.c
39334 @@ -107,7 +107,7 @@ static struct rndis_request *get_rndis_request(struct rndis_device *dev,
39335 * template
39336 */
39337 set = &rndis_msg->msg.set_req;
39338 - set->req_id = atomic_inc_return(&dev->new_req_id);
39339 + set->req_id = atomic_inc_return_unchecked(&dev->new_req_id);
39340
39341 /* Add to the request list */
39342 spin_lock_irqsave(&dev->request_lock, flags);
39343 @@ -758,7 +758,7 @@ static void rndis_filter_halt_device(struct rndis_device *dev)
39344
39345 /* Setup the rndis set */
39346 halt = &request->request_msg.msg.halt_req;
39347 - halt->req_id = atomic_inc_return(&dev->new_req_id);
39348 + halt->req_id = atomic_inc_return_unchecked(&dev->new_req_id);
39349
39350 /* Ignore return since this msg is optional. */
39351 rndis_filter_send_request(dev, request);
39352 diff --git a/drivers/net/ieee802154/fakehard.c b/drivers/net/ieee802154/fakehard.c
39353 index 1e9cb0b..7839125 100644
39354 --- a/drivers/net/ieee802154/fakehard.c
39355 +++ b/drivers/net/ieee802154/fakehard.c
39356 @@ -386,7 +386,7 @@ static int ieee802154fake_probe(struct platform_device *pdev)
39357 phy->transmit_power = 0xbf;
39358
39359 dev->netdev_ops = &fake_ops;
39360 - dev->ml_priv = &fake_mlme;
39361 + dev->ml_priv = (void *)&fake_mlme;
39362
39363 priv = netdev_priv(dev);
39364 priv->phy = phy;
39365 diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c
39366 index d3fb97d..19520c7 100644
39367 --- a/drivers/net/macvlan.c
39368 +++ b/drivers/net/macvlan.c
39369 @@ -851,13 +851,15 @@ static const struct nla_policy macvlan_policy[IFLA_MACVLAN_MAX + 1] = {
39370 int macvlan_link_register(struct rtnl_link_ops *ops)
39371 {
39372 /* common fields */
39373 - ops->priv_size = sizeof(struct macvlan_dev);
39374 - ops->validate = macvlan_validate;
39375 - ops->maxtype = IFLA_MACVLAN_MAX;
39376 - ops->policy = macvlan_policy;
39377 - ops->changelink = macvlan_changelink;
39378 - ops->get_size = macvlan_get_size;
39379 - ops->fill_info = macvlan_fill_info;
39380 + pax_open_kernel();
39381 + *(size_t *)&ops->priv_size = sizeof(struct macvlan_dev);
39382 + *(void **)&ops->validate = macvlan_validate;
39383 + *(int *)&ops->maxtype = IFLA_MACVLAN_MAX;
39384 + *(const void **)&ops->policy = macvlan_policy;
39385 + *(void **)&ops->changelink = macvlan_changelink;
39386 + *(void **)&ops->get_size = macvlan_get_size;
39387 + *(void **)&ops->fill_info = macvlan_fill_info;
39388 + pax_close_kernel();
39389
39390 return rtnl_link_register(ops);
39391 };
39392 @@ -913,7 +915,7 @@ static int macvlan_device_event(struct notifier_block *unused,
39393 return NOTIFY_DONE;
39394 }
39395
39396 -static struct notifier_block macvlan_notifier_block __read_mostly = {
39397 +static struct notifier_block macvlan_notifier_block = {
39398 .notifier_call = macvlan_device_event,
39399 };
39400
39401 diff --git a/drivers/net/macvtap.c b/drivers/net/macvtap.c
39402 index 0f0f9ce..0ca5819 100644
39403 --- a/drivers/net/macvtap.c
39404 +++ b/drivers/net/macvtap.c
39405 @@ -1100,7 +1100,7 @@ static int macvtap_device_event(struct notifier_block *unused,
39406 return NOTIFY_DONE;
39407 }
39408
39409 -static struct notifier_block macvtap_notifier_block __read_mostly = {
39410 +static struct notifier_block macvtap_notifier_block = {
39411 .notifier_call = macvtap_device_event,
39412 };
39413
39414 diff --git a/drivers/net/phy/mdio-bitbang.c b/drivers/net/phy/mdio-bitbang.c
39415 index daec9b0..6428fcb 100644
39416 --- a/drivers/net/phy/mdio-bitbang.c
39417 +++ b/drivers/net/phy/mdio-bitbang.c
39418 @@ -234,6 +234,7 @@ void free_mdio_bitbang(struct mii_bus *bus)
39419 struct mdiobb_ctrl *ctrl = bus->priv;
39420
39421 module_put(ctrl->ops->owner);
39422 + mdiobus_unregister(bus);
39423 mdiobus_free(bus);
39424 }
39425 EXPORT_SYMBOL(free_mdio_bitbang);
39426 diff --git a/drivers/net/ppp/ppp_generic.c b/drivers/net/ppp/ppp_generic.c
39427 index 508570e..f706dc7 100644
39428 --- a/drivers/net/ppp/ppp_generic.c
39429 +++ b/drivers/net/ppp/ppp_generic.c
39430 @@ -999,7 +999,6 @@ ppp_net_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
39431 void __user *addr = (void __user *) ifr->ifr_ifru.ifru_data;
39432 struct ppp_stats stats;
39433 struct ppp_comp_stats cstats;
39434 - char *vers;
39435
39436 switch (cmd) {
39437 case SIOCGPPPSTATS:
39438 @@ -1021,8 +1020,7 @@ ppp_net_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
39439 break;
39440
39441 case SIOCGPPPVER:
39442 - vers = PPP_VERSION;
39443 - if (copy_to_user(addr, vers, strlen(vers) + 1))
39444 + if (copy_to_user(addr, PPP_VERSION, sizeof(PPP_VERSION)))
39445 break;
39446 err = 0;
39447 break;
39448 diff --git a/drivers/net/team/team.c b/drivers/net/team/team.c
39449 index ad86660..9fd0884 100644
39450 --- a/drivers/net/team/team.c
39451 +++ b/drivers/net/team/team.c
39452 @@ -2601,7 +2601,7 @@ static int team_device_event(struct notifier_block *unused,
39453 return NOTIFY_DONE;
39454 }
39455
39456 -static struct notifier_block team_notifier_block __read_mostly = {
39457 +static struct notifier_block team_notifier_block = {
39458 .notifier_call = team_device_event,
39459 };
39460
39461 diff --git a/drivers/net/tun.c b/drivers/net/tun.c
39462 index 2917a86..edd463f 100644
39463 --- a/drivers/net/tun.c
39464 +++ b/drivers/net/tun.c
39465 @@ -1836,7 +1836,7 @@ unlock:
39466 }
39467
39468 static long __tun_chr_ioctl(struct file *file, unsigned int cmd,
39469 - unsigned long arg, int ifreq_len)
39470 + unsigned long arg, size_t ifreq_len)
39471 {
39472 struct tun_file *tfile = file->private_data;
39473 struct tun_struct *tun;
39474 @@ -1848,6 +1848,9 @@ static long __tun_chr_ioctl(struct file *file, unsigned int cmd,
39475 int vnet_hdr_sz;
39476 int ret;
39477
39478 + if (ifreq_len > sizeof ifr)
39479 + return -EFAULT;
39480 +
39481 if (cmd == TUNSETIFF || cmd == TUNSETQUEUE || _IOC_TYPE(cmd) == 0x89) {
39482 if (copy_from_user(&ifr, argp, ifreq_len))
39483 return -EFAULT;
39484 diff --git a/drivers/net/usb/hso.c b/drivers/net/usb/hso.c
39485 index cd8ccb2..cff5144 100644
39486 --- a/drivers/net/usb/hso.c
39487 +++ b/drivers/net/usb/hso.c
39488 @@ -71,7 +71,7 @@
39489 #include <asm/byteorder.h>
39490 #include <linux/serial_core.h>
39491 #include <linux/serial.h>
39492 -
39493 +#include <asm/local.h>
39494
39495 #define MOD_AUTHOR "Option Wireless"
39496 #define MOD_DESCRIPTION "USB High Speed Option driver"
39497 @@ -1180,7 +1180,7 @@ static void put_rxbuf_data_and_resubmit_ctrl_urb(struct hso_serial *serial)
39498 struct urb *urb;
39499
39500 urb = serial->rx_urb[0];
39501 - if (serial->port.count > 0) {
39502 + if (atomic_read(&serial->port.count) > 0) {
39503 count = put_rxbuf_data(urb, serial);
39504 if (count == -1)
39505 return;
39506 @@ -1216,7 +1216,7 @@ static void hso_std_serial_read_bulk_callback(struct urb *urb)
39507 DUMP1(urb->transfer_buffer, urb->actual_length);
39508
39509 /* Anyone listening? */
39510 - if (serial->port.count == 0)
39511 + if (atomic_read(&serial->port.count) == 0)
39512 return;
39513
39514 if (status == 0) {
39515 @@ -1298,8 +1298,7 @@ static int hso_serial_open(struct tty_struct *tty, struct file *filp)
39516 tty_port_tty_set(&serial->port, tty);
39517
39518 /* check for port already opened, if not set the termios */
39519 - serial->port.count++;
39520 - if (serial->port.count == 1) {
39521 + if (atomic_inc_return(&serial->port.count) == 1) {
39522 serial->rx_state = RX_IDLE;
39523 /* Force default termio settings */
39524 _hso_serial_set_termios(tty, NULL);
39525 @@ -1311,7 +1310,7 @@ static int hso_serial_open(struct tty_struct *tty, struct file *filp)
39526 result = hso_start_serial_device(serial->parent, GFP_KERNEL);
39527 if (result) {
39528 hso_stop_serial_device(serial->parent);
39529 - serial->port.count--;
39530 + atomic_dec(&serial->port.count);
39531 kref_put(&serial->parent->ref, hso_serial_ref_free);
39532 }
39533 } else {
39534 @@ -1348,10 +1347,10 @@ static void hso_serial_close(struct tty_struct *tty, struct file *filp)
39535
39536 /* reset the rts and dtr */
39537 /* do the actual close */
39538 - serial->port.count--;
39539 + atomic_dec(&serial->port.count);
39540
39541 - if (serial->port.count <= 0) {
39542 - serial->port.count = 0;
39543 + if (atomic_read(&serial->port.count) <= 0) {
39544 + atomic_set(&serial->port.count, 0);
39545 tty_port_tty_set(&serial->port, NULL);
39546 if (!usb_gone)
39547 hso_stop_serial_device(serial->parent);
39548 @@ -1427,7 +1426,7 @@ static void hso_serial_set_termios(struct tty_struct *tty, struct ktermios *old)
39549
39550 /* the actual setup */
39551 spin_lock_irqsave(&serial->serial_lock, flags);
39552 - if (serial->port.count)
39553 + if (atomic_read(&serial->port.count))
39554 _hso_serial_set_termios(tty, old);
39555 else
39556 tty->termios = *old;
39557 @@ -1886,7 +1885,7 @@ static void intr_callback(struct urb *urb)
39558 D1("Pending read interrupt on port %d\n", i);
39559 spin_lock(&serial->serial_lock);
39560 if (serial->rx_state == RX_IDLE &&
39561 - serial->port.count > 0) {
39562 + atomic_read(&serial->port.count) > 0) {
39563 /* Setup and send a ctrl req read on
39564 * port i */
39565 if (!serial->rx_urb_filled[0]) {
39566 @@ -3079,7 +3078,7 @@ static int hso_resume(struct usb_interface *iface)
39567 /* Start all serial ports */
39568 for (i = 0; i < HSO_SERIAL_TTY_MINORS; i++) {
39569 if (serial_table[i] && (serial_table[i]->interface == iface)) {
39570 - if (dev2ser(serial_table[i])->port.count) {
39571 + if (atomic_read(&dev2ser(serial_table[i])->port.count)) {
39572 result =
39573 hso_start_serial_device(serial_table[i], GFP_NOIO);
39574 hso_kick_transmit(dev2ser(serial_table[i]));
39575 diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c
39576 index 656230e..15525a8 100644
39577 --- a/drivers/net/vxlan.c
39578 +++ b/drivers/net/vxlan.c
39579 @@ -1428,7 +1428,7 @@ nla_put_failure:
39580 return -EMSGSIZE;
39581 }
39582
39583 -static struct rtnl_link_ops vxlan_link_ops __read_mostly = {
39584 +static struct rtnl_link_ops vxlan_link_ops = {
39585 .kind = "vxlan",
39586 .maxtype = IFLA_VXLAN_MAX,
39587 .policy = vxlan_policy,
39588 diff --git a/drivers/net/wireless/at76c50x-usb.c b/drivers/net/wireless/at76c50x-usb.c
39589 index 77fa428..996b355 100644
39590 --- a/drivers/net/wireless/at76c50x-usb.c
39591 +++ b/drivers/net/wireless/at76c50x-usb.c
39592 @@ -353,7 +353,7 @@ static int at76_dfu_get_state(struct usb_device *udev, u8 *state)
39593 }
39594
39595 /* Convert timeout from the DFU status to jiffies */
39596 -static inline unsigned long at76_get_timeout(struct dfu_status *s)
39597 +static inline unsigned long __intentional_overflow(-1) at76_get_timeout(struct dfu_status *s)
39598 {
39599 return msecs_to_jiffies((s->poll_timeout[2] << 16)
39600 | (s->poll_timeout[1] << 8)
39601 diff --git a/drivers/net/wireless/ath/ath9k/ar9002_mac.c b/drivers/net/wireless/ath/ath9k/ar9002_mac.c
39602 index 8d78253..bebbb68 100644
39603 --- a/drivers/net/wireless/ath/ath9k/ar9002_mac.c
39604 +++ b/drivers/net/wireless/ath/ath9k/ar9002_mac.c
39605 @@ -184,8 +184,8 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
39606 ads->ds_txstatus6 = ads->ds_txstatus7 = 0;
39607 ads->ds_txstatus8 = ads->ds_txstatus9 = 0;
39608
39609 - ACCESS_ONCE(ads->ds_link) = i->link;
39610 - ACCESS_ONCE(ads->ds_data) = i->buf_addr[0];
39611 + ACCESS_ONCE_RW(ads->ds_link) = i->link;
39612 + ACCESS_ONCE_RW(ads->ds_data) = i->buf_addr[0];
39613
39614 ctl1 = i->buf_len[0] | (i->is_last ? 0 : AR_TxMore);
39615 ctl6 = SM(i->keytype, AR_EncrType);
39616 @@ -199,26 +199,26 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
39617
39618 if ((i->is_first || i->is_last) &&
39619 i->aggr != AGGR_BUF_MIDDLE && i->aggr != AGGR_BUF_LAST) {
39620 - ACCESS_ONCE(ads->ds_ctl2) = set11nTries(i->rates, 0)
39621 + ACCESS_ONCE_RW(ads->ds_ctl2) = set11nTries(i->rates, 0)
39622 | set11nTries(i->rates, 1)
39623 | set11nTries(i->rates, 2)
39624 | set11nTries(i->rates, 3)
39625 | (i->dur_update ? AR_DurUpdateEna : 0)
39626 | SM(0, AR_BurstDur);
39627
39628 - ACCESS_ONCE(ads->ds_ctl3) = set11nRate(i->rates, 0)
39629 + ACCESS_ONCE_RW(ads->ds_ctl3) = set11nRate(i->rates, 0)
39630 | set11nRate(i->rates, 1)
39631 | set11nRate(i->rates, 2)
39632 | set11nRate(i->rates, 3);
39633 } else {
39634 - ACCESS_ONCE(ads->ds_ctl2) = 0;
39635 - ACCESS_ONCE(ads->ds_ctl3) = 0;
39636 + ACCESS_ONCE_RW(ads->ds_ctl2) = 0;
39637 + ACCESS_ONCE_RW(ads->ds_ctl3) = 0;
39638 }
39639
39640 if (!i->is_first) {
39641 - ACCESS_ONCE(ads->ds_ctl0) = 0;
39642 - ACCESS_ONCE(ads->ds_ctl1) = ctl1;
39643 - ACCESS_ONCE(ads->ds_ctl6) = ctl6;
39644 + ACCESS_ONCE_RW(ads->ds_ctl0) = 0;
39645 + ACCESS_ONCE_RW(ads->ds_ctl1) = ctl1;
39646 + ACCESS_ONCE_RW(ads->ds_ctl6) = ctl6;
39647 return;
39648 }
39649
39650 @@ -243,7 +243,7 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
39651 break;
39652 }
39653
39654 - ACCESS_ONCE(ads->ds_ctl0) = (i->pkt_len & AR_FrameLen)
39655 + ACCESS_ONCE_RW(ads->ds_ctl0) = (i->pkt_len & AR_FrameLen)
39656 | (i->flags & ATH9K_TXDESC_VMF ? AR_VirtMoreFrag : 0)
39657 | SM(i->txpower, AR_XmitPower)
39658 | (i->flags & ATH9K_TXDESC_VEOL ? AR_VEOL : 0)
39659 @@ -253,19 +253,19 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
39660 | (i->flags & ATH9K_TXDESC_RTSENA ? AR_RTSEnable :
39661 (i->flags & ATH9K_TXDESC_CTSENA ? AR_CTSEnable : 0));
39662
39663 - ACCESS_ONCE(ads->ds_ctl1) = ctl1;
39664 - ACCESS_ONCE(ads->ds_ctl6) = ctl6;
39665 + ACCESS_ONCE_RW(ads->ds_ctl1) = ctl1;
39666 + ACCESS_ONCE_RW(ads->ds_ctl6) = ctl6;
39667
39668 if (i->aggr == AGGR_BUF_MIDDLE || i->aggr == AGGR_BUF_LAST)
39669 return;
39670
39671 - ACCESS_ONCE(ads->ds_ctl4) = set11nPktDurRTSCTS(i->rates, 0)
39672 + ACCESS_ONCE_RW(ads->ds_ctl4) = set11nPktDurRTSCTS(i->rates, 0)
39673 | set11nPktDurRTSCTS(i->rates, 1);
39674
39675 - ACCESS_ONCE(ads->ds_ctl5) = set11nPktDurRTSCTS(i->rates, 2)
39676 + ACCESS_ONCE_RW(ads->ds_ctl5) = set11nPktDurRTSCTS(i->rates, 2)
39677 | set11nPktDurRTSCTS(i->rates, 3);
39678
39679 - ACCESS_ONCE(ads->ds_ctl7) = set11nRateFlags(i->rates, 0)
39680 + ACCESS_ONCE_RW(ads->ds_ctl7) = set11nRateFlags(i->rates, 0)
39681 | set11nRateFlags(i->rates, 1)
39682 | set11nRateFlags(i->rates, 2)
39683 | set11nRateFlags(i->rates, 3)
39684 diff --git a/drivers/net/wireless/ath/ath9k/ar9003_mac.c b/drivers/net/wireless/ath/ath9k/ar9003_mac.c
39685 index 301bf72..3f5654f 100644
39686 --- a/drivers/net/wireless/ath/ath9k/ar9003_mac.c
39687 +++ b/drivers/net/wireless/ath/ath9k/ar9003_mac.c
39688 @@ -39,47 +39,47 @@ ar9003_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
39689 (i->qcu << AR_TxQcuNum_S) | desc_len;
39690
39691 checksum += val;
39692 - ACCESS_ONCE(ads->info) = val;
39693 + ACCESS_ONCE_RW(ads->info) = val;
39694
39695 checksum += i->link;
39696 - ACCESS_ONCE(ads->link) = i->link;
39697 + ACCESS_ONCE_RW(ads->link) = i->link;
39698
39699 checksum += i->buf_addr[0];
39700 - ACCESS_ONCE(ads->data0) = i->buf_addr[0];
39701 + ACCESS_ONCE_RW(ads->data0) = i->buf_addr[0];
39702 checksum += i->buf_addr[1];
39703 - ACCESS_ONCE(ads->data1) = i->buf_addr[1];
39704 + ACCESS_ONCE_RW(ads->data1) = i->buf_addr[1];
39705 checksum += i->buf_addr[2];
39706 - ACCESS_ONCE(ads->data2) = i->buf_addr[2];
39707 + ACCESS_ONCE_RW(ads->data2) = i->buf_addr[2];
39708 checksum += i->buf_addr[3];
39709 - ACCESS_ONCE(ads->data3) = i->buf_addr[3];
39710 + ACCESS_ONCE_RW(ads->data3) = i->buf_addr[3];
39711
39712 checksum += (val = (i->buf_len[0] << AR_BufLen_S) & AR_BufLen);
39713 - ACCESS_ONCE(ads->ctl3) = val;
39714 + ACCESS_ONCE_RW(ads->ctl3) = val;
39715 checksum += (val = (i->buf_len[1] << AR_BufLen_S) & AR_BufLen);
39716 - ACCESS_ONCE(ads->ctl5) = val;
39717 + ACCESS_ONCE_RW(ads->ctl5) = val;
39718 checksum += (val = (i->buf_len[2] << AR_BufLen_S) & AR_BufLen);
39719 - ACCESS_ONCE(ads->ctl7) = val;
39720 + ACCESS_ONCE_RW(ads->ctl7) = val;
39721 checksum += (val = (i->buf_len[3] << AR_BufLen_S) & AR_BufLen);
39722 - ACCESS_ONCE(ads->ctl9) = val;
39723 + ACCESS_ONCE_RW(ads->ctl9) = val;
39724
39725 checksum = (u16) (((checksum & 0xffff) + (checksum >> 16)) & 0xffff);
39726 - ACCESS_ONCE(ads->ctl10) = checksum;
39727 + ACCESS_ONCE_RW(ads->ctl10) = checksum;
39728
39729 if (i->is_first || i->is_last) {
39730 - ACCESS_ONCE(ads->ctl13) = set11nTries(i->rates, 0)
39731 + ACCESS_ONCE_RW(ads->ctl13) = set11nTries(i->rates, 0)
39732 | set11nTries(i->rates, 1)
39733 | set11nTries(i->rates, 2)
39734 | set11nTries(i->rates, 3)
39735 | (i->dur_update ? AR_DurUpdateEna : 0)
39736 | SM(0, AR_BurstDur);
39737
39738 - ACCESS_ONCE(ads->ctl14) = set11nRate(i->rates, 0)
39739 + ACCESS_ONCE_RW(ads->ctl14) = set11nRate(i->rates, 0)
39740 | set11nRate(i->rates, 1)
39741 | set11nRate(i->rates, 2)
39742 | set11nRate(i->rates, 3);
39743 } else {
39744 - ACCESS_ONCE(ads->ctl13) = 0;
39745 - ACCESS_ONCE(ads->ctl14) = 0;
39746 + ACCESS_ONCE_RW(ads->ctl13) = 0;
39747 + ACCESS_ONCE_RW(ads->ctl14) = 0;
39748 }
39749
39750 ads->ctl20 = 0;
39751 @@ -89,17 +89,17 @@ ar9003_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
39752
39753 ctl17 = SM(i->keytype, AR_EncrType);
39754 if (!i->is_first) {
39755 - ACCESS_ONCE(ads->ctl11) = 0;
39756 - ACCESS_ONCE(ads->ctl12) = i->is_last ? 0 : AR_TxMore;
39757 - ACCESS_ONCE(ads->ctl15) = 0;
39758 - ACCESS_ONCE(ads->ctl16) = 0;
39759 - ACCESS_ONCE(ads->ctl17) = ctl17;
39760 - ACCESS_ONCE(ads->ctl18) = 0;
39761 - ACCESS_ONCE(ads->ctl19) = 0;
39762 + ACCESS_ONCE_RW(ads->ctl11) = 0;
39763 + ACCESS_ONCE_RW(ads->ctl12) = i->is_last ? 0 : AR_TxMore;
39764 + ACCESS_ONCE_RW(ads->ctl15) = 0;
39765 + ACCESS_ONCE_RW(ads->ctl16) = 0;
39766 + ACCESS_ONCE_RW(ads->ctl17) = ctl17;
39767 + ACCESS_ONCE_RW(ads->ctl18) = 0;
39768 + ACCESS_ONCE_RW(ads->ctl19) = 0;
39769 return;
39770 }
39771
39772 - ACCESS_ONCE(ads->ctl11) = (i->pkt_len & AR_FrameLen)
39773 + ACCESS_ONCE_RW(ads->ctl11) = (i->pkt_len & AR_FrameLen)
39774 | (i->flags & ATH9K_TXDESC_VMF ? AR_VirtMoreFrag : 0)
39775 | SM(i->txpower, AR_XmitPower)
39776 | (i->flags & ATH9K_TXDESC_VEOL ? AR_VEOL : 0)
39777 @@ -135,22 +135,22 @@ ar9003_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
39778 val = (i->flags & ATH9K_TXDESC_PAPRD) >> ATH9K_TXDESC_PAPRD_S;
39779 ctl12 |= SM(val, AR_PAPRDChainMask);
39780
39781 - ACCESS_ONCE(ads->ctl12) = ctl12;
39782 - ACCESS_ONCE(ads->ctl17) = ctl17;
39783 + ACCESS_ONCE_RW(ads->ctl12) = ctl12;
39784 + ACCESS_ONCE_RW(ads->ctl17) = ctl17;
39785
39786 - ACCESS_ONCE(ads->ctl15) = set11nPktDurRTSCTS(i->rates, 0)
39787 + ACCESS_ONCE_RW(ads->ctl15) = set11nPktDurRTSCTS(i->rates, 0)
39788 | set11nPktDurRTSCTS(i->rates, 1);
39789
39790 - ACCESS_ONCE(ads->ctl16) = set11nPktDurRTSCTS(i->rates, 2)
39791 + ACCESS_ONCE_RW(ads->ctl16) = set11nPktDurRTSCTS(i->rates, 2)
39792 | set11nPktDurRTSCTS(i->rates, 3);
39793
39794 - ACCESS_ONCE(ads->ctl18) = set11nRateFlags(i->rates, 0)
39795 + ACCESS_ONCE_RW(ads->ctl18) = set11nRateFlags(i->rates, 0)
39796 | set11nRateFlags(i->rates, 1)
39797 | set11nRateFlags(i->rates, 2)
39798 | set11nRateFlags(i->rates, 3)
39799 | SM(i->rtscts_rate, AR_RTSCTSRate);
39800
39801 - ACCESS_ONCE(ads->ctl19) = AR_Not_Sounding;
39802 + ACCESS_ONCE_RW(ads->ctl19) = AR_Not_Sounding;
39803 }
39804
39805 static u16 ar9003_calc_ptr_chksum(struct ar9003_txc *ads)
39806 diff --git a/drivers/net/wireless/ath/ath9k/hw.h b/drivers/net/wireless/ath/ath9k/hw.h
39807 index 9d26fc5..60d9f14 100644
39808 --- a/drivers/net/wireless/ath/ath9k/hw.h
39809 +++ b/drivers/net/wireless/ath/ath9k/hw.h
39810 @@ -658,7 +658,7 @@ struct ath_hw_private_ops {
39811
39812 /* ANI */
39813 void (*ani_cache_ini_regs)(struct ath_hw *ah);
39814 -};
39815 +} __no_const;
39816
39817 /**
39818 * struct ath_hw_ops - callbacks used by hardware code and driver code
39819 @@ -688,7 +688,7 @@ struct ath_hw_ops {
39820 void (*antdiv_comb_conf_set)(struct ath_hw *ah,
39821 struct ath_hw_antcomb_conf *antconf);
39822 void (*antctrl_shared_chain_lnadiv)(struct ath_hw *hw, bool enable);
39823 -};
39824 +} __no_const;
39825
39826 struct ath_nf_limits {
39827 s16 max;
39828 diff --git a/drivers/net/wireless/iwlegacy/3945-mac.c b/drivers/net/wireless/iwlegacy/3945-mac.c
39829 index 3726cd6..b655808 100644
39830 --- a/drivers/net/wireless/iwlegacy/3945-mac.c
39831 +++ b/drivers/net/wireless/iwlegacy/3945-mac.c
39832 @@ -3615,7 +3615,9 @@ il3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
39833 */
39834 if (il3945_mod_params.disable_hw_scan) {
39835 D_INFO("Disabling hw_scan\n");
39836 - il3945_mac_ops.hw_scan = NULL;
39837 + pax_open_kernel();
39838 + *(void **)&il3945_mac_ops.hw_scan = NULL;
39839 + pax_close_kernel();
39840 }
39841
39842 D_INFO("*** LOAD DRIVER ***\n");
39843 diff --git a/drivers/net/wireless/iwlwifi/dvm/debugfs.c b/drivers/net/wireless/iwlwifi/dvm/debugfs.c
39844 index 5b9533e..7733880 100644
39845 --- a/drivers/net/wireless/iwlwifi/dvm/debugfs.c
39846 +++ b/drivers/net/wireless/iwlwifi/dvm/debugfs.c
39847 @@ -203,7 +203,7 @@ static ssize_t iwl_dbgfs_sram_write(struct file *file,
39848 {
39849 struct iwl_priv *priv = file->private_data;
39850 char buf[64];
39851 - int buf_size;
39852 + size_t buf_size;
39853 u32 offset, len;
39854
39855 memset(buf, 0, sizeof(buf));
39856 @@ -473,7 +473,7 @@ static ssize_t iwl_dbgfs_rx_handlers_write(struct file *file,
39857 struct iwl_priv *priv = file->private_data;
39858
39859 char buf[8];
39860 - int buf_size;
39861 + size_t buf_size;
39862 u32 reset_flag;
39863
39864 memset(buf, 0, sizeof(buf));
39865 @@ -554,7 +554,7 @@ static ssize_t iwl_dbgfs_disable_ht40_write(struct file *file,
39866 {
39867 struct iwl_priv *priv = file->private_data;
39868 char buf[8];
39869 - int buf_size;
39870 + size_t buf_size;
39871 int ht40;
39872
39873 memset(buf, 0, sizeof(buf));
39874 @@ -606,7 +606,7 @@ static ssize_t iwl_dbgfs_sleep_level_override_write(struct file *file,
39875 {
39876 struct iwl_priv *priv = file->private_data;
39877 char buf[8];
39878 - int buf_size;
39879 + size_t buf_size;
39880 int value;
39881
39882 memset(buf, 0, sizeof(buf));
39883 @@ -1871,7 +1871,7 @@ static ssize_t iwl_dbgfs_clear_ucode_statistics_write(struct file *file,
39884 {
39885 struct iwl_priv *priv = file->private_data;
39886 char buf[8];
39887 - int buf_size;
39888 + size_t buf_size;
39889 int clear;
39890
39891 memset(buf, 0, sizeof(buf));
39892 @@ -1916,7 +1916,7 @@ static ssize_t iwl_dbgfs_ucode_tracing_write(struct file *file,
39893 {
39894 struct iwl_priv *priv = file->private_data;
39895 char buf[8];
39896 - int buf_size;
39897 + size_t buf_size;
39898 int trace;
39899
39900 memset(buf, 0, sizeof(buf));
39901 @@ -1987,7 +1987,7 @@ static ssize_t iwl_dbgfs_missed_beacon_write(struct file *file,
39902 {
39903 struct iwl_priv *priv = file->private_data;
39904 char buf[8];
39905 - int buf_size;
39906 + size_t buf_size;
39907 int missed;
39908
39909 memset(buf, 0, sizeof(buf));
39910 @@ -2028,7 +2028,7 @@ static ssize_t iwl_dbgfs_plcp_delta_write(struct file *file,
39911
39912 struct iwl_priv *priv = file->private_data;
39913 char buf[8];
39914 - int buf_size;
39915 + size_t buf_size;
39916 int plcp;
39917
39918 memset(buf, 0, sizeof(buf));
39919 @@ -2088,7 +2088,7 @@ static ssize_t iwl_dbgfs_txfifo_flush_write(struct file *file,
39920
39921 struct iwl_priv *priv = file->private_data;
39922 char buf[8];
39923 - int buf_size;
39924 + size_t buf_size;
39925 int flush;
39926
39927 memset(buf, 0, sizeof(buf));
39928 @@ -2178,7 +2178,7 @@ static ssize_t iwl_dbgfs_protection_mode_write(struct file *file,
39929
39930 struct iwl_priv *priv = file->private_data;
39931 char buf[8];
39932 - int buf_size;
39933 + size_t buf_size;
39934 int rts;
39935
39936 if (!priv->cfg->ht_params)
39937 @@ -2220,7 +2220,7 @@ static ssize_t iwl_dbgfs_echo_test_write(struct file *file,
39938 {
39939 struct iwl_priv *priv = file->private_data;
39940 char buf[8];
39941 - int buf_size;
39942 + size_t buf_size;
39943
39944 memset(buf, 0, sizeof(buf));
39945 buf_size = min(count, sizeof(buf) - 1);
39946 @@ -2256,7 +2256,7 @@ static ssize_t iwl_dbgfs_log_event_write(struct file *file,
39947 struct iwl_priv *priv = file->private_data;
39948 u32 event_log_flag;
39949 char buf[8];
39950 - int buf_size;
39951 + size_t buf_size;
39952
39953 /* check that the interface is up */
39954 if (!iwl_is_ready(priv))
39955 @@ -2310,7 +2310,7 @@ static ssize_t iwl_dbgfs_calib_disabled_write(struct file *file,
39956 struct iwl_priv *priv = file->private_data;
39957 char buf[8];
39958 u32 calib_disabled;
39959 - int buf_size;
39960 + size_t buf_size;
39961
39962 memset(buf, 0, sizeof(buf));
39963 buf_size = min(count, sizeof(buf) - 1);
39964 diff --git a/drivers/net/wireless/iwlwifi/pcie/trans.c b/drivers/net/wireless/iwlwifi/pcie/trans.c
39965 index 35708b9..31f7754 100644
39966 --- a/drivers/net/wireless/iwlwifi/pcie/trans.c
39967 +++ b/drivers/net/wireless/iwlwifi/pcie/trans.c
39968 @@ -1100,7 +1100,7 @@ static ssize_t iwl_dbgfs_interrupt_write(struct file *file,
39969 struct isr_statistics *isr_stats = &trans_pcie->isr_stats;
39970
39971 char buf[8];
39972 - int buf_size;
39973 + size_t buf_size;
39974 u32 reset_flag;
39975
39976 memset(buf, 0, sizeof(buf));
39977 @@ -1121,7 +1121,7 @@ static ssize_t iwl_dbgfs_csr_write(struct file *file,
39978 {
39979 struct iwl_trans *trans = file->private_data;
39980 char buf[8];
39981 - int buf_size;
39982 + size_t buf_size;
39983 int csr;
39984
39985 memset(buf, 0, sizeof(buf));
39986 diff --git a/drivers/net/wireless/mac80211_hwsim.c b/drivers/net/wireless/mac80211_hwsim.c
39987 index ff90855..e46d223 100644
39988 --- a/drivers/net/wireless/mac80211_hwsim.c
39989 +++ b/drivers/net/wireless/mac80211_hwsim.c
39990 @@ -2062,25 +2062,19 @@ static int __init init_mac80211_hwsim(void)
39991
39992 if (channels > 1) {
39993 hwsim_if_comb.num_different_channels = channels;
39994 - mac80211_hwsim_ops.hw_scan = mac80211_hwsim_hw_scan;
39995 - mac80211_hwsim_ops.cancel_hw_scan =
39996 - mac80211_hwsim_cancel_hw_scan;
39997 - mac80211_hwsim_ops.sw_scan_start = NULL;
39998 - mac80211_hwsim_ops.sw_scan_complete = NULL;
39999 - mac80211_hwsim_ops.remain_on_channel =
40000 - mac80211_hwsim_roc;
40001 - mac80211_hwsim_ops.cancel_remain_on_channel =
40002 - mac80211_hwsim_croc;
40003 - mac80211_hwsim_ops.add_chanctx =
40004 - mac80211_hwsim_add_chanctx;
40005 - mac80211_hwsim_ops.remove_chanctx =
40006 - mac80211_hwsim_remove_chanctx;
40007 - mac80211_hwsim_ops.change_chanctx =
40008 - mac80211_hwsim_change_chanctx;
40009 - mac80211_hwsim_ops.assign_vif_chanctx =
40010 - mac80211_hwsim_assign_vif_chanctx;
40011 - mac80211_hwsim_ops.unassign_vif_chanctx =
40012 - mac80211_hwsim_unassign_vif_chanctx;
40013 + pax_open_kernel();
40014 + *(void **)&mac80211_hwsim_ops.hw_scan = mac80211_hwsim_hw_scan;
40015 + *(void **)&mac80211_hwsim_ops.cancel_hw_scan = mac80211_hwsim_cancel_hw_scan;
40016 + *(void **)&mac80211_hwsim_ops.sw_scan_start = NULL;
40017 + *(void **)&mac80211_hwsim_ops.sw_scan_complete = NULL;
40018 + *(void **)&mac80211_hwsim_ops.remain_on_channel = mac80211_hwsim_roc;
40019 + *(void **)&mac80211_hwsim_ops.cancel_remain_on_channel = mac80211_hwsim_croc;
40020 + *(void **)&mac80211_hwsim_ops.add_chanctx = mac80211_hwsim_add_chanctx;
40021 + *(void **)&mac80211_hwsim_ops.remove_chanctx = mac80211_hwsim_remove_chanctx;
40022 + *(void **)&mac80211_hwsim_ops.change_chanctx = mac80211_hwsim_change_chanctx;
40023 + *(void **)&mac80211_hwsim_ops.assign_vif_chanctx = mac80211_hwsim_assign_vif_chanctx;
40024 + *(void **)&mac80211_hwsim_ops.unassign_vif_chanctx = mac80211_hwsim_unassign_vif_chanctx;
40025 + pax_close_kernel();
40026 }
40027
40028 spin_lock_init(&hwsim_radio_lock);
40029 diff --git a/drivers/net/wireless/rndis_wlan.c b/drivers/net/wireless/rndis_wlan.c
40030 index abe1d03..fb02c22 100644
40031 --- a/drivers/net/wireless/rndis_wlan.c
40032 +++ b/drivers/net/wireless/rndis_wlan.c
40033 @@ -1238,7 +1238,7 @@ static int set_rts_threshold(struct usbnet *usbdev, u32 rts_threshold)
40034
40035 netdev_dbg(usbdev->net, "%s(): %i\n", __func__, rts_threshold);
40036
40037 - if (rts_threshold < 0 || rts_threshold > 2347)
40038 + if (rts_threshold > 2347)
40039 rts_threshold = 2347;
40040
40041 tmp = cpu_to_le32(rts_threshold);
40042 diff --git a/drivers/net/wireless/rt2x00/rt2x00.h b/drivers/net/wireless/rt2x00/rt2x00.h
40043 index 0751b35..246ba3e 100644
40044 --- a/drivers/net/wireless/rt2x00/rt2x00.h
40045 +++ b/drivers/net/wireless/rt2x00/rt2x00.h
40046 @@ -398,7 +398,7 @@ struct rt2x00_intf {
40047 * for hardware which doesn't support hardware
40048 * sequence counting.
40049 */
40050 - atomic_t seqno;
40051 + atomic_unchecked_t seqno;
40052 };
40053
40054 static inline struct rt2x00_intf* vif_to_intf(struct ieee80211_vif *vif)
40055 diff --git a/drivers/net/wireless/rt2x00/rt2x00queue.c b/drivers/net/wireless/rt2x00/rt2x00queue.c
40056 index e488b94..14b6a0c 100644
40057 --- a/drivers/net/wireless/rt2x00/rt2x00queue.c
40058 +++ b/drivers/net/wireless/rt2x00/rt2x00queue.c
40059 @@ -240,9 +240,9 @@ static void rt2x00queue_create_tx_descriptor_seq(struct rt2x00_dev *rt2x00dev,
40060 * sequence counter given by mac80211.
40061 */
40062 if (test_bit(ENTRY_TXD_FIRST_FRAGMENT, &txdesc->flags))
40063 - seqno = atomic_add_return(0x10, &intf->seqno);
40064 + seqno = atomic_add_return_unchecked(0x10, &intf->seqno);
40065 else
40066 - seqno = atomic_read(&intf->seqno);
40067 + seqno = atomic_read_unchecked(&intf->seqno);
40068
40069 hdr->seq_ctrl &= cpu_to_le16(IEEE80211_SCTL_FRAG);
40070 hdr->seq_ctrl |= cpu_to_le16(seqno);
40071 diff --git a/drivers/net/wireless/ti/wl1251/sdio.c b/drivers/net/wireless/ti/wl1251/sdio.c
40072 index e57ee48..541cf6c 100644
40073 --- a/drivers/net/wireless/ti/wl1251/sdio.c
40074 +++ b/drivers/net/wireless/ti/wl1251/sdio.c
40075 @@ -269,13 +269,17 @@ static int wl1251_sdio_probe(struct sdio_func *func,
40076
40077 irq_set_irq_type(wl->irq, IRQ_TYPE_EDGE_RISING);
40078
40079 - wl1251_sdio_ops.enable_irq = wl1251_enable_line_irq;
40080 - wl1251_sdio_ops.disable_irq = wl1251_disable_line_irq;
40081 + pax_open_kernel();
40082 + *(void **)&wl1251_sdio_ops.enable_irq = wl1251_enable_line_irq;
40083 + *(void **)&wl1251_sdio_ops.disable_irq = wl1251_disable_line_irq;
40084 + pax_close_kernel();
40085
40086 wl1251_info("using dedicated interrupt line");
40087 } else {
40088 - wl1251_sdio_ops.enable_irq = wl1251_sdio_enable_irq;
40089 - wl1251_sdio_ops.disable_irq = wl1251_sdio_disable_irq;
40090 + pax_open_kernel();
40091 + *(void **)&wl1251_sdio_ops.enable_irq = wl1251_sdio_enable_irq;
40092 + *(void **)&wl1251_sdio_ops.disable_irq = wl1251_sdio_disable_irq;
40093 + pax_close_kernel();
40094
40095 wl1251_info("using SDIO interrupt");
40096 }
40097 diff --git a/drivers/net/wireless/ti/wl12xx/main.c b/drivers/net/wireless/ti/wl12xx/main.c
40098 index e5f5f8f..fdf15b7 100644
40099 --- a/drivers/net/wireless/ti/wl12xx/main.c
40100 +++ b/drivers/net/wireless/ti/wl12xx/main.c
40101 @@ -644,7 +644,9 @@ static int wl12xx_identify_chip(struct wl1271 *wl)
40102 sizeof(wl->conf.mem));
40103
40104 /* read data preparation is only needed by wl127x */
40105 - wl->ops->prepare_read = wl127x_prepare_read;
40106 + pax_open_kernel();
40107 + *(void **)&wl->ops->prepare_read = wl127x_prepare_read;
40108 + pax_close_kernel();
40109
40110 wlcore_set_min_fw_ver(wl, WL127X_CHIP_VER, WL127X_IFTYPE_VER,
40111 WL127X_MAJOR_VER, WL127X_SUBTYPE_VER,
40112 @@ -665,7 +667,9 @@ static int wl12xx_identify_chip(struct wl1271 *wl)
40113 sizeof(wl->conf.mem));
40114
40115 /* read data preparation is only needed by wl127x */
40116 - wl->ops->prepare_read = wl127x_prepare_read;
40117 + pax_open_kernel();
40118 + *(void **)&wl->ops->prepare_read = wl127x_prepare_read;
40119 + pax_close_kernel();
40120
40121 wlcore_set_min_fw_ver(wl, WL127X_CHIP_VER, WL127X_IFTYPE_VER,
40122 WL127X_MAJOR_VER, WL127X_SUBTYPE_VER,
40123 diff --git a/drivers/net/wireless/ti/wl18xx/main.c b/drivers/net/wireless/ti/wl18xx/main.c
40124 index 8d8c1f8..e754844 100644
40125 --- a/drivers/net/wireless/ti/wl18xx/main.c
40126 +++ b/drivers/net/wireless/ti/wl18xx/main.c
40127 @@ -1489,8 +1489,10 @@ static int wl18xx_setup(struct wl1271 *wl)
40128 }
40129
40130 if (!checksum_param) {
40131 - wl18xx_ops.set_rx_csum = NULL;
40132 - wl18xx_ops.init_vif = NULL;
40133 + pax_open_kernel();
40134 + *(void **)&wl18xx_ops.set_rx_csum = NULL;
40135 + *(void **)&wl18xx_ops.init_vif = NULL;
40136 + pax_close_kernel();
40137 }
40138
40139 /* Enable 11a Band only if we have 5G antennas */
40140 diff --git a/drivers/oprofile/buffer_sync.c b/drivers/oprofile/buffer_sync.c
40141 index d93b2b6..ae50401 100644
40142 --- a/drivers/oprofile/buffer_sync.c
40143 +++ b/drivers/oprofile/buffer_sync.c
40144 @@ -332,7 +332,7 @@ static void add_data(struct op_entry *entry, struct mm_struct *mm)
40145 if (cookie == NO_COOKIE)
40146 offset = pc;
40147 if (cookie == INVALID_COOKIE) {
40148 - atomic_inc(&oprofile_stats.sample_lost_no_mapping);
40149 + atomic_inc_unchecked(&oprofile_stats.sample_lost_no_mapping);
40150 offset = pc;
40151 }
40152 if (cookie != last_cookie) {
40153 @@ -376,14 +376,14 @@ add_sample(struct mm_struct *mm, struct op_sample *s, int in_kernel)
40154 /* add userspace sample */
40155
40156 if (!mm) {
40157 - atomic_inc(&oprofile_stats.sample_lost_no_mm);
40158 + atomic_inc_unchecked(&oprofile_stats.sample_lost_no_mm);
40159 return 0;
40160 }
40161
40162 cookie = lookup_dcookie(mm, s->eip, &offset);
40163
40164 if (cookie == INVALID_COOKIE) {
40165 - atomic_inc(&oprofile_stats.sample_lost_no_mapping);
40166 + atomic_inc_unchecked(&oprofile_stats.sample_lost_no_mapping);
40167 return 0;
40168 }
40169
40170 @@ -552,7 +552,7 @@ void sync_buffer(int cpu)
40171 /* ignore backtraces if failed to add a sample */
40172 if (state == sb_bt_start) {
40173 state = sb_bt_ignore;
40174 - atomic_inc(&oprofile_stats.bt_lost_no_mapping);
40175 + atomic_inc_unchecked(&oprofile_stats.bt_lost_no_mapping);
40176 }
40177 }
40178 release_mm(mm);
40179 diff --git a/drivers/oprofile/event_buffer.c b/drivers/oprofile/event_buffer.c
40180 index c0cc4e7..44d4e54 100644
40181 --- a/drivers/oprofile/event_buffer.c
40182 +++ b/drivers/oprofile/event_buffer.c
40183 @@ -53,7 +53,7 @@ void add_event_entry(unsigned long value)
40184 }
40185
40186 if (buffer_pos == buffer_size) {
40187 - atomic_inc(&oprofile_stats.event_lost_overflow);
40188 + atomic_inc_unchecked(&oprofile_stats.event_lost_overflow);
40189 return;
40190 }
40191
40192 diff --git a/drivers/oprofile/oprof.c b/drivers/oprofile/oprof.c
40193 index ed2c3ec..deda85a 100644
40194 --- a/drivers/oprofile/oprof.c
40195 +++ b/drivers/oprofile/oprof.c
40196 @@ -110,7 +110,7 @@ static void switch_worker(struct work_struct *work)
40197 if (oprofile_ops.switch_events())
40198 return;
40199
40200 - atomic_inc(&oprofile_stats.multiplex_counter);
40201 + atomic_inc_unchecked(&oprofile_stats.multiplex_counter);
40202 start_switch_worker();
40203 }
40204
40205 diff --git a/drivers/oprofile/oprofile_files.c b/drivers/oprofile/oprofile_files.c
40206 index 84a208d..d61b0a1 100644
40207 --- a/drivers/oprofile/oprofile_files.c
40208 +++ b/drivers/oprofile/oprofile_files.c
40209 @@ -27,7 +27,7 @@ unsigned long oprofile_time_slice;
40210
40211 #ifdef CONFIG_OPROFILE_EVENT_MULTIPLEX
40212
40213 -static ssize_t timeout_read(struct file *file, char __user *buf,
40214 +static ssize_t __intentional_overflow(-1) timeout_read(struct file *file, char __user *buf,
40215 size_t count, loff_t *offset)
40216 {
40217 return oprofilefs_ulong_to_user(jiffies_to_msecs(oprofile_time_slice),
40218 diff --git a/drivers/oprofile/oprofile_stats.c b/drivers/oprofile/oprofile_stats.c
40219 index 917d28e..d62d981 100644
40220 --- a/drivers/oprofile/oprofile_stats.c
40221 +++ b/drivers/oprofile/oprofile_stats.c
40222 @@ -30,11 +30,11 @@ void oprofile_reset_stats(void)
40223 cpu_buf->sample_invalid_eip = 0;
40224 }
40225
40226 - atomic_set(&oprofile_stats.sample_lost_no_mm, 0);
40227 - atomic_set(&oprofile_stats.sample_lost_no_mapping, 0);
40228 - atomic_set(&oprofile_stats.event_lost_overflow, 0);
40229 - atomic_set(&oprofile_stats.bt_lost_no_mapping, 0);
40230 - atomic_set(&oprofile_stats.multiplex_counter, 0);
40231 + atomic_set_unchecked(&oprofile_stats.sample_lost_no_mm, 0);
40232 + atomic_set_unchecked(&oprofile_stats.sample_lost_no_mapping, 0);
40233 + atomic_set_unchecked(&oprofile_stats.event_lost_overflow, 0);
40234 + atomic_set_unchecked(&oprofile_stats.bt_lost_no_mapping, 0);
40235 + atomic_set_unchecked(&oprofile_stats.multiplex_counter, 0);
40236 }
40237
40238
40239 diff --git a/drivers/oprofile/oprofile_stats.h b/drivers/oprofile/oprofile_stats.h
40240 index 38b6fc0..b5cbfce 100644
40241 --- a/drivers/oprofile/oprofile_stats.h
40242 +++ b/drivers/oprofile/oprofile_stats.h
40243 @@ -13,11 +13,11 @@
40244 #include <linux/atomic.h>
40245
40246 struct oprofile_stat_struct {
40247 - atomic_t sample_lost_no_mm;
40248 - atomic_t sample_lost_no_mapping;
40249 - atomic_t bt_lost_no_mapping;
40250 - atomic_t event_lost_overflow;
40251 - atomic_t multiplex_counter;
40252 + atomic_unchecked_t sample_lost_no_mm;
40253 + atomic_unchecked_t sample_lost_no_mapping;
40254 + atomic_unchecked_t bt_lost_no_mapping;
40255 + atomic_unchecked_t event_lost_overflow;
40256 + atomic_unchecked_t multiplex_counter;
40257 };
40258
40259 extern struct oprofile_stat_struct oprofile_stats;
40260 diff --git a/drivers/oprofile/oprofilefs.c b/drivers/oprofile/oprofilefs.c
40261 index 849357c..b83c1e0 100644
40262 --- a/drivers/oprofile/oprofilefs.c
40263 +++ b/drivers/oprofile/oprofilefs.c
40264 @@ -185,7 +185,7 @@ static const struct file_operations atomic_ro_fops = {
40265
40266
40267 int oprofilefs_create_ro_atomic(struct super_block *sb, struct dentry *root,
40268 - char const *name, atomic_t *val)
40269 + char const *name, atomic_unchecked_t *val)
40270 {
40271 return __oprofilefs_create_file(sb, root, name,
40272 &atomic_ro_fops, 0444, val);
40273 diff --git a/drivers/oprofile/timer_int.c b/drivers/oprofile/timer_int.c
40274 index 93404f7..4a313d8 100644
40275 --- a/drivers/oprofile/timer_int.c
40276 +++ b/drivers/oprofile/timer_int.c
40277 @@ -93,7 +93,7 @@ static int __cpuinit oprofile_cpu_notify(struct notifier_block *self,
40278 return NOTIFY_OK;
40279 }
40280
40281 -static struct notifier_block __refdata oprofile_cpu_notifier = {
40282 +static struct notifier_block oprofile_cpu_notifier = {
40283 .notifier_call = oprofile_cpu_notify,
40284 };
40285
40286 diff --git a/drivers/parport/procfs.c b/drivers/parport/procfs.c
40287 index 3f56bc0..707d642 100644
40288 --- a/drivers/parport/procfs.c
40289 +++ b/drivers/parport/procfs.c
40290 @@ -64,7 +64,7 @@ static int do_active_device(ctl_table *table, int write,
40291
40292 *ppos += len;
40293
40294 - return copy_to_user(result, buffer, len) ? -EFAULT : 0;
40295 + return (len > sizeof buffer || copy_to_user(result, buffer, len)) ? -EFAULT : 0;
40296 }
40297
40298 #ifdef CONFIG_PARPORT_1284
40299 @@ -106,7 +106,7 @@ static int do_autoprobe(ctl_table *table, int write,
40300
40301 *ppos += len;
40302
40303 - return copy_to_user (result, buffer, len) ? -EFAULT : 0;
40304 + return (len > sizeof buffer || copy_to_user (result, buffer, len)) ? -EFAULT : 0;
40305 }
40306 #endif /* IEEE1284.3 support. */
40307
40308 diff --git a/drivers/pci/hotplug/acpiphp_ibm.c b/drivers/pci/hotplug/acpiphp_ibm.c
40309 index c35e8ad..fc33beb 100644
40310 --- a/drivers/pci/hotplug/acpiphp_ibm.c
40311 +++ b/drivers/pci/hotplug/acpiphp_ibm.c
40312 @@ -464,7 +464,9 @@ static int __init ibm_acpiphp_init(void)
40313 goto init_cleanup;
40314 }
40315
40316 - ibm_apci_table_attr.size = ibm_get_table_from_acpi(NULL);
40317 + pax_open_kernel();
40318 + *(size_t *)&ibm_apci_table_attr.size = ibm_get_table_from_acpi(NULL);
40319 + pax_close_kernel();
40320 retval = sysfs_create_bin_file(sysdir, &ibm_apci_table_attr);
40321
40322 return retval;
40323 diff --git a/drivers/pci/hotplug/cpcihp_generic.c b/drivers/pci/hotplug/cpcihp_generic.c
40324 index a6a71c4..c91097b 100644
40325 --- a/drivers/pci/hotplug/cpcihp_generic.c
40326 +++ b/drivers/pci/hotplug/cpcihp_generic.c
40327 @@ -73,7 +73,6 @@ static u16 port;
40328 static unsigned int enum_bit;
40329 static u8 enum_mask;
40330
40331 -static struct cpci_hp_controller_ops generic_hpc_ops;
40332 static struct cpci_hp_controller generic_hpc;
40333
40334 static int __init validate_parameters(void)
40335 @@ -139,6 +138,10 @@ static int query_enum(void)
40336 return ((value & enum_mask) == enum_mask);
40337 }
40338
40339 +static struct cpci_hp_controller_ops generic_hpc_ops = {
40340 + .query_enum = query_enum,
40341 +};
40342 +
40343 static int __init cpcihp_generic_init(void)
40344 {
40345 int status;
40346 @@ -165,7 +168,6 @@ static int __init cpcihp_generic_init(void)
40347 pci_dev_put(dev);
40348
40349 memset(&generic_hpc, 0, sizeof (struct cpci_hp_controller));
40350 - generic_hpc_ops.query_enum = query_enum;
40351 generic_hpc.ops = &generic_hpc_ops;
40352
40353 status = cpci_hp_register_controller(&generic_hpc);
40354 diff --git a/drivers/pci/hotplug/cpcihp_zt5550.c b/drivers/pci/hotplug/cpcihp_zt5550.c
40355 index 449b4bb..257e2e8 100644
40356 --- a/drivers/pci/hotplug/cpcihp_zt5550.c
40357 +++ b/drivers/pci/hotplug/cpcihp_zt5550.c
40358 @@ -59,7 +59,6 @@
40359 /* local variables */
40360 static bool debug;
40361 static bool poll;
40362 -static struct cpci_hp_controller_ops zt5550_hpc_ops;
40363 static struct cpci_hp_controller zt5550_hpc;
40364
40365 /* Primary cPCI bus bridge device */
40366 @@ -205,6 +204,10 @@ static int zt5550_hc_disable_irq(void)
40367 return 0;
40368 }
40369
40370 +static struct cpci_hp_controller_ops zt5550_hpc_ops = {
40371 + .query_enum = zt5550_hc_query_enum,
40372 +};
40373 +
40374 static int zt5550_hc_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
40375 {
40376 int status;
40377 @@ -216,16 +219,17 @@ static int zt5550_hc_init_one (struct pci_dev *pdev, const struct pci_device_id
40378 dbg("returned from zt5550_hc_config");
40379
40380 memset(&zt5550_hpc, 0, sizeof (struct cpci_hp_controller));
40381 - zt5550_hpc_ops.query_enum = zt5550_hc_query_enum;
40382 zt5550_hpc.ops = &zt5550_hpc_ops;
40383 if(!poll) {
40384 zt5550_hpc.irq = hc_dev->irq;
40385 zt5550_hpc.irq_flags = IRQF_SHARED;
40386 zt5550_hpc.dev_id = hc_dev;
40387
40388 - zt5550_hpc_ops.enable_irq = zt5550_hc_enable_irq;
40389 - zt5550_hpc_ops.disable_irq = zt5550_hc_disable_irq;
40390 - zt5550_hpc_ops.check_irq = zt5550_hc_check_irq;
40391 + pax_open_kernel();
40392 + *(void **)&zt5550_hpc_ops.enable_irq = zt5550_hc_enable_irq;
40393 + *(void **)&zt5550_hpc_ops.disable_irq = zt5550_hc_disable_irq;
40394 + *(void **)&zt5550_hpc_ops.check_irq = zt5550_hc_check_irq;
40395 + pax_open_kernel();
40396 } else {
40397 info("using ENUM# polling mode");
40398 }
40399 diff --git a/drivers/pci/hotplug/cpqphp_nvram.c b/drivers/pci/hotplug/cpqphp_nvram.c
40400 index 76ba8a1..20ca857 100644
40401 --- a/drivers/pci/hotplug/cpqphp_nvram.c
40402 +++ b/drivers/pci/hotplug/cpqphp_nvram.c
40403 @@ -428,9 +428,13 @@ static u32 store_HRT (void __iomem *rom_start)
40404
40405 void compaq_nvram_init (void __iomem *rom_start)
40406 {
40407 +
40408 +#ifndef CONFIG_PAX_KERNEXEC
40409 if (rom_start) {
40410 compaq_int15_entry_point = (rom_start + ROM_INT15_PHY_ADDR - ROM_PHY_ADDR);
40411 }
40412 +#endif
40413 +
40414 dbg("int15 entry = %p\n", compaq_int15_entry_point);
40415
40416 /* initialize our int15 lock */
40417 diff --git a/drivers/pci/hotplug/pci_hotplug_core.c b/drivers/pci/hotplug/pci_hotplug_core.c
40418 index 202f4a9..8ee47d0 100644
40419 --- a/drivers/pci/hotplug/pci_hotplug_core.c
40420 +++ b/drivers/pci/hotplug/pci_hotplug_core.c
40421 @@ -448,8 +448,10 @@ int __pci_hp_register(struct hotplug_slot *slot, struct pci_bus *bus,
40422 return -EINVAL;
40423 }
40424
40425 - slot->ops->owner = owner;
40426 - slot->ops->mod_name = mod_name;
40427 + pax_open_kernel();
40428 + *(struct module **)&slot->ops->owner = owner;
40429 + *(const char **)&slot->ops->mod_name = mod_name;
40430 + pax_close_kernel();
40431
40432 mutex_lock(&pci_hp_mutex);
40433 /*
40434 diff --git a/drivers/pci/hotplug/pciehp_core.c b/drivers/pci/hotplug/pciehp_core.c
40435 index 939bd1d..a1459c9 100644
40436 --- a/drivers/pci/hotplug/pciehp_core.c
40437 +++ b/drivers/pci/hotplug/pciehp_core.c
40438 @@ -91,7 +91,7 @@ static int init_slot(struct controller *ctrl)
40439 struct slot *slot = ctrl->slot;
40440 struct hotplug_slot *hotplug = NULL;
40441 struct hotplug_slot_info *info = NULL;
40442 - struct hotplug_slot_ops *ops = NULL;
40443 + hotplug_slot_ops_no_const *ops = NULL;
40444 char name[SLOT_NAME_SIZE];
40445 int retval = -ENOMEM;
40446
40447 diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
40448 index 9c6e9bb..2916736 100644
40449 --- a/drivers/pci/pci-sysfs.c
40450 +++ b/drivers/pci/pci-sysfs.c
40451 @@ -1071,7 +1071,7 @@ static int pci_create_attr(struct pci_dev *pdev, int num, int write_combine)
40452 {
40453 /* allocate attribute structure, piggyback attribute name */
40454 int name_len = write_combine ? 13 : 10;
40455 - struct bin_attribute *res_attr;
40456 + bin_attribute_no_const *res_attr;
40457 int retval;
40458
40459 res_attr = kzalloc(sizeof(*res_attr) + name_len, GFP_ATOMIC);
40460 @@ -1256,7 +1256,7 @@ static struct device_attribute reset_attr = __ATTR(reset, 0200, NULL, reset_stor
40461 static int pci_create_capabilities_sysfs(struct pci_dev *dev)
40462 {
40463 int retval;
40464 - struct bin_attribute *attr;
40465 + bin_attribute_no_const *attr;
40466
40467 /* If the device has VPD, try to expose it in sysfs. */
40468 if (dev->vpd) {
40469 @@ -1303,7 +1303,7 @@ int __must_check pci_create_sysfs_dev_files (struct pci_dev *pdev)
40470 {
40471 int retval;
40472 int rom_size = 0;
40473 - struct bin_attribute *attr;
40474 + bin_attribute_no_const *attr;
40475
40476 if (!sysfs_initialized)
40477 return -EACCES;
40478 diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
40479 index e851829..a1a7196 100644
40480 --- a/drivers/pci/pci.h
40481 +++ b/drivers/pci/pci.h
40482 @@ -98,7 +98,7 @@ struct pci_vpd_ops {
40483 struct pci_vpd {
40484 unsigned int len;
40485 const struct pci_vpd_ops *ops;
40486 - struct bin_attribute *attr; /* descriptor for sysfs VPD entry */
40487 + bin_attribute_no_const *attr; /* descriptor for sysfs VPD entry */
40488 };
40489
40490 extern int pci_vpd_pci22_init(struct pci_dev *dev);
40491 diff --git a/drivers/pci/pcie/aspm.c b/drivers/pci/pcie/aspm.c
40492 index 8474b6a..ee81993 100644
40493 --- a/drivers/pci/pcie/aspm.c
40494 +++ b/drivers/pci/pcie/aspm.c
40495 @@ -27,9 +27,9 @@
40496 #define MODULE_PARAM_PREFIX "pcie_aspm."
40497
40498 /* Note: those are not register definitions */
40499 -#define ASPM_STATE_L0S_UP (1) /* Upstream direction L0s state */
40500 -#define ASPM_STATE_L0S_DW (2) /* Downstream direction L0s state */
40501 -#define ASPM_STATE_L1 (4) /* L1 state */
40502 +#define ASPM_STATE_L0S_UP (1U) /* Upstream direction L0s state */
40503 +#define ASPM_STATE_L0S_DW (2U) /* Downstream direction L0s state */
40504 +#define ASPM_STATE_L1 (4U) /* L1 state */
40505 #define ASPM_STATE_L0S (ASPM_STATE_L0S_UP | ASPM_STATE_L0S_DW)
40506 #define ASPM_STATE_ALL (ASPM_STATE_L0S | ASPM_STATE_L1)
40507
40508 diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
40509 index 6186f03..1a78714 100644
40510 --- a/drivers/pci/probe.c
40511 +++ b/drivers/pci/probe.c
40512 @@ -173,7 +173,7 @@ int __pci_read_base(struct pci_dev *dev, enum pci_bar_type type,
40513 struct pci_bus_region region;
40514 bool bar_too_big = false, bar_disabled = false;
40515
40516 - mask = type ? PCI_ROM_ADDRESS_MASK : ~0;
40517 + mask = type ? (u32)PCI_ROM_ADDRESS_MASK : ~0;
40518
40519 /* No printks while decoding is disabled! */
40520 if (!dev->mmio_always_on) {
40521 diff --git a/drivers/pci/proc.c b/drivers/pci/proc.c
40522 index 9b8505c..f00870a 100644
40523 --- a/drivers/pci/proc.c
40524 +++ b/drivers/pci/proc.c
40525 @@ -465,7 +465,16 @@ static const struct file_operations proc_bus_pci_dev_operations = {
40526 static int __init pci_proc_init(void)
40527 {
40528 struct pci_dev *dev = NULL;
40529 +
40530 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
40531 +#ifdef CONFIG_GRKERNSEC_PROC_USER
40532 + proc_bus_pci_dir = proc_mkdir_mode("bus/pci", S_IRUSR | S_IXUSR, NULL);
40533 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
40534 + proc_bus_pci_dir = proc_mkdir_mode("bus/pci", S_IRUSR | S_IXUSR | S_IRGRP | S_IXGRP, NULL);
40535 +#endif
40536 +#else
40537 proc_bus_pci_dir = proc_mkdir("bus/pci", NULL);
40538 +#endif
40539 proc_create("devices", 0, proc_bus_pci_dir,
40540 &proc_bus_pci_dev_operations);
40541 proc_initialized = 1;
40542 diff --git a/drivers/platform/x86/msi-laptop.c b/drivers/platform/x86/msi-laptop.c
40543 index 2111dbb..79e434b 100644
40544 --- a/drivers/platform/x86/msi-laptop.c
40545 +++ b/drivers/platform/x86/msi-laptop.c
40546 @@ -820,12 +820,14 @@ static int __init load_scm_model_init(struct platform_device *sdev)
40547 int result;
40548
40549 /* allow userland write sysfs file */
40550 - dev_attr_bluetooth.store = store_bluetooth;
40551 - dev_attr_wlan.store = store_wlan;
40552 - dev_attr_threeg.store = store_threeg;
40553 - dev_attr_bluetooth.attr.mode |= S_IWUSR;
40554 - dev_attr_wlan.attr.mode |= S_IWUSR;
40555 - dev_attr_threeg.attr.mode |= S_IWUSR;
40556 + pax_open_kernel();
40557 + *(void **)&dev_attr_bluetooth.store = store_bluetooth;
40558 + *(void **)&dev_attr_wlan.store = store_wlan;
40559 + *(void **)&dev_attr_threeg.store = store_threeg;
40560 + *(umode_t *)&dev_attr_bluetooth.attr.mode |= S_IWUSR;
40561 + *(umode_t *)&dev_attr_wlan.attr.mode |= S_IWUSR;
40562 + *(umode_t *)&dev_attr_threeg.attr.mode |= S_IWUSR;
40563 + pax_close_kernel();
40564
40565 /* disable hardware control by fn key */
40566 result = ec_read(MSI_STANDARD_EC_SCM_LOAD_ADDRESS, &data);
40567 diff --git a/drivers/platform/x86/sony-laptop.c b/drivers/platform/x86/sony-laptop.c
40568 index 0fe987f..6f3d5c3 100644
40569 --- a/drivers/platform/x86/sony-laptop.c
40570 +++ b/drivers/platform/x86/sony-laptop.c
40571 @@ -2356,7 +2356,7 @@ static void sony_nc_lid_resume_cleanup(struct platform_device *pd)
40572 }
40573
40574 /* High speed charging function */
40575 -static struct device_attribute *hsc_handle;
40576 +static device_attribute_no_const *hsc_handle;
40577
40578 static ssize_t sony_nc_highspeed_charging_store(struct device *dev,
40579 struct device_attribute *attr,
40580 diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c
40581 index f946ca7..f25c833 100644
40582 --- a/drivers/platform/x86/thinkpad_acpi.c
40583 +++ b/drivers/platform/x86/thinkpad_acpi.c
40584 @@ -2097,7 +2097,7 @@ static int hotkey_mask_get(void)
40585 return 0;
40586 }
40587
40588 -void static hotkey_mask_warn_incomplete_mask(void)
40589 +static void hotkey_mask_warn_incomplete_mask(void)
40590 {
40591 /* log only what the user can fix... */
40592 const u32 wantedmask = hotkey_driver_mask &
40593 @@ -2328,11 +2328,6 @@ static void hotkey_read_nvram(struct tp_nvram_state *n, const u32 m)
40594 }
40595 }
40596
40597 -static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
40598 - struct tp_nvram_state *newn,
40599 - const u32 event_mask)
40600 -{
40601 -
40602 #define TPACPI_COMPARE_KEY(__scancode, __member) \
40603 do { \
40604 if ((event_mask & (1 << __scancode)) && \
40605 @@ -2346,36 +2341,42 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
40606 tpacpi_hotkey_send_key(__scancode); \
40607 } while (0)
40608
40609 - void issue_volchange(const unsigned int oldvol,
40610 - const unsigned int newvol)
40611 - {
40612 - unsigned int i = oldvol;
40613 +static void issue_volchange(const unsigned int oldvol,
40614 + const unsigned int newvol,
40615 + const u32 event_mask)
40616 +{
40617 + unsigned int i = oldvol;
40618
40619 - while (i > newvol) {
40620 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEDOWN);
40621 - i--;
40622 - }
40623 - while (i < newvol) {
40624 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEUP);
40625 - i++;
40626 - }
40627 + while (i > newvol) {
40628 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEDOWN);
40629 + i--;
40630 }
40631 + while (i < newvol) {
40632 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEUP);
40633 + i++;
40634 + }
40635 +}
40636
40637 - void issue_brightnesschange(const unsigned int oldbrt,
40638 - const unsigned int newbrt)
40639 - {
40640 - unsigned int i = oldbrt;
40641 +static void issue_brightnesschange(const unsigned int oldbrt,
40642 + const unsigned int newbrt,
40643 + const u32 event_mask)
40644 +{
40645 + unsigned int i = oldbrt;
40646
40647 - while (i > newbrt) {
40648 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNEND);
40649 - i--;
40650 - }
40651 - while (i < newbrt) {
40652 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNHOME);
40653 - i++;
40654 - }
40655 + while (i > newbrt) {
40656 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNEND);
40657 + i--;
40658 + }
40659 + while (i < newbrt) {
40660 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNHOME);
40661 + i++;
40662 }
40663 +}
40664
40665 +static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
40666 + struct tp_nvram_state *newn,
40667 + const u32 event_mask)
40668 +{
40669 TPACPI_COMPARE_KEY(TP_ACPI_HOTKEYSCAN_THINKPAD, thinkpad_toggle);
40670 TPACPI_COMPARE_KEY(TP_ACPI_HOTKEYSCAN_FNSPACE, zoom_toggle);
40671 TPACPI_COMPARE_KEY(TP_ACPI_HOTKEYSCAN_FNF7, display_toggle);
40672 @@ -2409,7 +2410,7 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
40673 oldn->volume_level != newn->volume_level) {
40674 /* recently muted, or repeated mute keypress, or
40675 * multiple presses ending in mute */
40676 - issue_volchange(oldn->volume_level, newn->volume_level);
40677 + issue_volchange(oldn->volume_level, newn->volume_level, event_mask);
40678 TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_MUTE);
40679 }
40680 } else {
40681 @@ -2419,7 +2420,7 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
40682 TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEUP);
40683 }
40684 if (oldn->volume_level != newn->volume_level) {
40685 - issue_volchange(oldn->volume_level, newn->volume_level);
40686 + issue_volchange(oldn->volume_level, newn->volume_level, event_mask);
40687 } else if (oldn->volume_toggle != newn->volume_toggle) {
40688 /* repeated vol up/down keypress at end of scale ? */
40689 if (newn->volume_level == 0)
40690 @@ -2432,7 +2433,8 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
40691 /* handle brightness */
40692 if (oldn->brightness_level != newn->brightness_level) {
40693 issue_brightnesschange(oldn->brightness_level,
40694 - newn->brightness_level);
40695 + newn->brightness_level,
40696 + event_mask);
40697 } else if (oldn->brightness_toggle != newn->brightness_toggle) {
40698 /* repeated key presses that didn't change state */
40699 if (newn->brightness_level == 0)
40700 @@ -2441,10 +2443,10 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
40701 && !tp_features.bright_unkfw)
40702 TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNHOME);
40703 }
40704 +}
40705
40706 #undef TPACPI_COMPARE_KEY
40707 #undef TPACPI_MAY_SEND_KEY
40708 -}
40709
40710 /*
40711 * Polling driver
40712 diff --git a/drivers/pnp/pnpbios/bioscalls.c b/drivers/pnp/pnpbios/bioscalls.c
40713 index 769d265..a3a05ca 100644
40714 --- a/drivers/pnp/pnpbios/bioscalls.c
40715 +++ b/drivers/pnp/pnpbios/bioscalls.c
40716 @@ -58,7 +58,7 @@ do { \
40717 set_desc_limit(&gdt[(selname) >> 3], (size) - 1); \
40718 } while(0)
40719
40720 -static struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4092,
40721 +static const struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4093,
40722 (unsigned long)__va(0x400UL), PAGE_SIZE - 0x400 - 1);
40723
40724 /*
40725 @@ -95,7 +95,10 @@ static inline u16 call_pnp_bios(u16 func, u16 arg1, u16 arg2, u16 arg3,
40726
40727 cpu = get_cpu();
40728 save_desc_40 = get_cpu_gdt_table(cpu)[0x40 / 8];
40729 +
40730 + pax_open_kernel();
40731 get_cpu_gdt_table(cpu)[0x40 / 8] = bad_bios_desc;
40732 + pax_close_kernel();
40733
40734 /* On some boxes IRQ's during PnP BIOS calls are deadly. */
40735 spin_lock_irqsave(&pnp_bios_lock, flags);
40736 @@ -133,7 +136,10 @@ static inline u16 call_pnp_bios(u16 func, u16 arg1, u16 arg2, u16 arg3,
40737 :"memory");
40738 spin_unlock_irqrestore(&pnp_bios_lock, flags);
40739
40740 + pax_open_kernel();
40741 get_cpu_gdt_table(cpu)[0x40 / 8] = save_desc_40;
40742 + pax_close_kernel();
40743 +
40744 put_cpu();
40745
40746 /* If we get here and this is set then the PnP BIOS faulted on us. */
40747 @@ -467,7 +473,7 @@ int pnp_bios_read_escd(char *data, u32 nvram_base)
40748 return status;
40749 }
40750
40751 -void pnpbios_calls_init(union pnp_bios_install_struct *header)
40752 +void __init pnpbios_calls_init(union pnp_bios_install_struct *header)
40753 {
40754 int i;
40755
40756 @@ -475,6 +481,8 @@ void pnpbios_calls_init(union pnp_bios_install_struct *header)
40757 pnp_bios_callpoint.offset = header->fields.pm16offset;
40758 pnp_bios_callpoint.segment = PNP_CS16;
40759
40760 + pax_open_kernel();
40761 +
40762 for_each_possible_cpu(i) {
40763 struct desc_struct *gdt = get_cpu_gdt_table(i);
40764 if (!gdt)
40765 @@ -486,4 +494,6 @@ void pnpbios_calls_init(union pnp_bios_install_struct *header)
40766 set_desc_base(&gdt[GDT_ENTRY_PNPBIOS_DS],
40767 (unsigned long)__va(header->fields.pm16dseg));
40768 }
40769 +
40770 + pax_close_kernel();
40771 }
40772 diff --git a/drivers/pnp/resource.c b/drivers/pnp/resource.c
40773 index 3e6db1c..1fbbdae 100644
40774 --- a/drivers/pnp/resource.c
40775 +++ b/drivers/pnp/resource.c
40776 @@ -360,7 +360,7 @@ int pnp_check_irq(struct pnp_dev *dev, struct resource *res)
40777 return 1;
40778
40779 /* check if the resource is valid */
40780 - if (*irq < 0 || *irq > 15)
40781 + if (*irq > 15)
40782 return 0;
40783
40784 /* check if the resource is reserved */
40785 @@ -424,7 +424,7 @@ int pnp_check_dma(struct pnp_dev *dev, struct resource *res)
40786 return 1;
40787
40788 /* check if the resource is valid */
40789 - if (*dma < 0 || *dma == 4 || *dma > 7)
40790 + if (*dma == 4 || *dma > 7)
40791 return 0;
40792
40793 /* check if the resource is reserved */
40794 diff --git a/drivers/power/pda_power.c b/drivers/power/pda_power.c
40795 index 7df7c5f..bd48c47 100644
40796 --- a/drivers/power/pda_power.c
40797 +++ b/drivers/power/pda_power.c
40798 @@ -37,7 +37,11 @@ static int polling;
40799
40800 #ifdef CONFIG_USB_OTG_UTILS
40801 static struct usb_phy *transceiver;
40802 -static struct notifier_block otg_nb;
40803 +static int otg_handle_notification(struct notifier_block *nb,
40804 + unsigned long event, void *unused);
40805 +static struct notifier_block otg_nb = {
40806 + .notifier_call = otg_handle_notification
40807 +};
40808 #endif
40809
40810 static struct regulator *ac_draw;
40811 @@ -369,7 +373,6 @@ static int pda_power_probe(struct platform_device *pdev)
40812
40813 #ifdef CONFIG_USB_OTG_UTILS
40814 if (!IS_ERR_OR_NULL(transceiver) && pdata->use_otg_notifier) {
40815 - otg_nb.notifier_call = otg_handle_notification;
40816 ret = usb_register_notifier(transceiver, &otg_nb);
40817 if (ret) {
40818 dev_err(dev, "failure to register otg notifier\n");
40819 diff --git a/drivers/power/power_supply.h b/drivers/power/power_supply.h
40820 index cc439fd..8fa30df 100644
40821 --- a/drivers/power/power_supply.h
40822 +++ b/drivers/power/power_supply.h
40823 @@ -16,12 +16,12 @@ struct power_supply;
40824
40825 #ifdef CONFIG_SYSFS
40826
40827 -extern void power_supply_init_attrs(struct device_type *dev_type);
40828 +extern void power_supply_init_attrs(void);
40829 extern int power_supply_uevent(struct device *dev, struct kobj_uevent_env *env);
40830
40831 #else
40832
40833 -static inline void power_supply_init_attrs(struct device_type *dev_type) {}
40834 +static inline void power_supply_init_attrs(void) {}
40835 #define power_supply_uevent NULL
40836
40837 #endif /* CONFIG_SYSFS */
40838 diff --git a/drivers/power/power_supply_core.c b/drivers/power/power_supply_core.c
40839 index 8a7cfb3..72e6e9b 100644
40840 --- a/drivers/power/power_supply_core.c
40841 +++ b/drivers/power/power_supply_core.c
40842 @@ -24,7 +24,10 @@
40843 struct class *power_supply_class;
40844 EXPORT_SYMBOL_GPL(power_supply_class);
40845
40846 -static struct device_type power_supply_dev_type;
40847 +extern const struct attribute_group *power_supply_attr_groups[];
40848 +static struct device_type power_supply_dev_type = {
40849 + .groups = power_supply_attr_groups,
40850 +};
40851
40852 static int __power_supply_changed_work(struct device *dev, void *data)
40853 {
40854 @@ -393,7 +396,7 @@ static int __init power_supply_class_init(void)
40855 return PTR_ERR(power_supply_class);
40856
40857 power_supply_class->dev_uevent = power_supply_uevent;
40858 - power_supply_init_attrs(&power_supply_dev_type);
40859 + power_supply_init_attrs();
40860
40861 return 0;
40862 }
40863 diff --git a/drivers/power/power_supply_sysfs.c b/drivers/power/power_supply_sysfs.c
40864 index 40fa3b7..d9c2e0e 100644
40865 --- a/drivers/power/power_supply_sysfs.c
40866 +++ b/drivers/power/power_supply_sysfs.c
40867 @@ -229,17 +229,15 @@ static struct attribute_group power_supply_attr_group = {
40868 .is_visible = power_supply_attr_is_visible,
40869 };
40870
40871 -static const struct attribute_group *power_supply_attr_groups[] = {
40872 +const struct attribute_group *power_supply_attr_groups[] = {
40873 &power_supply_attr_group,
40874 NULL,
40875 };
40876
40877 -void power_supply_init_attrs(struct device_type *dev_type)
40878 +void power_supply_init_attrs(void)
40879 {
40880 int i;
40881
40882 - dev_type->groups = power_supply_attr_groups;
40883 -
40884 for (i = 0; i < ARRAY_SIZE(power_supply_attrs); i++)
40885 __power_supply_attrs[i] = &power_supply_attrs[i].attr;
40886 }
40887 diff --git a/drivers/regulator/max8660.c b/drivers/regulator/max8660.c
40888 index 4d7c635..9860196 100644
40889 --- a/drivers/regulator/max8660.c
40890 +++ b/drivers/regulator/max8660.c
40891 @@ -333,8 +333,10 @@ static int max8660_probe(struct i2c_client *client,
40892 max8660->shadow_regs[MAX8660_OVER1] = 5;
40893 } else {
40894 /* Otherwise devices can be toggled via software */
40895 - max8660_dcdc_ops.enable = max8660_dcdc_enable;
40896 - max8660_dcdc_ops.disable = max8660_dcdc_disable;
40897 + pax_open_kernel();
40898 + *(void **)&max8660_dcdc_ops.enable = max8660_dcdc_enable;
40899 + *(void **)&max8660_dcdc_ops.disable = max8660_dcdc_disable;
40900 + pax_close_kernel();
40901 }
40902
40903 /*
40904 diff --git a/drivers/regulator/max8973-regulator.c b/drivers/regulator/max8973-regulator.c
40905 index 9a8ea91..c483dd9 100644
40906 --- a/drivers/regulator/max8973-regulator.c
40907 +++ b/drivers/regulator/max8973-regulator.c
40908 @@ -401,9 +401,11 @@ static int max8973_probe(struct i2c_client *client,
40909 if (!pdata->enable_ext_control) {
40910 max->desc.enable_reg = MAX8973_VOUT;
40911 max->desc.enable_mask = MAX8973_VOUT_ENABLE;
40912 - max8973_dcdc_ops.enable = regulator_enable_regmap;
40913 - max8973_dcdc_ops.disable = regulator_disable_regmap;
40914 - max8973_dcdc_ops.is_enabled = regulator_is_enabled_regmap;
40915 + pax_open_kernel();
40916 + *(void **)&max8973_dcdc_ops.enable = regulator_enable_regmap;
40917 + *(void **)&max8973_dcdc_ops.disable = regulator_disable_regmap;
40918 + *(void **)&max8973_dcdc_ops.is_enabled = regulator_is_enabled_regmap;
40919 + pax_close_kernel();
40920 }
40921
40922 max->enable_external_control = pdata->enable_ext_control;
40923 diff --git a/drivers/regulator/mc13892-regulator.c b/drivers/regulator/mc13892-regulator.c
40924 index 0d84b1f..c2da6ac 100644
40925 --- a/drivers/regulator/mc13892-regulator.c
40926 +++ b/drivers/regulator/mc13892-regulator.c
40927 @@ -540,10 +540,12 @@ static int mc13892_regulator_probe(struct platform_device *pdev)
40928 }
40929 mc13xxx_unlock(mc13892);
40930
40931 - mc13892_regulators[MC13892_VCAM].desc.ops->set_mode
40932 + pax_open_kernel();
40933 + *(void **)&mc13892_regulators[MC13892_VCAM].desc.ops->set_mode
40934 = mc13892_vcam_set_mode;
40935 - mc13892_regulators[MC13892_VCAM].desc.ops->get_mode
40936 + *(void **)&mc13892_regulators[MC13892_VCAM].desc.ops->get_mode
40937 = mc13892_vcam_get_mode;
40938 + pax_close_kernel();
40939
40940 mc13xxx_data = mc13xxx_parse_regulators_dt(pdev, mc13892_regulators,
40941 ARRAY_SIZE(mc13892_regulators));
40942 diff --git a/drivers/rtc/rtc-cmos.c b/drivers/rtc/rtc-cmos.c
40943 index 16630aa..6afc992 100644
40944 --- a/drivers/rtc/rtc-cmos.c
40945 +++ b/drivers/rtc/rtc-cmos.c
40946 @@ -724,7 +724,9 @@ cmos_do_probe(struct device *dev, struct resource *ports, int rtc_irq)
40947 hpet_rtc_timer_init();
40948
40949 /* export at least the first block of NVRAM */
40950 - nvram.size = address_space - NVRAM_OFFSET;
40951 + pax_open_kernel();
40952 + *(size_t *)&nvram.size = address_space - NVRAM_OFFSET;
40953 + pax_close_kernel();
40954 retval = sysfs_create_bin_file(&dev->kobj, &nvram);
40955 if (retval < 0) {
40956 dev_dbg(dev, "can't create nvram file? %d\n", retval);
40957 diff --git a/drivers/rtc/rtc-dev.c b/drivers/rtc/rtc-dev.c
40958 index 9a86b4b..3a383dc 100644
40959 --- a/drivers/rtc/rtc-dev.c
40960 +++ b/drivers/rtc/rtc-dev.c
40961 @@ -14,6 +14,7 @@
40962 #include <linux/module.h>
40963 #include <linux/rtc.h>
40964 #include <linux/sched.h>
40965 +#include <linux/grsecurity.h>
40966 #include "rtc-core.h"
40967
40968 static dev_t rtc_devt;
40969 @@ -345,6 +346,8 @@ static long rtc_dev_ioctl(struct file *file,
40970 if (copy_from_user(&tm, uarg, sizeof(tm)))
40971 return -EFAULT;
40972
40973 + gr_log_timechange();
40974 +
40975 return rtc_set_time(rtc, &tm);
40976
40977 case RTC_PIE_ON:
40978 diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c
40979 index e0d0ba4..3c65868 100644
40980 --- a/drivers/rtc/rtc-ds1307.c
40981 +++ b/drivers/rtc/rtc-ds1307.c
40982 @@ -106,7 +106,7 @@ struct ds1307 {
40983 u8 offset; /* register's offset */
40984 u8 regs[11];
40985 u16 nvram_offset;
40986 - struct bin_attribute *nvram;
40987 + bin_attribute_no_const *nvram;
40988 enum ds_type type;
40989 unsigned long flags;
40990 #define HAS_NVRAM 0 /* bit 0 == sysfs file active */
40991 diff --git a/drivers/rtc/rtc-m48t59.c b/drivers/rtc/rtc-m48t59.c
40992 index 130f29a..6179d03 100644
40993 --- a/drivers/rtc/rtc-m48t59.c
40994 +++ b/drivers/rtc/rtc-m48t59.c
40995 @@ -482,7 +482,9 @@ static int m48t59_rtc_probe(struct platform_device *pdev)
40996 goto out;
40997 }
40998
40999 - m48t59_nvram_attr.size = pdata->offset;
41000 + pax_open_kernel();
41001 + *(size_t *)&m48t59_nvram_attr.size = pdata->offset;
41002 + pax_close_kernel();
41003
41004 ret = sysfs_create_bin_file(&pdev->dev.kobj, &m48t59_nvram_attr);
41005 if (ret) {
41006 diff --git a/drivers/scsi/bfa/bfa_fcpim.h b/drivers/scsi/bfa/bfa_fcpim.h
41007 index e693af6..2e525b6 100644
41008 --- a/drivers/scsi/bfa/bfa_fcpim.h
41009 +++ b/drivers/scsi/bfa/bfa_fcpim.h
41010 @@ -36,7 +36,7 @@ struct bfa_iotag_s {
41011
41012 struct bfa_itn_s {
41013 bfa_isr_func_t isr;
41014 -};
41015 +} __no_const;
41016
41017 void bfa_itn_create(struct bfa_s *bfa, struct bfa_rport_s *rport,
41018 void (*isr)(struct bfa_s *bfa, struct bfi_msg_s *m));
41019 diff --git a/drivers/scsi/bfa/bfa_ioc.h b/drivers/scsi/bfa/bfa_ioc.h
41020 index 23a90e7..9cf04ee 100644
41021 --- a/drivers/scsi/bfa/bfa_ioc.h
41022 +++ b/drivers/scsi/bfa/bfa_ioc.h
41023 @@ -258,7 +258,7 @@ struct bfa_ioc_cbfn_s {
41024 bfa_ioc_disable_cbfn_t disable_cbfn;
41025 bfa_ioc_hbfail_cbfn_t hbfail_cbfn;
41026 bfa_ioc_reset_cbfn_t reset_cbfn;
41027 -};
41028 +} __no_const;
41029
41030 /*
41031 * IOC event notification mechanism.
41032 @@ -346,7 +346,7 @@ struct bfa_ioc_hwif_s {
41033 void (*ioc_sync_ack) (struct bfa_ioc_s *ioc);
41034 bfa_boolean_t (*ioc_sync_complete) (struct bfa_ioc_s *ioc);
41035 bfa_boolean_t (*ioc_lpu_read_stat) (struct bfa_ioc_s *ioc);
41036 -};
41037 +} __no_const;
41038
41039 /*
41040 * Queue element to wait for room in request queue. FIFO order is
41041 diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c
41042 index 593085a..47aa999 100644
41043 --- a/drivers/scsi/hosts.c
41044 +++ b/drivers/scsi/hosts.c
41045 @@ -42,7 +42,7 @@
41046 #include "scsi_logging.h"
41047
41048
41049 -static atomic_t scsi_host_next_hn = ATOMIC_INIT(0); /* host_no for next new host */
41050 +static atomic_unchecked_t scsi_host_next_hn = ATOMIC_INIT(0); /* host_no for next new host */
41051
41052
41053 static void scsi_host_cls_release(struct device *dev)
41054 @@ -361,7 +361,7 @@ struct Scsi_Host *scsi_host_alloc(struct scsi_host_template *sht, int privsize)
41055 * subtract one because we increment first then return, but we need to
41056 * know what the next host number was before increment
41057 */
41058 - shost->host_no = atomic_inc_return(&scsi_host_next_hn) - 1;
41059 + shost->host_no = atomic_inc_return_unchecked(&scsi_host_next_hn) - 1;
41060 shost->dma_channel = 0xff;
41061
41062 /* These three are default values which can be overridden */
41063 diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
41064 index 4f33806..afd6f60 100644
41065 --- a/drivers/scsi/hpsa.c
41066 +++ b/drivers/scsi/hpsa.c
41067 @@ -554,7 +554,7 @@ static inline u32 next_command(struct ctlr_info *h, u8 q)
41068 unsigned long flags;
41069
41070 if (unlikely(!(h->transMethod & CFGTBL_Trans_Performant)))
41071 - return h->access.command_completed(h, q);
41072 + return h->access->command_completed(h, q);
41073
41074 if ((rq->head[rq->current_entry] & 1) == rq->wraparound) {
41075 a = rq->head[rq->current_entry];
41076 @@ -3374,7 +3374,7 @@ static void start_io(struct ctlr_info *h)
41077 while (!list_empty(&h->reqQ)) {
41078 c = list_entry(h->reqQ.next, struct CommandList, list);
41079 /* can't do anything if fifo is full */
41080 - if ((h->access.fifo_full(h))) {
41081 + if ((h->access->fifo_full(h))) {
41082 dev_warn(&h->pdev->dev, "fifo full\n");
41083 break;
41084 }
41085 @@ -3396,7 +3396,7 @@ static void start_io(struct ctlr_info *h)
41086
41087 /* Tell the controller execute command */
41088 spin_unlock_irqrestore(&h->lock, flags);
41089 - h->access.submit_command(h, c);
41090 + h->access->submit_command(h, c);
41091 spin_lock_irqsave(&h->lock, flags);
41092 }
41093 spin_unlock_irqrestore(&h->lock, flags);
41094 @@ -3404,17 +3404,17 @@ static void start_io(struct ctlr_info *h)
41095
41096 static inline unsigned long get_next_completion(struct ctlr_info *h, u8 q)
41097 {
41098 - return h->access.command_completed(h, q);
41099 + return h->access->command_completed(h, q);
41100 }
41101
41102 static inline bool interrupt_pending(struct ctlr_info *h)
41103 {
41104 - return h->access.intr_pending(h);
41105 + return h->access->intr_pending(h);
41106 }
41107
41108 static inline long interrupt_not_for_us(struct ctlr_info *h)
41109 {
41110 - return (h->access.intr_pending(h) == 0) ||
41111 + return (h->access->intr_pending(h) == 0) ||
41112 (h->interrupts_enabled == 0);
41113 }
41114
41115 @@ -4316,7 +4316,7 @@ static int hpsa_pci_init(struct ctlr_info *h)
41116 if (prod_index < 0)
41117 return -ENODEV;
41118 h->product_name = products[prod_index].product_name;
41119 - h->access = *(products[prod_index].access);
41120 + h->access = products[prod_index].access;
41121
41122 pci_disable_link_state(h->pdev, PCIE_LINK_STATE_L0S |
41123 PCIE_LINK_STATE_L1 | PCIE_LINK_STATE_CLKPM);
41124 @@ -4598,7 +4598,7 @@ static void controller_lockup_detected(struct ctlr_info *h)
41125
41126 assert_spin_locked(&lockup_detector_lock);
41127 remove_ctlr_from_lockup_detector_list(h);
41128 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
41129 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
41130 spin_lock_irqsave(&h->lock, flags);
41131 h->lockup_detected = readl(h->vaddr + SA5_SCRATCHPAD_OFFSET);
41132 spin_unlock_irqrestore(&h->lock, flags);
41133 @@ -4775,7 +4775,7 @@ reinit_after_soft_reset:
41134 }
41135
41136 /* make sure the board interrupts are off */
41137 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
41138 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
41139
41140 if (hpsa_request_irq(h, do_hpsa_intr_msi, do_hpsa_intr_intx))
41141 goto clean2;
41142 @@ -4809,7 +4809,7 @@ reinit_after_soft_reset:
41143 * fake ones to scoop up any residual completions.
41144 */
41145 spin_lock_irqsave(&h->lock, flags);
41146 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
41147 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
41148 spin_unlock_irqrestore(&h->lock, flags);
41149 free_irqs(h);
41150 rc = hpsa_request_irq(h, hpsa_msix_discard_completions,
41151 @@ -4828,9 +4828,9 @@ reinit_after_soft_reset:
41152 dev_info(&h->pdev->dev, "Board READY.\n");
41153 dev_info(&h->pdev->dev,
41154 "Waiting for stale completions to drain.\n");
41155 - h->access.set_intr_mask(h, HPSA_INTR_ON);
41156 + h->access->set_intr_mask(h, HPSA_INTR_ON);
41157 msleep(10000);
41158 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
41159 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
41160
41161 rc = controller_reset_failed(h->cfgtable);
41162 if (rc)
41163 @@ -4851,7 +4851,7 @@ reinit_after_soft_reset:
41164 }
41165
41166 /* Turn the interrupts on so we can service requests */
41167 - h->access.set_intr_mask(h, HPSA_INTR_ON);
41168 + h->access->set_intr_mask(h, HPSA_INTR_ON);
41169
41170 hpsa_hba_inquiry(h);
41171 hpsa_register_scsi(h); /* hook ourselves into SCSI subsystem */
41172 @@ -4903,7 +4903,7 @@ static void hpsa_shutdown(struct pci_dev *pdev)
41173 * To write all data in the battery backed cache to disks
41174 */
41175 hpsa_flush_cache(h);
41176 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
41177 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
41178 hpsa_free_irqs_and_disable_msix(h);
41179 }
41180
41181 @@ -5071,7 +5071,7 @@ static void hpsa_enter_performant_mode(struct ctlr_info *h, u32 use_short_tags)
41182 return;
41183 }
41184 /* Change the access methods to the performant access methods */
41185 - h->access = SA5_performant_access;
41186 + h->access = &SA5_performant_access;
41187 h->transMethod = CFGTBL_Trans_Performant;
41188 }
41189
41190 diff --git a/drivers/scsi/hpsa.h b/drivers/scsi/hpsa.h
41191 index 9816479..c5d4e97 100644
41192 --- a/drivers/scsi/hpsa.h
41193 +++ b/drivers/scsi/hpsa.h
41194 @@ -79,7 +79,7 @@ struct ctlr_info {
41195 unsigned int msix_vector;
41196 unsigned int msi_vector;
41197 int intr_mode; /* either PERF_MODE_INT or SIMPLE_MODE_INT */
41198 - struct access_method access;
41199 + struct access_method *access;
41200
41201 /* queue and queue Info */
41202 struct list_head reqQ;
41203 diff --git a/drivers/scsi/libfc/fc_exch.c b/drivers/scsi/libfc/fc_exch.c
41204 index c772d8d..35c362c 100644
41205 --- a/drivers/scsi/libfc/fc_exch.c
41206 +++ b/drivers/scsi/libfc/fc_exch.c
41207 @@ -100,12 +100,12 @@ struct fc_exch_mgr {
41208 u16 pool_max_index;
41209
41210 struct {
41211 - atomic_t no_free_exch;
41212 - atomic_t no_free_exch_xid;
41213 - atomic_t xid_not_found;
41214 - atomic_t xid_busy;
41215 - atomic_t seq_not_found;
41216 - atomic_t non_bls_resp;
41217 + atomic_unchecked_t no_free_exch;
41218 + atomic_unchecked_t no_free_exch_xid;
41219 + atomic_unchecked_t xid_not_found;
41220 + atomic_unchecked_t xid_busy;
41221 + atomic_unchecked_t seq_not_found;
41222 + atomic_unchecked_t non_bls_resp;
41223 } stats;
41224 };
41225
41226 @@ -725,7 +725,7 @@ static struct fc_exch *fc_exch_em_alloc(struct fc_lport *lport,
41227 /* allocate memory for exchange */
41228 ep = mempool_alloc(mp->ep_pool, GFP_ATOMIC);
41229 if (!ep) {
41230 - atomic_inc(&mp->stats.no_free_exch);
41231 + atomic_inc_unchecked(&mp->stats.no_free_exch);
41232 goto out;
41233 }
41234 memset(ep, 0, sizeof(*ep));
41235 @@ -786,7 +786,7 @@ out:
41236 return ep;
41237 err:
41238 spin_unlock_bh(&pool->lock);
41239 - atomic_inc(&mp->stats.no_free_exch_xid);
41240 + atomic_inc_unchecked(&mp->stats.no_free_exch_xid);
41241 mempool_free(ep, mp->ep_pool);
41242 return NULL;
41243 }
41244 @@ -929,7 +929,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
41245 xid = ntohs(fh->fh_ox_id); /* we originated exch */
41246 ep = fc_exch_find(mp, xid);
41247 if (!ep) {
41248 - atomic_inc(&mp->stats.xid_not_found);
41249 + atomic_inc_unchecked(&mp->stats.xid_not_found);
41250 reject = FC_RJT_OX_ID;
41251 goto out;
41252 }
41253 @@ -959,7 +959,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
41254 ep = fc_exch_find(mp, xid);
41255 if ((f_ctl & FC_FC_FIRST_SEQ) && fc_sof_is_init(fr_sof(fp))) {
41256 if (ep) {
41257 - atomic_inc(&mp->stats.xid_busy);
41258 + atomic_inc_unchecked(&mp->stats.xid_busy);
41259 reject = FC_RJT_RX_ID;
41260 goto rel;
41261 }
41262 @@ -970,7 +970,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
41263 }
41264 xid = ep->xid; /* get our XID */
41265 } else if (!ep) {
41266 - atomic_inc(&mp->stats.xid_not_found);
41267 + atomic_inc_unchecked(&mp->stats.xid_not_found);
41268 reject = FC_RJT_RX_ID; /* XID not found */
41269 goto out;
41270 }
41271 @@ -987,7 +987,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
41272 } else {
41273 sp = &ep->seq;
41274 if (sp->id != fh->fh_seq_id) {
41275 - atomic_inc(&mp->stats.seq_not_found);
41276 + atomic_inc_unchecked(&mp->stats.seq_not_found);
41277 if (f_ctl & FC_FC_END_SEQ) {
41278 /*
41279 * Update sequence_id based on incoming last
41280 @@ -1437,22 +1437,22 @@ static void fc_exch_recv_seq_resp(struct fc_exch_mgr *mp, struct fc_frame *fp)
41281
41282 ep = fc_exch_find(mp, ntohs(fh->fh_ox_id));
41283 if (!ep) {
41284 - atomic_inc(&mp->stats.xid_not_found);
41285 + atomic_inc_unchecked(&mp->stats.xid_not_found);
41286 goto out;
41287 }
41288 if (ep->esb_stat & ESB_ST_COMPLETE) {
41289 - atomic_inc(&mp->stats.xid_not_found);
41290 + atomic_inc_unchecked(&mp->stats.xid_not_found);
41291 goto rel;
41292 }
41293 if (ep->rxid == FC_XID_UNKNOWN)
41294 ep->rxid = ntohs(fh->fh_rx_id);
41295 if (ep->sid != 0 && ep->sid != ntoh24(fh->fh_d_id)) {
41296 - atomic_inc(&mp->stats.xid_not_found);
41297 + atomic_inc_unchecked(&mp->stats.xid_not_found);
41298 goto rel;
41299 }
41300 if (ep->did != ntoh24(fh->fh_s_id) &&
41301 ep->did != FC_FID_FLOGI) {
41302 - atomic_inc(&mp->stats.xid_not_found);
41303 + atomic_inc_unchecked(&mp->stats.xid_not_found);
41304 goto rel;
41305 }
41306 sof = fr_sof(fp);
41307 @@ -1461,7 +1461,7 @@ static void fc_exch_recv_seq_resp(struct fc_exch_mgr *mp, struct fc_frame *fp)
41308 sp->ssb_stat |= SSB_ST_RESP;
41309 sp->id = fh->fh_seq_id;
41310 } else if (sp->id != fh->fh_seq_id) {
41311 - atomic_inc(&mp->stats.seq_not_found);
41312 + atomic_inc_unchecked(&mp->stats.seq_not_found);
41313 goto rel;
41314 }
41315
41316 @@ -1525,9 +1525,9 @@ static void fc_exch_recv_resp(struct fc_exch_mgr *mp, struct fc_frame *fp)
41317 sp = fc_seq_lookup_orig(mp, fp); /* doesn't hold sequence */
41318
41319 if (!sp)
41320 - atomic_inc(&mp->stats.xid_not_found);
41321 + atomic_inc_unchecked(&mp->stats.xid_not_found);
41322 else
41323 - atomic_inc(&mp->stats.non_bls_resp);
41324 + atomic_inc_unchecked(&mp->stats.non_bls_resp);
41325
41326 fc_frame_free(fp);
41327 }
41328 @@ -2174,13 +2174,13 @@ void fc_exch_update_stats(struct fc_lport *lport)
41329
41330 list_for_each_entry(ema, &lport->ema_list, ema_list) {
41331 mp = ema->mp;
41332 - st->fc_no_free_exch += atomic_read(&mp->stats.no_free_exch);
41333 + st->fc_no_free_exch += atomic_read_unchecked(&mp->stats.no_free_exch);
41334 st->fc_no_free_exch_xid +=
41335 - atomic_read(&mp->stats.no_free_exch_xid);
41336 - st->fc_xid_not_found += atomic_read(&mp->stats.xid_not_found);
41337 - st->fc_xid_busy += atomic_read(&mp->stats.xid_busy);
41338 - st->fc_seq_not_found += atomic_read(&mp->stats.seq_not_found);
41339 - st->fc_non_bls_resp += atomic_read(&mp->stats.non_bls_resp);
41340 + atomic_read_unchecked(&mp->stats.no_free_exch_xid);
41341 + st->fc_xid_not_found += atomic_read_unchecked(&mp->stats.xid_not_found);
41342 + st->fc_xid_busy += atomic_read_unchecked(&mp->stats.xid_busy);
41343 + st->fc_seq_not_found += atomic_read_unchecked(&mp->stats.seq_not_found);
41344 + st->fc_non_bls_resp += atomic_read_unchecked(&mp->stats.non_bls_resp);
41345 }
41346 }
41347 EXPORT_SYMBOL(fc_exch_update_stats);
41348 diff --git a/drivers/scsi/libsas/sas_ata.c b/drivers/scsi/libsas/sas_ata.c
41349 index bdb81cd..d3c7c2c 100644
41350 --- a/drivers/scsi/libsas/sas_ata.c
41351 +++ b/drivers/scsi/libsas/sas_ata.c
41352 @@ -554,7 +554,7 @@ static struct ata_port_operations sas_sata_ops = {
41353 .postreset = ata_std_postreset,
41354 .error_handler = ata_std_error_handler,
41355 .post_internal_cmd = sas_ata_post_internal,
41356 - .qc_defer = ata_std_qc_defer,
41357 + .qc_defer = ata_std_qc_defer,
41358 .qc_prep = ata_noop_qc_prep,
41359 .qc_issue = sas_ata_qc_issue,
41360 .qc_fill_rtf = sas_ata_qc_fill_rtf,
41361 diff --git a/drivers/scsi/lpfc/lpfc.h b/drivers/scsi/lpfc/lpfc.h
41362 index df4c13a..a51e90c 100644
41363 --- a/drivers/scsi/lpfc/lpfc.h
41364 +++ b/drivers/scsi/lpfc/lpfc.h
41365 @@ -424,7 +424,7 @@ struct lpfc_vport {
41366 struct dentry *debug_nodelist;
41367 struct dentry *vport_debugfs_root;
41368 struct lpfc_debugfs_trc *disc_trc;
41369 - atomic_t disc_trc_cnt;
41370 + atomic_unchecked_t disc_trc_cnt;
41371 #endif
41372 uint8_t stat_data_enabled;
41373 uint8_t stat_data_blocked;
41374 @@ -842,8 +842,8 @@ struct lpfc_hba {
41375 struct timer_list fabric_block_timer;
41376 unsigned long bit_flags;
41377 #define FABRIC_COMANDS_BLOCKED 0
41378 - atomic_t num_rsrc_err;
41379 - atomic_t num_cmd_success;
41380 + atomic_unchecked_t num_rsrc_err;
41381 + atomic_unchecked_t num_cmd_success;
41382 unsigned long last_rsrc_error_time;
41383 unsigned long last_ramp_down_time;
41384 unsigned long last_ramp_up_time;
41385 @@ -879,7 +879,7 @@ struct lpfc_hba {
41386
41387 struct dentry *debug_slow_ring_trc;
41388 struct lpfc_debugfs_trc *slow_ring_trc;
41389 - atomic_t slow_ring_trc_cnt;
41390 + atomic_unchecked_t slow_ring_trc_cnt;
41391 /* iDiag debugfs sub-directory */
41392 struct dentry *idiag_root;
41393 struct dentry *idiag_pci_cfg;
41394 diff --git a/drivers/scsi/lpfc/lpfc_debugfs.c b/drivers/scsi/lpfc/lpfc_debugfs.c
41395 index f63f5ff..de29189 100644
41396 --- a/drivers/scsi/lpfc/lpfc_debugfs.c
41397 +++ b/drivers/scsi/lpfc/lpfc_debugfs.c
41398 @@ -106,7 +106,7 @@ MODULE_PARM_DESC(lpfc_debugfs_mask_disc_trc,
41399
41400 #include <linux/debugfs.h>
41401
41402 -static atomic_t lpfc_debugfs_seq_trc_cnt = ATOMIC_INIT(0);
41403 +static atomic_unchecked_t lpfc_debugfs_seq_trc_cnt = ATOMIC_INIT(0);
41404 static unsigned long lpfc_debugfs_start_time = 0L;
41405
41406 /* iDiag */
41407 @@ -147,7 +147,7 @@ lpfc_debugfs_disc_trc_data(struct lpfc_vport *vport, char *buf, int size)
41408 lpfc_debugfs_enable = 0;
41409
41410 len = 0;
41411 - index = (atomic_read(&vport->disc_trc_cnt) + 1) &
41412 + index = (atomic_read_unchecked(&vport->disc_trc_cnt) + 1) &
41413 (lpfc_debugfs_max_disc_trc - 1);
41414 for (i = index; i < lpfc_debugfs_max_disc_trc; i++) {
41415 dtp = vport->disc_trc + i;
41416 @@ -213,7 +213,7 @@ lpfc_debugfs_slow_ring_trc_data(struct lpfc_hba *phba, char *buf, int size)
41417 lpfc_debugfs_enable = 0;
41418
41419 len = 0;
41420 - index = (atomic_read(&phba->slow_ring_trc_cnt) + 1) &
41421 + index = (atomic_read_unchecked(&phba->slow_ring_trc_cnt) + 1) &
41422 (lpfc_debugfs_max_slow_ring_trc - 1);
41423 for (i = index; i < lpfc_debugfs_max_slow_ring_trc; i++) {
41424 dtp = phba->slow_ring_trc + i;
41425 @@ -646,14 +646,14 @@ lpfc_debugfs_disc_trc(struct lpfc_vport *vport, int mask, char *fmt,
41426 !vport || !vport->disc_trc)
41427 return;
41428
41429 - index = atomic_inc_return(&vport->disc_trc_cnt) &
41430 + index = atomic_inc_return_unchecked(&vport->disc_trc_cnt) &
41431 (lpfc_debugfs_max_disc_trc - 1);
41432 dtp = vport->disc_trc + index;
41433 dtp->fmt = fmt;
41434 dtp->data1 = data1;
41435 dtp->data2 = data2;
41436 dtp->data3 = data3;
41437 - dtp->seq_cnt = atomic_inc_return(&lpfc_debugfs_seq_trc_cnt);
41438 + dtp->seq_cnt = atomic_inc_return_unchecked(&lpfc_debugfs_seq_trc_cnt);
41439 dtp->jif = jiffies;
41440 #endif
41441 return;
41442 @@ -684,14 +684,14 @@ lpfc_debugfs_slow_ring_trc(struct lpfc_hba *phba, char *fmt,
41443 !phba || !phba->slow_ring_trc)
41444 return;
41445
41446 - index = atomic_inc_return(&phba->slow_ring_trc_cnt) &
41447 + index = atomic_inc_return_unchecked(&phba->slow_ring_trc_cnt) &
41448 (lpfc_debugfs_max_slow_ring_trc - 1);
41449 dtp = phba->slow_ring_trc + index;
41450 dtp->fmt = fmt;
41451 dtp->data1 = data1;
41452 dtp->data2 = data2;
41453 dtp->data3 = data3;
41454 - dtp->seq_cnt = atomic_inc_return(&lpfc_debugfs_seq_trc_cnt);
41455 + dtp->seq_cnt = atomic_inc_return_unchecked(&lpfc_debugfs_seq_trc_cnt);
41456 dtp->jif = jiffies;
41457 #endif
41458 return;
41459 @@ -4182,7 +4182,7 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport)
41460 "slow_ring buffer\n");
41461 goto debug_failed;
41462 }
41463 - atomic_set(&phba->slow_ring_trc_cnt, 0);
41464 + atomic_set_unchecked(&phba->slow_ring_trc_cnt, 0);
41465 memset(phba->slow_ring_trc, 0,
41466 (sizeof(struct lpfc_debugfs_trc) *
41467 lpfc_debugfs_max_slow_ring_trc));
41468 @@ -4228,7 +4228,7 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport)
41469 "buffer\n");
41470 goto debug_failed;
41471 }
41472 - atomic_set(&vport->disc_trc_cnt, 0);
41473 + atomic_set_unchecked(&vport->disc_trc_cnt, 0);
41474
41475 snprintf(name, sizeof(name), "discovery_trace");
41476 vport->debug_disc_trc =
41477 diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c
41478 index 89ad558..76956c4 100644
41479 --- a/drivers/scsi/lpfc/lpfc_init.c
41480 +++ b/drivers/scsi/lpfc/lpfc_init.c
41481 @@ -10618,8 +10618,10 @@ lpfc_init(void)
41482 "misc_register returned with status %d", error);
41483
41484 if (lpfc_enable_npiv) {
41485 - lpfc_transport_functions.vport_create = lpfc_vport_create;
41486 - lpfc_transport_functions.vport_delete = lpfc_vport_delete;
41487 + pax_open_kernel();
41488 + *(void **)&lpfc_transport_functions.vport_create = lpfc_vport_create;
41489 + *(void **)&lpfc_transport_functions.vport_delete = lpfc_vport_delete;
41490 + pax_close_kernel();
41491 }
41492 lpfc_transport_template =
41493 fc_attach_transport(&lpfc_transport_functions);
41494 diff --git a/drivers/scsi/lpfc/lpfc_scsi.c b/drivers/scsi/lpfc/lpfc_scsi.c
41495 index 60e5a17..ff7a793 100644
41496 --- a/drivers/scsi/lpfc/lpfc_scsi.c
41497 +++ b/drivers/scsi/lpfc/lpfc_scsi.c
41498 @@ -305,7 +305,7 @@ lpfc_rampdown_queue_depth(struct lpfc_hba *phba)
41499 uint32_t evt_posted;
41500
41501 spin_lock_irqsave(&phba->hbalock, flags);
41502 - atomic_inc(&phba->num_rsrc_err);
41503 + atomic_inc_unchecked(&phba->num_rsrc_err);
41504 phba->last_rsrc_error_time = jiffies;
41505
41506 if ((phba->last_ramp_down_time + QUEUE_RAMP_DOWN_INTERVAL) > jiffies) {
41507 @@ -346,7 +346,7 @@ lpfc_rampup_queue_depth(struct lpfc_vport *vport,
41508 unsigned long flags;
41509 struct lpfc_hba *phba = vport->phba;
41510 uint32_t evt_posted;
41511 - atomic_inc(&phba->num_cmd_success);
41512 + atomic_inc_unchecked(&phba->num_cmd_success);
41513
41514 if (vport->cfg_lun_queue_depth <= queue_depth)
41515 return;
41516 @@ -390,8 +390,8 @@ lpfc_ramp_down_queue_handler(struct lpfc_hba *phba)
41517 unsigned long num_rsrc_err, num_cmd_success;
41518 int i;
41519
41520 - num_rsrc_err = atomic_read(&phba->num_rsrc_err);
41521 - num_cmd_success = atomic_read(&phba->num_cmd_success);
41522 + num_rsrc_err = atomic_read_unchecked(&phba->num_rsrc_err);
41523 + num_cmd_success = atomic_read_unchecked(&phba->num_cmd_success);
41524
41525 /*
41526 * The error and success command counters are global per
41527 @@ -419,8 +419,8 @@ lpfc_ramp_down_queue_handler(struct lpfc_hba *phba)
41528 }
41529 }
41530 lpfc_destroy_vport_work_array(phba, vports);
41531 - atomic_set(&phba->num_rsrc_err, 0);
41532 - atomic_set(&phba->num_cmd_success, 0);
41533 + atomic_set_unchecked(&phba->num_rsrc_err, 0);
41534 + atomic_set_unchecked(&phba->num_cmd_success, 0);
41535 }
41536
41537 /**
41538 @@ -454,8 +454,8 @@ lpfc_ramp_up_queue_handler(struct lpfc_hba *phba)
41539 }
41540 }
41541 lpfc_destroy_vport_work_array(phba, vports);
41542 - atomic_set(&phba->num_rsrc_err, 0);
41543 - atomic_set(&phba->num_cmd_success, 0);
41544 + atomic_set_unchecked(&phba->num_rsrc_err, 0);
41545 + atomic_set_unchecked(&phba->num_cmd_success, 0);
41546 }
41547
41548 /**
41549 diff --git a/drivers/scsi/pmcraid.c b/drivers/scsi/pmcraid.c
41550 index b46f5e9..c4c4ccb 100644
41551 --- a/drivers/scsi/pmcraid.c
41552 +++ b/drivers/scsi/pmcraid.c
41553 @@ -200,8 +200,8 @@ static int pmcraid_slave_alloc(struct scsi_device *scsi_dev)
41554 res->scsi_dev = scsi_dev;
41555 scsi_dev->hostdata = res;
41556 res->change_detected = 0;
41557 - atomic_set(&res->read_failures, 0);
41558 - atomic_set(&res->write_failures, 0);
41559 + atomic_set_unchecked(&res->read_failures, 0);
41560 + atomic_set_unchecked(&res->write_failures, 0);
41561 rc = 0;
41562 }
41563 spin_unlock_irqrestore(&pinstance->resource_lock, lock_flags);
41564 @@ -2676,9 +2676,9 @@ static int pmcraid_error_handler(struct pmcraid_cmd *cmd)
41565
41566 /* If this was a SCSI read/write command keep count of errors */
41567 if (SCSI_CMD_TYPE(scsi_cmd->cmnd[0]) == SCSI_READ_CMD)
41568 - atomic_inc(&res->read_failures);
41569 + atomic_inc_unchecked(&res->read_failures);
41570 else if (SCSI_CMD_TYPE(scsi_cmd->cmnd[0]) == SCSI_WRITE_CMD)
41571 - atomic_inc(&res->write_failures);
41572 + atomic_inc_unchecked(&res->write_failures);
41573
41574 if (!RES_IS_GSCSI(res->cfg_entry) &&
41575 masked_ioasc != PMCRAID_IOASC_HW_DEVICE_BUS_STATUS_ERROR) {
41576 @@ -3534,7 +3534,7 @@ static int pmcraid_queuecommand_lck(
41577 * block of scsi_cmd which is re-used (e.g. cancel/abort), which uses
41578 * hrrq_id assigned here in queuecommand
41579 */
41580 - ioarcb->hrrq_id = atomic_add_return(1, &(pinstance->last_message_id)) %
41581 + ioarcb->hrrq_id = atomic_add_return_unchecked(1, &(pinstance->last_message_id)) %
41582 pinstance->num_hrrq;
41583 cmd->cmd_done = pmcraid_io_done;
41584
41585 @@ -3859,7 +3859,7 @@ static long pmcraid_ioctl_passthrough(
41586 * block of scsi_cmd which is re-used (e.g. cancel/abort), which uses
41587 * hrrq_id assigned here in queuecommand
41588 */
41589 - ioarcb->hrrq_id = atomic_add_return(1, &(pinstance->last_message_id)) %
41590 + ioarcb->hrrq_id = atomic_add_return_unchecked(1, &(pinstance->last_message_id)) %
41591 pinstance->num_hrrq;
41592
41593 if (request_size) {
41594 @@ -4497,7 +4497,7 @@ static void pmcraid_worker_function(struct work_struct *workp)
41595
41596 pinstance = container_of(workp, struct pmcraid_instance, worker_q);
41597 /* add resources only after host is added into system */
41598 - if (!atomic_read(&pinstance->expose_resources))
41599 + if (!atomic_read_unchecked(&pinstance->expose_resources))
41600 return;
41601
41602 fw_version = be16_to_cpu(pinstance->inq_data->fw_version);
41603 @@ -5324,8 +5324,8 @@ static int pmcraid_init_instance(struct pci_dev *pdev, struct Scsi_Host *host,
41604 init_waitqueue_head(&pinstance->reset_wait_q);
41605
41606 atomic_set(&pinstance->outstanding_cmds, 0);
41607 - atomic_set(&pinstance->last_message_id, 0);
41608 - atomic_set(&pinstance->expose_resources, 0);
41609 + atomic_set_unchecked(&pinstance->last_message_id, 0);
41610 + atomic_set_unchecked(&pinstance->expose_resources, 0);
41611
41612 INIT_LIST_HEAD(&pinstance->free_res_q);
41613 INIT_LIST_HEAD(&pinstance->used_res_q);
41614 @@ -6038,7 +6038,7 @@ static int pmcraid_probe(struct pci_dev *pdev,
41615 /* Schedule worker thread to handle CCN and take care of adding and
41616 * removing devices to OS
41617 */
41618 - atomic_set(&pinstance->expose_resources, 1);
41619 + atomic_set_unchecked(&pinstance->expose_resources, 1);
41620 schedule_work(&pinstance->worker_q);
41621 return rc;
41622
41623 diff --git a/drivers/scsi/pmcraid.h b/drivers/scsi/pmcraid.h
41624 index e1d150f..6c6df44 100644
41625 --- a/drivers/scsi/pmcraid.h
41626 +++ b/drivers/scsi/pmcraid.h
41627 @@ -748,7 +748,7 @@ struct pmcraid_instance {
41628 struct pmcraid_isr_param hrrq_vector[PMCRAID_NUM_MSIX_VECTORS];
41629
41630 /* Message id as filled in last fired IOARCB, used to identify HRRQ */
41631 - atomic_t last_message_id;
41632 + atomic_unchecked_t last_message_id;
41633
41634 /* configuration table */
41635 struct pmcraid_config_table *cfg_table;
41636 @@ -777,7 +777,7 @@ struct pmcraid_instance {
41637 atomic_t outstanding_cmds;
41638
41639 /* should add/delete resources to mid-layer now ?*/
41640 - atomic_t expose_resources;
41641 + atomic_unchecked_t expose_resources;
41642
41643
41644
41645 @@ -813,8 +813,8 @@ struct pmcraid_resource_entry {
41646 struct pmcraid_config_table_entry_ext cfg_entry_ext;
41647 };
41648 struct scsi_device *scsi_dev; /* Link scsi_device structure */
41649 - atomic_t read_failures; /* count of failed READ commands */
41650 - atomic_t write_failures; /* count of failed WRITE commands */
41651 + atomic_unchecked_t read_failures; /* count of failed READ commands */
41652 + atomic_unchecked_t write_failures; /* count of failed WRITE commands */
41653
41654 /* To indicate add/delete/modify during CCN */
41655 u8 change_detected;
41656 diff --git a/drivers/scsi/qla2xxx/qla_attr.c b/drivers/scsi/qla2xxx/qla_attr.c
41657 index 83d7984..a27d947 100644
41658 --- a/drivers/scsi/qla2xxx/qla_attr.c
41659 +++ b/drivers/scsi/qla2xxx/qla_attr.c
41660 @@ -1969,7 +1969,7 @@ qla24xx_vport_disable(struct fc_vport *fc_vport, bool disable)
41661 return 0;
41662 }
41663
41664 -struct fc_function_template qla2xxx_transport_functions = {
41665 +fc_function_template_no_const qla2xxx_transport_functions = {
41666
41667 .show_host_node_name = 1,
41668 .show_host_port_name = 1,
41669 @@ -2016,7 +2016,7 @@ struct fc_function_template qla2xxx_transport_functions = {
41670 .bsg_timeout = qla24xx_bsg_timeout,
41671 };
41672
41673 -struct fc_function_template qla2xxx_transport_vport_functions = {
41674 +fc_function_template_no_const qla2xxx_transport_vport_functions = {
41675
41676 .show_host_node_name = 1,
41677 .show_host_port_name = 1,
41678 diff --git a/drivers/scsi/qla2xxx/qla_gbl.h b/drivers/scsi/qla2xxx/qla_gbl.h
41679 index 2411d1a..4673766 100644
41680 --- a/drivers/scsi/qla2xxx/qla_gbl.h
41681 +++ b/drivers/scsi/qla2xxx/qla_gbl.h
41682 @@ -515,8 +515,8 @@ extern void qla2x00_get_sym_node_name(scsi_qla_host_t *, uint8_t *);
41683 struct device_attribute;
41684 extern struct device_attribute *qla2x00_host_attrs[];
41685 struct fc_function_template;
41686 -extern struct fc_function_template qla2xxx_transport_functions;
41687 -extern struct fc_function_template qla2xxx_transport_vport_functions;
41688 +extern fc_function_template_no_const qla2xxx_transport_functions;
41689 +extern fc_function_template_no_const qla2xxx_transport_vport_functions;
41690 extern void qla2x00_alloc_sysfs_attr(scsi_qla_host_t *);
41691 extern void qla2x00_free_sysfs_attr(scsi_qla_host_t *);
41692 extern void qla2x00_init_host_attr(scsi_qla_host_t *);
41693 diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
41694 index 10d23f8..a7d5d4c 100644
41695 --- a/drivers/scsi/qla2xxx/qla_os.c
41696 +++ b/drivers/scsi/qla2xxx/qla_os.c
41697 @@ -1472,8 +1472,10 @@ qla2x00_config_dma_addressing(struct qla_hw_data *ha)
41698 !pci_set_consistent_dma_mask(ha->pdev, DMA_BIT_MASK(64))) {
41699 /* Ok, a 64bit DMA mask is applicable. */
41700 ha->flags.enable_64bit_addressing = 1;
41701 - ha->isp_ops->calc_req_entries = qla2x00_calc_iocbs_64;
41702 - ha->isp_ops->build_iocbs = qla2x00_build_scsi_iocbs_64;
41703 + pax_open_kernel();
41704 + *(void **)&ha->isp_ops->calc_req_entries = qla2x00_calc_iocbs_64;
41705 + *(void **)&ha->isp_ops->build_iocbs = qla2x00_build_scsi_iocbs_64;
41706 + pax_close_kernel();
41707 return;
41708 }
41709 }
41710 diff --git a/drivers/scsi/qla4xxx/ql4_def.h b/drivers/scsi/qla4xxx/ql4_def.h
41711 index 329d553..f20d31d 100644
41712 --- a/drivers/scsi/qla4xxx/ql4_def.h
41713 +++ b/drivers/scsi/qla4xxx/ql4_def.h
41714 @@ -273,7 +273,7 @@ struct ddb_entry {
41715 * (4000 only) */
41716 atomic_t relogin_timer; /* Max Time to wait for
41717 * relogin to complete */
41718 - atomic_t relogin_retry_count; /* Num of times relogin has been
41719 + atomic_unchecked_t relogin_retry_count; /* Num of times relogin has been
41720 * retried */
41721 uint32_t default_time2wait; /* Default Min time between
41722 * relogins (+aens) */
41723 diff --git a/drivers/scsi/qla4xxx/ql4_os.c b/drivers/scsi/qla4xxx/ql4_os.c
41724 index 4cec123..7c1329f 100644
41725 --- a/drivers/scsi/qla4xxx/ql4_os.c
41726 +++ b/drivers/scsi/qla4xxx/ql4_os.c
41727 @@ -2621,12 +2621,12 @@ static void qla4xxx_check_relogin_flash_ddb(struct iscsi_cls_session *cls_sess)
41728 */
41729 if (!iscsi_is_session_online(cls_sess)) {
41730 /* Reset retry relogin timer */
41731 - atomic_inc(&ddb_entry->relogin_retry_count);
41732 + atomic_inc_unchecked(&ddb_entry->relogin_retry_count);
41733 DEBUG2(ql4_printk(KERN_INFO, ha,
41734 "%s: index[%d] relogin timed out-retrying"
41735 " relogin (%d), retry (%d)\n", __func__,
41736 ddb_entry->fw_ddb_index,
41737 - atomic_read(&ddb_entry->relogin_retry_count),
41738 + atomic_read_unchecked(&ddb_entry->relogin_retry_count),
41739 ddb_entry->default_time2wait + 4));
41740 set_bit(DPC_RELOGIN_DEVICE, &ha->dpc_flags);
41741 atomic_set(&ddb_entry->retry_relogin_timer,
41742 @@ -4738,7 +4738,7 @@ static void qla4xxx_setup_flash_ddb_entry(struct scsi_qla_host *ha,
41743
41744 atomic_set(&ddb_entry->retry_relogin_timer, INVALID_ENTRY);
41745 atomic_set(&ddb_entry->relogin_timer, 0);
41746 - atomic_set(&ddb_entry->relogin_retry_count, 0);
41747 + atomic_set_unchecked(&ddb_entry->relogin_retry_count, 0);
41748 def_timeout = le16_to_cpu(ddb_entry->fw_ddb_entry.def_timeout);
41749 ddb_entry->default_relogin_timeout =
41750 (def_timeout > LOGIN_TOV) && (def_timeout < LOGIN_TOV * 10) ?
41751 diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
41752 index 2c0d0ec..4e8681a 100644
41753 --- a/drivers/scsi/scsi.c
41754 +++ b/drivers/scsi/scsi.c
41755 @@ -661,7 +661,7 @@ int scsi_dispatch_cmd(struct scsi_cmnd *cmd)
41756 unsigned long timeout;
41757 int rtn = 0;
41758
41759 - atomic_inc(&cmd->device->iorequest_cnt);
41760 + atomic_inc_unchecked(&cmd->device->iorequest_cnt);
41761
41762 /* check if the device is still usable */
41763 if (unlikely(cmd->device->sdev_state == SDEV_DEL)) {
41764 diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
41765 index f1bf5af..f67e943 100644
41766 --- a/drivers/scsi/scsi_lib.c
41767 +++ b/drivers/scsi/scsi_lib.c
41768 @@ -1454,7 +1454,7 @@ static void scsi_kill_request(struct request *req, struct request_queue *q)
41769 shost = sdev->host;
41770 scsi_init_cmd_errh(cmd);
41771 cmd->result = DID_NO_CONNECT << 16;
41772 - atomic_inc(&cmd->device->iorequest_cnt);
41773 + atomic_inc_unchecked(&cmd->device->iorequest_cnt);
41774
41775 /*
41776 * SCSI request completion path will do scsi_device_unbusy(),
41777 @@ -1480,9 +1480,9 @@ static void scsi_softirq_done(struct request *rq)
41778
41779 INIT_LIST_HEAD(&cmd->eh_entry);
41780
41781 - atomic_inc(&cmd->device->iodone_cnt);
41782 + atomic_inc_unchecked(&cmd->device->iodone_cnt);
41783 if (cmd->result)
41784 - atomic_inc(&cmd->device->ioerr_cnt);
41785 + atomic_inc_unchecked(&cmd->device->ioerr_cnt);
41786
41787 disposition = scsi_decide_disposition(cmd);
41788 if (disposition != SUCCESS &&
41789 diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
41790 index 931a7d9..0c2a754 100644
41791 --- a/drivers/scsi/scsi_sysfs.c
41792 +++ b/drivers/scsi/scsi_sysfs.c
41793 @@ -658,7 +658,7 @@ show_iostat_##field(struct device *dev, struct device_attribute *attr, \
41794 char *buf) \
41795 { \
41796 struct scsi_device *sdev = to_scsi_device(dev); \
41797 - unsigned long long count = atomic_read(&sdev->field); \
41798 + unsigned long long count = atomic_read_unchecked(&sdev->field); \
41799 return snprintf(buf, 20, "0x%llx\n", count); \
41800 } \
41801 static DEVICE_ATTR(field, S_IRUGO, show_iostat_##field, NULL)
41802 diff --git a/drivers/scsi/scsi_tgt_lib.c b/drivers/scsi/scsi_tgt_lib.c
41803 index 84a1fdf..693b0d6 100644
41804 --- a/drivers/scsi/scsi_tgt_lib.c
41805 +++ b/drivers/scsi/scsi_tgt_lib.c
41806 @@ -362,7 +362,7 @@ static int scsi_map_user_pages(struct scsi_tgt_cmd *tcmd, struct scsi_cmnd *cmd,
41807 int err;
41808
41809 dprintk("%lx %u\n", uaddr, len);
41810 - err = blk_rq_map_user(q, rq, NULL, (void *)uaddr, len, GFP_KERNEL);
41811 + err = blk_rq_map_user(q, rq, NULL, (void __user *)uaddr, len, GFP_KERNEL);
41812 if (err) {
41813 /*
41814 * TODO: need to fixup sg_tablesize, max_segment_size,
41815 diff --git a/drivers/scsi/scsi_transport_fc.c b/drivers/scsi/scsi_transport_fc.c
41816 index e894ca7..de9d7660 100644
41817 --- a/drivers/scsi/scsi_transport_fc.c
41818 +++ b/drivers/scsi/scsi_transport_fc.c
41819 @@ -498,7 +498,7 @@ static DECLARE_TRANSPORT_CLASS(fc_vport_class,
41820 * Netlink Infrastructure
41821 */
41822
41823 -static atomic_t fc_event_seq;
41824 +static atomic_unchecked_t fc_event_seq;
41825
41826 /**
41827 * fc_get_event_number - Obtain the next sequential FC event number
41828 @@ -511,7 +511,7 @@ static atomic_t fc_event_seq;
41829 u32
41830 fc_get_event_number(void)
41831 {
41832 - return atomic_add_return(1, &fc_event_seq);
41833 + return atomic_add_return_unchecked(1, &fc_event_seq);
41834 }
41835 EXPORT_SYMBOL(fc_get_event_number);
41836
41837 @@ -659,7 +659,7 @@ static __init int fc_transport_init(void)
41838 {
41839 int error;
41840
41841 - atomic_set(&fc_event_seq, 0);
41842 + atomic_set_unchecked(&fc_event_seq, 0);
41843
41844 error = transport_class_register(&fc_host_class);
41845 if (error)
41846 @@ -849,7 +849,7 @@ static int fc_str_to_dev_loss(const char *buf, unsigned long *val)
41847 char *cp;
41848
41849 *val = simple_strtoul(buf, &cp, 0);
41850 - if ((*cp && (*cp != '\n')) || (*val < 0))
41851 + if (*cp && (*cp != '\n'))
41852 return -EINVAL;
41853 /*
41854 * Check for overflow; dev_loss_tmo is u32
41855 diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c
41856 index 31969f2..2b348f0 100644
41857 --- a/drivers/scsi/scsi_transport_iscsi.c
41858 +++ b/drivers/scsi/scsi_transport_iscsi.c
41859 @@ -79,7 +79,7 @@ struct iscsi_internal {
41860 struct transport_container session_cont;
41861 };
41862
41863 -static atomic_t iscsi_session_nr; /* sysfs session id for next new session */
41864 +static atomic_unchecked_t iscsi_session_nr; /* sysfs session id for next new session */
41865 static struct workqueue_struct *iscsi_eh_timer_workq;
41866
41867 static DEFINE_IDA(iscsi_sess_ida);
41868 @@ -1064,7 +1064,7 @@ int iscsi_add_session(struct iscsi_cls_session *session, unsigned int target_id)
41869 int err;
41870
41871 ihost = shost->shost_data;
41872 - session->sid = atomic_add_return(1, &iscsi_session_nr);
41873 + session->sid = atomic_add_return_unchecked(1, &iscsi_session_nr);
41874
41875 if (target_id == ISCSI_MAX_TARGET) {
41876 id = ida_simple_get(&iscsi_sess_ida, 0, 0, GFP_KERNEL);
41877 @@ -2943,7 +2943,7 @@ static __init int iscsi_transport_init(void)
41878 printk(KERN_INFO "Loading iSCSI transport class v%s.\n",
41879 ISCSI_TRANSPORT_VERSION);
41880
41881 - atomic_set(&iscsi_session_nr, 0);
41882 + atomic_set_unchecked(&iscsi_session_nr, 0);
41883
41884 err = class_register(&iscsi_transport_class);
41885 if (err)
41886 diff --git a/drivers/scsi/scsi_transport_srp.c b/drivers/scsi/scsi_transport_srp.c
41887 index f379c7f..e8fc69c 100644
41888 --- a/drivers/scsi/scsi_transport_srp.c
41889 +++ b/drivers/scsi/scsi_transport_srp.c
41890 @@ -33,7 +33,7 @@
41891 #include "scsi_transport_srp_internal.h"
41892
41893 struct srp_host_attrs {
41894 - atomic_t next_port_id;
41895 + atomic_unchecked_t next_port_id;
41896 };
41897 #define to_srp_host_attrs(host) ((struct srp_host_attrs *)(host)->shost_data)
41898
41899 @@ -61,7 +61,7 @@ static int srp_host_setup(struct transport_container *tc, struct device *dev,
41900 struct Scsi_Host *shost = dev_to_shost(dev);
41901 struct srp_host_attrs *srp_host = to_srp_host_attrs(shost);
41902
41903 - atomic_set(&srp_host->next_port_id, 0);
41904 + atomic_set_unchecked(&srp_host->next_port_id, 0);
41905 return 0;
41906 }
41907
41908 @@ -210,7 +210,7 @@ struct srp_rport *srp_rport_add(struct Scsi_Host *shost,
41909 memcpy(rport->port_id, ids->port_id, sizeof(rport->port_id));
41910 rport->roles = ids->roles;
41911
41912 - id = atomic_inc_return(&to_srp_host_attrs(shost)->next_port_id);
41913 + id = atomic_inc_return_unchecked(&to_srp_host_attrs(shost)->next_port_id);
41914 dev_set_name(&rport->dev, "port-%d:%d", shost->host_no, id);
41915
41916 transport_setup_device(&rport->dev);
41917 diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
41918 index 7992635..609faf8 100644
41919 --- a/drivers/scsi/sd.c
41920 +++ b/drivers/scsi/sd.c
41921 @@ -2909,7 +2909,7 @@ static int sd_probe(struct device *dev)
41922 sdkp->disk = gd;
41923 sdkp->index = index;
41924 atomic_set(&sdkp->openers, 0);
41925 - atomic_set(&sdkp->device->ioerr_cnt, 0);
41926 + atomic_set_unchecked(&sdkp->device->ioerr_cnt, 0);
41927
41928 if (!sdp->request_queue->rq_timeout) {
41929 if (sdp->type != TYPE_MOD)
41930 diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
41931 index be2c9a6..275525c 100644
41932 --- a/drivers/scsi/sg.c
41933 +++ b/drivers/scsi/sg.c
41934 @@ -1101,7 +1101,7 @@ sg_ioctl(struct file *filp, unsigned int cmd_in, unsigned long arg)
41935 sdp->disk->disk_name,
41936 MKDEV(SCSI_GENERIC_MAJOR, sdp->index),
41937 NULL,
41938 - (char *)arg);
41939 + (char __user *)arg);
41940 case BLKTRACESTART:
41941 return blk_trace_startstop(sdp->device->request_queue, 1);
41942 case BLKTRACESTOP:
41943 diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
41944 index 19ee901..6e8c2ef 100644
41945 --- a/drivers/spi/spi.c
41946 +++ b/drivers/spi/spi.c
41947 @@ -1616,7 +1616,7 @@ int spi_bus_unlock(struct spi_master *master)
41948 EXPORT_SYMBOL_GPL(spi_bus_unlock);
41949
41950 /* portable code must never pass more than 32 bytes */
41951 -#define SPI_BUFSIZ max(32,SMP_CACHE_BYTES)
41952 +#define SPI_BUFSIZ max(32UL,SMP_CACHE_BYTES)
41953
41954 static u8 *buf;
41955
41956 diff --git a/drivers/staging/iio/iio_hwmon.c b/drivers/staging/iio/iio_hwmon.c
41957 index c7a5f97..71ecd35 100644
41958 --- a/drivers/staging/iio/iio_hwmon.c
41959 +++ b/drivers/staging/iio/iio_hwmon.c
41960 @@ -72,7 +72,7 @@ static void iio_hwmon_free_attrs(struct iio_hwmon_state *st)
41961 static int iio_hwmon_probe(struct platform_device *pdev)
41962 {
41963 struct iio_hwmon_state *st;
41964 - struct sensor_device_attribute *a;
41965 + sensor_device_attribute_no_const *a;
41966 int ret, i;
41967 int in_i = 1, temp_i = 1, curr_i = 1;
41968 enum iio_chan_type type;
41969 diff --git a/drivers/staging/octeon/ethernet-rx.c b/drivers/staging/octeon/ethernet-rx.c
41970 index 34afc16..ffe44dd 100644
41971 --- a/drivers/staging/octeon/ethernet-rx.c
41972 +++ b/drivers/staging/octeon/ethernet-rx.c
41973 @@ -421,11 +421,11 @@ static int cvm_oct_napi_poll(struct napi_struct *napi, int budget)
41974 /* Increment RX stats for virtual ports */
41975 if (work->ipprt >= CVMX_PIP_NUM_INPUT_PORTS) {
41976 #ifdef CONFIG_64BIT
41977 - atomic64_add(1, (atomic64_t *)&priv->stats.rx_packets);
41978 - atomic64_add(skb->len, (atomic64_t *)&priv->stats.rx_bytes);
41979 + atomic64_add_unchecked(1, (atomic64_unchecked_t *)&priv->stats.rx_packets);
41980 + atomic64_add_unchecked(skb->len, (atomic64_unchecked_t *)&priv->stats.rx_bytes);
41981 #else
41982 - atomic_add(1, (atomic_t *)&priv->stats.rx_packets);
41983 - atomic_add(skb->len, (atomic_t *)&priv->stats.rx_bytes);
41984 + atomic_add_unchecked(1, (atomic_unchecked_t *)&priv->stats.rx_packets);
41985 + atomic_add_unchecked(skb->len, (atomic_unchecked_t *)&priv->stats.rx_bytes);
41986 #endif
41987 }
41988 netif_receive_skb(skb);
41989 @@ -437,9 +437,9 @@ static int cvm_oct_napi_poll(struct napi_struct *napi, int budget)
41990 dev->name);
41991 */
41992 #ifdef CONFIG_64BIT
41993 - atomic64_add(1, (atomic64_t *)&priv->stats.rx_dropped);
41994 + atomic64_unchecked_add(1, (atomic64_unchecked_t *)&priv->stats.rx_dropped);
41995 #else
41996 - atomic_add(1, (atomic_t *)&priv->stats.rx_dropped);
41997 + atomic_add_unchecked(1, (atomic_unchecked_t *)&priv->stats.rx_dropped);
41998 #endif
41999 dev_kfree_skb_irq(skb);
42000 }
42001 diff --git a/drivers/staging/octeon/ethernet.c b/drivers/staging/octeon/ethernet.c
42002 index ef32dc1..a159d68 100644
42003 --- a/drivers/staging/octeon/ethernet.c
42004 +++ b/drivers/staging/octeon/ethernet.c
42005 @@ -252,11 +252,11 @@ static struct net_device_stats *cvm_oct_common_get_stats(struct net_device *dev)
42006 * since the RX tasklet also increments it.
42007 */
42008 #ifdef CONFIG_64BIT
42009 - atomic64_add(rx_status.dropped_packets,
42010 - (atomic64_t *)&priv->stats.rx_dropped);
42011 + atomic64_add_unchecked(rx_status.dropped_packets,
42012 + (atomic64_unchecked_t *)&priv->stats.rx_dropped);
42013 #else
42014 - atomic_add(rx_status.dropped_packets,
42015 - (atomic_t *)&priv->stats.rx_dropped);
42016 + atomic_add_unchecked(rx_status.dropped_packets,
42017 + (atomic_unchecked_t *)&priv->stats.rx_dropped);
42018 #endif
42019 }
42020
42021 diff --git a/drivers/staging/ramster/tmem.c b/drivers/staging/ramster/tmem.c
42022 index a2b7e03..aaf3630 100644
42023 --- a/drivers/staging/ramster/tmem.c
42024 +++ b/drivers/staging/ramster/tmem.c
42025 @@ -50,25 +50,25 @@
42026 * A tmem host implementation must use this function to register callbacks
42027 * for memory allocation.
42028 */
42029 -static struct tmem_hostops tmem_hostops;
42030 +static struct tmem_hostops *tmem_hostops;
42031
42032 static void tmem_objnode_tree_init(void);
42033
42034 void tmem_register_hostops(struct tmem_hostops *m)
42035 {
42036 tmem_objnode_tree_init();
42037 - tmem_hostops = *m;
42038 + tmem_hostops = m;
42039 }
42040
42041 /*
42042 * A tmem host implementation must use this function to register
42043 * callbacks for a page-accessible memory (PAM) implementation.
42044 */
42045 -static struct tmem_pamops tmem_pamops;
42046 +static struct tmem_pamops *tmem_pamops;
42047
42048 void tmem_register_pamops(struct tmem_pamops *m)
42049 {
42050 - tmem_pamops = *m;
42051 + tmem_pamops = m;
42052 }
42053
42054 /*
42055 @@ -174,7 +174,7 @@ static void tmem_obj_init(struct tmem_obj *obj, struct tmem_hashbucket *hb,
42056 obj->pampd_count = 0;
42057 #ifdef CONFIG_RAMSTER
42058 if (tmem_pamops.new_obj != NULL)
42059 - (*tmem_pamops.new_obj)(obj);
42060 + (tmem_pamops->new_obj)(obj);
42061 #endif
42062 SET_SENTINEL(obj, OBJ);
42063
42064 @@ -210,7 +210,7 @@ static void tmem_pool_flush(struct tmem_pool *pool, bool destroy)
42065 rbnode = rb_next(rbnode);
42066 tmem_pampd_destroy_all_in_obj(obj, true);
42067 tmem_obj_free(obj, hb);
42068 - (*tmem_hostops.obj_free)(obj, pool);
42069 + (tmem_hostops->obj_free)(obj, pool);
42070 }
42071 spin_unlock(&hb->lock);
42072 }
42073 @@ -261,7 +261,7 @@ static struct tmem_objnode *tmem_objnode_alloc(struct tmem_obj *obj)
42074 ASSERT_SENTINEL(obj, OBJ);
42075 BUG_ON(obj->pool == NULL);
42076 ASSERT_SENTINEL(obj->pool, POOL);
42077 - objnode = (*tmem_hostops.objnode_alloc)(obj->pool);
42078 + objnode = (tmem_hostops->objnode_alloc)(obj->pool);
42079 if (unlikely(objnode == NULL))
42080 goto out;
42081 objnode->obj = obj;
42082 @@ -290,7 +290,7 @@ static void tmem_objnode_free(struct tmem_objnode *objnode)
42083 ASSERT_SENTINEL(pool, POOL);
42084 objnode->obj->objnode_count--;
42085 objnode->obj = NULL;
42086 - (*tmem_hostops.objnode_free)(objnode, pool);
42087 + (tmem_hostops->objnode_free)(objnode, pool);
42088 }
42089
42090 /*
42091 @@ -348,7 +348,7 @@ static void *tmem_pampd_replace_in_obj(struct tmem_obj *obj, uint32_t index,
42092 void *old_pampd = *(void **)slot;
42093 *(void **)slot = new_pampd;
42094 if (!no_free)
42095 - (*tmem_pamops.free)(old_pampd, obj->pool,
42096 + (tmem_pamops->free)(old_pampd, obj->pool,
42097 NULL, 0, false);
42098 ret = new_pampd;
42099 }
42100 @@ -505,7 +505,7 @@ static void tmem_objnode_node_destroy(struct tmem_obj *obj,
42101 if (objnode->slots[i]) {
42102 if (ht == 1) {
42103 obj->pampd_count--;
42104 - (*tmem_pamops.free)(objnode->slots[i],
42105 + (tmem_pamops->free)(objnode->slots[i],
42106 obj->pool, NULL, 0, true);
42107 objnode->slots[i] = NULL;
42108 continue;
42109 @@ -524,7 +524,7 @@ static void tmem_pampd_destroy_all_in_obj(struct tmem_obj *obj,
42110 return;
42111 if (obj->objnode_tree_height == 0) {
42112 obj->pampd_count--;
42113 - (*tmem_pamops.free)(obj->objnode_tree_root,
42114 + (tmem_pamops->free)(obj->objnode_tree_root,
42115 obj->pool, NULL, 0, true);
42116 } else {
42117 tmem_objnode_node_destroy(obj, obj->objnode_tree_root,
42118 @@ -535,7 +535,7 @@ static void tmem_pampd_destroy_all_in_obj(struct tmem_obj *obj,
42119 obj->objnode_tree_root = NULL;
42120 #ifdef CONFIG_RAMSTER
42121 if (tmem_pamops.free_obj != NULL)
42122 - (*tmem_pamops.free_obj)(obj->pool, obj, pool_destroy);
42123 + (tmem_pamops->free_obj)(obj->pool, obj, pool_destroy);
42124 #endif
42125 }
42126
42127 @@ -574,7 +574,7 @@ int tmem_put(struct tmem_pool *pool, struct tmem_oid *oidp, uint32_t index,
42128 /* if found, is a dup put, flush the old one */
42129 pampd_del = tmem_pampd_delete_from_obj(obj, index);
42130 BUG_ON(pampd_del != pampd);
42131 - (*tmem_pamops.free)(pampd, pool, oidp, index, true);
42132 + (tmem_pamops->free)(pampd, pool, oidp, index, true);
42133 if (obj->pampd_count == 0) {
42134 objnew = obj;
42135 objfound = NULL;
42136 @@ -582,7 +582,7 @@ int tmem_put(struct tmem_pool *pool, struct tmem_oid *oidp, uint32_t index,
42137 pampd = NULL;
42138 }
42139 } else {
42140 - obj = objnew = (*tmem_hostops.obj_alloc)(pool);
42141 + obj = objnew = (tmem_hostops->obj_alloc)(pool);
42142 if (unlikely(obj == NULL)) {
42143 ret = -ENOMEM;
42144 goto out;
42145 @@ -597,16 +597,16 @@ int tmem_put(struct tmem_pool *pool, struct tmem_oid *oidp, uint32_t index,
42146 if (unlikely(ret == -ENOMEM))
42147 /* may have partially built objnode tree ("stump") */
42148 goto delete_and_free;
42149 - (*tmem_pamops.create_finish)(pampd, is_ephemeral(pool));
42150 + (tmem_pamops->create_finish)(pampd, is_ephemeral(pool));
42151 goto out;
42152
42153 delete_and_free:
42154 (void)tmem_pampd_delete_from_obj(obj, index);
42155 if (pampd)
42156 - (*tmem_pamops.free)(pampd, pool, NULL, 0, true);
42157 + (tmem_pamops->free)(pampd, pool, NULL, 0, true);
42158 if (objnew) {
42159 tmem_obj_free(objnew, hb);
42160 - (*tmem_hostops.obj_free)(objnew, pool);
42161 + (tmem_hostops->obj_free)(objnew, pool);
42162 }
42163 out:
42164 spin_unlock(&hb->lock);
42165 @@ -651,7 +651,7 @@ void tmem_localify_finish(struct tmem_obj *obj, uint32_t index,
42166 if (pampd != NULL) {
42167 BUG_ON(obj == NULL);
42168 (void)tmem_pampd_replace_in_obj(obj, index, pampd, 1);
42169 - (*tmem_pamops.create_finish)(pampd, is_ephemeral(obj->pool));
42170 + (tmem_pamops->create_finish)(pampd, is_ephemeral(obj->pool));
42171 } else if (delete) {
42172 BUG_ON(obj == NULL);
42173 (void)tmem_pampd_delete_from_obj(obj, index);
42174 @@ -671,7 +671,7 @@ static int tmem_repatriate(void **ppampd, struct tmem_hashbucket *hb,
42175 int ret = 0;
42176
42177 if (!is_ephemeral(pool))
42178 - new_pampd = (*tmem_pamops.repatriate_preload)(
42179 + new_pampd = (tmem_pamops->repatriate_preload)(
42180 old_pampd, pool, oidp, index, &intransit);
42181 if (intransit)
42182 ret = -EAGAIN;
42183 @@ -680,7 +680,7 @@ static int tmem_repatriate(void **ppampd, struct tmem_hashbucket *hb,
42184 /* must release the hb->lock else repatriate can't sleep */
42185 spin_unlock(&hb->lock);
42186 if (!intransit)
42187 - ret = (*tmem_pamops.repatriate)(old_pampd, new_pampd, pool,
42188 + ret = (tmem_pamops->repatriate)(old_pampd, new_pampd, pool,
42189 oidp, index, free, data);
42190 if (ret == -EAGAIN) {
42191 /* rare I think, but should cond_resched()??? */
42192 @@ -714,7 +714,7 @@ int tmem_replace(struct tmem_pool *pool, struct tmem_oid *oidp,
42193 new_pampd = tmem_pampd_replace_in_obj(obj, index, new_pampd, 0);
42194 /* if we bug here, pamops wasn't properly set up for ramster */
42195 BUG_ON(tmem_pamops.replace_in_obj == NULL);
42196 - ret = (*tmem_pamops.replace_in_obj)(new_pampd, obj);
42197 + ret = (tmem_pamops->replace_in_obj)(new_pampd, obj);
42198 out:
42199 spin_unlock(&hb->lock);
42200 return ret;
42201 @@ -776,15 +776,15 @@ int tmem_get(struct tmem_pool *pool, struct tmem_oid *oidp, uint32_t index,
42202 if (free) {
42203 if (obj->pampd_count == 0) {
42204 tmem_obj_free(obj, hb);
42205 - (*tmem_hostops.obj_free)(obj, pool);
42206 + (tmem_hostops->obj_free)(obj, pool);
42207 obj = NULL;
42208 }
42209 }
42210 if (free)
42211 - ret = (*tmem_pamops.get_data_and_free)(
42212 + ret = (tmem_pamops->get_data_and_free)(
42213 data, sizep, raw, pampd, pool, oidp, index);
42214 else
42215 - ret = (*tmem_pamops.get_data)(
42216 + ret = (tmem_pamops->get_data)(
42217 data, sizep, raw, pampd, pool, oidp, index);
42218 if (ret < 0)
42219 goto out;
42220 @@ -816,10 +816,10 @@ int tmem_flush_page(struct tmem_pool *pool,
42221 pampd = tmem_pampd_delete_from_obj(obj, index);
42222 if (pampd == NULL)
42223 goto out;
42224 - (*tmem_pamops.free)(pampd, pool, oidp, index, true);
42225 + (tmem_pamops->free)(pampd, pool, oidp, index, true);
42226 if (obj->pampd_count == 0) {
42227 tmem_obj_free(obj, hb);
42228 - (*tmem_hostops.obj_free)(obj, pool);
42229 + (tmem_hostops->obj_free)(obj, pool);
42230 }
42231 ret = 0;
42232
42233 @@ -844,7 +844,7 @@ int tmem_flush_object(struct tmem_pool *pool, struct tmem_oid *oidp)
42234 goto out;
42235 tmem_pampd_destroy_all_in_obj(obj, false);
42236 tmem_obj_free(obj, hb);
42237 - (*tmem_hostops.obj_free)(obj, pool);
42238 + (tmem_hostops->obj_free)(obj, pool);
42239 ret = 0;
42240
42241 out:
42242 diff --git a/drivers/staging/rtl8712/rtl871x_io.h b/drivers/staging/rtl8712/rtl871x_io.h
42243 index dc23395..cf7e9b1 100644
42244 --- a/drivers/staging/rtl8712/rtl871x_io.h
42245 +++ b/drivers/staging/rtl8712/rtl871x_io.h
42246 @@ -108,7 +108,7 @@ struct _io_ops {
42247 u8 *pmem);
42248 u32 (*_write_port)(struct intf_hdl *pintfhdl, u32 addr, u32 cnt,
42249 u8 *pmem);
42250 -};
42251 +} __no_const;
42252
42253 struct io_req {
42254 struct list_head list;
42255 diff --git a/drivers/staging/sbe-2t3e3/netdev.c b/drivers/staging/sbe-2t3e3/netdev.c
42256 index 1f5088b..0e59820 100644
42257 --- a/drivers/staging/sbe-2t3e3/netdev.c
42258 +++ b/drivers/staging/sbe-2t3e3/netdev.c
42259 @@ -51,7 +51,7 @@ static int t3e3_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
42260 t3e3_if_config(sc, cmd_2t3e3, (char *)&param, &resp, &rlen);
42261
42262 if (rlen)
42263 - if (copy_to_user(data, &resp, rlen))
42264 + if (rlen > sizeof resp || copy_to_user(data, &resp, rlen))
42265 return -EFAULT;
42266
42267 return 0;
42268 diff --git a/drivers/staging/usbip/vhci.h b/drivers/staging/usbip/vhci.h
42269 index 5dddc4d..34fcb2f 100644
42270 --- a/drivers/staging/usbip/vhci.h
42271 +++ b/drivers/staging/usbip/vhci.h
42272 @@ -83,7 +83,7 @@ struct vhci_hcd {
42273 unsigned resuming:1;
42274 unsigned long re_timeout;
42275
42276 - atomic_t seqnum;
42277 + atomic_unchecked_t seqnum;
42278
42279 /*
42280 * NOTE:
42281 diff --git a/drivers/staging/usbip/vhci_hcd.c b/drivers/staging/usbip/vhci_hcd.c
42282 index c3aa219..bf8b3de 100644
42283 --- a/drivers/staging/usbip/vhci_hcd.c
42284 +++ b/drivers/staging/usbip/vhci_hcd.c
42285 @@ -451,7 +451,7 @@ static void vhci_tx_urb(struct urb *urb)
42286 return;
42287 }
42288
42289 - priv->seqnum = atomic_inc_return(&the_controller->seqnum);
42290 + priv->seqnum = atomic_inc_return_unchecked(&the_controller->seqnum);
42291 if (priv->seqnum == 0xffff)
42292 dev_info(&urb->dev->dev, "seqnum max\n");
42293
42294 @@ -703,7 +703,7 @@ static int vhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status)
42295 return -ENOMEM;
42296 }
42297
42298 - unlink->seqnum = atomic_inc_return(&the_controller->seqnum);
42299 + unlink->seqnum = atomic_inc_return_unchecked(&the_controller->seqnum);
42300 if (unlink->seqnum == 0xffff)
42301 pr_info("seqnum max\n");
42302
42303 @@ -907,7 +907,7 @@ static int vhci_start(struct usb_hcd *hcd)
42304 vdev->rhport = rhport;
42305 }
42306
42307 - atomic_set(&vhci->seqnum, 0);
42308 + atomic_set_unchecked(&vhci->seqnum, 0);
42309 spin_lock_init(&vhci->lock);
42310
42311 hcd->power_budget = 0; /* no limit */
42312 diff --git a/drivers/staging/usbip/vhci_rx.c b/drivers/staging/usbip/vhci_rx.c
42313 index ba5f1c0..11d8122 100644
42314 --- a/drivers/staging/usbip/vhci_rx.c
42315 +++ b/drivers/staging/usbip/vhci_rx.c
42316 @@ -77,7 +77,7 @@ static void vhci_recv_ret_submit(struct vhci_device *vdev,
42317 if (!urb) {
42318 pr_err("cannot find a urb of seqnum %u\n", pdu->base.seqnum);
42319 pr_info("max seqnum %d\n",
42320 - atomic_read(&the_controller->seqnum));
42321 + atomic_read_unchecked(&the_controller->seqnum));
42322 usbip_event_add(ud, VDEV_EVENT_ERROR_TCP);
42323 return;
42324 }
42325 diff --git a/drivers/staging/vt6655/hostap.c b/drivers/staging/vt6655/hostap.c
42326 index 5f13890..36a044b 100644
42327 --- a/drivers/staging/vt6655/hostap.c
42328 +++ b/drivers/staging/vt6655/hostap.c
42329 @@ -73,14 +73,13 @@ static int msglevel =MSG_LEVEL_INFO;
42330 *
42331 */
42332
42333 +static net_device_ops_no_const apdev_netdev_ops;
42334 +
42335 static int hostap_enable_hostapd(PSDevice pDevice, int rtnl_locked)
42336 {
42337 PSDevice apdev_priv;
42338 struct net_device *dev = pDevice->dev;
42339 int ret;
42340 - const struct net_device_ops apdev_netdev_ops = {
42341 - .ndo_start_xmit = pDevice->tx_80211,
42342 - };
42343
42344 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%s: Enabling hostapd mode\n", dev->name);
42345
42346 @@ -92,6 +91,8 @@ static int hostap_enable_hostapd(PSDevice pDevice, int rtnl_locked)
42347 *apdev_priv = *pDevice;
42348 memcpy(pDevice->apdev->dev_addr, dev->dev_addr, ETH_ALEN);
42349
42350 + /* only half broken now */
42351 + apdev_netdev_ops.ndo_start_xmit = pDevice->tx_80211;
42352 pDevice->apdev->netdev_ops = &apdev_netdev_ops;
42353
42354 pDevice->apdev->type = ARPHRD_IEEE80211;
42355 diff --git a/drivers/staging/vt6656/hostap.c b/drivers/staging/vt6656/hostap.c
42356 index 26a7d0e..897b083 100644
42357 --- a/drivers/staging/vt6656/hostap.c
42358 +++ b/drivers/staging/vt6656/hostap.c
42359 @@ -60,14 +60,13 @@ static int msglevel =MSG_LEVEL_INFO;
42360 *
42361 */
42362
42363 +static net_device_ops_no_const apdev_netdev_ops;
42364 +
42365 static int hostap_enable_hostapd(PSDevice pDevice, int rtnl_locked)
42366 {
42367 PSDevice apdev_priv;
42368 struct net_device *dev = pDevice->dev;
42369 int ret;
42370 - const struct net_device_ops apdev_netdev_ops = {
42371 - .ndo_start_xmit = pDevice->tx_80211,
42372 - };
42373
42374 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%s: Enabling hostapd mode\n", dev->name);
42375
42376 @@ -79,6 +78,8 @@ static int hostap_enable_hostapd(PSDevice pDevice, int rtnl_locked)
42377 *apdev_priv = *pDevice;
42378 memcpy(pDevice->apdev->dev_addr, dev->dev_addr, ETH_ALEN);
42379
42380 + /* only half broken now */
42381 + apdev_netdev_ops.ndo_start_xmit = pDevice->tx_80211;
42382 pDevice->apdev->netdev_ops = &apdev_netdev_ops;
42383
42384 pDevice->apdev->type = ARPHRD_IEEE80211;
42385 diff --git a/drivers/staging/zcache/tmem.c b/drivers/staging/zcache/tmem.c
42386 index 56c8e60..1920c63 100644
42387 --- a/drivers/staging/zcache/tmem.c
42388 +++ b/drivers/staging/zcache/tmem.c
42389 @@ -39,7 +39,7 @@
42390 * A tmem host implementation must use this function to register callbacks
42391 * for memory allocation.
42392 */
42393 -static struct tmem_hostops tmem_hostops;
42394 +static tmem_hostops_no_const tmem_hostops;
42395
42396 static void tmem_objnode_tree_init(void);
42397
42398 @@ -53,7 +53,7 @@ void tmem_register_hostops(struct tmem_hostops *m)
42399 * A tmem host implementation must use this function to register
42400 * callbacks for a page-accessible memory (PAM) implementation
42401 */
42402 -static struct tmem_pamops tmem_pamops;
42403 +static tmem_pamops_no_const tmem_pamops;
42404
42405 void tmem_register_pamops(struct tmem_pamops *m)
42406 {
42407 diff --git a/drivers/staging/zcache/tmem.h b/drivers/staging/zcache/tmem.h
42408 index 0d4aa82..f7832d4 100644
42409 --- a/drivers/staging/zcache/tmem.h
42410 +++ b/drivers/staging/zcache/tmem.h
42411 @@ -180,6 +180,7 @@ struct tmem_pamops {
42412 void (*new_obj)(struct tmem_obj *);
42413 int (*replace_in_obj)(void *, struct tmem_obj *);
42414 };
42415 +typedef struct tmem_pamops __no_const tmem_pamops_no_const;
42416 extern void tmem_register_pamops(struct tmem_pamops *m);
42417
42418 /* memory allocation methods provided by the host implementation */
42419 @@ -189,6 +190,7 @@ struct tmem_hostops {
42420 struct tmem_objnode *(*objnode_alloc)(struct tmem_pool *);
42421 void (*objnode_free)(struct tmem_objnode *, struct tmem_pool *);
42422 };
42423 +typedef struct tmem_hostops __no_const tmem_hostops_no_const;
42424 extern void tmem_register_hostops(struct tmem_hostops *m);
42425
42426 /* core tmem accessor functions */
42427 diff --git a/drivers/target/target_core_device.c b/drivers/target/target_core_device.c
42428 index 96f4981..4daaa7e 100644
42429 --- a/drivers/target/target_core_device.c
42430 +++ b/drivers/target/target_core_device.c
42431 @@ -1370,7 +1370,7 @@ struct se_device *target_alloc_device(struct se_hba *hba, const char *name)
42432 spin_lock_init(&dev->se_port_lock);
42433 spin_lock_init(&dev->se_tmr_lock);
42434 spin_lock_init(&dev->qf_cmd_lock);
42435 - atomic_set(&dev->dev_ordered_id, 0);
42436 + atomic_set_unchecked(&dev->dev_ordered_id, 0);
42437 INIT_LIST_HEAD(&dev->t10_wwn.t10_vpd_list);
42438 spin_lock_init(&dev->t10_wwn.t10_vpd_lock);
42439 INIT_LIST_HEAD(&dev->t10_pr.registration_list);
42440 diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c
42441 index bd587b7..173daf3 100644
42442 --- a/drivers/target/target_core_transport.c
42443 +++ b/drivers/target/target_core_transport.c
42444 @@ -1077,7 +1077,7 @@ transport_check_alloc_task_attr(struct se_cmd *cmd)
42445 * Used to determine when ORDERED commands should go from
42446 * Dormant to Active status.
42447 */
42448 - cmd->se_ordered_id = atomic_inc_return(&dev->dev_ordered_id);
42449 + cmd->se_ordered_id = atomic_inc_return_unchecked(&dev->dev_ordered_id);
42450 smp_mb__after_atomic_inc();
42451 pr_debug("Allocated se_ordered_id: %u for Task Attr: 0x%02x on %s\n",
42452 cmd->se_ordered_id, cmd->sam_task_attr,
42453 diff --git a/drivers/tty/cyclades.c b/drivers/tty/cyclades.c
42454 index b09c8d1f..c4225c0 100644
42455 --- a/drivers/tty/cyclades.c
42456 +++ b/drivers/tty/cyclades.c
42457 @@ -1589,10 +1589,10 @@ static int cy_open(struct tty_struct *tty, struct file *filp)
42458 printk(KERN_DEBUG "cyc:cy_open ttyC%d, count = %d\n", info->line,
42459 info->port.count);
42460 #endif
42461 - info->port.count++;
42462 + atomic_inc(&info->port.count);
42463 #ifdef CY_DEBUG_COUNT
42464 printk(KERN_DEBUG "cyc:cy_open (%d): incrementing count to %d\n",
42465 - current->pid, info->port.count);
42466 + current->pid, atomic_read(&info->port.count));
42467 #endif
42468
42469 /*
42470 @@ -3991,7 +3991,7 @@ static int cyclades_proc_show(struct seq_file *m, void *v)
42471 for (j = 0; j < cy_card[i].nports; j++) {
42472 info = &cy_card[i].ports[j];
42473
42474 - if (info->port.count) {
42475 + if (atomic_read(&info->port.count)) {
42476 /* XXX is the ldisc num worth this? */
42477 struct tty_struct *tty;
42478 struct tty_ldisc *ld;
42479 diff --git a/drivers/tty/hvc/hvc_console.c b/drivers/tty/hvc/hvc_console.c
42480 index 13ee53b..418d164 100644
42481 --- a/drivers/tty/hvc/hvc_console.c
42482 +++ b/drivers/tty/hvc/hvc_console.c
42483 @@ -338,7 +338,7 @@ static int hvc_open(struct tty_struct *tty, struct file * filp)
42484
42485 spin_lock_irqsave(&hp->port.lock, flags);
42486 /* Check and then increment for fast path open. */
42487 - if (hp->port.count++ > 0) {
42488 + if (atomic_inc_return(&hp->port.count) > 1) {
42489 spin_unlock_irqrestore(&hp->port.lock, flags);
42490 hvc_kick();
42491 return 0;
42492 @@ -388,7 +388,7 @@ static void hvc_close(struct tty_struct *tty, struct file * filp)
42493
42494 spin_lock_irqsave(&hp->port.lock, flags);
42495
42496 - if (--hp->port.count == 0) {
42497 + if (atomic_dec_return(&hp->port.count) == 0) {
42498 spin_unlock_irqrestore(&hp->port.lock, flags);
42499 /* We are done with the tty pointer now. */
42500 tty_port_tty_set(&hp->port, NULL);
42501 @@ -406,9 +406,9 @@ static void hvc_close(struct tty_struct *tty, struct file * filp)
42502 */
42503 tty_wait_until_sent_from_close(tty, HVC_CLOSE_WAIT);
42504 } else {
42505 - if (hp->port.count < 0)
42506 + if (atomic_read(&hp->port.count) < 0)
42507 printk(KERN_ERR "hvc_close %X: oops, count is %d\n",
42508 - hp->vtermno, hp->port.count);
42509 + hp->vtermno, atomic_read(&hp->port.count));
42510 spin_unlock_irqrestore(&hp->port.lock, flags);
42511 }
42512 }
42513 @@ -438,12 +438,12 @@ static void hvc_hangup(struct tty_struct *tty)
42514 * open->hangup case this can be called after the final close so prevent
42515 * that from happening for now.
42516 */
42517 - if (hp->port.count <= 0) {
42518 + if (atomic_read(&hp->port.count) <= 0) {
42519 spin_unlock_irqrestore(&hp->port.lock, flags);
42520 return;
42521 }
42522
42523 - hp->port.count = 0;
42524 + atomic_set(&hp->port.count, 0);
42525 spin_unlock_irqrestore(&hp->port.lock, flags);
42526 tty_port_tty_set(&hp->port, NULL);
42527
42528 @@ -491,7 +491,7 @@ static int hvc_write(struct tty_struct *tty, const unsigned char *buf, int count
42529 return -EPIPE;
42530
42531 /* FIXME what's this (unprotected) check for? */
42532 - if (hp->port.count <= 0)
42533 + if (atomic_read(&hp->port.count) <= 0)
42534 return -EIO;
42535
42536 spin_lock_irqsave(&hp->lock, flags);
42537 diff --git a/drivers/tty/hvc/hvcs.c b/drivers/tty/hvc/hvcs.c
42538 index 8776357..b2d4afd 100644
42539 --- a/drivers/tty/hvc/hvcs.c
42540 +++ b/drivers/tty/hvc/hvcs.c
42541 @@ -83,6 +83,7 @@
42542 #include <asm/hvcserver.h>
42543 #include <asm/uaccess.h>
42544 #include <asm/vio.h>
42545 +#include <asm/local.h>
42546
42547 /*
42548 * 1.3.0 -> 1.3.1 In hvcs_open memset(..,0x00,..) instead of memset(..,0x3F,00).
42549 @@ -416,7 +417,7 @@ static ssize_t hvcs_vterm_state_store(struct device *dev, struct device_attribut
42550
42551 spin_lock_irqsave(&hvcsd->lock, flags);
42552
42553 - if (hvcsd->port.count > 0) {
42554 + if (atomic_read(&hvcsd->port.count) > 0) {
42555 spin_unlock_irqrestore(&hvcsd->lock, flags);
42556 printk(KERN_INFO "HVCS: vterm state unchanged. "
42557 "The hvcs device node is still in use.\n");
42558 @@ -1132,7 +1133,7 @@ static int hvcs_install(struct tty_driver *driver, struct tty_struct *tty)
42559 }
42560 }
42561
42562 - hvcsd->port.count = 0;
42563 + atomic_set(&hvcsd->port.count, 0);
42564 hvcsd->port.tty = tty;
42565 tty->driver_data = hvcsd;
42566
42567 @@ -1185,7 +1186,7 @@ static int hvcs_open(struct tty_struct *tty, struct file *filp)
42568 unsigned long flags;
42569
42570 spin_lock_irqsave(&hvcsd->lock, flags);
42571 - hvcsd->port.count++;
42572 + atomic_inc(&hvcsd->port.count);
42573 hvcsd->todo_mask |= HVCS_SCHED_READ;
42574 spin_unlock_irqrestore(&hvcsd->lock, flags);
42575
42576 @@ -1221,7 +1222,7 @@ static void hvcs_close(struct tty_struct *tty, struct file *filp)
42577 hvcsd = tty->driver_data;
42578
42579 spin_lock_irqsave(&hvcsd->lock, flags);
42580 - if (--hvcsd->port.count == 0) {
42581 + if (atomic_dec_and_test(&hvcsd->port.count)) {
42582
42583 vio_disable_interrupts(hvcsd->vdev);
42584
42585 @@ -1246,10 +1247,10 @@ static void hvcs_close(struct tty_struct *tty, struct file *filp)
42586
42587 free_irq(irq, hvcsd);
42588 return;
42589 - } else if (hvcsd->port.count < 0) {
42590 + } else if (atomic_read(&hvcsd->port.count) < 0) {
42591 printk(KERN_ERR "HVCS: vty-server@%X open_count: %d"
42592 " is missmanaged.\n",
42593 - hvcsd->vdev->unit_address, hvcsd->port.count);
42594 + hvcsd->vdev->unit_address, atomic_read(&hvcsd->port.count));
42595 }
42596
42597 spin_unlock_irqrestore(&hvcsd->lock, flags);
42598 @@ -1271,7 +1272,7 @@ static void hvcs_hangup(struct tty_struct * tty)
42599
42600 spin_lock_irqsave(&hvcsd->lock, flags);
42601 /* Preserve this so that we know how many kref refs to put */
42602 - temp_open_count = hvcsd->port.count;
42603 + temp_open_count = atomic_read(&hvcsd->port.count);
42604
42605 /*
42606 * Don't kref put inside the spinlock because the destruction
42607 @@ -1286,7 +1287,7 @@ static void hvcs_hangup(struct tty_struct * tty)
42608 tty->driver_data = NULL;
42609 hvcsd->port.tty = NULL;
42610
42611 - hvcsd->port.count = 0;
42612 + atomic_set(&hvcsd->port.count, 0);
42613
42614 /* This will drop any buffered data on the floor which is OK in a hangup
42615 * scenario. */
42616 @@ -1357,7 +1358,7 @@ static int hvcs_write(struct tty_struct *tty,
42617 * the middle of a write operation? This is a crummy place to do this
42618 * but we want to keep it all in the spinlock.
42619 */
42620 - if (hvcsd->port.count <= 0) {
42621 + if (atomic_read(&hvcsd->port.count) <= 0) {
42622 spin_unlock_irqrestore(&hvcsd->lock, flags);
42623 return -ENODEV;
42624 }
42625 @@ -1431,7 +1432,7 @@ static int hvcs_write_room(struct tty_struct *tty)
42626 {
42627 struct hvcs_struct *hvcsd = tty->driver_data;
42628
42629 - if (!hvcsd || hvcsd->port.count <= 0)
42630 + if (!hvcsd || atomic_read(&hvcsd->port.count) <= 0)
42631 return 0;
42632
42633 return HVCS_BUFF_LEN - hvcsd->chars_in_buffer;
42634 diff --git a/drivers/tty/ipwireless/tty.c b/drivers/tty/ipwireless/tty.c
42635 index 2cde13d..645d78f 100644
42636 --- a/drivers/tty/ipwireless/tty.c
42637 +++ b/drivers/tty/ipwireless/tty.c
42638 @@ -29,6 +29,7 @@
42639 #include <linux/tty_driver.h>
42640 #include <linux/tty_flip.h>
42641 #include <linux/uaccess.h>
42642 +#include <asm/local.h>
42643
42644 #include "tty.h"
42645 #include "network.h"
42646 @@ -99,10 +100,10 @@ static int ipw_open(struct tty_struct *linux_tty, struct file *filp)
42647 mutex_unlock(&tty->ipw_tty_mutex);
42648 return -ENODEV;
42649 }
42650 - if (tty->port.count == 0)
42651 + if (atomic_read(&tty->port.count) == 0)
42652 tty->tx_bytes_queued = 0;
42653
42654 - tty->port.count++;
42655 + atomic_inc(&tty->port.count);
42656
42657 tty->port.tty = linux_tty;
42658 linux_tty->driver_data = tty;
42659 @@ -118,9 +119,7 @@ static int ipw_open(struct tty_struct *linux_tty, struct file *filp)
42660
42661 static void do_ipw_close(struct ipw_tty *tty)
42662 {
42663 - tty->port.count--;
42664 -
42665 - if (tty->port.count == 0) {
42666 + if (atomic_dec_return(&tty->port.count) == 0) {
42667 struct tty_struct *linux_tty = tty->port.tty;
42668
42669 if (linux_tty != NULL) {
42670 @@ -141,7 +140,7 @@ static void ipw_hangup(struct tty_struct *linux_tty)
42671 return;
42672
42673 mutex_lock(&tty->ipw_tty_mutex);
42674 - if (tty->port.count == 0) {
42675 + if (atomic_read(&tty->port.count) == 0) {
42676 mutex_unlock(&tty->ipw_tty_mutex);
42677 return;
42678 }
42679 @@ -170,7 +169,7 @@ void ipwireless_tty_received(struct ipw_tty *tty, unsigned char *data,
42680 return;
42681 }
42682
42683 - if (!tty->port.count) {
42684 + if (!atomic_read(&tty->port.count)) {
42685 mutex_unlock(&tty->ipw_tty_mutex);
42686 return;
42687 }
42688 @@ -212,7 +211,7 @@ static int ipw_write(struct tty_struct *linux_tty,
42689 return -ENODEV;
42690
42691 mutex_lock(&tty->ipw_tty_mutex);
42692 - if (!tty->port.count) {
42693 + if (!atomic_read(&tty->port.count)) {
42694 mutex_unlock(&tty->ipw_tty_mutex);
42695 return -EINVAL;
42696 }
42697 @@ -252,7 +251,7 @@ static int ipw_write_room(struct tty_struct *linux_tty)
42698 if (!tty)
42699 return -ENODEV;
42700
42701 - if (!tty->port.count)
42702 + if (!atomic_read(&tty->port.count))
42703 return -EINVAL;
42704
42705 room = IPWIRELESS_TX_QUEUE_SIZE - tty->tx_bytes_queued;
42706 @@ -294,7 +293,7 @@ static int ipw_chars_in_buffer(struct tty_struct *linux_tty)
42707 if (!tty)
42708 return 0;
42709
42710 - if (!tty->port.count)
42711 + if (!atomic_read(&tty->port.count))
42712 return 0;
42713
42714 return tty->tx_bytes_queued;
42715 @@ -375,7 +374,7 @@ static int ipw_tiocmget(struct tty_struct *linux_tty)
42716 if (!tty)
42717 return -ENODEV;
42718
42719 - if (!tty->port.count)
42720 + if (!atomic_read(&tty->port.count))
42721 return -EINVAL;
42722
42723 return get_control_lines(tty);
42724 @@ -391,7 +390,7 @@ ipw_tiocmset(struct tty_struct *linux_tty,
42725 if (!tty)
42726 return -ENODEV;
42727
42728 - if (!tty->port.count)
42729 + if (!atomic_read(&tty->port.count))
42730 return -EINVAL;
42731
42732 return set_control_lines(tty, set, clear);
42733 @@ -405,7 +404,7 @@ static int ipw_ioctl(struct tty_struct *linux_tty,
42734 if (!tty)
42735 return -ENODEV;
42736
42737 - if (!tty->port.count)
42738 + if (!atomic_read(&tty->port.count))
42739 return -EINVAL;
42740
42741 /* FIXME: Exactly how is the tty object locked here .. */
42742 @@ -561,7 +560,7 @@ void ipwireless_tty_free(struct ipw_tty *tty)
42743 * are gone */
42744 mutex_lock(&ttyj->ipw_tty_mutex);
42745 }
42746 - while (ttyj->port.count)
42747 + while (atomic_read(&ttyj->port.count))
42748 do_ipw_close(ttyj);
42749 ipwireless_disassociate_network_ttys(network,
42750 ttyj->channel_idx);
42751 diff --git a/drivers/tty/moxa.c b/drivers/tty/moxa.c
42752 index f9d2850..b006f04 100644
42753 --- a/drivers/tty/moxa.c
42754 +++ b/drivers/tty/moxa.c
42755 @@ -1193,7 +1193,7 @@ static int moxa_open(struct tty_struct *tty, struct file *filp)
42756 }
42757
42758 ch = &brd->ports[port % MAX_PORTS_PER_BOARD];
42759 - ch->port.count++;
42760 + atomic_inc(&ch->port.count);
42761 tty->driver_data = ch;
42762 tty_port_tty_set(&ch->port, tty);
42763 mutex_lock(&ch->port.mutex);
42764 diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c
42765 index bfd6771..e0d93c4 100644
42766 --- a/drivers/tty/n_gsm.c
42767 +++ b/drivers/tty/n_gsm.c
42768 @@ -1636,7 +1636,7 @@ static struct gsm_dlci *gsm_dlci_alloc(struct gsm_mux *gsm, int addr)
42769 spin_lock_init(&dlci->lock);
42770 mutex_init(&dlci->mutex);
42771 dlci->fifo = &dlci->_fifo;
42772 - if (kfifo_alloc(&dlci->_fifo, 4096, GFP_KERNEL) < 0) {
42773 + if (kfifo_alloc(&dlci->_fifo, 4096, GFP_KERNEL)) {
42774 kfree(dlci);
42775 return NULL;
42776 }
42777 @@ -2936,7 +2936,7 @@ static int gsmtty_open(struct tty_struct *tty, struct file *filp)
42778 struct gsm_dlci *dlci = tty->driver_data;
42779 struct tty_port *port = &dlci->port;
42780
42781 - port->count++;
42782 + atomic_inc(&port->count);
42783 dlci_get(dlci);
42784 dlci_get(dlci->gsm->dlci[0]);
42785 mux_get(dlci->gsm);
42786 diff --git a/drivers/tty/n_tty.c b/drivers/tty/n_tty.c
42787 index 19083ef..6e34e97 100644
42788 --- a/drivers/tty/n_tty.c
42789 +++ b/drivers/tty/n_tty.c
42790 @@ -2196,6 +2196,7 @@ void n_tty_inherit_ops(struct tty_ldisc_ops *ops)
42791 {
42792 *ops = tty_ldisc_N_TTY;
42793 ops->owner = NULL;
42794 - ops->refcount = ops->flags = 0;
42795 + atomic_set(&ops->refcount, 0);
42796 + ops->flags = 0;
42797 }
42798 EXPORT_SYMBOL_GPL(n_tty_inherit_ops);
42799 diff --git a/drivers/tty/pty.c b/drivers/tty/pty.c
42800 index 79ff3a5..1fe9399 100644
42801 --- a/drivers/tty/pty.c
42802 +++ b/drivers/tty/pty.c
42803 @@ -791,8 +791,10 @@ static void __init unix98_pty_init(void)
42804 panic("Couldn't register Unix98 pts driver");
42805
42806 /* Now create the /dev/ptmx special device */
42807 + pax_open_kernel();
42808 tty_default_fops(&ptmx_fops);
42809 - ptmx_fops.open = ptmx_open;
42810 + *(void **)&ptmx_fops.open = ptmx_open;
42811 + pax_close_kernel();
42812
42813 cdev_init(&ptmx_cdev, &ptmx_fops);
42814 if (cdev_add(&ptmx_cdev, MKDEV(TTYAUX_MAJOR, 2), 1) ||
42815 diff --git a/drivers/tty/rocket.c b/drivers/tty/rocket.c
42816 index e42009a..566a036 100644
42817 --- a/drivers/tty/rocket.c
42818 +++ b/drivers/tty/rocket.c
42819 @@ -925,7 +925,7 @@ static int rp_open(struct tty_struct *tty, struct file *filp)
42820 tty->driver_data = info;
42821 tty_port_tty_set(port, tty);
42822
42823 - if (port->count++ == 0) {
42824 + if (atomic_inc_return(&port->count) == 1) {
42825 atomic_inc(&rp_num_ports_open);
42826
42827 #ifdef ROCKET_DEBUG_OPEN
42828 @@ -934,7 +934,7 @@ static int rp_open(struct tty_struct *tty, struct file *filp)
42829 #endif
42830 }
42831 #ifdef ROCKET_DEBUG_OPEN
42832 - printk(KERN_INFO "rp_open ttyR%d, count=%d\n", info->line, info->port.count);
42833 + printk(KERN_INFO "rp_open ttyR%d, count=%d\n", info->line, atomic-read(&info->port.count));
42834 #endif
42835
42836 /*
42837 @@ -1529,7 +1529,7 @@ static void rp_hangup(struct tty_struct *tty)
42838 spin_unlock_irqrestore(&info->port.lock, flags);
42839 return;
42840 }
42841 - if (info->port.count)
42842 + if (atomic_read(&info->port.count))
42843 atomic_dec(&rp_num_ports_open);
42844 clear_bit((info->aiop * 8) + info->chan, (void *) &xmit_flags[info->board]);
42845 spin_unlock_irqrestore(&info->port.lock, flags);
42846 diff --git a/drivers/tty/serial/kgdboc.c b/drivers/tty/serial/kgdboc.c
42847 index 1002054..dd644a8 100644
42848 --- a/drivers/tty/serial/kgdboc.c
42849 +++ b/drivers/tty/serial/kgdboc.c
42850 @@ -24,8 +24,9 @@
42851 #define MAX_CONFIG_LEN 40
42852
42853 static struct kgdb_io kgdboc_io_ops;
42854 +static struct kgdb_io kgdboc_io_ops_console;
42855
42856 -/* -1 = init not run yet, 0 = unconfigured, 1 = configured. */
42857 +/* -1 = init not run yet, 0 = unconfigured, 1/2 = configured. */
42858 static int configured = -1;
42859
42860 static char config[MAX_CONFIG_LEN];
42861 @@ -151,6 +152,8 @@ static void cleanup_kgdboc(void)
42862 kgdboc_unregister_kbd();
42863 if (configured == 1)
42864 kgdb_unregister_io_module(&kgdboc_io_ops);
42865 + else if (configured == 2)
42866 + kgdb_unregister_io_module(&kgdboc_io_ops_console);
42867 }
42868
42869 static int configure_kgdboc(void)
42870 @@ -160,13 +163,13 @@ static int configure_kgdboc(void)
42871 int err;
42872 char *cptr = config;
42873 struct console *cons;
42874 + int is_console = 0;
42875
42876 err = kgdboc_option_setup(config);
42877 if (err || !strlen(config) || isspace(config[0]))
42878 goto noconfig;
42879
42880 err = -ENODEV;
42881 - kgdboc_io_ops.is_console = 0;
42882 kgdb_tty_driver = NULL;
42883
42884 kgdboc_use_kms = 0;
42885 @@ -187,7 +190,7 @@ static int configure_kgdboc(void)
42886 int idx;
42887 if (cons->device && cons->device(cons, &idx) == p &&
42888 idx == tty_line) {
42889 - kgdboc_io_ops.is_console = 1;
42890 + is_console = 1;
42891 break;
42892 }
42893 cons = cons->next;
42894 @@ -197,7 +200,13 @@ static int configure_kgdboc(void)
42895 kgdb_tty_line = tty_line;
42896
42897 do_register:
42898 - err = kgdb_register_io_module(&kgdboc_io_ops);
42899 + if (is_console) {
42900 + err = kgdb_register_io_module(&kgdboc_io_ops_console);
42901 + configured = 2;
42902 + } else {
42903 + err = kgdb_register_io_module(&kgdboc_io_ops);
42904 + configured = 1;
42905 + }
42906 if (err)
42907 goto noconfig;
42908
42909 @@ -205,8 +214,6 @@ do_register:
42910 if (err)
42911 goto nmi_con_failed;
42912
42913 - configured = 1;
42914 -
42915 return 0;
42916
42917 nmi_con_failed:
42918 @@ -223,7 +230,7 @@ noconfig:
42919 static int __init init_kgdboc(void)
42920 {
42921 /* Already configured? */
42922 - if (configured == 1)
42923 + if (configured >= 1)
42924 return 0;
42925
42926 return configure_kgdboc();
42927 @@ -272,7 +279,7 @@ static int param_set_kgdboc_var(const char *kmessage, struct kernel_param *kp)
42928 if (config[len - 1] == '\n')
42929 config[len - 1] = '\0';
42930
42931 - if (configured == 1)
42932 + if (configured >= 1)
42933 cleanup_kgdboc();
42934
42935 /* Go and configure with the new params. */
42936 @@ -312,6 +319,15 @@ static struct kgdb_io kgdboc_io_ops = {
42937 .post_exception = kgdboc_post_exp_handler,
42938 };
42939
42940 +static struct kgdb_io kgdboc_io_ops_console = {
42941 + .name = "kgdboc",
42942 + .read_char = kgdboc_get_char,
42943 + .write_char = kgdboc_put_char,
42944 + .pre_exception = kgdboc_pre_exp_handler,
42945 + .post_exception = kgdboc_post_exp_handler,
42946 + .is_console = 1
42947 +};
42948 +
42949 #ifdef CONFIG_KGDB_SERIAL_CONSOLE
42950 /* This is only available if kgdboc is a built in for early debugging */
42951 static int __init kgdboc_early_init(char *opt)
42952 diff --git a/drivers/tty/serial/samsung.c b/drivers/tty/serial/samsung.c
42953 index e514b3a..c73d614 100644
42954 --- a/drivers/tty/serial/samsung.c
42955 +++ b/drivers/tty/serial/samsung.c
42956 @@ -453,11 +453,16 @@ static void s3c24xx_serial_shutdown(struct uart_port *port)
42957 }
42958 }
42959
42960 +static int s3c64xx_serial_startup(struct uart_port *port);
42961 static int s3c24xx_serial_startup(struct uart_port *port)
42962 {
42963 struct s3c24xx_uart_port *ourport = to_ourport(port);
42964 int ret;
42965
42966 + /* Startup sequence is different for s3c64xx and higher SoC's */
42967 + if (s3c24xx_serial_has_interrupt_mask(port))
42968 + return s3c64xx_serial_startup(port);
42969 +
42970 dbg("s3c24xx_serial_startup: port=%p (%08lx,%p)\n",
42971 port->mapbase, port->membase);
42972
42973 @@ -1122,10 +1127,6 @@ static int s3c24xx_serial_init_port(struct s3c24xx_uart_port *ourport,
42974 /* setup info for port */
42975 port->dev = &platdev->dev;
42976
42977 - /* Startup sequence is different for s3c64xx and higher SoC's */
42978 - if (s3c24xx_serial_has_interrupt_mask(port))
42979 - s3c24xx_serial_ops.startup = s3c64xx_serial_startup;
42980 -
42981 port->uartclk = 1;
42982
42983 if (cfg->uart_flags & UPF_CONS_FLOW) {
42984 diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
42985 index 2c7230a..2104f16 100644
42986 --- a/drivers/tty/serial/serial_core.c
42987 +++ b/drivers/tty/serial/serial_core.c
42988 @@ -1455,7 +1455,7 @@ static void uart_hangup(struct tty_struct *tty)
42989 uart_flush_buffer(tty);
42990 uart_shutdown(tty, state);
42991 spin_lock_irqsave(&port->lock, flags);
42992 - port->count = 0;
42993 + atomic_set(&port->count, 0);
42994 clear_bit(ASYNCB_NORMAL_ACTIVE, &port->flags);
42995 spin_unlock_irqrestore(&port->lock, flags);
42996 tty_port_tty_set(port, NULL);
42997 @@ -1551,7 +1551,7 @@ static int uart_open(struct tty_struct *tty, struct file *filp)
42998 goto end;
42999 }
43000
43001 - port->count++;
43002 + atomic_inc(&port->count);
43003 if (!state->uart_port || state->uart_port->flags & UPF_DEAD) {
43004 retval = -ENXIO;
43005 goto err_dec_count;
43006 @@ -1578,7 +1578,7 @@ static int uart_open(struct tty_struct *tty, struct file *filp)
43007 /*
43008 * Make sure the device is in D0 state.
43009 */
43010 - if (port->count == 1)
43011 + if (atomic_read(&port->count) == 1)
43012 uart_change_pm(state, 0);
43013
43014 /*
43015 @@ -1596,7 +1596,7 @@ static int uart_open(struct tty_struct *tty, struct file *filp)
43016 end:
43017 return retval;
43018 err_dec_count:
43019 - port->count--;
43020 + atomic_inc(&port->count);
43021 mutex_unlock(&port->mutex);
43022 goto end;
43023 }
43024 diff --git a/drivers/tty/synclink.c b/drivers/tty/synclink.c
43025 index 9e071f6..f30ae69 100644
43026 --- a/drivers/tty/synclink.c
43027 +++ b/drivers/tty/synclink.c
43028 @@ -3095,7 +3095,7 @@ static void mgsl_close(struct tty_struct *tty, struct file * filp)
43029
43030 if (debug_level >= DEBUG_LEVEL_INFO)
43031 printk("%s(%d):mgsl_close(%s) entry, count=%d\n",
43032 - __FILE__,__LINE__, info->device_name, info->port.count);
43033 + __FILE__,__LINE__, info->device_name, atomic_read(&info->port.count));
43034
43035 if (tty_port_close_start(&info->port, tty, filp) == 0)
43036 goto cleanup;
43037 @@ -3113,7 +3113,7 @@ static void mgsl_close(struct tty_struct *tty, struct file * filp)
43038 cleanup:
43039 if (debug_level >= DEBUG_LEVEL_INFO)
43040 printk("%s(%d):mgsl_close(%s) exit, count=%d\n", __FILE__,__LINE__,
43041 - tty->driver->name, info->port.count);
43042 + tty->driver->name, atomic_read(&info->port.count));
43043
43044 } /* end of mgsl_close() */
43045
43046 @@ -3212,8 +3212,8 @@ static void mgsl_hangup(struct tty_struct *tty)
43047
43048 mgsl_flush_buffer(tty);
43049 shutdown(info);
43050 -
43051 - info->port.count = 0;
43052 +
43053 + atomic_set(&info->port.count, 0);
43054 info->port.flags &= ~ASYNC_NORMAL_ACTIVE;
43055 info->port.tty = NULL;
43056
43057 @@ -3302,12 +3302,12 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
43058
43059 if (debug_level >= DEBUG_LEVEL_INFO)
43060 printk("%s(%d):block_til_ready before block on %s count=%d\n",
43061 - __FILE__,__LINE__, tty->driver->name, port->count );
43062 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
43063
43064 spin_lock_irqsave(&info->irq_spinlock, flags);
43065 if (!tty_hung_up_p(filp)) {
43066 extra_count = true;
43067 - port->count--;
43068 + atomic_dec(&port->count);
43069 }
43070 spin_unlock_irqrestore(&info->irq_spinlock, flags);
43071 port->blocked_open++;
43072 @@ -3336,7 +3336,7 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
43073
43074 if (debug_level >= DEBUG_LEVEL_INFO)
43075 printk("%s(%d):block_til_ready blocking on %s count=%d\n",
43076 - __FILE__,__LINE__, tty->driver->name, port->count );
43077 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
43078
43079 tty_unlock(tty);
43080 schedule();
43081 @@ -3348,12 +3348,12 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
43082
43083 /* FIXME: Racy on hangup during close wait */
43084 if (extra_count)
43085 - port->count++;
43086 + atomic_inc(&port->count);
43087 port->blocked_open--;
43088
43089 if (debug_level >= DEBUG_LEVEL_INFO)
43090 printk("%s(%d):block_til_ready after blocking on %s count=%d\n",
43091 - __FILE__,__LINE__, tty->driver->name, port->count );
43092 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
43093
43094 if (!retval)
43095 port->flags |= ASYNC_NORMAL_ACTIVE;
43096 @@ -3405,7 +3405,7 @@ static int mgsl_open(struct tty_struct *tty, struct file * filp)
43097
43098 if (debug_level >= DEBUG_LEVEL_INFO)
43099 printk("%s(%d):mgsl_open(%s), old ref count = %d\n",
43100 - __FILE__,__LINE__,tty->driver->name, info->port.count);
43101 + __FILE__,__LINE__,tty->driver->name, atomic_read(&info->port.count));
43102
43103 /* If port is closing, signal caller to try again */
43104 if (tty_hung_up_p(filp) || info->port.flags & ASYNC_CLOSING){
43105 @@ -3424,10 +3424,10 @@ static int mgsl_open(struct tty_struct *tty, struct file * filp)
43106 spin_unlock_irqrestore(&info->netlock, flags);
43107 goto cleanup;
43108 }
43109 - info->port.count++;
43110 + atomic_inc(&info->port.count);
43111 spin_unlock_irqrestore(&info->netlock, flags);
43112
43113 - if (info->port.count == 1) {
43114 + if (atomic_read(&info->port.count) == 1) {
43115 /* 1st open on this device, init hardware */
43116 retval = startup(info);
43117 if (retval < 0)
43118 @@ -3451,8 +3451,8 @@ cleanup:
43119 if (retval) {
43120 if (tty->count == 1)
43121 info->port.tty = NULL; /* tty layer will release tty struct */
43122 - if(info->port.count)
43123 - info->port.count--;
43124 + if (atomic_read(&info->port.count))
43125 + atomic_dec(&info->port.count);
43126 }
43127
43128 return retval;
43129 @@ -7662,7 +7662,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
43130 unsigned short new_crctype;
43131
43132 /* return error if TTY interface open */
43133 - if (info->port.count)
43134 + if (atomic_read(&info->port.count))
43135 return -EBUSY;
43136
43137 switch (encoding)
43138 @@ -7757,7 +7757,7 @@ static int hdlcdev_open(struct net_device *dev)
43139
43140 /* arbitrate between network and tty opens */
43141 spin_lock_irqsave(&info->netlock, flags);
43142 - if (info->port.count != 0 || info->netcount != 0) {
43143 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
43144 printk(KERN_WARNING "%s: hdlc_open returning busy\n", dev->name);
43145 spin_unlock_irqrestore(&info->netlock, flags);
43146 return -EBUSY;
43147 @@ -7843,7 +7843,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
43148 printk("%s:hdlcdev_ioctl(%s)\n",__FILE__,dev->name);
43149
43150 /* return error if TTY interface open */
43151 - if (info->port.count)
43152 + if (atomic_read(&info->port.count))
43153 return -EBUSY;
43154
43155 if (cmd != SIOCWANDEV)
43156 diff --git a/drivers/tty/synclink_gt.c b/drivers/tty/synclink_gt.c
43157 index aba1e59..877ac33 100644
43158 --- a/drivers/tty/synclink_gt.c
43159 +++ b/drivers/tty/synclink_gt.c
43160 @@ -671,7 +671,7 @@ static int open(struct tty_struct *tty, struct file *filp)
43161 tty->driver_data = info;
43162 info->port.tty = tty;
43163
43164 - DBGINFO(("%s open, old ref count = %d\n", info->device_name, info->port.count));
43165 + DBGINFO(("%s open, old ref count = %d\n", info->device_name, atomic_read(&info->port.count)));
43166
43167 /* If port is closing, signal caller to try again */
43168 if (tty_hung_up_p(filp) || info->port.flags & ASYNC_CLOSING){
43169 @@ -692,10 +692,10 @@ static int open(struct tty_struct *tty, struct file *filp)
43170 mutex_unlock(&info->port.mutex);
43171 goto cleanup;
43172 }
43173 - info->port.count++;
43174 + atomic_inc(&info->port.count);
43175 spin_unlock_irqrestore(&info->netlock, flags);
43176
43177 - if (info->port.count == 1) {
43178 + if (atomic_read(&info->port.count) == 1) {
43179 /* 1st open on this device, init hardware */
43180 retval = startup(info);
43181 if (retval < 0) {
43182 @@ -716,8 +716,8 @@ cleanup:
43183 if (retval) {
43184 if (tty->count == 1)
43185 info->port.tty = NULL; /* tty layer will release tty struct */
43186 - if(info->port.count)
43187 - info->port.count--;
43188 + if(atomic_read(&info->port.count))
43189 + atomic_dec(&info->port.count);
43190 }
43191
43192 DBGINFO(("%s open rc=%d\n", info->device_name, retval));
43193 @@ -730,7 +730,7 @@ static void close(struct tty_struct *tty, struct file *filp)
43194
43195 if (sanity_check(info, tty->name, "close"))
43196 return;
43197 - DBGINFO(("%s close entry, count=%d\n", info->device_name, info->port.count));
43198 + DBGINFO(("%s close entry, count=%d\n", info->device_name, atomic_read(&info->port.count)));
43199
43200 if (tty_port_close_start(&info->port, tty, filp) == 0)
43201 goto cleanup;
43202 @@ -747,7 +747,7 @@ static void close(struct tty_struct *tty, struct file *filp)
43203 tty_port_close_end(&info->port, tty);
43204 info->port.tty = NULL;
43205 cleanup:
43206 - DBGINFO(("%s close exit, count=%d\n", tty->driver->name, info->port.count));
43207 + DBGINFO(("%s close exit, count=%d\n", tty->driver->name, atomic_read(&info->port.count)));
43208 }
43209
43210 static void hangup(struct tty_struct *tty)
43211 @@ -765,7 +765,7 @@ static void hangup(struct tty_struct *tty)
43212 shutdown(info);
43213
43214 spin_lock_irqsave(&info->port.lock, flags);
43215 - info->port.count = 0;
43216 + atomic_set(&info->port.count, 0);
43217 info->port.flags &= ~ASYNC_NORMAL_ACTIVE;
43218 info->port.tty = NULL;
43219 spin_unlock_irqrestore(&info->port.lock, flags);
43220 @@ -1450,7 +1450,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
43221 unsigned short new_crctype;
43222
43223 /* return error if TTY interface open */
43224 - if (info->port.count)
43225 + if (atomic_read(&info->port.count))
43226 return -EBUSY;
43227
43228 DBGINFO(("%s hdlcdev_attach\n", info->device_name));
43229 @@ -1545,7 +1545,7 @@ static int hdlcdev_open(struct net_device *dev)
43230
43231 /* arbitrate between network and tty opens */
43232 spin_lock_irqsave(&info->netlock, flags);
43233 - if (info->port.count != 0 || info->netcount != 0) {
43234 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
43235 DBGINFO(("%s hdlc_open busy\n", dev->name));
43236 spin_unlock_irqrestore(&info->netlock, flags);
43237 return -EBUSY;
43238 @@ -1630,7 +1630,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
43239 DBGINFO(("%s hdlcdev_ioctl\n", dev->name));
43240
43241 /* return error if TTY interface open */
43242 - if (info->port.count)
43243 + if (atomic_read(&info->port.count))
43244 return -EBUSY;
43245
43246 if (cmd != SIOCWANDEV)
43247 @@ -2419,7 +2419,7 @@ static irqreturn_t slgt_interrupt(int dummy, void *dev_id)
43248 if (port == NULL)
43249 continue;
43250 spin_lock(&port->lock);
43251 - if ((port->port.count || port->netcount) &&
43252 + if ((atomic_read(&port->port.count) || port->netcount) &&
43253 port->pending_bh && !port->bh_running &&
43254 !port->bh_requested) {
43255 DBGISR(("%s bh queued\n", port->device_name));
43256 @@ -3308,7 +3308,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
43257 spin_lock_irqsave(&info->lock, flags);
43258 if (!tty_hung_up_p(filp)) {
43259 extra_count = true;
43260 - port->count--;
43261 + atomic_dec(&port->count);
43262 }
43263 spin_unlock_irqrestore(&info->lock, flags);
43264 port->blocked_open++;
43265 @@ -3345,7 +3345,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
43266 remove_wait_queue(&port->open_wait, &wait);
43267
43268 if (extra_count)
43269 - port->count++;
43270 + atomic_inc(&port->count);
43271 port->blocked_open--;
43272
43273 if (!retval)
43274 diff --git a/drivers/tty/synclinkmp.c b/drivers/tty/synclinkmp.c
43275 index fd43fb6..34704ad 100644
43276 --- a/drivers/tty/synclinkmp.c
43277 +++ b/drivers/tty/synclinkmp.c
43278 @@ -751,7 +751,7 @@ static int open(struct tty_struct *tty, struct file *filp)
43279
43280 if (debug_level >= DEBUG_LEVEL_INFO)
43281 printk("%s(%d):%s open(), old ref count = %d\n",
43282 - __FILE__,__LINE__,tty->driver->name, info->port.count);
43283 + __FILE__,__LINE__,tty->driver->name, atomic_read(&info->port.count));
43284
43285 /* If port is closing, signal caller to try again */
43286 if (tty_hung_up_p(filp) || info->port.flags & ASYNC_CLOSING){
43287 @@ -770,10 +770,10 @@ static int open(struct tty_struct *tty, struct file *filp)
43288 spin_unlock_irqrestore(&info->netlock, flags);
43289 goto cleanup;
43290 }
43291 - info->port.count++;
43292 + atomic_inc(&info->port.count);
43293 spin_unlock_irqrestore(&info->netlock, flags);
43294
43295 - if (info->port.count == 1) {
43296 + if (atomic_read(&info->port.count) == 1) {
43297 /* 1st open on this device, init hardware */
43298 retval = startup(info);
43299 if (retval < 0)
43300 @@ -797,8 +797,8 @@ cleanup:
43301 if (retval) {
43302 if (tty->count == 1)
43303 info->port.tty = NULL; /* tty layer will release tty struct */
43304 - if(info->port.count)
43305 - info->port.count--;
43306 + if(atomic_read(&info->port.count))
43307 + atomic_dec(&info->port.count);
43308 }
43309
43310 return retval;
43311 @@ -816,7 +816,7 @@ static void close(struct tty_struct *tty, struct file *filp)
43312
43313 if (debug_level >= DEBUG_LEVEL_INFO)
43314 printk("%s(%d):%s close() entry, count=%d\n",
43315 - __FILE__,__LINE__, info->device_name, info->port.count);
43316 + __FILE__,__LINE__, info->device_name, atomic_read(&info->port.count));
43317
43318 if (tty_port_close_start(&info->port, tty, filp) == 0)
43319 goto cleanup;
43320 @@ -835,7 +835,7 @@ static void close(struct tty_struct *tty, struct file *filp)
43321 cleanup:
43322 if (debug_level >= DEBUG_LEVEL_INFO)
43323 printk("%s(%d):%s close() exit, count=%d\n", __FILE__,__LINE__,
43324 - tty->driver->name, info->port.count);
43325 + tty->driver->name, atomic_read(&info->port.count));
43326 }
43327
43328 /* Called by tty_hangup() when a hangup is signaled.
43329 @@ -858,7 +858,7 @@ static void hangup(struct tty_struct *tty)
43330 shutdown(info);
43331
43332 spin_lock_irqsave(&info->port.lock, flags);
43333 - info->port.count = 0;
43334 + atomic_set(&info->port.count, 0);
43335 info->port.flags &= ~ASYNC_NORMAL_ACTIVE;
43336 info->port.tty = NULL;
43337 spin_unlock_irqrestore(&info->port.lock, flags);
43338 @@ -1566,7 +1566,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
43339 unsigned short new_crctype;
43340
43341 /* return error if TTY interface open */
43342 - if (info->port.count)
43343 + if (atomic_read(&info->port.count))
43344 return -EBUSY;
43345
43346 switch (encoding)
43347 @@ -1661,7 +1661,7 @@ static int hdlcdev_open(struct net_device *dev)
43348
43349 /* arbitrate between network and tty opens */
43350 spin_lock_irqsave(&info->netlock, flags);
43351 - if (info->port.count != 0 || info->netcount != 0) {
43352 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
43353 printk(KERN_WARNING "%s: hdlc_open returning busy\n", dev->name);
43354 spin_unlock_irqrestore(&info->netlock, flags);
43355 return -EBUSY;
43356 @@ -1747,7 +1747,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
43357 printk("%s:hdlcdev_ioctl(%s)\n",__FILE__,dev->name);
43358
43359 /* return error if TTY interface open */
43360 - if (info->port.count)
43361 + if (atomic_read(&info->port.count))
43362 return -EBUSY;
43363
43364 if (cmd != SIOCWANDEV)
43365 @@ -2632,7 +2632,7 @@ static irqreturn_t synclinkmp_interrupt(int dummy, void *dev_id)
43366 * do not request bottom half processing if the
43367 * device is not open in a normal mode.
43368 */
43369 - if ( port && (port->port.count || port->netcount) &&
43370 + if ( port && (atomic_read(&port->port.count) || port->netcount) &&
43371 port->pending_bh && !port->bh_running &&
43372 !port->bh_requested ) {
43373 if ( debug_level >= DEBUG_LEVEL_ISR )
43374 @@ -3330,12 +3330,12 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
43375
43376 if (debug_level >= DEBUG_LEVEL_INFO)
43377 printk("%s(%d):%s block_til_ready() before block, count=%d\n",
43378 - __FILE__,__LINE__, tty->driver->name, port->count );
43379 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
43380
43381 spin_lock_irqsave(&info->lock, flags);
43382 if (!tty_hung_up_p(filp)) {
43383 extra_count = true;
43384 - port->count--;
43385 + atomic_dec(&port->count);
43386 }
43387 spin_unlock_irqrestore(&info->lock, flags);
43388 port->blocked_open++;
43389 @@ -3364,7 +3364,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
43390
43391 if (debug_level >= DEBUG_LEVEL_INFO)
43392 printk("%s(%d):%s block_til_ready() count=%d\n",
43393 - __FILE__,__LINE__, tty->driver->name, port->count );
43394 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
43395
43396 tty_unlock(tty);
43397 schedule();
43398 @@ -3375,12 +3375,12 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
43399 remove_wait_queue(&port->open_wait, &wait);
43400
43401 if (extra_count)
43402 - port->count++;
43403 + atomic_inc(&port->count);
43404 port->blocked_open--;
43405
43406 if (debug_level >= DEBUG_LEVEL_INFO)
43407 printk("%s(%d):%s block_til_ready() after, count=%d\n",
43408 - __FILE__,__LINE__, tty->driver->name, port->count );
43409 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
43410
43411 if (!retval)
43412 port->flags |= ASYNC_NORMAL_ACTIVE;
43413 diff --git a/drivers/tty/sysrq.c b/drivers/tty/sysrq.c
43414 index b3c4a25..723916f 100644
43415 --- a/drivers/tty/sysrq.c
43416 +++ b/drivers/tty/sysrq.c
43417 @@ -867,7 +867,7 @@ EXPORT_SYMBOL(unregister_sysrq_key);
43418 static ssize_t write_sysrq_trigger(struct file *file, const char __user *buf,
43419 size_t count, loff_t *ppos)
43420 {
43421 - if (count) {
43422 + if (count && capable(CAP_SYS_ADMIN)) {
43423 char c;
43424
43425 if (get_user(c, buf))
43426 diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
43427 index da9fde8..c07975f 100644
43428 --- a/drivers/tty/tty_io.c
43429 +++ b/drivers/tty/tty_io.c
43430 @@ -3391,7 +3391,7 @@ EXPORT_SYMBOL_GPL(get_current_tty);
43431
43432 void tty_default_fops(struct file_operations *fops)
43433 {
43434 - *fops = tty_fops;
43435 + memcpy((void *)fops, &tty_fops, sizeof(tty_fops));
43436 }
43437
43438 /*
43439 diff --git a/drivers/tty/tty_ldisc.c b/drivers/tty/tty_ldisc.c
43440 index c578229..45aa9ee 100644
43441 --- a/drivers/tty/tty_ldisc.c
43442 +++ b/drivers/tty/tty_ldisc.c
43443 @@ -56,7 +56,7 @@ static void put_ldisc(struct tty_ldisc *ld)
43444 if (atomic_dec_and_test(&ld->users)) {
43445 struct tty_ldisc_ops *ldo = ld->ops;
43446
43447 - ldo->refcount--;
43448 + atomic_dec(&ldo->refcount);
43449 module_put(ldo->owner);
43450 raw_spin_unlock_irqrestore(&tty_ldisc_lock, flags);
43451
43452 @@ -91,7 +91,7 @@ int tty_register_ldisc(int disc, struct tty_ldisc_ops *new_ldisc)
43453 raw_spin_lock_irqsave(&tty_ldisc_lock, flags);
43454 tty_ldiscs[disc] = new_ldisc;
43455 new_ldisc->num = disc;
43456 - new_ldisc->refcount = 0;
43457 + atomic_set(&new_ldisc->refcount, 0);
43458 raw_spin_unlock_irqrestore(&tty_ldisc_lock, flags);
43459
43460 return ret;
43461 @@ -119,7 +119,7 @@ int tty_unregister_ldisc(int disc)
43462 return -EINVAL;
43463
43464 raw_spin_lock_irqsave(&tty_ldisc_lock, flags);
43465 - if (tty_ldiscs[disc]->refcount)
43466 + if (atomic_read(&tty_ldiscs[disc]->refcount))
43467 ret = -EBUSY;
43468 else
43469 tty_ldiscs[disc] = NULL;
43470 @@ -140,7 +140,7 @@ static struct tty_ldisc_ops *get_ldops(int disc)
43471 if (ldops) {
43472 ret = ERR_PTR(-EAGAIN);
43473 if (try_module_get(ldops->owner)) {
43474 - ldops->refcount++;
43475 + atomic_inc(&ldops->refcount);
43476 ret = ldops;
43477 }
43478 }
43479 @@ -153,7 +153,7 @@ static void put_ldops(struct tty_ldisc_ops *ldops)
43480 unsigned long flags;
43481
43482 raw_spin_lock_irqsave(&tty_ldisc_lock, flags);
43483 - ldops->refcount--;
43484 + atomic_dec(&ldops->refcount);
43485 module_put(ldops->owner);
43486 raw_spin_unlock_irqrestore(&tty_ldisc_lock, flags);
43487 }
43488 diff --git a/drivers/tty/tty_port.c b/drivers/tty/tty_port.c
43489 index b7ff59d..7c6105e 100644
43490 --- a/drivers/tty/tty_port.c
43491 +++ b/drivers/tty/tty_port.c
43492 @@ -218,7 +218,7 @@ void tty_port_hangup(struct tty_port *port)
43493 unsigned long flags;
43494
43495 spin_lock_irqsave(&port->lock, flags);
43496 - port->count = 0;
43497 + atomic_set(&port->count, 0);
43498 port->flags &= ~ASYNC_NORMAL_ACTIVE;
43499 if (port->tty) {
43500 set_bit(TTY_IO_ERROR, &port->tty->flags);
43501 @@ -344,7 +344,7 @@ int tty_port_block_til_ready(struct tty_port *port,
43502 /* The port lock protects the port counts */
43503 spin_lock_irqsave(&port->lock, flags);
43504 if (!tty_hung_up_p(filp))
43505 - port->count--;
43506 + atomic_dec(&port->count);
43507 port->blocked_open++;
43508 spin_unlock_irqrestore(&port->lock, flags);
43509
43510 @@ -386,7 +386,7 @@ int tty_port_block_til_ready(struct tty_port *port,
43511 we must not mess that up further */
43512 spin_lock_irqsave(&port->lock, flags);
43513 if (!tty_hung_up_p(filp))
43514 - port->count++;
43515 + atomic_inc(&port->count);
43516 port->blocked_open--;
43517 if (retval == 0)
43518 port->flags |= ASYNC_NORMAL_ACTIVE;
43519 @@ -406,19 +406,19 @@ int tty_port_close_start(struct tty_port *port,
43520 return 0;
43521 }
43522
43523 - if (tty->count == 1 && port->count != 1) {
43524 + if (tty->count == 1 && atomic_read(&port->count) != 1) {
43525 printk(KERN_WARNING
43526 "tty_port_close_start: tty->count = 1 port count = %d.\n",
43527 - port->count);
43528 - port->count = 1;
43529 + atomic_read(&port->count));
43530 + atomic_set(&port->count, 1);
43531 }
43532 - if (--port->count < 0) {
43533 + if (atomic_dec_return(&port->count) < 0) {
43534 printk(KERN_WARNING "tty_port_close_start: count = %d\n",
43535 - port->count);
43536 - port->count = 0;
43537 + atomic_read(&port->count));
43538 + atomic_set(&port->count, 0);
43539 }
43540
43541 - if (port->count) {
43542 + if (atomic_read(&port->count)) {
43543 spin_unlock_irqrestore(&port->lock, flags);
43544 if (port->ops->drop)
43545 port->ops->drop(port);
43546 @@ -516,7 +516,7 @@ int tty_port_open(struct tty_port *port, struct tty_struct *tty,
43547 {
43548 spin_lock_irq(&port->lock);
43549 if (!tty_hung_up_p(filp))
43550 - ++port->count;
43551 + atomic_inc(&port->count);
43552 spin_unlock_irq(&port->lock);
43553 tty_port_tty_set(port, tty);
43554
43555 diff --git a/drivers/tty/vt/keyboard.c b/drivers/tty/vt/keyboard.c
43556 index 681765b..d3ccdf2 100644
43557 --- a/drivers/tty/vt/keyboard.c
43558 +++ b/drivers/tty/vt/keyboard.c
43559 @@ -660,6 +660,16 @@ static void k_spec(struct vc_data *vc, unsigned char value, char up_flag)
43560 kbd->kbdmode == VC_OFF) &&
43561 value != KVAL(K_SAK))
43562 return; /* SAK is allowed even in raw mode */
43563 +
43564 +#if defined(CONFIG_GRKERNSEC_PROC) || defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
43565 + {
43566 + void *func = fn_handler[value];
43567 + if (func == fn_show_state || func == fn_show_ptregs ||
43568 + func == fn_show_mem)
43569 + return;
43570 + }
43571 +#endif
43572 +
43573 fn_handler[value](vc);
43574 }
43575
43576 @@ -1808,9 +1818,6 @@ int vt_do_kdsk_ioctl(int cmd, struct kbentry __user *user_kbe, int perm,
43577 if (copy_from_user(&tmp, user_kbe, sizeof(struct kbentry)))
43578 return -EFAULT;
43579
43580 - if (!capable(CAP_SYS_TTY_CONFIG))
43581 - perm = 0;
43582 -
43583 switch (cmd) {
43584 case KDGKBENT:
43585 /* Ensure another thread doesn't free it under us */
43586 @@ -1825,6 +1832,9 @@ int vt_do_kdsk_ioctl(int cmd, struct kbentry __user *user_kbe, int perm,
43587 spin_unlock_irqrestore(&kbd_event_lock, flags);
43588 return put_user(val, &user_kbe->kb_value);
43589 case KDSKBENT:
43590 + if (!capable(CAP_SYS_TTY_CONFIG))
43591 + perm = 0;
43592 +
43593 if (!perm)
43594 return -EPERM;
43595 if (!i && v == K_NOSUCHMAP) {
43596 @@ -1915,9 +1925,6 @@ int vt_do_kdgkb_ioctl(int cmd, struct kbsentry __user *user_kdgkb, int perm)
43597 int i, j, k;
43598 int ret;
43599
43600 - if (!capable(CAP_SYS_TTY_CONFIG))
43601 - perm = 0;
43602 -
43603 kbs = kmalloc(sizeof(*kbs), GFP_KERNEL);
43604 if (!kbs) {
43605 ret = -ENOMEM;
43606 @@ -1951,6 +1958,9 @@ int vt_do_kdgkb_ioctl(int cmd, struct kbsentry __user *user_kdgkb, int perm)
43607 kfree(kbs);
43608 return ((p && *p) ? -EOVERFLOW : 0);
43609 case KDSKBSENT:
43610 + if (!capable(CAP_SYS_TTY_CONFIG))
43611 + perm = 0;
43612 +
43613 if (!perm) {
43614 ret = -EPERM;
43615 goto reterr;
43616 diff --git a/drivers/uio/uio.c b/drivers/uio/uio.c
43617 index 5110f36..8dc0a74 100644
43618 --- a/drivers/uio/uio.c
43619 +++ b/drivers/uio/uio.c
43620 @@ -25,6 +25,7 @@
43621 #include <linux/kobject.h>
43622 #include <linux/cdev.h>
43623 #include <linux/uio_driver.h>
43624 +#include <asm/local.h>
43625
43626 #define UIO_MAX_DEVICES (1U << MINORBITS)
43627
43628 @@ -32,10 +33,10 @@ struct uio_device {
43629 struct module *owner;
43630 struct device *dev;
43631 int minor;
43632 - atomic_t event;
43633 + atomic_unchecked_t event;
43634 struct fasync_struct *async_queue;
43635 wait_queue_head_t wait;
43636 - int vma_count;
43637 + local_t vma_count;
43638 struct uio_info *info;
43639 struct kobject *map_dir;
43640 struct kobject *portio_dir;
43641 @@ -242,7 +243,7 @@ static ssize_t show_event(struct device *dev,
43642 struct device_attribute *attr, char *buf)
43643 {
43644 struct uio_device *idev = dev_get_drvdata(dev);
43645 - return sprintf(buf, "%u\n", (unsigned int)atomic_read(&idev->event));
43646 + return sprintf(buf, "%u\n", (unsigned int)atomic_read_unchecked(&idev->event));
43647 }
43648
43649 static struct device_attribute uio_class_attributes[] = {
43650 @@ -408,7 +409,7 @@ void uio_event_notify(struct uio_info *info)
43651 {
43652 struct uio_device *idev = info->uio_dev;
43653
43654 - atomic_inc(&idev->event);
43655 + atomic_inc_unchecked(&idev->event);
43656 wake_up_interruptible(&idev->wait);
43657 kill_fasync(&idev->async_queue, SIGIO, POLL_IN);
43658 }
43659 @@ -461,7 +462,7 @@ static int uio_open(struct inode *inode, struct file *filep)
43660 }
43661
43662 listener->dev = idev;
43663 - listener->event_count = atomic_read(&idev->event);
43664 + listener->event_count = atomic_read_unchecked(&idev->event);
43665 filep->private_data = listener;
43666
43667 if (idev->info->open) {
43668 @@ -512,7 +513,7 @@ static unsigned int uio_poll(struct file *filep, poll_table *wait)
43669 return -EIO;
43670
43671 poll_wait(filep, &idev->wait, wait);
43672 - if (listener->event_count != atomic_read(&idev->event))
43673 + if (listener->event_count != atomic_read_unchecked(&idev->event))
43674 return POLLIN | POLLRDNORM;
43675 return 0;
43676 }
43677 @@ -537,7 +538,7 @@ static ssize_t uio_read(struct file *filep, char __user *buf,
43678 do {
43679 set_current_state(TASK_INTERRUPTIBLE);
43680
43681 - event_count = atomic_read(&idev->event);
43682 + event_count = atomic_read_unchecked(&idev->event);
43683 if (event_count != listener->event_count) {
43684 if (copy_to_user(buf, &event_count, count))
43685 retval = -EFAULT;
43686 @@ -606,13 +607,13 @@ static int uio_find_mem_index(struct vm_area_struct *vma)
43687 static void uio_vma_open(struct vm_area_struct *vma)
43688 {
43689 struct uio_device *idev = vma->vm_private_data;
43690 - idev->vma_count++;
43691 + local_inc(&idev->vma_count);
43692 }
43693
43694 static void uio_vma_close(struct vm_area_struct *vma)
43695 {
43696 struct uio_device *idev = vma->vm_private_data;
43697 - idev->vma_count--;
43698 + local_dec(&idev->vma_count);
43699 }
43700
43701 static int uio_vma_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
43702 @@ -819,7 +820,7 @@ int __uio_register_device(struct module *owner,
43703 idev->owner = owner;
43704 idev->info = info;
43705 init_waitqueue_head(&idev->wait);
43706 - atomic_set(&idev->event, 0);
43707 + atomic_set_unchecked(&idev->event, 0);
43708
43709 ret = uio_get_minor(idev);
43710 if (ret)
43711 diff --git a/drivers/usb/atm/cxacru.c b/drivers/usb/atm/cxacru.c
43712 index b7eb86a..36d28af 100644
43713 --- a/drivers/usb/atm/cxacru.c
43714 +++ b/drivers/usb/atm/cxacru.c
43715 @@ -473,7 +473,7 @@ static ssize_t cxacru_sysfs_store_adsl_config(struct device *dev,
43716 ret = sscanf(buf + pos, "%x=%x%n", &index, &value, &tmp);
43717 if (ret < 2)
43718 return -EINVAL;
43719 - if (index < 0 || index > 0x7f)
43720 + if (index > 0x7f)
43721 return -EINVAL;
43722 pos += tmp;
43723
43724 diff --git a/drivers/usb/atm/usbatm.c b/drivers/usb/atm/usbatm.c
43725 index 35f10bf..6a38a0b 100644
43726 --- a/drivers/usb/atm/usbatm.c
43727 +++ b/drivers/usb/atm/usbatm.c
43728 @@ -333,7 +333,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
43729 if (printk_ratelimit())
43730 atm_warn(instance, "%s: OAM not supported (vpi %d, vci %d)!\n",
43731 __func__, vpi, vci);
43732 - atomic_inc(&vcc->stats->rx_err);
43733 + atomic_inc_unchecked(&vcc->stats->rx_err);
43734 return;
43735 }
43736
43737 @@ -361,7 +361,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
43738 if (length > ATM_MAX_AAL5_PDU) {
43739 atm_rldbg(instance, "%s: bogus length %u (vcc: 0x%p)!\n",
43740 __func__, length, vcc);
43741 - atomic_inc(&vcc->stats->rx_err);
43742 + atomic_inc_unchecked(&vcc->stats->rx_err);
43743 goto out;
43744 }
43745
43746 @@ -370,14 +370,14 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
43747 if (sarb->len < pdu_length) {
43748 atm_rldbg(instance, "%s: bogus pdu_length %u (sarb->len: %u, vcc: 0x%p)!\n",
43749 __func__, pdu_length, sarb->len, vcc);
43750 - atomic_inc(&vcc->stats->rx_err);
43751 + atomic_inc_unchecked(&vcc->stats->rx_err);
43752 goto out;
43753 }
43754
43755 if (crc32_be(~0, skb_tail_pointer(sarb) - pdu_length, pdu_length) != 0xc704dd7b) {
43756 atm_rldbg(instance, "%s: packet failed crc check (vcc: 0x%p)!\n",
43757 __func__, vcc);
43758 - atomic_inc(&vcc->stats->rx_err);
43759 + atomic_inc_unchecked(&vcc->stats->rx_err);
43760 goto out;
43761 }
43762
43763 @@ -389,7 +389,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
43764 if (printk_ratelimit())
43765 atm_err(instance, "%s: no memory for skb (length: %u)!\n",
43766 __func__, length);
43767 - atomic_inc(&vcc->stats->rx_drop);
43768 + atomic_inc_unchecked(&vcc->stats->rx_drop);
43769 goto out;
43770 }
43771
43772 @@ -417,7 +417,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
43773
43774 vcc->push(vcc, skb);
43775
43776 - atomic_inc(&vcc->stats->rx);
43777 + atomic_inc_unchecked(&vcc->stats->rx);
43778 out:
43779 skb_trim(sarb, 0);
43780 }
43781 @@ -623,7 +623,7 @@ static void usbatm_tx_process(unsigned long data)
43782 struct atm_vcc *vcc = UDSL_SKB(skb)->atm.vcc;
43783
43784 usbatm_pop(vcc, skb);
43785 - atomic_inc(&vcc->stats->tx);
43786 + atomic_inc_unchecked(&vcc->stats->tx);
43787
43788 skb = skb_dequeue(&instance->sndqueue);
43789 }
43790 @@ -779,11 +779,11 @@ static int usbatm_atm_proc_read(struct atm_dev *atm_dev, loff_t * pos, char *pag
43791 if (!left--)
43792 return sprintf(page,
43793 "AAL5: tx %d ( %d err ), rx %d ( %d err, %d drop )\n",
43794 - atomic_read(&atm_dev->stats.aal5.tx),
43795 - atomic_read(&atm_dev->stats.aal5.tx_err),
43796 - atomic_read(&atm_dev->stats.aal5.rx),
43797 - atomic_read(&atm_dev->stats.aal5.rx_err),
43798 - atomic_read(&atm_dev->stats.aal5.rx_drop));
43799 + atomic_read_unchecked(&atm_dev->stats.aal5.tx),
43800 + atomic_read_unchecked(&atm_dev->stats.aal5.tx_err),
43801 + atomic_read_unchecked(&atm_dev->stats.aal5.rx),
43802 + atomic_read_unchecked(&atm_dev->stats.aal5.rx_err),
43803 + atomic_read_unchecked(&atm_dev->stats.aal5.rx_drop));
43804
43805 if (!left--) {
43806 if (instance->disconnected)
43807 diff --git a/drivers/usb/class/cdc-wdm.c b/drivers/usb/class/cdc-wdm.c
43808 index 5f0cb41..122d056 100644
43809 --- a/drivers/usb/class/cdc-wdm.c
43810 +++ b/drivers/usb/class/cdc-wdm.c
43811 @@ -56,6 +56,7 @@ MODULE_DEVICE_TABLE (usb, wdm_ids);
43812 #define WDM_RESPONDING 7
43813 #define WDM_SUSPENDING 8
43814 #define WDM_RESETTING 9
43815 +#define WDM_OVERFLOW 10
43816
43817 #define WDM_MAX 16
43818
43819 @@ -155,6 +156,7 @@ static void wdm_in_callback(struct urb *urb)
43820 {
43821 struct wdm_device *desc = urb->context;
43822 int status = urb->status;
43823 + int length = urb->actual_length;
43824
43825 spin_lock(&desc->iuspin);
43826 clear_bit(WDM_RESPONDING, &desc->flags);
43827 @@ -185,9 +187,17 @@ static void wdm_in_callback(struct urb *urb)
43828 }
43829
43830 desc->rerr = status;
43831 - desc->reslength = urb->actual_length;
43832 - memmove(desc->ubuf + desc->length, desc->inbuf, desc->reslength);
43833 - desc->length += desc->reslength;
43834 + if (length + desc->length > desc->wMaxCommand) {
43835 + /* The buffer would overflow */
43836 + set_bit(WDM_OVERFLOW, &desc->flags);
43837 + } else {
43838 + /* we may already be in overflow */
43839 + if (!test_bit(WDM_OVERFLOW, &desc->flags)) {
43840 + memmove(desc->ubuf + desc->length, desc->inbuf, length);
43841 + desc->length += length;
43842 + desc->reslength = length;
43843 + }
43844 + }
43845 skip_error:
43846 wake_up(&desc->wait);
43847
43848 @@ -435,6 +445,11 @@ retry:
43849 rv = -ENODEV;
43850 goto err;
43851 }
43852 + if (test_bit(WDM_OVERFLOW, &desc->flags)) {
43853 + clear_bit(WDM_OVERFLOW, &desc->flags);
43854 + rv = -ENOBUFS;
43855 + goto err;
43856 + }
43857 i++;
43858 if (file->f_flags & O_NONBLOCK) {
43859 if (!test_bit(WDM_READ, &desc->flags)) {
43860 @@ -478,6 +493,7 @@ retry:
43861 spin_unlock_irq(&desc->iuspin);
43862 goto retry;
43863 }
43864 +
43865 if (!desc->reslength) { /* zero length read */
43866 dev_dbg(&desc->intf->dev, "%s: zero length - clearing WDM_READ\n", __func__);
43867 clear_bit(WDM_READ, &desc->flags);
43868 @@ -1004,6 +1020,7 @@ static int wdm_post_reset(struct usb_interface *intf)
43869 struct wdm_device *desc = wdm_find_device(intf);
43870 int rv;
43871
43872 + clear_bit(WDM_OVERFLOW, &desc->flags);
43873 clear_bit(WDM_RESETTING, &desc->flags);
43874 rv = recover_from_urb_loss(desc);
43875 mutex_unlock(&desc->wlock);
43876 diff --git a/drivers/usb/core/devices.c b/drivers/usb/core/devices.c
43877 index cbacea9..246cccd 100644
43878 --- a/drivers/usb/core/devices.c
43879 +++ b/drivers/usb/core/devices.c
43880 @@ -126,7 +126,7 @@ static const char format_endpt[] =
43881 * time it gets called.
43882 */
43883 static struct device_connect_event {
43884 - atomic_t count;
43885 + atomic_unchecked_t count;
43886 wait_queue_head_t wait;
43887 } device_event = {
43888 .count = ATOMIC_INIT(1),
43889 @@ -164,7 +164,7 @@ static const struct class_info clas_info[] = {
43890
43891 void usbfs_conn_disc_event(void)
43892 {
43893 - atomic_add(2, &device_event.count);
43894 + atomic_add_unchecked(2, &device_event.count);
43895 wake_up(&device_event.wait);
43896 }
43897
43898 @@ -645,7 +645,7 @@ static unsigned int usb_device_poll(struct file *file,
43899
43900 poll_wait(file, &device_event.wait, wait);
43901
43902 - event_count = atomic_read(&device_event.count);
43903 + event_count = atomic_read_unchecked(&device_event.count);
43904 if (file->f_version != event_count) {
43905 file->f_version = event_count;
43906 return POLLIN | POLLRDNORM;
43907 diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
43908 index 8e64adf..9a33a3c 100644
43909 --- a/drivers/usb/core/hcd.c
43910 +++ b/drivers/usb/core/hcd.c
43911 @@ -1522,7 +1522,7 @@ int usb_hcd_submit_urb (struct urb *urb, gfp_t mem_flags)
43912 */
43913 usb_get_urb(urb);
43914 atomic_inc(&urb->use_count);
43915 - atomic_inc(&urb->dev->urbnum);
43916 + atomic_inc_unchecked(&urb->dev->urbnum);
43917 usbmon_urb_submit(&hcd->self, urb);
43918
43919 /* NOTE requirements on root-hub callers (usbfs and the hub
43920 @@ -1549,7 +1549,7 @@ int usb_hcd_submit_urb (struct urb *urb, gfp_t mem_flags)
43921 urb->hcpriv = NULL;
43922 INIT_LIST_HEAD(&urb->urb_list);
43923 atomic_dec(&urb->use_count);
43924 - atomic_dec(&urb->dev->urbnum);
43925 + atomic_dec_unchecked(&urb->dev->urbnum);
43926 if (atomic_read(&urb->reject))
43927 wake_up(&usb_kill_urb_queue);
43928 usb_put_urb(urb);
43929 diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c
43930 index 131f736..99004c3 100644
43931 --- a/drivers/usb/core/message.c
43932 +++ b/drivers/usb/core/message.c
43933 @@ -129,7 +129,7 @@ static int usb_internal_control_msg(struct usb_device *usb_dev,
43934 * method can wait for it to complete. Since you don't have a handle on the
43935 * URB used, you can't cancel the request.
43936 */
43937 -int usb_control_msg(struct usb_device *dev, unsigned int pipe, __u8 request,
43938 +int __intentional_overflow(-1) usb_control_msg(struct usb_device *dev, unsigned int pipe, __u8 request,
43939 __u8 requesttype, __u16 value, __u16 index, void *data,
43940 __u16 size, int timeout)
43941 {
43942 diff --git a/drivers/usb/core/sysfs.c b/drivers/usb/core/sysfs.c
43943 index 818e4a0..0fc9589 100644
43944 --- a/drivers/usb/core/sysfs.c
43945 +++ b/drivers/usb/core/sysfs.c
43946 @@ -226,7 +226,7 @@ show_urbnum(struct device *dev, struct device_attribute *attr, char *buf)
43947 struct usb_device *udev;
43948
43949 udev = to_usb_device(dev);
43950 - return sprintf(buf, "%d\n", atomic_read(&udev->urbnum));
43951 + return sprintf(buf, "%d\n", atomic_read_unchecked(&udev->urbnum));
43952 }
43953 static DEVICE_ATTR(urbnum, S_IRUGO, show_urbnum, NULL);
43954
43955 diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c
43956 index f81b925..78d22ec 100644
43957 --- a/drivers/usb/core/usb.c
43958 +++ b/drivers/usb/core/usb.c
43959 @@ -388,7 +388,7 @@ struct usb_device *usb_alloc_dev(struct usb_device *parent,
43960 set_dev_node(&dev->dev, dev_to_node(bus->controller));
43961 dev->state = USB_STATE_ATTACHED;
43962 dev->lpm_disable_count = 1;
43963 - atomic_set(&dev->urbnum, 0);
43964 + atomic_set_unchecked(&dev->urbnum, 0);
43965
43966 INIT_LIST_HEAD(&dev->ep0.urb_list);
43967 dev->ep0.desc.bLength = USB_DT_ENDPOINT_SIZE;
43968 diff --git a/drivers/usb/early/ehci-dbgp.c b/drivers/usb/early/ehci-dbgp.c
43969 index 5e29dde..eca992f 100644
43970 --- a/drivers/usb/early/ehci-dbgp.c
43971 +++ b/drivers/usb/early/ehci-dbgp.c
43972 @@ -98,7 +98,8 @@ static inline u32 dbgp_len_update(u32 x, u32 len)
43973
43974 #ifdef CONFIG_KGDB
43975 static struct kgdb_io kgdbdbgp_io_ops;
43976 -#define dbgp_kgdb_mode (dbg_io_ops == &kgdbdbgp_io_ops)
43977 +static struct kgdb_io kgdbdbgp_io_ops_console;
43978 +#define dbgp_kgdb_mode (dbg_io_ops == &kgdbdbgp_io_ops || dbg_io_ops == &kgdbdbgp_io_ops_console)
43979 #else
43980 #define dbgp_kgdb_mode (0)
43981 #endif
43982 @@ -1047,6 +1048,13 @@ static struct kgdb_io kgdbdbgp_io_ops = {
43983 .write_char = kgdbdbgp_write_char,
43984 };
43985
43986 +static struct kgdb_io kgdbdbgp_io_ops_console = {
43987 + .name = "kgdbdbgp",
43988 + .read_char = kgdbdbgp_read_char,
43989 + .write_char = kgdbdbgp_write_char,
43990 + .is_console = 1
43991 +};
43992 +
43993 static int kgdbdbgp_wait_time;
43994
43995 static int __init kgdbdbgp_parse_config(char *str)
43996 @@ -1062,8 +1070,10 @@ static int __init kgdbdbgp_parse_config(char *str)
43997 ptr++;
43998 kgdbdbgp_wait_time = simple_strtoul(ptr, &ptr, 10);
43999 }
44000 - kgdb_register_io_module(&kgdbdbgp_io_ops);
44001 - kgdbdbgp_io_ops.is_console = early_dbgp_console.index != -1;
44002 + if (early_dbgp_console.index != -1)
44003 + kgdb_register_io_module(&kgdbdbgp_io_ops_console);
44004 + else
44005 + kgdb_register_io_module(&kgdbdbgp_io_ops);
44006
44007 return 0;
44008 }
44009 diff --git a/drivers/usb/gadget/u_serial.c b/drivers/usb/gadget/u_serial.c
44010 index 598dcc1..032dd4f 100644
44011 --- a/drivers/usb/gadget/u_serial.c
44012 +++ b/drivers/usb/gadget/u_serial.c
44013 @@ -735,9 +735,9 @@ static int gs_open(struct tty_struct *tty, struct file *file)
44014 spin_lock_irq(&port->port_lock);
44015
44016 /* already open? Great. */
44017 - if (port->port.count) {
44018 + if (atomic_read(&port->port.count)) {
44019 status = 0;
44020 - port->port.count++;
44021 + atomic_inc(&port->port.count);
44022
44023 /* currently opening/closing? wait ... */
44024 } else if (port->openclose) {
44025 @@ -796,7 +796,7 @@ static int gs_open(struct tty_struct *tty, struct file *file)
44026 tty->driver_data = port;
44027 port->port.tty = tty;
44028
44029 - port->port.count = 1;
44030 + atomic_set(&port->port.count, 1);
44031 port->openclose = false;
44032
44033 /* if connected, start the I/O stream */
44034 @@ -838,11 +838,11 @@ static void gs_close(struct tty_struct *tty, struct file *file)
44035
44036 spin_lock_irq(&port->port_lock);
44037
44038 - if (port->port.count != 1) {
44039 - if (port->port.count == 0)
44040 + if (atomic_read(&port->port.count) != 1) {
44041 + if (atomic_read(&port->port.count) == 0)
44042 WARN_ON(1);
44043 else
44044 - --port->port.count;
44045 + atomic_dec(&port->port.count);
44046 goto exit;
44047 }
44048
44049 @@ -852,7 +852,7 @@ static void gs_close(struct tty_struct *tty, struct file *file)
44050 * and sleep if necessary
44051 */
44052 port->openclose = true;
44053 - port->port.count = 0;
44054 + atomic_set(&port->port.count, 0);
44055
44056 gser = port->port_usb;
44057 if (gser && gser->disconnect)
44058 @@ -1159,7 +1159,7 @@ static int gs_closed(struct gs_port *port)
44059 int cond;
44060
44061 spin_lock_irq(&port->port_lock);
44062 - cond = (port->port.count == 0) && !port->openclose;
44063 + cond = (atomic_read(&port->port.count) == 0) && !port->openclose;
44064 spin_unlock_irq(&port->port_lock);
44065 return cond;
44066 }
44067 @@ -1273,7 +1273,7 @@ int gserial_connect(struct gserial *gser, u8 port_num)
44068 /* if it's already open, start I/O ... and notify the serial
44069 * protocol about open/close status (connect/disconnect).
44070 */
44071 - if (port->port.count) {
44072 + if (atomic_read(&port->port.count)) {
44073 pr_debug("gserial_connect: start ttyGS%d\n", port->port_num);
44074 gs_start_io(port);
44075 if (gser->connect)
44076 @@ -1320,7 +1320,7 @@ void gserial_disconnect(struct gserial *gser)
44077
44078 port->port_usb = NULL;
44079 gser->ioport = NULL;
44080 - if (port->port.count > 0 || port->openclose) {
44081 + if (atomic_read(&port->port.count) > 0 || port->openclose) {
44082 wake_up_interruptible(&port->drain_wait);
44083 if (port->port.tty)
44084 tty_hangup(port->port.tty);
44085 @@ -1336,7 +1336,7 @@ void gserial_disconnect(struct gserial *gser)
44086
44087 /* finally, free any unused/unusable I/O buffers */
44088 spin_lock_irqsave(&port->port_lock, flags);
44089 - if (port->port.count == 0 && !port->openclose)
44090 + if (atomic_read(&port->port.count) == 0 && !port->openclose)
44091 gs_buf_free(&port->port_write_buf);
44092 gs_free_requests(gser->out, &port->read_pool, NULL);
44093 gs_free_requests(gser->out, &port->read_queue, NULL);
44094 diff --git a/drivers/usb/serial/console.c b/drivers/usb/serial/console.c
44095 index 5f3bcd3..bfca43f 100644
44096 --- a/drivers/usb/serial/console.c
44097 +++ b/drivers/usb/serial/console.c
44098 @@ -124,7 +124,7 @@ static int usb_console_setup(struct console *co, char *options)
44099
44100 info->port = port;
44101
44102 - ++port->port.count;
44103 + atomic_inc(&port->port.count);
44104 if (!test_bit(ASYNCB_INITIALIZED, &port->port.flags)) {
44105 if (serial->type->set_termios) {
44106 /*
44107 @@ -174,7 +174,7 @@ static int usb_console_setup(struct console *co, char *options)
44108 }
44109 /* Now that any required fake tty operations are completed restore
44110 * the tty port count */
44111 - --port->port.count;
44112 + atomic_dec(&port->port.count);
44113 /* The console is special in terms of closing the device so
44114 * indicate this port is now acting as a system console. */
44115 port->port.console = 1;
44116 @@ -187,7 +187,7 @@ static int usb_console_setup(struct console *co, char *options)
44117 free_tty:
44118 kfree(tty);
44119 reset_open_count:
44120 - port->port.count = 0;
44121 + atomic_set(&port->port.count, 0);
44122 usb_autopm_put_interface(serial->interface);
44123 error_get_interface:
44124 usb_serial_put(serial);
44125 diff --git a/drivers/usb/storage/usb.h b/drivers/usb/storage/usb.h
44126 index 75f70f0..d467e1a 100644
44127 --- a/drivers/usb/storage/usb.h
44128 +++ b/drivers/usb/storage/usb.h
44129 @@ -63,7 +63,7 @@ struct us_unusual_dev {
44130 __u8 useProtocol;
44131 __u8 useTransport;
44132 int (*initFunction)(struct us_data *);
44133 -};
44134 +} __do_const;
44135
44136
44137 /* Dynamic bitflag definitions (us->dflags): used in set_bit() etc. */
44138 diff --git a/drivers/usb/wusbcore/wa-hc.h b/drivers/usb/wusbcore/wa-hc.h
44139 index d6bea3e..60b250e 100644
44140 --- a/drivers/usb/wusbcore/wa-hc.h
44141 +++ b/drivers/usb/wusbcore/wa-hc.h
44142 @@ -192,7 +192,7 @@ struct wahc {
44143 struct list_head xfer_delayed_list;
44144 spinlock_t xfer_list_lock;
44145 struct work_struct xfer_work;
44146 - atomic_t xfer_id_count;
44147 + atomic_unchecked_t xfer_id_count;
44148 };
44149
44150
44151 @@ -246,7 +246,7 @@ static inline void wa_init(struct wahc *wa)
44152 INIT_LIST_HEAD(&wa->xfer_delayed_list);
44153 spin_lock_init(&wa->xfer_list_lock);
44154 INIT_WORK(&wa->xfer_work, wa_urb_enqueue_run);
44155 - atomic_set(&wa->xfer_id_count, 1);
44156 + atomic_set_unchecked(&wa->xfer_id_count, 1);
44157 }
44158
44159 /**
44160 diff --git a/drivers/usb/wusbcore/wa-xfer.c b/drivers/usb/wusbcore/wa-xfer.c
44161 index 57c01ab..8a05959 100644
44162 --- a/drivers/usb/wusbcore/wa-xfer.c
44163 +++ b/drivers/usb/wusbcore/wa-xfer.c
44164 @@ -296,7 +296,7 @@ out:
44165 */
44166 static void wa_xfer_id_init(struct wa_xfer *xfer)
44167 {
44168 - xfer->id = atomic_add_return(1, &xfer->wa->xfer_id_count);
44169 + xfer->id = atomic_add_return_unchecked(1, &xfer->wa->xfer_id_count);
44170 }
44171
44172 /*
44173 diff --git a/drivers/video/aty/aty128fb.c b/drivers/video/aty/aty128fb.c
44174 index 8c55011..eed4ae1a 100644
44175 --- a/drivers/video/aty/aty128fb.c
44176 +++ b/drivers/video/aty/aty128fb.c
44177 @@ -149,7 +149,7 @@ enum {
44178 };
44179
44180 /* Must match above enum */
44181 -static char * const r128_family[] = {
44182 +static const char * const r128_family[] = {
44183 "AGP",
44184 "PCI",
44185 "PRO AGP",
44186 diff --git a/drivers/video/aty/atyfb_base.c b/drivers/video/aty/atyfb_base.c
44187 index 4f27fdc..d3537e6 100644
44188 --- a/drivers/video/aty/atyfb_base.c
44189 +++ b/drivers/video/aty/atyfb_base.c
44190 @@ -1325,10 +1325,14 @@ static int atyfb_set_par(struct fb_info *info)
44191 par->accel_flags = var->accel_flags; /* hack */
44192
44193 if (var->accel_flags) {
44194 - info->fbops->fb_sync = atyfb_sync;
44195 + pax_open_kernel();
44196 + *(void **)&info->fbops->fb_sync = atyfb_sync;
44197 + pax_close_kernel();
44198 info->flags &= ~FBINFO_HWACCEL_DISABLED;
44199 } else {
44200 - info->fbops->fb_sync = NULL;
44201 + pax_open_kernel();
44202 + *(void **)&info->fbops->fb_sync = NULL;
44203 + pax_close_kernel();
44204 info->flags |= FBINFO_HWACCEL_DISABLED;
44205 }
44206
44207 diff --git a/drivers/video/aty/mach64_cursor.c b/drivers/video/aty/mach64_cursor.c
44208 index 95ec042..e6affdd 100644
44209 --- a/drivers/video/aty/mach64_cursor.c
44210 +++ b/drivers/video/aty/mach64_cursor.c
44211 @@ -7,6 +7,7 @@
44212 #include <linux/string.h>
44213
44214 #include <asm/io.h>
44215 +#include <asm/pgtable.h>
44216
44217 #ifdef __sparc__
44218 #include <asm/fbio.h>
44219 @@ -208,7 +209,9 @@ int aty_init_cursor(struct fb_info *info)
44220 info->sprite.buf_align = 16; /* and 64 lines tall. */
44221 info->sprite.flags = FB_PIXMAP_IO;
44222
44223 - info->fbops->fb_cursor = atyfb_cursor;
44224 + pax_open_kernel();
44225 + *(void **)&info->fbops->fb_cursor = atyfb_cursor;
44226 + pax_close_kernel();
44227
44228 return 0;
44229 }
44230 diff --git a/drivers/video/backlight/kb3886_bl.c b/drivers/video/backlight/kb3886_bl.c
44231 index 6c5ed6b..b727c88 100644
44232 --- a/drivers/video/backlight/kb3886_bl.c
44233 +++ b/drivers/video/backlight/kb3886_bl.c
44234 @@ -78,7 +78,7 @@ static struct kb3886bl_machinfo *bl_machinfo;
44235 static unsigned long kb3886bl_flags;
44236 #define KB3886BL_SUSPENDED 0x01
44237
44238 -static struct dmi_system_id __initdata kb3886bl_device_table[] = {
44239 +static const struct dmi_system_id __initconst kb3886bl_device_table[] = {
44240 {
44241 .ident = "Sahara Touch-iT",
44242 .matches = {
44243 diff --git a/drivers/video/fb_defio.c b/drivers/video/fb_defio.c
44244 index 88cad6b..dd746c7 100644
44245 --- a/drivers/video/fb_defio.c
44246 +++ b/drivers/video/fb_defio.c
44247 @@ -206,7 +206,9 @@ void fb_deferred_io_init(struct fb_info *info)
44248
44249 BUG_ON(!fbdefio);
44250 mutex_init(&fbdefio->lock);
44251 - info->fbops->fb_mmap = fb_deferred_io_mmap;
44252 + pax_open_kernel();
44253 + *(void **)&info->fbops->fb_mmap = fb_deferred_io_mmap;
44254 + pax_close_kernel();
44255 INIT_DELAYED_WORK(&info->deferred_work, fb_deferred_io_work);
44256 INIT_LIST_HEAD(&fbdefio->pagelist);
44257 if (fbdefio->delay == 0) /* set a default of 1 s */
44258 @@ -237,7 +239,7 @@ void fb_deferred_io_cleanup(struct fb_info *info)
44259 page->mapping = NULL;
44260 }
44261
44262 - info->fbops->fb_mmap = NULL;
44263 + *(void **)&info->fbops->fb_mmap = NULL;
44264 mutex_destroy(&fbdefio->lock);
44265 }
44266 EXPORT_SYMBOL_GPL(fb_deferred_io_cleanup);
44267 diff --git a/drivers/video/fbcmap.c b/drivers/video/fbcmap.c
44268 index 5c3960d..15cf8fc 100644
44269 --- a/drivers/video/fbcmap.c
44270 +++ b/drivers/video/fbcmap.c
44271 @@ -285,8 +285,7 @@ int fb_set_user_cmap(struct fb_cmap_user *cmap, struct fb_info *info)
44272 rc = -ENODEV;
44273 goto out;
44274 }
44275 - if (cmap->start < 0 || (!info->fbops->fb_setcolreg &&
44276 - !info->fbops->fb_setcmap)) {
44277 + if (!info->fbops->fb_setcolreg && !info->fbops->fb_setcmap) {
44278 rc = -EINVAL;
44279 goto out1;
44280 }
44281 diff --git a/drivers/video/fbmem.c b/drivers/video/fbmem.c
44282 index dc61c12..e29796e 100644
44283 --- a/drivers/video/fbmem.c
44284 +++ b/drivers/video/fbmem.c
44285 @@ -428,7 +428,7 @@ static void fb_do_show_logo(struct fb_info *info, struct fb_image *image,
44286 image->dx += image->width + 8;
44287 }
44288 } else if (rotate == FB_ROTATE_UD) {
44289 - for (x = 0; x < num && image->dx >= 0; x++) {
44290 + for (x = 0; x < num && (__s32)image->dx >= 0; x++) {
44291 info->fbops->fb_imageblit(info, image);
44292 image->dx -= image->width + 8;
44293 }
44294 @@ -440,7 +440,7 @@ static void fb_do_show_logo(struct fb_info *info, struct fb_image *image,
44295 image->dy += image->height + 8;
44296 }
44297 } else if (rotate == FB_ROTATE_CCW) {
44298 - for (x = 0; x < num && image->dy >= 0; x++) {
44299 + for (x = 0; x < num && (__s32)image->dy >= 0; x++) {
44300 info->fbops->fb_imageblit(info, image);
44301 image->dy -= image->height + 8;
44302 }
44303 @@ -1166,7 +1166,7 @@ static long do_fb_ioctl(struct fb_info *info, unsigned int cmd,
44304 return -EFAULT;
44305 if (con2fb.console < 1 || con2fb.console > MAX_NR_CONSOLES)
44306 return -EINVAL;
44307 - if (con2fb.framebuffer < 0 || con2fb.framebuffer >= FB_MAX)
44308 + if (con2fb.framebuffer >= FB_MAX)
44309 return -EINVAL;
44310 if (!registered_fb[con2fb.framebuffer])
44311 request_module("fb%d", con2fb.framebuffer);
44312 diff --git a/drivers/video/i810/i810_accel.c b/drivers/video/i810/i810_accel.c
44313 index 7672d2e..b56437f 100644
44314 --- a/drivers/video/i810/i810_accel.c
44315 +++ b/drivers/video/i810/i810_accel.c
44316 @@ -73,6 +73,7 @@ static inline int wait_for_space(struct fb_info *info, u32 space)
44317 }
44318 }
44319 printk("ringbuffer lockup!!!\n");
44320 + printk("head:%u tail:%u iring.size:%u space:%u\n", head, tail, par->iring.size, space);
44321 i810_report_error(mmio);
44322 par->dev_flags |= LOCKUP;
44323 info->pixmap.scan_align = 1;
44324 diff --git a/drivers/video/logo/logo_linux_clut224.ppm b/drivers/video/logo/logo_linux_clut224.ppm
44325 index 3c14e43..eafa544 100644
44326 --- a/drivers/video/logo/logo_linux_clut224.ppm
44327 +++ b/drivers/video/logo/logo_linux_clut224.ppm
44328 @@ -1,1604 +1,1123 @@
44329 P3
44330 -# Standard 224-color Linux logo
44331 80 80
44332 255
44333 - 0 0 0 0 0 0 0 0 0 0 0 0
44334 - 0 0 0 0 0 0 0 0 0 0 0 0
44335 - 0 0 0 0 0 0 0 0 0 0 0 0
44336 - 0 0 0 0 0 0 0 0 0 0 0 0
44337 - 0 0 0 0 0 0 0 0 0 0 0 0
44338 - 0 0 0 0 0 0 0 0 0 0 0 0
44339 - 0 0 0 0 0 0 0 0 0 0 0 0
44340 - 0 0 0 0 0 0 0 0 0 0 0 0
44341 - 0 0 0 0 0 0 0 0 0 0 0 0
44342 - 6 6 6 6 6 6 10 10 10 10 10 10
44343 - 10 10 10 6 6 6 6 6 6 6 6 6
44344 - 0 0 0 0 0 0 0 0 0 0 0 0
44345 - 0 0 0 0 0 0 0 0 0 0 0 0
44346 - 0 0 0 0 0 0 0 0 0 0 0 0
44347 - 0 0 0 0 0 0 0 0 0 0 0 0
44348 - 0 0 0 0 0 0 0 0 0 0 0 0
44349 - 0 0 0 0 0 0 0 0 0 0 0 0
44350 - 0 0 0 0 0 0 0 0 0 0 0 0
44351 - 0 0 0 0 0 0 0 0 0 0 0 0
44352 - 0 0 0 0 0 0 0 0 0 0 0 0
44353 - 0 0 0 0 0 0 0 0 0 0 0 0
44354 - 0 0 0 0 0 0 0 0 0 0 0 0
44355 - 0 0 0 0 0 0 0 0 0 0 0 0
44356 - 0 0 0 0 0 0 0 0 0 0 0 0
44357 - 0 0 0 0 0 0 0 0 0 0 0 0
44358 - 0 0 0 0 0 0 0 0 0 0 0 0
44359 - 0 0 0 0 0 0 0 0 0 0 0 0
44360 - 0 0 0 0 0 0 0 0 0 0 0 0
44361 - 0 0 0 6 6 6 10 10 10 14 14 14
44362 - 22 22 22 26 26 26 30 30 30 34 34 34
44363 - 30 30 30 30 30 30 26 26 26 18 18 18
44364 - 14 14 14 10 10 10 6 6 6 0 0 0
44365 - 0 0 0 0 0 0 0 0 0 0 0 0
44366 - 0 0 0 0 0 0 0 0 0 0 0 0
44367 - 0 0 0 0 0 0 0 0 0 0 0 0
44368 - 0 0 0 0 0 0 0 0 0 0 0 0
44369 - 0 0 0 0 0 0 0 0 0 0 0 0
44370 - 0 0 0 0 0 0 0 0 0 0 0 0
44371 - 0 0 0 0 0 0 0 0 0 0 0 0
44372 - 0 0 0 0 0 0 0 0 0 0 0 0
44373 - 0 0 0 0 0 0 0 0 0 0 0 0
44374 - 0 0 0 0 0 1 0 0 1 0 0 0
44375 - 0 0 0 0 0 0 0 0 0 0 0 0
44376 - 0 0 0 0 0 0 0 0 0 0 0 0
44377 - 0 0 0 0 0 0 0 0 0 0 0 0
44378 - 0 0 0 0 0 0 0 0 0 0 0 0
44379 - 0 0 0 0 0 0 0 0 0 0 0 0
44380 - 0 0 0 0 0 0 0 0 0 0 0 0
44381 - 6 6 6 14 14 14 26 26 26 42 42 42
44382 - 54 54 54 66 66 66 78 78 78 78 78 78
44383 - 78 78 78 74 74 74 66 66 66 54 54 54
44384 - 42 42 42 26 26 26 18 18 18 10 10 10
44385 - 6 6 6 0 0 0 0 0 0 0 0 0
44386 - 0 0 0 0 0 0 0 0 0 0 0 0
44387 - 0 0 0 0 0 0 0 0 0 0 0 0
44388 - 0 0 0 0 0 0 0 0 0 0 0 0
44389 - 0 0 0 0 0 0 0 0 0 0 0 0
44390 - 0 0 0 0 0 0 0 0 0 0 0 0
44391 - 0 0 0 0 0 0 0 0 0 0 0 0
44392 - 0 0 0 0 0 0 0 0 0 0 0 0
44393 - 0 0 0 0 0 0 0 0 0 0 0 0
44394 - 0 0 1 0 0 0 0 0 0 0 0 0
44395 - 0 0 0 0 0 0 0 0 0 0 0 0
44396 - 0 0 0 0 0 0 0 0 0 0 0 0
44397 - 0 0 0 0 0 0 0 0 0 0 0 0
44398 - 0 0 0 0 0 0 0 0 0 0 0 0
44399 - 0 0 0 0 0 0 0 0 0 0 0 0
44400 - 0 0 0 0 0 0 0 0 0 10 10 10
44401 - 22 22 22 42 42 42 66 66 66 86 86 86
44402 - 66 66 66 38 38 38 38 38 38 22 22 22
44403 - 26 26 26 34 34 34 54 54 54 66 66 66
44404 - 86 86 86 70 70 70 46 46 46 26 26 26
44405 - 14 14 14 6 6 6 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 - 0 0 0 0 0 0 0 0 0 0 0 0
44412 - 0 0 0 0 0 0 0 0 0 0 0 0
44413 - 0 0 0 0 0 0 0 0 0 0 0 0
44414 - 0 0 1 0 0 1 0 0 1 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 10 10 10 26 26 26
44421 - 50 50 50 82 82 82 58 58 58 6 6 6
44422 - 2 2 6 2 2 6 2 2 6 2 2 6
44423 - 2 2 6 2 2 6 2 2 6 2 2 6
44424 - 6 6 6 54 54 54 86 86 86 66 66 66
44425 - 38 38 38 18 18 18 6 6 6 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 0 0 0 0 0 0 0 0 0
44431 - 0 0 0 0 0 0 0 0 0 0 0 0
44432 - 0 0 0 0 0 0 0 0 0 0 0 0
44433 - 0 0 0 0 0 0 0 0 0 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 6 6 6 22 22 22 50 50 50
44441 - 78 78 78 34 34 34 2 2 6 2 2 6
44442 - 2 2 6 2 2 6 2 2 6 2 2 6
44443 - 2 2 6 2 2 6 2 2 6 2 2 6
44444 - 2 2 6 2 2 6 6 6 6 70 70 70
44445 - 78 78 78 46 46 46 22 22 22 6 6 6
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 - 0 0 0 0 0 0 0 0 0 0 0 0
44451 - 0 0 0 0 0 0 0 0 0 0 0 0
44452 - 0 0 0 0 0 0 0 0 0 0 0 0
44453 - 0 0 0 0 0 0 0 0 0 0 0 0
44454 - 0 0 1 0 0 1 0 0 1 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 - 6 6 6 18 18 18 42 42 42 82 82 82
44461 - 26 26 26 2 2 6 2 2 6 2 2 6
44462 - 2 2 6 2 2 6 2 2 6 2 2 6
44463 - 2 2 6 2 2 6 2 2 6 14 14 14
44464 - 46 46 46 34 34 34 6 6 6 2 2 6
44465 - 42 42 42 78 78 78 42 42 42 18 18 18
44466 - 6 6 6 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 0 0 0
44470 - 0 0 0 0 0 0 0 0 0 0 0 0
44471 - 0 0 0 0 0 0 0 0 0 0 0 0
44472 - 0 0 0 0 0 0 0 0 0 0 0 0
44473 - 0 0 0 0 0 0 0 0 0 0 0 0
44474 - 0 0 1 0 0 0 0 0 1 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 - 10 10 10 30 30 30 66 66 66 58 58 58
44481 - 2 2 6 2 2 6 2 2 6 2 2 6
44482 - 2 2 6 2 2 6 2 2 6 2 2 6
44483 - 2 2 6 2 2 6 2 2 6 26 26 26
44484 - 86 86 86 101 101 101 46 46 46 10 10 10
44485 - 2 2 6 58 58 58 70 70 70 34 34 34
44486 - 10 10 10 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 0 0 0 0 0 0
44490 - 0 0 0 0 0 0 0 0 0 0 0 0
44491 - 0 0 0 0 0 0 0 0 0 0 0 0
44492 - 0 0 0 0 0 0 0 0 0 0 0 0
44493 - 0 0 0 0 0 0 0 0 0 0 0 0
44494 - 0 0 1 0 0 1 0 0 1 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 - 14 14 14 42 42 42 86 86 86 10 10 10
44501 - 2 2 6 2 2 6 2 2 6 2 2 6
44502 - 2 2 6 2 2 6 2 2 6 2 2 6
44503 - 2 2 6 2 2 6 2 2 6 30 30 30
44504 - 94 94 94 94 94 94 58 58 58 26 26 26
44505 - 2 2 6 6 6 6 78 78 78 54 54 54
44506 - 22 22 22 6 6 6 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 0 0 0 0 0 0 0 0 0
44510 - 0 0 0 0 0 0 0 0 0 0 0 0
44511 - 0 0 0 0 0 0 0 0 0 0 0 0
44512 - 0 0 0 0 0 0 0 0 0 0 0 0
44513 - 0 0 0 0 0 0 0 0 0 0 0 0
44514 - 0 0 0 0 0 0 0 0 0 0 0 0
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 6 6 6
44520 - 22 22 22 62 62 62 62 62 62 2 2 6
44521 - 2 2 6 2 2 6 2 2 6 2 2 6
44522 - 2 2 6 2 2 6 2 2 6 2 2 6
44523 - 2 2 6 2 2 6 2 2 6 26 26 26
44524 - 54 54 54 38 38 38 18 18 18 10 10 10
44525 - 2 2 6 2 2 6 34 34 34 82 82 82
44526 - 38 38 38 14 14 14 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 - 0 0 0 0 0 0 0 0 0 0 0 0
44530 - 0 0 0 0 0 0 0 0 0 0 0 0
44531 - 0 0 0 0 0 0 0 0 0 0 0 0
44532 - 0 0 0 0 0 0 0 0 0 0 0 0
44533 - 0 0 0 0 0 0 0 0 0 0 0 0
44534 - 0 0 0 0 0 1 0 0 1 0 0 0
44535 - 0 0 0 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 6 6 6
44540 - 30 30 30 78 78 78 30 30 30 2 2 6
44541 - 2 2 6 2 2 6 2 2 6 2 2 6
44542 - 2 2 6 2 2 6 2 2 6 2 2 6
44543 - 2 2 6 2 2 6 2 2 6 10 10 10
44544 - 10 10 10 2 2 6 2 2 6 2 2 6
44545 - 2 2 6 2 2 6 2 2 6 78 78 78
44546 - 50 50 50 18 18 18 6 6 6 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 - 0 0 0 0 0 0 0 0 0 0 0 0
44550 - 0 0 0 0 0 0 0 0 0 0 0 0
44551 - 0 0 0 0 0 0 0 0 0 0 0 0
44552 - 0 0 0 0 0 0 0 0 0 0 0 0
44553 - 0 0 0 0 0 0 0 0 0 0 0 0
44554 - 0 0 1 0 0 0 0 0 0 0 0 0
44555 - 0 0 0 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 10 10 10
44560 - 38 38 38 86 86 86 14 14 14 2 2 6
44561 - 2 2 6 2 2 6 2 2 6 2 2 6
44562 - 2 2 6 2 2 6 2 2 6 2 2 6
44563 - 2 2 6 2 2 6 2 2 6 2 2 6
44564 - 2 2 6 2 2 6 2 2 6 2 2 6
44565 - 2 2 6 2 2 6 2 2 6 54 54 54
44566 - 66 66 66 26 26 26 6 6 6 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 - 0 0 0 0 0 0 0 0 0 0 0 0
44570 - 0 0 0 0 0 0 0 0 0 0 0 0
44571 - 0 0 0 0 0 0 0 0 0 0 0 0
44572 - 0 0 0 0 0 0 0 0 0 0 0 0
44573 - 0 0 0 0 0 0 0 0 0 0 0 0
44574 - 0 0 0 0 0 1 0 0 1 0 0 0
44575 - 0 0 0 0 0 0 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 14 14 14
44580 - 42 42 42 82 82 82 2 2 6 2 2 6
44581 - 2 2 6 6 6 6 10 10 10 2 2 6
44582 - 2 2 6 2 2 6 2 2 6 2 2 6
44583 - 2 2 6 2 2 6 2 2 6 6 6 6
44584 - 14 14 14 10 10 10 2 2 6 2 2 6
44585 - 2 2 6 2 2 6 2 2 6 18 18 18
44586 - 82 82 82 34 34 34 10 10 10 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 0 0 0
44589 - 0 0 0 0 0 0 0 0 0 0 0 0
44590 - 0 0 0 0 0 0 0 0 0 0 0 0
44591 - 0 0 0 0 0 0 0 0 0 0 0 0
44592 - 0 0 0 0 0 0 0 0 0 0 0 0
44593 - 0 0 0 0 0 0 0 0 0 0 0 0
44594 - 0 0 1 0 0 0 0 0 0 0 0 0
44595 - 0 0 0 0 0 0 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 14 14 14
44600 - 46 46 46 86 86 86 2 2 6 2 2 6
44601 - 6 6 6 6 6 6 22 22 22 34 34 34
44602 - 6 6 6 2 2 6 2 2 6 2 2 6
44603 - 2 2 6 2 2 6 18 18 18 34 34 34
44604 - 10 10 10 50 50 50 22 22 22 2 2 6
44605 - 2 2 6 2 2 6 2 2 6 10 10 10
44606 - 86 86 86 42 42 42 14 14 14 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 0 0 0
44609 - 0 0 0 0 0 0 0 0 0 0 0 0
44610 - 0 0 0 0 0 0 0 0 0 0 0 0
44611 - 0 0 0 0 0 0 0 0 0 0 0 0
44612 - 0 0 0 0 0 0 0 0 0 0 0 0
44613 - 0 0 0 0 0 0 0 0 0 0 0 0
44614 - 0 0 1 0 0 1 0 0 1 0 0 0
44615 - 0 0 0 0 0 0 0 0 0 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 14 14 14
44620 - 46 46 46 86 86 86 2 2 6 2 2 6
44621 - 38 38 38 116 116 116 94 94 94 22 22 22
44622 - 22 22 22 2 2 6 2 2 6 2 2 6
44623 - 14 14 14 86 86 86 138 138 138 162 162 162
44624 -154 154 154 38 38 38 26 26 26 6 6 6
44625 - 2 2 6 2 2 6 2 2 6 2 2 6
44626 - 86 86 86 46 46 46 14 14 14 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 0 0 0
44629 - 0 0 0 0 0 0 0 0 0 0 0 0
44630 - 0 0 0 0 0 0 0 0 0 0 0 0
44631 - 0 0 0 0 0 0 0 0 0 0 0 0
44632 - 0 0 0 0 0 0 0 0 0 0 0 0
44633 - 0 0 0 0 0 0 0 0 0 0 0 0
44634 - 0 0 0 0 0 0 0 0 0 0 0 0
44635 - 0 0 0 0 0 0 0 0 0 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 14 14 14
44640 - 46 46 46 86 86 86 2 2 6 14 14 14
44641 -134 134 134 198 198 198 195 195 195 116 116 116
44642 - 10 10 10 2 2 6 2 2 6 6 6 6
44643 -101 98 89 187 187 187 210 210 210 218 218 218
44644 -214 214 214 134 134 134 14 14 14 6 6 6
44645 - 2 2 6 2 2 6 2 2 6 2 2 6
44646 - 86 86 86 50 50 50 18 18 18 6 6 6
44647 - 0 0 0 0 0 0 0 0 0 0 0 0
44648 - 0 0 0 0 0 0 0 0 0 0 0 0
44649 - 0 0 0 0 0 0 0 0 0 0 0 0
44650 - 0 0 0 0 0 0 0 0 0 0 0 0
44651 - 0 0 0 0 0 0 0 0 0 0 0 0
44652 - 0 0 0 0 0 0 0 0 0 0 0 0
44653 - 0 0 0 0 0 0 0 0 1 0 0 0
44654 - 0 0 1 0 0 1 0 0 1 0 0 0
44655 - 0 0 0 0 0 0 0 0 0 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 14 14 14
44660 - 46 46 46 86 86 86 2 2 6 54 54 54
44661 -218 218 218 195 195 195 226 226 226 246 246 246
44662 - 58 58 58 2 2 6 2 2 6 30 30 30
44663 -210 210 210 253 253 253 174 174 174 123 123 123
44664 -221 221 221 234 234 234 74 74 74 2 2 6
44665 - 2 2 6 2 2 6 2 2 6 2 2 6
44666 - 70 70 70 58 58 58 22 22 22 6 6 6
44667 - 0 0 0 0 0 0 0 0 0 0 0 0
44668 - 0 0 0 0 0 0 0 0 0 0 0 0
44669 - 0 0 0 0 0 0 0 0 0 0 0 0
44670 - 0 0 0 0 0 0 0 0 0 0 0 0
44671 - 0 0 0 0 0 0 0 0 0 0 0 0
44672 - 0 0 0 0 0 0 0 0 0 0 0 0
44673 - 0 0 0 0 0 0 0 0 0 0 0 0
44674 - 0 0 0 0 0 0 0 0 0 0 0 0
44675 - 0 0 0 0 0 0 0 0 0 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 14 14 14
44680 - 46 46 46 82 82 82 2 2 6 106 106 106
44681 -170 170 170 26 26 26 86 86 86 226 226 226
44682 -123 123 123 10 10 10 14 14 14 46 46 46
44683 -231 231 231 190 190 190 6 6 6 70 70 70
44684 - 90 90 90 238 238 238 158 158 158 2 2 6
44685 - 2 2 6 2 2 6 2 2 6 2 2 6
44686 - 70 70 70 58 58 58 22 22 22 6 6 6
44687 - 0 0 0 0 0 0 0 0 0 0 0 0
44688 - 0 0 0 0 0 0 0 0 0 0 0 0
44689 - 0 0 0 0 0 0 0 0 0 0 0 0
44690 - 0 0 0 0 0 0 0 0 0 0 0 0
44691 - 0 0 0 0 0 0 0 0 0 0 0 0
44692 - 0 0 0 0 0 0 0 0 0 0 0 0
44693 - 0 0 0 0 0 0 0 0 1 0 0 0
44694 - 0 0 1 0 0 1 0 0 1 0 0 0
44695 - 0 0 0 0 0 0 0 0 0 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 14 14 14
44700 - 42 42 42 86 86 86 6 6 6 116 116 116
44701 -106 106 106 6 6 6 70 70 70 149 149 149
44702 -128 128 128 18 18 18 38 38 38 54 54 54
44703 -221 221 221 106 106 106 2 2 6 14 14 14
44704 - 46 46 46 190 190 190 198 198 198 2 2 6
44705 - 2 2 6 2 2 6 2 2 6 2 2 6
44706 - 74 74 74 62 62 62 22 22 22 6 6 6
44707 - 0 0 0 0 0 0 0 0 0 0 0 0
44708 - 0 0 0 0 0 0 0 0 0 0 0 0
44709 - 0 0 0 0 0 0 0 0 0 0 0 0
44710 - 0 0 0 0 0 0 0 0 0 0 0 0
44711 - 0 0 0 0 0 0 0 0 0 0 0 0
44712 - 0 0 0 0 0 0 0 0 0 0 0 0
44713 - 0 0 0 0 0 0 0 0 1 0 0 0
44714 - 0 0 1 0 0 0 0 0 1 0 0 0
44715 - 0 0 0 0 0 0 0 0 0 0 0 0
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 14 14 14
44720 - 42 42 42 94 94 94 14 14 14 101 101 101
44721 -128 128 128 2 2 6 18 18 18 116 116 116
44722 -118 98 46 121 92 8 121 92 8 98 78 10
44723 -162 162 162 106 106 106 2 2 6 2 2 6
44724 - 2 2 6 195 195 195 195 195 195 6 6 6
44725 - 2 2 6 2 2 6 2 2 6 2 2 6
44726 - 74 74 74 62 62 62 22 22 22 6 6 6
44727 - 0 0 0 0 0 0 0 0 0 0 0 0
44728 - 0 0 0 0 0 0 0 0 0 0 0 0
44729 - 0 0 0 0 0 0 0 0 0 0 0 0
44730 - 0 0 0 0 0 0 0 0 0 0 0 0
44731 - 0 0 0 0 0 0 0 0 0 0 0 0
44732 - 0 0 0 0 0 0 0 0 0 0 0 0
44733 - 0 0 0 0 0 0 0 0 1 0 0 1
44734 - 0 0 1 0 0 0 0 0 1 0 0 0
44735 - 0 0 0 0 0 0 0 0 0 0 0 0
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 10 10 10
44740 - 38 38 38 90 90 90 14 14 14 58 58 58
44741 -210 210 210 26 26 26 54 38 6 154 114 10
44742 -226 170 11 236 186 11 225 175 15 184 144 12
44743 -215 174 15 175 146 61 37 26 9 2 2 6
44744 - 70 70 70 246 246 246 138 138 138 2 2 6
44745 - 2 2 6 2 2 6 2 2 6 2 2 6
44746 - 70 70 70 66 66 66 26 26 26 6 6 6
44747 - 0 0 0 0 0 0 0 0 0 0 0 0
44748 - 0 0 0 0 0 0 0 0 0 0 0 0
44749 - 0 0 0 0 0 0 0 0 0 0 0 0
44750 - 0 0 0 0 0 0 0 0 0 0 0 0
44751 - 0 0 0 0 0 0 0 0 0 0 0 0
44752 - 0 0 0 0 0 0 0 0 0 0 0 0
44753 - 0 0 0 0 0 0 0 0 0 0 0 0
44754 - 0 0 0 0 0 0 0 0 0 0 0 0
44755 - 0 0 0 0 0 0 0 0 0 0 0 0
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 10 10 10
44760 - 38 38 38 86 86 86 14 14 14 10 10 10
44761 -195 195 195 188 164 115 192 133 9 225 175 15
44762 -239 182 13 234 190 10 232 195 16 232 200 30
44763 -245 207 45 241 208 19 232 195 16 184 144 12
44764 -218 194 134 211 206 186 42 42 42 2 2 6
44765 - 2 2 6 2 2 6 2 2 6 2 2 6
44766 - 50 50 50 74 74 74 30 30 30 6 6 6
44767 - 0 0 0 0 0 0 0 0 0 0 0 0
44768 - 0 0 0 0 0 0 0 0 0 0 0 0
44769 - 0 0 0 0 0 0 0 0 0 0 0 0
44770 - 0 0 0 0 0 0 0 0 0 0 0 0
44771 - 0 0 0 0 0 0 0 0 0 0 0 0
44772 - 0 0 0 0 0 0 0 0 0 0 0 0
44773 - 0 0 0 0 0 0 0 0 0 0 0 0
44774 - 0 0 0 0 0 0 0 0 0 0 0 0
44775 - 0 0 0 0 0 0 0 0 0 0 0 0
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 10 10 10
44780 - 34 34 34 86 86 86 14 14 14 2 2 6
44781 -121 87 25 192 133 9 219 162 10 239 182 13
44782 -236 186 11 232 195 16 241 208 19 244 214 54
44783 -246 218 60 246 218 38 246 215 20 241 208 19
44784 -241 208 19 226 184 13 121 87 25 2 2 6
44785 - 2 2 6 2 2 6 2 2 6 2 2 6
44786 - 50 50 50 82 82 82 34 34 34 10 10 10
44787 - 0 0 0 0 0 0 0 0 0 0 0 0
44788 - 0 0 0 0 0 0 0 0 0 0 0 0
44789 - 0 0 0 0 0 0 0 0 0 0 0 0
44790 - 0 0 0 0 0 0 0 0 0 0 0 0
44791 - 0 0 0 0 0 0 0 0 0 0 0 0
44792 - 0 0 0 0 0 0 0 0 0 0 0 0
44793 - 0 0 0 0 0 0 0 0 0 0 0 0
44794 - 0 0 0 0 0 0 0 0 0 0 0 0
44795 - 0 0 0 0 0 0 0 0 0 0 0 0
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 10 10 10
44800 - 34 34 34 82 82 82 30 30 30 61 42 6
44801 -180 123 7 206 145 10 230 174 11 239 182 13
44802 -234 190 10 238 202 15 241 208 19 246 218 74
44803 -246 218 38 246 215 20 246 215 20 246 215 20
44804 -226 184 13 215 174 15 184 144 12 6 6 6
44805 - 2 2 6 2 2 6 2 2 6 2 2 6
44806 - 26 26 26 94 94 94 42 42 42 14 14 14
44807 - 0 0 0 0 0 0 0 0 0 0 0 0
44808 - 0 0 0 0 0 0 0 0 0 0 0 0
44809 - 0 0 0 0 0 0 0 0 0 0 0 0
44810 - 0 0 0 0 0 0 0 0 0 0 0 0
44811 - 0 0 0 0 0 0 0 0 0 0 0 0
44812 - 0 0 0 0 0 0 0 0 0 0 0 0
44813 - 0 0 0 0 0 0 0 0 0 0 0 0
44814 - 0 0 0 0 0 0 0 0 0 0 0 0
44815 - 0 0 0 0 0 0 0 0 0 0 0 0
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 10 10 10
44820 - 30 30 30 78 78 78 50 50 50 104 69 6
44821 -192 133 9 216 158 10 236 178 12 236 186 11
44822 -232 195 16 241 208 19 244 214 54 245 215 43
44823 -246 215 20 246 215 20 241 208 19 198 155 10
44824 -200 144 11 216 158 10 156 118 10 2 2 6
44825 - 2 2 6 2 2 6 2 2 6 2 2 6
44826 - 6 6 6 90 90 90 54 54 54 18 18 18
44827 - 6 6 6 0 0 0 0 0 0 0 0 0
44828 - 0 0 0 0 0 0 0 0 0 0 0 0
44829 - 0 0 0 0 0 0 0 0 0 0 0 0
44830 - 0 0 0 0 0 0 0 0 0 0 0 0
44831 - 0 0 0 0 0 0 0 0 0 0 0 0
44832 - 0 0 0 0 0 0 0 0 0 0 0 0
44833 - 0 0 0 0 0 0 0 0 0 0 0 0
44834 - 0 0 0 0 0 0 0 0 0 0 0 0
44835 - 0 0 0 0 0 0 0 0 0 0 0 0
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 10 10 10
44840 - 30 30 30 78 78 78 46 46 46 22 22 22
44841 -137 92 6 210 162 10 239 182 13 238 190 10
44842 -238 202 15 241 208 19 246 215 20 246 215 20
44843 -241 208 19 203 166 17 185 133 11 210 150 10
44844 -216 158 10 210 150 10 102 78 10 2 2 6
44845 - 6 6 6 54 54 54 14 14 14 2 2 6
44846 - 2 2 6 62 62 62 74 74 74 30 30 30
44847 - 10 10 10 0 0 0 0 0 0 0 0 0
44848 - 0 0 0 0 0 0 0 0 0 0 0 0
44849 - 0 0 0 0 0 0 0 0 0 0 0 0
44850 - 0 0 0 0 0 0 0 0 0 0 0 0
44851 - 0 0 0 0 0 0 0 0 0 0 0 0
44852 - 0 0 0 0 0 0 0 0 0 0 0 0
44853 - 0 0 0 0 0 0 0 0 0 0 0 0
44854 - 0 0 0 0 0 0 0 0 0 0 0 0
44855 - 0 0 0 0 0 0 0 0 0 0 0 0
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 10 10 10
44860 - 34 34 34 78 78 78 50 50 50 6 6 6
44861 - 94 70 30 139 102 15 190 146 13 226 184 13
44862 -232 200 30 232 195 16 215 174 15 190 146 13
44863 -168 122 10 192 133 9 210 150 10 213 154 11
44864 -202 150 34 182 157 106 101 98 89 2 2 6
44865 - 2 2 6 78 78 78 116 116 116 58 58 58
44866 - 2 2 6 22 22 22 90 90 90 46 46 46
44867 - 18 18 18 6 6 6 0 0 0 0 0 0
44868 - 0 0 0 0 0 0 0 0 0 0 0 0
44869 - 0 0 0 0 0 0 0 0 0 0 0 0
44870 - 0 0 0 0 0 0 0 0 0 0 0 0
44871 - 0 0 0 0 0 0 0 0 0 0 0 0
44872 - 0 0 0 0 0 0 0 0 0 0 0 0
44873 - 0 0 0 0 0 0 0 0 0 0 0 0
44874 - 0 0 0 0 0 0 0 0 0 0 0 0
44875 - 0 0 0 0 0 0 0 0 0 0 0 0
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 10 10 10
44880 - 38 38 38 86 86 86 50 50 50 6 6 6
44881 -128 128 128 174 154 114 156 107 11 168 122 10
44882 -198 155 10 184 144 12 197 138 11 200 144 11
44883 -206 145 10 206 145 10 197 138 11 188 164 115
44884 -195 195 195 198 198 198 174 174 174 14 14 14
44885 - 2 2 6 22 22 22 116 116 116 116 116 116
44886 - 22 22 22 2 2 6 74 74 74 70 70 70
44887 - 30 30 30 10 10 10 0 0 0 0 0 0
44888 - 0 0 0 0 0 0 0 0 0 0 0 0
44889 - 0 0 0 0 0 0 0 0 0 0 0 0
44890 - 0 0 0 0 0 0 0 0 0 0 0 0
44891 - 0 0 0 0 0 0 0 0 0 0 0 0
44892 - 0 0 0 0 0 0 0 0 0 0 0 0
44893 - 0 0 0 0 0 0 0 0 0 0 0 0
44894 - 0 0 0 0 0 0 0 0 0 0 0 0
44895 - 0 0 0 0 0 0 0 0 0 0 0 0
44896 - 0 0 0 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 6 6 6 18 18 18
44900 - 50 50 50 101 101 101 26 26 26 10 10 10
44901 -138 138 138 190 190 190 174 154 114 156 107 11
44902 -197 138 11 200 144 11 197 138 11 192 133 9
44903 -180 123 7 190 142 34 190 178 144 187 187 187
44904 -202 202 202 221 221 221 214 214 214 66 66 66
44905 - 2 2 6 2 2 6 50 50 50 62 62 62
44906 - 6 6 6 2 2 6 10 10 10 90 90 90
44907 - 50 50 50 18 18 18 6 6 6 0 0 0
44908 - 0 0 0 0 0 0 0 0 0 0 0 0
44909 - 0 0 0 0 0 0 0 0 0 0 0 0
44910 - 0 0 0 0 0 0 0 0 0 0 0 0
44911 - 0 0 0 0 0 0 0 0 0 0 0 0
44912 - 0 0 0 0 0 0 0 0 0 0 0 0
44913 - 0 0 0 0 0 0 0 0 0 0 0 0
44914 - 0 0 0 0 0 0 0 0 0 0 0 0
44915 - 0 0 0 0 0 0 0 0 0 0 0 0
44916 - 0 0 0 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 10 10 10 34 34 34
44920 - 74 74 74 74 74 74 2 2 6 6 6 6
44921 -144 144 144 198 198 198 190 190 190 178 166 146
44922 -154 121 60 156 107 11 156 107 11 168 124 44
44923 -174 154 114 187 187 187 190 190 190 210 210 210
44924 -246 246 246 253 253 253 253 253 253 182 182 182
44925 - 6 6 6 2 2 6 2 2 6 2 2 6
44926 - 2 2 6 2 2 6 2 2 6 62 62 62
44927 - 74 74 74 34 34 34 14 14 14 0 0 0
44928 - 0 0 0 0 0 0 0 0 0 0 0 0
44929 - 0 0 0 0 0 0 0 0 0 0 0 0
44930 - 0 0 0 0 0 0 0 0 0 0 0 0
44931 - 0 0 0 0 0 0 0 0 0 0 0 0
44932 - 0 0 0 0 0 0 0 0 0 0 0 0
44933 - 0 0 0 0 0 0 0 0 0 0 0 0
44934 - 0 0 0 0 0 0 0 0 0 0 0 0
44935 - 0 0 0 0 0 0 0 0 0 0 0 0
44936 - 0 0 0 0 0 0 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 10 10 10 22 22 22 54 54 54
44940 - 94 94 94 18 18 18 2 2 6 46 46 46
44941 -234 234 234 221 221 221 190 190 190 190 190 190
44942 -190 190 190 187 187 187 187 187 187 190 190 190
44943 -190 190 190 195 195 195 214 214 214 242 242 242
44944 -253 253 253 253 253 253 253 253 253 253 253 253
44945 - 82 82 82 2 2 6 2 2 6 2 2 6
44946 - 2 2 6 2 2 6 2 2 6 14 14 14
44947 - 86 86 86 54 54 54 22 22 22 6 6 6
44948 - 0 0 0 0 0 0 0 0 0 0 0 0
44949 - 0 0 0 0 0 0 0 0 0 0 0 0
44950 - 0 0 0 0 0 0 0 0 0 0 0 0
44951 - 0 0 0 0 0 0 0 0 0 0 0 0
44952 - 0 0 0 0 0 0 0 0 0 0 0 0
44953 - 0 0 0 0 0 0 0 0 0 0 0 0
44954 - 0 0 0 0 0 0 0 0 0 0 0 0
44955 - 0 0 0 0 0 0 0 0 0 0 0 0
44956 - 0 0 0 0 0 0 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 - 6 6 6 18 18 18 46 46 46 90 90 90
44960 - 46 46 46 18 18 18 6 6 6 182 182 182
44961 -253 253 253 246 246 246 206 206 206 190 190 190
44962 -190 190 190 190 190 190 190 190 190 190 190 190
44963 -206 206 206 231 231 231 250 250 250 253 253 253
44964 -253 253 253 253 253 253 253 253 253 253 253 253
44965 -202 202 202 14 14 14 2 2 6 2 2 6
44966 - 2 2 6 2 2 6 2 2 6 2 2 6
44967 - 42 42 42 86 86 86 42 42 42 18 18 18
44968 - 6 6 6 0 0 0 0 0 0 0 0 0
44969 - 0 0 0 0 0 0 0 0 0 0 0 0
44970 - 0 0 0 0 0 0 0 0 0 0 0 0
44971 - 0 0 0 0 0 0 0 0 0 0 0 0
44972 - 0 0 0 0 0 0 0 0 0 0 0 0
44973 - 0 0 0 0 0 0 0 0 0 0 0 0
44974 - 0 0 0 0 0 0 0 0 0 0 0 0
44975 - 0 0 0 0 0 0 0 0 0 0 0 0
44976 - 0 0 0 0 0 0 0 0 0 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 6 6 6
44979 - 14 14 14 38 38 38 74 74 74 66 66 66
44980 - 2 2 6 6 6 6 90 90 90 250 250 250
44981 -253 253 253 253 253 253 238 238 238 198 198 198
44982 -190 190 190 190 190 190 195 195 195 221 221 221
44983 -246 246 246 253 253 253 253 253 253 253 253 253
44984 -253 253 253 253 253 253 253 253 253 253 253 253
44985 -253 253 253 82 82 82 2 2 6 2 2 6
44986 - 2 2 6 2 2 6 2 2 6 2 2 6
44987 - 2 2 6 78 78 78 70 70 70 34 34 34
44988 - 14 14 14 6 6 6 0 0 0 0 0 0
44989 - 0 0 0 0 0 0 0 0 0 0 0 0
44990 - 0 0 0 0 0 0 0 0 0 0 0 0
44991 - 0 0 0 0 0 0 0 0 0 0 0 0
44992 - 0 0 0 0 0 0 0 0 0 0 0 0
44993 - 0 0 0 0 0 0 0 0 0 0 0 0
44994 - 0 0 0 0 0 0 0 0 0 0 0 0
44995 - 0 0 0 0 0 0 0 0 0 0 0 0
44996 - 0 0 0 0 0 0 0 0 0 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 14 14 14
44999 - 34 34 34 66 66 66 78 78 78 6 6 6
45000 - 2 2 6 18 18 18 218 218 218 253 253 253
45001 -253 253 253 253 253 253 253 253 253 246 246 246
45002 -226 226 226 231 231 231 246 246 246 253 253 253
45003 -253 253 253 253 253 253 253 253 253 253 253 253
45004 -253 253 253 253 253 253 253 253 253 253 253 253
45005 -253 253 253 178 178 178 2 2 6 2 2 6
45006 - 2 2 6 2 2 6 2 2 6 2 2 6
45007 - 2 2 6 18 18 18 90 90 90 62 62 62
45008 - 30 30 30 10 10 10 0 0 0 0 0 0
45009 - 0 0 0 0 0 0 0 0 0 0 0 0
45010 - 0 0 0 0 0 0 0 0 0 0 0 0
45011 - 0 0 0 0 0 0 0 0 0 0 0 0
45012 - 0 0 0 0 0 0 0 0 0 0 0 0
45013 - 0 0 0 0 0 0 0 0 0 0 0 0
45014 - 0 0 0 0 0 0 0 0 0 0 0 0
45015 - 0 0 0 0 0 0 0 0 0 0 0 0
45016 - 0 0 0 0 0 0 0 0 0 0 0 0
45017 - 0 0 0 0 0 0 0 0 0 0 0 0
45018 - 0 0 0 0 0 0 10 10 10 26 26 26
45019 - 58 58 58 90 90 90 18 18 18 2 2 6
45020 - 2 2 6 110 110 110 253 253 253 253 253 253
45021 -253 253 253 253 253 253 253 253 253 253 253 253
45022 -250 250 250 253 253 253 253 253 253 253 253 253
45023 -253 253 253 253 253 253 253 253 253 253 253 253
45024 -253 253 253 253 253 253 253 253 253 253 253 253
45025 -253 253 253 231 231 231 18 18 18 2 2 6
45026 - 2 2 6 2 2 6 2 2 6 2 2 6
45027 - 2 2 6 2 2 6 18 18 18 94 94 94
45028 - 54 54 54 26 26 26 10 10 10 0 0 0
45029 - 0 0 0 0 0 0 0 0 0 0 0 0
45030 - 0 0 0 0 0 0 0 0 0 0 0 0
45031 - 0 0 0 0 0 0 0 0 0 0 0 0
45032 - 0 0 0 0 0 0 0 0 0 0 0 0
45033 - 0 0 0 0 0 0 0 0 0 0 0 0
45034 - 0 0 0 0 0 0 0 0 0 0 0 0
45035 - 0 0 0 0 0 0 0 0 0 0 0 0
45036 - 0 0 0 0 0 0 0 0 0 0 0 0
45037 - 0 0 0 0 0 0 0 0 0 0 0 0
45038 - 0 0 0 6 6 6 22 22 22 50 50 50
45039 - 90 90 90 26 26 26 2 2 6 2 2 6
45040 - 14 14 14 195 195 195 250 250 250 253 253 253
45041 -253 253 253 253 253 253 253 253 253 253 253 253
45042 -253 253 253 253 253 253 253 253 253 253 253 253
45043 -253 253 253 253 253 253 253 253 253 253 253 253
45044 -253 253 253 253 253 253 253 253 253 253 253 253
45045 -250 250 250 242 242 242 54 54 54 2 2 6
45046 - 2 2 6 2 2 6 2 2 6 2 2 6
45047 - 2 2 6 2 2 6 2 2 6 38 38 38
45048 - 86 86 86 50 50 50 22 22 22 6 6 6
45049 - 0 0 0 0 0 0 0 0 0 0 0 0
45050 - 0 0 0 0 0 0 0 0 0 0 0 0
45051 - 0 0 0 0 0 0 0 0 0 0 0 0
45052 - 0 0 0 0 0 0 0 0 0 0 0 0
45053 - 0 0 0 0 0 0 0 0 0 0 0 0
45054 - 0 0 0 0 0 0 0 0 0 0 0 0
45055 - 0 0 0 0 0 0 0 0 0 0 0 0
45056 - 0 0 0 0 0 0 0 0 0 0 0 0
45057 - 0 0 0 0 0 0 0 0 0 0 0 0
45058 - 6 6 6 14 14 14 38 38 38 82 82 82
45059 - 34 34 34 2 2 6 2 2 6 2 2 6
45060 - 42 42 42 195 195 195 246 246 246 253 253 253
45061 -253 253 253 253 253 253 253 253 253 250 250 250
45062 -242 242 242 242 242 242 250 250 250 253 253 253
45063 -253 253 253 253 253 253 253 253 253 253 253 253
45064 -253 253 253 250 250 250 246 246 246 238 238 238
45065 -226 226 226 231 231 231 101 101 101 6 6 6
45066 - 2 2 6 2 2 6 2 2 6 2 2 6
45067 - 2 2 6 2 2 6 2 2 6 2 2 6
45068 - 38 38 38 82 82 82 42 42 42 14 14 14
45069 - 6 6 6 0 0 0 0 0 0 0 0 0
45070 - 0 0 0 0 0 0 0 0 0 0 0 0
45071 - 0 0 0 0 0 0 0 0 0 0 0 0
45072 - 0 0 0 0 0 0 0 0 0 0 0 0
45073 - 0 0 0 0 0 0 0 0 0 0 0 0
45074 - 0 0 0 0 0 0 0 0 0 0 0 0
45075 - 0 0 0 0 0 0 0 0 0 0 0 0
45076 - 0 0 0 0 0 0 0 0 0 0 0 0
45077 - 0 0 0 0 0 0 0 0 0 0 0 0
45078 - 10 10 10 26 26 26 62 62 62 66 66 66
45079 - 2 2 6 2 2 6 2 2 6 6 6 6
45080 - 70 70 70 170 170 170 206 206 206 234 234 234
45081 -246 246 246 250 250 250 250 250 250 238 238 238
45082 -226 226 226 231 231 231 238 238 238 250 250 250
45083 -250 250 250 250 250 250 246 246 246 231 231 231
45084 -214 214 214 206 206 206 202 202 202 202 202 202
45085 -198 198 198 202 202 202 182 182 182 18 18 18
45086 - 2 2 6 2 2 6 2 2 6 2 2 6
45087 - 2 2 6 2 2 6 2 2 6 2 2 6
45088 - 2 2 6 62 62 62 66 66 66 30 30 30
45089 - 10 10 10 0 0 0 0 0 0 0 0 0
45090 - 0 0 0 0 0 0 0 0 0 0 0 0
45091 - 0 0 0 0 0 0 0 0 0 0 0 0
45092 - 0 0 0 0 0 0 0 0 0 0 0 0
45093 - 0 0 0 0 0 0 0 0 0 0 0 0
45094 - 0 0 0 0 0 0 0 0 0 0 0 0
45095 - 0 0 0 0 0 0 0 0 0 0 0 0
45096 - 0 0 0 0 0 0 0 0 0 0 0 0
45097 - 0 0 0 0 0 0 0 0 0 0 0 0
45098 - 14 14 14 42 42 42 82 82 82 18 18 18
45099 - 2 2 6 2 2 6 2 2 6 10 10 10
45100 - 94 94 94 182 182 182 218 218 218 242 242 242
45101 -250 250 250 253 253 253 253 253 253 250 250 250
45102 -234 234 234 253 253 253 253 253 253 253 253 253
45103 -253 253 253 253 253 253 253 253 253 246 246 246
45104 -238 238 238 226 226 226 210 210 210 202 202 202
45105 -195 195 195 195 195 195 210 210 210 158 158 158
45106 - 6 6 6 14 14 14 50 50 50 14 14 14
45107 - 2 2 6 2 2 6 2 2 6 2 2 6
45108 - 2 2 6 6 6 6 86 86 86 46 46 46
45109 - 18 18 18 6 6 6 0 0 0 0 0 0
45110 - 0 0 0 0 0 0 0 0 0 0 0 0
45111 - 0 0 0 0 0 0 0 0 0 0 0 0
45112 - 0 0 0 0 0 0 0 0 0 0 0 0
45113 - 0 0 0 0 0 0 0 0 0 0 0 0
45114 - 0 0 0 0 0 0 0 0 0 0 0 0
45115 - 0 0 0 0 0 0 0 0 0 0 0 0
45116 - 0 0 0 0 0 0 0 0 0 0 0 0
45117 - 0 0 0 0 0 0 0 0 0 6 6 6
45118 - 22 22 22 54 54 54 70 70 70 2 2 6
45119 - 2 2 6 10 10 10 2 2 6 22 22 22
45120 -166 166 166 231 231 231 250 250 250 253 253 253
45121 -253 253 253 253 253 253 253 253 253 250 250 250
45122 -242 242 242 253 253 253 253 253 253 253 253 253
45123 -253 253 253 253 253 253 253 253 253 253 253 253
45124 -253 253 253 253 253 253 253 253 253 246 246 246
45125 -231 231 231 206 206 206 198 198 198 226 226 226
45126 - 94 94 94 2 2 6 6 6 6 38 38 38
45127 - 30 30 30 2 2 6 2 2 6 2 2 6
45128 - 2 2 6 2 2 6 62 62 62 66 66 66
45129 - 26 26 26 10 10 10 0 0 0 0 0 0
45130 - 0 0 0 0 0 0 0 0 0 0 0 0
45131 - 0 0 0 0 0 0 0 0 0 0 0 0
45132 - 0 0 0 0 0 0 0 0 0 0 0 0
45133 - 0 0 0 0 0 0 0 0 0 0 0 0
45134 - 0 0 0 0 0 0 0 0 0 0 0 0
45135 - 0 0 0 0 0 0 0 0 0 0 0 0
45136 - 0 0 0 0 0 0 0 0 0 0 0 0
45137 - 0 0 0 0 0 0 0 0 0 10 10 10
45138 - 30 30 30 74 74 74 50 50 50 2 2 6
45139 - 26 26 26 26 26 26 2 2 6 106 106 106
45140 -238 238 238 253 253 253 253 253 253 253 253 253
45141 -253 253 253 253 253 253 253 253 253 253 253 253
45142 -253 253 253 253 253 253 253 253 253 253 253 253
45143 -253 253 253 253 253 253 253 253 253 253 253 253
45144 -253 253 253 253 253 253 253 253 253 253 253 253
45145 -253 253 253 246 246 246 218 218 218 202 202 202
45146 -210 210 210 14 14 14 2 2 6 2 2 6
45147 - 30 30 30 22 22 22 2 2 6 2 2 6
45148 - 2 2 6 2 2 6 18 18 18 86 86 86
45149 - 42 42 42 14 14 14 0 0 0 0 0 0
45150 - 0 0 0 0 0 0 0 0 0 0 0 0
45151 - 0 0 0 0 0 0 0 0 0 0 0 0
45152 - 0 0 0 0 0 0 0 0 0 0 0 0
45153 - 0 0 0 0 0 0 0 0 0 0 0 0
45154 - 0 0 0 0 0 0 0 0 0 0 0 0
45155 - 0 0 0 0 0 0 0 0 0 0 0 0
45156 - 0 0 0 0 0 0 0 0 0 0 0 0
45157 - 0 0 0 0 0 0 0 0 0 14 14 14
45158 - 42 42 42 90 90 90 22 22 22 2 2 6
45159 - 42 42 42 2 2 6 18 18 18 218 218 218
45160 -253 253 253 253 253 253 253 253 253 253 253 253
45161 -253 253 253 253 253 253 253 253 253 253 253 253
45162 -253 253 253 253 253 253 253 253 253 253 253 253
45163 -253 253 253 253 253 253 253 253 253 253 253 253
45164 -253 253 253 253 253 253 253 253 253 253 253 253
45165 -253 253 253 253 253 253 250 250 250 221 221 221
45166 -218 218 218 101 101 101 2 2 6 14 14 14
45167 - 18 18 18 38 38 38 10 10 10 2 2 6
45168 - 2 2 6 2 2 6 2 2 6 78 78 78
45169 - 58 58 58 22 22 22 6 6 6 0 0 0
45170 - 0 0 0 0 0 0 0 0 0 0 0 0
45171 - 0 0 0 0 0 0 0 0 0 0 0 0
45172 - 0 0 0 0 0 0 0 0 0 0 0 0
45173 - 0 0 0 0 0 0 0 0 0 0 0 0
45174 - 0 0 0 0 0 0 0 0 0 0 0 0
45175 - 0 0 0 0 0 0 0 0 0 0 0 0
45176 - 0 0 0 0 0 0 0 0 0 0 0 0
45177 - 0 0 0 0 0 0 6 6 6 18 18 18
45178 - 54 54 54 82 82 82 2 2 6 26 26 26
45179 - 22 22 22 2 2 6 123 123 123 253 253 253
45180 -253 253 253 253 253 253 253 253 253 253 253 253
45181 -253 253 253 253 253 253 253 253 253 253 253 253
45182 -253 253 253 253 253 253 253 253 253 253 253 253
45183 -253 253 253 253 253 253 253 253 253 253 253 253
45184 -253 253 253 253 253 253 253 253 253 253 253 253
45185 -253 253 253 253 253 253 253 253 253 250 250 250
45186 -238 238 238 198 198 198 6 6 6 38 38 38
45187 - 58 58 58 26 26 26 38 38 38 2 2 6
45188 - 2 2 6 2 2 6 2 2 6 46 46 46
45189 - 78 78 78 30 30 30 10 10 10 0 0 0
45190 - 0 0 0 0 0 0 0 0 0 0 0 0
45191 - 0 0 0 0 0 0 0 0 0 0 0 0
45192 - 0 0 0 0 0 0 0 0 0 0 0 0
45193 - 0 0 0 0 0 0 0 0 0 0 0 0
45194 - 0 0 0 0 0 0 0 0 0 0 0 0
45195 - 0 0 0 0 0 0 0 0 0 0 0 0
45196 - 0 0 0 0 0 0 0 0 0 0 0 0
45197 - 0 0 0 0 0 0 10 10 10 30 30 30
45198 - 74 74 74 58 58 58 2 2 6 42 42 42
45199 - 2 2 6 22 22 22 231 231 231 253 253 253
45200 -253 253 253 253 253 253 253 253 253 253 253 253
45201 -253 253 253 253 253 253 253 253 253 250 250 250
45202 -253 253 253 253 253 253 253 253 253 253 253 253
45203 -253 253 253 253 253 253 253 253 253 253 253 253
45204 -253 253 253 253 253 253 253 253 253 253 253 253
45205 -253 253 253 253 253 253 253 253 253 253 253 253
45206 -253 253 253 246 246 246 46 46 46 38 38 38
45207 - 42 42 42 14 14 14 38 38 38 14 14 14
45208 - 2 2 6 2 2 6 2 2 6 6 6 6
45209 - 86 86 86 46 46 46 14 14 14 0 0 0
45210 - 0 0 0 0 0 0 0 0 0 0 0 0
45211 - 0 0 0 0 0 0 0 0 0 0 0 0
45212 - 0 0 0 0 0 0 0 0 0 0 0 0
45213 - 0 0 0 0 0 0 0 0 0 0 0 0
45214 - 0 0 0 0 0 0 0 0 0 0 0 0
45215 - 0 0 0 0 0 0 0 0 0 0 0 0
45216 - 0 0 0 0 0 0 0 0 0 0 0 0
45217 - 0 0 0 6 6 6 14 14 14 42 42 42
45218 - 90 90 90 18 18 18 18 18 18 26 26 26
45219 - 2 2 6 116 116 116 253 253 253 253 253 253
45220 -253 253 253 253 253 253 253 253 253 253 253 253
45221 -253 253 253 253 253 253 250 250 250 238 238 238
45222 -253 253 253 253 253 253 253 253 253 253 253 253
45223 -253 253 253 253 253 253 253 253 253 253 253 253
45224 -253 253 253 253 253 253 253 253 253 253 253 253
45225 -253 253 253 253 253 253 253 253 253 253 253 253
45226 -253 253 253 253 253 253 94 94 94 6 6 6
45227 - 2 2 6 2 2 6 10 10 10 34 34 34
45228 - 2 2 6 2 2 6 2 2 6 2 2 6
45229 - 74 74 74 58 58 58 22 22 22 6 6 6
45230 - 0 0 0 0 0 0 0 0 0 0 0 0
45231 - 0 0 0 0 0 0 0 0 0 0 0 0
45232 - 0 0 0 0 0 0 0 0 0 0 0 0
45233 - 0 0 0 0 0 0 0 0 0 0 0 0
45234 - 0 0 0 0 0 0 0 0 0 0 0 0
45235 - 0 0 0 0 0 0 0 0 0 0 0 0
45236 - 0 0 0 0 0 0 0 0 0 0 0 0
45237 - 0 0 0 10 10 10 26 26 26 66 66 66
45238 - 82 82 82 2 2 6 38 38 38 6 6 6
45239 - 14 14 14 210 210 210 253 253 253 253 253 253
45240 -253 253 253 253 253 253 253 253 253 253 253 253
45241 -253 253 253 253 253 253 246 246 246 242 242 242
45242 -253 253 253 253 253 253 253 253 253 253 253 253
45243 -253 253 253 253 253 253 253 253 253 253 253 253
45244 -253 253 253 253 253 253 253 253 253 253 253 253
45245 -253 253 253 253 253 253 253 253 253 253 253 253
45246 -253 253 253 253 253 253 144 144 144 2 2 6
45247 - 2 2 6 2 2 6 2 2 6 46 46 46
45248 - 2 2 6 2 2 6 2 2 6 2 2 6
45249 - 42 42 42 74 74 74 30 30 30 10 10 10
45250 - 0 0 0 0 0 0 0 0 0 0 0 0
45251 - 0 0 0 0 0 0 0 0 0 0 0 0
45252 - 0 0 0 0 0 0 0 0 0 0 0 0
45253 - 0 0 0 0 0 0 0 0 0 0 0 0
45254 - 0 0 0 0 0 0 0 0 0 0 0 0
45255 - 0 0 0 0 0 0 0 0 0 0 0 0
45256 - 0 0 0 0 0 0 0 0 0 0 0 0
45257 - 6 6 6 14 14 14 42 42 42 90 90 90
45258 - 26 26 26 6 6 6 42 42 42 2 2 6
45259 - 74 74 74 250 250 250 253 253 253 253 253 253
45260 -253 253 253 253 253 253 253 253 253 253 253 253
45261 -253 253 253 253 253 253 242 242 242 242 242 242
45262 -253 253 253 253 253 253 253 253 253 253 253 253
45263 -253 253 253 253 253 253 253 253 253 253 253 253
45264 -253 253 253 253 253 253 253 253 253 253 253 253
45265 -253 253 253 253 253 253 253 253 253 253 253 253
45266 -253 253 253 253 253 253 182 182 182 2 2 6
45267 - 2 2 6 2 2 6 2 2 6 46 46 46
45268 - 2 2 6 2 2 6 2 2 6 2 2 6
45269 - 10 10 10 86 86 86 38 38 38 10 10 10
45270 - 0 0 0 0 0 0 0 0 0 0 0 0
45271 - 0 0 0 0 0 0 0 0 0 0 0 0
45272 - 0 0 0 0 0 0 0 0 0 0 0 0
45273 - 0 0 0 0 0 0 0 0 0 0 0 0
45274 - 0 0 0 0 0 0 0 0 0 0 0 0
45275 - 0 0 0 0 0 0 0 0 0 0 0 0
45276 - 0 0 0 0 0 0 0 0 0 0 0 0
45277 - 10 10 10 26 26 26 66 66 66 82 82 82
45278 - 2 2 6 22 22 22 18 18 18 2 2 6
45279 -149 149 149 253 253 253 253 253 253 253 253 253
45280 -253 253 253 253 253 253 253 253 253 253 253 253
45281 -253 253 253 253 253 253 234 234 234 242 242 242
45282 -253 253 253 253 253 253 253 253 253 253 253 253
45283 -253 253 253 253 253 253 253 253 253 253 253 253
45284 -253 253 253 253 253 253 253 253 253 253 253 253
45285 -253 253 253 253 253 253 253 253 253 253 253 253
45286 -253 253 253 253 253 253 206 206 206 2 2 6
45287 - 2 2 6 2 2 6 2 2 6 38 38 38
45288 - 2 2 6 2 2 6 2 2 6 2 2 6
45289 - 6 6 6 86 86 86 46 46 46 14 14 14
45290 - 0 0 0 0 0 0 0 0 0 0 0 0
45291 - 0 0 0 0 0 0 0 0 0 0 0 0
45292 - 0 0 0 0 0 0 0 0 0 0 0 0
45293 - 0 0 0 0 0 0 0 0 0 0 0 0
45294 - 0 0 0 0 0 0 0 0 0 0 0 0
45295 - 0 0 0 0 0 0 0 0 0 0 0 0
45296 - 0 0 0 0 0 0 0 0 0 6 6 6
45297 - 18 18 18 46 46 46 86 86 86 18 18 18
45298 - 2 2 6 34 34 34 10 10 10 6 6 6
45299 -210 210 210 253 253 253 253 253 253 253 253 253
45300 -253 253 253 253 253 253 253 253 253 253 253 253
45301 -253 253 253 253 253 253 234 234 234 242 242 242
45302 -253 253 253 253 253 253 253 253 253 253 253 253
45303 -253 253 253 253 253 253 253 253 253 253 253 253
45304 -253 253 253 253 253 253 253 253 253 253 253 253
45305 -253 253 253 253 253 253 253 253 253 253 253 253
45306 -253 253 253 253 253 253 221 221 221 6 6 6
45307 - 2 2 6 2 2 6 6 6 6 30 30 30
45308 - 2 2 6 2 2 6 2 2 6 2 2 6
45309 - 2 2 6 82 82 82 54 54 54 18 18 18
45310 - 6 6 6 0 0 0 0 0 0 0 0 0
45311 - 0 0 0 0 0 0 0 0 0 0 0 0
45312 - 0 0 0 0 0 0 0 0 0 0 0 0
45313 - 0 0 0 0 0 0 0 0 0 0 0 0
45314 - 0 0 0 0 0 0 0 0 0 0 0 0
45315 - 0 0 0 0 0 0 0 0 0 0 0 0
45316 - 0 0 0 0 0 0 0 0 0 10 10 10
45317 - 26 26 26 66 66 66 62 62 62 2 2 6
45318 - 2 2 6 38 38 38 10 10 10 26 26 26
45319 -238 238 238 253 253 253 253 253 253 253 253 253
45320 -253 253 253 253 253 253 253 253 253 253 253 253
45321 -253 253 253 253 253 253 231 231 231 238 238 238
45322 -253 253 253 253 253 253 253 253 253 253 253 253
45323 -253 253 253 253 253 253 253 253 253 253 253 253
45324 -253 253 253 253 253 253 253 253 253 253 253 253
45325 -253 253 253 253 253 253 253 253 253 253 253 253
45326 -253 253 253 253 253 253 231 231 231 6 6 6
45327 - 2 2 6 2 2 6 10 10 10 30 30 30
45328 - 2 2 6 2 2 6 2 2 6 2 2 6
45329 - 2 2 6 66 66 66 58 58 58 22 22 22
45330 - 6 6 6 0 0 0 0 0 0 0 0 0
45331 - 0 0 0 0 0 0 0 0 0 0 0 0
45332 - 0 0 0 0 0 0 0 0 0 0 0 0
45333 - 0 0 0 0 0 0 0 0 0 0 0 0
45334 - 0 0 0 0 0 0 0 0 0 0 0 0
45335 - 0 0 0 0 0 0 0 0 0 0 0 0
45336 - 0 0 0 0 0 0 0 0 0 10 10 10
45337 - 38 38 38 78 78 78 6 6 6 2 2 6
45338 - 2 2 6 46 46 46 14 14 14 42 42 42
45339 -246 246 246 253 253 253 253 253 253 253 253 253
45340 -253 253 253 253 253 253 253 253 253 253 253 253
45341 -253 253 253 253 253 253 231 231 231 242 242 242
45342 -253 253 253 253 253 253 253 253 253 253 253 253
45343 -253 253 253 253 253 253 253 253 253 253 253 253
45344 -253 253 253 253 253 253 253 253 253 253 253 253
45345 -253 253 253 253 253 253 253 253 253 253 253 253
45346 -253 253 253 253 253 253 234 234 234 10 10 10
45347 - 2 2 6 2 2 6 22 22 22 14 14 14
45348 - 2 2 6 2 2 6 2 2 6 2 2 6
45349 - 2 2 6 66 66 66 62 62 62 22 22 22
45350 - 6 6 6 0 0 0 0 0 0 0 0 0
45351 - 0 0 0 0 0 0 0 0 0 0 0 0
45352 - 0 0 0 0 0 0 0 0 0 0 0 0
45353 - 0 0 0 0 0 0 0 0 0 0 0 0
45354 - 0 0 0 0 0 0 0 0 0 0 0 0
45355 - 0 0 0 0 0 0 0 0 0 0 0 0
45356 - 0 0 0 0 0 0 6 6 6 18 18 18
45357 - 50 50 50 74 74 74 2 2 6 2 2 6
45358 - 14 14 14 70 70 70 34 34 34 62 62 62
45359 -250 250 250 253 253 253 253 253 253 253 253 253
45360 -253 253 253 253 253 253 253 253 253 253 253 253
45361 -253 253 253 253 253 253 231 231 231 246 246 246
45362 -253 253 253 253 253 253 253 253 253 253 253 253
45363 -253 253 253 253 253 253 253 253 253 253 253 253
45364 -253 253 253 253 253 253 253 253 253 253 253 253
45365 -253 253 253 253 253 253 253 253 253 253 253 253
45366 -253 253 253 253 253 253 234 234 234 14 14 14
45367 - 2 2 6 2 2 6 30 30 30 2 2 6
45368 - 2 2 6 2 2 6 2 2 6 2 2 6
45369 - 2 2 6 66 66 66 62 62 62 22 22 22
45370 - 6 6 6 0 0 0 0 0 0 0 0 0
45371 - 0 0 0 0 0 0 0 0 0 0 0 0
45372 - 0 0 0 0 0 0 0 0 0 0 0 0
45373 - 0 0 0 0 0 0 0 0 0 0 0 0
45374 - 0 0 0 0 0 0 0 0 0 0 0 0
45375 - 0 0 0 0 0 0 0 0 0 0 0 0
45376 - 0 0 0 0 0 0 6 6 6 18 18 18
45377 - 54 54 54 62 62 62 2 2 6 2 2 6
45378 - 2 2 6 30 30 30 46 46 46 70 70 70
45379 -250 250 250 253 253 253 253 253 253 253 253 253
45380 -253 253 253 253 253 253 253 253 253 253 253 253
45381 -253 253 253 253 253 253 231 231 231 246 246 246
45382 -253 253 253 253 253 253 253 253 253 253 253 253
45383 -253 253 253 253 253 253 253 253 253 253 253 253
45384 -253 253 253 253 253 253 253 253 253 253 253 253
45385 -253 253 253 253 253 253 253 253 253 253 253 253
45386 -253 253 253 253 253 253 226 226 226 10 10 10
45387 - 2 2 6 6 6 6 30 30 30 2 2 6
45388 - 2 2 6 2 2 6 2 2 6 2 2 6
45389 - 2 2 6 66 66 66 58 58 58 22 22 22
45390 - 6 6 6 0 0 0 0 0 0 0 0 0
45391 - 0 0 0 0 0 0 0 0 0 0 0 0
45392 - 0 0 0 0 0 0 0 0 0 0 0 0
45393 - 0 0 0 0 0 0 0 0 0 0 0 0
45394 - 0 0 0 0 0 0 0 0 0 0 0 0
45395 - 0 0 0 0 0 0 0 0 0 0 0 0
45396 - 0 0 0 0 0 0 6 6 6 22 22 22
45397 - 58 58 58 62 62 62 2 2 6 2 2 6
45398 - 2 2 6 2 2 6 30 30 30 78 78 78
45399 -250 250 250 253 253 253 253 253 253 253 253 253
45400 -253 253 253 253 253 253 253 253 253 253 253 253
45401 -253 253 253 253 253 253 231 231 231 246 246 246
45402 -253 253 253 253 253 253 253 253 253 253 253 253
45403 -253 253 253 253 253 253 253 253 253 253 253 253
45404 -253 253 253 253 253 253 253 253 253 253 253 253
45405 -253 253 253 253 253 253 253 253 253 253 253 253
45406 -253 253 253 253 253 253 206 206 206 2 2 6
45407 - 22 22 22 34 34 34 18 14 6 22 22 22
45408 - 26 26 26 18 18 18 6 6 6 2 2 6
45409 - 2 2 6 82 82 82 54 54 54 18 18 18
45410 - 6 6 6 0 0 0 0 0 0 0 0 0
45411 - 0 0 0 0 0 0 0 0 0 0 0 0
45412 - 0 0 0 0 0 0 0 0 0 0 0 0
45413 - 0 0 0 0 0 0 0 0 0 0 0 0
45414 - 0 0 0 0 0 0 0 0 0 0 0 0
45415 - 0 0 0 0 0 0 0 0 0 0 0 0
45416 - 0 0 0 0 0 0 6 6 6 26 26 26
45417 - 62 62 62 106 106 106 74 54 14 185 133 11
45418 -210 162 10 121 92 8 6 6 6 62 62 62
45419 -238 238 238 253 253 253 253 253 253 253 253 253
45420 -253 253 253 253 253 253 253 253 253 253 253 253
45421 -253 253 253 253 253 253 231 231 231 246 246 246
45422 -253 253 253 253 253 253 253 253 253 253 253 253
45423 -253 253 253 253 253 253 253 253 253 253 253 253
45424 -253 253 253 253 253 253 253 253 253 253 253 253
45425 -253 253 253 253 253 253 253 253 253 253 253 253
45426 -253 253 253 253 253 253 158 158 158 18 18 18
45427 - 14 14 14 2 2 6 2 2 6 2 2 6
45428 - 6 6 6 18 18 18 66 66 66 38 38 38
45429 - 6 6 6 94 94 94 50 50 50 18 18 18
45430 - 6 6 6 0 0 0 0 0 0 0 0 0
45431 - 0 0 0 0 0 0 0 0 0 0 0 0
45432 - 0 0 0 0 0 0 0 0 0 0 0 0
45433 - 0 0 0 0 0 0 0 0 0 0 0 0
45434 - 0 0 0 0 0 0 0 0 0 0 0 0
45435 - 0 0 0 0 0 0 0 0 0 6 6 6
45436 - 10 10 10 10 10 10 18 18 18 38 38 38
45437 - 78 78 78 142 134 106 216 158 10 242 186 14
45438 -246 190 14 246 190 14 156 118 10 10 10 10
45439 - 90 90 90 238 238 238 253 253 253 253 253 253
45440 -253 253 253 253 253 253 253 253 253 253 253 253
45441 -253 253 253 253 253 253 231 231 231 250 250 250
45442 -253 253 253 253 253 253 253 253 253 253 253 253
45443 -253 253 253 253 253 253 253 253 253 253 253 253
45444 -253 253 253 253 253 253 253 253 253 253 253 253
45445 -253 253 253 253 253 253 253 253 253 246 230 190
45446 -238 204 91 238 204 91 181 142 44 37 26 9
45447 - 2 2 6 2 2 6 2 2 6 2 2 6
45448 - 2 2 6 2 2 6 38 38 38 46 46 46
45449 - 26 26 26 106 106 106 54 54 54 18 18 18
45450 - 6 6 6 0 0 0 0 0 0 0 0 0
45451 - 0 0 0 0 0 0 0 0 0 0 0 0
45452 - 0 0 0 0 0 0 0 0 0 0 0 0
45453 - 0 0 0 0 0 0 0 0 0 0 0 0
45454 - 0 0 0 0 0 0 0 0 0 0 0 0
45455 - 0 0 0 6 6 6 14 14 14 22 22 22
45456 - 30 30 30 38 38 38 50 50 50 70 70 70
45457 -106 106 106 190 142 34 226 170 11 242 186 14
45458 -246 190 14 246 190 14 246 190 14 154 114 10
45459 - 6 6 6 74 74 74 226 226 226 253 253 253
45460 -253 253 253 253 253 253 253 253 253 253 253 253
45461 -253 253 253 253 253 253 231 231 231 250 250 250
45462 -253 253 253 253 253 253 253 253 253 253 253 253
45463 -253 253 253 253 253 253 253 253 253 253 253 253
45464 -253 253 253 253 253 253 253 253 253 253 253 253
45465 -253 253 253 253 253 253 253 253 253 228 184 62
45466 -241 196 14 241 208 19 232 195 16 38 30 10
45467 - 2 2 6 2 2 6 2 2 6 2 2 6
45468 - 2 2 6 6 6 6 30 30 30 26 26 26
45469 -203 166 17 154 142 90 66 66 66 26 26 26
45470 - 6 6 6 0 0 0 0 0 0 0 0 0
45471 - 0 0 0 0 0 0 0 0 0 0 0 0
45472 - 0 0 0 0 0 0 0 0 0 0 0 0
45473 - 0 0 0 0 0 0 0 0 0 0 0 0
45474 - 0 0 0 0 0 0 0 0 0 0 0 0
45475 - 6 6 6 18 18 18 38 38 38 58 58 58
45476 - 78 78 78 86 86 86 101 101 101 123 123 123
45477 -175 146 61 210 150 10 234 174 13 246 186 14
45478 -246 190 14 246 190 14 246 190 14 238 190 10
45479 -102 78 10 2 2 6 46 46 46 198 198 198
45480 -253 253 253 253 253 253 253 253 253 253 253 253
45481 -253 253 253 253 253 253 234 234 234 242 242 242
45482 -253 253 253 253 253 253 253 253 253 253 253 253
45483 -253 253 253 253 253 253 253 253 253 253 253 253
45484 -253 253 253 253 253 253 253 253 253 253 253 253
45485 -253 253 253 253 253 253 253 253 253 224 178 62
45486 -242 186 14 241 196 14 210 166 10 22 18 6
45487 - 2 2 6 2 2 6 2 2 6 2 2 6
45488 - 2 2 6 2 2 6 6 6 6 121 92 8
45489 -238 202 15 232 195 16 82 82 82 34 34 34
45490 - 10 10 10 0 0 0 0 0 0 0 0 0
45491 - 0 0 0 0 0 0 0 0 0 0 0 0
45492 - 0 0 0 0 0 0 0 0 0 0 0 0
45493 - 0 0 0 0 0 0 0 0 0 0 0 0
45494 - 0 0 0 0 0 0 0 0 0 0 0 0
45495 - 14 14 14 38 38 38 70 70 70 154 122 46
45496 -190 142 34 200 144 11 197 138 11 197 138 11
45497 -213 154 11 226 170 11 242 186 14 246 190 14
45498 -246 190 14 246 190 14 246 190 14 246 190 14
45499 -225 175 15 46 32 6 2 2 6 22 22 22
45500 -158 158 158 250 250 250 253 253 253 253 253 253
45501 -253 253 253 253 253 253 253 253 253 253 253 253
45502 -253 253 253 253 253 253 253 253 253 253 253 253
45503 -253 253 253 253 253 253 253 253 253 253 253 253
45504 -253 253 253 253 253 253 253 253 253 253 253 253
45505 -253 253 253 250 250 250 242 242 242 224 178 62
45506 -239 182 13 236 186 11 213 154 11 46 32 6
45507 - 2 2 6 2 2 6 2 2 6 2 2 6
45508 - 2 2 6 2 2 6 61 42 6 225 175 15
45509 -238 190 10 236 186 11 112 100 78 42 42 42
45510 - 14 14 14 0 0 0 0 0 0 0 0 0
45511 - 0 0 0 0 0 0 0 0 0 0 0 0
45512 - 0 0 0 0 0 0 0 0 0 0 0 0
45513 - 0 0 0 0 0 0 0 0 0 0 0 0
45514 - 0 0 0 0 0 0 0 0 0 6 6 6
45515 - 22 22 22 54 54 54 154 122 46 213 154 11
45516 -226 170 11 230 174 11 226 170 11 226 170 11
45517 -236 178 12 242 186 14 246 190 14 246 190 14
45518 -246 190 14 246 190 14 246 190 14 246 190 14
45519 -241 196 14 184 144 12 10 10 10 2 2 6
45520 - 6 6 6 116 116 116 242 242 242 253 253 253
45521 -253 253 253 253 253 253 253 253 253 253 253 253
45522 -253 253 253 253 253 253 253 253 253 253 253 253
45523 -253 253 253 253 253 253 253 253 253 253 253 253
45524 -253 253 253 253 253 253 253 253 253 253 253 253
45525 -253 253 253 231 231 231 198 198 198 214 170 54
45526 -236 178 12 236 178 12 210 150 10 137 92 6
45527 - 18 14 6 2 2 6 2 2 6 2 2 6
45528 - 6 6 6 70 47 6 200 144 11 236 178 12
45529 -239 182 13 239 182 13 124 112 88 58 58 58
45530 - 22 22 22 6 6 6 0 0 0 0 0 0
45531 - 0 0 0 0 0 0 0 0 0 0 0 0
45532 - 0 0 0 0 0 0 0 0 0 0 0 0
45533 - 0 0 0 0 0 0 0 0 0 0 0 0
45534 - 0 0 0 0 0 0 0 0 0 10 10 10
45535 - 30 30 30 70 70 70 180 133 36 226 170 11
45536 -239 182 13 242 186 14 242 186 14 246 186 14
45537 -246 190 14 246 190 14 246 190 14 246 190 14
45538 -246 190 14 246 190 14 246 190 14 246 190 14
45539 -246 190 14 232 195 16 98 70 6 2 2 6
45540 - 2 2 6 2 2 6 66 66 66 221 221 221
45541 -253 253 253 253 253 253 253 253 253 253 253 253
45542 -253 253 253 253 253 253 253 253 253 253 253 253
45543 -253 253 253 253 253 253 253 253 253 253 253 253
45544 -253 253 253 253 253 253 253 253 253 253 253 253
45545 -253 253 253 206 206 206 198 198 198 214 166 58
45546 -230 174 11 230 174 11 216 158 10 192 133 9
45547 -163 110 8 116 81 8 102 78 10 116 81 8
45548 -167 114 7 197 138 11 226 170 11 239 182 13
45549 -242 186 14 242 186 14 162 146 94 78 78 78
45550 - 34 34 34 14 14 14 6 6 6 0 0 0
45551 - 0 0 0 0 0 0 0 0 0 0 0 0
45552 - 0 0 0 0 0 0 0 0 0 0 0 0
45553 - 0 0 0 0 0 0 0 0 0 0 0 0
45554 - 0 0 0 0 0 0 0 0 0 6 6 6
45555 - 30 30 30 78 78 78 190 142 34 226 170 11
45556 -239 182 13 246 190 14 246 190 14 246 190 14
45557 -246 190 14 246 190 14 246 190 14 246 190 14
45558 -246 190 14 246 190 14 246 190 14 246 190 14
45559 -246 190 14 241 196 14 203 166 17 22 18 6
45560 - 2 2 6 2 2 6 2 2 6 38 38 38
45561 -218 218 218 253 253 253 253 253 253 253 253 253
45562 -253 253 253 253 253 253 253 253 253 253 253 253
45563 -253 253 253 253 253 253 253 253 253 253 253 253
45564 -253 253 253 253 253 253 253 253 253 253 253 253
45565 -250 250 250 206 206 206 198 198 198 202 162 69
45566 -226 170 11 236 178 12 224 166 10 210 150 10
45567 -200 144 11 197 138 11 192 133 9 197 138 11
45568 -210 150 10 226 170 11 242 186 14 246 190 14
45569 -246 190 14 246 186 14 225 175 15 124 112 88
45570 - 62 62 62 30 30 30 14 14 14 6 6 6
45571 - 0 0 0 0 0 0 0 0 0 0 0 0
45572 - 0 0 0 0 0 0 0 0 0 0 0 0
45573 - 0 0 0 0 0 0 0 0 0 0 0 0
45574 - 0 0 0 0 0 0 0 0 0 10 10 10
45575 - 30 30 30 78 78 78 174 135 50 224 166 10
45576 -239 182 13 246 190 14 246 190 14 246 190 14
45577 -246 190 14 246 190 14 246 190 14 246 190 14
45578 -246 190 14 246 190 14 246 190 14 246 190 14
45579 -246 190 14 246 190 14 241 196 14 139 102 15
45580 - 2 2 6 2 2 6 2 2 6 2 2 6
45581 - 78 78 78 250 250 250 253 253 253 253 253 253
45582 -253 253 253 253 253 253 253 253 253 253 253 253
45583 -253 253 253 253 253 253 253 253 253 253 253 253
45584 -253 253 253 253 253 253 253 253 253 253 253 253
45585 -250 250 250 214 214 214 198 198 198 190 150 46
45586 -219 162 10 236 178 12 234 174 13 224 166 10
45587 -216 158 10 213 154 11 213 154 11 216 158 10
45588 -226 170 11 239 182 13 246 190 14 246 190 14
45589 -246 190 14 246 190 14 242 186 14 206 162 42
45590 -101 101 101 58 58 58 30 30 30 14 14 14
45591 - 6 6 6 0 0 0 0 0 0 0 0 0
45592 - 0 0 0 0 0 0 0 0 0 0 0 0
45593 - 0 0 0 0 0 0 0 0 0 0 0 0
45594 - 0 0 0 0 0 0 0 0 0 10 10 10
45595 - 30 30 30 74 74 74 174 135 50 216 158 10
45596 -236 178 12 246 190 14 246 190 14 246 190 14
45597 -246 190 14 246 190 14 246 190 14 246 190 14
45598 -246 190 14 246 190 14 246 190 14 246 190 14
45599 -246 190 14 246 190 14 241 196 14 226 184 13
45600 - 61 42 6 2 2 6 2 2 6 2 2 6
45601 - 22 22 22 238 238 238 253 253 253 253 253 253
45602 -253 253 253 253 253 253 253 253 253 253 253 253
45603 -253 253 253 253 253 253 253 253 253 253 253 253
45604 -253 253 253 253 253 253 253 253 253 253 253 253
45605 -253 253 253 226 226 226 187 187 187 180 133 36
45606 -216 158 10 236 178 12 239 182 13 236 178 12
45607 -230 174 11 226 170 11 226 170 11 230 174 11
45608 -236 178 12 242 186 14 246 190 14 246 190 14
45609 -246 190 14 246 190 14 246 186 14 239 182 13
45610 -206 162 42 106 106 106 66 66 66 34 34 34
45611 - 14 14 14 6 6 6 0 0 0 0 0 0
45612 - 0 0 0 0 0 0 0 0 0 0 0 0
45613 - 0 0 0 0 0 0 0 0 0 0 0 0
45614 - 0 0 0 0 0 0 0 0 0 6 6 6
45615 - 26 26 26 70 70 70 163 133 67 213 154 11
45616 -236 178 12 246 190 14 246 190 14 246 190 14
45617 -246 190 14 246 190 14 246 190 14 246 190 14
45618 -246 190 14 246 190 14 246 190 14 246 190 14
45619 -246 190 14 246 190 14 246 190 14 241 196 14
45620 -190 146 13 18 14 6 2 2 6 2 2 6
45621 - 46 46 46 246 246 246 253 253 253 253 253 253
45622 -253 253 253 253 253 253 253 253 253 253 253 253
45623 -253 253 253 253 253 253 253 253 253 253 253 253
45624 -253 253 253 253 253 253 253 253 253 253 253 253
45625 -253 253 253 221 221 221 86 86 86 156 107 11
45626 -216 158 10 236 178 12 242 186 14 246 186 14
45627 -242 186 14 239 182 13 239 182 13 242 186 14
45628 -242 186 14 246 186 14 246 190 14 246 190 14
45629 -246 190 14 246 190 14 246 190 14 246 190 14
45630 -242 186 14 225 175 15 142 122 72 66 66 66
45631 - 30 30 30 10 10 10 0 0 0 0 0 0
45632 - 0 0 0 0 0 0 0 0 0 0 0 0
45633 - 0 0 0 0 0 0 0 0 0 0 0 0
45634 - 0 0 0 0 0 0 0 0 0 6 6 6
45635 - 26 26 26 70 70 70 163 133 67 210 150 10
45636 -236 178 12 246 190 14 246 190 14 246 190 14
45637 -246 190 14 246 190 14 246 190 14 246 190 14
45638 -246 190 14 246 190 14 246 190 14 246 190 14
45639 -246 190 14 246 190 14 246 190 14 246 190 14
45640 -232 195 16 121 92 8 34 34 34 106 106 106
45641 -221 221 221 253 253 253 253 253 253 253 253 253
45642 -253 253 253 253 253 253 253 253 253 253 253 253
45643 -253 253 253 253 253 253 253 253 253 253 253 253
45644 -253 253 253 253 253 253 253 253 253 253 253 253
45645 -242 242 242 82 82 82 18 14 6 163 110 8
45646 -216 158 10 236 178 12 242 186 14 246 190 14
45647 -246 190 14 246 190 14 246 190 14 246 190 14
45648 -246 190 14 246 190 14 246 190 14 246 190 14
45649 -246 190 14 246 190 14 246 190 14 246 190 14
45650 -246 190 14 246 190 14 242 186 14 163 133 67
45651 - 46 46 46 18 18 18 6 6 6 0 0 0
45652 - 0 0 0 0 0 0 0 0 0 0 0 0
45653 - 0 0 0 0 0 0 0 0 0 0 0 0
45654 - 0 0 0 0 0 0 0 0 0 10 10 10
45655 - 30 30 30 78 78 78 163 133 67 210 150 10
45656 -236 178 12 246 186 14 246 190 14 246 190 14
45657 -246 190 14 246 190 14 246 190 14 246 190 14
45658 -246 190 14 246 190 14 246 190 14 246 190 14
45659 -246 190 14 246 190 14 246 190 14 246 190 14
45660 -241 196 14 215 174 15 190 178 144 253 253 253
45661 -253 253 253 253 253 253 253 253 253 253 253 253
45662 -253 253 253 253 253 253 253 253 253 253 253 253
45663 -253 253 253 253 253 253 253 253 253 253 253 253
45664 -253 253 253 253 253 253 253 253 253 218 218 218
45665 - 58 58 58 2 2 6 22 18 6 167 114 7
45666 -216 158 10 236 178 12 246 186 14 246 190 14
45667 -246 190 14 246 190 14 246 190 14 246 190 14
45668 -246 190 14 246 190 14 246 190 14 246 190 14
45669 -246 190 14 246 190 14 246 190 14 246 190 14
45670 -246 190 14 246 186 14 242 186 14 190 150 46
45671 - 54 54 54 22 22 22 6 6 6 0 0 0
45672 - 0 0 0 0 0 0 0 0 0 0 0 0
45673 - 0 0 0 0 0 0 0 0 0 0 0 0
45674 - 0 0 0 0 0 0 0 0 0 14 14 14
45675 - 38 38 38 86 86 86 180 133 36 213 154 11
45676 -236 178 12 246 186 14 246 190 14 246 190 14
45677 -246 190 14 246 190 14 246 190 14 246 190 14
45678 -246 190 14 246 190 14 246 190 14 246 190 14
45679 -246 190 14 246 190 14 246 190 14 246 190 14
45680 -246 190 14 232 195 16 190 146 13 214 214 214
45681 -253 253 253 253 253 253 253 253 253 253 253 253
45682 -253 253 253 253 253 253 253 253 253 253 253 253
45683 -253 253 253 253 253 253 253 253 253 253 253 253
45684 -253 253 253 250 250 250 170 170 170 26 26 26
45685 - 2 2 6 2 2 6 37 26 9 163 110 8
45686 -219 162 10 239 182 13 246 186 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 246 190 14
45689 -246 190 14 246 190 14 246 190 14 246 190 14
45690 -246 186 14 236 178 12 224 166 10 142 122 72
45691 - 46 46 46 18 18 18 6 6 6 0 0 0
45692 - 0 0 0 0 0 0 0 0 0 0 0 0
45693 - 0 0 0 0 0 0 0 0 0 0 0 0
45694 - 0 0 0 0 0 0 6 6 6 18 18 18
45695 - 50 50 50 109 106 95 192 133 9 224 166 10
45696 -242 186 14 246 190 14 246 190 14 246 190 14
45697 -246 190 14 246 190 14 246 190 14 246 190 14
45698 -246 190 14 246 190 14 246 190 14 246 190 14
45699 -246 190 14 246 190 14 246 190 14 246 190 14
45700 -242 186 14 226 184 13 210 162 10 142 110 46
45701 -226 226 226 253 253 253 253 253 253 253 253 253
45702 -253 253 253 253 253 253 253 253 253 253 253 253
45703 -253 253 253 253 253 253 253 253 253 253 253 253
45704 -198 198 198 66 66 66 2 2 6 2 2 6
45705 - 2 2 6 2 2 6 50 34 6 156 107 11
45706 -219 162 10 239 182 13 246 186 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 -246 190 14 246 190 14 246 190 14 242 186 14
45710 -234 174 13 213 154 11 154 122 46 66 66 66
45711 - 30 30 30 10 10 10 0 0 0 0 0 0
45712 - 0 0 0 0 0 0 0 0 0 0 0 0
45713 - 0 0 0 0 0 0 0 0 0 0 0 0
45714 - 0 0 0 0 0 0 6 6 6 22 22 22
45715 - 58 58 58 154 121 60 206 145 10 234 174 13
45716 -242 186 14 246 186 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 246 190 14 246 190 14
45720 -246 186 14 236 178 12 210 162 10 163 110 8
45721 - 61 42 6 138 138 138 218 218 218 250 250 250
45722 -253 253 253 253 253 253 253 253 253 250 250 250
45723 -242 242 242 210 210 210 144 144 144 66 66 66
45724 - 6 6 6 2 2 6 2 2 6 2 2 6
45725 - 2 2 6 2 2 6 61 42 6 163 110 8
45726 -216 158 10 236 178 12 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 -246 190 14 239 182 13 230 174 11 216 158 10
45730 -190 142 34 124 112 88 70 70 70 38 38 38
45731 - 18 18 18 6 6 6 0 0 0 0 0 0
45732 - 0 0 0 0 0 0 0 0 0 0 0 0
45733 - 0 0 0 0 0 0 0 0 0 0 0 0
45734 - 0 0 0 0 0 0 6 6 6 22 22 22
45735 - 62 62 62 168 124 44 206 145 10 224 166 10
45736 -236 178 12 239 182 13 242 186 14 242 186 14
45737 -246 186 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 190 14 246 190 14 246 190 14
45740 -246 190 14 236 178 12 216 158 10 175 118 6
45741 - 80 54 7 2 2 6 6 6 6 30 30 30
45742 - 54 54 54 62 62 62 50 50 50 38 38 38
45743 - 14 14 14 2 2 6 2 2 6 2 2 6
45744 - 2 2 6 2 2 6 2 2 6 2 2 6
45745 - 2 2 6 6 6 6 80 54 7 167 114 7
45746 -213 154 11 236 178 12 246 190 14 246 190 14
45747 -246 190 14 246 190 14 246 190 14 246 190 14
45748 -246 190 14 242 186 14 239 182 13 239 182 13
45749 -230 174 11 210 150 10 174 135 50 124 112 88
45750 - 82 82 82 54 54 54 34 34 34 18 18 18
45751 - 6 6 6 0 0 0 0 0 0 0 0 0
45752 - 0 0 0 0 0 0 0 0 0 0 0 0
45753 - 0 0 0 0 0 0 0 0 0 0 0 0
45754 - 0 0 0 0 0 0 6 6 6 18 18 18
45755 - 50 50 50 158 118 36 192 133 9 200 144 11
45756 -216 158 10 219 162 10 224 166 10 226 170 11
45757 -230 174 11 236 178 12 239 182 13 239 182 13
45758 -242 186 14 246 186 14 246 190 14 246 190 14
45759 -246 190 14 246 190 14 246 190 14 246 190 14
45760 -246 186 14 230 174 11 210 150 10 163 110 8
45761 -104 69 6 10 10 10 2 2 6 2 2 6
45762 - 2 2 6 2 2 6 2 2 6 2 2 6
45763 - 2 2 6 2 2 6 2 2 6 2 2 6
45764 - 2 2 6 2 2 6 2 2 6 2 2 6
45765 - 2 2 6 6 6 6 91 60 6 167 114 7
45766 -206 145 10 230 174 11 242 186 14 246 190 14
45767 -246 190 14 246 190 14 246 186 14 242 186 14
45768 -239 182 13 230 174 11 224 166 10 213 154 11
45769 -180 133 36 124 112 88 86 86 86 58 58 58
45770 - 38 38 38 22 22 22 10 10 10 6 6 6
45771 - 0 0 0 0 0 0 0 0 0 0 0 0
45772 - 0 0 0 0 0 0 0 0 0 0 0 0
45773 - 0 0 0 0 0 0 0 0 0 0 0 0
45774 - 0 0 0 0 0 0 0 0 0 14 14 14
45775 - 34 34 34 70 70 70 138 110 50 158 118 36
45776 -167 114 7 180 123 7 192 133 9 197 138 11
45777 -200 144 11 206 145 10 213 154 11 219 162 10
45778 -224 166 10 230 174 11 239 182 13 242 186 14
45779 -246 186 14 246 186 14 246 186 14 246 186 14
45780 -239 182 13 216 158 10 185 133 11 152 99 6
45781 -104 69 6 18 14 6 2 2 6 2 2 6
45782 - 2 2 6 2 2 6 2 2 6 2 2 6
45783 - 2 2 6 2 2 6 2 2 6 2 2 6
45784 - 2 2 6 2 2 6 2 2 6 2 2 6
45785 - 2 2 6 6 6 6 80 54 7 152 99 6
45786 -192 133 9 219 162 10 236 178 12 239 182 13
45787 -246 186 14 242 186 14 239 182 13 236 178 12
45788 -224 166 10 206 145 10 192 133 9 154 121 60
45789 - 94 94 94 62 62 62 42 42 42 22 22 22
45790 - 14 14 14 6 6 6 0 0 0 0 0 0
45791 - 0 0 0 0 0 0 0 0 0 0 0 0
45792 - 0 0 0 0 0 0 0 0 0 0 0 0
45793 - 0 0 0 0 0 0 0 0 0 0 0 0
45794 - 0 0 0 0 0 0 0 0 0 6 6 6
45795 - 18 18 18 34 34 34 58 58 58 78 78 78
45796 -101 98 89 124 112 88 142 110 46 156 107 11
45797 -163 110 8 167 114 7 175 118 6 180 123 7
45798 -185 133 11 197 138 11 210 150 10 219 162 10
45799 -226 170 11 236 178 12 236 178 12 234 174 13
45800 -219 162 10 197 138 11 163 110 8 130 83 6
45801 - 91 60 6 10 10 10 2 2 6 2 2 6
45802 - 18 18 18 38 38 38 38 38 38 38 38 38
45803 - 38 38 38 38 38 38 38 38 38 38 38 38
45804 - 38 38 38 38 38 38 26 26 26 2 2 6
45805 - 2 2 6 6 6 6 70 47 6 137 92 6
45806 -175 118 6 200 144 11 219 162 10 230 174 11
45807 -234 174 13 230 174 11 219 162 10 210 150 10
45808 -192 133 9 163 110 8 124 112 88 82 82 82
45809 - 50 50 50 30 30 30 14 14 14 6 6 6
45810 - 0 0 0 0 0 0 0 0 0 0 0 0
45811 - 0 0 0 0 0 0 0 0 0 0 0 0
45812 - 0 0 0 0 0 0 0 0 0 0 0 0
45813 - 0 0 0 0 0 0 0 0 0 0 0 0
45814 - 0 0 0 0 0 0 0 0 0 0 0 0
45815 - 6 6 6 14 14 14 22 22 22 34 34 34
45816 - 42 42 42 58 58 58 74 74 74 86 86 86
45817 -101 98 89 122 102 70 130 98 46 121 87 25
45818 -137 92 6 152 99 6 163 110 8 180 123 7
45819 -185 133 11 197 138 11 206 145 10 200 144 11
45820 -180 123 7 156 107 11 130 83 6 104 69 6
45821 - 50 34 6 54 54 54 110 110 110 101 98 89
45822 - 86 86 86 82 82 82 78 78 78 78 78 78
45823 - 78 78 78 78 78 78 78 78 78 78 78 78
45824 - 78 78 78 82 82 82 86 86 86 94 94 94
45825 -106 106 106 101 101 101 86 66 34 124 80 6
45826 -156 107 11 180 123 7 192 133 9 200 144 11
45827 -206 145 10 200 144 11 192 133 9 175 118 6
45828 -139 102 15 109 106 95 70 70 70 42 42 42
45829 - 22 22 22 10 10 10 0 0 0 0 0 0
45830 - 0 0 0 0 0 0 0 0 0 0 0 0
45831 - 0 0 0 0 0 0 0 0 0 0 0 0
45832 - 0 0 0 0 0 0 0 0 0 0 0 0
45833 - 0 0 0 0 0 0 0 0 0 0 0 0
45834 - 0 0 0 0 0 0 0 0 0 0 0 0
45835 - 0 0 0 0 0 0 6 6 6 10 10 10
45836 - 14 14 14 22 22 22 30 30 30 38 38 38
45837 - 50 50 50 62 62 62 74 74 74 90 90 90
45838 -101 98 89 112 100 78 121 87 25 124 80 6
45839 -137 92 6 152 99 6 152 99 6 152 99 6
45840 -138 86 6 124 80 6 98 70 6 86 66 30
45841 -101 98 89 82 82 82 58 58 58 46 46 46
45842 - 38 38 38 34 34 34 34 34 34 34 34 34
45843 - 34 34 34 34 34 34 34 34 34 34 34 34
45844 - 34 34 34 34 34 34 38 38 38 42 42 42
45845 - 54 54 54 82 82 82 94 86 76 91 60 6
45846 -134 86 6 156 107 11 167 114 7 175 118 6
45847 -175 118 6 167 114 7 152 99 6 121 87 25
45848 -101 98 89 62 62 62 34 34 34 18 18 18
45849 - 6 6 6 0 0 0 0 0 0 0 0 0
45850 - 0 0 0 0 0 0 0 0 0 0 0 0
45851 - 0 0 0 0 0 0 0 0 0 0 0 0
45852 - 0 0 0 0 0 0 0 0 0 0 0 0
45853 - 0 0 0 0 0 0 0 0 0 0 0 0
45854 - 0 0 0 0 0 0 0 0 0 0 0 0
45855 - 0 0 0 0 0 0 0 0 0 0 0 0
45856 - 0 0 0 6 6 6 6 6 6 10 10 10
45857 - 18 18 18 22 22 22 30 30 30 42 42 42
45858 - 50 50 50 66 66 66 86 86 86 101 98 89
45859 -106 86 58 98 70 6 104 69 6 104 69 6
45860 -104 69 6 91 60 6 82 62 34 90 90 90
45861 - 62 62 62 38 38 38 22 22 22 14 14 14
45862 - 10 10 10 10 10 10 10 10 10 10 10 10
45863 - 10 10 10 10 10 10 6 6 6 10 10 10
45864 - 10 10 10 10 10 10 10 10 10 14 14 14
45865 - 22 22 22 42 42 42 70 70 70 89 81 66
45866 - 80 54 7 104 69 6 124 80 6 137 92 6
45867 -134 86 6 116 81 8 100 82 52 86 86 86
45868 - 58 58 58 30 30 30 14 14 14 6 6 6
45869 - 0 0 0 0 0 0 0 0 0 0 0 0
45870 - 0 0 0 0 0 0 0 0 0 0 0 0
45871 - 0 0 0 0 0 0 0 0 0 0 0 0
45872 - 0 0 0 0 0 0 0 0 0 0 0 0
45873 - 0 0 0 0 0 0 0 0 0 0 0 0
45874 - 0 0 0 0 0 0 0 0 0 0 0 0
45875 - 0 0 0 0 0 0 0 0 0 0 0 0
45876 - 0 0 0 0 0 0 0 0 0 0 0 0
45877 - 0 0 0 6 6 6 10 10 10 14 14 14
45878 - 18 18 18 26 26 26 38 38 38 54 54 54
45879 - 70 70 70 86 86 86 94 86 76 89 81 66
45880 - 89 81 66 86 86 86 74 74 74 50 50 50
45881 - 30 30 30 14 14 14 6 6 6 0 0 0
45882 - 0 0 0 0 0 0 0 0 0 0 0 0
45883 - 0 0 0 0 0 0 0 0 0 0 0 0
45884 - 0 0 0 0 0 0 0 0 0 0 0 0
45885 - 6 6 6 18 18 18 34 34 34 58 58 58
45886 - 82 82 82 89 81 66 89 81 66 89 81 66
45887 - 94 86 66 94 86 76 74 74 74 50 50 50
45888 - 26 26 26 14 14 14 6 6 6 0 0 0
45889 - 0 0 0 0 0 0 0 0 0 0 0 0
45890 - 0 0 0 0 0 0 0 0 0 0 0 0
45891 - 0 0 0 0 0 0 0 0 0 0 0 0
45892 - 0 0 0 0 0 0 0 0 0 0 0 0
45893 - 0 0 0 0 0 0 0 0 0 0 0 0
45894 - 0 0 0 0 0 0 0 0 0 0 0 0
45895 - 0 0 0 0 0 0 0 0 0 0 0 0
45896 - 0 0 0 0 0 0 0 0 0 0 0 0
45897 - 0 0 0 0 0 0 0 0 0 0 0 0
45898 - 6 6 6 6 6 6 14 14 14 18 18 18
45899 - 30 30 30 38 38 38 46 46 46 54 54 54
45900 - 50 50 50 42 42 42 30 30 30 18 18 18
45901 - 10 10 10 0 0 0 0 0 0 0 0 0
45902 - 0 0 0 0 0 0 0 0 0 0 0 0
45903 - 0 0 0 0 0 0 0 0 0 0 0 0
45904 - 0 0 0 0 0 0 0 0 0 0 0 0
45905 - 0 0 0 6 6 6 14 14 14 26 26 26
45906 - 38 38 38 50 50 50 58 58 58 58 58 58
45907 - 54 54 54 42 42 42 30 30 30 18 18 18
45908 - 10 10 10 0 0 0 0 0 0 0 0 0
45909 - 0 0 0 0 0 0 0 0 0 0 0 0
45910 - 0 0 0 0 0 0 0 0 0 0 0 0
45911 - 0 0 0 0 0 0 0 0 0 0 0 0
45912 - 0 0 0 0 0 0 0 0 0 0 0 0
45913 - 0 0 0 0 0 0 0 0 0 0 0 0
45914 - 0 0 0 0 0 0 0 0 0 0 0 0
45915 - 0 0 0 0 0 0 0 0 0 0 0 0
45916 - 0 0 0 0 0 0 0 0 0 0 0 0
45917 - 0 0 0 0 0 0 0 0 0 0 0 0
45918 - 0 0 0 0 0 0 0 0 0 6 6 6
45919 - 6 6 6 10 10 10 14 14 14 18 18 18
45920 - 18 18 18 14 14 14 10 10 10 6 6 6
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 0 0 0 0 0 0 6 6 6
45926 - 14 14 14 18 18 18 22 22 22 22 22 22
45927 - 18 18 18 14 14 14 10 10 10 6 6 6
45928 - 0 0 0 0 0 0 0 0 0 0 0 0
45929 - 0 0 0 0 0 0 0 0 0 0 0 0
45930 - 0 0 0 0 0 0 0 0 0 0 0 0
45931 - 0 0 0 0 0 0 0 0 0 0 0 0
45932 - 0 0 0 0 0 0 0 0 0 0 0 0
45933 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45934 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45935 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45936 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45937 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45938 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45939 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45940 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45941 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45942 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45943 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45944 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45945 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45946 +4 4 4 4 4 4
45947 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45948 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45949 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45950 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45951 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45952 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45953 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45954 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45955 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45956 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45957 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45958 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45959 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45960 +4 4 4 4 4 4
45961 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45962 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45963 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45964 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45965 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45966 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45967 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45968 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45969 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45970 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45971 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45972 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45973 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45974 +4 4 4 4 4 4
45975 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45976 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45977 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45978 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45979 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45980 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45981 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45982 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45983 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45984 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45985 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45986 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45987 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45988 +4 4 4 4 4 4
45989 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45990 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45991 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45992 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45993 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45994 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45995 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45996 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45997 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45998 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45999 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46000 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46001 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46002 +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 4 4 4 4 4 4 4 4 4 4 4 4
46016 +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 3 3 3 0 0 0 0 0 0
46022 +0 0 0 0 0 0 0 0 0 0 0 0 3 3 3 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 1 1 1 0 0 0
46027 +0 0 0 3 3 3 4 4 4 4 4 4 4 4 4 4 4 4
46028 +4 4 4 4 4 4 4 4 4 2 1 0 2 1 0 3 2 2
46029 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46030 +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 2 2 2 0 0 0 3 4 3 26 28 28
46036 +37 38 37 37 38 37 14 17 19 2 2 2 0 0 0 2 2 2
46037 +5 5 5 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 3 3 3 0 0 0 1 1 1 6 6 6
46041 +2 2 2 0 0 0 3 3 3 4 4 4 4 4 4 4 4 4
46042 +4 4 5 3 3 3 1 0 0 0 0 0 1 0 0 0 0 0
46043 +1 1 1 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46044 +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 +2 2 2 0 0 0 0 0 0 14 17 19 60 74 84 137 136 137
46050 +153 152 153 137 136 137 125 124 125 60 73 81 6 6 6 3 1 0
46051 +0 0 0 3 3 3 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 0 0 0 4 4 4 41 54 63 125 124 125
46055 +60 73 81 6 6 6 4 0 0 3 3 3 4 4 4 4 4 4
46056 +4 4 4 0 0 0 6 9 11 41 54 63 41 65 82 22 30 35
46057 +2 2 2 2 1 0 4 4 4 4 4 4 4 4 4 4 4 4
46058 +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 5 5 5 5 5 5 2 2 2 0 0 0
46063 +4 0 0 6 6 6 41 54 63 137 136 137 174 174 174 167 166 167
46064 +165 164 165 165 164 165 163 162 163 163 162 163 125 124 125 41 54 63
46065 +1 1 1 0 0 0 0 0 0 3 3 3 5 5 5 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 5 5 5 5 5 5
46068 +3 3 3 2 0 0 4 0 0 60 73 81 156 155 156 167 166 167
46069 +163 162 163 85 115 134 5 7 8 0 0 0 4 4 4 5 5 5
46070 +0 0 0 2 5 5 55 98 126 90 154 193 90 154 193 72 125 159
46071 +37 51 59 2 0 0 1 1 1 4 5 5 4 4 4 4 4 4
46072 +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 5 5 5 4 4 4 1 1 1 0 0 0 3 3 3
46077 +37 38 37 125 124 125 163 162 163 174 174 174 158 157 158 158 157 158
46078 +156 155 156 156 155 156 158 157 158 165 164 165 174 174 174 166 165 166
46079 +125 124 125 16 19 21 1 0 0 0 0 0 0 0 0 4 4 4
46080 +5 5 5 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
46081 +4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 1 1 1
46082 +0 0 0 0 0 0 37 38 37 153 152 153 174 174 174 158 157 158
46083 +174 174 174 163 162 163 37 38 37 4 3 3 4 0 0 1 1 1
46084 +0 0 0 22 40 52 101 161 196 101 161 196 90 154 193 101 161 196
46085 +64 123 161 14 17 19 0 0 0 4 4 4 4 4 4 4 4 4
46086 +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 5 5 5
46090 +5 5 5 2 2 2 0 0 0 4 0 0 24 26 27 85 115 134
46091 +156 155 156 174 174 174 167 166 167 156 155 156 154 153 154 157 156 157
46092 +156 155 156 156 155 156 155 154 155 153 152 153 158 157 158 167 166 167
46093 +174 174 174 156 155 156 60 74 84 16 19 21 0 0 0 0 0 0
46094 +1 1 1 5 5 5 5 5 5 4 4 4 4 4 4 4 4 4
46095 +4 4 4 5 5 5 6 6 6 3 3 3 0 0 0 4 0 0
46096 +13 16 17 60 73 81 137 136 137 165 164 165 156 155 156 153 152 153
46097 +174 174 174 177 184 187 60 73 81 3 1 0 0 0 0 1 1 2
46098 +22 30 35 64 123 161 136 185 209 90 154 193 90 154 193 90 154 193
46099 +90 154 193 21 29 34 0 0 0 3 2 2 4 4 5 4 4 4
46100 +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 5 5 5 3 3 3
46104 +0 0 0 0 0 0 10 13 16 60 74 84 157 156 157 174 174 174
46105 +174 174 174 158 157 158 153 152 153 154 153 154 156 155 156 155 154 155
46106 +156 155 156 155 154 155 154 153 154 157 156 157 154 153 154 153 152 153
46107 +163 162 163 174 174 174 177 184 187 137 136 137 60 73 81 13 16 17
46108 +4 0 0 0 0 0 3 3 3 5 5 5 4 4 4 4 4 4
46109 +5 5 5 4 4 4 1 1 1 0 0 0 3 3 3 41 54 63
46110 +131 129 131 174 174 174 174 174 174 174 174 174 167 166 167 174 174 174
46111 +190 197 201 137 136 137 24 26 27 4 0 0 16 21 25 50 82 103
46112 +90 154 193 136 185 209 90 154 193 101 161 196 101 161 196 101 161 196
46113 +31 91 132 3 6 7 0 0 0 4 4 4 4 4 4 4 4 4
46114 +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 2 2 2 0 0 0 4 0 0
46118 +4 0 0 43 57 68 137 136 137 177 184 187 174 174 174 163 162 163
46119 +155 154 155 155 154 155 156 155 156 155 154 155 158 157 158 165 164 165
46120 +167 166 167 166 165 166 163 162 163 157 156 157 155 154 155 155 154 155
46121 +153 152 153 156 155 156 167 166 167 174 174 174 174 174 174 131 129 131
46122 +41 54 63 5 5 5 0 0 0 0 0 0 3 3 3 4 4 4
46123 +1 1 1 0 0 0 1 0 0 26 28 28 125 124 125 174 174 174
46124 +177 184 187 174 174 174 174 174 174 156 155 156 131 129 131 137 136 137
46125 +125 124 125 24 26 27 4 0 0 41 65 82 90 154 193 136 185 209
46126 +136 185 209 101 161 196 53 118 160 37 112 160 90 154 193 34 86 122
46127 +7 12 15 0 0 0 4 4 4 4 4 4 4 4 4 4 4 4
46128 +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 3 3 3 0 0 0 0 0 0 5 5 5 37 38 37
46132 +125 124 125 167 166 167 174 174 174 167 166 167 158 157 158 155 154 155
46133 +156 155 156 156 155 156 156 155 156 163 162 163 167 166 167 155 154 155
46134 +137 136 137 153 152 153 156 155 156 165 164 165 163 162 163 156 155 156
46135 +156 155 156 156 155 156 155 154 155 158 157 158 166 165 166 174 174 174
46136 +167 166 167 125 124 125 37 38 37 1 0 0 0 0 0 0 0 0
46137 +0 0 0 24 26 27 60 74 84 158 157 158 174 174 174 174 174 174
46138 +166 165 166 158 157 158 125 124 125 41 54 63 13 16 17 6 6 6
46139 +6 6 6 37 38 37 80 127 157 136 185 209 101 161 196 101 161 196
46140 +90 154 193 28 67 93 6 10 14 13 20 25 13 20 25 6 10 14
46141 +1 1 2 4 3 3 4 4 4 4 4 4 4 4 4 4 4 4
46142 +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 +1 1 1 1 0 0 4 3 3 37 38 37 60 74 84 153 152 153
46146 +167 166 167 167 166 167 158 157 158 154 153 154 155 154 155 156 155 156
46147 +157 156 157 158 157 158 167 166 167 167 166 167 131 129 131 43 57 68
46148 +26 28 28 37 38 37 60 73 81 131 129 131 165 164 165 166 165 166
46149 +158 157 158 155 154 155 156 155 156 156 155 156 156 155 156 158 157 158
46150 +165 164 165 174 174 174 163 162 163 60 74 84 16 19 21 13 16 17
46151 +60 73 81 131 129 131 174 174 174 174 174 174 167 166 167 165 164 165
46152 +137 136 137 60 73 81 24 26 27 4 0 0 4 0 0 16 19 21
46153 +52 104 138 101 161 196 136 185 209 136 185 209 90 154 193 27 99 146
46154 +13 20 25 4 5 7 2 5 5 4 5 7 1 1 2 0 0 0
46155 +4 4 4 4 4 4 3 3 3 2 2 2 2 2 2 4 4 4
46156 +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 3 3 3 0 0 0
46159 +0 0 0 13 16 17 60 73 81 137 136 137 174 174 174 166 165 166
46160 +158 157 158 156 155 156 157 156 157 156 155 156 155 154 155 158 157 158
46161 +167 166 167 174 174 174 153 152 153 60 73 81 16 19 21 4 0 0
46162 +4 0 0 4 0 0 6 6 6 26 28 28 60 74 84 158 157 158
46163 +174 174 174 166 165 166 157 156 157 155 154 155 156 155 156 156 155 156
46164 +155 154 155 158 157 158 167 166 167 167 166 167 131 129 131 125 124 125
46165 +137 136 137 167 166 167 167 166 167 174 174 174 158 157 158 125 124 125
46166 +16 19 21 4 0 0 4 0 0 10 13 16 49 76 92 107 159 188
46167 +136 185 209 136 185 209 90 154 193 26 108 161 22 40 52 6 10 14
46168 +2 3 3 1 1 2 1 1 2 4 4 5 4 4 5 4 4 5
46169 +4 4 5 2 2 1 0 0 0 0 0 0 0 0 0 2 2 2
46170 +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 5 5 5 3 3 3 0 0 0 1 0 0 4 0 0
46173 +37 51 59 131 129 131 167 166 167 167 166 167 163 162 163 157 156 157
46174 +157 156 157 155 154 155 153 152 153 157 156 157 167 166 167 174 174 174
46175 +153 152 153 125 124 125 37 38 37 4 0 0 4 0 0 4 0 0
46176 +4 3 3 4 3 3 4 0 0 6 6 6 4 0 0 37 38 37
46177 +125 124 125 174 174 174 174 174 174 165 164 165 156 155 156 154 153 154
46178 +156 155 156 156 155 156 155 154 155 163 162 163 158 157 158 163 162 163
46179 +174 174 174 174 174 174 174 174 174 125 124 125 37 38 37 0 0 0
46180 +4 0 0 6 9 11 41 54 63 90 154 193 136 185 209 146 190 211
46181 +136 185 209 37 112 160 22 40 52 6 10 14 3 6 7 1 1 2
46182 +1 1 2 3 3 3 1 1 2 3 3 3 4 4 4 4 4 4
46183 +2 2 2 2 0 0 16 19 21 37 38 37 24 26 27 0 0 0
46184 +0 0 0 4 4 4
46185 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 5 5 5
46186 +4 4 4 0 0 0 0 0 0 0 0 0 26 28 28 120 125 127
46187 +158 157 158 174 174 174 165 164 165 157 156 157 155 154 155 156 155 156
46188 +153 152 153 153 152 153 167 166 167 174 174 174 174 174 174 125 124 125
46189 +37 38 37 4 0 0 0 0 0 4 0 0 4 3 3 4 4 4
46190 +4 4 4 4 4 4 5 5 5 4 0 0 4 0 0 4 0 0
46191 +4 3 3 43 57 68 137 136 137 174 174 174 174 174 174 165 164 165
46192 +154 153 154 153 152 153 153 152 153 153 152 153 163 162 163 174 174 174
46193 +174 174 174 153 152 153 60 73 81 6 6 6 4 0 0 4 3 3
46194 +32 43 50 80 127 157 136 185 209 146 190 211 146 190 211 90 154 193
46195 +28 67 93 28 67 93 40 71 93 3 6 7 1 1 2 2 5 5
46196 +50 82 103 79 117 143 26 37 45 0 0 0 3 3 3 1 1 1
46197 +0 0 0 41 54 63 137 136 137 174 174 174 153 152 153 60 73 81
46198 +2 0 0 0 0 0
46199 +4 4 4 4 4 4 4 4 4 4 4 4 6 6 6 2 2 2
46200 +0 0 0 2 0 0 24 26 27 60 74 84 153 152 153 174 174 174
46201 +174 174 174 157 156 157 154 153 154 156 155 156 154 153 154 153 152 153
46202 +165 164 165 174 174 174 177 184 187 137 136 137 43 57 68 6 6 6
46203 +4 0 0 2 0 0 3 3 3 5 5 5 5 5 5 4 4 4
46204 +4 4 4 4 4 4 4 4 4 5 5 5 6 6 6 4 3 3
46205 +4 0 0 4 0 0 24 26 27 60 73 81 153 152 153 174 174 174
46206 +174 174 174 158 157 158 158 157 158 174 174 174 174 174 174 158 157 158
46207 +60 74 84 24 26 27 4 0 0 4 0 0 17 23 27 59 113 148
46208 +136 185 209 191 222 234 146 190 211 136 185 209 31 91 132 7 11 13
46209 +22 40 52 101 161 196 90 154 193 6 9 11 3 4 4 43 95 132
46210 +136 185 209 172 205 220 55 98 126 0 0 0 0 0 0 2 0 0
46211 +26 28 28 153 152 153 177 184 187 167 166 167 177 184 187 165 164 165
46212 +37 38 37 0 0 0
46213 +4 4 4 4 4 4 5 5 5 5 5 5 1 1 1 0 0 0
46214 +13 16 17 60 73 81 137 136 137 174 174 174 174 174 174 165 164 165
46215 +153 152 153 153 152 153 155 154 155 154 153 154 158 157 158 174 174 174
46216 +177 184 187 163 162 163 60 73 81 16 19 21 4 0 0 4 0 0
46217 +4 3 3 4 4 4 5 5 5 5 5 5 4 4 4 5 5 5
46218 +5 5 5 5 5 5 5 5 5 4 4 4 4 4 4 5 5 5
46219 +6 6 6 4 0 0 4 0 0 4 0 0 24 26 27 60 74 84
46220 +166 165 166 174 174 174 177 184 187 165 164 165 125 124 125 24 26 27
46221 +4 0 0 4 0 0 5 5 5 50 82 103 136 185 209 172 205 220
46222 +146 190 211 136 185 209 26 108 161 22 40 52 7 12 15 44 81 103
46223 +71 116 144 28 67 93 37 51 59 41 65 82 100 139 164 101 161 196
46224 +90 154 193 90 154 193 28 67 93 0 0 0 0 0 0 26 28 28
46225 +125 124 125 167 166 167 163 162 163 153 152 153 163 162 163 174 174 174
46226 +85 115 134 4 0 0
46227 +4 4 4 5 5 5 4 4 4 1 0 0 4 0 0 34 47 55
46228 +125 124 125 174 174 174 174 174 174 167 166 167 157 156 157 153 152 153
46229 +155 154 155 155 154 155 158 157 158 166 165 166 167 166 167 154 153 154
46230 +125 124 125 26 28 28 4 0 0 4 0 0 4 0 0 5 5 5
46231 +5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 1 1 1
46232 +0 0 0 0 0 0 1 1 1 4 4 4 4 4 4 4 4 4
46233 +5 5 5 5 5 5 4 3 3 4 0 0 4 0 0 6 6 6
46234 +37 38 37 131 129 131 137 136 137 37 38 37 0 0 0 4 0 0
46235 +4 5 5 43 61 72 90 154 193 172 205 220 146 190 211 136 185 209
46236 +90 154 193 28 67 93 13 20 25 43 61 72 71 116 144 44 81 103
46237 +2 5 5 7 11 13 59 113 148 101 161 196 90 154 193 28 67 93
46238 +13 20 25 6 10 14 0 0 0 13 16 17 60 73 81 137 136 137
46239 +166 165 166 158 157 158 156 155 156 154 153 154 167 166 167 174 174 174
46240 +60 73 81 4 0 0
46241 +4 4 4 4 4 4 0 0 0 3 3 3 60 74 84 174 174 174
46242 +174 174 174 167 166 167 163 162 163 155 154 155 157 156 157 155 154 155
46243 +156 155 156 163 162 163 167 166 167 158 157 158 125 124 125 37 38 37
46244 +4 3 3 4 0 0 4 0 0 6 6 6 6 6 6 5 5 5
46245 +4 4 4 4 4 4 4 4 4 1 1 1 0 0 0 2 3 3
46246 +10 13 16 7 11 13 1 0 0 0 0 0 2 2 1 4 4 4
46247 +4 4 4 4 4 4 4 4 4 5 5 5 4 3 3 4 0 0
46248 +4 0 0 7 11 13 13 16 17 4 0 0 3 3 3 34 47 55
46249 +80 127 157 146 190 211 172 205 220 136 185 209 136 185 209 136 185 209
46250 +28 67 93 22 40 52 55 98 126 55 98 126 21 29 34 7 11 13
46251 +50 82 103 101 161 196 101 161 196 35 83 115 13 20 25 2 2 1
46252 +1 1 2 1 1 2 37 51 59 131 129 131 174 174 174 174 174 174
46253 +167 166 167 163 162 163 163 162 163 167 166 167 174 174 174 125 124 125
46254 +16 19 21 4 0 0
46255 +4 4 4 4 0 0 4 0 0 60 74 84 174 174 174 174 174 174
46256 +158 157 158 155 154 155 155 154 155 156 155 156 155 154 155 158 157 158
46257 +167 166 167 165 164 165 131 129 131 60 73 81 13 16 17 4 0 0
46258 +4 0 0 4 3 3 6 6 6 4 3 3 5 5 5 4 4 4
46259 +4 4 4 3 2 2 0 0 0 0 0 0 7 11 13 45 69 86
46260 +80 127 157 71 116 144 43 61 72 7 11 13 0 0 0 1 1 1
46261 +4 3 3 4 4 4 4 4 4 4 4 4 6 6 6 5 5 5
46262 +3 2 2 4 0 0 1 0 0 21 29 34 59 113 148 136 185 209
46263 +146 190 211 136 185 209 136 185 209 136 185 209 136 185 209 136 185 209
46264 +68 124 159 44 81 103 22 40 52 13 16 17 43 61 72 90 154 193
46265 +136 185 209 59 113 148 21 29 34 3 4 3 1 1 1 0 0 0
46266 +24 26 27 125 124 125 163 162 163 174 174 174 166 165 166 165 164 165
46267 +163 162 163 125 124 125 125 124 125 125 124 125 125 124 125 26 28 28
46268 +4 0 0 4 3 3
46269 +3 3 3 0 0 0 24 26 27 153 152 153 177 184 187 158 157 158
46270 +156 155 156 156 155 156 155 154 155 155 154 155 165 164 165 174 174 174
46271 +155 154 155 60 74 84 26 28 28 4 0 0 4 0 0 3 1 0
46272 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 3 3
46273 +2 0 0 0 0 0 0 0 0 32 43 50 72 125 159 101 161 196
46274 +136 185 209 101 161 196 101 161 196 79 117 143 32 43 50 0 0 0
46275 +0 0 0 2 2 2 4 4 4 4 4 4 3 3 3 1 0 0
46276 +0 0 0 4 5 5 49 76 92 101 161 196 146 190 211 146 190 211
46277 +136 185 209 136 185 209 136 185 209 136 185 209 136 185 209 90 154 193
46278 +28 67 93 13 16 17 37 51 59 80 127 157 136 185 209 90 154 193
46279 +22 40 52 6 9 11 3 4 3 2 2 1 16 19 21 60 73 81
46280 +137 136 137 163 162 163 158 157 158 166 165 166 167 166 167 153 152 153
46281 +60 74 84 37 38 37 6 6 6 13 16 17 4 0 0 1 0 0
46282 +3 2 2 4 4 4
46283 +3 2 2 4 0 0 37 38 37 137 136 137 167 166 167 158 157 158
46284 +157 156 157 154 153 154 157 156 157 167 166 167 174 174 174 125 124 125
46285 +37 38 37 4 0 0 4 0 0 4 0 0 4 3 3 4 4 4
46286 +4 4 4 4 4 4 5 5 5 5 5 5 1 1 1 0 0 0
46287 +0 0 0 16 21 25 55 98 126 90 154 193 136 185 209 101 161 196
46288 +101 161 196 101 161 196 136 185 209 136 185 209 101 161 196 55 98 126
46289 +14 17 19 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
46290 +22 40 52 90 154 193 146 190 211 146 190 211 136 185 209 136 185 209
46291 +136 185 209 136 185 209 136 185 209 101 161 196 35 83 115 7 11 13
46292 +17 23 27 59 113 148 136 185 209 101 161 196 34 86 122 7 12 15
46293 +2 5 5 3 4 3 6 6 6 60 73 81 131 129 131 163 162 163
46294 +166 165 166 174 174 174 174 174 174 163 162 163 125 124 125 41 54 63
46295 +13 16 17 4 0 0 4 0 0 4 0 0 1 0 0 2 2 2
46296 +4 4 4 4 4 4
46297 +1 1 1 2 1 0 43 57 68 137 136 137 153 152 153 153 152 153
46298 +163 162 163 156 155 156 165 164 165 167 166 167 60 74 84 6 6 6
46299 +4 0 0 4 0 0 5 5 5 4 4 4 4 4 4 4 4 4
46300 +4 5 5 6 6 6 4 3 3 0 0 0 0 0 0 11 15 18
46301 +40 71 93 100 139 164 101 161 196 101 161 196 101 161 196 101 161 196
46302 +101 161 196 101 161 196 101 161 196 101 161 196 136 185 209 136 185 209
46303 +101 161 196 45 69 86 6 6 6 0 0 0 17 23 27 55 98 126
46304 +136 185 209 146 190 211 136 185 209 136 185 209 136 185 209 136 185 209
46305 +136 185 209 136 185 209 90 154 193 22 40 52 7 11 13 50 82 103
46306 +136 185 209 136 185 209 53 118 160 22 40 52 7 11 13 2 5 5
46307 +3 4 3 37 38 37 125 124 125 157 156 157 166 165 166 167 166 167
46308 +174 174 174 174 174 174 137 136 137 60 73 81 4 0 0 4 0 0
46309 +4 0 0 4 0 0 5 5 5 3 3 3 3 3 3 4 4 4
46310 +4 4 4 4 4 4
46311 +4 0 0 4 0 0 41 54 63 137 136 137 125 124 125 131 129 131
46312 +155 154 155 167 166 167 174 174 174 60 74 84 6 6 6 4 0 0
46313 +4 3 3 6 6 6 4 4 4 4 4 4 4 4 4 5 5 5
46314 +4 4 4 1 1 1 0 0 0 3 6 7 41 65 82 72 125 159
46315 +101 161 196 101 161 196 101 161 196 90 154 193 90 154 193 101 161 196
46316 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 136 185 209
46317 +136 185 209 136 185 209 80 127 157 55 98 126 101 161 196 146 190 211
46318 +136 185 209 136 185 209 136 185 209 101 161 196 136 185 209 101 161 196
46319 +136 185 209 101 161 196 35 83 115 22 30 35 101 161 196 172 205 220
46320 +90 154 193 28 67 93 7 11 13 2 5 5 3 4 3 13 16 17
46321 +85 115 134 167 166 167 174 174 174 174 174 174 174 174 174 174 174 174
46322 +167 166 167 60 74 84 13 16 17 4 0 0 4 0 0 4 3 3
46323 +6 6 6 5 5 5 4 4 4 5 5 5 4 4 4 5 5 5
46324 +5 5 5 5 5 5
46325 +1 1 1 4 0 0 41 54 63 137 136 137 137 136 137 125 124 125
46326 +131 129 131 167 166 167 157 156 157 37 38 37 6 6 6 4 0 0
46327 +6 6 6 5 5 5 4 4 4 4 4 4 4 5 5 2 2 1
46328 +0 0 0 0 0 0 26 37 45 58 111 146 101 161 196 101 161 196
46329 +101 161 196 90 154 193 90 154 193 90 154 193 101 161 196 101 161 196
46330 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
46331 +101 161 196 136 185 209 136 185 209 136 185 209 146 190 211 136 185 209
46332 +136 185 209 101 161 196 136 185 209 136 185 209 101 161 196 136 185 209
46333 +101 161 196 136 185 209 136 185 209 136 185 209 136 185 209 16 89 141
46334 +7 11 13 2 5 5 2 5 5 13 16 17 60 73 81 154 154 154
46335 +174 174 174 174 174 174 174 174 174 174 174 174 163 162 163 125 124 125
46336 +24 26 27 4 0 0 4 0 0 4 0 0 5 5 5 5 5 5
46337 +4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 5 5 5
46338 +5 5 5 4 4 4
46339 +4 0 0 6 6 6 37 38 37 137 136 137 137 136 137 131 129 131
46340 +131 129 131 153 152 153 131 129 131 26 28 28 4 0 0 4 3 3
46341 +6 6 6 4 4 4 4 4 4 4 4 4 0 0 0 0 0 0
46342 +13 20 25 51 88 114 90 154 193 101 161 196 101 161 196 90 154 193
46343 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 101 161 196
46344 +101 161 196 101 161 196 101 161 196 101 161 196 136 185 209 101 161 196
46345 +101 161 196 136 185 209 101 161 196 136 185 209 136 185 209 101 161 196
46346 +136 185 209 101 161 196 136 185 209 101 161 196 101 161 196 101 161 196
46347 +136 185 209 136 185 209 136 185 209 37 112 160 21 29 34 5 7 8
46348 +2 5 5 13 16 17 43 57 68 131 129 131 174 174 174 174 174 174
46349 +174 174 174 167 166 167 157 156 157 125 124 125 37 38 37 4 0 0
46350 +4 0 0 4 0 0 5 5 5 5 5 5 4 4 4 4 4 4
46351 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46352 +4 4 4 4 4 4
46353 +1 1 1 4 0 0 41 54 63 153 152 153 137 136 137 137 136 137
46354 +137 136 137 153 152 153 125 124 125 24 26 27 4 0 0 3 2 2
46355 +4 4 4 4 4 4 4 3 3 4 0 0 3 6 7 43 61 72
46356 +64 123 161 101 161 196 90 154 193 90 154 193 90 154 193 90 154 193
46357 +90 154 193 90 154 193 90 154 193 90 154 193 101 161 196 90 154 193
46358 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
46359 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
46360 +136 185 209 101 161 196 101 161 196 136 185 209 136 185 209 101 161 196
46361 +101 161 196 90 154 193 28 67 93 13 16 17 7 11 13 3 6 7
46362 +37 51 59 125 124 125 163 162 163 174 174 174 167 166 167 166 165 166
46363 +167 166 167 131 129 131 60 73 81 4 0 0 4 0 0 4 0 0
46364 +3 3 3 5 5 5 6 6 6 4 4 4 4 4 4 4 4 4
46365 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46366 +4 4 4 4 4 4
46367 +4 0 0 4 0 0 41 54 63 137 136 137 153 152 153 137 136 137
46368 +153 152 153 157 156 157 125 124 125 24 26 27 0 0 0 2 2 2
46369 +4 4 4 4 4 4 2 0 0 0 0 0 28 67 93 90 154 193
46370 +90 154 193 90 154 193 90 154 193 90 154 193 64 123 161 90 154 193
46371 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 101 161 196
46372 +90 154 193 101 161 196 101 161 196 101 161 196 90 154 193 136 185 209
46373 +101 161 196 101 161 196 136 185 209 101 161 196 136 185 209 101 161 196
46374 +101 161 196 101 161 196 136 185 209 101 161 196 101 161 196 90 154 193
46375 +35 83 115 13 16 17 3 6 7 2 5 5 13 16 17 60 74 84
46376 +154 154 154 166 165 166 165 164 165 158 157 158 163 162 163 157 156 157
46377 +60 74 84 13 16 17 4 0 0 4 0 0 3 2 2 4 4 4
46378 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46379 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46380 +4 4 4 4 4 4
46381 +1 1 1 4 0 0 41 54 63 157 156 157 155 154 155 137 136 137
46382 +153 152 153 158 157 158 137 136 137 26 28 28 2 0 0 2 2 2
46383 +4 4 4 4 4 4 1 0 0 6 10 14 34 86 122 90 154 193
46384 +64 123 161 90 154 193 64 123 161 90 154 193 90 154 193 90 154 193
46385 +64 123 161 90 154 193 90 154 193 90 154 193 90 154 193 90 154 193
46386 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
46387 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
46388 +136 185 209 101 161 196 136 185 209 90 154 193 26 108 161 22 40 52
46389 +13 16 17 5 7 8 2 5 5 2 5 5 37 38 37 165 164 165
46390 +174 174 174 163 162 163 154 154 154 165 164 165 167 166 167 60 73 81
46391 +6 6 6 4 0 0 4 0 0 4 4 4 4 4 4 4 4 4
46392 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46393 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46394 +4 4 4 4 4 4
46395 +4 0 0 6 6 6 41 54 63 156 155 156 158 157 158 153 152 153
46396 +156 155 156 165 164 165 137 136 137 26 28 28 0 0 0 2 2 2
46397 +4 4 5 4 4 4 2 0 0 7 12 15 31 96 139 64 123 161
46398 +90 154 193 64 123 161 90 154 193 90 154 193 64 123 161 90 154 193
46399 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 90 154 193
46400 +90 154 193 90 154 193 90 154 193 101 161 196 101 161 196 101 161 196
46401 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 136 185 209
46402 +101 161 196 136 185 209 26 108 161 22 40 52 7 11 13 5 7 8
46403 +2 5 5 2 5 5 2 5 5 2 2 1 37 38 37 158 157 158
46404 +174 174 174 154 154 154 156 155 156 167 166 167 165 164 165 37 38 37
46405 +4 0 0 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
46406 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46407 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46408 +4 4 4 4 4 4
46409 +3 1 0 4 0 0 60 73 81 157 156 157 163 162 163 153 152 153
46410 +158 157 158 167 166 167 137 136 137 26 28 28 2 0 0 2 2 2
46411 +4 5 5 4 4 4 4 0 0 7 12 15 24 86 132 26 108 161
46412 +37 112 160 64 123 161 90 154 193 64 123 161 90 154 193 90 154 193
46413 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 90 154 193
46414 +90 154 193 101 161 196 90 154 193 101 161 196 101 161 196 101 161 196
46415 +101 161 196 101 161 196 101 161 196 136 185 209 101 161 196 136 185 209
46416 +90 154 193 35 83 115 13 16 17 13 16 17 7 11 13 3 6 7
46417 +5 7 8 6 6 6 3 4 3 2 2 1 30 32 34 154 154 154
46418 +167 166 167 154 154 154 154 154 154 174 174 174 165 164 165 37 38 37
46419 +6 6 6 4 0 0 6 6 6 4 4 4 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 4 4 4 4 4 4 4 4 4 4 4 4
46422 +4 4 4 4 4 4
46423 +4 0 0 4 0 0 41 54 63 163 162 163 166 165 166 154 154 154
46424 +163 162 163 174 174 174 137 136 137 26 28 28 0 0 0 2 2 2
46425 +4 5 5 4 4 5 1 1 2 6 10 14 28 67 93 18 97 151
46426 +18 97 151 18 97 151 26 108 161 37 112 160 37 112 160 90 154 193
46427 +64 123 161 90 154 193 90 154 193 90 154 193 90 154 193 101 161 196
46428 +90 154 193 101 161 196 101 161 196 90 154 193 101 161 196 101 161 196
46429 +101 161 196 101 161 196 101 161 196 136 185 209 90 154 193 16 89 141
46430 +13 20 25 7 11 13 5 7 8 5 7 8 2 5 5 4 5 5
46431 +3 4 3 4 5 5 3 4 3 0 0 0 37 38 37 158 157 158
46432 +174 174 174 158 157 158 158 157 158 167 166 167 174 174 174 41 54 63
46433 +4 0 0 3 2 2 5 5 5 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 4 4 4 4 4 4 4 4 4 4 4 4
46436 +4 4 4 4 4 4
46437 +1 1 1 4 0 0 60 73 81 165 164 165 174 174 174 158 157 158
46438 +167 166 167 174 174 174 153 152 153 26 28 28 2 0 0 2 2 2
46439 +4 5 5 4 4 4 4 0 0 7 12 15 10 87 144 10 87 144
46440 +18 97 151 18 97 151 18 97 151 26 108 161 26 108 161 26 108 161
46441 +26 108 161 37 112 160 53 118 160 90 154 193 90 154 193 90 154 193
46442 +90 154 193 90 154 193 101 161 196 101 161 196 101 161 196 101 161 196
46443 +101 161 196 136 185 209 90 154 193 26 108 161 22 40 52 13 16 17
46444 +7 11 13 3 6 7 5 7 8 5 7 8 2 5 5 4 5 5
46445 +4 5 5 6 6 6 3 4 3 0 0 0 30 32 34 158 157 158
46446 +174 174 174 156 155 156 155 154 155 165 164 165 154 153 154 37 38 37
46447 +4 0 0 4 3 3 5 5 5 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 4 4 4 4 4 4 4 4 4 4 4 4
46450 +4 4 4 4 4 4
46451 +4 0 0 4 0 0 60 73 81 167 166 167 174 174 174 163 162 163
46452 +174 174 174 174 174 174 153 152 153 26 28 28 0 0 0 3 3 3
46453 +5 5 5 4 4 4 1 1 2 7 12 15 28 67 93 18 97 151
46454 +18 97 151 18 97 151 18 97 151 18 97 151 18 97 151 26 108 161
46455 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
46456 +90 154 193 26 108 161 90 154 193 90 154 193 90 154 193 101 161 196
46457 +101 161 196 26 108 161 22 40 52 13 16 17 7 11 13 2 5 5
46458 +2 5 5 6 6 6 2 5 5 4 5 5 4 5 5 4 5 5
46459 +3 4 3 5 5 5 3 4 3 2 0 0 30 32 34 137 136 137
46460 +153 152 153 137 136 137 131 129 131 137 136 137 131 129 131 37 38 37
46461 +4 0 0 4 3 3 5 5 5 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 4 4 4 4 4 4 4 4 4 4 4 4
46464 +4 4 4 4 4 4
46465 +1 1 1 4 0 0 60 73 81 167 166 167 174 174 174 166 165 166
46466 +174 174 174 177 184 187 153 152 153 30 32 34 1 0 0 3 3 3
46467 +5 5 5 4 3 3 4 0 0 7 12 15 10 87 144 10 87 144
46468 +18 97 151 18 97 151 18 97 151 26 108 161 26 108 161 26 108 161
46469 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
46470 +26 108 161 26 108 161 26 108 161 90 154 193 90 154 193 26 108 161
46471 +35 83 115 13 16 17 7 11 13 5 7 8 3 6 7 5 7 8
46472 +2 5 5 6 6 6 4 5 5 4 5 5 3 4 3 4 5 5
46473 +3 4 3 6 6 6 3 4 3 0 0 0 26 28 28 125 124 125
46474 +131 129 131 125 124 125 125 124 125 131 129 131 131 129 131 37 38 37
46475 +4 0 0 3 3 3 5 5 5 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 4 4 4 4 4 4 4 4 4 4 4 4
46478 +4 4 4 4 4 4
46479 +3 1 0 4 0 0 60 73 81 174 174 174 177 184 187 167 166 167
46480 +174 174 174 177 184 187 153 152 153 30 32 34 0 0 0 3 3 3
46481 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 18 97 151
46482 +18 97 151 18 97 151 18 97 151 18 97 151 18 97 151 26 108 161
46483 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
46484 +26 108 161 90 154 193 26 108 161 26 108 161 24 86 132 13 20 25
46485 +7 11 13 13 20 25 22 40 52 5 7 8 3 4 3 3 4 3
46486 +4 5 5 3 4 3 4 5 5 3 4 3 4 5 5 3 4 3
46487 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 125 124 125
46488 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
46489 +0 0 0 3 3 3 5 5 5 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 4 4 4 4 4 4 4 4 4 4 4 4
46492 +4 4 4 4 4 4
46493 +1 1 1 4 0 0 60 73 81 174 174 174 177 184 187 174 174 174
46494 +174 174 174 190 197 201 157 156 157 30 32 34 1 0 0 3 3 3
46495 +5 5 5 4 3 3 4 0 0 7 12 15 10 87 144 10 87 144
46496 +18 97 151 19 95 150 19 95 150 18 97 151 18 97 151 26 108 161
46497 +18 97 151 26 108 161 26 108 161 26 108 161 26 108 161 90 154 193
46498 +26 108 161 26 108 161 26 108 161 22 40 52 2 5 5 3 4 3
46499 +28 67 93 37 112 160 34 86 122 2 5 5 3 4 3 3 4 3
46500 +3 4 3 3 4 3 3 4 3 2 2 1 3 4 3 4 4 4
46501 +4 5 5 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
46502 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
46503 +0 0 0 3 3 3 5 5 5 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 4 4 4 4 4 4 4 4 4 4 4 4
46506 +4 4 4 4 4 4
46507 +4 0 0 4 0 0 60 73 81 174 174 174 177 184 187 174 174 174
46508 +174 174 174 190 197 201 158 157 158 30 32 34 0 0 0 2 2 2
46509 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 18 97 151
46510 +10 87 144 19 95 150 19 95 150 18 97 151 18 97 151 18 97 151
46511 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
46512 +18 97 151 22 40 52 2 5 5 2 2 1 22 40 52 26 108 161
46513 +90 154 193 37 112 160 22 40 52 3 4 3 13 20 25 22 30 35
46514 +3 6 7 1 1 1 2 2 2 6 9 11 5 5 5 4 3 3
46515 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 131 129 131
46516 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
46517 +0 0 0 3 3 3 5 5 5 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 4 4 4 4 4 4 4 4 4 4 4 4
46520 +4 4 4 4 4 4
46521 +1 1 1 4 0 0 60 73 81 177 184 187 193 200 203 174 174 174
46522 +177 184 187 193 200 203 163 162 163 30 32 34 4 0 0 2 2 2
46523 +5 5 5 4 3 3 4 0 0 6 10 14 24 86 132 10 87 144
46524 +10 87 144 10 87 144 19 95 150 19 95 150 19 95 150 18 97 151
46525 +26 108 161 26 108 161 26 108 161 90 154 193 26 108 161 28 67 93
46526 +6 10 14 2 5 5 13 20 25 24 86 132 37 112 160 90 154 193
46527 +10 87 144 7 12 15 2 5 5 28 67 93 37 112 160 28 67 93
46528 +2 2 1 7 12 15 35 83 115 28 67 93 3 6 7 1 0 0
46529 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
46530 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
46531 +0 0 0 3 3 3 5 5 5 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 4 4 4 4 4 4 4 4 4 4 4 4
46534 +4 4 4 4 4 4
46535 +4 0 0 4 0 0 60 73 81 174 174 174 190 197 201 174 174 174
46536 +177 184 187 193 200 203 163 162 163 30 32 34 0 0 0 2 2 2
46537 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 10 87 144
46538 +10 87 144 16 89 141 19 95 150 10 87 144 26 108 161 26 108 161
46539 +26 108 161 26 108 161 26 108 161 28 67 93 6 10 14 1 1 2
46540 +7 12 15 28 67 93 26 108 161 16 89 141 24 86 132 21 29 34
46541 +3 4 3 21 29 34 37 112 160 37 112 160 27 99 146 21 29 34
46542 +21 29 34 26 108 161 90 154 193 35 83 115 1 1 2 2 0 0
46543 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 125 124 125
46544 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
46545 +0 0 0 3 3 3 5 5 5 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 4 4 4 4 4 4 4 4 4 4 4 4
46548 +4 4 4 4 4 4
46549 +3 1 0 4 0 0 60 73 81 193 200 203 193 200 203 174 174 174
46550 +190 197 201 193 200 203 165 164 165 37 38 37 4 0 0 2 2 2
46551 +5 5 5 4 3 3 4 0 0 6 10 14 24 86 132 10 87 144
46552 +10 87 144 10 87 144 16 89 141 18 97 151 18 97 151 10 87 144
46553 +24 86 132 24 86 132 13 20 25 4 5 7 4 5 7 22 40 52
46554 +18 97 151 37 112 160 26 108 161 7 12 15 1 1 1 0 0 0
46555 +28 67 93 37 112 160 26 108 161 28 67 93 22 40 52 28 67 93
46556 +26 108 161 90 154 193 26 108 161 10 87 144 0 0 0 2 0 0
46557 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
46558 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
46559 +0 0 0 3 3 3 5 5 5 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 4 4 4 4 4 4 4 4 4 4 4 4
46562 +4 4 4 4 4 4
46563 +4 0 0 6 6 6 60 73 81 174 174 174 193 200 203 174 174 174
46564 +190 197 201 193 200 203 165 164 165 30 32 34 0 0 0 2 2 2
46565 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 10 87 144
46566 +10 87 144 10 87 144 10 87 144 18 97 151 28 67 93 6 10 14
46567 +0 0 0 1 1 2 4 5 7 13 20 25 16 89 141 26 108 161
46568 +26 108 161 26 108 161 24 86 132 6 9 11 2 3 3 22 40 52
46569 +37 112 160 16 89 141 22 40 52 28 67 93 26 108 161 26 108 161
46570 +90 154 193 26 108 161 26 108 161 28 67 93 1 1 1 4 0 0
46571 +4 4 4 5 5 5 3 3 3 4 0 0 26 28 28 124 126 130
46572 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
46573 +0 0 0 3 3 3 5 5 5 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 4 4 4 4 4 4 4 4 4 4 4 4
46576 +4 4 4 4 4 4
46577 +4 0 0 4 0 0 60 73 81 193 200 203 193 200 203 174 174 174
46578 +193 200 203 193 200 203 167 166 167 37 38 37 4 0 0 2 2 2
46579 +5 5 5 4 4 4 4 0 0 6 10 14 28 67 93 10 87 144
46580 +10 87 144 10 87 144 18 97 151 10 87 144 13 20 25 4 5 7
46581 +1 1 2 1 1 1 22 40 52 26 108 161 26 108 161 26 108 161
46582 +26 108 161 26 108 161 26 108 161 24 86 132 22 40 52 22 40 52
46583 +22 40 52 22 40 52 10 87 144 26 108 161 26 108 161 26 108 161
46584 +26 108 161 26 108 161 90 154 193 10 87 144 0 0 0 4 0 0
46585 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
46586 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
46587 +0 0 0 3 3 3 5 5 5 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 4 4 4 4 4 4 4 4 4 4 4 4
46590 +4 4 4 4 4 4
46591 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
46592 +190 197 201 205 212 215 167 166 167 30 32 34 0 0 0 2 2 2
46593 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 10 87 144
46594 +10 87 144 10 87 144 10 87 144 10 87 144 22 40 52 1 1 2
46595 +2 0 0 1 1 2 24 86 132 26 108 161 26 108 161 26 108 161
46596 +26 108 161 19 95 150 16 89 141 10 87 144 22 40 52 22 40 52
46597 +10 87 144 26 108 161 37 112 160 26 108 161 26 108 161 26 108 161
46598 +26 108 161 26 108 161 26 108 161 28 67 93 2 0 0 3 1 0
46599 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 131 129 131
46600 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
46601 +0 0 0 3 3 3 5 5 5 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 4 4 4 4 4 4 4 4 4 4 4 4
46604 +4 4 4 4 4 4
46605 +4 0 0 4 0 0 60 73 81 220 221 221 190 197 201 174 174 174
46606 +193 200 203 193 200 203 174 174 174 37 38 37 4 0 0 2 2 2
46607 +5 5 5 4 4 4 3 2 2 1 1 2 13 20 25 10 87 144
46608 +10 87 144 10 87 144 10 87 144 10 87 144 10 87 144 13 20 25
46609 +13 20 25 22 40 52 10 87 144 18 97 151 18 97 151 26 108 161
46610 +10 87 144 13 20 25 6 10 14 21 29 34 24 86 132 18 97 151
46611 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
46612 +26 108 161 90 154 193 18 97 151 13 20 25 0 0 0 4 3 3
46613 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
46614 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
46615 +0 0 0 3 3 3 5 5 5 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 4 4 4 4 4 4 4 4 4 4 4 4
46618 +4 4 4 4 4 4
46619 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
46620 +190 197 201 220 221 221 167 166 167 30 32 34 1 0 0 2 2 2
46621 +5 5 5 4 4 4 4 4 5 2 5 5 4 5 7 13 20 25
46622 +28 67 93 10 87 144 10 87 144 10 87 144 10 87 144 10 87 144
46623 +10 87 144 10 87 144 18 97 151 10 87 144 18 97 151 18 97 151
46624 +28 67 93 2 3 3 0 0 0 28 67 93 26 108 161 26 108 161
46625 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
46626 +26 108 161 10 87 144 13 20 25 1 1 2 3 2 2 4 4 4
46627 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 131 129 131
46628 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
46629 +0 0 0 3 3 3 5 5 5 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 4 4 4 4 4 4 4 4 4 4 4 4
46632 +4 4 4 4 4 4
46633 +4 0 0 4 0 0 60 73 81 220 221 221 190 197 201 174 174 174
46634 +193 200 203 193 200 203 174 174 174 26 28 28 4 0 0 4 3 3
46635 +5 5 5 4 4 4 4 4 4 4 4 5 1 1 2 2 5 5
46636 +4 5 7 22 40 52 10 87 144 10 87 144 18 97 151 10 87 144
46637 +10 87 144 10 87 144 10 87 144 10 87 144 10 87 144 18 97 151
46638 +10 87 144 28 67 93 22 40 52 10 87 144 26 108 161 18 97 151
46639 +18 97 151 18 97 151 26 108 161 26 108 161 26 108 161 26 108 161
46640 +22 40 52 1 1 2 0 0 0 2 3 3 4 4 4 4 4 4
46641 +4 4 4 5 5 5 4 4 4 0 0 0 26 28 28 131 129 131
46642 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
46643 +0 0 0 3 3 3 5 5 5 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 4 4 4 4 4 4 4 4 4 4 4 4
46646 +4 4 4 4 4 4
46647 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
46648 +190 197 201 220 221 221 190 197 201 41 54 63 4 0 0 2 2 2
46649 +6 6 6 4 4 4 4 4 4 4 4 5 4 4 5 3 3 3
46650 +1 1 2 1 1 2 6 10 14 22 40 52 10 87 144 18 97 151
46651 +18 97 151 10 87 144 10 87 144 10 87 144 18 97 151 10 87 144
46652 +10 87 144 18 97 151 26 108 161 18 97 151 18 97 151 10 87 144
46653 +26 108 161 26 108 161 26 108 161 10 87 144 28 67 93 6 10 14
46654 +1 1 2 1 1 2 4 3 3 4 4 5 4 4 4 4 4 4
46655 +5 5 5 5 5 5 1 1 1 4 0 0 37 51 59 137 136 137
46656 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
46657 +0 0 0 3 3 3 5 5 5 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 4 4 4 4 4 4 4 4 4 4 4 4
46660 +4 4 4 4 4 4
46661 +4 0 0 4 0 0 60 73 81 220 221 221 193 200 203 174 174 174
46662 +193 200 203 193 200 203 220 221 221 137 136 137 13 16 17 4 0 0
46663 +2 2 2 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5
46664 +4 4 5 4 3 3 1 1 2 4 5 7 13 20 25 28 67 93
46665 +10 87 144 10 87 144 10 87 144 10 87 144 10 87 144 10 87 144
46666 +10 87 144 18 97 151 18 97 151 10 87 144 18 97 151 26 108 161
46667 +26 108 161 18 97 151 28 67 93 6 10 14 0 0 0 0 0 0
46668 +2 3 3 4 5 5 4 4 5 4 4 4 4 4 4 5 5 5
46669 +3 3 3 1 1 1 0 0 0 16 19 21 125 124 125 137 136 137
46670 +131 129 131 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
46671 +0 0 0 3 3 3 5 5 5 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 4 4 4 4 4 4 4 4 4 4 4 4
46674 +4 4 4 4 4 4
46675 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
46676 +193 200 203 190 197 201 220 221 221 220 221 221 153 152 153 30 32 34
46677 +0 0 0 0 0 0 2 2 2 4 4 4 4 4 4 4 4 4
46678 +4 4 4 4 5 5 4 5 7 1 1 2 1 1 2 4 5 7
46679 +13 20 25 28 67 93 10 87 144 18 97 151 10 87 144 10 87 144
46680 +10 87 144 10 87 144 10 87 144 18 97 151 26 108 161 18 97 151
46681 +28 67 93 7 12 15 0 0 0 0 0 0 2 2 1 4 4 4
46682 +4 5 5 4 5 5 4 4 4 4 4 4 3 3 3 0 0 0
46683 +0 0 0 0 0 0 37 38 37 125 124 125 158 157 158 131 129 131
46684 +125 124 125 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
46685 +0 0 0 3 3 3 5 5 5 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 4 4 4 4 4 4 4 4 4 4 4 4
46688 +4 4 4 4 4 4
46689 +4 3 3 4 0 0 41 54 63 193 200 203 220 221 221 174 174 174
46690 +193 200 203 193 200 203 193 200 203 220 221 221 244 246 246 193 200 203
46691 +120 125 127 5 5 5 1 0 0 0 0 0 1 1 1 4 4 4
46692 +4 4 4 4 4 4 4 5 5 4 5 5 4 4 5 1 1 2
46693 +4 5 7 4 5 7 22 40 52 10 87 144 10 87 144 10 87 144
46694 +10 87 144 10 87 144 18 97 151 10 87 144 10 87 144 13 20 25
46695 +4 5 7 2 3 3 1 1 2 4 4 4 4 5 5 4 4 4
46696 +4 4 4 4 4 4 4 4 4 1 1 1 0 0 0 1 1 2
46697 +24 26 27 60 74 84 153 152 153 163 162 163 137 136 137 125 124 125
46698 +125 124 125 125 124 125 125 124 125 137 136 137 125 124 125 26 28 28
46699 +0 0 0 3 3 3 5 5 5 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 4 4 4 4 4 4 4 4 4 4 4 4
46702 +4 4 4 4 4 4
46703 +4 0 0 6 6 6 26 28 28 156 155 156 220 221 221 220 221 221
46704 +174 174 174 193 200 203 193 200 203 193 200 203 205 212 215 220 221 221
46705 +220 221 221 167 166 167 60 73 81 7 11 13 0 0 0 0 0 0
46706 +3 3 3 4 4 4 4 4 4 4 4 4 4 4 5 4 4 5
46707 +4 4 5 1 1 2 1 1 2 4 5 7 22 40 52 10 87 144
46708 +10 87 144 10 87 144 10 87 144 22 40 52 4 5 7 1 1 2
46709 +1 1 2 4 4 5 4 4 4 4 4 4 4 4 4 4 4 4
46710 +5 5 5 2 2 2 0 0 0 4 0 0 16 19 21 60 73 81
46711 +137 136 137 167 166 167 158 157 158 137 136 137 131 129 131 131 129 131
46712 +125 124 125 125 124 125 131 129 131 155 154 155 60 74 84 5 7 8
46713 +0 0 0 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 4 4 4 4 4 4 4 4 4 4 4 4
46716 +4 4 4 4 4 4
46717 +5 5 5 4 0 0 4 0 0 60 73 81 193 200 203 220 221 221
46718 +193 200 203 193 200 203 193 200 203 193 200 203 205 212 215 220 221 221
46719 +220 221 221 220 221 221 220 221 221 137 136 137 43 57 68 6 6 6
46720 +4 0 0 1 1 1 4 4 4 4 4 4 4 4 4 4 4 4
46721 +4 4 5 4 4 5 3 2 2 1 1 2 2 5 5 13 20 25
46722 +22 40 52 22 40 52 13 20 25 2 3 3 1 1 2 3 3 3
46723 +4 5 7 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46724 +1 1 1 0 0 0 2 3 3 41 54 63 131 129 131 166 165 166
46725 +166 165 166 155 154 155 153 152 153 137 136 137 137 136 137 125 124 125
46726 +125 124 125 137 136 137 137 136 137 125 124 125 37 38 37 4 3 3
46727 +4 3 3 5 5 5 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 4 4 4 4 4 4 4 4 4 4 4 4
46730 +4 4 4 4 4 4
46731 +4 3 3 6 6 6 6 6 6 13 16 17 60 73 81 167 166 167
46732 +220 221 221 220 221 221 220 221 221 193 200 203 193 200 203 193 200 203
46733 +205 212 215 220 221 221 220 221 221 244 246 246 205 212 215 125 124 125
46734 +24 26 27 0 0 0 0 0 0 2 2 2 5 5 5 5 5 5
46735 +4 4 4 4 4 4 4 4 4 4 4 5 1 1 2 4 5 7
46736 +4 5 7 4 5 7 1 1 2 3 2 2 4 4 5 4 4 4
46737 +4 4 4 4 4 4 5 5 5 4 4 4 0 0 0 0 0 0
46738 +2 0 0 26 28 28 125 124 125 174 174 174 174 174 174 166 165 166
46739 +156 155 156 153 152 153 137 136 137 137 136 137 131 129 131 137 136 137
46740 +137 136 137 137 136 137 60 74 84 30 32 34 4 0 0 4 0 0
46741 +5 5 5 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 4 4 4 4 4 4 4 4 4 4 4 4
46744 +4 4 4 4 4 4
46745 +5 5 5 6 6 6 4 0 0 4 0 0 6 6 6 26 28 28
46746 +125 124 125 174 174 174 220 221 221 220 221 221 220 221 221 193 200 203
46747 +205 212 215 220 221 221 205 212 215 220 221 221 220 221 221 244 246 246
46748 +193 200 203 60 74 84 13 16 17 4 0 0 0 0 0 3 3 3
46749 +5 5 5 5 5 5 4 4 4 4 4 4 4 4 5 3 3 3
46750 +1 1 2 3 3 3 4 4 5 4 4 5 4 4 4 4 4 4
46751 +5 5 5 5 5 5 2 2 2 0 0 0 0 0 0 13 16 17
46752 +60 74 84 174 174 174 193 200 203 174 174 174 167 166 167 163 162 163
46753 +153 152 153 153 152 153 137 136 137 137 136 137 153 152 153 137 136 137
46754 +125 124 125 41 54 63 24 26 27 4 0 0 4 0 0 5 5 5
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 4 4 4 4 4 4 4 4 4 4 4 4
46758 +4 4 4 4 4 4
46759 +4 3 3 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
46760 +6 6 6 37 38 37 131 129 131 220 221 221 220 221 221 220 221 221
46761 +193 200 203 193 200 203 220 221 221 205 212 215 220 221 221 244 246 246
46762 +244 246 246 244 246 246 174 174 174 41 54 63 0 0 0 0 0 0
46763 +0 0 0 4 4 4 5 5 5 5 5 5 4 4 4 4 4 5
46764 +4 4 5 4 4 5 4 4 4 4 4 4 6 6 6 6 6 6
46765 +3 3 3 0 0 0 2 0 0 13 16 17 60 73 81 156 155 156
46766 +220 221 221 193 200 203 174 174 174 165 164 165 163 162 163 154 153 154
46767 +153 152 153 153 152 153 158 157 158 163 162 163 137 136 137 60 73 81
46768 +13 16 17 4 0 0 4 0 0 4 3 3 4 4 4 4 4 4
46769 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46770 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46771 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46772 +4 4 4 4 4 4
46773 +5 5 5 4 3 3 4 3 3 6 6 6 6 6 6 6 6 6
46774 +6 6 6 6 6 6 6 6 6 37 38 37 167 166 167 244 246 246
46775 +244 246 246 220 221 221 205 212 215 205 212 215 220 221 221 193 200 203
46776 +220 221 221 244 246 246 244 246 246 244 246 246 137 136 137 37 38 37
46777 +3 2 2 0 0 0 1 1 1 5 5 5 5 5 5 4 4 4
46778 +4 4 4 4 4 4 4 4 4 5 5 5 4 4 4 1 1 1
46779 +0 0 0 5 5 5 43 57 68 153 152 153 193 200 203 220 221 221
46780 +177 184 187 174 174 174 167 166 167 166 165 166 158 157 158 157 156 157
46781 +158 157 158 166 165 166 156 155 156 85 115 134 13 16 17 4 0 0
46782 +4 0 0 4 0 0 5 5 5 5 5 5 4 4 4 4 4 4
46783 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46784 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46785 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46786 +4 4 4 4 4 4
46787 +5 5 5 4 3 3 6 6 6 6 6 6 4 0 0 6 6 6
46788 +6 6 6 6 6 6 6 6 6 6 6 6 13 16 17 60 73 81
46789 +177 184 187 220 221 221 220 221 221 220 221 221 205 212 215 220 221 221
46790 +220 221 221 205 212 215 220 221 221 244 246 246 244 246 246 205 212 215
46791 +125 124 125 30 32 34 0 0 0 0 0 0 2 2 2 5 5 5
46792 +4 4 4 4 4 4 4 4 4 1 1 1 0 0 0 1 0 0
46793 +37 38 37 131 129 131 205 212 215 220 221 221 193 200 203 174 174 174
46794 +174 174 174 174 174 174 167 166 167 165 164 165 166 165 166 167 166 167
46795 +158 157 158 125 124 125 37 38 37 4 0 0 4 0 0 4 0 0
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 4 4 4 4 4 4 4 4 4 4 4 4
46800 +4 4 4 4 4 4
46801 +4 4 4 5 5 5 4 3 3 4 3 3 6 6 6 6 6 6
46802 +4 0 0 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
46803 +26 28 28 125 124 125 205 212 215 220 221 221 220 221 221 220 221 221
46804 +205 212 215 220 221 221 205 212 215 220 221 221 220 221 221 244 246 246
46805 +244 246 246 190 197 201 60 74 84 16 19 21 4 0 0 0 0 0
46806 +0 0 0 0 0 0 0 0 0 0 0 0 16 19 21 120 125 127
46807 +177 184 187 220 221 221 205 212 215 177 184 187 174 174 174 177 184 187
46808 +174 174 174 174 174 174 167 166 167 174 174 174 166 165 166 137 136 137
46809 +60 73 81 13 16 17 4 0 0 4 0 0 4 3 3 6 6 6
46810 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46811 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46812 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46813 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46814 +4 4 4 4 4 4
46815 +5 5 5 4 3 3 5 5 5 4 3 3 6 6 6 4 0 0
46816 +6 6 6 6 6 6 4 0 0 6 6 6 4 0 0 6 6 6
46817 +6 6 6 6 6 6 37 38 37 137 136 137 193 200 203 220 221 221
46818 +220 221 221 205 212 215 220 221 221 205 212 215 205 212 215 220 221 221
46819 +220 221 221 220 221 221 244 246 246 166 165 166 43 57 68 2 2 2
46820 +0 0 0 4 0 0 16 19 21 60 73 81 157 156 157 202 210 214
46821 +220 221 221 193 200 203 177 184 187 177 184 187 177 184 187 174 174 174
46822 +174 174 174 174 174 174 174 174 174 157 156 157 60 74 84 24 26 27
46823 +4 0 0 4 0 0 4 0 0 6 6 6 4 4 4 4 4 4
46824 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46825 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46826 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46827 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46828 +4 4 4 4 4 4
46829 +4 4 4 4 4 4 5 5 5 4 3 3 5 5 5 6 6 6
46830 +6 6 6 4 0 0 6 6 6 6 6 6 6 6 6 4 0 0
46831 +4 0 0 4 0 0 6 6 6 24 26 27 60 73 81 167 166 167
46832 +220 221 221 220 221 221 220 221 221 205 212 215 205 212 215 205 212 215
46833 +205 212 215 220 221 221 220 221 221 220 221 221 205 212 215 137 136 137
46834 +60 74 84 125 124 125 137 136 137 190 197 201 220 221 221 193 200 203
46835 +177 184 187 177 184 187 177 184 187 174 174 174 174 174 174 177 184 187
46836 +190 197 201 174 174 174 125 124 125 37 38 37 6 6 6 4 0 0
46837 +4 0 0 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46838 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46839 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46840 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46841 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46842 +4 4 4 4 4 4
46843 +4 4 4 4 4 4 5 5 5 5 5 5 4 3 3 6 6 6
46844 +4 0 0 6 6 6 6 6 6 6 6 6 4 0 0 6 6 6
46845 +6 6 6 6 6 6 4 0 0 4 0 0 6 6 6 6 6 6
46846 +125 124 125 193 200 203 244 246 246 220 221 221 205 212 215 205 212 215
46847 +205 212 215 193 200 203 205 212 215 205 212 215 220 221 221 220 221 221
46848 +193 200 203 193 200 203 205 212 215 193 200 203 193 200 203 177 184 187
46849 +190 197 201 190 197 201 174 174 174 190 197 201 193 200 203 190 197 201
46850 +153 152 153 60 73 81 4 0 0 4 0 0 4 0 0 3 2 2
46851 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46852 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46853 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46854 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46855 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46856 +4 4 4 4 4 4
46857 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 4 3 3
46858 +6 6 6 4 3 3 4 3 3 4 3 3 6 6 6 6 6 6
46859 +4 0 0 6 6 6 6 6 6 6 6 6 4 0 0 4 0 0
46860 +4 0 0 26 28 28 131 129 131 220 221 221 244 246 246 220 221 221
46861 +205 212 215 193 200 203 205 212 215 193 200 203 193 200 203 205 212 215
46862 +220 221 221 193 200 203 193 200 203 193 200 203 190 197 201 174 174 174
46863 +174 174 174 190 197 201 193 200 203 193 200 203 167 166 167 125 124 125
46864 +6 6 6 4 0 0 4 0 0 4 3 3 4 4 4 4 4 4
46865 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46866 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46867 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46868 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46869 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46870 +4 4 4 4 4 4
46871 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
46872 +5 5 5 4 3 3 5 5 5 6 6 6 4 3 3 5 5 5
46873 +6 6 6 6 6 6 4 0 0 6 6 6 6 6 6 6 6 6
46874 +4 0 0 4 0 0 6 6 6 41 54 63 158 157 158 220 221 221
46875 +220 221 221 220 221 221 193 200 203 193 200 203 193 200 203 190 197 201
46876 +190 197 201 190 197 201 190 197 201 190 197 201 174 174 174 193 200 203
46877 +193 200 203 220 221 221 174 174 174 125 124 125 37 38 37 4 0 0
46878 +4 0 0 4 3 3 6 6 6 4 4 4 4 4 4 4 4 4
46879 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46880 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46881 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46882 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46883 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46884 +4 4 4 4 4 4
46885 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46886 +4 4 4 5 5 5 4 3 3 4 3 3 4 3 3 5 5 5
46887 +4 3 3 6 6 6 5 5 5 4 3 3 6 6 6 6 6 6
46888 +6 6 6 6 6 6 4 0 0 4 0 0 13 16 17 60 73 81
46889 +174 174 174 220 221 221 220 221 221 205 212 215 190 197 201 174 174 174
46890 +193 200 203 174 174 174 190 197 201 174 174 174 193 200 203 220 221 221
46891 +193 200 203 131 129 131 37 38 37 6 6 6 4 0 0 4 0 0
46892 +6 6 6 6 6 6 4 3 3 5 5 5 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 4 4 4 4 4 4 4 4 4 4 4 4
46898 +4 4 4 4 4 4
46899 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46900 +4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 5 5 5
46901 +5 5 5 4 3 3 4 3 3 5 5 5 4 3 3 4 3 3
46902 +5 5 5 6 6 6 6 6 6 4 0 0 6 6 6 6 6 6
46903 +6 6 6 125 124 125 174 174 174 220 221 221 220 221 221 193 200 203
46904 +193 200 203 193 200 203 193 200 203 193 200 203 220 221 221 158 157 158
46905 +60 73 81 6 6 6 4 0 0 4 0 0 5 5 5 6 6 6
46906 +5 5 5 5 5 5 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 4 4 4 4 4 4 4 4 4 4 4 4
46912 +4 4 4 4 4 4
46913 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46914 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46915 +4 4 4 5 5 5 5 5 5 4 3 3 5 5 5 4 3 3
46916 +5 5 5 5 5 5 6 6 6 6 6 6 4 0 0 4 0 0
46917 +4 0 0 4 0 0 26 28 28 125 124 125 174 174 174 193 200 203
46918 +193 200 203 174 174 174 193 200 203 167 166 167 125 124 125 6 6 6
46919 +6 6 6 6 6 6 4 0 0 6 6 6 6 6 6 5 5 5
46920 +4 3 3 5 5 5 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 4 4 4 4 4 4 4 4 4 4 4 4
46926 +4 4 4 4 4 4
46927 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46928 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46929 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
46930 +4 3 3 6 6 6 4 0 0 6 6 6 6 6 6 6 6 6
46931 +6 6 6 4 0 0 4 0 0 6 6 6 37 38 37 125 124 125
46932 +153 152 153 131 129 131 125 124 125 37 38 37 6 6 6 6 6 6
46933 +6 6 6 4 0 0 6 6 6 6 6 6 4 3 3 5 5 5
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 4 4 4 4 4 4 4 4 4 4 4 4
46940 +4 4 4 4 4 4
46941 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46942 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46943 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46944 +4 4 4 5 5 5 5 5 5 4 3 3 5 5 5 4 3 3
46945 +6 6 6 6 6 6 4 0 0 4 0 0 6 6 6 6 6 6
46946 +24 26 27 24 26 27 6 6 6 6 6 6 6 6 6 4 0 0
46947 +6 6 6 6 6 6 4 0 0 6 6 6 5 5 5 4 3 3
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 4 4 4 4 4 4 4 4 4 4 4 4
46954 +4 4 4 4 4 4
46955 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46956 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46957 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46958 +4 4 4 4 4 4 5 5 5 4 3 3 5 5 5 6 6 6
46959 +4 0 0 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
46960 +6 6 6 6 6 6 6 6 6 4 0 0 6 6 6 6 6 6
46961 +4 0 0 6 6 6 6 6 6 4 3 3 5 5 5 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 4 4 4 4 4 4 4 4 4 4 4 4
46968 +4 4 4 4 4 4
46969 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46970 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46971 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46972 +4 4 4 4 4 4 4 4 4 5 5 5 4 3 3 5 5 5
46973 +5 5 5 5 5 5 4 0 0 6 6 6 4 0 0 6 6 6
46974 +6 6 6 6 6 6 6 6 6 4 0 0 6 6 6 4 0 0
46975 +6 6 6 4 3 3 5 5 5 4 3 3 5 5 5 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 4 4 4 4 4 4 4 4 4 4 4 4
46982 +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 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46985 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46986 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
46987 +4 3 3 6 6 6 4 3 3 6 6 6 6 6 6 6 6 6
46988 +4 0 0 6 6 6 4 0 0 6 6 6 6 6 6 6 6 6
46989 +6 6 6 4 3 3 5 5 5 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 4 4 4 4 4 4 4 4 4 4 4 4
46996 +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 4 4 4
46999 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47000 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47001 +4 4 4 5 5 5 4 3 3 5 5 5 4 0 0 6 6 6
47002 +6 6 6 4 0 0 6 6 6 6 6 6 4 0 0 6 6 6
47003 +4 3 3 5 5 5 5 5 5 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 4 4 4 4 4 4 4 4 4 4 4 4
47010 +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 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47014 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47015 +4 4 4 5 5 5 4 3 3 5 5 5 6 6 6 4 3 3
47016 +4 3 3 6 6 6 6 6 6 4 3 3 6 6 6 4 3 3
47017 +5 5 5 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 4 4 4 4 4 4 4 4 4 4 4 4
47024 +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 4 4 4 4 4 4 4 4 4 4 4 4
47028 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47029 +4 4 4 4 4 4 4 4 4 5 5 5 4 3 3 6 6 6
47030 +5 5 5 4 3 3 4 3 3 4 3 3 5 5 5 5 5 5
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 4 4 4 4 4 4 4 4 4 4 4 4
47038 +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 4 4 4 4 4 4 4 4 4
47042 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47043 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 4 3 3
47044 +5 5 5 4 3 3 5 5 5 5 5 5 4 4 4 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 4 4 4 4 4 4 4 4 4 4 4 4
47052 +4 4 4 4 4 4
47053 diff --git a/drivers/video/mb862xx/mb862xxfb_accel.c b/drivers/video/mb862xx/mb862xxfb_accel.c
47054 index fe92eed..106e085 100644
47055 --- a/drivers/video/mb862xx/mb862xxfb_accel.c
47056 +++ b/drivers/video/mb862xx/mb862xxfb_accel.c
47057 @@ -312,14 +312,18 @@ void mb862xxfb_init_accel(struct fb_info *info, int xres)
47058 struct mb862xxfb_par *par = info->par;
47059
47060 if (info->var.bits_per_pixel == 32) {
47061 - info->fbops->fb_fillrect = cfb_fillrect;
47062 - info->fbops->fb_copyarea = cfb_copyarea;
47063 - info->fbops->fb_imageblit = cfb_imageblit;
47064 + pax_open_kernel();
47065 + *(void **)&info->fbops->fb_fillrect = cfb_fillrect;
47066 + *(void **)&info->fbops->fb_copyarea = cfb_copyarea;
47067 + *(void **)&info->fbops->fb_imageblit = cfb_imageblit;
47068 + pax_close_kernel();
47069 } else {
47070 outreg(disp, GC_L0EM, 3);
47071 - info->fbops->fb_fillrect = mb86290fb_fillrect;
47072 - info->fbops->fb_copyarea = mb86290fb_copyarea;
47073 - info->fbops->fb_imageblit = mb86290fb_imageblit;
47074 + pax_open_kernel();
47075 + *(void **)&info->fbops->fb_fillrect = mb86290fb_fillrect;
47076 + *(void **)&info->fbops->fb_copyarea = mb86290fb_copyarea;
47077 + *(void **)&info->fbops->fb_imageblit = mb86290fb_imageblit;
47078 + pax_close_kernel();
47079 }
47080 outreg(draw, GDC_REG_DRAW_BASE, 0);
47081 outreg(draw, GDC_REG_MODE_MISC, 0x8000);
47082 diff --git a/drivers/video/nvidia/nvidia.c b/drivers/video/nvidia/nvidia.c
47083 index ff22871..b129bed 100644
47084 --- a/drivers/video/nvidia/nvidia.c
47085 +++ b/drivers/video/nvidia/nvidia.c
47086 @@ -669,19 +669,23 @@ static int nvidiafb_set_par(struct fb_info *info)
47087 info->fix.line_length = (info->var.xres_virtual *
47088 info->var.bits_per_pixel) >> 3;
47089 if (info->var.accel_flags) {
47090 - info->fbops->fb_imageblit = nvidiafb_imageblit;
47091 - info->fbops->fb_fillrect = nvidiafb_fillrect;
47092 - info->fbops->fb_copyarea = nvidiafb_copyarea;
47093 - info->fbops->fb_sync = nvidiafb_sync;
47094 + pax_open_kernel();
47095 + *(void **)&info->fbops->fb_imageblit = nvidiafb_imageblit;
47096 + *(void **)&info->fbops->fb_fillrect = nvidiafb_fillrect;
47097 + *(void **)&info->fbops->fb_copyarea = nvidiafb_copyarea;
47098 + *(void **)&info->fbops->fb_sync = nvidiafb_sync;
47099 + pax_close_kernel();
47100 info->pixmap.scan_align = 4;
47101 info->flags &= ~FBINFO_HWACCEL_DISABLED;
47102 info->flags |= FBINFO_READS_FAST;
47103 NVResetGraphics(info);
47104 } else {
47105 - info->fbops->fb_imageblit = cfb_imageblit;
47106 - info->fbops->fb_fillrect = cfb_fillrect;
47107 - info->fbops->fb_copyarea = cfb_copyarea;
47108 - info->fbops->fb_sync = NULL;
47109 + pax_open_kernel();
47110 + *(void **)&info->fbops->fb_imageblit = cfb_imageblit;
47111 + *(void **)&info->fbops->fb_fillrect = cfb_fillrect;
47112 + *(void **)&info->fbops->fb_copyarea = cfb_copyarea;
47113 + *(void **)&info->fbops->fb_sync = NULL;
47114 + pax_close_kernel();
47115 info->pixmap.scan_align = 1;
47116 info->flags |= FBINFO_HWACCEL_DISABLED;
47117 info->flags &= ~FBINFO_READS_FAST;
47118 @@ -1173,8 +1177,11 @@ static int nvidia_set_fbinfo(struct fb_info *info)
47119 info->pixmap.size = 8 * 1024;
47120 info->pixmap.flags = FB_PIXMAP_SYSTEM;
47121
47122 - if (!hwcur)
47123 - info->fbops->fb_cursor = NULL;
47124 + if (!hwcur) {
47125 + pax_open_kernel();
47126 + *(void **)&info->fbops->fb_cursor = NULL;
47127 + pax_close_kernel();
47128 + }
47129
47130 info->var.accel_flags = (!noaccel);
47131
47132 diff --git a/drivers/video/s1d13xxxfb.c b/drivers/video/s1d13xxxfb.c
47133 index 76d9053..dec2bfd 100644
47134 --- a/drivers/video/s1d13xxxfb.c
47135 +++ b/drivers/video/s1d13xxxfb.c
47136 @@ -881,8 +881,10 @@ static int s1d13xxxfb_probe(struct platform_device *pdev)
47137
47138 switch(prod_id) {
47139 case S1D13506_PROD_ID: /* activate acceleration */
47140 - s1d13xxxfb_fbops.fb_fillrect = s1d13xxxfb_bitblt_solidfill;
47141 - s1d13xxxfb_fbops.fb_copyarea = s1d13xxxfb_bitblt_copyarea;
47142 + pax_open_kernel();
47143 + *(void **)&s1d13xxxfb_fbops.fb_fillrect = s1d13xxxfb_bitblt_solidfill;
47144 + *(void **)&s1d13xxxfb_fbops.fb_copyarea = s1d13xxxfb_bitblt_copyarea;
47145 + pax_close_kernel();
47146 info->flags = FBINFO_DEFAULT | FBINFO_HWACCEL_YPAN |
47147 FBINFO_HWACCEL_FILLRECT | FBINFO_HWACCEL_COPYAREA;
47148 break;
47149 diff --git a/drivers/video/smscufx.c b/drivers/video/smscufx.c
47150 index 97bd662..39fab85 100644
47151 --- a/drivers/video/smscufx.c
47152 +++ b/drivers/video/smscufx.c
47153 @@ -1171,7 +1171,9 @@ static int ufx_ops_release(struct fb_info *info, int user)
47154 fb_deferred_io_cleanup(info);
47155 kfree(info->fbdefio);
47156 info->fbdefio = NULL;
47157 - info->fbops->fb_mmap = ufx_ops_mmap;
47158 + pax_open_kernel();
47159 + *(void **)&info->fbops->fb_mmap = ufx_ops_mmap;
47160 + pax_close_kernel();
47161 }
47162
47163 pr_debug("released /dev/fb%d user=%d count=%d",
47164 diff --git a/drivers/video/udlfb.c b/drivers/video/udlfb.c
47165 index 86d449e..8e04dc5 100644
47166 --- a/drivers/video/udlfb.c
47167 +++ b/drivers/video/udlfb.c
47168 @@ -619,11 +619,11 @@ int dlfb_handle_damage(struct dlfb_data *dev, int x, int y,
47169 dlfb_urb_completion(urb);
47170
47171 error:
47172 - atomic_add(bytes_sent, &dev->bytes_sent);
47173 - atomic_add(bytes_identical, &dev->bytes_identical);
47174 - atomic_add(width*height*2, &dev->bytes_rendered);
47175 + atomic_add_unchecked(bytes_sent, &dev->bytes_sent);
47176 + atomic_add_unchecked(bytes_identical, &dev->bytes_identical);
47177 + atomic_add_unchecked(width*height*2, &dev->bytes_rendered);
47178 end_cycles = get_cycles();
47179 - atomic_add(((unsigned int) ((end_cycles - start_cycles)
47180 + atomic_add_unchecked(((unsigned int) ((end_cycles - start_cycles)
47181 >> 10)), /* Kcycles */
47182 &dev->cpu_kcycles_used);
47183
47184 @@ -744,11 +744,11 @@ static void dlfb_dpy_deferred_io(struct fb_info *info,
47185 dlfb_urb_completion(urb);
47186
47187 error:
47188 - atomic_add(bytes_sent, &dev->bytes_sent);
47189 - atomic_add(bytes_identical, &dev->bytes_identical);
47190 - atomic_add(bytes_rendered, &dev->bytes_rendered);
47191 + atomic_add_unchecked(bytes_sent, &dev->bytes_sent);
47192 + atomic_add_unchecked(bytes_identical, &dev->bytes_identical);
47193 + atomic_add_unchecked(bytes_rendered, &dev->bytes_rendered);
47194 end_cycles = get_cycles();
47195 - atomic_add(((unsigned int) ((end_cycles - start_cycles)
47196 + atomic_add_unchecked(((unsigned int) ((end_cycles - start_cycles)
47197 >> 10)), /* Kcycles */
47198 &dev->cpu_kcycles_used);
47199 }
47200 @@ -989,7 +989,9 @@ static int dlfb_ops_release(struct fb_info *info, int user)
47201 fb_deferred_io_cleanup(info);
47202 kfree(info->fbdefio);
47203 info->fbdefio = NULL;
47204 - info->fbops->fb_mmap = dlfb_ops_mmap;
47205 + pax_open_kernel();
47206 + *(void **)&info->fbops->fb_mmap = dlfb_ops_mmap;
47207 + pax_close_kernel();
47208 }
47209
47210 pr_warn("released /dev/fb%d user=%d count=%d\n",
47211 @@ -1372,7 +1374,7 @@ static ssize_t metrics_bytes_rendered_show(struct device *fbdev,
47212 struct fb_info *fb_info = dev_get_drvdata(fbdev);
47213 struct dlfb_data *dev = fb_info->par;
47214 return snprintf(buf, PAGE_SIZE, "%u\n",
47215 - atomic_read(&dev->bytes_rendered));
47216 + atomic_read_unchecked(&dev->bytes_rendered));
47217 }
47218
47219 static ssize_t metrics_bytes_identical_show(struct device *fbdev,
47220 @@ -1380,7 +1382,7 @@ static ssize_t metrics_bytes_identical_show(struct device *fbdev,
47221 struct fb_info *fb_info = dev_get_drvdata(fbdev);
47222 struct dlfb_data *dev = fb_info->par;
47223 return snprintf(buf, PAGE_SIZE, "%u\n",
47224 - atomic_read(&dev->bytes_identical));
47225 + atomic_read_unchecked(&dev->bytes_identical));
47226 }
47227
47228 static ssize_t metrics_bytes_sent_show(struct device *fbdev,
47229 @@ -1388,7 +1390,7 @@ static ssize_t metrics_bytes_sent_show(struct device *fbdev,
47230 struct fb_info *fb_info = dev_get_drvdata(fbdev);
47231 struct dlfb_data *dev = fb_info->par;
47232 return snprintf(buf, PAGE_SIZE, "%u\n",
47233 - atomic_read(&dev->bytes_sent));
47234 + atomic_read_unchecked(&dev->bytes_sent));
47235 }
47236
47237 static ssize_t metrics_cpu_kcycles_used_show(struct device *fbdev,
47238 @@ -1396,7 +1398,7 @@ static ssize_t metrics_cpu_kcycles_used_show(struct device *fbdev,
47239 struct fb_info *fb_info = dev_get_drvdata(fbdev);
47240 struct dlfb_data *dev = fb_info->par;
47241 return snprintf(buf, PAGE_SIZE, "%u\n",
47242 - atomic_read(&dev->cpu_kcycles_used));
47243 + atomic_read_unchecked(&dev->cpu_kcycles_used));
47244 }
47245
47246 static ssize_t edid_show(
47247 @@ -1456,10 +1458,10 @@ static ssize_t metrics_reset_store(struct device *fbdev,
47248 struct fb_info *fb_info = dev_get_drvdata(fbdev);
47249 struct dlfb_data *dev = fb_info->par;
47250
47251 - atomic_set(&dev->bytes_rendered, 0);
47252 - atomic_set(&dev->bytes_identical, 0);
47253 - atomic_set(&dev->bytes_sent, 0);
47254 - atomic_set(&dev->cpu_kcycles_used, 0);
47255 + atomic_set_unchecked(&dev->bytes_rendered, 0);
47256 + atomic_set_unchecked(&dev->bytes_identical, 0);
47257 + atomic_set_unchecked(&dev->bytes_sent, 0);
47258 + atomic_set_unchecked(&dev->cpu_kcycles_used, 0);
47259
47260 return count;
47261 }
47262 diff --git a/drivers/video/uvesafb.c b/drivers/video/uvesafb.c
47263 index b75db01..ad2f34a 100644
47264 --- a/drivers/video/uvesafb.c
47265 +++ b/drivers/video/uvesafb.c
47266 @@ -19,6 +19,7 @@
47267 #include <linux/io.h>
47268 #include <linux/mutex.h>
47269 #include <linux/slab.h>
47270 +#include <linux/moduleloader.h>
47271 #include <video/edid.h>
47272 #include <video/uvesafb.h>
47273 #ifdef CONFIG_X86
47274 @@ -569,10 +570,32 @@ static int uvesafb_vbe_getpmi(struct uvesafb_ktask *task,
47275 if ((task->t.regs.eax & 0xffff) != 0x4f || task->t.regs.es < 0xc000) {
47276 par->pmi_setpal = par->ypan = 0;
47277 } else {
47278 +
47279 +#ifdef CONFIG_PAX_KERNEXEC
47280 +#ifdef CONFIG_MODULES
47281 + par->pmi_code = module_alloc_exec((u16)task->t.regs.ecx);
47282 +#endif
47283 + if (!par->pmi_code) {
47284 + par->pmi_setpal = par->ypan = 0;
47285 + return 0;
47286 + }
47287 +#endif
47288 +
47289 par->pmi_base = (u16 *)phys_to_virt(((u32)task->t.regs.es << 4)
47290 + task->t.regs.edi);
47291 +
47292 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
47293 + pax_open_kernel();
47294 + memcpy(par->pmi_code, par->pmi_base, (u16)task->t.regs.ecx);
47295 + pax_close_kernel();
47296 +
47297 + par->pmi_start = ktva_ktla(par->pmi_code + par->pmi_base[1]);
47298 + par->pmi_pal = ktva_ktla(par->pmi_code + par->pmi_base[2]);
47299 +#else
47300 par->pmi_start = (u8 *)par->pmi_base + par->pmi_base[1];
47301 par->pmi_pal = (u8 *)par->pmi_base + par->pmi_base[2];
47302 +#endif
47303 +
47304 printk(KERN_INFO "uvesafb: protected mode interface info at "
47305 "%04x:%04x\n",
47306 (u16)task->t.regs.es, (u16)task->t.regs.edi);
47307 @@ -817,13 +840,14 @@ static int uvesafb_vbe_init(struct fb_info *info)
47308 par->ypan = ypan;
47309
47310 if (par->pmi_setpal || par->ypan) {
47311 +#if !defined(CONFIG_MODULES) || !defined(CONFIG_PAX_KERNEXEC)
47312 if (__supported_pte_mask & _PAGE_NX) {
47313 par->pmi_setpal = par->ypan = 0;
47314 printk(KERN_WARNING "uvesafb: NX protection is actively."
47315 "We have better not to use the PMI.\n");
47316 - } else {
47317 + } else
47318 +#endif
47319 uvesafb_vbe_getpmi(task, par);
47320 - }
47321 }
47322 #else
47323 /* The protected mode interface is not available on non-x86. */
47324 @@ -1457,8 +1481,11 @@ static void uvesafb_init_info(struct fb_info *info, struct vbe_mode_ib *mode)
47325 info->fix.ywrapstep = (par->ypan > 1) ? 1 : 0;
47326
47327 /* Disable blanking if the user requested so. */
47328 - if (!blank)
47329 - info->fbops->fb_blank = NULL;
47330 + if (!blank) {
47331 + pax_open_kernel();
47332 + *(void **)&info->fbops->fb_blank = NULL;
47333 + pax_close_kernel();
47334 + }
47335
47336 /*
47337 * Find out how much IO memory is required for the mode with
47338 @@ -1534,8 +1561,11 @@ static void uvesafb_init_info(struct fb_info *info, struct vbe_mode_ib *mode)
47339 info->flags = FBINFO_FLAG_DEFAULT |
47340 (par->ypan ? FBINFO_HWACCEL_YPAN : 0);
47341
47342 - if (!par->ypan)
47343 - info->fbops->fb_pan_display = NULL;
47344 + if (!par->ypan) {
47345 + pax_open_kernel();
47346 + *(void **)&info->fbops->fb_pan_display = NULL;
47347 + pax_close_kernel();
47348 + }
47349 }
47350
47351 static void uvesafb_init_mtrr(struct fb_info *info)
47352 @@ -1836,6 +1866,11 @@ out:
47353 if (par->vbe_modes)
47354 kfree(par->vbe_modes);
47355
47356 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
47357 + if (par->pmi_code)
47358 + module_free_exec(NULL, par->pmi_code);
47359 +#endif
47360 +
47361 framebuffer_release(info);
47362 return err;
47363 }
47364 @@ -1862,6 +1897,12 @@ static int uvesafb_remove(struct platform_device *dev)
47365 kfree(par->vbe_state_orig);
47366 if (par->vbe_state_saved)
47367 kfree(par->vbe_state_saved);
47368 +
47369 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
47370 + if (par->pmi_code)
47371 + module_free_exec(NULL, par->pmi_code);
47372 +#endif
47373 +
47374 }
47375
47376 framebuffer_release(info);
47377 diff --git a/drivers/video/vesafb.c b/drivers/video/vesafb.c
47378 index 501b340..d80aa17 100644
47379 --- a/drivers/video/vesafb.c
47380 +++ b/drivers/video/vesafb.c
47381 @@ -9,6 +9,7 @@
47382 */
47383
47384 #include <linux/module.h>
47385 +#include <linux/moduleloader.h>
47386 #include <linux/kernel.h>
47387 #include <linux/errno.h>
47388 #include <linux/string.h>
47389 @@ -52,8 +53,8 @@ static int vram_remap __initdata; /* Set amount of memory to be used */
47390 static int vram_total __initdata; /* Set total amount of memory */
47391 static int pmi_setpal __read_mostly = 1; /* pmi for palette changes ??? */
47392 static int ypan __read_mostly; /* 0..nothing, 1..ypan, 2..ywrap */
47393 -static void (*pmi_start)(void) __read_mostly;
47394 -static void (*pmi_pal) (void) __read_mostly;
47395 +static void (*pmi_start)(void) __read_only;
47396 +static void (*pmi_pal) (void) __read_only;
47397 static int depth __read_mostly;
47398 static int vga_compat __read_mostly;
47399 /* --------------------------------------------------------------------- */
47400 @@ -233,6 +234,7 @@ static int __init vesafb_probe(struct platform_device *dev)
47401 unsigned int size_vmode;
47402 unsigned int size_remap;
47403 unsigned int size_total;
47404 + void *pmi_code = NULL;
47405
47406 if (screen_info.orig_video_isVGA != VIDEO_TYPE_VLFB)
47407 return -ENODEV;
47408 @@ -275,10 +277,6 @@ static int __init vesafb_probe(struct platform_device *dev)
47409 size_remap = size_total;
47410 vesafb_fix.smem_len = size_remap;
47411
47412 -#ifndef __i386__
47413 - screen_info.vesapm_seg = 0;
47414 -#endif
47415 -
47416 if (!request_mem_region(vesafb_fix.smem_start, size_total, "vesafb")) {
47417 printk(KERN_WARNING
47418 "vesafb: cannot reserve video memory at 0x%lx\n",
47419 @@ -307,9 +305,21 @@ static int __init vesafb_probe(struct platform_device *dev)
47420 printk(KERN_INFO "vesafb: mode is %dx%dx%d, linelength=%d, pages=%d\n",
47421 vesafb_defined.xres, vesafb_defined.yres, vesafb_defined.bits_per_pixel, vesafb_fix.line_length, screen_info.pages);
47422
47423 +#ifdef __i386__
47424 +
47425 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
47426 + pmi_code = module_alloc_exec(screen_info.vesapm_size);
47427 + if (!pmi_code)
47428 +#elif !defined(CONFIG_PAX_KERNEXEC)
47429 + if (0)
47430 +#endif
47431 +
47432 +#endif
47433 + screen_info.vesapm_seg = 0;
47434 +
47435 if (screen_info.vesapm_seg) {
47436 - printk(KERN_INFO "vesafb: protected mode interface info at %04x:%04x\n",
47437 - screen_info.vesapm_seg,screen_info.vesapm_off);
47438 + printk(KERN_INFO "vesafb: protected mode interface info at %04x:%04x %04x bytes\n",
47439 + screen_info.vesapm_seg,screen_info.vesapm_off,screen_info.vesapm_size);
47440 }
47441
47442 if (screen_info.vesapm_seg < 0xc000)
47443 @@ -317,9 +327,25 @@ static int __init vesafb_probe(struct platform_device *dev)
47444
47445 if (ypan || pmi_setpal) {
47446 unsigned short *pmi_base;
47447 +
47448 pmi_base = (unsigned short*)phys_to_virt(((unsigned long)screen_info.vesapm_seg << 4) + screen_info.vesapm_off);
47449 - pmi_start = (void*)((char*)pmi_base + pmi_base[1]);
47450 - pmi_pal = (void*)((char*)pmi_base + pmi_base[2]);
47451 +
47452 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
47453 + pax_open_kernel();
47454 + memcpy(pmi_code, pmi_base, screen_info.vesapm_size);
47455 +#else
47456 + pmi_code = pmi_base;
47457 +#endif
47458 +
47459 + pmi_start = (void*)((char*)pmi_code + pmi_base[1]);
47460 + pmi_pal = (void*)((char*)pmi_code + pmi_base[2]);
47461 +
47462 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
47463 + pmi_start = ktva_ktla(pmi_start);
47464 + pmi_pal = ktva_ktla(pmi_pal);
47465 + pax_close_kernel();
47466 +#endif
47467 +
47468 printk(KERN_INFO "vesafb: pmi: set display start = %p, set palette = %p\n",pmi_start,pmi_pal);
47469 if (pmi_base[3]) {
47470 printk(KERN_INFO "vesafb: pmi: ports = ");
47471 @@ -472,8 +498,11 @@ static int __init vesafb_probe(struct platform_device *dev)
47472 info->flags = FBINFO_FLAG_DEFAULT | FBINFO_MISC_FIRMWARE |
47473 (ypan ? FBINFO_HWACCEL_YPAN : 0);
47474
47475 - if (!ypan)
47476 - info->fbops->fb_pan_display = NULL;
47477 + if (!ypan) {
47478 + pax_open_kernel();
47479 + *(void **)&info->fbops->fb_pan_display = NULL;
47480 + pax_close_kernel();
47481 + }
47482
47483 if (fb_alloc_cmap(&info->cmap, 256, 0) < 0) {
47484 err = -ENOMEM;
47485 @@ -488,6 +517,11 @@ static int __init vesafb_probe(struct platform_device *dev)
47486 info->node, info->fix.id);
47487 return 0;
47488 err:
47489 +
47490 +#if defined(__i386__) && defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
47491 + module_free_exec(NULL, pmi_code);
47492 +#endif
47493 +
47494 if (info->screen_base)
47495 iounmap(info->screen_base);
47496 framebuffer_release(info);
47497 diff --git a/drivers/video/via/via_clock.h b/drivers/video/via/via_clock.h
47498 index 88714ae..16c2e11 100644
47499 --- a/drivers/video/via/via_clock.h
47500 +++ b/drivers/video/via/via_clock.h
47501 @@ -56,7 +56,7 @@ struct via_clock {
47502
47503 void (*set_engine_pll_state)(u8 state);
47504 void (*set_engine_pll)(struct via_pll_config config);
47505 -};
47506 +} __no_const;
47507
47508
47509 static inline u32 get_pll_internal_frequency(u32 ref_freq,
47510 diff --git a/drivers/xen/xenfs/xenstored.c b/drivers/xen/xenfs/xenstored.c
47511 index fef20db..d28b1ab 100644
47512 --- a/drivers/xen/xenfs/xenstored.c
47513 +++ b/drivers/xen/xenfs/xenstored.c
47514 @@ -24,7 +24,12 @@ static int xsd_release(struct inode *inode, struct file *file)
47515 static int xsd_kva_open(struct inode *inode, struct file *file)
47516 {
47517 file->private_data = (void *)kasprintf(GFP_KERNEL, "0x%p",
47518 +#ifdef CONFIG_GRKERNSEC_HIDESYM
47519 + NULL);
47520 +#else
47521 xen_store_interface);
47522 +#endif
47523 +
47524 if (!file->private_data)
47525 return -ENOMEM;
47526 return 0;
47527 diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c
47528 index 890bed5..17ae73e 100644
47529 --- a/fs/9p/vfs_inode.c
47530 +++ b/fs/9p/vfs_inode.c
47531 @@ -1329,7 +1329,7 @@ static void *v9fs_vfs_follow_link(struct dentry *dentry, struct nameidata *nd)
47532 void
47533 v9fs_vfs_put_link(struct dentry *dentry, struct nameidata *nd, void *p)
47534 {
47535 - char *s = nd_get_link(nd);
47536 + const char *s = nd_get_link(nd);
47537
47538 p9_debug(P9_DEBUG_VFS, " %s %s\n",
47539 dentry->d_name.name, IS_ERR(s) ? "<error>" : s);
47540 diff --git a/fs/Kconfig.binfmt b/fs/Kconfig.binfmt
47541 index 0efd152..b5802ad 100644
47542 --- a/fs/Kconfig.binfmt
47543 +++ b/fs/Kconfig.binfmt
47544 @@ -89,7 +89,7 @@ config HAVE_AOUT
47545
47546 config BINFMT_AOUT
47547 tristate "Kernel support for a.out and ECOFF binaries"
47548 - depends on HAVE_AOUT
47549 + depends on HAVE_AOUT && BROKEN
47550 ---help---
47551 A.out (Assembler.OUTput) is a set of formats for libraries and
47552 executables used in the earliest versions of UNIX. Linux used
47553 diff --git a/fs/aio.c b/fs/aio.c
47554 index 71f613c..9d01f1f 100644
47555 --- a/fs/aio.c
47556 +++ b/fs/aio.c
47557 @@ -111,7 +111,7 @@ static int aio_setup_ring(struct kioctx *ctx)
47558 size += sizeof(struct io_event) * nr_events;
47559 nr_pages = (size + PAGE_SIZE-1) >> PAGE_SHIFT;
47560
47561 - if (nr_pages < 0)
47562 + if (nr_pages <= 0)
47563 return -EINVAL;
47564
47565 nr_events = (PAGE_SIZE * nr_pages - sizeof(struct aio_ring)) / sizeof(struct io_event);
47566 @@ -1373,18 +1373,19 @@ static ssize_t aio_fsync(struct kiocb *iocb)
47567 static ssize_t aio_setup_vectored_rw(int type, struct kiocb *kiocb, bool compat)
47568 {
47569 ssize_t ret;
47570 + struct iovec iovstack;
47571
47572 #ifdef CONFIG_COMPAT
47573 if (compat)
47574 ret = compat_rw_copy_check_uvector(type,
47575 (struct compat_iovec __user *)kiocb->ki_buf,
47576 - kiocb->ki_nbytes, 1, &kiocb->ki_inline_vec,
47577 + kiocb->ki_nbytes, 1, &iovstack,
47578 &kiocb->ki_iovec);
47579 else
47580 #endif
47581 ret = rw_copy_check_uvector(type,
47582 (struct iovec __user *)kiocb->ki_buf,
47583 - kiocb->ki_nbytes, 1, &kiocb->ki_inline_vec,
47584 + kiocb->ki_nbytes, 1, &iovstack,
47585 &kiocb->ki_iovec);
47586 if (ret < 0)
47587 goto out;
47588 @@ -1393,6 +1394,10 @@ static ssize_t aio_setup_vectored_rw(int type, struct kiocb *kiocb, bool compat)
47589 if (ret < 0)
47590 goto out;
47591
47592 + if (kiocb->ki_iovec == &iovstack) {
47593 + kiocb->ki_inline_vec = iovstack;
47594 + kiocb->ki_iovec = &kiocb->ki_inline_vec;
47595 + }
47596 kiocb->ki_nr_segs = kiocb->ki_nbytes;
47597 kiocb->ki_cur_seg = 0;
47598 /* ki_nbytes/left now reflect bytes instead of segs */
47599 diff --git a/fs/attr.c b/fs/attr.c
47600 index 1449adb..a2038c2 100644
47601 --- a/fs/attr.c
47602 +++ b/fs/attr.c
47603 @@ -102,6 +102,7 @@ int inode_newsize_ok(const struct inode *inode, loff_t offset)
47604 unsigned long limit;
47605
47606 limit = rlimit(RLIMIT_FSIZE);
47607 + gr_learn_resource(current, RLIMIT_FSIZE, (unsigned long)offset, 1);
47608 if (limit != RLIM_INFINITY && offset > limit)
47609 goto out_sig;
47610 if (offset > inode->i_sb->s_maxbytes)
47611 diff --git a/fs/autofs4/waitq.c b/fs/autofs4/waitq.c
47612 index 03bc1d3..6205356 100644
47613 --- a/fs/autofs4/waitq.c
47614 +++ b/fs/autofs4/waitq.c
47615 @@ -61,7 +61,7 @@ static int autofs4_write(struct autofs_sb_info *sbi,
47616 {
47617 unsigned long sigpipe, flags;
47618 mm_segment_t fs;
47619 - const char *data = (const char *)addr;
47620 + const char __user *data = (const char __force_user *)addr;
47621 ssize_t wr = 0;
47622
47623 sigpipe = sigismember(&current->pending.signal, SIGPIPE);
47624 @@ -348,6 +348,10 @@ static int validate_request(struct autofs_wait_queue **wait,
47625 return 1;
47626 }
47627
47628 +#ifdef CONFIG_GRKERNSEC_HIDESYM
47629 +static atomic_unchecked_t autofs_dummy_name_id = ATOMIC_INIT(0);
47630 +#endif
47631 +
47632 int autofs4_wait(struct autofs_sb_info *sbi, struct dentry *dentry,
47633 enum autofs_notify notify)
47634 {
47635 @@ -381,7 +385,12 @@ int autofs4_wait(struct autofs_sb_info *sbi, struct dentry *dentry,
47636
47637 /* If this is a direct mount request create a dummy name */
47638 if (IS_ROOT(dentry) && autofs_type_trigger(sbi->type))
47639 +#ifdef CONFIG_GRKERNSEC_HIDESYM
47640 + /* this name does get written to userland via autofs4_write() */
47641 + qstr.len = sprintf(name, "%08x", atomic_inc_return_unchecked(&autofs_dummy_name_id));
47642 +#else
47643 qstr.len = sprintf(name, "%p", dentry);
47644 +#endif
47645 else {
47646 qstr.len = autofs4_getpath(sbi, dentry, &name);
47647 if (!qstr.len) {
47648 diff --git a/fs/befs/endian.h b/fs/befs/endian.h
47649 index 2722387..c8dd2a7 100644
47650 --- a/fs/befs/endian.h
47651 +++ b/fs/befs/endian.h
47652 @@ -11,7 +11,7 @@
47653
47654 #include <asm/byteorder.h>
47655
47656 -static inline u64
47657 +static inline u64 __intentional_overflow(-1)
47658 fs64_to_cpu(const struct super_block *sb, fs64 n)
47659 {
47660 if (BEFS_SB(sb)->byte_order == BEFS_BYTESEX_LE)
47661 @@ -29,7 +29,7 @@ cpu_to_fs64(const struct super_block *sb, u64 n)
47662 return (__force fs64)cpu_to_be64(n);
47663 }
47664
47665 -static inline u32
47666 +static inline u32 __intentional_overflow(-1)
47667 fs32_to_cpu(const struct super_block *sb, fs32 n)
47668 {
47669 if (BEFS_SB(sb)->byte_order == BEFS_BYTESEX_LE)
47670 diff --git a/fs/befs/linuxvfs.c b/fs/befs/linuxvfs.c
47671 index 2b3bda8..6a2d4be 100644
47672 --- a/fs/befs/linuxvfs.c
47673 +++ b/fs/befs/linuxvfs.c
47674 @@ -510,7 +510,7 @@ static void befs_put_link(struct dentry *dentry, struct nameidata *nd, void *p)
47675 {
47676 befs_inode_info *befs_ino = BEFS_I(dentry->d_inode);
47677 if (befs_ino->i_flags & BEFS_LONG_SYMLINK) {
47678 - char *link = nd_get_link(nd);
47679 + const char *link = nd_get_link(nd);
47680 if (!IS_ERR(link))
47681 kfree(link);
47682 }
47683 diff --git a/fs/binfmt_aout.c b/fs/binfmt_aout.c
47684 index 6043567..16a9239 100644
47685 --- a/fs/binfmt_aout.c
47686 +++ b/fs/binfmt_aout.c
47687 @@ -16,6 +16,7 @@
47688 #include <linux/string.h>
47689 #include <linux/fs.h>
47690 #include <linux/file.h>
47691 +#include <linux/security.h>
47692 #include <linux/stat.h>
47693 #include <linux/fcntl.h>
47694 #include <linux/ptrace.h>
47695 @@ -59,6 +60,8 @@ static int aout_core_dump(struct coredump_params *cprm)
47696 #endif
47697 # define START_STACK(u) ((void __user *)u.start_stack)
47698
47699 + memset(&dump, 0, sizeof(dump));
47700 +
47701 fs = get_fs();
47702 set_fs(KERNEL_DS);
47703 has_dumped = 1;
47704 @@ -70,10 +73,12 @@ static int aout_core_dump(struct coredump_params *cprm)
47705
47706 /* If the size of the dump file exceeds the rlimit, then see what would happen
47707 if we wrote the stack, but not the data area. */
47708 + gr_learn_resource(current, RLIMIT_CORE, (dump.u_dsize + dump.u_ssize+1) * PAGE_SIZE, 1);
47709 if ((dump.u_dsize + dump.u_ssize+1) * PAGE_SIZE > cprm->limit)
47710 dump.u_dsize = 0;
47711
47712 /* Make sure we have enough room to write the stack and data areas. */
47713 + gr_learn_resource(current, RLIMIT_CORE, (dump.u_ssize + 1) * PAGE_SIZE, 1);
47714 if ((dump.u_ssize + 1) * PAGE_SIZE > cprm->limit)
47715 dump.u_ssize = 0;
47716
47717 @@ -234,6 +239,8 @@ static int load_aout_binary(struct linux_binprm * bprm)
47718 rlim = rlimit(RLIMIT_DATA);
47719 if (rlim >= RLIM_INFINITY)
47720 rlim = ~0;
47721 +
47722 + gr_learn_resource(current, RLIMIT_DATA, ex.a_data + ex.a_bss, 1);
47723 if (ex.a_data + ex.a_bss > rlim)
47724 return -ENOMEM;
47725
47726 @@ -268,6 +275,27 @@ static int load_aout_binary(struct linux_binprm * bprm)
47727
47728 install_exec_creds(bprm);
47729
47730 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
47731 + current->mm->pax_flags = 0UL;
47732 +#endif
47733 +
47734 +#ifdef CONFIG_PAX_PAGEEXEC
47735 + if (!(N_FLAGS(ex) & F_PAX_PAGEEXEC)) {
47736 + current->mm->pax_flags |= MF_PAX_PAGEEXEC;
47737 +
47738 +#ifdef CONFIG_PAX_EMUTRAMP
47739 + if (N_FLAGS(ex) & F_PAX_EMUTRAMP)
47740 + current->mm->pax_flags |= MF_PAX_EMUTRAMP;
47741 +#endif
47742 +
47743 +#ifdef CONFIG_PAX_MPROTECT
47744 + if (!(N_FLAGS(ex) & F_PAX_MPROTECT))
47745 + current->mm->pax_flags |= MF_PAX_MPROTECT;
47746 +#endif
47747 +
47748 + }
47749 +#endif
47750 +
47751 if (N_MAGIC(ex) == OMAGIC) {
47752 unsigned long text_addr, map_size;
47753 loff_t pos;
47754 @@ -333,7 +361,7 @@ static int load_aout_binary(struct linux_binprm * bprm)
47755 }
47756
47757 error = vm_mmap(bprm->file, N_DATADDR(ex), ex.a_data,
47758 - PROT_READ | PROT_WRITE | PROT_EXEC,
47759 + PROT_READ | PROT_WRITE,
47760 MAP_FIXED | MAP_PRIVATE | MAP_DENYWRITE | MAP_EXECUTABLE,
47761 fd_offset + ex.a_text);
47762 if (error != N_DATADDR(ex)) {
47763 diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c
47764 index 0c42cdb..c4f1cf1 100644
47765 --- a/fs/binfmt_elf.c
47766 +++ b/fs/binfmt_elf.c
47767 @@ -33,6 +33,7 @@
47768 #include <linux/elf.h>
47769 #include <linux/utsname.h>
47770 #include <linux/coredump.h>
47771 +#include <linux/xattr.h>
47772 #include <asm/uaccess.h>
47773 #include <asm/param.h>
47774 #include <asm/page.h>
47775 @@ -59,6 +60,10 @@ static int elf_core_dump(struct coredump_params *cprm);
47776 #define elf_core_dump NULL
47777 #endif
47778
47779 +#ifdef CONFIG_PAX_MPROTECT
47780 +static void elf_handle_mprotect(struct vm_area_struct *vma, unsigned long newflags);
47781 +#endif
47782 +
47783 #if ELF_EXEC_PAGESIZE > PAGE_SIZE
47784 #define ELF_MIN_ALIGN ELF_EXEC_PAGESIZE
47785 #else
47786 @@ -78,6 +83,11 @@ static struct linux_binfmt elf_format = {
47787 .load_binary = load_elf_binary,
47788 .load_shlib = load_elf_library,
47789 .core_dump = elf_core_dump,
47790 +
47791 +#ifdef CONFIG_PAX_MPROTECT
47792 + .handle_mprotect= elf_handle_mprotect,
47793 +#endif
47794 +
47795 .min_coredump = ELF_EXEC_PAGESIZE,
47796 };
47797
47798 @@ -85,6 +95,8 @@ static struct linux_binfmt elf_format = {
47799
47800 static int set_brk(unsigned long start, unsigned long end)
47801 {
47802 + unsigned long e = end;
47803 +
47804 start = ELF_PAGEALIGN(start);
47805 end = ELF_PAGEALIGN(end);
47806 if (end > start) {
47807 @@ -93,7 +105,7 @@ static int set_brk(unsigned long start, unsigned long end)
47808 if (BAD_ADDR(addr))
47809 return addr;
47810 }
47811 - current->mm->start_brk = current->mm->brk = end;
47812 + current->mm->start_brk = current->mm->brk = e;
47813 return 0;
47814 }
47815
47816 @@ -154,12 +166,13 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
47817 elf_addr_t __user *u_rand_bytes;
47818 const char *k_platform = ELF_PLATFORM;
47819 const char *k_base_platform = ELF_BASE_PLATFORM;
47820 - unsigned char k_rand_bytes[16];
47821 + u32 k_rand_bytes[4];
47822 int items;
47823 elf_addr_t *elf_info;
47824 int ei_index = 0;
47825 const struct cred *cred = current_cred();
47826 struct vm_area_struct *vma;
47827 + unsigned long saved_auxv[AT_VECTOR_SIZE];
47828
47829 /*
47830 * In some cases (e.g. Hyper-Threading), we want to avoid L1
47831 @@ -201,8 +214,12 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
47832 * Generate 16 random bytes for userspace PRNG seeding.
47833 */
47834 get_random_bytes(k_rand_bytes, sizeof(k_rand_bytes));
47835 - u_rand_bytes = (elf_addr_t __user *)
47836 - STACK_ALLOC(p, sizeof(k_rand_bytes));
47837 + srandom32(k_rand_bytes[0] ^ random32());
47838 + srandom32(k_rand_bytes[1] ^ random32());
47839 + srandom32(k_rand_bytes[2] ^ random32());
47840 + srandom32(k_rand_bytes[3] ^ random32());
47841 + p = STACK_ROUND(p, sizeof(k_rand_bytes));
47842 + u_rand_bytes = (elf_addr_t __user *) p;
47843 if (__copy_to_user(u_rand_bytes, k_rand_bytes, sizeof(k_rand_bytes)))
47844 return -EFAULT;
47845
47846 @@ -314,9 +331,11 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
47847 return -EFAULT;
47848 current->mm->env_end = p;
47849
47850 + memcpy(saved_auxv, elf_info, ei_index * sizeof(elf_addr_t));
47851 +
47852 /* Put the elf_info on the stack in the right place. */
47853 sp = (elf_addr_t __user *)envp + 1;
47854 - if (copy_to_user(sp, elf_info, ei_index * sizeof(elf_addr_t)))
47855 + if (copy_to_user(sp, saved_auxv, ei_index * sizeof(elf_addr_t)))
47856 return -EFAULT;
47857 return 0;
47858 }
47859 @@ -380,15 +399,14 @@ static unsigned long total_mapping_size(struct elf_phdr *cmds, int nr)
47860 an ELF header */
47861
47862 static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
47863 - struct file *interpreter, unsigned long *interp_map_addr,
47864 - unsigned long no_base)
47865 + struct file *interpreter, unsigned long no_base)
47866 {
47867 struct elf_phdr *elf_phdata;
47868 struct elf_phdr *eppnt;
47869 - unsigned long load_addr = 0;
47870 + unsigned long load_addr = 0, pax_task_size = TASK_SIZE;
47871 int load_addr_set = 0;
47872 unsigned long last_bss = 0, elf_bss = 0;
47873 - unsigned long error = ~0UL;
47874 + unsigned long error = -EINVAL;
47875 unsigned long total_size;
47876 int retval, i, size;
47877
47878 @@ -434,6 +452,11 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
47879 goto out_close;
47880 }
47881
47882 +#ifdef CONFIG_PAX_SEGMEXEC
47883 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC)
47884 + pax_task_size = SEGMEXEC_TASK_SIZE;
47885 +#endif
47886 +
47887 eppnt = elf_phdata;
47888 for (i = 0; i < interp_elf_ex->e_phnum; i++, eppnt++) {
47889 if (eppnt->p_type == PT_LOAD) {
47890 @@ -457,8 +480,6 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
47891 map_addr = elf_map(interpreter, load_addr + vaddr,
47892 eppnt, elf_prot, elf_type, total_size);
47893 total_size = 0;
47894 - if (!*interp_map_addr)
47895 - *interp_map_addr = map_addr;
47896 error = map_addr;
47897 if (BAD_ADDR(map_addr))
47898 goto out_close;
47899 @@ -477,8 +498,8 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
47900 k = load_addr + eppnt->p_vaddr;
47901 if (BAD_ADDR(k) ||
47902 eppnt->p_filesz > eppnt->p_memsz ||
47903 - eppnt->p_memsz > TASK_SIZE ||
47904 - TASK_SIZE - eppnt->p_memsz < k) {
47905 + eppnt->p_memsz > pax_task_size ||
47906 + pax_task_size - eppnt->p_memsz < k) {
47907 error = -ENOMEM;
47908 goto out_close;
47909 }
47910 @@ -530,6 +551,315 @@ out:
47911 return error;
47912 }
47913
47914 +#ifdef CONFIG_PAX_PT_PAX_FLAGS
47915 +#ifdef CONFIG_PAX_SOFTMODE
47916 +static unsigned long pax_parse_pt_pax_softmode(const struct elf_phdr * const elf_phdata)
47917 +{
47918 + unsigned long pax_flags = 0UL;
47919 +
47920 +#ifdef CONFIG_PAX_PAGEEXEC
47921 + if (elf_phdata->p_flags & PF_PAGEEXEC)
47922 + pax_flags |= MF_PAX_PAGEEXEC;
47923 +#endif
47924 +
47925 +#ifdef CONFIG_PAX_SEGMEXEC
47926 + if (elf_phdata->p_flags & PF_SEGMEXEC)
47927 + pax_flags |= MF_PAX_SEGMEXEC;
47928 +#endif
47929 +
47930 +#ifdef CONFIG_PAX_EMUTRAMP
47931 + if ((elf_phdata->p_flags & PF_EMUTRAMP) && (pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)))
47932 + pax_flags |= MF_PAX_EMUTRAMP;
47933 +#endif
47934 +
47935 +#ifdef CONFIG_PAX_MPROTECT
47936 + if (elf_phdata->p_flags & PF_MPROTECT)
47937 + pax_flags |= MF_PAX_MPROTECT;
47938 +#endif
47939 +
47940 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
47941 + if (randomize_va_space && (elf_phdata->p_flags & PF_RANDMMAP))
47942 + pax_flags |= MF_PAX_RANDMMAP;
47943 +#endif
47944 +
47945 + return pax_flags;
47946 +}
47947 +#endif
47948 +
47949 +static unsigned long pax_parse_pt_pax_hardmode(const struct elf_phdr * const elf_phdata)
47950 +{
47951 + unsigned long pax_flags = 0UL;
47952 +
47953 +#ifdef CONFIG_PAX_PAGEEXEC
47954 + if (!(elf_phdata->p_flags & PF_NOPAGEEXEC))
47955 + pax_flags |= MF_PAX_PAGEEXEC;
47956 +#endif
47957 +
47958 +#ifdef CONFIG_PAX_SEGMEXEC
47959 + if (!(elf_phdata->p_flags & PF_NOSEGMEXEC))
47960 + pax_flags |= MF_PAX_SEGMEXEC;
47961 +#endif
47962 +
47963 +#ifdef CONFIG_PAX_EMUTRAMP
47964 + if (!(elf_phdata->p_flags & PF_NOEMUTRAMP))
47965 + pax_flags |= MF_PAX_EMUTRAMP;
47966 +#endif
47967 +
47968 +#ifdef CONFIG_PAX_MPROTECT
47969 + if (!(elf_phdata->p_flags & PF_NOMPROTECT))
47970 + pax_flags |= MF_PAX_MPROTECT;
47971 +#endif
47972 +
47973 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
47974 + if (randomize_va_space && !(elf_phdata->p_flags & PF_NORANDMMAP))
47975 + pax_flags |= MF_PAX_RANDMMAP;
47976 +#endif
47977 +
47978 + return pax_flags;
47979 +}
47980 +#endif
47981 +
47982 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
47983 +#ifdef CONFIG_PAX_SOFTMODE
47984 +static unsigned long pax_parse_xattr_pax_softmode(unsigned long pax_flags_softmode)
47985 +{
47986 + unsigned long pax_flags = 0UL;
47987 +
47988 +#ifdef CONFIG_PAX_PAGEEXEC
47989 + if (pax_flags_softmode & MF_PAX_PAGEEXEC)
47990 + pax_flags |= MF_PAX_PAGEEXEC;
47991 +#endif
47992 +
47993 +#ifdef CONFIG_PAX_SEGMEXEC
47994 + if (pax_flags_softmode & MF_PAX_SEGMEXEC)
47995 + pax_flags |= MF_PAX_SEGMEXEC;
47996 +#endif
47997 +
47998 +#ifdef CONFIG_PAX_EMUTRAMP
47999 + if (pax_flags_softmode & MF_PAX_EMUTRAMP)
48000 + pax_flags |= MF_PAX_EMUTRAMP;
48001 +#endif
48002 +
48003 +#ifdef CONFIG_PAX_MPROTECT
48004 + if (pax_flags_softmode & MF_PAX_MPROTECT)
48005 + pax_flags |= MF_PAX_MPROTECT;
48006 +#endif
48007 +
48008 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
48009 + if (randomize_va_space && (pax_flags_softmode & MF_PAX_RANDMMAP))
48010 + pax_flags |= MF_PAX_RANDMMAP;
48011 +#endif
48012 +
48013 + return pax_flags;
48014 +}
48015 +#endif
48016 +
48017 +static unsigned long pax_parse_xattr_pax_hardmode(unsigned long pax_flags_hardmode)
48018 +{
48019 + unsigned long pax_flags = 0UL;
48020 +
48021 +#ifdef CONFIG_PAX_PAGEEXEC
48022 + if (!(pax_flags_hardmode & MF_PAX_PAGEEXEC))
48023 + pax_flags |= MF_PAX_PAGEEXEC;
48024 +#endif
48025 +
48026 +#ifdef CONFIG_PAX_SEGMEXEC
48027 + if (!(pax_flags_hardmode & MF_PAX_SEGMEXEC))
48028 + pax_flags |= MF_PAX_SEGMEXEC;
48029 +#endif
48030 +
48031 +#ifdef CONFIG_PAX_EMUTRAMP
48032 + if (!(pax_flags_hardmode & MF_PAX_EMUTRAMP))
48033 + pax_flags |= MF_PAX_EMUTRAMP;
48034 +#endif
48035 +
48036 +#ifdef CONFIG_PAX_MPROTECT
48037 + if (!(pax_flags_hardmode & MF_PAX_MPROTECT))
48038 + pax_flags |= MF_PAX_MPROTECT;
48039 +#endif
48040 +
48041 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
48042 + if (randomize_va_space && !(pax_flags_hardmode & MF_PAX_RANDMMAP))
48043 + pax_flags |= MF_PAX_RANDMMAP;
48044 +#endif
48045 +
48046 + return pax_flags;
48047 +}
48048 +#endif
48049 +
48050 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
48051 +static unsigned long pax_parse_ei_pax(const struct elfhdr * const elf_ex)
48052 +{
48053 + unsigned long pax_flags = 0UL;
48054 +
48055 +#ifdef CONFIG_PAX_EI_PAX
48056 +
48057 +#ifdef CONFIG_PAX_PAGEEXEC
48058 + if (!(elf_ex->e_ident[EI_PAX] & EF_PAX_PAGEEXEC))
48059 + pax_flags |= MF_PAX_PAGEEXEC;
48060 +#endif
48061 +
48062 +#ifdef CONFIG_PAX_SEGMEXEC
48063 + if (!(elf_ex->e_ident[EI_PAX] & EF_PAX_SEGMEXEC))
48064 + pax_flags |= MF_PAX_SEGMEXEC;
48065 +#endif
48066 +
48067 +#ifdef CONFIG_PAX_EMUTRAMP
48068 + if ((pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) && (elf_ex->e_ident[EI_PAX] & EF_PAX_EMUTRAMP))
48069 + pax_flags |= MF_PAX_EMUTRAMP;
48070 +#endif
48071 +
48072 +#ifdef CONFIG_PAX_MPROTECT
48073 + if ((pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) && !(elf_ex->e_ident[EI_PAX] & EF_PAX_MPROTECT))
48074 + pax_flags |= MF_PAX_MPROTECT;
48075 +#endif
48076 +
48077 +#ifdef CONFIG_PAX_ASLR
48078 + if (randomize_va_space && !(elf_ex->e_ident[EI_PAX] & EF_PAX_RANDMMAP))
48079 + pax_flags |= MF_PAX_RANDMMAP;
48080 +#endif
48081 +
48082 +#else
48083 +
48084 +#ifdef CONFIG_PAX_PAGEEXEC
48085 + pax_flags |= MF_PAX_PAGEEXEC;
48086 +#endif
48087 +
48088 +#ifdef CONFIG_PAX_SEGMEXEC
48089 + pax_flags |= MF_PAX_SEGMEXEC;
48090 +#endif
48091 +
48092 +#ifdef CONFIG_PAX_MPROTECT
48093 + pax_flags |= MF_PAX_MPROTECT;
48094 +#endif
48095 +
48096 +#ifdef CONFIG_PAX_RANDMMAP
48097 + if (randomize_va_space)
48098 + pax_flags |= MF_PAX_RANDMMAP;
48099 +#endif
48100 +
48101 +#endif
48102 +
48103 + return pax_flags;
48104 +}
48105 +
48106 +static unsigned long pax_parse_pt_pax(const struct elfhdr * const elf_ex, const struct elf_phdr * const elf_phdata)
48107 +{
48108 +
48109 +#ifdef CONFIG_PAX_PT_PAX_FLAGS
48110 + unsigned long i;
48111 +
48112 + for (i = 0UL; i < elf_ex->e_phnum; i++)
48113 + if (elf_phdata[i].p_type == PT_PAX_FLAGS) {
48114 + if (((elf_phdata[i].p_flags & PF_PAGEEXEC) && (elf_phdata[i].p_flags & PF_NOPAGEEXEC)) ||
48115 + ((elf_phdata[i].p_flags & PF_SEGMEXEC) && (elf_phdata[i].p_flags & PF_NOSEGMEXEC)) ||
48116 + ((elf_phdata[i].p_flags & PF_EMUTRAMP) && (elf_phdata[i].p_flags & PF_NOEMUTRAMP)) ||
48117 + ((elf_phdata[i].p_flags & PF_MPROTECT) && (elf_phdata[i].p_flags & PF_NOMPROTECT)) ||
48118 + ((elf_phdata[i].p_flags & PF_RANDMMAP) && (elf_phdata[i].p_flags & PF_NORANDMMAP)))
48119 + return ~0UL;
48120 +
48121 +#ifdef CONFIG_PAX_SOFTMODE
48122 + if (pax_softmode)
48123 + return pax_parse_pt_pax_softmode(&elf_phdata[i]);
48124 + else
48125 +#endif
48126 +
48127 + return pax_parse_pt_pax_hardmode(&elf_phdata[i]);
48128 + break;
48129 + }
48130 +#endif
48131 +
48132 + return ~0UL;
48133 +}
48134 +
48135 +static unsigned long pax_parse_xattr_pax(struct file * const file)
48136 +{
48137 +
48138 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
48139 + ssize_t xattr_size, i;
48140 + unsigned char xattr_value[5];
48141 + unsigned long pax_flags_hardmode = 0UL, pax_flags_softmode = 0UL;
48142 +
48143 + xattr_size = vfs_getxattr(file->f_path.dentry, XATTR_NAME_PAX_FLAGS, xattr_value, sizeof xattr_value);
48144 + if (xattr_size <= 0 || xattr_size > 5)
48145 + return ~0UL;
48146 +
48147 + for (i = 0; i < xattr_size; i++)
48148 + switch (xattr_value[i]) {
48149 + default:
48150 + return ~0UL;
48151 +
48152 +#define parse_flag(option1, option2, flag) \
48153 + case option1: \
48154 + if (pax_flags_hardmode & MF_PAX_##flag) \
48155 + return ~0UL; \
48156 + pax_flags_hardmode |= MF_PAX_##flag; \
48157 + break; \
48158 + case option2: \
48159 + if (pax_flags_softmode & MF_PAX_##flag) \
48160 + return ~0UL; \
48161 + pax_flags_softmode |= MF_PAX_##flag; \
48162 + break;
48163 +
48164 + parse_flag('p', 'P', PAGEEXEC);
48165 + parse_flag('e', 'E', EMUTRAMP);
48166 + parse_flag('m', 'M', MPROTECT);
48167 + parse_flag('r', 'R', RANDMMAP);
48168 + parse_flag('s', 'S', SEGMEXEC);
48169 +
48170 +#undef parse_flag
48171 + }
48172 +
48173 + if (pax_flags_hardmode & pax_flags_softmode)
48174 + return ~0UL;
48175 +
48176 +#ifdef CONFIG_PAX_SOFTMODE
48177 + if (pax_softmode)
48178 + return pax_parse_xattr_pax_softmode(pax_flags_softmode);
48179 + else
48180 +#endif
48181 +
48182 + return pax_parse_xattr_pax_hardmode(pax_flags_hardmode);
48183 +#else
48184 + return ~0UL;
48185 +#endif
48186 +
48187 +}
48188 +
48189 +static long pax_parse_pax_flags(const struct elfhdr * const elf_ex, const struct elf_phdr * const elf_phdata, struct file * const file)
48190 +{
48191 + unsigned long pax_flags, pt_pax_flags, xattr_pax_flags;
48192 +
48193 + pax_flags = pax_parse_ei_pax(elf_ex);
48194 + pt_pax_flags = pax_parse_pt_pax(elf_ex, elf_phdata);
48195 + xattr_pax_flags = pax_parse_xattr_pax(file);
48196 +
48197 + if (pt_pax_flags == ~0UL)
48198 + pt_pax_flags = xattr_pax_flags;
48199 + else if (xattr_pax_flags == ~0UL)
48200 + xattr_pax_flags = pt_pax_flags;
48201 + if (pt_pax_flags != xattr_pax_flags)
48202 + return -EINVAL;
48203 + if (pt_pax_flags != ~0UL)
48204 + pax_flags = pt_pax_flags;
48205 +
48206 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_PAX_SEGMEXEC)
48207 + if ((pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) == (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
48208 + if ((__supported_pte_mask & _PAGE_NX))
48209 + pax_flags &= ~MF_PAX_SEGMEXEC;
48210 + else
48211 + pax_flags &= ~MF_PAX_PAGEEXEC;
48212 + }
48213 +#endif
48214 +
48215 + if (0 > pax_check_flags(&pax_flags))
48216 + return -EINVAL;
48217 +
48218 + current->mm->pax_flags = pax_flags;
48219 + return 0;
48220 +}
48221 +#endif
48222 +
48223 /*
48224 * These are the functions used to load ELF style executables and shared
48225 * libraries. There is no binary dependent code anywhere else.
48226 @@ -546,6 +876,11 @@ static unsigned long randomize_stack_top(unsigned long stack_top)
48227 {
48228 unsigned int random_variable = 0;
48229
48230 +#ifdef CONFIG_PAX_RANDUSTACK
48231 + if (current->mm->pax_flags & MF_PAX_RANDMMAP)
48232 + return stack_top - current->mm->delta_stack;
48233 +#endif
48234 +
48235 if ((current->flags & PF_RANDOMIZE) &&
48236 !(current->personality & ADDR_NO_RANDOMIZE)) {
48237 random_variable = get_random_int() & STACK_RND_MASK;
48238 @@ -564,7 +899,7 @@ static int load_elf_binary(struct linux_binprm *bprm)
48239 unsigned long load_addr = 0, load_bias = 0;
48240 int load_addr_set = 0;
48241 char * elf_interpreter = NULL;
48242 - unsigned long error;
48243 + unsigned long error = 0;
48244 struct elf_phdr *elf_ppnt, *elf_phdata;
48245 unsigned long elf_bss, elf_brk;
48246 int retval, i;
48247 @@ -574,12 +909,12 @@ static int load_elf_binary(struct linux_binprm *bprm)
48248 unsigned long start_code, end_code, start_data, end_data;
48249 unsigned long reloc_func_desc __maybe_unused = 0;
48250 int executable_stack = EXSTACK_DEFAULT;
48251 - unsigned long def_flags = 0;
48252 struct pt_regs *regs = current_pt_regs();
48253 struct {
48254 struct elfhdr elf_ex;
48255 struct elfhdr interp_elf_ex;
48256 } *loc;
48257 + unsigned long pax_task_size = TASK_SIZE;
48258
48259 loc = kmalloc(sizeof(*loc), GFP_KERNEL);
48260 if (!loc) {
48261 @@ -715,11 +1050,82 @@ static int load_elf_binary(struct linux_binprm *bprm)
48262 goto out_free_dentry;
48263
48264 /* OK, This is the point of no return */
48265 - current->mm->def_flags = def_flags;
48266 +
48267 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
48268 + current->mm->pax_flags = 0UL;
48269 +#endif
48270 +
48271 +#ifdef CONFIG_PAX_DLRESOLVE
48272 + current->mm->call_dl_resolve = 0UL;
48273 +#endif
48274 +
48275 +#if defined(CONFIG_PPC32) && defined(CONFIG_PAX_EMUSIGRT)
48276 + current->mm->call_syscall = 0UL;
48277 +#endif
48278 +
48279 +#ifdef CONFIG_PAX_ASLR
48280 + current->mm->delta_mmap = 0UL;
48281 + current->mm->delta_stack = 0UL;
48282 + current->mm->aslr_gap = 0UL;
48283 +#endif
48284 +
48285 + current->mm->def_flags = 0;
48286 +
48287 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
48288 + if (0 > pax_parse_pax_flags(&loc->elf_ex, elf_phdata, bprm->file)) {
48289 + send_sig(SIGKILL, current, 0);
48290 + goto out_free_dentry;
48291 + }
48292 +#endif
48293 +
48294 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
48295 + pax_set_initial_flags(bprm);
48296 +#elif defined(CONFIG_PAX_HOOK_ACL_FLAGS)
48297 + if (pax_set_initial_flags_func)
48298 + (pax_set_initial_flags_func)(bprm);
48299 +#endif
48300 +
48301 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
48302 + if ((current->mm->pax_flags & MF_PAX_PAGEEXEC) && !(__supported_pte_mask & _PAGE_NX)) {
48303 + current->mm->context.user_cs_limit = PAGE_SIZE;
48304 + current->mm->def_flags |= VM_PAGEEXEC;
48305 + }
48306 +#endif
48307 +
48308 +#ifdef CONFIG_PAX_SEGMEXEC
48309 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC) {
48310 + current->mm->context.user_cs_base = SEGMEXEC_TASK_SIZE;
48311 + current->mm->context.user_cs_limit = TASK_SIZE-SEGMEXEC_TASK_SIZE;
48312 + pax_task_size = SEGMEXEC_TASK_SIZE;
48313 + current->mm->def_flags |= VM_NOHUGEPAGE;
48314 + }
48315 +#endif
48316 +
48317 +#if defined(CONFIG_ARCH_TRACK_EXEC_LIMIT) || defined(CONFIG_PAX_SEGMEXEC)
48318 + if (current->mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
48319 + set_user_cs(current->mm->context.user_cs_base, current->mm->context.user_cs_limit, get_cpu());
48320 + put_cpu();
48321 + }
48322 +#endif
48323
48324 /* Do this immediately, since STACK_TOP as used in setup_arg_pages
48325 may depend on the personality. */
48326 SET_PERSONALITY(loc->elf_ex);
48327 +
48328 +#ifdef CONFIG_PAX_ASLR
48329 + if (current->mm->pax_flags & MF_PAX_RANDMMAP) {
48330 + current->mm->delta_mmap = (pax_get_random_long() & ((1UL << PAX_DELTA_MMAP_LEN)-1)) << PAGE_SHIFT;
48331 + current->mm->delta_stack = (pax_get_random_long() & ((1UL << PAX_DELTA_STACK_LEN)-1)) << PAGE_SHIFT;
48332 + }
48333 +#endif
48334 +
48335 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
48336 + if (current->mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
48337 + executable_stack = EXSTACK_DISABLE_X;
48338 + current->personality &= ~READ_IMPLIES_EXEC;
48339 + } else
48340 +#endif
48341 +
48342 if (elf_read_implies_exec(loc->elf_ex, executable_stack))
48343 current->personality |= READ_IMPLIES_EXEC;
48344
48345 @@ -810,6 +1216,20 @@ static int load_elf_binary(struct linux_binprm *bprm)
48346 #else
48347 load_bias = ELF_PAGESTART(ELF_ET_DYN_BASE - vaddr);
48348 #endif
48349 +
48350 +#ifdef CONFIG_PAX_RANDMMAP
48351 + /* PaX: randomize base address at the default exe base if requested */
48352 + if ((current->mm->pax_flags & MF_PAX_RANDMMAP) && elf_interpreter) {
48353 +#ifdef CONFIG_SPARC64
48354 + load_bias = (pax_get_random_long() & ((1UL << PAX_DELTA_MMAP_LEN) - 1)) << (PAGE_SHIFT+1);
48355 +#else
48356 + load_bias = (pax_get_random_long() & ((1UL << PAX_DELTA_MMAP_LEN) - 1)) << PAGE_SHIFT;
48357 +#endif
48358 + load_bias = ELF_PAGESTART(PAX_ELF_ET_DYN_BASE - vaddr + load_bias);
48359 + elf_flags |= MAP_FIXED;
48360 + }
48361 +#endif
48362 +
48363 }
48364
48365 error = elf_map(bprm->file, load_bias + vaddr, elf_ppnt,
48366 @@ -842,9 +1262,9 @@ static int load_elf_binary(struct linux_binprm *bprm)
48367 * allowed task size. Note that p_filesz must always be
48368 * <= p_memsz so it is only necessary to check p_memsz.
48369 */
48370 - if (BAD_ADDR(k) || elf_ppnt->p_filesz > elf_ppnt->p_memsz ||
48371 - elf_ppnt->p_memsz > TASK_SIZE ||
48372 - TASK_SIZE - elf_ppnt->p_memsz < k) {
48373 + if (k >= pax_task_size || elf_ppnt->p_filesz > elf_ppnt->p_memsz ||
48374 + elf_ppnt->p_memsz > pax_task_size ||
48375 + pax_task_size - elf_ppnt->p_memsz < k) {
48376 /* set_brk can never work. Avoid overflows. */
48377 send_sig(SIGKILL, current, 0);
48378 retval = -EINVAL;
48379 @@ -883,17 +1303,45 @@ static int load_elf_binary(struct linux_binprm *bprm)
48380 goto out_free_dentry;
48381 }
48382 if (likely(elf_bss != elf_brk) && unlikely(padzero(elf_bss))) {
48383 - send_sig(SIGSEGV, current, 0);
48384 - retval = -EFAULT; /* Nobody gets to see this, but.. */
48385 - goto out_free_dentry;
48386 + /*
48387 + * This bss-zeroing can fail if the ELF
48388 + * file specifies odd protections. So
48389 + * we don't check the return value
48390 + */
48391 }
48392
48393 +#ifdef CONFIG_PAX_RANDMMAP
48394 + if (current->mm->pax_flags & MF_PAX_RANDMMAP) {
48395 + unsigned long start, size;
48396 +
48397 + start = ELF_PAGEALIGN(elf_brk);
48398 + size = PAGE_SIZE + ((pax_get_random_long() & ((1UL << 22) - 1UL)) << 4);
48399 + down_read(&current->mm->mmap_sem);
48400 + retval = -ENOMEM;
48401 + if (!find_vma_intersection(current->mm, start, start + size + PAGE_SIZE)) {
48402 + unsigned long prot = PROT_NONE;
48403 +
48404 + up_read(&current->mm->mmap_sem);
48405 +// if (current->personality & ADDR_NO_RANDOMIZE)
48406 +// prot = PROT_READ;
48407 + start = vm_mmap(NULL, start, size, prot, MAP_ANONYMOUS | MAP_FIXED | MAP_PRIVATE, 0);
48408 + retval = IS_ERR_VALUE(start) ? start : 0;
48409 + } else
48410 + up_read(&current->mm->mmap_sem);
48411 + if (retval == 0) {
48412 + current->mm->aslr_gap += PAGE_ALIGN(size) >> PAGE_SHIFT;
48413 + retval = set_brk(start + size, start + size + PAGE_SIZE);
48414 + }
48415 + if (retval < 0) {
48416 + send_sig(SIGKILL, current, 0);
48417 + goto out_free_dentry;
48418 + }
48419 + }
48420 +#endif
48421 +
48422 if (elf_interpreter) {
48423 - unsigned long interp_map_addr = 0;
48424 -
48425 elf_entry = load_elf_interp(&loc->interp_elf_ex,
48426 interpreter,
48427 - &interp_map_addr,
48428 load_bias);
48429 if (!IS_ERR((void *)elf_entry)) {
48430 /*
48431 @@ -1115,7 +1563,7 @@ static bool always_dump_vma(struct vm_area_struct *vma)
48432 * Decide what to dump of a segment, part, all or none.
48433 */
48434 static unsigned long vma_dump_size(struct vm_area_struct *vma,
48435 - unsigned long mm_flags)
48436 + unsigned long mm_flags, long signr)
48437 {
48438 #define FILTER(type) (mm_flags & (1UL << MMF_DUMP_##type))
48439
48440 @@ -1152,7 +1600,7 @@ static unsigned long vma_dump_size(struct vm_area_struct *vma,
48441 if (vma->vm_file == NULL)
48442 return 0;
48443
48444 - if (FILTER(MAPPED_PRIVATE))
48445 + if (signr == SIGKILL || FILTER(MAPPED_PRIVATE))
48446 goto whole;
48447
48448 /*
48449 @@ -1374,9 +1822,9 @@ static void fill_auxv_note(struct memelfnote *note, struct mm_struct *mm)
48450 {
48451 elf_addr_t *auxv = (elf_addr_t *) mm->saved_auxv;
48452 int i = 0;
48453 - do
48454 + do {
48455 i += 2;
48456 - while (auxv[i - 2] != AT_NULL);
48457 + } while (auxv[i - 2] != AT_NULL);
48458 fill_note(note, "CORE", NT_AUXV, i * sizeof(elf_addr_t), auxv);
48459 }
48460
48461 @@ -2006,14 +2454,14 @@ static void fill_extnum_info(struct elfhdr *elf, struct elf_shdr *shdr4extnum,
48462 }
48463
48464 static size_t elf_core_vma_data_size(struct vm_area_struct *gate_vma,
48465 - unsigned long mm_flags)
48466 + struct coredump_params *cprm)
48467 {
48468 struct vm_area_struct *vma;
48469 size_t size = 0;
48470
48471 for (vma = first_vma(current, gate_vma); vma != NULL;
48472 vma = next_vma(vma, gate_vma))
48473 - size += vma_dump_size(vma, mm_flags);
48474 + size += vma_dump_size(vma, cprm->mm_flags, cprm->siginfo->si_signo);
48475 return size;
48476 }
48477
48478 @@ -2107,7 +2555,7 @@ static int elf_core_dump(struct coredump_params *cprm)
48479
48480 dataoff = offset = roundup(offset, ELF_EXEC_PAGESIZE);
48481
48482 - offset += elf_core_vma_data_size(gate_vma, cprm->mm_flags);
48483 + offset += elf_core_vma_data_size(gate_vma, cprm);
48484 offset += elf_core_extra_data_size();
48485 e_shoff = offset;
48486
48487 @@ -2121,10 +2569,12 @@ static int elf_core_dump(struct coredump_params *cprm)
48488 offset = dataoff;
48489
48490 size += sizeof(*elf);
48491 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
48492 if (size > cprm->limit || !dump_write(cprm->file, elf, sizeof(*elf)))
48493 goto end_coredump;
48494
48495 size += sizeof(*phdr4note);
48496 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
48497 if (size > cprm->limit
48498 || !dump_write(cprm->file, phdr4note, sizeof(*phdr4note)))
48499 goto end_coredump;
48500 @@ -2138,7 +2588,7 @@ static int elf_core_dump(struct coredump_params *cprm)
48501 phdr.p_offset = offset;
48502 phdr.p_vaddr = vma->vm_start;
48503 phdr.p_paddr = 0;
48504 - phdr.p_filesz = vma_dump_size(vma, cprm->mm_flags);
48505 + phdr.p_filesz = vma_dump_size(vma, cprm->mm_flags, cprm->siginfo->si_signo);
48506 phdr.p_memsz = vma->vm_end - vma->vm_start;
48507 offset += phdr.p_filesz;
48508 phdr.p_flags = vma->vm_flags & VM_READ ? PF_R : 0;
48509 @@ -2149,6 +2599,7 @@ static int elf_core_dump(struct coredump_params *cprm)
48510 phdr.p_align = ELF_EXEC_PAGESIZE;
48511
48512 size += sizeof(phdr);
48513 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
48514 if (size > cprm->limit
48515 || !dump_write(cprm->file, &phdr, sizeof(phdr)))
48516 goto end_coredump;
48517 @@ -2173,7 +2624,7 @@ static int elf_core_dump(struct coredump_params *cprm)
48518 unsigned long addr;
48519 unsigned long end;
48520
48521 - end = vma->vm_start + vma_dump_size(vma, cprm->mm_flags);
48522 + end = vma->vm_start + vma_dump_size(vma, cprm->mm_flags, cprm->siginfo->si_signo);
48523
48524 for (addr = vma->vm_start; addr < end; addr += PAGE_SIZE) {
48525 struct page *page;
48526 @@ -2182,6 +2633,7 @@ static int elf_core_dump(struct coredump_params *cprm)
48527 page = get_dump_page(addr);
48528 if (page) {
48529 void *kaddr = kmap(page);
48530 + gr_learn_resource(current, RLIMIT_CORE, size + PAGE_SIZE, 1);
48531 stop = ((size += PAGE_SIZE) > cprm->limit) ||
48532 !dump_write(cprm->file, kaddr,
48533 PAGE_SIZE);
48534 @@ -2199,6 +2651,7 @@ static int elf_core_dump(struct coredump_params *cprm)
48535
48536 if (e_phnum == PN_XNUM) {
48537 size += sizeof(*shdr4extnum);
48538 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
48539 if (size > cprm->limit
48540 || !dump_write(cprm->file, shdr4extnum,
48541 sizeof(*shdr4extnum)))
48542 @@ -2219,6 +2672,97 @@ out:
48543
48544 #endif /* CONFIG_ELF_CORE */
48545
48546 +#ifdef CONFIG_PAX_MPROTECT
48547 +/* PaX: non-PIC ELF libraries need relocations on their executable segments
48548 + * therefore we'll grant them VM_MAYWRITE once during their life. Similarly
48549 + * we'll remove VM_MAYWRITE for good on RELRO segments.
48550 + *
48551 + * The checks favour ld-linux.so behaviour which operates on a per ELF segment
48552 + * basis because we want to allow the common case and not the special ones.
48553 + */
48554 +static void elf_handle_mprotect(struct vm_area_struct *vma, unsigned long newflags)
48555 +{
48556 + struct elfhdr elf_h;
48557 + struct elf_phdr elf_p;
48558 + unsigned long i;
48559 + unsigned long oldflags;
48560 + bool is_textrel_rw, is_textrel_rx, is_relro;
48561 +
48562 + if (!(vma->vm_mm->pax_flags & MF_PAX_MPROTECT))
48563 + return;
48564 +
48565 + oldflags = vma->vm_flags & (VM_MAYEXEC | VM_MAYWRITE | VM_MAYREAD | VM_EXEC | VM_WRITE | VM_READ);
48566 + newflags &= VM_MAYEXEC | VM_MAYWRITE | VM_MAYREAD | VM_EXEC | VM_WRITE | VM_READ;
48567 +
48568 +#ifdef CONFIG_PAX_ELFRELOCS
48569 + /* possible TEXTREL */
48570 + is_textrel_rw = vma->vm_file && !vma->anon_vma && oldflags == (VM_MAYEXEC | VM_MAYREAD | VM_EXEC | VM_READ) && newflags == (VM_WRITE | VM_READ);
48571 + 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);
48572 +#else
48573 + is_textrel_rw = false;
48574 + is_textrel_rx = false;
48575 +#endif
48576 +
48577 + /* possible RELRO */
48578 + is_relro = vma->vm_file && vma->anon_vma && oldflags == (VM_MAYWRITE | VM_MAYREAD | VM_READ) && newflags == (VM_MAYWRITE | VM_MAYREAD | VM_READ);
48579 +
48580 + if (!is_textrel_rw && !is_textrel_rx && !is_relro)
48581 + return;
48582 +
48583 + if (sizeof(elf_h) != kernel_read(vma->vm_file, 0UL, (char *)&elf_h, sizeof(elf_h)) ||
48584 + memcmp(elf_h.e_ident, ELFMAG, SELFMAG) ||
48585 +
48586 +#ifdef CONFIG_PAX_ETEXECRELOCS
48587 + ((is_textrel_rw || is_textrel_rx) && (elf_h.e_type != ET_DYN && elf_h.e_type != ET_EXEC)) ||
48588 +#else
48589 + ((is_textrel_rw || is_textrel_rx) && elf_h.e_type != ET_DYN) ||
48590 +#endif
48591 +
48592 + (is_relro && (elf_h.e_type != ET_DYN && elf_h.e_type != ET_EXEC)) ||
48593 + !elf_check_arch(&elf_h) ||
48594 + elf_h.e_phentsize != sizeof(struct elf_phdr) ||
48595 + elf_h.e_phnum > 65536UL / sizeof(struct elf_phdr))
48596 + return;
48597 +
48598 + for (i = 0UL; i < elf_h.e_phnum; i++) {
48599 + if (sizeof(elf_p) != kernel_read(vma->vm_file, elf_h.e_phoff + i*sizeof(elf_p), (char *)&elf_p, sizeof(elf_p)))
48600 + return;
48601 + switch (elf_p.p_type) {
48602 + case PT_DYNAMIC:
48603 + if (!is_textrel_rw && !is_textrel_rx)
48604 + continue;
48605 + i = 0UL;
48606 + while ((i+1) * sizeof(elf_dyn) <= elf_p.p_filesz) {
48607 + elf_dyn dyn;
48608 +
48609 + if (sizeof(dyn) != kernel_read(vma->vm_file, elf_p.p_offset + i*sizeof(dyn), (char *)&dyn, sizeof(dyn)))
48610 + return;
48611 + if (dyn.d_tag == DT_NULL)
48612 + return;
48613 + if (dyn.d_tag == DT_TEXTREL || (dyn.d_tag == DT_FLAGS && (dyn.d_un.d_val & DF_TEXTREL))) {
48614 + gr_log_textrel(vma);
48615 + if (is_textrel_rw)
48616 + vma->vm_flags |= VM_MAYWRITE;
48617 + else
48618 + /* PaX: disallow write access after relocs are done, hopefully noone else needs it... */
48619 + vma->vm_flags &= ~VM_MAYWRITE;
48620 + return;
48621 + }
48622 + i++;
48623 + }
48624 + return;
48625 +
48626 + case PT_GNU_RELRO:
48627 + if (!is_relro)
48628 + continue;
48629 + if ((elf_p.p_offset >> PAGE_SHIFT) == vma->vm_pgoff && ELF_PAGEALIGN(elf_p.p_memsz) == vma->vm_end - vma->vm_start)
48630 + vma->vm_flags &= ~VM_MAYWRITE;
48631 + return;
48632 + }
48633 + }
48634 +}
48635 +#endif
48636 +
48637 static int __init init_elf_binfmt(void)
48638 {
48639 register_binfmt(&elf_format);
48640 diff --git a/fs/binfmt_flat.c b/fs/binfmt_flat.c
48641 index b563719..3868998 100644
48642 --- a/fs/binfmt_flat.c
48643 +++ b/fs/binfmt_flat.c
48644 @@ -562,7 +562,9 @@ static int load_flat_file(struct linux_binprm * bprm,
48645 realdatastart = (unsigned long) -ENOMEM;
48646 printk("Unable to allocate RAM for process data, errno %d\n",
48647 (int)-realdatastart);
48648 + down_write(&current->mm->mmap_sem);
48649 vm_munmap(textpos, text_len);
48650 + up_write(&current->mm->mmap_sem);
48651 ret = realdatastart;
48652 goto err;
48653 }
48654 @@ -586,8 +588,10 @@ static int load_flat_file(struct linux_binprm * bprm,
48655 }
48656 if (IS_ERR_VALUE(result)) {
48657 printk("Unable to read data+bss, errno %d\n", (int)-result);
48658 + down_write(&current->mm->mmap_sem);
48659 vm_munmap(textpos, text_len);
48660 vm_munmap(realdatastart, len);
48661 + up_write(&current->mm->mmap_sem);
48662 ret = result;
48663 goto err;
48664 }
48665 @@ -654,8 +658,10 @@ static int load_flat_file(struct linux_binprm * bprm,
48666 }
48667 if (IS_ERR_VALUE(result)) {
48668 printk("Unable to read code+data+bss, errno %d\n",(int)-result);
48669 + down_write(&current->mm->mmap_sem);
48670 vm_munmap(textpos, text_len + data_len + extra +
48671 MAX_SHARED_LIBS * sizeof(unsigned long));
48672 + up_write(&current->mm->mmap_sem);
48673 ret = result;
48674 goto err;
48675 }
48676 diff --git a/fs/bio.c b/fs/bio.c
48677 index b96fc6c..431d628 100644
48678 --- a/fs/bio.c
48679 +++ b/fs/bio.c
48680 @@ -818,7 +818,7 @@ struct bio *bio_copy_user_iov(struct request_queue *q,
48681 /*
48682 * Overflow, abort
48683 */
48684 - if (end < start)
48685 + if (end < start || end - start > INT_MAX - nr_pages)
48686 return ERR_PTR(-EINVAL);
48687
48688 nr_pages += end - start;
48689 @@ -952,7 +952,7 @@ static struct bio *__bio_map_user_iov(struct request_queue *q,
48690 /*
48691 * Overflow, abort
48692 */
48693 - if (end < start)
48694 + if (end < start || end - start > INT_MAX - nr_pages)
48695 return ERR_PTR(-EINVAL);
48696
48697 nr_pages += end - start;
48698 @@ -1214,7 +1214,7 @@ static void bio_copy_kern_endio(struct bio *bio, int err)
48699 const int read = bio_data_dir(bio) == READ;
48700 struct bio_map_data *bmd = bio->bi_private;
48701 int i;
48702 - char *p = bmd->sgvecs[0].iov_base;
48703 + char *p = (char __force_kernel *)bmd->sgvecs[0].iov_base;
48704
48705 __bio_for_each_segment(bvec, bio, i, 0) {
48706 char *addr = page_address(bvec->bv_page);
48707 diff --git a/fs/block_dev.c b/fs/block_dev.c
48708 index 78333a3..23dcb4d 100644
48709 --- a/fs/block_dev.c
48710 +++ b/fs/block_dev.c
48711 @@ -651,7 +651,7 @@ static bool bd_may_claim(struct block_device *bdev, struct block_device *whole,
48712 else if (bdev->bd_contains == bdev)
48713 return true; /* is a whole device which isn't held */
48714
48715 - else if (whole->bd_holder == bd_may_claim)
48716 + else if (whole->bd_holder == (void *)bd_may_claim)
48717 return true; /* is a partition of a device that is being partitioned */
48718 else if (whole->bd_holder != NULL)
48719 return false; /* is a partition of a held device */
48720 diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c
48721 index eea5da7..88fead70 100644
48722 --- a/fs/btrfs/ctree.c
48723 +++ b/fs/btrfs/ctree.c
48724 @@ -1033,9 +1033,12 @@ static noinline int __btrfs_cow_block(struct btrfs_trans_handle *trans,
48725 free_extent_buffer(buf);
48726 add_root_to_dirty_list(root);
48727 } else {
48728 - if (root->root_key.objectid == BTRFS_TREE_RELOC_OBJECTID)
48729 - parent_start = parent->start;
48730 - else
48731 + if (root->root_key.objectid == BTRFS_TREE_RELOC_OBJECTID) {
48732 + if (parent)
48733 + parent_start = parent->start;
48734 + else
48735 + parent_start = 0;
48736 + } else
48737 parent_start = 0;
48738
48739 WARN_ON(trans->transid != btrfs_header_generation(parent));
48740 diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
48741 index 659ea81..0f63c1a 100644
48742 --- a/fs/btrfs/inode.c
48743 +++ b/fs/btrfs/inode.c
48744 @@ -7300,7 +7300,7 @@ fail:
48745 return -ENOMEM;
48746 }
48747
48748 -static int btrfs_getattr(struct vfsmount *mnt,
48749 +int btrfs_getattr(struct vfsmount *mnt,
48750 struct dentry *dentry, struct kstat *stat)
48751 {
48752 struct inode *inode = dentry->d_inode;
48753 @@ -7314,6 +7314,14 @@ static int btrfs_getattr(struct vfsmount *mnt,
48754 return 0;
48755 }
48756
48757 +EXPORT_SYMBOL(btrfs_getattr);
48758 +
48759 +dev_t get_btrfs_dev_from_inode(struct inode *inode)
48760 +{
48761 + return BTRFS_I(inode)->root->anon_dev;
48762 +}
48763 +EXPORT_SYMBOL(get_btrfs_dev_from_inode);
48764 +
48765 /*
48766 * If a file is moved, it will inherit the cow and compression flags of the new
48767 * directory.
48768 diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
48769 index 338f259..b657640 100644
48770 --- a/fs/btrfs/ioctl.c
48771 +++ b/fs/btrfs/ioctl.c
48772 @@ -3033,9 +3033,12 @@ long btrfs_ioctl_space_info(struct btrfs_root *root, void __user *arg)
48773 for (i = 0; i < num_types; i++) {
48774 struct btrfs_space_info *tmp;
48775
48776 + /* Don't copy in more than we allocated */
48777 if (!slot_count)
48778 break;
48779
48780 + slot_count--;
48781 +
48782 info = NULL;
48783 rcu_read_lock();
48784 list_for_each_entry_rcu(tmp, &root->fs_info->space_info,
48785 @@ -3057,10 +3060,7 @@ long btrfs_ioctl_space_info(struct btrfs_root *root, void __user *arg)
48786 memcpy(dest, &space, sizeof(space));
48787 dest++;
48788 space_args.total_spaces++;
48789 - slot_count--;
48790 }
48791 - if (!slot_count)
48792 - break;
48793 }
48794 up_read(&info->groups_sem);
48795 }
48796 diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c
48797 index 300e09a..9fe4539 100644
48798 --- a/fs/btrfs/relocation.c
48799 +++ b/fs/btrfs/relocation.c
48800 @@ -1269,7 +1269,7 @@ static int __update_reloc_root(struct btrfs_root *root, int del)
48801 }
48802 spin_unlock(&rc->reloc_root_tree.lock);
48803
48804 - BUG_ON((struct btrfs_root *)node->data != root);
48805 + BUG_ON(!node || (struct btrfs_root *)node->data != root);
48806
48807 if (!del) {
48808 spin_lock(&rc->reloc_root_tree.lock);
48809 diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
48810 index d8982e9..29a85fa 100644
48811 --- a/fs/btrfs/super.c
48812 +++ b/fs/btrfs/super.c
48813 @@ -267,7 +267,7 @@ void __btrfs_abort_transaction(struct btrfs_trans_handle *trans,
48814 function, line, errstr);
48815 return;
48816 }
48817 - ACCESS_ONCE(trans->transaction->aborted) = errno;
48818 + ACCESS_ONCE_RW(trans->transaction->aborted) = errno;
48819 __btrfs_std_error(root->fs_info, function, line, errno, NULL);
48820 }
48821 /*
48822 diff --git a/fs/cachefiles/bind.c b/fs/cachefiles/bind.c
48823 index 622f469..e8d2d55 100644
48824 --- a/fs/cachefiles/bind.c
48825 +++ b/fs/cachefiles/bind.c
48826 @@ -39,13 +39,11 @@ int cachefiles_daemon_bind(struct cachefiles_cache *cache, char *args)
48827 args);
48828
48829 /* start by checking things over */
48830 - ASSERT(cache->fstop_percent >= 0 &&
48831 - cache->fstop_percent < cache->fcull_percent &&
48832 + ASSERT(cache->fstop_percent < cache->fcull_percent &&
48833 cache->fcull_percent < cache->frun_percent &&
48834 cache->frun_percent < 100);
48835
48836 - ASSERT(cache->bstop_percent >= 0 &&
48837 - cache->bstop_percent < cache->bcull_percent &&
48838 + ASSERT(cache->bstop_percent < cache->bcull_percent &&
48839 cache->bcull_percent < cache->brun_percent &&
48840 cache->brun_percent < 100);
48841
48842 diff --git a/fs/cachefiles/daemon.c b/fs/cachefiles/daemon.c
48843 index 0a1467b..6a53245 100644
48844 --- a/fs/cachefiles/daemon.c
48845 +++ b/fs/cachefiles/daemon.c
48846 @@ -196,7 +196,7 @@ static ssize_t cachefiles_daemon_read(struct file *file, char __user *_buffer,
48847 if (n > buflen)
48848 return -EMSGSIZE;
48849
48850 - if (copy_to_user(_buffer, buffer, n) != 0)
48851 + if (n > sizeof(buffer) || copy_to_user(_buffer, buffer, n) != 0)
48852 return -EFAULT;
48853
48854 return n;
48855 @@ -222,7 +222,7 @@ static ssize_t cachefiles_daemon_write(struct file *file,
48856 if (test_bit(CACHEFILES_DEAD, &cache->flags))
48857 return -EIO;
48858
48859 - if (datalen < 0 || datalen > PAGE_SIZE - 1)
48860 + if (datalen > PAGE_SIZE - 1)
48861 return -EOPNOTSUPP;
48862
48863 /* drag the command string into the kernel so we can parse it */
48864 @@ -386,7 +386,7 @@ static int cachefiles_daemon_fstop(struct cachefiles_cache *cache, char *args)
48865 if (args[0] != '%' || args[1] != '\0')
48866 return -EINVAL;
48867
48868 - if (fstop < 0 || fstop >= cache->fcull_percent)
48869 + if (fstop >= cache->fcull_percent)
48870 return cachefiles_daemon_range_error(cache, args);
48871
48872 cache->fstop_percent = fstop;
48873 @@ -458,7 +458,7 @@ static int cachefiles_daemon_bstop(struct cachefiles_cache *cache, char *args)
48874 if (args[0] != '%' || args[1] != '\0')
48875 return -EINVAL;
48876
48877 - if (bstop < 0 || bstop >= cache->bcull_percent)
48878 + if (bstop >= cache->bcull_percent)
48879 return cachefiles_daemon_range_error(cache, args);
48880
48881 cache->bstop_percent = bstop;
48882 diff --git a/fs/cachefiles/internal.h b/fs/cachefiles/internal.h
48883 index 4938251..7e01445 100644
48884 --- a/fs/cachefiles/internal.h
48885 +++ b/fs/cachefiles/internal.h
48886 @@ -59,7 +59,7 @@ struct cachefiles_cache {
48887 wait_queue_head_t daemon_pollwq; /* poll waitqueue for daemon */
48888 struct rb_root active_nodes; /* active nodes (can't be culled) */
48889 rwlock_t active_lock; /* lock for active_nodes */
48890 - atomic_t gravecounter; /* graveyard uniquifier */
48891 + atomic_unchecked_t gravecounter; /* graveyard uniquifier */
48892 unsigned frun_percent; /* when to stop culling (% files) */
48893 unsigned fcull_percent; /* when to start culling (% files) */
48894 unsigned fstop_percent; /* when to stop allocating (% files) */
48895 @@ -171,19 +171,19 @@ extern int cachefiles_check_in_use(struct cachefiles_cache *cache,
48896 * proc.c
48897 */
48898 #ifdef CONFIG_CACHEFILES_HISTOGRAM
48899 -extern atomic_t cachefiles_lookup_histogram[HZ];
48900 -extern atomic_t cachefiles_mkdir_histogram[HZ];
48901 -extern atomic_t cachefiles_create_histogram[HZ];
48902 +extern atomic_unchecked_t cachefiles_lookup_histogram[HZ];
48903 +extern atomic_unchecked_t cachefiles_mkdir_histogram[HZ];
48904 +extern atomic_unchecked_t cachefiles_create_histogram[HZ];
48905
48906 extern int __init cachefiles_proc_init(void);
48907 extern void cachefiles_proc_cleanup(void);
48908 static inline
48909 -void cachefiles_hist(atomic_t histogram[], unsigned long start_jif)
48910 +void cachefiles_hist(atomic_unchecked_t histogram[], unsigned long start_jif)
48911 {
48912 unsigned long jif = jiffies - start_jif;
48913 if (jif >= HZ)
48914 jif = HZ - 1;
48915 - atomic_inc(&histogram[jif]);
48916 + atomic_inc_unchecked(&histogram[jif]);
48917 }
48918
48919 #else
48920 diff --git a/fs/cachefiles/namei.c b/fs/cachefiles/namei.c
48921 index 8c01c5fc..15f982e 100644
48922 --- a/fs/cachefiles/namei.c
48923 +++ b/fs/cachefiles/namei.c
48924 @@ -317,7 +317,7 @@ try_again:
48925 /* first step is to make up a grave dentry in the graveyard */
48926 sprintf(nbuffer, "%08x%08x",
48927 (uint32_t) get_seconds(),
48928 - (uint32_t) atomic_inc_return(&cache->gravecounter));
48929 + (uint32_t) atomic_inc_return_unchecked(&cache->gravecounter));
48930
48931 /* do the multiway lock magic */
48932 trap = lock_rename(cache->graveyard, dir);
48933 diff --git a/fs/cachefiles/proc.c b/fs/cachefiles/proc.c
48934 index eccd339..4c1d995 100644
48935 --- a/fs/cachefiles/proc.c
48936 +++ b/fs/cachefiles/proc.c
48937 @@ -14,9 +14,9 @@
48938 #include <linux/seq_file.h>
48939 #include "internal.h"
48940
48941 -atomic_t cachefiles_lookup_histogram[HZ];
48942 -atomic_t cachefiles_mkdir_histogram[HZ];
48943 -atomic_t cachefiles_create_histogram[HZ];
48944 +atomic_unchecked_t cachefiles_lookup_histogram[HZ];
48945 +atomic_unchecked_t cachefiles_mkdir_histogram[HZ];
48946 +atomic_unchecked_t cachefiles_create_histogram[HZ];
48947
48948 /*
48949 * display the latency histogram
48950 @@ -35,9 +35,9 @@ static int cachefiles_histogram_show(struct seq_file *m, void *v)
48951 return 0;
48952 default:
48953 index = (unsigned long) v - 3;
48954 - x = atomic_read(&cachefiles_lookup_histogram[index]);
48955 - y = atomic_read(&cachefiles_mkdir_histogram[index]);
48956 - z = atomic_read(&cachefiles_create_histogram[index]);
48957 + x = atomic_read_unchecked(&cachefiles_lookup_histogram[index]);
48958 + y = atomic_read_unchecked(&cachefiles_mkdir_histogram[index]);
48959 + z = atomic_read_unchecked(&cachefiles_create_histogram[index]);
48960 if (x == 0 && y == 0 && z == 0)
48961 return 0;
48962
48963 diff --git a/fs/cachefiles/rdwr.c b/fs/cachefiles/rdwr.c
48964 index 4809922..aab2c39 100644
48965 --- a/fs/cachefiles/rdwr.c
48966 +++ b/fs/cachefiles/rdwr.c
48967 @@ -965,7 +965,7 @@ int cachefiles_write_page(struct fscache_storage *op, struct page *page)
48968 old_fs = get_fs();
48969 set_fs(KERNEL_DS);
48970 ret = file->f_op->write(
48971 - file, (const void __user *) data, len, &pos);
48972 + file, (const void __force_user *) data, len, &pos);
48973 set_fs(old_fs);
48974 kunmap(page);
48975 if (ret != len)
48976 diff --git a/fs/ceph/dir.c b/fs/ceph/dir.c
48977 index 8c1aabe..bbf856a 100644
48978 --- a/fs/ceph/dir.c
48979 +++ b/fs/ceph/dir.c
48980 @@ -243,7 +243,7 @@ static int ceph_readdir(struct file *filp, void *dirent, filldir_t filldir)
48981 struct ceph_fs_client *fsc = ceph_inode_to_client(inode);
48982 struct ceph_mds_client *mdsc = fsc->mdsc;
48983 unsigned frag = fpos_frag(filp->f_pos);
48984 - int off = fpos_off(filp->f_pos);
48985 + unsigned int off = fpos_off(filp->f_pos);
48986 int err;
48987 u32 ftype;
48988 struct ceph_mds_reply_info_parsed *rinfo;
48989 diff --git a/fs/cifs/cifs_debug.c b/fs/cifs/cifs_debug.c
48990 index d9ea6ed..1e6c8ac 100644
48991 --- a/fs/cifs/cifs_debug.c
48992 +++ b/fs/cifs/cifs_debug.c
48993 @@ -267,8 +267,8 @@ static ssize_t cifs_stats_proc_write(struct file *file,
48994
48995 if (c == '1' || c == 'y' || c == 'Y' || c == '0') {
48996 #ifdef CONFIG_CIFS_STATS2
48997 - atomic_set(&totBufAllocCount, 0);
48998 - atomic_set(&totSmBufAllocCount, 0);
48999 + atomic_set_unchecked(&totBufAllocCount, 0);
49000 + atomic_set_unchecked(&totSmBufAllocCount, 0);
49001 #endif /* CONFIG_CIFS_STATS2 */
49002 spin_lock(&cifs_tcp_ses_lock);
49003 list_for_each(tmp1, &cifs_tcp_ses_list) {
49004 @@ -281,7 +281,7 @@ static ssize_t cifs_stats_proc_write(struct file *file,
49005 tcon = list_entry(tmp3,
49006 struct cifs_tcon,
49007 tcon_list);
49008 - atomic_set(&tcon->num_smbs_sent, 0);
49009 + atomic_set_unchecked(&tcon->num_smbs_sent, 0);
49010 if (server->ops->clear_stats)
49011 server->ops->clear_stats(tcon);
49012 }
49013 @@ -313,8 +313,8 @@ static int cifs_stats_proc_show(struct seq_file *m, void *v)
49014 smBufAllocCount.counter, cifs_min_small);
49015 #ifdef CONFIG_CIFS_STATS2
49016 seq_printf(m, "Total Large %d Small %d Allocations\n",
49017 - atomic_read(&totBufAllocCount),
49018 - atomic_read(&totSmBufAllocCount));
49019 + atomic_read_unchecked(&totBufAllocCount),
49020 + atomic_read_unchecked(&totSmBufAllocCount));
49021 #endif /* CONFIG_CIFS_STATS2 */
49022
49023 seq_printf(m, "Operations (MIDs): %d\n", atomic_read(&midCount));
49024 @@ -343,7 +343,7 @@ static int cifs_stats_proc_show(struct seq_file *m, void *v)
49025 if (tcon->need_reconnect)
49026 seq_puts(m, "\tDISCONNECTED ");
49027 seq_printf(m, "\nSMBs: %d",
49028 - atomic_read(&tcon->num_smbs_sent));
49029 + atomic_read_unchecked(&tcon->num_smbs_sent));
49030 if (server->ops->print_stats)
49031 server->ops->print_stats(m, tcon);
49032 }
49033 diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c
49034 index e328339..322228b 100644
49035 --- a/fs/cifs/cifsfs.c
49036 +++ b/fs/cifs/cifsfs.c
49037 @@ -1002,7 +1002,7 @@ cifs_init_request_bufs(void)
49038 /* cERROR(1, "CIFSMaxBufSize %d 0x%x",CIFSMaxBufSize,CIFSMaxBufSize); */
49039 cifs_req_cachep = kmem_cache_create("cifs_request",
49040 CIFSMaxBufSize + max_hdr_size, 0,
49041 - SLAB_HWCACHE_ALIGN, NULL);
49042 + SLAB_HWCACHE_ALIGN | SLAB_USERCOPY, NULL);
49043 if (cifs_req_cachep == NULL)
49044 return -ENOMEM;
49045
49046 @@ -1029,7 +1029,7 @@ cifs_init_request_bufs(void)
49047 efficient to alloc 1 per page off the slab compared to 17K (5page)
49048 alloc of large cifs buffers even when page debugging is on */
49049 cifs_sm_req_cachep = kmem_cache_create("cifs_small_rq",
49050 - MAX_CIFS_SMALL_BUFFER_SIZE, 0, SLAB_HWCACHE_ALIGN,
49051 + MAX_CIFS_SMALL_BUFFER_SIZE, 0, SLAB_HWCACHE_ALIGN | SLAB_USERCOPY,
49052 NULL);
49053 if (cifs_sm_req_cachep == NULL) {
49054 mempool_destroy(cifs_req_poolp);
49055 @@ -1114,8 +1114,8 @@ init_cifs(void)
49056 atomic_set(&bufAllocCount, 0);
49057 atomic_set(&smBufAllocCount, 0);
49058 #ifdef CONFIG_CIFS_STATS2
49059 - atomic_set(&totBufAllocCount, 0);
49060 - atomic_set(&totSmBufAllocCount, 0);
49061 + atomic_set_unchecked(&totBufAllocCount, 0);
49062 + atomic_set_unchecked(&totSmBufAllocCount, 0);
49063 #endif /* CONFIG_CIFS_STATS2 */
49064
49065 atomic_set(&midCount, 0);
49066 diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h
49067 index e6899ce..d6b2920 100644
49068 --- a/fs/cifs/cifsglob.h
49069 +++ b/fs/cifs/cifsglob.h
49070 @@ -751,35 +751,35 @@ struct cifs_tcon {
49071 __u16 Flags; /* optional support bits */
49072 enum statusEnum tidStatus;
49073 #ifdef CONFIG_CIFS_STATS
49074 - atomic_t num_smbs_sent;
49075 + atomic_unchecked_t num_smbs_sent;
49076 union {
49077 struct {
49078 - atomic_t num_writes;
49079 - atomic_t num_reads;
49080 - atomic_t num_flushes;
49081 - atomic_t num_oplock_brks;
49082 - atomic_t num_opens;
49083 - atomic_t num_closes;
49084 - atomic_t num_deletes;
49085 - atomic_t num_mkdirs;
49086 - atomic_t num_posixopens;
49087 - atomic_t num_posixmkdirs;
49088 - atomic_t num_rmdirs;
49089 - atomic_t num_renames;
49090 - atomic_t num_t2renames;
49091 - atomic_t num_ffirst;
49092 - atomic_t num_fnext;
49093 - atomic_t num_fclose;
49094 - atomic_t num_hardlinks;
49095 - atomic_t num_symlinks;
49096 - atomic_t num_locks;
49097 - atomic_t num_acl_get;
49098 - atomic_t num_acl_set;
49099 + atomic_unchecked_t num_writes;
49100 + atomic_unchecked_t num_reads;
49101 + atomic_unchecked_t num_flushes;
49102 + atomic_unchecked_t num_oplock_brks;
49103 + atomic_unchecked_t num_opens;
49104 + atomic_unchecked_t num_closes;
49105 + atomic_unchecked_t num_deletes;
49106 + atomic_unchecked_t num_mkdirs;
49107 + atomic_unchecked_t num_posixopens;
49108 + atomic_unchecked_t num_posixmkdirs;
49109 + atomic_unchecked_t num_rmdirs;
49110 + atomic_unchecked_t num_renames;
49111 + atomic_unchecked_t num_t2renames;
49112 + atomic_unchecked_t num_ffirst;
49113 + atomic_unchecked_t num_fnext;
49114 + atomic_unchecked_t num_fclose;
49115 + atomic_unchecked_t num_hardlinks;
49116 + atomic_unchecked_t num_symlinks;
49117 + atomic_unchecked_t num_locks;
49118 + atomic_unchecked_t num_acl_get;
49119 + atomic_unchecked_t num_acl_set;
49120 } cifs_stats;
49121 #ifdef CONFIG_CIFS_SMB2
49122 struct {
49123 - atomic_t smb2_com_sent[NUMBER_OF_SMB2_COMMANDS];
49124 - atomic_t smb2_com_failed[NUMBER_OF_SMB2_COMMANDS];
49125 + atomic_unchecked_t smb2_com_sent[NUMBER_OF_SMB2_COMMANDS];
49126 + atomic_unchecked_t smb2_com_failed[NUMBER_OF_SMB2_COMMANDS];
49127 } smb2_stats;
49128 #endif /* CONFIG_CIFS_SMB2 */
49129 } stats;
49130 @@ -1080,7 +1080,7 @@ convert_delimiter(char *path, char delim)
49131 }
49132
49133 #ifdef CONFIG_CIFS_STATS
49134 -#define cifs_stats_inc atomic_inc
49135 +#define cifs_stats_inc atomic_inc_unchecked
49136
49137 static inline void cifs_stats_bytes_written(struct cifs_tcon *tcon,
49138 unsigned int bytes)
49139 @@ -1445,8 +1445,8 @@ GLOBAL_EXTERN atomic_t tconInfoReconnectCount;
49140 /* Various Debug counters */
49141 GLOBAL_EXTERN atomic_t bufAllocCount; /* current number allocated */
49142 #ifdef CONFIG_CIFS_STATS2
49143 -GLOBAL_EXTERN atomic_t totBufAllocCount; /* total allocated over all time */
49144 -GLOBAL_EXTERN atomic_t totSmBufAllocCount;
49145 +GLOBAL_EXTERN atomic_unchecked_t totBufAllocCount; /* total allocated over all time */
49146 +GLOBAL_EXTERN atomic_unchecked_t totSmBufAllocCount;
49147 #endif
49148 GLOBAL_EXTERN atomic_t smBufAllocCount;
49149 GLOBAL_EXTERN atomic_t midCount;
49150 diff --git a/fs/cifs/link.c b/fs/cifs/link.c
49151 index 51dc2fb..1e12a33 100644
49152 --- a/fs/cifs/link.c
49153 +++ b/fs/cifs/link.c
49154 @@ -616,7 +616,7 @@ symlink_exit:
49155
49156 void cifs_put_link(struct dentry *direntry, struct nameidata *nd, void *cookie)
49157 {
49158 - char *p = nd_get_link(nd);
49159 + const char *p = nd_get_link(nd);
49160 if (!IS_ERR(p))
49161 kfree(p);
49162 }
49163 diff --git a/fs/cifs/misc.c b/fs/cifs/misc.c
49164 index 3a00c0d..42d901c 100644
49165 --- a/fs/cifs/misc.c
49166 +++ b/fs/cifs/misc.c
49167 @@ -169,7 +169,7 @@ cifs_buf_get(void)
49168 memset(ret_buf, 0, buf_size + 3);
49169 atomic_inc(&bufAllocCount);
49170 #ifdef CONFIG_CIFS_STATS2
49171 - atomic_inc(&totBufAllocCount);
49172 + atomic_inc_unchecked(&totBufAllocCount);
49173 #endif /* CONFIG_CIFS_STATS2 */
49174 }
49175
49176 @@ -204,7 +204,7 @@ cifs_small_buf_get(void)
49177 /* memset(ret_buf, 0, sizeof(struct smb_hdr) + 27);*/
49178 atomic_inc(&smBufAllocCount);
49179 #ifdef CONFIG_CIFS_STATS2
49180 - atomic_inc(&totSmBufAllocCount);
49181 + atomic_inc_unchecked(&totSmBufAllocCount);
49182 #endif /* CONFIG_CIFS_STATS2 */
49183
49184 }
49185 diff --git a/fs/cifs/smb1ops.c b/fs/cifs/smb1ops.c
49186 index 47bc5a8..10decbe 100644
49187 --- a/fs/cifs/smb1ops.c
49188 +++ b/fs/cifs/smb1ops.c
49189 @@ -586,27 +586,27 @@ static void
49190 cifs_clear_stats(struct cifs_tcon *tcon)
49191 {
49192 #ifdef CONFIG_CIFS_STATS
49193 - atomic_set(&tcon->stats.cifs_stats.num_writes, 0);
49194 - atomic_set(&tcon->stats.cifs_stats.num_reads, 0);
49195 - atomic_set(&tcon->stats.cifs_stats.num_flushes, 0);
49196 - atomic_set(&tcon->stats.cifs_stats.num_oplock_brks, 0);
49197 - atomic_set(&tcon->stats.cifs_stats.num_opens, 0);
49198 - atomic_set(&tcon->stats.cifs_stats.num_posixopens, 0);
49199 - atomic_set(&tcon->stats.cifs_stats.num_posixmkdirs, 0);
49200 - atomic_set(&tcon->stats.cifs_stats.num_closes, 0);
49201 - atomic_set(&tcon->stats.cifs_stats.num_deletes, 0);
49202 - atomic_set(&tcon->stats.cifs_stats.num_mkdirs, 0);
49203 - atomic_set(&tcon->stats.cifs_stats.num_rmdirs, 0);
49204 - atomic_set(&tcon->stats.cifs_stats.num_renames, 0);
49205 - atomic_set(&tcon->stats.cifs_stats.num_t2renames, 0);
49206 - atomic_set(&tcon->stats.cifs_stats.num_ffirst, 0);
49207 - atomic_set(&tcon->stats.cifs_stats.num_fnext, 0);
49208 - atomic_set(&tcon->stats.cifs_stats.num_fclose, 0);
49209 - atomic_set(&tcon->stats.cifs_stats.num_hardlinks, 0);
49210 - atomic_set(&tcon->stats.cifs_stats.num_symlinks, 0);
49211 - atomic_set(&tcon->stats.cifs_stats.num_locks, 0);
49212 - atomic_set(&tcon->stats.cifs_stats.num_acl_get, 0);
49213 - atomic_set(&tcon->stats.cifs_stats.num_acl_set, 0);
49214 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_writes, 0);
49215 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_reads, 0);
49216 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_flushes, 0);
49217 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_oplock_brks, 0);
49218 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_opens, 0);
49219 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_posixopens, 0);
49220 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_posixmkdirs, 0);
49221 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_closes, 0);
49222 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_deletes, 0);
49223 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_mkdirs, 0);
49224 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_rmdirs, 0);
49225 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_renames, 0);
49226 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_t2renames, 0);
49227 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_ffirst, 0);
49228 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_fnext, 0);
49229 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_fclose, 0);
49230 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_hardlinks, 0);
49231 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_symlinks, 0);
49232 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_locks, 0);
49233 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_acl_get, 0);
49234 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_acl_set, 0);
49235 #endif
49236 }
49237
49238 @@ -615,36 +615,36 @@ cifs_print_stats(struct seq_file *m, struct cifs_tcon *tcon)
49239 {
49240 #ifdef CONFIG_CIFS_STATS
49241 seq_printf(m, " Oplocks breaks: %d",
49242 - atomic_read(&tcon->stats.cifs_stats.num_oplock_brks));
49243 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_oplock_brks));
49244 seq_printf(m, "\nReads: %d Bytes: %llu",
49245 - atomic_read(&tcon->stats.cifs_stats.num_reads),
49246 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_reads),
49247 (long long)(tcon->bytes_read));
49248 seq_printf(m, "\nWrites: %d Bytes: %llu",
49249 - atomic_read(&tcon->stats.cifs_stats.num_writes),
49250 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_writes),
49251 (long long)(tcon->bytes_written));
49252 seq_printf(m, "\nFlushes: %d",
49253 - atomic_read(&tcon->stats.cifs_stats.num_flushes));
49254 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_flushes));
49255 seq_printf(m, "\nLocks: %d HardLinks: %d Symlinks: %d",
49256 - atomic_read(&tcon->stats.cifs_stats.num_locks),
49257 - atomic_read(&tcon->stats.cifs_stats.num_hardlinks),
49258 - atomic_read(&tcon->stats.cifs_stats.num_symlinks));
49259 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_locks),
49260 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_hardlinks),
49261 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_symlinks));
49262 seq_printf(m, "\nOpens: %d Closes: %d Deletes: %d",
49263 - atomic_read(&tcon->stats.cifs_stats.num_opens),
49264 - atomic_read(&tcon->stats.cifs_stats.num_closes),
49265 - atomic_read(&tcon->stats.cifs_stats.num_deletes));
49266 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_opens),
49267 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_closes),
49268 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_deletes));
49269 seq_printf(m, "\nPosix Opens: %d Posix Mkdirs: %d",
49270 - atomic_read(&tcon->stats.cifs_stats.num_posixopens),
49271 - atomic_read(&tcon->stats.cifs_stats.num_posixmkdirs));
49272 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_posixopens),
49273 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_posixmkdirs));
49274 seq_printf(m, "\nMkdirs: %d Rmdirs: %d",
49275 - atomic_read(&tcon->stats.cifs_stats.num_mkdirs),
49276 - atomic_read(&tcon->stats.cifs_stats.num_rmdirs));
49277 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_mkdirs),
49278 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_rmdirs));
49279 seq_printf(m, "\nRenames: %d T2 Renames %d",
49280 - atomic_read(&tcon->stats.cifs_stats.num_renames),
49281 - atomic_read(&tcon->stats.cifs_stats.num_t2renames));
49282 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_renames),
49283 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_t2renames));
49284 seq_printf(m, "\nFindFirst: %d FNext %d FClose %d",
49285 - atomic_read(&tcon->stats.cifs_stats.num_ffirst),
49286 - atomic_read(&tcon->stats.cifs_stats.num_fnext),
49287 - atomic_read(&tcon->stats.cifs_stats.num_fclose));
49288 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_ffirst),
49289 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_fnext),
49290 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_fclose));
49291 #endif
49292 }
49293
49294 diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c
49295 index bceffe7..cd1ae59 100644
49296 --- a/fs/cifs/smb2ops.c
49297 +++ b/fs/cifs/smb2ops.c
49298 @@ -274,8 +274,8 @@ smb2_clear_stats(struct cifs_tcon *tcon)
49299 #ifdef CONFIG_CIFS_STATS
49300 int i;
49301 for (i = 0; i < NUMBER_OF_SMB2_COMMANDS; i++) {
49302 - atomic_set(&tcon->stats.smb2_stats.smb2_com_sent[i], 0);
49303 - atomic_set(&tcon->stats.smb2_stats.smb2_com_failed[i], 0);
49304 + atomic_set_unchecked(&tcon->stats.smb2_stats.smb2_com_sent[i], 0);
49305 + atomic_set_unchecked(&tcon->stats.smb2_stats.smb2_com_failed[i], 0);
49306 }
49307 #endif
49308 }
49309 @@ -284,66 +284,66 @@ static void
49310 smb2_print_stats(struct seq_file *m, struct cifs_tcon *tcon)
49311 {
49312 #ifdef CONFIG_CIFS_STATS
49313 - atomic_t *sent = tcon->stats.smb2_stats.smb2_com_sent;
49314 - atomic_t *failed = tcon->stats.smb2_stats.smb2_com_failed;
49315 + atomic_unchecked_t *sent = tcon->stats.smb2_stats.smb2_com_sent;
49316 + atomic_unchecked_t *failed = tcon->stats.smb2_stats.smb2_com_failed;
49317 seq_printf(m, "\nNegotiates: %d sent %d failed",
49318 - atomic_read(&sent[SMB2_NEGOTIATE_HE]),
49319 - atomic_read(&failed[SMB2_NEGOTIATE_HE]));
49320 + atomic_read_unchecked(&sent[SMB2_NEGOTIATE_HE]),
49321 + atomic_read_unchecked(&failed[SMB2_NEGOTIATE_HE]));
49322 seq_printf(m, "\nSessionSetups: %d sent %d failed",
49323 - atomic_read(&sent[SMB2_SESSION_SETUP_HE]),
49324 - atomic_read(&failed[SMB2_SESSION_SETUP_HE]));
49325 + atomic_read_unchecked(&sent[SMB2_SESSION_SETUP_HE]),
49326 + atomic_read_unchecked(&failed[SMB2_SESSION_SETUP_HE]));
49327 #define SMB2LOGOFF 0x0002 /* trivial request/resp */
49328 seq_printf(m, "\nLogoffs: %d sent %d failed",
49329 - atomic_read(&sent[SMB2_LOGOFF_HE]),
49330 - atomic_read(&failed[SMB2_LOGOFF_HE]));
49331 + atomic_read_unchecked(&sent[SMB2_LOGOFF_HE]),
49332 + atomic_read_unchecked(&failed[SMB2_LOGOFF_HE]));
49333 seq_printf(m, "\nTreeConnects: %d sent %d failed",
49334 - atomic_read(&sent[SMB2_TREE_CONNECT_HE]),
49335 - atomic_read(&failed[SMB2_TREE_CONNECT_HE]));
49336 + atomic_read_unchecked(&sent[SMB2_TREE_CONNECT_HE]),
49337 + atomic_read_unchecked(&failed[SMB2_TREE_CONNECT_HE]));
49338 seq_printf(m, "\nTreeDisconnects: %d sent %d failed",
49339 - atomic_read(&sent[SMB2_TREE_DISCONNECT_HE]),
49340 - atomic_read(&failed[SMB2_TREE_DISCONNECT_HE]));
49341 + atomic_read_unchecked(&sent[SMB2_TREE_DISCONNECT_HE]),
49342 + atomic_read_unchecked(&failed[SMB2_TREE_DISCONNECT_HE]));
49343 seq_printf(m, "\nCreates: %d sent %d failed",
49344 - atomic_read(&sent[SMB2_CREATE_HE]),
49345 - atomic_read(&failed[SMB2_CREATE_HE]));
49346 + atomic_read_unchecked(&sent[SMB2_CREATE_HE]),
49347 + atomic_read_unchecked(&failed[SMB2_CREATE_HE]));
49348 seq_printf(m, "\nCloses: %d sent %d failed",
49349 - atomic_read(&sent[SMB2_CLOSE_HE]),
49350 - atomic_read(&failed[SMB2_CLOSE_HE]));
49351 + atomic_read_unchecked(&sent[SMB2_CLOSE_HE]),
49352 + atomic_read_unchecked(&failed[SMB2_CLOSE_HE]));
49353 seq_printf(m, "\nFlushes: %d sent %d failed",
49354 - atomic_read(&sent[SMB2_FLUSH_HE]),
49355 - atomic_read(&failed[SMB2_FLUSH_HE]));
49356 + atomic_read_unchecked(&sent[SMB2_FLUSH_HE]),
49357 + atomic_read_unchecked(&failed[SMB2_FLUSH_HE]));
49358 seq_printf(m, "\nReads: %d sent %d failed",
49359 - atomic_read(&sent[SMB2_READ_HE]),
49360 - atomic_read(&failed[SMB2_READ_HE]));
49361 + atomic_read_unchecked(&sent[SMB2_READ_HE]),
49362 + atomic_read_unchecked(&failed[SMB2_READ_HE]));
49363 seq_printf(m, "\nWrites: %d sent %d failed",
49364 - atomic_read(&sent[SMB2_WRITE_HE]),
49365 - atomic_read(&failed[SMB2_WRITE_HE]));
49366 + atomic_read_unchecked(&sent[SMB2_WRITE_HE]),
49367 + atomic_read_unchecked(&failed[SMB2_WRITE_HE]));
49368 seq_printf(m, "\nLocks: %d sent %d failed",
49369 - atomic_read(&sent[SMB2_LOCK_HE]),
49370 - atomic_read(&failed[SMB2_LOCK_HE]));
49371 + atomic_read_unchecked(&sent[SMB2_LOCK_HE]),
49372 + atomic_read_unchecked(&failed[SMB2_LOCK_HE]));
49373 seq_printf(m, "\nIOCTLs: %d sent %d failed",
49374 - atomic_read(&sent[SMB2_IOCTL_HE]),
49375 - atomic_read(&failed[SMB2_IOCTL_HE]));
49376 + atomic_read_unchecked(&sent[SMB2_IOCTL_HE]),
49377 + atomic_read_unchecked(&failed[SMB2_IOCTL_HE]));
49378 seq_printf(m, "\nCancels: %d sent %d failed",
49379 - atomic_read(&sent[SMB2_CANCEL_HE]),
49380 - atomic_read(&failed[SMB2_CANCEL_HE]));
49381 + atomic_read_unchecked(&sent[SMB2_CANCEL_HE]),
49382 + atomic_read_unchecked(&failed[SMB2_CANCEL_HE]));
49383 seq_printf(m, "\nEchos: %d sent %d failed",
49384 - atomic_read(&sent[SMB2_ECHO_HE]),
49385 - atomic_read(&failed[SMB2_ECHO_HE]));
49386 + atomic_read_unchecked(&sent[SMB2_ECHO_HE]),
49387 + atomic_read_unchecked(&failed[SMB2_ECHO_HE]));
49388 seq_printf(m, "\nQueryDirectories: %d sent %d failed",
49389 - atomic_read(&sent[SMB2_QUERY_DIRECTORY_HE]),
49390 - atomic_read(&failed[SMB2_QUERY_DIRECTORY_HE]));
49391 + atomic_read_unchecked(&sent[SMB2_QUERY_DIRECTORY_HE]),
49392 + atomic_read_unchecked(&failed[SMB2_QUERY_DIRECTORY_HE]));
49393 seq_printf(m, "\nChangeNotifies: %d sent %d failed",
49394 - atomic_read(&sent[SMB2_CHANGE_NOTIFY_HE]),
49395 - atomic_read(&failed[SMB2_CHANGE_NOTIFY_HE]));
49396 + atomic_read_unchecked(&sent[SMB2_CHANGE_NOTIFY_HE]),
49397 + atomic_read_unchecked(&failed[SMB2_CHANGE_NOTIFY_HE]));
49398 seq_printf(m, "\nQueryInfos: %d sent %d failed",
49399 - atomic_read(&sent[SMB2_QUERY_INFO_HE]),
49400 - atomic_read(&failed[SMB2_QUERY_INFO_HE]));
49401 + atomic_read_unchecked(&sent[SMB2_QUERY_INFO_HE]),
49402 + atomic_read_unchecked(&failed[SMB2_QUERY_INFO_HE]));
49403 seq_printf(m, "\nSetInfos: %d sent %d failed",
49404 - atomic_read(&sent[SMB2_SET_INFO_HE]),
49405 - atomic_read(&failed[SMB2_SET_INFO_HE]));
49406 + atomic_read_unchecked(&sent[SMB2_SET_INFO_HE]),
49407 + atomic_read_unchecked(&failed[SMB2_SET_INFO_HE]));
49408 seq_printf(m, "\nOplockBreaks: %d sent %d failed",
49409 - atomic_read(&sent[SMB2_OPLOCK_BREAK_HE]),
49410 - atomic_read(&failed[SMB2_OPLOCK_BREAK_HE]));
49411 + atomic_read_unchecked(&sent[SMB2_OPLOCK_BREAK_HE]),
49412 + atomic_read_unchecked(&failed[SMB2_OPLOCK_BREAK_HE]));
49413 #endif
49414 }
49415
49416 diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c
49417 index 41d9d07..dbb4772 100644
49418 --- a/fs/cifs/smb2pdu.c
49419 +++ b/fs/cifs/smb2pdu.c
49420 @@ -1761,8 +1761,7 @@ SMB2_query_directory(const unsigned int xid, struct cifs_tcon *tcon,
49421 default:
49422 cERROR(1, "info level %u isn't supported",
49423 srch_inf->info_level);
49424 - rc = -EINVAL;
49425 - goto qdir_exit;
49426 + return -EINVAL;
49427 }
49428
49429 req->FileIndex = cpu_to_le32(index);
49430 diff --git a/fs/coda/cache.c b/fs/coda/cache.c
49431 index 958ae0e..505c9d0 100644
49432 --- a/fs/coda/cache.c
49433 +++ b/fs/coda/cache.c
49434 @@ -24,7 +24,7 @@
49435 #include "coda_linux.h"
49436 #include "coda_cache.h"
49437
49438 -static atomic_t permission_epoch = ATOMIC_INIT(0);
49439 +static atomic_unchecked_t permission_epoch = ATOMIC_INIT(0);
49440
49441 /* replace or extend an acl cache hit */
49442 void coda_cache_enter(struct inode *inode, int mask)
49443 @@ -32,7 +32,7 @@ void coda_cache_enter(struct inode *inode, int mask)
49444 struct coda_inode_info *cii = ITOC(inode);
49445
49446 spin_lock(&cii->c_lock);
49447 - cii->c_cached_epoch = atomic_read(&permission_epoch);
49448 + cii->c_cached_epoch = atomic_read_unchecked(&permission_epoch);
49449 if (cii->c_uid != current_fsuid()) {
49450 cii->c_uid = current_fsuid();
49451 cii->c_cached_perm = mask;
49452 @@ -46,14 +46,14 @@ void coda_cache_clear_inode(struct inode *inode)
49453 {
49454 struct coda_inode_info *cii = ITOC(inode);
49455 spin_lock(&cii->c_lock);
49456 - cii->c_cached_epoch = atomic_read(&permission_epoch) - 1;
49457 + cii->c_cached_epoch = atomic_read_unchecked(&permission_epoch) - 1;
49458 spin_unlock(&cii->c_lock);
49459 }
49460
49461 /* remove all acl caches */
49462 void coda_cache_clear_all(struct super_block *sb)
49463 {
49464 - atomic_inc(&permission_epoch);
49465 + atomic_inc_unchecked(&permission_epoch);
49466 }
49467
49468
49469 @@ -66,7 +66,7 @@ int coda_cache_check(struct inode *inode, int mask)
49470 spin_lock(&cii->c_lock);
49471 hit = (mask & cii->c_cached_perm) == mask &&
49472 cii->c_uid == current_fsuid() &&
49473 - cii->c_cached_epoch == atomic_read(&permission_epoch);
49474 + cii->c_cached_epoch == atomic_read_unchecked(&permission_epoch);
49475 spin_unlock(&cii->c_lock);
49476
49477 return hit;
49478 diff --git a/fs/compat.c b/fs/compat.c
49479 index a06dcbc..dacb6d3 100644
49480 --- a/fs/compat.c
49481 +++ b/fs/compat.c
49482 @@ -54,7 +54,7 @@
49483 #include <asm/ioctls.h>
49484 #include "internal.h"
49485
49486 -int compat_log = 1;
49487 +int compat_log = 0;
49488
49489 int compat_printk(const char *fmt, ...)
49490 {
49491 @@ -490,7 +490,7 @@ compat_sys_io_setup(unsigned nr_reqs, u32 __user *ctx32p)
49492
49493 set_fs(KERNEL_DS);
49494 /* The __user pointer cast is valid because of the set_fs() */
49495 - ret = sys_io_setup(nr_reqs, (aio_context_t __user *) &ctx64);
49496 + ret = sys_io_setup(nr_reqs, (aio_context_t __force_user *) &ctx64);
49497 set_fs(oldfs);
49498 /* truncating is ok because it's a user address */
49499 if (!ret)
49500 @@ -548,7 +548,7 @@ ssize_t compat_rw_copy_check_uvector(int type,
49501 goto out;
49502
49503 ret = -EINVAL;
49504 - if (nr_segs > UIO_MAXIOV || nr_segs < 0)
49505 + if (nr_segs > UIO_MAXIOV)
49506 goto out;
49507 if (nr_segs > fast_segs) {
49508 ret = -ENOMEM;
49509 @@ -835,6 +835,7 @@ struct compat_old_linux_dirent {
49510
49511 struct compat_readdir_callback {
49512 struct compat_old_linux_dirent __user *dirent;
49513 + struct file * file;
49514 int result;
49515 };
49516
49517 @@ -852,6 +853,10 @@ static int compat_fillonedir(void *__buf, const char *name, int namlen,
49518 buf->result = -EOVERFLOW;
49519 return -EOVERFLOW;
49520 }
49521 +
49522 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
49523 + return 0;
49524 +
49525 buf->result++;
49526 dirent = buf->dirent;
49527 if (!access_ok(VERIFY_WRITE, dirent,
49528 @@ -882,6 +887,7 @@ asmlinkage long compat_sys_old_readdir(unsigned int fd,
49529
49530 buf.result = 0;
49531 buf.dirent = dirent;
49532 + buf.file = f.file;
49533
49534 error = vfs_readdir(f.file, compat_fillonedir, &buf);
49535 if (buf.result)
49536 @@ -901,6 +907,7 @@ struct compat_linux_dirent {
49537 struct compat_getdents_callback {
49538 struct compat_linux_dirent __user *current_dir;
49539 struct compat_linux_dirent __user *previous;
49540 + struct file * file;
49541 int count;
49542 int error;
49543 };
49544 @@ -922,6 +929,10 @@ static int compat_filldir(void *__buf, const char *name, int namlen,
49545 buf->error = -EOVERFLOW;
49546 return -EOVERFLOW;
49547 }
49548 +
49549 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
49550 + return 0;
49551 +
49552 dirent = buf->previous;
49553 if (dirent) {
49554 if (__put_user(offset, &dirent->d_off))
49555 @@ -967,6 +978,7 @@ asmlinkage long compat_sys_getdents(unsigned int fd,
49556 buf.previous = NULL;
49557 buf.count = count;
49558 buf.error = 0;
49559 + buf.file = f.file;
49560
49561 error = vfs_readdir(f.file, compat_filldir, &buf);
49562 if (error >= 0)
49563 @@ -987,6 +999,7 @@ asmlinkage long compat_sys_getdents(unsigned int fd,
49564 struct compat_getdents_callback64 {
49565 struct linux_dirent64 __user *current_dir;
49566 struct linux_dirent64 __user *previous;
49567 + struct file * file;
49568 int count;
49569 int error;
49570 };
49571 @@ -1003,6 +1016,10 @@ static int compat_filldir64(void * __buf, const char * name, int namlen, loff_t
49572 buf->error = -EINVAL; /* only used if we fail.. */
49573 if (reclen > buf->count)
49574 return -EINVAL;
49575 +
49576 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
49577 + return 0;
49578 +
49579 dirent = buf->previous;
49580
49581 if (dirent) {
49582 @@ -1052,13 +1069,14 @@ asmlinkage long compat_sys_getdents64(unsigned int fd,
49583 buf.previous = NULL;
49584 buf.count = count;
49585 buf.error = 0;
49586 + buf.file = f.file;
49587
49588 error = vfs_readdir(f.file, compat_filldir64, &buf);
49589 if (error >= 0)
49590 error = buf.error;
49591 lastdirent = buf.previous;
49592 if (lastdirent) {
49593 - typeof(lastdirent->d_off) d_off = f.file->f_pos;
49594 + typeof(((struct linux_dirent64 *)0)->d_off) d_off = f.file->f_pos;
49595 if (__put_user_unaligned(d_off, &lastdirent->d_off))
49596 error = -EFAULT;
49597 else
49598 diff --git a/fs/compat_binfmt_elf.c b/fs/compat_binfmt_elf.c
49599 index a81147e..20bf2b5 100644
49600 --- a/fs/compat_binfmt_elf.c
49601 +++ b/fs/compat_binfmt_elf.c
49602 @@ -30,11 +30,13 @@
49603 #undef elf_phdr
49604 #undef elf_shdr
49605 #undef elf_note
49606 +#undef elf_dyn
49607 #undef elf_addr_t
49608 #define elfhdr elf32_hdr
49609 #define elf_phdr elf32_phdr
49610 #define elf_shdr elf32_shdr
49611 #define elf_note elf32_note
49612 +#define elf_dyn Elf32_Dyn
49613 #define elf_addr_t Elf32_Addr
49614
49615 /*
49616 diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c
49617 index e2f57a0..3c78771 100644
49618 --- a/fs/compat_ioctl.c
49619 +++ b/fs/compat_ioctl.c
49620 @@ -623,7 +623,7 @@ static int serial_struct_ioctl(unsigned fd, unsigned cmd,
49621 return -EFAULT;
49622 if (__get_user(udata, &ss32->iomem_base))
49623 return -EFAULT;
49624 - ss.iomem_base = compat_ptr(udata);
49625 + ss.iomem_base = (unsigned char __force_kernel *)compat_ptr(udata);
49626 if (__get_user(ss.iomem_reg_shift, &ss32->iomem_reg_shift) ||
49627 __get_user(ss.port_high, &ss32->port_high))
49628 return -EFAULT;
49629 @@ -798,7 +798,7 @@ static int compat_ioctl_preallocate(struct file *file,
49630 copy_in_user(&p->l_len, &p32->l_len, sizeof(s64)) ||
49631 copy_in_user(&p->l_sysid, &p32->l_sysid, sizeof(s32)) ||
49632 copy_in_user(&p->l_pid, &p32->l_pid, sizeof(u32)) ||
49633 - copy_in_user(&p->l_pad, &p32->l_pad, 4*sizeof(u32)))
49634 + copy_in_user(p->l_pad, &p32->l_pad, 4*sizeof(u32)))
49635 return -EFAULT;
49636
49637 return ioctl_preallocate(file, p);
49638 @@ -1620,8 +1620,8 @@ asmlinkage long compat_sys_ioctl(unsigned int fd, unsigned int cmd,
49639 static int __init init_sys32_ioctl_cmp(const void *p, const void *q)
49640 {
49641 unsigned int a, b;
49642 - a = *(unsigned int *)p;
49643 - b = *(unsigned int *)q;
49644 + a = *(const unsigned int *)p;
49645 + b = *(const unsigned int *)q;
49646 if (a > b)
49647 return 1;
49648 if (a < b)
49649 diff --git a/fs/configfs/dir.c b/fs/configfs/dir.c
49650 index 712b10f..c33c4ca 100644
49651 --- a/fs/configfs/dir.c
49652 +++ b/fs/configfs/dir.c
49653 @@ -1037,10 +1037,11 @@ static int configfs_dump(struct configfs_dirent *sd, int level)
49654 static int configfs_depend_prep(struct dentry *origin,
49655 struct config_item *target)
49656 {
49657 - struct configfs_dirent *child_sd, *sd = origin->d_fsdata;
49658 + struct configfs_dirent *child_sd, *sd;
49659 int ret = 0;
49660
49661 - BUG_ON(!origin || !sd);
49662 + BUG_ON(!origin || !origin->d_fsdata);
49663 + sd = origin->d_fsdata;
49664
49665 if (sd->s_element == target) /* Boo-yah */
49666 goto out;
49667 @@ -1564,7 +1565,8 @@ static int configfs_readdir(struct file * filp, void * dirent, filldir_t filldir
49668 }
49669 for (p=q->next; p!= &parent_sd->s_children; p=p->next) {
49670 struct configfs_dirent *next;
49671 - const char * name;
49672 + const unsigned char * name;
49673 + char d_name[sizeof(next->s_dentry->d_iname)];
49674 int len;
49675 struct inode *inode = NULL;
49676
49677 @@ -1574,7 +1576,12 @@ static int configfs_readdir(struct file * filp, void * dirent, filldir_t filldir
49678 continue;
49679
49680 name = configfs_get_name(next);
49681 - len = strlen(name);
49682 + if (next->s_dentry && name == next->s_dentry->d_iname) {
49683 + len = next->s_dentry->d_name.len;
49684 + memcpy(d_name, name, len);
49685 + name = d_name;
49686 + } else
49687 + len = strlen(name);
49688
49689 /*
49690 * We'll have a dentry and an inode for
49691 diff --git a/fs/coredump.c b/fs/coredump.c
49692 index 1774932..5812106 100644
49693 --- a/fs/coredump.c
49694 +++ b/fs/coredump.c
49695 @@ -52,7 +52,7 @@ struct core_name {
49696 char *corename;
49697 int used, size;
49698 };
49699 -static atomic_t call_count = ATOMIC_INIT(1);
49700 +static atomic_unchecked_t call_count = ATOMIC_INIT(1);
49701
49702 /* The maximal length of core_pattern is also specified in sysctl.c */
49703
49704 @@ -60,7 +60,7 @@ static int expand_corename(struct core_name *cn)
49705 {
49706 char *old_corename = cn->corename;
49707
49708 - cn->size = CORENAME_MAX_SIZE * atomic_inc_return(&call_count);
49709 + cn->size = CORENAME_MAX_SIZE * atomic_inc_return_unchecked(&call_count);
49710 cn->corename = krealloc(old_corename, cn->size, GFP_KERNEL);
49711
49712 if (!cn->corename) {
49713 @@ -157,7 +157,7 @@ static int format_corename(struct core_name *cn, struct coredump_params *cprm)
49714 int pid_in_pattern = 0;
49715 int err = 0;
49716
49717 - cn->size = CORENAME_MAX_SIZE * atomic_read(&call_count);
49718 + cn->size = CORENAME_MAX_SIZE * atomic_read_unchecked(&call_count);
49719 cn->corename = kmalloc(cn->size, GFP_KERNEL);
49720 cn->used = 0;
49721
49722 @@ -414,17 +414,17 @@ static void wait_for_dump_helpers(struct file *file)
49723 pipe = file->f_path.dentry->d_inode->i_pipe;
49724
49725 pipe_lock(pipe);
49726 - pipe->readers++;
49727 - pipe->writers--;
49728 + atomic_inc(&pipe->readers);
49729 + atomic_dec(&pipe->writers);
49730
49731 - while ((pipe->readers > 1) && (!signal_pending(current))) {
49732 + while ((atomic_read(&pipe->readers) > 1) && (!signal_pending(current))) {
49733 wake_up_interruptible_sync(&pipe->wait);
49734 kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN);
49735 pipe_wait(pipe);
49736 }
49737
49738 - pipe->readers--;
49739 - pipe->writers++;
49740 + atomic_dec(&pipe->readers);
49741 + atomic_inc(&pipe->writers);
49742 pipe_unlock(pipe);
49743
49744 }
49745 @@ -471,7 +471,8 @@ void do_coredump(siginfo_t *siginfo)
49746 int ispipe;
49747 struct files_struct *displaced;
49748 bool need_nonrelative = false;
49749 - static atomic_t core_dump_count = ATOMIC_INIT(0);
49750 + static atomic_unchecked_t core_dump_count = ATOMIC_INIT(0);
49751 + long signr = siginfo->si_signo;
49752 struct coredump_params cprm = {
49753 .siginfo = siginfo,
49754 .regs = signal_pt_regs(),
49755 @@ -484,7 +485,10 @@ void do_coredump(siginfo_t *siginfo)
49756 .mm_flags = mm->flags,
49757 };
49758
49759 - audit_core_dumps(siginfo->si_signo);
49760 + audit_core_dumps(signr);
49761 +
49762 + if (signr == SIGSEGV || signr == SIGBUS || signr == SIGKILL || signr == SIGILL)
49763 + gr_handle_brute_attach(cprm.mm_flags);
49764
49765 binfmt = mm->binfmt;
49766 if (!binfmt || !binfmt->core_dump)
49767 @@ -508,7 +512,7 @@ void do_coredump(siginfo_t *siginfo)
49768 need_nonrelative = true;
49769 }
49770
49771 - retval = coredump_wait(siginfo->si_signo, &core_state);
49772 + retval = coredump_wait(signr, &core_state);
49773 if (retval < 0)
49774 goto fail_creds;
49775
49776 @@ -556,7 +560,7 @@ void do_coredump(siginfo_t *siginfo)
49777 }
49778 cprm.limit = RLIM_INFINITY;
49779
49780 - dump_count = atomic_inc_return(&core_dump_count);
49781 + dump_count = atomic_inc_return_unchecked(&core_dump_count);
49782 if (core_pipe_limit && (core_pipe_limit < dump_count)) {
49783 printk(KERN_WARNING "Pid %d(%s) over core_pipe_limit\n",
49784 task_tgid_vnr(current), current->comm);
49785 @@ -583,6 +587,8 @@ void do_coredump(siginfo_t *siginfo)
49786 } else {
49787 struct inode *inode;
49788
49789 + gr_learn_resource(current, RLIMIT_CORE, binfmt->min_coredump, 1);
49790 +
49791 if (cprm.limit < binfmt->min_coredump)
49792 goto fail_unlock;
49793
49794 @@ -640,7 +646,7 @@ close_fail:
49795 filp_close(cprm.file, NULL);
49796 fail_dropcount:
49797 if (ispipe)
49798 - atomic_dec(&core_dump_count);
49799 + atomic_dec_unchecked(&core_dump_count);
49800 fail_unlock:
49801 kfree(cn.corename);
49802 fail_corename:
49803 @@ -659,7 +665,7 @@ fail:
49804 */
49805 int dump_write(struct file *file, const void *addr, int nr)
49806 {
49807 - return access_ok(VERIFY_READ, addr, nr) && file->f_op->write(file, addr, nr, &file->f_pos) == nr;
49808 + return access_ok(VERIFY_READ, addr, nr) && file->f_op->write(file, (const char __force_user *)addr, nr, &file->f_pos) == nr;
49809 }
49810 EXPORT_SYMBOL(dump_write);
49811
49812 diff --git a/fs/dcache.c b/fs/dcache.c
49813 index 19153a0..428c2f5 100644
49814 --- a/fs/dcache.c
49815 +++ b/fs/dcache.c
49816 @@ -3133,7 +3133,7 @@ void __init vfs_caches_init(unsigned long mempages)
49817 mempages -= reserve;
49818
49819 names_cachep = kmem_cache_create("names_cache", PATH_MAX, 0,
49820 - SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
49821 + SLAB_HWCACHE_ALIGN|SLAB_PANIC|SLAB_USERCOPY, NULL);
49822
49823 dcache_init();
49824 inode_init();
49825 diff --git a/fs/debugfs/inode.c b/fs/debugfs/inode.c
49826 index a5f12b7..4ee8a6f 100644
49827 --- a/fs/debugfs/inode.c
49828 +++ b/fs/debugfs/inode.c
49829 @@ -415,7 +415,11 @@ EXPORT_SYMBOL_GPL(debugfs_create_file);
49830 */
49831 struct dentry *debugfs_create_dir(const char *name, struct dentry *parent)
49832 {
49833 +#ifdef CONFIG_GRKERNSEC_SYSFS_RESTRICT
49834 + return __create_file(name, S_IFDIR | S_IRWXU,
49835 +#else
49836 return __create_file(name, S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO,
49837 +#endif
49838 parent, NULL, NULL);
49839 }
49840 EXPORT_SYMBOL_GPL(debugfs_create_dir);
49841 diff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c
49842 index cc7709e..7e7211f 100644
49843 --- a/fs/ecryptfs/inode.c
49844 +++ b/fs/ecryptfs/inode.c
49845 @@ -674,7 +674,7 @@ static int ecryptfs_readlink_lower(struct dentry *dentry, char **buf,
49846 old_fs = get_fs();
49847 set_fs(get_ds());
49848 rc = lower_dentry->d_inode->i_op->readlink(lower_dentry,
49849 - (char __user *)lower_buf,
49850 + (char __force_user *)lower_buf,
49851 PATH_MAX);
49852 set_fs(old_fs);
49853 if (rc < 0)
49854 @@ -706,7 +706,7 @@ out:
49855 static void
49856 ecryptfs_put_link(struct dentry *dentry, struct nameidata *nd, void *ptr)
49857 {
49858 - char *buf = nd_get_link(nd);
49859 + const char *buf = nd_get_link(nd);
49860 if (!IS_ERR(buf)) {
49861 /* Free the char* */
49862 kfree(buf);
49863 diff --git a/fs/ecryptfs/miscdev.c b/fs/ecryptfs/miscdev.c
49864 index 412e6ed..4292d22 100644
49865 --- a/fs/ecryptfs/miscdev.c
49866 +++ b/fs/ecryptfs/miscdev.c
49867 @@ -315,7 +315,7 @@ check_list:
49868 goto out_unlock_msg_ctx;
49869 i = PKT_TYPE_SIZE + PKT_CTR_SIZE;
49870 if (msg_ctx->msg) {
49871 - if (copy_to_user(&buf[i], packet_length, packet_length_size))
49872 + if (packet_length_size > sizeof(packet_length) || copy_to_user(&buf[i], packet_length, packet_length_size))
49873 goto out_unlock_msg_ctx;
49874 i += packet_length_size;
49875 if (copy_to_user(&buf[i], msg_ctx->msg, msg_ctx->msg_size))
49876 diff --git a/fs/ecryptfs/read_write.c b/fs/ecryptfs/read_write.c
49877 index b2a34a1..162fa69 100644
49878 --- a/fs/ecryptfs/read_write.c
49879 +++ b/fs/ecryptfs/read_write.c
49880 @@ -48,7 +48,7 @@ int ecryptfs_write_lower(struct inode *ecryptfs_inode, char *data,
49881 return -EIO;
49882 fs_save = get_fs();
49883 set_fs(get_ds());
49884 - rc = vfs_write(lower_file, data, size, &offset);
49885 + rc = vfs_write(lower_file, (const char __force_user *)data, size, &offset);
49886 set_fs(fs_save);
49887 mark_inode_dirty_sync(ecryptfs_inode);
49888 return rc;
49889 @@ -244,7 +244,7 @@ int ecryptfs_read_lower(char *data, loff_t offset, size_t size,
49890 return -EIO;
49891 fs_save = get_fs();
49892 set_fs(get_ds());
49893 - rc = vfs_read(lower_file, data, size, &offset);
49894 + rc = vfs_read(lower_file, (char __force_user *)data, size, &offset);
49895 set_fs(fs_save);
49896 return rc;
49897 }
49898 diff --git a/fs/exec.c b/fs/exec.c
49899 index 20df02c..860e87f 100644
49900 --- a/fs/exec.c
49901 +++ b/fs/exec.c
49902 @@ -55,6 +55,17 @@
49903 #include <linux/pipe_fs_i.h>
49904 #include <linux/oom.h>
49905 #include <linux/compat.h>
49906 +#include <linux/random.h>
49907 +#include <linux/seq_file.h>
49908 +#include <linux/coredump.h>
49909 +#include <linux/mman.h>
49910 +
49911 +#ifdef CONFIG_PAX_REFCOUNT
49912 +#include <linux/kallsyms.h>
49913 +#include <linux/kdebug.h>
49914 +#endif
49915 +
49916 +#include <trace/events/fs.h>
49917
49918 #include <asm/uaccess.h>
49919 #include <asm/mmu_context.h>
49920 @@ -66,6 +77,18 @@
49921
49922 #include <trace/events/sched.h>
49923
49924 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
49925 +void __weak pax_set_initial_flags(struct linux_binprm *bprm)
49926 +{
49927 + 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");
49928 +}
49929 +#endif
49930 +
49931 +#ifdef CONFIG_PAX_HOOK_ACL_FLAGS
49932 +void (*pax_set_initial_flags_func)(struct linux_binprm *bprm);
49933 +EXPORT_SYMBOL(pax_set_initial_flags_func);
49934 +#endif
49935 +
49936 int suid_dumpable = 0;
49937
49938 static LIST_HEAD(formats);
49939 @@ -75,8 +98,8 @@ void __register_binfmt(struct linux_binfmt * fmt, int insert)
49940 {
49941 BUG_ON(!fmt);
49942 write_lock(&binfmt_lock);
49943 - insert ? list_add(&fmt->lh, &formats) :
49944 - list_add_tail(&fmt->lh, &formats);
49945 + insert ? pax_list_add((struct list_head *)&fmt->lh, &formats) :
49946 + pax_list_add_tail((struct list_head *)&fmt->lh, &formats);
49947 write_unlock(&binfmt_lock);
49948 }
49949
49950 @@ -85,7 +108,7 @@ EXPORT_SYMBOL(__register_binfmt);
49951 void unregister_binfmt(struct linux_binfmt * fmt)
49952 {
49953 write_lock(&binfmt_lock);
49954 - list_del(&fmt->lh);
49955 + pax_list_del((struct list_head *)&fmt->lh);
49956 write_unlock(&binfmt_lock);
49957 }
49958
49959 @@ -180,18 +203,10 @@ static struct page *get_arg_page(struct linux_binprm *bprm, unsigned long pos,
49960 int write)
49961 {
49962 struct page *page;
49963 - int ret;
49964
49965 -#ifdef CONFIG_STACK_GROWSUP
49966 - if (write) {
49967 - ret = expand_downwards(bprm->vma, pos);
49968 - if (ret < 0)
49969 - return NULL;
49970 - }
49971 -#endif
49972 - ret = get_user_pages(current, bprm->mm, pos,
49973 - 1, write, 1, &page, NULL);
49974 - if (ret <= 0)
49975 + if (0 > expand_downwards(bprm->vma, pos))
49976 + return NULL;
49977 + if (0 >= get_user_pages(current, bprm->mm, pos, 1, write, 1, &page, NULL))
49978 return NULL;
49979
49980 if (write) {
49981 @@ -207,6 +222,17 @@ static struct page *get_arg_page(struct linux_binprm *bprm, unsigned long pos,
49982 if (size <= ARG_MAX)
49983 return page;
49984
49985 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
49986 + // only allow 512KB for argv+env on suid/sgid binaries
49987 + // to prevent easy ASLR exhaustion
49988 + if (((!uid_eq(bprm->cred->euid, current_euid())) ||
49989 + (!gid_eq(bprm->cred->egid, current_egid()))) &&
49990 + (size > (512 * 1024))) {
49991 + put_page(page);
49992 + return NULL;
49993 + }
49994 +#endif
49995 +
49996 /*
49997 * Limit to 1/4-th the stack size for the argv+env strings.
49998 * This ensures that:
49999 @@ -266,6 +292,11 @@ static int __bprm_mm_init(struct linux_binprm *bprm)
50000 vma->vm_end = STACK_TOP_MAX;
50001 vma->vm_start = vma->vm_end - PAGE_SIZE;
50002 vma->vm_flags = VM_STACK_FLAGS | VM_STACK_INCOMPLETE_SETUP;
50003 +
50004 +#ifdef CONFIG_PAX_SEGMEXEC
50005 + vma->vm_flags &= ~(VM_EXEC | VM_MAYEXEC);
50006 +#endif
50007 +
50008 vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
50009 INIT_LIST_HEAD(&vma->anon_vma_chain);
50010
50011 @@ -276,6 +307,12 @@ static int __bprm_mm_init(struct linux_binprm *bprm)
50012 mm->stack_vm = mm->total_vm = 1;
50013 up_write(&mm->mmap_sem);
50014 bprm->p = vma->vm_end - sizeof(void *);
50015 +
50016 +#ifdef CONFIG_PAX_RANDUSTACK
50017 + if (randomize_va_space)
50018 + bprm->p ^= random32() & ~PAGE_MASK;
50019 +#endif
50020 +
50021 return 0;
50022 err:
50023 up_write(&mm->mmap_sem);
50024 @@ -396,7 +433,7 @@ struct user_arg_ptr {
50025 } ptr;
50026 };
50027
50028 -static const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr)
50029 +const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr)
50030 {
50031 const char __user *native;
50032
50033 @@ -405,14 +442,14 @@ static const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr)
50034 compat_uptr_t compat;
50035
50036 if (get_user(compat, argv.ptr.compat + nr))
50037 - return ERR_PTR(-EFAULT);
50038 + return (const char __force_user *)ERR_PTR(-EFAULT);
50039
50040 return compat_ptr(compat);
50041 }
50042 #endif
50043
50044 if (get_user(native, argv.ptr.native + nr))
50045 - return ERR_PTR(-EFAULT);
50046 + return (const char __force_user *)ERR_PTR(-EFAULT);
50047
50048 return native;
50049 }
50050 @@ -431,7 +468,7 @@ static int count(struct user_arg_ptr argv, int max)
50051 if (!p)
50052 break;
50053
50054 - if (IS_ERR(p))
50055 + if (IS_ERR((const char __force_kernel *)p))
50056 return -EFAULT;
50057
50058 if (i >= max)
50059 @@ -466,7 +503,7 @@ static int copy_strings(int argc, struct user_arg_ptr argv,
50060
50061 ret = -EFAULT;
50062 str = get_user_arg_ptr(argv, argc);
50063 - if (IS_ERR(str))
50064 + if (IS_ERR((const char __force_kernel *)str))
50065 goto out;
50066
50067 len = strnlen_user(str, MAX_ARG_STRLEN);
50068 @@ -548,7 +585,7 @@ int copy_strings_kernel(int argc, const char *const *__argv,
50069 int r;
50070 mm_segment_t oldfs = get_fs();
50071 struct user_arg_ptr argv = {
50072 - .ptr.native = (const char __user *const __user *)__argv,
50073 + .ptr.native = (const char __force_user *const __force_user *)__argv,
50074 };
50075
50076 set_fs(KERNEL_DS);
50077 @@ -583,7 +620,8 @@ static int shift_arg_pages(struct vm_area_struct *vma, unsigned long shift)
50078 unsigned long new_end = old_end - shift;
50079 struct mmu_gather tlb;
50080
50081 - BUG_ON(new_start > new_end);
50082 + if (new_start >= new_end || new_start < mmap_min_addr)
50083 + return -ENOMEM;
50084
50085 /*
50086 * ensure there are no vmas between where we want to go
50087 @@ -592,6 +630,10 @@ static int shift_arg_pages(struct vm_area_struct *vma, unsigned long shift)
50088 if (vma != find_vma(mm, new_start))
50089 return -EFAULT;
50090
50091 +#ifdef CONFIG_PAX_SEGMEXEC
50092 + BUG_ON(pax_find_mirror_vma(vma));
50093 +#endif
50094 +
50095 /*
50096 * cover the whole range: [new_start, old_end)
50097 */
50098 @@ -672,10 +714,6 @@ int setup_arg_pages(struct linux_binprm *bprm,
50099 stack_top = arch_align_stack(stack_top);
50100 stack_top = PAGE_ALIGN(stack_top);
50101
50102 - if (unlikely(stack_top < mmap_min_addr) ||
50103 - unlikely(vma->vm_end - vma->vm_start >= stack_top - mmap_min_addr))
50104 - return -ENOMEM;
50105 -
50106 stack_shift = vma->vm_end - stack_top;
50107
50108 bprm->p -= stack_shift;
50109 @@ -687,8 +725,28 @@ int setup_arg_pages(struct linux_binprm *bprm,
50110 bprm->exec -= stack_shift;
50111
50112 down_write(&mm->mmap_sem);
50113 +
50114 + /* Move stack pages down in memory. */
50115 + if (stack_shift) {
50116 + ret = shift_arg_pages(vma, stack_shift);
50117 + if (ret)
50118 + goto out_unlock;
50119 + }
50120 +
50121 vm_flags = VM_STACK_FLAGS;
50122
50123 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
50124 + if (mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
50125 + vm_flags &= ~VM_EXEC;
50126 +
50127 +#ifdef CONFIG_PAX_MPROTECT
50128 + if (mm->pax_flags & MF_PAX_MPROTECT)
50129 + vm_flags &= ~VM_MAYEXEC;
50130 +#endif
50131 +
50132 + }
50133 +#endif
50134 +
50135 /*
50136 * Adjust stack execute permissions; explicitly enable for
50137 * EXSTACK_ENABLE_X, disable for EXSTACK_DISABLE_X and leave alone
50138 @@ -707,13 +765,6 @@ int setup_arg_pages(struct linux_binprm *bprm,
50139 goto out_unlock;
50140 BUG_ON(prev != vma);
50141
50142 - /* Move stack pages down in memory. */
50143 - if (stack_shift) {
50144 - ret = shift_arg_pages(vma, stack_shift);
50145 - if (ret)
50146 - goto out_unlock;
50147 - }
50148 -
50149 /* mprotect_fixup is overkill to remove the temporary stack flags */
50150 vma->vm_flags &= ~VM_STACK_INCOMPLETE_SETUP;
50151
50152 @@ -737,6 +788,30 @@ int setup_arg_pages(struct linux_binprm *bprm,
50153 #endif
50154 current->mm->start_stack = bprm->p;
50155 ret = expand_stack(vma, stack_base);
50156 +
50157 +#if !defined(CONFIG_STACK_GROWSUP) && defined(CONFIG_PAX_ASLR)
50158 + if (!ret && (mm->pax_flags & MF_PAX_RANDMMAP) && STACK_TOP <= 0xFFFFFFFFU && STACK_TOP > vma->vm_end) {
50159 + unsigned long size, flags, vm_flags;
50160 +
50161 + size = STACK_TOP - vma->vm_end;
50162 + flags = MAP_FIXED | MAP_PRIVATE;
50163 + vm_flags = VM_NONE | VM_DONTEXPAND | VM_DONTDUMP;
50164 +
50165 + ret = vma->vm_end != mmap_region(NULL, vma->vm_end, size, flags, vm_flags, 0);
50166 +
50167 +#ifdef CONFIG_X86
50168 + if (!ret) {
50169 + current->mm->aslr_gap += size >> PAGE_SHIFT;
50170 + size = mmap_min_addr + ((mm->delta_mmap ^ mm->delta_stack) & (0xFFUL << PAGE_SHIFT));
50171 + ret = 0 != mmap_region(NULL, 0, size, flags, vm_flags, 0);
50172 + if (!ret)
50173 + current->mm->aslr_gap += size >> PAGE_SHIFT;
50174 + }
50175 +#endif
50176 +
50177 + }
50178 +#endif
50179 +
50180 if (ret)
50181 ret = -EFAULT;
50182
50183 @@ -772,6 +847,8 @@ struct file *open_exec(const char *name)
50184
50185 fsnotify_open(file);
50186
50187 + trace_open_exec(name);
50188 +
50189 err = deny_write_access(file);
50190 if (err)
50191 goto exit;
50192 @@ -795,7 +872,7 @@ int kernel_read(struct file *file, loff_t offset,
50193 old_fs = get_fs();
50194 set_fs(get_ds());
50195 /* The cast to a user pointer is valid due to the set_fs() */
50196 - result = vfs_read(file, (void __user *)addr, count, &pos);
50197 + result = vfs_read(file, (void __force_user *)addr, count, &pos);
50198 set_fs(old_fs);
50199 return result;
50200 }
50201 @@ -1247,7 +1324,7 @@ static int check_unsafe_exec(struct linux_binprm *bprm)
50202 }
50203 rcu_read_unlock();
50204
50205 - if (p->fs->users > n_fs) {
50206 + if (atomic_read(&p->fs->users) > n_fs) {
50207 bprm->unsafe |= LSM_UNSAFE_SHARE;
50208 } else {
50209 res = -EAGAIN;
50210 @@ -1447,6 +1524,31 @@ int search_binary_handler(struct linux_binprm *bprm)
50211
50212 EXPORT_SYMBOL(search_binary_handler);
50213
50214 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
50215 +static DEFINE_PER_CPU(u64, exec_counter);
50216 +static int __init init_exec_counters(void)
50217 +{
50218 + unsigned int cpu;
50219 +
50220 + for_each_possible_cpu(cpu) {
50221 + per_cpu(exec_counter, cpu) = (u64)cpu;
50222 + }
50223 +
50224 + return 0;
50225 +}
50226 +early_initcall(init_exec_counters);
50227 +static inline void increment_exec_counter(void)
50228 +{
50229 + BUILD_BUG_ON(NR_CPUS > (1 << 16));
50230 + current->exec_id = this_cpu_add_return(exec_counter, 1 << 16);
50231 +}
50232 +#else
50233 +static inline void increment_exec_counter(void) {}
50234 +#endif
50235 +
50236 +extern void gr_handle_exec_args(struct linux_binprm *bprm,
50237 + struct user_arg_ptr argv);
50238 +
50239 /*
50240 * sys_execve() executes a new program.
50241 */
50242 @@ -1454,6 +1556,11 @@ static int do_execve_common(const char *filename,
50243 struct user_arg_ptr argv,
50244 struct user_arg_ptr envp)
50245 {
50246 +#ifdef CONFIG_GRKERNSEC
50247 + struct file *old_exec_file;
50248 + struct acl_subject_label *old_acl;
50249 + struct rlimit old_rlim[RLIM_NLIMITS];
50250 +#endif
50251 struct linux_binprm *bprm;
50252 struct file *file;
50253 struct files_struct *displaced;
50254 @@ -1461,6 +1568,8 @@ static int do_execve_common(const char *filename,
50255 int retval;
50256 const struct cred *cred = current_cred();
50257
50258 + gr_learn_resource(current, RLIMIT_NPROC, atomic_read(&current->cred->user->processes), 1);
50259 +
50260 /*
50261 * We move the actual failure in case of RLIMIT_NPROC excess from
50262 * set*uid() to execve() because too many poorly written programs
50263 @@ -1501,12 +1610,27 @@ static int do_execve_common(const char *filename,
50264 if (IS_ERR(file))
50265 goto out_unmark;
50266
50267 + if (gr_ptrace_readexec(file, bprm->unsafe)) {
50268 + retval = -EPERM;
50269 + goto out_file;
50270 + }
50271 +
50272 sched_exec();
50273
50274 bprm->file = file;
50275 bprm->filename = filename;
50276 bprm->interp = filename;
50277
50278 + if (gr_process_user_ban()) {
50279 + retval = -EPERM;
50280 + goto out_file;
50281 + }
50282 +
50283 + if (!gr_acl_handle_execve(file->f_dentry, file->f_vfsmnt)) {
50284 + retval = -EACCES;
50285 + goto out_file;
50286 + }
50287 +
50288 retval = bprm_mm_init(bprm);
50289 if (retval)
50290 goto out_file;
50291 @@ -1523,24 +1647,65 @@ static int do_execve_common(const char *filename,
50292 if (retval < 0)
50293 goto out;
50294
50295 +#ifdef CONFIG_GRKERNSEC
50296 + old_acl = current->acl;
50297 + memcpy(old_rlim, current->signal->rlim, sizeof(old_rlim));
50298 + old_exec_file = current->exec_file;
50299 + get_file(file);
50300 + current->exec_file = file;
50301 +#endif
50302 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
50303 + /* limit suid stack to 8MB
50304 + * we saved the old limits above and will restore them if this exec fails
50305 + */
50306 + if (((!uid_eq(bprm->cred->euid, current_euid())) || (!gid_eq(bprm->cred->egid, current_egid()))) &&
50307 + (old_rlim[RLIMIT_STACK].rlim_cur > (8 * 1024 * 1024)))
50308 + current->signal->rlim[RLIMIT_STACK].rlim_cur = 8 * 1024 * 1024;
50309 +#endif
50310 +
50311 + if (!gr_tpe_allow(file)) {
50312 + retval = -EACCES;
50313 + goto out_fail;
50314 + }
50315 +
50316 + if (gr_check_crash_exec(file)) {
50317 + retval = -EACCES;
50318 + goto out_fail;
50319 + }
50320 +
50321 + retval = gr_set_proc_label(file->f_dentry, file->f_vfsmnt,
50322 + bprm->unsafe);
50323 + if (retval < 0)
50324 + goto out_fail;
50325 +
50326 retval = copy_strings_kernel(1, &bprm->filename, bprm);
50327 if (retval < 0)
50328 - goto out;
50329 + goto out_fail;
50330
50331 bprm->exec = bprm->p;
50332 retval = copy_strings(bprm->envc, envp, bprm);
50333 if (retval < 0)
50334 - goto out;
50335 + goto out_fail;
50336
50337 retval = copy_strings(bprm->argc, argv, bprm);
50338 if (retval < 0)
50339 - goto out;
50340 + goto out_fail;
50341 +
50342 + gr_log_chroot_exec(file->f_dentry, file->f_vfsmnt);
50343 +
50344 + gr_handle_exec_args(bprm, argv);
50345
50346 retval = search_binary_handler(bprm);
50347 if (retval < 0)
50348 - goto out;
50349 + goto out_fail;
50350 +#ifdef CONFIG_GRKERNSEC
50351 + if (old_exec_file)
50352 + fput(old_exec_file);
50353 +#endif
50354
50355 /* execve succeeded */
50356 +
50357 + increment_exec_counter();
50358 current->fs->in_exec = 0;
50359 current->in_execve = 0;
50360 acct_update_integrals(current);
50361 @@ -1549,6 +1714,14 @@ static int do_execve_common(const char *filename,
50362 put_files_struct(displaced);
50363 return retval;
50364
50365 +out_fail:
50366 +#ifdef CONFIG_GRKERNSEC
50367 + current->acl = old_acl;
50368 + memcpy(current->signal->rlim, old_rlim, sizeof(old_rlim));
50369 + fput(current->exec_file);
50370 + current->exec_file = old_exec_file;
50371 +#endif
50372 +
50373 out:
50374 if (bprm->mm) {
50375 acct_arg_size(bprm, 0);
50376 @@ -1697,3 +1870,253 @@ asmlinkage long compat_sys_execve(const char __user * filename,
50377 return error;
50378 }
50379 #endif
50380 +
50381 +int pax_check_flags(unsigned long *flags)
50382 +{
50383 + int retval = 0;
50384 +
50385 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_SEGMEXEC)
50386 + if (*flags & MF_PAX_SEGMEXEC)
50387 + {
50388 + *flags &= ~MF_PAX_SEGMEXEC;
50389 + retval = -EINVAL;
50390 + }
50391 +#endif
50392 +
50393 + if ((*flags & MF_PAX_PAGEEXEC)
50394 +
50395 +#ifdef CONFIG_PAX_PAGEEXEC
50396 + && (*flags & MF_PAX_SEGMEXEC)
50397 +#endif
50398 +
50399 + )
50400 + {
50401 + *flags &= ~MF_PAX_PAGEEXEC;
50402 + retval = -EINVAL;
50403 + }
50404 +
50405 + if ((*flags & MF_PAX_MPROTECT)
50406 +
50407 +#ifdef CONFIG_PAX_MPROTECT
50408 + && !(*flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC))
50409 +#endif
50410 +
50411 + )
50412 + {
50413 + *flags &= ~MF_PAX_MPROTECT;
50414 + retval = -EINVAL;
50415 + }
50416 +
50417 + if ((*flags & MF_PAX_EMUTRAMP)
50418 +
50419 +#ifdef CONFIG_PAX_EMUTRAMP
50420 + && !(*flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC))
50421 +#endif
50422 +
50423 + )
50424 + {
50425 + *flags &= ~MF_PAX_EMUTRAMP;
50426 + retval = -EINVAL;
50427 + }
50428 +
50429 + return retval;
50430 +}
50431 +
50432 +EXPORT_SYMBOL(pax_check_flags);
50433 +
50434 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
50435 +void pax_report_fault(struct pt_regs *regs, void *pc, void *sp)
50436 +{
50437 + struct task_struct *tsk = current;
50438 + struct mm_struct *mm = current->mm;
50439 + char *buffer_exec = (char *)__get_free_page(GFP_KERNEL);
50440 + char *buffer_fault = (char *)__get_free_page(GFP_KERNEL);
50441 + char *path_exec = NULL;
50442 + char *path_fault = NULL;
50443 + unsigned long start = 0UL, end = 0UL, offset = 0UL;
50444 + siginfo_t info = { };
50445 +
50446 + if (buffer_exec && buffer_fault) {
50447 + struct vm_area_struct *vma, *vma_exec = NULL, *vma_fault = NULL;
50448 +
50449 + down_read(&mm->mmap_sem);
50450 + vma = mm->mmap;
50451 + while (vma && (!vma_exec || !vma_fault)) {
50452 + if (vma->vm_file && mm->exe_file == vma->vm_file && (vma->vm_flags & VM_EXEC))
50453 + vma_exec = vma;
50454 + if (vma->vm_start <= (unsigned long)pc && (unsigned long)pc < vma->vm_end)
50455 + vma_fault = vma;
50456 + vma = vma->vm_next;
50457 + }
50458 + if (vma_exec) {
50459 + path_exec = d_path(&vma_exec->vm_file->f_path, buffer_exec, PAGE_SIZE);
50460 + if (IS_ERR(path_exec))
50461 + path_exec = "<path too long>";
50462 + else {
50463 + path_exec = mangle_path(buffer_exec, path_exec, "\t\n\\");
50464 + if (path_exec) {
50465 + *path_exec = 0;
50466 + path_exec = buffer_exec;
50467 + } else
50468 + path_exec = "<path too long>";
50469 + }
50470 + }
50471 + if (vma_fault) {
50472 + start = vma_fault->vm_start;
50473 + end = vma_fault->vm_end;
50474 + offset = vma_fault->vm_pgoff << PAGE_SHIFT;
50475 + if (vma_fault->vm_file) {
50476 + path_fault = d_path(&vma_fault->vm_file->f_path, buffer_fault, PAGE_SIZE);
50477 + if (IS_ERR(path_fault))
50478 + path_fault = "<path too long>";
50479 + else {
50480 + path_fault = mangle_path(buffer_fault, path_fault, "\t\n\\");
50481 + if (path_fault) {
50482 + *path_fault = 0;
50483 + path_fault = buffer_fault;
50484 + } else
50485 + path_fault = "<path too long>";
50486 + }
50487 + } else
50488 + path_fault = "<anonymous mapping>";
50489 + }
50490 + up_read(&mm->mmap_sem);
50491 + }
50492 + if (tsk->signal->curr_ip)
50493 + printk(KERN_ERR "PAX: From %pI4: execution attempt in: %s, %08lx-%08lx %08lx\n", &tsk->signal->curr_ip, path_fault, start, end, offset);
50494 + else
50495 + printk(KERN_ERR "PAX: execution attempt in: %s, %08lx-%08lx %08lx\n", path_fault, start, end, offset);
50496 + 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),
50497 + from_kuid_munged(&init_user_ns, task_uid(tsk)), from_kuid_munged(&init_user_ns, task_euid(tsk)), pc, sp);
50498 + free_page((unsigned long)buffer_exec);
50499 + free_page((unsigned long)buffer_fault);
50500 + pax_report_insns(regs, pc, sp);
50501 + info.si_signo = SIGKILL;
50502 + info.si_errno = 0;
50503 + info.si_code = SI_KERNEL;
50504 + info.si_pid = 0;
50505 + info.si_uid = 0;
50506 + do_coredump(&info);
50507 +}
50508 +#endif
50509 +
50510 +#ifdef CONFIG_PAX_REFCOUNT
50511 +void pax_report_refcount_overflow(struct pt_regs *regs)
50512 +{
50513 + if (current->signal->curr_ip)
50514 + printk(KERN_ERR "PAX: From %pI4: refcount overflow detected in: %s:%d, uid/euid: %u/%u\n",
50515 + &current->signal->curr_ip, current->comm, task_pid_nr(current),
50516 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
50517 + else
50518 + printk(KERN_ERR "PAX: refcount overflow detected in: %s:%d, uid/euid: %u/%u\n", current->comm, task_pid_nr(current),
50519 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
50520 + print_symbol(KERN_ERR "PAX: refcount overflow occured at: %s\n", instruction_pointer(regs));
50521 + show_regs(regs);
50522 + force_sig_info(SIGKILL, SEND_SIG_FORCED, current);
50523 +}
50524 +#endif
50525 +
50526 +#ifdef CONFIG_PAX_USERCOPY
50527 +/* 0: not at all, 1: fully, 2: fully inside frame, -1: partially (implies an error) */
50528 +static noinline int check_stack_object(const void *obj, unsigned long len)
50529 +{
50530 + const void * const stack = task_stack_page(current);
50531 + const void * const stackend = stack + THREAD_SIZE;
50532 +
50533 +#if defined(CONFIG_FRAME_POINTER) && defined(CONFIG_X86)
50534 + const void *frame = NULL;
50535 + const void *oldframe;
50536 +#endif
50537 +
50538 + if (obj + len < obj)
50539 + return -1;
50540 +
50541 + if (obj + len <= stack || stackend <= obj)
50542 + return 0;
50543 +
50544 + if (obj < stack || stackend < obj + len)
50545 + return -1;
50546 +
50547 +#if defined(CONFIG_FRAME_POINTER) && defined(CONFIG_X86)
50548 + oldframe = __builtin_frame_address(1);
50549 + if (oldframe)
50550 + frame = __builtin_frame_address(2);
50551 + /*
50552 + low ----------------------------------------------> high
50553 + [saved bp][saved ip][args][local vars][saved bp][saved ip]
50554 + ^----------------^
50555 + allow copies only within here
50556 + */
50557 + while (stack <= frame && frame < stackend) {
50558 + /* if obj + len extends past the last frame, this
50559 + check won't pass and the next frame will be 0,
50560 + causing us to bail out and correctly report
50561 + the copy as invalid
50562 + */
50563 + if (obj + len <= frame)
50564 + return obj >= oldframe + 2 * sizeof(void *) ? 2 : -1;
50565 + oldframe = frame;
50566 + frame = *(const void * const *)frame;
50567 + }
50568 + return -1;
50569 +#else
50570 + return 1;
50571 +#endif
50572 +}
50573 +
50574 +static __noreturn void pax_report_usercopy(const void *ptr, unsigned long len, bool to, const char *type)
50575 +{
50576 + if (current->signal->curr_ip)
50577 + printk(KERN_ERR "PAX: From %pI4: kernel memory %s attempt detected %s %p (%s) (%lu bytes)\n",
50578 + &current->signal->curr_ip, to ? "leak" : "overwrite", to ? "from" : "to", ptr, type ? : "unknown", len);
50579 + else
50580 + printk(KERN_ERR "PAX: kernel memory %s attempt detected %s %p (%s) (%lu bytes)\n",
50581 + to ? "leak" : "overwrite", to ? "from" : "to", ptr, type ? : "unknown", len);
50582 + dump_stack();
50583 + gr_handle_kernel_exploit();
50584 + do_group_exit(SIGKILL);
50585 +}
50586 +#endif
50587 +
50588 +void __check_object_size(const void *ptr, unsigned long n, bool to)
50589 +{
50590 +
50591 +#ifdef CONFIG_PAX_USERCOPY
50592 + const char *type;
50593 +
50594 + if (!n)
50595 + return;
50596 +
50597 + type = check_heap_object(ptr, n);
50598 + if (!type) {
50599 + if (check_stack_object(ptr, n) != -1)
50600 + return;
50601 + type = "<process stack>";
50602 + }
50603 +
50604 + pax_report_usercopy(ptr, n, to, type);
50605 +#endif
50606 +
50607 +}
50608 +EXPORT_SYMBOL(__check_object_size);
50609 +
50610 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
50611 +void pax_track_stack(void)
50612 +{
50613 + unsigned long sp = (unsigned long)&sp;
50614 + if (sp < current_thread_info()->lowest_stack &&
50615 + sp > (unsigned long)task_stack_page(current))
50616 + current_thread_info()->lowest_stack = sp;
50617 +}
50618 +EXPORT_SYMBOL(pax_track_stack);
50619 +#endif
50620 +
50621 +#ifdef CONFIG_PAX_SIZE_OVERFLOW
50622 +void report_size_overflow(const char *file, unsigned int line, const char *func, const char *ssa_name)
50623 +{
50624 + printk(KERN_ERR "PAX: size overflow detected in function %s %s:%u %s", func, file, line, ssa_name);
50625 + dump_stack();
50626 + do_group_exit(SIGKILL);
50627 +}
50628 +EXPORT_SYMBOL(report_size_overflow);
50629 +#endif
50630 diff --git a/fs/ext2/balloc.c b/fs/ext2/balloc.c
50631 index 2616d0e..2ffdec9 100644
50632 --- a/fs/ext2/balloc.c
50633 +++ b/fs/ext2/balloc.c
50634 @@ -1190,10 +1190,10 @@ static int ext2_has_free_blocks(struct ext2_sb_info *sbi)
50635
50636 free_blocks = percpu_counter_read_positive(&sbi->s_freeblocks_counter);
50637 root_blocks = le32_to_cpu(sbi->s_es->s_r_blocks_count);
50638 - if (free_blocks < root_blocks + 1 && !capable(CAP_SYS_RESOURCE) &&
50639 + if (free_blocks < root_blocks + 1 &&
50640 !uid_eq(sbi->s_resuid, current_fsuid()) &&
50641 (gid_eq(sbi->s_resgid, GLOBAL_ROOT_GID) ||
50642 - !in_group_p (sbi->s_resgid))) {
50643 + !in_group_p (sbi->s_resgid)) && !capable_nolog(CAP_SYS_RESOURCE)) {
50644 return 0;
50645 }
50646 return 1;
50647 diff --git a/fs/ext3/balloc.c b/fs/ext3/balloc.c
50648 index 22548f5..41521d8 100644
50649 --- a/fs/ext3/balloc.c
50650 +++ b/fs/ext3/balloc.c
50651 @@ -1438,10 +1438,10 @@ static int ext3_has_free_blocks(struct ext3_sb_info *sbi, int use_reservation)
50652
50653 free_blocks = percpu_counter_read_positive(&sbi->s_freeblocks_counter);
50654 root_blocks = le32_to_cpu(sbi->s_es->s_r_blocks_count);
50655 - if (free_blocks < root_blocks + 1 && !capable(CAP_SYS_RESOURCE) &&
50656 + if (free_blocks < root_blocks + 1 &&
50657 !use_reservation && !uid_eq(sbi->s_resuid, current_fsuid()) &&
50658 (gid_eq(sbi->s_resgid, GLOBAL_ROOT_GID) ||
50659 - !in_group_p (sbi->s_resgid))) {
50660 + !in_group_p (sbi->s_resgid)) && !capable_nolog(CAP_SYS_RESOURCE)) {
50661 return 0;
50662 }
50663 return 1;
50664 diff --git a/fs/ext4/balloc.c b/fs/ext4/balloc.c
50665 index 92e68b3..115d987 100644
50666 --- a/fs/ext4/balloc.c
50667 +++ b/fs/ext4/balloc.c
50668 @@ -505,8 +505,8 @@ static int ext4_has_free_clusters(struct ext4_sb_info *sbi,
50669 /* Hm, nope. Are (enough) root reserved clusters available? */
50670 if (uid_eq(sbi->s_resuid, current_fsuid()) ||
50671 (!gid_eq(sbi->s_resgid, GLOBAL_ROOT_GID) && in_group_p(sbi->s_resgid)) ||
50672 - capable(CAP_SYS_RESOURCE) ||
50673 - (flags & EXT4_MB_USE_ROOT_BLOCKS)) {
50674 + (flags & EXT4_MB_USE_ROOT_BLOCKS) ||
50675 + capable_nolog(CAP_SYS_RESOURCE)) {
50676
50677 if (free_clusters >= (nclusters + dirty_clusters))
50678 return 1;
50679 diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
50680 index 8462eb3..4a71af6 100644
50681 --- a/fs/ext4/ext4.h
50682 +++ b/fs/ext4/ext4.h
50683 @@ -1265,19 +1265,19 @@ struct ext4_sb_info {
50684 unsigned long s_mb_last_start;
50685
50686 /* stats for buddy allocator */
50687 - atomic_t s_bal_reqs; /* number of reqs with len > 1 */
50688 - atomic_t s_bal_success; /* we found long enough chunks */
50689 - atomic_t s_bal_allocated; /* in blocks */
50690 - atomic_t s_bal_ex_scanned; /* total extents scanned */
50691 - atomic_t s_bal_goals; /* goal hits */
50692 - atomic_t s_bal_breaks; /* too long searches */
50693 - atomic_t s_bal_2orders; /* 2^order hits */
50694 + atomic_unchecked_t s_bal_reqs; /* number of reqs with len > 1 */
50695 + atomic_unchecked_t s_bal_success; /* we found long enough chunks */
50696 + atomic_unchecked_t s_bal_allocated; /* in blocks */
50697 + atomic_unchecked_t s_bal_ex_scanned; /* total extents scanned */
50698 + atomic_unchecked_t s_bal_goals; /* goal hits */
50699 + atomic_unchecked_t s_bal_breaks; /* too long searches */
50700 + atomic_unchecked_t s_bal_2orders; /* 2^order hits */
50701 spinlock_t s_bal_lock;
50702 unsigned long s_mb_buddies_generated;
50703 unsigned long long s_mb_generation_time;
50704 - atomic_t s_mb_lost_chunks;
50705 - atomic_t s_mb_preallocated;
50706 - atomic_t s_mb_discarded;
50707 + atomic_unchecked_t s_mb_lost_chunks;
50708 + atomic_unchecked_t s_mb_preallocated;
50709 + atomic_unchecked_t s_mb_discarded;
50710 atomic_t s_lock_busy;
50711
50712 /* locality groups */
50713 diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
50714 index 28bbf9b..75ca7c1 100644
50715 --- a/fs/ext4/mballoc.c
50716 +++ b/fs/ext4/mballoc.c
50717 @@ -1747,7 +1747,7 @@ void ext4_mb_simple_scan_group(struct ext4_allocation_context *ac,
50718 BUG_ON(ac->ac_b_ex.fe_len != ac->ac_g_ex.fe_len);
50719
50720 if (EXT4_SB(sb)->s_mb_stats)
50721 - atomic_inc(&EXT4_SB(sb)->s_bal_2orders);
50722 + atomic_inc_unchecked(&EXT4_SB(sb)->s_bal_2orders);
50723
50724 break;
50725 }
50726 @@ -2044,7 +2044,7 @@ repeat:
50727 ac->ac_status = AC_STATUS_CONTINUE;
50728 ac->ac_flags |= EXT4_MB_HINT_FIRST;
50729 cr = 3;
50730 - atomic_inc(&sbi->s_mb_lost_chunks);
50731 + atomic_inc_unchecked(&sbi->s_mb_lost_chunks);
50732 goto repeat;
50733 }
50734 }
50735 @@ -2552,25 +2552,25 @@ int ext4_mb_release(struct super_block *sb)
50736 if (sbi->s_mb_stats) {
50737 ext4_msg(sb, KERN_INFO,
50738 "mballoc: %u blocks %u reqs (%u success)",
50739 - atomic_read(&sbi->s_bal_allocated),
50740 - atomic_read(&sbi->s_bal_reqs),
50741 - atomic_read(&sbi->s_bal_success));
50742 + atomic_read_unchecked(&sbi->s_bal_allocated),
50743 + atomic_read_unchecked(&sbi->s_bal_reqs),
50744 + atomic_read_unchecked(&sbi->s_bal_success));
50745 ext4_msg(sb, KERN_INFO,
50746 "mballoc: %u extents scanned, %u goal hits, "
50747 "%u 2^N hits, %u breaks, %u lost",
50748 - atomic_read(&sbi->s_bal_ex_scanned),
50749 - atomic_read(&sbi->s_bal_goals),
50750 - atomic_read(&sbi->s_bal_2orders),
50751 - atomic_read(&sbi->s_bal_breaks),
50752 - atomic_read(&sbi->s_mb_lost_chunks));
50753 + atomic_read_unchecked(&sbi->s_bal_ex_scanned),
50754 + atomic_read_unchecked(&sbi->s_bal_goals),
50755 + atomic_read_unchecked(&sbi->s_bal_2orders),
50756 + atomic_read_unchecked(&sbi->s_bal_breaks),
50757 + atomic_read_unchecked(&sbi->s_mb_lost_chunks));
50758 ext4_msg(sb, KERN_INFO,
50759 "mballoc: %lu generated and it took %Lu",
50760 sbi->s_mb_buddies_generated,
50761 sbi->s_mb_generation_time);
50762 ext4_msg(sb, KERN_INFO,
50763 "mballoc: %u preallocated, %u discarded",
50764 - atomic_read(&sbi->s_mb_preallocated),
50765 - atomic_read(&sbi->s_mb_discarded));
50766 + atomic_read_unchecked(&sbi->s_mb_preallocated),
50767 + atomic_read_unchecked(&sbi->s_mb_discarded));
50768 }
50769
50770 free_percpu(sbi->s_locality_groups);
50771 @@ -3060,16 +3060,16 @@ static void ext4_mb_collect_stats(struct ext4_allocation_context *ac)
50772 struct ext4_sb_info *sbi = EXT4_SB(ac->ac_sb);
50773
50774 if (sbi->s_mb_stats && ac->ac_g_ex.fe_len > 1) {
50775 - atomic_inc(&sbi->s_bal_reqs);
50776 - atomic_add(ac->ac_b_ex.fe_len, &sbi->s_bal_allocated);
50777 + atomic_inc_unchecked(&sbi->s_bal_reqs);
50778 + atomic_add_unchecked(ac->ac_b_ex.fe_len, &sbi->s_bal_allocated);
50779 if (ac->ac_b_ex.fe_len >= ac->ac_o_ex.fe_len)
50780 - atomic_inc(&sbi->s_bal_success);
50781 - atomic_add(ac->ac_found, &sbi->s_bal_ex_scanned);
50782 + atomic_inc_unchecked(&sbi->s_bal_success);
50783 + atomic_add_unchecked(ac->ac_found, &sbi->s_bal_ex_scanned);
50784 if (ac->ac_g_ex.fe_start == ac->ac_b_ex.fe_start &&
50785 ac->ac_g_ex.fe_group == ac->ac_b_ex.fe_group)
50786 - atomic_inc(&sbi->s_bal_goals);
50787 + atomic_inc_unchecked(&sbi->s_bal_goals);
50788 if (ac->ac_found > sbi->s_mb_max_to_scan)
50789 - atomic_inc(&sbi->s_bal_breaks);
50790 + atomic_inc_unchecked(&sbi->s_bal_breaks);
50791 }
50792
50793 if (ac->ac_op == EXT4_MB_HISTORY_ALLOC)
50794 @@ -3469,7 +3469,7 @@ ext4_mb_new_inode_pa(struct ext4_allocation_context *ac)
50795 trace_ext4_mb_new_inode_pa(ac, pa);
50796
50797 ext4_mb_use_inode_pa(ac, pa);
50798 - atomic_add(pa->pa_free, &sbi->s_mb_preallocated);
50799 + atomic_add_unchecked(pa->pa_free, &sbi->s_mb_preallocated);
50800
50801 ei = EXT4_I(ac->ac_inode);
50802 grp = ext4_get_group_info(sb, ac->ac_b_ex.fe_group);
50803 @@ -3529,7 +3529,7 @@ ext4_mb_new_group_pa(struct ext4_allocation_context *ac)
50804 trace_ext4_mb_new_group_pa(ac, pa);
50805
50806 ext4_mb_use_group_pa(ac, pa);
50807 - atomic_add(pa->pa_free, &EXT4_SB(sb)->s_mb_preallocated);
50808 + atomic_add_unchecked(pa->pa_free, &EXT4_SB(sb)->s_mb_preallocated);
50809
50810 grp = ext4_get_group_info(sb, ac->ac_b_ex.fe_group);
50811 lg = ac->ac_lg;
50812 @@ -3618,7 +3618,7 @@ ext4_mb_release_inode_pa(struct ext4_buddy *e4b, struct buffer_head *bitmap_bh,
50813 * from the bitmap and continue.
50814 */
50815 }
50816 - atomic_add(free, &sbi->s_mb_discarded);
50817 + atomic_add_unchecked(free, &sbi->s_mb_discarded);
50818
50819 return err;
50820 }
50821 @@ -3636,7 +3636,7 @@ ext4_mb_release_group_pa(struct ext4_buddy *e4b,
50822 ext4_get_group_no_and_offset(sb, pa->pa_pstart, &group, &bit);
50823 BUG_ON(group != e4b->bd_group && pa->pa_len != 0);
50824 mb_free_blocks(pa->pa_inode, e4b, bit, pa->pa_len);
50825 - atomic_add(pa->pa_len, &EXT4_SB(sb)->s_mb_discarded);
50826 + atomic_add_unchecked(pa->pa_len, &EXT4_SB(sb)->s_mb_discarded);
50827 trace_ext4_mballoc_discard(sb, NULL, group, bit, pa->pa_len);
50828
50829 return 0;
50830 diff --git a/fs/ext4/super.c b/fs/ext4/super.c
50831 index 5fa223d..12fa738 100644
50832 --- a/fs/ext4/super.c
50833 +++ b/fs/ext4/super.c
50834 @@ -2429,7 +2429,7 @@ struct ext4_attr {
50835 ssize_t (*store)(struct ext4_attr *, struct ext4_sb_info *,
50836 const char *, size_t);
50837 int offset;
50838 -};
50839 +} __do_const;
50840
50841 static int parse_strtoul(const char *buf,
50842 unsigned long max, unsigned long *value)
50843 diff --git a/fs/fcntl.c b/fs/fcntl.c
50844 index 71a600a..20d87b1 100644
50845 --- a/fs/fcntl.c
50846 +++ b/fs/fcntl.c
50847 @@ -107,6 +107,11 @@ int __f_setown(struct file *filp, struct pid *pid, enum pid_type type,
50848 if (err)
50849 return err;
50850
50851 + if (gr_handle_chroot_fowner(pid, type))
50852 + return -ENOENT;
50853 + if (gr_check_protected_task_fowner(pid, type))
50854 + return -EACCES;
50855 +
50856 f_modown(filp, pid, type, force);
50857 return 0;
50858 }
50859 diff --git a/fs/fhandle.c b/fs/fhandle.c
50860 index 999ff5c..41f4109 100644
50861 --- a/fs/fhandle.c
50862 +++ b/fs/fhandle.c
50863 @@ -67,8 +67,7 @@ static long do_sys_name_to_handle(struct path *path,
50864 } else
50865 retval = 0;
50866 /* copy the mount id */
50867 - if (copy_to_user(mnt_id, &real_mount(path->mnt)->mnt_id,
50868 - sizeof(*mnt_id)) ||
50869 + if (put_user(real_mount(path->mnt)->mnt_id, mnt_id) ||
50870 copy_to_user(ufh, handle,
50871 sizeof(struct file_handle) + handle_bytes))
50872 retval = -EFAULT;
50873 diff --git a/fs/fifo.c b/fs/fifo.c
50874 index cf6f434..3d7942c 100644
50875 --- a/fs/fifo.c
50876 +++ b/fs/fifo.c
50877 @@ -59,10 +59,10 @@ static int fifo_open(struct inode *inode, struct file *filp)
50878 */
50879 filp->f_op = &read_pipefifo_fops;
50880 pipe->r_counter++;
50881 - if (pipe->readers++ == 0)
50882 + if (atomic_inc_return(&pipe->readers) == 1)
50883 wake_up_partner(inode);
50884
50885 - if (!pipe->writers) {
50886 + if (!atomic_read(&pipe->writers)) {
50887 if ((filp->f_flags & O_NONBLOCK)) {
50888 /* suppress POLLHUP until we have
50889 * seen a writer */
50890 @@ -81,15 +81,15 @@ static int fifo_open(struct inode *inode, struct file *filp)
50891 * errno=ENXIO when there is no process reading the FIFO.
50892 */
50893 ret = -ENXIO;
50894 - if ((filp->f_flags & O_NONBLOCK) && !pipe->readers)
50895 + if ((filp->f_flags & O_NONBLOCK) && !atomic_read(&pipe->readers))
50896 goto err;
50897
50898 filp->f_op = &write_pipefifo_fops;
50899 pipe->w_counter++;
50900 - if (!pipe->writers++)
50901 + if (atomic_inc_return(&pipe->writers) == 1)
50902 wake_up_partner(inode);
50903
50904 - if (!pipe->readers) {
50905 + if (!atomic_read(&pipe->readers)) {
50906 if (wait_for_partner(inode, &pipe->r_counter))
50907 goto err_wr;
50908 }
50909 @@ -104,11 +104,11 @@ static int fifo_open(struct inode *inode, struct file *filp)
50910 */
50911 filp->f_op = &rdwr_pipefifo_fops;
50912
50913 - pipe->readers++;
50914 - pipe->writers++;
50915 + atomic_inc(&pipe->readers);
50916 + atomic_inc(&pipe->writers);
50917 pipe->r_counter++;
50918 pipe->w_counter++;
50919 - if (pipe->readers == 1 || pipe->writers == 1)
50920 + if (atomic_read(&pipe->readers) == 1 || atomic_read(&pipe->writers) == 1)
50921 wake_up_partner(inode);
50922 break;
50923
50924 @@ -122,19 +122,19 @@ static int fifo_open(struct inode *inode, struct file *filp)
50925 return 0;
50926
50927 err_rd:
50928 - if (!--pipe->readers)
50929 + if (atomic_dec_and_test(&pipe->readers))
50930 wake_up_interruptible(&pipe->wait);
50931 ret = -ERESTARTSYS;
50932 goto err;
50933
50934 err_wr:
50935 - if (!--pipe->writers)
50936 + if (atomic_dec_and_test(&pipe->writers))
50937 wake_up_interruptible(&pipe->wait);
50938 ret = -ERESTARTSYS;
50939 goto err;
50940
50941 err:
50942 - if (!pipe->readers && !pipe->writers)
50943 + if (!atomic_read(&pipe->readers) && !atomic_read(&pipe->writers))
50944 free_pipe_info(inode);
50945
50946 err_nocleanup:
50947 diff --git a/fs/file.c b/fs/file.c
50948 index 2b3570b..c57924b 100644
50949 --- a/fs/file.c
50950 +++ b/fs/file.c
50951 @@ -16,6 +16,7 @@
50952 #include <linux/slab.h>
50953 #include <linux/vmalloc.h>
50954 #include <linux/file.h>
50955 +#include <linux/security.h>
50956 #include <linux/fdtable.h>
50957 #include <linux/bitops.h>
50958 #include <linux/interrupt.h>
50959 @@ -892,6 +893,7 @@ int replace_fd(unsigned fd, struct file *file, unsigned flags)
50960 if (!file)
50961 return __close_fd(files, fd);
50962
50963 + gr_learn_resource(current, RLIMIT_NOFILE, fd, 0);
50964 if (fd >= rlimit(RLIMIT_NOFILE))
50965 return -EBADF;
50966
50967 @@ -918,6 +920,7 @@ SYSCALL_DEFINE3(dup3, unsigned int, oldfd, unsigned int, newfd, int, flags)
50968 if (unlikely(oldfd == newfd))
50969 return -EINVAL;
50970
50971 + gr_learn_resource(current, RLIMIT_NOFILE, newfd, 0);
50972 if (newfd >= rlimit(RLIMIT_NOFILE))
50973 return -EBADF;
50974
50975 @@ -973,6 +976,7 @@ SYSCALL_DEFINE1(dup, unsigned int, fildes)
50976 int f_dupfd(unsigned int from, struct file *file, unsigned flags)
50977 {
50978 int err;
50979 + gr_learn_resource(current, RLIMIT_NOFILE, from, 0);
50980 if (from >= rlimit(RLIMIT_NOFILE))
50981 return -EINVAL;
50982 err = alloc_fd(from, flags);
50983 diff --git a/fs/filesystems.c b/fs/filesystems.c
50984 index da165f6..3671bdb 100644
50985 --- a/fs/filesystems.c
50986 +++ b/fs/filesystems.c
50987 @@ -273,7 +273,12 @@ struct file_system_type *get_fs_type(const char *name)
50988 int len = dot ? dot - name : strlen(name);
50989
50990 fs = __get_fs_type(name, len);
50991 +
50992 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
50993 + if (!fs && (___request_module(true, "grsec_modharden_fs", "%.*s", len, name) == 0))
50994 +#else
50995 if (!fs && (request_module("%.*s", len, name) == 0))
50996 +#endif
50997 fs = __get_fs_type(name, len);
50998
50999 if (dot && fs && !(fs->fs_flags & FS_HAS_SUBTYPE)) {
51000 diff --git a/fs/fs_struct.c b/fs/fs_struct.c
51001 index fe6ca58..65318cf 100644
51002 --- a/fs/fs_struct.c
51003 +++ b/fs/fs_struct.c
51004 @@ -4,6 +4,7 @@
51005 #include <linux/path.h>
51006 #include <linux/slab.h>
51007 #include <linux/fs_struct.h>
51008 +#include <linux/grsecurity.h>
51009 #include "internal.h"
51010
51011 /*
51012 @@ -19,6 +20,7 @@ void set_fs_root(struct fs_struct *fs, struct path *path)
51013 write_seqcount_begin(&fs->seq);
51014 old_root = fs->root;
51015 fs->root = *path;
51016 + gr_set_chroot_entries(current, path);
51017 write_seqcount_end(&fs->seq);
51018 spin_unlock(&fs->lock);
51019 if (old_root.dentry)
51020 @@ -53,6 +55,21 @@ static inline int replace_path(struct path *p, const struct path *old, const str
51021 return 1;
51022 }
51023
51024 +static inline int replace_root_path(struct task_struct *task, struct path *p, const struct path *old, struct path *new)
51025 +{
51026 + if (likely(p->dentry != old->dentry || p->mnt != old->mnt))
51027 + return 0;
51028 + *p = *new;
51029 +
51030 + /* This function is only called from pivot_root(). Leave our
51031 + gr_chroot_dentry and is_chrooted flags as-is, so that a
51032 + pivoted root isn't treated as a chroot
51033 + */
51034 + //gr_set_chroot_entries(task, new);
51035 +
51036 + return 1;
51037 +}
51038 +
51039 void chroot_fs_refs(struct path *old_root, struct path *new_root)
51040 {
51041 struct task_struct *g, *p;
51042 @@ -67,7 +84,7 @@ void chroot_fs_refs(struct path *old_root, struct path *new_root)
51043 int hits = 0;
51044 spin_lock(&fs->lock);
51045 write_seqcount_begin(&fs->seq);
51046 - hits += replace_path(&fs->root, old_root, new_root);
51047 + hits += replace_root_path(p, &fs->root, old_root, new_root);
51048 hits += replace_path(&fs->pwd, old_root, new_root);
51049 write_seqcount_end(&fs->seq);
51050 while (hits--) {
51051 @@ -99,7 +116,8 @@ void exit_fs(struct task_struct *tsk)
51052 task_lock(tsk);
51053 spin_lock(&fs->lock);
51054 tsk->fs = NULL;
51055 - kill = !--fs->users;
51056 + gr_clear_chroot_entries(tsk);
51057 + kill = !atomic_dec_return(&fs->users);
51058 spin_unlock(&fs->lock);
51059 task_unlock(tsk);
51060 if (kill)
51061 @@ -112,7 +130,7 @@ struct fs_struct *copy_fs_struct(struct fs_struct *old)
51062 struct fs_struct *fs = kmem_cache_alloc(fs_cachep, GFP_KERNEL);
51063 /* We don't need to lock fs - think why ;-) */
51064 if (fs) {
51065 - fs->users = 1;
51066 + atomic_set(&fs->users, 1);
51067 fs->in_exec = 0;
51068 spin_lock_init(&fs->lock);
51069 seqcount_init(&fs->seq);
51070 @@ -121,6 +139,9 @@ struct fs_struct *copy_fs_struct(struct fs_struct *old)
51071 spin_lock(&old->lock);
51072 fs->root = old->root;
51073 path_get(&fs->root);
51074 + /* instead of calling gr_set_chroot_entries here,
51075 + we call it from every caller of this function
51076 + */
51077 fs->pwd = old->pwd;
51078 path_get(&fs->pwd);
51079 spin_unlock(&old->lock);
51080 @@ -139,8 +160,9 @@ int unshare_fs_struct(void)
51081
51082 task_lock(current);
51083 spin_lock(&fs->lock);
51084 - kill = !--fs->users;
51085 + kill = !atomic_dec_return(&fs->users);
51086 current->fs = new_fs;
51087 + gr_set_chroot_entries(current, &new_fs->root);
51088 spin_unlock(&fs->lock);
51089 task_unlock(current);
51090
51091 @@ -153,13 +175,13 @@ EXPORT_SYMBOL_GPL(unshare_fs_struct);
51092
51093 int current_umask(void)
51094 {
51095 - return current->fs->umask;
51096 + return current->fs->umask | gr_acl_umask();
51097 }
51098 EXPORT_SYMBOL(current_umask);
51099
51100 /* to be mentioned only in INIT_TASK */
51101 struct fs_struct init_fs = {
51102 - .users = 1,
51103 + .users = ATOMIC_INIT(1),
51104 .lock = __SPIN_LOCK_UNLOCKED(init_fs.lock),
51105 .seq = SEQCNT_ZERO,
51106 .umask = 0022,
51107 diff --git a/fs/fscache/cookie.c b/fs/fscache/cookie.c
51108 index 8dcb114..b1072e2 100644
51109 --- a/fs/fscache/cookie.c
51110 +++ b/fs/fscache/cookie.c
51111 @@ -68,11 +68,11 @@ struct fscache_cookie *__fscache_acquire_cookie(
51112 parent ? (char *) parent->def->name : "<no-parent>",
51113 def->name, netfs_data);
51114
51115 - fscache_stat(&fscache_n_acquires);
51116 + fscache_stat_unchecked(&fscache_n_acquires);
51117
51118 /* if there's no parent cookie, then we don't create one here either */
51119 if (!parent) {
51120 - fscache_stat(&fscache_n_acquires_null);
51121 + fscache_stat_unchecked(&fscache_n_acquires_null);
51122 _leave(" [no parent]");
51123 return NULL;
51124 }
51125 @@ -87,7 +87,7 @@ struct fscache_cookie *__fscache_acquire_cookie(
51126 /* allocate and initialise a cookie */
51127 cookie = kmem_cache_alloc(fscache_cookie_jar, GFP_KERNEL);
51128 if (!cookie) {
51129 - fscache_stat(&fscache_n_acquires_oom);
51130 + fscache_stat_unchecked(&fscache_n_acquires_oom);
51131 _leave(" [ENOMEM]");
51132 return NULL;
51133 }
51134 @@ -109,13 +109,13 @@ struct fscache_cookie *__fscache_acquire_cookie(
51135
51136 switch (cookie->def->type) {
51137 case FSCACHE_COOKIE_TYPE_INDEX:
51138 - fscache_stat(&fscache_n_cookie_index);
51139 + fscache_stat_unchecked(&fscache_n_cookie_index);
51140 break;
51141 case FSCACHE_COOKIE_TYPE_DATAFILE:
51142 - fscache_stat(&fscache_n_cookie_data);
51143 + fscache_stat_unchecked(&fscache_n_cookie_data);
51144 break;
51145 default:
51146 - fscache_stat(&fscache_n_cookie_special);
51147 + fscache_stat_unchecked(&fscache_n_cookie_special);
51148 break;
51149 }
51150
51151 @@ -126,13 +126,13 @@ struct fscache_cookie *__fscache_acquire_cookie(
51152 if (fscache_acquire_non_index_cookie(cookie) < 0) {
51153 atomic_dec(&parent->n_children);
51154 __fscache_cookie_put(cookie);
51155 - fscache_stat(&fscache_n_acquires_nobufs);
51156 + fscache_stat_unchecked(&fscache_n_acquires_nobufs);
51157 _leave(" = NULL");
51158 return NULL;
51159 }
51160 }
51161
51162 - fscache_stat(&fscache_n_acquires_ok);
51163 + fscache_stat_unchecked(&fscache_n_acquires_ok);
51164 _leave(" = %p", cookie);
51165 return cookie;
51166 }
51167 @@ -168,7 +168,7 @@ static int fscache_acquire_non_index_cookie(struct fscache_cookie *cookie)
51168 cache = fscache_select_cache_for_object(cookie->parent);
51169 if (!cache) {
51170 up_read(&fscache_addremove_sem);
51171 - fscache_stat(&fscache_n_acquires_no_cache);
51172 + fscache_stat_unchecked(&fscache_n_acquires_no_cache);
51173 _leave(" = -ENOMEDIUM [no cache]");
51174 return -ENOMEDIUM;
51175 }
51176 @@ -256,12 +256,12 @@ static int fscache_alloc_object(struct fscache_cache *cache,
51177 object = cache->ops->alloc_object(cache, cookie);
51178 fscache_stat_d(&fscache_n_cop_alloc_object);
51179 if (IS_ERR(object)) {
51180 - fscache_stat(&fscache_n_object_no_alloc);
51181 + fscache_stat_unchecked(&fscache_n_object_no_alloc);
51182 ret = PTR_ERR(object);
51183 goto error;
51184 }
51185
51186 - fscache_stat(&fscache_n_object_alloc);
51187 + fscache_stat_unchecked(&fscache_n_object_alloc);
51188
51189 object->debug_id = atomic_inc_return(&fscache_object_debug_id);
51190
51191 @@ -378,7 +378,7 @@ void __fscache_invalidate(struct fscache_cookie *cookie)
51192
51193 _enter("{%s}", cookie->def->name);
51194
51195 - fscache_stat(&fscache_n_invalidates);
51196 + fscache_stat_unchecked(&fscache_n_invalidates);
51197
51198 /* Only permit invalidation of data files. Invalidating an index will
51199 * require the caller to release all its attachments to the tree rooted
51200 @@ -437,10 +437,10 @@ void __fscache_update_cookie(struct fscache_cookie *cookie)
51201 struct fscache_object *object;
51202 struct hlist_node *_p;
51203
51204 - fscache_stat(&fscache_n_updates);
51205 + fscache_stat_unchecked(&fscache_n_updates);
51206
51207 if (!cookie) {
51208 - fscache_stat(&fscache_n_updates_null);
51209 + fscache_stat_unchecked(&fscache_n_updates_null);
51210 _leave(" [no cookie]");
51211 return;
51212 }
51213 @@ -474,12 +474,12 @@ void __fscache_relinquish_cookie(struct fscache_cookie *cookie, int retire)
51214 struct fscache_object *object;
51215 unsigned long event;
51216
51217 - fscache_stat(&fscache_n_relinquishes);
51218 + fscache_stat_unchecked(&fscache_n_relinquishes);
51219 if (retire)
51220 - fscache_stat(&fscache_n_relinquishes_retire);
51221 + fscache_stat_unchecked(&fscache_n_relinquishes_retire);
51222
51223 if (!cookie) {
51224 - fscache_stat(&fscache_n_relinquishes_null);
51225 + fscache_stat_unchecked(&fscache_n_relinquishes_null);
51226 _leave(" [no cookie]");
51227 return;
51228 }
51229 @@ -495,7 +495,7 @@ void __fscache_relinquish_cookie(struct fscache_cookie *cookie, int retire)
51230
51231 /* wait for the cookie to finish being instantiated (or to fail) */
51232 if (test_bit(FSCACHE_COOKIE_CREATING, &cookie->flags)) {
51233 - fscache_stat(&fscache_n_relinquishes_waitcrt);
51234 + fscache_stat_unchecked(&fscache_n_relinquishes_waitcrt);
51235 wait_on_bit(&cookie->flags, FSCACHE_COOKIE_CREATING,
51236 fscache_wait_bit, TASK_UNINTERRUPTIBLE);
51237 }
51238 diff --git a/fs/fscache/internal.h b/fs/fscache/internal.h
51239 index ee38fef..0a326d4 100644
51240 --- a/fs/fscache/internal.h
51241 +++ b/fs/fscache/internal.h
51242 @@ -148,101 +148,101 @@ extern void fscache_proc_cleanup(void);
51243 * stats.c
51244 */
51245 #ifdef CONFIG_FSCACHE_STATS
51246 -extern atomic_t fscache_n_ops_processed[FSCACHE_MAX_THREADS];
51247 -extern atomic_t fscache_n_objs_processed[FSCACHE_MAX_THREADS];
51248 +extern atomic_unchecked_t fscache_n_ops_processed[FSCACHE_MAX_THREADS];
51249 +extern atomic_unchecked_t fscache_n_objs_processed[FSCACHE_MAX_THREADS];
51250
51251 -extern atomic_t fscache_n_op_pend;
51252 -extern atomic_t fscache_n_op_run;
51253 -extern atomic_t fscache_n_op_enqueue;
51254 -extern atomic_t fscache_n_op_deferred_release;
51255 -extern atomic_t fscache_n_op_release;
51256 -extern atomic_t fscache_n_op_gc;
51257 -extern atomic_t fscache_n_op_cancelled;
51258 -extern atomic_t fscache_n_op_rejected;
51259 +extern atomic_unchecked_t fscache_n_op_pend;
51260 +extern atomic_unchecked_t fscache_n_op_run;
51261 +extern atomic_unchecked_t fscache_n_op_enqueue;
51262 +extern atomic_unchecked_t fscache_n_op_deferred_release;
51263 +extern atomic_unchecked_t fscache_n_op_release;
51264 +extern atomic_unchecked_t fscache_n_op_gc;
51265 +extern atomic_unchecked_t fscache_n_op_cancelled;
51266 +extern atomic_unchecked_t fscache_n_op_rejected;
51267
51268 -extern atomic_t fscache_n_attr_changed;
51269 -extern atomic_t fscache_n_attr_changed_ok;
51270 -extern atomic_t fscache_n_attr_changed_nobufs;
51271 -extern atomic_t fscache_n_attr_changed_nomem;
51272 -extern atomic_t fscache_n_attr_changed_calls;
51273 +extern atomic_unchecked_t fscache_n_attr_changed;
51274 +extern atomic_unchecked_t fscache_n_attr_changed_ok;
51275 +extern atomic_unchecked_t fscache_n_attr_changed_nobufs;
51276 +extern atomic_unchecked_t fscache_n_attr_changed_nomem;
51277 +extern atomic_unchecked_t fscache_n_attr_changed_calls;
51278
51279 -extern atomic_t fscache_n_allocs;
51280 -extern atomic_t fscache_n_allocs_ok;
51281 -extern atomic_t fscache_n_allocs_wait;
51282 -extern atomic_t fscache_n_allocs_nobufs;
51283 -extern atomic_t fscache_n_allocs_intr;
51284 -extern atomic_t fscache_n_allocs_object_dead;
51285 -extern atomic_t fscache_n_alloc_ops;
51286 -extern atomic_t fscache_n_alloc_op_waits;
51287 +extern atomic_unchecked_t fscache_n_allocs;
51288 +extern atomic_unchecked_t fscache_n_allocs_ok;
51289 +extern atomic_unchecked_t fscache_n_allocs_wait;
51290 +extern atomic_unchecked_t fscache_n_allocs_nobufs;
51291 +extern atomic_unchecked_t fscache_n_allocs_intr;
51292 +extern atomic_unchecked_t fscache_n_allocs_object_dead;
51293 +extern atomic_unchecked_t fscache_n_alloc_ops;
51294 +extern atomic_unchecked_t fscache_n_alloc_op_waits;
51295
51296 -extern atomic_t fscache_n_retrievals;
51297 -extern atomic_t fscache_n_retrievals_ok;
51298 -extern atomic_t fscache_n_retrievals_wait;
51299 -extern atomic_t fscache_n_retrievals_nodata;
51300 -extern atomic_t fscache_n_retrievals_nobufs;
51301 -extern atomic_t fscache_n_retrievals_intr;
51302 -extern atomic_t fscache_n_retrievals_nomem;
51303 -extern atomic_t fscache_n_retrievals_object_dead;
51304 -extern atomic_t fscache_n_retrieval_ops;
51305 -extern atomic_t fscache_n_retrieval_op_waits;
51306 +extern atomic_unchecked_t fscache_n_retrievals;
51307 +extern atomic_unchecked_t fscache_n_retrievals_ok;
51308 +extern atomic_unchecked_t fscache_n_retrievals_wait;
51309 +extern atomic_unchecked_t fscache_n_retrievals_nodata;
51310 +extern atomic_unchecked_t fscache_n_retrievals_nobufs;
51311 +extern atomic_unchecked_t fscache_n_retrievals_intr;
51312 +extern atomic_unchecked_t fscache_n_retrievals_nomem;
51313 +extern atomic_unchecked_t fscache_n_retrievals_object_dead;
51314 +extern atomic_unchecked_t fscache_n_retrieval_ops;
51315 +extern atomic_unchecked_t fscache_n_retrieval_op_waits;
51316
51317 -extern atomic_t fscache_n_stores;
51318 -extern atomic_t fscache_n_stores_ok;
51319 -extern atomic_t fscache_n_stores_again;
51320 -extern atomic_t fscache_n_stores_nobufs;
51321 -extern atomic_t fscache_n_stores_oom;
51322 -extern atomic_t fscache_n_store_ops;
51323 -extern atomic_t fscache_n_store_calls;
51324 -extern atomic_t fscache_n_store_pages;
51325 -extern atomic_t fscache_n_store_radix_deletes;
51326 -extern atomic_t fscache_n_store_pages_over_limit;
51327 +extern atomic_unchecked_t fscache_n_stores;
51328 +extern atomic_unchecked_t fscache_n_stores_ok;
51329 +extern atomic_unchecked_t fscache_n_stores_again;
51330 +extern atomic_unchecked_t fscache_n_stores_nobufs;
51331 +extern atomic_unchecked_t fscache_n_stores_oom;
51332 +extern atomic_unchecked_t fscache_n_store_ops;
51333 +extern atomic_unchecked_t fscache_n_store_calls;
51334 +extern atomic_unchecked_t fscache_n_store_pages;
51335 +extern atomic_unchecked_t fscache_n_store_radix_deletes;
51336 +extern atomic_unchecked_t fscache_n_store_pages_over_limit;
51337
51338 -extern atomic_t fscache_n_store_vmscan_not_storing;
51339 -extern atomic_t fscache_n_store_vmscan_gone;
51340 -extern atomic_t fscache_n_store_vmscan_busy;
51341 -extern atomic_t fscache_n_store_vmscan_cancelled;
51342 -extern atomic_t fscache_n_store_vmscan_wait;
51343 +extern atomic_unchecked_t fscache_n_store_vmscan_not_storing;
51344 +extern atomic_unchecked_t fscache_n_store_vmscan_gone;
51345 +extern atomic_unchecked_t fscache_n_store_vmscan_busy;
51346 +extern atomic_unchecked_t fscache_n_store_vmscan_cancelled;
51347 +extern atomic_unchecked_t fscache_n_store_vmscan_wait;
51348
51349 -extern atomic_t fscache_n_marks;
51350 -extern atomic_t fscache_n_uncaches;
51351 +extern atomic_unchecked_t fscache_n_marks;
51352 +extern atomic_unchecked_t fscache_n_uncaches;
51353
51354 -extern atomic_t fscache_n_acquires;
51355 -extern atomic_t fscache_n_acquires_null;
51356 -extern atomic_t fscache_n_acquires_no_cache;
51357 -extern atomic_t fscache_n_acquires_ok;
51358 -extern atomic_t fscache_n_acquires_nobufs;
51359 -extern atomic_t fscache_n_acquires_oom;
51360 +extern atomic_unchecked_t fscache_n_acquires;
51361 +extern atomic_unchecked_t fscache_n_acquires_null;
51362 +extern atomic_unchecked_t fscache_n_acquires_no_cache;
51363 +extern atomic_unchecked_t fscache_n_acquires_ok;
51364 +extern atomic_unchecked_t fscache_n_acquires_nobufs;
51365 +extern atomic_unchecked_t fscache_n_acquires_oom;
51366
51367 -extern atomic_t fscache_n_invalidates;
51368 -extern atomic_t fscache_n_invalidates_run;
51369 +extern atomic_unchecked_t fscache_n_invalidates;
51370 +extern atomic_unchecked_t fscache_n_invalidates_run;
51371
51372 -extern atomic_t fscache_n_updates;
51373 -extern atomic_t fscache_n_updates_null;
51374 -extern atomic_t fscache_n_updates_run;
51375 +extern atomic_unchecked_t fscache_n_updates;
51376 +extern atomic_unchecked_t fscache_n_updates_null;
51377 +extern atomic_unchecked_t fscache_n_updates_run;
51378
51379 -extern atomic_t fscache_n_relinquishes;
51380 -extern atomic_t fscache_n_relinquishes_null;
51381 -extern atomic_t fscache_n_relinquishes_waitcrt;
51382 -extern atomic_t fscache_n_relinquishes_retire;
51383 +extern atomic_unchecked_t fscache_n_relinquishes;
51384 +extern atomic_unchecked_t fscache_n_relinquishes_null;
51385 +extern atomic_unchecked_t fscache_n_relinquishes_waitcrt;
51386 +extern atomic_unchecked_t fscache_n_relinquishes_retire;
51387
51388 -extern atomic_t fscache_n_cookie_index;
51389 -extern atomic_t fscache_n_cookie_data;
51390 -extern atomic_t fscache_n_cookie_special;
51391 +extern atomic_unchecked_t fscache_n_cookie_index;
51392 +extern atomic_unchecked_t fscache_n_cookie_data;
51393 +extern atomic_unchecked_t fscache_n_cookie_special;
51394
51395 -extern atomic_t fscache_n_object_alloc;
51396 -extern atomic_t fscache_n_object_no_alloc;
51397 -extern atomic_t fscache_n_object_lookups;
51398 -extern atomic_t fscache_n_object_lookups_negative;
51399 -extern atomic_t fscache_n_object_lookups_positive;
51400 -extern atomic_t fscache_n_object_lookups_timed_out;
51401 -extern atomic_t fscache_n_object_created;
51402 -extern atomic_t fscache_n_object_avail;
51403 -extern atomic_t fscache_n_object_dead;
51404 +extern atomic_unchecked_t fscache_n_object_alloc;
51405 +extern atomic_unchecked_t fscache_n_object_no_alloc;
51406 +extern atomic_unchecked_t fscache_n_object_lookups;
51407 +extern atomic_unchecked_t fscache_n_object_lookups_negative;
51408 +extern atomic_unchecked_t fscache_n_object_lookups_positive;
51409 +extern atomic_unchecked_t fscache_n_object_lookups_timed_out;
51410 +extern atomic_unchecked_t fscache_n_object_created;
51411 +extern atomic_unchecked_t fscache_n_object_avail;
51412 +extern atomic_unchecked_t fscache_n_object_dead;
51413
51414 -extern atomic_t fscache_n_checkaux_none;
51415 -extern atomic_t fscache_n_checkaux_okay;
51416 -extern atomic_t fscache_n_checkaux_update;
51417 -extern atomic_t fscache_n_checkaux_obsolete;
51418 +extern atomic_unchecked_t fscache_n_checkaux_none;
51419 +extern atomic_unchecked_t fscache_n_checkaux_okay;
51420 +extern atomic_unchecked_t fscache_n_checkaux_update;
51421 +extern atomic_unchecked_t fscache_n_checkaux_obsolete;
51422
51423 extern atomic_t fscache_n_cop_alloc_object;
51424 extern atomic_t fscache_n_cop_lookup_object;
51425 @@ -267,6 +267,11 @@ static inline void fscache_stat(atomic_t *stat)
51426 atomic_inc(stat);
51427 }
51428
51429 +static inline void fscache_stat_unchecked(atomic_unchecked_t *stat)
51430 +{
51431 + atomic_inc_unchecked(stat);
51432 +}
51433 +
51434 static inline void fscache_stat_d(atomic_t *stat)
51435 {
51436 atomic_dec(stat);
51437 @@ -279,6 +284,7 @@ extern const struct file_operations fscache_stats_fops;
51438
51439 #define __fscache_stat(stat) (NULL)
51440 #define fscache_stat(stat) do {} while (0)
51441 +#define fscache_stat_unchecked(stat) do {} while (0)
51442 #define fscache_stat_d(stat) do {} while (0)
51443 #endif
51444
51445 diff --git a/fs/fscache/object.c b/fs/fscache/object.c
51446 index 50d41c1..10ee117 100644
51447 --- a/fs/fscache/object.c
51448 +++ b/fs/fscache/object.c
51449 @@ -143,7 +143,7 @@ static void fscache_object_state_machine(struct fscache_object *object)
51450 /* Invalidate an object on disk */
51451 case FSCACHE_OBJECT_INVALIDATING:
51452 clear_bit(FSCACHE_OBJECT_EV_INVALIDATE, &object->events);
51453 - fscache_stat(&fscache_n_invalidates_run);
51454 + fscache_stat_unchecked(&fscache_n_invalidates_run);
51455 fscache_stat(&fscache_n_cop_invalidate_object);
51456 fscache_invalidate_object(object);
51457 fscache_stat_d(&fscache_n_cop_invalidate_object);
51458 @@ -153,7 +153,7 @@ static void fscache_object_state_machine(struct fscache_object *object)
51459 /* update the object metadata on disk */
51460 case FSCACHE_OBJECT_UPDATING:
51461 clear_bit(FSCACHE_OBJECT_EV_UPDATE, &object->events);
51462 - fscache_stat(&fscache_n_updates_run);
51463 + fscache_stat_unchecked(&fscache_n_updates_run);
51464 fscache_stat(&fscache_n_cop_update_object);
51465 object->cache->ops->update_object(object);
51466 fscache_stat_d(&fscache_n_cop_update_object);
51467 @@ -242,7 +242,7 @@ static void fscache_object_state_machine(struct fscache_object *object)
51468 spin_lock(&object->lock);
51469 object->state = FSCACHE_OBJECT_DEAD;
51470 spin_unlock(&object->lock);
51471 - fscache_stat(&fscache_n_object_dead);
51472 + fscache_stat_unchecked(&fscache_n_object_dead);
51473 goto terminal_transit;
51474
51475 /* handle the parent cache of this object being withdrawn from
51476 @@ -257,7 +257,7 @@ static void fscache_object_state_machine(struct fscache_object *object)
51477 spin_lock(&object->lock);
51478 object->state = FSCACHE_OBJECT_DEAD;
51479 spin_unlock(&object->lock);
51480 - fscache_stat(&fscache_n_object_dead);
51481 + fscache_stat_unchecked(&fscache_n_object_dead);
51482 goto terminal_transit;
51483
51484 /* complain about the object being woken up once it is
51485 @@ -495,7 +495,7 @@ static void fscache_lookup_object(struct fscache_object *object)
51486 parent->cookie->def->name, cookie->def->name,
51487 object->cache->tag->name);
51488
51489 - fscache_stat(&fscache_n_object_lookups);
51490 + fscache_stat_unchecked(&fscache_n_object_lookups);
51491 fscache_stat(&fscache_n_cop_lookup_object);
51492 ret = object->cache->ops->lookup_object(object);
51493 fscache_stat_d(&fscache_n_cop_lookup_object);
51494 @@ -506,7 +506,7 @@ static void fscache_lookup_object(struct fscache_object *object)
51495 if (ret == -ETIMEDOUT) {
51496 /* probably stuck behind another object, so move this one to
51497 * the back of the queue */
51498 - fscache_stat(&fscache_n_object_lookups_timed_out);
51499 + fscache_stat_unchecked(&fscache_n_object_lookups_timed_out);
51500 set_bit(FSCACHE_OBJECT_EV_REQUEUE, &object->events);
51501 }
51502
51503 @@ -529,7 +529,7 @@ void fscache_object_lookup_negative(struct fscache_object *object)
51504
51505 spin_lock(&object->lock);
51506 if (object->state == FSCACHE_OBJECT_LOOKING_UP) {
51507 - fscache_stat(&fscache_n_object_lookups_negative);
51508 + fscache_stat_unchecked(&fscache_n_object_lookups_negative);
51509
51510 /* transit here to allow write requests to begin stacking up
51511 * and read requests to begin returning ENODATA */
51512 @@ -575,7 +575,7 @@ void fscache_obtained_object(struct fscache_object *object)
51513 * result, in which case there may be data available */
51514 spin_lock(&object->lock);
51515 if (object->state == FSCACHE_OBJECT_LOOKING_UP) {
51516 - fscache_stat(&fscache_n_object_lookups_positive);
51517 + fscache_stat_unchecked(&fscache_n_object_lookups_positive);
51518
51519 clear_bit(FSCACHE_COOKIE_NO_DATA_YET, &cookie->flags);
51520
51521 @@ -589,7 +589,7 @@ void fscache_obtained_object(struct fscache_object *object)
51522 set_bit(FSCACHE_OBJECT_EV_REQUEUE, &object->events);
51523 } else {
51524 ASSERTCMP(object->state, ==, FSCACHE_OBJECT_CREATING);
51525 - fscache_stat(&fscache_n_object_created);
51526 + fscache_stat_unchecked(&fscache_n_object_created);
51527
51528 object->state = FSCACHE_OBJECT_AVAILABLE;
51529 spin_unlock(&object->lock);
51530 @@ -634,7 +634,7 @@ static void fscache_object_available(struct fscache_object *object)
51531 fscache_enqueue_dependents(object);
51532
51533 fscache_hist(fscache_obj_instantiate_histogram, object->lookup_jif);
51534 - fscache_stat(&fscache_n_object_avail);
51535 + fscache_stat_unchecked(&fscache_n_object_avail);
51536
51537 _leave("");
51538 }
51539 @@ -894,7 +894,7 @@ enum fscache_checkaux fscache_check_aux(struct fscache_object *object,
51540 enum fscache_checkaux result;
51541
51542 if (!object->cookie->def->check_aux) {
51543 - fscache_stat(&fscache_n_checkaux_none);
51544 + fscache_stat_unchecked(&fscache_n_checkaux_none);
51545 return FSCACHE_CHECKAUX_OKAY;
51546 }
51547
51548 @@ -903,17 +903,17 @@ enum fscache_checkaux fscache_check_aux(struct fscache_object *object,
51549 switch (result) {
51550 /* entry okay as is */
51551 case FSCACHE_CHECKAUX_OKAY:
51552 - fscache_stat(&fscache_n_checkaux_okay);
51553 + fscache_stat_unchecked(&fscache_n_checkaux_okay);
51554 break;
51555
51556 /* entry requires update */
51557 case FSCACHE_CHECKAUX_NEEDS_UPDATE:
51558 - fscache_stat(&fscache_n_checkaux_update);
51559 + fscache_stat_unchecked(&fscache_n_checkaux_update);
51560 break;
51561
51562 /* entry requires deletion */
51563 case FSCACHE_CHECKAUX_OBSOLETE:
51564 - fscache_stat(&fscache_n_checkaux_obsolete);
51565 + fscache_stat_unchecked(&fscache_n_checkaux_obsolete);
51566 break;
51567
51568 default:
51569 diff --git a/fs/fscache/operation.c b/fs/fscache/operation.c
51570 index 762a9ec..2023284 100644
51571 --- a/fs/fscache/operation.c
51572 +++ b/fs/fscache/operation.c
51573 @@ -17,7 +17,7 @@
51574 #include <linux/slab.h>
51575 #include "internal.h"
51576
51577 -atomic_t fscache_op_debug_id;
51578 +atomic_unchecked_t fscache_op_debug_id;
51579 EXPORT_SYMBOL(fscache_op_debug_id);
51580
51581 /**
51582 @@ -39,7 +39,7 @@ void fscache_enqueue_operation(struct fscache_operation *op)
51583 ASSERTCMP(atomic_read(&op->usage), >, 0);
51584 ASSERTCMP(op->state, ==, FSCACHE_OP_ST_IN_PROGRESS);
51585
51586 - fscache_stat(&fscache_n_op_enqueue);
51587 + fscache_stat_unchecked(&fscache_n_op_enqueue);
51588 switch (op->flags & FSCACHE_OP_TYPE) {
51589 case FSCACHE_OP_ASYNC:
51590 _debug("queue async");
51591 @@ -73,7 +73,7 @@ static void fscache_run_op(struct fscache_object *object,
51592 wake_up_bit(&op->flags, FSCACHE_OP_WAITING);
51593 if (op->processor)
51594 fscache_enqueue_operation(op);
51595 - fscache_stat(&fscache_n_op_run);
51596 + fscache_stat_unchecked(&fscache_n_op_run);
51597 }
51598
51599 /*
51600 @@ -105,11 +105,11 @@ int fscache_submit_exclusive_op(struct fscache_object *object,
51601 if (object->n_in_progress > 0) {
51602 atomic_inc(&op->usage);
51603 list_add_tail(&op->pend_link, &object->pending_ops);
51604 - fscache_stat(&fscache_n_op_pend);
51605 + fscache_stat_unchecked(&fscache_n_op_pend);
51606 } else if (!list_empty(&object->pending_ops)) {
51607 atomic_inc(&op->usage);
51608 list_add_tail(&op->pend_link, &object->pending_ops);
51609 - fscache_stat(&fscache_n_op_pend);
51610 + fscache_stat_unchecked(&fscache_n_op_pend);
51611 fscache_start_operations(object);
51612 } else {
51613 ASSERTCMP(object->n_in_progress, ==, 0);
51614 @@ -125,7 +125,7 @@ int fscache_submit_exclusive_op(struct fscache_object *object,
51615 object->n_exclusive++; /* reads and writes must wait */
51616 atomic_inc(&op->usage);
51617 list_add_tail(&op->pend_link, &object->pending_ops);
51618 - fscache_stat(&fscache_n_op_pend);
51619 + fscache_stat_unchecked(&fscache_n_op_pend);
51620 ret = 0;
51621 } else {
51622 /* If we're in any other state, there must have been an I/O
51623 @@ -215,11 +215,11 @@ int fscache_submit_op(struct fscache_object *object,
51624 if (object->n_exclusive > 0) {
51625 atomic_inc(&op->usage);
51626 list_add_tail(&op->pend_link, &object->pending_ops);
51627 - fscache_stat(&fscache_n_op_pend);
51628 + fscache_stat_unchecked(&fscache_n_op_pend);
51629 } else if (!list_empty(&object->pending_ops)) {
51630 atomic_inc(&op->usage);
51631 list_add_tail(&op->pend_link, &object->pending_ops);
51632 - fscache_stat(&fscache_n_op_pend);
51633 + fscache_stat_unchecked(&fscache_n_op_pend);
51634 fscache_start_operations(object);
51635 } else {
51636 ASSERTCMP(object->n_exclusive, ==, 0);
51637 @@ -231,12 +231,12 @@ int fscache_submit_op(struct fscache_object *object,
51638 object->n_ops++;
51639 atomic_inc(&op->usage);
51640 list_add_tail(&op->pend_link, &object->pending_ops);
51641 - fscache_stat(&fscache_n_op_pend);
51642 + fscache_stat_unchecked(&fscache_n_op_pend);
51643 ret = 0;
51644 } else if (object->state == FSCACHE_OBJECT_DYING ||
51645 object->state == FSCACHE_OBJECT_LC_DYING ||
51646 object->state == FSCACHE_OBJECT_WITHDRAWING) {
51647 - fscache_stat(&fscache_n_op_rejected);
51648 + fscache_stat_unchecked(&fscache_n_op_rejected);
51649 op->state = FSCACHE_OP_ST_CANCELLED;
51650 ret = -ENOBUFS;
51651 } else if (!test_bit(FSCACHE_IOERROR, &object->cache->flags)) {
51652 @@ -315,7 +315,7 @@ int fscache_cancel_op(struct fscache_operation *op,
51653 ret = -EBUSY;
51654 if (op->state == FSCACHE_OP_ST_PENDING) {
51655 ASSERT(!list_empty(&op->pend_link));
51656 - fscache_stat(&fscache_n_op_cancelled);
51657 + fscache_stat_unchecked(&fscache_n_op_cancelled);
51658 list_del_init(&op->pend_link);
51659 if (do_cancel)
51660 do_cancel(op);
51661 @@ -347,7 +347,7 @@ void fscache_cancel_all_ops(struct fscache_object *object)
51662 while (!list_empty(&object->pending_ops)) {
51663 op = list_entry(object->pending_ops.next,
51664 struct fscache_operation, pend_link);
51665 - fscache_stat(&fscache_n_op_cancelled);
51666 + fscache_stat_unchecked(&fscache_n_op_cancelled);
51667 list_del_init(&op->pend_link);
51668
51669 ASSERTCMP(op->state, ==, FSCACHE_OP_ST_PENDING);
51670 @@ -419,7 +419,7 @@ void fscache_put_operation(struct fscache_operation *op)
51671 op->state, ==, FSCACHE_OP_ST_CANCELLED);
51672 op->state = FSCACHE_OP_ST_DEAD;
51673
51674 - fscache_stat(&fscache_n_op_release);
51675 + fscache_stat_unchecked(&fscache_n_op_release);
51676
51677 if (op->release) {
51678 op->release(op);
51679 @@ -442,7 +442,7 @@ void fscache_put_operation(struct fscache_operation *op)
51680 * lock, and defer it otherwise */
51681 if (!spin_trylock(&object->lock)) {
51682 _debug("defer put");
51683 - fscache_stat(&fscache_n_op_deferred_release);
51684 + fscache_stat_unchecked(&fscache_n_op_deferred_release);
51685
51686 cache = object->cache;
51687 spin_lock(&cache->op_gc_list_lock);
51688 @@ -495,7 +495,7 @@ void fscache_operation_gc(struct work_struct *work)
51689
51690 _debug("GC DEFERRED REL OBJ%x OP%x",
51691 object->debug_id, op->debug_id);
51692 - fscache_stat(&fscache_n_op_gc);
51693 + fscache_stat_unchecked(&fscache_n_op_gc);
51694
51695 ASSERTCMP(atomic_read(&op->usage), ==, 0);
51696 ASSERTCMP(op->state, ==, FSCACHE_OP_ST_DEAD);
51697 diff --git a/fs/fscache/page.c b/fs/fscache/page.c
51698 index ff000e5..c44ec6d 100644
51699 --- a/fs/fscache/page.c
51700 +++ b/fs/fscache/page.c
51701 @@ -61,7 +61,7 @@ try_again:
51702 val = radix_tree_lookup(&cookie->stores, page->index);
51703 if (!val) {
51704 rcu_read_unlock();
51705 - fscache_stat(&fscache_n_store_vmscan_not_storing);
51706 + fscache_stat_unchecked(&fscache_n_store_vmscan_not_storing);
51707 __fscache_uncache_page(cookie, page);
51708 return true;
51709 }
51710 @@ -91,11 +91,11 @@ try_again:
51711 spin_unlock(&cookie->stores_lock);
51712
51713 if (xpage) {
51714 - fscache_stat(&fscache_n_store_vmscan_cancelled);
51715 - fscache_stat(&fscache_n_store_radix_deletes);
51716 + fscache_stat_unchecked(&fscache_n_store_vmscan_cancelled);
51717 + fscache_stat_unchecked(&fscache_n_store_radix_deletes);
51718 ASSERTCMP(xpage, ==, page);
51719 } else {
51720 - fscache_stat(&fscache_n_store_vmscan_gone);
51721 + fscache_stat_unchecked(&fscache_n_store_vmscan_gone);
51722 }
51723
51724 wake_up_bit(&cookie->flags, 0);
51725 @@ -110,11 +110,11 @@ page_busy:
51726 * sleeping on memory allocation, so we may need to impose a timeout
51727 * too. */
51728 if (!(gfp & __GFP_WAIT)) {
51729 - fscache_stat(&fscache_n_store_vmscan_busy);
51730 + fscache_stat_unchecked(&fscache_n_store_vmscan_busy);
51731 return false;
51732 }
51733
51734 - fscache_stat(&fscache_n_store_vmscan_wait);
51735 + fscache_stat_unchecked(&fscache_n_store_vmscan_wait);
51736 __fscache_wait_on_page_write(cookie, page);
51737 gfp &= ~__GFP_WAIT;
51738 goto try_again;
51739 @@ -140,7 +140,7 @@ static void fscache_end_page_write(struct fscache_object *object,
51740 FSCACHE_COOKIE_STORING_TAG);
51741 if (!radix_tree_tag_get(&cookie->stores, page->index,
51742 FSCACHE_COOKIE_PENDING_TAG)) {
51743 - fscache_stat(&fscache_n_store_radix_deletes);
51744 + fscache_stat_unchecked(&fscache_n_store_radix_deletes);
51745 xpage = radix_tree_delete(&cookie->stores, page->index);
51746 }
51747 spin_unlock(&cookie->stores_lock);
51748 @@ -161,7 +161,7 @@ static void fscache_attr_changed_op(struct fscache_operation *op)
51749
51750 _enter("{OBJ%x OP%x}", object->debug_id, op->debug_id);
51751
51752 - fscache_stat(&fscache_n_attr_changed_calls);
51753 + fscache_stat_unchecked(&fscache_n_attr_changed_calls);
51754
51755 if (fscache_object_is_active(object)) {
51756 fscache_stat(&fscache_n_cop_attr_changed);
51757 @@ -187,11 +187,11 @@ int __fscache_attr_changed(struct fscache_cookie *cookie)
51758
51759 ASSERTCMP(cookie->def->type, !=, FSCACHE_COOKIE_TYPE_INDEX);
51760
51761 - fscache_stat(&fscache_n_attr_changed);
51762 + fscache_stat_unchecked(&fscache_n_attr_changed);
51763
51764 op = kzalloc(sizeof(*op), GFP_KERNEL);
51765 if (!op) {
51766 - fscache_stat(&fscache_n_attr_changed_nomem);
51767 + fscache_stat_unchecked(&fscache_n_attr_changed_nomem);
51768 _leave(" = -ENOMEM");
51769 return -ENOMEM;
51770 }
51771 @@ -209,7 +209,7 @@ int __fscache_attr_changed(struct fscache_cookie *cookie)
51772 if (fscache_submit_exclusive_op(object, op) < 0)
51773 goto nobufs;
51774 spin_unlock(&cookie->lock);
51775 - fscache_stat(&fscache_n_attr_changed_ok);
51776 + fscache_stat_unchecked(&fscache_n_attr_changed_ok);
51777 fscache_put_operation(op);
51778 _leave(" = 0");
51779 return 0;
51780 @@ -217,7 +217,7 @@ int __fscache_attr_changed(struct fscache_cookie *cookie)
51781 nobufs:
51782 spin_unlock(&cookie->lock);
51783 kfree(op);
51784 - fscache_stat(&fscache_n_attr_changed_nobufs);
51785 + fscache_stat_unchecked(&fscache_n_attr_changed_nobufs);
51786 _leave(" = %d", -ENOBUFS);
51787 return -ENOBUFS;
51788 }
51789 @@ -255,7 +255,7 @@ static struct fscache_retrieval *fscache_alloc_retrieval(
51790 /* allocate a retrieval operation and attempt to submit it */
51791 op = kzalloc(sizeof(*op), GFP_NOIO);
51792 if (!op) {
51793 - fscache_stat(&fscache_n_retrievals_nomem);
51794 + fscache_stat_unchecked(&fscache_n_retrievals_nomem);
51795 return NULL;
51796 }
51797
51798 @@ -283,13 +283,13 @@ static int fscache_wait_for_deferred_lookup(struct fscache_cookie *cookie)
51799 return 0;
51800 }
51801
51802 - fscache_stat(&fscache_n_retrievals_wait);
51803 + fscache_stat_unchecked(&fscache_n_retrievals_wait);
51804
51805 jif = jiffies;
51806 if (wait_on_bit(&cookie->flags, FSCACHE_COOKIE_LOOKING_UP,
51807 fscache_wait_bit_interruptible,
51808 TASK_INTERRUPTIBLE) != 0) {
51809 - fscache_stat(&fscache_n_retrievals_intr);
51810 + fscache_stat_unchecked(&fscache_n_retrievals_intr);
51811 _leave(" = -ERESTARTSYS");
51812 return -ERESTARTSYS;
51813 }
51814 @@ -318,8 +318,8 @@ static void fscache_do_cancel_retrieval(struct fscache_operation *_op)
51815 */
51816 static int fscache_wait_for_retrieval_activation(struct fscache_object *object,
51817 struct fscache_retrieval *op,
51818 - atomic_t *stat_op_waits,
51819 - atomic_t *stat_object_dead)
51820 + atomic_unchecked_t *stat_op_waits,
51821 + atomic_unchecked_t *stat_object_dead)
51822 {
51823 int ret;
51824
51825 @@ -327,7 +327,7 @@ static int fscache_wait_for_retrieval_activation(struct fscache_object *object,
51826 goto check_if_dead;
51827
51828 _debug(">>> WT");
51829 - fscache_stat(stat_op_waits);
51830 + fscache_stat_unchecked(stat_op_waits);
51831 if (wait_on_bit(&op->op.flags, FSCACHE_OP_WAITING,
51832 fscache_wait_bit_interruptible,
51833 TASK_INTERRUPTIBLE) != 0) {
51834 @@ -344,14 +344,14 @@ static int fscache_wait_for_retrieval_activation(struct fscache_object *object,
51835
51836 check_if_dead:
51837 if (op->op.state == FSCACHE_OP_ST_CANCELLED) {
51838 - fscache_stat(stat_object_dead);
51839 + fscache_stat_unchecked(stat_object_dead);
51840 _leave(" = -ENOBUFS [cancelled]");
51841 return -ENOBUFS;
51842 }
51843 if (unlikely(fscache_object_is_dead(object))) {
51844 pr_err("%s() = -ENOBUFS [obj dead %d]\n", __func__, op->op.state);
51845 fscache_cancel_op(&op->op, fscache_do_cancel_retrieval);
51846 - fscache_stat(stat_object_dead);
51847 + fscache_stat_unchecked(stat_object_dead);
51848 return -ENOBUFS;
51849 }
51850 return 0;
51851 @@ -378,7 +378,7 @@ int __fscache_read_or_alloc_page(struct fscache_cookie *cookie,
51852
51853 _enter("%p,%p,,,", cookie, page);
51854
51855 - fscache_stat(&fscache_n_retrievals);
51856 + fscache_stat_unchecked(&fscache_n_retrievals);
51857
51858 if (hlist_empty(&cookie->backing_objects))
51859 goto nobufs;
51860 @@ -417,7 +417,7 @@ int __fscache_read_or_alloc_page(struct fscache_cookie *cookie,
51861 goto nobufs_unlock_dec;
51862 spin_unlock(&cookie->lock);
51863
51864 - fscache_stat(&fscache_n_retrieval_ops);
51865 + fscache_stat_unchecked(&fscache_n_retrieval_ops);
51866
51867 /* pin the netfs read context in case we need to do the actual netfs
51868 * read because we've encountered a cache read failure */
51869 @@ -447,15 +447,15 @@ int __fscache_read_or_alloc_page(struct fscache_cookie *cookie,
51870
51871 error:
51872 if (ret == -ENOMEM)
51873 - fscache_stat(&fscache_n_retrievals_nomem);
51874 + fscache_stat_unchecked(&fscache_n_retrievals_nomem);
51875 else if (ret == -ERESTARTSYS)
51876 - fscache_stat(&fscache_n_retrievals_intr);
51877 + fscache_stat_unchecked(&fscache_n_retrievals_intr);
51878 else if (ret == -ENODATA)
51879 - fscache_stat(&fscache_n_retrievals_nodata);
51880 + fscache_stat_unchecked(&fscache_n_retrievals_nodata);
51881 else if (ret < 0)
51882 - fscache_stat(&fscache_n_retrievals_nobufs);
51883 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
51884 else
51885 - fscache_stat(&fscache_n_retrievals_ok);
51886 + fscache_stat_unchecked(&fscache_n_retrievals_ok);
51887
51888 fscache_put_retrieval(op);
51889 _leave(" = %d", ret);
51890 @@ -467,7 +467,7 @@ nobufs_unlock:
51891 spin_unlock(&cookie->lock);
51892 kfree(op);
51893 nobufs:
51894 - fscache_stat(&fscache_n_retrievals_nobufs);
51895 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
51896 _leave(" = -ENOBUFS");
51897 return -ENOBUFS;
51898 }
51899 @@ -505,7 +505,7 @@ int __fscache_read_or_alloc_pages(struct fscache_cookie *cookie,
51900
51901 _enter("%p,,%d,,,", cookie, *nr_pages);
51902
51903 - fscache_stat(&fscache_n_retrievals);
51904 + fscache_stat_unchecked(&fscache_n_retrievals);
51905
51906 if (hlist_empty(&cookie->backing_objects))
51907 goto nobufs;
51908 @@ -541,7 +541,7 @@ int __fscache_read_or_alloc_pages(struct fscache_cookie *cookie,
51909 goto nobufs_unlock_dec;
51910 spin_unlock(&cookie->lock);
51911
51912 - fscache_stat(&fscache_n_retrieval_ops);
51913 + fscache_stat_unchecked(&fscache_n_retrieval_ops);
51914
51915 /* pin the netfs read context in case we need to do the actual netfs
51916 * read because we've encountered a cache read failure */
51917 @@ -571,15 +571,15 @@ int __fscache_read_or_alloc_pages(struct fscache_cookie *cookie,
51918
51919 error:
51920 if (ret == -ENOMEM)
51921 - fscache_stat(&fscache_n_retrievals_nomem);
51922 + fscache_stat_unchecked(&fscache_n_retrievals_nomem);
51923 else if (ret == -ERESTARTSYS)
51924 - fscache_stat(&fscache_n_retrievals_intr);
51925 + fscache_stat_unchecked(&fscache_n_retrievals_intr);
51926 else if (ret == -ENODATA)
51927 - fscache_stat(&fscache_n_retrievals_nodata);
51928 + fscache_stat_unchecked(&fscache_n_retrievals_nodata);
51929 else if (ret < 0)
51930 - fscache_stat(&fscache_n_retrievals_nobufs);
51931 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
51932 else
51933 - fscache_stat(&fscache_n_retrievals_ok);
51934 + fscache_stat_unchecked(&fscache_n_retrievals_ok);
51935
51936 fscache_put_retrieval(op);
51937 _leave(" = %d", ret);
51938 @@ -591,7 +591,7 @@ nobufs_unlock:
51939 spin_unlock(&cookie->lock);
51940 kfree(op);
51941 nobufs:
51942 - fscache_stat(&fscache_n_retrievals_nobufs);
51943 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
51944 _leave(" = -ENOBUFS");
51945 return -ENOBUFS;
51946 }
51947 @@ -615,7 +615,7 @@ int __fscache_alloc_page(struct fscache_cookie *cookie,
51948
51949 _enter("%p,%p,,,", cookie, page);
51950
51951 - fscache_stat(&fscache_n_allocs);
51952 + fscache_stat_unchecked(&fscache_n_allocs);
51953
51954 if (hlist_empty(&cookie->backing_objects))
51955 goto nobufs;
51956 @@ -647,7 +647,7 @@ int __fscache_alloc_page(struct fscache_cookie *cookie,
51957 goto nobufs_unlock;
51958 spin_unlock(&cookie->lock);
51959
51960 - fscache_stat(&fscache_n_alloc_ops);
51961 + fscache_stat_unchecked(&fscache_n_alloc_ops);
51962
51963 ret = fscache_wait_for_retrieval_activation(
51964 object, op,
51965 @@ -663,11 +663,11 @@ int __fscache_alloc_page(struct fscache_cookie *cookie,
51966
51967 error:
51968 if (ret == -ERESTARTSYS)
51969 - fscache_stat(&fscache_n_allocs_intr);
51970 + fscache_stat_unchecked(&fscache_n_allocs_intr);
51971 else if (ret < 0)
51972 - fscache_stat(&fscache_n_allocs_nobufs);
51973 + fscache_stat_unchecked(&fscache_n_allocs_nobufs);
51974 else
51975 - fscache_stat(&fscache_n_allocs_ok);
51976 + fscache_stat_unchecked(&fscache_n_allocs_ok);
51977
51978 fscache_put_retrieval(op);
51979 _leave(" = %d", ret);
51980 @@ -677,7 +677,7 @@ nobufs_unlock:
51981 spin_unlock(&cookie->lock);
51982 kfree(op);
51983 nobufs:
51984 - fscache_stat(&fscache_n_allocs_nobufs);
51985 + fscache_stat_unchecked(&fscache_n_allocs_nobufs);
51986 _leave(" = -ENOBUFS");
51987 return -ENOBUFS;
51988 }
51989 @@ -736,7 +736,7 @@ static void fscache_write_op(struct fscache_operation *_op)
51990
51991 spin_lock(&cookie->stores_lock);
51992
51993 - fscache_stat(&fscache_n_store_calls);
51994 + fscache_stat_unchecked(&fscache_n_store_calls);
51995
51996 /* find a page to store */
51997 page = NULL;
51998 @@ -747,7 +747,7 @@ static void fscache_write_op(struct fscache_operation *_op)
51999 page = results[0];
52000 _debug("gang %d [%lx]", n, page->index);
52001 if (page->index > op->store_limit) {
52002 - fscache_stat(&fscache_n_store_pages_over_limit);
52003 + fscache_stat_unchecked(&fscache_n_store_pages_over_limit);
52004 goto superseded;
52005 }
52006
52007 @@ -759,7 +759,7 @@ static void fscache_write_op(struct fscache_operation *_op)
52008 spin_unlock(&cookie->stores_lock);
52009 spin_unlock(&object->lock);
52010
52011 - fscache_stat(&fscache_n_store_pages);
52012 + fscache_stat_unchecked(&fscache_n_store_pages);
52013 fscache_stat(&fscache_n_cop_write_page);
52014 ret = object->cache->ops->write_page(op, page);
52015 fscache_stat_d(&fscache_n_cop_write_page);
52016 @@ -860,7 +860,7 @@ int __fscache_write_page(struct fscache_cookie *cookie,
52017 ASSERTCMP(cookie->def->type, !=, FSCACHE_COOKIE_TYPE_INDEX);
52018 ASSERT(PageFsCache(page));
52019
52020 - fscache_stat(&fscache_n_stores);
52021 + fscache_stat_unchecked(&fscache_n_stores);
52022
52023 if (test_bit(FSCACHE_COOKIE_INVALIDATING, &cookie->flags)) {
52024 _leave(" = -ENOBUFS [invalidating]");
52025 @@ -916,7 +916,7 @@ int __fscache_write_page(struct fscache_cookie *cookie,
52026 spin_unlock(&cookie->stores_lock);
52027 spin_unlock(&object->lock);
52028
52029 - op->op.debug_id = atomic_inc_return(&fscache_op_debug_id);
52030 + op->op.debug_id = atomic_inc_return_unchecked(&fscache_op_debug_id);
52031 op->store_limit = object->store_limit;
52032
52033 if (fscache_submit_op(object, &op->op) < 0)
52034 @@ -924,8 +924,8 @@ int __fscache_write_page(struct fscache_cookie *cookie,
52035
52036 spin_unlock(&cookie->lock);
52037 radix_tree_preload_end();
52038 - fscache_stat(&fscache_n_store_ops);
52039 - fscache_stat(&fscache_n_stores_ok);
52040 + fscache_stat_unchecked(&fscache_n_store_ops);
52041 + fscache_stat_unchecked(&fscache_n_stores_ok);
52042
52043 /* the work queue now carries its own ref on the object */
52044 fscache_put_operation(&op->op);
52045 @@ -933,14 +933,14 @@ int __fscache_write_page(struct fscache_cookie *cookie,
52046 return 0;
52047
52048 already_queued:
52049 - fscache_stat(&fscache_n_stores_again);
52050 + fscache_stat_unchecked(&fscache_n_stores_again);
52051 already_pending:
52052 spin_unlock(&cookie->stores_lock);
52053 spin_unlock(&object->lock);
52054 spin_unlock(&cookie->lock);
52055 radix_tree_preload_end();
52056 kfree(op);
52057 - fscache_stat(&fscache_n_stores_ok);
52058 + fscache_stat_unchecked(&fscache_n_stores_ok);
52059 _leave(" = 0");
52060 return 0;
52061
52062 @@ -959,14 +959,14 @@ nobufs:
52063 spin_unlock(&cookie->lock);
52064 radix_tree_preload_end();
52065 kfree(op);
52066 - fscache_stat(&fscache_n_stores_nobufs);
52067 + fscache_stat_unchecked(&fscache_n_stores_nobufs);
52068 _leave(" = -ENOBUFS");
52069 return -ENOBUFS;
52070
52071 nomem_free:
52072 kfree(op);
52073 nomem:
52074 - fscache_stat(&fscache_n_stores_oom);
52075 + fscache_stat_unchecked(&fscache_n_stores_oom);
52076 _leave(" = -ENOMEM");
52077 return -ENOMEM;
52078 }
52079 @@ -984,7 +984,7 @@ void __fscache_uncache_page(struct fscache_cookie *cookie, struct page *page)
52080 ASSERTCMP(cookie->def->type, !=, FSCACHE_COOKIE_TYPE_INDEX);
52081 ASSERTCMP(page, !=, NULL);
52082
52083 - fscache_stat(&fscache_n_uncaches);
52084 + fscache_stat_unchecked(&fscache_n_uncaches);
52085
52086 /* cache withdrawal may beat us to it */
52087 if (!PageFsCache(page))
52088 @@ -1035,7 +1035,7 @@ void fscache_mark_page_cached(struct fscache_retrieval *op, struct page *page)
52089 struct fscache_cookie *cookie = op->op.object->cookie;
52090
52091 #ifdef CONFIG_FSCACHE_STATS
52092 - atomic_inc(&fscache_n_marks);
52093 + atomic_inc_unchecked(&fscache_n_marks);
52094 #endif
52095
52096 _debug("- mark %p{%lx}", page, page->index);
52097 diff --git a/fs/fscache/stats.c b/fs/fscache/stats.c
52098 index 8179e8b..5072cc7 100644
52099 --- a/fs/fscache/stats.c
52100 +++ b/fs/fscache/stats.c
52101 @@ -18,99 +18,99 @@
52102 /*
52103 * operation counters
52104 */
52105 -atomic_t fscache_n_op_pend;
52106 -atomic_t fscache_n_op_run;
52107 -atomic_t fscache_n_op_enqueue;
52108 -atomic_t fscache_n_op_requeue;
52109 -atomic_t fscache_n_op_deferred_release;
52110 -atomic_t fscache_n_op_release;
52111 -atomic_t fscache_n_op_gc;
52112 -atomic_t fscache_n_op_cancelled;
52113 -atomic_t fscache_n_op_rejected;
52114 +atomic_unchecked_t fscache_n_op_pend;
52115 +atomic_unchecked_t fscache_n_op_run;
52116 +atomic_unchecked_t fscache_n_op_enqueue;
52117 +atomic_unchecked_t fscache_n_op_requeue;
52118 +atomic_unchecked_t fscache_n_op_deferred_release;
52119 +atomic_unchecked_t fscache_n_op_release;
52120 +atomic_unchecked_t fscache_n_op_gc;
52121 +atomic_unchecked_t fscache_n_op_cancelled;
52122 +atomic_unchecked_t fscache_n_op_rejected;
52123
52124 -atomic_t fscache_n_attr_changed;
52125 -atomic_t fscache_n_attr_changed_ok;
52126 -atomic_t fscache_n_attr_changed_nobufs;
52127 -atomic_t fscache_n_attr_changed_nomem;
52128 -atomic_t fscache_n_attr_changed_calls;
52129 +atomic_unchecked_t fscache_n_attr_changed;
52130 +atomic_unchecked_t fscache_n_attr_changed_ok;
52131 +atomic_unchecked_t fscache_n_attr_changed_nobufs;
52132 +atomic_unchecked_t fscache_n_attr_changed_nomem;
52133 +atomic_unchecked_t fscache_n_attr_changed_calls;
52134
52135 -atomic_t fscache_n_allocs;
52136 -atomic_t fscache_n_allocs_ok;
52137 -atomic_t fscache_n_allocs_wait;
52138 -atomic_t fscache_n_allocs_nobufs;
52139 -atomic_t fscache_n_allocs_intr;
52140 -atomic_t fscache_n_allocs_object_dead;
52141 -atomic_t fscache_n_alloc_ops;
52142 -atomic_t fscache_n_alloc_op_waits;
52143 +atomic_unchecked_t fscache_n_allocs;
52144 +atomic_unchecked_t fscache_n_allocs_ok;
52145 +atomic_unchecked_t fscache_n_allocs_wait;
52146 +atomic_unchecked_t fscache_n_allocs_nobufs;
52147 +atomic_unchecked_t fscache_n_allocs_intr;
52148 +atomic_unchecked_t fscache_n_allocs_object_dead;
52149 +atomic_unchecked_t fscache_n_alloc_ops;
52150 +atomic_unchecked_t fscache_n_alloc_op_waits;
52151
52152 -atomic_t fscache_n_retrievals;
52153 -atomic_t fscache_n_retrievals_ok;
52154 -atomic_t fscache_n_retrievals_wait;
52155 -atomic_t fscache_n_retrievals_nodata;
52156 -atomic_t fscache_n_retrievals_nobufs;
52157 -atomic_t fscache_n_retrievals_intr;
52158 -atomic_t fscache_n_retrievals_nomem;
52159 -atomic_t fscache_n_retrievals_object_dead;
52160 -atomic_t fscache_n_retrieval_ops;
52161 -atomic_t fscache_n_retrieval_op_waits;
52162 +atomic_unchecked_t fscache_n_retrievals;
52163 +atomic_unchecked_t fscache_n_retrievals_ok;
52164 +atomic_unchecked_t fscache_n_retrievals_wait;
52165 +atomic_unchecked_t fscache_n_retrievals_nodata;
52166 +atomic_unchecked_t fscache_n_retrievals_nobufs;
52167 +atomic_unchecked_t fscache_n_retrievals_intr;
52168 +atomic_unchecked_t fscache_n_retrievals_nomem;
52169 +atomic_unchecked_t fscache_n_retrievals_object_dead;
52170 +atomic_unchecked_t fscache_n_retrieval_ops;
52171 +atomic_unchecked_t fscache_n_retrieval_op_waits;
52172
52173 -atomic_t fscache_n_stores;
52174 -atomic_t fscache_n_stores_ok;
52175 -atomic_t fscache_n_stores_again;
52176 -atomic_t fscache_n_stores_nobufs;
52177 -atomic_t fscache_n_stores_oom;
52178 -atomic_t fscache_n_store_ops;
52179 -atomic_t fscache_n_store_calls;
52180 -atomic_t fscache_n_store_pages;
52181 -atomic_t fscache_n_store_radix_deletes;
52182 -atomic_t fscache_n_store_pages_over_limit;
52183 +atomic_unchecked_t fscache_n_stores;
52184 +atomic_unchecked_t fscache_n_stores_ok;
52185 +atomic_unchecked_t fscache_n_stores_again;
52186 +atomic_unchecked_t fscache_n_stores_nobufs;
52187 +atomic_unchecked_t fscache_n_stores_oom;
52188 +atomic_unchecked_t fscache_n_store_ops;
52189 +atomic_unchecked_t fscache_n_store_calls;
52190 +atomic_unchecked_t fscache_n_store_pages;
52191 +atomic_unchecked_t fscache_n_store_radix_deletes;
52192 +atomic_unchecked_t fscache_n_store_pages_over_limit;
52193
52194 -atomic_t fscache_n_store_vmscan_not_storing;
52195 -atomic_t fscache_n_store_vmscan_gone;
52196 -atomic_t fscache_n_store_vmscan_busy;
52197 -atomic_t fscache_n_store_vmscan_cancelled;
52198 -atomic_t fscache_n_store_vmscan_wait;
52199 +atomic_unchecked_t fscache_n_store_vmscan_not_storing;
52200 +atomic_unchecked_t fscache_n_store_vmscan_gone;
52201 +atomic_unchecked_t fscache_n_store_vmscan_busy;
52202 +atomic_unchecked_t fscache_n_store_vmscan_cancelled;
52203 +atomic_unchecked_t fscache_n_store_vmscan_wait;
52204
52205 -atomic_t fscache_n_marks;
52206 -atomic_t fscache_n_uncaches;
52207 +atomic_unchecked_t fscache_n_marks;
52208 +atomic_unchecked_t fscache_n_uncaches;
52209
52210 -atomic_t fscache_n_acquires;
52211 -atomic_t fscache_n_acquires_null;
52212 -atomic_t fscache_n_acquires_no_cache;
52213 -atomic_t fscache_n_acquires_ok;
52214 -atomic_t fscache_n_acquires_nobufs;
52215 -atomic_t fscache_n_acquires_oom;
52216 +atomic_unchecked_t fscache_n_acquires;
52217 +atomic_unchecked_t fscache_n_acquires_null;
52218 +atomic_unchecked_t fscache_n_acquires_no_cache;
52219 +atomic_unchecked_t fscache_n_acquires_ok;
52220 +atomic_unchecked_t fscache_n_acquires_nobufs;
52221 +atomic_unchecked_t fscache_n_acquires_oom;
52222
52223 -atomic_t fscache_n_invalidates;
52224 -atomic_t fscache_n_invalidates_run;
52225 +atomic_unchecked_t fscache_n_invalidates;
52226 +atomic_unchecked_t fscache_n_invalidates_run;
52227
52228 -atomic_t fscache_n_updates;
52229 -atomic_t fscache_n_updates_null;
52230 -atomic_t fscache_n_updates_run;
52231 +atomic_unchecked_t fscache_n_updates;
52232 +atomic_unchecked_t fscache_n_updates_null;
52233 +atomic_unchecked_t fscache_n_updates_run;
52234
52235 -atomic_t fscache_n_relinquishes;
52236 -atomic_t fscache_n_relinquishes_null;
52237 -atomic_t fscache_n_relinquishes_waitcrt;
52238 -atomic_t fscache_n_relinquishes_retire;
52239 +atomic_unchecked_t fscache_n_relinquishes;
52240 +atomic_unchecked_t fscache_n_relinquishes_null;
52241 +atomic_unchecked_t fscache_n_relinquishes_waitcrt;
52242 +atomic_unchecked_t fscache_n_relinquishes_retire;
52243
52244 -atomic_t fscache_n_cookie_index;
52245 -atomic_t fscache_n_cookie_data;
52246 -atomic_t fscache_n_cookie_special;
52247 +atomic_unchecked_t fscache_n_cookie_index;
52248 +atomic_unchecked_t fscache_n_cookie_data;
52249 +atomic_unchecked_t fscache_n_cookie_special;
52250
52251 -atomic_t fscache_n_object_alloc;
52252 -atomic_t fscache_n_object_no_alloc;
52253 -atomic_t fscache_n_object_lookups;
52254 -atomic_t fscache_n_object_lookups_negative;
52255 -atomic_t fscache_n_object_lookups_positive;
52256 -atomic_t fscache_n_object_lookups_timed_out;
52257 -atomic_t fscache_n_object_created;
52258 -atomic_t fscache_n_object_avail;
52259 -atomic_t fscache_n_object_dead;
52260 +atomic_unchecked_t fscache_n_object_alloc;
52261 +atomic_unchecked_t fscache_n_object_no_alloc;
52262 +atomic_unchecked_t fscache_n_object_lookups;
52263 +atomic_unchecked_t fscache_n_object_lookups_negative;
52264 +atomic_unchecked_t fscache_n_object_lookups_positive;
52265 +atomic_unchecked_t fscache_n_object_lookups_timed_out;
52266 +atomic_unchecked_t fscache_n_object_created;
52267 +atomic_unchecked_t fscache_n_object_avail;
52268 +atomic_unchecked_t fscache_n_object_dead;
52269
52270 -atomic_t fscache_n_checkaux_none;
52271 -atomic_t fscache_n_checkaux_okay;
52272 -atomic_t fscache_n_checkaux_update;
52273 -atomic_t fscache_n_checkaux_obsolete;
52274 +atomic_unchecked_t fscache_n_checkaux_none;
52275 +atomic_unchecked_t fscache_n_checkaux_okay;
52276 +atomic_unchecked_t fscache_n_checkaux_update;
52277 +atomic_unchecked_t fscache_n_checkaux_obsolete;
52278
52279 atomic_t fscache_n_cop_alloc_object;
52280 atomic_t fscache_n_cop_lookup_object;
52281 @@ -138,118 +138,118 @@ static int fscache_stats_show(struct seq_file *m, void *v)
52282 seq_puts(m, "FS-Cache statistics\n");
52283
52284 seq_printf(m, "Cookies: idx=%u dat=%u spc=%u\n",
52285 - atomic_read(&fscache_n_cookie_index),
52286 - atomic_read(&fscache_n_cookie_data),
52287 - atomic_read(&fscache_n_cookie_special));
52288 + atomic_read_unchecked(&fscache_n_cookie_index),
52289 + atomic_read_unchecked(&fscache_n_cookie_data),
52290 + atomic_read_unchecked(&fscache_n_cookie_special));
52291
52292 seq_printf(m, "Objects: alc=%u nal=%u avl=%u ded=%u\n",
52293 - atomic_read(&fscache_n_object_alloc),
52294 - atomic_read(&fscache_n_object_no_alloc),
52295 - atomic_read(&fscache_n_object_avail),
52296 - atomic_read(&fscache_n_object_dead));
52297 + atomic_read_unchecked(&fscache_n_object_alloc),
52298 + atomic_read_unchecked(&fscache_n_object_no_alloc),
52299 + atomic_read_unchecked(&fscache_n_object_avail),
52300 + atomic_read_unchecked(&fscache_n_object_dead));
52301 seq_printf(m, "ChkAux : non=%u ok=%u upd=%u obs=%u\n",
52302 - atomic_read(&fscache_n_checkaux_none),
52303 - atomic_read(&fscache_n_checkaux_okay),
52304 - atomic_read(&fscache_n_checkaux_update),
52305 - atomic_read(&fscache_n_checkaux_obsolete));
52306 + atomic_read_unchecked(&fscache_n_checkaux_none),
52307 + atomic_read_unchecked(&fscache_n_checkaux_okay),
52308 + atomic_read_unchecked(&fscache_n_checkaux_update),
52309 + atomic_read_unchecked(&fscache_n_checkaux_obsolete));
52310
52311 seq_printf(m, "Pages : mrk=%u unc=%u\n",
52312 - atomic_read(&fscache_n_marks),
52313 - atomic_read(&fscache_n_uncaches));
52314 + atomic_read_unchecked(&fscache_n_marks),
52315 + atomic_read_unchecked(&fscache_n_uncaches));
52316
52317 seq_printf(m, "Acquire: n=%u nul=%u noc=%u ok=%u nbf=%u"
52318 " oom=%u\n",
52319 - atomic_read(&fscache_n_acquires),
52320 - atomic_read(&fscache_n_acquires_null),
52321 - atomic_read(&fscache_n_acquires_no_cache),
52322 - atomic_read(&fscache_n_acquires_ok),
52323 - atomic_read(&fscache_n_acquires_nobufs),
52324 - atomic_read(&fscache_n_acquires_oom));
52325 + atomic_read_unchecked(&fscache_n_acquires),
52326 + atomic_read_unchecked(&fscache_n_acquires_null),
52327 + atomic_read_unchecked(&fscache_n_acquires_no_cache),
52328 + atomic_read_unchecked(&fscache_n_acquires_ok),
52329 + atomic_read_unchecked(&fscache_n_acquires_nobufs),
52330 + atomic_read_unchecked(&fscache_n_acquires_oom));
52331
52332 seq_printf(m, "Lookups: n=%u neg=%u pos=%u crt=%u tmo=%u\n",
52333 - atomic_read(&fscache_n_object_lookups),
52334 - atomic_read(&fscache_n_object_lookups_negative),
52335 - atomic_read(&fscache_n_object_lookups_positive),
52336 - atomic_read(&fscache_n_object_created),
52337 - atomic_read(&fscache_n_object_lookups_timed_out));
52338 + atomic_read_unchecked(&fscache_n_object_lookups),
52339 + atomic_read_unchecked(&fscache_n_object_lookups_negative),
52340 + atomic_read_unchecked(&fscache_n_object_lookups_positive),
52341 + atomic_read_unchecked(&fscache_n_object_created),
52342 + atomic_read_unchecked(&fscache_n_object_lookups_timed_out));
52343
52344 seq_printf(m, "Invals : n=%u run=%u\n",
52345 - atomic_read(&fscache_n_invalidates),
52346 - atomic_read(&fscache_n_invalidates_run));
52347 + atomic_read_unchecked(&fscache_n_invalidates),
52348 + atomic_read_unchecked(&fscache_n_invalidates_run));
52349
52350 seq_printf(m, "Updates: n=%u nul=%u run=%u\n",
52351 - atomic_read(&fscache_n_updates),
52352 - atomic_read(&fscache_n_updates_null),
52353 - atomic_read(&fscache_n_updates_run));
52354 + atomic_read_unchecked(&fscache_n_updates),
52355 + atomic_read_unchecked(&fscache_n_updates_null),
52356 + atomic_read_unchecked(&fscache_n_updates_run));
52357
52358 seq_printf(m, "Relinqs: n=%u nul=%u wcr=%u rtr=%u\n",
52359 - atomic_read(&fscache_n_relinquishes),
52360 - atomic_read(&fscache_n_relinquishes_null),
52361 - atomic_read(&fscache_n_relinquishes_waitcrt),
52362 - atomic_read(&fscache_n_relinquishes_retire));
52363 + atomic_read_unchecked(&fscache_n_relinquishes),
52364 + atomic_read_unchecked(&fscache_n_relinquishes_null),
52365 + atomic_read_unchecked(&fscache_n_relinquishes_waitcrt),
52366 + atomic_read_unchecked(&fscache_n_relinquishes_retire));
52367
52368 seq_printf(m, "AttrChg: n=%u ok=%u nbf=%u oom=%u run=%u\n",
52369 - atomic_read(&fscache_n_attr_changed),
52370 - atomic_read(&fscache_n_attr_changed_ok),
52371 - atomic_read(&fscache_n_attr_changed_nobufs),
52372 - atomic_read(&fscache_n_attr_changed_nomem),
52373 - atomic_read(&fscache_n_attr_changed_calls));
52374 + atomic_read_unchecked(&fscache_n_attr_changed),
52375 + atomic_read_unchecked(&fscache_n_attr_changed_ok),
52376 + atomic_read_unchecked(&fscache_n_attr_changed_nobufs),
52377 + atomic_read_unchecked(&fscache_n_attr_changed_nomem),
52378 + atomic_read_unchecked(&fscache_n_attr_changed_calls));
52379
52380 seq_printf(m, "Allocs : n=%u ok=%u wt=%u nbf=%u int=%u\n",
52381 - atomic_read(&fscache_n_allocs),
52382 - atomic_read(&fscache_n_allocs_ok),
52383 - atomic_read(&fscache_n_allocs_wait),
52384 - atomic_read(&fscache_n_allocs_nobufs),
52385 - atomic_read(&fscache_n_allocs_intr));
52386 + atomic_read_unchecked(&fscache_n_allocs),
52387 + atomic_read_unchecked(&fscache_n_allocs_ok),
52388 + atomic_read_unchecked(&fscache_n_allocs_wait),
52389 + atomic_read_unchecked(&fscache_n_allocs_nobufs),
52390 + atomic_read_unchecked(&fscache_n_allocs_intr));
52391 seq_printf(m, "Allocs : ops=%u owt=%u abt=%u\n",
52392 - atomic_read(&fscache_n_alloc_ops),
52393 - atomic_read(&fscache_n_alloc_op_waits),
52394 - atomic_read(&fscache_n_allocs_object_dead));
52395 + atomic_read_unchecked(&fscache_n_alloc_ops),
52396 + atomic_read_unchecked(&fscache_n_alloc_op_waits),
52397 + atomic_read_unchecked(&fscache_n_allocs_object_dead));
52398
52399 seq_printf(m, "Retrvls: n=%u ok=%u wt=%u nod=%u nbf=%u"
52400 " int=%u oom=%u\n",
52401 - atomic_read(&fscache_n_retrievals),
52402 - atomic_read(&fscache_n_retrievals_ok),
52403 - atomic_read(&fscache_n_retrievals_wait),
52404 - atomic_read(&fscache_n_retrievals_nodata),
52405 - atomic_read(&fscache_n_retrievals_nobufs),
52406 - atomic_read(&fscache_n_retrievals_intr),
52407 - atomic_read(&fscache_n_retrievals_nomem));
52408 + atomic_read_unchecked(&fscache_n_retrievals),
52409 + atomic_read_unchecked(&fscache_n_retrievals_ok),
52410 + atomic_read_unchecked(&fscache_n_retrievals_wait),
52411 + atomic_read_unchecked(&fscache_n_retrievals_nodata),
52412 + atomic_read_unchecked(&fscache_n_retrievals_nobufs),
52413 + atomic_read_unchecked(&fscache_n_retrievals_intr),
52414 + atomic_read_unchecked(&fscache_n_retrievals_nomem));
52415 seq_printf(m, "Retrvls: ops=%u owt=%u abt=%u\n",
52416 - atomic_read(&fscache_n_retrieval_ops),
52417 - atomic_read(&fscache_n_retrieval_op_waits),
52418 - atomic_read(&fscache_n_retrievals_object_dead));
52419 + atomic_read_unchecked(&fscache_n_retrieval_ops),
52420 + atomic_read_unchecked(&fscache_n_retrieval_op_waits),
52421 + atomic_read_unchecked(&fscache_n_retrievals_object_dead));
52422
52423 seq_printf(m, "Stores : n=%u ok=%u agn=%u nbf=%u oom=%u\n",
52424 - atomic_read(&fscache_n_stores),
52425 - atomic_read(&fscache_n_stores_ok),
52426 - atomic_read(&fscache_n_stores_again),
52427 - atomic_read(&fscache_n_stores_nobufs),
52428 - atomic_read(&fscache_n_stores_oom));
52429 + atomic_read_unchecked(&fscache_n_stores),
52430 + atomic_read_unchecked(&fscache_n_stores_ok),
52431 + atomic_read_unchecked(&fscache_n_stores_again),
52432 + atomic_read_unchecked(&fscache_n_stores_nobufs),
52433 + atomic_read_unchecked(&fscache_n_stores_oom));
52434 seq_printf(m, "Stores : ops=%u run=%u pgs=%u rxd=%u olm=%u\n",
52435 - atomic_read(&fscache_n_store_ops),
52436 - atomic_read(&fscache_n_store_calls),
52437 - atomic_read(&fscache_n_store_pages),
52438 - atomic_read(&fscache_n_store_radix_deletes),
52439 - atomic_read(&fscache_n_store_pages_over_limit));
52440 + atomic_read_unchecked(&fscache_n_store_ops),
52441 + atomic_read_unchecked(&fscache_n_store_calls),
52442 + atomic_read_unchecked(&fscache_n_store_pages),
52443 + atomic_read_unchecked(&fscache_n_store_radix_deletes),
52444 + atomic_read_unchecked(&fscache_n_store_pages_over_limit));
52445
52446 seq_printf(m, "VmScan : nos=%u gon=%u bsy=%u can=%u wt=%u\n",
52447 - atomic_read(&fscache_n_store_vmscan_not_storing),
52448 - atomic_read(&fscache_n_store_vmscan_gone),
52449 - atomic_read(&fscache_n_store_vmscan_busy),
52450 - atomic_read(&fscache_n_store_vmscan_cancelled),
52451 - atomic_read(&fscache_n_store_vmscan_wait));
52452 + atomic_read_unchecked(&fscache_n_store_vmscan_not_storing),
52453 + atomic_read_unchecked(&fscache_n_store_vmscan_gone),
52454 + atomic_read_unchecked(&fscache_n_store_vmscan_busy),
52455 + atomic_read_unchecked(&fscache_n_store_vmscan_cancelled),
52456 + atomic_read_unchecked(&fscache_n_store_vmscan_wait));
52457
52458 seq_printf(m, "Ops : pend=%u run=%u enq=%u can=%u rej=%u\n",
52459 - atomic_read(&fscache_n_op_pend),
52460 - atomic_read(&fscache_n_op_run),
52461 - atomic_read(&fscache_n_op_enqueue),
52462 - atomic_read(&fscache_n_op_cancelled),
52463 - atomic_read(&fscache_n_op_rejected));
52464 + atomic_read_unchecked(&fscache_n_op_pend),
52465 + atomic_read_unchecked(&fscache_n_op_run),
52466 + atomic_read_unchecked(&fscache_n_op_enqueue),
52467 + atomic_read_unchecked(&fscache_n_op_cancelled),
52468 + atomic_read_unchecked(&fscache_n_op_rejected));
52469 seq_printf(m, "Ops : dfr=%u rel=%u gc=%u\n",
52470 - atomic_read(&fscache_n_op_deferred_release),
52471 - atomic_read(&fscache_n_op_release),
52472 - atomic_read(&fscache_n_op_gc));
52473 + atomic_read_unchecked(&fscache_n_op_deferred_release),
52474 + atomic_read_unchecked(&fscache_n_op_release),
52475 + atomic_read_unchecked(&fscache_n_op_gc));
52476
52477 seq_printf(m, "CacheOp: alo=%d luo=%d luc=%d gro=%d\n",
52478 atomic_read(&fscache_n_cop_alloc_object),
52479 diff --git a/fs/fuse/cuse.c b/fs/fuse/cuse.c
52480 index e397b67..b0d8709 100644
52481 --- a/fs/fuse/cuse.c
52482 +++ b/fs/fuse/cuse.c
52483 @@ -593,10 +593,12 @@ static int __init cuse_init(void)
52484 INIT_LIST_HEAD(&cuse_conntbl[i]);
52485
52486 /* inherit and extend fuse_dev_operations */
52487 - cuse_channel_fops = fuse_dev_operations;
52488 - cuse_channel_fops.owner = THIS_MODULE;
52489 - cuse_channel_fops.open = cuse_channel_open;
52490 - cuse_channel_fops.release = cuse_channel_release;
52491 + pax_open_kernel();
52492 + memcpy((void *)&cuse_channel_fops, &fuse_dev_operations, sizeof(fuse_dev_operations));
52493 + *(void **)&cuse_channel_fops.owner = THIS_MODULE;
52494 + *(void **)&cuse_channel_fops.open = cuse_channel_open;
52495 + *(void **)&cuse_channel_fops.release = cuse_channel_release;
52496 + pax_close_kernel();
52497
52498 cuse_class = class_create(THIS_MODULE, "cuse");
52499 if (IS_ERR(cuse_class))
52500 diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c
52501 index e83351a..41e3c9c 100644
52502 --- a/fs/fuse/dev.c
52503 +++ b/fs/fuse/dev.c
52504 @@ -1236,7 +1236,7 @@ static ssize_t fuse_dev_splice_read(struct file *in, loff_t *ppos,
52505 ret = 0;
52506 pipe_lock(pipe);
52507
52508 - if (!pipe->readers) {
52509 + if (!atomic_read(&pipe->readers)) {
52510 send_sig(SIGPIPE, current, 0);
52511 if (!ret)
52512 ret = -EPIPE;
52513 diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c
52514 index 315e1f8..91f890c 100644
52515 --- a/fs/fuse/dir.c
52516 +++ b/fs/fuse/dir.c
52517 @@ -1233,7 +1233,7 @@ static char *read_link(struct dentry *dentry)
52518 return link;
52519 }
52520
52521 -static void free_link(char *link)
52522 +static void free_link(const char *link)
52523 {
52524 if (!IS_ERR(link))
52525 free_page((unsigned long) link);
52526 diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c
52527 index 2b6f569..fcb4d1f 100644
52528 --- a/fs/gfs2/inode.c
52529 +++ b/fs/gfs2/inode.c
52530 @@ -1499,7 +1499,7 @@ out:
52531
52532 static void gfs2_put_link(struct dentry *dentry, struct nameidata *nd, void *p)
52533 {
52534 - char *s = nd_get_link(nd);
52535 + const char *s = nd_get_link(nd);
52536 if (!IS_ERR(s))
52537 kfree(s);
52538 }
52539 diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
52540 index 78bde32..767e906 100644
52541 --- a/fs/hugetlbfs/inode.c
52542 +++ b/fs/hugetlbfs/inode.c
52543 @@ -152,6 +152,7 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
52544 struct mm_struct *mm = current->mm;
52545 struct vm_area_struct *vma;
52546 struct hstate *h = hstate_file(file);
52547 + unsigned long offset = gr_rand_threadstack_offset(mm, file, flags);
52548 struct vm_unmapped_area_info info;
52549
52550 if (len & ~huge_page_mask(h))
52551 @@ -165,17 +166,26 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
52552 return addr;
52553 }
52554
52555 +#ifdef CONFIG_PAX_RANDMMAP
52556 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
52557 +#endif
52558 +
52559 if (addr) {
52560 addr = ALIGN(addr, huge_page_size(h));
52561 vma = find_vma(mm, addr);
52562 - if (TASK_SIZE - len >= addr &&
52563 - (!vma || addr + len <= vma->vm_start))
52564 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
52565 return addr;
52566 }
52567
52568 info.flags = 0;
52569 info.length = len;
52570 info.low_limit = TASK_UNMAPPED_BASE;
52571 +
52572 +#ifdef CONFIG_PAX_RANDMMAP
52573 + if (mm->pax_flags & MF_PAX_RANDMMAP)
52574 + info.low_limit += mm->delta_mmap;
52575 +#endif
52576 +
52577 info.high_limit = TASK_SIZE;
52578 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
52579 info.align_offset = 0;
52580 @@ -897,7 +907,7 @@ static struct file_system_type hugetlbfs_fs_type = {
52581 .kill_sb = kill_litter_super,
52582 };
52583
52584 -static struct vfsmount *hugetlbfs_vfsmount[HUGE_MAX_HSTATE];
52585 +struct vfsmount *hugetlbfs_vfsmount[HUGE_MAX_HSTATE];
52586
52587 static int can_do_hugetlb_shm(void)
52588 {
52589 diff --git a/fs/inode.c b/fs/inode.c
52590 index 14084b7..29af1d9 100644
52591 --- a/fs/inode.c
52592 +++ b/fs/inode.c
52593 @@ -880,8 +880,8 @@ unsigned int get_next_ino(void)
52594
52595 #ifdef CONFIG_SMP
52596 if (unlikely((res & (LAST_INO_BATCH-1)) == 0)) {
52597 - static atomic_t shared_last_ino;
52598 - int next = atomic_add_return(LAST_INO_BATCH, &shared_last_ino);
52599 + static atomic_unchecked_t shared_last_ino;
52600 + int next = atomic_add_return_unchecked(LAST_INO_BATCH, &shared_last_ino);
52601
52602 res = next - LAST_INO_BATCH;
52603 }
52604 diff --git a/fs/jffs2/erase.c b/fs/jffs2/erase.c
52605 index 4a6cf28..d3a29d3 100644
52606 --- a/fs/jffs2/erase.c
52607 +++ b/fs/jffs2/erase.c
52608 @@ -452,7 +452,8 @@ static void jffs2_mark_erased_block(struct jffs2_sb_info *c, struct jffs2_eraseb
52609 struct jffs2_unknown_node marker = {
52610 .magic = cpu_to_je16(JFFS2_MAGIC_BITMASK),
52611 .nodetype = cpu_to_je16(JFFS2_NODETYPE_CLEANMARKER),
52612 - .totlen = cpu_to_je32(c->cleanmarker_size)
52613 + .totlen = cpu_to_je32(c->cleanmarker_size),
52614 + .hdr_crc = cpu_to_je32(0)
52615 };
52616
52617 jffs2_prealloc_raw_node_refs(c, jeb, 1);
52618 diff --git a/fs/jffs2/wbuf.c b/fs/jffs2/wbuf.c
52619 index a6597d6..41b30ec 100644
52620 --- a/fs/jffs2/wbuf.c
52621 +++ b/fs/jffs2/wbuf.c
52622 @@ -1023,7 +1023,8 @@ static const struct jffs2_unknown_node oob_cleanmarker =
52623 {
52624 .magic = constant_cpu_to_je16(JFFS2_MAGIC_BITMASK),
52625 .nodetype = constant_cpu_to_je16(JFFS2_NODETYPE_CLEANMARKER),
52626 - .totlen = constant_cpu_to_je32(8)
52627 + .totlen = constant_cpu_to_je32(8),
52628 + .hdr_crc = constant_cpu_to_je32(0)
52629 };
52630
52631 /*
52632 diff --git a/fs/jfs/super.c b/fs/jfs/super.c
52633 index 1a543be..a4e1363 100644
52634 --- a/fs/jfs/super.c
52635 +++ b/fs/jfs/super.c
52636 @@ -225,7 +225,7 @@ static const match_table_t tokens = {
52637 static int parse_options(char *options, struct super_block *sb, s64 *newLVSize,
52638 int *flag)
52639 {
52640 - void *nls_map = (void *)-1; /* -1: no change; NULL: none */
52641 + const void *nls_map = (const void *)-1; /* -1: no change; NULL: none */
52642 char *p;
52643 struct jfs_sb_info *sbi = JFS_SBI(sb);
52644
52645 @@ -253,7 +253,7 @@ static int parse_options(char *options, struct super_block *sb, s64 *newLVSize,
52646 /* Don't do anything ;-) */
52647 break;
52648 case Opt_iocharset:
52649 - if (nls_map && nls_map != (void *) -1)
52650 + if (nls_map && nls_map != (const void *) -1)
52651 unload_nls(nls_map);
52652 if (!strcmp(args[0].from, "none"))
52653 nls_map = NULL;
52654 @@ -855,7 +855,7 @@ static int __init init_jfs_fs(void)
52655
52656 jfs_inode_cachep =
52657 kmem_cache_create("jfs_ip", sizeof(struct jfs_inode_info), 0,
52658 - SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD,
52659 + SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD|SLAB_USERCOPY,
52660 init_once);
52661 if (jfs_inode_cachep == NULL)
52662 return -ENOMEM;
52663 diff --git a/fs/libfs.c b/fs/libfs.c
52664 index 916da8c..1588998 100644
52665 --- a/fs/libfs.c
52666 +++ b/fs/libfs.c
52667 @@ -165,6 +165,9 @@ int dcache_readdir(struct file * filp, void * dirent, filldir_t filldir)
52668
52669 for (p=q->next; p != &dentry->d_subdirs; p=p->next) {
52670 struct dentry *next;
52671 + char d_name[sizeof(next->d_iname)];
52672 + const unsigned char *name;
52673 +
52674 next = list_entry(p, struct dentry, d_u.d_child);
52675 spin_lock_nested(&next->d_lock, DENTRY_D_LOCK_NESTED);
52676 if (!simple_positive(next)) {
52677 @@ -174,7 +177,12 @@ int dcache_readdir(struct file * filp, void * dirent, filldir_t filldir)
52678
52679 spin_unlock(&next->d_lock);
52680 spin_unlock(&dentry->d_lock);
52681 - if (filldir(dirent, next->d_name.name,
52682 + name = next->d_name.name;
52683 + if (name == next->d_iname) {
52684 + memcpy(d_name, name, next->d_name.len);
52685 + name = d_name;
52686 + }
52687 + if (filldir(dirent, name,
52688 next->d_name.len, filp->f_pos,
52689 next->d_inode->i_ino,
52690 dt_type(next->d_inode)) < 0)
52691 diff --git a/fs/lockd/clntproc.c b/fs/lockd/clntproc.c
52692 index 52e5120..808936e 100644
52693 --- a/fs/lockd/clntproc.c
52694 +++ b/fs/lockd/clntproc.c
52695 @@ -36,11 +36,11 @@ static const struct rpc_call_ops nlmclnt_cancel_ops;
52696 /*
52697 * Cookie counter for NLM requests
52698 */
52699 -static atomic_t nlm_cookie = ATOMIC_INIT(0x1234);
52700 +static atomic_unchecked_t nlm_cookie = ATOMIC_INIT(0x1234);
52701
52702 void nlmclnt_next_cookie(struct nlm_cookie *c)
52703 {
52704 - u32 cookie = atomic_inc_return(&nlm_cookie);
52705 + u32 cookie = atomic_inc_return_unchecked(&nlm_cookie);
52706
52707 memcpy(c->data, &cookie, 4);
52708 c->len=4;
52709 diff --git a/fs/locks.c b/fs/locks.c
52710 index a94e331..060bce3 100644
52711 --- a/fs/locks.c
52712 +++ b/fs/locks.c
52713 @@ -2064,16 +2064,16 @@ void locks_remove_flock(struct file *filp)
52714 return;
52715
52716 if (filp->f_op && filp->f_op->flock) {
52717 - struct file_lock fl = {
52718 + struct file_lock flock = {
52719 .fl_pid = current->tgid,
52720 .fl_file = filp,
52721 .fl_flags = FL_FLOCK,
52722 .fl_type = F_UNLCK,
52723 .fl_end = OFFSET_MAX,
52724 };
52725 - filp->f_op->flock(filp, F_SETLKW, &fl);
52726 - if (fl.fl_ops && fl.fl_ops->fl_release_private)
52727 - fl.fl_ops->fl_release_private(&fl);
52728 + filp->f_op->flock(filp, F_SETLKW, &flock);
52729 + if (flock.fl_ops && flock.fl_ops->fl_release_private)
52730 + flock.fl_ops->fl_release_private(&flock);
52731 }
52732
52733 lock_flocks();
52734 diff --git a/fs/namei.c b/fs/namei.c
52735 index ec97aef..6e33759 100644
52736 --- a/fs/namei.c
52737 +++ b/fs/namei.c
52738 @@ -319,16 +319,32 @@ int generic_permission(struct inode *inode, int mask)
52739 if (ret != -EACCES)
52740 return ret;
52741
52742 +#ifdef CONFIG_GRKERNSEC
52743 + /* we'll block if we have to log due to a denied capability use */
52744 + if (mask & MAY_NOT_BLOCK)
52745 + return -ECHILD;
52746 +#endif
52747 +
52748 if (S_ISDIR(inode->i_mode)) {
52749 /* DACs are overridable for directories */
52750 - if (inode_capable(inode, CAP_DAC_OVERRIDE))
52751 - return 0;
52752 if (!(mask & MAY_WRITE))
52753 - if (inode_capable(inode, CAP_DAC_READ_SEARCH))
52754 + if (inode_capable_nolog(inode, CAP_DAC_OVERRIDE) ||
52755 + inode_capable(inode, CAP_DAC_READ_SEARCH))
52756 return 0;
52757 + if (inode_capable(inode, CAP_DAC_OVERRIDE))
52758 + return 0;
52759 return -EACCES;
52760 }
52761 /*
52762 + * Searching includes executable on directories, else just read.
52763 + */
52764 + mask &= MAY_READ | MAY_WRITE | MAY_EXEC;
52765 + if (mask == MAY_READ)
52766 + if (inode_capable_nolog(inode, CAP_DAC_OVERRIDE) ||
52767 + inode_capable(inode, CAP_DAC_READ_SEARCH))
52768 + return 0;
52769 +
52770 + /*
52771 * Read/write DACs are always overridable.
52772 * Executable DACs are overridable when there is
52773 * at least one exec bit set.
52774 @@ -337,14 +353,6 @@ int generic_permission(struct inode *inode, int mask)
52775 if (inode_capable(inode, CAP_DAC_OVERRIDE))
52776 return 0;
52777
52778 - /*
52779 - * Searching includes executable on directories, else just read.
52780 - */
52781 - mask &= MAY_READ | MAY_WRITE | MAY_EXEC;
52782 - if (mask == MAY_READ)
52783 - if (inode_capable(inode, CAP_DAC_READ_SEARCH))
52784 - return 0;
52785 -
52786 return -EACCES;
52787 }
52788
52789 @@ -824,7 +832,7 @@ follow_link(struct path *link, struct nameidata *nd, void **p)
52790 {
52791 struct dentry *dentry = link->dentry;
52792 int error;
52793 - char *s;
52794 + const char *s;
52795
52796 BUG_ON(nd->flags & LOOKUP_RCU);
52797
52798 @@ -845,6 +853,12 @@ follow_link(struct path *link, struct nameidata *nd, void **p)
52799 if (error)
52800 goto out_put_nd_path;
52801
52802 + if (gr_handle_follow_link(dentry->d_parent->d_inode,
52803 + dentry->d_inode, dentry, nd->path.mnt)) {
52804 + error = -EACCES;
52805 + goto out_put_nd_path;
52806 + }
52807 +
52808 nd->last_type = LAST_BIND;
52809 *p = dentry->d_inode->i_op->follow_link(dentry, nd);
52810 error = PTR_ERR(*p);
52811 @@ -1594,6 +1608,8 @@ static inline int nested_symlink(struct path *path, struct nameidata *nd)
52812 break;
52813 res = walk_component(nd, path, &nd->last,
52814 nd->last_type, LOOKUP_FOLLOW);
52815 + if (res >= 0 && gr_handle_symlink_owner(&link, nd->inode))
52816 + res = -EACCES;
52817 put_link(nd, &link, cookie);
52818 } while (res > 0);
52819
52820 @@ -1692,7 +1708,7 @@ EXPORT_SYMBOL(full_name_hash);
52821 static inline unsigned long hash_name(const char *name, unsigned int *hashp)
52822 {
52823 unsigned long a, b, adata, bdata, mask, hash, len;
52824 - const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
52825 + static const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
52826
52827 hash = a = 0;
52828 len = -sizeof(unsigned long);
52829 @@ -1977,6 +1993,8 @@ static int path_lookupat(int dfd, const char *name,
52830 if (err)
52831 break;
52832 err = lookup_last(nd, &path);
52833 + if (!err && gr_handle_symlink_owner(&link, nd->inode))
52834 + err = -EACCES;
52835 put_link(nd, &link, cookie);
52836 }
52837 }
52838 @@ -1984,6 +2002,19 @@ static int path_lookupat(int dfd, const char *name,
52839 if (!err)
52840 err = complete_walk(nd);
52841
52842 + if (!err && !(nd->flags & LOOKUP_PARENT)) {
52843 +#ifdef CONFIG_GRKERNSEC
52844 + if (flags & LOOKUP_RCU) {
52845 + path_put(&nd->path);
52846 + err = -ECHILD;
52847 + } else
52848 +#endif
52849 + if (!gr_acl_handle_hidden_file(nd->path.dentry, nd->path.mnt)) {
52850 + path_put(&nd->path);
52851 + err = -ENOENT;
52852 + }
52853 + }
52854 +
52855 if (!err && nd->flags & LOOKUP_DIRECTORY) {
52856 if (!nd->inode->i_op->lookup) {
52857 path_put(&nd->path);
52858 @@ -2011,8 +2042,21 @@ static int filename_lookup(int dfd, struct filename *name,
52859 retval = path_lookupat(dfd, name->name,
52860 flags | LOOKUP_REVAL, nd);
52861
52862 - if (likely(!retval))
52863 + if (likely(!retval)) {
52864 audit_inode(name, nd->path.dentry, flags & LOOKUP_PARENT);
52865 + if (name->name[0] != '/' && nd->path.dentry && nd->inode) {
52866 +#ifdef CONFIG_GRKERNSEC
52867 + if (flags & LOOKUP_RCU) {
52868 + path_put(&nd->path);
52869 + return -ECHILD;
52870 + }
52871 +#endif
52872 + if (!gr_chroot_fchdir(nd->path.dentry, nd->path.mnt)) {
52873 + path_put(&nd->path);
52874 + return -ENOENT;
52875 + }
52876 + }
52877 + }
52878 return retval;
52879 }
52880
52881 @@ -2390,6 +2434,13 @@ static int may_open(struct path *path, int acc_mode, int flag)
52882 if (flag & O_NOATIME && !inode_owner_or_capable(inode))
52883 return -EPERM;
52884
52885 + if (gr_handle_rofs_blockwrite(dentry, path->mnt, acc_mode))
52886 + return -EPERM;
52887 + if (gr_handle_rawio(inode))
52888 + return -EPERM;
52889 + if (!gr_acl_handle_open(dentry, path->mnt, acc_mode))
52890 + return -EACCES;
52891 +
52892 return 0;
52893 }
52894
52895 @@ -2611,7 +2662,7 @@ looked_up:
52896 * cleared otherwise prior to returning.
52897 */
52898 static int lookup_open(struct nameidata *nd, struct path *path,
52899 - struct file *file,
52900 + struct path *link, struct file *file,
52901 const struct open_flags *op,
52902 bool got_write, int *opened)
52903 {
52904 @@ -2646,6 +2697,17 @@ static int lookup_open(struct nameidata *nd, struct path *path,
52905 /* Negative dentry, just create the file */
52906 if (!dentry->d_inode && (op->open_flag & O_CREAT)) {
52907 umode_t mode = op->mode;
52908 +
52909 + if (link && gr_handle_symlink_owner(link, dir->d_inode)) {
52910 + error = -EACCES;
52911 + goto out_dput;
52912 + }
52913 +
52914 + if (!gr_acl_handle_creat(dentry, dir, nd->path.mnt, op->open_flag, op->acc_mode, mode)) {
52915 + error = -EACCES;
52916 + goto out_dput;
52917 + }
52918 +
52919 if (!IS_POSIXACL(dir->d_inode))
52920 mode &= ~current_umask();
52921 /*
52922 @@ -2667,6 +2729,8 @@ static int lookup_open(struct nameidata *nd, struct path *path,
52923 nd->flags & LOOKUP_EXCL);
52924 if (error)
52925 goto out_dput;
52926 + else
52927 + gr_handle_create(dentry, nd->path.mnt);
52928 }
52929 out_no_open:
52930 path->dentry = dentry;
52931 @@ -2681,7 +2745,7 @@ out_dput:
52932 /*
52933 * Handle the last step of open()
52934 */
52935 -static int do_last(struct nameidata *nd, struct path *path,
52936 +static int do_last(struct nameidata *nd, struct path *path, struct path *link,
52937 struct file *file, const struct open_flags *op,
52938 int *opened, struct filename *name)
52939 {
52940 @@ -2710,16 +2774,44 @@ static int do_last(struct nameidata *nd, struct path *path,
52941 error = complete_walk(nd);
52942 if (error)
52943 return error;
52944 +#ifdef CONFIG_GRKERNSEC
52945 + if (nd->flags & LOOKUP_RCU) {
52946 + error = -ECHILD;
52947 + goto out;
52948 + }
52949 +#endif
52950 + if (!gr_acl_handle_hidden_file(nd->path.dentry, nd->path.mnt)) {
52951 + error = -ENOENT;
52952 + goto out;
52953 + }
52954 audit_inode(name, nd->path.dentry, 0);
52955 if (open_flag & O_CREAT) {
52956 error = -EISDIR;
52957 goto out;
52958 }
52959 + if (link && gr_handle_symlink_owner(link, nd->inode)) {
52960 + error = -EACCES;
52961 + goto out;
52962 + }
52963 goto finish_open;
52964 case LAST_BIND:
52965 error = complete_walk(nd);
52966 if (error)
52967 return error;
52968 +#ifdef CONFIG_GRKERNSEC
52969 + if (nd->flags & LOOKUP_RCU) {
52970 + error = -ECHILD;
52971 + goto out;
52972 + }
52973 +#endif
52974 + if (!gr_acl_handle_hidden_file(dir, nd->path.mnt)) {
52975 + error = -ENOENT;
52976 + goto out;
52977 + }
52978 + if (link && gr_handle_symlink_owner(link, nd->inode)) {
52979 + error = -EACCES;
52980 + goto out;
52981 + }
52982 audit_inode(name, dir, 0);
52983 goto finish_open;
52984 }
52985 @@ -2768,7 +2860,7 @@ retry_lookup:
52986 */
52987 }
52988 mutex_lock(&dir->d_inode->i_mutex);
52989 - error = lookup_open(nd, path, file, op, got_write, opened);
52990 + error = lookup_open(nd, path, link, file, op, got_write, opened);
52991 mutex_unlock(&dir->d_inode->i_mutex);
52992
52993 if (error <= 0) {
52994 @@ -2792,11 +2884,28 @@ retry_lookup:
52995 goto finish_open_created;
52996 }
52997
52998 + if (!gr_acl_handle_hidden_file(path->dentry, nd->path.mnt)) {
52999 + error = -ENOENT;
53000 + goto exit_dput;
53001 + }
53002 + if (link && gr_handle_symlink_owner(link, path->dentry->d_inode)) {
53003 + error = -EACCES;
53004 + goto exit_dput;
53005 + }
53006 +
53007 /*
53008 * create/update audit record if it already exists.
53009 */
53010 - if (path->dentry->d_inode)
53011 + if (path->dentry->d_inode) {
53012 + /* only check if O_CREAT is specified, all other checks need to go
53013 + into may_open */
53014 + if (gr_handle_fifo(path->dentry, path->mnt, dir, open_flag, acc_mode)) {
53015 + error = -EACCES;
53016 + goto exit_dput;
53017 + }
53018 +
53019 audit_inode(name, path->dentry, 0);
53020 + }
53021
53022 /*
53023 * If atomic_open() acquired write access it is dropped now due to
53024 @@ -2837,6 +2946,11 @@ finish_lookup:
53025 }
53026 }
53027 BUG_ON(inode != path->dentry->d_inode);
53028 + /* if we're resolving a symlink to another symlink */
53029 + if (link && gr_handle_symlink_owner(link, inode)) {
53030 + error = -EACCES;
53031 + goto out;
53032 + }
53033 return 1;
53034 }
53035
53036 @@ -2846,7 +2960,6 @@ finish_lookup:
53037 save_parent.dentry = nd->path.dentry;
53038 save_parent.mnt = mntget(path->mnt);
53039 nd->path.dentry = path->dentry;
53040 -
53041 }
53042 nd->inode = inode;
53043 /* Why this, you ask? _Now_ we might have grown LOOKUP_JUMPED... */
53044 @@ -2855,6 +2968,22 @@ finish_lookup:
53045 path_put(&save_parent);
53046 return error;
53047 }
53048 +
53049 +#ifdef CONFIG_GRKERNSEC
53050 + if (nd->flags & LOOKUP_RCU) {
53051 + error = -ECHILD;
53052 + goto out;
53053 + }
53054 +#endif
53055 + if (!gr_acl_handle_hidden_file(nd->path.dentry, nd->path.mnt)) {
53056 + error = -ENOENT;
53057 + goto out;
53058 + }
53059 + if (link && gr_handle_symlink_owner(link, nd->inode)) {
53060 + error = -EACCES;
53061 + goto out;
53062 + }
53063 +
53064 error = -EISDIR;
53065 if ((open_flag & O_CREAT) && S_ISDIR(nd->inode->i_mode))
53066 goto out;
53067 @@ -2953,7 +3082,7 @@ static struct file *path_openat(int dfd, struct filename *pathname,
53068 if (unlikely(error))
53069 goto out;
53070
53071 - error = do_last(nd, &path, file, op, &opened, pathname);
53072 + error = do_last(nd, &path, NULL, file, op, &opened, pathname);
53073 while (unlikely(error > 0)) { /* trailing symlink */
53074 struct path link = path;
53075 void *cookie;
53076 @@ -2971,7 +3100,7 @@ static struct file *path_openat(int dfd, struct filename *pathname,
53077 error = follow_link(&link, nd, &cookie);
53078 if (unlikely(error))
53079 break;
53080 - error = do_last(nd, &path, file, op, &opened, pathname);
53081 + error = do_last(nd, &path, &link, file, op, &opened, pathname);
53082 put_link(nd, &link, cookie);
53083 }
53084 out:
53085 @@ -3071,8 +3200,12 @@ struct dentry *kern_path_create(int dfd, const char *pathname,
53086 goto unlock;
53087
53088 error = -EEXIST;
53089 - if (dentry->d_inode)
53090 + if (dentry->d_inode) {
53091 + if (!gr_acl_handle_hidden_file(dentry, nd.path.mnt)) {
53092 + error = -ENOENT;
53093 + }
53094 goto fail;
53095 + }
53096 /*
53097 * Special case - lookup gave negative, but... we had foo/bar/
53098 * From the vfs_mknod() POV we just have a negative dentry -
53099 @@ -3124,6 +3257,20 @@ struct dentry *user_path_create(int dfd, const char __user *pathname,
53100 }
53101 EXPORT_SYMBOL(user_path_create);
53102
53103 +static struct dentry *user_path_create_with_name(int dfd, const char __user *pathname, struct path *path, struct filename **to, unsigned int lookup_flags)
53104 +{
53105 + struct filename *tmp = getname(pathname);
53106 + struct dentry *res;
53107 + if (IS_ERR(tmp))
53108 + return ERR_CAST(tmp);
53109 + res = kern_path_create(dfd, tmp->name, path, lookup_flags);
53110 + if (IS_ERR(res))
53111 + putname(tmp);
53112 + else
53113 + *to = tmp;
53114 + return res;
53115 +}
53116 +
53117 int vfs_mknod(struct inode *dir, struct dentry *dentry, umode_t mode, dev_t dev)
53118 {
53119 int error = may_create(dir, dentry);
53120 @@ -3186,6 +3333,17 @@ retry:
53121
53122 if (!IS_POSIXACL(path.dentry->d_inode))
53123 mode &= ~current_umask();
53124 +
53125 + if (gr_handle_chroot_mknod(dentry, path.mnt, mode)) {
53126 + error = -EPERM;
53127 + goto out;
53128 + }
53129 +
53130 + if (!gr_acl_handle_mknod(dentry, path.dentry, path.mnt, mode)) {
53131 + error = -EACCES;
53132 + goto out;
53133 + }
53134 +
53135 error = security_path_mknod(&path, dentry, mode, dev);
53136 if (error)
53137 goto out;
53138 @@ -3202,6 +3360,8 @@ retry:
53139 break;
53140 }
53141 out:
53142 + if (!error)
53143 + gr_handle_create(dentry, path.mnt);
53144 done_path_create(&path, dentry);
53145 if (retry_estale(error, lookup_flags)) {
53146 lookup_flags |= LOOKUP_REVAL;
53147 @@ -3254,9 +3414,16 @@ retry:
53148
53149 if (!IS_POSIXACL(path.dentry->d_inode))
53150 mode &= ~current_umask();
53151 + if (!gr_acl_handle_mkdir(dentry, path.dentry, path.mnt)) {
53152 + error = -EACCES;
53153 + goto out;
53154 + }
53155 error = security_path_mkdir(&path, dentry, mode);
53156 if (!error)
53157 error = vfs_mkdir(path.dentry->d_inode, dentry, mode);
53158 + if (!error)
53159 + gr_handle_create(dentry, path.mnt);
53160 +out:
53161 done_path_create(&path, dentry);
53162 if (retry_estale(error, lookup_flags)) {
53163 lookup_flags |= LOOKUP_REVAL;
53164 @@ -3337,6 +3504,8 @@ static long do_rmdir(int dfd, const char __user *pathname)
53165 struct filename *name;
53166 struct dentry *dentry;
53167 struct nameidata nd;
53168 + ino_t saved_ino = 0;
53169 + dev_t saved_dev = 0;
53170 unsigned int lookup_flags = 0;
53171 retry:
53172 name = user_path_parent(dfd, pathname, &nd, lookup_flags);
53173 @@ -3369,10 +3538,21 @@ retry:
53174 error = -ENOENT;
53175 goto exit3;
53176 }
53177 +
53178 + saved_ino = dentry->d_inode->i_ino;
53179 + saved_dev = gr_get_dev_from_dentry(dentry);
53180 +
53181 + if (!gr_acl_handle_rmdir(dentry, nd.path.mnt)) {
53182 + error = -EACCES;
53183 + goto exit3;
53184 + }
53185 +
53186 error = security_path_rmdir(&nd.path, dentry);
53187 if (error)
53188 goto exit3;
53189 error = vfs_rmdir(nd.path.dentry->d_inode, dentry);
53190 + if (!error && (saved_dev || saved_ino))
53191 + gr_handle_delete(saved_ino, saved_dev);
53192 exit3:
53193 dput(dentry);
53194 exit2:
53195 @@ -3438,6 +3618,8 @@ static long do_unlinkat(int dfd, const char __user *pathname)
53196 struct dentry *dentry;
53197 struct nameidata nd;
53198 struct inode *inode = NULL;
53199 + ino_t saved_ino = 0;
53200 + dev_t saved_dev = 0;
53201 unsigned int lookup_flags = 0;
53202 retry:
53203 name = user_path_parent(dfd, pathname, &nd, lookup_flags);
53204 @@ -3464,10 +3646,22 @@ retry:
53205 if (!inode)
53206 goto slashes;
53207 ihold(inode);
53208 +
53209 + if (inode->i_nlink <= 1) {
53210 + saved_ino = inode->i_ino;
53211 + saved_dev = gr_get_dev_from_dentry(dentry);
53212 + }
53213 + if (!gr_acl_handle_unlink(dentry, nd.path.mnt)) {
53214 + error = -EACCES;
53215 + goto exit2;
53216 + }
53217 +
53218 error = security_path_unlink(&nd.path, dentry);
53219 if (error)
53220 goto exit2;
53221 error = vfs_unlink(nd.path.dentry->d_inode, dentry);
53222 + if (!error && (saved_ino || saved_dev))
53223 + gr_handle_delete(saved_ino, saved_dev);
53224 exit2:
53225 dput(dentry);
53226 }
53227 @@ -3545,9 +3739,17 @@ retry:
53228 if (IS_ERR(dentry))
53229 goto out_putname;
53230
53231 + if (!gr_acl_handle_symlink(dentry, path.dentry, path.mnt, from)) {
53232 + error = -EACCES;
53233 + goto out;
53234 + }
53235 +
53236 error = security_path_symlink(&path, dentry, from->name);
53237 if (!error)
53238 error = vfs_symlink(path.dentry->d_inode, dentry, from->name);
53239 + if (!error)
53240 + gr_handle_create(dentry, path.mnt);
53241 +out:
53242 done_path_create(&path, dentry);
53243 if (retry_estale(error, lookup_flags)) {
53244 lookup_flags |= LOOKUP_REVAL;
53245 @@ -3621,6 +3823,7 @@ SYSCALL_DEFINE5(linkat, int, olddfd, const char __user *, oldname,
53246 {
53247 struct dentry *new_dentry;
53248 struct path old_path, new_path;
53249 + struct filename *to = NULL;
53250 int how = 0;
53251 int error;
53252
53253 @@ -3644,7 +3847,7 @@ retry:
53254 if (error)
53255 return error;
53256
53257 - new_dentry = user_path_create(newdfd, newname, &new_path,
53258 + new_dentry = user_path_create_with_name(newdfd, newname, &new_path, &to,
53259 (how & LOOKUP_REVAL));
53260 error = PTR_ERR(new_dentry);
53261 if (IS_ERR(new_dentry))
53262 @@ -3656,11 +3859,28 @@ retry:
53263 error = may_linkat(&old_path);
53264 if (unlikely(error))
53265 goto out_dput;
53266 +
53267 + if (gr_handle_hardlink(old_path.dentry, old_path.mnt,
53268 + old_path.dentry->d_inode,
53269 + old_path.dentry->d_inode->i_mode, to)) {
53270 + error = -EACCES;
53271 + goto out_dput;
53272 + }
53273 +
53274 + if (!gr_acl_handle_link(new_dentry, new_path.dentry, new_path.mnt,
53275 + old_path.dentry, old_path.mnt, to)) {
53276 + error = -EACCES;
53277 + goto out_dput;
53278 + }
53279 +
53280 error = security_path_link(old_path.dentry, &new_path, new_dentry);
53281 if (error)
53282 goto out_dput;
53283 error = vfs_link(old_path.dentry, new_path.dentry->d_inode, new_dentry);
53284 + if (!error)
53285 + gr_handle_create(new_dentry, new_path.mnt);
53286 out_dput:
53287 + putname(to);
53288 done_path_create(&new_path, new_dentry);
53289 if (retry_estale(error, how)) {
53290 how |= LOOKUP_REVAL;
53291 @@ -3906,12 +4126,21 @@ retry:
53292 if (new_dentry == trap)
53293 goto exit5;
53294
53295 + error = gr_acl_handle_rename(new_dentry, new_dir, newnd.path.mnt,
53296 + old_dentry, old_dir->d_inode, oldnd.path.mnt,
53297 + to);
53298 + if (error)
53299 + goto exit5;
53300 +
53301 error = security_path_rename(&oldnd.path, old_dentry,
53302 &newnd.path, new_dentry);
53303 if (error)
53304 goto exit5;
53305 error = vfs_rename(old_dir->d_inode, old_dentry,
53306 new_dir->d_inode, new_dentry);
53307 + if (!error)
53308 + gr_handle_rename(old_dir->d_inode, new_dir->d_inode, old_dentry,
53309 + new_dentry, oldnd.path.mnt, new_dentry->d_inode ? 1 : 0);
53310 exit5:
53311 dput(new_dentry);
53312 exit4:
53313 @@ -3943,6 +4172,8 @@ SYSCALL_DEFINE2(rename, const char __user *, oldname, const char __user *, newna
53314
53315 int vfs_readlink(struct dentry *dentry, char __user *buffer, int buflen, const char *link)
53316 {
53317 + char tmpbuf[64];
53318 + const char *newlink;
53319 int len;
53320
53321 len = PTR_ERR(link);
53322 @@ -3952,7 +4183,14 @@ int vfs_readlink(struct dentry *dentry, char __user *buffer, int buflen, const c
53323 len = strlen(link);
53324 if (len > (unsigned) buflen)
53325 len = buflen;
53326 - if (copy_to_user(buffer, link, len))
53327 +
53328 + if (len < sizeof(tmpbuf)) {
53329 + memcpy(tmpbuf, link, len);
53330 + newlink = tmpbuf;
53331 + } else
53332 + newlink = link;
53333 +
53334 + if (copy_to_user(buffer, newlink, len))
53335 len = -EFAULT;
53336 out:
53337 return len;
53338 diff --git a/fs/namespace.c b/fs/namespace.c
53339 index a51054f..f9b53e5 100644
53340 --- a/fs/namespace.c
53341 +++ b/fs/namespace.c
53342 @@ -1215,6 +1215,9 @@ static int do_umount(struct mount *mnt, int flags)
53343 if (!(sb->s_flags & MS_RDONLY))
53344 retval = do_remount_sb(sb, MS_RDONLY, NULL, 0);
53345 up_write(&sb->s_umount);
53346 +
53347 + gr_log_remount(mnt->mnt_devname, retval);
53348 +
53349 return retval;
53350 }
53351
53352 @@ -1234,6 +1237,9 @@ static int do_umount(struct mount *mnt, int flags)
53353 br_write_unlock(&vfsmount_lock);
53354 up_write(&namespace_sem);
53355 release_mounts(&umount_list);
53356 +
53357 + gr_log_unmount(mnt->mnt_devname, retval);
53358 +
53359 return retval;
53360 }
53361
53362 @@ -2287,6 +2293,16 @@ long do_mount(const char *dev_name, const char *dir_name,
53363 MS_NOATIME | MS_NODIRATIME | MS_RELATIME| MS_KERNMOUNT |
53364 MS_STRICTATIME);
53365
53366 + if (gr_handle_rofs_mount(path.dentry, path.mnt, mnt_flags)) {
53367 + retval = -EPERM;
53368 + goto dput_out;
53369 + }
53370 +
53371 + if (gr_handle_chroot_mount(path.dentry, path.mnt, dev_name)) {
53372 + retval = -EPERM;
53373 + goto dput_out;
53374 + }
53375 +
53376 if (flags & MS_REMOUNT)
53377 retval = do_remount(&path, flags & ~MS_REMOUNT, mnt_flags,
53378 data_page);
53379 @@ -2301,6 +2317,9 @@ long do_mount(const char *dev_name, const char *dir_name,
53380 dev_name, data_page);
53381 dput_out:
53382 path_put(&path);
53383 +
53384 + gr_log_mount(dev_name, dir_name, retval);
53385 +
53386 return retval;
53387 }
53388
53389 @@ -2587,6 +2606,11 @@ SYSCALL_DEFINE2(pivot_root, const char __user *, new_root,
53390 if (error)
53391 goto out2;
53392
53393 + if (gr_handle_chroot_pivot()) {
53394 + error = -EPERM;
53395 + goto out2;
53396 + }
53397 +
53398 get_fs_root(current->fs, &root);
53399 error = lock_mount(&old);
53400 if (error)
53401 @@ -2790,7 +2814,7 @@ static int mntns_install(struct nsproxy *nsproxy, void *ns)
53402 !nsown_capable(CAP_SYS_ADMIN))
53403 return -EPERM;
53404
53405 - if (fs->users != 1)
53406 + if (atomic_read(&fs->users) != 1)
53407 return -EINVAL;
53408
53409 get_mnt_ns(mnt_ns);
53410 diff --git a/fs/nfs/callback_xdr.c b/fs/nfs/callback_xdr.c
53411 index 59461c9..b17c57e 100644
53412 --- a/fs/nfs/callback_xdr.c
53413 +++ b/fs/nfs/callback_xdr.c
53414 @@ -51,7 +51,7 @@ struct callback_op {
53415 callback_decode_arg_t decode_args;
53416 callback_encode_res_t encode_res;
53417 long res_maxsize;
53418 -};
53419 +} __do_const;
53420
53421 static struct callback_op callback_ops[];
53422
53423 diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
53424 index ebeb94c..ff35337 100644
53425 --- a/fs/nfs/inode.c
53426 +++ b/fs/nfs/inode.c
53427 @@ -1042,16 +1042,16 @@ static int nfs_size_need_update(const struct inode *inode, const struct nfs_fatt
53428 return nfs_size_to_loff_t(fattr->size) > i_size_read(inode);
53429 }
53430
53431 -static atomic_long_t nfs_attr_generation_counter;
53432 +static atomic_long_unchecked_t nfs_attr_generation_counter;
53433
53434 static unsigned long nfs_read_attr_generation_counter(void)
53435 {
53436 - return atomic_long_read(&nfs_attr_generation_counter);
53437 + return atomic_long_read_unchecked(&nfs_attr_generation_counter);
53438 }
53439
53440 unsigned long nfs_inc_attr_generation_counter(void)
53441 {
53442 - return atomic_long_inc_return(&nfs_attr_generation_counter);
53443 + return atomic_long_inc_return_unchecked(&nfs_attr_generation_counter);
53444 }
53445
53446 void nfs_fattr_init(struct nfs_fattr *fattr)
53447 diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c
53448 index 9d1c5db..1e13db8 100644
53449 --- a/fs/nfsd/nfs4proc.c
53450 +++ b/fs/nfsd/nfs4proc.c
53451 @@ -1097,7 +1097,7 @@ struct nfsd4_operation {
53452 nfsd4op_rsize op_rsize_bop;
53453 stateid_getter op_get_currentstateid;
53454 stateid_setter op_set_currentstateid;
53455 -};
53456 +} __do_const;
53457
53458 static struct nfsd4_operation nfsd4_ops[];
53459
53460 diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
53461 index 0dc1158..ccf0338 100644
53462 --- a/fs/nfsd/nfs4xdr.c
53463 +++ b/fs/nfsd/nfs4xdr.c
53464 @@ -1456,7 +1456,7 @@ nfsd4_decode_notsupp(struct nfsd4_compoundargs *argp, void *p)
53465
53466 typedef __be32(*nfsd4_dec)(struct nfsd4_compoundargs *argp, void *);
53467
53468 -static nfsd4_dec nfsd4_dec_ops[] = {
53469 +static const nfsd4_dec nfsd4_dec_ops[] = {
53470 [OP_ACCESS] = (nfsd4_dec)nfsd4_decode_access,
53471 [OP_CLOSE] = (nfsd4_dec)nfsd4_decode_close,
53472 [OP_COMMIT] = (nfsd4_dec)nfsd4_decode_commit,
53473 @@ -1496,7 +1496,7 @@ static nfsd4_dec nfsd4_dec_ops[] = {
53474 [OP_RELEASE_LOCKOWNER] = (nfsd4_dec)nfsd4_decode_release_lockowner,
53475 };
53476
53477 -static nfsd4_dec nfsd41_dec_ops[] = {
53478 +static const nfsd4_dec nfsd41_dec_ops[] = {
53479 [OP_ACCESS] = (nfsd4_dec)nfsd4_decode_access,
53480 [OP_CLOSE] = (nfsd4_dec)nfsd4_decode_close,
53481 [OP_COMMIT] = (nfsd4_dec)nfsd4_decode_commit,
53482 @@ -1558,7 +1558,7 @@ static nfsd4_dec nfsd41_dec_ops[] = {
53483 };
53484
53485 struct nfsd4_minorversion_ops {
53486 - nfsd4_dec *decoders;
53487 + const nfsd4_dec *decoders;
53488 int nops;
53489 };
53490
53491 diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c
53492 index d586117..143d568 100644
53493 --- a/fs/nfsd/vfs.c
53494 +++ b/fs/nfsd/vfs.c
53495 @@ -939,7 +939,7 @@ nfsd_vfs_read(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
53496 } else {
53497 oldfs = get_fs();
53498 set_fs(KERNEL_DS);
53499 - host_err = vfs_readv(file, (struct iovec __user *)vec, vlen, &offset);
53500 + host_err = vfs_readv(file, (struct iovec __force_user *)vec, vlen, &offset);
53501 set_fs(oldfs);
53502 }
53503
53504 @@ -1025,7 +1025,7 @@ nfsd_vfs_write(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
53505
53506 /* Write the data. */
53507 oldfs = get_fs(); set_fs(KERNEL_DS);
53508 - host_err = vfs_writev(file, (struct iovec __user *)vec, vlen, &offset);
53509 + host_err = vfs_writev(file, (struct iovec __force_user *)vec, vlen, &offset);
53510 set_fs(oldfs);
53511 if (host_err < 0)
53512 goto out_nfserr;
53513 @@ -1571,7 +1571,7 @@ nfsd_readlink(struct svc_rqst *rqstp, struct svc_fh *fhp, char *buf, int *lenp)
53514 */
53515
53516 oldfs = get_fs(); set_fs(KERNEL_DS);
53517 - host_err = inode->i_op->readlink(path.dentry, (char __user *)buf, *lenp);
53518 + host_err = inode->i_op->readlink(path.dentry, (char __force_user *)buf, *lenp);
53519 set_fs(oldfs);
53520
53521 if (host_err < 0)
53522 diff --git a/fs/nls/nls_base.c b/fs/nls/nls_base.c
53523 index fea6bd5..8ee9d81 100644
53524 --- a/fs/nls/nls_base.c
53525 +++ b/fs/nls/nls_base.c
53526 @@ -234,20 +234,22 @@ EXPORT_SYMBOL(utf16s_to_utf8s);
53527
53528 int register_nls(struct nls_table * nls)
53529 {
53530 - struct nls_table ** tmp = &tables;
53531 + struct nls_table *tmp = tables;
53532
53533 if (nls->next)
53534 return -EBUSY;
53535
53536 spin_lock(&nls_lock);
53537 - while (*tmp) {
53538 - if (nls == *tmp) {
53539 + while (tmp) {
53540 + if (nls == tmp) {
53541 spin_unlock(&nls_lock);
53542 return -EBUSY;
53543 }
53544 - tmp = &(*tmp)->next;
53545 + tmp = tmp->next;
53546 }
53547 - nls->next = tables;
53548 + pax_open_kernel();
53549 + *(struct nls_table **)&nls->next = tables;
53550 + pax_close_kernel();
53551 tables = nls;
53552 spin_unlock(&nls_lock);
53553 return 0;
53554 @@ -255,12 +257,14 @@ int register_nls(struct nls_table * nls)
53555
53556 int unregister_nls(struct nls_table * nls)
53557 {
53558 - struct nls_table ** tmp = &tables;
53559 + struct nls_table * const * tmp = &tables;
53560
53561 spin_lock(&nls_lock);
53562 while (*tmp) {
53563 if (nls == *tmp) {
53564 - *tmp = nls->next;
53565 + pax_open_kernel();
53566 + *(struct nls_table **)tmp = nls->next;
53567 + pax_close_kernel();
53568 spin_unlock(&nls_lock);
53569 return 0;
53570 }
53571 diff --git a/fs/nls/nls_euc-jp.c b/fs/nls/nls_euc-jp.c
53572 index 7424929..35f6be5 100644
53573 --- a/fs/nls/nls_euc-jp.c
53574 +++ b/fs/nls/nls_euc-jp.c
53575 @@ -561,8 +561,10 @@ static int __init init_nls_euc_jp(void)
53576 p_nls = load_nls("cp932");
53577
53578 if (p_nls) {
53579 - table.charset2upper = p_nls->charset2upper;
53580 - table.charset2lower = p_nls->charset2lower;
53581 + pax_open_kernel();
53582 + *(const unsigned char **)&table.charset2upper = p_nls->charset2upper;
53583 + *(const unsigned char **)&table.charset2lower = p_nls->charset2lower;
53584 + pax_close_kernel();
53585 return register_nls(&table);
53586 }
53587
53588 diff --git a/fs/nls/nls_koi8-ru.c b/fs/nls/nls_koi8-ru.c
53589 index e7bc1d7..06bd4bb 100644
53590 --- a/fs/nls/nls_koi8-ru.c
53591 +++ b/fs/nls/nls_koi8-ru.c
53592 @@ -63,8 +63,10 @@ static int __init init_nls_koi8_ru(void)
53593 p_nls = load_nls("koi8-u");
53594
53595 if (p_nls) {
53596 - table.charset2upper = p_nls->charset2upper;
53597 - table.charset2lower = p_nls->charset2lower;
53598 + pax_open_kernel();
53599 + *(const unsigned char **)&table.charset2upper = p_nls->charset2upper;
53600 + *(const unsigned char **)&table.charset2lower = p_nls->charset2lower;
53601 + pax_close_kernel();
53602 return register_nls(&table);
53603 }
53604
53605 diff --git a/fs/notify/fanotify/fanotify_user.c b/fs/notify/fanotify/fanotify_user.c
53606 index 9ff4a5e..deb1f0f 100644
53607 --- a/fs/notify/fanotify/fanotify_user.c
53608 +++ b/fs/notify/fanotify/fanotify_user.c
53609 @@ -251,8 +251,8 @@ static ssize_t copy_event_to_user(struct fsnotify_group *group,
53610
53611 fd = fanotify_event_metadata.fd;
53612 ret = -EFAULT;
53613 - if (copy_to_user(buf, &fanotify_event_metadata,
53614 - fanotify_event_metadata.event_len))
53615 + if (fanotify_event_metadata.event_len > sizeof fanotify_event_metadata ||
53616 + copy_to_user(buf, &fanotify_event_metadata, fanotify_event_metadata.event_len))
53617 goto out_close_fd;
53618
53619 ret = prepare_for_access_response(group, event, fd);
53620 diff --git a/fs/notify/notification.c b/fs/notify/notification.c
53621 index 7b51b05..5ea5ef6 100644
53622 --- a/fs/notify/notification.c
53623 +++ b/fs/notify/notification.c
53624 @@ -57,7 +57,7 @@ static struct kmem_cache *fsnotify_event_holder_cachep;
53625 * get set to 0 so it will never get 'freed'
53626 */
53627 static struct fsnotify_event *q_overflow_event;
53628 -static atomic_t fsnotify_sync_cookie = ATOMIC_INIT(0);
53629 +static atomic_unchecked_t fsnotify_sync_cookie = ATOMIC_INIT(0);
53630
53631 /**
53632 * fsnotify_get_cookie - return a unique cookie for use in synchronizing events.
53633 @@ -65,7 +65,7 @@ static atomic_t fsnotify_sync_cookie = ATOMIC_INIT(0);
53634 */
53635 u32 fsnotify_get_cookie(void)
53636 {
53637 - return atomic_inc_return(&fsnotify_sync_cookie);
53638 + return atomic_inc_return_unchecked(&fsnotify_sync_cookie);
53639 }
53640 EXPORT_SYMBOL_GPL(fsnotify_get_cookie);
53641
53642 diff --git a/fs/ntfs/dir.c b/fs/ntfs/dir.c
53643 index 99e3610..02c1068 100644
53644 --- a/fs/ntfs/dir.c
53645 +++ b/fs/ntfs/dir.c
53646 @@ -1329,7 +1329,7 @@ find_next_index_buffer:
53647 ia = (INDEX_ALLOCATION*)(kaddr + (ia_pos & ~PAGE_CACHE_MASK &
53648 ~(s64)(ndir->itype.index.block_size - 1)));
53649 /* Bounds checks. */
53650 - if (unlikely((u8*)ia < kaddr || (u8*)ia > kaddr + PAGE_CACHE_SIZE)) {
53651 + if (unlikely(!kaddr || (u8*)ia < kaddr || (u8*)ia > kaddr + PAGE_CACHE_SIZE)) {
53652 ntfs_error(sb, "Out of bounds check failed. Corrupt directory "
53653 "inode 0x%lx or driver bug.", vdir->i_ino);
53654 goto err_out;
53655 diff --git a/fs/ntfs/file.c b/fs/ntfs/file.c
53656 index 5b2d4f0..c6de396 100644
53657 --- a/fs/ntfs/file.c
53658 +++ b/fs/ntfs/file.c
53659 @@ -2242,6 +2242,6 @@ const struct inode_operations ntfs_file_inode_ops = {
53660 #endif /* NTFS_RW */
53661 };
53662
53663 -const struct file_operations ntfs_empty_file_ops = {};
53664 +const struct file_operations ntfs_empty_file_ops __read_only;
53665
53666 -const struct inode_operations ntfs_empty_inode_ops = {};
53667 +const struct inode_operations ntfs_empty_inode_ops __read_only;
53668 diff --git a/fs/ocfs2/localalloc.c b/fs/ocfs2/localalloc.c
53669 index a9f78c7..ed8a381 100644
53670 --- a/fs/ocfs2/localalloc.c
53671 +++ b/fs/ocfs2/localalloc.c
53672 @@ -1279,7 +1279,7 @@ static int ocfs2_local_alloc_slide_window(struct ocfs2_super *osb,
53673 goto bail;
53674 }
53675
53676 - atomic_inc(&osb->alloc_stats.moves);
53677 + atomic_inc_unchecked(&osb->alloc_stats.moves);
53678
53679 bail:
53680 if (handle)
53681 diff --git a/fs/ocfs2/ocfs2.h b/fs/ocfs2/ocfs2.h
53682 index d355e6e..578d905 100644
53683 --- a/fs/ocfs2/ocfs2.h
53684 +++ b/fs/ocfs2/ocfs2.h
53685 @@ -235,11 +235,11 @@ enum ocfs2_vol_state
53686
53687 struct ocfs2_alloc_stats
53688 {
53689 - atomic_t moves;
53690 - atomic_t local_data;
53691 - atomic_t bitmap_data;
53692 - atomic_t bg_allocs;
53693 - atomic_t bg_extends;
53694 + atomic_unchecked_t moves;
53695 + atomic_unchecked_t local_data;
53696 + atomic_unchecked_t bitmap_data;
53697 + atomic_unchecked_t bg_allocs;
53698 + atomic_unchecked_t bg_extends;
53699 };
53700
53701 enum ocfs2_local_alloc_state
53702 diff --git a/fs/ocfs2/suballoc.c b/fs/ocfs2/suballoc.c
53703 index b7e74b5..19c6536 100644
53704 --- a/fs/ocfs2/suballoc.c
53705 +++ b/fs/ocfs2/suballoc.c
53706 @@ -872,7 +872,7 @@ static int ocfs2_reserve_suballoc_bits(struct ocfs2_super *osb,
53707 mlog_errno(status);
53708 goto bail;
53709 }
53710 - atomic_inc(&osb->alloc_stats.bg_extends);
53711 + atomic_inc_unchecked(&osb->alloc_stats.bg_extends);
53712
53713 /* You should never ask for this much metadata */
53714 BUG_ON(bits_wanted >
53715 @@ -2007,7 +2007,7 @@ int ocfs2_claim_metadata(handle_t *handle,
53716 mlog_errno(status);
53717 goto bail;
53718 }
53719 - atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
53720 + atomic_inc_unchecked(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
53721
53722 *suballoc_loc = res.sr_bg_blkno;
53723 *suballoc_bit_start = res.sr_bit_offset;
53724 @@ -2171,7 +2171,7 @@ int ocfs2_claim_new_inode_at_loc(handle_t *handle,
53725 trace_ocfs2_claim_new_inode_at_loc((unsigned long long)di_blkno,
53726 res->sr_bits);
53727
53728 - atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
53729 + atomic_inc_unchecked(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
53730
53731 BUG_ON(res->sr_bits != 1);
53732
53733 @@ -2213,7 +2213,7 @@ int ocfs2_claim_new_inode(handle_t *handle,
53734 mlog_errno(status);
53735 goto bail;
53736 }
53737 - atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
53738 + atomic_inc_unchecked(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
53739
53740 BUG_ON(res.sr_bits != 1);
53741
53742 @@ -2317,7 +2317,7 @@ int __ocfs2_claim_clusters(handle_t *handle,
53743 cluster_start,
53744 num_clusters);
53745 if (!status)
53746 - atomic_inc(&osb->alloc_stats.local_data);
53747 + atomic_inc_unchecked(&osb->alloc_stats.local_data);
53748 } else {
53749 if (min_clusters > (osb->bitmap_cpg - 1)) {
53750 /* The only paths asking for contiguousness
53751 @@ -2343,7 +2343,7 @@ int __ocfs2_claim_clusters(handle_t *handle,
53752 ocfs2_desc_bitmap_to_cluster_off(ac->ac_inode,
53753 res.sr_bg_blkno,
53754 res.sr_bit_offset);
53755 - atomic_inc(&osb->alloc_stats.bitmap_data);
53756 + atomic_inc_unchecked(&osb->alloc_stats.bitmap_data);
53757 *num_clusters = res.sr_bits;
53758 }
53759 }
53760 diff --git a/fs/ocfs2/super.c b/fs/ocfs2/super.c
53761 index 0e91ec2..f4b3fc6 100644
53762 --- a/fs/ocfs2/super.c
53763 +++ b/fs/ocfs2/super.c
53764 @@ -301,11 +301,11 @@ static int ocfs2_osb_dump(struct ocfs2_super *osb, char *buf, int len)
53765 "%10s => GlobalAllocs: %d LocalAllocs: %d "
53766 "SubAllocs: %d LAWinMoves: %d SAExtends: %d\n",
53767 "Stats",
53768 - atomic_read(&osb->alloc_stats.bitmap_data),
53769 - atomic_read(&osb->alloc_stats.local_data),
53770 - atomic_read(&osb->alloc_stats.bg_allocs),
53771 - atomic_read(&osb->alloc_stats.moves),
53772 - atomic_read(&osb->alloc_stats.bg_extends));
53773 + atomic_read_unchecked(&osb->alloc_stats.bitmap_data),
53774 + atomic_read_unchecked(&osb->alloc_stats.local_data),
53775 + atomic_read_unchecked(&osb->alloc_stats.bg_allocs),
53776 + atomic_read_unchecked(&osb->alloc_stats.moves),
53777 + atomic_read_unchecked(&osb->alloc_stats.bg_extends));
53778
53779 out += snprintf(buf + out, len - out,
53780 "%10s => State: %u Descriptor: %llu Size: %u bits "
53781 @@ -2121,11 +2121,11 @@ static int ocfs2_initialize_super(struct super_block *sb,
53782 spin_lock_init(&osb->osb_xattr_lock);
53783 ocfs2_init_steal_slots(osb);
53784
53785 - atomic_set(&osb->alloc_stats.moves, 0);
53786 - atomic_set(&osb->alloc_stats.local_data, 0);
53787 - atomic_set(&osb->alloc_stats.bitmap_data, 0);
53788 - atomic_set(&osb->alloc_stats.bg_allocs, 0);
53789 - atomic_set(&osb->alloc_stats.bg_extends, 0);
53790 + atomic_set_unchecked(&osb->alloc_stats.moves, 0);
53791 + atomic_set_unchecked(&osb->alloc_stats.local_data, 0);
53792 + atomic_set_unchecked(&osb->alloc_stats.bitmap_data, 0);
53793 + atomic_set_unchecked(&osb->alloc_stats.bg_allocs, 0);
53794 + atomic_set_unchecked(&osb->alloc_stats.bg_extends, 0);
53795
53796 /* Copy the blockcheck stats from the superblock probe */
53797 osb->osb_ecc_stats = *stats;
53798 diff --git a/fs/open.c b/fs/open.c
53799 index 9b33c0c..2ffcca2 100644
53800 --- a/fs/open.c
53801 +++ b/fs/open.c
53802 @@ -31,6 +31,8 @@
53803 #include <linux/ima.h>
53804 #include <linux/dnotify.h>
53805
53806 +#define CREATE_TRACE_POINTS
53807 +#include <trace/events/fs.h>
53808 #include "internal.h"
53809
53810 int do_truncate(struct dentry *dentry, loff_t length, unsigned int time_attrs,
53811 @@ -101,6 +103,8 @@ long vfs_truncate(struct path *path, loff_t length)
53812 error = locks_verify_truncate(inode, NULL, length);
53813 if (!error)
53814 error = security_path_truncate(path);
53815 + if (!error && !gr_acl_handle_truncate(path->dentry, path->mnt))
53816 + error = -EACCES;
53817 if (!error)
53818 error = do_truncate(path->dentry, length, 0, NULL);
53819
53820 @@ -178,6 +182,8 @@ static long do_sys_ftruncate(unsigned int fd, loff_t length, int small)
53821 error = locks_verify_truncate(inode, f.file, length);
53822 if (!error)
53823 error = security_path_truncate(&f.file->f_path);
53824 + if (!error && !gr_acl_handle_truncate(f.file->f_path.dentry, f.file->f_path.mnt))
53825 + error = -EACCES;
53826 if (!error)
53827 error = do_truncate(dentry, length, ATTR_MTIME|ATTR_CTIME, f.file);
53828 sb_end_write(inode->i_sb);
53829 @@ -373,6 +379,9 @@ retry:
53830 if (__mnt_is_readonly(path.mnt))
53831 res = -EROFS;
53832
53833 + if (!res && !gr_acl_handle_access(path.dentry, path.mnt, mode))
53834 + res = -EACCES;
53835 +
53836 out_path_release:
53837 path_put(&path);
53838 if (retry_estale(res, lookup_flags)) {
53839 @@ -404,6 +413,8 @@ retry:
53840 if (error)
53841 goto dput_and_out;
53842
53843 + gr_log_chdir(path.dentry, path.mnt);
53844 +
53845 set_fs_pwd(current->fs, &path);
53846
53847 dput_and_out:
53848 @@ -433,6 +444,13 @@ SYSCALL_DEFINE1(fchdir, unsigned int, fd)
53849 goto out_putf;
53850
53851 error = inode_permission(inode, MAY_EXEC | MAY_CHDIR);
53852 +
53853 + if (!error && !gr_chroot_fchdir(f.file->f_path.dentry, f.file->f_path.mnt))
53854 + error = -EPERM;
53855 +
53856 + if (!error)
53857 + gr_log_chdir(f.file->f_path.dentry, f.file->f_path.mnt);
53858 +
53859 if (!error)
53860 set_fs_pwd(current->fs, &f.file->f_path);
53861 out_putf:
53862 @@ -462,7 +480,13 @@ retry:
53863 if (error)
53864 goto dput_and_out;
53865
53866 + if (gr_handle_chroot_chroot(path.dentry, path.mnt))
53867 + goto dput_and_out;
53868 +
53869 set_fs_root(current->fs, &path);
53870 +
53871 + gr_handle_chroot_chdir(&path);
53872 +
53873 error = 0;
53874 dput_and_out:
53875 path_put(&path);
53876 @@ -484,6 +508,16 @@ static int chmod_common(struct path *path, umode_t mode)
53877 if (error)
53878 return error;
53879 mutex_lock(&inode->i_mutex);
53880 +
53881 + if (!gr_acl_handle_chmod(path->dentry, path->mnt, &mode)) {
53882 + error = -EACCES;
53883 + goto out_unlock;
53884 + }
53885 + if (gr_handle_chroot_chmod(path->dentry, path->mnt, mode)) {
53886 + error = -EACCES;
53887 + goto out_unlock;
53888 + }
53889 +
53890 error = security_path_chmod(path, mode);
53891 if (error)
53892 goto out_unlock;
53893 @@ -544,6 +578,9 @@ static int chown_common(struct path *path, uid_t user, gid_t group)
53894 uid = make_kuid(current_user_ns(), user);
53895 gid = make_kgid(current_user_ns(), group);
53896
53897 + if (!gr_acl_handle_chown(path->dentry, path->mnt))
53898 + return -EACCES;
53899 +
53900 newattrs.ia_valid = ATTR_CTIME;
53901 if (user != (uid_t) -1) {
53902 if (!uid_valid(uid))
53903 @@ -960,6 +997,7 @@ long do_sys_open(int dfd, const char __user *filename, int flags, umode_t mode)
53904 } else {
53905 fsnotify_open(f);
53906 fd_install(fd, f);
53907 + trace_do_sys_open(tmp->name, flags, mode);
53908 }
53909 }
53910 putname(tmp);
53911 diff --git a/fs/pipe.c b/fs/pipe.c
53912 index 8e2e73f..1ef1048 100644
53913 --- a/fs/pipe.c
53914 +++ b/fs/pipe.c
53915 @@ -438,9 +438,9 @@ redo:
53916 }
53917 if (bufs) /* More to do? */
53918 continue;
53919 - if (!pipe->writers)
53920 + if (!atomic_read(&pipe->writers))
53921 break;
53922 - if (!pipe->waiting_writers) {
53923 + if (!atomic_read(&pipe->waiting_writers)) {
53924 /* syscall merging: Usually we must not sleep
53925 * if O_NONBLOCK is set, or if we got some data.
53926 * But if a writer sleeps in kernel space, then
53927 @@ -504,7 +504,7 @@ pipe_write(struct kiocb *iocb, const struct iovec *_iov,
53928 mutex_lock(&inode->i_mutex);
53929 pipe = inode->i_pipe;
53930
53931 - if (!pipe->readers) {
53932 + if (!atomic_read(&pipe->readers)) {
53933 send_sig(SIGPIPE, current, 0);
53934 ret = -EPIPE;
53935 goto out;
53936 @@ -553,7 +553,7 @@ redo1:
53937 for (;;) {
53938 int bufs;
53939
53940 - if (!pipe->readers) {
53941 + if (!atomic_read(&pipe->readers)) {
53942 send_sig(SIGPIPE, current, 0);
53943 if (!ret)
53944 ret = -EPIPE;
53945 @@ -644,9 +644,9 @@ redo2:
53946 kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN);
53947 do_wakeup = 0;
53948 }
53949 - pipe->waiting_writers++;
53950 + atomic_inc(&pipe->waiting_writers);
53951 pipe_wait(pipe);
53952 - pipe->waiting_writers--;
53953 + atomic_dec(&pipe->waiting_writers);
53954 }
53955 out:
53956 mutex_unlock(&inode->i_mutex);
53957 @@ -716,7 +716,7 @@ pipe_poll(struct file *filp, poll_table *wait)
53958 mask = 0;
53959 if (filp->f_mode & FMODE_READ) {
53960 mask = (nrbufs > 0) ? POLLIN | POLLRDNORM : 0;
53961 - if (!pipe->writers && filp->f_version != pipe->w_counter)
53962 + if (!atomic_read(&pipe->writers) && filp->f_version != pipe->w_counter)
53963 mask |= POLLHUP;
53964 }
53965
53966 @@ -726,7 +726,7 @@ pipe_poll(struct file *filp, poll_table *wait)
53967 * Most Unices do not set POLLERR for FIFOs but on Linux they
53968 * behave exactly like pipes for poll().
53969 */
53970 - if (!pipe->readers)
53971 + if (!atomic_read(&pipe->readers))
53972 mask |= POLLERR;
53973 }
53974
53975 @@ -740,10 +740,10 @@ pipe_release(struct inode *inode, int decr, int decw)
53976
53977 mutex_lock(&inode->i_mutex);
53978 pipe = inode->i_pipe;
53979 - pipe->readers -= decr;
53980 - pipe->writers -= decw;
53981 + atomic_sub(decr, &pipe->readers);
53982 + atomic_sub(decw, &pipe->writers);
53983
53984 - if (!pipe->readers && !pipe->writers) {
53985 + if (!atomic_read(&pipe->readers) && !atomic_read(&pipe->writers)) {
53986 free_pipe_info(inode);
53987 } else {
53988 wake_up_interruptible_sync_poll(&pipe->wait, POLLIN | POLLOUT | POLLRDNORM | POLLWRNORM | POLLERR | POLLHUP);
53989 @@ -833,7 +833,7 @@ pipe_read_open(struct inode *inode, struct file *filp)
53990
53991 if (inode->i_pipe) {
53992 ret = 0;
53993 - inode->i_pipe->readers++;
53994 + atomic_inc(&inode->i_pipe->readers);
53995 }
53996
53997 mutex_unlock(&inode->i_mutex);
53998 @@ -850,7 +850,7 @@ pipe_write_open(struct inode *inode, struct file *filp)
53999
54000 if (inode->i_pipe) {
54001 ret = 0;
54002 - inode->i_pipe->writers++;
54003 + atomic_inc(&inode->i_pipe->writers);
54004 }
54005
54006 mutex_unlock(&inode->i_mutex);
54007 @@ -871,9 +871,9 @@ pipe_rdwr_open(struct inode *inode, struct file *filp)
54008 if (inode->i_pipe) {
54009 ret = 0;
54010 if (filp->f_mode & FMODE_READ)
54011 - inode->i_pipe->readers++;
54012 + atomic_inc(&inode->i_pipe->readers);
54013 if (filp->f_mode & FMODE_WRITE)
54014 - inode->i_pipe->writers++;
54015 + atomic_inc(&inode->i_pipe->writers);
54016 }
54017
54018 mutex_unlock(&inode->i_mutex);
54019 @@ -965,7 +965,7 @@ void free_pipe_info(struct inode *inode)
54020 inode->i_pipe = NULL;
54021 }
54022
54023 -static struct vfsmount *pipe_mnt __read_mostly;
54024 +struct vfsmount *pipe_mnt __read_mostly;
54025
54026 /*
54027 * pipefs_dname() is called from d_path().
54028 @@ -995,7 +995,8 @@ static struct inode * get_pipe_inode(void)
54029 goto fail_iput;
54030 inode->i_pipe = pipe;
54031
54032 - pipe->readers = pipe->writers = 1;
54033 + atomic_set(&pipe->readers, 1);
54034 + atomic_set(&pipe->writers, 1);
54035 inode->i_fop = &rdwr_pipefifo_fops;
54036
54037 /*
54038 diff --git a/fs/proc/Kconfig b/fs/proc/Kconfig
54039 index 15af622..0e9f4467 100644
54040 --- a/fs/proc/Kconfig
54041 +++ b/fs/proc/Kconfig
54042 @@ -30,12 +30,12 @@ config PROC_FS
54043
54044 config PROC_KCORE
54045 bool "/proc/kcore support" if !ARM
54046 - depends on PROC_FS && MMU
54047 + depends on PROC_FS && MMU && !GRKERNSEC_PROC_ADD
54048
54049 config PROC_VMCORE
54050 bool "/proc/vmcore support"
54051 - depends on PROC_FS && CRASH_DUMP
54052 - default y
54053 + depends on PROC_FS && CRASH_DUMP && !GRKERNSEC
54054 + default n
54055 help
54056 Exports the dump image of crashed kernel in ELF format.
54057
54058 @@ -59,8 +59,8 @@ config PROC_SYSCTL
54059 limited in memory.
54060
54061 config PROC_PAGE_MONITOR
54062 - default y
54063 - depends on PROC_FS && MMU
54064 + default n
54065 + depends on PROC_FS && MMU && !GRKERNSEC
54066 bool "Enable /proc page monitoring" if EXPERT
54067 help
54068 Various /proc files exist to monitor process memory utilization:
54069 diff --git a/fs/proc/array.c b/fs/proc/array.c
54070 index 6a91e6f..e54dbc14 100644
54071 --- a/fs/proc/array.c
54072 +++ b/fs/proc/array.c
54073 @@ -60,6 +60,7 @@
54074 #include <linux/tty.h>
54075 #include <linux/string.h>
54076 #include <linux/mman.h>
54077 +#include <linux/grsecurity.h>
54078 #include <linux/proc_fs.h>
54079 #include <linux/ioport.h>
54080 #include <linux/uaccess.h>
54081 @@ -362,6 +363,21 @@ static void task_cpus_allowed(struct seq_file *m, struct task_struct *task)
54082 seq_putc(m, '\n');
54083 }
54084
54085 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
54086 +static inline void task_pax(struct seq_file *m, struct task_struct *p)
54087 +{
54088 + if (p->mm)
54089 + seq_printf(m, "PaX:\t%c%c%c%c%c\n",
54090 + p->mm->pax_flags & MF_PAX_PAGEEXEC ? 'P' : 'p',
54091 + p->mm->pax_flags & MF_PAX_EMUTRAMP ? 'E' : 'e',
54092 + p->mm->pax_flags & MF_PAX_MPROTECT ? 'M' : 'm',
54093 + p->mm->pax_flags & MF_PAX_RANDMMAP ? 'R' : 'r',
54094 + p->mm->pax_flags & MF_PAX_SEGMEXEC ? 'S' : 's');
54095 + else
54096 + seq_printf(m, "PaX:\t-----\n");
54097 +}
54098 +#endif
54099 +
54100 int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
54101 struct pid *pid, struct task_struct *task)
54102 {
54103 @@ -380,9 +396,24 @@ int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
54104 task_cpus_allowed(m, task);
54105 cpuset_task_status_allowed(m, task);
54106 task_context_switch_counts(m, task);
54107 +
54108 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
54109 + task_pax(m, task);
54110 +#endif
54111 +
54112 +#if defined(CONFIG_GRKERNSEC) && !defined(CONFIG_GRKERNSEC_NO_RBAC)
54113 + task_grsec_rbac(m, task);
54114 +#endif
54115 +
54116 return 0;
54117 }
54118
54119 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
54120 +#define PAX_RAND_FLAGS(_mm) (_mm != NULL && _mm != current->mm && \
54121 + (_mm->pax_flags & MF_PAX_RANDMMAP || \
54122 + _mm->pax_flags & MF_PAX_SEGMEXEC))
54123 +#endif
54124 +
54125 static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
54126 struct pid *pid, struct task_struct *task, int whole)
54127 {
54128 @@ -404,6 +435,13 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
54129 char tcomm[sizeof(task->comm)];
54130 unsigned long flags;
54131
54132 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
54133 + if (current->exec_id != m->exec_id) {
54134 + gr_log_badprocpid("stat");
54135 + return 0;
54136 + }
54137 +#endif
54138 +
54139 state = *get_task_state(task);
54140 vsize = eip = esp = 0;
54141 permitted = ptrace_may_access(task, PTRACE_MODE_READ | PTRACE_MODE_NOAUDIT);
54142 @@ -475,6 +513,19 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
54143 gtime = task->gtime;
54144 }
54145
54146 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
54147 + if (PAX_RAND_FLAGS(mm)) {
54148 + eip = 0;
54149 + esp = 0;
54150 + wchan = 0;
54151 + }
54152 +#endif
54153 +#ifdef CONFIG_GRKERNSEC_HIDESYM
54154 + wchan = 0;
54155 + eip =0;
54156 + esp =0;
54157 +#endif
54158 +
54159 /* scale priority and nice values from timeslices to -20..20 */
54160 /* to make it look like a "normal" Unix priority/nice value */
54161 priority = task_prio(task);
54162 @@ -511,9 +562,15 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
54163 seq_put_decimal_ull(m, ' ', vsize);
54164 seq_put_decimal_ull(m, ' ', mm ? get_mm_rss(mm) : 0);
54165 seq_put_decimal_ull(m, ' ', rsslim);
54166 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
54167 + seq_put_decimal_ull(m, ' ', PAX_RAND_FLAGS(mm) ? 1 : (mm ? (permitted ? mm->start_code : 1) : 0));
54168 + seq_put_decimal_ull(m, ' ', PAX_RAND_FLAGS(mm) ? 1 : (mm ? (permitted ? mm->end_code : 1) : 0));
54169 + seq_put_decimal_ull(m, ' ', PAX_RAND_FLAGS(mm) ? 0 : ((permitted && mm) ? mm->start_stack : 0));
54170 +#else
54171 seq_put_decimal_ull(m, ' ', mm ? (permitted ? mm->start_code : 1) : 0);
54172 seq_put_decimal_ull(m, ' ', mm ? (permitted ? mm->end_code : 1) : 0);
54173 seq_put_decimal_ull(m, ' ', (permitted && mm) ? mm->start_stack : 0);
54174 +#endif
54175 seq_put_decimal_ull(m, ' ', esp);
54176 seq_put_decimal_ull(m, ' ', eip);
54177 /* The signal information here is obsolete.
54178 @@ -535,7 +592,11 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
54179 seq_put_decimal_ull(m, ' ', cputime_to_clock_t(gtime));
54180 seq_put_decimal_ll(m, ' ', cputime_to_clock_t(cgtime));
54181
54182 - if (mm && permitted) {
54183 + if (mm && permitted
54184 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
54185 + && !PAX_RAND_FLAGS(mm)
54186 +#endif
54187 + ) {
54188 seq_put_decimal_ull(m, ' ', mm->start_data);
54189 seq_put_decimal_ull(m, ' ', mm->end_data);
54190 seq_put_decimal_ull(m, ' ', mm->start_brk);
54191 @@ -573,8 +634,15 @@ int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns,
54192 struct pid *pid, struct task_struct *task)
54193 {
54194 unsigned long size = 0, resident = 0, shared = 0, text = 0, data = 0;
54195 - struct mm_struct *mm = get_task_mm(task);
54196 + struct mm_struct *mm;
54197
54198 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
54199 + if (current->exec_id != m->exec_id) {
54200 + gr_log_badprocpid("statm");
54201 + return 0;
54202 + }
54203 +#endif
54204 + mm = get_task_mm(task);
54205 if (mm) {
54206 size = task_statm(mm, &shared, &text, &data, &resident);
54207 mmput(mm);
54208 @@ -597,6 +665,13 @@ int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns,
54209 return 0;
54210 }
54211
54212 +#ifdef CONFIG_GRKERNSEC_PROC_IPADDR
54213 +int proc_pid_ipaddr(struct task_struct *task, char *buffer)
54214 +{
54215 + return sprintf(buffer, "%pI4\n", &task->signal->curr_ip);
54216 +}
54217 +#endif
54218 +
54219 #ifdef CONFIG_CHECKPOINT_RESTORE
54220 static struct pid *
54221 get_children_pid(struct inode *inode, struct pid *pid_prev, loff_t pos)
54222 diff --git a/fs/proc/base.c b/fs/proc/base.c
54223 index 9b43ff77..ba3e990 100644
54224 --- a/fs/proc/base.c
54225 +++ b/fs/proc/base.c
54226 @@ -111,6 +111,14 @@ struct pid_entry {
54227 union proc_op op;
54228 };
54229
54230 +struct getdents_callback {
54231 + struct linux_dirent __user * current_dir;
54232 + struct linux_dirent __user * previous;
54233 + struct file * file;
54234 + int count;
54235 + int error;
54236 +};
54237 +
54238 #define NOD(NAME, MODE, IOP, FOP, OP) { \
54239 .name = (NAME), \
54240 .len = sizeof(NAME) - 1, \
54241 @@ -208,6 +216,9 @@ static int proc_pid_cmdline(struct task_struct *task, char * buffer)
54242 if (!mm->arg_end)
54243 goto out_mm; /* Shh! No looking before we're done */
54244
54245 + if (gr_acl_handle_procpidmem(task))
54246 + goto out_mm;
54247 +
54248 len = mm->arg_end - mm->arg_start;
54249
54250 if (len > PAGE_SIZE)
54251 @@ -235,12 +246,28 @@ out:
54252 return res;
54253 }
54254
54255 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
54256 +#define PAX_RAND_FLAGS(_mm) (_mm != NULL && _mm != current->mm && \
54257 + (_mm->pax_flags & MF_PAX_RANDMMAP || \
54258 + _mm->pax_flags & MF_PAX_SEGMEXEC))
54259 +#endif
54260 +
54261 static int proc_pid_auxv(struct task_struct *task, char *buffer)
54262 {
54263 struct mm_struct *mm = mm_access(task, PTRACE_MODE_READ);
54264 int res = PTR_ERR(mm);
54265 if (mm && !IS_ERR(mm)) {
54266 unsigned int nwords = 0;
54267 +
54268 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
54269 + /* allow if we're currently ptracing this task */
54270 + if (PAX_RAND_FLAGS(mm) &&
54271 + (!(task->ptrace & PT_PTRACED) || (task->parent != current))) {
54272 + mmput(mm);
54273 + return 0;
54274 + }
54275 +#endif
54276 +
54277 do {
54278 nwords += 2;
54279 } while (mm->saved_auxv[nwords - 2] != 0); /* AT_NULL */
54280 @@ -254,7 +281,7 @@ static int proc_pid_auxv(struct task_struct *task, char *buffer)
54281 }
54282
54283
54284 -#ifdef CONFIG_KALLSYMS
54285 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
54286 /*
54287 * Provides a wchan file via kallsyms in a proper one-value-per-file format.
54288 * Returns the resolved symbol. If that fails, simply return the address.
54289 @@ -293,7 +320,7 @@ static void unlock_trace(struct task_struct *task)
54290 mutex_unlock(&task->signal->cred_guard_mutex);
54291 }
54292
54293 -#ifdef CONFIG_STACKTRACE
54294 +#if defined(CONFIG_STACKTRACE) && !defined(CONFIG_GRKERNSEC_HIDESYM)
54295
54296 #define MAX_STACK_TRACE_DEPTH 64
54297
54298 @@ -485,7 +512,7 @@ static int proc_pid_limits(struct task_struct *task, char *buffer)
54299 return count;
54300 }
54301
54302 -#ifdef CONFIG_HAVE_ARCH_TRACEHOOK
54303 +#if defined(CONFIG_HAVE_ARCH_TRACEHOOK) && !defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
54304 static int proc_pid_syscall(struct task_struct *task, char *buffer)
54305 {
54306 long nr;
54307 @@ -514,7 +541,7 @@ static int proc_pid_syscall(struct task_struct *task, char *buffer)
54308 /************************************************************************/
54309
54310 /* permission checks */
54311 -static int proc_fd_access_allowed(struct inode *inode)
54312 +static int proc_fd_access_allowed(struct inode *inode, unsigned int log)
54313 {
54314 struct task_struct *task;
54315 int allowed = 0;
54316 @@ -524,7 +551,10 @@ static int proc_fd_access_allowed(struct inode *inode)
54317 */
54318 task = get_proc_task(inode);
54319 if (task) {
54320 - allowed = ptrace_may_access(task, PTRACE_MODE_READ);
54321 + if (log)
54322 + allowed = ptrace_may_access(task, PTRACE_MODE_READ);
54323 + else
54324 + allowed = ptrace_may_access(task, PTRACE_MODE_READ | PTRACE_MODE_NOAUDIT);
54325 put_task_struct(task);
54326 }
54327 return allowed;
54328 @@ -555,10 +585,35 @@ static bool has_pid_permissions(struct pid_namespace *pid,
54329 struct task_struct *task,
54330 int hide_pid_min)
54331 {
54332 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
54333 + return false;
54334 +
54335 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
54336 + rcu_read_lock();
54337 + {
54338 + const struct cred *tmpcred = current_cred();
54339 + const struct cred *cred = __task_cred(task);
54340 +
54341 + if (uid_eq(tmpcred->uid, GLOBAL_ROOT_UID) || uid_eq(tmpcred->uid, cred->uid)
54342 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
54343 + || in_group_p(grsec_proc_gid)
54344 +#endif
54345 + ) {
54346 + rcu_read_unlock();
54347 + return true;
54348 + }
54349 + }
54350 + rcu_read_unlock();
54351 +
54352 + if (!pid->hide_pid)
54353 + return false;
54354 +#endif
54355 +
54356 if (pid->hide_pid < hide_pid_min)
54357 return true;
54358 if (in_group_p(pid->pid_gid))
54359 return true;
54360 +
54361 return ptrace_may_access(task, PTRACE_MODE_READ);
54362 }
54363
54364 @@ -576,7 +631,11 @@ static int proc_pid_permission(struct inode *inode, int mask)
54365 put_task_struct(task);
54366
54367 if (!has_perms) {
54368 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
54369 + {
54370 +#else
54371 if (pid->hide_pid == 2) {
54372 +#endif
54373 /*
54374 * Let's make getdents(), stat(), and open()
54375 * consistent with each other. If a process
54376 @@ -674,6 +733,11 @@ static int __mem_open(struct inode *inode, struct file *file, unsigned int mode)
54377 if (!task)
54378 return -ESRCH;
54379
54380 + if (gr_acl_handle_procpidmem(task)) {
54381 + put_task_struct(task);
54382 + return -EPERM;
54383 + }
54384 +
54385 mm = mm_access(task, mode);
54386 put_task_struct(task);
54387
54388 @@ -689,6 +753,10 @@ static int __mem_open(struct inode *inode, struct file *file, unsigned int mode)
54389
54390 file->private_data = mm;
54391
54392 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
54393 + file->f_version = current->exec_id;
54394 +#endif
54395 +
54396 return 0;
54397 }
54398
54399 @@ -710,6 +778,17 @@ static ssize_t mem_rw(struct file *file, char __user *buf,
54400 ssize_t copied;
54401 char *page;
54402
54403 +#ifdef CONFIG_GRKERNSEC
54404 + if (write)
54405 + return -EPERM;
54406 +#endif
54407 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
54408 + if (file->f_version != current->exec_id) {
54409 + gr_log_badprocpid("mem");
54410 + return 0;
54411 + }
54412 +#endif
54413 +
54414 if (!mm)
54415 return 0;
54416
54417 @@ -814,6 +893,13 @@ static ssize_t environ_read(struct file *file, char __user *buf,
54418 if (!mm)
54419 return 0;
54420
54421 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
54422 + if (file->f_version != current->exec_id) {
54423 + gr_log_badprocpid("environ");
54424 + return 0;
54425 + }
54426 +#endif
54427 +
54428 page = (char *)__get_free_page(GFP_TEMPORARY);
54429 if (!page)
54430 return -ENOMEM;
54431 @@ -1429,7 +1515,7 @@ static void *proc_pid_follow_link(struct dentry *dentry, struct nameidata *nd)
54432 int error = -EACCES;
54433
54434 /* Are we allowed to snoop on the tasks file descriptors? */
54435 - if (!proc_fd_access_allowed(inode))
54436 + if (!proc_fd_access_allowed(inode, 0))
54437 goto out;
54438
54439 error = PROC_I(inode)->op.proc_get_link(dentry, &path);
54440 @@ -1473,8 +1559,18 @@ static int proc_pid_readlink(struct dentry * dentry, char __user * buffer, int b
54441 struct path path;
54442
54443 /* Are we allowed to snoop on the tasks file descriptors? */
54444 - if (!proc_fd_access_allowed(inode))
54445 - goto out;
54446 + /* logging this is needed for learning on chromium to work properly,
54447 + but we don't want to flood the logs from 'ps' which does a readlink
54448 + on /proc/fd/2 of tasks in the listing, nor do we want 'ps' to learn
54449 + CAP_SYS_PTRACE as it's not necessary for its basic functionality
54450 + */
54451 + if (dentry->d_name.name[0] == '2' && dentry->d_name.name[1] == '\0') {
54452 + if (!proc_fd_access_allowed(inode,0))
54453 + goto out;
54454 + } else {
54455 + if (!proc_fd_access_allowed(inode,1))
54456 + goto out;
54457 + }
54458
54459 error = PROC_I(inode)->op.proc_get_link(dentry, &path);
54460 if (error)
54461 @@ -1524,7 +1620,11 @@ struct inode *proc_pid_make_inode(struct super_block * sb, struct task_struct *t
54462 rcu_read_lock();
54463 cred = __task_cred(task);
54464 inode->i_uid = cred->euid;
54465 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
54466 + inode->i_gid = grsec_proc_gid;
54467 +#else
54468 inode->i_gid = cred->egid;
54469 +#endif
54470 rcu_read_unlock();
54471 }
54472 security_task_to_inode(task, inode);
54473 @@ -1560,10 +1660,19 @@ int pid_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat)
54474 return -ENOENT;
54475 }
54476 if ((inode->i_mode == (S_IFDIR|S_IRUGO|S_IXUGO)) ||
54477 +#ifdef CONFIG_GRKERNSEC_PROC_USER
54478 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IXUSR)) ||
54479 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
54480 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IRGRP|S_IXUSR|S_IXGRP)) ||
54481 +#endif
54482 task_dumpable(task)) {
54483 cred = __task_cred(task);
54484 stat->uid = cred->euid;
54485 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
54486 + stat->gid = grsec_proc_gid;
54487 +#else
54488 stat->gid = cred->egid;
54489 +#endif
54490 }
54491 }
54492 rcu_read_unlock();
54493 @@ -1601,11 +1710,20 @@ int pid_revalidate(struct dentry *dentry, unsigned int flags)
54494
54495 if (task) {
54496 if ((inode->i_mode == (S_IFDIR|S_IRUGO|S_IXUGO)) ||
54497 +#ifdef CONFIG_GRKERNSEC_PROC_USER
54498 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IXUSR)) ||
54499 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
54500 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IRGRP|S_IXUSR|S_IXGRP)) ||
54501 +#endif
54502 task_dumpable(task)) {
54503 rcu_read_lock();
54504 cred = __task_cred(task);
54505 inode->i_uid = cred->euid;
54506 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
54507 + inode->i_gid = grsec_proc_gid;
54508 +#else
54509 inode->i_gid = cred->egid;
54510 +#endif
54511 rcu_read_unlock();
54512 } else {
54513 inode->i_uid = GLOBAL_ROOT_UID;
54514 @@ -2058,6 +2176,9 @@ static struct dentry *proc_pident_lookup(struct inode *dir,
54515 if (!task)
54516 goto out_no_task;
54517
54518 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
54519 + goto out;
54520 +
54521 /*
54522 * Yes, it does not scale. And it should not. Don't add
54523 * new entries into /proc/<tgid>/ without very good reasons.
54524 @@ -2102,6 +2223,9 @@ static int proc_pident_readdir(struct file *filp,
54525 if (!task)
54526 goto out_no_task;
54527
54528 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
54529 + goto out;
54530 +
54531 ret = 0;
54532 i = filp->f_pos;
54533 switch (i) {
54534 @@ -2515,7 +2639,7 @@ static const struct pid_entry tgid_base_stuff[] = {
54535 REG("autogroup", S_IRUGO|S_IWUSR, proc_pid_sched_autogroup_operations),
54536 #endif
54537 REG("comm", S_IRUGO|S_IWUSR, proc_pid_set_comm_operations),
54538 -#ifdef CONFIG_HAVE_ARCH_TRACEHOOK
54539 +#if defined(CONFIG_HAVE_ARCH_TRACEHOOK) && !defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
54540 INF("syscall", S_IRUGO, proc_pid_syscall),
54541 #endif
54542 INF("cmdline", S_IRUGO, proc_pid_cmdline),
54543 @@ -2540,10 +2664,10 @@ static const struct pid_entry tgid_base_stuff[] = {
54544 #ifdef CONFIG_SECURITY
54545 DIR("attr", S_IRUGO|S_IXUGO, proc_attr_dir_inode_operations, proc_attr_dir_operations),
54546 #endif
54547 -#ifdef CONFIG_KALLSYMS
54548 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
54549 INF("wchan", S_IRUGO, proc_pid_wchan),
54550 #endif
54551 -#ifdef CONFIG_STACKTRACE
54552 +#if defined(CONFIG_STACKTRACE) && !defined(CONFIG_GRKERNSEC_HIDESYM)
54553 ONE("stack", S_IRUGO, proc_pid_stack),
54554 #endif
54555 #ifdef CONFIG_SCHEDSTATS
54556 @@ -2577,6 +2701,9 @@ static const struct pid_entry tgid_base_stuff[] = {
54557 #ifdef CONFIG_HARDWALL
54558 INF("hardwall", S_IRUGO, proc_pid_hardwall),
54559 #endif
54560 +#ifdef CONFIG_GRKERNSEC_PROC_IPADDR
54561 + INF("ipaddr", S_IRUSR, proc_pid_ipaddr),
54562 +#endif
54563 #ifdef CONFIG_USER_NS
54564 REG("uid_map", S_IRUGO|S_IWUSR, proc_uid_map_operations),
54565 REG("gid_map", S_IRUGO|S_IWUSR, proc_gid_map_operations),
54566 @@ -2705,7 +2832,14 @@ static struct dentry *proc_pid_instantiate(struct inode *dir,
54567 if (!inode)
54568 goto out;
54569
54570 +#ifdef CONFIG_GRKERNSEC_PROC_USER
54571 + inode->i_mode = S_IFDIR|S_IRUSR|S_IXUSR;
54572 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
54573 + inode->i_gid = grsec_proc_gid;
54574 + inode->i_mode = S_IFDIR|S_IRUSR|S_IRGRP|S_IXUSR|S_IXGRP;
54575 +#else
54576 inode->i_mode = S_IFDIR|S_IRUGO|S_IXUGO;
54577 +#endif
54578 inode->i_op = &proc_tgid_base_inode_operations;
54579 inode->i_fop = &proc_tgid_base_operations;
54580 inode->i_flags|=S_IMMUTABLE;
54581 @@ -2743,7 +2877,11 @@ struct dentry *proc_pid_lookup(struct inode *dir, struct dentry * dentry, unsign
54582 if (!task)
54583 goto out;
54584
54585 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
54586 + goto out_put_task;
54587 +
54588 result = proc_pid_instantiate(dir, dentry, task, NULL);
54589 +out_put_task:
54590 put_task_struct(task);
54591 out:
54592 return result;
54593 @@ -2806,6 +2944,8 @@ static int proc_pid_fill_cache(struct file *filp, void *dirent, filldir_t filldi
54594 static int fake_filldir(void *buf, const char *name, int namelen,
54595 loff_t offset, u64 ino, unsigned d_type)
54596 {
54597 + struct getdents_callback * __buf = (struct getdents_callback *) buf;
54598 + __buf->error = -EINVAL;
54599 return 0;
54600 }
54601
54602 @@ -2857,7 +2997,7 @@ static const struct pid_entry tid_base_stuff[] = {
54603 REG("sched", S_IRUGO|S_IWUSR, proc_pid_sched_operations),
54604 #endif
54605 REG("comm", S_IRUGO|S_IWUSR, proc_pid_set_comm_operations),
54606 -#ifdef CONFIG_HAVE_ARCH_TRACEHOOK
54607 +#if defined(CONFIG_HAVE_ARCH_TRACEHOOK) && !defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
54608 INF("syscall", S_IRUGO, proc_pid_syscall),
54609 #endif
54610 INF("cmdline", S_IRUGO, proc_pid_cmdline),
54611 @@ -2884,10 +3024,10 @@ static const struct pid_entry tid_base_stuff[] = {
54612 #ifdef CONFIG_SECURITY
54613 DIR("attr", S_IRUGO|S_IXUGO, proc_attr_dir_inode_operations, proc_attr_dir_operations),
54614 #endif
54615 -#ifdef CONFIG_KALLSYMS
54616 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
54617 INF("wchan", S_IRUGO, proc_pid_wchan),
54618 #endif
54619 -#ifdef CONFIG_STACKTRACE
54620 +#if defined(CONFIG_STACKTRACE) && !defined(CONFIG_GRKERNSEC_HIDESYM)
54621 ONE("stack", S_IRUGO, proc_pid_stack),
54622 #endif
54623 #ifdef CONFIG_SCHEDSTATS
54624 diff --git a/fs/proc/cmdline.c b/fs/proc/cmdline.c
54625 index 82676e3..5f8518a 100644
54626 --- a/fs/proc/cmdline.c
54627 +++ b/fs/proc/cmdline.c
54628 @@ -23,7 +23,11 @@ static const struct file_operations cmdline_proc_fops = {
54629
54630 static int __init proc_cmdline_init(void)
54631 {
54632 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
54633 + proc_create_grsec("cmdline", 0, NULL, &cmdline_proc_fops);
54634 +#else
54635 proc_create("cmdline", 0, NULL, &cmdline_proc_fops);
54636 +#endif
54637 return 0;
54638 }
54639 module_init(proc_cmdline_init);
54640 diff --git a/fs/proc/devices.c b/fs/proc/devices.c
54641 index b143471..bb105e5 100644
54642 --- a/fs/proc/devices.c
54643 +++ b/fs/proc/devices.c
54644 @@ -64,7 +64,11 @@ static const struct file_operations proc_devinfo_operations = {
54645
54646 static int __init proc_devices_init(void)
54647 {
54648 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
54649 + proc_create_grsec("devices", 0, NULL, &proc_devinfo_operations);
54650 +#else
54651 proc_create("devices", 0, NULL, &proc_devinfo_operations);
54652 +#endif
54653 return 0;
54654 }
54655 module_init(proc_devices_init);
54656 diff --git a/fs/proc/fd.c b/fs/proc/fd.c
54657 index d7a4a28..0201742 100644
54658 --- a/fs/proc/fd.c
54659 +++ b/fs/proc/fd.c
54660 @@ -25,7 +25,8 @@ static int seq_show(struct seq_file *m, void *v)
54661 if (!task)
54662 return -ENOENT;
54663
54664 - files = get_files_struct(task);
54665 + if (!gr_acl_handle_procpidmem(task))
54666 + files = get_files_struct(task);
54667 put_task_struct(task);
54668
54669 if (files) {
54670 @@ -302,11 +303,21 @@ static struct dentry *proc_lookupfd(struct inode *dir, struct dentry *dentry,
54671 */
54672 int proc_fd_permission(struct inode *inode, int mask)
54673 {
54674 + struct task_struct *task;
54675 int rv = generic_permission(inode, mask);
54676 - if (rv == 0)
54677 - return 0;
54678 +
54679 if (task_pid(current) == proc_pid(inode))
54680 rv = 0;
54681 +
54682 + task = get_proc_task(inode);
54683 + if (task == NULL)
54684 + return rv;
54685 +
54686 + if (gr_acl_handle_procpidmem(task))
54687 + rv = -EACCES;
54688 +
54689 + put_task_struct(task);
54690 +
54691 return rv;
54692 }
54693
54694 diff --git a/fs/proc/inode.c b/fs/proc/inode.c
54695 index 439ae688..c21ac36 100644
54696 --- a/fs/proc/inode.c
54697 +++ b/fs/proc/inode.c
54698 @@ -21,11 +21,17 @@
54699 #include <linux/seq_file.h>
54700 #include <linux/slab.h>
54701 #include <linux/mount.h>
54702 +#include <linux/grsecurity.h>
54703
54704 #include <asm/uaccess.h>
54705
54706 #include "internal.h"
54707
54708 +#ifdef CONFIG_PROC_SYSCTL
54709 +extern const struct inode_operations proc_sys_inode_operations;
54710 +extern const struct inode_operations proc_sys_dir_operations;
54711 +#endif
54712 +
54713 static void proc_evict_inode(struct inode *inode)
54714 {
54715 struct proc_dir_entry *de;
54716 @@ -53,6 +59,13 @@ static void proc_evict_inode(struct inode *inode)
54717 ns = PROC_I(inode)->ns;
54718 if (ns_ops && ns)
54719 ns_ops->put(ns);
54720 +
54721 +#ifdef CONFIG_PROC_SYSCTL
54722 + if (inode->i_op == &proc_sys_inode_operations ||
54723 + inode->i_op == &proc_sys_dir_operations)
54724 + gr_handle_delete(inode->i_ino, inode->i_sb->s_dev);
54725 +#endif
54726 +
54727 }
54728
54729 static struct kmem_cache * proc_inode_cachep;
54730 @@ -457,7 +470,11 @@ struct inode *proc_get_inode(struct super_block *sb, struct proc_dir_entry *de)
54731 if (de->mode) {
54732 inode->i_mode = de->mode;
54733 inode->i_uid = de->uid;
54734 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
54735 + inode->i_gid = grsec_proc_gid;
54736 +#else
54737 inode->i_gid = de->gid;
54738 +#endif
54739 }
54740 if (de->size)
54741 inode->i_size = de->size;
54742 diff --git a/fs/proc/internal.h b/fs/proc/internal.h
54743 index 252544c..04395b9 100644
54744 --- a/fs/proc/internal.h
54745 +++ b/fs/proc/internal.h
54746 @@ -55,6 +55,9 @@ extern int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
54747 struct pid *pid, struct task_struct *task);
54748 extern int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns,
54749 struct pid *pid, struct task_struct *task);
54750 +#ifdef CONFIG_GRKERNSEC_PROC_IPADDR
54751 +extern int proc_pid_ipaddr(struct task_struct *task, char *buffer);
54752 +#endif
54753 extern loff_t mem_lseek(struct file *file, loff_t offset, int orig);
54754
54755 extern const struct file_operations proc_tid_children_operations;
54756 diff --git a/fs/proc/kcore.c b/fs/proc/kcore.c
54757 index e96d4f1..8b116ed 100644
54758 --- a/fs/proc/kcore.c
54759 +++ b/fs/proc/kcore.c
54760 @@ -480,9 +480,10 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
54761 * the addresses in the elf_phdr on our list.
54762 */
54763 start = kc_offset_to_vaddr(*fpos - elf_buflen);
54764 - if ((tsz = (PAGE_SIZE - (start & ~PAGE_MASK))) > buflen)
54765 + tsz = PAGE_SIZE - (start & ~PAGE_MASK);
54766 + if (tsz > buflen)
54767 tsz = buflen;
54768 -
54769 +
54770 while (buflen) {
54771 struct kcore_list *m;
54772
54773 @@ -511,20 +512,23 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
54774 kfree(elf_buf);
54775 } else {
54776 if (kern_addr_valid(start)) {
54777 - unsigned long n;
54778 + char *elf_buf;
54779 + mm_segment_t oldfs;
54780
54781 - n = copy_to_user(buffer, (char *)start, tsz);
54782 - /*
54783 - * We cannot distinguish between fault on source
54784 - * and fault on destination. When this happens
54785 - * we clear too and hope it will trigger the
54786 - * EFAULT again.
54787 - */
54788 - if (n) {
54789 - if (clear_user(buffer + tsz - n,
54790 - n))
54791 + elf_buf = kmalloc(tsz, GFP_KERNEL);
54792 + if (!elf_buf)
54793 + return -ENOMEM;
54794 + oldfs = get_fs();
54795 + set_fs(KERNEL_DS);
54796 + if (!__copy_from_user(elf_buf, (const void __user *)start, tsz)) {
54797 + set_fs(oldfs);
54798 + if (copy_to_user(buffer, elf_buf, tsz)) {
54799 + kfree(elf_buf);
54800 return -EFAULT;
54801 + }
54802 }
54803 + set_fs(oldfs);
54804 + kfree(elf_buf);
54805 } else {
54806 if (clear_user(buffer, tsz))
54807 return -EFAULT;
54808 @@ -544,6 +548,9 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
54809
54810 static int open_kcore(struct inode *inode, struct file *filp)
54811 {
54812 +#if defined(CONFIG_GRKERNSEC_PROC_ADD) || defined(CONFIG_GRKERNSEC_HIDESYM)
54813 + return -EPERM;
54814 +#endif
54815 if (!capable(CAP_SYS_RAWIO))
54816 return -EPERM;
54817 if (kcore_need_update)
54818 diff --git a/fs/proc/meminfo.c b/fs/proc/meminfo.c
54819 index 80e4645..53e5fcf 100644
54820 --- a/fs/proc/meminfo.c
54821 +++ b/fs/proc/meminfo.c
54822 @@ -158,7 +158,7 @@ static int meminfo_proc_show(struct seq_file *m, void *v)
54823 vmi.used >> 10,
54824 vmi.largest_chunk >> 10
54825 #ifdef CONFIG_MEMORY_FAILURE
54826 - ,atomic_long_read(&mce_bad_pages) << (PAGE_SHIFT - 10)
54827 + ,atomic_long_read_unchecked(&mce_bad_pages) << (PAGE_SHIFT - 10)
54828 #endif
54829 #ifdef CONFIG_TRANSPARENT_HUGEPAGE
54830 ,K(global_page_state(NR_ANON_TRANSPARENT_HUGEPAGES) *
54831 diff --git a/fs/proc/nommu.c b/fs/proc/nommu.c
54832 index b1822dd..df622cb 100644
54833 --- a/fs/proc/nommu.c
54834 +++ b/fs/proc/nommu.c
54835 @@ -66,7 +66,7 @@ static int nommu_region_show(struct seq_file *m, struct vm_region *region)
54836 if (len < 1)
54837 len = 1;
54838 seq_printf(m, "%*c", len, ' ');
54839 - seq_path(m, &file->f_path, "");
54840 + seq_path(m, &file->f_path, "\n\\");
54841 }
54842
54843 seq_putc(m, '\n');
54844 diff --git a/fs/proc/proc_net.c b/fs/proc/proc_net.c
54845 index fe72cd0..21b52ff 100644
54846 --- a/fs/proc/proc_net.c
54847 +++ b/fs/proc/proc_net.c
54848 @@ -23,6 +23,7 @@
54849 #include <linux/nsproxy.h>
54850 #include <net/net_namespace.h>
54851 #include <linux/seq_file.h>
54852 +#include <linux/grsecurity.h>
54853
54854 #include "internal.h"
54855
54856 @@ -105,6 +106,17 @@ static struct net *get_proc_task_net(struct inode *dir)
54857 struct task_struct *task;
54858 struct nsproxy *ns;
54859 struct net *net = NULL;
54860 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
54861 + const struct cred *cred = current_cred();
54862 +#endif
54863 +
54864 +#ifdef CONFIG_GRKERNSEC_PROC_USER
54865 + if (!uid_eq(cred->fsuid, GLOBAL_ROOT_UID))
54866 + return net;
54867 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
54868 + if (!uid_eq(cred->fsuid, GLOBAL_ROOT_UID) && !in_group_p(grsec_proc_gid))
54869 + return net;
54870 +#endif
54871
54872 rcu_read_lock();
54873 task = pid_task(proc_pid(dir), PIDTYPE_PID);
54874 diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c
54875 index 1827d88..43b0279 100644
54876 --- a/fs/proc/proc_sysctl.c
54877 +++ b/fs/proc/proc_sysctl.c
54878 @@ -12,11 +12,15 @@
54879 #include <linux/module.h>
54880 #include "internal.h"
54881
54882 +extern int gr_handle_chroot_sysctl(const int op);
54883 +extern int gr_handle_sysctl_mod(const char *dirname, const char *name,
54884 + const int op);
54885 +
54886 static const struct dentry_operations proc_sys_dentry_operations;
54887 static const struct file_operations proc_sys_file_operations;
54888 -static const struct inode_operations proc_sys_inode_operations;
54889 +const struct inode_operations proc_sys_inode_operations;
54890 static const struct file_operations proc_sys_dir_file_operations;
54891 -static const struct inode_operations proc_sys_dir_operations;
54892 +const struct inode_operations proc_sys_dir_operations;
54893
54894 void proc_sys_poll_notify(struct ctl_table_poll *poll)
54895 {
54896 @@ -466,6 +470,9 @@ static struct dentry *proc_sys_lookup(struct inode *dir, struct dentry *dentry,
54897
54898 err = NULL;
54899 d_set_d_op(dentry, &proc_sys_dentry_operations);
54900 +
54901 + gr_handle_proc_create(dentry, inode);
54902 +
54903 d_add(dentry, inode);
54904
54905 out:
54906 @@ -481,6 +488,7 @@ static ssize_t proc_sys_call_handler(struct file *filp, void __user *buf,
54907 struct inode *inode = filp->f_path.dentry->d_inode;
54908 struct ctl_table_header *head = grab_header(inode);
54909 struct ctl_table *table = PROC_I(inode)->sysctl_entry;
54910 + int op = write ? MAY_WRITE : MAY_READ;
54911 ssize_t error;
54912 size_t res;
54913
54914 @@ -492,7 +500,7 @@ static ssize_t proc_sys_call_handler(struct file *filp, void __user *buf,
54915 * and won't be until we finish.
54916 */
54917 error = -EPERM;
54918 - if (sysctl_perm(head, table, write ? MAY_WRITE : MAY_READ))
54919 + if (sysctl_perm(head, table, op))
54920 goto out;
54921
54922 /* if that can happen at all, it should be -EINVAL, not -EISDIR */
54923 @@ -500,6 +508,22 @@ static ssize_t proc_sys_call_handler(struct file *filp, void __user *buf,
54924 if (!table->proc_handler)
54925 goto out;
54926
54927 +#ifdef CONFIG_GRKERNSEC
54928 + error = -EPERM;
54929 + if (gr_handle_chroot_sysctl(op))
54930 + goto out;
54931 + dget(filp->f_path.dentry);
54932 + if (gr_handle_sysctl_mod(filp->f_path.dentry->d_parent->d_name.name, table->procname, op)) {
54933 + dput(filp->f_path.dentry);
54934 + goto out;
54935 + }
54936 + dput(filp->f_path.dentry);
54937 + if (!gr_acl_handle_open(filp->f_path.dentry, filp->f_path.mnt, op))
54938 + goto out;
54939 + if (write && !capable(CAP_SYS_ADMIN))
54940 + goto out;
54941 +#endif
54942 +
54943 /* careful: calling conventions are nasty here */
54944 res = count;
54945 error = table->proc_handler(table, write, buf, &res, ppos);
54946 @@ -597,6 +621,9 @@ static int proc_sys_fill_cache(struct file *filp, void *dirent,
54947 return -ENOMEM;
54948 } else {
54949 d_set_d_op(child, &proc_sys_dentry_operations);
54950 +
54951 + gr_handle_proc_create(child, inode);
54952 +
54953 d_add(child, inode);
54954 }
54955 } else {
54956 @@ -640,6 +667,9 @@ static int scan(struct ctl_table_header *head, ctl_table *table,
54957 if ((*pos)++ < file->f_pos)
54958 return 0;
54959
54960 + if (!gr_acl_handle_hidden_file(file->f_path.dentry, file->f_path.mnt))
54961 + return 0;
54962 +
54963 if (unlikely(S_ISLNK(table->mode)))
54964 res = proc_sys_link_fill_cache(file, dirent, filldir, head, table);
54965 else
54966 @@ -750,6 +780,9 @@ static int proc_sys_getattr(struct vfsmount *mnt, struct dentry *dentry, struct
54967 if (IS_ERR(head))
54968 return PTR_ERR(head);
54969
54970 + if (table && !gr_acl_handle_hidden_file(dentry, mnt))
54971 + return -ENOENT;
54972 +
54973 generic_fillattr(inode, stat);
54974 if (table)
54975 stat->mode = (stat->mode & S_IFMT) | table->mode;
54976 @@ -772,13 +805,13 @@ static const struct file_operations proc_sys_dir_file_operations = {
54977 .llseek = generic_file_llseek,
54978 };
54979
54980 -static const struct inode_operations proc_sys_inode_operations = {
54981 +const struct inode_operations proc_sys_inode_operations = {
54982 .permission = proc_sys_permission,
54983 .setattr = proc_sys_setattr,
54984 .getattr = proc_sys_getattr,
54985 };
54986
54987 -static const struct inode_operations proc_sys_dir_operations = {
54988 +const struct inode_operations proc_sys_dir_operations = {
54989 .lookup = proc_sys_lookup,
54990 .permission = proc_sys_permission,
54991 .setattr = proc_sys_setattr,
54992 @@ -854,7 +887,7 @@ static struct ctl_dir *find_subdir(struct ctl_dir *dir,
54993 static struct ctl_dir *new_dir(struct ctl_table_set *set,
54994 const char *name, int namelen)
54995 {
54996 - struct ctl_table *table;
54997 + ctl_table_no_const *table;
54998 struct ctl_dir *new;
54999 struct ctl_node *node;
55000 char *new_name;
55001 @@ -866,7 +899,7 @@ static struct ctl_dir *new_dir(struct ctl_table_set *set,
55002 return NULL;
55003
55004 node = (struct ctl_node *)(new + 1);
55005 - table = (struct ctl_table *)(node + 1);
55006 + table = (ctl_table_no_const *)(node + 1);
55007 new_name = (char *)(table + 2);
55008 memcpy(new_name, name, namelen);
55009 new_name[namelen] = '\0';
55010 @@ -1035,7 +1068,8 @@ static int sysctl_check_table(const char *path, struct ctl_table *table)
55011 static struct ctl_table_header *new_links(struct ctl_dir *dir, struct ctl_table *table,
55012 struct ctl_table_root *link_root)
55013 {
55014 - struct ctl_table *link_table, *entry, *link;
55015 + ctl_table_no_const *link_table, *link;
55016 + struct ctl_table *entry;
55017 struct ctl_table_header *links;
55018 struct ctl_node *node;
55019 char *link_name;
55020 @@ -1058,7 +1092,7 @@ static struct ctl_table_header *new_links(struct ctl_dir *dir, struct ctl_table
55021 return NULL;
55022
55023 node = (struct ctl_node *)(links + 1);
55024 - link_table = (struct ctl_table *)(node + nr_entries);
55025 + link_table = (ctl_table_no_const *)(node + nr_entries);
55026 link_name = (char *)&link_table[nr_entries + 1];
55027
55028 for (link = link_table, entry = table; entry->procname; link++, entry++) {
55029 @@ -1306,8 +1340,8 @@ static int register_leaf_sysctl_tables(const char *path, char *pos,
55030 struct ctl_table_header ***subheader, struct ctl_table_set *set,
55031 struct ctl_table *table)
55032 {
55033 - struct ctl_table *ctl_table_arg = NULL;
55034 - struct ctl_table *entry, *files;
55035 + ctl_table_no_const *ctl_table_arg = NULL, *files = NULL;
55036 + struct ctl_table *entry;
55037 int nr_files = 0;
55038 int nr_dirs = 0;
55039 int err = -ENOMEM;
55040 @@ -1319,10 +1353,9 @@ static int register_leaf_sysctl_tables(const char *path, char *pos,
55041 nr_files++;
55042 }
55043
55044 - files = table;
55045 /* If there are mixed files and directories we need a new table */
55046 if (nr_dirs && nr_files) {
55047 - struct ctl_table *new;
55048 + ctl_table_no_const *new;
55049 files = kzalloc(sizeof(struct ctl_table) * (nr_files + 1),
55050 GFP_KERNEL);
55051 if (!files)
55052 @@ -1340,7 +1373,7 @@ static int register_leaf_sysctl_tables(const char *path, char *pos,
55053 /* Register everything except a directory full of subdirectories */
55054 if (nr_files || !nr_dirs) {
55055 struct ctl_table_header *header;
55056 - header = __register_sysctl_table(set, path, files);
55057 + header = __register_sysctl_table(set, path, files ? files : table);
55058 if (!header) {
55059 kfree(ctl_table_arg);
55060 goto out;
55061 diff --git a/fs/proc/root.c b/fs/proc/root.c
55062 index c6e9fac..a740964 100644
55063 --- a/fs/proc/root.c
55064 +++ b/fs/proc/root.c
55065 @@ -176,7 +176,15 @@ void __init proc_root_init(void)
55066 #ifdef CONFIG_PROC_DEVICETREE
55067 proc_device_tree_init();
55068 #endif
55069 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
55070 +#ifdef CONFIG_GRKERNSEC_PROC_USER
55071 + proc_mkdir_mode("bus", S_IRUSR | S_IXUSR, NULL);
55072 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
55073 + proc_mkdir_mode("bus", S_IRUSR | S_IXUSR | S_IRGRP | S_IXGRP, NULL);
55074 +#endif
55075 +#else
55076 proc_mkdir("bus", NULL);
55077 +#endif
55078 proc_sys_init();
55079 }
55080
55081 diff --git a/fs/proc/self.c b/fs/proc/self.c
55082 index aa5cc3b..c91a5d0 100644
55083 --- a/fs/proc/self.c
55084 +++ b/fs/proc/self.c
55085 @@ -37,7 +37,7 @@ static void *proc_self_follow_link(struct dentry *dentry, struct nameidata *nd)
55086 static void proc_self_put_link(struct dentry *dentry, struct nameidata *nd,
55087 void *cookie)
55088 {
55089 - char *s = nd_get_link(nd);
55090 + const char *s = nd_get_link(nd);
55091 if (!IS_ERR(s))
55092 kfree(s);
55093 }
55094 diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
55095 index ca5ce7f..02c1cf0 100644
55096 --- a/fs/proc/task_mmu.c
55097 +++ b/fs/proc/task_mmu.c
55098 @@ -11,12 +11,19 @@
55099 #include <linux/rmap.h>
55100 #include <linux/swap.h>
55101 #include <linux/swapops.h>
55102 +#include <linux/grsecurity.h>
55103
55104 #include <asm/elf.h>
55105 #include <asm/uaccess.h>
55106 #include <asm/tlbflush.h>
55107 #include "internal.h"
55108
55109 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55110 +#define PAX_RAND_FLAGS(_mm) (_mm != NULL && _mm != current->mm && \
55111 + (_mm->pax_flags & MF_PAX_RANDMMAP || \
55112 + _mm->pax_flags & MF_PAX_SEGMEXEC))
55113 +#endif
55114 +
55115 void task_mem(struct seq_file *m, struct mm_struct *mm)
55116 {
55117 unsigned long data, text, lib, swap;
55118 @@ -52,8 +59,13 @@ void task_mem(struct seq_file *m, struct mm_struct *mm)
55119 "VmExe:\t%8lu kB\n"
55120 "VmLib:\t%8lu kB\n"
55121 "VmPTE:\t%8lu kB\n"
55122 - "VmSwap:\t%8lu kB\n",
55123 - hiwater_vm << (PAGE_SHIFT-10),
55124 + "VmSwap:\t%8lu kB\n"
55125 +
55126 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
55127 + "CsBase:\t%8lx\nCsLim:\t%8lx\n"
55128 +#endif
55129 +
55130 + ,hiwater_vm << (PAGE_SHIFT-10),
55131 total_vm << (PAGE_SHIFT-10),
55132 mm->locked_vm << (PAGE_SHIFT-10),
55133 mm->pinned_vm << (PAGE_SHIFT-10),
55134 @@ -62,7 +74,19 @@ void task_mem(struct seq_file *m, struct mm_struct *mm)
55135 data << (PAGE_SHIFT-10),
55136 mm->stack_vm << (PAGE_SHIFT-10), text, lib,
55137 (PTRS_PER_PTE*sizeof(pte_t)*mm->nr_ptes) >> 10,
55138 - swap << (PAGE_SHIFT-10));
55139 + swap << (PAGE_SHIFT-10)
55140 +
55141 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
55142 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55143 + , PAX_RAND_FLAGS(mm) ? 0 : mm->context.user_cs_base
55144 + , PAX_RAND_FLAGS(mm) ? 0 : mm->context.user_cs_limit
55145 +#else
55146 + , mm->context.user_cs_base
55147 + , mm->context.user_cs_limit
55148 +#endif
55149 +#endif
55150 +
55151 + );
55152 }
55153
55154 unsigned long task_vsize(struct mm_struct *mm)
55155 @@ -277,13 +301,13 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
55156 pgoff = ((loff_t)vma->vm_pgoff) << PAGE_SHIFT;
55157 }
55158
55159 - /* We don't show the stack guard page in /proc/maps */
55160 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55161 + start = PAX_RAND_FLAGS(mm) ? 0UL : vma->vm_start;
55162 + end = PAX_RAND_FLAGS(mm) ? 0UL : vma->vm_end;
55163 +#else
55164 start = vma->vm_start;
55165 - if (stack_guard_page_start(vma, start))
55166 - start += PAGE_SIZE;
55167 end = vma->vm_end;
55168 - if (stack_guard_page_end(vma, end))
55169 - end -= PAGE_SIZE;
55170 +#endif
55171
55172 seq_printf(m, "%08lx-%08lx %c%c%c%c %08llx %02x:%02x %lu %n",
55173 start,
55174 @@ -292,7 +316,11 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
55175 flags & VM_WRITE ? 'w' : '-',
55176 flags & VM_EXEC ? 'x' : '-',
55177 flags & VM_MAYSHARE ? 's' : 'p',
55178 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55179 + PAX_RAND_FLAGS(mm) ? 0UL : pgoff,
55180 +#else
55181 pgoff,
55182 +#endif
55183 MAJOR(dev), MINOR(dev), ino, &len);
55184
55185 /*
55186 @@ -301,7 +329,7 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
55187 */
55188 if (file) {
55189 pad_len_spaces(m, len);
55190 - seq_path(m, &file->f_path, "\n");
55191 + seq_path(m, &file->f_path, "\n\\");
55192 goto done;
55193 }
55194
55195 @@ -327,8 +355,9 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
55196 * Thread stack in /proc/PID/task/TID/maps or
55197 * the main process stack.
55198 */
55199 - if (!is_pid || (vma->vm_start <= mm->start_stack &&
55200 - vma->vm_end >= mm->start_stack)) {
55201 + if (!is_pid || (vma->vm_flags & (VM_GROWSDOWN | VM_GROWSUP)) ||
55202 + (vma->vm_start <= mm->start_stack &&
55203 + vma->vm_end >= mm->start_stack)) {
55204 name = "[stack]";
55205 } else {
55206 /* Thread stack in /proc/PID/maps */
55207 @@ -352,6 +381,13 @@ static int show_map(struct seq_file *m, void *v, int is_pid)
55208 struct proc_maps_private *priv = m->private;
55209 struct task_struct *task = priv->task;
55210
55211 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55212 + if (current->exec_id != m->exec_id) {
55213 + gr_log_badprocpid("maps");
55214 + return 0;
55215 + }
55216 +#endif
55217 +
55218 show_map_vma(m, vma, is_pid);
55219
55220 if (m->count < m->size) /* vma is copied successfully */
55221 @@ -589,12 +625,23 @@ static int show_smap(struct seq_file *m, void *v, int is_pid)
55222 .private = &mss,
55223 };
55224
55225 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55226 + if (current->exec_id != m->exec_id) {
55227 + gr_log_badprocpid("smaps");
55228 + return 0;
55229 + }
55230 +#endif
55231 memset(&mss, 0, sizeof mss);
55232 - mss.vma = vma;
55233 - /* mmap_sem is held in m_start */
55234 - if (vma->vm_mm && !is_vm_hugetlb_page(vma))
55235 - walk_page_range(vma->vm_start, vma->vm_end, &smaps_walk);
55236 -
55237 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55238 + if (!PAX_RAND_FLAGS(vma->vm_mm)) {
55239 +#endif
55240 + mss.vma = vma;
55241 + /* mmap_sem is held in m_start */
55242 + if (vma->vm_mm && !is_vm_hugetlb_page(vma))
55243 + walk_page_range(vma->vm_start, vma->vm_end, &smaps_walk);
55244 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55245 + }
55246 +#endif
55247 show_map_vma(m, vma, is_pid);
55248
55249 seq_printf(m,
55250 @@ -612,7 +659,11 @@ static int show_smap(struct seq_file *m, void *v, int is_pid)
55251 "KernelPageSize: %8lu kB\n"
55252 "MMUPageSize: %8lu kB\n"
55253 "Locked: %8lu kB\n",
55254 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55255 + PAX_RAND_FLAGS(vma->vm_mm) ? 0UL : (vma->vm_end - vma->vm_start) >> 10,
55256 +#else
55257 (vma->vm_end - vma->vm_start) >> 10,
55258 +#endif
55259 mss.resident >> 10,
55260 (unsigned long)(mss.pss >> (10 + PSS_SHIFT)),
55261 mss.shared_clean >> 10,
55262 @@ -1264,6 +1315,13 @@ static int show_numa_map(struct seq_file *m, void *v, int is_pid)
55263 int n;
55264 char buffer[50];
55265
55266 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55267 + if (current->exec_id != m->exec_id) {
55268 + gr_log_badprocpid("numa_maps");
55269 + return 0;
55270 + }
55271 +#endif
55272 +
55273 if (!mm)
55274 return 0;
55275
55276 @@ -1281,11 +1339,15 @@ static int show_numa_map(struct seq_file *m, void *v, int is_pid)
55277 mpol_to_str(buffer, sizeof(buffer), pol);
55278 mpol_cond_put(pol);
55279
55280 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55281 + seq_printf(m, "%08lx %s", PAX_RAND_FLAGS(vma->vm_mm) ? 0UL : vma->vm_start, buffer);
55282 +#else
55283 seq_printf(m, "%08lx %s", vma->vm_start, buffer);
55284 +#endif
55285
55286 if (file) {
55287 seq_printf(m, " file=");
55288 - seq_path(m, &file->f_path, "\n\t= ");
55289 + seq_path(m, &file->f_path, "\n\t\\= ");
55290 } else if (vma->vm_start <= mm->brk && vma->vm_end >= mm->start_brk) {
55291 seq_printf(m, " heap");
55292 } else {
55293 diff --git a/fs/proc/task_nommu.c b/fs/proc/task_nommu.c
55294 index 1ccfa53..0848f95 100644
55295 --- a/fs/proc/task_nommu.c
55296 +++ b/fs/proc/task_nommu.c
55297 @@ -51,7 +51,7 @@ void task_mem(struct seq_file *m, struct mm_struct *mm)
55298 else
55299 bytes += kobjsize(mm);
55300
55301 - if (current->fs && current->fs->users > 1)
55302 + if (current->fs && atomic_read(&current->fs->users) > 1)
55303 sbytes += kobjsize(current->fs);
55304 else
55305 bytes += kobjsize(current->fs);
55306 @@ -168,7 +168,7 @@ static int nommu_vma_show(struct seq_file *m, struct vm_area_struct *vma,
55307
55308 if (file) {
55309 pad_len_spaces(m, len);
55310 - seq_path(m, &file->f_path, "");
55311 + seq_path(m, &file->f_path, "\n\\");
55312 } else if (mm) {
55313 pid_t tid = vm_is_stack(priv->task, vma, is_pid);
55314
55315 diff --git a/fs/qnx6/qnx6.h b/fs/qnx6/qnx6.h
55316 index b00fcc9..e0c6381 100644
55317 --- a/fs/qnx6/qnx6.h
55318 +++ b/fs/qnx6/qnx6.h
55319 @@ -74,7 +74,7 @@ enum {
55320 BYTESEX_BE,
55321 };
55322
55323 -static inline __u64 fs64_to_cpu(struct qnx6_sb_info *sbi, __fs64 n)
55324 +static inline __u64 __intentional_overflow(-1) fs64_to_cpu(struct qnx6_sb_info *sbi, __fs64 n)
55325 {
55326 if (sbi->s_bytesex == BYTESEX_LE)
55327 return le64_to_cpu((__force __le64)n);
55328 @@ -90,7 +90,7 @@ static inline __fs64 cpu_to_fs64(struct qnx6_sb_info *sbi, __u64 n)
55329 return (__force __fs64)cpu_to_be64(n);
55330 }
55331
55332 -static inline __u32 fs32_to_cpu(struct qnx6_sb_info *sbi, __fs32 n)
55333 +static inline __u32 __intentional_overflow(-1) fs32_to_cpu(struct qnx6_sb_info *sbi, __fs32 n)
55334 {
55335 if (sbi->s_bytesex == BYTESEX_LE)
55336 return le32_to_cpu((__force __le32)n);
55337 diff --git a/fs/quota/netlink.c b/fs/quota/netlink.c
55338 index 16e8abb..2dcf914 100644
55339 --- a/fs/quota/netlink.c
55340 +++ b/fs/quota/netlink.c
55341 @@ -33,7 +33,7 @@ static struct genl_family quota_genl_family = {
55342 void quota_send_warning(struct kqid qid, dev_t dev,
55343 const char warntype)
55344 {
55345 - static atomic_t seq;
55346 + static atomic_unchecked_t seq;
55347 struct sk_buff *skb;
55348 void *msg_head;
55349 int ret;
55350 @@ -49,7 +49,7 @@ void quota_send_warning(struct kqid qid, dev_t dev,
55351 "VFS: Not enough memory to send quota warning.\n");
55352 return;
55353 }
55354 - msg_head = genlmsg_put(skb, 0, atomic_add_return(1, &seq),
55355 + msg_head = genlmsg_put(skb, 0, atomic_add_return_unchecked(1, &seq),
55356 &quota_genl_family, 0, QUOTA_NL_C_WARNING);
55357 if (!msg_head) {
55358 printk(KERN_ERR
55359 diff --git a/fs/readdir.c b/fs/readdir.c
55360 index 5e69ef5..e5d9099 100644
55361 --- a/fs/readdir.c
55362 +++ b/fs/readdir.c
55363 @@ -17,6 +17,7 @@
55364 #include <linux/security.h>
55365 #include <linux/syscalls.h>
55366 #include <linux/unistd.h>
55367 +#include <linux/namei.h>
55368
55369 #include <asm/uaccess.h>
55370
55371 @@ -67,6 +68,7 @@ struct old_linux_dirent {
55372
55373 struct readdir_callback {
55374 struct old_linux_dirent __user * dirent;
55375 + struct file * file;
55376 int result;
55377 };
55378
55379 @@ -84,6 +86,10 @@ static int fillonedir(void * __buf, const char * name, int namlen, loff_t offset
55380 buf->result = -EOVERFLOW;
55381 return -EOVERFLOW;
55382 }
55383 +
55384 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
55385 + return 0;
55386 +
55387 buf->result++;
55388 dirent = buf->dirent;
55389 if (!access_ok(VERIFY_WRITE, dirent,
55390 @@ -114,6 +120,7 @@ SYSCALL_DEFINE3(old_readdir, unsigned int, fd,
55391
55392 buf.result = 0;
55393 buf.dirent = dirent;
55394 + buf.file = f.file;
55395
55396 error = vfs_readdir(f.file, fillonedir, &buf);
55397 if (buf.result)
55398 @@ -139,6 +146,7 @@ struct linux_dirent {
55399 struct getdents_callback {
55400 struct linux_dirent __user * current_dir;
55401 struct linux_dirent __user * previous;
55402 + struct file * file;
55403 int count;
55404 int error;
55405 };
55406 @@ -160,6 +168,10 @@ static int filldir(void * __buf, const char * name, int namlen, loff_t offset,
55407 buf->error = -EOVERFLOW;
55408 return -EOVERFLOW;
55409 }
55410 +
55411 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
55412 + return 0;
55413 +
55414 dirent = buf->previous;
55415 if (dirent) {
55416 if (__put_user(offset, &dirent->d_off))
55417 @@ -205,6 +217,7 @@ SYSCALL_DEFINE3(getdents, unsigned int, fd,
55418 buf.previous = NULL;
55419 buf.count = count;
55420 buf.error = 0;
55421 + buf.file = f.file;
55422
55423 error = vfs_readdir(f.file, filldir, &buf);
55424 if (error >= 0)
55425 @@ -223,6 +236,7 @@ SYSCALL_DEFINE3(getdents, unsigned int, fd,
55426 struct getdents_callback64 {
55427 struct linux_dirent64 __user * current_dir;
55428 struct linux_dirent64 __user * previous;
55429 + struct file *file;
55430 int count;
55431 int error;
55432 };
55433 @@ -238,6 +252,10 @@ static int filldir64(void * __buf, const char * name, int namlen, loff_t offset,
55434 buf->error = -EINVAL; /* only used if we fail.. */
55435 if (reclen > buf->count)
55436 return -EINVAL;
55437 +
55438 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
55439 + return 0;
55440 +
55441 dirent = buf->previous;
55442 if (dirent) {
55443 if (__put_user(offset, &dirent->d_off))
55444 @@ -283,6 +301,7 @@ SYSCALL_DEFINE3(getdents64, unsigned int, fd,
55445
55446 buf.current_dir = dirent;
55447 buf.previous = NULL;
55448 + buf.file = f.file;
55449 buf.count = count;
55450 buf.error = 0;
55451
55452 @@ -291,7 +310,7 @@ SYSCALL_DEFINE3(getdents64, unsigned int, fd,
55453 error = buf.error;
55454 lastdirent = buf.previous;
55455 if (lastdirent) {
55456 - typeof(lastdirent->d_off) d_off = f.file->f_pos;
55457 + typeof(((struct linux_dirent64 *)0)->d_off) d_off = f.file->f_pos;
55458 if (__put_user(d_off, &lastdirent->d_off))
55459 error = -EFAULT;
55460 else
55461 diff --git a/fs/reiserfs/do_balan.c b/fs/reiserfs/do_balan.c
55462 index 2b7882b..1c5ef48 100644
55463 --- a/fs/reiserfs/do_balan.c
55464 +++ b/fs/reiserfs/do_balan.c
55465 @@ -2051,7 +2051,7 @@ void do_balance(struct tree_balance *tb, /* tree_balance structure */
55466 return;
55467 }
55468
55469 - atomic_inc(&(fs_generation(tb->tb_sb)));
55470 + atomic_inc_unchecked(&(fs_generation(tb->tb_sb)));
55471 do_balance_starts(tb);
55472
55473 /* balance leaf returns 0 except if combining L R and S into
55474 diff --git a/fs/reiserfs/procfs.c b/fs/reiserfs/procfs.c
55475 index e60e870..f40ac16 100644
55476 --- a/fs/reiserfs/procfs.c
55477 +++ b/fs/reiserfs/procfs.c
55478 @@ -112,7 +112,7 @@ static int show_super(struct seq_file *m, struct super_block *sb)
55479 "SMALL_TAILS " : "NO_TAILS ",
55480 replay_only(sb) ? "REPLAY_ONLY " : "",
55481 convert_reiserfs(sb) ? "CONV " : "",
55482 - atomic_read(&r->s_generation_counter),
55483 + atomic_read_unchecked(&r->s_generation_counter),
55484 SF(s_disk_reads), SF(s_disk_writes), SF(s_fix_nodes),
55485 SF(s_do_balance), SF(s_unneeded_left_neighbor),
55486 SF(s_good_search_by_key_reada), SF(s_bmaps),
55487 diff --git a/fs/reiserfs/reiserfs.h b/fs/reiserfs/reiserfs.h
55488 index 157e474..65a6114 100644
55489 --- a/fs/reiserfs/reiserfs.h
55490 +++ b/fs/reiserfs/reiserfs.h
55491 @@ -453,7 +453,7 @@ struct reiserfs_sb_info {
55492 /* Comment? -Hans */
55493 wait_queue_head_t s_wait;
55494 /* To be obsoleted soon by per buffer seals.. -Hans */
55495 - atomic_t s_generation_counter; // increased by one every time the
55496 + atomic_unchecked_t s_generation_counter; // increased by one every time the
55497 // tree gets re-balanced
55498 unsigned long s_properties; /* File system properties. Currently holds
55499 on-disk FS format */
55500 @@ -1978,7 +1978,7 @@ static inline loff_t max_reiserfs_offset(struct inode *inode)
55501 #define REISERFS_USER_MEM 1 /* reiserfs user memory mode */
55502
55503 #define fs_generation(s) (REISERFS_SB(s)->s_generation_counter)
55504 -#define get_generation(s) atomic_read (&fs_generation(s))
55505 +#define get_generation(s) atomic_read_unchecked (&fs_generation(s))
55506 #define FILESYSTEM_CHANGED_TB(tb) (get_generation((tb)->tb_sb) != (tb)->fs_gen)
55507 #define __fs_changed(gen,s) (gen != get_generation (s))
55508 #define fs_changed(gen,s) \
55509 diff --git a/fs/select.c b/fs/select.c
55510 index 2ef72d9..f213b17 100644
55511 --- a/fs/select.c
55512 +++ b/fs/select.c
55513 @@ -20,6 +20,7 @@
55514 #include <linux/export.h>
55515 #include <linux/slab.h>
55516 #include <linux/poll.h>
55517 +#include <linux/security.h>
55518 #include <linux/personality.h> /* for STICKY_TIMEOUTS */
55519 #include <linux/file.h>
55520 #include <linux/fdtable.h>
55521 @@ -826,6 +827,7 @@ int do_sys_poll(struct pollfd __user *ufds, unsigned int nfds,
55522 struct poll_list *walk = head;
55523 unsigned long todo = nfds;
55524
55525 + gr_learn_resource(current, RLIMIT_NOFILE, nfds, 1);
55526 if (nfds > rlimit(RLIMIT_NOFILE))
55527 return -EINVAL;
55528
55529 diff --git a/fs/seq_file.c b/fs/seq_file.c
55530 index f2bc3df..239d4f6 100644
55531 --- a/fs/seq_file.c
55532 +++ b/fs/seq_file.c
55533 @@ -10,6 +10,7 @@
55534 #include <linux/seq_file.h>
55535 #include <linux/slab.h>
55536 #include <linux/cred.h>
55537 +#include <linux/sched.h>
55538
55539 #include <asm/uaccess.h>
55540 #include <asm/page.h>
55541 @@ -60,6 +61,9 @@ int seq_open(struct file *file, const struct seq_operations *op)
55542 #ifdef CONFIG_USER_NS
55543 p->user_ns = file->f_cred->user_ns;
55544 #endif
55545 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55546 + p->exec_id = current->exec_id;
55547 +#endif
55548
55549 /*
55550 * Wrappers around seq_open(e.g. swaps_open) need to be
55551 @@ -96,7 +100,7 @@ static int traverse(struct seq_file *m, loff_t offset)
55552 return 0;
55553 }
55554 if (!m->buf) {
55555 - m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL);
55556 + m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL | GFP_USERCOPY);
55557 if (!m->buf)
55558 return -ENOMEM;
55559 }
55560 @@ -136,7 +140,7 @@ static int traverse(struct seq_file *m, loff_t offset)
55561 Eoverflow:
55562 m->op->stop(m, p);
55563 kfree(m->buf);
55564 - m->buf = kmalloc(m->size <<= 1, GFP_KERNEL);
55565 + m->buf = kmalloc(m->size <<= 1, GFP_KERNEL | GFP_USERCOPY);
55566 return !m->buf ? -ENOMEM : -EAGAIN;
55567 }
55568
55569 @@ -191,7 +195,7 @@ ssize_t seq_read(struct file *file, char __user *buf, size_t size, loff_t *ppos)
55570
55571 /* grab buffer if we didn't have one */
55572 if (!m->buf) {
55573 - m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL);
55574 + m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL | GFP_USERCOPY);
55575 if (!m->buf)
55576 goto Enomem;
55577 }
55578 @@ -232,7 +236,7 @@ ssize_t seq_read(struct file *file, char __user *buf, size_t size, loff_t *ppos)
55579 goto Fill;
55580 m->op->stop(m, p);
55581 kfree(m->buf);
55582 - m->buf = kmalloc(m->size <<= 1, GFP_KERNEL);
55583 + m->buf = kmalloc(m->size <<= 1, GFP_KERNEL | GFP_USERCOPY);
55584 if (!m->buf)
55585 goto Enomem;
55586 m->count = 0;
55587 @@ -581,7 +585,7 @@ static void single_stop(struct seq_file *p, void *v)
55588 int single_open(struct file *file, int (*show)(struct seq_file *, void *),
55589 void *data)
55590 {
55591 - struct seq_operations *op = kmalloc(sizeof(*op), GFP_KERNEL);
55592 + seq_operations_no_const *op = kzalloc(sizeof(*op), GFP_KERNEL);
55593 int res = -ENOMEM;
55594
55595 if (op) {
55596 diff --git a/fs/splice.c b/fs/splice.c
55597 index 6909d89..5b2e8f9 100644
55598 --- a/fs/splice.c
55599 +++ b/fs/splice.c
55600 @@ -194,7 +194,7 @@ ssize_t splice_to_pipe(struct pipe_inode_info *pipe,
55601 pipe_lock(pipe);
55602
55603 for (;;) {
55604 - if (!pipe->readers) {
55605 + if (!atomic_read(&pipe->readers)) {
55606 send_sig(SIGPIPE, current, 0);
55607 if (!ret)
55608 ret = -EPIPE;
55609 @@ -248,9 +248,9 @@ ssize_t splice_to_pipe(struct pipe_inode_info *pipe,
55610 do_wakeup = 0;
55611 }
55612
55613 - pipe->waiting_writers++;
55614 + atomic_inc(&pipe->waiting_writers);
55615 pipe_wait(pipe);
55616 - pipe->waiting_writers--;
55617 + atomic_dec(&pipe->waiting_writers);
55618 }
55619
55620 pipe_unlock(pipe);
55621 @@ -563,7 +563,7 @@ static ssize_t kernel_readv(struct file *file, const struct iovec *vec,
55622 old_fs = get_fs();
55623 set_fs(get_ds());
55624 /* The cast to a user pointer is valid due to the set_fs() */
55625 - res = vfs_readv(file, (const struct iovec __user *)vec, vlen, &pos);
55626 + res = vfs_readv(file, (const struct iovec __force_user *)vec, vlen, &pos);
55627 set_fs(old_fs);
55628
55629 return res;
55630 @@ -578,7 +578,7 @@ static ssize_t kernel_write(struct file *file, const char *buf, size_t count,
55631 old_fs = get_fs();
55632 set_fs(get_ds());
55633 /* The cast to a user pointer is valid due to the set_fs() */
55634 - res = vfs_write(file, (const char __user *)buf, count, &pos);
55635 + res = vfs_write(file, (const char __force_user *)buf, count, &pos);
55636 set_fs(old_fs);
55637
55638 return res;
55639 @@ -630,7 +630,7 @@ ssize_t default_file_splice_read(struct file *in, loff_t *ppos,
55640 goto err;
55641
55642 this_len = min_t(size_t, len, PAGE_CACHE_SIZE - offset);
55643 - vec[i].iov_base = (void __user *) page_address(page);
55644 + vec[i].iov_base = (void __force_user *) page_address(page);
55645 vec[i].iov_len = this_len;
55646 spd.pages[i] = page;
55647 spd.nr_pages++;
55648 @@ -851,10 +851,10 @@ EXPORT_SYMBOL(splice_from_pipe_feed);
55649 int splice_from_pipe_next(struct pipe_inode_info *pipe, struct splice_desc *sd)
55650 {
55651 while (!pipe->nrbufs) {
55652 - if (!pipe->writers)
55653 + if (!atomic_read(&pipe->writers))
55654 return 0;
55655
55656 - if (!pipe->waiting_writers && sd->num_spliced)
55657 + if (!atomic_read(&pipe->waiting_writers) && sd->num_spliced)
55658 return 0;
55659
55660 if (sd->flags & SPLICE_F_NONBLOCK)
55661 @@ -1189,7 +1189,7 @@ ssize_t splice_direct_to_actor(struct file *in, struct splice_desc *sd,
55662 * out of the pipe right after the splice_to_pipe(). So set
55663 * PIPE_READERS appropriately.
55664 */
55665 - pipe->readers = 1;
55666 + atomic_set(&pipe->readers, 1);
55667
55668 current->splice_pipe = pipe;
55669 }
55670 @@ -1738,9 +1738,9 @@ static int ipipe_prep(struct pipe_inode_info *pipe, unsigned int flags)
55671 ret = -ERESTARTSYS;
55672 break;
55673 }
55674 - if (!pipe->writers)
55675 + if (!atomic_read(&pipe->writers))
55676 break;
55677 - if (!pipe->waiting_writers) {
55678 + if (!atomic_read(&pipe->waiting_writers)) {
55679 if (flags & SPLICE_F_NONBLOCK) {
55680 ret = -EAGAIN;
55681 break;
55682 @@ -1772,7 +1772,7 @@ static int opipe_prep(struct pipe_inode_info *pipe, unsigned int flags)
55683 pipe_lock(pipe);
55684
55685 while (pipe->nrbufs >= pipe->buffers) {
55686 - if (!pipe->readers) {
55687 + if (!atomic_read(&pipe->readers)) {
55688 send_sig(SIGPIPE, current, 0);
55689 ret = -EPIPE;
55690 break;
55691 @@ -1785,9 +1785,9 @@ static int opipe_prep(struct pipe_inode_info *pipe, unsigned int flags)
55692 ret = -ERESTARTSYS;
55693 break;
55694 }
55695 - pipe->waiting_writers++;
55696 + atomic_inc(&pipe->waiting_writers);
55697 pipe_wait(pipe);
55698 - pipe->waiting_writers--;
55699 + atomic_dec(&pipe->waiting_writers);
55700 }
55701
55702 pipe_unlock(pipe);
55703 @@ -1823,14 +1823,14 @@ retry:
55704 pipe_double_lock(ipipe, opipe);
55705
55706 do {
55707 - if (!opipe->readers) {
55708 + if (!atomic_read(&opipe->readers)) {
55709 send_sig(SIGPIPE, current, 0);
55710 if (!ret)
55711 ret = -EPIPE;
55712 break;
55713 }
55714
55715 - if (!ipipe->nrbufs && !ipipe->writers)
55716 + if (!ipipe->nrbufs && !atomic_read(&ipipe->writers))
55717 break;
55718
55719 /*
55720 @@ -1927,7 +1927,7 @@ static int link_pipe(struct pipe_inode_info *ipipe,
55721 pipe_double_lock(ipipe, opipe);
55722
55723 do {
55724 - if (!opipe->readers) {
55725 + if (!atomic_read(&opipe->readers)) {
55726 send_sig(SIGPIPE, current, 0);
55727 if (!ret)
55728 ret = -EPIPE;
55729 @@ -1972,7 +1972,7 @@ static int link_pipe(struct pipe_inode_info *ipipe,
55730 * return EAGAIN if we have the potential of some data in the
55731 * future, otherwise just return 0
55732 */
55733 - if (!ret && ipipe->waiting_writers && (flags & SPLICE_F_NONBLOCK))
55734 + if (!ret && atomic_read(&ipipe->waiting_writers) && (flags & SPLICE_F_NONBLOCK))
55735 ret = -EAGAIN;
55736
55737 pipe_unlock(ipipe);
55738 diff --git a/fs/stat.c b/fs/stat.c
55739 index 14f4545..9b7f55b 100644
55740 --- a/fs/stat.c
55741 +++ b/fs/stat.c
55742 @@ -28,8 +28,13 @@ void generic_fillattr(struct inode *inode, struct kstat *stat)
55743 stat->gid = inode->i_gid;
55744 stat->rdev = inode->i_rdev;
55745 stat->size = i_size_read(inode);
55746 - stat->atime = inode->i_atime;
55747 - stat->mtime = inode->i_mtime;
55748 + if (is_sidechannel_device(inode) && !capable_nolog(CAP_MKNOD)) {
55749 + stat->atime = inode->i_ctime;
55750 + stat->mtime = inode->i_ctime;
55751 + } else {
55752 + stat->atime = inode->i_atime;
55753 + stat->mtime = inode->i_mtime;
55754 + }
55755 stat->ctime = inode->i_ctime;
55756 stat->blksize = (1 << inode->i_blkbits);
55757 stat->blocks = inode->i_blocks;
55758 @@ -46,8 +51,14 @@ int vfs_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat)
55759 if (retval)
55760 return retval;
55761
55762 - if (inode->i_op->getattr)
55763 - return inode->i_op->getattr(mnt, dentry, stat);
55764 + if (inode->i_op->getattr) {
55765 + retval = inode->i_op->getattr(mnt, dentry, stat);
55766 + if (!retval && is_sidechannel_device(inode) && !capable_nolog(CAP_MKNOD)) {
55767 + stat->atime = stat->ctime;
55768 + stat->mtime = stat->ctime;
55769 + }
55770 + return retval;
55771 + }
55772
55773 generic_fillattr(inode, stat);
55774 return 0;
55775 diff --git a/fs/sysfs/dir.c b/fs/sysfs/dir.c
55776 index 2fbdff6..5530a61 100644
55777 --- a/fs/sysfs/dir.c
55778 +++ b/fs/sysfs/dir.c
55779 @@ -685,6 +685,18 @@ static int create_dir(struct kobject *kobj, struct sysfs_dirent *parent_sd,
55780 struct sysfs_dirent *sd;
55781 int rc;
55782
55783 +#ifdef CONFIG_GRKERNSEC_SYSFS_RESTRICT
55784 + const char *parent_name = parent_sd->s_name;
55785 +
55786 + mode = S_IFDIR | S_IRWXU;
55787 +
55788 + if ((!strcmp(parent_name, "") && (!strcmp(name, "devices") || !strcmp(name, "fs"))) ||
55789 + (!strcmp(parent_name, "devices") && !strcmp(name, "system")) ||
55790 + (!strcmp(parent_name, "fs") && (!strcmp(name, "selinux") || !strcmp(name, "fuse"))) ||
55791 + (!strcmp(parent_name, "system") && !strcmp(name, "cpu")))
55792 + mode = S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO;
55793 +#endif
55794 +
55795 /* allocate */
55796 sd = sysfs_new_dirent(name, mode, SYSFS_DIR);
55797 if (!sd)
55798 diff --git a/fs/sysfs/file.c b/fs/sysfs/file.c
55799 index 602f56d..6853db8 100644
55800 --- a/fs/sysfs/file.c
55801 +++ b/fs/sysfs/file.c
55802 @@ -37,7 +37,7 @@ static DEFINE_SPINLOCK(sysfs_open_dirent_lock);
55803
55804 struct sysfs_open_dirent {
55805 atomic_t refcnt;
55806 - atomic_t event;
55807 + atomic_unchecked_t event;
55808 wait_queue_head_t poll;
55809 struct list_head buffers; /* goes through sysfs_buffer.list */
55810 };
55811 @@ -81,7 +81,7 @@ static int fill_read_buffer(struct dentry * dentry, struct sysfs_buffer * buffer
55812 if (!sysfs_get_active(attr_sd))
55813 return -ENODEV;
55814
55815 - buffer->event = atomic_read(&attr_sd->s_attr.open->event);
55816 + buffer->event = atomic_read_unchecked(&attr_sd->s_attr.open->event);
55817 count = ops->show(kobj, attr_sd->s_attr.attr, buffer->page);
55818
55819 sysfs_put_active(attr_sd);
55820 @@ -287,7 +287,7 @@ static int sysfs_get_open_dirent(struct sysfs_dirent *sd,
55821 return -ENOMEM;
55822
55823 atomic_set(&new_od->refcnt, 0);
55824 - atomic_set(&new_od->event, 1);
55825 + atomic_set_unchecked(&new_od->event, 1);
55826 init_waitqueue_head(&new_od->poll);
55827 INIT_LIST_HEAD(&new_od->buffers);
55828 goto retry;
55829 @@ -432,7 +432,7 @@ static unsigned int sysfs_poll(struct file *filp, poll_table *wait)
55830
55831 sysfs_put_active(attr_sd);
55832
55833 - if (buffer->event != atomic_read(&od->event))
55834 + if (buffer->event != atomic_read_unchecked(&od->event))
55835 goto trigger;
55836
55837 return DEFAULT_POLLMASK;
55838 @@ -451,7 +451,7 @@ void sysfs_notify_dirent(struct sysfs_dirent *sd)
55839
55840 od = sd->s_attr.open;
55841 if (od) {
55842 - atomic_inc(&od->event);
55843 + atomic_inc_unchecked(&od->event);
55844 wake_up_interruptible(&od->poll);
55845 }
55846
55847 diff --git a/fs/sysfs/symlink.c b/fs/sysfs/symlink.c
55848 index 3c9eb56..9dea5be 100644
55849 --- a/fs/sysfs/symlink.c
55850 +++ b/fs/sysfs/symlink.c
55851 @@ -286,7 +286,7 @@ static void *sysfs_follow_link(struct dentry *dentry, struct nameidata *nd)
55852
55853 static void sysfs_put_link(struct dentry *dentry, struct nameidata *nd, void *cookie)
55854 {
55855 - char *page = nd_get_link(nd);
55856 + const char *page = nd_get_link(nd);
55857 if (!IS_ERR(page))
55858 free_page((unsigned long)page);
55859 }
55860 diff --git a/fs/sysv/sysv.h b/fs/sysv/sysv.h
55861 index 69d4889..a810bd4 100644
55862 --- a/fs/sysv/sysv.h
55863 +++ b/fs/sysv/sysv.h
55864 @@ -188,7 +188,7 @@ static inline u32 PDP_swab(u32 x)
55865 #endif
55866 }
55867
55868 -static inline __u32 fs32_to_cpu(struct sysv_sb_info *sbi, __fs32 n)
55869 +static inline __u32 __intentional_overflow(-1) fs32_to_cpu(struct sysv_sb_info *sbi, __fs32 n)
55870 {
55871 if (sbi->s_bytesex == BYTESEX_PDP)
55872 return PDP_swab((__force __u32)n);
55873 diff --git a/fs/ubifs/io.c b/fs/ubifs/io.c
55874 index e18b988..f1d4ad0f 100644
55875 --- a/fs/ubifs/io.c
55876 +++ b/fs/ubifs/io.c
55877 @@ -155,7 +155,7 @@ int ubifs_leb_change(struct ubifs_info *c, int lnum, const void *buf, int len)
55878 return err;
55879 }
55880
55881 -int ubifs_leb_unmap(struct ubifs_info *c, int lnum)
55882 +int __intentional_overflow(-1) ubifs_leb_unmap(struct ubifs_info *c, int lnum)
55883 {
55884 int err;
55885
55886 diff --git a/fs/udf/misc.c b/fs/udf/misc.c
55887 index c175b4d..8f36a16 100644
55888 --- a/fs/udf/misc.c
55889 +++ b/fs/udf/misc.c
55890 @@ -289,7 +289,7 @@ void udf_new_tag(char *data, uint16_t ident, uint16_t version, uint16_t snum,
55891
55892 u8 udf_tag_checksum(const struct tag *t)
55893 {
55894 - u8 *data = (u8 *)t;
55895 + const u8 *data = (const u8 *)t;
55896 u8 checksum = 0;
55897 int i;
55898 for (i = 0; i < sizeof(struct tag); ++i)
55899 diff --git a/fs/ufs/swab.h b/fs/ufs/swab.h
55900 index 8d974c4..b82f6ec 100644
55901 --- a/fs/ufs/swab.h
55902 +++ b/fs/ufs/swab.h
55903 @@ -22,7 +22,7 @@ enum {
55904 BYTESEX_BE
55905 };
55906
55907 -static inline u64
55908 +static inline u64 __intentional_overflow(-1)
55909 fs64_to_cpu(struct super_block *sbp, __fs64 n)
55910 {
55911 if (UFS_SB(sbp)->s_bytesex == BYTESEX_LE)
55912 @@ -40,7 +40,7 @@ cpu_to_fs64(struct super_block *sbp, u64 n)
55913 return (__force __fs64)cpu_to_be64(n);
55914 }
55915
55916 -static inline u32
55917 +static inline u32 __intentional_overflow(-1)
55918 fs32_to_cpu(struct super_block *sbp, __fs32 n)
55919 {
55920 if (UFS_SB(sbp)->s_bytesex == BYTESEX_LE)
55921 diff --git a/fs/utimes.c b/fs/utimes.c
55922 index f4fb7ec..3fe03c0 100644
55923 --- a/fs/utimes.c
55924 +++ b/fs/utimes.c
55925 @@ -1,6 +1,7 @@
55926 #include <linux/compiler.h>
55927 #include <linux/file.h>
55928 #include <linux/fs.h>
55929 +#include <linux/security.h>
55930 #include <linux/linkage.h>
55931 #include <linux/mount.h>
55932 #include <linux/namei.h>
55933 @@ -101,6 +102,12 @@ static int utimes_common(struct path *path, struct timespec *times)
55934 goto mnt_drop_write_and_out;
55935 }
55936 }
55937 +
55938 + if (!gr_acl_handle_utime(path->dentry, path->mnt)) {
55939 + error = -EACCES;
55940 + goto mnt_drop_write_and_out;
55941 + }
55942 +
55943 mutex_lock(&inode->i_mutex);
55944 error = notify_change(path->dentry, &newattrs);
55945 mutex_unlock(&inode->i_mutex);
55946 diff --git a/fs/xattr.c b/fs/xattr.c
55947 index 3377dff..4feded6 100644
55948 --- a/fs/xattr.c
55949 +++ b/fs/xattr.c
55950 @@ -319,7 +319,7 @@ EXPORT_SYMBOL_GPL(vfs_removexattr);
55951 * Extended attribute SET operations
55952 */
55953 static long
55954 -setxattr(struct dentry *d, const char __user *name, const void __user *value,
55955 +setxattr(struct path *path, const char __user *name, const void __user *value,
55956 size_t size, int flags)
55957 {
55958 int error;
55959 @@ -355,7 +355,12 @@ setxattr(struct dentry *d, const char __user *name, const void __user *value,
55960 posix_acl_fix_xattr_from_user(kvalue, size);
55961 }
55962
55963 - error = vfs_setxattr(d, kname, kvalue, size, flags);
55964 + if (!gr_acl_handle_setxattr(path->dentry, path->mnt)) {
55965 + error = -EACCES;
55966 + goto out;
55967 + }
55968 +
55969 + error = vfs_setxattr(path->dentry, kname, kvalue, size, flags);
55970 out:
55971 if (vvalue)
55972 vfree(vvalue);
55973 @@ -377,7 +382,7 @@ retry:
55974 return error;
55975 error = mnt_want_write(path.mnt);
55976 if (!error) {
55977 - error = setxattr(path.dentry, name, value, size, flags);
55978 + error = setxattr(&path, name, value, size, flags);
55979 mnt_drop_write(path.mnt);
55980 }
55981 path_put(&path);
55982 @@ -401,7 +406,7 @@ retry:
55983 return error;
55984 error = mnt_want_write(path.mnt);
55985 if (!error) {
55986 - error = setxattr(path.dentry, name, value, size, flags);
55987 + error = setxattr(&path, name, value, size, flags);
55988 mnt_drop_write(path.mnt);
55989 }
55990 path_put(&path);
55991 @@ -416,16 +421,14 @@ SYSCALL_DEFINE5(fsetxattr, int, fd, const char __user *, name,
55992 const void __user *,value, size_t, size, int, flags)
55993 {
55994 struct fd f = fdget(fd);
55995 - struct dentry *dentry;
55996 int error = -EBADF;
55997
55998 if (!f.file)
55999 return error;
56000 - dentry = f.file->f_path.dentry;
56001 - audit_inode(NULL, dentry, 0);
56002 + audit_inode(NULL, f.file->f_path.dentry, 0);
56003 error = mnt_want_write_file(f.file);
56004 if (!error) {
56005 - error = setxattr(dentry, name, value, size, flags);
56006 + error = setxattr(&f.file->f_path, name, value, size, flags);
56007 mnt_drop_write_file(f.file);
56008 }
56009 fdput(f);
56010 diff --git a/fs/xattr_acl.c b/fs/xattr_acl.c
56011 index 9fbea87..6b19972 100644
56012 --- a/fs/xattr_acl.c
56013 +++ b/fs/xattr_acl.c
56014 @@ -76,8 +76,8 @@ struct posix_acl *
56015 posix_acl_from_xattr(struct user_namespace *user_ns,
56016 const void *value, size_t size)
56017 {
56018 - posix_acl_xattr_header *header = (posix_acl_xattr_header *)value;
56019 - posix_acl_xattr_entry *entry = (posix_acl_xattr_entry *)(header+1), *end;
56020 + const posix_acl_xattr_header *header = (const posix_acl_xattr_header *)value;
56021 + const posix_acl_xattr_entry *entry = (const posix_acl_xattr_entry *)(header+1), *end;
56022 int count;
56023 struct posix_acl *acl;
56024 struct posix_acl_entry *acl_e;
56025 diff --git a/fs/xfs/xfs_bmap.c b/fs/xfs/xfs_bmap.c
56026 index 572a858..12a9b0d 100644
56027 --- a/fs/xfs/xfs_bmap.c
56028 +++ b/fs/xfs/xfs_bmap.c
56029 @@ -192,7 +192,7 @@ xfs_bmap_validate_ret(
56030 int nmap,
56031 int ret_nmap);
56032 #else
56033 -#define xfs_bmap_validate_ret(bno,len,flags,mval,onmap,nmap)
56034 +#define xfs_bmap_validate_ret(bno,len,flags,mval,onmap,nmap) do {} while (0)
56035 #endif /* DEBUG */
56036
56037 STATIC int
56038 diff --git a/fs/xfs/xfs_dir2_sf.c b/fs/xfs/xfs_dir2_sf.c
56039 index 1b9fc3e..e1bdde0 100644
56040 --- a/fs/xfs/xfs_dir2_sf.c
56041 +++ b/fs/xfs/xfs_dir2_sf.c
56042 @@ -851,7 +851,15 @@ xfs_dir2_sf_getdents(
56043 }
56044
56045 ino = xfs_dir2_sfe_get_ino(sfp, sfep);
56046 - if (filldir(dirent, (char *)sfep->name, sfep->namelen,
56047 + if (dp->i_df.if_u1.if_data == dp->i_df.if_u2.if_inline_data) {
56048 + char name[sfep->namelen];
56049 + memcpy(name, sfep->name, sfep->namelen);
56050 + if (filldir(dirent, name, sfep->namelen,
56051 + off & 0x7fffffff, ino, DT_UNKNOWN)) {
56052 + *offset = off & 0x7fffffff;
56053 + return 0;
56054 + }
56055 + } else if (filldir(dirent, (char *)sfep->name, sfep->namelen,
56056 off & 0x7fffffff, ino, DT_UNKNOWN)) {
56057 *offset = off & 0x7fffffff;
56058 return 0;
56059 diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c
56060 index c1c3ef8..0952438 100644
56061 --- a/fs/xfs/xfs_ioctl.c
56062 +++ b/fs/xfs/xfs_ioctl.c
56063 @@ -127,7 +127,7 @@ xfs_find_handle(
56064 }
56065
56066 error = -EFAULT;
56067 - if (copy_to_user(hreq->ohandle, &handle, hsize) ||
56068 + if (hsize > sizeof handle || copy_to_user(hreq->ohandle, &handle, hsize) ||
56069 copy_to_user(hreq->ohandlen, &hsize, sizeof(__s32)))
56070 goto out_put;
56071
56072 diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c
56073 index d82efaa..0904a8e 100644
56074 --- a/fs/xfs/xfs_iops.c
56075 +++ b/fs/xfs/xfs_iops.c
56076 @@ -395,7 +395,7 @@ xfs_vn_put_link(
56077 struct nameidata *nd,
56078 void *p)
56079 {
56080 - char *s = nd_get_link(nd);
56081 + const char *s = nd_get_link(nd);
56082
56083 if (!IS_ERR(s))
56084 kfree(s);
56085 diff --git a/grsecurity/Kconfig b/grsecurity/Kconfig
56086 new file mode 100644
56087 index 0000000..92247e4
56088 --- /dev/null
56089 +++ b/grsecurity/Kconfig
56090 @@ -0,0 +1,1021 @@
56091 +#
56092 +# grecurity configuration
56093 +#
56094 +menu "Memory Protections"
56095 +depends on GRKERNSEC
56096 +
56097 +config GRKERNSEC_KMEM
56098 + bool "Deny reading/writing to /dev/kmem, /dev/mem, and /dev/port"
56099 + default y if GRKERNSEC_CONFIG_AUTO
56100 + select STRICT_DEVMEM if (X86 || ARM || TILE || S390)
56101 + help
56102 + If you say Y here, /dev/kmem and /dev/mem won't be allowed to
56103 + be written to or read from to modify or leak the contents of the running
56104 + kernel. /dev/port will also not be allowed to be opened and support
56105 + for /dev/cpu/*/msr will be removed. If you have module
56106 + support disabled, enabling this will close up five ways that are
56107 + currently used to insert malicious code into the running kernel.
56108 +
56109 + Even with all these features enabled, we still highly recommend that
56110 + you use the RBAC system, as it is still possible for an attacker to
56111 + modify the running kernel through privileged I/O granted by ioperm/iopl.
56112 +
56113 + If you are not using XFree86, you may be able to stop this additional
56114 + case by enabling the 'Disable privileged I/O' option. Though nothing
56115 + legitimately writes to /dev/kmem, XFree86 does need to write to /dev/mem,
56116 + but only to video memory, which is the only writing we allow in this
56117 + case. If /dev/kmem or /dev/mem are mmaped without PROT_WRITE, they will
56118 + not be allowed to mprotect it with PROT_WRITE later.
56119 + Enabling this feature will prevent the "cpupower" and "powertop" tools
56120 + from working.
56121 +
56122 + It is highly recommended that you say Y here if you meet all the
56123 + conditions above.
56124 +
56125 +config GRKERNSEC_VM86
56126 + bool "Restrict VM86 mode"
56127 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER)
56128 + depends on X86_32
56129 +
56130 + help
56131 + If you say Y here, only processes with CAP_SYS_RAWIO will be able to
56132 + make use of a special execution mode on 32bit x86 processors called
56133 + Virtual 8086 (VM86) mode. XFree86 may need vm86 mode for certain
56134 + video cards and will still work with this option enabled. The purpose
56135 + of the option is to prevent exploitation of emulation errors in
56136 + virtualization of vm86 mode like the one discovered in VMWare in 2009.
56137 + Nearly all users should be able to enable this option.
56138 +
56139 +config GRKERNSEC_IO
56140 + bool "Disable privileged I/O"
56141 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER)
56142 + depends on X86
56143 + select RTC_CLASS
56144 + select RTC_INTF_DEV
56145 + select RTC_DRV_CMOS
56146 +
56147 + help
56148 + If you say Y here, all ioperm and iopl calls will return an error.
56149 + Ioperm and iopl can be used to modify the running kernel.
56150 + Unfortunately, some programs need this access to operate properly,
56151 + the most notable of which are XFree86 and hwclock. hwclock can be
56152 + remedied by having RTC support in the kernel, so real-time
56153 + clock support is enabled if this option is enabled, to ensure
56154 + that hwclock operates correctly. XFree86 still will not
56155 + operate correctly with this option enabled, so DO NOT CHOOSE Y
56156 + IF YOU USE XFree86. If you use XFree86 and you still want to
56157 + protect your kernel against modification, use the RBAC system.
56158 +
56159 +config GRKERNSEC_JIT_HARDEN
56160 + bool "Harden BPF JIT against spray attacks"
56161 + default y if GRKERNSEC_CONFIG_AUTO
56162 + depends on BPF_JIT
56163 + help
56164 + If you say Y here, the native code generated by the kernel's Berkeley
56165 + Packet Filter (BPF) JIT engine will be hardened against JIT-spraying
56166 + attacks that attempt to fit attacker-beneficial instructions in
56167 + 32bit immediate fields of JIT-generated native instructions. The
56168 + attacker will generally aim to cause an unintended instruction sequence
56169 + of JIT-generated native code to execute by jumping into the middle of
56170 + a generated instruction. This feature effectively randomizes the 32bit
56171 + immediate constants present in the generated code to thwart such attacks.
56172 +
56173 + If you're using KERNEXEC, it's recommended that you enable this option
56174 + to supplement the hardening of the kernel.
56175 +
56176 +config GRKERNSEC_RAND_THREADSTACK
56177 + bool "Insert random gaps between thread stacks"
56178 + default y if GRKERNSEC_CONFIG_AUTO
56179 + depends on PAX_RANDMMAP && !PPC
56180 + help
56181 + If you say Y here, a random-sized gap will be enforced between allocated
56182 + thread stacks. Glibc's NPTL and other threading libraries that
56183 + pass MAP_STACK to the kernel for thread stack allocation are supported.
56184 + The implementation currently provides 8 bits of entropy for the gap.
56185 +
56186 + Many distributions do not compile threaded remote services with the
56187 + -fstack-check argument to GCC, causing the variable-sized stack-based
56188 + allocator, alloca(), to not probe the stack on allocation. This
56189 + permits an unbounded alloca() to skip over any guard page and potentially
56190 + modify another thread's stack reliably. An enforced random gap
56191 + reduces the reliability of such an attack and increases the chance
56192 + that such a read/write to another thread's stack instead lands in
56193 + an unmapped area, causing a crash and triggering grsecurity's
56194 + anti-bruteforcing logic.
56195 +
56196 +config GRKERNSEC_PROC_MEMMAP
56197 + bool "Harden ASLR against information leaks and entropy reduction"
56198 + default y if (GRKERNSEC_CONFIG_AUTO || PAX_NOEXEC || PAX_ASLR)
56199 + depends on PAX_NOEXEC || PAX_ASLR
56200 + help
56201 + If you say Y here, the /proc/<pid>/maps and /proc/<pid>/stat files will
56202 + give no information about the addresses of its mappings if
56203 + PaX features that rely on random addresses are enabled on the task.
56204 + In addition to sanitizing this information and disabling other
56205 + dangerous sources of information, this option causes reads of sensitive
56206 + /proc/<pid> entries where the file descriptor was opened in a different
56207 + task than the one performing the read. Such attempts are logged.
56208 + This option also limits argv/env strings for suid/sgid binaries
56209 + to 512KB to prevent a complete exhaustion of the stack entropy provided
56210 + by ASLR. Finally, it places an 8MB stack resource limit on suid/sgid
56211 + binaries to prevent alternative mmap layouts from being abused.
56212 +
56213 + If you use PaX it is essential that you say Y here as it closes up
56214 + several holes that make full ASLR useless locally.
56215 +
56216 +config GRKERNSEC_BRUTE
56217 + bool "Deter exploit bruteforcing"
56218 + default y if GRKERNSEC_CONFIG_AUTO
56219 + help
56220 + If you say Y here, attempts to bruteforce exploits against forking
56221 + daemons such as apache or sshd, as well as against suid/sgid binaries
56222 + will be deterred. When a child of a forking daemon is killed by PaX
56223 + or crashes due to an illegal instruction or other suspicious signal,
56224 + the parent process will be delayed 30 seconds upon every subsequent
56225 + fork until the administrator is able to assess the situation and
56226 + restart the daemon.
56227 + In the suid/sgid case, the attempt is logged, the user has all their
56228 + processes terminated, and they are prevented from executing any further
56229 + processes for 15 minutes.
56230 + It is recommended that you also enable signal logging in the auditing
56231 + section so that logs are generated when a process triggers a suspicious
56232 + signal.
56233 + If the sysctl option is enabled, a sysctl option with name
56234 + "deter_bruteforce" is created.
56235 +
56236 +
56237 +config GRKERNSEC_MODHARDEN
56238 + bool "Harden module auto-loading"
56239 + default y if GRKERNSEC_CONFIG_AUTO
56240 + depends on MODULES
56241 + help
56242 + If you say Y here, module auto-loading in response to use of some
56243 + feature implemented by an unloaded module will be restricted to
56244 + root users. Enabling this option helps defend against attacks
56245 + by unprivileged users who abuse the auto-loading behavior to
56246 + cause a vulnerable module to load that is then exploited.
56247 +
56248 + If this option prevents a legitimate use of auto-loading for a
56249 + non-root user, the administrator can execute modprobe manually
56250 + with the exact name of the module mentioned in the alert log.
56251 + Alternatively, the administrator can add the module to the list
56252 + of modules loaded at boot by modifying init scripts.
56253 +
56254 + Modification of init scripts will most likely be needed on
56255 + Ubuntu servers with encrypted home directory support enabled,
56256 + as the first non-root user logging in will cause the ecb(aes),
56257 + ecb(aes)-all, cbc(aes), and cbc(aes)-all modules to be loaded.
56258 +
56259 +config GRKERNSEC_HIDESYM
56260 + bool "Hide kernel symbols"
56261 + default y if GRKERNSEC_CONFIG_AUTO
56262 + select PAX_USERCOPY_SLABS
56263 + help
56264 + If you say Y here, getting information on loaded modules, and
56265 + displaying all kernel symbols through a syscall will be restricted
56266 + to users with CAP_SYS_MODULE. For software compatibility reasons,
56267 + /proc/kallsyms will be restricted to the root user. The RBAC
56268 + system can hide that entry even from root.
56269 +
56270 + This option also prevents leaking of kernel addresses through
56271 + several /proc entries.
56272 +
56273 + Note that this option is only effective provided the following
56274 + conditions are met:
56275 + 1) The kernel using grsecurity is not precompiled by some distribution
56276 + 2) You have also enabled GRKERNSEC_DMESG
56277 + 3) You are using the RBAC system and hiding other files such as your
56278 + kernel image and System.map. Alternatively, enabling this option
56279 + causes the permissions on /boot, /lib/modules, and the kernel
56280 + source directory to change at compile time to prevent
56281 + reading by non-root users.
56282 + If the above conditions are met, this option will aid in providing a
56283 + useful protection against local kernel exploitation of overflows
56284 + and arbitrary read/write vulnerabilities.
56285 +
56286 +config GRKERNSEC_KERN_LOCKOUT
56287 + bool "Active kernel exploit response"
56288 + default y if GRKERNSEC_CONFIG_AUTO
56289 + depends on X86 || ARM || PPC || SPARC
56290 + help
56291 + If you say Y here, when a PaX alert is triggered due to suspicious
56292 + activity in the kernel (from KERNEXEC/UDEREF/USERCOPY)
56293 + or an OOPS occurs due to bad memory accesses, instead of just
56294 + terminating the offending process (and potentially allowing
56295 + a subsequent exploit from the same user), we will take one of two
56296 + actions:
56297 + If the user was root, we will panic the system
56298 + If the user was non-root, we will log the attempt, terminate
56299 + all processes owned by the user, then prevent them from creating
56300 + any new processes until the system is restarted
56301 + This deters repeated kernel exploitation/bruteforcing attempts
56302 + and is useful for later forensics.
56303 +
56304 +endmenu
56305 +menu "Role Based Access Control Options"
56306 +depends on GRKERNSEC
56307 +
56308 +config GRKERNSEC_RBAC_DEBUG
56309 + bool
56310 +
56311 +config GRKERNSEC_NO_RBAC
56312 + bool "Disable RBAC system"
56313 + help
56314 + If you say Y here, the /dev/grsec device will be removed from the kernel,
56315 + preventing the RBAC system from being enabled. You should only say Y
56316 + here if you have no intention of using the RBAC system, so as to prevent
56317 + an attacker with root access from misusing the RBAC system to hide files
56318 + and processes when loadable module support and /dev/[k]mem have been
56319 + locked down.
56320 +
56321 +config GRKERNSEC_ACL_HIDEKERN
56322 + bool "Hide kernel processes"
56323 + help
56324 + If you say Y here, all kernel threads will be hidden to all
56325 + processes but those whose subject has the "view hidden processes"
56326 + flag.
56327 +
56328 +config GRKERNSEC_ACL_MAXTRIES
56329 + int "Maximum tries before password lockout"
56330 + default 3
56331 + help
56332 + This option enforces the maximum number of times a user can attempt
56333 + to authorize themselves with the grsecurity RBAC system before being
56334 + denied the ability to attempt authorization again for a specified time.
56335 + The lower the number, the harder it will be to brute-force a password.
56336 +
56337 +config GRKERNSEC_ACL_TIMEOUT
56338 + int "Time to wait after max password tries, in seconds"
56339 + default 30
56340 + help
56341 + This option specifies the time the user must wait after attempting to
56342 + authorize to the RBAC system with the maximum number of invalid
56343 + passwords. The higher the number, the harder it will be to brute-force
56344 + a password.
56345 +
56346 +endmenu
56347 +menu "Filesystem Protections"
56348 +depends on GRKERNSEC
56349 +
56350 +config GRKERNSEC_PROC
56351 + bool "Proc restrictions"
56352 + default y if GRKERNSEC_CONFIG_AUTO
56353 + help
56354 + If you say Y here, the permissions of the /proc filesystem
56355 + will be altered to enhance system security and privacy. You MUST
56356 + choose either a user only restriction or a user and group restriction.
56357 + Depending upon the option you choose, you can either restrict users to
56358 + see only the processes they themselves run, or choose a group that can
56359 + view all processes and files normally restricted to root if you choose
56360 + the "restrict to user only" option. NOTE: If you're running identd or
56361 + ntpd as a non-root user, you will have to run it as the group you
56362 + specify here.
56363 +
56364 +config GRKERNSEC_PROC_USER
56365 + bool "Restrict /proc to user only"
56366 + depends on GRKERNSEC_PROC
56367 + help
56368 + If you say Y here, non-root users will only be able to view their own
56369 + processes, and restricts them from viewing network-related information,
56370 + and viewing kernel symbol and module information.
56371 +
56372 +config GRKERNSEC_PROC_USERGROUP
56373 + bool "Allow special group"
56374 + default y if GRKERNSEC_CONFIG_AUTO
56375 + depends on GRKERNSEC_PROC && !GRKERNSEC_PROC_USER
56376 + help
56377 + If you say Y here, you will be able to select a group that will be
56378 + able to view all processes and network-related information. If you've
56379 + enabled GRKERNSEC_HIDESYM, kernel and symbol information may still
56380 + remain hidden. This option is useful if you want to run identd as
56381 + a non-root user. The group you select may also be chosen at boot time
56382 + via "grsec_proc_gid=" on the kernel commandline.
56383 +
56384 +config GRKERNSEC_PROC_GID
56385 + int "GID for special group"
56386 + depends on GRKERNSEC_PROC_USERGROUP
56387 + default 1001
56388 +
56389 +config GRKERNSEC_PROC_ADD
56390 + bool "Additional restrictions"
56391 + default y if GRKERNSEC_CONFIG_AUTO
56392 + depends on GRKERNSEC_PROC_USER || GRKERNSEC_PROC_USERGROUP
56393 + help
56394 + If you say Y here, additional restrictions will be placed on
56395 + /proc that keep normal users from viewing device information and
56396 + slabinfo information that could be useful for exploits.
56397 +
56398 +config GRKERNSEC_LINK
56399 + bool "Linking restrictions"
56400 + default y if GRKERNSEC_CONFIG_AUTO
56401 + help
56402 + If you say Y here, /tmp race exploits will be prevented, since users
56403 + will no longer be able to follow symlinks owned by other users in
56404 + world-writable +t directories (e.g. /tmp), unless the owner of the
56405 + symlink is the owner of the directory. users will also not be
56406 + able to hardlink to files they do not own. If the sysctl option is
56407 + enabled, a sysctl option with name "linking_restrictions" is created.
56408 +
56409 +config GRKERNSEC_SYMLINKOWN
56410 + bool "Kernel-enforced SymlinksIfOwnerMatch"
56411 + default y if GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER
56412 + help
56413 + Apache's SymlinksIfOwnerMatch option has an inherent race condition
56414 + that prevents it from being used as a security feature. As Apache
56415 + verifies the symlink by performing a stat() against the target of
56416 + the symlink before it is followed, an attacker can setup a symlink
56417 + to point to a same-owned file, then replace the symlink with one
56418 + that targets another user's file just after Apache "validates" the
56419 + symlink -- a classic TOCTOU race. If you say Y here, a complete,
56420 + race-free replacement for Apache's "SymlinksIfOwnerMatch" option
56421 + will be in place for the group you specify. If the sysctl option
56422 + is enabled, a sysctl option with name "enforce_symlinksifowner" is
56423 + created.
56424 +
56425 +config GRKERNSEC_SYMLINKOWN_GID
56426 + int "GID for users with kernel-enforced SymlinksIfOwnerMatch"
56427 + depends on GRKERNSEC_SYMLINKOWN
56428 + default 1006
56429 + help
56430 + Setting this GID determines what group kernel-enforced
56431 + SymlinksIfOwnerMatch will be enabled for. If the sysctl option
56432 + is enabled, a sysctl option with name "symlinkown_gid" is created.
56433 +
56434 +config GRKERNSEC_FIFO
56435 + bool "FIFO restrictions"
56436 + default y if GRKERNSEC_CONFIG_AUTO
56437 + help
56438 + If you say Y here, users will not be able to write to FIFOs they don't
56439 + own in world-writable +t directories (e.g. /tmp), unless the owner of
56440 + the FIFO is the same owner of the directory it's held in. If the sysctl
56441 + option is enabled, a sysctl option with name "fifo_restrictions" is
56442 + created.
56443 +
56444 +config GRKERNSEC_SYSFS_RESTRICT
56445 + bool "Sysfs/debugfs restriction"
56446 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER)
56447 + depends on SYSFS
56448 + help
56449 + If you say Y here, sysfs (the pseudo-filesystem mounted at /sys) and
56450 + any filesystem normally mounted under it (e.g. debugfs) will be
56451 + mostly accessible only by root. These filesystems generally provide access
56452 + to hardware and debug information that isn't appropriate for unprivileged
56453 + users of the system. Sysfs and debugfs have also become a large source
56454 + of new vulnerabilities, ranging from infoleaks to local compromise.
56455 + There has been very little oversight with an eye toward security involved
56456 + in adding new exporters of information to these filesystems, so their
56457 + use is discouraged.
56458 + For reasons of compatibility, a few directories have been whitelisted
56459 + for access by non-root users:
56460 + /sys/fs/selinux
56461 + /sys/fs/fuse
56462 + /sys/devices/system/cpu
56463 +
56464 +config GRKERNSEC_ROFS
56465 + bool "Runtime read-only mount protection"
56466 + help
56467 + If you say Y here, a sysctl option with name "romount_protect" will
56468 + be created. By setting this option to 1 at runtime, filesystems
56469 + will be protected in the following ways:
56470 + * No new writable mounts will be allowed
56471 + * Existing read-only mounts won't be able to be remounted read/write
56472 + * Write operations will be denied on all block devices
56473 + This option acts independently of grsec_lock: once it is set to 1,
56474 + it cannot be turned off. Therefore, please be mindful of the resulting
56475 + behavior if this option is enabled in an init script on a read-only
56476 + filesystem. This feature is mainly intended for secure embedded systems.
56477 +
56478 +config GRKERNSEC_DEVICE_SIDECHANNEL
56479 + bool "Eliminate stat/notify-based device sidechannels"
56480 + default y if GRKERNSEC_CONFIG_AUTO
56481 + help
56482 + If you say Y here, timing analyses on block or character
56483 + devices like /dev/ptmx using stat or inotify/dnotify/fanotify
56484 + will be thwarted for unprivileged users. If a process without
56485 + CAP_MKNOD stats such a device, the last access and last modify times
56486 + will match the device's create time. No access or modify events
56487 + will be triggered through inotify/dnotify/fanotify for such devices.
56488 + This feature will prevent attacks that may at a minimum
56489 + allow an attacker to determine the administrator's password length.
56490 +
56491 +config GRKERNSEC_CHROOT
56492 + bool "Chroot jail restrictions"
56493 + default y if GRKERNSEC_CONFIG_AUTO
56494 + help
56495 + If you say Y here, you will be able to choose several options that will
56496 + make breaking out of a chrooted jail much more difficult. If you
56497 + encounter no software incompatibilities with the following options, it
56498 + is recommended that you enable each one.
56499 +
56500 +config GRKERNSEC_CHROOT_MOUNT
56501 + bool "Deny mounts"
56502 + default y if GRKERNSEC_CONFIG_AUTO
56503 + depends on GRKERNSEC_CHROOT
56504 + help
56505 + If you say Y here, processes inside a chroot will not be able to
56506 + mount or remount filesystems. If the sysctl option is enabled, a
56507 + sysctl option with name "chroot_deny_mount" is created.
56508 +
56509 +config GRKERNSEC_CHROOT_DOUBLE
56510 + bool "Deny double-chroots"
56511 + default y if GRKERNSEC_CONFIG_AUTO
56512 + depends on GRKERNSEC_CHROOT
56513 + help
56514 + If you say Y here, processes inside a chroot will not be able to chroot
56515 + again outside the chroot. This is a widely used method of breaking
56516 + out of a chroot jail and should not be allowed. If the sysctl
56517 + option is enabled, a sysctl option with name
56518 + "chroot_deny_chroot" is created.
56519 +
56520 +config GRKERNSEC_CHROOT_PIVOT
56521 + bool "Deny pivot_root in chroot"
56522 + default y if GRKERNSEC_CONFIG_AUTO
56523 + depends on GRKERNSEC_CHROOT
56524 + help
56525 + If you say Y here, processes inside a chroot will not be able to use
56526 + a function called pivot_root() that was introduced in Linux 2.3.41. It
56527 + works similar to chroot in that it changes the root filesystem. This
56528 + function could be misused in a chrooted process to attempt to break out
56529 + of the chroot, and therefore should not be allowed. If the sysctl
56530 + option is enabled, a sysctl option with name "chroot_deny_pivot" is
56531 + created.
56532 +
56533 +config GRKERNSEC_CHROOT_CHDIR
56534 + bool "Enforce chdir(\"/\") on all chroots"
56535 + default y if GRKERNSEC_CONFIG_AUTO
56536 + depends on GRKERNSEC_CHROOT
56537 + help
56538 + If you say Y here, the current working directory of all newly-chrooted
56539 + applications will be set to the the root directory of the chroot.
56540 + The man page on chroot(2) states:
56541 + Note that this call does not change the current working
56542 + directory, so that `.' can be outside the tree rooted at
56543 + `/'. In particular, the super-user can escape from a
56544 + `chroot jail' by doing `mkdir foo; chroot foo; cd ..'.
56545 +
56546 + It is recommended that you say Y here, since it's not known to break
56547 + any software. If the sysctl option is enabled, a sysctl option with
56548 + name "chroot_enforce_chdir" is created.
56549 +
56550 +config GRKERNSEC_CHROOT_CHMOD
56551 + bool "Deny (f)chmod +s"
56552 + default y if GRKERNSEC_CONFIG_AUTO
56553 + depends on GRKERNSEC_CHROOT
56554 + help
56555 + If you say Y here, processes inside a chroot will not be able to chmod
56556 + or fchmod files to make them have suid or sgid bits. This protects
56557 + against another published method of breaking a chroot. If the sysctl
56558 + option is enabled, a sysctl option with name "chroot_deny_chmod" is
56559 + created.
56560 +
56561 +config GRKERNSEC_CHROOT_FCHDIR
56562 + bool "Deny fchdir out of chroot"
56563 + default y if GRKERNSEC_CONFIG_AUTO
56564 + depends on GRKERNSEC_CHROOT
56565 + help
56566 + If you say Y here, a well-known method of breaking chroots by fchdir'ing
56567 + to a file descriptor of the chrooting process that points to a directory
56568 + outside the filesystem will be stopped. If the sysctl option
56569 + is enabled, a sysctl option with name "chroot_deny_fchdir" is created.
56570 +
56571 +config GRKERNSEC_CHROOT_MKNOD
56572 + bool "Deny mknod"
56573 + default y if GRKERNSEC_CONFIG_AUTO
56574 + depends on GRKERNSEC_CHROOT
56575 + help
56576 + If you say Y here, processes inside a chroot will not be allowed to
56577 + mknod. The problem with using mknod inside a chroot is that it
56578 + would allow an attacker to create a device entry that is the same
56579 + as one on the physical root of your system, which could range from
56580 + anything from the console device to a device for your harddrive (which
56581 + they could then use to wipe the drive or steal data). It is recommended
56582 + that you say Y here, unless you run into software incompatibilities.
56583 + If the sysctl option is enabled, a sysctl option with name
56584 + "chroot_deny_mknod" is created.
56585 +
56586 +config GRKERNSEC_CHROOT_SHMAT
56587 + bool "Deny shmat() out of chroot"
56588 + default y if GRKERNSEC_CONFIG_AUTO
56589 + depends on GRKERNSEC_CHROOT
56590 + help
56591 + If you say Y here, processes inside a chroot will not be able to attach
56592 + to shared memory segments that were created outside of the chroot jail.
56593 + It is recommended that you say Y here. If the sysctl option is enabled,
56594 + a sysctl option with name "chroot_deny_shmat" is created.
56595 +
56596 +config GRKERNSEC_CHROOT_UNIX
56597 + bool "Deny access to abstract AF_UNIX sockets out of chroot"
56598 + default y if GRKERNSEC_CONFIG_AUTO
56599 + depends on GRKERNSEC_CHROOT
56600 + help
56601 + If you say Y here, processes inside a chroot will not be able to
56602 + connect to abstract (meaning not belonging to a filesystem) Unix
56603 + domain sockets that were bound outside of a chroot. It is recommended
56604 + that you say Y here. If the sysctl option is enabled, a sysctl option
56605 + with name "chroot_deny_unix" is created.
56606 +
56607 +config GRKERNSEC_CHROOT_FINDTASK
56608 + bool "Protect outside processes"
56609 + default y if GRKERNSEC_CONFIG_AUTO
56610 + depends on GRKERNSEC_CHROOT
56611 + help
56612 + If you say Y here, processes inside a chroot will not be able to
56613 + kill, send signals with fcntl, ptrace, capget, getpgid, setpgid,
56614 + getsid, or view any process outside of the chroot. If the sysctl
56615 + option is enabled, a sysctl option with name "chroot_findtask" is
56616 + created.
56617 +
56618 +config GRKERNSEC_CHROOT_NICE
56619 + bool "Restrict priority changes"
56620 + default y if GRKERNSEC_CONFIG_AUTO
56621 + depends on GRKERNSEC_CHROOT
56622 + help
56623 + If you say Y here, processes inside a chroot will not be able to raise
56624 + the priority of processes in the chroot, or alter the priority of
56625 + processes outside the chroot. This provides more security than simply
56626 + removing CAP_SYS_NICE from the process' capability set. If the
56627 + sysctl option is enabled, a sysctl option with name "chroot_restrict_nice"
56628 + is created.
56629 +
56630 +config GRKERNSEC_CHROOT_SYSCTL
56631 + bool "Deny sysctl writes"
56632 + default y if GRKERNSEC_CONFIG_AUTO
56633 + depends on GRKERNSEC_CHROOT
56634 + help
56635 + If you say Y here, an attacker in a chroot will not be able to
56636 + write to sysctl entries, either by sysctl(2) or through a /proc
56637 + interface. It is strongly recommended that you say Y here. If the
56638 + sysctl option is enabled, a sysctl option with name
56639 + "chroot_deny_sysctl" is created.
56640 +
56641 +config GRKERNSEC_CHROOT_CAPS
56642 + bool "Capability restrictions"
56643 + default y if GRKERNSEC_CONFIG_AUTO
56644 + depends on GRKERNSEC_CHROOT
56645 + help
56646 + If you say Y here, the capabilities on all processes within a
56647 + chroot jail will be lowered to stop module insertion, raw i/o,
56648 + system and net admin tasks, rebooting the system, modifying immutable
56649 + files, modifying IPC owned by another, and changing the system time.
56650 + This is left an option because it can break some apps. Disable this
56651 + if your chrooted apps are having problems performing those kinds of
56652 + tasks. If the sysctl option is enabled, a sysctl option with
56653 + name "chroot_caps" is created.
56654 +
56655 +endmenu
56656 +menu "Kernel Auditing"
56657 +depends on GRKERNSEC
56658 +
56659 +config GRKERNSEC_AUDIT_GROUP
56660 + bool "Single group for auditing"
56661 + help
56662 + If you say Y here, the exec and chdir logging features will only operate
56663 + on a group you specify. This option is recommended if you only want to
56664 + watch certain users instead of having a large amount of logs from the
56665 + entire system. If the sysctl option is enabled, a sysctl option with
56666 + name "audit_group" is created.
56667 +
56668 +config GRKERNSEC_AUDIT_GID
56669 + int "GID for auditing"
56670 + depends on GRKERNSEC_AUDIT_GROUP
56671 + default 1007
56672 +
56673 +config GRKERNSEC_EXECLOG
56674 + bool "Exec logging"
56675 + help
56676 + If you say Y here, all execve() calls will be logged (since the
56677 + other exec*() calls are frontends to execve(), all execution
56678 + will be logged). Useful for shell-servers that like to keep track
56679 + of their users. If the sysctl option is enabled, a sysctl option with
56680 + name "exec_logging" is created.
56681 + WARNING: This option when enabled will produce a LOT of logs, especially
56682 + on an active system.
56683 +
56684 +config GRKERNSEC_RESLOG
56685 + bool "Resource logging"
56686 + default y if GRKERNSEC_CONFIG_AUTO
56687 + help
56688 + If you say Y here, all attempts to overstep resource limits will
56689 + be logged with the resource name, the requested size, and the current
56690 + limit. It is highly recommended that you say Y here. If the sysctl
56691 + option is enabled, a sysctl option with name "resource_logging" is
56692 + created. If the RBAC system is enabled, the sysctl value is ignored.
56693 +
56694 +config GRKERNSEC_CHROOT_EXECLOG
56695 + bool "Log execs within chroot"
56696 + help
56697 + If you say Y here, all executions inside a chroot jail will be logged
56698 + to syslog. This can cause a large amount of logs if certain
56699 + applications (eg. djb's daemontools) are installed on the system, and
56700 + is therefore left as an option. If the sysctl option is enabled, a
56701 + sysctl option with name "chroot_execlog" is created.
56702 +
56703 +config GRKERNSEC_AUDIT_PTRACE
56704 + bool "Ptrace logging"
56705 + help
56706 + If you say Y here, all attempts to attach to a process via ptrace
56707 + will be logged. If the sysctl option is enabled, a sysctl option
56708 + with name "audit_ptrace" is created.
56709 +
56710 +config GRKERNSEC_AUDIT_CHDIR
56711 + bool "Chdir logging"
56712 + help
56713 + If you say Y here, all chdir() calls will be logged. If the sysctl
56714 + option is enabled, a sysctl option with name "audit_chdir" is created.
56715 +
56716 +config GRKERNSEC_AUDIT_MOUNT
56717 + bool "(Un)Mount logging"
56718 + help
56719 + If you say Y here, all mounts and unmounts will be logged. If the
56720 + sysctl option is enabled, a sysctl option with name "audit_mount" is
56721 + created.
56722 +
56723 +config GRKERNSEC_SIGNAL
56724 + bool "Signal logging"
56725 + default y if GRKERNSEC_CONFIG_AUTO
56726 + help
56727 + If you say Y here, certain important signals will be logged, such as
56728 + SIGSEGV, which will as a result inform you of when a error in a program
56729 + occurred, which in some cases could mean a possible exploit attempt.
56730 + If the sysctl option is enabled, a sysctl option with name
56731 + "signal_logging" is created.
56732 +
56733 +config GRKERNSEC_FORKFAIL
56734 + bool "Fork failure logging"
56735 + help
56736 + If you say Y here, all failed fork() attempts will be logged.
56737 + This could suggest a fork bomb, or someone attempting to overstep
56738 + their process limit. If the sysctl option is enabled, a sysctl option
56739 + with name "forkfail_logging" is created.
56740 +
56741 +config GRKERNSEC_TIME
56742 + bool "Time change logging"
56743 + default y if GRKERNSEC_CONFIG_AUTO
56744 + help
56745 + If you say Y here, any changes of the system clock will be logged.
56746 + If the sysctl option is enabled, a sysctl option with name
56747 + "timechange_logging" is created.
56748 +
56749 +config GRKERNSEC_PROC_IPADDR
56750 + bool "/proc/<pid>/ipaddr support"
56751 + default y if GRKERNSEC_CONFIG_AUTO
56752 + help
56753 + If you say Y here, a new entry will be added to each /proc/<pid>
56754 + directory that contains the IP address of the person using the task.
56755 + The IP is carried across local TCP and AF_UNIX stream sockets.
56756 + This information can be useful for IDS/IPSes to perform remote response
56757 + to a local attack. The entry is readable by only the owner of the
56758 + process (and root if he has CAP_DAC_OVERRIDE, which can be removed via
56759 + the RBAC system), and thus does not create privacy concerns.
56760 +
56761 +config GRKERNSEC_RWXMAP_LOG
56762 + bool 'Denied RWX mmap/mprotect logging'
56763 + default y if GRKERNSEC_CONFIG_AUTO
56764 + depends on PAX_MPROTECT && !PAX_EMUPLT && !PAX_EMUSIGRT
56765 + help
56766 + If you say Y here, calls to mmap() and mprotect() with explicit
56767 + usage of PROT_WRITE and PROT_EXEC together will be logged when
56768 + denied by the PAX_MPROTECT feature. If the sysctl option is
56769 + enabled, a sysctl option with name "rwxmap_logging" is created.
56770 +
56771 +config GRKERNSEC_AUDIT_TEXTREL
56772 + bool 'ELF text relocations logging (READ HELP)'
56773 + depends on PAX_MPROTECT
56774 + help
56775 + If you say Y here, text relocations will be logged with the filename
56776 + of the offending library or binary. The purpose of the feature is
56777 + to help Linux distribution developers get rid of libraries and
56778 + binaries that need text relocations which hinder the future progress
56779 + of PaX. Only Linux distribution developers should say Y here, and
56780 + never on a production machine, as this option creates an information
56781 + leak that could aid an attacker in defeating the randomization of
56782 + a single memory region. If the sysctl option is enabled, a sysctl
56783 + option with name "audit_textrel" is created.
56784 +
56785 +endmenu
56786 +
56787 +menu "Executable Protections"
56788 +depends on GRKERNSEC
56789 +
56790 +config GRKERNSEC_DMESG
56791 + bool "Dmesg(8) restriction"
56792 + default y if GRKERNSEC_CONFIG_AUTO
56793 + help
56794 + If you say Y here, non-root users will not be able to use dmesg(8)
56795 + to view the contents of the kernel's circular log buffer.
56796 + The kernel's log buffer often contains kernel addresses and other
56797 + identifying information useful to an attacker in fingerprinting a
56798 + system for a targeted exploit.
56799 + If the sysctl option is enabled, a sysctl option with name "dmesg" is
56800 + created.
56801 +
56802 +config GRKERNSEC_HARDEN_PTRACE
56803 + bool "Deter ptrace-based process snooping"
56804 + default y if GRKERNSEC_CONFIG_AUTO
56805 + help
56806 + If you say Y here, TTY sniffers and other malicious monitoring
56807 + programs implemented through ptrace will be defeated. If you
56808 + have been using the RBAC system, this option has already been
56809 + enabled for several years for all users, with the ability to make
56810 + fine-grained exceptions.
56811 +
56812 + This option only affects the ability of non-root users to ptrace
56813 + processes that are not a descendent of the ptracing process.
56814 + This means that strace ./binary and gdb ./binary will still work,
56815 + but attaching to arbitrary processes will not. If the sysctl
56816 + option is enabled, a sysctl option with name "harden_ptrace" is
56817 + created.
56818 +
56819 +config GRKERNSEC_PTRACE_READEXEC
56820 + bool "Require read access to ptrace sensitive binaries"
56821 + default y if GRKERNSEC_CONFIG_AUTO
56822 + help
56823 + If you say Y here, unprivileged users will not be able to ptrace unreadable
56824 + binaries. This option is useful in environments that
56825 + remove the read bits (e.g. file mode 4711) from suid binaries to
56826 + prevent infoleaking of their contents. This option adds
56827 + consistency to the use of that file mode, as the binary could normally
56828 + be read out when run without privileges while ptracing.
56829 +
56830 + If the sysctl option is enabled, a sysctl option with name "ptrace_readexec"
56831 + is created.
56832 +
56833 +config GRKERNSEC_SETXID
56834 + bool "Enforce consistent multithreaded privileges"
56835 + default y if GRKERNSEC_CONFIG_AUTO
56836 + depends on (X86 || SPARC64 || PPC || ARM || MIPS)
56837 + help
56838 + If you say Y here, a change from a root uid to a non-root uid
56839 + in a multithreaded application will cause the resulting uids,
56840 + gids, supplementary groups, and capabilities in that thread
56841 + to be propagated to the other threads of the process. In most
56842 + cases this is unnecessary, as glibc will emulate this behavior
56843 + on behalf of the application. Other libcs do not act in the
56844 + same way, allowing the other threads of the process to continue
56845 + running with root privileges. If the sysctl option is enabled,
56846 + a sysctl option with name "consistent_setxid" is created.
56847 +
56848 +config GRKERNSEC_TPE
56849 + bool "Trusted Path Execution (TPE)"
56850 + default y if GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER
56851 + help
56852 + If you say Y here, you will be able to choose a gid to add to the
56853 + supplementary groups of users you want to mark as "untrusted."
56854 + These users will not be able to execute any files that are not in
56855 + root-owned directories writable only by root. If the sysctl option
56856 + is enabled, a sysctl option with name "tpe" is created.
56857 +
56858 +config GRKERNSEC_TPE_ALL
56859 + bool "Partially restrict all non-root users"
56860 + depends on GRKERNSEC_TPE
56861 + help
56862 + If you say Y here, all non-root users will be covered under
56863 + a weaker TPE restriction. This is separate from, and in addition to,
56864 + the main TPE options that you have selected elsewhere. Thus, if a
56865 + "trusted" GID is chosen, this restriction applies to even that GID.
56866 + Under this restriction, all non-root users will only be allowed to
56867 + execute files in directories they own that are not group or
56868 + world-writable, or in directories owned by root and writable only by
56869 + root. If the sysctl option is enabled, a sysctl option with name
56870 + "tpe_restrict_all" is created.
56871 +
56872 +config GRKERNSEC_TPE_INVERT
56873 + bool "Invert GID option"
56874 + depends on GRKERNSEC_TPE
56875 + help
56876 + If you say Y here, the group you specify in the TPE configuration will
56877 + decide what group TPE restrictions will be *disabled* for. This
56878 + option is useful if you want TPE restrictions to be applied to most
56879 + users on the system. If the sysctl option is enabled, a sysctl option
56880 + with name "tpe_invert" is created. Unlike other sysctl options, this
56881 + entry will default to on for backward-compatibility.
56882 +
56883 +config GRKERNSEC_TPE_GID
56884 + int
56885 + default GRKERNSEC_TPE_UNTRUSTED_GID if (GRKERNSEC_TPE && !GRKERNSEC_TPE_INVERT)
56886 + default GRKERNSEC_TPE_TRUSTED_GID if (GRKERNSEC_TPE && GRKERNSEC_TPE_INVERT)
56887 +
56888 +config GRKERNSEC_TPE_UNTRUSTED_GID
56889 + int "GID for TPE-untrusted users"
56890 + depends on GRKERNSEC_TPE && !GRKERNSEC_TPE_INVERT
56891 + default 1005
56892 + help
56893 + Setting this GID determines what group TPE restrictions will be
56894 + *enabled* for. If the sysctl option is enabled, a sysctl option
56895 + with name "tpe_gid" is created.
56896 +
56897 +config GRKERNSEC_TPE_TRUSTED_GID
56898 + int "GID for TPE-trusted users"
56899 + depends on GRKERNSEC_TPE && GRKERNSEC_TPE_INVERT
56900 + default 1005
56901 + help
56902 + Setting this GID determines what group TPE restrictions will be
56903 + *disabled* for. If the sysctl option is enabled, a sysctl option
56904 + with name "tpe_gid" is created.
56905 +
56906 +endmenu
56907 +menu "Network Protections"
56908 +depends on GRKERNSEC
56909 +
56910 +config GRKERNSEC_RANDNET
56911 + bool "Larger entropy pools"
56912 + default y if GRKERNSEC_CONFIG_AUTO
56913 + help
56914 + If you say Y here, the entropy pools used for many features of Linux
56915 + and grsecurity will be doubled in size. Since several grsecurity
56916 + features use additional randomness, it is recommended that you say Y
56917 + here. Saying Y here has a similar effect as modifying
56918 + /proc/sys/kernel/random/poolsize.
56919 +
56920 +config GRKERNSEC_BLACKHOLE
56921 + bool "TCP/UDP blackhole and LAST_ACK DoS prevention"
56922 + default y if GRKERNSEC_CONFIG_AUTO
56923 + depends on NET
56924 + help
56925 + If you say Y here, neither TCP resets nor ICMP
56926 + destination-unreachable packets will be sent in response to packets
56927 + sent to ports for which no associated listening process exists.
56928 + This feature supports both IPV4 and IPV6 and exempts the
56929 + loopback interface from blackholing. Enabling this feature
56930 + makes a host more resilient to DoS attacks and reduces network
56931 + visibility against scanners.
56932 +
56933 + The blackhole feature as-implemented is equivalent to the FreeBSD
56934 + blackhole feature, as it prevents RST responses to all packets, not
56935 + just SYNs. Under most application behavior this causes no
56936 + problems, but applications (like haproxy) may not close certain
56937 + connections in a way that cleanly terminates them on the remote
56938 + end, leaving the remote host in LAST_ACK state. Because of this
56939 + side-effect and to prevent intentional LAST_ACK DoSes, this
56940 + feature also adds automatic mitigation against such attacks.
56941 + The mitigation drastically reduces the amount of time a socket
56942 + can spend in LAST_ACK state. If you're using haproxy and not
56943 + all servers it connects to have this option enabled, consider
56944 + disabling this feature on the haproxy host.
56945 +
56946 + If the sysctl option is enabled, two sysctl options with names
56947 + "ip_blackhole" and "lastack_retries" will be created.
56948 + While "ip_blackhole" takes the standard zero/non-zero on/off
56949 + toggle, "lastack_retries" uses the same kinds of values as
56950 + "tcp_retries1" and "tcp_retries2". The default value of 4
56951 + prevents a socket from lasting more than 45 seconds in LAST_ACK
56952 + state.
56953 +
56954 +config GRKERNSEC_NO_SIMULT_CONNECT
56955 + bool "Disable TCP Simultaneous Connect"
56956 + default y if GRKERNSEC_CONFIG_AUTO
56957 + depends on NET
56958 + help
56959 + If you say Y here, a feature by Willy Tarreau will be enabled that
56960 + removes a weakness in Linux's strict implementation of TCP that
56961 + allows two clients to connect to each other without either entering
56962 + a listening state. The weakness allows an attacker to easily prevent
56963 + a client from connecting to a known server provided the source port
56964 + for the connection is guessed correctly.
56965 +
56966 + As the weakness could be used to prevent an antivirus or IPS from
56967 + fetching updates, or prevent an SSL gateway from fetching a CRL,
56968 + it should be eliminated by enabling this option. Though Linux is
56969 + one of few operating systems supporting simultaneous connect, it
56970 + has no legitimate use in practice and is rarely supported by firewalls.
56971 +
56972 +config GRKERNSEC_SOCKET
56973 + bool "Socket restrictions"
56974 + depends on NET
56975 + help
56976 + If you say Y here, you will be able to choose from several options.
56977 + If you assign a GID on your system and add it to the supplementary
56978 + groups of users you want to restrict socket access to, this patch
56979 + will perform up to three things, based on the option(s) you choose.
56980 +
56981 +config GRKERNSEC_SOCKET_ALL
56982 + bool "Deny any sockets to group"
56983 + depends on GRKERNSEC_SOCKET
56984 + help
56985 + If you say Y here, you will be able to choose a GID of whose users will
56986 + be unable to connect to other hosts from your machine or run server
56987 + applications from your machine. If the sysctl option is enabled, a
56988 + sysctl option with name "socket_all" is created.
56989 +
56990 +config GRKERNSEC_SOCKET_ALL_GID
56991 + int "GID to deny all sockets for"
56992 + depends on GRKERNSEC_SOCKET_ALL
56993 + default 1004
56994 + help
56995 + Here you can choose the GID to disable socket access for. Remember to
56996 + add the users you want socket access disabled for to the GID
56997 + specified here. If the sysctl option is enabled, a sysctl option
56998 + with name "socket_all_gid" is created.
56999 +
57000 +config GRKERNSEC_SOCKET_CLIENT
57001 + bool "Deny client sockets to group"
57002 + depends on GRKERNSEC_SOCKET
57003 + help
57004 + If you say Y here, you will be able to choose a GID of whose users will
57005 + be unable to connect to other hosts from your machine, but will be
57006 + able to run servers. If this option is enabled, all users in the group
57007 + you specify will have to use passive mode when initiating ftp transfers
57008 + from the shell on your machine. If the sysctl option is enabled, a
57009 + sysctl option with name "socket_client" is created.
57010 +
57011 +config GRKERNSEC_SOCKET_CLIENT_GID
57012 + int "GID to deny client sockets for"
57013 + depends on GRKERNSEC_SOCKET_CLIENT
57014 + default 1003
57015 + help
57016 + Here you can choose the GID to disable client socket access for.
57017 + Remember to add the users you want client socket access disabled for to
57018 + the GID specified here. If the sysctl option is enabled, a sysctl
57019 + option with name "socket_client_gid" is created.
57020 +
57021 +config GRKERNSEC_SOCKET_SERVER
57022 + bool "Deny server sockets to group"
57023 + depends on GRKERNSEC_SOCKET
57024 + help
57025 + If you say Y here, you will be able to choose a GID of whose users will
57026 + be unable to run server applications from your machine. If the sysctl
57027 + option is enabled, a sysctl option with name "socket_server" is created.
57028 +
57029 +config GRKERNSEC_SOCKET_SERVER_GID
57030 + int "GID to deny server sockets for"
57031 + depends on GRKERNSEC_SOCKET_SERVER
57032 + default 1002
57033 + help
57034 + Here you can choose the GID to disable server socket access for.
57035 + Remember to add the users you want server socket access disabled for to
57036 + the GID specified here. If the sysctl option is enabled, a sysctl
57037 + option with name "socket_server_gid" is created.
57038 +
57039 +endmenu
57040 +menu "Sysctl Support"
57041 +depends on GRKERNSEC && SYSCTL
57042 +
57043 +config GRKERNSEC_SYSCTL
57044 + bool "Sysctl support"
57045 + default y if GRKERNSEC_CONFIG_AUTO
57046 + help
57047 + If you say Y here, you will be able to change the options that
57048 + grsecurity runs with at bootup, without having to recompile your
57049 + kernel. You can echo values to files in /proc/sys/kernel/grsecurity
57050 + to enable (1) or disable (0) various features. All the sysctl entries
57051 + are mutable until the "grsec_lock" entry is set to a non-zero value.
57052 + All features enabled in the kernel configuration are disabled at boot
57053 + if you do not say Y to the "Turn on features by default" option.
57054 + All options should be set at startup, and the grsec_lock entry should
57055 + be set to a non-zero value after all the options are set.
57056 + *THIS IS EXTREMELY IMPORTANT*
57057 +
57058 +config GRKERNSEC_SYSCTL_DISTRO
57059 + bool "Extra sysctl support for distro makers (READ HELP)"
57060 + depends on GRKERNSEC_SYSCTL && GRKERNSEC_IO
57061 + help
57062 + If you say Y here, additional sysctl options will be created
57063 + for features that affect processes running as root. Therefore,
57064 + it is critical when using this option that the grsec_lock entry be
57065 + enabled after boot. Only distros with prebuilt kernel packages
57066 + with this option enabled that can ensure grsec_lock is enabled
57067 + after boot should use this option.
57068 + *Failure to set grsec_lock after boot makes all grsec features
57069 + this option covers useless*
57070 +
57071 + Currently this option creates the following sysctl entries:
57072 + "Disable Privileged I/O": "disable_priv_io"
57073 +
57074 +config GRKERNSEC_SYSCTL_ON
57075 + bool "Turn on features by default"
57076 + default y if GRKERNSEC_CONFIG_AUTO
57077 + depends on GRKERNSEC_SYSCTL
57078 + help
57079 + If you say Y here, instead of having all features enabled in the
57080 + kernel configuration disabled at boot time, the features will be
57081 + enabled at boot time. It is recommended you say Y here unless
57082 + there is some reason you would want all sysctl-tunable features to
57083 + be disabled by default. As mentioned elsewhere, it is important
57084 + to enable the grsec_lock entry once you have finished modifying
57085 + the sysctl entries.
57086 +
57087 +endmenu
57088 +menu "Logging Options"
57089 +depends on GRKERNSEC
57090 +
57091 +config GRKERNSEC_FLOODTIME
57092 + int "Seconds in between log messages (minimum)"
57093 + default 10
57094 + help
57095 + This option allows you to enforce the number of seconds between
57096 + grsecurity log messages. The default should be suitable for most
57097 + people, however, if you choose to change it, choose a value small enough
57098 + to allow informative logs to be produced, but large enough to
57099 + prevent flooding.
57100 +
57101 +config GRKERNSEC_FLOODBURST
57102 + int "Number of messages in a burst (maximum)"
57103 + default 6
57104 + help
57105 + This option allows you to choose the maximum number of messages allowed
57106 + within the flood time interval you chose in a separate option. The
57107 + default should be suitable for most people, however if you find that
57108 + many of your logs are being interpreted as flooding, you may want to
57109 + raise this value.
57110 +
57111 +endmenu
57112 diff --git a/grsecurity/Makefile b/grsecurity/Makefile
57113 new file mode 100644
57114 index 0000000..1b9afa9
57115 --- /dev/null
57116 +++ b/grsecurity/Makefile
57117 @@ -0,0 +1,38 @@
57118 +# grsecurity's ACL system was originally written in 2001 by Michael Dalton
57119 +# during 2001-2009 it has been completely redesigned by Brad Spengler
57120 +# into an RBAC system
57121 +#
57122 +# All code in this directory and various hooks inserted throughout the kernel
57123 +# are copyright Brad Spengler - Open Source Security, Inc., and released
57124 +# under the GPL v2 or higher
57125 +
57126 +KBUILD_CFLAGS += -Werror
57127 +
57128 +obj-y = grsec_chdir.o grsec_chroot.o grsec_exec.o grsec_fifo.o grsec_fork.o \
57129 + grsec_mount.o grsec_sig.o grsec_sysctl.o \
57130 + grsec_time.o grsec_tpe.o grsec_link.o grsec_pax.o grsec_ptrace.o
57131 +
57132 +obj-$(CONFIG_GRKERNSEC) += grsec_init.o grsum.o gracl.o gracl_segv.o \
57133 + gracl_cap.o gracl_alloc.o gracl_shm.o grsec_mem.o gracl_fs.o \
57134 + gracl_learn.o grsec_log.o
57135 +obj-$(CONFIG_GRKERNSEC_RESLOG) += gracl_res.o
57136 +
57137 +ifdef CONFIG_NET
57138 +obj-y += grsec_sock.o
57139 +obj-$(CONFIG_GRKERNSEC) += gracl_ip.o
57140 +endif
57141 +
57142 +ifndef CONFIG_GRKERNSEC
57143 +obj-y += grsec_disabled.o
57144 +endif
57145 +
57146 +ifdef CONFIG_GRKERNSEC_HIDESYM
57147 +extra-y := grsec_hidesym.o
57148 +$(obj)/grsec_hidesym.o:
57149 + @-chmod -f 500 /boot
57150 + @-chmod -f 500 /lib/modules
57151 + @-chmod -f 500 /lib64/modules
57152 + @-chmod -f 500 /lib32/modules
57153 + @-chmod -f 700 .
57154 + @echo ' grsec: protected kernel image paths'
57155 +endif
57156 diff --git a/grsecurity/gracl.c b/grsecurity/gracl.c
57157 new file mode 100644
57158 index 0000000..ab45812
57159 --- /dev/null
57160 +++ b/grsecurity/gracl.c
57161 @@ -0,0 +1,4071 @@
57162 +#include <linux/kernel.h>
57163 +#include <linux/module.h>
57164 +#include <linux/sched.h>
57165 +#include <linux/mm.h>
57166 +#include <linux/file.h>
57167 +#include <linux/fs.h>
57168 +#include <linux/namei.h>
57169 +#include <linux/mount.h>
57170 +#include <linux/tty.h>
57171 +#include <linux/proc_fs.h>
57172 +#include <linux/lglock.h>
57173 +#include <linux/slab.h>
57174 +#include <linux/vmalloc.h>
57175 +#include <linux/types.h>
57176 +#include <linux/sysctl.h>
57177 +#include <linux/netdevice.h>
57178 +#include <linux/ptrace.h>
57179 +#include <linux/gracl.h>
57180 +#include <linux/gralloc.h>
57181 +#include <linux/security.h>
57182 +#include <linux/grinternal.h>
57183 +#include <linux/pid_namespace.h>
57184 +#include <linux/stop_machine.h>
57185 +#include <linux/fdtable.h>
57186 +#include <linux/percpu.h>
57187 +#include <linux/lglock.h>
57188 +#include <linux/hugetlb.h>
57189 +#include <linux/posix-timers.h>
57190 +#include "../fs/mount.h"
57191 +
57192 +#include <asm/uaccess.h>
57193 +#include <asm/errno.h>
57194 +#include <asm/mman.h>
57195 +
57196 +extern struct lglock vfsmount_lock;
57197 +
57198 +static struct acl_role_db acl_role_set;
57199 +static struct name_db name_set;
57200 +static struct inodev_db inodev_set;
57201 +
57202 +/* for keeping track of userspace pointers used for subjects, so we
57203 + can share references in the kernel as well
57204 +*/
57205 +
57206 +static struct path real_root;
57207 +
57208 +static struct acl_subj_map_db subj_map_set;
57209 +
57210 +static struct acl_role_label *default_role;
57211 +
57212 +static struct acl_role_label *role_list;
57213 +
57214 +static u16 acl_sp_role_value;
57215 +
57216 +extern char *gr_shared_page[4];
57217 +static DEFINE_MUTEX(gr_dev_mutex);
57218 +DEFINE_RWLOCK(gr_inode_lock);
57219 +
57220 +struct gr_arg *gr_usermode;
57221 +
57222 +static unsigned int gr_status __read_only = GR_STATUS_INIT;
57223 +
57224 +extern int chkpw(struct gr_arg *entry, unsigned char *salt, unsigned char *sum);
57225 +extern void gr_clear_learn_entries(void);
57226 +
57227 +unsigned char *gr_system_salt;
57228 +unsigned char *gr_system_sum;
57229 +
57230 +static struct sprole_pw **acl_special_roles = NULL;
57231 +static __u16 num_sprole_pws = 0;
57232 +
57233 +static struct acl_role_label *kernel_role = NULL;
57234 +
57235 +static unsigned int gr_auth_attempts = 0;
57236 +static unsigned long gr_auth_expires = 0UL;
57237 +
57238 +#ifdef CONFIG_NET
57239 +extern struct vfsmount *sock_mnt;
57240 +#endif
57241 +
57242 +extern struct vfsmount *pipe_mnt;
57243 +extern struct vfsmount *shm_mnt;
57244 +
57245 +#ifdef CONFIG_HUGETLBFS
57246 +extern struct vfsmount *hugetlbfs_vfsmount[HUGE_MAX_HSTATE];
57247 +#endif
57248 +
57249 +static struct acl_object_label *fakefs_obj_rw;
57250 +static struct acl_object_label *fakefs_obj_rwx;
57251 +
57252 +extern int gr_init_uidset(void);
57253 +extern void gr_free_uidset(void);
57254 +extern void gr_remove_uid(uid_t uid);
57255 +extern int gr_find_uid(uid_t uid);
57256 +
57257 +__inline__ int
57258 +gr_acl_is_enabled(void)
57259 +{
57260 + return (gr_status & GR_READY);
57261 +}
57262 +
57263 +#ifdef CONFIG_BTRFS_FS
57264 +extern dev_t get_btrfs_dev_from_inode(struct inode *inode);
57265 +extern int btrfs_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat);
57266 +#endif
57267 +
57268 +static inline dev_t __get_dev(const struct dentry *dentry)
57269 +{
57270 +#ifdef CONFIG_BTRFS_FS
57271 + if (dentry->d_inode->i_op && dentry->d_inode->i_op->getattr == &btrfs_getattr)
57272 + return get_btrfs_dev_from_inode(dentry->d_inode);
57273 + else
57274 +#endif
57275 + return dentry->d_inode->i_sb->s_dev;
57276 +}
57277 +
57278 +dev_t gr_get_dev_from_dentry(struct dentry *dentry)
57279 +{
57280 + return __get_dev(dentry);
57281 +}
57282 +
57283 +static char gr_task_roletype_to_char(struct task_struct *task)
57284 +{
57285 + switch (task->role->roletype &
57286 + (GR_ROLE_DEFAULT | GR_ROLE_USER | GR_ROLE_GROUP |
57287 + GR_ROLE_SPECIAL)) {
57288 + case GR_ROLE_DEFAULT:
57289 + return 'D';
57290 + case GR_ROLE_USER:
57291 + return 'U';
57292 + case GR_ROLE_GROUP:
57293 + return 'G';
57294 + case GR_ROLE_SPECIAL:
57295 + return 'S';
57296 + }
57297 +
57298 + return 'X';
57299 +}
57300 +
57301 +char gr_roletype_to_char(void)
57302 +{
57303 + return gr_task_roletype_to_char(current);
57304 +}
57305 +
57306 +__inline__ int
57307 +gr_acl_tpe_check(void)
57308 +{
57309 + if (unlikely(!(gr_status & GR_READY)))
57310 + return 0;
57311 + if (current->role->roletype & GR_ROLE_TPE)
57312 + return 1;
57313 + else
57314 + return 0;
57315 +}
57316 +
57317 +int
57318 +gr_handle_rawio(const struct inode *inode)
57319 +{
57320 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
57321 + if (inode && S_ISBLK(inode->i_mode) &&
57322 + grsec_enable_chroot_caps && proc_is_chrooted(current) &&
57323 + !capable(CAP_SYS_RAWIO))
57324 + return 1;
57325 +#endif
57326 + return 0;
57327 +}
57328 +
57329 +static int
57330 +gr_streq(const char *a, const char *b, const unsigned int lena, const unsigned int lenb)
57331 +{
57332 + if (likely(lena != lenb))
57333 + return 0;
57334 +
57335 + return !memcmp(a, b, lena);
57336 +}
57337 +
57338 +static int prepend(char **buffer, int *buflen, const char *str, int namelen)
57339 +{
57340 + *buflen -= namelen;
57341 + if (*buflen < 0)
57342 + return -ENAMETOOLONG;
57343 + *buffer -= namelen;
57344 + memcpy(*buffer, str, namelen);
57345 + return 0;
57346 +}
57347 +
57348 +static int prepend_name(char **buffer, int *buflen, struct qstr *name)
57349 +{
57350 + return prepend(buffer, buflen, name->name, name->len);
57351 +}
57352 +
57353 +static int prepend_path(const struct path *path, struct path *root,
57354 + char **buffer, int *buflen)
57355 +{
57356 + struct dentry *dentry = path->dentry;
57357 + struct vfsmount *vfsmnt = path->mnt;
57358 + struct mount *mnt = real_mount(vfsmnt);
57359 + bool slash = false;
57360 + int error = 0;
57361 +
57362 + while (dentry != root->dentry || vfsmnt != root->mnt) {
57363 + struct dentry * parent;
57364 +
57365 + if (dentry == vfsmnt->mnt_root || IS_ROOT(dentry)) {
57366 + /* Global root? */
57367 + if (!mnt_has_parent(mnt)) {
57368 + goto out;
57369 + }
57370 + dentry = mnt->mnt_mountpoint;
57371 + mnt = mnt->mnt_parent;
57372 + vfsmnt = &mnt->mnt;
57373 + continue;
57374 + }
57375 + parent = dentry->d_parent;
57376 + prefetch(parent);
57377 + spin_lock(&dentry->d_lock);
57378 + error = prepend_name(buffer, buflen, &dentry->d_name);
57379 + spin_unlock(&dentry->d_lock);
57380 + if (!error)
57381 + error = prepend(buffer, buflen, "/", 1);
57382 + if (error)
57383 + break;
57384 +
57385 + slash = true;
57386 + dentry = parent;
57387 + }
57388 +
57389 +out:
57390 + if (!error && !slash)
57391 + error = prepend(buffer, buflen, "/", 1);
57392 +
57393 + return error;
57394 +}
57395 +
57396 +/* this must be called with vfsmount_lock and rename_lock held */
57397 +
57398 +static char *__our_d_path(const struct path *path, struct path *root,
57399 + char *buf, int buflen)
57400 +{
57401 + char *res = buf + buflen;
57402 + int error;
57403 +
57404 + prepend(&res, &buflen, "\0", 1);
57405 + error = prepend_path(path, root, &res, &buflen);
57406 + if (error)
57407 + return ERR_PTR(error);
57408 +
57409 + return res;
57410 +}
57411 +
57412 +static char *
57413 +gen_full_path(struct path *path, struct path *root, char *buf, int buflen)
57414 +{
57415 + char *retval;
57416 +
57417 + retval = __our_d_path(path, root, buf, buflen);
57418 + if (unlikely(IS_ERR(retval)))
57419 + retval = strcpy(buf, "<path too long>");
57420 + else if (unlikely(retval[1] == '/' && retval[2] == '\0'))
57421 + retval[1] = '\0';
57422 +
57423 + return retval;
57424 +}
57425 +
57426 +static char *
57427 +__d_real_path(const struct dentry *dentry, const struct vfsmount *vfsmnt,
57428 + char *buf, int buflen)
57429 +{
57430 + struct path path;
57431 + char *res;
57432 +
57433 + path.dentry = (struct dentry *)dentry;
57434 + path.mnt = (struct vfsmount *)vfsmnt;
57435 +
57436 + /* we can use real_root.dentry, real_root.mnt, because this is only called
57437 + by the RBAC system */
57438 + res = gen_full_path(&path, &real_root, buf, buflen);
57439 +
57440 + return res;
57441 +}
57442 +
57443 +static char *
57444 +d_real_path(const struct dentry *dentry, const struct vfsmount *vfsmnt,
57445 + char *buf, int buflen)
57446 +{
57447 + char *res;
57448 + struct path path;
57449 + struct path root;
57450 + struct task_struct *reaper = init_pid_ns.child_reaper;
57451 +
57452 + path.dentry = (struct dentry *)dentry;
57453 + path.mnt = (struct vfsmount *)vfsmnt;
57454 +
57455 + /* we can't use real_root.dentry, real_root.mnt, because they belong only to the RBAC system */
57456 + get_fs_root(reaper->fs, &root);
57457 +
57458 + write_seqlock(&rename_lock);
57459 + br_read_lock(&vfsmount_lock);
57460 + res = gen_full_path(&path, &root, buf, buflen);
57461 + br_read_unlock(&vfsmount_lock);
57462 + write_sequnlock(&rename_lock);
57463 +
57464 + path_put(&root);
57465 + return res;
57466 +}
57467 +
57468 +static char *
57469 +gr_to_filename_rbac(const struct dentry *dentry, const struct vfsmount *mnt)
57470 +{
57471 + char *ret;
57472 + write_seqlock(&rename_lock);
57473 + br_read_lock(&vfsmount_lock);
57474 + ret = __d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0],smp_processor_id()),
57475 + PAGE_SIZE);
57476 + br_read_unlock(&vfsmount_lock);
57477 + write_sequnlock(&rename_lock);
57478 + return ret;
57479 +}
57480 +
57481 +static char *
57482 +gr_to_proc_filename_rbac(const struct dentry *dentry, const struct vfsmount *mnt)
57483 +{
57484 + char *ret;
57485 + char *buf;
57486 + int buflen;
57487 +
57488 + write_seqlock(&rename_lock);
57489 + br_read_lock(&vfsmount_lock);
57490 + buf = per_cpu_ptr(gr_shared_page[0], smp_processor_id());
57491 + ret = __d_real_path(dentry, mnt, buf, PAGE_SIZE - 6);
57492 + buflen = (int)(ret - buf);
57493 + if (buflen >= 5)
57494 + prepend(&ret, &buflen, "/proc", 5);
57495 + else
57496 + ret = strcpy(buf, "<path too long>");
57497 + br_read_unlock(&vfsmount_lock);
57498 + write_sequnlock(&rename_lock);
57499 + return ret;
57500 +}
57501 +
57502 +char *
57503 +gr_to_filename_nolock(const struct dentry *dentry, const struct vfsmount *mnt)
57504 +{
57505 + return __d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0],smp_processor_id()),
57506 + PAGE_SIZE);
57507 +}
57508 +
57509 +char *
57510 +gr_to_filename(const struct dentry *dentry, const struct vfsmount *mnt)
57511 +{
57512 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0], smp_processor_id()),
57513 + PAGE_SIZE);
57514 +}
57515 +
57516 +char *
57517 +gr_to_filename1(const struct dentry *dentry, const struct vfsmount *mnt)
57518 +{
57519 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[1], smp_processor_id()),
57520 + PAGE_SIZE);
57521 +}
57522 +
57523 +char *
57524 +gr_to_filename2(const struct dentry *dentry, const struct vfsmount *mnt)
57525 +{
57526 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[2], smp_processor_id()),
57527 + PAGE_SIZE);
57528 +}
57529 +
57530 +char *
57531 +gr_to_filename3(const struct dentry *dentry, const struct vfsmount *mnt)
57532 +{
57533 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[3], smp_processor_id()),
57534 + PAGE_SIZE);
57535 +}
57536 +
57537 +__inline__ __u32
57538 +to_gr_audit(const __u32 reqmode)
57539 +{
57540 + /* masks off auditable permission flags, then shifts them to create
57541 + auditing flags, and adds the special case of append auditing if
57542 + we're requesting write */
57543 + return (((reqmode & ~GR_AUDITS) << 10) | ((reqmode & GR_WRITE) ? GR_AUDIT_APPEND : 0));
57544 +}
57545 +
57546 +struct acl_subject_label *
57547 +lookup_subject_map(const struct acl_subject_label *userp)
57548 +{
57549 + unsigned int index = gr_shash(userp, subj_map_set.s_size);
57550 + struct subject_map *match;
57551 +
57552 + match = subj_map_set.s_hash[index];
57553 +
57554 + while (match && match->user != userp)
57555 + match = match->next;
57556 +
57557 + if (match != NULL)
57558 + return match->kernel;
57559 + else
57560 + return NULL;
57561 +}
57562 +
57563 +static void
57564 +insert_subj_map_entry(struct subject_map *subjmap)
57565 +{
57566 + unsigned int index = gr_shash(subjmap->user, subj_map_set.s_size);
57567 + struct subject_map **curr;
57568 +
57569 + subjmap->prev = NULL;
57570 +
57571 + curr = &subj_map_set.s_hash[index];
57572 + if (*curr != NULL)
57573 + (*curr)->prev = subjmap;
57574 +
57575 + subjmap->next = *curr;
57576 + *curr = subjmap;
57577 +
57578 + return;
57579 +}
57580 +
57581 +static struct acl_role_label *
57582 +lookup_acl_role_label(const struct task_struct *task, const uid_t uid,
57583 + const gid_t gid)
57584 +{
57585 + unsigned int index = gr_rhash(uid, GR_ROLE_USER, acl_role_set.r_size);
57586 + struct acl_role_label *match;
57587 + struct role_allowed_ip *ipp;
57588 + unsigned int x;
57589 + u32 curr_ip = task->signal->curr_ip;
57590 +
57591 + task->signal->saved_ip = curr_ip;
57592 +
57593 + match = acl_role_set.r_hash[index];
57594 +
57595 + while (match) {
57596 + if ((match->roletype & (GR_ROLE_DOMAIN | GR_ROLE_USER)) == (GR_ROLE_DOMAIN | GR_ROLE_USER)) {
57597 + for (x = 0; x < match->domain_child_num; x++) {
57598 + if (match->domain_children[x] == uid)
57599 + goto found;
57600 + }
57601 + } else if (match->uidgid == uid && match->roletype & GR_ROLE_USER)
57602 + break;
57603 + match = match->next;
57604 + }
57605 +found:
57606 + if (match == NULL) {
57607 + try_group:
57608 + index = gr_rhash(gid, GR_ROLE_GROUP, acl_role_set.r_size);
57609 + match = acl_role_set.r_hash[index];
57610 +
57611 + while (match) {
57612 + if ((match->roletype & (GR_ROLE_DOMAIN | GR_ROLE_GROUP)) == (GR_ROLE_DOMAIN | GR_ROLE_GROUP)) {
57613 + for (x = 0; x < match->domain_child_num; x++) {
57614 + if (match->domain_children[x] == gid)
57615 + goto found2;
57616 + }
57617 + } else if (match->uidgid == gid && match->roletype & GR_ROLE_GROUP)
57618 + break;
57619 + match = match->next;
57620 + }
57621 +found2:
57622 + if (match == NULL)
57623 + match = default_role;
57624 + if (match->allowed_ips == NULL)
57625 + return match;
57626 + else {
57627 + for (ipp = match->allowed_ips; ipp; ipp = ipp->next) {
57628 + if (likely
57629 + ((ntohl(curr_ip) & ipp->netmask) ==
57630 + (ntohl(ipp->addr) & ipp->netmask)))
57631 + return match;
57632 + }
57633 + match = default_role;
57634 + }
57635 + } else if (match->allowed_ips == NULL) {
57636 + return match;
57637 + } else {
57638 + for (ipp = match->allowed_ips; ipp; ipp = ipp->next) {
57639 + if (likely
57640 + ((ntohl(curr_ip) & ipp->netmask) ==
57641 + (ntohl(ipp->addr) & ipp->netmask)))
57642 + return match;
57643 + }
57644 + goto try_group;
57645 + }
57646 +
57647 + return match;
57648 +}
57649 +
57650 +struct acl_subject_label *
57651 +lookup_acl_subj_label(const ino_t ino, const dev_t dev,
57652 + const struct acl_role_label *role)
57653 +{
57654 + unsigned int index = gr_fhash(ino, dev, role->subj_hash_size);
57655 + struct acl_subject_label *match;
57656 +
57657 + match = role->subj_hash[index];
57658 +
57659 + while (match && (match->inode != ino || match->device != dev ||
57660 + (match->mode & GR_DELETED))) {
57661 + match = match->next;
57662 + }
57663 +
57664 + if (match && !(match->mode & GR_DELETED))
57665 + return match;
57666 + else
57667 + return NULL;
57668 +}
57669 +
57670 +struct acl_subject_label *
57671 +lookup_acl_subj_label_deleted(const ino_t ino, const dev_t dev,
57672 + const struct acl_role_label *role)
57673 +{
57674 + unsigned int index = gr_fhash(ino, dev, role->subj_hash_size);
57675 + struct acl_subject_label *match;
57676 +
57677 + match = role->subj_hash[index];
57678 +
57679 + while (match && (match->inode != ino || match->device != dev ||
57680 + !(match->mode & GR_DELETED))) {
57681 + match = match->next;
57682 + }
57683 +
57684 + if (match && (match->mode & GR_DELETED))
57685 + return match;
57686 + else
57687 + return NULL;
57688 +}
57689 +
57690 +static struct acl_object_label *
57691 +lookup_acl_obj_label(const ino_t ino, const dev_t dev,
57692 + const struct acl_subject_label *subj)
57693 +{
57694 + unsigned int index = gr_fhash(ino, dev, subj->obj_hash_size);
57695 + struct acl_object_label *match;
57696 +
57697 + match = subj->obj_hash[index];
57698 +
57699 + while (match && (match->inode != ino || match->device != dev ||
57700 + (match->mode & GR_DELETED))) {
57701 + match = match->next;
57702 + }
57703 +
57704 + if (match && !(match->mode & GR_DELETED))
57705 + return match;
57706 + else
57707 + return NULL;
57708 +}
57709 +
57710 +static struct acl_object_label *
57711 +lookup_acl_obj_label_create(const ino_t ino, const dev_t dev,
57712 + const struct acl_subject_label *subj)
57713 +{
57714 + unsigned int index = gr_fhash(ino, dev, subj->obj_hash_size);
57715 + struct acl_object_label *match;
57716 +
57717 + match = subj->obj_hash[index];
57718 +
57719 + while (match && (match->inode != ino || match->device != dev ||
57720 + !(match->mode & GR_DELETED))) {
57721 + match = match->next;
57722 + }
57723 +
57724 + if (match && (match->mode & GR_DELETED))
57725 + return match;
57726 +
57727 + match = subj->obj_hash[index];
57728 +
57729 + while (match && (match->inode != ino || match->device != dev ||
57730 + (match->mode & GR_DELETED))) {
57731 + match = match->next;
57732 + }
57733 +
57734 + if (match && !(match->mode & GR_DELETED))
57735 + return match;
57736 + else
57737 + return NULL;
57738 +}
57739 +
57740 +static struct name_entry *
57741 +lookup_name_entry(const char *name)
57742 +{
57743 + unsigned int len = strlen(name);
57744 + unsigned int key = full_name_hash(name, len);
57745 + unsigned int index = key % name_set.n_size;
57746 + struct name_entry *match;
57747 +
57748 + match = name_set.n_hash[index];
57749 +
57750 + while (match && (match->key != key || !gr_streq(match->name, name, match->len, len)))
57751 + match = match->next;
57752 +
57753 + return match;
57754 +}
57755 +
57756 +static struct name_entry *
57757 +lookup_name_entry_create(const char *name)
57758 +{
57759 + unsigned int len = strlen(name);
57760 + unsigned int key = full_name_hash(name, len);
57761 + unsigned int index = key % name_set.n_size;
57762 + struct name_entry *match;
57763 +
57764 + match = name_set.n_hash[index];
57765 +
57766 + while (match && (match->key != key || !gr_streq(match->name, name, match->len, len) ||
57767 + !match->deleted))
57768 + match = match->next;
57769 +
57770 + if (match && match->deleted)
57771 + return match;
57772 +
57773 + match = name_set.n_hash[index];
57774 +
57775 + while (match && (match->key != key || !gr_streq(match->name, name, match->len, len) ||
57776 + match->deleted))
57777 + match = match->next;
57778 +
57779 + if (match && !match->deleted)
57780 + return match;
57781 + else
57782 + return NULL;
57783 +}
57784 +
57785 +static struct inodev_entry *
57786 +lookup_inodev_entry(const ino_t ino, const dev_t dev)
57787 +{
57788 + unsigned int index = gr_fhash(ino, dev, inodev_set.i_size);
57789 + struct inodev_entry *match;
57790 +
57791 + match = inodev_set.i_hash[index];
57792 +
57793 + while (match && (match->nentry->inode != ino || match->nentry->device != dev))
57794 + match = match->next;
57795 +
57796 + return match;
57797 +}
57798 +
57799 +static void
57800 +insert_inodev_entry(struct inodev_entry *entry)
57801 +{
57802 + unsigned int index = gr_fhash(entry->nentry->inode, entry->nentry->device,
57803 + inodev_set.i_size);
57804 + struct inodev_entry **curr;
57805 +
57806 + entry->prev = NULL;
57807 +
57808 + curr = &inodev_set.i_hash[index];
57809 + if (*curr != NULL)
57810 + (*curr)->prev = entry;
57811 +
57812 + entry->next = *curr;
57813 + *curr = entry;
57814 +
57815 + return;
57816 +}
57817 +
57818 +static void
57819 +__insert_acl_role_label(struct acl_role_label *role, uid_t uidgid)
57820 +{
57821 + unsigned int index =
57822 + gr_rhash(uidgid, role->roletype & (GR_ROLE_USER | GR_ROLE_GROUP), acl_role_set.r_size);
57823 + struct acl_role_label **curr;
57824 + struct acl_role_label *tmp, *tmp2;
57825 +
57826 + curr = &acl_role_set.r_hash[index];
57827 +
57828 + /* simple case, slot is empty, just set it to our role */
57829 + if (*curr == NULL) {
57830 + *curr = role;
57831 + } else {
57832 + /* example:
57833 + 1 -> 2 -> 3 (adding 2 -> 3 to here)
57834 + 2 -> 3
57835 + */
57836 + /* first check to see if we can already be reached via this slot */
57837 + tmp = *curr;
57838 + while (tmp && tmp != role)
57839 + tmp = tmp->next;
57840 + if (tmp == role) {
57841 + /* we don't need to add ourselves to this slot's chain */
57842 + return;
57843 + }
57844 + /* we need to add ourselves to this chain, two cases */
57845 + if (role->next == NULL) {
57846 + /* simple case, append the current chain to our role */
57847 + role->next = *curr;
57848 + *curr = role;
57849 + } else {
57850 + /* 1 -> 2 -> 3 -> 4
57851 + 2 -> 3 -> 4
57852 + 3 -> 4 (adding 1 -> 2 -> 3 -> 4 to here)
57853 + */
57854 + /* trickier case: walk our role's chain until we find
57855 + the role for the start of the current slot's chain */
57856 + tmp = role;
57857 + tmp2 = *curr;
57858 + while (tmp->next && tmp->next != tmp2)
57859 + tmp = tmp->next;
57860 + if (tmp->next == tmp2) {
57861 + /* from example above, we found 3, so just
57862 + replace this slot's chain with ours */
57863 + *curr = role;
57864 + } else {
57865 + /* we didn't find a subset of our role's chain
57866 + in the current slot's chain, so append their
57867 + chain to ours, and set us as the first role in
57868 + the slot's chain
57869 +
57870 + we could fold this case with the case above,
57871 + but making it explicit for clarity
57872 + */
57873 + tmp->next = tmp2;
57874 + *curr = role;
57875 + }
57876 + }
57877 + }
57878 +
57879 + return;
57880 +}
57881 +
57882 +static void
57883 +insert_acl_role_label(struct acl_role_label *role)
57884 +{
57885 + int i;
57886 +
57887 + if (role_list == NULL) {
57888 + role_list = role;
57889 + role->prev = NULL;
57890 + } else {
57891 + role->prev = role_list;
57892 + role_list = role;
57893 + }
57894 +
57895 + /* used for hash chains */
57896 + role->next = NULL;
57897 +
57898 + if (role->roletype & GR_ROLE_DOMAIN) {
57899 + for (i = 0; i < role->domain_child_num; i++)
57900 + __insert_acl_role_label(role, role->domain_children[i]);
57901 + } else
57902 + __insert_acl_role_label(role, role->uidgid);
57903 +}
57904 +
57905 +static int
57906 +insert_name_entry(char *name, const ino_t inode, const dev_t device, __u8 deleted)
57907 +{
57908 + struct name_entry **curr, *nentry;
57909 + struct inodev_entry *ientry;
57910 + unsigned int len = strlen(name);
57911 + unsigned int key = full_name_hash(name, len);
57912 + unsigned int index = key % name_set.n_size;
57913 +
57914 + curr = &name_set.n_hash[index];
57915 +
57916 + while (*curr && ((*curr)->key != key || !gr_streq((*curr)->name, name, (*curr)->len, len)))
57917 + curr = &((*curr)->next);
57918 +
57919 + if (*curr != NULL)
57920 + return 1;
57921 +
57922 + nentry = acl_alloc(sizeof (struct name_entry));
57923 + if (nentry == NULL)
57924 + return 0;
57925 + ientry = acl_alloc(sizeof (struct inodev_entry));
57926 + if (ientry == NULL)
57927 + return 0;
57928 + ientry->nentry = nentry;
57929 +
57930 + nentry->key = key;
57931 + nentry->name = name;
57932 + nentry->inode = inode;
57933 + nentry->device = device;
57934 + nentry->len = len;
57935 + nentry->deleted = deleted;
57936 +
57937 + nentry->prev = NULL;
57938 + curr = &name_set.n_hash[index];
57939 + if (*curr != NULL)
57940 + (*curr)->prev = nentry;
57941 + nentry->next = *curr;
57942 + *curr = nentry;
57943 +
57944 + /* insert us into the table searchable by inode/dev */
57945 + insert_inodev_entry(ientry);
57946 +
57947 + return 1;
57948 +}
57949 +
57950 +static void
57951 +insert_acl_obj_label(struct acl_object_label *obj,
57952 + struct acl_subject_label *subj)
57953 +{
57954 + unsigned int index =
57955 + gr_fhash(obj->inode, obj->device, subj->obj_hash_size);
57956 + struct acl_object_label **curr;
57957 +
57958 +
57959 + obj->prev = NULL;
57960 +
57961 + curr = &subj->obj_hash[index];
57962 + if (*curr != NULL)
57963 + (*curr)->prev = obj;
57964 +
57965 + obj->next = *curr;
57966 + *curr = obj;
57967 +
57968 + return;
57969 +}
57970 +
57971 +static void
57972 +insert_acl_subj_label(struct acl_subject_label *obj,
57973 + struct acl_role_label *role)
57974 +{
57975 + unsigned int index = gr_fhash(obj->inode, obj->device, role->subj_hash_size);
57976 + struct acl_subject_label **curr;
57977 +
57978 + obj->prev = NULL;
57979 +
57980 + curr = &role->subj_hash[index];
57981 + if (*curr != NULL)
57982 + (*curr)->prev = obj;
57983 +
57984 + obj->next = *curr;
57985 + *curr = obj;
57986 +
57987 + return;
57988 +}
57989 +
57990 +/* allocating chained hash tables, so optimal size is where lambda ~ 1 */
57991 +
57992 +static void *
57993 +create_table(__u32 * len, int elementsize)
57994 +{
57995 + unsigned int table_sizes[] = {
57996 + 7, 13, 31, 61, 127, 251, 509, 1021, 2039, 4093, 8191, 16381,
57997 + 32749, 65521, 131071, 262139, 524287, 1048573, 2097143,
57998 + 4194301, 8388593, 16777213, 33554393, 67108859
57999 + };
58000 + void *newtable = NULL;
58001 + unsigned int pwr = 0;
58002 +
58003 + while ((pwr < ((sizeof (table_sizes) / sizeof (table_sizes[0])) - 1)) &&
58004 + table_sizes[pwr] <= *len)
58005 + pwr++;
58006 +
58007 + if (table_sizes[pwr] <= *len || (table_sizes[pwr] > ULONG_MAX / elementsize))
58008 + return newtable;
58009 +
58010 + if ((table_sizes[pwr] * elementsize) <= PAGE_SIZE)
58011 + newtable =
58012 + kmalloc(table_sizes[pwr] * elementsize, GFP_KERNEL);
58013 + else
58014 + newtable = vmalloc(table_sizes[pwr] * elementsize);
58015 +
58016 + *len = table_sizes[pwr];
58017 +
58018 + return newtable;
58019 +}
58020 +
58021 +static int
58022 +init_variables(const struct gr_arg *arg)
58023 +{
58024 + struct task_struct *reaper = init_pid_ns.child_reaper;
58025 + unsigned int stacksize;
58026 +
58027 + subj_map_set.s_size = arg->role_db.num_subjects;
58028 + acl_role_set.r_size = arg->role_db.num_roles + arg->role_db.num_domain_children;
58029 + name_set.n_size = arg->role_db.num_objects;
58030 + inodev_set.i_size = arg->role_db.num_objects;
58031 +
58032 + if (!subj_map_set.s_size || !acl_role_set.r_size ||
58033 + !name_set.n_size || !inodev_set.i_size)
58034 + return 1;
58035 +
58036 + if (!gr_init_uidset())
58037 + return 1;
58038 +
58039 + /* set up the stack that holds allocation info */
58040 +
58041 + stacksize = arg->role_db.num_pointers + 5;
58042 +
58043 + if (!acl_alloc_stack_init(stacksize))
58044 + return 1;
58045 +
58046 + /* grab reference for the real root dentry and vfsmount */
58047 + get_fs_root(reaper->fs, &real_root);
58048 +
58049 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
58050 + printk(KERN_ALERT "Obtained real root device=%d, inode=%lu\n", __get_dev(real_root.dentry), real_root.dentry->d_inode->i_ino);
58051 +#endif
58052 +
58053 + fakefs_obj_rw = acl_alloc(sizeof(struct acl_object_label));
58054 + if (fakefs_obj_rw == NULL)
58055 + return 1;
58056 + fakefs_obj_rw->mode = GR_FIND | GR_READ | GR_WRITE;
58057 +
58058 + fakefs_obj_rwx = acl_alloc(sizeof(struct acl_object_label));
58059 + if (fakefs_obj_rwx == NULL)
58060 + return 1;
58061 + fakefs_obj_rwx->mode = GR_FIND | GR_READ | GR_WRITE | GR_EXEC;
58062 +
58063 + subj_map_set.s_hash =
58064 + (struct subject_map **) create_table(&subj_map_set.s_size, sizeof(void *));
58065 + acl_role_set.r_hash =
58066 + (struct acl_role_label **) create_table(&acl_role_set.r_size, sizeof(void *));
58067 + name_set.n_hash = (struct name_entry **) create_table(&name_set.n_size, sizeof(void *));
58068 + inodev_set.i_hash =
58069 + (struct inodev_entry **) create_table(&inodev_set.i_size, sizeof(void *));
58070 +
58071 + if (!subj_map_set.s_hash || !acl_role_set.r_hash ||
58072 + !name_set.n_hash || !inodev_set.i_hash)
58073 + return 1;
58074 +
58075 + memset(subj_map_set.s_hash, 0,
58076 + sizeof(struct subject_map *) * subj_map_set.s_size);
58077 + memset(acl_role_set.r_hash, 0,
58078 + sizeof (struct acl_role_label *) * acl_role_set.r_size);
58079 + memset(name_set.n_hash, 0,
58080 + sizeof (struct name_entry *) * name_set.n_size);
58081 + memset(inodev_set.i_hash, 0,
58082 + sizeof (struct inodev_entry *) * inodev_set.i_size);
58083 +
58084 + return 0;
58085 +}
58086 +
58087 +/* free information not needed after startup
58088 + currently contains user->kernel pointer mappings for subjects
58089 +*/
58090 +
58091 +static void
58092 +free_init_variables(void)
58093 +{
58094 + __u32 i;
58095 +
58096 + if (subj_map_set.s_hash) {
58097 + for (i = 0; i < subj_map_set.s_size; i++) {
58098 + if (subj_map_set.s_hash[i]) {
58099 + kfree(subj_map_set.s_hash[i]);
58100 + subj_map_set.s_hash[i] = NULL;
58101 + }
58102 + }
58103 +
58104 + if ((subj_map_set.s_size * sizeof (struct subject_map *)) <=
58105 + PAGE_SIZE)
58106 + kfree(subj_map_set.s_hash);
58107 + else
58108 + vfree(subj_map_set.s_hash);
58109 + }
58110 +
58111 + return;
58112 +}
58113 +
58114 +static void
58115 +free_variables(void)
58116 +{
58117 + struct acl_subject_label *s;
58118 + struct acl_role_label *r;
58119 + struct task_struct *task, *task2;
58120 + unsigned int x;
58121 +
58122 + gr_clear_learn_entries();
58123 +
58124 + read_lock(&tasklist_lock);
58125 + do_each_thread(task2, task) {
58126 + task->acl_sp_role = 0;
58127 + task->acl_role_id = 0;
58128 + task->acl = NULL;
58129 + task->role = NULL;
58130 + } while_each_thread(task2, task);
58131 + read_unlock(&tasklist_lock);
58132 +
58133 + /* release the reference to the real root dentry and vfsmount */
58134 + path_put(&real_root);
58135 + memset(&real_root, 0, sizeof(real_root));
58136 +
58137 + /* free all object hash tables */
58138 +
58139 + FOR_EACH_ROLE_START(r)
58140 + if (r->subj_hash == NULL)
58141 + goto next_role;
58142 + FOR_EACH_SUBJECT_START(r, s, x)
58143 + if (s->obj_hash == NULL)
58144 + break;
58145 + if ((s->obj_hash_size * sizeof (struct acl_object_label *)) <= PAGE_SIZE)
58146 + kfree(s->obj_hash);
58147 + else
58148 + vfree(s->obj_hash);
58149 + FOR_EACH_SUBJECT_END(s, x)
58150 + FOR_EACH_NESTED_SUBJECT_START(r, s)
58151 + if (s->obj_hash == NULL)
58152 + break;
58153 + if ((s->obj_hash_size * sizeof (struct acl_object_label *)) <= PAGE_SIZE)
58154 + kfree(s->obj_hash);
58155 + else
58156 + vfree(s->obj_hash);
58157 + FOR_EACH_NESTED_SUBJECT_END(s)
58158 + if ((r->subj_hash_size * sizeof (struct acl_subject_label *)) <= PAGE_SIZE)
58159 + kfree(r->subj_hash);
58160 + else
58161 + vfree(r->subj_hash);
58162 + r->subj_hash = NULL;
58163 +next_role:
58164 + FOR_EACH_ROLE_END(r)
58165 +
58166 + acl_free_all();
58167 +
58168 + if (acl_role_set.r_hash) {
58169 + if ((acl_role_set.r_size * sizeof (struct acl_role_label *)) <=
58170 + PAGE_SIZE)
58171 + kfree(acl_role_set.r_hash);
58172 + else
58173 + vfree(acl_role_set.r_hash);
58174 + }
58175 + if (name_set.n_hash) {
58176 + if ((name_set.n_size * sizeof (struct name_entry *)) <=
58177 + PAGE_SIZE)
58178 + kfree(name_set.n_hash);
58179 + else
58180 + vfree(name_set.n_hash);
58181 + }
58182 +
58183 + if (inodev_set.i_hash) {
58184 + if ((inodev_set.i_size * sizeof (struct inodev_entry *)) <=
58185 + PAGE_SIZE)
58186 + kfree(inodev_set.i_hash);
58187 + else
58188 + vfree(inodev_set.i_hash);
58189 + }
58190 +
58191 + gr_free_uidset();
58192 +
58193 + memset(&name_set, 0, sizeof (struct name_db));
58194 + memset(&inodev_set, 0, sizeof (struct inodev_db));
58195 + memset(&acl_role_set, 0, sizeof (struct acl_role_db));
58196 + memset(&subj_map_set, 0, sizeof (struct acl_subj_map_db));
58197 +
58198 + default_role = NULL;
58199 + kernel_role = NULL;
58200 + role_list = NULL;
58201 +
58202 + return;
58203 +}
58204 +
58205 +static __u32
58206 +count_user_objs(struct acl_object_label *userp)
58207 +{
58208 + struct acl_object_label o_tmp;
58209 + __u32 num = 0;
58210 +
58211 + while (userp) {
58212 + if (copy_from_user(&o_tmp, userp,
58213 + sizeof (struct acl_object_label)))
58214 + break;
58215 +
58216 + userp = o_tmp.prev;
58217 + num++;
58218 + }
58219 +
58220 + return num;
58221 +}
58222 +
58223 +static struct acl_subject_label *
58224 +do_copy_user_subj(struct acl_subject_label *userp, struct acl_role_label *role, int *already_copied);
58225 +
58226 +static int
58227 +copy_user_glob(struct acl_object_label *obj)
58228 +{
58229 + struct acl_object_label *g_tmp, **guser;
58230 + unsigned int len;
58231 + char *tmp;
58232 +
58233 + if (obj->globbed == NULL)
58234 + return 0;
58235 +
58236 + guser = &obj->globbed;
58237 + while (*guser) {
58238 + g_tmp = (struct acl_object_label *)
58239 + acl_alloc(sizeof (struct acl_object_label));
58240 + if (g_tmp == NULL)
58241 + return -ENOMEM;
58242 +
58243 + if (copy_from_user(g_tmp, *guser,
58244 + sizeof (struct acl_object_label)))
58245 + return -EFAULT;
58246 +
58247 + len = strnlen_user(g_tmp->filename, PATH_MAX);
58248 +
58249 + if (!len || len >= PATH_MAX)
58250 + return -EINVAL;
58251 +
58252 + if ((tmp = (char *) acl_alloc(len)) == NULL)
58253 + return -ENOMEM;
58254 +
58255 + if (copy_from_user(tmp, g_tmp->filename, len))
58256 + return -EFAULT;
58257 + tmp[len-1] = '\0';
58258 + g_tmp->filename = tmp;
58259 +
58260 + *guser = g_tmp;
58261 + guser = &(g_tmp->next);
58262 + }
58263 +
58264 + return 0;
58265 +}
58266 +
58267 +static int
58268 +copy_user_objs(struct acl_object_label *userp, struct acl_subject_label *subj,
58269 + struct acl_role_label *role)
58270 +{
58271 + struct acl_object_label *o_tmp;
58272 + unsigned int len;
58273 + int ret;
58274 + char *tmp;
58275 +
58276 + while (userp) {
58277 + if ((o_tmp = (struct acl_object_label *)
58278 + acl_alloc(sizeof (struct acl_object_label))) == NULL)
58279 + return -ENOMEM;
58280 +
58281 + if (copy_from_user(o_tmp, userp,
58282 + sizeof (struct acl_object_label)))
58283 + return -EFAULT;
58284 +
58285 + userp = o_tmp->prev;
58286 +
58287 + len = strnlen_user(o_tmp->filename, PATH_MAX);
58288 +
58289 + if (!len || len >= PATH_MAX)
58290 + return -EINVAL;
58291 +
58292 + if ((tmp = (char *) acl_alloc(len)) == NULL)
58293 + return -ENOMEM;
58294 +
58295 + if (copy_from_user(tmp, o_tmp->filename, len))
58296 + return -EFAULT;
58297 + tmp[len-1] = '\0';
58298 + o_tmp->filename = tmp;
58299 +
58300 + insert_acl_obj_label(o_tmp, subj);
58301 + if (!insert_name_entry(o_tmp->filename, o_tmp->inode,
58302 + o_tmp->device, (o_tmp->mode & GR_DELETED) ? 1 : 0))
58303 + return -ENOMEM;
58304 +
58305 + ret = copy_user_glob(o_tmp);
58306 + if (ret)
58307 + return ret;
58308 +
58309 + if (o_tmp->nested) {
58310 + int already_copied;
58311 +
58312 + o_tmp->nested = do_copy_user_subj(o_tmp->nested, role, &already_copied);
58313 + if (IS_ERR(o_tmp->nested))
58314 + return PTR_ERR(o_tmp->nested);
58315 +
58316 + /* insert into nested subject list if we haven't copied this one yet
58317 + to prevent duplicate entries */
58318 + if (!already_copied) {
58319 + o_tmp->nested->next = role->hash->first;
58320 + role->hash->first = o_tmp->nested;
58321 + }
58322 + }
58323 + }
58324 +
58325 + return 0;
58326 +}
58327 +
58328 +static __u32
58329 +count_user_subjs(struct acl_subject_label *userp)
58330 +{
58331 + struct acl_subject_label s_tmp;
58332 + __u32 num = 0;
58333 +
58334 + while (userp) {
58335 + if (copy_from_user(&s_tmp, userp,
58336 + sizeof (struct acl_subject_label)))
58337 + break;
58338 +
58339 + userp = s_tmp.prev;
58340 + }
58341 +
58342 + return num;
58343 +}
58344 +
58345 +static int
58346 +copy_user_allowedips(struct acl_role_label *rolep)
58347 +{
58348 + struct role_allowed_ip *ruserip, *rtmp = NULL, *rlast;
58349 +
58350 + ruserip = rolep->allowed_ips;
58351 +
58352 + while (ruserip) {
58353 + rlast = rtmp;
58354 +
58355 + if ((rtmp = (struct role_allowed_ip *)
58356 + acl_alloc(sizeof (struct role_allowed_ip))) == NULL)
58357 + return -ENOMEM;
58358 +
58359 + if (copy_from_user(rtmp, ruserip,
58360 + sizeof (struct role_allowed_ip)))
58361 + return -EFAULT;
58362 +
58363 + ruserip = rtmp->prev;
58364 +
58365 + if (!rlast) {
58366 + rtmp->prev = NULL;
58367 + rolep->allowed_ips = rtmp;
58368 + } else {
58369 + rlast->next = rtmp;
58370 + rtmp->prev = rlast;
58371 + }
58372 +
58373 + if (!ruserip)
58374 + rtmp->next = NULL;
58375 + }
58376 +
58377 + return 0;
58378 +}
58379 +
58380 +static int
58381 +copy_user_transitions(struct acl_role_label *rolep)
58382 +{
58383 + struct role_transition *rusertp, *rtmp = NULL, *rlast;
58384 +
58385 + unsigned int len;
58386 + char *tmp;
58387 +
58388 + rusertp = rolep->transitions;
58389 +
58390 + while (rusertp) {
58391 + rlast = rtmp;
58392 +
58393 + if ((rtmp = (struct role_transition *)
58394 + acl_alloc(sizeof (struct role_transition))) == NULL)
58395 + return -ENOMEM;
58396 +
58397 + if (copy_from_user(rtmp, rusertp,
58398 + sizeof (struct role_transition)))
58399 + return -EFAULT;
58400 +
58401 + rusertp = rtmp->prev;
58402 +
58403 + len = strnlen_user(rtmp->rolename, GR_SPROLE_LEN);
58404 +
58405 + if (!len || len >= GR_SPROLE_LEN)
58406 + return -EINVAL;
58407 +
58408 + if ((tmp = (char *) acl_alloc(len)) == NULL)
58409 + return -ENOMEM;
58410 +
58411 + if (copy_from_user(tmp, rtmp->rolename, len))
58412 + return -EFAULT;
58413 + tmp[len-1] = '\0';
58414 + rtmp->rolename = tmp;
58415 +
58416 + if (!rlast) {
58417 + rtmp->prev = NULL;
58418 + rolep->transitions = rtmp;
58419 + } else {
58420 + rlast->next = rtmp;
58421 + rtmp->prev = rlast;
58422 + }
58423 +
58424 + if (!rusertp)
58425 + rtmp->next = NULL;
58426 + }
58427 +
58428 + return 0;
58429 +}
58430 +
58431 +static struct acl_subject_label *
58432 +do_copy_user_subj(struct acl_subject_label *userp, struct acl_role_label *role, int *already_copied)
58433 +{
58434 + struct acl_subject_label *s_tmp = NULL, *s_tmp2;
58435 + unsigned int len;
58436 + char *tmp;
58437 + __u32 num_objs;
58438 + struct acl_ip_label **i_tmp, *i_utmp2;
58439 + struct gr_hash_struct ghash;
58440 + struct subject_map *subjmap;
58441 + unsigned int i_num;
58442 + int err;
58443 +
58444 + if (already_copied != NULL)
58445 + *already_copied = 0;
58446 +
58447 + s_tmp = lookup_subject_map(userp);
58448 +
58449 + /* we've already copied this subject into the kernel, just return
58450 + the reference to it, and don't copy it over again
58451 + */
58452 + if (s_tmp) {
58453 + if (already_copied != NULL)
58454 + *already_copied = 1;
58455 + return(s_tmp);
58456 + }
58457 +
58458 + if ((s_tmp = (struct acl_subject_label *)
58459 + acl_alloc(sizeof (struct acl_subject_label))) == NULL)
58460 + return ERR_PTR(-ENOMEM);
58461 +
58462 + subjmap = (struct subject_map *)kmalloc(sizeof (struct subject_map), GFP_KERNEL);
58463 + if (subjmap == NULL)
58464 + return ERR_PTR(-ENOMEM);
58465 +
58466 + subjmap->user = userp;
58467 + subjmap->kernel = s_tmp;
58468 + insert_subj_map_entry(subjmap);
58469 +
58470 + if (copy_from_user(s_tmp, userp,
58471 + sizeof (struct acl_subject_label)))
58472 + return ERR_PTR(-EFAULT);
58473 +
58474 + len = strnlen_user(s_tmp->filename, PATH_MAX);
58475 +
58476 + if (!len || len >= PATH_MAX)
58477 + return ERR_PTR(-EINVAL);
58478 +
58479 + if ((tmp = (char *) acl_alloc(len)) == NULL)
58480 + return ERR_PTR(-ENOMEM);
58481 +
58482 + if (copy_from_user(tmp, s_tmp->filename, len))
58483 + return ERR_PTR(-EFAULT);
58484 + tmp[len-1] = '\0';
58485 + s_tmp->filename = tmp;
58486 +
58487 + if (!strcmp(s_tmp->filename, "/"))
58488 + role->root_label = s_tmp;
58489 +
58490 + if (copy_from_user(&ghash, s_tmp->hash, sizeof(struct gr_hash_struct)))
58491 + return ERR_PTR(-EFAULT);
58492 +
58493 + /* copy user and group transition tables */
58494 +
58495 + if (s_tmp->user_trans_num) {
58496 + uid_t *uidlist;
58497 +
58498 + uidlist = (uid_t *)acl_alloc_num(s_tmp->user_trans_num, sizeof(uid_t));
58499 + if (uidlist == NULL)
58500 + return ERR_PTR(-ENOMEM);
58501 + if (copy_from_user(uidlist, s_tmp->user_transitions, s_tmp->user_trans_num * sizeof(uid_t)))
58502 + return ERR_PTR(-EFAULT);
58503 +
58504 + s_tmp->user_transitions = uidlist;
58505 + }
58506 +
58507 + if (s_tmp->group_trans_num) {
58508 + gid_t *gidlist;
58509 +
58510 + gidlist = (gid_t *)acl_alloc_num(s_tmp->group_trans_num, sizeof(gid_t));
58511 + if (gidlist == NULL)
58512 + return ERR_PTR(-ENOMEM);
58513 + if (copy_from_user(gidlist, s_tmp->group_transitions, s_tmp->group_trans_num * sizeof(gid_t)))
58514 + return ERR_PTR(-EFAULT);
58515 +
58516 + s_tmp->group_transitions = gidlist;
58517 + }
58518 +
58519 + /* set up object hash table */
58520 + num_objs = count_user_objs(ghash.first);
58521 +
58522 + s_tmp->obj_hash_size = num_objs;
58523 + s_tmp->obj_hash =
58524 + (struct acl_object_label **)
58525 + create_table(&(s_tmp->obj_hash_size), sizeof(void *));
58526 +
58527 + if (!s_tmp->obj_hash)
58528 + return ERR_PTR(-ENOMEM);
58529 +
58530 + memset(s_tmp->obj_hash, 0,
58531 + s_tmp->obj_hash_size *
58532 + sizeof (struct acl_object_label *));
58533 +
58534 + /* add in objects */
58535 + err = copy_user_objs(ghash.first, s_tmp, role);
58536 +
58537 + if (err)
58538 + return ERR_PTR(err);
58539 +
58540 + /* set pointer for parent subject */
58541 + if (s_tmp->parent_subject) {
58542 + s_tmp2 = do_copy_user_subj(s_tmp->parent_subject, role, NULL);
58543 +
58544 + if (IS_ERR(s_tmp2))
58545 + return s_tmp2;
58546 +
58547 + s_tmp->parent_subject = s_tmp2;
58548 + }
58549 +
58550 + /* add in ip acls */
58551 +
58552 + if (!s_tmp->ip_num) {
58553 + s_tmp->ips = NULL;
58554 + goto insert;
58555 + }
58556 +
58557 + i_tmp =
58558 + (struct acl_ip_label **) acl_alloc_num(s_tmp->ip_num,
58559 + sizeof (struct acl_ip_label *));
58560 +
58561 + if (!i_tmp)
58562 + return ERR_PTR(-ENOMEM);
58563 +
58564 + for (i_num = 0; i_num < s_tmp->ip_num; i_num++) {
58565 + *(i_tmp + i_num) =
58566 + (struct acl_ip_label *)
58567 + acl_alloc(sizeof (struct acl_ip_label));
58568 + if (!*(i_tmp + i_num))
58569 + return ERR_PTR(-ENOMEM);
58570 +
58571 + if (copy_from_user
58572 + (&i_utmp2, s_tmp->ips + i_num,
58573 + sizeof (struct acl_ip_label *)))
58574 + return ERR_PTR(-EFAULT);
58575 +
58576 + if (copy_from_user
58577 + (*(i_tmp + i_num), i_utmp2,
58578 + sizeof (struct acl_ip_label)))
58579 + return ERR_PTR(-EFAULT);
58580 +
58581 + if ((*(i_tmp + i_num))->iface == NULL)
58582 + continue;
58583 +
58584 + len = strnlen_user((*(i_tmp + i_num))->iface, IFNAMSIZ);
58585 + if (!len || len >= IFNAMSIZ)
58586 + return ERR_PTR(-EINVAL);
58587 + tmp = acl_alloc(len);
58588 + if (tmp == NULL)
58589 + return ERR_PTR(-ENOMEM);
58590 + if (copy_from_user(tmp, (*(i_tmp + i_num))->iface, len))
58591 + return ERR_PTR(-EFAULT);
58592 + (*(i_tmp + i_num))->iface = tmp;
58593 + }
58594 +
58595 + s_tmp->ips = i_tmp;
58596 +
58597 +insert:
58598 + if (!insert_name_entry(s_tmp->filename, s_tmp->inode,
58599 + s_tmp->device, (s_tmp->mode & GR_DELETED) ? 1 : 0))
58600 + return ERR_PTR(-ENOMEM);
58601 +
58602 + return s_tmp;
58603 +}
58604 +
58605 +static int
58606 +copy_user_subjs(struct acl_subject_label *userp, struct acl_role_label *role)
58607 +{
58608 + struct acl_subject_label s_pre;
58609 + struct acl_subject_label * ret;
58610 + int err;
58611 +
58612 + while (userp) {
58613 + if (copy_from_user(&s_pre, userp,
58614 + sizeof (struct acl_subject_label)))
58615 + return -EFAULT;
58616 +
58617 + ret = do_copy_user_subj(userp, role, NULL);
58618 +
58619 + err = PTR_ERR(ret);
58620 + if (IS_ERR(ret))
58621 + return err;
58622 +
58623 + insert_acl_subj_label(ret, role);
58624 +
58625 + userp = s_pre.prev;
58626 + }
58627 +
58628 + return 0;
58629 +}
58630 +
58631 +static int
58632 +copy_user_acl(struct gr_arg *arg)
58633 +{
58634 + struct acl_role_label *r_tmp = NULL, **r_utmp, *r_utmp2;
58635 + struct acl_subject_label *subj_list;
58636 + struct sprole_pw *sptmp;
58637 + struct gr_hash_struct *ghash;
58638 + uid_t *domainlist;
58639 + unsigned int r_num;
58640 + unsigned int len;
58641 + char *tmp;
58642 + int err = 0;
58643 + __u16 i;
58644 + __u32 num_subjs;
58645 +
58646 + /* we need a default and kernel role */
58647 + if (arg->role_db.num_roles < 2)
58648 + return -EINVAL;
58649 +
58650 + /* copy special role authentication info from userspace */
58651 +
58652 + num_sprole_pws = arg->num_sprole_pws;
58653 + acl_special_roles = (struct sprole_pw **) acl_alloc_num(num_sprole_pws, sizeof(struct sprole_pw *));
58654 +
58655 + if (!acl_special_roles && num_sprole_pws)
58656 + return -ENOMEM;
58657 +
58658 + for (i = 0; i < num_sprole_pws; i++) {
58659 + sptmp = (struct sprole_pw *) acl_alloc(sizeof(struct sprole_pw));
58660 + if (!sptmp)
58661 + return -ENOMEM;
58662 + if (copy_from_user(sptmp, arg->sprole_pws + i,
58663 + sizeof (struct sprole_pw)))
58664 + return -EFAULT;
58665 +
58666 + len = strnlen_user(sptmp->rolename, GR_SPROLE_LEN);
58667 +
58668 + if (!len || len >= GR_SPROLE_LEN)
58669 + return -EINVAL;
58670 +
58671 + if ((tmp = (char *) acl_alloc(len)) == NULL)
58672 + return -ENOMEM;
58673 +
58674 + if (copy_from_user(tmp, sptmp->rolename, len))
58675 + return -EFAULT;
58676 +
58677 + tmp[len-1] = '\0';
58678 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
58679 + printk(KERN_ALERT "Copying special role %s\n", tmp);
58680 +#endif
58681 + sptmp->rolename = tmp;
58682 + acl_special_roles[i] = sptmp;
58683 + }
58684 +
58685 + r_utmp = (struct acl_role_label **) arg->role_db.r_table;
58686 +
58687 + for (r_num = 0; r_num < arg->role_db.num_roles; r_num++) {
58688 + r_tmp = acl_alloc(sizeof (struct acl_role_label));
58689 +
58690 + if (!r_tmp)
58691 + return -ENOMEM;
58692 +
58693 + if (copy_from_user(&r_utmp2, r_utmp + r_num,
58694 + sizeof (struct acl_role_label *)))
58695 + return -EFAULT;
58696 +
58697 + if (copy_from_user(r_tmp, r_utmp2,
58698 + sizeof (struct acl_role_label)))
58699 + return -EFAULT;
58700 +
58701 + len = strnlen_user(r_tmp->rolename, GR_SPROLE_LEN);
58702 +
58703 + if (!len || len >= PATH_MAX)
58704 + return -EINVAL;
58705 +
58706 + if ((tmp = (char *) acl_alloc(len)) == NULL)
58707 + return -ENOMEM;
58708 +
58709 + if (copy_from_user(tmp, r_tmp->rolename, len))
58710 + return -EFAULT;
58711 +
58712 + tmp[len-1] = '\0';
58713 + r_tmp->rolename = tmp;
58714 +
58715 + if (!strcmp(r_tmp->rolename, "default")
58716 + && (r_tmp->roletype & GR_ROLE_DEFAULT)) {
58717 + default_role = r_tmp;
58718 + } else if (!strcmp(r_tmp->rolename, ":::kernel:::")) {
58719 + kernel_role = r_tmp;
58720 + }
58721 +
58722 + if ((ghash = (struct gr_hash_struct *) acl_alloc(sizeof(struct gr_hash_struct))) == NULL)
58723 + return -ENOMEM;
58724 +
58725 + if (copy_from_user(ghash, r_tmp->hash, sizeof(struct gr_hash_struct)))
58726 + return -EFAULT;
58727 +
58728 + r_tmp->hash = ghash;
58729 +
58730 + num_subjs = count_user_subjs(r_tmp->hash->first);
58731 +
58732 + r_tmp->subj_hash_size = num_subjs;
58733 + r_tmp->subj_hash =
58734 + (struct acl_subject_label **)
58735 + create_table(&(r_tmp->subj_hash_size), sizeof(void *));
58736 +
58737 + if (!r_tmp->subj_hash)
58738 + return -ENOMEM;
58739 +
58740 + err = copy_user_allowedips(r_tmp);
58741 + if (err)
58742 + return err;
58743 +
58744 + /* copy domain info */
58745 + if (r_tmp->domain_children != NULL) {
58746 + domainlist = acl_alloc_num(r_tmp->domain_child_num, sizeof(uid_t));
58747 + if (domainlist == NULL)
58748 + return -ENOMEM;
58749 +
58750 + if (copy_from_user(domainlist, r_tmp->domain_children, r_tmp->domain_child_num * sizeof(uid_t)))
58751 + return -EFAULT;
58752 +
58753 + r_tmp->domain_children = domainlist;
58754 + }
58755 +
58756 + err = copy_user_transitions(r_tmp);
58757 + if (err)
58758 + return err;
58759 +
58760 + memset(r_tmp->subj_hash, 0,
58761 + r_tmp->subj_hash_size *
58762 + sizeof (struct acl_subject_label *));
58763 +
58764 + /* acquire the list of subjects, then NULL out
58765 + the list prior to parsing the subjects for this role,
58766 + as during this parsing the list is replaced with a list
58767 + of *nested* subjects for the role
58768 + */
58769 + subj_list = r_tmp->hash->first;
58770 +
58771 + /* set nested subject list to null */
58772 + r_tmp->hash->first = NULL;
58773 +
58774 + err = copy_user_subjs(subj_list, r_tmp);
58775 +
58776 + if (err)
58777 + return err;
58778 +
58779 + insert_acl_role_label(r_tmp);
58780 + }
58781 +
58782 + if (default_role == NULL || kernel_role == NULL)
58783 + return -EINVAL;
58784 +
58785 + return err;
58786 +}
58787 +
58788 +static int
58789 +gracl_init(struct gr_arg *args)
58790 +{
58791 + int error = 0;
58792 +
58793 + memcpy(gr_system_salt, args->salt, GR_SALT_LEN);
58794 + memcpy(gr_system_sum, args->sum, GR_SHA_LEN);
58795 +
58796 + if (init_variables(args)) {
58797 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_INITF_ACL_MSG, GR_VERSION);
58798 + error = -ENOMEM;
58799 + free_variables();
58800 + goto out;
58801 + }
58802 +
58803 + error = copy_user_acl(args);
58804 + free_init_variables();
58805 + if (error) {
58806 + free_variables();
58807 + goto out;
58808 + }
58809 +
58810 + if ((error = gr_set_acls(0))) {
58811 + free_variables();
58812 + goto out;
58813 + }
58814 +
58815 + pax_open_kernel();
58816 + gr_status |= GR_READY;
58817 + pax_close_kernel();
58818 +
58819 + out:
58820 + return error;
58821 +}
58822 +
58823 +/* derived from glibc fnmatch() 0: match, 1: no match*/
58824 +
58825 +static int
58826 +glob_match(const char *p, const char *n)
58827 +{
58828 + char c;
58829 +
58830 + while ((c = *p++) != '\0') {
58831 + switch (c) {
58832 + case '?':
58833 + if (*n == '\0')
58834 + return 1;
58835 + else if (*n == '/')
58836 + return 1;
58837 + break;
58838 + case '\\':
58839 + if (*n != c)
58840 + return 1;
58841 + break;
58842 + case '*':
58843 + for (c = *p++; c == '?' || c == '*'; c = *p++) {
58844 + if (*n == '/')
58845 + return 1;
58846 + else if (c == '?') {
58847 + if (*n == '\0')
58848 + return 1;
58849 + else
58850 + ++n;
58851 + }
58852 + }
58853 + if (c == '\0') {
58854 + return 0;
58855 + } else {
58856 + const char *endp;
58857 +
58858 + if ((endp = strchr(n, '/')) == NULL)
58859 + endp = n + strlen(n);
58860 +
58861 + if (c == '[') {
58862 + for (--p; n < endp; ++n)
58863 + if (!glob_match(p, n))
58864 + return 0;
58865 + } else if (c == '/') {
58866 + while (*n != '\0' && *n != '/')
58867 + ++n;
58868 + if (*n == '/' && !glob_match(p, n + 1))
58869 + return 0;
58870 + } else {
58871 + for (--p; n < endp; ++n)
58872 + if (*n == c && !glob_match(p, n))
58873 + return 0;
58874 + }
58875 +
58876 + return 1;
58877 + }
58878 + case '[':
58879 + {
58880 + int not;
58881 + char cold;
58882 +
58883 + if (*n == '\0' || *n == '/')
58884 + return 1;
58885 +
58886 + not = (*p == '!' || *p == '^');
58887 + if (not)
58888 + ++p;
58889 +
58890 + c = *p++;
58891 + for (;;) {
58892 + unsigned char fn = (unsigned char)*n;
58893 +
58894 + if (c == '\0')
58895 + return 1;
58896 + else {
58897 + if (c == fn)
58898 + goto matched;
58899 + cold = c;
58900 + c = *p++;
58901 +
58902 + if (c == '-' && *p != ']') {
58903 + unsigned char cend = *p++;
58904 +
58905 + if (cend == '\0')
58906 + return 1;
58907 +
58908 + if (cold <= fn && fn <= cend)
58909 + goto matched;
58910 +
58911 + c = *p++;
58912 + }
58913 + }
58914 +
58915 + if (c == ']')
58916 + break;
58917 + }
58918 + if (!not)
58919 + return 1;
58920 + break;
58921 + matched:
58922 + while (c != ']') {
58923 + if (c == '\0')
58924 + return 1;
58925 +
58926 + c = *p++;
58927 + }
58928 + if (not)
58929 + return 1;
58930 + }
58931 + break;
58932 + default:
58933 + if (c != *n)
58934 + return 1;
58935 + }
58936 +
58937 + ++n;
58938 + }
58939 +
58940 + if (*n == '\0')
58941 + return 0;
58942 +
58943 + if (*n == '/')
58944 + return 0;
58945 +
58946 + return 1;
58947 +}
58948 +
58949 +static struct acl_object_label *
58950 +chk_glob_label(struct acl_object_label *globbed,
58951 + const struct dentry *dentry, const struct vfsmount *mnt, char **path)
58952 +{
58953 + struct acl_object_label *tmp;
58954 +
58955 + if (*path == NULL)
58956 + *path = gr_to_filename_nolock(dentry, mnt);
58957 +
58958 + tmp = globbed;
58959 +
58960 + while (tmp) {
58961 + if (!glob_match(tmp->filename, *path))
58962 + return tmp;
58963 + tmp = tmp->next;
58964 + }
58965 +
58966 + return NULL;
58967 +}
58968 +
58969 +static struct acl_object_label *
58970 +__full_lookup(const struct dentry *orig_dentry, const struct vfsmount *orig_mnt,
58971 + const ino_t curr_ino, const dev_t curr_dev,
58972 + const struct acl_subject_label *subj, char **path, const int checkglob)
58973 +{
58974 + struct acl_subject_label *tmpsubj;
58975 + struct acl_object_label *retval;
58976 + struct acl_object_label *retval2;
58977 +
58978 + tmpsubj = (struct acl_subject_label *) subj;
58979 + read_lock(&gr_inode_lock);
58980 + do {
58981 + retval = lookup_acl_obj_label(curr_ino, curr_dev, tmpsubj);
58982 + if (retval) {
58983 + if (checkglob && retval->globbed) {
58984 + retval2 = chk_glob_label(retval->globbed, orig_dentry, orig_mnt, path);
58985 + if (retval2)
58986 + retval = retval2;
58987 + }
58988 + break;
58989 + }
58990 + } while ((tmpsubj = tmpsubj->parent_subject));
58991 + read_unlock(&gr_inode_lock);
58992 +
58993 + return retval;
58994 +}
58995 +
58996 +static __inline__ struct acl_object_label *
58997 +full_lookup(const struct dentry *orig_dentry, const struct vfsmount *orig_mnt,
58998 + struct dentry *curr_dentry,
58999 + const struct acl_subject_label *subj, char **path, const int checkglob)
59000 +{
59001 + int newglob = checkglob;
59002 + ino_t inode;
59003 + dev_t device;
59004 +
59005 + /* if we aren't checking a subdirectory of the original path yet, don't do glob checking
59006 + as we don't want a / * rule to match instead of the / object
59007 + don't do this for create lookups that call this function though, since they're looking up
59008 + on the parent and thus need globbing checks on all paths
59009 + */
59010 + if (orig_dentry == curr_dentry && newglob != GR_CREATE_GLOB)
59011 + newglob = GR_NO_GLOB;
59012 +
59013 + spin_lock(&curr_dentry->d_lock);
59014 + inode = curr_dentry->d_inode->i_ino;
59015 + device = __get_dev(curr_dentry);
59016 + spin_unlock(&curr_dentry->d_lock);
59017 +
59018 + return __full_lookup(orig_dentry, orig_mnt, inode, device, subj, path, newglob);
59019 +}
59020 +
59021 +#ifdef CONFIG_HUGETLBFS
59022 +static inline bool
59023 +is_hugetlbfs_mnt(const struct vfsmount *mnt)
59024 +{
59025 + int i;
59026 + for (i = 0; i < HUGE_MAX_HSTATE; i++) {
59027 + if (unlikely(hugetlbfs_vfsmount[i] == mnt))
59028 + return true;
59029 + }
59030 +
59031 + return false;
59032 +}
59033 +#endif
59034 +
59035 +static struct acl_object_label *
59036 +__chk_obj_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
59037 + const struct acl_subject_label *subj, char *path, const int checkglob)
59038 +{
59039 + struct dentry *dentry = (struct dentry *) l_dentry;
59040 + struct vfsmount *mnt = (struct vfsmount *) l_mnt;
59041 + struct mount *real_mnt = real_mount(mnt);
59042 + struct acl_object_label *retval;
59043 + struct dentry *parent;
59044 +
59045 + write_seqlock(&rename_lock);
59046 + br_read_lock(&vfsmount_lock);
59047 +
59048 + if (unlikely((mnt == shm_mnt && dentry->d_inode->i_nlink == 0) || mnt == pipe_mnt ||
59049 +#ifdef CONFIG_NET
59050 + mnt == sock_mnt ||
59051 +#endif
59052 +#ifdef CONFIG_HUGETLBFS
59053 + (is_hugetlbfs_mnt(mnt) && dentry->d_inode->i_nlink == 0) ||
59054 +#endif
59055 + /* ignore Eric Biederman */
59056 + IS_PRIVATE(l_dentry->d_inode))) {
59057 + retval = (subj->mode & GR_SHMEXEC) ? fakefs_obj_rwx : fakefs_obj_rw;
59058 + goto out;
59059 + }
59060 +
59061 + for (;;) {
59062 + if (dentry == real_root.dentry && mnt == real_root.mnt)
59063 + break;
59064 +
59065 + if (dentry == mnt->mnt_root || IS_ROOT(dentry)) {
59066 + if (!mnt_has_parent(real_mnt))
59067 + break;
59068 +
59069 + retval = full_lookup(l_dentry, l_mnt, dentry, subj, &path, checkglob);
59070 + if (retval != NULL)
59071 + goto out;
59072 +
59073 + dentry = real_mnt->mnt_mountpoint;
59074 + real_mnt = real_mnt->mnt_parent;
59075 + mnt = &real_mnt->mnt;
59076 + continue;
59077 + }
59078 +
59079 + parent = dentry->d_parent;
59080 + retval = full_lookup(l_dentry, l_mnt, dentry, subj, &path, checkglob);
59081 + if (retval != NULL)
59082 + goto out;
59083 +
59084 + dentry = parent;
59085 + }
59086 +
59087 + retval = full_lookup(l_dentry, l_mnt, dentry, subj, &path, checkglob);
59088 +
59089 + /* real_root is pinned so we don't have to hold a reference */
59090 + if (retval == NULL)
59091 + retval = full_lookup(l_dentry, l_mnt, real_root.dentry, subj, &path, checkglob);
59092 +out:
59093 + br_read_unlock(&vfsmount_lock);
59094 + write_sequnlock(&rename_lock);
59095 +
59096 + BUG_ON(retval == NULL);
59097 +
59098 + return retval;
59099 +}
59100 +
59101 +static __inline__ struct acl_object_label *
59102 +chk_obj_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
59103 + const struct acl_subject_label *subj)
59104 +{
59105 + char *path = NULL;
59106 + return __chk_obj_label(l_dentry, l_mnt, subj, path, GR_REG_GLOB);
59107 +}
59108 +
59109 +static __inline__ struct acl_object_label *
59110 +chk_obj_label_noglob(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
59111 + const struct acl_subject_label *subj)
59112 +{
59113 + char *path = NULL;
59114 + return __chk_obj_label(l_dentry, l_mnt, subj, path, GR_NO_GLOB);
59115 +}
59116 +
59117 +static __inline__ struct acl_object_label *
59118 +chk_obj_create_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
59119 + const struct acl_subject_label *subj, char *path)
59120 +{
59121 + return __chk_obj_label(l_dentry, l_mnt, subj, path, GR_CREATE_GLOB);
59122 +}
59123 +
59124 +static struct acl_subject_label *
59125 +chk_subj_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
59126 + const struct acl_role_label *role)
59127 +{
59128 + struct dentry *dentry = (struct dentry *) l_dentry;
59129 + struct vfsmount *mnt = (struct vfsmount *) l_mnt;
59130 + struct mount *real_mnt = real_mount(mnt);
59131 + struct acl_subject_label *retval;
59132 + struct dentry *parent;
59133 +
59134 + write_seqlock(&rename_lock);
59135 + br_read_lock(&vfsmount_lock);
59136 +
59137 + for (;;) {
59138 + if (dentry == real_root.dentry && mnt == real_root.mnt)
59139 + break;
59140 + if (dentry == mnt->mnt_root || IS_ROOT(dentry)) {
59141 + if (!mnt_has_parent(real_mnt))
59142 + break;
59143 +
59144 + spin_lock(&dentry->d_lock);
59145 + read_lock(&gr_inode_lock);
59146 + retval =
59147 + lookup_acl_subj_label(dentry->d_inode->i_ino,
59148 + __get_dev(dentry), role);
59149 + read_unlock(&gr_inode_lock);
59150 + spin_unlock(&dentry->d_lock);
59151 + if (retval != NULL)
59152 + goto out;
59153 +
59154 + dentry = real_mnt->mnt_mountpoint;
59155 + real_mnt = real_mnt->mnt_parent;
59156 + mnt = &real_mnt->mnt;
59157 + continue;
59158 + }
59159 +
59160 + spin_lock(&dentry->d_lock);
59161 + read_lock(&gr_inode_lock);
59162 + retval = lookup_acl_subj_label(dentry->d_inode->i_ino,
59163 + __get_dev(dentry), role);
59164 + read_unlock(&gr_inode_lock);
59165 + parent = dentry->d_parent;
59166 + spin_unlock(&dentry->d_lock);
59167 +
59168 + if (retval != NULL)
59169 + goto out;
59170 +
59171 + dentry = parent;
59172 + }
59173 +
59174 + spin_lock(&dentry->d_lock);
59175 + read_lock(&gr_inode_lock);
59176 + retval = lookup_acl_subj_label(dentry->d_inode->i_ino,
59177 + __get_dev(dentry), role);
59178 + read_unlock(&gr_inode_lock);
59179 + spin_unlock(&dentry->d_lock);
59180 +
59181 + if (unlikely(retval == NULL)) {
59182 + /* real_root is pinned, we don't need to hold a reference */
59183 + read_lock(&gr_inode_lock);
59184 + retval = lookup_acl_subj_label(real_root.dentry->d_inode->i_ino,
59185 + __get_dev(real_root.dentry), role);
59186 + read_unlock(&gr_inode_lock);
59187 + }
59188 +out:
59189 + br_read_unlock(&vfsmount_lock);
59190 + write_sequnlock(&rename_lock);
59191 +
59192 + BUG_ON(retval == NULL);
59193 +
59194 + return retval;
59195 +}
59196 +
59197 +static void
59198 +gr_log_learn(const struct dentry *dentry, const struct vfsmount *mnt, const __u32 mode)
59199 +{
59200 + struct task_struct *task = current;
59201 + const struct cred *cred = current_cred();
59202 +
59203 + security_learn(GR_LEARN_AUDIT_MSG, task->role->rolename, task->role->roletype,
59204 + GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), task->exec_file ? gr_to_filename1(task->exec_file->f_path.dentry,
59205 + task->exec_file->f_path.mnt) : task->acl->filename, task->acl->filename,
59206 + 1UL, 1UL, gr_to_filename(dentry, mnt), (unsigned long) mode, &task->signal->saved_ip);
59207 +
59208 + return;
59209 +}
59210 +
59211 +static void
59212 +gr_log_learn_uid_change(const kuid_t real, const kuid_t effective, const kuid_t fs)
59213 +{
59214 + struct task_struct *task = current;
59215 + const struct cred *cred = current_cred();
59216 +
59217 + security_learn(GR_ID_LEARN_MSG, task->role->rolename, task->role->roletype,
59218 + GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), task->exec_file ? gr_to_filename1(task->exec_file->f_path.dentry,
59219 + task->exec_file->f_path.mnt) : task->acl->filename, task->acl->filename,
59220 + 'u', GR_GLOBAL_UID(real), GR_GLOBAL_UID(effective), GR_GLOBAL_UID(fs), &task->signal->saved_ip);
59221 +
59222 + return;
59223 +}
59224 +
59225 +static void
59226 +gr_log_learn_gid_change(const kgid_t real, const kgid_t effective, const kgid_t fs)
59227 +{
59228 + struct task_struct *task = current;
59229 + const struct cred *cred = current_cred();
59230 +
59231 + security_learn(GR_ID_LEARN_MSG, task->role->rolename, task->role->roletype,
59232 + GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), task->exec_file ? gr_to_filename1(task->exec_file->f_path.dentry,
59233 + task->exec_file->f_path.mnt) : task->acl->filename, task->acl->filename,
59234 + 'g', GR_GLOBAL_GID(real), GR_GLOBAL_GID(effective), GR_GLOBAL_GID(fs), &task->signal->saved_ip);
59235 +
59236 + return;
59237 +}
59238 +
59239 +__u32
59240 +gr_search_file(const struct dentry * dentry, const __u32 mode,
59241 + const struct vfsmount * mnt)
59242 +{
59243 + __u32 retval = mode;
59244 + struct acl_subject_label *curracl;
59245 + struct acl_object_label *currobj;
59246 +
59247 + if (unlikely(!(gr_status & GR_READY)))
59248 + return (mode & ~GR_AUDITS);
59249 +
59250 + curracl = current->acl;
59251 +
59252 + currobj = chk_obj_label(dentry, mnt, curracl);
59253 + retval = currobj->mode & mode;
59254 +
59255 + /* if we're opening a specified transfer file for writing
59256 + (e.g. /dev/initctl), then transfer our role to init
59257 + */
59258 + if (unlikely(currobj->mode & GR_INIT_TRANSFER && retval & GR_WRITE &&
59259 + current->role->roletype & GR_ROLE_PERSIST)) {
59260 + struct task_struct *task = init_pid_ns.child_reaper;
59261 +
59262 + if (task->role != current->role) {
59263 + task->acl_sp_role = 0;
59264 + task->acl_role_id = current->acl_role_id;
59265 + task->role = current->role;
59266 + rcu_read_lock();
59267 + read_lock(&grsec_exec_file_lock);
59268 + gr_apply_subject_to_task(task);
59269 + read_unlock(&grsec_exec_file_lock);
59270 + rcu_read_unlock();
59271 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_INIT_TRANSFER_MSG);
59272 + }
59273 + }
59274 +
59275 + if (unlikely
59276 + ((curracl->mode & (GR_LEARN | GR_INHERITLEARN)) && !(mode & GR_NOPTRACE)
59277 + && (retval != (mode & ~(GR_AUDITS | GR_SUPPRESS))))) {
59278 + __u32 new_mode = mode;
59279 +
59280 + new_mode &= ~(GR_AUDITS | GR_SUPPRESS);
59281 +
59282 + retval = new_mode;
59283 +
59284 + if (new_mode & GR_EXEC && curracl->mode & GR_INHERITLEARN)
59285 + new_mode |= GR_INHERIT;
59286 +
59287 + if (!(mode & GR_NOLEARN))
59288 + gr_log_learn(dentry, mnt, new_mode);
59289 + }
59290 +
59291 + return retval;
59292 +}
59293 +
59294 +struct acl_object_label *gr_get_create_object(const struct dentry *new_dentry,
59295 + const struct dentry *parent,
59296 + const struct vfsmount *mnt)
59297 +{
59298 + struct name_entry *match;
59299 + struct acl_object_label *matchpo;
59300 + struct acl_subject_label *curracl;
59301 + char *path;
59302 +
59303 + if (unlikely(!(gr_status & GR_READY)))
59304 + return NULL;
59305 +
59306 + preempt_disable();
59307 + path = gr_to_filename_rbac(new_dentry, mnt);
59308 + match = lookup_name_entry_create(path);
59309 +
59310 + curracl = current->acl;
59311 +
59312 + if (match) {
59313 + read_lock(&gr_inode_lock);
59314 + matchpo = lookup_acl_obj_label_create(match->inode, match->device, curracl);
59315 + read_unlock(&gr_inode_lock);
59316 +
59317 + if (matchpo) {
59318 + preempt_enable();
59319 + return matchpo;
59320 + }
59321 + }
59322 +
59323 + // lookup parent
59324 +
59325 + matchpo = chk_obj_create_label(parent, mnt, curracl, path);
59326 +
59327 + preempt_enable();
59328 + return matchpo;
59329 +}
59330 +
59331 +__u32
59332 +gr_check_create(const struct dentry * new_dentry, const struct dentry * parent,
59333 + const struct vfsmount * mnt, const __u32 mode)
59334 +{
59335 + struct acl_object_label *matchpo;
59336 + __u32 retval;
59337 +
59338 + if (unlikely(!(gr_status & GR_READY)))
59339 + return (mode & ~GR_AUDITS);
59340 +
59341 + matchpo = gr_get_create_object(new_dentry, parent, mnt);
59342 +
59343 + retval = matchpo->mode & mode;
59344 +
59345 + if ((retval != (mode & ~(GR_AUDITS | GR_SUPPRESS)))
59346 + && (current->acl->mode & (GR_LEARN | GR_INHERITLEARN))) {
59347 + __u32 new_mode = mode;
59348 +
59349 + new_mode &= ~(GR_AUDITS | GR_SUPPRESS);
59350 +
59351 + gr_log_learn(new_dentry, mnt, new_mode);
59352 + return new_mode;
59353 + }
59354 +
59355 + return retval;
59356 +}
59357 +
59358 +__u32
59359 +gr_check_link(const struct dentry * new_dentry,
59360 + const struct dentry * parent_dentry,
59361 + const struct vfsmount * parent_mnt,
59362 + const struct dentry * old_dentry, const struct vfsmount * old_mnt)
59363 +{
59364 + struct acl_object_label *obj;
59365 + __u32 oldmode, newmode;
59366 + __u32 needmode;
59367 + __u32 checkmodes = GR_FIND | GR_APPEND | GR_WRITE | GR_EXEC | GR_SETID | GR_READ |
59368 + GR_DELETE | GR_INHERIT;
59369 +
59370 + if (unlikely(!(gr_status & GR_READY)))
59371 + return (GR_CREATE | GR_LINK);
59372 +
59373 + obj = chk_obj_label(old_dentry, old_mnt, current->acl);
59374 + oldmode = obj->mode;
59375 +
59376 + obj = gr_get_create_object(new_dentry, parent_dentry, parent_mnt);
59377 + newmode = obj->mode;
59378 +
59379 + needmode = newmode & checkmodes;
59380 +
59381 + // old name for hardlink must have at least the permissions of the new name
59382 + if ((oldmode & needmode) != needmode)
59383 + goto bad;
59384 +
59385 + // if old name had restrictions/auditing, make sure the new name does as well
59386 + needmode = oldmode & (GR_NOPTRACE | GR_PTRACERD | GR_INHERIT | GR_AUDITS);
59387 +
59388 + // don't allow hardlinking of suid/sgid/fcapped files without permission
59389 + if (is_privileged_binary(old_dentry))
59390 + needmode |= GR_SETID;
59391 +
59392 + if ((newmode & needmode) != needmode)
59393 + goto bad;
59394 +
59395 + // enforce minimum permissions
59396 + if ((newmode & (GR_CREATE | GR_LINK)) == (GR_CREATE | GR_LINK))
59397 + return newmode;
59398 +bad:
59399 + needmode = oldmode;
59400 + if (is_privileged_binary(old_dentry))
59401 + needmode |= GR_SETID;
59402 +
59403 + if (current->acl->mode & (GR_LEARN | GR_INHERITLEARN)) {
59404 + gr_log_learn(old_dentry, old_mnt, needmode | GR_CREATE | GR_LINK);
59405 + return (GR_CREATE | GR_LINK);
59406 + } else if (newmode & GR_SUPPRESS)
59407 + return GR_SUPPRESS;
59408 + else
59409 + return 0;
59410 +}
59411 +
59412 +int
59413 +gr_check_hidden_task(const struct task_struct *task)
59414 +{
59415 + if (unlikely(!(gr_status & GR_READY)))
59416 + return 0;
59417 +
59418 + if (!(task->acl->mode & GR_PROCFIND) && !(current->acl->mode & GR_VIEW))
59419 + return 1;
59420 +
59421 + return 0;
59422 +}
59423 +
59424 +int
59425 +gr_check_protected_task(const struct task_struct *task)
59426 +{
59427 + if (unlikely(!(gr_status & GR_READY) || !task))
59428 + return 0;
59429 +
59430 + if ((task->acl->mode & GR_PROTECTED) && !(current->acl->mode & GR_KILL) &&
59431 + task->acl != current->acl)
59432 + return 1;
59433 +
59434 + return 0;
59435 +}
59436 +
59437 +int
59438 +gr_check_protected_task_fowner(struct pid *pid, enum pid_type type)
59439 +{
59440 + struct task_struct *p;
59441 + int ret = 0;
59442 +
59443 + if (unlikely(!(gr_status & GR_READY) || !pid))
59444 + return ret;
59445 +
59446 + read_lock(&tasklist_lock);
59447 + do_each_pid_task(pid, type, p) {
59448 + if ((p->acl->mode & GR_PROTECTED) && !(current->acl->mode & GR_KILL) &&
59449 + p->acl != current->acl) {
59450 + ret = 1;
59451 + goto out;
59452 + }
59453 + } while_each_pid_task(pid, type, p);
59454 +out:
59455 + read_unlock(&tasklist_lock);
59456 +
59457 + return ret;
59458 +}
59459 +
59460 +void
59461 +gr_copy_label(struct task_struct *tsk)
59462 +{
59463 + tsk->signal->used_accept = 0;
59464 + tsk->acl_sp_role = 0;
59465 + tsk->acl_role_id = current->acl_role_id;
59466 + tsk->acl = current->acl;
59467 + tsk->role = current->role;
59468 + tsk->signal->curr_ip = current->signal->curr_ip;
59469 + tsk->signal->saved_ip = current->signal->saved_ip;
59470 + if (current->exec_file)
59471 + get_file(current->exec_file);
59472 + tsk->exec_file = current->exec_file;
59473 + tsk->is_writable = current->is_writable;
59474 + if (unlikely(current->signal->used_accept)) {
59475 + current->signal->curr_ip = 0;
59476 + current->signal->saved_ip = 0;
59477 + }
59478 +
59479 + return;
59480 +}
59481 +
59482 +static void
59483 +gr_set_proc_res(struct task_struct *task)
59484 +{
59485 + struct acl_subject_label *proc;
59486 + unsigned short i;
59487 +
59488 + proc = task->acl;
59489 +
59490 + if (proc->mode & (GR_LEARN | GR_INHERITLEARN))
59491 + return;
59492 +
59493 + for (i = 0; i < RLIM_NLIMITS; i++) {
59494 + if (!(proc->resmask & (1 << i)))
59495 + continue;
59496 +
59497 + task->signal->rlim[i].rlim_cur = proc->res[i].rlim_cur;
59498 + task->signal->rlim[i].rlim_max = proc->res[i].rlim_max;
59499 +
59500 + if (i == RLIMIT_CPU)
59501 + update_rlimit_cpu(task, proc->res[i].rlim_cur);
59502 + }
59503 +
59504 + return;
59505 +}
59506 +
59507 +extern int __gr_process_user_ban(struct user_struct *user);
59508 +
59509 +int
59510 +gr_check_user_change(kuid_t real, kuid_t effective, kuid_t fs)
59511 +{
59512 + unsigned int i;
59513 + __u16 num;
59514 + uid_t *uidlist;
59515 + uid_t curuid;
59516 + int realok = 0;
59517 + int effectiveok = 0;
59518 + int fsok = 0;
59519 + uid_t globalreal, globaleffective, globalfs;
59520 +
59521 +#if defined(CONFIG_GRKERNSEC_KERN_LOCKOUT) || defined(CONFIG_GRKERNSEC_BRUTE)
59522 + struct user_struct *user;
59523 +
59524 + if (!uid_valid(real))
59525 + goto skipit;
59526 +
59527 + /* find user based on global namespace */
59528 +
59529 + globalreal = GR_GLOBAL_UID(real);
59530 +
59531 + user = find_user(make_kuid(&init_user_ns, globalreal));
59532 + if (user == NULL)
59533 + goto skipit;
59534 +
59535 + if (__gr_process_user_ban(user)) {
59536 + /* for find_user */
59537 + free_uid(user);
59538 + return 1;
59539 + }
59540 +
59541 + /* for find_user */
59542 + free_uid(user);
59543 +
59544 +skipit:
59545 +#endif
59546 +
59547 + if (unlikely(!(gr_status & GR_READY)))
59548 + return 0;
59549 +
59550 + if (current->acl->mode & (GR_LEARN | GR_INHERITLEARN))
59551 + gr_log_learn_uid_change(real, effective, fs);
59552 +
59553 + num = current->acl->user_trans_num;
59554 + uidlist = current->acl->user_transitions;
59555 +
59556 + if (uidlist == NULL)
59557 + return 0;
59558 +
59559 + if (!uid_valid(real)) {
59560 + realok = 1;
59561 + globalreal = (uid_t)-1;
59562 + } else {
59563 + globalreal = GR_GLOBAL_UID(real);
59564 + }
59565 + if (!uid_valid(effective)) {
59566 + effectiveok = 1;
59567 + globaleffective = (uid_t)-1;
59568 + } else {
59569 + globaleffective = GR_GLOBAL_UID(effective);
59570 + }
59571 + if (!uid_valid(fs)) {
59572 + fsok = 1;
59573 + globalfs = (uid_t)-1;
59574 + } else {
59575 + globalfs = GR_GLOBAL_UID(fs);
59576 + }
59577 +
59578 + if (current->acl->user_trans_type & GR_ID_ALLOW) {
59579 + for (i = 0; i < num; i++) {
59580 + curuid = uidlist[i];
59581 + if (globalreal == curuid)
59582 + realok = 1;
59583 + if (globaleffective == curuid)
59584 + effectiveok = 1;
59585 + if (globalfs == curuid)
59586 + fsok = 1;
59587 + }
59588 + } else if (current->acl->user_trans_type & GR_ID_DENY) {
59589 + for (i = 0; i < num; i++) {
59590 + curuid = uidlist[i];
59591 + if (globalreal == curuid)
59592 + break;
59593 + if (globaleffective == curuid)
59594 + break;
59595 + if (globalfs == curuid)
59596 + break;
59597 + }
59598 + /* not in deny list */
59599 + if (i == num) {
59600 + realok = 1;
59601 + effectiveok = 1;
59602 + fsok = 1;
59603 + }
59604 + }
59605 +
59606 + if (realok && effectiveok && fsok)
59607 + return 0;
59608 + else {
59609 + gr_log_int(GR_DONT_AUDIT, GR_USRCHANGE_ACL_MSG, realok ? (effectiveok ? (fsok ? 0 : globalfs) : globaleffective) : globalreal);
59610 + return 1;
59611 + }
59612 +}
59613 +
59614 +int
59615 +gr_check_group_change(kgid_t real, kgid_t effective, kgid_t fs)
59616 +{
59617 + unsigned int i;
59618 + __u16 num;
59619 + gid_t *gidlist;
59620 + gid_t curgid;
59621 + int realok = 0;
59622 + int effectiveok = 0;
59623 + int fsok = 0;
59624 + gid_t globalreal, globaleffective, globalfs;
59625 +
59626 + if (unlikely(!(gr_status & GR_READY)))
59627 + return 0;
59628 +
59629 + if (current->acl->mode & (GR_LEARN | GR_INHERITLEARN))
59630 + gr_log_learn_gid_change(real, effective, fs);
59631 +
59632 + num = current->acl->group_trans_num;
59633 + gidlist = current->acl->group_transitions;
59634 +
59635 + if (gidlist == NULL)
59636 + return 0;
59637 +
59638 + if (!gid_valid(real)) {
59639 + realok = 1;
59640 + globalreal = (gid_t)-1;
59641 + } else {
59642 + globalreal = GR_GLOBAL_GID(real);
59643 + }
59644 + if (!gid_valid(effective)) {
59645 + effectiveok = 1;
59646 + globaleffective = (gid_t)-1;
59647 + } else {
59648 + globaleffective = GR_GLOBAL_GID(effective);
59649 + }
59650 + if (!gid_valid(fs)) {
59651 + fsok = 1;
59652 + globalfs = (gid_t)-1;
59653 + } else {
59654 + globalfs = GR_GLOBAL_GID(fs);
59655 + }
59656 +
59657 + if (current->acl->group_trans_type & GR_ID_ALLOW) {
59658 + for (i = 0; i < num; i++) {
59659 + curgid = gidlist[i];
59660 + if (globalreal == curgid)
59661 + realok = 1;
59662 + if (globaleffective == curgid)
59663 + effectiveok = 1;
59664 + if (globalfs == curgid)
59665 + fsok = 1;
59666 + }
59667 + } else if (current->acl->group_trans_type & GR_ID_DENY) {
59668 + for (i = 0; i < num; i++) {
59669 + curgid = gidlist[i];
59670 + if (globalreal == curgid)
59671 + break;
59672 + if (globaleffective == curgid)
59673 + break;
59674 + if (globalfs == curgid)
59675 + break;
59676 + }
59677 + /* not in deny list */
59678 + if (i == num) {
59679 + realok = 1;
59680 + effectiveok = 1;
59681 + fsok = 1;
59682 + }
59683 + }
59684 +
59685 + if (realok && effectiveok && fsok)
59686 + return 0;
59687 + else {
59688 + gr_log_int(GR_DONT_AUDIT, GR_GRPCHANGE_ACL_MSG, realok ? (effectiveok ? (fsok ? 0 : globalfs) : globaleffective) : globalreal);
59689 + return 1;
59690 + }
59691 +}
59692 +
59693 +extern int gr_acl_is_capable(const int cap);
59694 +
59695 +void
59696 +gr_set_role_label(struct task_struct *task, const kuid_t kuid, const kgid_t kgid)
59697 +{
59698 + struct acl_role_label *role = task->role;
59699 + struct acl_subject_label *subj = NULL;
59700 + struct acl_object_label *obj;
59701 + struct file *filp;
59702 + uid_t uid;
59703 + gid_t gid;
59704 +
59705 + if (unlikely(!(gr_status & GR_READY)))
59706 + return;
59707 +
59708 + uid = GR_GLOBAL_UID(kuid);
59709 + gid = GR_GLOBAL_GID(kgid);
59710 +
59711 + filp = task->exec_file;
59712 +
59713 + /* kernel process, we'll give them the kernel role */
59714 + if (unlikely(!filp)) {
59715 + task->role = kernel_role;
59716 + task->acl = kernel_role->root_label;
59717 + return;
59718 + } else if (!task->role || !(task->role->roletype & GR_ROLE_SPECIAL))
59719 + role = lookup_acl_role_label(task, uid, gid);
59720 +
59721 + /* don't change the role if we're not a privileged process */
59722 + if (role && task->role != role &&
59723 + (((role->roletype & GR_ROLE_USER) && !gr_acl_is_capable(CAP_SETUID)) ||
59724 + ((role->roletype & GR_ROLE_GROUP) && !gr_acl_is_capable(CAP_SETGID))))
59725 + return;
59726 +
59727 + /* perform subject lookup in possibly new role
59728 + we can use this result below in the case where role == task->role
59729 + */
59730 + subj = chk_subj_label(filp->f_path.dentry, filp->f_path.mnt, role);
59731 +
59732 + /* if we changed uid/gid, but result in the same role
59733 + and are using inheritance, don't lose the inherited subject
59734 + if current subject is other than what normal lookup
59735 + would result in, we arrived via inheritance, don't
59736 + lose subject
59737 + */
59738 + if (role != task->role || (!(task->acl->mode & GR_INHERITLEARN) &&
59739 + (subj == task->acl)))
59740 + task->acl = subj;
59741 +
59742 + task->role = role;
59743 +
59744 + task->is_writable = 0;
59745 +
59746 + /* ignore additional mmap checks for processes that are writable
59747 + by the default ACL */
59748 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, default_role->root_label);
59749 + if (unlikely(obj->mode & GR_WRITE))
59750 + task->is_writable = 1;
59751 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, task->role->root_label);
59752 + if (unlikely(obj->mode & GR_WRITE))
59753 + task->is_writable = 1;
59754 +
59755 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
59756 + 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);
59757 +#endif
59758 +
59759 + gr_set_proc_res(task);
59760 +
59761 + return;
59762 +}
59763 +
59764 +int
59765 +gr_set_proc_label(const struct dentry *dentry, const struct vfsmount *mnt,
59766 + const int unsafe_flags)
59767 +{
59768 + struct task_struct *task = current;
59769 + struct acl_subject_label *newacl;
59770 + struct acl_object_label *obj;
59771 + __u32 retmode;
59772 +
59773 + if (unlikely(!(gr_status & GR_READY)))
59774 + return 0;
59775 +
59776 + newacl = chk_subj_label(dentry, mnt, task->role);
59777 +
59778 + /* special handling for if we did an strace -f -p <pid> from an admin role, where pid then
59779 + did an exec
59780 + */
59781 + rcu_read_lock();
59782 + read_lock(&tasklist_lock);
59783 + if (task->ptrace && task->parent && ((task->parent->role->roletype & GR_ROLE_GOD) ||
59784 + (task->parent->acl->mode & GR_POVERRIDE))) {
59785 + read_unlock(&tasklist_lock);
59786 + rcu_read_unlock();
59787 + goto skip_check;
59788 + }
59789 + read_unlock(&tasklist_lock);
59790 + rcu_read_unlock();
59791 +
59792 + if (unsafe_flags && !(task->acl->mode & GR_POVERRIDE) && (task->acl != newacl) &&
59793 + !(task->role->roletype & GR_ROLE_GOD) &&
59794 + !gr_search_file(dentry, GR_PTRACERD, mnt) &&
59795 + !(task->acl->mode & (GR_LEARN | GR_INHERITLEARN))) {
59796 + if (unsafe_flags & LSM_UNSAFE_SHARE)
59797 + gr_log_fs_generic(GR_DONT_AUDIT, GR_UNSAFESHARE_EXEC_ACL_MSG, dentry, mnt);
59798 + else
59799 + gr_log_fs_generic(GR_DONT_AUDIT, GR_PTRACE_EXEC_ACL_MSG, dentry, mnt);
59800 + return -EACCES;
59801 + }
59802 +
59803 +skip_check:
59804 +
59805 + obj = chk_obj_label(dentry, mnt, task->acl);
59806 + retmode = obj->mode & (GR_INHERIT | GR_AUDIT_INHERIT);
59807 +
59808 + if (!(task->acl->mode & GR_INHERITLEARN) &&
59809 + ((newacl->mode & GR_LEARN) || !(retmode & GR_INHERIT))) {
59810 + if (obj->nested)
59811 + task->acl = obj->nested;
59812 + else
59813 + task->acl = newacl;
59814 + } else if (retmode & GR_INHERIT && retmode & GR_AUDIT_INHERIT)
59815 + gr_log_str_fs(GR_DO_AUDIT, GR_INHERIT_ACL_MSG, task->acl->filename, dentry, mnt);
59816 +
59817 + task->is_writable = 0;
59818 +
59819 + /* ignore additional mmap checks for processes that are writable
59820 + by the default ACL */
59821 + obj = chk_obj_label(dentry, mnt, default_role->root_label);
59822 + if (unlikely(obj->mode & GR_WRITE))
59823 + task->is_writable = 1;
59824 + obj = chk_obj_label(dentry, mnt, task->role->root_label);
59825 + if (unlikely(obj->mode & GR_WRITE))
59826 + task->is_writable = 1;
59827 +
59828 + gr_set_proc_res(task);
59829 +
59830 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
59831 + 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);
59832 +#endif
59833 + return 0;
59834 +}
59835 +
59836 +/* always called with valid inodev ptr */
59837 +static void
59838 +do_handle_delete(struct inodev_entry *inodev, const ino_t ino, const dev_t dev)
59839 +{
59840 + struct acl_object_label *matchpo;
59841 + struct acl_subject_label *matchps;
59842 + struct acl_subject_label *subj;
59843 + struct acl_role_label *role;
59844 + unsigned int x;
59845 +
59846 + FOR_EACH_ROLE_START(role)
59847 + FOR_EACH_SUBJECT_START(role, subj, x)
59848 + if ((matchpo = lookup_acl_obj_label(ino, dev, subj)) != NULL)
59849 + matchpo->mode |= GR_DELETED;
59850 + FOR_EACH_SUBJECT_END(subj,x)
59851 + FOR_EACH_NESTED_SUBJECT_START(role, subj)
59852 + /* nested subjects aren't in the role's subj_hash table */
59853 + if ((matchpo = lookup_acl_obj_label(ino, dev, subj)) != NULL)
59854 + matchpo->mode |= GR_DELETED;
59855 + FOR_EACH_NESTED_SUBJECT_END(subj)
59856 + if ((matchps = lookup_acl_subj_label(ino, dev, role)) != NULL)
59857 + matchps->mode |= GR_DELETED;
59858 + FOR_EACH_ROLE_END(role)
59859 +
59860 + inodev->nentry->deleted = 1;
59861 +
59862 + return;
59863 +}
59864 +
59865 +void
59866 +gr_handle_delete(const ino_t ino, const dev_t dev)
59867 +{
59868 + struct inodev_entry *inodev;
59869 +
59870 + if (unlikely(!(gr_status & GR_READY)))
59871 + return;
59872 +
59873 + write_lock(&gr_inode_lock);
59874 + inodev = lookup_inodev_entry(ino, dev);
59875 + if (inodev != NULL)
59876 + do_handle_delete(inodev, ino, dev);
59877 + write_unlock(&gr_inode_lock);
59878 +
59879 + return;
59880 +}
59881 +
59882 +static void
59883 +update_acl_obj_label(const ino_t oldinode, const dev_t olddevice,
59884 + const ino_t newinode, const dev_t newdevice,
59885 + struct acl_subject_label *subj)
59886 +{
59887 + unsigned int index = gr_fhash(oldinode, olddevice, subj->obj_hash_size);
59888 + struct acl_object_label *match;
59889 +
59890 + match = subj->obj_hash[index];
59891 +
59892 + while (match && (match->inode != oldinode ||
59893 + match->device != olddevice ||
59894 + !(match->mode & GR_DELETED)))
59895 + match = match->next;
59896 +
59897 + if (match && (match->inode == oldinode)
59898 + && (match->device == olddevice)
59899 + && (match->mode & GR_DELETED)) {
59900 + if (match->prev == NULL) {
59901 + subj->obj_hash[index] = match->next;
59902 + if (match->next != NULL)
59903 + match->next->prev = NULL;
59904 + } else {
59905 + match->prev->next = match->next;
59906 + if (match->next != NULL)
59907 + match->next->prev = match->prev;
59908 + }
59909 + match->prev = NULL;
59910 + match->next = NULL;
59911 + match->inode = newinode;
59912 + match->device = newdevice;
59913 + match->mode &= ~GR_DELETED;
59914 +
59915 + insert_acl_obj_label(match, subj);
59916 + }
59917 +
59918 + return;
59919 +}
59920 +
59921 +static void
59922 +update_acl_subj_label(const ino_t oldinode, const dev_t olddevice,
59923 + const ino_t newinode, const dev_t newdevice,
59924 + struct acl_role_label *role)
59925 +{
59926 + unsigned int index = gr_fhash(oldinode, olddevice, role->subj_hash_size);
59927 + struct acl_subject_label *match;
59928 +
59929 + match = role->subj_hash[index];
59930 +
59931 + while (match && (match->inode != oldinode ||
59932 + match->device != olddevice ||
59933 + !(match->mode & GR_DELETED)))
59934 + match = match->next;
59935 +
59936 + if (match && (match->inode == oldinode)
59937 + && (match->device == olddevice)
59938 + && (match->mode & GR_DELETED)) {
59939 + if (match->prev == NULL) {
59940 + role->subj_hash[index] = match->next;
59941 + if (match->next != NULL)
59942 + match->next->prev = NULL;
59943 + } else {
59944 + match->prev->next = match->next;
59945 + if (match->next != NULL)
59946 + match->next->prev = match->prev;
59947 + }
59948 + match->prev = NULL;
59949 + match->next = NULL;
59950 + match->inode = newinode;
59951 + match->device = newdevice;
59952 + match->mode &= ~GR_DELETED;
59953 +
59954 + insert_acl_subj_label(match, role);
59955 + }
59956 +
59957 + return;
59958 +}
59959 +
59960 +static void
59961 +update_inodev_entry(const ino_t oldinode, const dev_t olddevice,
59962 + const ino_t newinode, const dev_t newdevice)
59963 +{
59964 + unsigned int index = gr_fhash(oldinode, olddevice, inodev_set.i_size);
59965 + struct inodev_entry *match;
59966 +
59967 + match = inodev_set.i_hash[index];
59968 +
59969 + while (match && (match->nentry->inode != oldinode ||
59970 + match->nentry->device != olddevice || !match->nentry->deleted))
59971 + match = match->next;
59972 +
59973 + if (match && (match->nentry->inode == oldinode)
59974 + && (match->nentry->device == olddevice) &&
59975 + match->nentry->deleted) {
59976 + if (match->prev == NULL) {
59977 + inodev_set.i_hash[index] = match->next;
59978 + if (match->next != NULL)
59979 + match->next->prev = NULL;
59980 + } else {
59981 + match->prev->next = match->next;
59982 + if (match->next != NULL)
59983 + match->next->prev = match->prev;
59984 + }
59985 + match->prev = NULL;
59986 + match->next = NULL;
59987 + match->nentry->inode = newinode;
59988 + match->nentry->device = newdevice;
59989 + match->nentry->deleted = 0;
59990 +
59991 + insert_inodev_entry(match);
59992 + }
59993 +
59994 + return;
59995 +}
59996 +
59997 +static void
59998 +__do_handle_create(const struct name_entry *matchn, ino_t ino, dev_t dev)
59999 +{
60000 + struct acl_subject_label *subj;
60001 + struct acl_role_label *role;
60002 + unsigned int x;
60003 +
60004 + FOR_EACH_ROLE_START(role)
60005 + update_acl_subj_label(matchn->inode, matchn->device, ino, dev, role);
60006 +
60007 + FOR_EACH_NESTED_SUBJECT_START(role, subj)
60008 + if ((subj->inode == ino) && (subj->device == dev)) {
60009 + subj->inode = ino;
60010 + subj->device = dev;
60011 + }
60012 + /* nested subjects aren't in the role's subj_hash table */
60013 + update_acl_obj_label(matchn->inode, matchn->device,
60014 + ino, dev, subj);
60015 + FOR_EACH_NESTED_SUBJECT_END(subj)
60016 + FOR_EACH_SUBJECT_START(role, subj, x)
60017 + update_acl_obj_label(matchn->inode, matchn->device,
60018 + ino, dev, subj);
60019 + FOR_EACH_SUBJECT_END(subj,x)
60020 + FOR_EACH_ROLE_END(role)
60021 +
60022 + update_inodev_entry(matchn->inode, matchn->device, ino, dev);
60023 +
60024 + return;
60025 +}
60026 +
60027 +static void
60028 +do_handle_create(const struct name_entry *matchn, const struct dentry *dentry,
60029 + const struct vfsmount *mnt)
60030 +{
60031 + ino_t ino = dentry->d_inode->i_ino;
60032 + dev_t dev = __get_dev(dentry);
60033 +
60034 + __do_handle_create(matchn, ino, dev);
60035 +
60036 + return;
60037 +}
60038 +
60039 +void
60040 +gr_handle_create(const struct dentry *dentry, const struct vfsmount *mnt)
60041 +{
60042 + struct name_entry *matchn;
60043 +
60044 + if (unlikely(!(gr_status & GR_READY)))
60045 + return;
60046 +
60047 + preempt_disable();
60048 + matchn = lookup_name_entry(gr_to_filename_rbac(dentry, mnt));
60049 +
60050 + if (unlikely((unsigned long)matchn)) {
60051 + write_lock(&gr_inode_lock);
60052 + do_handle_create(matchn, dentry, mnt);
60053 + write_unlock(&gr_inode_lock);
60054 + }
60055 + preempt_enable();
60056 +
60057 + return;
60058 +}
60059 +
60060 +void
60061 +gr_handle_proc_create(const struct dentry *dentry, const struct inode *inode)
60062 +{
60063 + struct name_entry *matchn;
60064 +
60065 + if (unlikely(!(gr_status & GR_READY)))
60066 + return;
60067 +
60068 + preempt_disable();
60069 + matchn = lookup_name_entry(gr_to_proc_filename_rbac(dentry, init_pid_ns.proc_mnt));
60070 +
60071 + if (unlikely((unsigned long)matchn)) {
60072 + write_lock(&gr_inode_lock);
60073 + __do_handle_create(matchn, inode->i_ino, inode->i_sb->s_dev);
60074 + write_unlock(&gr_inode_lock);
60075 + }
60076 + preempt_enable();
60077 +
60078 + return;
60079 +}
60080 +
60081 +void
60082 +gr_handle_rename(struct inode *old_dir, struct inode *new_dir,
60083 + struct dentry *old_dentry,
60084 + struct dentry *new_dentry,
60085 + struct vfsmount *mnt, const __u8 replace)
60086 +{
60087 + struct name_entry *matchn;
60088 + struct inodev_entry *inodev;
60089 + struct inode *inode = new_dentry->d_inode;
60090 + ino_t old_ino = old_dentry->d_inode->i_ino;
60091 + dev_t old_dev = __get_dev(old_dentry);
60092 +
60093 + /* vfs_rename swaps the name and parent link for old_dentry and
60094 + new_dentry
60095 + at this point, old_dentry has the new name, parent link, and inode
60096 + for the renamed file
60097 + if a file is being replaced by a rename, new_dentry has the inode
60098 + and name for the replaced file
60099 + */
60100 +
60101 + if (unlikely(!(gr_status & GR_READY)))
60102 + return;
60103 +
60104 + preempt_disable();
60105 + matchn = lookup_name_entry(gr_to_filename_rbac(old_dentry, mnt));
60106 +
60107 + /* we wouldn't have to check d_inode if it weren't for
60108 + NFS silly-renaming
60109 + */
60110 +
60111 + write_lock(&gr_inode_lock);
60112 + if (unlikely(replace && inode)) {
60113 + ino_t new_ino = inode->i_ino;
60114 + dev_t new_dev = __get_dev(new_dentry);
60115 +
60116 + inodev = lookup_inodev_entry(new_ino, new_dev);
60117 + if (inodev != NULL && ((inode->i_nlink <= 1) || S_ISDIR(inode->i_mode)))
60118 + do_handle_delete(inodev, new_ino, new_dev);
60119 + }
60120 +
60121 + inodev = lookup_inodev_entry(old_ino, old_dev);
60122 + if (inodev != NULL && ((old_dentry->d_inode->i_nlink <= 1) || S_ISDIR(old_dentry->d_inode->i_mode)))
60123 + do_handle_delete(inodev, old_ino, old_dev);
60124 +
60125 + if (unlikely((unsigned long)matchn))
60126 + do_handle_create(matchn, old_dentry, mnt);
60127 +
60128 + write_unlock(&gr_inode_lock);
60129 + preempt_enable();
60130 +
60131 + return;
60132 +}
60133 +
60134 +static int
60135 +lookup_special_role_auth(__u16 mode, const char *rolename, unsigned char **salt,
60136 + unsigned char **sum)
60137 +{
60138 + struct acl_role_label *r;
60139 + struct role_allowed_ip *ipp;
60140 + struct role_transition *trans;
60141 + unsigned int i;
60142 + int found = 0;
60143 + u32 curr_ip = current->signal->curr_ip;
60144 +
60145 + current->signal->saved_ip = curr_ip;
60146 +
60147 + /* check transition table */
60148 +
60149 + for (trans = current->role->transitions; trans; trans = trans->next) {
60150 + if (!strcmp(rolename, trans->rolename)) {
60151 + found = 1;
60152 + break;
60153 + }
60154 + }
60155 +
60156 + if (!found)
60157 + return 0;
60158 +
60159 + /* handle special roles that do not require authentication
60160 + and check ip */
60161 +
60162 + FOR_EACH_ROLE_START(r)
60163 + if (!strcmp(rolename, r->rolename) &&
60164 + (r->roletype & GR_ROLE_SPECIAL)) {
60165 + found = 0;
60166 + if (r->allowed_ips != NULL) {
60167 + for (ipp = r->allowed_ips; ipp; ipp = ipp->next) {
60168 + if ((ntohl(curr_ip) & ipp->netmask) ==
60169 + (ntohl(ipp->addr) & ipp->netmask))
60170 + found = 1;
60171 + }
60172 + } else
60173 + found = 2;
60174 + if (!found)
60175 + return 0;
60176 +
60177 + if (((mode == GR_SPROLE) && (r->roletype & GR_ROLE_NOPW)) ||
60178 + ((mode == GR_SPROLEPAM) && (r->roletype & GR_ROLE_PAM))) {
60179 + *salt = NULL;
60180 + *sum = NULL;
60181 + return 1;
60182 + }
60183 + }
60184 + FOR_EACH_ROLE_END(r)
60185 +
60186 + for (i = 0; i < num_sprole_pws; i++) {
60187 + if (!strcmp(rolename, acl_special_roles[i]->rolename)) {
60188 + *salt = acl_special_roles[i]->salt;
60189 + *sum = acl_special_roles[i]->sum;
60190 + return 1;
60191 + }
60192 + }
60193 +
60194 + return 0;
60195 +}
60196 +
60197 +static void
60198 +assign_special_role(char *rolename)
60199 +{
60200 + struct acl_object_label *obj;
60201 + struct acl_role_label *r;
60202 + struct acl_role_label *assigned = NULL;
60203 + struct task_struct *tsk;
60204 + struct file *filp;
60205 +
60206 + FOR_EACH_ROLE_START(r)
60207 + if (!strcmp(rolename, r->rolename) &&
60208 + (r->roletype & GR_ROLE_SPECIAL)) {
60209 + assigned = r;
60210 + break;
60211 + }
60212 + FOR_EACH_ROLE_END(r)
60213 +
60214 + if (!assigned)
60215 + return;
60216 +
60217 + read_lock(&tasklist_lock);
60218 + read_lock(&grsec_exec_file_lock);
60219 +
60220 + tsk = current->real_parent;
60221 + if (tsk == NULL)
60222 + goto out_unlock;
60223 +
60224 + filp = tsk->exec_file;
60225 + if (filp == NULL)
60226 + goto out_unlock;
60227 +
60228 + tsk->is_writable = 0;
60229 +
60230 + tsk->acl_sp_role = 1;
60231 + tsk->acl_role_id = ++acl_sp_role_value;
60232 + tsk->role = assigned;
60233 + tsk->acl = chk_subj_label(filp->f_path.dentry, filp->f_path.mnt, tsk->role);
60234 +
60235 + /* ignore additional mmap checks for processes that are writable
60236 + by the default ACL */
60237 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, default_role->root_label);
60238 + if (unlikely(obj->mode & GR_WRITE))
60239 + tsk->is_writable = 1;
60240 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, tsk->role->root_label);
60241 + if (unlikely(obj->mode & GR_WRITE))
60242 + tsk->is_writable = 1;
60243 +
60244 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
60245 + 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));
60246 +#endif
60247 +
60248 +out_unlock:
60249 + read_unlock(&grsec_exec_file_lock);
60250 + read_unlock(&tasklist_lock);
60251 + return;
60252 +}
60253 +
60254 +int gr_check_secure_terminal(struct task_struct *task)
60255 +{
60256 + struct task_struct *p, *p2, *p3;
60257 + struct files_struct *files;
60258 + struct fdtable *fdt;
60259 + struct file *our_file = NULL, *file;
60260 + int i;
60261 +
60262 + if (task->signal->tty == NULL)
60263 + return 1;
60264 +
60265 + files = get_files_struct(task);
60266 + if (files != NULL) {
60267 + rcu_read_lock();
60268 + fdt = files_fdtable(files);
60269 + for (i=0; i < fdt->max_fds; i++) {
60270 + file = fcheck_files(files, i);
60271 + if (file && (our_file == NULL) && (file->private_data == task->signal->tty)) {
60272 + get_file(file);
60273 + our_file = file;
60274 + }
60275 + }
60276 + rcu_read_unlock();
60277 + put_files_struct(files);
60278 + }
60279 +
60280 + if (our_file == NULL)
60281 + return 1;
60282 +
60283 + read_lock(&tasklist_lock);
60284 + do_each_thread(p2, p) {
60285 + files = get_files_struct(p);
60286 + if (files == NULL ||
60287 + (p->signal && p->signal->tty == task->signal->tty)) {
60288 + if (files != NULL)
60289 + put_files_struct(files);
60290 + continue;
60291 + }
60292 + rcu_read_lock();
60293 + fdt = files_fdtable(files);
60294 + for (i=0; i < fdt->max_fds; i++) {
60295 + file = fcheck_files(files, i);
60296 + if (file && S_ISCHR(file->f_path.dentry->d_inode->i_mode) &&
60297 + file->f_path.dentry->d_inode->i_rdev == our_file->f_path.dentry->d_inode->i_rdev) {
60298 + p3 = task;
60299 + while (task_pid_nr(p3) > 0) {
60300 + if (p3 == p)
60301 + break;
60302 + p3 = p3->real_parent;
60303 + }
60304 + if (p3 == p)
60305 + break;
60306 + gr_log_ttysniff(GR_DONT_AUDIT_GOOD, GR_TTYSNIFF_ACL_MSG, p);
60307 + gr_handle_alertkill(p);
60308 + rcu_read_unlock();
60309 + put_files_struct(files);
60310 + read_unlock(&tasklist_lock);
60311 + fput(our_file);
60312 + return 0;
60313 + }
60314 + }
60315 + rcu_read_unlock();
60316 + put_files_struct(files);
60317 + } while_each_thread(p2, p);
60318 + read_unlock(&tasklist_lock);
60319 +
60320 + fput(our_file);
60321 + return 1;
60322 +}
60323 +
60324 +static int gr_rbac_disable(void *unused)
60325 +{
60326 + pax_open_kernel();
60327 + gr_status &= ~GR_READY;
60328 + pax_close_kernel();
60329 +
60330 + return 0;
60331 +}
60332 +
60333 +ssize_t
60334 +write_grsec_handler(struct file *file, const char * buf, size_t count, loff_t *ppos)
60335 +{
60336 + struct gr_arg_wrapper uwrap;
60337 + unsigned char *sprole_salt = NULL;
60338 + unsigned char *sprole_sum = NULL;
60339 + int error = sizeof (struct gr_arg_wrapper);
60340 + int error2 = 0;
60341 +
60342 + mutex_lock(&gr_dev_mutex);
60343 +
60344 + if ((gr_status & GR_READY) && !(current->acl->mode & GR_KERNELAUTH)) {
60345 + error = -EPERM;
60346 + goto out;
60347 + }
60348 +
60349 + if (count != sizeof (struct gr_arg_wrapper)) {
60350 + gr_log_int_int(GR_DONT_AUDIT_GOOD, GR_DEV_ACL_MSG, (int)count, (int)sizeof(struct gr_arg_wrapper));
60351 + error = -EINVAL;
60352 + goto out;
60353 + }
60354 +
60355 +
60356 + if (gr_auth_expires && time_after_eq(get_seconds(), gr_auth_expires)) {
60357 + gr_auth_expires = 0;
60358 + gr_auth_attempts = 0;
60359 + }
60360 +
60361 + if (copy_from_user(&uwrap, buf, sizeof (struct gr_arg_wrapper))) {
60362 + error = -EFAULT;
60363 + goto out;
60364 + }
60365 +
60366 + if ((uwrap.version != GRSECURITY_VERSION) || (uwrap.size != sizeof(struct gr_arg))) {
60367 + error = -EINVAL;
60368 + goto out;
60369 + }
60370 +
60371 + if (copy_from_user(gr_usermode, uwrap.arg, sizeof (struct gr_arg))) {
60372 + error = -EFAULT;
60373 + goto out;
60374 + }
60375 +
60376 + if (gr_usermode->mode != GR_SPROLE && gr_usermode->mode != GR_SPROLEPAM &&
60377 + gr_auth_attempts >= CONFIG_GRKERNSEC_ACL_MAXTRIES &&
60378 + time_after(gr_auth_expires, get_seconds())) {
60379 + error = -EBUSY;
60380 + goto out;
60381 + }
60382 +
60383 + /* if non-root trying to do anything other than use a special role,
60384 + do not attempt authentication, do not count towards authentication
60385 + locking
60386 + */
60387 +
60388 + if (gr_usermode->mode != GR_SPROLE && gr_usermode->mode != GR_STATUS &&
60389 + gr_usermode->mode != GR_UNSPROLE && gr_usermode->mode != GR_SPROLEPAM &&
60390 + gr_is_global_nonroot(current_uid())) {
60391 + error = -EPERM;
60392 + goto out;
60393 + }
60394 +
60395 + /* ensure pw and special role name are null terminated */
60396 +
60397 + gr_usermode->pw[GR_PW_LEN - 1] = '\0';
60398 + gr_usermode->sp_role[GR_SPROLE_LEN - 1] = '\0';
60399 +
60400 + /* Okay.
60401 + * We have our enough of the argument structure..(we have yet
60402 + * to copy_from_user the tables themselves) . Copy the tables
60403 + * only if we need them, i.e. for loading operations. */
60404 +
60405 + switch (gr_usermode->mode) {
60406 + case GR_STATUS:
60407 + if (gr_status & GR_READY) {
60408 + error = 1;
60409 + if (!gr_check_secure_terminal(current))
60410 + error = 3;
60411 + } else
60412 + error = 2;
60413 + goto out;
60414 + case GR_SHUTDOWN:
60415 + if ((gr_status & GR_READY)
60416 + && !(chkpw(gr_usermode, gr_system_salt, gr_system_sum))) {
60417 + stop_machine(gr_rbac_disable, NULL, NULL);
60418 + free_variables();
60419 + memset(gr_usermode, 0, sizeof (struct gr_arg));
60420 + memset(gr_system_salt, 0, GR_SALT_LEN);
60421 + memset(gr_system_sum, 0, GR_SHA_LEN);
60422 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SHUTS_ACL_MSG);
60423 + } else if (gr_status & GR_READY) {
60424 + gr_log_noargs(GR_DONT_AUDIT, GR_SHUTF_ACL_MSG);
60425 + error = -EPERM;
60426 + } else {
60427 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SHUTI_ACL_MSG);
60428 + error = -EAGAIN;
60429 + }
60430 + break;
60431 + case GR_ENABLE:
60432 + if (!(gr_status & GR_READY) && !(error2 = gracl_init(gr_usermode)))
60433 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_ENABLE_ACL_MSG, GR_VERSION);
60434 + else {
60435 + if (gr_status & GR_READY)
60436 + error = -EAGAIN;
60437 + else
60438 + error = error2;
60439 + gr_log_str(GR_DONT_AUDIT, GR_ENABLEF_ACL_MSG, GR_VERSION);
60440 + }
60441 + break;
60442 + case GR_RELOAD:
60443 + if (!(gr_status & GR_READY)) {
60444 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_RELOADI_ACL_MSG, GR_VERSION);
60445 + error = -EAGAIN;
60446 + } else if (!(chkpw(gr_usermode, gr_system_salt, gr_system_sum))) {
60447 + stop_machine(gr_rbac_disable, NULL, NULL);
60448 + free_variables();
60449 + error2 = gracl_init(gr_usermode);
60450 + if (!error2)
60451 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_RELOAD_ACL_MSG, GR_VERSION);
60452 + else {
60453 + gr_log_str(GR_DONT_AUDIT, GR_RELOADF_ACL_MSG, GR_VERSION);
60454 + error = error2;
60455 + }
60456 + } else {
60457 + gr_log_str(GR_DONT_AUDIT, GR_RELOADF_ACL_MSG, GR_VERSION);
60458 + error = -EPERM;
60459 + }
60460 + break;
60461 + case GR_SEGVMOD:
60462 + if (unlikely(!(gr_status & GR_READY))) {
60463 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SEGVMODI_ACL_MSG);
60464 + error = -EAGAIN;
60465 + break;
60466 + }
60467 +
60468 + if (!(chkpw(gr_usermode, gr_system_salt, gr_system_sum))) {
60469 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SEGVMODS_ACL_MSG);
60470 + if (gr_usermode->segv_device && gr_usermode->segv_inode) {
60471 + struct acl_subject_label *segvacl;
60472 + segvacl =
60473 + lookup_acl_subj_label(gr_usermode->segv_inode,
60474 + gr_usermode->segv_device,
60475 + current->role);
60476 + if (segvacl) {
60477 + segvacl->crashes = 0;
60478 + segvacl->expires = 0;
60479 + }
60480 + } else if (gr_find_uid(gr_usermode->segv_uid) >= 0) {
60481 + gr_remove_uid(gr_usermode->segv_uid);
60482 + }
60483 + } else {
60484 + gr_log_noargs(GR_DONT_AUDIT, GR_SEGVMODF_ACL_MSG);
60485 + error = -EPERM;
60486 + }
60487 + break;
60488 + case GR_SPROLE:
60489 + case GR_SPROLEPAM:
60490 + if (unlikely(!(gr_status & GR_READY))) {
60491 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SPROLEI_ACL_MSG);
60492 + error = -EAGAIN;
60493 + break;
60494 + }
60495 +
60496 + if (current->role->expires && time_after_eq(get_seconds(), current->role->expires)) {
60497 + current->role->expires = 0;
60498 + current->role->auth_attempts = 0;
60499 + }
60500 +
60501 + if (current->role->auth_attempts >= CONFIG_GRKERNSEC_ACL_MAXTRIES &&
60502 + time_after(current->role->expires, get_seconds())) {
60503 + error = -EBUSY;
60504 + goto out;
60505 + }
60506 +
60507 + if (lookup_special_role_auth
60508 + (gr_usermode->mode, gr_usermode->sp_role, &sprole_salt, &sprole_sum)
60509 + && ((!sprole_salt && !sprole_sum)
60510 + || !(chkpw(gr_usermode, sprole_salt, sprole_sum)))) {
60511 + char *p = "";
60512 + assign_special_role(gr_usermode->sp_role);
60513 + read_lock(&tasklist_lock);
60514 + if (current->real_parent)
60515 + p = current->real_parent->role->rolename;
60516 + read_unlock(&tasklist_lock);
60517 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_SPROLES_ACL_MSG,
60518 + p, acl_sp_role_value);
60519 + } else {
60520 + gr_log_str(GR_DONT_AUDIT, GR_SPROLEF_ACL_MSG, gr_usermode->sp_role);
60521 + error = -EPERM;
60522 + if(!(current->role->auth_attempts++))
60523 + current->role->expires = get_seconds() + CONFIG_GRKERNSEC_ACL_TIMEOUT;
60524 +
60525 + goto out;
60526 + }
60527 + break;
60528 + case GR_UNSPROLE:
60529 + if (unlikely(!(gr_status & GR_READY))) {
60530 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_UNSPROLEI_ACL_MSG);
60531 + error = -EAGAIN;
60532 + break;
60533 + }
60534 +
60535 + if (current->role->roletype & GR_ROLE_SPECIAL) {
60536 + char *p = "";
60537 + int i = 0;
60538 +
60539 + read_lock(&tasklist_lock);
60540 + if (current->real_parent) {
60541 + p = current->real_parent->role->rolename;
60542 + i = current->real_parent->acl_role_id;
60543 + }
60544 + read_unlock(&tasklist_lock);
60545 +
60546 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_UNSPROLES_ACL_MSG, p, i);
60547 + gr_set_acls(1);
60548 + } else {
60549 + error = -EPERM;
60550 + goto out;
60551 + }
60552 + break;
60553 + default:
60554 + gr_log_int(GR_DONT_AUDIT, GR_INVMODE_ACL_MSG, gr_usermode->mode);
60555 + error = -EINVAL;
60556 + break;
60557 + }
60558 +
60559 + if (error != -EPERM)
60560 + goto out;
60561 +
60562 + if(!(gr_auth_attempts++))
60563 + gr_auth_expires = get_seconds() + CONFIG_GRKERNSEC_ACL_TIMEOUT;
60564 +
60565 + out:
60566 + mutex_unlock(&gr_dev_mutex);
60567 + return error;
60568 +}
60569 +
60570 +/* must be called with
60571 + rcu_read_lock();
60572 + read_lock(&tasklist_lock);
60573 + read_lock(&grsec_exec_file_lock);
60574 +*/
60575 +int gr_apply_subject_to_task(struct task_struct *task)
60576 +{
60577 + struct acl_object_label *obj;
60578 + char *tmpname;
60579 + struct acl_subject_label *tmpsubj;
60580 + struct file *filp;
60581 + struct name_entry *nmatch;
60582 +
60583 + filp = task->exec_file;
60584 + if (filp == NULL)
60585 + return 0;
60586 +
60587 + /* the following is to apply the correct subject
60588 + on binaries running when the RBAC system
60589 + is enabled, when the binaries have been
60590 + replaced or deleted since their execution
60591 + -----
60592 + when the RBAC system starts, the inode/dev
60593 + from exec_file will be one the RBAC system
60594 + is unaware of. It only knows the inode/dev
60595 + of the present file on disk, or the absence
60596 + of it.
60597 + */
60598 + preempt_disable();
60599 + tmpname = gr_to_filename_rbac(filp->f_path.dentry, filp->f_path.mnt);
60600 +
60601 + nmatch = lookup_name_entry(tmpname);
60602 + preempt_enable();
60603 + tmpsubj = NULL;
60604 + if (nmatch) {
60605 + if (nmatch->deleted)
60606 + tmpsubj = lookup_acl_subj_label_deleted(nmatch->inode, nmatch->device, task->role);
60607 + else
60608 + tmpsubj = lookup_acl_subj_label(nmatch->inode, nmatch->device, task->role);
60609 + if (tmpsubj != NULL)
60610 + task->acl = tmpsubj;
60611 + }
60612 + if (tmpsubj == NULL)
60613 + task->acl = chk_subj_label(filp->f_path.dentry, filp->f_path.mnt,
60614 + task->role);
60615 + if (task->acl) {
60616 + task->is_writable = 0;
60617 + /* ignore additional mmap checks for processes that are writable
60618 + by the default ACL */
60619 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, default_role->root_label);
60620 + if (unlikely(obj->mode & GR_WRITE))
60621 + task->is_writable = 1;
60622 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, task->role->root_label);
60623 + if (unlikely(obj->mode & GR_WRITE))
60624 + task->is_writable = 1;
60625 +
60626 + gr_set_proc_res(task);
60627 +
60628 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
60629 + 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);
60630 +#endif
60631 + } else {
60632 + return 1;
60633 + }
60634 +
60635 + return 0;
60636 +}
60637 +
60638 +int
60639 +gr_set_acls(const int type)
60640 +{
60641 + struct task_struct *task, *task2;
60642 + struct acl_role_label *role = current->role;
60643 + __u16 acl_role_id = current->acl_role_id;
60644 + const struct cred *cred;
60645 + int ret;
60646 +
60647 + rcu_read_lock();
60648 + read_lock(&tasklist_lock);
60649 + read_lock(&grsec_exec_file_lock);
60650 + do_each_thread(task2, task) {
60651 + /* check to see if we're called from the exit handler,
60652 + if so, only replace ACLs that have inherited the admin
60653 + ACL */
60654 +
60655 + if (type && (task->role != role ||
60656 + task->acl_role_id != acl_role_id))
60657 + continue;
60658 +
60659 + task->acl_role_id = 0;
60660 + task->acl_sp_role = 0;
60661 +
60662 + if (task->exec_file) {
60663 + cred = __task_cred(task);
60664 + task->role = lookup_acl_role_label(task, GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid));
60665 + ret = gr_apply_subject_to_task(task);
60666 + if (ret) {
60667 + read_unlock(&grsec_exec_file_lock);
60668 + read_unlock(&tasklist_lock);
60669 + rcu_read_unlock();
60670 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_DEFACL_MSG, task->comm, task_pid_nr(task));
60671 + return ret;
60672 + }
60673 + } else {
60674 + // it's a kernel process
60675 + task->role = kernel_role;
60676 + task->acl = kernel_role->root_label;
60677 +#ifdef CONFIG_GRKERNSEC_ACL_HIDEKERN
60678 + task->acl->mode &= ~GR_PROCFIND;
60679 +#endif
60680 + }
60681 + } while_each_thread(task2, task);
60682 + read_unlock(&grsec_exec_file_lock);
60683 + read_unlock(&tasklist_lock);
60684 + rcu_read_unlock();
60685 +
60686 + return 0;
60687 +}
60688 +
60689 +#if defined(CONFIG_GRKERNSEC_RESLOG) || !defined(CONFIG_GRKERNSEC_NO_RBAC)
60690 +static const unsigned long res_learn_bumps[GR_NLIMITS] = {
60691 + [RLIMIT_CPU] = GR_RLIM_CPU_BUMP,
60692 + [RLIMIT_FSIZE] = GR_RLIM_FSIZE_BUMP,
60693 + [RLIMIT_DATA] = GR_RLIM_DATA_BUMP,
60694 + [RLIMIT_STACK] = GR_RLIM_STACK_BUMP,
60695 + [RLIMIT_CORE] = GR_RLIM_CORE_BUMP,
60696 + [RLIMIT_RSS] = GR_RLIM_RSS_BUMP,
60697 + [RLIMIT_NPROC] = GR_RLIM_NPROC_BUMP,
60698 + [RLIMIT_NOFILE] = GR_RLIM_NOFILE_BUMP,
60699 + [RLIMIT_MEMLOCK] = GR_RLIM_MEMLOCK_BUMP,
60700 + [RLIMIT_AS] = GR_RLIM_AS_BUMP,
60701 + [RLIMIT_LOCKS] = GR_RLIM_LOCKS_BUMP,
60702 + [RLIMIT_SIGPENDING] = GR_RLIM_SIGPENDING_BUMP,
60703 + [RLIMIT_MSGQUEUE] = GR_RLIM_MSGQUEUE_BUMP,
60704 + [RLIMIT_NICE] = GR_RLIM_NICE_BUMP,
60705 + [RLIMIT_RTPRIO] = GR_RLIM_RTPRIO_BUMP,
60706 + [RLIMIT_RTTIME] = GR_RLIM_RTTIME_BUMP
60707 +};
60708 +
60709 +void
60710 +gr_learn_resource(const struct task_struct *task,
60711 + const int res, const unsigned long wanted, const int gt)
60712 +{
60713 + struct acl_subject_label *acl;
60714 + const struct cred *cred;
60715 +
60716 + if (unlikely((gr_status & GR_READY) &&
60717 + task->acl && (task->acl->mode & (GR_LEARN | GR_INHERITLEARN))))
60718 + goto skip_reslog;
60719 +
60720 + gr_log_resource(task, res, wanted, gt);
60721 +skip_reslog:
60722 +
60723 + if (unlikely(!(gr_status & GR_READY) || !wanted || res >= GR_NLIMITS))
60724 + return;
60725 +
60726 + acl = task->acl;
60727 +
60728 + if (likely(!acl || !(acl->mode & (GR_LEARN | GR_INHERITLEARN)) ||
60729 + !(acl->resmask & (1 << (unsigned short) res))))
60730 + return;
60731 +
60732 + if (wanted >= acl->res[res].rlim_cur) {
60733 + unsigned long res_add;
60734 +
60735 + res_add = wanted + res_learn_bumps[res];
60736 +
60737 + acl->res[res].rlim_cur = res_add;
60738 +
60739 + if (wanted > acl->res[res].rlim_max)
60740 + acl->res[res].rlim_max = res_add;
60741 +
60742 + /* only log the subject filename, since resource logging is supported for
60743 + single-subject learning only */
60744 + rcu_read_lock();
60745 + cred = __task_cred(task);
60746 + security_learn(GR_LEARN_AUDIT_MSG, task->role->rolename,
60747 + task->role->roletype, GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), acl->filename,
60748 + acl->filename, acl->res[res].rlim_cur, acl->res[res].rlim_max,
60749 + "", (unsigned long) res, &task->signal->saved_ip);
60750 + rcu_read_unlock();
60751 + }
60752 +
60753 + return;
60754 +}
60755 +EXPORT_SYMBOL(gr_learn_resource);
60756 +#endif
60757 +
60758 +#if defined(CONFIG_PAX_HAVE_ACL_FLAGS) && (defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR))
60759 +void
60760 +pax_set_initial_flags(struct linux_binprm *bprm)
60761 +{
60762 + struct task_struct *task = current;
60763 + struct acl_subject_label *proc;
60764 + unsigned long flags;
60765 +
60766 + if (unlikely(!(gr_status & GR_READY)))
60767 + return;
60768 +
60769 + flags = pax_get_flags(task);
60770 +
60771 + proc = task->acl;
60772 +
60773 + if (proc->pax_flags & GR_PAX_DISABLE_PAGEEXEC)
60774 + flags &= ~MF_PAX_PAGEEXEC;
60775 + if (proc->pax_flags & GR_PAX_DISABLE_SEGMEXEC)
60776 + flags &= ~MF_PAX_SEGMEXEC;
60777 + if (proc->pax_flags & GR_PAX_DISABLE_RANDMMAP)
60778 + flags &= ~MF_PAX_RANDMMAP;
60779 + if (proc->pax_flags & GR_PAX_DISABLE_EMUTRAMP)
60780 + flags &= ~MF_PAX_EMUTRAMP;
60781 + if (proc->pax_flags & GR_PAX_DISABLE_MPROTECT)
60782 + flags &= ~MF_PAX_MPROTECT;
60783 +
60784 + if (proc->pax_flags & GR_PAX_ENABLE_PAGEEXEC)
60785 + flags |= MF_PAX_PAGEEXEC;
60786 + if (proc->pax_flags & GR_PAX_ENABLE_SEGMEXEC)
60787 + flags |= MF_PAX_SEGMEXEC;
60788 + if (proc->pax_flags & GR_PAX_ENABLE_RANDMMAP)
60789 + flags |= MF_PAX_RANDMMAP;
60790 + if (proc->pax_flags & GR_PAX_ENABLE_EMUTRAMP)
60791 + flags |= MF_PAX_EMUTRAMP;
60792 + if (proc->pax_flags & GR_PAX_ENABLE_MPROTECT)
60793 + flags |= MF_PAX_MPROTECT;
60794 +
60795 + pax_set_flags(task, flags);
60796 +
60797 + return;
60798 +}
60799 +#endif
60800 +
60801 +int
60802 +gr_handle_proc_ptrace(struct task_struct *task)
60803 +{
60804 + struct file *filp;
60805 + struct task_struct *tmp = task;
60806 + struct task_struct *curtemp = current;
60807 + __u32 retmode;
60808 +
60809 +#ifndef CONFIG_GRKERNSEC_HARDEN_PTRACE
60810 + if (unlikely(!(gr_status & GR_READY)))
60811 + return 0;
60812 +#endif
60813 +
60814 + read_lock(&tasklist_lock);
60815 + read_lock(&grsec_exec_file_lock);
60816 + filp = task->exec_file;
60817 +
60818 + while (task_pid_nr(tmp) > 0) {
60819 + if (tmp == curtemp)
60820 + break;
60821 + tmp = tmp->real_parent;
60822 + }
60823 +
60824 + if (!filp || (task_pid_nr(tmp) == 0 && ((grsec_enable_harden_ptrace && gr_is_global_nonroot(current_uid()) && !(gr_status & GR_READY)) ||
60825 + ((gr_status & GR_READY) && !(current->acl->mode & GR_RELAXPTRACE))))) {
60826 + read_unlock(&grsec_exec_file_lock);
60827 + read_unlock(&tasklist_lock);
60828 + return 1;
60829 + }
60830 +
60831 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
60832 + if (!(gr_status & GR_READY)) {
60833 + read_unlock(&grsec_exec_file_lock);
60834 + read_unlock(&tasklist_lock);
60835 + return 0;
60836 + }
60837 +#endif
60838 +
60839 + retmode = gr_search_file(filp->f_path.dentry, GR_NOPTRACE, filp->f_path.mnt);
60840 + read_unlock(&grsec_exec_file_lock);
60841 + read_unlock(&tasklist_lock);
60842 +
60843 + if (retmode & GR_NOPTRACE)
60844 + return 1;
60845 +
60846 + if (!(current->acl->mode & GR_POVERRIDE) && !(current->role->roletype & GR_ROLE_GOD)
60847 + && (current->acl != task->acl || (current->acl != current->role->root_label
60848 + && task_pid_nr(current) != task_pid_nr(task))))
60849 + return 1;
60850 +
60851 + return 0;
60852 +}
60853 +
60854 +void task_grsec_rbac(struct seq_file *m, struct task_struct *p)
60855 +{
60856 + if (unlikely(!(gr_status & GR_READY)))
60857 + return;
60858 +
60859 + if (!(current->role->roletype & GR_ROLE_GOD))
60860 + return;
60861 +
60862 + seq_printf(m, "RBAC:\t%.64s:%c:%.950s\n",
60863 + p->role->rolename, gr_task_roletype_to_char(p),
60864 + p->acl->filename);
60865 +}
60866 +
60867 +int
60868 +gr_handle_ptrace(struct task_struct *task, const long request)
60869 +{
60870 + struct task_struct *tmp = task;
60871 + struct task_struct *curtemp = current;
60872 + __u32 retmode;
60873 +
60874 +#ifndef CONFIG_GRKERNSEC_HARDEN_PTRACE
60875 + if (unlikely(!(gr_status & GR_READY)))
60876 + return 0;
60877 +#endif
60878 + if (request == PTRACE_ATTACH || request == PTRACE_SEIZE) {
60879 + read_lock(&tasklist_lock);
60880 + while (task_pid_nr(tmp) > 0) {
60881 + if (tmp == curtemp)
60882 + break;
60883 + tmp = tmp->real_parent;
60884 + }
60885 +
60886 + if (task_pid_nr(tmp) == 0 && ((grsec_enable_harden_ptrace && gr_is_global_nonroot(current_uid()) && !(gr_status & GR_READY)) ||
60887 + ((gr_status & GR_READY) && !(current->acl->mode & GR_RELAXPTRACE)))) {
60888 + read_unlock(&tasklist_lock);
60889 + gr_log_ptrace(GR_DONT_AUDIT, GR_PTRACE_ACL_MSG, task);
60890 + return 1;
60891 + }
60892 + read_unlock(&tasklist_lock);
60893 + }
60894 +
60895 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
60896 + if (!(gr_status & GR_READY))
60897 + return 0;
60898 +#endif
60899 +
60900 + read_lock(&grsec_exec_file_lock);
60901 + if (unlikely(!task->exec_file)) {
60902 + read_unlock(&grsec_exec_file_lock);
60903 + return 0;
60904 + }
60905 +
60906 + retmode = gr_search_file(task->exec_file->f_path.dentry, GR_PTRACERD | GR_NOPTRACE, task->exec_file->f_path.mnt);
60907 + read_unlock(&grsec_exec_file_lock);
60908 +
60909 + if (retmode & GR_NOPTRACE) {
60910 + gr_log_ptrace(GR_DONT_AUDIT, GR_PTRACE_ACL_MSG, task);
60911 + return 1;
60912 + }
60913 +
60914 + if (retmode & GR_PTRACERD) {
60915 + switch (request) {
60916 + case PTRACE_SEIZE:
60917 + case PTRACE_POKETEXT:
60918 + case PTRACE_POKEDATA:
60919 + case PTRACE_POKEUSR:
60920 +#if !defined(CONFIG_PPC32) && !defined(CONFIG_PPC64) && !defined(CONFIG_PARISC) && !defined(CONFIG_ALPHA) && !defined(CONFIG_IA64)
60921 + case PTRACE_SETREGS:
60922 + case PTRACE_SETFPREGS:
60923 +#endif
60924 +#ifdef CONFIG_X86
60925 + case PTRACE_SETFPXREGS:
60926 +#endif
60927 +#ifdef CONFIG_ALTIVEC
60928 + case PTRACE_SETVRREGS:
60929 +#endif
60930 + return 1;
60931 + default:
60932 + return 0;
60933 + }
60934 + } else if (!(current->acl->mode & GR_POVERRIDE) &&
60935 + !(current->role->roletype & GR_ROLE_GOD) &&
60936 + (current->acl != task->acl)) {
60937 + gr_log_ptrace(GR_DONT_AUDIT, GR_PTRACE_ACL_MSG, task);
60938 + return 1;
60939 + }
60940 +
60941 + return 0;
60942 +}
60943 +
60944 +static int is_writable_mmap(const struct file *filp)
60945 +{
60946 + struct task_struct *task = current;
60947 + struct acl_object_label *obj, *obj2;
60948 +
60949 + if (gr_status & GR_READY && !(task->acl->mode & GR_OVERRIDE) &&
60950 + !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))) {
60951 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, default_role->root_label);
60952 + obj2 = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt,
60953 + task->role->root_label);
60954 + if (unlikely((obj->mode & GR_WRITE) || (obj2->mode & GR_WRITE))) {
60955 + gr_log_fs_generic(GR_DONT_AUDIT, GR_WRITLIB_ACL_MSG, filp->f_path.dentry, filp->f_path.mnt);
60956 + return 1;
60957 + }
60958 + }
60959 + return 0;
60960 +}
60961 +
60962 +int
60963 +gr_acl_handle_mmap(const struct file *file, const unsigned long prot)
60964 +{
60965 + __u32 mode;
60966 +
60967 + if (unlikely(!file || !(prot & PROT_EXEC)))
60968 + return 1;
60969 +
60970 + if (is_writable_mmap(file))
60971 + return 0;
60972 +
60973 + mode =
60974 + gr_search_file(file->f_path.dentry,
60975 + GR_EXEC | GR_AUDIT_EXEC | GR_SUPPRESS,
60976 + file->f_path.mnt);
60977 +
60978 + if (!gr_tpe_allow(file))
60979 + return 0;
60980 +
60981 + if (unlikely(!(mode & GR_EXEC) && !(mode & GR_SUPPRESS))) {
60982 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, GR_MMAP_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
60983 + return 0;
60984 + } else if (unlikely(!(mode & GR_EXEC))) {
60985 + return 0;
60986 + } else if (unlikely(mode & GR_EXEC && mode & GR_AUDIT_EXEC)) {
60987 + gr_log_fs_rbac_generic(GR_DO_AUDIT, GR_MMAP_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
60988 + return 1;
60989 + }
60990 +
60991 + return 1;
60992 +}
60993 +
60994 +int
60995 +gr_acl_handle_mprotect(const struct file *file, const unsigned long prot)
60996 +{
60997 + __u32 mode;
60998 +
60999 + if (unlikely(!file || !(prot & PROT_EXEC)))
61000 + return 1;
61001 +
61002 + if (is_writable_mmap(file))
61003 + return 0;
61004 +
61005 + mode =
61006 + gr_search_file(file->f_path.dentry,
61007 + GR_EXEC | GR_AUDIT_EXEC | GR_SUPPRESS,
61008 + file->f_path.mnt);
61009 +
61010 + if (!gr_tpe_allow(file))
61011 + return 0;
61012 +
61013 + if (unlikely(!(mode & GR_EXEC) && !(mode & GR_SUPPRESS))) {
61014 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, GR_MPROTECT_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
61015 + return 0;
61016 + } else if (unlikely(!(mode & GR_EXEC))) {
61017 + return 0;
61018 + } else if (unlikely(mode & GR_EXEC && mode & GR_AUDIT_EXEC)) {
61019 + gr_log_fs_rbac_generic(GR_DO_AUDIT, GR_MPROTECT_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
61020 + return 1;
61021 + }
61022 +
61023 + return 1;
61024 +}
61025 +
61026 +void
61027 +gr_acl_handle_psacct(struct task_struct *task, const long code)
61028 +{
61029 + unsigned long runtime;
61030 + unsigned long cputime;
61031 + unsigned int wday, cday;
61032 + __u8 whr, chr;
61033 + __u8 wmin, cmin;
61034 + __u8 wsec, csec;
61035 + struct timespec timeval;
61036 +
61037 + if (unlikely(!(gr_status & GR_READY) || !task->acl ||
61038 + !(task->acl->mode & GR_PROCACCT)))
61039 + return;
61040 +
61041 + do_posix_clock_monotonic_gettime(&timeval);
61042 + runtime = timeval.tv_sec - task->start_time.tv_sec;
61043 + wday = runtime / (3600 * 24);
61044 + runtime -= wday * (3600 * 24);
61045 + whr = runtime / 3600;
61046 + runtime -= whr * 3600;
61047 + wmin = runtime / 60;
61048 + runtime -= wmin * 60;
61049 + wsec = runtime;
61050 +
61051 + cputime = (task->utime + task->stime) / HZ;
61052 + cday = cputime / (3600 * 24);
61053 + cputime -= cday * (3600 * 24);
61054 + chr = cputime / 3600;
61055 + cputime -= chr * 3600;
61056 + cmin = cputime / 60;
61057 + cputime -= cmin * 60;
61058 + csec = cputime;
61059 +
61060 + gr_log_procacct(GR_DO_AUDIT, GR_ACL_PROCACCT_MSG, task, wday, whr, wmin, wsec, cday, chr, cmin, csec, code);
61061 +
61062 + return;
61063 +}
61064 +
61065 +void gr_set_kernel_label(struct task_struct *task)
61066 +{
61067 + if (gr_status & GR_READY) {
61068 + task->role = kernel_role;
61069 + task->acl = kernel_role->root_label;
61070 + }
61071 + return;
61072 +}
61073 +
61074 +#ifdef CONFIG_TASKSTATS
61075 +int gr_is_taskstats_denied(int pid)
61076 +{
61077 + struct task_struct *task;
61078 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
61079 + const struct cred *cred;
61080 +#endif
61081 + int ret = 0;
61082 +
61083 + /* restrict taskstats viewing to un-chrooted root users
61084 + who have the 'view' subject flag if the RBAC system is enabled
61085 + */
61086 +
61087 + rcu_read_lock();
61088 + read_lock(&tasklist_lock);
61089 + task = find_task_by_vpid(pid);
61090 + if (task) {
61091 +#ifdef CONFIG_GRKERNSEC_CHROOT
61092 + if (proc_is_chrooted(task))
61093 + ret = -EACCES;
61094 +#endif
61095 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
61096 + cred = __task_cred(task);
61097 +#ifdef CONFIG_GRKERNSEC_PROC_USER
61098 + if (gr_is_global_nonroot(cred->uid))
61099 + ret = -EACCES;
61100 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
61101 + if (gr_is_global_nonroot(cred->uid) && !groups_search(cred->group_info, grsec_proc_gid))
61102 + ret = -EACCES;
61103 +#endif
61104 +#endif
61105 + if (gr_status & GR_READY) {
61106 + if (!(task->acl->mode & GR_VIEW))
61107 + ret = -EACCES;
61108 + }
61109 + } else
61110 + ret = -ENOENT;
61111 +
61112 + read_unlock(&tasklist_lock);
61113 + rcu_read_unlock();
61114 +
61115 + return ret;
61116 +}
61117 +#endif
61118 +
61119 +/* AUXV entries are filled via a descendant of search_binary_handler
61120 + after we've already applied the subject for the target
61121 +*/
61122 +int gr_acl_enable_at_secure(void)
61123 +{
61124 + if (unlikely(!(gr_status & GR_READY)))
61125 + return 0;
61126 +
61127 + if (current->acl->mode & GR_ATSECURE)
61128 + return 1;
61129 +
61130 + return 0;
61131 +}
61132 +
61133 +int gr_acl_handle_filldir(const struct file *file, const char *name, const unsigned int namelen, const ino_t ino)
61134 +{
61135 + struct task_struct *task = current;
61136 + struct dentry *dentry = file->f_path.dentry;
61137 + struct vfsmount *mnt = file->f_path.mnt;
61138 + struct acl_object_label *obj, *tmp;
61139 + struct acl_subject_label *subj;
61140 + unsigned int bufsize;
61141 + int is_not_root;
61142 + char *path;
61143 + dev_t dev = __get_dev(dentry);
61144 +
61145 + if (unlikely(!(gr_status & GR_READY)))
61146 + return 1;
61147 +
61148 + if (task->acl->mode & (GR_LEARN | GR_INHERITLEARN))
61149 + return 1;
61150 +
61151 + /* ignore Eric Biederman */
61152 + if (IS_PRIVATE(dentry->d_inode))
61153 + return 1;
61154 +
61155 + subj = task->acl;
61156 + read_lock(&gr_inode_lock);
61157 + do {
61158 + obj = lookup_acl_obj_label(ino, dev, subj);
61159 + if (obj != NULL) {
61160 + read_unlock(&gr_inode_lock);
61161 + return (obj->mode & GR_FIND) ? 1 : 0;
61162 + }
61163 + } while ((subj = subj->parent_subject));
61164 + read_unlock(&gr_inode_lock);
61165 +
61166 + /* this is purely an optimization since we're looking for an object
61167 + for the directory we're doing a readdir on
61168 + if it's possible for any globbed object to match the entry we're
61169 + filling into the directory, then the object we find here will be
61170 + an anchor point with attached globbed objects
61171 + */
61172 + obj = chk_obj_label_noglob(dentry, mnt, task->acl);
61173 + if (obj->globbed == NULL)
61174 + return (obj->mode & GR_FIND) ? 1 : 0;
61175 +
61176 + is_not_root = ((obj->filename[0] == '/') &&
61177 + (obj->filename[1] == '\0')) ? 0 : 1;
61178 + bufsize = PAGE_SIZE - namelen - is_not_root;
61179 +
61180 + /* check bufsize > PAGE_SIZE || bufsize == 0 */
61181 + if (unlikely((bufsize - 1) > (PAGE_SIZE - 1)))
61182 + return 1;
61183 +
61184 + preempt_disable();
61185 + path = d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0], smp_processor_id()),
61186 + bufsize);
61187 +
61188 + bufsize = strlen(path);
61189 +
61190 + /* if base is "/", don't append an additional slash */
61191 + if (is_not_root)
61192 + *(path + bufsize) = '/';
61193 + memcpy(path + bufsize + is_not_root, name, namelen);
61194 + *(path + bufsize + namelen + is_not_root) = '\0';
61195 +
61196 + tmp = obj->globbed;
61197 + while (tmp) {
61198 + if (!glob_match(tmp->filename, path)) {
61199 + preempt_enable();
61200 + return (tmp->mode & GR_FIND) ? 1 : 0;
61201 + }
61202 + tmp = tmp->next;
61203 + }
61204 + preempt_enable();
61205 + return (obj->mode & GR_FIND) ? 1 : 0;
61206 +}
61207 +
61208 +void gr_put_exec_file(struct task_struct *task)
61209 +{
61210 + struct file *filp;
61211 +
61212 + write_lock(&grsec_exec_file_lock);
61213 + filp = task->exec_file;
61214 + task->exec_file = NULL;
61215 + write_unlock(&grsec_exec_file_lock);
61216 +
61217 + if (filp)
61218 + fput(filp);
61219 +
61220 + return;
61221 +}
61222 +
61223 +
61224 +#ifdef CONFIG_NETFILTER_XT_MATCH_GRADM_MODULE
61225 +EXPORT_SYMBOL(gr_acl_is_enabled);
61226 +#endif
61227 +EXPORT_SYMBOL(gr_set_kernel_label);
61228 +#ifdef CONFIG_SECURITY
61229 +EXPORT_SYMBOL(gr_check_user_change);
61230 +EXPORT_SYMBOL(gr_check_group_change);
61231 +#endif
61232 +
61233 diff --git a/grsecurity/gracl_alloc.c b/grsecurity/gracl_alloc.c
61234 new file mode 100644
61235 index 0000000..34fefda
61236 --- /dev/null
61237 +++ b/grsecurity/gracl_alloc.c
61238 @@ -0,0 +1,105 @@
61239 +#include <linux/kernel.h>
61240 +#include <linux/mm.h>
61241 +#include <linux/slab.h>
61242 +#include <linux/vmalloc.h>
61243 +#include <linux/gracl.h>
61244 +#include <linux/grsecurity.h>
61245 +
61246 +static unsigned long alloc_stack_next = 1;
61247 +static unsigned long alloc_stack_size = 1;
61248 +static void **alloc_stack;
61249 +
61250 +static __inline__ int
61251 +alloc_pop(void)
61252 +{
61253 + if (alloc_stack_next == 1)
61254 + return 0;
61255 +
61256 + kfree(alloc_stack[alloc_stack_next - 2]);
61257 +
61258 + alloc_stack_next--;
61259 +
61260 + return 1;
61261 +}
61262 +
61263 +static __inline__ int
61264 +alloc_push(void *buf)
61265 +{
61266 + if (alloc_stack_next >= alloc_stack_size)
61267 + return 1;
61268 +
61269 + alloc_stack[alloc_stack_next - 1] = buf;
61270 +
61271 + alloc_stack_next++;
61272 +
61273 + return 0;
61274 +}
61275 +
61276 +void *
61277 +acl_alloc(unsigned long len)
61278 +{
61279 + void *ret = NULL;
61280 +
61281 + if (!len || len > PAGE_SIZE)
61282 + goto out;
61283 +
61284 + ret = kmalloc(len, GFP_KERNEL);
61285 +
61286 + if (ret) {
61287 + if (alloc_push(ret)) {
61288 + kfree(ret);
61289 + ret = NULL;
61290 + }
61291 + }
61292 +
61293 +out:
61294 + return ret;
61295 +}
61296 +
61297 +void *
61298 +acl_alloc_num(unsigned long num, unsigned long len)
61299 +{
61300 + if (!len || (num > (PAGE_SIZE / len)))
61301 + return NULL;
61302 +
61303 + return acl_alloc(num * len);
61304 +}
61305 +
61306 +void
61307 +acl_free_all(void)
61308 +{
61309 + if (gr_acl_is_enabled() || !alloc_stack)
61310 + return;
61311 +
61312 + while (alloc_pop()) ;
61313 +
61314 + if (alloc_stack) {
61315 + if ((alloc_stack_size * sizeof (void *)) <= PAGE_SIZE)
61316 + kfree(alloc_stack);
61317 + else
61318 + vfree(alloc_stack);
61319 + }
61320 +
61321 + alloc_stack = NULL;
61322 + alloc_stack_size = 1;
61323 + alloc_stack_next = 1;
61324 +
61325 + return;
61326 +}
61327 +
61328 +int
61329 +acl_alloc_stack_init(unsigned long size)
61330 +{
61331 + if ((size * sizeof (void *)) <= PAGE_SIZE)
61332 + alloc_stack =
61333 + (void **) kmalloc(size * sizeof (void *), GFP_KERNEL);
61334 + else
61335 + alloc_stack = (void **) vmalloc(size * sizeof (void *));
61336 +
61337 + alloc_stack_size = size;
61338 +
61339 + if (!alloc_stack)
61340 + return 0;
61341 + else
61342 + return 1;
61343 +}
61344 diff --git a/grsecurity/gracl_cap.c b/grsecurity/gracl_cap.c
61345 new file mode 100644
61346 index 0000000..bdd51ea
61347 --- /dev/null
61348 +++ b/grsecurity/gracl_cap.c
61349 @@ -0,0 +1,110 @@
61350 +#include <linux/kernel.h>
61351 +#include <linux/module.h>
61352 +#include <linux/sched.h>
61353 +#include <linux/gracl.h>
61354 +#include <linux/grsecurity.h>
61355 +#include <linux/grinternal.h>
61356 +
61357 +extern const char *captab_log[];
61358 +extern int captab_log_entries;
61359 +
61360 +int gr_task_acl_is_capable(const struct task_struct *task, const struct cred *cred, const int cap)
61361 +{
61362 + struct acl_subject_label *curracl;
61363 + kernel_cap_t cap_drop = __cap_empty_set, cap_mask = __cap_empty_set;
61364 + kernel_cap_t cap_audit = __cap_empty_set;
61365 +
61366 + if (!gr_acl_is_enabled())
61367 + return 1;
61368 +
61369 + curracl = task->acl;
61370 +
61371 + cap_drop = curracl->cap_lower;
61372 + cap_mask = curracl->cap_mask;
61373 + cap_audit = curracl->cap_invert_audit;
61374 +
61375 + while ((curracl = curracl->parent_subject)) {
61376 + /* if the cap isn't specified in the current computed mask but is specified in the
61377 + current level subject, and is lowered in the current level subject, then add
61378 + it to the set of dropped capabilities
61379 + otherwise, add the current level subject's mask to the current computed mask
61380 + */
61381 + if (!cap_raised(cap_mask, cap) && cap_raised(curracl->cap_mask, cap)) {
61382 + cap_raise(cap_mask, cap);
61383 + if (cap_raised(curracl->cap_lower, cap))
61384 + cap_raise(cap_drop, cap);
61385 + if (cap_raised(curracl->cap_invert_audit, cap))
61386 + cap_raise(cap_audit, cap);
61387 + }
61388 + }
61389 +
61390 + if (!cap_raised(cap_drop, cap)) {
61391 + if (cap_raised(cap_audit, cap))
61392 + gr_log_cap(GR_DO_AUDIT, GR_CAP_ACL_MSG2, task, captab_log[cap]);
61393 + return 1;
61394 + }
61395 +
61396 + curracl = task->acl;
61397 +
61398 + if ((curracl->mode & (GR_LEARN | GR_INHERITLEARN))
61399 + && cap_raised(cred->cap_effective, cap)) {
61400 + security_learn(GR_LEARN_AUDIT_MSG, task->role->rolename,
61401 + task->role->roletype, GR_GLOBAL_UID(cred->uid),
61402 + GR_GLOBAL_GID(cred->gid), task->exec_file ?
61403 + gr_to_filename(task->exec_file->f_path.dentry,
61404 + task->exec_file->f_path.mnt) : curracl->filename,
61405 + curracl->filename, 0UL,
61406 + 0UL, "", (unsigned long) cap, &task->signal->saved_ip);
61407 + return 1;
61408 + }
61409 +
61410 + if ((cap >= 0) && (cap < captab_log_entries) && cap_raised(cred->cap_effective, cap) && !cap_raised(cap_audit, cap))
61411 + gr_log_cap(GR_DONT_AUDIT, GR_CAP_ACL_MSG, task, captab_log[cap]);
61412 +
61413 + return 0;
61414 +}
61415 +
61416 +int
61417 +gr_acl_is_capable(const int cap)
61418 +{
61419 + return gr_task_acl_is_capable(current, current_cred(), cap);
61420 +}
61421 +
61422 +int gr_task_acl_is_capable_nolog(const struct task_struct *task, const int cap)
61423 +{
61424 + struct acl_subject_label *curracl;
61425 + kernel_cap_t cap_drop = __cap_empty_set, cap_mask = __cap_empty_set;
61426 +
61427 + if (!gr_acl_is_enabled())
61428 + return 1;
61429 +
61430 + curracl = task->acl;
61431 +
61432 + cap_drop = curracl->cap_lower;
61433 + cap_mask = curracl->cap_mask;
61434 +
61435 + while ((curracl = curracl->parent_subject)) {
61436 + /* if the cap isn't specified in the current computed mask but is specified in the
61437 + current level subject, and is lowered in the current level subject, then add
61438 + it to the set of dropped capabilities
61439 + otherwise, add the current level subject's mask to the current computed mask
61440 + */
61441 + if (!cap_raised(cap_mask, cap) && cap_raised(curracl->cap_mask, cap)) {
61442 + cap_raise(cap_mask, cap);
61443 + if (cap_raised(curracl->cap_lower, cap))
61444 + cap_raise(cap_drop, cap);
61445 + }
61446 + }
61447 +
61448 + if (!cap_raised(cap_drop, cap))
61449 + return 1;
61450 +
61451 + return 0;
61452 +}
61453 +
61454 +int
61455 +gr_acl_is_capable_nolog(const int cap)
61456 +{
61457 + return gr_task_acl_is_capable_nolog(current, cap);
61458 +}
61459 +
61460 diff --git a/grsecurity/gracl_fs.c b/grsecurity/gracl_fs.c
61461 new file mode 100644
61462 index 0000000..a340c17
61463 --- /dev/null
61464 +++ b/grsecurity/gracl_fs.c
61465 @@ -0,0 +1,431 @@
61466 +#include <linux/kernel.h>
61467 +#include <linux/sched.h>
61468 +#include <linux/types.h>
61469 +#include <linux/fs.h>
61470 +#include <linux/file.h>
61471 +#include <linux/stat.h>
61472 +#include <linux/grsecurity.h>
61473 +#include <linux/grinternal.h>
61474 +#include <linux/gracl.h>
61475 +
61476 +umode_t
61477 +gr_acl_umask(void)
61478 +{
61479 + if (unlikely(!gr_acl_is_enabled()))
61480 + return 0;
61481 +
61482 + return current->role->umask;
61483 +}
61484 +
61485 +__u32
61486 +gr_acl_handle_hidden_file(const struct dentry * dentry,
61487 + const struct vfsmount * mnt)
61488 +{
61489 + __u32 mode;
61490 +
61491 + if (unlikely(!dentry->d_inode))
61492 + return GR_FIND;
61493 +
61494 + mode =
61495 + gr_search_file(dentry, GR_FIND | GR_AUDIT_FIND | GR_SUPPRESS, mnt);
61496 +
61497 + if (unlikely(mode & GR_FIND && mode & GR_AUDIT_FIND)) {
61498 + gr_log_fs_rbac_generic(GR_DO_AUDIT, GR_HIDDEN_ACL_MSG, dentry, mnt);
61499 + return mode;
61500 + } else if (unlikely(!(mode & GR_FIND) && !(mode & GR_SUPPRESS))) {
61501 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, GR_HIDDEN_ACL_MSG, dentry, mnt);
61502 + return 0;
61503 + } else if (unlikely(!(mode & GR_FIND)))
61504 + return 0;
61505 +
61506 + return GR_FIND;
61507 +}
61508 +
61509 +__u32
61510 +gr_acl_handle_open(const struct dentry * dentry, const struct vfsmount * mnt,
61511 + int acc_mode)
61512 +{
61513 + __u32 reqmode = GR_FIND;
61514 + __u32 mode;
61515 +
61516 + if (unlikely(!dentry->d_inode))
61517 + return reqmode;
61518 +
61519 + if (acc_mode & MAY_APPEND)
61520 + reqmode |= GR_APPEND;
61521 + else if (acc_mode & MAY_WRITE)
61522 + reqmode |= GR_WRITE;
61523 + if ((acc_mode & MAY_READ) && !S_ISDIR(dentry->d_inode->i_mode))
61524 + reqmode |= GR_READ;
61525 +
61526 + mode =
61527 + gr_search_file(dentry, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS,
61528 + mnt);
61529 +
61530 + if (unlikely(((mode & reqmode) == reqmode) && mode & GR_AUDITS)) {
61531 + gr_log_fs_rbac_mode2(GR_DO_AUDIT, GR_OPEN_ACL_MSG, dentry, mnt,
61532 + reqmode & GR_READ ? " reading" : "",
61533 + reqmode & GR_WRITE ? " writing" : reqmode &
61534 + GR_APPEND ? " appending" : "");
61535 + return reqmode;
61536 + } else
61537 + if (unlikely((mode & reqmode) != reqmode && !(mode & GR_SUPPRESS)))
61538 + {
61539 + gr_log_fs_rbac_mode2(GR_DONT_AUDIT, GR_OPEN_ACL_MSG, dentry, mnt,
61540 + reqmode & GR_READ ? " reading" : "",
61541 + reqmode & GR_WRITE ? " writing" : reqmode &
61542 + GR_APPEND ? " appending" : "");
61543 + return 0;
61544 + } else if (unlikely((mode & reqmode) != reqmode))
61545 + return 0;
61546 +
61547 + return reqmode;
61548 +}
61549 +
61550 +__u32
61551 +gr_acl_handle_creat(const struct dentry * dentry,
61552 + const struct dentry * p_dentry,
61553 + const struct vfsmount * p_mnt, int open_flags, int acc_mode,
61554 + const int imode)
61555 +{
61556 + __u32 reqmode = GR_WRITE | GR_CREATE;
61557 + __u32 mode;
61558 +
61559 + if (acc_mode & MAY_APPEND)
61560 + reqmode |= GR_APPEND;
61561 + // if a directory was required or the directory already exists, then
61562 + // don't count this open as a read
61563 + if ((acc_mode & MAY_READ) &&
61564 + !((open_flags & O_DIRECTORY) || (dentry->d_inode && S_ISDIR(dentry->d_inode->i_mode))))
61565 + reqmode |= GR_READ;
61566 + if ((open_flags & O_CREAT) &&
61567 + ((imode & S_ISUID) || ((imode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))))
61568 + reqmode |= GR_SETID;
61569 +
61570 + mode =
61571 + gr_check_create(dentry, p_dentry, p_mnt,
61572 + reqmode | to_gr_audit(reqmode) | GR_SUPPRESS);
61573 +
61574 + if (unlikely(((mode & reqmode) == reqmode) && mode & GR_AUDITS)) {
61575 + gr_log_fs_rbac_mode2(GR_DO_AUDIT, GR_CREATE_ACL_MSG, dentry, p_mnt,
61576 + reqmode & GR_READ ? " reading" : "",
61577 + reqmode & GR_WRITE ? " writing" : reqmode &
61578 + GR_APPEND ? " appending" : "");
61579 + return reqmode;
61580 + } else
61581 + if (unlikely((mode & reqmode) != reqmode && !(mode & GR_SUPPRESS)))
61582 + {
61583 + gr_log_fs_rbac_mode2(GR_DONT_AUDIT, GR_CREATE_ACL_MSG, dentry, p_mnt,
61584 + reqmode & GR_READ ? " reading" : "",
61585 + reqmode & GR_WRITE ? " writing" : reqmode &
61586 + GR_APPEND ? " appending" : "");
61587 + return 0;
61588 + } else if (unlikely((mode & reqmode) != reqmode))
61589 + return 0;
61590 +
61591 + return reqmode;
61592 +}
61593 +
61594 +__u32
61595 +gr_acl_handle_access(const struct dentry * dentry, const struct vfsmount * mnt,
61596 + const int fmode)
61597 +{
61598 + __u32 mode, reqmode = GR_FIND;
61599 +
61600 + if ((fmode & S_IXOTH) && !S_ISDIR(dentry->d_inode->i_mode))
61601 + reqmode |= GR_EXEC;
61602 + if (fmode & S_IWOTH)
61603 + reqmode |= GR_WRITE;
61604 + if (fmode & S_IROTH)
61605 + reqmode |= GR_READ;
61606 +
61607 + mode =
61608 + gr_search_file(dentry, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS,
61609 + mnt);
61610 +
61611 + if (unlikely(((mode & reqmode) == reqmode) && mode & GR_AUDITS)) {
61612 + gr_log_fs_rbac_mode3(GR_DO_AUDIT, GR_ACCESS_ACL_MSG, dentry, mnt,
61613 + reqmode & GR_READ ? " reading" : "",
61614 + reqmode & GR_WRITE ? " writing" : "",
61615 + reqmode & GR_EXEC ? " executing" : "");
61616 + return reqmode;
61617 + } else
61618 + if (unlikely((mode & reqmode) != reqmode && !(mode & GR_SUPPRESS)))
61619 + {
61620 + gr_log_fs_rbac_mode3(GR_DONT_AUDIT, GR_ACCESS_ACL_MSG, dentry, mnt,
61621 + reqmode & GR_READ ? " reading" : "",
61622 + reqmode & GR_WRITE ? " writing" : "",
61623 + reqmode & GR_EXEC ? " executing" : "");
61624 + return 0;
61625 + } else if (unlikely((mode & reqmode) != reqmode))
61626 + return 0;
61627 +
61628 + return reqmode;
61629 +}
61630 +
61631 +static __u32 generic_fs_handler(const struct dentry *dentry, const struct vfsmount *mnt, __u32 reqmode, const char *fmt)
61632 +{
61633 + __u32 mode;
61634 +
61635 + mode = gr_search_file(dentry, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS, mnt);
61636 +
61637 + if (unlikely(((mode & (reqmode)) == (reqmode)) && mode & GR_AUDITS)) {
61638 + gr_log_fs_rbac_generic(GR_DO_AUDIT, fmt, dentry, mnt);
61639 + return mode;
61640 + } else if (unlikely((mode & (reqmode)) != (reqmode) && !(mode & GR_SUPPRESS))) {
61641 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, fmt, dentry, mnt);
61642 + return 0;
61643 + } else if (unlikely((mode & (reqmode)) != (reqmode)))
61644 + return 0;
61645 +
61646 + return (reqmode);
61647 +}
61648 +
61649 +__u32
61650 +gr_acl_handle_rmdir(const struct dentry * dentry, const struct vfsmount * mnt)
61651 +{
61652 + return generic_fs_handler(dentry, mnt, GR_WRITE | GR_DELETE , GR_RMDIR_ACL_MSG);
61653 +}
61654 +
61655 +__u32
61656 +gr_acl_handle_unlink(const struct dentry *dentry, const struct vfsmount *mnt)
61657 +{
61658 + return generic_fs_handler(dentry, mnt, GR_WRITE | GR_DELETE , GR_UNLINK_ACL_MSG);
61659 +}
61660 +
61661 +__u32
61662 +gr_acl_handle_truncate(const struct dentry *dentry, const struct vfsmount *mnt)
61663 +{
61664 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_TRUNCATE_ACL_MSG);
61665 +}
61666 +
61667 +__u32
61668 +gr_acl_handle_utime(const struct dentry *dentry, const struct vfsmount *mnt)
61669 +{
61670 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_ATIME_ACL_MSG);
61671 +}
61672 +
61673 +__u32
61674 +gr_acl_handle_chmod(const struct dentry *dentry, const struct vfsmount *mnt,
61675 + umode_t *modeptr)
61676 +{
61677 + umode_t mode;
61678 +
61679 + *modeptr &= ~gr_acl_umask();
61680 + mode = *modeptr;
61681 +
61682 + if (unlikely(dentry->d_inode && S_ISSOCK(dentry->d_inode->i_mode)))
61683 + return 1;
61684 +
61685 + if (unlikely(dentry->d_inode && !S_ISDIR(dentry->d_inode->i_mode) &&
61686 + ((mode & S_ISUID) || ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))))) {
61687 + return generic_fs_handler(dentry, mnt, GR_WRITE | GR_SETID,
61688 + GR_CHMOD_ACL_MSG);
61689 + } else {
61690 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_CHMOD_ACL_MSG);
61691 + }
61692 +}
61693 +
61694 +__u32
61695 +gr_acl_handle_chown(const struct dentry *dentry, const struct vfsmount *mnt)
61696 +{
61697 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_CHOWN_ACL_MSG);
61698 +}
61699 +
61700 +__u32
61701 +gr_acl_handle_setxattr(const struct dentry *dentry, const struct vfsmount *mnt)
61702 +{
61703 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_SETXATTR_ACL_MSG);
61704 +}
61705 +
61706 +__u32
61707 +gr_acl_handle_execve(const struct dentry *dentry, const struct vfsmount *mnt)
61708 +{
61709 + return generic_fs_handler(dentry, mnt, GR_EXEC, GR_EXEC_ACL_MSG);
61710 +}
61711 +
61712 +__u32
61713 +gr_acl_handle_unix(const struct dentry *dentry, const struct vfsmount *mnt)
61714 +{
61715 + return generic_fs_handler(dentry, mnt, GR_READ | GR_WRITE,
61716 + GR_UNIXCONNECT_ACL_MSG);
61717 +}
61718 +
61719 +/* hardlinks require at minimum create and link permission,
61720 + any additional privilege required is based on the
61721 + privilege of the file being linked to
61722 +*/
61723 +__u32
61724 +gr_acl_handle_link(const struct dentry * new_dentry,
61725 + const struct dentry * parent_dentry,
61726 + const struct vfsmount * parent_mnt,
61727 + const struct dentry * old_dentry,
61728 + const struct vfsmount * old_mnt, const struct filename *to)
61729 +{
61730 + __u32 mode;
61731 + __u32 needmode = GR_CREATE | GR_LINK;
61732 + __u32 needaudit = GR_AUDIT_CREATE | GR_AUDIT_LINK;
61733 +
61734 + mode =
61735 + gr_check_link(new_dentry, parent_dentry, parent_mnt, old_dentry,
61736 + old_mnt);
61737 +
61738 + if (unlikely(((mode & needmode) == needmode) && (mode & needaudit))) {
61739 + gr_log_fs_rbac_str(GR_DO_AUDIT, GR_LINK_ACL_MSG, old_dentry, old_mnt, to->name);
61740 + return mode;
61741 + } else if (unlikely(((mode & needmode) != needmode) && !(mode & GR_SUPPRESS))) {
61742 + gr_log_fs_rbac_str(GR_DONT_AUDIT, GR_LINK_ACL_MSG, old_dentry, old_mnt, to->name);
61743 + return 0;
61744 + } else if (unlikely((mode & needmode) != needmode))
61745 + return 0;
61746 +
61747 + return 1;
61748 +}
61749 +
61750 +__u32
61751 +gr_acl_handle_symlink(const struct dentry * new_dentry,
61752 + const struct dentry * parent_dentry,
61753 + const struct vfsmount * parent_mnt, const struct filename *from)
61754 +{
61755 + __u32 needmode = GR_WRITE | GR_CREATE;
61756 + __u32 mode;
61757 +
61758 + mode =
61759 + gr_check_create(new_dentry, parent_dentry, parent_mnt,
61760 + GR_CREATE | GR_AUDIT_CREATE |
61761 + GR_WRITE | GR_AUDIT_WRITE | GR_SUPPRESS);
61762 +
61763 + if (unlikely(mode & GR_WRITE && mode & GR_AUDITS)) {
61764 + gr_log_fs_str_rbac(GR_DO_AUDIT, GR_SYMLINK_ACL_MSG, from->name, new_dentry, parent_mnt);
61765 + return mode;
61766 + } else if (unlikely(((mode & needmode) != needmode) && !(mode & GR_SUPPRESS))) {
61767 + gr_log_fs_str_rbac(GR_DONT_AUDIT, GR_SYMLINK_ACL_MSG, from->name, new_dentry, parent_mnt);
61768 + return 0;
61769 + } else if (unlikely((mode & needmode) != needmode))
61770 + return 0;
61771 +
61772 + return (GR_WRITE | GR_CREATE);
61773 +}
61774 +
61775 +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)
61776 +{
61777 + __u32 mode;
61778 +
61779 + mode = gr_check_create(new_dentry, parent_dentry, parent_mnt, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS);
61780 +
61781 + if (unlikely(((mode & (reqmode)) == (reqmode)) && mode & GR_AUDITS)) {
61782 + gr_log_fs_rbac_generic(GR_DO_AUDIT, fmt, new_dentry, parent_mnt);
61783 + return mode;
61784 + } else if (unlikely((mode & (reqmode)) != (reqmode) && !(mode & GR_SUPPRESS))) {
61785 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, fmt, new_dentry, parent_mnt);
61786 + return 0;
61787 + } else if (unlikely((mode & (reqmode)) != (reqmode)))
61788 + return 0;
61789 +
61790 + return (reqmode);
61791 +}
61792 +
61793 +__u32
61794 +gr_acl_handle_mknod(const struct dentry * new_dentry,
61795 + const struct dentry * parent_dentry,
61796 + const struct vfsmount * parent_mnt,
61797 + const int mode)
61798 +{
61799 + __u32 reqmode = GR_WRITE | GR_CREATE;
61800 + if (unlikely((mode & S_ISUID) || ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))))
61801 + reqmode |= GR_SETID;
61802 +
61803 + return generic_fs_create_handler(new_dentry, parent_dentry, parent_mnt,
61804 + reqmode, GR_MKNOD_ACL_MSG);
61805 +}
61806 +
61807 +__u32
61808 +gr_acl_handle_mkdir(const struct dentry *new_dentry,
61809 + const struct dentry *parent_dentry,
61810 + const struct vfsmount *parent_mnt)
61811 +{
61812 + return generic_fs_create_handler(new_dentry, parent_dentry, parent_mnt,
61813 + GR_WRITE | GR_CREATE, GR_MKDIR_ACL_MSG);
61814 +}
61815 +
61816 +#define RENAME_CHECK_SUCCESS(old, new) \
61817 + (((old & (GR_WRITE | GR_READ)) == (GR_WRITE | GR_READ)) && \
61818 + ((new & (GR_WRITE | GR_READ)) == (GR_WRITE | GR_READ)))
61819 +
61820 +int
61821 +gr_acl_handle_rename(struct dentry *new_dentry,
61822 + struct dentry *parent_dentry,
61823 + const struct vfsmount *parent_mnt,
61824 + struct dentry *old_dentry,
61825 + struct inode *old_parent_inode,
61826 + struct vfsmount *old_mnt, const struct filename *newname)
61827 +{
61828 + __u32 comp1, comp2;
61829 + int error = 0;
61830 +
61831 + if (unlikely(!gr_acl_is_enabled()))
61832 + return 0;
61833 +
61834 + if (!new_dentry->d_inode) {
61835 + comp1 = gr_check_create(new_dentry, parent_dentry, parent_mnt,
61836 + GR_READ | GR_WRITE | GR_CREATE | GR_AUDIT_READ |
61837 + GR_AUDIT_WRITE | GR_AUDIT_CREATE | GR_SUPPRESS);
61838 + comp2 = gr_search_file(old_dentry, GR_READ | GR_WRITE |
61839 + GR_DELETE | GR_AUDIT_DELETE |
61840 + GR_AUDIT_READ | GR_AUDIT_WRITE |
61841 + GR_SUPPRESS, old_mnt);
61842 + } else {
61843 + comp1 = gr_search_file(new_dentry, GR_READ | GR_WRITE |
61844 + GR_CREATE | GR_DELETE |
61845 + GR_AUDIT_CREATE | GR_AUDIT_DELETE |
61846 + GR_AUDIT_READ | GR_AUDIT_WRITE |
61847 + GR_SUPPRESS, parent_mnt);
61848 + comp2 =
61849 + gr_search_file(old_dentry,
61850 + GR_READ | GR_WRITE | GR_AUDIT_READ |
61851 + GR_DELETE | GR_AUDIT_DELETE |
61852 + GR_AUDIT_WRITE | GR_SUPPRESS, old_mnt);
61853 + }
61854 +
61855 + if (RENAME_CHECK_SUCCESS(comp1, comp2) &&
61856 + ((comp1 & GR_AUDITS) || (comp2 & GR_AUDITS)))
61857 + gr_log_fs_rbac_str(GR_DO_AUDIT, GR_RENAME_ACL_MSG, old_dentry, old_mnt, newname->name);
61858 + else if (!RENAME_CHECK_SUCCESS(comp1, comp2) && !(comp1 & GR_SUPPRESS)
61859 + && !(comp2 & GR_SUPPRESS)) {
61860 + gr_log_fs_rbac_str(GR_DONT_AUDIT, GR_RENAME_ACL_MSG, old_dentry, old_mnt, newname->name);
61861 + error = -EACCES;
61862 + } else if (unlikely(!RENAME_CHECK_SUCCESS(comp1, comp2)))
61863 + error = -EACCES;
61864 +
61865 + return error;
61866 +}
61867 +
61868 +void
61869 +gr_acl_handle_exit(void)
61870 +{
61871 + u16 id;
61872 + char *rolename;
61873 +
61874 + if (unlikely(current->acl_sp_role && gr_acl_is_enabled() &&
61875 + !(current->role->roletype & GR_ROLE_PERSIST))) {
61876 + id = current->acl_role_id;
61877 + rolename = current->role->rolename;
61878 + gr_set_acls(1);
61879 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_SPROLEL_ACL_MSG, rolename, id);
61880 + }
61881 +
61882 + gr_put_exec_file(current);
61883 + return;
61884 +}
61885 +
61886 +int
61887 +gr_acl_handle_procpidmem(const struct task_struct *task)
61888 +{
61889 + if (unlikely(!gr_acl_is_enabled()))
61890 + return 0;
61891 +
61892 + if (task != current && task->acl->mode & GR_PROTPROCFD)
61893 + return -EACCES;
61894 +
61895 + return 0;
61896 +}
61897 diff --git a/grsecurity/gracl_ip.c b/grsecurity/gracl_ip.c
61898 new file mode 100644
61899 index 0000000..4699807
61900 --- /dev/null
61901 +++ b/grsecurity/gracl_ip.c
61902 @@ -0,0 +1,384 @@
61903 +#include <linux/kernel.h>
61904 +#include <asm/uaccess.h>
61905 +#include <asm/errno.h>
61906 +#include <net/sock.h>
61907 +#include <linux/file.h>
61908 +#include <linux/fs.h>
61909 +#include <linux/net.h>
61910 +#include <linux/in.h>
61911 +#include <linux/skbuff.h>
61912 +#include <linux/ip.h>
61913 +#include <linux/udp.h>
61914 +#include <linux/types.h>
61915 +#include <linux/sched.h>
61916 +#include <linux/netdevice.h>
61917 +#include <linux/inetdevice.h>
61918 +#include <linux/gracl.h>
61919 +#include <linux/grsecurity.h>
61920 +#include <linux/grinternal.h>
61921 +
61922 +#define GR_BIND 0x01
61923 +#define GR_CONNECT 0x02
61924 +#define GR_INVERT 0x04
61925 +#define GR_BINDOVERRIDE 0x08
61926 +#define GR_CONNECTOVERRIDE 0x10
61927 +#define GR_SOCK_FAMILY 0x20
61928 +
61929 +static const char * gr_protocols[IPPROTO_MAX] = {
61930 + "ip", "icmp", "igmp", "ggp", "ipencap", "st", "tcp", "cbt",
61931 + "egp", "igp", "bbn-rcc", "nvp", "pup", "argus", "emcon", "xnet",
61932 + "chaos", "udp", "mux", "dcn", "hmp", "prm", "xns-idp", "trunk-1",
61933 + "trunk-2", "leaf-1", "leaf-2", "rdp", "irtp", "iso-tp4", "netblt", "mfe-nsp",
61934 + "merit-inp", "sep", "3pc", "idpr", "xtp", "ddp", "idpr-cmtp", "tp++",
61935 + "il", "ipv6", "sdrp", "ipv6-route", "ipv6-frag", "idrp", "rsvp", "gre",
61936 + "mhrp", "bna", "ipv6-crypt", "ipv6-auth", "i-nlsp", "swipe", "narp", "mobile",
61937 + "tlsp", "skip", "ipv6-icmp", "ipv6-nonxt", "ipv6-opts", "unknown:61", "cftp", "unknown:63",
61938 + "sat-expak", "kryptolan", "rvd", "ippc", "unknown:68", "sat-mon", "visa", "ipcv",
61939 + "cpnx", "cphb", "wsn", "pvp", "br-sat-mon", "sun-nd", "wb-mon", "wb-expak",
61940 + "iso-ip", "vmtp", "secure-vmtp", "vines", "ttp", "nfsnet-igp", "dgp", "tcf",
61941 + "eigrp", "ospf", "sprite-rpc", "larp", "mtp", "ax.25", "ipip", "micp",
61942 + "scc-sp", "etherip", "encap", "unknown:99", "gmtp", "ifmp", "pnni", "pim",
61943 + "aris", "scps", "qnx", "a/n", "ipcomp", "snp", "compaq-peer", "ipx-in-ip",
61944 + "vrrp", "pgm", "unknown:114", "l2tp", "ddx", "iatp", "stp", "srp",
61945 + "uti", "smp", "sm", "ptp", "isis", "fire", "crtp", "crdup",
61946 + "sscopmce", "iplt", "sps", "pipe", "sctp", "fc", "unkown:134", "unknown:135",
61947 + "unknown:136", "unknown:137", "unknown:138", "unknown:139", "unknown:140", "unknown:141", "unknown:142", "unknown:143",
61948 + "unknown:144", "unknown:145", "unknown:146", "unknown:147", "unknown:148", "unknown:149", "unknown:150", "unknown:151",
61949 + "unknown:152", "unknown:153", "unknown:154", "unknown:155", "unknown:156", "unknown:157", "unknown:158", "unknown:159",
61950 + "unknown:160", "unknown:161", "unknown:162", "unknown:163", "unknown:164", "unknown:165", "unknown:166", "unknown:167",
61951 + "unknown:168", "unknown:169", "unknown:170", "unknown:171", "unknown:172", "unknown:173", "unknown:174", "unknown:175",
61952 + "unknown:176", "unknown:177", "unknown:178", "unknown:179", "unknown:180", "unknown:181", "unknown:182", "unknown:183",
61953 + "unknown:184", "unknown:185", "unknown:186", "unknown:187", "unknown:188", "unknown:189", "unknown:190", "unknown:191",
61954 + "unknown:192", "unknown:193", "unknown:194", "unknown:195", "unknown:196", "unknown:197", "unknown:198", "unknown:199",
61955 + "unknown:200", "unknown:201", "unknown:202", "unknown:203", "unknown:204", "unknown:205", "unknown:206", "unknown:207",
61956 + "unknown:208", "unknown:209", "unknown:210", "unknown:211", "unknown:212", "unknown:213", "unknown:214", "unknown:215",
61957 + "unknown:216", "unknown:217", "unknown:218", "unknown:219", "unknown:220", "unknown:221", "unknown:222", "unknown:223",
61958 + "unknown:224", "unknown:225", "unknown:226", "unknown:227", "unknown:228", "unknown:229", "unknown:230", "unknown:231",
61959 + "unknown:232", "unknown:233", "unknown:234", "unknown:235", "unknown:236", "unknown:237", "unknown:238", "unknown:239",
61960 + "unknown:240", "unknown:241", "unknown:242", "unknown:243", "unknown:244", "unknown:245", "unknown:246", "unknown:247",
61961 + "unknown:248", "unknown:249", "unknown:250", "unknown:251", "unknown:252", "unknown:253", "unknown:254", "unknown:255",
61962 + };
61963 +
61964 +static const char * gr_socktypes[SOCK_MAX] = {
61965 + "unknown:0", "stream", "dgram", "raw", "rdm", "seqpacket", "unknown:6",
61966 + "unknown:7", "unknown:8", "unknown:9", "packet"
61967 + };
61968 +
61969 +static const char * gr_sockfamilies[AF_MAX+1] = {
61970 + "unspec", "unix", "inet", "ax25", "ipx", "appletalk", "netrom", "bridge", "atmpvc", "x25",
61971 + "inet6", "rose", "decnet", "netbeui", "security", "key", "netlink", "packet", "ash",
61972 + "econet", "atmsvc", "rds", "sna", "irda", "ppox", "wanpipe", "llc", "fam_27", "fam_28",
61973 + "tipc", "bluetooth", "iucv", "rxrpc", "isdn", "phonet", "ieee802154", "ciaf"
61974 + };
61975 +
61976 +const char *
61977 +gr_proto_to_name(unsigned char proto)
61978 +{
61979 + return gr_protocols[proto];
61980 +}
61981 +
61982 +const char *
61983 +gr_socktype_to_name(unsigned char type)
61984 +{
61985 + return gr_socktypes[type];
61986 +}
61987 +
61988 +const char *
61989 +gr_sockfamily_to_name(unsigned char family)
61990 +{
61991 + return gr_sockfamilies[family];
61992 +}
61993 +
61994 +int
61995 +gr_search_socket(const int domain, const int type, const int protocol)
61996 +{
61997 + struct acl_subject_label *curr;
61998 + const struct cred *cred = current_cred();
61999 +
62000 + if (unlikely(!gr_acl_is_enabled()))
62001 + goto exit;
62002 +
62003 + if ((domain < 0) || (type < 0) || (protocol < 0) ||
62004 + (domain >= AF_MAX) || (type >= SOCK_MAX) || (protocol >= IPPROTO_MAX))
62005 + goto exit; // let the kernel handle it
62006 +
62007 + curr = current->acl;
62008 +
62009 + if (curr->sock_families[domain / 32] & (1 << (domain % 32))) {
62010 + /* the family is allowed, if this is PF_INET allow it only if
62011 + the extra sock type/protocol checks pass */
62012 + if (domain == PF_INET)
62013 + goto inet_check;
62014 + goto exit;
62015 + } else {
62016 + if (curr->mode & (GR_LEARN | GR_INHERITLEARN)) {
62017 + __u32 fakeip = 0;
62018 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
62019 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
62020 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
62021 + gr_to_filename(current->exec_file->f_path.dentry,
62022 + current->exec_file->f_path.mnt) :
62023 + curr->filename, curr->filename,
62024 + &fakeip, domain, 0, 0, GR_SOCK_FAMILY,
62025 + &current->signal->saved_ip);
62026 + goto exit;
62027 + }
62028 + goto exit_fail;
62029 + }
62030 +
62031 +inet_check:
62032 + /* the rest of this checking is for IPv4 only */
62033 + if (!curr->ips)
62034 + goto exit;
62035 +
62036 + if ((curr->ip_type & (1 << type)) &&
62037 + (curr->ip_proto[protocol / 32] & (1 << (protocol % 32))))
62038 + goto exit;
62039 +
62040 + if (curr->mode & (GR_LEARN | GR_INHERITLEARN)) {
62041 + /* we don't place acls on raw sockets , and sometimes
62042 + dgram/ip sockets are opened for ioctl and not
62043 + bind/connect, so we'll fake a bind learn log */
62044 + if (type == SOCK_RAW || type == SOCK_PACKET) {
62045 + __u32 fakeip = 0;
62046 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
62047 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
62048 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
62049 + gr_to_filename(current->exec_file->f_path.dentry,
62050 + current->exec_file->f_path.mnt) :
62051 + curr->filename, curr->filename,
62052 + &fakeip, 0, type,
62053 + protocol, GR_CONNECT, &current->signal->saved_ip);
62054 + } else if ((type == SOCK_DGRAM) && (protocol == IPPROTO_IP)) {
62055 + __u32 fakeip = 0;
62056 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
62057 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
62058 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
62059 + gr_to_filename(current->exec_file->f_path.dentry,
62060 + current->exec_file->f_path.mnt) :
62061 + curr->filename, curr->filename,
62062 + &fakeip, 0, type,
62063 + protocol, GR_BIND, &current->signal->saved_ip);
62064 + }
62065 + /* we'll log when they use connect or bind */
62066 + goto exit;
62067 + }
62068 +
62069 +exit_fail:
62070 + if (domain == PF_INET)
62071 + gr_log_str3(GR_DONT_AUDIT, GR_SOCK_MSG, gr_sockfamily_to_name(domain),
62072 + gr_socktype_to_name(type), gr_proto_to_name(protocol));
62073 + else
62074 + gr_log_str2_int(GR_DONT_AUDIT, GR_SOCK_NOINET_MSG, gr_sockfamily_to_name(domain),
62075 + gr_socktype_to_name(type), protocol);
62076 +
62077 + return 0;
62078 +exit:
62079 + return 1;
62080 +}
62081 +
62082 +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)
62083 +{
62084 + if ((ip->mode & mode) &&
62085 + (ip_port >= ip->low) &&
62086 + (ip_port <= ip->high) &&
62087 + ((ntohl(ip_addr) & our_netmask) ==
62088 + (ntohl(our_addr) & our_netmask))
62089 + && (ip->proto[protocol / 32] & (1 << (protocol % 32)))
62090 + && (ip->type & (1 << type))) {
62091 + if (ip->mode & GR_INVERT)
62092 + return 2; // specifically denied
62093 + else
62094 + return 1; // allowed
62095 + }
62096 +
62097 + return 0; // not specifically allowed, may continue parsing
62098 +}
62099 +
62100 +static int
62101 +gr_search_connectbind(const int full_mode, struct sock *sk,
62102 + struct sockaddr_in *addr, const int type)
62103 +{
62104 + char iface[IFNAMSIZ] = {0};
62105 + struct acl_subject_label *curr;
62106 + struct acl_ip_label *ip;
62107 + struct inet_sock *isk;
62108 + struct net_device *dev;
62109 + struct in_device *idev;
62110 + unsigned long i;
62111 + int ret;
62112 + int mode = full_mode & (GR_BIND | GR_CONNECT);
62113 + __u32 ip_addr = 0;
62114 + __u32 our_addr;
62115 + __u32 our_netmask;
62116 + char *p;
62117 + __u16 ip_port = 0;
62118 + const struct cred *cred = current_cred();
62119 +
62120 + if (unlikely(!gr_acl_is_enabled() || sk->sk_family != PF_INET))
62121 + return 0;
62122 +
62123 + curr = current->acl;
62124 + isk = inet_sk(sk);
62125 +
62126 + /* INADDR_ANY overriding for binds, inaddr_any_override is already in network order */
62127 + if ((full_mode & GR_BINDOVERRIDE) && addr->sin_addr.s_addr == htonl(INADDR_ANY) && curr->inaddr_any_override != 0)
62128 + addr->sin_addr.s_addr = curr->inaddr_any_override;
62129 + if ((full_mode & GR_CONNECT) && isk->inet_saddr == htonl(INADDR_ANY) && curr->inaddr_any_override != 0) {
62130 + struct sockaddr_in saddr;
62131 + int err;
62132 +
62133 + saddr.sin_family = AF_INET;
62134 + saddr.sin_addr.s_addr = curr->inaddr_any_override;
62135 + saddr.sin_port = isk->inet_sport;
62136 +
62137 + err = security_socket_bind(sk->sk_socket, (struct sockaddr *)&saddr, sizeof(struct sockaddr_in));
62138 + if (err)
62139 + return err;
62140 +
62141 + err = sk->sk_socket->ops->bind(sk->sk_socket, (struct sockaddr *)&saddr, sizeof(struct sockaddr_in));
62142 + if (err)
62143 + return err;
62144 + }
62145 +
62146 + if (!curr->ips)
62147 + return 0;
62148 +
62149 + ip_addr = addr->sin_addr.s_addr;
62150 + ip_port = ntohs(addr->sin_port);
62151 +
62152 + if (curr->mode & (GR_LEARN | GR_INHERITLEARN)) {
62153 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
62154 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
62155 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
62156 + gr_to_filename(current->exec_file->f_path.dentry,
62157 + current->exec_file->f_path.mnt) :
62158 + curr->filename, curr->filename,
62159 + &ip_addr, ip_port, type,
62160 + sk->sk_protocol, mode, &current->signal->saved_ip);
62161 + return 0;
62162 + }
62163 +
62164 + for (i = 0; i < curr->ip_num; i++) {
62165 + ip = *(curr->ips + i);
62166 + if (ip->iface != NULL) {
62167 + strncpy(iface, ip->iface, IFNAMSIZ - 1);
62168 + p = strchr(iface, ':');
62169 + if (p != NULL)
62170 + *p = '\0';
62171 + dev = dev_get_by_name(sock_net(sk), iface);
62172 + if (dev == NULL)
62173 + continue;
62174 + idev = in_dev_get(dev);
62175 + if (idev == NULL) {
62176 + dev_put(dev);
62177 + continue;
62178 + }
62179 + rcu_read_lock();
62180 + for_ifa(idev) {
62181 + if (!strcmp(ip->iface, ifa->ifa_label)) {
62182 + our_addr = ifa->ifa_address;
62183 + our_netmask = 0xffffffff;
62184 + ret = check_ip_policy(ip, ip_addr, ip_port, sk->sk_protocol, mode, type, our_addr, our_netmask);
62185 + if (ret == 1) {
62186 + rcu_read_unlock();
62187 + in_dev_put(idev);
62188 + dev_put(dev);
62189 + return 0;
62190 + } else if (ret == 2) {
62191 + rcu_read_unlock();
62192 + in_dev_put(idev);
62193 + dev_put(dev);
62194 + goto denied;
62195 + }
62196 + }
62197 + } endfor_ifa(idev);
62198 + rcu_read_unlock();
62199 + in_dev_put(idev);
62200 + dev_put(dev);
62201 + } else {
62202 + our_addr = ip->addr;
62203 + our_netmask = ip->netmask;
62204 + ret = check_ip_policy(ip, ip_addr, ip_port, sk->sk_protocol, mode, type, our_addr, our_netmask);
62205 + if (ret == 1)
62206 + return 0;
62207 + else if (ret == 2)
62208 + goto denied;
62209 + }
62210 + }
62211 +
62212 +denied:
62213 + if (mode == GR_BIND)
62214 + 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));
62215 + else if (mode == GR_CONNECT)
62216 + 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));
62217 +
62218 + return -EACCES;
62219 +}
62220 +
62221 +int
62222 +gr_search_connect(struct socket *sock, struct sockaddr_in *addr)
62223 +{
62224 + /* always allow disconnection of dgram sockets with connect */
62225 + if (addr->sin_family == AF_UNSPEC)
62226 + return 0;
62227 + return gr_search_connectbind(GR_CONNECT | GR_CONNECTOVERRIDE, sock->sk, addr, sock->type);
62228 +}
62229 +
62230 +int
62231 +gr_search_bind(struct socket *sock, struct sockaddr_in *addr)
62232 +{
62233 + return gr_search_connectbind(GR_BIND | GR_BINDOVERRIDE, sock->sk, addr, sock->type);
62234 +}
62235 +
62236 +int gr_search_listen(struct socket *sock)
62237 +{
62238 + struct sock *sk = sock->sk;
62239 + struct sockaddr_in addr;
62240 +
62241 + addr.sin_addr.s_addr = inet_sk(sk)->inet_saddr;
62242 + addr.sin_port = inet_sk(sk)->inet_sport;
62243 +
62244 + return gr_search_connectbind(GR_BIND | GR_CONNECTOVERRIDE, sock->sk, &addr, sock->type);
62245 +}
62246 +
62247 +int gr_search_accept(struct socket *sock)
62248 +{
62249 + struct sock *sk = sock->sk;
62250 + struct sockaddr_in addr;
62251 +
62252 + addr.sin_addr.s_addr = inet_sk(sk)->inet_saddr;
62253 + addr.sin_port = inet_sk(sk)->inet_sport;
62254 +
62255 + return gr_search_connectbind(GR_BIND | GR_CONNECTOVERRIDE, sock->sk, &addr, sock->type);
62256 +}
62257 +
62258 +int
62259 +gr_search_udp_sendmsg(struct sock *sk, struct sockaddr_in *addr)
62260 +{
62261 + if (addr)
62262 + return gr_search_connectbind(GR_CONNECT, sk, addr, SOCK_DGRAM);
62263 + else {
62264 + struct sockaddr_in sin;
62265 + const struct inet_sock *inet = inet_sk(sk);
62266 +
62267 + sin.sin_addr.s_addr = inet->inet_daddr;
62268 + sin.sin_port = inet->inet_dport;
62269 +
62270 + return gr_search_connectbind(GR_CONNECT | GR_CONNECTOVERRIDE, sk, &sin, SOCK_DGRAM);
62271 + }
62272 +}
62273 +
62274 +int
62275 +gr_search_udp_recvmsg(struct sock *sk, const struct sk_buff *skb)
62276 +{
62277 + struct sockaddr_in sin;
62278 +
62279 + if (unlikely(skb->len < sizeof (struct udphdr)))
62280 + return 0; // skip this packet
62281 +
62282 + sin.sin_addr.s_addr = ip_hdr(skb)->saddr;
62283 + sin.sin_port = udp_hdr(skb)->source;
62284 +
62285 + return gr_search_connectbind(GR_CONNECT | GR_CONNECTOVERRIDE, sk, &sin, SOCK_DGRAM);
62286 +}
62287 diff --git a/grsecurity/gracl_learn.c b/grsecurity/gracl_learn.c
62288 new file mode 100644
62289 index 0000000..25f54ef
62290 --- /dev/null
62291 +++ b/grsecurity/gracl_learn.c
62292 @@ -0,0 +1,207 @@
62293 +#include <linux/kernel.h>
62294 +#include <linux/mm.h>
62295 +#include <linux/sched.h>
62296 +#include <linux/poll.h>
62297 +#include <linux/string.h>
62298 +#include <linux/file.h>
62299 +#include <linux/types.h>
62300 +#include <linux/vmalloc.h>
62301 +#include <linux/grinternal.h>
62302 +
62303 +extern ssize_t write_grsec_handler(struct file * file, const char __user * buf,
62304 + size_t count, loff_t *ppos);
62305 +extern int gr_acl_is_enabled(void);
62306 +
62307 +static DECLARE_WAIT_QUEUE_HEAD(learn_wait);
62308 +static int gr_learn_attached;
62309 +
62310 +/* use a 512k buffer */
62311 +#define LEARN_BUFFER_SIZE (512 * 1024)
62312 +
62313 +static DEFINE_SPINLOCK(gr_learn_lock);
62314 +static DEFINE_MUTEX(gr_learn_user_mutex);
62315 +
62316 +/* we need to maintain two buffers, so that the kernel context of grlearn
62317 + uses a semaphore around the userspace copying, and the other kernel contexts
62318 + use a spinlock when copying into the buffer, since they cannot sleep
62319 +*/
62320 +static char *learn_buffer;
62321 +static char *learn_buffer_user;
62322 +static int learn_buffer_len;
62323 +static int learn_buffer_user_len;
62324 +
62325 +static ssize_t
62326 +read_learn(struct file *file, char __user * buf, size_t count, loff_t * ppos)
62327 +{
62328 + DECLARE_WAITQUEUE(wait, current);
62329 + ssize_t retval = 0;
62330 +
62331 + add_wait_queue(&learn_wait, &wait);
62332 + set_current_state(TASK_INTERRUPTIBLE);
62333 + do {
62334 + mutex_lock(&gr_learn_user_mutex);
62335 + spin_lock(&gr_learn_lock);
62336 + if (learn_buffer_len)
62337 + break;
62338 + spin_unlock(&gr_learn_lock);
62339 + mutex_unlock(&gr_learn_user_mutex);
62340 + if (file->f_flags & O_NONBLOCK) {
62341 + retval = -EAGAIN;
62342 + goto out;
62343 + }
62344 + if (signal_pending(current)) {
62345 + retval = -ERESTARTSYS;
62346 + goto out;
62347 + }
62348 +
62349 + schedule();
62350 + } while (1);
62351 +
62352 + memcpy(learn_buffer_user, learn_buffer, learn_buffer_len);
62353 + learn_buffer_user_len = learn_buffer_len;
62354 + retval = learn_buffer_len;
62355 + learn_buffer_len = 0;
62356 +
62357 + spin_unlock(&gr_learn_lock);
62358 +
62359 + if (copy_to_user(buf, learn_buffer_user, learn_buffer_user_len))
62360 + retval = -EFAULT;
62361 +
62362 + mutex_unlock(&gr_learn_user_mutex);
62363 +out:
62364 + set_current_state(TASK_RUNNING);
62365 + remove_wait_queue(&learn_wait, &wait);
62366 + return retval;
62367 +}
62368 +
62369 +static unsigned int
62370 +poll_learn(struct file * file, poll_table * wait)
62371 +{
62372 + poll_wait(file, &learn_wait, wait);
62373 +
62374 + if (learn_buffer_len)
62375 + return (POLLIN | POLLRDNORM);
62376 +
62377 + return 0;
62378 +}
62379 +
62380 +void
62381 +gr_clear_learn_entries(void)
62382 +{
62383 + char *tmp;
62384 +
62385 + mutex_lock(&gr_learn_user_mutex);
62386 + spin_lock(&gr_learn_lock);
62387 + tmp = learn_buffer;
62388 + learn_buffer = NULL;
62389 + spin_unlock(&gr_learn_lock);
62390 + if (tmp)
62391 + vfree(tmp);
62392 + if (learn_buffer_user != NULL) {
62393 + vfree(learn_buffer_user);
62394 + learn_buffer_user = NULL;
62395 + }
62396 + learn_buffer_len = 0;
62397 + mutex_unlock(&gr_learn_user_mutex);
62398 +
62399 + return;
62400 +}
62401 +
62402 +void
62403 +gr_add_learn_entry(const char *fmt, ...)
62404 +{
62405 + va_list args;
62406 + unsigned int len;
62407 +
62408 + if (!gr_learn_attached)
62409 + return;
62410 +
62411 + spin_lock(&gr_learn_lock);
62412 +
62413 + /* leave a gap at the end so we know when it's "full" but don't have to
62414 + compute the exact length of the string we're trying to append
62415 + */
62416 + if (learn_buffer_len > LEARN_BUFFER_SIZE - 16384) {
62417 + spin_unlock(&gr_learn_lock);
62418 + wake_up_interruptible(&learn_wait);
62419 + return;
62420 + }
62421 + if (learn_buffer == NULL) {
62422 + spin_unlock(&gr_learn_lock);
62423 + return;
62424 + }
62425 +
62426 + va_start(args, fmt);
62427 + len = vsnprintf(learn_buffer + learn_buffer_len, LEARN_BUFFER_SIZE - learn_buffer_len, fmt, args);
62428 + va_end(args);
62429 +
62430 + learn_buffer_len += len + 1;
62431 +
62432 + spin_unlock(&gr_learn_lock);
62433 + wake_up_interruptible(&learn_wait);
62434 +
62435 + return;
62436 +}
62437 +
62438 +static int
62439 +open_learn(struct inode *inode, struct file *file)
62440 +{
62441 + if (file->f_mode & FMODE_READ && gr_learn_attached)
62442 + return -EBUSY;
62443 + if (file->f_mode & FMODE_READ) {
62444 + int retval = 0;
62445 + mutex_lock(&gr_learn_user_mutex);
62446 + if (learn_buffer == NULL)
62447 + learn_buffer = vmalloc(LEARN_BUFFER_SIZE);
62448 + if (learn_buffer_user == NULL)
62449 + learn_buffer_user = vmalloc(LEARN_BUFFER_SIZE);
62450 + if (learn_buffer == NULL) {
62451 + retval = -ENOMEM;
62452 + goto out_error;
62453 + }
62454 + if (learn_buffer_user == NULL) {
62455 + retval = -ENOMEM;
62456 + goto out_error;
62457 + }
62458 + learn_buffer_len = 0;
62459 + learn_buffer_user_len = 0;
62460 + gr_learn_attached = 1;
62461 +out_error:
62462 + mutex_unlock(&gr_learn_user_mutex);
62463 + return retval;
62464 + }
62465 + return 0;
62466 +}
62467 +
62468 +static int
62469 +close_learn(struct inode *inode, struct file *file)
62470 +{
62471 + if (file->f_mode & FMODE_READ) {
62472 + char *tmp = NULL;
62473 + mutex_lock(&gr_learn_user_mutex);
62474 + spin_lock(&gr_learn_lock);
62475 + tmp = learn_buffer;
62476 + learn_buffer = NULL;
62477 + spin_unlock(&gr_learn_lock);
62478 + if (tmp)
62479 + vfree(tmp);
62480 + if (learn_buffer_user != NULL) {
62481 + vfree(learn_buffer_user);
62482 + learn_buffer_user = NULL;
62483 + }
62484 + learn_buffer_len = 0;
62485 + learn_buffer_user_len = 0;
62486 + gr_learn_attached = 0;
62487 + mutex_unlock(&gr_learn_user_mutex);
62488 + }
62489 +
62490 + return 0;
62491 +}
62492 +
62493 +const struct file_operations grsec_fops = {
62494 + .read = read_learn,
62495 + .write = write_grsec_handler,
62496 + .open = open_learn,
62497 + .release = close_learn,
62498 + .poll = poll_learn,
62499 +};
62500 diff --git a/grsecurity/gracl_res.c b/grsecurity/gracl_res.c
62501 new file mode 100644
62502 index 0000000..39645c9
62503 --- /dev/null
62504 +++ b/grsecurity/gracl_res.c
62505 @@ -0,0 +1,68 @@
62506 +#include <linux/kernel.h>
62507 +#include <linux/sched.h>
62508 +#include <linux/gracl.h>
62509 +#include <linux/grinternal.h>
62510 +
62511 +static const char *restab_log[] = {
62512 + [RLIMIT_CPU] = "RLIMIT_CPU",
62513 + [RLIMIT_FSIZE] = "RLIMIT_FSIZE",
62514 + [RLIMIT_DATA] = "RLIMIT_DATA",
62515 + [RLIMIT_STACK] = "RLIMIT_STACK",
62516 + [RLIMIT_CORE] = "RLIMIT_CORE",
62517 + [RLIMIT_RSS] = "RLIMIT_RSS",
62518 + [RLIMIT_NPROC] = "RLIMIT_NPROC",
62519 + [RLIMIT_NOFILE] = "RLIMIT_NOFILE",
62520 + [RLIMIT_MEMLOCK] = "RLIMIT_MEMLOCK",
62521 + [RLIMIT_AS] = "RLIMIT_AS",
62522 + [RLIMIT_LOCKS] = "RLIMIT_LOCKS",
62523 + [RLIMIT_SIGPENDING] = "RLIMIT_SIGPENDING",
62524 + [RLIMIT_MSGQUEUE] = "RLIMIT_MSGQUEUE",
62525 + [RLIMIT_NICE] = "RLIMIT_NICE",
62526 + [RLIMIT_RTPRIO] = "RLIMIT_RTPRIO",
62527 + [RLIMIT_RTTIME] = "RLIMIT_RTTIME",
62528 + [GR_CRASH_RES] = "RLIMIT_CRASH"
62529 +};
62530 +
62531 +void
62532 +gr_log_resource(const struct task_struct *task,
62533 + const int res, const unsigned long wanted, const int gt)
62534 +{
62535 + const struct cred *cred;
62536 + unsigned long rlim;
62537 +
62538 + if (!gr_acl_is_enabled() && !grsec_resource_logging)
62539 + return;
62540 +
62541 + // not yet supported resource
62542 + if (unlikely(!restab_log[res]))
62543 + return;
62544 +
62545 + if (res == RLIMIT_CPU || res == RLIMIT_RTTIME)
62546 + rlim = task_rlimit_max(task, res);
62547 + else
62548 + rlim = task_rlimit(task, res);
62549 +
62550 + if (likely((rlim == RLIM_INFINITY) || (gt && wanted <= rlim) || (!gt && wanted < rlim)))
62551 + return;
62552 +
62553 + rcu_read_lock();
62554 + cred = __task_cred(task);
62555 +
62556 + if (res == RLIMIT_NPROC &&
62557 + (cap_raised(cred->cap_effective, CAP_SYS_ADMIN) ||
62558 + cap_raised(cred->cap_effective, CAP_SYS_RESOURCE)))
62559 + goto out_rcu_unlock;
62560 + else if (res == RLIMIT_MEMLOCK &&
62561 + cap_raised(cred->cap_effective, CAP_IPC_LOCK))
62562 + goto out_rcu_unlock;
62563 + else if (res == RLIMIT_NICE && cap_raised(cred->cap_effective, CAP_SYS_NICE))
62564 + goto out_rcu_unlock;
62565 + rcu_read_unlock();
62566 +
62567 + gr_log_res_ulong2_str(GR_DONT_AUDIT, GR_RESOURCE_MSG, task, wanted, restab_log[res], rlim);
62568 +
62569 + return;
62570 +out_rcu_unlock:
62571 + rcu_read_unlock();
62572 + return;
62573 +}
62574 diff --git a/grsecurity/gracl_segv.c b/grsecurity/gracl_segv.c
62575 new file mode 100644
62576 index 0000000..8c8fc9d
62577 --- /dev/null
62578 +++ b/grsecurity/gracl_segv.c
62579 @@ -0,0 +1,303 @@
62580 +#include <linux/kernel.h>
62581 +#include <linux/mm.h>
62582 +#include <asm/uaccess.h>
62583 +#include <asm/errno.h>
62584 +#include <asm/mman.h>
62585 +#include <net/sock.h>
62586 +#include <linux/file.h>
62587 +#include <linux/fs.h>
62588 +#include <linux/net.h>
62589 +#include <linux/in.h>
62590 +#include <linux/slab.h>
62591 +#include <linux/types.h>
62592 +#include <linux/sched.h>
62593 +#include <linux/timer.h>
62594 +#include <linux/gracl.h>
62595 +#include <linux/grsecurity.h>
62596 +#include <linux/grinternal.h>
62597 +
62598 +static struct crash_uid *uid_set;
62599 +static unsigned short uid_used;
62600 +static DEFINE_SPINLOCK(gr_uid_lock);
62601 +extern rwlock_t gr_inode_lock;
62602 +extern struct acl_subject_label *
62603 + lookup_acl_subj_label(const ino_t inode, const dev_t dev,
62604 + struct acl_role_label *role);
62605 +
62606 +#ifdef CONFIG_BTRFS_FS
62607 +extern dev_t get_btrfs_dev_from_inode(struct inode *inode);
62608 +extern int btrfs_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat);
62609 +#endif
62610 +
62611 +static inline dev_t __get_dev(const struct dentry *dentry)
62612 +{
62613 +#ifdef CONFIG_BTRFS_FS
62614 + if (dentry->d_inode->i_op && dentry->d_inode->i_op->getattr == &btrfs_getattr)
62615 + return get_btrfs_dev_from_inode(dentry->d_inode);
62616 + else
62617 +#endif
62618 + return dentry->d_inode->i_sb->s_dev;
62619 +}
62620 +
62621 +int
62622 +gr_init_uidset(void)
62623 +{
62624 + uid_set =
62625 + kmalloc(GR_UIDTABLE_MAX * sizeof (struct crash_uid), GFP_KERNEL);
62626 + uid_used = 0;
62627 +
62628 + return uid_set ? 1 : 0;
62629 +}
62630 +
62631 +void
62632 +gr_free_uidset(void)
62633 +{
62634 + if (uid_set)
62635 + kfree(uid_set);
62636 +
62637 + return;
62638 +}
62639 +
62640 +int
62641 +gr_find_uid(const uid_t uid)
62642 +{
62643 + struct crash_uid *tmp = uid_set;
62644 + uid_t buid;
62645 + int low = 0, high = uid_used - 1, mid;
62646 +
62647 + while (high >= low) {
62648 + mid = (low + high) >> 1;
62649 + buid = tmp[mid].uid;
62650 + if (buid == uid)
62651 + return mid;
62652 + if (buid > uid)
62653 + high = mid - 1;
62654 + if (buid < uid)
62655 + low = mid + 1;
62656 + }
62657 +
62658 + return -1;
62659 +}
62660 +
62661 +static __inline__ void
62662 +gr_insertsort(void)
62663 +{
62664 + unsigned short i, j;
62665 + struct crash_uid index;
62666 +
62667 + for (i = 1; i < uid_used; i++) {
62668 + index = uid_set[i];
62669 + j = i;
62670 + while ((j > 0) && uid_set[j - 1].uid > index.uid) {
62671 + uid_set[j] = uid_set[j - 1];
62672 + j--;
62673 + }
62674 + uid_set[j] = index;
62675 + }
62676 +
62677 + return;
62678 +}
62679 +
62680 +static __inline__ void
62681 +gr_insert_uid(const kuid_t kuid, const unsigned long expires)
62682 +{
62683 + int loc;
62684 + uid_t uid = GR_GLOBAL_UID(kuid);
62685 +
62686 + if (uid_used == GR_UIDTABLE_MAX)
62687 + return;
62688 +
62689 + loc = gr_find_uid(uid);
62690 +
62691 + if (loc >= 0) {
62692 + uid_set[loc].expires = expires;
62693 + return;
62694 + }
62695 +
62696 + uid_set[uid_used].uid = uid;
62697 + uid_set[uid_used].expires = expires;
62698 + uid_used++;
62699 +
62700 + gr_insertsort();
62701 +
62702 + return;
62703 +}
62704 +
62705 +void
62706 +gr_remove_uid(const unsigned short loc)
62707 +{
62708 + unsigned short i;
62709 +
62710 + for (i = loc + 1; i < uid_used; i++)
62711 + uid_set[i - 1] = uid_set[i];
62712 +
62713 + uid_used--;
62714 +
62715 + return;
62716 +}
62717 +
62718 +int
62719 +gr_check_crash_uid(const kuid_t kuid)
62720 +{
62721 + int loc;
62722 + int ret = 0;
62723 + uid_t uid;
62724 +
62725 + if (unlikely(!gr_acl_is_enabled()))
62726 + return 0;
62727 +
62728 + uid = GR_GLOBAL_UID(kuid);
62729 +
62730 + spin_lock(&gr_uid_lock);
62731 + loc = gr_find_uid(uid);
62732 +
62733 + if (loc < 0)
62734 + goto out_unlock;
62735 +
62736 + if (time_before_eq(uid_set[loc].expires, get_seconds()))
62737 + gr_remove_uid(loc);
62738 + else
62739 + ret = 1;
62740 +
62741 +out_unlock:
62742 + spin_unlock(&gr_uid_lock);
62743 + return ret;
62744 +}
62745 +
62746 +static __inline__ int
62747 +proc_is_setxid(const struct cred *cred)
62748 +{
62749 + if (!uid_eq(cred->uid, cred->euid) || !uid_eq(cred->uid, cred->suid) ||
62750 + !uid_eq(cred->uid, cred->fsuid))
62751 + return 1;
62752 + if (!gid_eq(cred->gid, cred->egid) || !gid_eq(cred->gid, cred->sgid) ||
62753 + !gid_eq(cred->gid, cred->fsgid))
62754 + return 1;
62755 +
62756 + return 0;
62757 +}
62758 +
62759 +extern int gr_fake_force_sig(int sig, struct task_struct *t);
62760 +
62761 +void
62762 +gr_handle_crash(struct task_struct *task, const int sig)
62763 +{
62764 + struct acl_subject_label *curr;
62765 + struct task_struct *tsk, *tsk2;
62766 + const struct cred *cred;
62767 + const struct cred *cred2;
62768 +
62769 + if (sig != SIGSEGV && sig != SIGKILL && sig != SIGBUS && sig != SIGILL)
62770 + return;
62771 +
62772 + if (unlikely(!gr_acl_is_enabled()))
62773 + return;
62774 +
62775 + curr = task->acl;
62776 +
62777 + if (!(curr->resmask & (1 << GR_CRASH_RES)))
62778 + return;
62779 +
62780 + if (time_before_eq(curr->expires, get_seconds())) {
62781 + curr->expires = 0;
62782 + curr->crashes = 0;
62783 + }
62784 +
62785 + curr->crashes++;
62786 +
62787 + if (!curr->expires)
62788 + curr->expires = get_seconds() + curr->res[GR_CRASH_RES].rlim_max;
62789 +
62790 + if ((curr->crashes >= curr->res[GR_CRASH_RES].rlim_cur) &&
62791 + time_after(curr->expires, get_seconds())) {
62792 + rcu_read_lock();
62793 + cred = __task_cred(task);
62794 + if (gr_is_global_nonroot(cred->uid) && proc_is_setxid(cred)) {
62795 + gr_log_crash1(GR_DONT_AUDIT, GR_SEGVSTART_ACL_MSG, task, curr->res[GR_CRASH_RES].rlim_max);
62796 + spin_lock(&gr_uid_lock);
62797 + gr_insert_uid(cred->uid, curr->expires);
62798 + spin_unlock(&gr_uid_lock);
62799 + curr->expires = 0;
62800 + curr->crashes = 0;
62801 + read_lock(&tasklist_lock);
62802 + do_each_thread(tsk2, tsk) {
62803 + cred2 = __task_cred(tsk);
62804 + if (tsk != task && uid_eq(cred2->uid, cred->uid))
62805 + gr_fake_force_sig(SIGKILL, tsk);
62806 + } while_each_thread(tsk2, tsk);
62807 + read_unlock(&tasklist_lock);
62808 + } else {
62809 + gr_log_crash2(GR_DONT_AUDIT, GR_SEGVNOSUID_ACL_MSG, task, curr->res[GR_CRASH_RES].rlim_max);
62810 + read_lock(&tasklist_lock);
62811 + read_lock(&grsec_exec_file_lock);
62812 + do_each_thread(tsk2, tsk) {
62813 + if (likely(tsk != task)) {
62814 + // if this thread has the same subject as the one that triggered
62815 + // RES_CRASH and it's the same binary, kill it
62816 + if (tsk->acl == task->acl && tsk->exec_file == task->exec_file)
62817 + gr_fake_force_sig(SIGKILL, tsk);
62818 + }
62819 + } while_each_thread(tsk2, tsk);
62820 + read_unlock(&grsec_exec_file_lock);
62821 + read_unlock(&tasklist_lock);
62822 + }
62823 + rcu_read_unlock();
62824 + }
62825 +
62826 + return;
62827 +}
62828 +
62829 +int
62830 +gr_check_crash_exec(const struct file *filp)
62831 +{
62832 + struct acl_subject_label *curr;
62833 +
62834 + if (unlikely(!gr_acl_is_enabled()))
62835 + return 0;
62836 +
62837 + read_lock(&gr_inode_lock);
62838 + curr = lookup_acl_subj_label(filp->f_path.dentry->d_inode->i_ino,
62839 + __get_dev(filp->f_path.dentry),
62840 + current->role);
62841 + read_unlock(&gr_inode_lock);
62842 +
62843 + if (!curr || !(curr->resmask & (1 << GR_CRASH_RES)) ||
62844 + (!curr->crashes && !curr->expires))
62845 + return 0;
62846 +
62847 + if ((curr->crashes >= curr->res[GR_CRASH_RES].rlim_cur) &&
62848 + time_after(curr->expires, get_seconds()))
62849 + return 1;
62850 + else if (time_before_eq(curr->expires, get_seconds())) {
62851 + curr->crashes = 0;
62852 + curr->expires = 0;
62853 + }
62854 +
62855 + return 0;
62856 +}
62857 +
62858 +void
62859 +gr_handle_alertkill(struct task_struct *task)
62860 +{
62861 + struct acl_subject_label *curracl;
62862 + __u32 curr_ip;
62863 + struct task_struct *p, *p2;
62864 +
62865 + if (unlikely(!gr_acl_is_enabled()))
62866 + return;
62867 +
62868 + curracl = task->acl;
62869 + curr_ip = task->signal->curr_ip;
62870 +
62871 + if ((curracl->mode & GR_KILLIPPROC) && curr_ip) {
62872 + read_lock(&tasklist_lock);
62873 + do_each_thread(p2, p) {
62874 + if (p->signal->curr_ip == curr_ip)
62875 + gr_fake_force_sig(SIGKILL, p);
62876 + } while_each_thread(p2, p);
62877 + read_unlock(&tasklist_lock);
62878 + } else if (curracl->mode & GR_KILLPROC)
62879 + gr_fake_force_sig(SIGKILL, task);
62880 +
62881 + return;
62882 +}
62883 diff --git a/grsecurity/gracl_shm.c b/grsecurity/gracl_shm.c
62884 new file mode 100644
62885 index 0000000..98011b0
62886 --- /dev/null
62887 +++ b/grsecurity/gracl_shm.c
62888 @@ -0,0 +1,40 @@
62889 +#include <linux/kernel.h>
62890 +#include <linux/mm.h>
62891 +#include <linux/sched.h>
62892 +#include <linux/file.h>
62893 +#include <linux/ipc.h>
62894 +#include <linux/gracl.h>
62895 +#include <linux/grsecurity.h>
62896 +#include <linux/grinternal.h>
62897 +
62898 +int
62899 +gr_handle_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
62900 + const time_t shm_createtime, const kuid_t cuid, const int shmid)
62901 +{
62902 + struct task_struct *task;
62903 +
62904 + if (!gr_acl_is_enabled())
62905 + return 1;
62906 +
62907 + rcu_read_lock();
62908 + read_lock(&tasklist_lock);
62909 +
62910 + task = find_task_by_vpid(shm_cprid);
62911 +
62912 + if (unlikely(!task))
62913 + task = find_task_by_vpid(shm_lapid);
62914 +
62915 + if (unlikely(task && (time_before_eq((unsigned long)task->start_time.tv_sec, (unsigned long)shm_createtime) ||
62916 + (task_pid_nr(task) == shm_lapid)) &&
62917 + (task->acl->mode & GR_PROTSHM) &&
62918 + (task->acl != current->acl))) {
62919 + read_unlock(&tasklist_lock);
62920 + rcu_read_unlock();
62921 + gr_log_int3(GR_DONT_AUDIT, GR_SHMAT_ACL_MSG, GR_GLOBAL_UID(cuid), shm_cprid, shmid);
62922 + return 0;
62923 + }
62924 + read_unlock(&tasklist_lock);
62925 + rcu_read_unlock();
62926 +
62927 + return 1;
62928 +}
62929 diff --git a/grsecurity/grsec_chdir.c b/grsecurity/grsec_chdir.c
62930 new file mode 100644
62931 index 0000000..bc0be01
62932 --- /dev/null
62933 +++ b/grsecurity/grsec_chdir.c
62934 @@ -0,0 +1,19 @@
62935 +#include <linux/kernel.h>
62936 +#include <linux/sched.h>
62937 +#include <linux/fs.h>
62938 +#include <linux/file.h>
62939 +#include <linux/grsecurity.h>
62940 +#include <linux/grinternal.h>
62941 +
62942 +void
62943 +gr_log_chdir(const struct dentry *dentry, const struct vfsmount *mnt)
62944 +{
62945 +#ifdef CONFIG_GRKERNSEC_AUDIT_CHDIR
62946 + if ((grsec_enable_chdir && grsec_enable_group &&
62947 + in_group_p(grsec_audit_gid)) || (grsec_enable_chdir &&
62948 + !grsec_enable_group)) {
62949 + gr_log_fs_generic(GR_DO_AUDIT, GR_CHDIR_AUDIT_MSG, dentry, mnt);
62950 + }
62951 +#endif
62952 + return;
62953 +}
62954 diff --git a/grsecurity/grsec_chroot.c b/grsecurity/grsec_chroot.c
62955 new file mode 100644
62956 index 0000000..6d2de57
62957 --- /dev/null
62958 +++ b/grsecurity/grsec_chroot.c
62959 @@ -0,0 +1,357 @@
62960 +#include <linux/kernel.h>
62961 +#include <linux/module.h>
62962 +#include <linux/sched.h>
62963 +#include <linux/file.h>
62964 +#include <linux/fs.h>
62965 +#include <linux/mount.h>
62966 +#include <linux/types.h>
62967 +#include "../fs/mount.h"
62968 +#include <linux/grsecurity.h>
62969 +#include <linux/grinternal.h>
62970 +
62971 +void gr_set_chroot_entries(struct task_struct *task, struct path *path)
62972 +{
62973 +#ifdef CONFIG_GRKERNSEC
62974 + if (task_pid_nr(task) > 1 && path->dentry != init_task.fs->root.dentry &&
62975 + path->dentry != task->nsproxy->mnt_ns->root->mnt.mnt_root)
62976 + task->gr_is_chrooted = 1;
62977 + else
62978 + task->gr_is_chrooted = 0;
62979 +
62980 + task->gr_chroot_dentry = path->dentry;
62981 +#endif
62982 + return;
62983 +}
62984 +
62985 +void gr_clear_chroot_entries(struct task_struct *task)
62986 +{
62987 +#ifdef CONFIG_GRKERNSEC
62988 + task->gr_is_chrooted = 0;
62989 + task->gr_chroot_dentry = NULL;
62990 +#endif
62991 + return;
62992 +}
62993 +
62994 +int
62995 +gr_handle_chroot_unix(const pid_t pid)
62996 +{
62997 +#ifdef CONFIG_GRKERNSEC_CHROOT_UNIX
62998 + struct task_struct *p;
62999 +
63000 + if (unlikely(!grsec_enable_chroot_unix))
63001 + return 1;
63002 +
63003 + if (likely(!proc_is_chrooted(current)))
63004 + return 1;
63005 +
63006 + rcu_read_lock();
63007 + read_lock(&tasklist_lock);
63008 + p = find_task_by_vpid_unrestricted(pid);
63009 + if (unlikely(p && !have_same_root(current, p))) {
63010 + read_unlock(&tasklist_lock);
63011 + rcu_read_unlock();
63012 + gr_log_noargs(GR_DONT_AUDIT, GR_UNIX_CHROOT_MSG);
63013 + return 0;
63014 + }
63015 + read_unlock(&tasklist_lock);
63016 + rcu_read_unlock();
63017 +#endif
63018 + return 1;
63019 +}
63020 +
63021 +int
63022 +gr_handle_chroot_nice(void)
63023 +{
63024 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
63025 + if (grsec_enable_chroot_nice && proc_is_chrooted(current)) {
63026 + gr_log_noargs(GR_DONT_AUDIT, GR_NICE_CHROOT_MSG);
63027 + return -EPERM;
63028 + }
63029 +#endif
63030 + return 0;
63031 +}
63032 +
63033 +int
63034 +gr_handle_chroot_setpriority(struct task_struct *p, const int niceval)
63035 +{
63036 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
63037 + if (grsec_enable_chroot_nice && (niceval < task_nice(p))
63038 + && proc_is_chrooted(current)) {
63039 + gr_log_str_int(GR_DONT_AUDIT, GR_PRIORITY_CHROOT_MSG, p->comm, task_pid_nr(p));
63040 + return -EACCES;
63041 + }
63042 +#endif
63043 + return 0;
63044 +}
63045 +
63046 +int
63047 +gr_handle_chroot_fowner(struct pid *pid, enum pid_type type)
63048 +{
63049 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
63050 + struct task_struct *p;
63051 + int ret = 0;
63052 + if (!grsec_enable_chroot_findtask || !proc_is_chrooted(current) || !pid)
63053 + return ret;
63054 +
63055 + read_lock(&tasklist_lock);
63056 + do_each_pid_task(pid, type, p) {
63057 + if (!have_same_root(current, p)) {
63058 + ret = 1;
63059 + goto out;
63060 + }
63061 + } while_each_pid_task(pid, type, p);
63062 +out:
63063 + read_unlock(&tasklist_lock);
63064 + return ret;
63065 +#endif
63066 + return 0;
63067 +}
63068 +
63069 +int
63070 +gr_pid_is_chrooted(struct task_struct *p)
63071 +{
63072 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
63073 + if (!grsec_enable_chroot_findtask || !proc_is_chrooted(current) || p == NULL)
63074 + return 0;
63075 +
63076 + if ((p->exit_state & (EXIT_ZOMBIE | EXIT_DEAD)) ||
63077 + !have_same_root(current, p)) {
63078 + return 1;
63079 + }
63080 +#endif
63081 + return 0;
63082 +}
63083 +
63084 +EXPORT_SYMBOL(gr_pid_is_chrooted);
63085 +
63086 +#if defined(CONFIG_GRKERNSEC_CHROOT_DOUBLE) || defined(CONFIG_GRKERNSEC_CHROOT_FCHDIR)
63087 +int gr_is_outside_chroot(const struct dentry *u_dentry, const struct vfsmount *u_mnt)
63088 +{
63089 + struct path path, currentroot;
63090 + int ret = 0;
63091 +
63092 + path.dentry = (struct dentry *)u_dentry;
63093 + path.mnt = (struct vfsmount *)u_mnt;
63094 + get_fs_root(current->fs, &currentroot);
63095 + if (path_is_under(&path, &currentroot))
63096 + ret = 1;
63097 + path_put(&currentroot);
63098 +
63099 + return ret;
63100 +}
63101 +#endif
63102 +
63103 +int
63104 +gr_chroot_fchdir(struct dentry *u_dentry, struct vfsmount *u_mnt)
63105 +{
63106 +#ifdef CONFIG_GRKERNSEC_CHROOT_FCHDIR
63107 + if (!grsec_enable_chroot_fchdir)
63108 + return 1;
63109 +
63110 + if (!proc_is_chrooted(current))
63111 + return 1;
63112 + else if (!gr_is_outside_chroot(u_dentry, u_mnt)) {
63113 + gr_log_fs_generic(GR_DONT_AUDIT, GR_CHROOT_FCHDIR_MSG, u_dentry, u_mnt);
63114 + return 0;
63115 + }
63116 +#endif
63117 + return 1;
63118 +}
63119 +
63120 +int
63121 +gr_chroot_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
63122 + const time_t shm_createtime)
63123 +{
63124 +#ifdef CONFIG_GRKERNSEC_CHROOT_SHMAT
63125 + struct task_struct *p;
63126 + time_t starttime;
63127 +
63128 + if (unlikely(!grsec_enable_chroot_shmat))
63129 + return 1;
63130 +
63131 + if (likely(!proc_is_chrooted(current)))
63132 + return 1;
63133 +
63134 + rcu_read_lock();
63135 + read_lock(&tasklist_lock);
63136 +
63137 + if ((p = find_task_by_vpid_unrestricted(shm_cprid))) {
63138 + starttime = p->start_time.tv_sec;
63139 + if (time_before_eq((unsigned long)starttime, (unsigned long)shm_createtime)) {
63140 + if (have_same_root(current, p)) {
63141 + goto allow;
63142 + } else {
63143 + read_unlock(&tasklist_lock);
63144 + rcu_read_unlock();
63145 + gr_log_noargs(GR_DONT_AUDIT, GR_SHMAT_CHROOT_MSG);
63146 + return 0;
63147 + }
63148 + }
63149 + /* creator exited, pid reuse, fall through to next check */
63150 + }
63151 + if ((p = find_task_by_vpid_unrestricted(shm_lapid))) {
63152 + if (unlikely(!have_same_root(current, p))) {
63153 + read_unlock(&tasklist_lock);
63154 + rcu_read_unlock();
63155 + gr_log_noargs(GR_DONT_AUDIT, GR_SHMAT_CHROOT_MSG);
63156 + return 0;
63157 + }
63158 + }
63159 +
63160 +allow:
63161 + read_unlock(&tasklist_lock);
63162 + rcu_read_unlock();
63163 +#endif
63164 + return 1;
63165 +}
63166 +
63167 +void
63168 +gr_log_chroot_exec(const struct dentry *dentry, const struct vfsmount *mnt)
63169 +{
63170 +#ifdef CONFIG_GRKERNSEC_CHROOT_EXECLOG
63171 + if (grsec_enable_chroot_execlog && proc_is_chrooted(current))
63172 + gr_log_fs_generic(GR_DO_AUDIT, GR_EXEC_CHROOT_MSG, dentry, mnt);
63173 +#endif
63174 + return;
63175 +}
63176 +
63177 +int
63178 +gr_handle_chroot_mknod(const struct dentry *dentry,
63179 + const struct vfsmount *mnt, const int mode)
63180 +{
63181 +#ifdef CONFIG_GRKERNSEC_CHROOT_MKNOD
63182 + if (grsec_enable_chroot_mknod && !S_ISFIFO(mode) && !S_ISREG(mode) &&
63183 + proc_is_chrooted(current)) {
63184 + gr_log_fs_generic(GR_DONT_AUDIT, GR_MKNOD_CHROOT_MSG, dentry, mnt);
63185 + return -EPERM;
63186 + }
63187 +#endif
63188 + return 0;
63189 +}
63190 +
63191 +int
63192 +gr_handle_chroot_mount(const struct dentry *dentry,
63193 + const struct vfsmount *mnt, const char *dev_name)
63194 +{
63195 +#ifdef CONFIG_GRKERNSEC_CHROOT_MOUNT
63196 + if (grsec_enable_chroot_mount && proc_is_chrooted(current)) {
63197 + gr_log_str_fs(GR_DONT_AUDIT, GR_MOUNT_CHROOT_MSG, dev_name ? dev_name : "none", dentry, mnt);
63198 + return -EPERM;
63199 + }
63200 +#endif
63201 + return 0;
63202 +}
63203 +
63204 +int
63205 +gr_handle_chroot_pivot(void)
63206 +{
63207 +#ifdef CONFIG_GRKERNSEC_CHROOT_PIVOT
63208 + if (grsec_enable_chroot_pivot && proc_is_chrooted(current)) {
63209 + gr_log_noargs(GR_DONT_AUDIT, GR_PIVOT_CHROOT_MSG);
63210 + return -EPERM;
63211 + }
63212 +#endif
63213 + return 0;
63214 +}
63215 +
63216 +int
63217 +gr_handle_chroot_chroot(const struct dentry *dentry, const struct vfsmount *mnt)
63218 +{
63219 +#ifdef CONFIG_GRKERNSEC_CHROOT_DOUBLE
63220 + if (grsec_enable_chroot_double && proc_is_chrooted(current) &&
63221 + !gr_is_outside_chroot(dentry, mnt)) {
63222 + gr_log_fs_generic(GR_DONT_AUDIT, GR_CHROOT_CHROOT_MSG, dentry, mnt);
63223 + return -EPERM;
63224 + }
63225 +#endif
63226 + return 0;
63227 +}
63228 +
63229 +extern const char *captab_log[];
63230 +extern int captab_log_entries;
63231 +
63232 +int
63233 +gr_task_chroot_is_capable(const struct task_struct *task, const struct cred *cred, const int cap)
63234 +{
63235 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
63236 + if (grsec_enable_chroot_caps && proc_is_chrooted(task)) {
63237 + kernel_cap_t chroot_caps = GR_CHROOT_CAPS;
63238 + if (cap_raised(chroot_caps, cap)) {
63239 + if (cap_raised(cred->cap_effective, cap) && cap < captab_log_entries) {
63240 + gr_log_cap(GR_DONT_AUDIT, GR_CAP_CHROOT_MSG, task, captab_log[cap]);
63241 + }
63242 + return 0;
63243 + }
63244 + }
63245 +#endif
63246 + return 1;
63247 +}
63248 +
63249 +int
63250 +gr_chroot_is_capable(const int cap)
63251 +{
63252 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
63253 + return gr_task_chroot_is_capable(current, current_cred(), cap);
63254 +#endif
63255 + return 1;
63256 +}
63257 +
63258 +int
63259 +gr_task_chroot_is_capable_nolog(const struct task_struct *task, const int cap)
63260 +{
63261 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
63262 + if (grsec_enable_chroot_caps && proc_is_chrooted(task)) {
63263 + kernel_cap_t chroot_caps = GR_CHROOT_CAPS;
63264 + if (cap_raised(chroot_caps, cap)) {
63265 + return 0;
63266 + }
63267 + }
63268 +#endif
63269 + return 1;
63270 +}
63271 +
63272 +int
63273 +gr_chroot_is_capable_nolog(const int cap)
63274 +{
63275 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
63276 + return gr_task_chroot_is_capable_nolog(current, cap);
63277 +#endif
63278 + return 1;
63279 +}
63280 +
63281 +int
63282 +gr_handle_chroot_sysctl(const int op)
63283 +{
63284 +#ifdef CONFIG_GRKERNSEC_CHROOT_SYSCTL
63285 + if (grsec_enable_chroot_sysctl && (op & MAY_WRITE) &&
63286 + proc_is_chrooted(current))
63287 + return -EACCES;
63288 +#endif
63289 + return 0;
63290 +}
63291 +
63292 +void
63293 +gr_handle_chroot_chdir(struct path *path)
63294 +{
63295 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHDIR
63296 + if (grsec_enable_chroot_chdir)
63297 + set_fs_pwd(current->fs, path);
63298 +#endif
63299 + return;
63300 +}
63301 +
63302 +int
63303 +gr_handle_chroot_chmod(const struct dentry *dentry,
63304 + const struct vfsmount *mnt, const int mode)
63305 +{
63306 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHMOD
63307 + /* allow chmod +s on directories, but not files */
63308 + if (grsec_enable_chroot_chmod && !S_ISDIR(dentry->d_inode->i_mode) &&
63309 + ((mode & S_ISUID) || ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))) &&
63310 + proc_is_chrooted(current)) {
63311 + gr_log_fs_generic(GR_DONT_AUDIT, GR_CHMOD_CHROOT_MSG, dentry, mnt);
63312 + return -EPERM;
63313 + }
63314 +#endif
63315 + return 0;
63316 +}
63317 diff --git a/grsecurity/grsec_disabled.c b/grsecurity/grsec_disabled.c
63318 new file mode 100644
63319 index 0000000..207d409
63320 --- /dev/null
63321 +++ b/grsecurity/grsec_disabled.c
63322 @@ -0,0 +1,434 @@
63323 +#include <linux/kernel.h>
63324 +#include <linux/module.h>
63325 +#include <linux/sched.h>
63326 +#include <linux/file.h>
63327 +#include <linux/fs.h>
63328 +#include <linux/kdev_t.h>
63329 +#include <linux/net.h>
63330 +#include <linux/in.h>
63331 +#include <linux/ip.h>
63332 +#include <linux/skbuff.h>
63333 +#include <linux/sysctl.h>
63334 +
63335 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
63336 +void
63337 +pax_set_initial_flags(struct linux_binprm *bprm)
63338 +{
63339 + return;
63340 +}
63341 +#endif
63342 +
63343 +#ifdef CONFIG_SYSCTL
63344 +__u32
63345 +gr_handle_sysctl(const struct ctl_table * table, const int op)
63346 +{
63347 + return 0;
63348 +}
63349 +#endif
63350 +
63351 +#ifdef CONFIG_TASKSTATS
63352 +int gr_is_taskstats_denied(int pid)
63353 +{
63354 + return 0;
63355 +}
63356 +#endif
63357 +
63358 +int
63359 +gr_acl_is_enabled(void)
63360 +{
63361 + return 0;
63362 +}
63363 +
63364 +void
63365 +gr_handle_proc_create(const struct dentry *dentry, const struct inode *inode)
63366 +{
63367 + return;
63368 +}
63369 +
63370 +int
63371 +gr_handle_rawio(const struct inode *inode)
63372 +{
63373 + return 0;
63374 +}
63375 +
63376 +void
63377 +gr_acl_handle_psacct(struct task_struct *task, const long code)
63378 +{
63379 + return;
63380 +}
63381 +
63382 +int
63383 +gr_handle_ptrace(struct task_struct *task, const long request)
63384 +{
63385 + return 0;
63386 +}
63387 +
63388 +int
63389 +gr_handle_proc_ptrace(struct task_struct *task)
63390 +{
63391 + return 0;
63392 +}
63393 +
63394 +int
63395 +gr_set_acls(const int type)
63396 +{
63397 + return 0;
63398 +}
63399 +
63400 +int
63401 +gr_check_hidden_task(const struct task_struct *tsk)
63402 +{
63403 + return 0;
63404 +}
63405 +
63406 +int
63407 +gr_check_protected_task(const struct task_struct *task)
63408 +{
63409 + return 0;
63410 +}
63411 +
63412 +int
63413 +gr_check_protected_task_fowner(struct pid *pid, enum pid_type type)
63414 +{
63415 + return 0;
63416 +}
63417 +
63418 +void
63419 +gr_copy_label(struct task_struct *tsk)
63420 +{
63421 + return;
63422 +}
63423 +
63424 +void
63425 +gr_set_pax_flags(struct task_struct *task)
63426 +{
63427 + return;
63428 +}
63429 +
63430 +int
63431 +gr_set_proc_label(const struct dentry *dentry, const struct vfsmount *mnt,
63432 + const int unsafe_share)
63433 +{
63434 + return 0;
63435 +}
63436 +
63437 +void
63438 +gr_handle_delete(const ino_t ino, const dev_t dev)
63439 +{
63440 + return;
63441 +}
63442 +
63443 +void
63444 +gr_handle_create(const struct dentry *dentry, const struct vfsmount *mnt)
63445 +{
63446 + return;
63447 +}
63448 +
63449 +void
63450 +gr_handle_crash(struct task_struct *task, const int sig)
63451 +{
63452 + return;
63453 +}
63454 +
63455 +int
63456 +gr_check_crash_exec(const struct file *filp)
63457 +{
63458 + return 0;
63459 +}
63460 +
63461 +int
63462 +gr_check_crash_uid(const kuid_t uid)
63463 +{
63464 + return 0;
63465 +}
63466 +
63467 +void
63468 +gr_handle_rename(struct inode *old_dir, struct inode *new_dir,
63469 + struct dentry *old_dentry,
63470 + struct dentry *new_dentry,
63471 + struct vfsmount *mnt, const __u8 replace)
63472 +{
63473 + return;
63474 +}
63475 +
63476 +int
63477 +gr_search_socket(const int family, const int type, const int protocol)
63478 +{
63479 + return 1;
63480 +}
63481 +
63482 +int
63483 +gr_search_connectbind(const int mode, const struct socket *sock,
63484 + const struct sockaddr_in *addr)
63485 +{
63486 + return 0;
63487 +}
63488 +
63489 +void
63490 +gr_handle_alertkill(struct task_struct *task)
63491 +{
63492 + return;
63493 +}
63494 +
63495 +__u32
63496 +gr_acl_handle_execve(const struct dentry * dentry, const struct vfsmount * mnt)
63497 +{
63498 + return 1;
63499 +}
63500 +
63501 +__u32
63502 +gr_acl_handle_hidden_file(const struct dentry * dentry,
63503 + const struct vfsmount * mnt)
63504 +{
63505 + return 1;
63506 +}
63507 +
63508 +__u32
63509 +gr_acl_handle_open(const struct dentry * dentry, const struct vfsmount * mnt,
63510 + int acc_mode)
63511 +{
63512 + return 1;
63513 +}
63514 +
63515 +__u32
63516 +gr_acl_handle_rmdir(const struct dentry * dentry, const struct vfsmount * mnt)
63517 +{
63518 + return 1;
63519 +}
63520 +
63521 +__u32
63522 +gr_acl_handle_unlink(const struct dentry * dentry, const struct vfsmount * mnt)
63523 +{
63524 + return 1;
63525 +}
63526 +
63527 +int
63528 +gr_acl_handle_mmap(const struct file *file, const unsigned long prot,
63529 + unsigned int *vm_flags)
63530 +{
63531 + return 1;
63532 +}
63533 +
63534 +__u32
63535 +gr_acl_handle_truncate(const struct dentry * dentry,
63536 + const struct vfsmount * mnt)
63537 +{
63538 + return 1;
63539 +}
63540 +
63541 +__u32
63542 +gr_acl_handle_utime(const struct dentry * dentry, const struct vfsmount * mnt)
63543 +{
63544 + return 1;
63545 +}
63546 +
63547 +__u32
63548 +gr_acl_handle_access(const struct dentry * dentry,
63549 + const struct vfsmount * mnt, const int fmode)
63550 +{
63551 + return 1;
63552 +}
63553 +
63554 +__u32
63555 +gr_acl_handle_chmod(const struct dentry * dentry, const struct vfsmount * mnt,
63556 + umode_t *mode)
63557 +{
63558 + return 1;
63559 +}
63560 +
63561 +__u32
63562 +gr_acl_handle_chown(const struct dentry * dentry, const struct vfsmount * mnt)
63563 +{
63564 + return 1;
63565 +}
63566 +
63567 +__u32
63568 +gr_acl_handle_setxattr(const struct dentry * dentry, const struct vfsmount * mnt)
63569 +{
63570 + return 1;
63571 +}
63572 +
63573 +void
63574 +grsecurity_init(void)
63575 +{
63576 + return;
63577 +}
63578 +
63579 +umode_t gr_acl_umask(void)
63580 +{
63581 + return 0;
63582 +}
63583 +
63584 +__u32
63585 +gr_acl_handle_mknod(const struct dentry * new_dentry,
63586 + const struct dentry * parent_dentry,
63587 + const struct vfsmount * parent_mnt,
63588 + const int mode)
63589 +{
63590 + return 1;
63591 +}
63592 +
63593 +__u32
63594 +gr_acl_handle_mkdir(const struct dentry * new_dentry,
63595 + const struct dentry * parent_dentry,
63596 + const struct vfsmount * parent_mnt)
63597 +{
63598 + return 1;
63599 +}
63600 +
63601 +__u32
63602 +gr_acl_handle_symlink(const struct dentry * new_dentry,
63603 + const struct dentry * parent_dentry,
63604 + const struct vfsmount * parent_mnt, const struct filename *from)
63605 +{
63606 + return 1;
63607 +}
63608 +
63609 +__u32
63610 +gr_acl_handle_link(const struct dentry * new_dentry,
63611 + const struct dentry * parent_dentry,
63612 + const struct vfsmount * parent_mnt,
63613 + const struct dentry * old_dentry,
63614 + const struct vfsmount * old_mnt, const struct filename *to)
63615 +{
63616 + return 1;
63617 +}
63618 +
63619 +int
63620 +gr_acl_handle_rename(const struct dentry *new_dentry,
63621 + const struct dentry *parent_dentry,
63622 + const struct vfsmount *parent_mnt,
63623 + const struct dentry *old_dentry,
63624 + const struct inode *old_parent_inode,
63625 + const struct vfsmount *old_mnt, const struct filename *newname)
63626 +{
63627 + return 0;
63628 +}
63629 +
63630 +int
63631 +gr_acl_handle_filldir(const struct file *file, const char *name,
63632 + const int namelen, const ino_t ino)
63633 +{
63634 + return 1;
63635 +}
63636 +
63637 +int
63638 +gr_handle_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
63639 + const time_t shm_createtime, const kuid_t cuid, const int shmid)
63640 +{
63641 + return 1;
63642 +}
63643 +
63644 +int
63645 +gr_search_bind(const struct socket *sock, const struct sockaddr_in *addr)
63646 +{
63647 + return 0;
63648 +}
63649 +
63650 +int
63651 +gr_search_accept(const struct socket *sock)
63652 +{
63653 + return 0;
63654 +}
63655 +
63656 +int
63657 +gr_search_listen(const struct socket *sock)
63658 +{
63659 + return 0;
63660 +}
63661 +
63662 +int
63663 +gr_search_connect(const struct socket *sock, const struct sockaddr_in *addr)
63664 +{
63665 + return 0;
63666 +}
63667 +
63668 +__u32
63669 +gr_acl_handle_unix(const struct dentry * dentry, const struct vfsmount * mnt)
63670 +{
63671 + return 1;
63672 +}
63673 +
63674 +__u32
63675 +gr_acl_handle_creat(const struct dentry * dentry,
63676 + const struct dentry * p_dentry,
63677 + const struct vfsmount * p_mnt, int open_flags, int acc_mode,
63678 + const int imode)
63679 +{
63680 + return 1;
63681 +}
63682 +
63683 +void
63684 +gr_acl_handle_exit(void)
63685 +{
63686 + return;
63687 +}
63688 +
63689 +int
63690 +gr_acl_handle_mprotect(const struct file *file, const unsigned long prot)
63691 +{
63692 + return 1;
63693 +}
63694 +
63695 +void
63696 +gr_set_role_label(const kuid_t uid, const kgid_t gid)
63697 +{
63698 + return;
63699 +}
63700 +
63701 +int
63702 +gr_acl_handle_procpidmem(const struct task_struct *task)
63703 +{
63704 + return 0;
63705 +}
63706 +
63707 +int
63708 +gr_search_udp_recvmsg(const struct sock *sk, const struct sk_buff *skb)
63709 +{
63710 + return 0;
63711 +}
63712 +
63713 +int
63714 +gr_search_udp_sendmsg(const struct sock *sk, const struct sockaddr_in *addr)
63715 +{
63716 + return 0;
63717 +}
63718 +
63719 +void
63720 +gr_set_kernel_label(struct task_struct *task)
63721 +{
63722 + return;
63723 +}
63724 +
63725 +int
63726 +gr_check_user_change(kuid_t real, kuid_t effective, kuid_t fs)
63727 +{
63728 + return 0;
63729 +}
63730 +
63731 +int
63732 +gr_check_group_change(kgid_t real, kgid_t effective, kgid_t fs)
63733 +{
63734 + return 0;
63735 +}
63736 +
63737 +int gr_acl_enable_at_secure(void)
63738 +{
63739 + return 0;
63740 +}
63741 +
63742 +dev_t gr_get_dev_from_dentry(struct dentry *dentry)
63743 +{
63744 + return dentry->d_inode->i_sb->s_dev;
63745 +}
63746 +
63747 +void gr_put_exec_file(struct task_struct *task)
63748 +{
63749 + return;
63750 +}
63751 +
63752 +EXPORT_SYMBOL(gr_set_kernel_label);
63753 +#ifdef CONFIG_SECURITY
63754 +EXPORT_SYMBOL(gr_check_user_change);
63755 +EXPORT_SYMBOL(gr_check_group_change);
63756 +#endif
63757 diff --git a/grsecurity/grsec_exec.c b/grsecurity/grsec_exec.c
63758 new file mode 100644
63759 index 0000000..387032b
63760 --- /dev/null
63761 +++ b/grsecurity/grsec_exec.c
63762 @@ -0,0 +1,187 @@
63763 +#include <linux/kernel.h>
63764 +#include <linux/sched.h>
63765 +#include <linux/file.h>
63766 +#include <linux/binfmts.h>
63767 +#include <linux/fs.h>
63768 +#include <linux/types.h>
63769 +#include <linux/grdefs.h>
63770 +#include <linux/grsecurity.h>
63771 +#include <linux/grinternal.h>
63772 +#include <linux/capability.h>
63773 +#include <linux/module.h>
63774 +#include <linux/compat.h>
63775 +
63776 +#include <asm/uaccess.h>
63777 +
63778 +#ifdef CONFIG_GRKERNSEC_EXECLOG
63779 +static char gr_exec_arg_buf[132];
63780 +static DEFINE_MUTEX(gr_exec_arg_mutex);
63781 +#endif
63782 +
63783 +struct user_arg_ptr {
63784 +#ifdef CONFIG_COMPAT
63785 + bool is_compat;
63786 +#endif
63787 + union {
63788 + const char __user *const __user *native;
63789 +#ifdef CONFIG_COMPAT
63790 + const compat_uptr_t __user *compat;
63791 +#endif
63792 + } ptr;
63793 +};
63794 +
63795 +extern const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr);
63796 +
63797 +void
63798 +gr_handle_exec_args(struct linux_binprm *bprm, struct user_arg_ptr argv)
63799 +{
63800 +#ifdef CONFIG_GRKERNSEC_EXECLOG
63801 + char *grarg = gr_exec_arg_buf;
63802 + unsigned int i, x, execlen = 0;
63803 + char c;
63804 +
63805 + if (!((grsec_enable_execlog && grsec_enable_group &&
63806 + in_group_p(grsec_audit_gid))
63807 + || (grsec_enable_execlog && !grsec_enable_group)))
63808 + return;
63809 +
63810 + mutex_lock(&gr_exec_arg_mutex);
63811 + memset(grarg, 0, sizeof(gr_exec_arg_buf));
63812 +
63813 + for (i = 0; i < bprm->argc && execlen < 128; i++) {
63814 + const char __user *p;
63815 + unsigned int len;
63816 +
63817 + p = get_user_arg_ptr(argv, i);
63818 + if (IS_ERR(p))
63819 + goto log;
63820 +
63821 + len = strnlen_user(p, 128 - execlen);
63822 + if (len > 128 - execlen)
63823 + len = 128 - execlen;
63824 + else if (len > 0)
63825 + len--;
63826 + if (copy_from_user(grarg + execlen, p, len))
63827 + goto log;
63828 +
63829 + /* rewrite unprintable characters */
63830 + for (x = 0; x < len; x++) {
63831 + c = *(grarg + execlen + x);
63832 + if (c < 32 || c > 126)
63833 + *(grarg + execlen + x) = ' ';
63834 + }
63835 +
63836 + execlen += len;
63837 + *(grarg + execlen) = ' ';
63838 + *(grarg + execlen + 1) = '\0';
63839 + execlen++;
63840 + }
63841 +
63842 + log:
63843 + gr_log_fs_str(GR_DO_AUDIT, GR_EXEC_AUDIT_MSG, bprm->file->f_path.dentry,
63844 + bprm->file->f_path.mnt, grarg);
63845 + mutex_unlock(&gr_exec_arg_mutex);
63846 +#endif
63847 + return;
63848 +}
63849 +
63850 +#ifdef CONFIG_GRKERNSEC
63851 +extern int gr_acl_is_capable(const int cap);
63852 +extern int gr_acl_is_capable_nolog(const int cap);
63853 +extern int gr_task_acl_is_capable(const struct task_struct *task, const struct cred *cred, const int cap);
63854 +extern int gr_task_acl_is_capable_nolog(const struct task_struct *task, const int cap);
63855 +extern int gr_chroot_is_capable(const int cap);
63856 +extern int gr_chroot_is_capable_nolog(const int cap);
63857 +extern int gr_task_chroot_is_capable(const struct task_struct *task, const struct cred *cred, const int cap);
63858 +extern int gr_task_chroot_is_capable_nolog(const struct task_struct *task, const int cap);
63859 +#endif
63860 +
63861 +const char *captab_log[] = {
63862 + "CAP_CHOWN",
63863 + "CAP_DAC_OVERRIDE",
63864 + "CAP_DAC_READ_SEARCH",
63865 + "CAP_FOWNER",
63866 + "CAP_FSETID",
63867 + "CAP_KILL",
63868 + "CAP_SETGID",
63869 + "CAP_SETUID",
63870 + "CAP_SETPCAP",
63871 + "CAP_LINUX_IMMUTABLE",
63872 + "CAP_NET_BIND_SERVICE",
63873 + "CAP_NET_BROADCAST",
63874 + "CAP_NET_ADMIN",
63875 + "CAP_NET_RAW",
63876 + "CAP_IPC_LOCK",
63877 + "CAP_IPC_OWNER",
63878 + "CAP_SYS_MODULE",
63879 + "CAP_SYS_RAWIO",
63880 + "CAP_SYS_CHROOT",
63881 + "CAP_SYS_PTRACE",
63882 + "CAP_SYS_PACCT",
63883 + "CAP_SYS_ADMIN",
63884 + "CAP_SYS_BOOT",
63885 + "CAP_SYS_NICE",
63886 + "CAP_SYS_RESOURCE",
63887 + "CAP_SYS_TIME",
63888 + "CAP_SYS_TTY_CONFIG",
63889 + "CAP_MKNOD",
63890 + "CAP_LEASE",
63891 + "CAP_AUDIT_WRITE",
63892 + "CAP_AUDIT_CONTROL",
63893 + "CAP_SETFCAP",
63894 + "CAP_MAC_OVERRIDE",
63895 + "CAP_MAC_ADMIN",
63896 + "CAP_SYSLOG",
63897 + "CAP_WAKE_ALARM"
63898 +};
63899 +
63900 +int captab_log_entries = sizeof(captab_log)/sizeof(captab_log[0]);
63901 +
63902 +int gr_is_capable(const int cap)
63903 +{
63904 +#ifdef CONFIG_GRKERNSEC
63905 + if (gr_acl_is_capable(cap) && gr_chroot_is_capable(cap))
63906 + return 1;
63907 + return 0;
63908 +#else
63909 + return 1;
63910 +#endif
63911 +}
63912 +
63913 +int gr_task_is_capable(const struct task_struct *task, const struct cred *cred, const int cap)
63914 +{
63915 +#ifdef CONFIG_GRKERNSEC
63916 + if (gr_task_acl_is_capable(task, cred, cap) && gr_task_chroot_is_capable(task, cred, cap))
63917 + return 1;
63918 + return 0;
63919 +#else
63920 + return 1;
63921 +#endif
63922 +}
63923 +
63924 +int gr_is_capable_nolog(const int cap)
63925 +{
63926 +#ifdef CONFIG_GRKERNSEC
63927 + if (gr_acl_is_capable_nolog(cap) && gr_chroot_is_capable_nolog(cap))
63928 + return 1;
63929 + return 0;
63930 +#else
63931 + return 1;
63932 +#endif
63933 +}
63934 +
63935 +int gr_task_is_capable_nolog(const struct task_struct *task, const int cap)
63936 +{
63937 +#ifdef CONFIG_GRKERNSEC
63938 + if (gr_task_acl_is_capable_nolog(task, cap) && gr_task_chroot_is_capable_nolog(task, cap))
63939 + return 1;
63940 + return 0;
63941 +#else
63942 + return 1;
63943 +#endif
63944 +}
63945 +
63946 +EXPORT_SYMBOL(gr_is_capable);
63947 +EXPORT_SYMBOL(gr_is_capable_nolog);
63948 +EXPORT_SYMBOL(gr_task_is_capable);
63949 +EXPORT_SYMBOL(gr_task_is_capable_nolog);
63950 diff --git a/grsecurity/grsec_fifo.c b/grsecurity/grsec_fifo.c
63951 new file mode 100644
63952 index 0000000..06cc6ea
63953 --- /dev/null
63954 +++ b/grsecurity/grsec_fifo.c
63955 @@ -0,0 +1,24 @@
63956 +#include <linux/kernel.h>
63957 +#include <linux/sched.h>
63958 +#include <linux/fs.h>
63959 +#include <linux/file.h>
63960 +#include <linux/grinternal.h>
63961 +
63962 +int
63963 +gr_handle_fifo(const struct dentry *dentry, const struct vfsmount *mnt,
63964 + const struct dentry *dir, const int flag, const int acc_mode)
63965 +{
63966 +#ifdef CONFIG_GRKERNSEC_FIFO
63967 + const struct cred *cred = current_cred();
63968 +
63969 + if (grsec_enable_fifo && S_ISFIFO(dentry->d_inode->i_mode) &&
63970 + !(flag & O_EXCL) && (dir->d_inode->i_mode & S_ISVTX) &&
63971 + !uid_eq(dentry->d_inode->i_uid, dir->d_inode->i_uid) &&
63972 + !uid_eq(cred->fsuid, dentry->d_inode->i_uid)) {
63973 + if (!inode_permission(dentry->d_inode, acc_mode))
63974 + 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));
63975 + return -EACCES;
63976 + }
63977 +#endif
63978 + return 0;
63979 +}
63980 diff --git a/grsecurity/grsec_fork.c b/grsecurity/grsec_fork.c
63981 new file mode 100644
63982 index 0000000..8ca18bf
63983 --- /dev/null
63984 +++ b/grsecurity/grsec_fork.c
63985 @@ -0,0 +1,23 @@
63986 +#include <linux/kernel.h>
63987 +#include <linux/sched.h>
63988 +#include <linux/grsecurity.h>
63989 +#include <linux/grinternal.h>
63990 +#include <linux/errno.h>
63991 +
63992 +void
63993 +gr_log_forkfail(const int retval)
63994 +{
63995 +#ifdef CONFIG_GRKERNSEC_FORKFAIL
63996 + if (grsec_enable_forkfail && (retval == -EAGAIN || retval == -ENOMEM)) {
63997 + switch (retval) {
63998 + case -EAGAIN:
63999 + gr_log_str(GR_DONT_AUDIT, GR_FAILFORK_MSG, "EAGAIN");
64000 + break;
64001 + case -ENOMEM:
64002 + gr_log_str(GR_DONT_AUDIT, GR_FAILFORK_MSG, "ENOMEM");
64003 + break;
64004 + }
64005 + }
64006 +#endif
64007 + return;
64008 +}
64009 diff --git a/grsecurity/grsec_init.c b/grsecurity/grsec_init.c
64010 new file mode 100644
64011 index 0000000..a862e9f
64012 --- /dev/null
64013 +++ b/grsecurity/grsec_init.c
64014 @@ -0,0 +1,283 @@
64015 +#include <linux/kernel.h>
64016 +#include <linux/sched.h>
64017 +#include <linux/mm.h>
64018 +#include <linux/gracl.h>
64019 +#include <linux/slab.h>
64020 +#include <linux/vmalloc.h>
64021 +#include <linux/percpu.h>
64022 +#include <linux/module.h>
64023 +
64024 +int grsec_enable_ptrace_readexec;
64025 +int grsec_enable_setxid;
64026 +int grsec_enable_symlinkown;
64027 +kgid_t grsec_symlinkown_gid;
64028 +int grsec_enable_brute;
64029 +int grsec_enable_link;
64030 +int grsec_enable_dmesg;
64031 +int grsec_enable_harden_ptrace;
64032 +int grsec_enable_fifo;
64033 +int grsec_enable_execlog;
64034 +int grsec_enable_signal;
64035 +int grsec_enable_forkfail;
64036 +int grsec_enable_audit_ptrace;
64037 +int grsec_enable_time;
64038 +int grsec_enable_audit_textrel;
64039 +int grsec_enable_group;
64040 +kgid_t grsec_audit_gid;
64041 +int grsec_enable_chdir;
64042 +int grsec_enable_mount;
64043 +int grsec_enable_rofs;
64044 +int grsec_enable_chroot_findtask;
64045 +int grsec_enable_chroot_mount;
64046 +int grsec_enable_chroot_shmat;
64047 +int grsec_enable_chroot_fchdir;
64048 +int grsec_enable_chroot_double;
64049 +int grsec_enable_chroot_pivot;
64050 +int grsec_enable_chroot_chdir;
64051 +int grsec_enable_chroot_chmod;
64052 +int grsec_enable_chroot_mknod;
64053 +int grsec_enable_chroot_nice;
64054 +int grsec_enable_chroot_execlog;
64055 +int grsec_enable_chroot_caps;
64056 +int grsec_enable_chroot_sysctl;
64057 +int grsec_enable_chroot_unix;
64058 +int grsec_enable_tpe;
64059 +kgid_t grsec_tpe_gid;
64060 +int grsec_enable_blackhole;
64061 +#ifdef CONFIG_IPV6_MODULE
64062 +EXPORT_SYMBOL(grsec_enable_blackhole);
64063 +#endif
64064 +int grsec_lastack_retries;
64065 +int grsec_enable_tpe_all;
64066 +int grsec_enable_tpe_invert;
64067 +int grsec_enable_socket_all;
64068 +kgid_t grsec_socket_all_gid;
64069 +int grsec_enable_socket_client;
64070 +kgid_t grsec_socket_client_gid;
64071 +int grsec_enable_socket_server;
64072 +kgid_t grsec_socket_server_gid;
64073 +int grsec_resource_logging;
64074 +int grsec_disable_privio;
64075 +int grsec_enable_log_rwxmaps;
64076 +int grsec_lock;
64077 +
64078 +DEFINE_SPINLOCK(grsec_alert_lock);
64079 +unsigned long grsec_alert_wtime = 0;
64080 +unsigned long grsec_alert_fyet = 0;
64081 +
64082 +DEFINE_SPINLOCK(grsec_audit_lock);
64083 +
64084 +DEFINE_RWLOCK(grsec_exec_file_lock);
64085 +
64086 +char *gr_shared_page[4];
64087 +
64088 +char *gr_alert_log_fmt;
64089 +char *gr_audit_log_fmt;
64090 +char *gr_alert_log_buf;
64091 +char *gr_audit_log_buf;
64092 +
64093 +extern struct gr_arg *gr_usermode;
64094 +extern unsigned char *gr_system_salt;
64095 +extern unsigned char *gr_system_sum;
64096 +
64097 +void __init
64098 +grsecurity_init(void)
64099 +{
64100 + int j;
64101 + /* create the per-cpu shared pages */
64102 +
64103 +#ifdef CONFIG_X86
64104 + memset((char *)(0x41a + PAGE_OFFSET), 0, 36);
64105 +#endif
64106 +
64107 + for (j = 0; j < 4; j++) {
64108 + gr_shared_page[j] = (char *)__alloc_percpu(PAGE_SIZE, __alignof__(unsigned long long));
64109 + if (gr_shared_page[j] == NULL) {
64110 + panic("Unable to allocate grsecurity shared page");
64111 + return;
64112 + }
64113 + }
64114 +
64115 + /* allocate log buffers */
64116 + gr_alert_log_fmt = kmalloc(512, GFP_KERNEL);
64117 + if (!gr_alert_log_fmt) {
64118 + panic("Unable to allocate grsecurity alert log format buffer");
64119 + return;
64120 + }
64121 + gr_audit_log_fmt = kmalloc(512, GFP_KERNEL);
64122 + if (!gr_audit_log_fmt) {
64123 + panic("Unable to allocate grsecurity audit log format buffer");
64124 + return;
64125 + }
64126 + gr_alert_log_buf = (char *) get_zeroed_page(GFP_KERNEL);
64127 + if (!gr_alert_log_buf) {
64128 + panic("Unable to allocate grsecurity alert log buffer");
64129 + return;
64130 + }
64131 + gr_audit_log_buf = (char *) get_zeroed_page(GFP_KERNEL);
64132 + if (!gr_audit_log_buf) {
64133 + panic("Unable to allocate grsecurity audit log buffer");
64134 + return;
64135 + }
64136 +
64137 + /* allocate memory for authentication structure */
64138 + gr_usermode = kmalloc(sizeof(struct gr_arg), GFP_KERNEL);
64139 + gr_system_salt = kmalloc(GR_SALT_LEN, GFP_KERNEL);
64140 + gr_system_sum = kmalloc(GR_SHA_LEN, GFP_KERNEL);
64141 +
64142 + if (!gr_usermode || !gr_system_salt || !gr_system_sum) {
64143 + panic("Unable to allocate grsecurity authentication structure");
64144 + return;
64145 + }
64146 +
64147 +
64148 +#ifdef CONFIG_GRKERNSEC_IO
64149 +#if !defined(CONFIG_GRKERNSEC_SYSCTL_DISTRO)
64150 + grsec_disable_privio = 1;
64151 +#elif defined(CONFIG_GRKERNSEC_SYSCTL_ON)
64152 + grsec_disable_privio = 1;
64153 +#else
64154 + grsec_disable_privio = 0;
64155 +#endif
64156 +#endif
64157 +
64158 +#ifdef CONFIG_GRKERNSEC_TPE_INVERT
64159 + /* for backward compatibility, tpe_invert always defaults to on if
64160 + enabled in the kernel
64161 + */
64162 + grsec_enable_tpe_invert = 1;
64163 +#endif
64164 +
64165 +#if !defined(CONFIG_GRKERNSEC_SYSCTL) || defined(CONFIG_GRKERNSEC_SYSCTL_ON)
64166 +#ifndef CONFIG_GRKERNSEC_SYSCTL
64167 + grsec_lock = 1;
64168 +#endif
64169 +
64170 +#ifdef CONFIG_GRKERNSEC_AUDIT_TEXTREL
64171 + grsec_enable_audit_textrel = 1;
64172 +#endif
64173 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
64174 + grsec_enable_log_rwxmaps = 1;
64175 +#endif
64176 +#ifdef CONFIG_GRKERNSEC_AUDIT_GROUP
64177 + grsec_enable_group = 1;
64178 + grsec_audit_gid = KGIDT_INIT(CONFIG_GRKERNSEC_AUDIT_GID);
64179 +#endif
64180 +#ifdef CONFIG_GRKERNSEC_PTRACE_READEXEC
64181 + grsec_enable_ptrace_readexec = 1;
64182 +#endif
64183 +#ifdef CONFIG_GRKERNSEC_AUDIT_CHDIR
64184 + grsec_enable_chdir = 1;
64185 +#endif
64186 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
64187 + grsec_enable_harden_ptrace = 1;
64188 +#endif
64189 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
64190 + grsec_enable_mount = 1;
64191 +#endif
64192 +#ifdef CONFIG_GRKERNSEC_LINK
64193 + grsec_enable_link = 1;
64194 +#endif
64195 +#ifdef CONFIG_GRKERNSEC_BRUTE
64196 + grsec_enable_brute = 1;
64197 +#endif
64198 +#ifdef CONFIG_GRKERNSEC_DMESG
64199 + grsec_enable_dmesg = 1;
64200 +#endif
64201 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
64202 + grsec_enable_blackhole = 1;
64203 + grsec_lastack_retries = 4;
64204 +#endif
64205 +#ifdef CONFIG_GRKERNSEC_FIFO
64206 + grsec_enable_fifo = 1;
64207 +#endif
64208 +#ifdef CONFIG_GRKERNSEC_EXECLOG
64209 + grsec_enable_execlog = 1;
64210 +#endif
64211 +#ifdef CONFIG_GRKERNSEC_SETXID
64212 + grsec_enable_setxid = 1;
64213 +#endif
64214 +#ifdef CONFIG_GRKERNSEC_SIGNAL
64215 + grsec_enable_signal = 1;
64216 +#endif
64217 +#ifdef CONFIG_GRKERNSEC_FORKFAIL
64218 + grsec_enable_forkfail = 1;
64219 +#endif
64220 +#ifdef CONFIG_GRKERNSEC_TIME
64221 + grsec_enable_time = 1;
64222 +#endif
64223 +#ifdef CONFIG_GRKERNSEC_RESLOG
64224 + grsec_resource_logging = 1;
64225 +#endif
64226 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
64227 + grsec_enable_chroot_findtask = 1;
64228 +#endif
64229 +#ifdef CONFIG_GRKERNSEC_CHROOT_UNIX
64230 + grsec_enable_chroot_unix = 1;
64231 +#endif
64232 +#ifdef CONFIG_GRKERNSEC_CHROOT_MOUNT
64233 + grsec_enable_chroot_mount = 1;
64234 +#endif
64235 +#ifdef CONFIG_GRKERNSEC_CHROOT_FCHDIR
64236 + grsec_enable_chroot_fchdir = 1;
64237 +#endif
64238 +#ifdef CONFIG_GRKERNSEC_CHROOT_SHMAT
64239 + grsec_enable_chroot_shmat = 1;
64240 +#endif
64241 +#ifdef CONFIG_GRKERNSEC_AUDIT_PTRACE
64242 + grsec_enable_audit_ptrace = 1;
64243 +#endif
64244 +#ifdef CONFIG_GRKERNSEC_CHROOT_DOUBLE
64245 + grsec_enable_chroot_double = 1;
64246 +#endif
64247 +#ifdef CONFIG_GRKERNSEC_CHROOT_PIVOT
64248 + grsec_enable_chroot_pivot = 1;
64249 +#endif
64250 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHDIR
64251 + grsec_enable_chroot_chdir = 1;
64252 +#endif
64253 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHMOD
64254 + grsec_enable_chroot_chmod = 1;
64255 +#endif
64256 +#ifdef CONFIG_GRKERNSEC_CHROOT_MKNOD
64257 + grsec_enable_chroot_mknod = 1;
64258 +#endif
64259 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
64260 + grsec_enable_chroot_nice = 1;
64261 +#endif
64262 +#ifdef CONFIG_GRKERNSEC_CHROOT_EXECLOG
64263 + grsec_enable_chroot_execlog = 1;
64264 +#endif
64265 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
64266 + grsec_enable_chroot_caps = 1;
64267 +#endif
64268 +#ifdef CONFIG_GRKERNSEC_CHROOT_SYSCTL
64269 + grsec_enable_chroot_sysctl = 1;
64270 +#endif
64271 +#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
64272 + grsec_enable_symlinkown = 1;
64273 + grsec_symlinkown_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SYMLINKOWN_GID);
64274 +#endif
64275 +#ifdef CONFIG_GRKERNSEC_TPE
64276 + grsec_enable_tpe = 1;
64277 + grsec_tpe_gid = KGIDT_INIT(CONFIG_GRKERNSEC_TPE_GID);
64278 +#ifdef CONFIG_GRKERNSEC_TPE_ALL
64279 + grsec_enable_tpe_all = 1;
64280 +#endif
64281 +#endif
64282 +#ifdef CONFIG_GRKERNSEC_SOCKET_ALL
64283 + grsec_enable_socket_all = 1;
64284 + grsec_socket_all_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SOCKET_ALL_GID);
64285 +#endif
64286 +#ifdef CONFIG_GRKERNSEC_SOCKET_CLIENT
64287 + grsec_enable_socket_client = 1;
64288 + grsec_socket_client_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SOCKET_CLIENT_GID);
64289 +#endif
64290 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
64291 + grsec_enable_socket_server = 1;
64292 + grsec_socket_server_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SOCKET_SERVER_GID);
64293 +#endif
64294 +#endif
64295 +
64296 + return;
64297 +}
64298 diff --git a/grsecurity/grsec_link.c b/grsecurity/grsec_link.c
64299 new file mode 100644
64300 index 0000000..5e05e20
64301 --- /dev/null
64302 +++ b/grsecurity/grsec_link.c
64303 @@ -0,0 +1,58 @@
64304 +#include <linux/kernel.h>
64305 +#include <linux/sched.h>
64306 +#include <linux/fs.h>
64307 +#include <linux/file.h>
64308 +#include <linux/grinternal.h>
64309 +
64310 +int gr_handle_symlink_owner(const struct path *link, const struct inode *target)
64311 +{
64312 +#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
64313 + const struct inode *link_inode = link->dentry->d_inode;
64314 +
64315 + if (grsec_enable_symlinkown && in_group_p(grsec_symlinkown_gid) &&
64316 + /* ignore root-owned links, e.g. /proc/self */
64317 + gr_is_global_nonroot(link_inode->i_uid) && target &&
64318 + !uid_eq(link_inode->i_uid, target->i_uid)) {
64319 + gr_log_fs_int2(GR_DONT_AUDIT, GR_SYMLINKOWNER_MSG, link->dentry, link->mnt, link_inode->i_uid, target->i_uid);
64320 + return 1;
64321 + }
64322 +#endif
64323 + return 0;
64324 +}
64325 +
64326 +int
64327 +gr_handle_follow_link(const struct inode *parent,
64328 + const struct inode *inode,
64329 + const struct dentry *dentry, const struct vfsmount *mnt)
64330 +{
64331 +#ifdef CONFIG_GRKERNSEC_LINK
64332 + const struct cred *cred = current_cred();
64333 +
64334 + if (grsec_enable_link && S_ISLNK(inode->i_mode) &&
64335 + (parent->i_mode & S_ISVTX) && !uid_eq(parent->i_uid, inode->i_uid) &&
64336 + (parent->i_mode & S_IWOTH) && !uid_eq(cred->fsuid, inode->i_uid)) {
64337 + gr_log_fs_int2(GR_DONT_AUDIT, GR_SYMLINK_MSG, dentry, mnt, inode->i_uid, inode->i_gid);
64338 + return -EACCES;
64339 + }
64340 +#endif
64341 + return 0;
64342 +}
64343 +
64344 +int
64345 +gr_handle_hardlink(const struct dentry *dentry,
64346 + const struct vfsmount *mnt,
64347 + struct inode *inode, const int mode, const struct filename *to)
64348 +{
64349 +#ifdef CONFIG_GRKERNSEC_LINK
64350 + const struct cred *cred = current_cred();
64351 +
64352 + if (grsec_enable_link && !uid_eq(cred->fsuid, inode->i_uid) &&
64353 + (!S_ISREG(mode) || is_privileged_binary(dentry) ||
64354 + (inode_permission(inode, MAY_READ | MAY_WRITE))) &&
64355 + !capable(CAP_FOWNER) && gr_is_global_nonroot(cred->uid)) {
64356 + gr_log_fs_int2_str(GR_DONT_AUDIT, GR_HARDLINK_MSG, dentry, mnt, inode->i_uid, inode->i_gid, to->name);
64357 + return -EPERM;
64358 + }
64359 +#endif
64360 + return 0;
64361 +}
64362 diff --git a/grsecurity/grsec_log.c b/grsecurity/grsec_log.c
64363 new file mode 100644
64364 index 0000000..7c06085
64365 --- /dev/null
64366 +++ b/grsecurity/grsec_log.c
64367 @@ -0,0 +1,326 @@
64368 +#include <linux/kernel.h>
64369 +#include <linux/sched.h>
64370 +#include <linux/file.h>
64371 +#include <linux/tty.h>
64372 +#include <linux/fs.h>
64373 +#include <linux/grinternal.h>
64374 +
64375 +#ifdef CONFIG_TREE_PREEMPT_RCU
64376 +#define DISABLE_PREEMPT() preempt_disable()
64377 +#define ENABLE_PREEMPT() preempt_enable()
64378 +#else
64379 +#define DISABLE_PREEMPT()
64380 +#define ENABLE_PREEMPT()
64381 +#endif
64382 +
64383 +#define BEGIN_LOCKS(x) \
64384 + DISABLE_PREEMPT(); \
64385 + rcu_read_lock(); \
64386 + read_lock(&tasklist_lock); \
64387 + read_lock(&grsec_exec_file_lock); \
64388 + if (x != GR_DO_AUDIT) \
64389 + spin_lock(&grsec_alert_lock); \
64390 + else \
64391 + spin_lock(&grsec_audit_lock)
64392 +
64393 +#define END_LOCKS(x) \
64394 + if (x != GR_DO_AUDIT) \
64395 + spin_unlock(&grsec_alert_lock); \
64396 + else \
64397 + spin_unlock(&grsec_audit_lock); \
64398 + read_unlock(&grsec_exec_file_lock); \
64399 + read_unlock(&tasklist_lock); \
64400 + rcu_read_unlock(); \
64401 + ENABLE_PREEMPT(); \
64402 + if (x == GR_DONT_AUDIT) \
64403 + gr_handle_alertkill(current)
64404 +
64405 +enum {
64406 + FLOODING,
64407 + NO_FLOODING
64408 +};
64409 +
64410 +extern char *gr_alert_log_fmt;
64411 +extern char *gr_audit_log_fmt;
64412 +extern char *gr_alert_log_buf;
64413 +extern char *gr_audit_log_buf;
64414 +
64415 +static int gr_log_start(int audit)
64416 +{
64417 + char *loglevel = (audit == GR_DO_AUDIT) ? KERN_INFO : KERN_ALERT;
64418 + char *fmt = (audit == GR_DO_AUDIT) ? gr_audit_log_fmt : gr_alert_log_fmt;
64419 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
64420 +#if (CONFIG_GRKERNSEC_FLOODTIME > 0 && CONFIG_GRKERNSEC_FLOODBURST > 0)
64421 + unsigned long curr_secs = get_seconds();
64422 +
64423 + if (audit == GR_DO_AUDIT)
64424 + goto set_fmt;
64425 +
64426 + if (!grsec_alert_wtime || time_after(curr_secs, grsec_alert_wtime + CONFIG_GRKERNSEC_FLOODTIME)) {
64427 + grsec_alert_wtime = curr_secs;
64428 + grsec_alert_fyet = 0;
64429 + } else if (time_before_eq(curr_secs, grsec_alert_wtime + CONFIG_GRKERNSEC_FLOODTIME)
64430 + && (grsec_alert_fyet < CONFIG_GRKERNSEC_FLOODBURST)) {
64431 + grsec_alert_fyet++;
64432 + } else if (grsec_alert_fyet == CONFIG_GRKERNSEC_FLOODBURST) {
64433 + grsec_alert_wtime = curr_secs;
64434 + grsec_alert_fyet++;
64435 + printk(KERN_ALERT "grsec: more alerts, logging disabled for %d seconds\n", CONFIG_GRKERNSEC_FLOODTIME);
64436 + return FLOODING;
64437 + }
64438 + else return FLOODING;
64439 +
64440 +set_fmt:
64441 +#endif
64442 + memset(buf, 0, PAGE_SIZE);
64443 + if (current->signal->curr_ip && gr_acl_is_enabled()) {
64444 + sprintf(fmt, "%s%s", loglevel, "grsec: From %pI4: (%.64s:%c:%.950s) ");
64445 + snprintf(buf, PAGE_SIZE - 1, fmt, &current->signal->curr_ip, current->role->rolename, gr_roletype_to_char(), current->acl->filename);
64446 + } else if (current->signal->curr_ip) {
64447 + sprintf(fmt, "%s%s", loglevel, "grsec: From %pI4: ");
64448 + snprintf(buf, PAGE_SIZE - 1, fmt, &current->signal->curr_ip);
64449 + } else if (gr_acl_is_enabled()) {
64450 + sprintf(fmt, "%s%s", loglevel, "grsec: (%.64s:%c:%.950s) ");
64451 + snprintf(buf, PAGE_SIZE - 1, fmt, current->role->rolename, gr_roletype_to_char(), current->acl->filename);
64452 + } else {
64453 + sprintf(fmt, "%s%s", loglevel, "grsec: ");
64454 + strcpy(buf, fmt);
64455 + }
64456 +
64457 + return NO_FLOODING;
64458 +}
64459 +
64460 +static void gr_log_middle(int audit, const char *msg, va_list ap)
64461 + __attribute__ ((format (printf, 2, 0)));
64462 +
64463 +static void gr_log_middle(int audit, const char *msg, va_list ap)
64464 +{
64465 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
64466 + unsigned int len = strlen(buf);
64467 +
64468 + vsnprintf(buf + len, PAGE_SIZE - len - 1, msg, ap);
64469 +
64470 + return;
64471 +}
64472 +
64473 +static void gr_log_middle_varargs(int audit, const char *msg, ...)
64474 + __attribute__ ((format (printf, 2, 3)));
64475 +
64476 +static void gr_log_middle_varargs(int audit, const char *msg, ...)
64477 +{
64478 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
64479 + unsigned int len = strlen(buf);
64480 + va_list ap;
64481 +
64482 + va_start(ap, msg);
64483 + vsnprintf(buf + len, PAGE_SIZE - len - 1, msg, ap);
64484 + va_end(ap);
64485 +
64486 + return;
64487 +}
64488 +
64489 +static void gr_log_end(int audit, int append_default)
64490 +{
64491 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
64492 + if (append_default) {
64493 + struct task_struct *task = current;
64494 + struct task_struct *parent = task->real_parent;
64495 + const struct cred *cred = __task_cred(task);
64496 + const struct cred *pcred = __task_cred(parent);
64497 + unsigned int len = strlen(buf);
64498 +
64499 + 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));
64500 + }
64501 +
64502 + printk("%s\n", buf);
64503 +
64504 + return;
64505 +}
64506 +
64507 +void gr_log_varargs(int audit, const char *msg, int argtypes, ...)
64508 +{
64509 + int logtype;
64510 + char *result = (audit == GR_DO_AUDIT) ? "successful" : "denied";
64511 + char *str1 = NULL, *str2 = NULL, *str3 = NULL;
64512 + void *voidptr = NULL;
64513 + int num1 = 0, num2 = 0;
64514 + unsigned long ulong1 = 0, ulong2 = 0;
64515 + struct dentry *dentry = NULL;
64516 + struct vfsmount *mnt = NULL;
64517 + struct file *file = NULL;
64518 + struct task_struct *task = NULL;
64519 + const struct cred *cred, *pcred;
64520 + va_list ap;
64521 +
64522 + BEGIN_LOCKS(audit);
64523 + logtype = gr_log_start(audit);
64524 + if (logtype == FLOODING) {
64525 + END_LOCKS(audit);
64526 + return;
64527 + }
64528 + va_start(ap, argtypes);
64529 + switch (argtypes) {
64530 + case GR_TTYSNIFF:
64531 + task = va_arg(ap, struct task_struct *);
64532 + 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));
64533 + break;
64534 + case GR_SYSCTL_HIDDEN:
64535 + str1 = va_arg(ap, char *);
64536 + gr_log_middle_varargs(audit, msg, result, str1);
64537 + break;
64538 + case GR_RBAC:
64539 + dentry = va_arg(ap, struct dentry *);
64540 + mnt = va_arg(ap, struct vfsmount *);
64541 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt));
64542 + break;
64543 + case GR_RBAC_STR:
64544 + dentry = va_arg(ap, struct dentry *);
64545 + mnt = va_arg(ap, struct vfsmount *);
64546 + str1 = va_arg(ap, char *);
64547 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt), str1);
64548 + break;
64549 + case GR_STR_RBAC:
64550 + str1 = va_arg(ap, char *);
64551 + dentry = va_arg(ap, struct dentry *);
64552 + mnt = va_arg(ap, struct vfsmount *);
64553 + gr_log_middle_varargs(audit, msg, result, str1, gr_to_filename(dentry, mnt));
64554 + break;
64555 + case GR_RBAC_MODE2:
64556 + dentry = va_arg(ap, struct dentry *);
64557 + mnt = va_arg(ap, struct vfsmount *);
64558 + str1 = va_arg(ap, char *);
64559 + str2 = va_arg(ap, char *);
64560 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt), str1, str2);
64561 + break;
64562 + case GR_RBAC_MODE3:
64563 + dentry = va_arg(ap, struct dentry *);
64564 + mnt = va_arg(ap, struct vfsmount *);
64565 + str1 = va_arg(ap, char *);
64566 + str2 = va_arg(ap, char *);
64567 + str3 = va_arg(ap, char *);
64568 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt), str1, str2, str3);
64569 + break;
64570 + case GR_FILENAME:
64571 + dentry = va_arg(ap, struct dentry *);
64572 + mnt = va_arg(ap, struct vfsmount *);
64573 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt));
64574 + break;
64575 + case GR_STR_FILENAME:
64576 + str1 = va_arg(ap, char *);
64577 + dentry = va_arg(ap, struct dentry *);
64578 + mnt = va_arg(ap, struct vfsmount *);
64579 + gr_log_middle_varargs(audit, msg, str1, gr_to_filename(dentry, mnt));
64580 + break;
64581 + case GR_FILENAME_STR:
64582 + dentry = va_arg(ap, struct dentry *);
64583 + mnt = va_arg(ap, struct vfsmount *);
64584 + str1 = va_arg(ap, char *);
64585 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt), str1);
64586 + break;
64587 + case GR_FILENAME_TWO_INT:
64588 + dentry = va_arg(ap, struct dentry *);
64589 + mnt = va_arg(ap, struct vfsmount *);
64590 + num1 = va_arg(ap, int);
64591 + num2 = va_arg(ap, int);
64592 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt), num1, num2);
64593 + break;
64594 + case GR_FILENAME_TWO_INT_STR:
64595 + dentry = va_arg(ap, struct dentry *);
64596 + mnt = va_arg(ap, struct vfsmount *);
64597 + num1 = va_arg(ap, int);
64598 + num2 = va_arg(ap, int);
64599 + str1 = va_arg(ap, char *);
64600 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt), num1, num2, str1);
64601 + break;
64602 + case GR_TEXTREL:
64603 + file = va_arg(ap, struct file *);
64604 + ulong1 = va_arg(ap, unsigned long);
64605 + ulong2 = va_arg(ap, unsigned long);
64606 + gr_log_middle_varargs(audit, msg, file ? gr_to_filename(file->f_path.dentry, file->f_path.mnt) : "<anonymous mapping>", ulong1, ulong2);
64607 + break;
64608 + case GR_PTRACE:
64609 + task = va_arg(ap, struct task_struct *);
64610 + 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));
64611 + break;
64612 + case GR_RESOURCE:
64613 + task = va_arg(ap, struct task_struct *);
64614 + cred = __task_cred(task);
64615 + pcred = __task_cred(task->real_parent);
64616 + ulong1 = va_arg(ap, unsigned long);
64617 + str1 = va_arg(ap, char *);
64618 + ulong2 = va_arg(ap, unsigned long);
64619 + 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));
64620 + break;
64621 + case GR_CAP:
64622 + task = va_arg(ap, struct task_struct *);
64623 + cred = __task_cred(task);
64624 + pcred = __task_cred(task->real_parent);
64625 + str1 = va_arg(ap, char *);
64626 + 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));
64627 + break;
64628 + case GR_SIG:
64629 + str1 = va_arg(ap, char *);
64630 + voidptr = va_arg(ap, void *);
64631 + gr_log_middle_varargs(audit, msg, str1, voidptr);
64632 + break;
64633 + case GR_SIG2:
64634 + task = va_arg(ap, struct task_struct *);
64635 + cred = __task_cred(task);
64636 + pcred = __task_cred(task->real_parent);
64637 + num1 = va_arg(ap, int);
64638 + 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));
64639 + break;
64640 + case GR_CRASH1:
64641 + task = va_arg(ap, struct task_struct *);
64642 + cred = __task_cred(task);
64643 + pcred = __task_cred(task->real_parent);
64644 + ulong1 = va_arg(ap, unsigned long);
64645 + 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);
64646 + break;
64647 + case GR_CRASH2:
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 + 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);
64653 + break;
64654 + case GR_RWXMAP:
64655 + file = va_arg(ap, struct file *);
64656 + gr_log_middle_varargs(audit, msg, file ? gr_to_filename(file->f_path.dentry, file->f_path.mnt) : "<anonymous mapping>");
64657 + break;
64658 + case GR_PSACCT:
64659 + {
64660 + unsigned int wday, cday;
64661 + __u8 whr, chr;
64662 + __u8 wmin, cmin;
64663 + __u8 wsec, csec;
64664 + char cur_tty[64] = { 0 };
64665 + char parent_tty[64] = { 0 };
64666 +
64667 + task = va_arg(ap, struct task_struct *);
64668 + wday = va_arg(ap, unsigned int);
64669 + cday = va_arg(ap, unsigned int);
64670 + whr = va_arg(ap, int);
64671 + chr = va_arg(ap, int);
64672 + wmin = va_arg(ap, int);
64673 + cmin = va_arg(ap, int);
64674 + wsec = va_arg(ap, int);
64675 + csec = va_arg(ap, int);
64676 + ulong1 = va_arg(ap, unsigned long);
64677 + cred = __task_cred(task);
64678 + pcred = __task_cred(task->real_parent);
64679 +
64680 + 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));
64681 + }
64682 + break;
64683 + default:
64684 + gr_log_middle(audit, msg, ap);
64685 + }
64686 + va_end(ap);
64687 + // these don't need DEFAULTSECARGS printed on the end
64688 + if (argtypes == GR_CRASH1 || argtypes == GR_CRASH2)
64689 + gr_log_end(audit, 0);
64690 + else
64691 + gr_log_end(audit, 1);
64692 + END_LOCKS(audit);
64693 +}
64694 diff --git a/grsecurity/grsec_mem.c b/grsecurity/grsec_mem.c
64695 new file mode 100644
64696 index 0000000..f536303
64697 --- /dev/null
64698 +++ b/grsecurity/grsec_mem.c
64699 @@ -0,0 +1,40 @@
64700 +#include <linux/kernel.h>
64701 +#include <linux/sched.h>
64702 +#include <linux/mm.h>
64703 +#include <linux/mman.h>
64704 +#include <linux/grinternal.h>
64705 +
64706 +void
64707 +gr_handle_ioperm(void)
64708 +{
64709 + gr_log_noargs(GR_DONT_AUDIT, GR_IOPERM_MSG);
64710 + return;
64711 +}
64712 +
64713 +void
64714 +gr_handle_iopl(void)
64715 +{
64716 + gr_log_noargs(GR_DONT_AUDIT, GR_IOPL_MSG);
64717 + return;
64718 +}
64719 +
64720 +void
64721 +gr_handle_mem_readwrite(u64 from, u64 to)
64722 +{
64723 + gr_log_two_u64(GR_DONT_AUDIT, GR_MEM_READWRITE_MSG, from, to);
64724 + return;
64725 +}
64726 +
64727 +void
64728 +gr_handle_vm86(void)
64729 +{
64730 + gr_log_noargs(GR_DONT_AUDIT, GR_VM86_MSG);
64731 + return;
64732 +}
64733 +
64734 +void
64735 +gr_log_badprocpid(const char *entry)
64736 +{
64737 + gr_log_str(GR_DONT_AUDIT, GR_BADPROCPID_MSG, entry);
64738 + return;
64739 +}
64740 diff --git a/grsecurity/grsec_mount.c b/grsecurity/grsec_mount.c
64741 new file mode 100644
64742 index 0000000..2131422
64743 --- /dev/null
64744 +++ b/grsecurity/grsec_mount.c
64745 @@ -0,0 +1,62 @@
64746 +#include <linux/kernel.h>
64747 +#include <linux/sched.h>
64748 +#include <linux/mount.h>
64749 +#include <linux/grsecurity.h>
64750 +#include <linux/grinternal.h>
64751 +
64752 +void
64753 +gr_log_remount(const char *devname, const int retval)
64754 +{
64755 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
64756 + if (grsec_enable_mount && (retval >= 0))
64757 + gr_log_str(GR_DO_AUDIT, GR_REMOUNT_AUDIT_MSG, devname ? devname : "none");
64758 +#endif
64759 + return;
64760 +}
64761 +
64762 +void
64763 +gr_log_unmount(const char *devname, const int retval)
64764 +{
64765 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
64766 + if (grsec_enable_mount && (retval >= 0))
64767 + gr_log_str(GR_DO_AUDIT, GR_UNMOUNT_AUDIT_MSG, devname ? devname : "none");
64768 +#endif
64769 + return;
64770 +}
64771 +
64772 +void
64773 +gr_log_mount(const char *from, const char *to, const int retval)
64774 +{
64775 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
64776 + if (grsec_enable_mount && (retval >= 0))
64777 + gr_log_str_str(GR_DO_AUDIT, GR_MOUNT_AUDIT_MSG, from ? from : "none", to);
64778 +#endif
64779 + return;
64780 +}
64781 +
64782 +int
64783 +gr_handle_rofs_mount(struct dentry *dentry, struct vfsmount *mnt, int mnt_flags)
64784 +{
64785 +#ifdef CONFIG_GRKERNSEC_ROFS
64786 + if (grsec_enable_rofs && !(mnt_flags & MNT_READONLY)) {
64787 + gr_log_fs_generic(GR_DO_AUDIT, GR_ROFS_MOUNT_MSG, dentry, mnt);
64788 + return -EPERM;
64789 + } else
64790 + return 0;
64791 +#endif
64792 + return 0;
64793 +}
64794 +
64795 +int
64796 +gr_handle_rofs_blockwrite(struct dentry *dentry, struct vfsmount *mnt, int acc_mode)
64797 +{
64798 +#ifdef CONFIG_GRKERNSEC_ROFS
64799 + if (grsec_enable_rofs && (acc_mode & MAY_WRITE) &&
64800 + dentry->d_inode && S_ISBLK(dentry->d_inode->i_mode)) {
64801 + gr_log_fs_generic(GR_DO_AUDIT, GR_ROFS_BLOCKWRITE_MSG, dentry, mnt);
64802 + return -EPERM;
64803 + } else
64804 + return 0;
64805 +#endif
64806 + return 0;
64807 +}
64808 diff --git a/grsecurity/grsec_pax.c b/grsecurity/grsec_pax.c
64809 new file mode 100644
64810 index 0000000..a3b12a0
64811 --- /dev/null
64812 +++ b/grsecurity/grsec_pax.c
64813 @@ -0,0 +1,36 @@
64814 +#include <linux/kernel.h>
64815 +#include <linux/sched.h>
64816 +#include <linux/mm.h>
64817 +#include <linux/file.h>
64818 +#include <linux/grinternal.h>
64819 +#include <linux/grsecurity.h>
64820 +
64821 +void
64822 +gr_log_textrel(struct vm_area_struct * vma)
64823 +{
64824 +#ifdef CONFIG_GRKERNSEC_AUDIT_TEXTREL
64825 + if (grsec_enable_audit_textrel)
64826 + gr_log_textrel_ulong_ulong(GR_DO_AUDIT, GR_TEXTREL_AUDIT_MSG, vma->vm_file, vma->vm_start, vma->vm_pgoff);
64827 +#endif
64828 + return;
64829 +}
64830 +
64831 +void
64832 +gr_log_rwxmmap(struct file *file)
64833 +{
64834 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
64835 + if (grsec_enable_log_rwxmaps)
64836 + gr_log_rwxmap(GR_DONT_AUDIT, GR_RWXMMAP_MSG, file);
64837 +#endif
64838 + return;
64839 +}
64840 +
64841 +void
64842 +gr_log_rwxmprotect(struct file *file)
64843 +{
64844 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
64845 + if (grsec_enable_log_rwxmaps)
64846 + gr_log_rwxmap(GR_DONT_AUDIT, GR_RWXMPROTECT_MSG, file);
64847 +#endif
64848 + return;
64849 +}
64850 diff --git a/grsecurity/grsec_ptrace.c b/grsecurity/grsec_ptrace.c
64851 new file mode 100644
64852 index 0000000..f7f29aa
64853 --- /dev/null
64854 +++ b/grsecurity/grsec_ptrace.c
64855 @@ -0,0 +1,30 @@
64856 +#include <linux/kernel.h>
64857 +#include <linux/sched.h>
64858 +#include <linux/grinternal.h>
64859 +#include <linux/security.h>
64860 +
64861 +void
64862 +gr_audit_ptrace(struct task_struct *task)
64863 +{
64864 +#ifdef CONFIG_GRKERNSEC_AUDIT_PTRACE
64865 + if (grsec_enable_audit_ptrace)
64866 + gr_log_ptrace(GR_DO_AUDIT, GR_PTRACE_AUDIT_MSG, task);
64867 +#endif
64868 + return;
64869 +}
64870 +
64871 +int
64872 +gr_ptrace_readexec(struct file *file, int unsafe_flags)
64873 +{
64874 +#ifdef CONFIG_GRKERNSEC_PTRACE_READEXEC
64875 + const struct dentry *dentry = file->f_path.dentry;
64876 + const struct vfsmount *mnt = file->f_path.mnt;
64877 +
64878 + if (grsec_enable_ptrace_readexec && (unsafe_flags & LSM_UNSAFE_PTRACE) &&
64879 + (inode_permission(dentry->d_inode, MAY_READ) || !gr_acl_handle_open(dentry, mnt, MAY_READ))) {
64880 + gr_log_fs_generic(GR_DONT_AUDIT, GR_PTRACE_READEXEC_MSG, dentry, mnt);
64881 + return -EACCES;
64882 + }
64883 +#endif
64884 + return 0;
64885 +}
64886 diff --git a/grsecurity/grsec_sig.c b/grsecurity/grsec_sig.c
64887 new file mode 100644
64888 index 0000000..e09715a
64889 --- /dev/null
64890 +++ b/grsecurity/grsec_sig.c
64891 @@ -0,0 +1,222 @@
64892 +#include <linux/kernel.h>
64893 +#include <linux/sched.h>
64894 +#include <linux/delay.h>
64895 +#include <linux/grsecurity.h>
64896 +#include <linux/grinternal.h>
64897 +#include <linux/hardirq.h>
64898 +
64899 +char *signames[] = {
64900 + [SIGSEGV] = "Segmentation fault",
64901 + [SIGILL] = "Illegal instruction",
64902 + [SIGABRT] = "Abort",
64903 + [SIGBUS] = "Invalid alignment/Bus error"
64904 +};
64905 +
64906 +void
64907 +gr_log_signal(const int sig, const void *addr, const struct task_struct *t)
64908 +{
64909 +#ifdef CONFIG_GRKERNSEC_SIGNAL
64910 + if (grsec_enable_signal && ((sig == SIGSEGV) || (sig == SIGILL) ||
64911 + (sig == SIGABRT) || (sig == SIGBUS))) {
64912 + if (task_pid_nr(t) == task_pid_nr(current)) {
64913 + gr_log_sig_addr(GR_DONT_AUDIT_GOOD, GR_UNISIGLOG_MSG, signames[sig], addr);
64914 + } else {
64915 + gr_log_sig_task(GR_DONT_AUDIT_GOOD, GR_DUALSIGLOG_MSG, t, sig);
64916 + }
64917 + }
64918 +#endif
64919 + return;
64920 +}
64921 +
64922 +int
64923 +gr_handle_signal(const struct task_struct *p, const int sig)
64924 +{
64925 +#ifdef CONFIG_GRKERNSEC
64926 + /* ignore the 0 signal for protected task checks */
64927 + if (task_pid_nr(current) > 1 && sig && gr_check_protected_task(p)) {
64928 + gr_log_sig_task(GR_DONT_AUDIT, GR_SIG_ACL_MSG, p, sig);
64929 + return -EPERM;
64930 + } else if (gr_pid_is_chrooted((struct task_struct *)p)) {
64931 + return -EPERM;
64932 + }
64933 +#endif
64934 + return 0;
64935 +}
64936 +
64937 +#ifdef CONFIG_GRKERNSEC
64938 +extern int specific_send_sig_info(int sig, struct siginfo *info, struct task_struct *t);
64939 +
64940 +int gr_fake_force_sig(int sig, struct task_struct *t)
64941 +{
64942 + unsigned long int flags;
64943 + int ret, blocked, ignored;
64944 + struct k_sigaction *action;
64945 +
64946 + spin_lock_irqsave(&t->sighand->siglock, flags);
64947 + action = &t->sighand->action[sig-1];
64948 + ignored = action->sa.sa_handler == SIG_IGN;
64949 + blocked = sigismember(&t->blocked, sig);
64950 + if (blocked || ignored) {
64951 + action->sa.sa_handler = SIG_DFL;
64952 + if (blocked) {
64953 + sigdelset(&t->blocked, sig);
64954 + recalc_sigpending_and_wake(t);
64955 + }
64956 + }
64957 + if (action->sa.sa_handler == SIG_DFL)
64958 + t->signal->flags &= ~SIGNAL_UNKILLABLE;
64959 + ret = specific_send_sig_info(sig, SEND_SIG_PRIV, t);
64960 +
64961 + spin_unlock_irqrestore(&t->sighand->siglock, flags);
64962 +
64963 + return ret;
64964 +}
64965 +#endif
64966 +
64967 +#ifdef CONFIG_GRKERNSEC_BRUTE
64968 +#define GR_USER_BAN_TIME (15 * 60)
64969 +#define GR_DAEMON_BRUTE_TIME (30 * 60)
64970 +
64971 +static int __get_dumpable(unsigned long mm_flags)
64972 +{
64973 + int ret;
64974 +
64975 + ret = mm_flags & MMF_DUMPABLE_MASK;
64976 + return (ret >= 2) ? 2 : ret;
64977 +}
64978 +#endif
64979 +
64980 +void gr_handle_brute_attach(unsigned long mm_flags)
64981 +{
64982 +#ifdef CONFIG_GRKERNSEC_BRUTE
64983 + struct task_struct *p = current;
64984 + kuid_t uid = GLOBAL_ROOT_UID;
64985 + int daemon = 0;
64986 +
64987 + if (!grsec_enable_brute)
64988 + return;
64989 +
64990 + rcu_read_lock();
64991 + read_lock(&tasklist_lock);
64992 + read_lock(&grsec_exec_file_lock);
64993 + if (p->real_parent && p->real_parent->exec_file == p->exec_file) {
64994 + p->real_parent->brute_expires = get_seconds() + GR_DAEMON_BRUTE_TIME;
64995 + p->real_parent->brute = 1;
64996 + daemon = 1;
64997 + } else {
64998 + const struct cred *cred = __task_cred(p), *cred2;
64999 + struct task_struct *tsk, *tsk2;
65000 +
65001 + if (!__get_dumpable(mm_flags) && gr_is_global_nonroot(cred->uid)) {
65002 + struct user_struct *user;
65003 +
65004 + uid = cred->uid;
65005 +
65006 + /* this is put upon execution past expiration */
65007 + user = find_user(uid);
65008 + if (user == NULL)
65009 + goto unlock;
65010 + user->banned = 1;
65011 + user->ban_expires = get_seconds() + GR_USER_BAN_TIME;
65012 + if (user->ban_expires == ~0UL)
65013 + user->ban_expires--;
65014 +
65015 + do_each_thread(tsk2, tsk) {
65016 + cred2 = __task_cred(tsk);
65017 + if (tsk != p && uid_eq(cred2->uid, uid))
65018 + gr_fake_force_sig(SIGKILL, tsk);
65019 + } while_each_thread(tsk2, tsk);
65020 + }
65021 + }
65022 +unlock:
65023 + read_unlock(&grsec_exec_file_lock);
65024 + read_unlock(&tasklist_lock);
65025 + rcu_read_unlock();
65026 +
65027 + if (gr_is_global_nonroot(uid))
65028 + printk(KERN_ALERT "grsec: bruteforce prevention initiated against uid %u, banning for %d minutes\n",
65029 + GR_GLOBAL_UID(uid), GR_USER_BAN_TIME / 60);
65030 + else if (daemon)
65031 + gr_log_noargs(GR_DONT_AUDIT, GR_BRUTE_DAEMON_MSG);
65032 +
65033 +#endif
65034 + return;
65035 +}
65036 +
65037 +void gr_handle_brute_check(void)
65038 +{
65039 +#ifdef CONFIG_GRKERNSEC_BRUTE
65040 + struct task_struct *p = current;
65041 +
65042 + if (unlikely(p->brute)) {
65043 + if (!grsec_enable_brute)
65044 + p->brute = 0;
65045 + else if (time_before(get_seconds(), p->brute_expires))
65046 + msleep(30 * 1000);
65047 + }
65048 +#endif
65049 + return;
65050 +}
65051 +
65052 +void gr_handle_kernel_exploit(void)
65053 +{
65054 +#ifdef CONFIG_GRKERNSEC_KERN_LOCKOUT
65055 + const struct cred *cred;
65056 + struct task_struct *tsk, *tsk2;
65057 + struct user_struct *user;
65058 + kuid_t uid;
65059 +
65060 + if (in_irq() || in_serving_softirq() || in_nmi())
65061 + panic("grsec: halting the system due to suspicious kernel crash caused in interrupt context");
65062 +
65063 + uid = current_uid();
65064 +
65065 + if (gr_is_global_root(uid))
65066 + panic("grsec: halting the system due to suspicious kernel crash caused by root");
65067 + else {
65068 + /* kill all the processes of this user, hold a reference
65069 + to their creds struct, and prevent them from creating
65070 + another process until system reset
65071 + */
65072 + printk(KERN_ALERT "grsec: banning user with uid %u until system restart for suspicious kernel crash\n",
65073 + GR_GLOBAL_UID(uid));
65074 + /* we intentionally leak this ref */
65075 + user = get_uid(current->cred->user);
65076 + if (user) {
65077 + user->banned = 1;
65078 + user->ban_expires = ~0UL;
65079 + }
65080 +
65081 + read_lock(&tasklist_lock);
65082 + do_each_thread(tsk2, tsk) {
65083 + cred = __task_cred(tsk);
65084 + if (uid_eq(cred->uid, uid))
65085 + gr_fake_force_sig(SIGKILL, tsk);
65086 + } while_each_thread(tsk2, tsk);
65087 + read_unlock(&tasklist_lock);
65088 + }
65089 +#endif
65090 +}
65091 +
65092 +int __gr_process_user_ban(struct user_struct *user)
65093 +{
65094 +#if defined(CONFIG_GRKERNSEC_KERN_LOCKOUT) || defined(CONFIG_GRKERNSEC_BRUTE)
65095 + if (unlikely(user->banned)) {
65096 + if (user->ban_expires != ~0UL && time_after_eq(get_seconds(), user->ban_expires)) {
65097 + user->banned = 0;
65098 + user->ban_expires = 0;
65099 + free_uid(user);
65100 + } else
65101 + return -EPERM;
65102 + }
65103 +#endif
65104 + return 0;
65105 +}
65106 +
65107 +int gr_process_user_ban(void)
65108 +{
65109 +#if defined(CONFIG_GRKERNSEC_KERN_LOCKOUT) || defined(CONFIG_GRKERNSEC_BRUTE)
65110 + return __gr_process_user_ban(current->cred->user);
65111 +#endif
65112 + return 0;
65113 +}
65114 diff --git a/grsecurity/grsec_sock.c b/grsecurity/grsec_sock.c
65115 new file mode 100644
65116 index 0000000..4030d57
65117 --- /dev/null
65118 +++ b/grsecurity/grsec_sock.c
65119 @@ -0,0 +1,244 @@
65120 +#include <linux/kernel.h>
65121 +#include <linux/module.h>
65122 +#include <linux/sched.h>
65123 +#include <linux/file.h>
65124 +#include <linux/net.h>
65125 +#include <linux/in.h>
65126 +#include <linux/ip.h>
65127 +#include <net/sock.h>
65128 +#include <net/inet_sock.h>
65129 +#include <linux/grsecurity.h>
65130 +#include <linux/grinternal.h>
65131 +#include <linux/gracl.h>
65132 +
65133 +extern int gr_search_udp_recvmsg(const struct sock *sk, const struct sk_buff *skb);
65134 +extern int gr_search_udp_sendmsg(const struct sock *sk, const struct sockaddr_in *addr);
65135 +
65136 +EXPORT_SYMBOL(gr_search_udp_recvmsg);
65137 +EXPORT_SYMBOL(gr_search_udp_sendmsg);
65138 +
65139 +#ifdef CONFIG_UNIX_MODULE
65140 +EXPORT_SYMBOL(gr_acl_handle_unix);
65141 +EXPORT_SYMBOL(gr_acl_handle_mknod);
65142 +EXPORT_SYMBOL(gr_handle_chroot_unix);
65143 +EXPORT_SYMBOL(gr_handle_create);
65144 +#endif
65145 +
65146 +#ifdef CONFIG_GRKERNSEC
65147 +#define gr_conn_table_size 32749
65148 +struct conn_table_entry {
65149 + struct conn_table_entry *next;
65150 + struct signal_struct *sig;
65151 +};
65152 +
65153 +struct conn_table_entry *gr_conn_table[gr_conn_table_size];
65154 +DEFINE_SPINLOCK(gr_conn_table_lock);
65155 +
65156 +extern const char * gr_socktype_to_name(unsigned char type);
65157 +extern const char * gr_proto_to_name(unsigned char proto);
65158 +extern const char * gr_sockfamily_to_name(unsigned char family);
65159 +
65160 +static __inline__ int
65161 +conn_hash(__u32 saddr, __u32 daddr, __u16 sport, __u16 dport, unsigned int size)
65162 +{
65163 + return ((daddr + saddr + (sport << 8) + (dport << 16)) % size);
65164 +}
65165 +
65166 +static __inline__ int
65167 +conn_match(const struct signal_struct *sig, __u32 saddr, __u32 daddr,
65168 + __u16 sport, __u16 dport)
65169 +{
65170 + if (unlikely(sig->gr_saddr == saddr && sig->gr_daddr == daddr &&
65171 + sig->gr_sport == sport && sig->gr_dport == dport))
65172 + return 1;
65173 + else
65174 + return 0;
65175 +}
65176 +
65177 +static void gr_add_to_task_ip_table_nolock(struct signal_struct *sig, struct conn_table_entry *newent)
65178 +{
65179 + struct conn_table_entry **match;
65180 + unsigned int index;
65181 +
65182 + index = conn_hash(sig->gr_saddr, sig->gr_daddr,
65183 + sig->gr_sport, sig->gr_dport,
65184 + gr_conn_table_size);
65185 +
65186 + newent->sig = sig;
65187 +
65188 + match = &gr_conn_table[index];
65189 + newent->next = *match;
65190 + *match = newent;
65191 +
65192 + return;
65193 +}
65194 +
65195 +static void gr_del_task_from_ip_table_nolock(struct signal_struct *sig)
65196 +{
65197 + struct conn_table_entry *match, *last = NULL;
65198 + unsigned int index;
65199 +
65200 + index = conn_hash(sig->gr_saddr, sig->gr_daddr,
65201 + sig->gr_sport, sig->gr_dport,
65202 + gr_conn_table_size);
65203 +
65204 + match = gr_conn_table[index];
65205 + while (match && !conn_match(match->sig,
65206 + sig->gr_saddr, sig->gr_daddr, sig->gr_sport,
65207 + sig->gr_dport)) {
65208 + last = match;
65209 + match = match->next;
65210 + }
65211 +
65212 + if (match) {
65213 + if (last)
65214 + last->next = match->next;
65215 + else
65216 + gr_conn_table[index] = NULL;
65217 + kfree(match);
65218 + }
65219 +
65220 + return;
65221 +}
65222 +
65223 +static struct signal_struct * gr_lookup_task_ip_table(__u32 saddr, __u32 daddr,
65224 + __u16 sport, __u16 dport)
65225 +{
65226 + struct conn_table_entry *match;
65227 + unsigned int index;
65228 +
65229 + index = conn_hash(saddr, daddr, sport, dport, gr_conn_table_size);
65230 +
65231 + match = gr_conn_table[index];
65232 + while (match && !conn_match(match->sig, saddr, daddr, sport, dport))
65233 + match = match->next;
65234 +
65235 + if (match)
65236 + return match->sig;
65237 + else
65238 + return NULL;
65239 +}
65240 +
65241 +#endif
65242 +
65243 +void gr_update_task_in_ip_table(struct task_struct *task, const struct inet_sock *inet)
65244 +{
65245 +#ifdef CONFIG_GRKERNSEC
65246 + struct signal_struct *sig = task->signal;
65247 + struct conn_table_entry *newent;
65248 +
65249 + newent = kmalloc(sizeof(struct conn_table_entry), GFP_ATOMIC);
65250 + if (newent == NULL)
65251 + return;
65252 + /* no bh lock needed since we are called with bh disabled */
65253 + spin_lock(&gr_conn_table_lock);
65254 + gr_del_task_from_ip_table_nolock(sig);
65255 + sig->gr_saddr = inet->inet_rcv_saddr;
65256 + sig->gr_daddr = inet->inet_daddr;
65257 + sig->gr_sport = inet->inet_sport;
65258 + sig->gr_dport = inet->inet_dport;
65259 + gr_add_to_task_ip_table_nolock(sig, newent);
65260 + spin_unlock(&gr_conn_table_lock);
65261 +#endif
65262 + return;
65263 +}
65264 +
65265 +void gr_del_task_from_ip_table(struct task_struct *task)
65266 +{
65267 +#ifdef CONFIG_GRKERNSEC
65268 + spin_lock_bh(&gr_conn_table_lock);
65269 + gr_del_task_from_ip_table_nolock(task->signal);
65270 + spin_unlock_bh(&gr_conn_table_lock);
65271 +#endif
65272 + return;
65273 +}
65274 +
65275 +void
65276 +gr_attach_curr_ip(const struct sock *sk)
65277 +{
65278 +#ifdef CONFIG_GRKERNSEC
65279 + struct signal_struct *p, *set;
65280 + const struct inet_sock *inet = inet_sk(sk);
65281 +
65282 + if (unlikely(sk->sk_protocol != IPPROTO_TCP))
65283 + return;
65284 +
65285 + set = current->signal;
65286 +
65287 + spin_lock_bh(&gr_conn_table_lock);
65288 + p = gr_lookup_task_ip_table(inet->inet_daddr, inet->inet_rcv_saddr,
65289 + inet->inet_dport, inet->inet_sport);
65290 + if (unlikely(p != NULL)) {
65291 + set->curr_ip = p->curr_ip;
65292 + set->used_accept = 1;
65293 + gr_del_task_from_ip_table_nolock(p);
65294 + spin_unlock_bh(&gr_conn_table_lock);
65295 + return;
65296 + }
65297 + spin_unlock_bh(&gr_conn_table_lock);
65298 +
65299 + set->curr_ip = inet->inet_daddr;
65300 + set->used_accept = 1;
65301 +#endif
65302 + return;
65303 +}
65304 +
65305 +int
65306 +gr_handle_sock_all(const int family, const int type, const int protocol)
65307 +{
65308 +#ifdef CONFIG_GRKERNSEC_SOCKET_ALL
65309 + if (grsec_enable_socket_all && in_group_p(grsec_socket_all_gid) &&
65310 + (family != AF_UNIX)) {
65311 + if (family == AF_INET)
65312 + gr_log_str3(GR_DONT_AUDIT, GR_SOCK_MSG, gr_sockfamily_to_name(family), gr_socktype_to_name(type), gr_proto_to_name(protocol));
65313 + else
65314 + gr_log_str2_int(GR_DONT_AUDIT, GR_SOCK_NOINET_MSG, gr_sockfamily_to_name(family), gr_socktype_to_name(type), protocol);
65315 + return -EACCES;
65316 + }
65317 +#endif
65318 + return 0;
65319 +}
65320 +
65321 +int
65322 +gr_handle_sock_server(const struct sockaddr *sck)
65323 +{
65324 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
65325 + if (grsec_enable_socket_server &&
65326 + in_group_p(grsec_socket_server_gid) &&
65327 + sck && (sck->sa_family != AF_UNIX) &&
65328 + (sck->sa_family != AF_LOCAL)) {
65329 + gr_log_noargs(GR_DONT_AUDIT, GR_BIND_MSG);
65330 + return -EACCES;
65331 + }
65332 +#endif
65333 + return 0;
65334 +}
65335 +
65336 +int
65337 +gr_handle_sock_server_other(const struct sock *sck)
65338 +{
65339 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
65340 + if (grsec_enable_socket_server &&
65341 + in_group_p(grsec_socket_server_gid) &&
65342 + sck && (sck->sk_family != AF_UNIX) &&
65343 + (sck->sk_family != AF_LOCAL)) {
65344 + gr_log_noargs(GR_DONT_AUDIT, GR_BIND_MSG);
65345 + return -EACCES;
65346 + }
65347 +#endif
65348 + return 0;
65349 +}
65350 +
65351 +int
65352 +gr_handle_sock_client(const struct sockaddr *sck)
65353 +{
65354 +#ifdef CONFIG_GRKERNSEC_SOCKET_CLIENT
65355 + if (grsec_enable_socket_client && in_group_p(grsec_socket_client_gid) &&
65356 + sck && (sck->sa_family != AF_UNIX) &&
65357 + (sck->sa_family != AF_LOCAL)) {
65358 + gr_log_noargs(GR_DONT_AUDIT, GR_CONNECT_MSG);
65359 + return -EACCES;
65360 + }
65361 +#endif
65362 + return 0;
65363 +}
65364 diff --git a/grsecurity/grsec_sysctl.c b/grsecurity/grsec_sysctl.c
65365 new file mode 100644
65366 index 0000000..f55ef0f
65367 --- /dev/null
65368 +++ b/grsecurity/grsec_sysctl.c
65369 @@ -0,0 +1,469 @@
65370 +#include <linux/kernel.h>
65371 +#include <linux/sched.h>
65372 +#include <linux/sysctl.h>
65373 +#include <linux/grsecurity.h>
65374 +#include <linux/grinternal.h>
65375 +
65376 +int
65377 +gr_handle_sysctl_mod(const char *dirname, const char *name, const int op)
65378 +{
65379 +#ifdef CONFIG_GRKERNSEC_SYSCTL
65380 + if (dirname == NULL || name == NULL)
65381 + return 0;
65382 + if (!strcmp(dirname, "grsecurity") && grsec_lock && (op & MAY_WRITE)) {
65383 + gr_log_str(GR_DONT_AUDIT, GR_SYSCTL_MSG, name);
65384 + return -EACCES;
65385 + }
65386 +#endif
65387 + return 0;
65388 +}
65389 +
65390 +#ifdef CONFIG_GRKERNSEC_ROFS
65391 +static int __maybe_unused one = 1;
65392 +#endif
65393 +
65394 +#if defined(CONFIG_GRKERNSEC_SYSCTL) || defined(CONFIG_GRKERNSEC_ROFS)
65395 +struct ctl_table grsecurity_table[] = {
65396 +#ifdef CONFIG_GRKERNSEC_SYSCTL
65397 +#ifdef CONFIG_GRKERNSEC_SYSCTL_DISTRO
65398 +#ifdef CONFIG_GRKERNSEC_IO
65399 + {
65400 + .procname = "disable_priv_io",
65401 + .data = &grsec_disable_privio,
65402 + .maxlen = sizeof(int),
65403 + .mode = 0600,
65404 + .proc_handler = &proc_dointvec,
65405 + },
65406 +#endif
65407 +#endif
65408 +#ifdef CONFIG_GRKERNSEC_LINK
65409 + {
65410 + .procname = "linking_restrictions",
65411 + .data = &grsec_enable_link,
65412 + .maxlen = sizeof(int),
65413 + .mode = 0600,
65414 + .proc_handler = &proc_dointvec,
65415 + },
65416 +#endif
65417 +#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
65418 + {
65419 + .procname = "enforce_symlinksifowner",
65420 + .data = &grsec_enable_symlinkown,
65421 + .maxlen = sizeof(int),
65422 + .mode = 0600,
65423 + .proc_handler = &proc_dointvec,
65424 + },
65425 + {
65426 + .procname = "symlinkown_gid",
65427 + .data = &grsec_symlinkown_gid,
65428 + .maxlen = sizeof(int),
65429 + .mode = 0600,
65430 + .proc_handler = &proc_dointvec,
65431 + },
65432 +#endif
65433 +#ifdef CONFIG_GRKERNSEC_BRUTE
65434 + {
65435 + .procname = "deter_bruteforce",
65436 + .data = &grsec_enable_brute,
65437 + .maxlen = sizeof(int),
65438 + .mode = 0600,
65439 + .proc_handler = &proc_dointvec,
65440 + },
65441 +#endif
65442 +#ifdef CONFIG_GRKERNSEC_FIFO
65443 + {
65444 + .procname = "fifo_restrictions",
65445 + .data = &grsec_enable_fifo,
65446 + .maxlen = sizeof(int),
65447 + .mode = 0600,
65448 + .proc_handler = &proc_dointvec,
65449 + },
65450 +#endif
65451 +#ifdef CONFIG_GRKERNSEC_PTRACE_READEXEC
65452 + {
65453 + .procname = "ptrace_readexec",
65454 + .data = &grsec_enable_ptrace_readexec,
65455 + .maxlen = sizeof(int),
65456 + .mode = 0600,
65457 + .proc_handler = &proc_dointvec,
65458 + },
65459 +#endif
65460 +#ifdef CONFIG_GRKERNSEC_SETXID
65461 + {
65462 + .procname = "consistent_setxid",
65463 + .data = &grsec_enable_setxid,
65464 + .maxlen = sizeof(int),
65465 + .mode = 0600,
65466 + .proc_handler = &proc_dointvec,
65467 + },
65468 +#endif
65469 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
65470 + {
65471 + .procname = "ip_blackhole",
65472 + .data = &grsec_enable_blackhole,
65473 + .maxlen = sizeof(int),
65474 + .mode = 0600,
65475 + .proc_handler = &proc_dointvec,
65476 + },
65477 + {
65478 + .procname = "lastack_retries",
65479 + .data = &grsec_lastack_retries,
65480 + .maxlen = sizeof(int),
65481 + .mode = 0600,
65482 + .proc_handler = &proc_dointvec,
65483 + },
65484 +#endif
65485 +#ifdef CONFIG_GRKERNSEC_EXECLOG
65486 + {
65487 + .procname = "exec_logging",
65488 + .data = &grsec_enable_execlog,
65489 + .maxlen = sizeof(int),
65490 + .mode = 0600,
65491 + .proc_handler = &proc_dointvec,
65492 + },
65493 +#endif
65494 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
65495 + {
65496 + .procname = "rwxmap_logging",
65497 + .data = &grsec_enable_log_rwxmaps,
65498 + .maxlen = sizeof(int),
65499 + .mode = 0600,
65500 + .proc_handler = &proc_dointvec,
65501 + },
65502 +#endif
65503 +#ifdef CONFIG_GRKERNSEC_SIGNAL
65504 + {
65505 + .procname = "signal_logging",
65506 + .data = &grsec_enable_signal,
65507 + .maxlen = sizeof(int),
65508 + .mode = 0600,
65509 + .proc_handler = &proc_dointvec,
65510 + },
65511 +#endif
65512 +#ifdef CONFIG_GRKERNSEC_FORKFAIL
65513 + {
65514 + .procname = "forkfail_logging",
65515 + .data = &grsec_enable_forkfail,
65516 + .maxlen = sizeof(int),
65517 + .mode = 0600,
65518 + .proc_handler = &proc_dointvec,
65519 + },
65520 +#endif
65521 +#ifdef CONFIG_GRKERNSEC_TIME
65522 + {
65523 + .procname = "timechange_logging",
65524 + .data = &grsec_enable_time,
65525 + .maxlen = sizeof(int),
65526 + .mode = 0600,
65527 + .proc_handler = &proc_dointvec,
65528 + },
65529 +#endif
65530 +#ifdef CONFIG_GRKERNSEC_CHROOT_SHMAT
65531 + {
65532 + .procname = "chroot_deny_shmat",
65533 + .data = &grsec_enable_chroot_shmat,
65534 + .maxlen = sizeof(int),
65535 + .mode = 0600,
65536 + .proc_handler = &proc_dointvec,
65537 + },
65538 +#endif
65539 +#ifdef CONFIG_GRKERNSEC_CHROOT_UNIX
65540 + {
65541 + .procname = "chroot_deny_unix",
65542 + .data = &grsec_enable_chroot_unix,
65543 + .maxlen = sizeof(int),
65544 + .mode = 0600,
65545 + .proc_handler = &proc_dointvec,
65546 + },
65547 +#endif
65548 +#ifdef CONFIG_GRKERNSEC_CHROOT_MOUNT
65549 + {
65550 + .procname = "chroot_deny_mount",
65551 + .data = &grsec_enable_chroot_mount,
65552 + .maxlen = sizeof(int),
65553 + .mode = 0600,
65554 + .proc_handler = &proc_dointvec,
65555 + },
65556 +#endif
65557 +#ifdef CONFIG_GRKERNSEC_CHROOT_FCHDIR
65558 + {
65559 + .procname = "chroot_deny_fchdir",
65560 + .data = &grsec_enable_chroot_fchdir,
65561 + .maxlen = sizeof(int),
65562 + .mode = 0600,
65563 + .proc_handler = &proc_dointvec,
65564 + },
65565 +#endif
65566 +#ifdef CONFIG_GRKERNSEC_CHROOT_DOUBLE
65567 + {
65568 + .procname = "chroot_deny_chroot",
65569 + .data = &grsec_enable_chroot_double,
65570 + .maxlen = sizeof(int),
65571 + .mode = 0600,
65572 + .proc_handler = &proc_dointvec,
65573 + },
65574 +#endif
65575 +#ifdef CONFIG_GRKERNSEC_CHROOT_PIVOT
65576 + {
65577 + .procname = "chroot_deny_pivot",
65578 + .data = &grsec_enable_chroot_pivot,
65579 + .maxlen = sizeof(int),
65580 + .mode = 0600,
65581 + .proc_handler = &proc_dointvec,
65582 + },
65583 +#endif
65584 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHDIR
65585 + {
65586 + .procname = "chroot_enforce_chdir",
65587 + .data = &grsec_enable_chroot_chdir,
65588 + .maxlen = sizeof(int),
65589 + .mode = 0600,
65590 + .proc_handler = &proc_dointvec,
65591 + },
65592 +#endif
65593 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHMOD
65594 + {
65595 + .procname = "chroot_deny_chmod",
65596 + .data = &grsec_enable_chroot_chmod,
65597 + .maxlen = sizeof(int),
65598 + .mode = 0600,
65599 + .proc_handler = &proc_dointvec,
65600 + },
65601 +#endif
65602 +#ifdef CONFIG_GRKERNSEC_CHROOT_MKNOD
65603 + {
65604 + .procname = "chroot_deny_mknod",
65605 + .data = &grsec_enable_chroot_mknod,
65606 + .maxlen = sizeof(int),
65607 + .mode = 0600,
65608 + .proc_handler = &proc_dointvec,
65609 + },
65610 +#endif
65611 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
65612 + {
65613 + .procname = "chroot_restrict_nice",
65614 + .data = &grsec_enable_chroot_nice,
65615 + .maxlen = sizeof(int),
65616 + .mode = 0600,
65617 + .proc_handler = &proc_dointvec,
65618 + },
65619 +#endif
65620 +#ifdef CONFIG_GRKERNSEC_CHROOT_EXECLOG
65621 + {
65622 + .procname = "chroot_execlog",
65623 + .data = &grsec_enable_chroot_execlog,
65624 + .maxlen = sizeof(int),
65625 + .mode = 0600,
65626 + .proc_handler = &proc_dointvec,
65627 + },
65628 +#endif
65629 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
65630 + {
65631 + .procname = "chroot_caps",
65632 + .data = &grsec_enable_chroot_caps,
65633 + .maxlen = sizeof(int),
65634 + .mode = 0600,
65635 + .proc_handler = &proc_dointvec,
65636 + },
65637 +#endif
65638 +#ifdef CONFIG_GRKERNSEC_CHROOT_SYSCTL
65639 + {
65640 + .procname = "chroot_deny_sysctl",
65641 + .data = &grsec_enable_chroot_sysctl,
65642 + .maxlen = sizeof(int),
65643 + .mode = 0600,
65644 + .proc_handler = &proc_dointvec,
65645 + },
65646 +#endif
65647 +#ifdef CONFIG_GRKERNSEC_TPE
65648 + {
65649 + .procname = "tpe",
65650 + .data = &grsec_enable_tpe,
65651 + .maxlen = sizeof(int),
65652 + .mode = 0600,
65653 + .proc_handler = &proc_dointvec,
65654 + },
65655 + {
65656 + .procname = "tpe_gid",
65657 + .data = &grsec_tpe_gid,
65658 + .maxlen = sizeof(int),
65659 + .mode = 0600,
65660 + .proc_handler = &proc_dointvec,
65661 + },
65662 +#endif
65663 +#ifdef CONFIG_GRKERNSEC_TPE_INVERT
65664 + {
65665 + .procname = "tpe_invert",
65666 + .data = &grsec_enable_tpe_invert,
65667 + .maxlen = sizeof(int),
65668 + .mode = 0600,
65669 + .proc_handler = &proc_dointvec,
65670 + },
65671 +#endif
65672 +#ifdef CONFIG_GRKERNSEC_TPE_ALL
65673 + {
65674 + .procname = "tpe_restrict_all",
65675 + .data = &grsec_enable_tpe_all,
65676 + .maxlen = sizeof(int),
65677 + .mode = 0600,
65678 + .proc_handler = &proc_dointvec,
65679 + },
65680 +#endif
65681 +#ifdef CONFIG_GRKERNSEC_SOCKET_ALL
65682 + {
65683 + .procname = "socket_all",
65684 + .data = &grsec_enable_socket_all,
65685 + .maxlen = sizeof(int),
65686 + .mode = 0600,
65687 + .proc_handler = &proc_dointvec,
65688 + },
65689 + {
65690 + .procname = "socket_all_gid",
65691 + .data = &grsec_socket_all_gid,
65692 + .maxlen = sizeof(int),
65693 + .mode = 0600,
65694 + .proc_handler = &proc_dointvec,
65695 + },
65696 +#endif
65697 +#ifdef CONFIG_GRKERNSEC_SOCKET_CLIENT
65698 + {
65699 + .procname = "socket_client",
65700 + .data = &grsec_enable_socket_client,
65701 + .maxlen = sizeof(int),
65702 + .mode = 0600,
65703 + .proc_handler = &proc_dointvec,
65704 + },
65705 + {
65706 + .procname = "socket_client_gid",
65707 + .data = &grsec_socket_client_gid,
65708 + .maxlen = sizeof(int),
65709 + .mode = 0600,
65710 + .proc_handler = &proc_dointvec,
65711 + },
65712 +#endif
65713 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
65714 + {
65715 + .procname = "socket_server",
65716 + .data = &grsec_enable_socket_server,
65717 + .maxlen = sizeof(int),
65718 + .mode = 0600,
65719 + .proc_handler = &proc_dointvec,
65720 + },
65721 + {
65722 + .procname = "socket_server_gid",
65723 + .data = &grsec_socket_server_gid,
65724 + .maxlen = sizeof(int),
65725 + .mode = 0600,
65726 + .proc_handler = &proc_dointvec,
65727 + },
65728 +#endif
65729 +#ifdef CONFIG_GRKERNSEC_AUDIT_GROUP
65730 + {
65731 + .procname = "audit_group",
65732 + .data = &grsec_enable_group,
65733 + .maxlen = sizeof(int),
65734 + .mode = 0600,
65735 + .proc_handler = &proc_dointvec,
65736 + },
65737 + {
65738 + .procname = "audit_gid",
65739 + .data = &grsec_audit_gid,
65740 + .maxlen = sizeof(int),
65741 + .mode = 0600,
65742 + .proc_handler = &proc_dointvec,
65743 + },
65744 +#endif
65745 +#ifdef CONFIG_GRKERNSEC_AUDIT_CHDIR
65746 + {
65747 + .procname = "audit_chdir",
65748 + .data = &grsec_enable_chdir,
65749 + .maxlen = sizeof(int),
65750 + .mode = 0600,
65751 + .proc_handler = &proc_dointvec,
65752 + },
65753 +#endif
65754 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
65755 + {
65756 + .procname = "audit_mount",
65757 + .data = &grsec_enable_mount,
65758 + .maxlen = sizeof(int),
65759 + .mode = 0600,
65760 + .proc_handler = &proc_dointvec,
65761 + },
65762 +#endif
65763 +#ifdef CONFIG_GRKERNSEC_AUDIT_TEXTREL
65764 + {
65765 + .procname = "audit_textrel",
65766 + .data = &grsec_enable_audit_textrel,
65767 + .maxlen = sizeof(int),
65768 + .mode = 0600,
65769 + .proc_handler = &proc_dointvec,
65770 + },
65771 +#endif
65772 +#ifdef CONFIG_GRKERNSEC_DMESG
65773 + {
65774 + .procname = "dmesg",
65775 + .data = &grsec_enable_dmesg,
65776 + .maxlen = sizeof(int),
65777 + .mode = 0600,
65778 + .proc_handler = &proc_dointvec,
65779 + },
65780 +#endif
65781 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
65782 + {
65783 + .procname = "chroot_findtask",
65784 + .data = &grsec_enable_chroot_findtask,
65785 + .maxlen = sizeof(int),
65786 + .mode = 0600,
65787 + .proc_handler = &proc_dointvec,
65788 + },
65789 +#endif
65790 +#ifdef CONFIG_GRKERNSEC_RESLOG
65791 + {
65792 + .procname = "resource_logging",
65793 + .data = &grsec_resource_logging,
65794 + .maxlen = sizeof(int),
65795 + .mode = 0600,
65796 + .proc_handler = &proc_dointvec,
65797 + },
65798 +#endif
65799 +#ifdef CONFIG_GRKERNSEC_AUDIT_PTRACE
65800 + {
65801 + .procname = "audit_ptrace",
65802 + .data = &grsec_enable_audit_ptrace,
65803 + .maxlen = sizeof(int),
65804 + .mode = 0600,
65805 + .proc_handler = &proc_dointvec,
65806 + },
65807 +#endif
65808 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
65809 + {
65810 + .procname = "harden_ptrace",
65811 + .data = &grsec_enable_harden_ptrace,
65812 + .maxlen = sizeof(int),
65813 + .mode = 0600,
65814 + .proc_handler = &proc_dointvec,
65815 + },
65816 +#endif
65817 + {
65818 + .procname = "grsec_lock",
65819 + .data = &grsec_lock,
65820 + .maxlen = sizeof(int),
65821 + .mode = 0600,
65822 + .proc_handler = &proc_dointvec,
65823 + },
65824 +#endif
65825 +#ifdef CONFIG_GRKERNSEC_ROFS
65826 + {
65827 + .procname = "romount_protect",
65828 + .data = &grsec_enable_rofs,
65829 + .maxlen = sizeof(int),
65830 + .mode = 0600,
65831 + .proc_handler = &proc_dointvec_minmax,
65832 + .extra1 = &one,
65833 + .extra2 = &one,
65834 + },
65835 +#endif
65836 + { }
65837 +};
65838 +#endif
65839 diff --git a/grsecurity/grsec_time.c b/grsecurity/grsec_time.c
65840 new file mode 100644
65841 index 0000000..0dc13c3
65842 --- /dev/null
65843 +++ b/grsecurity/grsec_time.c
65844 @@ -0,0 +1,16 @@
65845 +#include <linux/kernel.h>
65846 +#include <linux/sched.h>
65847 +#include <linux/grinternal.h>
65848 +#include <linux/module.h>
65849 +
65850 +void
65851 +gr_log_timechange(void)
65852 +{
65853 +#ifdef CONFIG_GRKERNSEC_TIME
65854 + if (grsec_enable_time)
65855 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_TIME_MSG);
65856 +#endif
65857 + return;
65858 +}
65859 +
65860 +EXPORT_SYMBOL(gr_log_timechange);
65861 diff --git a/grsecurity/grsec_tpe.c b/grsecurity/grsec_tpe.c
65862 new file mode 100644
65863 index 0000000..ee57dcf
65864 --- /dev/null
65865 +++ b/grsecurity/grsec_tpe.c
65866 @@ -0,0 +1,73 @@
65867 +#include <linux/kernel.h>
65868 +#include <linux/sched.h>
65869 +#include <linux/file.h>
65870 +#include <linux/fs.h>
65871 +#include <linux/grinternal.h>
65872 +
65873 +extern int gr_acl_tpe_check(void);
65874 +
65875 +int
65876 +gr_tpe_allow(const struct file *file)
65877 +{
65878 +#ifdef CONFIG_GRKERNSEC
65879 + struct inode *inode = file->f_path.dentry->d_parent->d_inode;
65880 + const struct cred *cred = current_cred();
65881 + char *msg = NULL;
65882 + char *msg2 = NULL;
65883 +
65884 + // never restrict root
65885 + if (gr_is_global_root(cred->uid))
65886 + return 1;
65887 +
65888 + if (grsec_enable_tpe) {
65889 +#ifdef CONFIG_GRKERNSEC_TPE_INVERT
65890 + if (grsec_enable_tpe_invert && !in_group_p(grsec_tpe_gid))
65891 + msg = "not being in trusted group";
65892 + else if (!grsec_enable_tpe_invert && in_group_p(grsec_tpe_gid))
65893 + msg = "being in untrusted group";
65894 +#else
65895 + if (in_group_p(grsec_tpe_gid))
65896 + msg = "being in untrusted group";
65897 +#endif
65898 + }
65899 + if (!msg && gr_acl_tpe_check())
65900 + msg = "being in untrusted role";
65901 +
65902 + // not in any affected group/role
65903 + if (!msg)
65904 + goto next_check;
65905 +
65906 + if (gr_is_global_nonroot(inode->i_uid))
65907 + msg2 = "file in non-root-owned directory";
65908 + else if (inode->i_mode & S_IWOTH)
65909 + msg2 = "file in world-writable directory";
65910 + else if (inode->i_mode & S_IWGRP)
65911 + msg2 = "file in group-writable directory";
65912 +
65913 + if (msg && msg2) {
65914 + char fullmsg[70] = {0};
65915 + snprintf(fullmsg, sizeof(fullmsg)-1, "%s and %s", msg, msg2);
65916 + gr_log_str_fs(GR_DONT_AUDIT, GR_EXEC_TPE_MSG, fullmsg, file->f_path.dentry, file->f_path.mnt);
65917 + return 0;
65918 + }
65919 + msg = NULL;
65920 +next_check:
65921 +#ifdef CONFIG_GRKERNSEC_TPE_ALL
65922 + if (!grsec_enable_tpe || !grsec_enable_tpe_all)
65923 + return 1;
65924 +
65925 + if (gr_is_global_nonroot(inode->i_uid) && !uid_eq(inode->i_uid, cred->uid))
65926 + msg = "directory not owned by user";
65927 + else if (inode->i_mode & S_IWOTH)
65928 + msg = "file in world-writable directory";
65929 + else if (inode->i_mode & S_IWGRP)
65930 + msg = "file in group-writable directory";
65931 +
65932 + if (msg) {
65933 + gr_log_str_fs(GR_DONT_AUDIT, GR_EXEC_TPE_MSG, msg, file->f_path.dentry, file->f_path.mnt);
65934 + return 0;
65935 + }
65936 +#endif
65937 +#endif
65938 + return 1;
65939 +}
65940 diff --git a/grsecurity/grsum.c b/grsecurity/grsum.c
65941 new file mode 100644
65942 index 0000000..9f7b1ac
65943 --- /dev/null
65944 +++ b/grsecurity/grsum.c
65945 @@ -0,0 +1,61 @@
65946 +#include <linux/err.h>
65947 +#include <linux/kernel.h>
65948 +#include <linux/sched.h>
65949 +#include <linux/mm.h>
65950 +#include <linux/scatterlist.h>
65951 +#include <linux/crypto.h>
65952 +#include <linux/gracl.h>
65953 +
65954 +
65955 +#if !defined(CONFIG_CRYPTO) || defined(CONFIG_CRYPTO_MODULE) || !defined(CONFIG_CRYPTO_SHA256) || defined(CONFIG_CRYPTO_SHA256_MODULE)
65956 +#error "crypto and sha256 must be built into the kernel"
65957 +#endif
65958 +
65959 +int
65960 +chkpw(struct gr_arg *entry, unsigned char *salt, unsigned char *sum)
65961 +{
65962 + char *p;
65963 + struct crypto_hash *tfm;
65964 + struct hash_desc desc;
65965 + struct scatterlist sg;
65966 + unsigned char temp_sum[GR_SHA_LEN];
65967 + volatile int retval = 0;
65968 + volatile int dummy = 0;
65969 + unsigned int i;
65970 +
65971 + sg_init_table(&sg, 1);
65972 +
65973 + tfm = crypto_alloc_hash("sha256", 0, CRYPTO_ALG_ASYNC);
65974 + if (IS_ERR(tfm)) {
65975 + /* should never happen, since sha256 should be built in */
65976 + return 1;
65977 + }
65978 +
65979 + desc.tfm = tfm;
65980 + desc.flags = 0;
65981 +
65982 + crypto_hash_init(&desc);
65983 +
65984 + p = salt;
65985 + sg_set_buf(&sg, p, GR_SALT_LEN);
65986 + crypto_hash_update(&desc, &sg, sg.length);
65987 +
65988 + p = entry->pw;
65989 + sg_set_buf(&sg, p, strlen(p));
65990 +
65991 + crypto_hash_update(&desc, &sg, sg.length);
65992 +
65993 + crypto_hash_final(&desc, temp_sum);
65994 +
65995 + memset(entry->pw, 0, GR_PW_LEN);
65996 +
65997 + for (i = 0; i < GR_SHA_LEN; i++)
65998 + if (sum[i] != temp_sum[i])
65999 + retval = 1;
66000 + else
66001 + dummy = 1; // waste a cycle
66002 +
66003 + crypto_free_hash(tfm);
66004 +
66005 + return retval;
66006 +}
66007 diff --git a/include/asm-generic/4level-fixup.h b/include/asm-generic/4level-fixup.h
66008 index 77ff547..181834f 100644
66009 --- a/include/asm-generic/4level-fixup.h
66010 +++ b/include/asm-generic/4level-fixup.h
66011 @@ -13,8 +13,10 @@
66012 #define pmd_alloc(mm, pud, address) \
66013 ((unlikely(pgd_none(*(pud))) && __pmd_alloc(mm, pud, address))? \
66014 NULL: pmd_offset(pud, address))
66015 +#define pmd_alloc_kernel(mm, pud, address) pmd_alloc((mm), (pud), (address))
66016
66017 #define pud_alloc(mm, pgd, address) (pgd)
66018 +#define pud_alloc_kernel(mm, pgd, address) pud_alloc((mm), (pgd), (address))
66019 #define pud_offset(pgd, start) (pgd)
66020 #define pud_none(pud) 0
66021 #define pud_bad(pud) 0
66022 diff --git a/include/asm-generic/atomic-long.h b/include/asm-generic/atomic-long.h
66023 index b7babf0..04ad282 100644
66024 --- a/include/asm-generic/atomic-long.h
66025 +++ b/include/asm-generic/atomic-long.h
66026 @@ -22,6 +22,12 @@
66027
66028 typedef atomic64_t atomic_long_t;
66029
66030 +#ifdef CONFIG_PAX_REFCOUNT
66031 +typedef atomic64_unchecked_t atomic_long_unchecked_t;
66032 +#else
66033 +typedef atomic64_t atomic_long_unchecked_t;
66034 +#endif
66035 +
66036 #define ATOMIC_LONG_INIT(i) ATOMIC64_INIT(i)
66037
66038 static inline long atomic_long_read(atomic_long_t *l)
66039 @@ -31,6 +37,15 @@ static inline long atomic_long_read(atomic_long_t *l)
66040 return (long)atomic64_read(v);
66041 }
66042
66043 +#ifdef CONFIG_PAX_REFCOUNT
66044 +static inline long atomic_long_read_unchecked(atomic_long_unchecked_t *l)
66045 +{
66046 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
66047 +
66048 + return (long)atomic64_read_unchecked(v);
66049 +}
66050 +#endif
66051 +
66052 static inline void atomic_long_set(atomic_long_t *l, long i)
66053 {
66054 atomic64_t *v = (atomic64_t *)l;
66055 @@ -38,6 +53,15 @@ static inline void atomic_long_set(atomic_long_t *l, long i)
66056 atomic64_set(v, i);
66057 }
66058
66059 +#ifdef CONFIG_PAX_REFCOUNT
66060 +static inline void atomic_long_set_unchecked(atomic_long_unchecked_t *l, long i)
66061 +{
66062 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
66063 +
66064 + atomic64_set_unchecked(v, i);
66065 +}
66066 +#endif
66067 +
66068 static inline void atomic_long_inc(atomic_long_t *l)
66069 {
66070 atomic64_t *v = (atomic64_t *)l;
66071 @@ -45,6 +69,15 @@ static inline void atomic_long_inc(atomic_long_t *l)
66072 atomic64_inc(v);
66073 }
66074
66075 +#ifdef CONFIG_PAX_REFCOUNT
66076 +static inline void atomic_long_inc_unchecked(atomic_long_unchecked_t *l)
66077 +{
66078 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
66079 +
66080 + atomic64_inc_unchecked(v);
66081 +}
66082 +#endif
66083 +
66084 static inline void atomic_long_dec(atomic_long_t *l)
66085 {
66086 atomic64_t *v = (atomic64_t *)l;
66087 @@ -52,6 +85,15 @@ static inline void atomic_long_dec(atomic_long_t *l)
66088 atomic64_dec(v);
66089 }
66090
66091 +#ifdef CONFIG_PAX_REFCOUNT
66092 +static inline void atomic_long_dec_unchecked(atomic_long_unchecked_t *l)
66093 +{
66094 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
66095 +
66096 + atomic64_dec_unchecked(v);
66097 +}
66098 +#endif
66099 +
66100 static inline void atomic_long_add(long i, atomic_long_t *l)
66101 {
66102 atomic64_t *v = (atomic64_t *)l;
66103 @@ -59,6 +101,15 @@ static inline void atomic_long_add(long i, atomic_long_t *l)
66104 atomic64_add(i, v);
66105 }
66106
66107 +#ifdef CONFIG_PAX_REFCOUNT
66108 +static inline void atomic_long_add_unchecked(long i, atomic_long_unchecked_t *l)
66109 +{
66110 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
66111 +
66112 + atomic64_add_unchecked(i, v);
66113 +}
66114 +#endif
66115 +
66116 static inline void atomic_long_sub(long i, atomic_long_t *l)
66117 {
66118 atomic64_t *v = (atomic64_t *)l;
66119 @@ -66,6 +117,15 @@ static inline void atomic_long_sub(long i, atomic_long_t *l)
66120 atomic64_sub(i, v);
66121 }
66122
66123 +#ifdef CONFIG_PAX_REFCOUNT
66124 +static inline void atomic_long_sub_unchecked(long i, atomic_long_unchecked_t *l)
66125 +{
66126 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
66127 +
66128 + atomic64_sub_unchecked(i, v);
66129 +}
66130 +#endif
66131 +
66132 static inline int atomic_long_sub_and_test(long i, atomic_long_t *l)
66133 {
66134 atomic64_t *v = (atomic64_t *)l;
66135 @@ -101,6 +161,15 @@ static inline long atomic_long_add_return(long i, atomic_long_t *l)
66136 return (long)atomic64_add_return(i, v);
66137 }
66138
66139 +#ifdef CONFIG_PAX_REFCOUNT
66140 +static inline long atomic_long_add_return_unchecked(long i, atomic_long_unchecked_t *l)
66141 +{
66142 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
66143 +
66144 + return (long)atomic64_add_return_unchecked(i, v);
66145 +}
66146 +#endif
66147 +
66148 static inline long atomic_long_sub_return(long i, atomic_long_t *l)
66149 {
66150 atomic64_t *v = (atomic64_t *)l;
66151 @@ -115,6 +184,15 @@ static inline long atomic_long_inc_return(atomic_long_t *l)
66152 return (long)atomic64_inc_return(v);
66153 }
66154
66155 +#ifdef CONFIG_PAX_REFCOUNT
66156 +static inline long atomic_long_inc_return_unchecked(atomic_long_unchecked_t *l)
66157 +{
66158 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
66159 +
66160 + return (long)atomic64_inc_return_unchecked(v);
66161 +}
66162 +#endif
66163 +
66164 static inline long atomic_long_dec_return(atomic_long_t *l)
66165 {
66166 atomic64_t *v = (atomic64_t *)l;
66167 @@ -140,6 +218,12 @@ static inline long atomic_long_add_unless(atomic_long_t *l, long a, long u)
66168
66169 typedef atomic_t atomic_long_t;
66170
66171 +#ifdef CONFIG_PAX_REFCOUNT
66172 +typedef atomic_unchecked_t atomic_long_unchecked_t;
66173 +#else
66174 +typedef atomic_t atomic_long_unchecked_t;
66175 +#endif
66176 +
66177 #define ATOMIC_LONG_INIT(i) ATOMIC_INIT(i)
66178 static inline long atomic_long_read(atomic_long_t *l)
66179 {
66180 @@ -148,6 +232,15 @@ static inline long atomic_long_read(atomic_long_t *l)
66181 return (long)atomic_read(v);
66182 }
66183
66184 +#ifdef CONFIG_PAX_REFCOUNT
66185 +static inline long atomic_long_read_unchecked(atomic_long_unchecked_t *l)
66186 +{
66187 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
66188 +
66189 + return (long)atomic_read_unchecked(v);
66190 +}
66191 +#endif
66192 +
66193 static inline void atomic_long_set(atomic_long_t *l, long i)
66194 {
66195 atomic_t *v = (atomic_t *)l;
66196 @@ -155,6 +248,15 @@ static inline void atomic_long_set(atomic_long_t *l, long i)
66197 atomic_set(v, i);
66198 }
66199
66200 +#ifdef CONFIG_PAX_REFCOUNT
66201 +static inline void atomic_long_set_unchecked(atomic_long_unchecked_t *l, long i)
66202 +{
66203 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
66204 +
66205 + atomic_set_unchecked(v, i);
66206 +}
66207 +#endif
66208 +
66209 static inline void atomic_long_inc(atomic_long_t *l)
66210 {
66211 atomic_t *v = (atomic_t *)l;
66212 @@ -162,6 +264,15 @@ static inline void atomic_long_inc(atomic_long_t *l)
66213 atomic_inc(v);
66214 }
66215
66216 +#ifdef CONFIG_PAX_REFCOUNT
66217 +static inline void atomic_long_inc_unchecked(atomic_long_unchecked_t *l)
66218 +{
66219 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
66220 +
66221 + atomic_inc_unchecked(v);
66222 +}
66223 +#endif
66224 +
66225 static inline void atomic_long_dec(atomic_long_t *l)
66226 {
66227 atomic_t *v = (atomic_t *)l;
66228 @@ -169,6 +280,15 @@ static inline void atomic_long_dec(atomic_long_t *l)
66229 atomic_dec(v);
66230 }
66231
66232 +#ifdef CONFIG_PAX_REFCOUNT
66233 +static inline void atomic_long_dec_unchecked(atomic_long_unchecked_t *l)
66234 +{
66235 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
66236 +
66237 + atomic_dec_unchecked(v);
66238 +}
66239 +#endif
66240 +
66241 static inline void atomic_long_add(long i, atomic_long_t *l)
66242 {
66243 atomic_t *v = (atomic_t *)l;
66244 @@ -176,6 +296,15 @@ static inline void atomic_long_add(long i, atomic_long_t *l)
66245 atomic_add(i, v);
66246 }
66247
66248 +#ifdef CONFIG_PAX_REFCOUNT
66249 +static inline void atomic_long_add_unchecked(long i, atomic_long_unchecked_t *l)
66250 +{
66251 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
66252 +
66253 + atomic_add_unchecked(i, v);
66254 +}
66255 +#endif
66256 +
66257 static inline void atomic_long_sub(long i, atomic_long_t *l)
66258 {
66259 atomic_t *v = (atomic_t *)l;
66260 @@ -183,6 +312,15 @@ static inline void atomic_long_sub(long i, atomic_long_t *l)
66261 atomic_sub(i, v);
66262 }
66263
66264 +#ifdef CONFIG_PAX_REFCOUNT
66265 +static inline void atomic_long_sub_unchecked(long i, atomic_long_unchecked_t *l)
66266 +{
66267 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
66268 +
66269 + atomic_sub_unchecked(i, v);
66270 +}
66271 +#endif
66272 +
66273 static inline int atomic_long_sub_and_test(long i, atomic_long_t *l)
66274 {
66275 atomic_t *v = (atomic_t *)l;
66276 @@ -218,6 +356,16 @@ static inline long atomic_long_add_return(long i, atomic_long_t *l)
66277 return (long)atomic_add_return(i, v);
66278 }
66279
66280 +#ifdef CONFIG_PAX_REFCOUNT
66281 +static inline long atomic_long_add_return_unchecked(long i, atomic_long_unchecked_t *l)
66282 +{
66283 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
66284 +
66285 + return (long)atomic_add_return_unchecked(i, v);
66286 +}
66287 +
66288 +#endif
66289 +
66290 static inline long atomic_long_sub_return(long i, atomic_long_t *l)
66291 {
66292 atomic_t *v = (atomic_t *)l;
66293 @@ -232,6 +380,15 @@ static inline long atomic_long_inc_return(atomic_long_t *l)
66294 return (long)atomic_inc_return(v);
66295 }
66296
66297 +#ifdef CONFIG_PAX_REFCOUNT
66298 +static inline long atomic_long_inc_return_unchecked(atomic_long_unchecked_t *l)
66299 +{
66300 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
66301 +
66302 + return (long)atomic_inc_return_unchecked(v);
66303 +}
66304 +#endif
66305 +
66306 static inline long atomic_long_dec_return(atomic_long_t *l)
66307 {
66308 atomic_t *v = (atomic_t *)l;
66309 @@ -255,4 +412,57 @@ static inline long atomic_long_add_unless(atomic_long_t *l, long a, long u)
66310
66311 #endif /* BITS_PER_LONG == 64 */
66312
66313 +#ifdef CONFIG_PAX_REFCOUNT
66314 +static inline void pax_refcount_needs_these_functions(void)
66315 +{
66316 + atomic_read_unchecked((atomic_unchecked_t *)NULL);
66317 + atomic_set_unchecked((atomic_unchecked_t *)NULL, 0);
66318 + atomic_add_unchecked(0, (atomic_unchecked_t *)NULL);
66319 + atomic_sub_unchecked(0, (atomic_unchecked_t *)NULL);
66320 + atomic_inc_unchecked((atomic_unchecked_t *)NULL);
66321 + (void)atomic_inc_and_test_unchecked((atomic_unchecked_t *)NULL);
66322 + atomic_inc_return_unchecked((atomic_unchecked_t *)NULL);
66323 + atomic_add_return_unchecked(0, (atomic_unchecked_t *)NULL);
66324 + atomic_dec_unchecked((atomic_unchecked_t *)NULL);
66325 + atomic_cmpxchg_unchecked((atomic_unchecked_t *)NULL, 0, 0);
66326 + (void)atomic_xchg_unchecked((atomic_unchecked_t *)NULL, 0);
66327 +#ifdef CONFIG_X86
66328 + atomic_clear_mask_unchecked(0, NULL);
66329 + atomic_set_mask_unchecked(0, NULL);
66330 +#endif
66331 +
66332 + atomic_long_read_unchecked((atomic_long_unchecked_t *)NULL);
66333 + atomic_long_set_unchecked((atomic_long_unchecked_t *)NULL, 0);
66334 + atomic_long_add_unchecked(0, (atomic_long_unchecked_t *)NULL);
66335 + atomic_long_sub_unchecked(0, (atomic_long_unchecked_t *)NULL);
66336 + atomic_long_inc_unchecked((atomic_long_unchecked_t *)NULL);
66337 + atomic_long_add_return_unchecked(0, (atomic_long_unchecked_t *)NULL);
66338 + atomic_long_inc_return_unchecked((atomic_long_unchecked_t *)NULL);
66339 + atomic_long_dec_unchecked((atomic_long_unchecked_t *)NULL);
66340 +}
66341 +#else
66342 +#define atomic_read_unchecked(v) atomic_read(v)
66343 +#define atomic_set_unchecked(v, i) atomic_set((v), (i))
66344 +#define atomic_add_unchecked(i, v) atomic_add((i), (v))
66345 +#define atomic_sub_unchecked(i, v) atomic_sub((i), (v))
66346 +#define atomic_inc_unchecked(v) atomic_inc(v)
66347 +#define atomic_inc_and_test_unchecked(v) atomic_inc_and_test(v)
66348 +#define atomic_inc_return_unchecked(v) atomic_inc_return(v)
66349 +#define atomic_add_return_unchecked(i, v) atomic_add_return((i), (v))
66350 +#define atomic_dec_unchecked(v) atomic_dec(v)
66351 +#define atomic_cmpxchg_unchecked(v, o, n) atomic_cmpxchg((v), (o), (n))
66352 +#define atomic_xchg_unchecked(v, i) atomic_xchg((v), (i))
66353 +#define atomic_clear_mask_unchecked(mask, v) atomic_clear_mask((mask), (v))
66354 +#define atomic_set_mask_unchecked(mask, v) atomic_set_mask((mask), (v))
66355 +
66356 +#define atomic_long_read_unchecked(v) atomic_long_read(v)
66357 +#define atomic_long_set_unchecked(v, i) atomic_long_set((v), (i))
66358 +#define atomic_long_add_unchecked(i, v) atomic_long_add((i), (v))
66359 +#define atomic_long_sub_unchecked(i, v) atomic_long_sub((i), (v))
66360 +#define atomic_long_inc_unchecked(v) atomic_long_inc(v)
66361 +#define atomic_long_add_return_unchecked(i, v) atomic_long_add_return((i), (v))
66362 +#define atomic_long_inc_return_unchecked(v) atomic_long_inc_return(v)
66363 +#define atomic_long_dec_unchecked(v) atomic_long_dec(v)
66364 +#endif
66365 +
66366 #endif /* _ASM_GENERIC_ATOMIC_LONG_H */
66367 diff --git a/include/asm-generic/atomic.h b/include/asm-generic/atomic.h
66368 index 1ced641..c896ee8 100644
66369 --- a/include/asm-generic/atomic.h
66370 +++ b/include/asm-generic/atomic.h
66371 @@ -159,7 +159,7 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
66372 * Atomically clears the bits set in @mask from @v
66373 */
66374 #ifndef atomic_clear_mask
66375 -static inline void atomic_clear_mask(unsigned long mask, atomic_t *v)
66376 +static inline void atomic_clear_mask(unsigned int mask, atomic_t *v)
66377 {
66378 unsigned long flags;
66379
66380 diff --git a/include/asm-generic/atomic64.h b/include/asm-generic/atomic64.h
66381 index b18ce4f..2ee2843 100644
66382 --- a/include/asm-generic/atomic64.h
66383 +++ b/include/asm-generic/atomic64.h
66384 @@ -16,6 +16,8 @@ typedef struct {
66385 long long counter;
66386 } atomic64_t;
66387
66388 +typedef atomic64_t atomic64_unchecked_t;
66389 +
66390 #define ATOMIC64_INIT(i) { (i) }
66391
66392 extern long long atomic64_read(const atomic64_t *v);
66393 @@ -39,4 +41,14 @@ extern int atomic64_add_unless(atomic64_t *v, long long a, long long u);
66394 #define atomic64_dec_and_test(v) (atomic64_dec_return((v)) == 0)
66395 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1LL, 0LL)
66396
66397 +#define atomic64_read_unchecked(v) atomic64_read(v)
66398 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
66399 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
66400 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
66401 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
66402 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
66403 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
66404 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
66405 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
66406 +
66407 #endif /* _ASM_GENERIC_ATOMIC64_H */
66408 diff --git a/include/asm-generic/cache.h b/include/asm-generic/cache.h
66409 index 1bfcfe5..e04c5c9 100644
66410 --- a/include/asm-generic/cache.h
66411 +++ b/include/asm-generic/cache.h
66412 @@ -6,7 +6,7 @@
66413 * cache lines need to provide their own cache.h.
66414 */
66415
66416 -#define L1_CACHE_SHIFT 5
66417 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
66418 +#define L1_CACHE_SHIFT 5UL
66419 +#define L1_CACHE_BYTES (1UL << L1_CACHE_SHIFT)
66420
66421 #endif /* __ASM_GENERIC_CACHE_H */
66422 diff --git a/include/asm-generic/emergency-restart.h b/include/asm-generic/emergency-restart.h
66423 index 0d68a1e..b74a761 100644
66424 --- a/include/asm-generic/emergency-restart.h
66425 +++ b/include/asm-generic/emergency-restart.h
66426 @@ -1,7 +1,7 @@
66427 #ifndef _ASM_GENERIC_EMERGENCY_RESTART_H
66428 #define _ASM_GENERIC_EMERGENCY_RESTART_H
66429
66430 -static inline void machine_emergency_restart(void)
66431 +static inline __noreturn void machine_emergency_restart(void)
66432 {
66433 machine_restart(NULL);
66434 }
66435 diff --git a/include/asm-generic/kmap_types.h b/include/asm-generic/kmap_types.h
66436 index 90f99c7..00ce236 100644
66437 --- a/include/asm-generic/kmap_types.h
66438 +++ b/include/asm-generic/kmap_types.h
66439 @@ -2,9 +2,9 @@
66440 #define _ASM_GENERIC_KMAP_TYPES_H
66441
66442 #ifdef __WITH_KM_FENCE
66443 -# define KM_TYPE_NR 41
66444 +# define KM_TYPE_NR 42
66445 #else
66446 -# define KM_TYPE_NR 20
66447 +# define KM_TYPE_NR 21
66448 #endif
66449
66450 #endif
66451 diff --git a/include/asm-generic/local.h b/include/asm-generic/local.h
66452 index 9ceb03b..62b0b8f 100644
66453 --- a/include/asm-generic/local.h
66454 +++ b/include/asm-generic/local.h
66455 @@ -23,24 +23,37 @@ typedef struct
66456 atomic_long_t a;
66457 } local_t;
66458
66459 +typedef struct {
66460 + atomic_long_unchecked_t a;
66461 +} local_unchecked_t;
66462 +
66463 #define LOCAL_INIT(i) { ATOMIC_LONG_INIT(i) }
66464
66465 #define local_read(l) atomic_long_read(&(l)->a)
66466 +#define local_read_unchecked(l) atomic_long_read_unchecked(&(l)->a)
66467 #define local_set(l,i) atomic_long_set((&(l)->a),(i))
66468 +#define local_set_unchecked(l,i) atomic_long_set_unchecked((&(l)->a),(i))
66469 #define local_inc(l) atomic_long_inc(&(l)->a)
66470 +#define local_inc_unchecked(l) atomic_long_inc_unchecked(&(l)->a)
66471 #define local_dec(l) atomic_long_dec(&(l)->a)
66472 +#define local_dec_unchecked(l) atomic_long_dec_unchecked(&(l)->a)
66473 #define local_add(i,l) atomic_long_add((i),(&(l)->a))
66474 +#define local_add_unchecked(i,l) atomic_long_add_unchecked((i),(&(l)->a))
66475 #define local_sub(i,l) atomic_long_sub((i),(&(l)->a))
66476 +#define local_sub_unchecked(i,l) atomic_long_sub_unchecked((i),(&(l)->a))
66477
66478 #define local_sub_and_test(i, l) atomic_long_sub_and_test((i), (&(l)->a))
66479 #define local_dec_and_test(l) atomic_long_dec_and_test(&(l)->a)
66480 #define local_inc_and_test(l) atomic_long_inc_and_test(&(l)->a)
66481 #define local_add_negative(i, l) atomic_long_add_negative((i), (&(l)->a))
66482 #define local_add_return(i, l) atomic_long_add_return((i), (&(l)->a))
66483 +#define local_add_return_unchecked(i, l) atomic_long_add_return_unchecked((i), (&(l)->a))
66484 #define local_sub_return(i, l) atomic_long_sub_return((i), (&(l)->a))
66485 #define local_inc_return(l) atomic_long_inc_return(&(l)->a)
66486 +#define local_dec_return(l) atomic_long_dec_return(&(l)->a)
66487
66488 #define local_cmpxchg(l, o, n) atomic_long_cmpxchg((&(l)->a), (o), (n))
66489 +#define local_cmpxchg_unchecked(l, o, n) atomic_long_cmpxchg((&(l)->a), (o), (n))
66490 #define local_xchg(l, n) atomic_long_xchg((&(l)->a), (n))
66491 #define local_add_unless(l, _a, u) atomic_long_add_unless((&(l)->a), (_a), (u))
66492 #define local_inc_not_zero(l) atomic_long_inc_not_zero(&(l)->a)
66493 diff --git a/include/asm-generic/pgtable-nopmd.h b/include/asm-generic/pgtable-nopmd.h
66494 index 725612b..9cc513a 100644
66495 --- a/include/asm-generic/pgtable-nopmd.h
66496 +++ b/include/asm-generic/pgtable-nopmd.h
66497 @@ -1,14 +1,19 @@
66498 #ifndef _PGTABLE_NOPMD_H
66499 #define _PGTABLE_NOPMD_H
66500
66501 -#ifndef __ASSEMBLY__
66502 -
66503 #include <asm-generic/pgtable-nopud.h>
66504
66505 -struct mm_struct;
66506 -
66507 #define __PAGETABLE_PMD_FOLDED
66508
66509 +#define PMD_SHIFT PUD_SHIFT
66510 +#define PTRS_PER_PMD 1
66511 +#define PMD_SIZE (_AC(1,UL) << PMD_SHIFT)
66512 +#define PMD_MASK (~(PMD_SIZE-1))
66513 +
66514 +#ifndef __ASSEMBLY__
66515 +
66516 +struct mm_struct;
66517 +
66518 /*
66519 * Having the pmd type consist of a pud gets the size right, and allows
66520 * us to conceptually access the pud entry that this pmd is folded into
66521 @@ -16,11 +21,6 @@ struct mm_struct;
66522 */
66523 typedef struct { pud_t pud; } pmd_t;
66524
66525 -#define PMD_SHIFT PUD_SHIFT
66526 -#define PTRS_PER_PMD 1
66527 -#define PMD_SIZE (1UL << PMD_SHIFT)
66528 -#define PMD_MASK (~(PMD_SIZE-1))
66529 -
66530 /*
66531 * The "pud_xxx()" functions here are trivial for a folded two-level
66532 * setup: the pmd is never bad, and a pmd always exists (as it's folded
66533 diff --git a/include/asm-generic/pgtable-nopud.h b/include/asm-generic/pgtable-nopud.h
66534 index 810431d..0ec4804f 100644
66535 --- a/include/asm-generic/pgtable-nopud.h
66536 +++ b/include/asm-generic/pgtable-nopud.h
66537 @@ -1,10 +1,15 @@
66538 #ifndef _PGTABLE_NOPUD_H
66539 #define _PGTABLE_NOPUD_H
66540
66541 -#ifndef __ASSEMBLY__
66542 -
66543 #define __PAGETABLE_PUD_FOLDED
66544
66545 +#define PUD_SHIFT PGDIR_SHIFT
66546 +#define PTRS_PER_PUD 1
66547 +#define PUD_SIZE (_AC(1,UL) << PUD_SHIFT)
66548 +#define PUD_MASK (~(PUD_SIZE-1))
66549 +
66550 +#ifndef __ASSEMBLY__
66551 +
66552 /*
66553 * Having the pud type consist of a pgd gets the size right, and allows
66554 * us to conceptually access the pgd entry that this pud is folded into
66555 @@ -12,11 +17,6 @@
66556 */
66557 typedef struct { pgd_t pgd; } pud_t;
66558
66559 -#define PUD_SHIFT PGDIR_SHIFT
66560 -#define PTRS_PER_PUD 1
66561 -#define PUD_SIZE (1UL << PUD_SHIFT)
66562 -#define PUD_MASK (~(PUD_SIZE-1))
66563 -
66564 /*
66565 * The "pgd_xxx()" functions here are trivial for a folded two-level
66566 * setup: the pud is never bad, and a pud always exists (as it's folded
66567 @@ -29,6 +29,7 @@ static inline void pgd_clear(pgd_t *pgd) { }
66568 #define pud_ERROR(pud) (pgd_ERROR((pud).pgd))
66569
66570 #define pgd_populate(mm, pgd, pud) do { } while (0)
66571 +#define pgd_populate_kernel(mm, pgd, pud) do { } while (0)
66572 /*
66573 * (puds are folded into pgds so this doesn't get actually called,
66574 * but the define is needed for a generic inline function.)
66575 diff --git a/include/asm-generic/pgtable.h b/include/asm-generic/pgtable.h
66576 index 5cf680a..4b74d62 100644
66577 --- a/include/asm-generic/pgtable.h
66578 +++ b/include/asm-generic/pgtable.h
66579 @@ -688,6 +688,14 @@ static inline pmd_t pmd_mknuma(pmd_t pmd)
66580 }
66581 #endif /* CONFIG_NUMA_BALANCING */
66582
66583 +#ifndef __HAVE_ARCH_PAX_OPEN_KERNEL
66584 +static inline unsigned long pax_open_kernel(void) { return 0; }
66585 +#endif
66586 +
66587 +#ifndef __HAVE_ARCH_PAX_CLOSE_KERNEL
66588 +static inline unsigned long pax_close_kernel(void) { return 0; }
66589 +#endif
66590 +
66591 #endif /* CONFIG_MMU */
66592
66593 #endif /* !__ASSEMBLY__ */
66594 diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
66595 index d1ea7ce..b1ebf2a 100644
66596 --- a/include/asm-generic/vmlinux.lds.h
66597 +++ b/include/asm-generic/vmlinux.lds.h
66598 @@ -218,6 +218,7 @@
66599 .rodata : AT(ADDR(.rodata) - LOAD_OFFSET) { \
66600 VMLINUX_SYMBOL(__start_rodata) = .; \
66601 *(.rodata) *(.rodata.*) \
66602 + *(.data..read_only) \
66603 *(__vermagic) /* Kernel version magic */ \
66604 . = ALIGN(8); \
66605 VMLINUX_SYMBOL(__start___tracepoints_ptrs) = .; \
66606 @@ -725,17 +726,18 @@
66607 * section in the linker script will go there too. @phdr should have
66608 * a leading colon.
66609 *
66610 - * Note that this macros defines __per_cpu_load as an absolute symbol.
66611 + * Note that this macros defines per_cpu_load as an absolute symbol.
66612 * If there is no need to put the percpu section at a predetermined
66613 * address, use PERCPU_SECTION.
66614 */
66615 #define PERCPU_VADDR(cacheline, vaddr, phdr) \
66616 - VMLINUX_SYMBOL(__per_cpu_load) = .; \
66617 - .data..percpu vaddr : AT(VMLINUX_SYMBOL(__per_cpu_load) \
66618 + per_cpu_load = .; \
66619 + .data..percpu vaddr : AT(VMLINUX_SYMBOL(per_cpu_load) \
66620 - LOAD_OFFSET) { \
66621 + VMLINUX_SYMBOL(__per_cpu_load) = . + per_cpu_load; \
66622 PERCPU_INPUT(cacheline) \
66623 } phdr \
66624 - . = VMLINUX_SYMBOL(__per_cpu_load) + SIZEOF(.data..percpu);
66625 + . = VMLINUX_SYMBOL(per_cpu_load) + SIZEOF(.data..percpu);
66626
66627 /**
66628 * PERCPU_SECTION - define output section for percpu area, simple version
66629 diff --git a/include/crypto/algapi.h b/include/crypto/algapi.h
66630 index 418d270..bfd2794 100644
66631 --- a/include/crypto/algapi.h
66632 +++ b/include/crypto/algapi.h
66633 @@ -34,7 +34,7 @@ struct crypto_type {
66634 unsigned int maskclear;
66635 unsigned int maskset;
66636 unsigned int tfmsize;
66637 -};
66638 +} __do_const;
66639
66640 struct crypto_instance {
66641 struct crypto_alg alg;
66642 diff --git a/include/drm/drmP.h b/include/drm/drmP.h
66643 index fad21c9..ab858bc 100644
66644 --- a/include/drm/drmP.h
66645 +++ b/include/drm/drmP.h
66646 @@ -72,6 +72,7 @@
66647 #include <linux/workqueue.h>
66648 #include <linux/poll.h>
66649 #include <asm/pgalloc.h>
66650 +#include <asm/local.h>
66651 #include <drm/drm.h>
66652 #include <drm/drm_sarea.h>
66653
66654 @@ -293,10 +294,12 @@ do { \
66655 * \param cmd command.
66656 * \param arg argument.
66657 */
66658 -typedef int drm_ioctl_t(struct drm_device *dev, void *data,
66659 +typedef int (* const drm_ioctl_t)(struct drm_device *dev, void *data,
66660 + struct drm_file *file_priv);
66661 +typedef int (* drm_ioctl_no_const_t)(struct drm_device *dev, void *data,
66662 struct drm_file *file_priv);
66663
66664 -typedef int drm_ioctl_compat_t(struct file *filp, unsigned int cmd,
66665 +typedef int (* const drm_ioctl_compat_t)(struct file *filp, unsigned int cmd,
66666 unsigned long arg);
66667
66668 #define DRM_IOCTL_NR(n) _IOC_NR(n)
66669 @@ -311,9 +314,9 @@ typedef int drm_ioctl_compat_t(struct file *filp, unsigned int cmd,
66670 struct drm_ioctl_desc {
66671 unsigned int cmd;
66672 int flags;
66673 - drm_ioctl_t *func;
66674 + drm_ioctl_t func;
66675 unsigned int cmd_drv;
66676 -};
66677 +} __do_const;
66678
66679 /**
66680 * Creates a driver or general drm_ioctl_desc array entry for the given
66681 @@ -995,7 +998,7 @@ struct drm_info_list {
66682 int (*show)(struct seq_file*, void*); /** show callback */
66683 u32 driver_features; /**< Required driver features for this entry */
66684 void *data;
66685 -};
66686 +} __do_const;
66687
66688 /**
66689 * debugfs node structure. This structure represents a debugfs file.
66690 @@ -1068,7 +1071,7 @@ struct drm_device {
66691
66692 /** \name Usage Counters */
66693 /*@{ */
66694 - int open_count; /**< Outstanding files open */
66695 + local_t open_count; /**< Outstanding files open */
66696 atomic_t ioctl_count; /**< Outstanding IOCTLs pending */
66697 atomic_t vma_count; /**< Outstanding vma areas open */
66698 int buf_use; /**< Buffers in use -- cannot alloc */
66699 @@ -1079,7 +1082,7 @@ struct drm_device {
66700 /*@{ */
66701 unsigned long counters;
66702 enum drm_stat_type types[15];
66703 - atomic_t counts[15];
66704 + atomic_unchecked_t counts[15];
66705 /*@} */
66706
66707 struct list_head filelist;
66708 diff --git a/include/drm/drm_crtc_helper.h b/include/drm/drm_crtc_helper.h
66709 index f43d556..94d9343 100644
66710 --- a/include/drm/drm_crtc_helper.h
66711 +++ b/include/drm/drm_crtc_helper.h
66712 @@ -109,7 +109,7 @@ struct drm_encoder_helper_funcs {
66713 struct drm_connector *connector);
66714 /* disable encoder when not in use - more explicit than dpms off */
66715 void (*disable)(struct drm_encoder *encoder);
66716 -};
66717 +} __no_const;
66718
66719 /**
66720 * drm_connector_helper_funcs - helper operations for connectors
66721 diff --git a/include/drm/ttm/ttm_memory.h b/include/drm/ttm/ttm_memory.h
66722 index 72dcbe8..8db58d7 100644
66723 --- a/include/drm/ttm/ttm_memory.h
66724 +++ b/include/drm/ttm/ttm_memory.h
66725 @@ -48,7 +48,7 @@
66726
66727 struct ttm_mem_shrink {
66728 int (*do_shrink) (struct ttm_mem_shrink *);
66729 -};
66730 +} __no_const;
66731
66732 /**
66733 * struct ttm_mem_global - Global memory accounting structure.
66734 diff --git a/include/keys/asymmetric-subtype.h b/include/keys/asymmetric-subtype.h
66735 index 4b840e8..155d235 100644
66736 --- a/include/keys/asymmetric-subtype.h
66737 +++ b/include/keys/asymmetric-subtype.h
66738 @@ -37,7 +37,7 @@ struct asymmetric_key_subtype {
66739 /* Verify the signature on a key of this subtype (optional) */
66740 int (*verify_signature)(const struct key *key,
66741 const struct public_key_signature *sig);
66742 -};
66743 +} __do_const;
66744
66745 /**
66746 * asymmetric_key_subtype - Get the subtype from an asymmetric key
66747 diff --git a/include/linux/atmdev.h b/include/linux/atmdev.h
66748 index c1da539..1dcec55 100644
66749 --- a/include/linux/atmdev.h
66750 +++ b/include/linux/atmdev.h
66751 @@ -28,7 +28,7 @@ struct compat_atm_iobuf {
66752 #endif
66753
66754 struct k_atm_aal_stats {
66755 -#define __HANDLE_ITEM(i) atomic_t i
66756 +#define __HANDLE_ITEM(i) atomic_unchecked_t i
66757 __AAL_STAT_ITEMS
66758 #undef __HANDLE_ITEM
66759 };
66760 @@ -200,7 +200,7 @@ struct atmdev_ops { /* only send is required */
66761 int (*change_qos)(struct atm_vcc *vcc,struct atm_qos *qos,int flags);
66762 int (*proc_read)(struct atm_dev *dev,loff_t *pos,char *page);
66763 struct module *owner;
66764 -};
66765 +} __do_const ;
66766
66767 struct atmphy_ops {
66768 int (*start)(struct atm_dev *dev);
66769 diff --git a/include/linux/binfmts.h b/include/linux/binfmts.h
66770 index 0530b98..96a8ac0 100644
66771 --- a/include/linux/binfmts.h
66772 +++ b/include/linux/binfmts.h
66773 @@ -73,8 +73,9 @@ struct linux_binfmt {
66774 int (*load_binary)(struct linux_binprm *);
66775 int (*load_shlib)(struct file *);
66776 int (*core_dump)(struct coredump_params *cprm);
66777 + void (*handle_mprotect)(struct vm_area_struct *vma, unsigned long newflags);
66778 unsigned long min_coredump; /* minimal dump size */
66779 -};
66780 +} __do_const;
66781
66782 extern void __register_binfmt(struct linux_binfmt *fmt, int insert);
66783
66784 diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
66785 index f94bc83..62b9cfe 100644
66786 --- a/include/linux/blkdev.h
66787 +++ b/include/linux/blkdev.h
66788 @@ -1498,7 +1498,7 @@ struct block_device_operations {
66789 /* this callback is with swap_lock and sometimes page table lock held */
66790 void (*swap_slot_free_notify) (struct block_device *, unsigned long);
66791 struct module *owner;
66792 -};
66793 +} __do_const;
66794
66795 extern int __blkdev_driver_ioctl(struct block_device *, fmode_t, unsigned int,
66796 unsigned long);
66797 diff --git a/include/linux/blktrace_api.h b/include/linux/blktrace_api.h
66798 index 7c2e030..b72475d 100644
66799 --- a/include/linux/blktrace_api.h
66800 +++ b/include/linux/blktrace_api.h
66801 @@ -23,7 +23,7 @@ struct blk_trace {
66802 struct dentry *dir;
66803 struct dentry *dropped_file;
66804 struct dentry *msg_file;
66805 - atomic_t dropped;
66806 + atomic_unchecked_t dropped;
66807 };
66808
66809 extern int blk_trace_ioctl(struct block_device *, unsigned, char __user *);
66810 diff --git a/include/linux/cache.h b/include/linux/cache.h
66811 index 4c57065..4307975 100644
66812 --- a/include/linux/cache.h
66813 +++ b/include/linux/cache.h
66814 @@ -16,6 +16,10 @@
66815 #define __read_mostly
66816 #endif
66817
66818 +#ifndef __read_only
66819 +#define __read_only __read_mostly
66820 +#endif
66821 +
66822 #ifndef ____cacheline_aligned
66823 #define ____cacheline_aligned __attribute__((__aligned__(SMP_CACHE_BYTES)))
66824 #endif
66825 diff --git a/include/linux/capability.h b/include/linux/capability.h
66826 index 98503b7..cc36d18 100644
66827 --- a/include/linux/capability.h
66828 +++ b/include/linux/capability.h
66829 @@ -211,8 +211,13 @@ extern bool capable(int cap);
66830 extern bool ns_capable(struct user_namespace *ns, int cap);
66831 extern bool nsown_capable(int cap);
66832 extern bool inode_capable(const struct inode *inode, int cap);
66833 +extern bool capable_nolog(int cap);
66834 +extern bool ns_capable_nolog(struct user_namespace *ns, int cap);
66835 +extern bool inode_capable_nolog(const struct inode *inode, int cap);
66836
66837 /* audit system wants to get cap info from files as well */
66838 extern int get_vfs_caps_from_disk(const struct dentry *dentry, struct cpu_vfs_cap_data *cpu_caps);
66839
66840 +extern int is_privileged_binary(const struct dentry *dentry);
66841 +
66842 #endif /* !_LINUX_CAPABILITY_H */
66843 diff --git a/include/linux/cdrom.h b/include/linux/cdrom.h
66844 index 8609d57..86e4d79 100644
66845 --- a/include/linux/cdrom.h
66846 +++ b/include/linux/cdrom.h
66847 @@ -87,7 +87,6 @@ struct cdrom_device_ops {
66848
66849 /* driver specifications */
66850 const int capability; /* capability flags */
66851 - int n_minors; /* number of active minor devices */
66852 /* handle uniform packets for scsi type devices (scsi,atapi) */
66853 int (*generic_packet) (struct cdrom_device_info *,
66854 struct packet_command *);
66855 diff --git a/include/linux/cleancache.h b/include/linux/cleancache.h
66856 index 42e55de..1cd0e66 100644
66857 --- a/include/linux/cleancache.h
66858 +++ b/include/linux/cleancache.h
66859 @@ -31,7 +31,7 @@ struct cleancache_ops {
66860 void (*invalidate_page)(int, struct cleancache_filekey, pgoff_t);
66861 void (*invalidate_inode)(int, struct cleancache_filekey);
66862 void (*invalidate_fs)(int);
66863 -};
66864 +} __no_const;
66865
66866 extern struct cleancache_ops
66867 cleancache_register_ops(struct cleancache_ops *ops);
66868 diff --git a/include/linux/compat.h b/include/linux/compat.h
66869 index dec7e2d..e1d5880 100644
66870 --- a/include/linux/compat.h
66871 +++ b/include/linux/compat.h
66872 @@ -311,14 +311,14 @@ long compat_sys_msgsnd(int first, int second, int third, void __user *uptr);
66873 long compat_sys_msgrcv(int first, int second, int msgtyp, int third,
66874 int version, void __user *uptr);
66875 long compat_sys_shmat(int first, int second, compat_uptr_t third, int version,
66876 - void __user *uptr);
66877 + void __user *uptr) __intentional_overflow(0);
66878 #else
66879 long compat_sys_semctl(int semid, int semnum, int cmd, int arg);
66880 long compat_sys_msgsnd(int msqid, struct compat_msgbuf __user *msgp,
66881 compat_ssize_t msgsz, int msgflg);
66882 long compat_sys_msgrcv(int msqid, struct compat_msgbuf __user *msgp,
66883 compat_ssize_t msgsz, long msgtyp, int msgflg);
66884 -long compat_sys_shmat(int shmid, compat_uptr_t shmaddr, int shmflg);
66885 +long compat_sys_shmat(int shmid, compat_uptr_t shmaddr, int shmflg) __intentional_overflow(0);
66886 #endif
66887 long compat_sys_msgctl(int first, int second, void __user *uptr);
66888 long compat_sys_shmctl(int first, int second, void __user *uptr);
66889 diff --git a/include/linux/compiler-gcc4.h b/include/linux/compiler-gcc4.h
66890 index 662fd1b..e801992 100644
66891 --- a/include/linux/compiler-gcc4.h
66892 +++ b/include/linux/compiler-gcc4.h
66893 @@ -34,6 +34,21 @@
66894 #define __UNIQUE_ID(prefix) __PASTE(__PASTE(__UNIQUE_ID_, prefix), __COUNTER__)
66895
66896 #if __GNUC_MINOR__ >= 5
66897 +
66898 +#ifdef CONSTIFY_PLUGIN
66899 +#define __no_const __attribute__((no_const))
66900 +#define __do_const __attribute__((do_const))
66901 +#endif
66902 +
66903 +#ifdef SIZE_OVERFLOW_PLUGIN
66904 +#define __size_overflow(...) __attribute__((size_overflow(__VA_ARGS__)))
66905 +#define __intentional_overflow(...) __attribute__((intentional_overflow(__VA_ARGS__)))
66906 +#endif
66907 +
66908 +#ifdef LATENT_ENTROPY_PLUGIN
66909 +#define __latent_entropy __attribute__((latent_entropy))
66910 +#endif
66911 +
66912 /*
66913 * Mark a position in code as unreachable. This can be used to
66914 * suppress control flow warnings after asm blocks that transfer
66915 @@ -49,6 +64,11 @@
66916 #define __noclone __attribute__((__noclone__))
66917
66918 #endif
66919 +
66920 +#define __alloc_size(...) __attribute((alloc_size(__VA_ARGS__)))
66921 +#define __bos(ptr, arg) __builtin_object_size((ptr), (arg))
66922 +#define __bos0(ptr) __bos((ptr), 0)
66923 +#define __bos1(ptr) __bos((ptr), 1)
66924 #endif
66925
66926 #if __GNUC_MINOR__ >= 6
66927 diff --git a/include/linux/compiler.h b/include/linux/compiler.h
66928 index dd852b7..72924c0 100644
66929 --- a/include/linux/compiler.h
66930 +++ b/include/linux/compiler.h
66931 @@ -5,11 +5,14 @@
66932
66933 #ifdef __CHECKER__
66934 # define __user __attribute__((noderef, address_space(1)))
66935 +# define __force_user __force __user
66936 # define __kernel __attribute__((address_space(0)))
66937 +# define __force_kernel __force __kernel
66938 # define __safe __attribute__((safe))
66939 # define __force __attribute__((force))
66940 # define __nocast __attribute__((nocast))
66941 # define __iomem __attribute__((noderef, address_space(2)))
66942 +# define __force_iomem __force __iomem
66943 # define __must_hold(x) __attribute__((context(x,1,1)))
66944 # define __acquires(x) __attribute__((context(x,0,1)))
66945 # define __releases(x) __attribute__((context(x,1,0)))
66946 @@ -17,20 +20,48 @@
66947 # define __release(x) __context__(x,-1)
66948 # define __cond_lock(x,c) ((c) ? ({ __acquire(x); 1; }) : 0)
66949 # define __percpu __attribute__((noderef, address_space(3)))
66950 +# define __force_percpu __force __percpu
66951 #ifdef CONFIG_SPARSE_RCU_POINTER
66952 # define __rcu __attribute__((noderef, address_space(4)))
66953 +# define __force_rcu __force __rcu
66954 #else
66955 # define __rcu
66956 +# define __force_rcu
66957 #endif
66958 extern void __chk_user_ptr(const volatile void __user *);
66959 extern void __chk_io_ptr(const volatile void __iomem *);
66960 +#elif defined(CHECKER_PLUGIN)
66961 +//# define __user
66962 +//# define __force_user
66963 +//# define __kernel
66964 +//# define __force_kernel
66965 +# define __safe
66966 +# define __force
66967 +# define __nocast
66968 +# define __iomem
66969 +# define __force_iomem
66970 +# define __chk_user_ptr(x) (void)0
66971 +# define __chk_io_ptr(x) (void)0
66972 +# define __builtin_warning(x, y...) (1)
66973 +# define __acquires(x)
66974 +# define __releases(x)
66975 +# define __acquire(x) (void)0
66976 +# define __release(x) (void)0
66977 +# define __cond_lock(x,c) (c)
66978 +# define __percpu
66979 +# define __force_percpu
66980 +# define __rcu
66981 +# define __force_rcu
66982 #else
66983 # define __user
66984 +# define __force_user
66985 # define __kernel
66986 +# define __force_kernel
66987 # define __safe
66988 # define __force
66989 # define __nocast
66990 # define __iomem
66991 +# define __force_iomem
66992 # define __chk_user_ptr(x) (void)0
66993 # define __chk_io_ptr(x) (void)0
66994 # define __builtin_warning(x, y...) (1)
66995 @@ -41,7 +72,9 @@ extern void __chk_io_ptr(const volatile void __iomem *);
66996 # define __release(x) (void)0
66997 # define __cond_lock(x,c) (c)
66998 # define __percpu
66999 +# define __force_percpu
67000 # define __rcu
67001 +# define __force_rcu
67002 #endif
67003
67004 /* Indirect macros required for expanded argument pasting, eg. __LINE__. */
67005 @@ -275,6 +308,26 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
67006 # define __attribute_const__ /* unimplemented */
67007 #endif
67008
67009 +#ifndef __no_const
67010 +# define __no_const
67011 +#endif
67012 +
67013 +#ifndef __do_const
67014 +# define __do_const
67015 +#endif
67016 +
67017 +#ifndef __size_overflow
67018 +# define __size_overflow(...)
67019 +#endif
67020 +
67021 +#ifndef __intentional_overflow
67022 +# define __intentional_overflow(...)
67023 +#endif
67024 +
67025 +#ifndef __latent_entropy
67026 +# define __latent_entropy
67027 +#endif
67028 +
67029 /*
67030 * Tell gcc if a function is cold. The compiler will assume any path
67031 * directly leading to the call is unlikely.
67032 @@ -284,6 +337,22 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
67033 #define __cold
67034 #endif
67035
67036 +#ifndef __alloc_size
67037 +#define __alloc_size(...)
67038 +#endif
67039 +
67040 +#ifndef __bos
67041 +#define __bos(ptr, arg)
67042 +#endif
67043 +
67044 +#ifndef __bos0
67045 +#define __bos0(ptr)
67046 +#endif
67047 +
67048 +#ifndef __bos1
67049 +#define __bos1(ptr)
67050 +#endif
67051 +
67052 /* Simple shorthand for a section definition */
67053 #ifndef __section
67054 # define __section(S) __attribute__ ((__section__(#S)))
67055 @@ -323,6 +392,7 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
67056 * use is to mediate communication between process-level code and irq/NMI
67057 * handlers, all running on the same CPU.
67058 */
67059 -#define ACCESS_ONCE(x) (*(volatile typeof(x) *)&(x))
67060 +#define ACCESS_ONCE(x) (*(volatile const typeof(x) *)&(x))
67061 +#define ACCESS_ONCE_RW(x) (*(volatile typeof(x) *)&(x))
67062
67063 #endif /* __LINUX_COMPILER_H */
67064 diff --git a/include/linux/completion.h b/include/linux/completion.h
67065 index 51494e6..0fd1b61 100644
67066 --- a/include/linux/completion.h
67067 +++ b/include/linux/completion.h
67068 @@ -78,13 +78,13 @@ static inline void init_completion(struct completion *x)
67069
67070 extern void wait_for_completion(struct completion *);
67071 extern int wait_for_completion_interruptible(struct completion *x);
67072 -extern int wait_for_completion_killable(struct completion *x);
67073 +extern int wait_for_completion_killable(struct completion *x) __intentional_overflow(-1);
67074 extern unsigned long wait_for_completion_timeout(struct completion *x,
67075 unsigned long timeout);
67076 extern long wait_for_completion_interruptible_timeout(
67077 - struct completion *x, unsigned long timeout);
67078 + struct completion *x, unsigned long timeout) __intentional_overflow(-1);
67079 extern long wait_for_completion_killable_timeout(
67080 - struct completion *x, unsigned long timeout);
67081 + struct completion *x, unsigned long timeout) __intentional_overflow(-1);
67082 extern bool try_wait_for_completion(struct completion *x);
67083 extern bool completion_done(struct completion *x);
67084
67085 diff --git a/include/linux/configfs.h b/include/linux/configfs.h
67086 index 34025df..d94bbbc 100644
67087 --- a/include/linux/configfs.h
67088 +++ b/include/linux/configfs.h
67089 @@ -125,7 +125,7 @@ struct configfs_attribute {
67090 const char *ca_name;
67091 struct module *ca_owner;
67092 umode_t ca_mode;
67093 -};
67094 +} __do_const;
67095
67096 /*
67097 * Users often need to create attribute structures for their configurable
67098 diff --git a/include/linux/cpu.h b/include/linux/cpu.h
67099 index ce7a074..01ab8ac 100644
67100 --- a/include/linux/cpu.h
67101 +++ b/include/linux/cpu.h
67102 @@ -115,7 +115,7 @@ enum {
67103 /* Need to know about CPUs going up/down? */
67104 #if defined(CONFIG_HOTPLUG_CPU) || !defined(MODULE)
67105 #define cpu_notifier(fn, pri) { \
67106 - static struct notifier_block fn##_nb __cpuinitdata = \
67107 + static struct notifier_block fn##_nb = \
67108 { .notifier_call = fn, .priority = pri }; \
67109 register_cpu_notifier(&fn##_nb); \
67110 }
67111 diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h
67112 index a55b88e..fba90c5 100644
67113 --- a/include/linux/cpufreq.h
67114 +++ b/include/linux/cpufreq.h
67115 @@ -240,7 +240,7 @@ struct cpufreq_driver {
67116 int (*suspend) (struct cpufreq_policy *policy);
67117 int (*resume) (struct cpufreq_policy *policy);
67118 struct freq_attr **attr;
67119 -};
67120 +} __do_const;
67121
67122 /* flags */
67123
67124 @@ -299,6 +299,7 @@ struct global_attr {
67125 ssize_t (*store)(struct kobject *a, struct attribute *b,
67126 const char *c, size_t count);
67127 };
67128 +typedef struct global_attr __no_const global_attr_no_const;
67129
67130 #define define_one_global_ro(_name) \
67131 static struct global_attr _name = \
67132 diff --git a/include/linux/cpuidle.h b/include/linux/cpuidle.h
67133 index 24cd1037..20a63aae 100644
67134 --- a/include/linux/cpuidle.h
67135 +++ b/include/linux/cpuidle.h
67136 @@ -54,7 +54,8 @@ struct cpuidle_state {
67137 int index);
67138
67139 int (*enter_dead) (struct cpuidle_device *dev, int index);
67140 -};
67141 +} __do_const;
67142 +typedef struct cpuidle_state __no_const cpuidle_state_no_const;
67143
67144 /* Idle State Flags */
67145 #define CPUIDLE_FLAG_TIME_VALID (0x01) /* is residency time measurable? */
67146 @@ -216,7 +217,7 @@ struct cpuidle_governor {
67147 void (*reflect) (struct cpuidle_device *dev, int index);
67148
67149 struct module *owner;
67150 -};
67151 +} __do_const;
67152
67153 #ifdef CONFIG_CPU_IDLE
67154
67155 diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h
67156 index 0325602..5e9feff 100644
67157 --- a/include/linux/cpumask.h
67158 +++ b/include/linux/cpumask.h
67159 @@ -118,17 +118,17 @@ static inline unsigned int cpumask_first(const struct cpumask *srcp)
67160 }
67161
67162 /* Valid inputs for n are -1 and 0. */
67163 -static inline unsigned int cpumask_next(int n, const struct cpumask *srcp)
67164 +static inline unsigned int __intentional_overflow(-1) cpumask_next(int n, const struct cpumask *srcp)
67165 {
67166 return n+1;
67167 }
67168
67169 -static inline unsigned int cpumask_next_zero(int n, const struct cpumask *srcp)
67170 +static inline unsigned int __intentional_overflow(-1) cpumask_next_zero(int n, const struct cpumask *srcp)
67171 {
67172 return n+1;
67173 }
67174
67175 -static inline unsigned int cpumask_next_and(int n,
67176 +static inline unsigned int __intentional_overflow(-1) cpumask_next_and(int n,
67177 const struct cpumask *srcp,
67178 const struct cpumask *andp)
67179 {
67180 @@ -167,7 +167,7 @@ static inline unsigned int cpumask_first(const struct cpumask *srcp)
67181 *
67182 * Returns >= nr_cpu_ids if no further cpus set.
67183 */
67184 -static inline unsigned int cpumask_next(int n, const struct cpumask *srcp)
67185 +static inline unsigned int __intentional_overflow(-1) cpumask_next(int n, const struct cpumask *srcp)
67186 {
67187 /* -1 is a legal arg here. */
67188 if (n != -1)
67189 @@ -182,7 +182,7 @@ static inline unsigned int cpumask_next(int n, const struct cpumask *srcp)
67190 *
67191 * Returns >= nr_cpu_ids if no further cpus unset.
67192 */
67193 -static inline unsigned int cpumask_next_zero(int n, const struct cpumask *srcp)
67194 +static inline unsigned int __intentional_overflow(-1) cpumask_next_zero(int n, const struct cpumask *srcp)
67195 {
67196 /* -1 is a legal arg here. */
67197 if (n != -1)
67198 @@ -190,7 +190,7 @@ static inline unsigned int cpumask_next_zero(int n, const struct cpumask *srcp)
67199 return find_next_zero_bit(cpumask_bits(srcp), nr_cpumask_bits, n+1);
67200 }
67201
67202 -int cpumask_next_and(int n, const struct cpumask *, const struct cpumask *);
67203 +int cpumask_next_and(int n, const struct cpumask *, const struct cpumask *) __intentional_overflow(-1);
67204 int cpumask_any_but(const struct cpumask *mask, unsigned int cpu);
67205
67206 /**
67207 diff --git a/include/linux/cred.h b/include/linux/cred.h
67208 index 04421e8..6bce4ef 100644
67209 --- a/include/linux/cred.h
67210 +++ b/include/linux/cred.h
67211 @@ -194,6 +194,9 @@ static inline void validate_creds_for_do_exit(struct task_struct *tsk)
67212 static inline void validate_process_creds(void)
67213 {
67214 }
67215 +static inline void validate_task_creds(struct task_struct *task)
67216 +{
67217 +}
67218 #endif
67219
67220 /**
67221 diff --git a/include/linux/crypto.h b/include/linux/crypto.h
67222 index b92eadf..b4ecdc1 100644
67223 --- a/include/linux/crypto.h
67224 +++ b/include/linux/crypto.h
67225 @@ -373,7 +373,7 @@ struct cipher_tfm {
67226 const u8 *key, unsigned int keylen);
67227 void (*cit_encrypt_one)(struct crypto_tfm *tfm, u8 *dst, const u8 *src);
67228 void (*cit_decrypt_one)(struct crypto_tfm *tfm, u8 *dst, const u8 *src);
67229 -};
67230 +} __no_const;
67231
67232 struct hash_tfm {
67233 int (*init)(struct hash_desc *desc);
67234 @@ -394,13 +394,13 @@ struct compress_tfm {
67235 int (*cot_decompress)(struct crypto_tfm *tfm,
67236 const u8 *src, unsigned int slen,
67237 u8 *dst, unsigned int *dlen);
67238 -};
67239 +} __no_const;
67240
67241 struct rng_tfm {
67242 int (*rng_gen_random)(struct crypto_rng *tfm, u8 *rdata,
67243 unsigned int dlen);
67244 int (*rng_reset)(struct crypto_rng *tfm, u8 *seed, unsigned int slen);
67245 -};
67246 +} __no_const;
67247
67248 #define crt_ablkcipher crt_u.ablkcipher
67249 #define crt_aead crt_u.aead
67250 diff --git a/include/linux/ctype.h b/include/linux/ctype.h
67251 index 8acfe31..6ffccd63 100644
67252 --- a/include/linux/ctype.h
67253 +++ b/include/linux/ctype.h
67254 @@ -56,7 +56,7 @@ static inline unsigned char __toupper(unsigned char c)
67255 * Fast implementation of tolower() for internal usage. Do not use in your
67256 * code.
67257 */
67258 -static inline char _tolower(const char c)
67259 +static inline unsigned char _tolower(const unsigned char c)
67260 {
67261 return c | 0x20;
67262 }
67263 diff --git a/include/linux/decompress/mm.h b/include/linux/decompress/mm.h
67264 index 7925bf0..d5143d2 100644
67265 --- a/include/linux/decompress/mm.h
67266 +++ b/include/linux/decompress/mm.h
67267 @@ -77,7 +77,7 @@ static void free(void *where)
67268 * warnings when not needed (indeed large_malloc / large_free are not
67269 * needed by inflate */
67270
67271 -#define malloc(a) kmalloc(a, GFP_KERNEL)
67272 +#define malloc(a) kmalloc((a), GFP_KERNEL)
67273 #define free(a) kfree(a)
67274
67275 #define large_malloc(a) vmalloc(a)
67276 diff --git a/include/linux/devfreq.h b/include/linux/devfreq.h
67277 index e83ef39..33e0eb3 100644
67278 --- a/include/linux/devfreq.h
67279 +++ b/include/linux/devfreq.h
67280 @@ -114,7 +114,7 @@ struct devfreq_governor {
67281 int (*get_target_freq)(struct devfreq *this, unsigned long *freq);
67282 int (*event_handler)(struct devfreq *devfreq,
67283 unsigned int event, void *data);
67284 -};
67285 +} __do_const;
67286
67287 /**
67288 * struct devfreq - Device devfreq structure
67289 diff --git a/include/linux/device.h b/include/linux/device.h
67290 index 43dcda9..7a1fb65 100644
67291 --- a/include/linux/device.h
67292 +++ b/include/linux/device.h
67293 @@ -294,7 +294,7 @@ struct subsys_interface {
67294 struct list_head node;
67295 int (*add_dev)(struct device *dev, struct subsys_interface *sif);
67296 int (*remove_dev)(struct device *dev, struct subsys_interface *sif);
67297 -};
67298 +} __do_const;
67299
67300 int subsys_interface_register(struct subsys_interface *sif);
67301 void subsys_interface_unregister(struct subsys_interface *sif);
67302 @@ -474,7 +474,7 @@ struct device_type {
67303 void (*release)(struct device *dev);
67304
67305 const struct dev_pm_ops *pm;
67306 -};
67307 +} __do_const;
67308
67309 /* interface for exporting device attributes */
67310 struct device_attribute {
67311 @@ -484,11 +484,12 @@ struct device_attribute {
67312 ssize_t (*store)(struct device *dev, struct device_attribute *attr,
67313 const char *buf, size_t count);
67314 };
67315 +typedef struct device_attribute __no_const device_attribute_no_const;
67316
67317 struct dev_ext_attribute {
67318 struct device_attribute attr;
67319 void *var;
67320 -};
67321 +} __do_const;
67322
67323 ssize_t device_show_ulong(struct device *dev, struct device_attribute *attr,
67324 char *buf);
67325 diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h
67326 index 94af418..b1ca7a2 100644
67327 --- a/include/linux/dma-mapping.h
67328 +++ b/include/linux/dma-mapping.h
67329 @@ -54,7 +54,7 @@ struct dma_map_ops {
67330 u64 (*get_required_mask)(struct device *dev);
67331 #endif
67332 int is_phys;
67333 -};
67334 +} __do_const;
67335
67336 #define DMA_BIT_MASK(n) (((n) == 64) ? ~0ULL : ((1ULL<<(n))-1))
67337
67338 diff --git a/include/linux/dmaengine.h b/include/linux/dmaengine.h
67339 index d3201e4..8281e63 100644
67340 --- a/include/linux/dmaengine.h
67341 +++ b/include/linux/dmaengine.h
67342 @@ -1018,9 +1018,9 @@ struct dma_pinned_list {
67343 struct dma_pinned_list *dma_pin_iovec_pages(struct iovec *iov, size_t len);
67344 void dma_unpin_iovec_pages(struct dma_pinned_list* pinned_list);
67345
67346 -dma_cookie_t dma_memcpy_to_iovec(struct dma_chan *chan, struct iovec *iov,
67347 +dma_cookie_t __intentional_overflow(0) dma_memcpy_to_iovec(struct dma_chan *chan, struct iovec *iov,
67348 struct dma_pinned_list *pinned_list, unsigned char *kdata, size_t len);
67349 -dma_cookie_t dma_memcpy_pg_to_iovec(struct dma_chan *chan, struct iovec *iov,
67350 +dma_cookie_t __intentional_overflow(0) dma_memcpy_pg_to_iovec(struct dma_chan *chan, struct iovec *iov,
67351 struct dma_pinned_list *pinned_list, struct page *page,
67352 unsigned int offset, size_t len);
67353
67354 diff --git a/include/linux/efi.h b/include/linux/efi.h
67355 index 7a9498a..155713d 100644
67356 --- a/include/linux/efi.h
67357 +++ b/include/linux/efi.h
67358 @@ -733,6 +733,7 @@ struct efivar_operations {
67359 efi_set_variable_t *set_variable;
67360 efi_query_variable_info_t *query_variable_info;
67361 };
67362 +typedef struct efivar_operations __no_const efivar_operations_no_const;
67363
67364 struct efivars {
67365 /*
67366 diff --git a/include/linux/elf.h b/include/linux/elf.h
67367 index 8c9048e..16a4665 100644
67368 --- a/include/linux/elf.h
67369 +++ b/include/linux/elf.h
67370 @@ -20,6 +20,7 @@ extern Elf32_Dyn _DYNAMIC [];
67371 #define elf_note elf32_note
67372 #define elf_addr_t Elf32_Off
67373 #define Elf_Half Elf32_Half
67374 +#define elf_dyn Elf32_Dyn
67375
67376 #else
67377
67378 @@ -30,6 +31,7 @@ extern Elf64_Dyn _DYNAMIC [];
67379 #define elf_note elf64_note
67380 #define elf_addr_t Elf64_Off
67381 #define Elf_Half Elf64_Half
67382 +#define elf_dyn Elf64_Dyn
67383
67384 #endif
67385
67386 diff --git a/include/linux/err.h b/include/linux/err.h
67387 index f2edce2..cc2082c 100644
67388 --- a/include/linux/err.h
67389 +++ b/include/linux/err.h
67390 @@ -19,12 +19,12 @@
67391
67392 #define IS_ERR_VALUE(x) unlikely((x) >= (unsigned long)-MAX_ERRNO)
67393
67394 -static inline void * __must_check ERR_PTR(long error)
67395 +static inline void * __must_check __intentional_overflow(-1) ERR_PTR(long error)
67396 {
67397 return (void *) error;
67398 }
67399
67400 -static inline long __must_check PTR_ERR(const void *ptr)
67401 +static inline long __must_check __intentional_overflow(-1) PTR_ERR(const void *ptr)
67402 {
67403 return (long) ptr;
67404 }
67405 diff --git a/include/linux/extcon.h b/include/linux/extcon.h
67406 index fcb51c8..bdafcf6 100644
67407 --- a/include/linux/extcon.h
67408 +++ b/include/linux/extcon.h
67409 @@ -134,7 +134,7 @@ struct extcon_dev {
67410 /* /sys/class/extcon/.../mutually_exclusive/... */
67411 struct attribute_group attr_g_muex;
67412 struct attribute **attrs_muex;
67413 - struct device_attribute *d_attrs_muex;
67414 + device_attribute_no_const *d_attrs_muex;
67415 };
67416
67417 /**
67418 diff --git a/include/linux/fb.h b/include/linux/fb.h
67419 index c7a9571..02eeffe 100644
67420 --- a/include/linux/fb.h
67421 +++ b/include/linux/fb.h
67422 @@ -302,7 +302,7 @@ struct fb_ops {
67423 /* called at KDB enter and leave time to prepare the console */
67424 int (*fb_debug_enter)(struct fb_info *info);
67425 int (*fb_debug_leave)(struct fb_info *info);
67426 -};
67427 +} __do_const;
67428
67429 #ifdef CONFIG_FB_TILEBLITTING
67430 #define FB_TILE_CURSOR_NONE 0
67431 diff --git a/include/linux/filter.h b/include/linux/filter.h
67432 index c45eabc..baa0be5 100644
67433 --- a/include/linux/filter.h
67434 +++ b/include/linux/filter.h
67435 @@ -20,6 +20,7 @@ struct compat_sock_fprog {
67436
67437 struct sk_buff;
67438 struct sock;
67439 +struct bpf_jit_work;
67440
67441 struct sk_filter
67442 {
67443 @@ -27,6 +28,9 @@ struct sk_filter
67444 unsigned int len; /* Number of filter blocks */
67445 unsigned int (*bpf_func)(const struct sk_buff *skb,
67446 const struct sock_filter *filter);
67447 +#ifdef CONFIG_BPF_JIT
67448 + struct bpf_jit_work *work;
67449 +#endif
67450 struct rcu_head rcu;
67451 struct sock_filter insns[0];
67452 };
67453 diff --git a/include/linux/frontswap.h b/include/linux/frontswap.h
67454 index 3044254..9767f41 100644
67455 --- a/include/linux/frontswap.h
67456 +++ b/include/linux/frontswap.h
67457 @@ -11,7 +11,7 @@ struct frontswap_ops {
67458 int (*load)(unsigned, pgoff_t, struct page *);
67459 void (*invalidate_page)(unsigned, pgoff_t);
67460 void (*invalidate_area)(unsigned);
67461 -};
67462 +} __no_const;
67463
67464 extern bool frontswap_enabled;
67465 extern struct frontswap_ops
67466 diff --git a/include/linux/fs.h b/include/linux/fs.h
67467 index 7617ee0..b575199 100644
67468 --- a/include/linux/fs.h
67469 +++ b/include/linux/fs.h
67470 @@ -1541,7 +1541,8 @@ struct file_operations {
67471 long (*fallocate)(struct file *file, int mode, loff_t offset,
67472 loff_t len);
67473 int (*show_fdinfo)(struct seq_file *m, struct file *f);
67474 -};
67475 +} __do_const;
67476 +typedef struct file_operations __no_const file_operations_no_const;
67477
67478 struct inode_operations {
67479 struct dentry * (*lookup) (struct inode *,struct dentry *, unsigned int);
67480 @@ -2665,4 +2666,14 @@ static inline void inode_has_no_xattr(struct inode *inode)
67481 inode->i_flags |= S_NOSEC;
67482 }
67483
67484 +static inline bool is_sidechannel_device(const struct inode *inode)
67485 +{
67486 +#ifdef CONFIG_GRKERNSEC_DEVICE_SIDECHANNEL
67487 + umode_t mode = inode->i_mode;
67488 + return ((S_ISCHR(mode) || S_ISBLK(mode)) && (mode & (S_IROTH | S_IWOTH)));
67489 +#else
67490 + return false;
67491 +#endif
67492 +}
67493 +
67494 #endif /* _LINUX_FS_H */
67495 diff --git a/include/linux/fs_struct.h b/include/linux/fs_struct.h
67496 index d0ae3a8..0244b34 100644
67497 --- a/include/linux/fs_struct.h
67498 +++ b/include/linux/fs_struct.h
67499 @@ -6,7 +6,7 @@
67500 #include <linux/seqlock.h>
67501
67502 struct fs_struct {
67503 - int users;
67504 + atomic_t users;
67505 spinlock_t lock;
67506 seqcount_t seq;
67507 int umask;
67508 diff --git a/include/linux/fscache-cache.h b/include/linux/fscache-cache.h
67509 index 5dfa0aa..6acf322 100644
67510 --- a/include/linux/fscache-cache.h
67511 +++ b/include/linux/fscache-cache.h
67512 @@ -112,7 +112,7 @@ struct fscache_operation {
67513 fscache_operation_release_t release;
67514 };
67515
67516 -extern atomic_t fscache_op_debug_id;
67517 +extern atomic_unchecked_t fscache_op_debug_id;
67518 extern void fscache_op_work_func(struct work_struct *work);
67519
67520 extern void fscache_enqueue_operation(struct fscache_operation *);
67521 @@ -134,7 +134,7 @@ static inline void fscache_operation_init(struct fscache_operation *op,
67522 INIT_WORK(&op->work, fscache_op_work_func);
67523 atomic_set(&op->usage, 1);
67524 op->state = FSCACHE_OP_ST_INITIALISED;
67525 - op->debug_id = atomic_inc_return(&fscache_op_debug_id);
67526 + op->debug_id = atomic_inc_return_unchecked(&fscache_op_debug_id);
67527 op->processor = processor;
67528 op->release = release;
67529 INIT_LIST_HEAD(&op->pend_link);
67530 diff --git a/include/linux/fscache.h b/include/linux/fscache.h
67531 index 7a08623..4c07b0f 100644
67532 --- a/include/linux/fscache.h
67533 +++ b/include/linux/fscache.h
67534 @@ -152,7 +152,7 @@ struct fscache_cookie_def {
67535 * - this is mandatory for any object that may have data
67536 */
67537 void (*now_uncached)(void *cookie_netfs_data);
67538 -};
67539 +} __do_const;
67540
67541 /*
67542 * fscache cached network filesystem type
67543 diff --git a/include/linux/fsnotify.h b/include/linux/fsnotify.h
67544 index 0fbfb46..508eb0d 100644
67545 --- a/include/linux/fsnotify.h
67546 +++ b/include/linux/fsnotify.h
67547 @@ -195,6 +195,9 @@ static inline void fsnotify_access(struct file *file)
67548 struct inode *inode = path->dentry->d_inode;
67549 __u32 mask = FS_ACCESS;
67550
67551 + if (is_sidechannel_device(inode))
67552 + return;
67553 +
67554 if (S_ISDIR(inode->i_mode))
67555 mask |= FS_ISDIR;
67556
67557 @@ -213,6 +216,9 @@ static inline void fsnotify_modify(struct file *file)
67558 struct inode *inode = path->dentry->d_inode;
67559 __u32 mask = FS_MODIFY;
67560
67561 + if (is_sidechannel_device(inode))
67562 + return;
67563 +
67564 if (S_ISDIR(inode->i_mode))
67565 mask |= FS_ISDIR;
67566
67567 @@ -315,7 +321,7 @@ static inline void fsnotify_change(struct dentry *dentry, unsigned int ia_valid)
67568 */
67569 static inline const unsigned char *fsnotify_oldname_init(const unsigned char *name)
67570 {
67571 - return kstrdup(name, GFP_KERNEL);
67572 + return (const unsigned char *)kstrdup((const char *)name, GFP_KERNEL);
67573 }
67574
67575 /*
67576 diff --git a/include/linux/ftrace_event.h b/include/linux/ftrace_event.h
67577 index a3d4895..ddd2a50 100644
67578 --- a/include/linux/ftrace_event.h
67579 +++ b/include/linux/ftrace_event.h
67580 @@ -272,7 +272,7 @@ extern int trace_define_field(struct ftrace_event_call *call, const char *type,
67581 extern int trace_add_event_call(struct ftrace_event_call *call);
67582 extern void trace_remove_event_call(struct ftrace_event_call *call);
67583
67584 -#define is_signed_type(type) (((type)(-1)) < 0)
67585 +#define is_signed_type(type) (((type)(-1)) < (type)1)
67586
67587 int trace_set_clr_event(const char *system, const char *event, int set);
67588
67589 diff --git a/include/linux/genhd.h b/include/linux/genhd.h
67590 index 79b8bba..86b539e 100644
67591 --- a/include/linux/genhd.h
67592 +++ b/include/linux/genhd.h
67593 @@ -194,7 +194,7 @@ struct gendisk {
67594 struct kobject *slave_dir;
67595
67596 struct timer_rand_state *random;
67597 - atomic_t sync_io; /* RAID */
67598 + atomic_unchecked_t sync_io; /* RAID */
67599 struct disk_events *ev;
67600 #ifdef CONFIG_BLK_DEV_INTEGRITY
67601 struct blk_integrity *integrity;
67602 diff --git a/include/linux/genl_magic_func.h b/include/linux/genl_magic_func.h
67603 index 023bc34..b02b46a 100644
67604 --- a/include/linux/genl_magic_func.h
67605 +++ b/include/linux/genl_magic_func.h
67606 @@ -246,7 +246,7 @@ const char *CONCAT_(GENL_MAGIC_FAMILY, _genl_cmd_to_str)(__u8 cmd)
67607 },
67608
67609 #define ZZZ_genl_ops CONCAT_(GENL_MAGIC_FAMILY, _genl_ops)
67610 -static struct genl_ops ZZZ_genl_ops[] __read_mostly = {
67611 +static struct genl_ops ZZZ_genl_ops[] = {
67612 #include GENL_MAGIC_INCLUDE_FILE
67613 };
67614
67615 diff --git a/include/linux/gfp.h b/include/linux/gfp.h
67616 index 0f615eb..5c3832f 100644
67617 --- a/include/linux/gfp.h
67618 +++ b/include/linux/gfp.h
67619 @@ -35,6 +35,13 @@ struct vm_area_struct;
67620 #define ___GFP_NO_KSWAPD 0x400000u
67621 #define ___GFP_OTHER_NODE 0x800000u
67622 #define ___GFP_WRITE 0x1000000u
67623 +
67624 +#ifdef CONFIG_PAX_USERCOPY_SLABS
67625 +#define ___GFP_USERCOPY 0x2000000u
67626 +#else
67627 +#define ___GFP_USERCOPY 0
67628 +#endif
67629 +
67630 /* If the above are modified, __GFP_BITS_SHIFT may need updating */
67631
67632 /*
67633 @@ -92,6 +99,7 @@ struct vm_area_struct;
67634 #define __GFP_OTHER_NODE ((__force gfp_t)___GFP_OTHER_NODE) /* On behalf of other node */
67635 #define __GFP_KMEMCG ((__force gfp_t)___GFP_KMEMCG) /* Allocation comes from a memcg-accounted resource */
67636 #define __GFP_WRITE ((__force gfp_t)___GFP_WRITE) /* Allocator intends to dirty page */
67637 +#define __GFP_USERCOPY ((__force gfp_t)___GFP_USERCOPY)/* Allocator intends to copy page to/from userland */
67638
67639 /*
67640 * This may seem redundant, but it's a way of annotating false positives vs.
67641 @@ -99,7 +107,7 @@ struct vm_area_struct;
67642 */
67643 #define __GFP_NOTRACK_FALSE_POSITIVE (__GFP_NOTRACK)
67644
67645 -#define __GFP_BITS_SHIFT 25 /* Room for N __GFP_FOO bits */
67646 +#define __GFP_BITS_SHIFT 26 /* Room for N __GFP_FOO bits */
67647 #define __GFP_BITS_MASK ((__force gfp_t)((1 << __GFP_BITS_SHIFT) - 1))
67648
67649 /* This equals 0, but use constants in case they ever change */
67650 @@ -153,6 +161,8 @@ struct vm_area_struct;
67651 /* 4GB DMA on some platforms */
67652 #define GFP_DMA32 __GFP_DMA32
67653
67654 +#define GFP_USERCOPY __GFP_USERCOPY
67655 +
67656 /* Convert GFP flags to their corresponding migrate type */
67657 static inline int allocflags_to_migratetype(gfp_t gfp_flags)
67658 {
67659 diff --git a/include/linux/gracl.h b/include/linux/gracl.h
67660 new file mode 100644
67661 index 0000000..ebe6d72
67662 --- /dev/null
67663 +++ b/include/linux/gracl.h
67664 @@ -0,0 +1,319 @@
67665 +#ifndef GR_ACL_H
67666 +#define GR_ACL_H
67667 +
67668 +#include <linux/grdefs.h>
67669 +#include <linux/resource.h>
67670 +#include <linux/capability.h>
67671 +#include <linux/dcache.h>
67672 +#include <asm/resource.h>
67673 +
67674 +/* Major status information */
67675 +
67676 +#define GR_VERSION "grsecurity 2.9.1"
67677 +#define GRSECURITY_VERSION 0x2901
67678 +
67679 +enum {
67680 + GR_SHUTDOWN = 0,
67681 + GR_ENABLE = 1,
67682 + GR_SPROLE = 2,
67683 + GR_RELOAD = 3,
67684 + GR_SEGVMOD = 4,
67685 + GR_STATUS = 5,
67686 + GR_UNSPROLE = 6,
67687 + GR_PASSSET = 7,
67688 + GR_SPROLEPAM = 8,
67689 +};
67690 +
67691 +/* Password setup definitions
67692 + * kernel/grhash.c */
67693 +enum {
67694 + GR_PW_LEN = 128,
67695 + GR_SALT_LEN = 16,
67696 + GR_SHA_LEN = 32,
67697 +};
67698 +
67699 +enum {
67700 + GR_SPROLE_LEN = 64,
67701 +};
67702 +
67703 +enum {
67704 + GR_NO_GLOB = 0,
67705 + GR_REG_GLOB,
67706 + GR_CREATE_GLOB
67707 +};
67708 +
67709 +#define GR_NLIMITS 32
67710 +
67711 +/* Begin Data Structures */
67712 +
67713 +struct sprole_pw {
67714 + unsigned char *rolename;
67715 + unsigned char salt[GR_SALT_LEN];
67716 + unsigned char sum[GR_SHA_LEN]; /* 256-bit SHA hash of the password */
67717 +};
67718 +
67719 +struct name_entry {
67720 + __u32 key;
67721 + ino_t inode;
67722 + dev_t device;
67723 + char *name;
67724 + __u16 len;
67725 + __u8 deleted;
67726 + struct name_entry *prev;
67727 + struct name_entry *next;
67728 +};
67729 +
67730 +struct inodev_entry {
67731 + struct name_entry *nentry;
67732 + struct inodev_entry *prev;
67733 + struct inodev_entry *next;
67734 +};
67735 +
67736 +struct acl_role_db {
67737 + struct acl_role_label **r_hash;
67738 + __u32 r_size;
67739 +};
67740 +
67741 +struct inodev_db {
67742 + struct inodev_entry **i_hash;
67743 + __u32 i_size;
67744 +};
67745 +
67746 +struct name_db {
67747 + struct name_entry **n_hash;
67748 + __u32 n_size;
67749 +};
67750 +
67751 +struct crash_uid {
67752 + uid_t uid;
67753 + unsigned long expires;
67754 +};
67755 +
67756 +struct gr_hash_struct {
67757 + void **table;
67758 + void **nametable;
67759 + void *first;
67760 + __u32 table_size;
67761 + __u32 used_size;
67762 + int type;
67763 +};
67764 +
67765 +/* Userspace Grsecurity ACL data structures */
67766 +
67767 +struct acl_subject_label {
67768 + char *filename;
67769 + ino_t inode;
67770 + dev_t device;
67771 + __u32 mode;
67772 + kernel_cap_t cap_mask;
67773 + kernel_cap_t cap_lower;
67774 + kernel_cap_t cap_invert_audit;
67775 +
67776 + struct rlimit res[GR_NLIMITS];
67777 + __u32 resmask;
67778 +
67779 + __u8 user_trans_type;
67780 + __u8 group_trans_type;
67781 + uid_t *user_transitions;
67782 + gid_t *group_transitions;
67783 + __u16 user_trans_num;
67784 + __u16 group_trans_num;
67785 +
67786 + __u32 sock_families[2];
67787 + __u32 ip_proto[8];
67788 + __u32 ip_type;
67789 + struct acl_ip_label **ips;
67790 + __u32 ip_num;
67791 + __u32 inaddr_any_override;
67792 +
67793 + __u32 crashes;
67794 + unsigned long expires;
67795 +
67796 + struct acl_subject_label *parent_subject;
67797 + struct gr_hash_struct *hash;
67798 + struct acl_subject_label *prev;
67799 + struct acl_subject_label *next;
67800 +
67801 + struct acl_object_label **obj_hash;
67802 + __u32 obj_hash_size;
67803 + __u16 pax_flags;
67804 +};
67805 +
67806 +struct role_allowed_ip {
67807 + __u32 addr;
67808 + __u32 netmask;
67809 +
67810 + struct role_allowed_ip *prev;
67811 + struct role_allowed_ip *next;
67812 +};
67813 +
67814 +struct role_transition {
67815 + char *rolename;
67816 +
67817 + struct role_transition *prev;
67818 + struct role_transition *next;
67819 +};
67820 +
67821 +struct acl_role_label {
67822 + char *rolename;
67823 + uid_t uidgid;
67824 + __u16 roletype;
67825 +
67826 + __u16 auth_attempts;
67827 + unsigned long expires;
67828 +
67829 + struct acl_subject_label *root_label;
67830 + struct gr_hash_struct *hash;
67831 +
67832 + struct acl_role_label *prev;
67833 + struct acl_role_label *next;
67834 +
67835 + struct role_transition *transitions;
67836 + struct role_allowed_ip *allowed_ips;
67837 + uid_t *domain_children;
67838 + __u16 domain_child_num;
67839 +
67840 + umode_t umask;
67841 +
67842 + struct acl_subject_label **subj_hash;
67843 + __u32 subj_hash_size;
67844 +};
67845 +
67846 +struct user_acl_role_db {
67847 + struct acl_role_label **r_table;
67848 + __u32 num_pointers; /* Number of allocations to track */
67849 + __u32 num_roles; /* Number of roles */
67850 + __u32 num_domain_children; /* Number of domain children */
67851 + __u32 num_subjects; /* Number of subjects */
67852 + __u32 num_objects; /* Number of objects */
67853 +};
67854 +
67855 +struct acl_object_label {
67856 + char *filename;
67857 + ino_t inode;
67858 + dev_t device;
67859 + __u32 mode;
67860 +
67861 + struct acl_subject_label *nested;
67862 + struct acl_object_label *globbed;
67863 +
67864 + /* next two structures not used */
67865 +
67866 + struct acl_object_label *prev;
67867 + struct acl_object_label *next;
67868 +};
67869 +
67870 +struct acl_ip_label {
67871 + char *iface;
67872 + __u32 addr;
67873 + __u32 netmask;
67874 + __u16 low, high;
67875 + __u8 mode;
67876 + __u32 type;
67877 + __u32 proto[8];
67878 +
67879 + /* next two structures not used */
67880 +
67881 + struct acl_ip_label *prev;
67882 + struct acl_ip_label *next;
67883 +};
67884 +
67885 +struct gr_arg {
67886 + struct user_acl_role_db role_db;
67887 + unsigned char pw[GR_PW_LEN];
67888 + unsigned char salt[GR_SALT_LEN];
67889 + unsigned char sum[GR_SHA_LEN];
67890 + unsigned char sp_role[GR_SPROLE_LEN];
67891 + struct sprole_pw *sprole_pws;
67892 + dev_t segv_device;
67893 + ino_t segv_inode;
67894 + uid_t segv_uid;
67895 + __u16 num_sprole_pws;
67896 + __u16 mode;
67897 +};
67898 +
67899 +struct gr_arg_wrapper {
67900 + struct gr_arg *arg;
67901 + __u32 version;
67902 + __u32 size;
67903 +};
67904 +
67905 +struct subject_map {
67906 + struct acl_subject_label *user;
67907 + struct acl_subject_label *kernel;
67908 + struct subject_map *prev;
67909 + struct subject_map *next;
67910 +};
67911 +
67912 +struct acl_subj_map_db {
67913 + struct subject_map **s_hash;
67914 + __u32 s_size;
67915 +};
67916 +
67917 +/* End Data Structures Section */
67918 +
67919 +/* Hash functions generated by empirical testing by Brad Spengler
67920 + Makes good use of the low bits of the inode. Generally 0-1 times
67921 + in loop for successful match. 0-3 for unsuccessful match.
67922 + Shift/add algorithm with modulus of table size and an XOR*/
67923 +
67924 +static __inline__ unsigned int
67925 +gr_rhash(const uid_t uid, const __u16 type, const unsigned int sz)
67926 +{
67927 + return ((((uid + type) << (16 + type)) ^ uid) % sz);
67928 +}
67929 +
67930 + static __inline__ unsigned int
67931 +gr_shash(const struct acl_subject_label *userp, const unsigned int sz)
67932 +{
67933 + return ((const unsigned long)userp % sz);
67934 +}
67935 +
67936 +static __inline__ unsigned int
67937 +gr_fhash(const ino_t ino, const dev_t dev, const unsigned int sz)
67938 +{
67939 + return (((ino + dev) ^ ((ino << 13) + (ino << 23) + (dev << 9))) % sz);
67940 +}
67941 +
67942 +static __inline__ unsigned int
67943 +gr_nhash(const char *name, const __u16 len, const unsigned int sz)
67944 +{
67945 + return full_name_hash((const unsigned char *)name, len) % sz;
67946 +}
67947 +
67948 +#define FOR_EACH_ROLE_START(role) \
67949 + role = role_list; \
67950 + while (role) {
67951 +
67952 +#define FOR_EACH_ROLE_END(role) \
67953 + role = role->prev; \
67954 + }
67955 +
67956 +#define FOR_EACH_SUBJECT_START(role,subj,iter) \
67957 + subj = NULL; \
67958 + iter = 0; \
67959 + while (iter < role->subj_hash_size) { \
67960 + if (subj == NULL) \
67961 + subj = role->subj_hash[iter]; \
67962 + if (subj == NULL) { \
67963 + iter++; \
67964 + continue; \
67965 + }
67966 +
67967 +#define FOR_EACH_SUBJECT_END(subj,iter) \
67968 + subj = subj->next; \
67969 + if (subj == NULL) \
67970 + iter++; \
67971 + }
67972 +
67973 +
67974 +#define FOR_EACH_NESTED_SUBJECT_START(role,subj) \
67975 + subj = role->hash->first; \
67976 + while (subj != NULL) {
67977 +
67978 +#define FOR_EACH_NESTED_SUBJECT_END(subj) \
67979 + subj = subj->next; \
67980 + }
67981 +
67982 +#endif
67983 +
67984 diff --git a/include/linux/gralloc.h b/include/linux/gralloc.h
67985 new file mode 100644
67986 index 0000000..323ecf2
67987 --- /dev/null
67988 +++ b/include/linux/gralloc.h
67989 @@ -0,0 +1,9 @@
67990 +#ifndef __GRALLOC_H
67991 +#define __GRALLOC_H
67992 +
67993 +void acl_free_all(void);
67994 +int acl_alloc_stack_init(unsigned long size);
67995 +void *acl_alloc(unsigned long len);
67996 +void *acl_alloc_num(unsigned long num, unsigned long len);
67997 +
67998 +#endif
67999 diff --git a/include/linux/grdefs.h b/include/linux/grdefs.h
68000 new file mode 100644
68001 index 0000000..be66033
68002 --- /dev/null
68003 +++ b/include/linux/grdefs.h
68004 @@ -0,0 +1,140 @@
68005 +#ifndef GRDEFS_H
68006 +#define GRDEFS_H
68007 +
68008 +/* Begin grsecurity status declarations */
68009 +
68010 +enum {
68011 + GR_READY = 0x01,
68012 + GR_STATUS_INIT = 0x00 // disabled state
68013 +};
68014 +
68015 +/* Begin ACL declarations */
68016 +
68017 +/* Role flags */
68018 +
68019 +enum {
68020 + GR_ROLE_USER = 0x0001,
68021 + GR_ROLE_GROUP = 0x0002,
68022 + GR_ROLE_DEFAULT = 0x0004,
68023 + GR_ROLE_SPECIAL = 0x0008,
68024 + GR_ROLE_AUTH = 0x0010,
68025 + GR_ROLE_NOPW = 0x0020,
68026 + GR_ROLE_GOD = 0x0040,
68027 + GR_ROLE_LEARN = 0x0080,
68028 + GR_ROLE_TPE = 0x0100,
68029 + GR_ROLE_DOMAIN = 0x0200,
68030 + GR_ROLE_PAM = 0x0400,
68031 + GR_ROLE_PERSIST = 0x0800
68032 +};
68033 +
68034 +/* ACL Subject and Object mode flags */
68035 +enum {
68036 + GR_DELETED = 0x80000000
68037 +};
68038 +
68039 +/* ACL Object-only mode flags */
68040 +enum {
68041 + GR_READ = 0x00000001,
68042 + GR_APPEND = 0x00000002,
68043 + GR_WRITE = 0x00000004,
68044 + GR_EXEC = 0x00000008,
68045 + GR_FIND = 0x00000010,
68046 + GR_INHERIT = 0x00000020,
68047 + GR_SETID = 0x00000040,
68048 + GR_CREATE = 0x00000080,
68049 + GR_DELETE = 0x00000100,
68050 + GR_LINK = 0x00000200,
68051 + GR_AUDIT_READ = 0x00000400,
68052 + GR_AUDIT_APPEND = 0x00000800,
68053 + GR_AUDIT_WRITE = 0x00001000,
68054 + GR_AUDIT_EXEC = 0x00002000,
68055 + GR_AUDIT_FIND = 0x00004000,
68056 + GR_AUDIT_INHERIT= 0x00008000,
68057 + GR_AUDIT_SETID = 0x00010000,
68058 + GR_AUDIT_CREATE = 0x00020000,
68059 + GR_AUDIT_DELETE = 0x00040000,
68060 + GR_AUDIT_LINK = 0x00080000,
68061 + GR_PTRACERD = 0x00100000,
68062 + GR_NOPTRACE = 0x00200000,
68063 + GR_SUPPRESS = 0x00400000,
68064 + GR_NOLEARN = 0x00800000,
68065 + GR_INIT_TRANSFER= 0x01000000
68066 +};
68067 +
68068 +#define GR_AUDITS (GR_AUDIT_READ | GR_AUDIT_WRITE | GR_AUDIT_APPEND | GR_AUDIT_EXEC | \
68069 + GR_AUDIT_FIND | GR_AUDIT_INHERIT | GR_AUDIT_SETID | \
68070 + GR_AUDIT_CREATE | GR_AUDIT_DELETE | GR_AUDIT_LINK)
68071 +
68072 +/* ACL subject-only mode flags */
68073 +enum {
68074 + GR_KILL = 0x00000001,
68075 + GR_VIEW = 0x00000002,
68076 + GR_PROTECTED = 0x00000004,
68077 + GR_LEARN = 0x00000008,
68078 + GR_OVERRIDE = 0x00000010,
68079 + /* just a placeholder, this mode is only used in userspace */
68080 + GR_DUMMY = 0x00000020,
68081 + GR_PROTSHM = 0x00000040,
68082 + GR_KILLPROC = 0x00000080,
68083 + GR_KILLIPPROC = 0x00000100,
68084 + /* just a placeholder, this mode is only used in userspace */
68085 + GR_NOTROJAN = 0x00000200,
68086 + GR_PROTPROCFD = 0x00000400,
68087 + GR_PROCACCT = 0x00000800,
68088 + GR_RELAXPTRACE = 0x00001000,
68089 + //GR_NESTED = 0x00002000,
68090 + GR_INHERITLEARN = 0x00004000,
68091 + GR_PROCFIND = 0x00008000,
68092 + GR_POVERRIDE = 0x00010000,
68093 + GR_KERNELAUTH = 0x00020000,
68094 + GR_ATSECURE = 0x00040000,
68095 + GR_SHMEXEC = 0x00080000
68096 +};
68097 +
68098 +enum {
68099 + GR_PAX_ENABLE_SEGMEXEC = 0x0001,
68100 + GR_PAX_ENABLE_PAGEEXEC = 0x0002,
68101 + GR_PAX_ENABLE_MPROTECT = 0x0004,
68102 + GR_PAX_ENABLE_RANDMMAP = 0x0008,
68103 + GR_PAX_ENABLE_EMUTRAMP = 0x0010,
68104 + GR_PAX_DISABLE_SEGMEXEC = 0x0100,
68105 + GR_PAX_DISABLE_PAGEEXEC = 0x0200,
68106 + GR_PAX_DISABLE_MPROTECT = 0x0400,
68107 + GR_PAX_DISABLE_RANDMMAP = 0x0800,
68108 + GR_PAX_DISABLE_EMUTRAMP = 0x1000,
68109 +};
68110 +
68111 +enum {
68112 + GR_ID_USER = 0x01,
68113 + GR_ID_GROUP = 0x02,
68114 +};
68115 +
68116 +enum {
68117 + GR_ID_ALLOW = 0x01,
68118 + GR_ID_DENY = 0x02,
68119 +};
68120 +
68121 +#define GR_CRASH_RES 31
68122 +#define GR_UIDTABLE_MAX 500
68123 +
68124 +/* begin resource learning section */
68125 +enum {
68126 + GR_RLIM_CPU_BUMP = 60,
68127 + GR_RLIM_FSIZE_BUMP = 50000,
68128 + GR_RLIM_DATA_BUMP = 10000,
68129 + GR_RLIM_STACK_BUMP = 1000,
68130 + GR_RLIM_CORE_BUMP = 10000,
68131 + GR_RLIM_RSS_BUMP = 500000,
68132 + GR_RLIM_NPROC_BUMP = 1,
68133 + GR_RLIM_NOFILE_BUMP = 5,
68134 + GR_RLIM_MEMLOCK_BUMP = 50000,
68135 + GR_RLIM_AS_BUMP = 500000,
68136 + GR_RLIM_LOCKS_BUMP = 2,
68137 + GR_RLIM_SIGPENDING_BUMP = 5,
68138 + GR_RLIM_MSGQUEUE_BUMP = 10000,
68139 + GR_RLIM_NICE_BUMP = 1,
68140 + GR_RLIM_RTPRIO_BUMP = 1,
68141 + GR_RLIM_RTTIME_BUMP = 1000000
68142 +};
68143 +
68144 +#endif
68145 diff --git a/include/linux/grinternal.h b/include/linux/grinternal.h
68146 new file mode 100644
68147 index 0000000..9bb6662
68148 --- /dev/null
68149 +++ b/include/linux/grinternal.h
68150 @@ -0,0 +1,215 @@
68151 +#ifndef __GRINTERNAL_H
68152 +#define __GRINTERNAL_H
68153 +
68154 +#ifdef CONFIG_GRKERNSEC
68155 +
68156 +#include <linux/fs.h>
68157 +#include <linux/mnt_namespace.h>
68158 +#include <linux/nsproxy.h>
68159 +#include <linux/gracl.h>
68160 +#include <linux/grdefs.h>
68161 +#include <linux/grmsg.h>
68162 +
68163 +void gr_add_learn_entry(const char *fmt, ...)
68164 + __attribute__ ((format (printf, 1, 2)));
68165 +__u32 gr_search_file(const struct dentry *dentry, const __u32 mode,
68166 + const struct vfsmount *mnt);
68167 +__u32 gr_check_create(const struct dentry *new_dentry,
68168 + const struct dentry *parent,
68169 + const struct vfsmount *mnt, const __u32 mode);
68170 +int gr_check_protected_task(const struct task_struct *task);
68171 +__u32 to_gr_audit(const __u32 reqmode);
68172 +int gr_set_acls(const int type);
68173 +int gr_apply_subject_to_task(struct task_struct *task);
68174 +int gr_acl_is_enabled(void);
68175 +char gr_roletype_to_char(void);
68176 +
68177 +void gr_handle_alertkill(struct task_struct *task);
68178 +char *gr_to_filename(const struct dentry *dentry,
68179 + const struct vfsmount *mnt);
68180 +char *gr_to_filename1(const struct dentry *dentry,
68181 + const struct vfsmount *mnt);
68182 +char *gr_to_filename2(const struct dentry *dentry,
68183 + const struct vfsmount *mnt);
68184 +char *gr_to_filename3(const struct dentry *dentry,
68185 + const struct vfsmount *mnt);
68186 +
68187 +extern int grsec_enable_ptrace_readexec;
68188 +extern int grsec_enable_harden_ptrace;
68189 +extern int grsec_enable_link;
68190 +extern int grsec_enable_fifo;
68191 +extern int grsec_enable_execve;
68192 +extern int grsec_enable_shm;
68193 +extern int grsec_enable_execlog;
68194 +extern int grsec_enable_signal;
68195 +extern int grsec_enable_audit_ptrace;
68196 +extern int grsec_enable_forkfail;
68197 +extern int grsec_enable_time;
68198 +extern int grsec_enable_rofs;
68199 +extern int grsec_enable_chroot_shmat;
68200 +extern int grsec_enable_chroot_mount;
68201 +extern int grsec_enable_chroot_double;
68202 +extern int grsec_enable_chroot_pivot;
68203 +extern int grsec_enable_chroot_chdir;
68204 +extern int grsec_enable_chroot_chmod;
68205 +extern int grsec_enable_chroot_mknod;
68206 +extern int grsec_enable_chroot_fchdir;
68207 +extern int grsec_enable_chroot_nice;
68208 +extern int grsec_enable_chroot_execlog;
68209 +extern int grsec_enable_chroot_caps;
68210 +extern int grsec_enable_chroot_sysctl;
68211 +extern int grsec_enable_chroot_unix;
68212 +extern int grsec_enable_symlinkown;
68213 +extern kgid_t grsec_symlinkown_gid;
68214 +extern int grsec_enable_tpe;
68215 +extern kgid_t grsec_tpe_gid;
68216 +extern int grsec_enable_tpe_all;
68217 +extern int grsec_enable_tpe_invert;
68218 +extern int grsec_enable_socket_all;
68219 +extern kgid_t grsec_socket_all_gid;
68220 +extern int grsec_enable_socket_client;
68221 +extern kgid_t grsec_socket_client_gid;
68222 +extern int grsec_enable_socket_server;
68223 +extern kgid_t grsec_socket_server_gid;
68224 +extern kgid_t grsec_audit_gid;
68225 +extern int grsec_enable_group;
68226 +extern int grsec_enable_audit_textrel;
68227 +extern int grsec_enable_log_rwxmaps;
68228 +extern int grsec_enable_mount;
68229 +extern int grsec_enable_chdir;
68230 +extern int grsec_resource_logging;
68231 +extern int grsec_enable_blackhole;
68232 +extern int grsec_lastack_retries;
68233 +extern int grsec_enable_brute;
68234 +extern int grsec_lock;
68235 +
68236 +extern spinlock_t grsec_alert_lock;
68237 +extern unsigned long grsec_alert_wtime;
68238 +extern unsigned long grsec_alert_fyet;
68239 +
68240 +extern spinlock_t grsec_audit_lock;
68241 +
68242 +extern rwlock_t grsec_exec_file_lock;
68243 +
68244 +#define gr_task_fullpath(tsk) ((tsk)->exec_file ? \
68245 + gr_to_filename2((tsk)->exec_file->f_path.dentry, \
68246 + (tsk)->exec_file->f_vfsmnt) : "/")
68247 +
68248 +#define gr_parent_task_fullpath(tsk) ((tsk)->real_parent->exec_file ? \
68249 + gr_to_filename3((tsk)->real_parent->exec_file->f_path.dentry, \
68250 + (tsk)->real_parent->exec_file->f_vfsmnt) : "/")
68251 +
68252 +#define gr_task_fullpath0(tsk) ((tsk)->exec_file ? \
68253 + gr_to_filename((tsk)->exec_file->f_path.dentry, \
68254 + (tsk)->exec_file->f_vfsmnt) : "/")
68255 +
68256 +#define gr_parent_task_fullpath0(tsk) ((tsk)->real_parent->exec_file ? \
68257 + gr_to_filename1((tsk)->real_parent->exec_file->f_path.dentry, \
68258 + (tsk)->real_parent->exec_file->f_vfsmnt) : "/")
68259 +
68260 +#define proc_is_chrooted(tsk_a) ((tsk_a)->gr_is_chrooted)
68261 +
68262 +#define have_same_root(tsk_a,tsk_b) ((tsk_a)->gr_chroot_dentry == (tsk_b)->gr_chroot_dentry)
68263 +
68264 +#define GR_CHROOT_CAPS {{ \
68265 + CAP_TO_MASK(CAP_LINUX_IMMUTABLE) | CAP_TO_MASK(CAP_NET_ADMIN) | \
68266 + CAP_TO_MASK(CAP_SYS_MODULE) | CAP_TO_MASK(CAP_SYS_RAWIO) | \
68267 + CAP_TO_MASK(CAP_SYS_PACCT) | CAP_TO_MASK(CAP_SYS_ADMIN) | \
68268 + CAP_TO_MASK(CAP_SYS_BOOT) | CAP_TO_MASK(CAP_SYS_TIME) | \
68269 + CAP_TO_MASK(CAP_NET_RAW) | CAP_TO_MASK(CAP_SYS_TTY_CONFIG) | \
68270 + CAP_TO_MASK(CAP_IPC_OWNER) | CAP_TO_MASK(CAP_SETFCAP), \
68271 + CAP_TO_MASK(CAP_SYSLOG) | CAP_TO_MASK(CAP_MAC_ADMIN) }}
68272 +
68273 +#define security_learn(normal_msg,args...) \
68274 +({ \
68275 + read_lock(&grsec_exec_file_lock); \
68276 + gr_add_learn_entry(normal_msg "\n", ## args); \
68277 + read_unlock(&grsec_exec_file_lock); \
68278 +})
68279 +
68280 +enum {
68281 + GR_DO_AUDIT,
68282 + GR_DONT_AUDIT,
68283 + /* used for non-audit messages that we shouldn't kill the task on */
68284 + GR_DONT_AUDIT_GOOD
68285 +};
68286 +
68287 +enum {
68288 + GR_TTYSNIFF,
68289 + GR_RBAC,
68290 + GR_RBAC_STR,
68291 + GR_STR_RBAC,
68292 + GR_RBAC_MODE2,
68293 + GR_RBAC_MODE3,
68294 + GR_FILENAME,
68295 + GR_SYSCTL_HIDDEN,
68296 + GR_NOARGS,
68297 + GR_ONE_INT,
68298 + GR_ONE_INT_TWO_STR,
68299 + GR_ONE_STR,
68300 + GR_STR_INT,
68301 + GR_TWO_STR_INT,
68302 + GR_TWO_INT,
68303 + GR_TWO_U64,
68304 + GR_THREE_INT,
68305 + GR_FIVE_INT_TWO_STR,
68306 + GR_TWO_STR,
68307 + GR_THREE_STR,
68308 + GR_FOUR_STR,
68309 + GR_STR_FILENAME,
68310 + GR_FILENAME_STR,
68311 + GR_FILENAME_TWO_INT,
68312 + GR_FILENAME_TWO_INT_STR,
68313 + GR_TEXTREL,
68314 + GR_PTRACE,
68315 + GR_RESOURCE,
68316 + GR_CAP,
68317 + GR_SIG,
68318 + GR_SIG2,
68319 + GR_CRASH1,
68320 + GR_CRASH2,
68321 + GR_PSACCT,
68322 + GR_RWXMAP
68323 +};
68324 +
68325 +#define gr_log_hidden_sysctl(audit, msg, str) gr_log_varargs(audit, msg, GR_SYSCTL_HIDDEN, str)
68326 +#define gr_log_ttysniff(audit, msg, task) gr_log_varargs(audit, msg, GR_TTYSNIFF, task)
68327 +#define gr_log_fs_rbac_generic(audit, msg, dentry, mnt) gr_log_varargs(audit, msg, GR_RBAC, dentry, mnt)
68328 +#define gr_log_fs_rbac_str(audit, msg, dentry, mnt, str) gr_log_varargs(audit, msg, GR_RBAC_STR, dentry, mnt, str)
68329 +#define gr_log_fs_str_rbac(audit, msg, str, dentry, mnt) gr_log_varargs(audit, msg, GR_STR_RBAC, str, dentry, mnt)
68330 +#define gr_log_fs_rbac_mode2(audit, msg, dentry, mnt, str1, str2) gr_log_varargs(audit, msg, GR_RBAC_MODE2, dentry, mnt, str1, str2)
68331 +#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)
68332 +#define gr_log_fs_generic(audit, msg, dentry, mnt) gr_log_varargs(audit, msg, GR_FILENAME, dentry, mnt)
68333 +#define gr_log_noargs(audit, msg) gr_log_varargs(audit, msg, GR_NOARGS)
68334 +#define gr_log_int(audit, msg, num) gr_log_varargs(audit, msg, GR_ONE_INT, num)
68335 +#define gr_log_int_str2(audit, msg, num, str1, str2) gr_log_varargs(audit, msg, GR_ONE_INT_TWO_STR, num, str1, str2)
68336 +#define gr_log_str(audit, msg, str) gr_log_varargs(audit, msg, GR_ONE_STR, str)
68337 +#define gr_log_str_int(audit, msg, str, num) gr_log_varargs(audit, msg, GR_STR_INT, str, num)
68338 +#define gr_log_int_int(audit, msg, num1, num2) gr_log_varargs(audit, msg, GR_TWO_INT, num1, num2)
68339 +#define gr_log_two_u64(audit, msg, num1, num2) gr_log_varargs(audit, msg, GR_TWO_U64, num1, num2)
68340 +#define gr_log_int3(audit, msg, num1, num2, num3) gr_log_varargs(audit, msg, GR_THREE_INT, num1, num2, num3)
68341 +#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)
68342 +#define gr_log_str_str(audit, msg, str1, str2) gr_log_varargs(audit, msg, GR_TWO_STR, str1, str2)
68343 +#define gr_log_str2_int(audit, msg, str1, str2, num) gr_log_varargs(audit, msg, GR_TWO_STR_INT, str1, str2, num)
68344 +#define gr_log_str3(audit, msg, str1, str2, str3) gr_log_varargs(audit, msg, GR_THREE_STR, str1, str2, str3)
68345 +#define gr_log_str4(audit, msg, str1, str2, str3, str4) gr_log_varargs(audit, msg, GR_FOUR_STR, str1, str2, str3, str4)
68346 +#define gr_log_str_fs(audit, msg, str, dentry, mnt) gr_log_varargs(audit, msg, GR_STR_FILENAME, str, dentry, mnt)
68347 +#define gr_log_fs_str(audit, msg, dentry, mnt, str) gr_log_varargs(audit, msg, GR_FILENAME_STR, dentry, mnt, str)
68348 +#define gr_log_fs_int2(audit, msg, dentry, mnt, num1, num2) gr_log_varargs(audit, msg, GR_FILENAME_TWO_INT, dentry, mnt, num1, num2)
68349 +#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)
68350 +#define gr_log_textrel_ulong_ulong(audit, msg, file, ulong1, ulong2) gr_log_varargs(audit, msg, GR_TEXTREL, file, ulong1, ulong2)
68351 +#define gr_log_ptrace(audit, msg, task) gr_log_varargs(audit, msg, GR_PTRACE, task)
68352 +#define gr_log_res_ulong2_str(audit, msg, task, ulong1, str, ulong2) gr_log_varargs(audit, msg, GR_RESOURCE, task, ulong1, str, ulong2)
68353 +#define gr_log_cap(audit, msg, task, str) gr_log_varargs(audit, msg, GR_CAP, task, str)
68354 +#define gr_log_sig_addr(audit, msg, str, addr) gr_log_varargs(audit, msg, GR_SIG, str, addr)
68355 +#define gr_log_sig_task(audit, msg, task, num) gr_log_varargs(audit, msg, GR_SIG2, task, num)
68356 +#define gr_log_crash1(audit, msg, task, ulong) gr_log_varargs(audit, msg, GR_CRASH1, task, ulong)
68357 +#define gr_log_crash2(audit, msg, task, ulong1) gr_log_varargs(audit, msg, GR_CRASH2, task, ulong1)
68358 +#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)
68359 +#define gr_log_rwxmap(audit, msg, str) gr_log_varargs(audit, msg, GR_RWXMAP, str)
68360 +
68361 +void gr_log_varargs(int audit, const char *msg, int argtypes, ...);
68362 +
68363 +#endif
68364 +
68365 +#endif
68366 diff --git a/include/linux/grmsg.h b/include/linux/grmsg.h
68367 new file mode 100644
68368 index 0000000..2bd4c8d
68369 --- /dev/null
68370 +++ b/include/linux/grmsg.h
68371 @@ -0,0 +1,111 @@
68372 +#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"
68373 +#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"
68374 +#define GR_PTRACE_ACL_MSG "denied ptrace of %.950s(%.16s:%d) by "
68375 +#define GR_STOPMOD_MSG "denied modification of module state by "
68376 +#define GR_ROFS_BLOCKWRITE_MSG "denied write to block device %.950s by "
68377 +#define GR_ROFS_MOUNT_MSG "denied writable mount of %.950s by "
68378 +#define GR_IOPERM_MSG "denied use of ioperm() by "
68379 +#define GR_IOPL_MSG "denied use of iopl() by "
68380 +#define GR_SHMAT_ACL_MSG "denied attach of shared memory of UID %u, PID %d, ID %u by "
68381 +#define GR_UNIX_CHROOT_MSG "denied connect() to abstract AF_UNIX socket outside of chroot by "
68382 +#define GR_SHMAT_CHROOT_MSG "denied attach of shared memory outside of chroot by "
68383 +#define GR_MEM_READWRITE_MSG "denied access of range %Lx -> %Lx in /dev/mem by "
68384 +#define GR_SYMLINK_MSG "not following symlink %.950s owned by %d.%d by "
68385 +#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"
68386 +#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"
68387 +#define GR_HIDDEN_ACL_MSG "%s access to hidden file %.950s by "
68388 +#define GR_OPEN_ACL_MSG "%s open of %.950s for%s%s by "
68389 +#define GR_CREATE_ACL_MSG "%s create of %.950s for%s%s by "
68390 +#define GR_FIFO_MSG "denied writing FIFO %.950s of %d.%d by "
68391 +#define GR_MKNOD_CHROOT_MSG "denied mknod of %.950s from chroot by "
68392 +#define GR_MKNOD_ACL_MSG "%s mknod of %.950s by "
68393 +#define GR_UNIXCONNECT_ACL_MSG "%s connect() to the unix domain socket %.950s by "
68394 +#define GR_TTYSNIFF_ACL_MSG "terminal being sniffed by IP:%pI4 %.480s[%.16s:%d], parent %.480s[%.16s:%d] against "
68395 +#define GR_MKDIR_ACL_MSG "%s mkdir of %.950s by "
68396 +#define GR_RMDIR_ACL_MSG "%s rmdir of %.950s by "
68397 +#define GR_UNLINK_ACL_MSG "%s unlink of %.950s by "
68398 +#define GR_SYMLINK_ACL_MSG "%s symlink from %.480s to %.480s by "
68399 +#define GR_HARDLINK_MSG "denied hardlink of %.930s (owned by %d.%d) to %.30s for "
68400 +#define GR_LINK_ACL_MSG "%s link of %.480s to %.480s by "
68401 +#define GR_INHERIT_ACL_MSG "successful inherit of %.480s's ACL for %.480s by "
68402 +#define GR_RENAME_ACL_MSG "%s rename of %.480s to %.480s by "
68403 +#define GR_UNSAFESHARE_EXEC_ACL_MSG "denied exec with cloned fs of %.950s by "
68404 +#define GR_PTRACE_EXEC_ACL_MSG "denied ptrace of %.950s by "
68405 +#define GR_EXEC_ACL_MSG "%s execution of %.950s by "
68406 +#define GR_EXEC_TPE_MSG "denied untrusted exec (due to %.70s) of %.950s by "
68407 +#define GR_SEGVSTART_ACL_MSG "possible exploit bruteforcing on " DEFAULTSECMSG " banning uid %u from login for %lu seconds"
68408 +#define GR_SEGVNOSUID_ACL_MSG "possible exploit bruteforcing on " DEFAULTSECMSG " banning execution for %lu seconds"
68409 +#define GR_MOUNT_CHROOT_MSG "denied mount of %.256s as %.930s from chroot by "
68410 +#define GR_PIVOT_CHROOT_MSG "denied pivot_root from chroot by "
68411 +#define GR_TRUNCATE_ACL_MSG "%s truncate of %.950s by "
68412 +#define GR_ATIME_ACL_MSG "%s access time change of %.950s by "
68413 +#define GR_ACCESS_ACL_MSG "%s access of %.950s for%s%s%s by "
68414 +#define GR_CHROOT_CHROOT_MSG "denied double chroot to %.950s by "
68415 +#define GR_CHMOD_CHROOT_MSG "denied chmod +s of %.950s by "
68416 +#define GR_CHMOD_ACL_MSG "%s chmod of %.950s by "
68417 +#define GR_CHROOT_FCHDIR_MSG "denied fchdir outside of chroot to %.950s by "
68418 +#define GR_CHOWN_ACL_MSG "%s chown of %.950s by "
68419 +#define GR_SETXATTR_ACL_MSG "%s setting extended attributes of %.950s by "
68420 +#define GR_WRITLIB_ACL_MSG "denied load of writable library %.950s by "
68421 +#define GR_INITF_ACL_MSG "init_variables() failed %s by "
68422 +#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"
68423 +#define GR_DEV_ACL_MSG "/dev/grsec: %d bytes sent %d required, being fed garbage by "
68424 +#define GR_SHUTS_ACL_MSG "shutdown auth success for "
68425 +#define GR_SHUTF_ACL_MSG "shutdown auth failure for "
68426 +#define GR_SHUTI_ACL_MSG "ignoring shutdown for disabled RBAC system for "
68427 +#define GR_SEGVMODS_ACL_MSG "segvmod auth success for "
68428 +#define GR_SEGVMODF_ACL_MSG "segvmod auth failure for "
68429 +#define GR_SEGVMODI_ACL_MSG "ignoring segvmod for disabled RBAC system for "
68430 +#define GR_ENABLE_ACL_MSG "%s RBAC system loaded by "
68431 +#define GR_ENABLEF_ACL_MSG "unable to load %s for "
68432 +#define GR_RELOADI_ACL_MSG "ignoring reload request for disabled RBAC system"
68433 +#define GR_RELOAD_ACL_MSG "%s RBAC system reloaded by "
68434 +#define GR_RELOADF_ACL_MSG "failed reload of %s for "
68435 +#define GR_SPROLEI_ACL_MSG "ignoring change to special role for disabled RBAC system for "
68436 +#define GR_SPROLES_ACL_MSG "successful change to special role %s (id %d) by "
68437 +#define GR_SPROLEL_ACL_MSG "special role %s (id %d) exited by "
68438 +#define GR_SPROLEF_ACL_MSG "special role %s failure for "
68439 +#define GR_UNSPROLEI_ACL_MSG "ignoring unauth of special role for disabled RBAC system for "
68440 +#define GR_UNSPROLES_ACL_MSG "successful unauth of special role %s (id %d) by "
68441 +#define GR_INVMODE_ACL_MSG "invalid mode %d by "
68442 +#define GR_PRIORITY_CHROOT_MSG "denied priority change of process (%.16s:%d) by "
68443 +#define GR_FAILFORK_MSG "failed fork with errno %s by "
68444 +#define GR_NICE_CHROOT_MSG "denied priority change by "
68445 +#define GR_UNISIGLOG_MSG "%.32s occurred at %p in "
68446 +#define GR_DUALSIGLOG_MSG "signal %d sent to " DEFAULTSECMSG " by "
68447 +#define GR_SIG_ACL_MSG "denied send of signal %d to protected task " DEFAULTSECMSG " by "
68448 +#define GR_SYSCTL_MSG "denied modification of grsecurity sysctl value : %.32s by "
68449 +#define GR_SYSCTL_ACL_MSG "%s sysctl of %.950s for%s%s by "
68450 +#define GR_TIME_MSG "time set by "
68451 +#define GR_DEFACL_MSG "fatal: unable to find subject for (%.16s:%d), loaded by "
68452 +#define GR_MMAP_ACL_MSG "%s executable mmap of %.950s by "
68453 +#define GR_MPROTECT_ACL_MSG "%s executable mprotect of %.950s by "
68454 +#define GR_SOCK_MSG "denied socket(%.16s,%.16s,%.16s) by "
68455 +#define GR_SOCK_NOINET_MSG "denied socket(%.16s,%.16s,%d) by "
68456 +#define GR_BIND_MSG "denied bind() by "
68457 +#define GR_CONNECT_MSG "denied connect() by "
68458 +#define GR_BIND_ACL_MSG "denied bind() to %pI4 port %u sock type %.16s protocol %.16s by "
68459 +#define GR_CONNECT_ACL_MSG "denied connect() to %pI4 port %u sock type %.16s protocol %.16s by "
68460 +#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"
68461 +#define GR_EXEC_CHROOT_MSG "exec of %.980s within chroot by process "
68462 +#define GR_CAP_ACL_MSG "use of %s denied for "
68463 +#define GR_CAP_CHROOT_MSG "use of %s in chroot denied for "
68464 +#define GR_CAP_ACL_MSG2 "use of %s permitted for "
68465 +#define GR_USRCHANGE_ACL_MSG "change to uid %u denied for "
68466 +#define GR_GRPCHANGE_ACL_MSG "change to gid %u denied for "
68467 +#define GR_REMOUNT_AUDIT_MSG "remount of %.256s by "
68468 +#define GR_UNMOUNT_AUDIT_MSG "unmount of %.256s by "
68469 +#define GR_MOUNT_AUDIT_MSG "mount of %.256s to %.256s by "
68470 +#define GR_CHDIR_AUDIT_MSG "chdir to %.980s by "
68471 +#define GR_EXEC_AUDIT_MSG "exec of %.930s (%.128s) by "
68472 +#define GR_RESOURCE_MSG "denied resource overstep by requesting %lu for %.16s against limit %lu for "
68473 +#define GR_RWXMMAP_MSG "denied RWX mmap of %.950s by "
68474 +#define GR_RWXMPROTECT_MSG "denied RWX mprotect of %.950s by "
68475 +#define GR_TEXTREL_AUDIT_MSG "text relocation in %s, VMA:0x%08lx 0x%08lx by "
68476 +#define GR_VM86_MSG "denied use of vm86 by "
68477 +#define GR_PTRACE_AUDIT_MSG "process %.950s(%.16s:%d) attached to via ptrace by "
68478 +#define GR_PTRACE_READEXEC_MSG "denied ptrace of unreadable binary %.950s by "
68479 +#define GR_INIT_TRANSFER_MSG "persistent special role transferred privilege to init by "
68480 +#define GR_BADPROCPID_MSG "denied read of sensitive /proc/pid/%s entry via fd passed across exec by "
68481 +#define GR_SYMLINKOWNER_MSG "denied following symlink %.950s since symlink owner %u does not match target owner %u, by "
68482 +#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 "
68483 diff --git a/include/linux/grsecurity.h b/include/linux/grsecurity.h
68484 new file mode 100644
68485 index 0000000..8da63a4
68486 --- /dev/null
68487 +++ b/include/linux/grsecurity.h
68488 @@ -0,0 +1,242 @@
68489 +#ifndef GR_SECURITY_H
68490 +#define GR_SECURITY_H
68491 +#include <linux/fs.h>
68492 +#include <linux/fs_struct.h>
68493 +#include <linux/binfmts.h>
68494 +#include <linux/gracl.h>
68495 +
68496 +/* notify of brain-dead configs */
68497 +#if defined(CONFIG_GRKERNSEC_PROC_USER) && defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
68498 +#error "CONFIG_GRKERNSEC_PROC_USER and CONFIG_GRKERNSEC_PROC_USERGROUP cannot both be enabled."
68499 +#endif
68500 +#if defined(CONFIG_PAX_NOEXEC) && !defined(CONFIG_PAX_PAGEEXEC) && !defined(CONFIG_PAX_SEGMEXEC) && !defined(CONFIG_PAX_KERNEXEC)
68501 +#error "CONFIG_PAX_NOEXEC enabled, but PAGEEXEC, SEGMEXEC, and KERNEXEC are disabled."
68502 +#endif
68503 +#if defined(CONFIG_PAX_ASLR) && !defined(CONFIG_PAX_RANDKSTACK) && !defined(CONFIG_PAX_RANDUSTACK) && !defined(CONFIG_PAX_RANDMMAP)
68504 +#error "CONFIG_PAX_ASLR enabled, but RANDKSTACK, RANDUSTACK, and RANDMMAP are disabled."
68505 +#endif
68506 +#if defined(CONFIG_PAX) && !defined(CONFIG_PAX_NOEXEC) && !defined(CONFIG_PAX_ASLR)
68507 +#error "CONFIG_PAX enabled, but no PaX options are enabled."
68508 +#endif
68509 +
68510 +void gr_handle_brute_attach(unsigned long mm_flags);
68511 +void gr_handle_brute_check(void);
68512 +void gr_handle_kernel_exploit(void);
68513 +int gr_process_user_ban(void);
68514 +
68515 +char gr_roletype_to_char(void);
68516 +
68517 +int gr_acl_enable_at_secure(void);
68518 +
68519 +int gr_check_user_change(kuid_t real, kuid_t effective, kuid_t fs);
68520 +int gr_check_group_change(kgid_t real, kgid_t effective, kgid_t fs);
68521 +
68522 +void gr_del_task_from_ip_table(struct task_struct *p);
68523 +
68524 +int gr_pid_is_chrooted(struct task_struct *p);
68525 +int gr_handle_chroot_fowner(struct pid *pid, enum pid_type type);
68526 +int gr_handle_chroot_nice(void);
68527 +int gr_handle_chroot_sysctl(const int op);
68528 +int gr_handle_chroot_setpriority(struct task_struct *p,
68529 + const int niceval);
68530 +int gr_chroot_fchdir(struct dentry *u_dentry, struct vfsmount *u_mnt);
68531 +int gr_handle_chroot_chroot(const struct dentry *dentry,
68532 + const struct vfsmount *mnt);
68533 +void gr_handle_chroot_chdir(struct path *path);
68534 +int gr_handle_chroot_chmod(const struct dentry *dentry,
68535 + const struct vfsmount *mnt, const int mode);
68536 +int gr_handle_chroot_mknod(const struct dentry *dentry,
68537 + const struct vfsmount *mnt, const int mode);
68538 +int gr_handle_chroot_mount(const struct dentry *dentry,
68539 + const struct vfsmount *mnt,
68540 + const char *dev_name);
68541 +int gr_handle_chroot_pivot(void);
68542 +int gr_handle_chroot_unix(const pid_t pid);
68543 +
68544 +int gr_handle_rawio(const struct inode *inode);
68545 +
68546 +void gr_handle_ioperm(void);
68547 +void gr_handle_iopl(void);
68548 +
68549 +umode_t gr_acl_umask(void);
68550 +
68551 +int gr_tpe_allow(const struct file *file);
68552 +
68553 +void gr_set_chroot_entries(struct task_struct *task, struct path *path);
68554 +void gr_clear_chroot_entries(struct task_struct *task);
68555 +
68556 +void gr_log_forkfail(const int retval);
68557 +void gr_log_timechange(void);
68558 +void gr_log_signal(const int sig, const void *addr, const struct task_struct *t);
68559 +void gr_log_chdir(const struct dentry *dentry,
68560 + const struct vfsmount *mnt);
68561 +void gr_log_chroot_exec(const struct dentry *dentry,
68562 + const struct vfsmount *mnt);
68563 +void gr_log_remount(const char *devname, const int retval);
68564 +void gr_log_unmount(const char *devname, const int retval);
68565 +void gr_log_mount(const char *from, const char *to, const int retval);
68566 +void gr_log_textrel(struct vm_area_struct *vma);
68567 +void gr_log_rwxmmap(struct file *file);
68568 +void gr_log_rwxmprotect(struct file *file);
68569 +
68570 +int gr_handle_follow_link(const struct inode *parent,
68571 + const struct inode *inode,
68572 + const struct dentry *dentry,
68573 + const struct vfsmount *mnt);
68574 +int gr_handle_fifo(const struct dentry *dentry,
68575 + const struct vfsmount *mnt,
68576 + const struct dentry *dir, const int flag,
68577 + const int acc_mode);
68578 +int gr_handle_hardlink(const struct dentry *dentry,
68579 + const struct vfsmount *mnt,
68580 + struct inode *inode,
68581 + const int mode, const struct filename *to);
68582 +
68583 +int gr_is_capable(const int cap);
68584 +int gr_is_capable_nolog(const int cap);
68585 +int gr_task_is_capable(const struct task_struct *task, const struct cred *cred, const int cap);
68586 +int gr_task_is_capable_nolog(const struct task_struct *task, const int cap);
68587 +
68588 +void gr_copy_label(struct task_struct *tsk);
68589 +void gr_handle_crash(struct task_struct *task, const int sig);
68590 +int gr_handle_signal(const struct task_struct *p, const int sig);
68591 +int gr_check_crash_uid(const kuid_t uid);
68592 +int gr_check_protected_task(const struct task_struct *task);
68593 +int gr_check_protected_task_fowner(struct pid *pid, enum pid_type type);
68594 +int gr_acl_handle_mmap(const struct file *file,
68595 + const unsigned long prot);
68596 +int gr_acl_handle_mprotect(const struct file *file,
68597 + const unsigned long prot);
68598 +int gr_check_hidden_task(const struct task_struct *tsk);
68599 +__u32 gr_acl_handle_truncate(const struct dentry *dentry,
68600 + const struct vfsmount *mnt);
68601 +__u32 gr_acl_handle_utime(const struct dentry *dentry,
68602 + const struct vfsmount *mnt);
68603 +__u32 gr_acl_handle_access(const struct dentry *dentry,
68604 + const struct vfsmount *mnt, const int fmode);
68605 +__u32 gr_acl_handle_chmod(const struct dentry *dentry,
68606 + const struct vfsmount *mnt, umode_t *mode);
68607 +__u32 gr_acl_handle_chown(const struct dentry *dentry,
68608 + const struct vfsmount *mnt);
68609 +__u32 gr_acl_handle_setxattr(const struct dentry *dentry,
68610 + const struct vfsmount *mnt);
68611 +int gr_handle_ptrace(struct task_struct *task, const long request);
68612 +int gr_handle_proc_ptrace(struct task_struct *task);
68613 +__u32 gr_acl_handle_execve(const struct dentry *dentry,
68614 + const struct vfsmount *mnt);
68615 +int gr_check_crash_exec(const struct file *filp);
68616 +int gr_acl_is_enabled(void);
68617 +void gr_set_kernel_label(struct task_struct *task);
68618 +void gr_set_role_label(struct task_struct *task, const kuid_t uid,
68619 + const kgid_t gid);
68620 +int gr_set_proc_label(const struct dentry *dentry,
68621 + const struct vfsmount *mnt,
68622 + const int unsafe_flags);
68623 +__u32 gr_acl_handle_hidden_file(const struct dentry *dentry,
68624 + const struct vfsmount *mnt);
68625 +__u32 gr_acl_handle_open(const struct dentry *dentry,
68626 + const struct vfsmount *mnt, int acc_mode);
68627 +__u32 gr_acl_handle_creat(const struct dentry *dentry,
68628 + const struct dentry *p_dentry,
68629 + const struct vfsmount *p_mnt,
68630 + int open_flags, int acc_mode, const int imode);
68631 +void gr_handle_create(const struct dentry *dentry,
68632 + const struct vfsmount *mnt);
68633 +void gr_handle_proc_create(const struct dentry *dentry,
68634 + const struct inode *inode);
68635 +__u32 gr_acl_handle_mknod(const struct dentry *new_dentry,
68636 + const struct dentry *parent_dentry,
68637 + const struct vfsmount *parent_mnt,
68638 + const int mode);
68639 +__u32 gr_acl_handle_mkdir(const struct dentry *new_dentry,
68640 + const struct dentry *parent_dentry,
68641 + const struct vfsmount *parent_mnt);
68642 +__u32 gr_acl_handle_rmdir(const struct dentry *dentry,
68643 + const struct vfsmount *mnt);
68644 +void gr_handle_delete(const ino_t ino, const dev_t dev);
68645 +__u32 gr_acl_handle_unlink(const struct dentry *dentry,
68646 + const struct vfsmount *mnt);
68647 +__u32 gr_acl_handle_symlink(const struct dentry *new_dentry,
68648 + const struct dentry *parent_dentry,
68649 + const struct vfsmount *parent_mnt,
68650 + const struct filename *from);
68651 +__u32 gr_acl_handle_link(const struct dentry *new_dentry,
68652 + const struct dentry *parent_dentry,
68653 + const struct vfsmount *parent_mnt,
68654 + const struct dentry *old_dentry,
68655 + const struct vfsmount *old_mnt, const struct filename *to);
68656 +int gr_handle_symlink_owner(const struct path *link, const struct inode *target);
68657 +int gr_acl_handle_rename(struct dentry *new_dentry,
68658 + struct dentry *parent_dentry,
68659 + const struct vfsmount *parent_mnt,
68660 + struct dentry *old_dentry,
68661 + struct inode *old_parent_inode,
68662 + struct vfsmount *old_mnt, const struct filename *newname);
68663 +void gr_handle_rename(struct inode *old_dir, struct inode *new_dir,
68664 + struct dentry *old_dentry,
68665 + struct dentry *new_dentry,
68666 + struct vfsmount *mnt, const __u8 replace);
68667 +__u32 gr_check_link(const struct dentry *new_dentry,
68668 + const struct dentry *parent_dentry,
68669 + const struct vfsmount *parent_mnt,
68670 + const struct dentry *old_dentry,
68671 + const struct vfsmount *old_mnt);
68672 +int gr_acl_handle_filldir(const struct file *file, const char *name,
68673 + const unsigned int namelen, const ino_t ino);
68674 +
68675 +__u32 gr_acl_handle_unix(const struct dentry *dentry,
68676 + const struct vfsmount *mnt);
68677 +void gr_acl_handle_exit(void);
68678 +void gr_acl_handle_psacct(struct task_struct *task, const long code);
68679 +int gr_acl_handle_procpidmem(const struct task_struct *task);
68680 +int gr_handle_rofs_mount(struct dentry *dentry, struct vfsmount *mnt, int mnt_flags);
68681 +int gr_handle_rofs_blockwrite(struct dentry *dentry, struct vfsmount *mnt, int acc_mode);
68682 +void gr_audit_ptrace(struct task_struct *task);
68683 +dev_t gr_get_dev_from_dentry(struct dentry *dentry);
68684 +void gr_put_exec_file(struct task_struct *task);
68685 +
68686 +int gr_ptrace_readexec(struct file *file, int unsafe_flags);
68687 +
68688 +#if defined(CONFIG_GRKERNSEC) && (defined(CONFIG_GRKERNSEC_RESLOG) || !defined(CONFIG_GRKERNSEC_NO_RBAC))
68689 +extern void gr_learn_resource(const struct task_struct *task, const int res,
68690 + const unsigned long wanted, const int gt);
68691 +#else
68692 +static inline void gr_learn_resource(const struct task_struct *task, const int res,
68693 + const unsigned long wanted, const int gt)
68694 +{
68695 +}
68696 +#endif
68697 +
68698 +#ifdef CONFIG_GRKERNSEC_RESLOG
68699 +extern void gr_log_resource(const struct task_struct *task, const int res,
68700 + const unsigned long wanted, const int gt);
68701 +#else
68702 +static inline void gr_log_resource(const struct task_struct *task, const int res,
68703 + const unsigned long wanted, const int gt)
68704 +{
68705 +}
68706 +#endif
68707 +
68708 +#ifdef CONFIG_GRKERNSEC
68709 +void task_grsec_rbac(struct seq_file *m, struct task_struct *p);
68710 +void gr_handle_vm86(void);
68711 +void gr_handle_mem_readwrite(u64 from, u64 to);
68712 +
68713 +void gr_log_badprocpid(const char *entry);
68714 +
68715 +extern int grsec_enable_dmesg;
68716 +extern int grsec_disable_privio;
68717 +
68718 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
68719 +extern kgid_t grsec_proc_gid;
68720 +#endif
68721 +
68722 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
68723 +extern int grsec_enable_chroot_findtask;
68724 +#endif
68725 +#ifdef CONFIG_GRKERNSEC_SETXID
68726 +extern int grsec_enable_setxid;
68727 +#endif
68728 +#endif
68729 +
68730 +#endif
68731 diff --git a/include/linux/grsock.h b/include/linux/grsock.h
68732 new file mode 100644
68733 index 0000000..e7ffaaf
68734 --- /dev/null
68735 +++ b/include/linux/grsock.h
68736 @@ -0,0 +1,19 @@
68737 +#ifndef __GRSOCK_H
68738 +#define __GRSOCK_H
68739 +
68740 +extern void gr_attach_curr_ip(const struct sock *sk);
68741 +extern int gr_handle_sock_all(const int family, const int type,
68742 + const int protocol);
68743 +extern int gr_handle_sock_server(const struct sockaddr *sck);
68744 +extern int gr_handle_sock_server_other(const struct sock *sck);
68745 +extern int gr_handle_sock_client(const struct sockaddr *sck);
68746 +extern int gr_search_connect(struct socket * sock,
68747 + struct sockaddr_in * addr);
68748 +extern int gr_search_bind(struct socket * sock,
68749 + struct sockaddr_in * addr);
68750 +extern int gr_search_listen(struct socket * sock);
68751 +extern int gr_search_accept(struct socket * sock);
68752 +extern int gr_search_socket(const int domain, const int type,
68753 + const int protocol);
68754 +
68755 +#endif
68756 diff --git a/include/linux/highmem.h b/include/linux/highmem.h
68757 index ef788b5..ac41b7b 100644
68758 --- a/include/linux/highmem.h
68759 +++ b/include/linux/highmem.h
68760 @@ -189,6 +189,18 @@ static inline void clear_highpage(struct page *page)
68761 kunmap_atomic(kaddr);
68762 }
68763
68764 +static inline void sanitize_highpage(struct page *page)
68765 +{
68766 + void *kaddr;
68767 + unsigned long flags;
68768 +
68769 + local_irq_save(flags);
68770 + kaddr = kmap_atomic(page);
68771 + clear_page(kaddr);
68772 + kunmap_atomic(kaddr);
68773 + local_irq_restore(flags);
68774 +}
68775 +
68776 static inline void zero_user_segments(struct page *page,
68777 unsigned start1, unsigned end1,
68778 unsigned start2, unsigned end2)
68779 diff --git a/include/linux/hwmon-sysfs.h b/include/linux/hwmon-sysfs.h
68780 index 1c7b89a..7f52502 100644
68781 --- a/include/linux/hwmon-sysfs.h
68782 +++ b/include/linux/hwmon-sysfs.h
68783 @@ -25,7 +25,8 @@
68784 struct sensor_device_attribute{
68785 struct device_attribute dev_attr;
68786 int index;
68787 -};
68788 +} __do_const;
68789 +typedef struct sensor_device_attribute __no_const sensor_device_attribute_no_const;
68790 #define to_sensor_dev_attr(_dev_attr) \
68791 container_of(_dev_attr, struct sensor_device_attribute, dev_attr)
68792
68793 @@ -41,7 +42,7 @@ struct sensor_device_attribute_2 {
68794 struct device_attribute dev_attr;
68795 u8 index;
68796 u8 nr;
68797 -};
68798 +} __do_const;
68799 #define to_sensor_dev_attr_2(_dev_attr) \
68800 container_of(_dev_attr, struct sensor_device_attribute_2, dev_attr)
68801
68802 diff --git a/include/linux/i2c.h b/include/linux/i2c.h
68803 index d0c4db7..61b3577 100644
68804 --- a/include/linux/i2c.h
68805 +++ b/include/linux/i2c.h
68806 @@ -369,6 +369,7 @@ struct i2c_algorithm {
68807 /* To determine what the adapter supports */
68808 u32 (*functionality) (struct i2c_adapter *);
68809 };
68810 +typedef struct i2c_algorithm __no_const i2c_algorithm_no_const;
68811
68812 /*
68813 * i2c_adapter is the structure used to identify a physical i2c bus along
68814 diff --git a/include/linux/i2o.h b/include/linux/i2o.h
68815 index d23c3c2..eb63c81 100644
68816 --- a/include/linux/i2o.h
68817 +++ b/include/linux/i2o.h
68818 @@ -565,7 +565,7 @@ struct i2o_controller {
68819 struct i2o_device *exec; /* Executive */
68820 #if BITS_PER_LONG == 64
68821 spinlock_t context_list_lock; /* lock for context_list */
68822 - atomic_t context_list_counter; /* needed for unique contexts */
68823 + atomic_unchecked_t context_list_counter; /* needed for unique contexts */
68824 struct list_head context_list; /* list of context id's
68825 and pointers */
68826 #endif
68827 diff --git a/include/linux/if_pppox.h b/include/linux/if_pppox.h
68828 index aff7ad8..3942bbd 100644
68829 --- a/include/linux/if_pppox.h
68830 +++ b/include/linux/if_pppox.h
68831 @@ -76,7 +76,7 @@ struct pppox_proto {
68832 int (*ioctl)(struct socket *sock, unsigned int cmd,
68833 unsigned long arg);
68834 struct module *owner;
68835 -};
68836 +} __do_const;
68837
68838 extern int register_pppox_proto(int proto_num, const struct pppox_proto *pp);
68839 extern void unregister_pppox_proto(int proto_num);
68840 diff --git a/include/linux/init.h b/include/linux/init.h
68841 index 10ed4f4..8e8490d 100644
68842 --- a/include/linux/init.h
68843 +++ b/include/linux/init.h
68844 @@ -39,9 +39,36 @@
68845 * Also note, that this data cannot be "const".
68846 */
68847
68848 +#ifdef MODULE
68849 +#define add_init_latent_entropy
68850 +#define add_devinit_latent_entropy
68851 +#define add_cpuinit_latent_entropy
68852 +#define add_meminit_latent_entropy
68853 +#else
68854 +#define add_init_latent_entropy __latent_entropy
68855 +
68856 +#ifdef CONFIG_HOTPLUG
68857 +#define add_devinit_latent_entropy
68858 +#else
68859 +#define add_devinit_latent_entropy __latent_entropy
68860 +#endif
68861 +
68862 +#ifdef CONFIG_HOTPLUG_CPU
68863 +#define add_cpuinit_latent_entropy
68864 +#else
68865 +#define add_cpuinit_latent_entropy __latent_entropy
68866 +#endif
68867 +
68868 +#ifdef CONFIG_MEMORY_HOTPLUG
68869 +#define add_meminit_latent_entropy
68870 +#else
68871 +#define add_meminit_latent_entropy __latent_entropy
68872 +#endif
68873 +#endif
68874 +
68875 /* These are for everybody (although not all archs will actually
68876 discard it in modules) */
68877 -#define __init __section(.init.text) __cold notrace
68878 +#define __init __section(.init.text) __cold notrace add_init_latent_entropy
68879 #define __initdata __section(.init.data)
68880 #define __initconst __constsection(.init.rodata)
68881 #define __exitdata __section(.exit.data)
68882 @@ -94,7 +121,7 @@
68883 #define __exit __section(.exit.text) __exitused __cold notrace
68884
68885 /* Used for HOTPLUG_CPU */
68886 -#define __cpuinit __section(.cpuinit.text) __cold notrace
68887 +#define __cpuinit __section(.cpuinit.text) __cold notrace add_cpuinit_latent_entropy
68888 #define __cpuinitdata __section(.cpuinit.data)
68889 #define __cpuinitconst __constsection(.cpuinit.rodata)
68890 #define __cpuexit __section(.cpuexit.text) __exitused __cold notrace
68891 @@ -102,7 +129,7 @@
68892 #define __cpuexitconst __constsection(.cpuexit.rodata)
68893
68894 /* Used for MEMORY_HOTPLUG */
68895 -#define __meminit __section(.meminit.text) __cold notrace
68896 +#define __meminit __section(.meminit.text) __cold notrace add_meminit_latent_entropy
68897 #define __meminitdata __section(.meminit.data)
68898 #define __meminitconst __constsection(.meminit.rodata)
68899 #define __memexit __section(.memexit.text) __exitused __cold notrace
68900 diff --git a/include/linux/init_task.h b/include/linux/init_task.h
68901 index 6d087c5..401cab8 100644
68902 --- a/include/linux/init_task.h
68903 +++ b/include/linux/init_task.h
68904 @@ -143,6 +143,12 @@ extern struct task_group root_task_group;
68905
68906 #define INIT_TASK_COMM "swapper"
68907
68908 +#ifdef CONFIG_X86
68909 +#define INIT_TASK_THREAD_INFO .tinfo = INIT_THREAD_INFO,
68910 +#else
68911 +#define INIT_TASK_THREAD_INFO
68912 +#endif
68913 +
68914 /*
68915 * INIT_TASK is used to set up the first task table, touch at
68916 * your own risk!. Base=0, limit=0x1fffff (=2MB)
68917 @@ -182,6 +188,7 @@ extern struct task_group root_task_group;
68918 RCU_POINTER_INITIALIZER(cred, &init_cred), \
68919 .comm = INIT_TASK_COMM, \
68920 .thread = INIT_THREAD, \
68921 + INIT_TASK_THREAD_INFO \
68922 .fs = &init_fs, \
68923 .files = &init_files, \
68924 .signal = &init_signals, \
68925 diff --git a/include/linux/interrupt.h b/include/linux/interrupt.h
68926 index 5fa5afe..ac55b25 100644
68927 --- a/include/linux/interrupt.h
68928 +++ b/include/linux/interrupt.h
68929 @@ -430,7 +430,7 @@ enum
68930 /* map softirq index to softirq name. update 'softirq_to_name' in
68931 * kernel/softirq.c when adding a new softirq.
68932 */
68933 -extern char *softirq_to_name[NR_SOFTIRQS];
68934 +extern const char * const softirq_to_name[NR_SOFTIRQS];
68935
68936 /* softirq mask and active fields moved to irq_cpustat_t in
68937 * asm/hardirq.h to get better cache usage. KAO
68938 @@ -438,12 +438,12 @@ extern char *softirq_to_name[NR_SOFTIRQS];
68939
68940 struct softirq_action
68941 {
68942 - void (*action)(struct softirq_action *);
68943 -};
68944 + void (*action)(void);
68945 +} __no_const;
68946
68947 asmlinkage void do_softirq(void);
68948 asmlinkage void __do_softirq(void);
68949 -extern void open_softirq(int nr, void (*action)(struct softirq_action *));
68950 +extern void open_softirq(int nr, void (*action)(void));
68951 extern void softirq_init(void);
68952 extern void __raise_softirq_irqoff(unsigned int nr);
68953
68954 diff --git a/include/linux/iommu.h b/include/linux/iommu.h
68955 index f3b99e1..9b73cee 100644
68956 --- a/include/linux/iommu.h
68957 +++ b/include/linux/iommu.h
68958 @@ -101,7 +101,7 @@ struct iommu_ops {
68959 int (*domain_set_attr)(struct iommu_domain *domain,
68960 enum iommu_attr attr, void *data);
68961 unsigned long pgsize_bitmap;
68962 -};
68963 +} __do_const;
68964
68965 #define IOMMU_GROUP_NOTIFY_ADD_DEVICE 1 /* Device added */
68966 #define IOMMU_GROUP_NOTIFY_DEL_DEVICE 2 /* Pre Device removed */
68967 diff --git a/include/linux/irq.h b/include/linux/irq.h
68968 index fdf2c4a..5332486 100644
68969 --- a/include/linux/irq.h
68970 +++ b/include/linux/irq.h
68971 @@ -328,7 +328,8 @@ struct irq_chip {
68972 void (*irq_print_chip)(struct irq_data *data, struct seq_file *p);
68973
68974 unsigned long flags;
68975 -};
68976 +} __do_const;
68977 +typedef struct irq_chip __no_const irq_chip_no_const;
68978
68979 /*
68980 * irq_chip specific flags
68981 diff --git a/include/linux/kallsyms.h b/include/linux/kallsyms.h
68982 index 6883e19..06992b1 100644
68983 --- a/include/linux/kallsyms.h
68984 +++ b/include/linux/kallsyms.h
68985 @@ -15,7 +15,8 @@
68986
68987 struct module;
68988
68989 -#ifdef CONFIG_KALLSYMS
68990 +#if !defined(__INCLUDED_BY_HIDESYM) || !defined(CONFIG_KALLSYMS)
68991 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
68992 /* Lookup the address for a symbol. Returns 0 if not found. */
68993 unsigned long kallsyms_lookup_name(const char *name);
68994
68995 @@ -106,6 +107,17 @@ static inline int lookup_symbol_attrs(unsigned long addr, unsigned long *size, u
68996 /* Stupid that this does nothing, but I didn't create this mess. */
68997 #define __print_symbol(fmt, addr)
68998 #endif /*CONFIG_KALLSYMS*/
68999 +#else /* when included by kallsyms.c, vsnprintf.c, or
69000 + arch/x86/kernel/dumpstack.c, with HIDESYM enabled */
69001 +extern void __print_symbol(const char *fmt, unsigned long address);
69002 +extern int sprint_backtrace(char *buffer, unsigned long address);
69003 +extern int sprint_symbol(char *buffer, unsigned long address);
69004 +extern int sprint_symbol_no_offset(char *buffer, unsigned long address);
69005 +const char *kallsyms_lookup(unsigned long addr,
69006 + unsigned long *symbolsize,
69007 + unsigned long *offset,
69008 + char **modname, char *namebuf);
69009 +#endif
69010
69011 /* This macro allows us to keep printk typechecking */
69012 static __printf(1, 2)
69013 diff --git a/include/linux/key-type.h b/include/linux/key-type.h
69014 index 518a53a..5e28358 100644
69015 --- a/include/linux/key-type.h
69016 +++ b/include/linux/key-type.h
69017 @@ -125,7 +125,7 @@ struct key_type {
69018 /* internal fields */
69019 struct list_head link; /* link in types list */
69020 struct lock_class_key lock_class; /* key->sem lock class */
69021 -};
69022 +} __do_const;
69023
69024 extern struct key_type key_type_keyring;
69025
69026 diff --git a/include/linux/kgdb.h b/include/linux/kgdb.h
69027 index 4dff0c6..1ca9b72 100644
69028 --- a/include/linux/kgdb.h
69029 +++ b/include/linux/kgdb.h
69030 @@ -53,7 +53,7 @@ extern int kgdb_connected;
69031 extern int kgdb_io_module_registered;
69032
69033 extern atomic_t kgdb_setting_breakpoint;
69034 -extern atomic_t kgdb_cpu_doing_single_step;
69035 +extern atomic_unchecked_t kgdb_cpu_doing_single_step;
69036
69037 extern struct task_struct *kgdb_usethread;
69038 extern struct task_struct *kgdb_contthread;
69039 @@ -255,7 +255,7 @@ struct kgdb_arch {
69040 void (*correct_hw_break)(void);
69041
69042 void (*enable_nmi)(bool on);
69043 -};
69044 +} __do_const;
69045
69046 /**
69047 * struct kgdb_io - Describe the interface for an I/O driver to talk with KGDB.
69048 @@ -280,7 +280,7 @@ struct kgdb_io {
69049 void (*pre_exception) (void);
69050 void (*post_exception) (void);
69051 int is_console;
69052 -};
69053 +} __do_const;
69054
69055 extern struct kgdb_arch arch_kgdb_ops;
69056
69057 diff --git a/include/linux/kmod.h b/include/linux/kmod.h
69058 index 5398d58..5883a34 100644
69059 --- a/include/linux/kmod.h
69060 +++ b/include/linux/kmod.h
69061 @@ -34,6 +34,8 @@ extern char modprobe_path[]; /* for sysctl */
69062 * usually useless though. */
69063 extern __printf(2, 3)
69064 int __request_module(bool wait, const char *name, ...);
69065 +extern __printf(3, 4)
69066 +int ___request_module(bool wait, char *param_name, const char *name, ...);
69067 #define request_module(mod...) __request_module(true, mod)
69068 #define request_module_nowait(mod...) __request_module(false, mod)
69069 #define try_then_request_module(x, mod...) \
69070 diff --git a/include/linux/kobject.h b/include/linux/kobject.h
69071 index 939b112..ed6ed51 100644
69072 --- a/include/linux/kobject.h
69073 +++ b/include/linux/kobject.h
69074 @@ -111,7 +111,7 @@ struct kobj_type {
69075 struct attribute **default_attrs;
69076 const struct kobj_ns_type_operations *(*child_ns_type)(struct kobject *kobj);
69077 const void *(*namespace)(struct kobject *kobj);
69078 -};
69079 +} __do_const;
69080
69081 struct kobj_uevent_env {
69082 char *envp[UEVENT_NUM_ENVP];
69083 @@ -134,6 +134,7 @@ struct kobj_attribute {
69084 ssize_t (*store)(struct kobject *kobj, struct kobj_attribute *attr,
69085 const char *buf, size_t count);
69086 };
69087 +typedef struct kobj_attribute __no_const kobj_attribute_no_const;
69088
69089 extern const struct sysfs_ops kobj_sysfs_ops;
69090
69091 diff --git a/include/linux/kobject_ns.h b/include/linux/kobject_ns.h
69092 index f66b065..c2c29b4 100644
69093 --- a/include/linux/kobject_ns.h
69094 +++ b/include/linux/kobject_ns.h
69095 @@ -43,7 +43,7 @@ struct kobj_ns_type_operations {
69096 const void *(*netlink_ns)(struct sock *sk);
69097 const void *(*initial_ns)(void);
69098 void (*drop_ns)(void *);
69099 -};
69100 +} __do_const;
69101
69102 int kobj_ns_type_register(const struct kobj_ns_type_operations *ops);
69103 int kobj_ns_type_registered(enum kobj_ns_type type);
69104 diff --git a/include/linux/kref.h b/include/linux/kref.h
69105 index 4972e6e..de4d19b 100644
69106 --- a/include/linux/kref.h
69107 +++ b/include/linux/kref.h
69108 @@ -64,7 +64,7 @@ static inline void kref_get(struct kref *kref)
69109 static inline int kref_sub(struct kref *kref, unsigned int count,
69110 void (*release)(struct kref *kref))
69111 {
69112 - WARN_ON(release == NULL);
69113 + BUG_ON(release == NULL);
69114
69115 if (atomic_sub_and_test((int) count, &kref->refcount)) {
69116 release(kref);
69117 diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
69118 index 2c497ab..afe32f5 100644
69119 --- a/include/linux/kvm_host.h
69120 +++ b/include/linux/kvm_host.h
69121 @@ -418,7 +418,7 @@ void kvm_vcpu_uninit(struct kvm_vcpu *vcpu);
69122 int __must_check vcpu_load(struct kvm_vcpu *vcpu);
69123 void vcpu_put(struct kvm_vcpu *vcpu);
69124
69125 -int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
69126 +int kvm_init(const void *opaque, unsigned vcpu_size, unsigned vcpu_align,
69127 struct module *module);
69128 void kvm_exit(void);
69129
69130 @@ -574,7 +574,7 @@ int kvm_arch_vcpu_ioctl_set_guest_debug(struct kvm_vcpu *vcpu,
69131 struct kvm_guest_debug *dbg);
69132 int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run);
69133
69134 -int kvm_arch_init(void *opaque);
69135 +int kvm_arch_init(const void *opaque);
69136 void kvm_arch_exit(void);
69137
69138 int kvm_arch_vcpu_init(struct kvm_vcpu *vcpu);
69139 diff --git a/include/linux/libata.h b/include/linux/libata.h
69140 index 649e5f8..ead5194 100644
69141 --- a/include/linux/libata.h
69142 +++ b/include/linux/libata.h
69143 @@ -915,7 +915,7 @@ struct ata_port_operations {
69144 * fields must be pointers.
69145 */
69146 const struct ata_port_operations *inherits;
69147 -};
69148 +} __do_const;
69149
69150 struct ata_port_info {
69151 unsigned long flags;
69152 diff --git a/include/linux/list.h b/include/linux/list.h
69153 index cc6d2aa..c10ee83 100644
69154 --- a/include/linux/list.h
69155 +++ b/include/linux/list.h
69156 @@ -112,6 +112,19 @@ extern void __list_del_entry(struct list_head *entry);
69157 extern void list_del(struct list_head *entry);
69158 #endif
69159
69160 +extern void __pax_list_add(struct list_head *new,
69161 + struct list_head *prev,
69162 + struct list_head *next);
69163 +static inline void pax_list_add(struct list_head *new, struct list_head *head)
69164 +{
69165 + __pax_list_add(new, head, head->next);
69166 +}
69167 +static inline void pax_list_add_tail(struct list_head *new, struct list_head *head)
69168 +{
69169 + __pax_list_add(new, head->prev, head);
69170 +}
69171 +extern void pax_list_del(struct list_head *entry);
69172 +
69173 /**
69174 * list_replace - replace old entry by new one
69175 * @old : the element to be replaced
69176 @@ -145,6 +158,8 @@ static inline void list_del_init(struct list_head *entry)
69177 INIT_LIST_HEAD(entry);
69178 }
69179
69180 +extern void pax_list_del_init(struct list_head *entry);
69181 +
69182 /**
69183 * list_move - delete from one list and add as another's head
69184 * @list: the entry to move
69185 diff --git a/include/linux/math64.h b/include/linux/math64.h
69186 index b8ba855..0148090 100644
69187 --- a/include/linux/math64.h
69188 +++ b/include/linux/math64.h
69189 @@ -14,7 +14,7 @@
69190 * This is commonly provided by 32bit archs to provide an optimized 64bit
69191 * divide.
69192 */
69193 -static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
69194 +static inline u64 __intentional_overflow(-1) div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
69195 {
69196 *remainder = dividend % divisor;
69197 return dividend / divisor;
69198 @@ -50,7 +50,7 @@ static inline s64 div64_s64(s64 dividend, s64 divisor)
69199 #define div64_long(x,y) div_s64((x),(y))
69200
69201 #ifndef div_u64_rem
69202 -static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
69203 +static inline u64 __intentional_overflow(-1) div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
69204 {
69205 *remainder = do_div(dividend, divisor);
69206 return dividend;
69207 @@ -79,7 +79,7 @@ extern s64 div64_s64(s64 dividend, s64 divisor);
69208 * divide.
69209 */
69210 #ifndef div_u64
69211 -static inline u64 div_u64(u64 dividend, u32 divisor)
69212 +static inline u64 __intentional_overflow(-1) div_u64(u64 dividend, u32 divisor)
69213 {
69214 u32 remainder;
69215 return div_u64_rem(dividend, divisor, &remainder);
69216 diff --git a/include/linux/mm.h b/include/linux/mm.h
69217 index 66e2f7c..ea88001 100644
69218 --- a/include/linux/mm.h
69219 +++ b/include/linux/mm.h
69220 @@ -101,6 +101,11 @@ extern unsigned int kobjsize(const void *objp);
69221 #define VM_HUGETLB 0x00400000 /* Huge TLB Page VM */
69222 #define VM_NONLINEAR 0x00800000 /* Is non-linear (remap_file_pages) */
69223 #define VM_ARCH_1 0x01000000 /* Architecture-specific flag */
69224 +
69225 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
69226 +#define VM_PAGEEXEC 0x02000000 /* vma->vm_page_prot needs special handling */
69227 +#endif
69228 +
69229 #define VM_DONTDUMP 0x04000000 /* Do not include in the core dump */
69230
69231 #define VM_MIXEDMAP 0x10000000 /* Can contain "struct page" and pure PFN pages */
69232 @@ -231,6 +236,7 @@ struct vm_operations_struct {
69233 int (*remap_pages)(struct vm_area_struct *vma, unsigned long addr,
69234 unsigned long size, pgoff_t pgoff);
69235 };
69236 +typedef struct vm_operations_struct __no_const vm_operations_struct_no_const;
69237
69238 struct mmu_gather;
69239 struct inode;
69240 @@ -1068,34 +1074,6 @@ int set_page_dirty(struct page *page);
69241 int set_page_dirty_lock(struct page *page);
69242 int clear_page_dirty_for_io(struct page *page);
69243
69244 -/* Is the vma a continuation of the stack vma above it? */
69245 -static inline int vma_growsdown(struct vm_area_struct *vma, unsigned long addr)
69246 -{
69247 - return vma && (vma->vm_end == addr) && (vma->vm_flags & VM_GROWSDOWN);
69248 -}
69249 -
69250 -static inline int stack_guard_page_start(struct vm_area_struct *vma,
69251 - unsigned long addr)
69252 -{
69253 - return (vma->vm_flags & VM_GROWSDOWN) &&
69254 - (vma->vm_start == addr) &&
69255 - !vma_growsdown(vma->vm_prev, addr);
69256 -}
69257 -
69258 -/* Is the vma a continuation of the stack vma below it? */
69259 -static inline int vma_growsup(struct vm_area_struct *vma, unsigned long addr)
69260 -{
69261 - return vma && (vma->vm_start == addr) && (vma->vm_flags & VM_GROWSUP);
69262 -}
69263 -
69264 -static inline int stack_guard_page_end(struct vm_area_struct *vma,
69265 - unsigned long addr)
69266 -{
69267 - return (vma->vm_flags & VM_GROWSUP) &&
69268 - (vma->vm_end == addr) &&
69269 - !vma_growsup(vma->vm_next, addr);
69270 -}
69271 -
69272 extern pid_t
69273 vm_is_stack(struct task_struct *task, struct vm_area_struct *vma, int in_group);
69274
69275 @@ -1198,6 +1176,15 @@ static inline void sync_mm_rss(struct mm_struct *mm)
69276 }
69277 #endif
69278
69279 +#ifdef CONFIG_MMU
69280 +pgprot_t vm_get_page_prot(vm_flags_t vm_flags);
69281 +#else
69282 +static inline pgprot_t vm_get_page_prot(vm_flags_t vm_flags)
69283 +{
69284 + return __pgprot(0);
69285 +}
69286 +#endif
69287 +
69288 int vma_wants_writenotify(struct vm_area_struct *vma);
69289
69290 extern pte_t *__get_locked_pte(struct mm_struct *mm, unsigned long addr,
69291 @@ -1216,8 +1203,15 @@ static inline int __pud_alloc(struct mm_struct *mm, pgd_t *pgd,
69292 {
69293 return 0;
69294 }
69295 +
69296 +static inline int __pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd,
69297 + unsigned long address)
69298 +{
69299 + return 0;
69300 +}
69301 #else
69302 int __pud_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long address);
69303 +int __pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd, unsigned long address);
69304 #endif
69305
69306 #ifdef __PAGETABLE_PMD_FOLDED
69307 @@ -1226,8 +1220,15 @@ static inline int __pmd_alloc(struct mm_struct *mm, pud_t *pud,
69308 {
69309 return 0;
69310 }
69311 +
69312 +static inline int __pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud,
69313 + unsigned long address)
69314 +{
69315 + return 0;
69316 +}
69317 #else
69318 int __pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address);
69319 +int __pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud, unsigned long address);
69320 #endif
69321
69322 int __pte_alloc(struct mm_struct *mm, struct vm_area_struct *vma,
69323 @@ -1245,11 +1246,23 @@ static inline pud_t *pud_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long a
69324 NULL: pud_offset(pgd, address);
69325 }
69326
69327 +static inline pud_t *pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd, unsigned long address)
69328 +{
69329 + return (unlikely(pgd_none(*pgd)) && __pud_alloc_kernel(mm, pgd, address))?
69330 + NULL: pud_offset(pgd, address);
69331 +}
69332 +
69333 static inline pmd_t *pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address)
69334 {
69335 return (unlikely(pud_none(*pud)) && __pmd_alloc(mm, pud, address))?
69336 NULL: pmd_offset(pud, address);
69337 }
69338 +
69339 +static inline pmd_t *pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud, unsigned long address)
69340 +{
69341 + return (unlikely(pud_none(*pud)) && __pmd_alloc_kernel(mm, pud, address))?
69342 + NULL: pmd_offset(pud, address);
69343 +}
69344 #endif /* CONFIG_MMU && !__ARCH_HAS_4LEVEL_HACK */
69345
69346 #if USE_SPLIT_PTLOCKS
69347 @@ -1479,6 +1492,7 @@ extern unsigned long do_mmap_pgoff(struct file *, unsigned long,
69348 unsigned long, unsigned long,
69349 unsigned long, unsigned long);
69350 extern int do_munmap(struct mm_struct *, unsigned long, size_t);
69351 +extern int __do_munmap(struct mm_struct *, unsigned long, size_t);
69352
69353 /* These take the mm semaphore themselves */
69354 extern unsigned long vm_brk(unsigned long, unsigned long);
69355 @@ -1573,6 +1587,10 @@ extern struct vm_area_struct * find_vma(struct mm_struct * mm, unsigned long add
69356 extern struct vm_area_struct * find_vma_prev(struct mm_struct * mm, unsigned long addr,
69357 struct vm_area_struct **pprev);
69358
69359 +extern struct vm_area_struct *pax_find_mirror_vma(struct vm_area_struct *vma);
69360 +extern __must_check long pax_mirror_vma(struct vm_area_struct *vma_m, struct vm_area_struct *vma);
69361 +extern void pax_mirror_file_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m, spinlock_t *ptl);
69362 +
69363 /* Look up the first VMA which intersects the interval start_addr..end_addr-1,
69364 NULL if none. Assume start_addr < end_addr. */
69365 static inline struct vm_area_struct * find_vma_intersection(struct mm_struct * mm, unsigned long start_addr, unsigned long end_addr)
69366 @@ -1601,15 +1619,6 @@ static inline struct vm_area_struct *find_exact_vma(struct mm_struct *mm,
69367 return vma;
69368 }
69369
69370 -#ifdef CONFIG_MMU
69371 -pgprot_t vm_get_page_prot(unsigned long vm_flags);
69372 -#else
69373 -static inline pgprot_t vm_get_page_prot(unsigned long vm_flags)
69374 -{
69375 - return __pgprot(0);
69376 -}
69377 -#endif
69378 -
69379 #ifdef CONFIG_ARCH_USES_NUMA_PROT_NONE
69380 unsigned long change_prot_numa(struct vm_area_struct *vma,
69381 unsigned long start, unsigned long end);
69382 @@ -1721,7 +1730,7 @@ extern int unpoison_memory(unsigned long pfn);
69383 extern int sysctl_memory_failure_early_kill;
69384 extern int sysctl_memory_failure_recovery;
69385 extern void shake_page(struct page *p, int access);
69386 -extern atomic_long_t mce_bad_pages;
69387 +extern atomic_long_unchecked_t mce_bad_pages;
69388 extern int soft_offline_page(struct page *page, int flags);
69389
69390 extern void dump_page(struct page *page);
69391 @@ -1752,5 +1761,11 @@ static inline unsigned int debug_guardpage_minorder(void) { return 0; }
69392 static inline bool page_is_guard(struct page *page) { return false; }
69393 #endif /* CONFIG_DEBUG_PAGEALLOC */
69394
69395 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
69396 +extern void track_exec_limit(struct mm_struct *mm, unsigned long start, unsigned long end, unsigned long prot);
69397 +#else
69398 +static inline void track_exec_limit(struct mm_struct *mm, unsigned long start, unsigned long end, unsigned long prot) {}
69399 +#endif
69400 +
69401 #endif /* __KERNEL__ */
69402 #endif /* _LINUX_MM_H */
69403 diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h
69404 index f8f5162..a039af9 100644
69405 --- a/include/linux/mm_types.h
69406 +++ b/include/linux/mm_types.h
69407 @@ -288,6 +288,8 @@ struct vm_area_struct {
69408 #ifdef CONFIG_NUMA
69409 struct mempolicy *vm_policy; /* NUMA policy for the VMA */
69410 #endif
69411 +
69412 + struct vm_area_struct *vm_mirror;/* PaX: mirror vma or NULL */
69413 };
69414
69415 struct core_thread {
69416 @@ -362,7 +364,7 @@ struct mm_struct {
69417 unsigned long def_flags;
69418 unsigned long nr_ptes; /* Page table pages */
69419 unsigned long start_code, end_code, start_data, end_data;
69420 - unsigned long start_brk, brk, start_stack;
69421 + unsigned long aslr_gap, start_brk, brk, start_stack;
69422 unsigned long arg_start, arg_end, env_start, env_end;
69423
69424 unsigned long saved_auxv[AT_VECTOR_SIZE]; /* for /proc/PID/auxv */
69425 @@ -436,6 +438,24 @@ struct mm_struct {
69426 int first_nid;
69427 #endif
69428 struct uprobes_state uprobes_state;
69429 +
69430 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
69431 + unsigned long pax_flags;
69432 +#endif
69433 +
69434 +#ifdef CONFIG_PAX_DLRESOLVE
69435 + unsigned long call_dl_resolve;
69436 +#endif
69437 +
69438 +#if defined(CONFIG_PPC32) && defined(CONFIG_PAX_EMUSIGRT)
69439 + unsigned long call_syscall;
69440 +#endif
69441 +
69442 +#ifdef CONFIG_PAX_ASLR
69443 + unsigned long delta_mmap; /* randomized offset */
69444 + unsigned long delta_stack; /* randomized offset */
69445 +#endif
69446 +
69447 };
69448
69449 /* first nid will either be a valid NID or one of these values */
69450 diff --git a/include/linux/mmiotrace.h b/include/linux/mmiotrace.h
69451 index c5d5278..f0b68c8 100644
69452 --- a/include/linux/mmiotrace.h
69453 +++ b/include/linux/mmiotrace.h
69454 @@ -46,7 +46,7 @@ extern int kmmio_handler(struct pt_regs *regs, unsigned long addr);
69455 /* Called from ioremap.c */
69456 extern void mmiotrace_ioremap(resource_size_t offset, unsigned long size,
69457 void __iomem *addr);
69458 -extern void mmiotrace_iounmap(volatile void __iomem *addr);
69459 +extern void mmiotrace_iounmap(const volatile void __iomem *addr);
69460
69461 /* For anyone to insert markers. Remember trailing newline. */
69462 extern __printf(1, 2) int mmiotrace_printk(const char *fmt, ...);
69463 @@ -66,7 +66,7 @@ static inline void mmiotrace_ioremap(resource_size_t offset,
69464 {
69465 }
69466
69467 -static inline void mmiotrace_iounmap(volatile void __iomem *addr)
69468 +static inline void mmiotrace_iounmap(const volatile void __iomem *addr)
69469 {
69470 }
69471
69472 diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
69473 index 73b64a3..6562925 100644
69474 --- a/include/linux/mmzone.h
69475 +++ b/include/linux/mmzone.h
69476 @@ -412,7 +412,7 @@ struct zone {
69477 unsigned long flags; /* zone flags, see below */
69478
69479 /* Zone statistics */
69480 - atomic_long_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
69481 + atomic_long_unchecked_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
69482
69483 /*
69484 * The target ratio of ACTIVE_ANON to INACTIVE_ANON pages on
69485 diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h
69486 index fed3def..c933f99 100644
69487 --- a/include/linux/mod_devicetable.h
69488 +++ b/include/linux/mod_devicetable.h
69489 @@ -12,7 +12,7 @@
69490 typedef unsigned long kernel_ulong_t;
69491 #endif
69492
69493 -#define PCI_ANY_ID (~0)
69494 +#define PCI_ANY_ID ((__u16)~0)
69495
69496 struct pci_device_id {
69497 __u32 vendor, device; /* Vendor and device ID or PCI_ANY_ID*/
69498 @@ -139,7 +139,7 @@ struct usb_device_id {
69499 #define USB_DEVICE_ID_MATCH_INT_PROTOCOL 0x0200
69500 #define USB_DEVICE_ID_MATCH_INT_NUMBER 0x0400
69501
69502 -#define HID_ANY_ID (~0)
69503 +#define HID_ANY_ID (~0U)
69504 #define HID_BUS_ANY 0xffff
69505 #define HID_GROUP_ANY 0x0000
69506
69507 @@ -498,7 +498,7 @@ struct dmi_system_id {
69508 const char *ident;
69509 struct dmi_strmatch matches[4];
69510 void *driver_data;
69511 -};
69512 +} __do_const;
69513 /*
69514 * struct dmi_device_id appears during expansion of
69515 * "MODULE_DEVICE_TABLE(dmi, x)". Compiler doesn't look inside it
69516 diff --git a/include/linux/module.h b/include/linux/module.h
69517 index 1375ee3..ced8177 100644
69518 --- a/include/linux/module.h
69519 +++ b/include/linux/module.h
69520 @@ -17,9 +17,11 @@
69521 #include <linux/moduleparam.h>
69522 #include <linux/tracepoint.h>
69523 #include <linux/export.h>
69524 +#include <linux/fs.h>
69525
69526 #include <linux/percpu.h>
69527 #include <asm/module.h>
69528 +#include <asm/pgtable.h>
69529
69530 /* In stripped ARM and x86-64 modules, ~ is surprisingly rare. */
69531 #define MODULE_SIG_STRING "~Module signature appended~\n"
69532 @@ -54,12 +56,13 @@ struct module_attribute {
69533 int (*test)(struct module *);
69534 void (*free)(struct module *);
69535 };
69536 +typedef struct module_attribute __no_const module_attribute_no_const;
69537
69538 struct module_version_attribute {
69539 struct module_attribute mattr;
69540 const char *module_name;
69541 const char *version;
69542 -} __attribute__ ((__aligned__(sizeof(void *))));
69543 +} __do_const __attribute__ ((__aligned__(sizeof(void *))));
69544
69545 extern ssize_t __modver_version_show(struct module_attribute *,
69546 struct module_kobject *, char *);
69547 @@ -232,7 +235,7 @@ struct module
69548
69549 /* Sysfs stuff. */
69550 struct module_kobject mkobj;
69551 - struct module_attribute *modinfo_attrs;
69552 + module_attribute_no_const *modinfo_attrs;
69553 const char *version;
69554 const char *srcversion;
69555 struct kobject *holders_dir;
69556 @@ -281,19 +284,16 @@ struct module
69557 int (*init)(void);
69558
69559 /* If this is non-NULL, vfree after init() returns */
69560 - void *module_init;
69561 + void *module_init_rx, *module_init_rw;
69562
69563 /* Here is the actual code + data, vfree'd on unload. */
69564 - void *module_core;
69565 + void *module_core_rx, *module_core_rw;
69566
69567 /* Here are the sizes of the init and core sections */
69568 - unsigned int init_size, core_size;
69569 + unsigned int init_size_rw, core_size_rw;
69570
69571 /* The size of the executable code in each section. */
69572 - unsigned int init_text_size, core_text_size;
69573 -
69574 - /* Size of RO sections of the module (text+rodata) */
69575 - unsigned int init_ro_size, core_ro_size;
69576 + unsigned int init_size_rx, core_size_rx;
69577
69578 /* Arch-specific module values */
69579 struct mod_arch_specific arch;
69580 @@ -349,6 +349,10 @@ struct module
69581 #ifdef CONFIG_EVENT_TRACING
69582 struct ftrace_event_call **trace_events;
69583 unsigned int num_trace_events;
69584 + struct file_operations trace_id;
69585 + struct file_operations trace_enable;
69586 + struct file_operations trace_format;
69587 + struct file_operations trace_filter;
69588 #endif
69589 #ifdef CONFIG_FTRACE_MCOUNT_RECORD
69590 unsigned int num_ftrace_callsites;
69591 @@ -396,16 +400,46 @@ bool is_module_address(unsigned long addr);
69592 bool is_module_percpu_address(unsigned long addr);
69593 bool is_module_text_address(unsigned long addr);
69594
69595 +static inline int within_module_range(unsigned long addr, void *start, unsigned long size)
69596 +{
69597 +
69598 +#ifdef CONFIG_PAX_KERNEXEC
69599 + if (ktla_ktva(addr) >= (unsigned long)start &&
69600 + ktla_ktva(addr) < (unsigned long)start + size)
69601 + return 1;
69602 +#endif
69603 +
69604 + return ((void *)addr >= start && (void *)addr < start + size);
69605 +}
69606 +
69607 +static inline int within_module_core_rx(unsigned long addr, struct module *mod)
69608 +{
69609 + return within_module_range(addr, mod->module_core_rx, mod->core_size_rx);
69610 +}
69611 +
69612 +static inline int within_module_core_rw(unsigned long addr, struct module *mod)
69613 +{
69614 + return within_module_range(addr, mod->module_core_rw, mod->core_size_rw);
69615 +}
69616 +
69617 +static inline int within_module_init_rx(unsigned long addr, struct module *mod)
69618 +{
69619 + return within_module_range(addr, mod->module_init_rx, mod->init_size_rx);
69620 +}
69621 +
69622 +static inline int within_module_init_rw(unsigned long addr, struct module *mod)
69623 +{
69624 + return within_module_range(addr, mod->module_init_rw, mod->init_size_rw);
69625 +}
69626 +
69627 static inline int within_module_core(unsigned long addr, struct module *mod)
69628 {
69629 - return (unsigned long)mod->module_core <= addr &&
69630 - addr < (unsigned long)mod->module_core + mod->core_size;
69631 + return within_module_core_rx(addr, mod) || within_module_core_rw(addr, mod);
69632 }
69633
69634 static inline int within_module_init(unsigned long addr, struct module *mod)
69635 {
69636 - return (unsigned long)mod->module_init <= addr &&
69637 - addr < (unsigned long)mod->module_init + mod->init_size;
69638 + return within_module_init_rx(addr, mod) || within_module_init_rw(addr, mod);
69639 }
69640
69641 /* Search for module by name: must hold module_mutex. */
69642 diff --git a/include/linux/moduleloader.h b/include/linux/moduleloader.h
69643 index 560ca53..5ee8d73 100644
69644 --- a/include/linux/moduleloader.h
69645 +++ b/include/linux/moduleloader.h
69646 @@ -23,11 +23,23 @@ unsigned int arch_mod_section_prepend(struct module *mod, unsigned int section);
69647
69648 /* Allocator used for allocating struct module, core sections and init
69649 sections. Returns NULL on failure. */
69650 -void *module_alloc(unsigned long size);
69651 +void *module_alloc(unsigned long size) __size_overflow(1);
69652 +
69653 +#ifdef CONFIG_PAX_KERNEXEC
69654 +void *module_alloc_exec(unsigned long size) __size_overflow(1);
69655 +#else
69656 +#define module_alloc_exec(x) module_alloc(x)
69657 +#endif
69658
69659 /* Free memory returned from module_alloc. */
69660 void module_free(struct module *mod, void *module_region);
69661
69662 +#ifdef CONFIG_PAX_KERNEXEC
69663 +void module_free_exec(struct module *mod, void *module_region);
69664 +#else
69665 +#define module_free_exec(x, y) module_free((x), (y))
69666 +#endif
69667 +
69668 /*
69669 * Apply the given relocation to the (simplified) ELF. Return -error
69670 * or 0.
69671 @@ -45,7 +57,9 @@ static inline int apply_relocate(Elf_Shdr *sechdrs,
69672 unsigned int relsec,
69673 struct module *me)
69674 {
69675 +#ifdef CONFIG_MODULES
69676 printk(KERN_ERR "module %s: REL relocation unsupported\n", me->name);
69677 +#endif
69678 return -ENOEXEC;
69679 }
69680 #endif
69681 @@ -67,7 +81,9 @@ static inline int apply_relocate_add(Elf_Shdr *sechdrs,
69682 unsigned int relsec,
69683 struct module *me)
69684 {
69685 +#ifdef CONFIG_MODULES
69686 printk(KERN_ERR "module %s: REL relocation unsupported\n", me->name);
69687 +#endif
69688 return -ENOEXEC;
69689 }
69690 #endif
69691 diff --git a/include/linux/moduleparam.h b/include/linux/moduleparam.h
69692 index 137b419..fe663ec 100644
69693 --- a/include/linux/moduleparam.h
69694 +++ b/include/linux/moduleparam.h
69695 @@ -284,7 +284,7 @@ static inline void __kernel_param_unlock(void)
69696 * @len is usually just sizeof(string).
69697 */
69698 #define module_param_string(name, string, len, perm) \
69699 - static const struct kparam_string __param_string_##name \
69700 + static const struct kparam_string __param_string_##name __used \
69701 = { len, string }; \
69702 __module_param_call(MODULE_PARAM_PREFIX, name, \
69703 &param_ops_string, \
69704 @@ -423,7 +423,7 @@ extern int param_set_bint(const char *val, const struct kernel_param *kp);
69705 */
69706 #define module_param_array_named(name, array, type, nump, perm) \
69707 param_check_##type(name, &(array)[0]); \
69708 - static const struct kparam_array __param_arr_##name \
69709 + static const struct kparam_array __param_arr_##name __used \
69710 = { .max = ARRAY_SIZE(array), .num = nump, \
69711 .ops = &param_ops_##type, \
69712 .elemsize = sizeof(array[0]), .elem = array }; \
69713 diff --git a/include/linux/namei.h b/include/linux/namei.h
69714 index 5a5ff57..5ae5070 100644
69715 --- a/include/linux/namei.h
69716 +++ b/include/linux/namei.h
69717 @@ -19,7 +19,7 @@ struct nameidata {
69718 unsigned seq;
69719 int last_type;
69720 unsigned depth;
69721 - char *saved_names[MAX_NESTED_LINKS + 1];
69722 + const char *saved_names[MAX_NESTED_LINKS + 1];
69723 };
69724
69725 /*
69726 @@ -84,12 +84,12 @@ extern void unlock_rename(struct dentry *, struct dentry *);
69727
69728 extern void nd_jump_link(struct nameidata *nd, struct path *path);
69729
69730 -static inline void nd_set_link(struct nameidata *nd, char *path)
69731 +static inline void nd_set_link(struct nameidata *nd, const char *path)
69732 {
69733 nd->saved_names[nd->depth] = path;
69734 }
69735
69736 -static inline char *nd_get_link(struct nameidata *nd)
69737 +static inline const char *nd_get_link(const struct nameidata *nd)
69738 {
69739 return nd->saved_names[nd->depth];
69740 }
69741 diff --git a/include/linux/net.h b/include/linux/net.h
69742 index aa16731..514b875 100644
69743 --- a/include/linux/net.h
69744 +++ b/include/linux/net.h
69745 @@ -183,7 +183,7 @@ struct net_proto_family {
69746 int (*create)(struct net *net, struct socket *sock,
69747 int protocol, int kern);
69748 struct module *owner;
69749 -};
69750 +} __do_const;
69751
69752 struct iovec;
69753 struct kvec;
69754 diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
69755 index 9ef07d0..130a5d9 100644
69756 --- a/include/linux/netdevice.h
69757 +++ b/include/linux/netdevice.h
69758 @@ -1012,6 +1012,7 @@ struct net_device_ops {
69759 u32 pid, u32 seq,
69760 struct net_device *dev);
69761 };
69762 +typedef struct net_device_ops __no_const net_device_ops_no_const;
69763
69764 /*
69765 * The DEVICE structure.
69766 @@ -1078,7 +1079,7 @@ struct net_device {
69767 int iflink;
69768
69769 struct net_device_stats stats;
69770 - atomic_long_t rx_dropped; /* dropped packets by core network
69771 + atomic_long_unchecked_t rx_dropped; /* dropped packets by core network
69772 * Do not use this in drivers.
69773 */
69774
69775 diff --git a/include/linux/netfilter.h b/include/linux/netfilter.h
69776 index ee14284..bc65d63 100644
69777 --- a/include/linux/netfilter.h
69778 +++ b/include/linux/netfilter.h
69779 @@ -82,7 +82,7 @@ struct nf_sockopt_ops {
69780 #endif
69781 /* Use the module struct to lock set/get code in place */
69782 struct module *owner;
69783 -};
69784 +} __do_const;
69785
69786 /* Function to register/unregister hook points. */
69787 int nf_register_hook(struct nf_hook_ops *reg);
69788 diff --git a/include/linux/netfilter/ipset/ip_set.h b/include/linux/netfilter/ipset/ip_set.h
69789 index 7958e84..ed74d7a 100644
69790 --- a/include/linux/netfilter/ipset/ip_set.h
69791 +++ b/include/linux/netfilter/ipset/ip_set.h
69792 @@ -98,7 +98,7 @@ struct ip_set_type_variant {
69793 /* Return true if "b" set is the same as "a"
69794 * according to the create set parameters */
69795 bool (*same_set)(const struct ip_set *a, const struct ip_set *b);
69796 -};
69797 +} __do_const;
69798
69799 /* The core set type structure */
69800 struct ip_set_type {
69801 diff --git a/include/linux/netfilter/nfnetlink.h b/include/linux/netfilter/nfnetlink.h
69802 index 4966dde..7d8ce06 100644
69803 --- a/include/linux/netfilter/nfnetlink.h
69804 +++ b/include/linux/netfilter/nfnetlink.h
69805 @@ -16,7 +16,7 @@ struct nfnl_callback {
69806 const struct nlattr * const cda[]);
69807 const struct nla_policy *policy; /* netlink attribute policy */
69808 const u_int16_t attr_count; /* number of nlattr's */
69809 -};
69810 +} __do_const;
69811
69812 struct nfnetlink_subsystem {
69813 const char *name;
69814 diff --git a/include/linux/netfilter/xt_gradm.h b/include/linux/netfilter/xt_gradm.h
69815 new file mode 100644
69816 index 0000000..33f4af8
69817 --- /dev/null
69818 +++ b/include/linux/netfilter/xt_gradm.h
69819 @@ -0,0 +1,9 @@
69820 +#ifndef _LINUX_NETFILTER_XT_GRADM_H
69821 +#define _LINUX_NETFILTER_XT_GRADM_H 1
69822 +
69823 +struct xt_gradm_mtinfo {
69824 + __u16 flags;
69825 + __u16 invflags;
69826 +};
69827 +
69828 +#endif
69829 diff --git a/include/linux/nls.h b/include/linux/nls.h
69830 index 5dc635f..35f5e11 100644
69831 --- a/include/linux/nls.h
69832 +++ b/include/linux/nls.h
69833 @@ -31,7 +31,7 @@ struct nls_table {
69834 const unsigned char *charset2upper;
69835 struct module *owner;
69836 struct nls_table *next;
69837 -};
69838 +} __do_const;
69839
69840 /* this value hold the maximum octet of charset */
69841 #define NLS_MAX_CHARSET_SIZE 6 /* for UTF-8 */
69842 diff --git a/include/linux/notifier.h b/include/linux/notifier.h
69843 index d65746e..62e72c2 100644
69844 --- a/include/linux/notifier.h
69845 +++ b/include/linux/notifier.h
69846 @@ -51,7 +51,8 @@ struct notifier_block {
69847 int (*notifier_call)(struct notifier_block *, unsigned long, void *);
69848 struct notifier_block __rcu *next;
69849 int priority;
69850 -};
69851 +} __do_const;
69852 +typedef struct notifier_block __no_const notifier_block_no_const;
69853
69854 struct atomic_notifier_head {
69855 spinlock_t lock;
69856 diff --git a/include/linux/oprofile.h b/include/linux/oprofile.h
69857 index a4c5624..79d6d88 100644
69858 --- a/include/linux/oprofile.h
69859 +++ b/include/linux/oprofile.h
69860 @@ -139,9 +139,9 @@ int oprofilefs_create_ulong(struct super_block * sb, struct dentry * root,
69861 int oprofilefs_create_ro_ulong(struct super_block * sb, struct dentry * root,
69862 char const * name, ulong * val);
69863
69864 -/** Create a file for read-only access to an atomic_t. */
69865 +/** Create a file for read-only access to an atomic_unchecked_t. */
69866 int oprofilefs_create_ro_atomic(struct super_block * sb, struct dentry * root,
69867 - char const * name, atomic_t * val);
69868 + char const * name, atomic_unchecked_t * val);
69869
69870 /** create a directory */
69871 struct dentry * oprofilefs_mkdir(struct super_block * sb, struct dentry * root,
69872 diff --git a/include/linux/pci_hotplug.h b/include/linux/pci_hotplug.h
69873 index 45fc162..01a4068 100644
69874 --- a/include/linux/pci_hotplug.h
69875 +++ b/include/linux/pci_hotplug.h
69876 @@ -80,7 +80,8 @@ struct hotplug_slot_ops {
69877 int (*get_attention_status) (struct hotplug_slot *slot, u8 *value);
69878 int (*get_latch_status) (struct hotplug_slot *slot, u8 *value);
69879 int (*get_adapter_status) (struct hotplug_slot *slot, u8 *value);
69880 -};
69881 +} __do_const;
69882 +typedef struct hotplug_slot_ops __no_const hotplug_slot_ops_no_const;
69883
69884 /**
69885 * struct hotplug_slot_info - used to notify the hotplug pci core of the state of the slot
69886 diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h
69887 index 6bfb2faa..e5bc5e5 100644
69888 --- a/include/linux/perf_event.h
69889 +++ b/include/linux/perf_event.h
69890 @@ -328,8 +328,8 @@ struct perf_event {
69891
69892 enum perf_event_active_state state;
69893 unsigned int attach_state;
69894 - local64_t count;
69895 - atomic64_t child_count;
69896 + local64_t count; /* PaX: fix it one day */
69897 + atomic64_unchecked_t child_count;
69898
69899 /*
69900 * These are the total time in nanoseconds that the event
69901 @@ -380,8 +380,8 @@ struct perf_event {
69902 * These accumulate total time (in nanoseconds) that children
69903 * events have been enabled and running, respectively.
69904 */
69905 - atomic64_t child_total_time_enabled;
69906 - atomic64_t child_total_time_running;
69907 + atomic64_unchecked_t child_total_time_enabled;
69908 + atomic64_unchecked_t child_total_time_running;
69909
69910 /*
69911 * Protect attach/detach and child_list:
69912 @@ -801,7 +801,7 @@ static inline void perf_event_task_tick(void) { }
69913 */
69914 #define perf_cpu_notifier(fn) \
69915 do { \
69916 - static struct notifier_block fn##_nb __cpuinitdata = \
69917 + static struct notifier_block fn##_nb = \
69918 { .notifier_call = fn, .priority = CPU_PRI_PERF }; \
69919 unsigned long cpu = smp_processor_id(); \
69920 unsigned long flags; \
69921 diff --git a/include/linux/pipe_fs_i.h b/include/linux/pipe_fs_i.h
69922 index ad1a427..6419649 100644
69923 --- a/include/linux/pipe_fs_i.h
69924 +++ b/include/linux/pipe_fs_i.h
69925 @@ -45,9 +45,9 @@ struct pipe_buffer {
69926 struct pipe_inode_info {
69927 wait_queue_head_t wait;
69928 unsigned int nrbufs, curbuf, buffers;
69929 - unsigned int readers;
69930 - unsigned int writers;
69931 - unsigned int waiting_writers;
69932 + atomic_t readers;
69933 + atomic_t writers;
69934 + atomic_t waiting_writers;
69935 unsigned int r_counter;
69936 unsigned int w_counter;
69937 struct page *tmp_page;
69938 diff --git a/include/linux/platform_data/usb-ehci-s5p.h b/include/linux/platform_data/usb-ehci-s5p.h
69939 index 5f28cae..3d23723 100644
69940 --- a/include/linux/platform_data/usb-ehci-s5p.h
69941 +++ b/include/linux/platform_data/usb-ehci-s5p.h
69942 @@ -14,7 +14,7 @@
69943 struct s5p_ehci_platdata {
69944 int (*phy_init)(struct platform_device *pdev, int type);
69945 int (*phy_exit)(struct platform_device *pdev, int type);
69946 -};
69947 +} __no_const;
69948
69949 extern void s5p_ehci_set_platdata(struct s5p_ehci_platdata *pd);
69950
69951 diff --git a/include/linux/platform_data/usb-exynos.h b/include/linux/platform_data/usb-exynos.h
69952 index c256c59..8ea94c7 100644
69953 --- a/include/linux/platform_data/usb-exynos.h
69954 +++ b/include/linux/platform_data/usb-exynos.h
69955 @@ -14,7 +14,7 @@
69956 struct exynos4_ohci_platdata {
69957 int (*phy_init)(struct platform_device *pdev, int type);
69958 int (*phy_exit)(struct platform_device *pdev, int type);
69959 -};
69960 +} __no_const;
69961
69962 extern void exynos4_ohci_set_platdata(struct exynos4_ohci_platdata *pd);
69963
69964 diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h
69965 index 7c1d252..c5c773e 100644
69966 --- a/include/linux/pm_domain.h
69967 +++ b/include/linux/pm_domain.h
69968 @@ -48,7 +48,7 @@ struct gpd_dev_ops {
69969
69970 struct gpd_cpu_data {
69971 unsigned int saved_exit_latency;
69972 - struct cpuidle_state *idle_state;
69973 + cpuidle_state_no_const *idle_state;
69974 };
69975
69976 struct generic_pm_domain {
69977 diff --git a/include/linux/pm_runtime.h b/include/linux/pm_runtime.h
69978 index f271860..6b3bec5 100644
69979 --- a/include/linux/pm_runtime.h
69980 +++ b/include/linux/pm_runtime.h
69981 @@ -97,7 +97,7 @@ static inline bool pm_runtime_callbacks_present(struct device *dev)
69982
69983 static inline void pm_runtime_mark_last_busy(struct device *dev)
69984 {
69985 - ACCESS_ONCE(dev->power.last_busy) = jiffies;
69986 + ACCESS_ONCE_RW(dev->power.last_busy) = jiffies;
69987 }
69988
69989 #else /* !CONFIG_PM_RUNTIME */
69990 diff --git a/include/linux/pnp.h b/include/linux/pnp.h
69991 index 195aafc..49a7bc2 100644
69992 --- a/include/linux/pnp.h
69993 +++ b/include/linux/pnp.h
69994 @@ -297,7 +297,7 @@ static inline void pnp_set_drvdata(struct pnp_dev *pdev, void *data)
69995 struct pnp_fixup {
69996 char id[7];
69997 void (*quirk_function) (struct pnp_dev * dev); /* fixup function */
69998 -};
69999 +} __do_const;
70000
70001 /* config parameters */
70002 #define PNP_CONFIG_NORMAL 0x0001
70003 diff --git a/include/linux/poison.h b/include/linux/poison.h
70004 index 2110a81..13a11bb 100644
70005 --- a/include/linux/poison.h
70006 +++ b/include/linux/poison.h
70007 @@ -19,8 +19,8 @@
70008 * under normal circumstances, used to verify that nobody uses
70009 * non-initialized list entries.
70010 */
70011 -#define LIST_POISON1 ((void *) 0x00100100 + POISON_POINTER_DELTA)
70012 -#define LIST_POISON2 ((void *) 0x00200200 + POISON_POINTER_DELTA)
70013 +#define LIST_POISON1 ((void *) (long)0xFFFFFF01)
70014 +#define LIST_POISON2 ((void *) (long)0xFFFFFF02)
70015
70016 /********** include/linux/timer.h **********/
70017 /*
70018 diff --git a/include/linux/power/smartreflex.h b/include/linux/power/smartreflex.h
70019 index c0f44c2..1572583 100644
70020 --- a/include/linux/power/smartreflex.h
70021 +++ b/include/linux/power/smartreflex.h
70022 @@ -238,7 +238,7 @@ struct omap_sr_class_data {
70023 int (*notify)(struct omap_sr *sr, u32 status);
70024 u8 notify_flags;
70025 u8 class_type;
70026 -};
70027 +} __do_const;
70028
70029 /**
70030 * struct omap_sr_nvalue_table - Smartreflex n-target value info
70031 diff --git a/include/linux/ppp-comp.h b/include/linux/ppp-comp.h
70032 index 4ea1d37..80f4b33 100644
70033 --- a/include/linux/ppp-comp.h
70034 +++ b/include/linux/ppp-comp.h
70035 @@ -84,7 +84,7 @@ struct compressor {
70036 struct module *owner;
70037 /* Extra skb space needed by the compressor algorithm */
70038 unsigned int comp_extra;
70039 -};
70040 +} __do_const;
70041
70042 /*
70043 * The return value from decompress routine is the length of the
70044 diff --git a/include/linux/printk.h b/include/linux/printk.h
70045 index 9afc01e..92c32e8 100644
70046 --- a/include/linux/printk.h
70047 +++ b/include/linux/printk.h
70048 @@ -101,6 +101,8 @@ void early_printk(const char *fmt, ...);
70049 extern int printk_needs_cpu(int cpu);
70050 extern void printk_tick(void);
70051
70052 +extern int kptr_restrict;
70053 +
70054 #ifdef CONFIG_PRINTK
70055 asmlinkage __printf(5, 0)
70056 int vprintk_emit(int facility, int level,
70057 @@ -135,7 +137,6 @@ extern bool printk_timed_ratelimit(unsigned long *caller_jiffies,
70058
70059 extern int printk_delay_msec;
70060 extern int dmesg_restrict;
70061 -extern int kptr_restrict;
70062
70063 void log_buf_kexec_setup(void);
70064 void __init setup_log_buf(int early);
70065 diff --git a/include/linux/proc_fs.h b/include/linux/proc_fs.h
70066 index 32676b3..8f7a182 100644
70067 --- a/include/linux/proc_fs.h
70068 +++ b/include/linux/proc_fs.h
70069 @@ -159,6 +159,18 @@ static inline struct proc_dir_entry *proc_create(const char *name, umode_t mode,
70070 return proc_create_data(name, mode, parent, proc_fops, NULL);
70071 }
70072
70073 +static inline struct proc_dir_entry *proc_create_grsec(const char *name, umode_t mode,
70074 + struct proc_dir_entry *parent, const struct file_operations *proc_fops)
70075 +{
70076 +#ifdef CONFIG_GRKERNSEC_PROC_USER
70077 + return proc_create_data(name, S_IRUSR, parent, proc_fops, NULL);
70078 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
70079 + return proc_create_data(name, S_IRUSR | S_IRGRP, parent, proc_fops, NULL);
70080 +#else
70081 + return proc_create_data(name, mode, parent, proc_fops, NULL);
70082 +#endif
70083 +}
70084 +
70085 static inline struct proc_dir_entry *create_proc_read_entry(const char *name,
70086 umode_t mode, struct proc_dir_entry *base,
70087 read_proc_t *read_proc, void * data)
70088 diff --git a/include/linux/random.h b/include/linux/random.h
70089 index d984608..d6f0042 100644
70090 --- a/include/linux/random.h
70091 +++ b/include/linux/random.h
70092 @@ -39,6 +39,11 @@ void prandom_seed(u32 seed);
70093 u32 prandom_u32_state(struct rnd_state *);
70094 void prandom_bytes_state(struct rnd_state *state, void *buf, int nbytes);
70095
70096 +static inline unsigned long pax_get_random_long(void)
70097 +{
70098 + return prandom_u32() + (sizeof(long) > 4 ? (unsigned long)prandom_u32() << 32 : 0);
70099 +}
70100 +
70101 /*
70102 * Handle minimum values for seeds
70103 */
70104 diff --git a/include/linux/rculist.h b/include/linux/rculist.h
70105 index c92dd28..08f4eab 100644
70106 --- a/include/linux/rculist.h
70107 +++ b/include/linux/rculist.h
70108 @@ -44,6 +44,9 @@ extern void __list_add_rcu(struct list_head *new,
70109 struct list_head *prev, struct list_head *next);
70110 #endif
70111
70112 +extern void __pax_list_add_rcu(struct list_head *new,
70113 + struct list_head *prev, struct list_head *next);
70114 +
70115 /**
70116 * list_add_rcu - add a new entry to rcu-protected list
70117 * @new: new entry to be added
70118 @@ -65,6 +68,11 @@ static inline void list_add_rcu(struct list_head *new, struct list_head *head)
70119 __list_add_rcu(new, head, head->next);
70120 }
70121
70122 +static inline void pax_list_add_rcu(struct list_head *new, struct list_head *head)
70123 +{
70124 + __pax_list_add_rcu(new, head, head->next);
70125 +}
70126 +
70127 /**
70128 * list_add_tail_rcu - add a new entry to rcu-protected list
70129 * @new: new entry to be added
70130 @@ -87,6 +95,12 @@ static inline void list_add_tail_rcu(struct list_head *new,
70131 __list_add_rcu(new, head->prev, head);
70132 }
70133
70134 +static inline void pax_list_add_tail_rcu(struct list_head *new,
70135 + struct list_head *head)
70136 +{
70137 + __pax_list_add_rcu(new, head->prev, head);
70138 +}
70139 +
70140 /**
70141 * list_del_rcu - deletes entry from list without re-initialization
70142 * @entry: the element to delete from the list.
70143 @@ -117,6 +131,8 @@ static inline void list_del_rcu(struct list_head *entry)
70144 entry->prev = LIST_POISON2;
70145 }
70146
70147 +extern void pax_list_del_rcu(struct list_head *entry);
70148 +
70149 /**
70150 * hlist_del_init_rcu - deletes entry from hash list with re-initialization
70151 * @n: the element to delete from the hash list.
70152 diff --git a/include/linux/reboot.h b/include/linux/reboot.h
70153 index 23b3630..e1bc12b 100644
70154 --- a/include/linux/reboot.h
70155 +++ b/include/linux/reboot.h
70156 @@ -18,9 +18,9 @@ extern int unregister_reboot_notifier(struct notifier_block *);
70157 * Architecture-specific implementations of sys_reboot commands.
70158 */
70159
70160 -extern void machine_restart(char *cmd);
70161 -extern void machine_halt(void);
70162 -extern void machine_power_off(void);
70163 +extern void machine_restart(char *cmd) __noreturn;
70164 +extern void machine_halt(void) __noreturn;
70165 +extern void machine_power_off(void) __noreturn;
70166
70167 extern void machine_shutdown(void);
70168 struct pt_regs;
70169 @@ -31,9 +31,9 @@ extern void machine_crash_shutdown(struct pt_regs *);
70170 */
70171
70172 extern void kernel_restart_prepare(char *cmd);
70173 -extern void kernel_restart(char *cmd);
70174 -extern void kernel_halt(void);
70175 -extern void kernel_power_off(void);
70176 +extern void kernel_restart(char *cmd) __noreturn;
70177 +extern void kernel_halt(void) __noreturn;
70178 +extern void kernel_power_off(void) __noreturn;
70179
70180 extern int C_A_D; /* for sysctl */
70181 void ctrl_alt_del(void);
70182 @@ -47,7 +47,7 @@ extern int orderly_poweroff(bool force);
70183 * Emergency restart, callable from an interrupt handler.
70184 */
70185
70186 -extern void emergency_restart(void);
70187 +extern void emergency_restart(void) __noreturn;
70188 #include <asm/emergency-restart.h>
70189
70190 #endif /* _LINUX_REBOOT_H */
70191 diff --git a/include/linux/regset.h b/include/linux/regset.h
70192 index 8e0c9fe..ac4d221 100644
70193 --- a/include/linux/regset.h
70194 +++ b/include/linux/regset.h
70195 @@ -161,7 +161,8 @@ struct user_regset {
70196 unsigned int align;
70197 unsigned int bias;
70198 unsigned int core_note_type;
70199 -};
70200 +} __do_const;
70201 +typedef struct user_regset __no_const user_regset_no_const;
70202
70203 /**
70204 * struct user_regset_view - available regsets
70205 diff --git a/include/linux/relay.h b/include/linux/relay.h
70206 index 91cacc3..b55ff74 100644
70207 --- a/include/linux/relay.h
70208 +++ b/include/linux/relay.h
70209 @@ -160,7 +160,7 @@ struct rchan_callbacks
70210 * The callback should return 0 if successful, negative if not.
70211 */
70212 int (*remove_buf_file)(struct dentry *dentry);
70213 -};
70214 +} __no_const;
70215
70216 /*
70217 * CONFIG_RELAY kernel API, kernel/relay.c
70218 diff --git a/include/linux/rio.h b/include/linux/rio.h
70219 index a3e7842..d973ca6 100644
70220 --- a/include/linux/rio.h
70221 +++ b/include/linux/rio.h
70222 @@ -339,7 +339,7 @@ struct rio_ops {
70223 int (*map_inb)(struct rio_mport *mport, dma_addr_t lstart,
70224 u64 rstart, u32 size, u32 flags);
70225 void (*unmap_inb)(struct rio_mport *mport, dma_addr_t lstart);
70226 -};
70227 +} __no_const;
70228
70229 #define RIO_RESOURCE_MEM 0x00000100
70230 #define RIO_RESOURCE_DOORBELL 0x00000200
70231 diff --git a/include/linux/rmap.h b/include/linux/rmap.h
70232 index c20635c..2f5def4 100644
70233 --- a/include/linux/rmap.h
70234 +++ b/include/linux/rmap.h
70235 @@ -145,8 +145,8 @@ static inline void anon_vma_unlock_read(struct anon_vma *anon_vma)
70236 void anon_vma_init(void); /* create anon_vma_cachep */
70237 int anon_vma_prepare(struct vm_area_struct *);
70238 void unlink_anon_vmas(struct vm_area_struct *);
70239 -int anon_vma_clone(struct vm_area_struct *, struct vm_area_struct *);
70240 -int anon_vma_fork(struct vm_area_struct *, struct vm_area_struct *);
70241 +int anon_vma_clone(struct vm_area_struct *, const struct vm_area_struct *);
70242 +int anon_vma_fork(struct vm_area_struct *, const struct vm_area_struct *);
70243
70244 static inline void anon_vma_merge(struct vm_area_struct *vma,
70245 struct vm_area_struct *next)
70246 diff --git a/include/linux/sched.h b/include/linux/sched.h
70247 index d211247..eac6c2c 100644
70248 --- a/include/linux/sched.h
70249 +++ b/include/linux/sched.h
70250 @@ -61,6 +61,7 @@ struct bio_list;
70251 struct fs_struct;
70252 struct perf_event_context;
70253 struct blk_plug;
70254 +struct linux_binprm;
70255
70256 /*
70257 * List of flags we want to share for kernel threads,
70258 @@ -327,7 +328,7 @@ extern char __sched_text_start[], __sched_text_end[];
70259 extern int in_sched_functions(unsigned long addr);
70260
70261 #define MAX_SCHEDULE_TIMEOUT LONG_MAX
70262 -extern signed long schedule_timeout(signed long timeout);
70263 +extern signed long schedule_timeout(signed long timeout) __intentional_overflow(-1);
70264 extern signed long schedule_timeout_interruptible(signed long timeout);
70265 extern signed long schedule_timeout_killable(signed long timeout);
70266 extern signed long schedule_timeout_uninterruptible(signed long timeout);
70267 @@ -354,10 +355,23 @@ struct user_namespace;
70268 #define DEFAULT_MAX_MAP_COUNT (USHRT_MAX - MAPCOUNT_ELF_CORE_MARGIN)
70269
70270 extern int sysctl_max_map_count;
70271 +extern unsigned long sysctl_heap_stack_gap;
70272
70273 #include <linux/aio.h>
70274
70275 #ifdef CONFIG_MMU
70276 +
70277 +#ifdef CONFIG_GRKERNSEC_RAND_THREADSTACK
70278 +extern unsigned long gr_rand_threadstack_offset(const struct mm_struct *mm, const struct file *filp, unsigned long flags);
70279 +#else
70280 +static inline unsigned long gr_rand_threadstack_offset(const struct mm_struct *mm, const struct file *filp, unsigned long flags)
70281 +{
70282 + return 0;
70283 +}
70284 +#endif
70285 +
70286 +extern bool check_heap_stack_gap(const struct vm_area_struct *vma, unsigned long addr, unsigned long len, unsigned long offset);
70287 +extern unsigned long skip_heap_stack_gap(const struct vm_area_struct *vma, unsigned long len, unsigned long offset);
70288 extern void arch_pick_mmap_layout(struct mm_struct *mm);
70289 extern unsigned long
70290 arch_get_unmapped_area(struct file *, unsigned long, unsigned long,
70291 @@ -639,6 +653,17 @@ struct signal_struct {
70292 #ifdef CONFIG_TASKSTATS
70293 struct taskstats *stats;
70294 #endif
70295 +
70296 +#ifdef CONFIG_GRKERNSEC
70297 + u32 curr_ip;
70298 + u32 saved_ip;
70299 + u32 gr_saddr;
70300 + u32 gr_daddr;
70301 + u16 gr_sport;
70302 + u16 gr_dport;
70303 + u8 used_accept:1;
70304 +#endif
70305 +
70306 #ifdef CONFIG_AUDIT
70307 unsigned audit_tty;
70308 struct tty_audit_buf *tty_audit_buf;
70309 @@ -717,6 +742,11 @@ struct user_struct {
70310 struct key *session_keyring; /* UID's default session keyring */
70311 #endif
70312
70313 +#if defined(CONFIG_GRKERNSEC_KERN_LOCKOUT) || defined(CONFIG_GRKERNSEC_BRUTE)
70314 + unsigned int banned;
70315 + unsigned long ban_expires;
70316 +#endif
70317 +
70318 /* Hash table maintenance information */
70319 struct hlist_node uidhash_node;
70320 kuid_t uid;
70321 @@ -1116,7 +1146,7 @@ struct sched_class {
70322 #ifdef CONFIG_FAIR_GROUP_SCHED
70323 void (*task_move_group) (struct task_struct *p, int on_rq);
70324 #endif
70325 -};
70326 +} __do_const;
70327
70328 struct load_weight {
70329 unsigned long weight, inv_weight;
70330 @@ -1360,8 +1390,8 @@ struct task_struct {
70331 struct list_head thread_group;
70332
70333 struct completion *vfork_done; /* for vfork() */
70334 - int __user *set_child_tid; /* CLONE_CHILD_SETTID */
70335 - int __user *clear_child_tid; /* CLONE_CHILD_CLEARTID */
70336 + pid_t __user *set_child_tid; /* CLONE_CHILD_SETTID */
70337 + pid_t __user *clear_child_tid; /* CLONE_CHILD_CLEARTID */
70338
70339 cputime_t utime, stime, utimescaled, stimescaled;
70340 cputime_t gtime;
70341 @@ -1377,11 +1407,6 @@ struct task_struct {
70342 struct task_cputime cputime_expires;
70343 struct list_head cpu_timers[3];
70344
70345 -/* process credentials */
70346 - const struct cred __rcu *real_cred; /* objective and real subjective task
70347 - * credentials (COW) */
70348 - const struct cred __rcu *cred; /* effective (overridable) subjective task
70349 - * credentials (COW) */
70350 char comm[TASK_COMM_LEN]; /* executable name excluding path
70351 - access with [gs]et_task_comm (which lock
70352 it with task_lock())
70353 @@ -1398,6 +1423,10 @@ struct task_struct {
70354 #endif
70355 /* CPU-specific state of this task */
70356 struct thread_struct thread;
70357 +/* thread_info moved to task_struct */
70358 +#ifdef CONFIG_X86
70359 + struct thread_info tinfo;
70360 +#endif
70361 /* filesystem information */
70362 struct fs_struct *fs;
70363 /* open file information */
70364 @@ -1471,6 +1500,10 @@ struct task_struct {
70365 gfp_t lockdep_reclaim_gfp;
70366 #endif
70367
70368 +/* process credentials */
70369 + const struct cred __rcu *real_cred; /* objective and real subjective task
70370 + * credentials (COW) */
70371 +
70372 /* journalling filesystem info */
70373 void *journal_info;
70374
70375 @@ -1509,6 +1542,10 @@ struct task_struct {
70376 /* cg_list protected by css_set_lock and tsk->alloc_lock */
70377 struct list_head cg_list;
70378 #endif
70379 +
70380 + const struct cred __rcu *cred; /* effective (overridable) subjective task
70381 + * credentials (COW) */
70382 +
70383 #ifdef CONFIG_FUTEX
70384 struct robust_list_head __user *robust_list;
70385 #ifdef CONFIG_COMPAT
70386 @@ -1605,8 +1642,74 @@ struct task_struct {
70387 #ifdef CONFIG_UPROBES
70388 struct uprobe_task *utask;
70389 #endif
70390 +
70391 +#ifdef CONFIG_GRKERNSEC
70392 + /* grsecurity */
70393 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
70394 + u64 exec_id;
70395 +#endif
70396 +#ifdef CONFIG_GRKERNSEC_SETXID
70397 + const struct cred *delayed_cred;
70398 +#endif
70399 + struct dentry *gr_chroot_dentry;
70400 + struct acl_subject_label *acl;
70401 + struct acl_role_label *role;
70402 + struct file *exec_file;
70403 + unsigned long brute_expires;
70404 + u16 acl_role_id;
70405 + /* is this the task that authenticated to the special role */
70406 + u8 acl_sp_role;
70407 + u8 is_writable;
70408 + u8 brute;
70409 + u8 gr_is_chrooted;
70410 +#endif
70411 +
70412 };
70413
70414 +#define MF_PAX_PAGEEXEC 0x01000000 /* Paging based non-executable pages */
70415 +#define MF_PAX_EMUTRAMP 0x02000000 /* Emulate trampolines */
70416 +#define MF_PAX_MPROTECT 0x04000000 /* Restrict mprotect() */
70417 +#define MF_PAX_RANDMMAP 0x08000000 /* Randomize mmap() base */
70418 +/*#define MF_PAX_RANDEXEC 0x10000000*/ /* Randomize ET_EXEC base */
70419 +#define MF_PAX_SEGMEXEC 0x20000000 /* Segmentation based non-executable pages */
70420 +
70421 +#ifdef CONFIG_PAX_SOFTMODE
70422 +extern int pax_softmode;
70423 +#endif
70424 +
70425 +extern int pax_check_flags(unsigned long *);
70426 +
70427 +/* if tsk != current then task_lock must be held on it */
70428 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
70429 +static inline unsigned long pax_get_flags(struct task_struct *tsk)
70430 +{
70431 + if (likely(tsk->mm))
70432 + return tsk->mm->pax_flags;
70433 + else
70434 + return 0UL;
70435 +}
70436 +
70437 +/* if tsk != current then task_lock must be held on it */
70438 +static inline long pax_set_flags(struct task_struct *tsk, unsigned long flags)
70439 +{
70440 + if (likely(tsk->mm)) {
70441 + tsk->mm->pax_flags = flags;
70442 + return 0;
70443 + }
70444 + return -EINVAL;
70445 +}
70446 +#endif
70447 +
70448 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
70449 +extern void pax_set_initial_flags(struct linux_binprm *bprm);
70450 +#elif defined(CONFIG_PAX_HOOK_ACL_FLAGS)
70451 +extern void (*pax_set_initial_flags_func)(struct linux_binprm *bprm);
70452 +#endif
70453 +
70454 +extern void pax_report_fault(struct pt_regs *regs, void *pc, void *sp);
70455 +extern void pax_report_insns(struct pt_regs *regs, void *pc, void *sp);
70456 +extern void pax_report_refcount_overflow(struct pt_regs *regs);
70457 +
70458 /* Future-safe accessor for struct task_struct's cpus_allowed. */
70459 #define tsk_cpus_allowed(tsk) (&(tsk)->cpus_allowed)
70460
70461 @@ -1696,7 +1799,7 @@ struct pid_namespace;
70462 pid_t __task_pid_nr_ns(struct task_struct *task, enum pid_type type,
70463 struct pid_namespace *ns);
70464
70465 -static inline pid_t task_pid_nr(struct task_struct *tsk)
70466 +static inline pid_t task_pid_nr(const struct task_struct *tsk)
70467 {
70468 return tsk->pid;
70469 }
70470 @@ -2155,7 +2258,9 @@ void yield(void);
70471 extern struct exec_domain default_exec_domain;
70472
70473 union thread_union {
70474 +#ifndef CONFIG_X86
70475 struct thread_info thread_info;
70476 +#endif
70477 unsigned long stack[THREAD_SIZE/sizeof(long)];
70478 };
70479
70480 @@ -2188,6 +2293,7 @@ extern struct pid_namespace init_pid_ns;
70481 */
70482
70483 extern struct task_struct *find_task_by_vpid(pid_t nr);
70484 +extern struct task_struct *find_task_by_vpid_unrestricted(pid_t nr);
70485 extern struct task_struct *find_task_by_pid_ns(pid_t nr,
70486 struct pid_namespace *ns);
70487
70488 @@ -2344,7 +2450,7 @@ extern void __cleanup_sighand(struct sighand_struct *);
70489 extern void exit_itimers(struct signal_struct *);
70490 extern void flush_itimer_signals(void);
70491
70492 -extern void do_group_exit(int);
70493 +extern __noreturn void do_group_exit(int);
70494
70495 extern int allow_signal(int);
70496 extern int disallow_signal(int);
70497 @@ -2545,9 +2651,9 @@ static inline unsigned long *end_of_stack(struct task_struct *p)
70498
70499 #endif
70500
70501 -static inline int object_is_on_stack(void *obj)
70502 +static inline int object_starts_on_stack(void *obj)
70503 {
70504 - void *stack = task_stack_page(current);
70505 + const void *stack = task_stack_page(current);
70506
70507 return (obj >= stack) && (obj < (stack + THREAD_SIZE));
70508 }
70509 diff --git a/include/linux/security.h b/include/linux/security.h
70510 index eee7478..290f7ba 100644
70511 --- a/include/linux/security.h
70512 +++ b/include/linux/security.h
70513 @@ -26,6 +26,7 @@
70514 #include <linux/capability.h>
70515 #include <linux/slab.h>
70516 #include <linux/err.h>
70517 +#include <linux/grsecurity.h>
70518
70519 struct linux_binprm;
70520 struct cred;
70521 diff --git a/include/linux/seq_file.h b/include/linux/seq_file.h
70522 index 68a04a3..866e6a1 100644
70523 --- a/include/linux/seq_file.h
70524 +++ b/include/linux/seq_file.h
70525 @@ -26,6 +26,9 @@ struct seq_file {
70526 struct mutex lock;
70527 const struct seq_operations *op;
70528 int poll_event;
70529 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
70530 + u64 exec_id;
70531 +#endif
70532 #ifdef CONFIG_USER_NS
70533 struct user_namespace *user_ns;
70534 #endif
70535 @@ -38,6 +41,7 @@ struct seq_operations {
70536 void * (*next) (struct seq_file *m, void *v, loff_t *pos);
70537 int (*show) (struct seq_file *m, void *v);
70538 };
70539 +typedef struct seq_operations __no_const seq_operations_no_const;
70540
70541 #define SEQ_SKIP 1
70542
70543 diff --git a/include/linux/shm.h b/include/linux/shm.h
70544 index 429c199..4d42e38 100644
70545 --- a/include/linux/shm.h
70546 +++ b/include/linux/shm.h
70547 @@ -21,6 +21,10 @@ struct shmid_kernel /* private to the kernel */
70548
70549 /* The task created the shm object. NULL if the task is dead. */
70550 struct task_struct *shm_creator;
70551 +#ifdef CONFIG_GRKERNSEC
70552 + time_t shm_createtime;
70553 + pid_t shm_lapid;
70554 +#endif
70555 };
70556
70557 /* shm_mode upper byte flags */
70558 diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
70559 index 320e976..fd52553 100644
70560 --- a/include/linux/skbuff.h
70561 +++ b/include/linux/skbuff.h
70562 @@ -590,7 +590,7 @@ extern bool skb_try_coalesce(struct sk_buff *to, struct sk_buff *from,
70563 extern struct sk_buff *__alloc_skb(unsigned int size,
70564 gfp_t priority, int flags, int node);
70565 extern struct sk_buff *build_skb(void *data, unsigned int frag_size);
70566 -static inline struct sk_buff *alloc_skb(unsigned int size,
70567 +static inline struct sk_buff * __intentional_overflow(0) alloc_skb(unsigned int size,
70568 gfp_t priority)
70569 {
70570 return __alloc_skb(size, priority, 0, NUMA_NO_NODE);
70571 @@ -700,7 +700,7 @@ static inline struct skb_shared_hwtstamps *skb_hwtstamps(struct sk_buff *skb)
70572 */
70573 static inline int skb_queue_empty(const struct sk_buff_head *list)
70574 {
70575 - return list->next == (struct sk_buff *)list;
70576 + return list->next == (const struct sk_buff *)list;
70577 }
70578
70579 /**
70580 @@ -713,7 +713,7 @@ static inline int skb_queue_empty(const struct sk_buff_head *list)
70581 static inline bool skb_queue_is_last(const struct sk_buff_head *list,
70582 const struct sk_buff *skb)
70583 {
70584 - return skb->next == (struct sk_buff *)list;
70585 + return skb->next == (const struct sk_buff *)list;
70586 }
70587
70588 /**
70589 @@ -726,7 +726,7 @@ static inline bool skb_queue_is_last(const struct sk_buff_head *list,
70590 static inline bool skb_queue_is_first(const struct sk_buff_head *list,
70591 const struct sk_buff *skb)
70592 {
70593 - return skb->prev == (struct sk_buff *)list;
70594 + return skb->prev == (const struct sk_buff *)list;
70595 }
70596
70597 /**
70598 @@ -1722,7 +1722,7 @@ static inline int pskb_network_may_pull(struct sk_buff *skb, unsigned int len)
70599 * NET_IP_ALIGN(2) + ethernet_header(14) + IP_header(20/40) + ports(8)
70600 */
70601 #ifndef NET_SKB_PAD
70602 -#define NET_SKB_PAD max(32, L1_CACHE_BYTES)
70603 +#define NET_SKB_PAD max(_AC(32,UL), L1_CACHE_BYTES)
70604 #endif
70605
70606 extern int ___pskb_trim(struct sk_buff *skb, unsigned int len);
70607 @@ -2300,7 +2300,7 @@ extern struct sk_buff *skb_recv_datagram(struct sock *sk, unsigned flags,
70608 int noblock, int *err);
70609 extern unsigned int datagram_poll(struct file *file, struct socket *sock,
70610 struct poll_table_struct *wait);
70611 -extern int skb_copy_datagram_iovec(const struct sk_buff *from,
70612 +extern int __intentional_overflow(0) skb_copy_datagram_iovec(const struct sk_buff *from,
70613 int offset, struct iovec *to,
70614 int size);
70615 extern int skb_copy_and_csum_datagram_iovec(struct sk_buff *skb,
70616 diff --git a/include/linux/slab.h b/include/linux/slab.h
70617 index 5d168d7..720bff3 100644
70618 --- a/include/linux/slab.h
70619 +++ b/include/linux/slab.h
70620 @@ -12,13 +12,20 @@
70621 #include <linux/gfp.h>
70622 #include <linux/types.h>
70623 #include <linux/workqueue.h>
70624 -
70625 +#include <linux/err.h>
70626
70627 /*
70628 * Flags to pass to kmem_cache_create().
70629 * The ones marked DEBUG are only valid if CONFIG_SLAB_DEBUG is set.
70630 */
70631 #define SLAB_DEBUG_FREE 0x00000100UL /* DEBUG: Perform (expensive) checks on free */
70632 +
70633 +#ifdef CONFIG_PAX_USERCOPY_SLABS
70634 +#define SLAB_USERCOPY 0x00000200UL /* PaX: Allow copying objs to/from userland */
70635 +#else
70636 +#define SLAB_USERCOPY 0x00000000UL
70637 +#endif
70638 +
70639 #define SLAB_RED_ZONE 0x00000400UL /* DEBUG: Red zone objs in a cache */
70640 #define SLAB_POISON 0x00000800UL /* DEBUG: Poison objects */
70641 #define SLAB_HWCACHE_ALIGN 0x00002000UL /* Align objs on cache lines */
70642 @@ -89,10 +96,13 @@
70643 * ZERO_SIZE_PTR can be passed to kfree though in the same way that NULL can.
70644 * Both make kfree a no-op.
70645 */
70646 -#define ZERO_SIZE_PTR ((void *)16)
70647 +#define ZERO_SIZE_PTR \
70648 +({ \
70649 + BUILD_BUG_ON(!(MAX_ERRNO & ~PAGE_MASK));\
70650 + (void *)(-MAX_ERRNO-1L); \
70651 +})
70652
70653 -#define ZERO_OR_NULL_PTR(x) ((unsigned long)(x) <= \
70654 - (unsigned long)ZERO_SIZE_PTR)
70655 +#define ZERO_OR_NULL_PTR(x) ((unsigned long)(x) - 1 >= (unsigned long)ZERO_SIZE_PTR - 1)
70656
70657 /*
70658 * Common fields provided in kmem_cache by all slab allocators
70659 @@ -112,7 +122,7 @@ struct kmem_cache {
70660 unsigned int align; /* Alignment as calculated */
70661 unsigned long flags; /* Active flags on the slab */
70662 const char *name; /* Slab name for sysfs */
70663 - int refcount; /* Use counter */
70664 + atomic_t refcount; /* Use counter */
70665 void (*ctor)(void *); /* Called on object slot creation */
70666 struct list_head list; /* List of all slab caches on the system */
70667 };
70668 @@ -232,6 +242,8 @@ void * __must_check krealloc(const void *, size_t, gfp_t);
70669 void kfree(const void *);
70670 void kzfree(const void *);
70671 size_t ksize(const void *);
70672 +const char *check_heap_object(const void *ptr, unsigned long n);
70673 +bool is_usercopy_object(const void *ptr);
70674
70675 /*
70676 * Allocator specific definitions. These are mainly used to establish optimized
70677 @@ -311,6 +323,7 @@ size_t ksize(const void *);
70678 * for general use, and so are not documented here. For a full list of
70679 * potential flags, always refer to linux/gfp.h.
70680 */
70681 +
70682 static inline void *kmalloc_array(size_t n, size_t size, gfp_t flags)
70683 {
70684 if (size != 0 && n > SIZE_MAX / size)
70685 @@ -370,7 +383,7 @@ static inline void *kmem_cache_alloc_node(struct kmem_cache *cachep,
70686 #if defined(CONFIG_DEBUG_SLAB) || defined(CONFIG_SLUB) || \
70687 (defined(CONFIG_SLAB) && defined(CONFIG_TRACING)) || \
70688 (defined(CONFIG_SLOB) && defined(CONFIG_TRACING))
70689 -extern void *__kmalloc_track_caller(size_t, gfp_t, unsigned long);
70690 +extern void *__kmalloc_track_caller(size_t, gfp_t, unsigned long) __size_overflow(1);
70691 #define kmalloc_track_caller(size, flags) \
70692 __kmalloc_track_caller(size, flags, _RET_IP_)
70693 #else
70694 @@ -390,7 +403,7 @@ extern void *__kmalloc_track_caller(size_t, gfp_t, unsigned long);
70695 #if defined(CONFIG_DEBUG_SLAB) || defined(CONFIG_SLUB) || \
70696 (defined(CONFIG_SLAB) && defined(CONFIG_TRACING)) || \
70697 (defined(CONFIG_SLOB) && defined(CONFIG_TRACING))
70698 -extern void *__kmalloc_node_track_caller(size_t, gfp_t, int, unsigned long);
70699 +extern void *__kmalloc_node_track_caller(size_t, gfp_t, int, unsigned long) __size_overflow(1);
70700 #define kmalloc_node_track_caller(size, flags, node) \
70701 __kmalloc_node_track_caller(size, flags, node, \
70702 _RET_IP_)
70703 diff --git a/include/linux/slab_def.h b/include/linux/slab_def.h
70704 index 8bb6e0e..8eb0dbe 100644
70705 --- a/include/linux/slab_def.h
70706 +++ b/include/linux/slab_def.h
70707 @@ -52,7 +52,7 @@ struct kmem_cache {
70708 /* 4) cache creation/removal */
70709 const char *name;
70710 struct list_head list;
70711 - int refcount;
70712 + atomic_t refcount;
70713 int object_size;
70714 int align;
70715
70716 @@ -68,10 +68,10 @@ struct kmem_cache {
70717 unsigned long node_allocs;
70718 unsigned long node_frees;
70719 unsigned long node_overflow;
70720 - atomic_t allochit;
70721 - atomic_t allocmiss;
70722 - atomic_t freehit;
70723 - atomic_t freemiss;
70724 + atomic_unchecked_t allochit;
70725 + atomic_unchecked_t allocmiss;
70726 + atomic_unchecked_t freehit;
70727 + atomic_unchecked_t freemiss;
70728
70729 /*
70730 * If debugging is enabled, then the allocator can add additional
70731 @@ -111,11 +111,16 @@ struct cache_sizes {
70732 #ifdef CONFIG_ZONE_DMA
70733 struct kmem_cache *cs_dmacachep;
70734 #endif
70735 +
70736 +#ifdef CONFIG_PAX_USERCOPY_SLABS
70737 + struct kmem_cache *cs_usercopycachep;
70738 +#endif
70739 +
70740 };
70741 extern struct cache_sizes malloc_sizes[];
70742
70743 void *kmem_cache_alloc(struct kmem_cache *, gfp_t);
70744 -void *__kmalloc(size_t size, gfp_t flags);
70745 +void *__kmalloc(size_t size, gfp_t flags) __size_overflow(1);
70746
70747 #ifdef CONFIG_TRACING
70748 extern void *kmem_cache_alloc_trace(struct kmem_cache *, gfp_t, size_t);
70749 @@ -152,6 +157,13 @@ found:
70750 cachep = malloc_sizes[i].cs_dmacachep;
70751 else
70752 #endif
70753 +
70754 +#ifdef CONFIG_PAX_USERCOPY_SLABS
70755 + if (flags & GFP_USERCOPY)
70756 + cachep = malloc_sizes[i].cs_usercopycachep;
70757 + else
70758 +#endif
70759 +
70760 cachep = malloc_sizes[i].cs_cachep;
70761
70762 ret = kmem_cache_alloc_trace(cachep, flags, size);
70763 @@ -162,7 +174,7 @@ found:
70764 }
70765
70766 #ifdef CONFIG_NUMA
70767 -extern void *__kmalloc_node(size_t size, gfp_t flags, int node);
70768 +extern void *__kmalloc_node(size_t size, gfp_t flags, int node) __size_overflow(1);
70769 extern void *kmem_cache_alloc_node(struct kmem_cache *, gfp_t flags, int node);
70770
70771 #ifdef CONFIG_TRACING
70772 @@ -205,6 +217,13 @@ found:
70773 cachep = malloc_sizes[i].cs_dmacachep;
70774 else
70775 #endif
70776 +
70777 +#ifdef CONFIG_PAX_USERCOPY_SLABS
70778 + if (flags & GFP_USERCOPY)
70779 + cachep = malloc_sizes[i].cs_usercopycachep;
70780 + else
70781 +#endif
70782 +
70783 cachep = malloc_sizes[i].cs_cachep;
70784
70785 return kmem_cache_alloc_node_trace(cachep, flags, node, size);
70786 diff --git a/include/linux/slob_def.h b/include/linux/slob_def.h
70787 index f28e14a..7831211 100644
70788 --- a/include/linux/slob_def.h
70789 +++ b/include/linux/slob_def.h
70790 @@ -11,7 +11,7 @@ static __always_inline void *kmem_cache_alloc(struct kmem_cache *cachep,
70791 return kmem_cache_alloc_node(cachep, flags, NUMA_NO_NODE);
70792 }
70793
70794 -void *__kmalloc_node(size_t size, gfp_t flags, int node);
70795 +void *__kmalloc_node(size_t size, gfp_t flags, int node) __size_overflow(1);
70796
70797 static __always_inline void *kmalloc_node(size_t size, gfp_t flags, int node)
70798 {
70799 @@ -31,7 +31,7 @@ static __always_inline void *kmalloc(size_t size, gfp_t flags)
70800 return __kmalloc_node(size, flags, NUMA_NO_NODE);
70801 }
70802
70803 -static __always_inline void *__kmalloc(size_t size, gfp_t flags)
70804 +static __always_inline __size_overflow(1) void *__kmalloc(size_t size, gfp_t flags)
70805 {
70806 return kmalloc(size, flags);
70807 }
70808 diff --git a/include/linux/slub_def.h b/include/linux/slub_def.h
70809 index 9db4825..ed42fb5 100644
70810 --- a/include/linux/slub_def.h
70811 +++ b/include/linux/slub_def.h
70812 @@ -91,7 +91,7 @@ struct kmem_cache {
70813 struct kmem_cache_order_objects max;
70814 struct kmem_cache_order_objects min;
70815 gfp_t allocflags; /* gfp flags to use on each alloc */
70816 - int refcount; /* Refcount for slab cache destroy */
70817 + atomic_t refcount; /* Refcount for slab cache destroy */
70818 void (*ctor)(void *);
70819 int inuse; /* Offset to metadata */
70820 int align; /* Alignment */
70821 @@ -156,7 +156,7 @@ extern struct kmem_cache *kmalloc_caches[SLUB_PAGE_SHIFT];
70822 * Sorry that the following has to be that ugly but some versions of GCC
70823 * have trouble with constant propagation and loops.
70824 */
70825 -static __always_inline int kmalloc_index(size_t size)
70826 +static __always_inline __size_overflow(1) int kmalloc_index(size_t size)
70827 {
70828 if (!size)
70829 return 0;
70830 @@ -221,7 +221,7 @@ static __always_inline struct kmem_cache *kmalloc_slab(size_t size)
70831 }
70832
70833 void *kmem_cache_alloc(struct kmem_cache *, gfp_t);
70834 -void *__kmalloc(size_t size, gfp_t flags);
70835 +void *__kmalloc(size_t size, gfp_t flags) __alloc_size(1) __size_overflow(1);
70836
70837 static __always_inline void *
70838 kmalloc_order(size_t size, gfp_t flags, unsigned int order)
70839 @@ -265,7 +265,7 @@ kmalloc_order_trace(size_t size, gfp_t flags, unsigned int order)
70840 }
70841 #endif
70842
70843 -static __always_inline void *kmalloc_large(size_t size, gfp_t flags)
70844 +static __always_inline __size_overflow(1) void *kmalloc_large(size_t size, gfp_t flags)
70845 {
70846 unsigned int order = get_order(size);
70847 return kmalloc_order_trace(size, flags, order);
70848 @@ -290,7 +290,7 @@ static __always_inline void *kmalloc(size_t size, gfp_t flags)
70849 }
70850
70851 #ifdef CONFIG_NUMA
70852 -void *__kmalloc_node(size_t size, gfp_t flags, int node);
70853 +void *__kmalloc_node(size_t size, gfp_t flags, int node) __size_overflow(1);
70854 void *kmem_cache_alloc_node(struct kmem_cache *, gfp_t flags, int node);
70855
70856 #ifdef CONFIG_TRACING
70857 diff --git a/include/linux/sock_diag.h b/include/linux/sock_diag.h
70858 index e8d702e..0a56eb4 100644
70859 --- a/include/linux/sock_diag.h
70860 +++ b/include/linux/sock_diag.h
70861 @@ -10,7 +10,7 @@ struct sock;
70862 struct sock_diag_handler {
70863 __u8 family;
70864 int (*dump)(struct sk_buff *skb, struct nlmsghdr *nlh);
70865 -};
70866 +} __do_const;
70867
70868 int sock_diag_register(const struct sock_diag_handler *h);
70869 void sock_diag_unregister(const struct sock_diag_handler *h);
70870 diff --git a/include/linux/sonet.h b/include/linux/sonet.h
70871 index 680f9a3..f13aeb0 100644
70872 --- a/include/linux/sonet.h
70873 +++ b/include/linux/sonet.h
70874 @@ -7,7 +7,7 @@
70875 #include <uapi/linux/sonet.h>
70876
70877 struct k_sonet_stats {
70878 -#define __HANDLE_ITEM(i) atomic_t i
70879 +#define __HANDLE_ITEM(i) atomic_unchecked_t i
70880 __SONET_ITEMS
70881 #undef __HANDLE_ITEM
70882 };
70883 diff --git a/include/linux/sunrpc/clnt.h b/include/linux/sunrpc/clnt.h
70884 index 34206b8..3db7f1c 100644
70885 --- a/include/linux/sunrpc/clnt.h
70886 +++ b/include/linux/sunrpc/clnt.h
70887 @@ -96,7 +96,7 @@ struct rpc_procinfo {
70888 unsigned int p_timer; /* Which RTT timer to use */
70889 u32 p_statidx; /* Which procedure to account */
70890 const char * p_name; /* name of procedure */
70891 -};
70892 +} __do_const;
70893
70894 #ifdef __KERNEL__
70895
70896 @@ -176,9 +176,9 @@ static inline unsigned short rpc_get_port(const struct sockaddr *sap)
70897 {
70898 switch (sap->sa_family) {
70899 case AF_INET:
70900 - return ntohs(((struct sockaddr_in *)sap)->sin_port);
70901 + return ntohs(((const struct sockaddr_in *)sap)->sin_port);
70902 case AF_INET6:
70903 - return ntohs(((struct sockaddr_in6 *)sap)->sin6_port);
70904 + return ntohs(((const struct sockaddr_in6 *)sap)->sin6_port);
70905 }
70906 return 0;
70907 }
70908 @@ -211,7 +211,7 @@ static inline bool __rpc_cmp_addr4(const struct sockaddr *sap1,
70909 static inline bool __rpc_copy_addr4(struct sockaddr *dst,
70910 const struct sockaddr *src)
70911 {
70912 - const struct sockaddr_in *ssin = (struct sockaddr_in *) src;
70913 + const struct sockaddr_in *ssin = (const struct sockaddr_in *) src;
70914 struct sockaddr_in *dsin = (struct sockaddr_in *) dst;
70915
70916 dsin->sin_family = ssin->sin_family;
70917 @@ -314,7 +314,7 @@ static inline u32 rpc_get_scope_id(const struct sockaddr *sa)
70918 if (sa->sa_family != AF_INET6)
70919 return 0;
70920
70921 - return ((struct sockaddr_in6 *) sa)->sin6_scope_id;
70922 + return ((const struct sockaddr_in6 *) sa)->sin6_scope_id;
70923 }
70924
70925 #endif /* __KERNEL__ */
70926 diff --git a/include/linux/sunrpc/svc.h b/include/linux/sunrpc/svc.h
70927 index 676ddf5..4c519a1 100644
70928 --- a/include/linux/sunrpc/svc.h
70929 +++ b/include/linux/sunrpc/svc.h
70930 @@ -410,7 +410,7 @@ struct svc_procedure {
70931 unsigned int pc_count; /* call count */
70932 unsigned int pc_cachetype; /* cache info (NFS) */
70933 unsigned int pc_xdrressize; /* maximum size of XDR reply */
70934 -};
70935 +} __do_const;
70936
70937 /*
70938 * Function prototypes.
70939 diff --git a/include/linux/sunrpc/svc_rdma.h b/include/linux/sunrpc/svc_rdma.h
70940 index 0b8e3e6..33e0a01 100644
70941 --- a/include/linux/sunrpc/svc_rdma.h
70942 +++ b/include/linux/sunrpc/svc_rdma.h
70943 @@ -53,15 +53,15 @@ extern unsigned int svcrdma_ord;
70944 extern unsigned int svcrdma_max_requests;
70945 extern unsigned int svcrdma_max_req_size;
70946
70947 -extern atomic_t rdma_stat_recv;
70948 -extern atomic_t rdma_stat_read;
70949 -extern atomic_t rdma_stat_write;
70950 -extern atomic_t rdma_stat_sq_starve;
70951 -extern atomic_t rdma_stat_rq_starve;
70952 -extern atomic_t rdma_stat_rq_poll;
70953 -extern atomic_t rdma_stat_rq_prod;
70954 -extern atomic_t rdma_stat_sq_poll;
70955 -extern atomic_t rdma_stat_sq_prod;
70956 +extern atomic_unchecked_t rdma_stat_recv;
70957 +extern atomic_unchecked_t rdma_stat_read;
70958 +extern atomic_unchecked_t rdma_stat_write;
70959 +extern atomic_unchecked_t rdma_stat_sq_starve;
70960 +extern atomic_unchecked_t rdma_stat_rq_starve;
70961 +extern atomic_unchecked_t rdma_stat_rq_poll;
70962 +extern atomic_unchecked_t rdma_stat_rq_prod;
70963 +extern atomic_unchecked_t rdma_stat_sq_poll;
70964 +extern atomic_unchecked_t rdma_stat_sq_prod;
70965
70966 #define RPCRDMA_VERSION 1
70967
70968 diff --git a/include/linux/sunrpc/svcauth.h b/include/linux/sunrpc/svcauth.h
70969 index dd74084a..7f509d5 100644
70970 --- a/include/linux/sunrpc/svcauth.h
70971 +++ b/include/linux/sunrpc/svcauth.h
70972 @@ -109,7 +109,7 @@ struct auth_ops {
70973 int (*release)(struct svc_rqst *rq);
70974 void (*domain_release)(struct auth_domain *);
70975 int (*set_client)(struct svc_rqst *rq);
70976 -};
70977 +} __do_const;
70978
70979 #define SVC_GARBAGE 1
70980 #define SVC_SYSERR 2
70981 diff --git a/include/linux/swiotlb.h b/include/linux/swiotlb.h
70982 index 071d62c..4ccc7ac 100644
70983 --- a/include/linux/swiotlb.h
70984 +++ b/include/linux/swiotlb.h
70985 @@ -59,7 +59,8 @@ extern void
70986
70987 extern void
70988 swiotlb_free_coherent(struct device *hwdev, size_t size,
70989 - void *vaddr, dma_addr_t dma_handle);
70990 + void *vaddr, dma_addr_t dma_handle,
70991 + struct dma_attrs *attrs);
70992
70993 extern dma_addr_t swiotlb_map_page(struct device *dev, struct page *page,
70994 unsigned long offset, size_t size,
70995 diff --git a/include/linux/syscore_ops.h b/include/linux/syscore_ops.h
70996 index 27b3b0b..e093dd9 100644
70997 --- a/include/linux/syscore_ops.h
70998 +++ b/include/linux/syscore_ops.h
70999 @@ -16,7 +16,7 @@ struct syscore_ops {
71000 int (*suspend)(void);
71001 void (*resume)(void);
71002 void (*shutdown)(void);
71003 -};
71004 +} __do_const;
71005
71006 extern void register_syscore_ops(struct syscore_ops *ops);
71007 extern void unregister_syscore_ops(struct syscore_ops *ops);
71008 diff --git a/include/linux/sysctl.h b/include/linux/sysctl.h
71009 index 14a8ff2..af52bad 100644
71010 --- a/include/linux/sysctl.h
71011 +++ b/include/linux/sysctl.h
71012 @@ -34,13 +34,13 @@ struct ctl_table_root;
71013 struct ctl_table_header;
71014 struct ctl_dir;
71015
71016 -typedef struct ctl_table ctl_table;
71017 -
71018 typedef int proc_handler (struct ctl_table *ctl, int write,
71019 void __user *buffer, size_t *lenp, loff_t *ppos);
71020
71021 extern int proc_dostring(struct ctl_table *, int,
71022 void __user *, size_t *, loff_t *);
71023 +extern int proc_dostring_modpriv(struct ctl_table *, int,
71024 + void __user *, size_t *, loff_t *);
71025 extern int proc_dointvec(struct ctl_table *, int,
71026 void __user *, size_t *, loff_t *);
71027 extern int proc_dointvec_minmax(struct ctl_table *, int,
71028 @@ -115,7 +115,9 @@ struct ctl_table
71029 struct ctl_table_poll *poll;
71030 void *extra1;
71031 void *extra2;
71032 -};
71033 +} __do_const;
71034 +typedef struct ctl_table __no_const ctl_table_no_const;
71035 +typedef struct ctl_table ctl_table;
71036
71037 struct ctl_node {
71038 struct rb_node node;
71039 diff --git a/include/linux/sysfs.h b/include/linux/sysfs.h
71040 index 381f06d..dc16cc7 100644
71041 --- a/include/linux/sysfs.h
71042 +++ b/include/linux/sysfs.h
71043 @@ -31,7 +31,8 @@ struct attribute {
71044 struct lock_class_key *key;
71045 struct lock_class_key skey;
71046 #endif
71047 -};
71048 +} __do_const;
71049 +typedef struct attribute __no_const attribute_no_const;
71050
71051 /**
71052 * sysfs_attr_init - initialize a dynamically allocated sysfs attribute
71053 @@ -59,8 +60,8 @@ struct attribute_group {
71054 umode_t (*is_visible)(struct kobject *,
71055 struct attribute *, int);
71056 struct attribute **attrs;
71057 -};
71058 -
71059 +} __do_const;
71060 +typedef struct attribute_group __no_const attribute_group_no_const;
71061
71062
71063 /**
71064 @@ -107,7 +108,8 @@ struct bin_attribute {
71065 char *, loff_t, size_t);
71066 int (*mmap)(struct file *, struct kobject *, struct bin_attribute *attr,
71067 struct vm_area_struct *vma);
71068 -};
71069 +} __do_const;
71070 +typedef struct bin_attribute __no_const bin_attribute_no_const;
71071
71072 /**
71073 * sysfs_bin_attr_init - initialize a dynamically allocated bin_attribute
71074 diff --git a/include/linux/sysrq.h b/include/linux/sysrq.h
71075 index 7faf933..4657127 100644
71076 --- a/include/linux/sysrq.h
71077 +++ b/include/linux/sysrq.h
71078 @@ -15,7 +15,9 @@
71079 #define _LINUX_SYSRQ_H
71080
71081 #include <linux/errno.h>
71082 +#include <linux/compiler.h>
71083 #include <linux/types.h>
71084 +#include <linux/compiler.h>
71085
71086 /* Enable/disable SYSRQ support by default (0==no, 1==yes). */
71087 #define SYSRQ_DEFAULT_ENABLE 1
71088 @@ -36,7 +38,7 @@ struct sysrq_key_op {
71089 char *help_msg;
71090 char *action_msg;
71091 int enable_mask;
71092 -};
71093 +} __do_const;
71094
71095 #ifdef CONFIG_MAGIC_SYSRQ
71096
71097 diff --git a/include/linux/thread_info.h b/include/linux/thread_info.h
71098 index e7e0473..39b7b52 100644
71099 --- a/include/linux/thread_info.h
71100 +++ b/include/linux/thread_info.h
71101 @@ -148,6 +148,15 @@ static inline bool test_and_clear_restore_sigmask(void)
71102 #error "no set_restore_sigmask() provided and default one won't work"
71103 #endif
71104
71105 +extern void __check_object_size(const void *ptr, unsigned long n, bool to);
71106 +static inline void check_object_size(const void *ptr, unsigned long n, bool to)
71107 +{
71108 +#ifndef CONFIG_PAX_USERCOPY_DEBUG
71109 + if (!__builtin_constant_p(n))
71110 +#endif
71111 + __check_object_size(ptr, n, to);
71112 +}
71113 +
71114 #endif /* __KERNEL__ */
71115
71116 #endif /* _LINUX_THREAD_INFO_H */
71117 diff --git a/include/linux/tty.h b/include/linux/tty.h
71118 index 8db1b56..c16a040 100644
71119 --- a/include/linux/tty.h
71120 +++ b/include/linux/tty.h
71121 @@ -194,7 +194,7 @@ struct tty_port {
71122 const struct tty_port_operations *ops; /* Port operations */
71123 spinlock_t lock; /* Lock protecting tty field */
71124 int blocked_open; /* Waiting to open */
71125 - int count; /* Usage count */
71126 + atomic_t count; /* Usage count */
71127 wait_queue_head_t open_wait; /* Open waiters */
71128 wait_queue_head_t close_wait; /* Close waiters */
71129 wait_queue_head_t delta_msr_wait; /* Modem status change */
71130 @@ -490,7 +490,7 @@ extern int tty_port_open(struct tty_port *port,
71131 struct tty_struct *tty, struct file *filp);
71132 static inline int tty_port_users(struct tty_port *port)
71133 {
71134 - return port->count + port->blocked_open;
71135 + return atomic_read(&port->count) + port->blocked_open;
71136 }
71137
71138 extern int tty_register_ldisc(int disc, struct tty_ldisc_ops *new_ldisc);
71139 diff --git a/include/linux/tty_driver.h b/include/linux/tty_driver.h
71140 index dd976cf..e272742 100644
71141 --- a/include/linux/tty_driver.h
71142 +++ b/include/linux/tty_driver.h
71143 @@ -284,7 +284,7 @@ struct tty_operations {
71144 void (*poll_put_char)(struct tty_driver *driver, int line, char ch);
71145 #endif
71146 const struct file_operations *proc_fops;
71147 -};
71148 +} __do_const;
71149
71150 struct tty_driver {
71151 int magic; /* magic number for this structure */
71152 diff --git a/include/linux/tty_ldisc.h b/include/linux/tty_ldisc.h
71153 index fb79dd8d..07d4773 100644
71154 --- a/include/linux/tty_ldisc.h
71155 +++ b/include/linux/tty_ldisc.h
71156 @@ -149,7 +149,7 @@ struct tty_ldisc_ops {
71157
71158 struct module *owner;
71159
71160 - int refcount;
71161 + atomic_t refcount;
71162 };
71163
71164 struct tty_ldisc {
71165 diff --git a/include/linux/types.h b/include/linux/types.h
71166 index 4d118ba..c3ee9bf 100644
71167 --- a/include/linux/types.h
71168 +++ b/include/linux/types.h
71169 @@ -176,10 +176,26 @@ typedef struct {
71170 int counter;
71171 } atomic_t;
71172
71173 +#ifdef CONFIG_PAX_REFCOUNT
71174 +typedef struct {
71175 + int counter;
71176 +} atomic_unchecked_t;
71177 +#else
71178 +typedef atomic_t atomic_unchecked_t;
71179 +#endif
71180 +
71181 #ifdef CONFIG_64BIT
71182 typedef struct {
71183 long counter;
71184 } atomic64_t;
71185 +
71186 +#ifdef CONFIG_PAX_REFCOUNT
71187 +typedef struct {
71188 + long counter;
71189 +} atomic64_unchecked_t;
71190 +#else
71191 +typedef atomic64_t atomic64_unchecked_t;
71192 +#endif
71193 #endif
71194
71195 struct list_head {
71196 diff --git a/include/linux/uaccess.h b/include/linux/uaccess.h
71197 index 5ca0951..ab496a5 100644
71198 --- a/include/linux/uaccess.h
71199 +++ b/include/linux/uaccess.h
71200 @@ -76,11 +76,11 @@ static inline unsigned long __copy_from_user_nocache(void *to,
71201 long ret; \
71202 mm_segment_t old_fs = get_fs(); \
71203 \
71204 - set_fs(KERNEL_DS); \
71205 pagefault_disable(); \
71206 - ret = __copy_from_user_inatomic(&(retval), (__force typeof(retval) __user *)(addr), sizeof(retval)); \
71207 - pagefault_enable(); \
71208 + set_fs(KERNEL_DS); \
71209 + ret = __copy_from_user_inatomic(&(retval), (typeof(retval) __force_user *)(addr), sizeof(retval)); \
71210 set_fs(old_fs); \
71211 + pagefault_enable(); \
71212 ret; \
71213 })
71214
71215 diff --git a/include/linux/uidgid.h b/include/linux/uidgid.h
71216 index 8e522cbc..aa8572d 100644
71217 --- a/include/linux/uidgid.h
71218 +++ b/include/linux/uidgid.h
71219 @@ -197,4 +197,9 @@ static inline bool kgid_has_mapping(struct user_namespace *ns, kgid_t gid)
71220
71221 #endif /* CONFIG_USER_NS */
71222
71223 +#define GR_GLOBAL_UID(x) from_kuid_munged(&init_user_ns, (x))
71224 +#define GR_GLOBAL_GID(x) from_kgid_munged(&init_user_ns, (x))
71225 +#define gr_is_global_root(x) uid_eq((x), GLOBAL_ROOT_UID)
71226 +#define gr_is_global_nonroot(x) (!uid_eq((x), GLOBAL_ROOT_UID))
71227 +
71228 #endif /* _LINUX_UIDGID_H */
71229 diff --git a/include/linux/unaligned/access_ok.h b/include/linux/unaligned/access_ok.h
71230 index 99c1b4d..562e6f3 100644
71231 --- a/include/linux/unaligned/access_ok.h
71232 +++ b/include/linux/unaligned/access_ok.h
71233 @@ -4,34 +4,34 @@
71234 #include <linux/kernel.h>
71235 #include <asm/byteorder.h>
71236
71237 -static inline u16 get_unaligned_le16(const void *p)
71238 +static inline u16 __intentional_overflow(-1) get_unaligned_le16(const void *p)
71239 {
71240 - return le16_to_cpup((__le16 *)p);
71241 + return le16_to_cpup((const __le16 *)p);
71242 }
71243
71244 -static inline u32 get_unaligned_le32(const void *p)
71245 +static inline u32 __intentional_overflow(-1) get_unaligned_le32(const void *p)
71246 {
71247 - return le32_to_cpup((__le32 *)p);
71248 + return le32_to_cpup((const __le32 *)p);
71249 }
71250
71251 -static inline u64 get_unaligned_le64(const void *p)
71252 +static inline u64 __intentional_overflow(-1) get_unaligned_le64(const void *p)
71253 {
71254 - return le64_to_cpup((__le64 *)p);
71255 + return le64_to_cpup((const __le64 *)p);
71256 }
71257
71258 -static inline u16 get_unaligned_be16(const void *p)
71259 +static inline u16 __intentional_overflow(-1) get_unaligned_be16(const void *p)
71260 {
71261 - return be16_to_cpup((__be16 *)p);
71262 + return be16_to_cpup((const __be16 *)p);
71263 }
71264
71265 -static inline u32 get_unaligned_be32(const void *p)
71266 +static inline u32 __intentional_overflow(-1) get_unaligned_be32(const void *p)
71267 {
71268 - return be32_to_cpup((__be32 *)p);
71269 + return be32_to_cpup((const __be32 *)p);
71270 }
71271
71272 -static inline u64 get_unaligned_be64(const void *p)
71273 +static inline u64 __intentional_overflow(-1) get_unaligned_be64(const void *p)
71274 {
71275 - return be64_to_cpup((__be64 *)p);
71276 + return be64_to_cpup((const __be64 *)p);
71277 }
71278
71279 static inline void put_unaligned_le16(u16 val, void *p)
71280 diff --git a/include/linux/usb.h b/include/linux/usb.h
71281 index 4d22d0f..8d0e8f8 100644
71282 --- a/include/linux/usb.h
71283 +++ b/include/linux/usb.h
71284 @@ -554,7 +554,7 @@ struct usb_device {
71285 int maxchild;
71286
71287 u32 quirks;
71288 - atomic_t urbnum;
71289 + atomic_unchecked_t urbnum;
71290
71291 unsigned long active_duration;
71292
71293 @@ -1604,7 +1604,7 @@ void usb_buffer_unmap_sg(const struct usb_device *dev, int is_in,
71294
71295 extern int usb_control_msg(struct usb_device *dev, unsigned int pipe,
71296 __u8 request, __u8 requesttype, __u16 value, __u16 index,
71297 - void *data, __u16 size, int timeout);
71298 + void *data, __u16 size, int timeout) __intentional_overflow(-1);
71299 extern int usb_interrupt_msg(struct usb_device *usb_dev, unsigned int pipe,
71300 void *data, int len, int *actual_length, int timeout);
71301 extern int usb_bulk_msg(struct usb_device *usb_dev, unsigned int pipe,
71302 diff --git a/include/linux/usb/renesas_usbhs.h b/include/linux/usb/renesas_usbhs.h
71303 index c5d36c6..108f4f9 100644
71304 --- a/include/linux/usb/renesas_usbhs.h
71305 +++ b/include/linux/usb/renesas_usbhs.h
71306 @@ -39,7 +39,7 @@ enum {
71307 */
71308 struct renesas_usbhs_driver_callback {
71309 int (*notify_hotplug)(struct platform_device *pdev);
71310 -};
71311 +} __no_const;
71312
71313 /*
71314 * callback functions for platform
71315 diff --git a/include/linux/user_namespace.h b/include/linux/user_namespace.h
71316 index b9bd2e6..4ce0093 100644
71317 --- a/include/linux/user_namespace.h
71318 +++ b/include/linux/user_namespace.h
71319 @@ -21,7 +21,7 @@ struct user_namespace {
71320 struct uid_gid_map uid_map;
71321 struct uid_gid_map gid_map;
71322 struct uid_gid_map projid_map;
71323 - struct kref kref;
71324 + atomic_t count;
71325 struct user_namespace *parent;
71326 kuid_t owner;
71327 kgid_t group;
71328 @@ -35,18 +35,18 @@ extern struct user_namespace init_user_ns;
71329 static inline struct user_namespace *get_user_ns(struct user_namespace *ns)
71330 {
71331 if (ns)
71332 - kref_get(&ns->kref);
71333 + atomic_inc(&ns->count);
71334 return ns;
71335 }
71336
71337 extern int create_user_ns(struct cred *new);
71338 extern int unshare_userns(unsigned long unshare_flags, struct cred **new_cred);
71339 -extern void free_user_ns(struct kref *kref);
71340 +extern void free_user_ns(struct user_namespace *ns);
71341
71342 static inline void put_user_ns(struct user_namespace *ns)
71343 {
71344 - if (ns)
71345 - kref_put(&ns->kref, free_user_ns);
71346 + if (ns && atomic_dec_and_test(&ns->count))
71347 + free_user_ns(ns);
71348 }
71349
71350 struct seq_operations;
71351 diff --git a/include/linux/vermagic.h b/include/linux/vermagic.h
71352 index 6f8fbcf..8259001 100644
71353 --- a/include/linux/vermagic.h
71354 +++ b/include/linux/vermagic.h
71355 @@ -25,9 +25,35 @@
71356 #define MODULE_ARCH_VERMAGIC ""
71357 #endif
71358
71359 +#ifdef CONFIG_PAX_REFCOUNT
71360 +#define MODULE_PAX_REFCOUNT "REFCOUNT "
71361 +#else
71362 +#define MODULE_PAX_REFCOUNT ""
71363 +#endif
71364 +
71365 +#ifdef CONSTIFY_PLUGIN
71366 +#define MODULE_CONSTIFY_PLUGIN "CONSTIFY_PLUGIN "
71367 +#else
71368 +#define MODULE_CONSTIFY_PLUGIN ""
71369 +#endif
71370 +
71371 +#ifdef STACKLEAK_PLUGIN
71372 +#define MODULE_STACKLEAK_PLUGIN "STACKLEAK_PLUGIN "
71373 +#else
71374 +#define MODULE_STACKLEAK_PLUGIN ""
71375 +#endif
71376 +
71377 +#ifdef CONFIG_GRKERNSEC
71378 +#define MODULE_GRSEC "GRSEC "
71379 +#else
71380 +#define MODULE_GRSEC ""
71381 +#endif
71382 +
71383 #define VERMAGIC_STRING \
71384 UTS_RELEASE " " \
71385 MODULE_VERMAGIC_SMP MODULE_VERMAGIC_PREEMPT \
71386 MODULE_VERMAGIC_MODULE_UNLOAD MODULE_VERMAGIC_MODVERSIONS \
71387 - MODULE_ARCH_VERMAGIC
71388 + MODULE_ARCH_VERMAGIC \
71389 + MODULE_PAX_REFCOUNT MODULE_CONSTIFY_PLUGIN MODULE_STACKLEAK_PLUGIN \
71390 + MODULE_GRSEC
71391
71392 diff --git a/include/linux/vmalloc.h b/include/linux/vmalloc.h
71393 index 6071e91..ca6a489 100644
71394 --- a/include/linux/vmalloc.h
71395 +++ b/include/linux/vmalloc.h
71396 @@ -14,6 +14,11 @@ struct vm_area_struct; /* vma defining user mapping in mm_types.h */
71397 #define VM_USERMAP 0x00000008 /* suitable for remap_vmalloc_range */
71398 #define VM_VPAGES 0x00000010 /* buffer for pages was vmalloc'ed */
71399 #define VM_UNLIST 0x00000020 /* vm_struct is not listed in vmlist */
71400 +
71401 +#if defined(CONFIG_MODULES) && defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
71402 +#define VM_KERNEXEC 0x00000040 /* allocate from executable kernel memory range */
71403 +#endif
71404 +
71405 /* bits [20..32] reserved for arch specific ioremap internals */
71406
71407 /*
71408 @@ -62,7 +67,7 @@ extern void *vmalloc_32_user(unsigned long size);
71409 extern void *__vmalloc(unsigned long size, gfp_t gfp_mask, pgprot_t prot);
71410 extern void *__vmalloc_node_range(unsigned long size, unsigned long align,
71411 unsigned long start, unsigned long end, gfp_t gfp_mask,
71412 - pgprot_t prot, int node, const void *caller);
71413 + pgprot_t prot, int node, const void *caller) __size_overflow(1);
71414 extern void vfree(const void *addr);
71415
71416 extern void *vmap(struct page **pages, unsigned int count,
71417 @@ -124,8 +129,8 @@ extern struct vm_struct *alloc_vm_area(size_t size, pte_t **ptes);
71418 extern void free_vm_area(struct vm_struct *area);
71419
71420 /* for /dev/kmem */
71421 -extern long vread(char *buf, char *addr, unsigned long count);
71422 -extern long vwrite(char *buf, char *addr, unsigned long count);
71423 +extern long vread(char *buf, char *addr, unsigned long count) __size_overflow(3);
71424 +extern long vwrite(char *buf, char *addr, unsigned long count) __size_overflow(3);
71425
71426 /*
71427 * Internals. Dont't use..
71428 diff --git a/include/linux/vmstat.h b/include/linux/vmstat.h
71429 index a13291f..af51fa3 100644
71430 --- a/include/linux/vmstat.h
71431 +++ b/include/linux/vmstat.h
71432 @@ -95,18 +95,18 @@ static inline void vm_events_fold_cpu(int cpu)
71433 /*
71434 * Zone based page accounting with per cpu differentials.
71435 */
71436 -extern atomic_long_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
71437 +extern atomic_long_unchecked_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
71438
71439 static inline void zone_page_state_add(long x, struct zone *zone,
71440 enum zone_stat_item item)
71441 {
71442 - atomic_long_add(x, &zone->vm_stat[item]);
71443 - atomic_long_add(x, &vm_stat[item]);
71444 + atomic_long_add_unchecked(x, &zone->vm_stat[item]);
71445 + atomic_long_add_unchecked(x, &vm_stat[item]);
71446 }
71447
71448 static inline unsigned long global_page_state(enum zone_stat_item item)
71449 {
71450 - long x = atomic_long_read(&vm_stat[item]);
71451 + long x = atomic_long_read_unchecked(&vm_stat[item]);
71452 #ifdef CONFIG_SMP
71453 if (x < 0)
71454 x = 0;
71455 @@ -117,7 +117,7 @@ static inline unsigned long global_page_state(enum zone_stat_item item)
71456 static inline unsigned long zone_page_state(struct zone *zone,
71457 enum zone_stat_item item)
71458 {
71459 - long x = atomic_long_read(&zone->vm_stat[item]);
71460 + long x = atomic_long_read_unchecked(&zone->vm_stat[item]);
71461 #ifdef CONFIG_SMP
71462 if (x < 0)
71463 x = 0;
71464 @@ -134,7 +134,7 @@ static inline unsigned long zone_page_state(struct zone *zone,
71465 static inline unsigned long zone_page_state_snapshot(struct zone *zone,
71466 enum zone_stat_item item)
71467 {
71468 - long x = atomic_long_read(&zone->vm_stat[item]);
71469 + long x = atomic_long_read_unchecked(&zone->vm_stat[item]);
71470
71471 #ifdef CONFIG_SMP
71472 int cpu;
71473 @@ -226,8 +226,8 @@ static inline void __mod_zone_page_state(struct zone *zone,
71474
71475 static inline void __inc_zone_state(struct zone *zone, enum zone_stat_item item)
71476 {
71477 - atomic_long_inc(&zone->vm_stat[item]);
71478 - atomic_long_inc(&vm_stat[item]);
71479 + atomic_long_inc_unchecked(&zone->vm_stat[item]);
71480 + atomic_long_inc_unchecked(&vm_stat[item]);
71481 }
71482
71483 static inline void __inc_zone_page_state(struct page *page,
71484 @@ -238,8 +238,8 @@ static inline void __inc_zone_page_state(struct page *page,
71485
71486 static inline void __dec_zone_state(struct zone *zone, enum zone_stat_item item)
71487 {
71488 - atomic_long_dec(&zone->vm_stat[item]);
71489 - atomic_long_dec(&vm_stat[item]);
71490 + atomic_long_dec_unchecked(&zone->vm_stat[item]);
71491 + atomic_long_dec_unchecked(&vm_stat[item]);
71492 }
71493
71494 static inline void __dec_zone_page_state(struct page *page,
71495 diff --git a/include/linux/xattr.h b/include/linux/xattr.h
71496 index fdbafc6..b7ffd47 100644
71497 --- a/include/linux/xattr.h
71498 +++ b/include/linux/xattr.h
71499 @@ -28,7 +28,7 @@ struct xattr_handler {
71500 size_t size, int handler_flags);
71501 int (*set)(struct dentry *dentry, const char *name, const void *buffer,
71502 size_t size, int flags, int handler_flags);
71503 -};
71504 +} __do_const;
71505
71506 struct xattr {
71507 char *name;
71508 diff --git a/include/linux/zlib.h b/include/linux/zlib.h
71509 index 9c5a6b4..67259c9 100644
71510 --- a/include/linux/zlib.h
71511 +++ b/include/linux/zlib.h
71512 @@ -179,7 +179,7 @@ typedef z_stream *z_streamp;
71513
71514 /* basic functions */
71515
71516 -extern int zlib_deflate_workspacesize (int windowBits, int memLevel);
71517 +extern int zlib_deflate_workspacesize (int windowBits, int memLevel) __intentional_overflow(0);
71518 /*
71519 Returns the number of bytes that needs to be allocated for a per-
71520 stream workspace with the specified parameters. A pointer to this
71521 diff --git a/include/media/v4l2-dev.h b/include/media/v4l2-dev.h
71522 index 95d1c91..6798cca 100644
71523 --- a/include/media/v4l2-dev.h
71524 +++ b/include/media/v4l2-dev.h
71525 @@ -76,7 +76,7 @@ struct v4l2_file_operations {
71526 int (*mmap) (struct file *, struct vm_area_struct *);
71527 int (*open) (struct file *);
71528 int (*release) (struct file *);
71529 -};
71530 +} __do_const;
71531
71532 /*
71533 * Newer version of video_device, handled by videodev2.c
71534 diff --git a/include/media/v4l2-ioctl.h b/include/media/v4l2-ioctl.h
71535 index 4118ad1..cb7e25f 100644
71536 --- a/include/media/v4l2-ioctl.h
71537 +++ b/include/media/v4l2-ioctl.h
71538 @@ -284,7 +284,6 @@ struct v4l2_ioctl_ops {
71539 bool valid_prio, int cmd, void *arg);
71540 };
71541
71542 -
71543 /* v4l debugging and diagnostics */
71544
71545 /* Debug bitmask flags to be used on V4L2 */
71546 diff --git a/include/net/9p/transport.h b/include/net/9p/transport.h
71547 index adcbb20..62c2559 100644
71548 --- a/include/net/9p/transport.h
71549 +++ b/include/net/9p/transport.h
71550 @@ -57,7 +57,7 @@ struct p9_trans_module {
71551 int (*cancel) (struct p9_client *, struct p9_req_t *req);
71552 int (*zc_request)(struct p9_client *, struct p9_req_t *,
71553 char *, char *, int , int, int, int);
71554 -};
71555 +} __do_const;
71556
71557 void v9fs_register_trans(struct p9_trans_module *m);
71558 void v9fs_unregister_trans(struct p9_trans_module *m);
71559 diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h
71560 index 7588ef4..e62d35f 100644
71561 --- a/include/net/bluetooth/l2cap.h
71562 +++ b/include/net/bluetooth/l2cap.h
71563 @@ -552,7 +552,7 @@ struct l2cap_ops {
71564 void (*defer) (struct l2cap_chan *chan);
71565 struct sk_buff *(*alloc_skb) (struct l2cap_chan *chan,
71566 unsigned long len, int nb);
71567 -};
71568 +} __do_const;
71569
71570 struct l2cap_conn {
71571 struct hci_conn *hcon;
71572 diff --git a/include/net/caif/cfctrl.h b/include/net/caif/cfctrl.h
71573 index 9e5425b..8136ffc 100644
71574 --- a/include/net/caif/cfctrl.h
71575 +++ b/include/net/caif/cfctrl.h
71576 @@ -52,7 +52,7 @@ struct cfctrl_rsp {
71577 void (*radioset_rsp)(void);
71578 void (*reject_rsp)(struct cflayer *layer, u8 linkid,
71579 struct cflayer *client_layer);
71580 -};
71581 +} __no_const;
71582
71583 /* Link Setup Parameters for CAIF-Links. */
71584 struct cfctrl_link_param {
71585 @@ -101,8 +101,8 @@ struct cfctrl_request_info {
71586 struct cfctrl {
71587 struct cfsrvl serv;
71588 struct cfctrl_rsp res;
71589 - atomic_t req_seq_no;
71590 - atomic_t rsp_seq_no;
71591 + atomic_unchecked_t req_seq_no;
71592 + atomic_unchecked_t rsp_seq_no;
71593 struct list_head list;
71594 /* Protects from simultaneous access to first_req list */
71595 spinlock_t info_list_lock;
71596 diff --git a/include/net/flow.h b/include/net/flow.h
71597 index 628e11b..4c475df 100644
71598 --- a/include/net/flow.h
71599 +++ b/include/net/flow.h
71600 @@ -221,6 +221,6 @@ extern struct flow_cache_object *flow_cache_lookup(
71601
71602 extern void flow_cache_flush(void);
71603 extern void flow_cache_flush_deferred(void);
71604 -extern atomic_t flow_cache_genid;
71605 +extern atomic_unchecked_t flow_cache_genid;
71606
71607 #endif
71608 diff --git a/include/net/genetlink.h b/include/net/genetlink.h
71609 index bdfbe68..4402ebe 100644
71610 --- a/include/net/genetlink.h
71611 +++ b/include/net/genetlink.h
71612 @@ -118,7 +118,7 @@ struct genl_ops {
71613 struct netlink_callback *cb);
71614 int (*done)(struct netlink_callback *cb);
71615 struct list_head ops_list;
71616 -};
71617 +} __do_const;
71618
71619 extern int genl_register_family(struct genl_family *family);
71620 extern int genl_register_family_with_ops(struct genl_family *family,
71621 diff --git a/include/net/gro_cells.h b/include/net/gro_cells.h
71622 index e5062c9..48a9a4b 100644
71623 --- a/include/net/gro_cells.h
71624 +++ b/include/net/gro_cells.h
71625 @@ -29,7 +29,7 @@ static inline void gro_cells_receive(struct gro_cells *gcells, struct sk_buff *s
71626 cell += skb_get_rx_queue(skb) & gcells->gro_cells_mask;
71627
71628 if (skb_queue_len(&cell->napi_skbs) > netdev_max_backlog) {
71629 - atomic_long_inc(&dev->rx_dropped);
71630 + atomic_long_inc_unchecked(&dev->rx_dropped);
71631 kfree_skb(skb);
71632 return;
71633 }
71634 @@ -73,8 +73,8 @@ static inline int gro_cells_init(struct gro_cells *gcells, struct net_device *de
71635 int i;
71636
71637 gcells->gro_cells_mask = roundup_pow_of_two(netif_get_num_default_rss_queues()) - 1;
71638 - gcells->cells = kcalloc(sizeof(struct gro_cell),
71639 - gcells->gro_cells_mask + 1,
71640 + gcells->cells = kcalloc(gcells->gro_cells_mask + 1,
71641 + sizeof(struct gro_cell),
71642 GFP_KERNEL);
71643 if (!gcells->cells)
71644 return -ENOMEM;
71645 diff --git a/include/net/inet_connection_sock.h b/include/net/inet_connection_sock.h
71646 index 1832927..ce39aea 100644
71647 --- a/include/net/inet_connection_sock.h
71648 +++ b/include/net/inet_connection_sock.h
71649 @@ -62,7 +62,7 @@ struct inet_connection_sock_af_ops {
71650 void (*addr2sockaddr)(struct sock *sk, struct sockaddr *);
71651 int (*bind_conflict)(const struct sock *sk,
71652 const struct inet_bind_bucket *tb, bool relax);
71653 -};
71654 +} __do_const;
71655
71656 /** inet_connection_sock - INET connection oriented sock
71657 *
71658 diff --git a/include/net/inetpeer.h b/include/net/inetpeer.h
71659 index 53f464d..ba76aaa 100644
71660 --- a/include/net/inetpeer.h
71661 +++ b/include/net/inetpeer.h
71662 @@ -47,8 +47,8 @@ struct inet_peer {
71663 */
71664 union {
71665 struct {
71666 - atomic_t rid; /* Frag reception counter */
71667 - atomic_t ip_id_count; /* IP ID for the next packet */
71668 + atomic_unchecked_t rid; /* Frag reception counter */
71669 + atomic_unchecked_t ip_id_count; /* IP ID for the next packet */
71670 };
71671 struct rcu_head rcu;
71672 struct inet_peer *gc_next;
71673 @@ -182,11 +182,11 @@ static inline int inet_getid(struct inet_peer *p, int more)
71674 more++;
71675 inet_peer_refcheck(p);
71676 do {
71677 - old = atomic_read(&p->ip_id_count);
71678 + old = atomic_read_unchecked(&p->ip_id_count);
71679 new = old + more;
71680 if (!new)
71681 new = 1;
71682 - } while (atomic_cmpxchg(&p->ip_id_count, old, new) != old);
71683 + } while (atomic_cmpxchg_unchecked(&p->ip_id_count, old, new) != old);
71684 return new;
71685 }
71686
71687 diff --git a/include/net/ip.h b/include/net/ip.h
71688 index a68f838..74518ab 100644
71689 --- a/include/net/ip.h
71690 +++ b/include/net/ip.h
71691 @@ -202,7 +202,7 @@ extern struct local_ports {
71692 } sysctl_local_ports;
71693 extern void inet_get_local_port_range(int *low, int *high);
71694
71695 -extern unsigned long *sysctl_local_reserved_ports;
71696 +extern unsigned long sysctl_local_reserved_ports[65536 / 8 / sizeof(unsigned long)];
71697 static inline int inet_is_reserved_local_port(int port)
71698 {
71699 return test_bit(port, sysctl_local_reserved_ports);
71700 diff --git a/include/net/ip_fib.h b/include/net/ip_fib.h
71701 index 9497be1..5a4fafe 100644
71702 --- a/include/net/ip_fib.h
71703 +++ b/include/net/ip_fib.h
71704 @@ -169,7 +169,7 @@ extern __be32 fib_info_update_nh_saddr(struct net *net, struct fib_nh *nh);
71705
71706 #define FIB_RES_SADDR(net, res) \
71707 ((FIB_RES_NH(res).nh_saddr_genid == \
71708 - atomic_read(&(net)->ipv4.dev_addr_genid)) ? \
71709 + atomic_read_unchecked(&(net)->ipv4.dev_addr_genid)) ? \
71710 FIB_RES_NH(res).nh_saddr : \
71711 fib_info_update_nh_saddr((net), &FIB_RES_NH(res)))
71712 #define FIB_RES_GW(res) (FIB_RES_NH(res).nh_gw)
71713 diff --git a/include/net/ip_vs.h b/include/net/ip_vs.h
71714 index 68c69d5..bdab192 100644
71715 --- a/include/net/ip_vs.h
71716 +++ b/include/net/ip_vs.h
71717 @@ -599,7 +599,7 @@ struct ip_vs_conn {
71718 struct ip_vs_conn *control; /* Master control connection */
71719 atomic_t n_control; /* Number of controlled ones */
71720 struct ip_vs_dest *dest; /* real server */
71721 - atomic_t in_pkts; /* incoming packet counter */
71722 + atomic_unchecked_t in_pkts; /* incoming packet counter */
71723
71724 /* packet transmitter for different forwarding methods. If it
71725 mangles the packet, it must return NF_DROP or better NF_STOLEN,
71726 @@ -737,7 +737,7 @@ struct ip_vs_dest {
71727 __be16 port; /* port number of the server */
71728 union nf_inet_addr addr; /* IP address of the server */
71729 volatile unsigned int flags; /* dest status flags */
71730 - atomic_t conn_flags; /* flags to copy to conn */
71731 + atomic_unchecked_t conn_flags; /* flags to copy to conn */
71732 atomic_t weight; /* server weight */
71733
71734 atomic_t refcnt; /* reference counter */
71735 @@ -980,11 +980,11 @@ struct netns_ipvs {
71736 /* ip_vs_lblc */
71737 int sysctl_lblc_expiration;
71738 struct ctl_table_header *lblc_ctl_header;
71739 - struct ctl_table *lblc_ctl_table;
71740 + ctl_table_no_const *lblc_ctl_table;
71741 /* ip_vs_lblcr */
71742 int sysctl_lblcr_expiration;
71743 struct ctl_table_header *lblcr_ctl_header;
71744 - struct ctl_table *lblcr_ctl_table;
71745 + ctl_table_no_const *lblcr_ctl_table;
71746 /* ip_vs_est */
71747 struct list_head est_list; /* estimator list */
71748 spinlock_t est_lock;
71749 diff --git a/include/net/irda/ircomm_tty.h b/include/net/irda/ircomm_tty.h
71750 index 80ffde3..968b0f4 100644
71751 --- a/include/net/irda/ircomm_tty.h
71752 +++ b/include/net/irda/ircomm_tty.h
71753 @@ -35,6 +35,7 @@
71754 #include <linux/termios.h>
71755 #include <linux/timer.h>
71756 #include <linux/tty.h> /* struct tty_struct */
71757 +#include <asm/local.h>
71758
71759 #include <net/irda/irias_object.h>
71760 #include <net/irda/ircomm_core.h>
71761 diff --git a/include/net/iucv/af_iucv.h b/include/net/iucv/af_iucv.h
71762 index cc7c197..9f2da2a 100644
71763 --- a/include/net/iucv/af_iucv.h
71764 +++ b/include/net/iucv/af_iucv.h
71765 @@ -141,7 +141,7 @@ struct iucv_sock {
71766 struct iucv_sock_list {
71767 struct hlist_head head;
71768 rwlock_t lock;
71769 - atomic_t autobind_name;
71770 + atomic_unchecked_t autobind_name;
71771 };
71772
71773 unsigned int iucv_sock_poll(struct file *file, struct socket *sock,
71774 diff --git a/include/net/llc_c_ac.h b/include/net/llc_c_ac.h
71775 index df83f69..9b640b8 100644
71776 --- a/include/net/llc_c_ac.h
71777 +++ b/include/net/llc_c_ac.h
71778 @@ -87,7 +87,7 @@
71779 #define LLC_CONN_AC_STOP_SENDACK_TMR 70
71780 #define LLC_CONN_AC_START_SENDACK_TMR_IF_NOT_RUNNING 71
71781
71782 -typedef int (*llc_conn_action_t)(struct sock *sk, struct sk_buff *skb);
71783 +typedef int (* const llc_conn_action_t)(struct sock *sk, struct sk_buff *skb);
71784
71785 extern int llc_conn_ac_clear_remote_busy(struct sock *sk, struct sk_buff *skb);
71786 extern int llc_conn_ac_conn_ind(struct sock *sk, struct sk_buff *skb);
71787 diff --git a/include/net/llc_c_ev.h b/include/net/llc_c_ev.h
71788 index 6ca3113..f8026dd 100644
71789 --- a/include/net/llc_c_ev.h
71790 +++ b/include/net/llc_c_ev.h
71791 @@ -125,8 +125,8 @@ static __inline__ struct llc_conn_state_ev *llc_conn_ev(struct sk_buff *skb)
71792 return (struct llc_conn_state_ev *)skb->cb;
71793 }
71794
71795 -typedef int (*llc_conn_ev_t)(struct sock *sk, struct sk_buff *skb);
71796 -typedef int (*llc_conn_ev_qfyr_t)(struct sock *sk, struct sk_buff *skb);
71797 +typedef int (* const llc_conn_ev_t)(struct sock *sk, struct sk_buff *skb);
71798 +typedef int (* const llc_conn_ev_qfyr_t)(struct sock *sk, struct sk_buff *skb);
71799
71800 extern int llc_conn_ev_conn_req(struct sock *sk, struct sk_buff *skb);
71801 extern int llc_conn_ev_data_req(struct sock *sk, struct sk_buff *skb);
71802 diff --git a/include/net/llc_c_st.h b/include/net/llc_c_st.h
71803 index 0e79cfb..f46db31 100644
71804 --- a/include/net/llc_c_st.h
71805 +++ b/include/net/llc_c_st.h
71806 @@ -37,7 +37,7 @@ struct llc_conn_state_trans {
71807 u8 next_state;
71808 llc_conn_ev_qfyr_t *ev_qualifiers;
71809 llc_conn_action_t *ev_actions;
71810 -};
71811 +} __do_const;
71812
71813 struct llc_conn_state {
71814 u8 current_state;
71815 diff --git a/include/net/llc_s_ac.h b/include/net/llc_s_ac.h
71816 index 37a3bbd..55a4241 100644
71817 --- a/include/net/llc_s_ac.h
71818 +++ b/include/net/llc_s_ac.h
71819 @@ -23,7 +23,7 @@
71820 #define SAP_ACT_TEST_IND 9
71821
71822 /* All action functions must look like this */
71823 -typedef int (*llc_sap_action_t)(struct llc_sap *sap, struct sk_buff *skb);
71824 +typedef int (* const llc_sap_action_t)(struct llc_sap *sap, struct sk_buff *skb);
71825
71826 extern int llc_sap_action_unitdata_ind(struct llc_sap *sap,
71827 struct sk_buff *skb);
71828 diff --git a/include/net/llc_s_st.h b/include/net/llc_s_st.h
71829 index 567c681..cd73ac0 100644
71830 --- a/include/net/llc_s_st.h
71831 +++ b/include/net/llc_s_st.h
71832 @@ -20,7 +20,7 @@ struct llc_sap_state_trans {
71833 llc_sap_ev_t ev;
71834 u8 next_state;
71835 llc_sap_action_t *ev_actions;
71836 -};
71837 +} __do_const;
71838
71839 struct llc_sap_state {
71840 u8 curr_state;
71841 diff --git a/include/net/mac80211.h b/include/net/mac80211.h
71842 index ee50c5e..1bc3b1a 100644
71843 --- a/include/net/mac80211.h
71844 +++ b/include/net/mac80211.h
71845 @@ -3996,7 +3996,7 @@ struct rate_control_ops {
71846 void (*add_sta_debugfs)(void *priv, void *priv_sta,
71847 struct dentry *dir);
71848 void (*remove_sta_debugfs)(void *priv, void *priv_sta);
71849 -};
71850 +} __do_const;
71851
71852 static inline int rate_supported(struct ieee80211_sta *sta,
71853 enum ieee80211_band band,
71854 diff --git a/include/net/neighbour.h b/include/net/neighbour.h
71855 index 0dab173..1b76af0 100644
71856 --- a/include/net/neighbour.h
71857 +++ b/include/net/neighbour.h
71858 @@ -123,7 +123,7 @@ struct neigh_ops {
71859 void (*error_report)(struct neighbour *, struct sk_buff *);
71860 int (*output)(struct neighbour *, struct sk_buff *);
71861 int (*connected_output)(struct neighbour *, struct sk_buff *);
71862 -};
71863 +} __do_const;
71864
71865 struct pneigh_entry {
71866 struct pneigh_entry *next;
71867 diff --git a/include/net/net_namespace.h b/include/net/net_namespace.h
71868 index de644bc..351fd4e 100644
71869 --- a/include/net/net_namespace.h
71870 +++ b/include/net/net_namespace.h
71871 @@ -115,7 +115,7 @@ struct net {
71872 #endif
71873 struct netns_ipvs *ipvs;
71874 struct sock *diag_nlsk;
71875 - atomic_t rt_genid;
71876 + atomic_unchecked_t rt_genid;
71877 };
71878
71879 /*
71880 @@ -282,7 +282,7 @@ struct pernet_operations {
71881 void (*exit_batch)(struct list_head *net_exit_list);
71882 int *id;
71883 size_t size;
71884 -};
71885 +} __do_const;
71886
71887 /*
71888 * Use these carefully. If you implement a network device and it
71889 @@ -330,12 +330,12 @@ static inline void unregister_net_sysctl_table(struct ctl_table_header *header)
71890
71891 static inline int rt_genid(struct net *net)
71892 {
71893 - return atomic_read(&net->rt_genid);
71894 + return atomic_read_unchecked(&net->rt_genid);
71895 }
71896
71897 static inline void rt_genid_bump(struct net *net)
71898 {
71899 - atomic_inc(&net->rt_genid);
71900 + atomic_inc_unchecked(&net->rt_genid);
71901 }
71902
71903 #endif /* __NET_NET_NAMESPACE_H */
71904 diff --git a/include/net/netdma.h b/include/net/netdma.h
71905 index 8ba8ce2..99b7fff 100644
71906 --- a/include/net/netdma.h
71907 +++ b/include/net/netdma.h
71908 @@ -24,7 +24,7 @@
71909 #include <linux/dmaengine.h>
71910 #include <linux/skbuff.h>
71911
71912 -int dma_skb_copy_datagram_iovec(struct dma_chan* chan,
71913 +int __intentional_overflow(3,5) dma_skb_copy_datagram_iovec(struct dma_chan* chan,
71914 struct sk_buff *skb, int offset, struct iovec *to,
71915 size_t len, struct dma_pinned_list *pinned_list);
71916
71917 diff --git a/include/net/netlink.h b/include/net/netlink.h
71918 index 9690b0f..87aded7 100644
71919 --- a/include/net/netlink.h
71920 +++ b/include/net/netlink.h
71921 @@ -534,7 +534,7 @@ static inline void *nlmsg_get_pos(struct sk_buff *skb)
71922 static inline void nlmsg_trim(struct sk_buff *skb, const void *mark)
71923 {
71924 if (mark)
71925 - skb_trim(skb, (unsigned char *) mark - skb->data);
71926 + skb_trim(skb, (const unsigned char *) mark - skb->data);
71927 }
71928
71929 /**
71930 diff --git a/include/net/netns/conntrack.h b/include/net/netns/conntrack.h
71931 index 923cb20..deae816 100644
71932 --- a/include/net/netns/conntrack.h
71933 +++ b/include/net/netns/conntrack.h
71934 @@ -12,10 +12,10 @@ struct nf_conntrack_ecache;
71935 struct nf_proto_net {
71936 #ifdef CONFIG_SYSCTL
71937 struct ctl_table_header *ctl_table_header;
71938 - struct ctl_table *ctl_table;
71939 + ctl_table_no_const *ctl_table;
71940 #ifdef CONFIG_NF_CONNTRACK_PROC_COMPAT
71941 struct ctl_table_header *ctl_compat_header;
71942 - struct ctl_table *ctl_compat_table;
71943 + ctl_table_no_const *ctl_compat_table;
71944 #endif
71945 #endif
71946 unsigned int users;
71947 @@ -58,7 +58,7 @@ struct nf_ip_net {
71948 struct nf_icmp_net icmpv6;
71949 #if defined(CONFIG_SYSCTL) && defined(CONFIG_NF_CONNTRACK_PROC_COMPAT)
71950 struct ctl_table_header *ctl_table_header;
71951 - struct ctl_table *ctl_table;
71952 + ctl_table_no_const *ctl_table;
71953 #endif
71954 };
71955
71956 diff --git a/include/net/netns/ipv4.h b/include/net/netns/ipv4.h
71957 index 2ae2b83..dbdc85e 100644
71958 --- a/include/net/netns/ipv4.h
71959 +++ b/include/net/netns/ipv4.h
71960 @@ -64,7 +64,7 @@ struct netns_ipv4 {
71961 kgid_t sysctl_ping_group_range[2];
71962 long sysctl_tcp_mem[3];
71963
71964 - atomic_t dev_addr_genid;
71965 + atomic_unchecked_t dev_addr_genid;
71966
71967 #ifdef CONFIG_IP_MROUTE
71968 #ifndef CONFIG_IP_MROUTE_MULTIPLE_TABLES
71969 diff --git a/include/net/protocol.h b/include/net/protocol.h
71970 index 047c047..b9dad15 100644
71971 --- a/include/net/protocol.h
71972 +++ b/include/net/protocol.h
71973 @@ -44,7 +44,7 @@ struct net_protocol {
71974 void (*err_handler)(struct sk_buff *skb, u32 info);
71975 unsigned int no_policy:1,
71976 netns_ok:1;
71977 -};
71978 +} __do_const;
71979
71980 #if IS_ENABLED(CONFIG_IPV6)
71981 struct inet6_protocol {
71982 @@ -57,7 +57,7 @@ struct inet6_protocol {
71983 u8 type, u8 code, int offset,
71984 __be32 info);
71985 unsigned int flags; /* INET6_PROTO_xxx */
71986 -};
71987 +} __do_const;
71988
71989 #define INET6_PROTO_NOPOLICY 0x1
71990 #define INET6_PROTO_FINAL 0x2
71991 diff --git a/include/net/rtnetlink.h b/include/net/rtnetlink.h
71992 index 5a15fab..d799ea7 100644
71993 --- a/include/net/rtnetlink.h
71994 +++ b/include/net/rtnetlink.h
71995 @@ -81,7 +81,7 @@ struct rtnl_link_ops {
71996 const struct net_device *dev);
71997 unsigned int (*get_num_tx_queues)(void);
71998 unsigned int (*get_num_rx_queues)(void);
71999 -};
72000 +} __do_const;
72001
72002 extern int __rtnl_link_register(struct rtnl_link_ops *ops);
72003 extern void __rtnl_link_unregister(struct rtnl_link_ops *ops);
72004 diff --git a/include/net/sctp/sctp.h b/include/net/sctp/sctp.h
72005 index 7fdf298..197e9f7 100644
72006 --- a/include/net/sctp/sctp.h
72007 +++ b/include/net/sctp/sctp.h
72008 @@ -330,9 +330,9 @@ do { \
72009
72010 #else /* SCTP_DEBUG */
72011
72012 -#define SCTP_DEBUG_PRINTK(whatever...)
72013 -#define SCTP_DEBUG_PRINTK_CONT(fmt, args...)
72014 -#define SCTP_DEBUG_PRINTK_IPADDR(whatever...)
72015 +#define SCTP_DEBUG_PRINTK(whatever...) do {} while (0)
72016 +#define SCTP_DEBUG_PRINTK_CONT(fmt, args...) do {} while (0)
72017 +#define SCTP_DEBUG_PRINTK_IPADDR(whatever...) do {} while (0)
72018 #define SCTP_ENABLE_DEBUG
72019 #define SCTP_DISABLE_DEBUG
72020 #define SCTP_ASSERT(expr, str, func)
72021 diff --git a/include/net/sctp/sm.h b/include/net/sctp/sm.h
72022 index 2a82d13..62a31c2 100644
72023 --- a/include/net/sctp/sm.h
72024 +++ b/include/net/sctp/sm.h
72025 @@ -87,7 +87,7 @@ typedef void (sctp_timer_event_t) (unsigned long);
72026 typedef struct {
72027 sctp_state_fn_t *fn;
72028 const char *name;
72029 -} sctp_sm_table_entry_t;
72030 +} __do_const sctp_sm_table_entry_t;
72031
72032 /* A naming convention of "sctp_sf_xxx" applies to all the state functions
72033 * currently in use.
72034 @@ -299,7 +299,7 @@ __u32 sctp_generate_tag(const struct sctp_endpoint *);
72035 __u32 sctp_generate_tsn(const struct sctp_endpoint *);
72036
72037 /* Extern declarations for major data structures. */
72038 -extern sctp_timer_event_t *sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES];
72039 +extern sctp_timer_event_t * const sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES];
72040
72041
72042 /* Get the size of a DATA chunk payload. */
72043 diff --git a/include/net/sctp/structs.h b/include/net/sctp/structs.h
72044 index fdeb85a..1329d95 100644
72045 --- a/include/net/sctp/structs.h
72046 +++ b/include/net/sctp/structs.h
72047 @@ -517,7 +517,7 @@ struct sctp_pf {
72048 struct sctp_association *asoc);
72049 void (*addr_v4map) (struct sctp_sock *, union sctp_addr *);
72050 struct sctp_af *af;
72051 -};
72052 +} __do_const;
72053
72054
72055 /* Structure to track chunk fragments that have been acked, but peer
72056 diff --git a/include/net/sock.h b/include/net/sock.h
72057 index 25afaa0..8bb0070 100644
72058 --- a/include/net/sock.h
72059 +++ b/include/net/sock.h
72060 @@ -322,7 +322,7 @@ struct sock {
72061 #ifdef CONFIG_RPS
72062 __u32 sk_rxhash;
72063 #endif
72064 - atomic_t sk_drops;
72065 + atomic_unchecked_t sk_drops;
72066 int sk_rcvbuf;
72067
72068 struct sk_filter __rcu *sk_filter;
72069 @@ -1781,7 +1781,7 @@ static inline void sk_nocaps_add(struct sock *sk, netdev_features_t flags)
72070 }
72071
72072 static inline int skb_do_copy_data_nocache(struct sock *sk, struct sk_buff *skb,
72073 - char __user *from, char *to,
72074 + char __user *from, unsigned char *to,
72075 int copy, int offset)
72076 {
72077 if (skb->ip_summed == CHECKSUM_NONE) {
72078 @@ -2040,7 +2040,7 @@ static inline void sk_stream_moderate_sndbuf(struct sock *sk)
72079 }
72080 }
72081
72082 -struct sk_buff *sk_stream_alloc_skb(struct sock *sk, int size, gfp_t gfp);
72083 +struct sk_buff * __intentional_overflow(0) sk_stream_alloc_skb(struct sock *sk, int size, gfp_t gfp);
72084
72085 /**
72086 * sk_page_frag - return an appropriate page_frag
72087 diff --git a/include/net/tcp.h b/include/net/tcp.h
72088 index aed42c7..43890c6 100644
72089 --- a/include/net/tcp.h
72090 +++ b/include/net/tcp.h
72091 @@ -530,7 +530,7 @@ extern void tcp_retransmit_timer(struct sock *sk);
72092 extern void tcp_xmit_retransmit_queue(struct sock *);
72093 extern void tcp_simple_retransmit(struct sock *);
72094 extern int tcp_trim_head(struct sock *, struct sk_buff *, u32);
72095 -extern int tcp_fragment(struct sock *, struct sk_buff *, u32, unsigned int);
72096 +extern int __intentional_overflow(3) tcp_fragment(struct sock *, struct sk_buff *, u32, unsigned int);
72097
72098 extern void tcp_send_probe0(struct sock *);
72099 extern void tcp_send_partial(struct sock *);
72100 @@ -701,8 +701,8 @@ struct tcp_skb_cb {
72101 struct inet6_skb_parm h6;
72102 #endif
72103 } header; /* For incoming frames */
72104 - __u32 seq; /* Starting sequence number */
72105 - __u32 end_seq; /* SEQ + FIN + SYN + datalen */
72106 + __u32 seq __intentional_overflow(0); /* Starting sequence number */
72107 + __u32 end_seq __intentional_overflow(0); /* SEQ + FIN + SYN + datalen */
72108 __u32 when; /* used to compute rtt's */
72109 __u8 tcp_flags; /* TCP header flags. (tcp[13]) */
72110
72111 @@ -716,7 +716,7 @@ struct tcp_skb_cb {
72112
72113 __u8 ip_dsfield; /* IPv4 tos or IPv6 dsfield */
72114 /* 1 byte hole */
72115 - __u32 ack_seq; /* Sequence number ACK'd */
72116 + __u32 ack_seq __intentional_overflow(0); /* Sequence number ACK'd */
72117 };
72118
72119 #define TCP_SKB_CB(__skb) ((struct tcp_skb_cb *)&((__skb)->cb[0]))
72120 diff --git a/include/net/xfrm.h b/include/net/xfrm.h
72121 index 63445ed..d6fc34f 100644
72122 --- a/include/net/xfrm.h
72123 +++ b/include/net/xfrm.h
72124 @@ -304,7 +304,7 @@ struct xfrm_policy_afinfo {
72125 struct net_device *dev,
72126 const struct flowi *fl);
72127 struct dst_entry *(*blackhole_route)(struct net *net, struct dst_entry *orig);
72128 -};
72129 +} __do_const;
72130
72131 extern int xfrm_policy_register_afinfo(struct xfrm_policy_afinfo *afinfo);
72132 extern int xfrm_policy_unregister_afinfo(struct xfrm_policy_afinfo *afinfo);
72133 @@ -340,7 +340,7 @@ struct xfrm_state_afinfo {
72134 struct sk_buff *skb);
72135 int (*transport_finish)(struct sk_buff *skb,
72136 int async);
72137 -};
72138 +} __do_const;
72139
72140 extern int xfrm_state_register_afinfo(struct xfrm_state_afinfo *afinfo);
72141 extern int xfrm_state_unregister_afinfo(struct xfrm_state_afinfo *afinfo);
72142 @@ -423,7 +423,7 @@ struct xfrm_mode {
72143 struct module *owner;
72144 unsigned int encap;
72145 int flags;
72146 -};
72147 +} __do_const;
72148
72149 /* Flags for xfrm_mode. */
72150 enum {
72151 @@ -514,7 +514,7 @@ struct xfrm_policy {
72152 struct timer_list timer;
72153
72154 struct flow_cache_object flo;
72155 - atomic_t genid;
72156 + atomic_unchecked_t genid;
72157 u32 priority;
72158 u32 index;
72159 struct xfrm_mark mark;
72160 diff --git a/include/rdma/iw_cm.h b/include/rdma/iw_cm.h
72161 index 1a046b1..ee0bef0 100644
72162 --- a/include/rdma/iw_cm.h
72163 +++ b/include/rdma/iw_cm.h
72164 @@ -122,7 +122,7 @@ struct iw_cm_verbs {
72165 int backlog);
72166
72167 int (*destroy_listen)(struct iw_cm_id *cm_id);
72168 -};
72169 +} __no_const;
72170
72171 /**
72172 * iw_create_cm_id - Create an IW CM identifier.
72173 diff --git a/include/scsi/libfc.h b/include/scsi/libfc.h
72174 index 399162b..b337f1a 100644
72175 --- a/include/scsi/libfc.h
72176 +++ b/include/scsi/libfc.h
72177 @@ -762,6 +762,7 @@ struct libfc_function_template {
72178 */
72179 void (*disc_stop_final) (struct fc_lport *);
72180 };
72181 +typedef struct libfc_function_template __no_const libfc_function_template_no_const;
72182
72183 /**
72184 * struct fc_disc - Discovery context
72185 @@ -866,7 +867,7 @@ struct fc_lport {
72186 struct fc_vport *vport;
72187
72188 /* Operational Information */
72189 - struct libfc_function_template tt;
72190 + libfc_function_template_no_const tt;
72191 u8 link_up;
72192 u8 qfull;
72193 enum fc_lport_state state;
72194 diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h
72195 index e65c62e..aa2e5a2 100644
72196 --- a/include/scsi/scsi_device.h
72197 +++ b/include/scsi/scsi_device.h
72198 @@ -170,9 +170,9 @@ struct scsi_device {
72199 unsigned int max_device_blocked; /* what device_blocked counts down from */
72200 #define SCSI_DEFAULT_DEVICE_BLOCKED 3
72201
72202 - atomic_t iorequest_cnt;
72203 - atomic_t iodone_cnt;
72204 - atomic_t ioerr_cnt;
72205 + atomic_unchecked_t iorequest_cnt;
72206 + atomic_unchecked_t iodone_cnt;
72207 + atomic_unchecked_t ioerr_cnt;
72208
72209 struct device sdev_gendev,
72210 sdev_dev;
72211 diff --git a/include/scsi/scsi_transport_fc.h b/include/scsi/scsi_transport_fc.h
72212 index b797e8f..8e2c3aa 100644
72213 --- a/include/scsi/scsi_transport_fc.h
72214 +++ b/include/scsi/scsi_transport_fc.h
72215 @@ -751,7 +751,8 @@ struct fc_function_template {
72216 unsigned long show_host_system_hostname:1;
72217
72218 unsigned long disable_target_scan:1;
72219 -};
72220 +} __do_const;
72221 +typedef struct fc_function_template __no_const fc_function_template_no_const;
72222
72223
72224 /**
72225 diff --git a/include/sound/soc.h b/include/sound/soc.h
72226 index bc56738..a4be132 100644
72227 --- a/include/sound/soc.h
72228 +++ b/include/sound/soc.h
72229 @@ -771,7 +771,7 @@ struct snd_soc_codec_driver {
72230 /* probe ordering - for components with runtime dependencies */
72231 int probe_order;
72232 int remove_order;
72233 -};
72234 +} __do_const;
72235
72236 /* SoC platform interface */
72237 struct snd_soc_platform_driver {
72238 @@ -817,7 +817,7 @@ struct snd_soc_platform_driver {
72239 unsigned int (*read)(struct snd_soc_platform *, unsigned int);
72240 int (*write)(struct snd_soc_platform *, unsigned int, unsigned int);
72241 int (*bespoke_trigger)(struct snd_pcm_substream *, int);
72242 -};
72243 +} __do_const;
72244
72245 struct snd_soc_platform {
72246 const char *name;
72247 diff --git a/include/target/target_core_base.h b/include/target/target_core_base.h
72248 index 663e34a..91b306a 100644
72249 --- a/include/target/target_core_base.h
72250 +++ b/include/target/target_core_base.h
72251 @@ -654,7 +654,7 @@ struct se_device {
72252 spinlock_t stats_lock;
72253 /* Active commands on this virtual SE device */
72254 atomic_t simple_cmds;
72255 - atomic_t dev_ordered_id;
72256 + atomic_unchecked_t dev_ordered_id;
72257 atomic_t dev_ordered_sync;
72258 atomic_t dev_qf_count;
72259 int export_count;
72260 diff --git a/include/trace/events/fs.h b/include/trace/events/fs.h
72261 new file mode 100644
72262 index 0000000..fb634b7
72263 --- /dev/null
72264 +++ b/include/trace/events/fs.h
72265 @@ -0,0 +1,53 @@
72266 +#undef TRACE_SYSTEM
72267 +#define TRACE_SYSTEM fs
72268 +
72269 +#if !defined(_TRACE_FS_H) || defined(TRACE_HEADER_MULTI_READ)
72270 +#define _TRACE_FS_H
72271 +
72272 +#include <linux/fs.h>
72273 +#include <linux/tracepoint.h>
72274 +
72275 +TRACE_EVENT(do_sys_open,
72276 +
72277 + TP_PROTO(const char *filename, int flags, int mode),
72278 +
72279 + TP_ARGS(filename, flags, mode),
72280 +
72281 + TP_STRUCT__entry(
72282 + __string( filename, filename )
72283 + __field( int, flags )
72284 + __field( int, mode )
72285 + ),
72286 +
72287 + TP_fast_assign(
72288 + __assign_str(filename, filename);
72289 + __entry->flags = flags;
72290 + __entry->mode = mode;
72291 + ),
72292 +
72293 + TP_printk("\"%s\" %x %o",
72294 + __get_str(filename), __entry->flags, __entry->mode)
72295 +);
72296 +
72297 +TRACE_EVENT(open_exec,
72298 +
72299 + TP_PROTO(const char *filename),
72300 +
72301 + TP_ARGS(filename),
72302 +
72303 + TP_STRUCT__entry(
72304 + __string( filename, filename )
72305 + ),
72306 +
72307 + TP_fast_assign(
72308 + __assign_str(filename, filename);
72309 + ),
72310 +
72311 + TP_printk("\"%s\"",
72312 + __get_str(filename))
72313 +);
72314 +
72315 +#endif /* _TRACE_FS_H */
72316 +
72317 +/* This part must be outside protection */
72318 +#include <trace/define_trace.h>
72319 diff --git a/include/trace/events/irq.h b/include/trace/events/irq.h
72320 index 1c09820..7f5ec79 100644
72321 --- a/include/trace/events/irq.h
72322 +++ b/include/trace/events/irq.h
72323 @@ -36,7 +36,7 @@ struct softirq_action;
72324 */
72325 TRACE_EVENT(irq_handler_entry,
72326
72327 - TP_PROTO(int irq, struct irqaction *action),
72328 + TP_PROTO(int irq, const struct irqaction *action),
72329
72330 TP_ARGS(irq, action),
72331
72332 @@ -66,7 +66,7 @@ TRACE_EVENT(irq_handler_entry,
72333 */
72334 TRACE_EVENT(irq_handler_exit,
72335
72336 - TP_PROTO(int irq, struct irqaction *action, int ret),
72337 + TP_PROTO(int irq, const struct irqaction *action, int ret),
72338
72339 TP_ARGS(irq, action, ret),
72340
72341 diff --git a/include/uapi/linux/a.out.h b/include/uapi/linux/a.out.h
72342 index 7caf44c..23c6f27 100644
72343 --- a/include/uapi/linux/a.out.h
72344 +++ b/include/uapi/linux/a.out.h
72345 @@ -39,6 +39,14 @@ enum machine_type {
72346 M_MIPS2 = 152 /* MIPS R6000/R4000 binary */
72347 };
72348
72349 +/* Constants for the N_FLAGS field */
72350 +#define F_PAX_PAGEEXEC 1 /* Paging based non-executable pages */
72351 +#define F_PAX_EMUTRAMP 2 /* Emulate trampolines */
72352 +#define F_PAX_MPROTECT 4 /* Restrict mprotect() */
72353 +#define F_PAX_RANDMMAP 8 /* Randomize mmap() base */
72354 +/*#define F_PAX_RANDEXEC 16*/ /* Randomize ET_EXEC base */
72355 +#define F_PAX_SEGMEXEC 32 /* Segmentation based non-executable pages */
72356 +
72357 #if !defined (N_MAGIC)
72358 #define N_MAGIC(exec) ((exec).a_info & 0xffff)
72359 #endif
72360 diff --git a/include/uapi/linux/byteorder/little_endian.h b/include/uapi/linux/byteorder/little_endian.h
72361 index d876736..ccce5c0 100644
72362 --- a/include/uapi/linux/byteorder/little_endian.h
72363 +++ b/include/uapi/linux/byteorder/little_endian.h
72364 @@ -42,51 +42,51 @@
72365
72366 static inline __le64 __cpu_to_le64p(const __u64 *p)
72367 {
72368 - return (__force __le64)*p;
72369 + return (__force const __le64)*p;
72370 }
72371 -static inline __u64 __le64_to_cpup(const __le64 *p)
72372 +static inline __u64 __intentional_overflow(-1) __le64_to_cpup(const __le64 *p)
72373 {
72374 - return (__force __u64)*p;
72375 + return (__force const __u64)*p;
72376 }
72377 static inline __le32 __cpu_to_le32p(const __u32 *p)
72378 {
72379 - return (__force __le32)*p;
72380 + return (__force const __le32)*p;
72381 }
72382 static inline __u32 __le32_to_cpup(const __le32 *p)
72383 {
72384 - return (__force __u32)*p;
72385 + return (__force const __u32)*p;
72386 }
72387 static inline __le16 __cpu_to_le16p(const __u16 *p)
72388 {
72389 - return (__force __le16)*p;
72390 + return (__force const __le16)*p;
72391 }
72392 static inline __u16 __le16_to_cpup(const __le16 *p)
72393 {
72394 - return (__force __u16)*p;
72395 + return (__force const __u16)*p;
72396 }
72397 static inline __be64 __cpu_to_be64p(const __u64 *p)
72398 {
72399 - return (__force __be64)__swab64p(p);
72400 + return (__force const __be64)__swab64p(p);
72401 }
72402 static inline __u64 __be64_to_cpup(const __be64 *p)
72403 {
72404 - return __swab64p((__u64 *)p);
72405 + return __swab64p((const __u64 *)p);
72406 }
72407 static inline __be32 __cpu_to_be32p(const __u32 *p)
72408 {
72409 - return (__force __be32)__swab32p(p);
72410 + return (__force const __be32)__swab32p(p);
72411 }
72412 -static inline __u32 __be32_to_cpup(const __be32 *p)
72413 +static inline __u32 __intentional_overflow(-1) __be32_to_cpup(const __be32 *p)
72414 {
72415 - return __swab32p((__u32 *)p);
72416 + return __swab32p((const __u32 *)p);
72417 }
72418 static inline __be16 __cpu_to_be16p(const __u16 *p)
72419 {
72420 - return (__force __be16)__swab16p(p);
72421 + return (__force const __be16)__swab16p(p);
72422 }
72423 static inline __u16 __be16_to_cpup(const __be16 *p)
72424 {
72425 - return __swab16p((__u16 *)p);
72426 + return __swab16p((const __u16 *)p);
72427 }
72428 #define __cpu_to_le64s(x) do { (void)(x); } while (0)
72429 #define __le64_to_cpus(x) do { (void)(x); } while (0)
72430 diff --git a/include/uapi/linux/elf.h b/include/uapi/linux/elf.h
72431 index 126a817..d522bd1 100644
72432 --- a/include/uapi/linux/elf.h
72433 +++ b/include/uapi/linux/elf.h
72434 @@ -37,6 +37,17 @@ typedef __s64 Elf64_Sxword;
72435 #define PT_GNU_EH_FRAME 0x6474e550
72436
72437 #define PT_GNU_STACK (PT_LOOS + 0x474e551)
72438 +#define PT_GNU_RELRO (PT_LOOS + 0x474e552)
72439 +
72440 +#define PT_PAX_FLAGS (PT_LOOS + 0x5041580)
72441 +
72442 +/* Constants for the e_flags field */
72443 +#define EF_PAX_PAGEEXEC 1 /* Paging based non-executable pages */
72444 +#define EF_PAX_EMUTRAMP 2 /* Emulate trampolines */
72445 +#define EF_PAX_MPROTECT 4 /* Restrict mprotect() */
72446 +#define EF_PAX_RANDMMAP 8 /* Randomize mmap() base */
72447 +/*#define EF_PAX_RANDEXEC 16*/ /* Randomize ET_EXEC base */
72448 +#define EF_PAX_SEGMEXEC 32 /* Segmentation based non-executable pages */
72449
72450 /*
72451 * Extended Numbering
72452 @@ -94,6 +105,8 @@ typedef __s64 Elf64_Sxword;
72453 #define DT_DEBUG 21
72454 #define DT_TEXTREL 22
72455 #define DT_JMPREL 23
72456 +#define DT_FLAGS 30
72457 + #define DF_TEXTREL 0x00000004
72458 #define DT_ENCODING 32
72459 #define OLD_DT_LOOS 0x60000000
72460 #define DT_LOOS 0x6000000d
72461 @@ -240,6 +253,19 @@ typedef struct elf64_hdr {
72462 #define PF_W 0x2
72463 #define PF_X 0x1
72464
72465 +#define PF_PAGEEXEC (1U << 4) /* Enable PAGEEXEC */
72466 +#define PF_NOPAGEEXEC (1U << 5) /* Disable PAGEEXEC */
72467 +#define PF_SEGMEXEC (1U << 6) /* Enable SEGMEXEC */
72468 +#define PF_NOSEGMEXEC (1U << 7) /* Disable SEGMEXEC */
72469 +#define PF_MPROTECT (1U << 8) /* Enable MPROTECT */
72470 +#define PF_NOMPROTECT (1U << 9) /* Disable MPROTECT */
72471 +/*#define PF_RANDEXEC (1U << 10)*/ /* Enable RANDEXEC */
72472 +/*#define PF_NORANDEXEC (1U << 11)*/ /* Disable RANDEXEC */
72473 +#define PF_EMUTRAMP (1U << 12) /* Enable EMUTRAMP */
72474 +#define PF_NOEMUTRAMP (1U << 13) /* Disable EMUTRAMP */
72475 +#define PF_RANDMMAP (1U << 14) /* Enable RANDMMAP */
72476 +#define PF_NORANDMMAP (1U << 15) /* Disable RANDMMAP */
72477 +
72478 typedef struct elf32_phdr{
72479 Elf32_Word p_type;
72480 Elf32_Off p_offset;
72481 @@ -332,6 +358,8 @@ typedef struct elf64_shdr {
72482 #define EI_OSABI 7
72483 #define EI_PAD 8
72484
72485 +#define EI_PAX 14
72486 +
72487 #define ELFMAG0 0x7f /* EI_MAG */
72488 #define ELFMAG1 'E'
72489 #define ELFMAG2 'L'
72490 diff --git a/include/uapi/linux/personality.h b/include/uapi/linux/personality.h
72491 index aa169c4..6a2771d 100644
72492 --- a/include/uapi/linux/personality.h
72493 +++ b/include/uapi/linux/personality.h
72494 @@ -30,6 +30,7 @@ enum {
72495 #define PER_CLEAR_ON_SETID (READ_IMPLIES_EXEC | \
72496 ADDR_NO_RANDOMIZE | \
72497 ADDR_COMPAT_LAYOUT | \
72498 + ADDR_LIMIT_3GB | \
72499 MMAP_PAGE_ZERO)
72500
72501 /*
72502 diff --git a/include/uapi/linux/screen_info.h b/include/uapi/linux/screen_info.h
72503 index 7530e74..e714828 100644
72504 --- a/include/uapi/linux/screen_info.h
72505 +++ b/include/uapi/linux/screen_info.h
72506 @@ -43,7 +43,8 @@ struct screen_info {
72507 __u16 pages; /* 0x32 */
72508 __u16 vesa_attributes; /* 0x34 */
72509 __u32 capabilities; /* 0x36 */
72510 - __u8 _reserved[6]; /* 0x3a */
72511 + __u16 vesapm_size; /* 0x3a */
72512 + __u8 _reserved[4]; /* 0x3c */
72513 } __attribute__((packed));
72514
72515 #define VIDEO_TYPE_MDA 0x10 /* Monochrome Text Display */
72516 diff --git a/include/uapi/linux/swab.h b/include/uapi/linux/swab.h
72517 index 0e011eb..82681b1 100644
72518 --- a/include/uapi/linux/swab.h
72519 +++ b/include/uapi/linux/swab.h
72520 @@ -43,7 +43,7 @@
72521 * ___swab16, ___swab32, ___swab64, ___swahw32, ___swahb32
72522 */
72523
72524 -static inline __attribute_const__ __u16 __fswab16(__u16 val)
72525 +static inline __intentional_overflow(-1) __attribute_const__ __u16 __fswab16(__u16 val)
72526 {
72527 #ifdef __HAVE_BUILTIN_BSWAP16__
72528 return __builtin_bswap16(val);
72529 @@ -54,7 +54,7 @@ static inline __attribute_const__ __u16 __fswab16(__u16 val)
72530 #endif
72531 }
72532
72533 -static inline __attribute_const__ __u32 __fswab32(__u32 val)
72534 +static inline __intentional_overflow(-1) __attribute_const__ __u32 __fswab32(__u32 val)
72535 {
72536 #ifdef __HAVE_BUILTIN_BSWAP32__
72537 return __builtin_bswap32(val);
72538 @@ -65,7 +65,7 @@ static inline __attribute_const__ __u32 __fswab32(__u32 val)
72539 #endif
72540 }
72541
72542 -static inline __attribute_const__ __u64 __fswab64(__u64 val)
72543 +static inline __intentional_overflow(-1) __attribute_const__ __u64 __fswab64(__u64 val)
72544 {
72545 #ifdef __HAVE_BUILTIN_BSWAP64__
72546 return __builtin_bswap64(val);
72547 diff --git a/include/uapi/linux/sysctl.h b/include/uapi/linux/sysctl.h
72548 index 6d67213..8dab561 100644
72549 --- a/include/uapi/linux/sysctl.h
72550 +++ b/include/uapi/linux/sysctl.h
72551 @@ -155,7 +155,11 @@ enum
72552 KERN_PANIC_ON_NMI=76, /* int: whether we will panic on an unrecovered */
72553 };
72554
72555 -
72556 +#ifdef CONFIG_PAX_SOFTMODE
72557 +enum {
72558 + PAX_SOFTMODE=1 /* PaX: disable/enable soft mode */
72559 +};
72560 +#endif
72561
72562 /* CTL_VM names: */
72563 enum
72564 diff --git a/include/uapi/linux/xattr.h b/include/uapi/linux/xattr.h
72565 index 26607bd..588b65f 100644
72566 --- a/include/uapi/linux/xattr.h
72567 +++ b/include/uapi/linux/xattr.h
72568 @@ -60,5 +60,9 @@
72569 #define XATTR_POSIX_ACL_DEFAULT "posix_acl_default"
72570 #define XATTR_NAME_POSIX_ACL_DEFAULT XATTR_SYSTEM_PREFIX XATTR_POSIX_ACL_DEFAULT
72571
72572 +/* User namespace */
72573 +#define XATTR_PAX_PREFIX XATTR_USER_PREFIX "pax."
72574 +#define XATTR_PAX_FLAGS_SUFFIX "flags"
72575 +#define XATTR_NAME_PAX_FLAGS XATTR_PAX_PREFIX XATTR_PAX_FLAGS_SUFFIX
72576
72577 #endif /* _UAPI_LINUX_XATTR_H */
72578 diff --git a/include/video/udlfb.h b/include/video/udlfb.h
72579 index f9466fa..f4e2b81 100644
72580 --- a/include/video/udlfb.h
72581 +++ b/include/video/udlfb.h
72582 @@ -53,10 +53,10 @@ struct dlfb_data {
72583 u32 pseudo_palette[256];
72584 int blank_mode; /*one of FB_BLANK_ */
72585 /* blit-only rendering path metrics, exposed through sysfs */
72586 - atomic_t bytes_rendered; /* raw pixel-bytes driver asked to render */
72587 - atomic_t bytes_identical; /* saved effort with backbuffer comparison */
72588 - atomic_t bytes_sent; /* to usb, after compression including overhead */
72589 - atomic_t cpu_kcycles_used; /* transpired during pixel processing */
72590 + atomic_unchecked_t bytes_rendered; /* raw pixel-bytes driver asked to render */
72591 + atomic_unchecked_t bytes_identical; /* saved effort with backbuffer comparison */
72592 + atomic_unchecked_t bytes_sent; /* to usb, after compression including overhead */
72593 + atomic_unchecked_t cpu_kcycles_used; /* transpired during pixel processing */
72594 };
72595
72596 #define NR_USB_REQUEST_I2C_SUB_IO 0x02
72597 diff --git a/include/video/uvesafb.h b/include/video/uvesafb.h
72598 index 0993a22..32ba2fe 100644
72599 --- a/include/video/uvesafb.h
72600 +++ b/include/video/uvesafb.h
72601 @@ -177,6 +177,7 @@ struct uvesafb_par {
72602 u8 ypan; /* 0 - nothing, 1 - ypan, 2 - ywrap */
72603 u8 pmi_setpal; /* PMI for palette changes */
72604 u16 *pmi_base; /* protected mode interface location */
72605 + u8 *pmi_code; /* protected mode code location */
72606 void *pmi_start;
72607 void *pmi_pal;
72608 u8 *vbe_state_orig; /*
72609 diff --git a/init/Kconfig b/init/Kconfig
72610 index be8b7f5..1eeca9b 100644
72611 --- a/init/Kconfig
72612 +++ b/init/Kconfig
72613 @@ -990,6 +990,7 @@ endif # CGROUPS
72614
72615 config CHECKPOINT_RESTORE
72616 bool "Checkpoint/restore support" if EXPERT
72617 + depends on !GRKERNSEC
72618 default n
72619 help
72620 Enables additional kernel features in a sake of checkpoint/restore.
72621 @@ -1468,7 +1469,7 @@ config SLUB_DEBUG
72622
72623 config COMPAT_BRK
72624 bool "Disable heap randomization"
72625 - default y
72626 + default n
72627 help
72628 Randomizing heap placement makes heap exploits harder, but it
72629 also breaks ancient binaries (including anything libc5 based).
72630 @@ -1711,7 +1712,7 @@ config INIT_ALL_POSSIBLE
72631 config STOP_MACHINE
72632 bool
72633 default y
72634 - depends on (SMP && MODULE_UNLOAD) || HOTPLUG_CPU
72635 + depends on (SMP && MODULE_UNLOAD) || HOTPLUG_CPU || GRKERNSEC
72636 help
72637 Need stop_machine() primitive.
72638
72639 diff --git a/init/Makefile b/init/Makefile
72640 index 7bc47ee..6da2dc7 100644
72641 --- a/init/Makefile
72642 +++ b/init/Makefile
72643 @@ -2,6 +2,9 @@
72644 # Makefile for the linux kernel.
72645 #
72646
72647 +ccflags-y := $(GCC_PLUGINS_CFLAGS)
72648 +asflags-y := $(GCC_PLUGINS_AFLAGS)
72649 +
72650 obj-y := main.o version.o mounts.o
72651 ifneq ($(CONFIG_BLK_DEV_INITRD),y)
72652 obj-y += noinitramfs.o
72653 diff --git a/init/do_mounts.c b/init/do_mounts.c
72654 index 1d1b634..a1c810f 100644
72655 --- a/init/do_mounts.c
72656 +++ b/init/do_mounts.c
72657 @@ -355,11 +355,11 @@ static void __init get_fs_names(char *page)
72658 static int __init do_mount_root(char *name, char *fs, int flags, void *data)
72659 {
72660 struct super_block *s;
72661 - int err = sys_mount(name, "/root", fs, flags, data);
72662 + int err = sys_mount((char __force_user *)name, (char __force_user *)"/root", (char __force_user *)fs, flags, (void __force_user *)data);
72663 if (err)
72664 return err;
72665
72666 - sys_chdir("/root");
72667 + sys_chdir((const char __force_user *)"/root");
72668 s = current->fs->pwd.dentry->d_sb;
72669 ROOT_DEV = s->s_dev;
72670 printk(KERN_INFO
72671 @@ -480,18 +480,18 @@ void __init change_floppy(char *fmt, ...)
72672 va_start(args, fmt);
72673 vsprintf(buf, fmt, args);
72674 va_end(args);
72675 - fd = sys_open("/dev/root", O_RDWR | O_NDELAY, 0);
72676 + fd = sys_open((char __user *)"/dev/root", O_RDWR | O_NDELAY, 0);
72677 if (fd >= 0) {
72678 sys_ioctl(fd, FDEJECT, 0);
72679 sys_close(fd);
72680 }
72681 printk(KERN_NOTICE "VFS: Insert %s and press ENTER\n", buf);
72682 - fd = sys_open("/dev/console", O_RDWR, 0);
72683 + fd = sys_open((__force const char __user *)"/dev/console", O_RDWR, 0);
72684 if (fd >= 0) {
72685 sys_ioctl(fd, TCGETS, (long)&termios);
72686 termios.c_lflag &= ~ICANON;
72687 sys_ioctl(fd, TCSETSF, (long)&termios);
72688 - sys_read(fd, &c, 1);
72689 + sys_read(fd, (char __user *)&c, 1);
72690 termios.c_lflag |= ICANON;
72691 sys_ioctl(fd, TCSETSF, (long)&termios);
72692 sys_close(fd);
72693 @@ -585,6 +585,6 @@ void __init prepare_namespace(void)
72694 mount_root();
72695 out:
72696 devtmpfs_mount("dev");
72697 - sys_mount(".", "/", NULL, MS_MOVE, NULL);
72698 - sys_chroot(".");
72699 + sys_mount((char __force_user *)".", (char __force_user *)"/", NULL, MS_MOVE, NULL);
72700 + sys_chroot((const char __force_user *)".");
72701 }
72702 diff --git a/init/do_mounts.h b/init/do_mounts.h
72703 index f5b978a..69dbfe8 100644
72704 --- a/init/do_mounts.h
72705 +++ b/init/do_mounts.h
72706 @@ -15,15 +15,15 @@ extern int root_mountflags;
72707
72708 static inline int create_dev(char *name, dev_t dev)
72709 {
72710 - sys_unlink(name);
72711 - return sys_mknod(name, S_IFBLK|0600, new_encode_dev(dev));
72712 + sys_unlink((char __force_user *)name);
72713 + return sys_mknod((char __force_user *)name, S_IFBLK|0600, new_encode_dev(dev));
72714 }
72715
72716 #if BITS_PER_LONG == 32
72717 static inline u32 bstat(char *name)
72718 {
72719 struct stat64 stat;
72720 - if (sys_stat64(name, &stat) != 0)
72721 + if (sys_stat64((char __force_user *)name, (struct stat64 __force_user *)&stat) != 0)
72722 return 0;
72723 if (!S_ISBLK(stat.st_mode))
72724 return 0;
72725 @@ -35,7 +35,7 @@ static inline u32 bstat(char *name)
72726 static inline u32 bstat(char *name)
72727 {
72728 struct stat stat;
72729 - if (sys_newstat(name, &stat) != 0)
72730 + if (sys_newstat((const char __force_user *)name, (struct stat __force_user *)&stat) != 0)
72731 return 0;
72732 if (!S_ISBLK(stat.st_mode))
72733 return 0;
72734 diff --git a/init/do_mounts_initrd.c b/init/do_mounts_initrd.c
72735 index f9acf71..1e19144 100644
72736 --- a/init/do_mounts_initrd.c
72737 +++ b/init/do_mounts_initrd.c
72738 @@ -58,8 +58,8 @@ static void __init handle_initrd(void)
72739 create_dev("/dev/root.old", Root_RAM0);
72740 /* mount initrd on rootfs' /root */
72741 mount_block_root("/dev/root.old", root_mountflags & ~MS_RDONLY);
72742 - sys_mkdir("/old", 0700);
72743 - sys_chdir("/old");
72744 + sys_mkdir((const char __force_user *)"/old", 0700);
72745 + sys_chdir((const char __force_user *)"/old");
72746
72747 /*
72748 * In case that a resume from disk is carried out by linuxrc or one of
72749 @@ -73,31 +73,31 @@ static void __init handle_initrd(void)
72750 current->flags &= ~PF_FREEZER_SKIP;
72751
72752 /* move initrd to rootfs' /old */
72753 - sys_mount("..", ".", NULL, MS_MOVE, NULL);
72754 + sys_mount((char __force_user *)"..", (char __force_user *)".", NULL, MS_MOVE, NULL);
72755 /* switch root and cwd back to / of rootfs */
72756 - sys_chroot("..");
72757 + sys_chroot((const char __force_user *)"..");
72758
72759 if (new_decode_dev(real_root_dev) == Root_RAM0) {
72760 - sys_chdir("/old");
72761 + sys_chdir((const char __force_user *)"/old");
72762 return;
72763 }
72764
72765 - sys_chdir("/");
72766 + sys_chdir((const char __force_user *)"/");
72767 ROOT_DEV = new_decode_dev(real_root_dev);
72768 mount_root();
72769
72770 printk(KERN_NOTICE "Trying to move old root to /initrd ... ");
72771 - error = sys_mount("/old", "/root/initrd", NULL, MS_MOVE, NULL);
72772 + error = sys_mount((char __force_user *)"/old", (char __force_user *)"/root/initrd", NULL, MS_MOVE, NULL);
72773 if (!error)
72774 printk("okay\n");
72775 else {
72776 - int fd = sys_open("/dev/root.old", O_RDWR, 0);
72777 + int fd = sys_open((const char __force_user *)"/dev/root.old", O_RDWR, 0);
72778 if (error == -ENOENT)
72779 printk("/initrd does not exist. Ignored.\n");
72780 else
72781 printk("failed\n");
72782 printk(KERN_NOTICE "Unmounting old root\n");
72783 - sys_umount("/old", MNT_DETACH);
72784 + sys_umount((char __force_user *)"/old", MNT_DETACH);
72785 printk(KERN_NOTICE "Trying to free ramdisk memory ... ");
72786 if (fd < 0) {
72787 error = fd;
72788 @@ -120,11 +120,11 @@ int __init initrd_load(void)
72789 * mounted in the normal path.
72790 */
72791 if (rd_load_image("/initrd.image") && ROOT_DEV != Root_RAM0) {
72792 - sys_unlink("/initrd.image");
72793 + sys_unlink((const char __force_user *)"/initrd.image");
72794 handle_initrd();
72795 return 1;
72796 }
72797 }
72798 - sys_unlink("/initrd.image");
72799 + sys_unlink((const char __force_user *)"/initrd.image");
72800 return 0;
72801 }
72802 diff --git a/init/do_mounts_md.c b/init/do_mounts_md.c
72803 index 8cb6db5..d729f50 100644
72804 --- a/init/do_mounts_md.c
72805 +++ b/init/do_mounts_md.c
72806 @@ -180,7 +180,7 @@ static void __init md_setup_drive(void)
72807 partitioned ? "_d" : "", minor,
72808 md_setup_args[ent].device_names);
72809
72810 - fd = sys_open(name, 0, 0);
72811 + fd = sys_open((char __force_user *)name, 0, 0);
72812 if (fd < 0) {
72813 printk(KERN_ERR "md: open failed - cannot start "
72814 "array %s\n", name);
72815 @@ -243,7 +243,7 @@ static void __init md_setup_drive(void)
72816 * array without it
72817 */
72818 sys_close(fd);
72819 - fd = sys_open(name, 0, 0);
72820 + fd = sys_open((char __force_user *)name, 0, 0);
72821 sys_ioctl(fd, BLKRRPART, 0);
72822 }
72823 sys_close(fd);
72824 @@ -293,7 +293,7 @@ static void __init autodetect_raid(void)
72825
72826 wait_for_device_probe();
72827
72828 - fd = sys_open("/dev/md0", 0, 0);
72829 + fd = sys_open((const char __force_user *) "/dev/md0", 0, 0);
72830 if (fd >= 0) {
72831 sys_ioctl(fd, RAID_AUTORUN, raid_autopart);
72832 sys_close(fd);
72833 diff --git a/init/init_task.c b/init/init_task.c
72834 index 8b2f399..f0797c9 100644
72835 --- a/init/init_task.c
72836 +++ b/init/init_task.c
72837 @@ -20,5 +20,9 @@ EXPORT_SYMBOL(init_task);
72838 * Initial thread structure. Alignment of this is handled by a special
72839 * linker map entry.
72840 */
72841 +#ifdef CONFIG_X86
72842 +union thread_union init_thread_union __init_task_data;
72843 +#else
72844 union thread_union init_thread_union __init_task_data =
72845 { INIT_THREAD_INFO(init_task) };
72846 +#endif
72847 diff --git a/init/initramfs.c b/init/initramfs.c
72848 index 84c6bf1..8899338 100644
72849 --- a/init/initramfs.c
72850 +++ b/init/initramfs.c
72851 @@ -84,7 +84,7 @@ static void __init free_hash(void)
72852 }
72853 }
72854
72855 -static long __init do_utime(char *filename, time_t mtime)
72856 +static long __init do_utime(char __force_user *filename, time_t mtime)
72857 {
72858 struct timespec t[2];
72859
72860 @@ -119,7 +119,7 @@ static void __init dir_utime(void)
72861 struct dir_entry *de, *tmp;
72862 list_for_each_entry_safe(de, tmp, &dir_list, list) {
72863 list_del(&de->list);
72864 - do_utime(de->name, de->mtime);
72865 + do_utime((char __force_user *)de->name, de->mtime);
72866 kfree(de->name);
72867 kfree(de);
72868 }
72869 @@ -281,7 +281,7 @@ static int __init maybe_link(void)
72870 if (nlink >= 2) {
72871 char *old = find_link(major, minor, ino, mode, collected);
72872 if (old)
72873 - return (sys_link(old, collected) < 0) ? -1 : 1;
72874 + return (sys_link((char __force_user *)old, (char __force_user *)collected) < 0) ? -1 : 1;
72875 }
72876 return 0;
72877 }
72878 @@ -290,11 +290,11 @@ static void __init clean_path(char *path, umode_t mode)
72879 {
72880 struct stat st;
72881
72882 - if (!sys_newlstat(path, &st) && (st.st_mode^mode) & S_IFMT) {
72883 + if (!sys_newlstat((char __force_user *)path, (struct stat __force_user *)&st) && (st.st_mode^mode) & S_IFMT) {
72884 if (S_ISDIR(st.st_mode))
72885 - sys_rmdir(path);
72886 + sys_rmdir((char __force_user *)path);
72887 else
72888 - sys_unlink(path);
72889 + sys_unlink((char __force_user *)path);
72890 }
72891 }
72892
72893 @@ -315,7 +315,7 @@ static int __init do_name(void)
72894 int openflags = O_WRONLY|O_CREAT;
72895 if (ml != 1)
72896 openflags |= O_TRUNC;
72897 - wfd = sys_open(collected, openflags, mode);
72898 + wfd = sys_open((char __force_user *)collected, openflags, mode);
72899
72900 if (wfd >= 0) {
72901 sys_fchown(wfd, uid, gid);
72902 @@ -327,17 +327,17 @@ static int __init do_name(void)
72903 }
72904 }
72905 } else if (S_ISDIR(mode)) {
72906 - sys_mkdir(collected, mode);
72907 - sys_chown(collected, uid, gid);
72908 - sys_chmod(collected, mode);
72909 + sys_mkdir((char __force_user *)collected, mode);
72910 + sys_chown((char __force_user *)collected, uid, gid);
72911 + sys_chmod((char __force_user *)collected, mode);
72912 dir_add(collected, mtime);
72913 } else if (S_ISBLK(mode) || S_ISCHR(mode) ||
72914 S_ISFIFO(mode) || S_ISSOCK(mode)) {
72915 if (maybe_link() == 0) {
72916 - sys_mknod(collected, mode, rdev);
72917 - sys_chown(collected, uid, gid);
72918 - sys_chmod(collected, mode);
72919 - do_utime(collected, mtime);
72920 + sys_mknod((char __force_user *)collected, mode, rdev);
72921 + sys_chown((char __force_user *)collected, uid, gid);
72922 + sys_chmod((char __force_user *)collected, mode);
72923 + do_utime((char __force_user *)collected, mtime);
72924 }
72925 }
72926 return 0;
72927 @@ -346,15 +346,15 @@ static int __init do_name(void)
72928 static int __init do_copy(void)
72929 {
72930 if (count >= body_len) {
72931 - sys_write(wfd, victim, body_len);
72932 + sys_write(wfd, (char __force_user *)victim, body_len);
72933 sys_close(wfd);
72934 - do_utime(vcollected, mtime);
72935 + do_utime((char __force_user *)vcollected, mtime);
72936 kfree(vcollected);
72937 eat(body_len);
72938 state = SkipIt;
72939 return 0;
72940 } else {
72941 - sys_write(wfd, victim, count);
72942 + sys_write(wfd, (char __force_user *)victim, count);
72943 body_len -= count;
72944 eat(count);
72945 return 1;
72946 @@ -365,9 +365,9 @@ static int __init do_symlink(void)
72947 {
72948 collected[N_ALIGN(name_len) + body_len] = '\0';
72949 clean_path(collected, 0);
72950 - sys_symlink(collected + N_ALIGN(name_len), collected);
72951 - sys_lchown(collected, uid, gid);
72952 - do_utime(collected, mtime);
72953 + sys_symlink((char __force_user *)collected + N_ALIGN(name_len), (char __force_user *)collected);
72954 + sys_lchown((char __force_user *)collected, uid, gid);
72955 + do_utime((char __force_user *)collected, mtime);
72956 state = SkipIt;
72957 next_state = Reset;
72958 return 0;
72959 diff --git a/init/main.c b/init/main.c
72960 index cee4b5c..360e10a 100644
72961 --- a/init/main.c
72962 +++ b/init/main.c
72963 @@ -96,6 +96,8 @@ static inline void mark_rodata_ro(void) { }
72964 extern void tc_init(void);
72965 #endif
72966
72967 +extern void grsecurity_init(void);
72968 +
72969 /*
72970 * Debug helper: via this flag we know that we are in 'early bootup code'
72971 * where only the boot processor is running with IRQ disabled. This means
72972 @@ -149,6 +151,61 @@ static int __init set_reset_devices(char *str)
72973
72974 __setup("reset_devices", set_reset_devices);
72975
72976 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
72977 +kgid_t grsec_proc_gid = KGIDT_INIT(CONFIG_GRKERNSEC_PROC_GID);
72978 +static int __init setup_grsec_proc_gid(char *str)
72979 +{
72980 + grsec_proc_gid = KGIDT_INIT(simple_strtol(str, NULL, 0));
72981 + return 1;
72982 +}
72983 +__setup("grsec_proc_gid=", setup_grsec_proc_gid);
72984 +#endif
72985 +
72986 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
72987 +extern char pax_enter_kernel_user[];
72988 +extern char pax_exit_kernel_user[];
72989 +extern pgdval_t clone_pgd_mask;
72990 +#endif
72991 +
72992 +#if defined(CONFIG_X86) && defined(CONFIG_PAX_MEMORY_UDEREF)
72993 +static int __init setup_pax_nouderef(char *str)
72994 +{
72995 +#ifdef CONFIG_X86_32
72996 + unsigned int cpu;
72997 + struct desc_struct *gdt;
72998 +
72999 + for (cpu = 0; cpu < nr_cpu_ids; cpu++) {
73000 + gdt = get_cpu_gdt_table(cpu);
73001 + gdt[GDT_ENTRY_KERNEL_DS].type = 3;
73002 + gdt[GDT_ENTRY_KERNEL_DS].limit = 0xf;
73003 + gdt[GDT_ENTRY_DEFAULT_USER_CS].limit = 0xf;
73004 + gdt[GDT_ENTRY_DEFAULT_USER_DS].limit = 0xf;
73005 + }
73006 + loadsegment(ds, __KERNEL_DS);
73007 + loadsegment(es, __KERNEL_DS);
73008 + loadsegment(ss, __KERNEL_DS);
73009 +#else
73010 + memcpy(pax_enter_kernel_user, (unsigned char []){0xc3}, 1);
73011 + memcpy(pax_exit_kernel_user, (unsigned char []){0xc3}, 1);
73012 + clone_pgd_mask = ~(pgdval_t)0UL;
73013 +#endif
73014 +
73015 + return 0;
73016 +}
73017 +early_param("pax_nouderef", setup_pax_nouderef);
73018 +#endif
73019 +
73020 +#ifdef CONFIG_PAX_SOFTMODE
73021 +int pax_softmode;
73022 +
73023 +static int __init setup_pax_softmode(char *str)
73024 +{
73025 + get_option(&str, &pax_softmode);
73026 + return 1;
73027 +}
73028 +__setup("pax_softmode=", setup_pax_softmode);
73029 +#endif
73030 +
73031 static const char * argv_init[MAX_INIT_ARGS+2] = { "init", NULL, };
73032 const char * envp_init[MAX_INIT_ENVS+2] = { "HOME=/", "TERM=linux", NULL, };
73033 static const char *panic_later, *panic_param;
73034 @@ -681,6 +738,7 @@ int __init_or_module do_one_initcall(initcall_t fn)
73035 {
73036 int count = preempt_count();
73037 int ret;
73038 + const char *msg1 = "", *msg2 = "";
73039
73040 if (initcall_debug)
73041 ret = do_one_initcall_debug(fn);
73042 @@ -693,15 +751,15 @@ int __init_or_module do_one_initcall(initcall_t fn)
73043 sprintf(msgbuf, "error code %d ", ret);
73044
73045 if (preempt_count() != count) {
73046 - strlcat(msgbuf, "preemption imbalance ", sizeof(msgbuf));
73047 + msg1 = " preemption imbalance";
73048 preempt_count() = count;
73049 }
73050 if (irqs_disabled()) {
73051 - strlcat(msgbuf, "disabled interrupts ", sizeof(msgbuf));
73052 + msg2 = " disabled interrupts";
73053 local_irq_enable();
73054 }
73055 - if (msgbuf[0]) {
73056 - printk("initcall %pF returned with %s\n", fn, msgbuf);
73057 + if (msgbuf[0] || *msg1 || *msg2) {
73058 + printk("initcall %pF returned with %s%s%s\n", fn, msgbuf, msg1, msg2);
73059 }
73060
73061 return ret;
73062 @@ -755,8 +813,14 @@ static void __init do_initcall_level(int level)
73063 level, level,
73064 &repair_env_string);
73065
73066 - for (fn = initcall_levels[level]; fn < initcall_levels[level+1]; fn++)
73067 + for (fn = initcall_levels[level]; fn < initcall_levels[level+1]; fn++) {
73068 do_one_initcall(*fn);
73069 +
73070 +#ifdef LATENT_ENTROPY_PLUGIN
73071 + add_device_randomness((const void *)&latent_entropy, sizeof(latent_entropy));
73072 +#endif
73073 +
73074 + }
73075 }
73076
73077 static void __init do_initcalls(void)
73078 @@ -790,8 +854,14 @@ static void __init do_pre_smp_initcalls(void)
73079 {
73080 initcall_t *fn;
73081
73082 - for (fn = __initcall_start; fn < __initcall0_start; fn++)
73083 + for (fn = __initcall_start; fn < __initcall0_start; fn++) {
73084 do_one_initcall(*fn);
73085 +
73086 +#ifdef LATENT_ENTROPY_PLUGIN
73087 + add_device_randomness((const void *)&latent_entropy, sizeof(latent_entropy));
73088 +#endif
73089 +
73090 + }
73091 }
73092
73093 static int run_init_process(const char *init_filename)
73094 @@ -877,7 +947,7 @@ static noinline void __init kernel_init_freeable(void)
73095 do_basic_setup();
73096
73097 /* Open the /dev/console on the rootfs, this should never fail */
73098 - if (sys_open((const char __user *) "/dev/console", O_RDWR, 0) < 0)
73099 + if (sys_open((const char __force_user *) "/dev/console", O_RDWR, 0) < 0)
73100 printk(KERN_WARNING "Warning: unable to open an initial console.\n");
73101
73102 (void) sys_dup(0);
73103 @@ -890,11 +960,13 @@ static noinline void __init kernel_init_freeable(void)
73104 if (!ramdisk_execute_command)
73105 ramdisk_execute_command = "/init";
73106
73107 - if (sys_access((const char __user *) ramdisk_execute_command, 0) != 0) {
73108 + if (sys_access((const char __force_user *) ramdisk_execute_command, 0) != 0) {
73109 ramdisk_execute_command = NULL;
73110 prepare_namespace();
73111 }
73112
73113 + grsecurity_init();
73114 +
73115 /*
73116 * Ok, we have completed the initial bootup, and
73117 * we're essentially up and running. Get rid of the
73118 diff --git a/ipc/ipc_sysctl.c b/ipc/ipc_sysctl.c
73119 index 130dfec..cc88451 100644
73120 --- a/ipc/ipc_sysctl.c
73121 +++ b/ipc/ipc_sysctl.c
73122 @@ -30,7 +30,7 @@ static void *get_ipc(ctl_table *table)
73123 static int proc_ipc_dointvec(ctl_table *table, int write,
73124 void __user *buffer, size_t *lenp, loff_t *ppos)
73125 {
73126 - struct ctl_table ipc_table;
73127 + ctl_table_no_const ipc_table;
73128
73129 memcpy(&ipc_table, table, sizeof(ipc_table));
73130 ipc_table.data = get_ipc(table);
73131 @@ -41,7 +41,7 @@ static int proc_ipc_dointvec(ctl_table *table, int write,
73132 static int proc_ipc_dointvec_minmax(ctl_table *table, int write,
73133 void __user *buffer, size_t *lenp, loff_t *ppos)
73134 {
73135 - struct ctl_table ipc_table;
73136 + ctl_table_no_const ipc_table;
73137
73138 memcpy(&ipc_table, table, sizeof(ipc_table));
73139 ipc_table.data = get_ipc(table);
73140 @@ -65,7 +65,7 @@ static int proc_ipc_dointvec_minmax_orphans(ctl_table *table, int write,
73141 static int proc_ipc_callback_dointvec(ctl_table *table, int write,
73142 void __user *buffer, size_t *lenp, loff_t *ppos)
73143 {
73144 - struct ctl_table ipc_table;
73145 + ctl_table_no_const ipc_table;
73146 size_t lenp_bef = *lenp;
73147 int rc;
73148
73149 @@ -88,7 +88,7 @@ static int proc_ipc_callback_dointvec(ctl_table *table, int write,
73150 static int proc_ipc_doulongvec_minmax(ctl_table *table, int write,
73151 void __user *buffer, size_t *lenp, loff_t *ppos)
73152 {
73153 - struct ctl_table ipc_table;
73154 + ctl_table_no_const ipc_table;
73155 memcpy(&ipc_table, table, sizeof(ipc_table));
73156 ipc_table.data = get_ipc(table);
73157
73158 @@ -122,7 +122,7 @@ static void ipc_auto_callback(int val)
73159 static int proc_ipcauto_dointvec_minmax(ctl_table *table, int write,
73160 void __user *buffer, size_t *lenp, loff_t *ppos)
73161 {
73162 - struct ctl_table ipc_table;
73163 + ctl_table_no_const ipc_table;
73164 size_t lenp_bef = *lenp;
73165 int oldval;
73166 int rc;
73167 diff --git a/ipc/mq_sysctl.c b/ipc/mq_sysctl.c
73168 index 383d638..943fdbb 100644
73169 --- a/ipc/mq_sysctl.c
73170 +++ b/ipc/mq_sysctl.c
73171 @@ -25,7 +25,7 @@ static void *get_mq(ctl_table *table)
73172 static int proc_mq_dointvec_minmax(ctl_table *table, int write,
73173 void __user *buffer, size_t *lenp, loff_t *ppos)
73174 {
73175 - struct ctl_table mq_table;
73176 + ctl_table_no_const mq_table;
73177 memcpy(&mq_table, table, sizeof(mq_table));
73178 mq_table.data = get_mq(table);
73179
73180 diff --git a/ipc/mqueue.c b/ipc/mqueue.c
73181 index 71a3ca1..cc330ee 100644
73182 --- a/ipc/mqueue.c
73183 +++ b/ipc/mqueue.c
73184 @@ -278,6 +278,7 @@ static struct inode *mqueue_get_inode(struct super_block *sb,
73185 mq_bytes = mq_treesize + (info->attr.mq_maxmsg *
73186 info->attr.mq_msgsize);
73187
73188 + gr_learn_resource(current, RLIMIT_MSGQUEUE, u->mq_bytes + mq_bytes, 1);
73189 spin_lock(&mq_lock);
73190 if (u->mq_bytes + mq_bytes < u->mq_bytes ||
73191 u->mq_bytes + mq_bytes > rlimit(RLIMIT_MSGQUEUE)) {
73192 diff --git a/ipc/msg.c b/ipc/msg.c
73193 index 31cd1bf..362ea07 100644
73194 --- a/ipc/msg.c
73195 +++ b/ipc/msg.c
73196 @@ -309,18 +309,19 @@ static inline int msg_security(struct kern_ipc_perm *ipcp, int msgflg)
73197 return security_msg_queue_associate(msq, msgflg);
73198 }
73199
73200 +static struct ipc_ops msg_ops = {
73201 + .getnew = newque,
73202 + .associate = msg_security,
73203 + .more_checks = NULL
73204 +};
73205 +
73206 SYSCALL_DEFINE2(msgget, key_t, key, int, msgflg)
73207 {
73208 struct ipc_namespace *ns;
73209 - struct ipc_ops msg_ops;
73210 struct ipc_params msg_params;
73211
73212 ns = current->nsproxy->ipc_ns;
73213
73214 - msg_ops.getnew = newque;
73215 - msg_ops.associate = msg_security;
73216 - msg_ops.more_checks = NULL;
73217 -
73218 msg_params.key = key;
73219 msg_params.flg = msgflg;
73220
73221 diff --git a/ipc/sem.c b/ipc/sem.c
73222 index 58d31f1..cce7a55 100644
73223 --- a/ipc/sem.c
73224 +++ b/ipc/sem.c
73225 @@ -364,10 +364,15 @@ static inline int sem_more_checks(struct kern_ipc_perm *ipcp,
73226 return 0;
73227 }
73228
73229 +static struct ipc_ops sem_ops = {
73230 + .getnew = newary,
73231 + .associate = sem_security,
73232 + .more_checks = sem_more_checks
73233 +};
73234 +
73235 SYSCALL_DEFINE3(semget, key_t, key, int, nsems, int, semflg)
73236 {
73237 struct ipc_namespace *ns;
73238 - struct ipc_ops sem_ops;
73239 struct ipc_params sem_params;
73240
73241 ns = current->nsproxy->ipc_ns;
73242 @@ -375,10 +380,6 @@ SYSCALL_DEFINE3(semget, key_t, key, int, nsems, int, semflg)
73243 if (nsems < 0 || nsems > ns->sc_semmsl)
73244 return -EINVAL;
73245
73246 - sem_ops.getnew = newary;
73247 - sem_ops.associate = sem_security;
73248 - sem_ops.more_checks = sem_more_checks;
73249 -
73250 sem_params.key = key;
73251 sem_params.flg = semflg;
73252 sem_params.u.nsems = nsems;
73253 diff --git a/ipc/shm.c b/ipc/shm.c
73254 index 4fa6d8f..55cff14 100644
73255 --- a/ipc/shm.c
73256 +++ b/ipc/shm.c
73257 @@ -69,6 +69,14 @@ static void shm_destroy (struct ipc_namespace *ns, struct shmid_kernel *shp);
73258 static int sysvipc_shm_proc_show(struct seq_file *s, void *it);
73259 #endif
73260
73261 +#ifdef CONFIG_GRKERNSEC
73262 +extern int gr_handle_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
73263 + const time_t shm_createtime, const kuid_t cuid,
73264 + const int shmid);
73265 +extern int gr_chroot_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
73266 + const time_t shm_createtime);
73267 +#endif
73268 +
73269 void shm_init_ns(struct ipc_namespace *ns)
73270 {
73271 ns->shm_ctlmax = SHMMAX;
73272 @@ -521,6 +529,14 @@ static int newseg(struct ipc_namespace *ns, struct ipc_params *params)
73273 shp->shm_lprid = 0;
73274 shp->shm_atim = shp->shm_dtim = 0;
73275 shp->shm_ctim = get_seconds();
73276 +#ifdef CONFIG_GRKERNSEC
73277 + {
73278 + struct timespec timeval;
73279 + do_posix_clock_monotonic_gettime(&timeval);
73280 +
73281 + shp->shm_createtime = timeval.tv_sec;
73282 + }
73283 +#endif
73284 shp->shm_segsz = size;
73285 shp->shm_nattch = 0;
73286 shp->shm_file = file;
73287 @@ -572,18 +588,19 @@ static inline int shm_more_checks(struct kern_ipc_perm *ipcp,
73288 return 0;
73289 }
73290
73291 +static struct ipc_ops shm_ops = {
73292 + .getnew = newseg,
73293 + .associate = shm_security,
73294 + .more_checks = shm_more_checks
73295 +};
73296 +
73297 SYSCALL_DEFINE3(shmget, key_t, key, size_t, size, int, shmflg)
73298 {
73299 struct ipc_namespace *ns;
73300 - struct ipc_ops shm_ops;
73301 struct ipc_params shm_params;
73302
73303 ns = current->nsproxy->ipc_ns;
73304
73305 - shm_ops.getnew = newseg;
73306 - shm_ops.associate = shm_security;
73307 - shm_ops.more_checks = shm_more_checks;
73308 -
73309 shm_params.key = key;
73310 shm_params.flg = shmflg;
73311 shm_params.u.size = size;
73312 @@ -1004,6 +1021,12 @@ long do_shmat(int shmid, char __user *shmaddr, int shmflg, ulong *raddr,
73313 f_mode = FMODE_READ | FMODE_WRITE;
73314 }
73315 if (shmflg & SHM_EXEC) {
73316 +
73317 +#ifdef CONFIG_PAX_MPROTECT
73318 + if (current->mm->pax_flags & MF_PAX_MPROTECT)
73319 + goto out;
73320 +#endif
73321 +
73322 prot |= PROT_EXEC;
73323 acc_mode |= S_IXUGO;
73324 }
73325 @@ -1027,9 +1050,21 @@ long do_shmat(int shmid, char __user *shmaddr, int shmflg, ulong *raddr,
73326 if (err)
73327 goto out_unlock;
73328
73329 +#ifdef CONFIG_GRKERNSEC
73330 + if (!gr_handle_shmat(shp->shm_cprid, shp->shm_lapid, shp->shm_createtime,
73331 + shp->shm_perm.cuid, shmid) ||
73332 + !gr_chroot_shmat(shp->shm_cprid, shp->shm_lapid, shp->shm_createtime)) {
73333 + err = -EACCES;
73334 + goto out_unlock;
73335 + }
73336 +#endif
73337 +
73338 path = shp->shm_file->f_path;
73339 path_get(&path);
73340 shp->shm_nattch++;
73341 +#ifdef CONFIG_GRKERNSEC
73342 + shp->shm_lapid = current->pid;
73343 +#endif
73344 size = i_size_read(path.dentry->d_inode);
73345 shm_unlock(shp);
73346
73347 diff --git a/kernel/acct.c b/kernel/acct.c
73348 index 051e071..15e0920 100644
73349 --- a/kernel/acct.c
73350 +++ b/kernel/acct.c
73351 @@ -550,7 +550,7 @@ static void do_acct_process(struct bsd_acct_struct *acct,
73352 */
73353 flim = current->signal->rlim[RLIMIT_FSIZE].rlim_cur;
73354 current->signal->rlim[RLIMIT_FSIZE].rlim_cur = RLIM_INFINITY;
73355 - file->f_op->write(file, (char *)&ac,
73356 + file->f_op->write(file, (char __force_user *)&ac,
73357 sizeof(acct_t), &file->f_pos);
73358 current->signal->rlim[RLIMIT_FSIZE].rlim_cur = flim;
73359 set_fs(fs);
73360 diff --git a/kernel/audit.c b/kernel/audit.c
73361 index d596e53..dbef3c3 100644
73362 --- a/kernel/audit.c
73363 +++ b/kernel/audit.c
73364 @@ -116,7 +116,7 @@ u32 audit_sig_sid = 0;
73365 3) suppressed due to audit_rate_limit
73366 4) suppressed due to audit_backlog_limit
73367 */
73368 -static atomic_t audit_lost = ATOMIC_INIT(0);
73369 +static atomic_unchecked_t audit_lost = ATOMIC_INIT(0);
73370
73371 /* The netlink socket. */
73372 static struct sock *audit_sock;
73373 @@ -238,7 +238,7 @@ void audit_log_lost(const char *message)
73374 unsigned long now;
73375 int print;
73376
73377 - atomic_inc(&audit_lost);
73378 + atomic_inc_unchecked(&audit_lost);
73379
73380 print = (audit_failure == AUDIT_FAIL_PANIC || !audit_rate_limit);
73381
73382 @@ -257,7 +257,7 @@ void audit_log_lost(const char *message)
73383 printk(KERN_WARNING
73384 "audit: audit_lost=%d audit_rate_limit=%d "
73385 "audit_backlog_limit=%d\n",
73386 - atomic_read(&audit_lost),
73387 + atomic_read_unchecked(&audit_lost),
73388 audit_rate_limit,
73389 audit_backlog_limit);
73390 audit_panic(message);
73391 @@ -681,7 +681,7 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
73392 status_set.pid = audit_pid;
73393 status_set.rate_limit = audit_rate_limit;
73394 status_set.backlog_limit = audit_backlog_limit;
73395 - status_set.lost = atomic_read(&audit_lost);
73396 + status_set.lost = atomic_read_unchecked(&audit_lost);
73397 status_set.backlog = skb_queue_len(&audit_skb_queue);
73398 audit_send_reply(NETLINK_CB(skb).portid, seq, AUDIT_GET, 0, 0,
73399 &status_set, sizeof(status_set));
73400 diff --git a/kernel/auditsc.c b/kernel/auditsc.c
73401 index a371f85..da826c1 100644
73402 --- a/kernel/auditsc.c
73403 +++ b/kernel/auditsc.c
73404 @@ -2292,7 +2292,7 @@ int auditsc_get_stamp(struct audit_context *ctx,
73405 }
73406
73407 /* global counter which is incremented every time something logs in */
73408 -static atomic_t session_id = ATOMIC_INIT(0);
73409 +static atomic_unchecked_t session_id = ATOMIC_INIT(0);
73410
73411 /**
73412 * audit_set_loginuid - set current task's audit_context loginuid
73413 @@ -2316,7 +2316,7 @@ int audit_set_loginuid(kuid_t loginuid)
73414 return -EPERM;
73415 #endif /* CONFIG_AUDIT_LOGINUID_IMMUTABLE */
73416
73417 - sessionid = atomic_inc_return(&session_id);
73418 + sessionid = atomic_inc_return_unchecked(&session_id);
73419 if (context && context->in_syscall) {
73420 struct audit_buffer *ab;
73421
73422 diff --git a/kernel/capability.c b/kernel/capability.c
73423 index 493d972..f87dfbd 100644
73424 --- a/kernel/capability.c
73425 +++ b/kernel/capability.c
73426 @@ -202,6 +202,9 @@ SYSCALL_DEFINE2(capget, cap_user_header_t, header, cap_user_data_t, dataptr)
73427 * before modification is attempted and the application
73428 * fails.
73429 */
73430 + if (tocopy > ARRAY_SIZE(kdata))
73431 + return -EFAULT;
73432 +
73433 if (copy_to_user(dataptr, kdata, tocopy
73434 * sizeof(struct __user_cap_data_struct))) {
73435 return -EFAULT;
73436 @@ -303,10 +306,11 @@ bool has_ns_capability(struct task_struct *t,
73437 int ret;
73438
73439 rcu_read_lock();
73440 - ret = security_capable(__task_cred(t), ns, cap);
73441 + ret = security_capable(__task_cred(t), ns, cap) == 0 &&
73442 + gr_task_is_capable(t, __task_cred(t), cap);
73443 rcu_read_unlock();
73444
73445 - return (ret == 0);
73446 + return ret;
73447 }
73448
73449 /**
73450 @@ -343,10 +347,10 @@ bool has_ns_capability_noaudit(struct task_struct *t,
73451 int ret;
73452
73453 rcu_read_lock();
73454 - ret = security_capable_noaudit(__task_cred(t), ns, cap);
73455 + ret = security_capable_noaudit(__task_cred(t), ns, cap) == 0 && gr_task_is_capable_nolog(t, cap);
73456 rcu_read_unlock();
73457
73458 - return (ret == 0);
73459 + return ret;
73460 }
73461
73462 /**
73463 @@ -384,7 +388,7 @@ bool ns_capable(struct user_namespace *ns, int cap)
73464 BUG();
73465 }
73466
73467 - if (security_capable(current_cred(), ns, cap) == 0) {
73468 + if (security_capable(current_cred(), ns, cap) == 0 && gr_is_capable(cap)) {
73469 current->flags |= PF_SUPERPRIV;
73470 return true;
73471 }
73472 @@ -392,6 +396,21 @@ bool ns_capable(struct user_namespace *ns, int cap)
73473 }
73474 EXPORT_SYMBOL(ns_capable);
73475
73476 +bool ns_capable_nolog(struct user_namespace *ns, int cap)
73477 +{
73478 + if (unlikely(!cap_valid(cap))) {
73479 + printk(KERN_CRIT "capable_nolog() called with invalid cap=%u\n", cap);
73480 + BUG();
73481 + }
73482 +
73483 + if (security_capable_noaudit(current_cred(), ns, cap) == 0 && gr_is_capable_nolog(cap)) {
73484 + current->flags |= PF_SUPERPRIV;
73485 + return true;
73486 + }
73487 + return false;
73488 +}
73489 +EXPORT_SYMBOL(ns_capable_nolog);
73490 +
73491 /**
73492 * capable - Determine if the current task has a superior capability in effect
73493 * @cap: The capability to be tested for
73494 @@ -408,6 +427,12 @@ bool capable(int cap)
73495 }
73496 EXPORT_SYMBOL(capable);
73497
73498 +bool capable_nolog(int cap)
73499 +{
73500 + return ns_capable_nolog(&init_user_ns, cap);
73501 +}
73502 +EXPORT_SYMBOL(capable_nolog);
73503 +
73504 /**
73505 * nsown_capable - Check superior capability to one's own user_ns
73506 * @cap: The capability in question
73507 @@ -440,3 +465,10 @@ bool inode_capable(const struct inode *inode, int cap)
73508
73509 return ns_capable(ns, cap) && kuid_has_mapping(ns, inode->i_uid);
73510 }
73511 +
73512 +bool inode_capable_nolog(const struct inode *inode, int cap)
73513 +{
73514 + struct user_namespace *ns = current_user_ns();
73515 +
73516 + return ns_capable_nolog(ns, cap) && kuid_has_mapping(ns, inode->i_uid);
73517 +}
73518 diff --git a/kernel/cgroup.c b/kernel/cgroup.c
73519 index 1e23664..570a83d 100644
73520 --- a/kernel/cgroup.c
73521 +++ b/kernel/cgroup.c
73522 @@ -5543,7 +5543,7 @@ static int cgroup_css_links_read(struct cgroup *cont,
73523 struct css_set *cg = link->cg;
73524 struct task_struct *task;
73525 int count = 0;
73526 - seq_printf(seq, "css_set %p\n", cg);
73527 + seq_printf(seq, "css_set %pK\n", cg);
73528 list_for_each_entry(task, &cg->tasks, cg_list) {
73529 if (count++ > MAX_TASKS_SHOWN_PER_CSS) {
73530 seq_puts(seq, " ...\n");
73531 diff --git a/kernel/compat.c b/kernel/compat.c
73532 index 36700e9..73d770c 100644
73533 --- a/kernel/compat.c
73534 +++ b/kernel/compat.c
73535 @@ -13,6 +13,7 @@
73536
73537 #include <linux/linkage.h>
73538 #include <linux/compat.h>
73539 +#include <linux/module.h>
73540 #include <linux/errno.h>
73541 #include <linux/time.h>
73542 #include <linux/signal.h>
73543 @@ -220,7 +221,7 @@ static long compat_nanosleep_restart(struct restart_block *restart)
73544 mm_segment_t oldfs;
73545 long ret;
73546
73547 - restart->nanosleep.rmtp = (struct timespec __user *) &rmt;
73548 + restart->nanosleep.rmtp = (struct timespec __force_user *) &rmt;
73549 oldfs = get_fs();
73550 set_fs(KERNEL_DS);
73551 ret = hrtimer_nanosleep_restart(restart);
73552 @@ -252,7 +253,7 @@ asmlinkage long compat_sys_nanosleep(struct compat_timespec __user *rqtp,
73553 oldfs = get_fs();
73554 set_fs(KERNEL_DS);
73555 ret = hrtimer_nanosleep(&tu,
73556 - rmtp ? (struct timespec __user *)&rmt : NULL,
73557 + rmtp ? (struct timespec __force_user *)&rmt : NULL,
73558 HRTIMER_MODE_REL, CLOCK_MONOTONIC);
73559 set_fs(oldfs);
73560
73561 @@ -361,7 +362,7 @@ asmlinkage long compat_sys_sigpending(compat_old_sigset_t __user *set)
73562 mm_segment_t old_fs = get_fs();
73563
73564 set_fs(KERNEL_DS);
73565 - ret = sys_sigpending((old_sigset_t __user *) &s);
73566 + ret = sys_sigpending((old_sigset_t __force_user *) &s);
73567 set_fs(old_fs);
73568 if (ret == 0)
73569 ret = put_user(s, set);
73570 @@ -451,7 +452,7 @@ asmlinkage long compat_sys_old_getrlimit(unsigned int resource,
73571 mm_segment_t old_fs = get_fs();
73572
73573 set_fs(KERNEL_DS);
73574 - ret = sys_old_getrlimit(resource, &r);
73575 + ret = sys_old_getrlimit(resource, (struct rlimit __force_user *)&r);
73576 set_fs(old_fs);
73577
73578 if (!ret) {
73579 @@ -523,7 +524,7 @@ asmlinkage long compat_sys_getrusage(int who, struct compat_rusage __user *ru)
73580 mm_segment_t old_fs = get_fs();
73581
73582 set_fs(KERNEL_DS);
73583 - ret = sys_getrusage(who, (struct rusage __user *) &r);
73584 + ret = sys_getrusage(who, (struct rusage __force_user *) &r);
73585 set_fs(old_fs);
73586
73587 if (ret)
73588 @@ -552,8 +553,8 @@ COMPAT_SYSCALL_DEFINE4(wait4,
73589 set_fs (KERNEL_DS);
73590 ret = sys_wait4(pid,
73591 (stat_addr ?
73592 - (unsigned int __user *) &status : NULL),
73593 - options, (struct rusage __user *) &r);
73594 + (unsigned int __force_user *) &status : NULL),
73595 + options, (struct rusage __force_user *) &r);
73596 set_fs (old_fs);
73597
73598 if (ret > 0) {
73599 @@ -579,8 +580,8 @@ COMPAT_SYSCALL_DEFINE5(waitid,
73600 memset(&info, 0, sizeof(info));
73601
73602 set_fs(KERNEL_DS);
73603 - ret = sys_waitid(which, pid, (siginfo_t __user *)&info, options,
73604 - uru ? (struct rusage __user *)&ru : NULL);
73605 + ret = sys_waitid(which, pid, (siginfo_t __force_user *)&info, options,
73606 + uru ? (struct rusage __force_user *)&ru : NULL);
73607 set_fs(old_fs);
73608
73609 if ((ret < 0) || (info.si_signo == 0))
73610 @@ -714,8 +715,8 @@ long compat_sys_timer_settime(timer_t timer_id, int flags,
73611 oldfs = get_fs();
73612 set_fs(KERNEL_DS);
73613 err = sys_timer_settime(timer_id, flags,
73614 - (struct itimerspec __user *) &newts,
73615 - (struct itimerspec __user *) &oldts);
73616 + (struct itimerspec __force_user *) &newts,
73617 + (struct itimerspec __force_user *) &oldts);
73618 set_fs(oldfs);
73619 if (!err && old && put_compat_itimerspec(old, &oldts))
73620 return -EFAULT;
73621 @@ -732,7 +733,7 @@ long compat_sys_timer_gettime(timer_t timer_id,
73622 oldfs = get_fs();
73623 set_fs(KERNEL_DS);
73624 err = sys_timer_gettime(timer_id,
73625 - (struct itimerspec __user *) &ts);
73626 + (struct itimerspec __force_user *) &ts);
73627 set_fs(oldfs);
73628 if (!err && put_compat_itimerspec(setting, &ts))
73629 return -EFAULT;
73630 @@ -751,7 +752,7 @@ long compat_sys_clock_settime(clockid_t which_clock,
73631 oldfs = get_fs();
73632 set_fs(KERNEL_DS);
73633 err = sys_clock_settime(which_clock,
73634 - (struct timespec __user *) &ts);
73635 + (struct timespec __force_user *) &ts);
73636 set_fs(oldfs);
73637 return err;
73638 }
73639 @@ -766,7 +767,7 @@ long compat_sys_clock_gettime(clockid_t which_clock,
73640 oldfs = get_fs();
73641 set_fs(KERNEL_DS);
73642 err = sys_clock_gettime(which_clock,
73643 - (struct timespec __user *) &ts);
73644 + (struct timespec __force_user *) &ts);
73645 set_fs(oldfs);
73646 if (!err && put_compat_timespec(&ts, tp))
73647 return -EFAULT;
73648 @@ -786,7 +787,7 @@ long compat_sys_clock_adjtime(clockid_t which_clock,
73649
73650 oldfs = get_fs();
73651 set_fs(KERNEL_DS);
73652 - ret = sys_clock_adjtime(which_clock, (struct timex __user *) &txc);
73653 + ret = sys_clock_adjtime(which_clock, (struct timex __force_user *) &txc);
73654 set_fs(oldfs);
73655
73656 err = compat_put_timex(utp, &txc);
73657 @@ -806,7 +807,7 @@ long compat_sys_clock_getres(clockid_t which_clock,
73658 oldfs = get_fs();
73659 set_fs(KERNEL_DS);
73660 err = sys_clock_getres(which_clock,
73661 - (struct timespec __user *) &ts);
73662 + (struct timespec __force_user *) &ts);
73663 set_fs(oldfs);
73664 if (!err && tp && put_compat_timespec(&ts, tp))
73665 return -EFAULT;
73666 @@ -818,9 +819,9 @@ static long compat_clock_nanosleep_restart(struct restart_block *restart)
73667 long err;
73668 mm_segment_t oldfs;
73669 struct timespec tu;
73670 - struct compat_timespec *rmtp = restart->nanosleep.compat_rmtp;
73671 + struct compat_timespec __user *rmtp = restart->nanosleep.compat_rmtp;
73672
73673 - restart->nanosleep.rmtp = (struct timespec __user *) &tu;
73674 + restart->nanosleep.rmtp = (struct timespec __force_user *) &tu;
73675 oldfs = get_fs();
73676 set_fs(KERNEL_DS);
73677 err = clock_nanosleep_restart(restart);
73678 @@ -852,8 +853,8 @@ long compat_sys_clock_nanosleep(clockid_t which_clock, int flags,
73679 oldfs = get_fs();
73680 set_fs(KERNEL_DS);
73681 err = sys_clock_nanosleep(which_clock, flags,
73682 - (struct timespec __user *) &in,
73683 - (struct timespec __user *) &out);
73684 + (struct timespec __force_user *) &in,
73685 + (struct timespec __force_user *) &out);
73686 set_fs(oldfs);
73687
73688 if ((err == -ERESTART_RESTARTBLOCK) && rmtp &&
73689 diff --git a/kernel/configs.c b/kernel/configs.c
73690 index 42e8fa0..9e7406b 100644
73691 --- a/kernel/configs.c
73692 +++ b/kernel/configs.c
73693 @@ -74,8 +74,19 @@ static int __init ikconfig_init(void)
73694 struct proc_dir_entry *entry;
73695
73696 /* create the current config file */
73697 +#if defined(CONFIG_GRKERNSEC_PROC_ADD) || defined(CONFIG_GRKERNSEC_HIDESYM)
73698 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_HIDESYM)
73699 + entry = proc_create("config.gz", S_IFREG | S_IRUSR, NULL,
73700 + &ikconfig_file_ops);
73701 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
73702 + entry = proc_create("config.gz", S_IFREG | S_IRUSR | S_IRGRP, NULL,
73703 + &ikconfig_file_ops);
73704 +#endif
73705 +#else
73706 entry = proc_create("config.gz", S_IFREG | S_IRUGO, NULL,
73707 &ikconfig_file_ops);
73708 +#endif
73709 +
73710 if (!entry)
73711 return -ENOMEM;
73712
73713 diff --git a/kernel/cred.c b/kernel/cred.c
73714 index e0573a4..3874e41 100644
73715 --- a/kernel/cred.c
73716 +++ b/kernel/cred.c
73717 @@ -164,6 +164,16 @@ void exit_creds(struct task_struct *tsk)
73718 validate_creds(cred);
73719 alter_cred_subscribers(cred, -1);
73720 put_cred(cred);
73721 +
73722 +#ifdef CONFIG_GRKERNSEC_SETXID
73723 + cred = (struct cred *) tsk->delayed_cred;
73724 + if (cred != NULL) {
73725 + tsk->delayed_cred = NULL;
73726 + validate_creds(cred);
73727 + alter_cred_subscribers(cred, -1);
73728 + put_cred(cred);
73729 + }
73730 +#endif
73731 }
73732
73733 /**
73734 @@ -411,7 +421,7 @@ static bool cred_cap_issubset(const struct cred *set, const struct cred *subset)
73735 * Always returns 0 thus allowing this function to be tail-called at the end
73736 * of, say, sys_setgid().
73737 */
73738 -int commit_creds(struct cred *new)
73739 +static int __commit_creds(struct cred *new)
73740 {
73741 struct task_struct *task = current;
73742 const struct cred *old = task->real_cred;
73743 @@ -430,6 +440,8 @@ int commit_creds(struct cred *new)
73744
73745 get_cred(new); /* we will require a ref for the subj creds too */
73746
73747 + gr_set_role_label(task, new->uid, new->gid);
73748 +
73749 /* dumpability changes */
73750 if (!uid_eq(old->euid, new->euid) ||
73751 !gid_eq(old->egid, new->egid) ||
73752 @@ -479,6 +491,102 @@ int commit_creds(struct cred *new)
73753 put_cred(old);
73754 return 0;
73755 }
73756 +#ifdef CONFIG_GRKERNSEC_SETXID
73757 +extern int set_user(struct cred *new);
73758 +
73759 +void gr_delayed_cred_worker(void)
73760 +{
73761 + const struct cred *new = current->delayed_cred;
73762 + struct cred *ncred;
73763 +
73764 + current->delayed_cred = NULL;
73765 +
73766 + if (!uid_eq(current_uid(), GLOBAL_ROOT_UID) && new != NULL) {
73767 + // from doing get_cred on it when queueing this
73768 + put_cred(new);
73769 + return;
73770 + } else if (new == NULL)
73771 + return;
73772 +
73773 + ncred = prepare_creds();
73774 + if (!ncred)
73775 + goto die;
73776 + // uids
73777 + ncred->uid = new->uid;
73778 + ncred->euid = new->euid;
73779 + ncred->suid = new->suid;
73780 + ncred->fsuid = new->fsuid;
73781 + // gids
73782 + ncred->gid = new->gid;
73783 + ncred->egid = new->egid;
73784 + ncred->sgid = new->sgid;
73785 + ncred->fsgid = new->fsgid;
73786 + // groups
73787 + if (set_groups(ncred, new->group_info) < 0) {
73788 + abort_creds(ncred);
73789 + goto die;
73790 + }
73791 + // caps
73792 + ncred->securebits = new->securebits;
73793 + ncred->cap_inheritable = new->cap_inheritable;
73794 + ncred->cap_permitted = new->cap_permitted;
73795 + ncred->cap_effective = new->cap_effective;
73796 + ncred->cap_bset = new->cap_bset;
73797 +
73798 + if (set_user(ncred)) {
73799 + abort_creds(ncred);
73800 + goto die;
73801 + }
73802 +
73803 + // from doing get_cred on it when queueing this
73804 + put_cred(new);
73805 +
73806 + __commit_creds(ncred);
73807 + return;
73808 +die:
73809 + // from doing get_cred on it when queueing this
73810 + put_cred(new);
73811 + do_group_exit(SIGKILL);
73812 +}
73813 +#endif
73814 +
73815 +int commit_creds(struct cred *new)
73816 +{
73817 +#ifdef CONFIG_GRKERNSEC_SETXID
73818 + int ret;
73819 + int schedule_it = 0;
73820 + struct task_struct *t;
73821 +
73822 + /* we won't get called with tasklist_lock held for writing
73823 + and interrupts disabled as the cred struct in that case is
73824 + init_cred
73825 + */
73826 + if (grsec_enable_setxid && !current_is_single_threaded() &&
73827 + uid_eq(current_uid(), GLOBAL_ROOT_UID) &&
73828 + !uid_eq(new->uid, GLOBAL_ROOT_UID)) {
73829 + schedule_it = 1;
73830 + }
73831 + ret = __commit_creds(new);
73832 + if (schedule_it) {
73833 + rcu_read_lock();
73834 + read_lock(&tasklist_lock);
73835 + for (t = next_thread(current); t != current;
73836 + t = next_thread(t)) {
73837 + if (t->delayed_cred == NULL) {
73838 + t->delayed_cred = get_cred(new);
73839 + set_tsk_thread_flag(t, TIF_GRSEC_SETXID);
73840 + set_tsk_need_resched(t);
73841 + }
73842 + }
73843 + read_unlock(&tasklist_lock);
73844 + rcu_read_unlock();
73845 + }
73846 + return ret;
73847 +#else
73848 + return __commit_creds(new);
73849 +#endif
73850 +}
73851 +
73852 EXPORT_SYMBOL(commit_creds);
73853
73854 /**
73855 diff --git a/kernel/debug/debug_core.c b/kernel/debug/debug_core.c
73856 index 9a61738..c5c8f3a 100644
73857 --- a/kernel/debug/debug_core.c
73858 +++ b/kernel/debug/debug_core.c
73859 @@ -122,7 +122,7 @@ static DEFINE_RAW_SPINLOCK(dbg_slave_lock);
73860 */
73861 static atomic_t masters_in_kgdb;
73862 static atomic_t slaves_in_kgdb;
73863 -static atomic_t kgdb_break_tasklet_var;
73864 +static atomic_unchecked_t kgdb_break_tasklet_var;
73865 atomic_t kgdb_setting_breakpoint;
73866
73867 struct task_struct *kgdb_usethread;
73868 @@ -132,7 +132,7 @@ int kgdb_single_step;
73869 static pid_t kgdb_sstep_pid;
73870
73871 /* to keep track of the CPU which is doing the single stepping*/
73872 -atomic_t kgdb_cpu_doing_single_step = ATOMIC_INIT(-1);
73873 +atomic_unchecked_t kgdb_cpu_doing_single_step = ATOMIC_INIT(-1);
73874
73875 /*
73876 * If you are debugging a problem where roundup (the collection of
73877 @@ -540,7 +540,7 @@ return_normal:
73878 * kernel will only try for the value of sstep_tries before
73879 * giving up and continuing on.
73880 */
73881 - if (atomic_read(&kgdb_cpu_doing_single_step) != -1 &&
73882 + if (atomic_read_unchecked(&kgdb_cpu_doing_single_step) != -1 &&
73883 (kgdb_info[cpu].task &&
73884 kgdb_info[cpu].task->pid != kgdb_sstep_pid) && --sstep_tries) {
73885 atomic_set(&kgdb_active, -1);
73886 @@ -634,8 +634,8 @@ cpu_master_loop:
73887 }
73888
73889 kgdb_restore:
73890 - if (atomic_read(&kgdb_cpu_doing_single_step) != -1) {
73891 - int sstep_cpu = atomic_read(&kgdb_cpu_doing_single_step);
73892 + if (atomic_read_unchecked(&kgdb_cpu_doing_single_step) != -1) {
73893 + int sstep_cpu = atomic_read_unchecked(&kgdb_cpu_doing_single_step);
73894 if (kgdb_info[sstep_cpu].task)
73895 kgdb_sstep_pid = kgdb_info[sstep_cpu].task->pid;
73896 else
73897 @@ -887,18 +887,18 @@ static void kgdb_unregister_callbacks(void)
73898 static void kgdb_tasklet_bpt(unsigned long ing)
73899 {
73900 kgdb_breakpoint();
73901 - atomic_set(&kgdb_break_tasklet_var, 0);
73902 + atomic_set_unchecked(&kgdb_break_tasklet_var, 0);
73903 }
73904
73905 static DECLARE_TASKLET(kgdb_tasklet_breakpoint, kgdb_tasklet_bpt, 0);
73906
73907 void kgdb_schedule_breakpoint(void)
73908 {
73909 - if (atomic_read(&kgdb_break_tasklet_var) ||
73910 + if (atomic_read_unchecked(&kgdb_break_tasklet_var) ||
73911 atomic_read(&kgdb_active) != -1 ||
73912 atomic_read(&kgdb_setting_breakpoint))
73913 return;
73914 - atomic_inc(&kgdb_break_tasklet_var);
73915 + atomic_inc_unchecked(&kgdb_break_tasklet_var);
73916 tasklet_schedule(&kgdb_tasklet_breakpoint);
73917 }
73918 EXPORT_SYMBOL_GPL(kgdb_schedule_breakpoint);
73919 diff --git a/kernel/debug/kdb/kdb_main.c b/kernel/debug/kdb/kdb_main.c
73920 index 8875254..7cf4928 100644
73921 --- a/kernel/debug/kdb/kdb_main.c
73922 +++ b/kernel/debug/kdb/kdb_main.c
73923 @@ -1974,7 +1974,7 @@ static int kdb_lsmod(int argc, const char **argv)
73924 continue;
73925
73926 kdb_printf("%-20s%8u 0x%p ", mod->name,
73927 - mod->core_size, (void *)mod);
73928 + mod->core_size_rx + mod->core_size_rw, (void *)mod);
73929 #ifdef CONFIG_MODULE_UNLOAD
73930 kdb_printf("%4ld ", module_refcount(mod));
73931 #endif
73932 @@ -1984,7 +1984,7 @@ static int kdb_lsmod(int argc, const char **argv)
73933 kdb_printf(" (Loading)");
73934 else
73935 kdb_printf(" (Live)");
73936 - kdb_printf(" 0x%p", mod->module_core);
73937 + kdb_printf(" 0x%p 0x%p", mod->module_core_rx, mod->module_core_rw);
73938
73939 #ifdef CONFIG_MODULE_UNLOAD
73940 {
73941 diff --git a/kernel/events/core.c b/kernel/events/core.c
73942 index 7b6646a..3cb1135 100644
73943 --- a/kernel/events/core.c
73944 +++ b/kernel/events/core.c
73945 @@ -182,7 +182,7 @@ int perf_proc_update_handler(struct ctl_table *table, int write,
73946 return 0;
73947 }
73948
73949 -static atomic64_t perf_event_id;
73950 +static atomic64_unchecked_t perf_event_id;
73951
73952 static void cpu_ctx_sched_out(struct perf_cpu_context *cpuctx,
73953 enum event_type_t event_type);
73954 @@ -2677,7 +2677,7 @@ static void __perf_event_read(void *info)
73955
73956 static inline u64 perf_event_count(struct perf_event *event)
73957 {
73958 - return local64_read(&event->count) + atomic64_read(&event->child_count);
73959 + return local64_read(&event->count) + atomic64_read_unchecked(&event->child_count);
73960 }
73961
73962 static u64 perf_event_read(struct perf_event *event)
73963 @@ -3007,9 +3007,9 @@ u64 perf_event_read_value(struct perf_event *event, u64 *enabled, u64 *running)
73964 mutex_lock(&event->child_mutex);
73965 total += perf_event_read(event);
73966 *enabled += event->total_time_enabled +
73967 - atomic64_read(&event->child_total_time_enabled);
73968 + atomic64_read_unchecked(&event->child_total_time_enabled);
73969 *running += event->total_time_running +
73970 - atomic64_read(&event->child_total_time_running);
73971 + atomic64_read_unchecked(&event->child_total_time_running);
73972
73973 list_for_each_entry(child, &event->child_list, child_list) {
73974 total += perf_event_read(child);
73975 @@ -3412,10 +3412,10 @@ void perf_event_update_userpage(struct perf_event *event)
73976 userpg->offset -= local64_read(&event->hw.prev_count);
73977
73978 userpg->time_enabled = enabled +
73979 - atomic64_read(&event->child_total_time_enabled);
73980 + atomic64_read_unchecked(&event->child_total_time_enabled);
73981
73982 userpg->time_running = running +
73983 - atomic64_read(&event->child_total_time_running);
73984 + atomic64_read_unchecked(&event->child_total_time_running);
73985
73986 arch_perf_update_userpage(userpg, now);
73987
73988 @@ -3974,11 +3974,11 @@ static void perf_output_read_one(struct perf_output_handle *handle,
73989 values[n++] = perf_event_count(event);
73990 if (read_format & PERF_FORMAT_TOTAL_TIME_ENABLED) {
73991 values[n++] = enabled +
73992 - atomic64_read(&event->child_total_time_enabled);
73993 + atomic64_read_unchecked(&event->child_total_time_enabled);
73994 }
73995 if (read_format & PERF_FORMAT_TOTAL_TIME_RUNNING) {
73996 values[n++] = running +
73997 - atomic64_read(&event->child_total_time_running);
73998 + atomic64_read_unchecked(&event->child_total_time_running);
73999 }
74000 if (read_format & PERF_FORMAT_ID)
74001 values[n++] = primary_event_id(event);
74002 @@ -4721,12 +4721,12 @@ static void perf_event_mmap_event(struct perf_mmap_event *mmap_event)
74003 * need to add enough zero bytes after the string to handle
74004 * the 64bit alignment we do later.
74005 */
74006 - buf = kzalloc(PATH_MAX + sizeof(u64), GFP_KERNEL);
74007 + buf = kzalloc(PATH_MAX, GFP_KERNEL);
74008 if (!buf) {
74009 name = strncpy(tmp, "//enomem", sizeof(tmp));
74010 goto got_name;
74011 }
74012 - name = d_path(&file->f_path, buf, PATH_MAX);
74013 + name = d_path(&file->f_path, buf, PATH_MAX - sizeof(u64));
74014 if (IS_ERR(name)) {
74015 name = strncpy(tmp, "//toolong", sizeof(tmp));
74016 goto got_name;
74017 @@ -6165,7 +6165,7 @@ perf_event_alloc(struct perf_event_attr *attr, int cpu,
74018 event->parent = parent_event;
74019
74020 event->ns = get_pid_ns(task_active_pid_ns(current));
74021 - event->id = atomic64_inc_return(&perf_event_id);
74022 + event->id = atomic64_inc_return_unchecked(&perf_event_id);
74023
74024 event->state = PERF_EVENT_STATE_INACTIVE;
74025
74026 @@ -6790,10 +6790,10 @@ static void sync_child_event(struct perf_event *child_event,
74027 /*
74028 * Add back the child's count to the parent's count:
74029 */
74030 - atomic64_add(child_val, &parent_event->child_count);
74031 - atomic64_add(child_event->total_time_enabled,
74032 + atomic64_add_unchecked(child_val, &parent_event->child_count);
74033 + atomic64_add_unchecked(child_event->total_time_enabled,
74034 &parent_event->child_total_time_enabled);
74035 - atomic64_add(child_event->total_time_running,
74036 + atomic64_add_unchecked(child_event->total_time_running,
74037 &parent_event->child_total_time_running);
74038
74039 /*
74040 diff --git a/kernel/exit.c b/kernel/exit.c
74041 index b4df219..f13c02d 100644
74042 --- a/kernel/exit.c
74043 +++ b/kernel/exit.c
74044 @@ -170,6 +170,10 @@ void release_task(struct task_struct * p)
74045 struct task_struct *leader;
74046 int zap_leader;
74047 repeat:
74048 +#ifdef CONFIG_NET
74049 + gr_del_task_from_ip_table(p);
74050 +#endif
74051 +
74052 /* don't need to get the RCU readlock here - the process is dead and
74053 * can't be modifying its own credentials. But shut RCU-lockdep up */
74054 rcu_read_lock();
74055 @@ -338,7 +342,7 @@ int allow_signal(int sig)
74056 * know it'll be handled, so that they don't get converted to
74057 * SIGKILL or just silently dropped.
74058 */
74059 - current->sighand->action[(sig)-1].sa.sa_handler = (void __user *)2;
74060 + current->sighand->action[(sig)-1].sa.sa_handler = (__force void __user *)2;
74061 recalc_sigpending();
74062 spin_unlock_irq(&current->sighand->siglock);
74063 return 0;
74064 @@ -708,6 +712,8 @@ void do_exit(long code)
74065 struct task_struct *tsk = current;
74066 int group_dead;
74067
74068 + set_fs(USER_DS);
74069 +
74070 profile_task_exit(tsk);
74071
74072 WARN_ON(blk_needs_flush_plug(tsk));
74073 @@ -724,7 +730,6 @@ void do_exit(long code)
74074 * mm_release()->clear_child_tid() from writing to a user-controlled
74075 * kernel address.
74076 */
74077 - set_fs(USER_DS);
74078
74079 ptrace_event(PTRACE_EVENT_EXIT, code);
74080
74081 @@ -783,6 +788,9 @@ void do_exit(long code)
74082 tsk->exit_code = code;
74083 taskstats_exit(tsk, group_dead);
74084
74085 + gr_acl_handle_psacct(tsk, code);
74086 + gr_acl_handle_exit();
74087 +
74088 exit_mm(tsk);
74089
74090 if (group_dead)
74091 @@ -903,7 +911,7 @@ SYSCALL_DEFINE1(exit, int, error_code)
74092 * Take down every thread in the group. This is called by fatal signals
74093 * as well as by sys_exit_group (below).
74094 */
74095 -void
74096 +__noreturn void
74097 do_group_exit(int exit_code)
74098 {
74099 struct signal_struct *sig = current->signal;
74100 diff --git a/kernel/fork.c b/kernel/fork.c
74101 index 5630e52..0cee608 100644
74102 --- a/kernel/fork.c
74103 +++ b/kernel/fork.c
74104 @@ -318,7 +318,7 @@ static struct task_struct *dup_task_struct(struct task_struct *orig)
74105 *stackend = STACK_END_MAGIC; /* for overflow detection */
74106
74107 #ifdef CONFIG_CC_STACKPROTECTOR
74108 - tsk->stack_canary = get_random_int();
74109 + tsk->stack_canary = pax_get_random_long();
74110 #endif
74111
74112 /*
74113 @@ -344,13 +344,81 @@ free_tsk:
74114 }
74115
74116 #ifdef CONFIG_MMU
74117 +static struct vm_area_struct *dup_vma(struct mm_struct *mm, struct mm_struct *oldmm, struct vm_area_struct *mpnt)
74118 +{
74119 + struct vm_area_struct *tmp;
74120 + unsigned long charge;
74121 + struct mempolicy *pol;
74122 + struct file *file;
74123 +
74124 + charge = 0;
74125 + if (mpnt->vm_flags & VM_ACCOUNT) {
74126 + unsigned long len = vma_pages(mpnt);
74127 +
74128 + if (security_vm_enough_memory_mm(oldmm, len)) /* sic */
74129 + goto fail_nomem;
74130 + charge = len;
74131 + }
74132 + tmp = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
74133 + if (!tmp)
74134 + goto fail_nomem;
74135 + *tmp = *mpnt;
74136 + tmp->vm_mm = mm;
74137 + INIT_LIST_HEAD(&tmp->anon_vma_chain);
74138 + pol = mpol_dup(vma_policy(mpnt));
74139 + if (IS_ERR(pol))
74140 + goto fail_nomem_policy;
74141 + vma_set_policy(tmp, pol);
74142 + if (anon_vma_fork(tmp, mpnt))
74143 + goto fail_nomem_anon_vma_fork;
74144 + tmp->vm_flags &= ~VM_LOCKED;
74145 + tmp->vm_next = tmp->vm_prev = NULL;
74146 + tmp->vm_mirror = NULL;
74147 + file = tmp->vm_file;
74148 + if (file) {
74149 + struct inode *inode = file->f_path.dentry->d_inode;
74150 + struct address_space *mapping = file->f_mapping;
74151 +
74152 + get_file(file);
74153 + if (tmp->vm_flags & VM_DENYWRITE)
74154 + atomic_dec(&inode->i_writecount);
74155 + mutex_lock(&mapping->i_mmap_mutex);
74156 + if (tmp->vm_flags & VM_SHARED)
74157 + mapping->i_mmap_writable++;
74158 + flush_dcache_mmap_lock(mapping);
74159 + /* insert tmp into the share list, just after mpnt */
74160 + if (unlikely(tmp->vm_flags & VM_NONLINEAR))
74161 + vma_nonlinear_insert(tmp, &mapping->i_mmap_nonlinear);
74162 + else
74163 + vma_interval_tree_insert_after(tmp, mpnt, &mapping->i_mmap);
74164 + flush_dcache_mmap_unlock(mapping);
74165 + mutex_unlock(&mapping->i_mmap_mutex);
74166 + }
74167 +
74168 + /*
74169 + * Clear hugetlb-related page reserves for children. This only
74170 + * affects MAP_PRIVATE mappings. Faults generated by the child
74171 + * are not guaranteed to succeed, even if read-only
74172 + */
74173 + if (is_vm_hugetlb_page(tmp))
74174 + reset_vma_resv_huge_pages(tmp);
74175 +
74176 + return tmp;
74177 +
74178 +fail_nomem_anon_vma_fork:
74179 + mpol_put(pol);
74180 +fail_nomem_policy:
74181 + kmem_cache_free(vm_area_cachep, tmp);
74182 +fail_nomem:
74183 + vm_unacct_memory(charge);
74184 + return NULL;
74185 +}
74186 +
74187 static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
74188 {
74189 struct vm_area_struct *mpnt, *tmp, *prev, **pprev;
74190 struct rb_node **rb_link, *rb_parent;
74191 int retval;
74192 - unsigned long charge;
74193 - struct mempolicy *pol;
74194
74195 uprobe_start_dup_mmap();
74196 down_write(&oldmm->mmap_sem);
74197 @@ -364,8 +432,8 @@ static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
74198 mm->locked_vm = 0;
74199 mm->mmap = NULL;
74200 mm->mmap_cache = NULL;
74201 - mm->free_area_cache = oldmm->mmap_base;
74202 - mm->cached_hole_size = ~0UL;
74203 + mm->free_area_cache = oldmm->free_area_cache;
74204 + mm->cached_hole_size = oldmm->cached_hole_size;
74205 mm->map_count = 0;
74206 cpumask_clear(mm_cpumask(mm));
74207 mm->mm_rb = RB_ROOT;
74208 @@ -381,57 +449,15 @@ static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
74209
74210 prev = NULL;
74211 for (mpnt = oldmm->mmap; mpnt; mpnt = mpnt->vm_next) {
74212 - struct file *file;
74213 -
74214 if (mpnt->vm_flags & VM_DONTCOPY) {
74215 vm_stat_account(mm, mpnt->vm_flags, mpnt->vm_file,
74216 -vma_pages(mpnt));
74217 continue;
74218 }
74219 - charge = 0;
74220 - if (mpnt->vm_flags & VM_ACCOUNT) {
74221 - unsigned long len = vma_pages(mpnt);
74222 -
74223 - if (security_vm_enough_memory_mm(oldmm, len)) /* sic */
74224 - goto fail_nomem;
74225 - charge = len;
74226 - }
74227 - tmp = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
74228 - if (!tmp)
74229 - goto fail_nomem;
74230 - *tmp = *mpnt;
74231 - INIT_LIST_HEAD(&tmp->anon_vma_chain);
74232 - pol = mpol_dup(vma_policy(mpnt));
74233 - retval = PTR_ERR(pol);
74234 - if (IS_ERR(pol))
74235 - goto fail_nomem_policy;
74236 - vma_set_policy(tmp, pol);
74237 - tmp->vm_mm = mm;
74238 - if (anon_vma_fork(tmp, mpnt))
74239 - goto fail_nomem_anon_vma_fork;
74240 - tmp->vm_flags &= ~VM_LOCKED;
74241 - tmp->vm_next = tmp->vm_prev = NULL;
74242 - file = tmp->vm_file;
74243 - if (file) {
74244 - struct inode *inode = file->f_path.dentry->d_inode;
74245 - struct address_space *mapping = file->f_mapping;
74246 -
74247 - get_file(file);
74248 - if (tmp->vm_flags & VM_DENYWRITE)
74249 - atomic_dec(&inode->i_writecount);
74250 - mutex_lock(&mapping->i_mmap_mutex);
74251 - if (tmp->vm_flags & VM_SHARED)
74252 - mapping->i_mmap_writable++;
74253 - flush_dcache_mmap_lock(mapping);
74254 - /* insert tmp into the share list, just after mpnt */
74255 - if (unlikely(tmp->vm_flags & VM_NONLINEAR))
74256 - vma_nonlinear_insert(tmp,
74257 - &mapping->i_mmap_nonlinear);
74258 - else
74259 - vma_interval_tree_insert_after(tmp, mpnt,
74260 - &mapping->i_mmap);
74261 - flush_dcache_mmap_unlock(mapping);
74262 - mutex_unlock(&mapping->i_mmap_mutex);
74263 + tmp = dup_vma(mm, oldmm, mpnt);
74264 + if (!tmp) {
74265 + retval = -ENOMEM;
74266 + goto out;
74267 }
74268
74269 /*
74270 @@ -463,6 +489,31 @@ static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
74271 if (retval)
74272 goto out;
74273 }
74274 +
74275 +#ifdef CONFIG_PAX_SEGMEXEC
74276 + if (oldmm->pax_flags & MF_PAX_SEGMEXEC) {
74277 + struct vm_area_struct *mpnt_m;
74278 +
74279 + for (mpnt = oldmm->mmap, mpnt_m = mm->mmap; mpnt; mpnt = mpnt->vm_next, mpnt_m = mpnt_m->vm_next) {
74280 + BUG_ON(!mpnt_m || mpnt_m->vm_mirror || mpnt->vm_mm != oldmm || mpnt_m->vm_mm != mm);
74281 +
74282 + if (!mpnt->vm_mirror)
74283 + continue;
74284 +
74285 + if (mpnt->vm_end <= SEGMEXEC_TASK_SIZE) {
74286 + BUG_ON(mpnt->vm_mirror->vm_mirror != mpnt);
74287 + mpnt->vm_mirror = mpnt_m;
74288 + } else {
74289 + BUG_ON(mpnt->vm_mirror->vm_mirror == mpnt || mpnt->vm_mirror->vm_mirror->vm_mm != mm);
74290 + mpnt_m->vm_mirror = mpnt->vm_mirror->vm_mirror;
74291 + mpnt_m->vm_mirror->vm_mirror = mpnt_m;
74292 + mpnt->vm_mirror->vm_mirror = mpnt;
74293 + }
74294 + }
74295 + BUG_ON(mpnt_m);
74296 + }
74297 +#endif
74298 +
74299 /* a new mm has just been created */
74300 arch_dup_mmap(oldmm, mm);
74301 retval = 0;
74302 @@ -472,14 +523,6 @@ out:
74303 up_write(&oldmm->mmap_sem);
74304 uprobe_end_dup_mmap();
74305 return retval;
74306 -fail_nomem_anon_vma_fork:
74307 - mpol_put(pol);
74308 -fail_nomem_policy:
74309 - kmem_cache_free(vm_area_cachep, tmp);
74310 -fail_nomem:
74311 - retval = -ENOMEM;
74312 - vm_unacct_memory(charge);
74313 - goto out;
74314 }
74315
74316 static inline int mm_alloc_pgd(struct mm_struct *mm)
74317 @@ -694,8 +737,8 @@ struct mm_struct *mm_access(struct task_struct *task, unsigned int mode)
74318 return ERR_PTR(err);
74319
74320 mm = get_task_mm(task);
74321 - if (mm && mm != current->mm &&
74322 - !ptrace_may_access(task, mode)) {
74323 + if (mm && ((mm != current->mm && !ptrace_may_access(task, mode)) ||
74324 + (mode == PTRACE_MODE_ATTACH && (gr_handle_proc_ptrace(task) || gr_acl_handle_procpidmem(task))))) {
74325 mmput(mm);
74326 mm = ERR_PTR(-EACCES);
74327 }
74328 @@ -917,13 +960,20 @@ static int copy_fs(unsigned long clone_flags, struct task_struct *tsk)
74329 spin_unlock(&fs->lock);
74330 return -EAGAIN;
74331 }
74332 - fs->users++;
74333 + atomic_inc(&fs->users);
74334 spin_unlock(&fs->lock);
74335 return 0;
74336 }
74337 tsk->fs = copy_fs_struct(fs);
74338 if (!tsk->fs)
74339 return -ENOMEM;
74340 + /* Carry through gr_chroot_dentry and is_chrooted instead
74341 + of recomputing it here. Already copied when the task struct
74342 + is duplicated. This allows pivot_root to not be treated as
74343 + a chroot
74344 + */
74345 + //gr_set_chroot_entries(tsk, &tsk->fs->root);
74346 +
74347 return 0;
74348 }
74349
74350 @@ -1196,6 +1246,9 @@ static struct task_struct *copy_process(unsigned long clone_flags,
74351 DEBUG_LOCKS_WARN_ON(!p->softirqs_enabled);
74352 #endif
74353 retval = -EAGAIN;
74354 +
74355 + gr_learn_resource(p, RLIMIT_NPROC, atomic_read(&p->real_cred->user->processes), 0);
74356 +
74357 if (atomic_read(&p->real_cred->user->processes) >=
74358 task_rlimit(p, RLIMIT_NPROC)) {
74359 if (!capable(CAP_SYS_ADMIN) && !capable(CAP_SYS_RESOURCE) &&
74360 @@ -1435,6 +1488,11 @@ static struct task_struct *copy_process(unsigned long clone_flags,
74361 goto bad_fork_free_pid;
74362 }
74363
74364 + /* synchronizes with gr_set_acls()
74365 + we need to call this past the point of no return for fork()
74366 + */
74367 + gr_copy_label(p);
74368 +
74369 if (clone_flags & CLONE_THREAD) {
74370 current->signal->nr_threads++;
74371 atomic_inc(&current->signal->live);
74372 @@ -1518,6 +1576,8 @@ bad_fork_cleanup_count:
74373 bad_fork_free:
74374 free_task(p);
74375 fork_out:
74376 + gr_log_forkfail(retval);
74377 +
74378 return ERR_PTR(retval);
74379 }
74380
74381 @@ -1568,6 +1628,23 @@ long do_fork(unsigned long clone_flags,
74382 return -EINVAL;
74383 }
74384
74385 +#ifdef CONFIG_GRKERNSEC
74386 + if (clone_flags & CLONE_NEWUSER) {
74387 + /*
74388 + * This doesn't really inspire confidence:
74389 + * http://marc.info/?l=linux-kernel&m=135543612731939&w=2
74390 + * http://marc.info/?l=linux-kernel&m=135545831607095&w=2
74391 + * Increases kernel attack surface in areas developers
74392 + * previously cared little about ("low importance due
74393 + * to requiring "root" capability")
74394 + * To be removed when this code receives *proper* review
74395 + */
74396 + if (!capable(CAP_SYS_ADMIN) || !capable(CAP_SETUID) ||
74397 + !capable(CAP_SETGID))
74398 + return -EPERM;
74399 + }
74400 +#endif
74401 +
74402 /*
74403 * Determine whether and which event to report to ptracer. When
74404 * called from kernel_thread or CLONE_UNTRACED is explicitly
74405 @@ -1602,6 +1679,8 @@ long do_fork(unsigned long clone_flags,
74406 if (clone_flags & CLONE_PARENT_SETTID)
74407 put_user(nr, parent_tidptr);
74408
74409 + gr_handle_brute_check();
74410 +
74411 if (clone_flags & CLONE_VFORK) {
74412 p->vfork_done = &vfork;
74413 init_completion(&vfork);
74414 @@ -1755,7 +1834,7 @@ static int unshare_fs(unsigned long unshare_flags, struct fs_struct **new_fsp)
74415 return 0;
74416
74417 /* don't need lock here; in the worst case we'll do useless copy */
74418 - if (fs->users == 1)
74419 + if (atomic_read(&fs->users) == 1)
74420 return 0;
74421
74422 *new_fsp = copy_fs_struct(fs);
74423 @@ -1869,7 +1948,8 @@ SYSCALL_DEFINE1(unshare, unsigned long, unshare_flags)
74424 fs = current->fs;
74425 spin_lock(&fs->lock);
74426 current->fs = new_fs;
74427 - if (--fs->users)
74428 + gr_set_chroot_entries(current, &current->fs->root);
74429 + if (atomic_dec_return(&fs->users))
74430 new_fs = NULL;
74431 else
74432 new_fs = fs;
74433 diff --git a/kernel/futex.c b/kernel/futex.c
74434 index 8879430..31696f1 100644
74435 --- a/kernel/futex.c
74436 +++ b/kernel/futex.c
74437 @@ -54,6 +54,7 @@
74438 #include <linux/mount.h>
74439 #include <linux/pagemap.h>
74440 #include <linux/syscalls.h>
74441 +#include <linux/ptrace.h>
74442 #include <linux/signal.h>
74443 #include <linux/export.h>
74444 #include <linux/magic.h>
74445 @@ -239,6 +240,11 @@ get_futex_key(u32 __user *uaddr, int fshared, union futex_key *key, int rw)
74446 struct page *page, *page_head;
74447 int err, ro = 0;
74448
74449 +#ifdef CONFIG_PAX_SEGMEXEC
74450 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && address >= SEGMEXEC_TASK_SIZE)
74451 + return -EFAULT;
74452 +#endif
74453 +
74454 /*
74455 * The futex address must be "naturally" aligned.
74456 */
74457 @@ -2731,6 +2737,7 @@ static int __init futex_init(void)
74458 {
74459 u32 curval;
74460 int i;
74461 + mm_segment_t oldfs;
74462
74463 /*
74464 * This will fail and we want it. Some arch implementations do
74465 @@ -2742,8 +2749,11 @@ static int __init futex_init(void)
74466 * implementation, the non-functional ones will return
74467 * -ENOSYS.
74468 */
74469 + oldfs = get_fs();
74470 + set_fs(USER_DS);
74471 if (cmpxchg_futex_value_locked(&curval, NULL, 0, 0) == -EFAULT)
74472 futex_cmpxchg_enabled = 1;
74473 + set_fs(oldfs);
74474
74475 for (i = 0; i < ARRAY_SIZE(futex_queues); i++) {
74476 plist_head_init(&futex_queues[i].chain);
74477 diff --git a/kernel/gcov/base.c b/kernel/gcov/base.c
74478 index 9b22d03..6295b62 100644
74479 --- a/kernel/gcov/base.c
74480 +++ b/kernel/gcov/base.c
74481 @@ -102,11 +102,6 @@ void gcov_enable_events(void)
74482 }
74483
74484 #ifdef CONFIG_MODULES
74485 -static inline int within(void *addr, void *start, unsigned long size)
74486 -{
74487 - return ((addr >= start) && (addr < start + size));
74488 -}
74489 -
74490 /* Update list and generate events when modules are unloaded. */
74491 static int gcov_module_notifier(struct notifier_block *nb, unsigned long event,
74492 void *data)
74493 @@ -121,7 +116,7 @@ static int gcov_module_notifier(struct notifier_block *nb, unsigned long event,
74494 prev = NULL;
74495 /* Remove entries located in module from linked list. */
74496 for (info = gcov_info_head; info; info = info->next) {
74497 - if (within(info, mod->module_core, mod->core_size)) {
74498 + if (within_module_core_rw((unsigned long)info, mod)) {
74499 if (prev)
74500 prev->next = info->next;
74501 else
74502 diff --git a/kernel/hrtimer.c b/kernel/hrtimer.c
74503 index cdd5607..c3fc919 100644
74504 --- a/kernel/hrtimer.c
74505 +++ b/kernel/hrtimer.c
74506 @@ -1407,7 +1407,7 @@ void hrtimer_peek_ahead_timers(void)
74507 local_irq_restore(flags);
74508 }
74509
74510 -static void run_hrtimer_softirq(struct softirq_action *h)
74511 +static void run_hrtimer_softirq(void)
74512 {
74513 struct hrtimer_cpu_base *cpu_base = &__get_cpu_var(hrtimer_bases);
74514
74515 @@ -1751,7 +1751,7 @@ static int __cpuinit hrtimer_cpu_notify(struct notifier_block *self,
74516 return NOTIFY_OK;
74517 }
74518
74519 -static struct notifier_block __cpuinitdata hrtimers_nb = {
74520 +static struct notifier_block hrtimers_nb = {
74521 .notifier_call = hrtimer_cpu_notify,
74522 };
74523
74524 diff --git a/kernel/jump_label.c b/kernel/jump_label.c
74525 index 60f48fa..7f3a770 100644
74526 --- a/kernel/jump_label.c
74527 +++ b/kernel/jump_label.c
74528 @@ -13,6 +13,7 @@
74529 #include <linux/sort.h>
74530 #include <linux/err.h>
74531 #include <linux/static_key.h>
74532 +#include <linux/mm.h>
74533
74534 #ifdef HAVE_JUMP_LABEL
74535
74536 @@ -50,7 +51,9 @@ jump_label_sort_entries(struct jump_entry *start, struct jump_entry *stop)
74537
74538 size = (((unsigned long)stop - (unsigned long)start)
74539 / sizeof(struct jump_entry));
74540 + pax_open_kernel();
74541 sort(start, size, sizeof(struct jump_entry), jump_label_cmp, NULL);
74542 + pax_close_kernel();
74543 }
74544
74545 static void jump_label_update(struct static_key *key, int enable);
74546 @@ -357,10 +360,12 @@ static void jump_label_invalidate_module_init(struct module *mod)
74547 struct jump_entry *iter_stop = iter_start + mod->num_jump_entries;
74548 struct jump_entry *iter;
74549
74550 + pax_open_kernel();
74551 for (iter = iter_start; iter < iter_stop; iter++) {
74552 if (within_module_init(iter->code, mod))
74553 iter->code = 0;
74554 }
74555 + pax_close_kernel();
74556 }
74557
74558 static int
74559 diff --git a/kernel/kallsyms.c b/kernel/kallsyms.c
74560 index 2169fee..706ccca 100644
74561 --- a/kernel/kallsyms.c
74562 +++ b/kernel/kallsyms.c
74563 @@ -11,6 +11,9 @@
74564 * Changed the compression method from stem compression to "table lookup"
74565 * compression (see scripts/kallsyms.c for a more complete description)
74566 */
74567 +#ifdef CONFIG_GRKERNSEC_HIDESYM
74568 +#define __INCLUDED_BY_HIDESYM 1
74569 +#endif
74570 #include <linux/kallsyms.h>
74571 #include <linux/module.h>
74572 #include <linux/init.h>
74573 @@ -53,12 +56,33 @@ extern const unsigned long kallsyms_markers[] __attribute__((weak));
74574
74575 static inline int is_kernel_inittext(unsigned long addr)
74576 {
74577 + if (system_state != SYSTEM_BOOTING)
74578 + return 0;
74579 +
74580 if (addr >= (unsigned long)_sinittext
74581 && addr <= (unsigned long)_einittext)
74582 return 1;
74583 return 0;
74584 }
74585
74586 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
74587 +#ifdef CONFIG_MODULES
74588 +static inline int is_module_text(unsigned long addr)
74589 +{
74590 + if ((unsigned long)MODULES_EXEC_VADDR <= addr && addr <= (unsigned long)MODULES_EXEC_END)
74591 + return 1;
74592 +
74593 + addr = ktla_ktva(addr);
74594 + return (unsigned long)MODULES_EXEC_VADDR <= addr && addr <= (unsigned long)MODULES_EXEC_END;
74595 +}
74596 +#else
74597 +static inline int is_module_text(unsigned long addr)
74598 +{
74599 + return 0;
74600 +}
74601 +#endif
74602 +#endif
74603 +
74604 static inline int is_kernel_text(unsigned long addr)
74605 {
74606 if ((addr >= (unsigned long)_stext && addr <= (unsigned long)_etext) ||
74607 @@ -69,13 +93,28 @@ static inline int is_kernel_text(unsigned long addr)
74608
74609 static inline int is_kernel(unsigned long addr)
74610 {
74611 +
74612 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
74613 + if (is_kernel_text(addr) || is_kernel_inittext(addr))
74614 + return 1;
74615 +
74616 + if (ktla_ktva((unsigned long)_text) <= addr && addr < (unsigned long)_end)
74617 +#else
74618 if (addr >= (unsigned long)_stext && addr <= (unsigned long)_end)
74619 +#endif
74620 +
74621 return 1;
74622 return in_gate_area_no_mm(addr);
74623 }
74624
74625 static int is_ksym_addr(unsigned long addr)
74626 {
74627 +
74628 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
74629 + if (is_module_text(addr))
74630 + return 0;
74631 +#endif
74632 +
74633 if (all_var)
74634 return is_kernel(addr);
74635
74636 @@ -470,7 +509,6 @@ static unsigned long get_ksymbol_core(struct kallsym_iter *iter)
74637
74638 static void reset_iter(struct kallsym_iter *iter, loff_t new_pos)
74639 {
74640 - iter->name[0] = '\0';
74641 iter->nameoff = get_symbol_offset(new_pos);
74642 iter->pos = new_pos;
74643 }
74644 @@ -518,6 +556,11 @@ static int s_show(struct seq_file *m, void *p)
74645 {
74646 struct kallsym_iter *iter = m->private;
74647
74648 +#ifdef CONFIG_GRKERNSEC_HIDESYM
74649 + if (!uid_eq(current_uid(), GLOBAL_ROOT_UID))
74650 + return 0;
74651 +#endif
74652 +
74653 /* Some debugging symbols have no name. Ignore them. */
74654 if (!iter->name[0])
74655 return 0;
74656 @@ -531,6 +574,7 @@ static int s_show(struct seq_file *m, void *p)
74657 */
74658 type = iter->exported ? toupper(iter->type) :
74659 tolower(iter->type);
74660 +
74661 seq_printf(m, "%pK %c %s\t[%s]\n", (void *)iter->value,
74662 type, iter->name, iter->module_name);
74663 } else
74664 @@ -556,7 +600,7 @@ static int kallsyms_open(struct inode *inode, struct file *file)
74665 struct kallsym_iter *iter;
74666 int ret;
74667
74668 - iter = kmalloc(sizeof(*iter), GFP_KERNEL);
74669 + iter = kzalloc(sizeof(*iter), GFP_KERNEL);
74670 if (!iter)
74671 return -ENOMEM;
74672 reset_iter(iter, 0);
74673 diff --git a/kernel/kcmp.c b/kernel/kcmp.c
74674 index e30ac0f..3528cac 100644
74675 --- a/kernel/kcmp.c
74676 +++ b/kernel/kcmp.c
74677 @@ -99,6 +99,10 @@ SYSCALL_DEFINE5(kcmp, pid_t, pid1, pid_t, pid2, int, type,
74678 struct task_struct *task1, *task2;
74679 int ret;
74680
74681 +#ifdef CONFIG_GRKERNSEC
74682 + return -ENOSYS;
74683 +#endif
74684 +
74685 rcu_read_lock();
74686
74687 /*
74688 diff --git a/kernel/kexec.c b/kernel/kexec.c
74689 index 5e4bd78..00c5b91 100644
74690 --- a/kernel/kexec.c
74691 +++ b/kernel/kexec.c
74692 @@ -1045,7 +1045,8 @@ asmlinkage long compat_sys_kexec_load(unsigned long entry,
74693 unsigned long flags)
74694 {
74695 struct compat_kexec_segment in;
74696 - struct kexec_segment out, __user *ksegments;
74697 + struct kexec_segment out;
74698 + struct kexec_segment __user *ksegments;
74699 unsigned long i, result;
74700
74701 /* Don't allow clients that don't understand the native
74702 diff --git a/kernel/kmod.c b/kernel/kmod.c
74703 index 0023a87..9c0c068 100644
74704 --- a/kernel/kmod.c
74705 +++ b/kernel/kmod.c
74706 @@ -74,7 +74,7 @@ static void free_modprobe_argv(struct subprocess_info *info)
74707 kfree(info->argv);
74708 }
74709
74710 -static int call_modprobe(char *module_name, int wait)
74711 +static int call_modprobe(char *module_name, char *module_param, int wait)
74712 {
74713 static char *envp[] = {
74714 "HOME=/",
74715 @@ -83,7 +83,7 @@ static int call_modprobe(char *module_name, int wait)
74716 NULL
74717 };
74718
74719 - char **argv = kmalloc(sizeof(char *[5]), GFP_KERNEL);
74720 + char **argv = kmalloc(sizeof(char *[6]), GFP_KERNEL);
74721 if (!argv)
74722 goto out;
74723
74724 @@ -95,7 +95,8 @@ static int call_modprobe(char *module_name, int wait)
74725 argv[1] = "-q";
74726 argv[2] = "--";
74727 argv[3] = module_name; /* check free_modprobe_argv() */
74728 - argv[4] = NULL;
74729 + argv[4] = module_param;
74730 + argv[5] = NULL;
74731
74732 return call_usermodehelper_fns(modprobe_path, argv, envp,
74733 wait | UMH_KILLABLE, NULL, free_modprobe_argv, NULL);
74734 @@ -120,9 +121,8 @@ out:
74735 * If module auto-loading support is disabled then this function
74736 * becomes a no-operation.
74737 */
74738 -int __request_module(bool wait, const char *fmt, ...)
74739 +static int ____request_module(bool wait, char *module_param, const char *fmt, va_list ap)
74740 {
74741 - va_list args;
74742 char module_name[MODULE_NAME_LEN];
74743 unsigned int max_modprobes;
74744 int ret;
74745 @@ -130,9 +130,7 @@ int __request_module(bool wait, const char *fmt, ...)
74746 #define MAX_KMOD_CONCURRENT 50 /* Completely arbitrary value - KAO */
74747 static int kmod_loop_msg;
74748
74749 - va_start(args, fmt);
74750 - ret = vsnprintf(module_name, MODULE_NAME_LEN, fmt, args);
74751 - va_end(args);
74752 + ret = vsnprintf(module_name, MODULE_NAME_LEN, fmt, ap);
74753 if (ret >= MODULE_NAME_LEN)
74754 return -ENAMETOOLONG;
74755
74756 @@ -140,6 +138,20 @@ int __request_module(bool wait, const char *fmt, ...)
74757 if (ret)
74758 return ret;
74759
74760 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
74761 + if (uid_eq(current_uid(), GLOBAL_ROOT_UID)) {
74762 + /* hack to workaround consolekit/udisks stupidity */
74763 + read_lock(&tasklist_lock);
74764 + if (!strcmp(current->comm, "mount") &&
74765 + current->real_parent && !strncmp(current->real_parent->comm, "udisk", 5)) {
74766 + read_unlock(&tasklist_lock);
74767 + printk(KERN_ALERT "grsec: denied attempt to auto-load fs module %.64s by udisks\n", module_name);
74768 + return -EPERM;
74769 + }
74770 + read_unlock(&tasklist_lock);
74771 + }
74772 +#endif
74773 +
74774 /* If modprobe needs a service that is in a module, we get a recursive
74775 * loop. Limit the number of running kmod threads to max_threads/2 or
74776 * MAX_KMOD_CONCURRENT, whichever is the smaller. A cleaner method
74777 @@ -168,11 +180,52 @@ int __request_module(bool wait, const char *fmt, ...)
74778
74779 trace_module_request(module_name, wait, _RET_IP_);
74780
74781 - ret = call_modprobe(module_name, wait ? UMH_WAIT_PROC : UMH_WAIT_EXEC);
74782 + ret = call_modprobe(module_name, module_param, wait ? UMH_WAIT_PROC : UMH_WAIT_EXEC);
74783
74784 atomic_dec(&kmod_concurrent);
74785 return ret;
74786 }
74787 +
74788 +int ___request_module(bool wait, char *module_param, const char *fmt, ...)
74789 +{
74790 + va_list args;
74791 + int ret;
74792 +
74793 + va_start(args, fmt);
74794 + ret = ____request_module(wait, module_param, fmt, args);
74795 + va_end(args);
74796 +
74797 + return ret;
74798 +}
74799 +
74800 +int __request_module(bool wait, const char *fmt, ...)
74801 +{
74802 + va_list args;
74803 + int ret;
74804 +
74805 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
74806 + if (!uid_eq(current_uid(), GLOBAL_ROOT_UID)) {
74807 + char module_param[MODULE_NAME_LEN];
74808 +
74809 + memset(module_param, 0, sizeof(module_param));
74810 +
74811 + snprintf(module_param, sizeof(module_param) - 1, "grsec_modharden_normal%u_", GR_GLOBAL_UID(current_uid()));
74812 +
74813 + va_start(args, fmt);
74814 + ret = ____request_module(wait, module_param, fmt, args);
74815 + va_end(args);
74816 +
74817 + return ret;
74818 + }
74819 +#endif
74820 +
74821 + va_start(args, fmt);
74822 + ret = ____request_module(wait, NULL, fmt, args);
74823 + va_end(args);
74824 +
74825 + return ret;
74826 +}
74827 +
74828 EXPORT_SYMBOL(__request_module);
74829 #endif /* CONFIG_MODULES */
74830
74831 @@ -283,7 +336,7 @@ static int wait_for_helper(void *data)
74832 *
74833 * Thus the __user pointer cast is valid here.
74834 */
74835 - sys_wait4(pid, (int __user *)&ret, 0, NULL);
74836 + sys_wait4(pid, (int __force_user *)&ret, 0, NULL);
74837
74838 /*
74839 * If ret is 0, either ____call_usermodehelper failed and the
74840 @@ -635,7 +688,7 @@ EXPORT_SYMBOL(call_usermodehelper_fns);
74841 static int proc_cap_handler(struct ctl_table *table, int write,
74842 void __user *buffer, size_t *lenp, loff_t *ppos)
74843 {
74844 - struct ctl_table t;
74845 + ctl_table_no_const t;
74846 unsigned long cap_array[_KERNEL_CAPABILITY_U32S];
74847 kernel_cap_t new_cap;
74848 int err, i;
74849 diff --git a/kernel/kprobes.c b/kernel/kprobes.c
74850 index 098f396..fe85ff1 100644
74851 --- a/kernel/kprobes.c
74852 +++ b/kernel/kprobes.c
74853 @@ -185,7 +185,7 @@ static kprobe_opcode_t __kprobes *__get_insn_slot(struct kprobe_insn_cache *c)
74854 * kernel image and loaded module images reside. This is required
74855 * so x86_64 can correctly handle the %rip-relative fixups.
74856 */
74857 - kip->insns = module_alloc(PAGE_SIZE);
74858 + kip->insns = module_alloc_exec(PAGE_SIZE);
74859 if (!kip->insns) {
74860 kfree(kip);
74861 return NULL;
74862 @@ -225,7 +225,7 @@ static int __kprobes collect_one_slot(struct kprobe_insn_page *kip, int idx)
74863 */
74864 if (!list_is_singular(&kip->list)) {
74865 list_del(&kip->list);
74866 - module_free(NULL, kip->insns);
74867 + module_free_exec(NULL, kip->insns);
74868 kfree(kip);
74869 }
74870 return 1;
74871 @@ -2063,7 +2063,7 @@ static int __init init_kprobes(void)
74872 {
74873 int i, err = 0;
74874 unsigned long offset = 0, size = 0;
74875 - char *modname, namebuf[128];
74876 + char *modname, namebuf[KSYM_NAME_LEN];
74877 const char *symbol_name;
74878 void *addr;
74879 struct kprobe_blackpoint *kb;
74880 @@ -2148,11 +2148,11 @@ static void __kprobes report_probe(struct seq_file *pi, struct kprobe *p,
74881 kprobe_type = "k";
74882
74883 if (sym)
74884 - seq_printf(pi, "%p %s %s+0x%x %s ",
74885 + seq_printf(pi, "%pK %s %s+0x%x %s ",
74886 p->addr, kprobe_type, sym, offset,
74887 (modname ? modname : " "));
74888 else
74889 - seq_printf(pi, "%p %s %p ",
74890 + seq_printf(pi, "%pK %s %pK ",
74891 p->addr, kprobe_type, p->addr);
74892
74893 if (!pp)
74894 @@ -2190,7 +2190,7 @@ static int __kprobes show_kprobe_addr(struct seq_file *pi, void *v)
74895 const char *sym = NULL;
74896 unsigned int i = *(loff_t *) v;
74897 unsigned long offset = 0;
74898 - char *modname, namebuf[128];
74899 + char *modname, namebuf[KSYM_NAME_LEN];
74900
74901 head = &kprobe_table[i];
74902 preempt_disable();
74903 diff --git a/kernel/ksysfs.c b/kernel/ksysfs.c
74904 index 6ada93c..dce7d5d 100644
74905 --- a/kernel/ksysfs.c
74906 +++ b/kernel/ksysfs.c
74907 @@ -46,6 +46,8 @@ static ssize_t uevent_helper_store(struct kobject *kobj,
74908 {
74909 if (count+1 > UEVENT_HELPER_PATH_LEN)
74910 return -ENOENT;
74911 + if (!capable(CAP_SYS_ADMIN))
74912 + return -EPERM;
74913 memcpy(uevent_helper, buf, count);
74914 uevent_helper[count] = '\0';
74915 if (count && uevent_helper[count-1] == '\n')
74916 @@ -172,7 +174,7 @@ static ssize_t notes_read(struct file *filp, struct kobject *kobj,
74917 return count;
74918 }
74919
74920 -static struct bin_attribute notes_attr = {
74921 +static bin_attribute_no_const notes_attr __read_only = {
74922 .attr = {
74923 .name = "notes",
74924 .mode = S_IRUGO,
74925 diff --git a/kernel/lockdep.c b/kernel/lockdep.c
74926 index 7981e5b..7f2105c 100644
74927 --- a/kernel/lockdep.c
74928 +++ b/kernel/lockdep.c
74929 @@ -590,6 +590,10 @@ static int static_obj(void *obj)
74930 end = (unsigned long) &_end,
74931 addr = (unsigned long) obj;
74932
74933 +#ifdef CONFIG_PAX_KERNEXEC
74934 + start = ktla_ktva(start);
74935 +#endif
74936 +
74937 /*
74938 * static variable?
74939 */
74940 @@ -730,6 +734,7 @@ register_lock_class(struct lockdep_map *lock, unsigned int subclass, int force)
74941 if (!static_obj(lock->key)) {
74942 debug_locks_off();
74943 printk("INFO: trying to register non-static key.\n");
74944 + printk("lock:%pS key:%pS.\n", lock, lock->key);
74945 printk("the code is fine but needs lockdep annotation.\n");
74946 printk("turning off the locking correctness validator.\n");
74947 dump_stack();
74948 @@ -3078,7 +3083,7 @@ static int __lock_acquire(struct lockdep_map *lock, unsigned int subclass,
74949 if (!class)
74950 return 0;
74951 }
74952 - atomic_inc((atomic_t *)&class->ops);
74953 + atomic_inc_unchecked((atomic_unchecked_t *)&class->ops);
74954 if (very_verbose(class)) {
74955 printk("\nacquire class [%p] %s", class->key, class->name);
74956 if (class->name_version > 1)
74957 diff --git a/kernel/lockdep_proc.c b/kernel/lockdep_proc.c
74958 index b2c71c5..7b88d63 100644
74959 --- a/kernel/lockdep_proc.c
74960 +++ b/kernel/lockdep_proc.c
74961 @@ -65,7 +65,7 @@ static int l_show(struct seq_file *m, void *v)
74962 return 0;
74963 }
74964
74965 - seq_printf(m, "%p", class->key);
74966 + seq_printf(m, "%pK", class->key);
74967 #ifdef CONFIG_DEBUG_LOCKDEP
74968 seq_printf(m, " OPS:%8ld", class->ops);
74969 #endif
74970 @@ -83,7 +83,7 @@ static int l_show(struct seq_file *m, void *v)
74971
74972 list_for_each_entry(entry, &class->locks_after, entry) {
74973 if (entry->distance == 1) {
74974 - seq_printf(m, " -> [%p] ", entry->class->key);
74975 + seq_printf(m, " -> [%pK] ", entry->class->key);
74976 print_name(m, entry->class);
74977 seq_puts(m, "\n");
74978 }
74979 @@ -152,7 +152,7 @@ static int lc_show(struct seq_file *m, void *v)
74980 if (!class->key)
74981 continue;
74982
74983 - seq_printf(m, "[%p] ", class->key);
74984 + seq_printf(m, "[%pK] ", class->key);
74985 print_name(m, class);
74986 seq_puts(m, "\n");
74987 }
74988 @@ -495,7 +495,7 @@ static void seq_stats(struct seq_file *m, struct lock_stat_data *data)
74989 if (!i)
74990 seq_line(m, '-', 40-namelen, namelen);
74991
74992 - snprintf(ip, sizeof(ip), "[<%p>]",
74993 + snprintf(ip, sizeof(ip), "[<%pK>]",
74994 (void *)class->contention_point[i]);
74995 seq_printf(m, "%40s %14lu %29s %pS\n",
74996 name, stats->contention_point[i],
74997 @@ -510,7 +510,7 @@ static void seq_stats(struct seq_file *m, struct lock_stat_data *data)
74998 if (!i)
74999 seq_line(m, '-', 40-namelen, namelen);
75000
75001 - snprintf(ip, sizeof(ip), "[<%p>]",
75002 + snprintf(ip, sizeof(ip), "[<%pK>]",
75003 (void *)class->contending_point[i]);
75004 seq_printf(m, "%40s %14lu %29s %pS\n",
75005 name, stats->contending_point[i],
75006 diff --git a/kernel/module.c b/kernel/module.c
75007 index eab0827..f488603 100644
75008 --- a/kernel/module.c
75009 +++ b/kernel/module.c
75010 @@ -61,6 +61,7 @@
75011 #include <linux/pfn.h>
75012 #include <linux/bsearch.h>
75013 #include <linux/fips.h>
75014 +#include <linux/grsecurity.h>
75015 #include <uapi/linux/module.h>
75016 #include "module-internal.h"
75017
75018 @@ -156,7 +157,8 @@ static BLOCKING_NOTIFIER_HEAD(module_notify_list);
75019
75020 /* Bounds of module allocation, for speeding __module_address.
75021 * Protected by module_mutex. */
75022 -static unsigned long module_addr_min = -1UL, module_addr_max = 0;
75023 +static unsigned long module_addr_min_rw = -1UL, module_addr_max_rw = 0;
75024 +static unsigned long module_addr_min_rx = -1UL, module_addr_max_rx = 0;
75025
75026 int register_module_notifier(struct notifier_block * nb)
75027 {
75028 @@ -322,7 +324,7 @@ bool each_symbol_section(bool (*fn)(const struct symsearch *arr,
75029 return true;
75030
75031 list_for_each_entry_rcu(mod, &modules, list) {
75032 - struct symsearch arr[] = {
75033 + struct symsearch modarr[] = {
75034 { mod->syms, mod->syms + mod->num_syms, mod->crcs,
75035 NOT_GPL_ONLY, false },
75036 { mod->gpl_syms, mod->gpl_syms + mod->num_gpl_syms,
75037 @@ -347,7 +349,7 @@ bool each_symbol_section(bool (*fn)(const struct symsearch *arr,
75038 if (mod->state == MODULE_STATE_UNFORMED)
75039 continue;
75040
75041 - if (each_symbol_in_section(arr, ARRAY_SIZE(arr), mod, fn, data))
75042 + if (each_symbol_in_section(modarr, ARRAY_SIZE(modarr), mod, fn, data))
75043 return true;
75044 }
75045 return false;
75046 @@ -484,7 +486,7 @@ static inline void __percpu *mod_percpu(struct module *mod)
75047 static int percpu_modalloc(struct module *mod,
75048 unsigned long size, unsigned long align)
75049 {
75050 - if (align > PAGE_SIZE) {
75051 + if (align-1 >= PAGE_SIZE) {
75052 printk(KERN_WARNING "%s: per-cpu alignment %li > %li\n",
75053 mod->name, align, PAGE_SIZE);
75054 align = PAGE_SIZE;
75055 @@ -1088,7 +1090,7 @@ struct module_attribute module_uevent =
75056 static ssize_t show_coresize(struct module_attribute *mattr,
75057 struct module_kobject *mk, char *buffer)
75058 {
75059 - return sprintf(buffer, "%u\n", mk->mod->core_size);
75060 + return sprintf(buffer, "%u\n", mk->mod->core_size_rx + mk->mod->core_size_rw);
75061 }
75062
75063 static struct module_attribute modinfo_coresize =
75064 @@ -1097,7 +1099,7 @@ static struct module_attribute modinfo_coresize =
75065 static ssize_t show_initsize(struct module_attribute *mattr,
75066 struct module_kobject *mk, char *buffer)
75067 {
75068 - return sprintf(buffer, "%u\n", mk->mod->init_size);
75069 + return sprintf(buffer, "%u\n", mk->mod->init_size_rx + mk->mod->init_size_rw);
75070 }
75071
75072 static struct module_attribute modinfo_initsize =
75073 @@ -1311,7 +1313,7 @@ resolve_symbol_wait(struct module *mod,
75074 */
75075 #ifdef CONFIG_SYSFS
75076
75077 -#ifdef CONFIG_KALLSYMS
75078 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
75079 static inline bool sect_empty(const Elf_Shdr *sect)
75080 {
75081 return !(sect->sh_flags & SHF_ALLOC) || sect->sh_size == 0;
75082 @@ -1451,7 +1453,7 @@ static void add_notes_attrs(struct module *mod, const struct load_info *info)
75083 {
75084 unsigned int notes, loaded, i;
75085 struct module_notes_attrs *notes_attrs;
75086 - struct bin_attribute *nattr;
75087 + bin_attribute_no_const *nattr;
75088
75089 /* failed to create section attributes, so can't create notes */
75090 if (!mod->sect_attrs)
75091 @@ -1563,7 +1565,7 @@ static void del_usage_links(struct module *mod)
75092 static int module_add_modinfo_attrs(struct module *mod)
75093 {
75094 struct module_attribute *attr;
75095 - struct module_attribute *temp_attr;
75096 + module_attribute_no_const *temp_attr;
75097 int error = 0;
75098 int i;
75099
75100 @@ -1777,21 +1779,21 @@ static void set_section_ro_nx(void *base,
75101
75102 static void unset_module_core_ro_nx(struct module *mod)
75103 {
75104 - set_page_attributes(mod->module_core + mod->core_text_size,
75105 - mod->module_core + mod->core_size,
75106 + set_page_attributes(mod->module_core_rw,
75107 + mod->module_core_rw + mod->core_size_rw,
75108 set_memory_x);
75109 - set_page_attributes(mod->module_core,
75110 - mod->module_core + mod->core_ro_size,
75111 + set_page_attributes(mod->module_core_rx,
75112 + mod->module_core_rx + mod->core_size_rx,
75113 set_memory_rw);
75114 }
75115
75116 static void unset_module_init_ro_nx(struct module *mod)
75117 {
75118 - set_page_attributes(mod->module_init + mod->init_text_size,
75119 - mod->module_init + mod->init_size,
75120 + set_page_attributes(mod->module_init_rw,
75121 + mod->module_init_rw + mod->init_size_rw,
75122 set_memory_x);
75123 - set_page_attributes(mod->module_init,
75124 - mod->module_init + mod->init_ro_size,
75125 + set_page_attributes(mod->module_init_rx,
75126 + mod->module_init_rx + mod->init_size_rx,
75127 set_memory_rw);
75128 }
75129
75130 @@ -1804,14 +1806,14 @@ void set_all_modules_text_rw(void)
75131 list_for_each_entry_rcu(mod, &modules, list) {
75132 if (mod->state == MODULE_STATE_UNFORMED)
75133 continue;
75134 - if ((mod->module_core) && (mod->core_text_size)) {
75135 - set_page_attributes(mod->module_core,
75136 - mod->module_core + mod->core_text_size,
75137 + if ((mod->module_core_rx) && (mod->core_size_rx)) {
75138 + set_page_attributes(mod->module_core_rx,
75139 + mod->module_core_rx + mod->core_size_rx,
75140 set_memory_rw);
75141 }
75142 - if ((mod->module_init) && (mod->init_text_size)) {
75143 - set_page_attributes(mod->module_init,
75144 - mod->module_init + mod->init_text_size,
75145 + if ((mod->module_init_rx) && (mod->init_size_rx)) {
75146 + set_page_attributes(mod->module_init_rx,
75147 + mod->module_init_rx + mod->init_size_rx,
75148 set_memory_rw);
75149 }
75150 }
75151 @@ -1827,14 +1829,14 @@ void set_all_modules_text_ro(void)
75152 list_for_each_entry_rcu(mod, &modules, list) {
75153 if (mod->state == MODULE_STATE_UNFORMED)
75154 continue;
75155 - if ((mod->module_core) && (mod->core_text_size)) {
75156 - set_page_attributes(mod->module_core,
75157 - mod->module_core + mod->core_text_size,
75158 + if ((mod->module_core_rx) && (mod->core_size_rx)) {
75159 + set_page_attributes(mod->module_core_rx,
75160 + mod->module_core_rx + mod->core_size_rx,
75161 set_memory_ro);
75162 }
75163 - if ((mod->module_init) && (mod->init_text_size)) {
75164 - set_page_attributes(mod->module_init,
75165 - mod->module_init + mod->init_text_size,
75166 + if ((mod->module_init_rx) && (mod->init_size_rx)) {
75167 + set_page_attributes(mod->module_init_rx,
75168 + mod->module_init_rx + mod->init_size_rx,
75169 set_memory_ro);
75170 }
75171 }
75172 @@ -1880,16 +1882,19 @@ static void free_module(struct module *mod)
75173
75174 /* This may be NULL, but that's OK */
75175 unset_module_init_ro_nx(mod);
75176 - module_free(mod, mod->module_init);
75177 + module_free(mod, mod->module_init_rw);
75178 + module_free_exec(mod, mod->module_init_rx);
75179 kfree(mod->args);
75180 percpu_modfree(mod);
75181
75182 /* Free lock-classes: */
75183 - lockdep_free_key_range(mod->module_core, mod->core_size);
75184 + lockdep_free_key_range(mod->module_core_rx, mod->core_size_rx);
75185 + lockdep_free_key_range(mod->module_core_rw, mod->core_size_rw);
75186
75187 /* Finally, free the core (containing the module structure) */
75188 unset_module_core_ro_nx(mod);
75189 - module_free(mod, mod->module_core);
75190 + module_free_exec(mod, mod->module_core_rx);
75191 + module_free(mod, mod->module_core_rw);
75192
75193 #ifdef CONFIG_MPU
75194 update_protections(current->mm);
75195 @@ -1959,9 +1964,31 @@ static int simplify_symbols(struct module *mod, const struct load_info *info)
75196 int ret = 0;
75197 const struct kernel_symbol *ksym;
75198
75199 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
75200 + int is_fs_load = 0;
75201 + int register_filesystem_found = 0;
75202 + char *p;
75203 +
75204 + p = strstr(mod->args, "grsec_modharden_fs");
75205 + if (p) {
75206 + char *endptr = p + sizeof("grsec_modharden_fs") - 1;
75207 + /* copy \0 as well */
75208 + memmove(p, endptr, strlen(mod->args) - (unsigned int)(endptr - mod->args) + 1);
75209 + is_fs_load = 1;
75210 + }
75211 +#endif
75212 +
75213 for (i = 1; i < symsec->sh_size / sizeof(Elf_Sym); i++) {
75214 const char *name = info->strtab + sym[i].st_name;
75215
75216 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
75217 + /* it's a real shame this will never get ripped and copied
75218 + upstream! ;(
75219 + */
75220 + if (is_fs_load && !strcmp(name, "register_filesystem"))
75221 + register_filesystem_found = 1;
75222 +#endif
75223 +
75224 switch (sym[i].st_shndx) {
75225 case SHN_COMMON:
75226 /* We compiled with -fno-common. These are not
75227 @@ -1982,7 +2009,9 @@ static int simplify_symbols(struct module *mod, const struct load_info *info)
75228 ksym = resolve_symbol_wait(mod, info, name);
75229 /* Ok if resolved. */
75230 if (ksym && !IS_ERR(ksym)) {
75231 + pax_open_kernel();
75232 sym[i].st_value = ksym->value;
75233 + pax_close_kernel();
75234 break;
75235 }
75236
75237 @@ -2001,11 +2030,20 @@ static int simplify_symbols(struct module *mod, const struct load_info *info)
75238 secbase = (unsigned long)mod_percpu(mod);
75239 else
75240 secbase = info->sechdrs[sym[i].st_shndx].sh_addr;
75241 + pax_open_kernel();
75242 sym[i].st_value += secbase;
75243 + pax_close_kernel();
75244 break;
75245 }
75246 }
75247
75248 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
75249 + if (is_fs_load && !register_filesystem_found) {
75250 + printk(KERN_ALERT "grsec: Denied attempt to load non-fs module %.64s through mount\n", mod->name);
75251 + ret = -EPERM;
75252 + }
75253 +#endif
75254 +
75255 return ret;
75256 }
75257
75258 @@ -2089,22 +2127,12 @@ static void layout_sections(struct module *mod, struct load_info *info)
75259 || s->sh_entsize != ~0UL
75260 || strstarts(sname, ".init"))
75261 continue;
75262 - s->sh_entsize = get_offset(mod, &mod->core_size, s, i);
75263 + if ((s->sh_flags & SHF_WRITE) || !(s->sh_flags & SHF_ALLOC))
75264 + s->sh_entsize = get_offset(mod, &mod->core_size_rw, s, i);
75265 + else
75266 + s->sh_entsize = get_offset(mod, &mod->core_size_rx, s, i);
75267 pr_debug("\t%s\n", sname);
75268 }
75269 - switch (m) {
75270 - case 0: /* executable */
75271 - mod->core_size = debug_align(mod->core_size);
75272 - mod->core_text_size = mod->core_size;
75273 - break;
75274 - case 1: /* RO: text and ro-data */
75275 - mod->core_size = debug_align(mod->core_size);
75276 - mod->core_ro_size = mod->core_size;
75277 - break;
75278 - case 3: /* whole core */
75279 - mod->core_size = debug_align(mod->core_size);
75280 - break;
75281 - }
75282 }
75283
75284 pr_debug("Init section allocation order:\n");
75285 @@ -2118,23 +2146,13 @@ static void layout_sections(struct module *mod, struct load_info *info)
75286 || s->sh_entsize != ~0UL
75287 || !strstarts(sname, ".init"))
75288 continue;
75289 - s->sh_entsize = (get_offset(mod, &mod->init_size, s, i)
75290 - | INIT_OFFSET_MASK);
75291 + if ((s->sh_flags & SHF_WRITE) || !(s->sh_flags & SHF_ALLOC))
75292 + s->sh_entsize = get_offset(mod, &mod->init_size_rw, s, i);
75293 + else
75294 + s->sh_entsize = get_offset(mod, &mod->init_size_rx, s, i);
75295 + s->sh_entsize |= INIT_OFFSET_MASK;
75296 pr_debug("\t%s\n", sname);
75297 }
75298 - switch (m) {
75299 - case 0: /* executable */
75300 - mod->init_size = debug_align(mod->init_size);
75301 - mod->init_text_size = mod->init_size;
75302 - break;
75303 - case 1: /* RO: text and ro-data */
75304 - mod->init_size = debug_align(mod->init_size);
75305 - mod->init_ro_size = mod->init_size;
75306 - break;
75307 - case 3: /* whole init */
75308 - mod->init_size = debug_align(mod->init_size);
75309 - break;
75310 - }
75311 }
75312 }
75313
75314 @@ -2306,7 +2324,7 @@ static void layout_symtab(struct module *mod, struct load_info *info)
75315
75316 /* Put symbol section at end of init part of module. */
75317 symsect->sh_flags |= SHF_ALLOC;
75318 - symsect->sh_entsize = get_offset(mod, &mod->init_size, symsect,
75319 + symsect->sh_entsize = get_offset(mod, &mod->init_size_rx, symsect,
75320 info->index.sym) | INIT_OFFSET_MASK;
75321 pr_debug("\t%s\n", info->secstrings + symsect->sh_name);
75322
75323 @@ -2323,13 +2341,13 @@ static void layout_symtab(struct module *mod, struct load_info *info)
75324 }
75325
75326 /* Append room for core symbols at end of core part. */
75327 - info->symoffs = ALIGN(mod->core_size, symsect->sh_addralign ?: 1);
75328 - info->stroffs = mod->core_size = info->symoffs + ndst * sizeof(Elf_Sym);
75329 - mod->core_size += strtab_size;
75330 + info->symoffs = ALIGN(mod->core_size_rx, symsect->sh_addralign ?: 1);
75331 + info->stroffs = mod->core_size_rx = info->symoffs + ndst * sizeof(Elf_Sym);
75332 + mod->core_size_rx += strtab_size;
75333
75334 /* Put string table section at end of init part of module. */
75335 strsect->sh_flags |= SHF_ALLOC;
75336 - strsect->sh_entsize = get_offset(mod, &mod->init_size, strsect,
75337 + strsect->sh_entsize = get_offset(mod, &mod->init_size_rx, strsect,
75338 info->index.str) | INIT_OFFSET_MASK;
75339 pr_debug("\t%s\n", info->secstrings + strsect->sh_name);
75340 }
75341 @@ -2347,12 +2365,14 @@ static void add_kallsyms(struct module *mod, const struct load_info *info)
75342 /* Make sure we get permanent strtab: don't use info->strtab. */
75343 mod->strtab = (void *)info->sechdrs[info->index.str].sh_addr;
75344
75345 + pax_open_kernel();
75346 +
75347 /* Set types up while we still have access to sections. */
75348 for (i = 0; i < mod->num_symtab; i++)
75349 mod->symtab[i].st_info = elf_type(&mod->symtab[i], info);
75350
75351 - mod->core_symtab = dst = mod->module_core + info->symoffs;
75352 - mod->core_strtab = s = mod->module_core + info->stroffs;
75353 + mod->core_symtab = dst = mod->module_core_rx + info->symoffs;
75354 + mod->core_strtab = s = mod->module_core_rx + info->stroffs;
75355 src = mod->symtab;
75356 for (ndst = i = 0; i < mod->num_symtab; i++) {
75357 if (i == 0 ||
75358 @@ -2364,6 +2384,8 @@ static void add_kallsyms(struct module *mod, const struct load_info *info)
75359 }
75360 }
75361 mod->core_num_syms = ndst;
75362 +
75363 + pax_close_kernel();
75364 }
75365 #else
75366 static inline void layout_symtab(struct module *mod, struct load_info *info)
75367 @@ -2397,17 +2419,33 @@ void * __weak module_alloc(unsigned long size)
75368 return vmalloc_exec(size);
75369 }
75370
75371 -static void *module_alloc_update_bounds(unsigned long size)
75372 +static void *module_alloc_update_bounds_rw(unsigned long size)
75373 {
75374 void *ret = module_alloc(size);
75375
75376 if (ret) {
75377 mutex_lock(&module_mutex);
75378 /* Update module bounds. */
75379 - if ((unsigned long)ret < module_addr_min)
75380 - module_addr_min = (unsigned long)ret;
75381 - if ((unsigned long)ret + size > module_addr_max)
75382 - module_addr_max = (unsigned long)ret + size;
75383 + if ((unsigned long)ret < module_addr_min_rw)
75384 + module_addr_min_rw = (unsigned long)ret;
75385 + if ((unsigned long)ret + size > module_addr_max_rw)
75386 + module_addr_max_rw = (unsigned long)ret + size;
75387 + mutex_unlock(&module_mutex);
75388 + }
75389 + return ret;
75390 +}
75391 +
75392 +static void *module_alloc_update_bounds_rx(unsigned long size)
75393 +{
75394 + void *ret = module_alloc_exec(size);
75395 +
75396 + if (ret) {
75397 + mutex_lock(&module_mutex);
75398 + /* Update module bounds. */
75399 + if ((unsigned long)ret < module_addr_min_rx)
75400 + module_addr_min_rx = (unsigned long)ret;
75401 + if ((unsigned long)ret + size > module_addr_max_rx)
75402 + module_addr_max_rx = (unsigned long)ret + size;
75403 mutex_unlock(&module_mutex);
75404 }
75405 return ret;
75406 @@ -2683,8 +2721,14 @@ static struct module *setup_load_info(struct load_info *info, int flags)
75407 static int check_modinfo(struct module *mod, struct load_info *info, int flags)
75408 {
75409 const char *modmagic = get_modinfo(info, "vermagic");
75410 + const char *license = get_modinfo(info, "license");
75411 int err;
75412
75413 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR
75414 + if (!license || !license_is_gpl_compatible(license))
75415 + return -ENOEXEC;
75416 +#endif
75417 +
75418 if (flags & MODULE_INIT_IGNORE_VERMAGIC)
75419 modmagic = NULL;
75420
75421 @@ -2710,7 +2754,7 @@ static int check_modinfo(struct module *mod, struct load_info *info, int flags)
75422 }
75423
75424 /* Set up license info based on the info section */
75425 - set_license(mod, get_modinfo(info, "license"));
75426 + set_license(mod, license);
75427
75428 return 0;
75429 }
75430 @@ -2804,7 +2848,7 @@ static int move_module(struct module *mod, struct load_info *info)
75431 void *ptr;
75432
75433 /* Do the allocs. */
75434 - ptr = module_alloc_update_bounds(mod->core_size);
75435 + ptr = module_alloc_update_bounds_rw(mod->core_size_rw);
75436 /*
75437 * The pointer to this block is stored in the module structure
75438 * which is inside the block. Just mark it as not being a
75439 @@ -2814,11 +2858,11 @@ static int move_module(struct module *mod, struct load_info *info)
75440 if (!ptr)
75441 return -ENOMEM;
75442
75443 - memset(ptr, 0, mod->core_size);
75444 - mod->module_core = ptr;
75445 + memset(ptr, 0, mod->core_size_rw);
75446 + mod->module_core_rw = ptr;
75447
75448 - if (mod->init_size) {
75449 - ptr = module_alloc_update_bounds(mod->init_size);
75450 + if (mod->init_size_rw) {
75451 + ptr = module_alloc_update_bounds_rw(mod->init_size_rw);
75452 /*
75453 * The pointer to this block is stored in the module structure
75454 * which is inside the block. This block doesn't need to be
75455 @@ -2827,13 +2871,45 @@ static int move_module(struct module *mod, struct load_info *info)
75456 */
75457 kmemleak_ignore(ptr);
75458 if (!ptr) {
75459 - module_free(mod, mod->module_core);
75460 + module_free(mod, mod->module_core_rw);
75461 return -ENOMEM;
75462 }
75463 - memset(ptr, 0, mod->init_size);
75464 - mod->module_init = ptr;
75465 + memset(ptr, 0, mod->init_size_rw);
75466 + mod->module_init_rw = ptr;
75467 } else
75468 - mod->module_init = NULL;
75469 + mod->module_init_rw = NULL;
75470 +
75471 + ptr = module_alloc_update_bounds_rx(mod->core_size_rx);
75472 + kmemleak_not_leak(ptr);
75473 + if (!ptr) {
75474 + if (mod->module_init_rw)
75475 + module_free(mod, mod->module_init_rw);
75476 + module_free(mod, mod->module_core_rw);
75477 + return -ENOMEM;
75478 + }
75479 +
75480 + pax_open_kernel();
75481 + memset(ptr, 0, mod->core_size_rx);
75482 + pax_close_kernel();
75483 + mod->module_core_rx = ptr;
75484 +
75485 + if (mod->init_size_rx) {
75486 + ptr = module_alloc_update_bounds_rx(mod->init_size_rx);
75487 + kmemleak_ignore(ptr);
75488 + if (!ptr && mod->init_size_rx) {
75489 + module_free_exec(mod, mod->module_core_rx);
75490 + if (mod->module_init_rw)
75491 + module_free(mod, mod->module_init_rw);
75492 + module_free(mod, mod->module_core_rw);
75493 + return -ENOMEM;
75494 + }
75495 +
75496 + pax_open_kernel();
75497 + memset(ptr, 0, mod->init_size_rx);
75498 + pax_close_kernel();
75499 + mod->module_init_rx = ptr;
75500 + } else
75501 + mod->module_init_rx = NULL;
75502
75503 /* Transfer each section which specifies SHF_ALLOC */
75504 pr_debug("final section addresses:\n");
75505 @@ -2844,16 +2920,45 @@ static int move_module(struct module *mod, struct load_info *info)
75506 if (!(shdr->sh_flags & SHF_ALLOC))
75507 continue;
75508
75509 - if (shdr->sh_entsize & INIT_OFFSET_MASK)
75510 - dest = mod->module_init
75511 - + (shdr->sh_entsize & ~INIT_OFFSET_MASK);
75512 - else
75513 - dest = mod->module_core + shdr->sh_entsize;
75514 + if (shdr->sh_entsize & INIT_OFFSET_MASK) {
75515 + if ((shdr->sh_flags & SHF_WRITE) || !(shdr->sh_flags & SHF_ALLOC))
75516 + dest = mod->module_init_rw
75517 + + (shdr->sh_entsize & ~INIT_OFFSET_MASK);
75518 + else
75519 + dest = mod->module_init_rx
75520 + + (shdr->sh_entsize & ~INIT_OFFSET_MASK);
75521 + } else {
75522 + if ((shdr->sh_flags & SHF_WRITE) || !(shdr->sh_flags & SHF_ALLOC))
75523 + dest = mod->module_core_rw + shdr->sh_entsize;
75524 + else
75525 + dest = mod->module_core_rx + shdr->sh_entsize;
75526 + }
75527 +
75528 + if (shdr->sh_type != SHT_NOBITS) {
75529 +
75530 +#ifdef CONFIG_PAX_KERNEXEC
75531 +#ifdef CONFIG_X86_64
75532 + if ((shdr->sh_flags & SHF_WRITE) && (shdr->sh_flags & SHF_EXECINSTR))
75533 + set_memory_x((unsigned long)dest, (shdr->sh_size + PAGE_SIZE) >> PAGE_SHIFT);
75534 +#endif
75535 + if (!(shdr->sh_flags & SHF_WRITE) && (shdr->sh_flags & SHF_ALLOC)) {
75536 + pax_open_kernel();
75537 + memcpy(dest, (void *)shdr->sh_addr, shdr->sh_size);
75538 + pax_close_kernel();
75539 + } else
75540 +#endif
75541
75542 - if (shdr->sh_type != SHT_NOBITS)
75543 memcpy(dest, (void *)shdr->sh_addr, shdr->sh_size);
75544 + }
75545 /* Update sh_addr to point to copy in image. */
75546 - shdr->sh_addr = (unsigned long)dest;
75547 +
75548 +#ifdef CONFIG_PAX_KERNEXEC
75549 + if (shdr->sh_flags & SHF_EXECINSTR)
75550 + shdr->sh_addr = ktva_ktla((unsigned long)dest);
75551 + else
75552 +#endif
75553 +
75554 + shdr->sh_addr = (unsigned long)dest;
75555 pr_debug("\t0x%lx %s\n",
75556 (long)shdr->sh_addr, info->secstrings + shdr->sh_name);
75557 }
75558 @@ -2908,12 +3013,12 @@ static void flush_module_icache(const struct module *mod)
75559 * Do it before processing of module parameters, so the module
75560 * can provide parameter accessor functions of its own.
75561 */
75562 - if (mod->module_init)
75563 - flush_icache_range((unsigned long)mod->module_init,
75564 - (unsigned long)mod->module_init
75565 - + mod->init_size);
75566 - flush_icache_range((unsigned long)mod->module_core,
75567 - (unsigned long)mod->module_core + mod->core_size);
75568 + if (mod->module_init_rx)
75569 + flush_icache_range((unsigned long)mod->module_init_rx,
75570 + (unsigned long)mod->module_init_rx
75571 + + mod->init_size_rx);
75572 + flush_icache_range((unsigned long)mod->module_core_rx,
75573 + (unsigned long)mod->module_core_rx + mod->core_size_rx);
75574
75575 set_fs(old_fs);
75576 }
75577 @@ -2983,8 +3088,10 @@ out:
75578 static void module_deallocate(struct module *mod, struct load_info *info)
75579 {
75580 percpu_modfree(mod);
75581 - module_free(mod, mod->module_init);
75582 - module_free(mod, mod->module_core);
75583 + module_free_exec(mod, mod->module_init_rx);
75584 + module_free_exec(mod, mod->module_core_rx);
75585 + module_free(mod, mod->module_init_rw);
75586 + module_free(mod, mod->module_core_rw);
75587 }
75588
75589 int __weak module_finalize(const Elf_Ehdr *hdr,
75590 @@ -2997,7 +3104,9 @@ int __weak module_finalize(const Elf_Ehdr *hdr,
75591 static int post_relocation(struct module *mod, const struct load_info *info)
75592 {
75593 /* Sort exception table now relocations are done. */
75594 + pax_open_kernel();
75595 sort_extable(mod->extable, mod->extable + mod->num_exentries);
75596 + pax_close_kernel();
75597
75598 /* Copy relocated percpu area over. */
75599 percpu_modcopy(mod, (void *)info->sechdrs[info->index.pcpu].sh_addr,
75600 @@ -3051,16 +3160,16 @@ static int do_init_module(struct module *mod)
75601 MODULE_STATE_COMING, mod);
75602
75603 /* Set RO and NX regions for core */
75604 - set_section_ro_nx(mod->module_core,
75605 - mod->core_text_size,
75606 - mod->core_ro_size,
75607 - mod->core_size);
75608 + set_section_ro_nx(mod->module_core_rx,
75609 + mod->core_size_rx,
75610 + mod->core_size_rx,
75611 + mod->core_size_rx);
75612
75613 /* Set RO and NX regions for init */
75614 - set_section_ro_nx(mod->module_init,
75615 - mod->init_text_size,
75616 - mod->init_ro_size,
75617 - mod->init_size);
75618 + set_section_ro_nx(mod->module_init_rx,
75619 + mod->init_size_rx,
75620 + mod->init_size_rx,
75621 + mod->init_size_rx);
75622
75623 do_mod_ctors(mod);
75624 /* Start the module */
75625 @@ -3122,11 +3231,12 @@ static int do_init_module(struct module *mod)
75626 mod->strtab = mod->core_strtab;
75627 #endif
75628 unset_module_init_ro_nx(mod);
75629 - module_free(mod, mod->module_init);
75630 - mod->module_init = NULL;
75631 - mod->init_size = 0;
75632 - mod->init_ro_size = 0;
75633 - mod->init_text_size = 0;
75634 + module_free(mod, mod->module_init_rw);
75635 + module_free_exec(mod, mod->module_init_rx);
75636 + mod->module_init_rw = NULL;
75637 + mod->module_init_rx = NULL;
75638 + mod->init_size_rw = 0;
75639 + mod->init_size_rx = 0;
75640 mutex_unlock(&module_mutex);
75641 wake_up_all(&module_wq);
75642
75643 @@ -3209,9 +3319,38 @@ again:
75644 if (err)
75645 goto free_unload;
75646
75647 + /* Now copy in args */
75648 + mod->args = strndup_user(uargs, ~0UL >> 1);
75649 + if (IS_ERR(mod->args)) {
75650 + err = PTR_ERR(mod->args);
75651 + goto free_unload;
75652 + }
75653 +
75654 /* Set up MODINFO_ATTR fields */
75655 setup_modinfo(mod, info);
75656
75657 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
75658 + {
75659 + char *p, *p2;
75660 +
75661 + if (strstr(mod->args, "grsec_modharden_netdev")) {
75662 + 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);
75663 + err = -EPERM;
75664 + goto free_modinfo;
75665 + } else if ((p = strstr(mod->args, "grsec_modharden_normal"))) {
75666 + p += sizeof("grsec_modharden_normal") - 1;
75667 + p2 = strstr(p, "_");
75668 + if (p2) {
75669 + *p2 = '\0';
75670 + printk(KERN_ALERT "grsec: denied kernel module auto-load of %.64s by uid %.9s\n", mod->name, p);
75671 + *p2 = '_';
75672 + }
75673 + err = -EPERM;
75674 + goto free_modinfo;
75675 + }
75676 + }
75677 +#endif
75678 +
75679 /* Fix up syms, so that st_value is a pointer to location. */
75680 err = simplify_symbols(mod, info);
75681 if (err < 0)
75682 @@ -3227,13 +3366,6 @@ again:
75683
75684 flush_module_icache(mod);
75685
75686 - /* Now copy in args */
75687 - mod->args = strndup_user(uargs, ~0UL >> 1);
75688 - if (IS_ERR(mod->args)) {
75689 - err = PTR_ERR(mod->args);
75690 - goto free_arch_cleanup;
75691 - }
75692 -
75693 dynamic_debug_setup(info->debug, info->num_debug);
75694
75695 mutex_lock(&module_mutex);
75696 @@ -3278,11 +3410,10 @@ again:
75697 mutex_unlock(&module_mutex);
75698 dynamic_debug_remove(info->debug);
75699 synchronize_sched();
75700 - kfree(mod->args);
75701 - free_arch_cleanup:
75702 module_arch_cleanup(mod);
75703 free_modinfo:
75704 free_modinfo(mod);
75705 + kfree(mod->args);
75706 free_unload:
75707 module_unload_free(mod);
75708 unlink_mod:
75709 @@ -3365,10 +3496,16 @@ static const char *get_ksymbol(struct module *mod,
75710 unsigned long nextval;
75711
75712 /* At worse, next value is at end of module */
75713 - if (within_module_init(addr, mod))
75714 - nextval = (unsigned long)mod->module_init+mod->init_text_size;
75715 + if (within_module_init_rx(addr, mod))
75716 + nextval = (unsigned long)mod->module_init_rx+mod->init_size_rx;
75717 + else if (within_module_init_rw(addr, mod))
75718 + nextval = (unsigned long)mod->module_init_rw+mod->init_size_rw;
75719 + else if (within_module_core_rx(addr, mod))
75720 + nextval = (unsigned long)mod->module_core_rx+mod->core_size_rx;
75721 + else if (within_module_core_rw(addr, mod))
75722 + nextval = (unsigned long)mod->module_core_rw+mod->core_size_rw;
75723 else
75724 - nextval = (unsigned long)mod->module_core+mod->core_text_size;
75725 + return NULL;
75726
75727 /* Scan for closest preceding symbol, and next symbol. (ELF
75728 starts real symbols at 1). */
75729 @@ -3621,7 +3758,7 @@ static int m_show(struct seq_file *m, void *p)
75730 return 0;
75731
75732 seq_printf(m, "%s %u",
75733 - mod->name, mod->init_size + mod->core_size);
75734 + mod->name, mod->init_size_rx + mod->init_size_rw + mod->core_size_rx + mod->core_size_rw);
75735 print_unload_info(m, mod);
75736
75737 /* Informative for users. */
75738 @@ -3630,7 +3767,7 @@ static int m_show(struct seq_file *m, void *p)
75739 mod->state == MODULE_STATE_COMING ? "Loading":
75740 "Live");
75741 /* Used by oprofile and other similar tools. */
75742 - seq_printf(m, " 0x%pK", mod->module_core);
75743 + seq_printf(m, " 0x%pK 0x%pK", mod->module_core_rx, mod->module_core_rw);
75744
75745 /* Taints info */
75746 if (mod->taints)
75747 @@ -3666,7 +3803,17 @@ static const struct file_operations proc_modules_operations = {
75748
75749 static int __init proc_modules_init(void)
75750 {
75751 +#ifndef CONFIG_GRKERNSEC_HIDESYM
75752 +#ifdef CONFIG_GRKERNSEC_PROC_USER
75753 + proc_create("modules", S_IRUSR, NULL, &proc_modules_operations);
75754 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
75755 + proc_create("modules", S_IRUSR | S_IRGRP, NULL, &proc_modules_operations);
75756 +#else
75757 proc_create("modules", 0, NULL, &proc_modules_operations);
75758 +#endif
75759 +#else
75760 + proc_create("modules", S_IRUSR, NULL, &proc_modules_operations);
75761 +#endif
75762 return 0;
75763 }
75764 module_init(proc_modules_init);
75765 @@ -3727,14 +3874,14 @@ struct module *__module_address(unsigned long addr)
75766 {
75767 struct module *mod;
75768
75769 - if (addr < module_addr_min || addr > module_addr_max)
75770 + if ((addr < module_addr_min_rx || addr > module_addr_max_rx) &&
75771 + (addr < module_addr_min_rw || addr > module_addr_max_rw))
75772 return NULL;
75773
75774 list_for_each_entry_rcu(mod, &modules, list) {
75775 if (mod->state == MODULE_STATE_UNFORMED)
75776 continue;
75777 - if (within_module_core(addr, mod)
75778 - || within_module_init(addr, mod))
75779 + if (within_module_init(addr, mod) || within_module_core(addr, mod))
75780 return mod;
75781 }
75782 return NULL;
75783 @@ -3769,11 +3916,20 @@ bool is_module_text_address(unsigned long addr)
75784 */
75785 struct module *__module_text_address(unsigned long addr)
75786 {
75787 - struct module *mod = __module_address(addr);
75788 + struct module *mod;
75789 +
75790 +#ifdef CONFIG_X86_32
75791 + addr = ktla_ktva(addr);
75792 +#endif
75793 +
75794 + if (addr < module_addr_min_rx || addr > module_addr_max_rx)
75795 + return NULL;
75796 +
75797 + mod = __module_address(addr);
75798 +
75799 if (mod) {
75800 /* Make sure it's within the text section. */
75801 - if (!within(addr, mod->module_init, mod->init_text_size)
75802 - && !within(addr, mod->module_core, mod->core_text_size))
75803 + if (!within_module_init_rx(addr, mod) && !within_module_core_rx(addr, mod))
75804 mod = NULL;
75805 }
75806 return mod;
75807 diff --git a/kernel/mutex-debug.c b/kernel/mutex-debug.c
75808 index 7e3443f..b2a1e6b 100644
75809 --- a/kernel/mutex-debug.c
75810 +++ b/kernel/mutex-debug.c
75811 @@ -49,21 +49,21 @@ void debug_mutex_free_waiter(struct mutex_waiter *waiter)
75812 }
75813
75814 void debug_mutex_add_waiter(struct mutex *lock, struct mutex_waiter *waiter,
75815 - struct thread_info *ti)
75816 + struct task_struct *task)
75817 {
75818 SMP_DEBUG_LOCKS_WARN_ON(!spin_is_locked(&lock->wait_lock));
75819
75820 /* Mark the current thread as blocked on the lock: */
75821 - ti->task->blocked_on = waiter;
75822 + task->blocked_on = waiter;
75823 }
75824
75825 void mutex_remove_waiter(struct mutex *lock, struct mutex_waiter *waiter,
75826 - struct thread_info *ti)
75827 + struct task_struct *task)
75828 {
75829 DEBUG_LOCKS_WARN_ON(list_empty(&waiter->list));
75830 - DEBUG_LOCKS_WARN_ON(waiter->task != ti->task);
75831 - DEBUG_LOCKS_WARN_ON(ti->task->blocked_on != waiter);
75832 - ti->task->blocked_on = NULL;
75833 + DEBUG_LOCKS_WARN_ON(waiter->task != task);
75834 + DEBUG_LOCKS_WARN_ON(task->blocked_on != waiter);
75835 + task->blocked_on = NULL;
75836
75837 list_del_init(&waiter->list);
75838 waiter->task = NULL;
75839 diff --git a/kernel/mutex-debug.h b/kernel/mutex-debug.h
75840 index 0799fd3..d06ae3b 100644
75841 --- a/kernel/mutex-debug.h
75842 +++ b/kernel/mutex-debug.h
75843 @@ -20,9 +20,9 @@ extern void debug_mutex_wake_waiter(struct mutex *lock,
75844 extern void debug_mutex_free_waiter(struct mutex_waiter *waiter);
75845 extern void debug_mutex_add_waiter(struct mutex *lock,
75846 struct mutex_waiter *waiter,
75847 - struct thread_info *ti);
75848 + struct task_struct *task);
75849 extern void mutex_remove_waiter(struct mutex *lock, struct mutex_waiter *waiter,
75850 - struct thread_info *ti);
75851 + struct task_struct *task);
75852 extern void debug_mutex_unlock(struct mutex *lock);
75853 extern void debug_mutex_init(struct mutex *lock, const char *name,
75854 struct lock_class_key *key);
75855 diff --git a/kernel/mutex.c b/kernel/mutex.c
75856 index a307cc9..27fd2e9 100644
75857 --- a/kernel/mutex.c
75858 +++ b/kernel/mutex.c
75859 @@ -198,7 +198,7 @@ __mutex_lock_common(struct mutex *lock, long state, unsigned int subclass,
75860 spin_lock_mutex(&lock->wait_lock, flags);
75861
75862 debug_mutex_lock_common(lock, &waiter);
75863 - debug_mutex_add_waiter(lock, &waiter, task_thread_info(task));
75864 + debug_mutex_add_waiter(lock, &waiter, task);
75865
75866 /* add waiting tasks to the end of the waitqueue (FIFO): */
75867 list_add_tail(&waiter.list, &lock->wait_list);
75868 @@ -227,8 +227,7 @@ __mutex_lock_common(struct mutex *lock, long state, unsigned int subclass,
75869 * TASK_UNINTERRUPTIBLE case.)
75870 */
75871 if (unlikely(signal_pending_state(state, task))) {
75872 - mutex_remove_waiter(lock, &waiter,
75873 - task_thread_info(task));
75874 + mutex_remove_waiter(lock, &waiter, task);
75875 mutex_release(&lock->dep_map, 1, ip);
75876 spin_unlock_mutex(&lock->wait_lock, flags);
75877
75878 @@ -247,7 +246,7 @@ __mutex_lock_common(struct mutex *lock, long state, unsigned int subclass,
75879 done:
75880 lock_acquired(&lock->dep_map, ip);
75881 /* got the lock - rejoice! */
75882 - mutex_remove_waiter(lock, &waiter, current_thread_info());
75883 + mutex_remove_waiter(lock, &waiter, task);
75884 mutex_set_owner(lock);
75885
75886 /* set it to 0 if there are no waiters left: */
75887 diff --git a/kernel/notifier.c b/kernel/notifier.c
75888 index 2d5cc4c..d9ea600 100644
75889 --- a/kernel/notifier.c
75890 +++ b/kernel/notifier.c
75891 @@ -5,6 +5,7 @@
75892 #include <linux/rcupdate.h>
75893 #include <linux/vmalloc.h>
75894 #include <linux/reboot.h>
75895 +#include <linux/mm.h>
75896
75897 /*
75898 * Notifier list for kernel code which wants to be called
75899 @@ -24,10 +25,12 @@ static int notifier_chain_register(struct notifier_block **nl,
75900 while ((*nl) != NULL) {
75901 if (n->priority > (*nl)->priority)
75902 break;
75903 - nl = &((*nl)->next);
75904 + nl = (struct notifier_block **)&((*nl)->next);
75905 }
75906 - n->next = *nl;
75907 + pax_open_kernel();
75908 + *(const void **)&n->next = *nl;
75909 rcu_assign_pointer(*nl, n);
75910 + pax_close_kernel();
75911 return 0;
75912 }
75913
75914 @@ -39,10 +42,12 @@ static int notifier_chain_cond_register(struct notifier_block **nl,
75915 return 0;
75916 if (n->priority > (*nl)->priority)
75917 break;
75918 - nl = &((*nl)->next);
75919 + nl = (struct notifier_block **)&((*nl)->next);
75920 }
75921 - n->next = *nl;
75922 + pax_open_kernel();
75923 + *(const void **)&n->next = *nl;
75924 rcu_assign_pointer(*nl, n);
75925 + pax_close_kernel();
75926 return 0;
75927 }
75928
75929 @@ -51,10 +56,12 @@ static int notifier_chain_unregister(struct notifier_block **nl,
75930 {
75931 while ((*nl) != NULL) {
75932 if ((*nl) == n) {
75933 + pax_open_kernel();
75934 rcu_assign_pointer(*nl, n->next);
75935 + pax_close_kernel();
75936 return 0;
75937 }
75938 - nl = &((*nl)->next);
75939 + nl = (struct notifier_block **)&((*nl)->next);
75940 }
75941 return -ENOENT;
75942 }
75943 diff --git a/kernel/panic.c b/kernel/panic.c
75944 index e1b2822..5edc1d9 100644
75945 --- a/kernel/panic.c
75946 +++ b/kernel/panic.c
75947 @@ -410,7 +410,7 @@ static void warn_slowpath_common(const char *file, int line, void *caller,
75948 const char *board;
75949
75950 printk(KERN_WARNING "------------[ cut here ]------------\n");
75951 - printk(KERN_WARNING "WARNING: at %s:%d %pS()\n", file, line, caller);
75952 + printk(KERN_WARNING "WARNING: at %s:%d %pA()\n", file, line, caller);
75953 board = dmi_get_system_info(DMI_PRODUCT_NAME);
75954 if (board)
75955 printk(KERN_WARNING "Hardware name: %s\n", board);
75956 @@ -465,7 +465,8 @@ EXPORT_SYMBOL(warn_slowpath_null);
75957 */
75958 void __stack_chk_fail(void)
75959 {
75960 - panic("stack-protector: Kernel stack is corrupted in: %p\n",
75961 + dump_stack();
75962 + panic("stack-protector: Kernel stack is corrupted in: %pA\n",
75963 __builtin_return_address(0));
75964 }
75965 EXPORT_SYMBOL(__stack_chk_fail);
75966 diff --git a/kernel/pid.c b/kernel/pid.c
75967 index f2c6a68..4922d97 100644
75968 --- a/kernel/pid.c
75969 +++ b/kernel/pid.c
75970 @@ -33,6 +33,7 @@
75971 #include <linux/rculist.h>
75972 #include <linux/bootmem.h>
75973 #include <linux/hash.h>
75974 +#include <linux/security.h>
75975 #include <linux/pid_namespace.h>
75976 #include <linux/init_task.h>
75977 #include <linux/syscalls.h>
75978 @@ -46,7 +47,7 @@ struct pid init_struct_pid = INIT_STRUCT_PID;
75979
75980 int pid_max = PID_MAX_DEFAULT;
75981
75982 -#define RESERVED_PIDS 300
75983 +#define RESERVED_PIDS 500
75984
75985 int pid_max_min = RESERVED_PIDS + 1;
75986 int pid_max_max = PID_MAX_LIMIT;
75987 @@ -441,10 +442,18 @@ EXPORT_SYMBOL(pid_task);
75988 */
75989 struct task_struct *find_task_by_pid_ns(pid_t nr, struct pid_namespace *ns)
75990 {
75991 + struct task_struct *task;
75992 +
75993 rcu_lockdep_assert(rcu_read_lock_held(),
75994 "find_task_by_pid_ns() needs rcu_read_lock()"
75995 " protection");
75996 - return pid_task(find_pid_ns(nr, ns), PIDTYPE_PID);
75997 +
75998 + task = pid_task(find_pid_ns(nr, ns), PIDTYPE_PID);
75999 +
76000 + if (gr_pid_is_chrooted(task))
76001 + return NULL;
76002 +
76003 + return task;
76004 }
76005
76006 struct task_struct *find_task_by_vpid(pid_t vnr)
76007 @@ -452,6 +461,14 @@ struct task_struct *find_task_by_vpid(pid_t vnr)
76008 return find_task_by_pid_ns(vnr, task_active_pid_ns(current));
76009 }
76010
76011 +struct task_struct *find_task_by_vpid_unrestricted(pid_t vnr)
76012 +{
76013 + rcu_lockdep_assert(rcu_read_lock_held(),
76014 + "find_task_by_pid_ns() needs rcu_read_lock()"
76015 + " protection");
76016 + return pid_task(find_pid_ns(vnr, task_active_pid_ns(current)), PIDTYPE_PID);
76017 +}
76018 +
76019 struct pid *get_task_pid(struct task_struct *task, enum pid_type type)
76020 {
76021 struct pid *pid;
76022 diff --git a/kernel/pid_namespace.c b/kernel/pid_namespace.c
76023 index c1c3dc1..bbeaf31 100644
76024 --- a/kernel/pid_namespace.c
76025 +++ b/kernel/pid_namespace.c
76026 @@ -248,7 +248,7 @@ static int pid_ns_ctl_handler(struct ctl_table *table, int write,
76027 void __user *buffer, size_t *lenp, loff_t *ppos)
76028 {
76029 struct pid_namespace *pid_ns = task_active_pid_ns(current);
76030 - struct ctl_table tmp = *table;
76031 + ctl_table_no_const tmp = *table;
76032
76033 if (write && !ns_capable(pid_ns->user_ns, CAP_SYS_ADMIN))
76034 return -EPERM;
76035 diff --git a/kernel/posix-cpu-timers.c b/kernel/posix-cpu-timers.c
76036 index 942ca27..111e609 100644
76037 --- a/kernel/posix-cpu-timers.c
76038 +++ b/kernel/posix-cpu-timers.c
76039 @@ -1576,14 +1576,14 @@ struct k_clock clock_posix_cpu = {
76040
76041 static __init int init_posix_cpu_timers(void)
76042 {
76043 - struct k_clock process = {
76044 + static struct k_clock process = {
76045 .clock_getres = process_cpu_clock_getres,
76046 .clock_get = process_cpu_clock_get,
76047 .timer_create = process_cpu_timer_create,
76048 .nsleep = process_cpu_nsleep,
76049 .nsleep_restart = process_cpu_nsleep_restart,
76050 };
76051 - struct k_clock thread = {
76052 + static struct k_clock thread = {
76053 .clock_getres = thread_cpu_clock_getres,
76054 .clock_get = thread_cpu_clock_get,
76055 .timer_create = thread_cpu_timer_create,
76056 diff --git a/kernel/posix-timers.c b/kernel/posix-timers.c
76057 index e885be1..380fe76 100644
76058 --- a/kernel/posix-timers.c
76059 +++ b/kernel/posix-timers.c
76060 @@ -43,6 +43,7 @@
76061 #include <linux/idr.h>
76062 #include <linux/posix-clock.h>
76063 #include <linux/posix-timers.h>
76064 +#include <linux/grsecurity.h>
76065 #include <linux/syscalls.h>
76066 #include <linux/wait.h>
76067 #include <linux/workqueue.h>
76068 @@ -129,7 +130,7 @@ static DEFINE_SPINLOCK(idr_lock);
76069 * which we beg off on and pass to do_sys_settimeofday().
76070 */
76071
76072 -static struct k_clock posix_clocks[MAX_CLOCKS];
76073 +static struct k_clock *posix_clocks[MAX_CLOCKS];
76074
76075 /*
76076 * These ones are defined below.
76077 @@ -227,7 +228,7 @@ static int posix_get_boottime(const clockid_t which_clock, struct timespec *tp)
76078 */
76079 static __init int init_posix_timers(void)
76080 {
76081 - struct k_clock clock_realtime = {
76082 + static struct k_clock clock_realtime = {
76083 .clock_getres = hrtimer_get_res,
76084 .clock_get = posix_clock_realtime_get,
76085 .clock_set = posix_clock_realtime_set,
76086 @@ -239,7 +240,7 @@ static __init int init_posix_timers(void)
76087 .timer_get = common_timer_get,
76088 .timer_del = common_timer_del,
76089 };
76090 - struct k_clock clock_monotonic = {
76091 + static struct k_clock clock_monotonic = {
76092 .clock_getres = hrtimer_get_res,
76093 .clock_get = posix_ktime_get_ts,
76094 .nsleep = common_nsleep,
76095 @@ -249,19 +250,19 @@ static __init int init_posix_timers(void)
76096 .timer_get = common_timer_get,
76097 .timer_del = common_timer_del,
76098 };
76099 - struct k_clock clock_monotonic_raw = {
76100 + static struct k_clock clock_monotonic_raw = {
76101 .clock_getres = hrtimer_get_res,
76102 .clock_get = posix_get_monotonic_raw,
76103 };
76104 - struct k_clock clock_realtime_coarse = {
76105 + static struct k_clock clock_realtime_coarse = {
76106 .clock_getres = posix_get_coarse_res,
76107 .clock_get = posix_get_realtime_coarse,
76108 };
76109 - struct k_clock clock_monotonic_coarse = {
76110 + static struct k_clock clock_monotonic_coarse = {
76111 .clock_getres = posix_get_coarse_res,
76112 .clock_get = posix_get_monotonic_coarse,
76113 };
76114 - struct k_clock clock_boottime = {
76115 + static struct k_clock clock_boottime = {
76116 .clock_getres = hrtimer_get_res,
76117 .clock_get = posix_get_boottime,
76118 .nsleep = common_nsleep,
76119 @@ -473,7 +474,7 @@ void posix_timers_register_clock(const clockid_t clock_id,
76120 return;
76121 }
76122
76123 - posix_clocks[clock_id] = *new_clock;
76124 + posix_clocks[clock_id] = new_clock;
76125 }
76126 EXPORT_SYMBOL_GPL(posix_timers_register_clock);
76127
76128 @@ -519,9 +520,9 @@ static struct k_clock *clockid_to_kclock(const clockid_t id)
76129 return (id & CLOCKFD_MASK) == CLOCKFD ?
76130 &clock_posix_dynamic : &clock_posix_cpu;
76131
76132 - if (id >= MAX_CLOCKS || !posix_clocks[id].clock_getres)
76133 + if (id >= MAX_CLOCKS || !posix_clocks[id] || !posix_clocks[id]->clock_getres)
76134 return NULL;
76135 - return &posix_clocks[id];
76136 + return posix_clocks[id];
76137 }
76138
76139 static int common_timer_create(struct k_itimer *new_timer)
76140 @@ -966,6 +967,13 @@ SYSCALL_DEFINE2(clock_settime, const clockid_t, which_clock,
76141 if (copy_from_user(&new_tp, tp, sizeof (*tp)))
76142 return -EFAULT;
76143
76144 + /* only the CLOCK_REALTIME clock can be set, all other clocks
76145 + have their clock_set fptr set to a nosettime dummy function
76146 + CLOCK_REALTIME has a NULL clock_set fptr which causes it to
76147 + call common_clock_set, which calls do_sys_settimeofday, which
76148 + we hook
76149 + */
76150 +
76151 return kc->clock_set(which_clock, &new_tp);
76152 }
76153
76154 diff --git a/kernel/power/process.c b/kernel/power/process.c
76155 index d5a258b..4271191 100644
76156 --- a/kernel/power/process.c
76157 +++ b/kernel/power/process.c
76158 @@ -33,6 +33,7 @@ static int try_to_freeze_tasks(bool user_only)
76159 u64 elapsed_csecs64;
76160 unsigned int elapsed_csecs;
76161 bool wakeup = false;
76162 + bool timedout = false;
76163
76164 do_gettimeofday(&start);
76165
76166 @@ -43,13 +44,20 @@ static int try_to_freeze_tasks(bool user_only)
76167
76168 while (true) {
76169 todo = 0;
76170 + if (time_after(jiffies, end_time))
76171 + timedout = true;
76172 read_lock(&tasklist_lock);
76173 do_each_thread(g, p) {
76174 if (p == current || !freeze_task(p))
76175 continue;
76176
76177 - if (!freezer_should_skip(p))
76178 + if (!freezer_should_skip(p)) {
76179 todo++;
76180 + if (timedout) {
76181 + printk(KERN_ERR "Task refusing to freeze:\n");
76182 + sched_show_task(p);
76183 + }
76184 + }
76185 } while_each_thread(g, p);
76186 read_unlock(&tasklist_lock);
76187
76188 @@ -58,7 +66,7 @@ static int try_to_freeze_tasks(bool user_only)
76189 todo += wq_busy;
76190 }
76191
76192 - if (!todo || time_after(jiffies, end_time))
76193 + if (!todo || timedout)
76194 break;
76195
76196 if (pm_wakeup_pending()) {
76197 diff --git a/kernel/printk.c b/kernel/printk.c
76198 index 267ce78..2487112 100644
76199 --- a/kernel/printk.c
76200 +++ b/kernel/printk.c
76201 @@ -609,11 +609,17 @@ static unsigned int devkmsg_poll(struct file *file, poll_table *wait)
76202 return ret;
76203 }
76204
76205 +static int check_syslog_permissions(int type, bool from_file);
76206 +
76207 static int devkmsg_open(struct inode *inode, struct file *file)
76208 {
76209 struct devkmsg_user *user;
76210 int err;
76211
76212 + err = check_syslog_permissions(SYSLOG_ACTION_OPEN, SYSLOG_FROM_FILE);
76213 + if (err)
76214 + return err;
76215 +
76216 /* write-only does not need any file context */
76217 if ((file->f_flags & O_ACCMODE) == O_WRONLY)
76218 return 0;
76219 @@ -822,7 +828,7 @@ static int syslog_action_restricted(int type)
76220 if (dmesg_restrict)
76221 return 1;
76222 /* Unless restricted, we allow "read all" and "get buffer size" for everybody */
76223 - return type != SYSLOG_ACTION_READ_ALL && type != SYSLOG_ACTION_SIZE_BUFFER;
76224 + return type != SYSLOG_ACTION_OPEN && type != SYSLOG_ACTION_READ_ALL && type != SYSLOG_ACTION_SIZE_BUFFER;
76225 }
76226
76227 static int check_syslog_permissions(int type, bool from_file)
76228 @@ -834,6 +840,11 @@ static int check_syslog_permissions(int type, bool from_file)
76229 if (from_file && type != SYSLOG_ACTION_OPEN)
76230 return 0;
76231
76232 +#ifdef CONFIG_GRKERNSEC_DMESG
76233 + if (grsec_enable_dmesg && !capable(CAP_SYSLOG) && !capable_nolog(CAP_SYS_ADMIN))
76234 + return -EPERM;
76235 +#endif
76236 +
76237 if (syslog_action_restricted(type)) {
76238 if (capable(CAP_SYSLOG))
76239 return 0;
76240 diff --git a/kernel/profile.c b/kernel/profile.c
76241 index 1f39181..86093471 100644
76242 --- a/kernel/profile.c
76243 +++ b/kernel/profile.c
76244 @@ -40,7 +40,7 @@ struct profile_hit {
76245 /* Oprofile timer tick hook */
76246 static int (*timer_hook)(struct pt_regs *) __read_mostly;
76247
76248 -static atomic_t *prof_buffer;
76249 +static atomic_unchecked_t *prof_buffer;
76250 static unsigned long prof_len, prof_shift;
76251
76252 int prof_on __read_mostly;
76253 @@ -282,7 +282,7 @@ static void profile_flip_buffers(void)
76254 hits[i].pc = 0;
76255 continue;
76256 }
76257 - atomic_add(hits[i].hits, &prof_buffer[hits[i].pc]);
76258 + atomic_add_unchecked(hits[i].hits, &prof_buffer[hits[i].pc]);
76259 hits[i].hits = hits[i].pc = 0;
76260 }
76261 }
76262 @@ -343,9 +343,9 @@ static void do_profile_hits(int type, void *__pc, unsigned int nr_hits)
76263 * Add the current hit(s) and flush the write-queue out
76264 * to the global buffer:
76265 */
76266 - atomic_add(nr_hits, &prof_buffer[pc]);
76267 + atomic_add_unchecked(nr_hits, &prof_buffer[pc]);
76268 for (i = 0; i < NR_PROFILE_HIT; ++i) {
76269 - atomic_add(hits[i].hits, &prof_buffer[hits[i].pc]);
76270 + atomic_add_unchecked(hits[i].hits, &prof_buffer[hits[i].pc]);
76271 hits[i].pc = hits[i].hits = 0;
76272 }
76273 out:
76274 @@ -420,7 +420,7 @@ static void do_profile_hits(int type, void *__pc, unsigned int nr_hits)
76275 {
76276 unsigned long pc;
76277 pc = ((unsigned long)__pc - (unsigned long)_stext) >> prof_shift;
76278 - atomic_add(nr_hits, &prof_buffer[min(pc, prof_len - 1)]);
76279 + atomic_add_unchecked(nr_hits, &prof_buffer[min(pc, prof_len - 1)]);
76280 }
76281 #endif /* !CONFIG_SMP */
76282
76283 @@ -518,7 +518,7 @@ read_profile(struct file *file, char __user *buf, size_t count, loff_t *ppos)
76284 return -EFAULT;
76285 buf++; p++; count--; read++;
76286 }
76287 - pnt = (char *)prof_buffer + p - sizeof(atomic_t);
76288 + pnt = (char *)prof_buffer + p - sizeof(atomic_unchecked_t);
76289 if (copy_to_user(buf, (void *)pnt, count))
76290 return -EFAULT;
76291 read += count;
76292 @@ -549,7 +549,7 @@ static ssize_t write_profile(struct file *file, const char __user *buf,
76293 }
76294 #endif
76295 profile_discard_flip_buffers();
76296 - memset(prof_buffer, 0, prof_len * sizeof(atomic_t));
76297 + memset(prof_buffer, 0, prof_len * sizeof(atomic_unchecked_t));
76298 return count;
76299 }
76300
76301 diff --git a/kernel/ptrace.c b/kernel/ptrace.c
76302 index 6cbeaae..363c48a 100644
76303 --- a/kernel/ptrace.c
76304 +++ b/kernel/ptrace.c
76305 @@ -324,7 +324,7 @@ static int ptrace_attach(struct task_struct *task, long request,
76306 if (seize)
76307 flags |= PT_SEIZED;
76308 rcu_read_lock();
76309 - if (ns_capable(__task_cred(task)->user_ns, CAP_SYS_PTRACE))
76310 + if (ns_capable_nolog(__task_cred(task)->user_ns, CAP_SYS_PTRACE))
76311 flags |= PT_PTRACE_CAP;
76312 rcu_read_unlock();
76313 task->ptrace = flags;
76314 @@ -535,7 +535,7 @@ int ptrace_readdata(struct task_struct *tsk, unsigned long src, char __user *dst
76315 break;
76316 return -EIO;
76317 }
76318 - if (copy_to_user(dst, buf, retval))
76319 + if (retval > sizeof(buf) || copy_to_user(dst, buf, retval))
76320 return -EFAULT;
76321 copied += retval;
76322 src += retval;
76323 @@ -720,7 +720,7 @@ int ptrace_request(struct task_struct *child, long request,
76324 bool seized = child->ptrace & PT_SEIZED;
76325 int ret = -EIO;
76326 siginfo_t siginfo, *si;
76327 - void __user *datavp = (void __user *) data;
76328 + void __user *datavp = (__force void __user *) data;
76329 unsigned long __user *datalp = datavp;
76330 unsigned long flags;
76331
76332 @@ -922,14 +922,21 @@ SYSCALL_DEFINE4(ptrace, long, request, long, pid, unsigned long, addr,
76333 goto out;
76334 }
76335
76336 + if (gr_handle_ptrace(child, request)) {
76337 + ret = -EPERM;
76338 + goto out_put_task_struct;
76339 + }
76340 +
76341 if (request == PTRACE_ATTACH || request == PTRACE_SEIZE) {
76342 ret = ptrace_attach(child, request, addr, data);
76343 /*
76344 * Some architectures need to do book-keeping after
76345 * a ptrace attach.
76346 */
76347 - if (!ret)
76348 + if (!ret) {
76349 arch_ptrace_attach(child);
76350 + gr_audit_ptrace(child);
76351 + }
76352 goto out_put_task_struct;
76353 }
76354
76355 @@ -957,7 +964,7 @@ int generic_ptrace_peekdata(struct task_struct *tsk, unsigned long addr,
76356 copied = access_process_vm(tsk, addr, &tmp, sizeof(tmp), 0);
76357 if (copied != sizeof(tmp))
76358 return -EIO;
76359 - return put_user(tmp, (unsigned long __user *)data);
76360 + return put_user(tmp, (__force unsigned long __user *)data);
76361 }
76362
76363 int generic_ptrace_pokedata(struct task_struct *tsk, unsigned long addr,
76364 @@ -1067,14 +1074,21 @@ asmlinkage long compat_sys_ptrace(compat_long_t request, compat_long_t pid,
76365 goto out;
76366 }
76367
76368 + if (gr_handle_ptrace(child, request)) {
76369 + ret = -EPERM;
76370 + goto out_put_task_struct;
76371 + }
76372 +
76373 if (request == PTRACE_ATTACH || request == PTRACE_SEIZE) {
76374 ret = ptrace_attach(child, request, addr, data);
76375 /*
76376 * Some architectures need to do book-keeping after
76377 * a ptrace attach.
76378 */
76379 - if (!ret)
76380 + if (!ret) {
76381 arch_ptrace_attach(child);
76382 + gr_audit_ptrace(child);
76383 + }
76384 goto out_put_task_struct;
76385 }
76386
76387 diff --git a/kernel/rcutiny.c b/kernel/rcutiny.c
76388 index e7dce58..ad0d7b7 100644
76389 --- a/kernel/rcutiny.c
76390 +++ b/kernel/rcutiny.c
76391 @@ -46,7 +46,7 @@
76392 struct rcu_ctrlblk;
76393 static void invoke_rcu_callbacks(void);
76394 static void __rcu_process_callbacks(struct rcu_ctrlblk *rcp);
76395 -static void rcu_process_callbacks(struct softirq_action *unused);
76396 +static void rcu_process_callbacks(void);
76397 static void __call_rcu(struct rcu_head *head,
76398 void (*func)(struct rcu_head *rcu),
76399 struct rcu_ctrlblk *rcp);
76400 @@ -310,7 +310,7 @@ static void __rcu_process_callbacks(struct rcu_ctrlblk *rcp)
76401 rcu_is_callbacks_kthread()));
76402 }
76403
76404 -static void rcu_process_callbacks(struct softirq_action *unused)
76405 +static void rcu_process_callbacks(void)
76406 {
76407 __rcu_process_callbacks(&rcu_sched_ctrlblk);
76408 __rcu_process_callbacks(&rcu_bh_ctrlblk);
76409 diff --git a/kernel/rcutiny_plugin.h b/kernel/rcutiny_plugin.h
76410 index f85016a..91cb03b 100644
76411 --- a/kernel/rcutiny_plugin.h
76412 +++ b/kernel/rcutiny_plugin.h
76413 @@ -896,7 +896,7 @@ static int rcu_kthread(void *arg)
76414 have_rcu_kthread_work = morework;
76415 local_irq_restore(flags);
76416 if (work)
76417 - rcu_process_callbacks(NULL);
76418 + rcu_process_callbacks();
76419 schedule_timeout_interruptible(1); /* Leave CPU for others. */
76420 }
76421
76422 diff --git a/kernel/rcutorture.c b/kernel/rcutorture.c
76423 index 31dea01..ad91ffb 100644
76424 --- a/kernel/rcutorture.c
76425 +++ b/kernel/rcutorture.c
76426 @@ -163,12 +163,12 @@ static DEFINE_PER_CPU(long [RCU_TORTURE_PIPE_LEN + 1], rcu_torture_count) =
76427 { 0 };
76428 static DEFINE_PER_CPU(long [RCU_TORTURE_PIPE_LEN + 1], rcu_torture_batch) =
76429 { 0 };
76430 -static atomic_t rcu_torture_wcount[RCU_TORTURE_PIPE_LEN + 1];
76431 -static atomic_t n_rcu_torture_alloc;
76432 -static atomic_t n_rcu_torture_alloc_fail;
76433 -static atomic_t n_rcu_torture_free;
76434 -static atomic_t n_rcu_torture_mberror;
76435 -static atomic_t n_rcu_torture_error;
76436 +static atomic_unchecked_t rcu_torture_wcount[RCU_TORTURE_PIPE_LEN + 1];
76437 +static atomic_unchecked_t n_rcu_torture_alloc;
76438 +static atomic_unchecked_t n_rcu_torture_alloc_fail;
76439 +static atomic_unchecked_t n_rcu_torture_free;
76440 +static atomic_unchecked_t n_rcu_torture_mberror;
76441 +static atomic_unchecked_t n_rcu_torture_error;
76442 static long n_rcu_torture_barrier_error;
76443 static long n_rcu_torture_boost_ktrerror;
76444 static long n_rcu_torture_boost_rterror;
76445 @@ -272,11 +272,11 @@ rcu_torture_alloc(void)
76446
76447 spin_lock_bh(&rcu_torture_lock);
76448 if (list_empty(&rcu_torture_freelist)) {
76449 - atomic_inc(&n_rcu_torture_alloc_fail);
76450 + atomic_inc_unchecked(&n_rcu_torture_alloc_fail);
76451 spin_unlock_bh(&rcu_torture_lock);
76452 return NULL;
76453 }
76454 - atomic_inc(&n_rcu_torture_alloc);
76455 + atomic_inc_unchecked(&n_rcu_torture_alloc);
76456 p = rcu_torture_freelist.next;
76457 list_del_init(p);
76458 spin_unlock_bh(&rcu_torture_lock);
76459 @@ -289,7 +289,7 @@ rcu_torture_alloc(void)
76460 static void
76461 rcu_torture_free(struct rcu_torture *p)
76462 {
76463 - atomic_inc(&n_rcu_torture_free);
76464 + atomic_inc_unchecked(&n_rcu_torture_free);
76465 spin_lock_bh(&rcu_torture_lock);
76466 list_add_tail(&p->rtort_free, &rcu_torture_freelist);
76467 spin_unlock_bh(&rcu_torture_lock);
76468 @@ -409,7 +409,7 @@ rcu_torture_cb(struct rcu_head *p)
76469 i = rp->rtort_pipe_count;
76470 if (i > RCU_TORTURE_PIPE_LEN)
76471 i = RCU_TORTURE_PIPE_LEN;
76472 - atomic_inc(&rcu_torture_wcount[i]);
76473 + atomic_inc_unchecked(&rcu_torture_wcount[i]);
76474 if (++rp->rtort_pipe_count >= RCU_TORTURE_PIPE_LEN) {
76475 rp->rtort_mbtest = 0;
76476 rcu_torture_free(rp);
76477 @@ -457,7 +457,7 @@ static void rcu_sync_torture_deferred_free(struct rcu_torture *p)
76478 i = rp->rtort_pipe_count;
76479 if (i > RCU_TORTURE_PIPE_LEN)
76480 i = RCU_TORTURE_PIPE_LEN;
76481 - atomic_inc(&rcu_torture_wcount[i]);
76482 + atomic_inc_unchecked(&rcu_torture_wcount[i]);
76483 if (++rp->rtort_pipe_count >= RCU_TORTURE_PIPE_LEN) {
76484 rp->rtort_mbtest = 0;
76485 list_del(&rp->rtort_free);
76486 @@ -975,7 +975,7 @@ rcu_torture_writer(void *arg)
76487 i = old_rp->rtort_pipe_count;
76488 if (i > RCU_TORTURE_PIPE_LEN)
76489 i = RCU_TORTURE_PIPE_LEN;
76490 - atomic_inc(&rcu_torture_wcount[i]);
76491 + atomic_inc_unchecked(&rcu_torture_wcount[i]);
76492 old_rp->rtort_pipe_count++;
76493 cur_ops->deferred_free(old_rp);
76494 }
76495 @@ -1060,7 +1060,7 @@ static void rcu_torture_timer(unsigned long unused)
76496 }
76497 do_trace_rcu_torture_read(cur_ops->name, &p->rtort_rcu);
76498 if (p->rtort_mbtest == 0)
76499 - atomic_inc(&n_rcu_torture_mberror);
76500 + atomic_inc_unchecked(&n_rcu_torture_mberror);
76501 spin_lock(&rand_lock);
76502 cur_ops->read_delay(&rand);
76503 n_rcu_torture_timers++;
76504 @@ -1124,7 +1124,7 @@ rcu_torture_reader(void *arg)
76505 }
76506 do_trace_rcu_torture_read(cur_ops->name, &p->rtort_rcu);
76507 if (p->rtort_mbtest == 0)
76508 - atomic_inc(&n_rcu_torture_mberror);
76509 + atomic_inc_unchecked(&n_rcu_torture_mberror);
76510 cur_ops->read_delay(&rand);
76511 preempt_disable();
76512 pipe_count = p->rtort_pipe_count;
76513 @@ -1183,11 +1183,11 @@ rcu_torture_printk(char *page)
76514 rcu_torture_current,
76515 rcu_torture_current_version,
76516 list_empty(&rcu_torture_freelist),
76517 - atomic_read(&n_rcu_torture_alloc),
76518 - atomic_read(&n_rcu_torture_alloc_fail),
76519 - atomic_read(&n_rcu_torture_free));
76520 + atomic_read_unchecked(&n_rcu_torture_alloc),
76521 + atomic_read_unchecked(&n_rcu_torture_alloc_fail),
76522 + atomic_read_unchecked(&n_rcu_torture_free));
76523 cnt += sprintf(&page[cnt], "rtmbe: %d rtbke: %ld rtbre: %ld ",
76524 - atomic_read(&n_rcu_torture_mberror),
76525 + atomic_read_unchecked(&n_rcu_torture_mberror),
76526 n_rcu_torture_boost_ktrerror,
76527 n_rcu_torture_boost_rterror);
76528 cnt += sprintf(&page[cnt], "rtbf: %ld rtb: %ld nt: %ld ",
76529 @@ -1206,14 +1206,14 @@ rcu_torture_printk(char *page)
76530 n_barrier_attempts,
76531 n_rcu_torture_barrier_error);
76532 cnt += sprintf(&page[cnt], "\n%s%s ", torture_type, TORTURE_FLAG);
76533 - if (atomic_read(&n_rcu_torture_mberror) != 0 ||
76534 + if (atomic_read_unchecked(&n_rcu_torture_mberror) != 0 ||
76535 n_rcu_torture_barrier_error != 0 ||
76536 n_rcu_torture_boost_ktrerror != 0 ||
76537 n_rcu_torture_boost_rterror != 0 ||
76538 n_rcu_torture_boost_failure != 0 ||
76539 i > 1) {
76540 cnt += sprintf(&page[cnt], "!!! ");
76541 - atomic_inc(&n_rcu_torture_error);
76542 + atomic_inc_unchecked(&n_rcu_torture_error);
76543 WARN_ON_ONCE(1);
76544 }
76545 cnt += sprintf(&page[cnt], "Reader Pipe: ");
76546 @@ -1227,7 +1227,7 @@ rcu_torture_printk(char *page)
76547 cnt += sprintf(&page[cnt], "Free-Block Circulation: ");
76548 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++) {
76549 cnt += sprintf(&page[cnt], " %d",
76550 - atomic_read(&rcu_torture_wcount[i]));
76551 + atomic_read_unchecked(&rcu_torture_wcount[i]));
76552 }
76553 cnt += sprintf(&page[cnt], "\n");
76554 if (cur_ops->stats)
76555 @@ -1920,7 +1920,7 @@ rcu_torture_cleanup(void)
76556
76557 rcu_torture_stats_print(); /* -After- the stats thread is stopped! */
76558
76559 - if (atomic_read(&n_rcu_torture_error) || n_rcu_torture_barrier_error)
76560 + if (atomic_read_unchecked(&n_rcu_torture_error) || n_rcu_torture_barrier_error)
76561 rcu_torture_print_module_parms(cur_ops, "End of test: FAILURE");
76562 else if (n_online_successes != n_online_attempts ||
76563 n_offline_successes != n_offline_attempts)
76564 @@ -1989,18 +1989,18 @@ rcu_torture_init(void)
76565
76566 rcu_torture_current = NULL;
76567 rcu_torture_current_version = 0;
76568 - atomic_set(&n_rcu_torture_alloc, 0);
76569 - atomic_set(&n_rcu_torture_alloc_fail, 0);
76570 - atomic_set(&n_rcu_torture_free, 0);
76571 - atomic_set(&n_rcu_torture_mberror, 0);
76572 - atomic_set(&n_rcu_torture_error, 0);
76573 + atomic_set_unchecked(&n_rcu_torture_alloc, 0);
76574 + atomic_set_unchecked(&n_rcu_torture_alloc_fail, 0);
76575 + atomic_set_unchecked(&n_rcu_torture_free, 0);
76576 + atomic_set_unchecked(&n_rcu_torture_mberror, 0);
76577 + atomic_set_unchecked(&n_rcu_torture_error, 0);
76578 n_rcu_torture_barrier_error = 0;
76579 n_rcu_torture_boost_ktrerror = 0;
76580 n_rcu_torture_boost_rterror = 0;
76581 n_rcu_torture_boost_failure = 0;
76582 n_rcu_torture_boosts = 0;
76583 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++)
76584 - atomic_set(&rcu_torture_wcount[i], 0);
76585 + atomic_set_unchecked(&rcu_torture_wcount[i], 0);
76586 for_each_possible_cpu(cpu) {
76587 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++) {
76588 per_cpu(rcu_torture_count, cpu)[i] = 0;
76589 diff --git a/kernel/rcutree.c b/kernel/rcutree.c
76590 index e441b77..dd54f17 100644
76591 --- a/kernel/rcutree.c
76592 +++ b/kernel/rcutree.c
76593 @@ -349,9 +349,9 @@ static void rcu_eqs_enter_common(struct rcu_dynticks *rdtp, long long oldval,
76594 rcu_prepare_for_idle(smp_processor_id());
76595 /* CPUs seeing atomic_inc() must see prior RCU read-side crit sects */
76596 smp_mb__before_atomic_inc(); /* See above. */
76597 - atomic_inc(&rdtp->dynticks);
76598 + atomic_inc_unchecked(&rdtp->dynticks);
76599 smp_mb__after_atomic_inc(); /* Force ordering with next sojourn. */
76600 - WARN_ON_ONCE(atomic_read(&rdtp->dynticks) & 0x1);
76601 + WARN_ON_ONCE(atomic_read_unchecked(&rdtp->dynticks) & 0x1);
76602
76603 /*
76604 * It is illegal to enter an extended quiescent state while
76605 @@ -487,10 +487,10 @@ static void rcu_eqs_exit_common(struct rcu_dynticks *rdtp, long long oldval,
76606 int user)
76607 {
76608 smp_mb__before_atomic_inc(); /* Force ordering w/previous sojourn. */
76609 - atomic_inc(&rdtp->dynticks);
76610 + atomic_inc_unchecked(&rdtp->dynticks);
76611 /* CPUs seeing atomic_inc() must see later RCU read-side crit sects */
76612 smp_mb__after_atomic_inc(); /* See above. */
76613 - WARN_ON_ONCE(!(atomic_read(&rdtp->dynticks) & 0x1));
76614 + WARN_ON_ONCE(!(atomic_read_unchecked(&rdtp->dynticks) & 0x1));
76615 rcu_cleanup_after_idle(smp_processor_id());
76616 trace_rcu_dyntick("End", oldval, rdtp->dynticks_nesting);
76617 if (!user && !is_idle_task(current)) {
76618 @@ -629,14 +629,14 @@ void rcu_nmi_enter(void)
76619 struct rcu_dynticks *rdtp = &__get_cpu_var(rcu_dynticks);
76620
76621 if (rdtp->dynticks_nmi_nesting == 0 &&
76622 - (atomic_read(&rdtp->dynticks) & 0x1))
76623 + (atomic_read_unchecked(&rdtp->dynticks) & 0x1))
76624 return;
76625 rdtp->dynticks_nmi_nesting++;
76626 smp_mb__before_atomic_inc(); /* Force delay from prior write. */
76627 - atomic_inc(&rdtp->dynticks);
76628 + atomic_inc_unchecked(&rdtp->dynticks);
76629 /* CPUs seeing atomic_inc() must see later RCU read-side crit sects */
76630 smp_mb__after_atomic_inc(); /* See above. */
76631 - WARN_ON_ONCE(!(atomic_read(&rdtp->dynticks) & 0x1));
76632 + WARN_ON_ONCE(!(atomic_read_unchecked(&rdtp->dynticks) & 0x1));
76633 }
76634
76635 /**
76636 @@ -655,9 +655,9 @@ void rcu_nmi_exit(void)
76637 return;
76638 /* CPUs seeing atomic_inc() must see prior RCU read-side crit sects */
76639 smp_mb__before_atomic_inc(); /* See above. */
76640 - atomic_inc(&rdtp->dynticks);
76641 + atomic_inc_unchecked(&rdtp->dynticks);
76642 smp_mb__after_atomic_inc(); /* Force delay to next write. */
76643 - WARN_ON_ONCE(atomic_read(&rdtp->dynticks) & 0x1);
76644 + WARN_ON_ONCE(atomic_read_unchecked(&rdtp->dynticks) & 0x1);
76645 }
76646
76647 /**
76648 @@ -671,7 +671,7 @@ int rcu_is_cpu_idle(void)
76649 int ret;
76650
76651 preempt_disable();
76652 - ret = (atomic_read(&__get_cpu_var(rcu_dynticks).dynticks) & 0x1) == 0;
76653 + ret = (atomic_read_unchecked(&__get_cpu_var(rcu_dynticks).dynticks) & 0x1) == 0;
76654 preempt_enable();
76655 return ret;
76656 }
76657 @@ -739,7 +739,7 @@ int rcu_is_cpu_rrupt_from_idle(void)
76658 */
76659 static int dyntick_save_progress_counter(struct rcu_data *rdp)
76660 {
76661 - rdp->dynticks_snap = atomic_add_return(0, &rdp->dynticks->dynticks);
76662 + rdp->dynticks_snap = atomic_add_return_unchecked(0, &rdp->dynticks->dynticks);
76663 return (rdp->dynticks_snap & 0x1) == 0;
76664 }
76665
76666 @@ -754,7 +754,7 @@ static int rcu_implicit_dynticks_qs(struct rcu_data *rdp)
76667 unsigned int curr;
76668 unsigned int snap;
76669
76670 - curr = (unsigned int)atomic_add_return(0, &rdp->dynticks->dynticks);
76671 + curr = (unsigned int)atomic_add_return_unchecked(0, &rdp->dynticks->dynticks);
76672 snap = (unsigned int)rdp->dynticks_snap;
76673
76674 /*
76675 @@ -802,10 +802,10 @@ static int jiffies_till_stall_check(void)
76676 * for CONFIG_RCU_CPU_STALL_TIMEOUT.
76677 */
76678 if (till_stall_check < 3) {
76679 - ACCESS_ONCE(rcu_cpu_stall_timeout) = 3;
76680 + ACCESS_ONCE_RW(rcu_cpu_stall_timeout) = 3;
76681 till_stall_check = 3;
76682 } else if (till_stall_check > 300) {
76683 - ACCESS_ONCE(rcu_cpu_stall_timeout) = 300;
76684 + ACCESS_ONCE_RW(rcu_cpu_stall_timeout) = 300;
76685 till_stall_check = 300;
76686 }
76687 return till_stall_check * HZ + RCU_STALL_DELAY_DELTA;
76688 @@ -1592,7 +1592,7 @@ rcu_send_cbs_to_orphanage(int cpu, struct rcu_state *rsp,
76689 rsp->qlen += rdp->qlen;
76690 rdp->n_cbs_orphaned += rdp->qlen;
76691 rdp->qlen_lazy = 0;
76692 - ACCESS_ONCE(rdp->qlen) = 0;
76693 + ACCESS_ONCE_RW(rdp->qlen) = 0;
76694 }
76695
76696 /*
76697 @@ -1838,7 +1838,7 @@ static void rcu_do_batch(struct rcu_state *rsp, struct rcu_data *rdp)
76698 }
76699 smp_mb(); /* List handling before counting for rcu_barrier(). */
76700 rdp->qlen_lazy -= count_lazy;
76701 - ACCESS_ONCE(rdp->qlen) -= count;
76702 + ACCESS_ONCE_RW(rdp->qlen) -= count;
76703 rdp->n_cbs_invoked += count;
76704
76705 /* Reinstate batch limit if we have worked down the excess. */
76706 @@ -2031,7 +2031,7 @@ __rcu_process_callbacks(struct rcu_state *rsp)
76707 /*
76708 * Do RCU core processing for the current CPU.
76709 */
76710 -static void rcu_process_callbacks(struct softirq_action *unused)
76711 +static void rcu_process_callbacks(void)
76712 {
76713 struct rcu_state *rsp;
76714
76715 @@ -2154,7 +2154,7 @@ __call_rcu(struct rcu_head *head, void (*func)(struct rcu_head *rcu),
76716 local_irq_restore(flags);
76717 return;
76718 }
76719 - ACCESS_ONCE(rdp->qlen)++;
76720 + ACCESS_ONCE_RW(rdp->qlen)++;
76721 if (lazy)
76722 rdp->qlen_lazy++;
76723 else
76724 @@ -2363,11 +2363,11 @@ void synchronize_sched_expedited(void)
76725 * counter wrap on a 32-bit system. Quite a few more CPUs would of
76726 * course be required on a 64-bit system.
76727 */
76728 - if (ULONG_CMP_GE((ulong)atomic_long_read(&rsp->expedited_start),
76729 + if (ULONG_CMP_GE((ulong)atomic_long_read_unchecked(&rsp->expedited_start),
76730 (ulong)atomic_long_read(&rsp->expedited_done) +
76731 ULONG_MAX / 8)) {
76732 synchronize_sched();
76733 - atomic_long_inc(&rsp->expedited_wrap);
76734 + atomic_long_inc_unchecked(&rsp->expedited_wrap);
76735 return;
76736 }
76737
76738 @@ -2375,7 +2375,7 @@ void synchronize_sched_expedited(void)
76739 * Take a ticket. Note that atomic_inc_return() implies a
76740 * full memory barrier.
76741 */
76742 - snap = atomic_long_inc_return(&rsp->expedited_start);
76743 + snap = atomic_long_inc_return_unchecked(&rsp->expedited_start);
76744 firstsnap = snap;
76745 get_online_cpus();
76746 WARN_ON_ONCE(cpu_is_offline(raw_smp_processor_id()));
76747 @@ -2388,14 +2388,14 @@ void synchronize_sched_expedited(void)
76748 synchronize_sched_expedited_cpu_stop,
76749 NULL) == -EAGAIN) {
76750 put_online_cpus();
76751 - atomic_long_inc(&rsp->expedited_tryfail);
76752 + atomic_long_inc_unchecked(&rsp->expedited_tryfail);
76753
76754 /* Check to see if someone else did our work for us. */
76755 s = atomic_long_read(&rsp->expedited_done);
76756 if (ULONG_CMP_GE((ulong)s, (ulong)firstsnap)) {
76757 /* ensure test happens before caller kfree */
76758 smp_mb__before_atomic_inc(); /* ^^^ */
76759 - atomic_long_inc(&rsp->expedited_workdone1);
76760 + atomic_long_inc_unchecked(&rsp->expedited_workdone1);
76761 return;
76762 }
76763
76764 @@ -2404,7 +2404,7 @@ void synchronize_sched_expedited(void)
76765 udelay(trycount * num_online_cpus());
76766 } else {
76767 wait_rcu_gp(call_rcu_sched);
76768 - atomic_long_inc(&rsp->expedited_normal);
76769 + atomic_long_inc_unchecked(&rsp->expedited_normal);
76770 return;
76771 }
76772
76773 @@ -2413,7 +2413,7 @@ void synchronize_sched_expedited(void)
76774 if (ULONG_CMP_GE((ulong)s, (ulong)firstsnap)) {
76775 /* ensure test happens before caller kfree */
76776 smp_mb__before_atomic_inc(); /* ^^^ */
76777 - atomic_long_inc(&rsp->expedited_workdone2);
76778 + atomic_long_inc_unchecked(&rsp->expedited_workdone2);
76779 return;
76780 }
76781
76782 @@ -2425,10 +2425,10 @@ void synchronize_sched_expedited(void)
76783 * period works for us.
76784 */
76785 get_online_cpus();
76786 - snap = atomic_long_read(&rsp->expedited_start);
76787 + snap = atomic_long_read_unchecked(&rsp->expedited_start);
76788 smp_mb(); /* ensure read is before try_stop_cpus(). */
76789 }
76790 - atomic_long_inc(&rsp->expedited_stoppedcpus);
76791 + atomic_long_inc_unchecked(&rsp->expedited_stoppedcpus);
76792
76793 /*
76794 * Everyone up to our most recent fetch is covered by our grace
76795 @@ -2437,16 +2437,16 @@ void synchronize_sched_expedited(void)
76796 * than we did already did their update.
76797 */
76798 do {
76799 - atomic_long_inc(&rsp->expedited_done_tries);
76800 + atomic_long_inc_unchecked(&rsp->expedited_done_tries);
76801 s = atomic_long_read(&rsp->expedited_done);
76802 if (ULONG_CMP_GE((ulong)s, (ulong)snap)) {
76803 /* ensure test happens before caller kfree */
76804 smp_mb__before_atomic_inc(); /* ^^^ */
76805 - atomic_long_inc(&rsp->expedited_done_lost);
76806 + atomic_long_inc_unchecked(&rsp->expedited_done_lost);
76807 break;
76808 }
76809 } while (atomic_long_cmpxchg(&rsp->expedited_done, s, snap) != s);
76810 - atomic_long_inc(&rsp->expedited_done_exit);
76811 + atomic_long_inc_unchecked(&rsp->expedited_done_exit);
76812
76813 put_online_cpus();
76814 }
76815 @@ -2620,7 +2620,7 @@ static void _rcu_barrier(struct rcu_state *rsp)
76816 * ACCESS_ONCE() to prevent the compiler from speculating
76817 * the increment to precede the early-exit check.
76818 */
76819 - ACCESS_ONCE(rsp->n_barrier_done)++;
76820 + ACCESS_ONCE_RW(rsp->n_barrier_done)++;
76821 WARN_ON_ONCE((rsp->n_barrier_done & 0x1) != 1);
76822 _rcu_barrier_trace(rsp, "Inc1", -1, rsp->n_barrier_done);
76823 smp_mb(); /* Order ->n_barrier_done increment with below mechanism. */
76824 @@ -2670,7 +2670,7 @@ static void _rcu_barrier(struct rcu_state *rsp)
76825
76826 /* Increment ->n_barrier_done to prevent duplicate work. */
76827 smp_mb(); /* Keep increment after above mechanism. */
76828 - ACCESS_ONCE(rsp->n_barrier_done)++;
76829 + ACCESS_ONCE_RW(rsp->n_barrier_done)++;
76830 WARN_ON_ONCE((rsp->n_barrier_done & 0x1) != 0);
76831 _rcu_barrier_trace(rsp, "Inc2", -1, rsp->n_barrier_done);
76832 smp_mb(); /* Keep increment before caller's subsequent code. */
76833 @@ -2715,10 +2715,10 @@ rcu_boot_init_percpu_data(int cpu, struct rcu_state *rsp)
76834 rdp->grpmask = 1UL << (cpu - rdp->mynode->grplo);
76835 init_callback_list(rdp);
76836 rdp->qlen_lazy = 0;
76837 - ACCESS_ONCE(rdp->qlen) = 0;
76838 + ACCESS_ONCE_RW(rdp->qlen) = 0;
76839 rdp->dynticks = &per_cpu(rcu_dynticks, cpu);
76840 WARN_ON_ONCE(rdp->dynticks->dynticks_nesting != DYNTICK_TASK_EXIT_IDLE);
76841 - WARN_ON_ONCE(atomic_read(&rdp->dynticks->dynticks) != 1);
76842 + WARN_ON_ONCE(atomic_read_unchecked(&rdp->dynticks->dynticks) != 1);
76843 #ifdef CONFIG_RCU_USER_QS
76844 WARN_ON_ONCE(rdp->dynticks->in_user);
76845 #endif
76846 @@ -2754,8 +2754,8 @@ rcu_init_percpu_data(int cpu, struct rcu_state *rsp, int preemptible)
76847 rdp->blimit = blimit;
76848 init_callback_list(rdp); /* Re-enable callbacks on this CPU. */
76849 rdp->dynticks->dynticks_nesting = DYNTICK_TASK_EXIT_IDLE;
76850 - atomic_set(&rdp->dynticks->dynticks,
76851 - (atomic_read(&rdp->dynticks->dynticks) & ~0x1) + 1);
76852 + atomic_set_unchecked(&rdp->dynticks->dynticks,
76853 + (atomic_read_unchecked(&rdp->dynticks->dynticks) & ~0x1) + 1);
76854 rcu_prepare_for_idle_init(cpu);
76855 raw_spin_unlock(&rnp->lock); /* irqs remain disabled. */
76856
76857 diff --git a/kernel/rcutree.h b/kernel/rcutree.h
76858 index 4b69291..704c92e 100644
76859 --- a/kernel/rcutree.h
76860 +++ b/kernel/rcutree.h
76861 @@ -86,7 +86,7 @@ struct rcu_dynticks {
76862 long long dynticks_nesting; /* Track irq/process nesting level. */
76863 /* Process level is worth LLONG_MAX/2. */
76864 int dynticks_nmi_nesting; /* Track NMI nesting level. */
76865 - atomic_t dynticks; /* Even value for idle, else odd. */
76866 + atomic_unchecked_t dynticks;/* Even value for idle, else odd. */
76867 #ifdef CONFIG_RCU_FAST_NO_HZ
76868 int dyntick_drain; /* Prepare-for-idle state variable. */
76869 unsigned long dyntick_holdoff;
76870 @@ -423,17 +423,17 @@ struct rcu_state {
76871 /* _rcu_barrier(). */
76872 /* End of fields guarded by barrier_mutex. */
76873
76874 - atomic_long_t expedited_start; /* Starting ticket. */
76875 - atomic_long_t expedited_done; /* Done ticket. */
76876 - atomic_long_t expedited_wrap; /* # near-wrap incidents. */
76877 - atomic_long_t expedited_tryfail; /* # acquisition failures. */
76878 - atomic_long_t expedited_workdone1; /* # done by others #1. */
76879 - atomic_long_t expedited_workdone2; /* # done by others #2. */
76880 - atomic_long_t expedited_normal; /* # fallbacks to normal. */
76881 - atomic_long_t expedited_stoppedcpus; /* # successful stop_cpus. */
76882 - atomic_long_t expedited_done_tries; /* # tries to update _done. */
76883 - atomic_long_t expedited_done_lost; /* # times beaten to _done. */
76884 - atomic_long_t expedited_done_exit; /* # times exited _done loop. */
76885 + atomic_long_unchecked_t expedited_start; /* Starting ticket. */
76886 + atomic_long_t expedited_done; /* Done ticket. */
76887 + atomic_long_unchecked_t expedited_wrap; /* # near-wrap incidents. */
76888 + atomic_long_unchecked_t expedited_tryfail; /* # acquisition failures. */
76889 + atomic_long_unchecked_t expedited_workdone1; /* # done by others #1. */
76890 + atomic_long_unchecked_t expedited_workdone2; /* # done by others #2. */
76891 + atomic_long_unchecked_t expedited_normal; /* # fallbacks to normal. */
76892 + atomic_long_unchecked_t expedited_stoppedcpus; /* # successful stop_cpus. */
76893 + atomic_long_unchecked_t expedited_done_tries; /* # tries to update _done. */
76894 + atomic_long_unchecked_t expedited_done_lost; /* # times beaten to _done. */
76895 + atomic_long_unchecked_t expedited_done_exit; /* # times exited _done loop. */
76896
76897 unsigned long jiffies_force_qs; /* Time at which to invoke */
76898 /* force_quiescent_state(). */
76899 diff --git a/kernel/rcutree_plugin.h b/kernel/rcutree_plugin.h
76900 index c1cc7e1..f62e436 100644
76901 --- a/kernel/rcutree_plugin.h
76902 +++ b/kernel/rcutree_plugin.h
76903 @@ -892,7 +892,7 @@ void synchronize_rcu_expedited(void)
76904
76905 /* Clean up and exit. */
76906 smp_mb(); /* ensure expedited GP seen before counter increment. */
76907 - ACCESS_ONCE(sync_rcu_preempt_exp_count)++;
76908 + ACCESS_ONCE_RW(sync_rcu_preempt_exp_count)++;
76909 unlock_mb_ret:
76910 mutex_unlock(&sync_rcu_preempt_exp_mutex);
76911 mb_ret:
76912 @@ -1440,7 +1440,7 @@ static void rcu_boost_kthread_setaffinity(struct rcu_node *rnp, int outgoingcpu)
76913 free_cpumask_var(cm);
76914 }
76915
76916 -static struct smp_hotplug_thread rcu_cpu_thread_spec = {
76917 +static struct smp_hotplug_thread rcu_cpu_thread_spec __read_only = {
76918 .store = &rcu_cpu_kthread_task,
76919 .thread_should_run = rcu_cpu_kthread_should_run,
76920 .thread_fn = rcu_cpu_kthread,
76921 @@ -2072,7 +2072,7 @@ static void print_cpu_stall_info(struct rcu_state *rsp, int cpu)
76922 print_cpu_stall_fast_no_hz(fast_no_hz, cpu);
76923 printk(KERN_ERR "\t%d: (%lu %s) idle=%03x/%llx/%d %s\n",
76924 cpu, ticks_value, ticks_title,
76925 - atomic_read(&rdtp->dynticks) & 0xfff,
76926 + atomic_read_unchecked(&rdtp->dynticks) & 0xfff,
76927 rdtp->dynticks_nesting, rdtp->dynticks_nmi_nesting,
76928 fast_no_hz);
76929 }
76930 @@ -2192,7 +2192,7 @@ static void __call_rcu_nocb_enqueue(struct rcu_data *rdp,
76931
76932 /* Enqueue the callback on the nocb list and update counts. */
76933 old_rhpp = xchg(&rdp->nocb_tail, rhtp);
76934 - ACCESS_ONCE(*old_rhpp) = rhp;
76935 + ACCESS_ONCE_RW(*old_rhpp) = rhp;
76936 atomic_long_add(rhcount, &rdp->nocb_q_count);
76937 atomic_long_add(rhcount_lazy, &rdp->nocb_q_count_lazy);
76938
76939 @@ -2384,12 +2384,12 @@ static int rcu_nocb_kthread(void *arg)
76940 * Extract queued callbacks, update counts, and wait
76941 * for a grace period to elapse.
76942 */
76943 - ACCESS_ONCE(rdp->nocb_head) = NULL;
76944 + ACCESS_ONCE_RW(rdp->nocb_head) = NULL;
76945 tail = xchg(&rdp->nocb_tail, &rdp->nocb_head);
76946 c = atomic_long_xchg(&rdp->nocb_q_count, 0);
76947 cl = atomic_long_xchg(&rdp->nocb_q_count_lazy, 0);
76948 - ACCESS_ONCE(rdp->nocb_p_count) += c;
76949 - ACCESS_ONCE(rdp->nocb_p_count_lazy) += cl;
76950 + ACCESS_ONCE_RW(rdp->nocb_p_count) += c;
76951 + ACCESS_ONCE_RW(rdp->nocb_p_count_lazy) += cl;
76952 wait_rcu_gp(rdp->rsp->call_remote);
76953
76954 /* Each pass through the following loop invokes a callback. */
76955 @@ -2411,8 +2411,8 @@ static int rcu_nocb_kthread(void *arg)
76956 list = next;
76957 }
76958 trace_rcu_batch_end(rdp->rsp->name, c, !!list, 0, 0, 1);
76959 - ACCESS_ONCE(rdp->nocb_p_count) -= c;
76960 - ACCESS_ONCE(rdp->nocb_p_count_lazy) -= cl;
76961 + ACCESS_ONCE_RW(rdp->nocb_p_count) -= c;
76962 + ACCESS_ONCE_RW(rdp->nocb_p_count_lazy) -= cl;
76963 rdp->n_nocbs_invoked += c;
76964 }
76965 return 0;
76966 @@ -2438,7 +2438,7 @@ static void __init rcu_spawn_nocb_kthreads(struct rcu_state *rsp)
76967 rdp = per_cpu_ptr(rsp->rda, cpu);
76968 t = kthread_run(rcu_nocb_kthread, rdp, "rcuo%d", cpu);
76969 BUG_ON(IS_ERR(t));
76970 - ACCESS_ONCE(rdp->nocb_kthread) = t;
76971 + ACCESS_ONCE_RW(rdp->nocb_kthread) = t;
76972 }
76973 }
76974
76975 diff --git a/kernel/rcutree_trace.c b/kernel/rcutree_trace.c
76976 index 0d095dc..1985b19 100644
76977 --- a/kernel/rcutree_trace.c
76978 +++ b/kernel/rcutree_trace.c
76979 @@ -123,7 +123,7 @@ static void print_one_rcu_data(struct seq_file *m, struct rcu_data *rdp)
76980 ulong2long(rdp->completed), ulong2long(rdp->gpnum),
76981 rdp->passed_quiesce, rdp->qs_pending);
76982 seq_printf(m, " dt=%d/%llx/%d df=%lu",
76983 - atomic_read(&rdp->dynticks->dynticks),
76984 + atomic_read_unchecked(&rdp->dynticks->dynticks),
76985 rdp->dynticks->dynticks_nesting,
76986 rdp->dynticks->dynticks_nmi_nesting,
76987 rdp->dynticks_fqs);
76988 @@ -184,17 +184,17 @@ static int show_rcuexp(struct seq_file *m, void *v)
76989 struct rcu_state *rsp = (struct rcu_state *)m->private;
76990
76991 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",
76992 - atomic_long_read(&rsp->expedited_start),
76993 + atomic_long_read_unchecked(&rsp->expedited_start),
76994 atomic_long_read(&rsp->expedited_done),
76995 - atomic_long_read(&rsp->expedited_wrap),
76996 - atomic_long_read(&rsp->expedited_tryfail),
76997 - atomic_long_read(&rsp->expedited_workdone1),
76998 - atomic_long_read(&rsp->expedited_workdone2),
76999 - atomic_long_read(&rsp->expedited_normal),
77000 - atomic_long_read(&rsp->expedited_stoppedcpus),
77001 - atomic_long_read(&rsp->expedited_done_tries),
77002 - atomic_long_read(&rsp->expedited_done_lost),
77003 - atomic_long_read(&rsp->expedited_done_exit));
77004 + atomic_long_read_unchecked(&rsp->expedited_wrap),
77005 + atomic_long_read_unchecked(&rsp->expedited_tryfail),
77006 + atomic_long_read_unchecked(&rsp->expedited_workdone1),
77007 + atomic_long_read_unchecked(&rsp->expedited_workdone2),
77008 + atomic_long_read_unchecked(&rsp->expedited_normal),
77009 + atomic_long_read_unchecked(&rsp->expedited_stoppedcpus),
77010 + atomic_long_read_unchecked(&rsp->expedited_done_tries),
77011 + atomic_long_read_unchecked(&rsp->expedited_done_lost),
77012 + atomic_long_read_unchecked(&rsp->expedited_done_exit));
77013 return 0;
77014 }
77015
77016 diff --git a/kernel/resource.c b/kernel/resource.c
77017 index 73f35d4..4684fc4 100644
77018 --- a/kernel/resource.c
77019 +++ b/kernel/resource.c
77020 @@ -143,8 +143,18 @@ static const struct file_operations proc_iomem_operations = {
77021
77022 static int __init ioresources_init(void)
77023 {
77024 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
77025 +#ifdef CONFIG_GRKERNSEC_PROC_USER
77026 + proc_create("ioports", S_IRUSR, NULL, &proc_ioports_operations);
77027 + proc_create("iomem", S_IRUSR, NULL, &proc_iomem_operations);
77028 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
77029 + proc_create("ioports", S_IRUSR | S_IRGRP, NULL, &proc_ioports_operations);
77030 + proc_create("iomem", S_IRUSR | S_IRGRP, NULL, &proc_iomem_operations);
77031 +#endif
77032 +#else
77033 proc_create("ioports", 0, NULL, &proc_ioports_operations);
77034 proc_create("iomem", 0, NULL, &proc_iomem_operations);
77035 +#endif
77036 return 0;
77037 }
77038 __initcall(ioresources_init);
77039 diff --git a/kernel/rtmutex-tester.c b/kernel/rtmutex-tester.c
77040 index 98ec494..4241d6d 100644
77041 --- a/kernel/rtmutex-tester.c
77042 +++ b/kernel/rtmutex-tester.c
77043 @@ -20,7 +20,7 @@
77044 #define MAX_RT_TEST_MUTEXES 8
77045
77046 static spinlock_t rttest_lock;
77047 -static atomic_t rttest_event;
77048 +static atomic_unchecked_t rttest_event;
77049
77050 struct test_thread_data {
77051 int opcode;
77052 @@ -61,7 +61,7 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
77053
77054 case RTTEST_LOCKCONT:
77055 td->mutexes[td->opdata] = 1;
77056 - td->event = atomic_add_return(1, &rttest_event);
77057 + td->event = atomic_add_return_unchecked(1, &rttest_event);
77058 return 0;
77059
77060 case RTTEST_RESET:
77061 @@ -74,7 +74,7 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
77062 return 0;
77063
77064 case RTTEST_RESETEVENT:
77065 - atomic_set(&rttest_event, 0);
77066 + atomic_set_unchecked(&rttest_event, 0);
77067 return 0;
77068
77069 default:
77070 @@ -91,9 +91,9 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
77071 return ret;
77072
77073 td->mutexes[id] = 1;
77074 - td->event = atomic_add_return(1, &rttest_event);
77075 + td->event = atomic_add_return_unchecked(1, &rttest_event);
77076 rt_mutex_lock(&mutexes[id]);
77077 - td->event = atomic_add_return(1, &rttest_event);
77078 + td->event = atomic_add_return_unchecked(1, &rttest_event);
77079 td->mutexes[id] = 4;
77080 return 0;
77081
77082 @@ -104,9 +104,9 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
77083 return ret;
77084
77085 td->mutexes[id] = 1;
77086 - td->event = atomic_add_return(1, &rttest_event);
77087 + td->event = atomic_add_return_unchecked(1, &rttest_event);
77088 ret = rt_mutex_lock_interruptible(&mutexes[id], 0);
77089 - td->event = atomic_add_return(1, &rttest_event);
77090 + td->event = atomic_add_return_unchecked(1, &rttest_event);
77091 td->mutexes[id] = ret ? 0 : 4;
77092 return ret ? -EINTR : 0;
77093
77094 @@ -115,9 +115,9 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
77095 if (id < 0 || id >= MAX_RT_TEST_MUTEXES || td->mutexes[id] != 4)
77096 return ret;
77097
77098 - td->event = atomic_add_return(1, &rttest_event);
77099 + td->event = atomic_add_return_unchecked(1, &rttest_event);
77100 rt_mutex_unlock(&mutexes[id]);
77101 - td->event = atomic_add_return(1, &rttest_event);
77102 + td->event = atomic_add_return_unchecked(1, &rttest_event);
77103 td->mutexes[id] = 0;
77104 return 0;
77105
77106 @@ -164,7 +164,7 @@ void schedule_rt_mutex_test(struct rt_mutex *mutex)
77107 break;
77108
77109 td->mutexes[dat] = 2;
77110 - td->event = atomic_add_return(1, &rttest_event);
77111 + td->event = atomic_add_return_unchecked(1, &rttest_event);
77112 break;
77113
77114 default:
77115 @@ -184,7 +184,7 @@ void schedule_rt_mutex_test(struct rt_mutex *mutex)
77116 return;
77117
77118 td->mutexes[dat] = 3;
77119 - td->event = atomic_add_return(1, &rttest_event);
77120 + td->event = atomic_add_return_unchecked(1, &rttest_event);
77121 break;
77122
77123 case RTTEST_LOCKNOWAIT:
77124 @@ -196,7 +196,7 @@ void schedule_rt_mutex_test(struct rt_mutex *mutex)
77125 return;
77126
77127 td->mutexes[dat] = 1;
77128 - td->event = atomic_add_return(1, &rttest_event);
77129 + td->event = atomic_add_return_unchecked(1, &rttest_event);
77130 return;
77131
77132 default:
77133 diff --git a/kernel/sched/auto_group.c b/kernel/sched/auto_group.c
77134 index 0984a21..939f183 100644
77135 --- a/kernel/sched/auto_group.c
77136 +++ b/kernel/sched/auto_group.c
77137 @@ -11,7 +11,7 @@
77138
77139 unsigned int __read_mostly sysctl_sched_autogroup_enabled = 1;
77140 static struct autogroup autogroup_default;
77141 -static atomic_t autogroup_seq_nr;
77142 +static atomic_unchecked_t autogroup_seq_nr;
77143
77144 void __init autogroup_init(struct task_struct *init_task)
77145 {
77146 @@ -78,7 +78,7 @@ static inline struct autogroup *autogroup_create(void)
77147
77148 kref_init(&ag->kref);
77149 init_rwsem(&ag->lock);
77150 - ag->id = atomic_inc_return(&autogroup_seq_nr);
77151 + ag->id = atomic_inc_return_unchecked(&autogroup_seq_nr);
77152 ag->tg = tg;
77153 #ifdef CONFIG_RT_GROUP_SCHED
77154 /*
77155 diff --git a/kernel/sched/core.c b/kernel/sched/core.c
77156 index 26058d0..e315889 100644
77157 --- a/kernel/sched/core.c
77158 +++ b/kernel/sched/core.c
77159 @@ -3367,7 +3367,7 @@ EXPORT_SYMBOL(wait_for_completion_interruptible);
77160 * The return value is -ERESTARTSYS if interrupted, 0 if timed out,
77161 * positive (at least 1, or number of jiffies left till timeout) if completed.
77162 */
77163 -long __sched
77164 +long __sched __intentional_overflow(-1)
77165 wait_for_completion_interruptible_timeout(struct completion *x,
77166 unsigned long timeout)
77167 {
77168 @@ -3384,7 +3384,7 @@ EXPORT_SYMBOL(wait_for_completion_interruptible_timeout);
77169 *
77170 * The return value is -ERESTARTSYS if interrupted, 0 if completed.
77171 */
77172 -int __sched wait_for_completion_killable(struct completion *x)
77173 +int __sched __intentional_overflow(-1) wait_for_completion_killable(struct completion *x)
77174 {
77175 long t = wait_for_common(x, MAX_SCHEDULE_TIMEOUT, TASK_KILLABLE);
77176 if (t == -ERESTARTSYS)
77177 @@ -3405,7 +3405,7 @@ EXPORT_SYMBOL(wait_for_completion_killable);
77178 * The return value is -ERESTARTSYS if interrupted, 0 if timed out,
77179 * positive (at least 1, or number of jiffies left till timeout) if completed.
77180 */
77181 -long __sched
77182 +long __sched __intentional_overflow(-1)
77183 wait_for_completion_killable_timeout(struct completion *x,
77184 unsigned long timeout)
77185 {
77186 @@ -3631,6 +3631,8 @@ int can_nice(const struct task_struct *p, const int nice)
77187 /* convert nice value [19,-20] to rlimit style value [1,40] */
77188 int nice_rlim = 20 - nice;
77189
77190 + gr_learn_resource(p, RLIMIT_NICE, nice_rlim, 1);
77191 +
77192 return (nice_rlim <= task_rlimit(p, RLIMIT_NICE) ||
77193 capable(CAP_SYS_NICE));
77194 }
77195 @@ -3664,7 +3666,8 @@ SYSCALL_DEFINE1(nice, int, increment)
77196 if (nice > 19)
77197 nice = 19;
77198
77199 - if (increment < 0 && !can_nice(current, nice))
77200 + if (increment < 0 && (!can_nice(current, nice) ||
77201 + gr_handle_chroot_nice()))
77202 return -EPERM;
77203
77204 retval = security_task_setnice(current, nice);
77205 @@ -3818,6 +3821,7 @@ recheck:
77206 unsigned long rlim_rtprio =
77207 task_rlimit(p, RLIMIT_RTPRIO);
77208
77209 + gr_learn_resource(p, RLIMIT_RTPRIO, param->sched_priority, 1);
77210 /* can't set/change the rt policy */
77211 if (policy != p->policy && !rlim_rtprio)
77212 return -EPERM;
77213 @@ -4901,7 +4905,7 @@ static void migrate_tasks(unsigned int dead_cpu)
77214
77215 #if defined(CONFIG_SCHED_DEBUG) && defined(CONFIG_SYSCTL)
77216
77217 -static struct ctl_table sd_ctl_dir[] = {
77218 +static ctl_table_no_const sd_ctl_dir[] __read_only = {
77219 {
77220 .procname = "sched_domain",
77221 .mode = 0555,
77222 @@ -4918,17 +4922,17 @@ static struct ctl_table sd_ctl_root[] = {
77223 {}
77224 };
77225
77226 -static struct ctl_table *sd_alloc_ctl_entry(int n)
77227 +static ctl_table_no_const *sd_alloc_ctl_entry(int n)
77228 {
77229 - struct ctl_table *entry =
77230 + ctl_table_no_const *entry =
77231 kcalloc(n, sizeof(struct ctl_table), GFP_KERNEL);
77232
77233 return entry;
77234 }
77235
77236 -static void sd_free_ctl_entry(struct ctl_table **tablep)
77237 +static void sd_free_ctl_entry(ctl_table_no_const *tablep)
77238 {
77239 - struct ctl_table *entry;
77240 + ctl_table_no_const *entry;
77241
77242 /*
77243 * In the intermediate directories, both the child directory and
77244 @@ -4936,22 +4940,25 @@ static void sd_free_ctl_entry(struct ctl_table **tablep)
77245 * will always be set. In the lowest directory the names are
77246 * static strings and all have proc handlers.
77247 */
77248 - for (entry = *tablep; entry->mode; entry++) {
77249 - if (entry->child)
77250 - sd_free_ctl_entry(&entry->child);
77251 + for (entry = tablep; entry->mode; entry++) {
77252 + if (entry->child) {
77253 + sd_free_ctl_entry(entry->child);
77254 + pax_open_kernel();
77255 + entry->child = NULL;
77256 + pax_close_kernel();
77257 + }
77258 if (entry->proc_handler == NULL)
77259 kfree(entry->procname);
77260 }
77261
77262 - kfree(*tablep);
77263 - *tablep = NULL;
77264 + kfree(tablep);
77265 }
77266
77267 static int min_load_idx = 0;
77268 static int max_load_idx = CPU_LOAD_IDX_MAX;
77269
77270 static void
77271 -set_table_entry(struct ctl_table *entry,
77272 +set_table_entry(ctl_table_no_const *entry,
77273 const char *procname, void *data, int maxlen,
77274 umode_t mode, proc_handler *proc_handler,
77275 bool load_idx)
77276 @@ -4971,7 +4978,7 @@ set_table_entry(struct ctl_table *entry,
77277 static struct ctl_table *
77278 sd_alloc_ctl_domain_table(struct sched_domain *sd)
77279 {
77280 - struct ctl_table *table = sd_alloc_ctl_entry(13);
77281 + ctl_table_no_const *table = sd_alloc_ctl_entry(13);
77282
77283 if (table == NULL)
77284 return NULL;
77285 @@ -5006,9 +5013,9 @@ sd_alloc_ctl_domain_table(struct sched_domain *sd)
77286 return table;
77287 }
77288
77289 -static ctl_table *sd_alloc_ctl_cpu_table(int cpu)
77290 +static ctl_table_no_const *sd_alloc_ctl_cpu_table(int cpu)
77291 {
77292 - struct ctl_table *entry, *table;
77293 + ctl_table_no_const *entry, *table;
77294 struct sched_domain *sd;
77295 int domain_num = 0, i;
77296 char buf[32];
77297 @@ -5035,11 +5042,13 @@ static struct ctl_table_header *sd_sysctl_header;
77298 static void register_sched_domain_sysctl(void)
77299 {
77300 int i, cpu_num = num_possible_cpus();
77301 - struct ctl_table *entry = sd_alloc_ctl_entry(cpu_num + 1);
77302 + ctl_table_no_const *entry = sd_alloc_ctl_entry(cpu_num + 1);
77303 char buf[32];
77304
77305 WARN_ON(sd_ctl_dir[0].child);
77306 + pax_open_kernel();
77307 sd_ctl_dir[0].child = entry;
77308 + pax_close_kernel();
77309
77310 if (entry == NULL)
77311 return;
77312 @@ -5062,8 +5071,12 @@ static void unregister_sched_domain_sysctl(void)
77313 if (sd_sysctl_header)
77314 unregister_sysctl_table(sd_sysctl_header);
77315 sd_sysctl_header = NULL;
77316 - if (sd_ctl_dir[0].child)
77317 - sd_free_ctl_entry(&sd_ctl_dir[0].child);
77318 + if (sd_ctl_dir[0].child) {
77319 + sd_free_ctl_entry(sd_ctl_dir[0].child);
77320 + pax_open_kernel();
77321 + sd_ctl_dir[0].child = NULL;
77322 + pax_close_kernel();
77323 + }
77324 }
77325 #else
77326 static void register_sched_domain_sysctl(void)
77327 @@ -5162,7 +5175,7 @@ migration_call(struct notifier_block *nfb, unsigned long action, void *hcpu)
77328 * happens before everything else. This has to be lower priority than
77329 * the notifier in the perf_event subsystem, though.
77330 */
77331 -static struct notifier_block __cpuinitdata migration_notifier = {
77332 +static struct notifier_block migration_notifier = {
77333 .notifier_call = migration_call,
77334 .priority = CPU_PRI_MIGRATION,
77335 };
77336 diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
77337 index 81fa536..6ccf96a 100644
77338 --- a/kernel/sched/fair.c
77339 +++ b/kernel/sched/fair.c
77340 @@ -830,7 +830,7 @@ void task_numa_fault(int node, int pages, bool migrated)
77341
77342 static void reset_ptenuma_scan(struct task_struct *p)
77343 {
77344 - ACCESS_ONCE(p->mm->numa_scan_seq)++;
77345 + ACCESS_ONCE_RW(p->mm->numa_scan_seq)++;
77346 p->mm->numa_scan_offset = 0;
77347 }
77348
77349 @@ -3254,25 +3254,18 @@ find_idlest_cpu(struct sched_group *group, struct task_struct *p, int this_cpu)
77350 */
77351 static int select_idle_sibling(struct task_struct *p, int target)
77352 {
77353 - int cpu = smp_processor_id();
77354 - int prev_cpu = task_cpu(p);
77355 struct sched_domain *sd;
77356 struct sched_group *sg;
77357 - int i;
77358 + int i = task_cpu(p);
77359
77360 - /*
77361 - * If the task is going to be woken-up on this cpu and if it is
77362 - * already idle, then it is the right target.
77363 - */
77364 - if (target == cpu && idle_cpu(cpu))
77365 - return cpu;
77366 + if (idle_cpu(target))
77367 + return target;
77368
77369 /*
77370 - * If the task is going to be woken-up on the cpu where it previously
77371 - * ran and if it is currently idle, then it the right target.
77372 + * If the prevous cpu is cache affine and idle, don't be stupid.
77373 */
77374 - if (target == prev_cpu && idle_cpu(prev_cpu))
77375 - return prev_cpu;
77376 + if (i != target && cpus_share_cache(i, target) && idle_cpu(i))
77377 + return i;
77378
77379 /*
77380 * Otherwise, iterate the domains and find an elegible idle cpu.
77381 @@ -3286,7 +3279,7 @@ static int select_idle_sibling(struct task_struct *p, int target)
77382 goto next;
77383
77384 for_each_cpu(i, sched_group_cpus(sg)) {
77385 - if (!idle_cpu(i))
77386 + if (i == target || !idle_cpu(i))
77387 goto next;
77388 }
77389
77390 @@ -5663,7 +5656,7 @@ static void nohz_idle_balance(int this_cpu, enum cpu_idle_type idle) { }
77391 * run_rebalance_domains is triggered when needed from the scheduler tick.
77392 * Also triggered for nohz idle balancing (with nohz_balancing_kick set).
77393 */
77394 -static void run_rebalance_domains(struct softirq_action *h)
77395 +static void run_rebalance_domains(void)
77396 {
77397 int this_cpu = smp_processor_id();
77398 struct rq *this_rq = cpu_rq(this_cpu);
77399 diff --git a/kernel/signal.c b/kernel/signal.c
77400 index 3d09cf6..8988390 100644
77401 --- a/kernel/signal.c
77402 +++ b/kernel/signal.c
77403 @@ -50,12 +50,12 @@ static struct kmem_cache *sigqueue_cachep;
77404
77405 int print_fatal_signals __read_mostly;
77406
77407 -static void __user *sig_handler(struct task_struct *t, int sig)
77408 +static __sighandler_t sig_handler(struct task_struct *t, int sig)
77409 {
77410 return t->sighand->action[sig - 1].sa.sa_handler;
77411 }
77412
77413 -static int sig_handler_ignored(void __user *handler, int sig)
77414 +static int sig_handler_ignored(__sighandler_t handler, int sig)
77415 {
77416 /* Is it explicitly or implicitly ignored? */
77417 return handler == SIG_IGN ||
77418 @@ -64,7 +64,7 @@ static int sig_handler_ignored(void __user *handler, int sig)
77419
77420 static int sig_task_ignored(struct task_struct *t, int sig, bool force)
77421 {
77422 - void __user *handler;
77423 + __sighandler_t handler;
77424
77425 handler = sig_handler(t, sig);
77426
77427 @@ -368,6 +368,9 @@ __sigqueue_alloc(int sig, struct task_struct *t, gfp_t flags, int override_rlimi
77428 atomic_inc(&user->sigpending);
77429 rcu_read_unlock();
77430
77431 + if (!override_rlimit)
77432 + gr_learn_resource(t, RLIMIT_SIGPENDING, atomic_read(&user->sigpending), 1);
77433 +
77434 if (override_rlimit ||
77435 atomic_read(&user->sigpending) <=
77436 task_rlimit(t, RLIMIT_SIGPENDING)) {
77437 @@ -485,6 +488,9 @@ flush_signal_handlers(struct task_struct *t, int force_default)
77438 if (force_default || ka->sa.sa_handler != SIG_IGN)
77439 ka->sa.sa_handler = SIG_DFL;
77440 ka->sa.sa_flags = 0;
77441 +#ifdef SA_RESTORER
77442 + ka->sa.sa_restorer = NULL;
77443 +#endif
77444 sigemptyset(&ka->sa.sa_mask);
77445 ka++;
77446 }
77447 @@ -492,7 +498,7 @@ flush_signal_handlers(struct task_struct *t, int force_default)
77448
77449 int unhandled_signal(struct task_struct *tsk, int sig)
77450 {
77451 - void __user *handler = tsk->sighand->action[sig-1].sa.sa_handler;
77452 + __sighandler_t handler = tsk->sighand->action[sig-1].sa.sa_handler;
77453 if (is_global_init(tsk))
77454 return 1;
77455 if (handler != SIG_IGN && handler != SIG_DFL)
77456 @@ -812,6 +818,13 @@ static int check_kill_permission(int sig, struct siginfo *info,
77457 }
77458 }
77459
77460 + /* allow glibc communication via tgkill to other threads in our
77461 + thread group */
77462 + if ((info == SEND_SIG_NOINFO || info->si_code != SI_TKILL ||
77463 + sig != (SIGRTMIN+1) || task_tgid_vnr(t) != info->si_pid)
77464 + && gr_handle_signal(t, sig))
77465 + return -EPERM;
77466 +
77467 return security_task_kill(t, info, sig, 0);
77468 }
77469
77470 @@ -1194,7 +1207,7 @@ __group_send_sig_info(int sig, struct siginfo *info, struct task_struct *p)
77471 return send_signal(sig, info, p, 1);
77472 }
77473
77474 -static int
77475 +int
77476 specific_send_sig_info(int sig, struct siginfo *info, struct task_struct *t)
77477 {
77478 return send_signal(sig, info, t, 0);
77479 @@ -1231,6 +1244,7 @@ force_sig_info(int sig, struct siginfo *info, struct task_struct *t)
77480 unsigned long int flags;
77481 int ret, blocked, ignored;
77482 struct k_sigaction *action;
77483 + int is_unhandled = 0;
77484
77485 spin_lock_irqsave(&t->sighand->siglock, flags);
77486 action = &t->sighand->action[sig-1];
77487 @@ -1245,9 +1259,18 @@ force_sig_info(int sig, struct siginfo *info, struct task_struct *t)
77488 }
77489 if (action->sa.sa_handler == SIG_DFL)
77490 t->signal->flags &= ~SIGNAL_UNKILLABLE;
77491 + if (action->sa.sa_handler == SIG_IGN || action->sa.sa_handler == SIG_DFL)
77492 + is_unhandled = 1;
77493 ret = specific_send_sig_info(sig, info, t);
77494 spin_unlock_irqrestore(&t->sighand->siglock, flags);
77495
77496 + /* only deal with unhandled signals, java etc trigger SIGSEGV during
77497 + normal operation */
77498 + if (is_unhandled) {
77499 + gr_log_signal(sig, !is_si_special(info) ? info->si_addr : NULL, t);
77500 + gr_handle_crash(t, sig);
77501 + }
77502 +
77503 return ret;
77504 }
77505
77506 @@ -1314,8 +1337,11 @@ int group_send_sig_info(int sig, struct siginfo *info, struct task_struct *p)
77507 ret = check_kill_permission(sig, info, p);
77508 rcu_read_unlock();
77509
77510 - if (!ret && sig)
77511 + if (!ret && sig) {
77512 ret = do_send_sig_info(sig, info, p, true);
77513 + if (!ret)
77514 + gr_log_signal(sig, !is_si_special(info) ? info->si_addr : NULL, p);
77515 + }
77516
77517 return ret;
77518 }
77519 @@ -2852,7 +2878,15 @@ do_send_specific(pid_t tgid, pid_t pid, int sig, struct siginfo *info)
77520 int error = -ESRCH;
77521
77522 rcu_read_lock();
77523 - p = find_task_by_vpid(pid);
77524 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
77525 + /* allow glibc communication via tgkill to other threads in our
77526 + thread group */
77527 + if (grsec_enable_chroot_findtask && info->si_code == SI_TKILL &&
77528 + sig == (SIGRTMIN+1) && tgid == info->si_pid)
77529 + p = find_task_by_vpid_unrestricted(pid);
77530 + else
77531 +#endif
77532 + p = find_task_by_vpid(pid);
77533 if (p && (tgid <= 0 || task_tgid_vnr(p) == tgid)) {
77534 error = check_kill_permission(sig, info, p);
77535 /*
77536 @@ -3135,8 +3169,8 @@ COMPAT_SYSCALL_DEFINE2(sigaltstack,
77537 }
77538 seg = get_fs();
77539 set_fs(KERNEL_DS);
77540 - ret = do_sigaltstack((stack_t __force __user *) (uss_ptr ? &uss : NULL),
77541 - (stack_t __force __user *) &uoss,
77542 + ret = do_sigaltstack((stack_t __force_user *) (uss_ptr ? &uss : NULL),
77543 + (stack_t __force_user *) &uoss,
77544 compat_user_stack_pointer());
77545 set_fs(seg);
77546 if (ret >= 0 && uoss_ptr) {
77547 diff --git a/kernel/smp.c b/kernel/smp.c
77548 index 69f38bd..77bbf12 100644
77549 --- a/kernel/smp.c
77550 +++ b/kernel/smp.c
77551 @@ -77,7 +77,7 @@ hotplug_cfd(struct notifier_block *nfb, unsigned long action, void *hcpu)
77552 return NOTIFY_OK;
77553 }
77554
77555 -static struct notifier_block __cpuinitdata hotplug_cfd_notifier = {
77556 +static struct notifier_block hotplug_cfd_notifier = {
77557 .notifier_call = hotplug_cfd,
77558 };
77559
77560 diff --git a/kernel/smpboot.c b/kernel/smpboot.c
77561 index d6c5fc0..530560c 100644
77562 --- a/kernel/smpboot.c
77563 +++ b/kernel/smpboot.c
77564 @@ -275,7 +275,7 @@ int smpboot_register_percpu_thread(struct smp_hotplug_thread *plug_thread)
77565 }
77566 smpboot_unpark_thread(plug_thread, cpu);
77567 }
77568 - list_add(&plug_thread->list, &hotplug_threads);
77569 + pax_list_add(&plug_thread->list, &hotplug_threads);
77570 out:
77571 mutex_unlock(&smpboot_threads_lock);
77572 return ret;
77573 @@ -292,7 +292,7 @@ void smpboot_unregister_percpu_thread(struct smp_hotplug_thread *plug_thread)
77574 {
77575 get_online_cpus();
77576 mutex_lock(&smpboot_threads_lock);
77577 - list_del(&plug_thread->list);
77578 + pax_list_del(&plug_thread->list);
77579 smpboot_destroy_threads(plug_thread);
77580 mutex_unlock(&smpboot_threads_lock);
77581 put_online_cpus();
77582 diff --git a/kernel/softirq.c b/kernel/softirq.c
77583 index ed567ba..e71dabf 100644
77584 --- a/kernel/softirq.c
77585 +++ b/kernel/softirq.c
77586 @@ -53,11 +53,11 @@ irq_cpustat_t irq_stat[NR_CPUS] ____cacheline_aligned;
77587 EXPORT_SYMBOL(irq_stat);
77588 #endif
77589
77590 -static struct softirq_action softirq_vec[NR_SOFTIRQS] __cacheline_aligned_in_smp;
77591 +static struct softirq_action softirq_vec[NR_SOFTIRQS] __read_only __aligned(PAGE_SIZE);
77592
77593 DEFINE_PER_CPU(struct task_struct *, ksoftirqd);
77594
77595 -char *softirq_to_name[NR_SOFTIRQS] = {
77596 +const char * const softirq_to_name[NR_SOFTIRQS] = {
77597 "HI", "TIMER", "NET_TX", "NET_RX", "BLOCK", "BLOCK_IOPOLL",
77598 "TASKLET", "SCHED", "HRTIMER", "RCU"
77599 };
77600 @@ -244,7 +244,7 @@ restart:
77601 kstat_incr_softirqs_this_cpu(vec_nr);
77602
77603 trace_softirq_entry(vec_nr);
77604 - h->action(h);
77605 + h->action();
77606 trace_softirq_exit(vec_nr);
77607 if (unlikely(prev_count != preempt_count())) {
77608 printk(KERN_ERR "huh, entered softirq %u %s %p"
77609 @@ -391,7 +391,7 @@ void __raise_softirq_irqoff(unsigned int nr)
77610 or_softirq_pending(1UL << nr);
77611 }
77612
77613 -void open_softirq(int nr, void (*action)(struct softirq_action *))
77614 +void __init open_softirq(int nr, void (*action)(void))
77615 {
77616 softirq_vec[nr].action = action;
77617 }
77618 @@ -447,7 +447,7 @@ void __tasklet_hi_schedule_first(struct tasklet_struct *t)
77619
77620 EXPORT_SYMBOL(__tasklet_hi_schedule_first);
77621
77622 -static void tasklet_action(struct softirq_action *a)
77623 +static void tasklet_action(void)
77624 {
77625 struct tasklet_struct *list;
77626
77627 @@ -482,7 +482,7 @@ static void tasklet_action(struct softirq_action *a)
77628 }
77629 }
77630
77631 -static void tasklet_hi_action(struct softirq_action *a)
77632 +static void tasklet_hi_action(void)
77633 {
77634 struct tasklet_struct *list;
77635
77636 @@ -718,7 +718,7 @@ static int __cpuinit remote_softirq_cpu_notify(struct notifier_block *self,
77637 return NOTIFY_OK;
77638 }
77639
77640 -static struct notifier_block __cpuinitdata remote_softirq_cpu_notifier = {
77641 +static struct notifier_block remote_softirq_cpu_notifier = {
77642 .notifier_call = remote_softirq_cpu_notify,
77643 };
77644
77645 @@ -835,11 +835,11 @@ static int __cpuinit cpu_callback(struct notifier_block *nfb,
77646 return NOTIFY_OK;
77647 }
77648
77649 -static struct notifier_block __cpuinitdata cpu_nfb = {
77650 +static struct notifier_block cpu_nfb = {
77651 .notifier_call = cpu_callback
77652 };
77653
77654 -static struct smp_hotplug_thread softirq_threads = {
77655 +static struct smp_hotplug_thread softirq_threads __read_only = {
77656 .store = &ksoftirqd,
77657 .thread_should_run = ksoftirqd_should_run,
77658 .thread_fn = run_ksoftirqd,
77659 diff --git a/kernel/srcu.c b/kernel/srcu.c
77660 index 2b85982..d52ab26 100644
77661 --- a/kernel/srcu.c
77662 +++ b/kernel/srcu.c
77663 @@ -305,9 +305,9 @@ int __srcu_read_lock(struct srcu_struct *sp)
77664 preempt_disable();
77665 idx = rcu_dereference_index_check(sp->completed,
77666 rcu_read_lock_sched_held()) & 0x1;
77667 - ACCESS_ONCE(this_cpu_ptr(sp->per_cpu_ref)->c[idx]) += 1;
77668 + ACCESS_ONCE_RW(this_cpu_ptr(sp->per_cpu_ref)->c[idx]) += 1;
77669 smp_mb(); /* B */ /* Avoid leaking the critical section. */
77670 - ACCESS_ONCE(this_cpu_ptr(sp->per_cpu_ref)->seq[idx]) += 1;
77671 + ACCESS_ONCE_RW(this_cpu_ptr(sp->per_cpu_ref)->seq[idx]) += 1;
77672 preempt_enable();
77673 return idx;
77674 }
77675 @@ -323,7 +323,7 @@ void __srcu_read_unlock(struct srcu_struct *sp, int idx)
77676 {
77677 preempt_disable();
77678 smp_mb(); /* C */ /* Avoid leaking the critical section. */
77679 - ACCESS_ONCE(this_cpu_ptr(sp->per_cpu_ref)->c[idx]) -= 1;
77680 + ACCESS_ONCE_RW(this_cpu_ptr(sp->per_cpu_ref)->c[idx]) -= 1;
77681 preempt_enable();
77682 }
77683 EXPORT_SYMBOL_GPL(__srcu_read_unlock);
77684 diff --git a/kernel/stop_machine.c b/kernel/stop_machine.c
77685 index 2f194e9..2c05ea9 100644
77686 --- a/kernel/stop_machine.c
77687 +++ b/kernel/stop_machine.c
77688 @@ -362,7 +362,7 @@ static int __cpuinit cpu_stop_cpu_callback(struct notifier_block *nfb,
77689 * cpu notifiers. It currently shares the same priority as sched
77690 * migration_notifier.
77691 */
77692 -static struct notifier_block __cpuinitdata cpu_stop_cpu_notifier = {
77693 +static struct notifier_block cpu_stop_cpu_notifier = {
77694 .notifier_call = cpu_stop_cpu_callback,
77695 .priority = 10,
77696 };
77697 diff --git a/kernel/sys.c b/kernel/sys.c
77698 index 265b376..4e42ef5 100644
77699 --- a/kernel/sys.c
77700 +++ b/kernel/sys.c
77701 @@ -157,6 +157,12 @@ static int set_one_prio(struct task_struct *p, int niceval, int error)
77702 error = -EACCES;
77703 goto out;
77704 }
77705 +
77706 + if (gr_handle_chroot_setpriority(p, niceval)) {
77707 + error = -EACCES;
77708 + goto out;
77709 + }
77710 +
77711 no_nice = security_task_setnice(p, niceval);
77712 if (no_nice) {
77713 error = no_nice;
77714 @@ -595,6 +601,9 @@ SYSCALL_DEFINE2(setregid, gid_t, rgid, gid_t, egid)
77715 goto error;
77716 }
77717
77718 + if (gr_check_group_change(new->gid, new->egid, INVALID_GID))
77719 + goto error;
77720 +
77721 if (rgid != (gid_t) -1 ||
77722 (egid != (gid_t) -1 && !gid_eq(kegid, old->gid)))
77723 new->sgid = new->egid;
77724 @@ -630,6 +639,10 @@ SYSCALL_DEFINE1(setgid, gid_t, gid)
77725 old = current_cred();
77726
77727 retval = -EPERM;
77728 +
77729 + if (gr_check_group_change(kgid, kgid, kgid))
77730 + goto error;
77731 +
77732 if (nsown_capable(CAP_SETGID))
77733 new->gid = new->egid = new->sgid = new->fsgid = kgid;
77734 else if (gid_eq(kgid, old->gid) || gid_eq(kgid, old->sgid))
77735 @@ -647,7 +660,7 @@ error:
77736 /*
77737 * change the user struct in a credentials set to match the new UID
77738 */
77739 -static int set_user(struct cred *new)
77740 +int set_user(struct cred *new)
77741 {
77742 struct user_struct *new_user;
77743
77744 @@ -727,6 +740,9 @@ SYSCALL_DEFINE2(setreuid, uid_t, ruid, uid_t, euid)
77745 goto error;
77746 }
77747
77748 + if (gr_check_user_change(new->uid, new->euid, INVALID_UID))
77749 + goto error;
77750 +
77751 if (!uid_eq(new->uid, old->uid)) {
77752 retval = set_user(new);
77753 if (retval < 0)
77754 @@ -777,6 +793,12 @@ SYSCALL_DEFINE1(setuid, uid_t, uid)
77755 old = current_cred();
77756
77757 retval = -EPERM;
77758 +
77759 + if (gr_check_crash_uid(kuid))
77760 + goto error;
77761 + if (gr_check_user_change(kuid, kuid, kuid))
77762 + goto error;
77763 +
77764 if (nsown_capable(CAP_SETUID)) {
77765 new->suid = new->uid = kuid;
77766 if (!uid_eq(kuid, old->uid)) {
77767 @@ -846,6 +868,9 @@ SYSCALL_DEFINE3(setresuid, uid_t, ruid, uid_t, euid, uid_t, suid)
77768 goto error;
77769 }
77770
77771 + if (gr_check_user_change(kruid, keuid, INVALID_UID))
77772 + goto error;
77773 +
77774 if (ruid != (uid_t) -1) {
77775 new->uid = kruid;
77776 if (!uid_eq(kruid, old->uid)) {
77777 @@ -928,6 +953,9 @@ SYSCALL_DEFINE3(setresgid, gid_t, rgid, gid_t, egid, gid_t, sgid)
77778 goto error;
77779 }
77780
77781 + if (gr_check_group_change(krgid, kegid, INVALID_GID))
77782 + goto error;
77783 +
77784 if (rgid != (gid_t) -1)
77785 new->gid = krgid;
77786 if (egid != (gid_t) -1)
77787 @@ -981,6 +1009,9 @@ SYSCALL_DEFINE1(setfsuid, uid_t, uid)
77788 if (!uid_valid(kuid))
77789 return old_fsuid;
77790
77791 + if (gr_check_user_change(INVALID_UID, INVALID_UID, kuid))
77792 + goto error;
77793 +
77794 new = prepare_creds();
77795 if (!new)
77796 return old_fsuid;
77797 @@ -995,6 +1026,7 @@ SYSCALL_DEFINE1(setfsuid, uid_t, uid)
77798 }
77799 }
77800
77801 +error:
77802 abort_creds(new);
77803 return old_fsuid;
77804
77805 @@ -1027,12 +1059,16 @@ SYSCALL_DEFINE1(setfsgid, gid_t, gid)
77806 if (gid_eq(kgid, old->gid) || gid_eq(kgid, old->egid) ||
77807 gid_eq(kgid, old->sgid) || gid_eq(kgid, old->fsgid) ||
77808 nsown_capable(CAP_SETGID)) {
77809 + if (gr_check_group_change(INVALID_GID, INVALID_GID, kgid))
77810 + goto error;
77811 +
77812 if (!gid_eq(kgid, old->fsgid)) {
77813 new->fsgid = kgid;
77814 goto change_okay;
77815 }
77816 }
77817
77818 +error:
77819 abort_creds(new);
77820 return old_fsgid;
77821
77822 @@ -1340,19 +1376,19 @@ SYSCALL_DEFINE1(olduname, struct oldold_utsname __user *, name)
77823 return -EFAULT;
77824
77825 down_read(&uts_sem);
77826 - error = __copy_to_user(&name->sysname, &utsname()->sysname,
77827 + error = __copy_to_user(name->sysname, &utsname()->sysname,
77828 __OLD_UTS_LEN);
77829 error |= __put_user(0, name->sysname + __OLD_UTS_LEN);
77830 - error |= __copy_to_user(&name->nodename, &utsname()->nodename,
77831 + error |= __copy_to_user(name->nodename, &utsname()->nodename,
77832 __OLD_UTS_LEN);
77833 error |= __put_user(0, name->nodename + __OLD_UTS_LEN);
77834 - error |= __copy_to_user(&name->release, &utsname()->release,
77835 + error |= __copy_to_user(name->release, &utsname()->release,
77836 __OLD_UTS_LEN);
77837 error |= __put_user(0, name->release + __OLD_UTS_LEN);
77838 - error |= __copy_to_user(&name->version, &utsname()->version,
77839 + error |= __copy_to_user(name->version, &utsname()->version,
77840 __OLD_UTS_LEN);
77841 error |= __put_user(0, name->version + __OLD_UTS_LEN);
77842 - error |= __copy_to_user(&name->machine, &utsname()->machine,
77843 + error |= __copy_to_user(name->machine, &utsname()->machine,
77844 __OLD_UTS_LEN);
77845 error |= __put_user(0, name->machine + __OLD_UTS_LEN);
77846 up_read(&uts_sem);
77847 @@ -2026,7 +2062,7 @@ SYSCALL_DEFINE5(prctl, int, option, unsigned long, arg2, unsigned long, arg3,
77848 error = get_dumpable(me->mm);
77849 break;
77850 case PR_SET_DUMPABLE:
77851 - if (arg2 < 0 || arg2 > 1) {
77852 + if (arg2 > 1) {
77853 error = -EINVAL;
77854 break;
77855 }
77856 diff --git a/kernel/sysctl.c b/kernel/sysctl.c
77857 index c88878d..e4fa5d1 100644
77858 --- a/kernel/sysctl.c
77859 +++ b/kernel/sysctl.c
77860 @@ -92,7 +92,6 @@
77861
77862
77863 #if defined(CONFIG_SYSCTL)
77864 -
77865 /* External variables not in a header file. */
77866 extern int sysctl_overcommit_memory;
77867 extern int sysctl_overcommit_ratio;
77868 @@ -172,10 +171,8 @@ static int proc_taint(struct ctl_table *table, int write,
77869 void __user *buffer, size_t *lenp, loff_t *ppos);
77870 #endif
77871
77872 -#ifdef CONFIG_PRINTK
77873 static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
77874 void __user *buffer, size_t *lenp, loff_t *ppos);
77875 -#endif
77876
77877 static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write,
77878 void __user *buffer, size_t *lenp, loff_t *ppos);
77879 @@ -206,6 +203,8 @@ static int sysrq_sysctl_handler(ctl_table *table, int write,
77880
77881 #endif
77882
77883 +extern struct ctl_table grsecurity_table[];
77884 +
77885 static struct ctl_table kern_table[];
77886 static struct ctl_table vm_table[];
77887 static struct ctl_table fs_table[];
77888 @@ -220,6 +219,20 @@ extern struct ctl_table epoll_table[];
77889 int sysctl_legacy_va_layout;
77890 #endif
77891
77892 +#ifdef CONFIG_PAX_SOFTMODE
77893 +static ctl_table pax_table[] = {
77894 + {
77895 + .procname = "softmode",
77896 + .data = &pax_softmode,
77897 + .maxlen = sizeof(unsigned int),
77898 + .mode = 0600,
77899 + .proc_handler = &proc_dointvec,
77900 + },
77901 +
77902 + { }
77903 +};
77904 +#endif
77905 +
77906 /* The default sysctl tables: */
77907
77908 static struct ctl_table sysctl_base_table[] = {
77909 @@ -268,6 +281,22 @@ static int max_extfrag_threshold = 1000;
77910 #endif
77911
77912 static struct ctl_table kern_table[] = {
77913 +#if defined(CONFIG_GRKERNSEC_SYSCTL) || defined(CONFIG_GRKERNSEC_ROFS)
77914 + {
77915 + .procname = "grsecurity",
77916 + .mode = 0500,
77917 + .child = grsecurity_table,
77918 + },
77919 +#endif
77920 +
77921 +#ifdef CONFIG_PAX_SOFTMODE
77922 + {
77923 + .procname = "pax",
77924 + .mode = 0500,
77925 + .child = pax_table,
77926 + },
77927 +#endif
77928 +
77929 {
77930 .procname = "sched_child_runs_first",
77931 .data = &sysctl_sched_child_runs_first,
77932 @@ -593,7 +622,7 @@ static struct ctl_table kern_table[] = {
77933 .data = &modprobe_path,
77934 .maxlen = KMOD_PATH_LEN,
77935 .mode = 0644,
77936 - .proc_handler = proc_dostring,
77937 + .proc_handler = proc_dostring_modpriv,
77938 },
77939 {
77940 .procname = "modules_disabled",
77941 @@ -760,16 +789,20 @@ static struct ctl_table kern_table[] = {
77942 .extra1 = &zero,
77943 .extra2 = &one,
77944 },
77945 +#endif
77946 {
77947 .procname = "kptr_restrict",
77948 .data = &kptr_restrict,
77949 .maxlen = sizeof(int),
77950 .mode = 0644,
77951 .proc_handler = proc_dointvec_minmax_sysadmin,
77952 +#ifdef CONFIG_GRKERNSEC_HIDESYM
77953 + .extra1 = &two,
77954 +#else
77955 .extra1 = &zero,
77956 +#endif
77957 .extra2 = &two,
77958 },
77959 -#endif
77960 {
77961 .procname = "ngroups_max",
77962 .data = &ngroups_max,
77963 @@ -1266,6 +1299,13 @@ static struct ctl_table vm_table[] = {
77964 .proc_handler = proc_dointvec_minmax,
77965 .extra1 = &zero,
77966 },
77967 + {
77968 + .procname = "heap_stack_gap",
77969 + .data = &sysctl_heap_stack_gap,
77970 + .maxlen = sizeof(sysctl_heap_stack_gap),
77971 + .mode = 0644,
77972 + .proc_handler = proc_doulongvec_minmax,
77973 + },
77974 #else
77975 {
77976 .procname = "nr_trim_pages",
77977 @@ -1716,6 +1756,16 @@ int proc_dostring(struct ctl_table *table, int write,
77978 buffer, lenp, ppos);
77979 }
77980
77981 +int proc_dostring_modpriv(struct ctl_table *table, int write,
77982 + void __user *buffer, size_t *lenp, loff_t *ppos)
77983 +{
77984 + if (write && !capable(CAP_SYS_MODULE))
77985 + return -EPERM;
77986 +
77987 + return _proc_do_string(table->data, table->maxlen, write,
77988 + buffer, lenp, ppos);
77989 +}
77990 +
77991 static size_t proc_skip_spaces(char **buf)
77992 {
77993 size_t ret;
77994 @@ -1821,6 +1871,8 @@ static int proc_put_long(void __user **buf, size_t *size, unsigned long val,
77995 len = strlen(tmp);
77996 if (len > *size)
77997 len = *size;
77998 + if (len > sizeof(tmp))
77999 + len = sizeof(tmp);
78000 if (copy_to_user(*buf, tmp, len))
78001 return -EFAULT;
78002 *size -= len;
78003 @@ -1985,7 +2037,7 @@ int proc_dointvec(struct ctl_table *table, int write,
78004 static int proc_taint(struct ctl_table *table, int write,
78005 void __user *buffer, size_t *lenp, loff_t *ppos)
78006 {
78007 - struct ctl_table t;
78008 + ctl_table_no_const t;
78009 unsigned long tmptaint = get_taint();
78010 int err;
78011
78012 @@ -2013,7 +2065,6 @@ static int proc_taint(struct ctl_table *table, int write,
78013 return err;
78014 }
78015
78016 -#ifdef CONFIG_PRINTK
78017 static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
78018 void __user *buffer, size_t *lenp, loff_t *ppos)
78019 {
78020 @@ -2022,7 +2073,6 @@ static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
78021
78022 return proc_dointvec_minmax(table, write, buffer, lenp, ppos);
78023 }
78024 -#endif
78025
78026 struct do_proc_dointvec_minmax_conv_param {
78027 int *min;
78028 @@ -2169,8 +2219,11 @@ static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int
78029 *i = val;
78030 } else {
78031 val = convdiv * (*i) / convmul;
78032 - if (!first)
78033 + if (!first) {
78034 err = proc_put_char(&buffer, &left, '\t');
78035 + if (err)
78036 + break;
78037 + }
78038 err = proc_put_long(&buffer, &left, val, false);
78039 if (err)
78040 break;
78041 @@ -2562,6 +2615,12 @@ int proc_dostring(struct ctl_table *table, int write,
78042 return -ENOSYS;
78043 }
78044
78045 +int proc_dostring_modpriv(struct ctl_table *table, int write,
78046 + void __user *buffer, size_t *lenp, loff_t *ppos)
78047 +{
78048 + return -ENOSYS;
78049 +}
78050 +
78051 int proc_dointvec(struct ctl_table *table, int write,
78052 void __user *buffer, size_t *lenp, loff_t *ppos)
78053 {
78054 @@ -2618,5 +2677,6 @@ EXPORT_SYMBOL(proc_dointvec_minmax);
78055 EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
78056 EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
78057 EXPORT_SYMBOL(proc_dostring);
78058 +EXPORT_SYMBOL(proc_dostring_modpriv);
78059 EXPORT_SYMBOL(proc_doulongvec_minmax);
78060 EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);
78061 diff --git a/kernel/sysctl_binary.c b/kernel/sysctl_binary.c
78062 index 0ddf3a0..a199f50 100644
78063 --- a/kernel/sysctl_binary.c
78064 +++ b/kernel/sysctl_binary.c
78065 @@ -989,7 +989,7 @@ static ssize_t bin_intvec(struct file *file,
78066 int i;
78067
78068 set_fs(KERNEL_DS);
78069 - result = vfs_read(file, buffer, BUFSZ - 1, &pos);
78070 + result = vfs_read(file, (char __force_user *)buffer, BUFSZ - 1, &pos);
78071 set_fs(old_fs);
78072 if (result < 0)
78073 goto out_kfree;
78074 @@ -1034,7 +1034,7 @@ static ssize_t bin_intvec(struct file *file,
78075 }
78076
78077 set_fs(KERNEL_DS);
78078 - result = vfs_write(file, buffer, str - buffer, &pos);
78079 + result = vfs_write(file, (const char __force_user *)buffer, str - buffer, &pos);
78080 set_fs(old_fs);
78081 if (result < 0)
78082 goto out_kfree;
78083 @@ -1067,7 +1067,7 @@ static ssize_t bin_ulongvec(struct file *file,
78084 int i;
78085
78086 set_fs(KERNEL_DS);
78087 - result = vfs_read(file, buffer, BUFSZ - 1, &pos);
78088 + result = vfs_read(file, (char __force_user *)buffer, BUFSZ - 1, &pos);
78089 set_fs(old_fs);
78090 if (result < 0)
78091 goto out_kfree;
78092 @@ -1112,7 +1112,7 @@ static ssize_t bin_ulongvec(struct file *file,
78093 }
78094
78095 set_fs(KERNEL_DS);
78096 - result = vfs_write(file, buffer, str - buffer, &pos);
78097 + result = vfs_write(file, (const char __force_user *)buffer, str - buffer, &pos);
78098 set_fs(old_fs);
78099 if (result < 0)
78100 goto out_kfree;
78101 @@ -1138,7 +1138,7 @@ static ssize_t bin_uuid(struct file *file,
78102 int i;
78103
78104 set_fs(KERNEL_DS);
78105 - result = vfs_read(file, buf, sizeof(buf) - 1, &pos);
78106 + result = vfs_read(file, (char __force_user *)buf, sizeof(buf) - 1, &pos);
78107 set_fs(old_fs);
78108 if (result < 0)
78109 goto out;
78110 @@ -1185,7 +1185,7 @@ static ssize_t bin_dn_node_address(struct file *file,
78111 __le16 dnaddr;
78112
78113 set_fs(KERNEL_DS);
78114 - result = vfs_read(file, buf, sizeof(buf) - 1, &pos);
78115 + result = vfs_read(file, (char __force_user *)buf, sizeof(buf) - 1, &pos);
78116 set_fs(old_fs);
78117 if (result < 0)
78118 goto out;
78119 @@ -1234,7 +1234,7 @@ static ssize_t bin_dn_node_address(struct file *file,
78120 le16_to_cpu(dnaddr) & 0x3ff);
78121
78122 set_fs(KERNEL_DS);
78123 - result = vfs_write(file, buf, len, &pos);
78124 + result = vfs_write(file, (const char __force_user *)buf, len, &pos);
78125 set_fs(old_fs);
78126 if (result < 0)
78127 goto out;
78128 diff --git a/kernel/taskstats.c b/kernel/taskstats.c
78129 index 145bb4d..b2aa969 100644
78130 --- a/kernel/taskstats.c
78131 +++ b/kernel/taskstats.c
78132 @@ -28,9 +28,12 @@
78133 #include <linux/fs.h>
78134 #include <linux/file.h>
78135 #include <linux/pid_namespace.h>
78136 +#include <linux/grsecurity.h>
78137 #include <net/genetlink.h>
78138 #include <linux/atomic.h>
78139
78140 +extern int gr_is_taskstats_denied(int pid);
78141 +
78142 /*
78143 * Maximum length of a cpumask that can be specified in
78144 * the TASKSTATS_CMD_ATTR_REGISTER/DEREGISTER_CPUMASK attribute
78145 @@ -570,6 +573,9 @@ err:
78146
78147 static int taskstats_user_cmd(struct sk_buff *skb, struct genl_info *info)
78148 {
78149 + if (gr_is_taskstats_denied(current->pid))
78150 + return -EACCES;
78151 +
78152 if (info->attrs[TASKSTATS_CMD_ATTR_REGISTER_CPUMASK])
78153 return cmd_attr_register_cpumask(info);
78154 else if (info->attrs[TASKSTATS_CMD_ATTR_DEREGISTER_CPUMASK])
78155 diff --git a/kernel/time.c b/kernel/time.c
78156 index d226c6a..2f0d217 100644
78157 --- a/kernel/time.c
78158 +++ b/kernel/time.c
78159 @@ -163,6 +163,11 @@ int do_sys_settimeofday(const struct timespec *tv, const struct timezone *tz)
78160 return error;
78161
78162 if (tz) {
78163 + /* we log in do_settimeofday called below, so don't log twice
78164 + */
78165 + if (!tv)
78166 + gr_log_timechange();
78167 +
78168 sys_tz = *tz;
78169 update_vsyscall_tz();
78170 if (firsttime) {
78171 @@ -493,7 +498,7 @@ EXPORT_SYMBOL(usecs_to_jiffies);
78172 * The >> (NSEC_JIFFIE_SC - SEC_JIFFIE_SC) converts the scaled nsec
78173 * value to a scaled second value.
78174 */
78175 -unsigned long
78176 +unsigned long __intentional_overflow(-1)
78177 timespec_to_jiffies(const struct timespec *value)
78178 {
78179 unsigned long sec = value->tv_sec;
78180 diff --git a/kernel/time/alarmtimer.c b/kernel/time/alarmtimer.c
78181 index f11d83b..d016d91 100644
78182 --- a/kernel/time/alarmtimer.c
78183 +++ b/kernel/time/alarmtimer.c
78184 @@ -750,7 +750,7 @@ static int __init alarmtimer_init(void)
78185 struct platform_device *pdev;
78186 int error = 0;
78187 int i;
78188 - struct k_clock alarm_clock = {
78189 + static struct k_clock alarm_clock = {
78190 .clock_getres = alarm_clock_getres,
78191 .clock_get = alarm_clock_get,
78192 .timer_create = alarm_timer_create,
78193 diff --git a/kernel/time/tick-broadcast.c b/kernel/time/tick-broadcast.c
78194 index f113755..ec24223 100644
78195 --- a/kernel/time/tick-broadcast.c
78196 +++ b/kernel/time/tick-broadcast.c
78197 @@ -115,7 +115,7 @@ int tick_device_uses_broadcast(struct clock_event_device *dev, int cpu)
78198 * then clear the broadcast bit.
78199 */
78200 if (!(dev->features & CLOCK_EVT_FEAT_C3STOP)) {
78201 - int cpu = smp_processor_id();
78202 + cpu = smp_processor_id();
78203
78204 cpumask_clear_cpu(cpu, tick_get_broadcast_mask());
78205 tick_broadcast_clear_oneshot(cpu);
78206 diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
78207 index cbc6acb..3a77191 100644
78208 --- a/kernel/time/timekeeping.c
78209 +++ b/kernel/time/timekeeping.c
78210 @@ -15,6 +15,7 @@
78211 #include <linux/init.h>
78212 #include <linux/mm.h>
78213 #include <linux/sched.h>
78214 +#include <linux/grsecurity.h>
78215 #include <linux/syscore_ops.h>
78216 #include <linux/clocksource.h>
78217 #include <linux/jiffies.h>
78218 @@ -412,6 +413,8 @@ int do_settimeofday(const struct timespec *tv)
78219 if (!timespec_valid_strict(tv))
78220 return -EINVAL;
78221
78222 + gr_log_timechange();
78223 +
78224 write_seqlock_irqsave(&tk->lock, flags);
78225
78226 timekeeping_forward_now(tk);
78227 diff --git a/kernel/time/timer_list.c b/kernel/time/timer_list.c
78228 index af5a7e9..715611a 100644
78229 --- a/kernel/time/timer_list.c
78230 +++ b/kernel/time/timer_list.c
78231 @@ -38,12 +38,16 @@ DECLARE_PER_CPU(struct hrtimer_cpu_base, hrtimer_bases);
78232
78233 static void print_name_offset(struct seq_file *m, void *sym)
78234 {
78235 +#ifdef CONFIG_GRKERNSEC_HIDESYM
78236 + SEQ_printf(m, "<%p>", NULL);
78237 +#else
78238 char symname[KSYM_NAME_LEN];
78239
78240 if (lookup_symbol_name((unsigned long)sym, symname) < 0)
78241 SEQ_printf(m, "<%pK>", sym);
78242 else
78243 SEQ_printf(m, "%s", symname);
78244 +#endif
78245 }
78246
78247 static void
78248 @@ -112,7 +116,11 @@ next_one:
78249 static void
78250 print_base(struct seq_file *m, struct hrtimer_clock_base *base, u64 now)
78251 {
78252 +#ifdef CONFIG_GRKERNSEC_HIDESYM
78253 + SEQ_printf(m, " .base: %p\n", NULL);
78254 +#else
78255 SEQ_printf(m, " .base: %pK\n", base);
78256 +#endif
78257 SEQ_printf(m, " .index: %d\n",
78258 base->index);
78259 SEQ_printf(m, " .resolution: %Lu nsecs\n",
78260 @@ -293,7 +301,11 @@ static int __init init_timer_list_procfs(void)
78261 {
78262 struct proc_dir_entry *pe;
78263
78264 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
78265 + pe = proc_create("timer_list", 0400, NULL, &timer_list_fops);
78266 +#else
78267 pe = proc_create("timer_list", 0444, NULL, &timer_list_fops);
78268 +#endif
78269 if (!pe)
78270 return -ENOMEM;
78271 return 0;
78272 diff --git a/kernel/time/timer_stats.c b/kernel/time/timer_stats.c
78273 index 0b537f2..40d6c20 100644
78274 --- a/kernel/time/timer_stats.c
78275 +++ b/kernel/time/timer_stats.c
78276 @@ -116,7 +116,7 @@ static ktime_t time_start, time_stop;
78277 static unsigned long nr_entries;
78278 static struct entry entries[MAX_ENTRIES];
78279
78280 -static atomic_t overflow_count;
78281 +static atomic_unchecked_t overflow_count;
78282
78283 /*
78284 * The entries are in a hash-table, for fast lookup:
78285 @@ -140,7 +140,7 @@ static void reset_entries(void)
78286 nr_entries = 0;
78287 memset(entries, 0, sizeof(entries));
78288 memset(tstat_hash_table, 0, sizeof(tstat_hash_table));
78289 - atomic_set(&overflow_count, 0);
78290 + atomic_set_unchecked(&overflow_count, 0);
78291 }
78292
78293 static struct entry *alloc_entry(void)
78294 @@ -261,7 +261,7 @@ void timer_stats_update_stats(void *timer, pid_t pid, void *startf,
78295 if (likely(entry))
78296 entry->count++;
78297 else
78298 - atomic_inc(&overflow_count);
78299 + atomic_inc_unchecked(&overflow_count);
78300
78301 out_unlock:
78302 raw_spin_unlock_irqrestore(lock, flags);
78303 @@ -269,12 +269,16 @@ void timer_stats_update_stats(void *timer, pid_t pid, void *startf,
78304
78305 static void print_name_offset(struct seq_file *m, unsigned long addr)
78306 {
78307 +#ifdef CONFIG_GRKERNSEC_HIDESYM
78308 + seq_printf(m, "<%p>", NULL);
78309 +#else
78310 char symname[KSYM_NAME_LEN];
78311
78312 if (lookup_symbol_name(addr, symname) < 0)
78313 - seq_printf(m, "<%p>", (void *)addr);
78314 + seq_printf(m, "<%pK>", (void *)addr);
78315 else
78316 seq_printf(m, "%s", symname);
78317 +#endif
78318 }
78319
78320 static int tstats_show(struct seq_file *m, void *v)
78321 @@ -300,9 +304,9 @@ static int tstats_show(struct seq_file *m, void *v)
78322
78323 seq_puts(m, "Timer Stats Version: v0.2\n");
78324 seq_printf(m, "Sample period: %ld.%03ld s\n", period.tv_sec, ms);
78325 - if (atomic_read(&overflow_count))
78326 + if (atomic_read_unchecked(&overflow_count))
78327 seq_printf(m, "Overflow: %d entries\n",
78328 - atomic_read(&overflow_count));
78329 + atomic_read_unchecked(&overflow_count));
78330
78331 for (i = 0; i < nr_entries; i++) {
78332 entry = entries + i;
78333 @@ -417,7 +421,11 @@ static int __init init_tstats_procfs(void)
78334 {
78335 struct proc_dir_entry *pe;
78336
78337 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
78338 + pe = proc_create("timer_stats", 0600, NULL, &tstats_fops);
78339 +#else
78340 pe = proc_create("timer_stats", 0644, NULL, &tstats_fops);
78341 +#endif
78342 if (!pe)
78343 return -ENOMEM;
78344 return 0;
78345 diff --git a/kernel/timer.c b/kernel/timer.c
78346 index 367d008..5dee98f 100644
78347 --- a/kernel/timer.c
78348 +++ b/kernel/timer.c
78349 @@ -1363,7 +1363,7 @@ void update_process_times(int user_tick)
78350 /*
78351 * This function runs timers and the timer-tq in bottom half context.
78352 */
78353 -static void run_timer_softirq(struct softirq_action *h)
78354 +static void run_timer_softirq(void)
78355 {
78356 struct tvec_base *base = __this_cpu_read(tvec_bases);
78357
78358 @@ -1481,7 +1481,7 @@ static void process_timeout(unsigned long __data)
78359 *
78360 * In all cases the return value is guaranteed to be non-negative.
78361 */
78362 -signed long __sched schedule_timeout(signed long timeout)
78363 +signed long __sched __intentional_overflow(-1) schedule_timeout(signed long timeout)
78364 {
78365 struct timer_list timer;
78366 unsigned long expire;
78367 @@ -1772,7 +1772,7 @@ static int __cpuinit timer_cpu_notify(struct notifier_block *self,
78368 return NOTIFY_OK;
78369 }
78370
78371 -static struct notifier_block __cpuinitdata timers_nb = {
78372 +static struct notifier_block timers_nb = {
78373 .notifier_call = timer_cpu_notify,
78374 };
78375
78376 diff --git a/kernel/trace/blktrace.c b/kernel/trace/blktrace.c
78377 index c0bd030..62a1927 100644
78378 --- a/kernel/trace/blktrace.c
78379 +++ b/kernel/trace/blktrace.c
78380 @@ -317,7 +317,7 @@ static ssize_t blk_dropped_read(struct file *filp, char __user *buffer,
78381 struct blk_trace *bt = filp->private_data;
78382 char buf[16];
78383
78384 - snprintf(buf, sizeof(buf), "%u\n", atomic_read(&bt->dropped));
78385 + snprintf(buf, sizeof(buf), "%u\n", atomic_read_unchecked(&bt->dropped));
78386
78387 return simple_read_from_buffer(buffer, count, ppos, buf, strlen(buf));
78388 }
78389 @@ -375,7 +375,7 @@ static int blk_subbuf_start_callback(struct rchan_buf *buf, void *subbuf,
78390 return 1;
78391
78392 bt = buf->chan->private_data;
78393 - atomic_inc(&bt->dropped);
78394 + atomic_inc_unchecked(&bt->dropped);
78395 return 0;
78396 }
78397
78398 @@ -476,7 +476,7 @@ int do_blk_trace_setup(struct request_queue *q, char *name, dev_t dev,
78399
78400 bt->dir = dir;
78401 bt->dev = dev;
78402 - atomic_set(&bt->dropped, 0);
78403 + atomic_set_unchecked(&bt->dropped, 0);
78404
78405 ret = -EIO;
78406 bt->dropped_file = debugfs_create_file("dropped", 0444, dir, bt,
78407 diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
78408 index 43defd1..76da436 100644
78409 --- a/kernel/trace/ftrace.c
78410 +++ b/kernel/trace/ftrace.c
78411 @@ -1874,12 +1874,17 @@ ftrace_code_disable(struct module *mod, struct dyn_ftrace *rec)
78412 if (unlikely(ftrace_disabled))
78413 return 0;
78414
78415 + ret = ftrace_arch_code_modify_prepare();
78416 + FTRACE_WARN_ON(ret);
78417 + if (ret)
78418 + return 0;
78419 +
78420 ret = ftrace_make_nop(mod, rec, MCOUNT_ADDR);
78421 + FTRACE_WARN_ON(ftrace_arch_code_modify_post_process());
78422 if (ret) {
78423 ftrace_bug(ret, ip);
78424 - return 0;
78425 }
78426 - return 1;
78427 + return ret ? 0 : 1;
78428 }
78429
78430 /*
78431 @@ -2965,7 +2970,7 @@ static void ftrace_free_entry_rcu(struct rcu_head *rhp)
78432
78433 int
78434 register_ftrace_function_probe(char *glob, struct ftrace_probe_ops *ops,
78435 - void *data)
78436 + void *data)
78437 {
78438 struct ftrace_func_probe *entry;
78439 struct ftrace_page *pg;
78440 @@ -3832,8 +3837,10 @@ static int ftrace_process_locs(struct module *mod,
78441 if (!count)
78442 return 0;
78443
78444 + pax_open_kernel();
78445 sort(start, count, sizeof(*start),
78446 ftrace_cmp_ips, ftrace_swap_ips);
78447 + pax_close_kernel();
78448
78449 start_pg = ftrace_allocate_pages(count);
78450 if (!start_pg)
78451 @@ -4559,8 +4566,6 @@ ftrace_enable_sysctl(struct ctl_table *table, int write,
78452 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
78453
78454 static int ftrace_graph_active;
78455 -static struct notifier_block ftrace_suspend_notifier;
78456 -
78457 int ftrace_graph_entry_stub(struct ftrace_graph_ent *trace)
78458 {
78459 return 0;
78460 @@ -4704,6 +4709,10 @@ ftrace_suspend_notifier_call(struct notifier_block *bl, unsigned long state,
78461 return NOTIFY_DONE;
78462 }
78463
78464 +static struct notifier_block ftrace_suspend_notifier = {
78465 + .notifier_call = ftrace_suspend_notifier_call
78466 +};
78467 +
78468 int register_ftrace_graph(trace_func_graph_ret_t retfunc,
78469 trace_func_graph_ent_t entryfunc)
78470 {
78471 @@ -4717,7 +4726,6 @@ int register_ftrace_graph(trace_func_graph_ret_t retfunc,
78472 goto out;
78473 }
78474
78475 - ftrace_suspend_notifier.notifier_call = ftrace_suspend_notifier_call;
78476 register_pm_notifier(&ftrace_suspend_notifier);
78477
78478 ftrace_graph_active++;
78479 diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c
78480 index ce8514f..8233573 100644
78481 --- a/kernel/trace/ring_buffer.c
78482 +++ b/kernel/trace/ring_buffer.c
78483 @@ -346,9 +346,9 @@ struct buffer_data_page {
78484 */
78485 struct buffer_page {
78486 struct list_head list; /* list of buffer pages */
78487 - local_t write; /* index for next write */
78488 + local_unchecked_t write; /* index for next write */
78489 unsigned read; /* index for next read */
78490 - local_t entries; /* entries on this page */
78491 + local_unchecked_t entries; /* entries on this page */
78492 unsigned long real_end; /* real end of data */
78493 struct buffer_data_page *page; /* Actual data page */
78494 };
78495 @@ -461,8 +461,8 @@ struct ring_buffer_per_cpu {
78496 unsigned long last_overrun;
78497 local_t entries_bytes;
78498 local_t entries;
78499 - local_t overrun;
78500 - local_t commit_overrun;
78501 + local_unchecked_t overrun;
78502 + local_unchecked_t commit_overrun;
78503 local_t dropped_events;
78504 local_t committing;
78505 local_t commits;
78506 @@ -861,8 +861,8 @@ static int rb_tail_page_update(struct ring_buffer_per_cpu *cpu_buffer,
78507 *
78508 * We add a counter to the write field to denote this.
78509 */
78510 - old_write = local_add_return(RB_WRITE_INTCNT, &next_page->write);
78511 - old_entries = local_add_return(RB_WRITE_INTCNT, &next_page->entries);
78512 + old_write = local_add_return_unchecked(RB_WRITE_INTCNT, &next_page->write);
78513 + old_entries = local_add_return_unchecked(RB_WRITE_INTCNT, &next_page->entries);
78514
78515 /*
78516 * Just make sure we have seen our old_write and synchronize
78517 @@ -890,8 +890,8 @@ static int rb_tail_page_update(struct ring_buffer_per_cpu *cpu_buffer,
78518 * cmpxchg to only update if an interrupt did not already
78519 * do it for us. If the cmpxchg fails, we don't care.
78520 */
78521 - (void)local_cmpxchg(&next_page->write, old_write, val);
78522 - (void)local_cmpxchg(&next_page->entries, old_entries, eval);
78523 + (void)local_cmpxchg_unchecked(&next_page->write, old_write, val);
78524 + (void)local_cmpxchg_unchecked(&next_page->entries, old_entries, eval);
78525
78526 /*
78527 * No need to worry about races with clearing out the commit.
78528 @@ -1250,12 +1250,12 @@ static void rb_reset_cpu(struct ring_buffer_per_cpu *cpu_buffer);
78529
78530 static inline unsigned long rb_page_entries(struct buffer_page *bpage)
78531 {
78532 - return local_read(&bpage->entries) & RB_WRITE_MASK;
78533 + return local_read_unchecked(&bpage->entries) & RB_WRITE_MASK;
78534 }
78535
78536 static inline unsigned long rb_page_write(struct buffer_page *bpage)
78537 {
78538 - return local_read(&bpage->write) & RB_WRITE_MASK;
78539 + return local_read_unchecked(&bpage->write) & RB_WRITE_MASK;
78540 }
78541
78542 static int
78543 @@ -1350,7 +1350,7 @@ rb_remove_pages(struct ring_buffer_per_cpu *cpu_buffer, unsigned int nr_pages)
78544 * bytes consumed in ring buffer from here.
78545 * Increment overrun to account for the lost events.
78546 */
78547 - local_add(page_entries, &cpu_buffer->overrun);
78548 + local_add_unchecked(page_entries, &cpu_buffer->overrun);
78549 local_sub(BUF_PAGE_SIZE, &cpu_buffer->entries_bytes);
78550 }
78551
78552 @@ -1906,7 +1906,7 @@ rb_handle_head_page(struct ring_buffer_per_cpu *cpu_buffer,
78553 * it is our responsibility to update
78554 * the counters.
78555 */
78556 - local_add(entries, &cpu_buffer->overrun);
78557 + local_add_unchecked(entries, &cpu_buffer->overrun);
78558 local_sub(BUF_PAGE_SIZE, &cpu_buffer->entries_bytes);
78559
78560 /*
78561 @@ -2056,7 +2056,7 @@ rb_reset_tail(struct ring_buffer_per_cpu *cpu_buffer,
78562 if (tail == BUF_PAGE_SIZE)
78563 tail_page->real_end = 0;
78564
78565 - local_sub(length, &tail_page->write);
78566 + local_sub_unchecked(length, &tail_page->write);
78567 return;
78568 }
78569
78570 @@ -2091,7 +2091,7 @@ rb_reset_tail(struct ring_buffer_per_cpu *cpu_buffer,
78571 rb_event_set_padding(event);
78572
78573 /* Set the write back to the previous setting */
78574 - local_sub(length, &tail_page->write);
78575 + local_sub_unchecked(length, &tail_page->write);
78576 return;
78577 }
78578
78579 @@ -2103,7 +2103,7 @@ rb_reset_tail(struct ring_buffer_per_cpu *cpu_buffer,
78580
78581 /* Set write to end of buffer */
78582 length = (tail + length) - BUF_PAGE_SIZE;
78583 - local_sub(length, &tail_page->write);
78584 + local_sub_unchecked(length, &tail_page->write);
78585 }
78586
78587 /*
78588 @@ -2129,7 +2129,7 @@ rb_move_tail(struct ring_buffer_per_cpu *cpu_buffer,
78589 * about it.
78590 */
78591 if (unlikely(next_page == commit_page)) {
78592 - local_inc(&cpu_buffer->commit_overrun);
78593 + local_inc_unchecked(&cpu_buffer->commit_overrun);
78594 goto out_reset;
78595 }
78596
78597 @@ -2185,7 +2185,7 @@ rb_move_tail(struct ring_buffer_per_cpu *cpu_buffer,
78598 cpu_buffer->tail_page) &&
78599 (cpu_buffer->commit_page ==
78600 cpu_buffer->reader_page))) {
78601 - local_inc(&cpu_buffer->commit_overrun);
78602 + local_inc_unchecked(&cpu_buffer->commit_overrun);
78603 goto out_reset;
78604 }
78605 }
78606 @@ -2233,7 +2233,7 @@ __rb_reserve_next(struct ring_buffer_per_cpu *cpu_buffer,
78607 length += RB_LEN_TIME_EXTEND;
78608
78609 tail_page = cpu_buffer->tail_page;
78610 - write = local_add_return(length, &tail_page->write);
78611 + write = local_add_return_unchecked(length, &tail_page->write);
78612
78613 /* set write to only the index of the write */
78614 write &= RB_WRITE_MASK;
78615 @@ -2250,7 +2250,7 @@ __rb_reserve_next(struct ring_buffer_per_cpu *cpu_buffer,
78616 kmemcheck_annotate_bitfield(event, bitfield);
78617 rb_update_event(cpu_buffer, event, length, add_timestamp, delta);
78618
78619 - local_inc(&tail_page->entries);
78620 + local_inc_unchecked(&tail_page->entries);
78621
78622 /*
78623 * If this is the first commit on the page, then update
78624 @@ -2283,7 +2283,7 @@ rb_try_to_discard(struct ring_buffer_per_cpu *cpu_buffer,
78625
78626 if (bpage->page == (void *)addr && rb_page_write(bpage) == old_index) {
78627 unsigned long write_mask =
78628 - local_read(&bpage->write) & ~RB_WRITE_MASK;
78629 + local_read_unchecked(&bpage->write) & ~RB_WRITE_MASK;
78630 unsigned long event_length = rb_event_length(event);
78631 /*
78632 * This is on the tail page. It is possible that
78633 @@ -2293,7 +2293,7 @@ rb_try_to_discard(struct ring_buffer_per_cpu *cpu_buffer,
78634 */
78635 old_index += write_mask;
78636 new_index += write_mask;
78637 - index = local_cmpxchg(&bpage->write, old_index, new_index);
78638 + index = local_cmpxchg_unchecked(&bpage->write, old_index, new_index);
78639 if (index == old_index) {
78640 /* update counters */
78641 local_sub(event_length, &cpu_buffer->entries_bytes);
78642 @@ -2632,7 +2632,7 @@ rb_decrement_entry(struct ring_buffer_per_cpu *cpu_buffer,
78643
78644 /* Do the likely case first */
78645 if (likely(bpage->page == (void *)addr)) {
78646 - local_dec(&bpage->entries);
78647 + local_dec_unchecked(&bpage->entries);
78648 return;
78649 }
78650
78651 @@ -2644,7 +2644,7 @@ rb_decrement_entry(struct ring_buffer_per_cpu *cpu_buffer,
78652 start = bpage;
78653 do {
78654 if (bpage->page == (void *)addr) {
78655 - local_dec(&bpage->entries);
78656 + local_dec_unchecked(&bpage->entries);
78657 return;
78658 }
78659 rb_inc_page(cpu_buffer, &bpage);
78660 @@ -2926,7 +2926,7 @@ static inline unsigned long
78661 rb_num_of_entries(struct ring_buffer_per_cpu *cpu_buffer)
78662 {
78663 return local_read(&cpu_buffer->entries) -
78664 - (local_read(&cpu_buffer->overrun) + cpu_buffer->read);
78665 + (local_read_unchecked(&cpu_buffer->overrun) + cpu_buffer->read);
78666 }
78667
78668 /**
78669 @@ -3015,7 +3015,7 @@ unsigned long ring_buffer_overrun_cpu(struct ring_buffer *buffer, int cpu)
78670 return 0;
78671
78672 cpu_buffer = buffer->buffers[cpu];
78673 - ret = local_read(&cpu_buffer->overrun);
78674 + ret = local_read_unchecked(&cpu_buffer->overrun);
78675
78676 return ret;
78677 }
78678 @@ -3038,7 +3038,7 @@ ring_buffer_commit_overrun_cpu(struct ring_buffer *buffer, int cpu)
78679 return 0;
78680
78681 cpu_buffer = buffer->buffers[cpu];
78682 - ret = local_read(&cpu_buffer->commit_overrun);
78683 + ret = local_read_unchecked(&cpu_buffer->commit_overrun);
78684
78685 return ret;
78686 }
78687 @@ -3105,7 +3105,7 @@ unsigned long ring_buffer_overruns(struct ring_buffer *buffer)
78688 /* if you care about this being correct, lock the buffer */
78689 for_each_buffer_cpu(buffer, cpu) {
78690 cpu_buffer = buffer->buffers[cpu];
78691 - overruns += local_read(&cpu_buffer->overrun);
78692 + overruns += local_read_unchecked(&cpu_buffer->overrun);
78693 }
78694
78695 return overruns;
78696 @@ -3281,8 +3281,8 @@ rb_get_reader_page(struct ring_buffer_per_cpu *cpu_buffer)
78697 /*
78698 * Reset the reader page to size zero.
78699 */
78700 - local_set(&cpu_buffer->reader_page->write, 0);
78701 - local_set(&cpu_buffer->reader_page->entries, 0);
78702 + local_set_unchecked(&cpu_buffer->reader_page->write, 0);
78703 + local_set_unchecked(&cpu_buffer->reader_page->entries, 0);
78704 local_set(&cpu_buffer->reader_page->page->commit, 0);
78705 cpu_buffer->reader_page->real_end = 0;
78706
78707 @@ -3316,7 +3316,7 @@ rb_get_reader_page(struct ring_buffer_per_cpu *cpu_buffer)
78708 * want to compare with the last_overrun.
78709 */
78710 smp_mb();
78711 - overwrite = local_read(&(cpu_buffer->overrun));
78712 + overwrite = local_read_unchecked(&(cpu_buffer->overrun));
78713
78714 /*
78715 * Here's the tricky part.
78716 @@ -3886,8 +3886,8 @@ rb_reset_cpu(struct ring_buffer_per_cpu *cpu_buffer)
78717
78718 cpu_buffer->head_page
78719 = list_entry(cpu_buffer->pages, struct buffer_page, list);
78720 - local_set(&cpu_buffer->head_page->write, 0);
78721 - local_set(&cpu_buffer->head_page->entries, 0);
78722 + local_set_unchecked(&cpu_buffer->head_page->write, 0);
78723 + local_set_unchecked(&cpu_buffer->head_page->entries, 0);
78724 local_set(&cpu_buffer->head_page->page->commit, 0);
78725
78726 cpu_buffer->head_page->read = 0;
78727 @@ -3897,14 +3897,14 @@ rb_reset_cpu(struct ring_buffer_per_cpu *cpu_buffer)
78728
78729 INIT_LIST_HEAD(&cpu_buffer->reader_page->list);
78730 INIT_LIST_HEAD(&cpu_buffer->new_pages);
78731 - local_set(&cpu_buffer->reader_page->write, 0);
78732 - local_set(&cpu_buffer->reader_page->entries, 0);
78733 + local_set_unchecked(&cpu_buffer->reader_page->write, 0);
78734 + local_set_unchecked(&cpu_buffer->reader_page->entries, 0);
78735 local_set(&cpu_buffer->reader_page->page->commit, 0);
78736 cpu_buffer->reader_page->read = 0;
78737
78738 local_set(&cpu_buffer->entries_bytes, 0);
78739 - local_set(&cpu_buffer->overrun, 0);
78740 - local_set(&cpu_buffer->commit_overrun, 0);
78741 + local_set_unchecked(&cpu_buffer->overrun, 0);
78742 + local_set_unchecked(&cpu_buffer->commit_overrun, 0);
78743 local_set(&cpu_buffer->dropped_events, 0);
78744 local_set(&cpu_buffer->entries, 0);
78745 local_set(&cpu_buffer->committing, 0);
78746 @@ -4308,8 +4308,8 @@ int ring_buffer_read_page(struct ring_buffer *buffer,
78747 rb_init_page(bpage);
78748 bpage = reader->page;
78749 reader->page = *data_page;
78750 - local_set(&reader->write, 0);
78751 - local_set(&reader->entries, 0);
78752 + local_set_unchecked(&reader->write, 0);
78753 + local_set_unchecked(&reader->entries, 0);
78754 reader->read = 0;
78755 *data_page = bpage;
78756
78757 diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
78758 index 3c13e46..883d039 100644
78759 --- a/kernel/trace/trace.c
78760 +++ b/kernel/trace/trace.c
78761 @@ -4465,10 +4465,9 @@ static const struct file_operations tracing_dyn_info_fops = {
78762 };
78763 #endif
78764
78765 -static struct dentry *d_tracer;
78766 -
78767 struct dentry *tracing_init_dentry(void)
78768 {
78769 + static struct dentry *d_tracer;
78770 static int once;
78771
78772 if (d_tracer)
78773 @@ -4488,10 +4487,9 @@ struct dentry *tracing_init_dentry(void)
78774 return d_tracer;
78775 }
78776
78777 -static struct dentry *d_percpu;
78778 -
78779 struct dentry *tracing_dentry_percpu(void)
78780 {
78781 + static struct dentry *d_percpu;
78782 static int once;
78783 struct dentry *d_tracer;
78784
78785 diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c
78786 index 880073d..42db7c3 100644
78787 --- a/kernel/trace/trace_events.c
78788 +++ b/kernel/trace/trace_events.c
78789 @@ -1330,10 +1330,6 @@ static LIST_HEAD(ftrace_module_file_list);
78790 struct ftrace_module_file_ops {
78791 struct list_head list;
78792 struct module *mod;
78793 - struct file_operations id;
78794 - struct file_operations enable;
78795 - struct file_operations format;
78796 - struct file_operations filter;
78797 };
78798
78799 static struct ftrace_module_file_ops *
78800 @@ -1354,17 +1350,12 @@ trace_create_file_ops(struct module *mod)
78801
78802 file_ops->mod = mod;
78803
78804 - file_ops->id = ftrace_event_id_fops;
78805 - file_ops->id.owner = mod;
78806 -
78807 - file_ops->enable = ftrace_enable_fops;
78808 - file_ops->enable.owner = mod;
78809 -
78810 - file_ops->filter = ftrace_event_filter_fops;
78811 - file_ops->filter.owner = mod;
78812 -
78813 - file_ops->format = ftrace_event_format_fops;
78814 - file_ops->format.owner = mod;
78815 + pax_open_kernel();
78816 + mod->trace_id.owner = mod;
78817 + mod->trace_enable.owner = mod;
78818 + mod->trace_filter.owner = mod;
78819 + mod->trace_format.owner = mod;
78820 + pax_close_kernel();
78821
78822 list_add(&file_ops->list, &ftrace_module_file_list);
78823
78824 @@ -1388,8 +1379,8 @@ static void trace_module_add_events(struct module *mod)
78825
78826 for_each_event(call, start, end) {
78827 __trace_add_event_call(*call, mod,
78828 - &file_ops->id, &file_ops->enable,
78829 - &file_ops->filter, &file_ops->format);
78830 + &mod->trace_id, &mod->trace_enable,
78831 + &mod->trace_filter, &mod->trace_format);
78832 }
78833 }
78834
78835 diff --git a/kernel/trace/trace_mmiotrace.c b/kernel/trace/trace_mmiotrace.c
78836 index fd3c8aa..5f324a6 100644
78837 --- a/kernel/trace/trace_mmiotrace.c
78838 +++ b/kernel/trace/trace_mmiotrace.c
78839 @@ -24,7 +24,7 @@ struct header_iter {
78840 static struct trace_array *mmio_trace_array;
78841 static bool overrun_detected;
78842 static unsigned long prev_overruns;
78843 -static atomic_t dropped_count;
78844 +static atomic_unchecked_t dropped_count;
78845
78846 static void mmio_reset_data(struct trace_array *tr)
78847 {
78848 @@ -127,7 +127,7 @@ static void mmio_close(struct trace_iterator *iter)
78849
78850 static unsigned long count_overruns(struct trace_iterator *iter)
78851 {
78852 - unsigned long cnt = atomic_xchg(&dropped_count, 0);
78853 + unsigned long cnt = atomic_xchg_unchecked(&dropped_count, 0);
78854 unsigned long over = ring_buffer_overruns(iter->tr->buffer);
78855
78856 if (over > prev_overruns)
78857 @@ -317,7 +317,7 @@ static void __trace_mmiotrace_rw(struct trace_array *tr,
78858 event = trace_buffer_lock_reserve(buffer, TRACE_MMIO_RW,
78859 sizeof(*entry), 0, pc);
78860 if (!event) {
78861 - atomic_inc(&dropped_count);
78862 + atomic_inc_unchecked(&dropped_count);
78863 return;
78864 }
78865 entry = ring_buffer_event_data(event);
78866 @@ -347,7 +347,7 @@ static void __trace_mmiotrace_map(struct trace_array *tr,
78867 event = trace_buffer_lock_reserve(buffer, TRACE_MMIO_MAP,
78868 sizeof(*entry), 0, pc);
78869 if (!event) {
78870 - atomic_inc(&dropped_count);
78871 + atomic_inc_unchecked(&dropped_count);
78872 return;
78873 }
78874 entry = ring_buffer_event_data(event);
78875 diff --git a/kernel/trace/trace_output.c b/kernel/trace/trace_output.c
78876 index 194d796..76edb8f 100644
78877 --- a/kernel/trace/trace_output.c
78878 +++ b/kernel/trace/trace_output.c
78879 @@ -278,7 +278,7 @@ int trace_seq_path(struct trace_seq *s, const struct path *path)
78880
78881 p = d_path(path, s->buffer + s->len, PAGE_SIZE - s->len);
78882 if (!IS_ERR(p)) {
78883 - p = mangle_path(s->buffer + s->len, p, "\n");
78884 + p = mangle_path(s->buffer + s->len, p, "\n\\");
78885 if (p) {
78886 s->len = p - s->buffer;
78887 return 1;
78888 @@ -852,14 +852,16 @@ int register_ftrace_event(struct trace_event *event)
78889 goto out;
78890 }
78891
78892 + pax_open_kernel();
78893 if (event->funcs->trace == NULL)
78894 - event->funcs->trace = trace_nop_print;
78895 + *(void **)&event->funcs->trace = trace_nop_print;
78896 if (event->funcs->raw == NULL)
78897 - event->funcs->raw = trace_nop_print;
78898 + *(void **)&event->funcs->raw = trace_nop_print;
78899 if (event->funcs->hex == NULL)
78900 - event->funcs->hex = trace_nop_print;
78901 + *(void **)&event->funcs->hex = trace_nop_print;
78902 if (event->funcs->binary == NULL)
78903 - event->funcs->binary = trace_nop_print;
78904 + *(void **)&event->funcs->binary = trace_nop_print;
78905 + pax_close_kernel();
78906
78907 key = event->type & (EVENT_HASHSIZE - 1);
78908
78909 diff --git a/kernel/trace/trace_stack.c b/kernel/trace/trace_stack.c
78910 index 42ca822..cdcacc6 100644
78911 --- a/kernel/trace/trace_stack.c
78912 +++ b/kernel/trace/trace_stack.c
78913 @@ -52,7 +52,7 @@ static inline void check_stack(void)
78914 return;
78915
78916 /* we do not handle interrupt stacks yet */
78917 - if (!object_is_on_stack(&this_size))
78918 + if (!object_starts_on_stack(&this_size))
78919 return;
78920
78921 local_irq_save(flags);
78922 diff --git a/kernel/user.c b/kernel/user.c
78923 index 33acb5e..57ebfd4 100644
78924 --- a/kernel/user.c
78925 +++ b/kernel/user.c
78926 @@ -47,9 +47,7 @@ struct user_namespace init_user_ns = {
78927 .count = 4294967295U,
78928 },
78929 },
78930 - .kref = {
78931 - .refcount = ATOMIC_INIT(3),
78932 - },
78933 + .count = ATOMIC_INIT(3),
78934 .owner = GLOBAL_ROOT_UID,
78935 .group = GLOBAL_ROOT_GID,
78936 .proc_inum = PROC_USER_INIT_INO,
78937 diff --git a/kernel/user_namespace.c b/kernel/user_namespace.c
78938 index dbfe36a7..2a3c1df 100644
78939 --- a/kernel/user_namespace.c
78940 +++ b/kernel/user_namespace.c
78941 @@ -79,7 +79,7 @@ int create_user_ns(struct cred *new)
78942 return ret;
78943 }
78944
78945 - kref_init(&ns->kref);
78946 + atomic_set(&ns->count, 1);
78947 /* Leave the new->user_ns reference with the new user namespace. */
78948 ns->parent = parent_ns;
78949 ns->owner = owner;
78950 @@ -105,15 +105,16 @@ int unshare_userns(unsigned long unshare_flags, struct cred **new_cred)
78951 return create_user_ns(cred);
78952 }
78953
78954 -void free_user_ns(struct kref *kref)
78955 +void free_user_ns(struct user_namespace *ns)
78956 {
78957 - struct user_namespace *parent, *ns =
78958 - container_of(kref, struct user_namespace, kref);
78959 + struct user_namespace *parent;
78960
78961 - parent = ns->parent;
78962 - proc_free_inum(ns->proc_inum);
78963 - kmem_cache_free(user_ns_cachep, ns);
78964 - put_user_ns(parent);
78965 + do {
78966 + parent = ns->parent;
78967 + proc_free_inum(ns->proc_inum);
78968 + kmem_cache_free(user_ns_cachep, ns);
78969 + ns = parent;
78970 + } while (atomic_dec_and_test(&parent->count));
78971 }
78972 EXPORT_SYMBOL(free_user_ns);
78973
78974 @@ -804,7 +805,7 @@ static int userns_install(struct nsproxy *nsproxy, void *ns)
78975 if (atomic_read(&current->mm->mm_users) > 1)
78976 return -EINVAL;
78977
78978 - if (current->fs->users != 1)
78979 + if (atomic_read(&current->fs->users) != 1)
78980 return -EINVAL;
78981
78982 if (!ns_capable(user_ns, CAP_SYS_ADMIN))
78983 diff --git a/kernel/utsname_sysctl.c b/kernel/utsname_sysctl.c
78984 index 63da38c..639904e 100644
78985 --- a/kernel/utsname_sysctl.c
78986 +++ b/kernel/utsname_sysctl.c
78987 @@ -46,7 +46,7 @@ static void put_uts(ctl_table *table, int write, void *which)
78988 static int proc_do_uts_string(ctl_table *table, int write,
78989 void __user *buffer, size_t *lenp, loff_t *ppos)
78990 {
78991 - struct ctl_table uts_table;
78992 + ctl_table_no_const uts_table;
78993 int r;
78994 memcpy(&uts_table, table, sizeof(uts_table));
78995 uts_table.data = get_uts(table, write);
78996 diff --git a/kernel/watchdog.c b/kernel/watchdog.c
78997 index 75a2ab3..5961da7 100644
78998 --- a/kernel/watchdog.c
78999 +++ b/kernel/watchdog.c
79000 @@ -527,7 +527,7 @@ int proc_dowatchdog(struct ctl_table *table, int write,
79001 }
79002 #endif /* CONFIG_SYSCTL */
79003
79004 -static struct smp_hotplug_thread watchdog_threads = {
79005 +static struct smp_hotplug_thread watchdog_threads __read_only = {
79006 .store = &softlockup_watchdog,
79007 .thread_should_run = watchdog_should_run,
79008 .thread_fn = watchdog,
79009 diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
79010 index 67604e5..fe94fb1 100644
79011 --- a/lib/Kconfig.debug
79012 +++ b/lib/Kconfig.debug
79013 @@ -550,7 +550,7 @@ config DEBUG_MUTEXES
79014
79015 config DEBUG_LOCK_ALLOC
79016 bool "Lock debugging: detect incorrect freeing of live locks"
79017 - depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
79018 + depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT && !PAX_CONSTIFY_PLUGIN
79019 select DEBUG_SPINLOCK
79020 select DEBUG_MUTEXES
79021 select LOCKDEP
79022 @@ -564,7 +564,7 @@ config DEBUG_LOCK_ALLOC
79023
79024 config PROVE_LOCKING
79025 bool "Lock debugging: prove locking correctness"
79026 - depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
79027 + depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT && !PAX_CONSTIFY_PLUGIN
79028 select LOCKDEP
79029 select DEBUG_SPINLOCK
79030 select DEBUG_MUTEXES
79031 @@ -670,7 +670,7 @@ config LOCKDEP
79032
79033 config LOCK_STAT
79034 bool "Lock usage statistics"
79035 - depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
79036 + depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT && !PAX_CONSTIFY_PLUGIN
79037 select LOCKDEP
79038 select DEBUG_SPINLOCK
79039 select DEBUG_MUTEXES
79040 @@ -1278,6 +1278,7 @@ config LATENCYTOP
79041 depends on DEBUG_KERNEL
79042 depends on STACKTRACE_SUPPORT
79043 depends on PROC_FS
79044 + depends on !GRKERNSEC_HIDESYM
79045 select FRAME_POINTER if !MIPS && !PPC && !S390 && !MICROBLAZE && !ARM_UNWIND
79046 select KALLSYMS
79047 select KALLSYMS_ALL
79048 @@ -1306,7 +1307,7 @@ config INTERVAL_TREE_TEST
79049
79050 config PROVIDE_OHCI1394_DMA_INIT
79051 bool "Remote debugging over FireWire early on boot"
79052 - depends on PCI && X86
79053 + depends on PCI && X86 && !GRKERNSEC
79054 help
79055 If you want to debug problems which hang or crash the kernel early
79056 on boot and the crashing machine has a FireWire port, you can use
79057 @@ -1335,7 +1336,7 @@ config PROVIDE_OHCI1394_DMA_INIT
79058
79059 config FIREWIRE_OHCI_REMOTE_DMA
79060 bool "Remote debugging over FireWire with firewire-ohci"
79061 - depends on FIREWIRE_OHCI
79062 + depends on FIREWIRE_OHCI && !GRKERNSEC
79063 help
79064 This option lets you use the FireWire bus for remote debugging
79065 with help of the firewire-ohci driver. It enables unfiltered
79066 diff --git a/lib/Makefile b/lib/Makefile
79067 index 02ed6c0..bd243da 100644
79068 --- a/lib/Makefile
79069 +++ b/lib/Makefile
79070 @@ -47,7 +47,7 @@ obj-$(CONFIG_GENERIC_HWEIGHT) += hweight.o
79071
79072 obj-$(CONFIG_BTREE) += btree.o
79073 obj-$(CONFIG_DEBUG_PREEMPT) += smp_processor_id.o
79074 -obj-$(CONFIG_DEBUG_LIST) += list_debug.o
79075 +obj-y += list_debug.o
79076 obj-$(CONFIG_DEBUG_OBJECTS) += debugobjects.o
79077
79078 ifneq ($(CONFIG_HAVE_DEC_LOCK),y)
79079 diff --git a/lib/bitmap.c b/lib/bitmap.c
79080 index 06f7e4f..f3cf2b0 100644
79081 --- a/lib/bitmap.c
79082 +++ b/lib/bitmap.c
79083 @@ -422,7 +422,7 @@ int __bitmap_parse(const char *buf, unsigned int buflen,
79084 {
79085 int c, old_c, totaldigits, ndigits, nchunks, nbits;
79086 u32 chunk;
79087 - const char __user __force *ubuf = (const char __user __force *)buf;
79088 + const char __user *ubuf = (const char __force_user *)buf;
79089
79090 bitmap_zero(maskp, nmaskbits);
79091
79092 @@ -507,7 +507,7 @@ int bitmap_parse_user(const char __user *ubuf,
79093 {
79094 if (!access_ok(VERIFY_READ, ubuf, ulen))
79095 return -EFAULT;
79096 - return __bitmap_parse((const char __force *)ubuf,
79097 + return __bitmap_parse((const char __force_kernel *)ubuf,
79098 ulen, 1, maskp, nmaskbits);
79099
79100 }
79101 @@ -598,7 +598,7 @@ static int __bitmap_parselist(const char *buf, unsigned int buflen,
79102 {
79103 unsigned a, b;
79104 int c, old_c, totaldigits;
79105 - const char __user __force *ubuf = (const char __user __force *)buf;
79106 + const char __user *ubuf = (const char __force_user *)buf;
79107 int exp_digit, in_range;
79108
79109 totaldigits = c = 0;
79110 @@ -698,7 +698,7 @@ int bitmap_parselist_user(const char __user *ubuf,
79111 {
79112 if (!access_ok(VERIFY_READ, ubuf, ulen))
79113 return -EFAULT;
79114 - return __bitmap_parselist((const char __force *)ubuf,
79115 + return __bitmap_parselist((const char __force_kernel *)ubuf,
79116 ulen, 1, maskp, nmaskbits);
79117 }
79118 EXPORT_SYMBOL(bitmap_parselist_user);
79119 diff --git a/lib/bug.c b/lib/bug.c
79120 index d0cdf14..4d07bd2 100644
79121 --- a/lib/bug.c
79122 +++ b/lib/bug.c
79123 @@ -134,6 +134,8 @@ enum bug_trap_type report_bug(unsigned long bugaddr, struct pt_regs *regs)
79124 return BUG_TRAP_TYPE_NONE;
79125
79126 bug = find_bug(bugaddr);
79127 + if (!bug)
79128 + return BUG_TRAP_TYPE_NONE;
79129
79130 file = NULL;
79131 line = 0;
79132 diff --git a/lib/debugobjects.c b/lib/debugobjects.c
79133 index d11808c..dc2d6f8 100644
79134 --- a/lib/debugobjects.c
79135 +++ b/lib/debugobjects.c
79136 @@ -287,7 +287,7 @@ static void debug_object_is_on_stack(void *addr, int onstack)
79137 if (limit > 4)
79138 return;
79139
79140 - is_on_stack = object_is_on_stack(addr);
79141 + is_on_stack = object_starts_on_stack(addr);
79142 if (is_on_stack == onstack)
79143 return;
79144
79145 diff --git a/lib/devres.c b/lib/devres.c
79146 index 80b9c76..9e32279 100644
79147 --- a/lib/devres.c
79148 +++ b/lib/devres.c
79149 @@ -80,7 +80,7 @@ EXPORT_SYMBOL(devm_ioremap_nocache);
79150 void devm_iounmap(struct device *dev, void __iomem *addr)
79151 {
79152 WARN_ON(devres_destroy(dev, devm_ioremap_release, devm_ioremap_match,
79153 - (void *)addr));
79154 + (void __force *)addr));
79155 iounmap(addr);
79156 }
79157 EXPORT_SYMBOL(devm_iounmap);
79158 @@ -192,7 +192,7 @@ void devm_ioport_unmap(struct device *dev, void __iomem *addr)
79159 {
79160 ioport_unmap(addr);
79161 WARN_ON(devres_destroy(dev, devm_ioport_map_release,
79162 - devm_ioport_map_match, (void *)addr));
79163 + devm_ioport_map_match, (void __force *)addr));
79164 }
79165 EXPORT_SYMBOL(devm_ioport_unmap);
79166
79167 diff --git a/lib/div64.c b/lib/div64.c
79168 index a163b6c..9618fa5 100644
79169 --- a/lib/div64.c
79170 +++ b/lib/div64.c
79171 @@ -59,7 +59,7 @@ uint32_t __attribute__((weak)) __div64_32(uint64_t *n, uint32_t base)
79172 EXPORT_SYMBOL(__div64_32);
79173
79174 #ifndef div_s64_rem
79175 -s64 div_s64_rem(s64 dividend, s32 divisor, s32 *remainder)
79176 +s64 __intentional_overflow(-1) div_s64_rem(s64 dividend, s32 divisor, s32 *remainder)
79177 {
79178 u64 quotient;
79179
79180 @@ -90,7 +90,7 @@ EXPORT_SYMBOL(div_s64_rem);
79181 * 'http://www.hackersdelight.org/HDcode/newCode/divDouble.c.txt'
79182 */
79183 #ifndef div64_u64
79184 -u64 div64_u64(u64 dividend, u64 divisor)
79185 +u64 __intentional_overflow(-1) div64_u64(u64 dividend, u64 divisor)
79186 {
79187 u32 high = divisor >> 32;
79188 u64 quot;
79189 diff --git a/lib/dma-debug.c b/lib/dma-debug.c
79190 index 5e396ac..58d5de1 100644
79191 --- a/lib/dma-debug.c
79192 +++ b/lib/dma-debug.c
79193 @@ -768,7 +768,7 @@ static int dma_debug_device_change(struct notifier_block *nb, unsigned long acti
79194
79195 void dma_debug_add_bus(struct bus_type *bus)
79196 {
79197 - struct notifier_block *nb;
79198 + notifier_block_no_const *nb;
79199
79200 if (global_disable)
79201 return;
79202 @@ -942,7 +942,7 @@ out:
79203
79204 static void check_for_stack(struct device *dev, void *addr)
79205 {
79206 - if (object_is_on_stack(addr))
79207 + if (object_starts_on_stack(addr))
79208 err_printk(dev, NULL, "DMA-API: device driver maps memory from"
79209 "stack [addr=%p]\n", addr);
79210 }
79211 diff --git a/lib/inflate.c b/lib/inflate.c
79212 index 013a761..c28f3fc 100644
79213 --- a/lib/inflate.c
79214 +++ b/lib/inflate.c
79215 @@ -269,7 +269,7 @@ static void free(void *where)
79216 malloc_ptr = free_mem_ptr;
79217 }
79218 #else
79219 -#define malloc(a) kmalloc(a, GFP_KERNEL)
79220 +#define malloc(a) kmalloc((a), GFP_KERNEL)
79221 #define free(a) kfree(a)
79222 #endif
79223
79224 diff --git a/lib/ioremap.c b/lib/ioremap.c
79225 index 0c9216c..863bd89 100644
79226 --- a/lib/ioremap.c
79227 +++ b/lib/ioremap.c
79228 @@ -38,7 +38,7 @@ static inline int ioremap_pmd_range(pud_t *pud, unsigned long addr,
79229 unsigned long next;
79230
79231 phys_addr -= addr;
79232 - pmd = pmd_alloc(&init_mm, pud, addr);
79233 + pmd = pmd_alloc_kernel(&init_mm, pud, addr);
79234 if (!pmd)
79235 return -ENOMEM;
79236 do {
79237 @@ -56,7 +56,7 @@ static inline int ioremap_pud_range(pgd_t *pgd, unsigned long addr,
79238 unsigned long next;
79239
79240 phys_addr -= addr;
79241 - pud = pud_alloc(&init_mm, pgd, addr);
79242 + pud = pud_alloc_kernel(&init_mm, pgd, addr);
79243 if (!pud)
79244 return -ENOMEM;
79245 do {
79246 diff --git a/lib/is_single_threaded.c b/lib/is_single_threaded.c
79247 index bd2bea9..6b3c95e 100644
79248 --- a/lib/is_single_threaded.c
79249 +++ b/lib/is_single_threaded.c
79250 @@ -22,6 +22,9 @@ bool current_is_single_threaded(void)
79251 struct task_struct *p, *t;
79252 bool ret;
79253
79254 + if (!mm)
79255 + return true;
79256 +
79257 if (atomic_read(&task->signal->live) != 1)
79258 return false;
79259
79260 diff --git a/lib/kobject.c b/lib/kobject.c
79261 index e07ee1f..998489d 100644
79262 --- a/lib/kobject.c
79263 +++ b/lib/kobject.c
79264 @@ -852,9 +852,9 @@ EXPORT_SYMBOL_GPL(kset_create_and_add);
79265
79266
79267 static DEFINE_SPINLOCK(kobj_ns_type_lock);
79268 -static const struct kobj_ns_type_operations *kobj_ns_ops_tbl[KOBJ_NS_TYPES];
79269 +static const struct kobj_ns_type_operations *kobj_ns_ops_tbl[KOBJ_NS_TYPES] __read_only;
79270
79271 -int kobj_ns_type_register(const struct kobj_ns_type_operations *ops)
79272 +int __init kobj_ns_type_register(const struct kobj_ns_type_operations *ops)
79273 {
79274 enum kobj_ns_type type = ops->type;
79275 int error;
79276 diff --git a/lib/list_debug.c b/lib/list_debug.c
79277 index c24c2f7..0475b78 100644
79278 --- a/lib/list_debug.c
79279 +++ b/lib/list_debug.c
79280 @@ -11,7 +11,9 @@
79281 #include <linux/bug.h>
79282 #include <linux/kernel.h>
79283 #include <linux/rculist.h>
79284 +#include <linux/mm.h>
79285
79286 +#ifdef CONFIG_DEBUG_LIST
79287 /*
79288 * Insert a new entry between two known consecutive entries.
79289 *
79290 @@ -19,21 +21,32 @@
79291 * the prev/next entries already!
79292 */
79293
79294 -void __list_add(struct list_head *new,
79295 - struct list_head *prev,
79296 - struct list_head *next)
79297 +static bool __list_add_debug(struct list_head *new,
79298 + struct list_head *prev,
79299 + struct list_head *next)
79300 {
79301 - WARN(next->prev != prev,
79302 + if (WARN(next->prev != prev,
79303 "list_add corruption. next->prev should be "
79304 "prev (%p), but was %p. (next=%p).\n",
79305 - prev, next->prev, next);
79306 - WARN(prev->next != next,
79307 + prev, next->prev, next) ||
79308 + WARN(prev->next != next,
79309 "list_add corruption. prev->next should be "
79310 "next (%p), but was %p. (prev=%p).\n",
79311 - next, prev->next, prev);
79312 - WARN(new == prev || new == next,
79313 + next, prev->next, prev) ||
79314 + WARN(new == prev || new == next,
79315 "list_add double add: new=%p, prev=%p, next=%p.\n",
79316 - new, prev, next);
79317 + new, prev, next))
79318 + return false;
79319 + return true;
79320 +}
79321 +
79322 +void __list_add(struct list_head *new,
79323 + struct list_head *prev,
79324 + struct list_head *next)
79325 +{
79326 + if (!__list_add_debug(new, prev, next))
79327 + return;
79328 +
79329 next->prev = new;
79330 new->next = next;
79331 new->prev = prev;
79332 @@ -41,7 +54,7 @@ void __list_add(struct list_head *new,
79333 }
79334 EXPORT_SYMBOL(__list_add);
79335
79336 -void __list_del_entry(struct list_head *entry)
79337 +static bool __list_del_entry_debug(struct list_head *entry)
79338 {
79339 struct list_head *prev, *next;
79340
79341 @@ -60,9 +73,16 @@ void __list_del_entry(struct list_head *entry)
79342 WARN(next->prev != entry,
79343 "list_del corruption. next->prev should be %p, "
79344 "but was %p\n", entry, next->prev))
79345 + return false;
79346 + return true;
79347 +}
79348 +
79349 +void __list_del_entry(struct list_head *entry)
79350 +{
79351 + if (!__list_del_entry_debug(entry))
79352 return;
79353
79354 - __list_del(prev, next);
79355 + __list_del(entry->prev, entry->next);
79356 }
79357 EXPORT_SYMBOL(__list_del_entry);
79358
79359 @@ -86,15 +106,85 @@ EXPORT_SYMBOL(list_del);
79360 void __list_add_rcu(struct list_head *new,
79361 struct list_head *prev, struct list_head *next)
79362 {
79363 - WARN(next->prev != prev,
79364 - "list_add_rcu corruption. next->prev should be prev (%p), but was %p. (next=%p).\n",
79365 - prev, next->prev, next);
79366 - WARN(prev->next != next,
79367 - "list_add_rcu corruption. prev->next should be next (%p), but was %p. (prev=%p).\n",
79368 - next, prev->next, prev);
79369 + if (!__list_add_debug(new, prev, next))
79370 + return;
79371 +
79372 new->next = next;
79373 new->prev = prev;
79374 rcu_assign_pointer(list_next_rcu(prev), new);
79375 next->prev = new;
79376 }
79377 EXPORT_SYMBOL(__list_add_rcu);
79378 +#endif
79379 +
79380 +void __pax_list_add(struct list_head *new, struct list_head *prev, struct list_head *next)
79381 +{
79382 +#ifdef CONFIG_DEBUG_LIST
79383 + if (!__list_add_debug(new, prev, next))
79384 + return;
79385 +#endif
79386 +
79387 + pax_open_kernel();
79388 + next->prev = new;
79389 + new->next = next;
79390 + new->prev = prev;
79391 + prev->next = new;
79392 + pax_close_kernel();
79393 +}
79394 +EXPORT_SYMBOL(__pax_list_add);
79395 +
79396 +void pax_list_del(struct list_head *entry)
79397 +{
79398 +#ifdef CONFIG_DEBUG_LIST
79399 + if (!__list_del_entry_debug(entry))
79400 + return;
79401 +#endif
79402 +
79403 + pax_open_kernel();
79404 + __list_del(entry->prev, entry->next);
79405 + entry->next = LIST_POISON1;
79406 + entry->prev = LIST_POISON2;
79407 + pax_close_kernel();
79408 +}
79409 +EXPORT_SYMBOL(pax_list_del);
79410 +
79411 +void pax_list_del_init(struct list_head *entry)
79412 +{
79413 + pax_open_kernel();
79414 + __list_del(entry->prev, entry->next);
79415 + INIT_LIST_HEAD(entry);
79416 + pax_close_kernel();
79417 +}
79418 +EXPORT_SYMBOL(pax_list_del_init);
79419 +
79420 +void __pax_list_add_rcu(struct list_head *new,
79421 + struct list_head *prev, struct list_head *next)
79422 +{
79423 +#ifdef CONFIG_DEBUG_LIST
79424 + if (!__list_add_debug(new, prev, next))
79425 + return;
79426 +#endif
79427 +
79428 + pax_open_kernel();
79429 + new->next = next;
79430 + new->prev = prev;
79431 + rcu_assign_pointer(list_next_rcu(prev), new);
79432 + next->prev = new;
79433 + pax_close_kernel();
79434 +}
79435 +EXPORT_SYMBOL(__pax_list_add_rcu);
79436 +
79437 +void pax_list_del_rcu(struct list_head *entry)
79438 +{
79439 +#ifdef CONFIG_DEBUG_LIST
79440 + if (!__list_del_entry_debug(entry))
79441 + return;
79442 +#endif
79443 +
79444 + pax_open_kernel();
79445 + __list_del(entry->prev, entry->next);
79446 + entry->next = LIST_POISON1;
79447 + entry->prev = LIST_POISON2;
79448 + pax_close_kernel();
79449 +}
79450 +EXPORT_SYMBOL(pax_list_del_rcu);
79451 diff --git a/lib/radix-tree.c b/lib/radix-tree.c
79452 index e796429..6e38f9f 100644
79453 --- a/lib/radix-tree.c
79454 +++ b/lib/radix-tree.c
79455 @@ -92,7 +92,7 @@ struct radix_tree_preload {
79456 int nr;
79457 struct radix_tree_node *nodes[RADIX_TREE_PRELOAD_SIZE];
79458 };
79459 -static DEFINE_PER_CPU(struct radix_tree_preload, radix_tree_preloads) = { 0, };
79460 +static DEFINE_PER_CPU(struct radix_tree_preload, radix_tree_preloads);
79461
79462 static inline void *ptr_to_indirect(void *ptr)
79463 {
79464 diff --git a/lib/strncpy_from_user.c b/lib/strncpy_from_user.c
79465 index bb2b201..46abaf9 100644
79466 --- a/lib/strncpy_from_user.c
79467 +++ b/lib/strncpy_from_user.c
79468 @@ -21,7 +21,7 @@
79469 */
79470 static inline long do_strncpy_from_user(char *dst, const char __user *src, long count, unsigned long max)
79471 {
79472 - const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
79473 + static const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
79474 long res = 0;
79475
79476 /*
79477 diff --git a/lib/strnlen_user.c b/lib/strnlen_user.c
79478 index a28df52..3d55877 100644
79479 --- a/lib/strnlen_user.c
79480 +++ b/lib/strnlen_user.c
79481 @@ -26,7 +26,7 @@
79482 */
79483 static inline long do_strnlen_user(const char __user *src, unsigned long count, unsigned long max)
79484 {
79485 - const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
79486 + static const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
79487 long align, res = 0;
79488 unsigned long c;
79489
79490 diff --git a/lib/swiotlb.c b/lib/swiotlb.c
79491 index 196b069..358f342 100644
79492 --- a/lib/swiotlb.c
79493 +++ b/lib/swiotlb.c
79494 @@ -642,7 +642,7 @@ EXPORT_SYMBOL(swiotlb_alloc_coherent);
79495
79496 void
79497 swiotlb_free_coherent(struct device *hwdev, size_t size, void *vaddr,
79498 - dma_addr_t dev_addr)
79499 + dma_addr_t dev_addr, struct dma_attrs *attrs)
79500 {
79501 phys_addr_t paddr = dma_to_phys(hwdev, dev_addr);
79502
79503 diff --git a/lib/vsprintf.c b/lib/vsprintf.c
79504 index fab33a9..3b5fe68 100644
79505 --- a/lib/vsprintf.c
79506 +++ b/lib/vsprintf.c
79507 @@ -16,6 +16,9 @@
79508 * - scnprintf and vscnprintf
79509 */
79510
79511 +#ifdef CONFIG_GRKERNSEC_HIDESYM
79512 +#define __INCLUDED_BY_HIDESYM 1
79513 +#endif
79514 #include <stdarg.h>
79515 #include <linux/module.h> /* for KSYM_SYMBOL_LEN */
79516 #include <linux/types.h>
79517 @@ -541,7 +544,7 @@ char *symbol_string(char *buf, char *end, void *ptr,
79518 char sym[KSYM_SYMBOL_LEN];
79519 if (ext == 'B')
79520 sprint_backtrace(sym, value);
79521 - else if (ext != 'f' && ext != 's')
79522 + else if (ext != 'f' && ext != 's' && ext != 'a')
79523 sprint_symbol(sym, value);
79524 else
79525 sprint_symbol_no_offset(sym, value);
79526 @@ -974,7 +977,11 @@ char *netdev_feature_string(char *buf, char *end, const u8 *addr,
79527 return number(buf, end, *(const netdev_features_t *)addr, spec);
79528 }
79529
79530 +#ifdef CONFIG_GRKERNSEC_HIDESYM
79531 +int kptr_restrict __read_mostly = 2;
79532 +#else
79533 int kptr_restrict __read_mostly;
79534 +#endif
79535
79536 /*
79537 * Show a '%p' thing. A kernel extension is that the '%p' is followed
79538 @@ -988,6 +995,8 @@ int kptr_restrict __read_mostly;
79539 * - 'S' For symbolic direct pointers with offset
79540 * - 's' For symbolic direct pointers without offset
79541 * - 'B' For backtraced symbolic direct pointers with offset
79542 + * - 'A' For symbolic direct pointers with offset approved for use with GRKERNSEC_HIDESYM
79543 + * - 'a' For symbolic direct pointers without offset approved for use with GRKERNSEC_HIDESYM
79544 * - 'R' For decoded struct resource, e.g., [mem 0x0-0x1f 64bit pref]
79545 * - 'r' For raw struct resource, e.g., [mem 0x0-0x1f flags 0x201]
79546 * - 'M' For a 6-byte MAC address, it prints the address in the
79547 @@ -1043,12 +1052,12 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
79548
79549 if (!ptr && *fmt != 'K') {
79550 /*
79551 - * Print (null) with the same width as a pointer so it makes
79552 + * Print (nil) with the same width as a pointer so it makes
79553 * tabular output look nice.
79554 */
79555 if (spec.field_width == -1)
79556 spec.field_width = default_width;
79557 - return string(buf, end, "(null)", spec);
79558 + return string(buf, end, "(nil)", spec);
79559 }
79560
79561 switch (*fmt) {
79562 @@ -1058,6 +1067,13 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
79563 /* Fallthrough */
79564 case 'S':
79565 case 's':
79566 +#ifdef CONFIG_GRKERNSEC_HIDESYM
79567 + break;
79568 +#else
79569 + return symbol_string(buf, end, ptr, spec, *fmt);
79570 +#endif
79571 + case 'A':
79572 + case 'a':
79573 case 'B':
79574 return symbol_string(buf, end, ptr, spec, *fmt);
79575 case 'R':
79576 @@ -1098,6 +1114,8 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
79577 va_end(va);
79578 return buf;
79579 }
79580 + case 'P':
79581 + break;
79582 case 'K':
79583 /*
79584 * %pK cannot be used in IRQ context because its test
79585 @@ -1121,6 +1139,21 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
79586 }
79587 break;
79588 }
79589 +
79590 +#ifdef CONFIG_GRKERNSEC_HIDESYM
79591 + /* 'P' = approved pointers to copy to userland,
79592 + as in the /proc/kallsyms case, as we make it display nothing
79593 + for non-root users, and the real contents for root users
79594 + Also ignore 'K' pointers, since we force their NULLing for non-root users
79595 + above
79596 + */
79597 + if ((unsigned long)ptr > TASK_SIZE && *fmt != 'P' && *fmt != 'K' && is_usercopy_object(buf)) {
79598 + printk(KERN_ALERT "grsec: kernel infoleak detected! Please report this log to spender@grsecurity.net.\n");
79599 + dump_stack();
79600 + ptr = NULL;
79601 + }
79602 +#endif
79603 +
79604 spec.flags |= SMALL;
79605 if (spec.field_width == -1) {
79606 spec.field_width = default_width;
79607 @@ -1842,11 +1875,11 @@ int bstr_printf(char *buf, size_t size, const char *fmt, const u32 *bin_buf)
79608 typeof(type) value; \
79609 if (sizeof(type) == 8) { \
79610 args = PTR_ALIGN(args, sizeof(u32)); \
79611 - *(u32 *)&value = *(u32 *)args; \
79612 - *((u32 *)&value + 1) = *(u32 *)(args + 4); \
79613 + *(u32 *)&value = *(const u32 *)args; \
79614 + *((u32 *)&value + 1) = *(const u32 *)(args + 4); \
79615 } else { \
79616 args = PTR_ALIGN(args, sizeof(type)); \
79617 - value = *(typeof(type) *)args; \
79618 + value = *(const typeof(type) *)args; \
79619 } \
79620 args += sizeof(type); \
79621 value; \
79622 @@ -1909,7 +1942,7 @@ int bstr_printf(char *buf, size_t size, const char *fmt, const u32 *bin_buf)
79623 case FORMAT_TYPE_STR: {
79624 const char *str_arg = args;
79625 args += strlen(str_arg) + 1;
79626 - str = string(str, end, (char *)str_arg, spec);
79627 + str = string(str, end, str_arg, spec);
79628 break;
79629 }
79630
79631 diff --git a/localversion-grsec b/localversion-grsec
79632 new file mode 100644
79633 index 0000000..7cd6065
79634 --- /dev/null
79635 +++ b/localversion-grsec
79636 @@ -0,0 +1 @@
79637 +-grsec
79638 diff --git a/mm/Kconfig b/mm/Kconfig
79639 index 278e3ab..87c384d 100644
79640 --- a/mm/Kconfig
79641 +++ b/mm/Kconfig
79642 @@ -286,10 +286,10 @@ config KSM
79643 root has set /sys/kernel/mm/ksm/run to 1 (if CONFIG_SYSFS is set).
79644
79645 config DEFAULT_MMAP_MIN_ADDR
79646 - int "Low address space to protect from user allocation"
79647 + int "Low address space to protect from user allocation"
79648 depends on MMU
79649 - default 4096
79650 - help
79651 + default 65536
79652 + help
79653 This is the portion of low virtual memory which should be protected
79654 from userspace allocation. Keeping a user from writing to low pages
79655 can help reduce the impact of kernel NULL pointer bugs.
79656 @@ -320,7 +320,7 @@ config MEMORY_FAILURE
79657
79658 config HWPOISON_INJECT
79659 tristate "HWPoison pages injector"
79660 - depends on MEMORY_FAILURE && DEBUG_KERNEL && PROC_FS
79661 + depends on MEMORY_FAILURE && DEBUG_KERNEL && PROC_FS && !GRKERNSEC
79662 select PROC_PAGE_MONITOR
79663
79664 config NOMMU_INITIAL_TRIM_EXCESS
79665 diff --git a/mm/filemap.c b/mm/filemap.c
79666 index 83efee7..3f99381 100644
79667 --- a/mm/filemap.c
79668 +++ b/mm/filemap.c
79669 @@ -1747,7 +1747,7 @@ int generic_file_mmap(struct file * file, struct vm_area_struct * vma)
79670 struct address_space *mapping = file->f_mapping;
79671
79672 if (!mapping->a_ops->readpage)
79673 - return -ENOEXEC;
79674 + return -ENODEV;
79675 file_accessed(file);
79676 vma->vm_ops = &generic_file_vm_ops;
79677 return 0;
79678 @@ -2087,6 +2087,7 @@ inline int generic_write_checks(struct file *file, loff_t *pos, size_t *count, i
79679 *pos = i_size_read(inode);
79680
79681 if (limit != RLIM_INFINITY) {
79682 + gr_learn_resource(current, RLIMIT_FSIZE,*pos, 0);
79683 if (*pos >= limit) {
79684 send_sig(SIGXFSZ, current, 0);
79685 return -EFBIG;
79686 diff --git a/mm/fremap.c b/mm/fremap.c
79687 index a0aaf0e..20325c3 100644
79688 --- a/mm/fremap.c
79689 +++ b/mm/fremap.c
79690 @@ -157,6 +157,11 @@ SYSCALL_DEFINE5(remap_file_pages, unsigned long, start, unsigned long, size,
79691 retry:
79692 vma = find_vma(mm, start);
79693
79694 +#ifdef CONFIG_PAX_SEGMEXEC
79695 + if (vma && (mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_flags & VM_MAYEXEC))
79696 + goto out;
79697 +#endif
79698 +
79699 /*
79700 * Make sure the vma is shared, that it supports prefaulting,
79701 * and that the remapped range is valid and fully within
79702 diff --git a/mm/highmem.c b/mm/highmem.c
79703 index b32b70c..e512eb0 100644
79704 --- a/mm/highmem.c
79705 +++ b/mm/highmem.c
79706 @@ -138,8 +138,9 @@ static void flush_all_zero_pkmaps(void)
79707 * So no dangers, even with speculative execution.
79708 */
79709 page = pte_page(pkmap_page_table[i]);
79710 + pax_open_kernel();
79711 pte_clear(&init_mm, PKMAP_ADDR(i), &pkmap_page_table[i]);
79712 -
79713 + pax_close_kernel();
79714 set_page_address(page, NULL);
79715 need_flush = 1;
79716 }
79717 @@ -198,9 +199,11 @@ start:
79718 }
79719 }
79720 vaddr = PKMAP_ADDR(last_pkmap_nr);
79721 +
79722 + pax_open_kernel();
79723 set_pte_at(&init_mm, vaddr,
79724 &(pkmap_page_table[last_pkmap_nr]), mk_pte(page, kmap_prot));
79725 -
79726 + pax_close_kernel();
79727 pkmap_count[last_pkmap_nr] = 1;
79728 set_page_address(page, (void *)vaddr);
79729
79730 diff --git a/mm/hugetlb.c b/mm/hugetlb.c
79731 index 546db81..34830af 100644
79732 --- a/mm/hugetlb.c
79733 +++ b/mm/hugetlb.c
79734 @@ -2008,15 +2008,17 @@ static int hugetlb_sysctl_handler_common(bool obey_mempolicy,
79735 struct hstate *h = &default_hstate;
79736 unsigned long tmp;
79737 int ret;
79738 + ctl_table_no_const hugetlb_table;
79739
79740 tmp = h->max_huge_pages;
79741
79742 if (write && h->order >= MAX_ORDER)
79743 return -EINVAL;
79744
79745 - table->data = &tmp;
79746 - table->maxlen = sizeof(unsigned long);
79747 - ret = proc_doulongvec_minmax(table, write, buffer, length, ppos);
79748 + hugetlb_table = *table;
79749 + hugetlb_table.data = &tmp;
79750 + hugetlb_table.maxlen = sizeof(unsigned long);
79751 + ret = proc_doulongvec_minmax(&hugetlb_table, write, buffer, length, ppos);
79752 if (ret)
79753 goto out;
79754
79755 @@ -2073,15 +2075,17 @@ int hugetlb_overcommit_handler(struct ctl_table *table, int write,
79756 struct hstate *h = &default_hstate;
79757 unsigned long tmp;
79758 int ret;
79759 + ctl_table_no_const hugetlb_table;
79760
79761 tmp = h->nr_overcommit_huge_pages;
79762
79763 if (write && h->order >= MAX_ORDER)
79764 return -EINVAL;
79765
79766 - table->data = &tmp;
79767 - table->maxlen = sizeof(unsigned long);
79768 - ret = proc_doulongvec_minmax(table, write, buffer, length, ppos);
79769 + hugetlb_table = *table;
79770 + hugetlb_table.data = &tmp;
79771 + hugetlb_table.maxlen = sizeof(unsigned long);
79772 + ret = proc_doulongvec_minmax(&hugetlb_table, write, buffer, length, ppos);
79773 if (ret)
79774 goto out;
79775
79776 @@ -2511,6 +2515,27 @@ static int unmap_ref_private(struct mm_struct *mm, struct vm_area_struct *vma,
79777 return 1;
79778 }
79779
79780 +#ifdef CONFIG_PAX_SEGMEXEC
79781 +static void pax_mirror_huge_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m)
79782 +{
79783 + struct mm_struct *mm = vma->vm_mm;
79784 + struct vm_area_struct *vma_m;
79785 + unsigned long address_m;
79786 + pte_t *ptep_m;
79787 +
79788 + vma_m = pax_find_mirror_vma(vma);
79789 + if (!vma_m)
79790 + return;
79791 +
79792 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
79793 + address_m = address + SEGMEXEC_TASK_SIZE;
79794 + ptep_m = huge_pte_offset(mm, address_m & HPAGE_MASK);
79795 + get_page(page_m);
79796 + hugepage_add_anon_rmap(page_m, vma_m, address_m);
79797 + set_huge_pte_at(mm, address_m, ptep_m, make_huge_pte(vma_m, page_m, 0));
79798 +}
79799 +#endif
79800 +
79801 /*
79802 * Hugetlb_cow() should be called with page lock of the original hugepage held.
79803 * Called with hugetlb_instantiation_mutex held and pte_page locked so we
79804 @@ -2629,6 +2654,11 @@ retry_avoidcopy:
79805 make_huge_pte(vma, new_page, 1));
79806 page_remove_rmap(old_page);
79807 hugepage_add_new_anon_rmap(new_page, vma, address);
79808 +
79809 +#ifdef CONFIG_PAX_SEGMEXEC
79810 + pax_mirror_huge_pte(vma, address, new_page);
79811 +#endif
79812 +
79813 /* Make the old page be freed below */
79814 new_page = old_page;
79815 }
79816 @@ -2788,6 +2818,10 @@ retry:
79817 && (vma->vm_flags & VM_SHARED)));
79818 set_huge_pte_at(mm, address, ptep, new_pte);
79819
79820 +#ifdef CONFIG_PAX_SEGMEXEC
79821 + pax_mirror_huge_pte(vma, address, page);
79822 +#endif
79823 +
79824 if ((flags & FAULT_FLAG_WRITE) && !(vma->vm_flags & VM_SHARED)) {
79825 /* Optimization, do the COW without a second fault */
79826 ret = hugetlb_cow(mm, vma, address, ptep, new_pte, page);
79827 @@ -2817,6 +2851,10 @@ int hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma,
79828 static DEFINE_MUTEX(hugetlb_instantiation_mutex);
79829 struct hstate *h = hstate_vma(vma);
79830
79831 +#ifdef CONFIG_PAX_SEGMEXEC
79832 + struct vm_area_struct *vma_m;
79833 +#endif
79834 +
79835 address &= huge_page_mask(h);
79836
79837 ptep = huge_pte_offset(mm, address);
79838 @@ -2830,6 +2868,26 @@ int hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma,
79839 VM_FAULT_SET_HINDEX(hstate_index(h));
79840 }
79841
79842 +#ifdef CONFIG_PAX_SEGMEXEC
79843 + vma_m = pax_find_mirror_vma(vma);
79844 + if (vma_m) {
79845 + unsigned long address_m;
79846 +
79847 + if (vma->vm_start > vma_m->vm_start) {
79848 + address_m = address;
79849 + address -= SEGMEXEC_TASK_SIZE;
79850 + vma = vma_m;
79851 + h = hstate_vma(vma);
79852 + } else
79853 + address_m = address + SEGMEXEC_TASK_SIZE;
79854 +
79855 + if (!huge_pte_alloc(mm, address_m, huge_page_size(h)))
79856 + return VM_FAULT_OOM;
79857 + address_m &= HPAGE_MASK;
79858 + unmap_hugepage_range(vma, address_m, address_m + HPAGE_SIZE, NULL);
79859 + }
79860 +#endif
79861 +
79862 ptep = huge_pte_alloc(mm, address, huge_page_size(h));
79863 if (!ptep)
79864 return VM_FAULT_OOM;
79865 diff --git a/mm/internal.h b/mm/internal.h
79866 index 9ba2110..eaf0674 100644
79867 --- a/mm/internal.h
79868 +++ b/mm/internal.h
79869 @@ -100,6 +100,7 @@ extern pmd_t *mm_find_pmd(struct mm_struct *mm, unsigned long address);
79870 * in mm/page_alloc.c
79871 */
79872 extern void __free_pages_bootmem(struct page *page, unsigned int order);
79873 +extern void free_compound_page(struct page *page);
79874 extern void prep_compound_page(struct page *page, unsigned long order);
79875 #ifdef CONFIG_MEMORY_FAILURE
79876 extern bool is_free_buddy_page(struct page *page);
79877 diff --git a/mm/kmemleak.c b/mm/kmemleak.c
79878 index 752a705..6c3102e 100644
79879 --- a/mm/kmemleak.c
79880 +++ b/mm/kmemleak.c
79881 @@ -363,7 +363,7 @@ static void print_unreferenced(struct seq_file *seq,
79882
79883 for (i = 0; i < object->trace_len; i++) {
79884 void *ptr = (void *)object->trace[i];
79885 - seq_printf(seq, " [<%p>] %pS\n", ptr, ptr);
79886 + seq_printf(seq, " [<%pP>] %pA\n", ptr, ptr);
79887 }
79888 }
79889
79890 @@ -1853,7 +1853,7 @@ static int __init kmemleak_late_init(void)
79891 return -ENOMEM;
79892 }
79893
79894 - dentry = debugfs_create_file("kmemleak", S_IRUGO, NULL, NULL,
79895 + dentry = debugfs_create_file("kmemleak", S_IRUSR, NULL, NULL,
79896 &kmemleak_fops);
79897 if (!dentry)
79898 pr_warning("Failed to create the debugfs kmemleak file\n");
79899 diff --git a/mm/maccess.c b/mm/maccess.c
79900 index d53adf9..03a24bf 100644
79901 --- a/mm/maccess.c
79902 +++ b/mm/maccess.c
79903 @@ -26,7 +26,7 @@ long __probe_kernel_read(void *dst, const void *src, size_t size)
79904 set_fs(KERNEL_DS);
79905 pagefault_disable();
79906 ret = __copy_from_user_inatomic(dst,
79907 - (__force const void __user *)src, size);
79908 + (const void __force_user *)src, size);
79909 pagefault_enable();
79910 set_fs(old_fs);
79911
79912 @@ -53,7 +53,7 @@ long __probe_kernel_write(void *dst, const void *src, size_t size)
79913
79914 set_fs(KERNEL_DS);
79915 pagefault_disable();
79916 - ret = __copy_to_user_inatomic((__force void __user *)dst, src, size);
79917 + ret = __copy_to_user_inatomic((void __force_user *)dst, src, size);
79918 pagefault_enable();
79919 set_fs(old_fs);
79920
79921 diff --git a/mm/madvise.c b/mm/madvise.c
79922 index 03dfa5c..b032917 100644
79923 --- a/mm/madvise.c
79924 +++ b/mm/madvise.c
79925 @@ -48,6 +48,10 @@ static long madvise_behavior(struct vm_area_struct * vma,
79926 pgoff_t pgoff;
79927 unsigned long new_flags = vma->vm_flags;
79928
79929 +#ifdef CONFIG_PAX_SEGMEXEC
79930 + struct vm_area_struct *vma_m;
79931 +#endif
79932 +
79933 switch (behavior) {
79934 case MADV_NORMAL:
79935 new_flags = new_flags & ~VM_RAND_READ & ~VM_SEQ_READ;
79936 @@ -123,6 +127,13 @@ success:
79937 /*
79938 * vm_flags is protected by the mmap_sem held in write mode.
79939 */
79940 +
79941 +#ifdef CONFIG_PAX_SEGMEXEC
79942 + vma_m = pax_find_mirror_vma(vma);
79943 + if (vma_m)
79944 + vma_m->vm_flags = new_flags & ~(VM_WRITE | VM_MAYWRITE | VM_ACCOUNT);
79945 +#endif
79946 +
79947 vma->vm_flags = new_flags;
79948
79949 out:
79950 @@ -181,6 +192,11 @@ static long madvise_dontneed(struct vm_area_struct * vma,
79951 struct vm_area_struct ** prev,
79952 unsigned long start, unsigned long end)
79953 {
79954 +
79955 +#ifdef CONFIG_PAX_SEGMEXEC
79956 + struct vm_area_struct *vma_m;
79957 +#endif
79958 +
79959 *prev = vma;
79960 if (vma->vm_flags & (VM_LOCKED|VM_HUGETLB|VM_PFNMAP))
79961 return -EINVAL;
79962 @@ -193,6 +209,21 @@ static long madvise_dontneed(struct vm_area_struct * vma,
79963 zap_page_range(vma, start, end - start, &details);
79964 } else
79965 zap_page_range(vma, start, end - start, NULL);
79966 +
79967 +#ifdef CONFIG_PAX_SEGMEXEC
79968 + vma_m = pax_find_mirror_vma(vma);
79969 + if (vma_m) {
79970 + if (unlikely(vma->vm_flags & VM_NONLINEAR)) {
79971 + struct zap_details details = {
79972 + .nonlinear_vma = vma_m,
79973 + .last_index = ULONG_MAX,
79974 + };
79975 + zap_page_range(vma, start + SEGMEXEC_TASK_SIZE, end - start, &details);
79976 + } else
79977 + zap_page_range(vma, start + SEGMEXEC_TASK_SIZE, end - start, NULL);
79978 + }
79979 +#endif
79980 +
79981 return 0;
79982 }
79983
79984 @@ -397,6 +428,16 @@ SYSCALL_DEFINE3(madvise, unsigned long, start, size_t, len_in, int, behavior)
79985 if (end < start)
79986 goto out;
79987
79988 +#ifdef CONFIG_PAX_SEGMEXEC
79989 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC) {
79990 + if (end > SEGMEXEC_TASK_SIZE)
79991 + goto out;
79992 + } else
79993 +#endif
79994 +
79995 + if (end > TASK_SIZE)
79996 + goto out;
79997 +
79998 error = 0;
79999 if (end == start)
80000 goto out;
80001 diff --git a/mm/memory-failure.c b/mm/memory-failure.c
80002 index c6e4dd3..1f41988 100644
80003 --- a/mm/memory-failure.c
80004 +++ b/mm/memory-failure.c
80005 @@ -61,7 +61,7 @@ int sysctl_memory_failure_early_kill __read_mostly = 0;
80006
80007 int sysctl_memory_failure_recovery __read_mostly = 1;
80008
80009 -atomic_long_t mce_bad_pages __read_mostly = ATOMIC_LONG_INIT(0);
80010 +atomic_long_unchecked_t mce_bad_pages __read_mostly = ATOMIC_LONG_INIT(0);
80011
80012 #if defined(CONFIG_HWPOISON_INJECT) || defined(CONFIG_HWPOISON_INJECT_MODULE)
80013
80014 @@ -202,7 +202,7 @@ static int kill_proc(struct task_struct *t, unsigned long addr, int trapno,
80015 pfn, t->comm, t->pid);
80016 si.si_signo = SIGBUS;
80017 si.si_errno = 0;
80018 - si.si_addr = (void *)addr;
80019 + si.si_addr = (void __user *)addr;
80020 #ifdef __ARCH_SI_TRAPNO
80021 si.si_trapno = trapno;
80022 #endif
80023 @@ -760,7 +760,7 @@ static struct page_state {
80024 unsigned long res;
80025 char *msg;
80026 int (*action)(struct page *p, unsigned long pfn);
80027 -} error_states[] = {
80028 +} __do_const error_states[] = {
80029 { reserved, reserved, "reserved kernel", me_kernel },
80030 /*
80031 * free pages are specially detected outside this table:
80032 @@ -1040,7 +1040,7 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
80033 }
80034
80035 nr_pages = 1 << compound_trans_order(hpage);
80036 - atomic_long_add(nr_pages, &mce_bad_pages);
80037 + atomic_long_add_unchecked(nr_pages, &mce_bad_pages);
80038
80039 /*
80040 * We need/can do nothing about count=0 pages.
80041 @@ -1070,7 +1070,7 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
80042 if (!PageHWPoison(hpage)
80043 || (hwpoison_filter(p) && TestClearPageHWPoison(p))
80044 || (p != hpage && TestSetPageHWPoison(hpage))) {
80045 - atomic_long_sub(nr_pages, &mce_bad_pages);
80046 + atomic_long_sub_unchecked(nr_pages, &mce_bad_pages);
80047 return 0;
80048 }
80049 set_page_hwpoison_huge_page(hpage);
80050 @@ -1128,7 +1128,7 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
80051 }
80052 if (hwpoison_filter(p)) {
80053 if (TestClearPageHWPoison(p))
80054 - atomic_long_sub(nr_pages, &mce_bad_pages);
80055 + atomic_long_sub_unchecked(nr_pages, &mce_bad_pages);
80056 unlock_page(hpage);
80057 put_page(hpage);
80058 return 0;
80059 @@ -1323,7 +1323,7 @@ int unpoison_memory(unsigned long pfn)
80060 return 0;
80061 }
80062 if (TestClearPageHWPoison(p))
80063 - atomic_long_sub(nr_pages, &mce_bad_pages);
80064 + atomic_long_sub_unchecked(nr_pages, &mce_bad_pages);
80065 pr_info("MCE: Software-unpoisoned free page %#lx\n", pfn);
80066 return 0;
80067 }
80068 @@ -1337,7 +1337,7 @@ int unpoison_memory(unsigned long pfn)
80069 */
80070 if (TestClearPageHWPoison(page)) {
80071 pr_info("MCE: Software-unpoisoned page %#lx\n", pfn);
80072 - atomic_long_sub(nr_pages, &mce_bad_pages);
80073 + atomic_long_sub_unchecked(nr_pages, &mce_bad_pages);
80074 freeit = 1;
80075 if (PageHuge(page))
80076 clear_page_hwpoison_huge_page(page);
80077 @@ -1442,7 +1442,7 @@ static int soft_offline_huge_page(struct page *page, int flags)
80078 }
80079 done:
80080 if (!PageHWPoison(hpage))
80081 - atomic_long_add(1 << compound_trans_order(hpage),
80082 + atomic_long_add_unchecked(1 << compound_trans_order(hpage),
80083 &mce_bad_pages);
80084 set_page_hwpoison_huge_page(hpage);
80085 dequeue_hwpoisoned_huge_page(hpage);
80086 @@ -1583,7 +1583,7 @@ int soft_offline_page(struct page *page, int flags)
80087 return ret;
80088
80089 done:
80090 - atomic_long_add(1, &mce_bad_pages);
80091 + atomic_long_add_unchecked(1, &mce_bad_pages);
80092 SetPageHWPoison(page);
80093 /* keep elevated page count for bad page */
80094 return ret;
80095 diff --git a/mm/memory.c b/mm/memory.c
80096 index bb1369f..efb96b5 100644
80097 --- a/mm/memory.c
80098 +++ b/mm/memory.c
80099 @@ -433,6 +433,7 @@ static inline void free_pmd_range(struct mmu_gather *tlb, pud_t *pud,
80100 free_pte_range(tlb, pmd, addr);
80101 } while (pmd++, addr = next, addr != end);
80102
80103 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_PER_CPU_PGD)
80104 start &= PUD_MASK;
80105 if (start < floor)
80106 return;
80107 @@ -447,6 +448,8 @@ static inline void free_pmd_range(struct mmu_gather *tlb, pud_t *pud,
80108 pmd = pmd_offset(pud, start);
80109 pud_clear(pud);
80110 pmd_free_tlb(tlb, pmd, start);
80111 +#endif
80112 +
80113 }
80114
80115 static inline void free_pud_range(struct mmu_gather *tlb, pgd_t *pgd,
80116 @@ -466,6 +469,7 @@ static inline void free_pud_range(struct mmu_gather *tlb, pgd_t *pgd,
80117 free_pmd_range(tlb, pud, addr, next, floor, ceiling);
80118 } while (pud++, addr = next, addr != end);
80119
80120 +#if !defined(CONFIG_X86_64) || !defined(CONFIG_PAX_PER_CPU_PGD)
80121 start &= PGDIR_MASK;
80122 if (start < floor)
80123 return;
80124 @@ -480,6 +484,8 @@ static inline void free_pud_range(struct mmu_gather *tlb, pgd_t *pgd,
80125 pud = pud_offset(pgd, start);
80126 pgd_clear(pgd);
80127 pud_free_tlb(tlb, pud, start);
80128 +#endif
80129 +
80130 }
80131
80132 /*
80133 @@ -1618,12 +1624,6 @@ no_page_table:
80134 return page;
80135 }
80136
80137 -static inline int stack_guard_page(struct vm_area_struct *vma, unsigned long addr)
80138 -{
80139 - return stack_guard_page_start(vma, addr) ||
80140 - stack_guard_page_end(vma, addr+PAGE_SIZE);
80141 -}
80142 -
80143 /**
80144 * __get_user_pages() - pin user pages in memory
80145 * @tsk: task_struct of target task
80146 @@ -1709,10 +1709,10 @@ int __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
80147
80148 i = 0;
80149
80150 - do {
80151 + while (nr_pages) {
80152 struct vm_area_struct *vma;
80153
80154 - vma = find_extend_vma(mm, start);
80155 + vma = find_vma(mm, start);
80156 if (!vma && in_gate_area(mm, start)) {
80157 unsigned long pg = start & PAGE_MASK;
80158 pgd_t *pgd;
80159 @@ -1760,7 +1760,7 @@ int __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
80160 goto next_page;
80161 }
80162
80163 - if (!vma ||
80164 + if (!vma || start < vma->vm_start ||
80165 (vma->vm_flags & (VM_IO | VM_PFNMAP)) ||
80166 !(vm_flags & vma->vm_flags))
80167 return i ? : -EFAULT;
80168 @@ -1787,11 +1787,6 @@ int __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
80169 int ret;
80170 unsigned int fault_flags = 0;
80171
80172 - /* For mlock, just skip the stack guard page. */
80173 - if (foll_flags & FOLL_MLOCK) {
80174 - if (stack_guard_page(vma, start))
80175 - goto next_page;
80176 - }
80177 if (foll_flags & FOLL_WRITE)
80178 fault_flags |= FAULT_FLAG_WRITE;
80179 if (nonblocking)
80180 @@ -1865,7 +1860,7 @@ next_page:
80181 start += PAGE_SIZE;
80182 nr_pages--;
80183 } while (nr_pages && start < vma->vm_end);
80184 - } while (nr_pages);
80185 + }
80186 return i;
80187 }
80188 EXPORT_SYMBOL(__get_user_pages);
80189 @@ -2072,6 +2067,10 @@ static int insert_page(struct vm_area_struct *vma, unsigned long addr,
80190 page_add_file_rmap(page);
80191 set_pte_at(mm, addr, pte, mk_pte(page, prot));
80192
80193 +#ifdef CONFIG_PAX_SEGMEXEC
80194 + pax_mirror_file_pte(vma, addr, page, ptl);
80195 +#endif
80196 +
80197 retval = 0;
80198 pte_unmap_unlock(pte, ptl);
80199 return retval;
80200 @@ -2116,9 +2115,21 @@ int vm_insert_page(struct vm_area_struct *vma, unsigned long addr,
80201 if (!page_count(page))
80202 return -EINVAL;
80203 if (!(vma->vm_flags & VM_MIXEDMAP)) {
80204 +
80205 +#ifdef CONFIG_PAX_SEGMEXEC
80206 + struct vm_area_struct *vma_m;
80207 +#endif
80208 +
80209 BUG_ON(down_read_trylock(&vma->vm_mm->mmap_sem));
80210 BUG_ON(vma->vm_flags & VM_PFNMAP);
80211 vma->vm_flags |= VM_MIXEDMAP;
80212 +
80213 +#ifdef CONFIG_PAX_SEGMEXEC
80214 + vma_m = pax_find_mirror_vma(vma);
80215 + if (vma_m)
80216 + vma_m->vm_flags |= VM_MIXEDMAP;
80217 +#endif
80218 +
80219 }
80220 return insert_page(vma, addr, page, vma->vm_page_prot);
80221 }
80222 @@ -2201,6 +2212,7 @@ int vm_insert_mixed(struct vm_area_struct *vma, unsigned long addr,
80223 unsigned long pfn)
80224 {
80225 BUG_ON(!(vma->vm_flags & VM_MIXEDMAP));
80226 + BUG_ON(vma->vm_mirror);
80227
80228 if (addr < vma->vm_start || addr >= vma->vm_end)
80229 return -EFAULT;
80230 @@ -2401,7 +2413,9 @@ static int apply_to_pmd_range(struct mm_struct *mm, pud_t *pud,
80231
80232 BUG_ON(pud_huge(*pud));
80233
80234 - pmd = pmd_alloc(mm, pud, addr);
80235 + pmd = (mm == &init_mm) ?
80236 + pmd_alloc_kernel(mm, pud, addr) :
80237 + pmd_alloc(mm, pud, addr);
80238 if (!pmd)
80239 return -ENOMEM;
80240 do {
80241 @@ -2421,7 +2435,9 @@ static int apply_to_pud_range(struct mm_struct *mm, pgd_t *pgd,
80242 unsigned long next;
80243 int err;
80244
80245 - pud = pud_alloc(mm, pgd, addr);
80246 + pud = (mm == &init_mm) ?
80247 + pud_alloc_kernel(mm, pgd, addr) :
80248 + pud_alloc(mm, pgd, addr);
80249 if (!pud)
80250 return -ENOMEM;
80251 do {
80252 @@ -2509,6 +2525,186 @@ static inline void cow_user_page(struct page *dst, struct page *src, unsigned lo
80253 copy_user_highpage(dst, src, va, vma);
80254 }
80255
80256 +#ifdef CONFIG_PAX_SEGMEXEC
80257 +static void pax_unmap_mirror_pte(struct vm_area_struct *vma, unsigned long address, pmd_t *pmd)
80258 +{
80259 + struct mm_struct *mm = vma->vm_mm;
80260 + spinlock_t *ptl;
80261 + pte_t *pte, entry;
80262 +
80263 + pte = pte_offset_map_lock(mm, pmd, address, &ptl);
80264 + entry = *pte;
80265 + if (!pte_present(entry)) {
80266 + if (!pte_none(entry)) {
80267 + BUG_ON(pte_file(entry));
80268 + free_swap_and_cache(pte_to_swp_entry(entry));
80269 + pte_clear_not_present_full(mm, address, pte, 0);
80270 + }
80271 + } else {
80272 + struct page *page;
80273 +
80274 + flush_cache_page(vma, address, pte_pfn(entry));
80275 + entry = ptep_clear_flush(vma, address, pte);
80276 + BUG_ON(pte_dirty(entry));
80277 + page = vm_normal_page(vma, address, entry);
80278 + if (page) {
80279 + update_hiwater_rss(mm);
80280 + if (PageAnon(page))
80281 + dec_mm_counter_fast(mm, MM_ANONPAGES);
80282 + else
80283 + dec_mm_counter_fast(mm, MM_FILEPAGES);
80284 + page_remove_rmap(page);
80285 + page_cache_release(page);
80286 + }
80287 + }
80288 + pte_unmap_unlock(pte, ptl);
80289 +}
80290 +
80291 +/* PaX: if vma is mirrored, synchronize the mirror's PTE
80292 + *
80293 + * the ptl of the lower mapped page is held on entry and is not released on exit
80294 + * or inside to ensure atomic changes to the PTE states (swapout, mremap, munmap, etc)
80295 + */
80296 +static void pax_mirror_anon_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m, spinlock_t *ptl)
80297 +{
80298 + struct mm_struct *mm = vma->vm_mm;
80299 + unsigned long address_m;
80300 + spinlock_t *ptl_m;
80301 + struct vm_area_struct *vma_m;
80302 + pmd_t *pmd_m;
80303 + pte_t *pte_m, entry_m;
80304 +
80305 + BUG_ON(!page_m || !PageAnon(page_m));
80306 +
80307 + vma_m = pax_find_mirror_vma(vma);
80308 + if (!vma_m)
80309 + return;
80310 +
80311 + BUG_ON(!PageLocked(page_m));
80312 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
80313 + address_m = address + SEGMEXEC_TASK_SIZE;
80314 + pmd_m = pmd_offset(pud_offset(pgd_offset(mm, address_m), address_m), address_m);
80315 + pte_m = pte_offset_map(pmd_m, address_m);
80316 + ptl_m = pte_lockptr(mm, pmd_m);
80317 + if (ptl != ptl_m) {
80318 + spin_lock_nested(ptl_m, SINGLE_DEPTH_NESTING);
80319 + if (!pte_none(*pte_m))
80320 + goto out;
80321 + }
80322 +
80323 + entry_m = pfn_pte(page_to_pfn(page_m), vma_m->vm_page_prot);
80324 + page_cache_get(page_m);
80325 + page_add_anon_rmap(page_m, vma_m, address_m);
80326 + inc_mm_counter_fast(mm, MM_ANONPAGES);
80327 + set_pte_at(mm, address_m, pte_m, entry_m);
80328 + update_mmu_cache(vma_m, address_m, entry_m);
80329 +out:
80330 + if (ptl != ptl_m)
80331 + spin_unlock(ptl_m);
80332 + pte_unmap(pte_m);
80333 + unlock_page(page_m);
80334 +}
80335 +
80336 +void pax_mirror_file_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m, spinlock_t *ptl)
80337 +{
80338 + struct mm_struct *mm = vma->vm_mm;
80339 + unsigned long address_m;
80340 + spinlock_t *ptl_m;
80341 + struct vm_area_struct *vma_m;
80342 + pmd_t *pmd_m;
80343 + pte_t *pte_m, entry_m;
80344 +
80345 + BUG_ON(!page_m || PageAnon(page_m));
80346 +
80347 + vma_m = pax_find_mirror_vma(vma);
80348 + if (!vma_m)
80349 + return;
80350 +
80351 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
80352 + address_m = address + SEGMEXEC_TASK_SIZE;
80353 + pmd_m = pmd_offset(pud_offset(pgd_offset(mm, address_m), address_m), address_m);
80354 + pte_m = pte_offset_map(pmd_m, address_m);
80355 + ptl_m = pte_lockptr(mm, pmd_m);
80356 + if (ptl != ptl_m) {
80357 + spin_lock_nested(ptl_m, SINGLE_DEPTH_NESTING);
80358 + if (!pte_none(*pte_m))
80359 + goto out;
80360 + }
80361 +
80362 + entry_m = pfn_pte(page_to_pfn(page_m), vma_m->vm_page_prot);
80363 + page_cache_get(page_m);
80364 + page_add_file_rmap(page_m);
80365 + inc_mm_counter_fast(mm, MM_FILEPAGES);
80366 + set_pte_at(mm, address_m, pte_m, entry_m);
80367 + update_mmu_cache(vma_m, address_m, entry_m);
80368 +out:
80369 + if (ptl != ptl_m)
80370 + spin_unlock(ptl_m);
80371 + pte_unmap(pte_m);
80372 +}
80373 +
80374 +static void pax_mirror_pfn_pte(struct vm_area_struct *vma, unsigned long address, unsigned long pfn_m, spinlock_t *ptl)
80375 +{
80376 + struct mm_struct *mm = vma->vm_mm;
80377 + unsigned long address_m;
80378 + spinlock_t *ptl_m;
80379 + struct vm_area_struct *vma_m;
80380 + pmd_t *pmd_m;
80381 + pte_t *pte_m, entry_m;
80382 +
80383 + vma_m = pax_find_mirror_vma(vma);
80384 + if (!vma_m)
80385 + return;
80386 +
80387 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
80388 + address_m = address + SEGMEXEC_TASK_SIZE;
80389 + pmd_m = pmd_offset(pud_offset(pgd_offset(mm, address_m), address_m), address_m);
80390 + pte_m = pte_offset_map(pmd_m, address_m);
80391 + ptl_m = pte_lockptr(mm, pmd_m);
80392 + if (ptl != ptl_m) {
80393 + spin_lock_nested(ptl_m, SINGLE_DEPTH_NESTING);
80394 + if (!pte_none(*pte_m))
80395 + goto out;
80396 + }
80397 +
80398 + entry_m = pfn_pte(pfn_m, vma_m->vm_page_prot);
80399 + set_pte_at(mm, address_m, pte_m, entry_m);
80400 +out:
80401 + if (ptl != ptl_m)
80402 + spin_unlock(ptl_m);
80403 + pte_unmap(pte_m);
80404 +}
80405 +
80406 +static void pax_mirror_pte(struct vm_area_struct *vma, unsigned long address, pte_t *pte, pmd_t *pmd, spinlock_t *ptl)
80407 +{
80408 + struct page *page_m;
80409 + pte_t entry;
80410 +
80411 + if (!(vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC))
80412 + goto out;
80413 +
80414 + entry = *pte;
80415 + page_m = vm_normal_page(vma, address, entry);
80416 + if (!page_m)
80417 + pax_mirror_pfn_pte(vma, address, pte_pfn(entry), ptl);
80418 + else if (PageAnon(page_m)) {
80419 + if (pax_find_mirror_vma(vma)) {
80420 + pte_unmap_unlock(pte, ptl);
80421 + lock_page(page_m);
80422 + pte = pte_offset_map_lock(vma->vm_mm, pmd, address, &ptl);
80423 + if (pte_same(entry, *pte))
80424 + pax_mirror_anon_pte(vma, address, page_m, ptl);
80425 + else
80426 + unlock_page(page_m);
80427 + }
80428 + } else
80429 + pax_mirror_file_pte(vma, address, page_m, ptl);
80430 +
80431 +out:
80432 + pte_unmap_unlock(pte, ptl);
80433 +}
80434 +#endif
80435 +
80436 /*
80437 * This routine handles present pages, when users try to write
80438 * to a shared page. It is done by copying the page to a new address
80439 @@ -2725,6 +2921,12 @@ gotten:
80440 */
80441 page_table = pte_offset_map_lock(mm, pmd, address, &ptl);
80442 if (likely(pte_same(*page_table, orig_pte))) {
80443 +
80444 +#ifdef CONFIG_PAX_SEGMEXEC
80445 + if (pax_find_mirror_vma(vma))
80446 + BUG_ON(!trylock_page(new_page));
80447 +#endif
80448 +
80449 if (old_page) {
80450 if (!PageAnon(old_page)) {
80451 dec_mm_counter_fast(mm, MM_FILEPAGES);
80452 @@ -2776,6 +2978,10 @@ gotten:
80453 page_remove_rmap(old_page);
80454 }
80455
80456 +#ifdef CONFIG_PAX_SEGMEXEC
80457 + pax_mirror_anon_pte(vma, address, new_page, ptl);
80458 +#endif
80459 +
80460 /* Free the old page.. */
80461 new_page = old_page;
80462 ret |= VM_FAULT_WRITE;
80463 @@ -3051,6 +3257,11 @@ static int do_swap_page(struct mm_struct *mm, struct vm_area_struct *vma,
80464 swap_free(entry);
80465 if (vm_swap_full() || (vma->vm_flags & VM_LOCKED) || PageMlocked(page))
80466 try_to_free_swap(page);
80467 +
80468 +#ifdef CONFIG_PAX_SEGMEXEC
80469 + if ((flags & FAULT_FLAG_WRITE) || !pax_find_mirror_vma(vma))
80470 +#endif
80471 +
80472 unlock_page(page);
80473 if (swapcache) {
80474 /*
80475 @@ -3074,6 +3285,11 @@ static int do_swap_page(struct mm_struct *mm, struct vm_area_struct *vma,
80476
80477 /* No need to invalidate - it was non-present before */
80478 update_mmu_cache(vma, address, page_table);
80479 +
80480 +#ifdef CONFIG_PAX_SEGMEXEC
80481 + pax_mirror_anon_pte(vma, address, page, ptl);
80482 +#endif
80483 +
80484 unlock:
80485 pte_unmap_unlock(page_table, ptl);
80486 out:
80487 @@ -3093,40 +3309,6 @@ out_release:
80488 }
80489
80490 /*
80491 - * This is like a special single-page "expand_{down|up}wards()",
80492 - * except we must first make sure that 'address{-|+}PAGE_SIZE'
80493 - * doesn't hit another vma.
80494 - */
80495 -static inline int check_stack_guard_page(struct vm_area_struct *vma, unsigned long address)
80496 -{
80497 - address &= PAGE_MASK;
80498 - if ((vma->vm_flags & VM_GROWSDOWN) && address == vma->vm_start) {
80499 - struct vm_area_struct *prev = vma->vm_prev;
80500 -
80501 - /*
80502 - * Is there a mapping abutting this one below?
80503 - *
80504 - * That's only ok if it's the same stack mapping
80505 - * that has gotten split..
80506 - */
80507 - if (prev && prev->vm_end == address)
80508 - return prev->vm_flags & VM_GROWSDOWN ? 0 : -ENOMEM;
80509 -
80510 - expand_downwards(vma, address - PAGE_SIZE);
80511 - }
80512 - if ((vma->vm_flags & VM_GROWSUP) && address + PAGE_SIZE == vma->vm_end) {
80513 - struct vm_area_struct *next = vma->vm_next;
80514 -
80515 - /* As VM_GROWSDOWN but s/below/above/ */
80516 - if (next && next->vm_start == address + PAGE_SIZE)
80517 - return next->vm_flags & VM_GROWSUP ? 0 : -ENOMEM;
80518 -
80519 - expand_upwards(vma, address + PAGE_SIZE);
80520 - }
80521 - return 0;
80522 -}
80523 -
80524 -/*
80525 * We enter with non-exclusive mmap_sem (to exclude vma changes,
80526 * but allow concurrent faults), and pte mapped but not yet locked.
80527 * We return with mmap_sem still held, but pte unmapped and unlocked.
80528 @@ -3135,27 +3317,23 @@ static int do_anonymous_page(struct mm_struct *mm, struct vm_area_struct *vma,
80529 unsigned long address, pte_t *page_table, pmd_t *pmd,
80530 unsigned int flags)
80531 {
80532 - struct page *page;
80533 + struct page *page = NULL;
80534 spinlock_t *ptl;
80535 pte_t entry;
80536
80537 - pte_unmap(page_table);
80538 -
80539 - /* Check if we need to add a guard page to the stack */
80540 - if (check_stack_guard_page(vma, address) < 0)
80541 - return VM_FAULT_SIGBUS;
80542 -
80543 - /* Use the zero-page for reads */
80544 if (!(flags & FAULT_FLAG_WRITE)) {
80545 entry = pte_mkspecial(pfn_pte(my_zero_pfn(address),
80546 vma->vm_page_prot));
80547 - page_table = pte_offset_map_lock(mm, pmd, address, &ptl);
80548 + ptl = pte_lockptr(mm, pmd);
80549 + spin_lock(ptl);
80550 if (!pte_none(*page_table))
80551 goto unlock;
80552 goto setpte;
80553 }
80554
80555 /* Allocate our own private page. */
80556 + pte_unmap(page_table);
80557 +
80558 if (unlikely(anon_vma_prepare(vma)))
80559 goto oom;
80560 page = alloc_zeroed_user_highpage_movable(vma, address);
80561 @@ -3174,6 +3352,11 @@ static int do_anonymous_page(struct mm_struct *mm, struct vm_area_struct *vma,
80562 if (!pte_none(*page_table))
80563 goto release;
80564
80565 +#ifdef CONFIG_PAX_SEGMEXEC
80566 + if (pax_find_mirror_vma(vma))
80567 + BUG_ON(!trylock_page(page));
80568 +#endif
80569 +
80570 inc_mm_counter_fast(mm, MM_ANONPAGES);
80571 page_add_new_anon_rmap(page, vma, address);
80572 setpte:
80573 @@ -3181,6 +3364,12 @@ setpte:
80574
80575 /* No need to invalidate - it was non-present before */
80576 update_mmu_cache(vma, address, page_table);
80577 +
80578 +#ifdef CONFIG_PAX_SEGMEXEC
80579 + if (page)
80580 + pax_mirror_anon_pte(vma, address, page, ptl);
80581 +#endif
80582 +
80583 unlock:
80584 pte_unmap_unlock(page_table, ptl);
80585 return 0;
80586 @@ -3324,6 +3513,12 @@ static int __do_fault(struct mm_struct *mm, struct vm_area_struct *vma,
80587 */
80588 /* Only go through if we didn't race with anybody else... */
80589 if (likely(pte_same(*page_table, orig_pte))) {
80590 +
80591 +#ifdef CONFIG_PAX_SEGMEXEC
80592 + if (anon && pax_find_mirror_vma(vma))
80593 + BUG_ON(!trylock_page(page));
80594 +#endif
80595 +
80596 flush_icache_page(vma, page);
80597 entry = mk_pte(page, vma->vm_page_prot);
80598 if (flags & FAULT_FLAG_WRITE)
80599 @@ -3343,6 +3538,14 @@ static int __do_fault(struct mm_struct *mm, struct vm_area_struct *vma,
80600
80601 /* no need to invalidate: a not-present page won't be cached */
80602 update_mmu_cache(vma, address, page_table);
80603 +
80604 +#ifdef CONFIG_PAX_SEGMEXEC
80605 + if (anon)
80606 + pax_mirror_anon_pte(vma, address, page, ptl);
80607 + else
80608 + pax_mirror_file_pte(vma, address, page, ptl);
80609 +#endif
80610 +
80611 } else {
80612 if (cow_page)
80613 mem_cgroup_uncharge_page(cow_page);
80614 @@ -3664,6 +3867,12 @@ int handle_pte_fault(struct mm_struct *mm,
80615 if (flags & FAULT_FLAG_WRITE)
80616 flush_tlb_fix_spurious_fault(vma, address);
80617 }
80618 +
80619 +#ifdef CONFIG_PAX_SEGMEXEC
80620 + pax_mirror_pte(vma, address, pte, pmd, ptl);
80621 + return 0;
80622 +#endif
80623 +
80624 unlock:
80625 pte_unmap_unlock(pte, ptl);
80626 return 0;
80627 @@ -3680,6 +3889,10 @@ int handle_mm_fault(struct mm_struct *mm, struct vm_area_struct *vma,
80628 pmd_t *pmd;
80629 pte_t *pte;
80630
80631 +#ifdef CONFIG_PAX_SEGMEXEC
80632 + struct vm_area_struct *vma_m;
80633 +#endif
80634 +
80635 __set_current_state(TASK_RUNNING);
80636
80637 count_vm_event(PGFAULT);
80638 @@ -3691,6 +3904,34 @@ int handle_mm_fault(struct mm_struct *mm, struct vm_area_struct *vma,
80639 if (unlikely(is_vm_hugetlb_page(vma)))
80640 return hugetlb_fault(mm, vma, address, flags);
80641
80642 +#ifdef CONFIG_PAX_SEGMEXEC
80643 + vma_m = pax_find_mirror_vma(vma);
80644 + if (vma_m) {
80645 + unsigned long address_m;
80646 + pgd_t *pgd_m;
80647 + pud_t *pud_m;
80648 + pmd_t *pmd_m;
80649 +
80650 + if (vma->vm_start > vma_m->vm_start) {
80651 + address_m = address;
80652 + address -= SEGMEXEC_TASK_SIZE;
80653 + vma = vma_m;
80654 + } else
80655 + address_m = address + SEGMEXEC_TASK_SIZE;
80656 +
80657 + pgd_m = pgd_offset(mm, address_m);
80658 + pud_m = pud_alloc(mm, pgd_m, address_m);
80659 + if (!pud_m)
80660 + return VM_FAULT_OOM;
80661 + pmd_m = pmd_alloc(mm, pud_m, address_m);
80662 + if (!pmd_m)
80663 + return VM_FAULT_OOM;
80664 + if (!pmd_present(*pmd_m) && __pte_alloc(mm, vma_m, pmd_m, address_m))
80665 + return VM_FAULT_OOM;
80666 + pax_unmap_mirror_pte(vma_m, address_m, pmd_m);
80667 + }
80668 +#endif
80669 +
80670 retry:
80671 pgd = pgd_offset(mm, address);
80672 pud = pud_alloc(mm, pgd, address);
80673 @@ -3789,6 +4030,23 @@ int __pud_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long address)
80674 spin_unlock(&mm->page_table_lock);
80675 return 0;
80676 }
80677 +
80678 +int __pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd, unsigned long address)
80679 +{
80680 + pud_t *new = pud_alloc_one(mm, address);
80681 + if (!new)
80682 + return -ENOMEM;
80683 +
80684 + smp_wmb(); /* See comment in __pte_alloc */
80685 +
80686 + spin_lock(&mm->page_table_lock);
80687 + if (pgd_present(*pgd)) /* Another has populated it */
80688 + pud_free(mm, new);
80689 + else
80690 + pgd_populate_kernel(mm, pgd, new);
80691 + spin_unlock(&mm->page_table_lock);
80692 + return 0;
80693 +}
80694 #endif /* __PAGETABLE_PUD_FOLDED */
80695
80696 #ifndef __PAGETABLE_PMD_FOLDED
80697 @@ -3819,6 +4077,30 @@ int __pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address)
80698 spin_unlock(&mm->page_table_lock);
80699 return 0;
80700 }
80701 +
80702 +int __pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud, unsigned long address)
80703 +{
80704 + pmd_t *new = pmd_alloc_one(mm, address);
80705 + if (!new)
80706 + return -ENOMEM;
80707 +
80708 + smp_wmb(); /* See comment in __pte_alloc */
80709 +
80710 + spin_lock(&mm->page_table_lock);
80711 +#ifndef __ARCH_HAS_4LEVEL_HACK
80712 + if (pud_present(*pud)) /* Another has populated it */
80713 + pmd_free(mm, new);
80714 + else
80715 + pud_populate_kernel(mm, pud, new);
80716 +#else
80717 + if (pgd_present(*pud)) /* Another has populated it */
80718 + pmd_free(mm, new);
80719 + else
80720 + pgd_populate_kernel(mm, pud, new);
80721 +#endif /* __ARCH_HAS_4LEVEL_HACK */
80722 + spin_unlock(&mm->page_table_lock);
80723 + return 0;
80724 +}
80725 #endif /* __PAGETABLE_PMD_FOLDED */
80726
80727 int make_pages_present(unsigned long addr, unsigned long end)
80728 @@ -3856,7 +4138,7 @@ static int __init gate_vma_init(void)
80729 gate_vma.vm_start = FIXADDR_USER_START;
80730 gate_vma.vm_end = FIXADDR_USER_END;
80731 gate_vma.vm_flags = VM_READ | VM_MAYREAD | VM_EXEC | VM_MAYEXEC;
80732 - gate_vma.vm_page_prot = __P101;
80733 + gate_vma.vm_page_prot = vm_get_page_prot(gate_vma.vm_flags);
80734
80735 return 0;
80736 }
80737 diff --git a/mm/mempolicy.c b/mm/mempolicy.c
80738 index 3df6d12..a11056a 100644
80739 --- a/mm/mempolicy.c
80740 +++ b/mm/mempolicy.c
80741 @@ -721,6 +721,10 @@ static int mbind_range(struct mm_struct *mm, unsigned long start,
80742 unsigned long vmstart;
80743 unsigned long vmend;
80744
80745 +#ifdef CONFIG_PAX_SEGMEXEC
80746 + struct vm_area_struct *vma_m;
80747 +#endif
80748 +
80749 vma = find_vma(mm, start);
80750 if (!vma || vma->vm_start > start)
80751 return -EFAULT;
80752 @@ -757,9 +761,20 @@ static int mbind_range(struct mm_struct *mm, unsigned long start,
80753 if (err)
80754 goto out;
80755 }
80756 +
80757 err = vma_replace_policy(vma, new_pol);
80758 if (err)
80759 goto out;
80760 +
80761 +#ifdef CONFIG_PAX_SEGMEXEC
80762 + vma_m = pax_find_mirror_vma(vma);
80763 + if (vma_m) {
80764 + err = vma_replace_policy(vma_m, new_pol);
80765 + if (err)
80766 + goto out;
80767 + }
80768 +#endif
80769 +
80770 }
80771
80772 out:
80773 @@ -1216,6 +1231,17 @@ static long do_mbind(unsigned long start, unsigned long len,
80774
80775 if (end < start)
80776 return -EINVAL;
80777 +
80778 +#ifdef CONFIG_PAX_SEGMEXEC
80779 + if (mm->pax_flags & MF_PAX_SEGMEXEC) {
80780 + if (end > SEGMEXEC_TASK_SIZE)
80781 + return -EINVAL;
80782 + } else
80783 +#endif
80784 +
80785 + if (end > TASK_SIZE)
80786 + return -EINVAL;
80787 +
80788 if (end == start)
80789 return 0;
80790
80791 @@ -1445,8 +1471,7 @@ SYSCALL_DEFINE4(migrate_pages, pid_t, pid, unsigned long, maxnode,
80792 */
80793 tcred = __task_cred(task);
80794 if (!uid_eq(cred->euid, tcred->suid) && !uid_eq(cred->euid, tcred->uid) &&
80795 - !uid_eq(cred->uid, tcred->suid) && !uid_eq(cred->uid, tcred->uid) &&
80796 - !capable(CAP_SYS_NICE)) {
80797 + !uid_eq(cred->uid, tcred->suid) && !capable(CAP_SYS_NICE)) {
80798 rcu_read_unlock();
80799 err = -EPERM;
80800 goto out_put;
80801 @@ -1477,6 +1502,15 @@ SYSCALL_DEFINE4(migrate_pages, pid_t, pid, unsigned long, maxnode,
80802 goto out;
80803 }
80804
80805 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
80806 + if (mm != current->mm &&
80807 + (mm->pax_flags & MF_PAX_RANDMMAP || mm->pax_flags & MF_PAX_SEGMEXEC)) {
80808 + mmput(mm);
80809 + err = -EPERM;
80810 + goto out;
80811 + }
80812 +#endif
80813 +
80814 err = do_migrate_pages(mm, old, new,
80815 capable(CAP_SYS_NICE) ? MPOL_MF_MOVE_ALL : MPOL_MF_MOVE);
80816
80817 diff --git a/mm/migrate.c b/mm/migrate.c
80818 index 2fd8b4a..d70358f 100644
80819 --- a/mm/migrate.c
80820 +++ b/mm/migrate.c
80821 @@ -1401,8 +1401,7 @@ SYSCALL_DEFINE6(move_pages, pid_t, pid, unsigned long, nr_pages,
80822 */
80823 tcred = __task_cred(task);
80824 if (!uid_eq(cred->euid, tcred->suid) && !uid_eq(cred->euid, tcred->uid) &&
80825 - !uid_eq(cred->uid, tcred->suid) && !uid_eq(cred->uid, tcred->uid) &&
80826 - !capable(CAP_SYS_NICE)) {
80827 + !uid_eq(cred->uid, tcred->suid) && !capable(CAP_SYS_NICE)) {
80828 rcu_read_unlock();
80829 err = -EPERM;
80830 goto out;
80831 diff --git a/mm/mlock.c b/mm/mlock.c
80832 index c9bd528..da8d069 100644
80833 --- a/mm/mlock.c
80834 +++ b/mm/mlock.c
80835 @@ -13,6 +13,7 @@
80836 #include <linux/pagemap.h>
80837 #include <linux/mempolicy.h>
80838 #include <linux/syscalls.h>
80839 +#include <linux/security.h>
80840 #include <linux/sched.h>
80841 #include <linux/export.h>
80842 #include <linux/rmap.h>
80843 @@ -369,7 +370,7 @@ static int do_mlock(unsigned long start, size_t len, int on)
80844 {
80845 unsigned long nstart, end, tmp;
80846 struct vm_area_struct * vma, * prev;
80847 - int error;
80848 + int error = 0;
80849
80850 VM_BUG_ON(start & ~PAGE_MASK);
80851 VM_BUG_ON(len != PAGE_ALIGN(len));
80852 @@ -378,6 +379,9 @@ static int do_mlock(unsigned long start, size_t len, int on)
80853 return -EINVAL;
80854 if (end == start)
80855 return 0;
80856 + if (end > TASK_SIZE)
80857 + return -EINVAL;
80858 +
80859 vma = find_vma(current->mm, start);
80860 if (!vma || vma->vm_start > start)
80861 return -ENOMEM;
80862 @@ -389,6 +393,11 @@ static int do_mlock(unsigned long start, size_t len, int on)
80863 for (nstart = start ; ; ) {
80864 vm_flags_t newflags;
80865
80866 +#ifdef CONFIG_PAX_SEGMEXEC
80867 + if ((current->mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_start >= SEGMEXEC_TASK_SIZE))
80868 + break;
80869 +#endif
80870 +
80871 /* Here we know that vma->vm_start <= nstart < vma->vm_end. */
80872
80873 newflags = vma->vm_flags | VM_LOCKED;
80874 @@ -494,6 +503,7 @@ SYSCALL_DEFINE2(mlock, unsigned long, start, size_t, len)
80875 lock_limit >>= PAGE_SHIFT;
80876
80877 /* check against resource limits */
80878 + gr_learn_resource(current, RLIMIT_MEMLOCK, (current->mm->locked_vm << PAGE_SHIFT) + len, 1);
80879 if ((locked <= lock_limit) || capable(CAP_IPC_LOCK))
80880 error = do_mlock(start, len, 1);
80881 up_write(&current->mm->mmap_sem);
80882 @@ -528,6 +538,12 @@ static int do_mlockall(int flags)
80883 for (vma = current->mm->mmap; vma ; vma = prev->vm_next) {
80884 vm_flags_t newflags;
80885
80886 +#ifdef CONFIG_PAX_SEGMEXEC
80887 + if ((current->mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_start >= SEGMEXEC_TASK_SIZE))
80888 + break;
80889 +#endif
80890 +
80891 + BUG_ON(vma->vm_end > TASK_SIZE);
80892 newflags = vma->vm_flags | VM_LOCKED;
80893 if (!(flags & MCL_CURRENT))
80894 newflags &= ~VM_LOCKED;
80895 @@ -560,6 +576,7 @@ SYSCALL_DEFINE1(mlockall, int, flags)
80896 lock_limit >>= PAGE_SHIFT;
80897
80898 ret = -ENOMEM;
80899 + gr_learn_resource(current, RLIMIT_MEMLOCK, current->mm->total_vm << PAGE_SHIFT, 1);
80900 if (!(flags & MCL_CURRENT) || (current->mm->total_vm <= lock_limit) ||
80901 capable(CAP_IPC_LOCK))
80902 ret = do_mlockall(flags);
80903 diff --git a/mm/mmap.c b/mm/mmap.c
80904 index 8832b87..20500c1 100644
80905 --- a/mm/mmap.c
80906 +++ b/mm/mmap.c
80907 @@ -32,6 +32,7 @@
80908 #include <linux/khugepaged.h>
80909 #include <linux/uprobes.h>
80910 #include <linux/rbtree_augmented.h>
80911 +#include <linux/random.h>
80912
80913 #include <asm/uaccess.h>
80914 #include <asm/cacheflush.h>
80915 @@ -48,6 +49,16 @@
80916 #define arch_rebalance_pgtables(addr, len) (addr)
80917 #endif
80918
80919 +static inline void verify_mm_writelocked(struct mm_struct *mm)
80920 +{
80921 +#if defined(CONFIG_DEBUG_VM) || defined(CONFIG_PAX)
80922 + if (unlikely(down_read_trylock(&mm->mmap_sem))) {
80923 + up_read(&mm->mmap_sem);
80924 + BUG();
80925 + }
80926 +#endif
80927 +}
80928 +
80929 static void unmap_region(struct mm_struct *mm,
80930 struct vm_area_struct *vma, struct vm_area_struct *prev,
80931 unsigned long start, unsigned long end);
80932 @@ -67,22 +78,32 @@ static void unmap_region(struct mm_struct *mm,
80933 * x: (no) no x: (no) yes x: (no) yes x: (yes) yes
80934 *
80935 */
80936 -pgprot_t protection_map[16] = {
80937 +pgprot_t protection_map[16] __read_only = {
80938 __P000, __P001, __P010, __P011, __P100, __P101, __P110, __P111,
80939 __S000, __S001, __S010, __S011, __S100, __S101, __S110, __S111
80940 };
80941
80942 -pgprot_t vm_get_page_prot(unsigned long vm_flags)
80943 +pgprot_t vm_get_page_prot(vm_flags_t vm_flags)
80944 {
80945 - return __pgprot(pgprot_val(protection_map[vm_flags &
80946 + pgprot_t prot = __pgprot(pgprot_val(protection_map[vm_flags &
80947 (VM_READ|VM_WRITE|VM_EXEC|VM_SHARED)]) |
80948 pgprot_val(arch_vm_get_page_prot(vm_flags)));
80949 +
80950 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
80951 + if (!(__supported_pte_mask & _PAGE_NX) &&
80952 + (vm_flags & (VM_PAGEEXEC | VM_EXEC)) == VM_PAGEEXEC &&
80953 + (vm_flags & (VM_READ | VM_WRITE)))
80954 + prot = __pgprot(pte_val(pte_exprotect(__pte(pgprot_val(prot)))));
80955 +#endif
80956 +
80957 + return prot;
80958 }
80959 EXPORT_SYMBOL(vm_get_page_prot);
80960
80961 int sysctl_overcommit_memory __read_mostly = OVERCOMMIT_GUESS; /* heuristic overcommit */
80962 int sysctl_overcommit_ratio __read_mostly = 50; /* default is 50% */
80963 int sysctl_max_map_count __read_mostly = DEFAULT_MAX_MAP_COUNT;
80964 +unsigned long sysctl_heap_stack_gap __read_mostly = 64*1024;
80965 /*
80966 * Make sure vm_committed_as in one cacheline and not cacheline shared with
80967 * other variables. It can be updated by several CPUs frequently.
80968 @@ -238,6 +259,7 @@ static struct vm_area_struct *remove_vma(struct vm_area_struct *vma)
80969 struct vm_area_struct *next = vma->vm_next;
80970
80971 might_sleep();
80972 + BUG_ON(vma->vm_mirror);
80973 if (vma->vm_ops && vma->vm_ops->close)
80974 vma->vm_ops->close(vma);
80975 if (vma->vm_file)
80976 @@ -281,6 +303,7 @@ SYSCALL_DEFINE1(brk, unsigned long, brk)
80977 * not page aligned -Ram Gupta
80978 */
80979 rlim = rlimit(RLIMIT_DATA);
80980 + gr_learn_resource(current, RLIMIT_DATA, (brk - mm->start_brk) + (mm->end_data - mm->start_data), 1);
80981 if (rlim < RLIM_INFINITY && (brk - mm->start_brk) +
80982 (mm->end_data - mm->start_data) > rlim)
80983 goto out;
80984 @@ -888,6 +911,12 @@ static int
80985 can_vma_merge_before(struct vm_area_struct *vma, unsigned long vm_flags,
80986 struct anon_vma *anon_vma, struct file *file, pgoff_t vm_pgoff)
80987 {
80988 +
80989 +#ifdef CONFIG_PAX_SEGMEXEC
80990 + if ((vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) && vma->vm_start == SEGMEXEC_TASK_SIZE)
80991 + return 0;
80992 +#endif
80993 +
80994 if (is_mergeable_vma(vma, file, vm_flags) &&
80995 is_mergeable_anon_vma(anon_vma, vma->anon_vma, vma)) {
80996 if (vma->vm_pgoff == vm_pgoff)
80997 @@ -907,6 +936,12 @@ static int
80998 can_vma_merge_after(struct vm_area_struct *vma, unsigned long vm_flags,
80999 struct anon_vma *anon_vma, struct file *file, pgoff_t vm_pgoff)
81000 {
81001 +
81002 +#ifdef CONFIG_PAX_SEGMEXEC
81003 + if ((vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) && vma->vm_end == SEGMEXEC_TASK_SIZE)
81004 + return 0;
81005 +#endif
81006 +
81007 if (is_mergeable_vma(vma, file, vm_flags) &&
81008 is_mergeable_anon_vma(anon_vma, vma->anon_vma, vma)) {
81009 pgoff_t vm_pglen;
81010 @@ -949,13 +984,20 @@ can_vma_merge_after(struct vm_area_struct *vma, unsigned long vm_flags,
81011 struct vm_area_struct *vma_merge(struct mm_struct *mm,
81012 struct vm_area_struct *prev, unsigned long addr,
81013 unsigned long end, unsigned long vm_flags,
81014 - struct anon_vma *anon_vma, struct file *file,
81015 + struct anon_vma *anon_vma, struct file *file,
81016 pgoff_t pgoff, struct mempolicy *policy)
81017 {
81018 pgoff_t pglen = (end - addr) >> PAGE_SHIFT;
81019 struct vm_area_struct *area, *next;
81020 int err;
81021
81022 +#ifdef CONFIG_PAX_SEGMEXEC
81023 + unsigned long addr_m = addr + SEGMEXEC_TASK_SIZE, end_m = end + SEGMEXEC_TASK_SIZE;
81024 + struct vm_area_struct *area_m = NULL, *next_m = NULL, *prev_m = NULL;
81025 +
81026 + BUG_ON((mm->pax_flags & MF_PAX_SEGMEXEC) && SEGMEXEC_TASK_SIZE < end);
81027 +#endif
81028 +
81029 /*
81030 * We later require that vma->vm_flags == vm_flags,
81031 * so this tests vma->vm_flags & VM_SPECIAL, too.
81032 @@ -971,6 +1013,15 @@ struct vm_area_struct *vma_merge(struct mm_struct *mm,
81033 if (next && next->vm_end == end) /* cases 6, 7, 8 */
81034 next = next->vm_next;
81035
81036 +#ifdef CONFIG_PAX_SEGMEXEC
81037 + if (prev)
81038 + prev_m = pax_find_mirror_vma(prev);
81039 + if (area)
81040 + area_m = pax_find_mirror_vma(area);
81041 + if (next)
81042 + next_m = pax_find_mirror_vma(next);
81043 +#endif
81044 +
81045 /*
81046 * Can it merge with the predecessor?
81047 */
81048 @@ -990,9 +1041,24 @@ struct vm_area_struct *vma_merge(struct mm_struct *mm,
81049 /* cases 1, 6 */
81050 err = vma_adjust(prev, prev->vm_start,
81051 next->vm_end, prev->vm_pgoff, NULL);
81052 - } else /* cases 2, 5, 7 */
81053 +
81054 +#ifdef CONFIG_PAX_SEGMEXEC
81055 + if (!err && prev_m)
81056 + err = vma_adjust(prev_m, prev_m->vm_start,
81057 + next_m->vm_end, prev_m->vm_pgoff, NULL);
81058 +#endif
81059 +
81060 + } else { /* cases 2, 5, 7 */
81061 err = vma_adjust(prev, prev->vm_start,
81062 end, prev->vm_pgoff, NULL);
81063 +
81064 +#ifdef CONFIG_PAX_SEGMEXEC
81065 + if (!err && prev_m)
81066 + err = vma_adjust(prev_m, prev_m->vm_start,
81067 + end_m, prev_m->vm_pgoff, NULL);
81068 +#endif
81069 +
81070 + }
81071 if (err)
81072 return NULL;
81073 khugepaged_enter_vma_merge(prev);
81074 @@ -1006,12 +1072,27 @@ struct vm_area_struct *vma_merge(struct mm_struct *mm,
81075 mpol_equal(policy, vma_policy(next)) &&
81076 can_vma_merge_before(next, vm_flags,
81077 anon_vma, file, pgoff+pglen)) {
81078 - if (prev && addr < prev->vm_end) /* case 4 */
81079 + if (prev && addr < prev->vm_end) { /* case 4 */
81080 err = vma_adjust(prev, prev->vm_start,
81081 addr, prev->vm_pgoff, NULL);
81082 - else /* cases 3, 8 */
81083 +
81084 +#ifdef CONFIG_PAX_SEGMEXEC
81085 + if (!err && prev_m)
81086 + err = vma_adjust(prev_m, prev_m->vm_start,
81087 + addr_m, prev_m->vm_pgoff, NULL);
81088 +#endif
81089 +
81090 + } else { /* cases 3, 8 */
81091 err = vma_adjust(area, addr, next->vm_end,
81092 next->vm_pgoff - pglen, NULL);
81093 +
81094 +#ifdef CONFIG_PAX_SEGMEXEC
81095 + if (!err && area_m)
81096 + err = vma_adjust(area_m, addr_m, next_m->vm_end,
81097 + next_m->vm_pgoff - pglen, NULL);
81098 +#endif
81099 +
81100 + }
81101 if (err)
81102 return NULL;
81103 khugepaged_enter_vma_merge(area);
81104 @@ -1120,16 +1201,13 @@ none:
81105 void vm_stat_account(struct mm_struct *mm, unsigned long flags,
81106 struct file *file, long pages)
81107 {
81108 - const unsigned long stack_flags
81109 - = VM_STACK_FLAGS & (VM_GROWSUP|VM_GROWSDOWN);
81110 -
81111 mm->total_vm += pages;
81112
81113 if (file) {
81114 mm->shared_vm += pages;
81115 if ((flags & (VM_EXEC|VM_WRITE)) == VM_EXEC)
81116 mm->exec_vm += pages;
81117 - } else if (flags & stack_flags)
81118 + } else if (flags & (VM_GROWSUP|VM_GROWSDOWN))
81119 mm->stack_vm += pages;
81120 }
81121 #endif /* CONFIG_PROC_FS */
81122 @@ -1165,7 +1243,7 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
81123 * (the exception is when the underlying filesystem is noexec
81124 * mounted, in which case we dont add PROT_EXEC.)
81125 */
81126 - if ((prot & PROT_READ) && (current->personality & READ_IMPLIES_EXEC))
81127 + if ((prot & (PROT_READ | PROT_WRITE)) && (current->personality & READ_IMPLIES_EXEC))
81128 if (!(file && (file->f_path.mnt->mnt_flags & MNT_NOEXEC)))
81129 prot |= PROT_EXEC;
81130
81131 @@ -1191,7 +1269,7 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
81132 /* Obtain the address to map to. we verify (or select) it and ensure
81133 * that it represents a valid section of the address space.
81134 */
81135 - addr = get_unmapped_area(file, addr, len, pgoff, flags);
81136 + addr = get_unmapped_area(file, addr, len, pgoff, flags | ((prot & PROT_EXEC) ? MAP_EXECUTABLE : 0));
81137 if (addr & ~PAGE_MASK)
81138 return addr;
81139
81140 @@ -1202,6 +1280,36 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
81141 vm_flags = calc_vm_prot_bits(prot) | calc_vm_flag_bits(flags) |
81142 mm->def_flags | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC;
81143
81144 +#ifdef CONFIG_PAX_MPROTECT
81145 + if (mm->pax_flags & MF_PAX_MPROTECT) {
81146 +#ifndef CONFIG_PAX_MPROTECT_COMPAT
81147 + if ((vm_flags & (VM_WRITE | VM_EXEC)) == (VM_WRITE | VM_EXEC)) {
81148 + gr_log_rwxmmap(file);
81149 +
81150 +#ifdef CONFIG_PAX_EMUPLT
81151 + vm_flags &= ~VM_EXEC;
81152 +#else
81153 + return -EPERM;
81154 +#endif
81155 +
81156 + }
81157 +
81158 + if (!(vm_flags & VM_EXEC))
81159 + vm_flags &= ~VM_MAYEXEC;
81160 +#else
81161 + if ((vm_flags & (VM_WRITE | VM_EXEC)) != VM_EXEC)
81162 + vm_flags &= ~(VM_EXEC | VM_MAYEXEC);
81163 +#endif
81164 + else
81165 + vm_flags &= ~VM_MAYWRITE;
81166 + }
81167 +#endif
81168 +
81169 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
81170 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && file)
81171 + vm_flags &= ~VM_PAGEEXEC;
81172 +#endif
81173 +
81174 if (flags & MAP_LOCKED)
81175 if (!can_do_mlock())
81176 return -EPERM;
81177 @@ -1213,6 +1321,7 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
81178 locked += mm->locked_vm;
81179 lock_limit = rlimit(RLIMIT_MEMLOCK);
81180 lock_limit >>= PAGE_SHIFT;
81181 + gr_learn_resource(current, RLIMIT_MEMLOCK, locked << PAGE_SHIFT, 1);
81182 if (locked > lock_limit && !capable(CAP_IPC_LOCK))
81183 return -EAGAIN;
81184 }
81185 @@ -1279,6 +1388,9 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
81186 }
81187 }
81188
81189 + if (!gr_acl_handle_mmap(file, prot))
81190 + return -EACCES;
81191 +
81192 return mmap_region(file, addr, len, flags, vm_flags, pgoff);
81193 }
81194
81195 @@ -1356,7 +1468,7 @@ int vma_wants_writenotify(struct vm_area_struct *vma)
81196 vm_flags_t vm_flags = vma->vm_flags;
81197
81198 /* If it was private or non-writable, the write bit is already clear */
81199 - if ((vm_flags & (VM_WRITE|VM_SHARED)) != ((VM_WRITE|VM_SHARED)))
81200 + if ((vm_flags & (VM_WRITE|VM_SHARED)) != (VM_WRITE|VM_SHARED))
81201 return 0;
81202
81203 /* The backer wishes to know when pages are first written to? */
81204 @@ -1405,13 +1517,22 @@ unsigned long mmap_region(struct file *file, unsigned long addr,
81205 unsigned long charged = 0;
81206 struct inode *inode = file ? file->f_path.dentry->d_inode : NULL;
81207
81208 +#ifdef CONFIG_PAX_SEGMEXEC
81209 + struct vm_area_struct *vma_m = NULL;
81210 +#endif
81211 +
81212 + /*
81213 + * mm->mmap_sem is required to protect against another thread
81214 + * changing the mappings in case we sleep.
81215 + */
81216 + verify_mm_writelocked(mm);
81217 +
81218 /* Clear old maps */
81219 error = -ENOMEM;
81220 -munmap_back:
81221 if (find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent)) {
81222 if (do_munmap(mm, addr, len))
81223 return -ENOMEM;
81224 - goto munmap_back;
81225 + BUG_ON(find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent));
81226 }
81227
81228 /* Check against address space limit. */
81229 @@ -1460,6 +1581,16 @@ munmap_back:
81230 goto unacct_error;
81231 }
81232
81233 +#ifdef CONFIG_PAX_SEGMEXEC
81234 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (vm_flags & VM_EXEC)) {
81235 + vma_m = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
81236 + if (!vma_m) {
81237 + error = -ENOMEM;
81238 + goto free_vma;
81239 + }
81240 + }
81241 +#endif
81242 +
81243 vma->vm_mm = mm;
81244 vma->vm_start = addr;
81245 vma->vm_end = addr + len;
81246 @@ -1484,6 +1615,13 @@ munmap_back:
81247 if (error)
81248 goto unmap_and_free_vma;
81249
81250 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
81251 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && !(vma->vm_flags & VM_SPECIAL)) {
81252 + vma->vm_flags |= VM_PAGEEXEC;
81253 + vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
81254 + }
81255 +#endif
81256 +
81257 /* Can addr have changed??
81258 *
81259 * Answer: Yes, several device drivers can do it in their
81260 @@ -1522,6 +1660,11 @@ munmap_back:
81261 vma_link(mm, vma, prev, rb_link, rb_parent);
81262 file = vma->vm_file;
81263
81264 +#ifdef CONFIG_PAX_SEGMEXEC
81265 + if (vma_m)
81266 + BUG_ON(pax_mirror_vma(vma_m, vma));
81267 +#endif
81268 +
81269 /* Once vma denies write, undo our temporary denial count */
81270 if (correct_wcount)
81271 atomic_inc(&inode->i_writecount);
81272 @@ -1529,6 +1672,7 @@ out:
81273 perf_event_mmap(vma);
81274
81275 vm_stat_account(mm, vm_flags, file, len >> PAGE_SHIFT);
81276 + track_exec_limit(mm, addr, addr + len, vm_flags);
81277 if (vm_flags & VM_LOCKED) {
81278 if (!mlock_vma_pages_range(vma, addr, addr + len))
81279 mm->locked_vm += (len >> PAGE_SHIFT);
81280 @@ -1550,6 +1694,12 @@ unmap_and_free_vma:
81281 unmap_region(mm, vma, prev, vma->vm_start, vma->vm_end);
81282 charged = 0;
81283 free_vma:
81284 +
81285 +#ifdef CONFIG_PAX_SEGMEXEC
81286 + if (vma_m)
81287 + kmem_cache_free(vm_area_cachep, vma_m);
81288 +#endif
81289 +
81290 kmem_cache_free(vm_area_cachep, vma);
81291 unacct_error:
81292 if (charged)
81293 @@ -1557,6 +1707,62 @@ unacct_error:
81294 return error;
81295 }
81296
81297 +#ifdef CONFIG_GRKERNSEC_RAND_THREADSTACK
81298 +unsigned long gr_rand_threadstack_offset(const struct mm_struct *mm, const struct file *filp, unsigned long flags)
81299 +{
81300 + if ((mm->pax_flags & MF_PAX_RANDMMAP) && !filp && (flags & MAP_STACK))
81301 + return (random32() & 0xFF) << PAGE_SHIFT;
81302 +
81303 + return 0;
81304 +}
81305 +#endif
81306 +
81307 +bool check_heap_stack_gap(const struct vm_area_struct *vma, unsigned long addr, unsigned long len, unsigned long offset)
81308 +{
81309 + if (!vma) {
81310 +#ifdef CONFIG_STACK_GROWSUP
81311 + if (addr > sysctl_heap_stack_gap)
81312 + vma = find_vma(current->mm, addr - sysctl_heap_stack_gap);
81313 + else
81314 + vma = find_vma(current->mm, 0);
81315 + if (vma && (vma->vm_flags & VM_GROWSUP))
81316 + return false;
81317 +#endif
81318 + return true;
81319 + }
81320 +
81321 + if (addr + len > vma->vm_start)
81322 + return false;
81323 +
81324 + if (vma->vm_flags & VM_GROWSDOWN)
81325 + return sysctl_heap_stack_gap <= vma->vm_start - addr - len;
81326 +#ifdef CONFIG_STACK_GROWSUP
81327 + else if (vma->vm_prev && (vma->vm_prev->vm_flags & VM_GROWSUP))
81328 + return addr - vma->vm_prev->vm_end <= sysctl_heap_stack_gap;
81329 +#endif
81330 + else if (offset)
81331 + return offset <= vma->vm_start - addr - len;
81332 +
81333 + return true;
81334 +}
81335 +
81336 +unsigned long skip_heap_stack_gap(const struct vm_area_struct *vma, unsigned long len, unsigned long offset)
81337 +{
81338 + if (vma->vm_start < len)
81339 + return -ENOMEM;
81340 +
81341 + if (!(vma->vm_flags & VM_GROWSDOWN)) {
81342 + if (offset <= vma->vm_start - len)
81343 + return vma->vm_start - len - offset;
81344 + else
81345 + return -ENOMEM;
81346 + }
81347 +
81348 + if (sysctl_heap_stack_gap <= vma->vm_start - len)
81349 + return vma->vm_start - len - sysctl_heap_stack_gap;
81350 + return -ENOMEM;
81351 +}
81352 +
81353 unsigned long unmapped_area(struct vm_unmapped_area_info *info)
81354 {
81355 /*
81356 @@ -1776,6 +1982,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
81357 struct mm_struct *mm = current->mm;
81358 struct vm_area_struct *vma;
81359 struct vm_unmapped_area_info info;
81360 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
81361
81362 if (len > TASK_SIZE)
81363 return -ENOMEM;
81364 @@ -1783,17 +1990,26 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
81365 if (flags & MAP_FIXED)
81366 return addr;
81367
81368 +#ifdef CONFIG_PAX_RANDMMAP
81369 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
81370 +#endif
81371 +
81372 if (addr) {
81373 addr = PAGE_ALIGN(addr);
81374 vma = find_vma(mm, addr);
81375 - if (TASK_SIZE - len >= addr &&
81376 - (!vma || addr + len <= vma->vm_start))
81377 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
81378 return addr;
81379 }
81380
81381 info.flags = 0;
81382 info.length = len;
81383 info.low_limit = TASK_UNMAPPED_BASE;
81384 +
81385 +#ifdef CONFIG_PAX_RANDMMAP
81386 + if (mm->pax_flags & MF_PAX_RANDMMAP)
81387 + info.low_limit += mm->delta_mmap;
81388 +#endif
81389 +
81390 info.high_limit = TASK_SIZE;
81391 info.align_mask = 0;
81392 return vm_unmapped_area(&info);
81393 @@ -1802,10 +2018,16 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
81394
81395 void arch_unmap_area(struct mm_struct *mm, unsigned long addr)
81396 {
81397 +
81398 +#ifdef CONFIG_PAX_SEGMEXEC
81399 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && SEGMEXEC_TASK_SIZE <= addr)
81400 + return;
81401 +#endif
81402 +
81403 /*
81404 * Is this a new hole at the lowest possible address?
81405 */
81406 - if (addr >= TASK_UNMAPPED_BASE && addr < mm->free_area_cache)
81407 + if (addr >= mm->mmap_base && addr < mm->free_area_cache)
81408 mm->free_area_cache = addr;
81409 }
81410
81411 @@ -1823,6 +2045,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
81412 struct mm_struct *mm = current->mm;
81413 unsigned long addr = addr0;
81414 struct vm_unmapped_area_info info;
81415 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
81416
81417 /* requested length too big for entire address space */
81418 if (len > TASK_SIZE)
81419 @@ -1831,12 +2054,15 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
81420 if (flags & MAP_FIXED)
81421 return addr;
81422
81423 +#ifdef CONFIG_PAX_RANDMMAP
81424 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
81425 +#endif
81426 +
81427 /* requesting a specific address */
81428 if (addr) {
81429 addr = PAGE_ALIGN(addr);
81430 vma = find_vma(mm, addr);
81431 - if (TASK_SIZE - len >= addr &&
81432 - (!vma || addr + len <= vma->vm_start))
81433 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
81434 return addr;
81435 }
81436
81437 @@ -1857,6 +2083,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
81438 VM_BUG_ON(addr != -ENOMEM);
81439 info.flags = 0;
81440 info.low_limit = TASK_UNMAPPED_BASE;
81441 +
81442 +#ifdef CONFIG_PAX_RANDMMAP
81443 + if (mm->pax_flags & MF_PAX_RANDMMAP)
81444 + info.low_limit += mm->delta_mmap;
81445 +#endif
81446 +
81447 info.high_limit = TASK_SIZE;
81448 addr = vm_unmapped_area(&info);
81449 }
81450 @@ -1867,6 +2099,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
81451
81452 void arch_unmap_area_topdown(struct mm_struct *mm, unsigned long addr)
81453 {
81454 +
81455 +#ifdef CONFIG_PAX_SEGMEXEC
81456 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && SEGMEXEC_TASK_SIZE <= addr)
81457 + return;
81458 +#endif
81459 +
81460 /*
81461 * Is this a new hole at the highest possible address?
81462 */
81463 @@ -1874,8 +2112,10 @@ void arch_unmap_area_topdown(struct mm_struct *mm, unsigned long addr)
81464 mm->free_area_cache = addr;
81465
81466 /* dont allow allocations above current base */
81467 - if (mm->free_area_cache > mm->mmap_base)
81468 + if (mm->free_area_cache > mm->mmap_base) {
81469 mm->free_area_cache = mm->mmap_base;
81470 + mm->cached_hole_size = ~0UL;
81471 + }
81472 }
81473
81474 unsigned long
81475 @@ -1974,6 +2214,28 @@ find_vma_prev(struct mm_struct *mm, unsigned long addr,
81476 return vma;
81477 }
81478
81479 +#ifdef CONFIG_PAX_SEGMEXEC
81480 +struct vm_area_struct *pax_find_mirror_vma(struct vm_area_struct *vma)
81481 +{
81482 + struct vm_area_struct *vma_m;
81483 +
81484 + BUG_ON(!vma || vma->vm_start >= vma->vm_end);
81485 + if (!(vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) || !(vma->vm_flags & VM_EXEC)) {
81486 + BUG_ON(vma->vm_mirror);
81487 + return NULL;
81488 + }
81489 + BUG_ON(vma->vm_start < SEGMEXEC_TASK_SIZE && SEGMEXEC_TASK_SIZE < vma->vm_end);
81490 + vma_m = vma->vm_mirror;
81491 + BUG_ON(!vma_m || vma_m->vm_mirror != vma);
81492 + BUG_ON(vma->vm_file != vma_m->vm_file);
81493 + BUG_ON(vma->vm_end - vma->vm_start != vma_m->vm_end - vma_m->vm_start);
81494 + BUG_ON(vma->vm_pgoff != vma_m->vm_pgoff);
81495 + BUG_ON(vma->anon_vma != vma_m->anon_vma && vma->anon_vma->root != vma_m->anon_vma->root);
81496 + BUG_ON((vma->vm_flags ^ vma_m->vm_flags) & ~(VM_WRITE | VM_MAYWRITE | VM_ACCOUNT | VM_LOCKED));
81497 + return vma_m;
81498 +}
81499 +#endif
81500 +
81501 /*
81502 * Verify that the stack growth is acceptable and
81503 * update accounting. This is shared with both the
81504 @@ -1990,6 +2252,7 @@ static int acct_stack_growth(struct vm_area_struct *vma, unsigned long size, uns
81505 return -ENOMEM;
81506
81507 /* Stack limit test */
81508 + gr_learn_resource(current, RLIMIT_STACK, size, 1);
81509 if (size > ACCESS_ONCE(rlim[RLIMIT_STACK].rlim_cur))
81510 return -ENOMEM;
81511
81512 @@ -2000,6 +2263,7 @@ static int acct_stack_growth(struct vm_area_struct *vma, unsigned long size, uns
81513 locked = mm->locked_vm + grow;
81514 limit = ACCESS_ONCE(rlim[RLIMIT_MEMLOCK].rlim_cur);
81515 limit >>= PAGE_SHIFT;
81516 + gr_learn_resource(current, RLIMIT_MEMLOCK, locked << PAGE_SHIFT, 1);
81517 if (locked > limit && !capable(CAP_IPC_LOCK))
81518 return -ENOMEM;
81519 }
81520 @@ -2029,37 +2293,48 @@ static int acct_stack_growth(struct vm_area_struct *vma, unsigned long size, uns
81521 * PA-RISC uses this for its stack; IA64 for its Register Backing Store.
81522 * vma is the last one with address > vma->vm_end. Have to extend vma.
81523 */
81524 +#ifndef CONFIG_IA64
81525 +static
81526 +#endif
81527 int expand_upwards(struct vm_area_struct *vma, unsigned long address)
81528 {
81529 int error;
81530 + bool locknext;
81531
81532 if (!(vma->vm_flags & VM_GROWSUP))
81533 return -EFAULT;
81534
81535 + /* Also guard against wrapping around to address 0. */
81536 + if (address < PAGE_ALIGN(address+1))
81537 + address = PAGE_ALIGN(address+1);
81538 + else
81539 + return -ENOMEM;
81540 +
81541 /*
81542 * We must make sure the anon_vma is allocated
81543 * so that the anon_vma locking is not a noop.
81544 */
81545 if (unlikely(anon_vma_prepare(vma)))
81546 return -ENOMEM;
81547 + locknext = vma->vm_next && (vma->vm_next->vm_flags & VM_GROWSDOWN);
81548 + if (locknext && anon_vma_prepare(vma->vm_next))
81549 + return -ENOMEM;
81550 vma_lock_anon_vma(vma);
81551 + if (locknext)
81552 + vma_lock_anon_vma(vma->vm_next);
81553
81554 /*
81555 * vma->vm_start/vm_end cannot change under us because the caller
81556 * is required to hold the mmap_sem in read mode. We need the
81557 - * anon_vma lock to serialize against concurrent expand_stacks.
81558 - * Also guard against wrapping around to address 0.
81559 + * anon_vma locks to serialize against concurrent expand_stacks
81560 + * and expand_upwards.
81561 */
81562 - if (address < PAGE_ALIGN(address+4))
81563 - address = PAGE_ALIGN(address+4);
81564 - else {
81565 - vma_unlock_anon_vma(vma);
81566 - return -ENOMEM;
81567 - }
81568 error = 0;
81569
81570 /* Somebody else might have raced and expanded it already */
81571 - if (address > vma->vm_end) {
81572 + 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)
81573 + error = -ENOMEM;
81574 + else if (address > vma->vm_end && (!locknext || vma->vm_next->vm_start >= address)) {
81575 unsigned long size, grow;
81576
81577 size = address - vma->vm_start;
81578 @@ -2094,6 +2369,8 @@ int expand_upwards(struct vm_area_struct *vma, unsigned long address)
81579 }
81580 }
81581 }
81582 + if (locknext)
81583 + vma_unlock_anon_vma(vma->vm_next);
81584 vma_unlock_anon_vma(vma);
81585 khugepaged_enter_vma_merge(vma);
81586 validate_mm(vma->vm_mm);
81587 @@ -2108,6 +2385,8 @@ int expand_downwards(struct vm_area_struct *vma,
81588 unsigned long address)
81589 {
81590 int error;
81591 + bool lockprev = false;
81592 + struct vm_area_struct *prev;
81593
81594 /*
81595 * We must make sure the anon_vma is allocated
81596 @@ -2121,6 +2400,15 @@ int expand_downwards(struct vm_area_struct *vma,
81597 if (error)
81598 return error;
81599
81600 + prev = vma->vm_prev;
81601 +#if defined(CONFIG_STACK_GROWSUP) || defined(CONFIG_IA64)
81602 + lockprev = prev && (prev->vm_flags & VM_GROWSUP);
81603 +#endif
81604 + if (lockprev && anon_vma_prepare(prev))
81605 + return -ENOMEM;
81606 + if (lockprev)
81607 + vma_lock_anon_vma(prev);
81608 +
81609 vma_lock_anon_vma(vma);
81610
81611 /*
81612 @@ -2130,9 +2418,17 @@ int expand_downwards(struct vm_area_struct *vma,
81613 */
81614
81615 /* Somebody else might have raced and expanded it already */
81616 - if (address < vma->vm_start) {
81617 + if (prev && (prev->vm_flags & (VM_READ | VM_WRITE | VM_EXEC)) && address - prev->vm_end < sysctl_heap_stack_gap)
81618 + error = -ENOMEM;
81619 + else if (address < vma->vm_start && (!lockprev || prev->vm_end <= address)) {
81620 unsigned long size, grow;
81621
81622 +#ifdef CONFIG_PAX_SEGMEXEC
81623 + struct vm_area_struct *vma_m;
81624 +
81625 + vma_m = pax_find_mirror_vma(vma);
81626 +#endif
81627 +
81628 size = vma->vm_end - address;
81629 grow = (vma->vm_start - address) >> PAGE_SHIFT;
81630
81631 @@ -2157,6 +2453,18 @@ int expand_downwards(struct vm_area_struct *vma,
81632 vma->vm_pgoff -= grow;
81633 anon_vma_interval_tree_post_update_vma(vma);
81634 vma_gap_update(vma);
81635 + track_exec_limit(vma->vm_mm, vma->vm_start, vma->vm_end, vma->vm_flags);
81636 +
81637 +#ifdef CONFIG_PAX_SEGMEXEC
81638 + if (vma_m) {
81639 + anon_vma_interval_tree_pre_update_vma(vma_m);
81640 + vma_m->vm_start -= grow << PAGE_SHIFT;
81641 + vma_m->vm_pgoff -= grow;
81642 + anon_vma_interval_tree_post_update_vma(vma_m);
81643 + vma_gap_update(vma_m);
81644 + }
81645 +#endif
81646 +
81647 spin_unlock(&vma->vm_mm->page_table_lock);
81648
81649 perf_event_mmap(vma);
81650 @@ -2263,6 +2571,13 @@ static void remove_vma_list(struct mm_struct *mm, struct vm_area_struct *vma)
81651 do {
81652 long nrpages = vma_pages(vma);
81653
81654 +#ifdef CONFIG_PAX_SEGMEXEC
81655 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_start >= SEGMEXEC_TASK_SIZE)) {
81656 + vma = remove_vma(vma);
81657 + continue;
81658 + }
81659 +#endif
81660 +
81661 if (vma->vm_flags & VM_ACCOUNT)
81662 nr_accounted += nrpages;
81663 vm_stat_account(mm, vma->vm_flags, vma->vm_file, -nrpages);
81664 @@ -2308,6 +2623,16 @@ detach_vmas_to_be_unmapped(struct mm_struct *mm, struct vm_area_struct *vma,
81665 insertion_point = (prev ? &prev->vm_next : &mm->mmap);
81666 vma->vm_prev = NULL;
81667 do {
81668 +
81669 +#ifdef CONFIG_PAX_SEGMEXEC
81670 + if (vma->vm_mirror) {
81671 + BUG_ON(!vma->vm_mirror->vm_mirror || vma->vm_mirror->vm_mirror != vma);
81672 + vma->vm_mirror->vm_mirror = NULL;
81673 + vma->vm_mirror->vm_flags &= ~VM_EXEC;
81674 + vma->vm_mirror = NULL;
81675 + }
81676 +#endif
81677 +
81678 vma_rb_erase(vma, &mm->mm_rb);
81679 mm->map_count--;
81680 tail_vma = vma;
81681 @@ -2339,14 +2664,33 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
81682 struct vm_area_struct *new;
81683 int err = -ENOMEM;
81684
81685 +#ifdef CONFIG_PAX_SEGMEXEC
81686 + struct vm_area_struct *vma_m, *new_m = NULL;
81687 + unsigned long addr_m = addr + SEGMEXEC_TASK_SIZE;
81688 +#endif
81689 +
81690 if (is_vm_hugetlb_page(vma) && (addr &
81691 ~(huge_page_mask(hstate_vma(vma)))))
81692 return -EINVAL;
81693
81694 +#ifdef CONFIG_PAX_SEGMEXEC
81695 + vma_m = pax_find_mirror_vma(vma);
81696 +#endif
81697 +
81698 new = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
81699 if (!new)
81700 goto out_err;
81701
81702 +#ifdef CONFIG_PAX_SEGMEXEC
81703 + if (vma_m) {
81704 + new_m = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
81705 + if (!new_m) {
81706 + kmem_cache_free(vm_area_cachep, new);
81707 + goto out_err;
81708 + }
81709 + }
81710 +#endif
81711 +
81712 /* most fields are the same, copy all, and then fixup */
81713 *new = *vma;
81714
81715 @@ -2359,6 +2703,22 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
81716 new->vm_pgoff += ((addr - vma->vm_start) >> PAGE_SHIFT);
81717 }
81718
81719 +#ifdef CONFIG_PAX_SEGMEXEC
81720 + if (vma_m) {
81721 + *new_m = *vma_m;
81722 + INIT_LIST_HEAD(&new_m->anon_vma_chain);
81723 + new_m->vm_mirror = new;
81724 + new->vm_mirror = new_m;
81725 +
81726 + if (new_below)
81727 + new_m->vm_end = addr_m;
81728 + else {
81729 + new_m->vm_start = addr_m;
81730 + new_m->vm_pgoff += ((addr_m - vma_m->vm_start) >> PAGE_SHIFT);
81731 + }
81732 + }
81733 +#endif
81734 +
81735 pol = mpol_dup(vma_policy(vma));
81736 if (IS_ERR(pol)) {
81737 err = PTR_ERR(pol);
81738 @@ -2381,6 +2741,36 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
81739 else
81740 err = vma_adjust(vma, vma->vm_start, addr, vma->vm_pgoff, new);
81741
81742 +#ifdef CONFIG_PAX_SEGMEXEC
81743 + if (!err && vma_m) {
81744 + if (anon_vma_clone(new_m, vma_m))
81745 + goto out_free_mpol;
81746 +
81747 + mpol_get(pol);
81748 + vma_set_policy(new_m, pol);
81749 +
81750 + if (new_m->vm_file)
81751 + get_file(new_m->vm_file);
81752 +
81753 + if (new_m->vm_ops && new_m->vm_ops->open)
81754 + new_m->vm_ops->open(new_m);
81755 +
81756 + if (new_below)
81757 + err = vma_adjust(vma_m, addr_m, vma_m->vm_end, vma_m->vm_pgoff +
81758 + ((addr_m - new_m->vm_start) >> PAGE_SHIFT), new_m);
81759 + else
81760 + err = vma_adjust(vma_m, vma_m->vm_start, addr_m, vma_m->vm_pgoff, new_m);
81761 +
81762 + if (err) {
81763 + if (new_m->vm_ops && new_m->vm_ops->close)
81764 + new_m->vm_ops->close(new_m);
81765 + if (new_m->vm_file)
81766 + fput(new_m->vm_file);
81767 + mpol_put(pol);
81768 + }
81769 + }
81770 +#endif
81771 +
81772 /* Success. */
81773 if (!err)
81774 return 0;
81775 @@ -2390,10 +2780,18 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
81776 new->vm_ops->close(new);
81777 if (new->vm_file)
81778 fput(new->vm_file);
81779 - unlink_anon_vmas(new);
81780 out_free_mpol:
81781 mpol_put(pol);
81782 out_free_vma:
81783 +
81784 +#ifdef CONFIG_PAX_SEGMEXEC
81785 + if (new_m) {
81786 + unlink_anon_vmas(new_m);
81787 + kmem_cache_free(vm_area_cachep, new_m);
81788 + }
81789 +#endif
81790 +
81791 + unlink_anon_vmas(new);
81792 kmem_cache_free(vm_area_cachep, new);
81793 out_err:
81794 return err;
81795 @@ -2406,6 +2804,15 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
81796 int split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
81797 unsigned long addr, int new_below)
81798 {
81799 +
81800 +#ifdef CONFIG_PAX_SEGMEXEC
81801 + if (mm->pax_flags & MF_PAX_SEGMEXEC) {
81802 + BUG_ON(vma->vm_end > SEGMEXEC_TASK_SIZE);
81803 + if (mm->map_count >= sysctl_max_map_count-1)
81804 + return -ENOMEM;
81805 + } else
81806 +#endif
81807 +
81808 if (mm->map_count >= sysctl_max_map_count)
81809 return -ENOMEM;
81810
81811 @@ -2417,11 +2824,30 @@ int split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
81812 * work. This now handles partial unmappings.
81813 * Jeremy Fitzhardinge <jeremy@goop.org>
81814 */
81815 +#ifdef CONFIG_PAX_SEGMEXEC
81816 int do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
81817 {
81818 + int ret = __do_munmap(mm, start, len);
81819 + if (ret || !(mm->pax_flags & MF_PAX_SEGMEXEC))
81820 + return ret;
81821 +
81822 + return __do_munmap(mm, start + SEGMEXEC_TASK_SIZE, len);
81823 +}
81824 +
81825 +int __do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
81826 +#else
81827 +int do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
81828 +#endif
81829 +{
81830 unsigned long end;
81831 struct vm_area_struct *vma, *prev, *last;
81832
81833 + /*
81834 + * mm->mmap_sem is required to protect against another thread
81835 + * changing the mappings in case we sleep.
81836 + */
81837 + verify_mm_writelocked(mm);
81838 +
81839 if ((start & ~PAGE_MASK) || start > TASK_SIZE || len > TASK_SIZE-start)
81840 return -EINVAL;
81841
81842 @@ -2496,6 +2922,8 @@ int do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
81843 /* Fix up all other VM information */
81844 remove_vma_list(mm, vma);
81845
81846 + track_exec_limit(mm, start, end, 0UL);
81847 +
81848 return 0;
81849 }
81850
81851 @@ -2504,6 +2932,13 @@ int vm_munmap(unsigned long start, size_t len)
81852 int ret;
81853 struct mm_struct *mm = current->mm;
81854
81855 +
81856 +#ifdef CONFIG_PAX_SEGMEXEC
81857 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) &&
81858 + (len > SEGMEXEC_TASK_SIZE || start > SEGMEXEC_TASK_SIZE-len))
81859 + return -EINVAL;
81860 +#endif
81861 +
81862 down_write(&mm->mmap_sem);
81863 ret = do_munmap(mm, start, len);
81864 up_write(&mm->mmap_sem);
81865 @@ -2517,16 +2952,6 @@ SYSCALL_DEFINE2(munmap, unsigned long, addr, size_t, len)
81866 return vm_munmap(addr, len);
81867 }
81868
81869 -static inline void verify_mm_writelocked(struct mm_struct *mm)
81870 -{
81871 -#ifdef CONFIG_DEBUG_VM
81872 - if (unlikely(down_read_trylock(&mm->mmap_sem))) {
81873 - WARN_ON(1);
81874 - up_read(&mm->mmap_sem);
81875 - }
81876 -#endif
81877 -}
81878 -
81879 /*
81880 * this is really a simplified "do_mmap". it only handles
81881 * anonymous maps. eventually we may be able to do some
81882 @@ -2540,6 +2965,7 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
81883 struct rb_node ** rb_link, * rb_parent;
81884 pgoff_t pgoff = addr >> PAGE_SHIFT;
81885 int error;
81886 + unsigned long charged;
81887
81888 len = PAGE_ALIGN(len);
81889 if (!len)
81890 @@ -2547,16 +2973,30 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
81891
81892 flags = VM_DATA_DEFAULT_FLAGS | VM_ACCOUNT | mm->def_flags;
81893
81894 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
81895 + if (mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
81896 + flags &= ~VM_EXEC;
81897 +
81898 +#ifdef CONFIG_PAX_MPROTECT
81899 + if (mm->pax_flags & MF_PAX_MPROTECT)
81900 + flags &= ~VM_MAYEXEC;
81901 +#endif
81902 +
81903 + }
81904 +#endif
81905 +
81906 error = get_unmapped_area(NULL, addr, len, 0, MAP_FIXED);
81907 if (error & ~PAGE_MASK)
81908 return error;
81909
81910 + charged = len >> PAGE_SHIFT;
81911 +
81912 /*
81913 * mlock MCL_FUTURE?
81914 */
81915 if (mm->def_flags & VM_LOCKED) {
81916 unsigned long locked, lock_limit;
81917 - locked = len >> PAGE_SHIFT;
81918 + locked = charged;
81919 locked += mm->locked_vm;
81920 lock_limit = rlimit(RLIMIT_MEMLOCK);
81921 lock_limit >>= PAGE_SHIFT;
81922 @@ -2573,21 +3013,20 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
81923 /*
81924 * Clear old maps. this also does some error checking for us
81925 */
81926 - munmap_back:
81927 if (find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent)) {
81928 if (do_munmap(mm, addr, len))
81929 return -ENOMEM;
81930 - goto munmap_back;
81931 + BUG_ON(find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent));
81932 }
81933
81934 /* Check against address space limits *after* clearing old maps... */
81935 - if (!may_expand_vm(mm, len >> PAGE_SHIFT))
81936 + if (!may_expand_vm(mm, charged))
81937 return -ENOMEM;
81938
81939 if (mm->map_count > sysctl_max_map_count)
81940 return -ENOMEM;
81941
81942 - if (security_vm_enough_memory_mm(mm, len >> PAGE_SHIFT))
81943 + if (security_vm_enough_memory_mm(mm, charged))
81944 return -ENOMEM;
81945
81946 /* Can we just expand an old private anonymous mapping? */
81947 @@ -2601,7 +3040,7 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
81948 */
81949 vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
81950 if (!vma) {
81951 - vm_unacct_memory(len >> PAGE_SHIFT);
81952 + vm_unacct_memory(charged);
81953 return -ENOMEM;
81954 }
81955
81956 @@ -2615,11 +3054,12 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
81957 vma_link(mm, vma, prev, rb_link, rb_parent);
81958 out:
81959 perf_event_mmap(vma);
81960 - mm->total_vm += len >> PAGE_SHIFT;
81961 + mm->total_vm += charged;
81962 if (flags & VM_LOCKED) {
81963 if (!mlock_vma_pages_range(vma, addr, addr + len))
81964 - mm->locked_vm += (len >> PAGE_SHIFT);
81965 + mm->locked_vm += charged;
81966 }
81967 + track_exec_limit(mm, addr, addr + len, flags);
81968 return addr;
81969 }
81970
81971 @@ -2677,6 +3117,7 @@ void exit_mmap(struct mm_struct *mm)
81972 while (vma) {
81973 if (vma->vm_flags & VM_ACCOUNT)
81974 nr_accounted += vma_pages(vma);
81975 + vma->vm_mirror = NULL;
81976 vma = remove_vma(vma);
81977 }
81978 vm_unacct_memory(nr_accounted);
81979 @@ -2693,6 +3134,13 @@ int insert_vm_struct(struct mm_struct *mm, struct vm_area_struct *vma)
81980 struct vm_area_struct *prev;
81981 struct rb_node **rb_link, *rb_parent;
81982
81983 +#ifdef CONFIG_PAX_SEGMEXEC
81984 + struct vm_area_struct *vma_m = NULL;
81985 +#endif
81986 +
81987 + if (security_mmap_addr(vma->vm_start))
81988 + return -EPERM;
81989 +
81990 /*
81991 * The vm_pgoff of a purely anonymous vma should be irrelevant
81992 * until its first write fault, when page's anon_vma and index
81993 @@ -2716,7 +3164,21 @@ int insert_vm_struct(struct mm_struct *mm, struct vm_area_struct *vma)
81994 security_vm_enough_memory_mm(mm, vma_pages(vma)))
81995 return -ENOMEM;
81996
81997 +#ifdef CONFIG_PAX_SEGMEXEC
81998 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_flags & VM_EXEC)) {
81999 + vma_m = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
82000 + if (!vma_m)
82001 + return -ENOMEM;
82002 + }
82003 +#endif
82004 +
82005 vma_link(mm, vma, prev, rb_link, rb_parent);
82006 +
82007 +#ifdef CONFIG_PAX_SEGMEXEC
82008 + if (vma_m)
82009 + BUG_ON(pax_mirror_vma(vma_m, vma));
82010 +#endif
82011 +
82012 return 0;
82013 }
82014
82015 @@ -2736,6 +3198,8 @@ struct vm_area_struct *copy_vma(struct vm_area_struct **vmap,
82016 struct mempolicy *pol;
82017 bool faulted_in_anon_vma = true;
82018
82019 + BUG_ON(vma->vm_mirror);
82020 +
82021 /*
82022 * If anonymous vma has not yet been faulted, update new pgoff
82023 * to match new location, to increase its chance of merging.
82024 @@ -2802,6 +3266,39 @@ struct vm_area_struct *copy_vma(struct vm_area_struct **vmap,
82025 return NULL;
82026 }
82027
82028 +#ifdef CONFIG_PAX_SEGMEXEC
82029 +long pax_mirror_vma(struct vm_area_struct *vma_m, struct vm_area_struct *vma)
82030 +{
82031 + struct vm_area_struct *prev_m;
82032 + struct rb_node **rb_link_m, *rb_parent_m;
82033 + struct mempolicy *pol_m;
82034 +
82035 + BUG_ON(!(vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) || !(vma->vm_flags & VM_EXEC));
82036 + BUG_ON(vma->vm_mirror || vma_m->vm_mirror);
82037 + BUG_ON(!mpol_equal(vma_policy(vma), vma_policy(vma_m)));
82038 + *vma_m = *vma;
82039 + INIT_LIST_HEAD(&vma_m->anon_vma_chain);
82040 + if (anon_vma_clone(vma_m, vma))
82041 + return -ENOMEM;
82042 + pol_m = vma_policy(vma_m);
82043 + mpol_get(pol_m);
82044 + vma_set_policy(vma_m, pol_m);
82045 + vma_m->vm_start += SEGMEXEC_TASK_SIZE;
82046 + vma_m->vm_end += SEGMEXEC_TASK_SIZE;
82047 + vma_m->vm_flags &= ~(VM_WRITE | VM_MAYWRITE | VM_ACCOUNT | VM_LOCKED);
82048 + vma_m->vm_page_prot = vm_get_page_prot(vma_m->vm_flags);
82049 + if (vma_m->vm_file)
82050 + get_file(vma_m->vm_file);
82051 + if (vma_m->vm_ops && vma_m->vm_ops->open)
82052 + vma_m->vm_ops->open(vma_m);
82053 + BUG_ON(find_vma_links(vma->vm_mm, vma_m->vm_start, vma_m->vm_end, &prev_m, &rb_link_m, &rb_parent_m));
82054 + vma_link(vma->vm_mm, vma_m, prev_m, rb_link_m, rb_parent_m);
82055 + vma_m->vm_mirror = vma;
82056 + vma->vm_mirror = vma_m;
82057 + return 0;
82058 +}
82059 +#endif
82060 +
82061 /*
82062 * Return true if the calling process may expand its vm space by the passed
82063 * number of pages
82064 @@ -2813,6 +3310,12 @@ int may_expand_vm(struct mm_struct *mm, unsigned long npages)
82065
82066 lim = rlimit(RLIMIT_AS) >> PAGE_SHIFT;
82067
82068 +#ifdef CONFIG_PAX_RANDMMAP
82069 + if (mm->pax_flags & MF_PAX_RANDMMAP)
82070 + cur -= mm->aslr_gap;
82071 +#endif
82072 +
82073 + gr_learn_resource(current, RLIMIT_AS, (cur + npages) << PAGE_SHIFT, 1);
82074 if (cur + npages > lim)
82075 return 0;
82076 return 1;
82077 @@ -2883,6 +3386,22 @@ int install_special_mapping(struct mm_struct *mm,
82078 vma->vm_start = addr;
82079 vma->vm_end = addr + len;
82080
82081 +#ifdef CONFIG_PAX_MPROTECT
82082 + if (mm->pax_flags & MF_PAX_MPROTECT) {
82083 +#ifndef CONFIG_PAX_MPROTECT_COMPAT
82084 + if ((vm_flags & (VM_WRITE | VM_EXEC)) == (VM_WRITE | VM_EXEC))
82085 + return -EPERM;
82086 + if (!(vm_flags & VM_EXEC))
82087 + vm_flags &= ~VM_MAYEXEC;
82088 +#else
82089 + if ((vm_flags & (VM_WRITE | VM_EXEC)) != VM_EXEC)
82090 + vm_flags &= ~(VM_EXEC | VM_MAYEXEC);
82091 +#endif
82092 + else
82093 + vm_flags &= ~VM_MAYWRITE;
82094 + }
82095 +#endif
82096 +
82097 vma->vm_flags = vm_flags | mm->def_flags | VM_DONTEXPAND;
82098 vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
82099
82100 diff --git a/mm/mprotect.c b/mm/mprotect.c
82101 index 94722a4..9837984 100644
82102 --- a/mm/mprotect.c
82103 +++ b/mm/mprotect.c
82104 @@ -23,10 +23,17 @@
82105 #include <linux/mmu_notifier.h>
82106 #include <linux/migrate.h>
82107 #include <linux/perf_event.h>
82108 +
82109 +#ifdef CONFIG_PAX_MPROTECT
82110 +#include <linux/elf.h>
82111 +#include <linux/binfmts.h>
82112 +#endif
82113 +
82114 #include <asm/uaccess.h>
82115 #include <asm/pgtable.h>
82116 #include <asm/cacheflush.h>
82117 #include <asm/tlbflush.h>
82118 +#include <asm/mmu_context.h>
82119
82120 #ifndef pgprot_modify
82121 static inline pgprot_t pgprot_modify(pgprot_t oldprot, pgprot_t newprot)
82122 @@ -233,6 +240,48 @@ unsigned long change_protection(struct vm_area_struct *vma, unsigned long start,
82123 return pages;
82124 }
82125
82126 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
82127 +/* called while holding the mmap semaphor for writing except stack expansion */
82128 +void track_exec_limit(struct mm_struct *mm, unsigned long start, unsigned long end, unsigned long prot)
82129 +{
82130 + unsigned long oldlimit, newlimit = 0UL;
82131 +
82132 + if (!(mm->pax_flags & MF_PAX_PAGEEXEC) || (__supported_pte_mask & _PAGE_NX))
82133 + return;
82134 +
82135 + spin_lock(&mm->page_table_lock);
82136 + oldlimit = mm->context.user_cs_limit;
82137 + if ((prot & VM_EXEC) && oldlimit < end)
82138 + /* USER_CS limit moved up */
82139 + newlimit = end;
82140 + else if (!(prot & VM_EXEC) && start < oldlimit && oldlimit <= end)
82141 + /* USER_CS limit moved down */
82142 + newlimit = start;
82143 +
82144 + if (newlimit) {
82145 + mm->context.user_cs_limit = newlimit;
82146 +
82147 +#ifdef CONFIG_SMP
82148 + wmb();
82149 + cpus_clear(mm->context.cpu_user_cs_mask);
82150 + cpu_set(smp_processor_id(), mm->context.cpu_user_cs_mask);
82151 +#endif
82152 +
82153 + set_user_cs(mm->context.user_cs_base, mm->context.user_cs_limit, smp_processor_id());
82154 + }
82155 + spin_unlock(&mm->page_table_lock);
82156 + if (newlimit == end) {
82157 + struct vm_area_struct *vma = find_vma(mm, oldlimit);
82158 +
82159 + for (; vma && vma->vm_start < end; vma = vma->vm_next)
82160 + if (is_vm_hugetlb_page(vma))
82161 + hugetlb_change_protection(vma, vma->vm_start, vma->vm_end, vma->vm_page_prot);
82162 + else
82163 + change_protection(vma, vma->vm_start, vma->vm_end, vma->vm_page_prot, vma_wants_writenotify(vma), 0);
82164 + }
82165 +}
82166 +#endif
82167 +
82168 int
82169 mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev,
82170 unsigned long start, unsigned long end, unsigned long newflags)
82171 @@ -245,11 +294,29 @@ mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev,
82172 int error;
82173 int dirty_accountable = 0;
82174
82175 +#ifdef CONFIG_PAX_SEGMEXEC
82176 + struct vm_area_struct *vma_m = NULL;
82177 + unsigned long start_m, end_m;
82178 +
82179 + start_m = start + SEGMEXEC_TASK_SIZE;
82180 + end_m = end + SEGMEXEC_TASK_SIZE;
82181 +#endif
82182 +
82183 if (newflags == oldflags) {
82184 *pprev = vma;
82185 return 0;
82186 }
82187
82188 + if (newflags & (VM_READ | VM_WRITE | VM_EXEC)) {
82189 + struct vm_area_struct *prev = vma->vm_prev, *next = vma->vm_next;
82190 +
82191 + if (next && (next->vm_flags & VM_GROWSDOWN) && sysctl_heap_stack_gap > next->vm_start - end)
82192 + return -ENOMEM;
82193 +
82194 + if (prev && (prev->vm_flags & VM_GROWSUP) && sysctl_heap_stack_gap > start - prev->vm_end)
82195 + return -ENOMEM;
82196 + }
82197 +
82198 /*
82199 * If we make a private mapping writable we increase our commit;
82200 * but (without finer accounting) cannot reduce our commit if we
82201 @@ -266,6 +333,42 @@ mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev,
82202 }
82203 }
82204
82205 +#ifdef CONFIG_PAX_SEGMEXEC
82206 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && ((oldflags ^ newflags) & VM_EXEC)) {
82207 + if (start != vma->vm_start) {
82208 + error = split_vma(mm, vma, start, 1);
82209 + if (error)
82210 + goto fail;
82211 + BUG_ON(!*pprev || (*pprev)->vm_next == vma);
82212 + *pprev = (*pprev)->vm_next;
82213 + }
82214 +
82215 + if (end != vma->vm_end) {
82216 + error = split_vma(mm, vma, end, 0);
82217 + if (error)
82218 + goto fail;
82219 + }
82220 +
82221 + if (pax_find_mirror_vma(vma)) {
82222 + error = __do_munmap(mm, start_m, end_m - start_m);
82223 + if (error)
82224 + goto fail;
82225 + } else {
82226 + vma_m = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
82227 + if (!vma_m) {
82228 + error = -ENOMEM;
82229 + goto fail;
82230 + }
82231 + vma->vm_flags = newflags;
82232 + error = pax_mirror_vma(vma_m, vma);
82233 + if (error) {
82234 + vma->vm_flags = oldflags;
82235 + goto fail;
82236 + }
82237 + }
82238 + }
82239 +#endif
82240 +
82241 /*
82242 * First try to merge with previous and/or next vma.
82243 */
82244 @@ -296,9 +399,21 @@ success:
82245 * vm_flags and vm_page_prot are protected by the mmap_sem
82246 * held in write mode.
82247 */
82248 +
82249 +#ifdef CONFIG_PAX_SEGMEXEC
82250 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (newflags & VM_EXEC) && ((vma->vm_flags ^ newflags) & VM_READ))
82251 + pax_find_mirror_vma(vma)->vm_flags ^= VM_READ;
82252 +#endif
82253 +
82254 vma->vm_flags = newflags;
82255 +
82256 +#ifdef CONFIG_PAX_MPROTECT
82257 + if (mm->binfmt && mm->binfmt->handle_mprotect)
82258 + mm->binfmt->handle_mprotect(vma, newflags);
82259 +#endif
82260 +
82261 vma->vm_page_prot = pgprot_modify(vma->vm_page_prot,
82262 - vm_get_page_prot(newflags));
82263 + vm_get_page_prot(vma->vm_flags));
82264
82265 if (vma_wants_writenotify(vma)) {
82266 vma->vm_page_prot = vm_get_page_prot(newflags & ~VM_SHARED);
82267 @@ -337,6 +452,17 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
82268 end = start + len;
82269 if (end <= start)
82270 return -ENOMEM;
82271 +
82272 +#ifdef CONFIG_PAX_SEGMEXEC
82273 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC) {
82274 + if (end > SEGMEXEC_TASK_SIZE)
82275 + return -EINVAL;
82276 + } else
82277 +#endif
82278 +
82279 + if (end > TASK_SIZE)
82280 + return -EINVAL;
82281 +
82282 if (!arch_validate_prot(prot))
82283 return -EINVAL;
82284
82285 @@ -344,7 +470,7 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
82286 /*
82287 * Does the application expect PROT_READ to imply PROT_EXEC:
82288 */
82289 - if ((prot & PROT_READ) && (current->personality & READ_IMPLIES_EXEC))
82290 + if ((prot & (PROT_READ | PROT_WRITE)) && (current->personality & READ_IMPLIES_EXEC))
82291 prot |= PROT_EXEC;
82292
82293 vm_flags = calc_vm_prot_bits(prot);
82294 @@ -376,6 +502,11 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
82295 if (start > vma->vm_start)
82296 prev = vma;
82297
82298 +#ifdef CONFIG_PAX_MPROTECT
82299 + if (current->mm->binfmt && current->mm->binfmt->handle_mprotect)
82300 + current->mm->binfmt->handle_mprotect(vma, vm_flags);
82301 +#endif
82302 +
82303 for (nstart = start ; ; ) {
82304 unsigned long newflags;
82305
82306 @@ -386,6 +517,14 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
82307
82308 /* newflags >> 4 shift VM_MAY% in place of VM_% */
82309 if ((newflags & ~(newflags >> 4)) & (VM_READ | VM_WRITE | VM_EXEC)) {
82310 + if (prot & (PROT_WRITE | PROT_EXEC))
82311 + gr_log_rwxmprotect(vma->vm_file);
82312 +
82313 + error = -EACCES;
82314 + goto out;
82315 + }
82316 +
82317 + if (!gr_acl_handle_mprotect(vma->vm_file, prot)) {
82318 error = -EACCES;
82319 goto out;
82320 }
82321 @@ -400,6 +539,9 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
82322 error = mprotect_fixup(vma, &prev, nstart, tmp, newflags);
82323 if (error)
82324 goto out;
82325 +
82326 + track_exec_limit(current->mm, nstart, tmp, vm_flags);
82327 +
82328 nstart = tmp;
82329
82330 if (nstart < prev->vm_end)
82331 diff --git a/mm/mremap.c b/mm/mremap.c
82332 index e1031e1..1f2a0a1 100644
82333 --- a/mm/mremap.c
82334 +++ b/mm/mremap.c
82335 @@ -125,6 +125,12 @@ static void move_ptes(struct vm_area_struct *vma, pmd_t *old_pmd,
82336 continue;
82337 pte = ptep_get_and_clear(mm, old_addr, old_pte);
82338 pte = move_pte(pte, new_vma->vm_page_prot, old_addr, new_addr);
82339 +
82340 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
82341 + if (!(__supported_pte_mask & _PAGE_NX) && (new_vma->vm_flags & (VM_PAGEEXEC | VM_EXEC)) == VM_PAGEEXEC)
82342 + pte = pte_exprotect(pte);
82343 +#endif
82344 +
82345 set_pte_at(mm, new_addr, new_pte, pte);
82346 }
82347
82348 @@ -319,6 +325,11 @@ static struct vm_area_struct *vma_to_resize(unsigned long addr,
82349 if (is_vm_hugetlb_page(vma))
82350 goto Einval;
82351
82352 +#ifdef CONFIG_PAX_SEGMEXEC
82353 + if (pax_find_mirror_vma(vma))
82354 + goto Einval;
82355 +#endif
82356 +
82357 /* We can't remap across vm area boundaries */
82358 if (old_len > vma->vm_end - addr)
82359 goto Efault;
82360 @@ -375,20 +386,25 @@ static unsigned long mremap_to(unsigned long addr,
82361 unsigned long ret = -EINVAL;
82362 unsigned long charged = 0;
82363 unsigned long map_flags;
82364 + unsigned long pax_task_size = TASK_SIZE;
82365
82366 if (new_addr & ~PAGE_MASK)
82367 goto out;
82368
82369 - if (new_len > TASK_SIZE || new_addr > TASK_SIZE - new_len)
82370 +#ifdef CONFIG_PAX_SEGMEXEC
82371 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
82372 + pax_task_size = SEGMEXEC_TASK_SIZE;
82373 +#endif
82374 +
82375 + pax_task_size -= PAGE_SIZE;
82376 +
82377 + if (new_len > TASK_SIZE || new_addr > pax_task_size - new_len)
82378 goto out;
82379
82380 /* Check if the location we're moving into overlaps the
82381 * old location at all, and fail if it does.
82382 */
82383 - if ((new_addr <= addr) && (new_addr+new_len) > addr)
82384 - goto out;
82385 -
82386 - if ((addr <= new_addr) && (addr+old_len) > new_addr)
82387 + if (addr + old_len > new_addr && new_addr + new_len > addr)
82388 goto out;
82389
82390 ret = do_munmap(mm, new_addr, new_len);
82391 @@ -456,6 +472,7 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
82392 struct vm_area_struct *vma;
82393 unsigned long ret = -EINVAL;
82394 unsigned long charged = 0;
82395 + unsigned long pax_task_size = TASK_SIZE;
82396
82397 down_write(&current->mm->mmap_sem);
82398
82399 @@ -476,6 +493,17 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
82400 if (!new_len)
82401 goto out;
82402
82403 +#ifdef CONFIG_PAX_SEGMEXEC
82404 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
82405 + pax_task_size = SEGMEXEC_TASK_SIZE;
82406 +#endif
82407 +
82408 + pax_task_size -= PAGE_SIZE;
82409 +
82410 + if (new_len > pax_task_size || addr > pax_task_size-new_len ||
82411 + old_len > pax_task_size || addr > pax_task_size-old_len)
82412 + goto out;
82413 +
82414 if (flags & MREMAP_FIXED) {
82415 if (flags & MREMAP_MAYMOVE)
82416 ret = mremap_to(addr, old_len, new_addr, new_len);
82417 @@ -524,6 +552,7 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
82418 addr + new_len);
82419 }
82420 ret = addr;
82421 + track_exec_limit(vma->vm_mm, vma->vm_start, addr + new_len, vma->vm_flags);
82422 goto out;
82423 }
82424 }
82425 @@ -547,7 +576,12 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
82426 goto out;
82427 }
82428
82429 + map_flags = vma->vm_flags;
82430 ret = move_vma(vma, addr, old_len, new_len, new_addr);
82431 + if (!(ret & ~PAGE_MASK)) {
82432 + track_exec_limit(current->mm, addr, addr + old_len, 0UL);
82433 + track_exec_limit(current->mm, new_addr, new_addr + new_len, map_flags);
82434 + }
82435 }
82436 out:
82437 if (ret & ~PAGE_MASK)
82438 diff --git a/mm/nommu.c b/mm/nommu.c
82439 index 79c3cac..4d357e0 100644
82440 --- a/mm/nommu.c
82441 +++ b/mm/nommu.c
82442 @@ -62,7 +62,6 @@ int sysctl_overcommit_memory = OVERCOMMIT_GUESS; /* heuristic overcommit */
82443 int sysctl_overcommit_ratio = 50; /* default is 50% */
82444 int sysctl_max_map_count = DEFAULT_MAX_MAP_COUNT;
82445 int sysctl_nr_trim_pages = CONFIG_NOMMU_INITIAL_TRIM_EXCESS;
82446 -int heap_stack_gap = 0;
82447
82448 atomic_long_t mmap_pages_allocated;
82449
82450 @@ -839,15 +838,6 @@ struct vm_area_struct *find_vma(struct mm_struct *mm, unsigned long addr)
82451 EXPORT_SYMBOL(find_vma);
82452
82453 /*
82454 - * find a VMA
82455 - * - we don't extend stack VMAs under NOMMU conditions
82456 - */
82457 -struct vm_area_struct *find_extend_vma(struct mm_struct *mm, unsigned long addr)
82458 -{
82459 - return find_vma(mm, addr);
82460 -}
82461 -
82462 -/*
82463 * expand a stack to a given address
82464 * - not supported under NOMMU conditions
82465 */
82466 @@ -1555,6 +1545,7 @@ int split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
82467
82468 /* most fields are the same, copy all, and then fixup */
82469 *new = *vma;
82470 + INIT_LIST_HEAD(&new->anon_vma_chain);
82471 *region = *vma->vm_region;
82472 new->vm_region = region;
82473
82474 diff --git a/mm/page-writeback.c b/mm/page-writeback.c
82475 index 0713bfb..b95bb87 100644
82476 --- a/mm/page-writeback.c
82477 +++ b/mm/page-writeback.c
82478 @@ -655,7 +655,7 @@ unsigned long bdi_dirty_limit(struct backing_dev_info *bdi, unsigned long dirty)
82479 * card's bdi_dirty may rush to many times higher than bdi_setpoint.
82480 * - the bdi dirty thresh drops quickly due to change of JBOD workload
82481 */
82482 -static unsigned long bdi_position_ratio(struct backing_dev_info *bdi,
82483 +static unsigned long __intentional_overflow(-1) bdi_position_ratio(struct backing_dev_info *bdi,
82484 unsigned long thresh,
82485 unsigned long bg_thresh,
82486 unsigned long dirty,
82487 @@ -1630,7 +1630,7 @@ ratelimit_handler(struct notifier_block *self, unsigned long action,
82488 }
82489 }
82490
82491 -static struct notifier_block __cpuinitdata ratelimit_nb = {
82492 +static struct notifier_block ratelimit_nb = {
82493 .notifier_call = ratelimit_handler,
82494 .next = NULL,
82495 };
82496 diff --git a/mm/page_alloc.c b/mm/page_alloc.c
82497 index 6a83cd3..3ab04ef 100644
82498 --- a/mm/page_alloc.c
82499 +++ b/mm/page_alloc.c
82500 @@ -58,6 +58,7 @@
82501 #include <linux/prefetch.h>
82502 #include <linux/migrate.h>
82503 #include <linux/page-debug-flags.h>
82504 +#include <linux/random.h>
82505
82506 #include <asm/tlbflush.h>
82507 #include <asm/div64.h>
82508 @@ -338,7 +339,7 @@ out:
82509 * This usage means that zero-order pages may not be compound.
82510 */
82511
82512 -static void free_compound_page(struct page *page)
82513 +void free_compound_page(struct page *page)
82514 {
82515 __free_pages_ok(page, compound_order(page));
82516 }
82517 @@ -693,6 +694,10 @@ static bool free_pages_prepare(struct page *page, unsigned int order)
82518 int i;
82519 int bad = 0;
82520
82521 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
82522 + unsigned long index = 1UL << order;
82523 +#endif
82524 +
82525 trace_mm_page_free(page, order);
82526 kmemcheck_free_shadow(page, order);
82527
82528 @@ -708,6 +713,12 @@ static bool free_pages_prepare(struct page *page, unsigned int order)
82529 debug_check_no_obj_freed(page_address(page),
82530 PAGE_SIZE << order);
82531 }
82532 +
82533 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
82534 + for (; index; --index)
82535 + sanitize_highpage(page + index - 1);
82536 +#endif
82537 +
82538 arch_free_page(page, order);
82539 kernel_map_pages(page, 1 << order, 0);
82540
82541 @@ -730,6 +741,19 @@ static void __free_pages_ok(struct page *page, unsigned int order)
82542 local_irq_restore(flags);
82543 }
82544
82545 +#ifdef CONFIG_PAX_LATENT_ENTROPY
82546 +bool __meminitdata extra_latent_entropy;
82547 +
82548 +static int __init setup_pax_extra_latent_entropy(char *str)
82549 +{
82550 + extra_latent_entropy = true;
82551 + return 0;
82552 +}
82553 +early_param("pax_extra_latent_entropy", setup_pax_extra_latent_entropy);
82554 +
82555 +volatile u64 latent_entropy;
82556 +#endif
82557 +
82558 /*
82559 * Read access to zone->managed_pages is safe because it's unsigned long,
82560 * but we still need to serialize writers. Currently all callers of
82561 @@ -752,6 +776,19 @@ void __meminit __free_pages_bootmem(struct page *page, unsigned int order)
82562 set_page_count(p, 0);
82563 }
82564
82565 +#ifdef CONFIG_PAX_LATENT_ENTROPY
82566 + if (extra_latent_entropy && !PageHighMem(page) && page_to_pfn(page) < 0x100000) {
82567 + u64 hash = 0;
82568 + size_t index, end = PAGE_SIZE * nr_pages / sizeof hash;
82569 + const u64 *data = lowmem_page_address(page);
82570 +
82571 + for (index = 0; index < end; index++)
82572 + hash ^= hash + data[index];
82573 + latent_entropy ^= hash;
82574 + add_device_randomness((const void *)&latent_entropy, sizeof(latent_entropy));
82575 + }
82576 +#endif
82577 +
82578 page_zone(page)->managed_pages += 1 << order;
82579 set_page_refcounted(page);
82580 __free_pages(page, order);
82581 @@ -861,8 +898,10 @@ static int prep_new_page(struct page *page, int order, gfp_t gfp_flags)
82582 arch_alloc_page(page, order);
82583 kernel_map_pages(page, 1 << order, 1);
82584
82585 +#ifndef CONFIG_PAX_MEMORY_SANITIZE
82586 if (gfp_flags & __GFP_ZERO)
82587 prep_zero_page(page, order, gfp_flags);
82588 +#endif
82589
82590 if (order && (gfp_flags & __GFP_COMP))
82591 prep_compound_page(page, order);
82592 @@ -3752,7 +3791,13 @@ static int pageblock_is_reserved(unsigned long start_pfn, unsigned long end_pfn)
82593 unsigned long pfn;
82594
82595 for (pfn = start_pfn; pfn < end_pfn; pfn++) {
82596 +#ifdef CONFIG_X86_32
82597 + /* boot failures in VMware 8 on 32bit vanilla since
82598 + this change */
82599 + if (!pfn_valid(pfn) || PageReserved(pfn_to_page(pfn)))
82600 +#else
82601 if (!pfn_valid_within(pfn) || PageReserved(pfn_to_page(pfn)))
82602 +#endif
82603 return 1;
82604 }
82605 return 0;
82606 diff --git a/mm/percpu.c b/mm/percpu.c
82607 index 8c8e08f..73a5cda 100644
82608 --- a/mm/percpu.c
82609 +++ b/mm/percpu.c
82610 @@ -122,7 +122,7 @@ static unsigned int pcpu_low_unit_cpu __read_mostly;
82611 static unsigned int pcpu_high_unit_cpu __read_mostly;
82612
82613 /* the address of the first chunk which starts with the kernel static area */
82614 -void *pcpu_base_addr __read_mostly;
82615 +void *pcpu_base_addr __read_only;
82616 EXPORT_SYMBOL_GPL(pcpu_base_addr);
82617
82618 static const int *pcpu_unit_map __read_mostly; /* cpu -> unit */
82619 diff --git a/mm/process_vm_access.c b/mm/process_vm_access.c
82620 index fd26d04..0cea1b0 100644
82621 --- a/mm/process_vm_access.c
82622 +++ b/mm/process_vm_access.c
82623 @@ -13,6 +13,7 @@
82624 #include <linux/uio.h>
82625 #include <linux/sched.h>
82626 #include <linux/highmem.h>
82627 +#include <linux/security.h>
82628 #include <linux/ptrace.h>
82629 #include <linux/slab.h>
82630 #include <linux/syscalls.h>
82631 @@ -258,19 +259,19 @@ static ssize_t process_vm_rw_core(pid_t pid, const struct iovec *lvec,
82632 size_t iov_l_curr_offset = 0;
82633 ssize_t iov_len;
82634
82635 + return -ENOSYS; // PaX: until properly audited
82636 +
82637 /*
82638 * Work out how many pages of struct pages we're going to need
82639 * when eventually calling get_user_pages
82640 */
82641 for (i = 0; i < riovcnt; i++) {
82642 iov_len = rvec[i].iov_len;
82643 - if (iov_len > 0) {
82644 - nr_pages_iov = ((unsigned long)rvec[i].iov_base
82645 - + iov_len)
82646 - / PAGE_SIZE - (unsigned long)rvec[i].iov_base
82647 - / PAGE_SIZE + 1;
82648 - nr_pages = max(nr_pages, nr_pages_iov);
82649 - }
82650 + if (iov_len <= 0)
82651 + continue;
82652 + nr_pages_iov = ((unsigned long)rvec[i].iov_base + iov_len) / PAGE_SIZE -
82653 + (unsigned long)rvec[i].iov_base / PAGE_SIZE + 1;
82654 + nr_pages = max(nr_pages, nr_pages_iov);
82655 }
82656
82657 if (nr_pages == 0)
82658 @@ -298,6 +299,11 @@ static ssize_t process_vm_rw_core(pid_t pid, const struct iovec *lvec,
82659 goto free_proc_pages;
82660 }
82661
82662 + if (gr_handle_ptrace(task, vm_write ? PTRACE_POKETEXT : PTRACE_ATTACH)) {
82663 + rc = -EPERM;
82664 + goto put_task_struct;
82665 + }
82666 +
82667 mm = mm_access(task, PTRACE_MODE_ATTACH);
82668 if (!mm || IS_ERR(mm)) {
82669 rc = IS_ERR(mm) ? PTR_ERR(mm) : -ESRCH;
82670 diff --git a/mm/rmap.c b/mm/rmap.c
82671 index 2c78f8c..9e9c624 100644
82672 --- a/mm/rmap.c
82673 +++ b/mm/rmap.c
82674 @@ -163,6 +163,10 @@ int anon_vma_prepare(struct vm_area_struct *vma)
82675 struct anon_vma *anon_vma = vma->anon_vma;
82676 struct anon_vma_chain *avc;
82677
82678 +#ifdef CONFIG_PAX_SEGMEXEC
82679 + struct anon_vma_chain *avc_m = NULL;
82680 +#endif
82681 +
82682 might_sleep();
82683 if (unlikely(!anon_vma)) {
82684 struct mm_struct *mm = vma->vm_mm;
82685 @@ -172,6 +176,12 @@ int anon_vma_prepare(struct vm_area_struct *vma)
82686 if (!avc)
82687 goto out_enomem;
82688
82689 +#ifdef CONFIG_PAX_SEGMEXEC
82690 + avc_m = anon_vma_chain_alloc(GFP_KERNEL);
82691 + if (!avc_m)
82692 + goto out_enomem_free_avc;
82693 +#endif
82694 +
82695 anon_vma = find_mergeable_anon_vma(vma);
82696 allocated = NULL;
82697 if (!anon_vma) {
82698 @@ -185,6 +195,18 @@ int anon_vma_prepare(struct vm_area_struct *vma)
82699 /* page_table_lock to protect against threads */
82700 spin_lock(&mm->page_table_lock);
82701 if (likely(!vma->anon_vma)) {
82702 +
82703 +#ifdef CONFIG_PAX_SEGMEXEC
82704 + struct vm_area_struct *vma_m = pax_find_mirror_vma(vma);
82705 +
82706 + if (vma_m) {
82707 + BUG_ON(vma_m->anon_vma);
82708 + vma_m->anon_vma = anon_vma;
82709 + anon_vma_chain_link(vma_m, avc_m, anon_vma);
82710 + avc_m = NULL;
82711 + }
82712 +#endif
82713 +
82714 vma->anon_vma = anon_vma;
82715 anon_vma_chain_link(vma, avc, anon_vma);
82716 allocated = NULL;
82717 @@ -195,12 +217,24 @@ int anon_vma_prepare(struct vm_area_struct *vma)
82718
82719 if (unlikely(allocated))
82720 put_anon_vma(allocated);
82721 +
82722 +#ifdef CONFIG_PAX_SEGMEXEC
82723 + if (unlikely(avc_m))
82724 + anon_vma_chain_free(avc_m);
82725 +#endif
82726 +
82727 if (unlikely(avc))
82728 anon_vma_chain_free(avc);
82729 }
82730 return 0;
82731
82732 out_enomem_free_avc:
82733 +
82734 +#ifdef CONFIG_PAX_SEGMEXEC
82735 + if (avc_m)
82736 + anon_vma_chain_free(avc_m);
82737 +#endif
82738 +
82739 anon_vma_chain_free(avc);
82740 out_enomem:
82741 return -ENOMEM;
82742 @@ -236,7 +270,7 @@ static inline void unlock_anon_vma_root(struct anon_vma *root)
82743 * Attach the anon_vmas from src to dst.
82744 * Returns 0 on success, -ENOMEM on failure.
82745 */
82746 -int anon_vma_clone(struct vm_area_struct *dst, struct vm_area_struct *src)
82747 +int anon_vma_clone(struct vm_area_struct *dst, const struct vm_area_struct *src)
82748 {
82749 struct anon_vma_chain *avc, *pavc;
82750 struct anon_vma *root = NULL;
82751 @@ -269,7 +303,7 @@ int anon_vma_clone(struct vm_area_struct *dst, struct vm_area_struct *src)
82752 * the corresponding VMA in the parent process is attached to.
82753 * Returns 0 on success, non-zero on failure.
82754 */
82755 -int anon_vma_fork(struct vm_area_struct *vma, struct vm_area_struct *pvma)
82756 +int anon_vma_fork(struct vm_area_struct *vma, const struct vm_area_struct *pvma)
82757 {
82758 struct anon_vma_chain *avc;
82759 struct anon_vma *anon_vma;
82760 diff --git a/mm/shmem.c b/mm/shmem.c
82761 index efd0b3a..994b702 100644
82762 --- a/mm/shmem.c
82763 +++ b/mm/shmem.c
82764 @@ -31,7 +31,7 @@
82765 #include <linux/export.h>
82766 #include <linux/swap.h>
82767
82768 -static struct vfsmount *shm_mnt;
82769 +struct vfsmount *shm_mnt;
82770
82771 #ifdef CONFIG_SHMEM
82772 /*
82773 @@ -75,7 +75,7 @@ static struct vfsmount *shm_mnt;
82774 #define BOGO_DIRENT_SIZE 20
82775
82776 /* Symlink up to this size is kmalloc'ed instead of using a swappable page */
82777 -#define SHORT_SYMLINK_LEN 128
82778 +#define SHORT_SYMLINK_LEN 64
82779
82780 /*
82781 * shmem_fallocate and shmem_writepage communicate via inode->i_private
82782 @@ -2202,6 +2202,11 @@ static const struct xattr_handler *shmem_xattr_handlers[] = {
82783 static int shmem_xattr_validate(const char *name)
82784 {
82785 struct { const char *prefix; size_t len; } arr[] = {
82786 +
82787 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
82788 + { XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN},
82789 +#endif
82790 +
82791 { XATTR_SECURITY_PREFIX, XATTR_SECURITY_PREFIX_LEN },
82792 { XATTR_TRUSTED_PREFIX, XATTR_TRUSTED_PREFIX_LEN }
82793 };
82794 @@ -2257,6 +2262,15 @@ static int shmem_setxattr(struct dentry *dentry, const char *name,
82795 if (err)
82796 return err;
82797
82798 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
82799 + if (!strncmp(name, XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN)) {
82800 + if (strcmp(name, XATTR_NAME_PAX_FLAGS))
82801 + return -EOPNOTSUPP;
82802 + if (size > 8)
82803 + return -EINVAL;
82804 + }
82805 +#endif
82806 +
82807 return simple_xattr_set(&info->xattrs, name, value, size, flags);
82808 }
82809
82810 @@ -2562,8 +2576,7 @@ int shmem_fill_super(struct super_block *sb, void *data, int silent)
82811 int err = -ENOMEM;
82812
82813 /* Round up to L1_CACHE_BYTES to resist false sharing */
82814 - sbinfo = kzalloc(max((int)sizeof(struct shmem_sb_info),
82815 - L1_CACHE_BYTES), GFP_KERNEL);
82816 + sbinfo = kzalloc(max(sizeof(struct shmem_sb_info), L1_CACHE_BYTES), GFP_KERNEL);
82817 if (!sbinfo)
82818 return -ENOMEM;
82819
82820 diff --git a/mm/slab.c b/mm/slab.c
82821 index e7667a3..b62c169 100644
82822 --- a/mm/slab.c
82823 +++ b/mm/slab.c
82824 @@ -306,7 +306,7 @@ struct kmem_list3 {
82825 * Need this for bootstrapping a per node allocator.
82826 */
82827 #define NUM_INIT_LISTS (3 * MAX_NUMNODES)
82828 -static struct kmem_list3 __initdata initkmem_list3[NUM_INIT_LISTS];
82829 +static struct kmem_list3 initkmem_list3[NUM_INIT_LISTS];
82830 #define CACHE_CACHE 0
82831 #define SIZE_AC MAX_NUMNODES
82832 #define SIZE_L3 (2 * MAX_NUMNODES)
82833 @@ -407,10 +407,10 @@ static void kmem_list3_init(struct kmem_list3 *parent)
82834 if ((x)->max_freeable < i) \
82835 (x)->max_freeable = i; \
82836 } while (0)
82837 -#define STATS_INC_ALLOCHIT(x) atomic_inc(&(x)->allochit)
82838 -#define STATS_INC_ALLOCMISS(x) atomic_inc(&(x)->allocmiss)
82839 -#define STATS_INC_FREEHIT(x) atomic_inc(&(x)->freehit)
82840 -#define STATS_INC_FREEMISS(x) atomic_inc(&(x)->freemiss)
82841 +#define STATS_INC_ALLOCHIT(x) atomic_inc_unchecked(&(x)->allochit)
82842 +#define STATS_INC_ALLOCMISS(x) atomic_inc_unchecked(&(x)->allocmiss)
82843 +#define STATS_INC_FREEHIT(x) atomic_inc_unchecked(&(x)->freehit)
82844 +#define STATS_INC_FREEMISS(x) atomic_inc_unchecked(&(x)->freemiss)
82845 #else
82846 #define STATS_INC_ACTIVE(x) do { } while (0)
82847 #define STATS_DEC_ACTIVE(x) do { } while (0)
82848 @@ -518,7 +518,7 @@ static inline void *index_to_obj(struct kmem_cache *cache, struct slab *slab,
82849 * reciprocal_divide(offset, cache->reciprocal_buffer_size)
82850 */
82851 static inline unsigned int obj_to_index(const struct kmem_cache *cache,
82852 - const struct slab *slab, void *obj)
82853 + const struct slab *slab, const void *obj)
82854 {
82855 u32 offset = (obj - slab->s_mem);
82856 return reciprocal_divide(offset, cache->reciprocal_buffer_size);
82857 @@ -539,12 +539,13 @@ EXPORT_SYMBOL(malloc_sizes);
82858 struct cache_names {
82859 char *name;
82860 char *name_dma;
82861 + char *name_usercopy;
82862 };
82863
82864 static struct cache_names __initdata cache_names[] = {
82865 -#define CACHE(x) { .name = "size-" #x, .name_dma = "size-" #x "(DMA)" },
82866 +#define CACHE(x) { .name = "size-" #x, .name_dma = "size-" #x "(DMA)", .name_usercopy = "size-" #x "(USERCOPY)" },
82867 #include <linux/kmalloc_sizes.h>
82868 - {NULL,}
82869 + {NULL}
82870 #undef CACHE
82871 };
82872
82873 @@ -729,6 +730,12 @@ static inline struct kmem_cache *__find_general_cachep(size_t size,
82874 if (unlikely(gfpflags & GFP_DMA))
82875 return csizep->cs_dmacachep;
82876 #endif
82877 +
82878 +#ifdef CONFIG_PAX_USERCOPY_SLABS
82879 + if (unlikely(gfpflags & GFP_USERCOPY))
82880 + return csizep->cs_usercopycachep;
82881 +#endif
82882 +
82883 return csizep->cs_cachep;
82884 }
82885
82886 @@ -1482,7 +1489,7 @@ static int __cpuinit cpuup_callback(struct notifier_block *nfb,
82887 return notifier_from_errno(err);
82888 }
82889
82890 -static struct notifier_block __cpuinitdata cpucache_notifier = {
82891 +static struct notifier_block cpucache_notifier = {
82892 &cpuup_callback, NULL, 0
82893 };
82894
82895 @@ -1667,12 +1674,12 @@ void __init kmem_cache_init(void)
82896 */
82897
82898 sizes[INDEX_AC].cs_cachep = create_kmalloc_cache(names[INDEX_AC].name,
82899 - sizes[INDEX_AC].cs_size, ARCH_KMALLOC_FLAGS);
82900 + sizes[INDEX_AC].cs_size, ARCH_KMALLOC_FLAGS|SLAB_USERCOPY);
82901
82902 if (INDEX_AC != INDEX_L3)
82903 sizes[INDEX_L3].cs_cachep =
82904 create_kmalloc_cache(names[INDEX_L3].name,
82905 - sizes[INDEX_L3].cs_size, ARCH_KMALLOC_FLAGS);
82906 + sizes[INDEX_L3].cs_size, ARCH_KMALLOC_FLAGS|SLAB_USERCOPY);
82907
82908 slab_early_init = 0;
82909
82910 @@ -1686,13 +1693,20 @@ void __init kmem_cache_init(void)
82911 */
82912 if (!sizes->cs_cachep)
82913 sizes->cs_cachep = create_kmalloc_cache(names->name,
82914 - sizes->cs_size, ARCH_KMALLOC_FLAGS);
82915 + sizes->cs_size, ARCH_KMALLOC_FLAGS|SLAB_USERCOPY);
82916
82917 #ifdef CONFIG_ZONE_DMA
82918 sizes->cs_dmacachep = create_kmalloc_cache(
82919 names->name_dma, sizes->cs_size,
82920 SLAB_CACHE_DMA|ARCH_KMALLOC_FLAGS);
82921 #endif
82922 +
82923 +#ifdef CONFIG_PAX_USERCOPY_SLABS
82924 + sizes->cs_usercopycachep = create_kmalloc_cache(
82925 + names->name_usercopy, sizes->cs_size,
82926 + ARCH_KMALLOC_FLAGS|SLAB_USERCOPY);
82927 +#endif
82928 +
82929 sizes++;
82930 names++;
82931 }
82932 @@ -4365,10 +4379,10 @@ void slabinfo_show_stats(struct seq_file *m, struct kmem_cache *cachep)
82933 }
82934 /* cpu stats */
82935 {
82936 - unsigned long allochit = atomic_read(&cachep->allochit);
82937 - unsigned long allocmiss = atomic_read(&cachep->allocmiss);
82938 - unsigned long freehit = atomic_read(&cachep->freehit);
82939 - unsigned long freemiss = atomic_read(&cachep->freemiss);
82940 + unsigned long allochit = atomic_read_unchecked(&cachep->allochit);
82941 + unsigned long allocmiss = atomic_read_unchecked(&cachep->allocmiss);
82942 + unsigned long freehit = atomic_read_unchecked(&cachep->freehit);
82943 + unsigned long freemiss = atomic_read_unchecked(&cachep->freemiss);
82944
82945 seq_printf(m, " : cpustat %6lu %6lu %6lu %6lu",
82946 allochit, allocmiss, freehit, freemiss);
82947 @@ -4600,13 +4614,71 @@ static const struct file_operations proc_slabstats_operations = {
82948 static int __init slab_proc_init(void)
82949 {
82950 #ifdef CONFIG_DEBUG_SLAB_LEAK
82951 - proc_create("slab_allocators", 0, NULL, &proc_slabstats_operations);
82952 + proc_create("slab_allocators", S_IRUSR, NULL, &proc_slabstats_operations);
82953 #endif
82954 return 0;
82955 }
82956 module_init(slab_proc_init);
82957 #endif
82958
82959 +bool is_usercopy_object(const void *ptr)
82960 +{
82961 + struct page *page;
82962 + struct kmem_cache *cachep;
82963 +
82964 + if (ZERO_OR_NULL_PTR(ptr))
82965 + return false;
82966 +
82967 + if (!slab_is_available())
82968 + return false;
82969 +
82970 + if (!virt_addr_valid(ptr))
82971 + return false;
82972 +
82973 + page = virt_to_head_page(ptr);
82974 +
82975 + if (!PageSlab(page))
82976 + return false;
82977 +
82978 + cachep = page->slab_cache;
82979 + return cachep->flags & SLAB_USERCOPY;
82980 +}
82981 +
82982 +#ifdef CONFIG_PAX_USERCOPY
82983 +const char *check_heap_object(const void *ptr, unsigned long n)
82984 +{
82985 + struct page *page;
82986 + struct kmem_cache *cachep;
82987 + struct slab *slabp;
82988 + unsigned int objnr;
82989 + unsigned long offset;
82990 +
82991 + if (ZERO_OR_NULL_PTR(ptr))
82992 + return "<null>";
82993 +
82994 + if (!virt_addr_valid(ptr))
82995 + return NULL;
82996 +
82997 + page = virt_to_head_page(ptr);
82998 +
82999 + if (!PageSlab(page))
83000 + return NULL;
83001 +
83002 + cachep = page->slab_cache;
83003 + if (!(cachep->flags & SLAB_USERCOPY))
83004 + return cachep->name;
83005 +
83006 + slabp = page->slab_page;
83007 + objnr = obj_to_index(cachep, slabp, ptr);
83008 + BUG_ON(objnr >= cachep->num);
83009 + offset = ptr - index_to_obj(cachep, slabp, objnr) - obj_offset(cachep);
83010 + if (offset <= cachep->object_size && n <= cachep->object_size - offset)
83011 + return NULL;
83012 +
83013 + return cachep->name;
83014 +}
83015 +#endif
83016 +
83017 /**
83018 * ksize - get the actual amount of memory allocated for a given object
83019 * @objp: Pointer to the object
83020 diff --git a/mm/slab.h b/mm/slab.h
83021 index 34a98d6..73633d1 100644
83022 --- a/mm/slab.h
83023 +++ b/mm/slab.h
83024 @@ -58,7 +58,7 @@ __kmem_cache_alias(struct mem_cgroup *memcg, const char *name, size_t size,
83025
83026 /* Legal flag mask for kmem_cache_create(), for various configurations */
83027 #define SLAB_CORE_FLAGS (SLAB_HWCACHE_ALIGN | SLAB_CACHE_DMA | SLAB_PANIC | \
83028 - SLAB_DESTROY_BY_RCU | SLAB_DEBUG_OBJECTS )
83029 + SLAB_DESTROY_BY_RCU | SLAB_DEBUG_OBJECTS | SLAB_USERCOPY)
83030
83031 #if defined(CONFIG_DEBUG_SLAB)
83032 #define SLAB_DEBUG_FLAGS (SLAB_RED_ZONE | SLAB_POISON | SLAB_STORE_USER)
83033 @@ -220,6 +220,9 @@ static inline struct kmem_cache *cache_from_obj(struct kmem_cache *s, void *x)
83034 return s;
83035
83036 page = virt_to_head_page(x);
83037 +
83038 + BUG_ON(!PageSlab(page));
83039 +
83040 cachep = page->slab_cache;
83041 if (slab_equal_or_root(cachep, s))
83042 return cachep;
83043 diff --git a/mm/slab_common.c b/mm/slab_common.c
83044 index 3f3cd97..93b0236 100644
83045 --- a/mm/slab_common.c
83046 +++ b/mm/slab_common.c
83047 @@ -22,7 +22,7 @@
83048
83049 #include "slab.h"
83050
83051 -enum slab_state slab_state;
83052 +enum slab_state slab_state __read_only;
83053 LIST_HEAD(slab_caches);
83054 DEFINE_MUTEX(slab_mutex);
83055 struct kmem_cache *kmem_cache;
83056 @@ -209,7 +209,7 @@ kmem_cache_create_memcg(struct mem_cgroup *memcg, const char *name, size_t size,
83057
83058 err = __kmem_cache_create(s, flags);
83059 if (!err) {
83060 - s->refcount = 1;
83061 + atomic_set(&s->refcount, 1);
83062 list_add(&s->list, &slab_caches);
83063 memcg_cache_list_add(memcg, s);
83064 } else {
83065 @@ -255,8 +255,7 @@ void kmem_cache_destroy(struct kmem_cache *s)
83066
83067 get_online_cpus();
83068 mutex_lock(&slab_mutex);
83069 - s->refcount--;
83070 - if (!s->refcount) {
83071 + if (atomic_dec_and_test(&s->refcount)) {
83072 list_del(&s->list);
83073
83074 if (!__kmem_cache_shutdown(s)) {
83075 @@ -302,7 +301,7 @@ void __init create_boot_cache(struct kmem_cache *s, const char *name, size_t siz
83076 panic("Creation of kmalloc slab %s size=%zd failed. Reason %d\n",
83077 name, size, err);
83078
83079 - s->refcount = -1; /* Exempt from merging for now */
83080 + atomic_set(&s->refcount, -1); /* Exempt from merging for now */
83081 }
83082
83083 struct kmem_cache *__init create_kmalloc_cache(const char *name, size_t size,
83084 @@ -315,7 +314,7 @@ struct kmem_cache *__init create_kmalloc_cache(const char *name, size_t size,
83085
83086 create_boot_cache(s, name, size, flags);
83087 list_add(&s->list, &slab_caches);
83088 - s->refcount = 1;
83089 + atomic_set(&s->refcount, 1);
83090 return s;
83091 }
83092
83093 diff --git a/mm/slob.c b/mm/slob.c
83094 index a99fdf7..f5b6577 100644
83095 --- a/mm/slob.c
83096 +++ b/mm/slob.c
83097 @@ -157,7 +157,7 @@ static void set_slob(slob_t *s, slobidx_t size, slob_t *next)
83098 /*
83099 * Return the size of a slob block.
83100 */
83101 -static slobidx_t slob_units(slob_t *s)
83102 +static slobidx_t slob_units(const slob_t *s)
83103 {
83104 if (s->units > 0)
83105 return s->units;
83106 @@ -167,7 +167,7 @@ static slobidx_t slob_units(slob_t *s)
83107 /*
83108 * Return the next free slob block pointer after this one.
83109 */
83110 -static slob_t *slob_next(slob_t *s)
83111 +static slob_t *slob_next(const slob_t *s)
83112 {
83113 slob_t *base = (slob_t *)((unsigned long)s & PAGE_MASK);
83114 slobidx_t next;
83115 @@ -182,14 +182,14 @@ static slob_t *slob_next(slob_t *s)
83116 /*
83117 * Returns true if s is the last free block in its page.
83118 */
83119 -static int slob_last(slob_t *s)
83120 +static int slob_last(const slob_t *s)
83121 {
83122 return !((unsigned long)slob_next(s) & ~PAGE_MASK);
83123 }
83124
83125 -static void *slob_new_pages(gfp_t gfp, int order, int node)
83126 +static struct page *slob_new_pages(gfp_t gfp, unsigned int order, int node)
83127 {
83128 - void *page;
83129 + struct page *page;
83130
83131 #ifdef CONFIG_NUMA
83132 if (node != NUMA_NO_NODE)
83133 @@ -201,14 +201,18 @@ static void *slob_new_pages(gfp_t gfp, int order, int node)
83134 if (!page)
83135 return NULL;
83136
83137 - return page_address(page);
83138 + __SetPageSlab(page);
83139 + return page;
83140 }
83141
83142 -static void slob_free_pages(void *b, int order)
83143 +static void slob_free_pages(struct page *sp, int order)
83144 {
83145 if (current->reclaim_state)
83146 current->reclaim_state->reclaimed_slab += 1 << order;
83147 - free_pages((unsigned long)b, order);
83148 + __ClearPageSlab(sp);
83149 + reset_page_mapcount(sp);
83150 + sp->private = 0;
83151 + __free_pages(sp, order);
83152 }
83153
83154 /*
83155 @@ -313,15 +317,15 @@ static void *slob_alloc(size_t size, gfp_t gfp, int align, int node)
83156
83157 /* Not enough space: must allocate a new page */
83158 if (!b) {
83159 - b = slob_new_pages(gfp & ~__GFP_ZERO, 0, node);
83160 - if (!b)
83161 + sp = slob_new_pages(gfp & ~__GFP_ZERO, 0, node);
83162 + if (!sp)
83163 return NULL;
83164 - sp = virt_to_page(b);
83165 - __SetPageSlab(sp);
83166 + b = page_address(sp);
83167
83168 spin_lock_irqsave(&slob_lock, flags);
83169 sp->units = SLOB_UNITS(PAGE_SIZE);
83170 sp->freelist = b;
83171 + sp->private = 0;
83172 INIT_LIST_HEAD(&sp->list);
83173 set_slob(b, SLOB_UNITS(PAGE_SIZE), b + SLOB_UNITS(PAGE_SIZE));
83174 set_slob_page_free(sp, slob_list);
83175 @@ -359,9 +363,7 @@ static void slob_free(void *block, int size)
83176 if (slob_page_free(sp))
83177 clear_slob_page_free(sp);
83178 spin_unlock_irqrestore(&slob_lock, flags);
83179 - __ClearPageSlab(sp);
83180 - reset_page_mapcount(sp);
83181 - slob_free_pages(b, 0);
83182 + slob_free_pages(sp, 0);
83183 return;
83184 }
83185
83186 @@ -424,11 +426,10 @@ out:
83187 */
83188
83189 static __always_inline void *
83190 -__do_kmalloc_node(size_t size, gfp_t gfp, int node, unsigned long caller)
83191 +__do_kmalloc_node_align(size_t size, gfp_t gfp, int node, unsigned long caller, int align)
83192 {
83193 - unsigned int *m;
83194 - int align = max_t(size_t, ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
83195 - void *ret;
83196 + slob_t *m;
83197 + void *ret = NULL;
83198
83199 gfp &= gfp_allowed_mask;
83200
83201 @@ -442,23 +443,41 @@ __do_kmalloc_node(size_t size, gfp_t gfp, int node, unsigned long caller)
83202
83203 if (!m)
83204 return NULL;
83205 - *m = size;
83206 + BUILD_BUG_ON(ARCH_KMALLOC_MINALIGN < 2 * SLOB_UNIT);
83207 + BUILD_BUG_ON(ARCH_SLAB_MINALIGN < 2 * SLOB_UNIT);
83208 + m[0].units = size;
83209 + m[1].units = align;
83210 ret = (void *)m + align;
83211
83212 trace_kmalloc_node(caller, ret,
83213 size, size + align, gfp, node);
83214 } else {
83215 unsigned int order = get_order(size);
83216 + struct page *page;
83217
83218 if (likely(order))
83219 gfp |= __GFP_COMP;
83220 - ret = slob_new_pages(gfp, order, node);
83221 + page = slob_new_pages(gfp, order, node);
83222 + if (page) {
83223 + ret = page_address(page);
83224 + page->private = size;
83225 + }
83226
83227 trace_kmalloc_node(caller, ret,
83228 size, PAGE_SIZE << order, gfp, node);
83229 }
83230
83231 - kmemleak_alloc(ret, size, 1, gfp);
83232 + return ret;
83233 +}
83234 +
83235 +static __always_inline void *
83236 +__do_kmalloc_node(size_t size, gfp_t gfp, int node, unsigned long caller)
83237 +{
83238 + int align = max(ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
83239 + void *ret = __do_kmalloc_node_align(size, gfp, node, caller, align);
83240 +
83241 + if (!ZERO_OR_NULL_PTR(ret))
83242 + kmemleak_alloc(ret, size, 1, gfp);
83243 return ret;
83244 }
83245
83246 @@ -494,33 +513,110 @@ void kfree(const void *block)
83247 kmemleak_free(block);
83248
83249 sp = virt_to_page(block);
83250 - if (PageSlab(sp)) {
83251 + VM_BUG_ON(!PageSlab(sp));
83252 + if (!sp->private) {
83253 int align = max_t(size_t, ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
83254 - unsigned int *m = (unsigned int *)(block - align);
83255 - slob_free(m, *m + align);
83256 - } else
83257 + slob_t *m = (slob_t *)(block - align);
83258 + slob_free(m, m[0].units + align);
83259 + } else {
83260 + __ClearPageSlab(sp);
83261 + reset_page_mapcount(sp);
83262 + sp->private = 0;
83263 __free_pages(sp, compound_order(sp));
83264 + }
83265 }
83266 EXPORT_SYMBOL(kfree);
83267
83268 +bool is_usercopy_object(const void *ptr)
83269 +{
83270 + if (!slab_is_available())
83271 + return false;
83272 +
83273 + // PAX: TODO
83274 +
83275 + return false;
83276 +}
83277 +
83278 +#ifdef CONFIG_PAX_USERCOPY
83279 +const char *check_heap_object(const void *ptr, unsigned long n)
83280 +{
83281 + struct page *page;
83282 + const slob_t *free;
83283 + const void *base;
83284 + unsigned long flags;
83285 +
83286 + if (ZERO_OR_NULL_PTR(ptr))
83287 + return "<null>";
83288 +
83289 + if (!virt_addr_valid(ptr))
83290 + return NULL;
83291 +
83292 + page = virt_to_head_page(ptr);
83293 + if (!PageSlab(page))
83294 + return NULL;
83295 +
83296 + if (page->private) {
83297 + base = page;
83298 + if (base <= ptr && n <= page->private - (ptr - base))
83299 + return NULL;
83300 + return "<slob>";
83301 + }
83302 +
83303 + /* some tricky double walking to find the chunk */
83304 + spin_lock_irqsave(&slob_lock, flags);
83305 + base = (void *)((unsigned long)ptr & PAGE_MASK);
83306 + free = page->freelist;
83307 +
83308 + while (!slob_last(free) && (void *)free <= ptr) {
83309 + base = free + slob_units(free);
83310 + free = slob_next(free);
83311 + }
83312 +
83313 + while (base < (void *)free) {
83314 + slobidx_t m = ((slob_t *)base)[0].units, align = ((slob_t *)base)[1].units;
83315 + int size = SLOB_UNIT * SLOB_UNITS(m + align);
83316 + int offset;
83317 +
83318 + if (ptr < base + align)
83319 + break;
83320 +
83321 + offset = ptr - base - align;
83322 + if (offset >= m) {
83323 + base += size;
83324 + continue;
83325 + }
83326 +
83327 + if (n > m - offset)
83328 + break;
83329 +
83330 + spin_unlock_irqrestore(&slob_lock, flags);
83331 + return NULL;
83332 + }
83333 +
83334 + spin_unlock_irqrestore(&slob_lock, flags);
83335 + return "<slob>";
83336 +}
83337 +#endif
83338 +
83339 /* can't use ksize for kmem_cache_alloc memory, only kmalloc */
83340 size_t ksize(const void *block)
83341 {
83342 struct page *sp;
83343 int align;
83344 - unsigned int *m;
83345 + slob_t *m;
83346
83347 BUG_ON(!block);
83348 if (unlikely(block == ZERO_SIZE_PTR))
83349 return 0;
83350
83351 sp = virt_to_page(block);
83352 - if (unlikely(!PageSlab(sp)))
83353 - return PAGE_SIZE << compound_order(sp);
83354 + VM_BUG_ON(!PageSlab(sp));
83355 + if (sp->private)
83356 + return sp->private;
83357
83358 align = max_t(size_t, ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
83359 - m = (unsigned int *)(block - align);
83360 - return SLOB_UNITS(*m) * SLOB_UNIT;
83361 + m = (slob_t *)(block - align);
83362 + return SLOB_UNITS(m[0].units) * SLOB_UNIT;
83363 }
83364 EXPORT_SYMBOL(ksize);
83365
83366 @@ -536,23 +632,33 @@ int __kmem_cache_create(struct kmem_cache *c, unsigned long flags)
83367
83368 void *kmem_cache_alloc_node(struct kmem_cache *c, gfp_t flags, int node)
83369 {
83370 - void *b;
83371 + void *b = NULL;
83372
83373 flags &= gfp_allowed_mask;
83374
83375 lockdep_trace_alloc(flags);
83376
83377 +#ifdef CONFIG_PAX_USERCOPY_SLABS
83378 + b = __do_kmalloc_node_align(c->size, flags, node, _RET_IP_, c->align);
83379 +#else
83380 if (c->size < PAGE_SIZE) {
83381 b = slob_alloc(c->size, flags, c->align, node);
83382 trace_kmem_cache_alloc_node(_RET_IP_, b, c->object_size,
83383 SLOB_UNITS(c->size) * SLOB_UNIT,
83384 flags, node);
83385 } else {
83386 - b = slob_new_pages(flags, get_order(c->size), node);
83387 + struct page *sp;
83388 +
83389 + sp = slob_new_pages(flags, get_order(c->size), node);
83390 + if (sp) {
83391 + b = page_address(sp);
83392 + sp->private = c->size;
83393 + }
83394 trace_kmem_cache_alloc_node(_RET_IP_, b, c->object_size,
83395 PAGE_SIZE << get_order(c->size),
83396 flags, node);
83397 }
83398 +#endif
83399
83400 if (c->ctor)
83401 c->ctor(b);
83402 @@ -564,10 +670,14 @@ EXPORT_SYMBOL(kmem_cache_alloc_node);
83403
83404 static void __kmem_cache_free(void *b, int size)
83405 {
83406 - if (size < PAGE_SIZE)
83407 + struct page *sp;
83408 +
83409 + sp = virt_to_page(b);
83410 + BUG_ON(!PageSlab(sp));
83411 + if (!sp->private)
83412 slob_free(b, size);
83413 else
83414 - slob_free_pages(b, get_order(size));
83415 + slob_free_pages(sp, get_order(size));
83416 }
83417
83418 static void kmem_rcu_free(struct rcu_head *head)
83419 @@ -580,17 +690,31 @@ static void kmem_rcu_free(struct rcu_head *head)
83420
83421 void kmem_cache_free(struct kmem_cache *c, void *b)
83422 {
83423 + int size = c->size;
83424 +
83425 +#ifdef CONFIG_PAX_USERCOPY_SLABS
83426 + if (size + c->align < PAGE_SIZE) {
83427 + size += c->align;
83428 + b -= c->align;
83429 + }
83430 +#endif
83431 +
83432 kmemleak_free_recursive(b, c->flags);
83433 if (unlikely(c->flags & SLAB_DESTROY_BY_RCU)) {
83434 struct slob_rcu *slob_rcu;
83435 - slob_rcu = b + (c->size - sizeof(struct slob_rcu));
83436 - slob_rcu->size = c->size;
83437 + slob_rcu = b + (size - sizeof(struct slob_rcu));
83438 + slob_rcu->size = size;
83439 call_rcu(&slob_rcu->head, kmem_rcu_free);
83440 } else {
83441 - __kmem_cache_free(b, c->size);
83442 + __kmem_cache_free(b, size);
83443 }
83444
83445 +#ifdef CONFIG_PAX_USERCOPY_SLABS
83446 + trace_kfree(_RET_IP_, b);
83447 +#else
83448 trace_kmem_cache_free(_RET_IP_, b);
83449 +#endif
83450 +
83451 }
83452 EXPORT_SYMBOL(kmem_cache_free);
83453
83454 diff --git a/mm/slub.c b/mm/slub.c
83455 index ba2ca53..00b1f4e 100644
83456 --- a/mm/slub.c
83457 +++ b/mm/slub.c
83458 @@ -197,7 +197,7 @@ struct track {
83459
83460 enum track_item { TRACK_ALLOC, TRACK_FREE };
83461
83462 -#ifdef CONFIG_SYSFS
83463 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
83464 static int sysfs_slab_add(struct kmem_cache *);
83465 static int sysfs_slab_alias(struct kmem_cache *, const char *);
83466 static void sysfs_slab_remove(struct kmem_cache *);
83467 @@ -518,7 +518,7 @@ static void print_track(const char *s, struct track *t)
83468 if (!t->addr)
83469 return;
83470
83471 - printk(KERN_ERR "INFO: %s in %pS age=%lu cpu=%u pid=%d\n",
83472 + printk(KERN_ERR "INFO: %s in %pA age=%lu cpu=%u pid=%d\n",
83473 s, (void *)t->addr, jiffies - t->when, t->cpu, t->pid);
83474 #ifdef CONFIG_STACKTRACE
83475 {
83476 @@ -2653,7 +2653,7 @@ static int slub_min_objects;
83477 * Merge control. If this is set then no merging of slab caches will occur.
83478 * (Could be removed. This was introduced to pacify the merge skeptics.)
83479 */
83480 -static int slub_nomerge;
83481 +static int slub_nomerge = 1;
83482
83483 /*
83484 * Calculate the order of allocation given an slab object size.
83485 @@ -3181,6 +3181,10 @@ EXPORT_SYMBOL(kmalloc_caches);
83486 static struct kmem_cache *kmalloc_dma_caches[SLUB_PAGE_SHIFT];
83487 #endif
83488
83489 +#ifdef CONFIG_PAX_USERCOPY_SLABS
83490 +static struct kmem_cache *kmalloc_usercopy_caches[SLUB_PAGE_SHIFT];
83491 +#endif
83492 +
83493 static int __init setup_slub_min_order(char *str)
83494 {
83495 get_option(&str, &slub_min_order);
83496 @@ -3272,6 +3276,13 @@ static struct kmem_cache *get_slab(size_t size, gfp_t flags)
83497 return kmalloc_dma_caches[index];
83498
83499 #endif
83500 +
83501 +#ifdef CONFIG_PAX_USERCOPY_SLABS
83502 + if (flags & SLAB_USERCOPY)
83503 + return kmalloc_usercopy_caches[index];
83504 +
83505 +#endif
83506 +
83507 return kmalloc_caches[index];
83508 }
83509
83510 @@ -3340,6 +3351,59 @@ void *__kmalloc_node(size_t size, gfp_t flags, int node)
83511 EXPORT_SYMBOL(__kmalloc_node);
83512 #endif
83513
83514 +bool is_usercopy_object(const void *ptr)
83515 +{
83516 + struct page *page;
83517 + struct kmem_cache *s;
83518 +
83519 + if (ZERO_OR_NULL_PTR(ptr))
83520 + return false;
83521 +
83522 + if (!slab_is_available())
83523 + return false;
83524 +
83525 + if (!virt_addr_valid(ptr))
83526 + return false;
83527 +
83528 + page = virt_to_head_page(ptr);
83529 +
83530 + if (!PageSlab(page))
83531 + return false;
83532 +
83533 + s = page->slab_cache;
83534 + return s->flags & SLAB_USERCOPY;
83535 +}
83536 +
83537 +#ifdef CONFIG_PAX_USERCOPY
83538 +const char *check_heap_object(const void *ptr, unsigned long n)
83539 +{
83540 + struct page *page;
83541 + struct kmem_cache *s;
83542 + unsigned long offset;
83543 +
83544 + if (ZERO_OR_NULL_PTR(ptr))
83545 + return "<null>";
83546 +
83547 + if (!virt_addr_valid(ptr))
83548 + return NULL;
83549 +
83550 + page = virt_to_head_page(ptr);
83551 +
83552 + if (!PageSlab(page))
83553 + return NULL;
83554 +
83555 + s = page->slab_cache;
83556 + if (!(s->flags & SLAB_USERCOPY))
83557 + return s->name;
83558 +
83559 + offset = (ptr - page_address(page)) % s->size;
83560 + if (offset <= s->object_size && n <= s->object_size - offset)
83561 + return NULL;
83562 +
83563 + return s->name;
83564 +}
83565 +#endif
83566 +
83567 size_t ksize(const void *object)
83568 {
83569 struct page *page;
83570 @@ -3712,17 +3776,17 @@ void __init kmem_cache_init(void)
83571
83572 /* Caches that are not of the two-to-the-power-of size */
83573 if (KMALLOC_MIN_SIZE <= 32) {
83574 - kmalloc_caches[1] = create_kmalloc_cache("kmalloc-96", 96, 0);
83575 + kmalloc_caches[1] = create_kmalloc_cache("kmalloc-96", 96, SLAB_USERCOPY);
83576 caches++;
83577 }
83578
83579 if (KMALLOC_MIN_SIZE <= 64) {
83580 - kmalloc_caches[2] = create_kmalloc_cache("kmalloc-192", 192, 0);
83581 + kmalloc_caches[2] = create_kmalloc_cache("kmalloc-192", 192, SLAB_USERCOPY);
83582 caches++;
83583 }
83584
83585 for (i = KMALLOC_SHIFT_LOW; i < SLUB_PAGE_SHIFT; i++) {
83586 - kmalloc_caches[i] = create_kmalloc_cache("kmalloc", 1 << i, 0);
83587 + kmalloc_caches[i] = create_kmalloc_cache("kmalloc", 1 << i, SLAB_USERCOPY);
83588 caches++;
83589 }
83590
83591 @@ -3764,6 +3828,22 @@ void __init kmem_cache_init(void)
83592 }
83593 }
83594 #endif
83595 +
83596 +#ifdef CONFIG_PAX_USERCOPY_SLABS
83597 + for (i = 0; i < SLUB_PAGE_SHIFT; i++) {
83598 + struct kmem_cache *s = kmalloc_caches[i];
83599 +
83600 + if (s && s->size) {
83601 + char *name = kasprintf(GFP_NOWAIT,
83602 + "usercopy-kmalloc-%d", s->object_size);
83603 +
83604 + BUG_ON(!name);
83605 + kmalloc_usercopy_caches[i] = create_kmalloc_cache(name,
83606 + s->object_size, SLAB_USERCOPY);
83607 + }
83608 + }
83609 +#endif
83610 +
83611 printk(KERN_INFO
83612 "SLUB: Genslabs=%d, HWalign=%d, Order=%d-%d, MinObjects=%d,"
83613 " CPUs=%d, Nodes=%d\n",
83614 @@ -3790,7 +3870,7 @@ static int slab_unmergeable(struct kmem_cache *s)
83615 /*
83616 * We may have set a slab to be unmergeable during bootstrap.
83617 */
83618 - if (s->refcount < 0)
83619 + if (atomic_read(&s->refcount) < 0)
83620 return 1;
83621
83622 return 0;
83623 @@ -3848,7 +3928,7 @@ __kmem_cache_alias(struct mem_cgroup *memcg, const char *name, size_t size,
83624
83625 s = find_mergeable(memcg, size, align, flags, name, ctor);
83626 if (s) {
83627 - s->refcount++;
83628 + atomic_inc(&s->refcount);
83629 /*
83630 * Adjust the object sizes so that we clear
83631 * the complete object on kzalloc.
83632 @@ -3857,7 +3937,7 @@ __kmem_cache_alias(struct mem_cgroup *memcg, const char *name, size_t size,
83633 s->inuse = max_t(int, s->inuse, ALIGN(size, sizeof(void *)));
83634
83635 if (sysfs_slab_alias(s, name)) {
83636 - s->refcount--;
83637 + atomic_dec(&s->refcount);
83638 s = NULL;
83639 }
83640 }
83641 @@ -3919,7 +3999,7 @@ static int __cpuinit slab_cpuup_callback(struct notifier_block *nfb,
83642 return NOTIFY_OK;
83643 }
83644
83645 -static struct notifier_block __cpuinitdata slab_notifier = {
83646 +static struct notifier_block slab_notifier = {
83647 .notifier_call = slab_cpuup_callback
83648 };
83649
83650 @@ -3977,7 +4057,7 @@ void *__kmalloc_node_track_caller(size_t size, gfp_t gfpflags,
83651 }
83652 #endif
83653
83654 -#ifdef CONFIG_SYSFS
83655 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
83656 static int count_inuse(struct page *page)
83657 {
83658 return page->inuse;
83659 @@ -4364,12 +4444,12 @@ static void resiliency_test(void)
83660 validate_slab_cache(kmalloc_caches[9]);
83661 }
83662 #else
83663 -#ifdef CONFIG_SYSFS
83664 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
83665 static void resiliency_test(void) {};
83666 #endif
83667 #endif
83668
83669 -#ifdef CONFIG_SYSFS
83670 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
83671 enum slab_stat_type {
83672 SL_ALL, /* All slabs */
83673 SL_PARTIAL, /* Only partially allocated slabs */
83674 @@ -4613,7 +4693,7 @@ SLAB_ATTR_RO(ctor);
83675
83676 static ssize_t aliases_show(struct kmem_cache *s, char *buf)
83677 {
83678 - return sprintf(buf, "%d\n", s->refcount - 1);
83679 + return sprintf(buf, "%d\n", atomic_read(&s->refcount) - 1);
83680 }
83681 SLAB_ATTR_RO(aliases);
83682
83683 @@ -5266,6 +5346,7 @@ static char *create_unique_id(struct kmem_cache *s)
83684 return name;
83685 }
83686
83687 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
83688 static int sysfs_slab_add(struct kmem_cache *s)
83689 {
83690 int err;
83691 @@ -5323,6 +5404,7 @@ static void sysfs_slab_remove(struct kmem_cache *s)
83692 kobject_del(&s->kobj);
83693 kobject_put(&s->kobj);
83694 }
83695 +#endif
83696
83697 /*
83698 * Need to buffer aliases during bootup until sysfs becomes
83699 @@ -5336,6 +5418,7 @@ struct saved_alias {
83700
83701 static struct saved_alias *alias_list;
83702
83703 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
83704 static int sysfs_slab_alias(struct kmem_cache *s, const char *name)
83705 {
83706 struct saved_alias *al;
83707 @@ -5358,6 +5441,7 @@ static int sysfs_slab_alias(struct kmem_cache *s, const char *name)
83708 alias_list = al;
83709 return 0;
83710 }
83711 +#endif
83712
83713 static int __init slab_sysfs_init(void)
83714 {
83715 diff --git a/mm/sparse-vmemmap.c b/mm/sparse-vmemmap.c
83716 index 1b7e22a..3fcd4f3 100644
83717 --- a/mm/sparse-vmemmap.c
83718 +++ b/mm/sparse-vmemmap.c
83719 @@ -128,7 +128,7 @@ pud_t * __meminit vmemmap_pud_populate(pgd_t *pgd, unsigned long addr, int node)
83720 void *p = vmemmap_alloc_block(PAGE_SIZE, node);
83721 if (!p)
83722 return NULL;
83723 - pud_populate(&init_mm, pud, p);
83724 + pud_populate_kernel(&init_mm, pud, p);
83725 }
83726 return pud;
83727 }
83728 @@ -140,7 +140,7 @@ pgd_t * __meminit vmemmap_pgd_populate(unsigned long addr, int node)
83729 void *p = vmemmap_alloc_block(PAGE_SIZE, node);
83730 if (!p)
83731 return NULL;
83732 - pgd_populate(&init_mm, pgd, p);
83733 + pgd_populate_kernel(&init_mm, pgd, p);
83734 }
83735 return pgd;
83736 }
83737 diff --git a/mm/sparse.c b/mm/sparse.c
83738 index 6b5fb76..db0c190 100644
83739 --- a/mm/sparse.c
83740 +++ b/mm/sparse.c
83741 @@ -782,7 +782,7 @@ static void clear_hwpoisoned_pages(struct page *memmap, int nr_pages)
83742
83743 for (i = 0; i < PAGES_PER_SECTION; i++) {
83744 if (PageHWPoison(&memmap[i])) {
83745 - atomic_long_sub(1, &mce_bad_pages);
83746 + atomic_long_sub_unchecked(1, &mce_bad_pages);
83747 ClearPageHWPoison(&memmap[i]);
83748 }
83749 }
83750 diff --git a/mm/swap.c b/mm/swap.c
83751 index 6310dc2..3662b3f 100644
83752 --- a/mm/swap.c
83753 +++ b/mm/swap.c
83754 @@ -30,6 +30,7 @@
83755 #include <linux/backing-dev.h>
83756 #include <linux/memcontrol.h>
83757 #include <linux/gfp.h>
83758 +#include <linux/hugetlb.h>
83759
83760 #include "internal.h"
83761
83762 @@ -72,6 +73,8 @@ static void __put_compound_page(struct page *page)
83763
83764 __page_cache_release(page);
83765 dtor = get_compound_page_dtor(page);
83766 + if (!PageHuge(page))
83767 + BUG_ON(dtor != free_compound_page);
83768 (*dtor)(page);
83769 }
83770
83771 diff --git a/mm/swapfile.c b/mm/swapfile.c
83772 index e97a0e5..b50e796 100644
83773 --- a/mm/swapfile.c
83774 +++ b/mm/swapfile.c
83775 @@ -64,7 +64,7 @@ static DEFINE_MUTEX(swapon_mutex);
83776
83777 static DECLARE_WAIT_QUEUE_HEAD(proc_poll_wait);
83778 /* Activity counter to indicate that a swapon or swapoff has occurred */
83779 -static atomic_t proc_poll_event = ATOMIC_INIT(0);
83780 +static atomic_unchecked_t proc_poll_event = ATOMIC_INIT(0);
83781
83782 static inline unsigned char swap_count(unsigned char ent)
83783 {
83784 @@ -1608,7 +1608,7 @@ SYSCALL_DEFINE1(swapoff, const char __user *, specialfile)
83785 }
83786 filp_close(swap_file, NULL);
83787 err = 0;
83788 - atomic_inc(&proc_poll_event);
83789 + atomic_inc_unchecked(&proc_poll_event);
83790 wake_up_interruptible(&proc_poll_wait);
83791
83792 out_dput:
83793 @@ -1625,8 +1625,8 @@ static unsigned swaps_poll(struct file *file, poll_table *wait)
83794
83795 poll_wait(file, &proc_poll_wait, wait);
83796
83797 - if (seq->poll_event != atomic_read(&proc_poll_event)) {
83798 - seq->poll_event = atomic_read(&proc_poll_event);
83799 + if (seq->poll_event != atomic_read_unchecked(&proc_poll_event)) {
83800 + seq->poll_event = atomic_read_unchecked(&proc_poll_event);
83801 return POLLIN | POLLRDNORM | POLLERR | POLLPRI;
83802 }
83803
83804 @@ -1724,7 +1724,7 @@ static int swaps_open(struct inode *inode, struct file *file)
83805 return ret;
83806
83807 seq = file->private_data;
83808 - seq->poll_event = atomic_read(&proc_poll_event);
83809 + seq->poll_event = atomic_read_unchecked(&proc_poll_event);
83810 return 0;
83811 }
83812
83813 @@ -2066,7 +2066,7 @@ SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags)
83814 (frontswap_map) ? "FS" : "");
83815
83816 mutex_unlock(&swapon_mutex);
83817 - atomic_inc(&proc_poll_event);
83818 + atomic_inc_unchecked(&proc_poll_event);
83819 wake_up_interruptible(&proc_poll_wait);
83820
83821 if (S_ISREG(inode->i_mode))
83822 diff --git a/mm/util.c b/mm/util.c
83823 index c55e26b..3f913a9 100644
83824 --- a/mm/util.c
83825 +++ b/mm/util.c
83826 @@ -292,6 +292,12 @@ done:
83827 void arch_pick_mmap_layout(struct mm_struct *mm)
83828 {
83829 mm->mmap_base = TASK_UNMAPPED_BASE;
83830 +
83831 +#ifdef CONFIG_PAX_RANDMMAP
83832 + if (mm->pax_flags & MF_PAX_RANDMMAP)
83833 + mm->mmap_base += mm->delta_mmap;
83834 +#endif
83835 +
83836 mm->get_unmapped_area = arch_get_unmapped_area;
83837 mm->unmap_area = arch_unmap_area;
83838 }
83839 diff --git a/mm/vmalloc.c b/mm/vmalloc.c
83840 index 5123a16..f234a48 100644
83841 --- a/mm/vmalloc.c
83842 +++ b/mm/vmalloc.c
83843 @@ -39,8 +39,19 @@ static void vunmap_pte_range(pmd_t *pmd, unsigned long addr, unsigned long end)
83844
83845 pte = pte_offset_kernel(pmd, addr);
83846 do {
83847 - pte_t ptent = ptep_get_and_clear(&init_mm, addr, pte);
83848 - WARN_ON(!pte_none(ptent) && !pte_present(ptent));
83849 +
83850 +#if defined(CONFIG_MODULES) && defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
83851 + if ((unsigned long)MODULES_EXEC_VADDR <= addr && addr < (unsigned long)MODULES_EXEC_END) {
83852 + BUG_ON(!pte_exec(*pte));
83853 + set_pte_at(&init_mm, addr, pte, pfn_pte(__pa(addr) >> PAGE_SHIFT, PAGE_KERNEL_EXEC));
83854 + continue;
83855 + }
83856 +#endif
83857 +
83858 + {
83859 + pte_t ptent = ptep_get_and_clear(&init_mm, addr, pte);
83860 + WARN_ON(!pte_none(ptent) && !pte_present(ptent));
83861 + }
83862 } while (pte++, addr += PAGE_SIZE, addr != end);
83863 }
83864
83865 @@ -100,16 +111,29 @@ static int vmap_pte_range(pmd_t *pmd, unsigned long addr,
83866 pte = pte_alloc_kernel(pmd, addr);
83867 if (!pte)
83868 return -ENOMEM;
83869 +
83870 + pax_open_kernel();
83871 do {
83872 struct page *page = pages[*nr];
83873
83874 - if (WARN_ON(!pte_none(*pte)))
83875 +#if defined(CONFIG_MODULES) && defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
83876 + if (pgprot_val(prot) & _PAGE_NX)
83877 +#endif
83878 +
83879 + if (!pte_none(*pte)) {
83880 + pax_close_kernel();
83881 + WARN_ON(1);
83882 return -EBUSY;
83883 - if (WARN_ON(!page))
83884 + }
83885 + if (!page) {
83886 + pax_close_kernel();
83887 + WARN_ON(1);
83888 return -ENOMEM;
83889 + }
83890 set_pte_at(&init_mm, addr, pte, mk_pte(page, prot));
83891 (*nr)++;
83892 } while (pte++, addr += PAGE_SIZE, addr != end);
83893 + pax_close_kernel();
83894 return 0;
83895 }
83896
83897 @@ -119,7 +143,7 @@ static int vmap_pmd_range(pud_t *pud, unsigned long addr,
83898 pmd_t *pmd;
83899 unsigned long next;
83900
83901 - pmd = pmd_alloc(&init_mm, pud, addr);
83902 + pmd = pmd_alloc_kernel(&init_mm, pud, addr);
83903 if (!pmd)
83904 return -ENOMEM;
83905 do {
83906 @@ -136,7 +160,7 @@ static int vmap_pud_range(pgd_t *pgd, unsigned long addr,
83907 pud_t *pud;
83908 unsigned long next;
83909
83910 - pud = pud_alloc(&init_mm, pgd, addr);
83911 + pud = pud_alloc_kernel(&init_mm, pgd, addr);
83912 if (!pud)
83913 return -ENOMEM;
83914 do {
83915 @@ -191,11 +215,20 @@ int is_vmalloc_or_module_addr(const void *x)
83916 * and fall back on vmalloc() if that fails. Others
83917 * just put it in the vmalloc space.
83918 */
83919 -#if defined(CONFIG_MODULES) && defined(MODULES_VADDR)
83920 +#ifdef CONFIG_MODULES
83921 +#ifdef MODULES_VADDR
83922 unsigned long addr = (unsigned long)x;
83923 if (addr >= MODULES_VADDR && addr < MODULES_END)
83924 return 1;
83925 #endif
83926 +
83927 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
83928 + if (x >= (const void *)MODULES_EXEC_VADDR && x < (const void *)MODULES_EXEC_END)
83929 + return 1;
83930 +#endif
83931 +
83932 +#endif
83933 +
83934 return is_vmalloc_addr(x);
83935 }
83936
83937 @@ -216,8 +249,14 @@ struct page *vmalloc_to_page(const void *vmalloc_addr)
83938
83939 if (!pgd_none(*pgd)) {
83940 pud_t *pud = pud_offset(pgd, addr);
83941 +#ifdef CONFIG_X86
83942 + if (!pud_large(*pud))
83943 +#endif
83944 if (!pud_none(*pud)) {
83945 pmd_t *pmd = pmd_offset(pud, addr);
83946 +#ifdef CONFIG_X86
83947 + if (!pmd_large(*pmd))
83948 +#endif
83949 if (!pmd_none(*pmd)) {
83950 pte_t *ptep, pte;
83951
83952 @@ -329,7 +368,7 @@ static void purge_vmap_area_lazy(void);
83953 * Allocate a region of KVA of the specified size and alignment, within the
83954 * vstart and vend.
83955 */
83956 -static struct vmap_area *alloc_vmap_area(unsigned long size,
83957 +static __size_overflow(1) struct vmap_area *alloc_vmap_area(unsigned long size,
83958 unsigned long align,
83959 unsigned long vstart, unsigned long vend,
83960 int node, gfp_t gfp_mask)
83961 @@ -1328,6 +1367,16 @@ static struct vm_struct *__get_vm_area_node(unsigned long size,
83962 struct vm_struct *area;
83963
83964 BUG_ON(in_interrupt());
83965 +
83966 +#if defined(CONFIG_MODULES) && defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
83967 + if (flags & VM_KERNEXEC) {
83968 + if (start != VMALLOC_START || end != VMALLOC_END)
83969 + return NULL;
83970 + start = (unsigned long)MODULES_EXEC_VADDR;
83971 + end = (unsigned long)MODULES_EXEC_END;
83972 + }
83973 +#endif
83974 +
83975 if (flags & VM_IOREMAP) {
83976 int bit = fls(size);
83977
83978 @@ -1568,6 +1617,11 @@ void *vmap(struct page **pages, unsigned int count,
83979 if (count > totalram_pages)
83980 return NULL;
83981
83982 +#if defined(CONFIG_MODULES) && defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
83983 + if (!(pgprot_val(prot) & _PAGE_NX))
83984 + flags |= VM_KERNEXEC;
83985 +#endif
83986 +
83987 area = get_vm_area_caller((count << PAGE_SHIFT), flags,
83988 __builtin_return_address(0));
83989 if (!area)
83990 @@ -1669,6 +1723,13 @@ void *__vmalloc_node_range(unsigned long size, unsigned long align,
83991 if (!size || (size >> PAGE_SHIFT) > totalram_pages)
83992 goto fail;
83993
83994 +#if defined(CONFIG_MODULES) && defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
83995 + if (!(pgprot_val(prot) & _PAGE_NX))
83996 + area = __get_vm_area_node(size, align, VM_ALLOC | VM_UNLIST | VM_KERNEXEC,
83997 + VMALLOC_START, VMALLOC_END, node, gfp_mask, caller);
83998 + else
83999 +#endif
84000 +
84001 area = __get_vm_area_node(size, align, VM_ALLOC | VM_UNLIST,
84002 start, end, node, gfp_mask, caller);
84003 if (!area)
84004 @@ -1842,10 +1903,9 @@ EXPORT_SYMBOL(vzalloc_node);
84005 * For tight control over page level allocator and protection flags
84006 * use __vmalloc() instead.
84007 */
84008 -
84009 void *vmalloc_exec(unsigned long size)
84010 {
84011 - return __vmalloc_node(size, 1, GFP_KERNEL | __GFP_HIGHMEM, PAGE_KERNEL_EXEC,
84012 + return __vmalloc_node(size, 1, GFP_KERNEL | __GFP_HIGHMEM | __GFP_ZERO, PAGE_KERNEL_EXEC,
84013 -1, __builtin_return_address(0));
84014 }
84015
84016 @@ -2136,6 +2196,8 @@ int remap_vmalloc_range(struct vm_area_struct *vma, void *addr,
84017 unsigned long uaddr = vma->vm_start;
84018 unsigned long usize = vma->vm_end - vma->vm_start;
84019
84020 + BUG_ON(vma->vm_mirror);
84021 +
84022 if ((PAGE_SIZE-1) & (unsigned long)addr)
84023 return -EINVAL;
84024
84025 @@ -2575,7 +2637,11 @@ static int s_show(struct seq_file *m, void *p)
84026 v->addr, v->addr + v->size, v->size);
84027
84028 if (v->caller)
84029 +#ifdef CONFIG_GRKERNSEC_HIDESYM
84030 + seq_printf(m, " %pK", v->caller);
84031 +#else
84032 seq_printf(m, " %pS", v->caller);
84033 +#endif
84034
84035 if (v->nr_pages)
84036 seq_printf(m, " pages=%d", v->nr_pages);
84037 diff --git a/mm/vmstat.c b/mm/vmstat.c
84038 index 9800306..76b4b27 100644
84039 --- a/mm/vmstat.c
84040 +++ b/mm/vmstat.c
84041 @@ -78,7 +78,7 @@ void vm_events_fold_cpu(int cpu)
84042 *
84043 * vm_stat contains the global counters
84044 */
84045 -atomic_long_t vm_stat[NR_VM_ZONE_STAT_ITEMS] __cacheline_aligned_in_smp;
84046 +atomic_long_unchecked_t vm_stat[NR_VM_ZONE_STAT_ITEMS] __cacheline_aligned_in_smp;
84047 EXPORT_SYMBOL(vm_stat);
84048
84049 #ifdef CONFIG_SMP
84050 @@ -454,7 +454,7 @@ void refresh_cpu_vm_stats(int cpu)
84051 v = p->vm_stat_diff[i];
84052 p->vm_stat_diff[i] = 0;
84053 local_irq_restore(flags);
84054 - atomic_long_add(v, &zone->vm_stat[i]);
84055 + atomic_long_add_unchecked(v, &zone->vm_stat[i]);
84056 global_diff[i] += v;
84057 #ifdef CONFIG_NUMA
84058 /* 3 seconds idle till flush */
84059 @@ -492,7 +492,7 @@ void refresh_cpu_vm_stats(int cpu)
84060
84061 for (i = 0; i < NR_VM_ZONE_STAT_ITEMS; i++)
84062 if (global_diff[i])
84063 - atomic_long_add(global_diff[i], &vm_stat[i]);
84064 + atomic_long_add_unchecked(global_diff[i], &vm_stat[i]);
84065 }
84066
84067 void drain_zonestat(struct zone *zone, struct per_cpu_pageset *pset)
84068 @@ -503,8 +503,8 @@ void drain_zonestat(struct zone *zone, struct per_cpu_pageset *pset)
84069 if (pset->vm_stat_diff[i]) {
84070 int v = pset->vm_stat_diff[i];
84071 pset->vm_stat_diff[i] = 0;
84072 - atomic_long_add(v, &zone->vm_stat[i]);
84073 - atomic_long_add(v, &vm_stat[i]);
84074 + atomic_long_add_unchecked(v, &zone->vm_stat[i]);
84075 + atomic_long_add_unchecked(v, &vm_stat[i]);
84076 }
84077 }
84078 #endif
84079 @@ -1223,7 +1223,7 @@ static int __cpuinit vmstat_cpuup_callback(struct notifier_block *nfb,
84080 return NOTIFY_OK;
84081 }
84082
84083 -static struct notifier_block __cpuinitdata vmstat_notifier =
84084 +static struct notifier_block vmstat_notifier =
84085 { &vmstat_cpuup_callback, NULL, 0 };
84086 #endif
84087
84088 @@ -1238,10 +1238,20 @@ static int __init setup_vmstat(void)
84089 start_cpu_timer(cpu);
84090 #endif
84091 #ifdef CONFIG_PROC_FS
84092 - proc_create("buddyinfo", S_IRUGO, NULL, &fragmentation_file_operations);
84093 - proc_create("pagetypeinfo", S_IRUGO, NULL, &pagetypeinfo_file_ops);
84094 - proc_create("vmstat", S_IRUGO, NULL, &proc_vmstat_file_operations);
84095 - proc_create("zoneinfo", S_IRUGO, NULL, &proc_zoneinfo_file_operations);
84096 + {
84097 + mode_t gr_mode = S_IRUGO;
84098 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
84099 + gr_mode = S_IRUSR;
84100 +#endif
84101 + proc_create("buddyinfo", gr_mode, NULL, &fragmentation_file_operations);
84102 + proc_create("pagetypeinfo", gr_mode, NULL, &pagetypeinfo_file_ops);
84103 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
84104 + proc_create("vmstat", gr_mode | S_IRGRP, NULL, &proc_vmstat_file_operations);
84105 +#else
84106 + proc_create("vmstat", gr_mode, NULL, &proc_vmstat_file_operations);
84107 +#endif
84108 + proc_create("zoneinfo", gr_mode, NULL, &proc_zoneinfo_file_operations);
84109 + }
84110 #endif
84111 return 0;
84112 }
84113 diff --git a/net/8021q/vlan.c b/net/8021q/vlan.c
84114 index a292e80..785ee68 100644
84115 --- a/net/8021q/vlan.c
84116 +++ b/net/8021q/vlan.c
84117 @@ -485,7 +485,7 @@ out:
84118 return NOTIFY_DONE;
84119 }
84120
84121 -static struct notifier_block vlan_notifier_block __read_mostly = {
84122 +static struct notifier_block vlan_notifier_block = {
84123 .notifier_call = vlan_device_event,
84124 };
84125
84126 @@ -560,8 +560,7 @@ static int vlan_ioctl_handler(struct net *net, void __user *arg)
84127 err = -EPERM;
84128 if (!ns_capable(net->user_ns, CAP_NET_ADMIN))
84129 break;
84130 - if ((args.u.name_type >= 0) &&
84131 - (args.u.name_type < VLAN_NAME_TYPE_HIGHEST)) {
84132 + if (args.u.name_type < VLAN_NAME_TYPE_HIGHEST) {
84133 struct vlan_net *vn;
84134
84135 vn = net_generic(net, vlan_net_id);
84136 diff --git a/net/9p/mod.c b/net/9p/mod.c
84137 index 6ab36ae..6f1841b 100644
84138 --- a/net/9p/mod.c
84139 +++ b/net/9p/mod.c
84140 @@ -84,7 +84,7 @@ static LIST_HEAD(v9fs_trans_list);
84141 void v9fs_register_trans(struct p9_trans_module *m)
84142 {
84143 spin_lock(&v9fs_trans_lock);
84144 - list_add_tail(&m->list, &v9fs_trans_list);
84145 + pax_list_add_tail((struct list_head *)&m->list, &v9fs_trans_list);
84146 spin_unlock(&v9fs_trans_lock);
84147 }
84148 EXPORT_SYMBOL(v9fs_register_trans);
84149 @@ -97,7 +97,7 @@ EXPORT_SYMBOL(v9fs_register_trans);
84150 void v9fs_unregister_trans(struct p9_trans_module *m)
84151 {
84152 spin_lock(&v9fs_trans_lock);
84153 - list_del_init(&m->list);
84154 + pax_list_del_init((struct list_head *)&m->list);
84155 spin_unlock(&v9fs_trans_lock);
84156 }
84157 EXPORT_SYMBOL(v9fs_unregister_trans);
84158 diff --git a/net/9p/trans_fd.c b/net/9p/trans_fd.c
84159 index 02efb25..41541a9 100644
84160 --- a/net/9p/trans_fd.c
84161 +++ b/net/9p/trans_fd.c
84162 @@ -425,7 +425,7 @@ static int p9_fd_write(struct p9_client *client, void *v, int len)
84163 oldfs = get_fs();
84164 set_fs(get_ds());
84165 /* The cast to a user pointer is valid due to the set_fs() */
84166 - ret = vfs_write(ts->wr, (__force void __user *)v, len, &ts->wr->f_pos);
84167 + ret = vfs_write(ts->wr, (void __force_user *)v, len, &ts->wr->f_pos);
84168 set_fs(oldfs);
84169
84170 if (ret <= 0 && ret != -ERESTARTSYS && ret != -EAGAIN)
84171 diff --git a/net/atm/atm_misc.c b/net/atm/atm_misc.c
84172 index 876fbe8..8bbea9f 100644
84173 --- a/net/atm/atm_misc.c
84174 +++ b/net/atm/atm_misc.c
84175 @@ -17,7 +17,7 @@ int atm_charge(struct atm_vcc *vcc, int truesize)
84176 if (atomic_read(&sk_atm(vcc)->sk_rmem_alloc) <= sk_atm(vcc)->sk_rcvbuf)
84177 return 1;
84178 atm_return(vcc, truesize);
84179 - atomic_inc(&vcc->stats->rx_drop);
84180 + atomic_inc_unchecked(&vcc->stats->rx_drop);
84181 return 0;
84182 }
84183 EXPORT_SYMBOL(atm_charge);
84184 @@ -39,7 +39,7 @@ struct sk_buff *atm_alloc_charge(struct atm_vcc *vcc, int pdu_size,
84185 }
84186 }
84187 atm_return(vcc, guess);
84188 - atomic_inc(&vcc->stats->rx_drop);
84189 + atomic_inc_unchecked(&vcc->stats->rx_drop);
84190 return NULL;
84191 }
84192 EXPORT_SYMBOL(atm_alloc_charge);
84193 @@ -86,7 +86,7 @@ EXPORT_SYMBOL(atm_pcr_goal);
84194
84195 void sonet_copy_stats(struct k_sonet_stats *from, struct sonet_stats *to)
84196 {
84197 -#define __HANDLE_ITEM(i) to->i = atomic_read(&from->i)
84198 +#define __HANDLE_ITEM(i) to->i = atomic_read_unchecked(&from->i)
84199 __SONET_ITEMS
84200 #undef __HANDLE_ITEM
84201 }
84202 @@ -94,7 +94,7 @@ EXPORT_SYMBOL(sonet_copy_stats);
84203
84204 void sonet_subtract_stats(struct k_sonet_stats *from, struct sonet_stats *to)
84205 {
84206 -#define __HANDLE_ITEM(i) atomic_sub(to->i, &from->i)
84207 +#define __HANDLE_ITEM(i) atomic_sub_unchecked(to->i,&from->i)
84208 __SONET_ITEMS
84209 #undef __HANDLE_ITEM
84210 }
84211 diff --git a/net/atm/lec.h b/net/atm/lec.h
84212 index a86aff9..3a0d6f6 100644
84213 --- a/net/atm/lec.h
84214 +++ b/net/atm/lec.h
84215 @@ -48,7 +48,7 @@ struct lane2_ops {
84216 const u8 *tlvs, u32 sizeoftlvs);
84217 void (*associate_indicator) (struct net_device *dev, const u8 *mac_addr,
84218 const u8 *tlvs, u32 sizeoftlvs);
84219 -};
84220 +} __no_const;
84221
84222 /*
84223 * ATM LAN Emulation supports both LLC & Dix Ethernet EtherType
84224 diff --git a/net/atm/proc.c b/net/atm/proc.c
84225 index 0d020de..011c7bb 100644
84226 --- a/net/atm/proc.c
84227 +++ b/net/atm/proc.c
84228 @@ -45,9 +45,9 @@ static void add_stats(struct seq_file *seq, const char *aal,
84229 const struct k_atm_aal_stats *stats)
84230 {
84231 seq_printf(seq, "%s ( %d %d %d %d %d )", aal,
84232 - atomic_read(&stats->tx), atomic_read(&stats->tx_err),
84233 - atomic_read(&stats->rx), atomic_read(&stats->rx_err),
84234 - atomic_read(&stats->rx_drop));
84235 + atomic_read_unchecked(&stats->tx),atomic_read_unchecked(&stats->tx_err),
84236 + atomic_read_unchecked(&stats->rx),atomic_read_unchecked(&stats->rx_err),
84237 + atomic_read_unchecked(&stats->rx_drop));
84238 }
84239
84240 static void atm_dev_info(struct seq_file *seq, const struct atm_dev *dev)
84241 diff --git a/net/atm/resources.c b/net/atm/resources.c
84242 index 0447d5d..3cf4728 100644
84243 --- a/net/atm/resources.c
84244 +++ b/net/atm/resources.c
84245 @@ -160,7 +160,7 @@ EXPORT_SYMBOL(atm_dev_deregister);
84246 static void copy_aal_stats(struct k_atm_aal_stats *from,
84247 struct atm_aal_stats *to)
84248 {
84249 -#define __HANDLE_ITEM(i) to->i = atomic_read(&from->i)
84250 +#define __HANDLE_ITEM(i) to->i = atomic_read_unchecked(&from->i)
84251 __AAL_STAT_ITEMS
84252 #undef __HANDLE_ITEM
84253 }
84254 @@ -168,7 +168,7 @@ static void copy_aal_stats(struct k_atm_aal_stats *from,
84255 static void subtract_aal_stats(struct k_atm_aal_stats *from,
84256 struct atm_aal_stats *to)
84257 {
84258 -#define __HANDLE_ITEM(i) atomic_sub(to->i, &from->i)
84259 +#define __HANDLE_ITEM(i) atomic_sub_unchecked(to->i, &from->i)
84260 __AAL_STAT_ITEMS
84261 #undef __HANDLE_ITEM
84262 }
84263 diff --git a/net/ax25/sysctl_net_ax25.c b/net/ax25/sysctl_net_ax25.c
84264 index d5744b7..506bae3 100644
84265 --- a/net/ax25/sysctl_net_ax25.c
84266 +++ b/net/ax25/sysctl_net_ax25.c
84267 @@ -152,7 +152,7 @@ int ax25_register_dev_sysctl(ax25_dev *ax25_dev)
84268 {
84269 char path[sizeof("net/ax25/") + IFNAMSIZ];
84270 int k;
84271 - struct ctl_table *table;
84272 + ctl_table_no_const *table;
84273
84274 table = kmemdup(ax25_param_table, sizeof(ax25_param_table), GFP_KERNEL);
84275 if (!table)
84276 diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c
84277 index 7d02ebd..4d4cc01 100644
84278 --- a/net/batman-adv/bat_iv_ogm.c
84279 +++ b/net/batman-adv/bat_iv_ogm.c
84280 @@ -63,7 +63,7 @@ static int batadv_iv_ogm_iface_enable(struct batadv_hard_iface *hard_iface)
84281
84282 /* randomize initial seqno to avoid collision */
84283 get_random_bytes(&random_seqno, sizeof(random_seqno));
84284 - atomic_set(&hard_iface->bat_iv.ogm_seqno, random_seqno);
84285 + atomic_set_unchecked(&hard_iface->bat_iv.ogm_seqno, random_seqno);
84286
84287 hard_iface->bat_iv.ogm_buff_len = BATADV_OGM_HLEN;
84288 ogm_buff = kmalloc(hard_iface->bat_iv.ogm_buff_len, GFP_ATOMIC);
84289 @@ -615,9 +615,9 @@ static void batadv_iv_ogm_schedule(struct batadv_hard_iface *hard_iface)
84290 batadv_ogm_packet = (struct batadv_ogm_packet *)(*ogm_buff);
84291
84292 /* change sequence number to network order */
84293 - seqno = (uint32_t)atomic_read(&hard_iface->bat_iv.ogm_seqno);
84294 + seqno = (uint32_t)atomic_read_unchecked(&hard_iface->bat_iv.ogm_seqno);
84295 batadv_ogm_packet->seqno = htonl(seqno);
84296 - atomic_inc(&hard_iface->bat_iv.ogm_seqno);
84297 + atomic_inc_unchecked(&hard_iface->bat_iv.ogm_seqno);
84298
84299 batadv_ogm_packet->ttvn = atomic_read(&bat_priv->tt.vn);
84300 batadv_ogm_packet->tt_crc = htons(bat_priv->tt.local_crc);
84301 @@ -1022,7 +1022,7 @@ static void batadv_iv_ogm_process(const struct ethhdr *ethhdr,
84302 return;
84303
84304 /* could be changed by schedule_own_packet() */
84305 - if_incoming_seqno = atomic_read(&if_incoming->bat_iv.ogm_seqno);
84306 + if_incoming_seqno = atomic_read_unchecked(&if_incoming->bat_iv.ogm_seqno);
84307
84308 if (batadv_ogm_packet->flags & BATADV_DIRECTLINK)
84309 has_directlink_flag = 1;
84310 diff --git a/net/batman-adv/hard-interface.c b/net/batman-adv/hard-interface.c
84311 index f1d37cd..4190879 100644
84312 --- a/net/batman-adv/hard-interface.c
84313 +++ b/net/batman-adv/hard-interface.c
84314 @@ -370,7 +370,7 @@ int batadv_hardif_enable_interface(struct batadv_hard_iface *hard_iface,
84315 hard_iface->batman_adv_ptype.dev = hard_iface->net_dev;
84316 dev_add_pack(&hard_iface->batman_adv_ptype);
84317
84318 - atomic_set(&hard_iface->frag_seqno, 1);
84319 + atomic_set_unchecked(&hard_iface->frag_seqno, 1);
84320 batadv_info(hard_iface->soft_iface, "Adding interface: %s\n",
84321 hard_iface->net_dev->name);
84322
84323 @@ -493,7 +493,7 @@ batadv_hardif_add_interface(struct net_device *net_dev)
84324 /* This can't be called via a bat_priv callback because
84325 * we have no bat_priv yet.
84326 */
84327 - atomic_set(&hard_iface->bat_iv.ogm_seqno, 1);
84328 + atomic_set_unchecked(&hard_iface->bat_iv.ogm_seqno, 1);
84329 hard_iface->bat_iv.ogm_buff = NULL;
84330
84331 return hard_iface;
84332 diff --git a/net/batman-adv/soft-interface.c b/net/batman-adv/soft-interface.c
84333 index 6b548fd..fc32c8d 100644
84334 --- a/net/batman-adv/soft-interface.c
84335 +++ b/net/batman-adv/soft-interface.c
84336 @@ -252,7 +252,7 @@ static int batadv_interface_tx(struct sk_buff *skb,
84337 primary_if->net_dev->dev_addr, ETH_ALEN);
84338
84339 /* set broadcast sequence number */
84340 - seqno = atomic_inc_return(&bat_priv->bcast_seqno);
84341 + seqno = atomic_inc_return_unchecked(&bat_priv->bcast_seqno);
84342 bcast_packet->seqno = htonl(seqno);
84343
84344 batadv_add_bcast_packet_to_list(bat_priv, skb, brd_delay);
84345 @@ -497,7 +497,7 @@ struct net_device *batadv_softif_create(const char *name)
84346 atomic_set(&bat_priv->batman_queue_left, BATADV_BATMAN_QUEUE_LEN);
84347
84348 atomic_set(&bat_priv->mesh_state, BATADV_MESH_INACTIVE);
84349 - atomic_set(&bat_priv->bcast_seqno, 1);
84350 + atomic_set_unchecked(&bat_priv->bcast_seqno, 1);
84351 atomic_set(&bat_priv->tt.vn, 0);
84352 atomic_set(&bat_priv->tt.local_changes, 0);
84353 atomic_set(&bat_priv->tt.ogm_append_cnt, 0);
84354 diff --git a/net/batman-adv/types.h b/net/batman-adv/types.h
84355 index ae9ac9a..11e0fe7 100644
84356 --- a/net/batman-adv/types.h
84357 +++ b/net/batman-adv/types.h
84358 @@ -48,7 +48,7 @@
84359 struct batadv_hard_iface_bat_iv {
84360 unsigned char *ogm_buff;
84361 int ogm_buff_len;
84362 - atomic_t ogm_seqno;
84363 + atomic_unchecked_t ogm_seqno;
84364 };
84365
84366 struct batadv_hard_iface {
84367 @@ -56,7 +56,7 @@ struct batadv_hard_iface {
84368 int16_t if_num;
84369 char if_status;
84370 struct net_device *net_dev;
84371 - atomic_t frag_seqno;
84372 + atomic_unchecked_t frag_seqno;
84373 struct kobject *hardif_obj;
84374 atomic_t refcount;
84375 struct packet_type batman_adv_ptype;
84376 @@ -284,7 +284,7 @@ struct batadv_priv {
84377 atomic_t orig_interval; /* uint */
84378 atomic_t hop_penalty; /* uint */
84379 atomic_t log_level; /* uint */
84380 - atomic_t bcast_seqno;
84381 + atomic_unchecked_t bcast_seqno;
84382 atomic_t bcast_queue_left;
84383 atomic_t batman_queue_left;
84384 char num_ifaces;
84385 diff --git a/net/batman-adv/unicast.c b/net/batman-adv/unicast.c
84386 index 10aff49..ea8e021 100644
84387 --- a/net/batman-adv/unicast.c
84388 +++ b/net/batman-adv/unicast.c
84389 @@ -272,7 +272,7 @@ int batadv_frag_send_skb(struct sk_buff *skb, struct batadv_priv *bat_priv,
84390 frag1->flags = BATADV_UNI_FRAG_HEAD | large_tail;
84391 frag2->flags = large_tail;
84392
84393 - seqno = atomic_add_return(2, &hard_iface->frag_seqno);
84394 + seqno = atomic_add_return_unchecked(2, &hard_iface->frag_seqno);
84395 frag1->seqno = htons(seqno - 1);
84396 frag2->seqno = htons(seqno);
84397
84398 diff --git a/net/bluetooth/hci_sock.c b/net/bluetooth/hci_sock.c
84399 index 07f0739..3c42e34 100644
84400 --- a/net/bluetooth/hci_sock.c
84401 +++ b/net/bluetooth/hci_sock.c
84402 @@ -934,7 +934,7 @@ static int hci_sock_setsockopt(struct socket *sock, int level, int optname,
84403 uf.event_mask[1] = *((u32 *) f->event_mask + 1);
84404 }
84405
84406 - len = min_t(unsigned int, len, sizeof(uf));
84407 + len = min((size_t)len, sizeof(uf));
84408 if (copy_from_user(&uf, optval, len)) {
84409 err = -EFAULT;
84410 break;
84411 diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
84412 index 22e6583..426e2f3 100644
84413 --- a/net/bluetooth/l2cap_core.c
84414 +++ b/net/bluetooth/l2cap_core.c
84415 @@ -3400,8 +3400,10 @@ static int l2cap_parse_conf_rsp(struct l2cap_chan *chan, void *rsp, int len,
84416 break;
84417
84418 case L2CAP_CONF_RFC:
84419 - if (olen == sizeof(rfc))
84420 - memcpy(&rfc, (void *)val, olen);
84421 + if (olen != sizeof(rfc))
84422 + break;
84423 +
84424 + memcpy(&rfc, (void *)val, olen);
84425
84426 if (test_bit(CONF_STATE2_DEVICE, &chan->conf_state) &&
84427 rfc.mode != chan->mode)
84428 diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c
84429 index 1bcfb84..dad9f98 100644
84430 --- a/net/bluetooth/l2cap_sock.c
84431 +++ b/net/bluetooth/l2cap_sock.c
84432 @@ -479,7 +479,8 @@ static int l2cap_sock_setsockopt_old(struct socket *sock, int optname,
84433 struct sock *sk = sock->sk;
84434 struct l2cap_chan *chan = l2cap_pi(sk)->chan;
84435 struct l2cap_options opts;
84436 - int len, err = 0;
84437 + int err = 0;
84438 + size_t len = optlen;
84439 u32 opt;
84440
84441 BT_DBG("sk %p", sk);
84442 @@ -501,7 +502,7 @@ static int l2cap_sock_setsockopt_old(struct socket *sock, int optname,
84443 opts.max_tx = chan->max_tx;
84444 opts.txwin_size = chan->tx_win;
84445
84446 - len = min_t(unsigned int, sizeof(opts), optlen);
84447 + len = min(sizeof(opts), len);
84448 if (copy_from_user((char *) &opts, optval, len)) {
84449 err = -EFAULT;
84450 break;
84451 @@ -581,7 +582,8 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname,
84452 struct bt_security sec;
84453 struct bt_power pwr;
84454 struct l2cap_conn *conn;
84455 - int len, err = 0;
84456 + int err = 0;
84457 + size_t len = optlen;
84458 u32 opt;
84459
84460 BT_DBG("sk %p", sk);
84461 @@ -604,7 +606,7 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname,
84462
84463 sec.level = BT_SECURITY_LOW;
84464
84465 - len = min_t(unsigned int, sizeof(sec), optlen);
84466 + len = min(sizeof(sec), len);
84467 if (copy_from_user((char *) &sec, optval, len)) {
84468 err = -EFAULT;
84469 break;
84470 @@ -701,7 +703,7 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname,
84471
84472 pwr.force_active = BT_POWER_FORCE_ACTIVE_ON;
84473
84474 - len = min_t(unsigned int, sizeof(pwr), optlen);
84475 + len = min(sizeof(pwr), len);
84476 if (copy_from_user((char *) &pwr, optval, len)) {
84477 err = -EFAULT;
84478 break;
84479 diff --git a/net/bluetooth/rfcomm/sock.c b/net/bluetooth/rfcomm/sock.c
84480 index ce3f665..2c7d08f 100644
84481 --- a/net/bluetooth/rfcomm/sock.c
84482 +++ b/net/bluetooth/rfcomm/sock.c
84483 @@ -667,7 +667,7 @@ static int rfcomm_sock_setsockopt(struct socket *sock, int level, int optname, c
84484 struct sock *sk = sock->sk;
84485 struct bt_security sec;
84486 int err = 0;
84487 - size_t len;
84488 + size_t len = optlen;
84489 u32 opt;
84490
84491 BT_DBG("sk %p", sk);
84492 @@ -689,7 +689,7 @@ static int rfcomm_sock_setsockopt(struct socket *sock, int level, int optname, c
84493
84494 sec.level = BT_SECURITY_LOW;
84495
84496 - len = min_t(unsigned int, sizeof(sec), optlen);
84497 + len = min(sizeof(sec), len);
84498 if (copy_from_user((char *) &sec, optval, len)) {
84499 err = -EFAULT;
84500 break;
84501 diff --git a/net/bluetooth/rfcomm/tty.c b/net/bluetooth/rfcomm/tty.c
84502 index bd6fd0f..6492cba 100644
84503 --- a/net/bluetooth/rfcomm/tty.c
84504 +++ b/net/bluetooth/rfcomm/tty.c
84505 @@ -309,7 +309,7 @@ static void rfcomm_dev_del(struct rfcomm_dev *dev)
84506 BUG_ON(test_and_set_bit(RFCOMM_TTY_RELEASED, &dev->flags));
84507
84508 spin_lock_irqsave(&dev->port.lock, flags);
84509 - if (dev->port.count > 0) {
84510 + if (atomic_read(&dev->port.count) > 0) {
84511 spin_unlock_irqrestore(&dev->port.lock, flags);
84512 return;
84513 }
84514 @@ -664,10 +664,10 @@ static int rfcomm_tty_open(struct tty_struct *tty, struct file *filp)
84515 return -ENODEV;
84516
84517 BT_DBG("dev %p dst %pMR channel %d opened %d", dev, &dev->dst,
84518 - dev->channel, dev->port.count);
84519 + dev->channel, atomic_read(&dev->port.count));
84520
84521 spin_lock_irqsave(&dev->port.lock, flags);
84522 - if (++dev->port.count > 1) {
84523 + if (atomic_inc_return(&dev->port.count) > 1) {
84524 spin_unlock_irqrestore(&dev->port.lock, flags);
84525 return 0;
84526 }
84527 @@ -732,10 +732,10 @@ static void rfcomm_tty_close(struct tty_struct *tty, struct file *filp)
84528 return;
84529
84530 BT_DBG("tty %p dev %p dlc %p opened %d", tty, dev, dev->dlc,
84531 - dev->port.count);
84532 + atomic_read(&dev->port.count));
84533
84534 spin_lock_irqsave(&dev->port.lock, flags);
84535 - if (!--dev->port.count) {
84536 + if (!atomic_dec_return(&dev->port.count)) {
84537 spin_unlock_irqrestore(&dev->port.lock, flags);
84538 if (dev->tty_dev->parent)
84539 device_move(dev->tty_dev, NULL, DPM_ORDER_DEV_LAST);
84540 diff --git a/net/bridge/br_mdb.c b/net/bridge/br_mdb.c
84541 index acc9f4c..2897e40 100644
84542 --- a/net/bridge/br_mdb.c
84543 +++ b/net/bridge/br_mdb.c
84544 @@ -82,6 +82,7 @@ static int br_mdb_fill_info(struct sk_buff *skb, struct netlink_callback *cb,
84545 port = p->port;
84546 if (port) {
84547 struct br_mdb_entry e;
84548 + memset(&e, 0, sizeof(e));
84549 e.ifindex = port->dev->ifindex;
84550 e.state = p->state;
84551 if (p->addr.proto == htons(ETH_P_IP))
84552 @@ -138,6 +139,7 @@ static int br_mdb_dump(struct sk_buff *skb, struct netlink_callback *cb)
84553 break;
84554
84555 bpm = nlmsg_data(nlh);
84556 + memset(bpm, 0, sizeof(*bpm));
84557 bpm->ifindex = dev->ifindex;
84558 if (br_mdb_fill_info(skb, cb, dev) < 0)
84559 goto out;
84560 @@ -173,6 +175,7 @@ static int nlmsg_populate_mdb_fill(struct sk_buff *skb,
84561 return -EMSGSIZE;
84562
84563 bpm = nlmsg_data(nlh);
84564 + memset(bpm, 0, sizeof(*bpm));
84565 bpm->family = AF_BRIDGE;
84566 bpm->ifindex = dev->ifindex;
84567 nest = nla_nest_start(skb, MDBA_MDB);
84568 @@ -230,6 +233,7 @@ void br_mdb_notify(struct net_device *dev, struct net_bridge_port *port,
84569 {
84570 struct br_mdb_entry entry;
84571
84572 + memset(&entry, 0, sizeof(entry));
84573 entry.ifindex = port->dev->ifindex;
84574 entry.addr.proto = group->proto;
84575 entry.addr.u.ip4 = group->u.ip4;
84576 diff --git a/net/bridge/netfilter/ebtables.c b/net/bridge/netfilter/ebtables.c
84577 index 5fe2ff3..121d696 100644
84578 --- a/net/bridge/netfilter/ebtables.c
84579 +++ b/net/bridge/netfilter/ebtables.c
84580 @@ -1523,7 +1523,7 @@ static int do_ebt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
84581 tmp.valid_hooks = t->table->valid_hooks;
84582 }
84583 mutex_unlock(&ebt_mutex);
84584 - if (copy_to_user(user, &tmp, *len) != 0){
84585 + if (*len > sizeof(tmp) || copy_to_user(user, &tmp, *len) != 0){
84586 BUGPRINT("c2u Didn't work\n");
84587 ret = -EFAULT;
84588 break;
84589 @@ -2327,7 +2327,7 @@ static int compat_do_ebt_get_ctl(struct sock *sk, int cmd,
84590 goto out;
84591 tmp.valid_hooks = t->valid_hooks;
84592
84593 - if (copy_to_user(user, &tmp, *len) != 0) {
84594 + if (*len > sizeof(tmp) || copy_to_user(user, &tmp, *len) != 0) {
84595 ret = -EFAULT;
84596 break;
84597 }
84598 @@ -2338,7 +2338,7 @@ static int compat_do_ebt_get_ctl(struct sock *sk, int cmd,
84599 tmp.entries_size = t->table->entries_size;
84600 tmp.valid_hooks = t->table->valid_hooks;
84601
84602 - if (copy_to_user(user, &tmp, *len) != 0) {
84603 + if (*len > sizeof(tmp) || copy_to_user(user, &tmp, *len) != 0) {
84604 ret = -EFAULT;
84605 break;
84606 }
84607 diff --git a/net/caif/cfctrl.c b/net/caif/cfctrl.c
84608 index a376ec1..1fbd6be 100644
84609 --- a/net/caif/cfctrl.c
84610 +++ b/net/caif/cfctrl.c
84611 @@ -10,6 +10,7 @@
84612 #include <linux/spinlock.h>
84613 #include <linux/slab.h>
84614 #include <linux/pkt_sched.h>
84615 +#include <linux/sched.h>
84616 #include <net/caif/caif_layer.h>
84617 #include <net/caif/cfpkt.h>
84618 #include <net/caif/cfctrl.h>
84619 @@ -43,8 +44,8 @@ struct cflayer *cfctrl_create(void)
84620 memset(&dev_info, 0, sizeof(dev_info));
84621 dev_info.id = 0xff;
84622 cfsrvl_init(&this->serv, 0, &dev_info, false);
84623 - atomic_set(&this->req_seq_no, 1);
84624 - atomic_set(&this->rsp_seq_no, 1);
84625 + atomic_set_unchecked(&this->req_seq_no, 1);
84626 + atomic_set_unchecked(&this->rsp_seq_no, 1);
84627 this->serv.layer.receive = cfctrl_recv;
84628 sprintf(this->serv.layer.name, "ctrl");
84629 this->serv.layer.ctrlcmd = cfctrl_ctrlcmd;
84630 @@ -130,8 +131,8 @@ static void cfctrl_insert_req(struct cfctrl *ctrl,
84631 struct cfctrl_request_info *req)
84632 {
84633 spin_lock_bh(&ctrl->info_list_lock);
84634 - atomic_inc(&ctrl->req_seq_no);
84635 - req->sequence_no = atomic_read(&ctrl->req_seq_no);
84636 + atomic_inc_unchecked(&ctrl->req_seq_no);
84637 + req->sequence_no = atomic_read_unchecked(&ctrl->req_seq_no);
84638 list_add_tail(&req->list, &ctrl->list);
84639 spin_unlock_bh(&ctrl->info_list_lock);
84640 }
84641 @@ -149,7 +150,7 @@ static struct cfctrl_request_info *cfctrl_remove_req(struct cfctrl *ctrl,
84642 if (p != first)
84643 pr_warn("Requests are not received in order\n");
84644
84645 - atomic_set(&ctrl->rsp_seq_no,
84646 + atomic_set_unchecked(&ctrl->rsp_seq_no,
84647 p->sequence_no);
84648 list_del(&p->list);
84649 goto out;
84650 diff --git a/net/can/af_can.c b/net/can/af_can.c
84651 index ddac1ee..3ee0a78 100644
84652 --- a/net/can/af_can.c
84653 +++ b/net/can/af_can.c
84654 @@ -872,7 +872,7 @@ static const struct net_proto_family can_family_ops = {
84655 };
84656
84657 /* notifier block for netdevice event */
84658 -static struct notifier_block can_netdev_notifier __read_mostly = {
84659 +static struct notifier_block can_netdev_notifier = {
84660 .notifier_call = can_notifier,
84661 };
84662
84663 diff --git a/net/can/gw.c b/net/can/gw.c
84664 index 574dda78e..3d2b3da 100644
84665 --- a/net/can/gw.c
84666 +++ b/net/can/gw.c
84667 @@ -67,7 +67,6 @@ MODULE_AUTHOR("Oliver Hartkopp <oliver.hartkopp@volkswagen.de>");
84668 MODULE_ALIAS("can-gw");
84669
84670 static HLIST_HEAD(cgw_list);
84671 -static struct notifier_block notifier;
84672
84673 static struct kmem_cache *cgw_cache __read_mostly;
84674
84675 @@ -893,6 +892,10 @@ static int cgw_remove_job(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg)
84676 return err;
84677 }
84678
84679 +static struct notifier_block notifier = {
84680 + .notifier_call = cgw_notifier
84681 +};
84682 +
84683 static __init int cgw_module_init(void)
84684 {
84685 printk(banner);
84686 @@ -904,7 +907,6 @@ static __init int cgw_module_init(void)
84687 return -ENOMEM;
84688
84689 /* set notifier */
84690 - notifier.notifier_call = cgw_notifier;
84691 register_netdevice_notifier(&notifier);
84692
84693 if (__rtnl_register(PF_CAN, RTM_GETROUTE, NULL, cgw_dump_jobs, NULL)) {
84694 diff --git a/net/compat.c b/net/compat.c
84695 index 79ae884..17c5c09 100644
84696 --- a/net/compat.c
84697 +++ b/net/compat.c
84698 @@ -71,9 +71,9 @@ int get_compat_msghdr(struct msghdr *kmsg, struct compat_msghdr __user *umsg)
84699 __get_user(kmsg->msg_controllen, &umsg->msg_controllen) ||
84700 __get_user(kmsg->msg_flags, &umsg->msg_flags))
84701 return -EFAULT;
84702 - kmsg->msg_name = compat_ptr(tmp1);
84703 - kmsg->msg_iov = compat_ptr(tmp2);
84704 - kmsg->msg_control = compat_ptr(tmp3);
84705 + kmsg->msg_name = (void __force_kernel *)compat_ptr(tmp1);
84706 + kmsg->msg_iov = (void __force_kernel *)compat_ptr(tmp2);
84707 + kmsg->msg_control = (void __force_kernel *)compat_ptr(tmp3);
84708 return 0;
84709 }
84710
84711 @@ -85,7 +85,7 @@ int verify_compat_iovec(struct msghdr *kern_msg, struct iovec *kern_iov,
84712
84713 if (kern_msg->msg_namelen) {
84714 if (mode == VERIFY_READ) {
84715 - int err = move_addr_to_kernel(kern_msg->msg_name,
84716 + int err = move_addr_to_kernel((void __force_user *)kern_msg->msg_name,
84717 kern_msg->msg_namelen,
84718 kern_address);
84719 if (err < 0)
84720 @@ -96,7 +96,7 @@ int verify_compat_iovec(struct msghdr *kern_msg, struct iovec *kern_iov,
84721 kern_msg->msg_name = NULL;
84722
84723 tot_len = iov_from_user_compat_to_kern(kern_iov,
84724 - (struct compat_iovec __user *)kern_msg->msg_iov,
84725 + (struct compat_iovec __force_user *)kern_msg->msg_iov,
84726 kern_msg->msg_iovlen);
84727 if (tot_len >= 0)
84728 kern_msg->msg_iov = kern_iov;
84729 @@ -116,20 +116,20 @@ int verify_compat_iovec(struct msghdr *kern_msg, struct iovec *kern_iov,
84730
84731 #define CMSG_COMPAT_FIRSTHDR(msg) \
84732 (((msg)->msg_controllen) >= sizeof(struct compat_cmsghdr) ? \
84733 - (struct compat_cmsghdr __user *)((msg)->msg_control) : \
84734 + (struct compat_cmsghdr __force_user *)((msg)->msg_control) : \
84735 (struct compat_cmsghdr __user *)NULL)
84736
84737 #define CMSG_COMPAT_OK(ucmlen, ucmsg, mhdr) \
84738 ((ucmlen) >= sizeof(struct compat_cmsghdr) && \
84739 (ucmlen) <= (unsigned long) \
84740 ((mhdr)->msg_controllen - \
84741 - ((char *)(ucmsg) - (char *)(mhdr)->msg_control)))
84742 + ((char __force_kernel *)(ucmsg) - (char *)(mhdr)->msg_control)))
84743
84744 static inline struct compat_cmsghdr __user *cmsg_compat_nxthdr(struct msghdr *msg,
84745 struct compat_cmsghdr __user *cmsg, int cmsg_len)
84746 {
84747 char __user *ptr = (char __user *)cmsg + CMSG_COMPAT_ALIGN(cmsg_len);
84748 - if ((unsigned long)(ptr + 1 - (char __user *)msg->msg_control) >
84749 + if ((unsigned long)(ptr + 1 - (char __force_user *)msg->msg_control) >
84750 msg->msg_controllen)
84751 return NULL;
84752 return (struct compat_cmsghdr __user *)ptr;
84753 @@ -219,7 +219,7 @@ Efault:
84754
84755 int put_cmsg_compat(struct msghdr *kmsg, int level, int type, int len, void *data)
84756 {
84757 - struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __user *) kmsg->msg_control;
84758 + struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __force_user *) kmsg->msg_control;
84759 struct compat_cmsghdr cmhdr;
84760 struct compat_timeval ctv;
84761 struct compat_timespec cts[3];
84762 @@ -275,7 +275,7 @@ int put_cmsg_compat(struct msghdr *kmsg, int level, int type, int len, void *dat
84763
84764 void scm_detach_fds_compat(struct msghdr *kmsg, struct scm_cookie *scm)
84765 {
84766 - struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __user *) kmsg->msg_control;
84767 + struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __force_user *) kmsg->msg_control;
84768 int fdmax = (kmsg->msg_controllen - sizeof(struct compat_cmsghdr)) / sizeof(int);
84769 int fdnum = scm->fp->count;
84770 struct file **fp = scm->fp->fp;
84771 @@ -363,7 +363,7 @@ static int do_set_sock_timeout(struct socket *sock, int level,
84772 return -EFAULT;
84773 old_fs = get_fs();
84774 set_fs(KERNEL_DS);
84775 - err = sock_setsockopt(sock, level, optname, (char *)&ktime, sizeof(ktime));
84776 + err = sock_setsockopt(sock, level, optname, (char __force_user *)&ktime, sizeof(ktime));
84777 set_fs(old_fs);
84778
84779 return err;
84780 @@ -424,7 +424,7 @@ static int do_get_sock_timeout(struct socket *sock, int level, int optname,
84781 len = sizeof(ktime);
84782 old_fs = get_fs();
84783 set_fs(KERNEL_DS);
84784 - err = sock_getsockopt(sock, level, optname, (char *) &ktime, &len);
84785 + err = sock_getsockopt(sock, level, optname, (char __force_user *) &ktime, (int __force_user *)&len);
84786 set_fs(old_fs);
84787
84788 if (!err) {
84789 @@ -567,7 +567,7 @@ int compat_mc_setsockopt(struct sock *sock, int level, int optname,
84790 case MCAST_JOIN_GROUP:
84791 case MCAST_LEAVE_GROUP:
84792 {
84793 - struct compat_group_req __user *gr32 = (void *)optval;
84794 + struct compat_group_req __user *gr32 = (void __user *)optval;
84795 struct group_req __user *kgr =
84796 compat_alloc_user_space(sizeof(struct group_req));
84797 u32 interface;
84798 @@ -588,7 +588,7 @@ int compat_mc_setsockopt(struct sock *sock, int level, int optname,
84799 case MCAST_BLOCK_SOURCE:
84800 case MCAST_UNBLOCK_SOURCE:
84801 {
84802 - struct compat_group_source_req __user *gsr32 = (void *)optval;
84803 + struct compat_group_source_req __user *gsr32 = (void __user *)optval;
84804 struct group_source_req __user *kgsr = compat_alloc_user_space(
84805 sizeof(struct group_source_req));
84806 u32 interface;
84807 @@ -609,7 +609,7 @@ int compat_mc_setsockopt(struct sock *sock, int level, int optname,
84808 }
84809 case MCAST_MSFILTER:
84810 {
84811 - struct compat_group_filter __user *gf32 = (void *)optval;
84812 + struct compat_group_filter __user *gf32 = (void __user *)optval;
84813 struct group_filter __user *kgf;
84814 u32 interface, fmode, numsrc;
84815
84816 @@ -647,7 +647,7 @@ int compat_mc_getsockopt(struct sock *sock, int level, int optname,
84817 char __user *optval, int __user *optlen,
84818 int (*getsockopt)(struct sock *, int, int, char __user *, int __user *))
84819 {
84820 - struct compat_group_filter __user *gf32 = (void *)optval;
84821 + struct compat_group_filter __user *gf32 = (void __user *)optval;
84822 struct group_filter __user *kgf;
84823 int __user *koptlen;
84824 u32 interface, fmode, numsrc;
84825 @@ -796,7 +796,7 @@ asmlinkage long compat_sys_socketcall(int call, u32 __user *args)
84826
84827 if (call < SYS_SOCKET || call > SYS_SENDMMSG)
84828 return -EINVAL;
84829 - if (copy_from_user(a, args, nas[call]))
84830 + if (nas[call] > sizeof a || copy_from_user(a, args, nas[call]))
84831 return -EFAULT;
84832 a0 = a[0];
84833 a1 = a[1];
84834 diff --git a/net/core/datagram.c b/net/core/datagram.c
84835 index 368f9c3..f82d4a3 100644
84836 --- a/net/core/datagram.c
84837 +++ b/net/core/datagram.c
84838 @@ -289,7 +289,7 @@ int skb_kill_datagram(struct sock *sk, struct sk_buff *skb, unsigned int flags)
84839 }
84840
84841 kfree_skb(skb);
84842 - atomic_inc(&sk->sk_drops);
84843 + atomic_inc_unchecked(&sk->sk_drops);
84844 sk_mem_reclaim_partial(sk);
84845
84846 return err;
84847 diff --git a/net/core/dev.c b/net/core/dev.c
84848 index f64e439..8f959e6 100644
84849 --- a/net/core/dev.c
84850 +++ b/net/core/dev.c
84851 @@ -1250,9 +1250,13 @@ void dev_load(struct net *net, const char *name)
84852 if (no_module && capable(CAP_NET_ADMIN))
84853 no_module = request_module("netdev-%s", name);
84854 if (no_module && capable(CAP_SYS_MODULE)) {
84855 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
84856 + ___request_module(true, "grsec_modharden_netdev", "%s", name);
84857 +#else
84858 if (!request_module("%s", name))
84859 pr_warn("Loading kernel module for a network device with CAP_SYS_MODULE (deprecated). Use CAP_NET_ADMIN and alias netdev-%s instead.\n",
84860 name);
84861 +#endif
84862 }
84863 }
84864 EXPORT_SYMBOL(dev_load);
84865 @@ -1715,7 +1719,7 @@ int dev_forward_skb(struct net_device *dev, struct sk_buff *skb)
84866 {
84867 if (skb_shinfo(skb)->tx_flags & SKBTX_DEV_ZEROCOPY) {
84868 if (skb_copy_ubufs(skb, GFP_ATOMIC)) {
84869 - atomic_long_inc(&dev->rx_dropped);
84870 + atomic_long_inc_unchecked(&dev->rx_dropped);
84871 kfree_skb(skb);
84872 return NET_RX_DROP;
84873 }
84874 @@ -1725,7 +1729,7 @@ int dev_forward_skb(struct net_device *dev, struct sk_buff *skb)
84875 nf_reset(skb);
84876
84877 if (unlikely(!is_skb_forwardable(dev, skb))) {
84878 - atomic_long_inc(&dev->rx_dropped);
84879 + atomic_long_inc_unchecked(&dev->rx_dropped);
84880 kfree_skb(skb);
84881 return NET_RX_DROP;
84882 }
84883 @@ -2180,7 +2184,7 @@ static int illegal_highdma(struct net_device *dev, struct sk_buff *skb)
84884
84885 struct dev_gso_cb {
84886 void (*destructor)(struct sk_buff *skb);
84887 -};
84888 +} __no_const;
84889
84890 #define DEV_GSO_CB(skb) ((struct dev_gso_cb *)(skb)->cb)
84891
84892 @@ -3053,7 +3057,7 @@ enqueue:
84893
84894 local_irq_restore(flags);
84895
84896 - atomic_long_inc(&skb->dev->rx_dropped);
84897 + atomic_long_inc_unchecked(&skb->dev->rx_dropped);
84898 kfree_skb(skb);
84899 return NET_RX_DROP;
84900 }
84901 @@ -3125,7 +3129,7 @@ int netif_rx_ni(struct sk_buff *skb)
84902 }
84903 EXPORT_SYMBOL(netif_rx_ni);
84904
84905 -static void net_tx_action(struct softirq_action *h)
84906 +static void net_tx_action(void)
84907 {
84908 struct softnet_data *sd = &__get_cpu_var(softnet_data);
84909
84910 @@ -3456,7 +3460,7 @@ ncls:
84911 ret = pt_prev->func(skb, skb->dev, pt_prev, orig_dev);
84912 } else {
84913 drop:
84914 - atomic_long_inc(&skb->dev->rx_dropped);
84915 + atomic_long_inc_unchecked(&skb->dev->rx_dropped);
84916 kfree_skb(skb);
84917 /* Jamal, now you will not able to escape explaining
84918 * me how you were going to use this. :-)
84919 @@ -4039,7 +4043,7 @@ void netif_napi_del(struct napi_struct *napi)
84920 }
84921 EXPORT_SYMBOL(netif_napi_del);
84922
84923 -static void net_rx_action(struct softirq_action *h)
84924 +static void net_rx_action(void)
84925 {
84926 struct softnet_data *sd = &__get_cpu_var(softnet_data);
84927 unsigned long time_limit = jiffies + 2;
84928 @@ -4523,8 +4527,13 @@ static int ptype_seq_show(struct seq_file *seq, void *v)
84929 else
84930 seq_printf(seq, "%04x", ntohs(pt->type));
84931
84932 +#ifdef CONFIG_GRKERNSEC_HIDESYM
84933 + seq_printf(seq, " %-8s %p\n",
84934 + pt->dev ? pt->dev->name : "", NULL);
84935 +#else
84936 seq_printf(seq, " %-8s %pF\n",
84937 pt->dev ? pt->dev->name : "", pt->func);
84938 +#endif
84939 }
84940
84941 return 0;
84942 @@ -6096,7 +6105,7 @@ struct rtnl_link_stats64 *dev_get_stats(struct net_device *dev,
84943 } else {
84944 netdev_stats_to_stats64(storage, &dev->stats);
84945 }
84946 - storage->rx_dropped += atomic_long_read(&dev->rx_dropped);
84947 + storage->rx_dropped += atomic_long_read_unchecked(&dev->rx_dropped);
84948 return storage;
84949 }
84950 EXPORT_SYMBOL(dev_get_stats);
84951 diff --git a/net/core/flow.c b/net/core/flow.c
84952 index b0901ee..7d3c2ca 100644
84953 --- a/net/core/flow.c
84954 +++ b/net/core/flow.c
84955 @@ -61,7 +61,7 @@ struct flow_cache {
84956 struct timer_list rnd_timer;
84957 };
84958
84959 -atomic_t flow_cache_genid = ATOMIC_INIT(0);
84960 +atomic_unchecked_t flow_cache_genid = ATOMIC_INIT(0);
84961 EXPORT_SYMBOL(flow_cache_genid);
84962 static struct flow_cache flow_cache_global;
84963 static struct kmem_cache *flow_cachep __read_mostly;
84964 @@ -86,7 +86,7 @@ static void flow_cache_new_hashrnd(unsigned long arg)
84965
84966 static int flow_entry_valid(struct flow_cache_entry *fle)
84967 {
84968 - if (atomic_read(&flow_cache_genid) != fle->genid)
84969 + if (atomic_read_unchecked(&flow_cache_genid) != fle->genid)
84970 return 0;
84971 if (fle->object && !fle->object->ops->check(fle->object))
84972 return 0;
84973 @@ -259,7 +259,7 @@ flow_cache_lookup(struct net *net, const struct flowi *key, u16 family, u8 dir,
84974 hlist_add_head(&fle->u.hlist, &fcp->hash_table[hash]);
84975 fcp->hash_count++;
84976 }
84977 - } else if (likely(fle->genid == atomic_read(&flow_cache_genid))) {
84978 + } else if (likely(fle->genid == atomic_read_unchecked(&flow_cache_genid))) {
84979 flo = fle->object;
84980 if (!flo)
84981 goto ret_object;
84982 @@ -280,7 +280,7 @@ nocache:
84983 }
84984 flo = resolver(net, key, family, dir, flo, ctx);
84985 if (fle) {
84986 - fle->genid = atomic_read(&flow_cache_genid);
84987 + fle->genid = atomic_read_unchecked(&flow_cache_genid);
84988 if (!IS_ERR(flo))
84989 fle->object = flo;
84990 else
84991 diff --git a/net/core/iovec.c b/net/core/iovec.c
84992 index 7e7aeb0..2a998cb 100644
84993 --- a/net/core/iovec.c
84994 +++ b/net/core/iovec.c
84995 @@ -42,7 +42,7 @@ int verify_iovec(struct msghdr *m, struct iovec *iov, struct sockaddr_storage *a
84996 if (m->msg_namelen) {
84997 if (mode == VERIFY_READ) {
84998 void __user *namep;
84999 - namep = (void __user __force *) m->msg_name;
85000 + namep = (void __force_user *) m->msg_name;
85001 err = move_addr_to_kernel(namep, m->msg_namelen,
85002 address);
85003 if (err < 0)
85004 @@ -54,7 +54,7 @@ int verify_iovec(struct msghdr *m, struct iovec *iov, struct sockaddr_storage *a
85005 }
85006
85007 size = m->msg_iovlen * sizeof(struct iovec);
85008 - if (copy_from_user(iov, (void __user __force *) m->msg_iov, size))
85009 + if (copy_from_user(iov, (void __force_user *) m->msg_iov, size))
85010 return -EFAULT;
85011
85012 m->msg_iov = iov;
85013 diff --git a/net/core/neighbour.c b/net/core/neighbour.c
85014 index c815f28..e6403f2 100644
85015 --- a/net/core/neighbour.c
85016 +++ b/net/core/neighbour.c
85017 @@ -2776,7 +2776,7 @@ static int proc_unres_qlen(ctl_table *ctl, int write, void __user *buffer,
85018 size_t *lenp, loff_t *ppos)
85019 {
85020 int size, ret;
85021 - ctl_table tmp = *ctl;
85022 + ctl_table_no_const tmp = *ctl;
85023
85024 tmp.extra1 = &zero;
85025 tmp.extra2 = &unres_qlen_max;
85026 diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c
85027 index 28c5f5a..7edf2e2 100644
85028 --- a/net/core/net-sysfs.c
85029 +++ b/net/core/net-sysfs.c
85030 @@ -1455,7 +1455,7 @@ void netdev_class_remove_file(struct class_attribute *class_attr)
85031 }
85032 EXPORT_SYMBOL(netdev_class_remove_file);
85033
85034 -int netdev_kobject_init(void)
85035 +int __init netdev_kobject_init(void)
85036 {
85037 kobj_ns_type_register(&net_ns_type_operations);
85038 return class_register(&net_class);
85039 diff --git a/net/core/net_namespace.c b/net/core/net_namespace.c
85040 index 8acce01..2e306bb 100644
85041 --- a/net/core/net_namespace.c
85042 +++ b/net/core/net_namespace.c
85043 @@ -442,7 +442,7 @@ static int __register_pernet_operations(struct list_head *list,
85044 int error;
85045 LIST_HEAD(net_exit_list);
85046
85047 - list_add_tail(&ops->list, list);
85048 + pax_list_add_tail((struct list_head *)&ops->list, list);
85049 if (ops->init || (ops->id && ops->size)) {
85050 for_each_net(net) {
85051 error = ops_init(ops, net);
85052 @@ -455,7 +455,7 @@ static int __register_pernet_operations(struct list_head *list,
85053
85054 out_undo:
85055 /* If I have an error cleanup all namespaces I initialized */
85056 - list_del(&ops->list);
85057 + pax_list_del((struct list_head *)&ops->list);
85058 ops_exit_list(ops, &net_exit_list);
85059 ops_free_list(ops, &net_exit_list);
85060 return error;
85061 @@ -466,7 +466,7 @@ static void __unregister_pernet_operations(struct pernet_operations *ops)
85062 struct net *net;
85063 LIST_HEAD(net_exit_list);
85064
85065 - list_del(&ops->list);
85066 + pax_list_del((struct list_head *)&ops->list);
85067 for_each_net(net)
85068 list_add_tail(&net->exit_list, &net_exit_list);
85069 ops_exit_list(ops, &net_exit_list);
85070 @@ -600,7 +600,7 @@ int register_pernet_device(struct pernet_operations *ops)
85071 mutex_lock(&net_mutex);
85072 error = register_pernet_operations(&pernet_list, ops);
85073 if (!error && (first_device == &pernet_list))
85074 - first_device = &ops->list;
85075 + first_device = (struct list_head *)&ops->list;
85076 mutex_unlock(&net_mutex);
85077 return error;
85078 }
85079 diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
85080 index 1868625..e2261f5 100644
85081 --- a/net/core/rtnetlink.c
85082 +++ b/net/core/rtnetlink.c
85083 @@ -58,7 +58,7 @@ struct rtnl_link {
85084 rtnl_doit_func doit;
85085 rtnl_dumpit_func dumpit;
85086 rtnl_calcit_func calcit;
85087 -};
85088 +} __no_const;
85089
85090 static DEFINE_MUTEX(rtnl_mutex);
85091
85092 @@ -299,10 +299,13 @@ int __rtnl_link_register(struct rtnl_link_ops *ops)
85093 if (rtnl_link_ops_get(ops->kind))
85094 return -EEXIST;
85095
85096 - if (!ops->dellink)
85097 - ops->dellink = unregister_netdevice_queue;
85098 + if (!ops->dellink) {
85099 + pax_open_kernel();
85100 + *(void **)&ops->dellink = unregister_netdevice_queue;
85101 + pax_close_kernel();
85102 + }
85103
85104 - list_add_tail(&ops->list, &link_ops);
85105 + pax_list_add_tail((struct list_head *)&ops->list, &link_ops);
85106 return 0;
85107 }
85108 EXPORT_SYMBOL_GPL(__rtnl_link_register);
85109 @@ -349,7 +352,7 @@ void __rtnl_link_unregister(struct rtnl_link_ops *ops)
85110 for_each_net(net) {
85111 __rtnl_kill_links(net, ops);
85112 }
85113 - list_del(&ops->list);
85114 + pax_list_del((struct list_head *)&ops->list);
85115 }
85116 EXPORT_SYMBOL_GPL(__rtnl_link_unregister);
85117
85118 @@ -976,6 +979,7 @@ static int rtnl_fill_ifinfo(struct sk_buff *skb, struct net_device *dev,
85119 * report anything.
85120 */
85121 ivi.spoofchk = -1;
85122 + memset(ivi.mac, 0, sizeof(ivi.mac));
85123 if (dev->netdev_ops->ndo_get_vf_config(dev, i, &ivi))
85124 break;
85125 vf_mac.vf =
85126 diff --git a/net/core/scm.c b/net/core/scm.c
85127 index 905dcc6..14ee2d6 100644
85128 --- a/net/core/scm.c
85129 +++ b/net/core/scm.c
85130 @@ -224,7 +224,7 @@ EXPORT_SYMBOL(__scm_send);
85131 int put_cmsg(struct msghdr * msg, int level, int type, int len, void *data)
85132 {
85133 struct cmsghdr __user *cm
85134 - = (__force struct cmsghdr __user *)msg->msg_control;
85135 + = (struct cmsghdr __force_user *)msg->msg_control;
85136 struct cmsghdr cmhdr;
85137 int cmlen = CMSG_LEN(len);
85138 int err;
85139 @@ -247,7 +247,7 @@ int put_cmsg(struct msghdr * msg, int level, int type, int len, void *data)
85140 err = -EFAULT;
85141 if (copy_to_user(cm, &cmhdr, sizeof cmhdr))
85142 goto out;
85143 - if (copy_to_user(CMSG_DATA(cm), data, cmlen - sizeof(struct cmsghdr)))
85144 + if (copy_to_user((void __force_user *)CMSG_DATA((void __force_kernel *)cm), data, cmlen - sizeof(struct cmsghdr)))
85145 goto out;
85146 cmlen = CMSG_SPACE(len);
85147 if (msg->msg_controllen < cmlen)
85148 @@ -263,7 +263,7 @@ EXPORT_SYMBOL(put_cmsg);
85149 void scm_detach_fds(struct msghdr *msg, struct scm_cookie *scm)
85150 {
85151 struct cmsghdr __user *cm
85152 - = (__force struct cmsghdr __user*)msg->msg_control;
85153 + = (struct cmsghdr __force_user *)msg->msg_control;
85154
85155 int fdmax = 0;
85156 int fdnum = scm->fp->count;
85157 @@ -283,7 +283,7 @@ void scm_detach_fds(struct msghdr *msg, struct scm_cookie *scm)
85158 if (fdnum < fdmax)
85159 fdmax = fdnum;
85160
85161 - for (i=0, cmfptr=(__force int __user *)CMSG_DATA(cm); i<fdmax;
85162 + for (i=0, cmfptr=(int __force_user *)CMSG_DATA((void __force_kernel *)cm); i<fdmax;
85163 i++, cmfptr++)
85164 {
85165 struct socket *sock;
85166 diff --git a/net/core/sock.c b/net/core/sock.c
85167 index bc131d4..029e378 100644
85168 --- a/net/core/sock.c
85169 +++ b/net/core/sock.c
85170 @@ -388,7 +388,7 @@ int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
85171 struct sk_buff_head *list = &sk->sk_receive_queue;
85172
85173 if (atomic_read(&sk->sk_rmem_alloc) >= sk->sk_rcvbuf) {
85174 - atomic_inc(&sk->sk_drops);
85175 + atomic_inc_unchecked(&sk->sk_drops);
85176 trace_sock_rcvqueue_full(sk, skb);
85177 return -ENOMEM;
85178 }
85179 @@ -398,7 +398,7 @@ int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
85180 return err;
85181
85182 if (!sk_rmem_schedule(sk, skb, skb->truesize)) {
85183 - atomic_inc(&sk->sk_drops);
85184 + atomic_inc_unchecked(&sk->sk_drops);
85185 return -ENOBUFS;
85186 }
85187
85188 @@ -418,7 +418,7 @@ int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
85189 skb_dst_force(skb);
85190
85191 spin_lock_irqsave(&list->lock, flags);
85192 - skb->dropcount = atomic_read(&sk->sk_drops);
85193 + skb->dropcount = atomic_read_unchecked(&sk->sk_drops);
85194 __skb_queue_tail(list, skb);
85195 spin_unlock_irqrestore(&list->lock, flags);
85196
85197 @@ -438,7 +438,7 @@ int sk_receive_skb(struct sock *sk, struct sk_buff *skb, const int nested)
85198 skb->dev = NULL;
85199
85200 if (sk_rcvqueues_full(sk, skb, sk->sk_rcvbuf)) {
85201 - atomic_inc(&sk->sk_drops);
85202 + atomic_inc_unchecked(&sk->sk_drops);
85203 goto discard_and_relse;
85204 }
85205 if (nested)
85206 @@ -456,7 +456,7 @@ int sk_receive_skb(struct sock *sk, struct sk_buff *skb, const int nested)
85207 mutex_release(&sk->sk_lock.dep_map, 1, _RET_IP_);
85208 } else if (sk_add_backlog(sk, skb, sk->sk_rcvbuf)) {
85209 bh_unlock_sock(sk);
85210 - atomic_inc(&sk->sk_drops);
85211 + atomic_inc_unchecked(&sk->sk_drops);
85212 goto discard_and_relse;
85213 }
85214
85215 @@ -930,12 +930,12 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
85216 struct timeval tm;
85217 } v;
85218
85219 - int lv = sizeof(int);
85220 - int len;
85221 + unsigned int lv = sizeof(int);
85222 + unsigned int len;
85223
85224 if (get_user(len, optlen))
85225 return -EFAULT;
85226 - if (len < 0)
85227 + if (len > INT_MAX)
85228 return -EINVAL;
85229
85230 memset(&v, 0, sizeof(v));
85231 @@ -1083,11 +1083,11 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
85232
85233 case SO_PEERNAME:
85234 {
85235 - char address[128];
85236 + char address[_K_SS_MAXSIZE];
85237
85238 if (sock->ops->getname(sock, (struct sockaddr *)address, &lv, 2))
85239 return -ENOTCONN;
85240 - if (lv < len)
85241 + if (lv < len || sizeof address < len)
85242 return -EINVAL;
85243 if (copy_to_user(optval, address, len))
85244 return -EFAULT;
85245 @@ -1146,7 +1146,7 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
85246
85247 if (len > lv)
85248 len = lv;
85249 - if (copy_to_user(optval, &v, len))
85250 + if (len > sizeof(v) || copy_to_user(optval, &v, len))
85251 return -EFAULT;
85252 lenout:
85253 if (put_user(len, optlen))
85254 @@ -2276,7 +2276,7 @@ void sock_init_data(struct socket *sock, struct sock *sk)
85255 */
85256 smp_wmb();
85257 atomic_set(&sk->sk_refcnt, 1);
85258 - atomic_set(&sk->sk_drops, 0);
85259 + atomic_set_unchecked(&sk->sk_drops, 0);
85260 }
85261 EXPORT_SYMBOL(sock_init_data);
85262
85263 diff --git a/net/core/sock_diag.c b/net/core/sock_diag.c
85264 index 750f44f..922399c 100644
85265 --- a/net/core/sock_diag.c
85266 +++ b/net/core/sock_diag.c
85267 @@ -9,26 +9,33 @@
85268 #include <linux/inet_diag.h>
85269 #include <linux/sock_diag.h>
85270
85271 -static const struct sock_diag_handler *sock_diag_handlers[AF_MAX];
85272 +static const struct sock_diag_handler *sock_diag_handlers[AF_MAX] __read_only;
85273 static int (*inet_rcv_compat)(struct sk_buff *skb, struct nlmsghdr *nlh);
85274 static DEFINE_MUTEX(sock_diag_table_mutex);
85275
85276 int sock_diag_check_cookie(void *sk, __u32 *cookie)
85277 {
85278 +#ifndef CONFIG_GRKERNSEC_HIDESYM
85279 if ((cookie[0] != INET_DIAG_NOCOOKIE ||
85280 cookie[1] != INET_DIAG_NOCOOKIE) &&
85281 ((u32)(unsigned long)sk != cookie[0] ||
85282 (u32)((((unsigned long)sk) >> 31) >> 1) != cookie[1]))
85283 return -ESTALE;
85284 else
85285 +#endif
85286 return 0;
85287 }
85288 EXPORT_SYMBOL_GPL(sock_diag_check_cookie);
85289
85290 void sock_diag_save_cookie(void *sk, __u32 *cookie)
85291 {
85292 +#ifdef CONFIG_GRKERNSEC_HIDESYM
85293 + cookie[0] = 0;
85294 + cookie[1] = 0;
85295 +#else
85296 cookie[0] = (u32)(unsigned long)sk;
85297 cookie[1] = (u32)(((unsigned long)sk >> 31) >> 1);
85298 +#endif
85299 }
85300 EXPORT_SYMBOL_GPL(sock_diag_save_cookie);
85301
85302 @@ -75,8 +82,11 @@ int sock_diag_register(const struct sock_diag_handler *hndl)
85303 mutex_lock(&sock_diag_table_mutex);
85304 if (sock_diag_handlers[hndl->family])
85305 err = -EBUSY;
85306 - else
85307 + else {
85308 + pax_open_kernel();
85309 sock_diag_handlers[hndl->family] = hndl;
85310 + pax_close_kernel();
85311 + }
85312 mutex_unlock(&sock_diag_table_mutex);
85313
85314 return err;
85315 @@ -92,26 +102,13 @@ void sock_diag_unregister(const struct sock_diag_handler *hnld)
85316
85317 mutex_lock(&sock_diag_table_mutex);
85318 BUG_ON(sock_diag_handlers[family] != hnld);
85319 + pax_open_kernel();
85320 sock_diag_handlers[family] = NULL;
85321 + pax_close_kernel();
85322 mutex_unlock(&sock_diag_table_mutex);
85323 }
85324 EXPORT_SYMBOL_GPL(sock_diag_unregister);
85325
85326 -static const inline struct sock_diag_handler *sock_diag_lock_handler(int family)
85327 -{
85328 - if (sock_diag_handlers[family] == NULL)
85329 - request_module("net-pf-%d-proto-%d-type-%d", PF_NETLINK,
85330 - NETLINK_SOCK_DIAG, family);
85331 -
85332 - mutex_lock(&sock_diag_table_mutex);
85333 - return sock_diag_handlers[family];
85334 -}
85335 -
85336 -static inline void sock_diag_unlock_handler(const struct sock_diag_handler *h)
85337 -{
85338 - mutex_unlock(&sock_diag_table_mutex);
85339 -}
85340 -
85341 static int __sock_diag_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
85342 {
85343 int err;
85344 @@ -124,12 +121,17 @@ static int __sock_diag_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
85345 if (req->sdiag_family >= AF_MAX)
85346 return -EINVAL;
85347
85348 - hndl = sock_diag_lock_handler(req->sdiag_family);
85349 + if (sock_diag_handlers[req->sdiag_family] == NULL)
85350 + request_module("net-pf-%d-proto-%d-type-%d", PF_NETLINK,
85351 + NETLINK_SOCK_DIAG, req->sdiag_family);
85352 +
85353 + mutex_lock(&sock_diag_table_mutex);
85354 + hndl = sock_diag_handlers[req->sdiag_family];
85355 if (hndl == NULL)
85356 err = -ENOENT;
85357 else
85358 err = hndl->dump(skb, nlh);
85359 - sock_diag_unlock_handler(hndl);
85360 + mutex_unlock(&sock_diag_table_mutex);
85361
85362 return err;
85363 }
85364 diff --git a/net/core/sysctl_net_core.c b/net/core/sysctl_net_core.c
85365 index d1b0804..4aed0a5 100644
85366 --- a/net/core/sysctl_net_core.c
85367 +++ b/net/core/sysctl_net_core.c
85368 @@ -26,7 +26,7 @@ static int rps_sock_flow_sysctl(ctl_table *table, int write,
85369 {
85370 unsigned int orig_size, size;
85371 int ret, i;
85372 - ctl_table tmp = {
85373 + ctl_table_no_const tmp = {
85374 .data = &size,
85375 .maxlen = sizeof(size),
85376 .mode = table->mode
85377 @@ -205,13 +205,12 @@ static struct ctl_table netns_core_table[] = {
85378
85379 static __net_init int sysctl_core_net_init(struct net *net)
85380 {
85381 - struct ctl_table *tbl;
85382 + ctl_table_no_const *tbl = NULL;
85383
85384 net->core.sysctl_somaxconn = SOMAXCONN;
85385
85386 - tbl = netns_core_table;
85387 if (!net_eq(net, &init_net)) {
85388 - tbl = kmemdup(tbl, sizeof(netns_core_table), GFP_KERNEL);
85389 + tbl = kmemdup(netns_core_table, sizeof(netns_core_table), GFP_KERNEL);
85390 if (tbl == NULL)
85391 goto err_dup;
85392
85393 @@ -221,16 +220,16 @@ static __net_init int sysctl_core_net_init(struct net *net)
85394 if (net->user_ns != &init_user_ns) {
85395 tbl[0].procname = NULL;
85396 }
85397 - }
85398 -
85399 - net->core.sysctl_hdr = register_net_sysctl(net, "net/core", tbl);
85400 + net->core.sysctl_hdr = register_net_sysctl(net, "net/core", tbl);
85401 + } else
85402 + net->core.sysctl_hdr = register_net_sysctl(net, "net/core", netns_core_table);
85403 if (net->core.sysctl_hdr == NULL)
85404 goto err_reg;
85405
85406 return 0;
85407
85408 err_reg:
85409 - if (tbl != netns_core_table)
85410 + if (tbl)
85411 kfree(tbl);
85412 err_dup:
85413 return -ENOMEM;
85414 @@ -246,7 +245,7 @@ static __net_exit void sysctl_core_net_exit(struct net *net)
85415 kfree(tbl);
85416 }
85417
85418 -static __net_initdata struct pernet_operations sysctl_core_ops = {
85419 +static __net_initconst struct pernet_operations sysctl_core_ops = {
85420 .init = sysctl_core_net_init,
85421 .exit = sysctl_core_net_exit,
85422 };
85423 diff --git a/net/dcb/dcbnl.c b/net/dcb/dcbnl.c
85424 index 1b588e2..21291f1 100644
85425 --- a/net/dcb/dcbnl.c
85426 +++ b/net/dcb/dcbnl.c
85427 @@ -284,6 +284,7 @@ static int dcbnl_getperm_hwaddr(struct net_device *netdev, struct nlmsghdr *nlh,
85428 if (!netdev->dcbnl_ops->getpermhwaddr)
85429 return -EOPNOTSUPP;
85430
85431 + memset(perm_addr, 0, sizeof(perm_addr));
85432 netdev->dcbnl_ops->getpermhwaddr(netdev, perm_addr);
85433
85434 return nla_put(skb, DCB_ATTR_PERM_HWADDR, sizeof(perm_addr), perm_addr);
85435 @@ -1042,6 +1043,7 @@ static int dcbnl_ieee_fill(struct sk_buff *skb, struct net_device *netdev)
85436
85437 if (ops->ieee_getets) {
85438 struct ieee_ets ets;
85439 + memset(&ets, 0, sizeof(ets));
85440 err = ops->ieee_getets(netdev, &ets);
85441 if (!err &&
85442 nla_put(skb, DCB_ATTR_IEEE_ETS, sizeof(ets), &ets))
85443 @@ -1050,6 +1052,7 @@ static int dcbnl_ieee_fill(struct sk_buff *skb, struct net_device *netdev)
85444
85445 if (ops->ieee_getmaxrate) {
85446 struct ieee_maxrate maxrate;
85447 + memset(&maxrate, 0, sizeof(maxrate));
85448 err = ops->ieee_getmaxrate(netdev, &maxrate);
85449 if (!err) {
85450 err = nla_put(skb, DCB_ATTR_IEEE_MAXRATE,
85451 @@ -1061,6 +1064,7 @@ static int dcbnl_ieee_fill(struct sk_buff *skb, struct net_device *netdev)
85452
85453 if (ops->ieee_getpfc) {
85454 struct ieee_pfc pfc;
85455 + memset(&pfc, 0, sizeof(pfc));
85456 err = ops->ieee_getpfc(netdev, &pfc);
85457 if (!err &&
85458 nla_put(skb, DCB_ATTR_IEEE_PFC, sizeof(pfc), &pfc))
85459 @@ -1094,6 +1098,7 @@ static int dcbnl_ieee_fill(struct sk_buff *skb, struct net_device *netdev)
85460 /* get peer info if available */
85461 if (ops->ieee_peer_getets) {
85462 struct ieee_ets ets;
85463 + memset(&ets, 0, sizeof(ets));
85464 err = ops->ieee_peer_getets(netdev, &ets);
85465 if (!err &&
85466 nla_put(skb, DCB_ATTR_IEEE_PEER_ETS, sizeof(ets), &ets))
85467 @@ -1102,6 +1107,7 @@ static int dcbnl_ieee_fill(struct sk_buff *skb, struct net_device *netdev)
85468
85469 if (ops->ieee_peer_getpfc) {
85470 struct ieee_pfc pfc;
85471 + memset(&pfc, 0, sizeof(pfc));
85472 err = ops->ieee_peer_getpfc(netdev, &pfc);
85473 if (!err &&
85474 nla_put(skb, DCB_ATTR_IEEE_PEER_PFC, sizeof(pfc), &pfc))
85475 @@ -1280,6 +1286,7 @@ static int dcbnl_cee_fill(struct sk_buff *skb, struct net_device *netdev)
85476 /* peer info if available */
85477 if (ops->cee_peer_getpg) {
85478 struct cee_pg pg;
85479 + memset(&pg, 0, sizeof(pg));
85480 err = ops->cee_peer_getpg(netdev, &pg);
85481 if (!err &&
85482 nla_put(skb, DCB_ATTR_CEE_PEER_PG, sizeof(pg), &pg))
85483 @@ -1288,6 +1295,7 @@ static int dcbnl_cee_fill(struct sk_buff *skb, struct net_device *netdev)
85484
85485 if (ops->cee_peer_getpfc) {
85486 struct cee_pfc pfc;
85487 + memset(&pfc, 0, sizeof(pfc));
85488 err = ops->cee_peer_getpfc(netdev, &pfc);
85489 if (!err &&
85490 nla_put(skb, DCB_ATTR_CEE_PEER_PFC, sizeof(pfc), &pfc))
85491 diff --git a/net/decnet/af_decnet.c b/net/decnet/af_decnet.c
85492 index 307c322..78a4c6f 100644
85493 --- a/net/decnet/af_decnet.c
85494 +++ b/net/decnet/af_decnet.c
85495 @@ -468,6 +468,7 @@ static struct proto dn_proto = {
85496 .sysctl_rmem = sysctl_decnet_rmem,
85497 .max_header = DN_MAX_NSP_DATA_HEADER + 64,
85498 .obj_size = sizeof(struct dn_sock),
85499 + .slab_flags = SLAB_USERCOPY,
85500 };
85501
85502 static struct sock *dn_alloc_sock(struct net *net, struct socket *sock, gfp_t gfp)
85503 diff --git a/net/decnet/sysctl_net_decnet.c b/net/decnet/sysctl_net_decnet.c
85504 index a55eecc..dd8428c 100644
85505 --- a/net/decnet/sysctl_net_decnet.c
85506 +++ b/net/decnet/sysctl_net_decnet.c
85507 @@ -174,7 +174,7 @@ static int dn_node_address_handler(ctl_table *table, int write,
85508
85509 if (len > *lenp) len = *lenp;
85510
85511 - if (copy_to_user(buffer, addr, len))
85512 + if (len > sizeof addr || copy_to_user(buffer, addr, len))
85513 return -EFAULT;
85514
85515 *lenp = len;
85516 @@ -237,7 +237,7 @@ static int dn_def_dev_handler(ctl_table *table, int write,
85517
85518 if (len > *lenp) len = *lenp;
85519
85520 - if (copy_to_user(buffer, devname, len))
85521 + if (len > sizeof devname || copy_to_user(buffer, devname, len))
85522 return -EFAULT;
85523
85524 *lenp = len;
85525 diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c
85526 index fcf104e..95552d4 100644
85527 --- a/net/ipv4/af_inet.c
85528 +++ b/net/ipv4/af_inet.c
85529 @@ -1717,13 +1717,9 @@ static int __init inet_init(void)
85530
85531 BUILD_BUG_ON(sizeof(struct inet_skb_parm) > sizeof(dummy_skb->cb));
85532
85533 - sysctl_local_reserved_ports = kzalloc(65536 / 8, GFP_KERNEL);
85534 - if (!sysctl_local_reserved_ports)
85535 - goto out;
85536 -
85537 rc = proto_register(&tcp_prot, 1);
85538 if (rc)
85539 - goto out_free_reserved_ports;
85540 + goto out;
85541
85542 rc = proto_register(&udp_prot, 1);
85543 if (rc)
85544 @@ -1832,8 +1828,6 @@ out_unregister_udp_proto:
85545 proto_unregister(&udp_prot);
85546 out_unregister_tcp_proto:
85547 proto_unregister(&tcp_prot);
85548 -out_free_reserved_ports:
85549 - kfree(sysctl_local_reserved_ports);
85550 goto out;
85551 }
85552
85553 diff --git a/net/ipv4/ah4.c b/net/ipv4/ah4.c
85554 index a69b4e4..dbccba5 100644
85555 --- a/net/ipv4/ah4.c
85556 +++ b/net/ipv4/ah4.c
85557 @@ -421,7 +421,7 @@ static void ah4_err(struct sk_buff *skb, u32 info)
85558 return;
85559
85560 if (icmp_hdr(skb)->type == ICMP_DEST_UNREACH) {
85561 - atomic_inc(&flow_cache_genid);
85562 + atomic_inc_unchecked(&flow_cache_genid);
85563 rt_genid_bump(net);
85564
85565 ipv4_update_pmtu(skb, net, info, 0, 0, IPPROTO_AH, 0);
85566 diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c
85567 index a8e4f26..25e5f40 100644
85568 --- a/net/ipv4/devinet.c
85569 +++ b/net/ipv4/devinet.c
85570 @@ -1763,7 +1763,7 @@ static int ipv4_doint_and_flush(ctl_table *ctl, int write,
85571 #define DEVINET_SYSCTL_FLUSHING_ENTRY(attr, name) \
85572 DEVINET_SYSCTL_COMPLEX_ENTRY(attr, name, ipv4_doint_and_flush)
85573
85574 -static struct devinet_sysctl_table {
85575 +static const struct devinet_sysctl_table {
85576 struct ctl_table_header *sysctl_header;
85577 struct ctl_table devinet_vars[__IPV4_DEVCONF_MAX];
85578 } devinet_sysctl = {
85579 @@ -1881,7 +1881,7 @@ static __net_init int devinet_init_net(struct net *net)
85580 int err;
85581 struct ipv4_devconf *all, *dflt;
85582 #ifdef CONFIG_SYSCTL
85583 - struct ctl_table *tbl = ctl_forward_entry;
85584 + ctl_table_no_const *tbl = NULL;
85585 struct ctl_table_header *forw_hdr;
85586 #endif
85587
85588 @@ -1899,7 +1899,7 @@ static __net_init int devinet_init_net(struct net *net)
85589 goto err_alloc_dflt;
85590
85591 #ifdef CONFIG_SYSCTL
85592 - tbl = kmemdup(tbl, sizeof(ctl_forward_entry), GFP_KERNEL);
85593 + tbl = kmemdup(ctl_forward_entry, sizeof(ctl_forward_entry), GFP_KERNEL);
85594 if (tbl == NULL)
85595 goto err_alloc_ctl;
85596
85597 @@ -1919,7 +1919,10 @@ static __net_init int devinet_init_net(struct net *net)
85598 goto err_reg_dflt;
85599
85600 err = -ENOMEM;
85601 - forw_hdr = register_net_sysctl(net, "net/ipv4", tbl);
85602 + if (!net_eq(net, &init_net))
85603 + forw_hdr = register_net_sysctl(net, "net/ipv4", tbl);
85604 + else
85605 + forw_hdr = register_net_sysctl(net, "net/ipv4", ctl_forward_entry);
85606 if (forw_hdr == NULL)
85607 goto err_reg_ctl;
85608 net->ipv4.forw_hdr = forw_hdr;
85609 @@ -1935,8 +1938,7 @@ err_reg_ctl:
85610 err_reg_dflt:
85611 __devinet_sysctl_unregister(all);
85612 err_reg_all:
85613 - if (tbl != ctl_forward_entry)
85614 - kfree(tbl);
85615 + kfree(tbl);
85616 err_alloc_ctl:
85617 #endif
85618 if (dflt != &ipv4_devconf_dflt)
85619 diff --git a/net/ipv4/esp4.c b/net/ipv4/esp4.c
85620 index 3b4f0cd..8cb864c 100644
85621 --- a/net/ipv4/esp4.c
85622 +++ b/net/ipv4/esp4.c
85623 @@ -503,7 +503,7 @@ static void esp4_err(struct sk_buff *skb, u32 info)
85624 return;
85625
85626 if (icmp_hdr(skb)->type == ICMP_DEST_UNREACH) {
85627 - atomic_inc(&flow_cache_genid);
85628 + atomic_inc_unchecked(&flow_cache_genid);
85629 rt_genid_bump(net);
85630
85631 ipv4_update_pmtu(skb, net, info, 0, 0, IPPROTO_ESP, 0);
85632 diff --git a/net/ipv4/fib_frontend.c b/net/ipv4/fib_frontend.c
85633 index 5cd75e2..f57ef39 100644
85634 --- a/net/ipv4/fib_frontend.c
85635 +++ b/net/ipv4/fib_frontend.c
85636 @@ -1020,12 +1020,12 @@ static int fib_inetaddr_event(struct notifier_block *this, unsigned long event,
85637 #ifdef CONFIG_IP_ROUTE_MULTIPATH
85638 fib_sync_up(dev);
85639 #endif
85640 - atomic_inc(&net->ipv4.dev_addr_genid);
85641 + atomic_inc_unchecked(&net->ipv4.dev_addr_genid);
85642 rt_cache_flush(dev_net(dev));
85643 break;
85644 case NETDEV_DOWN:
85645 fib_del_ifaddr(ifa, NULL);
85646 - atomic_inc(&net->ipv4.dev_addr_genid);
85647 + atomic_inc_unchecked(&net->ipv4.dev_addr_genid);
85648 if (ifa->ifa_dev->ifa_list == NULL) {
85649 /* Last address was deleted from this interface.
85650 * Disable IP.
85651 @@ -1061,7 +1061,7 @@ static int fib_netdev_event(struct notifier_block *this, unsigned long event, vo
85652 #ifdef CONFIG_IP_ROUTE_MULTIPATH
85653 fib_sync_up(dev);
85654 #endif
85655 - atomic_inc(&net->ipv4.dev_addr_genid);
85656 + atomic_inc_unchecked(&net->ipv4.dev_addr_genid);
85657 rt_cache_flush(net);
85658 break;
85659 case NETDEV_DOWN:
85660 diff --git a/net/ipv4/fib_semantics.c b/net/ipv4/fib_semantics.c
85661 index 4797a80..2bd54e9 100644
85662 --- a/net/ipv4/fib_semantics.c
85663 +++ b/net/ipv4/fib_semantics.c
85664 @@ -767,7 +767,7 @@ __be32 fib_info_update_nh_saddr(struct net *net, struct fib_nh *nh)
85665 nh->nh_saddr = inet_select_addr(nh->nh_dev,
85666 nh->nh_gw,
85667 nh->nh_parent->fib_scope);
85668 - nh->nh_saddr_genid = atomic_read(&net->ipv4.dev_addr_genid);
85669 + nh->nh_saddr_genid = atomic_read_unchecked(&net->ipv4.dev_addr_genid);
85670
85671 return nh->nh_saddr;
85672 }
85673 diff --git a/net/ipv4/inet_connection_sock.c b/net/ipv4/inet_connection_sock.c
85674 index d0670f0..744ac80 100644
85675 --- a/net/ipv4/inet_connection_sock.c
85676 +++ b/net/ipv4/inet_connection_sock.c
85677 @@ -37,7 +37,7 @@ struct local_ports sysctl_local_ports __read_mostly = {
85678 .range = { 32768, 61000 },
85679 };
85680
85681 -unsigned long *sysctl_local_reserved_ports;
85682 +unsigned long sysctl_local_reserved_ports[65536 / 8 / sizeof(unsigned long)];
85683 EXPORT_SYMBOL(sysctl_local_reserved_ports);
85684
85685 void inet_get_local_port_range(int *low, int *high)
85686 diff --git a/net/ipv4/inet_hashtables.c b/net/ipv4/inet_hashtables.c
85687 index fa3ae81..0dbe6b8 100644
85688 --- a/net/ipv4/inet_hashtables.c
85689 +++ b/net/ipv4/inet_hashtables.c
85690 @@ -18,12 +18,15 @@
85691 #include <linux/sched.h>
85692 #include <linux/slab.h>
85693 #include <linux/wait.h>
85694 +#include <linux/security.h>
85695
85696 #include <net/inet_connection_sock.h>
85697 #include <net/inet_hashtables.h>
85698 #include <net/secure_seq.h>
85699 #include <net/ip.h>
85700
85701 +extern void gr_update_task_in_ip_table(struct task_struct *task, const struct inet_sock *inet);
85702 +
85703 /*
85704 * Allocate and initialize a new local port bind bucket.
85705 * The bindhash mutex for snum's hash chain must be held here.
85706 @@ -540,6 +543,8 @@ ok:
85707 twrefcnt += inet_twsk_bind_unhash(tw, hinfo);
85708 spin_unlock(&head->lock);
85709
85710 + gr_update_task_in_ip_table(current, inet_sk(sk));
85711 +
85712 if (tw) {
85713 inet_twsk_deschedule(tw, death_row);
85714 while (twrefcnt) {
85715 diff --git a/net/ipv4/inetpeer.c b/net/ipv4/inetpeer.c
85716 index 000e3d2..5472da3 100644
85717 --- a/net/ipv4/inetpeer.c
85718 +++ b/net/ipv4/inetpeer.c
85719 @@ -503,8 +503,8 @@ relookup:
85720 if (p) {
85721 p->daddr = *daddr;
85722 atomic_set(&p->refcnt, 1);
85723 - atomic_set(&p->rid, 0);
85724 - atomic_set(&p->ip_id_count,
85725 + atomic_set_unchecked(&p->rid, 0);
85726 + atomic_set_unchecked(&p->ip_id_count,
85727 (daddr->family == AF_INET) ?
85728 secure_ip_id(daddr->addr.a4) :
85729 secure_ipv6_id(daddr->addr.a6));
85730 diff --git a/net/ipv4/ip_fragment.c b/net/ipv4/ip_fragment.c
85731 index eb9d63a..31c5372 100644
85732 --- a/net/ipv4/ip_fragment.c
85733 +++ b/net/ipv4/ip_fragment.c
85734 @@ -322,7 +322,7 @@ static inline int ip_frag_too_far(struct ipq *qp)
85735 return 0;
85736
85737 start = qp->rid;
85738 - end = atomic_inc_return(&peer->rid);
85739 + end = atomic_inc_return_unchecked(&peer->rid);
85740 qp->rid = end;
85741
85742 rc = qp->q.fragments && (end - start) > max;
85743 @@ -789,12 +789,11 @@ static struct ctl_table ip4_frags_ctl_table[] = {
85744
85745 static int __net_init ip4_frags_ns_ctl_register(struct net *net)
85746 {
85747 - struct ctl_table *table;
85748 + ctl_table_no_const *table = NULL;
85749 struct ctl_table_header *hdr;
85750
85751 - table = ip4_frags_ns_ctl_table;
85752 if (!net_eq(net, &init_net)) {
85753 - table = kmemdup(table, sizeof(ip4_frags_ns_ctl_table), GFP_KERNEL);
85754 + table = kmemdup(ip4_frags_ns_ctl_table, sizeof(ip4_frags_ns_ctl_table), GFP_KERNEL);
85755 if (table == NULL)
85756 goto err_alloc;
85757
85758 @@ -805,9 +804,10 @@ static int __net_init ip4_frags_ns_ctl_register(struct net *net)
85759 /* Don't export sysctls to unprivileged users */
85760 if (net->user_ns != &init_user_ns)
85761 table[0].procname = NULL;
85762 - }
85763 + hdr = register_net_sysctl(net, "net/ipv4", table);
85764 + } else
85765 + hdr = register_net_sysctl(net, "net/ipv4", ip4_frags_ns_ctl_table);
85766
85767 - hdr = register_net_sysctl(net, "net/ipv4", table);
85768 if (hdr == NULL)
85769 goto err_reg;
85770
85771 @@ -815,8 +815,7 @@ static int __net_init ip4_frags_ns_ctl_register(struct net *net)
85772 return 0;
85773
85774 err_reg:
85775 - if (!net_eq(net, &init_net))
85776 - kfree(table);
85777 + kfree(table);
85778 err_alloc:
85779 return -ENOMEM;
85780 }
85781 diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c
85782 index e81b1ca..6f3b5b9 100644
85783 --- a/net/ipv4/ip_gre.c
85784 +++ b/net/ipv4/ip_gre.c
85785 @@ -124,7 +124,7 @@ static bool log_ecn_error = true;
85786 module_param(log_ecn_error, bool, 0644);
85787 MODULE_PARM_DESC(log_ecn_error, "Log packets received with corrupted ECN");
85788
85789 -static struct rtnl_link_ops ipgre_link_ops __read_mostly;
85790 +static struct rtnl_link_ops ipgre_link_ops;
85791 static int ipgre_tunnel_init(struct net_device *dev);
85792 static void ipgre_tunnel_setup(struct net_device *dev);
85793 static int ipgre_tunnel_bind_dev(struct net_device *dev);
85794 @@ -1756,7 +1756,7 @@ static const struct nla_policy ipgre_policy[IFLA_GRE_MAX + 1] = {
85795 [IFLA_GRE_PMTUDISC] = { .type = NLA_U8 },
85796 };
85797
85798 -static struct rtnl_link_ops ipgre_link_ops __read_mostly = {
85799 +static struct rtnl_link_ops ipgre_link_ops = {
85800 .kind = "gre",
85801 .maxtype = IFLA_GRE_MAX,
85802 .policy = ipgre_policy,
85803 @@ -1769,7 +1769,7 @@ static struct rtnl_link_ops ipgre_link_ops __read_mostly = {
85804 .fill_info = ipgre_fill_info,
85805 };
85806
85807 -static struct rtnl_link_ops ipgre_tap_ops __read_mostly = {
85808 +static struct rtnl_link_ops ipgre_tap_ops = {
85809 .kind = "gretap",
85810 .maxtype = IFLA_GRE_MAX,
85811 .policy = ipgre_policy,
85812 diff --git a/net/ipv4/ip_sockglue.c b/net/ipv4/ip_sockglue.c
85813 index d9c4f11..02b82db 100644
85814 --- a/net/ipv4/ip_sockglue.c
85815 +++ b/net/ipv4/ip_sockglue.c
85816 @@ -1152,7 +1152,8 @@ static int do_ip_getsockopt(struct sock *sk, int level, int optname,
85817 len = min_t(unsigned int, len, opt->optlen);
85818 if (put_user(len, optlen))
85819 return -EFAULT;
85820 - if (copy_to_user(optval, opt->__data, len))
85821 + if ((len > (sizeof(optbuf) - sizeof(struct ip_options))) ||
85822 + copy_to_user(optval, opt->__data, len))
85823 return -EFAULT;
85824 return 0;
85825 }
85826 @@ -1283,7 +1284,7 @@ static int do_ip_getsockopt(struct sock *sk, int level, int optname,
85827 if (sk->sk_type != SOCK_STREAM)
85828 return -ENOPROTOOPT;
85829
85830 - msg.msg_control = optval;
85831 + msg.msg_control = (void __force_kernel *)optval;
85832 msg.msg_controllen = len;
85833 msg.msg_flags = flags;
85834
85835 diff --git a/net/ipv4/ip_vti.c b/net/ipv4/ip_vti.c
85836 index c3a4233..1412161 100644
85837 --- a/net/ipv4/ip_vti.c
85838 +++ b/net/ipv4/ip_vti.c
85839 @@ -47,7 +47,7 @@
85840 #define HASH_SIZE 16
85841 #define HASH(addr) (((__force u32)addr^((__force u32)addr>>4))&(HASH_SIZE-1))
85842
85843 -static struct rtnl_link_ops vti_link_ops __read_mostly;
85844 +static struct rtnl_link_ops vti_link_ops;
85845
85846 static int vti_net_id __read_mostly;
85847 struct vti_net {
85848 @@ -886,7 +886,7 @@ static const struct nla_policy vti_policy[IFLA_VTI_MAX + 1] = {
85849 [IFLA_VTI_REMOTE] = { .len = FIELD_SIZEOF(struct iphdr, daddr) },
85850 };
85851
85852 -static struct rtnl_link_ops vti_link_ops __read_mostly = {
85853 +static struct rtnl_link_ops vti_link_ops = {
85854 .kind = "vti",
85855 .maxtype = IFLA_VTI_MAX,
85856 .policy = vti_policy,
85857 diff --git a/net/ipv4/ipcomp.c b/net/ipv4/ipcomp.c
85858 index 9a46dae..5f793a0 100644
85859 --- a/net/ipv4/ipcomp.c
85860 +++ b/net/ipv4/ipcomp.c
85861 @@ -48,7 +48,7 @@ static void ipcomp4_err(struct sk_buff *skb, u32 info)
85862 return;
85863
85864 if (icmp_hdr(skb)->type == ICMP_DEST_UNREACH) {
85865 - atomic_inc(&flow_cache_genid);
85866 + atomic_inc_unchecked(&flow_cache_genid);
85867 rt_genid_bump(net);
85868
85869 ipv4_update_pmtu(skb, net, info, 0, 0, IPPROTO_COMP, 0);
85870 diff --git a/net/ipv4/ipconfig.c b/net/ipv4/ipconfig.c
85871 index a2e50ae..e152b7c 100644
85872 --- a/net/ipv4/ipconfig.c
85873 +++ b/net/ipv4/ipconfig.c
85874 @@ -323,7 +323,7 @@ static int __init ic_devinet_ioctl(unsigned int cmd, struct ifreq *arg)
85875
85876 mm_segment_t oldfs = get_fs();
85877 set_fs(get_ds());
85878 - res = devinet_ioctl(&init_net, cmd, (struct ifreq __user *) arg);
85879 + res = devinet_ioctl(&init_net, cmd, (struct ifreq __force_user *) arg);
85880 set_fs(oldfs);
85881 return res;
85882 }
85883 @@ -334,7 +334,7 @@ static int __init ic_dev_ioctl(unsigned int cmd, struct ifreq *arg)
85884
85885 mm_segment_t oldfs = get_fs();
85886 set_fs(get_ds());
85887 - res = dev_ioctl(&init_net, cmd, (struct ifreq __user *) arg);
85888 + res = dev_ioctl(&init_net, cmd, (struct ifreq __force_user *) arg);
85889 set_fs(oldfs);
85890 return res;
85891 }
85892 @@ -345,7 +345,7 @@ static int __init ic_route_ioctl(unsigned int cmd, struct rtentry *arg)
85893
85894 mm_segment_t oldfs = get_fs();
85895 set_fs(get_ds());
85896 - res = ip_rt_ioctl(&init_net, cmd, (void __user *) arg);
85897 + res = ip_rt_ioctl(&init_net, cmd, (void __force_user *) arg);
85898 set_fs(oldfs);
85899 return res;
85900 }
85901 diff --git a/net/ipv4/ipip.c b/net/ipv4/ipip.c
85902 index 191fc24..1b3b804 100644
85903 --- a/net/ipv4/ipip.c
85904 +++ b/net/ipv4/ipip.c
85905 @@ -138,7 +138,7 @@ struct ipip_net {
85906 static int ipip_tunnel_init(struct net_device *dev);
85907 static void ipip_tunnel_setup(struct net_device *dev);
85908 static void ipip_dev_free(struct net_device *dev);
85909 -static struct rtnl_link_ops ipip_link_ops __read_mostly;
85910 +static struct rtnl_link_ops ipip_link_ops;
85911
85912 static struct rtnl_link_stats64 *ipip_get_stats64(struct net_device *dev,
85913 struct rtnl_link_stats64 *tot)
85914 @@ -972,7 +972,7 @@ static const struct nla_policy ipip_policy[IFLA_IPTUN_MAX + 1] = {
85915 [IFLA_IPTUN_PMTUDISC] = { .type = NLA_U8 },
85916 };
85917
85918 -static struct rtnl_link_ops ipip_link_ops __read_mostly = {
85919 +static struct rtnl_link_ops ipip_link_ops = {
85920 .kind = "ipip",
85921 .maxtype = IFLA_IPTUN_MAX,
85922 .policy = ipip_policy,
85923 diff --git a/net/ipv4/netfilter/arp_tables.c b/net/ipv4/netfilter/arp_tables.c
85924 index 3ea4127..849297b 100644
85925 --- a/net/ipv4/netfilter/arp_tables.c
85926 +++ b/net/ipv4/netfilter/arp_tables.c
85927 @@ -879,14 +879,14 @@ static int compat_table_info(const struct xt_table_info *info,
85928 #endif
85929
85930 static int get_info(struct net *net, void __user *user,
85931 - const int *len, int compat)
85932 + int len, int compat)
85933 {
85934 char name[XT_TABLE_MAXNAMELEN];
85935 struct xt_table *t;
85936 int ret;
85937
85938 - if (*len != sizeof(struct arpt_getinfo)) {
85939 - duprintf("length %u != %Zu\n", *len,
85940 + if (len != sizeof(struct arpt_getinfo)) {
85941 + duprintf("length %u != %Zu\n", len,
85942 sizeof(struct arpt_getinfo));
85943 return -EINVAL;
85944 }
85945 @@ -923,7 +923,7 @@ static int get_info(struct net *net, void __user *user,
85946 info.size = private->size;
85947 strcpy(info.name, name);
85948
85949 - if (copy_to_user(user, &info, *len) != 0)
85950 + if (copy_to_user(user, &info, len) != 0)
85951 ret = -EFAULT;
85952 else
85953 ret = 0;
85954 @@ -1682,7 +1682,7 @@ static int compat_do_arpt_get_ctl(struct sock *sk, int cmd, void __user *user,
85955
85956 switch (cmd) {
85957 case ARPT_SO_GET_INFO:
85958 - ret = get_info(sock_net(sk), user, len, 1);
85959 + ret = get_info(sock_net(sk), user, *len, 1);
85960 break;
85961 case ARPT_SO_GET_ENTRIES:
85962 ret = compat_get_entries(sock_net(sk), user, len);
85963 @@ -1727,7 +1727,7 @@ static int do_arpt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len
85964
85965 switch (cmd) {
85966 case ARPT_SO_GET_INFO:
85967 - ret = get_info(sock_net(sk), user, len, 0);
85968 + ret = get_info(sock_net(sk), user, *len, 0);
85969 break;
85970
85971 case ARPT_SO_GET_ENTRIES:
85972 diff --git a/net/ipv4/netfilter/ip_tables.c b/net/ipv4/netfilter/ip_tables.c
85973 index 17c5e06..1b91206 100644
85974 --- a/net/ipv4/netfilter/ip_tables.c
85975 +++ b/net/ipv4/netfilter/ip_tables.c
85976 @@ -1068,14 +1068,14 @@ static int compat_table_info(const struct xt_table_info *info,
85977 #endif
85978
85979 static int get_info(struct net *net, void __user *user,
85980 - const int *len, int compat)
85981 + int len, int compat)
85982 {
85983 char name[XT_TABLE_MAXNAMELEN];
85984 struct xt_table *t;
85985 int ret;
85986
85987 - if (*len != sizeof(struct ipt_getinfo)) {
85988 - duprintf("length %u != %zu\n", *len,
85989 + if (len != sizeof(struct ipt_getinfo)) {
85990 + duprintf("length %u != %zu\n", len,
85991 sizeof(struct ipt_getinfo));
85992 return -EINVAL;
85993 }
85994 @@ -1112,7 +1112,7 @@ static int get_info(struct net *net, void __user *user,
85995 info.size = private->size;
85996 strcpy(info.name, name);
85997
85998 - if (copy_to_user(user, &info, *len) != 0)
85999 + if (copy_to_user(user, &info, len) != 0)
86000 ret = -EFAULT;
86001 else
86002 ret = 0;
86003 @@ -1966,7 +1966,7 @@ compat_do_ipt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
86004
86005 switch (cmd) {
86006 case IPT_SO_GET_INFO:
86007 - ret = get_info(sock_net(sk), user, len, 1);
86008 + ret = get_info(sock_net(sk), user, *len, 1);
86009 break;
86010 case IPT_SO_GET_ENTRIES:
86011 ret = compat_get_entries(sock_net(sk), user, len);
86012 @@ -2013,7 +2013,7 @@ do_ipt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
86013
86014 switch (cmd) {
86015 case IPT_SO_GET_INFO:
86016 - ret = get_info(sock_net(sk), user, len, 0);
86017 + ret = get_info(sock_net(sk), user, *len, 0);
86018 break;
86019
86020 case IPT_SO_GET_ENTRIES:
86021 diff --git a/net/ipv4/ping.c b/net/ipv4/ping.c
86022 index dc454cc..5bb917f 100644
86023 --- a/net/ipv4/ping.c
86024 +++ b/net/ipv4/ping.c
86025 @@ -844,7 +844,7 @@ static void ping_format_sock(struct sock *sp, struct seq_file *f,
86026 from_kuid_munged(seq_user_ns(f), sock_i_uid(sp)),
86027 0, sock_i_ino(sp),
86028 atomic_read(&sp->sk_refcnt), sp,
86029 - atomic_read(&sp->sk_drops), len);
86030 + atomic_read_unchecked(&sp->sk_drops), len);
86031 }
86032
86033 static int ping_seq_show(struct seq_file *seq, void *v)
86034 diff --git a/net/ipv4/raw.c b/net/ipv4/raw.c
86035 index 6f08991..55867ad 100644
86036 --- a/net/ipv4/raw.c
86037 +++ b/net/ipv4/raw.c
86038 @@ -311,7 +311,7 @@ static int raw_rcv_skb(struct sock *sk, struct sk_buff *skb)
86039 int raw_rcv(struct sock *sk, struct sk_buff *skb)
86040 {
86041 if (!xfrm4_policy_check(sk, XFRM_POLICY_IN, skb)) {
86042 - atomic_inc(&sk->sk_drops);
86043 + atomic_inc_unchecked(&sk->sk_drops);
86044 kfree_skb(skb);
86045 return NET_RX_DROP;
86046 }
86047 @@ -747,16 +747,20 @@ static int raw_init(struct sock *sk)
86048
86049 static int raw_seticmpfilter(struct sock *sk, char __user *optval, int optlen)
86050 {
86051 + struct icmp_filter filter;
86052 +
86053 if (optlen > sizeof(struct icmp_filter))
86054 optlen = sizeof(struct icmp_filter);
86055 - if (copy_from_user(&raw_sk(sk)->filter, optval, optlen))
86056 + if (copy_from_user(&filter, optval, optlen))
86057 return -EFAULT;
86058 + raw_sk(sk)->filter = filter;
86059 return 0;
86060 }
86061
86062 static int raw_geticmpfilter(struct sock *sk, char __user *optval, int __user *optlen)
86063 {
86064 int len, ret = -EFAULT;
86065 + struct icmp_filter filter;
86066
86067 if (get_user(len, optlen))
86068 goto out;
86069 @@ -766,8 +770,8 @@ static int raw_geticmpfilter(struct sock *sk, char __user *optval, int __user *o
86070 if (len > sizeof(struct icmp_filter))
86071 len = sizeof(struct icmp_filter);
86072 ret = -EFAULT;
86073 - if (put_user(len, optlen) ||
86074 - copy_to_user(optval, &raw_sk(sk)->filter, len))
86075 + filter = raw_sk(sk)->filter;
86076 + if (put_user(len, optlen) || len > sizeof filter || copy_to_user(optval, &filter, len))
86077 goto out;
86078 ret = 0;
86079 out: return ret;
86080 @@ -998,7 +1002,7 @@ static void raw_sock_seq_show(struct seq_file *seq, struct sock *sp, int i)
86081 0, 0L, 0,
86082 from_kuid_munged(seq_user_ns(seq), sock_i_uid(sp)),
86083 0, sock_i_ino(sp),
86084 - atomic_read(&sp->sk_refcnt), sp, atomic_read(&sp->sk_drops));
86085 + atomic_read(&sp->sk_refcnt), sp, atomic_read_unchecked(&sp->sk_drops));
86086 }
86087
86088 static int raw_seq_show(struct seq_file *seq, void *v)
86089 diff --git a/net/ipv4/route.c b/net/ipv4/route.c
86090 index a0fcc47..32e2c89 100644
86091 --- a/net/ipv4/route.c
86092 +++ b/net/ipv4/route.c
86093 @@ -2552,34 +2552,34 @@ static struct ctl_table ipv4_route_flush_table[] = {
86094 .maxlen = sizeof(int),
86095 .mode = 0200,
86096 .proc_handler = ipv4_sysctl_rtcache_flush,
86097 + .extra1 = &init_net,
86098 },
86099 { },
86100 };
86101
86102 static __net_init int sysctl_route_net_init(struct net *net)
86103 {
86104 - struct ctl_table *tbl;
86105 + ctl_table_no_const *tbl = NULL;
86106
86107 - tbl = ipv4_route_flush_table;
86108 if (!net_eq(net, &init_net)) {
86109 - tbl = kmemdup(tbl, sizeof(ipv4_route_flush_table), GFP_KERNEL);
86110 + tbl = kmemdup(ipv4_route_flush_table, sizeof(ipv4_route_flush_table), GFP_KERNEL);
86111 if (tbl == NULL)
86112 goto err_dup;
86113
86114 /* Don't export sysctls to unprivileged users */
86115 if (net->user_ns != &init_user_ns)
86116 tbl[0].procname = NULL;
86117 - }
86118 - tbl[0].extra1 = net;
86119 + tbl[0].extra1 = net;
86120 + net->ipv4.route_hdr = register_net_sysctl(net, "net/ipv4/route", tbl);
86121 + } else
86122 + net->ipv4.route_hdr = register_net_sysctl(net, "net/ipv4/route", ipv4_route_flush_table);
86123
86124 - net->ipv4.route_hdr = register_net_sysctl(net, "net/ipv4/route", tbl);
86125 if (net->ipv4.route_hdr == NULL)
86126 goto err_reg;
86127 return 0;
86128
86129 err_reg:
86130 - if (tbl != ipv4_route_flush_table)
86131 - kfree(tbl);
86132 + kfree(tbl);
86133 err_dup:
86134 return -ENOMEM;
86135 }
86136 @@ -2602,7 +2602,7 @@ static __net_initdata struct pernet_operations sysctl_route_ops = {
86137
86138 static __net_init int rt_genid_init(struct net *net)
86139 {
86140 - atomic_set(&net->rt_genid, 0);
86141 + atomic_set_unchecked(&net->rt_genid, 0);
86142 get_random_bytes(&net->ipv4.dev_addr_genid,
86143 sizeof(net->ipv4.dev_addr_genid));
86144 return 0;
86145 diff --git a/net/ipv4/sysctl_net_ipv4.c b/net/ipv4/sysctl_net_ipv4.c
86146 index d84400b..62e066e 100644
86147 --- a/net/ipv4/sysctl_net_ipv4.c
86148 +++ b/net/ipv4/sysctl_net_ipv4.c
86149 @@ -54,7 +54,7 @@ static int ipv4_local_port_range(ctl_table *table, int write,
86150 {
86151 int ret;
86152 int range[2];
86153 - ctl_table tmp = {
86154 + ctl_table_no_const tmp = {
86155 .data = &range,
86156 .maxlen = sizeof(range),
86157 .mode = table->mode,
86158 @@ -107,7 +107,7 @@ static int ipv4_ping_group_range(ctl_table *table, int write,
86159 int ret;
86160 gid_t urange[2];
86161 kgid_t low, high;
86162 - ctl_table tmp = {
86163 + ctl_table_no_const tmp = {
86164 .data = &urange,
86165 .maxlen = sizeof(urange),
86166 .mode = table->mode,
86167 @@ -138,7 +138,7 @@ static int proc_tcp_congestion_control(ctl_table *ctl, int write,
86168 void __user *buffer, size_t *lenp, loff_t *ppos)
86169 {
86170 char val[TCP_CA_NAME_MAX];
86171 - ctl_table tbl = {
86172 + ctl_table_no_const tbl = {
86173 .data = val,
86174 .maxlen = TCP_CA_NAME_MAX,
86175 };
86176 @@ -157,7 +157,7 @@ static int proc_tcp_available_congestion_control(ctl_table *ctl,
86177 void __user *buffer, size_t *lenp,
86178 loff_t *ppos)
86179 {
86180 - ctl_table tbl = { .maxlen = TCP_CA_BUF_MAX, };
86181 + ctl_table_no_const tbl = { .maxlen = TCP_CA_BUF_MAX, };
86182 int ret;
86183
86184 tbl.data = kmalloc(tbl.maxlen, GFP_USER);
86185 @@ -174,7 +174,7 @@ static int proc_allowed_congestion_control(ctl_table *ctl,
86186 void __user *buffer, size_t *lenp,
86187 loff_t *ppos)
86188 {
86189 - ctl_table tbl = { .maxlen = TCP_CA_BUF_MAX };
86190 + ctl_table_no_const tbl = { .maxlen = TCP_CA_BUF_MAX };
86191 int ret;
86192
86193 tbl.data = kmalloc(tbl.maxlen, GFP_USER);
86194 @@ -200,15 +200,17 @@ static int ipv4_tcp_mem(ctl_table *ctl, int write,
86195 struct mem_cgroup *memcg;
86196 #endif
86197
86198 - ctl_table tmp = {
86199 + ctl_table_no_const tmp = {
86200 .data = &vec,
86201 .maxlen = sizeof(vec),
86202 .mode = ctl->mode,
86203 };
86204
86205 if (!write) {
86206 - ctl->data = &net->ipv4.sysctl_tcp_mem;
86207 - return proc_doulongvec_minmax(ctl, write, buffer, lenp, ppos);
86208 + ctl_table_no_const tcp_mem = *ctl;
86209 +
86210 + tcp_mem.data = &net->ipv4.sysctl_tcp_mem;
86211 + return proc_doulongvec_minmax(&tcp_mem, write, buffer, lenp, ppos);
86212 }
86213
86214 ret = proc_doulongvec_minmax(&tmp, write, buffer, lenp, ppos);
86215 @@ -235,7 +237,7 @@ static int ipv4_tcp_mem(ctl_table *ctl, int write,
86216 int proc_tcp_fastopen_key(ctl_table *ctl, int write, void __user *buffer,
86217 size_t *lenp, loff_t *ppos)
86218 {
86219 - ctl_table tbl = { .maxlen = (TCP_FASTOPEN_KEY_LENGTH * 2 + 10) };
86220 + ctl_table_no_const tbl = { .maxlen = (TCP_FASTOPEN_KEY_LENGTH * 2 + 10) };
86221 struct tcp_fastopen_context *ctxt;
86222 int ret;
86223 u32 user_key[4]; /* 16 bytes, matching TCP_FASTOPEN_KEY_LENGTH */
86224 @@ -476,7 +478,7 @@ static struct ctl_table ipv4_table[] = {
86225 },
86226 {
86227 .procname = "ip_local_reserved_ports",
86228 - .data = NULL, /* initialized in sysctl_ipv4_init */
86229 + .data = sysctl_local_reserved_ports,
86230 .maxlen = 65536,
86231 .mode = 0644,
86232 .proc_handler = proc_do_large_bitmap,
86233 @@ -860,11 +862,10 @@ static struct ctl_table ipv4_net_table[] = {
86234
86235 static __net_init int ipv4_sysctl_init_net(struct net *net)
86236 {
86237 - struct ctl_table *table;
86238 + ctl_table_no_const *table = NULL;
86239
86240 - table = ipv4_net_table;
86241 if (!net_eq(net, &init_net)) {
86242 - table = kmemdup(table, sizeof(ipv4_net_table), GFP_KERNEL);
86243 + table = kmemdup(ipv4_net_table, sizeof(ipv4_net_table), GFP_KERNEL);
86244 if (table == NULL)
86245 goto err_alloc;
86246
86247 @@ -897,15 +898,17 @@ static __net_init int ipv4_sysctl_init_net(struct net *net)
86248
86249 tcp_init_mem(net);
86250
86251 - net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", table);
86252 + if (!net_eq(net, &init_net))
86253 + net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", table);
86254 + else
86255 + net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", ipv4_net_table);
86256 if (net->ipv4.ipv4_hdr == NULL)
86257 goto err_reg;
86258
86259 return 0;
86260
86261 err_reg:
86262 - if (!net_eq(net, &init_net))
86263 - kfree(table);
86264 + kfree(table);
86265 err_alloc:
86266 return -ENOMEM;
86267 }
86268 @@ -927,16 +930,6 @@ static __net_initdata struct pernet_operations ipv4_sysctl_ops = {
86269 static __init int sysctl_ipv4_init(void)
86270 {
86271 struct ctl_table_header *hdr;
86272 - struct ctl_table *i;
86273 -
86274 - for (i = ipv4_table; i->procname; i++) {
86275 - if (strcmp(i->procname, "ip_local_reserved_ports") == 0) {
86276 - i->data = sysctl_local_reserved_ports;
86277 - break;
86278 - }
86279 - }
86280 - if (!i->procname)
86281 - return -EINVAL;
86282
86283 hdr = register_net_sysctl(&init_net, "net/ipv4", ipv4_table);
86284 if (hdr == NULL)
86285 diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
86286 index ad70a96..50cb55b 100644
86287 --- a/net/ipv4/tcp_input.c
86288 +++ b/net/ipv4/tcp_input.c
86289 @@ -4733,7 +4733,7 @@ static struct sk_buff *tcp_collapse_one(struct sock *sk, struct sk_buff *skb,
86290 * simplifies code)
86291 */
86292 static void
86293 -tcp_collapse(struct sock *sk, struct sk_buff_head *list,
86294 +__intentional_overflow(5,6) tcp_collapse(struct sock *sk, struct sk_buff_head *list,
86295 struct sk_buff *head, struct sk_buff *tail,
86296 u32 start, u32 end)
86297 {
86298 @@ -5850,6 +5850,7 @@ discard:
86299 tcp_paws_reject(&tp->rx_opt, 0))
86300 goto discard_and_undo;
86301
86302 +#ifndef CONFIG_GRKERNSEC_NO_SIMULT_CONNECT
86303 if (th->syn) {
86304 /* We see SYN without ACK. It is attempt of
86305 * simultaneous connect with crossed SYNs.
86306 @@ -5900,6 +5901,7 @@ discard:
86307 goto discard;
86308 #endif
86309 }
86310 +#endif
86311 /* "fifth, if neither of the SYN or RST bits is set then
86312 * drop the segment and return."
86313 */
86314 @@ -5944,7 +5946,7 @@ int tcp_rcv_state_process(struct sock *sk, struct sk_buff *skb,
86315 goto discard;
86316
86317 if (th->syn) {
86318 - if (th->fin)
86319 + if (th->fin || th->urg || th->psh)
86320 goto discard;
86321 if (icsk->icsk_af_ops->conn_request(sk, skb) < 0)
86322 return 1;
86323 diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
86324 index eadb693..e8f7251 100644
86325 --- a/net/ipv4/tcp_ipv4.c
86326 +++ b/net/ipv4/tcp_ipv4.c
86327 @@ -90,6 +90,10 @@ int sysctl_tcp_low_latency __read_mostly;
86328 EXPORT_SYMBOL(sysctl_tcp_low_latency);
86329
86330
86331 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
86332 +extern int grsec_enable_blackhole;
86333 +#endif
86334 +
86335 #ifdef CONFIG_TCP_MD5SIG
86336 static int tcp_v4_md5_hash_hdr(char *md5_hash, const struct tcp_md5sig_key *key,
86337 __be32 daddr, __be32 saddr, const struct tcphdr *th);
86338 @@ -1895,6 +1899,9 @@ int tcp_v4_do_rcv(struct sock *sk, struct sk_buff *skb)
86339 return 0;
86340
86341 reset:
86342 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
86343 + if (!grsec_enable_blackhole)
86344 +#endif
86345 tcp_v4_send_reset(rsk, skb);
86346 discard:
86347 kfree_skb(skb);
86348 @@ -1994,12 +2001,19 @@ int tcp_v4_rcv(struct sk_buff *skb)
86349 TCP_SKB_CB(skb)->sacked = 0;
86350
86351 sk = __inet_lookup_skb(&tcp_hashinfo, skb, th->source, th->dest);
86352 - if (!sk)
86353 + if (!sk) {
86354 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
86355 + ret = 1;
86356 +#endif
86357 goto no_tcp_socket;
86358 -
86359 + }
86360 process:
86361 - if (sk->sk_state == TCP_TIME_WAIT)
86362 + if (sk->sk_state == TCP_TIME_WAIT) {
86363 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
86364 + ret = 2;
86365 +#endif
86366 goto do_time_wait;
86367 + }
86368
86369 if (unlikely(iph->ttl < inet_sk(sk)->min_ttl)) {
86370 NET_INC_STATS_BH(net, LINUX_MIB_TCPMINTTLDROP);
86371 @@ -2050,6 +2064,10 @@ no_tcp_socket:
86372 bad_packet:
86373 TCP_INC_STATS_BH(net, TCP_MIB_INERRS);
86374 } else {
86375 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
86376 + if (!grsec_enable_blackhole || (ret == 1 &&
86377 + (skb->dev->flags & IFF_LOOPBACK)))
86378 +#endif
86379 tcp_v4_send_reset(NULL, skb);
86380 }
86381
86382 diff --git a/net/ipv4/tcp_minisocks.c b/net/ipv4/tcp_minisocks.c
86383 index f35f2df..ccb5ca6 100644
86384 --- a/net/ipv4/tcp_minisocks.c
86385 +++ b/net/ipv4/tcp_minisocks.c
86386 @@ -27,6 +27,10 @@
86387 #include <net/inet_common.h>
86388 #include <net/xfrm.h>
86389
86390 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
86391 +extern int grsec_enable_blackhole;
86392 +#endif
86393 +
86394 int sysctl_tcp_syncookies __read_mostly = 1;
86395 EXPORT_SYMBOL(sysctl_tcp_syncookies);
86396
86397 @@ -742,7 +746,10 @@ embryonic_reset:
86398 * avoid becoming vulnerable to outside attack aiming at
86399 * resetting legit local connections.
86400 */
86401 - req->rsk_ops->send_reset(sk, skb);
86402 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
86403 + if (!grsec_enable_blackhole)
86404 +#endif
86405 + req->rsk_ops->send_reset(sk, skb);
86406 } else if (fastopen) { /* received a valid RST pkt */
86407 reqsk_fastopen_remove(sk, req, true);
86408 tcp_reset(sk);
86409 diff --git a/net/ipv4/tcp_probe.c b/net/ipv4/tcp_probe.c
86410 index 4526fe6..1a34e43 100644
86411 --- a/net/ipv4/tcp_probe.c
86412 +++ b/net/ipv4/tcp_probe.c
86413 @@ -204,7 +204,7 @@ static ssize_t tcpprobe_read(struct file *file, char __user *buf,
86414 if (cnt + width >= len)
86415 break;
86416
86417 - if (copy_to_user(buf + cnt, tbuf, width))
86418 + if (width > sizeof tbuf || copy_to_user(buf + cnt, tbuf, width))
86419 return -EFAULT;
86420 cnt += width;
86421 }
86422 diff --git a/net/ipv4/tcp_timer.c b/net/ipv4/tcp_timer.c
86423 index b78aac3..e18230b 100644
86424 --- a/net/ipv4/tcp_timer.c
86425 +++ b/net/ipv4/tcp_timer.c
86426 @@ -22,6 +22,10 @@
86427 #include <linux/gfp.h>
86428 #include <net/tcp.h>
86429
86430 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
86431 +extern int grsec_lastack_retries;
86432 +#endif
86433 +
86434 int sysctl_tcp_syn_retries __read_mostly = TCP_SYN_RETRIES;
86435 int sysctl_tcp_synack_retries __read_mostly = TCP_SYNACK_RETRIES;
86436 int sysctl_tcp_keepalive_time __read_mostly = TCP_KEEPALIVE_TIME;
86437 @@ -185,6 +189,13 @@ static int tcp_write_timeout(struct sock *sk)
86438 }
86439 }
86440
86441 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
86442 + if ((sk->sk_state == TCP_LAST_ACK) &&
86443 + (grsec_lastack_retries > 0) &&
86444 + (grsec_lastack_retries < retry_until))
86445 + retry_until = grsec_lastack_retries;
86446 +#endif
86447 +
86448 if (retransmits_timed_out(sk, retry_until,
86449 syn_set ? 0 : icsk->icsk_user_timeout, syn_set)) {
86450 /* Has it gone just too far? */
86451 diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
86452 index 1f4d405..3524677 100644
86453 --- a/net/ipv4/udp.c
86454 +++ b/net/ipv4/udp.c
86455 @@ -87,6 +87,7 @@
86456 #include <linux/types.h>
86457 #include <linux/fcntl.h>
86458 #include <linux/module.h>
86459 +#include <linux/security.h>
86460 #include <linux/socket.h>
86461 #include <linux/sockios.h>
86462 #include <linux/igmp.h>
86463 @@ -111,6 +112,10 @@
86464 #include <trace/events/skb.h>
86465 #include "udp_impl.h"
86466
86467 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
86468 +extern int grsec_enable_blackhole;
86469 +#endif
86470 +
86471 struct udp_table udp_table __read_mostly;
86472 EXPORT_SYMBOL(udp_table);
86473
86474 @@ -569,6 +574,9 @@ found:
86475 return s;
86476 }
86477
86478 +extern int gr_search_udp_recvmsg(struct sock *sk, const struct sk_buff *skb);
86479 +extern int gr_search_udp_sendmsg(struct sock *sk, struct sockaddr_in *addr);
86480 +
86481 /*
86482 * This routine is called by the ICMP module when it gets some
86483 * sort of error condition. If err < 0 then the socket should
86484 @@ -864,9 +872,18 @@ int udp_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
86485 dport = usin->sin_port;
86486 if (dport == 0)
86487 return -EINVAL;
86488 +
86489 + err = gr_search_udp_sendmsg(sk, usin);
86490 + if (err)
86491 + return err;
86492 } else {
86493 if (sk->sk_state != TCP_ESTABLISHED)
86494 return -EDESTADDRREQ;
86495 +
86496 + err = gr_search_udp_sendmsg(sk, NULL);
86497 + if (err)
86498 + return err;
86499 +
86500 daddr = inet->inet_daddr;
86501 dport = inet->inet_dport;
86502 /* Open fast path for connected socket.
86503 @@ -1108,7 +1125,7 @@ static unsigned int first_packet_length(struct sock *sk)
86504 udp_lib_checksum_complete(skb)) {
86505 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS,
86506 IS_UDPLITE(sk));
86507 - atomic_inc(&sk->sk_drops);
86508 + atomic_inc_unchecked(&sk->sk_drops);
86509 __skb_unlink(skb, rcvq);
86510 __skb_queue_tail(&list_kill, skb);
86511 }
86512 @@ -1194,6 +1211,10 @@ try_again:
86513 if (!skb)
86514 goto out;
86515
86516 + err = gr_search_udp_recvmsg(sk, skb);
86517 + if (err)
86518 + goto out_free;
86519 +
86520 ulen = skb->len - sizeof(struct udphdr);
86521 copied = len;
86522 if (copied > ulen)
86523 @@ -1227,7 +1248,7 @@ try_again:
86524 if (unlikely(err)) {
86525 trace_kfree_skb(skb, udp_recvmsg);
86526 if (!peeked) {
86527 - atomic_inc(&sk->sk_drops);
86528 + atomic_inc_unchecked(&sk->sk_drops);
86529 UDP_INC_STATS_USER(sock_net(sk),
86530 UDP_MIB_INERRORS, is_udplite);
86531 }
86532 @@ -1510,7 +1531,7 @@ int udp_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
86533
86534 drop:
86535 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS, is_udplite);
86536 - atomic_inc(&sk->sk_drops);
86537 + atomic_inc_unchecked(&sk->sk_drops);
86538 kfree_skb(skb);
86539 return -1;
86540 }
86541 @@ -1529,7 +1550,7 @@ static void flush_stack(struct sock **stack, unsigned int count,
86542 skb1 = (i == final) ? skb : skb_clone(skb, GFP_ATOMIC);
86543
86544 if (!skb1) {
86545 - atomic_inc(&sk->sk_drops);
86546 + atomic_inc_unchecked(&sk->sk_drops);
86547 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_RCVBUFERRORS,
86548 IS_UDPLITE(sk));
86549 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS,
86550 @@ -1698,6 +1719,9 @@ int __udp4_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
86551 goto csum_error;
86552
86553 UDP_INC_STATS_BH(net, UDP_MIB_NOPORTS, proto == IPPROTO_UDPLITE);
86554 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
86555 + if (!grsec_enable_blackhole || (skb->dev->flags & IFF_LOOPBACK))
86556 +#endif
86557 icmp_send(skb, ICMP_DEST_UNREACH, ICMP_PORT_UNREACH, 0);
86558
86559 /*
86560 @@ -2120,7 +2144,7 @@ static void udp4_format_sock(struct sock *sp, struct seq_file *f,
86561 from_kuid_munged(seq_user_ns(f), sock_i_uid(sp)),
86562 0, sock_i_ino(sp),
86563 atomic_read(&sp->sk_refcnt), sp,
86564 - atomic_read(&sp->sk_drops), len);
86565 + atomic_read_unchecked(&sp->sk_drops), len);
86566 }
86567
86568 int udp4_seq_show(struct seq_file *seq, void *v)
86569 diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
86570 index 1b5d8cb..ffb0833 100644
86571 --- a/net/ipv6/addrconf.c
86572 +++ b/net/ipv6/addrconf.c
86573 @@ -2272,7 +2272,7 @@ int addrconf_set_dstaddr(struct net *net, void __user *arg)
86574 p.iph.ihl = 5;
86575 p.iph.protocol = IPPROTO_IPV6;
86576 p.iph.ttl = 64;
86577 - ifr.ifr_ifru.ifru_data = (__force void __user *)&p;
86578 + ifr.ifr_ifru.ifru_data = (void __force_user *)&p;
86579
86580 if (ops->ndo_do_ioctl) {
86581 mm_segment_t oldfs = get_fs();
86582 @@ -4388,7 +4388,7 @@ int addrconf_sysctl_forward(ctl_table *ctl, int write,
86583 int *valp = ctl->data;
86584 int val = *valp;
86585 loff_t pos = *ppos;
86586 - ctl_table lctl;
86587 + ctl_table_no_const lctl;
86588 int ret;
86589
86590 /*
86591 @@ -4470,7 +4470,7 @@ int addrconf_sysctl_disable(ctl_table *ctl, int write,
86592 int *valp = ctl->data;
86593 int val = *valp;
86594 loff_t pos = *ppos;
86595 - ctl_table lctl;
86596 + ctl_table_no_const lctl;
86597 int ret;
86598
86599 /*
86600 diff --git a/net/ipv6/icmp.c b/net/ipv6/icmp.c
86601 index fff5bdd..15194fb 100644
86602 --- a/net/ipv6/icmp.c
86603 +++ b/net/ipv6/icmp.c
86604 @@ -973,7 +973,7 @@ ctl_table ipv6_icmp_table_template[] = {
86605
86606 struct ctl_table * __net_init ipv6_icmp_sysctl_init(struct net *net)
86607 {
86608 - struct ctl_table *table;
86609 + ctl_table_no_const *table;
86610
86611 table = kmemdup(ipv6_icmp_table_template,
86612 sizeof(ipv6_icmp_table_template),
86613 diff --git a/net/ipv6/ip6_gre.c b/net/ipv6/ip6_gre.c
86614 index 131dd09..f7ed64f 100644
86615 --- a/net/ipv6/ip6_gre.c
86616 +++ b/net/ipv6/ip6_gre.c
86617 @@ -73,7 +73,7 @@ struct ip6gre_net {
86618 struct net_device *fb_tunnel_dev;
86619 };
86620
86621 -static struct rtnl_link_ops ip6gre_link_ops __read_mostly;
86622 +static struct rtnl_link_ops ip6gre_link_ops;
86623 static int ip6gre_tunnel_init(struct net_device *dev);
86624 static void ip6gre_tunnel_setup(struct net_device *dev);
86625 static void ip6gre_tunnel_link(struct ip6gre_net *ign, struct ip6_tnl *t);
86626 @@ -1337,7 +1337,7 @@ static void ip6gre_fb_tunnel_init(struct net_device *dev)
86627 }
86628
86629
86630 -static struct inet6_protocol ip6gre_protocol __read_mostly = {
86631 +static struct inet6_protocol ip6gre_protocol = {
86632 .handler = ip6gre_rcv,
86633 .err_handler = ip6gre_err,
86634 .flags = INET6_PROTO_NOPOLICY|INET6_PROTO_FINAL,
86635 @@ -1671,7 +1671,7 @@ static const struct nla_policy ip6gre_policy[IFLA_GRE_MAX + 1] = {
86636 [IFLA_GRE_FLAGS] = { .type = NLA_U32 },
86637 };
86638
86639 -static struct rtnl_link_ops ip6gre_link_ops __read_mostly = {
86640 +static struct rtnl_link_ops ip6gre_link_ops = {
86641 .kind = "ip6gre",
86642 .maxtype = IFLA_GRE_MAX,
86643 .policy = ip6gre_policy,
86644 @@ -1684,7 +1684,7 @@ static struct rtnl_link_ops ip6gre_link_ops __read_mostly = {
86645 .fill_info = ip6gre_fill_info,
86646 };
86647
86648 -static struct rtnl_link_ops ip6gre_tap_ops __read_mostly = {
86649 +static struct rtnl_link_ops ip6gre_tap_ops = {
86650 .kind = "ip6gretap",
86651 .maxtype = IFLA_GRE_MAX,
86652 .policy = ip6gre_policy,
86653 diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c
86654 index a14f28b..b4b8956 100644
86655 --- a/net/ipv6/ip6_tunnel.c
86656 +++ b/net/ipv6/ip6_tunnel.c
86657 @@ -87,7 +87,7 @@ static u32 HASH(const struct in6_addr *addr1, const struct in6_addr *addr2)
86658
86659 static int ip6_tnl_dev_init(struct net_device *dev);
86660 static void ip6_tnl_dev_setup(struct net_device *dev);
86661 -static struct rtnl_link_ops ip6_link_ops __read_mostly;
86662 +static struct rtnl_link_ops ip6_link_ops;
86663
86664 static int ip6_tnl_net_id __read_mostly;
86665 struct ip6_tnl_net {
86666 @@ -1686,7 +1686,7 @@ static const struct nla_policy ip6_tnl_policy[IFLA_IPTUN_MAX + 1] = {
86667 [IFLA_IPTUN_PROTO] = { .type = NLA_U8 },
86668 };
86669
86670 -static struct rtnl_link_ops ip6_link_ops __read_mostly = {
86671 +static struct rtnl_link_ops ip6_link_ops = {
86672 .kind = "ip6tnl",
86673 .maxtype = IFLA_IPTUN_MAX,
86674 .policy = ip6_tnl_policy,
86675 diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c
86676 index d1e2e8e..51c19ae 100644
86677 --- a/net/ipv6/ipv6_sockglue.c
86678 +++ b/net/ipv6/ipv6_sockglue.c
86679 @@ -991,7 +991,7 @@ static int do_ipv6_getsockopt(struct sock *sk, int level, int optname,
86680 if (sk->sk_type != SOCK_STREAM)
86681 return -ENOPROTOOPT;
86682
86683 - msg.msg_control = optval;
86684 + msg.msg_control = (void __force_kernel *)optval;
86685 msg.msg_controllen = len;
86686 msg.msg_flags = flags;
86687
86688 diff --git a/net/ipv6/netfilter/ip6_tables.c b/net/ipv6/netfilter/ip6_tables.c
86689 index 125a90d..2a11f36 100644
86690 --- a/net/ipv6/netfilter/ip6_tables.c
86691 +++ b/net/ipv6/netfilter/ip6_tables.c
86692 @@ -1076,14 +1076,14 @@ static int compat_table_info(const struct xt_table_info *info,
86693 #endif
86694
86695 static int get_info(struct net *net, void __user *user,
86696 - const int *len, int compat)
86697 + int len, int compat)
86698 {
86699 char name[XT_TABLE_MAXNAMELEN];
86700 struct xt_table *t;
86701 int ret;
86702
86703 - if (*len != sizeof(struct ip6t_getinfo)) {
86704 - duprintf("length %u != %zu\n", *len,
86705 + if (len != sizeof(struct ip6t_getinfo)) {
86706 + duprintf("length %u != %zu\n", len,
86707 sizeof(struct ip6t_getinfo));
86708 return -EINVAL;
86709 }
86710 @@ -1120,7 +1120,7 @@ static int get_info(struct net *net, void __user *user,
86711 info.size = private->size;
86712 strcpy(info.name, name);
86713
86714 - if (copy_to_user(user, &info, *len) != 0)
86715 + if (copy_to_user(user, &info, len) != 0)
86716 ret = -EFAULT;
86717 else
86718 ret = 0;
86719 @@ -1974,7 +1974,7 @@ compat_do_ip6t_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
86720
86721 switch (cmd) {
86722 case IP6T_SO_GET_INFO:
86723 - ret = get_info(sock_net(sk), user, len, 1);
86724 + ret = get_info(sock_net(sk), user, *len, 1);
86725 break;
86726 case IP6T_SO_GET_ENTRIES:
86727 ret = compat_get_entries(sock_net(sk), user, len);
86728 @@ -2021,7 +2021,7 @@ do_ip6t_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
86729
86730 switch (cmd) {
86731 case IP6T_SO_GET_INFO:
86732 - ret = get_info(sock_net(sk), user, len, 0);
86733 + ret = get_info(sock_net(sk), user, *len, 0);
86734 break;
86735
86736 case IP6T_SO_GET_ENTRIES:
86737 diff --git a/net/ipv6/netfilter/nf_conntrack_reasm.c b/net/ipv6/netfilter/nf_conntrack_reasm.c
86738 index 3dacecc..2939087 100644
86739 --- a/net/ipv6/netfilter/nf_conntrack_reasm.c
86740 +++ b/net/ipv6/netfilter/nf_conntrack_reasm.c
86741 @@ -87,12 +87,11 @@ static struct ctl_table nf_ct_frag6_sysctl_table[] = {
86742
86743 static int nf_ct_frag6_sysctl_register(struct net *net)
86744 {
86745 - struct ctl_table *table;
86746 + ctl_table_no_const *table = NULL;
86747 struct ctl_table_header *hdr;
86748
86749 - table = nf_ct_frag6_sysctl_table;
86750 if (!net_eq(net, &init_net)) {
86751 - table = kmemdup(table, sizeof(nf_ct_frag6_sysctl_table),
86752 + table = kmemdup(nf_ct_frag6_sysctl_table, sizeof(nf_ct_frag6_sysctl_table),
86753 GFP_KERNEL);
86754 if (table == NULL)
86755 goto err_alloc;
86756 @@ -100,9 +99,9 @@ static int nf_ct_frag6_sysctl_register(struct net *net)
86757 table[0].data = &net->ipv6.frags.high_thresh;
86758 table[1].data = &net->ipv6.frags.low_thresh;
86759 table[2].data = &net->ipv6.frags.timeout;
86760 - }
86761 -
86762 - hdr = register_net_sysctl(net, "net/netfilter", table);
86763 + hdr = register_net_sysctl(net, "net/netfilter", table);
86764 + } else
86765 + hdr = register_net_sysctl(net, "net/netfilter", nf_ct_frag6_sysctl_table);
86766 if (hdr == NULL)
86767 goto err_reg;
86768
86769 @@ -110,8 +109,7 @@ static int nf_ct_frag6_sysctl_register(struct net *net)
86770 return 0;
86771
86772 err_reg:
86773 - if (!net_eq(net, &init_net))
86774 - kfree(table);
86775 + kfree(table);
86776 err_alloc:
86777 return -ENOMEM;
86778 }
86779 diff --git a/net/ipv6/raw.c b/net/ipv6/raw.c
86780 index 70fa814..d70c28c 100644
86781 --- a/net/ipv6/raw.c
86782 +++ b/net/ipv6/raw.c
86783 @@ -379,7 +379,7 @@ static inline int rawv6_rcv_skb(struct sock *sk, struct sk_buff *skb)
86784 {
86785 if ((raw6_sk(sk)->checksum || rcu_access_pointer(sk->sk_filter)) &&
86786 skb_checksum_complete(skb)) {
86787 - atomic_inc(&sk->sk_drops);
86788 + atomic_inc_unchecked(&sk->sk_drops);
86789 kfree_skb(skb);
86790 return NET_RX_DROP;
86791 }
86792 @@ -407,7 +407,7 @@ int rawv6_rcv(struct sock *sk, struct sk_buff *skb)
86793 struct raw6_sock *rp = raw6_sk(sk);
86794
86795 if (!xfrm6_policy_check(sk, XFRM_POLICY_IN, skb)) {
86796 - atomic_inc(&sk->sk_drops);
86797 + atomic_inc_unchecked(&sk->sk_drops);
86798 kfree_skb(skb);
86799 return NET_RX_DROP;
86800 }
86801 @@ -431,7 +431,7 @@ int rawv6_rcv(struct sock *sk, struct sk_buff *skb)
86802
86803 if (inet->hdrincl) {
86804 if (skb_checksum_complete(skb)) {
86805 - atomic_inc(&sk->sk_drops);
86806 + atomic_inc_unchecked(&sk->sk_drops);
86807 kfree_skb(skb);
86808 return NET_RX_DROP;
86809 }
86810 @@ -604,7 +604,7 @@ out:
86811 return err;
86812 }
86813
86814 -static int rawv6_send_hdrinc(struct sock *sk, void *from, int length,
86815 +static int rawv6_send_hdrinc(struct sock *sk, void *from, unsigned int length,
86816 struct flowi6 *fl6, struct dst_entry **dstp,
86817 unsigned int flags)
86818 {
86819 @@ -916,12 +916,15 @@ do_confirm:
86820 static int rawv6_seticmpfilter(struct sock *sk, int level, int optname,
86821 char __user *optval, int optlen)
86822 {
86823 + struct icmp6_filter filter;
86824 +
86825 switch (optname) {
86826 case ICMPV6_FILTER:
86827 if (optlen > sizeof(struct icmp6_filter))
86828 optlen = sizeof(struct icmp6_filter);
86829 - if (copy_from_user(&raw6_sk(sk)->filter, optval, optlen))
86830 + if (copy_from_user(&filter, optval, optlen))
86831 return -EFAULT;
86832 + raw6_sk(sk)->filter = filter;
86833 return 0;
86834 default:
86835 return -ENOPROTOOPT;
86836 @@ -934,6 +937,7 @@ static int rawv6_geticmpfilter(struct sock *sk, int level, int optname,
86837 char __user *optval, int __user *optlen)
86838 {
86839 int len;
86840 + struct icmp6_filter filter;
86841
86842 switch (optname) {
86843 case ICMPV6_FILTER:
86844 @@ -945,7 +949,8 @@ static int rawv6_geticmpfilter(struct sock *sk, int level, int optname,
86845 len = sizeof(struct icmp6_filter);
86846 if (put_user(len, optlen))
86847 return -EFAULT;
86848 - if (copy_to_user(optval, &raw6_sk(sk)->filter, len))
86849 + filter = raw6_sk(sk)->filter;
86850 + if (len > sizeof filter || copy_to_user(optval, &filter, len))
86851 return -EFAULT;
86852 return 0;
86853 default:
86854 @@ -1253,7 +1258,7 @@ static void raw6_sock_seq_show(struct seq_file *seq, struct sock *sp, int i)
86855 from_kuid_munged(seq_user_ns(seq), sock_i_uid(sp)),
86856 0,
86857 sock_i_ino(sp),
86858 - atomic_read(&sp->sk_refcnt), sp, atomic_read(&sp->sk_drops));
86859 + atomic_read(&sp->sk_refcnt), sp, atomic_read_unchecked(&sp->sk_drops));
86860 }
86861
86862 static int raw6_seq_show(struct seq_file *seq, void *v)
86863 diff --git a/net/ipv6/reassembly.c b/net/ipv6/reassembly.c
86864 index e5253ec..0410257 100644
86865 --- a/net/ipv6/reassembly.c
86866 +++ b/net/ipv6/reassembly.c
86867 @@ -604,12 +604,11 @@ static struct ctl_table ip6_frags_ctl_table[] = {
86868
86869 static int __net_init ip6_frags_ns_sysctl_register(struct net *net)
86870 {
86871 - struct ctl_table *table;
86872 + ctl_table_no_const *table = NULL;
86873 struct ctl_table_header *hdr;
86874
86875 - table = ip6_frags_ns_ctl_table;
86876 if (!net_eq(net, &init_net)) {
86877 - table = kmemdup(table, sizeof(ip6_frags_ns_ctl_table), GFP_KERNEL);
86878 + table = kmemdup(ip6_frags_ns_ctl_table, sizeof(ip6_frags_ns_ctl_table), GFP_KERNEL);
86879 if (table == NULL)
86880 goto err_alloc;
86881
86882 @@ -620,9 +619,10 @@ static int __net_init ip6_frags_ns_sysctl_register(struct net *net)
86883 /* Don't export sysctls to unprivileged users */
86884 if (net->user_ns != &init_user_ns)
86885 table[0].procname = NULL;
86886 - }
86887 + hdr = register_net_sysctl(net, "net/ipv6", table);
86888 + } else
86889 + hdr = register_net_sysctl(net, "net/ipv6", ip6_frags_ns_ctl_table);
86890
86891 - hdr = register_net_sysctl(net, "net/ipv6", table);
86892 if (hdr == NULL)
86893 goto err_reg;
86894
86895 @@ -630,8 +630,7 @@ static int __net_init ip6_frags_ns_sysctl_register(struct net *net)
86896 return 0;
86897
86898 err_reg:
86899 - if (!net_eq(net, &init_net))
86900 - kfree(table);
86901 + kfree(table);
86902 err_alloc:
86903 return -ENOMEM;
86904 }
86905 diff --git a/net/ipv6/route.c b/net/ipv6/route.c
86906 index 6f9f7b6..2306d63 100644
86907 --- a/net/ipv6/route.c
86908 +++ b/net/ipv6/route.c
86909 @@ -2965,7 +2965,7 @@ ctl_table ipv6_route_table_template[] = {
86910
86911 struct ctl_table * __net_init ipv6_route_sysctl_init(struct net *net)
86912 {
86913 - struct ctl_table *table;
86914 + ctl_table_no_const *table;
86915
86916 table = kmemdup(ipv6_route_table_template,
86917 sizeof(ipv6_route_table_template),
86918 diff --git a/net/ipv6/sit.c b/net/ipv6/sit.c
86919 index cfba99b..20ca511 100644
86920 --- a/net/ipv6/sit.c
86921 +++ b/net/ipv6/sit.c
86922 @@ -72,7 +72,7 @@ MODULE_PARM_DESC(log_ecn_error, "Log packets received with corrupted ECN");
86923 static int ipip6_tunnel_init(struct net_device *dev);
86924 static void ipip6_tunnel_setup(struct net_device *dev);
86925 static void ipip6_dev_free(struct net_device *dev);
86926 -static struct rtnl_link_ops sit_link_ops __read_mostly;
86927 +static struct rtnl_link_ops sit_link_ops;
86928
86929 static int sit_net_id __read_mostly;
86930 struct sit_net {
86931 @@ -1463,7 +1463,7 @@ static const struct nla_policy ipip6_policy[IFLA_IPTUN_MAX + 1] = {
86932 #endif
86933 };
86934
86935 -static struct rtnl_link_ops sit_link_ops __read_mostly = {
86936 +static struct rtnl_link_ops sit_link_ops = {
86937 .kind = "sit",
86938 .maxtype = IFLA_IPTUN_MAX,
86939 .policy = ipip6_policy,
86940 diff --git a/net/ipv6/sysctl_net_ipv6.c b/net/ipv6/sysctl_net_ipv6.c
86941 index e85c48b..b8268d3 100644
86942 --- a/net/ipv6/sysctl_net_ipv6.c
86943 +++ b/net/ipv6/sysctl_net_ipv6.c
86944 @@ -40,7 +40,7 @@ static ctl_table ipv6_rotable[] = {
86945
86946 static int __net_init ipv6_sysctl_net_init(struct net *net)
86947 {
86948 - struct ctl_table *ipv6_table;
86949 + ctl_table_no_const *ipv6_table;
86950 struct ctl_table *ipv6_route_table;
86951 struct ctl_table *ipv6_icmp_table;
86952 int err;
86953 diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
86954 index 4f435371..5de9da7 100644
86955 --- a/net/ipv6/tcp_ipv6.c
86956 +++ b/net/ipv6/tcp_ipv6.c
86957 @@ -103,6 +103,10 @@ static void inet6_sk_rx_dst_set(struct sock *sk, const struct sk_buff *skb)
86958 inet6_sk(sk)->rx_dst_cookie = rt->rt6i_node->fn_sernum;
86959 }
86960
86961 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
86962 +extern int grsec_enable_blackhole;
86963 +#endif
86964 +
86965 static void tcp_v6_hash(struct sock *sk)
86966 {
86967 if (sk->sk_state != TCP_CLOSE) {
86968 @@ -1433,6 +1437,9 @@ static int tcp_v6_do_rcv(struct sock *sk, struct sk_buff *skb)
86969 return 0;
86970
86971 reset:
86972 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
86973 + if (!grsec_enable_blackhole)
86974 +#endif
86975 tcp_v6_send_reset(sk, skb);
86976 discard:
86977 if (opt_skb)
86978 @@ -1514,12 +1521,20 @@ static int tcp_v6_rcv(struct sk_buff *skb)
86979 TCP_SKB_CB(skb)->sacked = 0;
86980
86981 sk = __inet6_lookup_skb(&tcp_hashinfo, skb, th->source, th->dest);
86982 - if (!sk)
86983 + if (!sk) {
86984 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
86985 + ret = 1;
86986 +#endif
86987 goto no_tcp_socket;
86988 + }
86989
86990 process:
86991 - if (sk->sk_state == TCP_TIME_WAIT)
86992 + if (sk->sk_state == TCP_TIME_WAIT) {
86993 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
86994 + ret = 2;
86995 +#endif
86996 goto do_time_wait;
86997 + }
86998
86999 if (hdr->hop_limit < inet6_sk(sk)->min_hopcount) {
87000 NET_INC_STATS_BH(net, LINUX_MIB_TCPMINTTLDROP);
87001 @@ -1568,6 +1583,10 @@ no_tcp_socket:
87002 bad_packet:
87003 TCP_INC_STATS_BH(net, TCP_MIB_INERRS);
87004 } else {
87005 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87006 + if (!grsec_enable_blackhole || (ret == 1 &&
87007 + (skb->dev->flags & IFF_LOOPBACK)))
87008 +#endif
87009 tcp_v6_send_reset(NULL, skb);
87010 }
87011
87012 diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c
87013 index fb08329..2d6919e 100644
87014 --- a/net/ipv6/udp.c
87015 +++ b/net/ipv6/udp.c
87016 @@ -51,6 +51,10 @@
87017 #include <trace/events/skb.h>
87018 #include "udp_impl.h"
87019
87020 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87021 +extern int grsec_enable_blackhole;
87022 +#endif
87023 +
87024 int ipv6_rcv_saddr_equal(const struct sock *sk, const struct sock *sk2)
87025 {
87026 const struct in6_addr *sk_rcv_saddr6 = &inet6_sk(sk)->rcv_saddr;
87027 @@ -395,7 +399,7 @@ try_again:
87028 if (unlikely(err)) {
87029 trace_kfree_skb(skb, udpv6_recvmsg);
87030 if (!peeked) {
87031 - atomic_inc(&sk->sk_drops);
87032 + atomic_inc_unchecked(&sk->sk_drops);
87033 if (is_udp4)
87034 UDP_INC_STATS_USER(sock_net(sk),
87035 UDP_MIB_INERRORS,
87036 @@ -633,7 +637,7 @@ int udpv6_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
87037 return rc;
87038 drop:
87039 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS, is_udplite);
87040 - atomic_inc(&sk->sk_drops);
87041 + atomic_inc_unchecked(&sk->sk_drops);
87042 kfree_skb(skb);
87043 return -1;
87044 }
87045 @@ -691,7 +695,7 @@ static void flush_stack(struct sock **stack, unsigned int count,
87046 if (likely(skb1 == NULL))
87047 skb1 = (i == final) ? skb : skb_clone(skb, GFP_ATOMIC);
87048 if (!skb1) {
87049 - atomic_inc(&sk->sk_drops);
87050 + atomic_inc_unchecked(&sk->sk_drops);
87051 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_RCVBUFERRORS,
87052 IS_UDPLITE(sk));
87053 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS,
87054 @@ -862,6 +866,9 @@ int __udp6_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
87055 goto discard;
87056
87057 UDP6_INC_STATS_BH(net, UDP_MIB_NOPORTS, proto == IPPROTO_UDPLITE);
87058 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87059 + if (!grsec_enable_blackhole || (skb->dev->flags & IFF_LOOPBACK))
87060 +#endif
87061 icmpv6_send(skb, ICMPV6_DEST_UNREACH, ICMPV6_PORT_UNREACH, 0);
87062
87063 kfree_skb(skb);
87064 @@ -1379,7 +1386,7 @@ static void udp6_sock_seq_show(struct seq_file *seq, struct sock *sp, int bucket
87065 0,
87066 sock_i_ino(sp),
87067 atomic_read(&sp->sk_refcnt), sp,
87068 - atomic_read(&sp->sk_drops));
87069 + atomic_read_unchecked(&sp->sk_drops));
87070 }
87071
87072 int udp6_seq_show(struct seq_file *seq, void *v)
87073 diff --git a/net/irda/af_irda.c b/net/irda/af_irda.c
87074 index b833677..4d04105 100644
87075 --- a/net/irda/af_irda.c
87076 +++ b/net/irda/af_irda.c
87077 @@ -2584,8 +2584,10 @@ bed:
87078 NULL, NULL, NULL);
87079
87080 /* Check if the we got some results */
87081 - if (!self->cachedaddr)
87082 - return -EAGAIN; /* Didn't find any devices */
87083 + if (!self->cachedaddr) {
87084 + err = -EAGAIN; /* Didn't find any devices */
87085 + goto out;
87086 + }
87087 daddr = self->cachedaddr;
87088 /* Cleanup */
87089 self->cachedaddr = 0;
87090 diff --git a/net/irda/ircomm/ircomm_tty.c b/net/irda/ircomm/ircomm_tty.c
87091 index a68c88c..d55b0c5 100644
87092 --- a/net/irda/ircomm/ircomm_tty.c
87093 +++ b/net/irda/ircomm/ircomm_tty.c
87094 @@ -312,12 +312,12 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
87095 add_wait_queue(&port->open_wait, &wait);
87096
87097 IRDA_DEBUG(2, "%s(%d):block_til_ready before block on %s open_count=%d\n",
87098 - __FILE__, __LINE__, tty->driver->name, port->count);
87099 + __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
87100
87101 spin_lock_irqsave(&port->lock, flags);
87102 if (!tty_hung_up_p(filp)) {
87103 extra_count = 1;
87104 - port->count--;
87105 + atomic_dec(&port->count);
87106 }
87107 spin_unlock_irqrestore(&port->lock, flags);
87108 port->blocked_open++;
87109 @@ -353,7 +353,7 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
87110 }
87111
87112 IRDA_DEBUG(1, "%s(%d):block_til_ready blocking on %s open_count=%d\n",
87113 - __FILE__, __LINE__, tty->driver->name, port->count);
87114 + __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
87115
87116 schedule();
87117 }
87118 @@ -364,13 +364,13 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
87119 if (extra_count) {
87120 /* ++ is not atomic, so this should be protected - Jean II */
87121 spin_lock_irqsave(&port->lock, flags);
87122 - port->count++;
87123 + atomic_inc(&port->count);
87124 spin_unlock_irqrestore(&port->lock, flags);
87125 }
87126 port->blocked_open--;
87127
87128 IRDA_DEBUG(1, "%s(%d):block_til_ready after blocking on %s open_count=%d\n",
87129 - __FILE__, __LINE__, tty->driver->name, port->count);
87130 + __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
87131
87132 if (!retval)
87133 port->flags |= ASYNC_NORMAL_ACTIVE;
87134 @@ -444,12 +444,12 @@ static int ircomm_tty_open(struct tty_struct *tty, struct file *filp)
87135
87136 /* ++ is not atomic, so this should be protected - Jean II */
87137 spin_lock_irqsave(&self->port.lock, flags);
87138 - self->port.count++;
87139 + atomic_inc(&self->port.count);
87140 spin_unlock_irqrestore(&self->port.lock, flags);
87141 tty_port_tty_set(&self->port, tty);
87142
87143 IRDA_DEBUG(1, "%s(), %s%d, count = %d\n", __func__ , tty->driver->name,
87144 - self->line, self->port.count);
87145 + self->line, atomic_read(&self->port.count));
87146
87147 /* Not really used by us, but lets do it anyway */
87148 tty->low_latency = (self->port.flags & ASYNC_LOW_LATENCY) ? 1 : 0;
87149 @@ -986,7 +986,7 @@ static void ircomm_tty_hangup(struct tty_struct *tty)
87150 tty_kref_put(port->tty);
87151 }
87152 port->tty = NULL;
87153 - port->count = 0;
87154 + atomic_set(&port->count, 0);
87155 spin_unlock_irqrestore(&port->lock, flags);
87156
87157 wake_up_interruptible(&port->open_wait);
87158 @@ -1343,7 +1343,7 @@ static void ircomm_tty_line_info(struct ircomm_tty_cb *self, struct seq_file *m)
87159 seq_putc(m, '\n');
87160
87161 seq_printf(m, "Role: %s\n", self->client ? "client" : "server");
87162 - seq_printf(m, "Open count: %d\n", self->port.count);
87163 + seq_printf(m, "Open count: %d\n", atomic_read(&self->port.count));
87164 seq_printf(m, "Max data size: %d\n", self->max_data_size);
87165 seq_printf(m, "Max header size: %d\n", self->max_header_size);
87166
87167 diff --git a/net/irda/iriap.c b/net/irda/iriap.c
87168 index e71e85b..29340a9 100644
87169 --- a/net/irda/iriap.c
87170 +++ b/net/irda/iriap.c
87171 @@ -495,8 +495,11 @@ static void iriap_getvaluebyclass_confirm(struct iriap_cb *self,
87172 /* case CS_ISO_8859_9: */
87173 /* case CS_UNICODE: */
87174 default:
87175 - IRDA_DEBUG(0, "%s(), charset %s, not supported\n",
87176 - __func__, ias_charset_types[charset]);
87177 + IRDA_DEBUG(0, "%s(), charset [%d] %s, not supported\n",
87178 + __func__, charset,
87179 + charset < ARRAY_SIZE(ias_charset_types) ?
87180 + ias_charset_types[charset] :
87181 + "(unknown)");
87182
87183 /* Aborting, close connection! */
87184 iriap_disconnect_request(self);
87185 diff --git a/net/iucv/af_iucv.c b/net/iucv/af_iucv.c
87186 index cd6f7a9..e63fe89 100644
87187 --- a/net/iucv/af_iucv.c
87188 +++ b/net/iucv/af_iucv.c
87189 @@ -782,10 +782,10 @@ static int iucv_sock_autobind(struct sock *sk)
87190
87191 write_lock_bh(&iucv_sk_list.lock);
87192
87193 - sprintf(name, "%08x", atomic_inc_return(&iucv_sk_list.autobind_name));
87194 + sprintf(name, "%08x", atomic_inc_return_unchecked(&iucv_sk_list.autobind_name));
87195 while (__iucv_get_sock_by_name(name)) {
87196 sprintf(name, "%08x",
87197 - atomic_inc_return(&iucv_sk_list.autobind_name));
87198 + atomic_inc_return_unchecked(&iucv_sk_list.autobind_name));
87199 }
87200
87201 write_unlock_bh(&iucv_sk_list.lock);
87202 diff --git a/net/iucv/iucv.c b/net/iucv/iucv.c
87203 index df08250..02021fe 100644
87204 --- a/net/iucv/iucv.c
87205 +++ b/net/iucv/iucv.c
87206 @@ -690,7 +690,7 @@ static int __cpuinit iucv_cpu_notify(struct notifier_block *self,
87207 return NOTIFY_OK;
87208 }
87209
87210 -static struct notifier_block __refdata iucv_cpu_notifier = {
87211 +static struct notifier_block iucv_cpu_notifier = {
87212 .notifier_call = iucv_cpu_notify,
87213 };
87214
87215 diff --git a/net/key/af_key.c b/net/key/af_key.c
87216 index 5b426a6..970032b 100644
87217 --- a/net/key/af_key.c
87218 +++ b/net/key/af_key.c
87219 @@ -3019,10 +3019,10 @@ static int pfkey_send_policy_notify(struct xfrm_policy *xp, int dir, const struc
87220 static u32 get_acqseq(void)
87221 {
87222 u32 res;
87223 - static atomic_t acqseq;
87224 + static atomic_unchecked_t acqseq;
87225
87226 do {
87227 - res = atomic_inc_return(&acqseq);
87228 + res = atomic_inc_return_unchecked(&acqseq);
87229 } while (!res);
87230 return res;
87231 }
87232 diff --git a/net/l2tp/l2tp_ppp.c b/net/l2tp/l2tp_ppp.c
87233 index 716605c..044e9e1 100644
87234 --- a/net/l2tp/l2tp_ppp.c
87235 +++ b/net/l2tp/l2tp_ppp.c
87236 @@ -355,6 +355,7 @@ static int pppol2tp_sendmsg(struct kiocb *iocb, struct socket *sock, struct msgh
87237 l2tp_xmit_skb(session, skb, session->hdr_len);
87238
87239 sock_put(ps->tunnel_sock);
87240 + sock_put(sk);
87241
87242 return error;
87243
87244 diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
87245 index 0479c64..d031db6 100644
87246 --- a/net/mac80211/cfg.c
87247 +++ b/net/mac80211/cfg.c
87248 @@ -790,7 +790,7 @@ static int ieee80211_set_monitor_channel(struct wiphy *wiphy,
87249 ret = ieee80211_vif_use_channel(sdata, chandef,
87250 IEEE80211_CHANCTX_EXCLUSIVE);
87251 }
87252 - } else if (local->open_count == local->monitors) {
87253 + } else if (local_read(&local->open_count) == local->monitors) {
87254 local->_oper_channel = chandef->chan;
87255 local->_oper_channel_type = cfg80211_get_chandef_type(chandef);
87256 ieee80211_hw_config(local, 0);
87257 @@ -2716,7 +2716,7 @@ static void ieee80211_mgmt_frame_register(struct wiphy *wiphy,
87258 else
87259 local->probe_req_reg--;
87260
87261 - if (!local->open_count)
87262 + if (!local_read(&local->open_count))
87263 break;
87264
87265 ieee80211_queue_work(&local->hw, &local->reconfig_filter);
87266 diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h
87267 index 2ed065c..948177f 100644
87268 --- a/net/mac80211/ieee80211_i.h
87269 +++ b/net/mac80211/ieee80211_i.h
87270 @@ -28,6 +28,7 @@
87271 #include <net/ieee80211_radiotap.h>
87272 #include <net/cfg80211.h>
87273 #include <net/mac80211.h>
87274 +#include <asm/local.h>
87275 #include "key.h"
87276 #include "sta_info.h"
87277 #include "debug.h"
87278 @@ -909,7 +910,7 @@ struct ieee80211_local {
87279 /* also used to protect ampdu_ac_queue and amdpu_ac_stop_refcnt */
87280 spinlock_t queue_stop_reason_lock;
87281
87282 - int open_count;
87283 + local_t open_count;
87284 int monitors, cooked_mntrs;
87285 /* number of interfaces with corresponding FIF_ flags */
87286 int fif_fcsfail, fif_plcpfail, fif_control, fif_other_bss, fif_pspoll,
87287 diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c
87288 index 8be854e..ad72a69 100644
87289 --- a/net/mac80211/iface.c
87290 +++ b/net/mac80211/iface.c
87291 @@ -546,7 +546,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
87292 break;
87293 }
87294
87295 - if (local->open_count == 0) {
87296 + if (local_read(&local->open_count) == 0) {
87297 res = drv_start(local);
87298 if (res)
87299 goto err_del_bss;
87300 @@ -591,7 +591,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
87301 break;
87302 }
87303
87304 - if (local->monitors == 0 && local->open_count == 0) {
87305 + if (local->monitors == 0 && local_read(&local->open_count) == 0) {
87306 res = ieee80211_add_virtual_monitor(local);
87307 if (res)
87308 goto err_stop;
87309 @@ -699,7 +699,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
87310 mutex_unlock(&local->mtx);
87311
87312 if (coming_up)
87313 - local->open_count++;
87314 + local_inc(&local->open_count);
87315
87316 if (hw_reconf_flags)
87317 ieee80211_hw_config(local, hw_reconf_flags);
87318 @@ -713,7 +713,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
87319 err_del_interface:
87320 drv_remove_interface(local, sdata);
87321 err_stop:
87322 - if (!local->open_count)
87323 + if (!local_read(&local->open_count))
87324 drv_stop(local);
87325 err_del_bss:
87326 sdata->bss = NULL;
87327 @@ -827,7 +827,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
87328 }
87329
87330 if (going_down)
87331 - local->open_count--;
87332 + local_dec(&local->open_count);
87333
87334 switch (sdata->vif.type) {
87335 case NL80211_IFTYPE_AP_VLAN:
87336 @@ -884,7 +884,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
87337
87338 ieee80211_recalc_ps(local, -1);
87339
87340 - if (local->open_count == 0) {
87341 + if (local_read(&local->open_count) == 0) {
87342 if (local->ops->napi_poll)
87343 napi_disable(&local->napi);
87344 ieee80211_clear_tx_pending(local);
87345 @@ -910,7 +910,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
87346 }
87347 spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags);
87348
87349 - if (local->monitors == local->open_count && local->monitors > 0)
87350 + if (local->monitors == local_read(&local->open_count) && local->monitors > 0)
87351 ieee80211_add_virtual_monitor(local);
87352 }
87353
87354 diff --git a/net/mac80211/main.c b/net/mac80211/main.c
87355 index 1b087ff..bf600e9 100644
87356 --- a/net/mac80211/main.c
87357 +++ b/net/mac80211/main.c
87358 @@ -181,7 +181,7 @@ int ieee80211_hw_config(struct ieee80211_local *local, u32 changed)
87359 changed &= ~(IEEE80211_CONF_CHANGE_CHANNEL |
87360 IEEE80211_CONF_CHANGE_POWER);
87361
87362 - if (changed && local->open_count) {
87363 + if (changed && local_read(&local->open_count)) {
87364 ret = drv_config(local, changed);
87365 /*
87366 * Goal:
87367 diff --git a/net/mac80211/pm.c b/net/mac80211/pm.c
87368 index 79a48f3..5e185c9 100644
87369 --- a/net/mac80211/pm.c
87370 +++ b/net/mac80211/pm.c
87371 @@ -35,7 +35,7 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
87372 struct sta_info *sta;
87373 struct ieee80211_chanctx *ctx;
87374
87375 - if (!local->open_count)
87376 + if (!local_read(&local->open_count))
87377 goto suspend;
87378
87379 ieee80211_scan_cancel(local);
87380 @@ -73,7 +73,7 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
87381 cancel_work_sync(&local->dynamic_ps_enable_work);
87382 del_timer_sync(&local->dynamic_ps_timer);
87383
87384 - local->wowlan = wowlan && local->open_count;
87385 + local->wowlan = wowlan && local_read(&local->open_count);
87386 if (local->wowlan) {
87387 int err = drv_suspend(local, wowlan);
87388 if (err < 0) {
87389 @@ -187,7 +187,7 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
87390 mutex_unlock(&local->chanctx_mtx);
87391
87392 /* stop hardware - this must stop RX */
87393 - if (local->open_count)
87394 + if (local_read(&local->open_count))
87395 ieee80211_stop_device(local);
87396
87397 suspend:
87398 diff --git a/net/mac80211/rate.c b/net/mac80211/rate.c
87399 index dd88381..eef4dd6 100644
87400 --- a/net/mac80211/rate.c
87401 +++ b/net/mac80211/rate.c
87402 @@ -493,7 +493,7 @@ int ieee80211_init_rate_ctrl_alg(struct ieee80211_local *local,
87403
87404 ASSERT_RTNL();
87405
87406 - if (local->open_count)
87407 + if (local_read(&local->open_count))
87408 return -EBUSY;
87409
87410 if (local->hw.flags & IEEE80211_HW_HAS_RATE_CONTROL) {
87411 diff --git a/net/mac80211/rc80211_pid_debugfs.c b/net/mac80211/rc80211_pid_debugfs.c
87412 index c97a065..ff61928 100644
87413 --- a/net/mac80211/rc80211_pid_debugfs.c
87414 +++ b/net/mac80211/rc80211_pid_debugfs.c
87415 @@ -193,7 +193,7 @@ static ssize_t rate_control_pid_events_read(struct file *file, char __user *buf,
87416
87417 spin_unlock_irqrestore(&events->lock, status);
87418
87419 - if (copy_to_user(buf, pb, p))
87420 + if (p > sizeof(pb) || copy_to_user(buf, pb, p))
87421 return -EFAULT;
87422
87423 return p;
87424 diff --git a/net/mac80211/util.c b/net/mac80211/util.c
87425 index f11e8c5..08d0013 100644
87426 --- a/net/mac80211/util.c
87427 +++ b/net/mac80211/util.c
87428 @@ -1380,7 +1380,7 @@ int ieee80211_reconfig(struct ieee80211_local *local)
87429 }
87430 #endif
87431 /* everything else happens only if HW was up & running */
87432 - if (!local->open_count)
87433 + if (!local_read(&local->open_count))
87434 goto wake_up;
87435
87436 /*
87437 diff --git a/net/netfilter/Kconfig b/net/netfilter/Kconfig
87438 index 49e96df..63a51c3 100644
87439 --- a/net/netfilter/Kconfig
87440 +++ b/net/netfilter/Kconfig
87441 @@ -936,6 +936,16 @@ config NETFILTER_XT_MATCH_ESP
87442
87443 To compile it as a module, choose M here. If unsure, say N.
87444
87445 +config NETFILTER_XT_MATCH_GRADM
87446 + tristate '"gradm" match support'
87447 + depends on NETFILTER_XTABLES && NETFILTER_ADVANCED
87448 + depends on GRKERNSEC && !GRKERNSEC_NO_RBAC
87449 + ---help---
87450 + The gradm match allows to match on grsecurity RBAC being enabled.
87451 + It is useful when iptables rules are applied early on bootup to
87452 + prevent connections to the machine (except from a trusted host)
87453 + while the RBAC system is disabled.
87454 +
87455 config NETFILTER_XT_MATCH_HASHLIMIT
87456 tristate '"hashlimit" match support'
87457 depends on (IP6_NF_IPTABLES || IP6_NF_IPTABLES=n)
87458 diff --git a/net/netfilter/Makefile b/net/netfilter/Makefile
87459 index 3259697..54d5393 100644
87460 --- a/net/netfilter/Makefile
87461 +++ b/net/netfilter/Makefile
87462 @@ -109,6 +109,7 @@ obj-$(CONFIG_NETFILTER_XT_MATCH_DEVGROUP) += xt_devgroup.o
87463 obj-$(CONFIG_NETFILTER_XT_MATCH_DSCP) += xt_dscp.o
87464 obj-$(CONFIG_NETFILTER_XT_MATCH_ECN) += xt_ecn.o
87465 obj-$(CONFIG_NETFILTER_XT_MATCH_ESP) += xt_esp.o
87466 +obj-$(CONFIG_NETFILTER_XT_MATCH_GRADM) += xt_gradm.o
87467 obj-$(CONFIG_NETFILTER_XT_MATCH_HASHLIMIT) += xt_hashlimit.o
87468 obj-$(CONFIG_NETFILTER_XT_MATCH_HELPER) += xt_helper.o
87469 obj-$(CONFIG_NETFILTER_XT_MATCH_HL) += xt_hl.o
87470 diff --git a/net/netfilter/ipset/ip_set_core.c b/net/netfilter/ipset/ip_set_core.c
87471 index 6d6d8f2..a676749 100644
87472 --- a/net/netfilter/ipset/ip_set_core.c
87473 +++ b/net/netfilter/ipset/ip_set_core.c
87474 @@ -1800,7 +1800,7 @@ done:
87475 return ret;
87476 }
87477
87478 -static struct nf_sockopt_ops so_set __read_mostly = {
87479 +static struct nf_sockopt_ops so_set = {
87480 .pf = PF_INET,
87481 .get_optmin = SO_IP_SET,
87482 .get_optmax = SO_IP_SET + 1,
87483 diff --git a/net/netfilter/ipvs/ip_vs_conn.c b/net/netfilter/ipvs/ip_vs_conn.c
87484 index 30e764a..c3b6a9d 100644
87485 --- a/net/netfilter/ipvs/ip_vs_conn.c
87486 +++ b/net/netfilter/ipvs/ip_vs_conn.c
87487 @@ -554,7 +554,7 @@ ip_vs_bind_dest(struct ip_vs_conn *cp, struct ip_vs_dest *dest)
87488 /* Increase the refcnt counter of the dest */
87489 atomic_inc(&dest->refcnt);
87490
87491 - conn_flags = atomic_read(&dest->conn_flags);
87492 + conn_flags = atomic_read_unchecked(&dest->conn_flags);
87493 if (cp->protocol != IPPROTO_UDP)
87494 conn_flags &= ~IP_VS_CONN_F_ONE_PACKET;
87495 flags = cp->flags;
87496 @@ -899,7 +899,7 @@ ip_vs_conn_new(const struct ip_vs_conn_param *p,
87497 atomic_set(&cp->refcnt, 1);
87498
87499 atomic_set(&cp->n_control, 0);
87500 - atomic_set(&cp->in_pkts, 0);
87501 + atomic_set_unchecked(&cp->in_pkts, 0);
87502
87503 atomic_inc(&ipvs->conn_count);
87504 if (flags & IP_VS_CONN_F_NO_CPORT)
87505 @@ -1180,7 +1180,7 @@ static inline int todrop_entry(struct ip_vs_conn *cp)
87506
87507 /* Don't drop the entry if its number of incoming packets is not
87508 located in [0, 8] */
87509 - i = atomic_read(&cp->in_pkts);
87510 + i = atomic_read_unchecked(&cp->in_pkts);
87511 if (i > 8 || i < 0) return 0;
87512
87513 if (!todrop_rate[i]) return 0;
87514 diff --git a/net/netfilter/ipvs/ip_vs_core.c b/net/netfilter/ipvs/ip_vs_core.c
87515 index 47edf5a..235b07d 100644
87516 --- a/net/netfilter/ipvs/ip_vs_core.c
87517 +++ b/net/netfilter/ipvs/ip_vs_core.c
87518 @@ -559,7 +559,7 @@ int ip_vs_leave(struct ip_vs_service *svc, struct sk_buff *skb,
87519 ret = cp->packet_xmit(skb, cp, pd->pp, iph);
87520 /* do not touch skb anymore */
87521
87522 - atomic_inc(&cp->in_pkts);
87523 + atomic_inc_unchecked(&cp->in_pkts);
87524 ip_vs_conn_put(cp);
87525 return ret;
87526 }
87527 @@ -1691,7 +1691,7 @@ ip_vs_in(unsigned int hooknum, struct sk_buff *skb, int af)
87528 if (cp->flags & IP_VS_CONN_F_ONE_PACKET)
87529 pkts = sysctl_sync_threshold(ipvs);
87530 else
87531 - pkts = atomic_add_return(1, &cp->in_pkts);
87532 + pkts = atomic_add_return_unchecked(1, &cp->in_pkts);
87533
87534 if (ipvs->sync_state & IP_VS_STATE_MASTER)
87535 ip_vs_sync_conn(net, cp, pkts);
87536 diff --git a/net/netfilter/ipvs/ip_vs_ctl.c b/net/netfilter/ipvs/ip_vs_ctl.c
87537 index ec664cb..7f34a77 100644
87538 --- a/net/netfilter/ipvs/ip_vs_ctl.c
87539 +++ b/net/netfilter/ipvs/ip_vs_ctl.c
87540 @@ -787,7 +787,7 @@ __ip_vs_update_dest(struct ip_vs_service *svc, struct ip_vs_dest *dest,
87541 ip_vs_rs_hash(ipvs, dest);
87542 write_unlock_bh(&ipvs->rs_lock);
87543 }
87544 - atomic_set(&dest->conn_flags, conn_flags);
87545 + atomic_set_unchecked(&dest->conn_flags, conn_flags);
87546
87547 /* bind the service */
87548 if (!dest->svc) {
87549 @@ -1688,7 +1688,7 @@ proc_do_sync_ports(ctl_table *table, int write,
87550 * align with netns init in ip_vs_control_net_init()
87551 */
87552
87553 -static struct ctl_table vs_vars[] = {
87554 +static ctl_table_no_const vs_vars[] __read_only = {
87555 {
87556 .procname = "amemthresh",
87557 .maxlen = sizeof(int),
87558 @@ -2081,7 +2081,7 @@ static int ip_vs_info_seq_show(struct seq_file *seq, void *v)
87559 " %-7s %-6d %-10d %-10d\n",
87560 &dest->addr.in6,
87561 ntohs(dest->port),
87562 - ip_vs_fwd_name(atomic_read(&dest->conn_flags)),
87563 + ip_vs_fwd_name(atomic_read_unchecked(&dest->conn_flags)),
87564 atomic_read(&dest->weight),
87565 atomic_read(&dest->activeconns),
87566 atomic_read(&dest->inactconns));
87567 @@ -2092,7 +2092,7 @@ static int ip_vs_info_seq_show(struct seq_file *seq, void *v)
87568 "%-7s %-6d %-10d %-10d\n",
87569 ntohl(dest->addr.ip),
87570 ntohs(dest->port),
87571 - ip_vs_fwd_name(atomic_read(&dest->conn_flags)),
87572 + ip_vs_fwd_name(atomic_read_unchecked(&dest->conn_flags)),
87573 atomic_read(&dest->weight),
87574 atomic_read(&dest->activeconns),
87575 atomic_read(&dest->inactconns));
87576 @@ -2562,7 +2562,7 @@ __ip_vs_get_dest_entries(struct net *net, const struct ip_vs_get_dests *get,
87577
87578 entry.addr = dest->addr.ip;
87579 entry.port = dest->port;
87580 - entry.conn_flags = atomic_read(&dest->conn_flags);
87581 + entry.conn_flags = atomic_read_unchecked(&dest->conn_flags);
87582 entry.weight = atomic_read(&dest->weight);
87583 entry.u_threshold = dest->u_threshold;
87584 entry.l_threshold = dest->l_threshold;
87585 @@ -3098,7 +3098,7 @@ static int ip_vs_genl_fill_dest(struct sk_buff *skb, struct ip_vs_dest *dest)
87586 if (nla_put(skb, IPVS_DEST_ATTR_ADDR, sizeof(dest->addr), &dest->addr) ||
87587 nla_put_u16(skb, IPVS_DEST_ATTR_PORT, dest->port) ||
87588 nla_put_u32(skb, IPVS_DEST_ATTR_FWD_METHOD,
87589 - (atomic_read(&dest->conn_flags) &
87590 + (atomic_read_unchecked(&dest->conn_flags) &
87591 IP_VS_CONN_F_FWD_MASK)) ||
87592 nla_put_u32(skb, IPVS_DEST_ATTR_WEIGHT,
87593 atomic_read(&dest->weight)) ||
87594 @@ -3688,7 +3688,7 @@ static int __net_init ip_vs_control_net_init_sysctl(struct net *net)
87595 {
87596 int idx;
87597 struct netns_ipvs *ipvs = net_ipvs(net);
87598 - struct ctl_table *tbl;
87599 + ctl_table_no_const *tbl;
87600
87601 atomic_set(&ipvs->dropentry, 0);
87602 spin_lock_init(&ipvs->dropentry_lock);
87603 diff --git a/net/netfilter/ipvs/ip_vs_lblc.c b/net/netfilter/ipvs/ip_vs_lblc.c
87604 index fdd89b9..bd96aa9 100644
87605 --- a/net/netfilter/ipvs/ip_vs_lblc.c
87606 +++ b/net/netfilter/ipvs/ip_vs_lblc.c
87607 @@ -115,7 +115,7 @@ struct ip_vs_lblc_table {
87608 * IPVS LBLC sysctl table
87609 */
87610 #ifdef CONFIG_SYSCTL
87611 -static ctl_table vs_vars_table[] = {
87612 +static ctl_table_no_const vs_vars_table[] __read_only = {
87613 {
87614 .procname = "lblc_expiration",
87615 .data = NULL,
87616 diff --git a/net/netfilter/ipvs/ip_vs_lblcr.c b/net/netfilter/ipvs/ip_vs_lblcr.c
87617 index c03b6a3..8ce3681 100644
87618 --- a/net/netfilter/ipvs/ip_vs_lblcr.c
87619 +++ b/net/netfilter/ipvs/ip_vs_lblcr.c
87620 @@ -288,7 +288,7 @@ struct ip_vs_lblcr_table {
87621 * IPVS LBLCR sysctl table
87622 */
87623
87624 -static ctl_table vs_vars_table[] = {
87625 +static ctl_table_no_const vs_vars_table[] __read_only = {
87626 {
87627 .procname = "lblcr_expiration",
87628 .data = NULL,
87629 diff --git a/net/netfilter/ipvs/ip_vs_sync.c b/net/netfilter/ipvs/ip_vs_sync.c
87630 index 44fd10c..2a163b3 100644
87631 --- a/net/netfilter/ipvs/ip_vs_sync.c
87632 +++ b/net/netfilter/ipvs/ip_vs_sync.c
87633 @@ -596,7 +596,7 @@ static void ip_vs_sync_conn_v0(struct net *net, struct ip_vs_conn *cp,
87634 cp = cp->control;
87635 if (cp) {
87636 if (cp->flags & IP_VS_CONN_F_TEMPLATE)
87637 - pkts = atomic_add_return(1, &cp->in_pkts);
87638 + pkts = atomic_add_return_unchecked(1, &cp->in_pkts);
87639 else
87640 pkts = sysctl_sync_threshold(ipvs);
87641 ip_vs_sync_conn(net, cp->control, pkts);
87642 @@ -758,7 +758,7 @@ control:
87643 if (!cp)
87644 return;
87645 if (cp->flags & IP_VS_CONN_F_TEMPLATE)
87646 - pkts = atomic_add_return(1, &cp->in_pkts);
87647 + pkts = atomic_add_return_unchecked(1, &cp->in_pkts);
87648 else
87649 pkts = sysctl_sync_threshold(ipvs);
87650 goto sloop;
87651 @@ -885,7 +885,7 @@ static void ip_vs_proc_conn(struct net *net, struct ip_vs_conn_param *param,
87652
87653 if (opt)
87654 memcpy(&cp->in_seq, opt, sizeof(*opt));
87655 - atomic_set(&cp->in_pkts, sysctl_sync_threshold(ipvs));
87656 + atomic_set_unchecked(&cp->in_pkts, sysctl_sync_threshold(ipvs));
87657 cp->state = state;
87658 cp->old_state = cp->state;
87659 /*
87660 diff --git a/net/netfilter/ipvs/ip_vs_xmit.c b/net/netfilter/ipvs/ip_vs_xmit.c
87661 index ee6b7a9..f9a89f6 100644
87662 --- a/net/netfilter/ipvs/ip_vs_xmit.c
87663 +++ b/net/netfilter/ipvs/ip_vs_xmit.c
87664 @@ -1210,7 +1210,7 @@ ip_vs_icmp_xmit(struct sk_buff *skb, struct ip_vs_conn *cp,
87665 else
87666 rc = NF_ACCEPT;
87667 /* do not touch skb anymore */
87668 - atomic_inc(&cp->in_pkts);
87669 + atomic_inc_unchecked(&cp->in_pkts);
87670 goto out;
87671 }
87672
87673 @@ -1332,7 +1332,7 @@ ip_vs_icmp_xmit_v6(struct sk_buff *skb, struct ip_vs_conn *cp,
87674 else
87675 rc = NF_ACCEPT;
87676 /* do not touch skb anymore */
87677 - atomic_inc(&cp->in_pkts);
87678 + atomic_inc_unchecked(&cp->in_pkts);
87679 goto out;
87680 }
87681
87682 diff --git a/net/netfilter/nf_conntrack_acct.c b/net/netfilter/nf_conntrack_acct.c
87683 index 7df424e..a527b02 100644
87684 --- a/net/netfilter/nf_conntrack_acct.c
87685 +++ b/net/netfilter/nf_conntrack_acct.c
87686 @@ -60,7 +60,7 @@ static struct nf_ct_ext_type acct_extend __read_mostly = {
87687 #ifdef CONFIG_SYSCTL
87688 static int nf_conntrack_acct_init_sysctl(struct net *net)
87689 {
87690 - struct ctl_table *table;
87691 + ctl_table_no_const *table;
87692
87693 table = kmemdup(acct_sysctl_table, sizeof(acct_sysctl_table),
87694 GFP_KERNEL);
87695 diff --git a/net/netfilter/nf_conntrack_core.c b/net/netfilter/nf_conntrack_core.c
87696 index e4a0c4f..c263f28 100644
87697 --- a/net/netfilter/nf_conntrack_core.c
87698 +++ b/net/netfilter/nf_conntrack_core.c
87699 @@ -1529,6 +1529,10 @@ err_extend:
87700 #define DYING_NULLS_VAL ((1<<30)+1)
87701 #define TEMPLATE_NULLS_VAL ((1<<30)+2)
87702
87703 +#ifdef CONFIG_GRKERNSEC_HIDESYM
87704 +static atomic_unchecked_t conntrack_cache_id = ATOMIC_INIT(0);
87705 +#endif
87706 +
87707 static int nf_conntrack_init_net(struct net *net)
87708 {
87709 int ret;
87710 @@ -1543,7 +1547,11 @@ static int nf_conntrack_init_net(struct net *net)
87711 goto err_stat;
87712 }
87713
87714 +#ifdef CONFIG_GRKERNSEC_HIDESYM
87715 + net->ct.slabname = kasprintf(GFP_KERNEL, "nf_conntrack_%08lx", atomic_inc_return_unchecked(&conntrack_cache_id));
87716 +#else
87717 net->ct.slabname = kasprintf(GFP_KERNEL, "nf_conntrack_%p", net);
87718 +#endif
87719 if (!net->ct.slabname) {
87720 ret = -ENOMEM;
87721 goto err_slabname;
87722 diff --git a/net/netfilter/nf_conntrack_ecache.c b/net/netfilter/nf_conntrack_ecache.c
87723 index faa978f..1afb18f 100644
87724 --- a/net/netfilter/nf_conntrack_ecache.c
87725 +++ b/net/netfilter/nf_conntrack_ecache.c
87726 @@ -186,7 +186,7 @@ static struct nf_ct_ext_type event_extend __read_mostly = {
87727 #ifdef CONFIG_SYSCTL
87728 static int nf_conntrack_event_init_sysctl(struct net *net)
87729 {
87730 - struct ctl_table *table;
87731 + ctl_table_no_const *table;
87732
87733 table = kmemdup(event_sysctl_table, sizeof(event_sysctl_table),
87734 GFP_KERNEL);
87735 diff --git a/net/netfilter/nf_conntrack_helper.c b/net/netfilter/nf_conntrack_helper.c
87736 index 884f2b3..d53b33a 100644
87737 --- a/net/netfilter/nf_conntrack_helper.c
87738 +++ b/net/netfilter/nf_conntrack_helper.c
87739 @@ -55,7 +55,7 @@ static struct ctl_table helper_sysctl_table[] = {
87740
87741 static int nf_conntrack_helper_init_sysctl(struct net *net)
87742 {
87743 - struct ctl_table *table;
87744 + ctl_table_no_const *table;
87745
87746 table = kmemdup(helper_sysctl_table, sizeof(helper_sysctl_table),
87747 GFP_KERNEL);
87748 diff --git a/net/netfilter/nf_conntrack_proto.c b/net/netfilter/nf_conntrack_proto.c
87749 index 51e928d..72a413a 100644
87750 --- a/net/netfilter/nf_conntrack_proto.c
87751 +++ b/net/netfilter/nf_conntrack_proto.c
87752 @@ -51,7 +51,7 @@ nf_ct_register_sysctl(struct net *net,
87753
87754 static void
87755 nf_ct_unregister_sysctl(struct ctl_table_header **header,
87756 - struct ctl_table **table,
87757 + ctl_table_no_const **table,
87758 unsigned int users)
87759 {
87760 if (users > 0)
87761 diff --git a/net/netfilter/nf_conntrack_standalone.c b/net/netfilter/nf_conntrack_standalone.c
87762 index e7185c6..4ad6c9c 100644
87763 --- a/net/netfilter/nf_conntrack_standalone.c
87764 +++ b/net/netfilter/nf_conntrack_standalone.c
87765 @@ -470,7 +470,7 @@ static ctl_table nf_ct_netfilter_table[] = {
87766
87767 static int nf_conntrack_standalone_init_sysctl(struct net *net)
87768 {
87769 - struct ctl_table *table;
87770 + ctl_table_no_const *table;
87771
87772 if (net_eq(net, &init_net)) {
87773 nf_ct_netfilter_header =
87774 diff --git a/net/netfilter/nf_conntrack_timestamp.c b/net/netfilter/nf_conntrack_timestamp.c
87775 index 7ea8026..bc9512d 100644
87776 --- a/net/netfilter/nf_conntrack_timestamp.c
87777 +++ b/net/netfilter/nf_conntrack_timestamp.c
87778 @@ -42,7 +42,7 @@ static struct nf_ct_ext_type tstamp_extend __read_mostly = {
87779 #ifdef CONFIG_SYSCTL
87780 static int nf_conntrack_tstamp_init_sysctl(struct net *net)
87781 {
87782 - struct ctl_table *table;
87783 + ctl_table_no_const *table;
87784
87785 table = kmemdup(tstamp_sysctl_table, sizeof(tstamp_sysctl_table),
87786 GFP_KERNEL);
87787 diff --git a/net/netfilter/nf_log.c b/net/netfilter/nf_log.c
87788 index 9e31269..bc4c1b7 100644
87789 --- a/net/netfilter/nf_log.c
87790 +++ b/net/netfilter/nf_log.c
87791 @@ -215,7 +215,7 @@ static const struct file_operations nflog_file_ops = {
87792
87793 #ifdef CONFIG_SYSCTL
87794 static char nf_log_sysctl_fnames[NFPROTO_NUMPROTO-NFPROTO_UNSPEC][3];
87795 -static struct ctl_table nf_log_sysctl_table[NFPROTO_NUMPROTO+1];
87796 +static ctl_table_no_const nf_log_sysctl_table[NFPROTO_NUMPROTO+1] __read_only;
87797 static struct ctl_table_header *nf_log_dir_header;
87798
87799 static int nf_log_proc_dostring(ctl_table *table, int write,
87800 @@ -246,14 +246,16 @@ static int nf_log_proc_dostring(ctl_table *table, int write,
87801 rcu_assign_pointer(nf_loggers[tindex], logger);
87802 mutex_unlock(&nf_log_mutex);
87803 } else {
87804 + ctl_table_no_const nf_log_table = *table;
87805 +
87806 mutex_lock(&nf_log_mutex);
87807 logger = rcu_dereference_protected(nf_loggers[tindex],
87808 lockdep_is_held(&nf_log_mutex));
87809 if (!logger)
87810 - table->data = "NONE";
87811 + nf_log_table.data = "NONE";
87812 else
87813 - table->data = logger->name;
87814 - r = proc_dostring(table, write, buffer, lenp, ppos);
87815 + nf_log_table.data = logger->name;
87816 + r = proc_dostring(&nf_log_table, write, buffer, lenp, ppos);
87817 mutex_unlock(&nf_log_mutex);
87818 }
87819
87820 diff --git a/net/netfilter/nf_sockopt.c b/net/netfilter/nf_sockopt.c
87821 index f042ae5..30ea486 100644
87822 --- a/net/netfilter/nf_sockopt.c
87823 +++ b/net/netfilter/nf_sockopt.c
87824 @@ -45,7 +45,7 @@ int nf_register_sockopt(struct nf_sockopt_ops *reg)
87825 }
87826 }
87827
87828 - list_add(&reg->list, &nf_sockopts);
87829 + pax_list_add((struct list_head *)&reg->list, &nf_sockopts);
87830 out:
87831 mutex_unlock(&nf_sockopt_mutex);
87832 return ret;
87833 @@ -55,7 +55,7 @@ EXPORT_SYMBOL(nf_register_sockopt);
87834 void nf_unregister_sockopt(struct nf_sockopt_ops *reg)
87835 {
87836 mutex_lock(&nf_sockopt_mutex);
87837 - list_del(&reg->list);
87838 + pax_list_del((struct list_head *)&reg->list);
87839 mutex_unlock(&nf_sockopt_mutex);
87840 }
87841 EXPORT_SYMBOL(nf_unregister_sockopt);
87842 diff --git a/net/netfilter/nfnetlink_log.c b/net/netfilter/nfnetlink_log.c
87843 index 92fd8ec..3f6ea4b 100644
87844 --- a/net/netfilter/nfnetlink_log.c
87845 +++ b/net/netfilter/nfnetlink_log.c
87846 @@ -72,7 +72,7 @@ struct nfulnl_instance {
87847 };
87848
87849 static DEFINE_SPINLOCK(instances_lock);
87850 -static atomic_t global_seq;
87851 +static atomic_unchecked_t global_seq;
87852
87853 #define INSTANCE_BUCKETS 16
87854 static struct hlist_head instance_table[INSTANCE_BUCKETS];
87855 @@ -537,7 +537,7 @@ __build_packet_message(struct nfulnl_instance *inst,
87856 /* global sequence number */
87857 if ((inst->flags & NFULNL_CFG_F_SEQ_GLOBAL) &&
87858 nla_put_be32(inst->skb, NFULA_SEQ_GLOBAL,
87859 - htonl(atomic_inc_return(&global_seq))))
87860 + htonl(atomic_inc_return_unchecked(&global_seq))))
87861 goto nla_put_failure;
87862
87863 if (data_len) {
87864 diff --git a/net/netfilter/xt_gradm.c b/net/netfilter/xt_gradm.c
87865 new file mode 100644
87866 index 0000000..c566332
87867 --- /dev/null
87868 +++ b/net/netfilter/xt_gradm.c
87869 @@ -0,0 +1,51 @@
87870 +/*
87871 + * gradm match for netfilter
87872 + * Copyright © Zbigniew Krzystolik, 2010
87873 + *
87874 + * This program is free software; you can redistribute it and/or modify
87875 + * it under the terms of the GNU General Public License; either version
87876 + * 2 or 3 as published by the Free Software Foundation.
87877 + */
87878 +#include <linux/module.h>
87879 +#include <linux/moduleparam.h>
87880 +#include <linux/skbuff.h>
87881 +#include <linux/netfilter/x_tables.h>
87882 +#include <linux/grsecurity.h>
87883 +#include <linux/netfilter/xt_gradm.h>
87884 +
87885 +static bool
87886 +gradm_mt(const struct sk_buff *skb, struct xt_action_param *par)
87887 +{
87888 + const struct xt_gradm_mtinfo *info = par->matchinfo;
87889 + bool retval = false;
87890 + if (gr_acl_is_enabled())
87891 + retval = true;
87892 + return retval ^ info->invflags;
87893 +}
87894 +
87895 +static struct xt_match gradm_mt_reg __read_mostly = {
87896 + .name = "gradm",
87897 + .revision = 0,
87898 + .family = NFPROTO_UNSPEC,
87899 + .match = gradm_mt,
87900 + .matchsize = XT_ALIGN(sizeof(struct xt_gradm_mtinfo)),
87901 + .me = THIS_MODULE,
87902 +};
87903 +
87904 +static int __init gradm_mt_init(void)
87905 +{
87906 + return xt_register_match(&gradm_mt_reg);
87907 +}
87908 +
87909 +static void __exit gradm_mt_exit(void)
87910 +{
87911 + xt_unregister_match(&gradm_mt_reg);
87912 +}
87913 +
87914 +module_init(gradm_mt_init);
87915 +module_exit(gradm_mt_exit);
87916 +MODULE_AUTHOR("Zbigniew Krzystolik <zbyniu@destrukcja.pl>");
87917 +MODULE_DESCRIPTION("Xtables: Grsecurity RBAC match");
87918 +MODULE_LICENSE("GPL");
87919 +MODULE_ALIAS("ipt_gradm");
87920 +MODULE_ALIAS("ip6t_gradm");
87921 diff --git a/net/netfilter/xt_statistic.c b/net/netfilter/xt_statistic.c
87922 index 4fe4fb4..87a89e5 100644
87923 --- a/net/netfilter/xt_statistic.c
87924 +++ b/net/netfilter/xt_statistic.c
87925 @@ -19,7 +19,7 @@
87926 #include <linux/module.h>
87927
87928 struct xt_statistic_priv {
87929 - atomic_t count;
87930 + atomic_unchecked_t count;
87931 } ____cacheline_aligned_in_smp;
87932
87933 MODULE_LICENSE("GPL");
87934 @@ -42,9 +42,9 @@ statistic_mt(const struct sk_buff *skb, struct xt_action_param *par)
87935 break;
87936 case XT_STATISTIC_MODE_NTH:
87937 do {
87938 - oval = atomic_read(&info->master->count);
87939 + oval = atomic_read_unchecked(&info->master->count);
87940 nval = (oval == info->u.nth.every) ? 0 : oval + 1;
87941 - } while (atomic_cmpxchg(&info->master->count, oval, nval) != oval);
87942 + } while (atomic_cmpxchg_unchecked(&info->master->count, oval, nval) != oval);
87943 if (nval == 0)
87944 ret = !ret;
87945 break;
87946 @@ -64,7 +64,7 @@ static int statistic_mt_check(const struct xt_mtchk_param *par)
87947 info->master = kzalloc(sizeof(*info->master), GFP_KERNEL);
87948 if (info->master == NULL)
87949 return -ENOMEM;
87950 - atomic_set(&info->master->count, info->u.nth.count);
87951 + atomic_set_unchecked(&info->master->count, info->u.nth.count);
87952
87953 return 0;
87954 }
87955 diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
87956 index c0353d5..fcb0270 100644
87957 --- a/net/netlink/af_netlink.c
87958 +++ b/net/netlink/af_netlink.c
87959 @@ -785,7 +785,7 @@ static void netlink_overrun(struct sock *sk)
87960 sk->sk_error_report(sk);
87961 }
87962 }
87963 - atomic_inc(&sk->sk_drops);
87964 + atomic_inc_unchecked(&sk->sk_drops);
87965 }
87966
87967 static struct sock *netlink_getsockbyportid(struct sock *ssk, u32 portid)
87968 @@ -2071,7 +2071,7 @@ static int netlink_seq_show(struct seq_file *seq, void *v)
87969 sk_wmem_alloc_get(s),
87970 nlk->cb,
87971 atomic_read(&s->sk_refcnt),
87972 - atomic_read(&s->sk_drops),
87973 + atomic_read_unchecked(&s->sk_drops),
87974 sock_i_ino(s)
87975 );
87976
87977 diff --git a/net/netlink/genetlink.c b/net/netlink/genetlink.c
87978 index f2aabb6..2e5e66e 100644
87979 --- a/net/netlink/genetlink.c
87980 +++ b/net/netlink/genetlink.c
87981 @@ -295,18 +295,20 @@ int genl_register_ops(struct genl_family *family, struct genl_ops *ops)
87982 goto errout;
87983 }
87984
87985 + pax_open_kernel();
87986 if (ops->dumpit)
87987 - ops->flags |= GENL_CMD_CAP_DUMP;
87988 + *(unsigned int *)&ops->flags |= GENL_CMD_CAP_DUMP;
87989 if (ops->doit)
87990 - ops->flags |= GENL_CMD_CAP_DO;
87991 + *(unsigned int *)&ops->flags |= GENL_CMD_CAP_DO;
87992 if (ops->policy)
87993 - ops->flags |= GENL_CMD_CAP_HASPOL;
87994 + *(unsigned int *)&ops->flags |= GENL_CMD_CAP_HASPOL;
87995 + pax_close_kernel();
87996
87997 genl_lock();
87998 - list_add_tail(&ops->ops_list, &family->ops_list);
87999 + pax_list_add_tail((struct list_head *)&ops->ops_list, &family->ops_list);
88000 genl_unlock();
88001
88002 - genl_ctrl_event(CTRL_CMD_NEWOPS, ops);
88003 + genl_ctrl_event(CTRL_CMD_NEWOPS, (void *)ops);
88004 err = 0;
88005 errout:
88006 return err;
88007 @@ -336,9 +338,9 @@ int genl_unregister_ops(struct genl_family *family, struct genl_ops *ops)
88008 genl_lock();
88009 list_for_each_entry(rc, &family->ops_list, ops_list) {
88010 if (rc == ops) {
88011 - list_del(&ops->ops_list);
88012 + pax_list_del((struct list_head *)&ops->ops_list);
88013 genl_unlock();
88014 - genl_ctrl_event(CTRL_CMD_DELOPS, ops);
88015 + genl_ctrl_event(CTRL_CMD_DELOPS, (void *)ops);
88016 return 0;
88017 }
88018 }
88019 diff --git a/net/netrom/af_netrom.c b/net/netrom/af_netrom.c
88020 index 7261eb8..44e8ac6 100644
88021 --- a/net/netrom/af_netrom.c
88022 +++ b/net/netrom/af_netrom.c
88023 @@ -838,6 +838,7 @@ static int nr_getname(struct socket *sock, struct sockaddr *uaddr,
88024 struct sock *sk = sock->sk;
88025 struct nr_sock *nr = nr_sk(sk);
88026
88027 + memset(sax, 0, sizeof(*sax));
88028 lock_sock(sk);
88029 if (peer != 0) {
88030 if (sk->sk_state != TCP_ESTABLISHED) {
88031 @@ -852,7 +853,6 @@ static int nr_getname(struct socket *sock, struct sockaddr *uaddr,
88032 *uaddr_len = sizeof(struct full_sockaddr_ax25);
88033 } else {
88034 sax->fsa_ax25.sax25_family = AF_NETROM;
88035 - sax->fsa_ax25.sax25_ndigis = 0;
88036 sax->fsa_ax25.sax25_call = nr->source_addr;
88037 *uaddr_len = sizeof(struct sockaddr_ax25);
88038 }
88039 diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
88040 index c111bd0..7788ff7 100644
88041 --- a/net/packet/af_packet.c
88042 +++ b/net/packet/af_packet.c
88043 @@ -1578,7 +1578,7 @@ static int packet_rcv(struct sk_buff *skb, struct net_device *dev,
88044
88045 spin_lock(&sk->sk_receive_queue.lock);
88046 po->stats.tp_packets++;
88047 - skb->dropcount = atomic_read(&sk->sk_drops);
88048 + skb->dropcount = atomic_read_unchecked(&sk->sk_drops);
88049 __skb_queue_tail(&sk->sk_receive_queue, skb);
88050 spin_unlock(&sk->sk_receive_queue.lock);
88051 sk->sk_data_ready(sk, skb->len);
88052 @@ -1587,7 +1587,7 @@ static int packet_rcv(struct sk_buff *skb, struct net_device *dev,
88053 drop_n_acct:
88054 spin_lock(&sk->sk_receive_queue.lock);
88055 po->stats.tp_drops++;
88056 - atomic_inc(&sk->sk_drops);
88057 + atomic_inc_unchecked(&sk->sk_drops);
88058 spin_unlock(&sk->sk_receive_queue.lock);
88059
88060 drop_n_restore:
88061 @@ -2565,6 +2565,7 @@ out:
88062
88063 static int packet_recv_error(struct sock *sk, struct msghdr *msg, int len)
88064 {
88065 + struct sock_extended_err ee;
88066 struct sock_exterr_skb *serr;
88067 struct sk_buff *skb, *skb2;
88068 int copied, err;
88069 @@ -2586,8 +2587,9 @@ static int packet_recv_error(struct sock *sk, struct msghdr *msg, int len)
88070 sock_recv_timestamp(msg, sk, skb);
88071
88072 serr = SKB_EXT_ERR(skb);
88073 + ee = serr->ee;
88074 put_cmsg(msg, SOL_PACKET, PACKET_TX_TIMESTAMP,
88075 - sizeof(serr->ee), &serr->ee);
88076 + sizeof ee, &ee);
88077
88078 msg->msg_flags |= MSG_ERRQUEUE;
88079 err = copied;
88080 @@ -3212,7 +3214,7 @@ static int packet_getsockopt(struct socket *sock, int level, int optname,
88081 case PACKET_HDRLEN:
88082 if (len > sizeof(int))
88083 len = sizeof(int);
88084 - if (copy_from_user(&val, optval, len))
88085 + if (len > sizeof(val) || copy_from_user(&val, optval, len))
88086 return -EFAULT;
88087 switch (val) {
88088 case TPACKET_V1:
88089 @@ -3254,7 +3256,7 @@ static int packet_getsockopt(struct socket *sock, int level, int optname,
88090 len = lv;
88091 if (put_user(len, optlen))
88092 return -EFAULT;
88093 - if (copy_to_user(optval, data, len))
88094 + if (len > sizeof(st) || copy_to_user(optval, data, len))
88095 return -EFAULT;
88096 return 0;
88097 }
88098 diff --git a/net/phonet/af_phonet.c b/net/phonet/af_phonet.c
88099 index 5a940db..f0b9c12 100644
88100 --- a/net/phonet/af_phonet.c
88101 +++ b/net/phonet/af_phonet.c
88102 @@ -41,7 +41,7 @@ static struct phonet_protocol *phonet_proto_get(unsigned int protocol)
88103 {
88104 struct phonet_protocol *pp;
88105
88106 - if (protocol >= PHONET_NPROTO)
88107 + if (protocol < 0 || protocol >= PHONET_NPROTO)
88108 return NULL;
88109
88110 rcu_read_lock();
88111 @@ -469,7 +469,7 @@ int __init_or_module phonet_proto_register(unsigned int protocol,
88112 {
88113 int err = 0;
88114
88115 - if (protocol >= PHONET_NPROTO)
88116 + if (protocol < 0 || protocol >= PHONET_NPROTO)
88117 return -EINVAL;
88118
88119 err = proto_register(pp->prot, 1);
88120 diff --git a/net/phonet/pep.c b/net/phonet/pep.c
88121 index 576f22c..bc7a71b 100644
88122 --- a/net/phonet/pep.c
88123 +++ b/net/phonet/pep.c
88124 @@ -388,7 +388,7 @@ static int pipe_do_rcv(struct sock *sk, struct sk_buff *skb)
88125
88126 case PNS_PEP_CTRL_REQ:
88127 if (skb_queue_len(&pn->ctrlreq_queue) >= PNPIPE_CTRLREQ_MAX) {
88128 - atomic_inc(&sk->sk_drops);
88129 + atomic_inc_unchecked(&sk->sk_drops);
88130 break;
88131 }
88132 __skb_pull(skb, 4);
88133 @@ -409,7 +409,7 @@ static int pipe_do_rcv(struct sock *sk, struct sk_buff *skb)
88134 }
88135
88136 if (pn->rx_credits == 0) {
88137 - atomic_inc(&sk->sk_drops);
88138 + atomic_inc_unchecked(&sk->sk_drops);
88139 err = -ENOBUFS;
88140 break;
88141 }
88142 @@ -580,7 +580,7 @@ static int pipe_handler_do_rcv(struct sock *sk, struct sk_buff *skb)
88143 }
88144
88145 if (pn->rx_credits == 0) {
88146 - atomic_inc(&sk->sk_drops);
88147 + atomic_inc_unchecked(&sk->sk_drops);
88148 err = NET_RX_DROP;
88149 break;
88150 }
88151 diff --git a/net/phonet/socket.c b/net/phonet/socket.c
88152 index b7e9827..c264c85 100644
88153 --- a/net/phonet/socket.c
88154 +++ b/net/phonet/socket.c
88155 @@ -615,7 +615,7 @@ static int pn_sock_seq_show(struct seq_file *seq, void *v)
88156 from_kuid_munged(seq_user_ns(seq), sock_i_uid(sk)),
88157 sock_i_ino(sk),
88158 atomic_read(&sk->sk_refcnt), sk,
88159 - atomic_read(&sk->sk_drops), &len);
88160 + atomic_read_unchecked(&sk->sk_drops), &len);
88161 }
88162 seq_printf(seq, "%*s\n", 127 - len, "");
88163 return 0;
88164 diff --git a/net/phonet/sysctl.c b/net/phonet/sysctl.c
88165 index d6bbbbd..61561e4 100644
88166 --- a/net/phonet/sysctl.c
88167 +++ b/net/phonet/sysctl.c
88168 @@ -67,7 +67,7 @@ static int proc_local_port_range(ctl_table *table, int write,
88169 {
88170 int ret;
88171 int range[2] = {local_port_range[0], local_port_range[1]};
88172 - ctl_table tmp = {
88173 + ctl_table_no_const tmp = {
88174 .data = &range,
88175 .maxlen = sizeof(range),
88176 .mode = table->mode,
88177 diff --git a/net/rds/cong.c b/net/rds/cong.c
88178 index e5b65ac..f3b6fb7 100644
88179 --- a/net/rds/cong.c
88180 +++ b/net/rds/cong.c
88181 @@ -78,7 +78,7 @@
88182 * finds that the saved generation number is smaller than the global generation
88183 * number, it wakes up the process.
88184 */
88185 -static atomic_t rds_cong_generation = ATOMIC_INIT(0);
88186 +static atomic_unchecked_t rds_cong_generation = ATOMIC_INIT(0);
88187
88188 /*
88189 * Congestion monitoring
88190 @@ -233,7 +233,7 @@ void rds_cong_map_updated(struct rds_cong_map *map, uint64_t portmask)
88191 rdsdebug("waking map %p for %pI4\n",
88192 map, &map->m_addr);
88193 rds_stats_inc(s_cong_update_received);
88194 - atomic_inc(&rds_cong_generation);
88195 + atomic_inc_unchecked(&rds_cong_generation);
88196 if (waitqueue_active(&map->m_waitq))
88197 wake_up(&map->m_waitq);
88198 if (waitqueue_active(&rds_poll_waitq))
88199 @@ -259,7 +259,7 @@ EXPORT_SYMBOL_GPL(rds_cong_map_updated);
88200
88201 int rds_cong_updated_since(unsigned long *recent)
88202 {
88203 - unsigned long gen = atomic_read(&rds_cong_generation);
88204 + unsigned long gen = atomic_read_unchecked(&rds_cong_generation);
88205
88206 if (likely(*recent == gen))
88207 return 0;
88208 diff --git a/net/rds/ib.h b/net/rds/ib.h
88209 index 7280ab8..e04f4ea 100644
88210 --- a/net/rds/ib.h
88211 +++ b/net/rds/ib.h
88212 @@ -128,7 +128,7 @@ struct rds_ib_connection {
88213 /* sending acks */
88214 unsigned long i_ack_flags;
88215 #ifdef KERNEL_HAS_ATOMIC64
88216 - atomic64_t i_ack_next; /* next ACK to send */
88217 + atomic64_unchecked_t i_ack_next; /* next ACK to send */
88218 #else
88219 spinlock_t i_ack_lock; /* protect i_ack_next */
88220 u64 i_ack_next; /* next ACK to send */
88221 diff --git a/net/rds/ib_cm.c b/net/rds/ib_cm.c
88222 index 31b74f5..dc1fbfa 100644
88223 --- a/net/rds/ib_cm.c
88224 +++ b/net/rds/ib_cm.c
88225 @@ -717,7 +717,7 @@ void rds_ib_conn_shutdown(struct rds_connection *conn)
88226 /* Clear the ACK state */
88227 clear_bit(IB_ACK_IN_FLIGHT, &ic->i_ack_flags);
88228 #ifdef KERNEL_HAS_ATOMIC64
88229 - atomic64_set(&ic->i_ack_next, 0);
88230 + atomic64_set_unchecked(&ic->i_ack_next, 0);
88231 #else
88232 ic->i_ack_next = 0;
88233 #endif
88234 diff --git a/net/rds/ib_recv.c b/net/rds/ib_recv.c
88235 index 8eb9501..0c386ff 100644
88236 --- a/net/rds/ib_recv.c
88237 +++ b/net/rds/ib_recv.c
88238 @@ -597,7 +597,7 @@ static u64 rds_ib_get_ack(struct rds_ib_connection *ic)
88239 static void rds_ib_set_ack(struct rds_ib_connection *ic, u64 seq,
88240 int ack_required)
88241 {
88242 - atomic64_set(&ic->i_ack_next, seq);
88243 + atomic64_set_unchecked(&ic->i_ack_next, seq);
88244 if (ack_required) {
88245 smp_mb__before_clear_bit();
88246 set_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
88247 @@ -609,7 +609,7 @@ static u64 rds_ib_get_ack(struct rds_ib_connection *ic)
88248 clear_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
88249 smp_mb__after_clear_bit();
88250
88251 - return atomic64_read(&ic->i_ack_next);
88252 + return atomic64_read_unchecked(&ic->i_ack_next);
88253 }
88254 #endif
88255
88256 diff --git a/net/rds/iw.h b/net/rds/iw.h
88257 index 04ce3b1..48119a6 100644
88258 --- a/net/rds/iw.h
88259 +++ b/net/rds/iw.h
88260 @@ -134,7 +134,7 @@ struct rds_iw_connection {
88261 /* sending acks */
88262 unsigned long i_ack_flags;
88263 #ifdef KERNEL_HAS_ATOMIC64
88264 - atomic64_t i_ack_next; /* next ACK to send */
88265 + atomic64_unchecked_t i_ack_next; /* next ACK to send */
88266 #else
88267 spinlock_t i_ack_lock; /* protect i_ack_next */
88268 u64 i_ack_next; /* next ACK to send */
88269 diff --git a/net/rds/iw_cm.c b/net/rds/iw_cm.c
88270 index a91e1db..cf3053f 100644
88271 --- a/net/rds/iw_cm.c
88272 +++ b/net/rds/iw_cm.c
88273 @@ -663,7 +663,7 @@ void rds_iw_conn_shutdown(struct rds_connection *conn)
88274 /* Clear the ACK state */
88275 clear_bit(IB_ACK_IN_FLIGHT, &ic->i_ack_flags);
88276 #ifdef KERNEL_HAS_ATOMIC64
88277 - atomic64_set(&ic->i_ack_next, 0);
88278 + atomic64_set_unchecked(&ic->i_ack_next, 0);
88279 #else
88280 ic->i_ack_next = 0;
88281 #endif
88282 diff --git a/net/rds/iw_recv.c b/net/rds/iw_recv.c
88283 index 4503335..db566b4 100644
88284 --- a/net/rds/iw_recv.c
88285 +++ b/net/rds/iw_recv.c
88286 @@ -427,7 +427,7 @@ static u64 rds_iw_get_ack(struct rds_iw_connection *ic)
88287 static void rds_iw_set_ack(struct rds_iw_connection *ic, u64 seq,
88288 int ack_required)
88289 {
88290 - atomic64_set(&ic->i_ack_next, seq);
88291 + atomic64_set_unchecked(&ic->i_ack_next, seq);
88292 if (ack_required) {
88293 smp_mb__before_clear_bit();
88294 set_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
88295 @@ -439,7 +439,7 @@ static u64 rds_iw_get_ack(struct rds_iw_connection *ic)
88296 clear_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
88297 smp_mb__after_clear_bit();
88298
88299 - return atomic64_read(&ic->i_ack_next);
88300 + return atomic64_read_unchecked(&ic->i_ack_next);
88301 }
88302 #endif
88303
88304 diff --git a/net/rds/message.c b/net/rds/message.c
88305 index f0a4658..aff589c 100644
88306 --- a/net/rds/message.c
88307 +++ b/net/rds/message.c
88308 @@ -197,6 +197,9 @@ struct rds_message *rds_message_alloc(unsigned int extra_len, gfp_t gfp)
88309 {
88310 struct rds_message *rm;
88311
88312 + if (extra_len > KMALLOC_MAX_SIZE - sizeof(struct rds_message))
88313 + return NULL;
88314 +
88315 rm = kzalloc(sizeof(struct rds_message) + extra_len, gfp);
88316 if (!rm)
88317 goto out;
88318 diff --git a/net/rds/rds.h b/net/rds/rds.h
88319 index ec1d731..90a3a8d 100644
88320 --- a/net/rds/rds.h
88321 +++ b/net/rds/rds.h
88322 @@ -449,7 +449,7 @@ struct rds_transport {
88323 void (*sync_mr)(void *trans_private, int direction);
88324 void (*free_mr)(void *trans_private, int invalidate);
88325 void (*flush_mrs)(void);
88326 -};
88327 +} __do_const;
88328
88329 struct rds_sock {
88330 struct sock rs_sk;
88331 diff --git a/net/rds/tcp.c b/net/rds/tcp.c
88332 index edac9ef..16bcb98 100644
88333 --- a/net/rds/tcp.c
88334 +++ b/net/rds/tcp.c
88335 @@ -59,7 +59,7 @@ void rds_tcp_nonagle(struct socket *sock)
88336 int val = 1;
88337
88338 set_fs(KERNEL_DS);
88339 - sock->ops->setsockopt(sock, SOL_TCP, TCP_NODELAY, (char __user *)&val,
88340 + sock->ops->setsockopt(sock, SOL_TCP, TCP_NODELAY, (char __force_user *)&val,
88341 sizeof(val));
88342 set_fs(oldfs);
88343 }
88344 diff --git a/net/rds/tcp_send.c b/net/rds/tcp_send.c
88345 index 81cf5a4..b5826ff 100644
88346 --- a/net/rds/tcp_send.c
88347 +++ b/net/rds/tcp_send.c
88348 @@ -43,7 +43,7 @@ static void rds_tcp_cork(struct socket *sock, int val)
88349
88350 oldfs = get_fs();
88351 set_fs(KERNEL_DS);
88352 - sock->ops->setsockopt(sock, SOL_TCP, TCP_CORK, (char __user *)&val,
88353 + sock->ops->setsockopt(sock, SOL_TCP, TCP_CORK, (char __force_user *)&val,
88354 sizeof(val));
88355 set_fs(oldfs);
88356 }
88357 diff --git a/net/rxrpc/af_rxrpc.c b/net/rxrpc/af_rxrpc.c
88358 index 05996d0..5a1dfe0 100644
88359 --- a/net/rxrpc/af_rxrpc.c
88360 +++ b/net/rxrpc/af_rxrpc.c
88361 @@ -39,7 +39,7 @@ static const struct proto_ops rxrpc_rpc_ops;
88362 __be32 rxrpc_epoch;
88363
88364 /* current debugging ID */
88365 -atomic_t rxrpc_debug_id;
88366 +atomic_unchecked_t rxrpc_debug_id;
88367
88368 /* count of skbs currently in use */
88369 atomic_t rxrpc_n_skbs;
88370 diff --git a/net/rxrpc/ar-ack.c b/net/rxrpc/ar-ack.c
88371 index e4d9cbc..b229649 100644
88372 --- a/net/rxrpc/ar-ack.c
88373 +++ b/net/rxrpc/ar-ack.c
88374 @@ -175,7 +175,7 @@ static void rxrpc_resend(struct rxrpc_call *call)
88375
88376 _enter("{%d,%d,%d,%d},",
88377 call->acks_hard, call->acks_unacked,
88378 - atomic_read(&call->sequence),
88379 + atomic_read_unchecked(&call->sequence),
88380 CIRC_CNT(call->acks_head, call->acks_tail, call->acks_winsz));
88381
88382 stop = 0;
88383 @@ -199,7 +199,7 @@ static void rxrpc_resend(struct rxrpc_call *call)
88384
88385 /* each Tx packet has a new serial number */
88386 sp->hdr.serial =
88387 - htonl(atomic_inc_return(&call->conn->serial));
88388 + htonl(atomic_inc_return_unchecked(&call->conn->serial));
88389
88390 hdr = (struct rxrpc_header *) txb->head;
88391 hdr->serial = sp->hdr.serial;
88392 @@ -403,7 +403,7 @@ static void rxrpc_rotate_tx_window(struct rxrpc_call *call, u32 hard)
88393 */
88394 static void rxrpc_clear_tx_window(struct rxrpc_call *call)
88395 {
88396 - rxrpc_rotate_tx_window(call, atomic_read(&call->sequence));
88397 + rxrpc_rotate_tx_window(call, atomic_read_unchecked(&call->sequence));
88398 }
88399
88400 /*
88401 @@ -629,7 +629,7 @@ process_further:
88402
88403 latest = ntohl(sp->hdr.serial);
88404 hard = ntohl(ack.firstPacket);
88405 - tx = atomic_read(&call->sequence);
88406 + tx = atomic_read_unchecked(&call->sequence);
88407
88408 _proto("Rx ACK %%%u { m=%hu f=#%u p=#%u s=%%%u r=%s n=%u }",
88409 latest,
88410 @@ -1161,7 +1161,7 @@ void rxrpc_process_call(struct work_struct *work)
88411 goto maybe_reschedule;
88412
88413 send_ACK_with_skew:
88414 - ack.maxSkew = htons(atomic_read(&call->conn->hi_serial) -
88415 + ack.maxSkew = htons(atomic_read_unchecked(&call->conn->hi_serial) -
88416 ntohl(ack.serial));
88417 send_ACK:
88418 mtu = call->conn->trans->peer->if_mtu;
88419 @@ -1173,7 +1173,7 @@ send_ACK:
88420 ackinfo.rxMTU = htonl(5692);
88421 ackinfo.jumbo_max = htonl(4);
88422
88423 - hdr.serial = htonl(atomic_inc_return(&call->conn->serial));
88424 + hdr.serial = htonl(atomic_inc_return_unchecked(&call->conn->serial));
88425 _proto("Tx ACK %%%u { m=%hu f=#%u p=#%u s=%%%u r=%s n=%u }",
88426 ntohl(hdr.serial),
88427 ntohs(ack.maxSkew),
88428 @@ -1191,7 +1191,7 @@ send_ACK:
88429 send_message:
88430 _debug("send message");
88431
88432 - hdr.serial = htonl(atomic_inc_return(&call->conn->serial));
88433 + hdr.serial = htonl(atomic_inc_return_unchecked(&call->conn->serial));
88434 _proto("Tx %s %%%u", rxrpc_pkts[hdr.type], ntohl(hdr.serial));
88435 send_message_2:
88436
88437 diff --git a/net/rxrpc/ar-call.c b/net/rxrpc/ar-call.c
88438 index a3bbb36..3341fb9 100644
88439 --- a/net/rxrpc/ar-call.c
88440 +++ b/net/rxrpc/ar-call.c
88441 @@ -83,7 +83,7 @@ static struct rxrpc_call *rxrpc_alloc_call(gfp_t gfp)
88442 spin_lock_init(&call->lock);
88443 rwlock_init(&call->state_lock);
88444 atomic_set(&call->usage, 1);
88445 - call->debug_id = atomic_inc_return(&rxrpc_debug_id);
88446 + call->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
88447 call->state = RXRPC_CALL_CLIENT_SEND_REQUEST;
88448
88449 memset(&call->sock_node, 0xed, sizeof(call->sock_node));
88450 diff --git a/net/rxrpc/ar-connection.c b/net/rxrpc/ar-connection.c
88451 index 4106ca9..a338d7a 100644
88452 --- a/net/rxrpc/ar-connection.c
88453 +++ b/net/rxrpc/ar-connection.c
88454 @@ -206,7 +206,7 @@ static struct rxrpc_connection *rxrpc_alloc_connection(gfp_t gfp)
88455 rwlock_init(&conn->lock);
88456 spin_lock_init(&conn->state_lock);
88457 atomic_set(&conn->usage, 1);
88458 - conn->debug_id = atomic_inc_return(&rxrpc_debug_id);
88459 + conn->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
88460 conn->avail_calls = RXRPC_MAXCALLS;
88461 conn->size_align = 4;
88462 conn->header_size = sizeof(struct rxrpc_header);
88463 diff --git a/net/rxrpc/ar-connevent.c b/net/rxrpc/ar-connevent.c
88464 index e7ed43a..6afa140 100644
88465 --- a/net/rxrpc/ar-connevent.c
88466 +++ b/net/rxrpc/ar-connevent.c
88467 @@ -109,7 +109,7 @@ static int rxrpc_abort_connection(struct rxrpc_connection *conn,
88468
88469 len = iov[0].iov_len + iov[1].iov_len;
88470
88471 - hdr.serial = htonl(atomic_inc_return(&conn->serial));
88472 + hdr.serial = htonl(atomic_inc_return_unchecked(&conn->serial));
88473 _proto("Tx CONN ABORT %%%u { %d }", ntohl(hdr.serial), abort_code);
88474
88475 ret = kernel_sendmsg(conn->trans->local->socket, &msg, iov, 2, len);
88476 diff --git a/net/rxrpc/ar-input.c b/net/rxrpc/ar-input.c
88477 index 529572f..c758ca7 100644
88478 --- a/net/rxrpc/ar-input.c
88479 +++ b/net/rxrpc/ar-input.c
88480 @@ -340,9 +340,9 @@ void rxrpc_fast_process_packet(struct rxrpc_call *call, struct sk_buff *skb)
88481 /* track the latest serial number on this connection for ACK packet
88482 * information */
88483 serial = ntohl(sp->hdr.serial);
88484 - hi_serial = atomic_read(&call->conn->hi_serial);
88485 + hi_serial = atomic_read_unchecked(&call->conn->hi_serial);
88486 while (serial > hi_serial)
88487 - hi_serial = atomic_cmpxchg(&call->conn->hi_serial, hi_serial,
88488 + hi_serial = atomic_cmpxchg_unchecked(&call->conn->hi_serial, hi_serial,
88489 serial);
88490
88491 /* request ACK generation for any ACK or DATA packet that requests
88492 diff --git a/net/rxrpc/ar-internal.h b/net/rxrpc/ar-internal.h
88493 index a693aca..81e7293 100644
88494 --- a/net/rxrpc/ar-internal.h
88495 +++ b/net/rxrpc/ar-internal.h
88496 @@ -272,8 +272,8 @@ struct rxrpc_connection {
88497 int error; /* error code for local abort */
88498 int debug_id; /* debug ID for printks */
88499 unsigned int call_counter; /* call ID counter */
88500 - atomic_t serial; /* packet serial number counter */
88501 - atomic_t hi_serial; /* highest serial number received */
88502 + atomic_unchecked_t serial; /* packet serial number counter */
88503 + atomic_unchecked_t hi_serial; /* highest serial number received */
88504 u8 avail_calls; /* number of calls available */
88505 u8 size_align; /* data size alignment (for security) */
88506 u8 header_size; /* rxrpc + security header size */
88507 @@ -346,7 +346,7 @@ struct rxrpc_call {
88508 spinlock_t lock;
88509 rwlock_t state_lock; /* lock for state transition */
88510 atomic_t usage;
88511 - atomic_t sequence; /* Tx data packet sequence counter */
88512 + atomic_unchecked_t sequence; /* Tx data packet sequence counter */
88513 u32 abort_code; /* local/remote abort code */
88514 enum { /* current state of call */
88515 RXRPC_CALL_CLIENT_SEND_REQUEST, /* - client sending request phase */
88516 @@ -420,7 +420,7 @@ static inline void rxrpc_abort_call(struct rxrpc_call *call, u32 abort_code)
88517 */
88518 extern atomic_t rxrpc_n_skbs;
88519 extern __be32 rxrpc_epoch;
88520 -extern atomic_t rxrpc_debug_id;
88521 +extern atomic_unchecked_t rxrpc_debug_id;
88522 extern struct workqueue_struct *rxrpc_workqueue;
88523
88524 /*
88525 diff --git a/net/rxrpc/ar-local.c b/net/rxrpc/ar-local.c
88526 index 87f7135..74d3703 100644
88527 --- a/net/rxrpc/ar-local.c
88528 +++ b/net/rxrpc/ar-local.c
88529 @@ -45,7 +45,7 @@ struct rxrpc_local *rxrpc_alloc_local(struct sockaddr_rxrpc *srx)
88530 spin_lock_init(&local->lock);
88531 rwlock_init(&local->services_lock);
88532 atomic_set(&local->usage, 1);
88533 - local->debug_id = atomic_inc_return(&rxrpc_debug_id);
88534 + local->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
88535 memcpy(&local->srx, srx, sizeof(*srx));
88536 }
88537
88538 diff --git a/net/rxrpc/ar-output.c b/net/rxrpc/ar-output.c
88539 index e1ac183..b43e10e 100644
88540 --- a/net/rxrpc/ar-output.c
88541 +++ b/net/rxrpc/ar-output.c
88542 @@ -682,9 +682,9 @@ static int rxrpc_send_data(struct kiocb *iocb,
88543 sp->hdr.cid = call->cid;
88544 sp->hdr.callNumber = call->call_id;
88545 sp->hdr.seq =
88546 - htonl(atomic_inc_return(&call->sequence));
88547 + htonl(atomic_inc_return_unchecked(&call->sequence));
88548 sp->hdr.serial =
88549 - htonl(atomic_inc_return(&conn->serial));
88550 + htonl(atomic_inc_return_unchecked(&conn->serial));
88551 sp->hdr.type = RXRPC_PACKET_TYPE_DATA;
88552 sp->hdr.userStatus = 0;
88553 sp->hdr.securityIndex = conn->security_ix;
88554 diff --git a/net/rxrpc/ar-peer.c b/net/rxrpc/ar-peer.c
88555 index bebaa43..2644591 100644
88556 --- a/net/rxrpc/ar-peer.c
88557 +++ b/net/rxrpc/ar-peer.c
88558 @@ -72,7 +72,7 @@ static struct rxrpc_peer *rxrpc_alloc_peer(struct sockaddr_rxrpc *srx,
88559 INIT_LIST_HEAD(&peer->error_targets);
88560 spin_lock_init(&peer->lock);
88561 atomic_set(&peer->usage, 1);
88562 - peer->debug_id = atomic_inc_return(&rxrpc_debug_id);
88563 + peer->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
88564 memcpy(&peer->srx, srx, sizeof(*srx));
88565
88566 rxrpc_assess_MTU_size(peer);
88567 diff --git a/net/rxrpc/ar-proc.c b/net/rxrpc/ar-proc.c
88568 index 38047f7..9f48511 100644
88569 --- a/net/rxrpc/ar-proc.c
88570 +++ b/net/rxrpc/ar-proc.c
88571 @@ -164,8 +164,8 @@ static int rxrpc_connection_seq_show(struct seq_file *seq, void *v)
88572 atomic_read(&conn->usage),
88573 rxrpc_conn_states[conn->state],
88574 key_serial(conn->key),
88575 - atomic_read(&conn->serial),
88576 - atomic_read(&conn->hi_serial));
88577 + atomic_read_unchecked(&conn->serial),
88578 + atomic_read_unchecked(&conn->hi_serial));
88579
88580 return 0;
88581 }
88582 diff --git a/net/rxrpc/ar-transport.c b/net/rxrpc/ar-transport.c
88583 index 92df566..87ec1bf 100644
88584 --- a/net/rxrpc/ar-transport.c
88585 +++ b/net/rxrpc/ar-transport.c
88586 @@ -47,7 +47,7 @@ static struct rxrpc_transport *rxrpc_alloc_transport(struct rxrpc_local *local,
88587 spin_lock_init(&trans->client_lock);
88588 rwlock_init(&trans->conn_lock);
88589 atomic_set(&trans->usage, 1);
88590 - trans->debug_id = atomic_inc_return(&rxrpc_debug_id);
88591 + trans->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
88592
88593 if (peer->srx.transport.family == AF_INET) {
88594 switch (peer->srx.transport_type) {
88595 diff --git a/net/rxrpc/rxkad.c b/net/rxrpc/rxkad.c
88596 index f226709..0e735a8 100644
88597 --- a/net/rxrpc/rxkad.c
88598 +++ b/net/rxrpc/rxkad.c
88599 @@ -610,7 +610,7 @@ static int rxkad_issue_challenge(struct rxrpc_connection *conn)
88600
88601 len = iov[0].iov_len + iov[1].iov_len;
88602
88603 - hdr.serial = htonl(atomic_inc_return(&conn->serial));
88604 + hdr.serial = htonl(atomic_inc_return_unchecked(&conn->serial));
88605 _proto("Tx CHALLENGE %%%u", ntohl(hdr.serial));
88606
88607 ret = kernel_sendmsg(conn->trans->local->socket, &msg, iov, 2, len);
88608 @@ -660,7 +660,7 @@ static int rxkad_send_response(struct rxrpc_connection *conn,
88609
88610 len = iov[0].iov_len + iov[1].iov_len + iov[2].iov_len;
88611
88612 - hdr->serial = htonl(atomic_inc_return(&conn->serial));
88613 + hdr->serial = htonl(atomic_inc_return_unchecked(&conn->serial));
88614 _proto("Tx RESPONSE %%%u", ntohl(hdr->serial));
88615
88616 ret = kernel_sendmsg(conn->trans->local->socket, &msg, iov, 3, len);
88617 diff --git a/net/sctp/ipv6.c b/net/sctp/ipv6.c
88618 index 391a245..296b3d7 100644
88619 --- a/net/sctp/ipv6.c
88620 +++ b/net/sctp/ipv6.c
88621 @@ -981,7 +981,7 @@ static const struct inet6_protocol sctpv6_protocol = {
88622 .flags = INET6_PROTO_NOPOLICY | INET6_PROTO_FINAL,
88623 };
88624
88625 -static struct sctp_af sctp_af_inet6 = {
88626 +static struct sctp_af sctp_af_inet6 __read_only = {
88627 .sa_family = AF_INET6,
88628 .sctp_xmit = sctp_v6_xmit,
88629 .setsockopt = ipv6_setsockopt,
88630 @@ -1013,7 +1013,7 @@ static struct sctp_af sctp_af_inet6 = {
88631 #endif
88632 };
88633
88634 -static struct sctp_pf sctp_pf_inet6 = {
88635 +static struct sctp_pf sctp_pf_inet6 __read_only = {
88636 .event_msgname = sctp_inet6_event_msgname,
88637 .skb_msgname = sctp_inet6_skb_msgname,
88638 .af_supported = sctp_inet6_af_supported,
88639 @@ -1038,7 +1038,7 @@ void sctp_v6_pf_init(void)
88640
88641 void sctp_v6_pf_exit(void)
88642 {
88643 - list_del(&sctp_af_inet6.list);
88644 + pax_list_del(&sctp_af_inet6.list);
88645 }
88646
88647 /* Initialize IPv6 support and register with socket layer. */
88648 diff --git a/net/sctp/proc.c b/net/sctp/proc.c
88649 index 8c19e97..16264b8 100644
88650 --- a/net/sctp/proc.c
88651 +++ b/net/sctp/proc.c
88652 @@ -338,7 +338,8 @@ static int sctp_assocs_seq_show(struct seq_file *seq, void *v)
88653 seq_printf(seq,
88654 "%8pK %8pK %-3d %-3d %-2d %-4d "
88655 "%4d %8d %8d %7d %5lu %-5d %5d ",
88656 - assoc, sk, sctp_sk(sk)->type, sk->sk_state,
88657 + assoc, sk,
88658 + sctp_sk(sk)->type, sk->sk_state,
88659 assoc->state, hash,
88660 assoc->assoc_id,
88661 assoc->sndbuf_used,
88662 diff --git a/net/sctp/protocol.c b/net/sctp/protocol.c
88663 index f898b1c..a2d0fe8 100644
88664 --- a/net/sctp/protocol.c
88665 +++ b/net/sctp/protocol.c
88666 @@ -834,8 +834,10 @@ int sctp_register_af(struct sctp_af *af)
88667 return 0;
88668 }
88669
88670 + pax_open_kernel();
88671 INIT_LIST_HEAD(&af->list);
88672 - list_add_tail(&af->list, &sctp_address_families);
88673 + pax_close_kernel();
88674 + pax_list_add_tail(&af->list, &sctp_address_families);
88675 return 1;
88676 }
88677
88678 @@ -966,7 +968,7 @@ static inline int sctp_v4_xmit(struct sk_buff *skb,
88679
88680 static struct sctp_af sctp_af_inet;
88681
88682 -static struct sctp_pf sctp_pf_inet = {
88683 +static struct sctp_pf sctp_pf_inet __read_only = {
88684 .event_msgname = sctp_inet_event_msgname,
88685 .skb_msgname = sctp_inet_skb_msgname,
88686 .af_supported = sctp_inet_af_supported,
88687 @@ -1037,7 +1039,7 @@ static const struct net_protocol sctp_protocol = {
88688 };
88689
88690 /* IPv4 address related functions. */
88691 -static struct sctp_af sctp_af_inet = {
88692 +static struct sctp_af sctp_af_inet __read_only = {
88693 .sa_family = AF_INET,
88694 .sctp_xmit = sctp_v4_xmit,
88695 .setsockopt = ip_setsockopt,
88696 @@ -1122,7 +1124,7 @@ static void sctp_v4_pf_init(void)
88697
88698 static void sctp_v4_pf_exit(void)
88699 {
88700 - list_del(&sctp_af_inet.list);
88701 + pax_list_del(&sctp_af_inet.list);
88702 }
88703
88704 static int sctp_v4_protosw_init(void)
88705 diff --git a/net/sctp/sm_sideeffect.c b/net/sctp/sm_sideeffect.c
88706 index c957775..6d4593a 100644
88707 --- a/net/sctp/sm_sideeffect.c
88708 +++ b/net/sctp/sm_sideeffect.c
88709 @@ -447,7 +447,7 @@ static void sctp_generate_sack_event(unsigned long data)
88710 sctp_generate_timeout_event(asoc, SCTP_EVENT_TIMEOUT_SACK);
88711 }
88712
88713 -sctp_timer_event_t *sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES] = {
88714 +sctp_timer_event_t * const sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES] = {
88715 NULL,
88716 sctp_generate_t1_cookie_event,
88717 sctp_generate_t1_init_event,
88718 diff --git a/net/sctp/socket.c b/net/sctp/socket.c
88719 index cedd9bf..d577d71 100644
88720 --- a/net/sctp/socket.c
88721 +++ b/net/sctp/socket.c
88722 @@ -4665,6 +4665,8 @@ static int sctp_getsockopt_peer_addrs(struct sock *sk, int len,
88723 addrlen = sctp_get_af_specific(temp.sa.sa_family)->sockaddr_len;
88724 if (space_left < addrlen)
88725 return -ENOMEM;
88726 + if (addrlen > sizeof(temp) || addrlen < 0)
88727 + return -EFAULT;
88728 if (copy_to_user(to, &temp, addrlen))
88729 return -EFAULT;
88730 to += addrlen;
88731 @@ -5653,6 +5655,9 @@ static int sctp_getsockopt_assoc_stats(struct sock *sk, int len,
88732 if (len < sizeof(sctp_assoc_t))
88733 return -EINVAL;
88734
88735 + /* Allow the struct to grow and fill in as much as possible */
88736 + len = min_t(size_t, len, sizeof(sas));
88737 +
88738 if (copy_from_user(&sas, optval, len))
88739 return -EFAULT;
88740
88741 @@ -5686,9 +5691,6 @@ static int sctp_getsockopt_assoc_stats(struct sock *sk, int len,
88742 /* Mark beginning of a new observation period */
88743 asoc->stats.max_obs_rto = asoc->rto_min;
88744
88745 - /* Allow the struct to grow and fill in as much as possible */
88746 - len = min_t(size_t, len, sizeof(sas));
88747 -
88748 if (put_user(len, optlen))
88749 return -EFAULT;
88750
88751 diff --git a/net/sctp/ssnmap.c b/net/sctp/ssnmap.c
88752 index 442ad4e..825ea94 100644
88753 --- a/net/sctp/ssnmap.c
88754 +++ b/net/sctp/ssnmap.c
88755 @@ -41,8 +41,6 @@
88756 #include <net/sctp/sctp.h>
88757 #include <net/sctp/sm.h>
88758
88759 -#define MAX_KMALLOC_SIZE 131072
88760 -
88761 static struct sctp_ssnmap *sctp_ssnmap_init(struct sctp_ssnmap *map, __u16 in,
88762 __u16 out);
88763
88764 @@ -65,7 +63,7 @@ struct sctp_ssnmap *sctp_ssnmap_new(__u16 in, __u16 out,
88765 int size;
88766
88767 size = sctp_ssnmap_size(in, out);
88768 - if (size <= MAX_KMALLOC_SIZE)
88769 + if (size <= KMALLOC_MAX_SIZE)
88770 retval = kmalloc(size, gfp);
88771 else
88772 retval = (struct sctp_ssnmap *)
88773 @@ -82,7 +80,7 @@ struct sctp_ssnmap *sctp_ssnmap_new(__u16 in, __u16 out,
88774 return retval;
88775
88776 fail_map:
88777 - if (size <= MAX_KMALLOC_SIZE)
88778 + if (size <= KMALLOC_MAX_SIZE)
88779 kfree(retval);
88780 else
88781 free_pages((unsigned long)retval, get_order(size));
88782 @@ -124,7 +122,7 @@ void sctp_ssnmap_free(struct sctp_ssnmap *map)
88783 int size;
88784
88785 size = sctp_ssnmap_size(map->in.len, map->out.len);
88786 - if (size <= MAX_KMALLOC_SIZE)
88787 + if (size <= KMALLOC_MAX_SIZE)
88788 kfree(map);
88789 else
88790 free_pages((unsigned long)map, get_order(size));
88791 diff --git a/net/sctp/sysctl.c b/net/sctp/sysctl.c
88792 index bf3c6e8..376d8d0 100644
88793 --- a/net/sctp/sysctl.c
88794 +++ b/net/sctp/sysctl.c
88795 @@ -307,7 +307,7 @@ static int proc_sctp_do_hmac_alg(ctl_table *ctl,
88796 {
88797 struct net *net = current->nsproxy->net_ns;
88798 char tmp[8];
88799 - ctl_table tbl;
88800 + ctl_table_no_const tbl;
88801 int ret;
88802 int changed = 0;
88803 char *none = "none";
88804 @@ -350,7 +350,7 @@ static int proc_sctp_do_hmac_alg(ctl_table *ctl,
88805
88806 int sctp_sysctl_net_register(struct net *net)
88807 {
88808 - struct ctl_table *table;
88809 + ctl_table_no_const *table;
88810 int i;
88811
88812 table = kmemdup(sctp_net_table, sizeof(sctp_net_table), GFP_KERNEL);
88813 diff --git a/net/socket.c b/net/socket.c
88814 index 2ca51c7..adc6cb6 100644
88815 --- a/net/socket.c
88816 +++ b/net/socket.c
88817 @@ -89,6 +89,7 @@
88818 #include <linux/magic.h>
88819 #include <linux/slab.h>
88820 #include <linux/xattr.h>
88821 +#include <linux/in.h>
88822
88823 #include <asm/uaccess.h>
88824 #include <asm/unistd.h>
88825 @@ -106,6 +107,8 @@
88826 #include <linux/sockios.h>
88827 #include <linux/atalk.h>
88828
88829 +#include <linux/grsock.h>
88830 +
88831 static int sock_no_open(struct inode *irrelevant, struct file *dontcare);
88832 static ssize_t sock_aio_read(struct kiocb *iocb, const struct iovec *iov,
88833 unsigned long nr_segs, loff_t pos);
88834 @@ -322,7 +325,7 @@ static struct dentry *sockfs_mount(struct file_system_type *fs_type,
88835 &sockfs_dentry_operations, SOCKFS_MAGIC);
88836 }
88837
88838 -static struct vfsmount *sock_mnt __read_mostly;
88839 +struct vfsmount *sock_mnt __read_mostly;
88840
88841 static struct file_system_type sock_fs_type = {
88842 .name = "sockfs",
88843 @@ -1270,6 +1273,8 @@ int __sock_create(struct net *net, int family, int type, int protocol,
88844 return -EAFNOSUPPORT;
88845 if (type < 0 || type >= SOCK_MAX)
88846 return -EINVAL;
88847 + if (protocol < 0)
88848 + return -EINVAL;
88849
88850 /* Compatibility.
88851
88852 @@ -1401,6 +1406,16 @@ SYSCALL_DEFINE3(socket, int, family, int, type, int, protocol)
88853 if (SOCK_NONBLOCK != O_NONBLOCK && (flags & SOCK_NONBLOCK))
88854 flags = (flags & ~SOCK_NONBLOCK) | O_NONBLOCK;
88855
88856 + if(!gr_search_socket(family, type, protocol)) {
88857 + retval = -EACCES;
88858 + goto out;
88859 + }
88860 +
88861 + if (gr_handle_sock_all(family, type, protocol)) {
88862 + retval = -EACCES;
88863 + goto out;
88864 + }
88865 +
88866 retval = sock_create(family, type, protocol, &sock);
88867 if (retval < 0)
88868 goto out;
88869 @@ -1528,6 +1543,14 @@ SYSCALL_DEFINE3(bind, int, fd, struct sockaddr __user *, umyaddr, int, addrlen)
88870 if (sock) {
88871 err = move_addr_to_kernel(umyaddr, addrlen, &address);
88872 if (err >= 0) {
88873 + if (gr_handle_sock_server((struct sockaddr *)&address)) {
88874 + err = -EACCES;
88875 + goto error;
88876 + }
88877 + err = gr_search_bind(sock, (struct sockaddr_in *)&address);
88878 + if (err)
88879 + goto error;
88880 +
88881 err = security_socket_bind(sock,
88882 (struct sockaddr *)&address,
88883 addrlen);
88884 @@ -1536,6 +1559,7 @@ SYSCALL_DEFINE3(bind, int, fd, struct sockaddr __user *, umyaddr, int, addrlen)
88885 (struct sockaddr *)
88886 &address, addrlen);
88887 }
88888 +error:
88889 fput_light(sock->file, fput_needed);
88890 }
88891 return err;
88892 @@ -1559,10 +1583,20 @@ SYSCALL_DEFINE2(listen, int, fd, int, backlog)
88893 if ((unsigned int)backlog > somaxconn)
88894 backlog = somaxconn;
88895
88896 + if (gr_handle_sock_server_other(sock->sk)) {
88897 + err = -EPERM;
88898 + goto error;
88899 + }
88900 +
88901 + err = gr_search_listen(sock);
88902 + if (err)
88903 + goto error;
88904 +
88905 err = security_socket_listen(sock, backlog);
88906 if (!err)
88907 err = sock->ops->listen(sock, backlog);
88908
88909 +error:
88910 fput_light(sock->file, fput_needed);
88911 }
88912 return err;
88913 @@ -1606,6 +1640,18 @@ SYSCALL_DEFINE4(accept4, int, fd, struct sockaddr __user *, upeer_sockaddr,
88914 newsock->type = sock->type;
88915 newsock->ops = sock->ops;
88916
88917 + if (gr_handle_sock_server_other(sock->sk)) {
88918 + err = -EPERM;
88919 + sock_release(newsock);
88920 + goto out_put;
88921 + }
88922 +
88923 + err = gr_search_accept(sock);
88924 + if (err) {
88925 + sock_release(newsock);
88926 + goto out_put;
88927 + }
88928 +
88929 /*
88930 * We don't need try_module_get here, as the listening socket (sock)
88931 * has the protocol module (sock->ops->owner) held.
88932 @@ -1651,6 +1697,8 @@ SYSCALL_DEFINE4(accept4, int, fd, struct sockaddr __user *, upeer_sockaddr,
88933 fd_install(newfd, newfile);
88934 err = newfd;
88935
88936 + gr_attach_curr_ip(newsock->sk);
88937 +
88938 out_put:
88939 fput_light(sock->file, fput_needed);
88940 out:
88941 @@ -1683,6 +1731,7 @@ SYSCALL_DEFINE3(connect, int, fd, struct sockaddr __user *, uservaddr,
88942 int, addrlen)
88943 {
88944 struct socket *sock;
88945 + struct sockaddr *sck;
88946 struct sockaddr_storage address;
88947 int err, fput_needed;
88948
88949 @@ -1693,6 +1742,17 @@ SYSCALL_DEFINE3(connect, int, fd, struct sockaddr __user *, uservaddr,
88950 if (err < 0)
88951 goto out_put;
88952
88953 + sck = (struct sockaddr *)&address;
88954 +
88955 + if (gr_handle_sock_client(sck)) {
88956 + err = -EACCES;
88957 + goto out_put;
88958 + }
88959 +
88960 + err = gr_search_connect(sock, (struct sockaddr_in *)sck);
88961 + if (err)
88962 + goto out_put;
88963 +
88964 err =
88965 security_socket_connect(sock, (struct sockaddr *)&address, addrlen);
88966 if (err)
88967 @@ -1774,6 +1834,8 @@ SYSCALL_DEFINE3(getpeername, int, fd, struct sockaddr __user *, usockaddr,
88968 * the protocol.
88969 */
88970
88971 +asmlinkage long sys_sendto(int, void *, size_t, unsigned, struct sockaddr *, int) __intentional_overflow(0);
88972 +
88973 SYSCALL_DEFINE6(sendto, int, fd, void __user *, buff, size_t, len,
88974 unsigned int, flags, struct sockaddr __user *, addr,
88975 int, addr_len)
88976 @@ -2047,7 +2109,7 @@ static int __sys_sendmsg(struct socket *sock, struct msghdr __user *msg,
88977 * checking falls down on this.
88978 */
88979 if (copy_from_user(ctl_buf,
88980 - (void __user __force *)msg_sys->msg_control,
88981 + (void __force_user *)msg_sys->msg_control,
88982 ctl_len))
88983 goto out_freectl;
88984 msg_sys->msg_control = ctl_buf;
88985 @@ -2215,7 +2277,7 @@ static int __sys_recvmsg(struct socket *sock, struct msghdr __user *msg,
88986 * kernel msghdr to use the kernel address space)
88987 */
88988
88989 - uaddr = (__force void __user *)msg_sys->msg_name;
88990 + uaddr = (void __force_user *)msg_sys->msg_name;
88991 uaddr_len = COMPAT_NAMELEN(msg);
88992 if (MSG_CMSG_COMPAT & flags) {
88993 err = verify_compat_iovec(msg_sys, iov, &addr, VERIFY_WRITE);
88994 @@ -2838,7 +2900,7 @@ static int ethtool_ioctl(struct net *net, struct compat_ifreq __user *ifr32)
88995 }
88996
88997 ifr = compat_alloc_user_space(buf_size);
88998 - rxnfc = (void *)ifr + ALIGN(sizeof(struct ifreq), 8);
88999 + rxnfc = (void __user *)ifr + ALIGN(sizeof(struct ifreq), 8);
89000
89001 if (copy_in_user(&ifr->ifr_name, &ifr32->ifr_name, IFNAMSIZ))
89002 return -EFAULT;
89003 @@ -2862,12 +2924,12 @@ static int ethtool_ioctl(struct net *net, struct compat_ifreq __user *ifr32)
89004 offsetof(struct ethtool_rxnfc, fs.ring_cookie));
89005
89006 if (copy_in_user(rxnfc, compat_rxnfc,
89007 - (void *)(&rxnfc->fs.m_ext + 1) -
89008 - (void *)rxnfc) ||
89009 + (void __user *)(&rxnfc->fs.m_ext + 1) -
89010 + (void __user *)rxnfc) ||
89011 copy_in_user(&rxnfc->fs.ring_cookie,
89012 &compat_rxnfc->fs.ring_cookie,
89013 - (void *)(&rxnfc->fs.location + 1) -
89014 - (void *)&rxnfc->fs.ring_cookie) ||
89015 + (void __user *)(&rxnfc->fs.location + 1) -
89016 + (void __user *)&rxnfc->fs.ring_cookie) ||
89017 copy_in_user(&rxnfc->rule_cnt, &compat_rxnfc->rule_cnt,
89018 sizeof(rxnfc->rule_cnt)))
89019 return -EFAULT;
89020 @@ -2879,12 +2941,12 @@ static int ethtool_ioctl(struct net *net, struct compat_ifreq __user *ifr32)
89021
89022 if (convert_out) {
89023 if (copy_in_user(compat_rxnfc, rxnfc,
89024 - (const void *)(&rxnfc->fs.m_ext + 1) -
89025 - (const void *)rxnfc) ||
89026 + (const void __user *)(&rxnfc->fs.m_ext + 1) -
89027 + (const void __user *)rxnfc) ||
89028 copy_in_user(&compat_rxnfc->fs.ring_cookie,
89029 &rxnfc->fs.ring_cookie,
89030 - (const void *)(&rxnfc->fs.location + 1) -
89031 - (const void *)&rxnfc->fs.ring_cookie) ||
89032 + (const void __user *)(&rxnfc->fs.location + 1) -
89033 + (const void __user *)&rxnfc->fs.ring_cookie) ||
89034 copy_in_user(&compat_rxnfc->rule_cnt, &rxnfc->rule_cnt,
89035 sizeof(rxnfc->rule_cnt)))
89036 return -EFAULT;
89037 @@ -2954,7 +3016,7 @@ static int bond_ioctl(struct net *net, unsigned int cmd,
89038 old_fs = get_fs();
89039 set_fs(KERNEL_DS);
89040 err = dev_ioctl(net, cmd,
89041 - (struct ifreq __user __force *) &kifr);
89042 + (struct ifreq __force_user *) &kifr);
89043 set_fs(old_fs);
89044
89045 return err;
89046 @@ -3063,7 +3125,7 @@ static int compat_sioc_ifmap(struct net *net, unsigned int cmd,
89047
89048 old_fs = get_fs();
89049 set_fs(KERNEL_DS);
89050 - err = dev_ioctl(net, cmd, (void __user __force *)&ifr);
89051 + err = dev_ioctl(net, cmd, (void __force_user *)&ifr);
89052 set_fs(old_fs);
89053
89054 if (cmd == SIOCGIFMAP && !err) {
89055 @@ -3168,7 +3230,7 @@ static int routing_ioctl(struct net *net, struct socket *sock,
89056 ret |= __get_user(rtdev, &(ur4->rt_dev));
89057 if (rtdev) {
89058 ret |= copy_from_user(devname, compat_ptr(rtdev), 15);
89059 - r4.rt_dev = (char __user __force *)devname;
89060 + r4.rt_dev = (char __force_user *)devname;
89061 devname[15] = 0;
89062 } else
89063 r4.rt_dev = NULL;
89064 @@ -3394,8 +3456,8 @@ int kernel_getsockopt(struct socket *sock, int level, int optname,
89065 int __user *uoptlen;
89066 int err;
89067
89068 - uoptval = (char __user __force *) optval;
89069 - uoptlen = (int __user __force *) optlen;
89070 + uoptval = (char __force_user *) optval;
89071 + uoptlen = (int __force_user *) optlen;
89072
89073 set_fs(KERNEL_DS);
89074 if (level == SOL_SOCKET)
89075 @@ -3415,7 +3477,7 @@ int kernel_setsockopt(struct socket *sock, int level, int optname,
89076 char __user *uoptval;
89077 int err;
89078
89079 - uoptval = (char __user __force *) optval;
89080 + uoptval = (char __force_user *) optval;
89081
89082 set_fs(KERNEL_DS);
89083 if (level == SOL_SOCKET)
89084 diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c
89085 index 507b5e8..049e64a 100644
89086 --- a/net/sunrpc/clnt.c
89087 +++ b/net/sunrpc/clnt.c
89088 @@ -1272,7 +1272,9 @@ call_start(struct rpc_task *task)
89089 (RPC_IS_ASYNC(task) ? "async" : "sync"));
89090
89091 /* Increment call count */
89092 - task->tk_msg.rpc_proc->p_count++;
89093 + pax_open_kernel();
89094 + (*(unsigned int *)&task->tk_msg.rpc_proc->p_count)++;
89095 + pax_close_kernel();
89096 clnt->cl_stats->rpccnt++;
89097 task->tk_action = call_reserve;
89098 }
89099 diff --git a/net/sunrpc/sched.c b/net/sunrpc/sched.c
89100 index fb20f25..e3ba316 100644
89101 --- a/net/sunrpc/sched.c
89102 +++ b/net/sunrpc/sched.c
89103 @@ -259,9 +259,9 @@ static int rpc_wait_bit_killable(void *word)
89104 #ifdef RPC_DEBUG
89105 static void rpc_task_set_debuginfo(struct rpc_task *task)
89106 {
89107 - static atomic_t rpc_pid;
89108 + static atomic_unchecked_t rpc_pid;
89109
89110 - task->tk_pid = atomic_inc_return(&rpc_pid);
89111 + task->tk_pid = atomic_inc_return_unchecked(&rpc_pid);
89112 }
89113 #else
89114 static inline void rpc_task_set_debuginfo(struct rpc_task *task)
89115 diff --git a/net/sunrpc/svc.c b/net/sunrpc/svc.c
89116 index 2d34b6b..e2d584d 100644
89117 --- a/net/sunrpc/svc.c
89118 +++ b/net/sunrpc/svc.c
89119 @@ -1156,7 +1156,9 @@ svc_process_common(struct svc_rqst *rqstp, struct kvec *argv, struct kvec *resv)
89120 svc_putnl(resv, RPC_SUCCESS);
89121
89122 /* Bump per-procedure stats counter */
89123 - procp->pc_count++;
89124 + pax_open_kernel();
89125 + (*(unsigned int *)&procp->pc_count)++;
89126 + pax_close_kernel();
89127
89128 /* Initialize storage for argp and resp */
89129 memset(rqstp->rq_argp, 0, procp->pc_argsize);
89130 diff --git a/net/sunrpc/xprtrdma/svc_rdma.c b/net/sunrpc/xprtrdma/svc_rdma.c
89131 index 8343737..677025e 100644
89132 --- a/net/sunrpc/xprtrdma/svc_rdma.c
89133 +++ b/net/sunrpc/xprtrdma/svc_rdma.c
89134 @@ -62,15 +62,15 @@ unsigned int svcrdma_max_req_size = RPCRDMA_MAX_REQ_SIZE;
89135 static unsigned int min_max_inline = 4096;
89136 static unsigned int max_max_inline = 65536;
89137
89138 -atomic_t rdma_stat_recv;
89139 -atomic_t rdma_stat_read;
89140 -atomic_t rdma_stat_write;
89141 -atomic_t rdma_stat_sq_starve;
89142 -atomic_t rdma_stat_rq_starve;
89143 -atomic_t rdma_stat_rq_poll;
89144 -atomic_t rdma_stat_rq_prod;
89145 -atomic_t rdma_stat_sq_poll;
89146 -atomic_t rdma_stat_sq_prod;
89147 +atomic_unchecked_t rdma_stat_recv;
89148 +atomic_unchecked_t rdma_stat_read;
89149 +atomic_unchecked_t rdma_stat_write;
89150 +atomic_unchecked_t rdma_stat_sq_starve;
89151 +atomic_unchecked_t rdma_stat_rq_starve;
89152 +atomic_unchecked_t rdma_stat_rq_poll;
89153 +atomic_unchecked_t rdma_stat_rq_prod;
89154 +atomic_unchecked_t rdma_stat_sq_poll;
89155 +atomic_unchecked_t rdma_stat_sq_prod;
89156
89157 /* Temporary NFS request map and context caches */
89158 struct kmem_cache *svc_rdma_map_cachep;
89159 @@ -110,7 +110,7 @@ static int read_reset_stat(ctl_table *table, int write,
89160 len -= *ppos;
89161 if (len > *lenp)
89162 len = *lenp;
89163 - if (len && copy_to_user(buffer, str_buf, len))
89164 + if (len > sizeof str_buf || (len && copy_to_user(buffer, str_buf, len)))
89165 return -EFAULT;
89166 *lenp = len;
89167 *ppos += len;
89168 @@ -151,63 +151,63 @@ static ctl_table svcrdma_parm_table[] = {
89169 {
89170 .procname = "rdma_stat_read",
89171 .data = &rdma_stat_read,
89172 - .maxlen = sizeof(atomic_t),
89173 + .maxlen = sizeof(atomic_unchecked_t),
89174 .mode = 0644,
89175 .proc_handler = read_reset_stat,
89176 },
89177 {
89178 .procname = "rdma_stat_recv",
89179 .data = &rdma_stat_recv,
89180 - .maxlen = sizeof(atomic_t),
89181 + .maxlen = sizeof(atomic_unchecked_t),
89182 .mode = 0644,
89183 .proc_handler = read_reset_stat,
89184 },
89185 {
89186 .procname = "rdma_stat_write",
89187 .data = &rdma_stat_write,
89188 - .maxlen = sizeof(atomic_t),
89189 + .maxlen = sizeof(atomic_unchecked_t),
89190 .mode = 0644,
89191 .proc_handler = read_reset_stat,
89192 },
89193 {
89194 .procname = "rdma_stat_sq_starve",
89195 .data = &rdma_stat_sq_starve,
89196 - .maxlen = sizeof(atomic_t),
89197 + .maxlen = sizeof(atomic_unchecked_t),
89198 .mode = 0644,
89199 .proc_handler = read_reset_stat,
89200 },
89201 {
89202 .procname = "rdma_stat_rq_starve",
89203 .data = &rdma_stat_rq_starve,
89204 - .maxlen = sizeof(atomic_t),
89205 + .maxlen = sizeof(atomic_unchecked_t),
89206 .mode = 0644,
89207 .proc_handler = read_reset_stat,
89208 },
89209 {
89210 .procname = "rdma_stat_rq_poll",
89211 .data = &rdma_stat_rq_poll,
89212 - .maxlen = sizeof(atomic_t),
89213 + .maxlen = sizeof(atomic_unchecked_t),
89214 .mode = 0644,
89215 .proc_handler = read_reset_stat,
89216 },
89217 {
89218 .procname = "rdma_stat_rq_prod",
89219 .data = &rdma_stat_rq_prod,
89220 - .maxlen = sizeof(atomic_t),
89221 + .maxlen = sizeof(atomic_unchecked_t),
89222 .mode = 0644,
89223 .proc_handler = read_reset_stat,
89224 },
89225 {
89226 .procname = "rdma_stat_sq_poll",
89227 .data = &rdma_stat_sq_poll,
89228 - .maxlen = sizeof(atomic_t),
89229 + .maxlen = sizeof(atomic_unchecked_t),
89230 .mode = 0644,
89231 .proc_handler = read_reset_stat,
89232 },
89233 {
89234 .procname = "rdma_stat_sq_prod",
89235 .data = &rdma_stat_sq_prod,
89236 - .maxlen = sizeof(atomic_t),
89237 + .maxlen = sizeof(atomic_unchecked_t),
89238 .mode = 0644,
89239 .proc_handler = read_reset_stat,
89240 },
89241 diff --git a/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c b/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
89242 index 0ce7552..d074459 100644
89243 --- a/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
89244 +++ b/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
89245 @@ -501,7 +501,7 @@ next_sge:
89246 svc_rdma_put_context(ctxt, 0);
89247 goto out;
89248 }
89249 - atomic_inc(&rdma_stat_read);
89250 + atomic_inc_unchecked(&rdma_stat_read);
89251
89252 if (read_wr.num_sge < chl_map->ch[ch_no].count) {
89253 chl_map->ch[ch_no].count -= read_wr.num_sge;
89254 @@ -611,7 +611,7 @@ int svc_rdma_recvfrom(struct svc_rqst *rqstp)
89255 dto_q);
89256 list_del_init(&ctxt->dto_q);
89257 } else {
89258 - atomic_inc(&rdma_stat_rq_starve);
89259 + atomic_inc_unchecked(&rdma_stat_rq_starve);
89260 clear_bit(XPT_DATA, &xprt->xpt_flags);
89261 ctxt = NULL;
89262 }
89263 @@ -631,7 +631,7 @@ int svc_rdma_recvfrom(struct svc_rqst *rqstp)
89264 dprintk("svcrdma: processing ctxt=%p on xprt=%p, rqstp=%p, status=%d\n",
89265 ctxt, rdma_xprt, rqstp, ctxt->wc_status);
89266 BUG_ON(ctxt->wc_status != IB_WC_SUCCESS);
89267 - atomic_inc(&rdma_stat_recv);
89268 + atomic_inc_unchecked(&rdma_stat_recv);
89269
89270 /* Build up the XDR from the receive buffers. */
89271 rdma_build_arg_xdr(rqstp, ctxt, ctxt->byte_len);
89272 diff --git a/net/sunrpc/xprtrdma/svc_rdma_sendto.c b/net/sunrpc/xprtrdma/svc_rdma_sendto.c
89273 index c1d124d..acfc59e 100644
89274 --- a/net/sunrpc/xprtrdma/svc_rdma_sendto.c
89275 +++ b/net/sunrpc/xprtrdma/svc_rdma_sendto.c
89276 @@ -362,7 +362,7 @@ static int send_write(struct svcxprt_rdma *xprt, struct svc_rqst *rqstp,
89277 write_wr.wr.rdma.remote_addr = to;
89278
89279 /* Post It */
89280 - atomic_inc(&rdma_stat_write);
89281 + atomic_inc_unchecked(&rdma_stat_write);
89282 if (svc_rdma_send(xprt, &write_wr))
89283 goto err;
89284 return 0;
89285 diff --git a/net/sunrpc/xprtrdma/svc_rdma_transport.c b/net/sunrpc/xprtrdma/svc_rdma_transport.c
89286 index 62e4f9b..dd3f2d7 100644
89287 --- a/net/sunrpc/xprtrdma/svc_rdma_transport.c
89288 +++ b/net/sunrpc/xprtrdma/svc_rdma_transport.c
89289 @@ -292,7 +292,7 @@ static void rq_cq_reap(struct svcxprt_rdma *xprt)
89290 return;
89291
89292 ib_req_notify_cq(xprt->sc_rq_cq, IB_CQ_NEXT_COMP);
89293 - atomic_inc(&rdma_stat_rq_poll);
89294 + atomic_inc_unchecked(&rdma_stat_rq_poll);
89295
89296 while ((ret = ib_poll_cq(xprt->sc_rq_cq, 1, &wc)) > 0) {
89297 ctxt = (struct svc_rdma_op_ctxt *)(unsigned long)wc.wr_id;
89298 @@ -314,7 +314,7 @@ static void rq_cq_reap(struct svcxprt_rdma *xprt)
89299 }
89300
89301 if (ctxt)
89302 - atomic_inc(&rdma_stat_rq_prod);
89303 + atomic_inc_unchecked(&rdma_stat_rq_prod);
89304
89305 set_bit(XPT_DATA, &xprt->sc_xprt.xpt_flags);
89306 /*
89307 @@ -386,7 +386,7 @@ static void sq_cq_reap(struct svcxprt_rdma *xprt)
89308 return;
89309
89310 ib_req_notify_cq(xprt->sc_sq_cq, IB_CQ_NEXT_COMP);
89311 - atomic_inc(&rdma_stat_sq_poll);
89312 + atomic_inc_unchecked(&rdma_stat_sq_poll);
89313 while ((ret = ib_poll_cq(cq, 1, &wc)) > 0) {
89314 if (wc.status != IB_WC_SUCCESS)
89315 /* Close the transport */
89316 @@ -404,7 +404,7 @@ static void sq_cq_reap(struct svcxprt_rdma *xprt)
89317 }
89318
89319 if (ctxt)
89320 - atomic_inc(&rdma_stat_sq_prod);
89321 + atomic_inc_unchecked(&rdma_stat_sq_prod);
89322 }
89323
89324 static void sq_comp_handler(struct ib_cq *cq, void *cq_context)
89325 @@ -1262,7 +1262,7 @@ int svc_rdma_send(struct svcxprt_rdma *xprt, struct ib_send_wr *wr)
89326 spin_lock_bh(&xprt->sc_lock);
89327 if (xprt->sc_sq_depth < atomic_read(&xprt->sc_sq_count) + wr_count) {
89328 spin_unlock_bh(&xprt->sc_lock);
89329 - atomic_inc(&rdma_stat_sq_starve);
89330 + atomic_inc_unchecked(&rdma_stat_sq_starve);
89331
89332 /* See if we can opportunistically reap SQ WR to make room */
89333 sq_cq_reap(xprt);
89334 diff --git a/net/sysctl_net.c b/net/sysctl_net.c
89335 index 9bc6db0..47ac8c0 100644
89336 --- a/net/sysctl_net.c
89337 +++ b/net/sysctl_net.c
89338 @@ -46,7 +46,7 @@ static int net_ctl_permissions(struct ctl_table_header *head,
89339 kgid_t root_gid = make_kgid(net->user_ns, 0);
89340
89341 /* Allow network administrator to have same access as root. */
89342 - if (ns_capable(net->user_ns, CAP_NET_ADMIN) ||
89343 + if (ns_capable_nolog(net->user_ns, CAP_NET_ADMIN) ||
89344 uid_eq(root_uid, current_uid())) {
89345 int mode = (table->mode >> 6) & 7;
89346 return (mode << 6) | (mode << 3) | mode;
89347 diff --git a/net/tipc/link.c b/net/tipc/link.c
89348 index daa6080..02d357f 100644
89349 --- a/net/tipc/link.c
89350 +++ b/net/tipc/link.c
89351 @@ -1201,7 +1201,7 @@ static int link_send_sections_long(struct tipc_port *sender,
89352 struct tipc_msg fragm_hdr;
89353 struct sk_buff *buf, *buf_chain, *prev;
89354 u32 fragm_crs, fragm_rest, hsz, sect_rest;
89355 - const unchar *sect_crs;
89356 + const unchar __user *sect_crs;
89357 int curr_sect;
89358 u32 fragm_no;
89359
89360 @@ -1242,7 +1242,7 @@ again:
89361
89362 if (!sect_rest) {
89363 sect_rest = msg_sect[++curr_sect].iov_len;
89364 - sect_crs = (const unchar *)msg_sect[curr_sect].iov_base;
89365 + sect_crs = (const unchar __user *)msg_sect[curr_sect].iov_base;
89366 }
89367
89368 if (sect_rest < fragm_rest)
89369 @@ -1261,7 +1261,7 @@ error:
89370 }
89371 } else
89372 skb_copy_to_linear_data_offset(buf, fragm_crs,
89373 - sect_crs, sz);
89374 + (const void __force_kernel *)sect_crs, sz);
89375 sect_crs += sz;
89376 sect_rest -= sz;
89377 fragm_crs += sz;
89378 diff --git a/net/tipc/msg.c b/net/tipc/msg.c
89379 index f2db8a8..9245aa4 100644
89380 --- a/net/tipc/msg.c
89381 +++ b/net/tipc/msg.c
89382 @@ -98,7 +98,7 @@ int tipc_msg_build(struct tipc_msg *hdr, struct iovec const *msg_sect,
89383 msg_sect[cnt].iov_len);
89384 else
89385 skb_copy_to_linear_data_offset(*buf, pos,
89386 - msg_sect[cnt].iov_base,
89387 + (const void __force_kernel *)msg_sect[cnt].iov_base,
89388 msg_sect[cnt].iov_len);
89389 pos += msg_sect[cnt].iov_len;
89390 }
89391 diff --git a/net/tipc/subscr.c b/net/tipc/subscr.c
89392 index 6b42d47..2ac24d5 100644
89393 --- a/net/tipc/subscr.c
89394 +++ b/net/tipc/subscr.c
89395 @@ -96,7 +96,7 @@ static void subscr_send_event(struct tipc_subscription *sub,
89396 {
89397 struct iovec msg_sect;
89398
89399 - msg_sect.iov_base = (void *)&sub->evt;
89400 + msg_sect.iov_base = (void __force_user *)&sub->evt;
89401 msg_sect.iov_len = sizeof(struct tipc_event);
89402
89403 sub->evt.event = htohl(event, sub->swap);
89404 diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
89405 index 5b5c876..6713b81 100644
89406 --- a/net/unix/af_unix.c
89407 +++ b/net/unix/af_unix.c
89408 @@ -786,6 +786,12 @@ static struct sock *unix_find_other(struct net *net,
89409 err = -ECONNREFUSED;
89410 if (!S_ISSOCK(inode->i_mode))
89411 goto put_fail;
89412 +
89413 + if (!gr_acl_handle_unix(path.dentry, path.mnt)) {
89414 + err = -EACCES;
89415 + goto put_fail;
89416 + }
89417 +
89418 u = unix_find_socket_byinode(inode);
89419 if (!u)
89420 goto put_fail;
89421 @@ -806,6 +812,13 @@ static struct sock *unix_find_other(struct net *net,
89422 if (u) {
89423 struct dentry *dentry;
89424 dentry = unix_sk(u)->path.dentry;
89425 +
89426 + if (!gr_handle_chroot_unix(pid_vnr(u->sk_peer_pid))) {
89427 + err = -EPERM;
89428 + sock_put(u);
89429 + goto fail;
89430 + }
89431 +
89432 if (dentry)
89433 touch_atime(&unix_sk(u)->path);
89434 } else
89435 @@ -839,12 +852,18 @@ static int unix_mknod(const char *sun_path, umode_t mode, struct path *res)
89436 */
89437 err = security_path_mknod(&path, dentry, mode, 0);
89438 if (!err) {
89439 + if (!gr_acl_handle_mknod(dentry, path.dentry, path.mnt, mode)) {
89440 + err = -EACCES;
89441 + goto out;
89442 + }
89443 err = vfs_mknod(path.dentry->d_inode, dentry, mode, 0);
89444 if (!err) {
89445 res->mnt = mntget(path.mnt);
89446 res->dentry = dget(dentry);
89447 + gr_handle_create(dentry, path.mnt);
89448 }
89449 }
89450 +out:
89451 done_path_create(&path, dentry);
89452 return err;
89453 }
89454 @@ -2326,9 +2345,13 @@ static int unix_seq_show(struct seq_file *seq, void *v)
89455 seq_puts(seq, "Num RefCount Protocol Flags Type St "
89456 "Inode Path\n");
89457 else {
89458 - struct sock *s = v;
89459 + struct sock *s = v, *peer;
89460 struct unix_sock *u = unix_sk(s);
89461 unix_state_lock(s);
89462 + peer = unix_peer(s);
89463 + unix_state_unlock(s);
89464 +
89465 + unix_state_double_lock(s, peer);
89466
89467 seq_printf(seq, "%pK: %08X %08X %08X %04X %02X %5lu",
89468 s,
89469 @@ -2355,8 +2378,10 @@ static int unix_seq_show(struct seq_file *seq, void *v)
89470 }
89471 for ( ; i < len; i++)
89472 seq_putc(seq, u->addr->name->sun_path[i]);
89473 - }
89474 - unix_state_unlock(s);
89475 + } else if (peer)
89476 + seq_printf(seq, " P%lu", sock_i_ino(peer));
89477 +
89478 + unix_state_double_unlock(s, peer);
89479 seq_putc(seq, '\n');
89480 }
89481
89482 diff --git a/net/unix/sysctl_net_unix.c b/net/unix/sysctl_net_unix.c
89483 index 8800604..0526440 100644
89484 --- a/net/unix/sysctl_net_unix.c
89485 +++ b/net/unix/sysctl_net_unix.c
89486 @@ -28,7 +28,7 @@ static ctl_table unix_table[] = {
89487
89488 int __net_init unix_sysctl_register(struct net *net)
89489 {
89490 - struct ctl_table *table;
89491 + ctl_table_no_const *table;
89492
89493 table = kmemdup(unix_table, sizeof(unix_table), GFP_KERNEL);
89494 if (table == NULL)
89495 diff --git a/net/wireless/wext-core.c b/net/wireless/wext-core.c
89496 index c8717c1..08539f5 100644
89497 --- a/net/wireless/wext-core.c
89498 +++ b/net/wireless/wext-core.c
89499 @@ -748,8 +748,7 @@ static int ioctl_standard_iw_point(struct iw_point *iwp, unsigned int cmd,
89500 */
89501
89502 /* Support for very large requests */
89503 - if ((descr->flags & IW_DESCR_FLAG_NOMAX) &&
89504 - (user_length > descr->max_tokens)) {
89505 + if (user_length > descr->max_tokens) {
89506 /* Allow userspace to GET more than max so
89507 * we can support any size GET requests.
89508 * There is still a limit : -ENOMEM.
89509 @@ -788,22 +787,6 @@ static int ioctl_standard_iw_point(struct iw_point *iwp, unsigned int cmd,
89510 }
89511 }
89512
89513 - if (IW_IS_GET(cmd) && !(descr->flags & IW_DESCR_FLAG_NOMAX)) {
89514 - /*
89515 - * If this is a GET, but not NOMAX, it means that the extra
89516 - * data is not bounded by userspace, but by max_tokens. Thus
89517 - * set the length to max_tokens. This matches the extra data
89518 - * allocation.
89519 - * The driver should fill it with the number of tokens it
89520 - * provided, and it may check iwp->length rather than having
89521 - * knowledge of max_tokens. If the driver doesn't change the
89522 - * iwp->length, this ioctl just copies back max_token tokens
89523 - * filled with zeroes. Hopefully the driver isn't claiming
89524 - * them to be valid data.
89525 - */
89526 - iwp->length = descr->max_tokens;
89527 - }
89528 -
89529 err = handler(dev, info, (union iwreq_data *) iwp, extra);
89530
89531 iwp->length += essid_compat;
89532 diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c
89533 index 07c5857..fde4018 100644
89534 --- a/net/xfrm/xfrm_policy.c
89535 +++ b/net/xfrm/xfrm_policy.c
89536 @@ -317,7 +317,7 @@ static void xfrm_policy_kill(struct xfrm_policy *policy)
89537 {
89538 policy->walk.dead = 1;
89539
89540 - atomic_inc(&policy->genid);
89541 + atomic_inc_unchecked(&policy->genid);
89542
89543 if (del_timer(&policy->timer))
89544 xfrm_pol_put(policy);
89545 @@ -601,7 +601,7 @@ int xfrm_policy_insert(int dir, struct xfrm_policy *policy, int excl)
89546 hlist_add_head(&policy->bydst, chain);
89547 xfrm_pol_hold(policy);
89548 net->xfrm.policy_count[dir]++;
89549 - atomic_inc(&flow_cache_genid);
89550 + atomic_inc_unchecked(&flow_cache_genid);
89551 rt_genid_bump(net);
89552 if (delpol)
89553 __xfrm_policy_unlink(delpol, dir);
89554 @@ -1550,7 +1550,7 @@ free_dst:
89555 goto out;
89556 }
89557
89558 -static int inline
89559 +static inline int
89560 xfrm_dst_alloc_copy(void **target, const void *src, int size)
89561 {
89562 if (!*target) {
89563 @@ -1562,7 +1562,7 @@ xfrm_dst_alloc_copy(void **target, const void *src, int size)
89564 return 0;
89565 }
89566
89567 -static int inline
89568 +static inline int
89569 xfrm_dst_update_parent(struct dst_entry *dst, const struct xfrm_selector *sel)
89570 {
89571 #ifdef CONFIG_XFRM_SUB_POLICY
89572 @@ -1574,7 +1574,7 @@ xfrm_dst_update_parent(struct dst_entry *dst, const struct xfrm_selector *sel)
89573 #endif
89574 }
89575
89576 -static int inline
89577 +static inline int
89578 xfrm_dst_update_origin(struct dst_entry *dst, const struct flowi *fl)
89579 {
89580 #ifdef CONFIG_XFRM_SUB_POLICY
89581 @@ -1668,7 +1668,7 @@ xfrm_resolve_and_create_bundle(struct xfrm_policy **pols, int num_pols,
89582
89583 xdst->num_pols = num_pols;
89584 memcpy(xdst->pols, pols, sizeof(struct xfrm_policy*) * num_pols);
89585 - xdst->policy_genid = atomic_read(&pols[0]->genid);
89586 + xdst->policy_genid = atomic_read_unchecked(&pols[0]->genid);
89587
89588 return xdst;
89589 }
89590 @@ -2369,7 +2369,7 @@ static int xfrm_bundle_ok(struct xfrm_dst *first)
89591 if (xdst->xfrm_genid != dst->xfrm->genid)
89592 return 0;
89593 if (xdst->num_pols > 0 &&
89594 - xdst->policy_genid != atomic_read(&xdst->pols[0]->genid))
89595 + xdst->policy_genid != atomic_read_unchecked(&xdst->pols[0]->genid))
89596 return 0;
89597
89598 mtu = dst_mtu(dst->child);
89599 @@ -2457,8 +2457,11 @@ int xfrm_policy_register_afinfo(struct xfrm_policy_afinfo *afinfo)
89600 dst_ops->link_failure = xfrm_link_failure;
89601 if (likely(dst_ops->neigh_lookup == NULL))
89602 dst_ops->neigh_lookup = xfrm_neigh_lookup;
89603 - if (likely(afinfo->garbage_collect == NULL))
89604 - afinfo->garbage_collect = xfrm_garbage_collect_deferred;
89605 + if (likely(afinfo->garbage_collect == NULL)) {
89606 + pax_open_kernel();
89607 + *(void **)&afinfo->garbage_collect = xfrm_garbage_collect_deferred;
89608 + pax_close_kernel();
89609 + }
89610 rcu_assign_pointer(xfrm_policy_afinfo[afinfo->family], afinfo);
89611 }
89612 spin_unlock(&xfrm_policy_afinfo_lock);
89613 @@ -2512,7 +2515,9 @@ int xfrm_policy_unregister_afinfo(struct xfrm_policy_afinfo *afinfo)
89614 dst_ops->check = NULL;
89615 dst_ops->negative_advice = NULL;
89616 dst_ops->link_failure = NULL;
89617 - afinfo->garbage_collect = NULL;
89618 + pax_open_kernel();
89619 + *(void **)&afinfo->garbage_collect = NULL;
89620 + pax_close_kernel();
89621 }
89622 return err;
89623 }
89624 @@ -2896,7 +2901,7 @@ static int xfrm_policy_migrate(struct xfrm_policy *pol,
89625 sizeof(pol->xfrm_vec[i].saddr));
89626 pol->xfrm_vec[i].encap_family = mp->new_family;
89627 /* flush bundles */
89628 - atomic_inc(&pol->genid);
89629 + atomic_inc_unchecked(&pol->genid);
89630 }
89631 }
89632
89633 diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c
89634 index 3459692..e7cdb1a 100644
89635 --- a/net/xfrm/xfrm_state.c
89636 +++ b/net/xfrm/xfrm_state.c
89637 @@ -194,11 +194,13 @@ int xfrm_register_type(const struct xfrm_type *type, unsigned short family)
89638
89639 if (unlikely(afinfo == NULL))
89640 return -EAFNOSUPPORT;
89641 - typemap = afinfo->type_map;
89642 + typemap = (const struct xfrm_type **)afinfo->type_map;
89643
89644 - if (likely(typemap[type->proto] == NULL))
89645 + if (likely(typemap[type->proto] == NULL)) {
89646 + pax_open_kernel();
89647 typemap[type->proto] = type;
89648 - else
89649 + pax_close_kernel();
89650 + } else
89651 err = -EEXIST;
89652 xfrm_state_unlock_afinfo(afinfo);
89653 return err;
89654 @@ -213,12 +215,15 @@ int xfrm_unregister_type(const struct xfrm_type *type, unsigned short family)
89655
89656 if (unlikely(afinfo == NULL))
89657 return -EAFNOSUPPORT;
89658 - typemap = afinfo->type_map;
89659 + typemap = (const struct xfrm_type **)afinfo->type_map;
89660
89661 if (unlikely(typemap[type->proto] != type))
89662 err = -ENOENT;
89663 - else
89664 + else {
89665 + pax_open_kernel();
89666 typemap[type->proto] = NULL;
89667 + pax_close_kernel();
89668 + }
89669 xfrm_state_unlock_afinfo(afinfo);
89670 return err;
89671 }
89672 @@ -227,7 +232,6 @@ EXPORT_SYMBOL(xfrm_unregister_type);
89673 static const struct xfrm_type *xfrm_get_type(u8 proto, unsigned short family)
89674 {
89675 struct xfrm_state_afinfo *afinfo;
89676 - const struct xfrm_type **typemap;
89677 const struct xfrm_type *type;
89678 int modload_attempted = 0;
89679
89680 @@ -235,9 +239,8 @@ retry:
89681 afinfo = xfrm_state_get_afinfo(family);
89682 if (unlikely(afinfo == NULL))
89683 return NULL;
89684 - typemap = afinfo->type_map;
89685
89686 - type = typemap[proto];
89687 + type = afinfo->type_map[proto];
89688 if (unlikely(type && !try_module_get(type->owner)))
89689 type = NULL;
89690 if (!type && !modload_attempted) {
89691 @@ -270,7 +273,7 @@ int xfrm_register_mode(struct xfrm_mode *mode, int family)
89692 return -EAFNOSUPPORT;
89693
89694 err = -EEXIST;
89695 - modemap = afinfo->mode_map;
89696 + modemap = (struct xfrm_mode **)afinfo->mode_map;
89697 if (modemap[mode->encap])
89698 goto out;
89699
89700 @@ -278,8 +281,10 @@ int xfrm_register_mode(struct xfrm_mode *mode, int family)
89701 if (!try_module_get(afinfo->owner))
89702 goto out;
89703
89704 - mode->afinfo = afinfo;
89705 + pax_open_kernel();
89706 + *(const void **)&mode->afinfo = afinfo;
89707 modemap[mode->encap] = mode;
89708 + pax_close_kernel();
89709 err = 0;
89710
89711 out:
89712 @@ -302,9 +307,11 @@ int xfrm_unregister_mode(struct xfrm_mode *mode, int family)
89713 return -EAFNOSUPPORT;
89714
89715 err = -ENOENT;
89716 - modemap = afinfo->mode_map;
89717 + modemap = (struct xfrm_mode **)afinfo->mode_map;
89718 if (likely(modemap[mode->encap] == mode)) {
89719 + pax_open_kernel();
89720 modemap[mode->encap] = NULL;
89721 + pax_close_kernel();
89722 module_put(mode->afinfo->owner);
89723 err = 0;
89724 }
89725 diff --git a/net/xfrm/xfrm_sysctl.c b/net/xfrm/xfrm_sysctl.c
89726 index 05a6e3d..6716ec9 100644
89727 --- a/net/xfrm/xfrm_sysctl.c
89728 +++ b/net/xfrm/xfrm_sysctl.c
89729 @@ -42,7 +42,7 @@ static struct ctl_table xfrm_table[] = {
89730
89731 int __net_init xfrm_sysctl_init(struct net *net)
89732 {
89733 - struct ctl_table *table;
89734 + ctl_table_no_const *table;
89735
89736 __xfrm_sysctl_init(net);
89737
89738 diff --git a/scripts/Makefile.build b/scripts/Makefile.build
89739 index 0e801c3..5c8ad3b 100644
89740 --- a/scripts/Makefile.build
89741 +++ b/scripts/Makefile.build
89742 @@ -111,7 +111,7 @@ endif
89743 endif
89744
89745 # Do not include host rules unless needed
89746 -ifneq ($(hostprogs-y)$(hostprogs-m),)
89747 +ifneq ($(hostprogs-y)$(hostprogs-m)$(hostlibs-y)$(hostlibs-m)$(hostcxxlibs-y)$(hostcxxlibs-m),)
89748 include scripts/Makefile.host
89749 endif
89750
89751 diff --git a/scripts/Makefile.clean b/scripts/Makefile.clean
89752 index 686cb0d..9d653bf 100644
89753 --- a/scripts/Makefile.clean
89754 +++ b/scripts/Makefile.clean
89755 @@ -43,7 +43,8 @@ subdir-ymn := $(addprefix $(obj)/,$(subdir-ymn))
89756 __clean-files := $(extra-y) $(always) \
89757 $(targets) $(clean-files) \
89758 $(host-progs) \
89759 - $(hostprogs-y) $(hostprogs-m) $(hostprogs-)
89760 + $(hostprogs-y) $(hostprogs-m) $(hostprogs-) \
89761 + $(hostlibs-y) $(hostlibs-m) $(hostlibs-)
89762
89763 __clean-files := $(filter-out $(no-clean-files), $(__clean-files))
89764
89765 diff --git a/scripts/Makefile.host b/scripts/Makefile.host
89766 index 1ac414f..38575f7 100644
89767 --- a/scripts/Makefile.host
89768 +++ b/scripts/Makefile.host
89769 @@ -31,6 +31,8 @@
89770 # Note: Shared libraries consisting of C++ files are not supported
89771
89772 __hostprogs := $(sort $(hostprogs-y) $(hostprogs-m))
89773 +__hostlibs := $(sort $(hostlibs-y) $(hostlibs-m))
89774 +__hostcxxlibs := $(sort $(hostcxxlibs-y) $(hostcxxlibs-m))
89775
89776 # C code
89777 # Executables compiled from a single .c file
89778 @@ -54,11 +56,15 @@ host-cxxobjs := $(sort $(foreach m,$(host-cxxmulti),$($(m)-cxxobjs)))
89779 # Shared libaries (only .c supported)
89780 # Shared libraries (.so) - all .so files referenced in "xxx-objs"
89781 host-cshlib := $(sort $(filter %.so, $(host-cobjs)))
89782 +host-cshlib += $(sort $(filter %.so, $(__hostlibs)))
89783 +host-cxxshlib := $(sort $(filter %.so, $(__hostcxxlibs)))
89784 # Remove .so files from "xxx-objs"
89785 host-cobjs := $(filter-out %.so,$(host-cobjs))
89786 +host-cxxobjs := $(filter-out %.so,$(host-cxxobjs))
89787
89788 -#Object (.o) files used by the shared libaries
89789 +# Object (.o) files used by the shared libaries
89790 host-cshobjs := $(sort $(foreach m,$(host-cshlib),$($(m:.so=-objs))))
89791 +host-cxxshobjs := $(sort $(foreach m,$(host-cxxshlib),$($(m:.so=-objs))))
89792
89793 # output directory for programs/.o files
89794 # hostprogs-y := tools/build may have been specified. Retrieve directory
89795 @@ -82,7 +88,9 @@ host-cobjs := $(addprefix $(obj)/,$(host-cobjs))
89796 host-cxxmulti := $(addprefix $(obj)/,$(host-cxxmulti))
89797 host-cxxobjs := $(addprefix $(obj)/,$(host-cxxobjs))
89798 host-cshlib := $(addprefix $(obj)/,$(host-cshlib))
89799 +host-cxxshlib := $(addprefix $(obj)/,$(host-cxxshlib))
89800 host-cshobjs := $(addprefix $(obj)/,$(host-cshobjs))
89801 +host-cxxshobjs := $(addprefix $(obj)/,$(host-cxxshobjs))
89802 host-objdirs := $(addprefix $(obj)/,$(host-objdirs))
89803
89804 obj-dirs += $(host-objdirs)
89805 @@ -156,6 +164,13 @@ quiet_cmd_host-cshobjs = HOSTCC -fPIC $@
89806 $(host-cshobjs): $(obj)/%.o: $(src)/%.c FORCE
89807 $(call if_changed_dep,host-cshobjs)
89808
89809 +# Compile .c file, create position independent .o file
89810 +# host-cxxshobjs -> .o
89811 +quiet_cmd_host-cxxshobjs = HOSTCXX -fPIC $@
89812 + cmd_host-cxxshobjs = $(HOSTCXX) $(hostcxx_flags) -fPIC -c -o $@ $<
89813 +$(host-cxxshobjs): $(obj)/%.o: $(src)/%.c FORCE
89814 + $(call if_changed_dep,host-cxxshobjs)
89815 +
89816 # Link a shared library, based on position independent .o files
89817 # *.o -> .so shared library (host-cshlib)
89818 quiet_cmd_host-cshlib = HOSTLLD -shared $@
89819 @@ -165,6 +180,15 @@ quiet_cmd_host-cshlib = HOSTLLD -shared $@
89820 $(host-cshlib): $(obj)/%: $(host-cshobjs) FORCE
89821 $(call if_changed,host-cshlib)
89822
89823 +# Link a shared library, based on position independent .o files
89824 +# *.o -> .so shared library (host-cxxshlib)
89825 +quiet_cmd_host-cxxshlib = HOSTLLD -shared $@
89826 + cmd_host-cxxshlib = $(HOSTCXX) $(HOSTLDFLAGS) -shared -o $@ \
89827 + $(addprefix $(obj)/,$($(@F:.so=-objs))) \
89828 + $(HOST_LOADLIBES) $(HOSTLOADLIBES_$(@F))
89829 +$(host-cxxshlib): $(obj)/%: $(host-cxxshobjs) FORCE
89830 + $(call if_changed,host-cxxshlib)
89831 +
89832 targets += $(host-csingle) $(host-cmulti) $(host-cobjs)\
89833 - $(host-cxxmulti) $(host-cxxobjs) $(host-cshlib) $(host-cshobjs)
89834 + $(host-cxxmulti) $(host-cxxobjs) $(host-cshlib) $(host-cshobjs) $(host-cxxshlib) $(host-cxxshobjs)
89835
89836 diff --git a/scripts/basic/fixdep.c b/scripts/basic/fixdep.c
89837 index cb1f50c..cef2a7c 100644
89838 --- a/scripts/basic/fixdep.c
89839 +++ b/scripts/basic/fixdep.c
89840 @@ -161,7 +161,7 @@ static unsigned int strhash(const char *str, unsigned int sz)
89841 /*
89842 * Lookup a value in the configuration string.
89843 */
89844 -static int is_defined_config(const char *name, int len, unsigned int hash)
89845 +static int is_defined_config(const char *name, unsigned int len, unsigned int hash)
89846 {
89847 struct item *aux;
89848
89849 @@ -211,10 +211,10 @@ static void clear_config(void)
89850 /*
89851 * Record the use of a CONFIG_* word.
89852 */
89853 -static void use_config(const char *m, int slen)
89854 +static void use_config(const char *m, unsigned int slen)
89855 {
89856 unsigned int hash = strhash(m, slen);
89857 - int c, i;
89858 + unsigned int c, i;
89859
89860 if (is_defined_config(m, slen, hash))
89861 return;
89862 @@ -235,9 +235,9 @@ static void use_config(const char *m, int slen)
89863
89864 static void parse_config_file(const char *map, size_t len)
89865 {
89866 - const int *end = (const int *) (map + len);
89867 + const unsigned int *end = (const unsigned int *) (map + len);
89868 /* start at +1, so that p can never be < map */
89869 - const int *m = (const int *) map + 1;
89870 + const unsigned int *m = (const unsigned int *) map + 1;
89871 const char *p, *q;
89872
89873 for (; m < end; m++) {
89874 @@ -406,7 +406,7 @@ static void print_deps(void)
89875 static void traps(void)
89876 {
89877 static char test[] __attribute__((aligned(sizeof(int)))) = "CONF";
89878 - int *p = (int *)test;
89879 + unsigned int *p = (unsigned int *)test;
89880
89881 if (*p != INT_CONF) {
89882 fprintf(stderr, "fixdep: sizeof(int) != 4 or wrong endianess? %#x\n",
89883 diff --git a/scripts/gcc-plugin.sh b/scripts/gcc-plugin.sh
89884 new file mode 100644
89885 index 0000000..5e0222d
89886 --- /dev/null
89887 +++ b/scripts/gcc-plugin.sh
89888 @@ -0,0 +1,17 @@
89889 +#!/bin/bash
89890 +plugincc=`$1 -E -shared - -o /dev/null -I\`$3 -print-file-name=plugin\`/include 2>&1 <<EOF
89891 +#include "gcc-plugin.h"
89892 +#include "tree.h"
89893 +#include "tm.h"
89894 +#include "rtl.h"
89895 +#ifdef ENABLE_BUILD_WITH_CXX
89896 +#warning $2
89897 +#else
89898 +#warning $1
89899 +#endif
89900 +EOF`
89901 +if [ $? -eq 0 ]
89902 +then
89903 + [[ "$plugincc" =~ "$1" ]] && echo "$1"
89904 + [[ "$plugincc" =~ "$2" ]] && echo "$2"
89905 +fi
89906 diff --git a/scripts/link-vmlinux.sh b/scripts/link-vmlinux.sh
89907 index b3d907e..a4782ab 100644
89908 --- a/scripts/link-vmlinux.sh
89909 +++ b/scripts/link-vmlinux.sh
89910 @@ -152,7 +152,7 @@ else
89911 fi;
89912
89913 # final build of init/
89914 -${MAKE} -f "${srctree}/scripts/Makefile.build" obj=init
89915 +${MAKE} -f "${srctree}/scripts/Makefile.build" obj=init GCC_PLUGINS_CFLAGS="${GCC_PLUGINS_CFLAGS}" GCC_PLUGINS_AFLAGS="${GCC_PLUGINS_AFLAGS}"
89916
89917 kallsymso=""
89918 kallsyms_vmlinux=""
89919 diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c
89920 index df4fc23..0ea719d 100644
89921 --- a/scripts/mod/file2alias.c
89922 +++ b/scripts/mod/file2alias.c
89923 @@ -128,7 +128,7 @@ static void device_id_check(const char *modname, const char *device_id,
89924 unsigned long size, unsigned long id_size,
89925 void *symval)
89926 {
89927 - int i;
89928 + unsigned int i;
89929
89930 if (size % id_size || size < id_size) {
89931 if (cross_build != 0)
89932 @@ -158,7 +158,7 @@ static void device_id_check(const char *modname, const char *device_id,
89933 /* USB is special because the bcdDevice can be matched against a numeric range */
89934 /* Looks like "usb:vNpNdNdcNdscNdpNicNiscNipNinN" */
89935 static void do_usb_entry(struct usb_device_id *id,
89936 - unsigned int bcdDevice_initial, int bcdDevice_initial_digits,
89937 + unsigned int bcdDevice_initial, unsigned int bcdDevice_initial_digits,
89938 unsigned char range_lo, unsigned char range_hi,
89939 unsigned char max, struct module *mod)
89940 {
89941 @@ -262,7 +262,7 @@ static void do_usb_entry_multi(struct usb_device_id *id, struct module *mod)
89942 {
89943 unsigned int devlo, devhi;
89944 unsigned char chi, clo, max;
89945 - int ndigits;
89946 + unsigned int ndigits;
89947
89948 id->match_flags = TO_NATIVE(id->match_flags);
89949 id->idVendor = TO_NATIVE(id->idVendor);
89950 @@ -507,7 +507,7 @@ static void do_pnp_device_entry(void *symval, unsigned long size,
89951 for (i = 0; i < count; i++) {
89952 const char *id = (char *)devs[i].id;
89953 char acpi_id[sizeof(devs[0].id)];
89954 - int j;
89955 + unsigned int j;
89956
89957 buf_printf(&mod->dev_table_buf,
89958 "MODULE_ALIAS(\"pnp:d%s*\");\n", id);
89959 @@ -537,7 +537,7 @@ static void do_pnp_card_entries(void *symval, unsigned long size,
89960
89961 for (j = 0; j < PNP_MAX_DEVICES; j++) {
89962 const char *id = (char *)card->devs[j].id;
89963 - int i2, j2;
89964 + unsigned int i2, j2;
89965 int dup = 0;
89966
89967 if (!id[0])
89968 @@ -563,7 +563,7 @@ static void do_pnp_card_entries(void *symval, unsigned long size,
89969 /* add an individual alias for every device entry */
89970 if (!dup) {
89971 char acpi_id[sizeof(card->devs[0].id)];
89972 - int k;
89973 + unsigned int k;
89974
89975 buf_printf(&mod->dev_table_buf,
89976 "MODULE_ALIAS(\"pnp:d%s*\");\n", id);
89977 @@ -888,7 +888,7 @@ static void dmi_ascii_filter(char *d, const char *s)
89978 static int do_dmi_entry(const char *filename, struct dmi_system_id *id,
89979 char *alias)
89980 {
89981 - int i, j;
89982 + unsigned int i, j;
89983
89984 sprintf(alias, "dmi*");
89985
89986 diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
89987 index ff36c50..7ab4fa9 100644
89988 --- a/scripts/mod/modpost.c
89989 +++ b/scripts/mod/modpost.c
89990 @@ -929,6 +929,7 @@ enum mismatch {
89991 ANY_INIT_TO_ANY_EXIT,
89992 ANY_EXIT_TO_ANY_INIT,
89993 EXPORT_TO_INIT_EXIT,
89994 + DATA_TO_TEXT
89995 };
89996
89997 struct sectioncheck {
89998 @@ -1043,6 +1044,12 @@ const struct sectioncheck sectioncheck[] = {
89999 .tosec = { INIT_SECTIONS, EXIT_SECTIONS, NULL },
90000 .mismatch = EXPORT_TO_INIT_EXIT,
90001 .symbol_white_list = { DEFAULT_SYMBOL_WHITE_LIST, NULL },
90002 +},
90003 +/* Do not reference code from writable data */
90004 +{
90005 + .fromsec = { DATA_SECTIONS, NULL },
90006 + .tosec = { TEXT_SECTIONS, NULL },
90007 + .mismatch = DATA_TO_TEXT
90008 }
90009 };
90010
90011 @@ -1165,10 +1172,10 @@ static Elf_Sym *find_elf_symbol(struct elf_info *elf, Elf64_Sword addr,
90012 continue;
90013 if (ELF_ST_TYPE(sym->st_info) == STT_SECTION)
90014 continue;
90015 - if (sym->st_value == addr)
90016 - return sym;
90017 /* Find a symbol nearby - addr are maybe negative */
90018 d = sym->st_value - addr;
90019 + if (d == 0)
90020 + return sym;
90021 if (d < 0)
90022 d = addr - sym->st_value;
90023 if (d < distance) {
90024 @@ -1447,6 +1454,14 @@ static void report_sec_mismatch(const char *modname,
90025 tosym, prl_to, prl_to, tosym);
90026 free(prl_to);
90027 break;
90028 + case DATA_TO_TEXT:
90029 +#if 0
90030 + fprintf(stderr,
90031 + "The %s %s:%s references\n"
90032 + "the %s %s:%s%s\n",
90033 + from, fromsec, fromsym, to, tosec, tosym, to_p);
90034 +#endif
90035 + break;
90036 }
90037 fprintf(stderr, "\n");
90038 }
90039 @@ -1681,7 +1696,7 @@ static void section_rel(const char *modname, struct elf_info *elf,
90040 static void check_sec_ref(struct module *mod, const char *modname,
90041 struct elf_info *elf)
90042 {
90043 - int i;
90044 + unsigned int i;
90045 Elf_Shdr *sechdrs = elf->sechdrs;
90046
90047 /* Walk through all sections */
90048 @@ -1779,7 +1794,7 @@ void __attribute__((format(printf, 2, 3))) buf_printf(struct buffer *buf,
90049 va_end(ap);
90050 }
90051
90052 -void buf_write(struct buffer *buf, const char *s, int len)
90053 +void buf_write(struct buffer *buf, const char *s, unsigned int len)
90054 {
90055 if (buf->size - buf->pos < len) {
90056 buf->size += len + SZ;
90057 @@ -1997,7 +2012,7 @@ static void write_if_changed(struct buffer *b, const char *fname)
90058 if (fstat(fileno(file), &st) < 0)
90059 goto close_write;
90060
90061 - if (st.st_size != b->pos)
90062 + if (st.st_size != (off_t)b->pos)
90063 goto close_write;
90064
90065 tmp = NOFAIL(malloc(b->pos));
90066 diff --git a/scripts/mod/modpost.h b/scripts/mod/modpost.h
90067 index 51207e4..f7d603d 100644
90068 --- a/scripts/mod/modpost.h
90069 +++ b/scripts/mod/modpost.h
90070 @@ -92,15 +92,15 @@ void *do_nofail(void *ptr, const char *expr);
90071
90072 struct buffer {
90073 char *p;
90074 - int pos;
90075 - int size;
90076 + unsigned int pos;
90077 + unsigned int size;
90078 };
90079
90080 void __attribute__((format(printf, 2, 3)))
90081 buf_printf(struct buffer *buf, const char *fmt, ...);
90082
90083 void
90084 -buf_write(struct buffer *buf, const char *s, int len);
90085 +buf_write(struct buffer *buf, const char *s, unsigned int len);
90086
90087 struct module {
90088 struct module *next;
90089 diff --git a/scripts/mod/sumversion.c b/scripts/mod/sumversion.c
90090 index 9dfcd6d..099068e 100644
90091 --- a/scripts/mod/sumversion.c
90092 +++ b/scripts/mod/sumversion.c
90093 @@ -470,7 +470,7 @@ static void write_version(const char *filename, const char *sum,
90094 goto out;
90095 }
90096
90097 - if (write(fd, sum, strlen(sum)+1) != strlen(sum)+1) {
90098 + if (write(fd, sum, strlen(sum)+1) != (ssize_t)strlen(sum)+1) {
90099 warn("writing sum in %s failed: %s\n",
90100 filename, strerror(errno));
90101 goto out;
90102 diff --git a/scripts/package/builddeb b/scripts/package/builddeb
90103 index acb8650..b8c5f02 100644
90104 --- a/scripts/package/builddeb
90105 +++ b/scripts/package/builddeb
90106 @@ -246,6 +246,7 @@ fi
90107 (cd $srctree; find . -name Makefile\* -o -name Kconfig\* -o -name \*.pl > "$objtree/debian/hdrsrcfiles")
90108 (cd $srctree; find arch/$SRCARCH/include include scripts -type f >> "$objtree/debian/hdrsrcfiles")
90109 (cd $objtree; find arch/$SRCARCH/include .config Module.symvers include scripts -type f >> "$objtree/debian/hdrobjfiles")
90110 +(cd $objtree; find tools/gcc -name \*.so >> "$objtree/debian/hdrobjfiles")
90111 destdir=$kernel_headers_dir/usr/src/linux-headers-$version
90112 mkdir -p "$destdir"
90113 (cd $srctree; tar -c -f - -T "$objtree/debian/hdrsrcfiles") | (cd $destdir; tar -xf -)
90114 diff --git a/scripts/pnmtologo.c b/scripts/pnmtologo.c
90115 index 68bb4ef..2f419e1 100644
90116 --- a/scripts/pnmtologo.c
90117 +++ b/scripts/pnmtologo.c
90118 @@ -244,14 +244,14 @@ static void write_header(void)
90119 fprintf(out, " * Linux logo %s\n", logoname);
90120 fputs(" */\n\n", out);
90121 fputs("#include <linux/linux_logo.h>\n\n", out);
90122 - fprintf(out, "static unsigned char %s_data[] __initdata = {\n",
90123 + fprintf(out, "static unsigned char %s_data[] = {\n",
90124 logoname);
90125 }
90126
90127 static void write_footer(void)
90128 {
90129 fputs("\n};\n\n", out);
90130 - fprintf(out, "const struct linux_logo %s __initconst = {\n", logoname);
90131 + fprintf(out, "const struct linux_logo %s = {\n", logoname);
90132 fprintf(out, "\t.type\t\t= %s,\n", logo_types[logo_type]);
90133 fprintf(out, "\t.width\t\t= %d,\n", logo_width);
90134 fprintf(out, "\t.height\t\t= %d,\n", logo_height);
90135 @@ -381,7 +381,7 @@ static void write_logo_clut224(void)
90136 fputs("\n};\n\n", out);
90137
90138 /* write logo clut */
90139 - fprintf(out, "static unsigned char %s_clut[] __initdata = {\n",
90140 + fprintf(out, "static unsigned char %s_clut[] = {\n",
90141 logoname);
90142 write_hex_cnt = 0;
90143 for (i = 0; i < logo_clutsize; i++) {
90144 diff --git a/scripts/sortextable.h b/scripts/sortextable.h
90145 index e4fd45b..2eeb5c4 100644
90146 --- a/scripts/sortextable.h
90147 +++ b/scripts/sortextable.h
90148 @@ -106,9 +106,9 @@ do_func(Elf_Ehdr *ehdr, char const *const fname, table_sort_t custom_sort)
90149 const char *secstrtab;
90150 const char *strtab;
90151 char *extab_image;
90152 - int extab_index = 0;
90153 - int i;
90154 - int idx;
90155 + unsigned int extab_index = 0;
90156 + unsigned int i;
90157 + unsigned int idx;
90158
90159 shdr = (Elf_Shdr *)((char *)ehdr + _r(&ehdr->e_shoff));
90160 shstrtab_sec = shdr + r2(&ehdr->e_shstrndx);
90161 diff --git a/security/Kconfig b/security/Kconfig
90162 index e9c6ac7..952353c 100644
90163 --- a/security/Kconfig
90164 +++ b/security/Kconfig
90165 @@ -4,6 +4,925 @@
90166
90167 menu "Security options"
90168
90169 +menu "Grsecurity"
90170 +
90171 + config ARCH_TRACK_EXEC_LIMIT
90172 + bool
90173 +
90174 + config PAX_KERNEXEC_PLUGIN
90175 + bool
90176 +
90177 + config PAX_PER_CPU_PGD
90178 + bool
90179 +
90180 + config TASK_SIZE_MAX_SHIFT
90181 + int
90182 + depends on X86_64
90183 + default 47 if !PAX_PER_CPU_PGD
90184 + default 42 if PAX_PER_CPU_PGD
90185 +
90186 + config PAX_ENABLE_PAE
90187 + bool
90188 + default y if (X86_32 && (MPENTIUM4 || MK8 || MPSC || MCORE2 || MATOM))
90189 +
90190 + config PAX_USERCOPY_SLABS
90191 + bool
90192 +
90193 +config GRKERNSEC
90194 + bool "Grsecurity"
90195 + select CRYPTO
90196 + select CRYPTO_SHA256
90197 + select PROC_FS
90198 + select STOP_MACHINE
90199 + help
90200 + If you say Y here, you will be able to configure many features
90201 + that will enhance the security of your system. It is highly
90202 + recommended that you say Y here and read through the help
90203 + for each option so that you fully understand the features and
90204 + can evaluate their usefulness for your machine.
90205 +
90206 +choice
90207 + prompt "Configuration Method"
90208 + depends on GRKERNSEC
90209 + default GRKERNSEC_CONFIG_CUSTOM
90210 + help
90211 +
90212 +config GRKERNSEC_CONFIG_AUTO
90213 + bool "Automatic"
90214 + help
90215 + If you choose this configuration method, you'll be able to answer a small
90216 + number of simple questions about how you plan to use this kernel.
90217 + The settings of grsecurity and PaX will be automatically configured for
90218 + the highest commonly-used settings within the provided constraints.
90219 +
90220 + If you require additional configuration, custom changes can still be made
90221 + from the "custom configuration" menu.
90222 +
90223 +config GRKERNSEC_CONFIG_CUSTOM
90224 + bool "Custom"
90225 + help
90226 + If you choose this configuration method, you'll be able to configure all
90227 + grsecurity and PaX settings manually. Via this method, no options are
90228 + automatically enabled.
90229 +
90230 +endchoice
90231 +
90232 +choice
90233 + prompt "Usage Type"
90234 + depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO)
90235 + default GRKERNSEC_CONFIG_SERVER
90236 + help
90237 +
90238 +config GRKERNSEC_CONFIG_SERVER
90239 + bool "Server"
90240 + help
90241 + Choose this option if you plan to use this kernel on a server.
90242 +
90243 +config GRKERNSEC_CONFIG_DESKTOP
90244 + bool "Desktop"
90245 + help
90246 + Choose this option if you plan to use this kernel on a desktop.
90247 +
90248 +endchoice
90249 +
90250 +choice
90251 + prompt "Virtualization Type"
90252 + depends on (GRKERNSEC && X86 && GRKERNSEC_CONFIG_AUTO)
90253 + default GRKERNSEC_CONFIG_VIRT_NONE
90254 + help
90255 +
90256 +config GRKERNSEC_CONFIG_VIRT_NONE
90257 + bool "None"
90258 + help
90259 + Choose this option if this kernel will be run on bare metal.
90260 +
90261 +config GRKERNSEC_CONFIG_VIRT_GUEST
90262 + bool "Guest"
90263 + help
90264 + Choose this option if this kernel will be run as a VM guest.
90265 +
90266 +config GRKERNSEC_CONFIG_VIRT_HOST
90267 + bool "Host"
90268 + help
90269 + Choose this option if this kernel will be run as a VM host.
90270 +
90271 +endchoice
90272 +
90273 +choice
90274 + prompt "Virtualization Hardware"
90275 + depends on (GRKERNSEC && X86 && GRKERNSEC_CONFIG_AUTO && (GRKERNSEC_CONFIG_VIRT_GUEST || GRKERNSEC_CONFIG_VIRT_HOST))
90276 + help
90277 +
90278 +config GRKERNSEC_CONFIG_VIRT_EPT
90279 + bool "EPT/RVI Processor Support"
90280 + depends on X86
90281 + help
90282 + Choose this option if your CPU supports the EPT or RVI features of 2nd-gen
90283 + hardware virtualization. This allows for additional kernel hardening protections
90284 + to operate without additional performance impact.
90285 +
90286 + To see if your Intel processor supports EPT, see:
90287 + http://ark.intel.com/Products/VirtualizationTechnology
90288 + (Most Core i3/5/7 support EPT)
90289 +
90290 + To see if your AMD processor supports RVI, see:
90291 + http://support.amd.com/us/kbarticles/Pages/GPU120AMDRVICPUsHyperVWin8.aspx
90292 +
90293 +config GRKERNSEC_CONFIG_VIRT_SOFT
90294 + bool "First-gen/No Hardware Virtualization"
90295 + help
90296 + Choose this option if you use an Atom/Pentium/Core 2 processor that either doesn't
90297 + support hardware virtualization or doesn't support the EPT/RVI extensions.
90298 +
90299 +endchoice
90300 +
90301 +choice
90302 + prompt "Virtualization Software"
90303 + depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO && (GRKERNSEC_CONFIG_VIRT_GUEST || GRKERNSEC_CONFIG_VIRT_HOST))
90304 + help
90305 +
90306 +config GRKERNSEC_CONFIG_VIRT_XEN
90307 + bool "Xen"
90308 + help
90309 + Choose this option if this kernel is running as a Xen guest or host.
90310 +
90311 +config GRKERNSEC_CONFIG_VIRT_VMWARE
90312 + bool "VMWare"
90313 + help
90314 + Choose this option if this kernel is running as a VMWare guest or host.
90315 +
90316 +config GRKERNSEC_CONFIG_VIRT_KVM
90317 + bool "KVM"
90318 + help
90319 + Choose this option if this kernel is running as a KVM guest or host.
90320 +
90321 +config GRKERNSEC_CONFIG_VIRT_VIRTUALBOX
90322 + bool "VirtualBox"
90323 + help
90324 + Choose this option if this kernel is running as a VirtualBox guest or host.
90325 +
90326 +endchoice
90327 +
90328 +choice
90329 + prompt "Required Priorities"
90330 + depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO)
90331 + default GRKERNSEC_CONFIG_PRIORITY_PERF
90332 + help
90333 +
90334 +config GRKERNSEC_CONFIG_PRIORITY_PERF
90335 + bool "Performance"
90336 + help
90337 + Choose this option if performance is of highest priority for this deployment
90338 + of grsecurity. Features like UDEREF on a 64bit kernel, kernel stack clearing,
90339 + and freed memory sanitizing will be disabled.
90340 +
90341 +config GRKERNSEC_CONFIG_PRIORITY_SECURITY
90342 + bool "Security"
90343 + help
90344 + Choose this option if security is of highest priority for this deployment of
90345 + grsecurity. UDEREF, kernel stack clearing, and freed memory sanitizing will
90346 + be enabled for this kernel. In a worst-case scenario, these features can
90347 + introduce a 20% performance hit (UDEREF on x64 contributing half of this hit).
90348 +
90349 +endchoice
90350 +
90351 +menu "Default Special Groups"
90352 +depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO)
90353 +
90354 +config GRKERNSEC_PROC_GID
90355 + int "GID exempted from /proc restrictions"
90356 + default 1001
90357 + help
90358 + Setting this GID determines which group will be exempted from
90359 + grsecurity's /proc restrictions, allowing users of the specified
90360 + group to view network statistics and the existence of other users'
90361 + processes on the system. This GID may also be chosen at boot time
90362 + via "grsec_proc_gid=" on the kernel commandline.
90363 +
90364 +config GRKERNSEC_TPE_UNTRUSTED_GID
90365 + int "GID for TPE-untrusted users"
90366 + depends on GRKERNSEC_CONFIG_SERVER && GRKERNSEC_TPE && !GRKERNSEC_TPE_INVERT
90367 + default 1005
90368 + help
90369 + Setting this GID determines which group untrusted users should
90370 + be added to. These users will be placed under grsecurity's Trusted Path
90371 + Execution mechanism, preventing them from executing their own binaries.
90372 + The users will only be able to execute binaries in directories owned and
90373 + writable only by the root user. If the sysctl option is enabled, a sysctl
90374 + option with name "tpe_gid" is created.
90375 +
90376 +config GRKERNSEC_TPE_TRUSTED_GID
90377 + int "GID for TPE-trusted users"
90378 + depends on GRKERNSEC_CONFIG_SERVER && GRKERNSEC_TPE && GRKERNSEC_TPE_INVERT
90379 + default 1005
90380 + help
90381 + Setting this GID determines what group TPE restrictions will be
90382 + *disabled* for. If the sysctl option is enabled, a sysctl option
90383 + with name "tpe_gid" is created.
90384 +
90385 +config GRKERNSEC_SYMLINKOWN_GID
90386 + int "GID for users with kernel-enforced SymlinksIfOwnerMatch"
90387 + depends on GRKERNSEC_CONFIG_SERVER
90388 + default 1006
90389 + help
90390 + Setting this GID determines what group kernel-enforced
90391 + SymlinksIfOwnerMatch will be enabled for. If the sysctl option
90392 + is enabled, a sysctl option with name "symlinkown_gid" is created.
90393 +
90394 +
90395 +endmenu
90396 +
90397 +menu "Customize Configuration"
90398 +depends on GRKERNSEC
90399 +
90400 +menu "PaX"
90401 +
90402 +config PAX
90403 + bool "Enable various PaX features"
90404 + default y if GRKERNSEC_CONFIG_AUTO
90405 + depends on GRKERNSEC && (ALPHA || ARM || AVR32 || IA64 || MIPS || PARISC || PPC || SPARC || X86)
90406 + help
90407 + This allows you to enable various PaX features. PaX adds
90408 + intrusion prevention mechanisms to the kernel that reduce
90409 + the risks posed by exploitable memory corruption bugs.
90410 +
90411 +menu "PaX Control"
90412 + depends on PAX
90413 +
90414 +config PAX_SOFTMODE
90415 + bool 'Support soft mode'
90416 + help
90417 + Enabling this option will allow you to run PaX in soft mode, that
90418 + is, PaX features will not be enforced by default, only on executables
90419 + marked explicitly. You must also enable PT_PAX_FLAGS or XATTR_PAX_FLAGS
90420 + support as they are the only way to mark executables for soft mode use.
90421 +
90422 + Soft mode can be activated by using the "pax_softmode=1" kernel command
90423 + line option on boot. Furthermore you can control various PaX features
90424 + at runtime via the entries in /proc/sys/kernel/pax.
90425 +
90426 +config PAX_EI_PAX
90427 + bool 'Use legacy ELF header marking'
90428 + default y if GRKERNSEC_CONFIG_AUTO
90429 + help
90430 + Enabling this option will allow you to control PaX features on
90431 + a per executable basis via the 'chpax' utility available at
90432 + http://pax.grsecurity.net/. The control flags will be read from
90433 + an otherwise reserved part of the ELF header. This marking has
90434 + numerous drawbacks (no support for soft-mode, toolchain does not
90435 + know about the non-standard use of the ELF header) therefore it
90436 + has been deprecated in favour of PT_PAX_FLAGS and XATTR_PAX_FLAGS
90437 + support.
90438 +
90439 + Note that if you enable PT_PAX_FLAGS or XATTR_PAX_FLAGS marking
90440 + support as well, they will override the legacy EI_PAX marks.
90441 +
90442 + If you enable none of the marking options then all applications
90443 + will run with PaX enabled on them by default.
90444 +
90445 +config PAX_PT_PAX_FLAGS
90446 + bool 'Use ELF program header marking'
90447 + default y if GRKERNSEC_CONFIG_AUTO
90448 + help
90449 + Enabling this option will allow you to control PaX features on
90450 + a per executable basis via the 'paxctl' utility available at
90451 + http://pax.grsecurity.net/. The control flags will be read from
90452 + a PaX specific ELF program header (PT_PAX_FLAGS). This marking
90453 + has the benefits of supporting both soft mode and being fully
90454 + integrated into the toolchain (the binutils patch is available
90455 + from http://pax.grsecurity.net).
90456 +
90457 + Note that if you enable the legacy EI_PAX marking support as well,
90458 + the EI_PAX marks will be overridden by the PT_PAX_FLAGS marks.
90459 +
90460 + If you enable both PT_PAX_FLAGS and XATTR_PAX_FLAGS support then you
90461 + must make sure that the marks are the same if a binary has both marks.
90462 +
90463 + If you enable none of the marking options then all applications
90464 + will run with PaX enabled on them by default.
90465 +
90466 +config PAX_XATTR_PAX_FLAGS
90467 + bool 'Use filesystem extended attributes marking'
90468 + default y if GRKERNSEC_CONFIG_AUTO
90469 + select CIFS_XATTR if CIFS
90470 + select EXT2_FS_XATTR if EXT2_FS
90471 + select EXT3_FS_XATTR if EXT3_FS
90472 + select EXT4_FS_XATTR if EXT4_FS
90473 + select JFFS2_FS_XATTR if JFFS2_FS
90474 + select REISERFS_FS_XATTR if REISERFS_FS
90475 + select SQUASHFS_XATTR if SQUASHFS
90476 + select TMPFS_XATTR if TMPFS
90477 + select UBIFS_FS_XATTR if UBIFS_FS
90478 + help
90479 + Enabling this option will allow you to control PaX features on
90480 + a per executable basis via the 'setfattr' utility. The control
90481 + flags will be read from the user.pax.flags extended attribute of
90482 + the file. This marking has the benefit of supporting binary-only
90483 + applications that self-check themselves (e.g., skype) and would
90484 + not tolerate chpax/paxctl changes. The main drawback is that
90485 + extended attributes are not supported by some filesystems (e.g.,
90486 + isofs, udf, vfat) so copying files through such filesystems will
90487 + lose the extended attributes and these PaX markings.
90488 +
90489 + Note that if you enable the legacy EI_PAX marking support as well,
90490 + the EI_PAX marks will be overridden by the XATTR_PAX_FLAGS marks.
90491 +
90492 + If you enable both PT_PAX_FLAGS and XATTR_PAX_FLAGS support then you
90493 + must make sure that the marks are the same if a binary has both marks.
90494 +
90495 + If you enable none of the marking options then all applications
90496 + will run with PaX enabled on them by default.
90497 +
90498 +choice
90499 + prompt 'MAC system integration'
90500 + default PAX_HAVE_ACL_FLAGS
90501 + help
90502 + Mandatory Access Control systems have the option of controlling
90503 + PaX flags on a per executable basis, choose the method supported
90504 + by your particular system.
90505 +
90506 + - "none": if your MAC system does not interact with PaX,
90507 + - "direct": if your MAC system defines pax_set_initial_flags() itself,
90508 + - "hook": if your MAC system uses the pax_set_initial_flags_func callback.
90509 +
90510 + NOTE: this option is for developers/integrators only.
90511 +
90512 + config PAX_NO_ACL_FLAGS
90513 + bool 'none'
90514 +
90515 + config PAX_HAVE_ACL_FLAGS
90516 + bool 'direct'
90517 +
90518 + config PAX_HOOK_ACL_FLAGS
90519 + bool 'hook'
90520 +endchoice
90521 +
90522 +endmenu
90523 +
90524 +menu "Non-executable pages"
90525 + depends on PAX
90526 +
90527 +config PAX_NOEXEC
90528 + bool "Enforce non-executable pages"
90529 + default y if GRKERNSEC_CONFIG_AUTO
90530 + depends on ALPHA || (ARM && (CPU_V6 || CPU_V7)) || IA64 || MIPS || PARISC || PPC || S390 || SPARC || X86
90531 + help
90532 + By design some architectures do not allow for protecting memory
90533 + pages against execution or even if they do, Linux does not make
90534 + use of this feature. In practice this means that if a page is
90535 + readable (such as the stack or heap) it is also executable.
90536 +
90537 + There is a well known exploit technique that makes use of this
90538 + fact and a common programming mistake where an attacker can
90539 + introduce code of his choice somewhere in the attacked program's
90540 + memory (typically the stack or the heap) and then execute it.
90541 +
90542 + If the attacked program was running with different (typically
90543 + higher) privileges than that of the attacker, then he can elevate
90544 + his own privilege level (e.g. get a root shell, write to files for
90545 + which he does not have write access to, etc).
90546 +
90547 + Enabling this option will let you choose from various features
90548 + that prevent the injection and execution of 'foreign' code in
90549 + a program.
90550 +
90551 + This will also break programs that rely on the old behaviour and
90552 + expect that dynamically allocated memory via the malloc() family
90553 + of functions is executable (which it is not). Notable examples
90554 + are the XFree86 4.x server, the java runtime and wine.
90555 +
90556 +config PAX_PAGEEXEC
90557 + bool "Paging based non-executable pages"
90558 + default y if GRKERNSEC_CONFIG_AUTO
90559 + 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)
90560 + select S390_SWITCH_AMODE if S390
90561 + select S390_EXEC_PROTECT if S390
90562 + select ARCH_TRACK_EXEC_LIMIT if X86_32
90563 + help
90564 + This implementation is based on the paging feature of the CPU.
90565 + On i386 without hardware non-executable bit support there is a
90566 + variable but usually low performance impact, however on Intel's
90567 + P4 core based CPUs it is very high so you should not enable this
90568 + for kernels meant to be used on such CPUs.
90569 +
90570 + On alpha, avr32, ia64, parisc, sparc, sparc64, x86_64 and i386
90571 + with hardware non-executable bit support there is no performance
90572 + impact, on ppc the impact is negligible.
90573 +
90574 + Note that several architectures require various emulations due to
90575 + badly designed userland ABIs, this will cause a performance impact
90576 + but will disappear as soon as userland is fixed. For example, ppc
90577 + userland MUST have been built with secure-plt by a recent toolchain.
90578 +
90579 +config PAX_SEGMEXEC
90580 + bool "Segmentation based non-executable pages"
90581 + default y if GRKERNSEC_CONFIG_AUTO
90582 + depends on PAX_NOEXEC && X86_32
90583 + help
90584 + This implementation is based on the segmentation feature of the
90585 + CPU and has a very small performance impact, however applications
90586 + will be limited to a 1.5 GB address space instead of the normal
90587 + 3 GB.
90588 +
90589 +config PAX_EMUTRAMP
90590 + bool "Emulate trampolines" if (PAX_PAGEEXEC || PAX_SEGMEXEC) && (PARISC || X86)
90591 + default y if PARISC
90592 + help
90593 + There are some programs and libraries that for one reason or
90594 + another attempt to execute special small code snippets from
90595 + non-executable memory pages. Most notable examples are the
90596 + signal handler return code generated by the kernel itself and
90597 + the GCC trampolines.
90598 +
90599 + If you enabled CONFIG_PAX_PAGEEXEC or CONFIG_PAX_SEGMEXEC then
90600 + such programs will no longer work under your kernel.
90601 +
90602 + As a remedy you can say Y here and use the 'chpax' or 'paxctl'
90603 + utilities to enable trampoline emulation for the affected programs
90604 + yet still have the protection provided by the non-executable pages.
90605 +
90606 + On parisc you MUST enable this option and EMUSIGRT as well, otherwise
90607 + your system will not even boot.
90608 +
90609 + Alternatively you can say N here and use the 'chpax' or 'paxctl'
90610 + utilities to disable CONFIG_PAX_PAGEEXEC and CONFIG_PAX_SEGMEXEC
90611 + for the affected files.
90612 +
90613 + NOTE: enabling this feature *may* open up a loophole in the
90614 + protection provided by non-executable pages that an attacker
90615 + could abuse. Therefore the best solution is to not have any
90616 + files on your system that would require this option. This can
90617 + be achieved by not using libc5 (which relies on the kernel
90618 + signal handler return code) and not using or rewriting programs
90619 + that make use of the nested function implementation of GCC.
90620 + Skilled users can just fix GCC itself so that it implements
90621 + nested function calls in a way that does not interfere with PaX.
90622 +
90623 +config PAX_EMUSIGRT
90624 + bool "Automatically emulate sigreturn trampolines"
90625 + depends on PAX_EMUTRAMP && PARISC
90626 + default y
90627 + help
90628 + Enabling this option will have the kernel automatically detect
90629 + and emulate signal return trampolines executing on the stack
90630 + that would otherwise lead to task termination.
90631 +
90632 + This solution is intended as a temporary one for users with
90633 + legacy versions of libc (libc5, glibc 2.0, uClibc before 0.9.17,
90634 + Modula-3 runtime, etc) or executables linked to such, basically
90635 + everything that does not specify its own SA_RESTORER function in
90636 + normal executable memory like glibc 2.1+ does.
90637 +
90638 + On parisc you MUST enable this option, otherwise your system will
90639 + not even boot.
90640 +
90641 + NOTE: this feature cannot be disabled on a per executable basis
90642 + and since it *does* open up a loophole in the protection provided
90643 + by non-executable pages, the best solution is to not have any
90644 + files on your system that would require this option.
90645 +
90646 +config PAX_MPROTECT
90647 + bool "Restrict mprotect()"
90648 + default y if GRKERNSEC_CONFIG_AUTO
90649 + depends on (PAX_PAGEEXEC || PAX_SEGMEXEC)
90650 + help
90651 + Enabling this option will prevent programs from
90652 + - changing the executable status of memory pages that were
90653 + not originally created as executable,
90654 + - making read-only executable pages writable again,
90655 + - creating executable pages from anonymous memory,
90656 + - making read-only-after-relocations (RELRO) data pages writable again.
90657 +
90658 + You should say Y here to complete the protection provided by
90659 + the enforcement of non-executable pages.
90660 +
90661 + NOTE: you can use the 'chpax' or 'paxctl' utilities to control
90662 + this feature on a per file basis.
90663 +
90664 +config PAX_MPROTECT_COMPAT
90665 + bool "Use legacy/compat protection demoting (read help)"
90666 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_DESKTOP)
90667 + depends on PAX_MPROTECT
90668 + help
90669 + The current implementation of PAX_MPROTECT denies RWX allocations/mprotects
90670 + by sending the proper error code to the application. For some broken
90671 + userland, this can cause problems with Python or other applications. The
90672 + current implementation however allows for applications like clamav to
90673 + detect if JIT compilation/execution is allowed and to fall back gracefully
90674 + to an interpreter-based mode if it does not. While we encourage everyone
90675 + to use the current implementation as-is and push upstream to fix broken
90676 + userland (note that the RWX logging option can assist with this), in some
90677 + environments this may not be possible. Having to disable MPROTECT
90678 + completely on certain binaries reduces the security benefit of PaX,
90679 + so this option is provided for those environments to revert to the old
90680 + behavior.
90681 +
90682 +config PAX_ELFRELOCS
90683 + bool "Allow ELF text relocations (read help)"
90684 + depends on PAX_MPROTECT
90685 + default n
90686 + help
90687 + Non-executable pages and mprotect() restrictions are effective
90688 + in preventing the introduction of new executable code into an
90689 + attacked task's address space. There remain only two venues
90690 + for this kind of attack: if the attacker can execute already
90691 + existing code in the attacked task then he can either have it
90692 + create and mmap() a file containing his code or have it mmap()
90693 + an already existing ELF library that does not have position
90694 + independent code in it and use mprotect() on it to make it
90695 + writable and copy his code there. While protecting against
90696 + the former approach is beyond PaX, the latter can be prevented
90697 + by having only PIC ELF libraries on one's system (which do not
90698 + need to relocate their code). If you are sure this is your case,
90699 + as is the case with all modern Linux distributions, then leave
90700 + this option disabled. You should say 'n' here.
90701 +
90702 +config PAX_ETEXECRELOCS
90703 + bool "Allow ELF ET_EXEC text relocations"
90704 + depends on PAX_MPROTECT && (ALPHA || IA64 || PARISC)
90705 + select PAX_ELFRELOCS
90706 + default y
90707 + help
90708 + On some architectures there are incorrectly created applications
90709 + that require text relocations and would not work without enabling
90710 + this option. If you are an alpha, ia64 or parisc user, you should
90711 + enable this option and disable it once you have made sure that
90712 + none of your applications need it.
90713 +
90714 +config PAX_EMUPLT
90715 + bool "Automatically emulate ELF PLT"
90716 + depends on PAX_MPROTECT && (ALPHA || PARISC || SPARC)
90717 + default y
90718 + help
90719 + Enabling this option will have the kernel automatically detect
90720 + and emulate the Procedure Linkage Table entries in ELF files.
90721 + On some architectures such entries are in writable memory, and
90722 + become non-executable leading to task termination. Therefore
90723 + it is mandatory that you enable this option on alpha, parisc,
90724 + sparc and sparc64, otherwise your system would not even boot.
90725 +
90726 + NOTE: this feature *does* open up a loophole in the protection
90727 + provided by the non-executable pages, therefore the proper
90728 + solution is to modify the toolchain to produce a PLT that does
90729 + not need to be writable.
90730 +
90731 +config PAX_DLRESOLVE
90732 + bool 'Emulate old glibc resolver stub'
90733 + depends on PAX_EMUPLT && SPARC
90734 + default n
90735 + help
90736 + This option is needed if userland has an old glibc (before 2.4)
90737 + that puts a 'save' instruction into the runtime generated resolver
90738 + stub that needs special emulation.
90739 +
90740 +config PAX_KERNEXEC
90741 + bool "Enforce non-executable kernel pages"
90742 + 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))
90743 + depends on ((X86 && (!X86_32 || X86_WP_WORKS_OK)) || (ARM && (CPU_V6 || CPU_V7) && !(ARM_LPAE && MODULES))) && !XEN
90744 + select PAX_PER_CPU_PGD if X86_64 || (X86_32 && X86_PAE)
90745 + select PAX_KERNEXEC_PLUGIN if X86_64
90746 + help
90747 + This is the kernel land equivalent of PAGEEXEC and MPROTECT,
90748 + that is, enabling this option will make it harder to inject
90749 + and execute 'foreign' code in kernel memory itself.
90750 +
90751 +choice
90752 + prompt "Return Address Instrumentation Method"
90753 + default PAX_KERNEXEC_PLUGIN_METHOD_BTS
90754 + depends on PAX_KERNEXEC_PLUGIN
90755 + help
90756 + Select the method used to instrument function pointer dereferences.
90757 + Note that binary modules cannot be instrumented by this approach.
90758 +
90759 + Note that the implementation requires a gcc with plugin support,
90760 + i.e., gcc 4.5 or newer. You may need to install the supporting
90761 + headers explicitly in addition to the normal gcc package.
90762 +
90763 + config PAX_KERNEXEC_PLUGIN_METHOD_BTS
90764 + bool "bts"
90765 + help
90766 + This method is compatible with binary only modules but has
90767 + a higher runtime overhead.
90768 +
90769 + config PAX_KERNEXEC_PLUGIN_METHOD_OR
90770 + bool "or"
90771 + depends on !PARAVIRT
90772 + help
90773 + This method is incompatible with binary only modules but has
90774 + a lower runtime overhead.
90775 +endchoice
90776 +
90777 +config PAX_KERNEXEC_PLUGIN_METHOD
90778 + string
90779 + default "bts" if PAX_KERNEXEC_PLUGIN_METHOD_BTS
90780 + default "or" if PAX_KERNEXEC_PLUGIN_METHOD_OR
90781 + default ""
90782 +
90783 +config PAX_KERNEXEC_MODULE_TEXT
90784 + int "Minimum amount of memory reserved for module code"
90785 + default "4" if (!GRKERNSEC_CONFIG_AUTO || GRKERNSEC_CONFIG_SERVER)
90786 + default "12" if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_DESKTOP)
90787 + depends on PAX_KERNEXEC && X86_32 && MODULES
90788 + help
90789 + Due to implementation details the kernel must reserve a fixed
90790 + amount of memory for module code at compile time that cannot be
90791 + changed at runtime. Here you can specify the minimum amount
90792 + in MB that will be reserved. Due to the same implementation
90793 + details this size will always be rounded up to the next 2/4 MB
90794 + boundary (depends on PAE) so the actually available memory for
90795 + module code will usually be more than this minimum.
90796 +
90797 + The default 4 MB should be enough for most users but if you have
90798 + an excessive number of modules (e.g., most distribution configs
90799 + compile many drivers as modules) or use huge modules such as
90800 + nvidia's kernel driver, you will need to adjust this amount.
90801 + A good rule of thumb is to look at your currently loaded kernel
90802 + modules and add up their sizes.
90803 +
90804 +endmenu
90805 +
90806 +menu "Address Space Layout Randomization"
90807 + depends on PAX
90808 +
90809 +config PAX_ASLR
90810 + bool "Address Space Layout Randomization"
90811 + default y if GRKERNSEC_CONFIG_AUTO
90812 + help
90813 + Many if not most exploit techniques rely on the knowledge of
90814 + certain addresses in the attacked program. The following options
90815 + will allow the kernel to apply a certain amount of randomization
90816 + to specific parts of the program thereby forcing an attacker to
90817 + guess them in most cases. Any failed guess will most likely crash
90818 + the attacked program which allows the kernel to detect such attempts
90819 + and react on them. PaX itself provides no reaction mechanisms,
90820 + instead it is strongly encouraged that you make use of Nergal's
90821 + segvguard (ftp://ftp.pl.openwall.com/misc/segvguard/) or grsecurity's
90822 + (http://www.grsecurity.net/) built-in crash detection features or
90823 + develop one yourself.
90824 +
90825 + By saying Y here you can choose to randomize the following areas:
90826 + - top of the task's kernel stack
90827 + - top of the task's userland stack
90828 + - base address for mmap() requests that do not specify one
90829 + (this includes all libraries)
90830 + - base address of the main executable
90831 +
90832 + It is strongly recommended to say Y here as address space layout
90833 + randomization has negligible impact on performance yet it provides
90834 + a very effective protection.
90835 +
90836 + NOTE: you can use the 'chpax' or 'paxctl' utilities to control
90837 + this feature on a per file basis.
90838 +
90839 +config PAX_RANDKSTACK
90840 + bool "Randomize kernel stack base"
90841 + default y if GRKERNSEC_CONFIG_AUTO
90842 + depends on X86_TSC && X86
90843 + help
90844 + By saying Y here the kernel will randomize every task's kernel
90845 + stack on every system call. This will not only force an attacker
90846 + to guess it but also prevent him from making use of possible
90847 + leaked information about it.
90848 +
90849 + Since the kernel stack is a rather scarce resource, randomization
90850 + may cause unexpected stack overflows, therefore you should very
90851 + carefully test your system. Note that once enabled in the kernel
90852 + configuration, this feature cannot be disabled on a per file basis.
90853 +
90854 +config PAX_RANDUSTACK
90855 + bool "Randomize user stack base"
90856 + default y if GRKERNSEC_CONFIG_AUTO
90857 + depends on PAX_ASLR
90858 + help
90859 + By saying Y here the kernel will randomize every task's userland
90860 + stack. The randomization is done in two steps where the second
90861 + one may apply a big amount of shift to the top of the stack and
90862 + cause problems for programs that want to use lots of memory (more
90863 + than 2.5 GB if SEGMEXEC is not active, or 1.25 GB when it is).
90864 + For this reason the second step can be controlled by 'chpax' or
90865 + 'paxctl' on a per file basis.
90866 +
90867 +config PAX_RANDMMAP
90868 + bool "Randomize mmap() base"
90869 + default y if GRKERNSEC_CONFIG_AUTO
90870 + depends on PAX_ASLR
90871 + help
90872 + By saying Y here the kernel will use a randomized base address for
90873 + mmap() requests that do not specify one themselves. As a result
90874 + all dynamically loaded libraries will appear at random addresses
90875 + and therefore be harder to exploit by a technique where an attacker
90876 + attempts to execute library code for his purposes (e.g. spawn a
90877 + shell from an exploited program that is running at an elevated
90878 + privilege level).
90879 +
90880 + Furthermore, if a program is relinked as a dynamic ELF file, its
90881 + base address will be randomized as well, completing the full
90882 + randomization of the address space layout. Attacking such programs
90883 + becomes a guess game. You can find an example of doing this at
90884 + http://pax.grsecurity.net/et_dyn.tar.gz and practical samples at
90885 + http://www.grsecurity.net/grsec-gcc-specs.tar.gz .
90886 +
90887 + NOTE: you can use the 'chpax' or 'paxctl' utilities to control this
90888 + feature on a per file basis.
90889 +
90890 +endmenu
90891 +
90892 +menu "Miscellaneous hardening features"
90893 +
90894 +config PAX_MEMORY_SANITIZE
90895 + bool "Sanitize all freed memory"
90896 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_PRIORITY_SECURITY)
90897 + depends on !HIBERNATION
90898 + help
90899 + By saying Y here the kernel will erase memory pages as soon as they
90900 + are freed. This in turn reduces the lifetime of data stored in the
90901 + pages, making it less likely that sensitive information such as
90902 + passwords, cryptographic secrets, etc stay in memory for too long.
90903 +
90904 + This is especially useful for programs whose runtime is short, long
90905 + lived processes and the kernel itself benefit from this as long as
90906 + they operate on whole memory pages and ensure timely freeing of pages
90907 + that may hold sensitive information.
90908 +
90909 + The tradeoff is performance impact, on a single CPU system kernel
90910 + compilation sees a 3% slowdown, other systems and workloads may vary
90911 + and you are advised to test this feature on your expected workload
90912 + before deploying it.
90913 +
90914 + Note that this feature does not protect data stored in live pages,
90915 + e.g., process memory swapped to disk may stay there for a long time.
90916 +
90917 +config PAX_MEMORY_STACKLEAK
90918 + bool "Sanitize kernel stack"
90919 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_PRIORITY_SECURITY)
90920 + depends on X86
90921 + help
90922 + By saying Y here the kernel will erase the kernel stack before it
90923 + returns from a system call. This in turn reduces the information
90924 + that a kernel stack leak bug can reveal.
90925 +
90926 + Note that such a bug can still leak information that was put on
90927 + the stack by the current system call (the one eventually triggering
90928 + the bug) but traces of earlier system calls on the kernel stack
90929 + cannot leak anymore.
90930 +
90931 + The tradeoff is performance impact: on a single CPU system kernel
90932 + compilation sees a 1% slowdown, other systems and workloads may vary
90933 + and you are advised to test this feature on your expected workload
90934 + before deploying it.
90935 +
90936 + Note that the full feature requires a gcc with plugin support,
90937 + i.e., gcc 4.5 or newer. You may need to install the supporting
90938 + headers explicitly in addition to the normal gcc package. Using
90939 + older gcc versions means that functions with large enough stack
90940 + frames may leave uninitialized memory behind that may be exposed
90941 + to a later syscall leaking the stack.
90942 +
90943 +config PAX_MEMORY_UDEREF
90944 + bool "Prevent invalid userland pointer dereference"
90945 + default y if GRKERNSEC_CONFIG_AUTO && !(X86_64 && GRKERNSEC_CONFIG_PRIORITY_PERF) && (GRKERNSEC_CONFIG_VIRT_NONE || GRKERNSEC_CONFIG_VIRT_EPT)
90946 + depends on (X86 || (ARM && (CPU_V6 || CPU_V7) && !ARM_LPAE)) && !UML_X86 && !XEN
90947 + select PAX_PER_CPU_PGD if X86_64
90948 + help
90949 + By saying Y here the kernel will be prevented from dereferencing
90950 + userland pointers in contexts where the kernel expects only kernel
90951 + pointers. This is both a useful runtime debugging feature and a
90952 + security measure that prevents exploiting a class of kernel bugs.
90953 +
90954 + The tradeoff is that some virtualization solutions may experience
90955 + a huge slowdown and therefore you should not enable this feature
90956 + for kernels meant to run in such environments. Whether a given VM
90957 + solution is affected or not is best determined by simply trying it
90958 + out, the performance impact will be obvious right on boot as this
90959 + mechanism engages from very early on. A good rule of thumb is that
90960 + VMs running on CPUs without hardware virtualization support (i.e.,
90961 + the majority of IA-32 CPUs) will likely experience the slowdown.
90962 +
90963 +config PAX_REFCOUNT
90964 + bool "Prevent various kernel object reference counter overflows"
90965 + default y if GRKERNSEC_CONFIG_AUTO
90966 + depends on GRKERNSEC && ((ARM && (CPU_32v6 || CPU_32v6K || CPU_32v7)) || SPARC64 || X86)
90967 + help
90968 + By saying Y here the kernel will detect and prevent overflowing
90969 + various (but not all) kinds of object reference counters. Such
90970 + overflows can normally occur due to bugs only and are often, if
90971 + not always, exploitable.
90972 +
90973 + The tradeoff is that data structures protected by an overflowed
90974 + refcount will never be freed and therefore will leak memory. Note
90975 + that this leak also happens even without this protection but in
90976 + that case the overflow can eventually trigger the freeing of the
90977 + data structure while it is still being used elsewhere, resulting
90978 + in the exploitable situation that this feature prevents.
90979 +
90980 + Since this has a negligible performance impact, you should enable
90981 + this feature.
90982 +
90983 +config PAX_CONSTIFY_PLUGIN
90984 + bool "Automatically constify eligible structures"
90985 + default y
90986 + depends on !UML
90987 + help
90988 + By saying Y here the compiler will automatically constify a class
90989 + of types that contain only function pointers. This reduces the
90990 + kernel's attack surface and also produces a better memory layout.
90991 +
90992 + Note that the implementation requires a gcc with plugin support,
90993 + i.e., gcc 4.5 or newer. You may need to install the supporting
90994 + headers explicitly in addition to the normal gcc package.
90995 +
90996 + Note that if some code really has to modify constified variables
90997 + then the source code will have to be patched to allow it. Examples
90998 + can be found in PaX itself (the no_const attribute) and for some
90999 + out-of-tree modules at http://www.grsecurity.net/~paxguy1/ .
91000 +
91001 +config PAX_USERCOPY
91002 + bool "Harden heap object copies between kernel and userland"
91003 + default y if GRKERNSEC_CONFIG_AUTO
91004 + depends on ARM || IA64 || PPC || SPARC || X86
91005 + depends on GRKERNSEC && (SLAB || SLUB || SLOB)
91006 + select PAX_USERCOPY_SLABS
91007 + help
91008 + By saying Y here the kernel will enforce the size of heap objects
91009 + when they are copied in either direction between the kernel and
91010 + userland, even if only a part of the heap object is copied.
91011 +
91012 + Specifically, this checking prevents information leaking from the
91013 + kernel heap during kernel to userland copies (if the kernel heap
91014 + object is otherwise fully initialized) and prevents kernel heap
91015 + overflows during userland to kernel copies.
91016 +
91017 + Note that the current implementation provides the strictest bounds
91018 + checks for the SLUB allocator.
91019 +
91020 + Enabling this option also enables per-slab cache protection against
91021 + data in a given cache being copied into/out of via userland
91022 + accessors. Though the whitelist of regions will be reduced over
91023 + time, it notably protects important data structures like task structs.
91024 +
91025 + If frame pointers are enabled on x86, this option will also restrict
91026 + copies into and out of the kernel stack to local variables within a
91027 + single frame.
91028 +
91029 + Since this has a negligible performance impact, you should enable
91030 + this feature.
91031 +
91032 +
91033 +config PAX_USERCOPY_DEBUG
91034 + bool
91035 + depends on X86 && PAX_USERCOPY
91036 + default n
91037 +
91038 +config PAX_SIZE_OVERFLOW
91039 + bool "Prevent various integer overflows in function size parameters"
91040 + default y if GRKERNSEC_CONFIG_AUTO
91041 + depends on X86
91042 + help
91043 + By saying Y here the kernel recomputes expressions of function
91044 + arguments marked by a size_overflow attribute with double integer
91045 + precision (DImode/TImode for 32/64 bit integer types).
91046 +
91047 + The recomputed argument is checked against TYPE_MAX and an event
91048 + is logged on overflow and the triggering process is killed.
91049 +
91050 + Homepage: http://www.grsecurity.net/~ephox/overflow_plugin/
91051 +
91052 + Note that the implementation requires a gcc with plugin support,
91053 + i.e., gcc 4.5 or newer. You may need to install the supporting
91054 + headers explicitly in addition to the normal gcc package.
91055 +
91056 +config PAX_LATENT_ENTROPY
91057 + bool "Generate some entropy during boot"
91058 + default y if GRKERNSEC_CONFIG_AUTO
91059 + help
91060 + By saying Y here the kernel will instrument early boot code to
91061 + extract some entropy from both original and artificially created
91062 + program state. This will help especially embedded systems where
91063 + there is little 'natural' source of entropy normally. The cost
91064 + is some slowdown of the boot process.
91065 +
91066 + When pax_extra_latent_entropy is passed on the kernel command line,
91067 + entropy will be extracted from up to the first 4GB of RAM while the
91068 + runtime memory allocator is being initialized. This costs even more
91069 + slowdown of the boot process.
91070 +
91071 + Note that the implementation requires a gcc with plugin support,
91072 + i.e., gcc 4.5 or newer. You may need to install the supporting
91073 + headers explicitly in addition to the normal gcc package.
91074 +
91075 + Note that entropy extracted this way is not cryptographically
91076 + secure!
91077 +
91078 +endmenu
91079 +
91080 +endmenu
91081 +
91082 +source grsecurity/Kconfig
91083 +
91084 +endmenu
91085 +
91086 +endmenu
91087 +
91088 source security/keys/Kconfig
91089
91090 config SECURITY_DMESG_RESTRICT
91091 @@ -103,7 +1022,7 @@ config INTEL_TXT
91092 config LSM_MMAP_MIN_ADDR
91093 int "Low address space for LSM to protect from user allocation"
91094 depends on SECURITY && SECURITY_SELINUX
91095 - default 32768 if ARM
91096 + default 32768 if ALPHA || ARM || PARISC || SPARC32
91097 default 65536
91098 help
91099 This is the portion of low virtual memory which should be protected
91100 diff --git a/security/apparmor/lsm.c b/security/apparmor/lsm.c
91101 index 8c2a7f6..b133ac9 100644
91102 --- a/security/apparmor/lsm.c
91103 +++ b/security/apparmor/lsm.c
91104 @@ -614,7 +614,7 @@ static int apparmor_task_setrlimit(struct task_struct *task,
91105 return error;
91106 }
91107
91108 -static struct security_operations apparmor_ops = {
91109 +static struct security_operations apparmor_ops __read_only = {
91110 .name = "apparmor",
91111
91112 .ptrace_access_check = apparmor_ptrace_access_check,
91113 diff --git a/security/commoncap.c b/security/commoncap.c
91114 index 7ee08c7..8d1a9d6 100644
91115 --- a/security/commoncap.c
91116 +++ b/security/commoncap.c
91117 @@ -424,6 +424,32 @@ int get_vfs_caps_from_disk(const struct dentry *dentry, struct cpu_vfs_cap_data
91118 return 0;
91119 }
91120
91121 +/* returns:
91122 + 1 for suid privilege
91123 + 2 for sgid privilege
91124 + 3 for fscap privilege
91125 +*/
91126 +int is_privileged_binary(const struct dentry *dentry)
91127 +{
91128 + struct cpu_vfs_cap_data capdata;
91129 + struct inode *inode = dentry->d_inode;
91130 +
91131 + if (!inode || S_ISDIR(inode->i_mode))
91132 + return 0;
91133 +
91134 + if (inode->i_mode & S_ISUID)
91135 + return 1;
91136 + if ((inode->i_mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))
91137 + return 2;
91138 +
91139 + if (!get_vfs_caps_from_disk(dentry, &capdata)) {
91140 + if (!cap_isclear(capdata.inheritable) || !cap_isclear(capdata.permitted))
91141 + return 3;
91142 + }
91143 +
91144 + return 0;
91145 +}
91146 +
91147 /*
91148 * Attempt to get the on-exec apply capability sets for an executable file from
91149 * its xattrs and, if present, apply them to the proposed credentials being
91150 @@ -592,6 +618,9 @@ int cap_bprm_secureexec(struct linux_binprm *bprm)
91151 const struct cred *cred = current_cred();
91152 kuid_t root_uid = make_kuid(cred->user_ns, 0);
91153
91154 + if (gr_acl_enable_at_secure())
91155 + return 1;
91156 +
91157 if (!uid_eq(cred->uid, root_uid)) {
91158 if (bprm->cap_effective)
91159 return 1;
91160 diff --git a/security/integrity/ima/ima.h b/security/integrity/ima/ima.h
91161 index 079a85d..12e93f8 100644
91162 --- a/security/integrity/ima/ima.h
91163 +++ b/security/integrity/ima/ima.h
91164 @@ -96,8 +96,8 @@ void ima_add_violation(struct inode *inode, const unsigned char *filename,
91165 extern spinlock_t ima_queue_lock;
91166
91167 struct ima_h_table {
91168 - atomic_long_t len; /* number of stored measurements in the list */
91169 - atomic_long_t violations;
91170 + atomic_long_unchecked_t len; /* number of stored measurements in the list */
91171 + atomic_long_unchecked_t violations;
91172 struct hlist_head queue[IMA_MEASURE_HTABLE_SIZE];
91173 };
91174 extern struct ima_h_table ima_htable;
91175 diff --git a/security/integrity/ima/ima_api.c b/security/integrity/ima/ima_api.c
91176 index 0cea3db..2f0ef77 100644
91177 --- a/security/integrity/ima/ima_api.c
91178 +++ b/security/integrity/ima/ima_api.c
91179 @@ -79,7 +79,7 @@ void ima_add_violation(struct inode *inode, const unsigned char *filename,
91180 int result;
91181
91182 /* can overflow, only indicator */
91183 - atomic_long_inc(&ima_htable.violations);
91184 + atomic_long_inc_unchecked(&ima_htable.violations);
91185
91186 entry = kmalloc(sizeof(*entry), GFP_KERNEL);
91187 if (!entry) {
91188 diff --git a/security/integrity/ima/ima_fs.c b/security/integrity/ima/ima_fs.c
91189 index 38477c9..87a60c7 100644
91190 --- a/security/integrity/ima/ima_fs.c
91191 +++ b/security/integrity/ima/ima_fs.c
91192 @@ -28,12 +28,12 @@
91193 static int valid_policy = 1;
91194 #define TMPBUFLEN 12
91195 static ssize_t ima_show_htable_value(char __user *buf, size_t count,
91196 - loff_t *ppos, atomic_long_t *val)
91197 + loff_t *ppos, atomic_long_unchecked_t *val)
91198 {
91199 char tmpbuf[TMPBUFLEN];
91200 ssize_t len;
91201
91202 - len = scnprintf(tmpbuf, TMPBUFLEN, "%li\n", atomic_long_read(val));
91203 + len = scnprintf(tmpbuf, TMPBUFLEN, "%li\n", atomic_long_read_unchecked(val));
91204 return simple_read_from_buffer(buf, count, ppos, tmpbuf, len);
91205 }
91206
91207 diff --git a/security/integrity/ima/ima_queue.c b/security/integrity/ima/ima_queue.c
91208 index 55a6271..ad829c3 100644
91209 --- a/security/integrity/ima/ima_queue.c
91210 +++ b/security/integrity/ima/ima_queue.c
91211 @@ -81,7 +81,7 @@ static int ima_add_digest_entry(struct ima_template_entry *entry)
91212 INIT_LIST_HEAD(&qe->later);
91213 list_add_tail_rcu(&qe->later, &ima_measurements);
91214
91215 - atomic_long_inc(&ima_htable.len);
91216 + atomic_long_inc_unchecked(&ima_htable.len);
91217 key = ima_hash_key(entry->digest);
91218 hlist_add_head_rcu(&qe->hnext, &ima_htable.queue[key]);
91219 return 0;
91220 diff --git a/security/keys/compat.c b/security/keys/compat.c
91221 index d65fa7f..cbfe366 100644
91222 --- a/security/keys/compat.c
91223 +++ b/security/keys/compat.c
91224 @@ -44,7 +44,7 @@ static long compat_keyctl_instantiate_key_iov(
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/key.c b/security/keys/key.c
91234 index 8fb7c7b..ba3610d 100644
91235 --- a/security/keys/key.c
91236 +++ b/security/keys/key.c
91237 @@ -284,7 +284,7 @@ struct key *key_alloc(struct key_type *type, const char *desc,
91238
91239 atomic_set(&key->usage, 1);
91240 init_rwsem(&key->sem);
91241 - lockdep_set_class(&key->sem, &type->lock_class);
91242 + lockdep_set_class(&key->sem, (struct lock_class_key *)&type->lock_class);
91243 key->type = type;
91244 key->user = user;
91245 key->quotalen = quotalen;
91246 @@ -1032,7 +1032,9 @@ int register_key_type(struct key_type *ktype)
91247 struct key_type *p;
91248 int ret;
91249
91250 - memset(&ktype->lock_class, 0, sizeof(ktype->lock_class));
91251 + pax_open_kernel();
91252 + memset((void *)&ktype->lock_class, 0, sizeof(ktype->lock_class));
91253 + pax_close_kernel();
91254
91255 ret = -EEXIST;
91256 down_write(&key_types_sem);
91257 @@ -1044,7 +1046,7 @@ int register_key_type(struct key_type *ktype)
91258 }
91259
91260 /* store the type */
91261 - list_add(&ktype->link, &key_types_list);
91262 + pax_list_add((struct list_head *)&ktype->link, &key_types_list);
91263
91264 pr_notice("Key type %s registered\n", ktype->name);
91265 ret = 0;
91266 @@ -1066,7 +1068,7 @@ EXPORT_SYMBOL(register_key_type);
91267 void unregister_key_type(struct key_type *ktype)
91268 {
91269 down_write(&key_types_sem);
91270 - list_del_init(&ktype->link);
91271 + pax_list_del_init((struct list_head *)&ktype->link);
91272 downgrade_write(&key_types_sem);
91273 key_gc_keytype(ktype);
91274 pr_notice("Key type %s unregistered\n", ktype->name);
91275 @@ -1084,10 +1086,10 @@ void __init key_init(void)
91276 0, SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
91277
91278 /* add the special key types */
91279 - list_add_tail(&key_type_keyring.link, &key_types_list);
91280 - list_add_tail(&key_type_dead.link, &key_types_list);
91281 - list_add_tail(&key_type_user.link, &key_types_list);
91282 - list_add_tail(&key_type_logon.link, &key_types_list);
91283 + pax_list_add_tail((struct list_head *)&key_type_keyring.link, &key_types_list);
91284 + pax_list_add_tail((struct list_head *)&key_type_dead.link, &key_types_list);
91285 + pax_list_add_tail((struct list_head *)&key_type_user.link, &key_types_list);
91286 + pax_list_add_tail((struct list_head *)&key_type_logon.link, &key_types_list);
91287
91288 /* record the root user tracking */
91289 rb_link_node(&root_key_user.node,
91290 diff --git a/security/keys/keyctl.c b/security/keys/keyctl.c
91291 index 4b5c948..2054dc1 100644
91292 --- a/security/keys/keyctl.c
91293 +++ b/security/keys/keyctl.c
91294 @@ -986,7 +986,7 @@ static int keyctl_change_reqkey_auth(struct key *key)
91295 /*
91296 * Copy the iovec data from userspace
91297 */
91298 -static long copy_from_user_iovec(void *buffer, const struct iovec *iov,
91299 +static long copy_from_user_iovec(void *buffer, const struct iovec __user *iov,
91300 unsigned ioc)
91301 {
91302 for (; ioc > 0; ioc--) {
91303 @@ -1008,7 +1008,7 @@ static long copy_from_user_iovec(void *buffer, const struct iovec *iov,
91304 * If successful, 0 will be returned.
91305 */
91306 long keyctl_instantiate_key_common(key_serial_t id,
91307 - const struct iovec *payload_iov,
91308 + const struct iovec __user *payload_iov,
91309 unsigned ioc,
91310 size_t plen,
91311 key_serial_t ringid)
91312 @@ -1103,7 +1103,7 @@ long keyctl_instantiate_key(key_serial_t id,
91313 [0].iov_len = plen
91314 };
91315
91316 - return keyctl_instantiate_key_common(id, iov, 1, plen, ringid);
91317 + return keyctl_instantiate_key_common(id, (const struct iovec __force_user *)iov, 1, plen, ringid);
91318 }
91319
91320 return keyctl_instantiate_key_common(id, NULL, 0, 0, ringid);
91321 @@ -1136,7 +1136,7 @@ long keyctl_instantiate_key_iov(key_serial_t id,
91322 if (ret == 0)
91323 goto no_payload_free;
91324
91325 - ret = keyctl_instantiate_key_common(id, iov, ioc, ret, ringid);
91326 + ret = keyctl_instantiate_key_common(id, (const struct iovec __force_user *)iov, ioc, ret, ringid);
91327 err:
91328 if (iov != iovstack)
91329 kfree(iov);
91330 diff --git a/security/keys/keyring.c b/security/keys/keyring.c
91331 index 6ece7f2..ecdb55c 100644
91332 --- a/security/keys/keyring.c
91333 +++ b/security/keys/keyring.c
91334 @@ -227,16 +227,16 @@ static long keyring_read(const struct key *keyring,
91335 ret = -EFAULT;
91336
91337 for (loop = 0; loop < klist->nkeys; loop++) {
91338 + key_serial_t serial;
91339 key = rcu_deref_link_locked(klist, loop,
91340 keyring);
91341 + serial = key->serial;
91342
91343 tmp = sizeof(key_serial_t);
91344 if (tmp > buflen)
91345 tmp = buflen;
91346
91347 - if (copy_to_user(buffer,
91348 - &key->serial,
91349 - tmp) != 0)
91350 + if (copy_to_user(buffer, &serial, tmp))
91351 goto error;
91352
91353 buflen -= tmp;
91354 diff --git a/security/min_addr.c b/security/min_addr.c
91355 index f728728..6457a0c 100644
91356 --- a/security/min_addr.c
91357 +++ b/security/min_addr.c
91358 @@ -14,6 +14,7 @@ unsigned long dac_mmap_min_addr = CONFIG_DEFAULT_MMAP_MIN_ADDR;
91359 */
91360 static void update_mmap_min_addr(void)
91361 {
91362 +#ifndef SPARC
91363 #ifdef CONFIG_LSM_MMAP_MIN_ADDR
91364 if (dac_mmap_min_addr > CONFIG_LSM_MMAP_MIN_ADDR)
91365 mmap_min_addr = dac_mmap_min_addr;
91366 @@ -22,6 +23,7 @@ static void update_mmap_min_addr(void)
91367 #else
91368 mmap_min_addr = dac_mmap_min_addr;
91369 #endif
91370 +#endif
91371 }
91372
91373 /*
91374 diff --git a/security/security.c b/security/security.c
91375 index 7b88c6a..1e3ea8f 100644
91376 --- a/security/security.c
91377 +++ b/security/security.c
91378 @@ -20,6 +20,7 @@
91379 #include <linux/ima.h>
91380 #include <linux/evm.h>
91381 #include <linux/fsnotify.h>
91382 +#include <linux/mm.h>
91383 #include <linux/mman.h>
91384 #include <linux/mount.h>
91385 #include <linux/personality.h>
91386 @@ -32,8 +33,8 @@
91387 static __initdata char chosen_lsm[SECURITY_NAME_MAX + 1] =
91388 CONFIG_DEFAULT_SECURITY;
91389
91390 -static struct security_operations *security_ops;
91391 -static struct security_operations default_security_ops = {
91392 +static struct security_operations *security_ops __read_only;
91393 +static struct security_operations default_security_ops __read_only = {
91394 .name = "default",
91395 };
91396
91397 @@ -74,7 +75,9 @@ int __init security_init(void)
91398
91399 void reset_security_ops(void)
91400 {
91401 + pax_open_kernel();
91402 security_ops = &default_security_ops;
91403 + pax_close_kernel();
91404 }
91405
91406 /* Save user chosen LSM */
91407 diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
91408 index ef26e96..642fb78 100644
91409 --- a/security/selinux/hooks.c
91410 +++ b/security/selinux/hooks.c
91411 @@ -95,8 +95,6 @@
91412
91413 #define NUM_SEL_MNT_OPTS 5
91414
91415 -extern struct security_operations *security_ops;
91416 -
91417 /* SECMARK reference count */
91418 static atomic_t selinux_secmark_refcount = ATOMIC_INIT(0);
91419
91420 @@ -5501,7 +5499,7 @@ static int selinux_key_getsecurity(struct key *key, char **_buffer)
91421
91422 #endif
91423
91424 -static struct security_operations selinux_ops = {
91425 +static struct security_operations selinux_ops __read_only = {
91426 .name = "selinux",
91427
91428 .ptrace_access_check = selinux_ptrace_access_check,
91429 diff --git a/security/selinux/include/xfrm.h b/security/selinux/include/xfrm.h
91430 index 65f67cb..3f141ef 100644
91431 --- a/security/selinux/include/xfrm.h
91432 +++ b/security/selinux/include/xfrm.h
91433 @@ -50,7 +50,7 @@ int selinux_xfrm_decode_session(struct sk_buff *skb, u32 *sid, int ckall);
91434
91435 static inline void selinux_xfrm_notify_policyload(void)
91436 {
91437 - atomic_inc(&flow_cache_genid);
91438 + atomic_inc_unchecked(&flow_cache_genid);
91439 rt_genid_bump(&init_net);
91440 }
91441 #else
91442 diff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c
91443 index 38be92c..21f49ee 100644
91444 --- a/security/smack/smack_lsm.c
91445 +++ b/security/smack/smack_lsm.c
91446 @@ -3398,7 +3398,7 @@ static int smack_inode_getsecctx(struct inode *inode, void **ctx, u32 *ctxlen)
91447 return 0;
91448 }
91449
91450 -struct security_operations smack_ops = {
91451 +struct security_operations smack_ops __read_only = {
91452 .name = "smack",
91453
91454 .ptrace_access_check = smack_ptrace_access_check,
91455 diff --git a/security/tomoyo/mount.c b/security/tomoyo/mount.c
91456 index 390c646..f2f8db3 100644
91457 --- a/security/tomoyo/mount.c
91458 +++ b/security/tomoyo/mount.c
91459 @@ -118,6 +118,10 @@ static int tomoyo_mount_acl(struct tomoyo_request_info *r,
91460 type == tomoyo_mounts[TOMOYO_MOUNT_MOVE]) {
91461 need_dev = -1; /* dev_name is a directory */
91462 } else {
91463 + if (!capable(CAP_SYS_ADMIN)) {
91464 + error = -EPERM;
91465 + goto out;
91466 + }
91467 fstype = get_fs_type(type);
91468 if (!fstype) {
91469 error = -ENODEV;
91470 diff --git a/security/tomoyo/tomoyo.c b/security/tomoyo/tomoyo.c
91471 index a2ee362..5754f34 100644
91472 --- a/security/tomoyo/tomoyo.c
91473 +++ b/security/tomoyo/tomoyo.c
91474 @@ -503,7 +503,7 @@ static int tomoyo_socket_sendmsg(struct socket *sock, struct msghdr *msg,
91475 * tomoyo_security_ops is a "struct security_operations" which is used for
91476 * registering TOMOYO.
91477 */
91478 -static struct security_operations tomoyo_security_ops = {
91479 +static struct security_operations tomoyo_security_ops __read_only = {
91480 .name = "tomoyo",
91481 .cred_alloc_blank = tomoyo_cred_alloc_blank,
91482 .cred_prepare = tomoyo_cred_prepare,
91483 diff --git a/security/yama/Kconfig b/security/yama/Kconfig
91484 index 20ef514..4182bed 100644
91485 --- a/security/yama/Kconfig
91486 +++ b/security/yama/Kconfig
91487 @@ -1,6 +1,6 @@
91488 config SECURITY_YAMA
91489 bool "Yama support"
91490 - depends on SECURITY
91491 + depends on SECURITY && !GRKERNSEC
91492 select SECURITYFS
91493 select SECURITY_PATH
91494 default n
91495 diff --git a/security/yama/yama_lsm.c b/security/yama/yama_lsm.c
91496 index 23414b9..b92b314 100644
91497 --- a/security/yama/yama_lsm.c
91498 +++ b/security/yama/yama_lsm.c
91499 @@ -367,7 +367,7 @@ int yama_ptrace_traceme(struct task_struct *parent)
91500 }
91501
91502 #ifndef CONFIG_SECURITY_YAMA_STACKED
91503 -static struct security_operations yama_ops = {
91504 +static struct security_operations yama_ops __read_only = {
91505 .name = "yama",
91506
91507 .ptrace_access_check = yama_ptrace_access_check,
91508 @@ -378,28 +378,24 @@ static struct security_operations yama_ops = {
91509 #endif
91510
91511 #ifdef CONFIG_SYSCTL
91512 +static int zero __read_only;
91513 +static int max_scope __read_only = YAMA_SCOPE_NO_ATTACH;
91514 +
91515 static int yama_dointvec_minmax(struct ctl_table *table, int write,
91516 void __user *buffer, size_t *lenp, loff_t *ppos)
91517 {
91518 - int rc;
91519 + ctl_table_no_const yama_table;
91520
91521 if (write && !capable(CAP_SYS_PTRACE))
91522 return -EPERM;
91523
91524 - rc = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
91525 - if (rc)
91526 - return rc;
91527 -
91528 + yama_table = *table;
91529 /* Lock the max value if it ever gets set. */
91530 - if (write && *(int *)table->data == *(int *)table->extra2)
91531 - table->extra1 = table->extra2;
91532 -
91533 - return rc;
91534 + if (ptrace_scope == max_scope)
91535 + yama_table.extra1 = &max_scope;
91536 + return proc_dointvec_minmax(&yama_table, write, buffer, lenp, ppos);
91537 }
91538
91539 -static int zero;
91540 -static int max_scope = YAMA_SCOPE_NO_ATTACH;
91541 -
91542 struct ctl_path yama_sysctl_path[] = {
91543 { .procname = "kernel", },
91544 { .procname = "yama", },
91545 diff --git a/sound/aoa/codecs/onyx.c b/sound/aoa/codecs/onyx.c
91546 index 4cedc69..e59d8a3 100644
91547 --- a/sound/aoa/codecs/onyx.c
91548 +++ b/sound/aoa/codecs/onyx.c
91549 @@ -54,7 +54,7 @@ struct onyx {
91550 spdif_locked:1,
91551 analog_locked:1,
91552 original_mute:2;
91553 - int open_count;
91554 + local_t open_count;
91555 struct codec_info *codec_info;
91556
91557 /* mutex serializes concurrent access to the device
91558 @@ -753,7 +753,7 @@ static int onyx_open(struct codec_info_item *cii,
91559 struct onyx *onyx = cii->codec_data;
91560
91561 mutex_lock(&onyx->mutex);
91562 - onyx->open_count++;
91563 + local_inc(&onyx->open_count);
91564 mutex_unlock(&onyx->mutex);
91565
91566 return 0;
91567 @@ -765,8 +765,7 @@ static int onyx_close(struct codec_info_item *cii,
91568 struct onyx *onyx = cii->codec_data;
91569
91570 mutex_lock(&onyx->mutex);
91571 - onyx->open_count--;
91572 - if (!onyx->open_count)
91573 + if (local_dec_and_test(&onyx->open_count))
91574 onyx->spdif_locked = onyx->analog_locked = 0;
91575 mutex_unlock(&onyx->mutex);
91576
91577 diff --git a/sound/aoa/codecs/onyx.h b/sound/aoa/codecs/onyx.h
91578 index ffd2025..df062c9 100644
91579 --- a/sound/aoa/codecs/onyx.h
91580 +++ b/sound/aoa/codecs/onyx.h
91581 @@ -11,6 +11,7 @@
91582 #include <linux/i2c.h>
91583 #include <asm/pmac_low_i2c.h>
91584 #include <asm/prom.h>
91585 +#include <asm/local.h>
91586
91587 /* PCM3052 register definitions */
91588
91589 diff --git a/sound/core/oss/pcm_oss.c b/sound/core/oss/pcm_oss.c
91590 index 4c1cc51..16040040 100644
91591 --- a/sound/core/oss/pcm_oss.c
91592 +++ b/sound/core/oss/pcm_oss.c
91593 @@ -1189,10 +1189,10 @@ snd_pcm_sframes_t snd_pcm_oss_write3(struct snd_pcm_substream *substream, const
91594 if (in_kernel) {
91595 mm_segment_t fs;
91596 fs = snd_enter_user();
91597 - ret = snd_pcm_lib_write(substream, (void __force __user *)ptr, frames);
91598 + ret = snd_pcm_lib_write(substream, (void __force_user *)ptr, frames);
91599 snd_leave_user(fs);
91600 } else {
91601 - ret = snd_pcm_lib_write(substream, (void __force __user *)ptr, frames);
91602 + ret = snd_pcm_lib_write(substream, (void __force_user *)ptr, frames);
91603 }
91604 if (ret != -EPIPE && ret != -ESTRPIPE)
91605 break;
91606 @@ -1234,10 +1234,10 @@ snd_pcm_sframes_t snd_pcm_oss_read3(struct snd_pcm_substream *substream, char *p
91607 if (in_kernel) {
91608 mm_segment_t fs;
91609 fs = snd_enter_user();
91610 - ret = snd_pcm_lib_read(substream, (void __force __user *)ptr, frames);
91611 + ret = snd_pcm_lib_read(substream, (void __force_user *)ptr, frames);
91612 snd_leave_user(fs);
91613 } else {
91614 - ret = snd_pcm_lib_read(substream, (void __force __user *)ptr, frames);
91615 + ret = snd_pcm_lib_read(substream, (void __force_user *)ptr, frames);
91616 }
91617 if (ret == -EPIPE) {
91618 if (runtime->status->state == SNDRV_PCM_STATE_DRAINING) {
91619 @@ -1337,7 +1337,7 @@ static ssize_t snd_pcm_oss_write2(struct snd_pcm_substream *substream, const cha
91620 struct snd_pcm_plugin_channel *channels;
91621 size_t oss_frame_bytes = (runtime->oss.plugin_first->src_width * runtime->oss.plugin_first->src_format.channels) / 8;
91622 if (!in_kernel) {
91623 - if (copy_from_user(runtime->oss.buffer, (const char __force __user *)buf, bytes))
91624 + if (copy_from_user(runtime->oss.buffer, (const char __force_user *)buf, bytes))
91625 return -EFAULT;
91626 buf = runtime->oss.buffer;
91627 }
91628 @@ -1407,7 +1407,7 @@ static ssize_t snd_pcm_oss_write1(struct snd_pcm_substream *substream, const cha
91629 }
91630 } else {
91631 tmp = snd_pcm_oss_write2(substream,
91632 - (const char __force *)buf,
91633 + (const char __force_kernel *)buf,
91634 runtime->oss.period_bytes, 0);
91635 if (tmp <= 0)
91636 goto err;
91637 @@ -1433,7 +1433,7 @@ static ssize_t snd_pcm_oss_read2(struct snd_pcm_substream *substream, char *buf,
91638 struct snd_pcm_runtime *runtime = substream->runtime;
91639 snd_pcm_sframes_t frames, frames1;
91640 #ifdef CONFIG_SND_PCM_OSS_PLUGINS
91641 - char __user *final_dst = (char __force __user *)buf;
91642 + char __user *final_dst = (char __force_user *)buf;
91643 if (runtime->oss.plugin_first) {
91644 struct snd_pcm_plugin_channel *channels;
91645 size_t oss_frame_bytes = (runtime->oss.plugin_last->dst_width * runtime->oss.plugin_last->dst_format.channels) / 8;
91646 @@ -1495,7 +1495,7 @@ static ssize_t snd_pcm_oss_read1(struct snd_pcm_substream *substream, char __use
91647 xfer += tmp;
91648 runtime->oss.buffer_used -= tmp;
91649 } else {
91650 - tmp = snd_pcm_oss_read2(substream, (char __force *)buf,
91651 + tmp = snd_pcm_oss_read2(substream, (char __force_kernel *)buf,
91652 runtime->oss.period_bytes, 0);
91653 if (tmp <= 0)
91654 goto err;
91655 @@ -1663,7 +1663,7 @@ static int snd_pcm_oss_sync(struct snd_pcm_oss_file *pcm_oss_file)
91656 size1);
91657 size1 /= runtime->channels; /* frames */
91658 fs = snd_enter_user();
91659 - snd_pcm_lib_write(substream, (void __force __user *)runtime->oss.buffer, size1);
91660 + snd_pcm_lib_write(substream, (void __force_user *)runtime->oss.buffer, size1);
91661 snd_leave_user(fs);
91662 }
91663 } else if (runtime->access == SNDRV_PCM_ACCESS_RW_NONINTERLEAVED) {
91664 diff --git a/sound/core/pcm_compat.c b/sound/core/pcm_compat.c
91665 index af49721..e85058e 100644
91666 --- a/sound/core/pcm_compat.c
91667 +++ b/sound/core/pcm_compat.c
91668 @@ -31,7 +31,7 @@ static int snd_pcm_ioctl_delay_compat(struct snd_pcm_substream *substream,
91669 int err;
91670
91671 fs = snd_enter_user();
91672 - err = snd_pcm_delay(substream, &delay);
91673 + err = snd_pcm_delay(substream, (snd_pcm_sframes_t __force_user *)&delay);
91674 snd_leave_user(fs);
91675 if (err < 0)
91676 return err;
91677 diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c
91678 index 09b4286..8620fac 100644
91679 --- a/sound/core/pcm_native.c
91680 +++ b/sound/core/pcm_native.c
91681 @@ -2806,11 +2806,11 @@ int snd_pcm_kernel_ioctl(struct snd_pcm_substream *substream,
91682 switch (substream->stream) {
91683 case SNDRV_PCM_STREAM_PLAYBACK:
91684 result = snd_pcm_playback_ioctl1(NULL, substream, cmd,
91685 - (void __user *)arg);
91686 + (void __force_user *)arg);
91687 break;
91688 case SNDRV_PCM_STREAM_CAPTURE:
91689 result = snd_pcm_capture_ioctl1(NULL, substream, cmd,
91690 - (void __user *)arg);
91691 + (void __force_user *)arg);
91692 break;
91693 default:
91694 result = -EINVAL;
91695 diff --git a/sound/core/seq/seq_device.c b/sound/core/seq/seq_device.c
91696 index 040c60e..989a19a 100644
91697 --- a/sound/core/seq/seq_device.c
91698 +++ b/sound/core/seq/seq_device.c
91699 @@ -64,7 +64,7 @@ struct ops_list {
91700 int argsize; /* argument size */
91701
91702 /* operators */
91703 - struct snd_seq_dev_ops ops;
91704 + struct snd_seq_dev_ops *ops;
91705
91706 /* registered devices */
91707 struct list_head dev_list; /* list of devices */
91708 @@ -333,7 +333,7 @@ int snd_seq_device_register_driver(char *id, struct snd_seq_dev_ops *entry,
91709
91710 mutex_lock(&ops->reg_mutex);
91711 /* copy driver operators */
91712 - ops->ops = *entry;
91713 + ops->ops = entry;
91714 ops->driver |= DRIVER_LOADED;
91715 ops->argsize = argsize;
91716
91717 @@ -463,7 +463,7 @@ static int init_device(struct snd_seq_device *dev, struct ops_list *ops)
91718 dev->name, ops->id, ops->argsize, dev->argsize);
91719 return -EINVAL;
91720 }
91721 - if (ops->ops.init_device(dev) >= 0) {
91722 + if (ops->ops->init_device(dev) >= 0) {
91723 dev->status = SNDRV_SEQ_DEVICE_REGISTERED;
91724 ops->num_init_devices++;
91725 } else {
91726 @@ -490,7 +490,7 @@ static int free_device(struct snd_seq_device *dev, struct ops_list *ops)
91727 dev->name, ops->id, ops->argsize, dev->argsize);
91728 return -EINVAL;
91729 }
91730 - if ((result = ops->ops.free_device(dev)) >= 0 || result == -ENXIO) {
91731 + if ((result = ops->ops->free_device(dev)) >= 0 || result == -ENXIO) {
91732 dev->status = SNDRV_SEQ_DEVICE_FREE;
91733 dev->driver_data = NULL;
91734 ops->num_init_devices--;
91735 diff --git a/sound/drivers/mts64.c b/sound/drivers/mts64.c
91736 index 4e0dd22..7a1f32c 100644
91737 --- a/sound/drivers/mts64.c
91738 +++ b/sound/drivers/mts64.c
91739 @@ -29,6 +29,7 @@
91740 #include <sound/initval.h>
91741 #include <sound/rawmidi.h>
91742 #include <sound/control.h>
91743 +#include <asm/local.h>
91744
91745 #define CARD_NAME "Miditerminal 4140"
91746 #define DRIVER_NAME "MTS64"
91747 @@ -67,7 +68,7 @@ struct mts64 {
91748 struct pardevice *pardev;
91749 int pardev_claimed;
91750
91751 - int open_count;
91752 + local_t open_count;
91753 int current_midi_output_port;
91754 int current_midi_input_port;
91755 u8 mode[MTS64_NUM_INPUT_PORTS];
91756 @@ -697,7 +698,7 @@ static int snd_mts64_rawmidi_open(struct snd_rawmidi_substream *substream)
91757 {
91758 struct mts64 *mts = substream->rmidi->private_data;
91759
91760 - if (mts->open_count == 0) {
91761 + if (local_read(&mts->open_count) == 0) {
91762 /* We don't need a spinlock here, because this is just called
91763 if the device has not been opened before.
91764 So there aren't any IRQs from the device */
91765 @@ -705,7 +706,7 @@ static int snd_mts64_rawmidi_open(struct snd_rawmidi_substream *substream)
91766
91767 msleep(50);
91768 }
91769 - ++(mts->open_count);
91770 + local_inc(&mts->open_count);
91771
91772 return 0;
91773 }
91774 @@ -715,8 +716,7 @@ static int snd_mts64_rawmidi_close(struct snd_rawmidi_substream *substream)
91775 struct mts64 *mts = substream->rmidi->private_data;
91776 unsigned long flags;
91777
91778 - --(mts->open_count);
91779 - if (mts->open_count == 0) {
91780 + if (local_dec_return(&mts->open_count) == 0) {
91781 /* We need the spinlock_irqsave here because we can still
91782 have IRQs at this point */
91783 spin_lock_irqsave(&mts->lock, flags);
91784 @@ -725,8 +725,8 @@ static int snd_mts64_rawmidi_close(struct snd_rawmidi_substream *substream)
91785
91786 msleep(500);
91787
91788 - } else if (mts->open_count < 0)
91789 - mts->open_count = 0;
91790 + } else if (local_read(&mts->open_count) < 0)
91791 + local_set(&mts->open_count, 0);
91792
91793 return 0;
91794 }
91795 diff --git a/sound/drivers/opl4/opl4_lib.c b/sound/drivers/opl4/opl4_lib.c
91796 index b953fb4..1999c01 100644
91797 --- a/sound/drivers/opl4/opl4_lib.c
91798 +++ b/sound/drivers/opl4/opl4_lib.c
91799 @@ -29,7 +29,7 @@ MODULE_AUTHOR("Clemens Ladisch <clemens@ladisch.de>");
91800 MODULE_DESCRIPTION("OPL4 driver");
91801 MODULE_LICENSE("GPL");
91802
91803 -static void inline snd_opl4_wait(struct snd_opl4 *opl4)
91804 +static inline void snd_opl4_wait(struct snd_opl4 *opl4)
91805 {
91806 int timeout = 10;
91807 while ((inb(opl4->fm_port) & OPL4_STATUS_BUSY) && --timeout > 0)
91808 diff --git a/sound/drivers/portman2x4.c b/sound/drivers/portman2x4.c
91809 index 991018d..8984740 100644
91810 --- a/sound/drivers/portman2x4.c
91811 +++ b/sound/drivers/portman2x4.c
91812 @@ -48,6 +48,7 @@
91813 #include <sound/initval.h>
91814 #include <sound/rawmidi.h>
91815 #include <sound/control.h>
91816 +#include <asm/local.h>
91817
91818 #define CARD_NAME "Portman 2x4"
91819 #define DRIVER_NAME "portman"
91820 @@ -85,7 +86,7 @@ struct portman {
91821 struct pardevice *pardev;
91822 int pardev_claimed;
91823
91824 - int open_count;
91825 + local_t open_count;
91826 int mode[PORTMAN_NUM_INPUT_PORTS];
91827 struct snd_rawmidi_substream *midi_input[PORTMAN_NUM_INPUT_PORTS];
91828 };
91829 diff --git a/sound/firewire/amdtp.c b/sound/firewire/amdtp.c
91830 index ea995af..f1bfa37 100644
91831 --- a/sound/firewire/amdtp.c
91832 +++ b/sound/firewire/amdtp.c
91833 @@ -389,7 +389,7 @@ static void queue_out_packet(struct amdtp_out_stream *s, unsigned int cycle)
91834 ptr = s->pcm_buffer_pointer + data_blocks;
91835 if (ptr >= pcm->runtime->buffer_size)
91836 ptr -= pcm->runtime->buffer_size;
91837 - ACCESS_ONCE(s->pcm_buffer_pointer) = ptr;
91838 + ACCESS_ONCE_RW(s->pcm_buffer_pointer) = ptr;
91839
91840 s->pcm_period_pointer += data_blocks;
91841 if (s->pcm_period_pointer >= pcm->runtime->period_size) {
91842 @@ -557,7 +557,7 @@ EXPORT_SYMBOL(amdtp_out_stream_pcm_pointer);
91843 */
91844 void amdtp_out_stream_update(struct amdtp_out_stream *s)
91845 {
91846 - ACCESS_ONCE(s->source_node_id_field) =
91847 + ACCESS_ONCE_RW(s->source_node_id_field) =
91848 (fw_parent_device(s->unit)->card->node_id & 0x3f) << 24;
91849 }
91850 EXPORT_SYMBOL(amdtp_out_stream_update);
91851 diff --git a/sound/firewire/amdtp.h b/sound/firewire/amdtp.h
91852 index b680c5e..061b7a0 100644
91853 --- a/sound/firewire/amdtp.h
91854 +++ b/sound/firewire/amdtp.h
91855 @@ -139,7 +139,7 @@ static inline bool amdtp_out_streaming_error(struct amdtp_out_stream *s)
91856 static inline void amdtp_out_stream_pcm_trigger(struct amdtp_out_stream *s,
91857 struct snd_pcm_substream *pcm)
91858 {
91859 - ACCESS_ONCE(s->pcm) = pcm;
91860 + ACCESS_ONCE_RW(s->pcm) = pcm;
91861 }
91862
91863 static inline bool cip_sfc_is_base_44100(enum cip_sfc sfc)
91864 diff --git a/sound/firewire/isight.c b/sound/firewire/isight.c
91865 index d428ffe..751ef78 100644
91866 --- a/sound/firewire/isight.c
91867 +++ b/sound/firewire/isight.c
91868 @@ -96,7 +96,7 @@ static void isight_update_pointers(struct isight *isight, unsigned int count)
91869 ptr += count;
91870 if (ptr >= runtime->buffer_size)
91871 ptr -= runtime->buffer_size;
91872 - ACCESS_ONCE(isight->buffer_pointer) = ptr;
91873 + ACCESS_ONCE_RW(isight->buffer_pointer) = ptr;
91874
91875 isight->period_counter += count;
91876 if (isight->period_counter >= runtime->period_size) {
91877 @@ -307,7 +307,7 @@ static int isight_hw_params(struct snd_pcm_substream *substream,
91878 if (err < 0)
91879 return err;
91880
91881 - ACCESS_ONCE(isight->pcm_active) = true;
91882 + ACCESS_ONCE_RW(isight->pcm_active) = true;
91883
91884 return 0;
91885 }
91886 @@ -340,7 +340,7 @@ static int isight_hw_free(struct snd_pcm_substream *substream)
91887 {
91888 struct isight *isight = substream->private_data;
91889
91890 - ACCESS_ONCE(isight->pcm_active) = false;
91891 + ACCESS_ONCE_RW(isight->pcm_active) = false;
91892
91893 mutex_lock(&isight->mutex);
91894 isight_stop_streaming(isight);
91895 @@ -433,10 +433,10 @@ static int isight_trigger(struct snd_pcm_substream *substream, int cmd)
91896
91897 switch (cmd) {
91898 case SNDRV_PCM_TRIGGER_START:
91899 - ACCESS_ONCE(isight->pcm_running) = true;
91900 + ACCESS_ONCE_RW(isight->pcm_running) = true;
91901 break;
91902 case SNDRV_PCM_TRIGGER_STOP:
91903 - ACCESS_ONCE(isight->pcm_running) = false;
91904 + ACCESS_ONCE_RW(isight->pcm_running) = false;
91905 break;
91906 default:
91907 return -EINVAL;
91908 diff --git a/sound/firewire/scs1x.c b/sound/firewire/scs1x.c
91909 index 844a555..985ab83 100644
91910 --- a/sound/firewire/scs1x.c
91911 +++ b/sound/firewire/scs1x.c
91912 @@ -74,7 +74,7 @@ static void scs_output_trigger(struct snd_rawmidi_substream *stream, int up)
91913 {
91914 struct scs *scs = stream->rmidi->private_data;
91915
91916 - ACCESS_ONCE(scs->output) = up ? stream : NULL;
91917 + ACCESS_ONCE_RW(scs->output) = up ? stream : NULL;
91918 if (up) {
91919 scs->output_idle = false;
91920 tasklet_schedule(&scs->tasklet);
91921 @@ -257,7 +257,7 @@ static void scs_input_trigger(struct snd_rawmidi_substream *stream, int up)
91922 {
91923 struct scs *scs = stream->rmidi->private_data;
91924
91925 - ACCESS_ONCE(scs->input) = up ? stream : NULL;
91926 + ACCESS_ONCE_RW(scs->input) = up ? stream : NULL;
91927 }
91928
91929 static void scs_input_escaped_byte(struct snd_rawmidi_substream *stream,
91930 @@ -457,8 +457,8 @@ static int scs_remove(struct device *dev)
91931
91932 snd_card_disconnect(scs->card);
91933
91934 - ACCESS_ONCE(scs->output) = NULL;
91935 - ACCESS_ONCE(scs->input) = NULL;
91936 + ACCESS_ONCE_RW(scs->output) = NULL;
91937 + ACCESS_ONCE_RW(scs->input) = NULL;
91938
91939 wait_event(scs->idle_wait, scs->output_idle);
91940
91941 diff --git a/sound/oss/sb_audio.c b/sound/oss/sb_audio.c
91942 index 048439a..3be9f6f 100644
91943 --- a/sound/oss/sb_audio.c
91944 +++ b/sound/oss/sb_audio.c
91945 @@ -904,7 +904,7 @@ sb16_copy_from_user(int dev,
91946 buf16 = (signed short *)(localbuf + localoffs);
91947 while (c)
91948 {
91949 - locallen = (c >= LBUFCOPYSIZE ? LBUFCOPYSIZE : c);
91950 + locallen = ((unsigned)c >= LBUFCOPYSIZE ? LBUFCOPYSIZE : c);
91951 if (copy_from_user(lbuf8,
91952 userbuf+useroffs + p,
91953 locallen))
91954 diff --git a/sound/oss/swarm_cs4297a.c b/sound/oss/swarm_cs4297a.c
91955 index 7d8803a..559f8d0 100644
91956 --- a/sound/oss/swarm_cs4297a.c
91957 +++ b/sound/oss/swarm_cs4297a.c
91958 @@ -2621,7 +2621,6 @@ static int __init cs4297a_init(void)
91959 {
91960 struct cs4297a_state *s;
91961 u32 pwr, id;
91962 - mm_segment_t fs;
91963 int rval;
91964 #ifndef CONFIG_BCM_CS4297A_CSWARM
91965 u64 cfg;
91966 @@ -2711,22 +2710,23 @@ static int __init cs4297a_init(void)
91967 if (!rval) {
91968 char *sb1250_duart_present;
91969
91970 +#if 0
91971 + mm_segment_t fs;
91972 fs = get_fs();
91973 set_fs(KERNEL_DS);
91974 -#if 0
91975 val = SOUND_MASK_LINE;
91976 mixer_ioctl(s, SOUND_MIXER_WRITE_RECSRC, (unsigned long) &val);
91977 for (i = 0; i < ARRAY_SIZE(initvol); i++) {
91978 val = initvol[i].vol;
91979 mixer_ioctl(s, initvol[i].mixch, (unsigned long) &val);
91980 }
91981 + set_fs(fs);
91982 // cs4297a_write_ac97(s, 0x18, 0x0808);
91983 #else
91984 // cs4297a_write_ac97(s, 0x5e, 0x180);
91985 cs4297a_write_ac97(s, 0x02, 0x0808);
91986 cs4297a_write_ac97(s, 0x18, 0x0808);
91987 #endif
91988 - set_fs(fs);
91989
91990 list_add(&s->list, &cs4297a_devs);
91991
91992 diff --git a/sound/pci/ymfpci/ymfpci.h b/sound/pci/ymfpci/ymfpci.h
91993 index 4631a23..001ae57 100644
91994 --- a/sound/pci/ymfpci/ymfpci.h
91995 +++ b/sound/pci/ymfpci/ymfpci.h
91996 @@ -358,7 +358,7 @@ struct snd_ymfpci {
91997 spinlock_t reg_lock;
91998 spinlock_t voice_lock;
91999 wait_queue_head_t interrupt_sleep;
92000 - atomic_t interrupt_sleep_count;
92001 + atomic_unchecked_t interrupt_sleep_count;
92002 struct snd_info_entry *proc_entry;
92003 const struct firmware *dsp_microcode;
92004 const struct firmware *controller_microcode;
92005 diff --git a/sound/pci/ymfpci/ymfpci_main.c b/sound/pci/ymfpci/ymfpci_main.c
92006 index 22056c5..25d3244 100644
92007 --- a/sound/pci/ymfpci/ymfpci_main.c
92008 +++ b/sound/pci/ymfpci/ymfpci_main.c
92009 @@ -202,8 +202,8 @@ static void snd_ymfpci_hw_stop(struct snd_ymfpci *chip)
92010 if ((snd_ymfpci_readl(chip, YDSXGR_STATUS) & 2) == 0)
92011 break;
92012 }
92013 - if (atomic_read(&chip->interrupt_sleep_count)) {
92014 - atomic_set(&chip->interrupt_sleep_count, 0);
92015 + if (atomic_read_unchecked(&chip->interrupt_sleep_count)) {
92016 + atomic_set_unchecked(&chip->interrupt_sleep_count, 0);
92017 wake_up(&chip->interrupt_sleep);
92018 }
92019 __end:
92020 @@ -787,7 +787,7 @@ static void snd_ymfpci_irq_wait(struct snd_ymfpci *chip)
92021 continue;
92022 init_waitqueue_entry(&wait, current);
92023 add_wait_queue(&chip->interrupt_sleep, &wait);
92024 - atomic_inc(&chip->interrupt_sleep_count);
92025 + atomic_inc_unchecked(&chip->interrupt_sleep_count);
92026 schedule_timeout_uninterruptible(msecs_to_jiffies(50));
92027 remove_wait_queue(&chip->interrupt_sleep, &wait);
92028 }
92029 @@ -825,8 +825,8 @@ static irqreturn_t snd_ymfpci_interrupt(int irq, void *dev_id)
92030 snd_ymfpci_writel(chip, YDSXGR_MODE, mode);
92031 spin_unlock(&chip->reg_lock);
92032
92033 - if (atomic_read(&chip->interrupt_sleep_count)) {
92034 - atomic_set(&chip->interrupt_sleep_count, 0);
92035 + if (atomic_read_unchecked(&chip->interrupt_sleep_count)) {
92036 + atomic_set_unchecked(&chip->interrupt_sleep_count, 0);
92037 wake_up(&chip->interrupt_sleep);
92038 }
92039 }
92040 @@ -2421,7 +2421,7 @@ int snd_ymfpci_create(struct snd_card *card,
92041 spin_lock_init(&chip->reg_lock);
92042 spin_lock_init(&chip->voice_lock);
92043 init_waitqueue_head(&chip->interrupt_sleep);
92044 - atomic_set(&chip->interrupt_sleep_count, 0);
92045 + atomic_set_unchecked(&chip->interrupt_sleep_count, 0);
92046 chip->card = card;
92047 chip->pci = pci;
92048 chip->irq = -1;
92049 diff --git a/tools/gcc/.gitignore b/tools/gcc/.gitignore
92050 new file mode 100644
92051 index 0000000..50f2f2f
92052 --- /dev/null
92053 +++ b/tools/gcc/.gitignore
92054 @@ -0,0 +1 @@
92055 +size_overflow_hash.h
92056 diff --git a/tools/gcc/Makefile b/tools/gcc/Makefile
92057 new file mode 100644
92058 index 0000000..6920fb3
92059 --- /dev/null
92060 +++ b/tools/gcc/Makefile
92061 @@ -0,0 +1,43 @@
92062 +#CC := gcc
92063 +#PLUGIN_SOURCE_FILES := pax_plugin.c
92064 +#PLUGIN_OBJECT_FILES := $(patsubst %.c,%.o,$(PLUGIN_SOURCE_FILES))
92065 +GCCPLUGINS_DIR := $(shell $(CC) -print-file-name=plugin)
92066 +#CFLAGS += -I$(GCCPLUGINS_DIR)/include -fPIC -O2 -Wall -W -std=gnu99
92067 +
92068 +ifeq ($(PLUGINCC),$(HOSTCC))
92069 +HOSTLIBS := hostlibs
92070 +HOST_EXTRACFLAGS += -I$(GCCPLUGINS_DIR)/include -std=gnu99 -ggdb
92071 +else
92072 +HOSTLIBS := hostcxxlibs
92073 +HOST_EXTRACXXFLAGS += -I$(GCCPLUGINS_DIR)/include -std=gnu++98 -ggdb -Wno-unused-parameter
92074 +endif
92075 +
92076 +$(HOSTLIBS)-y := constify_plugin.so
92077 +$(HOSTLIBS)-$(CONFIG_PAX_MEMORY_STACKLEAK) += stackleak_plugin.so
92078 +$(HOSTLIBS)-$(CONFIG_KALLOCSTAT_PLUGIN) += kallocstat_plugin.so
92079 +$(HOSTLIBS)-$(CONFIG_PAX_KERNEXEC_PLUGIN) += kernexec_plugin.so
92080 +$(HOSTLIBS)-$(CONFIG_CHECKER_PLUGIN) += checker_plugin.so
92081 +$(HOSTLIBS)-y += colorize_plugin.so
92082 +$(HOSTLIBS)-$(CONFIG_PAX_SIZE_OVERFLOW) += size_overflow_plugin.so
92083 +$(HOSTLIBS)-$(CONFIG_PAX_LATENT_ENTROPY) += latent_entropy_plugin.so
92084 +
92085 +always := $($(HOSTLIBS)-y)
92086 +
92087 +constify_plugin-objs := constify_plugin.o
92088 +stackleak_plugin-objs := stackleak_plugin.o
92089 +kallocstat_plugin-objs := kallocstat_plugin.o
92090 +kernexec_plugin-objs := kernexec_plugin.o
92091 +checker_plugin-objs := checker_plugin.o
92092 +colorize_plugin-objs := colorize_plugin.o
92093 +size_overflow_plugin-objs := size_overflow_plugin.o
92094 +latent_entropy_plugin-objs := latent_entropy_plugin.o
92095 +
92096 +$(obj)/size_overflow_plugin.o: $(objtree)/$(obj)/size_overflow_hash.h
92097 +
92098 +quiet_cmd_build_size_overflow_hash = GENHASH $@
92099 + cmd_build_size_overflow_hash = \
92100 + $(CONFIG_SHELL) $(srctree)/$(src)/generate_size_overflow_hash.sh -d $< -o $@
92101 +$(objtree)/$(obj)/size_overflow_hash.h: $(src)/size_overflow_hash.data FORCE
92102 + $(call if_changed,build_size_overflow_hash)
92103 +
92104 +targets += size_overflow_hash.h
92105 diff --git a/tools/gcc/checker_plugin.c b/tools/gcc/checker_plugin.c
92106 new file mode 100644
92107 index 0000000..d41b5af
92108 --- /dev/null
92109 +++ b/tools/gcc/checker_plugin.c
92110 @@ -0,0 +1,171 @@
92111 +/*
92112 + * Copyright 2011 by the PaX Team <pageexec@freemail.hu>
92113 + * Licensed under the GPL v2
92114 + *
92115 + * Note: the choice of the license means that the compilation process is
92116 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
92117 + * but for the kernel it doesn't matter since it doesn't link against
92118 + * any of the gcc libraries
92119 + *
92120 + * gcc plugin to implement various sparse (source code checker) features
92121 + *
92122 + * TODO:
92123 + * - define separate __iomem, __percpu and __rcu address spaces (lots of code to patch)
92124 + *
92125 + * BUGS:
92126 + * - none known
92127 + */
92128 +#include "gcc-plugin.h"
92129 +#include "config.h"
92130 +#include "system.h"
92131 +#include "coretypes.h"
92132 +#include "tree.h"
92133 +#include "tree-pass.h"
92134 +#include "flags.h"
92135 +#include "intl.h"
92136 +#include "toplev.h"
92137 +#include "plugin.h"
92138 +//#include "expr.h" where are you...
92139 +#include "diagnostic.h"
92140 +#include "plugin-version.h"
92141 +#include "tm.h"
92142 +#include "function.h"
92143 +#include "basic-block.h"
92144 +#include "gimple.h"
92145 +#include "rtl.h"
92146 +#include "emit-rtl.h"
92147 +#include "tree-flow.h"
92148 +#include "target.h"
92149 +
92150 +extern void c_register_addr_space (const char *str, addr_space_t as);
92151 +extern enum machine_mode default_addr_space_pointer_mode (addr_space_t);
92152 +extern enum machine_mode default_addr_space_address_mode (addr_space_t);
92153 +extern bool default_addr_space_valid_pointer_mode(enum machine_mode mode, addr_space_t as);
92154 +extern bool default_addr_space_legitimate_address_p(enum machine_mode mode, rtx mem, bool strict, addr_space_t as);
92155 +extern rtx default_addr_space_legitimize_address(rtx x, rtx oldx, enum machine_mode mode, addr_space_t as);
92156 +
92157 +extern void print_gimple_stmt(FILE *, gimple, int, int);
92158 +extern rtx emit_move_insn(rtx x, rtx y);
92159 +
92160 +int plugin_is_GPL_compatible;
92161 +
92162 +static struct plugin_info checker_plugin_info = {
92163 + .version = "201111150100",
92164 +};
92165 +
92166 +#define ADDR_SPACE_KERNEL 0
92167 +#define ADDR_SPACE_FORCE_KERNEL 1
92168 +#define ADDR_SPACE_USER 2
92169 +#define ADDR_SPACE_FORCE_USER 3
92170 +#define ADDR_SPACE_IOMEM 0
92171 +#define ADDR_SPACE_FORCE_IOMEM 0
92172 +#define ADDR_SPACE_PERCPU 0
92173 +#define ADDR_SPACE_FORCE_PERCPU 0
92174 +#define ADDR_SPACE_RCU 0
92175 +#define ADDR_SPACE_FORCE_RCU 0
92176 +
92177 +static enum machine_mode checker_addr_space_pointer_mode(addr_space_t addrspace)
92178 +{
92179 + return default_addr_space_pointer_mode(ADDR_SPACE_GENERIC);
92180 +}
92181 +
92182 +static enum machine_mode checker_addr_space_address_mode(addr_space_t addrspace)
92183 +{
92184 + return default_addr_space_address_mode(ADDR_SPACE_GENERIC);
92185 +}
92186 +
92187 +static bool checker_addr_space_valid_pointer_mode(enum machine_mode mode, addr_space_t as)
92188 +{
92189 + return default_addr_space_valid_pointer_mode(mode, as);
92190 +}
92191 +
92192 +static bool checker_addr_space_legitimate_address_p(enum machine_mode mode, rtx mem, bool strict, addr_space_t as)
92193 +{
92194 + return default_addr_space_legitimate_address_p(mode, mem, strict, ADDR_SPACE_GENERIC);
92195 +}
92196 +
92197 +static rtx checker_addr_space_legitimize_address(rtx x, rtx oldx, enum machine_mode mode, addr_space_t as)
92198 +{
92199 + return default_addr_space_legitimize_address(x, oldx, mode, as);
92200 +}
92201 +
92202 +static bool checker_addr_space_subset_p(addr_space_t subset, addr_space_t superset)
92203 +{
92204 + if (subset == ADDR_SPACE_FORCE_KERNEL && superset == ADDR_SPACE_KERNEL)
92205 + return true;
92206 +
92207 + if (subset == ADDR_SPACE_FORCE_USER && superset == ADDR_SPACE_USER)
92208 + return true;
92209 +
92210 + if (subset == ADDR_SPACE_FORCE_IOMEM && superset == ADDR_SPACE_IOMEM)
92211 + return true;
92212 +
92213 + if (subset == ADDR_SPACE_KERNEL && superset == ADDR_SPACE_FORCE_USER)
92214 + return true;
92215 +
92216 + if (subset == ADDR_SPACE_KERNEL && superset == ADDR_SPACE_FORCE_IOMEM)
92217 + return true;
92218 +
92219 + if (subset == ADDR_SPACE_USER && superset == ADDR_SPACE_FORCE_KERNEL)
92220 + return true;
92221 +
92222 + if (subset == ADDR_SPACE_IOMEM && superset == ADDR_SPACE_FORCE_KERNEL)
92223 + return true;
92224 +
92225 + return subset == superset;
92226 +}
92227 +
92228 +static rtx checker_addr_space_convert(rtx op, tree from_type, tree to_type)
92229 +{
92230 +// addr_space_t from_as = TYPE_ADDR_SPACE(TREE_TYPE(from_type));
92231 +// addr_space_t to_as = TYPE_ADDR_SPACE(TREE_TYPE(to_type));
92232 +
92233 + return op;
92234 +}
92235 +
92236 +static void register_checker_address_spaces(void *event_data, void *data)
92237 +{
92238 + c_register_addr_space("__kernel", ADDR_SPACE_KERNEL);
92239 + c_register_addr_space("__force_kernel", ADDR_SPACE_FORCE_KERNEL);
92240 + c_register_addr_space("__user", ADDR_SPACE_USER);
92241 + c_register_addr_space("__force_user", ADDR_SPACE_FORCE_USER);
92242 +// c_register_addr_space("__iomem", ADDR_SPACE_IOMEM);
92243 +// c_register_addr_space("__force_iomem", ADDR_SPACE_FORCE_IOMEM);
92244 +// c_register_addr_space("__percpu", ADDR_SPACE_PERCPU);
92245 +// c_register_addr_space("__force_percpu", ADDR_SPACE_FORCE_PERCPU);
92246 +// c_register_addr_space("__rcu", ADDR_SPACE_RCU);
92247 +// c_register_addr_space("__force_rcu", ADDR_SPACE_FORCE_RCU);
92248 +
92249 + targetm.addr_space.pointer_mode = checker_addr_space_pointer_mode;
92250 + targetm.addr_space.address_mode = checker_addr_space_address_mode;
92251 + targetm.addr_space.valid_pointer_mode = checker_addr_space_valid_pointer_mode;
92252 + targetm.addr_space.legitimate_address_p = checker_addr_space_legitimate_address_p;
92253 +// targetm.addr_space.legitimize_address = checker_addr_space_legitimize_address;
92254 + targetm.addr_space.subset_p = checker_addr_space_subset_p;
92255 + targetm.addr_space.convert = checker_addr_space_convert;
92256 +}
92257 +
92258 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
92259 +{
92260 + const char * const plugin_name = plugin_info->base_name;
92261 + const int argc = plugin_info->argc;
92262 + const struct plugin_argument * const argv = plugin_info->argv;
92263 + int i;
92264 +
92265 + if (!plugin_default_version_check(version, &gcc_version)) {
92266 + error(G_("incompatible gcc/plugin versions"));
92267 + return 1;
92268 + }
92269 +
92270 + register_callback(plugin_name, PLUGIN_INFO, NULL, &checker_plugin_info);
92271 +
92272 + for (i = 0; i < argc; ++i)
92273 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
92274 +
92275 + if (TARGET_64BIT == 0)
92276 + return 0;
92277 +
92278 + register_callback(plugin_name, PLUGIN_PRAGMAS, register_checker_address_spaces, NULL);
92279 +
92280 + return 0;
92281 +}
92282 diff --git a/tools/gcc/colorize_plugin.c b/tools/gcc/colorize_plugin.c
92283 new file mode 100644
92284 index 0000000..414fe5e
92285 --- /dev/null
92286 +++ b/tools/gcc/colorize_plugin.c
92287 @@ -0,0 +1,151 @@
92288 +/*
92289 + * Copyright 2012-2013 by PaX Team <pageexec@freemail.hu>
92290 + * Licensed under the GPL v2
92291 + *
92292 + * Note: the choice of the license means that the compilation process is
92293 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
92294 + * but for the kernel it doesn't matter since it doesn't link against
92295 + * any of the gcc libraries
92296 + *
92297 + * gcc plugin to colorize diagnostic output
92298 + *
92299 + */
92300 +
92301 +#include "gcc-plugin.h"
92302 +#include "config.h"
92303 +#include "system.h"
92304 +#include "coretypes.h"
92305 +#include "tree.h"
92306 +#include "tree-pass.h"
92307 +#include "flags.h"
92308 +#include "intl.h"
92309 +#include "toplev.h"
92310 +#include "plugin.h"
92311 +#include "diagnostic.h"
92312 +#include "plugin-version.h"
92313 +#include "tm.h"
92314 +
92315 +int plugin_is_GPL_compatible;
92316 +
92317 +static struct plugin_info colorize_plugin_info = {
92318 + .version = "201302112000",
92319 + .help = NULL,
92320 +};
92321 +
92322 +#define GREEN "\033[32m\033[2m"
92323 +#define LIGHTGREEN "\033[32m\033[1m"
92324 +#define YELLOW "\033[33m\033[2m"
92325 +#define LIGHTYELLOW "\033[33m\033[1m"
92326 +#define RED "\033[31m\033[2m"
92327 +#define LIGHTRED "\033[31m\033[1m"
92328 +#define BLUE "\033[34m\033[2m"
92329 +#define LIGHTBLUE "\033[34m\033[1m"
92330 +#define BRIGHT "\033[m\033[1m"
92331 +#define NORMAL "\033[m"
92332 +
92333 +static diagnostic_starter_fn old_starter;
92334 +static diagnostic_finalizer_fn old_finalizer;
92335 +
92336 +static void start_colorize(diagnostic_context *context, diagnostic_info *diagnostic)
92337 +{
92338 + const char *color;
92339 + char *newprefix;
92340 +
92341 + switch (diagnostic->kind) {
92342 + case DK_NOTE:
92343 + color = LIGHTBLUE;
92344 + break;
92345 +
92346 + case DK_PEDWARN:
92347 + case DK_WARNING:
92348 + color = LIGHTYELLOW;
92349 + break;
92350 +
92351 + case DK_ERROR:
92352 + case DK_FATAL:
92353 + case DK_ICE:
92354 + case DK_PERMERROR:
92355 + case DK_SORRY:
92356 + color = LIGHTRED;
92357 + break;
92358 +
92359 + default:
92360 + color = NORMAL;
92361 + }
92362 +
92363 + old_starter(context, diagnostic);
92364 + if (-1 == asprintf(&newprefix, "%s%s" NORMAL, color, context->printer->prefix))
92365 + return;
92366 + pp_destroy_prefix(context->printer);
92367 + pp_set_prefix(context->printer, newprefix);
92368 +}
92369 +
92370 +static void finalize_colorize(diagnostic_context *context, diagnostic_info *diagnostic)
92371 +{
92372 + old_finalizer(context, diagnostic);
92373 +}
92374 +
92375 +static void colorize_arm(void)
92376 +{
92377 + old_starter = diagnostic_starter(global_dc);
92378 + old_finalizer = diagnostic_finalizer(global_dc);
92379 +
92380 + diagnostic_starter(global_dc) = start_colorize;
92381 + diagnostic_finalizer(global_dc) = finalize_colorize;
92382 +}
92383 +
92384 +static unsigned int execute_colorize_rearm(void)
92385 +{
92386 + if (diagnostic_starter(global_dc) == start_colorize)
92387 + return 0;
92388 +
92389 + colorize_arm();
92390 + return 0;
92391 +}
92392 +
92393 +struct simple_ipa_opt_pass pass_ipa_colorize_rearm = {
92394 + .pass = {
92395 + .type = SIMPLE_IPA_PASS,
92396 + .name = "colorize_rearm",
92397 +#if BUILDING_GCC_VERSION >= 4008
92398 + .optinfo_flags = OPTGROUP_NONE,
92399 +#endif
92400 + .gate = NULL,
92401 + .execute = execute_colorize_rearm,
92402 + .sub = NULL,
92403 + .next = NULL,
92404 + .static_pass_number = 0,
92405 + .tv_id = TV_NONE,
92406 + .properties_required = 0,
92407 + .properties_provided = 0,
92408 + .properties_destroyed = 0,
92409 + .todo_flags_start = 0,
92410 + .todo_flags_finish = 0
92411 + }
92412 +};
92413 +
92414 +static void colorize_start_unit(void *gcc_data, void *user_data)
92415 +{
92416 + colorize_arm();
92417 +}
92418 +
92419 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
92420 +{
92421 + const char * const plugin_name = plugin_info->base_name;
92422 + struct register_pass_info colorize_rearm_pass_info = {
92423 + .pass = &pass_ipa_colorize_rearm.pass,
92424 + .reference_pass_name = "*free_lang_data",
92425 + .ref_pass_instance_number = 1,
92426 + .pos_op = PASS_POS_INSERT_AFTER
92427 + };
92428 +
92429 + if (!plugin_default_version_check(version, &gcc_version)) {
92430 + error(G_("incompatible gcc/plugin versions"));
92431 + return 1;
92432 + }
92433 +
92434 + register_callback(plugin_name, PLUGIN_INFO, NULL, &colorize_plugin_info);
92435 + register_callback(plugin_name, PLUGIN_START_UNIT, &colorize_start_unit, NULL);
92436 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &colorize_rearm_pass_info);
92437 + return 0;
92438 +}
92439 diff --git a/tools/gcc/constify_plugin.c b/tools/gcc/constify_plugin.c
92440 new file mode 100644
92441 index 0000000..43e86d6
92442 --- /dev/null
92443 +++ b/tools/gcc/constify_plugin.c
92444 @@ -0,0 +1,512 @@
92445 +/*
92446 + * Copyright 2011 by Emese Revfy <re.emese@gmail.com>
92447 + * Copyright 2011-2013 by PaX Team <pageexec@freemail.hu>
92448 + * Licensed under the GPL v2, or (at your option) v3
92449 + *
92450 + * This gcc plugin constifies all structures which contain only function pointers or are explicitly marked for constification.
92451 + *
92452 + * Homepage:
92453 + * http://www.grsecurity.net/~ephox/const_plugin/
92454 + *
92455 + * Usage:
92456 + * $ gcc -I`gcc -print-file-name=plugin`/include -fPIC -shared -O2 -o constify_plugin.so constify_plugin.c
92457 + * $ gcc -fplugin=constify_plugin.so test.c -O2
92458 + */
92459 +
92460 +#include "gcc-plugin.h"
92461 +#include "config.h"
92462 +#include "system.h"
92463 +#include "coretypes.h"
92464 +#include "tree.h"
92465 +#include "tree-pass.h"
92466 +#include "flags.h"
92467 +#include "intl.h"
92468 +#include "toplev.h"
92469 +#include "plugin.h"
92470 +#include "diagnostic.h"
92471 +#include "plugin-version.h"
92472 +#include "tm.h"
92473 +#include "function.h"
92474 +#include "basic-block.h"
92475 +#include "gimple.h"
92476 +#include "rtl.h"
92477 +#include "emit-rtl.h"
92478 +#include "tree-flow.h"
92479 +#include "target.h"
92480 +
92481 +// should come from c-tree.h if only it were installed for gcc 4.5...
92482 +#define C_TYPE_FIELDS_READONLY(TYPE) TREE_LANG_FLAG_1(TYPE)
92483 +
92484 +// unused type flag in all versions 4.5-4.8
92485 +#define TYPE_CONSTIFY_VISITED(TYPE) TYPE_LANG_FLAG_4(TYPE)
92486 +
92487 +int plugin_is_GPL_compatible;
92488 +
92489 +static struct plugin_info const_plugin_info = {
92490 + .version = "201303070020",
92491 + .help = "no-constify\tturn off constification\n",
92492 +};
92493 +
92494 +typedef struct {
92495 + bool has_fptr_field;
92496 + bool has_writable_field;
92497 + bool has_do_const_field;
92498 + bool has_no_const_field;
92499 +} constify_info;
92500 +
92501 +static const_tree get_field_type(const_tree field)
92502 +{
92503 + return strip_array_types(TREE_TYPE(field));
92504 +}
92505 +
92506 +static bool is_fptr(const_tree field)
92507 +{
92508 + const_tree ptr = get_field_type(field);
92509 +
92510 + if (TREE_CODE(ptr) != POINTER_TYPE)
92511 + return false;
92512 +
92513 + return TREE_CODE(TREE_TYPE(ptr)) == FUNCTION_TYPE;
92514 +}
92515 +
92516 +/*
92517 + * determine whether the given structure type meets the requirements for automatic constification,
92518 + * including the constification attributes on nested structure types
92519 + */
92520 +static void constifiable(const_tree node, constify_info *cinfo)
92521 +{
92522 + const_tree field;
92523 +
92524 + gcc_assert(TREE_CODE(node) == RECORD_TYPE || TREE_CODE(node) == UNION_TYPE);
92525 +
92526 + // e.g., pointer to structure fields while still constructing the structure type
92527 + if (TYPE_FIELDS(node) == NULL_TREE)
92528 + return;
92529 +
92530 + for (field = TYPE_FIELDS(node); field; field = TREE_CHAIN(field)) {
92531 + const_tree type = get_field_type(field);
92532 + enum tree_code code = TREE_CODE(type);
92533 +
92534 + if (node == type)
92535 + continue;
92536 +
92537 + if (is_fptr(field))
92538 + cinfo->has_fptr_field = true;
92539 + else if (!TREE_READONLY(field))
92540 + cinfo->has_writable_field = true;
92541 +
92542 + if (code == RECORD_TYPE || code == UNION_TYPE) {
92543 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
92544 + cinfo->has_do_const_field = true;
92545 + else if (lookup_attribute("no_const", TYPE_ATTRIBUTES(type)))
92546 + cinfo->has_no_const_field = true;
92547 + else
92548 + constifiable(type, cinfo);
92549 + }
92550 + }
92551 +}
92552 +
92553 +static bool constified(const_tree node)
92554 +{
92555 + constify_info cinfo = {
92556 + .has_fptr_field = false,
92557 + .has_writable_field = false,
92558 + .has_do_const_field = false,
92559 + .has_no_const_field = false
92560 + };
92561 +
92562 + gcc_assert(TREE_CODE(node) == RECORD_TYPE || TREE_CODE(node) == UNION_TYPE);
92563 +
92564 + if (lookup_attribute("no_const", TYPE_ATTRIBUTES(node))) {
92565 + gcc_assert(!TYPE_READONLY(node));
92566 + return false;
92567 + }
92568 +
92569 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(node))) {
92570 + gcc_assert(TYPE_READONLY(node));
92571 + return true;
92572 + }
92573 +
92574 + constifiable(node, &cinfo);
92575 + if ((!cinfo.has_fptr_field || cinfo.has_writable_field) && !cinfo.has_do_const_field)
92576 + return false;
92577 +
92578 + return TYPE_READONLY(node);
92579 +}
92580 +
92581 +static void deconstify_tree(tree node);
92582 +
92583 +static void deconstify_type(tree type)
92584 +{
92585 + tree field;
92586 +
92587 + gcc_assert(TREE_CODE(type) == RECORD_TYPE || TREE_CODE(type) == UNION_TYPE);
92588 +
92589 + for (field = TYPE_FIELDS(type); field; field = TREE_CHAIN(field)) {
92590 + const_tree fieldtype = get_field_type(field);
92591 +
92592 + // special case handling of simple ptr-to-same-array-type members
92593 + if (TREE_CODE(TREE_TYPE(field)) == POINTER_TYPE) {
92594 + const_tree ptrtype = TREE_TYPE(TREE_TYPE(field));
92595 +
92596 + if (TREE_CODE(ptrtype) != RECORD_TYPE && TREE_CODE(ptrtype) != UNION_TYPE)
92597 + continue;
92598 + if (TREE_TYPE(TREE_TYPE(field)) == type)
92599 + continue;
92600 + if (TYPE_MAIN_VARIANT(ptrtype) == TYPE_MAIN_VARIANT(type)) {
92601 + TREE_TYPE(field) = copy_node(TREE_TYPE(field));
92602 + TREE_TYPE(TREE_TYPE(field)) = type;
92603 + }
92604 + continue;
92605 + }
92606 + if (TREE_CODE(fieldtype) != RECORD_TYPE && TREE_CODE(fieldtype) != UNION_TYPE)
92607 + continue;
92608 + if (!constified(fieldtype))
92609 + continue;
92610 +
92611 + deconstify_tree(field);
92612 + TREE_READONLY(field) = 0;
92613 + }
92614 + TYPE_READONLY(type) = 0;
92615 + C_TYPE_FIELDS_READONLY(type) = 0;
92616 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
92617 + TYPE_ATTRIBUTES(type) = remove_attribute("do_const", TYPE_ATTRIBUTES(type));
92618 +}
92619 +
92620 +static void deconstify_tree(tree node)
92621 +{
92622 + tree old_type, new_type, field;
92623 +
92624 + old_type = TREE_TYPE(node);
92625 + while (TREE_CODE(old_type) == ARRAY_TYPE && TREE_CODE(TREE_TYPE(old_type)) != ARRAY_TYPE) {
92626 + node = TREE_TYPE(node) = copy_node(old_type);
92627 + old_type = TREE_TYPE(old_type);
92628 + }
92629 +
92630 + gcc_assert(TREE_CODE(old_type) == RECORD_TYPE || TREE_CODE(old_type) == UNION_TYPE);
92631 + gcc_assert(TYPE_READONLY(old_type) && (TYPE_QUALS(old_type) & TYPE_QUAL_CONST));
92632 +
92633 + new_type = build_qualified_type(old_type, TYPE_QUALS(old_type) & ~TYPE_QUAL_CONST);
92634 + TYPE_FIELDS(new_type) = copy_list(TYPE_FIELDS(new_type));
92635 + for (field = TYPE_FIELDS(new_type); field; field = TREE_CHAIN(field))
92636 + DECL_FIELD_CONTEXT(field) = new_type;
92637 +
92638 + deconstify_type(new_type);
92639 +
92640 + TREE_TYPE(node) = new_type;
92641 +}
92642 +
92643 +static tree handle_no_const_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
92644 +{
92645 + tree type;
92646 + constify_info cinfo = {
92647 + .has_fptr_field = false,
92648 + .has_writable_field = false,
92649 + .has_do_const_field = false,
92650 + .has_no_const_field = false
92651 + };
92652 +
92653 + *no_add_attrs = true;
92654 + if (TREE_CODE(*node) == FUNCTION_DECL) {
92655 + error("%qE attribute does not apply to functions", name);
92656 + return NULL_TREE;
92657 + }
92658 +
92659 + if (TREE_CODE(*node) == PARM_DECL) {
92660 + error("%qE attribute does not apply to function parameters", name);
92661 + return NULL_TREE;
92662 + }
92663 +
92664 + if (TREE_CODE(*node) == VAR_DECL) {
92665 + error("%qE attribute does not apply to variables", name);
92666 + return NULL_TREE;
92667 + }
92668 +
92669 + if (TYPE_P(*node)) {
92670 + *no_add_attrs = false;
92671 + type = *node;
92672 + } else {
92673 + gcc_assert(TREE_CODE(*node) == TYPE_DECL);
92674 + type = TREE_TYPE(*node);
92675 + }
92676 +
92677 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE) {
92678 + error("%qE attribute applies to struct and union types only", name);
92679 + return NULL_TREE;
92680 + }
92681 +
92682 + if (lookup_attribute(IDENTIFIER_POINTER(name), TYPE_ATTRIBUTES(type))) {
92683 + error("%qE attribute is already applied to the type", name);
92684 + return NULL_TREE;
92685 + }
92686 +
92687 + if (TYPE_P(*node)) {
92688 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
92689 + error("%qE attribute is incompatible with 'do_const'", name);
92690 + return NULL_TREE;
92691 + }
92692 +
92693 + constifiable(type, &cinfo);
92694 + if ((cinfo.has_fptr_field && !cinfo.has_writable_field) || lookup_attribute("do_const", TYPE_ATTRIBUTES(type))) {
92695 + deconstify_tree(*node);
92696 + TYPE_CONSTIFY_VISITED(TREE_TYPE(*node)) = 1;
92697 + return NULL_TREE;
92698 + }
92699 +
92700 + error("%qE attribute used on type that is not constified", name);
92701 + return NULL_TREE;
92702 +}
92703 +
92704 +static void constify_type(tree type)
92705 +{
92706 + TYPE_READONLY(type) = 1;
92707 + C_TYPE_FIELDS_READONLY(type) = 1;
92708 + TYPE_CONSTIFY_VISITED(type) = 1;
92709 +// TYPE_ATTRIBUTES(type) = tree_cons(get_identifier("do_const"), NULL_TREE, TYPE_ATTRIBUTES(type));
92710 +}
92711 +
92712 +static tree handle_do_const_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
92713 +{
92714 + *no_add_attrs = true;
92715 + if (!TYPE_P(*node)) {
92716 + error("%qE attribute applies to types only", name);
92717 + return NULL_TREE;
92718 + }
92719 +
92720 + if (TREE_CODE(*node) != RECORD_TYPE && TREE_CODE(*node) != UNION_TYPE) {
92721 + error("%qE attribute applies to struct and union types only", name);
92722 + return NULL_TREE;
92723 + }
92724 +
92725 + if (lookup_attribute(IDENTIFIER_POINTER(name), TYPE_ATTRIBUTES(*node))) {
92726 + error("%qE attribute is already applied to the type", name);
92727 + return NULL_TREE;
92728 + }
92729 +
92730 + if (lookup_attribute("no_const", TYPE_ATTRIBUTES(*node))) {
92731 + error("%qE attribute is incompatible with 'no_const'", name);
92732 + return NULL_TREE;
92733 + }
92734 +
92735 + *no_add_attrs = false;
92736 + return NULL_TREE;
92737 +}
92738 +
92739 +static struct attribute_spec no_const_attr = {
92740 + .name = "no_const",
92741 + .min_length = 0,
92742 + .max_length = 0,
92743 + .decl_required = false,
92744 + .type_required = false,
92745 + .function_type_required = false,
92746 + .handler = handle_no_const_attribute,
92747 +#if BUILDING_GCC_VERSION >= 4007
92748 + .affects_type_identity = true
92749 +#endif
92750 +};
92751 +
92752 +static struct attribute_spec do_const_attr = {
92753 + .name = "do_const",
92754 + .min_length = 0,
92755 + .max_length = 0,
92756 + .decl_required = false,
92757 + .type_required = false,
92758 + .function_type_required = false,
92759 + .handler = handle_do_const_attribute,
92760 +#if BUILDING_GCC_VERSION >= 4007
92761 + .affects_type_identity = true
92762 +#endif
92763 +};
92764 +
92765 +static void register_attributes(void *event_data, void *data)
92766 +{
92767 + register_attribute(&no_const_attr);
92768 + register_attribute(&do_const_attr);
92769 +}
92770 +
92771 +static void finish_type(void *event_data, void *data)
92772 +{
92773 + tree type = (tree)event_data;
92774 + constify_info cinfo = {
92775 + .has_fptr_field = false,
92776 + .has_writable_field = false,
92777 + .has_do_const_field = false,
92778 + .has_no_const_field = false
92779 + };
92780 +
92781 + if (type == NULL_TREE || type == error_mark_node)
92782 + return;
92783 +
92784 + if (TYPE_FIELDS(type) == NULL_TREE || TYPE_CONSTIFY_VISITED(type))
92785 + return;
92786 +
92787 + constifiable(type, &cinfo);
92788 +
92789 + if (TYPE_READONLY(type) && C_TYPE_FIELDS_READONLY(type)) {
92790 + if (!lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
92791 + return;
92792 + if (cinfo.has_writable_field)
92793 + return;
92794 + error("'do_const' attribute used on type that is%sconstified", cinfo.has_fptr_field ? " " : " not ");
92795 + return;
92796 + }
92797 +
92798 + if (lookup_attribute("no_const", TYPE_ATTRIBUTES(type))) {
92799 + if ((cinfo.has_fptr_field && !cinfo.has_writable_field) || cinfo.has_do_const_field) {
92800 + deconstify_type(type);
92801 + TYPE_CONSTIFY_VISITED(type) = 1;
92802 + } else
92803 + error("'no_const' attribute used on type that is not constified");
92804 + return;
92805 + }
92806 +
92807 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type))) {
92808 + constify_type(type);
92809 + return;
92810 + }
92811 +
92812 + if (cinfo.has_fptr_field && !cinfo.has_writable_field) {
92813 + constify_type(type);
92814 + return;
92815 + }
92816 +
92817 + deconstify_type(type);
92818 + TYPE_CONSTIFY_VISITED(type) = 1;
92819 +}
92820 +
92821 +static unsigned int check_local_variables(void)
92822 +{
92823 + unsigned int ret = 0;
92824 + tree var;
92825 +
92826 +#if BUILDING_GCC_VERSION == 4005
92827 + tree vars;
92828 +#else
92829 + unsigned int i;
92830 +#endif
92831 +
92832 +#if BUILDING_GCC_VERSION == 4005
92833 + for (vars = cfun->local_decls; vars; vars = TREE_CHAIN(vars)) {
92834 + var = TREE_VALUE(vars);
92835 +#else
92836 + FOR_EACH_LOCAL_DECL(cfun, i, var) {
92837 +#endif
92838 + tree type = TREE_TYPE(var);
92839 +
92840 + gcc_assert(DECL_P(var));
92841 + if (is_global_var(var))
92842 + continue;
92843 +
92844 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE)
92845 + continue;
92846 +
92847 + if (!TYPE_READONLY(type) || !C_TYPE_FIELDS_READONLY(type))
92848 + continue;
92849 +
92850 + if (!TYPE_CONSTIFY_VISITED(type))
92851 + continue;
92852 +
92853 + error_at(DECL_SOURCE_LOCATION(var), "constified variable %qE cannot be local", var);
92854 + ret = 1;
92855 + }
92856 + return ret;
92857 +}
92858 +
92859 +static struct gimple_opt_pass pass_local_variable = {
92860 + {
92861 + .type = GIMPLE_PASS,
92862 + .name = "check_local_variables",
92863 +#if BUILDING_GCC_VERSION >= 4008
92864 + .optinfo_flags = OPTGROUP_NONE,
92865 +#endif
92866 + .gate = NULL,
92867 + .execute = check_local_variables,
92868 + .sub = NULL,
92869 + .next = NULL,
92870 + .static_pass_number = 0,
92871 + .tv_id = TV_NONE,
92872 + .properties_required = 0,
92873 + .properties_provided = 0,
92874 + .properties_destroyed = 0,
92875 + .todo_flags_start = 0,
92876 + .todo_flags_finish = 0
92877 + }
92878 +};
92879 +
92880 +static struct {
92881 + const char *name;
92882 + const char *asm_op;
92883 +} sections[] = {
92884 + {".init.rodata", "\t.section\t.init.rodata,\"a\""},
92885 + {".ref.rodata", "\t.section\t.ref.rodata,\"a\""},
92886 + {".devinit.rodata", "\t.section\t.devinit.rodata,\"a\""},
92887 + {".devexit.rodata", "\t.section\t.devexit.rodata,\"a\""},
92888 + {".cpuinit.rodata", "\t.section\t.cpuinit.rodata,\"a\""},
92889 + {".cpuexit.rodata", "\t.section\t.cpuexit.rodata,\"a\""},
92890 + {".meminit.rodata", "\t.section\t.meminit.rodata,\"a\""},
92891 + {".memexit.rodata", "\t.section\t.memexit.rodata,\"a\""},
92892 + {".data..read_only", "\t.section\t.data..read_only,\"a\""},
92893 +};
92894 +
92895 +static unsigned int (*old_section_type_flags)(tree decl, const char *name, int reloc);
92896 +
92897 +static unsigned int constify_section_type_flags(tree decl, const char *name, int reloc)
92898 +{
92899 + size_t i;
92900 +
92901 + for (i = 0; i < ARRAY_SIZE(sections); i++)
92902 + if (!strcmp(sections[i].name, name))
92903 + return 0;
92904 + return old_section_type_flags(decl, name, reloc);
92905 +}
92906 +
92907 +static void constify_start_unit(void *gcc_data, void *user_data)
92908 +{
92909 +// size_t i;
92910 +
92911 +// for (i = 0; i < ARRAY_SIZE(sections); i++)
92912 +// sections[i].section = get_unnamed_section(0, output_section_asm_op, sections[i].asm_op);
92913 +// sections[i].section = get_section(sections[i].name, 0, NULL);
92914 +
92915 + old_section_type_flags = targetm.section_type_flags;
92916 + targetm.section_type_flags = constify_section_type_flags;
92917 +}
92918 +
92919 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
92920 +{
92921 + const char * const plugin_name = plugin_info->base_name;
92922 + const int argc = plugin_info->argc;
92923 + const struct plugin_argument * const argv = plugin_info->argv;
92924 + int i;
92925 + bool constify = true;
92926 +
92927 + struct register_pass_info local_variable_pass_info = {
92928 + .pass = &pass_local_variable.pass,
92929 + .reference_pass_name = "ssa",
92930 + .ref_pass_instance_number = 1,
92931 + .pos_op = PASS_POS_INSERT_BEFORE
92932 + };
92933 +
92934 + if (!plugin_default_version_check(version, &gcc_version)) {
92935 + error(G_("incompatible gcc/plugin versions"));
92936 + return 1;
92937 + }
92938 +
92939 + for (i = 0; i < argc; ++i) {
92940 + if (!(strcmp(argv[i].key, "no-constify"))) {
92941 + constify = false;
92942 + continue;
92943 + }
92944 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
92945 + }
92946 +
92947 + register_callback(plugin_name, PLUGIN_INFO, NULL, &const_plugin_info);
92948 + if (constify) {
92949 + register_callback(plugin_name, PLUGIN_FINISH_TYPE, finish_type, NULL);
92950 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &local_variable_pass_info);
92951 + register_callback(plugin_name, PLUGIN_START_UNIT, constify_start_unit, NULL);
92952 + }
92953 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
92954 +
92955 + return 0;
92956 +}
92957 diff --git a/tools/gcc/generate_size_overflow_hash.sh b/tools/gcc/generate_size_overflow_hash.sh
92958 new file mode 100644
92959 index 0000000..e518932
92960 --- /dev/null
92961 +++ b/tools/gcc/generate_size_overflow_hash.sh
92962 @@ -0,0 +1,94 @@
92963 +#!/bin/bash
92964 +
92965 +# This script generates the hash table (size_overflow_hash.h) for the size_overflow gcc plugin (size_overflow_plugin.c).
92966 +
92967 +header1="size_overflow_hash.h"
92968 +database="size_overflow_hash.data"
92969 +n=65536
92970 +
92971 +usage() {
92972 +cat <<EOF
92973 +usage: $0 options
92974 +OPTIONS:
92975 + -h|--help help
92976 + -o header file
92977 + -d database file
92978 + -n hash array size
92979 +EOF
92980 + return 0
92981 +}
92982 +
92983 +while true
92984 +do
92985 + case "$1" in
92986 + -h|--help) usage && exit 0;;
92987 + -n) n=$2; shift 2;;
92988 + -o) header1="$2"; shift 2;;
92989 + -d) database="$2"; shift 2;;
92990 + --) shift 1; break ;;
92991 + *) break ;;
92992 + esac
92993 +done
92994 +
92995 +create_defines() {
92996 + for i in `seq 0 31`
92997 + do
92998 + echo -e "#define PARAM"$i" (1U << "$i")" >> "$header1"
92999 + done
93000 + echo >> "$header1"
93001 +}
93002 +
93003 +create_structs() {
93004 + rm -f "$header1"
93005 +
93006 + create_defines
93007 +
93008 + cat "$database" | while read data
93009 + do
93010 + data_array=($data)
93011 + struct_hash_name="${data_array[0]}"
93012 + funcn="${data_array[1]}"
93013 + params="${data_array[2]}"
93014 + next="${data_array[4]}"
93015 +
93016 + echo "const struct size_overflow_hash $struct_hash_name = {" >> "$header1"
93017 +
93018 + echo -e "\t.next\t= $next,\n\t.name\t= \"$funcn\"," >> "$header1"
93019 + echo -en "\t.param\t= " >> "$header1"
93020 + line=
93021 + for param_num in ${params//-/ };
93022 + do
93023 + line="${line}PARAM"$param_num"|"
93024 + done
93025 +
93026 + echo -e "${line%?},\n};\n" >> "$header1"
93027 + done
93028 +}
93029 +
93030 +create_headers() {
93031 + echo "const struct size_overflow_hash * const size_overflow_hash[$n] = {" >> "$header1"
93032 +}
93033 +
93034 +create_array_elements() {
93035 + index=0
93036 + grep -v "nohasharray" $database | sort -n -k 4 | while read data
93037 + do
93038 + data_array=($data)
93039 + i="${data_array[3]}"
93040 + hash="${data_array[0]}"
93041 + while [[ $index -lt $i ]]
93042 + do
93043 + echo -e "\t["$index"]\t= NULL," >> "$header1"
93044 + index=$(($index + 1))
93045 + done
93046 + index=$(($index + 1))
93047 + echo -e "\t["$i"]\t= &"$hash"," >> "$header1"
93048 + done
93049 + echo '};' >> $header1
93050 +}
93051 +
93052 +create_structs
93053 +create_headers
93054 +create_array_elements
93055 +
93056 +exit 0
93057 diff --git a/tools/gcc/kallocstat_plugin.c b/tools/gcc/kallocstat_plugin.c
93058 new file mode 100644
93059 index 0000000..568b360
93060 --- /dev/null
93061 +++ b/tools/gcc/kallocstat_plugin.c
93062 @@ -0,0 +1,170 @@
93063 +/*
93064 + * Copyright 2011-2013 by the PaX Team <pageexec@freemail.hu>
93065 + * Licensed under the GPL v2
93066 + *
93067 + * Note: the choice of the license means that the compilation process is
93068 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
93069 + * but for the kernel it doesn't matter since it doesn't link against
93070 + * any of the gcc libraries
93071 + *
93072 + * gcc plugin to find the distribution of k*alloc sizes
93073 + *
93074 + * TODO:
93075 + *
93076 + * BUGS:
93077 + * - none known
93078 + */
93079 +#include "gcc-plugin.h"
93080 +#include "config.h"
93081 +#include "system.h"
93082 +#include "coretypes.h"
93083 +#include "tree.h"
93084 +#include "tree-pass.h"
93085 +#include "flags.h"
93086 +#include "intl.h"
93087 +#include "toplev.h"
93088 +#include "plugin.h"
93089 +//#include "expr.h" where are you...
93090 +#include "diagnostic.h"
93091 +#include "plugin-version.h"
93092 +#include "tm.h"
93093 +#include "function.h"
93094 +#include "basic-block.h"
93095 +#include "gimple.h"
93096 +#include "rtl.h"
93097 +#include "emit-rtl.h"
93098 +
93099 +extern void print_gimple_stmt(FILE *, gimple, int, int);
93100 +
93101 +int plugin_is_GPL_compatible;
93102 +
93103 +static const char * const kalloc_functions[] = {
93104 + "__kmalloc",
93105 + "kmalloc",
93106 + "kmalloc_large",
93107 + "kmalloc_node",
93108 + "kmalloc_order",
93109 + "kmalloc_order_trace",
93110 + "kmalloc_slab",
93111 + "kzalloc",
93112 + "kzalloc_node",
93113 +};
93114 +
93115 +static struct plugin_info kallocstat_plugin_info = {
93116 + .version = "201302112000",
93117 +};
93118 +
93119 +static unsigned int execute_kallocstat(void);
93120 +
93121 +static struct gimple_opt_pass kallocstat_pass = {
93122 + .pass = {
93123 + .type = GIMPLE_PASS,
93124 + .name = "kallocstat",
93125 +#if BUILDING_GCC_VERSION >= 4008
93126 + .optinfo_flags = OPTGROUP_NONE,
93127 +#endif
93128 + .gate = NULL,
93129 + .execute = execute_kallocstat,
93130 + .sub = NULL,
93131 + .next = NULL,
93132 + .static_pass_number = 0,
93133 + .tv_id = TV_NONE,
93134 + .properties_required = 0,
93135 + .properties_provided = 0,
93136 + .properties_destroyed = 0,
93137 + .todo_flags_start = 0,
93138 + .todo_flags_finish = 0
93139 + }
93140 +};
93141 +
93142 +static bool is_kalloc(const char *fnname)
93143 +{
93144 + size_t i;
93145 +
93146 + for (i = 0; i < ARRAY_SIZE(kalloc_functions); i++)
93147 + if (!strcmp(fnname, kalloc_functions[i]))
93148 + return true;
93149 + return false;
93150 +}
93151 +
93152 +static unsigned int execute_kallocstat(void)
93153 +{
93154 + basic_block bb;
93155 +
93156 + // 1. loop through BBs and GIMPLE statements
93157 + FOR_EACH_BB(bb) {
93158 + gimple_stmt_iterator gsi;
93159 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
93160 + // gimple match:
93161 + tree fndecl, size;
93162 + gimple call_stmt;
93163 + const char *fnname;
93164 +
93165 + // is it a call
93166 + call_stmt = gsi_stmt(gsi);
93167 + if (!is_gimple_call(call_stmt))
93168 + continue;
93169 + fndecl = gimple_call_fndecl(call_stmt);
93170 + if (fndecl == NULL_TREE)
93171 + continue;
93172 + if (TREE_CODE(fndecl) != FUNCTION_DECL)
93173 + continue;
93174 +
93175 + // is it a call to k*alloc
93176 + fnname = IDENTIFIER_POINTER(DECL_NAME(fndecl));
93177 + if (!is_kalloc(fnname))
93178 + continue;
93179 +
93180 + // is the size arg the result of a simple const assignment
93181 + size = gimple_call_arg(call_stmt, 0);
93182 + while (true) {
93183 + gimple def_stmt;
93184 + expanded_location xloc;
93185 + size_t size_val;
93186 +
93187 + if (TREE_CODE(size) != SSA_NAME)
93188 + break;
93189 + def_stmt = SSA_NAME_DEF_STMT(size);
93190 + if (!def_stmt || !is_gimple_assign(def_stmt))
93191 + break;
93192 + if (gimple_num_ops(def_stmt) != 2)
93193 + break;
93194 + size = gimple_assign_rhs1(def_stmt);
93195 + if (!TREE_CONSTANT(size))
93196 + continue;
93197 + xloc = expand_location(gimple_location(def_stmt));
93198 + if (!xloc.file)
93199 + xloc = expand_location(DECL_SOURCE_LOCATION(current_function_decl));
93200 + size_val = TREE_INT_CST_LOW(size);
93201 + fprintf(stderr, "kallocsize: %8zu %8zx %s %s:%u\n", size_val, size_val, fnname, xloc.file, xloc.line);
93202 + break;
93203 + }
93204 +//print_gimple_stmt(stderr, call_stmt, 0, TDF_LINENO);
93205 +//debug_tree(gimple_call_fn(call_stmt));
93206 +//print_node(stderr, "pax", fndecl, 4);
93207 + }
93208 + }
93209 +
93210 + return 0;
93211 +}
93212 +
93213 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
93214 +{
93215 + const char * const plugin_name = plugin_info->base_name;
93216 + struct register_pass_info kallocstat_pass_info = {
93217 + .pass = &kallocstat_pass.pass,
93218 + .reference_pass_name = "ssa",
93219 + .ref_pass_instance_number = 1,
93220 + .pos_op = PASS_POS_INSERT_AFTER
93221 + };
93222 +
93223 + if (!plugin_default_version_check(version, &gcc_version)) {
93224 + error(G_("incompatible gcc/plugin versions"));
93225 + return 1;
93226 + }
93227 +
93228 + register_callback(plugin_name, PLUGIN_INFO, NULL, &kallocstat_plugin_info);
93229 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kallocstat_pass_info);
93230 +
93231 + return 0;
93232 +}
93233 diff --git a/tools/gcc/kernexec_plugin.c b/tools/gcc/kernexec_plugin.c
93234 new file mode 100644
93235 index 0000000..0408e06
93236 --- /dev/null
93237 +++ b/tools/gcc/kernexec_plugin.c
93238 @@ -0,0 +1,465 @@
93239 +/*
93240 + * Copyright 2011-2013 by the PaX Team <pageexec@freemail.hu>
93241 + * Licensed under the GPL v2
93242 + *
93243 + * Note: the choice of the license means that the compilation process is
93244 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
93245 + * but for the kernel it doesn't matter since it doesn't link against
93246 + * any of the gcc libraries
93247 + *
93248 + * gcc plugin to make KERNEXEC/amd64 almost as good as it is on i386
93249 + *
93250 + * TODO:
93251 + *
93252 + * BUGS:
93253 + * - none known
93254 + */
93255 +#include "gcc-plugin.h"
93256 +#include "config.h"
93257 +#include "system.h"
93258 +#include "coretypes.h"
93259 +#include "tree.h"
93260 +#include "tree-pass.h"
93261 +#include "flags.h"
93262 +#include "intl.h"
93263 +#include "toplev.h"
93264 +#include "plugin.h"
93265 +//#include "expr.h" where are you...
93266 +#include "diagnostic.h"
93267 +#include "plugin-version.h"
93268 +#include "tm.h"
93269 +#include "function.h"
93270 +#include "basic-block.h"
93271 +#include "gimple.h"
93272 +#include "rtl.h"
93273 +#include "emit-rtl.h"
93274 +#include "tree-flow.h"
93275 +
93276 +extern void print_gimple_stmt(FILE *, gimple, int, int);
93277 +extern rtx emit_move_insn(rtx x, rtx y);
93278 +
93279 +#if BUILDING_GCC_VERSION <= 4006
93280 +#define ANY_RETURN_P(rtx) (GET_CODE(rtx) == RETURN)
93281 +#endif
93282 +
93283 +#if BUILDING_GCC_VERSION >= 4008
93284 +#define TODO_dump_func 0
93285 +#endif
93286 +
93287 +int plugin_is_GPL_compatible;
93288 +
93289 +static struct plugin_info kernexec_plugin_info = {
93290 + .version = "201302112000",
93291 + .help = "method=[bts|or]\tinstrumentation method\n"
93292 +};
93293 +
93294 +static unsigned int execute_kernexec_reload(void);
93295 +static unsigned int execute_kernexec_fptr(void);
93296 +static unsigned int execute_kernexec_retaddr(void);
93297 +static bool kernexec_cmodel_check(void);
93298 +
93299 +static void (*kernexec_instrument_fptr)(gimple_stmt_iterator *);
93300 +static void (*kernexec_instrument_retaddr)(rtx);
93301 +
93302 +static struct gimple_opt_pass kernexec_reload_pass = {
93303 + .pass = {
93304 + .type = GIMPLE_PASS,
93305 + .name = "kernexec_reload",
93306 +#if BUILDING_GCC_VERSION >= 4008
93307 + .optinfo_flags = OPTGROUP_NONE,
93308 +#endif
93309 + .gate = kernexec_cmodel_check,
93310 + .execute = execute_kernexec_reload,
93311 + .sub = NULL,
93312 + .next = NULL,
93313 + .static_pass_number = 0,
93314 + .tv_id = TV_NONE,
93315 + .properties_required = 0,
93316 + .properties_provided = 0,
93317 + .properties_destroyed = 0,
93318 + .todo_flags_start = 0,
93319 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_remove_unused_locals | TODO_update_ssa_no_phi
93320 + }
93321 +};
93322 +
93323 +static struct gimple_opt_pass kernexec_fptr_pass = {
93324 + .pass = {
93325 + .type = GIMPLE_PASS,
93326 + .name = "kernexec_fptr",
93327 +#if BUILDING_GCC_VERSION >= 4008
93328 + .optinfo_flags = OPTGROUP_NONE,
93329 +#endif
93330 + .gate = kernexec_cmodel_check,
93331 + .execute = execute_kernexec_fptr,
93332 + .sub = NULL,
93333 + .next = NULL,
93334 + .static_pass_number = 0,
93335 + .tv_id = TV_NONE,
93336 + .properties_required = 0,
93337 + .properties_provided = 0,
93338 + .properties_destroyed = 0,
93339 + .todo_flags_start = 0,
93340 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_remove_unused_locals | TODO_update_ssa_no_phi
93341 + }
93342 +};
93343 +
93344 +static struct rtl_opt_pass kernexec_retaddr_pass = {
93345 + .pass = {
93346 + .type = RTL_PASS,
93347 + .name = "kernexec_retaddr",
93348 +#if BUILDING_GCC_VERSION >= 4008
93349 + .optinfo_flags = OPTGROUP_NONE,
93350 +#endif
93351 + .gate = kernexec_cmodel_check,
93352 + .execute = execute_kernexec_retaddr,
93353 + .sub = NULL,
93354 + .next = NULL,
93355 + .static_pass_number = 0,
93356 + .tv_id = TV_NONE,
93357 + .properties_required = 0,
93358 + .properties_provided = 0,
93359 + .properties_destroyed = 0,
93360 + .todo_flags_start = 0,
93361 + .todo_flags_finish = TODO_dump_func | TODO_ggc_collect
93362 + }
93363 +};
93364 +
93365 +static bool kernexec_cmodel_check(void)
93366 +{
93367 + tree section;
93368 +
93369 + if (ix86_cmodel != CM_KERNEL)
93370 + return false;
93371 +
93372 + section = lookup_attribute("section", DECL_ATTRIBUTES(current_function_decl));
93373 + if (!section || !TREE_VALUE(section))
93374 + return true;
93375 +
93376 + section = TREE_VALUE(TREE_VALUE(section));
93377 + if (strncmp(TREE_STRING_POINTER(section), ".vsyscall_", 10))
93378 + return true;
93379 +
93380 + return false;
93381 +}
93382 +
93383 +/*
93384 + * add special KERNEXEC instrumentation: reload %r10 after it has been clobbered
93385 + */
93386 +static void kernexec_reload_fptr_mask(gimple_stmt_iterator *gsi)
93387 +{
93388 + gimple asm_movabs_stmt;
93389 +
93390 + // build asm volatile("movabs $0x8000000000000000, %%r10\n\t" : : : );
93391 + asm_movabs_stmt = gimple_build_asm_vec("movabs $0x8000000000000000, %%r10\n\t", NULL, NULL, NULL, NULL);
93392 + gimple_asm_set_volatile(asm_movabs_stmt, true);
93393 + gsi_insert_after(gsi, asm_movabs_stmt, GSI_CONTINUE_LINKING);
93394 + update_stmt(asm_movabs_stmt);
93395 +}
93396 +
93397 +/*
93398 + * find all asm() stmts that clobber r10 and add a reload of r10
93399 + */
93400 +static unsigned int execute_kernexec_reload(void)
93401 +{
93402 + basic_block bb;
93403 +
93404 + // 1. loop through BBs and GIMPLE statements
93405 + FOR_EACH_BB(bb) {
93406 + gimple_stmt_iterator gsi;
93407 +
93408 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
93409 + // gimple match: __asm__ ("" : : : "r10");
93410 + gimple asm_stmt;
93411 + size_t nclobbers;
93412 +
93413 + // is it an asm ...
93414 + asm_stmt = gsi_stmt(gsi);
93415 + if (gimple_code(asm_stmt) != GIMPLE_ASM)
93416 + continue;
93417 +
93418 + // ... clobbering r10
93419 + nclobbers = gimple_asm_nclobbers(asm_stmt);
93420 + while (nclobbers--) {
93421 + tree op = gimple_asm_clobber_op(asm_stmt, nclobbers);
93422 + if (strcmp(TREE_STRING_POINTER(TREE_VALUE(op)), "r10"))
93423 + continue;
93424 + kernexec_reload_fptr_mask(&gsi);
93425 +//print_gimple_stmt(stderr, asm_stmt, 0, TDF_LINENO);
93426 + break;
93427 + }
93428 + }
93429 + }
93430 +
93431 + return 0;
93432 +}
93433 +
93434 +/*
93435 + * add special KERNEXEC instrumentation: force MSB of fptr to 1, which will produce
93436 + * a non-canonical address from a userland ptr and will just trigger a GPF on dereference
93437 + */
93438 +static void kernexec_instrument_fptr_bts(gimple_stmt_iterator *gsi)
93439 +{
93440 + gimple assign_intptr, assign_new_fptr, call_stmt;
93441 + tree intptr, old_fptr, new_fptr, kernexec_mask;
93442 +
93443 + call_stmt = gsi_stmt(*gsi);
93444 + old_fptr = gimple_call_fn(call_stmt);
93445 +
93446 + // create temporary unsigned long variable used for bitops and cast fptr to it
93447 + intptr = create_tmp_var(long_unsigned_type_node, "kernexec_bts");
93448 +#if BUILDING_GCC_VERSION <= 4007
93449 + add_referenced_var(intptr);
93450 + mark_sym_for_renaming(intptr);
93451 +#endif
93452 + assign_intptr = gimple_build_assign(intptr, fold_convert(long_unsigned_type_node, old_fptr));
93453 + gsi_insert_before(gsi, assign_intptr, GSI_SAME_STMT);
93454 + update_stmt(assign_intptr);
93455 +
93456 + // apply logical or to temporary unsigned long and bitmask
93457 + kernexec_mask = build_int_cstu(long_long_unsigned_type_node, 0x8000000000000000LL);
93458 +// kernexec_mask = build_int_cstu(long_long_unsigned_type_node, 0xffffffff80000000LL);
93459 + assign_intptr = gimple_build_assign(intptr, fold_build2(BIT_IOR_EXPR, long_long_unsigned_type_node, intptr, kernexec_mask));
93460 + gsi_insert_before(gsi, assign_intptr, GSI_SAME_STMT);
93461 + update_stmt(assign_intptr);
93462 +
93463 + // cast temporary unsigned long back to a temporary fptr variable
93464 + new_fptr = create_tmp_var(TREE_TYPE(old_fptr), "kernexec_fptr");
93465 +#if BUILDING_GCC_VERSION <= 4007
93466 + add_referenced_var(new_fptr);
93467 + mark_sym_for_renaming(new_fptr);
93468 +#endif
93469 + assign_new_fptr = gimple_build_assign(new_fptr, fold_convert(TREE_TYPE(old_fptr), intptr));
93470 + gsi_insert_before(gsi, assign_new_fptr, GSI_SAME_STMT);
93471 + update_stmt(assign_new_fptr);
93472 +
93473 + // replace call stmt fn with the new fptr
93474 + gimple_call_set_fn(call_stmt, new_fptr);
93475 + update_stmt(call_stmt);
93476 +}
93477 +
93478 +static void kernexec_instrument_fptr_or(gimple_stmt_iterator *gsi)
93479 +{
93480 + gimple asm_or_stmt, call_stmt;
93481 + tree old_fptr, new_fptr, input, output;
93482 +#if BUILDING_GCC_VERSION <= 4007
93483 + VEC(tree, gc) *inputs = NULL;
93484 + VEC(tree, gc) *outputs = NULL;
93485 +#else
93486 + vec<tree, va_gc> *inputs = NULL;
93487 + vec<tree, va_gc> *outputs = NULL;
93488 +#endif
93489 +
93490 + call_stmt = gsi_stmt(*gsi);
93491 + old_fptr = gimple_call_fn(call_stmt);
93492 +
93493 + // create temporary fptr variable
93494 + new_fptr = create_tmp_var(TREE_TYPE(old_fptr), "kernexec_or");
93495 +#if BUILDING_GCC_VERSION <= 4007
93496 + add_referenced_var(new_fptr);
93497 + mark_sym_for_renaming(new_fptr);
93498 +#endif
93499 +
93500 + // build asm volatile("orq %%r10, %0\n\t" : "=r"(new_fptr) : "0"(old_fptr));
93501 + input = build_tree_list(NULL_TREE, build_string(2, "0"));
93502 + input = chainon(NULL_TREE, build_tree_list(input, old_fptr));
93503 + output = build_tree_list(NULL_TREE, build_string(3, "=r"));
93504 + output = chainon(NULL_TREE, build_tree_list(output, new_fptr));
93505 +#if BUILDING_GCC_VERSION <= 4007
93506 + VEC_safe_push(tree, gc, inputs, input);
93507 + VEC_safe_push(tree, gc, outputs, output);
93508 +#else
93509 + vec_safe_push(inputs, input);
93510 + vec_safe_push(outputs, output);
93511 +#endif
93512 + asm_or_stmt = gimple_build_asm_vec("orq %%r10, %0\n\t", inputs, outputs, NULL, NULL);
93513 + gimple_asm_set_volatile(asm_or_stmt, true);
93514 + gsi_insert_before(gsi, asm_or_stmt, GSI_SAME_STMT);
93515 + update_stmt(asm_or_stmt);
93516 +
93517 + // replace call stmt fn with the new fptr
93518 + gimple_call_set_fn(call_stmt, new_fptr);
93519 + update_stmt(call_stmt);
93520 +}
93521 +
93522 +/*
93523 + * find all C level function pointer dereferences and forcibly set the highest bit of the pointer
93524 + */
93525 +static unsigned int execute_kernexec_fptr(void)
93526 +{
93527 + basic_block bb;
93528 +
93529 + // 1. loop through BBs and GIMPLE statements
93530 + FOR_EACH_BB(bb) {
93531 + gimple_stmt_iterator gsi;
93532 +
93533 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
93534 + // gimple match: h_1 = get_fptr (); D.2709_3 = h_1 (x_2(D));
93535 + tree fn;
93536 + gimple call_stmt;
93537 +
93538 + // is it a call ...
93539 + call_stmt = gsi_stmt(gsi);
93540 + if (!is_gimple_call(call_stmt))
93541 + continue;
93542 + fn = gimple_call_fn(call_stmt);
93543 + if (TREE_CODE(fn) == ADDR_EXPR)
93544 + continue;
93545 + if (TREE_CODE(fn) != SSA_NAME)
93546 + gcc_unreachable();
93547 +
93548 + // ... through a function pointer
93549 + if (SSA_NAME_VAR(fn) != NULL_TREE) {
93550 + fn = SSA_NAME_VAR(fn);
93551 + if (TREE_CODE(fn) != VAR_DECL && TREE_CODE(fn) != PARM_DECL) {
93552 + debug_tree(fn);
93553 + gcc_unreachable();
93554 + }
93555 + }
93556 + fn = TREE_TYPE(fn);
93557 + if (TREE_CODE(fn) != POINTER_TYPE)
93558 + continue;
93559 + fn = TREE_TYPE(fn);
93560 + if (TREE_CODE(fn) != FUNCTION_TYPE)
93561 + continue;
93562 +
93563 + kernexec_instrument_fptr(&gsi);
93564 +
93565 +//debug_tree(gimple_call_fn(call_stmt));
93566 +//print_gimple_stmt(stderr, call_stmt, 0, TDF_LINENO);
93567 + }
93568 + }
93569 +
93570 + return 0;
93571 +}
93572 +
93573 +// add special KERNEXEC instrumentation: btsq $63,(%rsp) just before retn
93574 +static void kernexec_instrument_retaddr_bts(rtx insn)
93575 +{
93576 + rtx btsq;
93577 + rtvec argvec, constraintvec, labelvec;
93578 + int line;
93579 +
93580 + // create asm volatile("btsq $63,(%%rsp)":::)
93581 + argvec = rtvec_alloc(0);
93582 + constraintvec = rtvec_alloc(0);
93583 + labelvec = rtvec_alloc(0);
93584 + line = expand_location(RTL_LOCATION(insn)).line;
93585 + btsq = gen_rtx_ASM_OPERANDS(VOIDmode, "btsq $63,(%%rsp)", empty_string, 0, argvec, constraintvec, labelvec, line);
93586 + MEM_VOLATILE_P(btsq) = 1;
93587 +// RTX_FRAME_RELATED_P(btsq) = 1; // not for ASM_OPERANDS
93588 + emit_insn_before(btsq, insn);
93589 +}
93590 +
93591 +// add special KERNEXEC instrumentation: orq %r10,(%rsp) just before retn
93592 +static void kernexec_instrument_retaddr_or(rtx insn)
93593 +{
93594 + rtx orq;
93595 + rtvec argvec, constraintvec, labelvec;
93596 + int line;
93597 +
93598 + // create asm volatile("orq %%r10,(%%rsp)":::)
93599 + argvec = rtvec_alloc(0);
93600 + constraintvec = rtvec_alloc(0);
93601 + labelvec = rtvec_alloc(0);
93602 + line = expand_location(RTL_LOCATION(insn)).line;
93603 + orq = gen_rtx_ASM_OPERANDS(VOIDmode, "orq %%r10,(%%rsp)", empty_string, 0, argvec, constraintvec, labelvec, line);
93604 + MEM_VOLATILE_P(orq) = 1;
93605 +// RTX_FRAME_RELATED_P(orq) = 1; // not for ASM_OPERANDS
93606 + emit_insn_before(orq, insn);
93607 +}
93608 +
93609 +/*
93610 + * find all asm level function returns and forcibly set the highest bit of the return address
93611 + */
93612 +static unsigned int execute_kernexec_retaddr(void)
93613 +{
93614 + rtx insn;
93615 +
93616 + // 1. find function returns
93617 + for (insn = get_insns(); insn; insn = NEXT_INSN(insn)) {
93618 + // rtl match: (jump_insn 41 40 42 2 (return) fptr.c:42 634 {return_internal} (nil))
93619 + // (jump_insn 12 9 11 2 (parallel [ (return) (unspec [ (0) ] UNSPEC_REP) ]) fptr.c:46 635 {return_internal_long} (nil))
93620 + // (jump_insn 97 96 98 6 (simple_return) fptr.c:50 -1 (nil) -> simple_return)
93621 + rtx body;
93622 +
93623 + // is it a retn
93624 + if (!JUMP_P(insn))
93625 + continue;
93626 + body = PATTERN(insn);
93627 + if (GET_CODE(body) == PARALLEL)
93628 + body = XVECEXP(body, 0, 0);
93629 + if (!ANY_RETURN_P(body))
93630 + continue;
93631 + kernexec_instrument_retaddr(insn);
93632 + }
93633 +
93634 +// print_simple_rtl(stderr, get_insns());
93635 +// print_rtl(stderr, get_insns());
93636 +
93637 + return 0;
93638 +}
93639 +
93640 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
93641 +{
93642 + const char * const plugin_name = plugin_info->base_name;
93643 + const int argc = plugin_info->argc;
93644 + const struct plugin_argument * const argv = plugin_info->argv;
93645 + int i;
93646 + struct register_pass_info kernexec_reload_pass_info = {
93647 + .pass = &kernexec_reload_pass.pass,
93648 + .reference_pass_name = "ssa",
93649 + .ref_pass_instance_number = 1,
93650 + .pos_op = PASS_POS_INSERT_AFTER
93651 + };
93652 + struct register_pass_info kernexec_fptr_pass_info = {
93653 + .pass = &kernexec_fptr_pass.pass,
93654 + .reference_pass_name = "ssa",
93655 + .ref_pass_instance_number = 1,
93656 + .pos_op = PASS_POS_INSERT_AFTER
93657 + };
93658 + struct register_pass_info kernexec_retaddr_pass_info = {
93659 + .pass = &kernexec_retaddr_pass.pass,
93660 + .reference_pass_name = "pro_and_epilogue",
93661 + .ref_pass_instance_number = 1,
93662 + .pos_op = PASS_POS_INSERT_AFTER
93663 + };
93664 +
93665 + if (!plugin_default_version_check(version, &gcc_version)) {
93666 + error(G_("incompatible gcc/plugin versions"));
93667 + return 1;
93668 + }
93669 +
93670 + register_callback(plugin_name, PLUGIN_INFO, NULL, &kernexec_plugin_info);
93671 +
93672 + if (TARGET_64BIT == 0)
93673 + return 0;
93674 +
93675 + for (i = 0; i < argc; ++i) {
93676 + if (!strcmp(argv[i].key, "method")) {
93677 + if (!argv[i].value) {
93678 + error(G_("no value supplied for option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
93679 + continue;
93680 + }
93681 + if (!strcmp(argv[i].value, "bts")) {
93682 + kernexec_instrument_fptr = kernexec_instrument_fptr_bts;
93683 + kernexec_instrument_retaddr = kernexec_instrument_retaddr_bts;
93684 + } else if (!strcmp(argv[i].value, "or")) {
93685 + kernexec_instrument_fptr = kernexec_instrument_fptr_or;
93686 + kernexec_instrument_retaddr = kernexec_instrument_retaddr_or;
93687 + fix_register("r10", 1, 1);
93688 + } else
93689 + error(G_("invalid option argument '-fplugin-arg-%s-%s=%s'"), plugin_name, argv[i].key, argv[i].value);
93690 + continue;
93691 + }
93692 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
93693 + }
93694 + if (!kernexec_instrument_fptr || !kernexec_instrument_retaddr)
93695 + error(G_("no instrumentation method was selected via '-fplugin-arg-%s-method'"), plugin_name);
93696 +
93697 + if (kernexec_instrument_fptr == kernexec_instrument_fptr_or)
93698 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kernexec_reload_pass_info);
93699 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kernexec_fptr_pass_info);
93700 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kernexec_retaddr_pass_info);
93701 +
93702 + return 0;
93703 +}
93704 diff --git a/tools/gcc/latent_entropy_plugin.c b/tools/gcc/latent_entropy_plugin.c
93705 new file mode 100644
93706 index 0000000..b5395ba
93707 --- /dev/null
93708 +++ b/tools/gcc/latent_entropy_plugin.c
93709 @@ -0,0 +1,327 @@
93710 +/*
93711 + * Copyright 2012-2013 by the PaX Team <pageexec@freemail.hu>
93712 + * Licensed under the GPL v2
93713 + *
93714 + * Note: the choice of the license means that the compilation process is
93715 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
93716 + * but for the kernel it doesn't matter since it doesn't link against
93717 + * any of the gcc libraries
93718 + *
93719 + * gcc plugin to help generate a little bit of entropy from program state,
93720 + * used during boot in the kernel
93721 + *
93722 + * TODO:
93723 + * - add ipa pass to identify not explicitly marked candidate functions
93724 + * - mix in more program state (function arguments/return values, loop variables, etc)
93725 + * - more instrumentation control via attribute parameters
93726 + *
93727 + * BUGS:
93728 + * - LTO needs -flto-partition=none for now
93729 + */
93730 +#include "gcc-plugin.h"
93731 +#include "config.h"
93732 +#include "system.h"
93733 +#include "coretypes.h"
93734 +#include "tree.h"
93735 +#include "tree-pass.h"
93736 +#include "flags.h"
93737 +#include "intl.h"
93738 +#include "toplev.h"
93739 +#include "plugin.h"
93740 +//#include "expr.h" where are you...
93741 +#include "diagnostic.h"
93742 +#include "plugin-version.h"
93743 +#include "tm.h"
93744 +#include "function.h"
93745 +#include "basic-block.h"
93746 +#include "gimple.h"
93747 +#include "rtl.h"
93748 +#include "emit-rtl.h"
93749 +#include "tree-flow.h"
93750 +#include "langhooks.h"
93751 +
93752 +#if BUILDING_GCC_VERSION >= 4008
93753 +#define TODO_dump_func 0
93754 +#endif
93755 +
93756 +int plugin_is_GPL_compatible;
93757 +
93758 +static tree latent_entropy_decl;
93759 +
93760 +static struct plugin_info latent_entropy_plugin_info = {
93761 + .version = "201303102320",
93762 + .help = NULL
93763 +};
93764 +
93765 +static unsigned int execute_latent_entropy(void);
93766 +static bool gate_latent_entropy(void);
93767 +
93768 +static struct gimple_opt_pass latent_entropy_pass = {
93769 + .pass = {
93770 + .type = GIMPLE_PASS,
93771 + .name = "latent_entropy",
93772 +#if BUILDING_GCC_VERSION >= 4008
93773 + .optinfo_flags = OPTGROUP_NONE,
93774 +#endif
93775 + .gate = gate_latent_entropy,
93776 + .execute = execute_latent_entropy,
93777 + .sub = NULL,
93778 + .next = NULL,
93779 + .static_pass_number = 0,
93780 + .tv_id = TV_NONE,
93781 + .properties_required = PROP_gimple_leh | PROP_cfg,
93782 + .properties_provided = 0,
93783 + .properties_destroyed = 0,
93784 + .todo_flags_start = 0, //TODO_verify_ssa | TODO_verify_flow | TODO_verify_stmts,
93785 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_update_ssa
93786 + }
93787 +};
93788 +
93789 +static tree handle_latent_entropy_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
93790 +{
93791 + if (TREE_CODE(*node) != FUNCTION_DECL) {
93792 + *no_add_attrs = true;
93793 + error("%qE attribute only applies to functions", name);
93794 + }
93795 + return NULL_TREE;
93796 +}
93797 +
93798 +static struct attribute_spec latent_entropy_attr = {
93799 + .name = "latent_entropy",
93800 + .min_length = 0,
93801 + .max_length = 0,
93802 + .decl_required = true,
93803 + .type_required = false,
93804 + .function_type_required = false,
93805 + .handler = handle_latent_entropy_attribute,
93806 +#if BUILDING_GCC_VERSION >= 4007
93807 + .affects_type_identity = false
93808 +#endif
93809 +};
93810 +
93811 +static void register_attributes(void *event_data, void *data)
93812 +{
93813 + register_attribute(&latent_entropy_attr);
93814 +}
93815 +
93816 +static bool gate_latent_entropy(void)
93817 +{
93818 + tree latent_entropy_attr;
93819 +
93820 + latent_entropy_attr = lookup_attribute("latent_entropy", DECL_ATTRIBUTES(current_function_decl));
93821 + return latent_entropy_attr != NULL_TREE;
93822 +}
93823 +
93824 +static unsigned HOST_WIDE_INT seed;
93825 +static unsigned HOST_WIDE_INT get_random_const(void)
93826 +{
93827 + seed = (seed >> 1U) ^ (-(seed & 1ULL) & 0xD800000000000000ULL);
93828 + return seed;
93829 +}
93830 +
93831 +static enum tree_code get_op(tree *rhs)
93832 +{
93833 + static enum tree_code op;
93834 + unsigned HOST_WIDE_INT random_const;
93835 +
93836 + random_const = get_random_const();
93837 +
93838 + switch (op) {
93839 + case BIT_XOR_EXPR:
93840 + op = PLUS_EXPR;
93841 + break;
93842 +
93843 + case PLUS_EXPR:
93844 + if (rhs) {
93845 + op = LROTATE_EXPR;
93846 + random_const &= HOST_BITS_PER_WIDE_INT - 1;
93847 + break;
93848 + }
93849 +
93850 + case LROTATE_EXPR:
93851 + default:
93852 + op = BIT_XOR_EXPR;
93853 + break;
93854 + }
93855 + if (rhs)
93856 + *rhs = build_int_cstu(unsigned_intDI_type_node, random_const);
93857 + return op;
93858 +}
93859 +
93860 +static void perturb_local_entropy(basic_block bb, tree local_entropy)
93861 +{
93862 + gimple_stmt_iterator gsi;
93863 + gimple assign;
93864 + tree addxorrol, rhs;
93865 + enum tree_code op;
93866 +
93867 + op = get_op(&rhs);
93868 + addxorrol = fold_build2_loc(UNKNOWN_LOCATION, op, unsigned_intDI_type_node, local_entropy, rhs);
93869 + assign = gimple_build_assign(local_entropy, addxorrol);
93870 +#if BUILDING_GCC_VERSION <= 4007
93871 + find_referenced_vars_in(assign);
93872 +#endif
93873 +//debug_bb(bb);
93874 + gsi = gsi_after_labels(bb);
93875 + gsi_insert_before(&gsi, assign, GSI_NEW_STMT);
93876 + update_stmt(assign);
93877 +}
93878 +
93879 +static void perturb_latent_entropy(basic_block bb, tree rhs)
93880 +{
93881 + gimple_stmt_iterator gsi;
93882 + gimple assign;
93883 + tree addxorrol, temp;
93884 +
93885 + // 1. create temporary copy of latent_entropy
93886 + temp = create_tmp_var(unsigned_intDI_type_node, "temp_latent_entropy");
93887 +#if BUILDING_GCC_VERSION <= 4007
93888 + add_referenced_var(temp);
93889 + mark_sym_for_renaming(temp);
93890 +#endif
93891 +
93892 + // 2. read...
93893 + assign = gimple_build_assign(temp, latent_entropy_decl);
93894 +#if BUILDING_GCC_VERSION <= 4007
93895 + find_referenced_vars_in(assign);
93896 +#endif
93897 + gsi = gsi_after_labels(bb);
93898 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
93899 + update_stmt(assign);
93900 +
93901 + // 3. ...modify...
93902 + addxorrol = fold_build2_loc(UNKNOWN_LOCATION, get_op(NULL), unsigned_intDI_type_node, temp, rhs);
93903 + assign = gimple_build_assign(temp, addxorrol);
93904 +#if BUILDING_GCC_VERSION <= 4007
93905 + find_referenced_vars_in(assign);
93906 +#endif
93907 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
93908 + update_stmt(assign);
93909 +
93910 + // 4. ...write latent_entropy
93911 + assign = gimple_build_assign(latent_entropy_decl, temp);
93912 +#if BUILDING_GCC_VERSION <= 4007
93913 + find_referenced_vars_in(assign);
93914 +#endif
93915 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
93916 + update_stmt(assign);
93917 +}
93918 +
93919 +static unsigned int execute_latent_entropy(void)
93920 +{
93921 + basic_block bb;
93922 + gimple assign;
93923 + gimple_stmt_iterator gsi;
93924 + tree local_entropy;
93925 +
93926 + if (!latent_entropy_decl) {
93927 + struct varpool_node *node;
93928 +
93929 +#if BUILDING_GCC_VERSION <= 4007
93930 + for (node = varpool_nodes; node; node = node->next) {
93931 + tree var = node->decl;
93932 +#else
93933 + FOR_EACH_VARIABLE(node) {
93934 + tree var = node->symbol.decl;
93935 +#endif
93936 + if (strcmp(IDENTIFIER_POINTER(DECL_NAME(var)), "latent_entropy"))
93937 + continue;
93938 + latent_entropy_decl = var;
93939 +// debug_tree(var);
93940 + break;
93941 + }
93942 + if (!latent_entropy_decl) {
93943 +// debug_tree(current_function_decl);
93944 + return 0;
93945 + }
93946 + }
93947 +
93948 +//fprintf(stderr, "latent_entropy: %s\n", IDENTIFIER_POINTER(DECL_NAME(current_function_decl)));
93949 +
93950 + // 1. create local entropy variable
93951 + local_entropy = create_tmp_var(unsigned_intDI_type_node, "local_entropy");
93952 +#if BUILDING_GCC_VERSION <= 4007
93953 + add_referenced_var(local_entropy);
93954 + mark_sym_for_renaming(local_entropy);
93955 +#endif
93956 +
93957 + // 2. initialize local entropy variable
93958 + bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
93959 + if (dom_info_available_p(CDI_DOMINATORS))
93960 + set_immediate_dominator(CDI_DOMINATORS, bb, ENTRY_BLOCK_PTR);
93961 + gsi = gsi_start_bb(bb);
93962 +
93963 + assign = gimple_build_assign(local_entropy, build_int_cstu(unsigned_intDI_type_node, get_random_const()));
93964 +// gimple_set_location(assign, loc);
93965 +#if BUILDING_GCC_VERSION <= 4007
93966 + find_referenced_vars_in(assign);
93967 +#endif
93968 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
93969 + update_stmt(assign);
93970 + bb = bb->next_bb;
93971 +
93972 + // 3. instrument each BB with an operation on the local entropy variable
93973 + while (bb != EXIT_BLOCK_PTR) {
93974 + perturb_local_entropy(bb, local_entropy);
93975 + bb = bb->next_bb;
93976 + };
93977 +
93978 + // 4. mix local entropy into the global entropy variable
93979 + perturb_latent_entropy(EXIT_BLOCK_PTR->prev_bb, local_entropy);
93980 + return 0;
93981 +}
93982 +
93983 +static void start_unit_callback(void *gcc_data, void *user_data)
93984 +{
93985 + tree latent_entropy_type;
93986 +
93987 +#if BUILDING_GCC_VERSION >= 4007
93988 + seed = get_random_seed(false);
93989 +#else
93990 + sscanf(get_random_seed(false), "%" HOST_WIDE_INT_PRINT "x", &seed);
93991 + seed *= seed;
93992 +#endif
93993 +
93994 + if (in_lto_p)
93995 + return;
93996 +
93997 + // extern volatile u64 latent_entropy
93998 + gcc_assert(TYPE_PRECISION(long_long_unsigned_type_node) == 64);
93999 + latent_entropy_type = build_qualified_type(long_long_unsigned_type_node, TYPE_QUALS(long_long_unsigned_type_node) | TYPE_QUAL_VOLATILE);
94000 + latent_entropy_decl = build_decl(UNKNOWN_LOCATION, VAR_DECL, get_identifier("latent_entropy"), latent_entropy_type);
94001 +
94002 + TREE_STATIC(latent_entropy_decl) = 1;
94003 + TREE_PUBLIC(latent_entropy_decl) = 1;
94004 + TREE_USED(latent_entropy_decl) = 1;
94005 + TREE_THIS_VOLATILE(latent_entropy_decl) = 1;
94006 + DECL_EXTERNAL(latent_entropy_decl) = 1;
94007 + DECL_ARTIFICIAL(latent_entropy_decl) = 1;
94008 + DECL_INITIAL(latent_entropy_decl) = NULL;
94009 + lang_hooks.decls.pushdecl(latent_entropy_decl);
94010 +// DECL_ASSEMBLER_NAME(latent_entropy_decl);
94011 +// varpool_finalize_decl(latent_entropy_decl);
94012 +// varpool_mark_needed_node(latent_entropy_decl);
94013 +}
94014 +
94015 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
94016 +{
94017 + const char * const plugin_name = plugin_info->base_name;
94018 + struct register_pass_info latent_entropy_pass_info = {
94019 + .pass = &latent_entropy_pass.pass,
94020 + .reference_pass_name = "optimized",
94021 + .ref_pass_instance_number = 1,
94022 + .pos_op = PASS_POS_INSERT_BEFORE
94023 + };
94024 +
94025 + if (!plugin_default_version_check(version, &gcc_version)) {
94026 + error(G_("incompatible gcc/plugin versions"));
94027 + return 1;
94028 + }
94029 +
94030 + register_callback(plugin_name, PLUGIN_INFO, NULL, &latent_entropy_plugin_info);
94031 + register_callback ("start_unit", PLUGIN_START_UNIT, &start_unit_callback, NULL);
94032 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &latent_entropy_pass_info);
94033 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
94034 +
94035 + return 0;
94036 +}
94037 diff --git a/tools/gcc/size_overflow_hash.data b/tools/gcc/size_overflow_hash.data
94038 new file mode 100644
94039 index 0000000..5ac778be
94040 --- /dev/null
94041 +++ b/tools/gcc/size_overflow_hash.data
94042 @@ -0,0 +1,5862 @@
94043 +intel_fake_agp_alloc_by_type_1 intel_fake_agp_alloc_by_type 1 1 NULL
94044 +batadv_orig_node_del_if_4 batadv_orig_node_del_if 2 4 NULL
94045 +storvsc_connect_to_vsp_22 storvsc_connect_to_vsp 2 22 NULL
94046 +compat_sock_setsockopt_23 compat_sock_setsockopt 5 23 NULL
94047 +carl9170_alloc_27 carl9170_alloc 1 27 NULL
94048 +sel_read_policyvers_55 sel_read_policyvers 3 55 NULL nohasharray
94049 +padzero_55 padzero 1 55 &sel_read_policyvers_55
94050 +cfg80211_disconnected_57 cfg80211_disconnected 4 57 NULL
94051 +__skb_to_sgvec_72 __skb_to_sgvec 0 72 NULL
94052 +DepcaSignature_80 DepcaSignature 2 80 NULL nohasharray
94053 +crypto_authenc_setkey_80 crypto_authenc_setkey 3 80 &DepcaSignature_80
94054 +snd_korg1212_copy_to_92 snd_korg1212_copy_to 6 92 NULL
94055 +load_msg_95 load_msg 2 95 NULL
94056 +device_flush_iotlb_115 device_flush_iotlb 2-3 115 NULL
94057 +init_q_132 init_q 4 132 NULL
94058 +memstick_alloc_host_142 memstick_alloc_host 1 142 NULL
94059 +hva_to_gfn_memslot_149 hva_to_gfn_memslot 0-1 149 NULL
94060 +tracing_trace_options_write_153 tracing_trace_options_write 3 153 NULL
94061 +nvme_create_queue_170 nvme_create_queue 3 170 NULL
94062 +xfs_buf_item_get_format_189 xfs_buf_item_get_format 2 189 NULL
94063 +iscsi_session_setup_196 iscsi_session_setup 4-5 196 NULL
94064 +virtblk_add_req_197 virtblk_add_req 2-3 197 NULL
94065 +proc_scsi_write_proc_267 proc_scsi_write_proc 3 267 NULL
94066 +br_port_info_size_268 br_port_info_size 0 268 NULL
94067 +generic_file_direct_write_291 generic_file_direct_write 0 291 NULL
94068 +read_file_war_stats_292 read_file_war_stats 3 292 NULL
94069 +syslog_print_307 syslog_print 2 307 NULL
94070 +platform_device_add_data_310 platform_device_add_data 3 310 NULL
94071 +dn_setsockopt_314 dn_setsockopt 5 314 NULL
94072 +next_node_allowed_318 next_node_allowed 1 318 NULL
94073 +compat_sys_ioctl_333 compat_sys_ioctl 3 333 NULL
94074 +btmrvl_txdnldready_read_413 btmrvl_txdnldready_read 3 413 NULL
94075 +lbs_rdmac_read_418 lbs_rdmac_read 3 418 NULL
94076 +snd_ca0106_ptr_read_467 snd_ca0106_ptr_read 0 467 NULL
94077 +_alloc_get_attr_desc_470 _alloc_get_attr_desc 2 470 NULL
94078 +dccp_manip_pkt_476 dccp_manip_pkt 4 476 NULL
94079 +pidlist_resize_496 pidlist_resize 2 496 NULL
94080 +read_vbt_r0_503 read_vbt_r0 1 503 NULL
94081 +rx_rx_defrag_end_read_505 rx_rx_defrag_end_read 3 505 NULL
94082 +ocfs2_validate_meta_ecc_bhs_527 ocfs2_validate_meta_ecc_bhs 0 527 NULL
94083 +zlib_deflate_workspacesize_537 zlib_deflate_workspacesize 0-1-2 537 NULL
94084 +iwl_dbgfs_wowlan_sram_read_540 iwl_dbgfs_wowlan_sram_read 3 540 NULL
94085 +dle_count_543 dle_count 0 543 NULL
94086 +devres_alloc_551 devres_alloc 2 551 NULL
94087 +snd_aw2_saa7146_get_hw_ptr_playback_558 snd_aw2_saa7146_get_hw_ptr_playback 0 558 NULL
94088 +dev_hard_header_565 dev_hard_header 0 565 NULL nohasharray
94089 +start_isoc_chain_565 start_isoc_chain 2 565 &dev_hard_header_565
94090 +compat_sys_preadv_583 compat_sys_preadv 3 583 NULL
94091 +smk_write_load_self2_591 smk_write_load_self2 3 591 NULL
94092 +ni_gpct_device_construct_610 ni_gpct_device_construct 5 610 NULL
94093 +compat_sys_shmat_620 compat_sys_shmat 3 620 NULL
94094 +isp1760_register_628 isp1760_register 1-2 628 NULL
94095 +drbd_bm_find_next_643 drbd_bm_find_next 2 643 NULL
94096 +unlink_queued_645 unlink_queued 3-4 645 NULL
94097 +dtim_interval_read_654 dtim_interval_read 3 654 NULL
94098 +ceph_copy_user_to_page_vector_656 ceph_copy_user_to_page_vector 4-3 656 NULL
94099 +div_u64_rem_672 div_u64_rem 0 672 NULL
94100 +mem_rx_free_mem_blks_read_675 mem_rx_free_mem_blks_read 3 675 NULL
94101 +rtl8169_try_rx_copy_705 rtl8169_try_rx_copy 3 705 NULL
94102 +persistent_ram_vmap_709 persistent_ram_vmap 1-2 709 NULL
94103 +ipath_resize_cq_712 ipath_resize_cq 2 712 NULL
94104 +sctp_setsockopt_peer_addr_params_734 sctp_setsockopt_peer_addr_params 3 734 NULL
94105 +wm8962_gpio_direction_out_738 wm8962_gpio_direction_out 2 738 NULL
94106 +dvb_video_write_754 dvb_video_write 3 754 NULL
94107 +iwl_read_targ_mem_772 iwl_read_targ_mem 0 772 NULL
94108 +snd_pcm_drain_811 snd_pcm_drain 0 811 NULL
94109 +if_writecmd_815 if_writecmd 2 815 NULL
94110 +aac_change_queue_depth_825 aac_change_queue_depth 2 825 NULL
94111 +read_fifo_826 read_fifo 3 826 NULL
94112 +read_tree_block_841 read_tree_block 3 841 NULL
94113 +um_idi_read_850 um_idi_read 3 850 NULL
94114 +ieee80211_if_fmt_rc_rateidx_mcs_mask_5ghz_856 ieee80211_if_fmt_rc_rateidx_mcs_mask_5ghz 3 856 NULL
94115 +o2net_send_message_vec_879 o2net_send_message_vec 4 879 NULL nohasharray
94116 +iwl_dbgfs_fh_reg_read_879 iwl_dbgfs_fh_reg_read 3 879 &o2net_send_message_vec_879
94117 +snd_pcm_action_single_905 snd_pcm_action_single 0 905 NULL
94118 +btmrvl_hsstate_read_920 btmrvl_hsstate_read 3 920 NULL
94119 +readw_931 readw 0 931 NULL
94120 +carl9170_cmd_buf_950 carl9170_cmd_buf 3 950 NULL
94121 +ieee80211_ie_build_vht_cap_956 ieee80211_ie_build_vht_cap 0 956 NULL nohasharray
94122 +__nodes_weight_956 __nodes_weight 2-0 956 &ieee80211_ie_build_vht_cap_956
94123 +sys_msgrcv_959 sys_msgrcv 3 959 NULL
94124 +hdlcdev_rx_997 hdlcdev_rx 3 997 NULL
94125 +smk_write_cipso2_1021 smk_write_cipso2 3 1021 NULL
94126 +lp872x_select_buck_vout_addr_1045 lp872x_select_buck_vout_addr 0 1045 NULL
94127 +gigaset_initdriver_1060 gigaset_initdriver 2 1060 NULL
94128 +Read_hfc16_1070 Read_hfc16 0 1070 NULL
94129 +mce_request_packet_1073 mce_request_packet 3 1073 NULL
94130 +agp_create_memory_1075 agp_create_memory 1 1075 NULL
94131 +_scsih_adjust_queue_depth_1083 _scsih_adjust_queue_depth 2 1083 NULL
94132 +nfs_pgarray_set_1085 nfs_pgarray_set 2 1085 NULL
94133 +llcp_sock_sendmsg_1092 llcp_sock_sendmsg 4 1092 NULL
94134 +nfs4_init_nonuniform_client_string_1097 nfs4_init_nonuniform_client_string 3 1097 NULL
94135 +store_risefalltime_1109 store_risefalltime 5 1109 NULL
94136 +cfg80211_report_obss_beacon_1133 cfg80211_report_obss_beacon 3 1133 NULL
94137 +vmalloc_32_1135 vmalloc_32 1 1135 NULL
94138 +i2400m_rx_ctl_1157 i2400m_rx_ctl 4 1157 NULL
94139 +ipc_alloc_1192 ipc_alloc 1 1192 NULL
94140 +ib_create_send_mad_1196 ib_create_send_mad 5 1196 NULL
94141 +i2400m_rx_ctl_ack_1199 i2400m_rx_ctl_ack 3 1199 NULL
94142 +dgrp_dpa_read_1204 dgrp_dpa_read 3 1204 NULL
94143 +i2cdev_read_1206 i2cdev_read 3 1206 NULL
94144 +ipw_packet_received_skb_1230 ipw_packet_received_skb 2 1230 NULL
94145 +thin_status_1239 thin_status 5 1239 NULL
94146 +acpi_battery_write_alarm_1240 acpi_battery_write_alarm 3 1240 NULL
94147 +ocfs2_extend_file_1266 ocfs2_extend_file 3 1266 NULL
94148 +qla4xxx_change_queue_depth_1268 qla4xxx_change_queue_depth 2 1268 NULL
94149 +ioctl_private_iw_point_1273 ioctl_private_iw_point 7 1273 NULL
94150 +batadv_tt_prepare_packet_buff_1280 batadv_tt_prepare_packet_buff 4 1280 NULL
94151 +tx_frag_in_process_called_read_1290 tx_frag_in_process_called_read 3 1290 NULL
94152 +compat_put_u64_1319 compat_put_u64 1 1319 NULL
94153 +ffs_1322 ffs 0 1322 NULL
94154 +carl9170_rx_stream_1334 carl9170_rx_stream 3 1334 NULL
94155 +btrfs_submit_compressed_write_1347 btrfs_submit_compressed_write 5 1347 NULL
94156 +gen_pool_best_fit_1348 gen_pool_best_fit 2-3-4 1348 NULL
94157 +io_mapping_create_wc_1354 io_mapping_create_wc 1-2 1354 NULL
94158 +snd_pcm_lib_write1_1358 snd_pcm_lib_write1 0-3 1358 NULL
94159 +ipx_sendmsg_1362 ipx_sendmsg 4 1362 NULL
94160 +fw_stats_raw_read_1369 fw_stats_raw_read 3 1369 NULL
94161 +ocfs2_prepare_inode_for_write_1372 ocfs2_prepare_inode_for_write 3 1372 NULL
94162 +sctp_setsockopt_initmsg_1383 sctp_setsockopt_initmsg 3 1383 NULL
94163 +do_msgsnd_1387 do_msgsnd 4 1387 NULL
94164 +zone_page_state_1393 zone_page_state 0 1393 NULL
94165 +file_read_actor_1401 file_read_actor 4 1401 NULL
94166 +lm3533_als_get_threshold_reg_1404 lm3533_als_get_threshold_reg 0-1 1404 NULL
94167 +stack_max_size_read_1445 stack_max_size_read 3 1445 NULL
94168 +tx_queue_len_read_1463 tx_queue_len_read 3 1463 NULL
94169 +xprt_alloc_1475 xprt_alloc 2 1475 NULL
94170 +sta_num_ps_buf_frames_read_1488 sta_num_ps_buf_frames_read 3 1488 NULL
94171 +posix_acl_permission_1495 posix_acl_permission 0 1495 NULL
94172 +tomoyo_round2_1518 tomoyo_round2 0 1518 NULL
94173 +alloc_perm_bits_1532 alloc_perm_bits 2 1532 NULL
94174 +ieee80211_if_read_dot11MeshHWMPnetDiameterTraversalTime_1589 ieee80211_if_read_dot11MeshHWMPnetDiameterTraversalTime 3 1589 NULL
94175 +fc_frame_alloc_1596 fc_frame_alloc 2 1596 NULL
94176 +packet_buffer_init_1607 packet_buffer_init 2 1607 NULL
94177 +btmrvl_hscmd_read_1614 btmrvl_hscmd_read 3 1614 NULL
94178 +v9fs_fid_xattr_get_1618 v9fs_fid_xattr_get 0 1618 NULL
94179 +btmrvl_hsmode_read_1647 btmrvl_hsmode_read 3 1647 NULL
94180 +ikconfig_read_current_1658 ikconfig_read_current 3 1658 NULL
94181 +netdev_feature_string_1667 netdev_feature_string 0 1667 NULL
94182 +compat_x25_ioctl_1674 compat_x25_ioctl 3 1674 NULL
94183 +rmap_add_1677 rmap_add 3 1677 NULL
94184 +configfs_read_file_1683 configfs_read_file 3 1683 NULL
94185 +coda_psdev_write_1711 coda_psdev_write 3 1711 NULL
94186 +btrfs_dir_data_len_1714 btrfs_dir_data_len 0 1714 NULL
94187 +dma_memcpy_pg_to_iovec_1725 dma_memcpy_pg_to_iovec 6 1725 NULL
94188 +tx_frag_called_read_1748 tx_frag_called_read 3 1748 NULL
94189 +compat_cdrom_generic_command_1756 compat_cdrom_generic_command 4 1756 NULL
94190 +ieee80211_new_mesh_header_1761 ieee80211_new_mesh_header 0 1761 NULL
94191 +ebt_size_mwt_1768 ebt_size_mwt 0 1768 NULL
94192 +cosa_write_1774 cosa_write 3 1774 NULL
94193 +update_macheader_1775 update_macheader 7 1775 NULL
94194 +fcoe_ctlr_device_add_1793 fcoe_ctlr_device_add 3 1793 NULL
94195 +__nodelist_scnprintf_1815 __nodelist_scnprintf 0-2-4 1815 NULL
94196 +rx_defrag_called_read_1897 rx_defrag_called_read 3 1897 NULL
94197 +nfs_parse_server_name_1899 nfs_parse_server_name 2 1899 NULL
94198 +tx_tx_retry_data_read_1926 tx_tx_retry_data_read 3 1926 NULL
94199 +cyttsp_probe_1940 cyttsp_probe 4 1940 NULL
94200 +ieee80211_if_fmt_dot11MeshConfirmTimeout_1945 ieee80211_if_fmt_dot11MeshConfirmTimeout 3 1945 NULL
94201 +read_swap_header_1957 read_swap_header 0 1957 NULL
94202 +ivtv_v4l2_read_1964 ivtv_v4l2_read 3 1964 NULL
94203 +sel_read_avc_hash_stats_1984 sel_read_avc_hash_stats 3 1984 NULL
94204 +__alloc_bootmem_node_1992 __alloc_bootmem_node 2 1992 NULL
94205 +atomic_read_unchecked_1995 atomic_read_unchecked 0 1995 NULL
94206 +batadv_tt_commit_changes_2008 batadv_tt_commit_changes 4 2008 NULL
94207 +sep_prepare_input_dma_table_2009 sep_prepare_input_dma_table 2-3 2009 NULL
94208 +rx_rx_defrag_read_2010 rx_rx_defrag_read 3 2010 NULL
94209 +ocfs2_global_qinit_alloc_2018 ocfs2_global_qinit_alloc 0 2018 NULL
94210 +write_flush_pipefs_2021 write_flush_pipefs 3 2021 NULL
94211 +BcmCopySection_2035 BcmCopySection 5 2035 NULL
94212 +devm_ioremap_nocache_2036 devm_ioremap_nocache 2-3 2036 NULL
94213 +ath6kl_fwlog_mask_read_2050 ath6kl_fwlog_mask_read 3 2050 NULL
94214 +ocfs2_expand_inline_dir_2063 ocfs2_expand_inline_dir 3 2063 NULL
94215 +subbuf_read_actor_2071 subbuf_read_actor 3 2071 NULL
94216 +iwl_dbgfs_current_sleep_command_read_2081 iwl_dbgfs_current_sleep_command_read 3 2081 NULL
94217 +get_unaligned_le32_2092 get_unaligned_le32 0 2092 NULL
94218 +idetape_chrdev_read_2097 idetape_chrdev_read 3 2097 NULL
94219 +audit_expand_2098 audit_expand 2 2098 NULL
94220 +num_pages_spanned_2105 num_pages_spanned 0 2105 NULL
94221 +iwl_dbgfs_log_event_read_2107 iwl_dbgfs_log_event_read 3 2107 NULL
94222 +ecryptfs_encrypt_and_encode_filename_2109 ecryptfs_encrypt_and_encode_filename 6 2109 NULL
94223 +__find_xattr_2117 __find_xattr 6 2117 NULL nohasharray
94224 +enable_read_2117 enable_read 3 2117 &__find_xattr_2117
94225 +pcf50633_write_block_2124 pcf50633_write_block 3-2 2124 NULL
94226 +check_load_and_stores_2143 check_load_and_stores 2 2143 NULL
94227 +mlx4_init_icm_table_2151 mlx4_init_icm_table 5-4 2151 NULL nohasharray
94228 +multipath_status_2151 multipath_status 5 2151 &mlx4_init_icm_table_2151
94229 +iov_iter_count_2152 iov_iter_count 0 2152 NULL
94230 +_ore_get_io_state_2166 _ore_get_io_state 3-4-5 2166 NULL
94231 +ssb_bus_ssbbus_register_2217 ssb_bus_ssbbus_register 2 2217 NULL
94232 +u32_array_read_2219 u32_array_read 3 2219 NULL
94233 +vhci_write_2224 vhci_write 3 2224 NULL
94234 +efx_tsoh_page_count_2225 efx_tsoh_page_count 0 2225 NULL
94235 +lowpan_get_mac_header_length_2231 lowpan_get_mac_header_length 0 2231 NULL
94236 +ieee80211_if_read_dot11MeshHWMPRannInterval_2249 ieee80211_if_read_dot11MeshHWMPRannInterval 3 2249 NULL
94237 +netlbl_secattr_catmap_walk_2255 netlbl_secattr_catmap_walk 0-2 2255 NULL
94238 +sel_write_avc_cache_threshold_2256 sel_write_avc_cache_threshold 3 2256 NULL
94239 +do_update_counters_2259 do_update_counters 4 2259 NULL
94240 +ath6kl_wmi_bssinfo_event_rx_2275 ath6kl_wmi_bssinfo_event_rx 3 2275 NULL
94241 +debug_debug5_read_2291 debug_debug5_read 3 2291 NULL
94242 +kvm_clear_guest_page_2308 kvm_clear_guest_page 4 2308 NULL
94243 +intel_sdvo_set_value_2311 intel_sdvo_set_value 4 2311 NULL
94244 +picolcd_fb_write_2318 picolcd_fb_write 3 2318 NULL
94245 +gart_map_page_2325 gart_map_page 3-4 2325 NULL
94246 +__erst_read_to_erange_2341 __erst_read_to_erange 0 2341 NULL
94247 +zr364xx_read_2354 zr364xx_read 3 2354 NULL
94248 +viafb_iga2_odev_proc_write_2363 viafb_iga2_odev_proc_write 3 2363 NULL
94249 +xfs_buf_map_from_irec_2368 xfs_buf_map_from_irec 5 2368 NULL
94250 +il_dbgfs_sensitivity_read_2370 il_dbgfs_sensitivity_read 3 2370 NULL
94251 +rtl_port_map_2385 rtl_port_map 1-2 2385 NULL
94252 +rxpipe_rx_prep_beacon_drop_read_2403 rxpipe_rx_prep_beacon_drop_read 3 2403 NULL
94253 +isdn_v110_open_2418 isdn_v110_open 3 2418 NULL
94254 +raid1_size_2419 raid1_size 0-2 2419 NULL
94255 +roccat_common2_send_2422 roccat_common2_send 4 2422 NULL
94256 +hfcpci_empty_fifo_2427 hfcpci_empty_fifo 4 2427 NULL
94257 +ioremap_nocache_2439 ioremap_nocache 1-2 2439 NULL
94258 +tty_buffer_find_2443 tty_buffer_find 2 2443 NULL
94259 +nfs4_alloc_slots_2454 nfs4_alloc_slots 1 2454 NULL nohasharray
94260 +ath6kl_usb_bmi_write_2454 ath6kl_usb_bmi_write 3 2454 &nfs4_alloc_slots_2454
94261 +b43legacy_debugfs_read_2473 b43legacy_debugfs_read 3 2473 NULL
94262 +update_pmkid_2481 update_pmkid 4 2481 NULL
94263 +wiphy_new_2482 wiphy_new 2 2482 NULL
94264 +bio_alloc_bioset_2484 bio_alloc_bioset 2 2484 NULL
94265 +squashfs_read_fragment_index_table_2506 squashfs_read_fragment_index_table 4 2506 NULL
94266 +dm_write_2513 dm_write 3 2513 NULL
94267 +v9fs_cached_file_read_2514 v9fs_cached_file_read 3 2514 NULL
94268 +ext4_get_inode_loc_2516 ext4_get_inode_loc 0 2516 NULL
94269 +gspca_dev_probe_2570 gspca_dev_probe 4 2570 NULL
94270 +pcm_sanity_check_2574 pcm_sanity_check 0 2574 NULL
94271 +smk_write_logging_2618 smk_write_logging 3 2618 NULL
94272 +lro_gen_skb_2644 lro_gen_skb 6 2644 NULL
94273 +nfc_llcp_send_ui_frame_2702 nfc_llcp_send_ui_frame 5 2702 NULL
94274 +memcpy_fromiovecend_2707 memcpy_fromiovecend 3-4 2707 NULL
94275 +__xip_file_write_2733 __xip_file_write 4-3 2733 NULL
94276 +hid_report_raw_event_2762 hid_report_raw_event 4 2762 NULL
94277 +mon_bin_ioctl_2771 mon_bin_ioctl 3 2771 NULL
94278 +__next_cpu_2782 __next_cpu 1 2782 NULL
94279 +sel_read_enforce_2828 sel_read_enforce 3 2828 NULL
94280 +vb2_dc_get_userptr_2829 vb2_dc_get_userptr 2-3 2829 NULL nohasharray
94281 +snd_pcm_reset_2829 snd_pcm_reset 0 2829 &vb2_dc_get_userptr_2829
94282 +wait_for_avail_2847 wait_for_avail 0 2847 NULL
94283 +ufs_free_fragments_2857 ufs_free_fragments 2 2857 NULL
94284 +sfq_alloc_2861 sfq_alloc 1 2861 NULL
94285 +move_addr_to_user_2868 move_addr_to_user 2 2868 NULL
94286 +__swab64p_2875 __swab64p 0 2875 NULL
94287 +nla_padlen_2883 nla_padlen 1 2883 NULL
94288 +cmm_write_2896 cmm_write 3 2896 NULL
94289 +rbd_req_sync_read_2915 rbd_req_sync_read 4-5 2915 NULL
94290 +alloc_page_cgroup_2919 alloc_page_cgroup 1 2919 NULL
94291 +xfs_trans_get_buf_map_2927 xfs_trans_get_buf_map 4 2927 NULL
94292 +nes_read_indexed_2946 nes_read_indexed 0 2946 NULL
94293 +tm6000_i2c_recv_regs16_2949 tm6000_i2c_recv_regs16 5 2949 NULL
94294 +ppp_cp_event_2965 ppp_cp_event 6 2965 NULL
94295 +do_strnlen_user_2976 do_strnlen_user 0-2 2976 NULL
94296 +p9_nr_pages_2992 p9_nr_pages 0-2 2992 NULL
94297 +do_dmabuf_dirty_sou_3017 do_dmabuf_dirty_sou 7 3017 NULL
94298 +depth_write_3021 depth_write 3 3021 NULL
94299 +snd_azf3328_codec_inl_3022 snd_azf3328_codec_inl 0 3022 NULL
94300 +xfrm_dst_alloc_copy_3034 xfrm_dst_alloc_copy 3 3034 NULL
94301 +iwl_dbgfs_sleep_level_override_read_3038 iwl_dbgfs_sleep_level_override_read 3 3038 NULL
94302 +nr_free_buffer_pages_3044 nr_free_buffer_pages 0 3044 NULL
94303 +il3945_ucode_rx_stats_read_3048 il3945_ucode_rx_stats_read 3 3048 NULL
94304 +__blk_end_bidi_request_3070 __blk_end_bidi_request 3-4 3070 NULL
94305 +dac960_user_command_proc_write_3071 dac960_user_command_proc_write 3 3071 NULL
94306 +free_coherent_3082 free_coherent 4-2 3082 NULL
94307 +ttusb2_msg_3100 ttusb2_msg 4 3100 NULL
94308 +rb_alloc_3102 rb_alloc 1 3102 NULL
94309 +simple_write_to_buffer_3122 simple_write_to_buffer 5-2 3122 NULL
94310 +print_time_3132 print_time 0 3132 NULL
94311 +fill_write_buffer_3142 fill_write_buffer 3 3142 NULL
94312 +CIFSSMBSetPosixACL_3154 CIFSSMBSetPosixACL 5 3154 NULL
94313 +compat_sys_migrate_pages_3157 compat_sys_migrate_pages 2 3157 NULL
94314 +uv_num_possible_blades_3177 uv_num_possible_blades 0 3177 NULL
94315 +uvc_video_stats_dump_3181 uvc_video_stats_dump 3 3181 NULL
94316 +compat_do_ip6t_set_ctl_3184 compat_do_ip6t_set_ctl 4 3184 NULL
94317 +mempool_create_node_3191 mempool_create_node 1 3191 NULL
94318 +alloc_context_3194 alloc_context 1 3194 NULL
94319 +shmem_pread_slow_3198 shmem_pread_slow 3 3198 NULL
94320 +kimage_crash_alloc_3233 kimage_crash_alloc 3 3233 NULL
94321 +do_read_log_to_user_3236 do_read_log_to_user 4 3236 NULL
94322 +ext3_xattr_find_entry_3237 ext3_xattr_find_entry 0 3237 NULL
94323 +key_key_read_3241 key_key_read 3 3241 NULL
94324 +number_3243 number 0 3243 NULL
94325 +check_vendor_extension_3254 check_vendor_extension 1 3254 NULL
94326 +__ilog2_u64_3284 __ilog2_u64 0 3284 NULL
94327 +arvo_sysfs_write_3311 arvo_sysfs_write 6 3311 NULL
94328 +dbDiscardAG_3322 dbDiscardAG 3 3322 NULL
94329 +compat_sys_setsockopt_3326 compat_sys_setsockopt 5 3326 NULL
94330 +de600_read_byte_3332 de600_read_byte 0 3332 NULL
94331 +aac_rkt_ioremap_3333 aac_rkt_ioremap 2 3333 NULL
94332 +read_from_oldmem_3337 read_from_oldmem 2 3337 NULL
94333 +tty_port_register_device_attr_3341 tty_port_register_device_attr 3 3341 NULL
94334 +il_dbgfs_interrupt_read_3351 il_dbgfs_interrupt_read 3 3351 NULL
94335 +gsm_control_rls_3353 gsm_control_rls 3 3353 NULL
94336 +scnprintf_3360 scnprintf 0-2 3360 NULL nohasharray
94337 +tps65090_clr_bits_3360 tps65090_clr_bits 2 3360 &scnprintf_3360
94338 +mtdchar_writeoob_3393 mtdchar_writeoob 4 3393 NULL
94339 +send_stream_3397 send_stream 4 3397 NULL
94340 +isdn_readbchan_3401 isdn_readbchan 0-5 3401 NULL
94341 +msix_map_region_3411 msix_map_region 3 3411 NULL
94342 +mei_io_cb_alloc_resp_buf_3414 mei_io_cb_alloc_resp_buf 2 3414 NULL
94343 +pci_add_cap_save_buffer_3426 pci_add_cap_save_buffer 3 3426 NULL
94344 +crystalhd_create_dio_pool_3427 crystalhd_create_dio_pool 2 3427 NULL
94345 +pipe_iov_copy_to_user_3447 pipe_iov_copy_to_user 3 3447 NULL
94346 +percpu_modalloc_3448 percpu_modalloc 2-3 3448 NULL
94347 +jffs2_acl_setxattr_3464 jffs2_acl_setxattr 4 3464 NULL nohasharray
94348 +snd_pcm_lib_readv_transfer_3464 snd_pcm_lib_readv_transfer 4-2-5 3464 &jffs2_acl_setxattr_3464
94349 +alloc_skb_fclone_3467 alloc_skb_fclone 1 3467 NULL
94350 +security_context_to_sid_default_3492 security_context_to_sid_default 2 3492 NULL
94351 +xfrm_migrate_msgsize_3496 xfrm_migrate_msgsize 1 3496 NULL
94352 +mem_tx_free_mem_blks_read_3521 mem_tx_free_mem_blks_read 3 3521 NULL nohasharray
94353 +ieee80211_wx_set_gen_ie_rsl_3521 ieee80211_wx_set_gen_ie_rsl 3 3521 &mem_tx_free_mem_blks_read_3521
94354 +btrfs_dir_name_len_3549 btrfs_dir_name_len 0 3549 NULL
94355 +b43legacy_read16_3561 b43legacy_read16 0 3561 NULL
94356 +alloc_smp_resp_3566 alloc_smp_resp 1 3566 NULL
94357 +evtchn_read_3569 evtchn_read 3 3569 NULL
94358 +vc_resize_3585 vc_resize 2-3 3585 NULL
94359 +compat_sys_semtimedop_3606 compat_sys_semtimedop 3 3606 NULL
94360 +sctp_getsockopt_events_3607 sctp_getsockopt_events 2 3607 NULL
94361 +edac_mc_alloc_3611 edac_mc_alloc 4 3611 NULL
94362 +tx_tx_starts_read_3617 tx_tx_starts_read 3 3617 NULL
94363 +aligned_kmalloc_3628 aligned_kmalloc 1 3628 NULL
94364 +x86_swiotlb_alloc_coherent_3649 x86_swiotlb_alloc_coherent 2 3649 NULL nohasharray
94365 +cm_copy_private_data_3649 cm_copy_private_data 2 3649 &x86_swiotlb_alloc_coherent_3649
94366 +ath6kl_disconnect_timeout_read_3650 ath6kl_disconnect_timeout_read 3 3650 NULL
94367 +i915_compat_ioctl_3656 i915_compat_ioctl 2 3656 NULL
94368 +ntfs_attr_make_non_resident_3694 ntfs_attr_make_non_resident 0 3694 NULL
94369 +create_irq_3703 create_irq 0 3703 NULL nohasharray
94370 +btmrvl_psmode_write_3703 btmrvl_psmode_write 3 3703 &create_irq_3703 nohasharray
94371 +snd_m3_assp_read_3703 snd_m3_assp_read 0 3703 &btmrvl_psmode_write_3703
94372 +videobuf_pages_to_sg_3708 videobuf_pages_to_sg 2 3708 NULL
94373 +lm3533_als_get_threshold_3725 lm3533_als_get_threshold 2 3725 NULL
94374 +ci_ll_write_3740 ci_ll_write 4 3740 NULL nohasharray
94375 +ath6kl_mgmt_tx_3740 ath6kl_mgmt_tx 7 3740 &ci_ll_write_3740
94376 +sctp_setsockopt_auth_key_3793 sctp_setsockopt_auth_key 3 3793 NULL
94377 +ncp_file_write_3813 ncp_file_write 3 3813 NULL
94378 +read_file_tx_chainmask_3829 read_file_tx_chainmask 3 3829 NULL
94379 +stringify_nodemap_3842 stringify_nodemap 2 3842 NULL
94380 +ubi_eba_read_leb_3847 ubi_eba_read_leb 0 3847 NULL
94381 +create_one_cdev_3852 create_one_cdev 2 3852 NULL
94382 +smk_read_onlycap_3855 smk_read_onlycap 3 3855 NULL
94383 +get_fd_set_3866 get_fd_set 1 3866 NULL
94384 +garp_attr_create_3883 garp_attr_create 3 3883 NULL
94385 +uea_send_modem_cmd_3888 uea_send_modem_cmd 3 3888 NULL
94386 +efivarfs_file_read_3893 efivarfs_file_read 3 3893 NULL
94387 +nvram_write_3894 nvram_write 3 3894 NULL
94388 +pipeline_pre_proc_swi_read_3898 pipeline_pre_proc_swi_read 3 3898 NULL
94389 +comedi_buf_read_n_available_3899 comedi_buf_read_n_available 0 3899 NULL
94390 +vcs_write_3910 vcs_write 3 3910 NULL
94391 +atalk_compat_ioctl_3991 atalk_compat_ioctl 3 3991 NULL
94392 +do_add_counters_3992 do_add_counters 3 3992 NULL
94393 +userspace_status_4004 userspace_status 4 4004 NULL
94394 +mei_write_4005 mei_write 3 4005 NULL nohasharray
94395 +xfs_check_block_4005 xfs_check_block 4 4005 &mei_write_4005
94396 +snd_hdsp_capture_copy_4011 snd_hdsp_capture_copy 5 4011 NULL
94397 +blk_end_request_4024 blk_end_request 3 4024 NULL
94398 +ext4_xattr_find_entry_4025 ext4_xattr_find_entry 0 4025 NULL
94399 +usbnet_write_cmd_async_4035 usbnet_write_cmd_async 7 4035 NULL
94400 +read_file_queues_4078 read_file_queues 3 4078 NULL
94401 +fbcon_do_set_font_4079 fbcon_do_set_font 2-3 4079 NULL
94402 +da9052_free_irq_4090 da9052_free_irq 2 4090 NULL
94403 +tm6000_read_4151 tm6000_read 3 4151 NULL
94404 +mpt_raid_phys_disk_get_num_paths_4155 mpt_raid_phys_disk_get_num_paths 0 4155 NULL
94405 +msg_bits_4158 msg_bits 0-3-4 4158 NULL
94406 +get_alua_req_4166 get_alua_req 3 4166 NULL
94407 +blk_dropped_read_4168 blk_dropped_read 3 4168 NULL
94408 +read_file_bool_4180 read_file_bool 3 4180 NULL
94409 +f1x_determine_channel_4202 f1x_determine_channel 2 4202 NULL
94410 +_osd_req_list_objects_4204 _osd_req_list_objects 6 4204 NULL
94411 +__snd_gf1_read_addr_4210 __snd_gf1_read_addr 0 4210 NULL
94412 +ext4_new_inode_4247 ext4_new_inode 5 4247 NULL
94413 +xt_compat_add_offset_4289 xt_compat_add_offset 0 4289 NULL
94414 +__usbnet_read_cmd_4299 __usbnet_read_cmd 7 4299 NULL
94415 +dvb_ringbuffer_pkt_read_user_4303 dvb_ringbuffer_pkt_read_user 2-3-5 4303 NULL
94416 +nouveau_fifo_create__4327 nouveau_fifo_create_ 5-6 4327 NULL
94417 +snd_rawmidi_kernel_read_4328 snd_rawmidi_kernel_read 3 4328 NULL
94418 +__copy_from_user_inatomic_4365 __copy_from_user_inatomic 3 4365 NULL
94419 +sys_setdomainname_4373 sys_setdomainname 2 4373 NULL
94420 +irda_sendmsg_4388 irda_sendmsg 4 4388 NULL
94421 +access_process_vm_4412 access_process_vm 0-2-4 4412 NULL nohasharray
94422 +cxacru_cm_get_array_4412 cxacru_cm_get_array 4 4412 &access_process_vm_4412
94423 +libfc_vport_create_4415 libfc_vport_create 2 4415 NULL
94424 +do_pages_stat_4437 do_pages_stat 2 4437 NULL
94425 +at76_set_card_command_4471 at76_set_card_command 4 4471 NULL
94426 +snd_seq_expand_var_event_4481 snd_seq_expand_var_event 0-5 4481 NULL
94427 +sys_semtimedop_4486 sys_semtimedop 3 4486 NULL
94428 +vmbus_establish_gpadl_4495 vmbus_establish_gpadl 3 4495 NULL
94429 +set_link_security_4502 set_link_security 4 4502 NULL
94430 +sys_llistxattr_4532 sys_llistxattr 3 4532 NULL
94431 +da9052_group_write_4534 da9052_group_write 2-3 4534 NULL
94432 +tty_register_device_4544 tty_register_device 2 4544 NULL
94433 +videobuf_vmalloc_to_sg_4548 videobuf_vmalloc_to_sg 2 4548 NULL
94434 +btrfs_file_extent_inline_item_len_4575 btrfs_file_extent_inline_item_len 0 4575 NULL
94435 +xfs_buf_get_maps_4581 xfs_buf_get_maps 2 4581 NULL
94436 +bch_alloc_4593 bch_alloc 1 4593 NULL
94437 +iwl_dbgfs_tx_queue_read_4635 iwl_dbgfs_tx_queue_read 3 4635 NULL
94438 +skb_add_data_nocache_4682 skb_add_data_nocache 4 4682 NULL
94439 +cx18_read_pos_4683 cx18_read_pos 3 4683 NULL
94440 +short_retry_limit_read_4687 short_retry_limit_read 3 4687 NULL
94441 +kone_receive_4690 kone_receive 4 4690 NULL
94442 +round_pipe_size_4701 round_pipe_size 0 4701 NULL
94443 +cxgbi_alloc_big_mem_4707 cxgbi_alloc_big_mem 1 4707 NULL
94444 +btmrvl_gpiogap_read_4718 btmrvl_gpiogap_read 3 4718 NULL
94445 +ati_create_gatt_pages_4722 ati_create_gatt_pages 1 4722 NULL nohasharray
94446 +show_header_4722 show_header 3 4722 &ati_create_gatt_pages_4722
94447 +pwr_rcvd_bcns_cnt_read_4774 pwr_rcvd_bcns_cnt_read 3 4774 NULL
94448 +ncp__vol2io_4804 ncp__vol2io 5 4804 NULL
94449 +repair_io_failure_4815 repair_io_failure 4 4815 NULL
94450 +__iio_allocate_sw_ring_buffer_4843 __iio_allocate_sw_ring_buffer 3 4843 NULL
94451 +gigaset_if_receive_4861 gigaset_if_receive 3 4861 NULL
94452 +key_tx_spec_read_4862 key_tx_spec_read 3 4862 NULL
94453 +ocfs2_defrag_extent_4873 ocfs2_defrag_extent 3 4873 NULL
94454 +hid_register_field_4874 hid_register_field 2-3 4874 NULL
94455 +vga_arb_read_4886 vga_arb_read 3 4886 NULL
94456 +sys_ipc_4889 sys_ipc 3 4889 NULL
94457 +lp872x_write_byte_4914 lp872x_write_byte 2 4914 NULL
94458 +sys_process_vm_writev_4928 sys_process_vm_writev 3-5 4928 NULL
94459 +ntfs_rl_insert_4931 ntfs_rl_insert 2-4 4931 NULL
94460 +ieee80211_if_fmt_ave_beacon_4941 ieee80211_if_fmt_ave_beacon 3 4941 NULL
94461 +da9055_reg_write_4942 da9055_reg_write 2 4942 NULL
94462 +devm_kzalloc_4966 devm_kzalloc 2 4966 NULL
94463 +compat_rawv6_setsockopt_4967 compat_rawv6_setsockopt 5 4967 NULL
94464 +skb_network_header_len_4971 skb_network_header_len 0 4971 NULL
94465 +ieee80211_if_fmt_dot11MeshHWMPconfirmationInterval_4976 ieee80211_if_fmt_dot11MeshHWMPconfirmationInterval 3 4976 NULL
94466 +vmw_surface_define_size_4993 vmw_surface_define_size 0 4993 NULL
94467 +qla82xx_pci_mem_write_direct_5008 qla82xx_pci_mem_write_direct 2 5008 NULL
94468 +lm3533_als_set_target_5010 lm3533_als_set_target 2-3 5010 NULL
94469 +do_mincore_5018 do_mincore 0-1 5018 NULL
94470 +mtd_device_parse_register_5024 mtd_device_parse_register 5 5024 NULL
94471 +ocfs2_check_range_for_holes_5066 ocfs2_check_range_for_holes 2-3 5066 NULL
94472 +snd_mixart_BA1_read_5082 snd_mixart_BA1_read 5 5082 NULL
94473 +snd_emu10k1_ptr20_read_5087 snd_emu10k1_ptr20_read 0 5087 NULL
94474 +get_random_bytes_5091 get_random_bytes 2 5091 NULL nohasharray
94475 +kfifo_copy_from_user_5091 kfifo_copy_from_user 3 5091 &get_random_bytes_5091 nohasharray
94476 +blk_rq_sectors_5091 blk_rq_sectors 0 5091 &kfifo_copy_from_user_5091
94477 +mpol_to_str_5093 mpol_to_str 2 5093 NULL
94478 +sound_write_5102 sound_write 3 5102 NULL
94479 +ufs_add_fragments_5144 ufs_add_fragments 2 5144 NULL
94480 +compat_ptr_5159 compat_ptr 0-1 5159 NULL
94481 +__uwb_addr_print_5161 __uwb_addr_print 2 5161 NULL
94482 +iwl_dbgfs_status_read_5171 iwl_dbgfs_status_read 3 5171 NULL
94483 +acpi_pcc_get_sqty_5176 acpi_pcc_get_sqty 0 5176 NULL
94484 +sfi_map_memory_5183 sfi_map_memory 1-2 5183 NULL
94485 +skb_network_header_5203 skb_network_header 0 5203 NULL
94486 +pipe_set_size_5204 pipe_set_size 2 5204 NULL
94487 +ppp_cp_parse_cr_5214 ppp_cp_parse_cr 4 5214 NULL
94488 +ath6kl_debug_roam_tbl_event_5224 ath6kl_debug_roam_tbl_event 3 5224 NULL
94489 +ssb_ioremap_5228 ssb_ioremap 2 5228 NULL
94490 +isdn_ppp_skb_push_5236 isdn_ppp_skb_push 2 5236 NULL
94491 +do_atmif_sioc_5247 do_atmif_sioc 3 5247 NULL
94492 +pwr_elp_enter_read_5324 pwr_elp_enter_read 3 5324 NULL
94493 +allocate_cnodes_5329 allocate_cnodes 1 5329 NULL
94494 +ps_pspoll_utilization_read_5361 ps_pspoll_utilization_read 3 5361 NULL
94495 +cciss_allocate_sg_chain_blocks_5368 cciss_allocate_sg_chain_blocks 3-2 5368 NULL
94496 +bitmap_fold_5396 bitmap_fold 4 5396 NULL
94497 +nilfs_palloc_entries_per_group_5418 nilfs_palloc_entries_per_group 0 5418 NULL
94498 +sfi_map_table_5462 sfi_map_table 1 5462 NULL
94499 +xfs_efd_init_5463 xfs_efd_init 3 5463 NULL
94500 +xfs_efi_init_5476 xfs_efi_init 2 5476 NULL
94501 +ubi_leb_write_5478 ubi_leb_write 4-5 5478 NULL
94502 +cifs_security_flags_proc_write_5484 cifs_security_flags_proc_write 3 5484 NULL
94503 +tty_write_5494 tty_write 3 5494 NULL
94504 +tomoyo_update_domain_5498 tomoyo_update_domain 2 5498 NULL nohasharray
94505 +ieee80211_if_fmt_last_beacon_5498 ieee80211_if_fmt_last_beacon 3 5498 &tomoyo_update_domain_5498
94506 +__max_nr_grant_frames_5505 __max_nr_grant_frames 0 5505 NULL
94507 +spidev_message_5518 spidev_message 3 5518 NULL
94508 +ieee80211_if_fmt_auto_open_plinks_5534 ieee80211_if_fmt_auto_open_plinks 3 5534 NULL
94509 +brcmu_pkt_buf_get_skb_5556 brcmu_pkt_buf_get_skb 1 5556 NULL
94510 +le_readq_5557 le_readq 0 5557 NULL
94511 +inw_5558 inw 0 5558 NULL
94512 +__first_dma_cap_5560 __first_dma_cap 0 5560 NULL
94513 +fir16_create_5574 fir16_create 3 5574 NULL
94514 +bioset_create_5580 bioset_create 1 5580 NULL
94515 +oz_ep_alloc_5587 oz_ep_alloc 2 5587 NULL
94516 +do_msgrcv_5590 do_msgrcv 4 5590 NULL
94517 +usb_dump_device_descriptor_5599 usb_dump_device_descriptor 0 5599 NULL
94518 +ldm_frag_add_5611 ldm_frag_add 2 5611 NULL
94519 +compat_copy_entries_5617 compat_copy_entries 0 5617 NULL
94520 +ext4_xattr_get_5661 ext4_xattr_get 0 5661 NULL
94521 +posix_clock_register_5662 posix_clock_register 2 5662 NULL
94522 +mthca_map_reg_5664 mthca_map_reg 2-3 5664 NULL
94523 +__videobuf_alloc_vb_5665 __videobuf_alloc_vb 1 5665 NULL
94524 +get_arg_5694 get_arg 3 5694 NULL
94525 +vmw_kms_readback_5727 vmw_kms_readback 6 5727 NULL
94526 +rts51x_transfer_data_partial_5735 rts51x_transfer_data_partial 6 5735 NULL
94527 +ubi_cdev_compat_ioctl_5746 ubi_cdev_compat_ioctl 3 5746 NULL
94528 +sctp_setsockopt_autoclose_5775 sctp_setsockopt_autoclose 3 5775 NULL
94529 +compat_sys_writev_5784 compat_sys_writev 3 5784 NULL
94530 +__vxge_hw_blockpool_malloc_5786 __vxge_hw_blockpool_malloc 2 5786 NULL
94531 +skb_copy_datagram_iovec_5806 skb_copy_datagram_iovec 2-4 5806 NULL
94532 +nv50_disp_pioc_create__5812 nv50_disp_pioc_create_ 5 5812 NULL
94533 +ceph_x_encrypt_buflen_5829 ceph_x_encrypt_buflen 0-1 5829 NULL
94534 +autofs4_root_compat_ioctl_5838 autofs4_root_compat_ioctl 3 5838 NULL
94535 +ceph_msg_new_5846 ceph_msg_new 2 5846 NULL
94536 +ixgb_check_copybreak_5847 ixgb_check_copybreak 3 5847 NULL
94537 +setup_req_5848 setup_req 3 5848 NULL
94538 +rx_filter_max_arp_queue_dep_read_5851 rx_filter_max_arp_queue_dep_read 3 5851 NULL
94539 +compat_sys_move_pages_5861 compat_sys_move_pages 2 5861 NULL nohasharray
94540 +uinput_compat_ioctl_5861 uinput_compat_ioctl 3 5861 &compat_sys_move_pages_5861
94541 +port_show_regs_5904 port_show_regs 3 5904 NULL
94542 +rbd_segment_length_5907 rbd_segment_length 0-3-2 5907 NULL
94543 +uhci_debug_read_5911 uhci_debug_read 3 5911 NULL
94544 +qla82xx_pci_mem_read_2M_5912 qla82xx_pci_mem_read_2M 2 5912 NULL
94545 +ttm_bo_kmap_ttm_5922 ttm_bo_kmap_ttm 3 5922 NULL
94546 +lbs_highsnr_read_5931 lbs_highsnr_read 3 5931 NULL
94547 +ps_poll_ps_poll_timeouts_read_5934 ps_poll_ps_poll_timeouts_read 3 5934 NULL
94548 +edac_device_alloc_ctl_info_5941 edac_device_alloc_ctl_info 1 5941 NULL
94549 +tipc_subseq_alloc_5957 tipc_subseq_alloc 1 5957 NULL
94550 +__apu_get_register_5967 __apu_get_register 0 5967 NULL
94551 +ieee80211_if_fmt_rc_rateidx_mask_5ghz_5971 ieee80211_if_fmt_rc_rateidx_mask_5ghz 3 5971 NULL
94552 +ntfs_rl_append_6037 ntfs_rl_append 2-4 6037 NULL
94553 +da9052_request_irq_6058 da9052_request_irq 2 6058 NULL
94554 +sctp_setsockopt_connectx_6073 sctp_setsockopt_connectx 3 6073 NULL
94555 +rts51x_ms_rw_multi_sector_6076 rts51x_ms_rw_multi_sector 3-4 6076 NULL
94556 +ipmi_addr_length_6110 ipmi_addr_length 0 6110 NULL
94557 +dfs_global_file_write_6112 dfs_global_file_write 3 6112 NULL
94558 +matrix_keypad_build_keymap_6129 matrix_keypad_build_keymap 3 6129 NULL
94559 +nouveau_parent_create__6131 nouveau_parent_create_ 7 6131 NULL
94560 +ivtv_copy_buf_to_user_6159 ivtv_copy_buf_to_user 4 6159 NULL
94561 +vdma_mem_alloc_6171 vdma_mem_alloc 1 6171 NULL
94562 +wl1251_cmd_template_set_6172 wl1251_cmd_template_set 4 6172 NULL
94563 +mxt_show_instance_6207 mxt_show_instance 2-0 6207 NULL
94564 +v4l2_ctrl_new_std_menu_6221 v4l2_ctrl_new_std_menu 4 6221 NULL
94565 +mqueue_read_file_6228 mqueue_read_file 3 6228 NULL
94566 +f_hidg_read_6238 f_hidg_read 3 6238 NULL
94567 +fbcon_prepare_logo_6246 fbcon_prepare_logo 5 6246 NULL
94568 +pcpu_next_pop_6277 pcpu_next_pop 4 6277 NULL
94569 +tx_tx_start_null_frame_read_6281 tx_tx_start_null_frame_read 3 6281 NULL
94570 +snd_hda_override_conn_list_6282 snd_hda_override_conn_list 0 6282 NULL nohasharray
94571 +xenbus_file_write_6282 xenbus_file_write 3 6282 &snd_hda_override_conn_list_6282
94572 +posix_acl_fix_xattr_to_user_6283 posix_acl_fix_xattr_to_user 2 6283 NULL
94573 +nf_nat_ipv6_manip_pkt_6289 nf_nat_ipv6_manip_pkt 2 6289 NULL
94574 +nf_nat_sack_adjust_6297 nf_nat_sack_adjust 2 6297 NULL
94575 +mid_get_vbt_data_r10_6308 mid_get_vbt_data_r10 2 6308 NULL
94576 +_proc_do_string_6376 _proc_do_string 2 6376 NULL
94577 +osd_req_read_sg_kern_6378 osd_req_read_sg_kern 5 6378 NULL
94578 +posix_acl_fix_xattr_userns_6420 posix_acl_fix_xattr_userns 4 6420 NULL
94579 +ipr_change_queue_depth_6431 ipr_change_queue_depth 2 6431 NULL
94580 +__alloc_bootmem_node_nopanic_6432 __alloc_bootmem_node_nopanic 2 6432 NULL
94581 +ext4_compat_ioctl_6471 ext4_compat_ioctl 3 6471 NULL
94582 +ieee80211_if_fmt_dot11MeshMaxRetries_6476 ieee80211_if_fmt_dot11MeshMaxRetries 3 6476 NULL
94583 +cipso_v4_map_lvl_hton_6490 cipso_v4_map_lvl_hton 0 6490 NULL
94584 +dbg_intr_buf_6501 dbg_intr_buf 2 6501 NULL
94585 +mei_read_6507 mei_read 3 6507 NULL
94586 +cpumask_next_and_6516 cpumask_next_and 1 6516 NULL
94587 +read_file_disable_ani_6536 read_file_disable_ani 3 6536 NULL
94588 +rndis_set_oid_6547 rndis_set_oid 4 6547 NULL
94589 +wdm_read_6549 wdm_read 3 6549 NULL
94590 +fb_alloc_cmap_6554 fb_alloc_cmap 2 6554 NULL
94591 +usb_dump_config_descriptor_6572 usb_dump_config_descriptor 0 6572 NULL
94592 +snd_pcm_hw_refine_old_user_6586 snd_pcm_hw_refine_old_user 0 6586 NULL
94593 +usemap_size_6601 usemap_size 0-1 6601 NULL
94594 +snmp_mib_init_6604 snmp_mib_init 2-3 6604 NULL
94595 +ecryptfs_filldir_6622 ecryptfs_filldir 3 6622 NULL
94596 +virtscsi_alloc_tgt_6643 virtscsi_alloc_tgt 2 6643 NULL
94597 +aac_srcv_ioremap_6659 aac_srcv_ioremap 2 6659 NULL
94598 +process_rcvd_data_6679 process_rcvd_data 3 6679 NULL
94599 +ql_process_mac_rx_skb_6689 ql_process_mac_rx_skb 4 6689 NULL
94600 +ieee80211_build_preq_ies_6691 ieee80211_build_preq_ies 0-4 6691 NULL
94601 +btrfs_lookup_csums_range_6696 btrfs_lookup_csums_range 2 6696 NULL
94602 +ps_pspoll_max_apturn_read_6699 ps_pspoll_max_apturn_read 3 6699 NULL
94603 +bnad_debugfs_write_regrd_6706 bnad_debugfs_write_regrd 3 6706 NULL
94604 +mpeg_read_6708 mpeg_read 3 6708 NULL
94605 +video_proc_write_6724 video_proc_write 3 6724 NULL
94606 +posix_acl_xattr_count_6725 posix_acl_xattr_count 0-1 6725 NULL
94607 +rds_rdma_pages_6735 rds_rdma_pages 0 6735 NULL
94608 +sfi_check_table_6772 sfi_check_table 1 6772 NULL
94609 +iwl_dbgfs_channels_read_6784 iwl_dbgfs_channels_read 3 6784 NULL
94610 +ieee80211_if_read_6785 ieee80211_if_read 3 6785 NULL
94611 +hdlcdrv_register_6792 hdlcdrv_register 2 6792 NULL
94612 +tx_tx_done_data_read_6799 tx_tx_done_data_read 3 6799 NULL
94613 +make_8259A_irq_6828 make_8259A_irq 1 6828 NULL
94614 +calc_pages_for_6838 calc_pages_for 0-1-2 6838 NULL
94615 +mon_bin_read_6841 mon_bin_read 3 6841 NULL
94616 +snd_cs4281_BA0_read_6847 snd_cs4281_BA0_read 5 6847 NULL
94617 +ieee80211_if_fmt_path_refresh_time_6888 ieee80211_if_fmt_path_refresh_time 3 6888 NULL nohasharray
94618 +raw_seticmpfilter_6888 raw_seticmpfilter 3 6888 &ieee80211_if_fmt_path_refresh_time_6888
94619 +dlmfs_file_write_6892 dlmfs_file_write 3 6892 NULL
94620 +spi_show_regs_6911 spi_show_regs 3 6911 NULL nohasharray
94621 +proc_sessionid_read_6911 proc_sessionid_read 3 6911 &spi_show_regs_6911 nohasharray
94622 +acm_alloc_minor_6911 acm_alloc_minor 0 6911 &proc_sessionid_read_6911
94623 +__kfifo_dma_in_finish_r_6913 __kfifo_dma_in_finish_r 2-3 6913 NULL
94624 +ieee80211_rx_mgmt_probe_resp_6918 ieee80211_rx_mgmt_probe_resp 3 6918 NULL
94625 +do_msgrcv_6921 do_msgrcv 3 6921 NULL
94626 +cache_do_downcall_6926 cache_do_downcall 3 6926 NULL
94627 +qsfp_cks_6945 qsfp_cks 0-2 6945 NULL
94628 +pch_uart_hal_read_6961 pch_uart_hal_read 0 6961 NULL
94629 +videobuf_dma_init_kernel_6963 videobuf_dma_init_kernel 3 6963 NULL
94630 +rsa_extract_mpi_6973 rsa_extract_mpi 5 6973 NULL
94631 +crypto_authenc_esn_setkey_6985 crypto_authenc_esn_setkey 3 6985 NULL
94632 +request_key_async_6990 request_key_async 4 6990 NULL
94633 +r871x_set_wpa_ie_7000 r871x_set_wpa_ie 3 7000 NULL
94634 +cipso_v4_gentag_enum_7006 cipso_v4_gentag_enum 0 7006 NULL
94635 +tracing_cpumask_read_7010 tracing_cpumask_read 3 7010 NULL
94636 +wimax_msg_7030 wimax_msg 4 7030 NULL
94637 +ipath_get_base_info_7043 ipath_get_base_info 3 7043 NULL
94638 +snd_pcm_oss_bytes_7051 snd_pcm_oss_bytes 2 7051 NULL
94639 +event_enable_read_7074 event_enable_read 3 7074 NULL
94640 +beacon_interval_read_7091 beacon_interval_read 3 7091 NULL
94641 +lp_compat_ioctl_7098 lp_compat_ioctl 3 7098 NULL
94642 +pipeline_enc_rx_stat_fifo_int_read_7107 pipeline_enc_rx_stat_fifo_int_read 3 7107 NULL
94643 +check_header_7108 check_header 0 7108 NULL
94644 +__alloc_objio_seg_7203 __alloc_objio_seg 1 7203 NULL nohasharray
94645 +utf16_strsize_7203 utf16_strsize 0 7203 &__alloc_objio_seg_7203
94646 +sys32_ipc_7238 sys32_ipc 3-5-6-4 7238 NULL
94647 +get_param_h_7247 get_param_h 0 7247 NULL
94648 +vm_mmap_pgoff_7259 vm_mmap_pgoff 0 7259 NULL
94649 +dma_ops_alloc_addresses_7272 dma_ops_alloc_addresses 3-4-5 7272 NULL
94650 +rx_rate_rx_frames_per_rates_read_7282 rx_rate_rx_frames_per_rates_read 3 7282 NULL
94651 +mgmt_control_7349 mgmt_control 3 7349 NULL
94652 +ext3_free_blocks_7362 ext3_free_blocks 3-4 7362 NULL
94653 +ieee80211_if_read_dot11MeshHWMPactivePathTimeout_7368 ieee80211_if_read_dot11MeshHWMPactivePathTimeout 3 7368 NULL
94654 +hweight_long_7388 hweight_long 0-1 7388 NULL
94655 +vhost_scsi_compat_ioctl_7393 vhost_scsi_compat_ioctl 3 7393 NULL
94656 +sl_change_mtu_7396 sl_change_mtu 2 7396 NULL
94657 +readb_7401 readb 0 7401 NULL
94658 +drm_property_create_blob_7414 drm_property_create_blob 2 7414 NULL
94659 +ip_options_get_alloc_7448 ip_options_get_alloc 1 7448 NULL
94660 +ms_rw_multi_sector_7459 ms_rw_multi_sector 3-4 7459 NULL
94661 +__mutex_lock_common_7469 __mutex_lock_common 0 7469 NULL nohasharray
94662 +wm8996_gpio_direction_out_7469 wm8996_gpio_direction_out 2 7469 &__mutex_lock_common_7469
94663 +garp_request_join_7471 garp_request_join 4 7471 NULL
94664 +compat_sys_msgrcv_7482 compat_sys_msgrcv 2 7482 NULL
94665 +snd_pcm_lib_read1_7491 snd_pcm_lib_read1 0-3 7491 NULL
94666 +sdhci_alloc_host_7509 sdhci_alloc_host 2 7509 NULL nohasharray
94667 +ahash_instance_headroom_7509 ahash_instance_headroom 0 7509 &sdhci_alloc_host_7509
94668 +array_zalloc_7519 array_zalloc 1-2 7519 NULL
94669 +setup_usemap_7524 setup_usemap 3 7524 NULL
94670 +goal_in_my_reservation_7553 goal_in_my_reservation 3 7553 NULL
94671 +smk_read_mapped_7562 smk_read_mapped 3 7562 NULL
94672 +ext3_try_to_allocate_7590 ext3_try_to_allocate 5-3 7590 NULL
94673 +groups_alloc_7614 groups_alloc 1 7614 NULL
94674 +sg_virt_7616 sg_virt 0 7616 NULL
94675 +cpumask_first_7648 cpumask_first 0 7648 NULL
94676 +skb_copy_expand_7685 skb_copy_expand 2-3 7685 NULL nohasharray
94677 +acpi_ex_allocate_name_string_7685 acpi_ex_allocate_name_string 2-1 7685 &skb_copy_expand_7685
94678 +acpi_ns_get_pathname_length_7699 acpi_ns_get_pathname_length 0 7699 NULL
94679 +dev_write_7708 dev_write 3 7708 NULL
94680 +tps65090_set_bits_7709 tps65090_set_bits 2 7709 NULL
94681 +brcmf_sdcard_send_buf_7713 brcmf_sdcard_send_buf 6 7713 NULL nohasharray
94682 +dbg_check_cats_7713 dbg_check_cats 0 7713 &brcmf_sdcard_send_buf_7713
94683 +set_bypass_pwup_pfs_7742 set_bypass_pwup_pfs 3 7742 NULL
94684 +vxge_device_register_7752 vxge_device_register 4 7752 NULL
94685 +osdv2_attr_list_elem_size_7763 osdv2_attr_list_elem_size 0-1 7763 NULL
94686 +ubi_io_read_vid_hdr_7766 ubi_io_read_vid_hdr 0 7766 NULL
94687 +alloc_candev_7776 alloc_candev 1-2 7776 NULL
94688 +dfs_global_file_read_7787 dfs_global_file_read 3 7787 NULL
94689 +bnx2_nvram_write_7790 bnx2_nvram_write 4-2 7790 NULL
94690 +diva_os_copy_from_user_7792 diva_os_copy_from_user 4 7792 NULL
94691 +ubifs_leb_read_7828 ubifs_leb_read 0 7828 NULL
94692 +da9052_reg_update_7858 da9052_reg_update 2 7858 NULL
94693 +tps6586x_clr_bits_7889 tps6586x_clr_bits 2 7889 NULL
94694 +dvb_dmxdev_read_sec_7892 dvb_dmxdev_read_sec 4 7892 NULL
94695 +xfs_trans_get_efi_7898 xfs_trans_get_efi 2 7898 NULL
94696 +gfs2_tune_get_i_7903 gfs2_tune_get_i 0 7903 NULL
94697 +ext3_group_extend_7911 ext3_group_extend 3 7911 NULL
94698 +libfc_host_alloc_7917 libfc_host_alloc 2 7917 NULL
94699 +f_hidg_write_7932 f_hidg_write 3 7932 NULL
94700 +io_apic_setup_irq_pin_once_7934 io_apic_setup_irq_pin_once 1 7934 NULL
94701 +smk_write_load_self_7958 smk_write_load_self 3 7958 NULL
94702 +sys_mbind_7990 sys_mbind 5 7990 NULL
94703 +tt3650_ci_msg_locked_8013 tt3650_ci_msg_locked 4 8013 NULL
94704 +vcs_read_8017 vcs_read 3 8017 NULL
94705 +normalize_up_8037 normalize_up 0-1-2 8037 NULL
94706 +vhost_add_used_and_signal_n_8038 vhost_add_used_and_signal_n 4 8038 NULL
94707 +ms_read_multiple_pages_8052 ms_read_multiple_pages 5-4 8052 NULL
94708 +dgrp_mon_read_8065 dgrp_mon_read 3 8065 NULL
94709 +leb_read_lock_8070 leb_read_lock 0 8070 NULL
94710 +alloc_targets_8074 alloc_targets 2 8074 NULL nohasharray
94711 +qla4xxx_post_ping_evt_work_8074 qla4xxx_post_ping_evt_work 4 8074 &alloc_targets_8074
94712 +venus_lookup_8121 venus_lookup 4 8121 NULL
94713 +lm3533_als_set_threshold_8125 lm3533_als_set_threshold 2 8125 NULL
94714 +ieee80211_if_fmt_num_buffered_multicast_8127 ieee80211_if_fmt_num_buffered_multicast 3 8127 NULL
94715 +ext_sd_execute_write_data_8175 ext_sd_execute_write_data 9 8175 NULL
94716 +dma_map_area_8178 dma_map_area 5-2-3 8178 NULL
94717 +__sk_mem_schedule_8185 __sk_mem_schedule 2 8185 NULL
94718 +ieee80211_if_fmt_dot11MeshHoldingTimeout_8187 ieee80211_if_fmt_dot11MeshHoldingTimeout 3 8187 NULL
94719 +recent_mt_proc_write_8206 recent_mt_proc_write 3 8206 NULL
94720 +rt2x00debug_write_bbp_8212 rt2x00debug_write_bbp 3 8212 NULL
94721 +ad7879_spi_multi_read_8218 ad7879_spi_multi_read 3 8218 NULL
94722 +play_iframe_8219 play_iframe 3 8219 NULL
94723 +create_log_8225 create_log 2 8225 NULL nohasharray
94724 +kvm_mmu_page_set_gfn_8225 kvm_mmu_page_set_gfn 2 8225 &create_log_8225
94725 +sctp_ssnmap_size_8228 sctp_ssnmap_size 0-1-2 8228 NULL
94726 +check_xattr_ref_inode_8244 check_xattr_ref_inode 0 8244 NULL
94727 +add_rx_skb_8257 add_rx_skb 3 8257 NULL
94728 +t3_init_l2t_8261 t3_init_l2t 1 8261 NULL
94729 +init_cdev_8274 init_cdev 1 8274 NULL
94730 +rproc_recovery_write_8281 rproc_recovery_write 3 8281 NULL
94731 +qib_decode_7220_err_8315 qib_decode_7220_err 3 8315 NULL
94732 +snd_pcm_update_state_8320 snd_pcm_update_state 0 8320 NULL
94733 +lm3533_led_get_pattern_8321 lm3533_led_get_pattern 0 8321 NULL nohasharray
94734 +construct_key_and_link_8321 construct_key_and_link 4 8321 &lm3533_led_get_pattern_8321
94735 +ipwireless_send_packet_8328 ipwireless_send_packet 4 8328 NULL
94736 +tracing_entries_read_8345 tracing_entries_read 3 8345 NULL
94737 +ieee80211_if_fmt_ht_opmode_8347 ieee80211_if_fmt_ht_opmode 3 8347 NULL
94738 +ping_getfrag_8360 ping_getfrag 4-3 8360 NULL
94739 +uvc_v4l2_compat_ioctl32_8375 uvc_v4l2_compat_ioctl32 3 8375 NULL
94740 +xdi_copy_from_user_8395 xdi_copy_from_user 4 8395 NULL
94741 +zd_rf_scnprint_id_8406 zd_rf_scnprint_id 0-3 8406 NULL
94742 +uvc_v4l2_ioctl_8411 uvc_v4l2_ioctl 2 8411 NULL
94743 +snd_usb_ctl_msg_8436 snd_usb_ctl_msg 8 8436 NULL
94744 +irq_create_mapping_8437 irq_create_mapping 2 8437 NULL
94745 +afs_cell_lookup_8482 afs_cell_lookup 2 8482 NULL
94746 +_irq_to_enable_addr_8485 _irq_to_enable_addr 0-1 8485 NULL
94747 +batadv_tt_len_8502 batadv_tt_len 0-1 8502 NULL
94748 +dev_config_8506 dev_config 3 8506 NULL
94749 +ACL_to_cifs_posix_8509 ACL_to_cifs_posix 3 8509 NULL
94750 +utf16_strnlen_8513 utf16_strnlen 0 8513 NULL
94751 +opticon_process_data_packet_8524 opticon_process_data_packet 3 8524 NULL
94752 +pnp_resource_len_8532 pnp_resource_len 0 8532 NULL
94753 +alloc_pg_vec_8533 alloc_pg_vec 2 8533 NULL
94754 +ocfs2_read_virt_blocks_8538 ocfs2_read_virt_blocks 2-3 8538 NULL
94755 +profile_remove_8556 profile_remove 3 8556 NULL
94756 +cache_slow_downcall_8570 cache_slow_downcall 2 8570 NULL
94757 +mga_ioremap_8571 mga_ioremap 1-2 8571 NULL
94758 +isr_dma0_done_read_8574 isr_dma0_done_read 3 8574 NULL
94759 +tower_write_8580 tower_write 3 8580 NULL
94760 +rtllib_MFIE_rate_len_8606 rtllib_MFIE_rate_len 0 8606 NULL
94761 +shash_setkey_unaligned_8620 shash_setkey_unaligned 3 8620 NULL
94762 +it821x_firmware_command_8628 it821x_firmware_command 3 8628 NULL
94763 +scsi_dma_map_8632 scsi_dma_map 0 8632 NULL
94764 +fuse_send_write_pages_8636 fuse_send_write_pages 0 8636 NULL
94765 +generic_acl_set_8658 generic_acl_set 4 8658 NULL
94766 +dio_bio_alloc_8677 dio_bio_alloc 5 8677 NULL
94767 +lbs_bcnmiss_read_8678 lbs_bcnmiss_read 3 8678 NULL
94768 +tc3589x_gpio_irq_unmap_8680 tc3589x_gpio_irq_unmap 2 8680 NULL
94769 +rproc_trace_read_8686 rproc_trace_read 3 8686 NULL
94770 +skb_frag_size_8695 skb_frag_size 0 8695 NULL
94771 +arcfb_write_8702 arcfb_write 3 8702 NULL
94772 +i_size_read_8703 i_size_read 0 8703 NULL nohasharray
94773 +init_header_8703 init_header 0 8703 &i_size_read_8703
94774 +ctrl_out_8712 ctrl_out 3-5 8712 NULL
94775 +jffs2_acl_count_8729 jffs2_acl_count 0-1 8729 NULL nohasharray
94776 +snapshot_status_8729 snapshot_status 5 8729 &jffs2_acl_count_8729
94777 +f_dupfd_8730 f_dupfd 1 8730 NULL
94778 +tx_tx_exch_expiry_read_8749 tx_tx_exch_expiry_read 3 8749 NULL
94779 +joydev_compat_ioctl_8765 joydev_compat_ioctl 2 8765 NULL
94780 +sys_prctl_8766 sys_prctl 4 8766 NULL
94781 +x32_arch_ptrace_8767 x32_arch_ptrace 3-4 8767 NULL
94782 +paging32_prefetch_gpte_8783 paging32_prefetch_gpte 4 8783 NULL
94783 +ext4_try_to_write_inline_data_8785 ext4_try_to_write_inline_data 3-4 8785 NULL
94784 +__bitmap_weight_8796 __bitmap_weight 0-2 8796 NULL
94785 +cpuset_common_file_read_8800 cpuset_common_file_read 5 8800 NULL
94786 +metronomefb_write_8823 metronomefb_write 3 8823 NULL
94787 +icmpv6_manip_pkt_8833 icmpv6_manip_pkt 4 8833 NULL nohasharray
94788 +get_queue_depth_8833 get_queue_depth 0 8833 &icmpv6_manip_pkt_8833
94789 +dvb_ringbuffer_pkt_next_8834 dvb_ringbuffer_pkt_next 0-2 8834 NULL
94790 +usb_ep_queue_8839 usb_ep_queue 0 8839 NULL
94791 +debug_debug1_read_8856 debug_debug1_read 3 8856 NULL
94792 +wa_nep_queue_8858 wa_nep_queue 2 8858 NULL
94793 +send_pages_8872 send_pages 3 8872 NULL
94794 +compressed_bio_size_8887 compressed_bio_size 0-2 8887 NULL
94795 +tracing_max_lat_read_8890 tracing_max_lat_read 3 8890 NULL
94796 +sdio_max_byte_size_8907 sdio_max_byte_size 0 8907 NULL
94797 +layout_commit_8926 layout_commit 3 8926 NULL
94798 +adjust_priv_size_8935 adjust_priv_size 0-1 8935 NULL
94799 +driver_stats_read_8944 driver_stats_read 3 8944 NULL
94800 +read_file_tgt_stats_8959 read_file_tgt_stats 3 8959 NULL
94801 +seq_bitmap_list_8963 seq_bitmap_list 3 8963 NULL
94802 +usb_allocate_stream_buffers_8964 usb_allocate_stream_buffers 3 8964 NULL
94803 +qib_qsfp_dump_8966 qib_qsfp_dump 0-3 8966 NULL
94804 +venus_mkdir_8967 venus_mkdir 4 8967 NULL
94805 +seq_open_net_8968 seq_open_net 4 8968 NULL nohasharray
94806 +vol_cdev_read_8968 vol_cdev_read 3 8968 &seq_open_net_8968
94807 +bio_integrity_get_tag_8974 bio_integrity_get_tag 3 8974 NULL
94808 +btrfs_alloc_free_block_8986 btrfs_alloc_free_block 3 8986 NULL
94809 +palmas_ldo_write_9012 palmas_ldo_write 2 9012 NULL
94810 +snd_emu10k1_ptr_read_9026 snd_emu10k1_ptr_read 0-2 9026 NULL
94811 +__pskb_copy_9038 __pskb_copy 2 9038 NULL
94812 +nla_put_9042 nla_put 3 9042 NULL
94813 +snd_emu10k1_synth_copy_from_user_9061 snd_emu10k1_synth_copy_from_user 3-5 9061 NULL
94814 +snd_gus_dram_peek_9062 snd_gus_dram_peek 4 9062 NULL
94815 +fib_info_hash_alloc_9075 fib_info_hash_alloc 1 9075 NULL
94816 +string_9080 string 0 9080 NULL
94817 +create_queues_9088 create_queues 2-3 9088 NULL
94818 +ftdi_prepare_write_buffer_9093 ftdi_prepare_write_buffer 3 9093 NULL
94819 +caif_stream_sendmsg_9110 caif_stream_sendmsg 4 9110 NULL nohasharray
94820 +gfn_to_rmap_9110 gfn_to_rmap 2-3 9110 &caif_stream_sendmsg_9110
94821 +pmcraid_change_queue_depth_9116 pmcraid_change_queue_depth 2 9116 NULL
94822 +ext4_list_backups_9138 ext4_list_backups 0 9138 NULL
94823 +dbg_command_buf_9165 dbg_command_buf 2 9165 NULL
94824 +isr_irqs_read_9181 isr_irqs_read 3 9181 NULL
94825 +count_leading_zeros_9183 count_leading_zeros 0 9183 NULL
94826 +alloc_group_attrs_9194 alloc_group_attrs 2 9194 NULL nohasharray
94827 +altera_swap_ir_9194 altera_swap_ir 2 9194 &alloc_group_attrs_9194
94828 +gx1_gx_base_9198 gx1_gx_base 0 9198 NULL
94829 +snd_m3_get_pointer_9206 snd_m3_get_pointer 0 9206 NULL
94830 +tx_tx_prepared_descs_read_9221 tx_tx_prepared_descs_read 3 9221 NULL
94831 +sctp_getsockopt_delayed_ack_9232 sctp_getsockopt_delayed_ack 2 9232 NULL
94832 +ocfs2_clear_ext_refcount_9256 ocfs2_clear_ext_refcount 4 9256 NULL
94833 +tcf_csum_ipv4_icmp_9258 tcf_csum_ipv4_icmp 3 9258 NULL
94834 +sparse_early_usemaps_alloc_node_9269 sparse_early_usemaps_alloc_node 4 9269 NULL
94835 +hdpvr_read_9273 hdpvr_read 3 9273 NULL
94836 +qla82xx_pci_set_window_9303 qla82xx_pci_set_window 0-2 9303 NULL
94837 +iwl_dbgfs_stations_read_9309 iwl_dbgfs_stations_read 3 9309 NULL
94838 +ceph_sync_setxattr_9310 ceph_sync_setxattr 4 9310 NULL
94839 +ieee80211_if_fmt_txpower_9334 ieee80211_if_fmt_txpower 3 9334 NULL
94840 +ocfs2_orphan_for_truncate_9342 ocfs2_orphan_for_truncate 4 9342 NULL
94841 +read_9397 read 3 9397 NULL
94842 +nf_nat_sip_expect_9418 nf_nat_sip_expect 8 9418 NULL
94843 +cfg80211_report_obss_beacon_9422 cfg80211_report_obss_beacon 3 9422 NULL
94844 +bm_realloc_pages_9431 bm_realloc_pages 2 9431 NULL
94845 +ffs_ep0_write_9438 ffs_ep0_write 3 9438 NULL
94846 +kmalloc_array_9444 kmalloc_array 1-2 9444 NULL
94847 +ieee80211_if_fmt_fwded_unicast_9454 ieee80211_if_fmt_fwded_unicast 3 9454 NULL
94848 +mcs_unwrap_mir_9455 mcs_unwrap_mir 3 9455 NULL
94849 +ext3_xattr_set_acl_9467 ext3_xattr_set_acl 4 9467 NULL
94850 +agp_generic_alloc_user_9470 agp_generic_alloc_user 1 9470 NULL
94851 +rbd_coll_end_req_9472 rbd_coll_end_req 3 9472 NULL
94852 +__alloc_preds_9492 __alloc_preds 2 9492 NULL
94853 +lp_write_9511 lp_write 3 9511 NULL
94854 +scsi_tgt_kspace_exec_9522 scsi_tgt_kspace_exec 8 9522 NULL
94855 +lm3533_update_9529 lm3533_update 2 9529 NULL
94856 +read_file_dma_9530 read_file_dma 3 9530 NULL
94857 +ext3_alloc_branch_9534 ext3_alloc_branch 5 9534 NULL
94858 +tps65910_gpio_output_9539 tps65910_gpio_output 2 9539 NULL
94859 +audit_log_n_untrustedstring_9548 audit_log_n_untrustedstring 3 9548 NULL
94860 +readl_9557 readl 0 9557 NULL
94861 +fw_node_create_9559 fw_node_create 2 9559 NULL
94862 +kobj_map_9566 kobj_map 2-3 9566 NULL
94863 +f2fs_read_data_pages_9574 f2fs_read_data_pages 4 9574 NULL
94864 +biovec_create_pools_9575 biovec_create_pools 2 9575 NULL
94865 +ieee80211_tdls_mgmt_9581 ieee80211_tdls_mgmt 8 9581 NULL
94866 +do_sync_9604 do_sync 1 9604 NULL
94867 +snd_emu10k1_fx8010_read_9605 snd_emu10k1_fx8010_read 5-6 9605 NULL
94868 +saa7164_buffer_alloc_user_9627 saa7164_buffer_alloc_user 2 9627 NULL
94869 +compat_sys_keyctl_9639 compat_sys_keyctl 4-2-3 9639 NULL
94870 +ocfs2_xattr_get_rec_9652 ocfs2_xattr_get_rec 0 9652 NULL
94871 +uvc_alloc_buffers_9656 uvc_alloc_buffers 2-3 9656 NULL
94872 +queue_received_packet_9657 queue_received_packet 5 9657 NULL
94873 +snd_opl4_mem_proc_write_9670 snd_opl4_mem_proc_write 5 9670 NULL
94874 +ks8842_read16_9676 ks8842_read16 0 9676 NULL nohasharray
94875 +dns_query_9676 dns_query 3 9676 &ks8842_read16_9676
94876 +qib_7322_handle_hwerrors_9678 qib_7322_handle_hwerrors 3 9678 NULL
94877 +__erst_read_from_storage_9690 __erst_read_from_storage 0 9690 NULL
94878 +is_hole_9694 is_hole 2 9694 NULL nohasharray
94879 +x25_asy_compat_ioctl_9694 x25_asy_compat_ioctl 4 9694 &is_hole_9694
94880 +fnb_9703 fnb 2-3 9703 NULL
94881 +ieee80211_if_read_aid_9705 ieee80211_if_read_aid 3 9705 NULL
94882 +ieee80211_if_fmt_num_mcast_sta_9738 ieee80211_if_fmt_num_mcast_sta 3 9738 NULL
94883 +ddb_input_read_9743 ddb_input_read 3 9743 NULL
94884 +sta_last_ack_signal_read_9751 sta_last_ack_signal_read 3 9751 NULL
94885 +btrfs_super_root_9763 btrfs_super_root 0 9763 NULL
94886 +__alloc_percpu_9764 __alloc_percpu 1-2 9764 NULL
94887 +do_sigpending_9766 do_sigpending 2 9766 NULL
94888 +__blk_queue_init_tags_9778 __blk_queue_init_tags 2 9778 NULL
94889 +snd_mem_proc_write_9786 snd_mem_proc_write 3 9786 NULL
94890 +_regmap_write_9803 _regmap_write 2 9803 NULL
94891 +ttm_bo_fbdev_io_9805 ttm_bo_fbdev_io 4 9805 NULL
94892 +ieee80211_if_read_state_9813 ieee80211_if_read_state 3 9813 NULL
94893 +pnp_mem_start_9817 pnp_mem_start 0 9817 NULL
94894 +kernel_physical_mapping_init_9818 kernel_physical_mapping_init 0-2-1 9818 NULL
94895 +dvb_dvr_set_buffer_size_9840 dvb_dvr_set_buffer_size 2 9840 NULL
94896 +cfg80211_send_deauth_9862 cfg80211_send_deauth 3 9862 NULL
94897 +pmcraid_alloc_sglist_9864 pmcraid_alloc_sglist 1 9864 NULL
94898 +btrfs_free_reserved_extent_9867 btrfs_free_reserved_extent 2 9867 NULL
94899 +f1x_translate_sysaddr_to_cs_9868 f1x_translate_sysaddr_to_cs 2 9868 NULL
94900 +mlx4_bitmap_alloc_range_9876 mlx4_bitmap_alloc_range 2-3 9876 NULL
94901 +wil_read_file_ioblob_9878 wil_read_file_ioblob 3 9878 NULL
94902 +bm_register_write_9893 bm_register_write 3 9893 NULL nohasharray
94903 +snd_midi_event_new_9893 snd_midi_event_new 1 9893 &bm_register_write_9893
94904 +snd_gf1_pcm_playback_copy_9895 snd_gf1_pcm_playback_copy 3-5 9895 NULL
94905 +receive_DataRequest_9904 receive_DataRequest 3 9904 NULL
94906 +nonpaging_page_fault_9908 nonpaging_page_fault 2 9908 NULL
94907 +pstore_ftrace_knob_read_9947 pstore_ftrace_knob_read 3 9947 NULL
94908 +read_file_misc_9948 read_file_misc 3 9948 NULL
94909 +set_rxd_buffer_pointer_9950 set_rxd_buffer_pointer 8 9950 NULL
94910 +ext2_new_blocks_9954 ext2_new_blocks 2 9954 NULL
94911 +csum_partial_copy_fromiovecend_9957 csum_partial_copy_fromiovecend 3-4 9957 NULL
94912 +get_free_serial_index_9969 get_free_serial_index 0 9969 NULL
94913 +btrfs_add_link_9973 btrfs_add_link 5 9973 NULL
94914 +ath6kl_usb_submit_ctrl_out_9978 ath6kl_usb_submit_ctrl_out 6 9978 NULL
94915 +twl6040_clear_bits_9985 twl6040_clear_bits 2 9985 NULL
94916 +aat2870_dump_reg_10019 aat2870_dump_reg 0 10019 NULL
94917 +handle_request_10024 handle_request 9 10024 NULL
94918 +batadv_orig_hash_add_if_10033 batadv_orig_hash_add_if 2 10033 NULL
94919 +ieee80211_probereq_get_10040 ieee80211_probereq_get 4-5 10040 NULL
94920 +rbd_coll_end_req_index_10041 rbd_coll_end_req_index 5 10041 NULL
94921 +ieee80211_set_probe_resp_10077 ieee80211_set_probe_resp 3 10077 NULL
94922 +wm831x_gpio_direction_in_10099 wm831x_gpio_direction_in 2 10099 NULL
94923 +ufs_bitmap_search_10105 ufs_bitmap_search 0-3 10105 NULL
94924 +get_elem_size_10110 get_elem_size 0-2 10110 NULL nohasharray
94925 +dynamic_ps_timeout_read_10110 dynamic_ps_timeout_read 3 10110 &get_elem_size_10110
94926 +gfs2_meta_read_10112 gfs2_meta_read 0 10112 NULL
94927 +offset_to_bit_10134 offset_to_bit 0 10134 NULL
94928 +aes_decrypt_packets_read_10155 aes_decrypt_packets_read 3 10155 NULL
94929 +rx_out_of_mem_read_10157 rx_out_of_mem_read 3 10157 NULL
94930 +hidg_alloc_ep_req_10159 hidg_alloc_ep_req 2 10159 NULL nohasharray
94931 +ol_chunk_entries_10159 ol_chunk_entries 0 10159 &hidg_alloc_ep_req_10159
94932 +stmpe_irq_unmap_10164 stmpe_irq_unmap 2 10164 NULL
94933 +asd_store_update_bios_10165 asd_store_update_bios 4 10165 NULL
94934 +proc_pid_attr_read_10173 proc_pid_attr_read 3 10173 NULL
94935 +jffs2_user_setxattr_10182 jffs2_user_setxattr 4 10182 NULL
94936 +do_ioctl_trans_10194 do_ioctl_trans 3 10194 NULL
94937 +cciss_proc_write_10259 cciss_proc_write 3 10259 NULL
94938 +snd_rme9652_capture_copy_10287 snd_rme9652_capture_copy 5 10287 NULL
94939 +ubi_leb_change_10289 ubi_leb_change 4 10289 NULL
94940 +lm3533_led_delay_set_10291 lm3533_led_delay_set 2 10291 NULL
94941 +read_emulate_10310 read_emulate 2-4 10310 NULL
94942 +ttm_object_device_init_10321 ttm_object_device_init 2 10321 NULL
94943 +ubi_leb_read_10328 ubi_leb_read 0 10328 NULL
94944 +tun_sendmsg_10337 tun_sendmsg 4 10337 NULL
94945 +ufx_alloc_urb_list_10349 ufx_alloc_urb_list 3 10349 NULL
94946 +dbAllocAny_10354 dbAllocAny 0 10354 NULL
94947 +ath6kl_listen_int_read_10355 ath6kl_listen_int_read 3 10355 NULL
94948 +ms_write_multiple_pages_10362 ms_write_multiple_pages 6-5 10362 NULL
94949 +sta_ht_capa_read_10366 sta_ht_capa_read 3 10366 NULL
94950 +ecryptfs_decode_and_decrypt_filename_10379 ecryptfs_decode_and_decrypt_filename 5 10379 NULL
94951 +do_compat_pselect_10398 do_compat_pselect 1 10398 NULL
94952 +fwtty_rx_10434 fwtty_rx 3 10434 NULL
94953 +event_phy_transmit_error_read_10471 event_phy_transmit_error_read 3 10471 NULL
94954 +ca91cx42_alloc_resource_10502 ca91cx42_alloc_resource 2 10502 NULL
94955 +qib_alloc_fast_reg_page_list_10507 qib_alloc_fast_reg_page_list 2 10507 NULL
94956 +sel_write_disable_10511 sel_write_disable 3 10511 NULL
94957 +osd_req_write_sg_kern_10514 osd_req_write_sg_kern 5 10514 NULL
94958 +rds_message_alloc_10517 rds_message_alloc 1 10517 NULL
94959 +snd_pcm_hw_params_user_10520 snd_pcm_hw_params_user 0 10520 NULL
94960 +ocfs2_add_refcounted_extent_10526 ocfs2_add_refcounted_extent 6 10526 NULL
94961 +get_vm_area_caller_10527 get_vm_area_caller 1 10527 NULL
94962 +snd_pcm_lib_read_10536 snd_pcm_lib_read 0-3 10536 NULL
94963 +ext4_write_begin_10576 ext4_write_begin 3-4 10576 NULL
94964 +scrub_remap_extent_10588 scrub_remap_extent 2 10588 NULL
94965 +otp_read_10594 otp_read 2-4-5 10594 NULL
94966 +supply_map_read_file_10608 supply_map_read_file 3 10608 NULL
94967 +mc13783_set_fmt_10616 mc13783_set_fmt 3 10616 NULL
94968 +ima_show_htable_violations_10619 ima_show_htable_violations 3 10619 NULL
94969 +alloc_coherent_10632 alloc_coherent 2 10632 NULL
94970 +nfs_idmap_lookup_id_10660 nfs_idmap_lookup_id 2 10660 NULL
94971 +parport_write_10669 parport_write 0 10669 NULL
94972 +inl_10708 inl 0 10708 NULL nohasharray
94973 +selinux_inode_setxattr_10708 selinux_inode_setxattr 4 10708 &inl_10708
94974 +pvr2_ioread_read_10720 pvr2_ioread_read 3 10720 NULL nohasharray
94975 +shash_async_setkey_10720 shash_async_setkey 3 10720 &pvr2_ioread_read_10720
94976 +spi_sync_10731 spi_sync 0 10731 NULL
94977 +sctp_getsockopt_maxseg_10737 sctp_getsockopt_maxseg 2 10737 NULL nohasharray
94978 +apu_get_register_10737 apu_get_register 0 10737 &sctp_getsockopt_maxseg_10737
94979 +compat_sys_msgsnd_10738 compat_sys_msgsnd 2 10738 NULL
94980 +sys_syslog_10746 sys_syslog 3 10746 NULL
94981 +alloc_one_pg_vec_page_10747 alloc_one_pg_vec_page 1 10747 NULL
94982 +vhost_add_used_n_10760 vhost_add_used_n 3 10760 NULL
94983 +kvm_read_guest_atomic_10765 kvm_read_guest_atomic 4 10765 NULL
94984 +sys_bind_10799 sys_bind 3 10799 NULL
94985 +compat_put_int_10828 compat_put_int 1 10828 NULL
94986 +lbs_sleepparams_read_10840 lbs_sleepparams_read 3 10840 NULL
94987 +ida_get_new_above_10853 ida_get_new_above 2 10853 NULL
94988 +fuse_conn_max_background_read_10855 fuse_conn_max_background_read 3 10855 NULL
94989 +ol_chunk_blocks_10864 ol_chunk_blocks 0 10864 NULL
94990 +batadv_check_unicast_packet_10866 batadv_check_unicast_packet 2 10866 NULL
94991 +snd_pcm_oss_write1_10872 snd_pcm_oss_write1 3 10872 NULL
94992 +mid_get_vbt_data_r0_10876 mid_get_vbt_data_r0 2 10876 NULL
94993 +bl_mark_for_commit_10879 bl_mark_for_commit 2-3 10879 NULL
94994 +get_scq_10897 get_scq 2 10897 NULL
94995 +cgroup_write_string_10900 cgroup_write_string 5 10900 NULL
94996 +tifm_alloc_adapter_10903 tifm_alloc_adapter 1 10903 NULL
94997 +__copy_from_user_10918 __copy_from_user 3 10918 NULL
94998 +da9052_map_irq_10952 da9052_map_irq 2 10952 NULL
94999 +bm_entry_read_10976 bm_entry_read 3 10976 NULL
95000 +i915_min_freq_write_10981 i915_min_freq_write 3 10981 NULL
95001 +sched_autogroup_write_10984 sched_autogroup_write 3 10984 NULL
95002 +__hci_num_ctrl_10985 __hci_num_ctrl 0 10985 NULL
95003 +xfrm_hash_alloc_10997 xfrm_hash_alloc 1 10997 NULL
95004 +rx_filter_accum_arp_pend_requests_read_11003 rx_filter_accum_arp_pend_requests_read 3 11003 NULL
95005 +SetLineNumber_11023 SetLineNumber 0 11023 NULL
95006 +mb_find_next_bit_11037 mb_find_next_bit 2-3-0 11037 NULL
95007 +nouveau_gpio_create__11048 nouveau_gpio_create_ 4 11048 NULL
95008 +tda10048_writeregbulk_11050 tda10048_writeregbulk 4 11050 NULL
95009 +carl9170_handle_mpdu_11056 carl9170_handle_mpdu 3 11056 NULL
95010 +tcp_send_mss_11079 tcp_send_mss 0 11079 NULL
95011 +snd_pcm_delay_11081 snd_pcm_delay 0 11081 NULL
95012 +count_argc_11083 count_argc 0 11083 NULL
95013 +kvm_write_guest_cached_11106 kvm_write_guest_cached 4 11106 NULL
95014 +stmpe_gpio_to_irq_11110 stmpe_gpio_to_irq 2 11110 NULL
95015 +tw_change_queue_depth_11116 tw_change_queue_depth 2 11116 NULL
95016 +page_offset_11120 page_offset 0 11120 NULL
95017 +tracing_buffers_read_11124 tracing_buffers_read 3 11124 NULL
95018 +alloc_alien_cache_11127 alloc_alien_cache 2 11127 NULL
95019 +acpi_os_map_memory_11161 acpi_os_map_memory 1-2 11161 NULL
95020 +ioat2_alloc_ring_11172 ioat2_alloc_ring 2 11172 NULL nohasharray
95021 +snd_gf1_pcm_playback_silence_11172 snd_gf1_pcm_playback_silence 3-4 11172 &ioat2_alloc_ring_11172
95022 +__swab16p_11220 __swab16p 0 11220 NULL
95023 +il_dbgfs_rx_queue_read_11221 il_dbgfs_rx_queue_read 3 11221 NULL
95024 +of_irq_count_11253 of_irq_count 0 11253 NULL
95025 +ubifs_write_node_11258 ubifs_write_node 5-3 11258 NULL
95026 +hugetlbfs_read_11268 hugetlbfs_read 3 11268 NULL
95027 +cru_detect_11272 cru_detect 1 11272 NULL
95028 +ext4_xattr_check_names_11314 ext4_xattr_check_names 0 11314 NULL
95029 +tcp_send_rcvq_11316 tcp_send_rcvq 3 11316 NULL
95030 +construct_key_11329 construct_key 3 11329 NULL nohasharray
95031 +__kfifo_out_peek_11329 __kfifo_out_peek 0-3 11329 &construct_key_11329
95032 +next_segment_11330 next_segment 0-2-1 11330 NULL
95033 +persistent_ram_buffer_map_11332 persistent_ram_buffer_map 1-2 11332 NULL
95034 +ext4_get_inline_size_11349 ext4_get_inline_size 0 11349 NULL
95035 +i915_max_freq_write_11350 i915_max_freq_write 3 11350 NULL
95036 +sel_write_create_11353 sel_write_create 3 11353 NULL
95037 +handle_unit_11355 handle_unit 0-1 11355 NULL
95038 +batadv_skb_head_push_11360 batadv_skb_head_push 2 11360 NULL
95039 +drm_vblank_init_11362 drm_vblank_init 2 11362 NULL
95040 +qib_get_base_info_11369 qib_get_base_info 3 11369 NULL
95041 +dev_irnet_write_11398 dev_irnet_write 3 11398 NULL
95042 +___alloc_bootmem_11410 ___alloc_bootmem 1 11410 NULL
95043 +str_to_user_11411 str_to_user 2 11411 NULL
95044 +mem_fw_gen_free_mem_blks_read_11413 mem_fw_gen_free_mem_blks_read 3 11413 NULL
95045 +ath6kl_wmi_test_rx_11414 ath6kl_wmi_test_rx 3 11414 NULL
95046 +adis16480_show_firmware_revision_11417 adis16480_show_firmware_revision 3 11417 NULL
95047 +trace_options_read_11419 trace_options_read 3 11419 NULL
95048 +xd_read_multiple_pages_11422 xd_read_multiple_pages 5-4 11422 NULL
95049 +prepare_image_11424 prepare_image 0 11424 NULL
95050 +vring_size_11426 vring_size 0-1-2 11426 NULL
95051 +bttv_read_11432 bttv_read 3 11432 NULL
95052 +create_zero_mask_11453 create_zero_mask 0-1 11453 NULL
95053 +swp_offset_11475 swp_offset 0 11475 NULL
95054 +sca3000_read_first_n_hw_rb_11479 sca3000_read_first_n_hw_rb 2 11479 NULL
95055 +xfs_file_buffered_aio_write_11492 xfs_file_buffered_aio_write 4 11492 NULL
95056 +sd_do_mode_sense_11507 sd_do_mode_sense 5 11507 NULL
95057 +kmem_zalloc_11510 kmem_zalloc 1 11510 NULL
95058 +twl_direction_in_11527 twl_direction_in 2 11527 NULL
95059 +setup_IO_APIC_irq_extra_11537 setup_IO_APIC_irq_extra 1 11537 NULL
95060 +skb_cow_data_11565 skb_cow_data 0-2 11565 NULL
95061 +mlx4_init_cmpt_table_11569 mlx4_init_cmpt_table 3 11569 NULL
95062 +oprofilefs_ulong_to_user_11582 oprofilefs_ulong_to_user 3 11582 NULL
95063 +snd_pcm_action_11589 snd_pcm_action 0 11589 NULL
95064 +fw_device_op_ioctl_11595 fw_device_op_ioctl 2 11595 NULL
95065 +sisusb_send_bridge_packet_11649 sisusb_send_bridge_packet 2 11649 NULL
95066 +nla_total_size_11658 nla_total_size 0-1 11658 NULL
95067 +ide_queue_pc_tail_11673 ide_queue_pc_tail 5 11673 NULL
95068 +btrfs_alloc_delayed_item_11678 btrfs_alloc_delayed_item 1 11678 NULL
95069 +da9055_gpio_direction_output_11680 da9055_gpio_direction_output 2 11680 NULL
95070 +dsp_buffer_alloc_11684 dsp_buffer_alloc 2 11684 NULL
95071 +sctp_setsockopt_hmac_ident_11687 sctp_setsockopt_hmac_ident 3 11687 NULL
95072 +split_11691 split 2 11691 NULL
95073 +snd_ctl_elem_user_tlv_11695 snd_ctl_elem_user_tlv 3 11695 NULL
95074 +blk_rq_cur_bytes_11723 blk_rq_cur_bytes 0 11723 NULL
95075 +tcf_csum_ipv6_icmp_11738 tcf_csum_ipv6_icmp 4 11738 NULL
95076 +nfsd4_get_drc_mem_11748 nfsd4_get_drc_mem 0-1-2 11748 NULL
95077 +dm_bio_prison_create_11749 dm_bio_prison_create 1 11749 NULL
95078 +iwl_dbgfs_qos_read_11753 iwl_dbgfs_qos_read 3 11753 NULL
95079 +ps_pspoll_timeouts_read_11776 ps_pspoll_timeouts_read 3 11776 NULL
95080 +ebt_buf_add_11779 ebt_buf_add 0 11779 NULL
95081 +btrfs_key_blockptr_11786 btrfs_key_blockptr 0 11786 NULL
95082 +pcpu_fc_alloc_11818 pcpu_fc_alloc 2 11818 NULL
95083 +zerocopy_sg_from_iovec_11828 zerocopy_sg_from_iovec 3 11828 NULL
95084 +sctp_setsockopt_maxseg_11829 sctp_setsockopt_maxseg 3 11829 NULL
95085 +rts51x_read_status_11830 rts51x_read_status 4 11830 NULL
95086 +unix_stream_connect_11844 unix_stream_connect 3 11844 NULL
95087 +nf_nat_sdp_media_11863 nf_nat_sdp_media 9 11863 NULL
95088 +ecryptfs_copy_filename_11868 ecryptfs_copy_filename 4 11868 NULL
95089 +kmalloc_slab_11917 kmalloc_slab 1 11917 NULL
95090 +fs_devrw_entry_11924 fs_devrw_entry 3 11924 NULL
95091 +bitmap_remap_11929 bitmap_remap 5 11929 NULL
95092 +atomic_sub_return_11939 atomic_sub_return 0-1 11939 NULL
95093 +dccp_feat_clone_sp_val_11942 dccp_feat_clone_sp_val 3 11942 NULL
95094 +kvm_set_msr_common_11953 kvm_set_msr_common 3 11953 NULL
95095 +f1x_swap_interleaved_region_11970 f1x_swap_interleaved_region 0-2 11970 NULL
95096 +atmel_read16_11981 atmel_read16 0 11981 NULL
95097 +read_and_add_raw_conns_11987 read_and_add_raw_conns 0 11987 NULL
95098 +mwifiex_cfg80211_mgmt_tx_12022 mwifiex_cfg80211_mgmt_tx 9 12022 NULL
95099 +ftdi_elan_total_command_size_12045 ftdi_elan_total_command_size 0 12045 NULL
95100 +ieee80211_if_read_user_power_level_12050 ieee80211_if_read_user_power_level 3 12050 NULL
95101 +il4965_ucode_tx_stats_read_12064 il4965_ucode_tx_stats_read 3 12064 NULL
95102 +ptc_proc_write_12076 ptc_proc_write 3 12076 NULL
95103 +ubifs_recover_log_leb_12079 ubifs_recover_log_leb 3 12079 NULL
95104 +da9052_gpio_direction_output_12120 da9052_gpio_direction_output 2 12120 NULL
95105 +alloc_bulk_urbs_generic_12127 alloc_bulk_urbs_generic 5 12127 NULL
95106 +set_powered_12129 set_powered 4 12129 NULL
95107 +nfs_writedata_alloc_12133 nfs_writedata_alloc 2 12133 NULL
95108 +ramoops_init_prz_12134 ramoops_init_prz 5 12134 NULL
95109 +xfs_handle_to_dentry_12135 xfs_handle_to_dentry 3 12135 NULL
95110 +batadv_add_packet_12136 batadv_add_packet 3 12136 NULL
95111 +rawv6_seticmpfilter_12137 rawv6_seticmpfilter 5 12137 NULL
95112 +vmw_fifo_reserve_12141 vmw_fifo_reserve 2 12141 NULL
95113 +get_idx_gc_leb_12148 get_idx_gc_leb 0 12148 NULL
95114 +btmrvl_sdio_host_to_card_12152 btmrvl_sdio_host_to_card 3 12152 NULL
95115 +vmbus_open_12154 vmbus_open 2-3 12154 NULL
95116 +wil_rxdesc_phy_length_12165 wil_rxdesc_phy_length 0 12165 NULL
95117 +dma_memcpy_to_iovec_12173 dma_memcpy_to_iovec 5 12173 NULL
95118 +ddp_make_gl_12179 ddp_make_gl 1 12179 NULL
95119 +compat_do_arpt_set_ctl_12184 compat_do_arpt_set_ctl 4 12184 NULL
95120 +ip_generic_getfrag_12187 ip_generic_getfrag 3-4 12187 NULL
95121 +bl_is_sector_init_12199 bl_is_sector_init 2 12199 NULL
95122 +receive_copy_12216 receive_copy 3 12216 NULL
95123 +snd_pcm_kernel_ioctl_12219 snd_pcm_kernel_ioctl 0 12219 NULL
95124 +aat2870_reg_read_file_12221 aat2870_reg_read_file 3 12221 NULL
95125 +ib_uverbs_unmarshall_recv_12251 ib_uverbs_unmarshall_recv 5 12251 NULL
95126 +ath_descdma_setup_12257 ath_descdma_setup 5 12257 NULL
95127 +shash_compat_setkey_12267 shash_compat_setkey 3 12267 NULL
95128 +add_sctp_bind_addr_12269 add_sctp_bind_addr 3 12269 NULL
95129 +note_last_dentry_12285 note_last_dentry 3 12285 NULL
95130 +il_dbgfs_nvm_read_12288 il_dbgfs_nvm_read 3 12288 NULL nohasharray
95131 +roundup_to_multiple_of_64_12288 roundup_to_multiple_of_64 0-1 12288 &il_dbgfs_nvm_read_12288
95132 +vxge_get_num_vfs_12302 vxge_get_num_vfs 0 12302 NULL
95133 +split_bvec_12312 split_bvec 6 12312 NULL
95134 +tipc_msg_build_12326 tipc_msg_build 4 12326 NULL
95135 +pcbit_writecmd_12332 pcbit_writecmd 2 12332 NULL
95136 +mptctl_ioctl_12355 mptctl_ioctl 2 12355 NULL
95137 +__nf_ct_ext_add_length_12364 __nf_ct_ext_add_length 3 12364 NULL
95138 +receive_packet_12367 receive_packet 2 12367 NULL
95139 +xfs_iext_inline_to_direct_12384 xfs_iext_inline_to_direct 2 12384 NULL
95140 +btrfs_file_extent_ram_bytes_12391 btrfs_file_extent_ram_bytes 0 12391 NULL
95141 +ntfs_get_size_for_mapping_pairs_12413 ntfs_get_size_for_mapping_pairs 0 12413 NULL
95142 +ieee80211_if_read_num_mcast_sta_12419 ieee80211_if_read_num_mcast_sta 3 12419 NULL
95143 +skb_do_copy_data_nocache_12465 skb_do_copy_data_nocache 5 12465 NULL
95144 +qla4_82xx_pci_mem_write_direct_12479 qla4_82xx_pci_mem_write_direct 2 12479 NULL
95145 +x25_sendmsg_12487 x25_sendmsg 4 12487 NULL
95146 +rtllib_auth_challenge_12493 rtllib_auth_challenge 3 12493 NULL
95147 +nfs_readdir_make_qstr_12509 nfs_readdir_make_qstr 3 12509 NULL
95148 +qib_alloc_fast_reg_mr_12526 qib_alloc_fast_reg_mr 2 12526 NULL
95149 +arizona_gpio_direction_out_12564 arizona_gpio_direction_out 2 12564 NULL
95150 +hvc_alloc_12579 hvc_alloc 4 12579 NULL
95151 +snd_pcm_plugin_alloc_12580 snd_pcm_plugin_alloc 2 12580 NULL
95152 +macvtap_compat_ioctl_12587 macvtap_compat_ioctl 3 12587 NULL
95153 +pcpu_extend_area_map_12589 pcpu_extend_area_map 2 12589 NULL
95154 +ipv6_get_l4proto_12600 ipv6_get_l4proto 2 12600 NULL
95155 +vhci_put_user_12604 vhci_put_user 4 12604 NULL
95156 +fc_fcp_frame_alloc_12624 fc_fcp_frame_alloc 2 12624 NULL
95157 +pwr_rcvd_awake_bcns_cnt_read_12632 pwr_rcvd_awake_bcns_cnt_read 3 12632 NULL
95158 +ctrl_cdev_compat_ioctl_12634 ctrl_cdev_compat_ioctl 3 12634 NULL
95159 +pn_sendmsg_12640 pn_sendmsg 4 12640 NULL
95160 +dwc3_link_state_write_12641 dwc3_link_state_write 3 12641 NULL
95161 +ocfs2_read_block_12659 ocfs2_read_block 0 12659 NULL
95162 +sel_read_class_12669 sel_read_class 3 12669 NULL nohasharray
95163 +sparse_mem_maps_populate_node_12669 sparse_mem_maps_populate_node 4 12669 &sel_read_class_12669
95164 +ieee80211_if_read_num_buffered_multicast_12716 ieee80211_if_read_num_buffered_multicast 3 12716 NULL
95165 +ivtv_write_12721 ivtv_write 3 12721 NULL
95166 +key_rx_spec_read_12736 key_rx_spec_read 3 12736 NULL
95167 +__videobuf_alloc_cached_12740 __videobuf_alloc_cached 1 12740 NULL
95168 +ieee80211_if_read_dot11MeshMaxRetries_12756 ieee80211_if_read_dot11MeshMaxRetries 3 12756 NULL
95169 +listxattr_12769 listxattr 3 12769 NULL
95170 +sctp_ssnmap_init_12772 sctp_ssnmap_init 2-3 12772 NULL
95171 +platform_create_bundle_12785 platform_create_bundle 4-6 12785 NULL
95172 +scsi_adjust_queue_depth_12802 scsi_adjust_queue_depth 3 12802 NULL
95173 +xfs_inumbers_fmt_12817 xfs_inumbers_fmt 3 12817 NULL
95174 +readq_12825 readq 0 12825 NULL
95175 +TSS_authhmac_12839 TSS_authhmac 3 12839 NULL
95176 +spidev_sync_12842 spidev_sync 0 12842 NULL nohasharray
95177 +ath6kl_wmi_add_wow_pattern_cmd_12842 ath6kl_wmi_add_wow_pattern_cmd 4 12842 &spidev_sync_12842
95178 +spidev_ioctl_12846 spidev_ioctl 2 12846 NULL
95179 +get_leb_cnt_12892 get_leb_cnt 0-2 12892 NULL
95180 +ocfs2_hamming_encode_block_12904 ocfs2_hamming_encode_block 2 12904 NULL
95181 +get_virtual_node_size_12908 get_virtual_node_size 0 12908 NULL
95182 +rds_pages_in_vec_12922 rds_pages_in_vec 0 12922 NULL
95183 +ci_ll_init_12930 ci_ll_init 3 12930 NULL
95184 +tps65910_reg_update_bits_12934 tps65910_reg_update_bits 2 12934 NULL
95185 +do_inode_permission_12946 do_inode_permission 0 12946 NULL
95186 +bm_status_write_12964 bm_status_write 3 12964 NULL
95187 +_drbd_md_first_sector_12984 _drbd_md_first_sector 0 12984 NULL
95188 +acpi_tb_install_table_12988 acpi_tb_install_table 1 12988 NULL
95189 +TransmitTcb_12989 TransmitTcb 4 12989 NULL
95190 +sk_peek_offset_12991 sk_peek_offset 0 12991 NULL
95191 +subsystem_filter_write_13022 subsystem_filter_write 3 13022 NULL
95192 +generic_segment_checks_13041 generic_segment_checks 0 13041 NULL
95193 +ocfs2_write_begin_13045 ocfs2_write_begin 3-4 13045 NULL
95194 +__dn_setsockopt_13060 __dn_setsockopt 5 13060 NULL
95195 +irq_set_chip_and_handler_13088 irq_set_chip_and_handler 1 13088 NULL
95196 +tps6586x_set_bits_13089 tps6586x_set_bits 2 13089 NULL
95197 +xattr_getsecurity_13090 xattr_getsecurity 0 13090 NULL
95198 +blk_rq_map_sg_13092 blk_rq_map_sg 0 13092 NULL
95199 +mb_find_next_zero_bit_13100 mb_find_next_zero_bit 2-3 13100 NULL
95200 +ubifs_compat_ioctl_13108 ubifs_compat_ioctl 3 13108 NULL
95201 +snd_rme96_playback_copy_13111 snd_rme96_playback_copy 5 13111 NULL
95202 +xen_allocate_irq_dynamic_13116 xen_allocate_irq_dynamic 0 13116 NULL
95203 +bfad_debugfs_read_13119 bfad_debugfs_read 3 13119 NULL
95204 +blk_update_request_13146 blk_update_request 3 13146 NULL
95205 +caif_stream_recvmsg_13173 caif_stream_recvmsg 4 13173 NULL
95206 +pwr_disable_ps_read_13176 pwr_disable_ps_read 3 13176 NULL
95207 +dgrp_net_ioctl_13183 dgrp_net_ioctl 2 13183 NULL
95208 +create_trace_uprobe_13184 create_trace_uprobe 1 13184 NULL
95209 +compat_put_ulong_13186 compat_put_ulong 1 13186 NULL
95210 +comedi_read_13199 comedi_read 3 13199 NULL
95211 +mmc_ext_csd_read_13205 mmc_ext_csd_read 3 13205 NULL
95212 +__nodes_fold_13215 __nodes_fold 4 13215 NULL
95213 +get_unaligned_le64_13219 get_unaligned_le64 0 13219 NULL
95214 +svm_msrpm_offset_13220 svm_msrpm_offset 0-1 13220 NULL
95215 +asix_read_cmd_13245 asix_read_cmd 5 13245 NULL
95216 +fw_download_code_13249 fw_download_code 3 13249 NULL
95217 +init_tid_tabs_13252 init_tid_tabs 2-3-4 13252 NULL
95218 +hostap_80211_get_hdrlen_13255 hostap_80211_get_hdrlen 0 13255 NULL
95219 +bio_integrity_trim_13259 bio_integrity_trim 3 13259 NULL
95220 +carl9170_rx_13272 carl9170_rx 3 13272 NULL
95221 +pmcraid_notify_aen_13274 pmcraid_notify_aen 3 13274 NULL
95222 +il4965_stats_flag_13281 il4965_stats_flag 0-3 13281 NULL
95223 +lpfc_idiag_mbxacc_get_setup_13282 lpfc_idiag_mbxacc_get_setup 0 13282 NULL
95224 +platform_device_add_resources_13289 platform_device_add_resources 3 13289 NULL
95225 +us122l_ctl_msg_13330 us122l_ctl_msg 8 13330 NULL
95226 +kvm_read_nested_guest_page_13337 kvm_read_nested_guest_page 5 13337 NULL
95227 +mthca_alloc_mtt_range_13371 mthca_alloc_mtt_range 2 13371 NULL
95228 +iso_sched_alloc_13377 iso_sched_alloc 1 13377 NULL nohasharray
95229 +wep_key_not_found_read_13377 wep_key_not_found_read 3 13377 &iso_sched_alloc_13377
95230 +carl9170_rx_untie_data_13405 carl9170_rx_untie_data 3 13405 NULL
95231 +sky2_receive_13407 sky2_receive 2 13407 NULL
95232 +netxen_alloc_sds_rings_13417 netxen_alloc_sds_rings 2 13417 NULL
95233 +keyring_read_13438 keyring_read 3 13438 NULL
95234 +sctp_setsockopt_peer_primary_addr_13440 sctp_setsockopt_peer_primary_addr 3 13440 NULL nohasharray
95235 +set_tap_pwup_pfs_13440 set_tap_pwup_pfs 3 13440 &sctp_setsockopt_peer_primary_addr_13440
95236 +ath6kl_cfg80211_connect_event_13443 ath6kl_cfg80211_connect_event 7-8-9 13443 NULL
95237 +mthca_buddy_alloc_13454 mthca_buddy_alloc 2 13454 NULL
95238 +ocfs2_align_bytes_to_blocks_13512 ocfs2_align_bytes_to_blocks 2 13512 NULL
95239 +core_status_13515 core_status 4 13515 NULL
95240 +smk_write_mapped_13519 smk_write_mapped 3 13519 NULL
95241 +bm_init_13529 bm_init 2 13529 NULL
95242 +llcp_sock_recvmsg_13556 llcp_sock_recvmsg 4 13556 NULL
95243 +ieee80211_if_read_ap_power_level_13558 ieee80211_if_read_ap_power_level 3 13558 NULL
95244 +alloc_tio_13564 alloc_tio 3 13564 NULL
95245 +ubifs_get_idx_gc_leb_13566 ubifs_get_idx_gc_leb 0 13566 NULL
95246 +read_file_antenna_13574 read_file_antenna 3 13574 NULL
95247 +pm860x_set_bits_13582 pm860x_set_bits 2 13582 NULL
95248 +cache_write_13589 cache_write 3 13589 NULL
95249 +mpt_lan_receive_post_turbo_13592 mpt_lan_receive_post_turbo 2 13592 NULL
95250 +aac_sa_ioremap_13596 aac_sa_ioremap 2 13596 NULL nohasharray
95251 +irias_new_octseq_value_13596 irias_new_octseq_value 2 13596 &aac_sa_ioremap_13596
95252 +usb_dump_interface_descriptor_13603 usb_dump_interface_descriptor 0 13603 NULL
95253 +swap_cgroup_swapon_13614 swap_cgroup_swapon 2 13614 NULL
95254 +wm8994_bulk_write_13615 wm8994_bulk_write 3-2 13615 NULL
95255 +pmcraid_get_minor_13619 pmcraid_get_minor 0 13619 NULL
95256 +iio_device_add_event_sysfs_13627 iio_device_add_event_sysfs 0 13627 NULL
95257 +packet_snd_13634 packet_snd 3 13634 NULL
95258 +blk_msg_write_13655 blk_msg_write 3 13655 NULL
95259 +cache_downcall_13666 cache_downcall 3 13666 NULL
95260 +fw_iso_buffer_alloc_13704 fw_iso_buffer_alloc 2 13704 NULL
95261 +audit_unpack_string_13748 audit_unpack_string 3 13748 NULL
95262 +ufs_dtog_13750 ufs_dtog 0-2 13750 NULL
95263 +ieee802154_alloc_device_13767 ieee802154_alloc_device 1 13767 NULL
95264 +fb_sys_read_13778 fb_sys_read 3 13778 NULL
95265 +ath6kl_mgmt_powersave_ap_13791 ath6kl_mgmt_powersave_ap 6 13791 NULL
95266 +random_read_13815 random_read 3 13815 NULL
95267 +hsi_register_board_info_13820 hsi_register_board_info 2 13820 NULL
95268 +evdev_ioctl_compat_13851 evdev_ioctl_compat 2-3 13851 NULL
95269 +compat_ip_setsockopt_13870 compat_ip_setsockopt 5 13870 NULL nohasharray
95270 +alloc_trace_uprobe_13870 alloc_trace_uprobe 3 13870 &compat_ip_setsockopt_13870
95271 +snd_pcm_aio_read_13900 snd_pcm_aio_read 3 13900 NULL
95272 +ext3_xattr_block_get_13936 ext3_xattr_block_get 0 13936 NULL
95273 +ieee80211_if_read_dot11MeshForwarding_13940 ieee80211_if_read_dot11MeshForwarding 3 13940 NULL nohasharray
95274 +ocfs2_xa_value_truncate_13940 ocfs2_xa_value_truncate 2 13940 &ieee80211_if_read_dot11MeshForwarding_13940
95275 +iwl_dbgfs_protection_mode_read_13943 iwl_dbgfs_protection_mode_read 3 13943 NULL
95276 +compat_chaninfo_13945 compat_chaninfo 2 13945 NULL
95277 +ieee80211_if_read_min_discovery_timeout_13946 ieee80211_if_read_min_discovery_timeout 3 13946 NULL
95278 +lpfc_idiag_queacc_read_13950 lpfc_idiag_queacc_read 3 13950 NULL
95279 +snd_pcm_plug_slave_size_13967 snd_pcm_plug_slave_size 0-2 13967 NULL
95280 +com90xx_found_13974 com90xx_found 3 13974 NULL
95281 +qcam_read_13977 qcam_read 3 13977 NULL
95282 +dsp_read_13980 dsp_read 2 13980 NULL
95283 +bm_block_bits_13981 bm_block_bits 0 13981 NULL nohasharray
95284 +dvb_demux_read_13981 dvb_demux_read 3 13981 &bm_block_bits_13981
95285 +ieee80211_bss_info_update_13991 ieee80211_bss_info_update 4 13991 NULL
95286 +btrfs_get_blocks_direct_14016 btrfs_get_blocks_direct 2 14016 NULL
95287 +_rtl92s_firmware_downloadcode_14021 _rtl92s_firmware_downloadcode 3 14021 NULL
95288 +dvb_usercopy_14036 dvb_usercopy 2 14036 NULL
95289 +read_def_modal_eeprom_14041 read_def_modal_eeprom 3 14041 NULL
95290 +ieee80211_if_fmt_aid_14055 ieee80211_if_fmt_aid 3 14055 NULL
95291 +sta_agg_status_read_14058 sta_agg_status_read 3 14058 NULL
95292 +do_proc_readlink_14096 do_proc_readlink 3 14096 NULL
95293 +compat_sys_pselect6_14105 compat_sys_pselect6 1 14105 NULL
95294 +nlmsg_len_14115 nlmsg_len 0 14115 NULL
95295 +vfio_fops_compat_ioctl_14130 vfio_fops_compat_ioctl 3 14130 NULL
95296 +ntfs_rl_replace_14136 ntfs_rl_replace 2-4 14136 NULL
95297 +em_canid_change_14150 em_canid_change 3 14150 NULL
95298 +gsm_dlci_data_14155 gsm_dlci_data 3 14155 NULL
95299 +print_input_mask_14168 print_input_mask 3-0 14168 NULL
95300 +ocfs2_xattr_value_truncate_14183 ocfs2_xattr_value_truncate 3 14183 NULL
95301 +alloc_async_14208 alloc_async 1 14208 NULL
95302 +sys_kexec_load_14222 sys_kexec_load 2 14222 NULL
95303 +pool_status_14230 pool_status 5 14230 NULL
95304 +ieee80211_if_write_uapsd_max_sp_len_14233 ieee80211_if_write_uapsd_max_sp_len 3 14233 NULL
95305 +inode_to_path_14235 inode_to_path 2 14235 NULL
95306 +dma_declare_coherent_memory_14244 dma_declare_coherent_memory 4-2 14244 NULL
95307 +snd_soc_hw_bulk_write_raw_14245 snd_soc_hw_bulk_write_raw 4-2 14245 NULL
95308 +reiserfs_compat_ioctl_14265 reiserfs_compat_ioctl 3 14265 NULL
95309 +ath6kl_connect_event_14267 ath6kl_connect_event 7-8-9 14267 NULL
95310 +add_numbered_child_14273 add_numbered_child 5 14273 NULL
95311 +OS_mem_token_alloc_14276 OS_mem_token_alloc 1 14276 NULL
95312 +snd_seq_oss_readq_new_14283 snd_seq_oss_readq_new 2 14283 NULL
95313 +rr_status_14293 rr_status 5 14293 NULL
95314 +lp8788_write_byte_14299 lp8788_write_byte 2 14299 NULL
95315 +read_default_ldt_14302 read_default_ldt 2 14302 NULL
95316 +oo_objects_14319 oo_objects 0 14319 NULL
95317 +p9_client_zc_rpc_14345 p9_client_zc_rpc 7 14345 NULL
95318 +snd_pcm_lib_readv_14363 snd_pcm_lib_readv 0-3 14363 NULL
95319 +acpi_get_override_irq_14381 acpi_get_override_irq 1 14381 NULL
95320 +ath6kl_regdump_read_14393 ath6kl_regdump_read 3 14393 NULL
95321 +smk_write_onlycap_14400 smk_write_onlycap 3 14400 NULL
95322 +mtd_concat_create_14416 mtd_concat_create 2 14416 NULL
95323 +get_kcore_size_14425 get_kcore_size 0 14425 NULL
95324 +check_lpt_crc_14442 check_lpt_crc 0 14442 NULL
95325 +block_size_14443 block_size 0 14443 NULL
95326 +ci13xxx_add_device_14456 ci13xxx_add_device 3 14456 NULL
95327 +snd_emu10k1_proc_spdif_status_14457 snd_emu10k1_proc_spdif_status 4-5 14457 NULL
95328 +udplite_getfrag_14479 udplite_getfrag 3-4 14479 NULL
95329 +ieee80211_if_read_dot11MeshGateAnnouncementProtocol_14486 ieee80211_if_read_dot11MeshGateAnnouncementProtocol 3 14486 NULL
95330 +stripe_status_14506 stripe_status 5 14506 NULL
95331 +ocfs2_debug_read_14507 ocfs2_debug_read 3 14507 NULL
95332 +ep0_write_14536 ep0_write 3 14536 NULL nohasharray
95333 +dataflash_read_user_otp_14536 dataflash_read_user_otp 2-3 14536 &ep0_write_14536
95334 +picolcd_debug_eeprom_read_14549 picolcd_debug_eeprom_read 3 14549 NULL
95335 +drm_vmalloc_dma_14550 drm_vmalloc_dma 1 14550 NULL
95336 +usb_dump_desc_14553 usb_dump_desc 0 14553 NULL
95337 +idmap_pipe_downcall_14591 idmap_pipe_downcall 3 14591 NULL
95338 +ocfs2_trim_group_14641 ocfs2_trim_group 4-3 14641 NULL
95339 +dbJoin_14644 dbJoin 0 14644 NULL
95340 +profile_replace_14652 profile_replace 3 14652 NULL
95341 +pipeline_enc_tx_stat_fifo_int_read_14680 pipeline_enc_tx_stat_fifo_int_read 3 14680 NULL
95342 +ieee80211_if_fmt_rc_rateidx_mask_2ghz_14683 ieee80211_if_fmt_rc_rateidx_mask_2ghz 3 14683 NULL
95343 +tsi148_master_set_14685 tsi148_master_set 4 14685 NULL
95344 +u_audio_playback_14709 u_audio_playback 3 14709 NULL
95345 +vfd_write_14717 vfd_write 3 14717 NULL
95346 +__blk_end_request_14729 __blk_end_request 3 14729 NULL
95347 +raid1_resize_14740 raid1_resize 2 14740 NULL
95348 +btrfs_inode_extref_name_len_14752 btrfs_inode_extref_name_len 0 14752 NULL
95349 +rx_rx_cmplt_read_14753 rx_rx_cmplt_read 3 14753 NULL
95350 +qla82xx_pci_mem_write_2M_14765 qla82xx_pci_mem_write_2M 2 14765 NULL
95351 +regmap_range_read_file_14775 regmap_range_read_file 3 14775 NULL
95352 +lm3533_als_get_hysteresis_14776 lm3533_als_get_hysteresis 2 14776 NULL
95353 +sta_dev_read_14782 sta_dev_read 3 14782 NULL
95354 +ext4_kvmalloc_14796 ext4_kvmalloc 1 14796 NULL
95355 +snd_als300_gcr_read_14801 snd_als300_gcr_read 0 14801 NULL nohasharray
95356 +hpet_readl_14801 hpet_readl 0 14801 &snd_als300_gcr_read_14801
95357 +bcma_scan_read32_14802 bcma_scan_read32 0 14802 NULL
95358 +do_tune_cpucache_14828 do_tune_cpucache 2 14828 NULL
95359 +__mutex_fastpath_lock_retval_14844 __mutex_fastpath_lock_retval 0 14844 NULL
95360 +lcd_write_14857 lcd_write 3 14857 NULL nohasharray
95361 +__krealloc_14857 __krealloc 2 14857 &lcd_write_14857
95362 +get_user_cpu_mask_14861 get_user_cpu_mask 2 14861 NULL
95363 +sriov_enable_migration_14889 sriov_enable_migration 2 14889 NULL
95364 +acpi_os_allocate_14892 acpi_os_allocate 1 14892 NULL
95365 +unifi_read_14899 unifi_read 3 14899 NULL
95366 +krealloc_14908 krealloc 2 14908 NULL
95367 +regmap_irq_get_virq_14910 regmap_irq_get_virq 2 14910 NULL
95368 +__arch_hweight64_14923 __arch_hweight64 0 14923 NULL
95369 +ocfs2_expand_nonsparse_inode_14936 ocfs2_expand_nonsparse_inode 3-4 14936 NULL
95370 +queue_cnt_14951 queue_cnt 0 14951 NULL
95371 +videobuf_read_stream_14956 videobuf_read_stream 3 14956 NULL
95372 +mce_flush_rx_buffer_14976 mce_flush_rx_buffer 2 14976 NULL
95373 +setkey_14987 setkey 3 14987 NULL nohasharray
95374 +gpio_twl4030_write_14987 gpio_twl4030_write 1 14987 &setkey_14987
95375 +vmap_15025 vmap 2 15025 NULL
95376 +blk_integrity_tuple_size_15027 blk_integrity_tuple_size 0 15027 NULL
95377 +irq_get_next_irq_15053 irq_get_next_irq 1 15053 NULL
95378 +cld_pipe_downcall_15058 cld_pipe_downcall 3 15058 NULL
95379 +ieee80211_if_read_uapsd_max_sp_len_15067 ieee80211_if_read_uapsd_max_sp_len 3 15067 NULL
95380 +nfs4_write_cached_acl_15070 nfs4_write_cached_acl 4 15070 NULL
95381 +ntfs_copy_from_user_15072 ntfs_copy_from_user 3-5 15072 NULL
95382 +__alloc_extent_buffer_15093 __alloc_extent_buffer 3 15093 NULL
95383 +hex_dump_to_buffer_15121 hex_dump_to_buffer 6 15121 NULL
95384 +start_port_15124 start_port 0 15124 NULL
95385 +memchr_15126 memchr 0 15126 NULL
95386 +ipwireless_ppp_mru_15153 ipwireless_ppp_mru 0 15153 NULL
95387 +self_check_not_bad_15175 self_check_not_bad 0 15175 NULL
95388 +iscsi_create_endpoint_15193 iscsi_create_endpoint 1 15193 NULL
95389 +reserve_resources_15194 reserve_resources 3 15194 NULL
95390 +bfad_debugfs_write_regrd_15218 bfad_debugfs_write_regrd 3 15218 NULL
95391 +variax_alloc_sysex_buffer_15237 variax_alloc_sysex_buffer 3 15237 NULL
95392 +il_dbgfs_rx_stats_read_15243 il_dbgfs_rx_stats_read 3 15243 NULL
95393 +compat_raw_ioctl_15290 compat_raw_ioctl 3 15290 NULL
95394 +sys_connect_15291 sys_connect 3 15291 NULL nohasharray
95395 +xlate_dev_mem_ptr_15291 xlate_dev_mem_ptr 1 15291 &sys_connect_15291
95396 +arch_enable_uv_irq_15294 arch_enable_uv_irq 2 15294 NULL
95397 +acpi_ev_create_gpe_block_15297 acpi_ev_create_gpe_block 5 15297 NULL
95398 +tpm_tis_init_15304 tpm_tis_init 2-3 15304 NULL
95399 +fcoe_ctlr_send_keep_alive_15308 fcoe_ctlr_send_keep_alive 3 15308 NULL
95400 +__ocfs2_remove_xattr_range_15330 __ocfs2_remove_xattr_range 4-5-3 15330 NULL
95401 +kovaplus_sysfs_read_15337 kovaplus_sysfs_read 6 15337 NULL
95402 +ioread16_15342 ioread16 0 15342 NULL
95403 +alloc_ring_15345 alloc_ring 2-4 15345 NULL
95404 +acpi_ut_create_string_object_15360 acpi_ut_create_string_object 1 15360 NULL
95405 +compat_sys_process_vm_readv_15374 compat_sys_process_vm_readv 3-5 15374 NULL
95406 +fq_codel_zalloc_15378 fq_codel_zalloc 1 15378 NULL
95407 +domain_flush_pages_15379 domain_flush_pages 2-3 15379 NULL
95408 +alloc_fddidev_15382 alloc_fddidev 1 15382 NULL
95409 +btrfs_level_size_15392 btrfs_level_size 0 15392 NULL
95410 +pipeline_csum_to_rx_xfer_swi_read_15403 pipeline_csum_to_rx_xfer_swi_read 3 15403 NULL
95411 +get_modalias_15406 get_modalias 2 15406 NULL
95412 +__videobuf_copy_to_user_15423 __videobuf_copy_to_user 4 15423 NULL
95413 +tcp_mtu_to_mss_15438 tcp_mtu_to_mss 0-2 15438 NULL
95414 +hpsa_change_queue_depth_15449 hpsa_change_queue_depth 2 15449 NULL
95415 +memweight_15450 memweight 2 15450 NULL
95416 +vmalloc_15464 vmalloc 1 15464 NULL
95417 +insert_old_idx_znode_15500 insert_old_idx_znode 0 15500 NULL
95418 +zd_chip_is_zd1211b_15518 zd_chip_is_zd1211b 0 15518 NULL
95419 +da9052_bat_irq_15533 da9052_bat_irq 1 15533 NULL
95420 +p9_check_zc_errors_15534 p9_check_zc_errors 4 15534 NULL
95421 +ql_process_mac_rx_page_15543 ql_process_mac_rx_page 4 15543 NULL
95422 +ieee80211_amsdu_to_8023s_15561 ieee80211_amsdu_to_8023s 5 15561 NULL
95423 +snd_pcm_channel_info_15572 snd_pcm_channel_info 0 15572 NULL
95424 +persistent_status_15574 persistent_status 4 15574 NULL
95425 +bnx2fc_process_unsol_compl_15576 bnx2fc_process_unsol_compl 2 15576 NULL
95426 +vme_user_write_15587 vme_user_write 3 15587 NULL
95427 +ocfs2_truncate_rec_15595 ocfs2_truncate_rec 7 15595 NULL
95428 +sx150x_install_irq_chip_15609 sx150x_install_irq_chip 3 15609 NULL
95429 +iommu_device_max_index_15620 iommu_device_max_index 0-3-2-1 15620 NULL nohasharray
95430 +compat_fillonedir_15620 compat_fillonedir 3 15620 &iommu_device_max_index_15620
95431 +set_dis_tap_pfs_15621 set_dis_tap_pfs 3 15621 NULL
95432 +proc_loginuid_read_15631 proc_loginuid_read 3 15631 NULL
95433 +tomoyo_scan_bprm_15642 tomoyo_scan_bprm 2-4 15642 NULL nohasharray
95434 +sk_memory_allocated_add_15642 sk_memory_allocated_add 2 15642 &tomoyo_scan_bprm_15642 nohasharray
95435 +pipeline_hs_tx_stat_fifo_int_read_15642 pipeline_hs_tx_stat_fifo_int_read 3 15642 &sk_memory_allocated_add_15642
95436 +fs_path_add_15648 fs_path_add 3 15648 NULL
95437 +xsd_read_15653 xsd_read 3 15653 NULL
95438 +compat_sys_fcntl_15654 compat_sys_fcntl 3 15654 NULL
95439 +unix_bind_15668 unix_bind 3 15668 NULL
95440 +dm_read_15674 dm_read 3 15674 NULL
95441 +pstore_mkfile_15675 pstore_mkfile 6 15675 NULL
95442 +uf_sme_queue_message_15697 uf_sme_queue_message 3 15697 NULL
95443 +ocfs2_split_tree_15716 ocfs2_split_tree 5 15716 NULL
95444 +HiSax_readstatus_15752 HiSax_readstatus 2 15752 NULL
95445 +bitmap_search_next_usable_block_15762 bitmap_search_next_usable_block 3-1 15762 NULL
95446 +do_test_15766 do_test 1 15766 NULL
95447 +set_std_nic_pfs_15792 set_std_nic_pfs 3 15792 NULL
95448 +smk_read_direct_15803 smk_read_direct 3 15803 NULL
95449 +snd_pcm_ioctl_compat_15804 snd_pcm_ioctl_compat 3 15804 NULL
95450 +gx1_read_conf_reg_15817 gx1_read_conf_reg 0 15817 NULL nohasharray
95451 +nameseq_list_15817 nameseq_list 3 15817 &gx1_read_conf_reg_15817 nohasharray
95452 +gnttab_expand_15817 gnttab_expand 1 15817 &nameseq_list_15817
95453 +afs_proc_rootcell_write_15822 afs_proc_rootcell_write 3 15822 NULL
95454 +brcmf_sdbrcm_died_dump_15841 brcmf_sdbrcm_died_dump 3 15841 NULL
95455 +table_size_15851 table_size 0-1-2 15851 NULL
95456 +ubi_io_write_15870 ubi_io_write 5-4 15870 NULL nohasharray
95457 +media_entity_init_15870 media_entity_init 2-4 15870 &ubi_io_write_15870
95458 +__mptctl_ioctl_15875 __mptctl_ioctl 2 15875 NULL
95459 +ERR_PTR_15881 ERR_PTR 0 15881 NULL
95460 +nfs_map_group_to_gid_15892 nfs_map_group_to_gid 3 15892 NULL
95461 +native_read_msr_15905 native_read_msr 0 15905 NULL
95462 +wm5100_gpio_direction_in_15934 wm5100_gpio_direction_in 2 15934 NULL
95463 +parse_audio_stream_data_15937 parse_audio_stream_data 3 15937 NULL
95464 +power_read_15939 power_read 3 15939 NULL
95465 +lpfc_idiag_drbacc_read_15948 lpfc_idiag_drbacc_read 3 15948 NULL
95466 +snd_pcm_lib_read_transfer_15952 snd_pcm_lib_read_transfer 4-2-5 15952 NULL
95467 +remap_pci_mem_15966 remap_pci_mem 1-2 15966 NULL
95468 +set_spte_15977 set_spte 7-6 15977 NULL
95469 +frame_alloc_15981 frame_alloc 4 15981 NULL
95470 +alloc_vm_area_15989 alloc_vm_area 1 15989 NULL
95471 +hdpvr_register_videodev_16010 hdpvr_register_videodev 3 16010 NULL
95472 +viafb_vt1636_proc_write_16018 viafb_vt1636_proc_write 3 16018 NULL
95473 +got_frame_16028 got_frame 2 16028 NULL
95474 +isr_tx_exch_complete_read_16103 isr_tx_exch_complete_read 3 16103 NULL
95475 +dma_tx_requested_read_16110 dma_tx_requested_read 3 16110 NULL nohasharray
95476 +isr_hw_pm_mode_changes_read_16110 isr_hw_pm_mode_changes_read 3 16110 &dma_tx_requested_read_16110
95477 +irq_set_chip_and_handler_name_16111 irq_set_chip_and_handler_name 1 16111 NULL
95478 +snd_dma_pointer_16126 snd_dma_pointer 0-2 16126 NULL
95479 +compat_sys_select_16131 compat_sys_select 1 16131 NULL
95480 +fsm_init_16134 fsm_init 2 16134 NULL
95481 +hysdn_rx_netpkt_16136 hysdn_rx_netpkt 3 16136 NULL
95482 +ext4_xattr_block_get_16148 ext4_xattr_block_get 0 16148 NULL
95483 +bnx2i_get_cid_num_16166 bnx2i_get_cid_num 0 16166 NULL
95484 +mapping_level_16188 mapping_level 2 16188 NULL
95485 +cipso_v4_map_cat_rng_hton_16203 cipso_v4_map_cat_rng_hton 0 16203 NULL
95486 +create_table_16213 create_table 2 16213 NULL
95487 +atomic_read_file_16227 atomic_read_file 3 16227 NULL
95488 +BcmGetSectionValStartOffset_16235 BcmGetSectionValStartOffset 0 16235 NULL
95489 +btrfs_dev_extent_chunk_offset_16247 btrfs_dev_extent_chunk_offset 0 16247 NULL
95490 +mark_written_sectors_16262 mark_written_sectors 2 16262 NULL
95491 +reiserfs_acl_count_16265 reiserfs_acl_count 0-1 16265 NULL
95492 +set_disc_pfs_16270 set_disc_pfs 3 16270 NULL
95493 +ocfs2_xattr_bucket_value_truncate_16279 ocfs2_xattr_bucket_value_truncate 4 16279 NULL
95494 +drbd_setsockopt_16280 drbd_setsockopt 5 16280 NULL nohasharray
95495 +nand_bch_init_16280 nand_bch_init 3-2 16280 &drbd_setsockopt_16280
95496 +account_16283 account 0-2-4 16283 NULL
95497 +stk_allocate_buffers_16291 stk_allocate_buffers 2 16291 NULL
95498 +rbd_segment_offset_16293 rbd_segment_offset 0-2 16293 NULL
95499 +rsc_mgr_init_16299 rsc_mgr_init 3 16299 NULL
95500 +vmw_cursor_update_image_16332 vmw_cursor_update_image 3-4 16332 NULL
95501 +tps80031_update_16360 tps80031_update 3 16360 NULL
95502 +total_ps_buffered_read_16365 total_ps_buffered_read 3 16365 NULL
95503 +rbd_add_16366 rbd_add 3 16366 NULL
95504 +iscsi_tcp_conn_setup_16376 iscsi_tcp_conn_setup 2 16376 NULL
95505 +nl80211_send_unprot_deauth_16378 nl80211_send_unprot_deauth 4 16378 NULL
95506 +diva_os_malloc_16406 diva_os_malloc 2 16406 NULL
95507 +ieee80211_if_read_tsf_16420 ieee80211_if_read_tsf 3 16420 NULL
95508 +rxrpc_server_keyring_16431 rxrpc_server_keyring 3 16431 NULL
95509 +netlink_change_ngroups_16457 netlink_change_ngroups 2 16457 NULL
95510 +tracing_readme_read_16493 tracing_readme_read 3 16493 NULL
95511 +snd_interval_max_16529 snd_interval_max 0 16529 NULL
95512 +raid10_resize_16537 raid10_resize 2 16537 NULL
95513 +tcp_manip_pkt_16563 tcp_manip_pkt 4 16563 NULL
95514 +lpfc_debugfs_read_16566 lpfc_debugfs_read 3 16566 NULL
95515 +agp_allocate_memory_wrap_16576 agp_allocate_memory_wrap 1 16576 NULL
95516 +btrfs_get_token_32_16651 btrfs_get_token_32 0 16651 NULL
95517 +mfd_add_devices_16668 mfd_add_devices 4 16668 NULL
95518 +da9052_reg_write_16685 da9052_reg_write 2 16685 NULL
95519 +em28xx_v4l2_read_16701 em28xx_v4l2_read 3 16701 NULL
95520 +arcmsr_adjust_disk_queue_depth_16756 arcmsr_adjust_disk_queue_depth 2 16756 NULL
95521 +compat_blkdev_driver_ioctl_16769 compat_blkdev_driver_ioctl 4 16769 NULL
95522 +blk_rq_map_user_iov_16772 blk_rq_map_user_iov 5 16772 NULL
95523 +i2o_parm_issue_16790 i2o_parm_issue 0 16790 NULL
95524 +get_server_iovec_16804 get_server_iovec 2 16804 NULL
95525 +tipc_send2name_16809 tipc_send2name 6 16809 NULL
95526 +dm_vcalloc_16814 dm_vcalloc 1-2 16814 NULL
95527 +drm_malloc_ab_16831 drm_malloc_ab 1-2 16831 NULL
95528 +scsi_mode_sense_16835 scsi_mode_sense 5 16835 NULL
95529 +hfsplus_min_io_size_16859 hfsplus_min_io_size 0 16859 NULL
95530 +alloc_idx_lebs_16872 alloc_idx_lebs 2 16872 NULL
95531 +carl9170_debugfs_ampdu_state_read_16873 carl9170_debugfs_ampdu_state_read 3 16873 NULL
95532 +st_write_16874 st_write 3 16874 NULL
95533 +__kfifo_peek_n_16877 __kfifo_peek_n 0 16877 NULL
95534 +wm8350_set_bits_16911 wm8350_set_bits 2 16911 NULL
95535 +psb_unlocked_ioctl_16926 psb_unlocked_ioctl 2 16926 NULL nohasharray
95536 +snd_gf1_mem_proc_dump_16926 snd_gf1_mem_proc_dump 5 16926 &psb_unlocked_ioctl_16926
95537 +random32_16937 random32 0 16937 NULL
95538 +_sp2d_alloc_16944 _sp2d_alloc 1-2-3 16944 NULL
95539 +squashfs_read_table_16945 squashfs_read_table 3 16945 NULL
95540 +cfg80211_send_unprot_disassoc_16951 cfg80211_send_unprot_disassoc 3 16951 NULL
95541 +keyctl_instantiate_key_iov_16969 keyctl_instantiate_key_iov 3 16969 NULL
95542 +ceph_read_dir_17005 ceph_read_dir 3 17005 NULL
95543 +copy_counters_to_user_17027 copy_counters_to_user 5 17027 NULL
95544 +jffs2_trusted_setxattr_17048 jffs2_trusted_setxattr 4 17048 NULL
95545 +__arch_hweight32_17060 __arch_hweight32 0 17060 NULL
95546 +dvb_dvr_read_17073 dvb_dvr_read 3 17073 NULL
95547 +simple_transaction_read_17076 simple_transaction_read 3 17076 NULL
95548 +__kmalloc_reserve_17080 __kmalloc_reserve 1 17080 NULL
95549 +carl9170_debugfs_mem_usage_read_17084 carl9170_debugfs_mem_usage_read 3 17084 NULL
95550 +mac_address_string_17091 mac_address_string 0 17091 NULL
95551 +entry_length_17093 entry_length 0 17093 NULL
95552 +sys_preadv_17100 sys_preadv 3 17100 NULL
95553 +pvr2_hdw_state_report_17121 pvr2_hdw_state_report 3 17121 NULL
95554 +mwifiex_get_common_rates_17131 mwifiex_get_common_rates 3 17131 NULL
95555 +nouveau_instobj_create__17144 nouveau_instobj_create_ 4 17144 NULL
95556 +sep_read_17161 sep_read 3 17161 NULL
95557 +befs_nls2utf_17163 befs_nls2utf 3 17163 NULL
95558 +tx_tx_start_templates_read_17164 tx_tx_start_templates_read 3 17164 NULL
95559 +UniStrnlen_17169 UniStrnlen 0 17169 NULL
95560 +access_remote_vm_17189 access_remote_vm 0-2-4 17189 NULL
95561 +driver_state_read_17194 driver_state_read 3 17194 NULL nohasharray
95562 +iscsit_find_cmd_from_itt_or_dump_17194 iscsit_find_cmd_from_itt_or_dump 3 17194 &driver_state_read_17194
95563 +dn_recvmsg_17213 dn_recvmsg 4 17213 NULL
95564 +ms_rw_17220 ms_rw 3-4 17220 NULL
95565 +__be16_to_cpup_17261 __be16_to_cpup 0 17261 NULL
95566 +error_error_frame_cts_nul_flid_read_17262 error_error_frame_cts_nul_flid_read 3 17262 NULL
95567 +alloc_ep_17269 alloc_ep 1 17269 NULL
95568 +pg_read_17276 pg_read 3 17276 NULL
95569 +raw_recvmsg_17277 raw_recvmsg 4 17277 NULL
95570 +hmac_sha256_17278 hmac_sha256 2 17278 NULL
95571 +neigh_hash_grow_17283 neigh_hash_grow 2 17283 NULL
95572 +minstrel_stats_read_17290 minstrel_stats_read 3 17290 NULL
95573 +ieee80211_if_fmt_dot11MeshForwarding_17301 ieee80211_if_fmt_dot11MeshForwarding 3 17301 NULL
95574 +skb_pad_17302 skb_pad 2 17302 NULL
95575 +mb_cache_create_17307 mb_cache_create 2 17307 NULL
95576 +gnttab_map_frames_v2_17314 gnttab_map_frames_v2 2 17314 NULL
95577 +ata_host_alloc_pinfo_17325 ata_host_alloc_pinfo 3 17325 NULL
95578 +ieee80211_if_read_dot11MeshHWMPperrMinInterval_17346 ieee80211_if_read_dot11MeshHWMPperrMinInterval 3 17346 NULL
95579 +ath6kl_wmi_send_mgmt_cmd_17347 ath6kl_wmi_send_mgmt_cmd 7 17347 NULL
95580 +lpfc_debugfs_dif_err_write_17424 lpfc_debugfs_dif_err_write 3 17424 NULL
95581 +sta_connected_time_read_17435 sta_connected_time_read 3 17435 NULL
95582 +nla_get_u32_17455 nla_get_u32 0 17455 NULL
95583 +__ref_totlen_17461 __ref_totlen 0 17461 NULL
95584 +compat_cmd_17465 compat_cmd 2 17465 NULL
95585 +probe_bios_17467 probe_bios 1 17467 NULL
95586 +probe_kernel_write_17481 probe_kernel_write 3 17481 NULL
95587 +__alloc_session_17485 __alloc_session 2-1 17485 NULL
95588 +TSS_rawhmac_17486 TSS_rawhmac 3 17486 NULL
95589 +bitmap_pos_to_ord_17503 bitmap_pos_to_ord 3 17503 NULL
95590 +arizona_apply_fll_17538 arizona_apply_fll 2 17538 NULL
95591 +xlog_do_log_recovery_17550 xlog_do_log_recovery 3 17550 NULL
95592 +__copy_to_user_17551 __copy_to_user 0-3 17551 NULL
95593 +copy_from_user_17559 copy_from_user 3 17559 NULL
95594 +snd_pcm_action_lock_irq_17569 snd_pcm_action_lock_irq 0 17569 NULL
95595 +acpi_ut_create_package_object_17594 acpi_ut_create_package_object 1 17594 NULL
95596 +neigh_hash_alloc_17595 neigh_hash_alloc 1 17595 NULL
95597 +rts51x_write_mem_17598 rts51x_write_mem 4 17598 NULL
95598 +iwl_dump_nic_event_log_17601 iwl_dump_nic_event_log 0 17601 NULL
95599 +wm8994_gpio_to_irq_17604 wm8994_gpio_to_irq 2 17604 NULL
95600 +osst_execute_17607 osst_execute 7-6 17607 NULL
95601 +ocfs2_mark_extent_written_17615 ocfs2_mark_extent_written 6 17615 NULL
95602 +ieee80211_if_read_dot11MeshHWMPactivePathToRootTimeout_17618 ieee80211_if_read_dot11MeshHWMPactivePathToRootTimeout 3 17618 NULL
95603 +twl4030_set_gpio_direction_17645 twl4030_set_gpio_direction 1 17645 NULL
95604 +packet_setsockopt_17662 packet_setsockopt 5 17662 NULL nohasharray
95605 +ubi_io_read_data_17662 ubi_io_read_data 0 17662 &packet_setsockopt_17662
95606 +pwr_enable_ps_read_17686 pwr_enable_ps_read 3 17686 NULL
95607 +__einj_error_trigger_17707 __einj_error_trigger 1 17707 NULL nohasharray
95608 +venus_rename_17707 venus_rename 5-4 17707 &__einj_error_trigger_17707
95609 +exofs_read_lookup_dev_table_17733 exofs_read_lookup_dev_table 3 17733 NULL
95610 +sctpprobe_read_17741 sctpprobe_read 3 17741 NULL
95611 +mark_unsafe_pages_17759 mark_unsafe_pages 0 17759 NULL
95612 +brcmf_usb_attach_17766 brcmf_usb_attach 2-3 17766 NULL
95613 +ubifs_leb_change_17789 ubifs_leb_change 4 17789 NULL
95614 +get_unaligned_be64_17794 get_unaligned_be64 0 17794 NULL
95615 +_snd_pcm_lib_alloc_vmalloc_buffer_17820 _snd_pcm_lib_alloc_vmalloc_buffer 2 17820 NULL
95616 +gnet_stats_copy_app_17821 gnet_stats_copy_app 3 17821 NULL
95617 +cipso_v4_gentag_rbm_17836 cipso_v4_gentag_rbm 0 17836 NULL
95618 +count_leafs_17842 count_leafs 0 17842 NULL
95619 +sisusb_send_bulk_msg_17864 sisusb_send_bulk_msg 3 17864 NULL
95620 +alloc_sja1000dev_17868 alloc_sja1000dev 1 17868 NULL
95621 +ray_cs_essid_proc_write_17875 ray_cs_essid_proc_write 3 17875 NULL
95622 +orinoco_set_key_17878 orinoco_set_key 5-7 17878 NULL
95623 +init_per_cpu_17880 init_per_cpu 1 17880 NULL
95624 +ieee80211_if_fmt_dot11MeshMaxPeerLinks_17883 ieee80211_if_fmt_dot11MeshMaxPeerLinks 3 17883 NULL
95625 +compat_sys_pwritev_17886 compat_sys_pwritev 3 17886 NULL
95626 +ieee80211_if_fmt_dot11MeshHWMPRootMode_17890 ieee80211_if_fmt_dot11MeshHWMPRootMode 3 17890 NULL
95627 +ocfs2_clusters_to_blocks_17896 ocfs2_clusters_to_blocks 0-2 17896 NULL
95628 +wm8400_set_bits_17898 wm8400_set_bits 2 17898 NULL
95629 +recover_head_17904 recover_head 3 17904 NULL
95630 +dccp_feat_register_sp_17914 dccp_feat_register_sp 5 17914 NULL
95631 +xfs_buf_associate_memory_17915 xfs_buf_associate_memory 3 17915 NULL
95632 +srp_iu_pool_alloc_17920 srp_iu_pool_alloc 2 17920 NULL
95633 +scsi_bufflen_17933 scsi_bufflen 0 17933 NULL
95634 +ufs_free_blocks_17963 ufs_free_blocks 2-3 17963 NULL
95635 +calc_nr_buckets_17976 calc_nr_buckets 0 17976 NULL
95636 +smk_write_cipso_17989 smk_write_cipso 3 17989 NULL
95637 +gnttab_max_grant_frames_17993 gnttab_max_grant_frames 0 17993 NULL
95638 +ext4_num_overhead_clusters_18001 ext4_num_overhead_clusters 2 18001 NULL
95639 +pvr2_v4l2_read_18006 pvr2_v4l2_read 3 18006 NULL
95640 +prandom32_18007 prandom32 0 18007 NULL
95641 +alloc_rx_desc_ring_18016 alloc_rx_desc_ring 2 18016 NULL
95642 +fill_read_18019 fill_read 0 18019 NULL
95643 +o2hb_highest_node_18034 o2hb_highest_node 2 18034 NULL
95644 +cryptd_alloc_instance_18048 cryptd_alloc_instance 2-3 18048 NULL
95645 +find_next_inuse_18051 find_next_inuse 2-3 18051 NULL
95646 +ddebug_proc_write_18055 ddebug_proc_write 3 18055 NULL
95647 +lua_sysfs_read_18062 lua_sysfs_read 6 18062 NULL
95648 +hex_byte_pack_18064 hex_byte_pack 0 18064 NULL
95649 +packet_came_18072 packet_came 3 18072 NULL
95650 +kvm_read_guest_page_18074 kvm_read_guest_page 5 18074 NULL
95651 +get_vm_area_18080 get_vm_area 1 18080 NULL
95652 +mpi_alloc_18094 mpi_alloc 1 18094 NULL
95653 +tps65910_gpio_input_18110 tps65910_gpio_input 2 18110 NULL
95654 +dfs_file_read_18116 dfs_file_read 3 18116 NULL
95655 +svc_getnl_18120 svc_getnl 0 18120 NULL
95656 +paging32_gpte_to_gfn_lvl_18131 paging32_gpte_to_gfn_lvl 0-1-2 18131 NULL
95657 +vmw_surface_dma_size_18132 vmw_surface_dma_size 0 18132 NULL
95658 +tps65910_gpio_set_18135 tps65910_gpio_set 2 18135 NULL
95659 +selinux_inode_setsecurity_18148 selinux_inode_setsecurity 4 18148 NULL
95660 +is_idx_node_in_use_18165 is_idx_node_in_use 0 18165 NULL
95661 +_has_tag_18169 _has_tag 2 18169 NULL
95662 +pccard_store_cis_18176 pccard_store_cis 6 18176 NULL
95663 +snd_pcm_hw_refine_user_18204 snd_pcm_hw_refine_user 0 18204 NULL
95664 +orinoco_add_extscan_result_18207 orinoco_add_extscan_result 3 18207 NULL
95665 +gsm_control_message_18209 gsm_control_message 4 18209 NULL
95666 +do_ipv6_setsockopt_18215 do_ipv6_setsockopt 5 18215 NULL
95667 +gnttab_alloc_grant_references_18240 gnttab_alloc_grant_references 1 18240 NULL
95668 +snd_ctl_ioctl_compat_18250 snd_ctl_ioctl_compat 3 18250 NULL
95669 +qdisc_class_hash_alloc_18262 qdisc_class_hash_alloc 1 18262 NULL
95670 +gfs2_alloc_sort_buffer_18275 gfs2_alloc_sort_buffer 1 18275 NULL
95671 +alloc_ring_18278 alloc_ring 2-4 18278 NULL
95672 +find_dirty_idx_leb_18280 find_dirty_idx_leb 0 18280 NULL
95673 +nouveau_subdev_create__18281 nouveau_subdev_create_ 7 18281 NULL nohasharray
95674 +bio_phys_segments_18281 bio_phys_segments 0 18281 &nouveau_subdev_create__18281
95675 +ext4_readpages_18283 ext4_readpages 4 18283 NULL
95676 +mmc_send_bus_test_18285 mmc_send_bus_test 4 18285 NULL
95677 +um_idi_write_18293 um_idi_write 3 18293 NULL
95678 +ip6ip6_err_18308 ip6ip6_err 5 18308 NULL
95679 +vga_r_18310 vga_r 0 18310 NULL
95680 +ecryptfs_send_message_18322 ecryptfs_send_message 2 18322 NULL
95681 +bio_integrity_advance_18324 bio_integrity_advance 2 18324 NULL
95682 +wm8994_gpio_direction_out_18337 wm8994_gpio_direction_out 2 18337 NULL
95683 +pwr_power_save_off_read_18355 pwr_power_save_off_read 3 18355 NULL
95684 +xlbd_reserve_minors_18365 xlbd_reserve_minors 1-2 18365 NULL
95685 +ep_io_18367 ep_io 0 18367 NULL
95686 +lp872x_update_bits_18368 lp872x_update_bits 2 18368 NULL
95687 +irq_find_mapping_18388 irq_find_mapping 0-2 18388 NULL
95688 +__video_register_device_18399 __video_register_device 3 18399 NULL
95689 +reada_tree_block_flagged_18402 reada_tree_block_flagged 3 18402 NULL nohasharray
95690 +adis16136_show_serial_18402 adis16136_show_serial 3 18402 &reada_tree_block_flagged_18402
95691 +crystalhd_user_data_18407 crystalhd_user_data 3 18407 NULL
95692 +usbnet_write_cmd_nopm_18426 usbnet_write_cmd_nopm 7 18426 NULL
95693 +batadv_orig_node_add_if_18433 batadv_orig_node_add_if 2 18433 NULL
95694 +snd_hda_get_connections_18437 snd_hda_get_connections 0 18437 NULL
95695 +fuse_perform_write_18457 fuse_perform_write 4 18457 NULL
95696 +regset_tls_set_18459 regset_tls_set 4 18459 NULL
95697 +dma_alloc_from_contiguous_18466 dma_alloc_from_contiguous 3-2 18466 NULL
95698 +pci_vpd_lrdt_size_18479 pci_vpd_lrdt_size 0 18479 NULL
95699 +udpv6_setsockopt_18487 udpv6_setsockopt 5 18487 NULL
95700 +snd_gus_dram_poke_18525 snd_gus_dram_poke 4 18525 NULL
95701 +nouveau_fifo_channel_create__18530 nouveau_fifo_channel_create_ 5-6-9 18530 NULL
95702 +seq_copy_in_user_18543 seq_copy_in_user 3 18543 NULL
95703 +acpi_register_gsi_ioapic_18550 acpi_register_gsi_ioapic 2 18550 NULL
95704 +sas_change_queue_depth_18555 sas_change_queue_depth 2 18555 NULL
95705 +smk_write_rules_list_18565 smk_write_rules_list 3 18565 NULL
95706 +debug_output_18575 debug_output 3 18575 NULL
95707 +check_lpt_type_18577 check_lpt_type 0 18577 NULL
95708 +__netdev_alloc_skb_18595 __netdev_alloc_skb 2 18595 NULL
95709 +filemap_fdatawait_range_18600 filemap_fdatawait_range 0 18600 NULL nohasharray
95710 +slabinfo_write_18600 slabinfo_write 3 18600 &filemap_fdatawait_range_18600
95711 +iowarrior_write_18604 iowarrior_write 3 18604 NULL
95712 +batadv_arp_get_type_18609 batadv_arp_get_type 3 18609 NULL
95713 +from_buffer_18625 from_buffer 3 18625 NULL
95714 +f1x_map_sysaddr_to_csrow_18628 f1x_map_sysaddr_to_csrow 2 18628 NULL
95715 +snd_pcm_oss_write3_18657 snd_pcm_oss_write3 0-3 18657 NULL
95716 +ieee80211_if_fmt_rssi_threshold_18664 ieee80211_if_fmt_rssi_threshold 3 18664 NULL
95717 +unmap_page_18665 unmap_page 2-3 18665 NULL
95718 +edge_tty_recv_18667 edge_tty_recv 4 18667 NULL nohasharray
95719 +xfs_iext_insert_18667 xfs_iext_insert 3 18667 &edge_tty_recv_18667
95720 +replay_log_leb_18704 replay_log_leb 3 18704 NULL
95721 +iwl_dbgfs_rx_handlers_read_18708 iwl_dbgfs_rx_handlers_read 3 18708 NULL
95722 +ceph_alloc_page_vector_18710 ceph_alloc_page_vector 1 18710 NULL
95723 +ocfs2_trim_extent_18711 ocfs2_trim_extent 4-3 18711 NULL
95724 +blk_rq_bytes_18715 blk_rq_bytes 0 18715 NULL
95725 +snd_als4k_gcr_read_addr_18741 snd_als4k_gcr_read_addr 0 18741 NULL
95726 +o2hb_debug_create_18744 o2hb_debug_create 4 18744 NULL
95727 +__erst_read_to_erange_from_nvram_18748 __erst_read_to_erange_from_nvram 0 18748 NULL
95728 +wep_packets_read_18751 wep_packets_read 3 18751 NULL
95729 +md_compat_ioctl_18764 md_compat_ioctl 4 18764 NULL
95730 +read_file_dump_nfcal_18766 read_file_dump_nfcal 3 18766 NULL
95731 +ffs_epfile_read_18775 ffs_epfile_read 3 18775 NULL
95732 +alloc_fcdev_18780 alloc_fcdev 1 18780 NULL
95733 +fat_compat_dir_ioctl_18800 fat_compat_dir_ioctl 3 18800 NULL
95734 +ieee80211_auth_challenge_18810 ieee80211_auth_challenge 3 18810 NULL
95735 +setup_ioapic_irq_18813 setup_ioapic_irq 1 18813 NULL
95736 +sys_modify_ldt_18824 sys_modify_ldt 3 18824 NULL
95737 +mtf_test_write_18844 mtf_test_write 3 18844 NULL
95738 +drm_ht_create_18853 drm_ht_create 2 18853 NULL
95739 +sctp_setsockopt_events_18862 sctp_setsockopt_events 3 18862 NULL
95740 +ieee80211_if_read_element_ttl_18869 ieee80211_if_read_element_ttl 3 18869 NULL
95741 +xlog_find_verify_log_record_18870 xlog_find_verify_log_record 2 18870 NULL
95742 +width_to_agaw_18883 width_to_agaw 0-1 18883 NULL
95743 +ceph_setxattr_18913 ceph_setxattr 4 18913 NULL
95744 +mangle_packet_18920 mangle_packet 7-9 18920 NULL
95745 +snapshot_write_next_18937 snapshot_write_next 0 18937 NULL
95746 +__nla_reserve_18974 __nla_reserve 3 18974 NULL
95747 +alc_auto_create_extra_outs_18975 alc_auto_create_extra_outs 2 18975 NULL
95748 +find_dirtiest_idx_leb_19001 find_dirtiest_idx_leb 0 19001 NULL
95749 +layout_in_gaps_19006 layout_in_gaps 2 19006 NULL
95750 +huge_page_size_19008 huge_page_size 0 19008 NULL
95751 +usbdev_compat_ioctl_19026 usbdev_compat_ioctl 3 19026 NULL
95752 +prepare_highmem_image_19028 prepare_highmem_image 0 19028 NULL
95753 +revalidate_19043 revalidate 2 19043 NULL
95754 +drm_fb_helper_init_19044 drm_fb_helper_init 3-4 19044 NULL
95755 +create_gpadl_header_19064 create_gpadl_header 2 19064 NULL
95756 +ieee80211_key_alloc_19065 ieee80211_key_alloc 3 19065 NULL
95757 +copy_and_check_19089 copy_and_check 3 19089 NULL
95758 +sys_process_vm_readv_19090 sys_process_vm_readv 3-5 19090 NULL nohasharray
95759 +brcmf_usbdev_qinit_19090 brcmf_usbdev_qinit 2 19090 &sys_process_vm_readv_19090
95760 +sta_last_seq_ctrl_read_19106 sta_last_seq_ctrl_read 3 19106 NULL
95761 +cifs_readv_from_socket_19109 cifs_readv_from_socket 3 19109 NULL
95762 +skb_gro_offset_19123 skb_gro_offset 0 19123 NULL
95763 +ext4_inode_table_19125 ext4_inode_table 0 19125 NULL
95764 +snd_als4k_iobase_readl_19136 snd_als4k_iobase_readl 0 19136 NULL
95765 +alloc_irdadev_19140 alloc_irdadev 1 19140 NULL
95766 +sleep_auth_read_19159 sleep_auth_read 3 19159 NULL
95767 +smk_write_access2_19170 smk_write_access2 3 19170 NULL
95768 +iwl_dbgfs_reply_tx_error_read_19205 iwl_dbgfs_reply_tx_error_read 3 19205 NULL
95769 +vmw_unlocked_ioctl_19212 vmw_unlocked_ioctl 2 19212 NULL
95770 +__copy_to_user_inatomic_19214 __copy_to_user_inatomic 3 19214 NULL
95771 +dev_counters_read_19216 dev_counters_read 3 19216 NULL
95772 +wbcir_tx_19219 wbcir_tx 3 19219 NULL
95773 +gsi_to_irq_19220 gsi_to_irq 0-1 19220 NULL
95774 +snd_mask_max_19224 snd_mask_max 0 19224 NULL
95775 +snd_pcm_capture_rewind_19229 snd_pcm_capture_rewind 0-2 19229 NULL
95776 +bio_alloc_mddev_19238 bio_alloc_mddev 2 19238 NULL
95777 +sys_fcntl_19267 sys_fcntl 3 19267 NULL
95778 +il_dbgfs_rxon_filter_flags_read_19281 il_dbgfs_rxon_filter_flags_read 3 19281 NULL
95779 +io_mapping_map_wc_19284 io_mapping_map_wc 2 19284 NULL
95780 +qc_capture_19298 qc_capture 3 19298 NULL
95781 +ocfs2_prepare_inode_for_refcount_19303 ocfs2_prepare_inode_for_refcount 3-4 19303 NULL
95782 +event_tx_stuck_read_19305 event_tx_stuck_read 3 19305 NULL
95783 +debug_read_19322 debug_read 3 19322 NULL
95784 +cfg80211_inform_bss_19332 cfg80211_inform_bss 8 19332 NULL
95785 +read_zero_19366 read_zero 3 19366 NULL
95786 +interpret_user_input_19393 interpret_user_input 2 19393 NULL
95787 +get_unaligned_be16_19400 get_unaligned_be16 0 19400 NULL
95788 +get_n_events_by_type_19401 get_n_events_by_type 0 19401 NULL
95789 +dvbdmx_write_19423 dvbdmx_write 3 19423 NULL
95790 +__phys_addr_19434 __phys_addr 0 19434 NULL
95791 +xfrm_alg_auth_len_19454 xfrm_alg_auth_len 0 19454 NULL
95792 +hpet_compat_ioctl_19455 hpet_compat_ioctl 3 19455 NULL
95793 +gnet_stats_copy_19458 gnet_stats_copy 4 19458 NULL
95794 +sky2_read16_19475 sky2_read16 0 19475 NULL
95795 +efivar_create_sysfs_entry_19485 efivar_create_sysfs_entry 2 19485 NULL
95796 +ext4_add_new_descs_19509 ext4_add_new_descs 3 19509 NULL
95797 +skb_realloc_headroom_19516 skb_realloc_headroom 2 19516 NULL
95798 +dev_alloc_skb_19517 dev_alloc_skb 1 19517 NULL
95799 +nfc_llcp_build_tlv_19536 nfc_llcp_build_tlv 3 19536 NULL
95800 +gfn_to_index_19558 gfn_to_index 0-1-3-2 19558 NULL
95801 +ocfs2_control_message_19564 ocfs2_control_message 3 19564 NULL
95802 +ieee80211_if_read_tkip_mic_test_19565 ieee80211_if_read_tkip_mic_test 3 19565 NULL nohasharray
95803 +wlcore_hw_get_rx_packet_len_19565 wlcore_hw_get_rx_packet_len 0 19565 &ieee80211_if_read_tkip_mic_test_19565
95804 +nfsd_read_19568 nfsd_read 5 19568 NULL
95805 +cgroup_read_s64_19570 cgroup_read_s64 5 19570 NULL
95806 +bm_status_read_19583 bm_status_read 3 19583 NULL
95807 +batadv_tt_update_orig_19586 batadv_tt_update_orig 4 19586 NULL
95808 +load_xattr_datum_19594 load_xattr_datum 0 19594 NULL
95809 +usbvision_rvmalloc_19655 usbvision_rvmalloc 1 19655 NULL
95810 +LoadBitmap_19658 LoadBitmap 2 19658 NULL
95811 +usbnet_write_cmd_19679 usbnet_write_cmd 7 19679 NULL
95812 +read_reg_19723 read_reg 0 19723 NULL
95813 +wm8350_block_write_19727 wm8350_block_write 3-2 19727 NULL
95814 +memcpy_toiovecend_19736 memcpy_toiovecend 4-3 19736 NULL
95815 +snd_es1968_get_dma_ptr_19747 snd_es1968_get_dma_ptr 0 19747 NULL
95816 +p9_client_read_19750 p9_client_read 5 19750 NULL
95817 +pnpbios_proc_write_19758 pnpbios_proc_write 3 19758 NULL
95818 +ocfs2_readpages_19759 ocfs2_readpages 4 19759 NULL
95819 +jffs2_acl_from_medium_19762 jffs2_acl_from_medium 2 19762 NULL
95820 +__set_print_fmt_19776 __set_print_fmt 0 19776 NULL
95821 +saa7146_vmalloc_build_pgtable_19780 saa7146_vmalloc_build_pgtable 2 19780 NULL
95822 +irda_setsockopt_19824 irda_setsockopt 5 19824 NULL
95823 +pcpu_next_unpop_19831 pcpu_next_unpop 4 19831 NULL
95824 +vip_read_19832 vip_read 3 19832 NULL nohasharray
95825 +vfs_getxattr_19832 vfs_getxattr 0 19832 &vip_read_19832
95826 +security_context_to_sid_19839 security_context_to_sid 2 19839 NULL
95827 +crypt_alloc_buffer_19846 crypt_alloc_buffer 2 19846 NULL
95828 +cfg80211_mlme_register_mgmt_19852 cfg80211_mlme_register_mgmt 5 19852 NULL
95829 +__nla_put_19857 __nla_put 3 19857 NULL
95830 +ip6gre_err_19869 ip6gre_err 5 19869 NULL
95831 +aes_decrypt_interrupt_read_19910 aes_decrypt_interrupt_read 3 19910 NULL
95832 +ps_upsd_max_apturn_read_19918 ps_upsd_max_apturn_read 3 19918 NULL
95833 +cgroup_task_count_19930 cgroup_task_count 0 19930 NULL
95834 +iwl_dbgfs_rx_queue_read_19943 iwl_dbgfs_rx_queue_read 3 19943 NULL
95835 +attach_hdlc_protocol_19986 attach_hdlc_protocol 3 19986 NULL
95836 +diva_um_idi_read_20003 diva_um_idi_read 0 20003 NULL
95837 +split_scan_timeout_read_20029 split_scan_timeout_read 3 20029 NULL
95838 +__be32_to_cpup_20056 __be32_to_cpup 0 20056 NULL
95839 +alloc_ieee80211_20063 alloc_ieee80211 1 20063 NULL
95840 +rawv6_sendmsg_20080 rawv6_sendmsg 4 20080 NULL
95841 +fuse_conn_limit_read_20084 fuse_conn_limit_read 3 20084 NULL
95842 +team_options_register_20091 team_options_register 3 20091 NULL
95843 +qla2x00_adjust_sdev_qdepth_up_20097 qla2x00_adjust_sdev_qdepth_up 2 20097 NULL
95844 +hptiop_adjust_disk_queue_depth_20122 hptiop_adjust_disk_queue_depth 2 20122 NULL
95845 +tomoyo_commit_ok_20167 tomoyo_commit_ok 2 20167 NULL
95846 +read_flush_pipefs_20171 read_flush_pipefs 3 20171 NULL
95847 +wep_addr_key_count_read_20174 wep_addr_key_count_read 3 20174 NULL
95848 +create_trace_probe_20175 create_trace_probe 1 20175 NULL
95849 +udf_bitmap_new_block_20214 udf_bitmap_new_block 4 20214 NULL
95850 +pvr2_ctrl_value_to_sym_20229 pvr2_ctrl_value_to_sym 5 20229 NULL
95851 +rose_sendmsg_20249 rose_sendmsg 4 20249 NULL
95852 +tm6000_i2c_send_regs_20250 tm6000_i2c_send_regs 5 20250 NULL
95853 +pcpu_alloc_20255 pcpu_alloc 1-2 20255 NULL
95854 +resource_size_20256 resource_size 0 20256 NULL
95855 +_rtl92s_get_h2c_cmdlen_20312 _rtl92s_get_h2c_cmdlen 0 20312 NULL
95856 +tx_tx_burst_programmed_read_20320 tx_tx_burst_programmed_read 3 20320 NULL
95857 +snd_cs4281_BA1_read_20323 snd_cs4281_BA1_read 5 20323 NULL
95858 +gfs2_glock_nq_m_20347 gfs2_glock_nq_m 1 20347 NULL
95859 +qla82xx_pci_mem_read_direct_20368 qla82xx_pci_mem_read_direct 2 20368 NULL
95860 +snd_pcm_stop_20376 snd_pcm_stop 0 20376 NULL
95861 +smk_set_cipso_20379 smk_set_cipso 3 20379 NULL
95862 +u64_to_uptr_20384 u64_to_uptr 1 20384 NULL
95863 +snd_nm256_readl_20394 snd_nm256_readl 0 20394 NULL
95864 +__kfifo_from_user_20399 __kfifo_from_user 3 20399 NULL
95865 +pm860x_write_reg_cache_20448 pm860x_write_reg_cache 2 20448 NULL
95866 +nfs3_setxattr_20458 nfs3_setxattr 4 20458 NULL
95867 +ip_vs_icmp_xmit_v6_20464 ip_vs_icmp_xmit_v6 4 20464 NULL
95868 +compat_ipv6_setsockopt_20468 compat_ipv6_setsockopt 5 20468 NULL
95869 +read_buf_20469 read_buf 2 20469 NULL
95870 +btrfs_get_32_20476 btrfs_get_32 0 20476 NULL
95871 +fast_user_write_20494 fast_user_write 5 20494 NULL
95872 +ocfs2_db_frozen_trigger_20503 ocfs2_db_frozen_trigger 4 20503 NULL nohasharray
95873 +hidraw_report_event_20503 hidraw_report_event 3 20503 &ocfs2_db_frozen_trigger_20503
95874 +pcpu_alloc_area_20511 pcpu_alloc_area 0-3 20511 NULL
95875 +pcpu_depopulate_chunk_20517 pcpu_depopulate_chunk 2-3 20517 NULL
95876 +xfs_iext_realloc_direct_20521 xfs_iext_realloc_direct 2 20521 NULL
95877 +drbd_bm_resize_20522 drbd_bm_resize 2 20522 NULL
95878 +amd_create_gatt_pages_20537 amd_create_gatt_pages 1 20537 NULL
95879 +scsi_report_opcode_20551 scsi_report_opcode 3 20551 NULL
95880 +venus_create_20555 venus_create 4 20555 NULL
95881 +btrfs_super_log_root_20565 btrfs_super_log_root 0 20565 NULL
95882 +crypto_ahash_reqsize_20569 crypto_ahash_reqsize 0 20569 NULL
95883 +rc5t583_set_bits_20573 rc5t583_set_bits 2 20573 NULL
95884 +i915_max_freq_read_20581 i915_max_freq_read 3 20581 NULL
95885 +batadv_tt_append_diff_20588 batadv_tt_append_diff 4 20588 NULL
95886 +lirc_write_20604 lirc_write 3 20604 NULL
95887 +qib_qsfp_write_20614 qib_qsfp_write 0-4-2 20614 NULL
95888 +snd_pcm_oss_prepare_20641 snd_pcm_oss_prepare 0 20641 NULL
95889 +kfifo_copy_to_user_20646 kfifo_copy_to_user 3 20646 NULL
95890 +cpulist_scnprintf_20648 cpulist_scnprintf 0-2 20648 NULL
95891 +oz_add_farewell_20652 oz_add_farewell 5 20652 NULL
95892 +ceph_osdc_new_request_20654 ceph_osdc_new_request 15-4 20654 NULL
95893 +oz_cdev_read_20659 oz_cdev_read 3 20659 NULL
95894 +sec_reg_write_20667 sec_reg_write 2 20667 NULL
95895 +tps65910_reg_clear_bits_20672 tps65910_reg_clear_bits 2 20672 NULL
95896 +snd_hdsp_playback_copy_20676 snd_hdsp_playback_copy 5 20676 NULL
95897 +dvb_dmxdev_buffer_read_20682 dvb_dmxdev_buffer_read 0-4 20682 NULL
95898 +cpumask_size_20683 cpumask_size 0 20683 NULL
95899 +btrfs_node_blockptr_20685 btrfs_node_blockptr 0 20685 NULL
95900 +read_file_tgt_int_stats_20697 read_file_tgt_int_stats 3 20697 NULL
95901 +__maestro_read_20700 __maestro_read 0 20700 NULL
95902 +cipso_v4_gentag_rng_20703 cipso_v4_gentag_rng 0 20703 NULL
95903 +pcpu_page_first_chunk_20712 pcpu_page_first_chunk 1 20712 NULL
95904 +ocfs2_read_xattr_bucket_20722 ocfs2_read_xattr_bucket 0 20722 NULL
95905 +security_context_to_sid_force_20724 security_context_to_sid_force 2 20724 NULL
95906 +vring_add_indirect_20737 vring_add_indirect 3-4 20737 NULL
95907 +io_apic_set_pci_routing_20740 io_apic_set_pci_routing 2 20740 NULL
95908 +vol_cdev_direct_write_20751 vol_cdev_direct_write 3 20751 NULL
95909 +ocfs2_align_bytes_to_clusters_20754 ocfs2_align_bytes_to_clusters 2 20754 NULL
95910 +ubi_io_read_20767 ubi_io_read 0 20767 NULL
95911 +fb_alloc_cmap_gfp_20792 fb_alloc_cmap_gfp 2 20792 NULL
95912 +iommu_range_alloc_20794 iommu_range_alloc 3 20794 NULL
95913 +iwl_dbgfs_rxon_flags_read_20795 iwl_dbgfs_rxon_flags_read 3 20795 NULL
95914 +sys_sendto_20809 sys_sendto 6 20809 NULL
95915 +strndup_user_20819 strndup_user 2 20819 NULL
95916 +wl1271_format_buffer_20834 wl1271_format_buffer 2 20834 NULL
95917 +uvc_alloc_entity_20836 uvc_alloc_entity 4-3 20836 NULL
95918 +snd_pcm_capture_avail_20867 snd_pcm_capture_avail 0 20867 NULL
95919 +ocfs2_bmap_20874 ocfs2_bmap 2 20874 NULL
95920 +sisusb_send_packet_20891 sisusb_send_packet 2 20891 NULL
95921 +key_icverrors_read_20895 key_icverrors_read 3 20895 NULL
95922 +vfio_msi_enable_20906 vfio_msi_enable 2 20906 NULL
95923 +compat_sys_readv_20911 compat_sys_readv 3 20911 NULL
95924 +htable_bits_20933 htable_bits 0 20933 NULL
95925 +altera_set_ir_post_20948 altera_set_ir_post 2 20948 NULL
95926 +rx_rx_phy_hdr_read_20950 rx_rx_phy_hdr_read 3 20950 NULL
95927 +snd_rme9652_playback_copy_20970 snd_rme9652_playback_copy 5 20970 NULL
95928 +brcmf_tx_frame_20978 brcmf_tx_frame 3 20978 NULL
95929 +alg_setsockopt_20985 alg_setsockopt 5 20985 NULL
95930 +ocfs2_free_clusters_21001 ocfs2_free_clusters 4 21001 NULL
95931 +btrfs_inode_ref_name_len_21024 btrfs_inode_ref_name_len 0 21024 NULL
95932 +rx_defrag_tkip_called_read_21031 rx_defrag_tkip_called_read 3 21031 NULL
95933 +lbs_threshold_read_21046 lbs_threshold_read 5 21046 NULL
95934 +proc_fault_inject_write_21058 proc_fault_inject_write 3 21058 NULL
95935 +event_calibration_read_21083 event_calibration_read 3 21083 NULL
95936 +compat_sock_ioctl_trans_21092 compat_sock_ioctl_trans 4 21092 NULL
95937 +__cfg80211_send_disassoc_21096 __cfg80211_send_disassoc 3 21096 NULL
95938 +ext2_valid_block_bitmap_21101 ext2_valid_block_bitmap 3 21101 NULL
95939 +ath6kl_send_go_probe_resp_21113 ath6kl_send_go_probe_resp 3 21113 NULL
95940 +i2400m_rx_trace_21127 i2400m_rx_trace 3 21127 NULL
95941 +tps6586x_irq_init_21144 tps6586x_irq_init 3 21144 NULL
95942 +ocfs2_block_check_validate_21149 ocfs2_block_check_validate 2 21149 NULL
95943 +ath6kl_mgmt_tx_21153 ath6kl_mgmt_tx 9 21153 NULL
95944 +setup_msi_irq_21169 setup_msi_irq 3 21169 NULL
95945 +cx18_v4l2_read_21196 cx18_v4l2_read 3 21196 NULL
95946 +ipc_rcu_alloc_21208 ipc_rcu_alloc 1 21208 NULL
95947 +_ocfs2_free_clusters_21220 _ocfs2_free_clusters 4 21220 NULL
95948 +get_numpages_21227 get_numpages 0-1-2 21227 NULL
95949 +input_ff_create_21240 input_ff_create 2 21240 NULL
95950 +cfg80211_notify_new_peer_candidate_21242 cfg80211_notify_new_peer_candidate 4 21242 NULL
95951 +ocfs2_blocks_for_bytes_21268 ocfs2_blocks_for_bytes 0-2 21268 NULL
95952 +ip_vs_icmp_xmit_21269 ip_vs_icmp_xmit 4 21269 NULL
95953 +rc5t583_clear_bits_21300 rc5t583_clear_bits 2 21300 NULL
95954 +vmw_gmr2_bind_21305 vmw_gmr2_bind 3 21305 NULL
95955 +do_msg_fill_21307 do_msg_fill 3 21307 NULL
95956 +add_res_range_21310 add_res_range 4 21310 NULL
95957 +get_zeroed_page_21322 get_zeroed_page 0 21322 NULL
95958 +ftrace_profile_read_21327 ftrace_profile_read 3 21327 NULL
95959 +gfs2_ea_get_copy_21353 gfs2_ea_get_copy 0 21353 NULL
95960 +max77693_irq_domain_map_21357 max77693_irq_domain_map 2 21357 NULL
95961 +alloc_orinocodev_21371 alloc_orinocodev 1 21371 NULL
95962 +video_ioctl2_21380 video_ioctl2 2 21380 NULL
95963 +diva_get_driver_dbg_mask_21399 diva_get_driver_dbg_mask 0 21399 NULL
95964 +snd_m3_inw_21406 snd_m3_inw 0 21406 NULL
95965 +snapshot_read_next_21426 snapshot_read_next 0 21426 NULL
95966 +tcp_bound_to_half_wnd_21429 tcp_bound_to_half_wnd 0-2 21429 NULL
95967 +tracing_saved_cmdlines_read_21434 tracing_saved_cmdlines_read 3 21434 NULL
95968 +aggr_size_tx_agg_vs_rate_read_21438 aggr_size_tx_agg_vs_rate_read 3 21438 NULL
95969 +btrfs_iref_to_path_21445 btrfs_iref_to_path 7 21445 NULL
95970 +__ertm_hdr_size_21450 __ertm_hdr_size 0 21450 NULL
95971 +concat_writev_21451 concat_writev 3 21451 NULL
95972 +extend_netdev_table_21453 extend_netdev_table 2 21453 NULL
95973 +read_file_xmit_21487 read_file_xmit 3 21487 NULL
95974 +mmc_alloc_sg_21504 mmc_alloc_sg 1 21504 NULL
95975 +btrfs_file_aio_write_21520 btrfs_file_aio_write 4 21520 NULL
95976 +il_dbgfs_stations_read_21532 il_dbgfs_stations_read 3 21532 NULL
95977 +cipso_v4_map_cat_enum_hton_21540 cipso_v4_map_cat_enum_hton 0 21540 NULL
95978 +rxrpc_send_data_21553 rxrpc_send_data 5 21553 NULL
95979 +rx_rx_beacon_early_term_read_21559 rx_rx_beacon_early_term_read 3 21559 NULL
95980 +xfs_buf_read_uncached_21585 xfs_buf_read_uncached 3 21585 NULL
95981 +ocfs2_acl_from_xattr_21604 ocfs2_acl_from_xattr 2 21604 NULL
95982 +xlog_do_recovery_pass_21618 xlog_do_recovery_pass 3 21618 NULL
95983 +__jfs_getxattr_21631 __jfs_getxattr 0 21631 NULL
95984 +rbd_req_sync_op_21632 rbd_req_sync_op 7-8 21632 NULL
95985 +validate_nnode_21638 validate_nnode 0 21638 NULL
95986 +__irq_alloc_descs_21639 __irq_alloc_descs 2-1-3 21639 NULL
95987 +carl9170_rx_copy_data_21656 carl9170_rx_copy_data 2 21656 NULL
95988 +hpet_setup_msi_irq_21662 hpet_setup_msi_irq 1 21662 NULL
95989 +atalk_sendmsg_21677 atalk_sendmsg 4 21677 NULL
95990 +ocfs2_xattr_get_nolock_21678 ocfs2_xattr_get_nolock 0 21678 NULL
95991 +regmap_register_patch_21681 regmap_register_patch 3 21681 NULL
95992 +rtllib_alloc_txb_21687 rtllib_alloc_txb 1-2 21687 NULL
95993 +evdev_ioctl_handler_21705 evdev_ioctl_handler 2 21705 NULL
95994 +reiserfs_allocate_list_bitmaps_21732 reiserfs_allocate_list_bitmaps 3 21732 NULL
95995 +__nf_nat_mangle_tcp_packet_21744 __nf_nat_mangle_tcp_packet 8-6 21744 NULL
95996 +mthca_alloc_init_21754 mthca_alloc_init 2 21754 NULL
95997 +gen_pool_add_21776 gen_pool_add 3 21776 NULL
95998 +xfs_da_grow_inode_int_21785 xfs_da_grow_inode_int 3 21785 NULL
95999 +__ioremap_caller_21800 __ioremap_caller 1-2 21800 NULL
96000 +dvb_generic_ioctl_21810 dvb_generic_ioctl 2 21810 NULL
96001 +wm8994_request_irq_21822 wm8994_request_irq 2 21822 NULL
96002 +oom_adj_read_21847 oom_adj_read 3 21847 NULL
96003 +acpi_tb_check_xsdt_21862 acpi_tb_check_xsdt 1 21862 NULL
96004 +lpfc_idiag_extacc_avail_get_21865 lpfc_idiag_extacc_avail_get 0-3 21865 NULL
96005 +brcms_debugfs_hardware_read_21867 brcms_debugfs_hardware_read 3 21867 NULL
96006 +sisusbcon_bmove_21873 sisusbcon_bmove 6-5-7 21873 NULL nohasharray
96007 +tcp_cookie_size_check_21873 tcp_cookie_size_check 0-1 21873 &sisusbcon_bmove_21873
96008 +__alloc_reserved_percpu_21895 __alloc_reserved_percpu 1-2 21895 NULL
96009 +rio_destid_first_21900 rio_destid_first 0 21900 NULL
96010 +dbAllocCtl_21911 dbAllocCtl 0 21911 NULL
96011 +qsfp_1_read_21915 qsfp_1_read 3 21915 NULL
96012 +rbd_req_read_21952 rbd_req_read 4-5 21952 NULL
96013 +security_mmap_addr_21970 security_mmap_addr 0 21970 NULL
96014 +alloc_ldt_21972 alloc_ldt 2 21972 NULL
96015 +rxpipe_descr_host_int_trig_rx_data_read_22001 rxpipe_descr_host_int_trig_rx_data_read 3 22001 NULL nohasharray
96016 +compat_rw_copy_check_uvector_22001 compat_rw_copy_check_uvector 0-3 22001 &rxpipe_descr_host_int_trig_rx_data_read_22001
96017 +btrfs_get_16_22023 btrfs_get_16 0 22023 NULL
96018 +ti_recv_22027 ti_recv 4 22027 NULL
96019 +pcf50633_irq_unmask_22034 pcf50633_irq_unmask 2 22034 NULL
96020 +zd_usb_read_fw_22049 zd_usb_read_fw 4 22049 NULL
96021 +ieee80211_if_fmt_dropped_frames_ttl_22054 ieee80211_if_fmt_dropped_frames_ttl 3 22054 NULL
96022 +btrfs_reloc_clone_csums_22077 btrfs_reloc_clone_csums 2 22077 NULL
96023 +mem_rw_22085 mem_rw 3 22085 NULL
96024 +snd_pcm_xrun_22088 snd_pcm_xrun 0 22088 NULL
96025 +lowpan_fragment_xmit_22095 lowpan_fragment_xmit 3-4 22095 NULL
96026 +sys_remap_file_pages_22124 sys_remap_file_pages 1 22124 NULL
96027 +__bitmap_size_22138 __bitmap_size 0 22138 NULL
96028 +compat_insn_22142 compat_insn 2 22142 NULL
96029 +pn533_dep_link_up_22154 pn533_dep_link_up 5 22154 NULL
96030 +do_tcp_sendpages_22155 do_tcp_sendpages 4 22155 NULL
96031 +__kfifo_alloc_22173 __kfifo_alloc 2-3 22173 NULL
96032 +fls_22210 fls 0 22210 NULL
96033 +bio_chain_clone_22227 bio_chain_clone 4 22227 NULL
96034 +mem_write_22232 mem_write 3 22232 NULL
96035 +p9_virtio_zc_request_22240 p9_virtio_zc_request 6-5 22240 NULL
96036 +atomic64_xchg_22246 atomic64_xchg 0 22246 NULL
96037 +compat_process_vm_rw_22254 compat_process_vm_rw 3-5 22254 NULL
96038 +__btrfs_direct_write_22273 __btrfs_direct_write 4 22273 NULL
96039 +queue_max_sectors_22280 queue_max_sectors 0 22280 NULL
96040 +pci_vpd_srdt_size_22300 pci_vpd_srdt_size 0 22300 NULL nohasharray
96041 +__tun_chr_ioctl_22300 __tun_chr_ioctl 4 22300 &pci_vpd_srdt_size_22300
96042 +mesh_table_alloc_22305 mesh_table_alloc 1 22305 NULL
96043 +get_segment_base_22324 get_segment_base 0 22324 NULL
96044 +radix_tree_find_next_bit_22334 radix_tree_find_next_bit 2-3 22334 NULL
96045 +atomic_read_22342 atomic_read 0 22342 NULL
96046 +mlx4_db_alloc_22358 mlx4_db_alloc 3 22358 NULL
96047 +irq_reserve_irq_22360 irq_reserve_irq 1 22360 NULL
96048 +snd_pcm_alsa_frames_22363 snd_pcm_alsa_frames 2 22363 NULL
96049 +wlcore_alloc_hw_22365 wlcore_alloc_hw 1 22365 NULL nohasharray
96050 +tps6586x_gpio_to_irq_22365 tps6586x_gpio_to_irq 2 22365 &wlcore_alloc_hw_22365
96051 +evdev_ioctl_22371 evdev_ioctl 2 22371 NULL
96052 +alloc_large_system_hash_22391 alloc_large_system_hash 2 22391 NULL
96053 +btmrvl_psmode_read_22395 btmrvl_psmode_read 3 22395 NULL
96054 +zoran_write_22404 zoran_write 3 22404 NULL
96055 +queue_reply_22416 queue_reply 3 22416 NULL
96056 +__set_enter_print_fmt_22431 __set_enter_print_fmt 0 22431 NULL
96057 +queue_max_segments_22441 queue_max_segments 0 22441 NULL
96058 +handle_received_packet_22457 handle_received_packet 3 22457 NULL
96059 +mem_cgroup_read_22461 mem_cgroup_read 5 22461 NULL
96060 +cache_write_procfs_22491 cache_write_procfs 3 22491 NULL
96061 +mp_find_ioapic_pin_22499 mp_find_ioapic_pin 0-2 22499 NULL
96062 +mutex_lock_interruptible_22505 mutex_lock_interruptible 0 22505 NULL
96063 +ip4_addr_string_22511 ip4_addr_string 0 22511 NULL
96064 +pskb_may_pull_22546 pskb_may_pull 2 22546 NULL
96065 +ocfs2_read_extent_block_22550 ocfs2_read_extent_block 0 22550 NULL
96066 +atomic_long_read_unchecked_22551 atomic_long_read_unchecked 0 22551 NULL
96067 +agp_alloc_page_array_22554 agp_alloc_page_array 1 22554 NULL
96068 +dbFindCtl_22587 dbFindCtl 0 22587 NULL
96069 +snapshot_read_22601 snapshot_read 3 22601 NULL
96070 +sctp_setsockopt_connectx_old_22631 sctp_setsockopt_connectx_old 3 22631 NULL
96071 +ide_core_cp_entry_22636 ide_core_cp_entry 3 22636 NULL
96072 +wl1271_rx_filter_get_fields_size_22638 wl1271_rx_filter_get_fields_size 0 22638 NULL
96073 +pwr_wake_on_timer_exp_read_22640 pwr_wake_on_timer_exp_read 3 22640 NULL
96074 +iwl_dbgfs_calib_disabled_read_22649 iwl_dbgfs_calib_disabled_read 3 22649 NULL
96075 +ubifs_leb_write_22679 ubifs_leb_write 4-5 22679 NULL
96076 +fill_gap_22681 fill_gap 0 22681 NULL
96077 +ocfs2_get_block_22687 ocfs2_get_block 2 22687 NULL
96078 +compat_fd_ioctl_22694 compat_fd_ioctl 4 22694 NULL
96079 +alloc_libipw_22708 alloc_libipw 1 22708 NULL
96080 +brcmf_sdbrcm_read_control_22721 brcmf_sdbrcm_read_control 3 22721 NULL
96081 +cx18_copy_buf_to_user_22735 cx18_copy_buf_to_user 4 22735 NULL
96082 +ceph_decode_32_22738 ceph_decode_32 0 22738 NULL
96083 +iio_debugfs_write_reg_22742 iio_debugfs_write_reg 3 22742 NULL
96084 +print_frame_22769 print_frame 0 22769 NULL
96085 +ftrace_arch_read_dyn_info_22773 ftrace_arch_read_dyn_info 0 22773 NULL
96086 +retu_write_22800 retu_write 2 22800 NULL
96087 +compat_blkdev_ioctl_22841 compat_blkdev_ioctl 3 22841 NULL
96088 +can_nocow_odirect_22854 can_nocow_odirect 3 22854 NULL nohasharray
96089 +read_file_rcstat_22854 read_file_rcstat 3 22854 &can_nocow_odirect_22854
96090 +do_atm_iobuf_22857 do_atm_iobuf 3 22857 NULL
96091 +nfs4_realloc_slot_table_22859 nfs4_realloc_slot_table 2 22859 NULL
96092 +create_attr_set_22861 create_attr_set 1 22861 NULL
96093 +vmw_execbuf_process_22885 vmw_execbuf_process 5 22885 NULL
96094 +usblp_new_writeurb_22894 usblp_new_writeurb 2 22894 NULL
96095 +mdc800_device_read_22896 mdc800_device_read 3 22896 NULL
96096 +pcpu_mem_zalloc_22948 pcpu_mem_zalloc 1 22948 NULL
96097 +alloc_sglist_22960 alloc_sglist 1-2-3 22960 NULL
96098 +caif_seqpkt_sendmsg_22961 caif_seqpkt_sendmsg 4 22961 NULL
96099 +vme_get_size_22964 vme_get_size 0 22964 NULL
96100 +tx_frag_key_not_found_read_22971 tx_frag_key_not_found_read 3 22971 NULL
96101 +usb_get_langid_22983 usb_get_langid 0 22983 NULL
96102 +remote_settings_file_write_22987 remote_settings_file_write 3 22987 NULL
96103 +viafb_dvp0_proc_write_23023 viafb_dvp0_proc_write 3 23023 NULL
96104 +cifs_local_to_utf16_bytes_23025 cifs_local_to_utf16_bytes 0 23025 NULL
96105 +st_status_23032 st_status 5 23032 NULL
96106 +nv50_disp_chan_create__23056 nv50_disp_chan_create_ 5 23056 NULL
96107 +reiserfs_add_entry_23062 reiserfs_add_entry 4 23062 NULL
96108 +vm_map_ram_23078 vm_map_ram 2 23078 NULL nohasharray
96109 +raw_sendmsg_23078 raw_sendmsg 4 23078 &vm_map_ram_23078
96110 +qla4_82xx_pci_mem_read_2M_23081 qla4_82xx_pci_mem_read_2M 2 23081 NULL
96111 +isr_tx_procs_read_23084 isr_tx_procs_read 3 23084 NULL
96112 +lnw_gpio_irq_map_23087 lnw_gpio_irq_map 2 23087 NULL
96113 +rt2x00debug_write_eeprom_23091 rt2x00debug_write_eeprom 3 23091 NULL
96114 +fls_long_23096 fls_long 0 23096 NULL
96115 +ntfs_ucstonls_23097 ntfs_ucstonls 3-5 23097 NULL
96116 +pipe_iov_copy_from_user_23102 pipe_iov_copy_from_user 3 23102 NULL
96117 +mwl8k_cmd_set_beacon_23110 mwl8k_cmd_set_beacon 4 23110 NULL
96118 +nl80211_send_rx_auth_23111 nl80211_send_rx_auth 4 23111 NULL
96119 +__clear_user_23118 __clear_user 0 23118 NULL
96120 +dm_write_async_23120 dm_write_async 3 23120 NULL
96121 +drm_mode_create_tv_properties_23122 drm_mode_create_tv_properties 2 23122 NULL
96122 +ca91cx42_master_set_23146 ca91cx42_master_set 4 23146 NULL
96123 +wm831x_set_bits_23158 wm831x_set_bits 2 23158 NULL
96124 +read_file_ani_23161 read_file_ani 3 23161 NULL
96125 +ioremap_23172 ioremap 1-2 23172 NULL
96126 +usblp_write_23178 usblp_write 3 23178 NULL
96127 +msnd_fifo_alloc_23179 msnd_fifo_alloc 2 23179 NULL
96128 +gss_pipe_downcall_23182 gss_pipe_downcall 3 23182 NULL
96129 +ieee80211_get_mesh_hdrlen_23183 ieee80211_get_mesh_hdrlen 0 23183 NULL
96130 +fix_unclean_leb_23188 fix_unclean_leb 3 23188 NULL
96131 +mpi_alloc_limb_space_23190 mpi_alloc_limb_space 1 23190 NULL
96132 +__next_dma_cap_23195 __next_dma_cap 1 23195 NULL
96133 +convert_ip_to_linear_23198 convert_ip_to_linear 0 23198 NULL
96134 +pm80x_free_irq_23210 pm80x_free_irq 2 23210 NULL nohasharray
96135 +compat_rawv6_ioctl_23210 compat_rawv6_ioctl 3 23210 &pm80x_free_irq_23210
96136 +tty_buffer_request_room_23228 tty_buffer_request_room 2 23228 NULL
96137 +xlog_get_bp_23229 xlog_get_bp 2 23229 NULL
96138 +rxrpc_client_sendmsg_23236 rxrpc_client_sendmsg 5 23236 NULL
96139 +__gfn_to_rmap_23240 __gfn_to_rmap 1-2 23240 NULL
96140 +uwb_dev_addr_print_23282 uwb_dev_addr_print 2 23282 NULL
96141 +ipv6_skip_exthdr_23283 ipv6_skip_exthdr 0-2 23283 NULL
96142 +doc_probe_23285 doc_probe 1 23285 NULL
96143 +diva_get_trace_filter_23286 diva_get_trace_filter 0 23286 NULL
96144 +i2cdev_write_23310 i2cdev_write 3 23310 NULL
96145 +mc13xxx_get_num_regulators_dt_23344 mc13xxx_get_num_regulators_dt 0 23344 NULL
96146 +page_readlink_23346 page_readlink 3 23346 NULL
96147 +get_dst_timing_23358 get_dst_timing 0 23358 NULL
96148 +iscsi_change_queue_depth_23416 iscsi_change_queue_depth 2 23416 NULL
96149 +vga_mm_r_23419 vga_mm_r 0 23419 NULL
96150 +vzalloc_node_23424 vzalloc_node 1 23424 NULL
96151 +__cxio_init_resource_fifo_23447 __cxio_init_resource_fifo 3 23447 NULL nohasharray
96152 +ocfs2_zero_tail_23447 ocfs2_zero_tail 3 23447 &__cxio_init_resource_fifo_23447
96153 +hidraw_send_report_23449 hidraw_send_report 3 23449 NULL
96154 +linear_conf_23485 linear_conf 2 23485 NULL nohasharray
96155 +divasa_remap_pci_bar_23485 divasa_remap_pci_bar 3-4 23485 &linear_conf_23485
96156 +event_filter_read_23494 event_filter_read 3 23494 NULL
96157 +ima_show_measurements_count_23536 ima_show_measurements_count 3 23536 NULL
96158 +xen_allocate_irq_gsi_23546 xen_allocate_irq_gsi 1-0 23546 NULL
96159 +tcp_current_mss_23552 tcp_current_mss 0 23552 NULL
96160 +dbg_leb_change_23555 dbg_leb_change 4 23555 NULL
96161 +venus_symlink_23570 venus_symlink 4-6 23570 NULL
96162 +iwl_dbgfs_interrupt_read_23574 iwl_dbgfs_interrupt_read 3 23574 NULL
96163 +snd_interval_min_23590 snd_interval_min 0 23590 NULL
96164 +_alloc_cdb_cont_23609 _alloc_cdb_cont 2 23609 NULL
96165 +islpci_mgt_transaction_23610 islpci_mgt_transaction 5 23610 NULL
96166 +__i2400mu_send_barker_23652 __i2400mu_send_barker 3 23652 NULL
96167 +ext3_compat_ioctl_23659 ext3_compat_ioctl 3 23659 NULL
96168 +sInW_23663 sInW 0 23663 NULL
96169 +proc_ioctl_compat_23682 proc_ioctl_compat 2 23682 NULL
96170 +nftl_partscan_23688 nftl_partscan 0 23688 NULL
96171 +cx18_read_23699 cx18_read 3 23699 NULL
96172 +mp_config_acpi_gsi_23728 mp_config_acpi_gsi 2 23728 NULL
96173 +pack_sg_list_p_23739 pack_sg_list_p 0-2 23739 NULL
96174 +rx_rx_dropped_frame_read_23748 rx_rx_dropped_frame_read 3 23748 NULL
96175 +__kfifo_max_r_23768 __kfifo_max_r 0-2-1 23768 NULL
96176 +security_inode_getxattr_23781 security_inode_getxattr 0 23781 NULL
96177 +diva_alloc_dma_map_23798 diva_alloc_dma_map 2 23798 NULL
96178 +rx_path_reset_read_23801 rx_path_reset_read 3 23801 NULL
96179 +__earlyonly_bootmem_alloc_23824 __earlyonly_bootmem_alloc 2 23824 NULL
96180 +xfs_dir2_leaf_getdents_23841 xfs_dir2_leaf_getdents 3 23841 NULL
96181 +iwl_dbgfs_nvm_read_23845 iwl_dbgfs_nvm_read 3 23845 NULL
96182 +p54_init_common_23850 p54_init_common 1 23850 NULL
96183 +gart_alloc_coherent_23852 gart_alloc_coherent 2 23852 NULL
96184 +bin_to_hex_dup_23853 bin_to_hex_dup 2 23853 NULL
96185 +ocfs2_xattr_get_clusters_23857 ocfs2_xattr_get_clusters 0 23857 NULL
96186 +ieee80211_if_read_dot11MeshMaxPeerLinks_23878 ieee80211_if_read_dot11MeshMaxPeerLinks 3 23878 NULL
96187 +ieee80211_if_read_channel_type_23884 ieee80211_if_read_channel_type 3 23884 NULL
96188 +nes_alloc_resource_23891 nes_alloc_resource 3 23891 NULL
96189 +tipc_snprintf_23893 tipc_snprintf 2 23893 NULL
96190 +add_new_gdb_meta_bg_23911 add_new_gdb_meta_bg 3 23911 NULL nohasharray
96191 +ieee80211_if_read_hw_queues_23911 ieee80211_if_read_hw_queues 3 23911 &add_new_gdb_meta_bg_23911
96192 +f2fs_getxattr_23917 f2fs_getxattr 0 23917 NULL
96193 +ipath_reg_phys_mr_23918 ipath_reg_phys_mr 3 23918 NULL nohasharray
96194 +mpihelp_mul_karatsuba_case_23918 mpihelp_mul_karatsuba_case 5-3 23918 &ipath_reg_phys_mr_23918
96195 +kvm_read_guest_23928 kvm_read_guest 4-2 23928 NULL
96196 +__alloc_skb_23940 __alloc_skb 1 23940 NULL
96197 +uvc_endpoint_max_bpi_23944 uvc_endpoint_max_bpi 0 23944 NULL
96198 +cifs_setxattr_23957 cifs_setxattr 4 23957 NULL
96199 +zd_usb_iowrite16v_async_23984 zd_usb_iowrite16v_async 3 23984 NULL
96200 +cxgb_alloc_mem_24007 cxgb_alloc_mem 1 24007 NULL
96201 +dgrp_send_24028 dgrp_send 0-2 24028 NULL
96202 +ocfs2_mark_extent_refcounted_24035 ocfs2_mark_extent_refcounted 6 24035 NULL
96203 +afs_cell_alloc_24052 afs_cell_alloc 2 24052 NULL
96204 +blkcipher_copy_iv_24075 blkcipher_copy_iv 3 24075 NULL
96205 +vb2_fop_read_24080 vb2_fop_read 3 24080 NULL
96206 +pipeline_post_proc_swi_read_24108 pipeline_post_proc_swi_read 3 24108 NULL
96207 +request_key_auth_read_24109 request_key_auth_read 3 24109 NULL
96208 +ieee80211_send_auth_24121 ieee80211_send_auth 5 24121 NULL
96209 +mpu401_read_24126 mpu401_read 3 24126 NULL
96210 +irnet_ctrl_write_24139 irnet_ctrl_write 3 24139 NULL
96211 +trim_bitmaps_24158 trim_bitmaps 3 24158 NULL
96212 +adu_read_24177 adu_read 3 24177 NULL
96213 +safe_prepare_write_buffer_24187 safe_prepare_write_buffer 3 24187 NULL
96214 +ieee80211_if_read_dot11MeshHWMPpreqMinInterval_24208 ieee80211_if_read_dot11MeshHWMPpreqMinInterval 3 24208 NULL
96215 +efx_vf_size_24213 efx_vf_size 0 24213 NULL
96216 +tcpprobe_sprint_24222 tcpprobe_sprint 0-2 24222 NULL
96217 +pcpu_embed_first_chunk_24224 pcpu_embed_first_chunk 1-2-3 24224 NULL nohasharray
96218 +mei_amthif_read_24224 mei_amthif_read 4 24224 &pcpu_embed_first_chunk_24224
96219 +pci_num_vf_24235 pci_num_vf 0 24235 NULL
96220 +sel_read_bool_24236 sel_read_bool 3 24236 NULL
96221 +compat_sys_preadv64_24283 compat_sys_preadv64 3 24283 NULL
96222 +msg_size_24288 msg_size 0 24288 NULL
96223 +ext2_free_blocks_24292 ext2_free_blocks 2-3 24292 NULL
96224 +map_page_24298 map_page 3-4 24298 NULL
96225 +btmrvl_pscmd_read_24308 btmrvl_pscmd_read 3 24308 NULL
96226 +ath6kl_add_bss_if_needed_24317 ath6kl_add_bss_if_needed 6 24317 NULL
96227 +ocfs2_direct_IO_get_blocks_24333 ocfs2_direct_IO_get_blocks 2 24333 NULL
96228 +kzalloc_node_24352 kzalloc_node 1 24352 NULL
96229 +qla2x00_handle_queue_full_24365 qla2x00_handle_queue_full 2 24365 NULL
96230 +cfi_read_pri_24366 cfi_read_pri 3 24366 NULL
96231 +btrfs_item_size_nr_24367 btrfs_item_size_nr 0 24367 NULL
96232 +igetword_24373 igetword 0 24373 NULL
96233 +pvr2_v4l2_ioctl_24398 pvr2_v4l2_ioctl 2 24398 NULL nohasharray
96234 +getxattr_24398 getxattr 4 24398 &pvr2_v4l2_ioctl_24398
96235 +blk_update_bidi_request_24415 blk_update_bidi_request 3-4 24415 NULL
96236 +b43_debugfs_read_24425 b43_debugfs_read 3 24425 NULL
96237 +ieee80211_rx_mgmt_beacon_24430 ieee80211_rx_mgmt_beacon 3 24430 NULL
96238 +ixgbe_alloc_q_vector_24439 ixgbe_alloc_q_vector 4-6 24439 NULL
96239 +smk_user_access_24440 smk_user_access 3 24440 NULL
96240 +page_address_24444 page_address 0 24444 NULL
96241 +evdev_do_ioctl_24459 evdev_do_ioctl 2 24459 NULL
96242 +ocfs2_write_cluster_by_desc_24466 ocfs2_write_cluster_by_desc 5-6 24466 NULL
96243 +pd_video_read_24510 pd_video_read 3 24510 NULL
96244 +request_key_with_auxdata_24515 request_key_with_auxdata 4 24515 NULL
96245 +xfs_buf_get_map_24522 xfs_buf_get_map 3 24522 NULL
96246 +named_prepare_buf_24532 named_prepare_buf 2 24532 NULL
96247 +do_mpage_readpage_24536 do_mpage_readpage 3 24536 NULL
96248 +write_cache_pages_24562 write_cache_pages 0 24562 NULL
96249 +tsi148_alloc_resource_24563 tsi148_alloc_resource 2 24563 NULL
96250 +udf_compute_nr_groups_24594 udf_compute_nr_groups 0 24594 NULL
96251 +palmas_smps_write_24600 palmas_smps_write 2 24600 NULL nohasharray
96252 +count_preds_24600 count_preds 0 24600 &palmas_smps_write_24600
96253 +sensor_hub_get_physical_device_count_24605 sensor_hub_get_physical_device_count 0 24605 NULL
96254 +context_alloc_24645 context_alloc 3 24645 NULL
96255 +blk_rq_err_bytes_24650 blk_rq_err_bytes 0 24650 NULL
96256 +unifi_net_data_malloc_24716 unifi_net_data_malloc 3 24716 NULL
96257 +simple_attr_read_24738 simple_attr_read 3 24738 NULL
96258 +qla2x00_change_queue_depth_24742 qla2x00_change_queue_depth 2 24742 NULL
96259 +ath_rxbuf_alloc_24745 ath_rxbuf_alloc 2 24745 NULL
96260 +get_dma_residue_24749 get_dma_residue 0 24749 NULL
96261 +kgdb_hex2mem_24755 kgdb_hex2mem 3 24755 NULL
96262 +nfsd4_sanitize_slot_size_24756 nfsd4_sanitize_slot_size 0-1 24756 NULL
96263 +i915_cache_sharing_read_24775 i915_cache_sharing_read 3 24775 NULL
96264 +ocfs2_read_blocks_24777 ocfs2_read_blocks 0 24777 NULL
96265 +skb_make_writable_24783 skb_make_writable 2 24783 NULL
96266 +datablob_hmac_verify_24786 datablob_hmac_verify 4 24786 NULL
96267 +cache_read_24790 cache_read 3 24790 NULL
96268 +unpack_str_24798 unpack_str 0 24798 NULL
96269 +__next_cpu_nr_24805 __next_cpu_nr 1 24805 NULL
96270 +comedi_buf_alloc_24822 comedi_buf_alloc 3 24822 NULL
96271 +snd_als4k_gcr_read_24840 snd_als4k_gcr_read 0 24840 NULL
96272 +snd_pcm_lib_buffer_bytes_24865 snd_pcm_lib_buffer_bytes 0 24865 NULL
96273 +pnp_alloc_24869 pnp_alloc 1 24869 NULL nohasharray
96274 +l2cap_create_basic_pdu_24869 l2cap_create_basic_pdu 3 24869 &pnp_alloc_24869
96275 +bnx2fc_cmd_mgr_alloc_24873 bnx2fc_cmd_mgr_alloc 3-2 24873 NULL
96276 +queues_read_24877 queues_read 3 24877 NULL
96277 +codec_list_read_file_24910 codec_list_read_file 3 24910 NULL
96278 +v4l2_ctrl_new_24927 v4l2_ctrl_new 7 24927 NULL
96279 +next_token_24929 next_token 0 24929 NULL
96280 +uf_create_device_nodes_24948 uf_create_device_nodes 2 24948 NULL
96281 +ocfs2_fiemap_24949 ocfs2_fiemap 3-4 24949 NULL
96282 +packet_sendmsg_24954 packet_sendmsg 4 24954 NULL
96283 +sys_rt_sigpending_24961 sys_rt_sigpending 2 24961 NULL
96284 +ensure_wear_leveling_24971 ensure_wear_leveling 0 24971 NULL
96285 +twl_i2c_write_u8_24976 twl_i2c_write_u8 3 24976 NULL
96286 +nf_nat_sdp_port_24977 nf_nat_sdp_port 7 24977 NULL
96287 +llc_ui_sendmsg_24987 llc_ui_sendmsg 4 24987 NULL
96288 +key_conf_hw_key_idx_read_25003 key_conf_hw_key_idx_read 3 25003 NULL
96289 +il_dbgfs_channels_read_25005 il_dbgfs_channels_read 3 25005 NULL
96290 +ni_660x_num_counters_25031 ni_660x_num_counters 0 25031 NULL
96291 +nfs_dns_resolve_name_25036 nfs_dns_resolve_name 3 25036 NULL
96292 +gs_buf_alloc_25067 gs_buf_alloc 2 25067 NULL
96293 +gfs2_iter_unstuffed_25099 gfs2_iter_unstuffed 0 25099 NULL
96294 +cxio_hal_init_rhdl_resource_25104 cxio_hal_init_rhdl_resource 1 25104 NULL
96295 +snd_rawmidi_kernel_write_25106 snd_rawmidi_kernel_write 3 25106 NULL
96296 +fs32_to_cpu_25143 fs32_to_cpu 0 25143 NULL
96297 +sys_fgetxattr_25166 sys_fgetxattr 4 25166 NULL
96298 +ipath_init_qp_table_25167 ipath_init_qp_table 2 25167 NULL
96299 +mmu_set_spte_25177 mmu_set_spte 8-9 25177 NULL
96300 +sctp_getsockopt_local_addrs_25178 sctp_getsockopt_local_addrs 2 25178 NULL
96301 +ks8851_rdreg32_25187 ks8851_rdreg32 0 25187 NULL
96302 +ocfs2_block_check_compute_25223 ocfs2_block_check_compute 2 25223 NULL
96303 +mon_stat_read_25238 mon_stat_read 3 25238 NULL
96304 +tcf_csum_ipv6_udp_25241 tcf_csum_ipv6_udp 4 25241 NULL
96305 +nilfs_palloc_find_available_slot_25245 nilfs_palloc_find_available_slot 3-5 25245 NULL
96306 +snd_pcm_start_25273 snd_pcm_start 0 25273 NULL
96307 +crypto_alloc_instance2_25277 crypto_alloc_instance2 3 25277 NULL
96308 +vfs_writev_25278 vfs_writev 3 25278 NULL
96309 +l2tp_session_create_25286 l2tp_session_create 1 25286 NULL
96310 +snd_seq_ioctl_compat_25307 snd_seq_ioctl_compat 3 25307 NULL
96311 +help_25316 help 5 25316 NULL nohasharray
96312 +ath9k_debugfs_read_buf_25316 ath9k_debugfs_read_buf 3 25316 &help_25316
96313 +i915_gem_execbuffer_relocate_slow_25355 i915_gem_execbuffer_relocate_slow 7 25355 NULL
96314 +rio_destid_next_25368 rio_destid_next 2 25368 NULL nohasharray
96315 +unix_mkname_25368 unix_mkname 0-2 25368 &rio_destid_next_25368
96316 +sel_read_mls_25369 sel_read_mls 3 25369 NULL
96317 +tc3589x_gpio_to_irq_25371 tc3589x_gpio_to_irq 2 25371 NULL
96318 +ebt_buf_add_pad_25413 ebt_buf_add_pad 0 25413 NULL
96319 +dai_list_read_file_25421 dai_list_read_file 3 25421 NULL
96320 +ath6kl_wmi_beginscan_cmd_25462 ath6kl_wmi_beginscan_cmd 8 25462 NULL
96321 +generic_file_buffered_write_25464 generic_file_buffered_write 4 25464 NULL
96322 +crypto_hash_digestsize_25469 crypto_hash_digestsize 0 25469 NULL
96323 +ocfs2_hamming_encode_25501 ocfs2_hamming_encode 3 25501 NULL
96324 +ivtv_buf_copy_from_user_25502 ivtv_buf_copy_from_user 4 25502 NULL
96325 +snd_pcm_plugin_build_25505 snd_pcm_plugin_build 5 25505 NULL
96326 +sb_permission_25523 sb_permission 0 25523 NULL
96327 +ext3_get_inode_loc_25542 ext3_get_inode_loc 0 25542 NULL
96328 +ieee80211_if_read_path_refresh_time_25545 ieee80211_if_read_path_refresh_time 3 25545 NULL
96329 +wimax_addr_scnprint_25548 wimax_addr_scnprint 2 25548 NULL
96330 +ht_print_chan_25556 ht_print_chan 0 25556 NULL
96331 +skb_tailroom_25567 skb_tailroom 0 25567 NULL
96332 +__devres_alloc_25598 __devres_alloc 2 25598 NULL
96333 +copy_user_generic_25611 copy_user_generic 0 25611 NULL
96334 +proc_coredump_filter_write_25625 proc_coredump_filter_write 3 25625 NULL
96335 +__get_user_pages_25628 __get_user_pages 0 25628 NULL nohasharray
96336 +befs_utf2nls_25628 befs_utf2nls 3 25628 &__get_user_pages_25628
96337 +__direct_map_25647 __direct_map 5-6 25647 NULL
96338 +ext2_try_to_allocate_25667 ext2_try_to_allocate 4-2 25667 NULL
96339 +aircable_prepare_write_buffer_25669 aircable_prepare_write_buffer 3 25669 NULL
96340 +sta_inactive_ms_read_25690 sta_inactive_ms_read 3 25690 NULL
96341 +ebitmap_start_positive_25703 ebitmap_start_positive 0 25703 NULL
96342 +rx_filter_mc_filter_read_25712 rx_filter_mc_filter_read 3 25712 NULL
96343 +ibmasm_new_command_25714 ibmasm_new_command 2 25714 NULL
96344 +sel_write_context_25726 sel_write_context 3 25726 NULL nohasharray
96345 +__alloc_bootmem_low_node_25726 __alloc_bootmem_low_node 2 25726 &sel_write_context_25726
96346 +mcs_unwrap_fir_25733 mcs_unwrap_fir 3 25733 NULL
96347 +ext2_find_near_25734 ext2_find_near 0 25734 NULL
96348 +cxgbi_device_portmap_create_25747 cxgbi_device_portmap_create 3 25747 NULL
96349 +event_rx_pool_read_25792 event_rx_pool_read 3 25792 NULL
96350 +sg_read_25799 sg_read 3 25799 NULL
96351 +sys32_rt_sigpending_25814 sys32_rt_sigpending 2 25814 NULL
96352 +system_enable_read_25815 system_enable_read 3 25815 NULL
96353 +realloc_buffer_25816 realloc_buffer 2 25816 NULL
96354 +pwr_missing_bcns_read_25824 pwr_missing_bcns_read 3 25824 NULL
96355 +parport_read_25855 parport_read 0 25855 NULL
96356 +xfs_dir2_sf_hdr_size_25858 xfs_dir2_sf_hdr_size 0 25858 NULL
96357 +uf_ap_process_data_pdu_25860 uf_ap_process_data_pdu 7 25860 NULL
96358 +ath6kl_regread_read_25884 ath6kl_regread_read 3 25884 NULL
96359 +run_delalloc_nocow_25896 run_delalloc_nocow 3 25896 NULL
96360 +sisusbcon_scroll_area_25899 sisusbcon_scroll_area 4-3 25899 NULL
96361 +lpfc_change_queue_depth_25905 lpfc_change_queue_depth 2 25905 NULL
96362 +do_jffs2_setxattr_25910 do_jffs2_setxattr 5 25910 NULL
96363 +utf16_strlen_25913 utf16_strlen 0 25913 NULL
96364 +rcname_read_25919 rcname_read 3 25919 NULL
96365 +snd_es1938_capture_copy_25930 snd_es1938_capture_copy 5 25930 NULL
96366 +key_flags_read_25931 key_flags_read 3 25931 NULL
96367 +copy_play_buf_25932 copy_play_buf 3 25932 NULL
96368 +tps80031_clr_bits_25942 tps80031_clr_bits 3 25942 NULL
96369 +flush_25957 flush 2 25957 NULL
96370 +video_register_device_25971 video_register_device 3 25971 NULL
96371 +udp_setsockopt_25985 udp_setsockopt 5 25985 NULL
96372 +ebt_compat_entry_padsize_26001 ebt_compat_entry_padsize 0 26001 NULL
96373 +lpfc_sli_probe_sriov_nr_virtfn_26004 lpfc_sli_probe_sriov_nr_virtfn 2 26004 NULL
96374 +mirror_status_26010 mirror_status 5 26010 NULL
96375 +irq_create_strict_mappings_26025 irq_create_strict_mappings 2-4 26025 NULL
96376 +xfs_xattr_acl_set_26028 xfs_xattr_acl_set 4 26028 NULL
96377 +skb_mac_header_26034 skb_mac_header 0 26034 NULL
96378 +mptscsih_change_queue_depth_26036 mptscsih_change_queue_depth 2 26036 NULL
96379 +selinux_inode_post_setxattr_26037 selinux_inode_post_setxattr 4 26037 NULL
96380 +tun_do_read_26047 tun_do_read 5 26047 NULL
96381 +keyctl_update_key_26061 keyctl_update_key 3 26061 NULL
96382 +rx_rx_wa_density_dropped_frame_read_26095 rx_rx_wa_density_dropped_frame_read 3 26095 NULL
96383 +cpumask_next_26096 cpumask_next 1 26096 NULL
96384 +skb_cow_26138 skb_cow 2 26138 NULL
96385 +usb_dump_device_strings_26146 usb_dump_device_strings 0 26146 NULL
96386 +__fswab64_26155 __fswab64 0 26155 NULL
96387 +copy_oldmem_page_26164 copy_oldmem_page 3-1 26164 NULL
96388 +ath6kl_roam_table_read_26166 ath6kl_roam_table_read 3 26166 NULL nohasharray
96389 +gfs2_xattr_acl_get_26166 gfs2_xattr_acl_get 0 26166 &ath6kl_roam_table_read_26166
96390 +mid_get_vbt_data_r1_26170 mid_get_vbt_data_r1 2 26170 NULL
96391 +disk_devt_26180 disk_devt 0 26180 NULL
96392 +get_registers_26187 get_registers 3 26187 NULL
96393 +cgroup_setxattr_26188 cgroup_setxattr 4 26188 NULL
96394 +ieee80211_if_fmt_dot11MeshTTL_26198 ieee80211_if_fmt_dot11MeshTTL 3 26198 NULL
96395 +xfs_idata_realloc_26199 xfs_idata_realloc 2 26199 NULL
96396 +mce_write_26201 mce_write 3 26201 NULL
96397 +_scsih_change_queue_depth_26230 _scsih_change_queue_depth 2 26230 NULL
96398 +cxio_num_stags_26233 cxio_num_stags 0 26233 NULL
96399 +bio_split_26235 bio_split 2 26235 NULL
96400 +crypto_ctxsize_26278 crypto_ctxsize 0 26278 NULL
96401 +wacom_set_device_mode_26280 wacom_set_device_mode 3 26280 NULL
96402 +ext2_find_goal_26306 ext2_find_goal 0 26306 NULL
96403 +snd_pcm_plug_client_channels_buf_26309 snd_pcm_plug_client_channels_buf 0-3 26309 NULL nohasharray
96404 +pax_get_random_long_26309 pax_get_random_long 0 26309 &snd_pcm_plug_client_channels_buf_26309
96405 +pwr_wake_on_host_read_26321 pwr_wake_on_host_read 3 26321 NULL
96406 +ocfs2_duplicate_clusters_by_page_26357 ocfs2_duplicate_clusters_by_page 5 26357 NULL
96407 +cifs_readdata_alloc_26360 cifs_readdata_alloc 1 26360 NULL
96408 +dup_to_netobj_26363 dup_to_netobj 3 26363 NULL
96409 +invalidate_inode_pages2_range_26403 invalidate_inode_pages2_range 0 26403 NULL
96410 +virtio_has_feature_26467 virtio_has_feature 0 26467 NULL
96411 +ib_alloc_device_26483 ib_alloc_device 1 26483 NULL
96412 +ulong_write_file_26485 ulong_write_file 3 26485 NULL
96413 +dvb_ca_en50221_io_ioctl_26490 dvb_ca_en50221_io_ioctl 2 26490 NULL
96414 +read_vmcore_26501 read_vmcore 3 26501 NULL
96415 +vfio_pci_set_msi_trigger_26507 vfio_pci_set_msi_trigger 3-4 26507 NULL
96416 +iwl_dbgfs_rf_reset_read_26512 iwl_dbgfs_rf_reset_read 3 26512 NULL
96417 +rds_message_inc_copy_to_user_26540 rds_message_inc_copy_to_user 3 26540 NULL
96418 +__vhost_add_used_n_26554 __vhost_add_used_n 3 26554 NULL
96419 +ip6_addr_string_26568 ip6_addr_string 0 26568 NULL
96420 +rts51x_read_mem_26577 rts51x_read_mem 4 26577 NULL nohasharray
96421 +batadv_receive_server_sync_packet_26577 batadv_receive_server_sync_packet 3 26577 &rts51x_read_mem_26577
96422 +cirrusfb_get_memsize_26597 cirrusfb_get_memsize 0 26597 NULL
96423 +__unmap_single_26604 __unmap_single 2-3 26604 NULL
96424 +iommu_alloc_26621 iommu_alloc 4 26621 NULL
96425 +pwr_fix_tsf_ps_read_26627 pwr_fix_tsf_ps_read 3 26627 NULL
96426 +mmap_region_26649 mmap_region 0-2 26649 NULL
96427 +irq_alloc_generic_chip_26650 irq_alloc_generic_chip 2 26650 NULL nohasharray
96428 +inb_p_26650 inb_p 0 26650 &irq_alloc_generic_chip_26650
96429 +cipso_v4_map_cat_rbm_hton_26680 cipso_v4_map_cat_rbm_hton 0 26680 NULL
96430 +__alloc_pred_stack_26687 __alloc_pred_stack 2 26687 NULL
96431 +rtllib_authentication_req_26713 rtllib_authentication_req 3 26713 NULL
96432 +aty_ld_le32_26720 aty_ld_le32 0 26720 NULL
96433 +nouveau_namedb_create__26732 nouveau_namedb_create_ 7 26732 NULL
96434 +pipeline_tcp_rx_stat_fifo_int_read_26745 pipeline_tcp_rx_stat_fifo_int_read 3 26745 NULL
96435 +srp_ring_alloc_26760 srp_ring_alloc 2 26760 NULL
96436 +snd_hda_get_raw_connections_26762 snd_hda_get_raw_connections 0 26762 NULL
96437 +ntfs_are_rl_mergeable_26777 ntfs_are_rl_mergeable 0 26777 NULL
96438 +qlcnic_alloc_sds_rings_26795 qlcnic_alloc_sds_rings 2 26795 NULL
96439 +cipso_v4_genopt_26812 cipso_v4_genopt 0 26812 NULL
96440 +smk_write_load_26829 smk_write_load 3 26829 NULL
96441 +slgt_compat_ioctl_26834 slgt_compat_ioctl 3 26834 NULL
96442 +__nodes_onto_26838 __nodes_onto 4 26838 NULL
96443 +scnprint_id_26842 scnprint_id 3 26842 NULL
96444 +ecryptfs_miscdev_write_26847 ecryptfs_miscdev_write 3 26847 NULL
96445 +netxen_nic_hw_read_wx_128M_26858 netxen_nic_hw_read_wx_128M 2 26858 NULL
96446 +svc_print_xprts_26881 svc_print_xprts 0 26881 NULL
96447 +ext2_compat_ioctl_26883 ext2_compat_ioctl 3 26883 NULL
96448 +slhc_uncompress_26905 slhc_uncompress 0-3 26905 NULL
96449 +wm8994_reg_write_26919 wm8994_reg_write 2 26919 NULL
96450 +x25_asy_change_mtu_26928 x25_asy_change_mtu 2 26928 NULL
96451 +compat_mtw_from_user_26932 compat_mtw_from_user 0 26932 NULL
96452 +scsi_tgt_copy_sense_26933 scsi_tgt_copy_sense 3 26933 NULL
96453 +pwr_ps_enter_read_26935 pwr_ps_enter_read 3 26935 NULL nohasharray
96454 +sctp_setsockopt_adaptation_layer_26935 sctp_setsockopt_adaptation_layer 3 26935 &pwr_ps_enter_read_26935
96455 +carl9170_handle_mpdu_26940 carl9170_handle_mpdu 3 26940 NULL nohasharray
96456 +create_bm_block_list_26940 create_bm_block_list 0 26940 &carl9170_handle_mpdu_26940
96457 +hecubafb_write_26942 hecubafb_write 3 26942 NULL
96458 +extract_entropy_user_26952 extract_entropy_user 3 26952 NULL nohasharray
96459 +do_trimming_26952 do_trimming 3 26952 &extract_entropy_user_26952
96460 +pcf857x_irq_domain_map_26998 pcf857x_irq_domain_map 2 26998 NULL
96461 +rbd_do_op_27025 rbd_do_op 7-8 27025 NULL
96462 +ufs_alloc_fragments_27059 ufs_alloc_fragments 3-0-2 27059 NULL
96463 +__videobuf_alloc_vb_27062 __videobuf_alloc_vb 1 27062 NULL
96464 +snd_pcm_lib_period_bytes_27071 snd_pcm_lib_period_bytes 0 27071 NULL
96465 +paravirt_read_msr_27077 paravirt_read_msr 0 27077 NULL
96466 +alloc_fdmem_27083 alloc_fdmem 1 27083 NULL
96467 +find_first_bit_27088 find_first_bit 0-2 27088 NULL
96468 +btmrvl_hscmd_write_27089 btmrvl_hscmd_write 3 27089 NULL
96469 +__devcgroup_inode_permission_27108 __devcgroup_inode_permission 0 27108 NULL
96470 +get_kernel_page_27133 get_kernel_page 0 27133 NULL
96471 +drbd_get_capacity_27141 drbd_get_capacity 0 27141 NULL
96472 +pms_capture_27142 pms_capture 4 27142 NULL
96473 +btmrvl_hscfgcmd_write_27143 btmrvl_hscfgcmd_write 3 27143 NULL
96474 +snd_compr_calc_avail_27165 snd_compr_calc_avail 0 27165 NULL
96475 +mc13xxx_irq_handle_27166 mc13xxx_irq_handle 3 27166 NULL
96476 +i2400m_net_rx_27170 i2400m_net_rx 5 27170 NULL
96477 +ieee80211_if_read_rc_rateidx_mask_5ghz_27183 ieee80211_if_read_rc_rateidx_mask_5ghz 3 27183 NULL
96478 +get_unaligned_be32_27184 get_unaligned_be32 0 27184 NULL
96479 +mmc_blk_compat_ioctl_27194 mmc_blk_compat_ioctl 4 27194 NULL
96480 +dbAllocAG_27228 dbAllocAG 0 27228 NULL
96481 +rxrpc_request_key_27235 rxrpc_request_key 3 27235 NULL
96482 +cfpkt_add_trail_27260 cfpkt_add_trail 3 27260 NULL
96483 +__dma_map_cont_27289 __dma_map_cont 5 27289 NULL
96484 +hpi_read_reg_27302 hpi_read_reg 0 27302 NULL
96485 +copy_from_buf_27308 copy_from_buf 4-2 27308 NULL
96486 +ath6kl_wmi_test_cmd_27312 ath6kl_wmi_test_cmd 3 27312 NULL
96487 +rbd_req_sync_exec_27320 rbd_req_sync_exec 8 27320 NULL
96488 +ocfs2_blocks_to_clusters_27327 ocfs2_blocks_to_clusters 0-2 27327 NULL
96489 +snd_pcm_oss_write2_27332 snd_pcm_oss_write2 3-0 27332 NULL
96490 +afs_cell_create_27346 afs_cell_create 2 27346 NULL
96491 +pcbit_stat_27364 pcbit_stat 2 27364 NULL
96492 +init_memory_mapping_27395 init_memory_mapping 0 27395 NULL
96493 +phys_pte_init_27411 phys_pte_init 0-3-2 27411 NULL
96494 +ib_dma_map_sg_27413 ib_dma_map_sg 0 27413 NULL
96495 +acpi_os_get_root_pointer_27416 acpi_os_get_root_pointer 0 27416 NULL nohasharray
96496 +ieee80211_if_read_smps_27416 ieee80211_if_read_smps 3 27416 &acpi_os_get_root_pointer_27416
96497 +pack_sg_list_27425 pack_sg_list 0-2 27425 NULL
96498 +tps65910_reg_set_bits_27468 tps65910_reg_set_bits 2 27468 NULL
96499 +rtsx_write_cfg_seq_27485 rtsx_write_cfg_seq 5-3 27485 NULL
96500 +v4l2_ctrl_new_std_menu_items_27487 v4l2_ctrl_new_std_menu_items 4 27487 NULL
96501 +set_tpl_pfs_27490 set_tpl_pfs 3 27490 NULL
96502 +hcd_buffer_alloc_27495 hcd_buffer_alloc 2 27495 NULL
96503 +qib_create_cq_27497 qib_create_cq 2 27497 NULL
96504 +ip_set_get_h32_27498 ip_set_get_h32 0 27498 NULL
96505 +btrfs_get_64_27499 btrfs_get_64 0 27499 NULL
96506 +__usbnet_write_cmd_27500 __usbnet_write_cmd 7 27500 NULL
96507 +garmin_read_process_27509 garmin_read_process 3 27509 NULL
96508 +ib_copy_to_udata_27525 ib_copy_to_udata 3 27525 NULL
96509 +snd_sonicvibes_getdmaa_27552 snd_sonicvibes_getdmaa 0 27552 NULL
96510 +libipw_alloc_txb_27579 libipw_alloc_txb 1-2-3 27579 NULL
96511 +read_flush_procfs_27642 read_flush_procfs 3 27642 NULL nohasharray
96512 +nl80211_send_connect_result_27642 nl80211_send_connect_result 5-7 27642 &read_flush_procfs_27642 nohasharray
96513 +ocfs2_xattr_ibody_get_27642 ocfs2_xattr_ibody_get 0 27642 &nl80211_send_connect_result_27642
96514 +add_new_gdb_27643 add_new_gdb 3 27643 NULL
96515 +qnx6_readpages_27657 qnx6_readpages 4 27657 NULL
96516 +cdrom_read_cdda_old_27664 cdrom_read_cdda_old 4 27664 NULL
96517 +set_bypass_pwoff_pfs_27669 set_bypass_pwoff_pfs 3 27669 NULL
96518 +qword_get_27670 qword_get 0 27670 NULL
96519 +ocfs2_extend_dir_27695 ocfs2_extend_dir 4 27695 NULL
96520 +__tty_buffer_request_room_27700 __tty_buffer_request_room 2 27700 NULL
96521 +fs_path_add_from_extent_buffer_27702 fs_path_add_from_extent_buffer 4 27702 NULL
96522 +evm_write_key_27715 evm_write_key 3 27715 NULL
96523 +ieee80211_if_fmt_dot11MeshGateAnnouncementProtocol_27722 ieee80211_if_fmt_dot11MeshGateAnnouncementProtocol 3 27722 NULL
96524 +reg_w_buf_27724 reg_w_buf 3 27724 NULL
96525 +xfs_dir2_block_sfsize_27727 xfs_dir2_block_sfsize 0 27727 NULL
96526 +a4t_cs_init_27734 a4t_cs_init 3 27734 NULL
96527 +kcalloc_27770 kcalloc 1-2 27770 NULL
96528 +twl4030_set_gpio_dataout_27792 twl4030_set_gpio_dataout 1 27792 NULL
96529 +DivaSTraceGetMemotyRequirement_27797 DivaSTraceGetMemotyRequirement 0-1 27797 NULL
96530 +ttm_object_file_init_27804 ttm_object_file_init 2 27804 NULL
96531 +mpihelp_mul_27805 mpihelp_mul 5-3 27805 NULL
96532 +fwtty_buffer_rx_27821 fwtty_buffer_rx 3 27821 NULL
96533 +init_header_complete_27833 init_header_complete 0 27833 NULL nohasharray
96534 +sys_listxattr_27833 sys_listxattr 3 27833 &init_header_complete_27833
96535 +read_profile_27859 read_profile 3 27859 NULL
96536 +sky2_pci_read16_27863 sky2_pci_read16 0 27863 NULL
96537 +ieee80211_if_read_dot11MeshHWMProotInterval_27873 ieee80211_if_read_dot11MeshHWMProotInterval 3 27873 NULL
96538 +unix_seqpacket_sendmsg_27893 unix_seqpacket_sendmsg 4 27893 NULL
96539 +gluebi_write_27905 gluebi_write 3 27905 NULL
96540 +mc13783_set_sysclk_27914 mc13783_set_sysclk 5 27914 NULL
96541 +bm_find_next_27929 bm_find_next 2 27929 NULL
96542 +tracing_clock_write_27961 tracing_clock_write 3 27961 NULL
96543 +tipc_media_addr_printf_27971 tipc_media_addr_printf 2 27971 NULL
96544 +mic_rx_pkts_read_27972 mic_rx_pkts_read 3 27972 NULL
96545 +f2fs_bio_alloc_27983 f2fs_bio_alloc 2 27983 NULL
96546 +edt_ft5x06_debugfs_raw_data_read_28002 edt_ft5x06_debugfs_raw_data_read 3 28002 NULL
96547 +snd_rawmidi_write_28008 snd_rawmidi_write 3 28008 NULL
96548 +serial8250_port_size_28019 serial8250_port_size 0 28019 NULL
96549 +sctp_setsockopt_maxburst_28041 sctp_setsockopt_maxburst 3 28041 NULL
96550 +rts51x_xd_rw_28046 rts51x_xd_rw 3-4 28046 NULL
96551 +cx231xx_init_vbi_isoc_28053 cx231xx_init_vbi_isoc 3-2 28053 NULL
96552 +lpfc_idiag_mbxacc_read_28061 lpfc_idiag_mbxacc_read 3 28061 NULL
96553 +tx_frag_bad_mblk_num_read_28064 tx_frag_bad_mblk_num_read 3 28064 NULL
96554 +ext4_read_block_bitmap_nowait_28078 ext4_read_block_bitmap_nowait 2 28078 NULL
96555 +GetRecvByte_28082 GetRecvByte 0 28082 NULL
96556 +platform_get_irq_28088 platform_get_irq 0 28088 NULL
96557 +gdth_init_isa_28091 gdth_init_isa 1 28091 NULL
96558 +mmc_test_alloc_mem_28102 mmc_test_alloc_mem 3-2 28102 NULL
96559 +rx_defrag_need_defrag_read_28117 rx_defrag_need_defrag_read 3 28117 NULL
96560 +vgacon_adjust_height_28124 vgacon_adjust_height 2 28124 NULL
96561 +video_read_28148 video_read 3 28148 NULL
96562 +snd_midi_channel_alloc_set_28153 snd_midi_channel_alloc_set 1 28153 NULL
96563 +stats_dot11FCSErrorCount_read_28154 stats_dot11FCSErrorCount_read 3 28154 NULL
96564 +vread_28173 vread 0 28173 NULL
96565 +macvtap_get_user_28185 macvtap_get_user 4 28185 NULL
96566 +d_path_28198 d_path 0 28198 NULL
96567 +nouveau_mxm_create__28200 nouveau_mxm_create_ 4 28200 NULL
96568 +line6_alloc_sysex_buffer_28225 line6_alloc_sysex_buffer 4 28225 NULL nohasharray
96569 +set_dis_disc_pfs_28225 set_dis_disc_pfs 3 28225 &line6_alloc_sysex_buffer_28225
96570 +amd_nb_num_28228 amd_nb_num 0 28228 NULL
96571 +ext4_validate_block_bitmap_28243 ext4_validate_block_bitmap 3 28243 NULL
96572 +usemap_size_28281 usemap_size 0 28281 NULL
96573 +dma_map_sg_attrs_28289 dma_map_sg_attrs 0 28289 NULL
96574 +acpi_register_gsi_xen_28305 acpi_register_gsi_xen 2 28305 NULL nohasharray
96575 +nouveau_compat_ioctl_28305 nouveau_compat_ioctl 2 28305 &acpi_register_gsi_xen_28305
96576 +snd_pcm_oss_read_28317 snd_pcm_oss_read 3 28317 NULL
96577 +bm_entry_write_28338 bm_entry_write 3 28338 NULL
96578 +snapshot_write_28351 snapshot_write 3 28351 NULL
96579 +__next_wq_cpu_28352 __next_wq_cpu 1 28352 NULL
96580 +sys_writev_28384 sys_writev 3 28384 NULL
96581 +dlmfs_file_read_28385 dlmfs_file_read 3 28385 NULL
96582 +tx_frag_cache_miss_read_28394 tx_frag_cache_miss_read 3 28394 NULL
96583 +set_bypass_pfs_28395 set_bypass_pfs 3 28395 NULL
96584 +subdev_ioctl_28417 subdev_ioctl 2 28417 NULL
96585 +mpage_readpages_28436 mpage_readpages 3 28436 NULL
96586 +snd_emu10k1_efx_read_28452 snd_emu10k1_efx_read 2 28452 NULL
96587 +key_mic_failures_read_28457 key_mic_failures_read 3 28457 NULL
96588 +alloc_irq_cpu_rmap_28459 alloc_irq_cpu_rmap 1 28459 NULL
96589 +vmw_du_crtc_cursor_set_28479 vmw_du_crtc_cursor_set 4-5 28479 NULL
96590 +ocfs2_backup_super_blkno_28484 ocfs2_backup_super_blkno 0-2 28484 NULL
96591 +max_response_pages_28492 max_response_pages 0 28492 NULL
96592 +ps_poll_upsd_utilization_read_28519 ps_poll_upsd_utilization_read 3 28519 NULL
96593 +__next_node_28521 __next_node 1 28521 NULL
96594 +i2400m_tx_stats_read_28527 i2400m_tx_stats_read 3 28527 NULL
96595 +early_init_dt_alloc_memory_arch_28528 early_init_dt_alloc_memory_arch 1 28528 NULL
96596 +sel_read_policycap_28544 sel_read_policycap 3 28544 NULL
96597 +run_delalloc_range_28545 run_delalloc_range 3 28545 NULL nohasharray
96598 +mptctl_getiocinfo_28545 mptctl_getiocinfo 2 28545 &run_delalloc_range_28545
96599 +b43legacy_debugfs_write_28556 b43legacy_debugfs_write 3 28556 NULL
96600 +i2o_msg_post_wait_mem_28558 i2o_msg_post_wait_mem 0 28558 NULL
96601 +phys_pud_init_28574 phys_pud_init 0-3-2 28574 NULL
96602 +cfg80211_send_rx_auth_28580 cfg80211_send_rx_auth 3 28580 NULL
96603 +oxygen_read32_28582 oxygen_read32 0 28582 NULL
96604 +ocfs2_read_dir_block_28587 ocfs2_read_dir_block 2 28587 NULL
96605 +wm8350_clear_bits_28596 wm8350_clear_bits 2 28596 NULL
96606 +extract_entropy_28604 extract_entropy 3-5 28604 NULL
96607 +kfifo_unused_28612 kfifo_unused 0 28612 NULL
96608 +mp_override_legacy_irq_28618 mp_override_legacy_irq 4 28618 NULL
96609 +snd_nm256_capture_copy_28622 snd_nm256_capture_copy 5-3 28622 NULL
96610 +_set_range_28627 _set_range 3 28627 NULL
96611 +v4l2_compat_ioctl32_28630 v4l2_compat_ioctl32 3 28630 NULL
96612 +setup_usemap_28636 setup_usemap 3-4 28636 NULL
96613 +blk_queue_resize_tags_28670 blk_queue_resize_tags 2 28670 NULL
96614 +__dev_alloc_skb_28681 __dev_alloc_skb 1 28681 NULL
96615 +nl80211_send_new_peer_candidate_28692 nl80211_send_new_peer_candidate 5 28692 NULL nohasharray
96616 +kvm_mmu_get_page_28692 kvm_mmu_get_page 2 28692 &nl80211_send_new_peer_candidate_28692
96617 +drm_plane_init_28731 drm_plane_init 6 28731 NULL
96618 +spi_execute_28736 spi_execute 5 28736 NULL
96619 +snd_pcm_aio_write_28738 snd_pcm_aio_write 3 28738 NULL nohasharray
96620 +phantom_compat_ioctl_28738 phantom_compat_ioctl 3 28738 &snd_pcm_aio_write_28738
96621 +read_file_btcoex_28743 read_file_btcoex 3 28743 NULL
96622 +cxio_init_resource_fifo_28764 cxio_init_resource_fifo 3 28764 NULL
96623 +ath6kl_get_num_reg_28780 ath6kl_get_num_reg 0 28780 NULL
96624 +dvb_net_sec_callback_28786 dvb_net_sec_callback 2 28786 NULL
96625 +sel_write_member_28800 sel_write_member 3 28800 NULL
96626 +cgroup_file_read_28804 cgroup_file_read 3 28804 NULL
96627 +btrfs_ref_to_path_28809 btrfs_ref_to_path 0-8-3 28809 NULL
96628 +memory_bm_create_28814 memory_bm_create 0 28814 NULL
96629 +iwl_dbgfs_rxon_filter_flags_read_28832 iwl_dbgfs_rxon_filter_flags_read 3 28832 NULL
96630 +vp_request_msix_vectors_28849 vp_request_msix_vectors 2 28849 NULL
96631 +ipv6_renew_options_28867 ipv6_renew_options 5 28867 NULL
96632 +packet_sendmsg_spkt_28885 packet_sendmsg_spkt 4 28885 NULL
96633 +tps6586x_update_28898 tps6586x_update 2 28898 NULL
96634 +da9055_group_write_28904 da9055_group_write 2-3 28904 NULL
96635 +ps_upsd_timeouts_read_28924 ps_upsd_timeouts_read 3 28924 NULL
96636 +ocfs2_frozen_trigger_28929 ocfs2_frozen_trigger 4 28929 NULL
96637 +push_rx_28939 push_rx 3 28939 NULL
96638 +btrfs_trim_block_group_28963 btrfs_trim_block_group 3 28963 NULL
96639 +alloc_sched_domains_28972 alloc_sched_domains 1 28972 NULL
96640 +ext4_mb_add_groupinfo_28988 ext4_mb_add_groupinfo 2 28988 NULL
96641 +bin_uuid_28999 bin_uuid 3 28999 NULL
96642 +xz_dec_init_29029 xz_dec_init 2 29029 NULL
96643 +sys_fcntl64_29031 sys_fcntl64 3 29031 NULL
96644 +ieee80211_if_read_ht_opmode_29044 ieee80211_if_read_ht_opmode 3 29044 NULL
96645 +rxrpc_sendmsg_29049 rxrpc_sendmsg 4 29049 NULL
96646 +iso_packets_buffer_init_29061 iso_packets_buffer_init 3-4 29061 NULL
96647 +lpfc_idiag_extacc_drivr_get_29067 lpfc_idiag_extacc_drivr_get 0-3 29067 NULL
96648 +ieee80211_probereq_get_29069 ieee80211_probereq_get 4-6 29069 NULL
96649 +sctp_getsockopt_assoc_stats_29074 sctp_getsockopt_assoc_stats 2 29074 NULL
96650 +mark_extents_written_29082 mark_extents_written 2 29082 NULL
96651 +isdn_ppp_write_29109 isdn_ppp_write 4 29109 NULL
96652 +snprintf_29125 snprintf 0 29125 NULL
96653 +iov_shorten_29130 iov_shorten 0 29130 NULL
96654 +pm860x_reg_write_29141 pm860x_reg_write 2 29141 NULL
96655 +proc_scsi_write_29142 proc_scsi_write 3 29142 NULL
96656 +reshape_ring_29147 reshape_ring 2 29147 NULL
96657 +drm_property_create_enum_29201 drm_property_create_enum 5 29201 NULL
96658 +wusb_prf_256_29203 wusb_prf_256 7 29203 NULL nohasharray
96659 +alloc_group_attrs_29203 alloc_group_attrs 3 29203 &wusb_prf_256_29203
96660 +comedi_alloc_subdevices_29207 comedi_alloc_subdevices 2 29207 NULL
96661 +do_shrinker_shrink_29208 do_shrinker_shrink 0 29208 NULL
96662 +rds_iw_inc_copy_to_user_29214 rds_iw_inc_copy_to_user 3 29214 NULL
96663 +iwl_dbgfs_temperature_read_29224 iwl_dbgfs_temperature_read 3 29224 NULL
96664 +devm_ioremap_29235 devm_ioremap 2-3 29235 NULL
96665 +irq_domain_add_linear_29236 irq_domain_add_linear 2 29236 NULL
96666 +recover_peb_29238 recover_peb 6-7 29238 NULL
96667 +security_context_to_sid_core_29248 security_context_to_sid_core 2 29248 NULL
96668 +prism2_set_genericelement_29277 prism2_set_genericelement 3 29277 NULL
96669 +bitmap_ord_to_pos_29279 bitmap_ord_to_pos 3 29279 NULL
96670 +sn9c102_read_29305 sn9c102_read 3 29305 NULL
96671 +fd_do_writev_29329 fd_do_writev 3 29329 NULL
96672 +lo_compat_ioctl_29336 lo_compat_ioctl 4 29336 NULL
96673 +tun_put_user_29337 tun_put_user 5 29337 NULL
96674 +__alloc_ei_netdev_29338 __alloc_ei_netdev 1 29338 NULL
96675 +alloc_and_copy_ftrace_hash_29368 alloc_and_copy_ftrace_hash 1 29368 NULL
96676 +mwifiex_cfg80211_mgmt_tx_29387 mwifiex_cfg80211_mgmt_tx 7 29387 NULL
96677 +pca953x_irq_setup_29407 pca953x_irq_setup 3 29407 NULL
96678 +mempool_create_29437 mempool_create 1 29437 NULL
96679 +crypto_ahash_alignmask_29445 crypto_ahash_alignmask 0 29445 NULL
96680 +apei_exec_ctx_get_output_29457 apei_exec_ctx_get_output 0 29457 NULL
96681 +validate_scan_freqs_29462 validate_scan_freqs 0 29462 NULL
96682 +do_register_entry_29478 do_register_entry 4 29478 NULL
96683 +simple_strtoul_29480 simple_strtoul 0 29480 NULL
96684 +btmrvl_pscmd_write_29504 btmrvl_pscmd_write 3 29504 NULL
96685 +btrfs_file_extent_disk_bytenr_29505 btrfs_file_extent_disk_bytenr 0 29505 NULL
96686 +atk_debugfs_ggrp_read_29522 atk_debugfs_ggrp_read 3 29522 NULL
96687 +ftrace_write_29551 ftrace_write 3 29551 NULL
96688 +idetape_queue_rw_tail_29562 idetape_queue_rw_tail 3 29562 NULL
96689 +leaf_dealloc_29566 leaf_dealloc 3 29566 NULL nohasharray
96690 +alloc_empty_pages_29566 alloc_empty_pages 2 29566 &leaf_dealloc_29566
96691 +lbs_lowsnr_read_29571 lbs_lowsnr_read 3 29571 NULL
96692 +pvr2_hdw_report_unlocked_29589 pvr2_hdw_report_unlocked 4 29589 NULL
96693 +wm8903_gpio_set_29597 wm8903_gpio_set 2 29597 NULL
96694 +slots_per_page_29601 slots_per_page 0 29601 NULL
96695 +qla4_82xx_pci_set_window_29605 qla4_82xx_pci_set_window 0-2 29605 NULL
96696 +nla_get_u16_29624 nla_get_u16 0 29624 NULL
96697 +tx_frag_cache_hit_read_29639 tx_frag_cache_hit_read 3 29639 NULL
96698 +lowmem_page_address_29649 lowmem_page_address 0 29649 NULL
96699 +sctp_make_abort_user_29654 sctp_make_abort_user 3 29654 NULL
96700 +br_send_bpdu_29669 br_send_bpdu 3 29669 NULL
96701 +sisusb_write_mem_bulk_29678 sisusb_write_mem_bulk 4 29678 NULL
96702 +sd_alloc_ctl_entry_29708 sd_alloc_ctl_entry 1 29708 NULL nohasharray
96703 +posix_acl_from_xattr_29708 posix_acl_from_xattr 3 29708 &sd_alloc_ctl_entry_29708
96704 +probes_write_29711 probes_write 3 29711 NULL
96705 +emi62_writememory_29731 emi62_writememory 4 29731 NULL
96706 +read_cis_cache_29735 read_cis_cache 4 29735 NULL
96707 +da9055_gpio_direction_input_29742 da9055_gpio_direction_input 2 29742 NULL
96708 +cxio_hal_init_resource_29771 cxio_hal_init_resource 2-6-7 29771 NULL nohasharray
96709 +ip_vs_conn_fill_param_sync_29771 ip_vs_conn_fill_param_sync 6 29771 &cxio_hal_init_resource_29771
96710 +dbAlloc_29794 dbAlloc 0 29794 NULL
96711 +ext4_trim_all_free_29806 ext4_trim_all_free 4-3-2 29806 NULL
96712 +arizona_gpio_set_29823 arizona_gpio_set 2 29823 NULL
96713 +tcp_sendpage_29829 tcp_sendpage 4 29829 NULL
96714 +scan_bitmap_block_29840 scan_bitmap_block 4 29840 NULL
96715 +__probe_kernel_write_29842 __probe_kernel_write 3 29842 NULL
96716 +kvm_read_hva_atomic_29848 kvm_read_hva_atomic 3 29848 NULL
96717 +ipv6_setsockopt_29871 ipv6_setsockopt 5 29871 NULL
96718 +scsi_end_request_29876 scsi_end_request 3 29876 NULL
96719 +crypto_aead_alignmask_29885 crypto_aead_alignmask 0 29885 NULL
96720 +nfc_targets_found_29886 nfc_targets_found 3 29886 NULL
96721 +tps6586x_write_29894 tps6586x_write 2 29894 NULL
96722 +check586_29914 check586 2 29914 NULL
96723 +ext4_xattr_set_acl_29930 ext4_xattr_set_acl 4 29930 NULL
96724 +__btrfs_getxattr_29947 __btrfs_getxattr 0 29947 NULL
96725 +irias_add_octseq_attrib_29983 irias_add_octseq_attrib 4 29983 NULL nohasharray
96726 +diva_os_get_context_size_29983 diva_os_get_context_size 0 29983 &irias_add_octseq_attrib_29983
96727 +arch_setup_dmar_msi_29992 arch_setup_dmar_msi 1 29992 NULL
96728 +utf32_to_utf8_30028 utf32_to_utf8 0 30028 NULL
96729 +alloc_netdev_mqs_30030 alloc_netdev_mqs 1 30030 NULL
96730 +scsi_vpd_inquiry_30040 scsi_vpd_inquiry 4 30040 NULL
96731 +drp_wmove_30043 drp_wmove 4 30043 NULL
96732 +cxgbi_ddp_reserve_30091 cxgbi_ddp_reserve 4 30091 NULL
96733 +snd_midi_channel_init_set_30092 snd_midi_channel_init_set 1 30092 NULL
96734 +tg3_run_loopback_30093 tg3_run_loopback 2 30093 NULL
96735 +rx_filter_data_filter_read_30098 rx_filter_data_filter_read 3 30098 NULL
96736 +skb_pagelen_30113 skb_pagelen 0 30113 NULL
96737 +spi_async_locked_30117 spi_async_locked 0 30117 NULL
96738 +calgary_unmap_page_30130 calgary_unmap_page 2-3 30130 NULL
96739 +_osd_req_sizeof_alist_header_30134 _osd_req_sizeof_alist_header 0 30134 NULL
96740 +u_memcpya_30139 u_memcpya 2-3 30139 NULL
96741 +cx25821_video_ioctl_30188 cx25821_video_ioctl 2 30188 NULL
96742 +mempool_create_page_pool_30189 mempool_create_page_pool 1 30189 NULL
96743 +drm_property_create_bitmask_30195 drm_property_create_bitmask 5 30195 NULL
96744 +snd_pcm_playback_forward_30201 snd_pcm_playback_forward 0-2 30201 NULL
96745 +usblp_ioctl_30203 usblp_ioctl 2 30203 NULL
96746 +nfs_idmap_request_key_30208 nfs_idmap_request_key 3 30208 NULL
96747 +read_4k_modal_eeprom_30212 read_4k_modal_eeprom 3 30212 NULL
96748 +snd_ac97_pcm_assign_30218 snd_ac97_pcm_assign 2 30218 NULL
96749 +isr_pci_pm_read_30271 isr_pci_pm_read 3 30271 NULL
96750 +compat_readv_30273 compat_readv 3 30273 NULL
96751 +lapic_register_intr_30279 lapic_register_intr 1 30279 NULL
96752 +__be64_to_cpup_30283 __be64_to_cpup 0 30283 NULL
96753 +skcipher_sendmsg_30290 skcipher_sendmsg 4 30290 NULL
96754 +pipeline_sec_frag_swi_read_30294 pipeline_sec_frag_swi_read 3 30294 NULL
96755 +tcp_sendmsg_30296 tcp_sendmsg 4 30296 NULL
96756 +ext4_acl_from_disk_30320 ext4_acl_from_disk 2 30320 NULL
96757 +generic_ptrace_pokedata_30338 generic_ptrace_pokedata 2 30338 NULL
96758 +resource_from_user_30341 resource_from_user 3 30341 NULL
96759 +__vmalloc_node_flags_30352 __vmalloc_node_flags 1 30352 NULL
96760 +sys_get_mempolicy_30379 sys_get_mempolicy 3 30379 NULL
96761 +mangle_sdp_packet_30381 mangle_sdp_packet 10 30381 NULL
96762 +c4iw_init_resource_30393 c4iw_init_resource 2-3 30393 NULL
96763 +get_kernel_pages_30397 get_kernel_pages 0 30397 NULL
96764 +_drbd_bm_find_next_zero_30415 _drbd_bm_find_next_zero 2 30415 NULL
96765 +vb2_fop_write_30420 vb2_fop_write 3 30420 NULL
96766 +tx_tx_template_prepared_read_30424 tx_tx_template_prepared_read 3 30424 NULL
96767 +enable_write_30456 enable_write 3 30456 NULL
96768 +tx_tx_template_programmed_read_30461 tx_tx_template_programmed_read 3 30461 NULL
96769 +urandom_read_30462 urandom_read 3 30462 NULL
96770 +zoran_ioctl_30465 zoran_ioctl 2 30465 NULL
96771 +write_head_30481 write_head 4 30481 NULL
96772 +adu_write_30487 adu_write 3 30487 NULL
96773 +dwc3_testmode_write_30516 dwc3_testmode_write 3 30516 NULL
96774 +debug_debug2_read_30526 debug_debug2_read 3 30526 NULL
96775 +batadv_dat_snoop_incoming_arp_request_30548 batadv_dat_snoop_incoming_arp_request 3 30548 NULL
96776 +disk_expand_part_tbl_30561 disk_expand_part_tbl 2 30561 NULL
96777 +set_le_30581 set_le 4 30581 NULL
96778 +blk_init_tags_30592 blk_init_tags 1 30592 NULL
96779 +i2c_hid_get_report_length_30598 i2c_hid_get_report_length 0 30598 NULL
96780 +sgl_map_user_pages_30610 sgl_map_user_pages 2 30610 NULL
96781 +macvtap_sendmsg_30629 macvtap_sendmsg 4 30629 NULL
96782 +compat_raw_setsockopt_30634 compat_raw_setsockopt 5 30634 NULL
96783 +nfsd_nrpools_30651 nfsd_nrpools 0 30651 NULL
96784 +agp_remap_30665 agp_remap 2 30665 NULL
96785 +jffs2_flash_read_30667 jffs2_flash_read 0 30667 NULL
96786 +dccp_setsockopt_ccid_30701 dccp_setsockopt_ccid 4 30701 NULL
96787 +lbs_debugfs_read_30721 lbs_debugfs_read 3 30721 NULL
96788 +snd_nm256_playback_silence_30727 snd_nm256_playback_silence 4-3 30727 NULL
96789 +max77693_update_reg_30747 max77693_update_reg 2 30747 NULL
96790 +tcf_csum_ipv4_udp_30777 tcf_csum_ipv4_udp 4 30777 NULL
96791 +wm8350_read_auxadc_30780 wm8350_read_auxadc 2 30780 NULL
96792 +smk_read_doi_30813 smk_read_doi 3 30813 NULL
96793 +get_kobj_path_length_30831 get_kobj_path_length 0 30831 NULL
96794 +create_subvol_30836 create_subvol 4 30836 NULL
96795 +sctp_setsockopt_auth_chunk_30843 sctp_setsockopt_auth_chunk 3 30843 NULL
96796 +cfg80211_rx_mgmt_30844 cfg80211_rx_mgmt 5 30844 NULL nohasharray
96797 +twl6040_set_bits_30844 twl6040_set_bits 2 30844 &cfg80211_rx_mgmt_30844
96798 +hda_hwdep_ioctl_compat_30847 hda_hwdep_ioctl_compat 4 30847 NULL
96799 +ieee80211_if_fmt_dropped_frames_no_route_30884 ieee80211_if_fmt_dropped_frames_no_route 3 30884 NULL
96800 +f1x_match_to_this_node_30888 f1x_match_to_this_node 3 30888 NULL
96801 +regmap_update_bits_check_30894 regmap_update_bits_check 2 30894 NULL
96802 +iommu_map_mmio_space_30919 iommu_map_mmio_space 1 30919 NULL
96803 +sctp_setsockopt_rtoinfo_30941 sctp_setsockopt_rtoinfo 3 30941 NULL
96804 +tty_insert_flip_string_flags_30969 tty_insert_flip_string_flags 4 30969 NULL
96805 +huge_page_mask_30981 huge_page_mask 0 30981 NULL
96806 +i2400mu_rx_size_grow_30989 i2400mu_rx_size_grow 0 30989 NULL
96807 +lbs_host_sleep_read_31013 lbs_host_sleep_read 3 31013 NULL
96808 +phys_pmd_init_31024 phys_pmd_init 0-3-2 31024 NULL
96809 +compat_sys_mq_timedsend_31060 compat_sys_mq_timedsend 3 31060 NULL
96810 +lbs_failcount_read_31063 lbs_failcount_read 3 31063 NULL
96811 +find_next_bit_le_31064 find_next_bit_le 0-2-3 31064 NULL
96812 +sys_mincore_31079 sys_mincore 1 31079 NULL
96813 +ttm_bo_ioremap_31082 ttm_bo_ioremap 2-3 31082 NULL
96814 +sctp_setsockopt_context_31091 sctp_setsockopt_context 3 31091 NULL
96815 +compat_sys_get_mempolicy_31109 compat_sys_get_mempolicy 3 31109 NULL
96816 +depth_read_31112 depth_read 3 31112 NULL
96817 +ssb_read16_31139 ssb_read16 0 31139 NULL
96818 +kimage_normal_alloc_31140 kimage_normal_alloc 3 31140 NULL
96819 +size_inside_page_31141 size_inside_page 0 31141 NULL
96820 +w9966_v4l_read_31148 w9966_v4l_read 3 31148 NULL
96821 +ch_do_scsi_31171 ch_do_scsi 4 31171 NULL
96822 +acpi_ex_system_memory_space_handler_31192 acpi_ex_system_memory_space_handler 2 31192 NULL
96823 +r592_read_fifo_pio_31198 r592_read_fifo_pio 3 31198 NULL
96824 +mtdchar_readoob_31200 mtdchar_readoob 4 31200 NULL
96825 +__btrfs_free_reserved_extent_31207 __btrfs_free_reserved_extent 2 31207 NULL
96826 +cpumask_weight_31215 cpumask_weight 0 31215 NULL
96827 +__read_reg_31216 __read_reg 0 31216 NULL
96828 +atm_get_addr_31221 atm_get_addr 3 31221 NULL
96829 +cyy_readb_31240 cyy_readb 0 31240 NULL
96830 +_create_sg_bios_31244 _create_sg_bios 4 31244 NULL
96831 +ieee80211_if_read_last_beacon_31257 ieee80211_if_read_last_beacon 3 31257 NULL
96832 +ceph_copy_page_vector_to_user_31270 ceph_copy_page_vector_to_user 3-4 31270 NULL
96833 +sctp_tsnmap_find_gap_ack_31272 sctp_tsnmap_find_gap_ack 3-2 31272 NULL
96834 +uvc_simplify_fraction_31303 uvc_simplify_fraction 3 31303 NULL
96835 +sisusbcon_scroll_31315 sisusbcon_scroll 5-2-3 31315 NULL
96836 +futex_uaddr_31316 futex_uaddr 2 31316 NULL
96837 +command_file_write_31318 command_file_write 3 31318 NULL
96838 +__cpu_to_node_31345 __cpu_to_node 0 31345 NULL
96839 +xprt_rdma_allocate_31372 xprt_rdma_allocate 2 31372 NULL
96840 +vb2_vmalloc_get_userptr_31374 vb2_vmalloc_get_userptr 3 31374 NULL
96841 +trace_parser_get_init_31379 trace_parser_get_init 2 31379 NULL
96842 +inb_31388 inb 0 31388 NULL
96843 +key_ifindex_read_31411 key_ifindex_read 3 31411 NULL
96844 +mcs7830_set_reg_31413 mcs7830_set_reg 3 31413 NULL
96845 +TSS_checkhmac1_31429 TSS_checkhmac1 5 31429 NULL
96846 +snd_aw2_saa7146_get_hw_ptr_capture_31431 snd_aw2_saa7146_get_hw_ptr_capture 0 31431 NULL
96847 +acpi_sci_ioapic_setup_31445 acpi_sci_ioapic_setup 4 31445 NULL
96848 +opera1_xilinx_rw_31453 opera1_xilinx_rw 5 31453 NULL
96849 +_regmap_update_bits_31456 _regmap_update_bits 2 31456 NULL
96850 +input_get_new_minor_31464 input_get_new_minor 1 31464 NULL
96851 +do_fcntl_31468 do_fcntl 3 31468 NULL
96852 +xfs_btree_get_numrecs_31477 xfs_btree_get_numrecs 0 31477 NULL
96853 +alg_setkey_31485 alg_setkey 3 31485 NULL
96854 +rds_message_map_pages_31487 rds_message_map_pages 2 31487 NULL
96855 +qsfp_2_read_31491 qsfp_2_read 3 31491 NULL
96856 +__alloc_bootmem_31498 __alloc_bootmem 1 31498 NULL
96857 +hidraw_write_31536 hidraw_write 3 31536 NULL
96858 +mtd_div_by_eb_31543 mtd_div_by_eb 0-1 31543 NULL
96859 +usbvision_read_31555 usbvision_read 3 31555 NULL
96860 +normalize_31566 normalize 0-1-2 31566 NULL
96861 +tx_frag_tkip_called_read_31575 tx_frag_tkip_called_read 3 31575 NULL
96862 +get_max_inline_xattr_value_size_31578 get_max_inline_xattr_value_size 0 31578 NULL
96863 +osst_write_31581 osst_write 3 31581 NULL
96864 +snd_compr_get_avail_31584 snd_compr_get_avail 0 31584 NULL
96865 +iwl_dbgfs_ucode_tx_stats_read_31611 iwl_dbgfs_ucode_tx_stats_read 3 31611 NULL
96866 +mtd_get_user_prot_info_31616 mtd_get_user_prot_info 0 31616 NULL
96867 +arvo_sysfs_read_31617 arvo_sysfs_read 6 31617 NULL
96868 +videobuf_read_one_31637 videobuf_read_one 3 31637 NULL
96869 +pod_alloc_sysex_buffer_31651 pod_alloc_sysex_buffer 3 31651 NULL
96870 +xfer_secondary_pool_31661 xfer_secondary_pool 2 31661 NULL
96871 +__lgread_31668 __lgread 4 31668 NULL
96872 +symbol_string_31670 symbol_string 0 31670 NULL
96873 +_usb_writeN_sync_31682 _usb_writeN_sync 4 31682 NULL
96874 +forced_ps_read_31685 forced_ps_read 3 31685 NULL
96875 +reiserfs_in_journal_31689 reiserfs_in_journal 3 31689 NULL
96876 +audit_log_n_string_31705 audit_log_n_string 3 31705 NULL
96877 +ath6kl_wmi_send_probe_response_cmd_31728 ath6kl_wmi_send_probe_response_cmd 6 31728 NULL
96878 +utf16s_to_utf8s_31735 utf16s_to_utf8s 0 31735 NULL
96879 +shmem_pwrite_slow_31741 shmem_pwrite_slow 3 31741 NULL
96880 +NCR_700_change_queue_depth_31742 NCR_700_change_queue_depth 2 31742 NULL nohasharray
96881 +input_abs_get_max_31742 input_abs_get_max 0 31742 &NCR_700_change_queue_depth_31742
96882 +bcm_char_read_31750 bcm_char_read 3 31750 NULL
96883 +lm3533_led_get_pattern_reg_31752 lm3533_led_get_pattern_reg 0-2 31752 NULL
96884 +snd_seq_device_new_31753 snd_seq_device_new 4 31753 NULL
96885 +usblp_cache_device_id_string_31790 usblp_cache_device_id_string 0 31790 NULL
96886 +get_count_order_31800 get_count_order 0 31800 NULL
96887 +ecryptfs_send_message_locked_31801 ecryptfs_send_message_locked 2 31801 NULL
96888 +isr_rx_procs_read_31804 isr_rx_procs_read 3 31804 NULL
96889 +strnlen_user_31815 strnlen_user 0-2 31815 NULL
96890 +sta_last_signal_read_31818 sta_last_signal_read 3 31818 NULL
96891 +drm_mode_crtc_set_gamma_size_31881 drm_mode_crtc_set_gamma_size 2 31881 NULL
96892 +ddb_output_write_31902 ddb_output_write 3 31902 NULL
96893 +xattr_permission_31907 xattr_permission 0 31907 NULL
96894 +new_dir_31919 new_dir 3 31919 NULL
96895 +kmem_alloc_31920 kmem_alloc 1 31920 NULL
96896 +guestwidth_to_adjustwidth_31937 guestwidth_to_adjustwidth 0-1 31937 NULL
96897 +iov_iter_copy_from_user_31942 iov_iter_copy_from_user 4 31942 NULL
96898 +vb2_write_31948 vb2_write 3 31948 NULL
96899 +pvr2_ctrl_get_valname_31951 pvr2_ctrl_get_valname 4 31951 NULL
96900 +regcache_rbtree_sync_31964 regcache_rbtree_sync 2 31964 NULL
96901 +copy_from_user_toio_31966 copy_from_user_toio 3 31966 NULL
96902 +mtd_add_partition_31971 mtd_add_partition 3 31971 NULL
96903 +find_next_zero_bit_31990 find_next_zero_bit 0-2-3 31990 NULL
96904 +tps6586x_irq_map_32002 tps6586x_irq_map 2 32002 NULL
96905 +calc_hmac_32010 calc_hmac 3 32010 NULL
96906 +aead_len_32021 aead_len 0 32021 NULL
96907 +ocfs2_remove_extent_32032 ocfs2_remove_extent 4-3 32032 NULL
96908 +posix_acl_set_32037 posix_acl_set 4 32037 NULL
96909 +vmw_cursor_update_dmabuf_32045 vmw_cursor_update_dmabuf 3-4 32045 NULL
96910 +sys_sched_setaffinity_32046 sys_sched_setaffinity 2 32046 NULL
96911 +proc_scsi_devinfo_write_32064 proc_scsi_devinfo_write 3 32064 NULL
96912 +cfg80211_send_unprot_deauth_32080 cfg80211_send_unprot_deauth 3 32080 NULL
96913 +bio_alloc_32095 bio_alloc 2 32095 NULL
96914 +alloc_pwms_32100 alloc_pwms 1-2 32100 NULL
96915 +ath6kl_fwlog_read_32101 ath6kl_fwlog_read 3 32101 NULL
96916 +disk_status_32120 disk_status 4 32120 NULL
96917 +rc5t583_write_32124 rc5t583_write 2 32124 NULL
96918 +venus_link_32165 venus_link 5 32165 NULL
96919 +drbd_new_dev_size_32171 drbd_new_dev_size 0 32171 NULL
96920 +do_writepages_32173 do_writepages 0 32173 NULL nohasharray
96921 +ntfs_rl_realloc_nofail_32173 ntfs_rl_realloc_nofail 3 32173 &do_writepages_32173
96922 +load_header_32183 load_header 0 32183 NULL
96923 +ubi_wl_scrub_peb_32196 ubi_wl_scrub_peb 0 32196 NULL
96924 +wusb_ccm_mac_32199 wusb_ccm_mac 7 32199 NULL
96925 +riva_get_cmap_len_32218 riva_get_cmap_len 0 32218 NULL
96926 +lm3533_write_32236 lm3533_write 2 32236 NULL
96927 +lbs_lowrssi_read_32242 lbs_lowrssi_read 3 32242 NULL
96928 +ocfs2_xattr_find_entry_32260 ocfs2_xattr_find_entry 0 32260 NULL
96929 +fb_compat_ioctl_32265 fb_compat_ioctl 3 32265 NULL
96930 +vmalloc_user_32308 vmalloc_user 1 32308 NULL
96931 +hex_string_32310 hex_string 0 32310 NULL
96932 +flakey_status_32315 flakey_status 5 32315 NULL
96933 +nouveau_bar_create__32332 nouveau_bar_create_ 4 32332 NULL
96934 +nl80211_send_mlme_event_32337 nl80211_send_mlme_event 4 32337 NULL
96935 +t4_alloc_mem_32342 t4_alloc_mem 1 32342 NULL
96936 +dispatch_ioctl_32357 dispatch_ioctl 2 32357 NULL
96937 +f1x_translate_sysaddr_to_cs_32359 f1x_translate_sysaddr_to_cs 2 32359 NULL
96938 +sel_read_initcon_32362 sel_read_initcon 3 32362 NULL
96939 +_drbd_bm_find_next_32372 _drbd_bm_find_next 2 32372 NULL
96940 +variax_set_raw2_32374 variax_set_raw2 4 32374 NULL
96941 +usbtmc_read_32377 usbtmc_read 3 32377 NULL
96942 +qla4_82xx_pci_mem_write_2M_32398 qla4_82xx_pci_mem_write_2M 2 32398 NULL
96943 +xfs_iext_add_indirect_multi_32400 xfs_iext_add_indirect_multi 3 32400 NULL
96944 +log_text_32428 log_text 0 32428 NULL
96945 +regmap_irq_map_32429 regmap_irq_map 2 32429 NULL
96946 +hid_input_report_32458 hid_input_report 4 32458 NULL
96947 +snd_pcm_sync_ptr_32461 snd_pcm_sync_ptr 0 32461 NULL
96948 +ieee80211_fill_mesh_addresses_32465 ieee80211_fill_mesh_addresses 0 32465 NULL
96949 +ide_driver_proc_write_32493 ide_driver_proc_write 3 32493 NULL
96950 +ctrl_std_val_to_sym_32516 ctrl_std_val_to_sym 5 32516 NULL
96951 +disconnect_32521 disconnect 4 32521 NULL
96952 +qsfp_read_32522 qsfp_read 0-4-2 32522 NULL
96953 +ilo_read_32531 ilo_read 3 32531 NULL
96954 +ieee80211_if_read_estab_plinks_32533 ieee80211_if_read_estab_plinks 3 32533 NULL nohasharray
96955 +crypt_status_32533 crypt_status 5 32533 &ieee80211_if_read_estab_plinks_32533
96956 +format_devstat_counter_32550 format_devstat_counter 3 32550 NULL
96957 +__first_node_32558 __first_node 0 32558 NULL
96958 +aes_encrypt_fail_read_32562 aes_encrypt_fail_read 3 32562 NULL
96959 +pnp_mem_len_32584 pnp_mem_len 0 32584 NULL
96960 +mem_swapout_entry_32586 mem_swapout_entry 3 32586 NULL
96961 +pipeline_tcp_tx_stat_fifo_int_read_32589 pipeline_tcp_tx_stat_fifo_int_read 3 32589 NULL
96962 +read_file_beacon_32595 read_file_beacon 3 32595 NULL
96963 +ieee80211_if_read_dropped_frames_congestion_32603 ieee80211_if_read_dropped_frames_congestion 3 32603 NULL
96964 +sys_set_mempolicy_32608 sys_set_mempolicy 3 32608 NULL
96965 +cfg80211_roamed_32632 cfg80211_roamed 5-7 32632 NULL
96966 +ieee80211_hdrlen_32637 ieee80211_hdrlen 0 32637 NULL
96967 +ite_decode_bytes_32642 ite_decode_bytes 3 32642 NULL
96968 +kvmalloc_32646 kvmalloc 1 32646 NULL
96969 +ib_sg_dma_len_32649 ib_sg_dma_len 0 32649 NULL
96970 +generic_readlink_32654 generic_readlink 3 32654 NULL
96971 +move_addr_to_kernel_32673 move_addr_to_kernel 2 32673 NULL
96972 +tps80031_set_bits_32686 tps80031_set_bits 3 32686 NULL
96973 +jfs_readpages_32702 jfs_readpages 4 32702 NULL
96974 +snd_hwdep_ioctl_compat_32736 snd_hwdep_ioctl_compat 3 32736 NULL
96975 +megasas_change_queue_depth_32747 megasas_change_queue_depth 2 32747 NULL
96976 +stats_read_ul_32751 stats_read_ul 3 32751 NULL
96977 +tty_compat_ioctl_32761 tty_compat_ioctl 3 32761 NULL
96978 +sctp_tsnmap_grow_32784 sctp_tsnmap_grow 2 32784 NULL
96979 +firmwareUpload_32794 firmwareUpload 3 32794 NULL
96980 +rproc_name_read_32805 rproc_name_read 3 32805 NULL
96981 +vga_rseq_32848 vga_rseq 0 32848 NULL
96982 +new_tape_buffer_32866 new_tape_buffer 2 32866 NULL
96983 +io_apic_setup_irq_pin_32868 io_apic_setup_irq_pin 1 32868 NULL
96984 +ath6kl_usb_submit_ctrl_in_32880 ath6kl_usb_submit_ctrl_in 6 32880 NULL nohasharray
96985 +cifs_writedata_alloc_32880 cifs_writedata_alloc 1 32880 &ath6kl_usb_submit_ctrl_in_32880
96986 +ath6kl_usb_post_recv_transfers_32892 ath6kl_usb_post_recv_transfers 2 32892 NULL
96987 +il_dbgfs_tx_stats_read_32913 il_dbgfs_tx_stats_read 3 32913 NULL
96988 +zlib_inflate_workspacesize_32927 zlib_inflate_workspacesize 0 32927 NULL
96989 +rmap_recycle_32938 rmap_recycle 3 32938 NULL
96990 +irq_reserve_irqs_32946 irq_reserve_irqs 1-2 32946 NULL
96991 +ext4_valid_block_bitmap_32958 ext4_valid_block_bitmap 3 32958 NULL
96992 +arch_ptrace_32981 arch_ptrace 3 32981 NULL
96993 +compat_filldir_32999 compat_filldir 3 32999 NULL
96994 +ext3_alloc_blocks_33007 ext3_alloc_blocks 3 33007 NULL
96995 +snd_pcm_prepare_33036 snd_pcm_prepare 0 33036 NULL
96996 +pipeline_dec_packet_in_fifo_full_read_33052 pipeline_dec_packet_in_fifo_full_read 3 33052 NULL
96997 +ebt_compat_match_offset_33053 ebt_compat_match_offset 0-2 33053 NULL
96998 +bitmap_resize_33054 bitmap_resize 2 33054 NULL
96999 +stats_dot11RTSSuccessCount_read_33065 stats_dot11RTSSuccessCount_read 3 33065 NULL
97000 +sel_read_checkreqprot_33068 sel_read_checkreqprot 3 33068 NULL
97001 +acl_permission_check_33083 acl_permission_check 0 33083 NULL
97002 +ieee80211_fragment_33112 ieee80211_fragment 4 33112 NULL
97003 +write_node_33121 write_node 4 33121 NULL
97004 +calc_patch_size_33124 calc_patch_size 0 33124 NULL
97005 +fb_sys_write_33130 fb_sys_write 3 33130 NULL
97006 +debug_debug6_read_33168 debug_debug6_read 3 33168 NULL
97007 +dataflash_read_fact_otp_33204 dataflash_read_fact_otp 2-3 33204 NULL
97008 +pp_read_33210 pp_read 3 33210 NULL
97009 +xfs_file_aio_write_33234 xfs_file_aio_write 4 33234 NULL
97010 +snd_pcm_plug_client_size_33267 snd_pcm_plug_client_size 0-2 33267 NULL
97011 +sched_find_first_bit_33270 sched_find_first_bit 0 33270 NULL
97012 +cachefiles_cook_key_33274 cachefiles_cook_key 2 33274 NULL
97013 +mei_compat_ioctl_33275 mei_compat_ioctl 3 33275 NULL
97014 +pcf50633_irq_mask_33280 pcf50633_irq_mask 2 33280 NULL
97015 +mcs7830_get_reg_33308 mcs7830_get_reg 3 33308 NULL
97016 +ath6kl_usb_ctrl_msg_exchange_33327 ath6kl_usb_ctrl_msg_exchange 4 33327 NULL
97017 +gsm_mux_rx_netchar_33336 gsm_mux_rx_netchar 3 33336 NULL
97018 +joydev_ioctl_33343 joydev_ioctl 2 33343 NULL
97019 +create_xattr_datum_33356 create_xattr_datum 5 33356 NULL nohasharray
97020 +irq_pkt_threshold_read_33356 irq_pkt_threshold_read 3 33356 &create_xattr_datum_33356
97021 +read_file_regidx_33370 read_file_regidx 3 33370 NULL
97022 +ceph_osdc_writepages_33375 ceph_osdc_writepages 5 33375 NULL
97023 +ocfs2_quota_read_33382 ocfs2_quota_read 5 33382 NULL
97024 +ieee80211_if_read_dropped_frames_no_route_33383 ieee80211_if_read_dropped_frames_no_route 3 33383 NULL
97025 +scsi_varlen_cdb_length_33385 scsi_varlen_cdb_length 0 33385 NULL
97026 +ocfs2_allocate_unwritten_extents_33394 ocfs2_allocate_unwritten_extents 2-3 33394 NULL
97027 +ext4_meta_bg_first_block_no_33408 ext4_meta_bg_first_block_no 2 33408 NULL nohasharray
97028 +snd_pcm_capture_ioctl1_33408 snd_pcm_capture_ioctl1 0 33408 &ext4_meta_bg_first_block_no_33408
97029 +ufs_getfrag_block_33409 ufs_getfrag_block 2 33409 NULL
97030 +ubh_scanc_33436 ubh_scanc 0-4-3 33436 NULL
97031 +ovs_vport_alloc_33475 ovs_vport_alloc 1 33475 NULL
97032 +create_entry_33479 create_entry 2 33479 NULL
97033 +ip_setsockopt_33487 ip_setsockopt 5 33487 NULL nohasharray
97034 +elf_map_33487 elf_map 0-2 33487 &ip_setsockopt_33487
97035 +netxen_nic_hw_write_wx_128M_33488 netxen_nic_hw_write_wx_128M 2 33488 NULL
97036 +ol_dqblk_chunk_off_33489 ol_dqblk_chunk_off 2 33489 NULL
97037 +res_counter_read_33499 res_counter_read 4 33499 NULL
97038 +fb_read_33506 fb_read 3 33506 NULL
97039 +musb_test_mode_write_33518 musb_test_mode_write 3 33518 NULL
97040 +ahash_setkey_unaligned_33521 ahash_setkey_unaligned 3 33521 NULL
97041 +nes_alloc_fast_reg_page_list_33523 nes_alloc_fast_reg_page_list 2 33523 NULL
97042 +aggr_size_rx_size_read_33526 aggr_size_rx_size_read 3 33526 NULL
97043 +acpi_gsi_to_irq_33533 acpi_gsi_to_irq 1 33533 NULL
97044 +tomoyo_read_self_33539 tomoyo_read_self 3 33539 NULL
97045 +dup_array_33551 dup_array 3 33551 NULL
97046 +solo_enc_read_33553 solo_enc_read 3 33553 NULL
97047 +count_subheaders_33591 count_subheaders 0 33591 NULL
97048 +scsi_execute_33596 scsi_execute 5 33596 NULL
97049 +comedi_buf_write_n_allocated_33604 comedi_buf_write_n_allocated 0 33604 NULL
97050 +xt_compat_target_offset_33608 xt_compat_target_offset 0 33608 NULL nohasharray
97051 +ip6_find_1stfragopt_33608 ip6_find_1stfragopt 0 33608 &xt_compat_target_offset_33608
97052 +il_dbgfs_qos_read_33615 il_dbgfs_qos_read 3 33615 NULL
97053 +irq_blk_threshold_read_33666 irq_blk_threshold_read 3 33666 NULL
97054 +inw_p_33668 inw_p 0 33668 NULL
97055 +arp_hdr_len_33671 arp_hdr_len 0 33671 NULL
97056 +i2c_hid_alloc_buffers_33673 i2c_hid_alloc_buffers 2 33673 NULL
97057 +ath6kl_wmi_startscan_cmd_33674 ath6kl_wmi_startscan_cmd 8 33674 NULL
97058 +rbd_alloc_coll_33678 rbd_alloc_coll 1 33678 NULL
97059 +nv50_disp_dmac_create__33696 nv50_disp_dmac_create_ 6 33696 NULL
97060 +compat_insnlist_33706 compat_insnlist 2 33706 NULL
97061 +sys_keyctl_33708 sys_keyctl 4 33708 NULL nohasharray
97062 +netlink_sendmsg_33708 netlink_sendmsg 4 33708 &sys_keyctl_33708
97063 +tipc_link_stats_33716 tipc_link_stats 3 33716 NULL
97064 +pvr2_stream_buffer_count_33719 pvr2_stream_buffer_count 2 33719 NULL
97065 +ocfs2_extent_map_get_blocks_33720 ocfs2_extent_map_get_blocks 2 33720 NULL
97066 +__mutex_lock_interruptible_slowpath_33735 __mutex_lock_interruptible_slowpath 0 33735 NULL
97067 +Read_hfc_33755 Read_hfc 0 33755 NULL
97068 +vifs_state_read_33762 vifs_state_read 3 33762 NULL
97069 +hashtab_create_33769 hashtab_create 3 33769 NULL
97070 +midibuf_message_length_33770 midibuf_message_length 0 33770 NULL
97071 +if_sdio_read_rx_len_33800 if_sdio_read_rx_len 0 33800 NULL
97072 +find_next_offset_33804 find_next_offset 3 33804 NULL
97073 +sky2_rx_pad_33819 sky2_rx_pad 0 33819 NULL
97074 +sep_create_msgarea_context_33829 sep_create_msgarea_context 4 33829 NULL
97075 +scrub_setup_recheck_block_33831 scrub_setup_recheck_block 5-4 33831 NULL
97076 +udplite_manip_pkt_33832 udplite_manip_pkt 4 33832 NULL
97077 +snd_pcm_action_nonatomic_33844 snd_pcm_action_nonatomic 0 33844 NULL
97078 +usb_dump_endpoint_descriptor_33849 usb_dump_endpoint_descriptor 0 33849 NULL
97079 +calgary_alloc_coherent_33851 calgary_alloc_coherent 2 33851 NULL
97080 +oz_cdev_write_33852 oz_cdev_write 3 33852 NULL
97081 +cap_mmap_addr_33853 cap_mmap_addr 0 33853 NULL
97082 +config_proc_write_33878 config_proc_write 3 33878 NULL
97083 +get_user_pages_33908 get_user_pages 0 33908 NULL
97084 +queue_logical_block_size_33918 queue_logical_block_size 0 33918 NULL
97085 +sel_read_avc_cache_threshold_33942 sel_read_avc_cache_threshold 3 33942 NULL
97086 +lpfc_idiag_ctlacc_read_33943 lpfc_idiag_ctlacc_read 3 33943 NULL
97087 +read_file_tgt_rx_stats_33944 read_file_tgt_rx_stats 3 33944 NULL
97088 +vga_switcheroo_debugfs_write_33984 vga_switcheroo_debugfs_write 3 33984 NULL
97089 +__ntfs_malloc_34022 __ntfs_malloc 1 34022 NULL
97090 +ppp_write_34034 ppp_write 3 34034 NULL
97091 +tty_insert_flip_string_34042 tty_insert_flip_string 3 34042 NULL
97092 +__domain_flush_pages_34045 __domain_flush_pages 2-3 34045 NULL
97093 +acpi_dev_get_irqresource_34064 acpi_dev_get_irqresource 2 34064 NULL
97094 +memcg_update_all_caches_34068 memcg_update_all_caches 1 34068 NULL
97095 +read_file_ant_diversity_34071 read_file_ant_diversity 3 34071 NULL
97096 +show_risefalltime_34084 show_risefalltime 4 34084 NULL
97097 +compat_hdio_ioctl_34088 compat_hdio_ioctl 4 34088 NULL
97098 +pipeline_pipeline_fifo_full_read_34095 pipeline_pipeline_fifo_full_read 3 34095 NULL
97099 +islpci_mgt_transmit_34133 islpci_mgt_transmit 5 34133 NULL
97100 +ttm_dma_page_pool_free_34135 ttm_dma_page_pool_free 2 34135 NULL
97101 +cdc_mbim_process_dgram_34136 cdc_mbim_process_dgram 3 34136 NULL
97102 +ixgbe_dbg_netdev_ops_write_34141 ixgbe_dbg_netdev_ops_write 3 34141 NULL
97103 +shmem_pread_fast_34147 shmem_pread_fast 3 34147 NULL
97104 +skb_to_sgvec_34171 skb_to_sgvec 0 34171 NULL
97105 +ext4_da_write_begin_34215 ext4_da_write_begin 3-4 34215 NULL
97106 +bl_pipe_downcall_34264 bl_pipe_downcall 3 34264 NULL
97107 +pcf857x_to_irq_34273 pcf857x_to_irq 2 34273 NULL
97108 +zone_spanned_pages_in_node_34299 zone_spanned_pages_in_node 0 34299 NULL
97109 +iov_iter_single_seg_count_34326 iov_iter_single_seg_count 0 34326 NULL nohasharray
97110 +pcpu_need_to_extend_34326 pcpu_need_to_extend 0 34326 &iov_iter_single_seg_count_34326
97111 +crypto_ablkcipher_ivsize_34363 crypto_ablkcipher_ivsize 0 34363 NULL
97112 +rngapi_reset_34366 rngapi_reset 3 34366 NULL nohasharray
97113 +p54_alloc_skb_34366 p54_alloc_skb 3 34366 &rngapi_reset_34366
97114 +reiserfs_resize_34377 reiserfs_resize 2 34377 NULL
97115 +ea_read_34378 ea_read 0 34378 NULL
97116 +av7110_vbi_write_34384 av7110_vbi_write 3 34384 NULL
97117 +usbvision_v4l2_read_34386 usbvision_v4l2_read 3 34386 NULL
97118 +read_rbu_image_type_34387 read_rbu_image_type 6 34387 NULL
97119 +iwl_calib_set_34400 iwl_calib_set 3 34400 NULL nohasharray
97120 +ivtv_read_pos_34400 ivtv_read_pos 3 34400 &iwl_calib_set_34400
97121 +nl80211_send_disassoc_34424 nl80211_send_disassoc 4 34424 NULL
97122 +usbtest_alloc_urb_34446 usbtest_alloc_urb 3-5 34446 NULL
97123 +mwifiex_regrdwr_read_34472 mwifiex_regrdwr_read 3 34472 NULL
97124 +line6_dumpreq_init_34473 line6_dumpreq_init 3 34473 NULL
97125 +skcipher_sndbuf_34476 skcipher_sndbuf 0 34476 NULL
97126 +i2o_parm_field_get_34477 i2o_parm_field_get 5 34477 NULL
97127 +security_inode_permission_34488 security_inode_permission 0 34488 NULL
97128 +alloc_buf_34532 alloc_buf 1 34532 NULL
97129 +tracing_stats_read_34537 tracing_stats_read 3 34537 NULL
97130 +hugetlbfs_read_actor_34547 hugetlbfs_read_actor 0-2-5-4 34547 NULL
97131 +dbBackSplit_34561 dbBackSplit 0 34561 NULL
97132 +alloc_ieee80211_rsl_34564 alloc_ieee80211_rsl 1 34564 NULL
97133 +velocity_rx_copy_34583 velocity_rx_copy 2 34583 NULL
97134 +init_send_hfcd_34586 init_send_hfcd 1 34586 NULL
97135 +inet6_ifla6_size_34591 inet6_ifla6_size 0 34591 NULL
97136 +ceph_msgpool_init_34599 ceph_msgpool_init 4 34599 NULL
97137 +__jffs2_ref_totlen_34609 __jffs2_ref_totlen 0 34609 NULL
97138 +__cfg80211_disconnected_34622 __cfg80211_disconnected 3 34622 NULL
97139 +cnic_alloc_dma_34641 cnic_alloc_dma 3 34641 NULL
97140 +nf_nat_mangle_udp_packet_34661 nf_nat_mangle_udp_packet 8-6 34661 NULL
97141 +isr_fiqs_read_34687 isr_fiqs_read 3 34687 NULL
97142 +port_print_34704 port_print 3 34704 NULL
97143 +alloc_irq_and_cfg_at_34706 alloc_irq_and_cfg_at 1 34706 NULL
97144 +ieee80211_if_read_num_sta_ps_34722 ieee80211_if_read_num_sta_ps 3 34722 NULL
97145 +platform_list_read_file_34734 platform_list_read_file 3 34734 NULL
97146 +reg_w_ixbuf_34736 reg_w_ixbuf 4 34736 NULL
97147 +qib_cdev_init_34778 qib_cdev_init 1 34778 NULL
97148 +ssd1307fb_write_array_34779 ssd1307fb_write_array 4 34779 NULL
97149 +__copy_in_user_34790 __copy_in_user 3 34790 NULL
97150 +drbd_get_max_capacity_34804 drbd_get_max_capacity 0 34804 NULL
97151 +b43_debugfs_write_34838 b43_debugfs_write 3 34838 NULL
97152 +nl_portid_hash_zalloc_34843 nl_portid_hash_zalloc 1 34843 NULL
97153 +acpi_system_write_wakeup_device_34853 acpi_system_write_wakeup_device 3 34853 NULL
97154 +usb_serial_generic_prepare_write_buffer_34857 usb_serial_generic_prepare_write_buffer 3 34857 NULL
97155 +ieee80211_if_read_txpower_34871 ieee80211_if_read_txpower 3 34871 NULL
97156 +lm3533_ctrlbank_get_reg_34886 lm3533_ctrlbank_get_reg 0-2 34886 NULL
97157 +msg_print_text_34889 msg_print_text 0 34889 NULL
97158 +ieee80211_if_write_34894 ieee80211_if_write 3 34894 NULL
97159 +compat_put_uint_34905 compat_put_uint 1 34905 NULL
97160 +__inode_permission_34925 __inode_permission 0 34925 NULL nohasharray
97161 +btrfs_super_chunk_root_34925 btrfs_super_chunk_root 0 34925 &__inode_permission_34925
97162 +skb_gro_header_slow_34958 skb_gro_header_slow 2 34958 NULL
97163 +Realloc_34961 Realloc 2 34961 NULL
97164 +rx_rx_hdr_overflow_read_35002 rx_rx_hdr_overflow_read 3 35002 NULL
97165 +l2cap_skbuff_fromiovec_35003 l2cap_skbuff_fromiovec 4-3 35003 NULL
97166 +sisusb_copy_memory_35016 sisusb_copy_memory 4 35016 NULL
97167 +coda_psdev_read_35029 coda_psdev_read 3 35029 NULL
97168 +btmrvl_gpiogap_write_35053 btmrvl_gpiogap_write 3 35053 NULL
97169 +pwr_connection_out_of_sync_read_35061 pwr_connection_out_of_sync_read 3 35061 NULL
97170 +store_ifalias_35088 store_ifalias 4 35088 NULL
97171 +__kfifo_uint_must_check_helper_35097 __kfifo_uint_must_check_helper 0-1 35097 NULL
97172 +capi_write_35104 capi_write 3 35104 NULL nohasharray
97173 +tx_tx_done_template_read_35104 tx_tx_done_template_read 3 35104 &capi_write_35104
97174 +ide_settings_proc_write_35110 ide_settings_proc_write 3 35110 NULL
97175 +pointer_35138 pointer 0 35138 NULL
97176 +gntdev_alloc_map_35145 gntdev_alloc_map 2 35145 NULL
97177 +iscsi_conn_setup_35159 iscsi_conn_setup 2 35159 NULL
97178 +ieee80211_if_read_bssid_35161 ieee80211_if_read_bssid 3 35161 NULL
97179 +unix_stream_recvmsg_35210 unix_stream_recvmsg 4 35210 NULL
97180 +_osd_req_alist_elem_size_35216 _osd_req_alist_elem_size 0-2 35216 NULL
97181 +striped_read_35218 striped_read 0-2-8-3 35218 NULL nohasharray
97182 +security_key_getsecurity_35218 security_key_getsecurity 0 35218 &striped_read_35218
97183 +video_register_device_no_warn_35226 video_register_device_no_warn 3 35226 NULL nohasharray
97184 +rx_rx_cmplt_task_read_35226 rx_rx_cmplt_task_read 3 35226 &video_register_device_no_warn_35226
97185 +set_fd_set_35249 set_fd_set 1 35249 NULL
97186 +ioapic_setup_resources_35255 ioapic_setup_resources 1 35255 NULL
97187 +dma_show_regs_35266 dma_show_regs 3 35266 NULL
97188 +irda_recvmsg_stream_35280 irda_recvmsg_stream 4 35280 NULL
97189 +i2o_block_end_request_35282 i2o_block_end_request 3 35282 NULL
97190 +isr_rx_rdys_read_35283 isr_rx_rdys_read 3 35283 NULL
97191 +brcmf_sdio_forensic_read_35311 brcmf_sdio_forensic_read 3 35311 NULL nohasharray
97192 +__btrfs_buffered_write_35311 __btrfs_buffered_write 3 35311 &brcmf_sdio_forensic_read_35311
97193 +tracing_read_pipe_35312 tracing_read_pipe 3 35312 NULL
97194 +sys_setsockopt_35320 sys_setsockopt 5 35320 NULL
97195 +new_bind_ctl_35324 new_bind_ctl 2 35324 NULL
97196 +irq_domain_disassociate_many_35325 irq_domain_disassociate_many 2-3 35325 NULL
97197 +fallback_on_nodma_alloc_35332 fallback_on_nodma_alloc 2 35332 NULL
97198 +pskb_network_may_pull_35336 pskb_network_may_pull 2 35336 NULL
97199 +ieee80211_if_fmt_ap_power_level_35347 ieee80211_if_fmt_ap_power_level 3 35347 NULL
97200 +nouveau_devinit_create__35348 nouveau_devinit_create_ 4 35348 NULL
97201 +hpi_alloc_control_cache_35351 hpi_alloc_control_cache 1 35351 NULL
97202 +compat_filldir64_35354 compat_filldir64 3 35354 NULL
97203 +rawv6_send_hdrinc_35425 rawv6_send_hdrinc 3 35425 NULL
97204 +__set_test_and_free_35436 __set_test_and_free 2 35436 NULL
97205 +buffer_to_user_35439 buffer_to_user 3 35439 NULL
97206 +rdev_get_id_35454 rdev_get_id 0 35454 NULL
97207 +i915_wedged_read_35474 i915_wedged_read 3 35474 NULL
97208 +do_atm_ioctl_35519 do_atm_ioctl 3 35519 NULL
97209 +async_setkey_35521 async_setkey 3 35521 NULL
97210 +__filemap_fdatawrite_range_35528 __filemap_fdatawrite_range 0 35528 NULL
97211 +iwl_dbgfs_bt_traffic_read_35534 iwl_dbgfs_bt_traffic_read 3 35534 NULL
97212 +rxpipe_tx_xfr_host_int_trig_rx_data_read_35538 rxpipe_tx_xfr_host_int_trig_rx_data_read 3 35538 NULL
97213 +ibnl_put_attr_35541 ibnl_put_attr 3 35541 NULL
97214 +ieee80211_if_write_smps_35550 ieee80211_if_write_smps 3 35550 NULL
97215 +ext2_acl_from_disk_35580 ext2_acl_from_disk 2 35580 NULL
97216 +ReadZReg_35604 ReadZReg 0 35604 NULL
97217 +kernel_readv_35617 kernel_readv 3 35617 NULL
97218 +reiserfs_readpages_35629 reiserfs_readpages 4 35629 NULL
97219 +scrub_stripe_35637 scrub_stripe 4-3 35637 NULL
97220 +spi_register_board_info_35651 spi_register_board_info 2 35651 NULL
97221 +store_debug_level_35652 store_debug_level 3 35652 NULL
97222 +regmap_update_bits_35668 regmap_update_bits 2 35668 NULL
97223 +rdmaltWithLock_35669 rdmaltWithLock 0 35669 NULL
97224 +compat_sys_kexec_load_35674 compat_sys_kexec_load 2 35674 NULL
97225 +dm_table_create_35687 dm_table_create 3 35687 NULL
97226 +rds_page_copy_user_35691 rds_page_copy_user 4 35691 NULL
97227 +pci_enable_sriov_35745 pci_enable_sriov 2 35745 NULL
97228 +iwl_dbgfs_disable_ht40_read_35761 iwl_dbgfs_disable_ht40_read 3 35761 NULL
97229 +udf_alloc_i_data_35786 udf_alloc_i_data 2 35786 NULL
97230 +read_file_stations_35795 read_file_stations 3 35795 NULL
97231 +pvr2_hdw_cpufw_get_35824 pvr2_hdw_cpufw_get 0-4-2 35824 NULL
97232 +tx_tx_cmplt_read_35854 tx_tx_cmplt_read 3 35854 NULL
97233 +mthca_buf_alloc_35861 mthca_buf_alloc 2 35861 NULL
97234 +fls64_35862 fls64 0 35862 NULL
97235 +kvm_dirty_bitmap_bytes_35886 kvm_dirty_bitmap_bytes 0 35886 NULL
97236 +ieee80211_if_fmt_dot11MeshRetryTimeout_35890 ieee80211_if_fmt_dot11MeshRetryTimeout 3 35890 NULL
97237 +uwb_rc_cmd_done_35892 uwb_rc_cmd_done 4 35892 NULL
97238 +kernel_setsockopt_35913 kernel_setsockopt 5 35913 NULL
97239 +vol_cdev_compat_ioctl_35923 vol_cdev_compat_ioctl 3 35923 NULL
97240 +sctp_tsnmap_mark_35929 sctp_tsnmap_mark 2 35929 NULL
97241 +rx_defrag_init_called_read_35935 rx_defrag_init_called_read 3 35935 NULL
97242 +put_cmsg_compat_35937 put_cmsg_compat 4 35937 NULL
97243 +wm8350_reg_write_35967 wm8350_reg_write 2 35967 NULL
97244 +ext_rts51x_sd_execute_write_data_35971 ext_rts51x_sd_execute_write_data 9 35971 NULL
97245 +ceph_buffer_new_35974 ceph_buffer_new 1 35974 NULL
97246 +acl_alloc_35979 acl_alloc 1 35979 NULL
97247 +generic_file_aio_read_35987 generic_file_aio_read 0 35987 NULL
97248 +koneplus_sysfs_write_35993 koneplus_sysfs_write 6 35993 NULL
97249 +il3945_ucode_tx_stats_read_36016 il3945_ucode_tx_stats_read 3 36016 NULL
97250 +ubi_eba_write_leb_36029 ubi_eba_write_leb 5-6 36029 NULL
97251 +sys_init_module_36047 sys_init_module 2 36047 NULL
97252 +account_shadowed_36048 account_shadowed 2 36048 NULL
97253 +gpio_power_read_36059 gpio_power_read 3 36059 NULL
97254 +snd_pcm_playback_hw_avail_36061 snd_pcm_playback_hw_avail 0 36061 NULL
97255 +write_emulate_36065 write_emulate 2-4 36065 NULL
97256 +radeon_vm_num_pdes_36070 radeon_vm_num_pdes 0 36070 NULL
97257 +ieee80211_if_fmt_peer_36071 ieee80211_if_fmt_peer 3 36071 NULL
97258 +ext3_new_blocks_36073 ext3_new_blocks 3 36073 NULL
97259 +ieee80211_if_write_tsf_36077 ieee80211_if_write_tsf 3 36077 NULL
97260 +snd_pcm_plug_read_transfer_36080 snd_pcm_plug_read_transfer 0-3 36080 NULL
97261 +vga_arb_write_36112 vga_arb_write 3 36112 NULL
97262 +simple_xattr_alloc_36118 simple_xattr_alloc 2 36118 NULL
97263 +compat_ptrace_request_36131 compat_ptrace_request 3-4 36131 NULL
97264 +vmalloc_exec_36132 vmalloc_exec 1 36132 NULL
97265 +ext3_readpages_36144 ext3_readpages 4 36144 NULL
97266 +iwl_trans_txq_alloc_36147 iwl_trans_txq_alloc 3 36147 NULL
97267 +alloc_vm_area_36149 alloc_vm_area 1 36149 NULL
97268 +twl_set_36154 twl_set 2 36154 NULL
97269 +b1_alloc_card_36155 b1_alloc_card 1 36155 NULL
97270 +btrfs_file_extent_inline_len_36158 btrfs_file_extent_inline_len 0 36158 NULL
97271 +snd_korg1212_copy_from_36169 snd_korg1212_copy_from 6 36169 NULL
97272 +ubifs_read_nnode_36221 ubifs_read_nnode 0 36221 NULL
97273 +nfqnl_mangle_36226 nfqnl_mangle 4-2 36226 NULL
97274 +atomic_stats_read_36228 atomic_stats_read 3 36228 NULL
97275 +viafb_iga1_odev_proc_write_36241 viafb_iga1_odev_proc_write 3 36241 NULL
97276 +rproc_recovery_read_36245 rproc_recovery_read 3 36245 NULL
97277 +scrub_stripe_36248 scrub_stripe 5-4 36248 NULL
97278 +compat_sys_mbind_36256 compat_sys_mbind 5 36256 NULL
97279 +usb_buffer_alloc_36276 usb_buffer_alloc 2 36276 NULL
97280 +codec_reg_read_file_36280 codec_reg_read_file 3 36280 NULL
97281 +crypto_shash_digestsize_36284 crypto_shash_digestsize 0 36284 NULL
97282 +readahead_tree_block_36285 readahead_tree_block 3 36285 NULL
97283 +nouveau_cli_create_36293 nouveau_cli_create 3 36293 NULL
97284 +lpfc_debugfs_dif_err_read_36303 lpfc_debugfs_dif_err_read 3 36303 NULL
97285 +ad7879_spi_xfer_36311 ad7879_spi_xfer 3 36311 NULL
97286 +fat_compat_ioctl_filldir_36328 fat_compat_ioctl_filldir 3 36328 NULL
97287 +lc_create_36332 lc_create 4 36332 NULL
97288 +jbd2_journal_init_revoke_table_36336 jbd2_journal_init_revoke_table 1 36336 NULL
97289 +v9fs_file_readn_36353 v9fs_file_readn 4 36353 NULL nohasharray
97290 +xz_dec_lzma2_create_36353 xz_dec_lzma2_create 2 36353 &v9fs_file_readn_36353
97291 +to_sector_36361 to_sector 0-1 36361 NULL
97292 +tunables_read_36385 tunables_read 3 36385 NULL
97293 +afs_alloc_flat_call_36399 afs_alloc_flat_call 2-3 36399 NULL
97294 +sctp_tsnmap_init_36446 sctp_tsnmap_init 2 36446 NULL
97295 +alloc_etherdev_mqs_36450 alloc_etherdev_mqs 1 36450 NULL
97296 +b43_nphy_load_samples_36481 b43_nphy_load_samples 3 36481 NULL
97297 +tx_tx_checksum_result_read_36490 tx_tx_checksum_result_read 3 36490 NULL
97298 +__hwahc_op_set_ptk_36510 __hwahc_op_set_ptk 5 36510 NULL
97299 +mcam_v4l_read_36513 mcam_v4l_read 3 36513 NULL
97300 +get_param_l_36518 get_param_l 0 36518 NULL
97301 +ieee80211_if_read_fwded_frames_36520 ieee80211_if_read_fwded_frames 3 36520 NULL
97302 +lguest_setup_irq_36531 lguest_setup_irq 1 36531 NULL
97303 +crypto_aead_authsize_36537 crypto_aead_authsize 0 36537 NULL
97304 +ssd1307fb_write_data_array_36538 ssd1307fb_write_data_array 3 36538 NULL
97305 +cpu_type_read_36540 cpu_type_read 3 36540 NULL
97306 +get_entry_len_36549 get_entry_len 0 36549 NULL
97307 +__kfifo_to_user_36555 __kfifo_to_user 3 36555 NULL nohasharray
97308 +macvtap_do_read_36555 macvtap_do_read 4 36555 &__kfifo_to_user_36555
97309 +btrfs_get_token_64_36572 btrfs_get_token_64 0 36572 NULL
97310 +ssb_bus_scan_36578 ssb_bus_scan 2 36578 NULL
97311 +__erst_read_36579 __erst_read 0 36579 NULL
97312 +put_cmsg_36589 put_cmsg 4 36589 NULL
97313 +pcnet32_realloc_rx_ring_36598 pcnet32_realloc_rx_ring 3 36598 NULL
97314 +fat_ioctl_filldir_36621 fat_ioctl_filldir 3 36621 NULL
97315 +vxge_config_vpaths_36636 vxge_config_vpaths 0 36636 NULL
97316 +format_decode_36638 format_decode 0 36638 NULL
97317 +ced_ioctl_36647 ced_ioctl 2 36647 NULL
97318 +lpfc_idiag_extacc_alloc_get_36648 lpfc_idiag_extacc_alloc_get 0-3 36648 NULL
97319 +osd_req_list_collection_objects_36664 osd_req_list_collection_objects 5 36664 NULL
97320 +iscsi_host_alloc_36671 iscsi_host_alloc 2 36671 NULL
97321 +ptr_to_compat_36680 ptr_to_compat 0 36680 NULL
97322 +ext4_mb_discard_group_preallocations_36685 ext4_mb_discard_group_preallocations 2 36685 NULL
97323 +snd_soc_update_bits_36714 snd_soc_update_bits 2 36714 NULL
97324 +extract_icmp6_fields_36732 extract_icmp6_fields 2 36732 NULL
97325 +snd_rawmidi_kernel_read1_36740 snd_rawmidi_kernel_read1 4 36740 NULL
97326 +cxgbi_device_register_36746 cxgbi_device_register 1-2 36746 NULL
97327 +ps_poll_upsd_timeouts_read_36755 ps_poll_upsd_timeouts_read 3 36755 NULL
97328 +snd_soc_update_bits_locked_36766 snd_soc_update_bits_locked 2 36766 NULL
97329 +ip4ip6_err_36772 ip4ip6_err 5 36772 NULL
97330 +ptp_filter_init_36780 ptp_filter_init 2 36780 NULL
97331 +proc_fault_inject_read_36802 proc_fault_inject_read 3 36802 NULL
97332 +hiddev_ioctl_36816 hiddev_ioctl 2 36816 NULL
97333 +int_hardware_entry_36833 int_hardware_entry 3 36833 NULL
97334 +pcf50633_reg_write_36841 pcf50633_reg_write 2 36841 NULL nohasharray
97335 +fc_change_queue_depth_36841 fc_change_queue_depth 2 36841 &pcf50633_reg_write_36841
97336 +keyctl_describe_key_36853 keyctl_describe_key 3 36853 NULL
97337 +cm_write_36858 cm_write 3 36858 NULL
97338 +tx_tx_data_programmed_read_36871 tx_tx_data_programmed_read 3 36871 NULL
97339 +svc_setsockopt_36876 svc_setsockopt 5 36876 NULL
97340 +ib_ucm_alloc_data_36885 ib_ucm_alloc_data 3 36885 NULL
97341 +selinux_inode_notifysecctx_36896 selinux_inode_notifysecctx 3 36896 NULL
97342 +lm3533_als_get_target_36905 lm3533_als_get_target 2-3 36905 NULL
97343 +OS_kmalloc_36909 OS_kmalloc 1 36909 NULL
97344 +crypto_blkcipher_ivsize_36944 crypto_blkcipher_ivsize 0 36944 NULL
97345 +div_u64_36951 div_u64 0 36951 NULL
97346 +write_leb_36957 write_leb 5 36957 NULL
97347 +ntfs_external_attr_find_36963 ntfs_external_attr_find 0 36963 NULL
97348 +sparse_early_mem_maps_alloc_node_36971 sparse_early_mem_maps_alloc_node 4 36971 NULL
97349 +mc13xxx_reg_rmw_36997 mc13xxx_reg_rmw 2 36997 NULL
97350 +drbd_new_dev_size_36998 drbd_new_dev_size 0-3 36998 NULL
97351 +auok190xfb_write_37001 auok190xfb_write 3 37001 NULL
97352 +setxattr_37006 setxattr 4 37006 NULL
97353 +ieee80211_if_read_drop_unencrypted_37053 ieee80211_if_read_drop_unencrypted 3 37053 NULL
97354 +parse_command_37079 parse_command 2 37079 NULL
97355 +wm8994_gpio_set_37082 wm8994_gpio_set 2 37082 NULL
97356 +pipeline_cs_rx_packet_in_read_37089 pipeline_cs_rx_packet_in_read 3 37089 NULL
97357 +tun_get_user_37094 tun_get_user 5 37094 NULL
97358 +has_wrprotected_page_37123 has_wrprotected_page 2-3 37123 NULL
97359 +msg_word_37164 msg_word 0 37164 NULL
97360 +can_set_xattr_37182 can_set_xattr 4 37182 NULL
97361 +crypto_shash_descsize_37212 crypto_shash_descsize 0 37212 NULL
97362 +regmap_access_read_file_37223 regmap_access_read_file 3 37223 NULL
97363 +__do_replace_37227 __do_replace 5 37227 NULL
97364 +rx_filter_dup_filter_read_37238 rx_filter_dup_filter_read 3 37238 NULL
97365 +prot_queue_del_37258 prot_queue_del 0 37258 NULL
97366 +ath6kl_wmi_set_ie_cmd_37260 ath6kl_wmi_set_ie_cmd 6 37260 NULL
97367 +exofs_max_io_pages_37263 exofs_max_io_pages 0-2 37263 NULL
97368 +c101_run_37279 c101_run 2 37279 NULL
97369 +srp_target_alloc_37288 srp_target_alloc 3 37288 NULL
97370 +jffs2_write_dirent_37311 jffs2_write_dirent 5 37311 NULL
97371 +send_msg_37323 send_msg 4 37323 NULL
97372 +brcmf_sdbrcm_membytes_37324 brcmf_sdbrcm_membytes 3-5 37324 NULL
97373 +l2cap_create_connless_pdu_37327 l2cap_create_connless_pdu 3 37327 NULL
97374 +scsi_mode_select_37330 scsi_mode_select 6 37330 NULL
97375 +rxrpc_server_sendmsg_37331 rxrpc_server_sendmsg 4 37331 NULL
97376 +security_inode_getsecurity_37354 security_inode_getsecurity 0 37354 NULL
97377 +iommu_num_pages_37391 iommu_num_pages 0-1-3-2 37391 NULL
97378 +sys_getxattr_37418 sys_getxattr 4 37418 NULL
97379 +hci_sock_sendmsg_37420 hci_sock_sendmsg 4 37420 NULL
97380 +acpi_os_allocate_zeroed_37422 acpi_os_allocate_zeroed 1 37422 NULL nohasharray
97381 +find_next_bit_37422 find_next_bit 0-2-3 37422 &acpi_os_allocate_zeroed_37422
97382 +tty_insert_flip_string_fixed_flag_37428 tty_insert_flip_string_fixed_flag 4 37428 NULL
97383 +iwl_print_last_event_logs_37433 iwl_print_last_event_logs 0-7-9 37433 NULL
97384 +tcp_established_options_37450 tcp_established_options 0 37450 NULL
97385 +brcmf_sdio_dump_console_37455 brcmf_sdio_dump_console 4 37455 NULL
97386 +ufs_data_ptr_to_cpu_37475 ufs_data_ptr_to_cpu 0 37475 NULL
97387 +get_est_timing_37484 get_est_timing 0 37484 NULL
97388 +xfs_trans_read_buf_map_37487 xfs_trans_read_buf_map 5 37487 NULL
97389 +kmem_realloc_37489 kmem_realloc 2 37489 NULL
97390 +kvm_vcpu_compat_ioctl_37500 kvm_vcpu_compat_ioctl 3 37500 NULL
97391 +vmalloc_32_user_37519 vmalloc_32_user 1 37519 NULL
97392 +fault_inject_read_37534 fault_inject_read 3 37534 NULL
97393 +hdr_size_37536 hdr_size 0 37536 NULL
97394 +sep_create_dcb_dmatables_context_37551 sep_create_dcb_dmatables_context 6 37551 NULL nohasharray
97395 +nf_nat_mangle_tcp_packet_37551 nf_nat_mangle_tcp_packet 6-8 37551 &sep_create_dcb_dmatables_context_37551
97396 +xhci_alloc_streams_37586 xhci_alloc_streams 5 37586 NULL
97397 +mlx4_get_mgm_entry_size_37607 mlx4_get_mgm_entry_size 0 37607 NULL
97398 +kvm_read_guest_page_mmu_37611 kvm_read_guest_page_mmu 6 37611 NULL
97399 +alloc_fd_37637 alloc_fd 1 37637 NULL
97400 +bio_copy_user_iov_37660 bio_copy_user_iov 4 37660 NULL
97401 +rfcomm_sock_sendmsg_37661 rfcomm_sock_sendmsg 4 37661 NULL nohasharray
97402 +vmw_framebuffer_dmabuf_dirty_37661 vmw_framebuffer_dmabuf_dirty 6 37661 &rfcomm_sock_sendmsg_37661
97403 +lnw_gpio_to_irq_37665 lnw_gpio_to_irq 2 37665 NULL
97404 +ieee80211_if_read_rc_rateidx_mcs_mask_2ghz_37675 ieee80211_if_read_rc_rateidx_mcs_mask_2ghz 3 37675 NULL
97405 +regmap_map_read_file_37685 regmap_map_read_file 3 37685 NULL
97406 +nametbl_header_37698 nametbl_header 2 37698 NULL
97407 +__le32_to_cpup_37702 __le32_to_cpup 0 37702 NULL
97408 +soc_widget_update_bits_locked_37715 soc_widget_update_bits_locked 2 37715 NULL
97409 +read_enabled_file_bool_37744 read_enabled_file_bool 3 37744 NULL
97410 +ocfs2_duplicate_clusters_by_jbd_37749 ocfs2_duplicate_clusters_by_jbd 6-4-5 37749 NULL
97411 +ocfs2_control_cfu_37750 ocfs2_control_cfu 2 37750 NULL
97412 +ipath_cdev_init_37752 ipath_cdev_init 1 37752 NULL
97413 +dccp_setsockopt_cscov_37766 dccp_setsockopt_cscov 2 37766 NULL
97414 +il4965_rs_sta_dbgfs_rate_scale_data_read_37792 il4965_rs_sta_dbgfs_rate_scale_data_read 3 37792 NULL
97415 +smk_read_logging_37804 smk_read_logging 3 37804 NULL
97416 +deny_write_access_37813 deny_write_access 0 37813 NULL
97417 +rx_decrypt_key_not_found_read_37820 rx_decrypt_key_not_found_read 3 37820 NULL
97418 +bitmap_find_next_zero_area_37827 bitmap_find_next_zero_area 2-3-5-4 37827 NULL
97419 +o2hb_debug_read_37851 o2hb_debug_read 3 37851 NULL
97420 +xfs_dir2_block_to_sf_37868 xfs_dir2_block_to_sf 3 37868 NULL
97421 +sys_setxattr_37880 sys_setxattr 4 37880 NULL
97422 +lm3533_als_get_target_reg_37881 lm3533_als_get_target_reg 0-1-2 37881 NULL
97423 +dvb_net_sec_37884 dvb_net_sec 3 37884 NULL
97424 +max77686_irq_domain_map_37897 max77686_irq_domain_map 2 37897 NULL
97425 +tipc_link_send_sections_fast_37920 tipc_link_send_sections_fast 4 37920 NULL
97426 +pkt_alloc_packet_data_37928 pkt_alloc_packet_data 1 37928 NULL
97427 +read_rbu_packet_size_37939 read_rbu_packet_size 6 37939 NULL
97428 +fifo_alloc_37961 fifo_alloc 1 37961 NULL
97429 +ext3_free_blocks_sb_37967 ext3_free_blocks_sb 3-4 37967 NULL
97430 +rds_rdma_extra_size_37990 rds_rdma_extra_size 0 37990 NULL
97431 +persistent_ram_old_size_37997 persistent_ram_old_size 0 37997 NULL
97432 +vfs_readv_38011 vfs_readv 3 38011 NULL
97433 +aggr_recv_addba_req_evt_38037 aggr_recv_addba_req_evt 4 38037 NULL
97434 +klsi_105_prepare_write_buffer_38044 klsi_105_prepare_write_buffer 3 38044 NULL nohasharray
97435 +il_dbgfs_chain_noise_read_38044 il_dbgfs_chain_noise_read 3 38044 &klsi_105_prepare_write_buffer_38044
97436 +_xfs_buf_alloc_38058 _xfs_buf_alloc 3 38058 NULL
97437 +nsm_create_handle_38060 nsm_create_handle 4 38060 NULL
97438 +alloc_ltalkdev_38071 alloc_ltalkdev 1 38071 NULL
97439 +xfs_buf_readahead_map_38081 xfs_buf_readahead_map 3 38081 NULL
97440 +uwb_mac_addr_print_38085 uwb_mac_addr_print 2 38085 NULL
97441 +request_key_auth_new_38092 request_key_auth_new 3 38092 NULL
97442 +proc_self_readlink_38094 proc_self_readlink 3 38094 NULL
97443 +ep0_read_38095 ep0_read 3 38095 NULL
97444 +sk_wmem_schedule_38096 sk_wmem_schedule 2 38096 NULL
97445 +snd_pcm_oss_write_38108 snd_pcm_oss_write 3 38108 NULL
97446 +vmw_kms_present_38130 vmw_kms_present 9 38130 NULL
97447 +__ntfs_copy_from_user_iovec_inatomic_38153 __ntfs_copy_from_user_iovec_inatomic 3-4 38153 NULL
97448 +kvm_clear_guest_38164 kvm_clear_guest 3-2 38164 NULL
97449 +cdev_add_38176 cdev_add 2-3 38176 NULL
97450 +brcmf_sdcard_recv_buf_38179 brcmf_sdcard_recv_buf 6 38179 NULL
97451 +rt2x00debug_write_rf_38195 rt2x00debug_write_rf 3 38195 NULL
97452 +get_ucode_user_38202 get_ucode_user 3 38202 NULL
97453 +ext3_new_block_38208 ext3_new_block 3 38208 NULL
97454 +stmpe_gpio_irq_map_38222 stmpe_gpio_irq_map 3 38222 NULL
97455 +osd_req_list_partition_collections_38223 osd_req_list_partition_collections 5 38223 NULL
97456 +vhost_net_compat_ioctl_38237 vhost_net_compat_ioctl 3 38237 NULL
97457 +_ipw_read_reg32_38245 _ipw_read_reg32 0 38245 NULL
97458 +snd_pcm_playback_rewind_38249 snd_pcm_playback_rewind 0-2 38249 NULL
97459 +ieee80211_if_read_auto_open_plinks_38268 ieee80211_if_read_auto_open_plinks 3 38268 NULL nohasharray
97460 +mthca_alloc_icm_table_38268 mthca_alloc_icm_table 4-3 38268 &ieee80211_if_read_auto_open_plinks_38268
97461 +verity_status_38273 verity_status 5 38273 NULL
97462 +xfs_bmdr_to_bmbt_38275 xfs_bmdr_to_bmbt 5 38275 NULL nohasharray
97463 +xfs_bmbt_to_bmdr_38275 xfs_bmbt_to_bmdr 3 38275 &xfs_bmdr_to_bmbt_38275
97464 +zd_mac_rx_38296 zd_mac_rx 3 38296 NULL
97465 +ieee80211_send_probe_req_38307 ieee80211_send_probe_req 6-4 38307 NULL
97466 +isr_rx_headers_read_38325 isr_rx_headers_read 3 38325 NULL
97467 +ida_simple_get_38326 ida_simple_get 2 38326 NULL
97468 +__snd_gf1_look8_38333 __snd_gf1_look8 0 38333 NULL
97469 +pyra_sysfs_write_38370 pyra_sysfs_write 6 38370 NULL
97470 +dn_sendmsg_38390 dn_sendmsg 4 38390 NULL
97471 +get_valid_node_allowed_38412 get_valid_node_allowed 1-0 38412 NULL
97472 +ocfs2_which_cluster_group_38413 ocfs2_which_cluster_group 2 38413 NULL
97473 +ht_destroy_irq_38418 ht_destroy_irq 1 38418 NULL
97474 +ieee80211_if_read_dtim_count_38419 ieee80211_if_read_dtim_count 3 38419 NULL
97475 +asix_write_cmd_async_38420 asix_write_cmd_async 5 38420 NULL
97476 +pcnet32_realloc_tx_ring_38428 pcnet32_realloc_tx_ring 3 38428 NULL
97477 +pmcraid_copy_sglist_38431 pmcraid_copy_sglist 3 38431 NULL
97478 +kvm_write_guest_38454 kvm_write_guest 4-2 38454 NULL
97479 +i915_min_freq_read_38470 i915_min_freq_read 3 38470 NULL
97480 +blk_end_bidi_request_38482 blk_end_bidi_request 3-4 38482 NULL
97481 +cpu_to_mem_38501 cpu_to_mem 0 38501 NULL
97482 +dev_names_read_38509 dev_names_read 3 38509 NULL
97483 +iscsi_create_iface_38510 iscsi_create_iface 5 38510 NULL
97484 +event_rx_mismatch_read_38518 event_rx_mismatch_read 3 38518 NULL
97485 +set_queue_count_38519 set_queue_count 0 38519 NULL
97486 +ubifs_idx_node_sz_38546 ubifs_idx_node_sz 0-2 38546 NULL
97487 +btrfs_discard_extent_38547 btrfs_discard_extent 2 38547 NULL
97488 +cpu_to_node_38561 cpu_to_node 0 38561 NULL
97489 +irda_sendmsg_dgram_38563 irda_sendmsg_dgram 4 38563 NULL
97490 +il4965_rs_sta_dbgfs_scale_table_read_38564 il4965_rs_sta_dbgfs_scale_table_read 3 38564 NULL
97491 +_ipw_read32_38565 _ipw_read32 0 38565 NULL
97492 +snd_nm256_playback_copy_38567 snd_nm256_playback_copy 5-3 38567 NULL
97493 +copy_ctl_value_to_user_38587 copy_ctl_value_to_user 4 38587 NULL
97494 +cosa_net_setup_rx_38594 cosa_net_setup_rx 2 38594 NULL
97495 +compat_sys_ptrace_38595 compat_sys_ptrace 3-4 38595 NULL
97496 +delay_status_38606 delay_status 5 38606 NULL
97497 +icn_writecmd_38629 icn_writecmd 2 38629 NULL
97498 +ext2_readpages_38640 ext2_readpages 4 38640 NULL
97499 +cma_create_area_38642 cma_create_area 2 38642 NULL
97500 +audit_init_entry_38644 audit_init_entry 1 38644 NULL
97501 +mmc_send_cxd_data_38655 mmc_send_cxd_data 5 38655 NULL
97502 +nouveau_instmem_create__38664 nouveau_instmem_create_ 4 38664 NULL
97503 +cfg80211_send_disassoc_38678 cfg80211_send_disassoc 3 38678 NULL
97504 +iscsit_dump_data_payload_38683 iscsit_dump_data_payload 2 38683 NULL
97505 +ext4_wait_block_bitmap_38695 ext4_wait_block_bitmap 2 38695 NULL
97506 +find_next_usable_block_38716 find_next_usable_block 1-3 38716 NULL
97507 +alloc_trace_probe_38720 alloc_trace_probe 6 38720 NULL
97508 +udf_readpages_38761 udf_readpages 4 38761 NULL
97509 +iwl_dbgfs_thermal_throttling_read_38779 iwl_dbgfs_thermal_throttling_read 3 38779 NULL
97510 +snd_gus_dram_write_38784 snd_gus_dram_write 4 38784 NULL
97511 +err_decode_38804 err_decode 2 38804 NULL
97512 +ipv6_renew_option_38813 ipv6_renew_option 3 38813 NULL
97513 +sys_select_38827 sys_select 1 38827 NULL
97514 +b43_txhdr_size_38832 b43_txhdr_size 0 38832 NULL
97515 +direct_entry_38836 direct_entry 3 38836 NULL
97516 +compat_udp_setsockopt_38840 compat_udp_setsockopt 5 38840 NULL
97517 +interfaces_38859 interfaces 2 38859 NULL
97518 +pci_msix_table_size_38867 pci_msix_table_size 0 38867 NULL
97519 +sizeof_gpio_leds_priv_38882 sizeof_gpio_leds_priv 0-1 38882 NULL
97520 +dbgfs_state_38894 dbgfs_state 3 38894 NULL
97521 +f2fs_xattr_set_acl_38895 f2fs_xattr_set_acl 4 38895 NULL
97522 +__fswab16_38898 __fswab16 0 38898 NULL
97523 +process_bulk_data_command_38906 process_bulk_data_command 4 38906 NULL
97524 +ext3_trim_all_free_38929 ext3_trim_all_free 3-4-2 38929 NULL
97525 +sbp_count_se_tpg_luns_38943 sbp_count_se_tpg_luns 0 38943 NULL
97526 +__ath6kl_wmi_send_mgmt_cmd_38971 __ath6kl_wmi_send_mgmt_cmd 7 38971 NULL
97527 +usb_maxpacket_38977 usb_maxpacket 0 38977 NULL
97528 +OSDSetBlock_38986 OSDSetBlock 4-2 38986 NULL
97529 +udf_new_block_38999 udf_new_block 4 38999 NULL
97530 +get_nodes_39012 get_nodes 3 39012 NULL
97531 +twl6030_interrupt_unmask_39013 twl6030_interrupt_unmask 2 39013 NULL
97532 +acpi_install_gpe_block_39031 acpi_install_gpe_block 4 39031 NULL
97533 +_zd_iowrite32v_async_locked_39034 _zd_iowrite32v_async_locked 3 39034 NULL
97534 +line6_midibuf_read_39067 line6_midibuf_read 0-3 39067 NULL
97535 +ext4_init_block_bitmap_39071 ext4_init_block_bitmap 3 39071 NULL
97536 +tun_get_user_39099 tun_get_user 4 39099 NULL
97537 +tomoyo_truncate_39105 tomoyo_truncate 0 39105 NULL
97538 +__kfifo_to_user_r_39123 __kfifo_to_user_r 3 39123 NULL
97539 +ea_foreach_39133 ea_foreach 0 39133 NULL
97540 +generic_permission_39150 generic_permission 0 39150 NULL
97541 +alloc_ring_39151 alloc_ring 2-4 39151 NULL
97542 +proc_coredump_filter_read_39153 proc_coredump_filter_read 3 39153 NULL
97543 +create_bounce_buffer_39155 create_bounce_buffer 3 39155 NULL
97544 +ext3_xattr_check_names_39174 ext3_xattr_check_names 0 39174 NULL
97545 +init_list_set_39188 init_list_set 2-3 39188 NULL
97546 +ubi_more_update_data_39189 ubi_more_update_data 4 39189 NULL
97547 +qcam_read_bytes_39205 qcam_read_bytes 0 39205 NULL
97548 +qla4_82xx_pci_mem_read_direct_39208 qla4_82xx_pci_mem_read_direct 2 39208 NULL
97549 +vfio_group_fops_compat_ioctl_39219 vfio_group_fops_compat_ioctl 3 39219 NULL
97550 +ivtv_v4l2_write_39226 ivtv_v4l2_write 3 39226 NULL
97551 +batadv_tt_response_fill_table_39236 batadv_tt_response_fill_table 1 39236 NULL
97552 +posix_acl_to_xattr_39237 posix_acl_to_xattr 0 39237 NULL
97553 +drm_order_39244 drm_order 0 39244 NULL
97554 +snd_pcm_capture_forward_39248 snd_pcm_capture_forward 0-2 39248 NULL
97555 +r128_compat_ioctl_39250 r128_compat_ioctl 2 39250 NULL nohasharray
97556 +pwr_cont_miss_bcns_spread_read_39250 pwr_cont_miss_bcns_spread_read 3 39250 &r128_compat_ioctl_39250
97557 +__skb_cow_39254 __skb_cow 2 39254 NULL
97558 +ath6kl_wmi_set_appie_cmd_39266 ath6kl_wmi_set_appie_cmd 5 39266 NULL
97559 +rx_filter_protection_filter_read_39282 rx_filter_protection_filter_read 3 39282 NULL
97560 +__vmalloc_node_39308 __vmalloc_node 1 39308 NULL
97561 +__cfg80211_connect_result_39326 __cfg80211_connect_result 4-6 39326 NULL
97562 +wimax_msg_alloc_39343 wimax_msg_alloc 4 39343 NULL
97563 +__cfg80211_send_deauth_39344 __cfg80211_send_deauth 3 39344 NULL
97564 +__copy_from_user_nocache_39351 __copy_from_user_nocache 3 39351 NULL
97565 +ide_complete_rq_39354 ide_complete_rq 3 39354 NULL
97566 +do_write_log_from_user_39362 do_write_log_from_user 3 39362 NULL
97567 +vortex_wtdma_getlinearpos_39371 vortex_wtdma_getlinearpos 0 39371 NULL
97568 +regmap_name_read_file_39379 regmap_name_read_file 3 39379 NULL
97569 +ps_poll_ps_poll_utilization_read_39383 ps_poll_ps_poll_utilization_read 3 39383 NULL
97570 +__send_to_port_39386 __send_to_port 3 39386 NULL
97571 +user_power_read_39414 user_power_read 3 39414 NULL
97572 +alloc_agpphysmem_i8xx_39427 alloc_agpphysmem_i8xx 1 39427 NULL
97573 +sys_semop_39457 sys_semop 3 39457 NULL
97574 +setkey_unaligned_39474 setkey_unaligned 3 39474 NULL
97575 +ieee80211_if_fmt_dot11MeshHWMPmaxPREQretries_39499 ieee80211_if_fmt_dot11MeshHWMPmaxPREQretries 3 39499 NULL
97576 +atomic64_read_unchecked_39505 atomic64_read_unchecked 0 39505 NULL
97577 +int_proc_write_39542 int_proc_write 3 39542 NULL
97578 +pp_write_39554 pp_write 3 39554 NULL
97579 +ol_dqblk_block_39558 ol_dqblk_block 0-3-2 39558 NULL
97580 +datablob_format_39571 datablob_format 2 39571 NULL nohasharray
97581 +ieee80211_if_read_fwded_mcast_39571 ieee80211_if_read_fwded_mcast 3 39571 &datablob_format_39571
97582 +handle_response_icmp_39574 handle_response_icmp 7 39574 NULL
97583 +adau1373_set_pll_39593 adau1373_set_pll 2 39593 NULL
97584 +mtdchar_compat_ioctl_39602 mtdchar_compat_ioctl 3 39602 NULL
97585 +n_tty_compat_ioctl_helper_39605 n_tty_compat_ioctl_helper 4 39605 NULL
97586 +ext_depth_39607 ext_depth 0 39607 NULL
97587 +nfs_idmap_get_key_39616 nfs_idmap_get_key 2 39616 NULL
97588 +sdio_readb_39618 sdio_readb 0 39618 NULL
97589 +dm_exception_table_init_39645 dm_exception_table_init 2 39645 NULL nohasharray
97590 +set_dev_class_39645 set_dev_class 4 39645 &dm_exception_table_init_39645
97591 +snd_rme32_capture_copy_39653 snd_rme32_capture_copy 5 39653 NULL
97592 +tcp_try_rmem_schedule_39657 tcp_try_rmem_schedule 3 39657 NULL nohasharray
97593 +prism2_info_hostscanresults_39657 prism2_info_hostscanresults 3 39657 &tcp_try_rmem_schedule_39657
97594 +kvm_read_guest_cached_39666 kvm_read_guest_cached 4 39666 NULL
97595 +v4l_stk_read_39672 v4l_stk_read 3 39672 NULL
97596 +hsc_msg_len_get_39673 hsc_msg_len_get 0 39673 NULL
97597 +do_surface_dirty_sou_39678 do_surface_dirty_sou 7 39678 NULL
97598 +ftrace_pid_write_39710 ftrace_pid_write 3 39710 NULL
97599 +tcf_csum_ipv4_tcp_39713 tcf_csum_ipv4_tcp 4 39713 NULL
97600 +ocfs2_pages_per_cluster_39790 ocfs2_pages_per_cluster 0 39790 NULL
97601 +security_inode_listsecurity_39812 security_inode_listsecurity 0 39812 NULL
97602 +snd_pcm_oss_writev3_39818 snd_pcm_oss_writev3 3 39818 NULL
97603 +sys_migrate_pages_39825 sys_migrate_pages 2 39825 NULL
97604 +get_priv_size_39828 get_priv_size 0-1 39828 NULL
97605 +pkt_add_39897 pkt_add 3 39897 NULL
97606 +read_file_modal_eeprom_39909 read_file_modal_eeprom 3 39909 NULL
97607 +gen_pool_add_virt_39913 gen_pool_add_virt 4 39913 NULL
97608 +dw210x_op_rw_39915 dw210x_op_rw 6 39915 NULL
97609 +aes_encrypt_interrupt_read_39919 aes_encrypt_interrupt_read 3 39919 NULL
97610 +exofs_read_kern_39921 exofs_read_kern 6 39921 NULL nohasharray
97611 +oom_score_adj_read_39921 oom_score_adj_read 3 39921 &exofs_read_kern_39921
97612 +__spi_async_39932 __spi_async 0 39932 NULL
97613 +__get_order_39935 __get_order 0 39935 NULL
97614 +error_error_frame_read_39947 error_error_frame_read 3 39947 NULL nohasharray
97615 +fwnet_pd_new_39947 fwnet_pd_new 4 39947 &error_error_frame_read_39947
97616 +tty_prepare_flip_string_39955 tty_prepare_flip_string 3 39955 NULL
97617 +dma_push_rx_39973 dma_push_rx 2 39973 NULL
97618 +broadsheetfb_write_39976 broadsheetfb_write 3 39976 NULL
97619 +mthca_array_init_39987 mthca_array_init 2 39987 NULL
97620 +xen_hvm_config_40018 xen_hvm_config 2 40018 NULL
97621 +nf_nat_icmpv6_reply_translation_40023 nf_nat_icmpv6_reply_translation 5 40023 NULL nohasharray
97622 +ivtvfb_write_40023 ivtvfb_write 3 40023 &nf_nat_icmpv6_reply_translation_40023
97623 +ea_foreach_i_40028 ea_foreach_i 0 40028 NULL
97624 +datablob_hmac_append_40038 datablob_hmac_append 3 40038 NULL
97625 +regmap_add_irq_chip_40042 regmap_add_irq_chip 4 40042 NULL
97626 +add_tty_40055 add_tty 1 40055 NULL nohasharray
97627 +l2cap_create_iframe_pdu_40055 l2cap_create_iframe_pdu 3 40055 &add_tty_40055
97628 +atomic_xchg_40070 atomic_xchg 0 40070 NULL
97629 +snd_pcm_sw_params_user_40095 snd_pcm_sw_params_user 0 40095 NULL
97630 +gen_pool_first_fit_40110 gen_pool_first_fit 2-3-4 40110 NULL
97631 +rbd_do_op_40128 rbd_do_op 4-5 40128 NULL
97632 +sctp_setsockopt_delayed_ack_40129 sctp_setsockopt_delayed_ack 3 40129 NULL
97633 +rx_rx_frame_checksum_read_40140 rx_rx_frame_checksum_read 3 40140 NULL
97634 +iwch_alloc_fastreg_pbl_40153 iwch_alloc_fastreg_pbl 2 40153 NULL
97635 +pt_write_40159 pt_write 3 40159 NULL
97636 +scsi_sg_count_40182 scsi_sg_count 0 40182 NULL
97637 +ipr_alloc_ucode_buffer_40199 ipr_alloc_ucode_buffer 1 40199 NULL nohasharray
97638 +devnode_find_40199 devnode_find 3-2 40199 &ipr_alloc_ucode_buffer_40199
97639 +allocate_probes_40204 allocate_probes 1 40204 NULL
97640 +acpi_system_write_alarm_40205 acpi_system_write_alarm 3 40205 NULL
97641 +compat_put_long_40214 compat_put_long 1 40214 NULL
97642 +au0828_v4l2_read_40220 au0828_v4l2_read 3 40220 NULL
97643 +xfs_buf_read_map_40226 xfs_buf_read_map 3 40226 NULL
97644 +osst_read_40237 osst_read 3 40237 NULL
97645 +lpage_info_slot_40243 lpage_info_slot 1-3 40243 NULL
97646 +ocfs2_zero_extend_get_range_40248 ocfs2_zero_extend_get_range 4 40248 NULL
97647 +of_get_child_count_40254 of_get_child_count 0 40254 NULL
97648 +rs_sta_dbgfs_scale_table_read_40262 rs_sta_dbgfs_scale_table_read 3 40262 NULL
97649 +usbnet_read_cmd_40275 usbnet_read_cmd 7 40275 NULL
97650 +rx_xfr_hint_trig_read_40283 rx_xfr_hint_trig_read 3 40283 NULL
97651 +ubi_io_write_data_40305 ubi_io_write_data 4-5 40305 NULL
97652 +batadv_tt_changes_fill_buff_40323 batadv_tt_changes_fill_buff 4 40323 NULL
97653 +ib_get_mad_data_offset_40336 ib_get_mad_data_offset 0 40336 NULL
97654 +mmio_read_40348 mmio_read 4 40348 NULL
97655 +usb_dump_interface_40353 usb_dump_interface 0 40353 NULL
97656 +ocfs2_release_clusters_40355 ocfs2_release_clusters 4 40355 NULL
97657 +event_rx_mem_empty_read_40363 event_rx_mem_empty_read 3 40363 NULL
97658 +ocfs2_check_range_for_refcount_40365 ocfs2_check_range_for_refcount 2-3 40365 NULL
97659 +fwnet_incoming_packet_40380 fwnet_incoming_packet 3 40380 NULL
97660 +brcmf_sdbrcm_get_image_40397 brcmf_sdbrcm_get_image 0-2 40397 NULL
97661 +atmel_rmem16_40450 atmel_rmem16 0 40450 NULL
97662 +tomoyo_update_policy_40458 tomoyo_update_policy 2 40458 NULL
97663 +zd_usb_scnprint_id_40459 zd_usb_scnprint_id 0-3 40459 NULL
97664 +batadv_hash_new_40491 batadv_hash_new 1 40491 NULL
97665 +devcgroup_inode_permission_40492 devcgroup_inode_permission 0 40492 NULL
97666 +tty_write_room_40495 tty_write_room 0 40495 NULL
97667 +persistent_ram_new_40501 persistent_ram_new 1-2 40501 NULL
97668 +sg_phys_40507 sg_phys 0 40507 NULL
97669 +TSS_checkhmac2_40520 TSS_checkhmac2 5-7 40520 NULL
97670 +ixgbe_dbg_reg_ops_read_40540 ixgbe_dbg_reg_ops_read 3 40540 NULL
97671 +ima_write_policy_40548 ima_write_policy 3 40548 NULL
97672 +esp_alloc_tmp_40558 esp_alloc_tmp 3-2 40558 NULL
97673 +ufs_inode_getfrag_40560 ufs_inode_getfrag 2-4 40560 NULL
97674 +arch_setup_hpet_msi_40584 arch_setup_hpet_msi 1 40584 NULL
97675 +skge_rx_get_40598 skge_rx_get 3 40598 NULL
97676 +get_priv_descr_and_size_40612 get_priv_descr_and_size 0 40612 NULL
97677 +bl_mark_sectors_init_40613 bl_mark_sectors_init 2-3 40613 NULL
97678 +cpuset_sprintf_cpulist_40627 cpuset_sprintf_cpulist 0 40627 NULL
97679 +twl4030_kpwrite_u8_40665 twl4030_kpwrite_u8 3 40665 NULL
97680 +__cfg80211_roamed_40668 __cfg80211_roamed 4-6 40668 NULL
97681 +pipeline_rx_complete_stat_fifo_int_read_40671 pipeline_rx_complete_stat_fifo_int_read 3 40671 NULL
97682 +fops_read_40672 fops_read 3 40672 NULL
97683 +tps80031_write_40678 tps80031_write 3 40678 NULL
97684 +nfc_hci_set_param_40697 nfc_hci_set_param 5 40697 NULL
97685 +__seq_open_private_40715 __seq_open_private 3 40715 NULL
97686 +xfs_iext_remove_direct_40744 xfs_iext_remove_direct 3 40744 NULL nohasharray
97687 +find_next_zero_bit_le_40744 find_next_zero_bit_le 0-2-3 40744 &xfs_iext_remove_direct_40744
97688 +tps65910_irq_map_40748 tps65910_irq_map 2 40748 NULL
97689 +security_inode_listxattr_40752 security_inode_listxattr 0 40752 NULL
97690 +fat_generic_compat_ioctl_40755 fat_generic_compat_ioctl 3 40755 NULL
97691 +card_send_command_40757 card_send_command 3 40757 NULL
97692 +ad1889_readl_40765 ad1889_readl 0 40765 NULL
97693 +pg_write_40766 pg_write 3 40766 NULL
97694 +show_list_40775 show_list 3 40775 NULL
97695 +kfifo_out_copy_r_40784 kfifo_out_copy_r 0-3 40784 NULL
97696 +bitmap_weight_40791 bitmap_weight 0-2 40791 NULL
97697 +pyra_sysfs_read_40795 pyra_sysfs_read 6 40795 NULL
97698 +netdev_alloc_skb_ip_align_40811 netdev_alloc_skb_ip_align 2 40811 NULL
97699 +nl80211_send_roamed_40825 nl80211_send_roamed 5-7 40825 NULL
97700 +__mlx4_qp_reserve_range_40847 __mlx4_qp_reserve_range 2-3 40847 NULL
97701 +ocfs2_zero_partial_clusters_40856 ocfs2_zero_partial_clusters 2-3 40856 NULL
97702 +v9fs_file_read_40858 v9fs_file_read 3 40858 NULL
97703 +read_file_queue_40895 read_file_queue 3 40895 NULL
97704 +waiters_read_40902 waiters_read 3 40902 NULL
97705 +isdn_add_channels_40905 isdn_add_channels 3 40905 NULL
97706 +gfs2_ea_find_40913 gfs2_ea_find 0 40913 NULL
97707 +vol_cdev_write_40915 vol_cdev_write 3 40915 NULL
97708 +snd_vx_create_40948 snd_vx_create 4 40948 NULL
97709 +skb_end_offset_40949 skb_end_offset 0 40949 NULL
97710 +wm8994_free_irq_40951 wm8994_free_irq 2 40951 NULL
97711 +rds_sendmsg_40976 rds_sendmsg 4 40976 NULL
97712 +insert_old_idx_40987 insert_old_idx 0 40987 NULL
97713 +il_dbgfs_fh_reg_read_40993 il_dbgfs_fh_reg_read 3 40993 NULL
97714 +mac80211_format_buffer_41010 mac80211_format_buffer 2 41010 NULL
97715 +mtd_block_isbad_41015 mtd_block_isbad 0 41015 NULL
97716 +_req_append_segment_41031 _req_append_segment 2 41031 NULL
97717 +mISDN_sock_sendmsg_41035 mISDN_sock_sendmsg 4 41035 NULL
97718 +ocfs2_xattr_index_block_find_41040 ocfs2_xattr_index_block_find 0 41040 NULL
97719 +vfs_listxattr_41062 vfs_listxattr 0 41062 NULL
97720 +cfg80211_inform_bss_frame_41078 cfg80211_inform_bss_frame 4 41078 NULL
97721 +roccat_read_41093 roccat_read 3 41093 NULL nohasharray
97722 +nvme_map_user_pages_41093 nvme_map_user_pages 3-4 41093 &roccat_read_41093
97723 +dma_attach_41094 dma_attach 5-6 41094 NULL
97724 +provide_user_output_41105 provide_user_output 3 41105 NULL
97725 +f_audio_buffer_alloc_41110 f_audio_buffer_alloc 1 41110 NULL
97726 +v4l2_ctrl_new_int_menu_41151 v4l2_ctrl_new_int_menu 4 41151 NULL
97727 +tx_frag_mpdu_alloc_failed_read_41167 tx_frag_mpdu_alloc_failed_read 3 41167 NULL
97728 +dvb_ca_write_41171 dvb_ca_write 3 41171 NULL
97729 +ol_quota_chunk_block_41177 ol_quota_chunk_block 0-2 41177 NULL
97730 +netif_get_num_default_rss_queues_41187 netif_get_num_default_rss_queues 0 41187 NULL
97731 +compat_sys_process_vm_writev_41194 compat_sys_process_vm_writev 3-5 41194 NULL
97732 +dfs_file_write_41196 dfs_file_write 3 41196 NULL
97733 +xfs_readdir_41200 xfs_readdir 3 41200 NULL
97734 +ocfs2_read_quota_block_41207 ocfs2_read_quota_block 2 41207 NULL
97735 +nfs_page_array_len_41219 nfs_page_array_len 0-2-1 41219 NULL
97736 +hiddev_compat_ioctl_41255 hiddev_compat_ioctl 2-3 41255 NULL
97737 +erst_read_41260 erst_read 0 41260 NULL
97738 +__fprog_create_41263 __fprog_create 2 41263 NULL
97739 +alloc_context_41283 alloc_context 1 41283 NULL
97740 +arch_gnttab_map_shared_41306 arch_gnttab_map_shared 3 41306 NULL
97741 +twl_change_queue_depth_41342 twl_change_queue_depth 2 41342 NULL
97742 +cnic_init_id_tbl_41354 cnic_init_id_tbl 2 41354 NULL
97743 +jbd2_alloc_41359 jbd2_alloc 1 41359 NULL
97744 +kmp_init_41373 kmp_init 2 41373 NULL
97745 +isr_commands_read_41398 isr_commands_read 3 41398 NULL
97746 +sys_flistxattr_41407 sys_flistxattr 3 41407 NULL
97747 +rx_defrag_decrypt_failed_read_41411 rx_defrag_decrypt_failed_read 3 41411 NULL
97748 +xfs_iext_add_41422 xfs_iext_add 3 41422 NULL
97749 +isdn_ppp_fill_rq_41428 isdn_ppp_fill_rq 2 41428 NULL
97750 +lbs_rdrf_read_41431 lbs_rdrf_read 3 41431 NULL
97751 +ext4_trim_extent_41436 ext4_trim_extent 4 41436 NULL
97752 +iio_device_alloc_41440 iio_device_alloc 1 41440 NULL
97753 +ntfs_file_buffered_write_41442 ntfs_file_buffered_write 4-6 41442 NULL
97754 +pcpu_build_alloc_info_41443 pcpu_build_alloc_info 1-2-3 41443 NULL
97755 +layout_leb_in_gaps_41470 layout_leb_in_gaps 0 41470 NULL
97756 +snd_pcm_status_41472 snd_pcm_status 0 41472 NULL
97757 +rt2x00debug_write_rfcsr_41473 rt2x00debug_write_rfcsr 3 41473 NULL
97758 +wep_interrupt_read_41492 wep_interrupt_read 3 41492 NULL
97759 +hpfs_translate_name_41497 hpfs_translate_name 3 41497 NULL
97760 +xfrm_hash_new_size_41505 xfrm_hash_new_size 0-1 41505 NULL
97761 +ldisc_receive_41516 ldisc_receive 4 41516 NULL
97762 +tx_tx_frame_checksum_read_41553 tx_tx_frame_checksum_read 3 41553 NULL
97763 +ath6kl_endpoint_stats_read_41554 ath6kl_endpoint_stats_read 3 41554 NULL
97764 +gserial_setup_41558 gserial_setup 2 41558 NULL
97765 +nr_status_frames_41559 nr_status_frames 0-1 41559 NULL
97766 +batadv_receive_client_update_packet_41578 batadv_receive_client_update_packet 3 41578 NULL
97767 +rng_dev_read_41581 rng_dev_read 3 41581 NULL
97768 +read_file_rx_chainmask_41605 read_file_rx_chainmask 3 41605 NULL
97769 +vga_io_r_41609 vga_io_r 0 41609 NULL
97770 +usb_endpoint_maxp_41613 usb_endpoint_maxp 0 41613 NULL
97771 +a2mp_send_41615 a2mp_send 4 41615 NULL
97772 +mempool_create_kmalloc_pool_41650 mempool_create_kmalloc_pool 1 41650 NULL
97773 +rx_rx_pre_complt_read_41653 rx_rx_pre_complt_read 3 41653 NULL
97774 +get_std_timing_41654 get_std_timing 0 41654 NULL
97775 +squashfs_cache_init_41656 squashfs_cache_init 2 41656 NULL
97776 +ieee80211_if_fmt_bssid_41677 ieee80211_if_fmt_bssid 3 41677 NULL
97777 +params_period_bytes_41683 params_period_bytes 0 41683 NULL
97778 +aac_src_ioremap_41688 aac_src_ioremap 2 41688 NULL
97779 +bdx_tx_db_init_41719 bdx_tx_db_init 2 41719 NULL
97780 +sys_pwritev_41722 sys_pwritev 3 41722 NULL
97781 +get_bios_ebda_41730 get_bios_ebda 0 41730 NULL
97782 +fillonedir_41746 fillonedir 3 41746 NULL
97783 +ocfs2_dx_dir_rebalance_41793 ocfs2_dx_dir_rebalance 7 41793 NULL
97784 +hsi_alloc_controller_41802 hsi_alloc_controller 1 41802 NULL
97785 +da9052_enable_irq_41814 da9052_enable_irq 2 41814 NULL
97786 +sco_send_frame_41815 sco_send_frame 3 41815 NULL
97787 +ixgbe_dbg_netdev_ops_read_41839 ixgbe_dbg_netdev_ops_read 3 41839 NULL
97788 +do_ip_setsockopt_41852 do_ip_setsockopt 5 41852 NULL
97789 +irq_data_to_status_reg_41854 irq_data_to_status_reg 0 41854 NULL
97790 +keyctl_instantiate_key_41855 keyctl_instantiate_key 3 41855 NULL
97791 +ieee80211_rx_radiotap_space_41870 ieee80211_rx_radiotap_space 0 41870 NULL
97792 +get_fdb_entries_41916 get_fdb_entries 3 41916 NULL
97793 +ceph_get_direct_page_vector_41917 ceph_get_direct_page_vector 2 41917 NULL
97794 +find_ge_pid_41918 find_ge_pid 1 41918 NULL
97795 +build_inv_iotlb_pages_41922 build_inv_iotlb_pages 4-5 41922 NULL
97796 +nfsd_getxattr_41934 nfsd_getxattr 0 41934 NULL
97797 +ext4_da_write_inline_data_begin_41935 ext4_da_write_inline_data_begin 3-4 41935 NULL
97798 +ocfs2_xattr_bucket_get_name_value_41949 ocfs2_xattr_bucket_get_name_value 0 41949 NULL
97799 +portnames_read_41958 portnames_read 3 41958 NULL
97800 +ubi_self_check_all_ff_41959 ubi_self_check_all_ff 4 41959 NULL
97801 +dst_mtu_41969 dst_mtu 0 41969 NULL
97802 +cx24116_writeregN_41975 cx24116_writeregN 4 41975 NULL
97803 +ubi_io_is_bad_41983 ubi_io_is_bad 0 41983 NULL
97804 +lguest_map_42008 lguest_map 1-2 42008 NULL
97805 +pool_allocate_42012 pool_allocate 3 42012 NULL
97806 +spidev_sync_read_42014 spidev_sync_read 0 42014 NULL
97807 +acpi_ut_create_buffer_object_42030 acpi_ut_create_buffer_object 1 42030 NULL
97808 +__hwahc_op_set_gtk_42038 __hwahc_op_set_gtk 4 42038 NULL
97809 +irda_sendmsg_ultra_42047 irda_sendmsg_ultra 4 42047 NULL
97810 +dma_generic_alloc_coherent_42048 dma_generic_alloc_coherent 2 42048 NULL nohasharray
97811 +jffs2_do_link_42048 jffs2_do_link 6 42048 &dma_generic_alloc_coherent_42048
97812 +ps_poll_upsd_max_ap_turn_read_42050 ps_poll_upsd_max_ap_turn_read 3 42050 NULL
97813 +InterfaceTransmitPacket_42058 InterfaceTransmitPacket 3 42058 NULL
97814 +scsi_execute_req_42088 scsi_execute_req 5 42088 NULL
97815 +sk_chk_filter_42095 sk_chk_filter 2 42095 NULL
97816 +submit_inquiry_42108 submit_inquiry 3 42108 NULL
97817 +sysfs_read_file_42113 sysfs_read_file 3 42113 NULL
97818 +Read_hfc16_stable_42131 Read_hfc16_stable 0 42131 NULL
97819 +v9fs_alloc_rdir_buf_42150 v9fs_alloc_rdir_buf 2 42150 NULL
97820 +mmc_align_data_size_42161 mmc_align_data_size 0-2 42161 NULL
97821 +read_file_base_eeprom_42168 read_file_base_eeprom 3 42168 NULL
97822 +oprofilefs_str_to_user_42182 oprofilefs_str_to_user 3 42182 NULL
97823 +get_znodes_to_commit_42201 get_znodes_to_commit 0 42201 NULL
97824 +btmrvl_hsmode_write_42252 btmrvl_hsmode_write 3 42252 NULL
97825 +rx_defrag_need_decrypt_read_42253 rx_defrag_need_decrypt_read 3 42253 NULL
97826 +netxen_nic_map_indirect_address_128M_42257 netxen_nic_map_indirect_address_128M 2 42257 NULL
97827 +savu_sysfs_write_42273 savu_sysfs_write 6 42273 NULL
97828 +snd_pcm_hw_param_value_max_42280 snd_pcm_hw_param_value_max 0 42280 NULL
97829 +sel_read_perm_42302 sel_read_perm 3 42302 NULL
97830 +sctp_setsockopt_del_key_42304 sctp_setsockopt_del_key 3 42304 NULL nohasharray
97831 +ulong_read_file_42304 ulong_read_file 3 42304 &sctp_setsockopt_del_key_42304
97832 +xfs_vm_readpages_42308 xfs_vm_readpages 4 42308 NULL
97833 +hysdn_conf_read_42324 hysdn_conf_read 3 42324 NULL
97834 +tcp_sync_mss_42330 tcp_sync_mss 2-0 42330 NULL
97835 +snd_pcm_plug_alloc_42339 snd_pcm_plug_alloc 2 42339 NULL
97836 +ide_raw_taskfile_42355 ide_raw_taskfile 4 42355 NULL
97837 +il_dbgfs_disable_ht40_read_42386 il_dbgfs_disable_ht40_read 3 42386 NULL
97838 +msnd_fifo_read_42406 msnd_fifo_read 0-3 42406 NULL
97839 +krng_get_random_42420 krng_get_random 3 42420 NULL
97840 +gsm_data_alloc_42437 gsm_data_alloc 3 42437 NULL
97841 +key_conf_keyidx_read_42443 key_conf_keyidx_read 3 42443 NULL
97842 +snd_pcm_action_group_42452 snd_pcm_action_group 0 42452 NULL
97843 +tcm_loop_change_queue_depth_42454 tcm_loop_change_queue_depth 2 42454 NULL
97844 +tc3589x_gpio_irq_get_virq_42457 tc3589x_gpio_irq_get_virq 2 42457 NULL
97845 +ext3_valid_block_bitmap_42459 ext3_valid_block_bitmap 3 42459 NULL
97846 +__simple_xattr_set_42474 __simple_xattr_set 4 42474 NULL
97847 +follow_hugetlb_page_42486 follow_hugetlb_page 0-7 42486 NULL
97848 +omfs_readpages_42490 omfs_readpages 4 42490 NULL
97849 +brcmf_sdbrcm_bus_txctl_42492 brcmf_sdbrcm_bus_txctl 3 42492 NULL
97850 +kvm_write_wall_clock_42520 kvm_write_wall_clock 2 42520 NULL
97851 +smk_write_netlbladdr_42525 smk_write_netlbladdr 3 42525 NULL
97852 +snd_emux_create_port_42533 snd_emux_create_port 3 42533 NULL
97853 +dbAllocNear_42546 dbAllocNear 0 42546 NULL
97854 +i915_ring_stop_read_42549 i915_ring_stop_read 3 42549 NULL nohasharray
97855 +ath6kl_wmi_proc_events_vif_42549 ath6kl_wmi_proc_events_vif 5 42549 &i915_ring_stop_read_42549
97856 +iwl_print_event_log_42566 iwl_print_event_log 0-5-7 42566 NULL
97857 +xfrm_new_hash_mask_42579 xfrm_new_hash_mask 0-1 42579 NULL
97858 +oom_score_adj_write_42594 oom_score_adj_write 3 42594 NULL
97859 +map_state_42602 map_state 1 42602 NULL nohasharray
97860 +__pskb_pull_42602 __pskb_pull 2 42602 &map_state_42602
97861 +sys_move_pages_42626 sys_move_pages 2 42626 NULL
97862 +ieee80211_if_fmt_dot11MeshHWMPactivePathTimeout_42635 ieee80211_if_fmt_dot11MeshHWMPactivePathTimeout 3 42635 NULL
97863 +scsi_activate_tcq_42640 scsi_activate_tcq 2 42640 NULL
97864 +br_mdb_rehash_42643 br_mdb_rehash 2 42643 NULL
97865 +_regmap_raw_write_42652 _regmap_raw_write 4-2 42652 NULL
97866 +l2tp_xmit_skb_42672 l2tp_xmit_skb 3 42672 NULL
97867 +request_key_and_link_42693 request_key_and_link 4 42693 NULL
97868 +vb2_read_42703 vb2_read 3 42703 NULL
97869 +sierra_net_send_cmd_42708 sierra_net_send_cmd 3 42708 NULL
97870 +__ocfs2_decrease_refcount_42717 __ocfs2_decrease_refcount 4 42717 NULL
97871 +dvb_demux_ioctl_42733 dvb_demux_ioctl 2 42733 NULL
97872 +set_aoe_iflist_42737 set_aoe_iflist 2 42737 NULL
97873 +ax25_setsockopt_42740 ax25_setsockopt 5 42740 NULL
97874 +xen_bind_pirq_gsi_to_irq_42750 xen_bind_pirq_gsi_to_irq 1 42750 NULL
97875 +snd_midi_event_decode_42780 snd_midi_event_decode 0 42780 NULL
97876 +cryptd_hash_setkey_42781 cryptd_hash_setkey 3 42781 NULL
97877 +koneplus_sysfs_read_42792 koneplus_sysfs_read 6 42792 NULL
97878 +ntfs_attr_extend_allocation_42796 ntfs_attr_extend_allocation 0-2 42796 NULL
97879 +fw_device_op_compat_ioctl_42804 fw_device_op_compat_ioctl 2-3 42804 NULL
97880 +drm_ioctl_42813 drm_ioctl 2 42813 NULL
97881 +iwl_dbgfs_ucode_bt_stats_read_42820 iwl_dbgfs_ucode_bt_stats_read 3 42820 NULL
97882 +set_arg_42824 set_arg 3 42824 NULL
97883 +ocfs2_desc_bitmap_to_cluster_off_42831 ocfs2_desc_bitmap_to_cluster_off 2 42831 NULL
97884 +xfs_buf_read_uncached_42844 xfs_buf_read_uncached 3 42844 NULL
97885 +prandom_u32_42853 prandom_u32 0 42853 NULL
97886 +of_property_count_strings_42863 of_property_count_strings 0 42863 NULL
97887 +ocfs2_clusters_for_bytes_42872 ocfs2_clusters_for_bytes 0-2 42872 NULL
97888 +pskb_expand_head_42881 pskb_expand_head 2-3 42881 NULL
97889 +vt_compat_ioctl_42887 vt_compat_ioctl 3 42887 NULL
97890 +tipc_port_recv_sections_42890 tipc_port_recv_sections 4 42890 NULL
97891 +xpc_kmalloc_cacheline_aligned_42895 xpc_kmalloc_cacheline_aligned 1 42895 NULL
97892 +SendTxCommandPacket_42901 SendTxCommandPacket 3 42901 NULL
97893 +hd_end_request_42904 hd_end_request 2 42904 NULL
97894 +sta_last_rx_rate_read_42909 sta_last_rx_rate_read 3 42909 NULL
97895 +sctp_getsockopt_maxburst_42941 sctp_getsockopt_maxburst 2 42941 NULL
97896 +get_unmapped_area_42944 get_unmapped_area 0 42944 NULL
97897 +sys_sethostname_42962 sys_sethostname 2 42962 NULL
97898 +read_file_node_stat_42964 read_file_node_stat 3 42964 NULL
97899 +compat_udpv6_setsockopt_42981 compat_udpv6_setsockopt 5 42981 NULL
97900 +snd_timer_user_ioctl_compat_42985 snd_timer_user_ioctl_compat 3 42985 NULL
97901 +nfs_idmap_get_desc_42990 nfs_idmap_get_desc 4-2 42990 NULL
97902 +mlx4_qp_reserve_range_43000 mlx4_qp_reserve_range 2-3 43000 NULL
97903 +isr_rx_mem_overflow_read_43025 isr_rx_mem_overflow_read 3 43025 NULL
97904 +wep_default_key_count_read_43035 wep_default_key_count_read 3 43035 NULL
97905 +nouveau_gpuobj_create__43072 nouveau_gpuobj_create_ 9 43072 NULL
97906 +cpuset_sprintf_memlist_43088 cpuset_sprintf_memlist 0 43088 NULL
97907 +ieee80211_if_fmt_drop_unencrypted_43107 ieee80211_if_fmt_drop_unencrypted 3 43107 NULL
97908 +read_file_dfs_43145 read_file_dfs 3 43145 NULL
97909 +uuid_string_43154 uuid_string 0 43154 NULL
97910 +usb_string_sub_43164 usb_string_sub 0 43164 NULL
97911 +il_dbgfs_power_save_status_read_43165 il_dbgfs_power_save_status_read 3 43165 NULL
97912 +ath6kl_set_assoc_req_ies_43185 ath6kl_set_assoc_req_ies 3 43185 NULL
97913 +process_measurement_43190 process_measurement 0 43190 NULL
97914 +ext4_xattr_ibody_get_43200 ext4_xattr_ibody_get 0 43200 NULL
97915 +uio_write_43202 uio_write 3 43202 NULL
97916 +iso_callback_43208 iso_callback 3 43208 NULL
97917 +f2fs_acl_from_disk_43210 f2fs_acl_from_disk 2 43210 NULL
97918 +atomic_long_add_return_43217 atomic_long_add_return 1 43217 NULL
97919 +comedi_compat_ioctl_43218 comedi_compat_ioctl 3 43218 NULL
97920 +vmemmap_alloc_block_43245 vmemmap_alloc_block 1 43245 NULL
97921 +fixup_leb_43256 fixup_leb 3 43256 NULL
97922 +ide_end_rq_43269 ide_end_rq 4 43269 NULL
97923 +evtchn_write_43278 evtchn_write 3 43278 NULL
97924 +filemap_write_and_wait_range_43279 filemap_write_and_wait_range 0 43279 NULL
97925 +mpage_alloc_43299 mpage_alloc 3 43299 NULL
97926 +get_nr_irqs_gsi_43315 get_nr_irqs_gsi 0 43315 NULL
97927 +__ext4_get_inode_loc_43332 __ext4_get_inode_loc 0 43332 NULL
97928 +gart_free_coherent_43362 gart_free_coherent 4-2 43362 NULL
97929 +xenfb_write_43412 xenfb_write 3 43412 NULL
97930 +__alloc_bootmem_low_43423 __alloc_bootmem_low 1 43423 NULL nohasharray
97931 +gdm_wimax_netif_rx_43423 gdm_wimax_netif_rx 3 43423 &__alloc_bootmem_low_43423
97932 +usb_alloc_urb_43436 usb_alloc_urb 1 43436 NULL
97933 +ath6kl_wmi_roam_tbl_event_rx_43440 ath6kl_wmi_roam_tbl_event_rx 3 43440 NULL
97934 +usb_string_43443 usb_string 0 43443 NULL nohasharray
97935 +usemap_size_43443 usemap_size 0-2-1 43443 &usb_string_43443
97936 +alloc_new_reservation_43480 alloc_new_reservation 4 43480 NULL
97937 +tx_tx_data_prepared_read_43497 tx_tx_data_prepared_read 3 43497 NULL
97938 +ieee80211_if_fmt_dot11MeshHWMPnetDiameterTraversalTime_43505 ieee80211_if_fmt_dot11MeshHWMPnetDiameterTraversalTime 3 43505 NULL
97939 +do_readlink_43518 do_readlink 2 43518 NULL
97940 +dvb_ca_en50221_io_write_43533 dvb_ca_en50221_io_write 3 43533 NULL
97941 +cachefiles_daemon_write_43535 cachefiles_daemon_write 3 43535 NULL
97942 +tx_frag_failed_read_43540 tx_frag_failed_read 3 43540 NULL nohasharray
97943 +ufs_alloccg_block_43540 ufs_alloccg_block 3-0 43540 &tx_frag_failed_read_43540
97944 +ath_rx_init_43564 ath_rx_init 2 43564 NULL
97945 +_fc_frame_alloc_43568 _fc_frame_alloc 1 43568 NULL
97946 +rpc_malloc_43573 rpc_malloc 2 43573 NULL
97947 +lpfc_idiag_drbacc_read_reg_43606 lpfc_idiag_drbacc_read_reg 0-3 43606 NULL
97948 +proc_read_43614 proc_read 3 43614 NULL
97949 +bio_integrity_tag_43658 bio_integrity_tag 3 43658 NULL
97950 +tps65217_set_bits_43659 tps65217_set_bits 2 43659 NULL nohasharray
97951 +ext4_acl_count_43659 ext4_acl_count 0-1 43659 &tps65217_set_bits_43659
97952 +dmam_declare_coherent_memory_43679 dmam_declare_coherent_memory 4-2 43679 NULL
97953 +calgary_map_page_43686 calgary_map_page 3-4 43686 NULL
97954 +max77693_bulk_write_43698 max77693_bulk_write 2-3 43698 NULL
97955 +drbd_md_first_sector_43729 drbd_md_first_sector 0 43729 NULL
97956 +snd_rme32_playback_copy_43732 snd_rme32_playback_copy 5 43732 NULL
97957 +ocfs2_replace_clusters_43733 ocfs2_replace_clusters 5 43733 NULL
97958 +osdv1_attr_list_elem_size_43747 osdv1_attr_list_elem_size 0-1 43747 NULL
97959 +__bm_find_next_43748 __bm_find_next 2 43748 NULL
97960 +gigaset_initcs_43753 gigaset_initcs 2 43753 NULL
97961 +sctp_setsockopt_active_key_43755 sctp_setsockopt_active_key 3 43755 NULL
97962 +ocfs2_xattr_get_value_outside_43787 ocfs2_xattr_get_value_outside 0 43787 NULL nohasharray
97963 +byte_pos_43787 byte_pos 0-2 43787 &ocfs2_xattr_get_value_outside_43787
97964 +btrfs_copy_from_user_43806 btrfs_copy_from_user 3-1 43806 NULL
97965 +ext4_read_block_bitmap_43814 ext4_read_block_bitmap 2 43814 NULL
97966 +ieee80211_if_fmt_element_ttl_43825 ieee80211_if_fmt_element_ttl 3 43825 NULL
97967 +ieee80211_alloc_hw_43829 ieee80211_alloc_hw 1 43829 NULL
97968 +p54_download_eeprom_43842 p54_download_eeprom 4 43842 NULL
97969 +read_flush_43851 read_flush 3 43851 NULL
97970 +ocfs2_block_group_find_clear_bits_43874 ocfs2_block_group_find_clear_bits 4 43874 NULL
97971 +pm860x_bulk_write_43875 pm860x_bulk_write 3-2 43875 NULL
97972 +ec_dbgfs_cmd_write_43895 ec_dbgfs_cmd_write 3 43895 NULL
97973 +prism2_sta_send_mgmt_43916 prism2_sta_send_mgmt 5 43916 NULL
97974 +SendString_43928 SendString 3 43928 NULL
97975 +xen_register_gsi_43946 xen_register_gsi 1-2 43946 NULL
97976 +stats_dot11RTSFailureCount_read_43948 stats_dot11RTSFailureCount_read 3 43948 NULL
97977 +__get_required_blob_size_43980 __get_required_blob_size 0-2-3 43980 NULL
97978 +nla_reserve_43984 nla_reserve 3 43984 NULL
97979 +scsi_command_size_43992 scsi_command_size 0 43992 NULL nohasharray
97980 +bcm_recvmsg_43992 bcm_recvmsg 4 43992 &scsi_command_size_43992
97981 +emit_flags_44006 emit_flags 4-3 44006 NULL
97982 +write_flush_procfs_44011 write_flush_procfs 3 44011 NULL
97983 +xlog_recover_add_to_cont_trans_44102 xlog_recover_add_to_cont_trans 4 44102 NULL
97984 +tracing_set_trace_read_44122 tracing_set_trace_read 3 44122 NULL
97985 +vmw_gmr_bind_44130 vmw_gmr_bind 3 44130 NULL
97986 +scsi_get_resid_44147 scsi_get_resid 0 44147 NULL
97987 +ubifs_find_dirty_idx_leb_44169 ubifs_find_dirty_idx_leb 0 44169 NULL
97988 +ocfs2_xattr_bucket_find_44174 ocfs2_xattr_bucket_find 0 44174 NULL
97989 +handle_eviocgbit_44193 handle_eviocgbit 3 44193 NULL
97990 +IO_APIC_get_PCI_irq_vector_44198 IO_APIC_get_PCI_irq_vector 0 44198 NULL
97991 +__set_free_44211 __set_free 2 44211 NULL
97992 +claim_ptd_buffers_44213 claim_ptd_buffers 3 44213 NULL
97993 +srp_alloc_iu_44227 srp_alloc_iu 2 44227 NULL
97994 +ioapic_register_intr_44238 ioapic_register_intr 1 44238 NULL
97995 +scsi_track_queue_full_44239 scsi_track_queue_full 2 44239 NULL
97996 +tc3589x_gpio_irq_map_44245 tc3589x_gpio_irq_map 2 44245 NULL
97997 +enlarge_skb_44248 enlarge_skb 2 44248 NULL nohasharray
97998 +xfs_buf_readahead_map_44248 xfs_buf_readahead_map 3 44248 &enlarge_skb_44248
97999 +ufs_clusteracct_44293 ufs_clusteracct 3 44293 NULL
98000 +ocfs2_zero_range_for_truncate_44294 ocfs2_zero_range_for_truncate 3 44294 NULL
98001 +ath6kl_keepalive_read_44303 ath6kl_keepalive_read 3 44303 NULL
98002 +bitmap_scnprintf_44318 bitmap_scnprintf 0-2 44318 NULL
98003 +dispatch_proc_write_44320 dispatch_proc_write 3 44320 NULL
98004 +ubi_eba_write_leb_st_44343 ubi_eba_write_leb_st 5 44343 NULL
98005 +nfs_fscache_get_super_cookie_44355 nfs_fscache_get_super_cookie 3 44355 NULL nohasharray
98006 +blk_queue_init_tags_44355 blk_queue_init_tags 2 44355 &nfs_fscache_get_super_cookie_44355
98007 +rts_threshold_read_44384 rts_threshold_read 3 44384 NULL
98008 +aoedev_flush_44398 aoedev_flush 2 44398 NULL
98009 +drm_buffer_alloc_44405 drm_buffer_alloc 2 44405 NULL
98010 +osst_do_scsi_44410 osst_do_scsi 4 44410 NULL
98011 +ieee80211_if_read_rc_rateidx_mcs_mask_5ghz_44423 ieee80211_if_read_rc_rateidx_mcs_mask_5ghz 3 44423 NULL
98012 +prandom_u32_state_44445 prandom_u32_state 0 44445 NULL
98013 +btrfs_chunk_item_size_44478 btrfs_chunk_item_size 0-1 44478 NULL
98014 +sdio_align_size_44489 sdio_align_size 0-2 44489 NULL
98015 +ieee80211_if_read_dropped_frames_ttl_44500 ieee80211_if_read_dropped_frames_ttl 3 44500 NULL
98016 +security_getprocattr_44505 security_getprocattr 0 44505 NULL nohasharray
98017 +iwl_dbgfs_sram_read_44505 iwl_dbgfs_sram_read 3 44505 &security_getprocattr_44505
98018 +spidev_write_44510 spidev_write 3 44510 NULL
98019 +sys_msgsnd_44537 sys_msgsnd 3 44537 NULL nohasharray
98020 +comm_write_44537 comm_write 3 44537 &sys_msgsnd_44537
98021 +snd_pcm_drop_44542 snd_pcm_drop 0 44542 NULL
98022 +dbg_chk_pnode_44555 dbg_chk_pnode 0 44555 NULL
98023 +snd_pcm_alloc_vmalloc_buffer_44595 snd_pcm_alloc_vmalloc_buffer 2 44595 NULL
98024 +slip_compat_ioctl_44599 slip_compat_ioctl 4 44599 NULL
98025 +wm5100_gpio_set_44602 wm5100_gpio_set 2 44602 NULL
98026 +brcmf_sdbrcm_glom_len_44618 brcmf_sdbrcm_glom_len 0 44618 NULL
98027 +cfpkt_add_body_44630 cfpkt_add_body 3 44630 NULL
98028 +ext2_new_block_44645 ext2_new_block 2 44645 NULL
98029 +alloc_ctrl_packet_44667 alloc_ctrl_packet 1 44667 NULL
98030 +mpi_resize_44674 mpi_resize 2 44674 NULL
98031 +ts_read_44687 ts_read 3 44687 NULL
98032 +_zd_iowrite32v_locked_44725 _zd_iowrite32v_locked 3 44725 NULL
98033 +clusterip_proc_write_44729 clusterip_proc_write 3 44729 NULL
98034 +fib_count_nexthops_44730 fib_count_nexthops 0 44730 NULL
98035 +key_tx_rx_count_read_44742 key_tx_rx_count_read 3 44742 NULL
98036 +WIL_GET_BITS_44747 WIL_GET_BITS 0-1-2-3 44747 NULL
98037 +tnode_new_44757 tnode_new 3 44757 NULL nohasharray
98038 +pty_write_44757 pty_write 3 44757 &tnode_new_44757
98039 +__videobuf_copy_stream_44769 __videobuf_copy_stream 4 44769 NULL
98040 +handsfree_ramp_44777 handsfree_ramp 2 44777 NULL
98041 +sctp_setsockopt_44788 sctp_setsockopt 5 44788 NULL
98042 +rx_dropped_read_44799 rx_dropped_read 3 44799 NULL
98043 +qla4xxx_alloc_work_44813 qla4xxx_alloc_work 2 44813 NULL
98044 +rmap_write_protect_44833 rmap_write_protect 2 44833 NULL
98045 +sisusb_write_44834 sisusb_write 3 44834 NULL
98046 +nl80211_send_unprot_disassoc_44846 nl80211_send_unprot_disassoc 4 44846 NULL
98047 +kvm_read_hva_44847 kvm_read_hva 3 44847 NULL
98048 +skb_availroom_44883 skb_availroom 0 44883 NULL
98049 +nf_bridge_encap_header_len_44890 nf_bridge_encap_header_len 0 44890 NULL
98050 +do_tty_write_44896 do_tty_write 5 44896 NULL
98051 +tx_queue_status_read_44978 tx_queue_status_read 3 44978 NULL
98052 +nf_nat_seq_adjust_44989 nf_nat_seq_adjust 4 44989 NULL
98053 +max77693_write_reg_45004 max77693_write_reg 2 45004 NULL
98054 +ftdi_process_packet_45005 ftdi_process_packet 5 45005 NULL
98055 +bytepos_delta_45017 bytepos_delta 0 45017 NULL
98056 +read_block_bitmap_45021 read_block_bitmap 2 45021 NULL nohasharray
98057 +ptrace_writedata_45021 ptrace_writedata 4-3 45021 &read_block_bitmap_45021
98058 +vhci_get_user_45039 vhci_get_user 3 45039 NULL
98059 +sel_write_user_45060 sel_write_user 3 45060 NULL
98060 +do_video_ioctl_45069 do_video_ioctl 3 45069 NULL nohasharray
98061 +snd_mixart_BA0_read_45069 snd_mixart_BA0_read 5 45069 &do_video_ioctl_45069
98062 +kvm_mmu_page_get_gfn_45110 kvm_mmu_page_get_gfn 0-2 45110 NULL
98063 +pwr_missing_bcns_cnt_read_45113 pwr_missing_bcns_cnt_read 3 45113 NULL
98064 +usbdev_read_45114 usbdev_read 3 45114 NULL
98065 +send_to_tty_45141 send_to_tty 3 45141 NULL
98066 +stmpe_irq_map_45146 stmpe_irq_map 2 45146 NULL
98067 +crypto_aead_blocksize_45148 crypto_aead_blocksize 0 45148 NULL
98068 +gen_bitmask_string_45149 gen_bitmask_string 6 45149 NULL
98069 +ocfs2_remove_inode_range_45156 ocfs2_remove_inode_range 3-4 45156 NULL nohasharray
98070 +device_write_45156 device_write 3 45156 &ocfs2_remove_inode_range_45156
98071 +ocfs2_dq_frozen_trigger_45159 ocfs2_dq_frozen_trigger 4 45159 NULL
98072 +tomoyo_write_self_45161 tomoyo_write_self 3 45161 NULL
98073 +sta_agg_status_write_45164 sta_agg_status_write 3 45164 NULL
98074 +snd_sb_csp_load_user_45190 snd_sb_csp_load_user 3 45190 NULL
98075 +num_clusters_in_group_45194 num_clusters_in_group 2 45194 NULL
98076 +add_child_45201 add_child 4 45201 NULL
98077 +iso_alloc_urb_45206 iso_alloc_urb 4-5 45206 NULL
98078 +spi_alloc_master_45223 spi_alloc_master 2 45223 NULL
98079 +ieee80211_if_read_peer_45233 ieee80211_if_read_peer 3 45233 NULL
98080 +input_mt_init_slots_45279 input_mt_init_slots 2 45279 NULL
98081 +vcc_compat_ioctl_45291 vcc_compat_ioctl 3 45291 NULL
98082 +snd_pcm_oss_sync1_45298 snd_pcm_oss_sync1 2 45298 NULL
98083 +copy_vm86_regs_from_user_45340 copy_vm86_regs_from_user 3 45340 NULL
98084 +lane2_associate_req_45398 lane2_associate_req 4 45398 NULL
98085 +keymap_store_45406 keymap_store 4 45406 NULL
98086 +ieee80211_if_fmt_dot11MeshHWMProotInterval_45421 ieee80211_if_fmt_dot11MeshHWMProotInterval 3 45421 NULL
98087 +tty_buffer_alloc_45437 tty_buffer_alloc 2 45437 NULL
98088 +do_mmap_pgoff_45441 do_mmap_pgoff 0 45441 NULL
98089 +intel_render_ring_init_dri_45446 intel_render_ring_init_dri 2-3 45446 NULL
98090 +__node_remap_45458 __node_remap 4 45458 NULL
98091 +rds_ib_set_wr_signal_state_45463 rds_ib_set_wr_signal_state 0 45463 NULL
98092 +udp_manip_pkt_45467 udp_manip_pkt 4 45467 NULL
98093 +tracing_read_dyn_info_45468 tracing_read_dyn_info 3 45468 NULL
98094 +snd_pcm_hwsync_45479 snd_pcm_hwsync 0 45479 NULL
98095 +arizona_init_fll_45503 arizona_init_fll 4-5 45503 NULL
98096 +rds_message_copy_from_user_45510 rds_message_copy_from_user 3 45510 NULL
98097 +clone_bio_45516 clone_bio 6 45516 NULL
98098 +sys_lgetxattr_45531 sys_lgetxattr 4 45531 NULL
98099 +cgroup_read_u64_45532 cgroup_read_u64 5 45532 NULL
98100 +copy_macs_45534 copy_macs 4 45534 NULL
98101 +nla_attr_size_45545 nla_attr_size 0-1 45545 NULL
98102 +v9fs_direct_read_45546 v9fs_direct_read 3 45546 NULL
98103 +cx18_copy_mdl_to_user_45549 cx18_copy_mdl_to_user 4 45549 NULL
98104 +atomic_long_sub_return_45551 atomic_long_sub_return 1 45551 NULL
98105 +ext3_group_first_block_no_45555 ext3_group_first_block_no 0-2 45555 NULL
98106 +stats_dot11ACKFailureCount_read_45558 stats_dot11ACKFailureCount_read 3 45558 NULL
98107 +posix_acl_xattr_size_45561 posix_acl_xattr_size 0-1 45561 NULL
98108 +venus_rmdir_45564 venus_rmdir 4 45564 NULL
98109 +ipath_create_cq_45586 ipath_create_cq 2 45586 NULL
98110 +rdma_set_ib_paths_45592 rdma_set_ib_paths 3 45592 NULL
98111 +hidraw_get_report_45609 hidraw_get_report 3 45609 NULL
98112 +audit_log_n_hex_45617 audit_log_n_hex 3 45617 NULL
98113 +da9052_gpio_set_45643 da9052_gpio_set 2 45643 NULL
98114 +ebitmap_next_positive_45651 ebitmap_next_positive 3 45651 NULL
98115 +dma_map_cont_45668 dma_map_cont 5 45668 NULL
98116 +compat_mpctl_ioctl_45671 compat_mpctl_ioctl 2 45671 NULL
98117 +dgram_sendmsg_45679 dgram_sendmsg 4 45679 NULL
98118 +smk_write_ambient_45691 smk_write_ambient 3 45691 NULL
98119 +dm_compat_ctl_ioctl_45692 dm_compat_ctl_ioctl 3 45692 NULL
98120 +unix_dgram_sendmsg_45699 unix_dgram_sendmsg 4 45699 NULL nohasharray
98121 +bscnl_emit_45699 bscnl_emit 2-5-0 45699 &unix_dgram_sendmsg_45699
98122 +dvb_ca_en50221_init_45718 dvb_ca_en50221_init 4 45718 NULL
98123 +snd_cs46xx_io_read_45734 snd_cs46xx_io_read 5 45734 NULL
98124 +rw_copy_check_uvector_45748 rw_copy_check_uvector 3 45748 NULL nohasharray
98125 +v4l2_ctrl_new_std_45748 v4l2_ctrl_new_std 5 45748 &rw_copy_check_uvector_45748
98126 +lkdtm_debugfs_read_45752 lkdtm_debugfs_read 3 45752 NULL
98127 +nilfs_compat_ioctl_45769 nilfs_compat_ioctl 3 45769 NULL
98128 +alloc_ts_config_45775 alloc_ts_config 1 45775 NULL
98129 +raw_setsockopt_45800 raw_setsockopt 5 45800 NULL
98130 +lbs_rdbbp_read_45805 lbs_rdbbp_read 3 45805 NULL
98131 +pcpu_alloc_alloc_info_45813 pcpu_alloc_alloc_info 1-2 45813 NULL
98132 +fm_v4l2_init_video_device_45821 fm_v4l2_init_video_device 2 45821 NULL
98133 +memcg_update_cache_size_45828 memcg_update_cache_size 2 45828 NULL
98134 +amthi_read_45831 amthi_read 4 45831 NULL
98135 +x509_process_extension_45854 x509_process_extension 5 45854 NULL
98136 +isdn_write_45863 isdn_write 3 45863 NULL
98137 +rbd_get_num_segments_45864 rbd_get_num_segments 0-2-3 45864 NULL
98138 +unpack_orig_pfns_45867 unpack_orig_pfns 0 45867 NULL
98139 +get_rdac_req_45882 get_rdac_req 3 45882 NULL
98140 +ocfs2_xattr_block_find_45891 ocfs2_xattr_block_find 0 45891 NULL
98141 +dbgfs_frame_45917 dbgfs_frame 3 45917 NULL
98142 +nf_nat_ftp_fmt_cmd_45926 nf_nat_ftp_fmt_cmd 0 45926 NULL
98143 +alloc_mr_45935 alloc_mr 1 45935 NULL
98144 +rb_simple_read_45972 rb_simple_read 3 45972 NULL
98145 +ezusb_writememory_45976 ezusb_writememory 4 45976 NULL
98146 +ioat2_dca_count_dca_slots_45984 ioat2_dca_count_dca_slots 0 45984 NULL
98147 +sierra_setup_urb_46029 sierra_setup_urb 5 46029 NULL
98148 +get_free_entries_46030 get_free_entries 1 46030 NULL
98149 +__access_remote_vm_46031 __access_remote_vm 0-5-3 46031 NULL
98150 +snd_emu10k1x_ptr_read_46049 snd_emu10k1x_ptr_read 0 46049 NULL
98151 +acpi_register_gsi_xen_hvm_46052 acpi_register_gsi_xen_hvm 2 46052 NULL
98152 +line6_midibuf_bytes_used_46059 line6_midibuf_bytes_used 0 46059 NULL
98153 +__ocfs2_move_extent_46060 __ocfs2_move_extent 5-6 46060 NULL nohasharray
98154 +dma_tx_errors_read_46060 dma_tx_errors_read 3 46060 &__ocfs2_move_extent_46060
98155 +slhc_toss_46066 slhc_toss 0 46066 NULL
98156 +sel_commit_bools_write_46077 sel_commit_bools_write 3 46077 NULL
98157 +vfio_config_do_rw_46091 vfio_config_do_rw 3 46091 NULL
98158 +ata_host_alloc_46094 ata_host_alloc 2 46094 NULL
98159 +arizona_set_irq_wake_46101 arizona_set_irq_wake 2 46101 NULL
98160 +pkt_ctl_compat_ioctl_46110 pkt_ctl_compat_ioctl 3 46110 NULL
98161 +il3945_ucode_general_stats_read_46111 il3945_ucode_general_stats_read 3 46111 NULL nohasharray
98162 +memcg_update_array_size_46111 memcg_update_array_size 1 46111 &il3945_ucode_general_stats_read_46111
98163 +mlx4_ib_alloc_fast_reg_page_list_46119 mlx4_ib_alloc_fast_reg_page_list 2 46119 NULL
98164 +__netlink_change_ngroups_46156 __netlink_change_ngroups 2 46156 NULL
98165 +qlcnic_alloc_msix_entries_46160 qlcnic_alloc_msix_entries 2 46160 NULL
98166 +twl_direction_out_46182 twl_direction_out 2 46182 NULL
98167 +vxge_os_dma_malloc_46184 vxge_os_dma_malloc 2 46184 NULL
98168 +i2400m_op_msg_from_user_46213 i2400m_op_msg_from_user 4 46213 NULL
98169 +tm6000_i2c_recv_regs_46215 tm6000_i2c_recv_regs 5 46215 NULL
98170 +dsp_write_46218 dsp_write 2 46218 NULL
98171 +mpi_read_raw_data_46248 mpi_read_raw_data 2 46248 NULL
98172 +__le64_to_cpup_46257 __le64_to_cpup 0 46257 NULL
98173 +nf_nat_ftp_46265 nf_nat_ftp 6 46265 NULL
98174 +ReadReg_46277 ReadReg 0 46277 NULL
98175 +batadv_iv_ogm_queue_add_46319 batadv_iv_ogm_queue_add 3 46319 NULL
98176 +__hwahc_dev_set_key_46328 __hwahc_dev_set_key 5 46328 NULL
98177 +twl6040_write_46351 twl6040_write 2 46351 NULL
98178 +iwl_dbgfs_chain_noise_read_46355 iwl_dbgfs_chain_noise_read 3 46355 NULL
98179 +smk_write_direct_46363 smk_write_direct 3 46363 NULL
98180 +__iommu_calculate_agaw_46366 __iommu_calculate_agaw 2 46366 NULL
98181 +ubi_dump_flash_46381 ubi_dump_flash 4 46381 NULL
98182 +fuse_file_aio_write_46399 fuse_file_aio_write 4 46399 NULL
98183 +crypto_ablkcipher_reqsize_46411 crypto_ablkcipher_reqsize 0 46411 NULL
98184 +cp210x_set_config_46447 cp210x_set_config 4 46447 NULL
98185 +filldir64_46469 filldir64 3 46469 NULL
98186 +fill_in_write_vector_46498 fill_in_write_vector 0 46498 NULL
98187 +pin_code_reply_46510 pin_code_reply 4 46510 NULL
98188 +mthca_alloc_cq_buf_46512 mthca_alloc_cq_buf 3 46512 NULL
98189 +kmsg_read_46514 kmsg_read 3 46514 NULL
98190 +bdx_rxdb_create_46525 bdx_rxdb_create 1 46525 NULL
98191 +nl80211_send_rx_assoc_46538 nl80211_send_rx_assoc 4 46538 NULL
98192 +pm860x_irq_domain_map_46553 pm860x_irq_domain_map 2 46553 NULL
98193 +mv_get_hc_count_46554 mv_get_hc_count 0 46554 NULL
98194 +link_send_sections_long_46556 link_send_sections_long 4 46556 NULL
98195 +irq_domain_associate_46564 irq_domain_associate 2 46564 NULL
98196 +dn_current_mss_46574 dn_current_mss 0 46574 NULL
98197 +serverworks_create_gatt_pages_46582 serverworks_create_gatt_pages 1 46582 NULL
98198 +snd_compr_write_data_46592 snd_compr_write_data 3 46592 NULL
98199 +il3945_stats_flag_46606 il3945_stats_flag 0-3 46606 NULL
98200 +vscnprintf_46617 vscnprintf 0-2 46617 NULL
98201 +__kfifo_out_r_46623 __kfifo_out_r 0-3 46623 NULL
98202 +request_key_async_with_auxdata_46624 request_key_async_with_auxdata 4 46624 NULL
98203 +aircable_process_packet_46639 aircable_process_packet 5 46639 NULL
98204 +av7110_ipack_init_46655 av7110_ipack_init 2 46655 NULL
98205 +alloc_data_packet_46698 alloc_data_packet 1 46698 NULL
98206 +__ilog2_u32_46706 __ilog2_u32 0 46706 NULL
98207 +erst_dbg_write_46715 erst_dbg_write 3 46715 NULL
98208 +wl1271_rx_filter_alloc_field_46721 wl1271_rx_filter_alloc_field 5 46721 NULL
98209 +prepare_copy_46725 prepare_copy 2 46725 NULL
98210 +irq_domain_add_simple_46734 irq_domain_add_simple 2-3 46734 NULL
98211 +ext4_count_free_46754 ext4_count_free 2 46754 NULL
98212 +hest_ghes_dev_register_46766 hest_ghes_dev_register 1 46766 NULL
98213 +int_hw_irq_en_46776 int_hw_irq_en 3 46776 NULL
98214 +regcache_lzo_sync_46777 regcache_lzo_sync 2 46777 NULL
98215 +scrub_chunk_46789 scrub_chunk 4 46789 NULL
98216 +_sys_packet_req_46793 _sys_packet_req 4 46793 NULL
98217 +_xfs_buf_get_pages_46811 _xfs_buf_get_pages 2 46811 NULL
98218 +xfs_iroot_realloc_46826 xfs_iroot_realloc 2 46826 NULL
98219 +shmem_pwrite_fast_46842 shmem_pwrite_fast 3 46842 NULL
98220 +ieee80211_rx_radiotap_len_46846 ieee80211_rx_radiotap_len 0 46846 NULL
98221 +spi_async_46857 spi_async 0 46857 NULL
98222 +ieee80211_mgmt_tx_46860 ieee80211_mgmt_tx 9 46860 NULL
98223 +vsnprintf_46863 vsnprintf 0 46863 NULL
98224 +nvme_alloc_queue_46865 nvme_alloc_queue 3 46865 NULL
98225 +sip_sprintf_addr_46872 sip_sprintf_addr 0 46872 NULL
98226 +rvmalloc_46873 rvmalloc 1 46873 NULL
98227 +hpi_read_word_nolock_46881 hpi_read_word_nolock 0 46881 NULL
98228 +stmpe_gpio_irq_unmap_46884 stmpe_gpio_irq_unmap 2 46884 NULL
98229 +em28xx_alloc_isoc_46892 em28xx_alloc_isoc 4 46892 NULL
98230 +ixgbe_dbg_reg_ops_write_46895 ixgbe_dbg_reg_ops_write 3 46895 NULL
98231 +sk_mem_pages_46896 sk_mem_pages 0-1 46896 NULL
98232 +ol_dqblk_off_46904 ol_dqblk_off 3-2 46904 NULL
98233 +fb_write_46924 fb_write 3 46924 NULL
98234 +raid_status_46930 raid_status 5 46930 NULL
98235 +btmrvl_curpsmode_read_46939 btmrvl_curpsmode_read 3 46939 NULL
98236 +__sctp_setsockopt_connectx_46949 __sctp_setsockopt_connectx 3 46949 NULL
98237 +qla4xxx_post_aen_work_46953 qla4xxx_post_aen_work 3 46953 NULL
98238 +crypto_tfm_alg_alignmask_46971 crypto_tfm_alg_alignmask 0 46971 NULL
98239 +mgmt_pending_add_46976 mgmt_pending_add 5 46976 NULL
98240 +gfs2_xattr_system_set_46996 gfs2_xattr_system_set 4 46996 NULL nohasharray
98241 +sel_write_bool_46996 sel_write_bool 3 46996 &gfs2_xattr_system_set_46996
98242 +ttm_bo_io_47000 ttm_bo_io 5 47000 NULL
98243 +blk_rq_map_kern_47004 blk_rq_map_kern 4 47004 NULL
98244 +__map_single_47020 __map_single 3-4-7 47020 NULL
98245 +cx231xx_init_bulk_47024 cx231xx_init_bulk 3-2 47024 NULL
98246 +set_dis_bypass_pfs_47038 set_dis_bypass_pfs 3 47038 NULL
98247 +wm8994_set_bits_47052 wm8994_set_bits 2 47052 NULL
98248 +fs_path_len_47060 fs_path_len 0 47060 NULL
98249 +ufs_new_fragments_47070 ufs_new_fragments 3-5-4 47070 NULL
98250 +pipeline_dec_packet_in_read_47076 pipeline_dec_packet_in_read 3 47076 NULL
98251 +scsi_deactivate_tcq_47086 scsi_deactivate_tcq 2 47086 NULL
98252 +mousedev_read_47123 mousedev_read 3 47123 NULL
98253 +ses_recv_diag_47143 ses_recv_diag 4 47143 NULL nohasharray
98254 +acpi_ut_initialize_buffer_47143 acpi_ut_initialize_buffer 2 47143 &ses_recv_diag_47143
98255 +cxio_init_resource_fifo_random_47151 cxio_init_resource_fifo_random 3 47151 NULL
98256 +persistent_ram_iomap_47156 persistent_ram_iomap 1-2 47156 NULL
98257 +mxms_headerlen_47161 mxms_headerlen 0 47161 NULL
98258 +rs_sta_dbgfs_rate_scale_data_read_47165 rs_sta_dbgfs_rate_scale_data_read 3 47165 NULL
98259 +rts51x_ms_rw_47171 rts51x_ms_rw 3-4 47171 NULL
98260 +svc_pool_map_alloc_arrays_47181 svc_pool_map_alloc_arrays 2 47181 NULL
98261 +can_set_system_xattr_47182 can_set_system_xattr 4 47182 NULL
98262 +ioremap_cache_47189 ioremap_cache 1-2 47189 NULL
98263 +wm8903_gpio_direction_in_47213 wm8903_gpio_direction_in 2 47213 NULL
98264 +l2headersize_47238 l2headersize 0 47238 NULL
98265 +options_write_47243 options_write 3 47243 NULL
98266 +portcntrs_1_read_47253 portcntrs_1_read 3 47253 NULL
98267 +da9052_disable_irq_nosync_47260 da9052_disable_irq_nosync 2 47260 NULL
98268 +ablkcipher_next_slow_47274 ablkcipher_next_slow 4-3 47274 NULL
98269 +tty_audit_log_47280 tty_audit_log 8 47280 NULL
98270 +gfs2_readpages_47285 gfs2_readpages 4 47285 NULL
98271 +vsnprintf_47291 vsnprintf 0 47291 NULL
98272 +tx_internal_desc_overflow_read_47300 tx_internal_desc_overflow_read 3 47300 NULL
98273 +ieee80211_if_read_dot11MeshHoldingTimeout_47356 ieee80211_if_read_dot11MeshHoldingTimeout 3 47356 NULL
98274 +avc_get_hash_stats_47359 avc_get_hash_stats 0 47359 NULL
98275 +find_first_zero_bit_le_47369 find_first_zero_bit_le 2 47369 NULL
98276 +__bio_map_kern_47379 __bio_map_kern 3 47379 NULL
98277 +trace_options_core_read_47390 trace_options_core_read 3 47390 NULL
98278 +nametbl_list_47391 nametbl_list 2 47391 NULL
98279 +dgrp_net_write_47392 dgrp_net_write 3 47392 NULL
98280 +pfkey_sendmsg_47394 pfkey_sendmsg 4 47394 NULL
98281 +ocfs2_resv_end_47408 ocfs2_resv_end 0 47408 NULL
98282 +crypto_ablkcipher_alignmask_47410 crypto_ablkcipher_alignmask 0 47410 NULL
98283 +vzalloc_47421 vzalloc 1 47421 NULL
98284 +posix_acl_from_disk_47445 posix_acl_from_disk 2 47445 NULL
98285 +newpart_47485 newpart 6 47485 NULL
98286 +core_sys_select_47494 core_sys_select 1 47494 NULL
98287 +alloc_arraycache_47505 alloc_arraycache 2 47505 NULL
98288 +unlink_simple_47506 unlink_simple 3 47506 NULL
98289 +ufs_inode_getblock_47512 ufs_inode_getblock 4 47512 NULL
98290 +snd_pcm_resume_47530 snd_pcm_resume 0 47530 NULL
98291 +vscnprintf_47533 vscnprintf 0-2 47533 NULL nohasharray
98292 +process_vm_rw_47533 process_vm_rw 3-5 47533 &vscnprintf_47533
98293 +oz_events_read_47535 oz_events_read 3 47535 NULL
98294 +ieee80211_if_fmt_min_discovery_timeout_47539 ieee80211_if_fmt_min_discovery_timeout 3 47539 NULL
98295 +cycx_setup_47562 cycx_setup 4 47562 NULL
98296 +read_ldt_47570 read_ldt 2 47570 NULL
98297 +pci_iomap_47575 pci_iomap 3 47575 NULL
98298 +rpipe_get_idx_47579 rpipe_get_idx 2 47579 NULL
98299 +ext4_kvzalloc_47605 ext4_kvzalloc 1 47605 NULL
98300 +wm831x_gpio_direction_out_47607 wm831x_gpio_direction_out 2 47607 NULL
98301 +sctp_ssnmap_new_47608 sctp_ssnmap_new 1-2 47608 NULL
98302 +uea_request_47613 uea_request 4 47613 NULL
98303 +cache_read_pipefs_47615 cache_read_pipefs 3 47615 NULL
98304 +tps65217_clear_bits_47619 tps65217_clear_bits 2 47619 NULL
98305 +twl4030_clear_set_47624 twl4030_clear_set 4 47624 NULL
98306 +irq_set_chip_47638 irq_set_chip 1 47638 NULL
98307 +__build_packet_message_47643 __build_packet_message 3-9 47643 NULL
98308 +irq_linear_revmap_47682 irq_linear_revmap 0 47682 NULL
98309 +snd_pcm_info_47699 snd_pcm_info 0 47699 NULL
98310 +bits_to_user_47733 bits_to_user 2-3 47733 NULL
98311 +carl9170_debugfs_read_47738 carl9170_debugfs_read 3 47738 NULL
98312 +ir_prepare_write_buffer_47747 ir_prepare_write_buffer 3 47747 NULL
98313 +mvumi_alloc_mem_resource_47750 mvumi_alloc_mem_resource 3 47750 NULL
98314 +ext3_find_near_47752 ext3_find_near 0 47752 NULL
98315 +alloc_sched_domains_47756 alloc_sched_domains 1 47756 NULL
98316 +irq_domain_legacy_revmap_47765 irq_domain_legacy_revmap 0-2 47765 NULL
98317 +i915_wedged_write_47771 i915_wedged_write 3 47771 NULL
98318 +uwb_ie_dump_hex_47774 uwb_ie_dump_hex 4 47774 NULL
98319 +error_error_numll_frame_cts_start_read_47781 error_error_numll_frame_cts_start_read 3 47781 NULL
98320 +posix_acl_fix_xattr_from_user_47793 posix_acl_fix_xattr_from_user 2 47793 NULL
98321 +stmmac_set_bfsize_47834 stmmac_set_bfsize 0 47834 NULL
98322 +__pcf50633_irq_mask_set_47847 __pcf50633_irq_mask_set 2 47847 NULL
98323 +ubifs_unpack_nnode_47866 ubifs_unpack_nnode 0 47866 NULL
98324 +vhci_read_47878 vhci_read 3 47878 NULL
98325 +keyctl_instantiate_key_common_47889 keyctl_instantiate_key_common 4 47889 NULL
98326 +osd_req_read_sg_47905 osd_req_read_sg 5 47905 NULL
98327 +timeout_read_47915 timeout_read 3 47915 NULL
98328 +comedi_write_47926 comedi_write 3 47926 NULL
98329 +lp8788_irq_map_47964 lp8788_irq_map 2 47964 NULL
98330 +iwl_dbgfs_ucode_tracing_read_47983 iwl_dbgfs_ucode_tracing_read 3 47983 NULL nohasharray
98331 +mempool_resize_47983 mempool_resize 2 47983 &iwl_dbgfs_ucode_tracing_read_47983
98332 +pnpacpi_parse_allocated_irqresource_47986 pnpacpi_parse_allocated_irqresource 2 47986 NULL
98333 +dbg_port_buf_47990 dbg_port_buf 2 47990 NULL
98334 +ib_umad_write_47993 ib_umad_write 3 47993 NULL
98335 +ffs_epfile_write_48014 ffs_epfile_write 3 48014 NULL
98336 +bio_integrity_set_tag_48035 bio_integrity_set_tag 3 48035 NULL
98337 +pppoe_sendmsg_48039 pppoe_sendmsg 4 48039 NULL
98338 +wpan_phy_alloc_48056 wpan_phy_alloc 1 48056 NULL
98339 +posix_acl_alloc_48063 posix_acl_alloc 1 48063 NULL
98340 +mmc_alloc_host_48097 mmc_alloc_host 1 48097 NULL
98341 +skb_copy_datagram_const_iovec_48102 skb_copy_datagram_const_iovec 4-2-5 48102 NULL
98342 +radio_isa_common_probe_48107 radio_isa_common_probe 3 48107 NULL
98343 +vmw_framebuffer_surface_dirty_48132 vmw_framebuffer_surface_dirty 6 48132 NULL
98344 +rtsx_read_cfg_seq_48139 rtsx_read_cfg_seq 5-3 48139 NULL
98345 +set_discoverable_48141 set_discoverable 4 48141 NULL
98346 +dn_fib_count_nhs_48145 dn_fib_count_nhs 0 48145 NULL
98347 +bitmap_onto_48152 bitmap_onto 4 48152 NULL
98348 +isr_dma1_done_read_48159 isr_dma1_done_read 3 48159 NULL
98349 +c4iw_id_table_alloc_48163 c4iw_id_table_alloc 3 48163 NULL
98350 +ocfs2_find_next_zero_bit_unaligned_48170 ocfs2_find_next_zero_bit_unaligned 2-3 48170 NULL
98351 +alloc_cc770dev_48186 alloc_cc770dev 1 48186 NULL
98352 +init_ipath_48187 init_ipath 1 48187 NULL nohasharray
98353 +ieee80211_send_auth_48187 ieee80211_send_auth 6 48187 &init_ipath_48187
98354 +snd_seq_dump_var_event_48209 snd_seq_dump_var_event 0 48209 NULL
98355 +is_block_in_journal_48223 is_block_in_journal 3 48223 NULL
98356 +uv_blade_nr_possible_cpus_48226 uv_blade_nr_possible_cpus 0 48226 NULL
98357 +nilfs_readpages_48229 nilfs_readpages 4 48229 NULL
98358 +read_file_recv_48232 read_file_recv 3 48232 NULL
98359 +unaccount_shadowed_48233 unaccount_shadowed 2 48233 NULL nohasharray
98360 +blk_rq_pos_48233 blk_rq_pos 0 48233 &unaccount_shadowed_48233
98361 +nfsctl_transaction_read_48250 nfsctl_transaction_read 3 48250 NULL
98362 +cache_write_pipefs_48270 cache_write_pipefs 3 48270 NULL
98363 +send_set_info_48288 send_set_info 7 48288 NULL
98364 +set_disc_pwup_pfs_48300 set_disc_pwup_pfs 3 48300 NULL
98365 +lpfc_idiag_extacc_read_48301 lpfc_idiag_extacc_read 3 48301 NULL
98366 +timblogiw_read_48305 timblogiw_read 3 48305 NULL
98367 +hash_setkey_48310 hash_setkey 3 48310 NULL
98368 +__alloc_fd_48356 __alloc_fd 2 48356 NULL
98369 +skb_add_data_48363 skb_add_data 3 48363 NULL
98370 +tx_frag_init_called_read_48377 tx_frag_init_called_read 3 48377 NULL
98371 +lbs_debugfs_write_48413 lbs_debugfs_write 3 48413 NULL
98372 +snd_power_wait_48422 snd_power_wait 0 48422 NULL
98373 +pwr_tx_without_ps_read_48423 pwr_tx_without_ps_read 3 48423 NULL
98374 +nfs4_alloc_pages_48426 nfs4_alloc_pages 1 48426 NULL
98375 +tun_recvmsg_48463 tun_recvmsg 4 48463 NULL
98376 +r8712_usbctrl_vendorreq_48489 r8712_usbctrl_vendorreq 6 48489 NULL
98377 +send_control_msg_48498 send_control_msg 6 48498 NULL
98378 +mlx4_en_create_tx_ring_48501 mlx4_en_create_tx_ring 4 48501 NULL
98379 +count_masked_bytes_48507 count_masked_bytes 0-1 48507 NULL
98380 +diva_os_copy_to_user_48508 diva_os_copy_to_user 4 48508 NULL
98381 +brcmf_sdio_trap_info_48510 brcmf_sdio_trap_info 4 48510 NULL
98382 +phantom_get_free_48514 phantom_get_free 0 48514 NULL
98383 +wiimote_hid_send_48528 wiimote_hid_send 3 48528 NULL
98384 +ext3_splice_branch_48531 ext3_splice_branch 6 48531 NULL
98385 +named_distribute_48544 named_distribute 4 48544 NULL
98386 +raid10_size_48571 raid10_size 0-2-3 48571 NULL
98387 +ext_sd_execute_read_data_48589 ext_sd_execute_read_data 9 48589 NULL
98388 +ufs_dtogd_48616 ufs_dtogd 0-2 48616 NULL
98389 +do_ip_vs_set_ctl_48641 do_ip_vs_set_ctl 4 48641 NULL
98390 +mtd_read_48655 mtd_read 0 48655 NULL
98391 +lc_create_48662 lc_create 3 48662 NULL
98392 +aes_encrypt_packets_read_48666 aes_encrypt_packets_read 3 48666 NULL
98393 +sm501_create_subdev_48668 sm501_create_subdev 3-4 48668 NULL nohasharray
98394 +sys_setgroups_48668 sys_setgroups 1 48668 &sm501_create_subdev_48668
98395 +altera_drscan_48698 altera_drscan 2 48698 NULL
98396 +kvm_set_irq_routing_48704 kvm_set_irq_routing 3 48704 NULL
98397 +ath6kl_usb_bmi_read_48745 ath6kl_usb_bmi_read 3 48745 NULL
98398 +ath6kl_regwrite_read_48747 ath6kl_regwrite_read 3 48747 NULL
98399 +l2cap_segment_sdu_48772 l2cap_segment_sdu 4 48772 NULL
98400 +lua_sysfs_write_48797 lua_sysfs_write 6 48797 NULL
98401 +il3945_sta_dbgfs_stats_table_read_48802 il3945_sta_dbgfs_stats_table_read 3 48802 NULL
98402 +twa_change_queue_depth_48808 twa_change_queue_depth 2 48808 NULL
98403 +atomic_counters_read_48827 atomic_counters_read 3 48827 NULL
98404 +azx_get_position_48841 azx_get_position 0 48841 NULL
98405 +vc_do_resize_48842 vc_do_resize 3-4 48842 NULL
98406 +viafb_dvp1_proc_write_48864 viafb_dvp1_proc_write 3 48864 NULL
98407 +__ffs_ep0_read_events_48868 __ffs_ep0_read_events 3 48868 NULL
98408 +sys_setgroups16_48882 sys_setgroups16 1 48882 NULL
98409 +get_num_ops_48886 get_num_ops 0 48886 NULL
98410 +ext2_alloc_branch_48889 ext2_alloc_branch 4 48889 NULL
98411 +crypto_cipher_ctxsize_48890 crypto_cipher_ctxsize 0 48890 NULL
98412 +xdi_copy_to_user_48900 xdi_copy_to_user 4 48900 NULL
98413 +msg_hdr_sz_48908 msg_hdr_sz 0 48908 NULL
98414 +gdth_isa_probe_one_48925 gdth_isa_probe_one 1 48925 NULL nohasharray
98415 +snd_pcm_update_hw_ptr_48925 snd_pcm_update_hw_ptr 0 48925 &gdth_isa_probe_one_48925
98416 +sep_crypto_dma_48937 sep_crypto_dma 0 48937 NULL
98417 +event_heart_beat_read_48961 event_heart_beat_read 3 48961 NULL
98418 +nand_ecc_test_run_48966 nand_ecc_test_run 1 48966 NULL
98419 +batadv_orig_hash_del_if_48972 batadv_orig_hash_del_if 2 48972 NULL
98420 +_alloc_set_attr_list_48991 _alloc_set_attr_list 4 48991 NULL
98421 +rds_rm_size_48996 rds_rm_size 0-2 48996 NULL
98422 +sel_write_enforce_48998 sel_write_enforce 3 48998 NULL
98423 +xd_rw_49020 xd_rw 3-4 49020 NULL
98424 +transient_status_49027 transient_status 4 49027 NULL
98425 +ubi_read_49061 ubi_read 0 49061 NULL
98426 +tps65910_reg_write_49066 tps65910_reg_write 2 49066 NULL
98427 +calc_layout_49074 calc_layout 4 49074 NULL
98428 +vmx_set_msr_49090 vmx_set_msr 3 49090 NULL
98429 +scsi_register_49094 scsi_register 2 49094 NULL
98430 +compat_do_readv_writev_49102 compat_do_readv_writev 4 49102 NULL
98431 +xfrm_replay_state_esn_len_49119 xfrm_replay_state_esn_len 0 49119 NULL
98432 +pt_read_49136 pt_read 3 49136 NULL
98433 +tipc_multicast_49144 tipc_multicast 5 49144 NULL
98434 +atyfb_setup_generic_49151 atyfb_setup_generic 3 49151 NULL
98435 +ipwireless_tty_received_49154 ipwireless_tty_received 3 49154 NULL
98436 +f2fs_acl_count_49155 f2fs_acl_count 0-1 49155 NULL
98437 +ipw_queue_tx_init_49161 ipw_queue_tx_init 3 49161 NULL
98438 +ext4_free_clusters_after_init_49174 ext4_free_clusters_after_init 2 49174 NULL
98439 +dvb_dvr_ioctl_49182 dvb_dvr_ioctl 2 49182 NULL
98440 +iwl_dbgfs_ucode_general_stats_read_49199 iwl_dbgfs_ucode_general_stats_read 3 49199 NULL
98441 +il4965_rs_sta_dbgfs_stats_table_read_49206 il4965_rs_sta_dbgfs_stats_table_read 3 49206 NULL
98442 +do_jffs2_getxattr_49210 do_jffs2_getxattr 0 49210 NULL
98443 +pcf50633_gpio_invert_set_49256 pcf50633_gpio_invert_set 2 49256 NULL
98444 +hugetlb_cgroup_read_49259 hugetlb_cgroup_read 5 49259 NULL
98445 +ieee80211_if_read_rssi_threshold_49260 ieee80211_if_read_rssi_threshold 3 49260 NULL
98446 +osd_req_add_get_attr_list_49278 osd_req_add_get_attr_list 3 49278 NULL
98447 +rx_filter_beacon_filter_read_49279 rx_filter_beacon_filter_read 3 49279 NULL
98448 +uio_read_49300 uio_read 3 49300 NULL
98449 +ocfs2_resmap_find_free_bits_49301 ocfs2_resmap_find_free_bits 3 49301 NULL
98450 +fwtty_port_handler_49327 fwtty_port_handler 9 49327 NULL
98451 +srpt_alloc_ioctx_ring_49330 srpt_alloc_ioctx_ring 2-3-4 49330 NULL
98452 +cfpkt_setlen_49343 cfpkt_setlen 2 49343 NULL
98453 +joydev_ioctl_common_49359 joydev_ioctl_common 2 49359 NULL
98454 +ocfs2_remove_btree_range_49370 ocfs2_remove_btree_range 4-5-3 49370 NULL
98455 +px_raw_event_49371 px_raw_event 4 49371 NULL
98456 +iscsi_alloc_session_49390 iscsi_alloc_session 3 49390 NULL
98457 +applesmc_create_nodes_49392 applesmc_create_nodes 2 49392 NULL
98458 +rx_streaming_always_read_49401 rx_streaming_always_read 3 49401 NULL
98459 +tnode_alloc_49407 tnode_alloc 1 49407 NULL
98460 +samples_to_bytes_49426 samples_to_bytes 0-2 49426 NULL
98461 +md_domain_init_49432 md_domain_init 2 49432 NULL
98462 +compat_do_msg_fill_49440 compat_do_msg_fill 3 49440 NULL
98463 +agp_3_5_isochronous_node_enable_49465 agp_3_5_isochronous_node_enable 3 49465 NULL
98464 +xfs_iformat_local_49472 xfs_iformat_local 4 49472 NULL
98465 +savu_sysfs_read_49473 savu_sysfs_read 6 49473 NULL
98466 +ieee80211_ie_split_49474 ieee80211_ie_split 0-5 49474 NULL
98467 +isr_decrypt_done_read_49490 isr_decrypt_done_read 3 49490 NULL
98468 +emulator_write_phys_49520 emulator_write_phys 2-4 49520 NULL
98469 +acpi_os_ioremap_49523 acpi_os_ioremap 1-2 49523 NULL
98470 +wm831x_dcdc_set_mode_int_49546 wm831x_dcdc_set_mode_int 2 49546 NULL
98471 +smk_write_access_49561 smk_write_access 3 49561 NULL
98472 +ntfs_malloc_nofs_49572 ntfs_malloc_nofs 1 49572 NULL
98473 +alloc_chunk_49575 alloc_chunk 1 49575 NULL
98474 +sctp_setsockopt_default_send_param_49578 sctp_setsockopt_default_send_param 3 49578 NULL
98475 +isr_wakeups_read_49607 isr_wakeups_read 3 49607 NULL
98476 +heap_init_49617 heap_init 2 49617 NULL
98477 +smk_write_doi_49621 smk_write_doi 3 49621 NULL
98478 +btrfsic_cmp_log_and_dev_bytenr_49628 btrfsic_cmp_log_and_dev_bytenr 2 49628 NULL
98479 +svm_set_msr_49643 svm_set_msr 3 49643 NULL
98480 +aa_simple_write_to_buffer_49683 aa_simple_write_to_buffer 3-4 49683 NULL
98481 +sys_gethostname_49698 sys_gethostname 2 49698 NULL
98482 +cx2341x_ctrl_new_menu_49700 cx2341x_ctrl_new_menu 3 49700 NULL
98483 +sep_create_dcb_dmatables_context_kernel_49728 sep_create_dcb_dmatables_context_kernel 6 49728 NULL
98484 +sys_fsetxattr_49736 sys_fsetxattr 4 49736 NULL
98485 +check_frame_49741 check_frame 0 49741 NULL
98486 +zd_usb_iowrite16v_49744 zd_usb_iowrite16v 3 49744 NULL
98487 +btrfs_chunk_num_stripes_49751 btrfs_chunk_num_stripes 0 49751 NULL
98488 +key_conf_keylen_read_49758 key_conf_keylen_read 3 49758 NULL
98489 +fuse_conn_waiting_read_49762 fuse_conn_waiting_read 3 49762 NULL
98490 +isku_sysfs_write_49767 isku_sysfs_write 6 49767 NULL
98491 +ceph_osdc_readpages_49789 ceph_osdc_readpages 10-4 49789 NULL
98492 +nfs4_acl_new_49806 nfs4_acl_new 1 49806 NULL
98493 +arch_gnttab_map_status_49812 arch_gnttab_map_status 3 49812 NULL
98494 +ntfs_copy_from_user_iovec_49829 ntfs_copy_from_user_iovec 3-6-0 49829 NULL
98495 +add_uuid_49831 add_uuid 4 49831 NULL
98496 +ath6kl_fwlog_block_read_49836 ath6kl_fwlog_block_read 3 49836 NULL
98497 +__btrfs_map_block_49839 __btrfs_map_block 3 49839 NULL
98498 +twl4030_write_49846 twl4030_write 2 49846 NULL
98499 +scsi_dispatch_cmd_entry_49848 scsi_dispatch_cmd_entry 3 49848 NULL
98500 +timeradd_entry_49850 timeradd_entry 3 49850 NULL
98501 +sctp_setsockopt_bindx_49870 sctp_setsockopt_bindx 3 49870 NULL
98502 +ceph_get_caps_49890 ceph_get_caps 0 49890 NULL
98503 +__cow_file_range_49901 __cow_file_range 5 49901 NULL
98504 +__copy_from_user_inatomic_nocache_49921 __copy_from_user_inatomic_nocache 3 49921 NULL
98505 +batadv_tt_realloc_packet_buff_49960 batadv_tt_realloc_packet_buff 4 49960 NULL
98506 +b43legacy_pio_read_49978 b43legacy_pio_read 0 49978 NULL
98507 +ieee80211_if_fmt_dtim_count_49987 ieee80211_if_fmt_dtim_count 3 49987 NULL
98508 +sta2x11_swiotlb_alloc_coherent_49994 sta2x11_swiotlb_alloc_coherent 2 49994 NULL
98509 +l2cap_chan_send_49995 l2cap_chan_send 3 49995 NULL
98510 +__module_alloc_50004 __module_alloc 1 50004 NULL
98511 +dn_mss_from_pmtu_50011 dn_mss_from_pmtu 0-2 50011 NULL
98512 +ptrace_readdata_50020 ptrace_readdata 2-4 50020 NULL
98513 +isdn_read_50021 isdn_read 3 50021 NULL
98514 +rbd_req_write_50041 rbd_req_write 4-5 50041 NULL
98515 +alloc_ebda_hpc_50046 alloc_ebda_hpc 1-2 50046 NULL
98516 +vmw_surface_destroy_size_50072 vmw_surface_destroy_size 0 50072 NULL
98517 +arch_setup_ht_irq_50073 arch_setup_ht_irq 1 50073 NULL
98518 +dev_set_alias_50084 dev_set_alias 3 50084 NULL
98519 +pcpu_get_vm_areas_50085 pcpu_get_vm_areas 3 50085 NULL
98520 +sock_setsockopt_50088 sock_setsockopt 5 50088 NULL
98521 +altera_swap_dr_50090 altera_swap_dr 2 50090 NULL
98522 +read_file_slot_50111 read_file_slot 3 50111 NULL
98523 +copy_items_50140 copy_items 6 50140 NULL
98524 +tx_frag_need_fragmentation_read_50153 tx_frag_need_fragmentation_read 3 50153 NULL
98525 +set_cmd_header_50155 set_cmd_header 0 50155 NULL
98526 +reiserfs_bmap_count_50160 reiserfs_bmap_count 0 50160 NULL
98527 +aac_nark_ioremap_50163 aac_nark_ioremap 2 50163 NULL nohasharray
98528 +kmalloc_node_50163 kmalloc_node 1 50163 &aac_nark_ioremap_50163
98529 +rx_filter_ibss_filter_read_50167 rx_filter_ibss_filter_read 3 50167 NULL
98530 +odev_update_50169 odev_update 2 50169 NULL
98531 +ieee80211_if_fmt_dot11MeshHWMPRannInterval_50172 ieee80211_if_fmt_dot11MeshHWMPRannInterval 3 50172 NULL nohasharray
98532 +ubi_resize_volume_50172 ubi_resize_volume 2 50172 &ieee80211_if_fmt_dot11MeshHWMPRannInterval_50172
98533 +ib_send_cm_drep_50186 ib_send_cm_drep 3 50186 NULL
98534 +cfg80211_roamed_bss_50198 cfg80211_roamed_bss 4-6 50198 NULL
98535 +rx_rx_timeout_wa_read_50204 rx_rx_timeout_wa_read 3 50204 NULL
98536 +ieee80211_skb_resize_50211 ieee80211_skb_resize 3 50211 NULL
98537 +mon_bin_compat_ioctl_50234 mon_bin_compat_ioctl 3 50234 NULL
98538 +sg_kmalloc_50240 sg_kmalloc 1 50240 NULL
98539 +afs_extract_data_50261 afs_extract_data 5 50261 NULL
98540 +rxrpc_setsockopt_50286 rxrpc_setsockopt 5 50286 NULL
98541 +soc_codec_reg_show_50302 soc_codec_reg_show 0 50302 NULL
98542 +soc_camera_read_50319 soc_camera_read 3 50319 NULL
98543 +do_launder_page_50329 do_launder_page 0 50329 NULL
98544 +nouveau_engine_create__50331 nouveau_engine_create_ 7 50331 NULL
98545 +lpfc_idiag_pcicfg_read_50334 lpfc_idiag_pcicfg_read 3 50334 NULL
98546 +ocfs2_block_to_cluster_group_50337 ocfs2_block_to_cluster_group 2 50337 NULL nohasharray
98547 +snd_pcm_lib_writev_50337 snd_pcm_lib_writev 0-3 50337 &ocfs2_block_to_cluster_group_50337
98548 +roccat_common2_send_with_status_50343 roccat_common2_send_with_status 4 50343 NULL
98549 +tpm_read_50344 tpm_read 3 50344 NULL
98550 +kvm_arch_create_memslot_50354 kvm_arch_create_memslot 2 50354 NULL
98551 +isdn_ppp_read_50356 isdn_ppp_read 4 50356 NULL
98552 +unpack_u16_chunk_50357 unpack_u16_chunk 0 50357 NULL
98553 +xfrm_send_migrate_50365 xfrm_send_migrate 5 50365 NULL
98554 +roccat_common2_receive_50369 roccat_common2_receive 4 50369 NULL
98555 +sl_alloc_bufs_50380 sl_alloc_bufs 2 50380 NULL
98556 +l2tp_ip_sendmsg_50411 l2tp_ip_sendmsg 4 50411 NULL
98557 +iscsi_create_conn_50425 iscsi_create_conn 2 50425 NULL
98558 +btrfs_error_discard_extent_50444 btrfs_error_discard_extent 2 50444 NULL
98559 +pgctrl_write_50453 pgctrl_write 3 50453 NULL
98560 +tps65217_update_bits_50472 tps65217_update_bits 2 50472 NULL
98561 +cdrom_read_cdda_50478 cdrom_read_cdda 4 50478 NULL
98562 +mei_io_cb_alloc_req_buf_50493 mei_io_cb_alloc_req_buf 2 50493 NULL
98563 +pwr_rcvd_awake_beacons_read_50505 pwr_rcvd_awake_beacons_read 3 50505 NULL
98564 +fwnet_receive_packet_50537 fwnet_receive_packet 9 50537 NULL
98565 +ath6kl_set_ap_probe_resp_ies_50539 ath6kl_set_ap_probe_resp_ies 3 50539 NULL
98566 +pcf50633_reg_set_bit_mask_50544 pcf50633_reg_set_bit_mask 2 50544 NULL
98567 +hme_read_desc32_50574 hme_read_desc32 0 50574 NULL
98568 +fat_readpages_50582 fat_readpages 4 50582 NULL
98569 +iwl_dbgfs_missed_beacon_read_50584 iwl_dbgfs_missed_beacon_read 3 50584 NULL
98570 +build_inv_iommu_pages_50589 build_inv_iommu_pages 2-3 50589 NULL
98571 +rx_rx_checksum_result_read_50617 rx_rx_checksum_result_read 3 50617 NULL
98572 +__ffs_50625 __ffs 0 50625 NULL
98573 +simple_transaction_get_50633 simple_transaction_get 3 50633 NULL
98574 +ath6kl_tm_rx_event_50664 ath6kl_tm_rx_event 3 50664 NULL nohasharray
98575 +sys_readv_50664 sys_readv 3 50664 &ath6kl_tm_rx_event_50664
98576 +bnad_debugfs_read_50665 bnad_debugfs_read 3 50665 NULL
98577 +ext2_try_to_allocate_with_rsv_50669 ext2_try_to_allocate_with_rsv 4-2 50669 NULL
98578 +btmrvl_psstate_read_50683 btmrvl_psstate_read 3 50683 NULL
98579 +xfs_growfs_get_hdr_buf_50697 xfs_growfs_get_hdr_buf 3 50697 NULL
98580 +blk_check_plugged_50736 blk_check_plugged 3 50736 NULL
98581 +__ext3_get_inode_loc_50744 __ext3_get_inode_loc 0 50744 NULL
98582 +skb_padto_50759 skb_padto 2 50759 NULL
98583 +ocfs2_xattr_block_get_50773 ocfs2_xattr_block_get 0 50773 NULL
98584 +tm6000_read_write_usb_50774 tm6000_read_write_usb 7 50774 NULL
98585 +bio_alloc_map_data_50782 bio_alloc_map_data 1-2 50782 NULL
98586 +tpm_write_50798 tpm_write 3 50798 NULL
98587 +tun_do_read_50800 tun_do_read 4 50800 NULL
98588 +write_flush_50803 write_flush 3 50803 NULL
98589 +dvb_play_50814 dvb_play 3 50814 NULL
98590 +dpcm_show_state_50827 dpcm_show_state 0 50827 NULL
98591 +acpi_ev_install_gpe_block_50829 acpi_ev_install_gpe_block 2 50829 NULL
98592 +pstore_mkfile_50830 pstore_mkfile 5 50830 NULL
98593 +dma_attach_50831 dma_attach 6-7 50831 NULL
98594 +SetArea_50835 SetArea 4 50835 NULL nohasharray
98595 +create_mem_extents_50835 create_mem_extents 0 50835 &SetArea_50835
98596 +self_check_write_50856 self_check_write 5 50856 NULL
98597 +carl9170_debugfs_write_50857 carl9170_debugfs_write 3 50857 NULL
98598 +netlbl_secattr_catmap_walk_rng_50894 netlbl_secattr_catmap_walk_rng 0-2 50894 NULL
98599 +osd_req_write_sg_50908 osd_req_write_sg 5 50908 NULL
98600 +xfs_iext_remove_50909 xfs_iext_remove 3 50909 NULL
98601 +blk_rq_cur_sectors_50910 blk_rq_cur_sectors 0 50910 NULL
98602 +hash_recvmsg_50924 hash_recvmsg 4 50924 NULL
98603 +chd_dec_fetch_cdata_50926 chd_dec_fetch_cdata 3 50926 NULL
98604 +sock_bindtodevice_50942 sock_bindtodevice 3 50942 NULL
98605 +ocfs2_add_refcount_flag_50952 ocfs2_add_refcount_flag 6 50952 NULL
98606 +iwl_statistics_flag_50981 iwl_statistics_flag 0-3 50981 NULL
98607 +timeout_write_50991 timeout_write 3 50991 NULL
98608 +wm831x_irq_map_50995 wm831x_irq_map 2 50995 NULL nohasharray
98609 +wm8903_gpio_direction_out_50995 wm8903_gpio_direction_out 2 50995 &wm831x_irq_map_50995
98610 +proc_write_51003 proc_write 3 51003 NULL
98611 +lbs_dev_info_51023 lbs_dev_info 3 51023 NULL
98612 +ntfs_attr_find_51028 ntfs_attr_find 0 51028 NULL nohasharray
98613 +fuse_conn_congestion_threshold_read_51028 fuse_conn_congestion_threshold_read 3 51028 &ntfs_attr_find_51028
98614 +BcmGetSectionValEndOffset_51039 BcmGetSectionValEndOffset 0 51039 NULL
98615 +dump_midi_51040 dump_midi 3 51040 NULL
98616 +srpt_alloc_ioctx_51042 srpt_alloc_ioctx 2-3 51042 NULL
98617 +do_arpt_set_ctl_51053 do_arpt_set_ctl 4 51053 NULL
98618 +wusb_prf_64_51065 wusb_prf_64 7 51065 NULL
98619 +jbd2_journal_init_revoke_51088 jbd2_journal_init_revoke 2 51088 NULL
98620 +__ocfs2_find_path_51096 __ocfs2_find_path 0 51096 NULL
98621 +dgrp_net_read_51113 dgrp_net_read 3 51113 NULL
98622 +lm3533_als_get_current_51120 lm3533_als_get_current 2 51120 NULL
98623 +nfs_map_name_to_uid_51132 nfs_map_name_to_uid 3 51132 NULL
98624 +alloc_rtllib_51136 alloc_rtllib 1 51136 NULL
98625 +simple_xattr_set_51140 simple_xattr_set 4 51140 NULL
98626 +xfs_trans_get_efd_51148 xfs_trans_get_efd 3 51148 NULL
98627 +compat_sys_pwritev64_51151 compat_sys_pwritev64 3 51151 NULL
98628 +snd_pcm_unlink_51210 snd_pcm_unlink 0 51210 NULL
98629 +blk_bio_map_sg_51213 blk_bio_map_sg 0 51213 NULL
98630 +nf_ct_ext_create_51232 nf_ct_ext_create 3 51232 NULL
98631 +snd_pcm_write_51235 snd_pcm_write 3 51235 NULL
98632 +tipc_send_51238 tipc_send 4 51238 NULL
98633 +drm_property_create_51239 drm_property_create 4 51239 NULL
98634 +st_read_51251 st_read 3 51251 NULL
98635 +compat_dccp_setsockopt_51263 compat_dccp_setsockopt 5 51263 NULL
98636 +dvb_audio_write_51275 dvb_audio_write 3 51275 NULL
98637 +ipwireless_network_packet_received_51277 ipwireless_network_packet_received 4 51277 NULL
98638 +zone_reclaimable_pages_51283 zone_reclaimable_pages 0 51283 NULL
98639 +pvr2_std_id_to_str_51288 pvr2_std_id_to_str 2 51288 NULL
98640 +fd_do_readv_51297 fd_do_readv 3 51297 NULL
98641 +bnad_debugfs_read_regrd_51308 bnad_debugfs_read_regrd 3 51308 NULL
98642 +alloc_hippi_dev_51320 alloc_hippi_dev 1 51320 NULL
98643 +ext2_xattr_get_51327 ext2_xattr_get 0 51327 NULL
98644 +alloc_smp_req_51337 alloc_smp_req 1 51337 NULL nohasharray
98645 +compat_arch_ptrace_51337 compat_arch_ptrace 3-4 51337 &alloc_smp_req_51337
98646 +ipw_get_event_log_len_51341 ipw_get_event_log_len 0 51341 NULL
98647 +ieee80211_if_fmt_estab_plinks_51370 ieee80211_if_fmt_estab_plinks 3 51370 NULL
98648 +radeon_kms_compat_ioctl_51371 radeon_kms_compat_ioctl 2 51371 NULL
98649 +ieee80211_wx_set_gen_ie_51399 ieee80211_wx_set_gen_ie 3 51399 NULL
98650 +ceph_sync_read_51410 ceph_sync_read 3 51410 NULL
98651 +blk_register_region_51424 blk_register_region 1-2 51424 NULL
98652 +mwifiex_rdeeprom_read_51429 mwifiex_rdeeprom_read 3 51429 NULL
98653 +ieee80211_if_read_dot11MeshHWMPRootMode_51441 ieee80211_if_read_dot11MeshHWMPRootMode 3 51441 NULL
98654 +print_devstats_dot11ACKFailureCount_51443 print_devstats_dot11ACKFailureCount 3 51443 NULL
98655 +____alloc_ei_netdev_51475 ____alloc_ei_netdev 1 51475 NULL
98656 +xfs_buf_get_uncached_51477 xfs_buf_get_uncached 2 51477 NULL
98657 +ieee80211_if_write_uapsd_queues_51526 ieee80211_if_write_uapsd_queues 3 51526 NULL
98658 +__alloc_eip_netdev_51549 __alloc_eip_netdev 1 51549 NULL
98659 +icmp_manip_pkt_51560 icmp_manip_pkt 4 51560 NULL
98660 +ixgb_get_eeprom_len_51586 ixgb_get_eeprom_len 0 51586 NULL
98661 +aac_convert_sgraw2_51598 aac_convert_sgraw2 4 51598 NULL
98662 +raw_ioctl_51607 raw_ioctl 3 51607 NULL
98663 +table_size_to_number_of_entries_51613 table_size_to_number_of_entries 0-1 51613 NULL
98664 +dns_resolve_server_name_to_ip_51632 dns_resolve_server_name_to_ip 0 51632 NULL
98665 +sctp_auth_create_key_51641 sctp_auth_create_key 1 51641 NULL
98666 +iscsi_create_session_51647 iscsi_create_session 3 51647 NULL
98667 +get_new_cssid_51665 get_new_cssid 2 51665 NULL
98668 +ps_upsd_utilization_read_51669 ps_upsd_utilization_read 3 51669 NULL
98669 +sctp_setsockopt_associnfo_51684 sctp_setsockopt_associnfo 3 51684 NULL
98670 +sfi_sysfs_install_table_51688 sfi_sysfs_install_table 1 51688 NULL
98671 +sel_write_access_51704 sel_write_access 3 51704 NULL
98672 +tty_cdev_add_51714 tty_cdev_add 2-4 51714 NULL
98673 +drm_compat_ioctl_51717 drm_compat_ioctl 2 51717 NULL
98674 +sg_read_oxfer_51724 sg_read_oxfer 3 51724 NULL
98675 +msg_set_51725 msg_set 3 51725 NULL
98676 +dbg_check_lpt_nodes_51727 dbg_check_lpt_nodes 0 51727 NULL
98677 +hid_parse_report_51737 hid_parse_report 3 51737 NULL
98678 +get_user_pages_fast_51751 get_user_pages_fast 0 51751 NULL
98679 +ifx_spi_insert_flip_string_51752 ifx_spi_insert_flip_string 3 51752 NULL
98680 +if_write_51756 if_write 3 51756 NULL
98681 +ioremap_prot_51764 ioremap_prot 1-2 51764 NULL
98682 +iio_buffer_add_channel_sysfs_51766 iio_buffer_add_channel_sysfs 0 51766 NULL
98683 +__fswab32_51781 __fswab32 0 51781 NULL
98684 +qib_alloc_devdata_51819 qib_alloc_devdata 2 51819 NULL
98685 +buffer_from_user_51826 buffer_from_user 3 51826 NULL
98686 +wm2000_write_51834 wm2000_write 2 51834 NULL
98687 +ioread32_51847 ioread32 0 51847 NULL nohasharray
98688 +read_file_tgt_tx_stats_51847 read_file_tgt_tx_stats 3 51847 &ioread32_51847
98689 +do_readv_writev_51849 do_readv_writev 4 51849 NULL
98690 +pointer_size_read_51863 pointer_size_read 3 51863 NULL
98691 +mlx4_alloc_db_from_pgdir_51865 mlx4_alloc_db_from_pgdir 3 51865 NULL
98692 +get_indirect_ea_51869 get_indirect_ea 4 51869 NULL
98693 +user_read_51881 user_read 3 51881 NULL
98694 +dbAdjCtl_51888 dbAdjCtl 0 51888 NULL
98695 +virt_to_phys_51896 virt_to_phys 0 51896 NULL
98696 +iio_read_first_n_sw_rb_51911 iio_read_first_n_sw_rb 2 51911 NULL
98697 +wmi_set_ie_51919 wmi_set_ie 3 51919 NULL
98698 +dbg_status_buf_51930 dbg_status_buf 2 51930 NULL
98699 +__tcp_mtu_to_mss_51938 __tcp_mtu_to_mss 0-2 51938 NULL
98700 +xfrm_alg_len_51940 xfrm_alg_len 0 51940 NULL
98701 +irq_dispose_mapping_51941 irq_dispose_mapping 1 51941 NULL
98702 +scsi_get_vpd_page_51951 scsi_get_vpd_page 4 51951 NULL
98703 +arizona_free_irq_51969 arizona_free_irq 2 51969 NULL nohasharray
98704 +snd_mask_min_51969 snd_mask_min 0 51969 &arizona_free_irq_51969
98705 +ath6kl_sdio_alloc_prep_scat_req_51986 ath6kl_sdio_alloc_prep_scat_req 2 51986 NULL
98706 +dwc3_mode_write_51997 dwc3_mode_write 3 51997 NULL
98707 +skb_copy_datagram_from_iovec_52014 skb_copy_datagram_from_iovec 4-2-5 52014 NULL
98708 +rdmalt_52022 rdmalt 0 52022 NULL
98709 +vxge_rx_alloc_52024 vxge_rx_alloc 3 52024 NULL
98710 +override_release_52032 override_release 2 52032 NULL
98711 +end_port_52042 end_port 0 52042 NULL
98712 +dma_rx_errors_read_52045 dma_rx_errors_read 3 52045 NULL
98713 +msnd_fifo_write_52052 msnd_fifo_write 0-3 52052 NULL
98714 +dvb_ringbuffer_avail_52057 dvb_ringbuffer_avail 0 52057 NULL
98715 +isofs_readpages_52067 isofs_readpages 4 52067 NULL
98716 +nsm_get_handle_52089 nsm_get_handle 4 52089 NULL
98717 +o2net_debug_read_52105 o2net_debug_read 3 52105 NULL
98718 +retry_count_read_52129 retry_count_read 3 52129 NULL
98719 +snd_pcm_channel_info_user_52135 snd_pcm_channel_info_user 0 52135 NULL
98720 +hysdn_conf_write_52145 hysdn_conf_write 3 52145 NULL nohasharray
98721 +ext2_alloc_blocks_52145 ext2_alloc_blocks 2 52145 &hysdn_conf_write_52145
98722 +htable_size_52148 htable_size 0-1 52148 NULL
98723 +__le16_to_cpup_52155 __le16_to_cpup 0 52155 NULL nohasharray
98724 +smk_write_load2_52155 smk_write_load2 3 52155 &__le16_to_cpup_52155
98725 +ieee80211_if_read_dot11MeshRetryTimeout_52168 ieee80211_if_read_dot11MeshRetryTimeout 3 52168 NULL
98726 +mga_compat_ioctl_52170 mga_compat_ioctl 2 52170 NULL
98727 +print_prefix_52176 print_prefix 0 52176 NULL
98728 +proc_pid_readlink_52186 proc_pid_readlink 3 52186 NULL
98729 +do_dmabuf_dirty_ldu_52241 do_dmabuf_dirty_ldu 6 52241 NULL
98730 +pm80x_request_irq_52250 pm80x_request_irq 2 52250 NULL
98731 +mdiobus_alloc_size_52259 mdiobus_alloc_size 1 52259 NULL
98732 +shrink_slab_52261 shrink_slab 2-3 52261 NULL
98733 +sisusbcon_do_font_op_52271 sisusbcon_do_font_op 9 52271 NULL
98734 +mpol_to_str_52293 mpol_to_str 2 52293 NULL
98735 +ath6kl_wmi_get_new_buf_52304 ath6kl_wmi_get_new_buf 1 52304 NULL
98736 +read_file_reset_52310 read_file_reset 3 52310 NULL
98737 +ssd1307fb_write_52315 ssd1307fb_write 3 52315 NULL
98738 +request_asymmetric_key_52317 request_asymmetric_key 2-4 52317 NULL
98739 +hwflags_read_52318 hwflags_read 3 52318 NULL
98740 +snd_pcm_hw_free_52327 snd_pcm_hw_free 0 52327 NULL
98741 +ntfs_rl_split_52328 ntfs_rl_split 2-4 52328 NULL
98742 +test_unaligned_bulk_52333 test_unaligned_bulk 3 52333 NULL
98743 +bytes_to_frames_52362 bytes_to_frames 0-2 52362 NULL
98744 +copy_entries_to_user_52367 copy_entries_to_user 1 52367 NULL
98745 +iwl_dump_fh_52371 iwl_dump_fh 0 52371 NULL
98746 +isdn_writebuf_stub_52383 isdn_writebuf_stub 4 52383 NULL
98747 +jfs_setxattr_52389 jfs_setxattr 4 52389 NULL
98748 +aer_inject_write_52399 aer_inject_write 3 52399 NULL
98749 +pcf50633_reg_clear_bits_52407 pcf50633_reg_clear_bits 2 52407 NULL
98750 +aac_rx_ioremap_52410 aac_rx_ioremap 2 52410 NULL
98751 +cgroup_file_write_52417 cgroup_file_write 3 52417 NULL
98752 +line6_midibuf_init_52425 line6_midibuf_init 2 52425 NULL
98753 +ieee80211_if_fmt_num_sta_ps_52438 ieee80211_if_fmt_num_sta_ps 3 52438 NULL
98754 +nl80211_send_mgmt_tx_status_52445 nl80211_send_mgmt_tx_status 5 52445 NULL
98755 +ieee80211_alloc_txb_52477 ieee80211_alloc_txb 1-2 52477 NULL
98756 +ocfs2_extend_no_holes_52483 ocfs2_extend_no_holes 3-4 52483 NULL
98757 +fd_do_rw_52495 fd_do_rw 3 52495 NULL nohasharray
98758 +skb_cow_head_52495 skb_cow_head 2 52495 &fd_do_rw_52495
98759 +int_tasklet_entry_52500 int_tasklet_entry 3 52500 NULL
98760 +pm_qos_power_write_52513 pm_qos_power_write 3 52513 NULL
98761 +dccpprobe_read_52549 dccpprobe_read 3 52549 NULL
98762 +ocfs2_make_right_split_rec_52562 ocfs2_make_right_split_rec 3 52562 NULL
98763 +emit_code_52583 emit_code 0-3 52583 NULL
98764 +snd_pcm_sw_params_52594 snd_pcm_sw_params 0 52594 NULL
98765 +brcmf_sdio_assert_info_52653 brcmf_sdio_assert_info 4 52653 NULL
98766 +ntfs_get_nr_significant_bytes_52688 ntfs_get_nr_significant_bytes 0 52688 NULL
98767 +nvd0_disp_pioc_create__52693 nvd0_disp_pioc_create_ 5 52693 NULL
98768 +nouveau_client_create__52715 nouveau_client_create_ 5 52715 NULL
98769 +cx25840_ir_rx_read_52724 cx25840_ir_rx_read 3 52724 NULL
98770 +blkcipher_next_slow_52733 blkcipher_next_slow 3-4 52733 NULL
98771 +relay_alloc_page_array_52735 relay_alloc_page_array 1 52735 NULL
98772 +carl9170_debugfs_vif_dump_read_52755 carl9170_debugfs_vif_dump_read 3 52755 NULL
98773 +alloc_extent_buffer_52824 alloc_extent_buffer 3 52824 NULL
98774 +pwr_rcvd_beacons_read_52836 pwr_rcvd_beacons_read 3 52836 NULL
98775 +ext2_xattr_set_acl_52857 ext2_xattr_set_acl 4 52857 NULL
98776 +mon_bin_get_event_52863 mon_bin_get_event 4 52863 NULL
98777 +twlreg_write_52880 twlreg_write 3 52880 NULL
98778 +pvr2_ctrl_value_to_sym_internal_52881 pvr2_ctrl_value_to_sym_internal 5 52881 NULL
98779 +cache_read_procfs_52882 cache_read_procfs 3 52882 NULL
98780 +kvm_kvzalloc_52894 kvm_kvzalloc 1 52894 NULL
98781 +arizona_request_irq_52908 arizona_request_irq 2 52908 NULL
98782 +__kfifo_out_peek_r_52919 __kfifo_out_peek_r 3 52919 NULL
98783 +iblock_get_bio_52936 iblock_get_bio 3 52936 NULL nohasharray
98784 +__iio_device_attr_init_52936 __iio_device_attr_init 0 52936 &iblock_get_bio_52936
98785 +__nodes_remap_52951 __nodes_remap 5 52951 NULL
98786 +send_packet_52960 send_packet 4 52960 NULL
98787 +ieee80211_if_fmt_fwded_mcast_52961 ieee80211_if_fmt_fwded_mcast 3 52961 NULL
98788 +compat_sock_ioctl_52964 compat_sock_ioctl 3 52964 NULL
98789 +tx_tx_exch_read_52986 tx_tx_exch_read 3 52986 NULL
98790 +num_node_state_52989 num_node_state 0 52989 NULL
98791 +batadv_check_management_packet_52993 batadv_check_management_packet 3 52993 NULL
98792 +efivarfs_file_write_53000 efivarfs_file_write 3 53000 NULL
98793 +btrfs_free_and_pin_reserved_extent_53016 btrfs_free_and_pin_reserved_extent 2 53016 NULL
98794 +tx_tx_exch_pending_read_53018 tx_tx_exch_pending_read 3 53018 NULL
98795 +ext4_meta_bg_first_group_53031 ext4_meta_bg_first_group 0-2 53031 NULL
98796 +bio_cur_bytes_53037 bio_cur_bytes 0 53037 NULL
98797 +regcache_lzo_block_count_53056 regcache_lzo_block_count 0 53056 NULL
98798 +cfi_read_query_53066 cfi_read_query 0 53066 NULL
98799 +mwifiex_debug_read_53074 mwifiex_debug_read 3 53074 NULL
98800 +qib_resize_cq_53090 qib_resize_cq 2 53090 NULL
98801 +line6_dumpreq_initbuf_53123 line6_dumpreq_initbuf 3 53123 NULL
98802 +brcmf_usb_dl_cmd_53130 brcmf_usb_dl_cmd 4 53130 NULL
98803 +ps_poll_ps_poll_max_ap_turn_read_53140 ps_poll_ps_poll_max_ap_turn_read 3 53140 NULL
98804 +clear_capture_buf_53192 clear_capture_buf 2 53192 NULL
98805 +mtdoops_erase_block_53206 mtdoops_erase_block 2 53206 NULL
98806 +tx_tx_start_data_read_53219 tx_tx_start_data_read 3 53219 NULL
98807 +xfs_trans_read_buf_map_53258 xfs_trans_read_buf_map 5 53258 NULL
98808 +wil_write_file_ssid_53266 wil_write_file_ssid 3 53266 NULL
98809 +btrfs_file_extent_num_bytes_53269 btrfs_file_extent_num_bytes 0 53269 NULL
98810 +lirc_buffer_init_53282 lirc_buffer_init 3-2 53282 NULL
98811 +batadv_interface_rx_53325 batadv_interface_rx 4 53325 NULL
98812 +gsm_control_reply_53333 gsm_control_reply 4 53333 NULL
98813 +vm_mmap_53339 vm_mmap 0 53339 NULL
98814 +sock_setbindtodevice_53369 sock_setbindtodevice 3 53369 NULL
98815 +get_random_bytes_arch_53370 get_random_bytes_arch 2 53370 NULL
98816 +iwl_pcie_txq_alloc_53413 iwl_pcie_txq_alloc 3 53413 NULL
98817 +wm8996_gpio_set_53421 wm8996_gpio_set 2 53421 NULL
98818 +isr_cmd_cmplt_read_53439 isr_cmd_cmplt_read 3 53439 NULL
98819 +mwifiex_info_read_53447 mwifiex_info_read 3 53447 NULL
98820 +apei_exec_run_optional_53452 apei_exec_run_optional 0 53452 NULL
98821 +acpi_tb_parse_root_table_53455 acpi_tb_parse_root_table 1 53455 NULL
98822 +n2_run_53459 n2_run 3 53459 NULL
98823 +paging64_prefetch_gpte_53468 paging64_prefetch_gpte 4 53468 NULL
98824 +wm831x_write_53469 wm831x_write 2 53469 NULL
98825 +rds_tcp_data_recv_53476 rds_tcp_data_recv 3 53476 NULL
98826 +iowarrior_read_53483 iowarrior_read 3 53483 NULL
98827 +osd_req_write_kern_53486 osd_req_write_kern 5 53486 NULL
98828 +do_verify_xattr_datum_53499 do_verify_xattr_datum 0 53499 NULL
98829 +snd_pcm_format_physical_width_53505 snd_pcm_format_physical_width 0 53505 NULL
98830 +dbAllocNext_53506 dbAllocNext 0 53506 NULL
98831 +ocfs2_xattr_set_acl_53508 ocfs2_xattr_set_acl 4 53508 NULL
98832 +check_acl_53512 check_acl 0 53512 NULL
98833 +set_registers_53582 set_registers 3 53582 NULL
98834 +cifs_utf16_bytes_53593 cifs_utf16_bytes 0 53593 NULL
98835 +__readw_53594 __readw 0 53594 NULL
98836 +___alloc_bootmem_nopanic_53626 ___alloc_bootmem_nopanic 1 53626 NULL
98837 +xd_write_multiple_pages_53633 xd_write_multiple_pages 6-5 53633 NULL
98838 +ccid_getsockopt_builtin_ccids_53634 ccid_getsockopt_builtin_ccids 2 53634 NULL
98839 +nr_sendmsg_53656 nr_sendmsg 4 53656 NULL
98840 +_preload_range_53676 _preload_range 2-3 53676 NULL
98841 +fuse_fill_write_pages_53682 fuse_fill_write_pages 4 53682 NULL
98842 +v4l2_event_subscribe_53687 v4l2_event_subscribe 3 53687 NULL
98843 +bdev_logical_block_size_53690 bdev_logical_block_size 0 53690 NULL nohasharray
98844 +igb_alloc_q_vector_53690 igb_alloc_q_vector 4-6 53690 &bdev_logical_block_size_53690
98845 +find_overflow_devnum_53711 find_overflow_devnum 0 53711 NULL
98846 +bio_integrity_split_53714 bio_integrity_split 3 53714 NULL
98847 +__ocfs2_resv_find_window_53721 __ocfs2_resv_find_window 3 53721 NULL
98848 +wdm_write_53735 wdm_write 3 53735 NULL
98849 +ext3_try_to_allocate_with_rsv_53737 ext3_try_to_allocate_with_rsv 5-3 53737 NULL
98850 +da9052_disable_irq_53745 da9052_disable_irq 2 53745 NULL
98851 +lpfc_idiag_queacc_read_qe_53755 lpfc_idiag_queacc_read_qe 0-2 53755 NULL nohasharray
98852 +amdtp_out_stream_get_max_payload_53755 amdtp_out_stream_get_max_payload 0 53755 &lpfc_idiag_queacc_read_qe_53755
98853 +ext2_acl_count_53773 ext2_acl_count 0-1 53773 NULL
98854 +__kfifo_dma_in_prepare_r_53792 __kfifo_dma_in_prepare_r 4-5 53792 NULL
98855 +__tty_alloc_driver_53799 __tty_alloc_driver 1 53799 NULL
98856 +regmap_raw_write_53803 regmap_raw_write 4-2 53803 NULL
98857 +lpfc_idiag_ctlacc_read_reg_53809 lpfc_idiag_ctlacc_read_reg 0-3 53809 NULL
98858 +nls_nullsize_53815 nls_nullsize 0 53815 NULL
98859 +cpumask_next_zero_53835 cpumask_next_zero 1 53835 NULL
98860 +pms_read_53873 pms_read 3 53873 NULL
98861 +ieee80211_if_fmt_dropped_frames_congestion_53883 ieee80211_if_fmt_dropped_frames_congestion 3 53883 NULL
98862 +ocfs2_rm_xattr_cluster_53900 ocfs2_rm_xattr_cluster 5-4-3 53900 NULL
98863 +proc_file_read_53905 proc_file_read 3 53905 NULL
98864 +azx_via_get_position_53916 azx_via_get_position 0 53916 NULL
98865 +ocfs2_make_clusters_writable_53938 ocfs2_make_clusters_writable 4 53938 NULL
98866 +mthca_setup_cmd_doorbells_53954 mthca_setup_cmd_doorbells 2 53954 NULL
98867 +mlx4_num_eq_uar_53965 mlx4_num_eq_uar 0 53965 NULL
98868 +idetape_chrdev_write_53976 idetape_chrdev_write 3 53976 NULL
98869 +__ocfs2_xattr_set_value_outside_53981 __ocfs2_xattr_set_value_outside 5 53981 NULL
98870 +ieee80211_if_fmt_dot11MeshHWMPperrMinInterval_53998 ieee80211_if_fmt_dot11MeshHWMPperrMinInterval 3 53998 NULL
98871 +snd_pcm_lib_write_transfer_54018 snd_pcm_lib_write_transfer 4-2-5 54018 NULL
98872 +cmpk_message_handle_tx_54024 cmpk_message_handle_tx 4 54024 NULL
98873 +ipxrtr_route_packet_54036 ipxrtr_route_packet 4 54036 NULL
98874 +pipeline_dec_packet_out_read_54052 pipeline_dec_packet_out_read 3 54052 NULL
98875 +nl80211_send_disconnected_54056 nl80211_send_disconnected 5 54056 NULL
98876 +rproc_state_read_54057 rproc_state_read 3 54057 NULL
98877 +_malloc_54077 _malloc 1 54077 NULL
98878 +bitmap_bitremap_54096 bitmap_bitremap 4 54096 NULL
98879 +altera_set_ir_pre_54103 altera_set_ir_pre 2 54103 NULL
98880 +create_xattr_54106 create_xattr 5 54106 NULL
98881 +strn_len_54122 strn_len 0 54122 NULL
98882 +isku_receive_54130 isku_receive 4 54130 NULL
98883 +isr_host_acknowledges_read_54136 isr_host_acknowledges_read 3 54136 NULL
98884 +i2400m_zrealloc_2x_54166 i2400m_zrealloc_2x 3 54166 NULL nohasharray
98885 +memcpy_toiovec_54166 memcpy_toiovec 3 54166 &i2400m_zrealloc_2x_54166
98886 +nouveau_falcon_create__54169 nouveau_falcon_create_ 8 54169 NULL
98887 +acpi_os_read_memory_54186 acpi_os_read_memory 1-3 54186 NULL
98888 +__register_chrdev_54223 __register_chrdev 2-3 54223 NULL
98889 +_format_mac_addr_54229 _format_mac_addr 2-0 54229 NULL
98890 +pi_read_regr_54231 pi_read_regr 0 54231 NULL
98891 +reada_add_block_54247 reada_add_block 2 54247 NULL
98892 +xfs_dir2_sf_addname_hard_54254 xfs_dir2_sf_addname_hard 3 54254 NULL
98893 +ceph_msgpool_get_54258 ceph_msgpool_get 2 54258 NULL
98894 +wusb_prf_54261 wusb_prf 7 54261 NULL nohasharray
98895 +audio_write_54261 audio_write 4 54261 &wusb_prf_54261
98896 +mwifiex_getlog_read_54269 mwifiex_getlog_read 3 54269 NULL
98897 +ubi_calc_data_len_54279 ubi_calc_data_len 0-3 54279 NULL
98898 +altera_set_dr_post_54291 altera_set_dr_post 2 54291 NULL
98899 +dlm_alloc_pagevec_54296 dlm_alloc_pagevec 1 54296 NULL
98900 +sprintf_54306 sprintf 0 54306 NULL
98901 +irq_domain_associate_many_54307 irq_domain_associate_many 2 54307 NULL
98902 +br_fdb_fillbuf_54339 br_fdb_fillbuf 0 54339 NULL
98903 +__alloc_dev_table_54343 __alloc_dev_table 2 54343 NULL
98904 +_osd_realloc_seg_54352 _osd_realloc_seg 3 54352 NULL nohasharray
98905 +__get_free_pages_54352 __get_free_pages 0 54352 &_osd_realloc_seg_54352
98906 +tcf_hash_create_54360 tcf_hash_create 4 54360 NULL
98907 +read_file_credit_dist_stats_54367 read_file_credit_dist_stats 3 54367 NULL
98908 +vfs_readlink_54368 vfs_readlink 3 54368 NULL
98909 +do_dccp_setsockopt_54377 do_dccp_setsockopt 5 54377 NULL nohasharray
98910 +intel_sdvo_write_cmd_54377 intel_sdvo_write_cmd 4 54377 &do_dccp_setsockopt_54377
98911 +ah_alloc_tmp_54378 ah_alloc_tmp 3-2 54378 NULL
98912 +gart_unmap_page_54379 gart_unmap_page 2-3 54379 NULL
98913 +snd_pcm_oss_read2_54387 snd_pcm_oss_read2 0-3 54387 NULL
98914 +i386_mmap_check_54388 i386_mmap_check 0 54388 NULL
98915 +__do_krealloc_54389 __do_krealloc 2 54389 NULL
98916 +iwl_dbgfs_power_save_status_read_54392 iwl_dbgfs_power_save_status_read 3 54392 NULL
98917 +simple_strtoull_54493 simple_strtoull 0 54493 NULL
98918 +btrfs_ordered_sum_size_54509 btrfs_ordered_sum_size 0-2 54509 NULL
98919 +cgroup_write_X64_54514 cgroup_write_X64 5 54514 NULL
98920 +rfc4106_set_key_54519 rfc4106_set_key 3 54519 NULL
98921 +viacam_read_54526 viacam_read 3 54526 NULL
98922 +unix_dgram_connect_54535 unix_dgram_connect 3 54535 NULL
98923 +setsockopt_54539 setsockopt 5 54539 NULL
98924 +mwifiex_usb_submit_rx_urb_54558 mwifiex_usb_submit_rx_urb 2 54558 NULL
98925 +nfsd_vfs_write_54577 nfsd_vfs_write 6 54577 NULL
98926 +fw_iso_buffer_init_54582 fw_iso_buffer_init 3 54582 NULL
98927 +nvme_npages_54601 nvme_npages 0-1 54601 NULL
98928 +fwSendNullPacket_54618 fwSendNullPacket 2 54618 NULL
98929 +irq_of_parse_and_map_54646 irq_of_parse_and_map 0 54646 NULL
98930 +irq_timeout_read_54653 irq_timeout_read 3 54653 NULL
98931 +dns_resolver_read_54658 dns_resolver_read 3 54658 NULL
98932 +twl6030_interrupt_mask_54659 twl6030_interrupt_mask 2 54659 NULL
98933 +bio_kmalloc_54672 bio_kmalloc 2 54672 NULL
98934 +vring_new_virtqueue_54673 vring_new_virtqueue 2 54673 NULL
98935 +evm_read_key_54674 evm_read_key 3 54674 NULL
98936 +resource_string_54699 resource_string 0 54699 NULL
98937 +platform_get_irq_byname_54700 platform_get_irq_byname 0 54700 NULL
98938 +rfkill_fop_read_54711 rfkill_fop_read 3 54711 NULL
98939 +_add_sg_continuation_descriptor_54721 _add_sg_continuation_descriptor 3 54721 NULL
98940 +ocfs2_control_write_54737 ocfs2_control_write 3 54737 NULL
98941 +kzalloc_54740 kzalloc 1 54740 NULL
98942 +wep_iv_read_54744 wep_iv_read 3 54744 NULL
98943 +iio_event_chrdev_read_54757 iio_event_chrdev_read 3 54757 NULL
98944 +batadv_iv_ogm_aggregate_new_54761 batadv_iv_ogm_aggregate_new 2 54761 NULL
98945 +adis16480_show_firmware_date_54762 adis16480_show_firmware_date 3 54762 NULL
98946 +flexcop_device_kmalloc_54793 flexcop_device_kmalloc 1 54793 NULL
98947 +domain_init_54797 domain_init 2 54797 NULL
98948 +ext3_find_goal_54801 ext3_find_goal 0 54801 NULL
98949 +nfsd_write_54809 nfsd_write 6 54809 NULL
98950 +aes_decrypt_fail_read_54815 aes_decrypt_fail_read 3 54815 NULL nohasharray
98951 +crypto_tfm_ctx_alignment_54815 crypto_tfm_ctx_alignment 0 54815 &aes_decrypt_fail_read_54815
98952 +generic_perform_write_54832 generic_perform_write 3 54832 NULL
98953 +write_rio_54837 write_rio 3 54837 NULL
98954 +nouveau_engctx_create__54839 nouveau_engctx_create_ 8 54839 NULL nohasharray
98955 +ext3_acl_from_disk_54839 ext3_acl_from_disk 2 54839 &nouveau_engctx_create__54839
98956 +ufx_ops_write_54848 ufx_ops_write 3 54848 NULL
98957 +printer_read_54851 printer_read 3 54851 NULL
98958 +alloc_ep_req_54860 alloc_ep_req 2 54860 NULL
98959 +broadsheet_spiflash_rewrite_sector_54864 broadsheet_spiflash_rewrite_sector 2 54864 NULL
98960 +prism_build_supp_rates_54865 prism_build_supp_rates 0 54865 NULL
98961 +tcf_csum_ipv6_tcp_54877 tcf_csum_ipv6_tcp 4 54877 NULL
98962 +lm3533_led_get_lv_reg_54900 lm3533_led_get_lv_reg 0-2 54900 NULL
98963 +iscsi_pool_init_54913 iscsi_pool_init 2-4 54913 NULL
98964 +btrfs_stack_chunk_num_stripes_54923 btrfs_stack_chunk_num_stripes 0 54923 NULL
98965 +mxms_structlen_54939 mxms_structlen 0 54939 NULL
98966 +add_port_54941 add_port 2 54941 NULL
98967 +virtblk_add_buf_wait_54943 virtblk_add_buf_wait 3-4 54943 NULL
98968 +wl12xx_cmd_build_probe_req_54946 wl12xx_cmd_build_probe_req 6-8 54946 NULL
98969 +ath9k_dump_btcoex_54949 ath9k_dump_btcoex 0 54949 NULL
98970 +c4_add_card_54968 c4_add_card 3 54968 NULL
98971 +iwl_pcie_dump_fh_54975 iwl_pcie_dump_fh 0 54975 NULL
98972 +__proc_file_read_54978 __proc_file_read 3 54978 NULL
98973 +ext3_xattr_get_54989 ext3_xattr_get 0 54989 NULL
98974 +rds_ib_inc_copy_to_user_55007 rds_ib_inc_copy_to_user 3 55007 NULL
98975 +cx231xx_v4l2_read_55014 cx231xx_v4l2_read 3 55014 NULL
98976 +error_error_null_Frame_tx_start_read_55024 error_error_null_Frame_tx_start_read 3 55024 NULL
98977 +__netdev_alloc_skb_ip_align_55067 __netdev_alloc_skb_ip_align 2 55067 NULL
98978 +apei_exec_run_55075 apei_exec_run 0 55075 NULL
98979 +bitmap_storage_alloc_55077 bitmap_storage_alloc 2 55077 NULL
98980 +snd_pcm_capture_hw_avail_55086 snd_pcm_capture_hw_avail 0 55086 NULL
98981 +rxpipe_beacon_buffer_thres_host_int_trig_rx_data_read_55106 rxpipe_beacon_buffer_thres_host_int_trig_rx_data_read 3 55106 NULL
98982 +corrupt_data_55120 corrupt_data 0 55120 NULL
98983 +crypto_ahash_setkey_55134 crypto_ahash_setkey 3 55134 NULL
98984 +ocfs2_prepare_refcount_change_for_del_55137 ocfs2_prepare_refcount_change_for_del 3 55137 NULL nohasharray
98985 +filldir_55137 filldir 3 55137 &ocfs2_prepare_refcount_change_for_del_55137
98986 +ocfs2_truncate_file_55148 ocfs2_truncate_file 3 55148 NULL
98987 +ieee80211_if_read_uapsd_queues_55150 ieee80211_if_read_uapsd_queues 3 55150 NULL
98988 +mtd_get_fact_prot_info_55186 mtd_get_fact_prot_info 0 55186 NULL
98989 +sel_write_relabel_55195 sel_write_relabel 3 55195 NULL
98990 +sched_feat_write_55202 sched_feat_write 3 55202 NULL
98991 +ht40allow_map_read_55209 ht40allow_map_read 3 55209 NULL nohasharray
98992 +pcf50633_gpio_set_55209 pcf50633_gpio_set 2 55209 &ht40allow_map_read_55209
98993 +ssd1307fb_write_cmd_array_55211 ssd1307fb_write_cmd_array 3 55211 NULL nohasharray
98994 +__kfifo_dma_out_prepare_r_55211 __kfifo_dma_out_prepare_r 4-5 55211 &ssd1307fb_write_cmd_array_55211
98995 +do_raw_setsockopt_55215 do_raw_setsockopt 5 55215 NULL
98996 +dbAllocDmap_55227 dbAllocDmap 0 55227 NULL
98997 +tipc_port_reject_sections_55229 tipc_port_reject_sections 5 55229 NULL
98998 +register_unifi_sdio_55239 register_unifi_sdio 2 55239 NULL
98999 +memcpy_fromiovec_55247 memcpy_fromiovec 3 55247 NULL
99000 +ptrace_request_55288 ptrace_request 3 55288 NULL
99001 +rx_streaming_interval_read_55291 rx_streaming_interval_read 3 55291 NULL
99002 +rbd_create_rw_ops_55297 rbd_create_rw_ops 1 55297 NULL
99003 +gsm_control_modem_55303 gsm_control_modem 3 55303 NULL
99004 +__get_vm_area_node_55305 __get_vm_area_node 1 55305 NULL
99005 +vme_user_read_55338 vme_user_read 3 55338 NULL
99006 +sctp_datamsg_from_user_55342 sctp_datamsg_from_user 4 55342 NULL nohasharray
99007 +__wa_xfer_setup_sizes_55342 __wa_xfer_setup_sizes 0 55342 &sctp_datamsg_from_user_55342
99008 +acpi_system_read_event_55362 acpi_system_read_event 3 55362 NULL
99009 +__send_to_port_55383 __send_to_port 3 55383 NULL
99010 +nf_nat_ipv4_manip_pkt_55387 nf_nat_ipv4_manip_pkt 2 55387 NULL
99011 +iwl_dbgfs_plcp_delta_read_55407 iwl_dbgfs_plcp_delta_read 3 55407 NULL
99012 +alloc_skb_55439 alloc_skb 1 55439 NULL
99013 +__vxge_hw_channel_allocate_55462 __vxge_hw_channel_allocate 3 55462 NULL
99014 +isdnhdlc_decode_55466 isdnhdlc_decode 0 55466 NULL
99015 +cx23888_ir_rx_read_55473 cx23888_ir_rx_read 3 55473 NULL
99016 +batadv_unicast_push_and_fill_skb_55474 batadv_unicast_push_and_fill_skb 2 55474 NULL
99017 +snd_pcm_lib_write_55483 snd_pcm_lib_write 0-3 55483 NULL
99018 +i2o_pool_alloc_55485 i2o_pool_alloc 4 55485 NULL
99019 +wm5100_gpio_direction_out_55497 wm5100_gpio_direction_out 2 55497 NULL
99020 +ocfs2_rec_clusters_55501 ocfs2_rec_clusters 0 55501 NULL
99021 +ext4_flex_bg_size_55502 ext4_flex_bg_size 0 55502 NULL
99022 +cfpkt_pad_trail_55511 cfpkt_pad_trail 2 55511 NULL nohasharray
99023 +tx_tx_done_int_template_read_55511 tx_tx_done_int_template_read 3 55511 &cfpkt_pad_trail_55511
99024 +ea_get_55522 ea_get 0 55522 NULL
99025 +buffer_size_55534 buffer_size 0 55534 NULL
99026 +set_msr_interception_55538 set_msr_interception 2 55538 NULL
99027 +tty_port_register_device_55543 tty_port_register_device 3 55543 NULL
99028 +add_partition_55588 add_partition 2 55588 NULL
99029 +macvtap_put_user_55609 macvtap_put_user 4 55609 NULL
99030 +selinux_setprocattr_55611 selinux_setprocattr 4 55611 NULL
99031 +reiserfs_xattr_get_55628 reiserfs_xattr_get 0 55628 NULL nohasharray
99032 +pktgen_if_write_55628 pktgen_if_write 3 55628 &reiserfs_xattr_get_55628
99033 +dvb_dmxdev_set_buffer_size_55643 dvb_dmxdev_set_buffer_size 2 55643 NULL
99034 +mlx4_buddy_alloc_55647 mlx4_buddy_alloc 2 55647 NULL
99035 +xfs_bmbt_maxrecs_55649 xfs_bmbt_maxrecs 0-2 55649 NULL
99036 +ib_umad_compat_ioctl_55650 ib_umad_compat_ioctl 3 55650 NULL
99037 +cfg80211_send_rx_assoc_55651 cfg80211_send_rx_assoc 4 55651 NULL
99038 +read_oldmem_55658 read_oldmem 3 55658 NULL
99039 +lpfc_idiag_queinfo_read_55662 lpfc_idiag_queinfo_read 3 55662 NULL
99040 +il_dbgfs_tx_queue_read_55668 il_dbgfs_tx_queue_read 3 55668 NULL
99041 +get_info_55681 get_info 3 55681 NULL
99042 +arizona_gpio_direction_in_55690 arizona_gpio_direction_in 2 55690 NULL
99043 +wil_vring_alloc_skb_55703 wil_vring_alloc_skb 4 55703 NULL
99044 +__videobuf_alloc_uncached_55711 __videobuf_alloc_uncached 1 55711 NULL
99045 +pm8001_store_update_fw_55716 pm8001_store_update_fw 4 55716 NULL
99046 +mtdswap_init_55719 mtdswap_init 2 55719 NULL
99047 +__iio_allocate_kfifo_55738 __iio_allocate_kfifo 3-2 55738 NULL
99048 +set_local_name_55757 set_local_name 4 55757 NULL
99049 +btrfs_init_new_buffer_55761 btrfs_init_new_buffer 4 55761 NULL
99050 +strlen_55778 strlen 0 55778 NULL nohasharray
99051 +is_idx_node_in_tnc_55778 is_idx_node_in_tnc 0 55778 &strlen_55778
99052 +req_bio_endio_55786 req_bio_endio 3 55786 NULL nohasharray
99053 +conf_read_55786 conf_read 3 55786 &req_bio_endio_55786
99054 +uwb_rc_neh_grok_event_55799 uwb_rc_neh_grok_event 3 55799 NULL
99055 +btrfs_find_create_tree_block_55812 btrfs_find_create_tree_block 3 55812 NULL
99056 +sb16_copy_from_user_55836 sb16_copy_from_user 10-6-7 55836 NULL
99057 +ip_hdrlen_55849 ip_hdrlen 0 55849 NULL
99058 +hcd_alloc_coherent_55862 hcd_alloc_coherent 5 55862 NULL
99059 +shmem_setxattr_55867 shmem_setxattr 4 55867 NULL
99060 +hsc_write_55875 hsc_write 3 55875 NULL
99061 +pm_qos_power_read_55891 pm_qos_power_read 3 55891 NULL
99062 +snd_pcm_hw_param_value_min_55917 snd_pcm_hw_param_value_min 0 55917 NULL
99063 +sel_read_policy_55947 sel_read_policy 3 55947 NULL
99064 +handle_response_55951 handle_response 5 55951 NULL
99065 +simple_read_from_buffer_55957 simple_read_from_buffer 2-5 55957 NULL
99066 +tx_tx_imm_resp_read_55964 tx_tx_imm_resp_read 3 55964 NULL
99067 +ssb_bus_pcmciabus_register_56020 ssb_bus_pcmciabus_register 3 56020 NULL
99068 +nvme_alloc_iod_56027 nvme_alloc_iod 1-2 56027 NULL
99069 +dccp_sendmsg_56058 dccp_sendmsg 4 56058 NULL
99070 +pscsi_get_bio_56103 pscsi_get_bio 1 56103 NULL
99071 +usb_alloc_stream_buffers_56123 usb_alloc_stream_buffers 3 56123 NULL
99072 +kmem_zalloc_large_56128 kmem_zalloc_large 1 56128 NULL
99073 +sel_read_handle_status_56139 sel_read_handle_status 3 56139 NULL
99074 +map_addr_56144 map_addr 7 56144 NULL
99075 +rawv6_setsockopt_56165 rawv6_setsockopt 5 56165 NULL
99076 +create_irq_nr_56180 create_irq_nr 1 56180 NULL
99077 +ath9k_dump_legacy_btcoex_56194 ath9k_dump_legacy_btcoex 0 56194 NULL
99078 +skb_headroom_56200 skb_headroom 0 56200 NULL
99079 +usb_dump_iad_descriptor_56204 usb_dump_iad_descriptor 0 56204 NULL
99080 +ncp_read_bounce_size_56221 ncp_read_bounce_size 0-1 56221 NULL
99081 +ocfs2_find_xe_in_bucket_56224 ocfs2_find_xe_in_bucket 0 56224 NULL
99082 +cp210x_get_config_56229 cp210x_get_config 4 56229 NULL
99083 +do_ipt_set_ctl_56238 do_ipt_set_ctl 4 56238 NULL
99084 +scrub_setup_recheck_block_56245 scrub_setup_recheck_block 4-3 56245 NULL
99085 +fd_copyin_56247 fd_copyin 3 56247 NULL
99086 +sk_rmem_schedule_56255 sk_rmem_schedule 3 56255 NULL
99087 +il4965_ucode_general_stats_read_56277 il4965_ucode_general_stats_read 3 56277 NULL
99088 +ieee80211_if_fmt_user_power_level_56283 ieee80211_if_fmt_user_power_level 3 56283 NULL
99089 +RESIZE_IF_NEEDED_56286 RESIZE_IF_NEEDED 2 56286 NULL
99090 +dvb_aplay_56296 dvb_aplay 3 56296 NULL
99091 +btmrvl_hscfgcmd_read_56303 btmrvl_hscfgcmd_read 3 56303 NULL
99092 +compat_cdrom_read_audio_56304 compat_cdrom_read_audio 4 56304 NULL
99093 +pipeline_pre_to_defrag_swi_read_56321 pipeline_pre_to_defrag_swi_read 3 56321 NULL
99094 +journal_init_revoke_table_56331 journal_init_revoke_table 1 56331 NULL
99095 +snd_rawmidi_read_56337 snd_rawmidi_read 3 56337 NULL
99096 +sixpack_compat_ioctl_56346 sixpack_compat_ioctl 4 56346 NULL
99097 +vxge_os_dma_malloc_async_56348 vxge_os_dma_malloc_async 3 56348 NULL
99098 +tps80031_ext_power_req_config_56353 tps80031_ext_power_req_config 3-4-5 56353 NULL
99099 +iov_iter_copy_from_user_atomic_56368 iov_iter_copy_from_user_atomic 4 56368 NULL
99100 +dev_read_56369 dev_read 3 56369 NULL
99101 +alloc_dummy_extent_buffer_56374 alloc_dummy_extent_buffer 2 56374 NULL
99102 +snd_pcm_common_ioctl1_56382 snd_pcm_common_ioctl1 0 56382 NULL
99103 +ocfs2_control_read_56405 ocfs2_control_read 3 56405 NULL
99104 +__get_vm_area_caller_56416 __get_vm_area_caller 1 56416 NULL nohasharray
99105 +acpi_os_write_memory_56416 acpi_os_write_memory 1-3 56416 &__get_vm_area_caller_56416
99106 +store_msg_56417 store_msg 3 56417 NULL
99107 +pppol2tp_sendmsg_56420 pppol2tp_sendmsg 4 56420 NULL
99108 +ec_dbgfs_cmd_read_56431 ec_dbgfs_cmd_read 3 56431 NULL
99109 +fl_create_56435 fl_create 5 56435 NULL
99110 +gnttab_map_56439 gnttab_map 2 56439 NULL
99111 +cx231xx_init_isoc_56453 cx231xx_init_isoc 3-2 56453 NULL
99112 +set_connectable_56458 set_connectable 4 56458 NULL
99113 +osd_req_list_partition_objects_56464 osd_req_list_partition_objects 5 56464 NULL
99114 +calc_linear_pos_56472 calc_linear_pos 0-3 56472 NULL
99115 +crypto_shash_alignmask_56486 crypto_shash_alignmask 0 56486 NULL
99116 +cfg80211_connect_result_56515 cfg80211_connect_result 4-6 56515 NULL
99117 +ip_options_get_56538 ip_options_get 4 56538 NULL
99118 +ocfs2_change_extent_flag_56549 ocfs2_change_extent_flag 5 56549 NULL
99119 +alloc_apertures_56561 alloc_apertures 1 56561 NULL
99120 +rs_sta_dbgfs_stats_table_read_56573 rs_sta_dbgfs_stats_table_read 3 56573 NULL
99121 +portcntrs_2_read_56586 portcntrs_2_read 3 56586 NULL
99122 +event_filter_write_56609 event_filter_write 3 56609 NULL
99123 +gather_array_56641 gather_array 3 56641 NULL
99124 +uvc_debugfs_stats_read_56651 uvc_debugfs_stats_read 3 56651 NULL
99125 +snd_gus_dram_read_56686 snd_gus_dram_read 4 56686 NULL nohasharray
99126 +da9055_gpio_to_irq_56686 da9055_gpio_to_irq 2 56686 &snd_gus_dram_read_56686
99127 +dvb_ringbuffer_read_user_56702 dvb_ringbuffer_read_user 3 56702 NULL
99128 +sta_flags_read_56710 sta_flags_read 3 56710 NULL
99129 +ipv6_getsockopt_sticky_56711 ipv6_getsockopt_sticky 5 56711 NULL
99130 +__wa_xfer_setup_segs_56725 __wa_xfer_setup_segs 2 56725 NULL
99131 +pcpu_populate_chunk_56741 pcpu_populate_chunk 2-3 56741 NULL
99132 +drm_agp_bind_pages_56748 drm_agp_bind_pages 3 56748 NULL
99133 +btrfsic_map_block_56751 btrfsic_map_block 2 56751 NULL
99134 +alloc_iommu_56778 alloc_iommu 2-3 56778 NULL
99135 +__carl9170_rx_56784 __carl9170_rx 3 56784 NULL
99136 +do_syslog_56807 do_syslog 3 56807 NULL
99137 +mtdchar_write_56831 mtdchar_write 3 56831 NULL nohasharray
99138 +ntfs_rl_realloc_56831 ntfs_rl_realloc 3 56831 &mtdchar_write_56831
99139 +snd_rawmidi_kernel_write1_56847 snd_rawmidi_kernel_write1 4 56847 NULL
99140 +ext3_xattr_ibody_get_56880 ext3_xattr_ibody_get 0 56880 NULL
99141 +pvr2_debugifc_print_status_56890 pvr2_debugifc_print_status 3 56890 NULL
99142 +debug_debug3_read_56894 debug_debug3_read 3 56894 NULL
99143 +batadv_tt_update_changes_56895 batadv_tt_update_changes 3 56895 NULL
99144 +strcspn_56913 strcspn 0 56913 NULL
99145 +__kfifo_out_56927 __kfifo_out 0-3 56927 NULL
99146 +check_header_56930 check_header 2 56930 NULL
99147 +journal_init_revoke_56933 journal_init_revoke 2 56933 NULL
99148 +diva_get_driver_info_56967 diva_get_driver_info 0 56967 NULL
99149 +nouveau_device_create__56984 nouveau_device_create_ 6 56984 NULL
99150 +vlsi_alloc_ring_57003 vlsi_alloc_ring 3-4 57003 NULL
99151 +btrfs_super_csum_size_57004 btrfs_super_csum_size 0 57004 NULL
99152 +skb_network_offset_57043 skb_network_offset 0 57043 NULL nohasharray
99153 +ieee80211_if_fmt_state_57043 ieee80211_if_fmt_state 3 57043 &skb_network_offset_57043
99154 +bytes_to_samples_57049 bytes_to_samples 0-2 57049 NULL
99155 +xfs_buf_read_map_57053 xfs_buf_read_map 3 57053 NULL
99156 +autofs_dev_ioctl_compat_57059 autofs_dev_ioctl_compat 3 57059 NULL
99157 +cx2341x_ctrl_new_std_57061 cx2341x_ctrl_new_std 4 57061 NULL
99158 +sca3000_read_data_57064 sca3000_read_data 4 57064 NULL
99159 +pcmcia_replace_cis_57066 pcmcia_replace_cis 3 57066 NULL
99160 +sis190_try_rx_copy_57069 sis190_try_rx_copy 3 57069 NULL
99161 +tracing_set_trace_write_57096 tracing_set_trace_write 3 57096 NULL
99162 +snd_pcm_hw_params_old_user_57108 snd_pcm_hw_params_old_user 0 57108 NULL
99163 +crypto_compress_ctxsize_57109 crypto_compress_ctxsize 0 57109 NULL
99164 +sysfs_write_file_57116 sysfs_write_file 3 57116 NULL
99165 +cipso_v4_gentag_loc_57119 cipso_v4_gentag_loc 0 57119 NULL
99166 +nl80211_send_deauth_57136 nl80211_send_deauth 4 57136 NULL nohasharray
99167 +rds_ib_sub_signaled_57136 rds_ib_sub_signaled 2 57136 &nl80211_send_deauth_57136 nohasharray
99168 +ima_show_htable_value_57136 ima_show_htable_value 2 57136 &rds_ib_sub_signaled_57136
99169 +snd_sonicvibes_getdmac_57140 snd_sonicvibes_getdmac 0 57140 NULL
99170 +udl_prime_create_57159 udl_prime_create 2 57159 NULL
99171 +stk_prepare_sio_buffers_57168 stk_prepare_sio_buffers 2 57168 NULL
99172 +rx_hw_stuck_read_57179 rx_hw_stuck_read 3 57179 NULL
99173 +tt3650_ci_msg_57219 tt3650_ci_msg 4 57219 NULL
99174 +dma_fifo_alloc_57236 dma_fifo_alloc 5-3-2 57236 NULL
99175 +ieee80211_if_fmt_tsf_57249 ieee80211_if_fmt_tsf 3 57249 NULL
99176 +oprofilefs_ulong_from_user_57251 oprofilefs_ulong_from_user 3 57251 NULL
99177 +alloc_flex_gd_57259 alloc_flex_gd 1 57259 NULL
99178 +security_mmap_file_57268 security_mmap_file 0 57268 NULL
99179 +pstore_file_read_57288 pstore_file_read 3 57288 NULL
99180 +snd_pcm_read_57289 snd_pcm_read 3 57289 NULL
99181 +ath6kl_buf_alloc_57304 ath6kl_buf_alloc 1 57304 NULL
99182 +fw_file_size_57307 fw_file_size 0 57307 NULL
99183 +ftdi_elan_write_57309 ftdi_elan_write 3 57309 NULL
99184 +__mxt_write_reg_57326 __mxt_write_reg 3 57326 NULL
99185 +ocfs2_xattr_shrink_size_57328 ocfs2_xattr_shrink_size 3 57328 NULL
99186 +check_mirror_57342 check_mirror 1-2 57342 NULL nohasharray
99187 +usblp_read_57342 usblp_read 3 57342 &check_mirror_57342
99188 +print_devstats_dot11RTSFailureCount_57347 print_devstats_dot11RTSFailureCount 3 57347 NULL
99189 +tipc_bclink_stats_57372 tipc_bclink_stats 2 57372 NULL
99190 +max8997_irq_domain_map_57375 max8997_irq_domain_map 2 57375 NULL
99191 +tty_register_device_attr_57381 tty_register_device_attr 2 57381 NULL
99192 +read_file_blob_57406 read_file_blob 3 57406 NULL
99193 +enclosure_register_57412 enclosure_register 3 57412 NULL
99194 +gre_manip_pkt_57416 gre_manip_pkt 4 57416 NULL
99195 +wm831x_gpio_set_debounce_57428 wm831x_gpio_set_debounce 2 57428 NULL
99196 +compat_keyctl_instantiate_key_iov_57431 compat_keyctl_instantiate_key_iov 3 57431 NULL nohasharray
99197 +alloc_ftrace_hash_57431 alloc_ftrace_hash 1 57431 &compat_keyctl_instantiate_key_iov_57431
99198 +copy_to_user_fromio_57432 copy_to_user_fromio 3 57432 NULL
99199 +sys_pselect6_57449 sys_pselect6 1 57449 NULL
99200 +ReadReg_57453 ReadReg 0 57453 NULL
99201 +__roundup_pow_of_two_57461 __roundup_pow_of_two 0 57461 NULL
99202 +crypto_tfm_alg_blocksize_57463 crypto_tfm_alg_blocksize 0 57463 NULL nohasharray
99203 +send_midi_async_57463 send_midi_async 3 57463 &crypto_tfm_alg_blocksize_57463
99204 +sisusb_clear_vram_57466 sisusb_clear_vram 3-2 57466 NULL
99205 +ieee80211_if_read_flags_57470 ieee80211_if_read_flags 3 57470 NULL nohasharray
99206 +sep_lock_user_pages_57470 sep_lock_user_pages 2-3 57470 &ieee80211_if_read_flags_57470
99207 +ocfs2_write_cluster_57483 ocfs2_write_cluster 8-2-9 57483 NULL
99208 +bnad_debugfs_write_regwr_57500 bnad_debugfs_write_regwr 3 57500 NULL
99209 +skb_headlen_57501 skb_headlen 0 57501 NULL
99210 +ks8842_read32_57505 ks8842_read32 0 57505 NULL nohasharray
99211 +ckhdid_printf_57505 ckhdid_printf 2 57505 &ks8842_read32_57505
99212 +init_tag_map_57515 init_tag_map 3 57515 NULL
99213 +wil_read_file_ssid_57517 wil_read_file_ssid 3 57517 NULL nohasharray
99214 +il_dbgfs_force_reset_read_57517 il_dbgfs_force_reset_read 3 57517 &wil_read_file_ssid_57517
99215 +inode_permission_57531 inode_permission 0 57531 NULL
99216 +acpi_dev_get_resources_57534 acpi_dev_get_resources 0 57534 NULL nohasharray
99217 +DoC_Probe_57534 DoC_Probe 1 57534 &acpi_dev_get_resources_57534
99218 +ext4_group_first_block_no_57559 ext4_group_first_block_no 0-2 57559 NULL
99219 +snd_pcm_playback_ioctl1_57569 snd_pcm_playback_ioctl1 0 57569 NULL
99220 +lp8788_update_bits_57600 lp8788_update_bits 2 57600 NULL
99221 +wm831x_gpio_to_irq_57614 wm831x_gpio_to_irq 2 57614 NULL
99222 +sk_stream_alloc_skb_57622 sk_stream_alloc_skb 2 57622 NULL
99223 +tps65217_reg_write_57623 tps65217_reg_write 2 57623 NULL nohasharray
99224 +tx_tx_retry_template_read_57623 tx_tx_retry_template_read 3 57623 &tps65217_reg_write_57623
99225 +osdmap_set_max_osd_57630 osdmap_set_max_osd 2 57630 NULL nohasharray
99226 +sisusbcon_putcs_57630 sisusbcon_putcs 3 57630 &osdmap_set_max_osd_57630
99227 +mem_read_57631 mem_read 3 57631 NULL
99228 +tc3589x_irq_map_57639 tc3589x_irq_map 2 57639 NULL
99229 +sys_mq_timedsend_57661 sys_mq_timedsend 3 57661 NULL
99230 +r3964_write_57662 r3964_write 4 57662 NULL
99231 +proc_ns_readlink_57664 proc_ns_readlink 3 57664 NULL
99232 +__lgwrite_57669 __lgwrite 4 57669 NULL
99233 +ieee80211_MFIE_rate_len_57692 ieee80211_MFIE_rate_len 0 57692 NULL
99234 +f1x_match_to_this_node_57695 f1x_match_to_this_node 3 57695 NULL
99235 +check_prefree_segments_57702 check_prefree_segments 2 57702 NULL
99236 +i2400m_rx_stats_read_57706 i2400m_rx_stats_read 3 57706 NULL
99237 +ieee80211_if_read_dot11MeshHWMPconfirmationInterval_57722 ieee80211_if_read_dot11MeshHWMPconfirmationInterval 3 57722 NULL
99238 +compat_sys_set_mempolicy_57742 compat_sys_set_mempolicy 3 57742 NULL
99239 +ieee80211_if_fmt_dot11MeshHWMPpreqMinInterval_57762 ieee80211_if_fmt_dot11MeshHWMPpreqMinInterval 3 57762 NULL
99240 +ld2_57794 ld2 0 57794 NULL
99241 +ivtv_read_57796 ivtv_read 3 57796 NULL
99242 +generic_ptrace_peekdata_57806 generic_ptrace_peekdata 2 57806 NULL
99243 +usb_dump_config_57817 usb_dump_config 0 57817 NULL
99244 +bfad_debugfs_read_regrd_57830 bfad_debugfs_read_regrd 3 57830 NULL
99245 +copy_to_user_57835 copy_to_user 3 57835 NULL
99246 +flash_read_57843 flash_read 3 57843 NULL
99247 +xt_alloc_table_info_57903 xt_alloc_table_info 1 57903 NULL
99248 +ad5380_info_to_reg_57905 ad5380_info_to_reg 0 57905 NULL
99249 +emi26_writememory_57908 emi26_writememory 4 57908 NULL
99250 +iio_read_first_n_kfifo_57910 iio_read_first_n_kfifo 2 57910 NULL
99251 +memcg_caches_array_size_57918 memcg_caches_array_size 0-1 57918 NULL
99252 +twl_i2c_write_57923 twl_i2c_write 4-3 57923 NULL
99253 +__snd_gf1_look16_57925 __snd_gf1_look16 0 57925 NULL
99254 +sel_read_handle_unknown_57933 sel_read_handle_unknown 3 57933 NULL
99255 +key_algorithm_read_57946 key_algorithm_read 3 57946 NULL
99256 +ip_set_alloc_57953 ip_set_alloc 1 57953 NULL nohasharray
99257 +ioat3_dca_count_dca_slots_57953 ioat3_dca_count_dca_slots 0 57953 &ip_set_alloc_57953
99258 +i915_cache_sharing_write_57961 i915_cache_sharing_write 3 57961 NULL
99259 +hfc_empty_fifo_57972 hfc_empty_fifo 2 57972 NULL
99260 +rx_reset_counter_read_58001 rx_reset_counter_read 3 58001 NULL
99261 +regcache_rbtree_insert_to_block_58009 regcache_rbtree_insert_to_block 5 58009 NULL
99262 +iwl_dbgfs_ucode_rx_stats_read_58023 iwl_dbgfs_ucode_rx_stats_read 3 58023 NULL
99263 +io_playback_transfer_58030 io_playback_transfer 4 58030 NULL
99264 +mc13783_write_58033 mc13783_write 2 58033 NULL
99265 +mce_async_out_58056 mce_async_out 3 58056 NULL
99266 +ocfs2_find_leaf_58065 ocfs2_find_leaf 0 58065 NULL
99267 +dt3155_alloc_coherent_58073 dt3155_alloc_coherent 2 58073 NULL
99268 +cm4040_write_58079 cm4040_write 3 58079 NULL
99269 +udi_log_event_58105 udi_log_event 3 58105 NULL
99270 +savemem_58129 savemem 3 58129 NULL
99271 +ipv6_flowlabel_opt_58135 ipv6_flowlabel_opt 3 58135 NULL nohasharray
99272 +slhc_init_58135 slhc_init 1-2 58135 &ipv6_flowlabel_opt_58135
99273 +garmin_write_bulk_58191 garmin_write_bulk 3 58191 NULL
99274 +asix_write_cmd_58192 asix_write_cmd 5 58192 NULL
99275 +ieee80211_if_fmt_flags_58205 ieee80211_if_fmt_flags 3 58205 NULL
99276 +btrfs_mksubvol_58240 btrfs_mksubvol 3 58240 NULL
99277 +btrfsic_create_link_to_next_block_58246 btrfsic_create_link_to_next_block 4 58246 NULL
99278 +read_file_debug_58256 read_file_debug 3 58256 NULL
99279 +cfg80211_mgmt_tx_status_58266 cfg80211_mgmt_tx_status 4 58266 NULL
99280 +profile_load_58267 profile_load 3 58267 NULL
99281 +acpi_ds_build_internal_package_obj_58271 acpi_ds_build_internal_package_obj 3 58271 NULL
99282 +r100_mm_rreg_58276 r100_mm_rreg 0 58276 NULL
99283 +iscsi_decode_text_input_58292 iscsi_decode_text_input 4 58292 NULL
99284 +ieee80211_if_read_dot11MeshTTL_58307 ieee80211_if_read_dot11MeshTTL 3 58307 NULL
99285 +tx_tx_start_int_templates_read_58324 tx_tx_start_int_templates_read 3 58324 NULL
99286 +pcim_iomap_58334 pcim_iomap 3 58334 NULL
99287 +diva_init_dma_map_58336 diva_init_dma_map 3 58336 NULL
99288 +ieee80211_send_probe_req_58337 ieee80211_send_probe_req 4-6 58337 NULL
99289 +next_pidmap_58347 next_pidmap 2 58347 NULL
99290 +vmalloc_to_sg_58354 vmalloc_to_sg 2 58354 NULL
99291 +brcmf_debugfs_sdio_counter_read_58369 brcmf_debugfs_sdio_counter_read 3 58369 NULL
99292 +il_dbgfs_status_read_58388 il_dbgfs_status_read 3 58388 NULL
99293 +kvm_mmu_write_protect_pt_masked_58406 kvm_mmu_write_protect_pt_masked 3 58406 NULL
99294 +i2400m_pld_size_58415 i2400m_pld_size 0 58415 NULL
99295 +__mlx4_alloc_mtt_range_58418 __mlx4_alloc_mtt_range 2 58418 NULL
99296 +__iio_add_chan_devattr_58451 __iio_add_chan_devattr 0 58451 NULL
99297 +capabilities_read_58457 capabilities_read 3 58457 NULL
99298 +batadv_iv_ogm_aggr_packet_58462 batadv_iv_ogm_aggr_packet 3 58462 NULL
99299 +lpfc_idiag_baracc_read_58466 lpfc_idiag_baracc_read 3 58466 NULL nohasharray
99300 +compat_do_ipt_set_ctl_58466 compat_do_ipt_set_ctl 4 58466 &lpfc_idiag_baracc_read_58466
99301 +snd_gf1_read_addr_58483 snd_gf1_read_addr 0 58483 NULL
99302 +snd_rme96_capture_copy_58484 snd_rme96_capture_copy 5 58484 NULL
99303 +batadv_bla_is_backbone_gw_58488 batadv_bla_is_backbone_gw 3 58488 NULL
99304 +wm831x_reg_write_58489 wm831x_reg_write 2 58489 NULL
99305 +rndis_add_response_58544 rndis_add_response 2 58544 NULL
99306 +wep_decrypt_fail_read_58567 wep_decrypt_fail_read 3 58567 NULL
99307 +sip_sprintf_addr_port_58574 sip_sprintf_addr_port 0 58574 NULL
99308 +scnprint_mac_oui_58578 scnprint_mac_oui 3-0 58578 NULL
99309 +ea_read_inline_58589 ea_read_inline 0 58589 NULL
99310 +xip_file_read_58592 xip_file_read 3 58592 NULL
99311 +gdth_search_isa_58595 gdth_search_isa 1 58595 NULL
99312 +ebt_buf_count_58607 ebt_buf_count 0 58607 NULL
99313 +skb_copy_to_page_nocache_58624 skb_copy_to_page_nocache 6 58624 NULL
99314 +module_alloc_update_bounds_rx_58634 module_alloc_update_bounds_rx 1 58634 NULL nohasharray
99315 +efi_ioremap_58634 efi_ioremap 1-2 58634 &module_alloc_update_bounds_rx_58634
99316 +tx_tx_start_fw_gen_read_58648 tx_tx_start_fw_gen_read 3 58648 NULL
99317 +ocfs2_block_to_cluster_start_58653 ocfs2_block_to_cluster_start 2 58653 NULL
99318 +find_zero_58685 find_zero 0-1 58685 NULL nohasharray
99319 +mcs7830_set_reg_async_58685 mcs7830_set_reg_async 3 58685 &find_zero_58685
99320 +uwb_bce_print_IEs_58686 uwb_bce_print_IEs 4 58686 NULL
99321 +tps6586x_writes_58689 tps6586x_writes 3-2 58689 NULL
99322 +vmalloc_node_58700 vmalloc_node 1 58700 NULL
99323 +acpi_map_58725 acpi_map 1-2 58725 NULL
99324 +da9052_gpio_to_irq_58729 da9052_gpio_to_irq 2 58729 NULL
99325 +csum_exist_in_range_58730 csum_exist_in_range 2 58730 NULL
99326 +frames_to_bytes_58741 frames_to_bytes 0-2 58741 NULL
99327 +ieee80211_if_write_tkip_mic_test_58748 ieee80211_if_write_tkip_mic_test 3 58748 NULL
99328 +agp_allocate_memory_58761 agp_allocate_memory 2 58761 NULL
99329 +__do_config_autodelink_58763 __do_config_autodelink 3 58763 NULL
99330 +regmap_calc_reg_len_58795 regmap_calc_reg_len 0 58795 NULL
99331 +raw_send_hdrinc_58803 raw_send_hdrinc 4 58803 NULL
99332 +isku_sysfs_read_58806 isku_sysfs_read 6 58806 NULL
99333 +ep_read_58813 ep_read 3 58813 NULL
99334 +command_write_58841 command_write 3 58841 NULL
99335 +ocfs2_truncate_log_append_58850 ocfs2_truncate_log_append 3 58850 NULL
99336 +ath6kl_wmi_send_action_cmd_58860 ath6kl_wmi_send_action_cmd 7 58860 NULL
99337 +hw_write_58881 hw_write 2 58881 NULL
99338 +gs_alloc_req_58883 gs_alloc_req 2 58883 NULL
99339 +cs553x_init_one_58886 cs553x_init_one 3 58886 NULL
99340 +raw_ctl_compat_ioctl_58905 raw_ctl_compat_ioctl 3 58905 NULL
99341 +print_devstats_dot11FCSErrorCount_58919 print_devstats_dot11FCSErrorCount 3 58919 NULL
99342 +tun_chr_compat_ioctl_58921 tun_chr_compat_ioctl 3 58921 NULL
99343 +pipeline_cs_rx_packet_out_read_58926 pipeline_cs_rx_packet_out_read 3 58926 NULL
99344 +st5481_isoc_flatten_58952 st5481_isoc_flatten 0 58952 NULL
99345 +ieee80211_if_fmt_dot11MeshHWMPactivePathToRootTimeout_58965 ieee80211_if_fmt_dot11MeshHWMPactivePathToRootTimeout 3 58965 NULL
99346 +crypto_aead_ivsize_58970 crypto_aead_ivsize 0 58970 NULL
99347 +handle_rx_packet_58993 handle_rx_packet 3 58993 NULL
99348 +edac_align_ptr_59003 edac_align_ptr 0 59003 NULL
99349 +ep_write_59008 ep_write 3 59008 NULL
99350 +i915_ring_stop_write_59010 i915_ring_stop_write 3 59010 NULL
99351 +init_pci_cap_msi_perm_59033 init_pci_cap_msi_perm 2 59033 NULL
99352 +selinux_transaction_write_59038 selinux_transaction_write 3 59038 NULL
99353 +crypto_aead_reqsize_59039 crypto_aead_reqsize 0 59039 NULL
99354 +regmap_bulk_write_59049 regmap_bulk_write 4-2 59049 NULL
99355 +da9052_gpio_direction_input_59062 da9052_gpio_direction_input 2 59062 NULL
99356 +vfio_device_fops_compat_ioctl_59111 vfio_device_fops_compat_ioctl 3 59111 NULL
99357 +mmc_sd_num_wr_blocks_59112 mmc_sd_num_wr_blocks 0 59112 NULL
99358 +scsi_io_completion_59122 scsi_io_completion 2 59122 NULL
99359 +nfc_llcp_send_i_frame_59130 nfc_llcp_send_i_frame 3 59130 NULL
99360 +__iio_add_event_config_attrs_59136 __iio_add_event_config_attrs 0 59136 NULL
99361 +print_devstats_dot11RTSSuccessCount_59145 print_devstats_dot11RTSSuccessCount 3 59145 NULL nohasharray
99362 +framebuffer_alloc_59145 framebuffer_alloc 1 59145 &print_devstats_dot11RTSSuccessCount_59145
99363 +radeon_compat_ioctl_59150 radeon_compat_ioctl 2 59150 NULL
99364 +pvr2_hdw_report_clients_59152 pvr2_hdw_report_clients 3 59152 NULL
99365 +setup_window_59178 setup_window 4-2-5-7 59178 NULL
99366 +ocfs2_move_extent_59187 ocfs2_move_extent 3 59187 NULL
99367 +xfs_iext_realloc_indirect_59211 xfs_iext_realloc_indirect 2 59211 NULL
99368 +fast_rx_path_59214 fast_rx_path 3 59214 NULL
99369 +inftl_partscan_59216 inftl_partscan 0 59216 NULL
99370 +skb_transport_header_59223 skb_transport_header 0 59223 NULL
99371 +dt3155_read_59226 dt3155_read 3 59226 NULL
99372 +paging64_gpte_to_gfn_lvl_59229 paging64_gpte_to_gfn_lvl 0-1-2 59229 NULL
99373 +rbd_do_request_59239 rbd_do_request 6-7 59239 NULL
99374 +tty_prepare_flip_string_flags_59240 tty_prepare_flip_string_flags 4 59240 NULL
99375 +solo_v4l2_read_59247 solo_v4l2_read 3 59247 NULL
99376 +nla_len_59258 nla_len 0 59258 NULL
99377 +da9055_reg_update_59280 da9055_reg_update 2 59280 NULL
99378 +btrfs_insert_dir_item_59304 btrfs_insert_dir_item 4 59304 NULL
99379 +fd_copyout_59323 fd_copyout 3 59323 NULL
99380 +read_9287_modal_eeprom_59327 read_9287_modal_eeprom 3 59327 NULL
99381 +rx_defrag_in_process_called_read_59338 rx_defrag_in_process_called_read 3 59338 NULL
99382 +xfs_attrmulti_attr_set_59346 xfs_attrmulti_attr_set 4 59346 NULL
99383 +xfs_dir2_sf_entsize_59366 xfs_dir2_sf_entsize 0-2 59366 NULL
99384 +pvr2_debugifc_print_info_59380 pvr2_debugifc_print_info 3 59380 NULL
99385 +fc_frame_alloc_fill_59394 fc_frame_alloc_fill 2 59394 NULL
99386 +vxge_hw_ring_rxds_per_block_get_59425 vxge_hw_ring_rxds_per_block_get 0 59425 NULL
99387 +snd_pcm_tstamp_59431 snd_pcm_tstamp 0 59431 NULL
99388 +squashfs_read_data_59440 squashfs_read_data 6 59440 NULL
99389 +fs_path_ensure_buf_59445 fs_path_ensure_buf 2 59445 NULL
99390 +descriptor_loc_59446 descriptor_loc 3 59446 NULL
99391 +do_compat_semctl_59449 do_compat_semctl 4 59449 NULL
99392 +virtqueue_add_buf_59470 virtqueue_add_buf 3-4 59470 NULL
99393 +ib_copy_from_udata_59502 ib_copy_from_udata 3 59502 NULL
99394 +nfsd_nrpools_59503 nfsd_nrpools 0 59503 NULL
99395 +rds_pin_pages_59507 rds_pin_pages 0 59507 NULL
99396 +mpi_get_nbits_59551 mpi_get_nbits 0 59551 NULL
99397 +tunables_write_59563 tunables_write 3 59563 NULL
99398 +memdup_user_59590 memdup_user 2 59590 NULL
99399 +tps6586x_irq_get_virq_59601 tps6586x_irq_get_virq 2 59601 NULL
99400 +mem_fwlog_free_mem_blks_read_59616 mem_fwlog_free_mem_blks_read 3 59616 NULL
99401 +mtrr_write_59622 mtrr_write 3 59622 NULL
99402 +ip_vs_icmp_xmit_59624 ip_vs_icmp_xmit 4 59624 NULL
99403 +find_first_zero_bit_59636 find_first_zero_bit 0-2 59636 NULL
99404 +ubifs_setxattr_59650 ubifs_setxattr 4 59650 NULL nohasharray
99405 +hidraw_read_59650 hidraw_read 3 59650 &ubifs_setxattr_59650
99406 +v9fs_xattr_set_acl_59651 v9fs_xattr_set_acl 4 59651 NULL
99407 +__devcgroup_check_permission_59665 __devcgroup_check_permission 0 59665 NULL
99408 +alloc_dca_provider_59670 alloc_dca_provider 2 59670 NULL
99409 +wm8400_write_59675 wm8400_write 2 59675 NULL
99410 +sriov_enable_59689 sriov_enable 2 59689 NULL
99411 +mic_calc_failure_read_59700 mic_calc_failure_read 3 59700 NULL
99412 +snd_pcm_info_user_59711 snd_pcm_info_user 0 59711 NULL
99413 +prism2_info_scanresults_59729 prism2_info_scanresults 3 59729 NULL
99414 +wm8996_gpio_direction_in_59739 wm8996_gpio_direction_in 2 59739 NULL
99415 +ieee80211_if_read_fwded_unicast_59740 ieee80211_if_read_fwded_unicast 3 59740 NULL
99416 +qib_decode_7220_sdma_errs_59745 qib_decode_7220_sdma_errs 4 59745 NULL
99417 +strnlen_59746 strnlen 0 59746 NULL
99418 +sctp_manip_pkt_59749 sctp_manip_pkt 4 59749 NULL
99419 +ext3_acl_count_59754 ext3_acl_count 0-1 59754 NULL
99420 +long_retry_limit_read_59766 long_retry_limit_read 3 59766 NULL
99421 +sec_reg_update_59771 sec_reg_update 2 59771 NULL
99422 +venus_remove_59781 venus_remove 4 59781 NULL
99423 +xlog_do_recover_59789 xlog_do_recover 3 59789 NULL
99424 +ipw_write_59807 ipw_write 3 59807 NULL
99425 +rtllib_wx_set_gen_ie_59808 rtllib_wx_set_gen_ie 3 59808 NULL
99426 +scsi_init_shared_tag_map_59812 scsi_init_shared_tag_map 2 59812 NULL
99427 +ieee80211_if_read_dot11MeshHWMPmaxPREQretries_59829 ieee80211_if_read_dot11MeshHWMPmaxPREQretries 3 59829 NULL
99428 +gspca_dev_probe2_59833 gspca_dev_probe2 4 59833 NULL
99429 +fs64_to_cpu_59845 fs64_to_cpu 0 59845 NULL
99430 +tun_put_user_59849 tun_put_user 4 59849 NULL
99431 +pvr2_ioread_set_sync_key_59882 pvr2_ioread_set_sync_key 3 59882 NULL
99432 +shmem_zero_setup_59885 shmem_zero_setup 0 59885 NULL
99433 +ffs_prepare_buffer_59892 ffs_prepare_buffer 2 59892 NULL
99434 +il_dbgfs_rxon_flags_read_59950 il_dbgfs_rxon_flags_read 3 59950 NULL nohasharray
99435 +dapm_widget_power_read_file_59950 dapm_widget_power_read_file 3 59950 &il_dbgfs_rxon_flags_read_59950
99436 +il_dbgfs_missed_beacon_read_59956 il_dbgfs_missed_beacon_read 3 59956 NULL nohasharray
99437 +compat_ipmi_ioctl_59956 compat_ipmi_ioctl 3 59956 &il_dbgfs_missed_beacon_read_59956
99438 +fb_getput_cmap_59971 fb_getput_cmap 3 59971 NULL
99439 +__arch_hweight16_59975 __arch_hweight16 0 59975 NULL
99440 +osd_req_read_kern_59990 osd_req_read_kern 5 59990 NULL
99441 +ghash_async_setkey_60001 ghash_async_setkey 3 60001 NULL
99442 +rawsock_sendmsg_60010 rawsock_sendmsg 4 60010 NULL
99443 +mthca_init_cq_60011 mthca_init_cq 2 60011 NULL
99444 +register_device_60015 register_device 2-3 60015 NULL
99445 +osd_req_list_dev_partitions_60027 osd_req_list_dev_partitions 4 60027 NULL
99446 +xlog_bread_offset_60030 xlog_bread_offset 3 60030 NULL
99447 +sys_sched_getaffinity_60033 sys_sched_getaffinity 2 60033 NULL
99448 +ceph_calc_raw_layout_60035 ceph_calc_raw_layout 4 60035 NULL
99449 +bio_integrity_hw_sectors_60039 bio_integrity_hw_sectors 0-2 60039 NULL
99450 +do_ip6t_set_ctl_60040 do_ip6t_set_ctl 4 60040 NULL
99451 +vcs_size_60050 vcs_size 0 60050 NULL nohasharray
99452 +pin_2_irq_60050 pin_2_irq 0-3 60050 &vcs_size_60050
99453 +load_module_60056 load_module 2 60056 NULL nohasharray
99454 +gru_alloc_gts_60056 gru_alloc_gts 3-2 60056 &load_module_60056
99455 +compat_writev_60063 compat_writev 3 60063 NULL
99456 +ieee80211_build_probe_req_60064 ieee80211_build_probe_req 8-6 60064 NULL
99457 +c4iw_num_stags_60073 c4iw_num_stags 0 60073 NULL
99458 +mp_register_gsi_60079 mp_register_gsi 2 60079 NULL
99459 +rxrpc_kernel_send_data_60083 rxrpc_kernel_send_data 3 60083 NULL
99460 +ieee80211_if_fmt_fwded_frames_60103 ieee80211_if_fmt_fwded_frames 3 60103 NULL
99461 +ttm_bo_kmap_60118 ttm_bo_kmap 3-2 60118 NULL
99462 +jmb38x_ms_count_slots_60164 jmb38x_ms_count_slots 0 60164 NULL
99463 +init_state_60165 init_state 2 60165 NULL
99464 +sg_build_sgat_60179 sg_build_sgat 3 60179 NULL nohasharray
99465 +jffs2_alloc_full_dirent_60179 jffs2_alloc_full_dirent 1 60179 &sg_build_sgat_60179
99466 +rx_rx_tkip_replays_read_60193 rx_rx_tkip_replays_read 3 60193 NULL
99467 +svc_compat_ioctl_60194 svc_compat_ioctl 3 60194 NULL
99468 +ib_send_cm_mra_60202 ib_send_cm_mra 4 60202 NULL nohasharray
99469 +qib_reg_phys_mr_60202 qib_reg_phys_mr 3 60202 &ib_send_cm_mra_60202
99470 +set_tap_pfs_60203 set_tap_pfs 3 60203 NULL
99471 +ieee80211_mgmt_tx_60209 ieee80211_mgmt_tx 7 60209 NULL
99472 +btrfs_get_token_16_60220 btrfs_get_token_16 0 60220 NULL
99473 +arizona_map_irq_60230 arizona_map_irq 2 60230 NULL
99474 +lp8788_select_buck_vout_addr_60241 lp8788_select_buck_vout_addr 0 60241 NULL
99475 +wm831x_irq_60254 wm831x_irq 2 60254 NULL
99476 +compat_sys_fcntl64_60256 compat_sys_fcntl64 3 60256 NULL
99477 +printer_write_60276 printer_write 3 60276 NULL
99478 +__pskb_pull_tail_60287 __pskb_pull_tail 2 60287 NULL
99479 +do_xip_mapping_read_60297 do_xip_mapping_read 5 60297 NULL
99480 +getDataLength_60301 getDataLength 0 60301 NULL
99481 +ceph_parse_server_name_60318 ceph_parse_server_name 2 60318 NULL
99482 +__kfifo_from_user_r_60345 __kfifo_from_user_r 3-5 60345 NULL
99483 +dccp_setsockopt_60367 dccp_setsockopt 5 60367 NULL
99484 +ubi_eba_atomic_leb_change_60379 ubi_eba_atomic_leb_change 5 60379 NULL
99485 +mthca_alloc_resize_buf_60394 mthca_alloc_resize_buf 3 60394 NULL
99486 +ocfs2_zero_extend_60396 ocfs2_zero_extend 3 60396 NULL
99487 +driver_names_read_60399 driver_names_read 3 60399 NULL
99488 +simple_alloc_urb_60420 simple_alloc_urb 3 60420 NULL
99489 +excessive_retries_read_60425 excessive_retries_read 3 60425 NULL
99490 +tstats_write_60432 tstats_write 3 60432 NULL nohasharray
99491 +kmalloc_60432 kmalloc 1 60432 &tstats_write_60432
99492 +tipc_buf_acquire_60437 tipc_buf_acquire 1 60437 NULL
99493 +rx_data_60442 rx_data 4 60442 NULL
99494 +tcf_csum_ipv4_igmp_60446 tcf_csum_ipv4_igmp 3 60446 NULL
99495 +crypto_shash_setkey_60483 crypto_shash_setkey 3 60483 NULL
99496 +ath_tx_init_60515 ath_tx_init 2 60515 NULL
99497 +hysdn_sched_rx_60533 hysdn_sched_rx 3 60533 NULL
99498 +v9fs_fid_readn_60544 v9fs_fid_readn 4 60544 NULL
99499 +nonpaging_map_60551 nonpaging_map 4 60551 NULL
99500 +skb_transport_offset_60619 skb_transport_offset 0 60619 NULL
99501 +wl1273_fm_fops_write_60621 wl1273_fm_fops_write 3 60621 NULL
99502 +usb_control_msg_60624 usb_control_msg 0 60624 NULL
99503 +acl_alloc_stack_init_60630 acl_alloc_stack_init 1 60630 NULL
99504 +ubifs_recover_leb_60639 ubifs_recover_leb 3 60639 NULL
99505 +fb_get_fscreeninfo_60640 fb_get_fscreeninfo 3 60640 NULL
99506 +if_sdio_host_to_card_60666 if_sdio_host_to_card 4 60666 NULL
99507 +ieee80211_if_read_dot11MeshConfirmTimeout_60670 ieee80211_if_read_dot11MeshConfirmTimeout 3 60670 NULL
99508 +read_vbt_r10_60679 read_vbt_r10 1 60679 NULL
99509 +init_data_container_60709 init_data_container 1 60709 NULL
99510 +snd_ice1712_ds_read_60754 snd_ice1712_ds_read 0 60754 NULL
99511 +sel_write_checkreqprot_60774 sel_write_checkreqprot 3 60774 NULL
99512 +opticon_write_60775 opticon_write 4 60775 NULL
99513 +acl_alloc_num_60778 acl_alloc_num 1-2 60778 NULL
99514 +snd_pcm_oss_readv3_60792 snd_pcm_oss_readv3 3 60792 NULL
99515 +pwr_tx_with_ps_read_60851 pwr_tx_with_ps_read 3 60851 NULL
99516 +alloc_buf_60864 alloc_buf 3-2 60864 NULL
99517 +alloc_irq_from_60868 alloc_irq_from 1 60868 NULL
99518 +generic_writepages_60871 generic_writepages 0 60871 NULL
99519 +ubifs_read_one_lp_60882 ubifs_read_one_lp 0 60882 NULL
99520 +ext4_update_inline_data_60888 ext4_update_inline_data 3 60888 NULL
99521 +wm8962_gpio_set_60894 wm8962_gpio_set 2 60894 NULL
99522 +iio_debugfs_read_reg_60908 iio_debugfs_read_reg 3 60908 NULL
99523 +mgt_set_varlen_60916 mgt_set_varlen 4 60916 NULL
99524 +scrub_chunk_60926 scrub_chunk 5 60926 NULL
99525 +pti_char_write_60960 pti_char_write 3 60960 NULL
99526 +mwifiex_alloc_sdio_mpa_buffers_60961 mwifiex_alloc_sdio_mpa_buffers 2-3 60961 NULL
99527 +__a2mp_build_60987 __a2mp_build 3 60987 NULL
99528 +hsc_msg_alloc_60990 hsc_msg_alloc 1 60990 NULL
99529 +ath6kl_lrssi_roam_read_61022 ath6kl_lrssi_roam_read 3 61022 NULL
99530 +symtab_init_61050 symtab_init 2 61050 NULL
99531 +fuse_send_write_61053 fuse_send_write 0 61053 NULL
99532 +snd_pcm_pause_61054 snd_pcm_pause 0 61054 NULL
99533 +bitmap_scnlistprintf_61062 bitmap_scnlistprintf 0-4-2 61062 NULL
99534 +ahash_align_buffer_size_61070 ahash_align_buffer_size 0-1-2 61070 NULL
99535 +snd_pcm_update_hw_ptr0_61084 snd_pcm_update_hw_ptr0 0 61084 NULL
99536 +get_derived_key_61100 get_derived_key 4 61100 NULL
99537 +alloc_chrdev_region_61112 alloc_chrdev_region 0 61112 NULL
99538 +p80211_headerlen_61119 p80211_headerlen 0 61119 NULL nohasharray
99539 +__probe_kernel_read_61119 __probe_kernel_read 3 61119 &p80211_headerlen_61119
99540 +vmemmap_alloc_block_buf_61126 vmemmap_alloc_block_buf 1 61126 NULL
99541 +afs_proc_cells_write_61139 afs_proc_cells_write 3 61139 NULL
99542 +__vmalloc_61168 __vmalloc 1 61168 NULL
99543 +event_oom_late_read_61175 event_oom_late_read 3 61175 NULL nohasharray
99544 +pair_device_61175 pair_device 4 61175 &event_oom_late_read_61175
99545 +sys_lsetxattr_61177 sys_lsetxattr 4 61177 NULL
99546 +arch_hibernation_header_save_61212 arch_hibernation_header_save 0 61212 NULL
99547 +smk_read_ambient_61220 smk_read_ambient 3 61220 NULL
99548 +btrfs_bio_alloc_61270 btrfs_bio_alloc 3 61270 NULL
99549 +vortex_adbdma_getlinearpos_61283 vortex_adbdma_getlinearpos 0 61283 NULL
99550 +sys_add_key_61288 sys_add_key 4 61288 NULL
99551 +ext4_issue_discard_61305 ext4_issue_discard 2 61305 NULL
99552 +xfrm_user_sec_ctx_size_61320 xfrm_user_sec_ctx_size 0 61320 NULL
99553 +st5481_setup_isocpipes_61340 st5481_setup_isocpipes 6-4 61340 NULL
99554 +rx_rx_wa_ba_not_expected_read_61341 rx_rx_wa_ba_not_expected_read 3 61341 NULL
99555 +f1x_map_sysaddr_to_csrow_61344 f1x_map_sysaddr_to_csrow 2 61344 NULL
99556 +debug_debug4_read_61367 debug_debug4_read 3 61367 NULL
99557 +sys_ptrace_61369 sys_ptrace 3 61369 NULL
99558 +change_xattr_61390 change_xattr 5 61390 NULL
99559 +size_entry_mwt_61400 size_entry_mwt 0 61400 NULL
99560 +irq_create_of_mapping_61428 irq_create_of_mapping 0 61428 NULL
99561 +dma_ops_area_alloc_61440 dma_ops_area_alloc 3-4-5 61440 NULL
99562 +tc3589x_irq_unmap_61447 tc3589x_irq_unmap 2 61447 NULL
99563 +unix_stream_sendmsg_61455 unix_stream_sendmsg 4 61455 NULL
99564 +snd_pcm_lib_writev_transfer_61483 snd_pcm_lib_writev_transfer 4-2-5 61483 NULL
99565 +btrfs_item_size_61485 btrfs_item_size 0 61485 NULL
99566 +mc13xxx_reg_write_61490 mc13xxx_reg_write 2 61490 NULL
99567 +erst_errno_61526 erst_errno 0 61526 NULL
99568 +ntfs_attr_lookup_61539 ntfs_attr_lookup 0 61539 NULL
99569 +o2hb_pop_count_61553 o2hb_pop_count 2 61553 NULL
99570 +dvb_net_ioctl_61559 dvb_net_ioctl 2 61559 NULL
99571 +ieee80211_if_read_rc_rateidx_mask_2ghz_61570 ieee80211_if_read_rc_rateidx_mask_2ghz 3 61570 NULL
99572 +seq_open_private_61589 seq_open_private 3 61589 NULL
99573 +__get_vm_area_61599 __get_vm_area 1 61599 NULL
99574 +nfs4_init_uniform_client_string_61601 nfs4_init_uniform_client_string 3 61601 NULL
99575 +ncp_compat_ioctl_61608 ncp_compat_ioctl 3 61608 NULL
99576 +configfs_write_file_61621 configfs_write_file 3 61621 NULL
99577 +ieee80211_if_fmt_hw_queues_61629 ieee80211_if_fmt_hw_queues 3 61629 NULL
99578 +ieee80211_rx_bss_info_61630 ieee80211_rx_bss_info 3 61630 NULL
99579 +i2o_parm_table_get_61635 i2o_parm_table_get 6 61635 NULL
99580 +snd_pcm_oss_read3_61643 snd_pcm_oss_read3 0-3 61643 NULL
99581 +resize_stripes_61650 resize_stripes 2 61650 NULL
99582 +ttm_page_pool_free_61661 ttm_page_pool_free 2 61661 NULL
99583 +insert_one_name_61668 insert_one_name 7 61668 NULL
99584 +snd_pcm_playback_avail_61671 snd_pcm_playback_avail 0 61671 NULL
99585 +lock_loop_61681 lock_loop 1 61681 NULL
99586 +__do_tune_cpucache_61684 __do_tune_cpucache 2 61684 NULL
99587 +filter_read_61692 filter_read 3 61692 NULL
99588 +iov_length_61716 iov_length 0 61716 NULL
99589 +fragmentation_threshold_read_61718 fragmentation_threshold_read 3 61718 NULL
99590 +read_file_interrupt_61742 read_file_interrupt 3 61742 NULL nohasharray
99591 +read_file_regval_61742 read_file_regval 3 61742 &read_file_interrupt_61742
99592 +gfs2_meta_wait_61773 gfs2_meta_wait 0 61773 NULL
99593 +batadv_dat_snoop_incoming_arp_reply_61801 batadv_dat_snoop_incoming_arp_reply 3 61801 NULL
99594 +tps80031_irq_init_61830 tps80031_irq_init 3 61830 NULL
99595 +bfad_debugfs_write_regwr_61841 bfad_debugfs_write_regwr 3 61841 NULL
99596 +fs_path_prepare_for_add_61854 fs_path_prepare_for_add 2 61854 NULL
99597 +evdev_compute_buffer_size_61863 evdev_compute_buffer_size 0 61863 NULL
99598 +get_fw_name_61874 get_fw_name 3 61874 NULL
99599 +twl4030_sih_setup_61878 twl4030_sih_setup 3 61878 NULL
99600 +ieee80211_rtl_auth_challenge_61897 ieee80211_rtl_auth_challenge 3 61897 NULL
99601 +ax25_addr_size_61899 ax25_addr_size 0 61899 NULL nohasharray
99602 +cxgb4_pktgl_to_skb_61899 cxgb4_pktgl_to_skb 2 61899 &ax25_addr_size_61899
99603 +clear_refs_write_61904 clear_refs_write 3 61904 NULL
99604 +rx_filter_arp_filter_read_61914 rx_filter_arp_filter_read 3 61914 NULL
99605 +au0828_init_isoc_61917 au0828_init_isoc 3-2 61917 NULL
99606 +sctp_sendmsg_61919 sctp_sendmsg 4 61919 NULL
99607 +send_bulk_static_data_61932 send_bulk_static_data 3 61932 NULL
99608 +il4965_ucode_rx_stats_read_61948 il4965_ucode_rx_stats_read 3 61948 NULL
99609 +squashfs_read_id_index_table_61961 squashfs_read_id_index_table 4 61961 NULL
99610 +mlx4_alloc_mtt_range_61966 mlx4_alloc_mtt_range 2 61966 NULL
99611 +ocfs2_quota_write_61972 ocfs2_quota_write 5-4 61972 NULL
99612 +cow_file_range_61979 cow_file_range 3 61979 NULL
99613 +virtnet_send_command_61993 virtnet_send_command 5-6 61993 NULL
99614 +xt_compat_match_offset_62011 xt_compat_match_offset 0 62011 NULL
99615 +jffs2_do_unlink_62020 jffs2_do_unlink 4 62020 NULL
99616 +pmcraid_build_passthrough_ioadls_62034 pmcraid_build_passthrough_ioadls 2 62034 NULL
99617 +ppp_tx_cp_62044 ppp_tx_cp 5 62044 NULL
99618 +sctp_user_addto_chunk_62047 sctp_user_addto_chunk 2-3 62047 NULL
99619 +do_pselect_62061 do_pselect 1 62061 NULL
99620 +pcpu_alloc_bootmem_62074 pcpu_alloc_bootmem 2 62074 NULL
99621 +__next_gcwq_cpu_62078 __next_gcwq_cpu 1 62078 NULL
99622 +get_domain_for_dev_62099 get_domain_for_dev 2 62099 NULL
99623 +jffs2_security_setxattr_62107 jffs2_security_setxattr 4 62107 NULL
99624 +llc_ui_header_len_62131 llc_ui_header_len 0 62131 NULL
99625 +qib_diag_write_62133 qib_diag_write 3 62133 NULL
99626 +ql_status_62135 ql_status 5 62135 NULL
99627 +video_usercopy_62151 video_usercopy 2 62151 NULL
99628 +prism54_wpa_bss_ie_get_62173 prism54_wpa_bss_ie_get 0 62173 NULL
99629 +_irq_to_addr_62183 _irq_to_addr 0-1 62183 NULL
99630 +alloc_upcall_62186 alloc_upcall 2 62186 NULL
99631 +btrfs_xattr_acl_set_62203 btrfs_xattr_acl_set 4 62203 NULL
99632 +sock_kmalloc_62205 sock_kmalloc 2 62205 NULL
99633 +nfsd_read_file_62241 nfsd_read_file 6 62241 NULL
99634 +allocate_partition_62245 allocate_partition 4 62245 NULL
99635 +il_dbgfs_sram_read_62296 il_dbgfs_sram_read 3 62296 NULL
99636 +sparse_early_usemaps_alloc_pgdat_section_62304 sparse_early_usemaps_alloc_pgdat_section 2 62304 NULL
99637 +subsystem_filter_read_62310 subsystem_filter_read 3 62310 NULL
99638 +udf_sb_alloc_partition_maps_62313 udf_sb_alloc_partition_maps 2 62313 NULL
99639 +Wb35Reg_BurstWrite_62327 Wb35Reg_BurstWrite 4 62327 NULL
99640 +subseq_list_62332 subseq_list 3-0 62332 NULL
99641 +flash_write_62354 flash_write 3 62354 NULL
99642 +set_wd_exp_mode_pfs_62372 set_wd_exp_mode_pfs 3 62372 NULL
99643 +rx_rx_timeout_read_62389 rx_rx_timeout_read 3 62389 NULL
99644 +altera_irscan_62396 altera_irscan 2 62396 NULL
99645 +set_ssp_62411 set_ssp 4 62411 NULL
99646 +tscadc_writel_62426 tscadc_writel 2 62426 NULL
99647 +netdev_alloc_skb_62437 netdev_alloc_skb 2 62437 NULL
99648 +e1000_check_copybreak_62448 e1000_check_copybreak 3 62448 NULL
99649 +ip_vs_icmp_xmit_v6_62477 ip_vs_icmp_xmit_v6 4 62477 NULL
99650 +ceph_dns_resolve_name_62488 ceph_dns_resolve_name 2 62488 NULL
99651 +mlx4_en_create_rx_ring_62498 mlx4_en_create_rx_ring 3 62498 NULL
99652 +ext_rts51x_sd_execute_read_data_62501 ext_rts51x_sd_execute_read_data 9 62501 NULL
99653 +pep_sendmsg_62524 pep_sendmsg 4 62524 NULL
99654 +test_iso_queue_62534 test_iso_queue 5 62534 NULL
99655 +debugfs_read_62535 debugfs_read 3 62535 NULL
99656 +sco_sock_sendmsg_62542 sco_sock_sendmsg 4 62542 NULL
99657 +qib_refresh_qsfp_cache_62547 qib_refresh_qsfp_cache 0 62547 NULL
99658 +xfrm_user_policy_62573 xfrm_user_policy 4 62573 NULL
99659 +get_subdir_62581 get_subdir 3 62581 NULL
99660 +prism2_send_mgmt_62605 prism2_send_mgmt 4 62605 NULL nohasharray
99661 +nfsd_vfs_read_62605 nfsd_vfs_read 6 62605 &prism2_send_mgmt_62605
99662 +get_desc_base_62617 get_desc_base 0 62617 NULL
99663 +iommu_area_alloc_62619 iommu_area_alloc 2-3-4-7 62619 NULL
99664 +ems_pcmcia_add_card_62627 ems_pcmcia_add_card 2 62627 NULL
99665 +compat_rangeinfo_62630 compat_rangeinfo 2 62630 NULL
99666 +lpfc_sli4_queue_alloc_62646 lpfc_sli4_queue_alloc 3 62646 NULL
99667 +wm8994_gpio_direction_in_62649 wm8994_gpio_direction_in 2 62649 NULL
99668 +ima_file_mmap_62663 ima_file_mmap 0 62663 NULL
99669 +write_62671 write 3 62671 NULL
99670 +printer_req_alloc_62687 printer_req_alloc 2 62687 NULL
99671 +qla4_83xx_rd_reg_62693 qla4_83xx_rd_reg 0 62693 NULL
99672 +ioremap_wc_62695 ioremap_wc 1-2 62695 NULL
99673 +bioset_integrity_create_62708 bioset_integrity_create 2 62708 NULL
99674 +rdm_62719 rdm 0 62719 NULL
99675 +key_replays_read_62746 key_replays_read 3 62746 NULL
99676 +init_chip_wc_pat_62768 init_chip_wc_pat 2 62768 NULL
99677 +ax25_sendmsg_62770 ax25_sendmsg 4 62770 NULL
99678 +page_key_alloc_62771 page_key_alloc 0 62771 NULL
99679 +tracing_total_entries_read_62817 tracing_total_entries_read 3 62817 NULL
99680 +__rounddown_pow_of_two_62836 __rounddown_pow_of_two 0 62836 NULL
99681 +bio_get_nr_vecs_62838 bio_get_nr_vecs 0 62838 NULL
99682 +xlog_recover_add_to_trans_62839 xlog_recover_add_to_trans 4 62839 NULL
99683 +rx_fcs_err_read_62844 rx_fcs_err_read 3 62844 NULL
99684 +hpi_read_word_62862 hpi_read_word 0 62862 NULL
99685 +em28xx_init_isoc_62883 em28xx_init_isoc 4 62883 NULL nohasharray
99686 +aoechr_write_62883 aoechr_write 3 62883 &em28xx_init_isoc_62883
99687 +resize_info_buffer_62889 resize_info_buffer 2 62889 NULL
99688 +if_spi_host_to_card_62890 if_spi_host_to_card 4 62890 NULL
99689 +mempool_create_slab_pool_62907 mempool_create_slab_pool 1 62907 NULL
99690 +getdqbuf_62908 getdqbuf 1 62908 NULL
99691 +agp_create_user_memory_62955 agp_create_user_memory 1 62955 NULL
99692 +PTR_ERR_63033 PTR_ERR 0 63033 NULL nohasharray
99693 +__vb2_perform_fileio_63033 __vb2_perform_fileio 3 63033 &PTR_ERR_63033
99694 +pipeline_defrag_to_csum_swi_read_63037 pipeline_defrag_to_csum_swi_read 3 63037 NULL
99695 +scsi_host_alloc_63041 scsi_host_alloc 2 63041 NULL
99696 +unlink1_63059 unlink1 3 63059 NULL
99697 +xen_set_nslabs_63066 xen_set_nslabs 0 63066 NULL
99698 +ocfs2_decrease_refcount_63078 ocfs2_decrease_refcount 3 63078 NULL
99699 +sep_prepare_input_output_dma_table_in_dcb_63087 sep_prepare_input_output_dma_table_in_dcb 4-5-2-3 63087 NULL
99700 +iwl_dbgfs_sensitivity_read_63116 iwl_dbgfs_sensitivity_read 3 63116 NULL
99701 +ib_send_cm_rtu_63138 ib_send_cm_rtu 3 63138 NULL
99702 +snd_pcm_status_user_63140 snd_pcm_status_user 0 63140 NULL
99703 +ubifs_change_one_lp_63157 ubifs_change_one_lp 0 63157 NULL
99704 +smk_write_revoke_subj_63173 smk_write_revoke_subj 3 63173 NULL
99705 +vme_master_read_63221 vme_master_read 0 63221 NULL
99706 +module_alloc_update_bounds_rw_63233 module_alloc_update_bounds_rw 1 63233 NULL
99707 +ptp_read_63251 ptp_read 4 63251 NULL
99708 +ntfs_attr_can_be_non_resident_63267 ntfs_attr_can_be_non_resident 0 63267 NULL
99709 +raid5_resize_63306 raid5_resize 2 63306 NULL
99710 +proc_info_read_63344 proc_info_read 3 63344 NULL
99711 +ps_upsd_max_sptime_read_63362 ps_upsd_max_sptime_read 3 63362 NULL
99712 +idmouse_read_63374 idmouse_read 3 63374 NULL
99713 +edac_pci_alloc_ctl_info_63388 edac_pci_alloc_ctl_info 1 63388 NULL nohasharray
99714 +usbnet_read_cmd_nopm_63388 usbnet_read_cmd_nopm 7 63388 &edac_pci_alloc_ctl_info_63388
99715 +rxpipe_missed_beacon_host_int_trig_rx_data_read_63405 rxpipe_missed_beacon_host_int_trig_rx_data_read 3 63405 NULL
99716 +l2cap_sock_sendmsg_63427 l2cap_sock_sendmsg 4 63427 NULL
99717 +sep_prepare_input_output_dma_table_63429 sep_prepare_input_output_dma_table 2-4-3 63429 NULL
99718 +kone_send_63435 kone_send 4 63435 NULL
99719 +nfsd_symlink_63442 nfsd_symlink 6 63442 NULL
99720 +snd_info_entry_write_63474 snd_info_entry_write 3 63474 NULL
99721 +reada_find_extent_63486 reada_find_extent 2 63486 NULL
99722 +read_kcore_63488 read_kcore 3 63488 NULL
99723 +snd_pcm_plug_write_transfer_63503 snd_pcm_plug_write_transfer 0-3 63503 NULL
99724 +ubi_more_leb_change_data_63534 ubi_more_leb_change_data 4 63534 NULL
99725 +if_sdio_read_scratch_63540 if_sdio_read_scratch 0 63540 NULL
99726 +append_to_buffer_63550 append_to_buffer 3 63550 NULL
99727 +dbg_leb_write_63555 dbg_leb_write 4-5 63555 NULL nohasharray
99728 +kvm_write_guest_page_63555 kvm_write_guest_page 5 63555 &dbg_leb_write_63555
99729 +ubifs_lpt_scan_nolock_63572 ubifs_lpt_scan_nolock 0 63572 NULL
99730 +ocfs2_calc_trunc_pos_63576 ocfs2_calc_trunc_pos 4 63576 NULL
99731 +rproc_alloc_63577 rproc_alloc 5 63577 NULL
99732 +ext3_clear_blocks_63597 ext3_clear_blocks 4-5 63597 NULL
99733 +ntfs_malloc_nofs_nofail_63631 ntfs_malloc_nofs_nofail 1 63631 NULL
99734 +symbol_build_supp_rates_63634 symbol_build_supp_rates 0 63634 NULL
99735 +_ubh_find_next_zero_bit__63640 _ubh_find_next_zero_bit_ 4-5-3 63640 NULL
99736 +proc_loginuid_write_63648 proc_loginuid_write 3 63648 NULL
99737 +ValidateDSDParamsChecksum_63654 ValidateDSDParamsChecksum 3 63654 NULL
99738 +hidraw_ioctl_63658 hidraw_ioctl 2 63658 NULL
99739 +vbi_read_63673 vbi_read 3 63673 NULL nohasharray
99740 +xen_register_pirq_63673 xen_register_pirq 1-2 63673 &vbi_read_63673
99741 +alloc_tty_driver_63681 alloc_tty_driver 1 63681 NULL
99742 +mkiss_compat_ioctl_63686 mkiss_compat_ioctl 4 63686 NULL
99743 +arizona_irq_map_63709 arizona_irq_map 2 63709 NULL
99744 +nouveau_object_create__63715 nouveau_object_create_ 5 63715 NULL
99745 +btrfs_insert_delayed_dir_index_63720 btrfs_insert_delayed_dir_index 4 63720 NULL
99746 +selinux_secctx_to_secid_63744 selinux_secctx_to_secid 2 63744 NULL
99747 +snd_pcm_oss_read1_63771 snd_pcm_oss_read1 3 63771 NULL
99748 +snd_pcm_link_63772 snd_pcm_link 0 63772 NULL
99749 +snd_opl4_mem_proc_read_63774 snd_opl4_mem_proc_read 5 63774 NULL
99750 +spidev_compat_ioctl_63778 spidev_compat_ioctl 2-3 63778 NULL
99751 +snapshot_compat_ioctl_63792 snapshot_compat_ioctl 3 63792 NULL
99752 +kovaplus_sysfs_write_63795 kovaplus_sysfs_write 6 63795 NULL
99753 +mwifiex_11n_create_rx_reorder_tbl_63806 mwifiex_11n_create_rx_reorder_tbl 4 63806 NULL
99754 +copy_nodes_to_user_63807 copy_nodes_to_user 2 63807 NULL
99755 +sel_write_load_63830 sel_write_load 3 63830 NULL
99756 +proc_pid_attr_write_63845 proc_pid_attr_write 3 63845 NULL
99757 +ieee80211_if_fmt_channel_type_63855 ieee80211_if_fmt_channel_type 3 63855 NULL
99758 +init_map_ipmac_63896 init_map_ipmac 4-3 63896 NULL
99759 +divas_write_63901 divas_write 3 63901 NULL
99760 +xhci_alloc_stream_info_63902 xhci_alloc_stream_info 3 63902 NULL
99761 +uvc_alloc_urb_buffers_63922 uvc_alloc_urb_buffers 0-3-2 63922 NULL
99762 +snd_compr_write_63923 snd_compr_write 3 63923 NULL
99763 +acpi_ev_get_gpe_xrupt_block_63924 acpi_ev_get_gpe_xrupt_block 1 63924 NULL
99764 +tipc_send2port_63935 tipc_send2port 5 63935 NULL
99765 +afs_send_simple_reply_63940 afs_send_simple_reply 3 63940 NULL
99766 +__team_options_register_63941 __team_options_register 3 63941 NULL
99767 +macvtap_recvmsg_63949 macvtap_recvmsg 4 63949 NULL
99768 +ieee80211_if_fmt_rc_rateidx_mcs_mask_2ghz_63968 ieee80211_if_fmt_rc_rateidx_mcs_mask_2ghz 3 63968 NULL
99769 +ieee80211_authentication_req_63973 ieee80211_authentication_req 3 63973 NULL
99770 +diva_xdi_write_63975 diva_xdi_write 4 63975 NULL
99771 +read_file_frameerrors_64001 read_file_frameerrors 3 64001 NULL
99772 +kmemdup_64015 kmemdup 2 64015 NULL
99773 +tcf_csum_skb_nextlayer_64025 tcf_csum_skb_nextlayer 3 64025 NULL
99774 +dbAllocDmapLev_64030 dbAllocDmapLev 0 64030 NULL
99775 +resize_async_buffer_64031 resize_async_buffer 4 64031 NULL
99776 +sep_lli_table_secure_dma_64042 sep_lli_table_secure_dma 2-3 64042 NULL
99777 +get_u8_64076 get_u8 0 64076 NULL
99778 +sl_realloc_bufs_64086 sl_realloc_bufs 2 64086 NULL
99779 +lbs_highrssi_read_64089 lbs_highrssi_read 3 64089 NULL
99780 +do_load_xattr_datum_64118 do_load_xattr_datum 0 64118 NULL
99781 +ol_quota_entries_per_block_64122 ol_quota_entries_per_block 0 64122 NULL
99782 +ext4_prepare_inline_data_64124 ext4_prepare_inline_data 3 64124 NULL
99783 +init_bch_64130 init_bch 1-2 64130 NULL
99784 +uea_idma_write_64139 uea_idma_write 3 64139 NULL
99785 +ablkcipher_copy_iv_64140 ablkcipher_copy_iv 3 64140 NULL
99786 +dlfb_ops_write_64150 dlfb_ops_write 3 64150 NULL
99787 +cpumask_scnprintf_64170 cpumask_scnprintf 2 64170 NULL
99788 +read_pulse_64227 read_pulse 0-3 64227 NULL
99789 +header_len_64232 header_len 0 64232 NULL
99790 +redrat3_transmit_ir_64244 redrat3_transmit_ir 3 64244 NULL
99791 +io_capture_transfer_64276 io_capture_transfer 4 64276 NULL
99792 +btrfs_file_extent_offset_64278 btrfs_file_extent_offset 0 64278 NULL
99793 +sta_current_tx_rate_read_64286 sta_current_tx_rate_read 3 64286 NULL
99794 +event_id_read_64288 event_id_read 3 64288 NULL nohasharray
99795 +xfs_dir_cilookup_result_64288 xfs_dir_cilookup_result 3 64288 &event_id_read_64288
99796 +ocfs2_block_check_validate_bhs_64302 ocfs2_block_check_validate_bhs 0 64302 NULL
99797 +error_error_bar_retry_read_64305 error_error_bar_retry_read 3 64305 NULL
99798 +ffz_64324 ffz 0 64324 NULL
99799 +sisusbcon_clear_64329 sisusbcon_clear 4-3-5 64329 NULL
99800 +ts_write_64336 ts_write 3 64336 NULL
99801 +usbtmc_write_64340 usbtmc_write 3 64340 NULL
99802 +do_write_orph_node_64343 do_write_orph_node 2 64343 NULL
99803 +ft1000_read_reg_64352 ft1000_read_reg 0 64352 NULL
99804 +wlc_phy_loadsampletable_nphy_64367 wlc_phy_loadsampletable_nphy 3 64367 NULL
99805 +ilo_write_64378 ilo_write 3 64378 NULL
99806 +btrfs_map_block_64379 btrfs_map_block 3 64379 NULL
99807 +nilfs_alloc_seg_bio_64383 nilfs_alloc_seg_bio 3 64383 NULL
99808 +ir_lirc_transmit_ir_64403 ir_lirc_transmit_ir 3 64403 NULL
99809 +pidlist_allocate_64404 pidlist_allocate 1 64404 NULL
99810 +rx_hdr_overflow_read_64407 rx_hdr_overflow_read 3 64407 NULL
99811 +snd_card_create_64418 snd_card_create 4 64418 NULL nohasharray
99812 +keyctl_get_security_64418 keyctl_get_security 3 64418 &snd_card_create_64418
99813 +nl80211_send_mgmt_64419 nl80211_send_mgmt 7 64419 NULL
99814 +oom_adj_write_64428 oom_adj_write 3 64428 NULL
99815 +ext4_trim_extent_64431 ext4_trim_extent 4 64431 NULL
99816 +ieee80211_ie_build_ht_cap_64443 ieee80211_ie_build_ht_cap 0 64443 NULL
99817 +cap_capable_64462 cap_capable 0 64462 NULL
99818 +ip_vs_create_timeout_table_64478 ip_vs_create_timeout_table 2 64478 NULL
99819 +p54_parse_rssical_64493 p54_parse_rssical 3 64493 NULL
99820 +msg_data_sz_64503 msg_data_sz 0 64503 NULL
99821 +remove_uuid_64505 remove_uuid 4 64505 NULL
99822 +crypto_blkcipher_alignmask_64520 crypto_blkcipher_alignmask 0 64520 NULL
99823 +opera1_usb_i2c_msgxfer_64521 opera1_usb_i2c_msgxfer 4 64521 NULL
99824 +ses_send_diag_64527 ses_send_diag 4 64527 NULL
99825 +prctl_set_mm_64538 prctl_set_mm 3 64538 NULL
99826 +__spi_sync_64561 __spi_sync 0 64561 NULL
99827 +__apei_exec_run_64563 __apei_exec_run 0 64563 NULL
99828 +fanotify_write_64623 fanotify_write 3 64623 NULL
99829 +regmap_read_debugfs_64658 regmap_read_debugfs 5 64658 NULL
99830 +ocfs2_read_xattr_block_64661 ocfs2_read_xattr_block 0 64661 NULL nohasharray
99831 +tlbflush_read_file_64661 tlbflush_read_file 3 64661 &ocfs2_read_xattr_block_64661
99832 +efx_tsoh_get_buffer_64664 efx_tsoh_get_buffer 3 64664 NULL
99833 +rx_rx_out_of_mpdu_nodes_read_64668 rx_rx_out_of_mpdu_nodes_read 3 64668 NULL
99834 +nr_free_zone_pages_64680 nr_free_zone_pages 0 64680 NULL
99835 +sec_bulk_write_64691 sec_bulk_write 2-3 64691 NULL
99836 +__feat_register_sp_64712 __feat_register_sp 6 64712 NULL
99837 +snd_pcm_oss_capture_position_fixup_64713 snd_pcm_oss_capture_position_fixup 0 64713 NULL
99838 +dapm_bias_read_file_64715 dapm_bias_read_file 3 64715 NULL
99839 +atomic_add_return_64720 atomic_add_return 0-1 64720 NULL
99840 +i2400m_msg_to_dev_64722 i2400m_msg_to_dev 3 64722 NULL
99841 +squashfs_read_inode_lookup_table_64739 squashfs_read_inode_lookup_table 4 64739 NULL
99842 +bio_map_kern_64751 bio_map_kern 3 64751 NULL
99843 +rt2x00debug_write_csr_64753 rt2x00debug_write_csr 3 64753 NULL
99844 +isr_low_rssi_read_64789 isr_low_rssi_read 3 64789 NULL
99845 +twl6040_reg_write_64790 twl6040_reg_write 2 64790 NULL
99846 +nfsctl_transaction_write_64800 nfsctl_transaction_write 3 64800 NULL
99847 +megaraid_change_queue_depth_64815 megaraid_change_queue_depth 2 64815 NULL
99848 +ecryptfs_send_miscdev_64816 ecryptfs_send_miscdev 2 64816 NULL
99849 +do_kimage_alloc_64827 do_kimage_alloc 3 64827 NULL
99850 +altera_set_dr_pre_64862 altera_set_dr_pre 2 64862 NULL
99851 +ffs_epfile_io_64886 ffs_epfile_io 3 64886 NULL
99852 +ieee80211_if_read_ave_beacon_64924 ieee80211_if_read_ave_beacon 3 64924 NULL
99853 +ubifs_wbuf_write_nolock_64946 ubifs_wbuf_write_nolock 3 64946 NULL
99854 +snd_rawmidi_ioctl_compat_64954 snd_rawmidi_ioctl_compat 3 64954 NULL
99855 +ip_options_get_from_user_64958 ip_options_get_from_user 4 64958 NULL
99856 +acpi_os_install_interrupt_handler_64968 acpi_os_install_interrupt_handler 1 64968 NULL
99857 +traceprobe_probes_write_64969 traceprobe_probes_write 3 64969 NULL
99858 +suspend_dtim_interval_read_64971 suspend_dtim_interval_read 3 64971 NULL
99859 +ext2_group_first_block_no_64972 ext2_group_first_block_no 0-2 64972 NULL
99860 +pskb_pull_65005 pskb_pull 2 65005 NULL
99861 +unifi_write_65012 unifi_write 3 65012 NULL
99862 +crypto_ahash_digestsize_65014 crypto_ahash_digestsize 0 65014 NULL
99863 +nfs_readdata_alloc_65015 nfs_readdata_alloc 2 65015 NULL
99864 +insert_dent_65034 insert_dent 7 65034 NULL
99865 +compat_put_ushort_65040 compat_put_ushort 1 65040 NULL
99866 +brcmf_sdcard_rwdata_65041 brcmf_sdcard_rwdata 5 65041 NULL
99867 +compat_cmdtest_65064 compat_cmdtest 2 65064 NULL
99868 +make_idx_node_65068 make_idx_node 0 65068 NULL
99869 +count_run_65072 count_run 0-2-4 65072 NULL nohasharray
99870 +bnx2fc_process_l2_frame_compl_65072 bnx2fc_process_l2_frame_compl 3 65072 &count_run_65072
99871 +__alloc_bootmem_node_high_65076 __alloc_bootmem_node_high 2 65076 NULL
99872 +ocfs2_truncate_cluster_pages_65086 ocfs2_truncate_cluster_pages 2 65086 NULL
99873 +ath9k_dump_mci_btcoex_65090 ath9k_dump_mci_btcoex 0 65090 NULL
99874 +ssb_bus_register_65183 ssb_bus_register 3 65183 NULL
99875 +rx_rx_done_read_65217 rx_rx_done_read 3 65217 NULL
99876 +print_endpoint_stat_65232 print_endpoint_stat 0-4-3 65232 NULL
99877 +whci_n_caps_65247 whci_n_caps 0 65247 NULL
99878 +kmem_zalloc_greedy_65268 kmem_zalloc_greedy 3-2 65268 NULL
99879 +kmalloc_parameter_65279 kmalloc_parameter 1 65279 NULL
99880 +compat_core_sys_select_65285 compat_core_sys_select 1 65285 NULL
99881 +get_unaligned_le16_65293 get_unaligned_le16 0 65293 NULL
99882 +mpi_set_buffer_65294 mpi_set_buffer 3 65294 NULL
99883 +redirected_tty_write_65297 redirected_tty_write 3 65297 NULL
99884 +get_var_len_65304 get_var_len 0 65304 NULL
99885 +unpack_array_65318 unpack_array 0 65318 NULL
99886 +pci_vpd_find_tag_65325 pci_vpd_find_tag 0-2 65325 NULL
99887 +dccp_setsockopt_service_65336 dccp_setsockopt_service 4 65336 NULL
99888 +dma_rx_requested_read_65354 dma_rx_requested_read 3 65354 NULL
99889 +batadv_tt_save_orig_buffer_65361 batadv_tt_save_orig_buffer 4 65361 NULL
99890 +alloc_cpu_rmap_65363 alloc_cpu_rmap 1 65363 NULL
99891 +strchr_65372 strchr 0 65372 NULL
99892 +__alloc_bootmem_nopanic_65397 __alloc_bootmem_nopanic 1 65397 NULL
99893 +trace_seq_to_user_65398 trace_seq_to_user 3 65398 NULL
99894 +mtd_get_device_size_65400 mtd_get_device_size 0 65400 NULL
99895 +iio_device_add_channel_sysfs_65406 iio_device_add_channel_sysfs 0 65406 NULL
99896 +ocfs2_write_begin_nolock_65410 ocfs2_write_begin_nolock 3-4 65410 NULL
99897 +drm_calloc_large_65421 drm_calloc_large 1-2 65421 NULL
99898 +xpc_kzalloc_cacheline_aligned_65433 xpc_kzalloc_cacheline_aligned 1 65433 NULL
99899 +pn533_init_target_frame_65438 pn533_init_target_frame 3 65438 NULL
99900 +usb_alloc_coherent_65444 usb_alloc_coherent 2 65444 NULL
99901 +regmap_write_65478 regmap_write 2 65478 NULL
99902 +ath_rx_edma_init_65483 ath_rx_edma_init 2 65483 NULL
99903 +dpcm_state_read_file_65489 dpcm_state_read_file 3 65489 NULL
99904 +alloc_dr_65495 alloc_dr 2 65495 NULL
99905 diff --git a/tools/gcc/size_overflow_plugin.c b/tools/gcc/size_overflow_plugin.c
99906 new file mode 100644
99907 index 0000000..63c46e5
99908 --- /dev/null
99909 +++ b/tools/gcc/size_overflow_plugin.c
99910 @@ -0,0 +1,2050 @@
99911 +/*
99912 + * Copyright 2011, 2012 by Emese Revfy <re.emese@gmail.com>
99913 + * Licensed under the GPL v2, or (at your option) v3
99914 + *
99915 + * Homepage:
99916 + * http://www.grsecurity.net/~ephox/overflow_plugin/
99917 + *
99918 + * This plugin recomputes expressions of function arguments marked by a size_overflow attribute
99919 + * with double integer precision (DImode/TImode for 32/64 bit integer types).
99920 + * The recomputed argument is checked against TYPE_MAX and an event is logged on overflow and the triggering process is killed.
99921 + *
99922 + * Usage:
99923 + * $ 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
99924 + * $ gcc -fplugin=size_overflow_plugin.so test.c -O2
99925 + */
99926 +
99927 +#include "gcc-plugin.h"
99928 +#include "config.h"
99929 +#include "system.h"
99930 +#include "coretypes.h"
99931 +#include "tree.h"
99932 +#include "tree-pass.h"
99933 +#include "intl.h"
99934 +#include "plugin-version.h"
99935 +#include "tm.h"
99936 +#include "toplev.h"
99937 +#include "function.h"
99938 +#include "tree-flow.h"
99939 +#include "plugin.h"
99940 +#include "gimple.h"
99941 +#include "diagnostic.h"
99942 +#include "cfgloop.h"
99943 +
99944 +#if BUILDING_GCC_VERSION >= 4008
99945 +#define TODO_dump_func 0
99946 +#endif
99947 +
99948 +struct size_overflow_hash {
99949 + const struct size_overflow_hash * const next;
99950 + const char * const name;
99951 + const unsigned int param;
99952 +};
99953 +
99954 +#include "size_overflow_hash.h"
99955 +
99956 +enum mark {
99957 + MARK_NO, MARK_YES, MARK_NOT_INTENTIONAL, MARK_TURN_OFF
99958 +};
99959 +
99960 +enum err_code_conditions {
99961 + CAST_ONLY, FROM_CONST
99962 +};
99963 +
99964 +static unsigned int call_count = 0;
99965 +
99966 +#define __unused __attribute__((__unused__))
99967 +#define NAME(node) IDENTIFIER_POINTER(DECL_NAME(node))
99968 +#define NAME_LEN(node) IDENTIFIER_LENGTH(DECL_NAME(node))
99969 +#define BEFORE_STMT true
99970 +#define AFTER_STMT false
99971 +#define CREATE_NEW_VAR NULL_TREE
99972 +#define CODES_LIMIT 32
99973 +#define MAX_PARAM 31
99974 +#define MY_STMT GF_PLF_1
99975 +#define NO_CAST_CHECK GF_PLF_2
99976 +#define FROM_ARG true
99977 +#define FROM_RET false
99978 +
99979 +#if BUILDING_GCC_VERSION == 4005
99980 +#define DECL_CHAIN(NODE) (TREE_CHAIN(DECL_MINIMAL_CHECK(NODE)))
99981 +#endif
99982 +
99983 +int plugin_is_GPL_compatible;
99984 +void debug_gimple_stmt(gimple gs);
99985 +
99986 +static tree expand(struct pointer_set_t *visited, tree lhs);
99987 +static enum mark pre_expand(struct pointer_set_t *visited, bool *search_err_code, const_tree lhs);
99988 +static tree report_size_overflow_decl;
99989 +static const_tree const_char_ptr_type_node;
99990 +static unsigned int handle_function(void);
99991 +static void check_size_overflow(gimple stmt, tree size_overflow_type, tree cast_rhs, tree rhs, bool before);
99992 +static tree get_size_overflow_type(gimple stmt, const_tree node);
99993 +static tree dup_assign(struct pointer_set_t *visited, gimple oldstmt, const_tree node, tree rhs1, tree rhs2, tree __unused rhs3);
99994 +static void print_missing_msg(tree func, unsigned int argnum);
99995 +
99996 +static struct plugin_info size_overflow_plugin_info = {
99997 + .version = "20130316beta",
99998 + .help = "no-size-overflow\tturn off size overflow checking\n",
99999 +};
100000 +
100001 +static tree handle_size_overflow_attribute(tree *node, tree __unused name, tree args, int __unused flags, bool *no_add_attrs)
100002 +{
100003 + unsigned int arg_count;
100004 + enum tree_code code = TREE_CODE(*node);
100005 +
100006 + switch (code) {
100007 + case FUNCTION_DECL:
100008 + arg_count = type_num_arguments(TREE_TYPE(*node));
100009 + break;
100010 + case FUNCTION_TYPE:
100011 + case METHOD_TYPE:
100012 + arg_count = type_num_arguments(*node);
100013 + break;
100014 + default:
100015 + *no_add_attrs = true;
100016 + error("%s: %qE attribute only applies to functions", __func__, name);
100017 + return NULL_TREE;
100018 + }
100019 +
100020 + for (; args; args = TREE_CHAIN(args)) {
100021 + tree position = TREE_VALUE(args);
100022 + if (TREE_CODE(position) != INTEGER_CST || TREE_INT_CST_LOW(position) > arg_count ) {
100023 + error("%s: parameter %u is outside range.", __func__, (unsigned int)TREE_INT_CST_LOW(position));
100024 + *no_add_attrs = true;
100025 + }
100026 + }
100027 + return NULL_TREE;
100028 +}
100029 +
100030 +static const char* get_asm_name(tree node)
100031 +{
100032 + return IDENTIFIER_POINTER(DECL_ASSEMBLER_NAME(node));
100033 +}
100034 +
100035 +static tree handle_intentional_overflow_attribute(tree *node, tree __unused name, tree args, int __unused flags, bool *no_add_attrs)
100036 +{
100037 + unsigned int arg_count, arg_num;
100038 + enum tree_code code = TREE_CODE(*node);
100039 +
100040 + switch (code) {
100041 + case FUNCTION_DECL:
100042 + arg_count = type_num_arguments(TREE_TYPE(*node));
100043 + break;
100044 + case FUNCTION_TYPE:
100045 + case METHOD_TYPE:
100046 + arg_count = type_num_arguments(*node);
100047 + break;
100048 + case FIELD_DECL:
100049 + arg_num = TREE_INT_CST_LOW(TREE_VALUE(args));
100050 + if (arg_num != 0) {
100051 + *no_add_attrs = true;
100052 + error("%s: %qE attribute parameter can only be 0 in structure fields", __func__, name);
100053 + }
100054 + return NULL_TREE;
100055 + default:
100056 + *no_add_attrs = true;
100057 + error("%qE attribute only applies to functions", name);
100058 + return NULL_TREE;
100059 + }
100060 +
100061 + if (TREE_INT_CST_HIGH(TREE_VALUE(args)) != 0)
100062 + return NULL_TREE;
100063 +
100064 + for (; args; args = TREE_CHAIN(args)) {
100065 + tree position = TREE_VALUE(args);
100066 + if (TREE_CODE(position) != INTEGER_CST || TREE_INT_CST_LOW(position) > arg_count ) {
100067 + error("%s: parameter %u is outside range.", __func__, (unsigned int)TREE_INT_CST_LOW(position));
100068 + *no_add_attrs = true;
100069 + }
100070 + }
100071 + return NULL_TREE;
100072 +}
100073 +
100074 +static struct attribute_spec size_overflow_attr = {
100075 + .name = "size_overflow",
100076 + .min_length = 1,
100077 + .max_length = -1,
100078 + .decl_required = true,
100079 + .type_required = false,
100080 + .function_type_required = false,
100081 + .handler = handle_size_overflow_attribute,
100082 +#if BUILDING_GCC_VERSION >= 4007
100083 + .affects_type_identity = false
100084 +#endif
100085 +};
100086 +
100087 +static struct attribute_spec intentional_overflow_attr = {
100088 + .name = "intentional_overflow",
100089 + .min_length = 1,
100090 + .max_length = -1,
100091 + .decl_required = true,
100092 + .type_required = false,
100093 + .function_type_required = false,
100094 + .handler = handle_intentional_overflow_attribute,
100095 +#if BUILDING_GCC_VERSION >= 4007
100096 + .affects_type_identity = false
100097 +#endif
100098 +};
100099 +
100100 +static void register_attributes(void __unused *event_data, void __unused *data)
100101 +{
100102 + register_attribute(&size_overflow_attr);
100103 + register_attribute(&intentional_overflow_attr);
100104 +}
100105 +
100106 +// http://www.team5150.com/~andrew/noncryptohashzoo2~/CrapWow.html
100107 +static unsigned int CrapWow(const char *key, unsigned int len, unsigned int seed)
100108 +{
100109 +#define cwfold( a, b, lo, hi ) { p = (unsigned int)(a) * (unsigned long long)(b); lo ^= (unsigned int)p; hi ^= (unsigned int)(p >> 32); }
100110 +#define cwmixa( in ) { cwfold( in, m, k, h ); }
100111 +#define cwmixb( in ) { cwfold( in, n, h, k ); }
100112 +
100113 + unsigned int m = 0x57559429;
100114 + unsigned int n = 0x5052acdb;
100115 + const unsigned int *key4 = (const unsigned int *)key;
100116 + unsigned int h = len;
100117 + unsigned int k = len + seed + n;
100118 + unsigned long long p;
100119 +
100120 + while (len >= 8) {
100121 + cwmixb(key4[0]) cwmixa(key4[1]) key4 += 2;
100122 + len -= 8;
100123 + }
100124 + if (len >= 4) {
100125 + cwmixb(key4[0]) key4 += 1;
100126 + len -= 4;
100127 + }
100128 + if (len)
100129 + cwmixa(key4[0] & ((1 << (len * 8)) - 1 ));
100130 + cwmixb(h ^ (k + n));
100131 + return k ^ h;
100132 +
100133 +#undef cwfold
100134 +#undef cwmixa
100135 +#undef cwmixb
100136 +}
100137 +
100138 +static inline unsigned int get_hash_num(const char *fndecl, const char *tree_codes, unsigned int len, unsigned int seed)
100139 +{
100140 + unsigned int fn = CrapWow(fndecl, strlen(fndecl), seed) & 0xffff;
100141 + unsigned int codes = CrapWow(tree_codes, len, seed) & 0xffff;
100142 + return fn ^ codes;
100143 +}
100144 +
100145 +static inline tree get_original_function_decl(tree fndecl)
100146 +{
100147 + if (DECL_ABSTRACT_ORIGIN(fndecl))
100148 + return DECL_ABSTRACT_ORIGIN(fndecl);
100149 + return fndecl;
100150 +}
100151 +
100152 +static inline gimple get_def_stmt(const_tree node)
100153 +{
100154 + gcc_assert(node != NULL_TREE);
100155 + if (TREE_CODE(node) != SSA_NAME)
100156 + return NULL;
100157 + return SSA_NAME_DEF_STMT(node);
100158 +}
100159 +
100160 +static unsigned char get_tree_code(const_tree type)
100161 +{
100162 + switch (TREE_CODE(type)) {
100163 + case ARRAY_TYPE:
100164 + return 0;
100165 + case BOOLEAN_TYPE:
100166 + return 1;
100167 + case ENUMERAL_TYPE:
100168 + return 2;
100169 + case FUNCTION_TYPE:
100170 + return 3;
100171 + case INTEGER_TYPE:
100172 + return 4;
100173 + case POINTER_TYPE:
100174 + return 5;
100175 + case RECORD_TYPE:
100176 + return 6;
100177 + case UNION_TYPE:
100178 + return 7;
100179 + case VOID_TYPE:
100180 + return 8;
100181 + case REAL_TYPE:
100182 + return 9;
100183 + case VECTOR_TYPE:
100184 + return 10;
100185 + case REFERENCE_TYPE:
100186 + return 11;
100187 + case OFFSET_TYPE:
100188 + return 12;
100189 + case COMPLEX_TYPE:
100190 + return 13;
100191 + default:
100192 + debug_tree((tree)type);
100193 + gcc_unreachable();
100194 + }
100195 +}
100196 +
100197 +static size_t add_type_codes(const_tree type, unsigned char *tree_codes, size_t len)
100198 +{
100199 + gcc_assert(type != NULL_TREE);
100200 +
100201 + while (type && len < CODES_LIMIT) {
100202 + tree_codes[len] = get_tree_code(type);
100203 + len++;
100204 + type = TREE_TYPE(type);
100205 + }
100206 + return len;
100207 +}
100208 +
100209 +static unsigned int get_function_decl(const_tree fndecl, unsigned char *tree_codes)
100210 +{
100211 + const_tree arg, result, arg_field, type = TREE_TYPE(fndecl);
100212 + enum tree_code code = TREE_CODE(type);
100213 + size_t len = 0;
100214 +
100215 + gcc_assert(code == FUNCTION_TYPE || code == METHOD_TYPE);
100216 +
100217 + arg = TYPE_ARG_TYPES(type);
100218 + // skip builtins __builtin_constant_p
100219 + if (!arg && DECL_BUILT_IN(fndecl))
100220 + return 0;
100221 +
100222 + if (TREE_CODE_CLASS(code) == tcc_type)
100223 + result = type;
100224 + else
100225 + result = DECL_RESULT(fndecl);
100226 +
100227 + gcc_assert(result != NULL_TREE);
100228 + len = add_type_codes(TREE_TYPE(result), tree_codes, len);
100229 +
100230 + if (arg == NULL_TREE) {
100231 + gcc_assert(CODE_CONTAINS_STRUCT(TREE_CODE(fndecl), TS_DECL_NON_COMMON));
100232 + arg_field = DECL_ARGUMENT_FLD(fndecl);
100233 + if (arg_field == NULL_TREE)
100234 + return 0;
100235 + arg = TREE_TYPE(arg_field);
100236 + len = add_type_codes(arg, tree_codes, len);
100237 + gcc_assert(len != 0);
100238 + return len;
100239 + }
100240 +
100241 + gcc_assert(arg != NULL_TREE && TREE_CODE(arg) == TREE_LIST);
100242 + while (arg && len < CODES_LIMIT) {
100243 + len = add_type_codes(TREE_VALUE(arg), tree_codes, len);
100244 + arg = TREE_CHAIN(arg);
100245 + }
100246 +
100247 + gcc_assert(len != 0);
100248 + return len;
100249 +}
100250 +
100251 +static const struct size_overflow_hash *get_function_hash(tree fndecl)
100252 +{
100253 + unsigned int hash;
100254 + const struct size_overflow_hash *entry;
100255 + unsigned char tree_codes[CODES_LIMIT];
100256 + size_t len;
100257 + const char *func_name;
100258 +
100259 + fndecl = get_original_function_decl(fndecl);
100260 + len = get_function_decl(fndecl, tree_codes);
100261 + if (len == 0)
100262 + return NULL;
100263 +
100264 + func_name = get_asm_name(fndecl);
100265 + hash = get_hash_num(func_name, (const char*) tree_codes, len, 0);
100266 +
100267 + entry = size_overflow_hash[hash];
100268 + while (entry) {
100269 + if (!strcmp(entry->name, func_name))
100270 + return entry;
100271 + entry = entry->next;
100272 + }
100273 +
100274 + return NULL;
100275 +}
100276 +
100277 +static bool is_bool(const_tree node)
100278 +{
100279 + const_tree type;
100280 +
100281 + if (node == NULL_TREE)
100282 + return false;
100283 +
100284 + type = TREE_TYPE(node);
100285 + if (!INTEGRAL_TYPE_P(type))
100286 + return false;
100287 + if (TREE_CODE(type) == BOOLEAN_TYPE)
100288 + return true;
100289 + if (TYPE_PRECISION(type) == 1)
100290 + return true;
100291 + return false;
100292 +}
100293 +
100294 +static bool skip_types(const_tree var)
100295 +{
100296 + tree type;
100297 +
100298 + if (is_gimple_constant(var))
100299 + return true;
100300 +
100301 + switch (TREE_CODE(var)) {
100302 + case ADDR_EXPR:
100303 +#if BUILDING_GCC_VERSION >= 4006
100304 + case MEM_REF:
100305 +#endif
100306 + case ARRAY_REF:
100307 + case BIT_FIELD_REF:
100308 + case INDIRECT_REF:
100309 + case TARGET_MEM_REF:
100310 + return true;
100311 + case PARM_DECL:
100312 + case VAR_DECL:
100313 + case COMPONENT_REF:
100314 + return false;
100315 + default:
100316 + break;
100317 + }
100318 +
100319 + gcc_assert(TREE_CODE(var) == SSA_NAME);
100320 +
100321 + type = TREE_TYPE(var);
100322 + switch (TREE_CODE(type)) {
100323 + case INTEGER_TYPE:
100324 + case ENUMERAL_TYPE:
100325 + return false;
100326 + case BOOLEAN_TYPE:
100327 + return is_bool(var);
100328 + default:
100329 + break;
100330 + }
100331 +
100332 + gcc_assert(TREE_CODE(type) == POINTER_TYPE);
100333 +
100334 + type = TREE_TYPE(type);
100335 + gcc_assert(type != NULL_TREE);
100336 + switch (TREE_CODE(type)) {
100337 + case RECORD_TYPE:
100338 + case POINTER_TYPE:
100339 + case ARRAY_TYPE:
100340 + return true;
100341 + case VOID_TYPE:
100342 + case INTEGER_TYPE:
100343 + case UNION_TYPE:
100344 + return false;
100345 + default:
100346 + break;
100347 + }
100348 +
100349 + debug_tree((tree)var);
100350 + gcc_unreachable();
100351 +}
100352 +
100353 +static unsigned int find_arg_number(const_tree arg, tree func)
100354 +{
100355 + tree var;
100356 + unsigned int argnum = 1;
100357 +
100358 + if (TREE_CODE(arg) == SSA_NAME)
100359 + arg = SSA_NAME_VAR(arg);
100360 +
100361 + for (var = DECL_ARGUMENTS(func); var; var = TREE_CHAIN(var), argnum++) {
100362 + if (!operand_equal_p(arg, var, 0) && strcmp(NAME(var), NAME(arg)))
100363 + continue;
100364 + if (!skip_types(var))
100365 + return argnum;
100366 + }
100367 +
100368 + return 0;
100369 +}
100370 +
100371 +static tree create_new_var(tree type)
100372 +{
100373 + tree new_var = create_tmp_var(type, "cicus");
100374 +
100375 +#if BUILDING_GCC_VERSION <= 4007
100376 + add_referenced_var(new_var);
100377 + mark_sym_for_renaming(new_var);
100378 +#endif
100379 + return new_var;
100380 +}
100381 +
100382 +static gimple create_binary_assign(enum tree_code code, gimple stmt, tree rhs1, tree rhs2)
100383 +{
100384 + gimple assign;
100385 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
100386 + tree type = TREE_TYPE(rhs1);
100387 + tree lhs = create_new_var(type);
100388 +
100389 + gcc_assert(types_compatible_p(type, TREE_TYPE(rhs2)));
100390 + assign = gimple_build_assign_with_ops(code, lhs, rhs1, rhs2);
100391 + gimple_set_lhs(assign, make_ssa_name(lhs, assign));
100392 +
100393 + gsi_insert_before(&gsi, assign, GSI_NEW_STMT);
100394 + update_stmt(assign);
100395 + gimple_set_plf(assign, MY_STMT, true);
100396 + return assign;
100397 +}
100398 +
100399 +static tree cast_a_tree(tree type, tree var)
100400 +{
100401 + gcc_assert(type != NULL_TREE);
100402 + gcc_assert(var != NULL_TREE);
100403 + gcc_assert(fold_convertible_p(type, var));
100404 +
100405 + return fold_convert(type, var);
100406 +}
100407 +
100408 +static tree get_lhs(const_gimple stmt)
100409 +{
100410 + switch (gimple_code(stmt)) {
100411 + case GIMPLE_ASSIGN:
100412 + return gimple_get_lhs(stmt);
100413 + case GIMPLE_PHI:
100414 + return gimple_phi_result(stmt);
100415 + case GIMPLE_CALL:
100416 + return gimple_call_lhs(stmt);
100417 + default:
100418 + return NULL_TREE;
100419 + }
100420 +}
100421 +
100422 +static bool skip_cast(tree dst_type, const_tree rhs, bool force)
100423 +{
100424 + const_gimple def_stmt = get_def_stmt(rhs);
100425 +
100426 + if (force)
100427 + return false;
100428 +
100429 + if (is_gimple_constant(rhs))
100430 + return false;
100431 +
100432 + if (!def_stmt || gimple_code(def_stmt) == GIMPLE_NOP)
100433 + return false;
100434 +
100435 + if (!types_compatible_p(dst_type, TREE_TYPE(rhs)))
100436 + return false;
100437 +
100438 + // DI type can be on 32 bit (from create_assign) but overflow type stays DI
100439 + if (LONG_TYPE_SIZE == GET_MODE_BITSIZE(SImode))
100440 + return false;
100441 +
100442 + return true;
100443 +}
100444 +
100445 +static gimple build_cast_stmt(tree dst_type, tree rhs, tree lhs, gimple_stmt_iterator *gsi, bool before, bool force)
100446 +{
100447 + gimple assign, def_stmt;
100448 +
100449 + gcc_assert(dst_type != NULL_TREE && rhs != NULL_TREE);
100450 + if (gsi_end_p(*gsi) && before == AFTER_STMT)
100451 + gcc_unreachable();
100452 +
100453 + def_stmt = get_def_stmt(rhs);
100454 + if (skip_cast(dst_type, rhs, force) && gimple_plf(def_stmt, MY_STMT))
100455 + return def_stmt;
100456 +
100457 + if (lhs == CREATE_NEW_VAR)
100458 + lhs = create_new_var(dst_type);
100459 +
100460 + assign = gimple_build_assign(lhs, cast_a_tree(dst_type, rhs));
100461 +
100462 + if (!gsi_end_p(*gsi)) {
100463 + location_t loc = gimple_location(gsi_stmt(*gsi));
100464 + gimple_set_location(assign, loc);
100465 + }
100466 +
100467 + gimple_set_lhs(assign, make_ssa_name(lhs, assign));
100468 +
100469 + if (before)
100470 + gsi_insert_before(gsi, assign, GSI_NEW_STMT);
100471 + else
100472 + gsi_insert_after(gsi, assign, GSI_NEW_STMT);
100473 + update_stmt(assign);
100474 + gimple_set_plf(assign, MY_STMT, true);
100475 +
100476 + return assign;
100477 +}
100478 +
100479 +static tree cast_to_new_size_overflow_type(gimple stmt, tree rhs, tree size_overflow_type, bool before)
100480 +{
100481 + gimple_stmt_iterator gsi;
100482 + tree lhs;
100483 + const_gimple new_stmt;
100484 +
100485 + if (rhs == NULL_TREE)
100486 + return NULL_TREE;
100487 +
100488 + gsi = gsi_for_stmt(stmt);
100489 + new_stmt = build_cast_stmt(size_overflow_type, rhs, CREATE_NEW_VAR, &gsi, before, false);
100490 +
100491 + lhs = get_lhs(new_stmt);
100492 + gcc_assert(lhs != NULL_TREE);
100493 + return lhs;
100494 +}
100495 +
100496 +static tree cast_to_TI_type(gimple stmt, tree node)
100497 +{
100498 + gimple_stmt_iterator gsi;
100499 + gimple cast_stmt;
100500 + tree type = TREE_TYPE(node);
100501 +
100502 + if (types_compatible_p(type, intTI_type_node))
100503 + return node;
100504 +
100505 + gsi = gsi_for_stmt(stmt);
100506 + cast_stmt = build_cast_stmt(intTI_type_node, node, CREATE_NEW_VAR, &gsi, BEFORE_STMT, false);
100507 + return gimple_get_lhs(cast_stmt);
100508 +}
100509 +
100510 +static void check_function_hash(const_gimple stmt)
100511 +{
100512 + tree func;
100513 + const struct size_overflow_hash *hash;
100514 +
100515 + if (gimple_code(stmt) != GIMPLE_CALL)
100516 + return;
100517 +
100518 + func = gimple_call_fndecl(stmt);
100519 + //fs/xattr.c D.34222_15 = D.34219_14 (dentry_3(D), name_7(D), 0B, 0);
100520 + if (func == NULL_TREE)
100521 + return;
100522 +
100523 + hash = get_function_hash(func);
100524 + if (!hash)
100525 + print_missing_msg(func, 0);
100526 +}
100527 +
100528 +static tree create_assign(struct pointer_set_t *visited, gimple oldstmt, tree rhs1, bool before)
100529 +{
100530 + tree lhs, new_lhs;
100531 + gimple_stmt_iterator gsi;
100532 +
100533 + if (rhs1 == NULL_TREE) {
100534 + debug_gimple_stmt(oldstmt);
100535 + error("%s: rhs1 is NULL_TREE", __func__);
100536 + gcc_unreachable();
100537 + }
100538 +
100539 + switch (gimple_code(oldstmt)) {
100540 + case GIMPLE_ASM:
100541 + lhs = rhs1;
100542 + break;
100543 + case GIMPLE_CALL:
100544 + lhs = gimple_call_lhs(oldstmt);
100545 + break;
100546 + case GIMPLE_ASSIGN:
100547 + lhs = gimple_get_lhs(oldstmt);
100548 + break;
100549 + default:
100550 + debug_gimple_stmt(oldstmt);
100551 + gcc_unreachable();
100552 + }
100553 +
100554 + gsi = gsi_for_stmt(oldstmt);
100555 + pointer_set_insert(visited, oldstmt);
100556 + if (lookup_stmt_eh_lp(oldstmt) != 0) {
100557 + basic_block next_bb, cur_bb;
100558 + const_edge e;
100559 +
100560 + gcc_assert(before == false);
100561 + gcc_assert(stmt_can_throw_internal(oldstmt));
100562 + gcc_assert(gimple_code(oldstmt) == GIMPLE_CALL);
100563 + gcc_assert(!gsi_end_p(gsi));
100564 +
100565 + cur_bb = gimple_bb(oldstmt);
100566 + next_bb = cur_bb->next_bb;
100567 + e = find_edge(cur_bb, next_bb);
100568 + gcc_assert(e != NULL);
100569 + gcc_assert(e->flags & EDGE_FALLTHRU);
100570 +
100571 + gsi = gsi_after_labels(next_bb);
100572 + gcc_assert(!gsi_end_p(gsi));
100573 +
100574 + before = true;
100575 + oldstmt = gsi_stmt(gsi);
100576 + }
100577 +
100578 + new_lhs = cast_to_new_size_overflow_type(oldstmt, rhs1, get_size_overflow_type(oldstmt, lhs), before);
100579 + return new_lhs;
100580 +}
100581 +
100582 +static tree dup_assign(struct pointer_set_t *visited, gimple oldstmt, const_tree node, tree rhs1, tree rhs2, tree __unused rhs3)
100583 +{
100584 + gimple stmt;
100585 + gimple_stmt_iterator gsi;
100586 + tree size_overflow_type, new_var, lhs = gimple_get_lhs(oldstmt);
100587 +
100588 + if (gimple_plf(oldstmt, MY_STMT))
100589 + return lhs;
100590 +
100591 + if (gimple_num_ops(oldstmt) != 4 && rhs1 == NULL_TREE) {
100592 + rhs1 = gimple_assign_rhs1(oldstmt);
100593 + rhs1 = create_assign(visited, oldstmt, rhs1, BEFORE_STMT);
100594 + }
100595 + if (gimple_num_ops(oldstmt) == 3 && rhs2 == NULL_TREE) {
100596 + rhs2 = gimple_assign_rhs2(oldstmt);
100597 + rhs2 = create_assign(visited, oldstmt, rhs2, BEFORE_STMT);
100598 + }
100599 +
100600 + stmt = gimple_copy(oldstmt);
100601 + gimple_set_location(stmt, gimple_location(oldstmt));
100602 + gimple_set_plf(stmt, MY_STMT, true);
100603 +
100604 + if (gimple_assign_rhs_code(oldstmt) == WIDEN_MULT_EXPR)
100605 + gimple_assign_set_rhs_code(stmt, MULT_EXPR);
100606 +
100607 + size_overflow_type = get_size_overflow_type(oldstmt, node);
100608 +
100609 + new_var = create_new_var(size_overflow_type);
100610 + new_var = make_ssa_name(new_var, stmt);
100611 + gimple_set_lhs(stmt, new_var);
100612 +
100613 + if (rhs1 != NULL_TREE)
100614 + gimple_assign_set_rhs1(stmt, rhs1);
100615 +
100616 + if (rhs2 != NULL_TREE)
100617 + gimple_assign_set_rhs2(stmt, rhs2);
100618 +#if BUILDING_GCC_VERSION >= 4007
100619 + if (rhs3 != NULL_TREE)
100620 + gimple_assign_set_rhs3(stmt, rhs3);
100621 +#endif
100622 + gimple_set_vuse(stmt, gimple_vuse(oldstmt));
100623 + gimple_set_vdef(stmt, gimple_vdef(oldstmt));
100624 +
100625 + gsi = gsi_for_stmt(oldstmt);
100626 + gsi_insert_after(&gsi, stmt, GSI_SAME_STMT);
100627 + update_stmt(stmt);
100628 + pointer_set_insert(visited, oldstmt);
100629 + return gimple_get_lhs(stmt);
100630 +}
100631 +
100632 +static tree cast_parm_decl(tree phi_ssa_name, tree arg, tree size_overflow_type)
100633 +{
100634 + basic_block first_bb;
100635 + gimple assign;
100636 + gimple_stmt_iterator gsi;
100637 +
100638 + first_bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
100639 + gcc_assert(dom_info_available_p(CDI_DOMINATORS));
100640 + set_immediate_dominator(CDI_DOMINATORS, first_bb, ENTRY_BLOCK_PTR);
100641 +
100642 + gsi = gsi_start_bb(first_bb);
100643 + assign = build_cast_stmt(size_overflow_type, arg, phi_ssa_name, &gsi, BEFORE_STMT, false);
100644 + return gimple_get_lhs(assign);
100645 +}
100646 +
100647 +static tree use_phi_ssa_name(tree phi_ssa_name, tree new_arg)
100648 +{
100649 + gimple_stmt_iterator gsi;
100650 + const_gimple assign;
100651 + gimple def_stmt = get_def_stmt(new_arg);
100652 +
100653 + if (gimple_code(def_stmt) == GIMPLE_PHI) {
100654 + gsi = gsi_after_labels(gimple_bb(def_stmt));
100655 + assign = build_cast_stmt(TREE_TYPE(new_arg), new_arg, phi_ssa_name, &gsi, BEFORE_STMT, true);
100656 + } else {
100657 + gsi = gsi_for_stmt(def_stmt);
100658 + assign = build_cast_stmt(TREE_TYPE(new_arg), new_arg, phi_ssa_name, &gsi, AFTER_STMT, true);
100659 + }
100660 +
100661 + return gimple_get_lhs(assign);
100662 +}
100663 +
100664 +static tree cast_visited_phi_arg(tree phi_ssa_name, tree arg, tree size_overflow_type)
100665 +{
100666 + basic_block bb;
100667 + gimple_stmt_iterator gsi;
100668 + const_gimple assign, def_stmt;
100669 +
100670 + def_stmt = get_def_stmt(arg);
100671 + bb = gimple_bb(def_stmt);
100672 + gcc_assert(bb->index != 0);
100673 + gsi = gsi_after_labels(bb);
100674 +
100675 + assign = build_cast_stmt(size_overflow_type, arg, phi_ssa_name, &gsi, BEFORE_STMT, false);
100676 + return gimple_get_lhs(assign);
100677 +}
100678 +
100679 +static tree create_new_phi_arg(tree phi_ssa_name, tree new_arg, tree arg, gimple oldstmt)
100680 +{
100681 + tree size_overflow_type;
100682 + const_gimple def_stmt = get_def_stmt(arg);
100683 +
100684 + if (phi_ssa_name != NULL_TREE)
100685 + phi_ssa_name = SSA_NAME_VAR(phi_ssa_name);
100686 +
100687 + size_overflow_type = get_size_overflow_type(oldstmt, arg);
100688 +
100689 + if (new_arg != NULL_TREE) {
100690 + gcc_assert(types_compatible_p(TREE_TYPE(new_arg), size_overflow_type));
100691 + return use_phi_ssa_name(phi_ssa_name, new_arg);
100692 + }
100693 +
100694 + switch(gimple_code(def_stmt)) {
100695 + case GIMPLE_PHI:
100696 + return cast_visited_phi_arg(phi_ssa_name, arg, size_overflow_type);
100697 + case GIMPLE_NOP:
100698 + return cast_parm_decl(phi_ssa_name, arg, size_overflow_type);
100699 + default:
100700 + debug_gimple_stmt((gimple)def_stmt);
100701 + gcc_unreachable();
100702 + }
100703 +}
100704 +
100705 +static gimple overflow_create_phi_node(gimple oldstmt, tree result)
100706 +{
100707 + basic_block bb;
100708 + gimple phi;
100709 + gimple_seq seq;
100710 + gimple_stmt_iterator gsi = gsi_for_stmt(oldstmt);
100711 +
100712 + bb = gsi_bb(gsi);
100713 +
100714 + phi = create_phi_node(result, bb);
100715 + gimple_phi_set_result(phi, make_ssa_name(result, phi));
100716 + seq = phi_nodes(bb);
100717 + gsi = gsi_last(seq);
100718 + gsi_remove(&gsi, false);
100719 +
100720 + gsi = gsi_for_stmt(oldstmt);
100721 + gsi_insert_after(&gsi, phi, GSI_NEW_STMT);
100722 + gimple_set_bb(phi, bb);
100723 + gimple_set_plf(phi, MY_STMT, true);
100724 + return phi;
100725 +}
100726 +
100727 +static tree handle_phi(struct pointer_set_t *visited, tree orig_result)
100728 +{
100729 + gimple new_phi = NULL;
100730 + gimple oldstmt = get_def_stmt(orig_result);
100731 + tree phi_ssa_name = NULL_TREE;
100732 + unsigned int i;
100733 +
100734 + pointer_set_insert(visited, oldstmt);
100735 + for (i = 0; i < gimple_phi_num_args(oldstmt); i++) {
100736 + tree arg, new_arg;
100737 +
100738 + arg = gimple_phi_arg_def(oldstmt, i);
100739 +
100740 + new_arg = expand(visited, arg);
100741 + new_arg = create_new_phi_arg(phi_ssa_name, new_arg, arg, oldstmt);
100742 + if (i == 0) {
100743 + phi_ssa_name = new_arg;
100744 + new_phi = overflow_create_phi_node(oldstmt, SSA_NAME_VAR(phi_ssa_name));
100745 + }
100746 +
100747 + gcc_assert(new_phi != NULL);
100748 + add_phi_arg(new_phi, new_arg, gimple_phi_arg_edge(oldstmt, i), gimple_location(oldstmt));
100749 + }
100750 +
100751 + gcc_assert(new_phi != NULL);
100752 + update_stmt(new_phi);
100753 + return gimple_phi_result(new_phi);
100754 +}
100755 +
100756 +static tree change_assign_rhs(gimple stmt, const_tree orig_rhs, tree new_rhs)
100757 +{
100758 + const_gimple assign;
100759 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
100760 + tree origtype = TREE_TYPE(orig_rhs);
100761 +
100762 + gcc_assert(gimple_code(stmt) == GIMPLE_ASSIGN);
100763 +
100764 + assign = build_cast_stmt(origtype, new_rhs, CREATE_NEW_VAR, &gsi, BEFORE_STMT, false);
100765 + return gimple_get_lhs(assign);
100766 +}
100767 +
100768 +static bool is_a_cast_and_const_overflow(const_tree no_const_rhs)
100769 +{
100770 + const_tree rhs1, lhs, rhs1_type, lhs_type;
100771 + enum machine_mode lhs_mode, rhs_mode;
100772 + gimple def_stmt = get_def_stmt(no_const_rhs);
100773 +
100774 + if (!gimple_assign_cast_p(def_stmt))
100775 + return false;
100776 +
100777 + rhs1 = gimple_assign_rhs1(def_stmt);
100778 + lhs = gimple_get_lhs(def_stmt);
100779 + rhs1_type = TREE_TYPE(rhs1);
100780 + lhs_type = TREE_TYPE(lhs);
100781 + rhs_mode = TYPE_MODE(rhs1_type);
100782 + lhs_mode = TYPE_MODE(lhs_type);
100783 + if (TYPE_UNSIGNED(lhs_type) == TYPE_UNSIGNED(rhs1_type) || lhs_mode != rhs_mode)
100784 + return false;
100785 +
100786 + return true;
100787 +}
100788 +
100789 +static tree create_cast_assign(struct pointer_set_t *visited, gimple stmt)
100790 +{
100791 + tree rhs1 = gimple_assign_rhs1(stmt);
100792 + tree lhs = gimple_get_lhs(stmt);
100793 + const_tree rhs1_type = TREE_TYPE(rhs1);
100794 + const_tree lhs_type = TREE_TYPE(lhs);
100795 +
100796 + if (TYPE_UNSIGNED(rhs1_type) == TYPE_UNSIGNED(lhs_type))
100797 + return create_assign(visited, stmt, lhs, AFTER_STMT);
100798 +
100799 + return create_assign(visited, stmt, rhs1, AFTER_STMT);
100800 +}
100801 +
100802 +static bool skip_lhs_cast_check(const_gimple stmt)
100803 +{
100804 + const_tree rhs = gimple_assign_rhs1(stmt);
100805 + const_gimple def_stmt = get_def_stmt(rhs);
100806 +
100807 + // 3.8.2 kernel/futex_compat.c compat_exit_robust_list(): get_user() 64 ulong -> int (compat_long_t), int max
100808 + if (gimple_code(def_stmt) == GIMPLE_ASM)
100809 + return true;
100810 +
100811 + return false;
100812 +}
100813 +
100814 +static tree create_cast_overflow_check(struct pointer_set_t *visited, tree new_rhs1, gimple stmt)
100815 +{
100816 + bool cast_lhs, cast_rhs;
100817 + tree lhs = gimple_get_lhs(stmt);
100818 + tree rhs = gimple_assign_rhs1(stmt);
100819 + const_tree lhs_type = TREE_TYPE(lhs);
100820 + const_tree rhs_type = TREE_TYPE(rhs);
100821 + enum machine_mode lhs_mode = TYPE_MODE(lhs_type);
100822 + enum machine_mode rhs_mode = TYPE_MODE(rhs_type);
100823 + unsigned int lhs_size = GET_MODE_BITSIZE(lhs_mode);
100824 + unsigned int rhs_size = GET_MODE_BITSIZE(rhs_mode);
100825 +
100826 + static bool check_lhs[3][4] = {
100827 + // ss su us uu
100828 + { false, true, true, false }, // lhs > rhs
100829 + { false, false, false, false }, // lhs = rhs
100830 + { true, true, true, true }, // lhs < rhs
100831 + };
100832 +
100833 + static bool check_rhs[3][4] = {
100834 + // ss su us uu
100835 + { true, false, true, true }, // lhs > rhs
100836 + { true, false, true, true }, // lhs = rhs
100837 + { true, false, true, true }, // lhs < rhs
100838 + };
100839 +
100840 + // skip lhs check on signed SI -> HI cast or signed SI -> QI cast !!!!
100841 + if (rhs_mode == SImode && !TYPE_UNSIGNED(rhs_type) && (lhs_mode == HImode || lhs_mode == QImode))
100842 + return create_assign(visited, stmt, lhs, AFTER_STMT);
100843 +
100844 + if (lhs_size > rhs_size) {
100845 + cast_lhs = check_lhs[0][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
100846 + cast_rhs = check_rhs[0][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
100847 + } else if (lhs_size == rhs_size) {
100848 + cast_lhs = check_lhs[1][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
100849 + cast_rhs = check_rhs[1][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
100850 + } else {
100851 + cast_lhs = check_lhs[2][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
100852 + cast_rhs = check_rhs[2][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
100853 + }
100854 +
100855 + if (!cast_lhs && !cast_rhs)
100856 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
100857 +
100858 + if (cast_lhs && !skip_lhs_cast_check(stmt))
100859 + check_size_overflow(stmt, TREE_TYPE(new_rhs1), new_rhs1, lhs, BEFORE_STMT);
100860 +
100861 + if (cast_rhs)
100862 + check_size_overflow(stmt, TREE_TYPE(new_rhs1), new_rhs1, rhs, BEFORE_STMT);
100863 +
100864 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
100865 +}
100866 +
100867 +static tree handle_unary_rhs(struct pointer_set_t *visited, gimple stmt)
100868 +{
100869 + tree rhs1, new_rhs1, lhs = gimple_get_lhs(stmt);
100870 +
100871 + if (gimple_plf(stmt, MY_STMT))
100872 + return lhs;
100873 +
100874 + rhs1 = gimple_assign_rhs1(stmt);
100875 + if (TREE_CODE(TREE_TYPE(rhs1)) == POINTER_TYPE)
100876 + return create_assign(visited, stmt, lhs, AFTER_STMT);
100877 +
100878 + new_rhs1 = expand(visited, rhs1);
100879 +
100880 + if (new_rhs1 == NULL_TREE)
100881 + return create_cast_assign(visited, stmt);
100882 +
100883 + if (gimple_plf(stmt, NO_CAST_CHECK))
100884 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
100885 +
100886 + if (gimple_assign_rhs_code(stmt) == BIT_NOT_EXPR) {
100887 + tree size_overflow_type = get_size_overflow_type(stmt, rhs1);
100888 +
100889 + new_rhs1 = cast_to_new_size_overflow_type(stmt, new_rhs1, size_overflow_type, BEFORE_STMT);
100890 + check_size_overflow(stmt, size_overflow_type, new_rhs1, rhs1, BEFORE_STMT);
100891 + return create_assign(visited, stmt, lhs, AFTER_STMT);
100892 + }
100893 +
100894 + if (!gimple_assign_cast_p(stmt))
100895 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
100896 +
100897 + return create_cast_overflow_check(visited, new_rhs1, stmt);
100898 +}
100899 +
100900 +static tree handle_unary_ops(struct pointer_set_t *visited, gimple stmt)
100901 +{
100902 + tree rhs1, lhs = gimple_get_lhs(stmt);
100903 + gimple def_stmt = get_def_stmt(lhs);
100904 +
100905 + gcc_assert(gimple_code(def_stmt) != GIMPLE_NOP);
100906 + rhs1 = gimple_assign_rhs1(def_stmt);
100907 +
100908 + if (is_gimple_constant(rhs1))
100909 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
100910 +
100911 + switch (TREE_CODE(rhs1)) {
100912 + case SSA_NAME:
100913 + return handle_unary_rhs(visited, def_stmt);
100914 + case ARRAY_REF:
100915 + case BIT_FIELD_REF:
100916 + case ADDR_EXPR:
100917 + case COMPONENT_REF:
100918 + case INDIRECT_REF:
100919 +#if BUILDING_GCC_VERSION >= 4006
100920 + case MEM_REF:
100921 +#endif
100922 + case TARGET_MEM_REF:
100923 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
100924 + case PARM_DECL:
100925 + case VAR_DECL:
100926 + return create_assign(visited, stmt, lhs, AFTER_STMT);
100927 +
100928 + default:
100929 + debug_gimple_stmt(def_stmt);
100930 + debug_tree(rhs1);
100931 + gcc_unreachable();
100932 + }
100933 +}
100934 +
100935 +static void insert_cond(basic_block cond_bb, tree arg, enum tree_code cond_code, tree type_value)
100936 +{
100937 + gimple cond_stmt;
100938 + gimple_stmt_iterator gsi = gsi_last_bb(cond_bb);
100939 +
100940 + cond_stmt = gimple_build_cond(cond_code, arg, type_value, NULL_TREE, NULL_TREE);
100941 + gsi_insert_after(&gsi, cond_stmt, GSI_CONTINUE_LINKING);
100942 + update_stmt(cond_stmt);
100943 +}
100944 +
100945 +static tree create_string_param(tree string)
100946 +{
100947 + tree i_type, a_type;
100948 + const int length = TREE_STRING_LENGTH(string);
100949 +
100950 + gcc_assert(length > 0);
100951 +
100952 + i_type = build_index_type(build_int_cst(NULL_TREE, length - 1));
100953 + a_type = build_array_type(char_type_node, i_type);
100954 +
100955 + TREE_TYPE(string) = a_type;
100956 + TREE_CONSTANT(string) = 1;
100957 + TREE_READONLY(string) = 1;
100958 +
100959 + return build1(ADDR_EXPR, ptr_type_node, string);
100960 +}
100961 +
100962 +static void insert_cond_result(basic_block bb_true, const_gimple stmt, const_tree arg, bool min)
100963 +{
100964 + gimple func_stmt;
100965 + const_gimple def_stmt;
100966 + const_tree loc_line;
100967 + tree loc_file, ssa_name, current_func;
100968 + expanded_location xloc;
100969 + char *ssa_name_buf;
100970 + int len;
100971 + gimple_stmt_iterator gsi = gsi_start_bb(bb_true);
100972 +
100973 + def_stmt = get_def_stmt(arg);
100974 + xloc = expand_location(gimple_location(def_stmt));
100975 +
100976 + if (!gimple_has_location(def_stmt)) {
100977 + xloc = expand_location(gimple_location(stmt));
100978 + if (!gimple_has_location(stmt))
100979 + xloc = expand_location(DECL_SOURCE_LOCATION(current_function_decl));
100980 + }
100981 +
100982 + loc_line = build_int_cstu(unsigned_type_node, xloc.line);
100983 +
100984 + loc_file = build_string(strlen(xloc.file) + 1, xloc.file);
100985 + loc_file = create_string_param(loc_file);
100986 +
100987 + current_func = build_string(NAME_LEN(current_function_decl) + 1, NAME(current_function_decl));
100988 + current_func = create_string_param(current_func);
100989 +
100990 + gcc_assert(DECL_NAME(SSA_NAME_VAR(arg)) != NULL);
100991 + call_count++;
100992 + 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);
100993 + gcc_assert(len > 0);
100994 + ssa_name = build_string(len + 1, ssa_name_buf);
100995 + free(ssa_name_buf);
100996 + ssa_name = create_string_param(ssa_name);
100997 +
100998 + // void report_size_overflow(const char *file, unsigned int line, const char *func, const char *ssa_name)
100999 + func_stmt = gimple_build_call(report_size_overflow_decl, 4, loc_file, loc_line, current_func, ssa_name);
101000 +
101001 + gsi_insert_after(&gsi, func_stmt, GSI_CONTINUE_LINKING);
101002 +}
101003 +
101004 +static void __unused print_the_code_insertions(const_gimple stmt)
101005 +{
101006 + location_t loc = gimple_location(stmt);
101007 +
101008 + inform(loc, "Integer size_overflow check applied here.");
101009 +}
101010 +
101011 +static void insert_check_size_overflow(gimple stmt, enum tree_code cond_code, tree arg, tree type_value, bool before, bool min)
101012 +{
101013 + basic_block cond_bb, join_bb, bb_true;
101014 + edge e;
101015 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
101016 +
101017 + cond_bb = gimple_bb(stmt);
101018 + if (before)
101019 + gsi_prev(&gsi);
101020 + if (gsi_end_p(gsi))
101021 + e = split_block_after_labels(cond_bb);
101022 + else
101023 + e = split_block(cond_bb, gsi_stmt(gsi));
101024 + cond_bb = e->src;
101025 + join_bb = e->dest;
101026 + e->flags = EDGE_FALSE_VALUE;
101027 + e->probability = REG_BR_PROB_BASE;
101028 +
101029 + bb_true = create_empty_bb(cond_bb);
101030 + make_edge(cond_bb, bb_true, EDGE_TRUE_VALUE);
101031 + make_edge(cond_bb, join_bb, EDGE_FALSE_VALUE);
101032 + make_edge(bb_true, join_bb, EDGE_FALLTHRU);
101033 +
101034 + gcc_assert(dom_info_available_p(CDI_DOMINATORS));
101035 + set_immediate_dominator(CDI_DOMINATORS, bb_true, cond_bb);
101036 + set_immediate_dominator(CDI_DOMINATORS, join_bb, cond_bb);
101037 +
101038 + if (current_loops != NULL) {
101039 + gcc_assert(cond_bb->loop_father == join_bb->loop_father);
101040 + add_bb_to_loop(bb_true, cond_bb->loop_father);
101041 + }
101042 +
101043 + insert_cond(cond_bb, arg, cond_code, type_value);
101044 + insert_cond_result(bb_true, stmt, arg, min);
101045 +
101046 +// print_the_code_insertions(stmt);
101047 +}
101048 +
101049 +static void check_size_overflow(gimple stmt, tree size_overflow_type, tree cast_rhs, tree rhs, bool before)
101050 +{
101051 + const_tree rhs_type = TREE_TYPE(rhs);
101052 + tree cast_rhs_type, type_max_type, type_min_type, type_max, type_min;
101053 +
101054 + gcc_assert(rhs_type != NULL_TREE);
101055 + if (TREE_CODE(rhs_type) == POINTER_TYPE)
101056 + return;
101057 +
101058 + gcc_assert(TREE_CODE(rhs_type) == INTEGER_TYPE || TREE_CODE(rhs_type) == ENUMERAL_TYPE);
101059 +
101060 + type_max = cast_a_tree(size_overflow_type, TYPE_MAX_VALUE(rhs_type));
101061 + // typemax (-1) < typemin (0)
101062 + if (TREE_OVERFLOW(type_max))
101063 + return;
101064 +
101065 + type_min = cast_a_tree(size_overflow_type, TYPE_MIN_VALUE(rhs_type));
101066 +
101067 + cast_rhs_type = TREE_TYPE(cast_rhs);
101068 + type_max_type = TREE_TYPE(type_max);
101069 + type_min_type = TREE_TYPE(type_min);
101070 + gcc_assert(types_compatible_p(cast_rhs_type, type_max_type));
101071 + gcc_assert(types_compatible_p(type_max_type, type_min_type));
101072 +
101073 + insert_check_size_overflow(stmt, GT_EXPR, cast_rhs, type_max, before, false);
101074 + insert_check_size_overflow(stmt, LT_EXPR, cast_rhs, type_min, before, true);
101075 +}
101076 +
101077 +static bool is_a_constant_overflow(const_gimple stmt, const_tree rhs)
101078 +{
101079 + if (gimple_assign_rhs_code(stmt) == MIN_EXPR)
101080 + return false;
101081 + if (!is_gimple_constant(rhs))
101082 + return false;
101083 + return true;
101084 +}
101085 +
101086 +static tree get_def_stmt_rhs(const_tree var)
101087 +{
101088 + tree rhs1, def_stmt_rhs1;
101089 + gimple rhs1_def_stmt, def_stmt_rhs1_def_stmt, def_stmt;
101090 +
101091 + def_stmt = get_def_stmt(var);
101092 + gcc_assert(gimple_code(def_stmt) != GIMPLE_NOP && gimple_plf(def_stmt, MY_STMT) && gimple_assign_cast_p(def_stmt));
101093 +
101094 + rhs1 = gimple_assign_rhs1(def_stmt);
101095 + rhs1_def_stmt = get_def_stmt(rhs1);
101096 + if (!gimple_assign_cast_p(rhs1_def_stmt))
101097 + return rhs1;
101098 +
101099 + def_stmt_rhs1 = gimple_assign_rhs1(rhs1_def_stmt);
101100 + def_stmt_rhs1_def_stmt = get_def_stmt(def_stmt_rhs1);
101101 +
101102 + switch (gimple_code(def_stmt_rhs1_def_stmt)) {
101103 + case GIMPLE_CALL:
101104 + case GIMPLE_NOP:
101105 + case GIMPLE_ASM:
101106 + case GIMPLE_PHI:
101107 + return def_stmt_rhs1;
101108 + case GIMPLE_ASSIGN:
101109 + return rhs1;
101110 + default:
101111 + debug_gimple_stmt(def_stmt_rhs1_def_stmt);
101112 + gcc_unreachable();
101113 + }
101114 +}
101115 +
101116 +static tree handle_intentional_overflow(struct pointer_set_t *visited, bool check_overflow, gimple stmt, tree change_rhs, tree new_rhs2)
101117 +{
101118 + tree new_rhs, orig_rhs;
101119 + void (*gimple_assign_set_rhs)(gimple, tree);
101120 + tree rhs1 = gimple_assign_rhs1(stmt);
101121 + tree rhs2 = gimple_assign_rhs2(stmt);
101122 + tree lhs = gimple_get_lhs(stmt);
101123 +
101124 + if (!check_overflow)
101125 + return create_assign(visited, stmt, lhs, AFTER_STMT);
101126 +
101127 + if (change_rhs == NULL_TREE)
101128 + return create_assign(visited, stmt, lhs, AFTER_STMT);
101129 +
101130 + if (new_rhs2 == NULL_TREE) {
101131 + orig_rhs = rhs1;
101132 + gimple_assign_set_rhs = &gimple_assign_set_rhs1;
101133 + } else {
101134 + orig_rhs = rhs2;
101135 + gimple_assign_set_rhs = &gimple_assign_set_rhs2;
101136 + }
101137 +
101138 + check_size_overflow(stmt, TREE_TYPE(change_rhs), change_rhs, orig_rhs, BEFORE_STMT);
101139 +
101140 + new_rhs = change_assign_rhs(stmt, orig_rhs, change_rhs);
101141 + gimple_assign_set_rhs(stmt, new_rhs);
101142 + update_stmt(stmt);
101143 +
101144 + return create_assign(visited, stmt, lhs, AFTER_STMT);
101145 +}
101146 +
101147 +static bool is_subtraction_special(const_gimple stmt)
101148 +{
101149 + gimple rhs1_def_stmt, rhs2_def_stmt;
101150 + const_tree rhs1_def_stmt_rhs1, rhs2_def_stmt_rhs1, rhs1_def_stmt_lhs, rhs2_def_stmt_lhs;
101151 + enum machine_mode rhs1_def_stmt_rhs1_mode, rhs2_def_stmt_rhs1_mode, rhs1_def_stmt_lhs_mode, rhs2_def_stmt_lhs_mode;
101152 + const_tree rhs1 = gimple_assign_rhs1(stmt);
101153 + const_tree rhs2 = gimple_assign_rhs2(stmt);
101154 +
101155 + if (is_gimple_constant(rhs1) || is_gimple_constant(rhs2))
101156 + return false;
101157 +
101158 + gcc_assert(TREE_CODE(rhs1) == SSA_NAME && TREE_CODE(rhs2) == SSA_NAME);
101159 +
101160 + if (gimple_assign_rhs_code(stmt) != MINUS_EXPR)
101161 + return false;
101162 +
101163 + rhs1_def_stmt = get_def_stmt(rhs1);
101164 + rhs2_def_stmt = get_def_stmt(rhs2);
101165 + if (!gimple_assign_cast_p(rhs1_def_stmt) || !gimple_assign_cast_p(rhs2_def_stmt))
101166 + return false;
101167 +
101168 + rhs1_def_stmt_rhs1 = gimple_assign_rhs1(rhs1_def_stmt);
101169 + rhs2_def_stmt_rhs1 = gimple_assign_rhs1(rhs2_def_stmt);
101170 + rhs1_def_stmt_lhs = gimple_get_lhs(rhs1_def_stmt);
101171 + rhs2_def_stmt_lhs = gimple_get_lhs(rhs2_def_stmt);
101172 + rhs1_def_stmt_rhs1_mode = TYPE_MODE(TREE_TYPE(rhs1_def_stmt_rhs1));
101173 + rhs2_def_stmt_rhs1_mode = TYPE_MODE(TREE_TYPE(rhs2_def_stmt_rhs1));
101174 + rhs1_def_stmt_lhs_mode = TYPE_MODE(TREE_TYPE(rhs1_def_stmt_lhs));
101175 + rhs2_def_stmt_lhs_mode = TYPE_MODE(TREE_TYPE(rhs2_def_stmt_lhs));
101176 + if (GET_MODE_BITSIZE(rhs1_def_stmt_rhs1_mode) <= GET_MODE_BITSIZE(rhs1_def_stmt_lhs_mode))
101177 + return false;
101178 + if (GET_MODE_BITSIZE(rhs2_def_stmt_rhs1_mode) <= GET_MODE_BITSIZE(rhs2_def_stmt_lhs_mode))
101179 + return false;
101180 +
101181 + gimple_set_plf(rhs1_def_stmt, NO_CAST_CHECK, true);
101182 + gimple_set_plf(rhs2_def_stmt, NO_CAST_CHECK, true);
101183 + return true;
101184 +}
101185 +
101186 +static tree handle_integer_truncation(struct pointer_set_t *visited, const_tree lhs)
101187 +{
101188 + tree new_rhs1, new_rhs2;
101189 + tree new_rhs1_def_stmt_rhs1, new_rhs2_def_stmt_rhs1, new_lhs;
101190 + gimple assign, stmt = get_def_stmt(lhs);
101191 + tree rhs1 = gimple_assign_rhs1(stmt);
101192 + tree rhs2 = gimple_assign_rhs2(stmt);
101193 +
101194 + if (!is_subtraction_special(stmt))
101195 + return NULL_TREE;
101196 +
101197 + new_rhs1 = expand(visited, rhs1);
101198 + new_rhs2 = expand(visited, rhs2);
101199 +
101200 + new_rhs1_def_stmt_rhs1 = get_def_stmt_rhs(new_rhs1);
101201 + new_rhs2_def_stmt_rhs1 = get_def_stmt_rhs(new_rhs2);
101202 +
101203 + if (!types_compatible_p(TREE_TYPE(new_rhs1_def_stmt_rhs1), TREE_TYPE(new_rhs2_def_stmt_rhs1))) {
101204 + new_rhs1_def_stmt_rhs1 = cast_to_TI_type(stmt, new_rhs1_def_stmt_rhs1);
101205 + new_rhs2_def_stmt_rhs1 = cast_to_TI_type(stmt, new_rhs2_def_stmt_rhs1);
101206 + }
101207 +
101208 + assign = create_binary_assign(MINUS_EXPR, stmt, new_rhs1_def_stmt_rhs1, new_rhs2_def_stmt_rhs1);
101209 + new_lhs = gimple_get_lhs(assign);
101210 + check_size_overflow(assign, TREE_TYPE(new_lhs), new_lhs, rhs1, AFTER_STMT);
101211 +
101212 + return dup_assign(visited, stmt, lhs, new_rhs1, new_rhs2, NULL_TREE);
101213 +}
101214 +
101215 +static bool is_a_neg_overflow(const_gimple stmt, const_tree rhs)
101216 +{
101217 + const_gimple def_stmt;
101218 +
101219 + if (TREE_CODE(rhs) != SSA_NAME)
101220 + return false;
101221 +
101222 + if (gimple_assign_rhs_code(stmt) != PLUS_EXPR)
101223 + return false;
101224 +
101225 + def_stmt = get_def_stmt(rhs);
101226 + if (gimple_code(def_stmt) != GIMPLE_ASSIGN || gimple_assign_rhs_code(def_stmt) != BIT_NOT_EXPR)
101227 + return false;
101228 +
101229 + return true;
101230 +}
101231 +
101232 +static tree handle_binary_ops(struct pointer_set_t *visited, tree lhs)
101233 +{
101234 + tree rhs1, rhs2, new_lhs;
101235 + gimple def_stmt = get_def_stmt(lhs);
101236 + tree new_rhs1 = NULL_TREE;
101237 + tree new_rhs2 = NULL_TREE;
101238 +
101239 + rhs1 = gimple_assign_rhs1(def_stmt);
101240 + rhs2 = gimple_assign_rhs2(def_stmt);
101241 +
101242 + /* no DImode/TImode division in the 32/64 bit kernel */
101243 + switch (gimple_assign_rhs_code(def_stmt)) {
101244 + case RDIV_EXPR:
101245 + case TRUNC_DIV_EXPR:
101246 + case CEIL_DIV_EXPR:
101247 + case FLOOR_DIV_EXPR:
101248 + case ROUND_DIV_EXPR:
101249 + case TRUNC_MOD_EXPR:
101250 + case CEIL_MOD_EXPR:
101251 + case FLOOR_MOD_EXPR:
101252 + case ROUND_MOD_EXPR:
101253 + case EXACT_DIV_EXPR:
101254 + case POINTER_PLUS_EXPR:
101255 + case BIT_AND_EXPR:
101256 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
101257 + default:
101258 + break;
101259 + }
101260 +
101261 + new_lhs = handle_integer_truncation(visited, lhs);
101262 + if (new_lhs != NULL_TREE)
101263 + return new_lhs;
101264 +
101265 + if (TREE_CODE(rhs1) == SSA_NAME)
101266 + new_rhs1 = expand(visited, rhs1);
101267 + if (TREE_CODE(rhs2) == SSA_NAME)
101268 + new_rhs2 = expand(visited, rhs2);
101269 +
101270 + if (is_a_neg_overflow(def_stmt, rhs2))
101271 + return handle_intentional_overflow(visited, true, def_stmt, new_rhs1, NULL_TREE);
101272 + if (is_a_neg_overflow(def_stmt, rhs1))
101273 + return handle_intentional_overflow(visited, true, def_stmt, new_rhs2, new_rhs2);
101274 +
101275 +
101276 + if (is_a_constant_overflow(def_stmt, rhs2))
101277 + return handle_intentional_overflow(visited, !is_a_cast_and_const_overflow(rhs1), def_stmt, new_rhs1, NULL_TREE);
101278 + if (is_a_constant_overflow(def_stmt, rhs1))
101279 + return handle_intentional_overflow(visited, !is_a_cast_and_const_overflow(rhs2), def_stmt, new_rhs2, new_rhs2);
101280 +
101281 + return dup_assign(visited, def_stmt, lhs, new_rhs1, new_rhs2, NULL_TREE);
101282 +}
101283 +
101284 +#if BUILDING_GCC_VERSION >= 4007
101285 +static tree get_new_rhs(struct pointer_set_t *visited, tree size_overflow_type, tree rhs)
101286 +{
101287 + if (is_gimple_constant(rhs))
101288 + return cast_a_tree(size_overflow_type, rhs);
101289 + if (TREE_CODE(rhs) != SSA_NAME)
101290 + return NULL_TREE;
101291 + return expand(visited, rhs);
101292 +}
101293 +
101294 +static tree handle_ternary_ops(struct pointer_set_t *visited, tree lhs)
101295 +{
101296 + tree rhs1, rhs2, rhs3, new_rhs1, new_rhs2, new_rhs3, size_overflow_type;
101297 + gimple def_stmt = get_def_stmt(lhs);
101298 +
101299 + size_overflow_type = get_size_overflow_type(def_stmt, lhs);
101300 +
101301 + rhs1 = gimple_assign_rhs1(def_stmt);
101302 + rhs2 = gimple_assign_rhs2(def_stmt);
101303 + rhs3 = gimple_assign_rhs3(def_stmt);
101304 + new_rhs1 = get_new_rhs(visited, size_overflow_type, rhs1);
101305 + new_rhs2 = get_new_rhs(visited, size_overflow_type, rhs2);
101306 + new_rhs3 = get_new_rhs(visited, size_overflow_type, rhs3);
101307 +
101308 + return dup_assign(visited, def_stmt, lhs, new_rhs1, new_rhs2, new_rhs3);
101309 +}
101310 +#endif
101311 +
101312 +static tree get_size_overflow_type(gimple stmt, const_tree node)
101313 +{
101314 + const_tree type;
101315 + tree new_type;
101316 +
101317 + gcc_assert(node != NULL_TREE);
101318 +
101319 + type = TREE_TYPE(node);
101320 +
101321 + if (gimple_plf(stmt, MY_STMT))
101322 + return TREE_TYPE(node);
101323 +
101324 + switch (TYPE_MODE(type)) {
101325 + case QImode:
101326 + new_type = intHI_type_node;
101327 + break;
101328 + case HImode:
101329 + new_type = intSI_type_node;
101330 + break;
101331 + case SImode:
101332 + new_type = intDI_type_node;
101333 + break;
101334 + case DImode:
101335 + if (LONG_TYPE_SIZE == GET_MODE_BITSIZE(SImode))
101336 + new_type = intDI_type_node;
101337 + else
101338 + new_type = intTI_type_node;
101339 + break;
101340 + default:
101341 + debug_tree((tree)node);
101342 + error("%s: unsupported gcc configuration.", __func__);
101343 + gcc_unreachable();
101344 + }
101345 +
101346 + if (TYPE_QUALS(type) != 0)
101347 + return build_qualified_type(new_type, TYPE_QUALS(type));
101348 + return new_type;
101349 +}
101350 +
101351 +static tree expand_visited(gimple def_stmt)
101352 +{
101353 + const_gimple next_stmt;
101354 + gimple_stmt_iterator gsi;
101355 + enum gimple_code code = gimple_code(def_stmt);
101356 +
101357 + if (code == GIMPLE_ASM)
101358 + return NULL_TREE;
101359 +
101360 + gsi = gsi_for_stmt(def_stmt);
101361 + gsi_next(&gsi);
101362 +
101363 + if (gimple_code(def_stmt) == GIMPLE_PHI && gsi_end_p(gsi))
101364 + return NULL_TREE;
101365 + gcc_assert(!gsi_end_p(gsi));
101366 + next_stmt = gsi_stmt(gsi);
101367 +
101368 + if (gimple_code(def_stmt) == GIMPLE_PHI && !gimple_plf((gimple)next_stmt, MY_STMT))
101369 + return NULL_TREE;
101370 + gcc_assert(gimple_plf((gimple)next_stmt, MY_STMT));
101371 +
101372 + return get_lhs(next_stmt);
101373 +}
101374 +
101375 +static tree expand(struct pointer_set_t *visited, tree lhs)
101376 +{
101377 + gimple def_stmt;
101378 +
101379 + if (skip_types(lhs))
101380 + return NULL_TREE;
101381 +
101382 + def_stmt = get_def_stmt(lhs);
101383 +
101384 + if (!def_stmt || gimple_code(def_stmt) == GIMPLE_NOP)
101385 + return NULL_TREE;
101386 +
101387 + if (gimple_plf(def_stmt, MY_STMT))
101388 + return lhs;
101389 +
101390 + if (pointer_set_contains(visited, def_stmt))
101391 + return expand_visited(def_stmt);
101392 +
101393 + switch (gimple_code(def_stmt)) {
101394 + case GIMPLE_PHI:
101395 + return handle_phi(visited, lhs);
101396 + case GIMPLE_CALL:
101397 + case GIMPLE_ASM:
101398 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
101399 + case GIMPLE_ASSIGN:
101400 + switch (gimple_num_ops(def_stmt)) {
101401 + case 2:
101402 + return handle_unary_ops(visited, def_stmt);
101403 + case 3:
101404 + return handle_binary_ops(visited, lhs);
101405 +#if BUILDING_GCC_VERSION >= 4007
101406 + case 4:
101407 + return handle_ternary_ops(visited, lhs);
101408 +#endif
101409 + }
101410 + default:
101411 + debug_gimple_stmt(def_stmt);
101412 + error("%s: unknown gimple code", __func__);
101413 + gcc_unreachable();
101414 + }
101415 +}
101416 +
101417 +static tree get_new_tree(gimple stmt, const_tree orig_node, tree new_node)
101418 +{
101419 + const_gimple assign;
101420 + tree orig_type = TREE_TYPE(orig_node);
101421 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
101422 +
101423 + assign = build_cast_stmt(orig_type, new_node, CREATE_NEW_VAR, &gsi, BEFORE_STMT, false);
101424 + return gimple_get_lhs(assign);
101425 +}
101426 +
101427 +static void change_function_arg(gimple stmt, const_tree orig_arg, unsigned int argnum, tree new_arg)
101428 +{
101429 + gimple_call_set_arg(stmt, argnum, get_new_tree(stmt, orig_arg, new_arg));
101430 + update_stmt(stmt);
101431 +}
101432 +
101433 +static void change_function_return(gimple stmt, const_tree orig_ret, tree new_ret)
101434 +{
101435 + gimple_return_set_retval(stmt, get_new_tree(stmt, orig_ret, new_ret));
101436 + update_stmt(stmt);
101437 +}
101438 +
101439 +static bool get_function_arg(unsigned int* argnum, const_tree fndecl)
101440 +{
101441 + tree arg;
101442 + const_tree origarg;
101443 +
101444 + if (!DECL_ABSTRACT_ORIGIN(fndecl))
101445 + return true;
101446 +
101447 + origarg = DECL_ARGUMENTS(DECL_ABSTRACT_ORIGIN(fndecl));
101448 + while (origarg && *argnum) {
101449 + (*argnum)--;
101450 + origarg = TREE_CHAIN(origarg);
101451 + }
101452 +
101453 + gcc_assert(*argnum == 0);
101454 +
101455 + gcc_assert(origarg != NULL_TREE);
101456 + *argnum = 0;
101457 + for (arg = DECL_ARGUMENTS(fndecl); arg; arg = TREE_CHAIN(arg), (*argnum)++)
101458 + if (operand_equal_p(origarg, arg, 0) || !strcmp(NAME(origarg), NAME(arg)))
101459 + return true;
101460 + return false;
101461 +}
101462 +
101463 +static enum mark walk_phi(struct pointer_set_t *visited, bool *search_err_code, const_tree result)
101464 +{
101465 + gimple phi = get_def_stmt(result);
101466 + unsigned int i, n = gimple_phi_num_args(phi);
101467 +
101468 + if (!phi)
101469 + return MARK_NO;
101470 +
101471 + pointer_set_insert(visited, phi);
101472 + for (i = 0; i < n; i++) {
101473 + enum mark marked;
101474 + const_tree arg = gimple_phi_arg_def(phi, i);
101475 + marked = pre_expand(visited, search_err_code, arg);
101476 + if (marked != MARK_NO)
101477 + return marked;
101478 + }
101479 + return MARK_NO;
101480 +}
101481 +
101482 +static enum mark walk_unary_ops(struct pointer_set_t *visited, bool *search_err_code, const_tree lhs)
101483 +{
101484 + gimple def_stmt = get_def_stmt(lhs);
101485 + const_tree rhs;
101486 +
101487 + if (!def_stmt)
101488 + return MARK_NO;
101489 +
101490 + rhs = gimple_assign_rhs1(def_stmt);
101491 +
101492 + def_stmt = get_def_stmt(rhs);
101493 + if (is_gimple_constant(rhs))
101494 + search_err_code[FROM_CONST] = true;
101495 +
101496 + return pre_expand(visited, search_err_code, rhs);
101497 +}
101498 +
101499 +static enum mark walk_binary_ops(struct pointer_set_t *visited, bool *search_err_code, const_tree lhs)
101500 +{
101501 + gimple def_stmt = get_def_stmt(lhs);
101502 + const_tree rhs1, rhs2;
101503 + enum mark marked;
101504 +
101505 + if (!def_stmt)
101506 + return MARK_NO;
101507 +
101508 + search_err_code[CAST_ONLY] = false;
101509 +
101510 + rhs1 = gimple_assign_rhs1(def_stmt);
101511 + rhs2 = gimple_assign_rhs2(def_stmt);
101512 + marked = pre_expand(visited, search_err_code, rhs1);
101513 + if (marked != MARK_NO)
101514 + return marked;
101515 + return pre_expand(visited, search_err_code, rhs2);
101516 +}
101517 +
101518 +static const_tree search_field_decl(const_tree comp_ref)
101519 +{
101520 + const_tree field = NULL_TREE;
101521 + unsigned int i, len = TREE_OPERAND_LENGTH(comp_ref);
101522 +
101523 + for (i = 0; i < len; i++) {
101524 + field = TREE_OPERAND(comp_ref, i);
101525 + if (TREE_CODE(field) == FIELD_DECL)
101526 + break;
101527 + }
101528 + gcc_assert(TREE_CODE(field) == FIELD_DECL);
101529 + return field;
101530 +}
101531 +
101532 +static enum mark mark_status(const_tree fndecl, unsigned int argnum)
101533 +{
101534 + const_tree attr, p;
101535 +
101536 + // 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);
101537 + if (fndecl == NULL_TREE)
101538 + return MARK_NO;
101539 +
101540 + attr = lookup_attribute("intentional_overflow", DECL_ATTRIBUTES(fndecl));
101541 + if (!attr || !TREE_VALUE(attr))
101542 + return MARK_NO;
101543 +
101544 + p = TREE_VALUE(attr);
101545 + if (TREE_INT_CST_HIGH(TREE_VALUE(p)) == -1)
101546 + return MARK_TURN_OFF;
101547 + if (!TREE_INT_CST_LOW(TREE_VALUE(p)))
101548 + return MARK_NOT_INTENTIONAL;
101549 + if (argnum == 0) {
101550 + gcc_assert(current_function_decl == fndecl);
101551 + return MARK_NO;
101552 + }
101553 +
101554 + do {
101555 + if (argnum == TREE_INT_CST_LOW(TREE_VALUE(p)))
101556 + return MARK_YES;
101557 + p = TREE_CHAIN(p);
101558 + } while (p);
101559 +
101560 + return MARK_NO;
101561 +}
101562 +
101563 +static void print_missing_msg(tree func, unsigned int argnum)
101564 +{
101565 + unsigned int new_hash;
101566 + size_t len;
101567 + unsigned char tree_codes[CODES_LIMIT];
101568 + location_t loc;
101569 + const char *curfunc;
101570 +
101571 + func = get_original_function_decl(func);
101572 + loc = DECL_SOURCE_LOCATION(func);
101573 + curfunc = get_asm_name(func);
101574 +
101575 + len = get_function_decl(func, tree_codes);
101576 + new_hash = get_hash_num(curfunc, (const char *) tree_codes, len, 0);
101577 + inform(loc, "Function %s is missing from the size_overflow hash table +%s+%u+%u+", curfunc, curfunc, argnum, new_hash);
101578 +}
101579 +
101580 +static unsigned int search_missing_attribute(const_tree arg)
101581 +{
101582 + unsigned int argnum;
101583 + const struct size_overflow_hash *hash;
101584 + const_tree type = TREE_TYPE(arg);
101585 + tree func = get_original_function_decl(current_function_decl);
101586 +
101587 + gcc_assert(TREE_CODE(arg) != COMPONENT_REF);
101588 +
101589 + if (TREE_CODE(type) == POINTER_TYPE)
101590 + return 0;
101591 +
101592 + argnum = find_arg_number(arg, func);
101593 + if (argnum == 0)
101594 + return 0;
101595 +
101596 + if (lookup_attribute("size_overflow", DECL_ATTRIBUTES(func)))
101597 + return argnum;
101598 +
101599 + hash = get_function_hash(func);
101600 + if (!hash || !(hash->param & (1U << argnum))) {
101601 + print_missing_msg(func, argnum);
101602 + return 0;
101603 + }
101604 + return argnum;
101605 +}
101606 +
101607 +static enum mark is_already_marked(const_tree lhs)
101608 +{
101609 + unsigned int argnum;
101610 + const_tree fndecl;
101611 +
101612 + argnum = search_missing_attribute(lhs);
101613 + fndecl = get_original_function_decl(current_function_decl);
101614 + if (argnum && mark_status(fndecl, argnum) == MARK_YES)
101615 + return MARK_YES;
101616 + return MARK_NO;
101617 +}
101618 +
101619 +static enum mark pre_expand(struct pointer_set_t *visited, bool *search_err_code, const_tree lhs)
101620 +{
101621 + const_gimple def_stmt;
101622 +
101623 + if (skip_types(lhs))
101624 + return MARK_NO;
101625 +
101626 + if (TREE_CODE(lhs) == PARM_DECL)
101627 + return is_already_marked(lhs);
101628 +
101629 + if (TREE_CODE(lhs) == COMPONENT_REF) {
101630 + const_tree field, attr;
101631 +
101632 + field = search_field_decl(lhs);
101633 + attr = lookup_attribute("intentional_overflow", DECL_ATTRIBUTES(field));
101634 + if (!attr || !TREE_VALUE(attr))
101635 + return MARK_NO;
101636 + return MARK_YES;
101637 + }
101638 +
101639 + def_stmt = get_def_stmt(lhs);
101640 +
101641 + if (!def_stmt)
101642 + return MARK_NO;
101643 +
101644 + if (pointer_set_contains(visited, def_stmt))
101645 + return MARK_NO;
101646 +
101647 + switch (gimple_code(def_stmt)) {
101648 + case GIMPLE_NOP:
101649 + if (TREE_CODE(SSA_NAME_VAR(lhs)) == PARM_DECL)
101650 + return is_already_marked(lhs);
101651 + return MARK_NO;
101652 + case GIMPLE_PHI:
101653 + return walk_phi(visited, search_err_code, lhs);
101654 + case GIMPLE_CALL:
101655 + if (mark_status((gimple_call_fndecl(def_stmt)), 0) == MARK_TURN_OFF)
101656 + return MARK_TURN_OFF;
101657 + check_function_hash(def_stmt);
101658 + return MARK_NO;
101659 + case GIMPLE_ASM:
101660 + search_err_code[CAST_ONLY] = false;
101661 + return MARK_NO;
101662 + case GIMPLE_ASSIGN:
101663 + switch (gimple_num_ops(def_stmt)) {
101664 + case 2:
101665 + return walk_unary_ops(visited, search_err_code, lhs);
101666 + case 3:
101667 + return walk_binary_ops(visited, search_err_code, lhs);
101668 + }
101669 + default:
101670 + debug_gimple_stmt((gimple)def_stmt);
101671 + error("%s: unknown gimple code", __func__);
101672 + gcc_unreachable();
101673 + }
101674 +}
101675 +
101676 +// e.g., 3.8.2, 64, arch/x86/ia32/ia32_signal.c copy_siginfo_from_user32(): compat_ptr() u32 max
101677 +static bool skip_asm(const_tree arg)
101678 +{
101679 + gimple def_stmt = get_def_stmt(arg);
101680 +
101681 + if (!def_stmt || !gimple_assign_cast_p(def_stmt))
101682 + return false;
101683 +
101684 + def_stmt = get_def_stmt(gimple_assign_rhs1(def_stmt));
101685 + return def_stmt && gimple_code(def_stmt) == GIMPLE_ASM;
101686 +}
101687 +
101688 +/*
101689 +0</MARK_YES: no dup, search attributes (so, int)
101690 +0/MARK_NOT_INTENTIONAL: no dup, search attribute (int)
101691 +-1/MARK_TURN_OFF: no dup, no search, current_function_decl -> no dup
101692 +*/
101693 +
101694 +static bool search_attributes(tree fndecl, const_tree arg, unsigned int argnum, bool where)
101695 +{
101696 + struct pointer_set_t *visited;
101697 + enum mark is_marked, is_found;
101698 + location_t loc;
101699 + bool search_err_code[2] = {true, false};
101700 +
101701 + is_marked = mark_status(current_function_decl, 0);
101702 + if (is_marked == MARK_TURN_OFF)
101703 + return true;
101704 +
101705 + is_marked = mark_status(fndecl, argnum + 1);
101706 + if (is_marked == MARK_TURN_OFF || is_marked == MARK_NOT_INTENTIONAL)
101707 + return true;
101708 +
101709 + visited = pointer_set_create();
101710 + is_found = pre_expand(visited, search_err_code, arg);
101711 + pointer_set_destroy(visited);
101712 +
101713 + if (where == FROM_RET && search_err_code[CAST_ONLY] && search_err_code[FROM_CONST])
101714 + return true;
101715 +
101716 + if (where == FROM_ARG && skip_asm(arg))
101717 + return true;
101718 +
101719 + if (is_found == MARK_TURN_OFF)
101720 + return true;
101721 +
101722 + if ((is_found == MARK_YES && is_marked == MARK_YES))
101723 + return true;
101724 +
101725 + if (is_found == MARK_YES) {
101726 + loc = DECL_SOURCE_LOCATION(fndecl);
101727 + inform(loc, "The intentional_overflow attribute is missing from +%s+%u+", get_asm_name(fndecl), argnum + 1);
101728 + return true;
101729 + }
101730 + return false;
101731 +}
101732 +
101733 +static void handle_function_arg(gimple stmt, tree fndecl, unsigned int argnum)
101734 +{
101735 + struct pointer_set_t *visited;
101736 + tree arg, new_arg;
101737 + bool match;
101738 +
101739 + if (argnum == 0)
101740 + return;
101741 +
101742 + argnum--;
101743 +
101744 + match = get_function_arg(&argnum, fndecl);
101745 + if (!match)
101746 + return;
101747 + gcc_assert(gimple_call_num_args(stmt) > argnum);
101748 + arg = gimple_call_arg(stmt, argnum);
101749 + if (arg == NULL_TREE)
101750 + return;
101751 +
101752 + if (skip_types(arg))
101753 + return;
101754 +
101755 + if (search_attributes(fndecl, arg, argnum, FROM_ARG))
101756 + return;
101757 +
101758 + visited = pointer_set_create();
101759 + new_arg = expand(visited, arg);
101760 + pointer_set_destroy(visited);
101761 +
101762 + if (new_arg == NULL_TREE)
101763 + return;
101764 +
101765 + change_function_arg(stmt, arg, argnum, new_arg);
101766 + check_size_overflow(stmt, TREE_TYPE(new_arg), new_arg, arg, BEFORE_STMT);
101767 +}
101768 +
101769 +static void handle_function_by_attribute(gimple stmt, const_tree attr, tree fndecl)
101770 +{
101771 + tree p = TREE_VALUE(attr);
101772 + do {
101773 + handle_function_arg(stmt, fndecl, TREE_INT_CST_LOW(TREE_VALUE(p)));
101774 + p = TREE_CHAIN(p);
101775 + } while (p);
101776 +}
101777 +
101778 +static void handle_function_by_hash(gimple stmt, tree fndecl)
101779 +{
101780 + unsigned int num;
101781 + const struct size_overflow_hash *hash;
101782 +
101783 + hash = get_function_hash(fndecl);
101784 + if (!hash)
101785 + return;
101786 +
101787 + for (num = 0; num <= MAX_PARAM; num++)
101788 + if (hash->param & (1U << num))
101789 + handle_function_arg(stmt, fndecl, num);
101790 +}
101791 +
101792 +static bool check_return_value(void)
101793 +{
101794 + const struct size_overflow_hash *hash;
101795 +
101796 + hash = get_function_hash(current_function_decl);
101797 + if (!hash || !(hash->param & 1U << 0))
101798 + return false;
101799 +
101800 + return true;
101801 +}
101802 +
101803 +static void handle_return_value(gimple ret_stmt)
101804 +{
101805 + struct pointer_set_t *visited;
101806 + tree ret, new_ret;
101807 +
101808 + if (gimple_code(ret_stmt) != GIMPLE_RETURN)
101809 + return;
101810 +
101811 + ret = gimple_return_retval(ret_stmt);
101812 +
101813 + if (skip_types(ret))
101814 + return;
101815 +
101816 + if (search_attributes(current_function_decl, ret, 0, FROM_RET))
101817 + return;
101818 +
101819 + visited = pointer_set_create();
101820 + new_ret = expand(visited, ret);
101821 + pointer_set_destroy(visited);
101822 +
101823 + change_function_return(ret_stmt, ret, new_ret);
101824 + check_size_overflow(ret_stmt, TREE_TYPE(new_ret), new_ret, ret, BEFORE_STMT);
101825 +}
101826 +
101827 +static void set_plf_false(void)
101828 +{
101829 + basic_block bb;
101830 +
101831 + FOR_ALL_BB(bb) {
101832 + gimple_stmt_iterator si;
101833 +
101834 + for (si = gsi_start_bb(bb); !gsi_end_p(si); gsi_next(&si))
101835 + gimple_set_plf(gsi_stmt(si), MY_STMT, false);
101836 + for (si = gsi_start_phis(bb); !gsi_end_p(si); gsi_next(&si))
101837 + gimple_set_plf(gsi_stmt(si), MY_STMT, false);
101838 + }
101839 +}
101840 +
101841 +static unsigned int handle_function(void)
101842 +{
101843 + basic_block next, bb = ENTRY_BLOCK_PTR->next_bb;
101844 + bool check_ret;
101845 +
101846 + set_plf_false();
101847 +
101848 + check_ret = check_return_value();
101849 +
101850 + do {
101851 + gimple_stmt_iterator gsi;
101852 + next = bb->next_bb;
101853 +
101854 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
101855 + tree fndecl, attr;
101856 + gimple stmt = gsi_stmt(gsi);
101857 +
101858 + if (check_ret)
101859 + handle_return_value(stmt);
101860 +
101861 + if (!(is_gimple_call(stmt)))
101862 + continue;
101863 + fndecl = gimple_call_fndecl(stmt);
101864 + if (fndecl == NULL_TREE)
101865 + continue;
101866 + if (gimple_call_num_args(stmt) == 0)
101867 + continue;
101868 + attr = lookup_attribute("size_overflow", DECL_ATTRIBUTES(fndecl));
101869 + if (!attr || !TREE_VALUE(attr))
101870 + handle_function_by_hash(stmt, fndecl);
101871 + else
101872 + handle_function_by_attribute(stmt, attr, fndecl);
101873 + gsi = gsi_for_stmt(stmt);
101874 + next = gimple_bb(stmt)->next_bb;
101875 + }
101876 + bb = next;
101877 + } while (bb);
101878 + return 0;
101879 +}
101880 +
101881 +static struct gimple_opt_pass size_overflow_pass = {
101882 + .pass = {
101883 + .type = GIMPLE_PASS,
101884 + .name = "size_overflow",
101885 +#if BUILDING_GCC_VERSION >= 4008
101886 + .optinfo_flags = OPTGROUP_NONE,
101887 +#endif
101888 + .gate = NULL,
101889 + .execute = handle_function,
101890 + .sub = NULL,
101891 + .next = NULL,
101892 + .static_pass_number = 0,
101893 + .tv_id = TV_NONE,
101894 + .properties_required = PROP_cfg,
101895 + .properties_provided = 0,
101896 + .properties_destroyed = 0,
101897 + .todo_flags_start = 0,
101898 + .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
101899 + }
101900 +};
101901 +
101902 +static void start_unit_callback(void __unused *gcc_data, void __unused *user_data)
101903 +{
101904 + tree fntype;
101905 +
101906 + const_char_ptr_type_node = build_pointer_type(build_type_variant(char_type_node, 1, 0));
101907 +
101908 + // void report_size_overflow(const char *loc_file, unsigned int loc_line, const char *current_func, const char *ssa_var)
101909 + fntype = build_function_type_list(void_type_node,
101910 + const_char_ptr_type_node,
101911 + unsigned_type_node,
101912 + const_char_ptr_type_node,
101913 + const_char_ptr_type_node,
101914 + NULL_TREE);
101915 + report_size_overflow_decl = build_fn_decl("report_size_overflow", fntype);
101916 +
101917 + DECL_ASSEMBLER_NAME(report_size_overflow_decl);
101918 + TREE_PUBLIC(report_size_overflow_decl) = 1;
101919 + DECL_EXTERNAL(report_size_overflow_decl) = 1;
101920 + DECL_ARTIFICIAL(report_size_overflow_decl) = 1;
101921 + TREE_THIS_VOLATILE(report_size_overflow_decl) = 1;
101922 +}
101923 +
101924 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
101925 +{
101926 + int i;
101927 + const char * const plugin_name = plugin_info->base_name;
101928 + const int argc = plugin_info->argc;
101929 + const struct plugin_argument * const argv = plugin_info->argv;
101930 + bool enable = true;
101931 +
101932 + struct register_pass_info size_overflow_pass_info = {
101933 + .pass = &size_overflow_pass.pass,
101934 + .reference_pass_name = "ssa",
101935 + .ref_pass_instance_number = 1,
101936 + .pos_op = PASS_POS_INSERT_AFTER
101937 + };
101938 +
101939 + if (!plugin_default_version_check(version, &gcc_version)) {
101940 + error(G_("incompatible gcc/plugin versions"));
101941 + return 1;
101942 + }
101943 +
101944 + for (i = 0; i < argc; ++i) {
101945 + if (!strcmp(argv[i].key, "no-size-overflow")) {
101946 + enable = false;
101947 + continue;
101948 + }
101949 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
101950 + }
101951 +
101952 + register_callback(plugin_name, PLUGIN_INFO, NULL, &size_overflow_plugin_info);
101953 + if (enable) {
101954 + register_callback("start_unit", PLUGIN_START_UNIT, &start_unit_callback, NULL);
101955 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &size_overflow_pass_info);
101956 + }
101957 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
101958 +
101959 + return 0;
101960 +}
101961 diff --git a/tools/gcc/stackleak_plugin.c b/tools/gcc/stackleak_plugin.c
101962 new file mode 100644
101963 index 0000000..ac2901e
101964 --- /dev/null
101965 +++ b/tools/gcc/stackleak_plugin.c
101966 @@ -0,0 +1,327 @@
101967 +/*
101968 + * Copyright 2011-2013 by the PaX Team <pageexec@freemail.hu>
101969 + * Licensed under the GPL v2
101970 + *
101971 + * Note: the choice of the license means that the compilation process is
101972 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
101973 + * but for the kernel it doesn't matter since it doesn't link against
101974 + * any of the gcc libraries
101975 + *
101976 + * gcc plugin to help implement various PaX features
101977 + *
101978 + * - track lowest stack pointer
101979 + *
101980 + * TODO:
101981 + * - initialize all local variables
101982 + *
101983 + * BUGS:
101984 + * - none known
101985 + */
101986 +#include "gcc-plugin.h"
101987 +#include "config.h"
101988 +#include "system.h"
101989 +#include "coretypes.h"
101990 +#include "tree.h"
101991 +#include "tree-pass.h"
101992 +#include "flags.h"
101993 +#include "intl.h"
101994 +#include "toplev.h"
101995 +#include "plugin.h"
101996 +//#include "expr.h" where are you...
101997 +#include "diagnostic.h"
101998 +#include "plugin-version.h"
101999 +#include "tm.h"
102000 +#include "function.h"
102001 +#include "basic-block.h"
102002 +#include "gimple.h"
102003 +#include "rtl.h"
102004 +#include "emit-rtl.h"
102005 +
102006 +#if BUILDING_GCC_VERSION >= 4008
102007 +#define TODO_dump_func 0
102008 +#endif
102009 +
102010 +extern void print_gimple_stmt(FILE *, gimple, int, int);
102011 +
102012 +int plugin_is_GPL_compatible;
102013 +
102014 +static int track_frame_size = -1;
102015 +static const char track_function[] = "pax_track_stack";
102016 +static const char check_function[] = "pax_check_alloca";
102017 +static bool init_locals;
102018 +
102019 +static struct plugin_info stackleak_plugin_info = {
102020 + .version = "201302112000",
102021 + .help = "track-lowest-sp=nn\ttrack sp in functions whose frame size is at least nn bytes\n"
102022 +// "initialize-locals\t\tforcibly initialize all stack frames\n"
102023 +};
102024 +
102025 +static bool gate_stackleak_track_stack(void);
102026 +static unsigned int execute_stackleak_tree_instrument(void);
102027 +static unsigned int execute_stackleak_final(void);
102028 +
102029 +static struct gimple_opt_pass stackleak_tree_instrument_pass = {
102030 + .pass = {
102031 + .type = GIMPLE_PASS,
102032 + .name = "stackleak_tree_instrument",
102033 +#if BUILDING_GCC_VERSION >= 4008
102034 + .optinfo_flags = OPTGROUP_NONE,
102035 +#endif
102036 + .gate = gate_stackleak_track_stack,
102037 + .execute = execute_stackleak_tree_instrument,
102038 + .sub = NULL,
102039 + .next = NULL,
102040 + .static_pass_number = 0,
102041 + .tv_id = TV_NONE,
102042 + .properties_required = PROP_gimple_leh | PROP_cfg,
102043 + .properties_provided = 0,
102044 + .properties_destroyed = 0,
102045 + .todo_flags_start = 0, //TODO_verify_ssa | TODO_verify_flow | TODO_verify_stmts,
102046 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_update_ssa
102047 + }
102048 +};
102049 +
102050 +static struct rtl_opt_pass stackleak_final_rtl_opt_pass = {
102051 + .pass = {
102052 + .type = RTL_PASS,
102053 + .name = "stackleak_final",
102054 +#if BUILDING_GCC_VERSION >= 4008
102055 + .optinfo_flags = OPTGROUP_NONE,
102056 +#endif
102057 + .gate = gate_stackleak_track_stack,
102058 + .execute = execute_stackleak_final,
102059 + .sub = NULL,
102060 + .next = NULL,
102061 + .static_pass_number = 0,
102062 + .tv_id = TV_NONE,
102063 + .properties_required = 0,
102064 + .properties_provided = 0,
102065 + .properties_destroyed = 0,
102066 + .todo_flags_start = 0,
102067 + .todo_flags_finish = TODO_dump_func
102068 + }
102069 +};
102070 +
102071 +static bool gate_stackleak_track_stack(void)
102072 +{
102073 + return track_frame_size >= 0;
102074 +}
102075 +
102076 +static void stackleak_check_alloca(gimple_stmt_iterator *gsi)
102077 +{
102078 + gimple check_alloca;
102079 + tree fntype, fndecl, alloca_size;
102080 +
102081 + fntype = build_function_type_list(void_type_node, long_unsigned_type_node, NULL_TREE);
102082 + fndecl = build_fn_decl(check_function, fntype);
102083 + DECL_ASSEMBLER_NAME(fndecl); // for LTO
102084 +
102085 + // insert call to void pax_check_alloca(unsigned long size)
102086 + alloca_size = gimple_call_arg(gsi_stmt(*gsi), 0);
102087 + check_alloca = gimple_build_call(fndecl, 1, alloca_size);
102088 + gsi_insert_before(gsi, check_alloca, GSI_SAME_STMT);
102089 +}
102090 +
102091 +static void stackleak_add_instrumentation(gimple_stmt_iterator *gsi)
102092 +{
102093 + gimple track_stack;
102094 + tree fntype, fndecl;
102095 +
102096 + fntype = build_function_type_list(void_type_node, NULL_TREE);
102097 + fndecl = build_fn_decl(track_function, fntype);
102098 + DECL_ASSEMBLER_NAME(fndecl); // for LTO
102099 +
102100 + // insert call to void pax_track_stack(void)
102101 + track_stack = gimple_build_call(fndecl, 0);
102102 + gsi_insert_after(gsi, track_stack, GSI_CONTINUE_LINKING);
102103 +}
102104 +
102105 +#if BUILDING_GCC_VERSION == 4005
102106 +static bool gimple_call_builtin_p(gimple stmt, enum built_in_function code)
102107 +{
102108 + tree fndecl;
102109 +
102110 + if (!is_gimple_call(stmt))
102111 + return false;
102112 + fndecl = gimple_call_fndecl(stmt);
102113 + if (!fndecl)
102114 + return false;
102115 + if (DECL_BUILT_IN_CLASS(fndecl) != BUILT_IN_NORMAL)
102116 + return false;
102117 +// print_node(stderr, "pax", fndecl, 4);
102118 + return DECL_FUNCTION_CODE(fndecl) == code;
102119 +}
102120 +#endif
102121 +
102122 +static bool is_alloca(gimple stmt)
102123 +{
102124 + if (gimple_call_builtin_p(stmt, BUILT_IN_ALLOCA))
102125 + return true;
102126 +
102127 +#if BUILDING_GCC_VERSION >= 4007
102128 + if (gimple_call_builtin_p(stmt, BUILT_IN_ALLOCA_WITH_ALIGN))
102129 + return true;
102130 +#endif
102131 +
102132 + return false;
102133 +}
102134 +
102135 +static unsigned int execute_stackleak_tree_instrument(void)
102136 +{
102137 + basic_block bb, entry_bb;
102138 + bool prologue_instrumented = false, is_leaf = true;
102139 +
102140 + entry_bb = ENTRY_BLOCK_PTR_FOR_FUNCTION(cfun)->next_bb;
102141 +
102142 + // 1. loop through BBs and GIMPLE statements
102143 + FOR_EACH_BB(bb) {
102144 + gimple_stmt_iterator gsi;
102145 +
102146 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
102147 + gimple stmt;
102148 +
102149 + stmt = gsi_stmt(gsi);
102150 +
102151 + if (is_gimple_call(stmt))
102152 + is_leaf = false;
102153 +
102154 + // gimple match: align 8 built-in BUILT_IN_NORMAL:BUILT_IN_ALLOCA attributes <tree_list 0xb7576450>
102155 + if (!is_alloca(stmt))
102156 + continue;
102157 +
102158 + // 2. insert stack overflow check before each __builtin_alloca call
102159 + stackleak_check_alloca(&gsi);
102160 +
102161 + // 3. insert track call after each __builtin_alloca call
102162 + stackleak_add_instrumentation(&gsi);
102163 + if (bb == entry_bb)
102164 + prologue_instrumented = true;
102165 + }
102166 + }
102167 +
102168 + // special cases for some bad linux code: taking the address of static inline functions will materialize them
102169 + // but we mustn't instrument some of them as the resulting stack alignment required by the function call ABI
102170 + // will break other assumptions regarding the expected (but not otherwise enforced) register clobbering ABI.
102171 + // case in point: native_save_fl on amd64 when optimized for size clobbers rdx if it were instrumented here.
102172 + if (is_leaf && !TREE_PUBLIC(current_function_decl) && DECL_DECLARED_INLINE_P(current_function_decl))
102173 + return 0;
102174 + if (is_leaf && !strncmp(IDENTIFIER_POINTER(DECL_NAME(current_function_decl)), "_paravirt_", 10))
102175 + return 0;
102176 +
102177 + // 4. insert track call at the beginning
102178 + if (!prologue_instrumented) {
102179 + gimple_stmt_iterator gsi;
102180 +
102181 + bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
102182 + if (dom_info_available_p(CDI_DOMINATORS))
102183 + set_immediate_dominator(CDI_DOMINATORS, bb, ENTRY_BLOCK_PTR);
102184 + gsi = gsi_start_bb(bb);
102185 + stackleak_add_instrumentation(&gsi);
102186 + }
102187 +
102188 + return 0;
102189 +}
102190 +
102191 +static unsigned int execute_stackleak_final(void)
102192 +{
102193 + rtx insn, next;
102194 +
102195 + if (cfun->calls_alloca)
102196 + return 0;
102197 +
102198 + // keep calls only if function frame is big enough
102199 + if (get_frame_size() >= track_frame_size)
102200 + return 0;
102201 +
102202 + // 1. find pax_track_stack calls
102203 + for (insn = get_insns(); insn; insn = next) {
102204 + // 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))
102205 + rtx body;
102206 +
102207 + next = NEXT_INSN(insn);
102208 + if (!CALL_P(insn))
102209 + continue;
102210 + body = PATTERN(insn);
102211 + if (GET_CODE(body) != CALL)
102212 + continue;
102213 + body = XEXP(body, 0);
102214 + if (GET_CODE(body) != MEM)
102215 + continue;
102216 + body = XEXP(body, 0);
102217 + if (GET_CODE(body) != SYMBOL_REF)
102218 + continue;
102219 + if (strcmp(XSTR(body, 0), track_function))
102220 + continue;
102221 +// warning(0, "track_frame_size: %d %ld %d", cfun->calls_alloca, get_frame_size(), track_frame_size);
102222 + // 2. delete call
102223 + delete_insn_and_edges(insn);
102224 +#if BUILDING_GCC_VERSION >= 4007
102225 + if (GET_CODE(next) == NOTE && NOTE_KIND(next) == NOTE_INSN_CALL_ARG_LOCATION) {
102226 + insn = next;
102227 + next = NEXT_INSN(insn);
102228 + delete_insn_and_edges(insn);
102229 + }
102230 +#endif
102231 + }
102232 +
102233 +// print_simple_rtl(stderr, get_insns());
102234 +// print_rtl(stderr, get_insns());
102235 +// warning(0, "track_frame_size: %d %ld %d", cfun->calls_alloca, get_frame_size(), track_frame_size);
102236 +
102237 + return 0;
102238 +}
102239 +
102240 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
102241 +{
102242 + const char * const plugin_name = plugin_info->base_name;
102243 + const int argc = plugin_info->argc;
102244 + const struct plugin_argument * const argv = plugin_info->argv;
102245 + int i;
102246 + struct register_pass_info stackleak_tree_instrument_pass_info = {
102247 + .pass = &stackleak_tree_instrument_pass.pass,
102248 +// .reference_pass_name = "tree_profile",
102249 + .reference_pass_name = "optimized",
102250 + .ref_pass_instance_number = 1,
102251 + .pos_op = PASS_POS_INSERT_BEFORE
102252 + };
102253 + struct register_pass_info stackleak_final_pass_info = {
102254 + .pass = &stackleak_final_rtl_opt_pass.pass,
102255 + .reference_pass_name = "final",
102256 + .ref_pass_instance_number = 1,
102257 + .pos_op = PASS_POS_INSERT_BEFORE
102258 + };
102259 +
102260 + if (!plugin_default_version_check(version, &gcc_version)) {
102261 + error(G_("incompatible gcc/plugin versions"));
102262 + return 1;
102263 + }
102264 +
102265 + register_callback(plugin_name, PLUGIN_INFO, NULL, &stackleak_plugin_info);
102266 +
102267 + for (i = 0; i < argc; ++i) {
102268 + if (!strcmp(argv[i].key, "track-lowest-sp")) {
102269 + if (!argv[i].value) {
102270 + error(G_("no value supplied for option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
102271 + continue;
102272 + }
102273 + track_frame_size = atoi(argv[i].value);
102274 + if (argv[i].value[0] < '0' || argv[i].value[0] > '9' || track_frame_size < 0)
102275 + error(G_("invalid option argument '-fplugin-arg-%s-%s=%s'"), plugin_name, argv[i].key, argv[i].value);
102276 + continue;
102277 + }
102278 + if (!strcmp(argv[i].key, "initialize-locals")) {
102279 + if (argv[i].value) {
102280 + error(G_("invalid option argument '-fplugin-arg-%s-%s=%s'"), plugin_name, argv[i].key, argv[i].value);
102281 + continue;
102282 + }
102283 + init_locals = true;
102284 + continue;
102285 + }
102286 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
102287 + }
102288 +
102289 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &stackleak_tree_instrument_pass_info);
102290 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &stackleak_final_pass_info);
102291 +
102292 + return 0;
102293 +}
102294 diff --git a/tools/perf/util/include/asm/alternative-asm.h b/tools/perf/util/include/asm/alternative-asm.h
102295 index 6789d78..4afd019e 100644
102296 --- a/tools/perf/util/include/asm/alternative-asm.h
102297 +++ b/tools/perf/util/include/asm/alternative-asm.h
102298 @@ -5,4 +5,7 @@
102299
102300 #define altinstruction_entry #
102301
102302 + .macro pax_force_retaddr rip=0, reload=0
102303 + .endm
102304 +
102305 #endif
102306 diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
102307 index 1cd693a..f4a7b20 100644
102308 --- a/virt/kvm/kvm_main.c
102309 +++ b/virt/kvm/kvm_main.c
102310 @@ -75,12 +75,17 @@ LIST_HEAD(vm_list);
102311
102312 static cpumask_var_t cpus_hardware_enabled;
102313 static int kvm_usage_count = 0;
102314 -static atomic_t hardware_enable_failed;
102315 +static atomic_unchecked_t hardware_enable_failed;
102316
102317 struct kmem_cache *kvm_vcpu_cache;
102318 EXPORT_SYMBOL_GPL(kvm_vcpu_cache);
102319
102320 -static __read_mostly struct preempt_ops kvm_preempt_ops;
102321 +static void kvm_sched_in(struct preempt_notifier *pn, int cpu);
102322 +static void kvm_sched_out(struct preempt_notifier *pn, struct task_struct *next);
102323 +static struct preempt_ops kvm_preempt_ops = {
102324 + .sched_in = kvm_sched_in,
102325 + .sched_out = kvm_sched_out,
102326 +};
102327
102328 struct dentry *kvm_debugfs_dir;
102329
102330 @@ -731,7 +736,7 @@ int __kvm_set_memory_region(struct kvm *kvm,
102331 /* We can read the guest memory with __xxx_user() later on. */
102332 if (user_alloc &&
102333 ((mem->userspace_addr & (PAGE_SIZE - 1)) ||
102334 - !access_ok(VERIFY_WRITE,
102335 + !__access_ok(VERIFY_WRITE,
102336 (void __user *)(unsigned long)mem->userspace_addr,
102337 mem->memory_size)))
102338 goto out;
102339 @@ -1783,7 +1788,7 @@ static int kvm_vcpu_release(struct inode *inode, struct file *filp)
102340 return 0;
102341 }
102342
102343 -static struct file_operations kvm_vcpu_fops = {
102344 +static file_operations_no_const kvm_vcpu_fops __read_only = {
102345 .release = kvm_vcpu_release,
102346 .unlocked_ioctl = kvm_vcpu_ioctl,
102347 #ifdef CONFIG_COMPAT
102348 @@ -2304,7 +2309,7 @@ static int kvm_vm_mmap(struct file *file, struct vm_area_struct *vma)
102349 return 0;
102350 }
102351
102352 -static struct file_operations kvm_vm_fops = {
102353 +static file_operations_no_const kvm_vm_fops __read_only = {
102354 .release = kvm_vm_release,
102355 .unlocked_ioctl = kvm_vm_ioctl,
102356 #ifdef CONFIG_COMPAT
102357 @@ -2402,7 +2407,7 @@ out:
102358 return r;
102359 }
102360
102361 -static struct file_operations kvm_chardev_ops = {
102362 +static file_operations_no_const kvm_chardev_ops __read_only = {
102363 .unlocked_ioctl = kvm_dev_ioctl,
102364 .compat_ioctl = kvm_dev_ioctl,
102365 .llseek = noop_llseek,
102366 @@ -2428,7 +2433,7 @@ static void hardware_enable_nolock(void *junk)
102367
102368 if (r) {
102369 cpumask_clear_cpu(cpu, cpus_hardware_enabled);
102370 - atomic_inc(&hardware_enable_failed);
102371 + atomic_inc_unchecked(&hardware_enable_failed);
102372 printk(KERN_INFO "kvm: enabling virtualization on "
102373 "CPU%d failed\n", cpu);
102374 }
102375 @@ -2482,10 +2487,10 @@ static int hardware_enable_all(void)
102376
102377 kvm_usage_count++;
102378 if (kvm_usage_count == 1) {
102379 - atomic_set(&hardware_enable_failed, 0);
102380 + atomic_set_unchecked(&hardware_enable_failed, 0);
102381 on_each_cpu(hardware_enable_nolock, NULL, 1);
102382
102383 - if (atomic_read(&hardware_enable_failed)) {
102384 + if (atomic_read_unchecked(&hardware_enable_failed)) {
102385 hardware_disable_all_nolock();
102386 r = -EBUSY;
102387 }
102388 @@ -2843,7 +2848,7 @@ static void kvm_sched_out(struct preempt_notifier *pn,
102389 kvm_arch_vcpu_put(vcpu);
102390 }
102391
102392 -int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
102393 +int kvm_init(const void *opaque, unsigned vcpu_size, unsigned vcpu_align,
102394 struct module *module)
102395 {
102396 int r;
102397 @@ -2879,7 +2884,7 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
102398 if (!vcpu_align)
102399 vcpu_align = __alignof__(struct kvm_vcpu);
102400 kvm_vcpu_cache = kmem_cache_create("kvm_vcpu", vcpu_size, vcpu_align,
102401 - 0, NULL);
102402 + SLAB_USERCOPY, NULL);
102403 if (!kvm_vcpu_cache) {
102404 r = -ENOMEM;
102405 goto out_free_3;
102406 @@ -2889,9 +2894,11 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
102407 if (r)
102408 goto out_free;
102409
102410 + pax_open_kernel();
102411 kvm_chardev_ops.owner = module;
102412 kvm_vm_fops.owner = module;
102413 kvm_vcpu_fops.owner = module;
102414 + pax_close_kernel();
102415
102416 r = misc_register(&kvm_dev);
102417 if (r) {
102418 @@ -2901,9 +2908,6 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
102419
102420 register_syscore_ops(&kvm_syscore_ops);
102421
102422 - kvm_preempt_ops.sched_in = kvm_sched_in;
102423 - kvm_preempt_ops.sched_out = kvm_sched_out;
102424 -
102425 r = kvm_init_debug();
102426 if (r) {
102427 printk(KERN_ERR "kvm: create debugfs files failed\n");